@inappstory/slide-api 0.0.18 → 0.0.19

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.js CHANGED
@@ -1252,7 +1252,7 @@ class WidgetBase {
1252
1252
  this.id = `w_${this.elementId}_${WidgetBase.widgetIndex}`;
1253
1253
  ++WidgetBase.widgetIndex;
1254
1254
  }
1255
- refreshUserData(localData) { }
1255
+ onRefreshUserData(localData) { }
1256
1256
  static widgetCacheKey = "ias.story-element";
1257
1257
  static widgetClassName = "";
1258
1258
  static getInstance(element) {
@@ -1431,13 +1431,14 @@ class WidgetBase {
1431
1431
  console.error(error);
1432
1432
  }
1433
1433
  }
1434
+ /** @deprecated */
1434
1435
  static refreshUserData(nodes, localData) {
1435
1436
  const cb = (el, localData) => {
1436
1437
  const widgetElement = el.closest(`.${this.widgetClassName}`);
1437
1438
  if (widgetElement) {
1438
1439
  const widget = WidgetBase.getInstance(widgetElement);
1439
1440
  if (widget) {
1440
- widget.refreshUserData(localData);
1441
+ widget.onRefreshUserData(localData);
1441
1442
  }
1442
1443
  }
1443
1444
  };
@@ -1452,6 +1453,25 @@ class WidgetBase {
1452
1453
  });
1453
1454
  }
1454
1455
  }
