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