@inappstory/slide-api 0.0.18 → 0.0.20

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 CHANGED
@@ -1254,7 +1254,7 @@ class WidgetBase {
1254
1254
  this.id = `w_${this.elementId}_${WidgetBase.widgetIndex}`;
1255
1255
  ++WidgetBase.widgetIndex;
1256
1256
  }
1257
- refreshUserData(localData) { }
1257
+ onRefreshUserData(localData) { }
1258
1258
  static widgetCacheKey = "ias.story-element";
1259
1259
  static widgetClassName = "";
1260
1260
  static getInstance(element) {
@@ -1433,13 +1433,14 @@ class WidgetBase {
1433
1433
  console.error(error);
1434
1434
  }
1435
1435
  }
1436
+ /** @deprecated */
1436
1437
  static refreshUserData(nodes, localData) {
1437
1438
  const cb = (el, localData) => {
1438
1439
  const widgetElement = el.closest(`.${this.widgetClassName}`);
1439
1440
  if (widgetElement) {
1440
1441
  const widget = WidgetBase.getInstance(widgetElement);
1441
1442
  if (widget) {
1442
- widget.refreshUserData(localData);
1443
+ widget.onRefreshUserData(localData);
1443
1444
  }
1444
1445
  }
1445
1446
  };
@@ -1454,6 +1455,25 @@ class WidgetBase {
1454
1455
  });
1455
1456
  }
1456
1457
  }
