@inappstory/slide-api 0.1.29 → 0.1.31
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 +241 -156
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -6
- package/dist/index.d.ts +23 -6
- package/dist/index.js +241 -156
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2654,7 +2654,9 @@ class Image extends ClickableBase {
|
|
|
2654
2654
|
this._layer = _layer;
|
|
2655
2655
|
const mediaElements = Array.from(this._elementNodeRef.querySelectorAll("img"));
|
|
2656
2656
|
this.mediaElementsLoadingPromises = mediaElements.map(waitForImageHtmlElementLoad);
|
|
2657
|
+
this._animatedImageVideoElement = this._elementNodeRef.querySelector("video");
|
|
2657
2658
|
}
|
|
2659
|
+
_animatedImageVideoElement;
|
|
2658
2660
|
mediaElementsLoadingPromises = [];
|
|
2659
2661
|
get nodeRef() {
|
|
2660
2662
|
return this._elementNodeRef;
|
|
@@ -2662,8 +2664,12 @@ class Image extends ClickableBase {
|
|
|
2662
2664
|
init(localData) {
|
|
2663
2665
|
return Promise.resolve(true);
|
|
2664
2666
|
}
|
|
2665
|
-
onPause() {
|
|
2666
|
-
|
|
2667
|
+
onPause() {
|
|
2668
|
+
this._animatedImageVideoElement?.pause();
|
|
2669
|
+
}
|
|
2670
|
+
onResume() {
|
|
2671
|
+
this._animatedImageVideoElement?.play();
|
|
2672
|
+
}
|
|
2667
2673
|
onStart() { }
|
|
2668
2674
|
onStop() { }
|
|
2669
2675
|
onBeforeUnmount() {
|
|
@@ -3300,6 +3306,7 @@ class VideoStateAdapter {
|
|
|
3300
3306
|
class Timer {
|
|
3301
3307
|
_elementNodeRef;
|
|
3302
3308
|
_layer;
|
|
3309
|
+
_layersNodesRefs;
|
|
3303
3310
|
_widgetApi;
|
|
3304
3311
|
_widgetCallbacks;
|
|
3305
3312
|
_widgetDeps;
|
|
@@ -3307,9 +3314,10 @@ class Timer {
|
|
|
3307
3314
|
static className() {
|
|
3308
3315
|
return Timer._className;
|
|
3309
3316
|
}
|
|
3310
|
-
constructor(_elementNodeRef, _layer, _widgetApi, _widgetCallbacks, _widgetDeps) {
|
|
3317
|
+
constructor(_elementNodeRef, _layer, _layersNodesRefs, _widgetApi, _widgetCallbacks, _widgetDeps) {
|
|
3311
3318
|
this._elementNodeRef = _elementNodeRef;
|
|
3312
3319
|
this._layer = _layer;
|
|
3320
|
+
this._layersNodesRefs = _layersNodesRefs;
|
|
3313
3321
|
this._widgetApi = _widgetApi;
|
|
3314
3322
|
this._widgetCallbacks = _widgetCallbacks;
|
|
3315
3323
|
this._widgetDeps = _widgetDeps;
|
|
@@ -3320,7 +3328,7 @@ class Timer {
|
|
|
3320
3328
|
}
|
|
3321
3329
|
init(localData) {
|
|
3322
3330
|
try {
|
|
3323
|
-
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
3331
|
+
this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData, this._widgetCallbacks, this._widgetDeps);
|
|
3324
3332
|
}
|
|
3325
3333
|
catch (e) {
|
|
3326
3334
|
console.error(e);
|
|
@@ -3344,7 +3352,7 @@ class Timer {
|
|
|
3344
3352
|
get isLayerForcePaused() {
|
|
3345
3353
|
return false;
|
|
3346
3354
|
}
|
|
3347
|
-
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetTimer.api`, `WidgetCallbacks`, `WidgetDeps`]; }
|
|
3355
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `Array`, `typeof WidgetTimer.api`, `WidgetCallbacks`, `WidgetDeps`]; }
|
|
3348
3356
|
}
|
|
3349
3357
|
|
|
3350
3358
|
// export const tryCreateAtLayer = (layerNodeRef: HTMLElement): IElement {
|
|
@@ -3408,7 +3416,7 @@ const tryCreateFromHtmlElement = (nodeRef, layer, widgetCallbacks, widgetDeps) =
|
|
|
3408
3416
|
case Tooltip.className():
|
|
3409
3417
|
return layoutApi.widgetTooltipApi ? new Tooltip(nodeRef, layer, layoutApi.widgetTooltipApi, widgetCallbacks, widgetDeps) : null;
|
|
3410
3418
|
case Timer.className():
|
|
3411
|
-
return layoutApi.widgetTimerApi ? new Timer(nodeRef, layer, layoutApi.widgetTimerApi, widgetCallbacks, widgetDeps) : null;
|
|
3419
|
+
return layoutApi.widgetTimerApi ? new Timer(nodeRef, layer, layersNodesRefs, layoutApi.widgetTimerApi, widgetCallbacks, widgetDeps) : null;
|
|
3412
3420
|
}
|
|
3413
3421
|
}
|
|
3414
3422
|
return null;
|
|
@@ -5166,6 +5174,16 @@ let SlideApi$1 = class SlideApi {
|
|
|
5166
5174
|
}
|
|
5167
5175
|
}
|
|
5168
5176
|
/** rate */
|
|
5177
|
+
if (target?.classList.contains("narrative-element-rate-next-button")) {
|
|
5178
|
+
element = target;
|
|
5179
|
+
}
|
|
5180
|
+
else {
|
|
5181
|
+
element = target?.closest(".narrative-element-rate-next-button");
|
|
5182
|
+
}
|
|
5183
|
+
if (element) {
|
|
5184
|
+
result.canClickNext = false;
|
|
5185
|
+
return result;
|
|
5186
|
+
}
|
|
5169
5187
|
if (target?.classList.contains("narrative-element-rate-input")) {
|
|
5170
5188
|
element = target;
|
|
5171
5189
|
}
|
|
@@ -6206,6 +6224,10 @@ class Slider {
|
|
|
6206
6224
|
bullets.appendChild(bullet);
|
|
6207
6225
|
}
|
|
6208
6226
|
}
|
|
6227
|
+
else {
|
|
6228
|
+
// additionally hide bullets container for single slide
|
|
6229
|
+
bullets.classList.add("hidden");
|
|
6230
|
+
}
|
|
6209
6231
|
// const onUpdateActiveIndex = (activeIndex: number) => {
|
|
6210
6232
|
// if (activeIndex >= 0 && activeIndex < count) {
|
|
6211
6233
|
// for (const bullet of bullets.querySelectorAll(".cards-slider__bullet--active")) {
|
|
@@ -7345,6 +7367,7 @@ var TimerCompletionAction;
|
|
|
7345
7367
|
TimerCompletionAction["ChangeText"] = "changeText";
|
|
7346
7368
|
TimerCompletionAction["CloseCard"] = "closeCard";
|
|
7347
7369
|
TimerCompletionAction["NextSlide"] = "nextSlide";
|
|
7370
|
+
TimerCompletionAction["ShowLayer"] = "showLayer";
|
|
7348
7371
|
})(TimerCompletionAction || (TimerCompletionAction = {}));
|
|
7349
7372
|
const pulseDurationStep = 200;
|
|
7350
7373
|
const maxPulseDuration = 2000;
|
|
@@ -7610,6 +7633,7 @@ class WidgetTimer extends WidgetBase {
|
|
|
7610
7633
|
activateAfterCreate: false,
|
|
7611
7634
|
create: false,
|
|
7612
7635
|
localData: {},
|
|
7636
|
+
layers: [],
|
|
7613
7637
|
};
|
|
7614
7638
|
static widgetClassName = "narrative-element-timer";
|
|
7615
7639
|
model;
|
|
@@ -7620,6 +7644,7 @@ class WidgetTimer extends WidgetBase {
|
|
|
7620
7644
|
rafId;
|
|
7621
7645
|
effects = [];
|
|
7622
7646
|
abortController = new AbortController();
|
|
7647
|
+
layers;
|
|
7623
7648
|
constructor(element, options, widgetCallbacks, widgetDeps) {
|
|
7624
7649
|
super(element, options, widgetCallbacks, widgetDeps);
|
|
7625
7650
|
this.model = this.createTimerModel();
|
|
@@ -7627,9 +7652,7 @@ class WidgetTimer extends WidgetBase {
|
|
|
7627
7652
|
this.timerRenderer = new TimerRenderer();
|
|
7628
7653
|
this.timerGroup = this.mountTimerGroup(this.timerRenderer);
|
|
7629
7654
|
this.fillEffects();
|
|
7630
|
-
|
|
7631
|
-
this.update();
|
|
7632
|
-
}
|
|
7655
|
+
this.layers = this.options.layers;
|
|
7633
7656
|
}
|
|
7634
7657
|
isDone() {
|
|
7635
7658
|
const time = this.getCurrentTime();
|
|
@@ -7701,7 +7724,6 @@ class WidgetTimer extends WidgetBase {
|
|
|
7701
7724
|
super.onStop();
|
|
7702
7725
|
this.abortController.abort();
|
|
7703
7726
|
this.reset();
|
|
7704
|
-
this.showElement();
|
|
7705
7727
|
}
|
|
7706
7728
|
onPause() {
|
|
7707
7729
|
this.env.cancelAnimationFrame(this.rafId);
|
|
@@ -7723,6 +7745,7 @@ class WidgetTimer extends WidgetBase {
|
|
|
7723
7745
|
const { days, hours, minutes, seconds, remainingSeconds } = this.getCurrentTime();
|
|
7724
7746
|
this.timerRenderer.setTime({ days, hours, minutes, seconds });
|
|
7725
7747
|
this.resetEffects(remainingSeconds);
|
|
7748
|
+
this.showElement();
|
|
7726
7749
|
}
|
|
7727
7750
|
update() {
|
|
7728
7751
|
if (!this.timerInit)
|
|
@@ -7787,6 +7810,11 @@ class WidgetTimer extends WidgetBase {
|
|
|
7787
7810
|
case TimerCompletionAction.NextSlide:
|
|
7788
7811
|
this.widgetDeps.slideApiDeps.showNextSlide(0);
|
|
7789
7812
|
break;
|
|
7813
|
+
case TimerCompletionAction.ShowLayer: {
|
|
7814
|
+
if (this.layers[1] != null) {
|
|
7815
|
+
this._showLayer(this.layers, 1);
|
|
7816
|
+
}
|
|
7817
|
+
}
|
|
7790
7818
|
}
|
|
7791
7819
|
}
|
|
7792
7820
|
getMaxCardAnimationsDelay() {
|
|
@@ -7803,8 +7831,8 @@ class WidgetTimer extends WidgetBase {
|
|
|
7803
7831
|
static api = {
|
|
7804
7832
|
widgetClassName: WidgetTimer.widgetClassName,
|
|
7805
7833
|
onRefreshUserData: WidgetTimer.onRefreshUserData,
|
|
7806
|
-
init: function (element, localData, widgetCallbacks, widgetDeps) {
|
|
7807
|
-
WidgetTimer.initWidget(element, localData, (element, options) => new WidgetTimer(element, options, widgetCallbacks, widgetDeps));
|
|
7834
|
+
init: function (element, layers, localData, widgetCallbacks, widgetDeps) {
|
|
7835
|
+
WidgetTimer.initWidget(element, localData, (element, options) => new WidgetTimer(element, { ...options, layers }, widgetCallbacks, widgetDeps));
|
|
7808
7836
|
},
|
|
7809
7837
|
onStart: function (element) {
|
|
7810
7838
|
WidgetTimer.getInstance(element)?.onStart();
|
|
@@ -22442,6 +22470,18 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
22442
22470
|
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `WidgetCallbacks`, `WidgetDeps`]; }
|
|
22443
22471
|
}
|
|
22444
22472
|
|
|
22473
|
+
var RateCompletionAction;
|
|
22474
|
+
(function (RateCompletionAction) {
|
|
22475
|
+
RateCompletionAction[RateCompletionAction["Default"] = 0] = "Default";
|
|
22476
|
+
RateCompletionAction[RateCompletionAction["ShowDialog"] = 1] = "ShowDialog";
|
|
22477
|
+
RateCompletionAction[RateCompletionAction["SubmitToAppStores"] = 2] = "SubmitToAppStores";
|
|
22478
|
+
})(RateCompletionAction || (RateCompletionAction = {}));
|
|
22479
|
+
class NoStarSelectedError extends Error {
|
|
22480
|
+
constructor() {
|
|
22481
|
+
super("[Rate Widget] No star selected");
|
|
22482
|
+
}
|
|
22483
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return []; }
|
|
22484
|
+
}
|
|
22445
22485
|
class WidgetRate extends WidgetBase {
|
|
22446
22486
|
static DEFAULTS = {
|
|
22447
22487
|
slide: null,
|
|
@@ -22456,16 +22496,18 @@ class WidgetRate extends WidgetBase {
|
|
|
22456
22496
|
submitToStores;
|
|
22457
22497
|
submitToStoresMin;
|
|
22458
22498
|
submitToStoresMax;
|
|
22499
|
+
hasSubmitButton;
|
|
22459
22500
|
showDialogOnLowRate;
|
|
22460
22501
|
showDialogueMin;
|
|
22461
22502
|
showDialogueMax;
|
|
22462
|
-
selectedStar;
|
|
22503
|
+
selectedStar = null;
|
|
22463
22504
|
answerSelectDuration;
|
|
22464
22505
|
elementRect;
|
|
22465
22506
|
constructor(element, options, widgetCallbacks, widgetDeps) {
|
|
22466
22507
|
super(element, options, widgetCallbacks, widgetDeps);
|
|
22467
22508
|
this.label = this.element.querySelector(".label-view .label");
|
|
22468
22509
|
this.stars = slice.call(this.element.querySelectorAll(".input-view"));
|
|
22510
|
+
this.hasSubmitButton = Boolean(this.element.querySelector(".submit-button-view"));
|
|
22469
22511
|
this.submitToStores = Boolean(getValueOrDefault(getTagDataAsNumber(this.element, "submitToStores"), 0));
|
|
22470
22512
|
this.submitToStoresMin = getValueOrDefault(getTagDataAsNumber(this.element, "submitToStoresMin"), 4);
|
|
22471
22513
|
this.submitToStoresMax = getValueOrDefault(getTagDataAsNumber(this.element, "submitToStoresMax"), 5);
|
|
@@ -22473,176 +22515,199 @@ class WidgetRate extends WidgetBase {
|
|
|
22473
22515
|
this.showDialogueMin = getValueOrDefault(getTagDataAsNumber(this.element, "showDialogueMin"), 1);
|
|
22474
22516
|
this.showDialogueMax = getValueOrDefault(getTagDataAsNumber(this.element, "showDialogueMax"), 3);
|
|
22475
22517
|
}
|
|
22518
|
+
onStart() {
|
|
22519
|
+
super.onStart();
|
|
22520
|
+
this.submitButtonAnimatedView?.addEventListener("click", this.handleSubmit);
|
|
22521
|
+
}
|
|
22522
|
+
onStop() {
|
|
22523
|
+
this.submitButtonAnimatedView?.removeEventListener("click", this.handleSubmit);
|
|
22524
|
+
}
|
|
22476
22525
|
/**
|
|
22477
22526
|
* Start or restart widget
|
|
22478
22527
|
* @param localData
|
|
22479
22528
|
*/
|
|
22480
22529
|
onRefreshUserData(localData) {
|
|
22481
22530
|
super.onRefreshUserData(localData);
|
|
22482
|
-
this.
|
|
22483
|
-
|
|
22484
|
-
|
|
22485
|
-
|
|
22486
|
-
|
|
22487
|
-
|
|
22488
|
-
this._clearSelectedStar();
|
|
22489
|
-
}
|
|
22531
|
+
this.resetState();
|
|
22532
|
+
const savedStar = this.localData["_r_g_" + this.elementId + "_ss"];
|
|
22533
|
+
if (savedStar != null) {
|
|
22534
|
+
this.selectedStar = savedStar;
|
|
22535
|
+
this.fillStars(savedStar);
|
|
22536
|
+
this.markWidgetCompleted(savedStar);
|
|
22490
22537
|
}
|
|
22491
|
-
this.firstOpenTime = new Date().getTime();
|
|
22492
|
-
this.answerSelectDuration = 0;
|
|
22493
|
-
this.nativeDialogueWasOpened = false;
|
|
22494
22538
|
}
|
|
22495
|
-
|
|
22539
|
+
sendStatistic(answerText) {
|
|
22540
|
+
if (this.selectedStar == null)
|
|
22541
|
+
throw new NoStarSelectedError();
|
|
22496
22542
|
try {
|
|
22497
22543
|
const labelText = this.label?.textContent ?? "";
|
|
22498
|
-
|
|
22499
|
-
|
|
22500
|
-
this.
|
|
22501
|
-
|
|
22502
|
-
|
|
22503
|
-
|
|
22504
|
-
|
|
22505
|
-
|
|
22506
|
-
|
|
22507
|
-
|
|
22508
|
-
|
|
22509
|
-
|
|
22510
|
-
|
|
22511
|
-
|
|
22512
|
-
|
|
22513
|
-
|
|
22514
|
-
});
|
|
22515
|
-
}
|
|
22544
|
+
const selectedAnswer = this.selectedStar + 1;
|
|
22545
|
+
this.sendStatisticEventToApp("w-rate-answer", {
|
|
22546
|
+
...this.statisticEventBaseFieldsShortForm,
|
|
22547
|
+
wi: this.elementId,
|
|
22548
|
+
wl: labelText,
|
|
22549
|
+
wa: selectedAnswer,
|
|
22550
|
+
wv: answerText,
|
|
22551
|
+
d: this.answerSelectDuration,
|
|
22552
|
+
}, {
|
|
22553
|
+
...this.statisticEventBaseFieldsFullForm,
|
|
22554
|
+
widget_id: this.elementId,
|
|
22555
|
+
widget_label: labelText,
|
|
22556
|
+
widget_answer: selectedAnswer,
|
|
22557
|
+
widget_value: answerText,
|
|
22558
|
+
duration_ms: this.answerSelectDuration,
|
|
22559
|
+
});
|
|
22516
22560
|
}
|
|
22517
22561
|
catch (error) {
|
|
22518
22562
|
console.error(error);
|
|
22519
22563
|
}
|
|
22520
22564
|
}
|
|
22521
|
-
|
|
22522
|
-
|
|
22523
|
-
|
|
22524
|
-
|
|
22525
|
-
|
|
22565
|
+
resetState() {
|
|
22566
|
+
this.selectedStar = null;
|
|
22567
|
+
this.nativeDialogueWasOpened = false;
|
|
22568
|
+
this.answerSelectDuration = 0;
|
|
22569
|
+
this.firstOpenTime = Date.now();
|
|
22570
|
+
this.clearStars();
|
|
22571
|
+
this.hideSubmitButton();
|
|
22572
|
+
}
|
|
22573
|
+
selectStar(starElement) {
|
|
22574
|
+
if ((this.selectedStar != null && !this.hasSubmitButton) || this.isDone())
|
|
22575
|
+
return true;
|
|
22576
|
+
const value = this.stars.indexOf(starElement);
|
|
22577
|
+
if (value === -1)
|
|
22578
|
+
return false;
|
|
22579
|
+
this.selectedStar = value;
|
|
22580
|
+
this.fillStars(value);
|
|
22581
|
+
if (this.hasSubmitButton) {
|
|
22582
|
+
this.showSubmitButton();
|
|
22526
22583
|
}
|
|
22527
|
-
|
|
22528
|
-
|
|
22529
|
-
if (key <= value) {
|
|
22530
|
-
element.classList.add("fill");
|
|
22531
|
-
}
|
|
22532
|
-
});
|
|
22533
|
-
if (list[value]) {
|
|
22534
|
-
list[value].classList.add("selected");
|
|
22584
|
+
else {
|
|
22585
|
+
this.handleSubmit();
|
|
22535
22586
|
}
|
|
22536
|
-
|
|
22537
|
-
|
|
22538
|
-
|
|
22587
|
+
return false;
|
|
22588
|
+
}
|
|
22589
|
+
completeWidget(value, userText = "") {
|
|
22590
|
+
this.markWidgetCompleted(value);
|
|
22591
|
+
this.showToast();
|
|
22592
|
+
this.saveLocalData();
|
|
22593
|
+
this.sendStatistic(userText);
|
|
22594
|
+
}
|
|
22595
|
+
saveLocalData() {
|
|
22596
|
+
const time = Math.round(new Date().getTime() / 1000);
|
|
22597
|
+
this.localData["_r_g_" + this.elementId + "_done_at"] = time;
|
|
22598
|
+
// ответ на вопрос
|
|
22599
|
+
this.localData["_&ts_r_g_" + this.elementId + "_a_at"] = time;
|
|
22600
|
+
this.setLocalData(this.localData, true);
|
|
22601
|
+
}
|
|
22602
|
+
markWidgetCompleted(value) {
|
|
22603
|
+
this.saveStarSelection(value);
|
|
22539
22604
|
this.startReadyPromise.then(() => {
|
|
22540
|
-
if (this.disableTimer
|
|
22605
|
+
if (this.disableTimer) {
|
|
22541
22606
|
this.onWidgetComplete();
|
|
22542
22607
|
}
|
|
22543
22608
|
});
|
|
22544
22609
|
}
|
|
22545
|
-
|
|
22546
|
-
|
|
22547
|
-
|
|
22548
|
-
element.classList.remove("selected");
|
|
22549
|
-
});
|
|
22550
|
-
this.element.classList.remove("done");
|
|
22610
|
+
saveStarSelection(value) {
|
|
22611
|
+
this.localData["_r_g_" + this.elementId + "_ss"] = value;
|
|
22612
|
+
this.element.classList.add("done");
|
|
22551
22613
|
}
|
|
22552
|
-
|
|
22553
|
-
|
|
22554
|
-
|
|
22555
|
-
|
|
22556
|
-
|
|
22557
|
-
|
|
22558
|
-
|
|
22559
|
-
|
|
22560
|
-
|
|
22561
|
-
|
|
22614
|
+
isDone() {
|
|
22615
|
+
return this.localData["_r_g_" + this.elementId + "_done_at"] !== undefined;
|
|
22616
|
+
}
|
|
22617
|
+
slideRateIsDone() {
|
|
22618
|
+
return this.localData["_r_g_" + this.elementId + "_sa"] !== undefined;
|
|
22619
|
+
}
|
|
22620
|
+
handleSubmit = () => {
|
|
22621
|
+
if (this.selectedStar == null)
|
|
22622
|
+
throw new NoStarSelectedError();
|
|
22623
|
+
const value = this.selectedStar;
|
|
22624
|
+
const action = this.getCompletionAction(value);
|
|
22562
22625
|
this.nativeDialogueWasOpened = false;
|
|
22563
|
-
|
|
22564
|
-
|
|
22565
|
-
|
|
22566
|
-
|
|
22567
|
-
|
|
22568
|
-
|
|
22569
|
-
|
|
22570
|
-
|
|
22571
|
-
|
|
22572
|
-
|
|
22573
|
-
|
|
22574
|
-
|
|
22575
|
-
|
|
22576
|
-
|
|
22577
|
-
|
|
22578
|
-
|
|
22579
|
-
|
|
22580
|
-
|
|
22581
|
-
|
|
22582
|
-
|
|
22583
|
-
|
|
22584
|
-
|
|
22585
|
-
|
|
22586
|
-
|
|
22587
|
-
|
|
22588
|
-
|
|
22589
|
-
|
|
22590
|
-
|
|
22591
|
-
|
|
22592
|
-
|
|
22593
|
-
|
|
22594
|
-
|
|
22595
|
-
|
|
22596
|
-
|
|
22597
|
-
|
|
22598
|
-
|
|
22599
|
-
|
|
22600
|
-
|
|
22601
|
-
|
|
22602
|
-
|
|
22603
|
-
|
|
22604
|
-
|
|
22605
|
-
|
|
22606
|
-
|
|
22626
|
+
this.answerSelectDuration = new Date().getTime() - this.firstOpenTime;
|
|
22627
|
+
switch (action) {
|
|
22628
|
+
case RateCompletionAction.ShowDialog:
|
|
22629
|
+
this.openUserDialog(value);
|
|
22630
|
+
break;
|
|
22631
|
+
case RateCompletionAction.SubmitToAppStores:
|
|
22632
|
+
this.submitToAppStores(value);
|
|
22633
|
+
break;
|
|
22634
|
+
default:
|
|
22635
|
+
this.completeWidget(value);
|
|
22636
|
+
}
|
|
22637
|
+
this.hideSubmitButton();
|
|
22638
|
+
};
|
|
22639
|
+
getCompletionAction(value) {
|
|
22640
|
+
if (value + 1 >= this.showDialogueMin && value + 1 <= this.showDialogueMax) {
|
|
22641
|
+
if (this.showDialogOnLowRate)
|
|
22642
|
+
return RateCompletionAction.ShowDialog;
|
|
22643
|
+
else
|
|
22644
|
+
RateCompletionAction.Default;
|
|
22645
|
+
}
|
|
22646
|
+
if (value + 1 >= this.submitToStoresMin && value + 1 <= this.submitToStoresMax)
|
|
22647
|
+
return RateCompletionAction.SubmitToAppStores;
|
|
22648
|
+
return RateCompletionAction.Default;
|
|
22649
|
+
}
|
|
22650
|
+
submitToAppStores(value) {
|
|
22651
|
+
let target = null;
|
|
22652
|
+
if (this.widgetDeps.slideApiDeps.isAndroid) {
|
|
22653
|
+
target = getTagData(this.element, "androidLink");
|
|
22654
|
+
}
|
|
22655
|
+
else if (this.widgetDeps.slideApiDeps.isIOS) {
|
|
22656
|
+
target = getTagData(this.element, "appleLink");
|
|
22657
|
+
}
|
|
22658
|
+
this.completeWidget(value);
|
|
22659
|
+
if (this.submitToStores && target) {
|
|
22660
|
+
this.widgetDeps.slideApiDeps.openUrl({ type: "link", link: { type: "url", target } });
|
|
22661
|
+
}
|
|
22662
|
+
}
|
|
22663
|
+
openUserDialog(value) {
|
|
22664
|
+
this.saveStarSelection(value);
|
|
22665
|
+
this.localData["_r_g_" + this.elementId + "_ss"] = value;
|
|
22666
|
+
this.element.classList.add("done");
|
|
22667
|
+
this.elementRect = this.element.getBoundingClientRect();
|
|
22668
|
+
if (this.widgetDeps.slideApiDeps.isAndroid) {
|
|
22669
|
+
this.slide.classList.add("blured");
|
|
22670
|
+
}
|
|
22671
|
+
this.slide.classList.add("data-input-editing");
|
|
22672
|
+
const dataString = this.element.dataset["clientdialogwidgetconfig"];
|
|
22673
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowCardTextInput && dataString) {
|
|
22674
|
+
const data = JSON.parse(dataString);
|
|
22675
|
+
data.size = getElementBounding(this.env, this.elementRect);
|
|
22676
|
+
if (!this.disableTimer) {
|
|
22677
|
+
this.onWidgetRequirePauseUI();
|
|
22607
22678
|
}
|
|
22608
|
-
|
|
22609
|
-
|
|
22610
|
-
|
|
22611
|
-
|
|
22612
|
-
|
|
22613
|
-
|
|
22614
|
-
|
|
22615
|
-
|
|
22616
|
-
|
|
22617
|
-
|
|
22618
|
-
|
|
22619
|
-
|
|
22620
|
-
this.widgetDeps.slideApiDeps.openUrl({ type: "link", link: { type: "url", target } });
|
|
22621
|
-
}
|
|
22679
|
+
this.nativeDialogueWasOpened = true;
|
|
22680
|
+
try {
|
|
22681
|
+
data.text.value = data.text.value.replaceAll("\\n", "\n").replaceAll("\\r", "\r").replaceAll("\\t", "\t");
|
|
22682
|
+
data.input.text.placeholder = data.input.text.placeholder.replaceAll("\\n", "\n").replaceAll("\\r", "\r").replaceAll("\\t", "\t");
|
|
22683
|
+
data.configV2.main.question.text.value = data.configV2.main.question.text.value
|
|
22684
|
+
.replaceAll("\\n", "\n")
|
|
22685
|
+
.replaceAll("\\r", "\r")
|
|
22686
|
+
.replaceAll("\\t", "\t");
|
|
22687
|
+
data.configV2.main.input.text.placeholder = data.configV2.main.input.text.placeholder
|
|
22688
|
+
.replaceAll("\\n", "\n")
|
|
22689
|
+
.replaceAll("\\r", "\r")
|
|
22690
|
+
.replaceAll("\\t", "\t");
|
|
22622
22691
|
}
|
|
22623
|
-
|
|
22624
|
-
|
|
22625
|
-
this.completeWidget();
|
|
22626
|
-
this._statEventRateUsAnswer("");
|
|
22692
|
+
catch (e) {
|
|
22693
|
+
console.error(e);
|
|
22627
22694
|
}
|
|
22695
|
+
this.widgetDeps.slideApiDeps.showCardTextInput(this.id, data);
|
|
22628
22696
|
}
|
|
22629
|
-
return false;
|
|
22630
22697
|
}
|
|
22631
|
-
|
|
22698
|
+
onUserDialogComplete(userText) {
|
|
22699
|
+
if (this.selectedStar == null)
|
|
22700
|
+
throw new NoStarSelectedError();
|
|
22632
22701
|
this.slide.classList.remove("data-input-editing");
|
|
22633
22702
|
this.slide.classList.remove("blured");
|
|
22634
|
-
if (this.selectedStar != null) {
|
|
22635
|
-
this._selectStar(this.selectedStar, true);
|
|
22636
|
-
}
|
|
22637
22703
|
if (!this.disableTimer && this.nativeDialogueWasOpened) {
|
|
22638
22704
|
this.onWidgetRequireResumeUI();
|
|
22639
22705
|
this.nativeDialogueWasOpened = false;
|
|
22640
22706
|
}
|
|
22641
|
-
this.localData["_r_g_" + this.elementId + "_user_response"] =
|
|
22642
|
-
this.completeWidget();
|
|
22643
|
-
this._statEventRateUsAnswer(text);
|
|
22707
|
+
this.localData["_r_g_" + this.elementId + "_user_response"] = userText;
|
|
22708
|
+
this.completeWidget(this.selectedStar, userText);
|
|
22644
22709
|
}
|
|
22645
|
-
|
|
22710
|
+
showToast() {
|
|
22646
22711
|
if (this.widgetDone) {
|
|
22647
22712
|
this.widgetDone.classList.add("active", "opacity-active");
|
|
22648
22713
|
setTimeout(() => {
|
|
@@ -22652,16 +22717,36 @@ class WidgetRate extends WidgetBase {
|
|
|
22652
22717
|
}, 250);
|
|
22653
22718
|
}, 2000);
|
|
22654
22719
|
}
|
|
22655
|
-
this.localData["_r_g_" + this.elementId + "_done_at"] = Math.round(new Date().getTime() / 1000);
|
|
22656
|
-
// ответ на вопрос
|
|
22657
|
-
this.localData["_&ts_r_g_" + this.elementId + "_a_at"] = Math.round(new Date().getTime() / 1000);
|
|
22658
|
-
this.setLocalData(this.localData, true);
|
|
22659
22720
|
}
|
|
22660
|
-
|
|
22661
|
-
|
|
22721
|
+
showSubmitButton() {
|
|
22722
|
+
this.env.requestAnimationFrame(() => {
|
|
22723
|
+
if (this.submitButtonAnimatedView != null) {
|
|
22724
|
+
this.submitButtonAnimatedView.style.maxHeight = `${this.submitButtonViewHeight}px`;
|
|
22725
|
+
}
|
|
22726
|
+
});
|
|
22662
22727
|
}
|
|
22663
|
-
|
|
22664
|
-
|
|
22728
|
+
hideSubmitButton() {
|
|
22729
|
+
this.env.requestAnimationFrame(() => {
|
|
22730
|
+
if (this.submitButtonAnimatedView != null) {
|
|
22731
|
+
this.submitButtonAnimatedView.style.maxHeight = "0px";
|
|
22732
|
+
}
|
|
22733
|
+
});
|
|
22734
|
+
}
|
|
22735
|
+
fillStars(value) {
|
|
22736
|
+
if (!this.stars[value])
|
|
22737
|
+
return;
|
|
22738
|
+
this.stars.forEach((star, index) => {
|
|
22739
|
+
star.classList.remove("fill", "selected");
|
|
22740
|
+
if (index <= value)
|
|
22741
|
+
star.classList.add("fill");
|
|
22742
|
+
});
|
|
22743
|
+
this.stars[value].classList.add("selected");
|
|
22744
|
+
}
|
|
22745
|
+
clearStars() {
|
|
22746
|
+
this.stars.forEach(star => {
|
|
22747
|
+
star.classList.remove("fill", "selected");
|
|
22748
|
+
});
|
|
22749
|
+
this.element.classList.remove("done");
|
|
22665
22750
|
}
|
|
22666
22751
|
static api = {
|
|
22667
22752
|
widgetClassName: WidgetRate.widgetClassName,
|
|
@@ -22693,7 +22778,7 @@ class WidgetRate extends WidgetBase {
|
|
|
22693
22778
|
return true;
|
|
22694
22779
|
},
|
|
22695
22780
|
setUserData: function (slideRoot, id, text) {
|
|
22696
|
-
WidgetRate.getInstanceById(slideRoot, id)?.
|
|
22781
|
+
WidgetRate.getInstanceById(slideRoot, id)?.onUserDialogComplete(text);
|
|
22697
22782
|
},
|
|
22698
22783
|
};
|
|
22699
22784
|
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `WidgetCallbacks`, `WidgetDeps`]; }
|