@inappstory/slide-api 0.0.20 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +428 -168
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +132 -25
- package/dist/index.d.ts +132 -25
- package/dist/index.js +428 -168
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1202,6 +1202,8 @@ class WidgetBase {
|
|
|
1202
1202
|
localData = null;
|
|
1203
1203
|
firstOpenTime = 0;
|
|
1204
1204
|
id;
|
|
1205
|
+
startReadyPromise = null;
|
|
1206
|
+
startReadyResolve = null;
|
|
1205
1207
|
constructor(element, options, elementIdGetter, slideGetter) {
|
|
1206
1208
|
this.options = extend({}, this.constructor.DEFAULTS, options);
|
|
1207
1209
|
this.element = element;
|
|
@@ -1253,8 +1255,32 @@ class WidgetBase {
|
|
|
1253
1255
|
this.localData = extend({}, this.savedData ?? {}, this.options.localData ?? {});
|
|
1254
1256
|
this.id = `w_${this.elementId}_${WidgetBase.widgetIndex}`;
|
|
1255
1257
|
++WidgetBase.widgetIndex;
|
|
1258
|
+
this.resetStartReadyPromise();
|
|
1256
1259
|
}
|
|
1257
|
-
|
|
1260
|
+
resetStartReadyPromise() {
|
|
1261
|
+
this.startReadyPromise = new Promise(resolve => {
|
|
1262
|
+
this.startReadyResolve = resolve;
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* Start or restart widget
|
|
1267
|
+
* @param localData
|
|
1268
|
+
*/
|
|
1269
|
+
onRefreshUserData(localData) {
|
|
1270
|
+
this.savedData = this.sdkApi.getCardServerData(this.cardId);
|
|
1271
|
+
this.localData = extend({}, this.savedData ?? {}, localData);
|
|
1272
|
+
}
|
|
1273
|
+
onStart() {
|
|
1274
|
+
// add active class for enable animation
|
|
1275
|
+
this.element.classList.add("active");
|
|
1276
|
+
this.startReadyResolve();
|
|
1277
|
+
}
|
|
1278
|
+
onStop() {
|
|
1279
|
+
this.element.classList.remove("active");
|
|
1280
|
+
this.resetStartReadyPromise();
|
|
1281
|
+
}
|
|
1282
|
+
onPause() { }
|
|
1283
|
+
onResume() { }
|
|
1258
1284
|
static widgetCacheKey = "ias.story-element";
|
|
1259
1285
|
static widgetClassName = "";
|
|
1260
1286
|
static getInstance(element) {
|
|
@@ -1284,19 +1310,23 @@ class WidgetBase {
|
|
|
1284
1310
|
}
|
|
1285
1311
|
static initWidget(htmlElement, localData, instantiate) {
|
|
1286
1312
|
if (localData != null) {
|
|
1287
|
-
this.createInstance(instantiate, htmlElement, {
|
|
1313
|
+
const widget = this.createInstance(instantiate, htmlElement, {
|
|
1288
1314
|
slide: null,
|
|
1289
1315
|
localData,
|
|
1290
1316
|
});
|
|
1317
|
+
// start widget (just created or cached instance)
|
|
1318
|
+
widget.onRefreshUserData(localData);
|
|
1291
1319
|
return Promise.resolve(localData);
|
|
1292
1320
|
}
|
|
1293
1321
|
else {
|
|
1294
1322
|
return new Promise(resolve => {
|
|
1295
1323
|
this.getLocalData().then(localData => {
|
|
1296
|
-
this.createInstance(instantiate, htmlElement, {
|
|
1324
|
+
const widget = this.createInstance(instantiate, htmlElement, {
|
|
1297
1325
|
slide: null,
|
|
1298
1326
|
localData,
|
|
1299
1327
|
});
|
|
1328
|
+
// start widget (just created or cached instance)
|
|
1329
|
+
widget.onRefreshUserData(localData);
|
|
1300
1330
|
resolve(localData);
|
|
1301
1331
|
});
|
|
1302
1332
|
});
|
|
@@ -1306,10 +1336,12 @@ class WidgetBase {
|
|
|
1306
1336
|
static initWidgets(instantiate, elements, localData) {
|
|
1307
1337
|
if (localData != null) {
|
|
1308
1338
|
forEach(elements, element => {
|
|
1309
|
-
this.createInstance(instantiate, element, {
|
|
1339
|
+
const widget = this.createInstance(instantiate, element, {
|
|
1310
1340
|
slide: null,
|
|
1311
1341
|
localData,
|
|
1312
1342
|
});
|
|
1343
|
+
// start widget (just created or cached instance)
|
|
1344
|
+
widget.onRefreshUserData(localData);
|
|
1313
1345
|
});
|
|
1314
1346
|
return Promise.resolve(localData);
|
|
1315
1347
|
}
|
|
@@ -1317,10 +1349,12 @@ class WidgetBase {
|
|
|
1317
1349
|
return new Promise(resolve => {
|
|
1318
1350
|
this.getLocalData().then(localData => {
|
|
1319
1351
|
forEach(elements, element => {
|
|
1320
|
-
this.createInstance(instantiate, element, {
|
|
1352
|
+
const widget = this.createInstance(instantiate, element, {
|
|
1321
1353
|
slide: null,
|
|
1322
1354
|
localData,
|
|
1323
1355
|
});
|
|
1356
|
+
// start widget (just created or cached instance)
|
|
1357
|
+
widget.onRefreshUserData(localData);
|
|
1324
1358
|
});
|
|
1325
1359
|
resolve(localData);
|
|
1326
1360
|
});
|
|
@@ -1400,7 +1434,7 @@ class WidgetBase {
|
|
|
1400
1434
|
startDisabledTimeline() {
|
|
1401
1435
|
this.sdkApi.startDisabledTimeline(this.cardId, this.slideIndex);
|
|
1402
1436
|
}
|
|
1403
|
-
|
|
1437
|
+
_showLayer(layers, selectIndex, withStatEvent = false) {
|
|
1404
1438
|
if (this.sdkApi.isExistsShowLayer()) {
|
|
1405
1439
|
this.sdkApi.showLayer(selectIndex);
|
|
1406
1440
|
}
|
|
@@ -1509,7 +1543,6 @@ class WidgetCopy extends WidgetBase {
|
|
|
1509
1543
|
this.button = this.element.querySelector(".narrative-element-text-lines");
|
|
1510
1544
|
this.clipboardTarget = getTagData(element, "clipboardTarget");
|
|
1511
1545
|
this.isPromotionalCode = getTagData(element, "clipboardType") === "promocode";
|
|
1512
|
-
this.state = null;
|
|
1513
1546
|
this.msgNetworkError = getTagData(this.element, "msgNetworkError");
|
|
1514
1547
|
this.msgServiceError = getTagData(this.element, "msgServiceError");
|
|
1515
1548
|
this.msgNoMoreCodes = getTagData(this.element, "msgNoMoreCodes");
|
|
@@ -1538,12 +1571,31 @@ class WidgetCopy extends WidgetBase {
|
|
|
1538
1571
|
this.resultLayerGeometry.style.setProperty("left", newResultLayerGeometryLeft + "px");
|
|
1539
1572
|
}
|
|
1540
1573
|
}
|
|
1574
|
+
}
|
|
1575
|
+
/**
|
|
1576
|
+
* Start or restart widget
|
|
1577
|
+
* @param localData
|
|
1578
|
+
*/
|
|
1579
|
+
onRefreshUserData(localData) {
|
|
1580
|
+
super.onRefreshUserData(localData);
|
|
1581
|
+
// return DOM to init state (ready to copy)
|
|
1582
|
+
this.element.classList.remove("done");
|
|
1583
|
+
if (this.resultLayer) {
|
|
1584
|
+
this.resultLayer.classList.remove("done");
|
|
1585
|
+
}
|
|
1586
|
+
this.state = null;
|
|
1587
|
+
if (this.isPromotionalCode) {
|
|
1588
|
+
this.initPromotionalCodeFromLocalData();
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
onStart() {
|
|
1592
|
+
super.onStart();
|
|
1593
|
+
// add active class for enable animation
|
|
1594
|
+
this.resultLayer?.classList.add("active");
|
|
1541
1595
|
if (this.isPromotionalCode) {
|
|
1542
1596
|
this.fetchPromoCode();
|
|
1543
1597
|
}
|
|
1544
|
-
// this.onRefreshUserData(this.options.localData);
|
|
1545
1598
|
}
|
|
1546
|
-
onRefreshUserData(localData) { }
|
|
1547
1599
|
isTransparentElement() {
|
|
1548
1600
|
if (this.element) {
|
|
1549
1601
|
try {
|
|
@@ -1563,16 +1615,22 @@ class WidgetCopy extends WidgetBase {
|
|
|
1563
1615
|
this.button.textContent = newText;
|
|
1564
1616
|
}
|
|
1565
1617
|
}
|
|
1566
|
-
|
|
1567
|
-
this.
|
|
1568
|
-
|
|
1618
|
+
getPromotionalCodeFromLocalData() {
|
|
1619
|
+
return this.localData["_cp_g_" + this.elementId + "_pc"];
|
|
1620
|
+
}
|
|
1621
|
+
initPromotionalCodeFromLocalData() {
|
|
1622
|
+
if (this.getPromotionalCodeFromLocalData() !== undefined) {
|
|
1569
1623
|
this.state = 1;
|
|
1570
|
-
this.clipboardTarget = this.
|
|
1624
|
+
this.clipboardTarget = this.getPromotionalCodeFromLocalData();
|
|
1571
1625
|
if (this.clipboardTarget != null) {
|
|
1572
1626
|
this.changeText(this.clipboardTarget);
|
|
1573
1627
|
}
|
|
1574
1628
|
removeClass(this.element, "loader");
|
|
1575
1629
|
}
|
|
1630
|
+
}
|
|
1631
|
+
fetchPromoCode() {
|
|
1632
|
+
this.state = 0;
|
|
1633
|
+
this.initPromotionalCodeFromLocalData();
|
|
1576
1634
|
if (this.state === 0) {
|
|
1577
1635
|
if (!this.isTransparentElement()) {
|
|
1578
1636
|
// for transparent element
|
|
@@ -1660,12 +1718,14 @@ class WidgetCopy extends WidgetBase {
|
|
|
1660
1718
|
if (this.resultLayer) {
|
|
1661
1719
|
this.resultLayer.classList.add("done");
|
|
1662
1720
|
}
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1721
|
+
this.startReadyPromise.then(() => {
|
|
1722
|
+
if (this.disableTimer) {
|
|
1723
|
+
// флаг - что таймер уже стартанул (в layout или добавить объект sharedMemory)
|
|
1724
|
+
// смотрим что прозрачный текст - тогда и лоадер прозрачный
|
|
1725
|
+
// _log("_showNarrativeNextSlide: " + getSlideDuration(this.narrativeId, this.slideIndex), true);
|
|
1726
|
+
this.startDisabledTimeline();
|
|
1727
|
+
}
|
|
1728
|
+
});
|
|
1669
1729
|
}
|
|
1670
1730
|
copyToClipboard(element) {
|
|
1671
1731
|
this._select();
|
|
@@ -1699,6 +1759,13 @@ class WidgetCopy extends WidgetBase {
|
|
|
1699
1759
|
// prevent initWidget for result layer
|
|
1700
1760
|
const elements = slice.call(nodeList).filter(element => !element.classList.contains("narrative-element-copy-result-variant"));
|
|
1701
1761
|
WidgetCopy.initWidgets((element, options) => new WidgetCopy(element, options), elements, localData);
|
|
1762
|
+
elements.forEach(element => WidgetCopy.getInstance(element)?.onStart());
|
|
1763
|
+
},
|
|
1764
|
+
onStart: function (element) {
|
|
1765
|
+
WidgetCopy.getInstance(element)?.onStart();
|
|
1766
|
+
},
|
|
1767
|
+
onStop: function (element) {
|
|
1768
|
+
WidgetCopy.getInstance(element)?.onStop();
|
|
1702
1769
|
},
|
|
1703
1770
|
click: function (element) {
|
|
1704
1771
|
const widgetElement = element.closest(`.${WidgetCopy.widgetClassName}`);
|
|
@@ -1748,20 +1815,27 @@ class WidgetDataInput extends WidgetBase {
|
|
|
1748
1815
|
this.inputElement = getValueOrException(this.element.querySelector(".input-view .input"), "Empty .input-view .input");
|
|
1749
1816
|
this.textElement = getValueOrException(this.inputElement.querySelector(".narrative-element-text-lines"), "Empty .narrative-element-text-lines");
|
|
1750
1817
|
this.inputPlaceholderValue = this.textElement.innerHTML;
|
|
1751
|
-
this.onRefreshUserData(this.options.localData);
|
|
1752
1818
|
}
|
|
1819
|
+
/**
|
|
1820
|
+
* Start or restart widget
|
|
1821
|
+
* @param localData
|
|
1822
|
+
*/
|
|
1753
1823
|
onRefreshUserData(localData) {
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
const text = this.localData["_di_g_" + this.elementId + "_t"];
|
|
1824
|
+
super.onRefreshUserData(localData);
|
|
1825
|
+
const text = this.getTextFromLocalData();
|
|
1757
1826
|
this._fillUserText(text);
|
|
1758
|
-
if (text) {
|
|
1827
|
+
if (text != null) {
|
|
1759
1828
|
this.element.classList.add("done");
|
|
1760
|
-
|
|
1761
|
-
this.
|
|
1762
|
-
|
|
1829
|
+
this.startReadyPromise.then(() => {
|
|
1830
|
+
if (this.disableTimer) {
|
|
1831
|
+
this.startDisabledTimeline();
|
|
1832
|
+
}
|
|
1833
|
+
});
|
|
1763
1834
|
}
|
|
1764
1835
|
}
|
|
1836
|
+
getTextFromLocalData() {
|
|
1837
|
+
return this.localData["_di_g_" + this.elementId + "_t"];
|
|
1838
|
+
}
|
|
1765
1839
|
_statEventFocusIn() {
|
|
1766
1840
|
try {
|
|
1767
1841
|
const labelText = this.label ? this.label.textContent ?? "" : "";
|
|
@@ -1839,7 +1913,7 @@ class WidgetDataInput extends WidgetBase {
|
|
|
1839
1913
|
}
|
|
1840
1914
|
_fillUserText(text) {
|
|
1841
1915
|
if (this.inputElement && this.textElement) {
|
|
1842
|
-
if (text) {
|
|
1916
|
+
if (text != null) {
|
|
1843
1917
|
this.inputElement.classList.remove("_is-placeholder");
|
|
1844
1918
|
text = text.replace(new RegExp("\r?\n", "g"), "<br />");
|
|
1845
1919
|
this.textElement.innerHTML = text;
|
|
@@ -1889,7 +1963,15 @@ class WidgetDataInput extends WidgetBase {
|
|
|
1889
1963
|
},
|
|
1890
1964
|
/** @deprecated */
|
|
1891
1965
|
initWidget: function (nodeList, localData) {
|
|
1966
|
+
const elements = slice.call(nodeList);
|
|
1892
1967
|
WidgetDataInput.initWidgets((element, options) => new WidgetDataInput(element, options), slice.call(nodeList), localData);
|
|
1968
|
+
elements.forEach(element => WidgetDataInput.getInstance(element)?.onStart());
|
|
1969
|
+
},
|
|
1970
|
+
onStart: function (element) {
|
|
1971
|
+
WidgetDataInput.getInstance(element)?.onStart();
|
|
1972
|
+
},
|
|
1973
|
+
onStop: function (element) {
|
|
1974
|
+
WidgetDataInput.getInstance(element)?.onStop();
|
|
1893
1975
|
},
|
|
1894
1976
|
click: function (element) {
|
|
1895
1977
|
const widgetElement = element.closest(`.${WidgetDataInput.widgetClassName}`);
|
|
@@ -1920,9 +2002,9 @@ class WidgetDateCountdown extends WidgetBase {
|
|
|
1920
2002
|
label;
|
|
1921
2003
|
layers;
|
|
1922
2004
|
messages;
|
|
1923
|
-
|
|
2005
|
+
timestampMs;
|
|
1924
2006
|
diff;
|
|
1925
|
-
|
|
2007
|
+
timerInit;
|
|
1926
2008
|
pendingUpdate;
|
|
1927
2009
|
firstGroup1;
|
|
1928
2010
|
firstGroup2;
|
|
@@ -1942,52 +2024,56 @@ class WidgetDateCountdown extends WidgetBase {
|
|
|
1942
2024
|
minutes: getTagData(this.element, "tMinutes") ?? "",
|
|
1943
2025
|
seconds: getTagData(this.element, "tSeconds") ?? "",
|
|
1944
2026
|
};
|
|
1945
|
-
this.
|
|
2027
|
+
this.timestampMs = getValueOrException(getTagDataAsNumber(this.element, "timestampSeconds"), "Empty timestampSeconds") * 1000;
|
|
1946
2028
|
this.diff = 0;
|
|
1947
|
-
this.
|
|
2029
|
+
this.timerInit = false;
|
|
1948
2030
|
this.pendingUpdate = true;
|
|
1949
2031
|
this.layers = this.options.layers;
|
|
1950
|
-
// if (false) {
|
|
1951
|
-
// // if (sendApiRequestSupported()) {
|
|
1952
|
-
// // fetch project time
|
|
1953
|
-
// var path = "story/" + this.storyId + "/widget/" + this.elementId + "/timestamp";
|
|
1954
|
-
// var profileKey = "fetch-story-timestamp";
|
|
1955
|
-
// this.sdkApi
|
|
1956
|
-
// .sendApiRequest<{ timestamp: number }>(path, "GET", null, null, null, profileKey)
|
|
1957
|
-
// .then(response => {
|
|
1958
|
-
// var status = response.status;
|
|
1959
|
-
// var timestamp = null;
|
|
1960
|
-
// if (status === 200) {
|
|
1961
|
-
// if (response.data) timestamp = response.data.timestamp;
|
|
1962
|
-
// if (timestamp) {
|
|
1963
|
-
// this.diff = new Date().getTime() - timestamp * 1000;
|
|
1964
|
-
// }
|
|
1965
|
-
// }
|
|
1966
|
-
//
|
|
1967
|
-
// this.initTimer();
|
|
1968
|
-
// })
|
|
1969
|
-
// .catch( (reason)=> {
|
|
1970
|
-
// console.error(reason);
|
|
1971
|
-
// this.initTimer();
|
|
1972
|
-
// });
|
|
1973
|
-
// } else {
|
|
1974
|
-
this.initTimer();
|
|
1975
|
-
// }
|
|
1976
|
-
// this.onRefreshUserData(this.options.localData);
|
|
1977
2032
|
}
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
2033
|
+
/**
|
|
2034
|
+
* Start or restart widget
|
|
2035
|
+
* @param localData
|
|
2036
|
+
*/
|
|
2037
|
+
onRefreshUserData(localData) {
|
|
2038
|
+
super.onRefreshUserData(localData);
|
|
2039
|
+
const value = this.timestampMs - (new Date().getTime() - this.diff);
|
|
2040
|
+
if (value > 0) {
|
|
2041
|
+
this._showLayer(this.layers, 0);
|
|
2042
|
+
}
|
|
2043
|
+
else {
|
|
2044
|
+
this._showLayer(this.layers, 1);
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
onPause() {
|
|
2048
|
+
super.onPause();
|
|
2049
|
+
if (this.timerInit) {
|
|
1981
2050
|
this.pendingUpdate = false;
|
|
1982
2051
|
}
|
|
1983
2052
|
}
|
|
1984
|
-
|
|
1985
|
-
|
|
2053
|
+
onResume() {
|
|
2054
|
+
super.onResume();
|
|
2055
|
+
if (this.timerInit && !this.pendingUpdate) {
|
|
1986
2056
|
this.pendingUpdate = true;
|
|
1987
2057
|
this.updateTimer();
|
|
1988
2058
|
}
|
|
1989
2059
|
}
|
|
2060
|
+
onStart() {
|
|
2061
|
+
super.onStart();
|
|
2062
|
+
if (!this.timerInit) {
|
|
2063
|
+
this.initTimer();
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
onStop() {
|
|
2067
|
+
super.onStop();
|
|
2068
|
+
if (this.timerInit) {
|
|
2069
|
+
this.pendingUpdate = false;
|
|
2070
|
+
this.timerInit = false;
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
1990
2073
|
initTimer() {
|
|
2074
|
+
if (this.timerInit) {
|
|
2075
|
+
return;
|
|
2076
|
+
}
|
|
1991
2077
|
// find groups
|
|
1992
2078
|
this.firstGroup1 = getValueOrException(this.element.querySelector(".date-item-view-group-1 .date-output-label-1"), "Empty firstGroup1");
|
|
1993
2079
|
this.firstGroup2 = getValueOrException(this.element.querySelector(".date-item-view-group-1 .date-output-label-2"), "Empty firstGroup2");
|
|
@@ -1998,16 +2084,18 @@ class WidgetDateCountdown extends WidgetBase {
|
|
|
1998
2084
|
this.thirdGroup1 = getValueOrException(this.element.querySelector(".date-item-view-group-3 .date-output-label-1"), "Empty thirdGroup1");
|
|
1999
2085
|
this.thirdGroup2 = getValueOrException(this.element.querySelector(".date-item-view-group-3 .date-output-label-2"), "Empty thirdGroup2");
|
|
2000
2086
|
this.thirdGroupCaption = getValueOrException(this.element.querySelector(".date-item-view-group-3 .date-item-caption"), "Empty thirdGroupCaption");
|
|
2001
|
-
this.
|
|
2002
|
-
this.
|
|
2003
|
-
const value = this.timestampSeconds - (new Date().getTime() - this.diff);
|
|
2087
|
+
this.timerInit = true;
|
|
2088
|
+
const value = this.timestampMs - (new Date().getTime() - this.diff);
|
|
2004
2089
|
if (value > 0) {
|
|
2005
|
-
this.
|
|
2090
|
+
this._showLayer(this.layers, 0);
|
|
2006
2091
|
}
|
|
2007
2092
|
this.updateTimer();
|
|
2008
2093
|
}
|
|
2009
2094
|
updateTimer() {
|
|
2010
|
-
|
|
2095
|
+
if (!this.timerInit) {
|
|
2096
|
+
return;
|
|
2097
|
+
}
|
|
2098
|
+
const value = this.timestampMs - (new Date().getTime() - this.diff);
|
|
2011
2099
|
if (value > 0) {
|
|
2012
2100
|
const result = this._asDuration(Math.round(value / 1000));
|
|
2013
2101
|
if (result.days) {
|
|
@@ -2036,7 +2124,7 @@ class WidgetDateCountdown extends WidgetBase {
|
|
|
2036
2124
|
}
|
|
2037
2125
|
else {
|
|
2038
2126
|
this.pendingUpdate = false;
|
|
2039
|
-
this.
|
|
2127
|
+
this._showLayer(this.layers, 1);
|
|
2040
2128
|
}
|
|
2041
2129
|
if (this.pendingUpdate) {
|
|
2042
2130
|
this.env.requestAnimationFrame(() => this.updateTimer());
|
|
@@ -2109,24 +2197,32 @@ class WidgetDateCountdown extends WidgetBase {
|
|
|
2109
2197
|
},
|
|
2110
2198
|
/** @deprecated */
|
|
2111
2199
|
initWidget: function (nodeList, layers, localData) {
|
|
2112
|
-
|
|
2200
|
+
const elements = slice.call(nodeList);
|
|
2201
|
+
WidgetDateCountdown.initWidgets((element, options) => new WidgetDateCountdown(element, { ...options, layers }), elements, localData);
|
|
2202
|
+
elements.forEach(element => WidgetDateCountdown.getInstance(element)?.onStart());
|
|
2203
|
+
},
|
|
2204
|
+
onStart: function (element) {
|
|
2205
|
+
WidgetDateCountdown.getInstance(element)?.onStart();
|
|
2206
|
+
},
|
|
2207
|
+
onStop: function (element) {
|
|
2208
|
+
WidgetDateCountdown.getInstance(element)?.onStop();
|
|
2113
2209
|
},
|
|
2114
2210
|
onPause: function (element) {
|
|
2115
|
-
WidgetDateCountdown.getInstance(element)?.
|
|
2211
|
+
WidgetDateCountdown.getInstance(element)?.onPause();
|
|
2116
2212
|
},
|
|
2117
2213
|
onResume: function (element) {
|
|
2118
|
-
WidgetDateCountdown.getInstance(element)?.
|
|
2214
|
+
WidgetDateCountdown.getInstance(element)?.onResume();
|
|
2119
2215
|
},
|
|
2120
2216
|
/** @deprecated */
|
|
2121
2217
|
pause: function (nodeList) {
|
|
2122
2218
|
forEach(slice.call(nodeList), function (el, index) {
|
|
2123
|
-
WidgetDateCountdown.getInstance(el)?.
|
|
2219
|
+
WidgetDateCountdown.getInstance(el)?.onPause();
|
|
2124
2220
|
});
|
|
2125
2221
|
},
|
|
2126
2222
|
/** @deprecated */
|
|
2127
2223
|
resume: function (nodeList) {
|
|
2128
2224
|
forEach(slice.call(nodeList), function (el, index) {
|
|
2129
|
-
WidgetDateCountdown.getInstance(el)?.
|
|
2225
|
+
WidgetDateCountdown.getInstance(el)?.onResume();
|
|
2130
2226
|
});
|
|
2131
2227
|
},
|
|
2132
2228
|
};
|
|
@@ -2312,11 +2408,13 @@ class WidgetPoll extends WidgetBase {
|
|
|
2312
2408
|
this.getUseResponseOnFirstButton = Boolean(getTagDataAsNumber(this.element, "getUserResponseOnFirstButton"));
|
|
2313
2409
|
this.getUseResponseOnSecondButton = Boolean(getTagDataAsNumber(this.element, "getUserResponseOnSecondButton"));
|
|
2314
2410
|
this.showClientTotalResult = Boolean(getTagDataAsNumber(this.element, "showClientTotalResult"));
|
|
2315
|
-
this.onRefreshUserData(this.options.localData);
|
|
2316
2411
|
}
|
|
2412
|
+
/**
|
|
2413
|
+
* Start or restart widget
|
|
2414
|
+
* @param localData
|
|
2415
|
+
*/
|
|
2317
2416
|
onRefreshUserData(localData) {
|
|
2318
|
-
|
|
2319
|
-
this.localData = extend({}, this.savedData ?? {}, localData);
|
|
2417
|
+
super.onRefreshUserData(localData);
|
|
2320
2418
|
this.selectedVariant = undefined;
|
|
2321
2419
|
if (this.localData) {
|
|
2322
2420
|
if (this.localData["_p_g_" + this.elementId + "_sa"] !== undefined) {
|
|
@@ -2399,14 +2497,11 @@ class WidgetPoll extends WidgetBase {
|
|
|
2399
2497
|
this.element.classList.add("with-total-result");
|
|
2400
2498
|
this.displayPercents(index, filled);
|
|
2401
2499
|
}
|
|
2402
|
-
|
|
2403
|
-
this.
|
|
2404
|
-
// todo poll - если виджет на первом слайде то при повторном заходе автоматически не стартует таймлайн слайда
|
|
2405
|
-
// только в web sdk такое
|
|
2406
|
-
// если поставить через setTimeout то все ок
|
|
2500
|
+
this.startReadyPromise.then(() => {
|
|
2501
|
+
if (this.disableTimer) {
|
|
2407
2502
|
this.startDisabledTimeline();
|
|
2408
|
-
}
|
|
2409
|
-
}
|
|
2503
|
+
}
|
|
2504
|
+
});
|
|
2410
2505
|
}
|
|
2411
2506
|
_clearVariantSelection() {
|
|
2412
2507
|
forEach(this.variants, function (variant) {
|
|
@@ -2753,6 +2848,13 @@ class WidgetPoll extends WidgetBase {
|
|
|
2753
2848
|
/** @deprecated */
|
|
2754
2849
|
initWidget: function (element, localData) {
|
|
2755
2850
|
WidgetPoll.initWidgets((element, options) => new WidgetPoll(element, options), [element], localData);
|
|
2851
|
+
WidgetPoll.getInstance(element)?.onStart();
|
|
2852
|
+
},
|
|
2853
|
+
onStart: function (element) {
|
|
2854
|
+
WidgetPoll.getInstance(element)?.onStart();
|
|
2855
|
+
},
|
|
2856
|
+
onStop: function (element) {
|
|
2857
|
+
WidgetPoll.getInstance(element)?.onStop();
|
|
2756
2858
|
},
|
|
2757
2859
|
/**
|
|
2758
2860
|
* click
|
|
@@ -2821,17 +2923,22 @@ class WidgetPollLayers extends WidgetBase {
|
|
|
2821
2923
|
this.variantsTexts.push(label.textContent ?? "");
|
|
2822
2924
|
}
|
|
2823
2925
|
});
|
|
2926
|
+
}
|
|
2927
|
+
/**
|
|
2928
|
+
* Start or restart widget
|
|
2929
|
+
* @param localData
|
|
2930
|
+
*/
|
|
2931
|
+
onRefreshUserData(localData) {
|
|
2932
|
+
super.onRefreshUserData(localData);
|
|
2824
2933
|
this.selectedVariant = undefined;
|
|
2825
2934
|
if (this.slidePollIsDone()) {
|
|
2826
2935
|
this._selectVariant(this.localData["_pl_g_" + this.elementId + "_sa"]);
|
|
2827
2936
|
}
|
|
2828
2937
|
else {
|
|
2829
|
-
this.
|
|
2938
|
+
this._showLayer(this.layers, 0);
|
|
2830
2939
|
}
|
|
2831
2940
|
this.firstOpenTime = new Date().getTime();
|
|
2832
|
-
this.onRefreshUserData(this.options.localData);
|
|
2833
2941
|
}
|
|
2834
|
-
onRefreshUserData(localData) { }
|
|
2835
2942
|
_statEventPollVariant() {
|
|
2836
2943
|
try {
|
|
2837
2944
|
if (this.selectedVariant != null) {
|
|
@@ -2874,10 +2981,12 @@ class WidgetPollLayers extends WidgetBase {
|
|
|
2874
2981
|
else if (index === 1) {
|
|
2875
2982
|
layerIndex = 2;
|
|
2876
2983
|
}
|
|
2877
|
-
this.
|
|
2878
|
-
|
|
2879
|
-
this.
|
|
2880
|
-
|
|
2984
|
+
this._showLayer(this.layers, layerIndex, userAction);
|
|
2985
|
+
this.startReadyPromise.then(() => {
|
|
2986
|
+
if (this.disableTimer) {
|
|
2987
|
+
this.startDisabledTimeline();
|
|
2988
|
+
}
|
|
2989
|
+
});
|
|
2881
2990
|
}
|
|
2882
2991
|
selectVariant(variant) {
|
|
2883
2992
|
if (this.selectedVariant !== undefined) {
|
|
@@ -2934,6 +3043,13 @@ class WidgetPollLayers extends WidgetBase {
|
|
|
2934
3043
|
localData = undefined;
|
|
2935
3044
|
}
|
|
2936
3045
|
WidgetPollLayers.initWidgets((element, options) => new WidgetPollLayers(element, { ...options, layers }), [element], localData);
|
|
3046
|
+
WidgetPollLayers.getInstance(element)?.onStart();
|
|
3047
|
+
},
|
|
3048
|
+
onStart: function (element) {
|
|
3049
|
+
WidgetPollLayers.getInstance(element)?.onStart();
|
|
3050
|
+
},
|
|
3051
|
+
onStop: function (element) {
|
|
3052
|
+
WidgetPollLayers.getInstance(element)?.onStop();
|
|
2937
3053
|
},
|
|
2938
3054
|
/**
|
|
2939
3055
|
* click on poll variant
|
|
@@ -2981,9 +3097,14 @@ class WidgetQuest extends WidgetBase {
|
|
|
2981
3097
|
this.label = this.element.querySelector(".label-view .label");
|
|
2982
3098
|
this.variants = slice.call(this.element.querySelectorAll(".variants-box .variant-view"));
|
|
2983
3099
|
this.selectedAnswer = undefined;
|
|
2984
|
-
// this.onRefreshUserData(this.options.localData);
|
|
2985
3100
|
}
|
|
2986
|
-
|
|
3101
|
+
/**
|
|
3102
|
+
* Start or restart widget
|
|
3103
|
+
* @param localData
|
|
3104
|
+
*/
|
|
3105
|
+
onRefreshUserData(localData) {
|
|
3106
|
+
super.onRefreshUserData(localData);
|
|
3107
|
+
}
|
|
2987
3108
|
setCardSessionValue(name, value) {
|
|
2988
3109
|
this.sdkApi.setCardSessionValue(this.element, name, value);
|
|
2989
3110
|
}
|
|
@@ -3223,6 +3344,7 @@ class WidgetQuest extends WidgetBase {
|
|
|
3223
3344
|
});
|
|
3224
3345
|
});
|
|
3225
3346
|
},
|
|
3347
|
+
/** @deprecated */
|
|
3226
3348
|
initWidget: function (element, localData) {
|
|
3227
3349
|
return new Promise(function (resolve, reject) {
|
|
3228
3350
|
WidgetQuest.initWidgets((element, options) => new WidgetQuest(element, options), [element], localData).then(localData => {
|
|
@@ -3234,8 +3356,15 @@ class WidgetQuest extends WidgetBase {
|
|
|
3234
3356
|
resolve(true);
|
|
3235
3357
|
}
|
|
3236
3358
|
});
|
|
3359
|
+
WidgetQuest.getInstance(element)?.onStart();
|
|
3237
3360
|
});
|
|
3238
3361
|
},
|
|
3362
|
+
onStart: function (element) {
|
|
3363
|
+
WidgetQuest.getInstance(element)?.onStart();
|
|
3364
|
+
},
|
|
3365
|
+
onStop: function (element) {
|
|
3366
|
+
WidgetQuest.getInstance(element)?.onStop();
|
|
3367
|
+
},
|
|
3239
3368
|
select: function (element) {
|
|
3240
3369
|
const widgetElement = element.closest(`.${WidgetQuest.widgetClassName}`);
|
|
3241
3370
|
if (widgetElement) {
|
|
@@ -3280,11 +3409,13 @@ class WidgetQuiz extends WidgetBase {
|
|
|
3280
3409
|
this.question = this.element.querySelector(".label-view .label");
|
|
3281
3410
|
this.answers = slice.call(this.element.querySelectorAll(".variants-box .variant-view-group"));
|
|
3282
3411
|
this.questionCount = getValueOrException(getTagDataAsNumber(this.slide, "quizCount"), "Empty quizCount");
|
|
3283
|
-
this.onRefreshUserData(this.options.localData);
|
|
3284
3412
|
}
|
|
3413
|
+
/**
|
|
3414
|
+
* Start or restart widget
|
|
3415
|
+
* @param localData
|
|
3416
|
+
*/
|
|
3285
3417
|
onRefreshUserData(localData) {
|
|
3286
|
-
|
|
3287
|
-
this.localData = extend({}, this.savedData ?? {}, localData);
|
|
3418
|
+
super.onRefreshUserData(localData);
|
|
3288
3419
|
this.selectedAnswer = undefined;
|
|
3289
3420
|
if (this.localData) {
|
|
3290
3421
|
if (this.localData["_q_g_" + this.elementId + "_sa"] !== undefined) {
|
|
@@ -3327,9 +3458,11 @@ class WidgetQuiz extends WidgetBase {
|
|
|
3327
3458
|
// })
|
|
3328
3459
|
// })
|
|
3329
3460
|
// }
|
|
3330
|
-
|
|
3331
|
-
this.
|
|
3332
|
-
|
|
3461
|
+
this.startReadyPromise.then(() => {
|
|
3462
|
+
if (this.disableTimer) {
|
|
3463
|
+
this.startDisabledTimeline();
|
|
3464
|
+
}
|
|
3465
|
+
});
|
|
3333
3466
|
}
|
|
3334
3467
|
_clearAnswerSelection() {
|
|
3335
3468
|
forEach(this.answers, function (answer) {
|
|
@@ -3428,6 +3561,13 @@ class WidgetQuiz extends WidgetBase {
|
|
|
3428
3561
|
/** @deprecated */
|
|
3429
3562
|
initWidget: function (element, localData) {
|
|
3430
3563
|
WidgetQuiz.initWidgets((element, options) => new WidgetQuiz(element, options), [element], localData);
|
|
3564
|
+
WidgetQuiz.getInstance(element)?.onStart();
|
|
3565
|
+
},
|
|
3566
|
+
onStart: function (element) {
|
|
3567
|
+
WidgetQuiz.getInstance(element)?.onStart();
|
|
3568
|
+
},
|
|
3569
|
+
onStop: function (element) {
|
|
3570
|
+
WidgetQuiz.getInstance(element)?.onStop();
|
|
3431
3571
|
},
|
|
3432
3572
|
/**
|
|
3433
3573
|
* click on quiz answer
|
|
@@ -3475,11 +3615,13 @@ class WidgetQuizGrouped extends WidgetBase {
|
|
|
3475
3615
|
this.question = this.element.querySelector(".label-view .label");
|
|
3476
3616
|
this.answers = slice.call(this.element.querySelectorAll(".variants-box .variant-view-group"));
|
|
3477
3617
|
this.questionCount = getValueOrException(getTagDataAsNumber(this.slide, "quizCount"), "Empty quizCount");
|
|
3478
|
-
this.onRefreshUserData(this.options.localData);
|
|
3479
3618
|
}
|
|
3619
|
+
/**
|
|
3620
|
+
* Start or restart widget
|
|
3621
|
+
* @param localData
|
|
3622
|
+
*/
|
|
3480
3623
|
onRefreshUserData(localData) {
|
|
3481
|
-
|
|
3482
|
-
this.localData = extend({}, this.savedData ?? {}, localData);
|
|
3624
|
+
super.onRefreshUserData(localData);
|
|
3483
3625
|
this.selectedAnswer = undefined;
|
|
3484
3626
|
if (this.localData) {
|
|
3485
3627
|
if (this.localData["_q_gg_" + this.elementId + "_sa"] !== undefined) {
|
|
@@ -3509,9 +3651,11 @@ class WidgetQuizGrouped extends WidgetBase {
|
|
|
3509
3651
|
this.submitButtonAnimatedView.style.maxHeight = this.submitButtonViewHeight + "px";
|
|
3510
3652
|
}
|
|
3511
3653
|
});
|
|
3512
|
-
|
|
3513
|
-
this.
|
|
3514
|
-
|
|
3654
|
+
this.startReadyPromise.then(() => {
|
|
3655
|
+
if (this.disableTimer) {
|
|
3656
|
+
this.startDisabledTimeline();
|
|
3657
|
+
}
|
|
3658
|
+
});
|
|
3515
3659
|
}
|
|
3516
3660
|
_clearAnswerSelection() {
|
|
3517
3661
|
forEach(this.answers, function (answer) {
|
|
@@ -3627,6 +3771,13 @@ class WidgetQuizGrouped extends WidgetBase {
|
|
|
3627
3771
|
/** @deprecated */
|
|
3628
3772
|
initWidget: function (element, localData) {
|
|
3629
3773
|
WidgetQuizGrouped.initWidgets((element, options) => new WidgetQuizGrouped(element, options), [element], localData);
|
|
3774
|
+
WidgetQuizGrouped.getInstance(element)?.onStart();
|
|
3775
|
+
},
|
|
3776
|
+
onStart: function (element) {
|
|
3777
|
+
WidgetQuizGrouped.getInstance(element)?.onStart();
|
|
3778
|
+
},
|
|
3779
|
+
onStop: function (element) {
|
|
3780
|
+
WidgetQuizGrouped.getInstance(element)?.onStop();
|
|
3630
3781
|
},
|
|
3631
3782
|
/**
|
|
3632
3783
|
* click on quiz answer
|
|
@@ -3857,7 +4008,6 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
3857
4008
|
this.handleDown = proxy(this.handleDown, this);
|
|
3858
4009
|
this.handleMove = proxy(this.handleMove, this);
|
|
3859
4010
|
this.handleEnd = proxy(this.handleEnd, this);
|
|
3860
|
-
this.onRefreshUserData(this.options.localData);
|
|
3861
4011
|
// Attach Events
|
|
3862
4012
|
// window.addEventListener('resize.' + this.identifier, debounce(function() {
|
|
3863
4013
|
// // Simulate resizeEnd event.
|
|
@@ -3868,16 +4018,21 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
3868
4018
|
this.env.document.addEventListener("touchstart", this.handleDown);
|
|
3869
4019
|
this.env.document.addEventListener("mousedown", this.handleDown);
|
|
3870
4020
|
}
|
|
4021
|
+
/**
|
|
4022
|
+
* Start or restart widget
|
|
4023
|
+
* @param localData
|
|
4024
|
+
*/
|
|
3871
4025
|
onRefreshUserData(localData) {
|
|
3872
|
-
|
|
3873
|
-
this.localData = extend({}, this.savedData ?? {}, localData);
|
|
4026
|
+
super.onRefreshUserData(localData);
|
|
3874
4027
|
if (this.localData["_rs_g_" + this.elementId + "_v"] !== undefined) {
|
|
3875
4028
|
this.elementSlider.value = String(tryParseFloat(this.localData["_rs_g_" + this.elementId + "_v"], 0));
|
|
3876
4029
|
this.element.classList.add("done");
|
|
3877
4030
|
this.displayAverageAnswer();
|
|
3878
|
-
|
|
3879
|
-
this.
|
|
3880
|
-
|
|
4031
|
+
this.startReadyPromise.then(() => {
|
|
4032
|
+
if (this.disableTimer) {
|
|
4033
|
+
this.startDisabledTimeline();
|
|
4034
|
+
}
|
|
4035
|
+
});
|
|
3881
4036
|
}
|
|
3882
4037
|
else {
|
|
3883
4038
|
this.elementSlider.value = String(this.startValue);
|
|
@@ -3886,6 +4041,10 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
3886
4041
|
}
|
|
3887
4042
|
this.init();
|
|
3888
4043
|
}
|
|
4044
|
+
onStop() {
|
|
4045
|
+
super.onStop();
|
|
4046
|
+
this.destroy();
|
|
4047
|
+
}
|
|
3889
4048
|
_statEventInputSave(val) {
|
|
3890
4049
|
try {
|
|
3891
4050
|
const labelText = this.label?.textContent ?? "";
|
|
@@ -4237,11 +4396,18 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
4237
4396
|
onRefreshUserData: WidgetRangeSlider.onRefreshUserData,
|
|
4238
4397
|
init: function (element, localData) {
|
|
4239
4398
|
WidgetRangeSlider.initWidget(element, localData, (element, options) => new WidgetRangeSlider(element, options));
|
|
4399
|
+
WidgetRangeSlider.getInstance(element)?.onStart();
|
|
4240
4400
|
},
|
|
4241
4401
|
/** @deprecated */
|
|
4242
4402
|
initWidget: function (element, localData) {
|
|
4243
4403
|
WidgetRangeSlider.initWidgets((element, options) => new WidgetRangeSlider(element, options), [element], localData);
|
|
4244
4404
|
},
|
|
4405
|
+
onStart: function (element) {
|
|
4406
|
+
WidgetRangeSlider.getInstance(element)?.onStart();
|
|
4407
|
+
},
|
|
4408
|
+
onStop: function (element) {
|
|
4409
|
+
WidgetRangeSlider.getInstance(element)?.onStop();
|
|
4410
|
+
},
|
|
4245
4411
|
click: function (element) {
|
|
4246
4412
|
const widgetElement = element.closest(`.${WidgetRangeSlider.widgetClassName}`);
|
|
4247
4413
|
if (widgetElement) {
|
|
@@ -4296,11 +4462,13 @@ class WidgetRate extends WidgetBase {
|
|
|
4296
4462
|
this.showDialogOnLowRate = Boolean(getValueOrDefault(getTagDataAsNumber(this.element, "showDialogOnLowRate"), 0));
|
|
4297
4463
|
this.showDialogueMin = getValueOrDefault(getTagDataAsNumber(this.element, "showDialogueMin"), 1);
|
|
4298
4464
|
this.showDialogueMax = getValueOrDefault(getTagDataAsNumber(this.element, "showDialogueMax"), 3);
|
|
4299
|
-
this.onRefreshUserData(this.options.localData);
|
|
4300
4465
|
}
|
|
4466
|
+
/**
|
|
4467
|
+
* Start or restart widget
|
|
4468
|
+
* @param localData
|
|
4469
|
+
*/
|
|
4301
4470
|
onRefreshUserData(localData) {
|
|
4302
|
-
|
|
4303
|
-
this.localData = extend({}, this.savedData ?? {}, localData);
|
|
4471
|
+
super.onRefreshUserData(localData);
|
|
4304
4472
|
this.selectedStar = undefined;
|
|
4305
4473
|
if (this.localData) {
|
|
4306
4474
|
if (this.localData["_r_g_" + this.elementId + "_ss"] !== undefined) {
|
|
@@ -4358,9 +4526,11 @@ class WidgetRate extends WidgetBase {
|
|
|
4358
4526
|
this.selectedStar = value;
|
|
4359
4527
|
this.localData["_r_g_" + this.elementId + "_ss"] = value;
|
|
4360
4528
|
this.element.classList.add("done");
|
|
4361
|
-
|
|
4362
|
-
this.
|
|
4363
|
-
|
|
4529
|
+
this.startReadyPromise.then(() => {
|
|
4530
|
+
if (this.disableTimer && runTimer) {
|
|
4531
|
+
this.startDisabledTimeline();
|
|
4532
|
+
}
|
|
4533
|
+
});
|
|
4364
4534
|
}
|
|
4365
4535
|
_clearSelectedStar() {
|
|
4366
4536
|
forEach(this.stars, function (element) {
|
|
@@ -4493,7 +4663,15 @@ class WidgetRate extends WidgetBase {
|
|
|
4493
4663
|
},
|
|
4494
4664
|
/** @deprecated */
|
|
4495
4665
|
initWidget: function (nodeList, localData) {
|
|
4496
|
-
|
|
4666
|
+
const elements = slice.call(nodeList);
|
|
4667
|
+
WidgetRate.initWidgets((element, options) => new WidgetRate(element, options), elements, localData);
|
|
4668
|
+
elements.forEach(element => WidgetRate.getInstance(element)?.onStart());
|
|
4669
|
+
},
|
|
4670
|
+
onStart: function (element) {
|
|
4671
|
+
WidgetRate.getInstance(element)?.onStart();
|
|
4672
|
+
},
|
|
4673
|
+
onStop: function (element) {
|
|
4674
|
+
WidgetRate.getInstance(element)?.onStop();
|
|
4497
4675
|
},
|
|
4498
4676
|
select: function (element) {
|
|
4499
4677
|
const widgetElement = element.closest(`.${WidgetRate.widgetClassName}`);
|
|
@@ -4539,21 +4717,28 @@ class WidgetShare extends WidgetBase {
|
|
|
4539
4717
|
this.shareTarget = getTagData(this.element, "shareTarget");
|
|
4540
4718
|
this.layers = this.options.layers;
|
|
4541
4719
|
this.withLayer = Boolean(getValueOrDefault(getTagDataAsNumber(this.element, "withLayer"), 0));
|
|
4720
|
+
}
|
|
4721
|
+
/**
|
|
4722
|
+
* Start or restart widget
|
|
4723
|
+
* @param localData
|
|
4724
|
+
*/
|
|
4725
|
+
onRefreshUserData(localData) {
|
|
4726
|
+
super.onRefreshUserData(localData);
|
|
4542
4727
|
if (this.withLayer) {
|
|
4543
4728
|
if (this.isDone()) {
|
|
4544
|
-
this.
|
|
4729
|
+
this._showLayer(this.layers, 1);
|
|
4545
4730
|
}
|
|
4546
4731
|
else {
|
|
4547
|
-
this.
|
|
4732
|
+
this._showLayer(this.layers, 0);
|
|
4548
4733
|
}
|
|
4549
4734
|
}
|
|
4550
|
-
|
|
4551
|
-
this.
|
|
4552
|
-
|
|
4735
|
+
this.startReadyPromise.then(() => {
|
|
4736
|
+
if (this.isDone() && this.disableTimer) {
|
|
4737
|
+
this.startDisabledTimeline();
|
|
4738
|
+
}
|
|
4739
|
+
});
|
|
4553
4740
|
this.btnDisabled = false;
|
|
4554
|
-
// this.onRefreshUserData(this.options.localData);
|
|
4555
4741
|
}
|
|
4556
|
-
onRefreshUserData(localData) { }
|
|
4557
4742
|
_statEventShare(result, via) {
|
|
4558
4743
|
try {
|
|
4559
4744
|
const buttonText = this.element.textContent ?? "";
|
|
@@ -4606,7 +4791,7 @@ class WidgetShare extends WidgetBase {
|
|
|
4606
4791
|
}
|
|
4607
4792
|
this._statEventShare(isSuccess, null);
|
|
4608
4793
|
if (isSuccess && this.withLayer) {
|
|
4609
|
-
this.
|
|
4794
|
+
this._showLayer(this.layers, 1, true);
|
|
4610
4795
|
}
|
|
4611
4796
|
if (this.disableTimer) {
|
|
4612
4797
|
this.startDisabledTimeline();
|
|
@@ -4622,7 +4807,10 @@ class WidgetShare extends WidgetBase {
|
|
|
4622
4807
|
refreshUserData: WidgetShare.refreshUserData,
|
|
4623
4808
|
onRefreshUserData: WidgetShare.onRefreshUserData,
|
|
4624
4809
|
init: function (element, layers, localData) {
|
|
4625
|
-
WidgetShare.initWidget(element, localData, (element, options) => new WidgetShare(element, {
|
|
4810
|
+
WidgetShare.initWidget(element, localData, (element, options) => new WidgetShare(element, {
|
|
4811
|
+
...options,
|
|
4812
|
+
layers,
|
|
4813
|
+
}));
|
|
4626
4814
|
},
|
|
4627
4815
|
/** @deprecated
|
|
4628
4816
|
* signature variants
|
|
@@ -4636,7 +4824,15 @@ class WidgetShare extends WidgetBase {
|
|
|
4636
4824
|
layers = localData;
|
|
4637
4825
|
localData = undefined;
|
|
4638
4826
|
}
|
|
4639
|
-
|
|
4827
|
+
const elements = slice.call(nodeList);
|
|
4828
|
+
WidgetShare.initWidgets((element, options) => new WidgetShare(element, { ...options, layers }), elements, localData);
|
|
4829
|
+
elements.forEach(element => WidgetShare.getInstance(element)?.onStart());
|
|
4830
|
+
},
|
|
4831
|
+
onStart: function (element) {
|
|
4832
|
+
WidgetShare.getInstance(element)?.onStart();
|
|
4833
|
+
},
|
|
4834
|
+
onStop: function (element) {
|
|
4835
|
+
WidgetShare.getInstance(element)?.onStop();
|
|
4640
4836
|
},
|
|
4641
4837
|
click: function (element) {
|
|
4642
4838
|
const widgetElement = element.closest(`.${WidgetShare.widgetClassName}`);
|
|
@@ -4682,18 +4878,6 @@ class WidgetTest extends WidgetBase {
|
|
|
4682
4878
|
this.testCount = getValueOrException(getTagDataAsNumber(this.slide, "testCount"), "Empty testCount");
|
|
4683
4879
|
this.withTimeToAnswer = Boolean(getValueOrDefault(getTagDataAsNumber(this.element, "withTimeToAnswer"), 0));
|
|
4684
4880
|
this.answerTimeout = getValueOrDefault(getTagDataAsNumber(this.element, "answerTimeout"), 0);
|
|
4685
|
-
this.selectedAnswer = undefined;
|
|
4686
|
-
if (this.localData) {
|
|
4687
|
-
if (this.localData["_t_g_" + this.elementId + "_sa"] !== undefined) {
|
|
4688
|
-
this._selectAnswer(this.localData["_t_g_" + this.elementId + "_sa"]);
|
|
4689
|
-
this.setLocalData(this.localData, false);
|
|
4690
|
-
}
|
|
4691
|
-
if (this.localData["_t_fo_at"] === undefined) {
|
|
4692
|
-
this.localData["_t_fo_at"] = Math.round(new Date().getTime() / 1000);
|
|
4693
|
-
this.setLocalData(this.localData, false);
|
|
4694
|
-
}
|
|
4695
|
-
}
|
|
4696
|
-
this.firstOpenTime = new Date().getTime();
|
|
4697
4881
|
this.tick = () => {
|
|
4698
4882
|
this.animationFrameId = this.env.requestAnimationFrame(() => {
|
|
4699
4883
|
this.tick();
|
|
@@ -4722,7 +4906,27 @@ class WidgetTest extends WidgetBase {
|
|
|
4722
4906
|
this.env.cancelAnimationFrame(this.animationFrameId);
|
|
4723
4907
|
}
|
|
4724
4908
|
};
|
|
4909
|
+
}
|
|
4910
|
+
/**
|
|
4911
|
+
* Start or restart widget
|
|
4912
|
+
* @param localData
|
|
4913
|
+
*/
|
|
4914
|
+
onRefreshUserData(localData) {
|
|
4915
|
+
super.onRefreshUserData(localData);
|
|
4916
|
+
this.selectedAnswer = undefined;
|
|
4917
|
+
if (this.localData) {
|
|
4918
|
+
if (this.localData["_t_g_" + this.elementId + "_sa"] !== undefined) {
|
|
4919
|
+
this._selectAnswer(this.localData["_t_g_" + this.elementId + "_sa"]);
|
|
4920
|
+
this.setLocalData(this.localData, false);
|
|
4921
|
+
}
|
|
4922
|
+
if (this.localData["_t_fo_at"] === undefined) {
|
|
4923
|
+
this.localData["_t_fo_at"] = Math.round(new Date().getTime() / 1000);
|
|
4924
|
+
this.setLocalData(this.localData, false);
|
|
4925
|
+
}
|
|
4926
|
+
}
|
|
4927
|
+
this.firstOpenTime = new Date().getTime();
|
|
4725
4928
|
if (this.slideTestWithTimer()) {
|
|
4929
|
+
this.cancelTick();
|
|
4726
4930
|
this.timeline = this.element.querySelector(".timeline");
|
|
4727
4931
|
if (this.selectedAnswer === undefined) {
|
|
4728
4932
|
// find timer element
|
|
@@ -4732,7 +4936,9 @@ class WidgetTest extends WidgetBase {
|
|
|
4732
4936
|
this.timeLeft = this.timeLeftDefault;
|
|
4733
4937
|
this.animationFrameId = null;
|
|
4734
4938
|
this.startTimerAt = new Date().getTime();
|
|
4735
|
-
this.
|
|
4939
|
+
this.startReadyPromise.then(() => {
|
|
4940
|
+
this.tick();
|
|
4941
|
+
});
|
|
4736
4942
|
// set answer - unanswered (for close and run again)
|
|
4737
4943
|
this.localData["_t_g_" + this.elementId + "_sa"] = -1;
|
|
4738
4944
|
this.setLocalData(this.localData, true);
|
|
@@ -4751,9 +4957,16 @@ class WidgetTest extends WidgetBase {
|
|
|
4751
4957
|
}
|
|
4752
4958
|
}
|
|
4753
4959
|
}
|
|
4754
|
-
// this.onRefreshUserData(this.options.localData);
|
|
4755
4960
|
}
|
|
4756
|
-
|
|
4961
|
+
onStart() {
|
|
4962
|
+
super.onStart();
|
|
4963
|
+
}
|
|
4964
|
+
onStop() {
|
|
4965
|
+
super.onStop();
|
|
4966
|
+
if (this.slideTestWithTimer()) {
|
|
4967
|
+
this.cancelTick();
|
|
4968
|
+
}
|
|
4969
|
+
}
|
|
4757
4970
|
_statEventVoteAnswer(answerScore) {
|
|
4758
4971
|
try {
|
|
4759
4972
|
if (this.selectedAnswer != null) {
|
|
@@ -4801,9 +5014,11 @@ class WidgetTest extends WidgetBase {
|
|
|
4801
5014
|
this.submitButtonAnimatedView.style.maxHeight = this.submitButtonViewHeight + "px";
|
|
4802
5015
|
}
|
|
4803
5016
|
});
|
|
4804
|
-
|
|
4805
|
-
this.
|
|
4806
|
-
|
|
5017
|
+
this.startReadyPromise.then(() => {
|
|
5018
|
+
if (this.disableTimer) {
|
|
5019
|
+
this.startDisabledTimeline();
|
|
5020
|
+
}
|
|
5021
|
+
});
|
|
4807
5022
|
}
|
|
4808
5023
|
selectAnswer(answer) {
|
|
4809
5024
|
if (this.selectedAnswer !== undefined) {
|
|
@@ -4882,6 +5097,13 @@ class WidgetTest extends WidgetBase {
|
|
|
4882
5097
|
/** @deprecated */
|
|
4883
5098
|
initWidget: function (element, localData) {
|
|
4884
5099
|
WidgetTest.initWidgets((element, options) => new WidgetTest(element, options), [element], localData);
|
|
5100
|
+
WidgetTest.getInstance(element)?.onStart();
|
|
5101
|
+
},
|
|
5102
|
+
onStart: function (element) {
|
|
5103
|
+
WidgetTest.getInstance(element)?.onStart();
|
|
5104
|
+
},
|
|
5105
|
+
onStop: function (element) {
|
|
5106
|
+
WidgetTest.getInstance(element)?.onStop();
|
|
4885
5107
|
},
|
|
4886
5108
|
/**
|
|
4887
5109
|
* click on quiz answer
|
|
@@ -4952,7 +5174,6 @@ class WidgetVote extends WidgetBase {
|
|
|
4952
5174
|
});
|
|
4953
5175
|
this.hideClientTotalResult = getValueOrDefault(Boolean(getTagDataAsNumber(this.element, "hideClientTotalResult")), false);
|
|
4954
5176
|
this.multipleChoice = getValueOrDefault(Boolean(getTagDataAsNumber(this.element, "multipleChoice")), false);
|
|
4955
|
-
this.onRefreshUserData(this.options.localData);
|
|
4956
5177
|
}
|
|
4957
5178
|
_initFromLocalData() {
|
|
4958
5179
|
const value = this.localData["_v_g_" + this.elementId + "_sa"];
|
|
@@ -4987,9 +5208,12 @@ class WidgetVote extends WidgetBase {
|
|
|
4987
5208
|
this._fillWidget(true);
|
|
4988
5209
|
}
|
|
4989
5210
|
}
|
|
5211
|
+
/**
|
|
5212
|
+
* Start or restart widget
|
|
5213
|
+
* @param localData
|
|
5214
|
+
*/
|
|
4990
5215
|
onRefreshUserData(localData) {
|
|
4991
|
-
|
|
4992
|
-
this.localData = extend({}, this.savedData ?? {}, localData);
|
|
5216
|
+
super.onRefreshUserData(localData);
|
|
4993
5217
|
this.selectedVariant = undefined;
|
|
4994
5218
|
if (this.localData) {
|
|
4995
5219
|
if (this.localData["_v_g_" + this.elementId + "_sa"] != null) {
|
|
@@ -5119,9 +5343,11 @@ class WidgetVote extends WidgetBase {
|
|
|
5119
5343
|
this._removeInputDone();
|
|
5120
5344
|
this._hideSubmitBtn();
|
|
5121
5345
|
}
|
|
5122
|
-
|
|
5123
|
-
this.
|
|
5124
|
-
|
|
5346
|
+
this.startReadyPromise.then(() => {
|
|
5347
|
+
if (this.disableTimer) {
|
|
5348
|
+
this.startDisabledTimeline();
|
|
5349
|
+
}
|
|
5350
|
+
});
|
|
5125
5351
|
}
|
|
5126
5352
|
_showSubmitBtn() {
|
|
5127
5353
|
this.env.requestAnimationFrame(() => {
|
|
@@ -5352,6 +5578,13 @@ class WidgetVote extends WidgetBase {
|
|
|
5352
5578
|
WidgetVote.initWidgets((element, options) => new WidgetVote(element, options), [element], localData).then(localData => {
|
|
5353
5579
|
WidgetVote.api.fallbackInitOnMultiSlide(element, localData);
|
|
5354
5580
|
});
|
|
5581
|
+
WidgetVote.getInstance(element)?.onStart();
|
|
5582
|
+
},
|
|
5583
|
+
onStart: function (element) {
|
|
5584
|
+
WidgetVote.getInstance(element)?.onStart();
|
|
5585
|
+
},
|
|
5586
|
+
onStop: function (element) {
|
|
5587
|
+
WidgetVote.getInstance(element)?.onStop();
|
|
5355
5588
|
},
|
|
5356
5589
|
select: function (element) {
|
|
5357
5590
|
const widgetElement = element.closest(`.${WidgetVote.widgetClassName}`);
|
|
@@ -14769,22 +15002,33 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14769
15002
|
this.formatterType = getTagData(element, "formatterType");
|
|
14770
15003
|
this.copiedText = getTagData(element, "copiedText");
|
|
14771
15004
|
this.svgView = this.element.querySelector(".barcode-view-inner");
|
|
14772
|
-
this.state = null;
|
|
14773
15005
|
this.msgNetworkError = getTagData(this.element, "msgNetworkError");
|
|
14774
15006
|
this.msgServiceError = getTagData(this.element, "msgServiceError");
|
|
14775
15007
|
this.msgNoMoreCodes = getTagData(this.element, "msgNoMoreCodes");
|
|
14776
15008
|
this.msgTryAgain = getTagData(this.element, "msgTryAgain");
|
|
14777
15009
|
this.msgBarcodeRenderError = getTagData(this.element, "msgBarcodeRenderError");
|
|
15010
|
+
}
|
|
15011
|
+
/**
|
|
15012
|
+
* Start or restart widget
|
|
15013
|
+
* @param localData
|
|
15014
|
+
*/
|
|
15015
|
+
onRefreshUserData(localData) {
|
|
15016
|
+
super.onRefreshUserData(localData);
|
|
15017
|
+
this.state = null;
|
|
14778
15018
|
if (this.isPromotionalCode) {
|
|
14779
|
-
this.
|
|
15019
|
+
this.initPromotionalCodeFromLocalData();
|
|
14780
15020
|
}
|
|
14781
15021
|
else {
|
|
14782
15022
|
this.renderCodeView();
|
|
14783
15023
|
this.renderCaptionView();
|
|
14784
15024
|
}
|
|
14785
|
-
// this.onRefreshUserData(this.options.localData);
|
|
14786
15025
|
}
|
|
14787
|
-
|
|
15026
|
+
onStart() {
|
|
15027
|
+
super.onStart();
|
|
15028
|
+
if (this.isPromotionalCode) {
|
|
15029
|
+
this.fetchPromoCode();
|
|
15030
|
+
}
|
|
15031
|
+
}
|
|
14788
15032
|
isTransparentElement() {
|
|
14789
15033
|
if (this.element) {
|
|
14790
15034
|
try {
|
|
@@ -14866,17 +15110,23 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14866
15110
|
this.captionView.textContent = text;
|
|
14867
15111
|
}
|
|
14868
15112
|
}
|
|
14869
|
-
|
|
14870
|
-
this.
|
|
14871
|
-
|
|
15113
|
+
getPromotionalCodeFromLocalData() {
|
|
15114
|
+
return this.localData["_bc_g_" + this.elementId + "_pc"];
|
|
15115
|
+
}
|
|
15116
|
+
initPromotionalCodeFromLocalData() {
|
|
15117
|
+
if (this.getPromotionalCodeFromLocalData() !== undefined) {
|
|
14872
15118
|
this.state = 1;
|
|
14873
|
-
this.clipboardTarget = this.
|
|
15119
|
+
this.clipboardTarget = this.getPromotionalCodeFromLocalData();
|
|
14874
15120
|
if (this.clipboardTarget != null) {
|
|
14875
15121
|
this.renderCaptionView();
|
|
14876
15122
|
this.renderCodeView();
|
|
14877
15123
|
}
|
|
14878
15124
|
removeClass(this.element, "loader");
|
|
14879
15125
|
}
|
|
15126
|
+
}
|
|
15127
|
+
fetchPromoCode() {
|
|
15128
|
+
this.state = 0;
|
|
15129
|
+
this.initPromotionalCodeFromLocalData();
|
|
14880
15130
|
if (this.state === 0) {
|
|
14881
15131
|
if (!this.isTransparentElement()) {
|
|
14882
15132
|
// for transparent element
|
|
@@ -14962,12 +15212,14 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14962
15212
|
}
|
|
14963
15213
|
_select() {
|
|
14964
15214
|
this.element.classList.add("done");
|
|
14965
|
-
|
|
14966
|
-
|
|
14967
|
-
|
|
14968
|
-
|
|
14969
|
-
|
|
14970
|
-
|
|
15215
|
+
this.startReadyPromise.then(() => {
|
|
15216
|
+
if (this.disableTimer) {
|
|
15217
|
+
// флаг - что таймер уже стартанул (в layout или добавить объект sharedMemory)
|
|
15218
|
+
// смотрим что прозрачный текст - тогда и лоадер прозрачный
|
|
15219
|
+
// _log("_showNarrativeNextSlide: " + getSlideDuration(this.narrativeId, this.slideIndex), true);
|
|
15220
|
+
this.startDisabledTimeline();
|
|
15221
|
+
}
|
|
15222
|
+
});
|
|
14971
15223
|
if (this.copiedText) {
|
|
14972
15224
|
this.sdkApi.showToast(this.copiedText);
|
|
14973
15225
|
}
|
|
@@ -14998,7 +15250,15 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14998
15250
|
},
|
|
14999
15251
|
/** @deprecated */
|
|
15000
15252
|
initWidget: function (nodeList, localData) {
|
|
15001
|
-
|
|
15253
|
+
const elements = slice.call(nodeList);
|
|
15254
|
+
WidgetBarcode.initWidgets((element, options) => new WidgetBarcode(element, options), elements, localData);
|
|
15255
|
+
elements.forEach(element => WidgetBarcode.getInstance(element)?.onStart());
|
|
15256
|
+
},
|
|
15257
|
+
onStart: function (element) {
|
|
15258
|
+
WidgetBarcode.getInstance(element)?.onStart();
|
|
15259
|
+
},
|
|
15260
|
+
onStop: function (element) {
|
|
15261
|
+
WidgetBarcode.getInstance(element)?.onStop();
|
|
15002
15262
|
},
|
|
15003
15263
|
click: function (element) {
|
|
15004
15264
|
const widgetElement = element.closest(`.${WidgetBarcode.widgetClassName}`);
|