@inappstory/slide-api 0.0.16 → 0.0.18
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 +202 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +202 -88
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1282,6 +1282,27 @@ class WidgetBase {
|
|
|
1282
1282
|
}
|
|
1283
1283
|
return instance;
|
|
1284
1284
|
}
|
|
1285
|
+
static initWidget(htmlElement, localData, instantiate) {
|
|
1286
|
+
if (localData != null) {
|
|
1287
|
+
this.createInstance(instantiate, htmlElement, {
|
|
1288
|
+
slide: null,
|
|
1289
|
+
localData,
|
|
1290
|
+
});
|
|
1291
|
+
return Promise.resolve(localData);
|
|
1292
|
+
}
|
|
1293
|
+
else {
|
|
1294
|
+
return new Promise(resolve => {
|
|
1295
|
+
this.getLocalData().then(localData => {
|
|
1296
|
+
this.createInstance(instantiate, htmlElement, {
|
|
1297
|
+
slide: null,
|
|
1298
|
+
localData,
|
|
1299
|
+
});
|
|
1300
|
+
resolve(localData);
|
|
1301
|
+
});
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
/** @deprecated */
|
|
1285
1306
|
static initWidgets(instantiate, elements, localData) {
|
|
1286
1307
|
if (localData != null) {
|
|
1287
1308
|
forEach(elements, element => {
|
|
@@ -1479,16 +1500,16 @@ class WidgetCopy extends WidgetBase {
|
|
|
1479
1500
|
this.resultLayerGeometry = this.resultLayer.closest(".narrative-element-geometry");
|
|
1480
1501
|
// create align center
|
|
1481
1502
|
if (this.resultLayerGeometry) {
|
|
1482
|
-
|
|
1483
|
-
|
|
1503
|
+
const baseComputedGeometry = window.getComputedStyle(this.geometry);
|
|
1504
|
+
let resultComputedGeometry = window.getComputedStyle(this.resultLayerGeometry);
|
|
1484
1505
|
if (parseFloat(resultComputedGeometry.width) < parseFloat(baseComputedGeometry.width)) {
|
|
1485
1506
|
// prevent resultLayer shrinking
|
|
1486
1507
|
this.resultLayerGeometry.style.setProperty("width", parseFloat(baseComputedGeometry.width) + "px");
|
|
1487
1508
|
resultComputedGeometry = window.getComputedStyle(this.resultLayerGeometry);
|
|
1488
1509
|
}
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1510
|
+
const geometryCenter = parseFloat(baseComputedGeometry.left) + parseFloat(baseComputedGeometry.width) / 2;
|
|
1511
|
+
const resultLayerGeometryWidth = parseFloat(resultComputedGeometry.width);
|
|
1512
|
+
const newResultLayerGeometryLeft = geometryCenter - resultLayerGeometryWidth / 2;
|
|
1492
1513
|
this.resultLayerGeometry.style.setProperty("left", newResultLayerGeometryLeft + "px");
|
|
1493
1514
|
}
|
|
1494
1515
|
}
|
|
@@ -1501,7 +1522,7 @@ class WidgetCopy extends WidgetBase {
|
|
|
1501
1522
|
isTransparentElement() {
|
|
1502
1523
|
if (this.element) {
|
|
1503
1524
|
try {
|
|
1504
|
-
|
|
1525
|
+
const color = window.getComputedStyle(this.element).color;
|
|
1505
1526
|
if (color === "transparent" || color === "rgba(0, 0, 0, 0)" || color === "rgba(0,0,0,0)") {
|
|
1506
1527
|
return true;
|
|
1507
1528
|
}
|
|
@@ -1592,7 +1613,7 @@ class WidgetCopy extends WidgetBase {
|
|
|
1592
1613
|
}
|
|
1593
1614
|
_statEventCopyClick(clipboardTarget) {
|
|
1594
1615
|
try {
|
|
1595
|
-
|
|
1616
|
+
const buttonText = this.button?.textContent ?? "";
|
|
1596
1617
|
this.sendStatisticEventToApp("w-copy", {
|
|
1597
1618
|
...this.statisticEventBaseFieldsShortForm,
|
|
1598
1619
|
wi: this.elementId,
|
|
@@ -1623,7 +1644,7 @@ class WidgetCopy extends WidgetBase {
|
|
|
1623
1644
|
}
|
|
1624
1645
|
copyToClipboard(element) {
|
|
1625
1646
|
this._select();
|
|
1626
|
-
|
|
1647
|
+
const text = this.clipboardTarget ?? "";
|
|
1627
1648
|
Clipboard.copy(text);
|
|
1628
1649
|
this.completeWidget();
|
|
1629
1650
|
this._statEventCopyClick(text);
|
|
@@ -1640,6 +1661,13 @@ class WidgetCopy extends WidgetBase {
|
|
|
1640
1661
|
static api = {
|
|
1641
1662
|
widgetClassName: WidgetCopy.widgetClassName,
|
|
1642
1663
|
refreshUserData: WidgetCopy.refreshUserData,
|
|
1664
|
+
init: function (element, localData) {
|
|
1665
|
+
// prevent initWidget for result layer
|
|
1666
|
+
if (!element.classList.contains("narrative-element-copy-result-variant")) {
|
|
1667
|
+
WidgetCopy.initWidget(element, localData, (element, options) => new WidgetCopy(element, options));
|
|
1668
|
+
}
|
|
1669
|
+
},
|
|
1670
|
+
/** @deprecated */
|
|
1643
1671
|
initWidget: function (nodeList, localData) {
|
|
1644
1672
|
// prevent initWidget for result layer
|
|
1645
1673
|
const elements = slice.call(nodeList).filter(element => !element.classList.contains("narrative-element-copy-result-variant"));
|
|
@@ -1698,7 +1726,7 @@ class WidgetDataInput extends WidgetBase {
|
|
|
1698
1726
|
refreshUserData(localData) {
|
|
1699
1727
|
this.savedData = this.sdkApi.getCardServerData(this.cardId);
|
|
1700
1728
|
this.localData = extend({}, this.savedData ?? {}, localData);
|
|
1701
|
-
|
|
1729
|
+
const text = this.localData["_di_g_" + this.elementId + "_t"];
|
|
1702
1730
|
this._fillUserText(text);
|
|
1703
1731
|
if (text) {
|
|
1704
1732
|
this.element.classList.add("done");
|
|
@@ -1798,7 +1826,7 @@ class WidgetDataInput extends WidgetBase {
|
|
|
1798
1826
|
setUserText(text) {
|
|
1799
1827
|
this.slide.classList.remove("data-input-editing");
|
|
1800
1828
|
this.slide.classList.remove("blured");
|
|
1801
|
-
|
|
1829
|
+
let needResumeUITimer = true;
|
|
1802
1830
|
if (text) {
|
|
1803
1831
|
this._fillUserText(text);
|
|
1804
1832
|
this.localData["_di_g_" + this.elementId + "_t"] = text;
|
|
@@ -1827,6 +1855,10 @@ class WidgetDataInput extends WidgetBase {
|
|
|
1827
1855
|
static api = {
|
|
1828
1856
|
widgetClassName: WidgetDataInput.widgetClassName,
|
|
1829
1857
|
refreshUserData: WidgetDataInput.refreshUserData,
|
|
1858
|
+
init: function (element, localData) {
|
|
1859
|
+
WidgetDataInput.initWidget(element, localData, (element, options) => new WidgetDataInput(element, options));
|
|
1860
|
+
},
|
|
1861
|
+
/** @deprecated */
|
|
1830
1862
|
initWidget: function (nodeList, localData) {
|
|
1831
1863
|
WidgetDataInput.initWidgets((element, options) => new WidgetDataInput(element, options), slice.call(nodeList), localData);
|
|
1832
1864
|
},
|
|
@@ -1939,16 +1971,16 @@ class WidgetDateCountdown extends WidgetBase {
|
|
|
1939
1971
|
this.thirdGroupCaption = getValueOrException(this.element.querySelector(".date-item-view-group-3 .date-item-caption"), "Empty thirdGroupCaption");
|
|
1940
1972
|
this.timestampSeconds *= 1000;
|
|
1941
1973
|
this.timerInited = true;
|
|
1942
|
-
|
|
1974
|
+
const value = this.timestampSeconds - (new Date().getTime() - this.diff);
|
|
1943
1975
|
if (value > 0) {
|
|
1944
1976
|
this._showLayout(this.layers, 0);
|
|
1945
1977
|
}
|
|
1946
1978
|
this.updateTimer();
|
|
1947
1979
|
}
|
|
1948
1980
|
updateTimer() {
|
|
1949
|
-
|
|
1981
|
+
const value = this.timestampSeconds - (new Date().getTime() - this.diff);
|
|
1950
1982
|
if (value > 0) {
|
|
1951
|
-
|
|
1983
|
+
const result = this._asDuration(Math.round(value / 1000));
|
|
1952
1984
|
if (result.days) {
|
|
1953
1985
|
this.firstGroupCaption.textContent = this.messages.days;
|
|
1954
1986
|
this.firstGroup1.textContent = result.day1;
|
|
@@ -1982,7 +2014,7 @@ class WidgetDateCountdown extends WidgetBase {
|
|
|
1982
2014
|
}
|
|
1983
2015
|
}
|
|
1984
2016
|
_asDuration(value) {
|
|
1985
|
-
|
|
2017
|
+
const result = {
|
|
1986
2018
|
days: false,
|
|
1987
2019
|
day1: "0",
|
|
1988
2020
|
day2: "0",
|
|
@@ -2000,11 +2032,11 @@ class WidgetDateCountdown extends WidgetBase {
|
|
|
2000
2032
|
return result;
|
|
2001
2033
|
}
|
|
2002
2034
|
value = Math.floor(value);
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2035
|
+
const days = Math.floor((value / 86400) % 365);
|
|
2036
|
+
const hours = Math.floor((value / 3600) % 24);
|
|
2037
|
+
const minutes = Math.floor((value / 60) % 60);
|
|
2038
|
+
const seconds = value % 60;
|
|
2039
|
+
let pair;
|
|
2008
2040
|
if (days > 0) {
|
|
2009
2041
|
result.days = true;
|
|
2010
2042
|
if (days < 10)
|
|
@@ -2041,14 +2073,26 @@ class WidgetDateCountdown extends WidgetBase {
|
|
|
2041
2073
|
static api = {
|
|
2042
2074
|
widgetClassName: WidgetDateCountdown.widgetClassName,
|
|
2043
2075
|
refreshUserData: WidgetDateCountdown.refreshUserData,
|
|
2076
|
+
init: function (element, layers, localData) {
|
|
2077
|
+
WidgetDateCountdown.initWidget(element, localData, (element, options) => new WidgetDateCountdown(element, { ...options, layers }));
|
|
2078
|
+
},
|
|
2079
|
+
/** @deprecated */
|
|
2044
2080
|
initWidget: function (nodeList, layers, localData) {
|
|
2045
2081
|
WidgetDateCountdown.initWidgets((element, options) => new WidgetDateCountdown(element, { ...options, layers }), slice.call(nodeList), localData);
|
|
2046
2082
|
},
|
|
2083
|
+
onPause: function (element) {
|
|
2084
|
+
WidgetDateCountdown.getInstance(element)?.pause();
|
|
2085
|
+
},
|
|
2086
|
+
onResume: function (element) {
|
|
2087
|
+
WidgetDateCountdown.getInstance(element)?.resume();
|
|
2088
|
+
},
|
|
2089
|
+
/** @deprecated */
|
|
2047
2090
|
pause: function (nodeList) {
|
|
2048
2091
|
forEach(slice.call(nodeList), function (el, index) {
|
|
2049
2092
|
WidgetDateCountdown.getInstance(el)?.pause();
|
|
2050
2093
|
});
|
|
2051
2094
|
},
|
|
2095
|
+
/** @deprecated */
|
|
2052
2096
|
resume: function (nodeList) {
|
|
2053
2097
|
forEach(slice.call(nodeList), function (el, index) {
|
|
2054
2098
|
WidgetDateCountdown.getInstance(el)?.resume();
|
|
@@ -2212,6 +2256,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
2212
2256
|
selectedVariant;
|
|
2213
2257
|
nativeDialogueWasOpened = false;
|
|
2214
2258
|
answerDuration = 0;
|
|
2259
|
+
elementRect;
|
|
2215
2260
|
/**
|
|
2216
2261
|
* @throws Error
|
|
2217
2262
|
* @param element
|
|
@@ -2257,8 +2302,8 @@ class WidgetPoll extends WidgetBase {
|
|
|
2257
2302
|
this.answerDuration = new Date().getTime() - this.firstOpenTime;
|
|
2258
2303
|
try {
|
|
2259
2304
|
if (this.selectedVariant !== undefined) {
|
|
2260
|
-
|
|
2261
|
-
|
|
2305
|
+
const labelText = this.label?.textContent ?? "";
|
|
2306
|
+
const variantText = this.variantsTexts[this.selectedVariant] ? this.variantsTexts[this.selectedVariant] : "";
|
|
2262
2307
|
this.sendStatisticEventToApp("w-poll-answer", {
|
|
2263
2308
|
...this.statisticEventBaseFieldsShortForm,
|
|
2264
2309
|
wi: this.elementId,
|
|
@@ -2350,6 +2395,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
2350
2395
|
}
|
|
2351
2396
|
const index = this.variants.indexOf(variantView);
|
|
2352
2397
|
if (index !== -1) {
|
|
2398
|
+
this.elementRect = this.element.getBoundingClientRect();
|
|
2353
2399
|
if (this.getUseResponseOnFirstButton && index === 0) {
|
|
2354
2400
|
if (this.sdkApi.isAndroid) {
|
|
2355
2401
|
this.slide.classList.add("blured");
|
|
@@ -2359,7 +2405,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
2359
2405
|
this.selectedVariant = index;
|
|
2360
2406
|
if (this.sdkApi.isExistsShowCardTextInput && dataString) {
|
|
2361
2407
|
const data = JSON.parse(dataString);
|
|
2362
|
-
data.size = getElementBounding(this.env, this.
|
|
2408
|
+
data.size = getElementBounding(this.env, this.elementRect);
|
|
2363
2409
|
if (!this.disableTimer) {
|
|
2364
2410
|
this.sdkApi.pauseUI();
|
|
2365
2411
|
}
|
|
@@ -2393,7 +2439,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
2393
2439
|
this.selectedVariant = index;
|
|
2394
2440
|
if (this.sdkApi.isExistsShowCardTextInput && dataString) {
|
|
2395
2441
|
const data = JSON.parse(dataString);
|
|
2396
|
-
data.size = getElementBounding(this.env, this.
|
|
2442
|
+
data.size = getElementBounding(this.env, this.elementRect);
|
|
2397
2443
|
if (!this.disableTimer) {
|
|
2398
2444
|
this.sdkApi.pauseUI();
|
|
2399
2445
|
}
|
|
@@ -2668,6 +2714,10 @@ class WidgetPoll extends WidgetBase {
|
|
|
2668
2714
|
static api = {
|
|
2669
2715
|
widgetClassName: WidgetPoll.widgetClassName,
|
|
2670
2716
|
refreshUserData: WidgetPoll.refreshUserData,
|
|
2717
|
+
init: function (element, localData) {
|
|
2718
|
+
WidgetPoll.initWidget(element, localData, (element, options) => new WidgetPoll(element, options));
|
|
2719
|
+
},
|
|
2720
|
+
/** @deprecated */
|
|
2671
2721
|
initWidget: function (element, localData) {
|
|
2672
2722
|
WidgetPoll.initWidgets((element, options) => new WidgetPoll(element, options), [element], localData);
|
|
2673
2723
|
},
|
|
@@ -2752,9 +2802,9 @@ class WidgetPollLayers extends WidgetBase {
|
|
|
2752
2802
|
_statEventPollVariant() {
|
|
2753
2803
|
try {
|
|
2754
2804
|
if (this.selectedVariant != null) {
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2805
|
+
const labelText = this.label?.textContent ?? "";
|
|
2806
|
+
const variantText = this.variants[this.selectedVariant]?.textContent ?? "";
|
|
2807
|
+
const duration = new Date().getTime() - this.firstOpenTime;
|
|
2758
2808
|
this.sendStatisticEventToApp("w-poll-layers-answer", {
|
|
2759
2809
|
...this.statisticEventBaseFieldsShortForm,
|
|
2760
2810
|
wi: this.elementId,
|
|
@@ -2784,7 +2834,7 @@ class WidgetPollLayers extends WidgetBase {
|
|
|
2784
2834
|
this.localData["_pl_g_" + this.elementId + "_sa"] = index;
|
|
2785
2835
|
this.element.classList.add("done");
|
|
2786
2836
|
// main
|
|
2787
|
-
|
|
2837
|
+
let layerIndex = 0;
|
|
2788
2838
|
if (index === 0) {
|
|
2789
2839
|
layerIndex = 1;
|
|
2790
2840
|
}
|
|
@@ -2800,7 +2850,7 @@ class WidgetPollLayers extends WidgetBase {
|
|
|
2800
2850
|
if (this.selectedVariant !== undefined) {
|
|
2801
2851
|
return true;
|
|
2802
2852
|
}
|
|
2803
|
-
|
|
2853
|
+
const index = this.variants.indexOf(variant);
|
|
2804
2854
|
if (index !== -1) {
|
|
2805
2855
|
this._selectVariant(index, true);
|
|
2806
2856
|
this.completeWidget();
|
|
@@ -2832,10 +2882,16 @@ class WidgetPollLayers extends WidgetBase {
|
|
|
2832
2882
|
static api = {
|
|
2833
2883
|
widgetClassName: WidgetPollLayers.widgetClassName,
|
|
2834
2884
|
refreshUserData: WidgetPollLayers.refreshUserData,
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2885
|
+
init: function (element, layers, localData) {
|
|
2886
|
+
WidgetPollLayers.initWidget(element, localData, (element, options) => new WidgetPollLayers(element, { ...options, layers }));
|
|
2887
|
+
},
|
|
2888
|
+
/** @deprecated
|
|
2889
|
+
*
|
|
2890
|
+
* signature variants
|
|
2891
|
+
* (widget, layers, undefined) - modern web sdk
|
|
2892
|
+
* (widget, undefined, layers) - old web sdk and rn
|
|
2893
|
+
* (widget, layers, localData) - native sdk
|
|
2894
|
+
*/
|
|
2839
2895
|
initWidget: function (element, layers, localData) {
|
|
2840
2896
|
if (layers === undefined && localData !== undefined) {
|
|
2841
2897
|
// @ts-ignore
|
|
@@ -2906,7 +2962,7 @@ class WidgetQuest extends WidgetBase {
|
|
|
2906
2962
|
this.localData["_qt_fo_at"] = Math.round(new Date().getTime() / 1000);
|
|
2907
2963
|
this.setLocalData(this.localData, false);
|
|
2908
2964
|
}
|
|
2909
|
-
|
|
2965
|
+
let lastSlideIdx = this.localData["_qt_last_slide_idx"];
|
|
2910
2966
|
if (lastSlideIdx !== undefined) {
|
|
2911
2967
|
lastSlideIdx = parseInt(lastSlideIdx);
|
|
2912
2968
|
if (lastSlideIdx >= 0 &&
|
|
@@ -2924,7 +2980,7 @@ class WidgetQuest extends WidgetBase {
|
|
|
2924
2980
|
}
|
|
2925
2981
|
}
|
|
2926
2982
|
// если этого слайда нет в роутинге (сработал переход по таймеру в app)
|
|
2927
|
-
|
|
2983
|
+
const routes = this._getRoutes();
|
|
2928
2984
|
if (routes[0].indexOf(this.slideIndex) === -1 && this.finalSlide) {
|
|
2929
2985
|
if (this.sdkApi.isExistsShowNextCard) {
|
|
2930
2986
|
this.sdkApi.cardShowNext();
|
|
@@ -2966,9 +3022,9 @@ class WidgetQuest extends WidgetBase {
|
|
|
2966
3022
|
// if (this.selectedAnswer !== undefined) {
|
|
2967
3023
|
// return true;
|
|
2968
3024
|
// }
|
|
2969
|
-
|
|
3025
|
+
const index = this.variants.indexOf(answer);
|
|
2970
3026
|
if (index !== -1) {
|
|
2971
|
-
|
|
3027
|
+
const slideIndex = getValueOrDefault(getTagDataAsNumber(this.variants[index], "score"), 0) - 1;
|
|
2972
3028
|
this._selectAnswer(index, slideIndex);
|
|
2973
3029
|
this.setLocalData(this.localData, true);
|
|
2974
3030
|
this.env.setTimeout(() => {
|
|
@@ -2994,22 +3050,22 @@ class WidgetQuest extends WidgetBase {
|
|
|
2994
3050
|
return getTagDataAsNumber(this.slide, "lastSlideWithQuest") ?? 0;
|
|
2995
3051
|
}
|
|
2996
3052
|
_getRoutes() {
|
|
2997
|
-
|
|
3053
|
+
let routes = this.localData["_qt_routes"];
|
|
2998
3054
|
if (!Array.isArray(routes)) {
|
|
2999
3055
|
routes = [[0], 0];
|
|
3000
3056
|
}
|
|
3001
3057
|
return routes;
|
|
3002
3058
|
}
|
|
3003
3059
|
_addNewRouteHistory(route) {
|
|
3004
|
-
|
|
3005
|
-
|
|
3060
|
+
const routes = this._getRoutes();
|
|
3061
|
+
const _routes = routes[0].slice(0, routes[1] + 1);
|
|
3006
3062
|
routes[0] = _routes.concat([route]);
|
|
3007
3063
|
routes[1] = routes[0].length - 1;
|
|
3008
3064
|
this.localData["_qt_routes"] = routes;
|
|
3009
3065
|
}
|
|
3010
3066
|
_routeMvPtrBack() {
|
|
3011
|
-
|
|
3012
|
-
|
|
3067
|
+
const routes = this._getRoutes();
|
|
3068
|
+
const newPtr = routes[1] - 1;
|
|
3013
3069
|
if (newPtr >= 0 && routes[0][newPtr] !== undefined) {
|
|
3014
3070
|
routes[1] = newPtr;
|
|
3015
3071
|
this.localData["_qt_routes"] = routes;
|
|
@@ -3019,12 +3075,13 @@ class WidgetQuest extends WidgetBase {
|
|
|
3019
3075
|
return false;
|
|
3020
3076
|
}
|
|
3021
3077
|
getLastSlideIndexFromRouteHistory() {
|
|
3022
|
-
|
|
3078
|
+
const routes = this._getRoutes();
|
|
3023
3079
|
return routes[0][routes[1]];
|
|
3024
3080
|
}
|
|
3025
3081
|
handleRouteClick(event) {
|
|
3082
|
+
let moveTo;
|
|
3026
3083
|
// event: direction ('backward', 'forward') slideIndex, slideCount
|
|
3027
|
-
|
|
3084
|
+
const directionForward = event.direction === "forward";
|
|
3028
3085
|
event.direction === "backward";
|
|
3029
3086
|
if (this.isWidget) {
|
|
3030
3087
|
if (directionForward) {
|
|
@@ -3037,7 +3094,7 @@ class WidgetQuest extends WidgetBase {
|
|
|
3037
3094
|
}
|
|
3038
3095
|
else {
|
|
3039
3096
|
// by routing - move back
|
|
3040
|
-
|
|
3097
|
+
moveTo = this._routeMvPtrBack();
|
|
3041
3098
|
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.sdkApi.isExistsShowCardSlide) {
|
|
3042
3099
|
this.sdkApi.showCardSlide(moveTo);
|
|
3043
3100
|
}
|
|
@@ -3054,7 +3111,7 @@ class WidgetQuest extends WidgetBase {
|
|
|
3054
3111
|
// simple slide case
|
|
3055
3112
|
if (this.nonFinalSlide || event.slideIndex < this.firstSlideWithQuestIndex()) {
|
|
3056
3113
|
if (directionForward) {
|
|
3057
|
-
|
|
3114
|
+
const nextSlideIndex = event.slideIndex + 1;
|
|
3058
3115
|
if (nextSlideIndex < this.slideCount) {
|
|
3059
3116
|
this._addNewRouteHistory(nextSlideIndex);
|
|
3060
3117
|
this.setLocalData(this.localData, true);
|
|
@@ -3073,7 +3130,7 @@ class WidgetQuest extends WidgetBase {
|
|
|
3073
3130
|
}
|
|
3074
3131
|
else {
|
|
3075
3132
|
// by routing - move back
|
|
3076
|
-
|
|
3133
|
+
moveTo = this._routeMvPtrBack();
|
|
3077
3134
|
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.sdkApi.isExistsShowCardSlide) {
|
|
3078
3135
|
this.sdkApi.showCardSlide(moveTo);
|
|
3079
3136
|
}
|
|
@@ -3101,7 +3158,7 @@ class WidgetQuest extends WidgetBase {
|
|
|
3101
3158
|
}
|
|
3102
3159
|
else {
|
|
3103
3160
|
// by routing - move back
|
|
3104
|
-
|
|
3161
|
+
moveTo = this._routeMvPtrBack();
|
|
3105
3162
|
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.sdkApi.isExistsShowCardSlide) {
|
|
3106
3163
|
this.sdkApi.showCardSlide(moveTo);
|
|
3107
3164
|
}
|
|
@@ -3116,6 +3173,19 @@ class WidgetQuest extends WidgetBase {
|
|
|
3116
3173
|
static api = {
|
|
3117
3174
|
widgetClassName: WidgetQuest.widgetClassName,
|
|
3118
3175
|
refreshUserData: WidgetQuest.refreshUserData,
|
|
3176
|
+
init: function (element, localData) {
|
|
3177
|
+
return new Promise(function (resolve, reject) {
|
|
3178
|
+
WidgetQuest.initWidget(element, localData, (element, options) => new WidgetQuest(element, options)).then(localData => {
|
|
3179
|
+
const widget = WidgetQuest.getInstance(element);
|
|
3180
|
+
if (widget) {
|
|
3181
|
+
resolve(widget.init());
|
|
3182
|
+
}
|
|
3183
|
+
else {
|
|
3184
|
+
resolve(true);
|
|
3185
|
+
}
|
|
3186
|
+
});
|
|
3187
|
+
});
|
|
3188
|
+
},
|
|
3119
3189
|
initWidget: function (element, localData) {
|
|
3120
3190
|
return new Promise(function (resolve, reject) {
|
|
3121
3191
|
WidgetQuest.initWidgets((element, options) => new WidgetQuest(element, options), [element], localData).then(localData => {
|
|
@@ -3243,10 +3313,10 @@ class WidgetQuiz extends WidgetBase {
|
|
|
3243
3313
|
const selectedAnswerIndex = this.answers.indexOf(answer);
|
|
3244
3314
|
if (selectedAnswerIndex !== -1) {
|
|
3245
3315
|
this._selectAnswer(selectedAnswerIndex);
|
|
3246
|
-
|
|
3316
|
+
const isCorrect = this.answers[selectedAnswerIndex].classList.contains("check");
|
|
3247
3317
|
this.localData["q_score"] = (this.localData["q_score"] === undefined ? 0 : this.localData["q_score"]) + (isCorrect ? 1 : 0);
|
|
3248
|
-
|
|
3249
|
-
for (
|
|
3318
|
+
let answeredQuestion = 0;
|
|
3319
|
+
for (const key in this.localData) {
|
|
3250
3320
|
if (this.localData.hasOwnProperty(key)) {
|
|
3251
3321
|
if (/^_q_g_[A-z0-9-_]+_sa$/.test(key)) {
|
|
3252
3322
|
answeredQuestion++;
|
|
@@ -3273,7 +3343,7 @@ class WidgetQuiz extends WidgetBase {
|
|
|
3273
3343
|
}, 2000);
|
|
3274
3344
|
}
|
|
3275
3345
|
try {
|
|
3276
|
-
|
|
3346
|
+
const questionText = this.question ? this.question.textContent ?? "" : "";
|
|
3277
3347
|
let answerText = "";
|
|
3278
3348
|
if (this.answers[selectedAnswerIndex]) {
|
|
3279
3349
|
const answerLabel = this.answers[selectedAnswerIndex].querySelector(".variant-view .label");
|
|
@@ -3281,7 +3351,7 @@ class WidgetQuiz extends WidgetBase {
|
|
|
3281
3351
|
answerText = answerLabel.textContent;
|
|
3282
3352
|
}
|
|
3283
3353
|
}
|
|
3284
|
-
|
|
3354
|
+
const duration = new Date().getTime() - this.firstOpenTime;
|
|
3285
3355
|
this.sendStatisticEventToApp("w-quiz-answer", {
|
|
3286
3356
|
...this.statisticEventBaseFieldsShortForm,
|
|
3287
3357
|
wi: this.elementId,
|
|
@@ -3313,6 +3383,10 @@ class WidgetQuiz extends WidgetBase {
|
|
|
3313
3383
|
static api = {
|
|
3314
3384
|
widgetClassName: WidgetQuiz.widgetClassName,
|
|
3315
3385
|
refreshUserData: WidgetQuiz.refreshUserData,
|
|
3386
|
+
init: function (element, localData) {
|
|
3387
|
+
WidgetQuiz.initWidget(element, localData, (element, options) => new WidgetQuiz(element, options));
|
|
3388
|
+
},
|
|
3389
|
+
/** @deprecated */
|
|
3316
3390
|
initWidget: function (element, localData) {
|
|
3317
3391
|
WidgetQuiz.initWidgets((element, options) => new WidgetQuiz(element, options), [element], localData);
|
|
3318
3392
|
},
|
|
@@ -3506,6 +3580,10 @@ class WidgetQuizGrouped extends WidgetBase {
|
|
|
3506
3580
|
static api = {
|
|
3507
3581
|
widgetClassName: WidgetQuizGrouped.widgetClassName,
|
|
3508
3582
|
refreshUserData: WidgetQuizGrouped.refreshUserData,
|
|
3583
|
+
init: function (element, localData) {
|
|
3584
|
+
WidgetQuizGrouped.initWidget(element, localData, (element, options) => new WidgetQuizGrouped(element, options));
|
|
3585
|
+
},
|
|
3586
|
+
/** @deprecated */
|
|
3509
3587
|
initWidget: function (element, localData) {
|
|
3510
3588
|
WidgetQuizGrouped.initWidgets((element, options) => new WidgetQuizGrouped(element, options), [element], localData);
|
|
3511
3589
|
},
|
|
@@ -3639,7 +3717,7 @@ function tryParseFloat(str, defaultValue) {
|
|
|
3639
3717
|
if (str == null) {
|
|
3640
3718
|
return defaultValue;
|
|
3641
3719
|
}
|
|
3642
|
-
|
|
3720
|
+
const value = parseFloat(str);
|
|
3643
3721
|
return Number.isNaN(value) ? defaultValue : value;
|
|
3644
3722
|
}
|
|
3645
3723
|
/**
|
|
@@ -3954,7 +4032,7 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
3954
4032
|
if ((" " + e.target.className + " ").replace(/[\n\t]/g, " ").indexOf(this.options.handleClass) > -1) {
|
|
3955
4033
|
return;
|
|
3956
4034
|
}
|
|
3957
|
-
|
|
4035
|
+
const pos = this.getRelativePosition(e), rangePos = this.range.getBoundingClientRect()[this.DIRECTION], handlePos = this.getPositionFromNode(this.handle) - rangePos, setPos = this.orientation === "vertical" ? this.maxHandlePos - (pos - this.grabPos) : pos - this.grabPos;
|
|
3958
4036
|
this.setPosition(setPos);
|
|
3959
4037
|
if (pos >= handlePos && pos < handlePos + this.handleDimension) {
|
|
3960
4038
|
this.grabPos = pos - handlePos;
|
|
@@ -4114,6 +4192,10 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
4114
4192
|
static api = {
|
|
4115
4193
|
widgetClassName: WidgetRangeSlider.widgetClassName,
|
|
4116
4194
|
refreshUserData: WidgetRangeSlider.refreshUserData,
|
|
4195
|
+
init: function (element, localData) {
|
|
4196
|
+
WidgetRangeSlider.initWidget(element, localData, (element, options) => new WidgetRangeSlider(element, options));
|
|
4197
|
+
},
|
|
4198
|
+
/** @deprecated */
|
|
4117
4199
|
initWidget: function (element, localData) {
|
|
4118
4200
|
WidgetRangeSlider.initWidgets((element, options) => new WidgetRangeSlider(element, options), [element], localData);
|
|
4119
4201
|
},
|
|
@@ -4160,6 +4242,7 @@ class WidgetRate extends WidgetBase {
|
|
|
4160
4242
|
showDialogueMax;
|
|
4161
4243
|
selectedStar;
|
|
4162
4244
|
answerSelectDuration;
|
|
4245
|
+
elementRect;
|
|
4163
4246
|
constructor(element, options) {
|
|
4164
4247
|
super(element, options);
|
|
4165
4248
|
this.label = this.element.querySelector(".label-view .label");
|
|
@@ -4260,6 +4343,7 @@ class WidgetRate extends WidgetBase {
|
|
|
4260
4343
|
if (value + 1 >= this.showDialogueMin && value + 1 <= this.showDialogueMax) {
|
|
4261
4344
|
this.selectedStar = value;
|
|
4262
4345
|
if (this.showDialogOnLowRate) {
|
|
4346
|
+
this.elementRect = this.element.getBoundingClientRect();
|
|
4263
4347
|
this._selectStar(this.selectedStar, false);
|
|
4264
4348
|
if (this.sdkApi.isAndroid) {
|
|
4265
4349
|
this.slide.classList.add("blured");
|
|
@@ -4268,7 +4352,7 @@ class WidgetRate extends WidgetBase {
|
|
|
4268
4352
|
const dataString = this.element.dataset["clientdialogwidgetconfig"];
|
|
4269
4353
|
if (this.sdkApi.isExistsShowCardTextInput && dataString) {
|
|
4270
4354
|
const data = JSON.parse(dataString);
|
|
4271
|
-
data.size = getElementBounding(this.env, this.
|
|
4355
|
+
data.size = getElementBounding(this.env, this.elementRect);
|
|
4272
4356
|
if (!this.disableTimer) {
|
|
4273
4357
|
this.sdkApi.pauseUI();
|
|
4274
4358
|
}
|
|
@@ -4299,7 +4383,7 @@ class WidgetRate extends WidgetBase {
|
|
|
4299
4383
|
return false;
|
|
4300
4384
|
}
|
|
4301
4385
|
else if (value + 1 >= this.submitToStoresMin && value + 1 <= this.submitToStoresMax) {
|
|
4302
|
-
|
|
4386
|
+
let target = null;
|
|
4303
4387
|
if (this.sdkApi.isAndroid) {
|
|
4304
4388
|
target = getTagData(this.element, "androidLink");
|
|
4305
4389
|
}
|
|
@@ -4359,6 +4443,10 @@ class WidgetRate extends WidgetBase {
|
|
|
4359
4443
|
static api = {
|
|
4360
4444
|
widgetClassName: WidgetRate.widgetClassName,
|
|
4361
4445
|
refreshUserData: WidgetRate.refreshUserData,
|
|
4446
|
+
init: function (element, localData) {
|
|
4447
|
+
WidgetRate.initWidget(element, localData, (element, options) => new WidgetRate(element, options));
|
|
4448
|
+
},
|
|
4449
|
+
/** @deprecated */
|
|
4362
4450
|
initWidget: function (nodeList, localData) {
|
|
4363
4451
|
WidgetRate.initWidgets((element, options) => new WidgetRate(element, options), slice.call(nodeList), localData);
|
|
4364
4452
|
},
|
|
@@ -4414,6 +4502,9 @@ class WidgetShare extends WidgetBase {
|
|
|
4414
4502
|
this._showLayout(this.layers, 0);
|
|
4415
4503
|
}
|
|
4416
4504
|
}
|
|
4505
|
+
if (this.isDone() && this.disableTimer) {
|
|
4506
|
+
this.startDisabledTimeline();
|
|
4507
|
+
}
|
|
4417
4508
|
this.btnDisabled = false;
|
|
4418
4509
|
// this.refreshUserData(this.options.localData);
|
|
4419
4510
|
}
|
|
@@ -4472,6 +4563,9 @@ class WidgetShare extends WidgetBase {
|
|
|
4472
4563
|
if (isSuccess && this.withLayer) {
|
|
4473
4564
|
this._showLayout(this.layers, 1, true);
|
|
4474
4565
|
}
|
|
4566
|
+
if (this.disableTimer) {
|
|
4567
|
+
this.startDisabledTimeline();
|
|
4568
|
+
}
|
|
4475
4569
|
this.btnDisabled = false;
|
|
4476
4570
|
}
|
|
4477
4571
|
isDone() {
|
|
@@ -4480,10 +4574,15 @@ class WidgetShare extends WidgetBase {
|
|
|
4480
4574
|
static api = {
|
|
4481
4575
|
widgetClassName: WidgetShare.widgetClassName,
|
|
4482
4576
|
refreshUserData: WidgetShare.refreshUserData,
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4577
|
+
init: function (element, layers, localData) {
|
|
4578
|
+
WidgetShare.initWidget(element, localData, (element, options) => new WidgetShare(element, { ...options, layers }));
|
|
4579
|
+
},
|
|
4580
|
+
/** @deprecated
|
|
4581
|
+
* signature variants
|
|
4582
|
+
* (widget, layers, undefined) - modern web sdk
|
|
4583
|
+
* (widget, undefined, layers) - old web sdk and rn
|
|
4584
|
+
* (widget, layers, localData) - native sdk
|
|
4585
|
+
*/
|
|
4487
4586
|
initWidget: function (nodeList, layers, localData) {
|
|
4488
4587
|
if (layers === undefined && localData !== undefined) {
|
|
4489
4588
|
// @ts-ignore
|
|
@@ -4558,7 +4657,7 @@ class WidgetTest extends WidgetBase {
|
|
|
4558
4657
|
// if (this.state.timeLeft - this.timeLeft >= 950) {
|
|
4559
4658
|
// this.setState({timeLeft: this.timeLeft});
|
|
4560
4659
|
// }
|
|
4561
|
-
|
|
4660
|
+
const timeNow = new Date().getTime();
|
|
4562
4661
|
this.timeLeft -= timeNow - this.startTimerAt;
|
|
4563
4662
|
this.startTimerAt = timeNow;
|
|
4564
4663
|
if (this.timeLeft <= 0) {
|
|
@@ -4612,14 +4711,14 @@ class WidgetTest extends WidgetBase {
|
|
|
4612
4711
|
try {
|
|
4613
4712
|
if (this.selectedAnswer != null) {
|
|
4614
4713
|
const labelText = this.label?.textContent ?? "";
|
|
4615
|
-
|
|
4714
|
+
let answerText = "";
|
|
4616
4715
|
if (this.variants[this.selectedAnswer]) {
|
|
4617
|
-
|
|
4716
|
+
const answerLabel = this.variants[this.selectedAnswer].querySelector(".label");
|
|
4618
4717
|
if (answerLabel != null) {
|
|
4619
4718
|
answerText = answerLabel.textContent ?? "";
|
|
4620
4719
|
}
|
|
4621
4720
|
}
|
|
4622
|
-
|
|
4721
|
+
const duration = new Date().getTime() - this.firstOpenTime;
|
|
4623
4722
|
this.sendStatisticEventToApp("w-test-answer", {
|
|
4624
4723
|
...this.statisticEventBaseFieldsShortForm,
|
|
4625
4724
|
wi: this.elementId,
|
|
@@ -4663,9 +4762,9 @@ class WidgetTest extends WidgetBase {
|
|
|
4663
4762
|
if (this.selectedAnswer !== undefined) {
|
|
4664
4763
|
return true;
|
|
4665
4764
|
}
|
|
4666
|
-
|
|
4765
|
+
const index = this.variants.indexOf(answer);
|
|
4667
4766
|
if (index !== -1) {
|
|
4668
|
-
|
|
4767
|
+
const answerScore = getValueOrDefault(getTagDataAsNumber(this.variants[index], "score"), 0);
|
|
4669
4768
|
this._completeWidget(index, answerScore);
|
|
4670
4769
|
}
|
|
4671
4770
|
if (Boolean(this.withTimeToAnswer && this.answerTimeout)) {
|
|
@@ -4677,15 +4776,15 @@ class WidgetTest extends WidgetBase {
|
|
|
4677
4776
|
if (this.selectedAnswer !== undefined) {
|
|
4678
4777
|
return;
|
|
4679
4778
|
}
|
|
4680
|
-
|
|
4779
|
+
const index = -1, answerScore = 0;
|
|
4681
4780
|
this._completeWidget(index, answerScore);
|
|
4682
4781
|
}
|
|
4683
4782
|
// complete answer select and save local data + stat event
|
|
4684
4783
|
_completeWidget(index, answerScore) {
|
|
4685
4784
|
this._selectAnswer(index);
|
|
4686
4785
|
this.localData["t_score"] = (this.localData["t_score"] === undefined ? 0 : this.localData["t_score"]) + answerScore;
|
|
4687
|
-
|
|
4688
|
-
for (
|
|
4786
|
+
let answeredQuestion = 0;
|
|
4787
|
+
for (const key in this.localData) {
|
|
4689
4788
|
if (this.localData.hasOwnProperty(key)) {
|
|
4690
4789
|
if (/^_t_g_[A-z0-9-_]+_sa$/.test(key)) {
|
|
4691
4790
|
answeredQuestion++;
|
|
@@ -4728,6 +4827,10 @@ class WidgetTest extends WidgetBase {
|
|
|
4728
4827
|
static api = {
|
|
4729
4828
|
widgetClassName: WidgetTest.widgetClassName,
|
|
4730
4829
|
refreshUserData: WidgetTest.refreshUserData,
|
|
4830
|
+
init: function (element, localData) {
|
|
4831
|
+
WidgetTest.initWidget(element, localData, (element, options) => new WidgetTest(element, options));
|
|
4832
|
+
},
|
|
4833
|
+
/** @deprecated */
|
|
4731
4834
|
initWidget: function (element, localData) {
|
|
4732
4835
|
WidgetTest.initWidgets((element, options) => new WidgetTest(element, options), [element], localData);
|
|
4733
4836
|
},
|
|
@@ -4996,7 +5099,7 @@ class WidgetVote extends WidgetBase {
|
|
|
4996
5099
|
return true;
|
|
4997
5100
|
}
|
|
4998
5101
|
}
|
|
4999
|
-
|
|
5102
|
+
const selectedVariantIndex = this.variants.indexOf(variant);
|
|
5000
5103
|
if (selectedVariantIndex !== -1) {
|
|
5001
5104
|
this._checkVariant(selectedVariantIndex);
|
|
5002
5105
|
if (this.multipleChoice) {
|
|
@@ -5095,7 +5198,7 @@ class WidgetVote extends WidgetBase {
|
|
|
5095
5198
|
}
|
|
5096
5199
|
voteAllocationTs = sharedData.ts;
|
|
5097
5200
|
}
|
|
5098
|
-
|
|
5201
|
+
const voteDoneAt = this.localData["_v_g_" + this.elementId + "_done_at"];
|
|
5099
5202
|
if (voteAllocationTs === undefined || voteDoneAt === undefined || voteDoneAt > voteAllocationTs) {
|
|
5100
5203
|
forEach(this.variants, function (element, index) {
|
|
5101
5204
|
const key = index;
|
|
@@ -5108,7 +5211,7 @@ class WidgetVote extends WidgetBase {
|
|
|
5108
5211
|
});
|
|
5109
5212
|
}
|
|
5110
5213
|
// calc percents
|
|
5111
|
-
|
|
5214
|
+
let percents = [], total = 0;
|
|
5112
5215
|
forEach(this.variants, (element, index) => {
|
|
5113
5216
|
const key = index;
|
|
5114
5217
|
if (voteAllocation[key] !== undefined) {
|
|
@@ -5131,10 +5234,10 @@ class WidgetVote extends WidgetBase {
|
|
|
5131
5234
|
// percents[i] += '%';
|
|
5132
5235
|
}
|
|
5133
5236
|
}
|
|
5134
|
-
|
|
5237
|
+
const self = this;
|
|
5135
5238
|
forEach(this.variants, (element, index) => {
|
|
5136
5239
|
const key = index;
|
|
5137
|
-
|
|
5240
|
+
const percentLabels = slice.call(element.querySelectorAll(".percent-label"));
|
|
5138
5241
|
forEach(percentLabels, label => {
|
|
5139
5242
|
if (percents[key] != null) {
|
|
5140
5243
|
label.textContent = percents[key] + "%";
|
|
@@ -5142,7 +5245,7 @@ class WidgetVote extends WidgetBase {
|
|
|
5142
5245
|
});
|
|
5143
5246
|
element.classList.add("selected");
|
|
5144
5247
|
});
|
|
5145
|
-
|
|
5248
|
+
const cb = function () {
|
|
5146
5249
|
forEach(self.variants, function (element, index) {
|
|
5147
5250
|
const key = index;
|
|
5148
5251
|
if (percents[key] != null) {
|
|
@@ -5166,18 +5269,24 @@ class WidgetVote extends WidgetBase {
|
|
|
5166
5269
|
static api = {
|
|
5167
5270
|
widgetClassName: WidgetVote.widgetClassName,
|
|
5168
5271
|
refreshUserData: WidgetVote.refreshUserData,
|
|
5169
|
-
|
|
5272
|
+
init: function (element, localData) {
|
|
5273
|
+
WidgetVote.initWidget(element, localData, (element, options) => new WidgetVote(element, options));
|
|
5274
|
+
},
|
|
5275
|
+
/** @deprecated
|
|
5276
|
+
*
|
|
5277
|
+
* fix for WidgetVote on every layer of multilayers story
|
|
5278
|
+
*/
|
|
5170
5279
|
fallbackInitOnMultiSlide: function (element, localData) {
|
|
5171
5280
|
if (element.dataset.fallbackInitOnMultiSlide) {
|
|
5172
5281
|
return;
|
|
5173
5282
|
}
|
|
5174
|
-
|
|
5283
|
+
const multiSlide = element.closest(".narrative-multi-slide");
|
|
5175
5284
|
if (multiSlide != null) {
|
|
5176
|
-
|
|
5177
|
-
|
|
5285
|
+
const container = multiSlide.parentElement;
|
|
5286
|
+
const widgetElements = container?.querySelectorAll(`.${WidgetVote.widgetClassName}`);
|
|
5178
5287
|
if (widgetElements != null) {
|
|
5179
|
-
for (
|
|
5180
|
-
|
|
5288
|
+
for (let i = 0; i < widgetElements.length; ++i) {
|
|
5289
|
+
const widgetElement = widgetElements[i];
|
|
5181
5290
|
const widget = WidgetVote.getInstance(widgetElement);
|
|
5182
5291
|
if (!widget) {
|
|
5183
5292
|
WidgetVote.initWidgets((element, options) => new WidgetVote(element, options), [widgetElement], localData);
|
|
@@ -5187,6 +5296,7 @@ class WidgetVote extends WidgetBase {
|
|
|
5187
5296
|
}
|
|
5188
5297
|
element.dataset.fallbackInitOnMultiSlide = "1";
|
|
5189
5298
|
},
|
|
5299
|
+
/** @deprecated */
|
|
5190
5300
|
initWidget: function (element, localData) {
|
|
5191
5301
|
WidgetVote.initWidgets((element, options) => new WidgetVote(element, options), [element], localData).then(localData => {
|
|
5192
5302
|
WidgetVote.api.fallbackInitOnMultiSlide(element, localData);
|
|
@@ -14627,7 +14737,7 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14627
14737
|
isTransparentElement() {
|
|
14628
14738
|
if (this.element) {
|
|
14629
14739
|
try {
|
|
14630
|
-
|
|
14740
|
+
const color = window.getComputedStyle(this.element).color;
|
|
14631
14741
|
if (color === "transparent" || color === "rgba(0, 0, 0, 0)" || color === "rgba(0,0,0,0)") {
|
|
14632
14742
|
return true;
|
|
14633
14743
|
}
|
|
@@ -14734,10 +14844,10 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14734
14844
|
return setTimeout(t, 300);
|
|
14735
14845
|
}),
|
|
14736
14846
|
]).then(values => {
|
|
14737
|
-
|
|
14738
|
-
|
|
14739
|
-
|
|
14740
|
-
|
|
14847
|
+
const r = values[0];
|
|
14848
|
+
const status = r.status;
|
|
14849
|
+
let code = null;
|
|
14850
|
+
let success = false;
|
|
14741
14851
|
if (status === 200 || status === 201) {
|
|
14742
14852
|
if (r.data)
|
|
14743
14853
|
code = r.data.code;
|
|
@@ -14782,7 +14892,7 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14782
14892
|
}
|
|
14783
14893
|
_statEventCopyClick(clipboardTarget) {
|
|
14784
14894
|
try {
|
|
14785
|
-
|
|
14895
|
+
const captionViewText = this.captionView?.textContent ?? "";
|
|
14786
14896
|
this.sendStatisticEventToApp("w-barcode", {
|
|
14787
14897
|
...this.statisticEventBaseFieldsShortForm,
|
|
14788
14898
|
wi: this.elementId,
|
|
@@ -14813,7 +14923,7 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14813
14923
|
}
|
|
14814
14924
|
copyToClipboard(element) {
|
|
14815
14925
|
this._select();
|
|
14816
|
-
|
|
14926
|
+
const text = this.clipboardTarget ?? "";
|
|
14817
14927
|
Clipboard.copy(text);
|
|
14818
14928
|
this.completeWidget();
|
|
14819
14929
|
this._statEventCopyClick(text);
|
|
@@ -14830,6 +14940,10 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14830
14940
|
static api = {
|
|
14831
14941
|
widgetClassName: WidgetBarcode.widgetClassName,
|
|
14832
14942
|
refreshUserData: WidgetBarcode.refreshUserData,
|
|
14943
|
+
init: function (element, localData) {
|
|
14944
|
+
WidgetBarcode.initWidget(element, localData, (element, options) => new WidgetBarcode(element, options));
|
|
14945
|
+
},
|
|
14946
|
+
/** @deprecated */
|
|
14833
14947
|
initWidget: function (nodeList, localData) {
|
|
14834
14948
|
WidgetBarcode.initWidgets((element, options) => new WidgetBarcode(element, options), slice.call(nodeList), localData);
|
|
14835
14949
|
},
|