@inappstory/slide-api 0.0.24 → 0.0.26
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 +58 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +58 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3159,8 +3159,8 @@ class WidgetQuest extends WidgetBase {
|
|
|
3159
3159
|
init() {
|
|
3160
3160
|
if (this.localData) {
|
|
3161
3161
|
if (this.localData["_qt_g_" + this.elementId + "_sa"] !== undefined) ;
|
|
3162
|
-
if (this.localData["
|
|
3163
|
-
this.localData["
|
|
3162
|
+
if (this.localData["_qt_g_" + this.elementId + "fo_at"] === undefined) {
|
|
3163
|
+
this.localData["_qt_g_" + this.elementId + "fo_at"] = Math.round(new Date().getTime() / 1000);
|
|
3164
3164
|
this.setLocalData(this.localData, false);
|
|
3165
3165
|
}
|
|
3166
3166
|
let lastSlideIdx = this.localData["_qt_last_slide_idx"];
|
|
@@ -3478,8 +3478,8 @@ class WidgetQuiz extends WidgetBase {
|
|
|
3478
3478
|
else {
|
|
3479
3479
|
this._clearAnswerSelection();
|
|
3480
3480
|
}
|
|
3481
|
-
if (this.localData["
|
|
3482
|
-
this.localData["
|
|
3481
|
+
if (this.localData["_q_g_" + this.elementId + "fo_at"] === undefined) {
|
|
3482
|
+
this.localData["_q_g_" + this.elementId + "fo_at"] = Math.round(new Date().getTime() / 1000);
|
|
3483
3483
|
this.setLocalData(this.localData, false);
|
|
3484
3484
|
}
|
|
3485
3485
|
}
|
|
@@ -3685,8 +3685,8 @@ class WidgetQuizGrouped extends WidgetBase {
|
|
|
3685
3685
|
else {
|
|
3686
3686
|
this._clearAnswerSelection();
|
|
3687
3687
|
}
|
|
3688
|
-
if (this.localData["
|
|
3689
|
-
this.localData["
|
|
3688
|
+
if (this.localData["_qg_g_" + this.elementId + "fo_at"] === undefined) {
|
|
3689
|
+
this.localData["_qg_g_" + this.elementId + "fo_at"] = Math.round(new Date().getTime() / 1000);
|
|
3690
3690
|
this.setLocalData(this.localData, false);
|
|
3691
3691
|
}
|
|
3692
3692
|
}
|
|
@@ -4068,8 +4068,14 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
4068
4068
|
// _this.update(false, false);
|
|
4069
4069
|
// }, 300);
|
|
4070
4070
|
// }, 20));
|
|
4071
|
-
|
|
4072
|
-
|
|
4071
|
+
}
|
|
4072
|
+
isTouchListenersInit = false;
|
|
4073
|
+
initTouchListeners() {
|
|
4074
|
+
if (!this.isTouchListenersInit) {
|
|
4075
|
+
this.env.document.addEventListener("touchstart", this.handleDown);
|
|
4076
|
+
this.env.document.addEventListener("mousedown", this.handleDown);
|
|
4077
|
+
this.isTouchListenersInit = true;
|
|
4078
|
+
}
|
|
4073
4079
|
}
|
|
4074
4080
|
/**
|
|
4075
4081
|
* Start or restart widget
|
|
@@ -4094,6 +4100,10 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
4094
4100
|
}
|
|
4095
4101
|
this.init();
|
|
4096
4102
|
}
|
|
4103
|
+
onStart() {
|
|
4104
|
+
super.onStart();
|
|
4105
|
+
this.initTouchListeners();
|
|
4106
|
+
}
|
|
4097
4107
|
onStop() {
|
|
4098
4108
|
super.onStop();
|
|
4099
4109
|
this.destroy();
|
|
@@ -4435,6 +4445,11 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
4435
4445
|
destroy() {
|
|
4436
4446
|
this.env.document.removeEventListener("touchstart", this.handleDown);
|
|
4437
4447
|
this.env.document.removeEventListener("mousedown", this.handleDown);
|
|
4448
|
+
this.env.document.removeEventListener("touchmove", this.handleMove);
|
|
4449
|
+
this.env.document.removeEventListener("touchend", this.handleEnd);
|
|
4450
|
+
this.env.document.removeEventListener("mousemove", this.handleMove);
|
|
4451
|
+
this.env.document.removeEventListener("mouseup", this.handleEnd);
|
|
4452
|
+
this.isTouchListenersInit = false;
|
|
4438
4453
|
// off resize event
|
|
4439
4454
|
// this.$window.off('.' + this.identifier);
|
|
4440
4455
|
// this.$element
|
|
@@ -4449,11 +4464,11 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
4449
4464
|
onRefreshUserData: WidgetRangeSlider.onRefreshUserData,
|
|
4450
4465
|
init: function (element, localData) {
|
|
4451
4466
|
WidgetRangeSlider.initWidget(element, localData, (element, options) => new WidgetRangeSlider(element, options));
|
|
4452
|
-
WidgetRangeSlider.getInstance(element)?.onStart();
|
|
4453
4467
|
},
|
|
4454
4468
|
/** @deprecated */
|
|
4455
4469
|
initWidget: function (element, localData) {
|
|
4456
4470
|
WidgetRangeSlider.initWidgets((element, options) => new WidgetRangeSlider(element, options), [element], localData);
|
|
4471
|
+
WidgetRangeSlider.getInstance(element)?.onStart();
|
|
4457
4472
|
},
|
|
4458
4473
|
onStart: function (element) {
|
|
4459
4474
|
WidgetRangeSlider.getInstance(element)?.onStart();
|
|
@@ -4924,6 +4939,7 @@ class WidgetTest extends WidgetBase {
|
|
|
4924
4939
|
timeLeft;
|
|
4925
4940
|
timeLeftDefault;
|
|
4926
4941
|
timeline;
|
|
4942
|
+
isWidgetTimerInit = false;
|
|
4927
4943
|
constructor(element, options) {
|
|
4928
4944
|
super(element, options);
|
|
4929
4945
|
this.label = this.element.querySelector(".label-view .label");
|
|
@@ -4931,6 +4947,7 @@ class WidgetTest extends WidgetBase {
|
|
|
4931
4947
|
this.testCount = getValueOrException(getTagDataAsNumber(this.slide, "testCount"), "Empty testCount");
|
|
4932
4948
|
this.withTimeToAnswer = Boolean(getValueOrDefault(getTagDataAsNumber(this.element, "withTimeToAnswer"), 0));
|
|
4933
4949
|
this.answerTimeout = getValueOrDefault(getTagDataAsNumber(this.element, "answerTimeout"), 0);
|
|
4950
|
+
this.timeline = this.element.querySelector(".timeline");
|
|
4934
4951
|
this.tick = () => {
|
|
4935
4952
|
this.animationFrameId = this.env.requestAnimationFrame(() => {
|
|
4936
4953
|
this.tick();
|
|
@@ -4938,12 +4955,8 @@ class WidgetTest extends WidgetBase {
|
|
|
4938
4955
|
// update timer
|
|
4939
4956
|
// update timeline position
|
|
4940
4957
|
if (this.startTimerAt) {
|
|
4941
|
-
// if (this.state.timeLeft - this.timeLeft >= 950) {
|
|
4942
|
-
// this.setState({timeLeft: this.timeLeft});
|
|
4943
|
-
// }
|
|
4944
4958
|
const timeNow = new Date().getTime();
|
|
4945
|
-
this.timeLeft
|
|
4946
|
-
this.startTimerAt = timeNow;
|
|
4959
|
+
this.timeLeft = this.startTimerAt + this.timeLeftDefault - timeNow;
|
|
4947
4960
|
if (this.timeLeft <= 0) {
|
|
4948
4961
|
this.timeLeft = 0;
|
|
4949
4962
|
this.cancelTick();
|
|
@@ -4972,15 +4985,19 @@ class WidgetTest extends WidgetBase {
|
|
|
4972
4985
|
this._selectAnswer(this.localData["_t_g_" + this.elementId + "_sa"]);
|
|
4973
4986
|
this.setLocalData(this.localData, false);
|
|
4974
4987
|
}
|
|
4975
|
-
if (this.localData["
|
|
4976
|
-
this.localData["
|
|
4988
|
+
if (this.localData["_t_g_" + this.elementId + "fo_at"] === undefined) {
|
|
4989
|
+
this.localData["_t_g_" + this.elementId + "fo_at"] = Math.round(new Date().getTime() / 1000);
|
|
4977
4990
|
this.setLocalData(this.localData, false);
|
|
4978
4991
|
}
|
|
4979
4992
|
}
|
|
4980
4993
|
this.firstOpenTime = new Date().getTime();
|
|
4981
4994
|
if (this.slideTestWithTimer()) {
|
|
4982
4995
|
this.cancelTick();
|
|
4983
|
-
this.
|
|
4996
|
+
this.initWidgetTimer();
|
|
4997
|
+
}
|
|
4998
|
+
}
|
|
4999
|
+
initWidgetTimer() {
|
|
5000
|
+
if (!this.isWidgetTimerInit) {
|
|
4984
5001
|
if (this.selectedAnswer === undefined) {
|
|
4985
5002
|
// find timer element
|
|
4986
5003
|
// start raf
|
|
@@ -4988,13 +5005,18 @@ class WidgetTest extends WidgetBase {
|
|
|
4988
5005
|
this.timeLeftDefault = (this.answerTimeout ? this.answerTimeout : 0) * 1000;
|
|
4989
5006
|
this.timeLeft = this.timeLeftDefault;
|
|
4990
5007
|
this.animationFrameId = null;
|
|
4991
|
-
this.startTimerAt = new Date().getTime();
|
|
4992
5008
|
this.startReadyPromise.then(() => {
|
|
5009
|
+
if (this.localData["_t_g_" + this.elementId + "st_at"] != null) {
|
|
5010
|
+
this.startTimerAt = this.localData["_t_g_" + this.elementId + "st_at"];
|
|
5011
|
+
this.startTimerAt *= 1000;
|
|
5012
|
+
}
|
|
5013
|
+
if (this.startTimerAt == null) {
|
|
5014
|
+
this.startTimerAt = new Date().getTime();
|
|
5015
|
+
this.localData["_t_g_" + this.elementId + "st_at"] = Math.round(this.startTimerAt / 1000);
|
|
5016
|
+
this.setLocalData(this.localData, false);
|
|
5017
|
+
}
|
|
4993
5018
|
this.tick();
|
|
4994
5019
|
});
|
|
4995
|
-
// set answer - unanswered (for close and run again)
|
|
4996
|
-
this.localData["_t_g_" + this.elementId + "_sa"] = -1;
|
|
4997
|
-
this.setLocalData(this.localData, true);
|
|
4998
5020
|
}
|
|
4999
5021
|
else {
|
|
5000
5022
|
// animate 100%
|
|
@@ -5009,16 +5031,21 @@ class WidgetTest extends WidgetBase {
|
|
|
5009
5031
|
}
|
|
5010
5032
|
}
|
|
5011
5033
|
}
|
|
5034
|
+
this.isWidgetTimerInit = true;
|
|
5012
5035
|
}
|
|
5013
5036
|
}
|
|
5014
5037
|
onStart() {
|
|
5015
5038
|
super.onStart();
|
|
5039
|
+
if (this.slideTestWithTimer()) {
|
|
5040
|
+
this.initWidgetTimer();
|
|
5041
|
+
}
|
|
5016
5042
|
}
|
|
5017
5043
|
onStop() {
|
|
5018
5044
|
super.onStop();
|
|
5019
5045
|
if (this.slideTestWithTimer()) {
|
|
5020
5046
|
this.cancelTick();
|
|
5021
5047
|
}
|
|
5048
|
+
this.isWidgetTimerInit = false;
|
|
5022
5049
|
}
|
|
5023
5050
|
_statEventVoteAnswer(answerScore) {
|
|
5024
5051
|
try {
|
|
@@ -5235,7 +5262,7 @@ class WidgetVote extends WidgetBase {
|
|
|
5235
5262
|
if (Array.isArray(value)) {
|
|
5236
5263
|
index = value[0];
|
|
5237
5264
|
}
|
|
5238
|
-
this.
|
|
5265
|
+
this.variants[index]?.classList.add("checked");
|
|
5239
5266
|
this._selectVariant(index, true);
|
|
5240
5267
|
if (!this.hideClientTotalResult) {
|
|
5241
5268
|
this.displayPercents([index], true);
|
|
@@ -5252,7 +5279,7 @@ class WidgetVote extends WidgetBase {
|
|
|
5252
5279
|
}
|
|
5253
5280
|
for (let i = 0; i < values.length; ++i) {
|
|
5254
5281
|
const index = values[i];
|
|
5255
|
-
this.
|
|
5282
|
+
this.variants[index]?.classList.add("checked");
|
|
5256
5283
|
this._selectVariant(index, true);
|
|
5257
5284
|
}
|
|
5258
5285
|
if (!this.hideClientTotalResult) {
|
|
@@ -16007,7 +16034,7 @@ class WidgetProducts extends WidgetBase {
|
|
|
16007
16034
|
...this.statisticEventBaseFieldsShortForm,
|
|
16008
16035
|
wi: this.elementId,
|
|
16009
16036
|
wl: captionViewText,
|
|
16010
|
-
wv: this.linkTarget,
|
|
16037
|
+
wv: JSON.stringify(this.linkTarget),
|
|
16011
16038
|
}, {
|
|
16012
16039
|
...this.statisticEventBaseFieldsShortForm,
|
|
16013
16040
|
widget_id: this.elementId,
|
|
@@ -16028,8 +16055,8 @@ class WidgetProducts extends WidgetBase {
|
|
|
16028
16055
|
...this.statisticEventBaseFieldsShortForm,
|
|
16029
16056
|
wi: this.elementId,
|
|
16030
16057
|
wl: captionViewText,
|
|
16031
|
-
wv: this.linkTarget,
|
|
16032
|
-
wit: offers.map(item => item.offerId),
|
|
16058
|
+
wv: JSON.stringify(this.linkTarget),
|
|
16059
|
+
wit: JSON.stringify(offers.map(item => item.offerId)),
|
|
16033
16060
|
}, {
|
|
16034
16061
|
...this.statisticEventBaseFieldsShortForm,
|
|
16035
16062
|
widget_id: this.elementId,
|
|
@@ -16246,14 +16273,15 @@ class WidgetProducts extends WidgetBase {
|
|
|
16246
16273
|
const figure = document.createElement("div");
|
|
16247
16274
|
figure.classList.add("ias-products-card-figure");
|
|
16248
16275
|
if (offer.coverUrl) {
|
|
16249
|
-
// todo preload coverImage by fetch, save to offer.coverUrl via createUrl (add revoke)
|
|
16250
|
-
// if cannot fetch - skip caching
|
|
16251
16276
|
const image = document.createElement("img");
|
|
16252
16277
|
image.classList.add("ias-products-card-figure-image");
|
|
16253
16278
|
image.alt = offer.name ?? "";
|
|
16254
16279
|
image.src = offer.coverUrl;
|
|
16255
16280
|
figure.appendChild(image);
|
|
16256
16281
|
}
|
|
16282
|
+
const imageMask = document.createElement("div");
|
|
16283
|
+
imageMask.classList.add("ias-products-card-figure-image-mask");
|
|
16284
|
+
figure.appendChild(imageMask);
|
|
16257
16285
|
// const subTitle = document.createElement("div");
|
|
16258
16286
|
// subTitle.classList.add("ias-products-card-subtitle");
|
|
16259
16287
|
// subTitle.innerText = offer.description ?? "";
|
|
@@ -16364,8 +16392,10 @@ class WidgetProducts extends WidgetBase {
|
|
|
16364
16392
|
e.stopPropagation();
|
|
16365
16393
|
onClose();
|
|
16366
16394
|
};
|
|
16395
|
+
const divider = document.createElement("div");
|
|
16367
16396
|
backgroundView.appendChild(scrollView);
|
|
16368
16397
|
backgroundView.appendChild(closeButton);
|
|
16398
|
+
backgroundView.appendChild(divider);
|
|
16369
16399
|
containerView.appendChild(backdropView);
|
|
16370
16400
|
containerView.appendChild(backgroundView);
|
|
16371
16401
|
return containerView;
|