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