1456
+ static onRefreshUserData(element, localData) {
1457
+ const cb = (el, localData) => {
1458
+ const widgetElement = el.closest(`.${this.widgetClassName}`);
1459
+ if (widgetElement) {
1460
+ const widget = WidgetBase.getInstance(widgetElement);
1461
+ if (widget) {
1462
+ widget.onRefreshUserData(localData);
1463
+ }
1464
+ }
1465
+ };
1466
+ if (localData != null) {
1467
+ cb(element, localData);
1468
+ }
1469
+ else {
1470
+ WidgetBase.getLocalData().then(localData => {
1471
+ cb(element, localData);
1472
+ });
1473
+ }
1474
+ }
1455
1475
  getPromotionalCodeFetchPath(promotionalCodeId) {
1456
1476
  switch (this.cardType) {
1457
1477
  case 4 /* CARD_TYPE.IN_APP_MESSAGING */:
@@ -1514,9 +1534,9 @@ class WidgetCopy extends WidgetBase {
1514
1534
  if (this.isPromotionalCode) {
1515
1535
  this.fetchPromoCode();
1516
1536
  }
1517
- // this.refreshUserData(this.options.localData);
1537
+ // this.onRefreshUserData(this.options.localData);
1518
1538
  }
1519
- refreshUserData(localData) { }
1539
+ onRefreshUserData(localData) { }
1520
1540
  isTransparentElement() {
1521
1541
  if (this.element) {
1522
1542
  try {
@@ -1658,7 +1678,9 @@ class WidgetCopy extends WidgetBase {
1658
1678
  }
1659
1679
  static api = {
1660
1680
  widgetClassName: WidgetCopy.widgetClassName,
1681
+ /** @deprecated */
1661
1682
  refreshUserData: WidgetCopy.refreshUserData,
1683
+ onRefreshUserData: WidgetCopy.onRefreshUserData,
1662
1684
  init: function (element, localData) {
1663
1685
  // prevent initWidget for result layer
1664
1686
  if (!element.classList.contains("narrative-element-copy-result-variant")) {
@@ -1719,9 +1741,9 @@ class WidgetDataInput extends WidgetBase {
1719
1741
  this.inputElement = getValueOrException(this.element.querySelector(".input-view .input"), "Empty .input-view .input");
1720
1742
  this.textElement = getValueOrException(this.inputElement.querySelector(".narrative-element-text-lines"), "Empty .narrative-element-text-lines");
1721
1743
  this.inputPlaceholderValue = this.textElement.innerHTML;
1722
- this.refreshUserData(this.options.localData);
1744
+ this.onRefreshUserData(this.options.localData);
1723
1745
  }
1724
- refreshUserData(localData) {
1746
+ onRefreshUserData(localData) {
1725
1747
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
1726
1748
  this.localData = extend({}, this.savedData ?? {}, localData);
1727
1749
  const text = this.localData["_di_g_" + this.elementId + "_t"];
@@ -1852,7 +1874,9 @@ class WidgetDataInput extends WidgetBase {
1852
1874
  }
1853
1875
  static api = {
1854
1876
  widgetClassName: WidgetDataInput.widgetClassName,
1877
+ /** @deprecated */
1855
1878
  refreshUserData: WidgetDataInput.refreshUserData,
1879
+ onRefreshUserData: WidgetDataInput.onRefreshUserData,
1856
1880
  init: function (element, localData) {
1857
1881
  WidgetDataInput.initWidget(element, localData, (element, options) => new WidgetDataInput(element, options));
1858
1882
  },
@@ -1942,9 +1966,9 @@ class WidgetDateCountdown extends WidgetBase {
1942
1966
  // } else {
1943
1967
  this.initTimer();
1944
1968
  // }
1945
- // this.refreshUserData(this.options.localData);
1969
+ // this.onRefreshUserData(this.options.localData);
1946
1970
  }
1947
- refreshUserData(localData) { }
1971
+ onRefreshUserData(localData) { }
1948
1972
  pause() {
1949
1973
  if (this.timerInited) {
1950
1974
  this.pendingUpdate = false;
@@ -2070,7 +2094,9 @@ class WidgetDateCountdown extends WidgetBase {
2070
2094
  }
2071
2095
  static api = {
2072
2096
  widgetClassName: WidgetDateCountdown.widgetClassName,
2097
+ /** @deprecated */
2073
2098
  refreshUserData: WidgetDateCountdown.refreshUserData,
2099
+ onRefreshUserData: WidgetDateCountdown.onRefreshUserData,
2074
2100
  init: function (element, layers, localData) {
2075
2101
  WidgetDateCountdown.initWidget(element, localData, (element, options) => new WidgetDateCountdown(element, { ...options, layers }));
2076
2102
  },
@@ -2279,9 +2305,9 @@ class WidgetPoll extends WidgetBase {
2279
2305
  this.getUseResponseOnFirstButton = Boolean(getTagDataAsNumber(this.element, "getUserResponseOnFirstButton"));
2280
2306
  this.getUseResponseOnSecondButton = Boolean(getTagDataAsNumber(this.element, "getUserResponseOnSecondButton"));
2281
2307
  this.showClientTotalResult = Boolean(getTagDataAsNumber(this.element, "showClientTotalResult"));
2282
- this.refreshUserData(this.options.localData);
2308
+ this.onRefreshUserData(this.options.localData);
2283
2309
  }
2284
- refreshUserData(localData) {
2310
+ onRefreshUserData(localData) {
2285
2311
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
2286
2312
  this.localData = extend({}, this.savedData ?? {}, localData);
2287
2313
  this.selectedVariant = undefined;
@@ -2711,7 +2737,9 @@ class WidgetPoll extends WidgetBase {
2711
2737
  }
2712
2738
  static api = {
2713
2739
  widgetClassName: WidgetPoll.widgetClassName,
2740
+ /** @deprecated */
2714
2741
  refreshUserData: WidgetPoll.refreshUserData,
2742
+ onRefreshUserData: WidgetPoll.onRefreshUserData,
2715
2743
  init: function (element, localData) {
2716
2744
  WidgetPoll.initWidget(element, localData, (element, options) => new WidgetPoll(element, options));
2717
2745
  },
@@ -2794,9 +2822,9 @@ class WidgetPollLayers extends WidgetBase {
2794
2822
  this._showLayout(this.layers, 0);
2795
2823
  }
2796
2824
  this.firstOpenTime = new Date().getTime();
2797
- this.refreshUserData(this.options.localData);
2825
+ this.onRefreshUserData(this.options.localData);
2798
2826
  }
2799
- refreshUserData(localData) { }
2827
+ onRefreshUserData(localData) { }
2800
2828
  _statEventPollVariant() {
2801
2829
  try {
2802
2830
  if (this.selectedVariant != null) {
@@ -2879,7 +2907,9 @@ class WidgetPollLayers extends WidgetBase {
2879
2907
  }
2880
2908
  static api = {
2881
2909
  widgetClassName: WidgetPollLayers.widgetClassName,
2910
+ /** @deprecated */
2882
2911
  refreshUserData: WidgetPollLayers.refreshUserData,
2912
+ onRefreshUserData: WidgetPollLayers.onRefreshUserData,
2883
2913
  init: function (element, layers, localData) {
2884
2914
  WidgetPollLayers.initWidget(element, localData, (element, options) => new WidgetPollLayers(element, { ...options, layers }));
2885
2915
  },
@@ -2944,9 +2974,9 @@ class WidgetQuest extends WidgetBase {
2944
2974
  this.label = this.element.querySelector(".label-view .label");
2945
2975
  this.variants = slice.call(this.element.querySelectorAll(".variants-box .variant-view"));
2946
2976
  this.selectedAnswer = undefined;
2947
- // this.refreshUserData(this.options.localData);
2977
+ // this.onRefreshUserData(this.options.localData);
2948
2978
  }
2949
- refreshUserData(localData) { }
2979
+ onRefreshUserData(localData) { }
2950
2980
  setCardSessionValue(name, value) {
2951
2981
  this.sdkApi.setCardSessionValue(this.element, name, value);
2952
2982
  }
@@ -3170,7 +3200,9 @@ class WidgetQuest extends WidgetBase {
3170
3200
  }
3171
3201
  static api = {
3172
3202
  widgetClassName: WidgetQuest.widgetClassName,
3203
+ /** @deprecated */
3173
3204
  refreshUserData: WidgetQuest.refreshUserData,
3205
+ onRefreshUserData: WidgetQuest.onRefreshUserData,
3174
3206
  init: function (element, localData) {
3175
3207
  return new Promise(function (resolve, reject) {
3176
3208
  WidgetQuest.initWidget(element, localData, (element, options) => new WidgetQuest(element, options)).then(localData => {
@@ -3241,9 +3273,9 @@ class WidgetQuiz extends WidgetBase {
3241
3273
  this.question = this.element.querySelector(".label-view .label");
3242
3274
  this.answers = slice.call(this.element.querySelectorAll(".variants-box .variant-view-group"));
3243
3275
  this.questionCount = getValueOrException(getTagDataAsNumber(this.slide, "quizCount"), "Empty quizCount");
3244
- this.refreshUserData(this.options.localData);
3276
+ this.onRefreshUserData(this.options.localData);
3245
3277
  }
3246
- refreshUserData(localData) {
3278
+ onRefreshUserData(localData) {
3247
3279
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
3248
3280
  this.localData = extend({}, this.savedData ?? {}, localData);
3249
3281
  this.selectedAnswer = undefined;
@@ -3380,7 +3412,9 @@ class WidgetQuiz extends WidgetBase {
3380
3412
  }
3381
3413
  static api = {
3382
3414
  widgetClassName: WidgetQuiz.widgetClassName,
3415
+ /** @deprecated */
3383
3416
  refreshUserData: WidgetQuiz.refreshUserData,
3417
+ onRefreshUserData: WidgetQuiz.onRefreshUserData,
3384
3418
  init: function (element, localData) {
3385
3419
  WidgetQuiz.initWidget(element, localData, (element, options) => new WidgetQuiz(element, options));
3386
3420
  },
@@ -3434,9 +3468,9 @@ class WidgetQuizGrouped extends WidgetBase {
3434
3468
  this.question = this.element.querySelector(".label-view .label");
3435
3469
  this.answers = slice.call(this.element.querySelectorAll(".variants-box .variant-view-group"));
3436
3470
  this.questionCount = getValueOrException(getTagDataAsNumber(this.slide, "quizCount"), "Empty quizCount");
3437
- this.refreshUserData(this.options.localData);
3471
+ this.onRefreshUserData(this.options.localData);
3438
3472
  }
3439
- refreshUserData(localData) {
3473
+ onRefreshUserData(localData) {
3440
3474
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
3441
3475
  this.localData = extend({}, this.savedData ?? {}, localData);
3442
3476
  this.selectedAnswer = undefined;
@@ -3577,7 +3611,9 @@ class WidgetQuizGrouped extends WidgetBase {
3577
3611
  }
3578
3612
  static api = {
3579
3613
  widgetClassName: WidgetQuizGrouped.widgetClassName,
3614
+ /** @deprecated */
3580
3615
  refreshUserData: WidgetQuizGrouped.refreshUserData,
3616
+ onRefreshUserData: WidgetQuizGrouped.onRefreshUserData,
3581
3617
  init: function (element, localData) {
3582
3618
  WidgetQuizGrouped.initWidget(element, localData, (element, options) => new WidgetQuizGrouped(element, options));
3583
3619
  },
@@ -3814,7 +3850,7 @@ class WidgetRangeSlider extends WidgetBase {
3814
3850
  this.handleDown = proxy(this.handleDown, this);
3815
3851
  this.handleMove = proxy(this.handleMove, this);
3816
3852
  this.handleEnd = proxy(this.handleEnd, this);
3817
- this.refreshUserData(this.options.localData);
3853
+ this.onRefreshUserData(this.options.localData);
3818
3854
  // Attach Events
3819
3855
  // window.addEventListener('resize.' + this.identifier, debounce(function() {
3820
3856
  // // Simulate resizeEnd event.
@@ -3825,7 +3861,7 @@ class WidgetRangeSlider extends WidgetBase {
3825
3861
  this.env.document.addEventListener("touchstart", this.handleDown);
3826
3862
  this.env.document.addEventListener("mousedown", this.handleDown);
3827
3863
  }
3828
- refreshUserData(localData) {
3864
+ onRefreshUserData(localData) {
3829
3865
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
3830
3866
  this.localData = extend({}, this.savedData ?? {}, localData);
3831
3867
  if (this.localData["_rs_g_" + this.elementId + "_v"] !== undefined) {
@@ -4189,7 +4225,9 @@ class WidgetRangeSlider extends WidgetBase {
4189
4225
  }
4190
4226
  static api = {
4191
4227
  widgetClassName: WidgetRangeSlider.widgetClassName,
4228
+ /** @deprecated */
4192
4229
  refreshUserData: WidgetRangeSlider.refreshUserData,
4230
+ onRefreshUserData: WidgetRangeSlider.onRefreshUserData,
4193
4231
  init: function (element, localData) {
4194
4232
  WidgetRangeSlider.initWidget(element, localData, (element, options) => new WidgetRangeSlider(element, options));
4195
4233
  },
@@ -4251,9 +4289,9 @@ class WidgetRate extends WidgetBase {
4251
4289
  this.showDialogOnLowRate = Boolean(getValueOrDefault(getTagDataAsNumber(this.element, "showDialogOnLowRate"), 0));
4252
4290
  this.showDialogueMin = getValueOrDefault(getTagDataAsNumber(this.element, "showDialogueMin"), 1);
4253
4291
  this.showDialogueMax = getValueOrDefault(getTagDataAsNumber(this.element, "showDialogueMax"), 3);
4254
- this.refreshUserData(this.options.localData);
4292
+ this.onRefreshUserData(this.options.localData);
4255
4293
  }
4256
- refreshUserData(localData) {
4294
+ onRefreshUserData(localData) {
4257
4295
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
4258
4296
  this.localData = extend({}, this.savedData ?? {}, localData);
4259
4297
  this.selectedStar = undefined;
@@ -4440,7 +4478,9 @@ class WidgetRate extends WidgetBase {
4440
4478
  }
4441
4479
  static api = {
4442
4480
  widgetClassName: WidgetRate.widgetClassName,
4481
+ /** @deprecated */
4443
4482
  refreshUserData: WidgetRate.refreshUserData,
4483
+ onRefreshUserData: WidgetRate.onRefreshUserData,
4444
4484
  init: function (element, localData) {
4445
4485
  WidgetRate.initWidget(element, localData, (element, options) => new WidgetRate(element, options));
4446
4486
  },
@@ -4504,9 +4544,9 @@ class WidgetShare extends WidgetBase {
4504
4544
  this.startDisabledTimeline();
4505
4545
  }
4506
4546
  this.btnDisabled = false;
4507
- // this.refreshUserData(this.options.localData);
4547
+ // this.onRefreshUserData(this.options.localData);
4508
4548
  }
4509
- refreshUserData(localData) { }
4549
+ onRefreshUserData(localData) { }
4510
4550
  _statEventShare(result, via) {
4511
4551
  try {
4512
4552
  const buttonText = this.element.textContent ?? "";
@@ -4571,7 +4611,9 @@ class WidgetShare extends WidgetBase {
4571
4611
  }
4572
4612
  static api = {
4573
4613
  widgetClassName: WidgetShare.widgetClassName,
4614
+ /** @deprecated */
4574
4615
  refreshUserData: WidgetShare.refreshUserData,
4616
+ onRefreshUserData: WidgetShare.onRefreshUserData,
4575
4617
  init: function (element, layers, localData) {
4576
4618
  WidgetShare.initWidget(element, localData, (element, options) => new WidgetShare(element, { ...options, layers }));
4577
4619
  },
@@ -4702,9 +4744,9 @@ class WidgetTest extends WidgetBase {
4702
4744
  }
4703
4745
  }
4704
4746
  }
4705
- // this.refreshUserData(this.options.localData);
4747
+ // this.onRefreshUserData(this.options.localData);
4706
4748
  }
4707
- refreshUserData(localData) { }
4749
+ onRefreshUserData(localData) { }
4708
4750
  _statEventVoteAnswer(answerScore) {
4709
4751
  try {
4710
4752
  if (this.selectedAnswer != null) {
@@ -4824,7 +4866,9 @@ class WidgetTest extends WidgetBase {
4824
4866
  }
4825
4867
  static api = {
4826
4868
  widgetClassName: WidgetTest.widgetClassName,
4869
+ /** @deprecated */
4827
4870
  refreshUserData: WidgetTest.refreshUserData,
4871
+ onRefreshUserData: WidgetTest.onRefreshUserData,
4828
4872
  init: function (element, localData) {
4829
4873
  WidgetTest.initWidget(element, localData, (element, options) => new WidgetTest(element, options));
4830
4874
  },
@@ -4901,7 +4945,7 @@ class WidgetVote extends WidgetBase {
4901
4945
  });
4902
4946
  this.hideClientTotalResult = getValueOrDefault(Boolean(getTagDataAsNumber(this.element, "hideClientTotalResult")), false);
4903
4947
  this.multipleChoice = getValueOrDefault(Boolean(getTagDataAsNumber(this.element, "multipleChoice")), false);
4904
- this.refreshUserData(this.options.localData);
4948
+ this.onRefreshUserData(this.options.localData);
4905
4949
  }
4906
4950
  _initFromLocalData() {
4907
4951
  const value = this.localData["_v_g_" + this.elementId + "_sa"];
@@ -4936,7 +4980,7 @@ class WidgetVote extends WidgetBase {
4936
4980
  this._fillWidget(true);
4937
4981
  }
4938
4982
  }
4939
- refreshUserData(localData) {
4983
+ onRefreshUserData(localData) {
4940
4984
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
4941
4985
  this.localData = extend({}, this.savedData ?? {}, localData);
4942
4986
  this.selectedVariant = undefined;
@@ -5266,7 +5310,9 @@ class WidgetVote extends WidgetBase {
5266
5310
  }
5267
5311
  static api = {
5268
5312
  widgetClassName: WidgetVote.widgetClassName,
5313
+ /** @deprecated */
5269
5314
  refreshUserData: WidgetVote.refreshUserData,
5315
+ onRefreshUserData: WidgetVote.onRefreshUserData,
5270
5316
  init: function (element, localData) {
5271
5317
  WidgetVote.initWidget(element, localData, (element, options) => new WidgetVote(element, options));
5272
5318
  },
@@ -14729,9 +14775,9 @@ class WidgetBarcode extends WidgetBase {
14729
14775
  this.renderCodeView();
14730
14776
  this.renderCaptionView();
14731
14777
  }
14732
- // this.refreshUserData(this.options.localData);
14778
+ // this.onRefreshUserData(this.options.localData);
14733
14779
  }
14734
- refreshUserData(localData) { }
14780
+ onRefreshUserData(localData) { }
14735
14781
  isTransparentElement() {
14736
14782
  if (this.element) {
14737
14783
  try {
@@ -14937,7 +14983,9 @@ class WidgetBarcode extends WidgetBase {
14937
14983
  }
14938
14984
  static api = {
14939
14985
  widgetClassName: WidgetBarcode.widgetClassName,
14986
+ /** @deprecated */
14940
14987
  refreshUserData: WidgetBarcode.refreshUserData,
14988
+ onRefreshUserData: WidgetBarcode.onRefreshUserData,
14941
14989
  init: function (element, localData) {
14942
14990
  WidgetBarcode.initWidget(element, localData, (element, options) => new WidgetBarcode(element, options));
14943
14991
  },