@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.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 */:
@@ -1516,9 +1536,9 @@ class WidgetCopy extends WidgetBase {
1516
1536
  if (this.isPromotionalCode) {
1517
1537
  this.fetchPromoCode();
1518
1538
  }
1519
- // this.refreshUserData(this.options.localData);
1539
+ // this.onRefreshUserData(this.options.localData);
1520
1540
  }
1521
- refreshUserData(localData) { }
1541
+ onRefreshUserData(localData) { }
1522
1542
  isTransparentElement() {
1523
1543
  if (this.element) {
1524
1544
  try {
@@ -1660,7 +1680,9 @@ class WidgetCopy extends WidgetBase {
1660
1680
  }
1661
1681
  static api = {
1662
1682
  widgetClassName: WidgetCopy.widgetClassName,
1683
+ /** @deprecated */
1663
1684
  refreshUserData: WidgetCopy.refreshUserData,
1685
+ onRefreshUserData: WidgetCopy.onRefreshUserData,
1664
1686
  init: function (element, localData) {
1665
1687
  // prevent initWidget for result layer
1666
1688
  if (!element.classList.contains("narrative-element-copy-result-variant")) {
@@ -1721,9 +1743,9 @@ class WidgetDataInput extends WidgetBase {
1721
1743
  this.inputElement = getValueOrException(this.element.querySelector(".input-view .input"), "Empty .input-view .input");
1722
1744
  this.textElement = getValueOrException(this.inputElement.querySelector(".narrative-element-text-lines"), "Empty .narrative-element-text-lines");
1723
1745
  this.inputPlaceholderValue = this.textElement.innerHTML;
1724
- this.refreshUserData(this.options.localData);
1746
+ this.onRefreshUserData(this.options.localData);
1725
1747
  }
1726
- refreshUserData(localData) {
1748
+ onRefreshUserData(localData) {
1727
1749
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
1728
1750
  this.localData = extend({}, this.savedData ?? {}, localData);
1729
1751
  const text = this.localData["_di_g_" + this.elementId + "_t"];
@@ -1854,7 +1876,9 @@ class WidgetDataInput extends WidgetBase {
1854
1876
  }
1855
1877
  static api = {
1856
1878
  widgetClassName: WidgetDataInput.widgetClassName,
1879
+ /** @deprecated */
1857
1880
  refreshUserData: WidgetDataInput.refreshUserData,
1881
+ onRefreshUserData: WidgetDataInput.onRefreshUserData,
1858
1882
  init: function (element, localData) {
1859
1883
  WidgetDataInput.initWidget(element, localData, (element, options) => new WidgetDataInput(element, options));
1860
1884
  },
@@ -1944,9 +1968,9 @@ class WidgetDateCountdown extends WidgetBase {
1944
1968
  // } else {
1945
1969
  this.initTimer();
1946
1970
  // }
1947
- // this.refreshUserData(this.options.localData);
1971
+ // this.onRefreshUserData(this.options.localData);
1948
1972
  }
1949
- refreshUserData(localData) { }
1973
+ onRefreshUserData(localData) { }
1950
1974
  pause() {
1951
1975
  if (this.timerInited) {
1952
1976
  this.pendingUpdate = false;
@@ -2072,7 +2096,9 @@ class WidgetDateCountdown extends WidgetBase {
2072
2096
  }
2073
2097
  static api = {
2074
2098
  widgetClassName: WidgetDateCountdown.widgetClassName,
2099
+ /** @deprecated */
2075
2100
  refreshUserData: WidgetDateCountdown.refreshUserData,
2101
+ onRefreshUserData: WidgetDateCountdown.onRefreshUserData,
2076
2102
  init: function (element, layers, localData) {
2077
2103
  WidgetDateCountdown.initWidget(element, localData, (element, options) => new WidgetDateCountdown(element, { ...options, layers }));
2078
2104
  },
@@ -2281,9 +2307,9 @@ class WidgetPoll extends WidgetBase {
2281
2307
  this.getUseResponseOnFirstButton = Boolean(getTagDataAsNumber(this.element, "getUserResponseOnFirstButton"));
2282
2308
  this.getUseResponseOnSecondButton = Boolean(getTagDataAsNumber(this.element, "getUserResponseOnSecondButton"));
2283
2309
  this.showClientTotalResult = Boolean(getTagDataAsNumber(this.element, "showClientTotalResult"));
2284
- this.refreshUserData(this.options.localData);
2310
+ this.onRefreshUserData(this.options.localData);
2285
2311
  }
2286
- refreshUserData(localData) {
2312
+ onRefreshUserData(localData) {
2287
2313
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
2288
2314
  this.localData = extend({}, this.savedData ?? {}, localData);
2289
2315
  this.selectedVariant = undefined;
@@ -2713,7 +2739,9 @@ class WidgetPoll extends WidgetBase {
2713
2739
  }
2714
2740
  static api = {
2715
2741
  widgetClassName: WidgetPoll.widgetClassName,
2742
+ /** @deprecated */
2716
2743
  refreshUserData: WidgetPoll.refreshUserData,
2744
+ onRefreshUserData: WidgetPoll.onRefreshUserData,
2717
2745
  init: function (element, localData) {
2718
2746
  WidgetPoll.initWidget(element, localData, (element, options) => new WidgetPoll(element, options));
2719
2747
  },
@@ -2796,9 +2824,9 @@ class WidgetPollLayers extends WidgetBase {
2796
2824
  this._showLayout(this.layers, 0);
2797
2825
  }
2798
2826
  this.firstOpenTime = new Date().getTime();
2799
- this.refreshUserData(this.options.localData);
2827
+ this.onRefreshUserData(this.options.localData);
2800
2828
  }
2801
- refreshUserData(localData) { }
2829
+ onRefreshUserData(localData) { }
2802
2830
  _statEventPollVariant() {
2803
2831
  try {
2804
2832
  if (this.selectedVariant != null) {
@@ -2881,7 +2909,9 @@ class WidgetPollLayers extends WidgetBase {
2881
2909
  }
2882
2910
  static api = {
2883
2911
  widgetClassName: WidgetPollLayers.widgetClassName,
2912
+ /** @deprecated */
2884
2913
  refreshUserData: WidgetPollLayers.refreshUserData,
2914
+ onRefreshUserData: WidgetPollLayers.onRefreshUserData,
2885
2915
  init: function (element, layers, localData) {
2886
2916
  WidgetPollLayers.initWidget(element, localData, (element, options) => new WidgetPollLayers(element, { ...options, layers }));
2887
2917
  },
@@ -2946,9 +2976,9 @@ class WidgetQuest extends WidgetBase {
2946
2976
  this.label = this.element.querySelector(".label-view .label");
2947
2977
  this.variants = slice.call(this.element.querySelectorAll(".variants-box .variant-view"));
2948
2978
  this.selectedAnswer = undefined;
2949
- // this.refreshUserData(this.options.localData);
2979
+ // this.onRefreshUserData(this.options.localData);
2950
2980
  }
2951
- refreshUserData(localData) { }
2981
+ onRefreshUserData(localData) { }
2952
2982
  setCardSessionValue(name, value) {
2953
2983
  this.sdkApi.setCardSessionValue(this.element, name, value);
2954
2984
  }
@@ -3172,7 +3202,9 @@ class WidgetQuest extends WidgetBase {
3172
3202
  }
3173
3203
  static api = {
3174
3204
  widgetClassName: WidgetQuest.widgetClassName,
3205
+ /** @deprecated */
3175
3206
  refreshUserData: WidgetQuest.refreshUserData,
3207
+ onRefreshUserData: WidgetQuest.onRefreshUserData,
3176
3208
  init: function (element, localData) {
3177
3209
  return new Promise(function (resolve, reject) {
3178
3210
  WidgetQuest.initWidget(element, localData, (element, options) => new WidgetQuest(element, options)).then(localData => {
@@ -3243,9 +3275,9 @@ class WidgetQuiz extends WidgetBase {
3243
3275
  this.question = this.element.querySelector(".label-view .label");
3244
3276
  this.answers = slice.call(this.element.querySelectorAll(".variants-box .variant-view-group"));
3245
3277
  this.questionCount = getValueOrException(getTagDataAsNumber(this.slide, "quizCount"), "Empty quizCount");
3246
- this.refreshUserData(this.options.localData);
3278
+ this.onRefreshUserData(this.options.localData);
3247
3279
  }
3248
- refreshUserData(localData) {
3280
+ onRefreshUserData(localData) {
3249
3281
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
3250
3282
  this.localData = extend({}, this.savedData ?? {}, localData);
3251
3283
  this.selectedAnswer = undefined;
@@ -3382,7 +3414,9 @@ class WidgetQuiz extends WidgetBase {
3382
3414
  }
3383
3415
  static api = {
3384
3416
  widgetClassName: WidgetQuiz.widgetClassName,
3417
+ /** @deprecated */
3385
3418
  refreshUserData: WidgetQuiz.refreshUserData,
3419
+ onRefreshUserData: WidgetQuiz.onRefreshUserData,
3386
3420
  init: function (element, localData) {
3387
3421
  WidgetQuiz.initWidget(element, localData, (element, options) => new WidgetQuiz(element, options));
3388
3422
  },
@@ -3436,9 +3470,9 @@ class WidgetQuizGrouped extends WidgetBase {
3436
3470
  this.question = this.element.querySelector(".label-view .label");
3437
3471
  this.answers = slice.call(this.element.querySelectorAll(".variants-box .variant-view-group"));
3438
3472
  this.questionCount = getValueOrException(getTagDataAsNumber(this.slide, "quizCount"), "Empty quizCount");
3439
- this.refreshUserData(this.options.localData);
3473
+ this.onRefreshUserData(this.options.localData);
3440
3474
  }
3441
- refreshUserData(localData) {
3475
+ onRefreshUserData(localData) {
3442
3476
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
3443
3477
  this.localData = extend({}, this.savedData ?? {}, localData);
3444
3478
  this.selectedAnswer = undefined;
@@ -3579,7 +3613,9 @@ class WidgetQuizGrouped extends WidgetBase {
3579
3613
  }
3580
3614
  static api = {
3581
3615
  widgetClassName: WidgetQuizGrouped.widgetClassName,
3616
+ /** @deprecated */
3582
3617
  refreshUserData: WidgetQuizGrouped.refreshUserData,
3618
+ onRefreshUserData: WidgetQuizGrouped.onRefreshUserData,
3583
3619
  init: function (element, localData) {
3584
3620
  WidgetQuizGrouped.initWidget(element, localData, (element, options) => new WidgetQuizGrouped(element, options));
3585
3621
  },
@@ -3816,7 +3852,7 @@ class WidgetRangeSlider extends WidgetBase {
3816
3852
  this.handleDown = proxy(this.handleDown, this);
3817
3853
  this.handleMove = proxy(this.handleMove, this);
3818
3854
  this.handleEnd = proxy(this.handleEnd, this);
3819
- this.refreshUserData(this.options.localData);
3855
+ this.onRefreshUserData(this.options.localData);
3820
3856
  // Attach Events
3821
3857
  // window.addEventListener('resize.' + this.identifier, debounce(function() {
3822
3858
  // // Simulate resizeEnd event.
@@ -3827,7 +3863,7 @@ class WidgetRangeSlider extends WidgetBase {
3827
3863
  this.env.document.addEventListener("touchstart", this.handleDown);
3828
3864
  this.env.document.addEventListener("mousedown", this.handleDown);
3829
3865
  }
3830
- refreshUserData(localData) {
3866
+ onRefreshUserData(localData) {
3831
3867
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
3832
3868
  this.localData = extend({}, this.savedData ?? {}, localData);
3833
3869
  if (this.localData["_rs_g_" + this.elementId + "_v"] !== undefined) {
@@ -4191,7 +4227,9 @@ class WidgetRangeSlider extends WidgetBase {
4191
4227
  }
4192
4228
  static api = {
4193
4229
  widgetClassName: WidgetRangeSlider.widgetClassName,
4230
+ /** @deprecated */
4194
4231
  refreshUserData: WidgetRangeSlider.refreshUserData,
4232
+ onRefreshUserData: WidgetRangeSlider.onRefreshUserData,
4195
4233
  init: function (element, localData) {
4196
4234
  WidgetRangeSlider.initWidget(element, localData, (element, options) => new WidgetRangeSlider(element, options));
4197
4235
  },
@@ -4253,9 +4291,9 @@ class WidgetRate extends WidgetBase {
4253
4291
  this.showDialogOnLowRate = Boolean(getValueOrDefault(getTagDataAsNumber(this.element, "showDialogOnLowRate"), 0));
4254
4292
  this.showDialogueMin = getValueOrDefault(getTagDataAsNumber(this.element, "showDialogueMin"), 1);
4255
4293
  this.showDialogueMax = getValueOrDefault(getTagDataAsNumber(this.element, "showDialogueMax"), 3);
4256
- this.refreshUserData(this.options.localData);
4294
+ this.onRefreshUserData(this.options.localData);
4257
4295
  }
4258
- refreshUserData(localData) {
4296
+ onRefreshUserData(localData) {
4259
4297
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
4260
4298
  this.localData = extend({}, this.savedData ?? {}, localData);
4261
4299
  this.selectedStar = undefined;
@@ -4442,7 +4480,9 @@ class WidgetRate extends WidgetBase {
4442
4480
  }
4443
4481
  static api = {
4444
4482
  widgetClassName: WidgetRate.widgetClassName,
4483
+ /** @deprecated */
4445
4484
  refreshUserData: WidgetRate.refreshUserData,
4485
+ onRefreshUserData: WidgetRate.onRefreshUserData,
4446
4486
  init: function (element, localData) {
4447
4487
  WidgetRate.initWidget(element, localData, (element, options) => new WidgetRate(element, options));
4448
4488
  },
@@ -4506,9 +4546,9 @@ class WidgetShare extends WidgetBase {
4506
4546
  this.startDisabledTimeline();
4507
4547
  }
4508
4548
  this.btnDisabled = false;
4509
- // this.refreshUserData(this.options.localData);
4549
+ // this.onRefreshUserData(this.options.localData);
4510
4550
  }
4511
- refreshUserData(localData) { }
4551
+ onRefreshUserData(localData) { }
4512
4552
  _statEventShare(result, via) {
4513
4553
  try {
4514
4554
  const buttonText = this.element.textContent ?? "";
@@ -4573,7 +4613,9 @@ class WidgetShare extends WidgetBase {
4573
4613
  }
4574
4614
  static api = {
4575
4615
  widgetClassName: WidgetShare.widgetClassName,
4616
+ /** @deprecated */
4576
4617
  refreshUserData: WidgetShare.refreshUserData,
4618
+ onRefreshUserData: WidgetShare.onRefreshUserData,
4577
4619
  init: function (element, layers, localData) {
4578
4620
  WidgetShare.initWidget(element, localData, (element, options) => new WidgetShare(element, { ...options, layers }));
4579
4621
  },
@@ -4704,9 +4746,9 @@ class WidgetTest extends WidgetBase {
4704
4746
  }
4705
4747
  }
4706
4748
  }
4707
- // this.refreshUserData(this.options.localData);
4749
+ // this.onRefreshUserData(this.options.localData);
4708
4750
  }
4709
- refreshUserData(localData) { }
4751
+ onRefreshUserData(localData) { }
4710
4752
  _statEventVoteAnswer(answerScore) {
4711
4753
  try {
4712
4754
  if (this.selectedAnswer != null) {
@@ -4826,7 +4868,9 @@ class WidgetTest extends WidgetBase {
4826
4868
  }
4827
4869
  static api = {
4828
4870
  widgetClassName: WidgetTest.widgetClassName,
4871
+ /** @deprecated */
4829
4872
  refreshUserData: WidgetTest.refreshUserData,
4873
+ onRefreshUserData: WidgetTest.onRefreshUserData,
4830
4874
  init: function (element, localData) {
4831
4875
  WidgetTest.initWidget(element, localData, (element, options) => new WidgetTest(element, options));
4832
4876
  },
@@ -4903,7 +4947,7 @@ class WidgetVote extends WidgetBase {
4903
4947
  });
4904
4948
  this.hideClientTotalResult = getValueOrDefault(Boolean(getTagDataAsNumber(this.element, "hideClientTotalResult")), false);
4905
4949
  this.multipleChoice = getValueOrDefault(Boolean(getTagDataAsNumber(this.element, "multipleChoice")), false);
4906
- this.refreshUserData(this.options.localData);
4950
+ this.onRefreshUserData(this.options.localData);
4907
4951
  }
4908
4952
  _initFromLocalData() {
4909
4953
  const value = this.localData["_v_g_" + this.elementId + "_sa"];
@@ -4938,7 +4982,7 @@ class WidgetVote extends WidgetBase {
4938
4982
  this._fillWidget(true);
4939
4983
  }
4940
4984
  }
4941
- refreshUserData(localData) {
4985
+ onRefreshUserData(localData) {
4942
4986
  this.savedData = this.sdkApi.getCardServerData(this.cardId);
4943
4987
  this.localData = extend({}, this.savedData ?? {}, localData);
4944
4988
  this.selectedVariant = undefined;
@@ -5268,7 +5312,9 @@ class WidgetVote extends WidgetBase {
5268
5312
  }
5269
5313
  static api = {
5270
5314
  widgetClassName: WidgetVote.widgetClassName,
5315
+ /** @deprecated */
5271
5316
  refreshUserData: WidgetVote.refreshUserData,
5317
+ onRefreshUserData: WidgetVote.onRefreshUserData,
5272
5318
  init: function (element, localData) {
5273
5319
  WidgetVote.initWidget(element, localData, (element, options) => new WidgetVote(element, options));
5274
5320
  },
@@ -14731,9 +14777,9 @@ class WidgetBarcode extends WidgetBase {
14731
14777
  this.renderCodeView();
14732
14778
  this.renderCaptionView();
14733
14779
  }
14734
- // this.refreshUserData(this.options.localData);
14780
+ // this.onRefreshUserData(this.options.localData);
14735
14781
  }
14736
- refreshUserData(localData) { }
14782
+ onRefreshUserData(localData) { }
14737
14783
  isTransparentElement() {
14738
14784
  if (this.element) {
14739
14785
  try {
@@ -14939,7 +14985,9 @@ class WidgetBarcode extends WidgetBase {
14939
14985
  }
14940
14986
  static api = {
14941
14987
  widgetClassName: WidgetBarcode.widgetClassName,
14988
+ /** @deprecated */
14942
14989
  refreshUserData: WidgetBarcode.refreshUserData,
14990
+ onRefreshUserData: WidgetBarcode.onRefreshUserData,
14943
14991
  init: function (element, localData) {
14944
14992
  WidgetBarcode.initWidget(element, localData, (element, options) => new WidgetBarcode(element, options));
14945
14993
  },