1458
+ static onRefreshUserData(element, localData) {
1459
+ const cb = (el, localData) => {
1460
+ const widgetElement = el.closest(`.${this.widgetClassName}`);
1461
+ if (widgetElement) {
1462
+ const widget = WidgetBase.getInstance(widgetElement);
1463
+ if (widget) {
1464
+ widget.onRefreshUserData(localData);
1465
+ }
1466
+ }
1467
+ };
1468
+ if (localData != null) {
1469
+ cb(element, localData);
1470
+ }
1471
+ else {
1472
+ WidgetBase.getLocalData().then(localData => {
1473
+ cb(element, localData);
1474
+ });
1475
+ }
1476
+ }
1457
1477
  getPromotionalCodeFetchPath(promotionalCodeId) {
1458
1478
  switch (this.cardType) {
1459
1479
  case 4 /* CARD_TYPE.IN_APP_MESSAGING */:
@@ -1495,7 +1515,12 @@ class WidgetCopy extends WidgetBase {
1495
1515
  this.msgNoMoreCodes = getTagData(this.element, "msgNoMoreCodes");
1496
1516
  this.msgTryAgain = getTagData(this.element, "msgTryAgain");
1497
1517
  this.geometry = this.element.closest(".narrative-element-geometry");
1498
- this.resultLayer = this.slide.querySelector(".narrative-element-copy-result-variant");
1518
+ // this is result layer - skip init
1519
+ // todo prevent call Widget.init on result-layer
1520
+ if (this.element.classList.contains("narrative-element-copy-result-variant")) {
1521
+ return;
1522
+ }
1523
+ this.resultLayer = this.slide.querySelector(`.narrative-element-copy-result-variant[data-element-id="${this.elementId}"]`);
1499
1524
  if (this.resultLayer && this.geometry) {
1500
1525
  this.resultLayerGeometry = this.resultLayer.closest(".narrative-element-geometry");
1501
1526
  // create align center
@@ -1516,9 +1541,9 @@ class WidgetCopy extends WidgetBase {
1516
1541
  if (this.isPromotionalCode) {
1517
1542
  this.fetchPromoCode();
1518
1543
  }
1519
- // this.refreshUserData(this.options.localData);
1544
+ // this.onRefreshUserData(this.options.localData);
1520
1545
  }
1521
- refreshUserData(localData) { }
1546
+ onRefreshUserData(localData) { }
1522
1547
  isTransparentElement() {
1523
1548
  if (this.element) {
1524
1549
  try {
@@ -1660,7 +1685,9 @@ class WidgetCopy extends WidgetBase {
1660
1685
  }
1661
1686
  static api = {
1662
1687
  widgetClassName: WidgetCopy.widgetClassName,
1688
+ /** @deprecated */
1663
1689
  refreshUserData: WidgetCopy.refreshUserData,
1690
+ onRefreshUserData: WidgetCopy.onRefreshUserData,
1664
1691
  init: function (element, localData) {
1665
1692
  // prevent initWidget for result layer
1666
1693
  if (!element.classList.contains("narrative-element-copy-result-variant")) {
@@ -1721,9 +1748,9 @@ class WidgetDataInput extends WidgetBase {
1721
1748
  this.inputElement = getValueOrException(this.element.querySelector(".input-view .input"), "Empty .input-view .input");
1722
1749
  this.textElement = getValueOrException(this.inputElement.querySelector(".narrative-element-text-lines"), "Empty .narrative-element-text-lines");
1723
1750
  this.inputPlaceholderValue = this.textElement.innerHTML;
1724
- this.refreshUserData(this.options.localData);
1751
+ this.onRefreshUserData(this.options.localData);
1725
1752
  }
1726
- refreshUserData(localData) {
1753
+ onRefreshUserData(localData) {
1727
1754
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
1728
1755
  this.localData = extend({}, this.savedData ?? {}, localData);
1729
1756
  const text = this.localData["_di_g_" + this.elementId + "_t"];
@@ -1854,7 +1881,9 @@ class WidgetDataInput extends WidgetBase {
1854
1881
  }
1855
1882
  static api = {
1856
1883
  widgetClassName: WidgetDataInput.widgetClassName,
1884
+ /** @deprecated */
1857
1885
  refreshUserData: WidgetDataInput.refreshUserData,
1886
+ onRefreshUserData: WidgetDataInput.onRefreshUserData,
1858
1887
  init: function (element, localData) {
1859
1888
  WidgetDataInput.initWidget(element, localData, (element, options) => new WidgetDataInput(element, options));
1860
1889
  },
@@ -1944,9 +1973,9 @@ class WidgetDateCountdown extends WidgetBase {
1944
1973
  // } else {
1945
1974
  this.initTimer();
1946
1975
  // }
1947
- // this.refreshUserData(this.options.localData);
1976
+ // this.onRefreshUserData(this.options.localData);
1948
1977
  }
1949
- refreshUserData(localData) { }
1978
+ onRefreshUserData(localData) { }
1950
1979
  pause() {
1951
1980
  if (this.timerInited) {
1952
1981
  this.pendingUpdate = false;
@@ -2072,7 +2101,9 @@ class WidgetDateCountdown extends WidgetBase {
2072
2101
  }
2073
2102
  static api = {
2074
2103
  widgetClassName: WidgetDateCountdown.widgetClassName,
2104
+ /** @deprecated */
2075
2105
  refreshUserData: WidgetDateCountdown.refreshUserData,
2106
+ onRefreshUserData: WidgetDateCountdown.onRefreshUserData,
2076
2107
  init: function (element, layers, localData) {
2077
2108
  WidgetDateCountdown.initWidget(element, localData, (element, options) => new WidgetDateCountdown(element, { ...options, layers }));
2078
2109
  },
@@ -2281,9 +2312,9 @@ class WidgetPoll extends WidgetBase {
2281
2312
  this.getUseResponseOnFirstButton = Boolean(getTagDataAsNumber(this.element, "getUserResponseOnFirstButton"));
2282
2313
  this.getUseResponseOnSecondButton = Boolean(getTagDataAsNumber(this.element, "getUserResponseOnSecondButton"));
2283
2314
  this.showClientTotalResult = Boolean(getTagDataAsNumber(this.element, "showClientTotalResult"));
2284
- this.refreshUserData(this.options.localData);
2315
+ this.onRefreshUserData(this.options.localData);
2285
2316
  }
2286
- refreshUserData(localData) {
2317
+ onRefreshUserData(localData) {
2287
2318
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
2288
2319
  this.localData = extend({}, this.savedData ?? {}, localData);
2289
2320
  this.selectedVariant = undefined;
@@ -2713,7 +2744,9 @@ class WidgetPoll extends WidgetBase {
2713
2744
  }
2714
2745
  static api = {
2715
2746
  widgetClassName: WidgetPoll.widgetClassName,
2747
+ /** @deprecated */
2716
2748
  refreshUserData: WidgetPoll.refreshUserData,
2749
+ onRefreshUserData: WidgetPoll.onRefreshUserData,
2717
2750
  init: function (element, localData) {
2718
2751
  WidgetPoll.initWidget(element, localData, (element, options) => new WidgetPoll(element, options));
2719
2752
  },
@@ -2796,9 +2829,9 @@ class WidgetPollLayers extends WidgetBase {
2796
2829
  this._showLayout(this.layers, 0);
2797
2830
  }
2798
2831
  this.firstOpenTime = new Date().getTime();
2799
- this.refreshUserData(this.options.localData);
2832
+ this.onRefreshUserData(this.options.localData);
2800
2833
  }
2801
- refreshUserData(localData) { }
2834
+ onRefreshUserData(localData) { }
2802
2835
  _statEventPollVariant() {
2803
2836
  try {
2804
2837
  if (this.selectedVariant != null) {
@@ -2881,7 +2914,9 @@ class WidgetPollLayers extends WidgetBase {
2881
2914
  }
2882
2915
  static api = {
2883
2916
  widgetClassName: WidgetPollLayers.widgetClassName,
2917
+ /** @deprecated */
2884
2918
  refreshUserData: WidgetPollLayers.refreshUserData,
2919
+ onRefreshUserData: WidgetPollLayers.onRefreshUserData,
2885
2920
  init: function (element, layers, localData) {
2886
2921
  WidgetPollLayers.initWidget(element, localData, (element, options) => new WidgetPollLayers(element, { ...options, layers }));
2887
2922
  },
@@ -2946,9 +2981,9 @@ class WidgetQuest extends WidgetBase {
2946
2981
  this.label = this.element.querySelector(".label-view .label");
2947
2982
  this.variants = slice.call(this.element.querySelectorAll(".variants-box .variant-view"));
2948
2983
  this.selectedAnswer = undefined;
2949
- // this.refreshUserData(this.options.localData);
2984
+ // this.onRefreshUserData(this.options.localData);
2950
2985
  }
2951
- refreshUserData(localData) { }
2986
+ onRefreshUserData(localData) { }
2952
2987
  setCardSessionValue(name, value) {
2953
2988
  this.sdkApi.setCardSessionValue(this.element, name, value);
2954
2989
  }
@@ -3172,7 +3207,9 @@ class WidgetQuest extends WidgetBase {
3172
3207
  }
3173
3208
  static api = {
3174
3209
  widgetClassName: WidgetQuest.widgetClassName,
3210
+ /** @deprecated */
3175
3211
  refreshUserData: WidgetQuest.refreshUserData,
3212
+ onRefreshUserData: WidgetQuest.onRefreshUserData,
3176
3213
  init: function (element, localData) {
3177
3214
  return new Promise(function (resolve, reject) {
3178
3215
  WidgetQuest.initWidget(element, localData, (element, options) => new WidgetQuest(element, options)).then(localData => {
@@ -3243,9 +3280,9 @@ class WidgetQuiz extends WidgetBase {
3243
3280
  this.question = this.element.querySelector(".label-view .label");
3244
3281
  this.answers = slice.call(this.element.querySelectorAll(".variants-box .variant-view-group"));
3245
3282
  this.questionCount = getValueOrException(getTagDataAsNumber(this.slide, "quizCount"), "Empty quizCount");
3246
- this.refreshUserData(this.options.localData);
3283
+ this.onRefreshUserData(this.options.localData);
3247
3284
  }
3248
- refreshUserData(localData) {
3285
+ onRefreshUserData(localData) {
3249
3286
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
3250
3287
  this.localData = extend({}, this.savedData ?? {}, localData);
3251
3288
  this.selectedAnswer = undefined;
@@ -3382,7 +3419,9 @@ class WidgetQuiz extends WidgetBase {
3382
3419
  }
3383
3420
  static api = {
3384
3421
  widgetClassName: WidgetQuiz.widgetClassName,
3422
+ /** @deprecated */
3385
3423
  refreshUserData: WidgetQuiz.refreshUserData,
3424
+ onRefreshUserData: WidgetQuiz.onRefreshUserData,
3386
3425
  init: function (element, localData) {
3387
3426
  WidgetQuiz.initWidget(element, localData, (element, options) => new WidgetQuiz(element, options));
3388
3427
  },
@@ -3436,9 +3475,9 @@ class WidgetQuizGrouped extends WidgetBase {
3436
3475
  this.question = this.element.querySelector(".label-view .label");
3437
3476
  this.answers = slice.call(this.element.querySelectorAll(".variants-box .variant-view-group"));
3438
3477
  this.questionCount = getValueOrException(getTagDataAsNumber(this.slide, "quizCount"), "Empty quizCount");
3439
- this.refreshUserData(this.options.localData);
3478
+ this.onRefreshUserData(this.options.localData);
3440
3479
  }
3441
- refreshUserData(localData) {
3480
+ onRefreshUserData(localData) {
3442
3481
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
3443
3482
  this.localData = extend({}, this.savedData ?? {}, localData);
3444
3483
  this.selectedAnswer = undefined;
@@ -3579,7 +3618,9 @@ class WidgetQuizGrouped extends WidgetBase {
3579
3618
  }
3580
3619
  static api = {
3581
3620
  widgetClassName: WidgetQuizGrouped.widgetClassName,
3621
+ /** @deprecated */
3582
3622
  refreshUserData: WidgetQuizGrouped.refreshUserData,
3623
+ onRefreshUserData: WidgetQuizGrouped.onRefreshUserData,
3583
3624
  init: function (element, localData) {
3584
3625
  WidgetQuizGrouped.initWidget(element, localData, (element, options) => new WidgetQuizGrouped(element, options));
3585
3626
  },
@@ -3816,7 +3857,7 @@ class WidgetRangeSlider extends WidgetBase {
3816
3857
  this.handleDown = proxy(this.handleDown, this);
3817
3858
  this.handleMove = proxy(this.handleMove, this);
3818
3859
  this.handleEnd = proxy(this.handleEnd, this);
3819
- this.refreshUserData(this.options.localData);
3860
+ this.onRefreshUserData(this.options.localData);
3820
3861
  // Attach Events
3821
3862
  // window.addEventListener('resize.' + this.identifier, debounce(function() {
3822
3863
  // // Simulate resizeEnd event.
@@ -3827,7 +3868,7 @@ class WidgetRangeSlider extends WidgetBase {
3827
3868
  this.env.document.addEventListener("touchstart", this.handleDown);
3828
3869
  this.env.document.addEventListener("mousedown", this.handleDown);
3829
3870
  }
3830
- refreshUserData(localData) {
3871
+ onRefreshUserData(localData) {
3831
3872
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
3832
3873
  this.localData = extend({}, this.savedData ?? {}, localData);
3833
3874
  if (this.localData["_rs_g_" + this.elementId + "_v"] !== undefined) {
@@ -4191,7 +4232,9 @@ class WidgetRangeSlider extends WidgetBase {
4191
4232
  }
4192
4233
  static api = {
4193
4234
  widgetClassName: WidgetRangeSlider.widgetClassName,
4235
+ /** @deprecated */
4194
4236
  refreshUserData: WidgetRangeSlider.refreshUserData,
4237
+ onRefreshUserData: WidgetRangeSlider.onRefreshUserData,
4195
4238
  init: function (element, localData) {
4196
4239
  WidgetRangeSlider.initWidget(element, localData, (element, options) => new WidgetRangeSlider(element, options));
4197
4240
  },
@@ -4253,9 +4296,9 @@ class WidgetRate extends WidgetBase {
4253
4296
  this.showDialogOnLowRate = Boolean(getValueOrDefault(getTagDataAsNumber(this.element, "showDialogOnLowRate"), 0));
4254
4297
  this.showDialogueMin = getValueOrDefault(getTagDataAsNumber(this.element, "showDialogueMin"), 1);
4255
4298
  this.showDialogueMax = getValueOrDefault(getTagDataAsNumber(this.element, "showDialogueMax"), 3);
4256
- this.refreshUserData(this.options.localData);
4299
+ this.onRefreshUserData(this.options.localData);
4257
4300
  }
4258
- refreshUserData(localData) {
4301
+ onRefreshUserData(localData) {
4259
4302
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
4260
4303
  this.localData = extend({}, this.savedData ?? {}, localData);
4261
4304
  this.selectedStar = undefined;
@@ -4442,7 +4485,9 @@ class WidgetRate extends WidgetBase {
4442
4485
  }
4443
4486
  static api = {
4444
4487
  widgetClassName: WidgetRate.widgetClassName,
4488
+ /** @deprecated */
4445
4489
  refreshUserData: WidgetRate.refreshUserData,
4490
+ onRefreshUserData: WidgetRate.onRefreshUserData,
4446
4491
  init: function (element, localData) {
4447
4492
  WidgetRate.initWidget(element, localData, (element, options) => new WidgetRate(element, options));
4448
4493
  },
@@ -4506,9 +4551,9 @@ class WidgetShare extends WidgetBase {
4506
4551
  this.startDisabledTimeline();
4507
4552
  }
4508
4553
  this.btnDisabled = false;
4509
- // this.refreshUserData(this.options.localData);
4554
+ // this.onRefreshUserData(this.options.localData);
4510
4555
  }
4511
- refreshUserData(localData) { }
4556
+ onRefreshUserData(localData) { }
4512
4557
  _statEventShare(result, via) {
4513
4558
  try {
4514
4559
  const buttonText = this.element.textContent ?? "";
@@ -4573,7 +4618,9 @@ class WidgetShare extends WidgetBase {
4573
4618
  }
4574
4619
  static api = {
4575
4620
  widgetClassName: WidgetShare.widgetClassName,
4621
+ /** @deprecated */
4576
4622
  refreshUserData: WidgetShare.refreshUserData,
4623
+ onRefreshUserData: WidgetShare.onRefreshUserData,
4577
4624
  init: function (element, layers, localData) {
4578
4625
  WidgetShare.initWidget(element, localData, (element, options) => new WidgetShare(element, { ...options, layers }));
4579
4626
  },
@@ -4704,9 +4751,9 @@ class WidgetTest extends WidgetBase {
4704
4751
  }
4705
4752
  }
4706
4753
  }
4707
- // this.refreshUserData(this.options.localData);
4754
+ // this.onRefreshUserData(this.options.localData);
4708
4755
  }
4709
- refreshUserData(localData) { }
4756
+ onRefreshUserData(localData) { }
4710
4757
  _statEventVoteAnswer(answerScore) {
4711
4758
  try {
4712
4759
  if (this.selectedAnswer != null) {
@@ -4826,7 +4873,9 @@ class WidgetTest extends WidgetBase {
4826
4873
  }
4827
4874
  static api = {
4828
4875
  widgetClassName: WidgetTest.widgetClassName,
4876
+ /** @deprecated */
4829
4877
  refreshUserData: WidgetTest.refreshUserData,
4878
+ onRefreshUserData: WidgetTest.onRefreshUserData,
4830
4879
  init: function (element, localData) {
4831
4880
  WidgetTest.initWidget(element, localData, (element, options) => new WidgetTest(element, options));
4832
4881
  },
@@ -4903,7 +4952,7 @@ class WidgetVote extends WidgetBase {
4903
4952
  });
4904
4953
  this.hideClientTotalResult = getValueOrDefault(Boolean(getTagDataAsNumber(this.element, "hideClientTotalResult")), false);
4905
4954
  this.multipleChoice = getValueOrDefault(Boolean(getTagDataAsNumber(this.element, "multipleChoice")), false);
4906
- this.refreshUserData(this.options.localData);
4955
+ this.onRefreshUserData(this.options.localData);
4907
4956
  }
4908
4957
  _initFromLocalData() {
4909
4958
  const value = this.localData["_v_g_" + this.elementId + "_sa"];
@@ -4938,7 +4987,7 @@ class WidgetVote extends WidgetBase {
4938
4987
  this._fillWidget(true);
4939
4988
  }
4940
4989
  }
4941
- refreshUserData(localData) {
4990
+ onRefreshUserData(localData) {
4942
4991
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
4943
4992
  this.localData = extend({}, this.savedData ?? {}, localData);
4944
4993
  this.selectedVariant = undefined;
@@ -5268,7 +5317,9 @@ class WidgetVote extends WidgetBase {
5268
5317
  }
5269
5318
  static api = {
5270
5319
  widgetClassName: WidgetVote.widgetClassName,
5320
+ /** @deprecated */
5271
5321
  refreshUserData: WidgetVote.refreshUserData,
5322
+ onRefreshUserData: WidgetVote.onRefreshUserData,
5272
5323
  init: function (element, localData) {
5273
5324
  WidgetVote.initWidget(element, localData, (element, options) => new WidgetVote(element, options));
5274
5325
  },
@@ -14731,9 +14782,9 @@ class WidgetBarcode extends WidgetBase {
14731
14782
  this.renderCodeView();
14732
14783
  this.renderCaptionView();
14733
14784
  }
14734
- // this.refreshUserData(this.options.localData);
14785
+ // this.onRefreshUserData(this.options.localData);
14735
14786
  }
14736
- refreshUserData(localData) { }
14787
+ onRefreshUserData(localData) { }
14737
14788
  isTransparentElement() {
14738
14789
  if (this.element) {
14739
14790
  try {
@@ -14939,7 +14990,9 @@ class WidgetBarcode extends WidgetBase {
14939
14990
  }
14940
14991
  static api = {
14941
14992
  widgetClassName: WidgetBarcode.widgetClassName,
14993
+ /** @deprecated */
14942
14994
  refreshUserData: WidgetBarcode.refreshUserData,
14995
+ onRefreshUserData: WidgetBarcode.onRefreshUserData,
14943
14996
  init: function (element, localData) {
14944
14997
  WidgetBarcode.initWidget(element, localData, (element, options) => new WidgetBarcode(element, options));
14945
14998
  },