@inappstory/slide-api 0.1.29 → 0.1.30
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 +237 -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 +237 -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
|
}
|
|
@@ -7345,6 +7363,7 @@ var TimerCompletionAction;
|
|
|
7345
7363
|
TimerCompletionAction["ChangeText"] = "changeText";
|
|
7346
7364
|
TimerCompletionAction["CloseCard"] = "closeCard";
|
|
7347
7365
|
TimerCompletionAction["NextSlide"] = "nextSlide";
|
|
7366
|
+
TimerCompletionAction["ShowLayer"] = "showLayer";
|
|
7348
7367
|
})(TimerCompletionAction || (TimerCompletionAction = {}));
|
|
7349
7368
|
const pulseDurationStep = 200;
|
|
7350
7369
|
const maxPulseDuration = 2000;
|
|
@@ -7610,6 +7629,7 @@ class WidgetTimer extends WidgetBase {
|
|
|
7610
7629
|
activateAfterCreate: false,
|
|
7611
7630
|
create: false,
|
|
7612
7631
|
localData: {},
|
|
7632
|
+
layers: [],
|
|
7613
7633
|
};
|
|
7614
7634
|
static widgetClassName = "narrative-element-timer";
|
|
7615
7635
|
model;
|
|
@@ -7620,6 +7640,7 @@ class WidgetTimer extends WidgetBase {
|
|
|
7620
7640
|
rafId;
|
|
7621
7641
|
effects = [];
|
|
7622
7642
|
abortController = new AbortController();
|
|
7643
|
+
layers;
|
|
7623
7644
|
constructor(element, options, widgetCallbacks, widgetDeps) {
|
|
7624
7645
|
super(element, options, widgetCallbacks, widgetDeps);
|
|
7625
7646
|
this.model = this.createTimerModel();
|
|
@@ -7627,9 +7648,7 @@ class WidgetTimer extends WidgetBase {
|
|
|
7627
7648
|
this.timerRenderer = new TimerRenderer();
|
|
7628
7649
|
this.timerGroup = this.mountTimerGroup(this.timerRenderer);
|
|
7629
7650
|
this.fillEffects();
|
|
7630
|
-
|
|
7631
|
-
this.update();
|
|
7632
|
-
}
|
|
7651
|
+
this.layers = this.options.layers;
|
|
7633
7652
|
}
|
|
7634
7653
|
isDone() {
|
|
7635
7654
|
const time = this.getCurrentTime();
|
|
@@ -7701,7 +7720,6 @@ class WidgetTimer extends WidgetBase {
|
|
|
7701
7720
|
super.onStop();
|
|
7702
7721
|
this.abortController.abort();
|
|
7703
7722
|
this.reset();
|
|
7704
|
-
this.showElement();
|
|
7705
7723
|
}
|
|
7706
7724
|
onPause() {
|
|
7707
7725
|
this.env.cancelAnimationFrame(this.rafId);
|
|
@@ -7723,6 +7741,7 @@ class WidgetTimer extends WidgetBase {
|
|
|
7723
7741
|
const { days, hours, minutes, seconds, remainingSeconds } = this.getCurrentTime();
|
|
7724
7742
|
this.timerRenderer.setTime({ days, hours, minutes, seconds });
|
|
7725
7743
|
this.resetEffects(remainingSeconds);
|
|
7744
|
+
this.showElement();
|
|
7726
7745
|
}
|
|
7727
7746
|
update() {
|
|
7728
7747
|
if (!this.timerInit)
|
|
@@ -7787,6 +7806,11 @@ class WidgetTimer extends WidgetBase {
|
|
|
7787
7806
|
case TimerCompletionAction.NextSlide:
|
|
7788
7807
|
this.widgetDeps.slideApiDeps.showNextSlide(0);
|
|
7789
7808
|
break;
|
|
7809
|
+
case TimerCompletionAction.ShowLayer: {
|
|
7810
|
+
if (this.layers[1] != null) {
|
|
7811
|
+
this._showLayer(this.layers, 1);
|
|
7812
|
+
}
|
|
7813
|
+
}
|
|
7790
7814
|
}
|
|
7791
7815
|
}
|
|
7792
7816
|
getMaxCardAnimationsDelay() {
|
|
@@ -7803,8 +7827,8 @@ class WidgetTimer extends WidgetBase {
|
|
|
7803
7827
|
static api = {
|
|
7804
7828
|
widgetClassName: WidgetTimer.widgetClassName,
|
|
7805
7829
|
onRefreshUserData: WidgetTimer.onRefreshUserData,
|
|
7806
|
-
init: function (element, localData, widgetCallbacks, widgetDeps) {
|
|
7807
|
-
WidgetTimer.initWidget(element, localData, (element, options) => new WidgetTimer(element, options, widgetCallbacks, widgetDeps));
|
|
7830
|
+
init: function (element, layers, localData, widgetCallbacks, widgetDeps) {
|
|
7831
|
+
WidgetTimer.initWidget(element, localData, (element, options) => new WidgetTimer(element, { ...options, layers }, widgetCallbacks, widgetDeps));
|
|
7808
7832
|
},
|
|
7809
7833
|
onStart: function (element) {
|
|
7810
7834
|
WidgetTimer.getInstance(element)?.onStart();
|
|
@@ -22442,6 +22466,18 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
22442
22466
|
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `WidgetCallbacks`, `WidgetDeps`]; }
|
|
22443
22467
|
}
|
|
22444
22468
|
|
|
22469
|
+
var RateCompletionAction;
|
|
22470
|
+
(function (RateCompletionAction) {
|
|
22471
|
+
RateCompletionAction[RateCompletionAction["Default"] = 0] = "Default";
|
|
22472
|
+
RateCompletionAction[RateCompletionAction["ShowDialog"] = 1] = "ShowDialog";
|
|
22473
|
+
RateCompletionAction[RateCompletionAction["SubmitToAppStores"] = 2] = "SubmitToAppStores";
|
|
22474
|
+
})(RateCompletionAction || (RateCompletionAction = {}));
|
|
22475
|
+
class NoStarSelectedError extends Error {
|
|
22476
|
+
constructor() {
|
|
22477
|
+
super("[Rate Widget] No star selected");
|
|
22478
|
+
}
|
|
22479
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return []; }
|
|
22480
|
+
}
|
|
22445
22481
|
class WidgetRate extends WidgetBase {
|
|
22446
22482
|
static DEFAULTS = {
|
|
22447
22483
|
slide: null,
|
|
@@ -22456,16 +22492,18 @@ class WidgetRate extends WidgetBase {
|
|
|
22456
22492
|
submitToStores;
|
|
22457
22493
|
submitToStoresMin;
|
|
22458
22494
|
submitToStoresMax;
|
|
22495
|
+
hasSubmitButton;
|
|
22459
22496
|
showDialogOnLowRate;
|
|
22460
22497
|
showDialogueMin;
|
|
22461
22498
|
showDialogueMax;
|
|
22462
|
-
selectedStar;
|
|
22499
|
+
selectedStar = null;
|
|
22463
22500
|
answerSelectDuration;
|
|
22464
22501
|
elementRect;
|
|
22465
22502
|
constructor(element, options, widgetCallbacks, widgetDeps) {
|
|
22466
22503
|
super(element, options, widgetCallbacks, widgetDeps);
|
|
22467
22504
|
this.label = this.element.querySelector(".label-view .label");
|
|
22468
22505
|
this.stars = slice.call(this.element.querySelectorAll(".input-view"));
|
|
22506
|
+
this.hasSubmitButton = Boolean(this.element.querySelector(".submit-button-view"));
|
|
22469
22507
|
this.submitToStores = Boolean(getValueOrDefault(getTagDataAsNumber(this.element, "submitToStores"), 0));
|
|
22470
22508
|
this.submitToStoresMin = getValueOrDefault(getTagDataAsNumber(this.element, "submitToStoresMin"), 4);
|
|
22471
22509
|
this.submitToStoresMax = getValueOrDefault(getTagDataAsNumber(this.element, "submitToStoresMax"), 5);
|
|
@@ -22473,176 +22511,199 @@ class WidgetRate extends WidgetBase {
|
|
|
22473
22511
|
this.showDialogueMin = getValueOrDefault(getTagDataAsNumber(this.element, "showDialogueMin"), 1);
|
|
22474
22512
|
this.showDialogueMax = getValueOrDefault(getTagDataAsNumber(this.element, "showDialogueMax"), 3);
|
|
22475
22513
|
}
|
|
22514
|
+
onStart() {
|
|
22515
|
+
super.onStart();
|
|
22516
|
+
this.submitButtonAnimatedView?.addEventListener("click", this.handleSubmit);
|
|
22517
|
+
}
|
|
22518
|
+
onStop() {
|
|
22519
|
+
this.submitButtonAnimatedView?.removeEventListener("click", this.handleSubmit);
|
|
22520
|
+
}
|
|
22476
22521
|
/**
|
|
22477
22522
|
* Start or restart widget
|
|
22478
22523
|
* @param localData
|
|
22479
22524
|
*/
|
|
22480
22525
|
onRefreshUserData(localData) {
|
|
22481
22526
|
super.onRefreshUserData(localData);
|
|
22482
|
-
this.
|
|
22483
|
-
|
|
22484
|
-
|
|
22485
|
-
|
|
22486
|
-
|
|
22487
|
-
|
|
22488
|
-
this._clearSelectedStar();
|
|
22489
|
-
}
|
|
22527
|
+
this.resetState();
|
|
22528
|
+
const savedStar = this.localData["_r_g_" + this.elementId + "_ss"];
|
|
22529
|
+
if (savedStar != null) {
|
|
22530
|
+
this.selectedStar = savedStar;
|
|
22531
|
+
this.fillStars(savedStar);
|
|
22532
|
+
this.markWidgetCompleted(savedStar);
|
|
22490
22533
|
}
|
|
22491
|
-
this.firstOpenTime = new Date().getTime();
|
|
22492
|
-
this.answerSelectDuration = 0;
|
|
22493
|
-
this.nativeDialogueWasOpened = false;
|
|
22494
22534
|
}
|
|
22495
|
-
|
|
22535
|
+
sendStatistic(answerText) {
|
|
22536
|
+
if (this.selectedStar == null)
|
|
22537
|
+
throw new NoStarSelectedError();
|
|
22496
22538
|
try {
|
|
22497
22539
|
const labelText = this.label?.textContent ?? "";
|
|
22498
|
-
|
|
22499
|
-
|
|
22500
|
-
this.
|
|
22501
|
-
|
|
22502
|
-
|
|
22503
|
-
|
|
22504
|
-
|
|
22505
|
-
|
|
22506
|
-
|
|
22507
|
-
|
|
22508
|
-
|
|
22509
|
-
|
|
22510
|
-
|
|
22511
|
-
|
|
22512
|
-
|
|
22513
|
-
|
|
22514
|
-
});
|
|
22515
|
-
}
|
|
22540
|
+
const selectedAnswer = this.selectedStar + 1;
|
|
22541
|
+
this.sendStatisticEventToApp("w-rate-answer", {
|
|
22542
|
+
...this.statisticEventBaseFieldsShortForm,
|
|
22543
|
+
wi: this.elementId,
|
|
22544
|
+
wl: labelText,
|
|
22545
|
+
wa: selectedAnswer,
|
|
22546
|
+
wv: answerText,
|
|
22547
|
+
d: this.answerSelectDuration,
|
|
22548
|
+
}, {
|
|
22549
|
+
...this.statisticEventBaseFieldsFullForm,
|
|
22550
|
+
widget_id: this.elementId,
|
|
22551
|
+
widget_label: labelText,
|
|
22552
|
+
widget_answer: selectedAnswer,
|
|
22553
|
+
widget_value: answerText,
|
|
22554
|
+
duration_ms: this.answerSelectDuration,
|
|
22555
|
+
});
|
|
22516
22556
|
}
|
|
22517
22557
|
catch (error) {
|
|
22518
22558
|
console.error(error);
|
|
22519
22559
|
}
|
|
22520
22560
|
}
|
|
22521
|
-
|
|
22522
|
-
|
|
22523
|
-
|
|
22524
|
-
|
|
22525
|
-
|
|
22561
|
+
resetState() {
|
|
22562
|
+
this.selectedStar = null;
|
|
22563
|
+
this.nativeDialogueWasOpened = false;
|
|
22564
|
+
this.answerSelectDuration = 0;
|
|
22565
|
+
this.firstOpenTime = Date.now();
|
|
22566
|
+
this.clearStars();
|
|
22567
|
+
this.hideSubmitButton();
|
|
22568
|
+
}
|
|
22569
|
+
selectStar(starElement) {
|
|
22570
|
+
if ((this.selectedStar != null && !this.hasSubmitButton) || this.isDone())
|
|
22571
|
+
return true;
|
|
22572
|
+
const value = this.stars.indexOf(starElement);
|
|
22573
|
+
if (value === -1)
|
|
22574
|
+
return false;
|
|
22575
|
+
this.selectedStar = value;
|
|
22576
|
+
this.fillStars(value);
|
|
22577
|
+
if (this.hasSubmitButton) {
|
|
22578
|
+
this.showSubmitButton();
|
|
22526
22579
|
}
|
|
22527
|
-
|
|
22528
|
-
|
|
22529
|
-
if (key <= value) {
|
|
22530
|
-
element.classList.add("fill");
|
|
22531
|
-
}
|
|
22532
|
-
});
|
|
22533
|
-
if (list[value]) {
|
|
22534
|
-
list[value].classList.add("selected");
|
|
22580
|
+
else {
|
|
22581
|
+
this.handleSubmit();
|
|
22535
22582
|
}
|
|
22536
|
-
|
|
22537
|
-
|
|
22538
|
-
|
|
22583
|
+
return false;
|
|
22584
|
+
}
|
|
22585
|
+
completeWidget(value, userText = "") {
|
|
22586
|
+
this.markWidgetCompleted(value);
|
|
22587
|
+
this.showToast();
|
|
22588
|
+
this.saveLocalData();
|
|
22589
|
+
this.sendStatistic(userText);
|
|
22590
|
+
}
|
|
22591
|
+
saveLocalData() {
|
|
22592
|
+
const time = Math.round(new Date().getTime() / 1000);
|
|
22593
|
+
this.localData["_r_g_" + this.elementId + "_done_at"] = time;
|
|
22594
|
+
// ответ на вопрос
|
|
22595
|
+
this.localData["_&ts_r_g_" + this.elementId + "_a_at"] = time;
|
|
22596
|
+
this.setLocalData(this.localData, true);
|
|
22597
|
+
}
|
|
22598
|
+
markWidgetCompleted(value) {
|
|
22599
|
+
this.saveStarSelection(value);
|
|
22539
22600
|
this.startReadyPromise.then(() => {
|
|
22540
|
-
if (this.disableTimer
|
|
22601
|
+
if (this.disableTimer) {
|
|
22541
22602
|
this.onWidgetComplete();
|
|
22542
22603
|
}
|
|
22543
22604
|
});
|
|
22544
22605
|
}
|
|
22545
|
-
|
|
22546
|
-
|
|
22547
|
-
|
|
22548
|
-
element.classList.remove("selected");
|
|
22549
|
-
});
|
|
22550
|
-
this.element.classList.remove("done");
|
|
22606
|
+
saveStarSelection(value) {
|
|
22607
|
+
this.localData["_r_g_" + this.elementId + "_ss"] = value;
|
|
22608
|
+
this.element.classList.add("done");
|
|
22551
22609
|
}
|
|
22552
|
-
|
|
22553
|
-
|
|
22554
|
-
|
|
22555
|
-
|
|
22556
|
-
|
|
22557
|
-
|
|
22558
|
-
|
|
22559
|
-
|
|
22560
|
-
|
|
22561
|
-
|
|
22610
|
+
isDone() {
|
|
22611
|
+
return this.localData["_r_g_" + this.elementId + "_done_at"] !== undefined;
|
|
22612
|
+
}
|
|
22613
|
+
slideRateIsDone() {
|
|
22614
|
+
return this.localData["_r_g_" + this.elementId + "_sa"] !== undefined;
|
|
22615
|
+
}
|
|
22616
|
+
handleSubmit = () => {
|
|
22617
|
+
if (this.selectedStar == null)
|
|
22618
|
+
throw new NoStarSelectedError();
|
|
22619
|
+
const value = this.selectedStar;
|
|
22620
|
+
const action = this.getCompletionAction(value);
|
|
22562
22621
|
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
|
-
|
|
22622
|
+
this.answerSelectDuration = new Date().getTime() - this.firstOpenTime;
|
|
22623
|
+
switch (action) {
|
|
22624
|
+
case RateCompletionAction.ShowDialog:
|
|
22625
|
+
this.openUserDialog(value);
|
|
22626
|
+
break;
|
|
22627
|
+
case RateCompletionAction.SubmitToAppStores:
|
|
22628
|
+
this.submitToAppStores(value);
|
|
22629
|
+
break;
|
|
22630
|
+
default:
|
|
22631
|
+
this.completeWidget(value);
|
|
22632
|
+
}
|
|
22633
|
+
this.hideSubmitButton();
|
|
22634
|
+
};
|
|
22635
|
+
getCompletionAction(value) {
|
|
22636
|
+
if (value + 1 >= this.showDialogueMin && value + 1 <= this.showDialogueMax) {
|
|
22637
|
+
if (this.showDialogOnLowRate)
|
|
22638
|
+
return RateCompletionAction.ShowDialog;
|
|
22639
|
+
else
|
|
22640
|
+
RateCompletionAction.Default;
|
|
22641
|
+
}
|
|
22642
|
+
if (value + 1 >= this.submitToStoresMin && value + 1 <= this.submitToStoresMax)
|
|
22643
|
+
return RateCompletionAction.SubmitToAppStores;
|
|
22644
|
+
return RateCompletionAction.Default;
|
|
22645
|
+
}
|
|
22646
|
+
submitToAppStores(value) {
|
|
22647
|
+
let target = null;
|
|
22648
|
+
if (this.widgetDeps.slideApiDeps.isAndroid) {
|
|
22649
|
+
target = getTagData(this.element, "androidLink");
|
|
22650
|
+
}
|
|
22651
|
+
else if (this.widgetDeps.slideApiDeps.isIOS) {
|
|
22652
|
+
target = getTagData(this.element, "appleLink");
|
|
22653
|
+
}
|
|
22654
|
+
this.completeWidget(value);
|
|
22655
|
+
if (this.submitToStores && target) {
|
|
22656
|
+
this.widgetDeps.slideApiDeps.openUrl({ type: "link", link: { type: "url", target } });
|
|
22657
|
+
}
|
|
22658
|
+
}
|
|
22659
|
+
openUserDialog(value) {
|
|
22660
|
+
this.saveStarSelection(value);
|
|
22661
|
+
this.localData["_r_g_" + this.elementId + "_ss"] = value;
|
|
22662
|
+
this.element.classList.add("done");
|
|
22663
|
+
this.elementRect = this.element.getBoundingClientRect();
|
|
22664
|
+
if (this.widgetDeps.slideApiDeps.isAndroid) {
|
|
22665
|
+
this.slide.classList.add("blured");
|
|
22666
|
+
}
|
|
22667
|
+
this.slide.classList.add("data-input-editing");
|
|
22668
|
+
const dataString = this.element.dataset["clientdialogwidgetconfig"];
|
|
22669
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowCardTextInput && dataString) {
|
|
22670
|
+
const data = JSON.parse(dataString);
|
|
22671
|
+
data.size = getElementBounding(this.env, this.elementRect);
|
|
22672
|
+
if (!this.disableTimer) {
|
|
22673
|
+
this.onWidgetRequirePauseUI();
|
|
22607
22674
|
}
|
|
22608
|
-
|
|
22609
|
-
|
|
22610
|
-
|
|
22611
|
-
|
|
22612
|
-
|
|
22613
|
-
|
|
22614
|
-
|
|
22615
|
-
|
|
22616
|
-
|
|
22617
|
-
|
|
22618
|
-
|
|
22619
|
-
|
|
22620
|
-
this.widgetDeps.slideApiDeps.openUrl({ type: "link", link: { type: "url", target } });
|
|
22621
|
-
}
|
|
22675
|
+
this.nativeDialogueWasOpened = true;
|
|
22676
|
+
try {
|
|
22677
|
+
data.text.value = data.text.value.replaceAll("\\n", "\n").replaceAll("\\r", "\r").replaceAll("\\t", "\t");
|
|
22678
|
+
data.input.text.placeholder = data.input.text.placeholder.replaceAll("\\n", "\n").replaceAll("\\r", "\r").replaceAll("\\t", "\t");
|
|
22679
|
+
data.configV2.main.question.text.value = data.configV2.main.question.text.value
|
|
22680
|
+
.replaceAll("\\n", "\n")
|
|
22681
|
+
.replaceAll("\\r", "\r")
|
|
22682
|
+
.replaceAll("\\t", "\t");
|
|
22683
|
+
data.configV2.main.input.text.placeholder = data.configV2.main.input.text.placeholder
|
|
22684
|
+
.replaceAll("\\n", "\n")
|
|
22685
|
+
.replaceAll("\\r", "\r")
|
|
22686
|
+
.replaceAll("\\t", "\t");
|
|
22622
22687
|
}
|
|
22623
|
-
|
|
22624
|
-
|
|
22625
|
-
this.completeWidget();
|
|
22626
|
-
this._statEventRateUsAnswer("");
|
|
22688
|
+
catch (e) {
|
|
22689
|
+
console.error(e);
|
|
22627
22690
|
}
|
|
22691
|
+
this.widgetDeps.slideApiDeps.showCardTextInput(this.id, data);
|
|
22628
22692
|
}
|
|
22629
|
-
return false;
|
|
22630
22693
|
}
|
|
22631
|
-
|
|
22694
|
+
onUserDialogComplete(userText) {
|
|
22695
|
+
if (this.selectedStar == null)
|
|
22696
|
+
throw new NoStarSelectedError();
|
|
22632
22697
|
this.slide.classList.remove("data-input-editing");
|
|
22633
22698
|
this.slide.classList.remove("blured");
|
|
22634
|
-
if (this.selectedStar != null) {
|
|
22635
|
-
this._selectStar(this.selectedStar, true);
|
|
22636
|
-
}
|
|
22637
22699
|
if (!this.disableTimer && this.nativeDialogueWasOpened) {
|
|
22638
22700
|
this.onWidgetRequireResumeUI();
|
|
22639
22701
|
this.nativeDialogueWasOpened = false;
|
|
22640
22702
|
}
|
|
22641
|
-
this.localData["_r_g_" + this.elementId + "_user_response"] =
|
|
22642
|
-
this.completeWidget();
|
|
22643
|
-
this._statEventRateUsAnswer(text);
|
|
22703
|
+
this.localData["_r_g_" + this.elementId + "_user_response"] = userText;
|
|
22704
|
+
this.completeWidget(this.selectedStar, userText);
|
|
22644
22705
|
}
|
|
22645
|
-
|
|
22706
|
+
showToast() {
|
|
22646
22707
|
if (this.widgetDone) {
|
|
22647
22708
|
this.widgetDone.classList.add("active", "opacity-active");
|
|
22648
22709
|
setTimeout(() => {
|
|
@@ -22652,16 +22713,36 @@ class WidgetRate extends WidgetBase {
|
|
|
22652
22713
|
}, 250);
|
|
22653
22714
|
}, 2000);
|
|
22654
22715
|
}
|
|
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
22716
|
}
|
|
22660
|
-
|
|
22661
|
-
|
|
22717
|
+
showSubmitButton() {
|
|
22718
|
+
this.env.requestAnimationFrame(() => {
|
|
22719
|
+
if (this.submitButtonAnimatedView != null) {
|
|
22720
|
+
this.submitButtonAnimatedView.style.maxHeight = `${this.submitButtonViewHeight}px`;
|
|
22721
|
+
}
|
|
22722
|
+
});
|
|
22662
22723
|
}
|
|
22663
|
-
|
|
22664
|
-
|
|
22724
|
+
hideSubmitButton() {
|
|
22725
|
+
this.env.requestAnimationFrame(() => {
|
|
22726
|
+
if (this.submitButtonAnimatedView != null) {
|
|
22727
|
+
this.submitButtonAnimatedView.style.maxHeight = "0px";
|
|
22728
|
+
}
|
|
22729
|
+
});
|
|
22730
|
+
}
|
|
22731
|
+
fillStars(value) {
|
|
22732
|
+
if (!this.stars[value])
|
|
22733
|
+
return;
|
|
22734
|
+
this.stars.forEach((star, index) => {
|
|
22735
|
+
star.classList.remove("fill", "selected");
|
|
22736
|
+
if (index <= value)
|
|
22737
|
+
star.classList.add("fill");
|
|
22738
|
+
});
|
|
22739
|
+
this.stars[value].classList.add("selected");
|
|
22740
|
+
}
|
|
22741
|
+
clearStars() {
|
|
22742
|
+
this.stars.forEach(star => {
|
|
22743
|
+
star.classList.remove("fill", "selected");
|
|
22744
|
+
});
|
|
22745
|
+
this.element.classList.remove("done");
|
|
22665
22746
|
}
|
|
22666
22747
|
static api = {
|
|
22667
22748
|
widgetClassName: WidgetRate.widgetClassName,
|
|
@@ -22693,7 +22774,7 @@ class WidgetRate extends WidgetBase {
|
|
|
22693
22774
|
return true;
|
|
22694
22775
|
},
|
|
22695
22776
|
setUserData: function (slideRoot, id, text) {
|
|
22696
|
-
WidgetRate.getInstanceById(slideRoot, id)?.
|
|
22777
|
+
WidgetRate.getInstanceById(slideRoot, id)?.onUserDialogComplete(text);
|
|
22697
22778
|
},
|
|
22698
22779
|
};
|
|
22699
22780
|
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `WidgetCallbacks`, `WidgetDeps`]; }
|