@inappstory/slide-api 0.0.13 → 0.0.14
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 +200 -184
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +68 -47
- package/dist/index.d.ts +68 -47
- package/dist/index.js +200 -184
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1060,11 +1060,11 @@ class EsModuleSdkApi {
|
|
|
1060
1060
|
constructor(sdkBinding) {
|
|
1061
1061
|
this.sdkBinding = sdkBinding;
|
|
1062
1062
|
}
|
|
1063
|
-
|
|
1064
|
-
return this.sdkBinding().
|
|
1063
|
+
getCardServerData(cardId) {
|
|
1064
|
+
return this.sdkBinding().getCardServerData(cardId);
|
|
1065
1065
|
}
|
|
1066
|
-
getSlideDuration(
|
|
1067
|
-
return this.sdkBinding().getSlideDuration(
|
|
1066
|
+
getSlideDuration(cardId, slideIndex) {
|
|
1067
|
+
return this.sdkBinding().getSlideDuration(cardId, slideIndex);
|
|
1068
1068
|
}
|
|
1069
1069
|
showNextSlide(duration) {
|
|
1070
1070
|
this.sdkBinding().showNextSlide(duration);
|
|
@@ -1072,8 +1072,8 @@ class EsModuleSdkApi {
|
|
|
1072
1072
|
sendStatisticEvent(name, data, devPayload) {
|
|
1073
1073
|
this.sdkBinding().sendStatisticEvent(name, data, devPayload);
|
|
1074
1074
|
}
|
|
1075
|
-
|
|
1076
|
-
return this.sdkBinding().
|
|
1075
|
+
getCardLocalData() {
|
|
1076
|
+
return this.sdkBinding().getCardLocalData();
|
|
1077
1077
|
}
|
|
1078
1078
|
isExistsShowLayer() {
|
|
1079
1079
|
return true;
|
|
@@ -1081,7 +1081,7 @@ class EsModuleSdkApi {
|
|
|
1081
1081
|
showLayer(index) {
|
|
1082
1082
|
this.sdkBinding().showLayer(index);
|
|
1083
1083
|
}
|
|
1084
|
-
get
|
|
1084
|
+
get cardAnimation() {
|
|
1085
1085
|
return animationApi;
|
|
1086
1086
|
}
|
|
1087
1087
|
get isAndroid() {
|
|
@@ -1099,17 +1099,17 @@ class EsModuleSdkApi {
|
|
|
1099
1099
|
resumeUI() {
|
|
1100
1100
|
this.sdkBinding().resumeUI();
|
|
1101
1101
|
}
|
|
1102
|
-
get
|
|
1102
|
+
get isExistsShowCardTextInput() {
|
|
1103
1103
|
return true;
|
|
1104
1104
|
}
|
|
1105
|
-
|
|
1106
|
-
this.sdkBinding().
|
|
1105
|
+
showCardTextInput(id, data) {
|
|
1106
|
+
this.sdkBinding().showCardTextInput(id, data);
|
|
1107
1107
|
}
|
|
1108
|
-
|
|
1109
|
-
this.sdkBinding().
|
|
1108
|
+
setCardLocalData(keyValue, sendToServer) {
|
|
1109
|
+
this.sdkBinding().setCardLocalData(keyValue, sendToServer);
|
|
1110
1110
|
}
|
|
1111
|
-
getWidgetsSharedData(
|
|
1112
|
-
return this.sdkBinding().getWidgetsSharedData(
|
|
1111
|
+
getWidgetsSharedData(cardId, widget) {
|
|
1112
|
+
return this.sdkBinding().getWidgetsSharedData(cardId, widget);
|
|
1113
1113
|
}
|
|
1114
1114
|
vibrate(pattern) {
|
|
1115
1115
|
navigator.vibrate(pattern);
|
|
@@ -1138,23 +1138,23 @@ class EsModuleSdkApi {
|
|
|
1138
1138
|
shareSlideScreenshot(shareId, hideElementsSelector, shareText) {
|
|
1139
1139
|
this.sdkBinding().shareSlideScreenshot(shareId, hideElementsSelector, shareText);
|
|
1140
1140
|
}
|
|
1141
|
-
get
|
|
1141
|
+
get isExistsShowCardSlide() {
|
|
1142
1142
|
return true;
|
|
1143
1143
|
}
|
|
1144
|
-
|
|
1145
|
-
this.sdkBinding().
|
|
1144
|
+
showCardSlide(index) {
|
|
1145
|
+
this.sdkBinding().showCardSlide(index);
|
|
1146
1146
|
}
|
|
1147
|
-
get
|
|
1147
|
+
get isExistsShowNextCard() {
|
|
1148
1148
|
return true;
|
|
1149
1149
|
}
|
|
1150
|
-
|
|
1151
|
-
this.sdkBinding().
|
|
1150
|
+
cardShowNext() {
|
|
1151
|
+
this.sdkBinding().cardShowNext();
|
|
1152
1152
|
}
|
|
1153
|
-
|
|
1154
|
-
this.sdkBinding().
|
|
1153
|
+
setCardSessionValue(element, key, value) {
|
|
1154
|
+
this.sdkBinding().setCardSessionValue(key, value);
|
|
1155
1155
|
}
|
|
1156
|
-
|
|
1157
|
-
return this.sdkBinding().
|
|
1156
|
+
getCardSessionValue(element, key) {
|
|
1157
|
+
return this.sdkBinding().getCardSessionValue(key);
|
|
1158
1158
|
}
|
|
1159
1159
|
updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError) {
|
|
1160
1160
|
const updateTimeline = this.sdkBinding().updateTimeline;
|
|
@@ -1162,14 +1162,14 @@ class EsModuleSdkApi {
|
|
|
1162
1162
|
updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError);
|
|
1163
1163
|
}
|
|
1164
1164
|
}
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
startDisabledTimeline(
|
|
1165
|
+
cardPausedCallback(currentTime) { }
|
|
1166
|
+
cardResumedCallback(currentTime) { }
|
|
1167
|
+
startDisabledTimeline(cardId, slideIndex) {
|
|
1168
1168
|
// old api
|
|
1169
|
-
this.showNextSlide(this.getSlideDuration(
|
|
1169
|
+
this.showNextSlide(this.getSlideDuration(cardId, slideIndex) ?? DEFAULT_SLIDE_DURATION);
|
|
1170
1170
|
}
|
|
1171
|
-
|
|
1172
|
-
return this.sdkBinding().
|
|
1171
|
+
getCardFonts() {
|
|
1172
|
+
return this.sdkBinding().getCardFonts();
|
|
1173
1173
|
}
|
|
1174
1174
|
static get [Symbol.for("___CTOR_ARGS___")]() { return [`() => SDKInterface`]; }
|
|
1175
1175
|
}
|
|
@@ -1191,7 +1191,8 @@ class WidgetBase {
|
|
|
1191
1191
|
slideIndex = null;
|
|
1192
1192
|
disableTimer = null;
|
|
1193
1193
|
layoutDirection = "ltr";
|
|
1194
|
-
|
|
1194
|
+
cardId = null;
|
|
1195
|
+
cardType = null;
|
|
1195
1196
|
widgetDone = null;
|
|
1196
1197
|
showWidgetCompleteToast = null;
|
|
1197
1198
|
submitButtonAnimatedView = null;
|
|
@@ -1218,7 +1219,8 @@ class WidgetBase {
|
|
|
1218
1219
|
}
|
|
1219
1220
|
this.slideIndex = getValueOrException(getTagDataAsNumber(this.slide, "index"), "Empty slideIndex");
|
|
1220
1221
|
this.disableTimer = getTagData(this.slide, "disableTimer") === "1";
|
|
1221
|
-
this.
|
|
1222
|
+
this.cardId = getValueOrException(getTagDataAsNumber(this.slide, "id"), "Empty cardId");
|
|
1223
|
+
this.cardType = getValueOrException(getTagDataAsNumber(this.slide, "card-type"), "Empty card type");
|
|
1222
1224
|
if (this.env.getComputedStyle(this.element).direction === "rtl") {
|
|
1223
1225
|
this.layoutDirection = "rtl";
|
|
1224
1226
|
}
|
|
@@ -1247,7 +1249,7 @@ class WidgetBase {
|
|
|
1247
1249
|
}
|
|
1248
1250
|
}
|
|
1249
1251
|
}
|
|
1250
|
-
this.savedData = this.sdkApi.
|
|
1252
|
+
this.savedData = this.sdkApi.getCardServerData(this.cardId);
|
|
1251
1253
|
this.localData = extend({}, this.savedData ?? {}, this.options.localData ?? {});
|
|
1252
1254
|
this.id = `w_${this.elementId}_${WidgetBase.widgetIndex}`;
|
|
1253
1255
|
++WidgetBase.widgetIndex;
|
|
@@ -1308,7 +1310,7 @@ class WidgetBase {
|
|
|
1308
1310
|
return container.get({ identifier: "WidgetsService" });
|
|
1309
1311
|
}
|
|
1310
1312
|
static getLocalData() {
|
|
1311
|
-
return this.widgetsService.sdkApi.
|
|
1313
|
+
return this.widgetsService.sdkApi.getCardLocalData();
|
|
1312
1314
|
}
|
|
1313
1315
|
getLocalData() {
|
|
1314
1316
|
return this.constructor.getLocalData();
|
|
@@ -1332,17 +1334,42 @@ class WidgetBase {
|
|
|
1332
1334
|
// 1 - old values, 2 - new values
|
|
1333
1335
|
keyValue = extend({}, localData, keyValue);
|
|
1334
1336
|
// todo make async via promise or async
|
|
1335
|
-
this.widgetsService.sdkApi.
|
|
1337
|
+
this.widgetsService.sdkApi.setCardLocalData(keyValue, sendToServer);
|
|
1336
1338
|
});
|
|
1337
1339
|
}
|
|
1338
1340
|
else {
|
|
1339
1341
|
// todo make async via promise or async
|
|
1340
|
-
this.widgetsService.sdkApi.
|
|
1342
|
+
this.widgetsService.sdkApi.setCardLocalData(keyValue, sendToServer);
|
|
1341
1343
|
}
|
|
1342
1344
|
}
|
|
1343
1345
|
setLocalData(keyValue, sendToServer, syncWithRuntimeLocalData) {
|
|
1344
1346
|
return this.constructor.setLocalData(keyValue, sendToServer, syncWithRuntimeLocalData);
|
|
1345
1347
|
}
|
|
1348
|
+
get statisticEventBaseFieldsShortForm() {
|
|
1349
|
+
return WidgetBase.getStatisticEventBaseFieldsShortForm(this.cardId, this.slideIndex);
|
|
1350
|
+
}
|
|
1351
|
+
static getStatisticEventBaseFieldsShortForm(cardId, slideIndex) {
|
|
1352
|
+
return {
|
|
1353
|
+
i: cardId,
|
|
1354
|
+
si: slideIndex,
|
|
1355
|
+
};
|
|
1356
|
+
}
|
|
1357
|
+
get statisticEventBaseFieldsFullForm() {
|
|
1358
|
+
return WidgetBase.getStatisticEventBaseFieldsFullForm(this.cardId, this.cardType, this.slideIndex);
|
|
1359
|
+
}
|
|
1360
|
+
static getStatisticEventBaseFieldsFullForm(cardId, cardType, slideIndex) {
|
|
1361
|
+
const data = { slide_index: slideIndex };
|
|
1362
|
+
switch (cardType) {
|
|
1363
|
+
case 1 /* CARD_TYPE.STORY */:
|
|
1364
|
+
case 2 /* CARD_TYPE.UGC_STORY */:
|
|
1365
|
+
data.story_id = cardId;
|
|
1366
|
+
break;
|
|
1367
|
+
case 4 /* CARD_TYPE.IN_APP_MESSAGING */:
|
|
1368
|
+
data.message_id = cardId;
|
|
1369
|
+
break;
|
|
1370
|
+
}
|
|
1371
|
+
return data;
|
|
1372
|
+
}
|
|
1346
1373
|
static sendStatisticEventToApp(name, data, devPayload) {
|
|
1347
1374
|
sendStatisticEventToApp(this.widgetsService.sdkApi, name, data, devPayload);
|
|
1348
1375
|
}
|
|
@@ -1350,7 +1377,7 @@ class WidgetBase {
|
|
|
1350
1377
|
this.constructor.sendStatisticEventToApp(name, data, devPayload);
|
|
1351
1378
|
}
|
|
1352
1379
|
startDisabledTimeline() {
|
|
1353
|
-
this.sdkApi.startDisabledTimeline(this.
|
|
1380
|
+
this.sdkApi.startDisabledTimeline(this.cardId, this.slideIndex);
|
|
1354
1381
|
}
|
|
1355
1382
|
_showLayout(layers, selectIndex, withStatEvent = false) {
|
|
1356
1383
|
if (this.sdkApi.isExistsShowLayer()) {
|
|
@@ -1360,7 +1387,7 @@ class WidgetBase {
|
|
|
1360
1387
|
forEach(layers, (layer, index) => {
|
|
1361
1388
|
if (index === selectIndex) {
|
|
1362
1389
|
layer.classList.remove("hidden");
|
|
1363
|
-
this.sdkApi.
|
|
1390
|
+
this.sdkApi.cardAnimation?.start(layer);
|
|
1364
1391
|
}
|
|
1365
1392
|
else {
|
|
1366
1393
|
layer.classList.add("hidden");
|
|
@@ -1374,12 +1401,10 @@ class WidgetBase {
|
|
|
1374
1401
|
_statEventLayoutShow(layoutIndex) {
|
|
1375
1402
|
try {
|
|
1376
1403
|
this.sendStatisticEventToApp("layout-show", {
|
|
1377
|
-
|
|
1378
|
-
si: this.slideIndex,
|
|
1404
|
+
...this.statisticEventBaseFieldsShortForm,
|
|
1379
1405
|
li: layoutIndex,
|
|
1380
1406
|
}, {
|
|
1381
|
-
|
|
1382
|
-
slide_index: this.slideIndex,
|
|
1407
|
+
...this.statisticEventBaseFieldsFullForm,
|
|
1383
1408
|
layout_index: layoutIndex,
|
|
1384
1409
|
});
|
|
1385
1410
|
}
|
|
@@ -1408,6 +1433,14 @@ class WidgetBase {
|
|
|
1408
1433
|
});
|
|
1409
1434
|
}
|
|
1410
1435
|
}
|
|
1436
|
+
getPromotionalCodeFetchPath(promotionalCodeId) {
|
|
1437
|
+
switch (this.cardType) {
|
|
1438
|
+
case 4 /* CARD_TYPE.IN_APP_MESSAGING */:
|
|
1439
|
+
return `inappmessaging/message/${this.cardId}/widget/${this.elementId}/promo-code/${promotionalCodeId}`;
|
|
1440
|
+
default:
|
|
1441
|
+
return `story/${this.cardId}/widget/${this.elementId}/promo-code/${promotionalCodeId}`;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1411
1444
|
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `(element: HTMLElement) => string`, `(element: HTMLElement) => HTMLElement`]; }
|
|
1412
1445
|
}
|
|
1413
1446
|
|
|
@@ -1499,23 +1532,23 @@ class WidgetCopy extends WidgetBase {
|
|
|
1499
1532
|
// for transparent element
|
|
1500
1533
|
addClass(this.element, "loader");
|
|
1501
1534
|
}
|
|
1502
|
-
// fetch
|
|
1503
|
-
|
|
1504
|
-
|
|
1535
|
+
// fetch promotional code
|
|
1536
|
+
const path = this.getPromotionalCodeFetchPath(this.clipboardTarget ?? "");
|
|
1537
|
+
const headers = {
|
|
1505
1538
|
accept: "application/json",
|
|
1506
1539
|
"Content-Type": "application/json",
|
|
1507
1540
|
};
|
|
1508
|
-
|
|
1541
|
+
const profileKey = "fetch-promo-code";
|
|
1509
1542
|
Promise.all([
|
|
1510
1543
|
this.sdkApi.sendApiRequest(path, "POST", null, headers, null, profileKey),
|
|
1511
1544
|
new Promise(function (t, e) {
|
|
1512
1545
|
return setTimeout(t, 300);
|
|
1513
1546
|
}),
|
|
1514
1547
|
]).then(values => {
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1548
|
+
const r = values[0];
|
|
1549
|
+
const status = r.status;
|
|
1550
|
+
let code = null;
|
|
1551
|
+
let success = false;
|
|
1519
1552
|
if (status === 200 || status === 201) {
|
|
1520
1553
|
if (r.data)
|
|
1521
1554
|
code = r.data.code;
|
|
@@ -1561,14 +1594,12 @@ class WidgetCopy extends WidgetBase {
|
|
|
1561
1594
|
try {
|
|
1562
1595
|
var buttonText = this.button?.textContent ?? "";
|
|
1563
1596
|
this.sendStatisticEventToApp("w-copy", {
|
|
1564
|
-
|
|
1565
|
-
si: this.slideIndex,
|
|
1597
|
+
...this.statisticEventBaseFieldsShortForm,
|
|
1566
1598
|
wi: this.elementId,
|
|
1567
1599
|
wl: buttonText,
|
|
1568
1600
|
wv: clipboardTarget,
|
|
1569
1601
|
}, {
|
|
1570
|
-
|
|
1571
|
-
slide_index: this.slideIndex,
|
|
1602
|
+
...this.statisticEventBaseFieldsFullForm,
|
|
1572
1603
|
widget_id: this.elementId,
|
|
1573
1604
|
widget_label: buttonText,
|
|
1574
1605
|
widget_value: clipboardTarget,
|
|
@@ -1665,7 +1696,7 @@ class WidgetDataInput extends WidgetBase {
|
|
|
1665
1696
|
this.refreshUserData(this.options.localData);
|
|
1666
1697
|
}
|
|
1667
1698
|
refreshUserData(localData) {
|
|
1668
|
-
this.savedData = this.sdkApi.
|
|
1699
|
+
this.savedData = this.sdkApi.getCardServerData(this.cardId);
|
|
1669
1700
|
this.localData = extend({}, this.savedData ?? {}, localData);
|
|
1670
1701
|
var text = this.localData["_di_g_" + this.elementId + "_t"];
|
|
1671
1702
|
this._fillUserText(text);
|
|
@@ -1678,15 +1709,13 @@ class WidgetDataInput extends WidgetBase {
|
|
|
1678
1709
|
}
|
|
1679
1710
|
_statEventFocusIn() {
|
|
1680
1711
|
try {
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
si: this.slideIndex,
|
|
1712
|
+
const labelText = this.label ? this.label.textContent ?? "" : "";
|
|
1713
|
+
this.sendStatisticEventToApp("w-data-input-focus", {
|
|
1714
|
+
...this.statisticEventBaseFieldsShortForm,
|
|
1685
1715
|
wi: this.elementId,
|
|
1686
1716
|
wl: labelText,
|
|
1687
1717
|
}, {
|
|
1688
|
-
|
|
1689
|
-
slide_index: this.slideIndex,
|
|
1718
|
+
...this.statisticEventBaseFieldsFullForm,
|
|
1690
1719
|
widget_id: this.elementId,
|
|
1691
1720
|
widget_label: labelText,
|
|
1692
1721
|
});
|
|
@@ -1698,15 +1727,13 @@ class WidgetDataInput extends WidgetBase {
|
|
|
1698
1727
|
_statEventInputSave(answerText) {
|
|
1699
1728
|
try {
|
|
1700
1729
|
const labelText = this.label ? this.label.textContent ?? "" : "";
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
si: this.slideIndex,
|
|
1730
|
+
this.sendStatisticEventToApp("w-data-input-save", {
|
|
1731
|
+
...this.statisticEventBaseFieldsShortForm,
|
|
1704
1732
|
wi: this.elementId,
|
|
1705
1733
|
wl: labelText,
|
|
1706
1734
|
wv: answerText,
|
|
1707
1735
|
}, {
|
|
1708
|
-
|
|
1709
|
-
slide_index: this.slideIndex,
|
|
1736
|
+
...this.statisticEventBaseFieldsFullForm,
|
|
1710
1737
|
widget_id: this.elementId,
|
|
1711
1738
|
widget_label: labelText,
|
|
1712
1739
|
widget_value: answerText,
|
|
@@ -1729,7 +1756,7 @@ class WidgetDataInput extends WidgetBase {
|
|
|
1729
1756
|
}
|
|
1730
1757
|
this.slide.classList.add("data-input-editing");
|
|
1731
1758
|
const dataString = this.element.dataset["clientdialogwidgetconfig"];
|
|
1732
|
-
if (this.sdkApi.
|
|
1759
|
+
if (this.sdkApi.isExistsShowCardTextInput && dataString) {
|
|
1733
1760
|
const data = JSON.parse(dataString);
|
|
1734
1761
|
data.size = getElementBounding(this.env, this.elementRect);
|
|
1735
1762
|
if (!this.disableTimer) {
|
|
@@ -1750,7 +1777,7 @@ class WidgetDataInput extends WidgetBase {
|
|
|
1750
1777
|
catch (e) {
|
|
1751
1778
|
console.error(e);
|
|
1752
1779
|
}
|
|
1753
|
-
this.sdkApi.
|
|
1780
|
+
this.sdkApi.showCardTextInput(this.id, data);
|
|
1754
1781
|
this._statEventFocusIn();
|
|
1755
1782
|
}
|
|
1756
1783
|
return false;
|
|
@@ -2033,10 +2060,12 @@ class WidgetDateCountdown extends WidgetBase {
|
|
|
2033
2060
|
|
|
2034
2061
|
const displaySlide = function (slides, localData) {
|
|
2035
2062
|
const multiSlideItem = slides[0];
|
|
2036
|
-
let
|
|
2063
|
+
let cardId = undefined;
|
|
2064
|
+
let cardType = 1 /* CARD_TYPE.STORY */;
|
|
2037
2065
|
let slideIndex = undefined;
|
|
2038
2066
|
if (multiSlideItem != null) {
|
|
2039
|
-
|
|
2067
|
+
cardId = getTagDataAsNumber(multiSlideItem, "id");
|
|
2068
|
+
cardType = getTagDataAsNumber(multiSlideItem, "card-type") ?? 1 /* CARD_TYPE.STORY */;
|
|
2040
2069
|
slideIndex = getTagDataAsNumber(multiSlideItem, "index");
|
|
2041
2070
|
if (multiSlideItem.querySelectorAll(".narrative-element-share[data-with-layer='1'], .narrative-element-poll-layers, .narrative-element-date-countdown, .narrative-element-game").length > 0) {
|
|
2042
2071
|
// skip if exists share/poll_layers
|
|
@@ -2094,7 +2123,7 @@ const displaySlide = function (slides, localData) {
|
|
|
2094
2123
|
if (slides.length > 0) {
|
|
2095
2124
|
var slide = slides[0];
|
|
2096
2125
|
slide.classList.remove("hidden");
|
|
2097
|
-
WidgetBase.widgetsService.sdkApi.
|
|
2126
|
+
WidgetBase.widgetsService.sdkApi.cardAnimation?.start(slide);
|
|
2098
2127
|
return;
|
|
2099
2128
|
}
|
|
2100
2129
|
score = 0;
|
|
@@ -2123,8 +2152,8 @@ const displaySlide = function (slides, localData) {
|
|
|
2123
2152
|
if (index === selectedIndex) {
|
|
2124
2153
|
slide.classList.remove("hidden");
|
|
2125
2154
|
undefinedResult = false;
|
|
2126
|
-
WidgetBase.widgetsService.sdkApi.
|
|
2127
|
-
_sendStatEvent(
|
|
2155
|
+
WidgetBase.widgetsService.sdkApi.cardAnimation?.start(slide);
|
|
2156
|
+
_sendStatEvent(cardId, cardType, slideIndex, selectedIndex);
|
|
2128
2157
|
}
|
|
2129
2158
|
});
|
|
2130
2159
|
}
|
|
@@ -2133,12 +2162,14 @@ const displaySlide = function (slides, localData) {
|
|
|
2133
2162
|
WidgetBase.widgetsService.sdkApi.showLayer(0);
|
|
2134
2163
|
}
|
|
2135
2164
|
};
|
|
2136
|
-
const _sendStatEvent = function (
|
|
2165
|
+
const _sendStatEvent = function (cardId, cardType, slideIndex, layerIndex) {
|
|
2137
2166
|
try {
|
|
2138
2167
|
WidgetBase.sendStatisticEventToApp("layout-show", {
|
|
2139
|
-
|
|
2140
|
-
si: slideIndex,
|
|
2168
|
+
...WidgetBase.getStatisticEventBaseFieldsShortForm(cardId, slideIndex),
|
|
2141
2169
|
li: layerIndex,
|
|
2170
|
+
}, {
|
|
2171
|
+
...WidgetBase.getStatisticEventBaseFieldsFullForm(cardId, cardType, slideIndex),
|
|
2172
|
+
layout_index: layerIndex,
|
|
2142
2173
|
});
|
|
2143
2174
|
}
|
|
2144
2175
|
catch (error) {
|
|
@@ -2210,7 +2241,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
2210
2241
|
this.refreshUserData(this.options.localData);
|
|
2211
2242
|
}
|
|
2212
2243
|
refreshUserData(localData) {
|
|
2213
|
-
this.savedData = this.sdkApi.
|
|
2244
|
+
this.savedData = this.sdkApi.getCardServerData(this.cardId);
|
|
2214
2245
|
this.localData = extend({}, this.savedData ?? {}, localData);
|
|
2215
2246
|
this.selectedVariant = undefined;
|
|
2216
2247
|
if (this.localData) {
|
|
@@ -2231,16 +2262,14 @@ class WidgetPoll extends WidgetBase {
|
|
|
2231
2262
|
var labelText = this.label?.textContent ?? "";
|
|
2232
2263
|
var variantText = this.variantsTexts[this.selectedVariant] ? this.variantsTexts[this.selectedVariant] : "";
|
|
2233
2264
|
this.sendStatisticEventToApp("w-poll-answer", {
|
|
2234
|
-
|
|
2235
|
-
si: this.slideIndex,
|
|
2265
|
+
...this.statisticEventBaseFieldsShortForm,
|
|
2236
2266
|
wi: this.elementId,
|
|
2237
2267
|
wl: labelText,
|
|
2238
2268
|
wa: this.selectedVariant,
|
|
2239
2269
|
wal: variantText,
|
|
2240
2270
|
d: this.answerDuration,
|
|
2241
2271
|
}, {
|
|
2242
|
-
|
|
2243
|
-
slide_index: this.slideIndex,
|
|
2272
|
+
...this.statisticEventBaseFieldsFullForm,
|
|
2244
2273
|
widget_id: this.elementId,
|
|
2245
2274
|
widget_label: labelText,
|
|
2246
2275
|
widget_answer: this.selectedVariant,
|
|
@@ -2259,8 +2288,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
2259
2288
|
var labelText = this.label?.textContent ?? "";
|
|
2260
2289
|
var variantText = this.variantsTexts[this.selectedVariant] ? this.variantsTexts[this.selectedVariant] : "";
|
|
2261
2290
|
this.sendStatisticEventToApp("w-poll-clarification", {
|
|
2262
|
-
|
|
2263
|
-
si: this.slideIndex,
|
|
2291
|
+
...this.statisticEventBaseFieldsShortForm,
|
|
2264
2292
|
wi: this.elementId,
|
|
2265
2293
|
wl: labelText,
|
|
2266
2294
|
wa: this.selectedVariant,
|
|
@@ -2268,8 +2296,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
2268
2296
|
wv: responseText,
|
|
2269
2297
|
d: this.answerDuration,
|
|
2270
2298
|
}, {
|
|
2271
|
-
|
|
2272
|
-
slide_index: this.slideIndex,
|
|
2299
|
+
...this.statisticEventBaseFieldsFullForm,
|
|
2273
2300
|
widget_id: this.elementId,
|
|
2274
2301
|
widget_label: labelText,
|
|
2275
2302
|
widget_answer: this.selectedVariant,
|
|
@@ -2332,7 +2359,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
2332
2359
|
this.slide.classList.add("data-input-editing");
|
|
2333
2360
|
const dataString = this.element.dataset["clientdialogwidgetconfig"];
|
|
2334
2361
|
this.selectedVariant = index;
|
|
2335
|
-
if (this.sdkApi.
|
|
2362
|
+
if (this.sdkApi.isExistsShowCardTextInput && dataString) {
|
|
2336
2363
|
const data = JSON.parse(dataString);
|
|
2337
2364
|
data.size = getElementBounding(this.env, this.elementRect);
|
|
2338
2365
|
if (!this.disableTimer) {
|
|
@@ -2354,7 +2381,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
2354
2381
|
catch (e) {
|
|
2355
2382
|
console.error(e);
|
|
2356
2383
|
}
|
|
2357
|
-
this.sdkApi.
|
|
2384
|
+
this.sdkApi.showCardTextInput(`${this.id}_first`, data);
|
|
2358
2385
|
}
|
|
2359
2386
|
this._statEventPollAnswer();
|
|
2360
2387
|
return false;
|
|
@@ -2366,7 +2393,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
2366
2393
|
this.slide.classList.add("data-input-editing");
|
|
2367
2394
|
const dataString = this.element.dataset["clientdialogwidgetconfig"];
|
|
2368
2395
|
this.selectedVariant = index;
|
|
2369
|
-
if (this.sdkApi.
|
|
2396
|
+
if (this.sdkApi.isExistsShowCardTextInput && dataString) {
|
|
2370
2397
|
const data = JSON.parse(dataString);
|
|
2371
2398
|
data.size = getElementBounding(this.env, this.elementRect);
|
|
2372
2399
|
if (!this.disableTimer) {
|
|
@@ -2387,7 +2414,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
2387
2414
|
catch (e) {
|
|
2388
2415
|
console.error(e);
|
|
2389
2416
|
}
|
|
2390
|
-
this.sdkApi.
|
|
2417
|
+
this.sdkApi.showCardTextInput(`${this.id}_second`, data);
|
|
2391
2418
|
}
|
|
2392
2419
|
this._statEventPollAnswer();
|
|
2393
2420
|
return false;
|
|
@@ -2430,7 +2457,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
2430
2457
|
displayPercents(selectedVariantIndex, filled = false) {
|
|
2431
2458
|
let pollAllocation = [0, 0];
|
|
2432
2459
|
let pollAllocationTs = undefined;
|
|
2433
|
-
const sharedData = this.sdkApi.getWidgetsSharedData(this.
|
|
2460
|
+
const sharedData = this.sdkApi.getWidgetsSharedData(this.cardId, "poll" /* Widgets.Poll */);
|
|
2434
2461
|
if (sharedData && sharedData[this.elementId] != null && (isObject(sharedData[this.elementId]) || isArray(sharedData[this.elementId]))) {
|
|
2435
2462
|
pollAllocation = sharedData[this.elementId];
|
|
2436
2463
|
if (isObject(sharedData[this.elementId])) {
|
|
@@ -2731,16 +2758,14 @@ class WidgetPollLayers extends WidgetBase {
|
|
|
2731
2758
|
var variantText = this.variants[this.selectedVariant]?.textContent ?? "";
|
|
2732
2759
|
var duration = new Date().getTime() - this.firstOpenTime;
|
|
2733
2760
|
this.sendStatisticEventToApp("w-poll-layers-answer", {
|
|
2734
|
-
|
|
2735
|
-
si: this.slideIndex,
|
|
2761
|
+
...this.statisticEventBaseFieldsShortForm,
|
|
2736
2762
|
wi: this.elementId,
|
|
2737
2763
|
wl: labelText,
|
|
2738
2764
|
wa: this.selectedVariant,
|
|
2739
2765
|
wal: variantText,
|
|
2740
2766
|
d: duration,
|
|
2741
2767
|
}, {
|
|
2742
|
-
|
|
2743
|
-
slide_index: this.slideIndex,
|
|
2768
|
+
...this.statisticEventBaseFieldsFullForm,
|
|
2744
2769
|
widget_id: this.elementId,
|
|
2745
2770
|
widget_label: labelText,
|
|
2746
2771
|
widget_variant: this.selectedVariant,
|
|
@@ -2870,11 +2895,11 @@ class WidgetQuest extends WidgetBase {
|
|
|
2870
2895
|
// this.refreshUserData(this.options.localData);
|
|
2871
2896
|
}
|
|
2872
2897
|
refreshUserData(localData) { }
|
|
2873
|
-
|
|
2874
|
-
this.sdkApi.
|
|
2898
|
+
setCardSessionValue(name, value) {
|
|
2899
|
+
this.sdkApi.setCardSessionValue(this.element, name, value);
|
|
2875
2900
|
}
|
|
2876
|
-
|
|
2877
|
-
return this.sdkApi.
|
|
2901
|
+
getCardSessionValue(name) {
|
|
2902
|
+
return this.sdkApi.getCardSessionValue(this.element, name);
|
|
2878
2903
|
}
|
|
2879
2904
|
init() {
|
|
2880
2905
|
if (this.localData) {
|
|
@@ -2889,12 +2914,12 @@ class WidgetQuest extends WidgetBase {
|
|
|
2889
2914
|
if (lastSlideIdx >= 0 &&
|
|
2890
2915
|
lastSlideIdx < this.slideCount &&
|
|
2891
2916
|
lastSlideIdx !== this.slideIndex /*&& this.slideIndex === this.firstSlideWithQuestIndex()*/) {
|
|
2892
|
-
if (this.
|
|
2917
|
+
if (this.getCardSessionValue("__storyQuestSlideChanged") === undefined) {
|
|
2893
2918
|
// global flag - был сделан переход на нужный слайд, больше не нужно повторять за эту сессию
|
|
2894
2919
|
// perform showStorySlide with lastSlideIdx only on story open first time (not on second slide, etc)
|
|
2895
|
-
this.
|
|
2896
|
-
if (this.sdkApi.
|
|
2897
|
-
this.sdkApi.
|
|
2920
|
+
this.setCardSessionValue("__storyQuestSlideChanged", "1");
|
|
2921
|
+
if (this.sdkApi.isExistsShowCardSlide) {
|
|
2922
|
+
this.sdkApi.showCardSlide(lastSlideIdx);
|
|
2898
2923
|
return false;
|
|
2899
2924
|
}
|
|
2900
2925
|
}
|
|
@@ -2903,8 +2928,8 @@ class WidgetQuest extends WidgetBase {
|
|
|
2903
2928
|
// если этого слайда нет в роутинге (сработал переход по таймеру в app)
|
|
2904
2929
|
var routes = this._getRoutes();
|
|
2905
2930
|
if (routes[0].indexOf(this.slideIndex) === -1 && this.finalSlide) {
|
|
2906
|
-
if (this.sdkApi.
|
|
2907
|
-
this.sdkApi.
|
|
2931
|
+
if (this.sdkApi.isExistsShowNextCard) {
|
|
2932
|
+
this.sdkApi.cardShowNext();
|
|
2908
2933
|
return false;
|
|
2909
2934
|
}
|
|
2910
2935
|
}
|
|
@@ -2914,7 +2939,7 @@ class WidgetQuest extends WidgetBase {
|
|
|
2914
2939
|
// только если находимся в диапазоне квеста
|
|
2915
2940
|
this.localData["_qt_last_slide_idx"] = this.slideIndex;
|
|
2916
2941
|
// global flag - был сделан переход на нужный слайд, больше не нужно повторять за эту сессию
|
|
2917
|
-
this.
|
|
2942
|
+
this.setCardSessionValue("__storyQuestSlideChanged", "1");
|
|
2918
2943
|
// если перешли на слайд (через кнопку - на слайд например) то не будет истории в роутере
|
|
2919
2944
|
// добавляем сами
|
|
2920
2945
|
if (this.getLastSlideIndexFromRouteHistory() !== this.slideIndex) {
|
|
@@ -2949,10 +2974,10 @@ class WidgetQuest extends WidgetBase {
|
|
|
2949
2974
|
this._selectAnswer(index, slideIndex);
|
|
2950
2975
|
this.setLocalData(this.localData, true);
|
|
2951
2976
|
this.env.setTimeout(() => {
|
|
2952
|
-
if (slideIndex >= 0 && slideIndex < this.slideCount && this.sdkApi.
|
|
2977
|
+
if (slideIndex >= 0 && slideIndex < this.slideCount && this.sdkApi.isExistsShowCardSlide) {
|
|
2953
2978
|
// global flag - был сделан переход на нужный слайд, больше не нужно повторять за эту сессию
|
|
2954
|
-
this.
|
|
2955
|
-
this.sdkApi.
|
|
2979
|
+
this.setCardSessionValue("__storyQuestSlideChanged", "1");
|
|
2980
|
+
this.sdkApi.showCardSlide(slideIndex);
|
|
2956
2981
|
}
|
|
2957
2982
|
}, 100);
|
|
2958
2983
|
}
|
|
@@ -3015,12 +3040,12 @@ class WidgetQuest extends WidgetBase {
|
|
|
3015
3040
|
else {
|
|
3016
3041
|
// by routing - move back
|
|
3017
3042
|
var moveTo = this._routeMvPtrBack();
|
|
3018
|
-
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.sdkApi.
|
|
3019
|
-
this.sdkApi.
|
|
3043
|
+
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.sdkApi.isExistsShowCardSlide) {
|
|
3044
|
+
this.sdkApi.showCardSlide(moveTo);
|
|
3020
3045
|
}
|
|
3021
|
-
if (moveTo === false && this.sdkApi.
|
|
3046
|
+
if (moveTo === false && this.sdkApi.isExistsShowCardSlide) {
|
|
3022
3047
|
// allow move to start - for broken route history
|
|
3023
|
-
this.sdkApi.
|
|
3048
|
+
this.sdkApi.showCardSlide(0);
|
|
3024
3049
|
}
|
|
3025
3050
|
}
|
|
3026
3051
|
return;
|
|
@@ -3035,11 +3060,11 @@ class WidgetQuest extends WidgetBase {
|
|
|
3035
3060
|
if (nextSlideIndex < this.slideCount) {
|
|
3036
3061
|
this._addNewRouteHistory(nextSlideIndex);
|
|
3037
3062
|
this.setLocalData(this.localData, true);
|
|
3038
|
-
this.sdkApi.
|
|
3063
|
+
this.sdkApi.showCardSlide(nextSlideIndex);
|
|
3039
3064
|
}
|
|
3040
3065
|
else {
|
|
3041
|
-
if (this.sdkApi.
|
|
3042
|
-
this.sdkApi.
|
|
3066
|
+
if (this.sdkApi.isExistsShowNextCard) {
|
|
3067
|
+
this.sdkApi.cardShowNext();
|
|
3043
3068
|
}
|
|
3044
3069
|
}
|
|
3045
3070
|
}
|
|
@@ -3051,12 +3076,12 @@ class WidgetQuest extends WidgetBase {
|
|
|
3051
3076
|
else {
|
|
3052
3077
|
// by routing - move back
|
|
3053
3078
|
var moveTo = this._routeMvPtrBack();
|
|
3054
|
-
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.sdkApi.
|
|
3055
|
-
this.sdkApi.
|
|
3079
|
+
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.sdkApi.isExistsShowCardSlide) {
|
|
3080
|
+
this.sdkApi.showCardSlide(moveTo);
|
|
3056
3081
|
}
|
|
3057
|
-
if (moveTo === false && this.sdkApi.
|
|
3082
|
+
if (moveTo === false && this.sdkApi.isExistsShowCardSlide) {
|
|
3058
3083
|
// allow move to start - for broken route history
|
|
3059
|
-
this.sdkApi.
|
|
3084
|
+
this.sdkApi.showCardSlide(0);
|
|
3060
3085
|
}
|
|
3061
3086
|
}
|
|
3062
3087
|
}
|
|
@@ -3071,20 +3096,20 @@ class WidgetQuest extends WidgetBase {
|
|
|
3071
3096
|
// setLocalData(this.localData, true);
|
|
3072
3097
|
// window._showNarrativeSlide(nextSlideIndex);
|
|
3073
3098
|
// } else {
|
|
3074
|
-
if (this.sdkApi.
|
|
3075
|
-
this.sdkApi.
|
|
3099
|
+
if (this.sdkApi.isExistsShowNextCard) {
|
|
3100
|
+
this.sdkApi.cardShowNext();
|
|
3076
3101
|
}
|
|
3077
3102
|
// }
|
|
3078
3103
|
}
|
|
3079
3104
|
else {
|
|
3080
3105
|
// by routing - move back
|
|
3081
3106
|
var moveTo = this._routeMvPtrBack();
|
|
3082
|
-
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.sdkApi.
|
|
3083
|
-
this.sdkApi.
|
|
3107
|
+
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.sdkApi.isExistsShowCardSlide) {
|
|
3108
|
+
this.sdkApi.showCardSlide(moveTo);
|
|
3084
3109
|
}
|
|
3085
|
-
if (moveTo === false && this.sdkApi.
|
|
3110
|
+
if (moveTo === false && this.sdkApi.isExistsShowCardSlide) {
|
|
3086
3111
|
// allow move to start - for broken route history
|
|
3087
|
-
this.sdkApi.
|
|
3112
|
+
this.sdkApi.showCardSlide(0);
|
|
3088
3113
|
}
|
|
3089
3114
|
}
|
|
3090
3115
|
}
|
|
@@ -3153,7 +3178,7 @@ class WidgetQuiz extends WidgetBase {
|
|
|
3153
3178
|
this.refreshUserData(this.options.localData);
|
|
3154
3179
|
}
|
|
3155
3180
|
refreshUserData(localData) {
|
|
3156
|
-
this.savedData = this.sdkApi.
|
|
3181
|
+
this.savedData = this.sdkApi.getCardServerData(this.cardId);
|
|
3157
3182
|
this.localData = extend({}, this.savedData ?? {}, localData);
|
|
3158
3183
|
this.selectedAnswer = undefined;
|
|
3159
3184
|
if (this.localData) {
|
|
@@ -3259,17 +3284,15 @@ class WidgetQuiz extends WidgetBase {
|
|
|
3259
3284
|
}
|
|
3260
3285
|
}
|
|
3261
3286
|
var duration = new Date().getTime() - this.firstOpenTime;
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
si: this.slideIndex,
|
|
3287
|
+
this.sendStatisticEventToApp("w-quiz-answer", {
|
|
3288
|
+
...this.statisticEventBaseFieldsShortForm,
|
|
3265
3289
|
wi: this.elementId,
|
|
3266
3290
|
wl: questionText,
|
|
3267
3291
|
wa: selectedAnswerIndex,
|
|
3268
3292
|
wal: answerText,
|
|
3269
3293
|
d: duration,
|
|
3270
3294
|
}, {
|
|
3271
|
-
|
|
3272
|
-
slide_index: this.slideIndex,
|
|
3295
|
+
...this.statisticEventBaseFieldsFullForm,
|
|
3273
3296
|
widget_id: this.elementId,
|
|
3274
3297
|
widget_label: questionText,
|
|
3275
3298
|
widget_answer: selectedAnswerIndex,
|
|
@@ -3344,7 +3367,7 @@ class WidgetQuizGrouped extends WidgetBase {
|
|
|
3344
3367
|
this.refreshUserData(this.options.localData);
|
|
3345
3368
|
}
|
|
3346
3369
|
refreshUserData(localData) {
|
|
3347
|
-
this.savedData = this.sdkApi.
|
|
3370
|
+
this.savedData = this.sdkApi.getCardServerData(this.cardId);
|
|
3348
3371
|
this.localData = extend({}, this.savedData ?? {}, localData);
|
|
3349
3372
|
this.selectedAnswer = undefined;
|
|
3350
3373
|
if (this.localData) {
|
|
@@ -3396,8 +3419,8 @@ class WidgetQuizGrouped extends WidgetBase {
|
|
|
3396
3419
|
if (this.localData["qg_score"] == null) {
|
|
3397
3420
|
this.localData["qg_score"] = {};
|
|
3398
3421
|
}
|
|
3399
|
-
|
|
3400
|
-
for (
|
|
3422
|
+
let sum = 0;
|
|
3423
|
+
for (let i = 0; i < this.answers.length; i++) {
|
|
3401
3424
|
if (this.localData["qg_score"][i] == null) {
|
|
3402
3425
|
this.localData["qg_score"][i] = 0;
|
|
3403
3426
|
}
|
|
@@ -3406,8 +3429,8 @@ class WidgetQuizGrouped extends WidgetBase {
|
|
|
3406
3429
|
// если еще не ответили на все
|
|
3407
3430
|
if (sum < this.questionCount) {
|
|
3408
3431
|
this.localData["qg_score"][answerValue] += 1;
|
|
3409
|
-
|
|
3410
|
-
for (
|
|
3432
|
+
let answeredQuestion = 0;
|
|
3433
|
+
for (const key in this.localData) {
|
|
3411
3434
|
if (this.localData.hasOwnProperty(key)) {
|
|
3412
3435
|
if (/^_q_gg_[A-z0-9-_]+_sa$/.test(key)) {
|
|
3413
3436
|
answeredQuestion++;
|
|
@@ -3445,26 +3468,24 @@ class WidgetQuizGrouped extends WidgetBase {
|
|
|
3445
3468
|
}, 2000);
|
|
3446
3469
|
}
|
|
3447
3470
|
try {
|
|
3448
|
-
|
|
3449
|
-
|
|
3471
|
+
const questionText = this.question ? this.question.textContent ?? "" : "";
|
|
3472
|
+
let answerText = "";
|
|
3450
3473
|
if (this.answers[selectedAnswerIndex]) {
|
|
3451
|
-
|
|
3474
|
+
const answerLabel = this.answers[selectedAnswerIndex].querySelector(".variant-view .label");
|
|
3452
3475
|
if (answerLabel != null) {
|
|
3453
3476
|
answerText = answerLabel.textContent ?? "";
|
|
3454
3477
|
}
|
|
3455
3478
|
}
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
si: this.slideIndex,
|
|
3479
|
+
const duration = new Date().getTime() - this.firstOpenTime;
|
|
3480
|
+
this.sendStatisticEventToApp("w-quiz-grouped-answer", {
|
|
3481
|
+
...this.statisticEventBaseFieldsShortForm,
|
|
3460
3482
|
wi: this.elementId,
|
|
3461
3483
|
wl: questionText,
|
|
3462
3484
|
wa: selectedAnswerIndex,
|
|
3463
3485
|
wal: answerText,
|
|
3464
3486
|
d: duration,
|
|
3465
3487
|
}, {
|
|
3466
|
-
|
|
3467
|
-
slide_index: this.slideIndex,
|
|
3488
|
+
...this.statisticEventBaseFieldsFullForm,
|
|
3468
3489
|
widget_id: this.elementId,
|
|
3469
3490
|
widget_label: questionText,
|
|
3470
3491
|
widget_answer: selectedAnswerIndex,
|
|
@@ -3731,7 +3752,7 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
3731
3752
|
this.env.document.addEventListener("mousedown", this.handleDown);
|
|
3732
3753
|
}
|
|
3733
3754
|
refreshUserData(localData) {
|
|
3734
|
-
this.savedData = this.sdkApi.
|
|
3755
|
+
this.savedData = this.sdkApi.getCardServerData(this.cardId);
|
|
3735
3756
|
this.localData = extend({}, this.savedData ?? {}, localData);
|
|
3736
3757
|
if (this.localData["_rs_g_" + this.elementId + "_v"] !== undefined) {
|
|
3737
3758
|
this.elementSlider.value = String(tryParseFloat(this.localData["_rs_g_" + this.elementId + "_v"], 0));
|
|
@@ -3752,14 +3773,12 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
3752
3773
|
try {
|
|
3753
3774
|
const labelText = this.label?.textContent ?? "";
|
|
3754
3775
|
this.sendStatisticEventToApp("w-range-slider-answer", {
|
|
3755
|
-
|
|
3756
|
-
si: this.slideIndex,
|
|
3776
|
+
...this.statisticEventBaseFieldsShortForm,
|
|
3757
3777
|
wi: this.elementId,
|
|
3758
3778
|
wl: labelText,
|
|
3759
3779
|
wa: val,
|
|
3760
3780
|
}, {
|
|
3761
|
-
|
|
3762
|
-
slide_index: this.slideIndex,
|
|
3781
|
+
...this.statisticEventBaseFieldsFullForm,
|
|
3763
3782
|
widget_id: this.elementId,
|
|
3764
3783
|
widget_label: labelText,
|
|
3765
3784
|
widget_answer: val,
|
|
@@ -3824,7 +3843,7 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
3824
3843
|
total_user: 0,
|
|
3825
3844
|
};
|
|
3826
3845
|
let answerAllocationTs = undefined;
|
|
3827
|
-
const sharedData = this.sdkApi.getWidgetsSharedData(this.
|
|
3846
|
+
const sharedData = this.sdkApi.getWidgetsSharedData(this.cardId, "rangeSlider" /* Widgets.RangeSlider */);
|
|
3828
3847
|
if (sharedData && sharedData[this.elementId] != null && (isObject(sharedData[this.elementId]) || isArray(sharedData[this.elementId]))) {
|
|
3829
3848
|
answerAllocation = sharedData[this.elementId];
|
|
3830
3849
|
answerAllocationTs = sharedData.ts;
|
|
@@ -4158,7 +4177,7 @@ class WidgetRate extends WidgetBase {
|
|
|
4158
4177
|
this.refreshUserData(this.options.localData);
|
|
4159
4178
|
}
|
|
4160
4179
|
refreshUserData(localData) {
|
|
4161
|
-
this.savedData = this.sdkApi.
|
|
4180
|
+
this.savedData = this.sdkApi.getCardServerData(this.cardId);
|
|
4162
4181
|
this.localData = extend({}, this.savedData ?? {}, localData);
|
|
4163
4182
|
this.selectedStar = undefined;
|
|
4164
4183
|
if (this.localData) {
|
|
@@ -4179,16 +4198,14 @@ class WidgetRate extends WidgetBase {
|
|
|
4179
4198
|
if (this.selectedStar != null) {
|
|
4180
4199
|
var selectedAnswer = this.selectedStar + 1;
|
|
4181
4200
|
this.sendStatisticEventToApp("w-rate-answer", {
|
|
4182
|
-
|
|
4183
|
-
si: this.slideIndex,
|
|
4201
|
+
...this.statisticEventBaseFieldsShortForm,
|
|
4184
4202
|
wi: this.elementId,
|
|
4185
4203
|
wl: labelText,
|
|
4186
4204
|
wa: selectedAnswer,
|
|
4187
4205
|
wv: answerText,
|
|
4188
4206
|
d: this.answerSelectDuration,
|
|
4189
4207
|
}, {
|
|
4190
|
-
|
|
4191
|
-
slide_index: this.slideIndex,
|
|
4208
|
+
...this.statisticEventBaseFieldsFullForm,
|
|
4192
4209
|
widget_id: this.elementId,
|
|
4193
4210
|
widget_label: labelText,
|
|
4194
4211
|
widget_answer: selectedAnswer,
|
|
@@ -4253,7 +4270,7 @@ class WidgetRate extends WidgetBase {
|
|
|
4253
4270
|
}
|
|
4254
4271
|
this.slide.classList.add("data-input-editing");
|
|
4255
4272
|
const dataString = this.element.dataset["clientdialogwidgetconfig"];
|
|
4256
|
-
if (this.sdkApi.
|
|
4273
|
+
if (this.sdkApi.isExistsShowCardTextInput && dataString) {
|
|
4257
4274
|
const data = JSON.parse(dataString);
|
|
4258
4275
|
data.size = getElementBounding(this.env, this.elementRect);
|
|
4259
4276
|
if (!this.disableTimer) {
|
|
@@ -4275,7 +4292,7 @@ class WidgetRate extends WidgetBase {
|
|
|
4275
4292
|
catch (e) {
|
|
4276
4293
|
console.error(e);
|
|
4277
4294
|
}
|
|
4278
|
-
this.sdkApi.
|
|
4295
|
+
this.sdkApi.showCardTextInput(this.id, data);
|
|
4279
4296
|
}
|
|
4280
4297
|
}
|
|
4281
4298
|
else {
|
|
@@ -4407,18 +4424,16 @@ class WidgetShare extends WidgetBase {
|
|
|
4407
4424
|
refreshUserData(localData) { }
|
|
4408
4425
|
_statEventShare(result, via) {
|
|
4409
4426
|
try {
|
|
4410
|
-
|
|
4427
|
+
const buttonText = this.element.textContent ?? "";
|
|
4411
4428
|
this.sendStatisticEventToApp("w-share", {
|
|
4412
|
-
|
|
4413
|
-
si: this.slideIndex,
|
|
4429
|
+
...this.statisticEventBaseFieldsShortForm,
|
|
4414
4430
|
wi: this.elementId,
|
|
4415
4431
|
wl: buttonText,
|
|
4416
4432
|
wv: this.shareTarget ?? "",
|
|
4417
4433
|
wa: result ? 1 : 0,
|
|
4418
4434
|
wal: via ?? "",
|
|
4419
4435
|
}, {
|
|
4420
|
-
|
|
4421
|
-
slide_index: this.slideIndex,
|
|
4436
|
+
...this.statisticEventBaseFieldsFullForm,
|
|
4422
4437
|
widget_id: this.elementId,
|
|
4423
4438
|
widget_label: buttonText,
|
|
4424
4439
|
widget_value: this.shareTarget ?? "",
|
|
@@ -4610,8 +4625,7 @@ class WidgetTest extends WidgetBase {
|
|
|
4610
4625
|
}
|
|
4611
4626
|
var duration = new Date().getTime() - this.firstOpenTime;
|
|
4612
4627
|
this.sendStatisticEventToApp("w-test-answer", {
|
|
4613
|
-
|
|
4614
|
-
si: this.slideIndex,
|
|
4628
|
+
...this.statisticEventBaseFieldsShortForm,
|
|
4615
4629
|
wi: this.elementId,
|
|
4616
4630
|
wl: labelText,
|
|
4617
4631
|
wa: this.selectedAnswer,
|
|
@@ -4619,8 +4633,7 @@ class WidgetTest extends WidgetBase {
|
|
|
4619
4633
|
was: answerScore,
|
|
4620
4634
|
d: duration,
|
|
4621
4635
|
}, {
|
|
4622
|
-
|
|
4623
|
-
slide_index: this.slideIndex,
|
|
4636
|
+
...this.statisticEventBaseFieldsFullForm,
|
|
4624
4637
|
widget_id: this.elementId,
|
|
4625
4638
|
widget_label: labelText,
|
|
4626
4639
|
widget_answer: this.selectedAnswer,
|
|
@@ -4827,7 +4840,7 @@ class WidgetVote extends WidgetBase {
|
|
|
4827
4840
|
}
|
|
4828
4841
|
}
|
|
4829
4842
|
refreshUserData(localData) {
|
|
4830
|
-
this.savedData = this.sdkApi.
|
|
4843
|
+
this.savedData = this.sdkApi.getCardServerData(this.cardId);
|
|
4831
4844
|
this.localData = extend({}, this.savedData ?? {}, localData);
|
|
4832
4845
|
this.selectedVariant = undefined;
|
|
4833
4846
|
if (this.localData) {
|
|
@@ -4877,8 +4890,7 @@ class WidgetVote extends WidgetBase {
|
|
|
4877
4890
|
// доп поля - для multiple choice
|
|
4878
4891
|
// первые оставляем пустыми в этом случае
|
|
4879
4892
|
this.sendStatisticEventToApp("w-vote-answer", {
|
|
4880
|
-
|
|
4881
|
-
si: this.slideIndex,
|
|
4893
|
+
...this.statisticEventBaseFieldsShortForm,
|
|
4882
4894
|
wi: this.elementId,
|
|
4883
4895
|
wl: labelText,
|
|
4884
4896
|
wa: selectedVariant,
|
|
@@ -4887,8 +4899,7 @@ class WidgetVote extends WidgetBase {
|
|
|
4887
4899
|
was: selectedVariantsIdxs,
|
|
4888
4900
|
wvs: selectedVariantsLabels,
|
|
4889
4901
|
}, {
|
|
4890
|
-
|
|
4891
|
-
slide_index: this.slideIndex,
|
|
4902
|
+
...this.statisticEventBaseFieldsFullForm,
|
|
4892
4903
|
widget_id: this.elementId,
|
|
4893
4904
|
widget_label: labelText,
|
|
4894
4905
|
widget_answer: selectedVariant,
|
|
@@ -5080,7 +5091,7 @@ class WidgetVote extends WidgetBase {
|
|
|
5080
5091
|
// voteAllocation[7]
|
|
5081
5092
|
let voteAllocation = [];
|
|
5082
5093
|
let voteAllocationTs = undefined;
|
|
5083
|
-
const sharedData = this.sdkApi.getWidgetsSharedData(this.
|
|
5094
|
+
const sharedData = this.sdkApi.getWidgetsSharedData(this.cardId, "vote" /* Widgets.Vote */);
|
|
5084
5095
|
if (sharedData && sharedData[this.elementId] != null && (isObject(sharedData[this.elementId]) || isArray(sharedData[this.elementId]))) {
|
|
5085
5096
|
voteAllocation = sharedData[this.elementId];
|
|
5086
5097
|
if (isObject(sharedData[this.elementId])) {
|
|
@@ -14650,9 +14661,16 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14650
14661
|
}
|
|
14651
14662
|
if (this.svgView && svg) {
|
|
14652
14663
|
this.svgView.innerHTML = svg;
|
|
14653
|
-
const
|
|
14654
|
-
|
|
14655
|
-
svgPathNode.
|
|
14664
|
+
const svgPathNodes = this.svgView.querySelectorAll("svg path");
|
|
14665
|
+
for (const svgPathNode of svgPathNodes) {
|
|
14666
|
+
if (svgPathNode.hasAttribute("fill")) {
|
|
14667
|
+
// for paths with fill (qr, pdf417)
|
|
14668
|
+
svgPathNode.setAttribute("fill", "currentColor");
|
|
14669
|
+
}
|
|
14670
|
+
if (svgPathNode.hasAttribute("stroke")) {
|
|
14671
|
+
// for paths with stroke (EAN 13)
|
|
14672
|
+
svgPathNode.setAttribute("stroke", "currentColor");
|
|
14673
|
+
}
|
|
14656
14674
|
}
|
|
14657
14675
|
}
|
|
14658
14676
|
}
|
|
@@ -14707,13 +14725,13 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14707
14725
|
// for transparent element
|
|
14708
14726
|
addClass(this.element, "loader");
|
|
14709
14727
|
}
|
|
14710
|
-
// fetch
|
|
14711
|
-
|
|
14712
|
-
|
|
14728
|
+
// fetch promotional code
|
|
14729
|
+
const path = this.getPromotionalCodeFetchPath(this.clipboardTarget ?? "");
|
|
14730
|
+
const headers = {
|
|
14713
14731
|
accept: "application/json",
|
|
14714
14732
|
"Content-Type": "application/json",
|
|
14715
14733
|
};
|
|
14716
|
-
|
|
14734
|
+
const profileKey = "fetch-promo-code";
|
|
14717
14735
|
Promise.all([
|
|
14718
14736
|
this.sdkApi.sendApiRequest(path, "POST", null, headers, null, profileKey),
|
|
14719
14737
|
new Promise(function (t, e) {
|
|
@@ -14770,14 +14788,12 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14770
14788
|
try {
|
|
14771
14789
|
var captionViewText = this.captionView?.textContent ?? "";
|
|
14772
14790
|
this.sendStatisticEventToApp("w-barcode", {
|
|
14773
|
-
|
|
14774
|
-
si: this.slideIndex,
|
|
14791
|
+
...this.statisticEventBaseFieldsShortForm,
|
|
14775
14792
|
wi: this.elementId,
|
|
14776
14793
|
wl: captionViewText,
|
|
14777
14794
|
wv: clipboardTarget,
|
|
14778
14795
|
}, {
|
|
14779
|
-
|
|
14780
|
-
slide_index: this.slideIndex,
|
|
14796
|
+
...this.statisticEventBaseFieldsShortForm,
|
|
14781
14797
|
widget_id: this.elementId,
|
|
14782
14798
|
widget_label: captionViewText,
|
|
14783
14799
|
widget_value: clipboardTarget,
|