@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.js
CHANGED
|
@@ -1280,6 +1280,27 @@ class WidgetBase {
|
|
|
1280
1280
|
}
|
|
1281
1281
|
return instance;
|
|
1282
1282
|
}
|
|
1283
|
+
static initWidget(htmlElement, localData, instantiate) {
|
|
1284
|
+
if (localData != null) {
|
|
1285
|
+
this.createInstance(instantiate, htmlElement, {
|
|
1286
|
+
slide: null,
|
|
1287
|
+
localData,
|
|
1288
|
+
});
|
|
1289
|
+
return Promise.resolve(localData);
|
|
1290
|
+
}
|
|
1291
|
+
else {
|
|
1292
|
+
return new Promise(resolve => {
|
|
1293
|
+
this.getLocalData().then(localData => {
|
|
1294
|
+
this.createInstance(instantiate, htmlElement, {
|
|
1295
|
+
slide: null,
|
|
1296
|
+
localData,
|
|
1297
|
+
});
|
|
1298
|
+
resolve(localData);
|
|
1299
|
+
});
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
/** @deprecated */
|
|
1283
1304
|
static initWidgets(instantiate, elements, localData) {
|
|
1284
1305
|
if (localData != null) {
|
|
1285
1306
|
forEach(elements, element => {
|
|
@@ -1477,16 +1498,16 @@ class WidgetCopy extends WidgetBase {
|
|
|
1477
1498
|
this.resultLayerGeometry = this.resultLayer.closest(".narrative-element-geometry");
|
|
1478
1499
|
// create align center
|
|
1479
1500
|
if (this.resultLayerGeometry) {
|
|
1480
|
-
|
|
1481
|
-
|
|
1501
|
+
const baseComputedGeometry = window.getComputedStyle(this.geometry);
|
|
1502
|
+
let resultComputedGeometry = window.getComputedStyle(this.resultLayerGeometry);
|
|
1482
1503
|
if (parseFloat(resultComputedGeometry.width) < parseFloat(baseComputedGeometry.width)) {
|
|
1483
1504
|
// prevent resultLayer shrinking
|
|
1484
1505
|
this.resultLayerGeometry.style.setProperty("width", parseFloat(baseComputedGeometry.width) + "px");
|
|
1485
1506
|
resultComputedGeometry = window.getComputedStyle(this.resultLayerGeometry);
|
|
1486
1507
|
}
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1508
|
+
const geometryCenter = parseFloat(baseComputedGeometry.left) + parseFloat(baseComputedGeometry.width) / 2;
|
|
1509
|
+
const resultLayerGeometryWidth = parseFloat(resultComputedGeometry.width);
|
|
1510
|
+
const newResultLayerGeometryLeft = geometryCenter - resultLayerGeometryWidth / 2;
|
|
1490
1511
|
this.resultLayerGeometry.style.setProperty("left", newResultLayerGeometryLeft + "px");
|
|
1491
1512
|
}
|
|
1492
1513
|
}
|
|
@@ -1499,7 +1520,7 @@ class WidgetCopy extends WidgetBase {
|
|
|
1499
1520
|
isTransparentElement() {
|
|
1500
1521
|
if (this.element) {
|
|
1501
1522
|
try {
|
|
1502
|
-
|
|
1523
|
+
const color = window.getComputedStyle(this.element).color;
|
|
1503
1524
|
if (color === "transparent" || color === "rgba(0, 0, 0, 0)" || color === "rgba(0,0,0,0)") {
|
|
1504
1525
|
return true;
|
|
1505
1526
|
}
|
|
@@ -1590,7 +1611,7 @@ class WidgetCopy extends WidgetBase {
|
|
|
1590
1611
|
}
|
|
1591
1612
|
_statEventCopyClick(clipboardTarget) {
|
|
1592
1613
|
try {
|
|
1593
|
-
|
|
1614
|
+
const buttonText = this.button?.textContent ?? "";
|
|
1594
1615
|
this.sendStatisticEventToApp("w-copy", {
|
|
1595
1616
|
...this.statisticEventBaseFieldsShortForm,
|
|
1596
1617
|
wi: this.elementId,
|
|
@@ -1621,7 +1642,7 @@ class WidgetCopy extends WidgetBase {
|
|
|
1621
1642
|
}
|
|
1622
1643
|
copyToClipboard(element) {
|
|
1623
1644
|
this._select();
|
|
1624
|
-
|
|
1645
|
+
const text = this.clipboardTarget ?? "";
|
|
1625
1646
|
Clipboard.copy(text);
|
|
1626
1647
|
this.completeWidget();
|
|
1627
1648
|
this._statEventCopyClick(text);
|
|
@@ -1638,6 +1659,13 @@ class WidgetCopy extends WidgetBase {
|
|
|
1638
1659
|
static api = {
|
|
1639
1660
|
widgetClassName: WidgetCopy.widgetClassName,
|
|
1640
1661
|
refreshUserData: WidgetCopy.refreshUserData,
|
|
1662
|
+
init: function (element, localData) {
|
|
1663
|
+
// prevent initWidget for result layer
|
|
1664
|
+
if (!element.classList.contains("narrative-element-copy-result-variant")) {
|
|
1665
|
+
WidgetCopy.initWidget(element, localData, (element, options) => new WidgetCopy(element, options));
|
|
1666
|
+
}
|
|
1667
|
+
},
|
|
1668
|
+
/** @deprecated */
|
|
1641
1669
|
initWidget: function (nodeList, localData) {
|
|
1642
1670
|
// prevent initWidget for result layer
|
|
1643
1671
|
const elements = slice.call(nodeList).filter(element => !element.classList.contains("narrative-element-copy-result-variant"));
|
|
@@ -1696,7 +1724,7 @@ class WidgetDataInput extends WidgetBase {
|
|
|
1696
1724
|
refreshUserData(localData) {
|
|
1697
1725
|
this.savedData = this.sdkApi.getCardServerData(this.cardId);
|
|
1698
1726
|
this.localData = extend({}, this.savedData ?? {}, localData);
|
|
1699
|
-
|
|
1727
|
+
const text = this.localData["_di_g_" + this.elementId + "_t"];
|
|
1700
1728
|
this._fillUserText(text);
|
|
1701
1729
|
if (text) {
|
|
1702
1730
|
this.element.classList.add("done");
|
|
@@ -1796,7 +1824,7 @@ class WidgetDataInput extends WidgetBase {
|
|
|
1796
1824
|
setUserText(text) {
|
|
1797
1825
|
this.slide.classList.remove("data-input-editing");
|
|
1798
1826
|
this.slide.classList.remove("blured");
|
|
1799
|
-
|
|
1827
|
+
let needResumeUITimer = true;
|
|
1800
1828
|
if (text) {
|
|
1801
1829
|
this._fillUserText(text);
|
|
1802
1830
|
this.localData["_di_g_" + this.elementId + "_t"] = text;
|
|
@@ -1825,6 +1853,10 @@ class WidgetDataInput extends WidgetBase {
|
|
|
1825
1853
|
static api = {
|
|
1826
1854
|
widgetClassName: WidgetDataInput.widgetClassName,
|
|
1827
1855
|
refreshUserData: WidgetDataInput.refreshUserData,
|
|
1856
|
+
init: function (element, localData) {
|
|
1857
|
+
WidgetDataInput.initWidget(element, localData, (element, options) => new WidgetDataInput(element, options));
|
|
1858
|
+
},
|
|
1859
|
+
/** @deprecated */
|
|
1828
1860
|
initWidget: function (nodeList, localData) {
|
|
1829
1861
|
WidgetDataInput.initWidgets((element, options) => new WidgetDataInput(element, options), slice.call(nodeList), localData);
|
|
1830
1862
|
},
|
|
@@ -1937,16 +1969,16 @@ class WidgetDateCountdown extends WidgetBase {
|
|
|
1937
1969
|
this.thirdGroupCaption = getValueOrException(this.element.querySelector(".date-item-view-group-3 .date-item-caption"), "Empty thirdGroupCaption");
|
|
1938
1970
|
this.timestampSeconds *= 1000;
|
|
1939
1971
|
this.timerInited = true;
|
|
1940
|
-
|
|
1972
|
+
const value = this.timestampSeconds - (new Date().getTime() - this.diff);
|
|
1941
1973
|
if (value > 0) {
|
|
1942
1974
|
this._showLayout(this.layers, 0);
|
|
1943
1975
|
}
|
|
1944
1976
|
this.updateTimer();
|
|
1945
1977
|
}
|
|
1946
1978
|
updateTimer() {
|
|
1947
|
-
|
|
1979
|
+
const value = this.timestampSeconds - (new Date().getTime() - this.diff);
|
|
1948
1980
|
if (value > 0) {
|
|
1949
|
-
|
|
1981
|
+
const result = this._asDuration(Math.round(value / 1000));
|
|
1950
1982
|
if (result.days) {
|
|
1951
1983
|
this.firstGroupCaption.textContent = this.messages.days;
|
|
1952
1984
|
this.firstGroup1.textContent = result.day1;
|
|
@@ -1980,7 +2012,7 @@ class WidgetDateCountdown extends WidgetBase {
|
|
|
1980
2012
|
}
|
|
1981
2013
|
}
|
|
1982
2014
|
_asDuration(value) {
|
|
1983
|
-
|
|
2015
|
+
const result = {
|
|
1984
2016
|
days: false,
|
|
1985
2017
|
day1: "0",
|
|
1986
2018
|
day2: "0",
|
|
@@ -1998,11 +2030,11 @@ class WidgetDateCountdown extends WidgetBase {
|
|
|
1998
2030
|
return result;
|
|
1999
2031
|
}
|
|
2000
2032
|
value = Math.floor(value);
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2033
|
+
const days = Math.floor((value / 86400) % 365);
|
|
2034
|
+
const hours = Math.floor((value / 3600) % 24);
|
|
2035
|
+
const minutes = Math.floor((value / 60) % 60);
|
|
2036
|
+
const seconds = value % 60;
|
|
2037
|
+
let pair;
|
|
2006
2038
|
if (days > 0) {
|
|
2007
2039
|
result.days = true;
|
|
2008
2040
|
if (days < 10)
|
|
@@ -2039,14 +2071,26 @@ class WidgetDateCountdown extends WidgetBase {
|
|
|
2039
2071
|
static api = {
|
|
2040
2072
|
widgetClassName: WidgetDateCountdown.widgetClassName,
|
|
2041
2073
|
refreshUserData: WidgetDateCountdown.refreshUserData,
|
|
2074
|
+
init: function (element, layers, localData) {
|
|
2075
|
+
WidgetDateCountdown.initWidget(element, localData, (element, options) => new WidgetDateCountdown(element, { ...options, layers }));
|
|
2076
|
+
},
|
|
2077
|
+
/** @deprecated */
|
|
2042
2078
|
initWidget: function (nodeList, layers, localData) {
|
|
2043
2079
|
WidgetDateCountdown.initWidgets((element, options) => new WidgetDateCountdown(element, { ...options, layers }), slice.call(nodeList), localData);
|
|
2044
2080
|
},
|
|
2081
|
+
onPause: function (element) {
|
|
2082
|
+
WidgetDateCountdown.getInstance(element)?.pause();
|
|
2083
|
+
},
|
|
2084
|
+
onResume: function (element) {
|
|
2085
|
+
WidgetDateCountdown.getInstance(element)?.resume();
|
|
2086
|
+
},
|
|
2087
|
+
/** @deprecated */
|
|
2045
2088
|
pause: function (nodeList) {
|
|
2046
2089
|
forEach(slice.call(nodeList), function (el, index) {
|
|
2047
2090
|
WidgetDateCountdown.getInstance(el)?.pause();
|
|
2048
2091
|
});
|
|
2049
2092
|
},
|
|
2093
|
+
/** @deprecated */
|
|
2050
2094
|
resume: function (nodeList) {
|
|
2051
2095
|
forEach(slice.call(nodeList), function (el, index) {
|
|
2052
2096
|
WidgetDateCountdown.getInstance(el)?.resume();
|
|
@@ -2210,6 +2254,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
2210
2254
|
selectedVariant;
|
|
2211
2255
|
nativeDialogueWasOpened = false;
|
|
2212
2256
|
answerDuration = 0;
|
|
2257
|
+
elementRect;
|
|
2213
2258
|
/**
|
|
2214
2259
|
* @throws Error
|
|
2215
2260
|
* @param element
|
|
@@ -2255,8 +2300,8 @@ class WidgetPoll extends WidgetBase {
|
|
|
2255
2300
|
this.answerDuration = new Date().getTime() - this.firstOpenTime;
|
|
2256
2301
|
try {
|
|
2257
2302
|
if (this.selectedVariant !== undefined) {
|
|
2258
|
-
|
|
2259
|
-
|
|
2303
|
+
const labelText = this.label?.textContent ?? "";
|
|
2304
|
+
const variantText = this.variantsTexts[this.selectedVariant] ? this.variantsTexts[this.selectedVariant] : "";
|
|
2260
2305
|
this.sendStatisticEventToApp("w-poll-answer", {
|
|
2261
2306
|
...this.statisticEventBaseFieldsShortForm,
|
|
2262
2307
|
wi: this.elementId,
|
|
@@ -2348,6 +2393,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
2348
2393
|
}
|
|
2349
2394
|
const index = this.variants.indexOf(variantView);
|
|
2350
2395
|
if (index !== -1) {
|
|
2396
|
+
this.elementRect = this.element.getBoundingClientRect();
|
|
2351
2397
|
if (this.getUseResponseOnFirstButton && index === 0) {
|
|
2352
2398
|
if (this.sdkApi.isAndroid) {
|
|
2353
2399
|
this.slide.classList.add("blured");
|
|
@@ -2357,7 +2403,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
2357
2403
|
this.selectedVariant = index;
|
|
2358
2404
|
if (this.sdkApi.isExistsShowCardTextInput && dataString) {
|
|
2359
2405
|
const data = JSON.parse(dataString);
|
|
2360
|
-
data.size = getElementBounding(this.env, this.
|
|
2406
|
+
data.size = getElementBounding(this.env, this.elementRect);
|
|
2361
2407
|
if (!this.disableTimer) {
|
|
2362
2408
|
this.sdkApi.pauseUI();
|
|
2363
2409
|
}
|
|
@@ -2391,7 +2437,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
2391
2437
|
this.selectedVariant = index;
|
|
2392
2438
|
if (this.sdkApi.isExistsShowCardTextInput && dataString) {
|
|
2393
2439
|
const data = JSON.parse(dataString);
|
|
2394
|
-
data.size = getElementBounding(this.env, this.
|
|
2440
|
+
data.size = getElementBounding(this.env, this.elementRect);
|
|
2395
2441
|
if (!this.disableTimer) {
|
|
2396
2442
|
this.sdkApi.pauseUI();
|
|
2397
2443
|
}
|
|
@@ -2666,6 +2712,10 @@ class WidgetPoll extends WidgetBase {
|
|
|
2666
2712
|
static api = {
|
|
2667
2713
|
widgetClassName: WidgetPoll.widgetClassName,
|
|
2668
2714
|
refreshUserData: WidgetPoll.refreshUserData,
|
|
2715
|
+
init: function (element, localData) {
|
|
2716
|
+
WidgetPoll.initWidget(element, localData, (element, options) => new WidgetPoll(element, options));
|
|
2717
|
+
},
|
|
2718
|
+
/** @deprecated */
|
|
2669
2719
|
initWidget: function (element, localData) {
|
|
2670
2720
|
WidgetPoll.initWidgets((element, options) => new WidgetPoll(element, options), [element], localData);
|
|
2671
2721
|
},
|
|
@@ -2750,9 +2800,9 @@ class WidgetPollLayers extends WidgetBase {
|
|
|
2750
2800
|
_statEventPollVariant() {
|
|
2751
2801
|
try {
|
|
2752
2802
|
if (this.selectedVariant != null) {
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2803
|
+
const labelText = this.label?.textContent ?? "";
|
|
2804
|
+
const variantText = this.variants[this.selectedVariant]?.textContent ?? "";
|
|
2805
|
+
const duration = new Date().getTime() - this.firstOpenTime;
|
|
2756
2806
|
this.sendStatisticEventToApp("w-poll-layers-answer", {
|
|
2757
2807
|
...this.statisticEventBaseFieldsShortForm,
|
|
2758
2808
|
wi: this.elementId,
|
|
@@ -2782,7 +2832,7 @@ class WidgetPollLayers extends WidgetBase {
|
|
|
2782
2832
|
this.localData["_pl_g_" + this.elementId + "_sa"] = index;
|
|
2783
2833
|
this.element.classList.add("done");
|
|
2784
2834
|
// main
|
|
2785
|
-
|
|
2835
|
+
let layerIndex = 0;
|
|
2786
2836
|
if (index === 0) {
|
|
2787
2837
|
layerIndex = 1;
|
|
2788
2838
|
}
|
|
@@ -2798,7 +2848,7 @@ class WidgetPollLayers extends WidgetBase {
|
|
|
2798
2848
|
if (this.selectedVariant !== undefined) {
|
|
2799
2849
|
return true;
|
|
2800
2850
|
}
|
|
2801
|
-
|
|
2851
|
+
const index = this.variants.indexOf(variant);
|
|
2802
2852
|
if (index !== -1) {
|
|
2803
2853
|
this._selectVariant(index, true);
|
|
2804
2854
|
this.completeWidget();
|
|
@@ -2830,10 +2880,16 @@ class WidgetPollLayers extends WidgetBase {
|
|
|
2830
2880
|
static api = {
|
|
2831
2881
|
widgetClassName: WidgetPollLayers.widgetClassName,
|
|
2832
2882
|
refreshUserData: WidgetPollLayers.refreshUserData,
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2883
|
+
init: function (element, layers, localData) {
|
|
2884
|
+
WidgetPollLayers.initWidget(element, localData, (element, options) => new WidgetPollLayers(element, { ...options, layers }));
|
|
2885
|
+
},
|
|
2886
|
+
/** @deprecated
|
|
2887
|
+
*
|
|
2888
|
+
* signature variants
|
|
2889
|
+
* (widget, layers, undefined) - modern web sdk
|
|
2890
|
+
* (widget, undefined, layers) - old web sdk and rn
|
|
2891
|
+
* (widget, layers, localData) - native sdk
|
|
2892
|
+
*/
|
|
2837
2893
|
initWidget: function (element, layers, localData) {
|
|
2838
2894
|
if (layers === undefined && localData !== undefined) {
|
|
2839
2895
|
// @ts-ignore
|
|
@@ -2904,7 +2960,7 @@ class WidgetQuest extends WidgetBase {
|
|
|
2904
2960
|
this.localData["_qt_fo_at"] = Math.round(new Date().getTime() / 1000);
|
|
2905
2961
|
this.setLocalData(this.localData, false);
|
|
2906
2962
|
}
|
|
2907
|
-
|
|
2963
|
+
let lastSlideIdx = this.localData["_qt_last_slide_idx"];
|
|
2908
2964
|
if (lastSlideIdx !== undefined) {
|
|
2909
2965
|
lastSlideIdx = parseInt(lastSlideIdx);
|
|
2910
2966
|
if (lastSlideIdx >= 0 &&
|
|
@@ -2922,7 +2978,7 @@ class WidgetQuest extends WidgetBase {
|
|
|
2922
2978
|
}
|
|
2923
2979
|
}
|
|
2924
2980
|
// если этого слайда нет в роутинге (сработал переход по таймеру в app)
|
|
2925
|
-
|
|
2981
|
+
const routes = this._getRoutes();
|
|
2926
2982
|
if (routes[0].indexOf(this.slideIndex) === -1 && this.finalSlide) {
|
|
2927
2983
|
if (this.sdkApi.isExistsShowNextCard) {
|
|
2928
2984
|
this.sdkApi.cardShowNext();
|
|
@@ -2964,9 +3020,9 @@ class WidgetQuest extends WidgetBase {
|
|
|
2964
3020
|
// if (this.selectedAnswer !== undefined) {
|
|
2965
3021
|
// return true;
|
|
2966
3022
|
// }
|
|
2967
|
-
|
|
3023
|
+
const index = this.variants.indexOf(answer);
|
|
2968
3024
|
if (index !== -1) {
|
|
2969
|
-
|
|
3025
|
+
const slideIndex = getValueOrDefault(getTagDataAsNumber(this.variants[index], "score"), 0) - 1;
|
|
2970
3026
|
this._selectAnswer(index, slideIndex);
|
|
2971
3027
|
this.setLocalData(this.localData, true);
|
|
2972
3028
|
this.env.setTimeout(() => {
|
|
@@ -2992,22 +3048,22 @@ class WidgetQuest extends WidgetBase {
|
|
|
2992
3048
|
return getTagDataAsNumber(this.slide, "lastSlideWithQuest") ?? 0;
|
|
2993
3049
|
}
|
|
2994
3050
|
_getRoutes() {
|
|
2995
|
-
|
|
3051
|
+
let routes = this.localData["_qt_routes"];
|
|
2996
3052
|
if (!Array.isArray(routes)) {
|
|
2997
3053
|
routes = [[0], 0];
|
|
2998
3054
|
}
|
|
2999
3055
|
return routes;
|
|
3000
3056
|
}
|
|
3001
3057
|
_addNewRouteHistory(route) {
|
|
3002
|
-
|
|
3003
|
-
|
|
3058
|
+
const routes = this._getRoutes();
|
|
3059
|
+
const _routes = routes[0].slice(0, routes[1] + 1);
|
|
3004
3060
|
routes[0] = _routes.concat([route]);
|
|
3005
3061
|
routes[1] = routes[0].length - 1;
|
|
3006
3062
|
this.localData["_qt_routes"] = routes;
|
|
3007
3063
|
}
|
|
3008
3064
|
_routeMvPtrBack() {
|
|
3009
|
-
|
|
3010
|
-
|
|
3065
|
+
const routes = this._getRoutes();
|
|
3066
|
+
const newPtr = routes[1] - 1;
|
|
3011
3067
|
if (newPtr >= 0 && routes[0][newPtr] !== undefined) {
|
|
3012
3068
|
routes[1] = newPtr;
|
|
3013
3069
|
this.localData["_qt_routes"] = routes;
|
|
@@ -3017,12 +3073,13 @@ class WidgetQuest extends WidgetBase {
|
|
|
3017
3073
|
return false;
|
|
3018
3074
|
}
|
|
3019
3075
|
getLastSlideIndexFromRouteHistory() {
|
|
3020
|
-
|
|
3076
|
+
const routes = this._getRoutes();
|
|
3021
3077
|
return routes[0][routes[1]];
|
|
3022
3078
|
}
|
|
3023
3079
|
handleRouteClick(event) {
|
|
3080
|
+
let moveTo;
|
|
3024
3081
|
// event: direction ('backward', 'forward') slideIndex, slideCount
|
|
3025
|
-
|
|
3082
|
+
const directionForward = event.direction === "forward";
|
|
3026
3083
|
event.direction === "backward";
|
|
3027
3084
|
if (this.isWidget) {
|
|
3028
3085
|
if (directionForward) {
|
|
@@ -3035,7 +3092,7 @@ class WidgetQuest extends WidgetBase {
|
|
|
3035
3092
|
}
|
|
3036
3093
|
else {
|
|
3037
3094
|
// by routing - move back
|
|
3038
|
-
|
|
3095
|
+
moveTo = this._routeMvPtrBack();
|
|
3039
3096
|
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.sdkApi.isExistsShowCardSlide) {
|
|
3040
3097
|
this.sdkApi.showCardSlide(moveTo);
|
|
3041
3098
|
}
|
|
@@ -3052,7 +3109,7 @@ class WidgetQuest extends WidgetBase {
|
|
|
3052
3109
|
// simple slide case
|
|
3053
3110
|
if (this.nonFinalSlide || event.slideIndex < this.firstSlideWithQuestIndex()) {
|
|
3054
3111
|
if (directionForward) {
|
|
3055
|
-
|
|
3112
|
+
const nextSlideIndex = event.slideIndex + 1;
|
|
3056
3113
|
if (nextSlideIndex < this.slideCount) {
|
|
3057
3114
|
this._addNewRouteHistory(nextSlideIndex);
|
|
3058
3115
|
this.setLocalData(this.localData, true);
|
|
@@ -3071,7 +3128,7 @@ class WidgetQuest extends WidgetBase {
|
|
|
3071
3128
|
}
|
|
3072
3129
|
else {
|
|
3073
3130
|
// by routing - move back
|
|
3074
|
-
|
|
3131
|
+
moveTo = this._routeMvPtrBack();
|
|
3075
3132
|
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.sdkApi.isExistsShowCardSlide) {
|
|
3076
3133
|
this.sdkApi.showCardSlide(moveTo);
|
|
3077
3134
|
}
|
|
@@ -3099,7 +3156,7 @@ class WidgetQuest extends WidgetBase {
|
|
|
3099
3156
|
}
|
|
3100
3157
|
else {
|
|
3101
3158
|
// by routing - move back
|
|
3102
|
-
|
|
3159
|
+
moveTo = this._routeMvPtrBack();
|
|
3103
3160
|
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.sdkApi.isExistsShowCardSlide) {
|
|
3104
3161
|
this.sdkApi.showCardSlide(moveTo);
|
|
3105
3162
|
}
|
|
@@ -3114,6 +3171,19 @@ class WidgetQuest extends WidgetBase {
|
|
|
3114
3171
|
static api = {
|
|
3115
3172
|
widgetClassName: WidgetQuest.widgetClassName,
|
|
3116
3173
|
refreshUserData: WidgetQuest.refreshUserData,
|
|
3174
|
+
init: function (element, localData) {
|
|
3175
|
+
return new Promise(function (resolve, reject) {
|
|
3176
|
+
WidgetQuest.initWidget(element, localData, (element, options) => new WidgetQuest(element, options)).then(localData => {
|
|
3177
|
+
const widget = WidgetQuest.getInstance(element);
|
|
3178
|
+
if (widget) {
|
|
3179
|
+
resolve(widget.init());
|
|
3180
|
+
}
|
|
3181
|
+
else {
|
|
3182
|
+
resolve(true);
|
|
3183
|
+
}
|
|
3184
|
+
});
|
|
3185
|
+
});
|
|
3186
|
+
},
|
|
3117
3187
|
initWidget: function (element, localData) {
|
|
3118
3188
|
return new Promise(function (resolve, reject) {
|
|
3119
3189
|
WidgetQuest.initWidgets((element, options) => new WidgetQuest(element, options), [element], localData).then(localData => {
|
|
@@ -3241,10 +3311,10 @@ class WidgetQuiz extends WidgetBase {
|
|
|
3241
3311
|
const selectedAnswerIndex = this.answers.indexOf(answer);
|
|
3242
3312
|
if (selectedAnswerIndex !== -1) {
|
|
3243
3313
|
this._selectAnswer(selectedAnswerIndex);
|
|
3244
|
-
|
|
3314
|
+
const isCorrect = this.answers[selectedAnswerIndex].classList.contains("check");
|
|
3245
3315
|
this.localData["q_score"] = (this.localData["q_score"] === undefined ? 0 : this.localData["q_score"]) + (isCorrect ? 1 : 0);
|
|
3246
|
-
|
|
3247
|
-
for (
|
|
3316
|
+
let answeredQuestion = 0;
|
|
3317
|
+
for (const key in this.localData) {
|
|
3248
3318
|
if (this.localData.hasOwnProperty(key)) {
|
|
3249
3319
|
if (/^_q_g_[A-z0-9-_]+_sa$/.test(key)) {
|
|
3250
3320
|
answeredQuestion++;
|
|
@@ -3271,7 +3341,7 @@ class WidgetQuiz extends WidgetBase {
|
|
|
3271
3341
|
}, 2000);
|
|
3272
3342
|
}
|
|
3273
3343
|
try {
|
|
3274
|
-
|
|
3344
|
+
const questionText = this.question ? this.question.textContent ?? "" : "";
|
|
3275
3345
|
let answerText = "";
|
|
3276
3346
|
if (this.answers[selectedAnswerIndex]) {
|
|
3277
3347
|
const answerLabel = this.answers[selectedAnswerIndex].querySelector(".variant-view .label");
|
|
@@ -3279,7 +3349,7 @@ class WidgetQuiz extends WidgetBase {
|
|
|
3279
3349
|
answerText = answerLabel.textContent;
|
|
3280
3350
|
}
|
|
3281
3351
|
}
|
|
3282
|
-
|
|
3352
|
+
const duration = new Date().getTime() - this.firstOpenTime;
|
|
3283
3353
|
this.sendStatisticEventToApp("w-quiz-answer", {
|
|
3284
3354
|
...this.statisticEventBaseFieldsShortForm,
|
|
3285
3355
|
wi: this.elementId,
|
|
@@ -3311,6 +3381,10 @@ class WidgetQuiz extends WidgetBase {
|
|
|
3311
3381
|
static api = {
|
|
3312
3382
|
widgetClassName: WidgetQuiz.widgetClassName,
|
|
3313
3383
|
refreshUserData: WidgetQuiz.refreshUserData,
|
|
3384
|
+
init: function (element, localData) {
|
|
3385
|
+
WidgetQuiz.initWidget(element, localData, (element, options) => new WidgetQuiz(element, options));
|
|
3386
|
+
},
|
|
3387
|
+
/** @deprecated */
|
|
3314
3388
|
initWidget: function (element, localData) {
|
|
3315
3389
|
WidgetQuiz.initWidgets((element, options) => new WidgetQuiz(element, options), [element], localData);
|
|
3316
3390
|
},
|
|
@@ -3504,6 +3578,10 @@ class WidgetQuizGrouped extends WidgetBase {
|
|
|
3504
3578
|
static api = {
|
|
3505
3579
|
widgetClassName: WidgetQuizGrouped.widgetClassName,
|
|
3506
3580
|
refreshUserData: WidgetQuizGrouped.refreshUserData,
|
|
3581
|
+
init: function (element, localData) {
|
|
3582
|
+
WidgetQuizGrouped.initWidget(element, localData, (element, options) => new WidgetQuizGrouped(element, options));
|
|
3583
|
+
},
|
|
3584
|
+
/** @deprecated */
|
|
3507
3585
|
initWidget: function (element, localData) {
|
|
3508
3586
|
WidgetQuizGrouped.initWidgets((element, options) => new WidgetQuizGrouped(element, options), [element], localData);
|
|
3509
3587
|
},
|
|
@@ -3637,7 +3715,7 @@ function tryParseFloat(str, defaultValue) {
|
|
|
3637
3715
|
if (str == null) {
|
|
3638
3716
|
return defaultValue;
|
|
3639
3717
|
}
|
|
3640
|
-
|
|
3718
|
+
const value = parseFloat(str);
|
|
3641
3719
|
return Number.isNaN(value) ? defaultValue : value;
|
|
3642
3720
|
}
|
|
3643
3721
|
/**
|
|
@@ -3952,7 +4030,7 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
3952
4030
|
if ((" " + e.target.className + " ").replace(/[\n\t]/g, " ").indexOf(this.options.handleClass) > -1) {
|
|
3953
4031
|
return;
|
|
3954
4032
|
}
|
|
3955
|
-
|
|
4033
|
+
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;
|
|
3956
4034
|
this.setPosition(setPos);
|
|
3957
4035
|
if (pos >= handlePos && pos < handlePos + this.handleDimension) {
|
|
3958
4036
|
this.grabPos = pos - handlePos;
|
|
@@ -4112,6 +4190,10 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
4112
4190
|
static api = {
|
|
4113
4191
|
widgetClassName: WidgetRangeSlider.widgetClassName,
|
|
4114
4192
|
refreshUserData: WidgetRangeSlider.refreshUserData,
|
|
4193
|
+
init: function (element, localData) {
|
|
4194
|
+
WidgetRangeSlider.initWidget(element, localData, (element, options) => new WidgetRangeSlider(element, options));
|
|
4195
|
+
},
|
|
4196
|
+
/** @deprecated */
|
|
4115
4197
|
initWidget: function (element, localData) {
|
|
4116
4198
|
WidgetRangeSlider.initWidgets((element, options) => new WidgetRangeSlider(element, options), [element], localData);
|
|
4117
4199
|
},
|
|
@@ -4158,6 +4240,7 @@ class WidgetRate extends WidgetBase {
|
|
|
4158
4240
|
showDialogueMax;
|
|
4159
4241
|
selectedStar;
|
|
4160
4242
|
answerSelectDuration;
|
|
4243
|
+
elementRect;
|
|
4161
4244
|
constructor(element, options) {
|
|
4162
4245
|
super(element, options);
|
|
4163
4246
|
this.label = this.element.querySelector(".label-view .label");
|
|
@@ -4258,6 +4341,7 @@ class WidgetRate extends WidgetBase {
|
|
|
4258
4341
|
if (value + 1 >= this.showDialogueMin && value + 1 <= this.showDialogueMax) {
|
|
4259
4342
|
this.selectedStar = value;
|
|
4260
4343
|
if (this.showDialogOnLowRate) {
|
|
4344
|
+
this.elementRect = this.element.getBoundingClientRect();
|
|
4261
4345
|
this._selectStar(this.selectedStar, false);
|
|
4262
4346
|
if (this.sdkApi.isAndroid) {
|
|
4263
4347
|
this.slide.classList.add("blured");
|
|
@@ -4266,7 +4350,7 @@ class WidgetRate extends WidgetBase {
|
|
|
4266
4350
|
const dataString = this.element.dataset["clientdialogwidgetconfig"];
|
|
4267
4351
|
if (this.sdkApi.isExistsShowCardTextInput && dataString) {
|
|
4268
4352
|
const data = JSON.parse(dataString);
|
|
4269
|
-
data.size = getElementBounding(this.env, this.
|
|
4353
|
+
data.size = getElementBounding(this.env, this.elementRect);
|
|
4270
4354
|
if (!this.disableTimer) {
|
|
4271
4355
|
this.sdkApi.pauseUI();
|
|
4272
4356
|
}
|
|
@@ -4297,7 +4381,7 @@ class WidgetRate extends WidgetBase {
|
|
|
4297
4381
|
return false;
|
|
4298
4382
|
}
|
|
4299
4383
|
else if (value + 1 >= this.submitToStoresMin && value + 1 <= this.submitToStoresMax) {
|
|
4300
|
-
|
|
4384
|
+
let target = null;
|
|
4301
4385
|
if (this.sdkApi.isAndroid) {
|
|
4302
4386
|
target = getTagData(this.element, "androidLink");
|
|
4303
4387
|
}
|
|
@@ -4357,6 +4441,10 @@ class WidgetRate extends WidgetBase {
|
|
|
4357
4441
|
static api = {
|
|
4358
4442
|
widgetClassName: WidgetRate.widgetClassName,
|
|
4359
4443
|
refreshUserData: WidgetRate.refreshUserData,
|
|
4444
|
+
init: function (element, localData) {
|
|
4445
|
+
WidgetRate.initWidget(element, localData, (element, options) => new WidgetRate(element, options));
|
|
4446
|
+
},
|
|
4447
|
+
/** @deprecated */
|
|
4360
4448
|
initWidget: function (nodeList, localData) {
|
|
4361
4449
|
WidgetRate.initWidgets((element, options) => new WidgetRate(element, options), slice.call(nodeList), localData);
|
|
4362
4450
|
},
|
|
@@ -4412,6 +4500,9 @@ class WidgetShare extends WidgetBase {
|
|
|
4412
4500
|
this._showLayout(this.layers, 0);
|
|
4413
4501
|
}
|
|
4414
4502
|
}
|
|
4503
|
+
if (this.isDone() && this.disableTimer) {
|
|
4504
|
+
this.startDisabledTimeline();
|
|
4505
|
+
}
|
|
4415
4506
|
this.btnDisabled = false;
|
|
4416
4507
|
// this.refreshUserData(this.options.localData);
|
|
4417
4508
|
}
|
|
@@ -4470,6 +4561,9 @@ class WidgetShare extends WidgetBase {
|
|
|
4470
4561
|
if (isSuccess && this.withLayer) {
|
|
4471
4562
|
this._showLayout(this.layers, 1, true);
|
|
4472
4563
|
}
|
|
4564
|
+
if (this.disableTimer) {
|
|
4565
|
+
this.startDisabledTimeline();
|
|
4566
|
+
}
|
|
4473
4567
|
this.btnDisabled = false;
|
|
4474
4568
|
}
|
|
4475
4569
|
isDone() {
|
|
@@ -4478,10 +4572,15 @@ class WidgetShare extends WidgetBase {
|
|
|
4478
4572
|
static api = {
|
|
4479
4573
|
widgetClassName: WidgetShare.widgetClassName,
|
|
4480
4574
|
refreshUserData: WidgetShare.refreshUserData,
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4575
|
+
init: function (element, layers, localData) {
|
|
4576
|
+
WidgetShare.initWidget(element, localData, (element, options) => new WidgetShare(element, { ...options, layers }));
|
|
4577
|
+
},
|
|
4578
|
+
/** @deprecated
|
|
4579
|
+
* signature variants
|
|
4580
|
+
* (widget, layers, undefined) - modern web sdk
|
|
4581
|
+
* (widget, undefined, layers) - old web sdk and rn
|
|
4582
|
+
* (widget, layers, localData) - native sdk
|
|
4583
|
+
*/
|
|
4485
4584
|
initWidget: function (nodeList, layers, localData) {
|
|
4486
4585
|
if (layers === undefined && localData !== undefined) {
|
|
4487
4586
|
// @ts-ignore
|
|
@@ -4556,7 +4655,7 @@ class WidgetTest extends WidgetBase {
|
|
|
4556
4655
|
// if (this.state.timeLeft - this.timeLeft >= 950) {
|
|
4557
4656
|
// this.setState({timeLeft: this.timeLeft});
|
|
4558
4657
|
// }
|
|
4559
|
-
|
|
4658
|
+
const timeNow = new Date().getTime();
|
|
4560
4659
|
this.timeLeft -= timeNow - this.startTimerAt;
|
|
4561
4660
|
this.startTimerAt = timeNow;
|
|
4562
4661
|
if (this.timeLeft <= 0) {
|
|
@@ -4610,14 +4709,14 @@ class WidgetTest extends WidgetBase {
|
|
|
4610
4709
|
try {
|
|
4611
4710
|
if (this.selectedAnswer != null) {
|
|
4612
4711
|
const labelText = this.label?.textContent ?? "";
|
|
4613
|
-
|
|
4712
|
+
let answerText = "";
|
|
4614
4713
|
if (this.variants[this.selectedAnswer]) {
|
|
4615
|
-
|
|
4714
|
+
const answerLabel = this.variants[this.selectedAnswer].querySelector(".label");
|
|
4616
4715
|
if (answerLabel != null) {
|
|
4617
4716
|
answerText = answerLabel.textContent ?? "";
|
|
4618
4717
|
}
|
|
4619
4718
|
}
|
|
4620
|
-
|
|
4719
|
+
const duration = new Date().getTime() - this.firstOpenTime;
|
|
4621
4720
|
this.sendStatisticEventToApp("w-test-answer", {
|
|
4622
4721
|
...this.statisticEventBaseFieldsShortForm,
|
|
4623
4722
|
wi: this.elementId,
|
|
@@ -4661,9 +4760,9 @@ class WidgetTest extends WidgetBase {
|
|
|
4661
4760
|
if (this.selectedAnswer !== undefined) {
|
|
4662
4761
|
return true;
|
|
4663
4762
|
}
|
|
4664
|
-
|
|
4763
|
+
const index = this.variants.indexOf(answer);
|
|
4665
4764
|
if (index !== -1) {
|
|
4666
|
-
|
|
4765
|
+
const answerScore = getValueOrDefault(getTagDataAsNumber(this.variants[index], "score"), 0);
|
|
4667
4766
|
this._completeWidget(index, answerScore);
|
|
4668
4767
|
}
|
|
4669
4768
|
if (Boolean(this.withTimeToAnswer && this.answerTimeout)) {
|
|
@@ -4675,15 +4774,15 @@ class WidgetTest extends WidgetBase {
|
|
|
4675
4774
|
if (this.selectedAnswer !== undefined) {
|
|
4676
4775
|
return;
|
|
4677
4776
|
}
|
|
4678
|
-
|
|
4777
|
+
const index = -1, answerScore = 0;
|
|
4679
4778
|
this._completeWidget(index, answerScore);
|
|
4680
4779
|
}
|
|
4681
4780
|
// complete answer select and save local data + stat event
|
|
4682
4781
|
_completeWidget(index, answerScore) {
|
|
4683
4782
|
this._selectAnswer(index);
|
|
4684
4783
|
this.localData["t_score"] = (this.localData["t_score"] === undefined ? 0 : this.localData["t_score"]) + answerScore;
|
|
4685
|
-
|
|
4686
|
-
for (
|
|
4784
|
+
let answeredQuestion = 0;
|
|
4785
|
+
for (const key in this.localData) {
|
|
4687
4786
|
if (this.localData.hasOwnProperty(key)) {
|
|
4688
4787
|
if (/^_t_g_[A-z0-9-_]+_sa$/.test(key)) {
|
|
4689
4788
|
answeredQuestion++;
|
|
@@ -4726,6 +4825,10 @@ class WidgetTest extends WidgetBase {
|
|
|
4726
4825
|
static api = {
|
|
4727
4826
|
widgetClassName: WidgetTest.widgetClassName,
|
|
4728
4827
|
refreshUserData: WidgetTest.refreshUserData,
|
|
4828
|
+
init: function (element, localData) {
|
|
4829
|
+
WidgetTest.initWidget(element, localData, (element, options) => new WidgetTest(element, options));
|
|
4830
|
+
},
|
|
4831
|
+
/** @deprecated */
|
|
4729
4832
|
initWidget: function (element, localData) {
|
|
4730
4833
|
WidgetTest.initWidgets((element, options) => new WidgetTest(element, options), [element], localData);
|
|
4731
4834
|
},
|
|
@@ -4994,7 +5097,7 @@ class WidgetVote extends WidgetBase {
|
|
|
4994
5097
|
return true;
|
|
4995
5098
|
}
|
|
4996
5099
|
}
|
|
4997
|
-
|
|
5100
|
+
const selectedVariantIndex = this.variants.indexOf(variant);
|
|
4998
5101
|
if (selectedVariantIndex !== -1) {
|
|
4999
5102
|
this._checkVariant(selectedVariantIndex);
|
|
5000
5103
|
if (this.multipleChoice) {
|
|
@@ -5093,7 +5196,7 @@ class WidgetVote extends WidgetBase {
|
|
|
5093
5196
|
}
|
|
5094
5197
|
voteAllocationTs = sharedData.ts;
|
|
5095
5198
|
}
|
|
5096
|
-
|
|
5199
|
+
const voteDoneAt = this.localData["_v_g_" + this.elementId + "_done_at"];
|
|
5097
5200
|
if (voteAllocationTs === undefined || voteDoneAt === undefined || voteDoneAt > voteAllocationTs) {
|
|
5098
5201
|
forEach(this.variants, function (element, index) {
|
|
5099
5202
|
const key = index;
|
|
@@ -5106,7 +5209,7 @@ class WidgetVote extends WidgetBase {
|
|
|
5106
5209
|
});
|
|
5107
5210
|
}
|
|
5108
5211
|
// calc percents
|
|
5109
|
-
|
|
5212
|
+
let percents = [], total = 0;
|
|
5110
5213
|
forEach(this.variants, (element, index) => {
|
|
5111
5214
|
const key = index;
|
|
5112
5215
|
if (voteAllocation[key] !== undefined) {
|
|
@@ -5129,10 +5232,10 @@ class WidgetVote extends WidgetBase {
|
|
|
5129
5232
|
// percents[i] += '%';
|
|
5130
5233
|
}
|
|
5131
5234
|
}
|
|
5132
|
-
|
|
5235
|
+
const self = this;
|
|
5133
5236
|
forEach(this.variants, (element, index) => {
|
|
5134
5237
|
const key = index;
|
|
5135
|
-
|
|
5238
|
+
const percentLabels = slice.call(element.querySelectorAll(".percent-label"));
|
|
5136
5239
|
forEach(percentLabels, label => {
|
|
5137
5240
|
if (percents[key] != null) {
|
|
5138
5241
|
label.textContent = percents[key] + "%";
|
|
@@ -5140,7 +5243,7 @@ class WidgetVote extends WidgetBase {
|
|
|
5140
5243
|
});
|
|
5141
5244
|
element.classList.add("selected");
|
|
5142
5245
|
});
|
|
5143
|
-
|
|
5246
|
+
const cb = function () {
|
|
5144
5247
|
forEach(self.variants, function (element, index) {
|
|
5145
5248
|
const key = index;
|
|
5146
5249
|
if (percents[key] != null) {
|
|
@@ -5164,18 +5267,24 @@ class WidgetVote extends WidgetBase {
|
|
|
5164
5267
|
static api = {
|
|
5165
5268
|
widgetClassName: WidgetVote.widgetClassName,
|
|
5166
5269
|
refreshUserData: WidgetVote.refreshUserData,
|
|
5167
|
-
|
|
5270
|
+
init: function (element, localData) {
|
|
5271
|
+
WidgetVote.initWidget(element, localData, (element, options) => new WidgetVote(element, options));
|
|
5272
|
+
},
|
|
5273
|
+
/** @deprecated
|
|
5274
|
+
*
|
|
5275
|
+
* fix for WidgetVote on every layer of multilayers story
|
|
5276
|
+
*/
|
|
5168
5277
|
fallbackInitOnMultiSlide: function (element, localData) {
|
|
5169
5278
|
if (element.dataset.fallbackInitOnMultiSlide) {
|
|
5170
5279
|
return;
|
|
5171
5280
|
}
|
|
5172
|
-
|
|
5281
|
+
const multiSlide = element.closest(".narrative-multi-slide");
|
|
5173
5282
|
if (multiSlide != null) {
|
|
5174
|
-
|
|
5175
|
-
|
|
5283
|
+
const container = multiSlide.parentElement;
|
|
5284
|
+
const widgetElements = container?.querySelectorAll(`.${WidgetVote.widgetClassName}`);
|
|
5176
5285
|
if (widgetElements != null) {
|
|
5177
|
-
for (
|
|
5178
|
-
|
|
5286
|
+
for (let i = 0; i < widgetElements.length; ++i) {
|
|
5287
|
+
const widgetElement = widgetElements[i];
|
|
5179
5288
|
const widget = WidgetVote.getInstance(widgetElement);
|
|
5180
5289
|
if (!widget) {
|
|
5181
5290
|
WidgetVote.initWidgets((element, options) => new WidgetVote(element, options), [widgetElement], localData);
|
|
@@ -5185,6 +5294,7 @@ class WidgetVote extends WidgetBase {
|
|
|
5185
5294
|
}
|
|
5186
5295
|
element.dataset.fallbackInitOnMultiSlide = "1";
|
|
5187
5296
|
},
|
|
5297
|
+
/** @deprecated */
|
|
5188
5298
|
initWidget: function (element, localData) {
|
|
5189
5299
|
WidgetVote.initWidgets((element, options) => new WidgetVote(element, options), [element], localData).then(localData => {
|
|
5190
5300
|
WidgetVote.api.fallbackInitOnMultiSlide(element, localData);
|
|
@@ -14625,7 +14735,7 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14625
14735
|
isTransparentElement() {
|
|
14626
14736
|
if (this.element) {
|
|
14627
14737
|
try {
|
|
14628
|
-
|
|
14738
|
+
const color = window.getComputedStyle(this.element).color;
|
|
14629
14739
|
if (color === "transparent" || color === "rgba(0, 0, 0, 0)" || color === "rgba(0,0,0,0)") {
|
|
14630
14740
|
return true;
|
|
14631
14741
|
}
|
|
@@ -14732,10 +14842,10 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14732
14842
|
return setTimeout(t, 300);
|
|
14733
14843
|
}),
|
|
14734
14844
|
]).then(values => {
|
|
14735
|
-
|
|
14736
|
-
|
|
14737
|
-
|
|
14738
|
-
|
|
14845
|
+
const r = values[0];
|
|
14846
|
+
const status = r.status;
|
|
14847
|
+
let code = null;
|
|
14848
|
+
let success = false;
|
|
14739
14849
|
if (status === 200 || status === 201) {
|
|
14740
14850
|
if (r.data)
|
|
14741
14851
|
code = r.data.code;
|
|
@@ -14780,7 +14890,7 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14780
14890
|
}
|
|
14781
14891
|
_statEventCopyClick(clipboardTarget) {
|
|
14782
14892
|
try {
|
|
14783
|
-
|
|
14893
|
+
const captionViewText = this.captionView?.textContent ?? "";
|
|
14784
14894
|
this.sendStatisticEventToApp("w-barcode", {
|
|
14785
14895
|
...this.statisticEventBaseFieldsShortForm,
|
|
14786
14896
|
wi: this.elementId,
|
|
@@ -14811,7 +14921,7 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14811
14921
|
}
|
|
14812
14922
|
copyToClipboard(element) {
|
|
14813
14923
|
this._select();
|
|
14814
|
-
|
|
14924
|
+
const text = this.clipboardTarget ?? "";
|
|
14815
14925
|
Clipboard.copy(text);
|
|
14816
14926
|
this.completeWidget();
|
|
14817
14927
|
this._statEventCopyClick(text);
|
|
@@ -14828,6 +14938,10 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14828
14938
|
static api = {
|
|
14829
14939
|
widgetClassName: WidgetBarcode.widgetClassName,
|
|
14830
14940
|
refreshUserData: WidgetBarcode.refreshUserData,
|
|
14941
|
+
init: function (element, localData) {
|
|
14942
|
+
WidgetBarcode.initWidget(element, localData, (element, options) => new WidgetBarcode(element, options));
|
|
14943
|
+
},
|
|
14944
|
+
/** @deprecated */
|
|
14831
14945
|
initWidget: function (nodeList, localData) {
|
|
14832
14946
|
WidgetBarcode.initWidgets((element, options) => new WidgetBarcode(element, options), slice.call(nodeList), localData);
|
|
14833
14947
|
},
|