@inappstory/slide-api 0.1.24 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2157 -360
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +149 -70
- package/dist/index.d.ts +149 -70
- package/dist/index.js +2157 -360
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -563,8 +563,8 @@ const getWinWidth = function (env) {
|
|
|
563
563
|
const getWinHeight = function (env) {
|
|
564
564
|
return env.innerHeight || env.document.documentElement.clientHeight || env.document.body.clientHeight;
|
|
565
565
|
};
|
|
566
|
-
const sendStatisticEventToApp = function (
|
|
567
|
-
|
|
566
|
+
const sendStatisticEventToApp = function (slideApiDeps, name, data, devPayload, options) {
|
|
567
|
+
slideApiDeps.sendStatisticEvent(name, data, devPayload, options?.forceEnableStatisticV2 ?? false);
|
|
568
568
|
};
|
|
569
569
|
const getValueOrException = function (value, message) {
|
|
570
570
|
if (value == null) {
|
|
@@ -1135,6 +1135,9 @@ class EsModuleSdkApi {
|
|
|
1135
1135
|
getCardSessionValue(element, key) {
|
|
1136
1136
|
return this.sdkBinding.getCardSessionValue(key);
|
|
1137
1137
|
}
|
|
1138
|
+
isSdkSupportUpdateTimeline() {
|
|
1139
|
+
return true;
|
|
1140
|
+
}
|
|
1138
1141
|
updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError) {
|
|
1139
1142
|
this.sdkBinding.updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError);
|
|
1140
1143
|
}
|
|
@@ -1175,9 +1178,79 @@ class EsModuleSdkApi {
|
|
|
1175
1178
|
isSdkSupportCorrectPauseResumeLifecycle() {
|
|
1176
1179
|
return true;
|
|
1177
1180
|
}
|
|
1181
|
+
emitEvent(name, event) {
|
|
1182
|
+
this.sdkBinding.onEvent(name, event);
|
|
1183
|
+
}
|
|
1184
|
+
onCardLoadingStateChange(state, reason) {
|
|
1185
|
+
// console.log("onCardLoadingStateChange", { state });
|
|
1186
|
+
this.sdkBinding.onCardLoadingStateChange(state, reason);
|
|
1187
|
+
}
|
|
1178
1188
|
static get [Symbol.for("___CTOR_ARGS___")]() { return [`SDKInterface`]; }
|
|
1179
1189
|
}
|
|
1180
1190
|
|
|
1191
|
+
class CardLoadingStateController {
|
|
1192
|
+
onCardLoadingStateChange;
|
|
1193
|
+
constructor(onCardLoadingStateChange) {
|
|
1194
|
+
this.onCardLoadingStateChange = onCardLoadingStateChange;
|
|
1195
|
+
}
|
|
1196
|
+
timeout = 300;
|
|
1197
|
+
onSetLoadStartState() {
|
|
1198
|
+
this.onBeforeStateChanged();
|
|
1199
|
+
// prevent micro loaders in UI
|
|
1200
|
+
if (this.currentState === 1 /* CARD_LOADING_STATE.LOADED */) {
|
|
1201
|
+
this.deferredDataWaitingStateTimerId = window.setTimeout(() => {
|
|
1202
|
+
this.onCardLoadingStateChange(0 /* CARD_LOADING_STATE.LOADING */);
|
|
1203
|
+
this.dataWaitingStartedAt = Date.now();
|
|
1204
|
+
}, this.timeout);
|
|
1205
|
+
}
|
|
1206
|
+
else {
|
|
1207
|
+
this.onCardLoadingStateChange(0 /* CARD_LOADING_STATE.LOADING */);
|
|
1208
|
+
this.dataWaitingStartedAt = Date.now();
|
|
1209
|
+
}
|
|
1210
|
+
this.currentState = 0 /* CARD_LOADING_STATE.LOADING */;
|
|
1211
|
+
}
|
|
1212
|
+
onSetLoadEndState() {
|
|
1213
|
+
this.onBeforeStateChanged();
|
|
1214
|
+
// prevent micro loaders in UI
|
|
1215
|
+
const delay = this.timeout;
|
|
1216
|
+
let dataWaitingLoaderSpent = delay;
|
|
1217
|
+
if (this.dataWaitingStartedAt != null) {
|
|
1218
|
+
dataWaitingLoaderSpent = Date.now() - this.dataWaitingStartedAt;
|
|
1219
|
+
}
|
|
1220
|
+
if (dataWaitingLoaderSpent < delay) {
|
|
1221
|
+
this.deferredResumeStateTimerId = window.setTimeout(() => this.onCardLoadingStateChange(1 /* CARD_LOADING_STATE.LOADED */), dataWaitingLoaderSpent - delay);
|
|
1222
|
+
}
|
|
1223
|
+
else {
|
|
1224
|
+
this.onCardLoadingStateChange(1 /* CARD_LOADING_STATE.LOADED */);
|
|
1225
|
+
}
|
|
1226
|
+
this.currentState = 1 /* CARD_LOADING_STATE.LOADED */;
|
|
1227
|
+
}
|
|
1228
|
+
onSetLoadErrorState(reason) {
|
|
1229
|
+
this.onBeforeStateChanged();
|
|
1230
|
+
this.onCardLoadingStateChange(2 /* CARD_LOADING_STATE.LOADING_ERROR */, reason);
|
|
1231
|
+
this.currentState = 2 /* CARD_LOADING_STATE.LOADING_ERROR */;
|
|
1232
|
+
}
|
|
1233
|
+
currentState = 0 /* CARD_LOADING_STATE.LOADING */;
|
|
1234
|
+
deferredDataWaitingStateTimerId = null;
|
|
1235
|
+
deferredResumeStateTimerId = null;
|
|
1236
|
+
dataWaitingStartedAt = null;
|
|
1237
|
+
clearDeferredDataWaitingStateTimerId() {
|
|
1238
|
+
if (this.deferredDataWaitingStateTimerId != null) {
|
|
1239
|
+
window.clearTimeout(this.deferredDataWaitingStateTimerId);
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
clearDeferredResumeStateTimerId() {
|
|
1243
|
+
if (this.deferredResumeStateTimerId != null) {
|
|
1244
|
+
window.clearTimeout(this.deferredResumeStateTimerId);
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
onBeforeStateChanged() {
|
|
1248
|
+
this.clearDeferredDataWaitingStateTimerId();
|
|
1249
|
+
this.clearDeferredResumeStateTimerId();
|
|
1250
|
+
}
|
|
1251
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`(state: CARD_LOADING_STATE, reason?: string) => void`]; }
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1181
1254
|
const DEFAULT_SLIDE_DURATION = 10000;
|
|
1182
1255
|
|
|
1183
1256
|
class DataInput {
|
|
@@ -1201,6 +1274,9 @@ class DataInput {
|
|
|
1201
1274
|
return element instanceof DataInput;
|
|
1202
1275
|
}
|
|
1203
1276
|
mediaElementsLoadingPromises = [];
|
|
1277
|
+
get nodeRef() {
|
|
1278
|
+
return this._elementNodeRef;
|
|
1279
|
+
}
|
|
1204
1280
|
init(localData) {
|
|
1205
1281
|
try {
|
|
1206
1282
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1251,6 +1327,9 @@ class Barcode {
|
|
|
1251
1327
|
this._widgetDeps = _widgetDeps;
|
|
1252
1328
|
}
|
|
1253
1329
|
mediaElementsLoadingPromises = [];
|
|
1330
|
+
get nodeRef() {
|
|
1331
|
+
return this._elementNodeRef;
|
|
1332
|
+
}
|
|
1254
1333
|
init(localData) {
|
|
1255
1334
|
try {
|
|
1256
1335
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1288,36 +1367,311 @@ class ClickableBase {
|
|
|
1288
1367
|
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`]; }
|
|
1289
1368
|
}
|
|
1290
1369
|
|
|
1370
|
+
class PromocodeNetworkError extends Error {
|
|
1371
|
+
}
|
|
1372
|
+
class PromocodeServiceError extends Error {
|
|
1373
|
+
}
|
|
1374
|
+
class PromocodeNoMoreCodes extends Error {
|
|
1375
|
+
}
|
|
1376
|
+
class PromocodeApi {
|
|
1377
|
+
sdkApi;
|
|
1378
|
+
messages;
|
|
1379
|
+
constructor(sdkApi, messages) {
|
|
1380
|
+
this.sdkApi = sdkApi;
|
|
1381
|
+
this.messages = messages;
|
|
1382
|
+
}
|
|
1383
|
+
async fetchPromoCode(params) {
|
|
1384
|
+
const path = this.getPromotionalCodeFetchPath(params);
|
|
1385
|
+
const headers = {
|
|
1386
|
+
accept: "application/json",
|
|
1387
|
+
"Content-Type": "application/json",
|
|
1388
|
+
};
|
|
1389
|
+
const [response] = await Promise.all([
|
|
1390
|
+
this.sdkApi.sendApiRequest(path, "POST", null, headers, null, "fetch-promo-code"),
|
|
1391
|
+
new Promise(resolve => setTimeout(resolve, 300)),
|
|
1392
|
+
]);
|
|
1393
|
+
const { status, data } = response;
|
|
1394
|
+
if (status === 200 || status === 201) {
|
|
1395
|
+
const promocode = data?.code;
|
|
1396
|
+
if (promocode) {
|
|
1397
|
+
return { promocode, status };
|
|
1398
|
+
}
|
|
1399
|
+
throw new PromocodeNoMoreCodes(this.messages.noMoreCodes);
|
|
1400
|
+
}
|
|
1401
|
+
if (status === 12163 || status === 12002) {
|
|
1402
|
+
throw new PromocodeNetworkError(this.messages.networkError);
|
|
1403
|
+
}
|
|
1404
|
+
throw new PromocodeServiceError(this.messages.serviceError);
|
|
1405
|
+
}
|
|
1406
|
+
getPromotionalCodeFetchPath(params) {
|
|
1407
|
+
switch (params.card.type) {
|
|
1408
|
+
case 4 /* CARD_TYPE.IN_APP_MESSAGING */:
|
|
1409
|
+
return `inappmessaging/message/${params.card.id}/widget/${params.elementId}/promo-code/${params.promocodeId}`;
|
|
1410
|
+
default:
|
|
1411
|
+
return `story/${params.card.id}/widget/${params.elementId}/promo-code/${params.promocodeId}`;
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`Pick`, `{
|
|
1415
|
+
noMoreCodes?: string;
|
|
1416
|
+
networkError?: string;
|
|
1417
|
+
serviceError?: string;
|
|
1418
|
+
}`]; }
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
class PromocodeLocalRepository {
|
|
1422
|
+
elementId;
|
|
1423
|
+
sdkApi;
|
|
1424
|
+
localData = {};
|
|
1425
|
+
constructor(elementId, sdkApi) {
|
|
1426
|
+
this.elementId = elementId;
|
|
1427
|
+
this.sdkApi = sdkApi;
|
|
1428
|
+
}
|
|
1429
|
+
init({ localData, cardId }) {
|
|
1430
|
+
const savedData = this.sdkApi.getCardServerData(cardId) ?? {};
|
|
1431
|
+
this.localData = extend({}, savedData, localData ?? {});
|
|
1432
|
+
}
|
|
1433
|
+
getPromocode() {
|
|
1434
|
+
return this.localData["_pcl_g_" + this.elementId + "_pc"];
|
|
1435
|
+
}
|
|
1436
|
+
savePromocodeByStatus(promocode, status) {
|
|
1437
|
+
if (status === 201)
|
|
1438
|
+
this.savePromocodeWithTime(promocode);
|
|
1439
|
+
else
|
|
1440
|
+
this.savePromocode(promocode);
|
|
1441
|
+
}
|
|
1442
|
+
savePromocodeWithTime(promocode) {
|
|
1443
|
+
this.localData["_pcl_g_" + this.elementId + "_pc_fetched_at"] = Math.round(new Date().getTime() / 1000);
|
|
1444
|
+
this.localData["_&ts_pcl_g_" + this.elementId + "_pc_fetched_at"] = Math.round(new Date().getTime() / 1000);
|
|
1445
|
+
this.savePromocode(promocode);
|
|
1446
|
+
}
|
|
1447
|
+
savePromocode(promocode) {
|
|
1448
|
+
this.localData["_pcl_g_" + this.elementId + "_pc"] = promocode;
|
|
1449
|
+
this.setCardLocalData(this.localData);
|
|
1450
|
+
}
|
|
1451
|
+
async setCardLocalData(newLocalData) {
|
|
1452
|
+
const localData = await this.sdkApi.getCardLocalData();
|
|
1453
|
+
const mergedData = extend({}, localData, newLocalData);
|
|
1454
|
+
await this.sdkApi.setCardLocalData(mergedData, true);
|
|
1455
|
+
}
|
|
1456
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`string`, `ISlideApiDeps`]; }
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
var PromocodeLinkState;
|
|
1460
|
+
(function (PromocodeLinkState) {
|
|
1461
|
+
PromocodeLinkState[PromocodeLinkState["Idle"] = 0] = "Idle";
|
|
1462
|
+
PromocodeLinkState[PromocodeLinkState["Fetched"] = 1] = "Fetched";
|
|
1463
|
+
PromocodeLinkState[PromocodeLinkState["Error"] = 2] = "Error";
|
|
1464
|
+
})(PromocodeLinkState || (PromocodeLinkState = {}));
|
|
1465
|
+
const PROMOCODE_PLACEHOLDER = "%__ias_pc%";
|
|
1466
|
+
class PromocodeLink {
|
|
1467
|
+
element;
|
|
1468
|
+
layer;
|
|
1469
|
+
widgetDeps;
|
|
1470
|
+
state = PromocodeLinkState.Idle;
|
|
1471
|
+
promocode = null;
|
|
1472
|
+
promocodeId;
|
|
1473
|
+
linkTemplate;
|
|
1474
|
+
textContent;
|
|
1475
|
+
button;
|
|
1476
|
+
elementId;
|
|
1477
|
+
card;
|
|
1478
|
+
api;
|
|
1479
|
+
localRepository;
|
|
1480
|
+
constructor(element, layer, widgetDeps) {
|
|
1481
|
+
this.element = element;
|
|
1482
|
+
this.layer = layer;
|
|
1483
|
+
this.widgetDeps = widgetDeps;
|
|
1484
|
+
this.elementId = getValueOrException(getTagData(this.element, "elementId"), "Empty elementId");
|
|
1485
|
+
this.promocodeId = getTagData(this.element, "linkTarget") ?? "";
|
|
1486
|
+
this.linkTemplate = getTagData(this.element, "linkTemplate") ?? "";
|
|
1487
|
+
this.button = this.element.querySelector(".narrative-element-text-lines");
|
|
1488
|
+
this.textContent = this.button?.textContent ?? "";
|
|
1489
|
+
this.card = this.getCard();
|
|
1490
|
+
this.api = new PromocodeApi(this.widgetDeps.slideApiDeps, {
|
|
1491
|
+
networkError: getTagData(this.element, "msgNetworkError") ?? "",
|
|
1492
|
+
serviceError: getTagData(this.element, "msgServiceError") ?? "",
|
|
1493
|
+
noMoreCodes: getTagData(this.element, "msgNoMoreCodes") ?? "",
|
|
1494
|
+
});
|
|
1495
|
+
this.localRepository = new PromocodeLocalRepository(this.elementId, this.widgetDeps.slideApiDeps);
|
|
1496
|
+
}
|
|
1497
|
+
get nodeRef() {
|
|
1498
|
+
return this.element;
|
|
1499
|
+
}
|
|
1500
|
+
mediaElementsLoadingPromises = [];
|
|
1501
|
+
init(localData) {
|
|
1502
|
+
this.localRepository.init({ localData: localData ?? {}, cardId: this.card.id });
|
|
1503
|
+
this.state = PromocodeLinkState.Idle;
|
|
1504
|
+
const promocode = this.localRepository.getPromocode();
|
|
1505
|
+
if (promocode) {
|
|
1506
|
+
this.state = PromocodeLinkState.Fetched;
|
|
1507
|
+
this.showPromocode(promocode);
|
|
1508
|
+
this.promocode = promocode;
|
|
1509
|
+
}
|
|
1510
|
+
return Promise.resolve(true);
|
|
1511
|
+
}
|
|
1512
|
+
onPause() { }
|
|
1513
|
+
onResume() { }
|
|
1514
|
+
onStop() { }
|
|
1515
|
+
onBeforeUnmount() {
|
|
1516
|
+
return Promise.resolve();
|
|
1517
|
+
}
|
|
1518
|
+
handleClick() {
|
|
1519
|
+
switch (this.state) {
|
|
1520
|
+
case PromocodeLinkState.Idle:
|
|
1521
|
+
return false;
|
|
1522
|
+
case PromocodeLinkState.Fetched:
|
|
1523
|
+
this.openPromocodeUrl();
|
|
1524
|
+
return true;
|
|
1525
|
+
case PromocodeLinkState.Error:
|
|
1526
|
+
this.loadPromocode(this.promocodeId).catch(() => { });
|
|
1527
|
+
break;
|
|
1528
|
+
}
|
|
1529
|
+
return false;
|
|
1530
|
+
}
|
|
1531
|
+
get isLayerForcePaused() {
|
|
1532
|
+
return false;
|
|
1533
|
+
}
|
|
1534
|
+
onStart() {
|
|
1535
|
+
this.element.classList.add("active");
|
|
1536
|
+
this.loadPromocode(this.promocodeId).catch(() => { });
|
|
1537
|
+
}
|
|
1538
|
+
openPromocodeUrl() {
|
|
1539
|
+
if (!this.promocode)
|
|
1540
|
+
return;
|
|
1541
|
+
const target = this.linkTemplate.replaceAll(PROMOCODE_PLACEHOLDER, this.promocode);
|
|
1542
|
+
this.layer.layoutService.env.setTimeout(() => {
|
|
1543
|
+
this.widgetDeps.slideApiDeps.openUrl({ type: "link", link: { type: "url", target } });
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
async loadPromocode(promocodeId) {
|
|
1547
|
+
try {
|
|
1548
|
+
this.state = PromocodeLinkState.Idle;
|
|
1549
|
+
this.showLoader();
|
|
1550
|
+
const promocode = await this.getPromocode({
|
|
1551
|
+
promocodeId,
|
|
1552
|
+
card: this.card,
|
|
1553
|
+
elementId: this.elementId,
|
|
1554
|
+
});
|
|
1555
|
+
this.state = PromocodeLinkState.Fetched;
|
|
1556
|
+
this.promocode = promocode;
|
|
1557
|
+
this.showPromocode(promocode);
|
|
1558
|
+
return promocode;
|
|
1559
|
+
}
|
|
1560
|
+
catch (error) {
|
|
1561
|
+
this.handleLoadPromocodeError(error);
|
|
1562
|
+
throw error;
|
|
1563
|
+
}
|
|
1564
|
+
finally {
|
|
1565
|
+
this.hideLoader();
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
async getPromocode(params) {
|
|
1569
|
+
if (this.promocode)
|
|
1570
|
+
return this.promocode;
|
|
1571
|
+
let promocode = this.localRepository.getPromocode();
|
|
1572
|
+
if (!promocode) {
|
|
1573
|
+
const result = await this.api.fetchPromoCode(params);
|
|
1574
|
+
promocode = result.promocode;
|
|
1575
|
+
this.localRepository.savePromocodeByStatus(promocode, result.status);
|
|
1576
|
+
}
|
|
1577
|
+
this.promocode = promocode;
|
|
1578
|
+
return promocode;
|
|
1579
|
+
}
|
|
1580
|
+
handleLoadPromocodeError(error) {
|
|
1581
|
+
this.state = PromocodeLinkState.Error;
|
|
1582
|
+
this.showErrorMessage(getTagData(this.element, "msgTryAgain") ?? "");
|
|
1583
|
+
if (error.message.length) {
|
|
1584
|
+
this.widgetDeps.slideApiDeps.showToast(error.message);
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
showPromocode(promocode) {
|
|
1588
|
+
if (!this.button)
|
|
1589
|
+
return;
|
|
1590
|
+
this.button.textContent = this.textContent.replaceAll(PROMOCODE_PLACEHOLDER, promocode);
|
|
1591
|
+
}
|
|
1592
|
+
showErrorMessage(message) {
|
|
1593
|
+
if (!this.button)
|
|
1594
|
+
return;
|
|
1595
|
+
this.button.textContent = message;
|
|
1596
|
+
}
|
|
1597
|
+
getCard() {
|
|
1598
|
+
const slide = getValueOrException(this.element.closest(".narrative-slide"), "Empty slide");
|
|
1599
|
+
return {
|
|
1600
|
+
id: getValueOrException(getTagDataAsNumber(slide, "id"), "Empty cardId"),
|
|
1601
|
+
type: getValueOrException(getTagDataAsNumber(slide, "cardType"), "Empty card type"),
|
|
1602
|
+
};
|
|
1603
|
+
}
|
|
1604
|
+
showLoader() {
|
|
1605
|
+
if (!this.isTransparentElement())
|
|
1606
|
+
addClass(this.element, "loader");
|
|
1607
|
+
}
|
|
1608
|
+
hideLoader() {
|
|
1609
|
+
removeClass(this.element, "loader");
|
|
1610
|
+
}
|
|
1611
|
+
isTransparentElement() {
|
|
1612
|
+
if (this.element) {
|
|
1613
|
+
try {
|
|
1614
|
+
const color = window.getComputedStyle(this.element).color;
|
|
1615
|
+
if (color === "transparent" || color === "rgba(0, 0, 0, 0)" || color === "rgba(0,0,0,0)") {
|
|
1616
|
+
return true;
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
catch (err) {
|
|
1620
|
+
console.error(err);
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
return false;
|
|
1624
|
+
}
|
|
1625
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `WidgetDeps`]; }
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1291
1628
|
class Button extends ClickableBase {
|
|
1292
1629
|
_elementNodeRef;
|
|
1293
|
-
|
|
1630
|
+
layer;
|
|
1631
|
+
widgetDeps;
|
|
1294
1632
|
static _className = "narrative-element-link";
|
|
1633
|
+
isPromotionalCode;
|
|
1634
|
+
promocodeLink = null;
|
|
1295
1635
|
static className() {
|
|
1296
1636
|
return Button._className;
|
|
1297
1637
|
}
|
|
1298
|
-
|
|
1638
|
+
static isTypeOf(element) {
|
|
1639
|
+
return element instanceof Button;
|
|
1640
|
+
}
|
|
1641
|
+
constructor(_elementNodeRef, layer, widgetDeps) {
|
|
1299
1642
|
super(_elementNodeRef);
|
|
1300
1643
|
this._elementNodeRef = _elementNodeRef;
|
|
1301
|
-
this.
|
|
1644
|
+
this.layer = layer;
|
|
1645
|
+
this.widgetDeps = widgetDeps;
|
|
1646
|
+
this.isPromotionalCode = getTagData(_elementNodeRef, "linkType") === "promocode";
|
|
1647
|
+
if (this.isPromotionalCode) {
|
|
1648
|
+
this.promocodeLink = new PromocodeLink(_elementNodeRef, layer, widgetDeps);
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
get nodeRef() {
|
|
1652
|
+
return this._elementNodeRef;
|
|
1302
1653
|
}
|
|
1303
1654
|
mediaElementsLoadingPromises = [];
|
|
1304
|
-
init(localData) {
|
|
1305
|
-
|
|
1655
|
+
async init(localData) {
|
|
1656
|
+
await this.promocodeLink?.init(localData);
|
|
1657
|
+
return true;
|
|
1306
1658
|
}
|
|
1307
1659
|
onPause() { }
|
|
1308
1660
|
onResume() { }
|
|
1309
|
-
onStart() {
|
|
1661
|
+
onStart() {
|
|
1662
|
+
this.promocodeLink?.onStart();
|
|
1663
|
+
}
|
|
1310
1664
|
onStop() { }
|
|
1311
1665
|
onBeforeUnmount() {
|
|
1312
1666
|
return Promise.resolve();
|
|
1313
1667
|
}
|
|
1314
1668
|
handleClick() {
|
|
1315
|
-
return
|
|
1669
|
+
return this.promocodeLink?.handleClick() ?? true;
|
|
1316
1670
|
}
|
|
1317
1671
|
get isLayerForcePaused() {
|
|
1318
1672
|
return false;
|
|
1319
1673
|
}
|
|
1320
|
-
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`]; }
|
|
1674
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `WidgetDeps`]; }
|
|
1321
1675
|
}
|
|
1322
1676
|
|
|
1323
1677
|
class Copy {
|
|
@@ -1338,6 +1692,9 @@ class Copy {
|
|
|
1338
1692
|
this._widgetDeps = _widgetDeps;
|
|
1339
1693
|
}
|
|
1340
1694
|
mediaElementsLoadingPromises = [];
|
|
1695
|
+
get nodeRef() {
|
|
1696
|
+
return this._elementNodeRef;
|
|
1697
|
+
}
|
|
1341
1698
|
init(localData) {
|
|
1342
1699
|
try {
|
|
1343
1700
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1387,6 +1744,9 @@ class DateCountdown {
|
|
|
1387
1744
|
this._widgetDeps = _widgetDeps;
|
|
1388
1745
|
}
|
|
1389
1746
|
mediaElementsLoadingPromises = [];
|
|
1747
|
+
get nodeRef() {
|
|
1748
|
+
return this._elementNodeRef;
|
|
1749
|
+
}
|
|
1390
1750
|
init(localData) {
|
|
1391
1751
|
try {
|
|
1392
1752
|
this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1441,6 +1801,9 @@ class Poll {
|
|
|
1441
1801
|
return element instanceof Poll;
|
|
1442
1802
|
}
|
|
1443
1803
|
mediaElementsLoadingPromises = [];
|
|
1804
|
+
get nodeRef() {
|
|
1805
|
+
return this._elementNodeRef;
|
|
1806
|
+
}
|
|
1444
1807
|
init(localData) {
|
|
1445
1808
|
try {
|
|
1446
1809
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1496,6 +1859,9 @@ class PollLayers {
|
|
|
1496
1859
|
return element instanceof PollLayers;
|
|
1497
1860
|
}
|
|
1498
1861
|
mediaElementsLoadingPromises = [];
|
|
1862
|
+
get nodeRef() {
|
|
1863
|
+
return this._elementNodeRef;
|
|
1864
|
+
}
|
|
1499
1865
|
init(localData) {
|
|
1500
1866
|
try {
|
|
1501
1867
|
this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1546,6 +1912,9 @@ class Products {
|
|
|
1546
1912
|
return element instanceof Products;
|
|
1547
1913
|
}
|
|
1548
1914
|
mediaElementsLoadingPromises = [];
|
|
1915
|
+
get nodeRef() {
|
|
1916
|
+
return this._elementNodeRef;
|
|
1917
|
+
}
|
|
1549
1918
|
init(localData) {
|
|
1550
1919
|
try {
|
|
1551
1920
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1605,6 +1974,9 @@ class Quest {
|
|
|
1605
1974
|
return element instanceof Quest;
|
|
1606
1975
|
}
|
|
1607
1976
|
mediaElementsLoadingPromises = [];
|
|
1977
|
+
get nodeRef() {
|
|
1978
|
+
return this._elementNodeRef;
|
|
1979
|
+
}
|
|
1608
1980
|
init(localData) {
|
|
1609
1981
|
return this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
1610
1982
|
}
|
|
@@ -1653,6 +2025,9 @@ class Quiz {
|
|
|
1653
2025
|
return element instanceof Quiz;
|
|
1654
2026
|
}
|
|
1655
2027
|
mediaElementsLoadingPromises = [];
|
|
2028
|
+
get nodeRef() {
|
|
2029
|
+
return this._elementNodeRef;
|
|
2030
|
+
}
|
|
1656
2031
|
init(localData) {
|
|
1657
2032
|
try {
|
|
1658
2033
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1706,6 +2081,9 @@ class QuizGrouped {
|
|
|
1706
2081
|
return element instanceof QuizGrouped;
|
|
1707
2082
|
}
|
|
1708
2083
|
mediaElementsLoadingPromises = [];
|
|
2084
|
+
get nodeRef() {
|
|
2085
|
+
return this._elementNodeRef;
|
|
2086
|
+
}
|
|
1709
2087
|
init(localData) {
|
|
1710
2088
|
try {
|
|
1711
2089
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1759,6 +2137,9 @@ class RangeSlider {
|
|
|
1759
2137
|
return element instanceof RangeSlider;
|
|
1760
2138
|
}
|
|
1761
2139
|
mediaElementsLoadingPromises = [];
|
|
2140
|
+
get nodeRef() {
|
|
2141
|
+
return this._elementNodeRef;
|
|
2142
|
+
}
|
|
1762
2143
|
init(localData) {
|
|
1763
2144
|
try {
|
|
1764
2145
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1812,6 +2193,9 @@ class Rate {
|
|
|
1812
2193
|
return element instanceof Rate;
|
|
1813
2194
|
}
|
|
1814
2195
|
mediaElementsLoadingPromises = [];
|
|
2196
|
+
get nodeRef() {
|
|
2197
|
+
return this._elementNodeRef;
|
|
2198
|
+
}
|
|
1815
2199
|
init(localData) {
|
|
1816
2200
|
try {
|
|
1817
2201
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1868,6 +2252,9 @@ class Share {
|
|
|
1868
2252
|
return element instanceof Share;
|
|
1869
2253
|
}
|
|
1870
2254
|
mediaElementsLoadingPromises = [];
|
|
2255
|
+
get nodeRef() {
|
|
2256
|
+
return this._elementNodeRef;
|
|
2257
|
+
}
|
|
1871
2258
|
init(localData) {
|
|
1872
2259
|
try {
|
|
1873
2260
|
this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1915,6 +2302,9 @@ class SwipeUpItems {
|
|
|
1915
2302
|
return element instanceof SwipeUpItems;
|
|
1916
2303
|
}
|
|
1917
2304
|
mediaElementsLoadingPromises = [];
|
|
2305
|
+
get nodeRef() {
|
|
2306
|
+
return this._elementNodeRef;
|
|
2307
|
+
}
|
|
1918
2308
|
init(localData) {
|
|
1919
2309
|
return Promise.resolve(true);
|
|
1920
2310
|
}
|
|
@@ -1958,6 +2348,9 @@ class Test {
|
|
|
1958
2348
|
return element instanceof Test;
|
|
1959
2349
|
}
|
|
1960
2350
|
mediaElementsLoadingPromises = [];
|
|
2351
|
+
get nodeRef() {
|
|
2352
|
+
return this._elementNodeRef;
|
|
2353
|
+
}
|
|
1961
2354
|
init(localData) {
|
|
1962
2355
|
try {
|
|
1963
2356
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -2011,6 +2404,9 @@ class Tooltip {
|
|
|
2011
2404
|
this._widgetDeps = _widgetDeps;
|
|
2012
2405
|
}
|
|
2013
2406
|
mediaElementsLoadingPromises = [];
|
|
2407
|
+
get nodeRef() {
|
|
2408
|
+
return this._elementNodeRef;
|
|
2409
|
+
}
|
|
2014
2410
|
init(localData) {
|
|
2015
2411
|
try {
|
|
2016
2412
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -2058,6 +2454,9 @@ class Vote {
|
|
|
2058
2454
|
this._widgetDeps = _widgetDeps;
|
|
2059
2455
|
}
|
|
2060
2456
|
mediaElementsLoadingPromises = [];
|
|
2457
|
+
get nodeRef() {
|
|
2458
|
+
return this._elementNodeRef;
|
|
2459
|
+
}
|
|
2061
2460
|
init(localData) {
|
|
2062
2461
|
try {
|
|
2063
2462
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -2099,6 +2498,9 @@ class Text {
|
|
|
2099
2498
|
this._layer = _layer;
|
|
2100
2499
|
}
|
|
2101
2500
|
mediaElementsLoadingPromises = [];
|
|
2501
|
+
get nodeRef() {
|
|
2502
|
+
return this._elementNodeRef;
|
|
2503
|
+
}
|
|
2102
2504
|
init(localData) {
|
|
2103
2505
|
return Promise.resolve(true);
|
|
2104
2506
|
}
|
|
@@ -2222,6 +2624,9 @@ class Image extends ClickableBase {
|
|
|
2222
2624
|
this.mediaElementsLoadingPromises = mediaElements.map(waitForImageHtmlElementLoad);
|
|
2223
2625
|
}
|
|
2224
2626
|
mediaElementsLoadingPromises = [];
|
|
2627
|
+
get nodeRef() {
|
|
2628
|
+
return this._elementNodeRef;
|
|
2629
|
+
}
|
|
2225
2630
|
init(localData) {
|
|
2226
2631
|
return Promise.resolve(true);
|
|
2227
2632
|
}
|
|
@@ -2256,6 +2661,9 @@ class SwipeUp {
|
|
|
2256
2661
|
return element instanceof SwipeUp;
|
|
2257
2662
|
}
|
|
2258
2663
|
mediaElementsLoadingPromises = [];
|
|
2664
|
+
get nodeRef() {
|
|
2665
|
+
return this._elementNodeRef;
|
|
2666
|
+
}
|
|
2259
2667
|
init(localData) {
|
|
2260
2668
|
return Promise.resolve(true);
|
|
2261
2669
|
}
|
|
@@ -2282,7 +2690,7 @@ class Video {
|
|
|
2282
2690
|
_elementNodeRef;
|
|
2283
2691
|
_layer;
|
|
2284
2692
|
_VideoPlayer;
|
|
2285
|
-
|
|
2693
|
+
_slideApiDeps;
|
|
2286
2694
|
static _className = "narrative-element-video";
|
|
2287
2695
|
static className() {
|
|
2288
2696
|
return Video._className;
|
|
@@ -2292,11 +2700,11 @@ class Video {
|
|
|
2292
2700
|
_vodData;
|
|
2293
2701
|
_vodPlayerInstance = null;
|
|
2294
2702
|
_videoStateAdapter = null;
|
|
2295
|
-
constructor(_elementNodeRef, _layer, _VideoPlayer,
|
|
2703
|
+
constructor(_elementNodeRef, _layer, _VideoPlayer, _slideApiDeps) {
|
|
2296
2704
|
this._elementNodeRef = _elementNodeRef;
|
|
2297
2705
|
this._layer = _layer;
|
|
2298
2706
|
this._VideoPlayer = _VideoPlayer;
|
|
2299
|
-
this.
|
|
2707
|
+
this._slideApiDeps = _slideApiDeps;
|
|
2300
2708
|
const _video = this._elementNodeRef.querySelector("video");
|
|
2301
2709
|
if (!_video) {
|
|
2302
2710
|
return;
|
|
@@ -2352,6 +2760,9 @@ class Video {
|
|
|
2352
2760
|
return element instanceof Video;
|
|
2353
2761
|
}
|
|
2354
2762
|
mediaElementsLoadingPromises = [];
|
|
2763
|
+
get nodeRef() {
|
|
2764
|
+
return this._elementNodeRef;
|
|
2765
|
+
}
|
|
2355
2766
|
init(localData) {
|
|
2356
2767
|
return Promise.resolve(true);
|
|
2357
2768
|
}
|
|
@@ -2371,6 +2782,9 @@ class Video {
|
|
|
2371
2782
|
// console.log("onBeforeUnmount")
|
|
2372
2783
|
return await this._destroyVODPlayer();
|
|
2373
2784
|
}
|
|
2785
|
+
get durationMs() {
|
|
2786
|
+
return this._video.duration * 1000;
|
|
2787
|
+
}
|
|
2374
2788
|
_initVOD(vodData) {
|
|
2375
2789
|
const onWaiting = () => {
|
|
2376
2790
|
/**
|
|
@@ -2396,7 +2810,7 @@ class Video {
|
|
|
2396
2810
|
// TODO via class instead of data attr
|
|
2397
2811
|
if (this._video.getAttribute("data-waiting") === "1") {
|
|
2398
2812
|
this._video.setAttribute("data-waiting", "0");
|
|
2399
|
-
this._layer.timeline.slideResumed(this._video.currentTime * 1000);
|
|
2813
|
+
this._layer.timeline.slideResumed(() => this._video.currentTime * 1000);
|
|
2400
2814
|
// @ts-ignore
|
|
2401
2815
|
// _log(`playing: ${this._video.currentTime}`, true);
|
|
2402
2816
|
// clearTimeout(window.synthErrorId);
|
|
@@ -2480,13 +2894,13 @@ class Video {
|
|
|
2480
2894
|
});
|
|
2481
2895
|
}
|
|
2482
2896
|
_convertMpdUrls(mpd_) {
|
|
2483
|
-
if (this.
|
|
2897
|
+
if (this._slideApiDeps.isWeb) {
|
|
2484
2898
|
return mpd_;
|
|
2485
2899
|
}
|
|
2486
2900
|
if (isObject(mpd_) && mpd_.adaptiveFormats != null && Array.isArray(mpd_.adaptiveFormats)) {
|
|
2487
2901
|
const mpd = { ...mpd_ };
|
|
2488
2902
|
for (let i = 0; i < mpd.adaptiveFormats.length; ++i) {
|
|
2489
|
-
mpd.adaptiveFormats[i].url = `${this.
|
|
2903
|
+
mpd.adaptiveFormats[i].url = `${this._slideApiDeps.isAndroid ? `http://vod-asset/` : `vod-asset://`}${mpd.adaptiveFormats[i].cacheName}`;
|
|
2490
2904
|
}
|
|
2491
2905
|
return mpd;
|
|
2492
2906
|
}
|
|
@@ -2521,7 +2935,13 @@ class Video {
|
|
|
2521
2935
|
get videoStartedPromise() {
|
|
2522
2936
|
return this._videoStartedPromise;
|
|
2523
2937
|
}
|
|
2524
|
-
|
|
2938
|
+
get isLooped() {
|
|
2939
|
+
if (this._video != null) {
|
|
2940
|
+
return this._video?.loop;
|
|
2941
|
+
}
|
|
2942
|
+
return false;
|
|
2943
|
+
}
|
|
2944
|
+
start(muted = true, getIsLooped) {
|
|
2525
2945
|
this._videoStartedPromise = new Promise(async (resolve) => {
|
|
2526
2946
|
// invariant - always wait for mediaElementsLoadingPromises
|
|
2527
2947
|
// else call of _initVOD can start and onAllMediaLoaded failed
|
|
@@ -2535,7 +2955,7 @@ class Video {
|
|
|
2535
2955
|
// console.log("Video:start => this._video.pause()");
|
|
2536
2956
|
this._video.pause();
|
|
2537
2957
|
this._video.currentTime = 0;
|
|
2538
|
-
this._video.loop =
|
|
2958
|
+
this._video.loop = getIsLooped();
|
|
2539
2959
|
// remove init class
|
|
2540
2960
|
// if vod - create VoD player
|
|
2541
2961
|
if (this._video.getAttribute("data-default-muted") !== "1") {
|
|
@@ -2548,13 +2968,13 @@ class Video {
|
|
|
2548
2968
|
this._video.currentTime = 0;
|
|
2549
2969
|
this._elementNodeRef.classList.remove("init");
|
|
2550
2970
|
resolve({
|
|
2551
|
-
|
|
2971
|
+
getVideoCurrentTime: () => this._video.currentTime,
|
|
2552
2972
|
});
|
|
2553
2973
|
})
|
|
2554
2974
|
.catch(error => {
|
|
2555
2975
|
console.error(error);
|
|
2556
2976
|
resolve({
|
|
2557
|
-
|
|
2977
|
+
getVideoCurrentTime: () => this._video.currentTime,
|
|
2558
2978
|
});
|
|
2559
2979
|
});
|
|
2560
2980
|
}
|
|
@@ -2563,14 +2983,14 @@ class Video {
|
|
|
2563
2983
|
this._video.currentTime = 0;
|
|
2564
2984
|
this._elementNodeRef.classList.remove("init");
|
|
2565
2985
|
resolve({
|
|
2566
|
-
|
|
2986
|
+
getVideoCurrentTime: () => this._video.currentTime,
|
|
2567
2987
|
});
|
|
2568
2988
|
}, 0);
|
|
2569
2989
|
}
|
|
2570
2990
|
}
|
|
2571
2991
|
else {
|
|
2572
2992
|
resolve({
|
|
2573
|
-
|
|
2993
|
+
getVideoCurrentTime: () => 0,
|
|
2574
2994
|
});
|
|
2575
2995
|
}
|
|
2576
2996
|
});
|
|
@@ -2606,7 +3026,7 @@ class Video {
|
|
|
2606
3026
|
// console.log("resolve 1.1", { ts });
|
|
2607
3027
|
this._video.currentTime = ts;
|
|
2608
3028
|
}
|
|
2609
|
-
resolve({
|
|
3029
|
+
resolve({ getVideoCurrentTime: () => this._video.currentTime });
|
|
2610
3030
|
})
|
|
2611
3031
|
.catch(error => {
|
|
2612
3032
|
console.error(error);
|
|
@@ -2614,7 +3034,7 @@ class Video {
|
|
|
2614
3034
|
if (this._video.currentTime < ts) {
|
|
2615
3035
|
this._video.currentTime = ts;
|
|
2616
3036
|
}
|
|
2617
|
-
resolve({
|
|
3037
|
+
resolve({ getVideoCurrentTime: () => this._video.currentTime });
|
|
2618
3038
|
});
|
|
2619
3039
|
}
|
|
2620
3040
|
else {
|
|
@@ -2623,7 +3043,7 @@ class Video {
|
|
|
2623
3043
|
if (this._video.currentTime < ts) {
|
|
2624
3044
|
this._video.currentTime = ts;
|
|
2625
3045
|
}
|
|
2626
|
-
resolve({
|
|
3046
|
+
resolve({ getVideoCurrentTime: () => this._video.currentTime });
|
|
2627
3047
|
}, 0);
|
|
2628
3048
|
}
|
|
2629
3049
|
});
|
|
@@ -2677,7 +3097,7 @@ class Video {
|
|
|
2677
3097
|
this._video.muted = true;
|
|
2678
3098
|
}
|
|
2679
3099
|
}
|
|
2680
|
-
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof VideoPlayer | undefined`, `
|
|
3100
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof VideoPlayer | undefined`, `ISlideApiDeps`]; }
|
|
2681
3101
|
}
|
|
2682
3102
|
// class VideoStateAdapter {
|
|
2683
3103
|
//
|
|
@@ -2771,7 +3191,12 @@ class VideoStateAdapter {
|
|
|
2771
3191
|
}
|
|
2772
3192
|
// todo - add debounce
|
|
2773
3193
|
this._playingCheckerId = window.setTimeout(() => {
|
|
3194
|
+
// console.log({now: Date.now(), _timeupdate: this._timeupdate, currentTime: this._video.currentTime, duration: this._video.duration});
|
|
2774
3195
|
if (Date.now() - this._timeupdate >= this._maxDiff / 2) {
|
|
3196
|
+
// prevent onWaiting triggering if the video has ended
|
|
3197
|
+
if (Math.round(this._video.currentTime) >= Math.round(this._video.duration)) {
|
|
3198
|
+
return;
|
|
3199
|
+
}
|
|
2775
3200
|
this._state = 2 /* VIDEO_STATE.WAITING */;
|
|
2776
3201
|
this._triggerUpdate();
|
|
2777
3202
|
}
|
|
@@ -2854,7 +3279,7 @@ const tryCreateFromHtmlElement = (nodeRef, layer, widgetCallbacks, widgetDeps) =
|
|
|
2854
3279
|
case Text.className():
|
|
2855
3280
|
return new Text(nodeRef, layer);
|
|
2856
3281
|
case Button.className():
|
|
2857
|
-
return new Button(nodeRef, layer);
|
|
3282
|
+
return new Button(nodeRef, layer, widgetDeps);
|
|
2858
3283
|
case Image.className():
|
|
2859
3284
|
return new Image(nodeRef, layer);
|
|
2860
3285
|
case SwipeUp.className():
|
|
@@ -2862,7 +3287,7 @@ const tryCreateFromHtmlElement = (nodeRef, layer, widgetCallbacks, widgetDeps) =
|
|
|
2862
3287
|
case SwipeUpItems.className():
|
|
2863
3288
|
return new SwipeUpItems(nodeRef, layer);
|
|
2864
3289
|
case Video.className():
|
|
2865
|
-
return new Video(nodeRef, layer, layoutApi.VideoPlayer, layer.
|
|
3290
|
+
return new Video(nodeRef, layer, layoutApi.VideoPlayer, layer.slideApiDeps);
|
|
2866
3291
|
//////// widgets ///////
|
|
2867
3292
|
case Copy.className():
|
|
2868
3293
|
return layoutApi.widgetCopyApi ? new Copy(nodeRef, layer, layoutApi.widgetCopyApi, widgetCallbacks, widgetDeps) : null;
|
|
@@ -2920,20 +3345,23 @@ class SlideTimeline {
|
|
|
2920
3345
|
slideDisabledTimer;
|
|
2921
3346
|
slideReady;
|
|
2922
3347
|
_afterAppResumeQueuePush;
|
|
2923
|
-
|
|
2924
|
-
constructor(slideIndex, slideDuration, slideDisabledTimer, slideReady, _afterAppResumeQueuePush,
|
|
3348
|
+
slideApiDeps;
|
|
3349
|
+
constructor(slideIndex, slideDuration, slideDisabledTimer, slideReady, _afterAppResumeQueuePush, slideApiDeps) {
|
|
2925
3350
|
this.slideIndex = slideIndex;
|
|
2926
3351
|
this.slideDuration = slideDuration;
|
|
2927
3352
|
this.slideDisabledTimer = slideDisabledTimer;
|
|
2928
3353
|
this.slideReady = slideReady;
|
|
2929
3354
|
this._afterAppResumeQueuePush = _afterAppResumeQueuePush;
|
|
2930
|
-
this.
|
|
3355
|
+
this.slideApiDeps = slideApiDeps;
|
|
2931
3356
|
this.timelineDisabledState = this.slideDisabledTimer ? TimelineDisabledState.disabled : TimelineDisabledState.enabled;
|
|
2932
3357
|
}
|
|
2933
3358
|
resumedAt = new Date().getTime();
|
|
2934
3359
|
timeSpent = 0;
|
|
2935
3360
|
timelineDisabledState;
|
|
2936
3361
|
currentState = "stop" /* TIMELINE_ACTION.STOP */;
|
|
3362
|
+
deferredDataWaitingStateTimerId = null;
|
|
3363
|
+
deferredResumeStateTimerId = null;
|
|
3364
|
+
dataWaitingStartedAt = null;
|
|
2937
3365
|
static get layoutService() {
|
|
2938
3366
|
return container.get({ identifier: "LayoutService" });
|
|
2939
3367
|
}
|
|
@@ -2941,22 +3369,10 @@ class SlideTimeline {
|
|
|
2941
3369
|
return SlideTimeline.layoutService;
|
|
2942
3370
|
}
|
|
2943
3371
|
get isSDKSupportUpdateTimeline() {
|
|
2944
|
-
|
|
2945
|
-
return Boolean(SlideTimeline.layoutService.env.Android && "updateTimeline" in SlideTimeline.layoutService.env.Android);
|
|
2946
|
-
}
|
|
2947
|
-
else if (this.sdkApi.isIOS) {
|
|
2948
|
-
const mh = SlideTimeline.layoutService.env?.webkit?.messageHandlers ?? {};
|
|
2949
|
-
return "updateTimeline" in mh;
|
|
2950
|
-
}
|
|
2951
|
-
else if (this.sdkApi.isWeb) {
|
|
2952
|
-
return true;
|
|
2953
|
-
}
|
|
2954
|
-
else {
|
|
2955
|
-
return false;
|
|
2956
|
-
}
|
|
3372
|
+
return this.slideApiDeps.isSdkSupportUpdateTimeline();
|
|
2957
3373
|
}
|
|
2958
3374
|
get isSdkSupportTimelineOnBeforeStart() {
|
|
2959
|
-
return this.
|
|
3375
|
+
return this.slideApiDeps.isSdkSupportTimelineOnBeforeStart();
|
|
2960
3376
|
}
|
|
2961
3377
|
get index() {
|
|
2962
3378
|
return this.slideIndex;
|
|
@@ -2964,6 +3380,9 @@ class SlideTimeline {
|
|
|
2964
3380
|
get isTimelineDisabled() {
|
|
2965
3381
|
return this.timelineDisabledState === TimelineDisabledState.disabled;
|
|
2966
3382
|
}
|
|
3383
|
+
get durationMs() {
|
|
3384
|
+
return this.slideDuration;
|
|
3385
|
+
}
|
|
2967
3386
|
async updateTimeline(action, showLoader = false, showError = false) {
|
|
2968
3387
|
// два кейса
|
|
2969
3388
|
// когда есть слои и у слоя вызываем showLayer который вызывает startTimer до старта слайда, потом start от sdk
|
|
@@ -2992,13 +3411,15 @@ class SlideTimeline {
|
|
|
2992
3411
|
//@ts-ignore
|
|
2993
3412
|
// window._log(`updateTimeline 1, a: ${action} ct: ${currentTime} d: ${duration} tds: ${this.timelineDisabledState}`, true);
|
|
2994
3413
|
await this.slideReady.then();
|
|
2995
|
-
//@ts-ignore
|
|
2996
3414
|
// window._log(`updateTimeline, a: ${action} ct: ${currentTime} d: ${duration} tds: ${this.timelineDisabledState}`, true);
|
|
2997
|
-
// console.trace(`updateTimeline ${action} slideIndex: ${this.slideIndex} currentTime:${currentTime} duration:${duration} tds: ${this.timelineDisabledState}`);
|
|
2998
|
-
this.
|
|
3415
|
+
// console.trace(`updateTimeline ${action} slideIndex: ${this.slideIndex} currentTime:${currentTime} duration:${duration} tds: ${this.timelineDisabledState} showLoader: ${showLoader} showError: ${showError}`);
|
|
3416
|
+
this.slideApiDeps.updateTimeline(this.slideIndex, action, currentTime, duration, showLoader, showError);
|
|
3417
|
+
if (action === "pause" /* TIMELINE_ACTION.PAUSE */ && showLoader) {
|
|
3418
|
+
this.dataWaitingStartedAt = Date.now();
|
|
3419
|
+
}
|
|
2999
3420
|
}
|
|
3000
3421
|
/**
|
|
3001
|
-
* trigger timeline update for new slide in sdk, before slide
|
|
3422
|
+
* trigger timeline update for new slide in sdk, before slide start event (prevent timeout in timeline while we wait for video start)
|
|
3002
3423
|
*/
|
|
3003
3424
|
triggerSlideLoadState() {
|
|
3004
3425
|
if (this.isSDKSupportUpdateTimeline && this.isSdkSupportTimelineOnBeforeStart) {
|
|
@@ -3011,7 +3432,7 @@ class SlideTimeline {
|
|
|
3011
3432
|
if (this.timelineDisabledState === TimelineDisabledState.disabled) {
|
|
3012
3433
|
duration = 0;
|
|
3013
3434
|
}
|
|
3014
|
-
this.
|
|
3435
|
+
this.slideApiDeps.updateTimeline(this.slideIndex, "before_start" /* TIMELINE_ACTION.BEFORE_START */, 0, duration, false, false);
|
|
3015
3436
|
}
|
|
3016
3437
|
}
|
|
3017
3438
|
/**
|
|
@@ -3020,6 +3441,7 @@ class SlideTimeline {
|
|
|
3020
3441
|
*/
|
|
3021
3442
|
slideStarted() {
|
|
3022
3443
|
// console.trace("slideStarted");
|
|
3444
|
+
this.onBeforeStateChanged();
|
|
3023
3445
|
if (this.isSDKSupportUpdateTimeline) {
|
|
3024
3446
|
this.resumedAt = new Date().getTime();
|
|
3025
3447
|
this.timeSpent = 0; // for case when instance exists, but we return to slide again
|
|
@@ -3028,6 +3450,7 @@ class SlideTimeline {
|
|
|
3028
3450
|
}
|
|
3029
3451
|
slideRestarted() {
|
|
3030
3452
|
// console.trace("slideRestarted");
|
|
3453
|
+
this.onBeforeStateChanged();
|
|
3031
3454
|
if (this.isSDKSupportUpdateTimeline) {
|
|
3032
3455
|
this.resumedAt = new Date().getTime();
|
|
3033
3456
|
this.timeSpent = 0;
|
|
@@ -3037,11 +3460,12 @@ class SlideTimeline {
|
|
|
3037
3460
|
/**
|
|
3038
3461
|
*
|
|
3039
3462
|
*/
|
|
3040
|
-
slidePaused(
|
|
3463
|
+
slidePaused(currentTime) {
|
|
3041
3464
|
// console.trace("slidePaused");
|
|
3465
|
+
this.onBeforeStateChanged();
|
|
3042
3466
|
if (this.isSDKSupportUpdateTimeline) {
|
|
3043
|
-
if (
|
|
3044
|
-
this.timeSpent = Math.round(
|
|
3467
|
+
if (currentTime != null) {
|
|
3468
|
+
this.timeSpent = Math.round(currentTime);
|
|
3045
3469
|
}
|
|
3046
3470
|
else {
|
|
3047
3471
|
const globalCurrentTime = new Date().getTime();
|
|
@@ -3051,28 +3475,46 @@ class SlideTimeline {
|
|
|
3051
3475
|
this.updateTimeline("pause" /* TIMELINE_ACTION.PAUSE */);
|
|
3052
3476
|
}
|
|
3053
3477
|
else {
|
|
3054
|
-
this.
|
|
3478
|
+
this.slideApiDeps.cardPausedCallback(currentTime);
|
|
3055
3479
|
}
|
|
3056
3480
|
}
|
|
3057
|
-
slideResumed(
|
|
3481
|
+
slideResumed(getVideoCurrentTime) {
|
|
3058
3482
|
// console.trace("slideResumed");
|
|
3483
|
+
this.onBeforeStateChanged();
|
|
3059
3484
|
// @ts-ignore
|
|
3060
3485
|
// window._log(`updateTimeline slideResumed ${videoCurrentTime}`, true);
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3486
|
+
// dataWaitingStartedAt
|
|
3487
|
+
const slideResume = () => {
|
|
3488
|
+
if (this.isSDKSupportUpdateTimeline) {
|
|
3489
|
+
if (getVideoCurrentTime != null) {
|
|
3490
|
+
this.timeSpent = Math.round(getVideoCurrentTime());
|
|
3491
|
+
}
|
|
3492
|
+
this.resumedAt = new Date().getTime();
|
|
3493
|
+
this.updateTimeline("start" /* TIMELINE_ACTION.START */);
|
|
3064
3494
|
}
|
|
3065
|
-
|
|
3066
|
-
|
|
3495
|
+
else {
|
|
3496
|
+
this.slideApiDeps.cardResumedCallback(getVideoCurrentTime != null ? getVideoCurrentTime() : null);
|
|
3497
|
+
}
|
|
3498
|
+
};
|
|
3499
|
+
// prevent micro loaders in UI
|
|
3500
|
+
const delay = 300;
|
|
3501
|
+
let dataWaitingLoaderSpent = delay;
|
|
3502
|
+
if (this.dataWaitingStartedAt != null) {
|
|
3503
|
+
dataWaitingLoaderSpent = Date.now() - this.dataWaitingStartedAt;
|
|
3504
|
+
}
|
|
3505
|
+
if (dataWaitingLoaderSpent < delay) {
|
|
3506
|
+
this.deferredResumeStateTimerId = window.setTimeout(slideResume, dataWaitingLoaderSpent - delay);
|
|
3067
3507
|
}
|
|
3068
3508
|
else {
|
|
3069
|
-
|
|
3509
|
+
slideResume();
|
|
3070
3510
|
}
|
|
3071
3511
|
}
|
|
3072
3512
|
slideStopped() {
|
|
3073
3513
|
// console.trace("slideStopped");
|
|
3514
|
+
this.onBeforeStateChanged();
|
|
3074
3515
|
if (this.isSDKSupportUpdateTimeline) {
|
|
3075
3516
|
this.updateTimeline("stop" /* TIMELINE_ACTION.STOP */);
|
|
3517
|
+
// console.log(`TIMELINE_ACTION -> slideStopped, index: ${this.slideIndex}`);
|
|
3076
3518
|
}
|
|
3077
3519
|
}
|
|
3078
3520
|
/**
|
|
@@ -3080,6 +3522,7 @@ class SlideTimeline {
|
|
|
3080
3522
|
* used by widgets
|
|
3081
3523
|
*/
|
|
3082
3524
|
startDisabledTimeline(fallback) {
|
|
3525
|
+
this.onBeforeStateChanged();
|
|
3083
3526
|
// if app is paused (in background) - don't call start timeline (Android issues)
|
|
3084
3527
|
// @ts-ignore
|
|
3085
3528
|
// window._log(`Push startDisabledTimeline to queue at state: ${window.slideApi.state}, time: ${new Date().getTime()}`, true);
|
|
@@ -3099,6 +3542,7 @@ class SlideTimeline {
|
|
|
3099
3542
|
}
|
|
3100
3543
|
onSlideDataWaiting(videoCurrentTime) {
|
|
3101
3544
|
// console.trace("onSlideDataWaiting");
|
|
3545
|
+
this.onBeforeStateChanged();
|
|
3102
3546
|
// @ts-ignore
|
|
3103
3547
|
// window._log(`updateTimeline onSlideDataWaiting ${videoCurrentTime}`, true);
|
|
3104
3548
|
if (videoCurrentTime != null) {
|
|
@@ -3109,10 +3553,20 @@ class SlideTimeline {
|
|
|
3109
3553
|
let spent = globalCurrentTime - this.resumedAt;
|
|
3110
3554
|
this.timeSpent += spent;
|
|
3111
3555
|
}
|
|
3112
|
-
|
|
3556
|
+
// prevent micro loaders in UI
|
|
3557
|
+
if (this.currentState === "start" /* TIMELINE_ACTION.START */) {
|
|
3558
|
+
this.updateTimeline("pause" /* TIMELINE_ACTION.PAUSE */, false, false);
|
|
3559
|
+
this.deferredDataWaitingStateTimerId = window.setTimeout(() => {
|
|
3560
|
+
this.updateTimeline("pause" /* TIMELINE_ACTION.PAUSE */, true, false);
|
|
3561
|
+
}, 300);
|
|
3562
|
+
}
|
|
3563
|
+
else {
|
|
3564
|
+
this.updateTimeline("pause" /* TIMELINE_ACTION.PAUSE */, true, false);
|
|
3565
|
+
}
|
|
3113
3566
|
}
|
|
3114
3567
|
onSlideError(videoCurrentTime) {
|
|
3115
3568
|
// console.trace("onSlideError");
|
|
3569
|
+
this.onBeforeStateChanged();
|
|
3116
3570
|
if (videoCurrentTime != null) {
|
|
3117
3571
|
this.timeSpent = Math.round(videoCurrentTime);
|
|
3118
3572
|
}
|
|
@@ -3123,7 +3577,21 @@ class SlideTimeline {
|
|
|
3123
3577
|
}
|
|
3124
3578
|
this.updateTimeline("stop" /* TIMELINE_ACTION.STOP */, false, true);
|
|
3125
3579
|
}
|
|
3126
|
-
|
|
3580
|
+
clearDeferredDataWaitingStateTimerId() {
|
|
3581
|
+
if (this.deferredDataWaitingStateTimerId != null) {
|
|
3582
|
+
window.clearTimeout(this.deferredDataWaitingStateTimerId);
|
|
3583
|
+
}
|
|
3584
|
+
}
|
|
3585
|
+
clearDeferredResumeStateTimerId() {
|
|
3586
|
+
if (this.deferredResumeStateTimerId != null) {
|
|
3587
|
+
window.clearTimeout(this.deferredResumeStateTimerId);
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
onBeforeStateChanged() {
|
|
3591
|
+
this.clearDeferredDataWaitingStateTimerId();
|
|
3592
|
+
this.clearDeferredResumeStateTimerId();
|
|
3593
|
+
}
|
|
3594
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`number`, `number`, `boolean`, `Promise`, `(cb: () => void) => void`, `ISlideApiDeps`]; }
|
|
3127
3595
|
}
|
|
3128
3596
|
|
|
3129
3597
|
class Layer {
|
|
@@ -3132,8 +3600,7 @@ class Layer {
|
|
|
3132
3600
|
_slideReadyPromise;
|
|
3133
3601
|
_afterAppResumeQueuePush;
|
|
3134
3602
|
_afterStartInitQueuePush;
|
|
3135
|
-
|
|
3136
|
-
sdkApi;
|
|
3603
|
+
slideApiDeps;
|
|
3137
3604
|
_slideRoot;
|
|
3138
3605
|
_getLayoutDirection;
|
|
3139
3606
|
_slidePauseUI;
|
|
@@ -3149,14 +3616,13 @@ class Layer {
|
|
|
3149
3616
|
_elements = [];
|
|
3150
3617
|
_timeline;
|
|
3151
3618
|
_widgetDeps;
|
|
3152
|
-
constructor(_nodeRef, _slide, _slideReadyPromise, _afterAppResumeQueuePush, _afterStartInitQueuePush,
|
|
3619
|
+
constructor(_nodeRef, _slide, _slideReadyPromise, _afterAppResumeQueuePush, _afterStartInitQueuePush, slideApiDeps, _slideRoot, _getLayoutDirection, _slidePauseUI, _slideResumeUI, _getSdkClientVariables) {
|
|
3153
3620
|
this._nodeRef = _nodeRef;
|
|
3154
3621
|
this._slide = _slide;
|
|
3155
3622
|
this._slideReadyPromise = _slideReadyPromise;
|
|
3156
3623
|
this._afterAppResumeQueuePush = _afterAppResumeQueuePush;
|
|
3157
3624
|
this._afterStartInitQueuePush = _afterStartInitQueuePush;
|
|
3158
|
-
this.
|
|
3159
|
-
this.sdkApi = sdkApi;
|
|
3625
|
+
this.slideApiDeps = slideApiDeps;
|
|
3160
3626
|
this._slideRoot = _slideRoot;
|
|
3161
3627
|
this._getLayoutDirection = _getLayoutDirection;
|
|
3162
3628
|
this._slidePauseUI = _slidePauseUI;
|
|
@@ -3169,16 +3635,16 @@ class Layer {
|
|
|
3169
3635
|
this._duration = parseInt(this._nodeRef.getAttribute("data-duration") ?? "") || DEFAULT_SLIDE_DURATION;
|
|
3170
3636
|
this._disabledTimer = this._nodeRef.getAttribute("data-disable-timer") === "1";
|
|
3171
3637
|
this._disabledNavigation = this._nodeRef.getAttribute("data-disable-navigation") === "1";
|
|
3172
|
-
this._timeline = new SlideTimeline(this._slideIndex, this._duration, this._disabledTimer, this._slideReadyPromise, this._afterAppResumeQueuePush, this.
|
|
3638
|
+
this._timeline = new SlideTimeline(this._slideIndex, this._duration, this._disabledTimer, this._slideReadyPromise, this._afterAppResumeQueuePush, this.slideApiDeps);
|
|
3173
3639
|
this._widgetDeps = {
|
|
3174
|
-
|
|
3640
|
+
slideApiDeps: this.slideApiDeps,
|
|
3175
3641
|
slideRoot: this._slideRoot,
|
|
3176
3642
|
getLayoutDirection: this._getLayoutDirection,
|
|
3177
3643
|
getSdkClientVariables: this._getSdkClientVariables,
|
|
3178
3644
|
};
|
|
3179
3645
|
const onWidgetComplete = (cardId, slideIndex) => {
|
|
3180
3646
|
// todo if nothing more widgets with disabled timers - we can start layer timeline
|
|
3181
|
-
const fallback = () => this.
|
|
3647
|
+
const fallback = () => this.slideApiDeps.showNextSlide(DEFAULT_SLIDE_DURATION);
|
|
3182
3648
|
// для android sdk важно чтобы этот метод вызывался только после slide_start
|
|
3183
3649
|
this._afterStartInitQueuePush(() => {
|
|
3184
3650
|
this._timeline.startDisabledTimeline(fallback);
|
|
@@ -3220,17 +3686,17 @@ class Layer {
|
|
|
3220
3686
|
}
|
|
3221
3687
|
}
|
|
3222
3688
|
init(localData) {
|
|
3223
|
-
if (this.
|
|
3689
|
+
if (this.slideApiDeps.isIOS || this.slideApiDeps.isAndroid) {
|
|
3224
3690
|
this._nodeRef.classList.add("_app");
|
|
3225
|
-
this.
|
|
3226
|
-
this.
|
|
3691
|
+
this.slideApiDeps.isIOS && this._nodeRef.classList.add("_isIos");
|
|
3692
|
+
this.slideApiDeps.isAndroid && this._nodeRef.classList.add("_isAndroid");
|
|
3227
3693
|
}
|
|
3228
|
-
this.
|
|
3694
|
+
this.slideApiDeps.cardAnimation?.init(this._nodeRef);
|
|
3229
3695
|
const promises = this._elements.map(element => element.init(localData));
|
|
3230
3696
|
return promises;
|
|
3231
3697
|
}
|
|
3232
3698
|
onAfterAllMediaResourcesLoaded() {
|
|
3233
|
-
if (this.
|
|
3699
|
+
if (this.slideApiDeps.isIOS) ;
|
|
3234
3700
|
this._initTextFit();
|
|
3235
3701
|
}
|
|
3236
3702
|
get nodeRef() {
|
|
@@ -3249,7 +3715,10 @@ class Layer {
|
|
|
3249
3715
|
return container.get({ identifier: "LayoutService" });
|
|
3250
3716
|
}
|
|
3251
3717
|
getLocalData() {
|
|
3252
|
-
return this.
|
|
3718
|
+
return this.slideApiDeps.getCardLocalData();
|
|
3719
|
+
}
|
|
3720
|
+
findElementByNodeRef(nodeRef) {
|
|
3721
|
+
return this._elements.find(element => element.nodeRef === nodeRef);
|
|
3253
3722
|
}
|
|
3254
3723
|
get isQuest() {
|
|
3255
3724
|
return this._nodeRef.getAttribute("data-quest-count") != null;
|
|
@@ -3402,14 +3871,19 @@ class Layer {
|
|
|
3402
3871
|
const videoElement = this.videoElement;
|
|
3403
3872
|
let currentTime = 0;
|
|
3404
3873
|
if (videoElement != null) {
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3874
|
+
const getVideoIsLooped = () => {
|
|
3875
|
+
let videoLoop = false;
|
|
3876
|
+
if (this.timeline.isTimelineDisabled || this.timeline.durationMs > videoElement.durationMs) {
|
|
3877
|
+
videoLoop = true;
|
|
3878
|
+
}
|
|
3879
|
+
// console.log({videoLoop, isTimelineDisabled: this.timeline.isTimelineDisabled, timelineDurationMs: this.timeline.durationMs, videoElementDurationMs: videoElement.durationMs});
|
|
3880
|
+
return videoLoop;
|
|
3881
|
+
};
|
|
3882
|
+
// todo - need to convert to ms ?
|
|
3883
|
+
currentTime = (await videoElement.start(muted, getVideoIsLooped)).getVideoCurrentTime();
|
|
3410
3884
|
}
|
|
3411
|
-
if (this.
|
|
3412
|
-
this._animationPauseCb = this.
|
|
3885
|
+
if (this.slideApiDeps.cardAnimation) {
|
|
3886
|
+
this._animationPauseCb = this.slideApiDeps.cardAnimation.start(this._nodeRef);
|
|
3413
3887
|
}
|
|
3414
3888
|
for (const element of this._elements) {
|
|
3415
3889
|
element.onStart();
|
|
@@ -3425,7 +3899,7 @@ class Layer {
|
|
|
3425
3899
|
}
|
|
3426
3900
|
async stop(options) {
|
|
3427
3901
|
this.videoElement?.stop(options);
|
|
3428
|
-
this.
|
|
3902
|
+
this.slideApiDeps.cardAnimation?.stop(this._nodeRef);
|
|
3429
3903
|
for (const element of this._elements) {
|
|
3430
3904
|
element.onPause();
|
|
3431
3905
|
}
|
|
@@ -3436,7 +3910,7 @@ class Layer {
|
|
|
3436
3910
|
}
|
|
3437
3911
|
stopInternal(options) {
|
|
3438
3912
|
this.videoElement?.stop(options);
|
|
3439
|
-
this.
|
|
3913
|
+
this.slideApiDeps.cardAnimation?.stop(this._nodeRef);
|
|
3440
3914
|
for (const element of this._elements) {
|
|
3441
3915
|
element.onPause();
|
|
3442
3916
|
}
|
|
@@ -3448,17 +3922,21 @@ class Layer {
|
|
|
3448
3922
|
return new Promise(resolve => {
|
|
3449
3923
|
const cb = () => {
|
|
3450
3924
|
let currentTime = this.videoElement?.pause(resetVideoTime) ?? null;
|
|
3925
|
+
if (this.videoElement?.isLooped) {
|
|
3926
|
+
// skip currentTime from looped video (bcz in that case video time does not associated with timeline)
|
|
3927
|
+
currentTime = null;
|
|
3928
|
+
}
|
|
3929
|
+
if (currentTime != null) {
|
|
3930
|
+
currentTime *= 1000;
|
|
3931
|
+
}
|
|
3451
3932
|
if (stopAnimation) {
|
|
3452
|
-
this.
|
|
3933
|
+
this.slideApiDeps.cardAnimation?.stop(this._nodeRef);
|
|
3453
3934
|
}
|
|
3454
3935
|
else {
|
|
3455
3936
|
if (this._animationPauseCb != null && isFunction(this._animationPauseCb)) {
|
|
3456
3937
|
this._animationResumeCb = this._animationPauseCb(false);
|
|
3457
3938
|
}
|
|
3458
3939
|
}
|
|
3459
|
-
if (currentTime != null) {
|
|
3460
|
-
currentTime *= 1000;
|
|
3461
|
-
}
|
|
3462
3940
|
for (const element of this._elements) {
|
|
3463
3941
|
element.onPause();
|
|
3464
3942
|
}
|
|
@@ -3478,26 +3956,23 @@ class Layer {
|
|
|
3478
3956
|
}
|
|
3479
3957
|
async resume() {
|
|
3480
3958
|
return new Promise(resolve => {
|
|
3481
|
-
const cb = ({
|
|
3959
|
+
const cb = ({ getVideoCurrentTime }) => {
|
|
3482
3960
|
// console.log("resumed cb with currentTime", { currentTime });
|
|
3483
|
-
if (currentTime != null) {
|
|
3484
|
-
currentTime *= 1000;
|
|
3485
|
-
}
|
|
3486
3961
|
if (isFunction(this._animationResumeCb)) {
|
|
3487
3962
|
this._animationResumeCb();
|
|
3488
3963
|
}
|
|
3489
3964
|
for (const element of this._elements) {
|
|
3490
3965
|
element.onResume();
|
|
3491
3966
|
}
|
|
3492
|
-
this.timeline.slideResumed(
|
|
3493
|
-
resolve({ currentTime });
|
|
3967
|
+
this.timeline.slideResumed(getVideoCurrentTime != null ? () => getVideoCurrentTime() * 1000 : undefined);
|
|
3968
|
+
resolve({ currentTime: getVideoCurrentTime != null ? getVideoCurrentTime() : null });
|
|
3494
3969
|
};
|
|
3495
3970
|
const videoStartedPromise = this.videoElement?.resume();
|
|
3496
3971
|
if (videoStartedPromise != null && videoStartedPromise.then != null) {
|
|
3497
3972
|
videoStartedPromise.then(cb);
|
|
3498
3973
|
}
|
|
3499
3974
|
else {
|
|
3500
|
-
cb({
|
|
3975
|
+
cb({ getVideoCurrentTime: undefined });
|
|
3501
3976
|
}
|
|
3502
3977
|
});
|
|
3503
3978
|
}
|
|
@@ -3513,7 +3988,7 @@ class Layer {
|
|
|
3513
3988
|
get isLayerForcePaused() {
|
|
3514
3989
|
return this.elements.some(element => element.isLayerForcePaused);
|
|
3515
3990
|
}
|
|
3516
|
-
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Slide`, `Promise`, `(cb: () => void) => void`, `(cb: () => void) => void`, `
|
|
3991
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Slide`, `Promise`, `(cb: () => void) => void`, `(cb: () => void) => void`, `ISlideApiDeps`, `HTMLElement`, `() => "ltr" | "rtl"`, `() => Promise<void>`, `() => Promise<void>`, `GetSdkClientVariables`]; }
|
|
3517
3992
|
}
|
|
3518
3993
|
const TextFit = (function () {
|
|
3519
3994
|
const defaultSettings = {
|
|
@@ -3704,8 +4179,7 @@ class Slide {
|
|
|
3704
4179
|
_slideReadyPromise;
|
|
3705
4180
|
_afterAppResumeQueuePush;
|
|
3706
4181
|
_afterStartInitQueuePush;
|
|
3707
|
-
|
|
3708
|
-
sdkApi;
|
|
4182
|
+
slideApiDeps;
|
|
3709
4183
|
_slideRoot;
|
|
3710
4184
|
_getLayoutDirection;
|
|
3711
4185
|
_slidePauseUI;
|
|
@@ -3713,13 +4187,12 @@ class Slide {
|
|
|
3713
4187
|
_getSdkClientVariables;
|
|
3714
4188
|
_layers;
|
|
3715
4189
|
_start;
|
|
3716
|
-
constructor(_slidesNodesRefs, _slideReadyPromise, _afterAppResumeQueuePush, _afterStartInitQueuePush,
|
|
4190
|
+
constructor(_slidesNodesRefs, _slideReadyPromise, _afterAppResumeQueuePush, _afterStartInitQueuePush, slideApiDeps, _slideRoot, _getLayoutDirection, _slidePauseUI, _slideResumeUI, _getSdkClientVariables) {
|
|
3717
4191
|
this._slidesNodesRefs = _slidesNodesRefs;
|
|
3718
4192
|
this._slideReadyPromise = _slideReadyPromise;
|
|
3719
4193
|
this._afterAppResumeQueuePush = _afterAppResumeQueuePush;
|
|
3720
4194
|
this._afterStartInitQueuePush = _afterStartInitQueuePush;
|
|
3721
|
-
this.
|
|
3722
|
-
this.sdkApi = sdkApi;
|
|
4195
|
+
this.slideApiDeps = slideApiDeps;
|
|
3723
4196
|
this._slideRoot = _slideRoot;
|
|
3724
4197
|
this._getLayoutDirection = _getLayoutDirection;
|
|
3725
4198
|
this._slidePauseUI = _slidePauseUI;
|
|
@@ -3729,7 +4202,7 @@ class Slide {
|
|
|
3729
4202
|
if (!this._slidesNodesRefs.length) {
|
|
3730
4203
|
throw new Error("No slides found.");
|
|
3731
4204
|
}
|
|
3732
|
-
this._layers = this._slidesNodesRefs.map(item => new Layer(item, this, this._slideReadyPromise, this._afterAppResumeQueuePush, this._afterStartInitQueuePush, this.
|
|
4205
|
+
this._layers = this._slidesNodesRefs.map(item => new Layer(item, this, this._slideReadyPromise, this._afterAppResumeQueuePush, this._afterStartInitQueuePush, this.slideApiDeps, this._slideRoot, this._getLayoutDirection, this._slidePauseUI, this._slideResumeUI, this._getSdkClientVariables));
|
|
3733
4206
|
this._activeLayer = this._layers[0];
|
|
3734
4207
|
}
|
|
3735
4208
|
_activeLayer;
|
|
@@ -3749,7 +4222,7 @@ class Slide {
|
|
|
3749
4222
|
if (multiSlideApi != null && this.layers.length > 1) {
|
|
3750
4223
|
try {
|
|
3751
4224
|
multiSlideApi.init(this.layersNodesRefs, localData, {
|
|
3752
|
-
|
|
4225
|
+
slideApiDeps: this.slideApiDeps,
|
|
3753
4226
|
slideRoot: this._slideRoot,
|
|
3754
4227
|
getLayoutDirection: this._getLayoutDirection,
|
|
3755
4228
|
getSdkClientVariables: this._getSdkClientVariables,
|
|
@@ -3826,7 +4299,7 @@ class Slide {
|
|
|
3826
4299
|
get disabledNavigation() {
|
|
3827
4300
|
return this._activeLayer.disabledNavigation;
|
|
3828
4301
|
}
|
|
3829
|
-
static get [Symbol.for("___CTOR_ARGS___")]() { return [`Array`, `Promise`, `(cb: () => void) => void`, `(cb: () => void) => void`, `
|
|
4302
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`Array`, `Promise`, `(cb: () => void) => void`, `(cb: () => void) => void`, `ISlideApiDeps`, `HTMLElement`, `() => "ltr" | "rtl"`, `() => Promise<void>`, `() => Promise<void>`, `GetSdkClientVariables`]; }
|
|
3830
4303
|
}
|
|
3831
4304
|
|
|
3832
4305
|
let SlideApi$1 = class SlideApi {
|
|
@@ -3843,20 +4316,29 @@ let SlideApi$1 = class SlideApi {
|
|
|
3843
4316
|
_getViewportHeight;
|
|
3844
4317
|
_overlappingActionBarHeight;
|
|
3845
4318
|
_separateUserAndAppPause;
|
|
3846
|
-
|
|
4319
|
+
_index;
|
|
4320
|
+
slideApiDeps;
|
|
3847
4321
|
constructor(config) {
|
|
3848
4322
|
this.config = config;
|
|
3849
|
-
this.
|
|
4323
|
+
this.slideApiDeps = config.slideApiDeps;
|
|
3850
4324
|
this._slideWrapper = config.slideWrapper;
|
|
3851
4325
|
this._viewport = config.viewport;
|
|
3852
4326
|
this._getViewportWidth = config.getViewportWidth;
|
|
3853
4327
|
this._getViewportHeight = config.getViewportHeight;
|
|
3854
4328
|
this._overlappingActionBarHeight = config.overlappingActionBarHeight ?? 0;
|
|
3855
4329
|
this._separateUserAndAppPause = config.separateUserAndAppPause;
|
|
3856
|
-
this.
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
4330
|
+
this._index = config.index;
|
|
4331
|
+
}
|
|
4332
|
+
static checkPreloadedInLayoutSlide() {
|
|
4333
|
+
// for sdk backward compatibility
|
|
4334
|
+
const slideBox = document.getElementById("narrative-slide-box");
|
|
4335
|
+
if (slideBox && slideBox.innerText.trim() !== "{%content}".replace("{", "{{").replace("}", "}}")) {
|
|
4336
|
+
return true;
|
|
4337
|
+
}
|
|
4338
|
+
return false;
|
|
4339
|
+
}
|
|
4340
|
+
initPreloadedInLayoutSlide(slideLoadedCb) {
|
|
4341
|
+
// for sdk backward compatibility
|
|
3860
4342
|
const slideBox = document.getElementById("narrative-slide-box");
|
|
3861
4343
|
// todo via first child and its innerText - faster variant
|
|
3862
4344
|
if (slideBox && slideBox.innerText.trim() !== "{%content}".replace("{", "{{").replace("}", "}}")) {
|
|
@@ -3864,117 +4346,42 @@ let SlideApi$1 = class SlideApi {
|
|
|
3864
4346
|
this._slideInRender = true;
|
|
3865
4347
|
this._init(() => this._slideBoxRenderComplete(null)).then(({ slide, result, reason }) => {
|
|
3866
4348
|
this._slide = slide;
|
|
3867
|
-
if (
|
|
3868
|
-
|
|
4349
|
+
if (slideLoadedCb != null) {
|
|
4350
|
+
slideLoadedCb({ cardId: slide.cardId, slideIndex: slide.slideIndex, result, reason });
|
|
3869
4351
|
}
|
|
3870
4352
|
});
|
|
3871
4353
|
}
|
|
3872
4354
|
}
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
}
|
|
3883
|
-
destroyListeners() {
|
|
3884
|
-
this._viewport.removeEventListener("resize", this.refreshSizes);
|
|
3885
|
-
}
|
|
3886
|
-
_savedViewportWidth = null;
|
|
3887
|
-
_savedViewportHeight = null;
|
|
3888
|
-
refreshSizes() {
|
|
3889
|
-
const viewportWidth = this._getViewportWidth();
|
|
3890
|
-
const viewportHeight = this._getViewportHeight();
|
|
3891
|
-
if (this._savedViewportWidth === viewportWidth && this._savedViewportHeight === viewportHeight) {
|
|
3892
|
-
return;
|
|
3893
|
-
}
|
|
3894
|
-
this._savedViewportWidth = viewportWidth;
|
|
3895
|
-
this._savedViewportHeight = viewportHeight;
|
|
3896
|
-
const viewportRatio = viewportWidth / viewportHeight;
|
|
3897
|
-
let slideWidth = 0;
|
|
3898
|
-
let slideHeight = 0;
|
|
3899
|
-
// _ratio = 310 / 480,
|
|
3900
|
-
const _ratio = this.config.slideRatio;
|
|
3901
|
-
let _isFullscreen = this.config.isFullscreen;
|
|
3902
|
-
const slideOffset = this._slideWrapper.querySelector(".narrative-slide-offset");
|
|
3903
|
-
let offset = 0;
|
|
3904
|
-
let xOffset = "0px";
|
|
3905
|
-
// for elements with bottom anchor (absolute position)
|
|
3906
|
-
let yOffset = "0px";
|
|
3907
|
-
// alert(viewportHeight);
|
|
3908
|
-
// todo - mobile only (or isIos or isAndroid)
|
|
3909
|
-
if (this.sdkApi.isAndroid || this.sdkApi.isIOS) {
|
|
3910
|
-
if (viewportRatio > _ratio) {
|
|
3911
|
-
// disable _isFullscreen if viewport small
|
|
3912
|
-
_isFullscreen = false;
|
|
3913
|
-
}
|
|
3914
|
-
}
|
|
3915
|
-
if (_isFullscreen) {
|
|
3916
|
-
// более квадратное чем надо (desktop)
|
|
3917
|
-
if (viewportRatio > _ratio) {
|
|
3918
|
-
// fit by height
|
|
3919
|
-
slideHeight = viewportHeight;
|
|
3920
|
-
slideWidth = Math.ceil(slideHeight * _ratio);
|
|
3921
|
-
offset = Math.ceil(slideWidth - viewportWidth) / 2;
|
|
3922
|
-
if (slideOffset != null) {
|
|
3923
|
-
slideOffset.style.margin = "0 " + -offset + "px"; // -8.5
|
|
3924
|
-
}
|
|
3925
|
-
xOffset = offset + "px";
|
|
3926
|
-
}
|
|
3927
|
-
else {
|
|
3928
|
-
// fit by width, top and bottom - to offscreen or fill with bg image
|
|
3929
|
-
slideWidth = viewportWidth;
|
|
3930
|
-
slideHeight = Math.ceil(viewportWidth / _ratio);
|
|
3931
|
-
offset = Math.ceil(slideHeight - viewportHeight) / 2;
|
|
3932
|
-
if (slideOffset != null) {
|
|
3933
|
-
slideOffset.style.margin = -1 * offset + "px" + " 0 ";
|
|
3934
|
-
}
|
|
3935
|
-
// offset from viewport bottom to StoryBottom plus safe area offset bottom
|
|
3936
|
-
yOffset = `calc(${offset + this._overlappingActionBarHeight}px + env(safe-area-inset-bottom))`;
|
|
3937
|
-
// detect safe area offset
|
|
3938
|
-
}
|
|
3939
|
-
}
|
|
3940
|
-
else {
|
|
3941
|
-
// более квадратное чем надо
|
|
3942
|
-
if (viewportRatio > _ratio) {
|
|
3943
|
-
// fit by width, top and bottom - to offscreen
|
|
3944
|
-
slideWidth = viewportWidth;
|
|
3945
|
-
slideHeight = Math.ceil(viewportWidth / _ratio);
|
|
3946
|
-
offset = Math.ceil(slideHeight - viewportHeight) / 2;
|
|
3947
|
-
if (slideOffset != null) {
|
|
3948
|
-
slideOffset.style.margin = -offset + "px" + " 0 ";
|
|
3949
|
-
}
|
|
3950
|
-
yOffset = offset + this._overlappingActionBarHeight + "px";
|
|
4355
|
+
onUpdateSizeMetrics({ fontSize, xOffset, yOffset, isFullscreen, slideOffsetMargin }) {
|
|
4356
|
+
// todo CSP violation
|
|
4357
|
+
this._slideWrapper.style.fontSize = fontSize;
|
|
4358
|
+
if (this.slideOffsetElement != null) {
|
|
4359
|
+
// todo CSP violation
|
|
4360
|
+
this.slideOffsetElement.style.setProperty("--y-offset", yOffset);
|
|
4361
|
+
this.slideOffsetElement.style.setProperty("--x-offset", xOffset);
|
|
4362
|
+
if (isFullscreen) {
|
|
4363
|
+
this.slideOffsetElement.classList.add("narrative-slide-offset-fullscreen");
|
|
3951
4364
|
}
|
|
3952
4365
|
else {
|
|
3953
|
-
|
|
3954
|
-
// fit by height, sides - to offscreen
|
|
3955
|
-
slideHeight = viewportHeight;
|
|
3956
|
-
slideWidth = Math.ceil(slideHeight * _ratio);
|
|
3957
|
-
offset = Math.ceil(slideWidth - viewportWidth) / 2;
|
|
3958
|
-
if (slideOffset != null) {
|
|
3959
|
-
slideOffset.style.margin = "0 " + -offset + "px"; // -8.5
|
|
3960
|
-
}
|
|
3961
|
-
xOffset = offset + "px";
|
|
4366
|
+
this.slideOffsetElement.classList.remove("narrative-slide-offset-fullscreen");
|
|
3962
4367
|
}
|
|
4368
|
+
this.slideOffsetElement.style.margin = slideOffsetMargin;
|
|
3963
4369
|
}
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
this._slideWrapper
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
if (this.
|
|
3976
|
-
this.
|
|
4370
|
+
}
|
|
4371
|
+
get slideWrapperElement() {
|
|
4372
|
+
return this._slideWrapper;
|
|
4373
|
+
}
|
|
4374
|
+
get slideOffsetElement() {
|
|
4375
|
+
return this._slideWrapper.querySelector(".narrative-slide-offset");
|
|
4376
|
+
}
|
|
4377
|
+
get index() {
|
|
4378
|
+
return this._index;
|
|
4379
|
+
}
|
|
4380
|
+
async destroy() {
|
|
4381
|
+
if (this.slide != null) {
|
|
4382
|
+
await this.slide.onBeforeUnmount();
|
|
3977
4383
|
}
|
|
4384
|
+
this._state = 13 /* STATE.DESTROYED */;
|
|
3978
4385
|
}
|
|
3979
4386
|
async showSlide(html) {
|
|
3980
4387
|
const slideBox = this._slideWrapper.querySelector(`.${SlideApi.renderedBoxClassName}`);
|
|
@@ -3987,7 +4394,9 @@ let SlideApi$1 = class SlideApi {
|
|
|
3987
4394
|
}
|
|
3988
4395
|
this._slideInInit = null;
|
|
3989
4396
|
this._slideInRender = true;
|
|
3990
|
-
|
|
4397
|
+
if (html != null) {
|
|
4398
|
+
slideBoxPrerender.innerHTML = html;
|
|
4399
|
+
}
|
|
3991
4400
|
const prevSlide = this.slide ? Object.assign(Object.create(Object.getPrototypeOf(this.slide)), this.slide) : null;
|
|
3992
4401
|
const { slide, result, reason } = await this._init(() => this._slideBoxRenderComplete(prevSlide));
|
|
3993
4402
|
this._slide = slide;
|
|
@@ -4009,7 +4418,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4009
4418
|
return container.get({ identifier: "LayoutService" });
|
|
4010
4419
|
}
|
|
4011
4420
|
getLocalData() {
|
|
4012
|
-
return this.
|
|
4421
|
+
return this.slideApiDeps.getCardLocalData();
|
|
4013
4422
|
}
|
|
4014
4423
|
_fontsInit = false;
|
|
4015
4424
|
_initAndLoadFonts(fonts) {
|
|
@@ -4101,7 +4510,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4101
4510
|
/**
|
|
4102
4511
|
* For case when SlideApi instance was created before root was attached to DOM
|
|
4103
4512
|
*/
|
|
4104
|
-
this.refreshSizes();
|
|
4513
|
+
// this.config.refreshSizes(this);
|
|
4105
4514
|
const slideNodeRef = this._slideWrapper.querySelector(`.${SlideApi.prerenderBoxClassName} .narrative-slide`);
|
|
4106
4515
|
const slidesNodesRefs = Array.prototype.slice.call(this._slideWrapper.querySelectorAll(`.${SlideApi.prerenderBoxClassName} .narrative-slide.narrative-multi-slide`));
|
|
4107
4516
|
if (!slidesNodesRefs.length && slideNodeRef != null) {
|
|
@@ -4114,17 +4523,18 @@ let SlideApi$1 = class SlideApi {
|
|
|
4114
4523
|
const slideReadyPromise = new Promise(resolve => {
|
|
4115
4524
|
slideReadyResolve = resolve;
|
|
4116
4525
|
});
|
|
4117
|
-
const slide = new Slide(slidesNodesRefs, slideReadyPromise, this.afterAppResumeQueuePush.bind(this), this.afterStartInitQueuePush.bind(this), this.
|
|
4526
|
+
const slide = new Slide(slidesNodesRefs, slideReadyPromise, this.afterAppResumeQueuePush.bind(this), this.afterStartInitQueuePush.bind(this), this.slideApiDeps, this._slideWrapper, () => this.layoutDirection, this.slidePauseUI.bind(this), this.slideResumeUI.bind(this), this.config.getSdkClientVariables);
|
|
4118
4527
|
this._slideInInit = slide;
|
|
4528
|
+
// todo - call via DI
|
|
4119
4529
|
slide.activeLayer.timeline.triggerSlideLoadState();
|
|
4120
|
-
if (this.
|
|
4530
|
+
if (this.slideApiDeps.isAndroid) {
|
|
4121
4531
|
this._afterStartInitQueue = [];
|
|
4122
4532
|
}
|
|
4123
4533
|
this._afterAppResumeQueue = [];
|
|
4124
4534
|
const result = { slide, result: false, reason: "" };
|
|
4125
4535
|
try {
|
|
4126
4536
|
const onAllMediaLoaded = this._onAllMediaLoaded(slide);
|
|
4127
|
-
const fontsPromise = this._initAndLoadFonts(this.
|
|
4537
|
+
const fontsPromise = this._initAndLoadFonts(this.slideApiDeps.getCardFonts());
|
|
4128
4538
|
const mediaAndFontsPromise = Promise.all([onAllMediaLoaded, fontsPromise]).then(() => {
|
|
4129
4539
|
this.layoutService.env.clearTimeout(mediaResourcesTimeoutId);
|
|
4130
4540
|
});
|
|
@@ -4223,7 +4633,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4223
4633
|
this._slideConfig = config;
|
|
4224
4634
|
// start deferred fncs from widgets
|
|
4225
4635
|
// important - Android only
|
|
4226
|
-
if (this.
|
|
4636
|
+
if (this.slideApiDeps.isAndroid && this._afterStartInitQueue && Array.isArray(this._afterStartInitQueue)) {
|
|
4227
4637
|
for (const job of this._afterStartInitQueue) {
|
|
4228
4638
|
if (isFunction(job)) {
|
|
4229
4639
|
job();
|
|
@@ -4277,7 +4687,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4277
4687
|
this._state = 9 /* STATE.USER_PAUSED */;
|
|
4278
4688
|
};
|
|
4279
4689
|
// todo move to Android adapter
|
|
4280
|
-
if (this.
|
|
4690
|
+
if (this.slideApiDeps.isAndroid && !this.slideApiDeps.isSdkSupportCorrectPauseResumeLifecycle()) {
|
|
4281
4691
|
this._pauseCbTimer = this.layoutService.env.setTimeout(pauseCb, 300);
|
|
4282
4692
|
}
|
|
4283
4693
|
else {
|
|
@@ -4336,7 +4746,9 @@ let SlideApi$1 = class SlideApi {
|
|
|
4336
4746
|
this._state = 5 /* STATE.RESUMED */;
|
|
4337
4747
|
}
|
|
4338
4748
|
async slideStop(options) {
|
|
4339
|
-
|
|
4749
|
+
// console.log(`TIMELINE_ACTION -> STOP, index: ${this.slide.slideIndex}, state: ${this._state}`);
|
|
4750
|
+
// из состояния START (слайд (например с видео) еще не стартовал) тоже позволяем прерывать - чтобы был правильный LC при быстром пролистывании слайдера
|
|
4751
|
+
if (!(this._state === 2 /* STATE.START */ || this._state === 3 /* STATE.STARTED */ || this._state === 5 /* STATE.RESUMED */ || this._state === 9 /* STATE.USER_PAUSED */)) {
|
|
4340
4752
|
return;
|
|
4341
4753
|
}
|
|
4342
4754
|
this._state = 11 /* STATE.STOP */;
|
|
@@ -4351,10 +4763,10 @@ let SlideApi$1 = class SlideApi {
|
|
|
4351
4763
|
const defaultAction = () => {
|
|
4352
4764
|
const nextSlideIndex = this.slide.slideIndex + 1;
|
|
4353
4765
|
if (nextSlideIndex >= 0 && nextSlideIndex < this.slide.slideCount) {
|
|
4354
|
-
this.
|
|
4766
|
+
this.slideApiDeps.showCardSlide(nextSlideIndex);
|
|
4355
4767
|
}
|
|
4356
4768
|
else {
|
|
4357
|
-
this.
|
|
4769
|
+
this.slideApiDeps.cardShowNext();
|
|
4358
4770
|
}
|
|
4359
4771
|
};
|
|
4360
4772
|
if (this.activeLayer.questElement) {
|
|
@@ -4401,7 +4813,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4401
4813
|
if (!isFunction(cb)) {
|
|
4402
4814
|
return false;
|
|
4403
4815
|
}
|
|
4404
|
-
if (this.
|
|
4816
|
+
if (this.slideApiDeps.isAndroid && this._state === 0 /* STATE.INIT */) {
|
|
4405
4817
|
this._afterStartInitQueue.push(cb);
|
|
4406
4818
|
}
|
|
4407
4819
|
else {
|
|
@@ -4530,7 +4942,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4530
4942
|
if (this.layoutService.layoutApi.widgetVoteApi) {
|
|
4531
4943
|
if (this.layoutService.layoutApi.widgetVoteApi.click(element)) {
|
|
4532
4944
|
this.layoutService.env.setTimeout(() => {
|
|
4533
|
-
this.
|
|
4945
|
+
this.slideApiDeps.showNextSlide(0);
|
|
4534
4946
|
});
|
|
4535
4947
|
}
|
|
4536
4948
|
result.canClickNext = false;
|
|
@@ -4554,7 +4966,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4554
4966
|
}
|
|
4555
4967
|
if (element) {
|
|
4556
4968
|
this.layoutService.env.setTimeout(() => {
|
|
4557
|
-
this.
|
|
4969
|
+
this.slideApiDeps.showNextSlide(0);
|
|
4558
4970
|
});
|
|
4559
4971
|
result.canClickNext = false;
|
|
4560
4972
|
return result;
|
|
@@ -4582,7 +4994,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4582
4994
|
if (this.layoutService.layoutApi.widgetRangeSliderApi) {
|
|
4583
4995
|
if (this.layoutService.layoutApi.widgetRangeSliderApi.click(element)) {
|
|
4584
4996
|
this.layoutService.env.setTimeout(() => {
|
|
4585
|
-
this.
|
|
4997
|
+
this.slideApiDeps.showNextSlide(0);
|
|
4586
4998
|
});
|
|
4587
4999
|
}
|
|
4588
5000
|
result.canClickNext = false;
|
|
@@ -4789,18 +5201,18 @@ let SlideApi$1 = class SlideApi {
|
|
|
4789
5201
|
}
|
|
4790
5202
|
if (element) {
|
|
4791
5203
|
propagation = false;
|
|
4792
|
-
this.
|
|
4793
|
-
this.
|
|
5204
|
+
this.slideApiDeps.setCardLocalData({}, true);
|
|
5205
|
+
this.slideApiDeps.updateCardServerDataLocally(this.slide.cardId, {});
|
|
4794
5206
|
// window._resetTimers();
|
|
4795
5207
|
// сделать async в ios
|
|
4796
5208
|
let slideIndex = this.slide.slideIndex;
|
|
4797
5209
|
// prevent simultaneous call _showNarrativeSlide and _showLayer - prevent 2 calls of initAfterLoad (break video start on iOS)
|
|
4798
5210
|
if (slideIndex === 0) {
|
|
4799
5211
|
// for story repeat on the first slide with layers
|
|
4800
|
-
this.
|
|
5212
|
+
this.slideApiDeps.showLayer(0);
|
|
4801
5213
|
}
|
|
4802
5214
|
else {
|
|
4803
|
-
this.
|
|
5215
|
+
this.slideApiDeps.showCardSlide(0); // сделать ее async
|
|
4804
5216
|
}
|
|
4805
5217
|
}
|
|
4806
5218
|
// todo в каждом виджете делать выход через
|
|
@@ -4888,44 +5300,44 @@ let SlideApi$1 = class SlideApi {
|
|
|
4888
5300
|
// this.activeLayer.timeline.slidePaused(0);
|
|
4889
5301
|
// return {handled: true};
|
|
4890
5302
|
}
|
|
4891
|
-
if (this.
|
|
5303
|
+
if (this.slideApiDeps.isAndroid && linkTargetAndroid) {
|
|
4892
5304
|
linkTarget = linkTargetAndroid;
|
|
4893
5305
|
}
|
|
4894
|
-
if (this.
|
|
5306
|
+
if (this.slideApiDeps.isIOS && linkTargetIos) {
|
|
4895
5307
|
linkTarget = linkTargetIos;
|
|
4896
5308
|
}
|
|
4897
|
-
if (this.
|
|
5309
|
+
if (this.slideApiDeps.isWeb && linkTargetWeb) {
|
|
4898
5310
|
linkTarget = linkTargetWeb;
|
|
4899
5311
|
}
|
|
4900
5312
|
// for btn(link) without url (openGame, openStory, closeCard, products, goods, etc)
|
|
4901
5313
|
let statisticWidgetValue = linkType;
|
|
4902
5314
|
let statisticWidgetEventType = "w-link";
|
|
4903
5315
|
if (linkType === "closeStory" || linkType === "closeIAM") {
|
|
4904
|
-
this.layoutService.env.setTimeout(() => this.
|
|
5316
|
+
this.layoutService.env.setTimeout(() => this.slideApiDeps.closeCard("click"));
|
|
4905
5317
|
handled = true;
|
|
4906
5318
|
}
|
|
4907
5319
|
else if (linkType && linkTarget) {
|
|
4908
5320
|
if (linkType === "story") {
|
|
4909
5321
|
// storyId: number, slideIndex: number
|
|
4910
|
-
this.layoutService.env.setTimeout(() => this.
|
|
5322
|
+
this.layoutService.env.setTimeout(() => this.slideApiDeps.openStory(parseInt(linkTarget), 0));
|
|
4911
5323
|
handled = true;
|
|
4912
5324
|
}
|
|
4913
5325
|
else if (linkType === "slide") {
|
|
4914
5326
|
const __slideIndex = parseInt(linkTarget);
|
|
4915
5327
|
const __slideCount = this.slide.slideCount;
|
|
4916
5328
|
if (__slideIndex >= 0 && __slideIndex < __slideCount) {
|
|
4917
|
-
this.layoutService.env.setTimeout(() => this.
|
|
5329
|
+
this.layoutService.env.setTimeout(() => this.slideApiDeps.showCardSlide(__slideIndex));
|
|
4918
5330
|
handled = true;
|
|
4919
5331
|
}
|
|
4920
5332
|
}
|
|
4921
5333
|
else if (linkType === "game") {
|
|
4922
|
-
this.layoutService.env.setTimeout(() => this.
|
|
5334
|
+
this.layoutService.env.setTimeout(() => this.slideApiDeps.openGame(linkTarget));
|
|
4923
5335
|
handled = true;
|
|
4924
5336
|
}
|
|
4925
5337
|
else if (linkType === "layer") {
|
|
4926
5338
|
const layerIndex = parseInt(linkTarget);
|
|
4927
5339
|
if (layerIndex >= 0) {
|
|
4928
|
-
this.layoutService.env.setTimeout(() => this.
|
|
5340
|
+
this.layoutService.env.setTimeout(() => this.slideApiDeps.showLayer(layerIndex));
|
|
4929
5341
|
handled = true;
|
|
4930
5342
|
}
|
|
4931
5343
|
}
|
|
@@ -4933,7 +5345,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4933
5345
|
// traditional link, with url
|
|
4934
5346
|
statisticWidgetValue = linkTarget;
|
|
4935
5347
|
this.layoutService.env.setTimeout(() => {
|
|
4936
|
-
this.
|
|
5348
|
+
this.slideApiDeps.openUrl({
|
|
4937
5349
|
type: isSwipeUpAction ? "swipeUpLink" : "link",
|
|
4938
5350
|
link: {
|
|
4939
5351
|
type: "url",
|
|
@@ -4943,6 +5355,12 @@ let SlideApi$1 = class SlideApi {
|
|
|
4943
5355
|
});
|
|
4944
5356
|
handled = true;
|
|
4945
5357
|
}
|
|
5358
|
+
else if (linkType === "promocode") {
|
|
5359
|
+
handled = this.activeLayer.findElementByNodeRef(element)?.handleClick() ?? true;
|
|
5360
|
+
if (!handled) {
|
|
5361
|
+
return { handled: true };
|
|
5362
|
+
}
|
|
5363
|
+
}
|
|
4946
5364
|
else if (linkType === "products") {
|
|
4947
5365
|
if (this.layoutService.layoutApi.widgetProductsApi) {
|
|
4948
5366
|
this.layoutService.layoutApi.widgetProductsApi.click(element);
|
|
@@ -4952,7 +5370,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4952
5370
|
else if (linkType === "swipe-up-items") {
|
|
4953
5371
|
const target = linkTarget;
|
|
4954
5372
|
this.layoutService.env.setTimeout(() => {
|
|
4955
|
-
this.
|
|
5373
|
+
this.slideApiDeps.openUrl({
|
|
4956
5374
|
type: "swipeUpItems",
|
|
4957
5375
|
link: {
|
|
4958
5376
|
type: "json",
|
|
@@ -4988,7 +5406,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4988
5406
|
baseFields.message_id = cardId;
|
|
4989
5407
|
break;
|
|
4990
5408
|
}
|
|
4991
|
-
this.
|
|
5409
|
+
this.slideApiDeps.sendStatisticEvent(statisticWidgetEventType, {
|
|
4992
5410
|
i: cardId,
|
|
4993
5411
|
si: slideIndex,
|
|
4994
5412
|
wi: elementId,
|
|
@@ -5044,28 +5462,1403 @@ let SlideApi$1 = class SlideApi {
|
|
|
5044
5462
|
}
|
|
5045
5463
|
}
|
|
5046
5464
|
}
|
|
5047
|
-
_sdkClientVariables = {};
|
|
5048
|
-
getSdkClientVariables() {
|
|
5049
|
-
return this._sdkClientVariables;
|
|
5050
|
-
}
|
|
5051
|
-
setSdkClientVariables(variables) {
|
|
5052
|
-
this._sdkClientVariables = variables;
|
|
5053
|
-
}
|
|
5054
5465
|
static get [Symbol.for("___CTOR_ARGS___")]() { return [`{
|
|
5055
|
-
|
|
5466
|
+
slideApiDeps: ISlideApiDeps;
|
|
5056
5467
|
slideWrapper: HTMLElement;
|
|
5057
5468
|
viewport: Window;
|
|
5058
5469
|
userResizeHandler?: (data: { viewportWidth: number; viewportHeight: number; fontSize: number }) => void;
|
|
5059
5470
|
slideRatio: number;
|
|
5060
5471
|
isFullscreen: boolean;
|
|
5061
|
-
slideLoadedCb?: (data: { cardId: number; slideIndex: number; result: boolean; reason?: string }) => void;
|
|
5062
5472
|
getViewportWidth: () => number;
|
|
5063
5473
|
getViewportHeight: () => number;
|
|
5064
5474
|
overlappingActionBarHeight?: number;
|
|
5065
5475
|
separateUserAndAppPause: boolean;
|
|
5476
|
+
root: HTMLElement;
|
|
5477
|
+
nonce?: string;
|
|
5478
|
+
// refreshSizes: (slide: SlideApi) => void;
|
|
5479
|
+
index: number;
|
|
5480
|
+
getSdkClientVariables: GetSdkClientVariables;
|
|
5066
5481
|
}`]; }
|
|
5067
5482
|
};
|
|
5068
5483
|
|
|
5484
|
+
class SlideApiDepsMultiSlideMode {
|
|
5485
|
+
sdkApi;
|
|
5486
|
+
slider;
|
|
5487
|
+
constructor(sdkApi, slider) {
|
|
5488
|
+
this.sdkApi = sdkApi;
|
|
5489
|
+
this.slider = slider;
|
|
5490
|
+
}
|
|
5491
|
+
getWidgetsSharedData(cardId, widget) {
|
|
5492
|
+
return this.sdkApi.getWidgetsSharedData(cardId, widget);
|
|
5493
|
+
}
|
|
5494
|
+
showToast(text) {
|
|
5495
|
+
return this.sdkApi.showToast(text);
|
|
5496
|
+
}
|
|
5497
|
+
writeToClipboard(data) {
|
|
5498
|
+
return this.sdkApi.writeToClipboard(data);
|
|
5499
|
+
}
|
|
5500
|
+
get isExistsShare() {
|
|
5501
|
+
return this.sdkApi.isExistsShare;
|
|
5502
|
+
}
|
|
5503
|
+
share(id, config) {
|
|
5504
|
+
this.sdkApi.share(id, config);
|
|
5505
|
+
}
|
|
5506
|
+
get sdkCanSendShareComplete() {
|
|
5507
|
+
return this.sdkApi.sdkCanSendShareComplete;
|
|
5508
|
+
}
|
|
5509
|
+
shareSlideScreenshot(shareId, hideElementsSelector, shareText) {
|
|
5510
|
+
this.sdkApi.shareSlideScreenshot(shareId, hideElementsSelector, shareText);
|
|
5511
|
+
}
|
|
5512
|
+
setCardSessionValue(element, key, value) {
|
|
5513
|
+
this.sdkApi.setCardSessionValue(element, key, value);
|
|
5514
|
+
}
|
|
5515
|
+
getCardSessionValue(element, key) {
|
|
5516
|
+
return this.sdkApi.getCardSessionValue(element, key);
|
|
5517
|
+
}
|
|
5518
|
+
getCardFonts() {
|
|
5519
|
+
return this.sdkApi.getCardFonts();
|
|
5520
|
+
}
|
|
5521
|
+
disableVerticalSwipeGesture() {
|
|
5522
|
+
this.sdkApi.disableVerticalSwipeGesture();
|
|
5523
|
+
}
|
|
5524
|
+
enableVerticalSwipeGesture() {
|
|
5525
|
+
this.sdkApi.enableVerticalSwipeGesture();
|
|
5526
|
+
}
|
|
5527
|
+
disableBackpress() {
|
|
5528
|
+
this.sdkApi.disableBackpress();
|
|
5529
|
+
}
|
|
5530
|
+
enableBackpress() {
|
|
5531
|
+
this.sdkApi.enableBackpress();
|
|
5532
|
+
}
|
|
5533
|
+
closeCard(reason) {
|
|
5534
|
+
this.sdkApi.closeCard(reason);
|
|
5535
|
+
}
|
|
5536
|
+
openStory(id, index) {
|
|
5537
|
+
// TODO rewrite with Promise - for usage story loading states in Button
|
|
5538
|
+
this.sdkApi.openStory(id, index);
|
|
5539
|
+
}
|
|
5540
|
+
openGame(gameInstanceId) {
|
|
5541
|
+
// TODO rewrite with Promise - for usage game loading states in Button
|
|
5542
|
+
this.sdkApi.openGame(gameInstanceId);
|
|
5543
|
+
}
|
|
5544
|
+
openUrl(data) {
|
|
5545
|
+
this.sdkApi.openUrl(data);
|
|
5546
|
+
}
|
|
5547
|
+
get isAndroid() {
|
|
5548
|
+
return this.sdkApi.isAndroid;
|
|
5549
|
+
}
|
|
5550
|
+
get isWeb() {
|
|
5551
|
+
return this.sdkApi.isWeb;
|
|
5552
|
+
}
|
|
5553
|
+
get isIOS() {
|
|
5554
|
+
return this.sdkApi.isIOS;
|
|
5555
|
+
}
|
|
5556
|
+
get isExistsShowCardTextInput() {
|
|
5557
|
+
return this.sdkApi.isExistsShowCardTextInput;
|
|
5558
|
+
}
|
|
5559
|
+
showCardTextInput(id, data) {
|
|
5560
|
+
this.sdkApi.showCardTextInput(id, data);
|
|
5561
|
+
}
|
|
5562
|
+
vibrate(pattern) {
|
|
5563
|
+
this.sdkApi.vibrate(pattern);
|
|
5564
|
+
}
|
|
5565
|
+
sendApiRequest(url, method, params, headers, data, profilingKey) {
|
|
5566
|
+
return this.sdkApi.sendApiRequest(url, method, params, headers, data, profilingKey);
|
|
5567
|
+
}
|
|
5568
|
+
sendStatisticEvent(name, data, devPayload, forceEnableStatisticV2) {
|
|
5569
|
+
this.sdkApi.sendStatisticEvent(name, data, devPayload, forceEnableStatisticV2);
|
|
5570
|
+
}
|
|
5571
|
+
setCardLocalData(keyValue, sendToServer) {
|
|
5572
|
+
this.sdkApi.setCardLocalData(keyValue, sendToServer);
|
|
5573
|
+
}
|
|
5574
|
+
getCardLocalData() {
|
|
5575
|
+
return this.sdkApi.getCardLocalData();
|
|
5576
|
+
}
|
|
5577
|
+
getCardServerData(cardId) {
|
|
5578
|
+
return this.sdkApi.getCardServerData(cardId);
|
|
5579
|
+
}
|
|
5580
|
+
get cardAnimation() {
|
|
5581
|
+
return this.sdkApi.cardAnimation;
|
|
5582
|
+
}
|
|
5583
|
+
updateCardServerDataLocally(cardId, data) {
|
|
5584
|
+
this.sdkApi.updateCardServerDataLocally(cardId, data);
|
|
5585
|
+
}
|
|
5586
|
+
get isExistsShowNextCard() {
|
|
5587
|
+
return this.sdkApi.isExistsShowNextCard;
|
|
5588
|
+
}
|
|
5589
|
+
cardShowNext() {
|
|
5590
|
+
return;
|
|
5591
|
+
// skip action in multislide mode (business logic)
|
|
5592
|
+
// this.sdkApi.cardShowNext();
|
|
5593
|
+
}
|
|
5594
|
+
/** @deprecated, used only in native sdk **/
|
|
5595
|
+
cardPausedCallback(currentTime) {
|
|
5596
|
+
this.sdkApi.cardPausedCallback(currentTime);
|
|
5597
|
+
}
|
|
5598
|
+
/** @deprecated, used only in native sdk **/
|
|
5599
|
+
cardResumedCallback(currentTime) {
|
|
5600
|
+
this.sdkApi.cardResumedCallback(currentTime);
|
|
5601
|
+
}
|
|
5602
|
+
disableHorizontalSwipeGesture() {
|
|
5603
|
+
this.sdkApi.disableHorizontalSwipeGesture();
|
|
5604
|
+
}
|
|
5605
|
+
enableHorizontalSwipeGesture() {
|
|
5606
|
+
this.sdkApi.enableHorizontalSwipeGesture();
|
|
5607
|
+
}
|
|
5608
|
+
isExistsShowLayer() {
|
|
5609
|
+
return this.sdkApi.isExistsShowLayer();
|
|
5610
|
+
}
|
|
5611
|
+
showLayer(index) {
|
|
5612
|
+
this.sdkApi.showLayer(index);
|
|
5613
|
+
}
|
|
5614
|
+
/**
|
|
5615
|
+
* For single slide mode - proxy these methods via SDKApi
|
|
5616
|
+
* =================================================================================================================
|
|
5617
|
+
*/
|
|
5618
|
+
get isExistsShowCardSlide() {
|
|
5619
|
+
return true;
|
|
5620
|
+
}
|
|
5621
|
+
showCardSlide(index) {
|
|
5622
|
+
this.slider.showByIndex(index);
|
|
5623
|
+
}
|
|
5624
|
+
isSdkSupportUpdateTimeline() {
|
|
5625
|
+
return true;
|
|
5626
|
+
}
|
|
5627
|
+
updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError) {
|
|
5628
|
+
this.slider.updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError);
|
|
5629
|
+
}
|
|
5630
|
+
isSdkSupportTimelineOnBeforeStart() {
|
|
5631
|
+
return true;
|
|
5632
|
+
}
|
|
5633
|
+
isSdkSupportCorrectPauseResumeLifecycle() {
|
|
5634
|
+
return true;
|
|
5635
|
+
}
|
|
5636
|
+
showNextSlide(duration) {
|
|
5637
|
+
this.slider.showNextSlide();
|
|
5638
|
+
}
|
|
5639
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`SDKApi`, `ISlider`]; }
|
|
5640
|
+
}
|
|
5641
|
+
|
|
5642
|
+
class SlideApiDepsSingleSlideMode {
|
|
5643
|
+
sdkApi;
|
|
5644
|
+
constructor(sdkApi) {
|
|
5645
|
+
this.sdkApi = sdkApi;
|
|
5646
|
+
}
|
|
5647
|
+
getWidgetsSharedData(cardId, widget) {
|
|
5648
|
+
return this.sdkApi.getWidgetsSharedData(cardId, widget);
|
|
5649
|
+
}
|
|
5650
|
+
showToast(text) {
|
|
5651
|
+
return this.sdkApi.showToast(text);
|
|
5652
|
+
}
|
|
5653
|
+
writeToClipboard(data) {
|
|
5654
|
+
return this.sdkApi.writeToClipboard(data);
|
|
5655
|
+
}
|
|
5656
|
+
get isExistsShare() {
|
|
5657
|
+
return this.sdkApi.isExistsShare;
|
|
5658
|
+
}
|
|
5659
|
+
share(id, config) {
|
|
5660
|
+
this.sdkApi.share(id, config);
|
|
5661
|
+
}
|
|
5662
|
+
get sdkCanSendShareComplete() {
|
|
5663
|
+
return this.sdkApi.sdkCanSendShareComplete;
|
|
5664
|
+
}
|
|
5665
|
+
shareSlideScreenshot(shareId, hideElementsSelector, shareText) {
|
|
5666
|
+
this.sdkApi.shareSlideScreenshot(shareId, hideElementsSelector, shareText);
|
|
5667
|
+
}
|
|
5668
|
+
setCardSessionValue(element, key, value) {
|
|
5669
|
+
this.sdkApi.setCardSessionValue(element, key, value);
|
|
5670
|
+
}
|
|
5671
|
+
getCardSessionValue(element, key) {
|
|
5672
|
+
return this.sdkApi.getCardSessionValue(element, key);
|
|
5673
|
+
}
|
|
5674
|
+
getCardFonts() {
|
|
5675
|
+
return this.sdkApi.getCardFonts();
|
|
5676
|
+
}
|
|
5677
|
+
disableVerticalSwipeGesture() {
|
|
5678
|
+
this.sdkApi.disableVerticalSwipeGesture();
|
|
5679
|
+
}
|
|
5680
|
+
enableVerticalSwipeGesture() {
|
|
5681
|
+
this.sdkApi.enableVerticalSwipeGesture();
|
|
5682
|
+
}
|
|
5683
|
+
disableBackpress() {
|
|
5684
|
+
this.sdkApi.disableBackpress();
|
|
5685
|
+
}
|
|
5686
|
+
enableBackpress() {
|
|
5687
|
+
this.sdkApi.enableBackpress();
|
|
5688
|
+
}
|
|
5689
|
+
closeCard(reason) {
|
|
5690
|
+
this.sdkApi.closeCard(reason);
|
|
5691
|
+
}
|
|
5692
|
+
openStory(id, index) {
|
|
5693
|
+
// TODO rewrite with Promise - for usage story loading states in Button
|
|
5694
|
+
this.sdkApi.openStory(id, index);
|
|
5695
|
+
}
|
|
5696
|
+
openGame(gameInstanceId) {
|
|
5697
|
+
// TODO rewrite with Promise - for usage game loading states in Button
|
|
5698
|
+
this.sdkApi.openGame(gameInstanceId);
|
|
5699
|
+
}
|
|
5700
|
+
openUrl(data) {
|
|
5701
|
+
this.sdkApi.openUrl(data);
|
|
5702
|
+
}
|
|
5703
|
+
get isAndroid() {
|
|
5704
|
+
return this.sdkApi.isAndroid;
|
|
5705
|
+
}
|
|
5706
|
+
get isWeb() {
|
|
5707
|
+
return this.sdkApi.isWeb;
|
|
5708
|
+
}
|
|
5709
|
+
get isIOS() {
|
|
5710
|
+
return this.sdkApi.isIOS;
|
|
5711
|
+
}
|
|
5712
|
+
get isExistsShowCardTextInput() {
|
|
5713
|
+
return this.sdkApi.isExistsShowCardTextInput;
|
|
5714
|
+
}
|
|
5715
|
+
showCardTextInput(id, data) {
|
|
5716
|
+
this.sdkApi.showCardTextInput(id, data);
|
|
5717
|
+
}
|
|
5718
|
+
vibrate(pattern) {
|
|
5719
|
+
this.sdkApi.vibrate(pattern);
|
|
5720
|
+
}
|
|
5721
|
+
sendApiRequest(url, method, params, headers, data, profilingKey) {
|
|
5722
|
+
return this.sdkApi.sendApiRequest(url, method, params, headers, data, profilingKey);
|
|
5723
|
+
}
|
|
5724
|
+
sendStatisticEvent(name, data, devPayload, forceEnableStatisticV2) {
|
|
5725
|
+
this.sdkApi.sendStatisticEvent(name, data, devPayload, forceEnableStatisticV2);
|
|
5726
|
+
}
|
|
5727
|
+
setCardLocalData(keyValue, sendToServer) {
|
|
5728
|
+
this.sdkApi.setCardLocalData(keyValue, sendToServer);
|
|
5729
|
+
}
|
|
5730
|
+
getCardLocalData() {
|
|
5731
|
+
return this.sdkApi.getCardLocalData();
|
|
5732
|
+
}
|
|
5733
|
+
getCardServerData(cardId) {
|
|
5734
|
+
return this.sdkApi.getCardServerData(cardId);
|
|
5735
|
+
}
|
|
5736
|
+
get cardAnimation() {
|
|
5737
|
+
return this.sdkApi.cardAnimation;
|
|
5738
|
+
}
|
|
5739
|
+
updateCardServerDataLocally(cardId, data) {
|
|
5740
|
+
this.sdkApi.updateCardServerDataLocally(cardId, data);
|
|
5741
|
+
}
|
|
5742
|
+
get isExistsShowNextCard() {
|
|
5743
|
+
return this.sdkApi.isExistsShowNextCard;
|
|
5744
|
+
}
|
|
5745
|
+
cardShowNext() {
|
|
5746
|
+
this.sdkApi.cardShowNext();
|
|
5747
|
+
}
|
|
5748
|
+
/** @deprecated, used only in native sdk **/
|
|
5749
|
+
cardPausedCallback(currentTime) {
|
|
5750
|
+
this.sdkApi.cardPausedCallback(currentTime);
|
|
5751
|
+
}
|
|
5752
|
+
/** @deprecated, used only in native sdk **/
|
|
5753
|
+
cardResumedCallback(currentTime) {
|
|
5754
|
+
this.sdkApi.cardResumedCallback(currentTime);
|
|
5755
|
+
}
|
|
5756
|
+
disableHorizontalSwipeGesture() {
|
|
5757
|
+
this.sdkApi.disableHorizontalSwipeGesture();
|
|
5758
|
+
}
|
|
5759
|
+
enableHorizontalSwipeGesture() {
|
|
5760
|
+
this.sdkApi.enableHorizontalSwipeGesture();
|
|
5761
|
+
}
|
|
5762
|
+
isExistsShowLayer() {
|
|
5763
|
+
return this.sdkApi.isExistsShowLayer();
|
|
5764
|
+
}
|
|
5765
|
+
showLayer(index) {
|
|
5766
|
+
this.sdkApi.showLayer(index);
|
|
5767
|
+
}
|
|
5768
|
+
/**
|
|
5769
|
+
* For single slide mode - proxy these methods via SDKApi
|
|
5770
|
+
*/
|
|
5771
|
+
get isExistsShowCardSlide() {
|
|
5772
|
+
return this.sdkApi.isExistsShowCardSlide;
|
|
5773
|
+
}
|
|
5774
|
+
showCardSlide(index) {
|
|
5775
|
+
this.sdkApi.showCardSlide(index);
|
|
5776
|
+
}
|
|
5777
|
+
isSdkSupportUpdateTimeline() {
|
|
5778
|
+
return this.sdkApi.isSdkSupportUpdateTimeline();
|
|
5779
|
+
}
|
|
5780
|
+
updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError) {
|
|
5781
|
+
this.sdkApi.updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError);
|
|
5782
|
+
}
|
|
5783
|
+
isSdkSupportTimelineOnBeforeStart() {
|
|
5784
|
+
return this.sdkApi.isSdkSupportTimelineOnBeforeStart();
|
|
5785
|
+
}
|
|
5786
|
+
isSdkSupportCorrectPauseResumeLifecycle() {
|
|
5787
|
+
return this.sdkApi.isSdkSupportCorrectPauseResumeLifecycle();
|
|
5788
|
+
}
|
|
5789
|
+
showNextSlide(duration) {
|
|
5790
|
+
this.sdkApi.showNextSlide(duration);
|
|
5791
|
+
}
|
|
5792
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`SDKApi`]; }
|
|
5793
|
+
}
|
|
5794
|
+
|
|
5795
|
+
class SlideTimer {
|
|
5796
|
+
requestStartTimer;
|
|
5797
|
+
requestCancelTimer;
|
|
5798
|
+
updateCb;
|
|
5799
|
+
doneCb;
|
|
5800
|
+
constructor(requestStartTimer, requestCancelTimer, updateCb, doneCb) {
|
|
5801
|
+
this.requestStartTimer = requestStartTimer;
|
|
5802
|
+
this.requestCancelTimer = requestCancelTimer;
|
|
5803
|
+
this.updateCb = updateCb;
|
|
5804
|
+
this.doneCb = doneCb;
|
|
5805
|
+
}
|
|
5806
|
+
duration;
|
|
5807
|
+
timeLeft;
|
|
5808
|
+
_pause = true;
|
|
5809
|
+
_stop = true;
|
|
5810
|
+
_started = false;
|
|
5811
|
+
start(duration) {
|
|
5812
|
+
this.duration = duration;
|
|
5813
|
+
this.stop();
|
|
5814
|
+
this.timeLeft = this.duration;
|
|
5815
|
+
this._pause = false;
|
|
5816
|
+
this._stop = false;
|
|
5817
|
+
this._started = true;
|
|
5818
|
+
this.tick();
|
|
5819
|
+
}
|
|
5820
|
+
stop() {
|
|
5821
|
+
this._stop = true;
|
|
5822
|
+
this._started = false;
|
|
5823
|
+
if (this.timerId != null) {
|
|
5824
|
+
this.requestCancelTimer(this.timerId);
|
|
5825
|
+
this.timerId = null;
|
|
5826
|
+
}
|
|
5827
|
+
// this.updateCb(0);
|
|
5828
|
+
}
|
|
5829
|
+
pause() {
|
|
5830
|
+
this._pause = true;
|
|
5831
|
+
if (this.timerId != null) {
|
|
5832
|
+
this.requestCancelTimer(this.timerId);
|
|
5833
|
+
this.timerId = null;
|
|
5834
|
+
}
|
|
5835
|
+
}
|
|
5836
|
+
resume(currentTime = undefined, duration = 0) {
|
|
5837
|
+
this._pause = false;
|
|
5838
|
+
if (!this._started) {
|
|
5839
|
+
this.start(duration);
|
|
5840
|
+
}
|
|
5841
|
+
else {
|
|
5842
|
+
if (currentTime != null) {
|
|
5843
|
+
// timeLeft correction
|
|
5844
|
+
this.timeLeft = this.duration - currentTime;
|
|
5845
|
+
}
|
|
5846
|
+
this.tick();
|
|
5847
|
+
}
|
|
5848
|
+
}
|
|
5849
|
+
timerId;
|
|
5850
|
+
tick() {
|
|
5851
|
+
if (this._stop) {
|
|
5852
|
+
return;
|
|
5853
|
+
}
|
|
5854
|
+
const rafStartTime = new Date().getTime();
|
|
5855
|
+
this.timerId = this.requestStartTimer(() => {
|
|
5856
|
+
if (this._stop) {
|
|
5857
|
+
return;
|
|
5858
|
+
}
|
|
5859
|
+
const dtDiff = new Date().getTime() - rafStartTime;
|
|
5860
|
+
this.timeLeft -= dtDiff;
|
|
5861
|
+
let progressPercent = Math.round(((this.duration - this.timeLeft) / this.duration) * 100 * 10000) / 10000;
|
|
5862
|
+
if (progressPercent > 100) {
|
|
5863
|
+
progressPercent = 100;
|
|
5864
|
+
}
|
|
5865
|
+
this.updateCb(progressPercent);
|
|
5866
|
+
if (progressPercent < 100) {
|
|
5867
|
+
if (this._pause !== true) {
|
|
5868
|
+
this.tick();
|
|
5869
|
+
}
|
|
5870
|
+
}
|
|
5871
|
+
else {
|
|
5872
|
+
this.doneCb();
|
|
5873
|
+
}
|
|
5874
|
+
});
|
|
5875
|
+
}
|
|
5876
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`(callback: () => void) => number`, `(timerId: number) => void`, `(progressPercent: number) => void`, `() => void`]; }
|
|
5877
|
+
}
|
|
5878
|
+
|
|
5879
|
+
/**
|
|
5880
|
+
* usage TS interface with ctor
|
|
5881
|
+
* https://blog.logrocket.com/writing-constructor-typescript/
|
|
5882
|
+
*
|
|
5883
|
+
* @param ctor
|
|
5884
|
+
* @param slides
|
|
5885
|
+
* @param getLayoutDirection
|
|
5886
|
+
*/
|
|
5887
|
+
function createTimelineController(ctor, slides, getLayoutDirection) {
|
|
5888
|
+
return new ctor(slides, getLayoutDirection);
|
|
5889
|
+
}
|
|
5890
|
+
class TimelineController {
|
|
5891
|
+
slides;
|
|
5892
|
+
getLayoutDirection;
|
|
5893
|
+
constructor(slides, getLayoutDirection) {
|
|
5894
|
+
this.slides = slides;
|
|
5895
|
+
this.getLayoutDirection = getLayoutDirection;
|
|
5896
|
+
}
|
|
5897
|
+
onSlideTimerUpdate(index, progressPercent) {
|
|
5898
|
+
this.slides[index]?.updateTimelineProgress(progressPercent, true);
|
|
5899
|
+
}
|
|
5900
|
+
onSlideBeforeStart(index) {
|
|
5901
|
+
// fill to 100% all previous slides
|
|
5902
|
+
for (let i = 0; i < index; ++i) {
|
|
5903
|
+
this.slides[i]?.updateTimelineProgress(100, false);
|
|
5904
|
+
}
|
|
5905
|
+
// fill to 0% all next slides (for user revert direction)
|
|
5906
|
+
for (let i = index + 1; i < this.slides.length; ++i) {
|
|
5907
|
+
this.slides[i]?.updateTimelineProgress(0, false);
|
|
5908
|
+
}
|
|
5909
|
+
// activate current slide
|
|
5910
|
+
this.slides[index]?.updateTimelineProgress(0, true);
|
|
5911
|
+
}
|
|
5912
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`Array`, `GetLayoutDirection`]; }
|
|
5913
|
+
}
|
|
5914
|
+
|
|
5915
|
+
class Slider {
|
|
5916
|
+
config;
|
|
5917
|
+
constructor(config) {
|
|
5918
|
+
this.config = config;
|
|
5919
|
+
for (let i = 0; i < config.slides.length; ++i) {
|
|
5920
|
+
const item = {
|
|
5921
|
+
called: false,
|
|
5922
|
+
firstRenderCall: null,
|
|
5923
|
+
firstRenderCallPromise: null,
|
|
5924
|
+
};
|
|
5925
|
+
item.firstRenderCallPromise = new Promise(resolver => {
|
|
5926
|
+
item.firstRenderCall = resolver;
|
|
5927
|
+
});
|
|
5928
|
+
this.slidesFirstRenders[i] = item;
|
|
5929
|
+
}
|
|
5930
|
+
const slideWrapper = this.createSliderElement({
|
|
5931
|
+
slides: config.slides,
|
|
5932
|
+
nonce: config.nonce,
|
|
5933
|
+
slideRender: config.slideRender,
|
|
5934
|
+
navbarAppearance: config.navbarAppearance,
|
|
5935
|
+
});
|
|
5936
|
+
config.root.appendChild(slideWrapper);
|
|
5937
|
+
this.slideWrapperElement = slideWrapper;
|
|
5938
|
+
this.timelineController = createTimelineController(TimelineController, this.slides, this.config.getLayoutDirection.bind(this));
|
|
5939
|
+
// cardMounted: (card: HTMLElement) => Promise<void>
|
|
5940
|
+
requestAnimationFrame(async () => {
|
|
5941
|
+
await Promise.all(this.slides.map((slide, index) => config.onSlideMounted(slide.element, index)));
|
|
5942
|
+
});
|
|
5943
|
+
}
|
|
5944
|
+
isAnimating = false;
|
|
5945
|
+
activeIndex = -1;
|
|
5946
|
+
get activeSlide() {
|
|
5947
|
+
return this.slides[this.activeIndex];
|
|
5948
|
+
}
|
|
5949
|
+
slides = [];
|
|
5950
|
+
sliderTrack = null;
|
|
5951
|
+
bulletsContainer = null;
|
|
5952
|
+
slidesFirstRenders = [];
|
|
5953
|
+
slideWrapperElement;
|
|
5954
|
+
timelineController;
|
|
5955
|
+
assembleNavbarCssVariables(navbarAppearance) {
|
|
5956
|
+
let css = "";
|
|
5957
|
+
if (navbarAppearance.edge_offset != null) {
|
|
5958
|
+
css += `--navbar-edge-offset: ${navbarAppearance.edge_offset};`;
|
|
5959
|
+
}
|
|
5960
|
+
if (navbarAppearance.active_timeline_width != null) {
|
|
5961
|
+
css += `--navbar-active-timeline_width: ${navbarAppearance.active_timeline_width};`;
|
|
5962
|
+
}
|
|
5963
|
+
if (navbarAppearance.background_color != null) {
|
|
5964
|
+
css += `--navbar-background-color: ${navbarAppearance.background_color};`;
|
|
5965
|
+
}
|
|
5966
|
+
if (navbarAppearance.border_radius != null) {
|
|
5967
|
+
css += `--navbar-border-radius: ${navbarAppearance.border_radius};`;
|
|
5968
|
+
}
|
|
5969
|
+
if (navbarAppearance.drop_shadow_blur != null) {
|
|
5970
|
+
css += `--navbar-drop-shadow-blur: ${navbarAppearance.drop_shadow_blur};`;
|
|
5971
|
+
}
|
|
5972
|
+
if (navbarAppearance.drop_shadow_color != null) {
|
|
5973
|
+
css += `--navbar-drop-shadow-color: ${navbarAppearance.drop_shadow_color};`;
|
|
5974
|
+
}
|
|
5975
|
+
if (navbarAppearance.drop_shadow_x_offset != null) {
|
|
5976
|
+
css += `--navbar-drop-shadow-x-offset: ${navbarAppearance.drop_shadow_x_offset};`;
|
|
5977
|
+
}
|
|
5978
|
+
if (navbarAppearance.drop_shadow_y_offset != null) {
|
|
5979
|
+
css += `--navbar-drop-shadow-y-offset: ${navbarAppearance.drop_shadow_y_offset};`;
|
|
5980
|
+
}
|
|
5981
|
+
if (navbarAppearance.timeline_background_color != null) {
|
|
5982
|
+
css += `--navbar-timeline-background-color: ${navbarAppearance.timeline_background_color};`;
|
|
5983
|
+
}
|
|
5984
|
+
if (navbarAppearance.timeline_fill_color != null) {
|
|
5985
|
+
css += `--navbar-timeline-fill-color: ${navbarAppearance.timeline_fill_color};`;
|
|
5986
|
+
}
|
|
5987
|
+
if (navbarAppearance.timeline_size != null) {
|
|
5988
|
+
css += `--navbar-timeline-size: ${navbarAppearance.timeline_size};`;
|
|
5989
|
+
}
|
|
5990
|
+
if (navbarAppearance.timelines_gap != null) {
|
|
5991
|
+
css += `--navbar-timelines-gap: ${navbarAppearance.timelines_gap};`;
|
|
5992
|
+
}
|
|
5993
|
+
if (navbarAppearance.vertical_padding != null) {
|
|
5994
|
+
css += `--navbar-vertical-padding: ${navbarAppearance.vertical_padding};`;
|
|
5995
|
+
}
|
|
5996
|
+
if (navbarAppearance.horizontal_padding != null) {
|
|
5997
|
+
css += `--navbar-horizontal-padding: ${navbarAppearance.horizontal_padding};`;
|
|
5998
|
+
}
|
|
5999
|
+
return `.cards-slider {${css}`;
|
|
6000
|
+
}
|
|
6001
|
+
createSliderElement = ({ slides, nonce, slideRender, navbarAppearance, }) => {
|
|
6002
|
+
const style = document.createElement("style");
|
|
6003
|
+
if (nonce != null) {
|
|
6004
|
+
style.nonce = nonce;
|
|
6005
|
+
}
|
|
6006
|
+
style.innerText = this.assembleNavbarCssVariables(navbarAppearance);
|
|
6007
|
+
const slider = document.createElement("div");
|
|
6008
|
+
slider.classList.add("cards-slider");
|
|
6009
|
+
const track = document.createElement("div");
|
|
6010
|
+
track.classList.add("cards-slider__track");
|
|
6011
|
+
this.sliderTrack = track;
|
|
6012
|
+
const [bullets, updateTimelineProgress] = this.createBulletPoints(slides.length, this.config.getLayoutDirection.bind(this), navbarAppearance.position);
|
|
6013
|
+
this.bulletsContainer = bullets;
|
|
6014
|
+
this.slides = slides.map((slide, i) => ({
|
|
6015
|
+
element: slideRender(slide, i, this.slidesFirstRenders[i].firstRenderCallPromise),
|
|
6016
|
+
timer: new SlideTimer(cb => window.requestAnimationFrame(cb), handle => window.cancelAnimationFrame(handle), progressPercent => this.timelineController.onSlideTimerUpdate(i, progressPercent), this.onSlideTimerEnd.bind(this)),
|
|
6017
|
+
updateTimelineProgress: (progressPercent, isActive) => updateTimelineProgress(i, progressPercent, isActive),
|
|
6018
|
+
}));
|
|
6019
|
+
for (let i = 0; i < this.slides.length; ++i) {
|
|
6020
|
+
const slideElement = document.createElement("div");
|
|
6021
|
+
slideElement.classList.add("cards-slider__slide");
|
|
6022
|
+
slideElement.setAttribute("data-index", String(i));
|
|
6023
|
+
slideElement.appendChild(this.slides[i].element);
|
|
6024
|
+
track.appendChild(slideElement);
|
|
6025
|
+
}
|
|
6026
|
+
slider.appendChild(track);
|
|
6027
|
+
const safeAreaView = document.createElement("div");
|
|
6028
|
+
safeAreaView.classList.add("safe-area-view", "inset-0", "non-touchable");
|
|
6029
|
+
const safeAreaRelativeZoneView = document.createElement("div");
|
|
6030
|
+
safeAreaRelativeZoneView.classList.add("safe-area-relative-zone-view");
|
|
6031
|
+
safeAreaRelativeZoneView.appendChild(bullets);
|
|
6032
|
+
safeAreaView.appendChild(safeAreaRelativeZoneView);
|
|
6033
|
+
slider.appendChild(safeAreaView);
|
|
6034
|
+
slider.appendChild(style);
|
|
6035
|
+
return slider;
|
|
6036
|
+
};
|
|
6037
|
+
createBulletPoints(count, getLayoutDirection, position) {
|
|
6038
|
+
const bullets = document.createElement("div");
|
|
6039
|
+
bullets.classList.add("cards-slider__navbar");
|
|
6040
|
+
if (position === 0) {
|
|
6041
|
+
bullets.classList.add("cards-slider__navbar--position-none");
|
|
6042
|
+
}
|
|
6043
|
+
else if (position === 1) {
|
|
6044
|
+
bullets.classList.add("cards-slider__navbar--position-top");
|
|
6045
|
+
}
|
|
6046
|
+
else if (position === 2) {
|
|
6047
|
+
bullets.classList.add("cards-slider__navbar--position-bottom");
|
|
6048
|
+
}
|
|
6049
|
+
else {
|
|
6050
|
+
// default
|
|
6051
|
+
bullets.classList.add("cards-slider__navbar--position-bottom");
|
|
6052
|
+
}
|
|
6053
|
+
bullets.dir = getLayoutDirection();
|
|
6054
|
+
for (let i = 0; i < count; ++i) {
|
|
6055
|
+
const bullet = document.createElement("div");
|
|
6056
|
+
bullet.classList.add("cards-slider__timeline", "touchable");
|
|
6057
|
+
bullet.setAttribute("data-index", String(i));
|
|
6058
|
+
bullet.onclick = (e) => {
|
|
6059
|
+
e.stopPropagation();
|
|
6060
|
+
e.preventDefault();
|
|
6061
|
+
const bullet = e.target;
|
|
6062
|
+
if (bullet != null) {
|
|
6063
|
+
const index = bullet.dataset.index;
|
|
6064
|
+
if (index != null) {
|
|
6065
|
+
this.showByIndex(parseInt(index));
|
|
6066
|
+
}
|
|
6067
|
+
}
|
|
6068
|
+
};
|
|
6069
|
+
const bulletFill = document.createElement("div");
|
|
6070
|
+
bulletFill.classList.add("cards-slider__timeline-fill");
|
|
6071
|
+
bullet.append(bulletFill);
|
|
6072
|
+
bullets.appendChild(bullet);
|
|
6073
|
+
}
|
|
6074
|
+
// const onUpdateActiveIndex = (activeIndex: number) => {
|
|
6075
|
+
// if (activeIndex >= 0 && activeIndex < count) {
|
|
6076
|
+
// for (const bullet of bullets.querySelectorAll(".cards-slider__bullet--active")) {
|
|
6077
|
+
// bullet.classList.toggle("cards-slider__bullet--active");
|
|
6078
|
+
// }
|
|
6079
|
+
// bullets.querySelector(`.cards-slider__bullet[data-index="${activeIndex}"]`)?.classList.toggle("cards-slider__bullet--active");
|
|
6080
|
+
// }
|
|
6081
|
+
// };
|
|
6082
|
+
const onUpdateTimelineProgress = (index, progress, isActive) => {
|
|
6083
|
+
if (index >= 0 && index < count) {
|
|
6084
|
+
const bullet = bullets.querySelector(`.cards-slider__timeline:nth-child(${index + 1})`);
|
|
6085
|
+
const bulletFill = bullet?.querySelector(".cards-slider__timeline-fill");
|
|
6086
|
+
bullet?.classList[isActive ? "add" : "remove"]("cards-slider__timeline--active");
|
|
6087
|
+
if (bulletFill != null) {
|
|
6088
|
+
// todo remove progress after slide changed?
|
|
6089
|
+
if (this.config.getLayoutDirection() === "rtl") {
|
|
6090
|
+
progress = -1 * progress;
|
|
6091
|
+
}
|
|
6092
|
+
bulletFill.style.setProperty("transform", `translateX(${progress}%)`);
|
|
6093
|
+
}
|
|
6094
|
+
}
|
|
6095
|
+
};
|
|
6096
|
+
return [bullets, onUpdateTimelineProgress];
|
|
6097
|
+
}
|
|
6098
|
+
async showByIndex(newIndex) {
|
|
6099
|
+
const prevIndex = this.activeIndex;
|
|
6100
|
+
if (this.isAnimating)
|
|
6101
|
+
return prevIndex;
|
|
6102
|
+
if (newIndex === prevIndex)
|
|
6103
|
+
return prevIndex;
|
|
6104
|
+
if (prevIndex !== -1) {
|
|
6105
|
+
// skip for slider start
|
|
6106
|
+
this.config.onSlideLeft(this.slides[prevIndex].element, prevIndex);
|
|
6107
|
+
await this.config.onSlideStop();
|
|
6108
|
+
}
|
|
6109
|
+
const { index, loadingError } = await this.initAndRenderSlide(newIndex);
|
|
6110
|
+
if (loadingError) {
|
|
6111
|
+
// todo via updateTimeline ????
|
|
6112
|
+
this.config.onSlideLoadingError(index, loadingError);
|
|
6113
|
+
}
|
|
6114
|
+
if (!loadingError) {
|
|
6115
|
+
this.onShowSlide(index);
|
|
6116
|
+
}
|
|
6117
|
+
await this.slideTo(index);
|
|
6118
|
+
if (!loadingError) {
|
|
6119
|
+
this.config.onSlideStart();
|
|
6120
|
+
}
|
|
6121
|
+
return newIndex;
|
|
6122
|
+
}
|
|
6123
|
+
async showNextSlide() {
|
|
6124
|
+
const prevIndex = this.activeIndex;
|
|
6125
|
+
if (this.isAnimating)
|
|
6126
|
+
return prevIndex;
|
|
6127
|
+
const newIndex = prevIndex + 1;
|
|
6128
|
+
if (newIndex < 0 || newIndex >= this.slides.length) {
|
|
6129
|
+
return null;
|
|
6130
|
+
}
|
|
6131
|
+
if (prevIndex !== -1) {
|
|
6132
|
+
// skip for slider start
|
|
6133
|
+
this.config.onSlideLeft(this.slides[prevIndex].element, prevIndex);
|
|
6134
|
+
await this.config.onSlideStop();
|
|
6135
|
+
}
|
|
6136
|
+
const { index, loadingError } = await this.initAndRenderSlide(newIndex);
|
|
6137
|
+
if (loadingError) {
|
|
6138
|
+
// todo via updateTimeline ????
|
|
6139
|
+
this.config.onSlideLoadingError(index, loadingError);
|
|
6140
|
+
}
|
|
6141
|
+
if (!loadingError) {
|
|
6142
|
+
this.onShowSlide(index);
|
|
6143
|
+
}
|
|
6144
|
+
await this.slideTo(index);
|
|
6145
|
+
if (!loadingError) {
|
|
6146
|
+
this.config.onSlideStart();
|
|
6147
|
+
}
|
|
6148
|
+
return newIndex;
|
|
6149
|
+
}
|
|
6150
|
+
async initAndRenderSlide(index) {
|
|
6151
|
+
this.config.onBeforeLoadSlide(index);
|
|
6152
|
+
let showSlidePromise;
|
|
6153
|
+
if (!this.slidesFirstRenders[index].called) {
|
|
6154
|
+
// first render call
|
|
6155
|
+
this.slidesFirstRenders[index].called = true;
|
|
6156
|
+
showSlidePromise = new Promise(resolve => {
|
|
6157
|
+
this.slidesFirstRenders[index].firstRenderCall(resolve);
|
|
6158
|
+
}).then(_ => _);
|
|
6159
|
+
}
|
|
6160
|
+
else {
|
|
6161
|
+
showSlidePromise = this.config.onBeforeShowSlide(this.slides[index].element, index);
|
|
6162
|
+
}
|
|
6163
|
+
try {
|
|
6164
|
+
const { moveToIndex } = await showSlidePromise;
|
|
6165
|
+
if (moveToIndex !== index) {
|
|
6166
|
+
index = moveToIndex;
|
|
6167
|
+
// jump to necessary slide (from WidgetQuest for instance)
|
|
6168
|
+
return this.initAndRenderSlide(index);
|
|
6169
|
+
}
|
|
6170
|
+
else {
|
|
6171
|
+
return { index, loadingError: undefined };
|
|
6172
|
+
}
|
|
6173
|
+
}
|
|
6174
|
+
catch (loadingError) {
|
|
6175
|
+
// catch loading error
|
|
6176
|
+
// this.config.onSlideLoadingError(index, e as string);
|
|
6177
|
+
console.error(loadingError);
|
|
6178
|
+
return { index, loadingError: loadingError };
|
|
6179
|
+
}
|
|
6180
|
+
}
|
|
6181
|
+
onShowSlide(index) {
|
|
6182
|
+
// this.updateBulletActiveIndex(index);
|
|
6183
|
+
this.config.onShowSlide(this.slides[index].element, index);
|
|
6184
|
+
// this.config.onSlideStart();
|
|
6185
|
+
}
|
|
6186
|
+
onUpdateSizeMetrics(metrics) {
|
|
6187
|
+
// this.slideTo(this.activeIndex, 0);
|
|
6188
|
+
}
|
|
6189
|
+
getSlideOffset(index) {
|
|
6190
|
+
if (!this.slides.length)
|
|
6191
|
+
return 0;
|
|
6192
|
+
const k = this.config.getLayoutDirection() === "ltr" ? -1 : 1;
|
|
6193
|
+
const cardWidth = this.slides[0].element.clientWidth;
|
|
6194
|
+
return k * index * cardWidth;
|
|
6195
|
+
}
|
|
6196
|
+
async slideTo(index, speed = 300) {
|
|
6197
|
+
if (index < 0 || index > this.slides.length - 1 || this.isAnimating)
|
|
6198
|
+
return;
|
|
6199
|
+
const cardOffset = this.getSlideOffset(index);
|
|
6200
|
+
await this.translateTo(cardOffset, speed);
|
|
6201
|
+
this.activeIndex = index;
|
|
6202
|
+
}
|
|
6203
|
+
setTranslate(value) {
|
|
6204
|
+
this.sliderTrack?.style.setProperty("transform", `translateX(${value}px)`);
|
|
6205
|
+
}
|
|
6206
|
+
setTransition(duration = 300) {
|
|
6207
|
+
this.sliderTrack?.style.setProperty("transition", `transform ${duration}ms`);
|
|
6208
|
+
}
|
|
6209
|
+
async translateTo(translate, speed) {
|
|
6210
|
+
if (this.isAnimating)
|
|
6211
|
+
return;
|
|
6212
|
+
this.setTransition(speed);
|
|
6213
|
+
this.setTranslate(translate);
|
|
6214
|
+
if (speed > 0) {
|
|
6215
|
+
this.isAnimating = true;
|
|
6216
|
+
await this.waitTransitionEnd();
|
|
6217
|
+
this.isAnimating = false;
|
|
6218
|
+
}
|
|
6219
|
+
}
|
|
6220
|
+
waitTransitionEnd() {
|
|
6221
|
+
const sliderTrack = this.sliderTrack;
|
|
6222
|
+
if (!sliderTrack)
|
|
6223
|
+
return Promise.resolve();
|
|
6224
|
+
return new Promise(resolve => {
|
|
6225
|
+
const handler = (e) => {
|
|
6226
|
+
if (e.propertyName === "transform") {
|
|
6227
|
+
sliderTrack.style.transitionDuration = "0ms";
|
|
6228
|
+
resolve();
|
|
6229
|
+
}
|
|
6230
|
+
};
|
|
6231
|
+
sliderTrack.addEventListener("transitionend", handler, { once: true });
|
|
6232
|
+
});
|
|
6233
|
+
}
|
|
6234
|
+
destroy() {
|
|
6235
|
+
this.activeSlide?.timer.stop();
|
|
6236
|
+
if (this.slideWrapperElement != null && this.config.root != null) {
|
|
6237
|
+
this.config.root.removeChild(this.slideWrapperElement);
|
|
6238
|
+
}
|
|
6239
|
+
}
|
|
6240
|
+
updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError) {
|
|
6241
|
+
switch (action) {
|
|
6242
|
+
case "before_start" /* TIMELINE_ACTION.BEFORE_START */: {
|
|
6243
|
+
// switch timeline to active slide and wait for start (wait VOD loading)
|
|
6244
|
+
// console.log("TIMELINE_ACTION.BEFORE_START", { activeSlide: this.activeSlide, duration });
|
|
6245
|
+
this.timelineController.onSlideBeforeStart(slideIndex);
|
|
6246
|
+
break;
|
|
6247
|
+
}
|
|
6248
|
+
case "start" /* TIMELINE_ACTION.START */: {
|
|
6249
|
+
this.config.onSlideDataResume();
|
|
6250
|
+
// also start after data waiting or pause
|
|
6251
|
+
// destroy on IAM closing
|
|
6252
|
+
// console.log("TIMELINE_ACTION.START", {
|
|
6253
|
+
// activeSlide: this.activeSlide,
|
|
6254
|
+
// index: this.activeIndex,
|
|
6255
|
+
// duration,
|
|
6256
|
+
// });
|
|
6257
|
+
let resumeTimer = false;
|
|
6258
|
+
if (duration > 0) {
|
|
6259
|
+
// skip timer start for slide/layer with disabled timeline
|
|
6260
|
+
resumeTimer = true;
|
|
6261
|
+
}
|
|
6262
|
+
if (currentTime === duration) {
|
|
6263
|
+
// skip timer start for already ended layer timeline
|
|
6264
|
+
// skip timer start for already ended layer timeline
|
|
6265
|
+
resumeTimer = false;
|
|
6266
|
+
}
|
|
6267
|
+
if (resumeTimer) {
|
|
6268
|
+
this.activeSlide?.timer.resume(currentTime, duration);
|
|
6269
|
+
}
|
|
6270
|
+
break;
|
|
6271
|
+
}
|
|
6272
|
+
case "pause" /* TIMELINE_ACTION.PAUSE */: {
|
|
6273
|
+
if (showLoader) {
|
|
6274
|
+
this.config.onSlideDataWaiting();
|
|
6275
|
+
}
|
|
6276
|
+
this.activeSlide?.timer.pause();
|
|
6277
|
+
// console.log("TIMELINE_ACTION.PAUSE", { activeSlide: this.activeSlide, duration });
|
|
6278
|
+
break;
|
|
6279
|
+
}
|
|
6280
|
+
case "stop" /* TIMELINE_ACTION.STOP */: {
|
|
6281
|
+
// loading error
|
|
6282
|
+
if (showError) {
|
|
6283
|
+
this.config.onSlideDataError();
|
|
6284
|
+
}
|
|
6285
|
+
this.activeSlide?.timer.stop();
|
|
6286
|
+
// todo нужен STOP когда вручную переключаем слайд на другой
|
|
6287
|
+
// console.log("TIMELINE_ACTION.STOP", { activeSlide: this.activeSlide, duration });
|
|
6288
|
+
break;
|
|
6289
|
+
}
|
|
6290
|
+
}
|
|
6291
|
+
}
|
|
6292
|
+
// private onSlideTimerUpdate(progress: number) {
|
|
6293
|
+
// this.updateTimelineProgress(this.activeIndex, progress);
|
|
6294
|
+
// }
|
|
6295
|
+
async onSlideTimerEnd() {
|
|
6296
|
+
await this.config.onSlideStop();
|
|
6297
|
+
this.config.onSlideTimerEnd();
|
|
6298
|
+
}
|
|
6299
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`{
|
|
6300
|
+
slides: Array<T>;
|
|
6301
|
+
root: HTMLElement;
|
|
6302
|
+
nonce?: string;
|
|
6303
|
+
navbarAppearance: NavbarAppearance;
|
|
6304
|
+
slideRender: SlideRender<T>;
|
|
6305
|
+
onSlideMounted: OnSlideMounted;
|
|
6306
|
+
onBeforeShowSlide: OnBeforeShowSlide;
|
|
6307
|
+
onBeforeLoadSlide: OnBeforeLoadSlide;
|
|
6308
|
+
onSlideLoadingError: OnSlideLoadingError;
|
|
6309
|
+
onShowSlide: OnShowSlide;
|
|
6310
|
+
onSlideLeft: OnSlideLeft;
|
|
6311
|
+
getLayoutDirection: GetLayoutDirection;
|
|
6312
|
+
|
|
6313
|
+
onSlideTimerEnd: OnSlideTimerEnd;
|
|
6314
|
+
onSlideStart: OnSlideStart;
|
|
6315
|
+
onSlideStop: OnSlideStop;
|
|
6316
|
+
onSlideDataWaiting: OnSlideDataWaiting;
|
|
6317
|
+
onSlideDataResume: OnSlideDataResume;
|
|
6318
|
+
onSlideDataError: OnSlideDataError;
|
|
6319
|
+
}`]; }
|
|
6320
|
+
}
|
|
6321
|
+
|
|
6322
|
+
class CardApi {
|
|
6323
|
+
config;
|
|
6324
|
+
get layoutDirection() {
|
|
6325
|
+
return this.activeSlide.layoutDirection;
|
|
6326
|
+
}
|
|
6327
|
+
static renderedBoxClassName = "narrative-slide-box-rendered";
|
|
6328
|
+
static prerenderBoxClassName = "narrative-slide-box-prerender";
|
|
6329
|
+
_singleCardSlideWrapper;
|
|
6330
|
+
_viewport;
|
|
6331
|
+
_getViewportWidth;
|
|
6332
|
+
_getViewportHeight;
|
|
6333
|
+
_overlappingActionBarHeight;
|
|
6334
|
+
_separateUserAndAppPause;
|
|
6335
|
+
_useSdkCacheForMultislideMode;
|
|
6336
|
+
sdkApi;
|
|
6337
|
+
activeSlide = null;
|
|
6338
|
+
slides = [];
|
|
6339
|
+
slidesMode = 0 /* SLIDES_MODE.SINGLE */;
|
|
6340
|
+
cardLoadingStateController = null;
|
|
6341
|
+
sizeMetrics = {
|
|
6342
|
+
fontSize: "0px",
|
|
6343
|
+
isFullscreen: false,
|
|
6344
|
+
slideOffsetMargin: "0px",
|
|
6345
|
+
xOffset: "0px",
|
|
6346
|
+
yOffset: "0px",
|
|
6347
|
+
};
|
|
6348
|
+
constructor(config) {
|
|
6349
|
+
this.config = config;
|
|
6350
|
+
this.sdkApi = config.sdkApi;
|
|
6351
|
+
this._singleCardSlideWrapper = config.slideWrapper;
|
|
6352
|
+
this._viewport = config.viewport;
|
|
6353
|
+
this._getViewportWidth = config.getViewportWidth;
|
|
6354
|
+
this._getViewportHeight = config.getViewportHeight;
|
|
6355
|
+
this._overlappingActionBarHeight = config.overlappingActionBarHeight ?? 0;
|
|
6356
|
+
this._separateUserAndAppPause = config.separateUserAndAppPause;
|
|
6357
|
+
this._useSdkCacheForMultislideMode = config.useSdkCacheForMultislideMode;
|
|
6358
|
+
this.refreshSizes = proxy(this.refreshSizes, this);
|
|
6359
|
+
this.getSdkClientVariables = proxy(this.getSdkClientVariables, this);
|
|
6360
|
+
this.refreshSizes();
|
|
6361
|
+
// todo - возможность не создавать slideApi в ctor (это не нужно для multislide mode)
|
|
6362
|
+
// но тогда все методы должны обходить случай когда activeSlide undefined
|
|
6363
|
+
this.activeSlide = new SlideApi$1({
|
|
6364
|
+
slideApiDeps: new SlideApiDepsSingleSlideMode(this.config.sdkApi),
|
|
6365
|
+
slideWrapper: this.config.slideWrapper,
|
|
6366
|
+
viewport: this.config.viewport,
|
|
6367
|
+
userResizeHandler: this.config.userResizeHandler,
|
|
6368
|
+
slideRatio: this.config.slideRatio,
|
|
6369
|
+
isFullscreen: this.config.isFullscreen,
|
|
6370
|
+
getViewportWidth: this.config.getViewportWidth,
|
|
6371
|
+
getViewportHeight: this.config.getViewportHeight,
|
|
6372
|
+
overlappingActionBarHeight: this.config.overlappingActionBarHeight,
|
|
6373
|
+
separateUserAndAppPause: this.config.separateUserAndAppPause,
|
|
6374
|
+
root: this.config.root,
|
|
6375
|
+
index: 0,
|
|
6376
|
+
getSdkClientVariables: this.getSdkClientVariables,
|
|
6377
|
+
});
|
|
6378
|
+
this.activeSlide.onUpdateSizeMetrics(this.sizeMetrics);
|
|
6379
|
+
if (SlideApi$1.checkPreloadedInLayoutSlide()) {
|
|
6380
|
+
this.activeSlide.initPreloadedInLayoutSlide(this.config.slideLoadedCb);
|
|
6381
|
+
}
|
|
6382
|
+
this.initListeners();
|
|
6383
|
+
}
|
|
6384
|
+
get state() {
|
|
6385
|
+
// TODO remove usage from web-sdk
|
|
6386
|
+
return this.activeSlide.state;
|
|
6387
|
+
}
|
|
6388
|
+
async destroy() {
|
|
6389
|
+
await this.activeSlide.destroy();
|
|
6390
|
+
await Promise.all(this.slides.map(({ slide }) => {
|
|
6391
|
+
if (slide !== this.activeSlide) {
|
|
6392
|
+
return slide?.destroy();
|
|
6393
|
+
}
|
|
6394
|
+
}));
|
|
6395
|
+
this.destroyListeners();
|
|
6396
|
+
}
|
|
6397
|
+
initListeners() {
|
|
6398
|
+
// @ts-ignore
|
|
6399
|
+
this._viewport.addEventListener("resize", this.refreshSizes);
|
|
6400
|
+
}
|
|
6401
|
+
destroyListeners() {
|
|
6402
|
+
// @ts-ignore
|
|
6403
|
+
this._viewport.removeEventListener("resize", this.refreshSizes);
|
|
6404
|
+
// todo call via activeSlide.refreshSizes
|
|
6405
|
+
}
|
|
6406
|
+
_savedViewportWidth = null;
|
|
6407
|
+
_savedViewportHeight = null;
|
|
6408
|
+
refreshSizes() {
|
|
6409
|
+
const viewportWidth = this._getViewportWidth();
|
|
6410
|
+
const viewportHeight = this._getViewportHeight();
|
|
6411
|
+
if (this._savedViewportWidth === viewportWidth && this._savedViewportHeight === viewportHeight) {
|
|
6412
|
+
return;
|
|
6413
|
+
}
|
|
6414
|
+
this._savedViewportWidth = viewportWidth;
|
|
6415
|
+
this._savedViewportHeight = viewportHeight;
|
|
6416
|
+
const viewportRatio = viewportWidth / viewportHeight;
|
|
6417
|
+
let slideWidth = 0;
|
|
6418
|
+
let slideHeight = 0;
|
|
6419
|
+
// _ratio = 310 / 480,
|
|
6420
|
+
const _ratio = this.config.slideRatio;
|
|
6421
|
+
let _isFullscreen = this.config.isFullscreen;
|
|
6422
|
+
let offset = 0;
|
|
6423
|
+
let xOffset = "0px";
|
|
6424
|
+
// for elements with bottom anchor (absolute position)
|
|
6425
|
+
let yOffset = "0px";
|
|
6426
|
+
// todo - mobile only (or isIos or isAndroid)
|
|
6427
|
+
if (this.sdkApi.isAndroid || this.sdkApi.isIOS) {
|
|
6428
|
+
if (viewportRatio > _ratio) {
|
|
6429
|
+
// disable _isFullscreen if viewport small
|
|
6430
|
+
_isFullscreen = false;
|
|
6431
|
+
}
|
|
6432
|
+
}
|
|
6433
|
+
let slideOffsetMargin = "";
|
|
6434
|
+
if (_isFullscreen) {
|
|
6435
|
+
// более квадратное чем надо (desktop)
|
|
6436
|
+
if (viewportRatio > _ratio) {
|
|
6437
|
+
// fit by height
|
|
6438
|
+
slideHeight = viewportHeight;
|
|
6439
|
+
slideWidth = Math.ceil(slideHeight * _ratio);
|
|
6440
|
+
offset = Math.ceil(slideWidth - viewportWidth) / 2;
|
|
6441
|
+
slideOffsetMargin = "0 " + -offset + "px"; // -8.5
|
|
6442
|
+
xOffset = offset + "px";
|
|
6443
|
+
}
|
|
6444
|
+
else {
|
|
6445
|
+
// fit by width, top and bottom - to offscreen or fill with bg image
|
|
6446
|
+
slideWidth = viewportWidth;
|
|
6447
|
+
slideHeight = Math.ceil(viewportWidth / _ratio);
|
|
6448
|
+
offset = Math.ceil(slideHeight - viewportHeight) / 2;
|
|
6449
|
+
slideOffsetMargin = -1 * offset + "px" + " 0 ";
|
|
6450
|
+
// offset from viewport bottom to StoryBottom plus safe area offset bottom
|
|
6451
|
+
yOffset = `calc(${offset + this._overlappingActionBarHeight}px + env(safe-area-inset-bottom))`;
|
|
6452
|
+
// detect safe area offset
|
|
6453
|
+
}
|
|
6454
|
+
}
|
|
6455
|
+
else {
|
|
6456
|
+
// более квадратное чем надо
|
|
6457
|
+
if (viewportRatio > _ratio) {
|
|
6458
|
+
// fit by width, top and bottom - to offscreen
|
|
6459
|
+
slideWidth = viewportWidth;
|
|
6460
|
+
slideHeight = Math.ceil(viewportWidth / _ratio);
|
|
6461
|
+
offset = Math.ceil(slideHeight - viewportHeight) / 2;
|
|
6462
|
+
slideOffsetMargin = -offset + "px" + " 0 ";
|
|
6463
|
+
yOffset = offset + this._overlappingActionBarHeight + "px";
|
|
6464
|
+
}
|
|
6465
|
+
else {
|
|
6466
|
+
// вьюпорт более вытянутый чем надо
|
|
6467
|
+
// fit by height, sides - to offscreen
|
|
6468
|
+
slideHeight = viewportHeight;
|
|
6469
|
+
slideWidth = Math.ceil(slideHeight * _ratio);
|
|
6470
|
+
offset = Math.ceil(slideWidth - viewportWidth) / 2;
|
|
6471
|
+
slideOffsetMargin = "0 " + -offset + "px"; // -8.5
|
|
6472
|
+
xOffset = offset + "px";
|
|
6473
|
+
}
|
|
6474
|
+
}
|
|
6475
|
+
const fontSizeNumber = slideWidth / 20;
|
|
6476
|
+
const fontSize = `${fontSizeNumber}px`;
|
|
6477
|
+
const sizeMetrics = { fontSize, xOffset, yOffset, isFullscreen: _isFullscreen, slideOffsetMargin };
|
|
6478
|
+
this.sizeMetrics = sizeMetrics;
|
|
6479
|
+
this.activeSlide?.onUpdateSizeMetrics(sizeMetrics);
|
|
6480
|
+
this.slides.forEach(({ slide }) => {
|
|
6481
|
+
if (slide !== this.activeSlide) {
|
|
6482
|
+
slide?.onUpdateSizeMetrics(sizeMetrics);
|
|
6483
|
+
}
|
|
6484
|
+
});
|
|
6485
|
+
this.slider?.onUpdateSizeMetrics(sizeMetrics);
|
|
6486
|
+
if (this.config.userResizeHandler != null) {
|
|
6487
|
+
this.config.userResizeHandler({ viewportWidth, viewportHeight, fontSize: fontSizeNumber });
|
|
6488
|
+
}
|
|
6489
|
+
}
|
|
6490
|
+
async showSlide(html) {
|
|
6491
|
+
this.slidesMode = 0 /* SLIDES_MODE.SINGLE */;
|
|
6492
|
+
if (this.activeSlide == null) {
|
|
6493
|
+
this.activeSlide = new SlideApi$1({
|
|
6494
|
+
slideApiDeps: new SlideApiDepsSingleSlideMode(this.config.sdkApi),
|
|
6495
|
+
slideWrapper: this.config.slideWrapper,
|
|
6496
|
+
viewport: this.config.viewport,
|
|
6497
|
+
userResizeHandler: this.config.userResizeHandler,
|
|
6498
|
+
slideRatio: this.config.slideRatio,
|
|
6499
|
+
isFullscreen: this.config.isFullscreen,
|
|
6500
|
+
getViewportWidth: this.config.getViewportWidth,
|
|
6501
|
+
getViewportHeight: this.config.getViewportHeight,
|
|
6502
|
+
overlappingActionBarHeight: this.config.overlappingActionBarHeight,
|
|
6503
|
+
separateUserAndAppPause: this.config.separateUserAndAppPause,
|
|
6504
|
+
root: this.config.root,
|
|
6505
|
+
// refreshSizes: this.refreshSizes,
|
|
6506
|
+
index: 0,
|
|
6507
|
+
getSdkClientVariables: this.getSdkClientVariables,
|
|
6508
|
+
});
|
|
6509
|
+
this.activeSlide.onUpdateSizeMetrics(this.sizeMetrics);
|
|
6510
|
+
}
|
|
6511
|
+
return this.activeSlide.showSlide(html);
|
|
6512
|
+
}
|
|
6513
|
+
slider = null;
|
|
6514
|
+
async showSlides(slides, cardAppearance, index = 0) {
|
|
6515
|
+
this.slidesMode = 1 /* SLIDES_MODE.MULTIPLE */;
|
|
6516
|
+
if (this.cardLoadingStateController === null) {
|
|
6517
|
+
this.cardLoadingStateController = new CardLoadingStateController(this.sdkApi.onCardLoadingStateChange.bind(this.sdkApi));
|
|
6518
|
+
}
|
|
6519
|
+
this.cardLoadingStateController.onSetLoadStartState();
|
|
6520
|
+
slides.forEach((content, index) => {
|
|
6521
|
+
if (this.slides[index] == null) {
|
|
6522
|
+
const item = { content, resourcesReadyPromise: null };
|
|
6523
|
+
if (this._useSdkCacheForMultislideMode) {
|
|
6524
|
+
item.resourcesReadyPromise = new Promise((resolve, reject) => {
|
|
6525
|
+
item.resourcesReadyPromisesResolver = { resolve, reject };
|
|
6526
|
+
});
|
|
6527
|
+
}
|
|
6528
|
+
else {
|
|
6529
|
+
item.resourcesReadyPromise = Promise.resolve();
|
|
6530
|
+
}
|
|
6531
|
+
this.slides[index] = item;
|
|
6532
|
+
}
|
|
6533
|
+
else {
|
|
6534
|
+
// for case when sdk call setSlideInCacheStatus before showSlides and for slideReloading (after loading error)
|
|
6535
|
+
this.slides[index].content = content;
|
|
6536
|
+
if (this.slides[index].resourcesReadyPromise == null) {
|
|
6537
|
+
if (this._useSdkCacheForMultislideMode) {
|
|
6538
|
+
this.slides[index].resourcesReadyPromise = new Promise((resolve, reject) => {
|
|
6539
|
+
this.slides[index].resourcesReadyPromisesResolver = { resolve, reject };
|
|
6540
|
+
});
|
|
6541
|
+
}
|
|
6542
|
+
else {
|
|
6543
|
+
this.slides[index].resourcesReadyPromise = Promise.resolve();
|
|
6544
|
+
}
|
|
6545
|
+
}
|
|
6546
|
+
}
|
|
6547
|
+
});
|
|
6548
|
+
const onBeforeShowSlide = (slideElement, index) => {
|
|
6549
|
+
if (this.slides[index].slide == null) {
|
|
6550
|
+
const slideApi = new SlideApi$1({
|
|
6551
|
+
slideApiDeps: new SlideApiDepsMultiSlideMode(this.config.sdkApi, this.slider),
|
|
6552
|
+
slideWrapper: slideElement,
|
|
6553
|
+
viewport: this.config.viewport,
|
|
6554
|
+
userResizeHandler: this.config.userResizeHandler,
|
|
6555
|
+
slideRatio: this.config.slideRatio,
|
|
6556
|
+
isFullscreen: this.config.isFullscreen,
|
|
6557
|
+
getViewportWidth: this.config.getViewportWidth,
|
|
6558
|
+
getViewportHeight: this.config.getViewportHeight,
|
|
6559
|
+
overlappingActionBarHeight: this.config.overlappingActionBarHeight,
|
|
6560
|
+
separateUserAndAppPause: this.config.separateUserAndAppPause,
|
|
6561
|
+
root: this.config.root,
|
|
6562
|
+
index,
|
|
6563
|
+
getSdkClientVariables: this.getSdkClientVariables,
|
|
6564
|
+
});
|
|
6565
|
+
slideApi.onUpdateSizeMetrics(this.sizeMetrics);
|
|
6566
|
+
this.slides[index].slide = slideApi;
|
|
6567
|
+
// TODO для виджета квест нужно при каждом показе слайда инициализировать виджет???
|
|
6568
|
+
// пока вызов убран из за того что init жестко завязан на single slide mode
|
|
6569
|
+
this.activeSlide = this.slides[index].slide;
|
|
6570
|
+
return this.slides[index].slide.showSlide().then(_ => ({ moveToIndex: index }));
|
|
6571
|
+
}
|
|
6572
|
+
else {
|
|
6573
|
+
// quot - // TODO для виджета квест нужно при каждом показе слайда инициализировать виджет???
|
|
6574
|
+
// // пока вызов убран из за того что init жестко завязан на single slide mode
|
|
6575
|
+
// из-за того что перед показом нет приватного вызова SlideApi::_init пока что нужно руками вызывать
|
|
6576
|
+
// slide.activeLayer.timeline.triggerSlideLoadState();
|
|
6577
|
+
// для того чтобы запустить TIMELINE_ACTION.BEFORE_START что нужно для таймлайна слайдера
|
|
6578
|
+
// todo убрать в случае если будем вызывать new SlideApi перед каждым показом слайда
|
|
6579
|
+
this.slides[index].slide.activeLayer.timeline.triggerSlideLoadState();
|
|
6580
|
+
}
|
|
6581
|
+
this.activeSlide = this.slides[index].slide;
|
|
6582
|
+
// TODO handle moveToIndex
|
|
6583
|
+
// return resolve or reject with reason
|
|
6584
|
+
// TODO для виджета квест нужно при каждом показе слайда инициализировать виджет???
|
|
6585
|
+
// пока вызов убран из за того что init жестко завязан на single slide mode
|
|
6586
|
+
// return this.slides[index].slide.showSlide().then(_ => ({ moveToIndex: index }));
|
|
6587
|
+
return Promise.resolve({ moveToIndex: index });
|
|
6588
|
+
// вызываем здесь cardLoadingState - loading
|
|
6589
|
+
// новый cb - onSlideShowError - там вызов cardLoadingState error - через cardLoadingStateManager
|
|
6590
|
+
// в onShowSlide- cardLoadingState load done
|
|
6591
|
+
// внутри слайдера - обрабатываем moveToIndex
|
|
6592
|
+
};
|
|
6593
|
+
const onBeforeLoadSlide = index => {
|
|
6594
|
+
this.cardLoadingStateController.onSetLoadStartState();
|
|
6595
|
+
};
|
|
6596
|
+
const onSlideLoadingError = (index, reason) => {
|
|
6597
|
+
this.cardLoadingStateController.onSetLoadErrorState(reason);
|
|
6598
|
+
};
|
|
6599
|
+
const onShowSlide = (slide, index) => {
|
|
6600
|
+
this.cardLoadingStateController.onSetLoadEndState();
|
|
6601
|
+
this.sdkApi.emitEvent("showSlide", { cardId: this.slides[index]?.slide?.slide.cardId ?? 0, index });
|
|
6602
|
+
// if (index === 0) {
|
|
6603
|
+
// this.activeSlide = slideApi;
|
|
6604
|
+
// }
|
|
6605
|
+
// const { result, cardId, slideIndex, reason } = await slideApi.showSlide();
|
|
6606
|
+
// if (index === 0) {
|
|
6607
|
+
// if (result) {
|
|
6608
|
+
// this.sdkApi.onCardLoadingStateChange(CARD_LOADING_STATE.LOADED);
|
|
6609
|
+
// this.sdkApi.emitEvent("showSlide", { cardId: this.activeSlide.slide.cardId, index });
|
|
6610
|
+
// } else {
|
|
6611
|
+
// this.sdkApi.onCardLoadingStateChange(CARD_LOADING_STATE.LOADING, reason);
|
|
6612
|
+
// }
|
|
6613
|
+
// }
|
|
6614
|
+
//
|
|
6615
|
+
// onShowActiveCardResolver({ cardId, slideIndex });
|
|
6616
|
+
};
|
|
6617
|
+
const onSlideLeft = (slide, index) => {
|
|
6618
|
+
this.sdkApi.emitEvent("slideLeft", { cardId: this.slides[index]?.slide?.slide.cardId ?? 0, index });
|
|
6619
|
+
};
|
|
6620
|
+
const slideRender = ({ content, canMediaMount }, index, onBeforeShowSlideDuringMounting) => {
|
|
6621
|
+
const slideWrapper = document.createElement("div");
|
|
6622
|
+
slideWrapper.classList.add("narrative-slide-wrapper");
|
|
6623
|
+
slideWrapper.classList.add("stories-viewer");
|
|
6624
|
+
const slideOffset = document.createElement("div");
|
|
6625
|
+
slideOffset.classList.add("narrative-slide-offset");
|
|
6626
|
+
const slideBoxPrerender = document.createElement("div");
|
|
6627
|
+
slideBoxPrerender.classList.add("narrative-slide-box");
|
|
6628
|
+
slideBoxPrerender.classList.add("narrative-slide-box-prerender");
|
|
6629
|
+
const slideBoxRendered = document.createElement("div");
|
|
6630
|
+
slideBoxRendered.classList.add("narrative-slide-box");
|
|
6631
|
+
slideBoxRendered.classList.add("narrative-slide-box-rendered");
|
|
6632
|
+
const style = document.createElement("style");
|
|
6633
|
+
if (this.config.nonce != null) {
|
|
6634
|
+
style.nonce = this.config.nonce;
|
|
6635
|
+
}
|
|
6636
|
+
const paddingTop = `${String(100 / this.config.slideRatio)}%`;
|
|
6637
|
+
// .narrative-slide-box {
|
|
6638
|
+
// padding: <?= $slideRatioPadding ?> 0 0 0;
|
|
6639
|
+
// }
|
|
6640
|
+
// style.sheet?.insertRule(`.narrative-slide-box {padding: ${paddingTop} 0 0 0;`);
|
|
6641
|
+
slideBoxRendered.style.padding = `${paddingTop} 0 0 0`;
|
|
6642
|
+
slideBoxPrerender.style.padding = `${paddingTop} 0 0 0`;
|
|
6643
|
+
// slideBoxPrerender.innerHTML = card;
|
|
6644
|
+
// extract and mount solid or gradient bg color (w/o bg image)
|
|
6645
|
+
onBeforeShowSlideDuringMounting.then(callback => {
|
|
6646
|
+
callback(canMediaMount.then(() => {
|
|
6647
|
+
// mount slide media content (after cache is ready event)
|
|
6648
|
+
slideBoxPrerender.innerHTML = content;
|
|
6649
|
+
// create slideApi
|
|
6650
|
+
// call init, init should return moveToIndex
|
|
6651
|
+
return onBeforeShowSlide(slideWrapper, index);
|
|
6652
|
+
}));
|
|
6653
|
+
});
|
|
6654
|
+
slideOffset.appendChild(slideBoxPrerender);
|
|
6655
|
+
slideOffset.appendChild(slideBoxRendered);
|
|
6656
|
+
slideWrapper.appendChild(slideOffset);
|
|
6657
|
+
slideWrapper.appendChild(style);
|
|
6658
|
+
return slideWrapper;
|
|
6659
|
+
};
|
|
6660
|
+
new Promise(resolve => {
|
|
6661
|
+
});
|
|
6662
|
+
// onContentMounted
|
|
6663
|
+
const onSlideMounted = async (slideElement, index) => {
|
|
6664
|
+
// if (index === 0) {
|
|
6665
|
+
// this.activeSlide = slideApi;
|
|
6666
|
+
// }
|
|
6667
|
+
//
|
|
6668
|
+
// const { result, cardId, slideIndex, reason } = await slideApi.showSlide();
|
|
6669
|
+
//
|
|
6670
|
+
//
|
|
6671
|
+
// if (index === 0) {
|
|
6672
|
+
// if (result) {
|
|
6673
|
+
// this.sdkApi.onCardLoadingStateChange(CARD_LOADING_STATE.LOADED);
|
|
6674
|
+
// this.sdkApi.emitEvent("showSlide", { cardId: this.activeSlide.slide.cardId, index });
|
|
6675
|
+
// } else {
|
|
6676
|
+
// this.sdkApi.onCardLoadingStateChange(CARD_LOADING_STATE.LOADING, reason);
|
|
6677
|
+
// }
|
|
6678
|
+
// }
|
|
6679
|
+
//
|
|
6680
|
+
// onShowActiveCardResolver({ cardId, slideIndex });
|
|
6681
|
+
};
|
|
6682
|
+
if (this.slider != null) {
|
|
6683
|
+
this.slider.destroy();
|
|
6684
|
+
}
|
|
6685
|
+
this.slider = new Slider({
|
|
6686
|
+
root: this.config.root,
|
|
6687
|
+
slides: this.slides.map(({ content, resourcesReadyPromise }) => ({
|
|
6688
|
+
content,
|
|
6689
|
+
canMediaMount: resourcesReadyPromise,
|
|
6690
|
+
})),
|
|
6691
|
+
nonce: this.config.nonce,
|
|
6692
|
+
navbarAppearance: cardAppearance.navbar ?? {},
|
|
6693
|
+
slideRender,
|
|
6694
|
+
onSlideMounted,
|
|
6695
|
+
onBeforeShowSlide,
|
|
6696
|
+
onBeforeLoadSlide,
|
|
6697
|
+
onSlideLoadingError,
|
|
6698
|
+
onShowSlide,
|
|
6699
|
+
onSlideLeft,
|
|
6700
|
+
getLayoutDirection: () => this.layoutDirection,
|
|
6701
|
+
onSlideTimerEnd: () => this.activeSlide.slideTimerEnd(),
|
|
6702
|
+
onSlideStart: () => {
|
|
6703
|
+
// return Promise.resolve({currentTime: 0});
|
|
6704
|
+
this.cardLoadingStateController.onSetLoadEndState();
|
|
6705
|
+
return this.activeSlide.slideStart({ muted: true });
|
|
6706
|
+
},
|
|
6707
|
+
onSlideStop: () => this.activeSlide.slideStop({ prepareForRestart: 1 /* ON_SLIDE_STOP_PREPARE_FOR_RESTART.PREPARE */ }),
|
|
6708
|
+
onSlideDataWaiting: () => this.cardLoadingStateController.onSetLoadStartState(),
|
|
6709
|
+
onSlideDataResume: () => this.cardLoadingStateController.onSetLoadEndState(),
|
|
6710
|
+
onSlideDataError: () => this.cardLoadingStateController.onSetLoadEndState(),
|
|
6711
|
+
});
|
|
6712
|
+
await this.slider.showByIndex(index);
|
|
6713
|
+
// return await onShowActiveCard;
|
|
6714
|
+
}
|
|
6715
|
+
handleBackpress() {
|
|
6716
|
+
this.activeSlide.handleBackpress();
|
|
6717
|
+
}
|
|
6718
|
+
get layoutService() {
|
|
6719
|
+
return container.get({ identifier: "LayoutService" });
|
|
6720
|
+
}
|
|
6721
|
+
getLocalData() {
|
|
6722
|
+
return this.sdkApi.getCardLocalData();
|
|
6723
|
+
}
|
|
6724
|
+
async slideStart(config) {
|
|
6725
|
+
return this.activeSlide.slideStart(config);
|
|
6726
|
+
}
|
|
6727
|
+
async slideRestart(config) {
|
|
6728
|
+
return this.activeSlide.slideRestart(config);
|
|
6729
|
+
}
|
|
6730
|
+
async slideUserPause() {
|
|
6731
|
+
return this.activeSlide.slideUserPause();
|
|
6732
|
+
}
|
|
6733
|
+
async slideUserResume() {
|
|
6734
|
+
return this.activeSlide.slideUserResume();
|
|
6735
|
+
}
|
|
6736
|
+
/**
|
|
6737
|
+
* Call on app gone background
|
|
6738
|
+
*/
|
|
6739
|
+
async slideAppPause() {
|
|
6740
|
+
return this.activeSlide.slideAppPause();
|
|
6741
|
+
}
|
|
6742
|
+
/**
|
|
6743
|
+
* Call on app gone foreground after a background
|
|
6744
|
+
*/
|
|
6745
|
+
async slideAppResume() {
|
|
6746
|
+
return this.activeSlide.slideAppResume();
|
|
6747
|
+
}
|
|
6748
|
+
async slideStop(options) {
|
|
6749
|
+
return this.activeSlide.slideStop(options);
|
|
6750
|
+
}
|
|
6751
|
+
slideTimerEnd() {
|
|
6752
|
+
this.activeSlide.slideTimerEnd();
|
|
6753
|
+
}
|
|
6754
|
+
enableAudio() {
|
|
6755
|
+
this.activeSlide.enableAudio();
|
|
6756
|
+
}
|
|
6757
|
+
disableAudio() {
|
|
6758
|
+
this.activeSlide.disableAudio();
|
|
6759
|
+
}
|
|
6760
|
+
get isStopped() {
|
|
6761
|
+
return this.activeSlide.isStopped;
|
|
6762
|
+
}
|
|
6763
|
+
afterStartInitQueuePush(cb) {
|
|
6764
|
+
return this.activeSlide.afterStartInitQueuePush(cb);
|
|
6765
|
+
}
|
|
6766
|
+
afterAppResumeQueuePush(cb) {
|
|
6767
|
+
return this.activeSlide.afterAppResumeQueuePush(cb);
|
|
6768
|
+
}
|
|
6769
|
+
get activeLayer() {
|
|
6770
|
+
return this.activeSlide.slide.activeLayer;
|
|
6771
|
+
}
|
|
6772
|
+
get slide() {
|
|
6773
|
+
return this.activeSlide.slide;
|
|
6774
|
+
}
|
|
6775
|
+
showLayer(index) {
|
|
6776
|
+
this.activeSlide.showLayer(index);
|
|
6777
|
+
}
|
|
6778
|
+
slideClickHandler(targetElement, navigationDirection) {
|
|
6779
|
+
const result = this.activeSlide.slideClickHandler(targetElement, navigationDirection);
|
|
6780
|
+
// todo make via strategy pattern, singleSlide and multiSlide impl
|
|
6781
|
+
if (this.slidesMode === 1 /* SLIDES_MODE.MULTIPLE */ && result.canClickNext) {
|
|
6782
|
+
result.canClickNext = false; // handle nav click via CardsSlider, not via SDK
|
|
6783
|
+
const currentIndex = this.activeSlide.index;
|
|
6784
|
+
/**
|
|
6785
|
+
* business logic - avoid action on side slides click
|
|
6786
|
+
*/
|
|
6787
|
+
if (currentIndex === 0 && navigationDirection === "backward") {
|
|
6788
|
+
return result;
|
|
6789
|
+
}
|
|
6790
|
+
if (currentIndex === this.slides.length - 1 && navigationDirection === "forward") {
|
|
6791
|
+
return result;
|
|
6792
|
+
}
|
|
6793
|
+
let index = navigationDirection === "forward" ? currentIndex + 1 : currentIndex - 1;
|
|
6794
|
+
if (index >= this.slides.length) {
|
|
6795
|
+
index = 0;
|
|
6796
|
+
}
|
|
6797
|
+
else if (index < 0) {
|
|
6798
|
+
index = this.slides.length - 1;
|
|
6799
|
+
}
|
|
6800
|
+
this.slider.showByIndex(index).then(index => {
|
|
6801
|
+
if (currentIndex === index)
|
|
6802
|
+
return;
|
|
6803
|
+
this.activeSlide = this.slides[index].slide;
|
|
6804
|
+
});
|
|
6805
|
+
}
|
|
6806
|
+
return result;
|
|
6807
|
+
}
|
|
6808
|
+
slideSwipeUpHandler() {
|
|
6809
|
+
return this.activeSlide.slideSwipeUpHandler();
|
|
6810
|
+
}
|
|
6811
|
+
setTextInputResult(id, text) {
|
|
6812
|
+
this.activeSlide.setTextInputResult(id, text);
|
|
6813
|
+
}
|
|
6814
|
+
setShareComplete(id, isSuccess) {
|
|
6815
|
+
this.activeSlide.setShareComplete(id, isSuccess);
|
|
6816
|
+
}
|
|
6817
|
+
setWidgetGoodsComplete(elementId) {
|
|
6818
|
+
this.activeSlide.setWidgetGoodsComplete(elementId);
|
|
6819
|
+
}
|
|
6820
|
+
_sdkClientVariables = {};
|
|
6821
|
+
getSdkClientVariables() {
|
|
6822
|
+
return this._sdkClientVariables;
|
|
6823
|
+
}
|
|
6824
|
+
setSdkClientVariables(variables) {
|
|
6825
|
+
this._sdkClientVariables = variables;
|
|
6826
|
+
}
|
|
6827
|
+
setSlideInCacheStatus(index, status) {
|
|
6828
|
+
if (this.slides[index] != null && this.slides[index].resourcesReadyPromisesResolver != null) {
|
|
6829
|
+
if (status === 1 /* SLIDE_IN_CACHE_STATUS.SUCCESS */) {
|
|
6830
|
+
this.slides[index].resourcesReadyPromisesResolver.resolve();
|
|
6831
|
+
}
|
|
6832
|
+
else {
|
|
6833
|
+
this.slides[index].resourcesReadyPromisesResolver.reject();
|
|
6834
|
+
}
|
|
6835
|
+
}
|
|
6836
|
+
else {
|
|
6837
|
+
// for call setSlideInCacheStatus before showSlides
|
|
6838
|
+
this.slides[index] = {
|
|
6839
|
+
content: "",
|
|
6840
|
+
resourcesReadyPromise: Promise.resolve(),
|
|
6841
|
+
};
|
|
6842
|
+
}
|
|
6843
|
+
}
|
|
6844
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`{
|
|
6845
|
+
sdkApi: SDKApi;
|
|
6846
|
+
slideWrapper: HTMLElement;
|
|
6847
|
+
viewport: Window;
|
|
6848
|
+
userResizeHandler?: (data: { viewportWidth: number; viewportHeight: number; fontSize: number }) => void;
|
|
6849
|
+
slideRatio: number;
|
|
6850
|
+
isFullscreen: boolean;
|
|
6851
|
+
slideLoadedCb?: (data: { cardId: number; slideIndex: number; result: boolean; reason?: string }) => void;
|
|
6852
|
+
getViewportWidth: () => number;
|
|
6853
|
+
getViewportHeight: () => number;
|
|
6854
|
+
overlappingActionBarHeight?: number;
|
|
6855
|
+
separateUserAndAppPause: boolean;
|
|
6856
|
+
root: HTMLElement;
|
|
6857
|
+
nonce?: string;
|
|
6858
|
+
useSdkCacheForMultislideMode: boolean;
|
|
6859
|
+
}`]; }
|
|
6860
|
+
}
|
|
6861
|
+
|
|
5069
6862
|
const slideApiPeerDeps = {};
|
|
5070
6863
|
const createSlideWrapper = ({ slideBoxRatio, nonce }) => {
|
|
5071
6864
|
const slideWrapper = document.createElement("div");
|
|
@@ -5096,7 +6889,7 @@ const createSlideWrapper = ({ slideBoxRatio, nonce }) => {
|
|
|
5096
6889
|
slideWrapper.appendChild(style);
|
|
5097
6890
|
return slideWrapper;
|
|
5098
6891
|
};
|
|
5099
|
-
class SlideApi extends
|
|
6892
|
+
class SlideApi extends CardApi {
|
|
5100
6893
|
root;
|
|
5101
6894
|
slideWrapper;
|
|
5102
6895
|
constructor(_sdkInterface, config) {
|
|
@@ -5114,6 +6907,9 @@ class SlideApi extends SlideApi$1 {
|
|
|
5114
6907
|
getViewportHeight: () => slideWrapper.clientHeight,
|
|
5115
6908
|
overlappingActionBarHeight: config.overlappingActionBarHeight,
|
|
5116
6909
|
separateUserAndAppPause: true,
|
|
6910
|
+
root: config.root,
|
|
6911
|
+
nonce: config.nonce,
|
|
6912
|
+
useSdkCacheForMultislideMode: config.useSdkCacheForMultislideMode,
|
|
5117
6913
|
});
|
|
5118
6914
|
this.root = config.root;
|
|
5119
6915
|
this.slideWrapper = slideWrapper;
|
|
@@ -5134,6 +6930,7 @@ class SlideApi extends SlideApi$1 {
|
|
|
5134
6930
|
userResizeHandler?: (data: { viewportWidth: number; viewportHeight: number; fontSize: number }) => void;
|
|
5135
6931
|
VODPlayer?: typeof VODPlayer;
|
|
5136
6932
|
overlappingActionBarHeight?: number;
|
|
6933
|
+
useSdkCacheForMultislideMode: boolean;
|
|
5137
6934
|
}`]; }
|
|
5138
6935
|
}
|
|
5139
6936
|
|
|
@@ -14563,7 +16360,7 @@ class WidgetBase {
|
|
|
14563
16360
|
this.submitButtonView = this.submitButtonAnimatedView.querySelector(".submit-button-view");
|
|
14564
16361
|
}
|
|
14565
16362
|
}
|
|
14566
|
-
this.savedData = this.widgetDeps.
|
|
16363
|
+
this.savedData = this.widgetDeps.slideApiDeps.getCardServerData(this.cardId);
|
|
14567
16364
|
this.localData = extend({}, this.savedData ?? {}, this.options.localData ?? {});
|
|
14568
16365
|
this.id = `w_${this.elementId}_${WidgetBase.widgetIndex}`;
|
|
14569
16366
|
++WidgetBase.widgetIndex;
|
|
@@ -14585,7 +16382,7 @@ class WidgetBase {
|
|
|
14585
16382
|
* @param localData
|
|
14586
16383
|
*/
|
|
14587
16384
|
onRefreshUserData(localData) {
|
|
14588
|
-
this.savedData = this.widgetDeps.
|
|
16385
|
+
this.savedData = this.widgetDeps.slideApiDeps.getCardServerData(this.cardId);
|
|
14589
16386
|
this.localData = extend({}, this.savedData ?? {}, localData);
|
|
14590
16387
|
}
|
|
14591
16388
|
onStart() {
|
|
@@ -14635,13 +16432,13 @@ class WidgetBase {
|
|
|
14635
16432
|
static get widgetsService() {
|
|
14636
16433
|
return container.get({ identifier: "WidgetsService" });
|
|
14637
16434
|
}
|
|
14638
|
-
static getLocalData(
|
|
14639
|
-
return
|
|
16435
|
+
static getLocalData(slideApiDeps) {
|
|
16436
|
+
return slideApiDeps.getCardLocalData();
|
|
14640
16437
|
}
|
|
14641
16438
|
getLocalData() {
|
|
14642
|
-
return this.constructor.getLocalData(this.widgetDeps.
|
|
16439
|
+
return this.constructor.getLocalData(this.widgetDeps.slideApiDeps);
|
|
14643
16440
|
}
|
|
14644
|
-
static setLocalData(
|
|
16441
|
+
static setLocalData(slideApiDeps, keyValue, sendToServer, syncWithRuntimeLocalData) {
|
|
14645
16442
|
// push json object as string
|
|
14646
16443
|
if (sendToServer === undefined) {
|
|
14647
16444
|
sendToServer = true;
|
|
@@ -14656,20 +16453,20 @@ class WidgetBase {
|
|
|
14656
16453
|
syncWithRuntimeLocalData = Boolean(syncWithRuntimeLocalData);
|
|
14657
16454
|
}
|
|
14658
16455
|
if (syncWithRuntimeLocalData) {
|
|
14659
|
-
this.getLocalData(
|
|
16456
|
+
this.getLocalData(slideApiDeps).then(localData => {
|
|
14660
16457
|
// 1 - old values, 2 - new values
|
|
14661
16458
|
keyValue = extend({}, localData, keyValue);
|
|
14662
16459
|
// todo make async via promise or async
|
|
14663
|
-
|
|
16460
|
+
slideApiDeps.setCardLocalData(keyValue, sendToServer);
|
|
14664
16461
|
});
|
|
14665
16462
|
}
|
|
14666
16463
|
else {
|
|
14667
16464
|
// todo make async via promise or async
|
|
14668
|
-
|
|
16465
|
+
slideApiDeps.setCardLocalData(keyValue, sendToServer);
|
|
14669
16466
|
}
|
|
14670
16467
|
}
|
|
14671
16468
|
setLocalData(keyValue, sendToServer, syncWithRuntimeLocalData) {
|
|
14672
|
-
return this.constructor.setLocalData(this.widgetDeps.
|
|
16469
|
+
return this.constructor.setLocalData(this.widgetDeps.slideApiDeps, keyValue, sendToServer, syncWithRuntimeLocalData);
|
|
14673
16470
|
}
|
|
14674
16471
|
get statisticEventBaseFieldsShortForm() {
|
|
14675
16472
|
return WidgetBase.getStatisticEventBaseFieldsShortForm(this.cardId, this.cardType, this.slideIndex);
|
|
@@ -14700,11 +16497,11 @@ class WidgetBase {
|
|
|
14700
16497
|
}
|
|
14701
16498
|
return data;
|
|
14702
16499
|
}
|
|
14703
|
-
static sendStatisticEventToApp(
|
|
14704
|
-
sendStatisticEventToApp(
|
|
16500
|
+
static sendStatisticEventToApp(slideApiDeps, name, data, devPayload, options) {
|
|
16501
|
+
sendStatisticEventToApp(slideApiDeps, name, data, devPayload, options);
|
|
14705
16502
|
}
|
|
14706
16503
|
sendStatisticEventToApp(name, data, devPayload, options) {
|
|
14707
|
-
this.constructor.sendStatisticEventToApp(this.widgetDeps.
|
|
16504
|
+
this.constructor.sendStatisticEventToApp(this.widgetDeps.slideApiDeps, name, data, devPayload, options);
|
|
14708
16505
|
}
|
|
14709
16506
|
onWidgetComplete() {
|
|
14710
16507
|
this._widgetCallbacks.onWidgetComplete(this.cardId, this.slideIndex);
|
|
@@ -14716,14 +16513,14 @@ class WidgetBase {
|
|
|
14716
16513
|
this._widgetCallbacks.onWidgetRequireResumeUI(this.cardId, this.slideIndex);
|
|
14717
16514
|
}
|
|
14718
16515
|
_showLayer(layers, selectIndex, withStatEvent = false) {
|
|
14719
|
-
if (this.widgetDeps.
|
|
14720
|
-
this.widgetDeps.
|
|
16516
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowLayer()) {
|
|
16517
|
+
this.widgetDeps.slideApiDeps.showLayer(selectIndex);
|
|
14721
16518
|
}
|
|
14722
16519
|
else {
|
|
14723
16520
|
forEach(layers, (layer, index) => {
|
|
14724
16521
|
if (index === selectIndex) {
|
|
14725
16522
|
layer.classList.remove("hidden");
|
|
14726
|
-
this.widgetDeps.
|
|
16523
|
+
this.widgetDeps.slideApiDeps.cardAnimation?.start(layer);
|
|
14727
16524
|
}
|
|
14728
16525
|
else {
|
|
14729
16526
|
layer.classList.add("hidden");
|
|
@@ -14873,7 +16670,7 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14873
16670
|
}
|
|
14874
16671
|
catch (e) {
|
|
14875
16672
|
if (this.msgBarcodeRenderError) {
|
|
14876
|
-
this.widgetDeps.
|
|
16673
|
+
this.widgetDeps.slideApiDeps.showToast(this.msgBarcodeRenderError);
|
|
14877
16674
|
}
|
|
14878
16675
|
console.error(e);
|
|
14879
16676
|
}
|
|
@@ -14936,7 +16733,7 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14936
16733
|
};
|
|
14937
16734
|
const profileKey = "fetch-promo-code";
|
|
14938
16735
|
Promise.all([
|
|
14939
|
-
this.widgetDeps.
|
|
16736
|
+
this.widgetDeps.slideApiDeps.sendApiRequest(path, "POST", null, headers, null, profileKey),
|
|
14940
16737
|
new Promise(function (t, e) {
|
|
14941
16738
|
return setTimeout(t, 300);
|
|
14942
16739
|
}),
|
|
@@ -14964,14 +16761,14 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14964
16761
|
this.setLocalData(this.localData, true);
|
|
14965
16762
|
}
|
|
14966
16763
|
else {
|
|
14967
|
-
this.msgNoMoreCodes && this.widgetDeps.
|
|
16764
|
+
this.msgNoMoreCodes && this.widgetDeps.slideApiDeps.showToast(this.msgNoMoreCodes);
|
|
14968
16765
|
}
|
|
14969
16766
|
}
|
|
14970
16767
|
else if (status === 12163 || status === 12002) {
|
|
14971
|
-
this.msgNetworkError && this.widgetDeps.
|
|
16768
|
+
this.msgNetworkError && this.widgetDeps.slideApiDeps.showToast(this.msgNetworkError);
|
|
14972
16769
|
}
|
|
14973
16770
|
else {
|
|
14974
|
-
this.msgServiceError && this.widgetDeps.
|
|
16771
|
+
this.msgServiceError && this.widgetDeps.slideApiDeps.showToast(this.msgServiceError);
|
|
14975
16772
|
}
|
|
14976
16773
|
if (!success) {
|
|
14977
16774
|
this.state = 3;
|
|
@@ -15017,13 +16814,13 @@ class WidgetBarcode extends WidgetBase {
|
|
|
15017
16814
|
}
|
|
15018
16815
|
});
|
|
15019
16816
|
if (this.copiedText) {
|
|
15020
|
-
this.widgetDeps.
|
|
16817
|
+
this.widgetDeps.slideApiDeps.showToast(this.copiedText);
|
|
15021
16818
|
}
|
|
15022
16819
|
}
|
|
15023
16820
|
copyToClipboard(element) {
|
|
15024
16821
|
this._select();
|
|
15025
16822
|
const textValue = this.clipboardTarget ?? "";
|
|
15026
|
-
this.widgetDeps.
|
|
16823
|
+
this.widgetDeps.slideApiDeps.writeToClipboard({ type: "text", textValue });
|
|
15027
16824
|
this.completeWidget();
|
|
15028
16825
|
this._statEventCopyClick(textValue);
|
|
15029
16826
|
}
|
|
@@ -15195,7 +16992,7 @@ class WidgetCopy extends WidgetBase {
|
|
|
15195
16992
|
};
|
|
15196
16993
|
const profileKey = "fetch-promo-code";
|
|
15197
16994
|
Promise.all([
|
|
15198
|
-
this.widgetDeps.
|
|
16995
|
+
this.widgetDeps.slideApiDeps.sendApiRequest(path, "POST", null, headers, null, profileKey),
|
|
15199
16996
|
new Promise(function (t, e) {
|
|
15200
16997
|
return setTimeout(t, 300);
|
|
15201
16998
|
}),
|
|
@@ -15222,14 +17019,14 @@ class WidgetCopy extends WidgetBase {
|
|
|
15222
17019
|
this.setLocalData(this.localData, true);
|
|
15223
17020
|
}
|
|
15224
17021
|
else {
|
|
15225
|
-
this.msgNoMoreCodes && this.widgetDeps.
|
|
17022
|
+
this.msgNoMoreCodes && this.widgetDeps.slideApiDeps.showToast(this.msgNoMoreCodes);
|
|
15226
17023
|
}
|
|
15227
17024
|
}
|
|
15228
17025
|
else if (status === 12163 || status === 12002) {
|
|
15229
|
-
this.msgNetworkError && this.widgetDeps.
|
|
17026
|
+
this.msgNetworkError && this.widgetDeps.slideApiDeps.showToast(this.msgNetworkError);
|
|
15230
17027
|
}
|
|
15231
17028
|
else {
|
|
15232
|
-
this.msgServiceError && this.widgetDeps.
|
|
17029
|
+
this.msgServiceError && this.widgetDeps.slideApiDeps.showToast(this.msgServiceError);
|
|
15233
17030
|
}
|
|
15234
17031
|
if (!success) {
|
|
15235
17032
|
this.state = 3;
|
|
@@ -15281,7 +17078,7 @@ class WidgetCopy extends WidgetBase {
|
|
|
15281
17078
|
copyToClipboard(element) {
|
|
15282
17079
|
this._select();
|
|
15283
17080
|
const textValue = this.clipboardTarget ?? "";
|
|
15284
|
-
this.widgetDeps.
|
|
17081
|
+
this.widgetDeps.slideApiDeps.writeToClipboard({ type: "text", textValue });
|
|
15285
17082
|
this.completeWidget();
|
|
15286
17083
|
this._statEventCopyClick(textValue);
|
|
15287
17084
|
}
|
|
@@ -15423,12 +17220,12 @@ class WidgetDataInput extends WidgetBase {
|
|
|
15423
17220
|
return true;
|
|
15424
17221
|
}
|
|
15425
17222
|
this.elementRect = this.element.getBoundingClientRect();
|
|
15426
|
-
if (this.widgetDeps.
|
|
17223
|
+
if (this.widgetDeps.slideApiDeps.isAndroid || this.widgetDeps.slideApiDeps.isWeb) {
|
|
15427
17224
|
this.slide.classList.add("blured");
|
|
15428
17225
|
}
|
|
15429
17226
|
this.slide.classList.add("data-input-editing");
|
|
15430
17227
|
const dataString = this.element.dataset["clientdialogwidgetconfig"];
|
|
15431
|
-
if (this.widgetDeps.
|
|
17228
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowCardTextInput && dataString) {
|
|
15432
17229
|
const data = JSON.parse(dataString);
|
|
15433
17230
|
data.size = getElementBounding(this.env, this.elementRect);
|
|
15434
17231
|
if (!this.disableTimer) {
|
|
@@ -15449,7 +17246,7 @@ class WidgetDataInput extends WidgetBase {
|
|
|
15449
17246
|
catch (e) {
|
|
15450
17247
|
console.error(e);
|
|
15451
17248
|
}
|
|
15452
|
-
this.widgetDeps.
|
|
17249
|
+
this.widgetDeps.slideApiDeps.showCardTextInput(this.id, data);
|
|
15453
17250
|
this._statEventFocusIn();
|
|
15454
17251
|
}
|
|
15455
17252
|
return false;
|
|
@@ -15748,7 +17545,7 @@ class WidgetDateCountdown extends WidgetBase {
|
|
|
15748
17545
|
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `WidgetCallbacks`, `WidgetDeps`]; }
|
|
15749
17546
|
}
|
|
15750
17547
|
|
|
15751
|
-
const displaySlide = function (slides, localData,
|
|
17548
|
+
const displaySlide = function (slides, localData, slideApiDeps) {
|
|
15752
17549
|
const multiSlideItem = slides[0];
|
|
15753
17550
|
let cardId = undefined;
|
|
15754
17551
|
let cardType = 1 /* CARD_TYPE.STORY */;
|
|
@@ -15813,7 +17610,7 @@ const displaySlide = function (slides, localData, sdkApi) {
|
|
|
15813
17610
|
if (slides.length > 0) {
|
|
15814
17611
|
var slide = slides[0];
|
|
15815
17612
|
slide.classList.remove("hidden");
|
|
15816
|
-
|
|
17613
|
+
slideApiDeps.cardAnimation?.start(slide);
|
|
15817
17614
|
return;
|
|
15818
17615
|
}
|
|
15819
17616
|
score = 0;
|
|
@@ -15842,19 +17639,19 @@ const displaySlide = function (slides, localData, sdkApi) {
|
|
|
15842
17639
|
if (index === selectedIndex) {
|
|
15843
17640
|
slide.classList.remove("hidden");
|
|
15844
17641
|
undefinedResult = false;
|
|
15845
|
-
|
|
15846
|
-
_sendStatEvent(
|
|
17642
|
+
slideApiDeps.cardAnimation?.start(slide);
|
|
17643
|
+
_sendStatEvent(slideApiDeps, cardId, cardType, slideIndex, selectedIndex);
|
|
15847
17644
|
}
|
|
15848
17645
|
});
|
|
15849
17646
|
}
|
|
15850
17647
|
if (undefinedResult) {
|
|
15851
17648
|
console.warn("undefinedResult layer index");
|
|
15852
|
-
|
|
17649
|
+
slideApiDeps.showLayer(0);
|
|
15853
17650
|
}
|
|
15854
17651
|
};
|
|
15855
|
-
const _sendStatEvent = function (
|
|
17652
|
+
const _sendStatEvent = function (slideApiDeps, cardId, cardType, slideIndex, layerIndex) {
|
|
15856
17653
|
try {
|
|
15857
|
-
WidgetBase.sendStatisticEventToApp(
|
|
17654
|
+
WidgetBase.sendStatisticEventToApp(slideApiDeps, "layout-show", {
|
|
15858
17655
|
...WidgetBase.getStatisticEventBaseFieldsShortForm(cardId, cardType, slideIndex),
|
|
15859
17656
|
li: layerIndex,
|
|
15860
17657
|
}, {
|
|
@@ -15869,7 +17666,7 @@ const _sendStatEvent = function (sdkApi, cardId, cardType, slideIndex, layerInde
|
|
|
15869
17666
|
class WidgetMultiSlide {
|
|
15870
17667
|
static api = {
|
|
15871
17668
|
init: function (slides, localData, widgetDeps) {
|
|
15872
|
-
displaySlide(slides, localData, widgetDeps.
|
|
17669
|
+
displaySlide(slides, localData, widgetDeps.slideApiDeps);
|
|
15873
17670
|
},
|
|
15874
17671
|
};
|
|
15875
17672
|
}
|
|
@@ -16037,13 +17834,13 @@ class WidgetPoll extends WidgetBase {
|
|
|
16037
17834
|
if (index !== -1) {
|
|
16038
17835
|
this.elementRect = this.element.getBoundingClientRect();
|
|
16039
17836
|
if (this.getUseResponseOnFirstButton && index === 0) {
|
|
16040
|
-
if (this.widgetDeps.
|
|
17837
|
+
if (this.widgetDeps.slideApiDeps.isAndroid) {
|
|
16041
17838
|
this.slide.classList.add("blured");
|
|
16042
17839
|
}
|
|
16043
17840
|
this.slide.classList.add("data-input-editing");
|
|
16044
17841
|
const dataString = this.element.dataset["clientdialogwidgetconfig"];
|
|
16045
17842
|
this.selectedVariant = index;
|
|
16046
|
-
if (this.widgetDeps.
|
|
17843
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowCardTextInput && dataString) {
|
|
16047
17844
|
const data = JSON.parse(dataString);
|
|
16048
17845
|
data.size = getElementBounding(this.env, this.elementRect);
|
|
16049
17846
|
if (!this.disableTimer) {
|
|
@@ -16065,19 +17862,19 @@ class WidgetPoll extends WidgetBase {
|
|
|
16065
17862
|
catch (e) {
|
|
16066
17863
|
console.error(e);
|
|
16067
17864
|
}
|
|
16068
|
-
this.widgetDeps.
|
|
17865
|
+
this.widgetDeps.slideApiDeps.showCardTextInput(`${this.id}_first`, data);
|
|
16069
17866
|
}
|
|
16070
17867
|
this._statEventPollAnswer();
|
|
16071
17868
|
return false;
|
|
16072
17869
|
}
|
|
16073
17870
|
else if (this.getUseResponseOnSecondButton && index === 1) {
|
|
16074
|
-
if (this.widgetDeps.
|
|
17871
|
+
if (this.widgetDeps.slideApiDeps.isAndroid) {
|
|
16075
17872
|
this.slide.classList.add("blured");
|
|
16076
17873
|
}
|
|
16077
17874
|
this.slide.classList.add("data-input-editing");
|
|
16078
17875
|
const dataString = this.element.dataset["clientdialogwidgetconfig"];
|
|
16079
17876
|
this.selectedVariant = index;
|
|
16080
|
-
if (this.widgetDeps.
|
|
17877
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowCardTextInput && dataString) {
|
|
16081
17878
|
const data = JSON.parse(dataString);
|
|
16082
17879
|
data.size = getElementBounding(this.env, this.elementRect);
|
|
16083
17880
|
if (!this.disableTimer) {
|
|
@@ -16098,7 +17895,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
16098
17895
|
catch (e) {
|
|
16099
17896
|
console.error(e);
|
|
16100
17897
|
}
|
|
16101
|
-
this.widgetDeps.
|
|
17898
|
+
this.widgetDeps.slideApiDeps.showCardTextInput(`${this.id}_second`, data);
|
|
16102
17899
|
}
|
|
16103
17900
|
this._statEventPollAnswer();
|
|
16104
17901
|
return false;
|
|
@@ -16141,7 +17938,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
16141
17938
|
displayPercents(selectedVariantIndex, filled = false) {
|
|
16142
17939
|
let pollAllocation = [0, 0];
|
|
16143
17940
|
let pollAllocationTs = undefined;
|
|
16144
|
-
const sharedData = this.widgetDeps.
|
|
17941
|
+
const sharedData = this.widgetDeps.slideApiDeps.getWidgetsSharedData(this.cardId, "poll" /* Widgets.Poll */);
|
|
16145
17942
|
if (sharedData && sharedData[this.elementId] != null && (isObject$1(sharedData[this.elementId]) || isArray(sharedData[this.elementId]))) {
|
|
16146
17943
|
pollAllocation = sharedData[this.elementId];
|
|
16147
17944
|
if (isObject$1(sharedData[this.elementId])) {
|
|
@@ -17322,7 +19119,7 @@ class WidgetProducts extends WidgetBase {
|
|
|
17322
19119
|
};
|
|
17323
19120
|
const profileKey = "fetch-products";
|
|
17324
19121
|
try {
|
|
17325
|
-
const response = await this.widgetDeps.
|
|
19122
|
+
const response = await this.widgetDeps.slideApiDeps.sendApiRequest(path, "GET", null, headers, null, profileKey);
|
|
17326
19123
|
// console.log({response});
|
|
17327
19124
|
const status = response.status;
|
|
17328
19125
|
if (status === 200 || status === 201) {
|
|
@@ -17448,15 +19245,15 @@ class WidgetProducts extends WidgetBase {
|
|
|
17448
19245
|
this.isOpen = true;
|
|
17449
19246
|
// prevent next slide navigation gesture
|
|
17450
19247
|
this.isClickCapturedByWidget = true;
|
|
17451
|
-
this.widgetDeps.
|
|
17452
|
-
this.widgetDeps.
|
|
17453
|
-
this.widgetDeps.
|
|
19248
|
+
this.widgetDeps.slideApiDeps.disableHorizontalSwipeGesture();
|
|
19249
|
+
this.widgetDeps.slideApiDeps.disableVerticalSwipeGesture();
|
|
19250
|
+
this.widgetDeps.slideApiDeps.disableBackpress();
|
|
17454
19251
|
this._statEventWidgetOpen(this.currentModels);
|
|
17455
19252
|
this.initSwipeGestureDetector();
|
|
17456
19253
|
}
|
|
17457
19254
|
else {
|
|
17458
19255
|
if (result.message) {
|
|
17459
|
-
this.widgetDeps.
|
|
19256
|
+
this.widgetDeps.slideApiDeps.showToast(result.message);
|
|
17460
19257
|
}
|
|
17461
19258
|
}
|
|
17462
19259
|
this.element.classList.remove("loader");
|
|
@@ -17468,13 +19265,13 @@ class WidgetProducts extends WidgetBase {
|
|
|
17468
19265
|
this.productsView?.classList.add("ias-products-container-view--hidden");
|
|
17469
19266
|
this.element.classList.remove("hidden");
|
|
17470
19267
|
this.isClickCapturedByWidget = false;
|
|
17471
|
-
this.widgetDeps.
|
|
19268
|
+
this.widgetDeps.slideApiDeps.enableHorizontalSwipeGesture();
|
|
17472
19269
|
if (this.swipeGestureDetector != null) {
|
|
17473
19270
|
this.swipeGestureDetector.destroy();
|
|
17474
19271
|
this.swipeGestureDetector = null;
|
|
17475
19272
|
}
|
|
17476
|
-
this.widgetDeps.
|
|
17477
|
-
this.widgetDeps.
|
|
19273
|
+
this.widgetDeps.slideApiDeps.enableVerticalSwipeGesture();
|
|
19274
|
+
this.widgetDeps.slideApiDeps.enableBackpress();
|
|
17478
19275
|
const onClosed = () => {
|
|
17479
19276
|
this.productsView?.removeEventListener("animationend", onClosed);
|
|
17480
19277
|
this.productsView?.parentElement?.removeChild(this.productsView);
|
|
@@ -17534,7 +19331,7 @@ class WidgetProducts extends WidgetBase {
|
|
|
17534
19331
|
e.preventDefault();
|
|
17535
19332
|
this._statEventWidgetCardClick(offer);
|
|
17536
19333
|
if (offer.url) {
|
|
17537
|
-
this.widgetDeps.
|
|
19334
|
+
this.widgetDeps.slideApiDeps.openUrl({ type: "link", link: { type: "url", target: offer.url } });
|
|
17538
19335
|
}
|
|
17539
19336
|
};
|
|
17540
19337
|
card.appendChild(figure);
|
|
@@ -17765,10 +19562,10 @@ class WidgetQuest extends WidgetBase {
|
|
|
17765
19562
|
super.onRefreshUserData(localData);
|
|
17766
19563
|
}
|
|
17767
19564
|
setCardSessionValue(name, value) {
|
|
17768
|
-
this.widgetDeps.
|
|
19565
|
+
this.widgetDeps.slideApiDeps.setCardSessionValue(this.element, name, value);
|
|
17769
19566
|
}
|
|
17770
19567
|
getCardSessionValue(name) {
|
|
17771
|
-
return this.widgetDeps.
|
|
19568
|
+
return this.widgetDeps.slideApiDeps.getCardSessionValue(this.element, name);
|
|
17772
19569
|
}
|
|
17773
19570
|
init() {
|
|
17774
19571
|
if (this.localData) {
|
|
@@ -17787,8 +19584,8 @@ class WidgetQuest extends WidgetBase {
|
|
|
17787
19584
|
// global flag - был сделан переход на нужный слайд, больше не нужно повторять за эту сессию
|
|
17788
19585
|
// perform showStorySlide with lastSlideIdx only on story open first time (not on second slide, etc)
|
|
17789
19586
|
this.setCardSessionValue("__storyQuestSlideChanged", "1");
|
|
17790
|
-
if (this.widgetDeps.
|
|
17791
|
-
this.widgetDeps.
|
|
19587
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
19588
|
+
this.widgetDeps.slideApiDeps.showCardSlide(lastSlideIdx);
|
|
17792
19589
|
return false;
|
|
17793
19590
|
}
|
|
17794
19591
|
}
|
|
@@ -17799,8 +19596,8 @@ class WidgetQuest extends WidgetBase {
|
|
|
17799
19596
|
// если этого слайда нет в роутинге (сработал переход по таймеру в app)
|
|
17800
19597
|
const routes = this._getRoutes();
|
|
17801
19598
|
if (routes[0].indexOf(this.slideIndex) === -1 && this.finalSlide) {
|
|
17802
|
-
if (this.widgetDeps.
|
|
17803
|
-
this.widgetDeps.
|
|
19599
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowNextCard) {
|
|
19600
|
+
this.widgetDeps.slideApiDeps.cardShowNext();
|
|
17804
19601
|
return false;
|
|
17805
19602
|
}
|
|
17806
19603
|
}
|
|
@@ -17846,10 +19643,10 @@ class WidgetQuest extends WidgetBase {
|
|
|
17846
19643
|
this._selectAnswer(index, slideIndex);
|
|
17847
19644
|
this.setLocalData(this.localData, true);
|
|
17848
19645
|
this.env.setTimeout(() => {
|
|
17849
|
-
if (slideIndex >= 0 && slideIndex < this.slideCount && this.widgetDeps.
|
|
19646
|
+
if (slideIndex >= 0 && slideIndex < this.slideCount && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
17850
19647
|
// global flag - был сделан переход на нужный слайд, больше не нужно повторять за эту сессию
|
|
17851
19648
|
this.setCardSessionValue("__storyQuestSlideChanged", "1");
|
|
17852
|
-
this.widgetDeps.
|
|
19649
|
+
this.widgetDeps.slideApiDeps.showCardSlide(slideIndex);
|
|
17853
19650
|
}
|
|
17854
19651
|
}, 100);
|
|
17855
19652
|
}
|
|
@@ -17921,12 +19718,12 @@ class WidgetQuest extends WidgetBase {
|
|
|
17921
19718
|
else {
|
|
17922
19719
|
// by routing - move back
|
|
17923
19720
|
moveTo = this._routeMvPtrBack();
|
|
17924
|
-
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.
|
|
17925
|
-
this.widgetDeps.
|
|
19721
|
+
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
19722
|
+
this.widgetDeps.slideApiDeps.showCardSlide(moveTo);
|
|
17926
19723
|
}
|
|
17927
|
-
if (moveTo === false && this.widgetDeps.
|
|
19724
|
+
if (moveTo === false && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
17928
19725
|
// allow move to start - for broken route history
|
|
17929
|
-
this.widgetDeps.
|
|
19726
|
+
this.widgetDeps.slideApiDeps.showCardSlide(0);
|
|
17930
19727
|
}
|
|
17931
19728
|
}
|
|
17932
19729
|
return result;
|
|
@@ -17942,8 +19739,8 @@ class WidgetQuest extends WidgetBase {
|
|
|
17942
19739
|
if (directionForward) {
|
|
17943
19740
|
if (this.navigationNextSlide === -1) {
|
|
17944
19741
|
// this is the final slide - exit from this quest
|
|
17945
|
-
if (this.widgetDeps.
|
|
17946
|
-
this.widgetDeps.
|
|
19742
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowNextCard) {
|
|
19743
|
+
this.widgetDeps.slideApiDeps.cardShowNext();
|
|
17947
19744
|
}
|
|
17948
19745
|
result.continueDefaultNavigation = false;
|
|
17949
19746
|
return result;
|
|
@@ -17952,11 +19749,11 @@ class WidgetQuest extends WidgetBase {
|
|
|
17952
19749
|
if (nextSlideIndex < this.slideCount) {
|
|
17953
19750
|
this._addNewRouteHistory(nextSlideIndex);
|
|
17954
19751
|
this.setLocalData(this.localData, true);
|
|
17955
|
-
this.widgetDeps.
|
|
19752
|
+
this.widgetDeps.slideApiDeps.showCardSlide(nextSlideIndex);
|
|
17956
19753
|
}
|
|
17957
19754
|
else {
|
|
17958
|
-
if (this.widgetDeps.
|
|
17959
|
-
this.widgetDeps.
|
|
19755
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowNextCard) {
|
|
19756
|
+
this.widgetDeps.slideApiDeps.cardShowNext();
|
|
17960
19757
|
}
|
|
17961
19758
|
}
|
|
17962
19759
|
}
|
|
@@ -17969,12 +19766,12 @@ class WidgetQuest extends WidgetBase {
|
|
|
17969
19766
|
else {
|
|
17970
19767
|
// by routing - move back
|
|
17971
19768
|
moveTo = this._routeMvPtrBack();
|
|
17972
|
-
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.
|
|
17973
|
-
this.widgetDeps.
|
|
19769
|
+
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
19770
|
+
this.widgetDeps.slideApiDeps.showCardSlide(moveTo);
|
|
17974
19771
|
}
|
|
17975
|
-
if (moveTo === false && this.widgetDeps.
|
|
19772
|
+
if (moveTo === false && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
17976
19773
|
// allow move to start - for broken route history
|
|
17977
|
-
this.widgetDeps.
|
|
19774
|
+
this.widgetDeps.slideApiDeps.showCardSlide(0);
|
|
17978
19775
|
}
|
|
17979
19776
|
}
|
|
17980
19777
|
}
|
|
@@ -17989,11 +19786,11 @@ class WidgetQuest extends WidgetBase {
|
|
|
17989
19786
|
if (nextSlideIndex < this.slideCount) {
|
|
17990
19787
|
this._addNewRouteHistory(nextSlideIndex);
|
|
17991
19788
|
this.setLocalData(this.localData, true);
|
|
17992
|
-
this.widgetDeps.
|
|
19789
|
+
this.widgetDeps.slideApiDeps.showCardSlide(nextSlideIndex);
|
|
17993
19790
|
}
|
|
17994
19791
|
else {
|
|
17995
|
-
if (this.widgetDeps.
|
|
17996
|
-
this.widgetDeps.
|
|
19792
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowNextCard) {
|
|
19793
|
+
this.widgetDeps.slideApiDeps.cardShowNext();
|
|
17997
19794
|
}
|
|
17998
19795
|
}
|
|
17999
19796
|
}
|
|
@@ -18006,12 +19803,12 @@ class WidgetQuest extends WidgetBase {
|
|
|
18006
19803
|
else {
|
|
18007
19804
|
// by routing - move back
|
|
18008
19805
|
moveTo = this._routeMvPtrBack();
|
|
18009
|
-
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.
|
|
18010
|
-
this.widgetDeps.
|
|
19806
|
+
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
19807
|
+
this.widgetDeps.slideApiDeps.showCardSlide(moveTo);
|
|
18011
19808
|
}
|
|
18012
|
-
if (moveTo === false && this.widgetDeps.
|
|
19809
|
+
if (moveTo === false && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
18013
19810
|
// allow move to start - for broken route history
|
|
18014
|
-
this.widgetDeps.
|
|
19811
|
+
this.widgetDeps.slideApiDeps.showCardSlide(0);
|
|
18015
19812
|
}
|
|
18016
19813
|
}
|
|
18017
19814
|
}
|
|
@@ -18026,20 +19823,20 @@ class WidgetQuest extends WidgetBase {
|
|
|
18026
19823
|
// setLocalData(this.localData, true);
|
|
18027
19824
|
// window._showNarrativeSlide(nextSlideIndex);
|
|
18028
19825
|
// } else {
|
|
18029
|
-
if (this.widgetDeps.
|
|
18030
|
-
this.widgetDeps.
|
|
19826
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowNextCard) {
|
|
19827
|
+
this.widgetDeps.slideApiDeps.cardShowNext();
|
|
18031
19828
|
}
|
|
18032
19829
|
// }
|
|
18033
19830
|
}
|
|
18034
19831
|
else {
|
|
18035
19832
|
// by routing - move back
|
|
18036
19833
|
moveTo = this._routeMvPtrBack();
|
|
18037
|
-
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.
|
|
18038
|
-
this.widgetDeps.
|
|
19834
|
+
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
19835
|
+
this.widgetDeps.slideApiDeps.showCardSlide(moveTo);
|
|
18039
19836
|
}
|
|
18040
|
-
if (moveTo === false && this.widgetDeps.
|
|
19837
|
+
if (moveTo === false && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
18041
19838
|
// allow move to start - for broken route history
|
|
18042
|
-
this.widgetDeps.
|
|
19839
|
+
this.widgetDeps.slideApiDeps.showCardSlide(0);
|
|
18043
19840
|
}
|
|
18044
19841
|
}
|
|
18045
19842
|
}
|
|
@@ -18829,7 +20626,7 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
18829
20626
|
total_user: 0,
|
|
18830
20627
|
};
|
|
18831
20628
|
let answerAllocationTs = undefined;
|
|
18832
|
-
const sharedData = this.widgetDeps.
|
|
20629
|
+
const sharedData = this.widgetDeps.slideApiDeps.getWidgetsSharedData(this.cardId, "rangeSlider" /* Widgets.RangeSlider */);
|
|
18833
20630
|
if (sharedData && sharedData[this.elementId] != null && (isObject$1(sharedData[this.elementId]) || isArray(sharedData[this.elementId]))) {
|
|
18834
20631
|
answerAllocation = sharedData[this.elementId];
|
|
18835
20632
|
answerAllocationTs = sharedData.ts;
|
|
@@ -18929,7 +20726,7 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
18929
20726
|
}
|
|
18930
20727
|
e.preventDefault();
|
|
18931
20728
|
this.isClickCapturedBySlider = true;
|
|
18932
|
-
this.widgetDeps.
|
|
20729
|
+
this.widgetDeps.slideApiDeps.disableHorizontalSwipeGesture();
|
|
18933
20730
|
if (!this.maxHandlePos) {
|
|
18934
20731
|
this.update(true, false);
|
|
18935
20732
|
}
|
|
@@ -18959,7 +20756,7 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
18959
20756
|
handleEnd(e) {
|
|
18960
20757
|
this.env.requestAnimationFrame(() => {
|
|
18961
20758
|
this.isClickCapturedBySlider = false;
|
|
18962
|
-
this.widgetDeps.
|
|
20759
|
+
this.widgetDeps.slideApiDeps.enableHorizontalSwipeGesture();
|
|
18963
20760
|
});
|
|
18964
20761
|
// e.preventDefault();
|
|
18965
20762
|
this.widgetDeps.slideRoot.removeEventListener("touchmove", this.handleMove);
|
|
@@ -19024,7 +20821,7 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
19024
20821
|
if (this.value !== this.prevSnapValue) {
|
|
19025
20822
|
this.prevSnapValue = this.value;
|
|
19026
20823
|
try {
|
|
19027
|
-
this.widgetDeps.
|
|
20824
|
+
this.widgetDeps.slideApiDeps.vibrate(20);
|
|
19028
20825
|
}
|
|
19029
20826
|
catch (e) {
|
|
19030
20827
|
console.error(e);
|
|
@@ -19271,12 +21068,12 @@ class WidgetRate extends WidgetBase {
|
|
|
19271
21068
|
if (this.showDialogOnLowRate) {
|
|
19272
21069
|
this.elementRect = this.element.getBoundingClientRect();
|
|
19273
21070
|
this._selectStar(this.selectedStar, false);
|
|
19274
|
-
if (this.widgetDeps.
|
|
21071
|
+
if (this.widgetDeps.slideApiDeps.isAndroid) {
|
|
19275
21072
|
this.slide.classList.add("blured");
|
|
19276
21073
|
}
|
|
19277
21074
|
this.slide.classList.add("data-input-editing");
|
|
19278
21075
|
const dataString = this.element.dataset["clientdialogwidgetconfig"];
|
|
19279
|
-
if (this.widgetDeps.
|
|
21076
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowCardTextInput && dataString) {
|
|
19280
21077
|
const data = JSON.parse(dataString);
|
|
19281
21078
|
data.size = getElementBounding(this.env, this.elementRect);
|
|
19282
21079
|
if (!this.disableTimer) {
|
|
@@ -19298,7 +21095,7 @@ class WidgetRate extends WidgetBase {
|
|
|
19298
21095
|
catch (e) {
|
|
19299
21096
|
console.error(e);
|
|
19300
21097
|
}
|
|
19301
|
-
this.widgetDeps.
|
|
21098
|
+
this.widgetDeps.slideApiDeps.showCardTextInput(this.id, data);
|
|
19302
21099
|
}
|
|
19303
21100
|
}
|
|
19304
21101
|
else {
|
|
@@ -19310,17 +21107,17 @@ class WidgetRate extends WidgetBase {
|
|
|
19310
21107
|
}
|
|
19311
21108
|
else if (value + 1 >= this.submitToStoresMin && value + 1 <= this.submitToStoresMax) {
|
|
19312
21109
|
let target = null;
|
|
19313
|
-
if (this.widgetDeps.
|
|
21110
|
+
if (this.widgetDeps.slideApiDeps.isAndroid) {
|
|
19314
21111
|
target = getTagData(this.element, "androidLink");
|
|
19315
21112
|
}
|
|
19316
|
-
else if (this.widgetDeps.
|
|
21113
|
+
else if (this.widgetDeps.slideApiDeps.isIOS) {
|
|
19317
21114
|
target = getTagData(this.element, "appleLink");
|
|
19318
21115
|
}
|
|
19319
21116
|
this._selectStar(value, true);
|
|
19320
21117
|
this.completeWidget();
|
|
19321
21118
|
this._statEventRateUsAnswer("");
|
|
19322
21119
|
if (this.submitToStores && target) {
|
|
19323
|
-
this.widgetDeps.
|
|
21120
|
+
this.widgetDeps.slideApiDeps.openUrl({ type: "link", link: { type: "url", target } });
|
|
19324
21121
|
}
|
|
19325
21122
|
}
|
|
19326
21123
|
else {
|
|
@@ -19469,12 +21266,12 @@ class WidgetShare extends WidgetBase {
|
|
|
19469
21266
|
}
|
|
19470
21267
|
share() {
|
|
19471
21268
|
if (!this.btnDisabled) {
|
|
19472
|
-
if (this.widgetDeps.
|
|
19473
|
-
if (this.widgetDeps.
|
|
21269
|
+
if (this.widgetDeps.slideApiDeps.isExistsShare) {
|
|
21270
|
+
if (this.widgetDeps.slideApiDeps.sdkCanSendShareComplete) {
|
|
19474
21271
|
this.btnDisabled = true;
|
|
19475
21272
|
}
|
|
19476
21273
|
if (this.shareType === "url" || this.shareType === "story") {
|
|
19477
|
-
this.widgetDeps.
|
|
21274
|
+
this.widgetDeps.slideApiDeps.share(this.id, {
|
|
19478
21275
|
url: this.shareTarget, // sdk old versions
|
|
19479
21276
|
text: this.shareTarget,
|
|
19480
21277
|
title: null,
|
|
@@ -19482,7 +21279,7 @@ class WidgetShare extends WidgetBase {
|
|
|
19482
21279
|
});
|
|
19483
21280
|
}
|
|
19484
21281
|
else if (this.shareType === "slide") {
|
|
19485
|
-
this.widgetDeps.
|
|
21282
|
+
this.widgetDeps.slideApiDeps.shareSlideScreenshot(this.id, "[data-element-id='" + this.elementId + "']", this.shareTarget ? this.shareTarget : undefined);
|
|
19486
21283
|
}
|
|
19487
21284
|
}
|
|
19488
21285
|
}
|
|
@@ -20088,9 +21885,9 @@ class WidgetTooltip extends WidgetBase {
|
|
|
20088
21885
|
copyToClipboard(element) {
|
|
20089
21886
|
const textValue = this.template1ClipboardTarget ?? "";
|
|
20090
21887
|
if (textValue) {
|
|
20091
|
-
this.widgetDeps.
|
|
21888
|
+
this.widgetDeps.slideApiDeps.writeToClipboard({ type: "text", textValue });
|
|
20092
21889
|
if (this.template1CopiedText) {
|
|
20093
|
-
this.widgetDeps.
|
|
21890
|
+
this.widgetDeps.slideApiDeps.showToast(this.template1CopiedText);
|
|
20094
21891
|
}
|
|
20095
21892
|
}
|
|
20096
21893
|
this._statEventWidgetCopyClick(textValue);
|
|
@@ -20469,7 +22266,7 @@ class WidgetVote extends WidgetBase {
|
|
|
20469
22266
|
// voteAllocation[7]
|
|
20470
22267
|
let voteAllocation = [];
|
|
20471
22268
|
let voteAllocationTs = undefined;
|
|
20472
|
-
const sharedData = this.widgetDeps.
|
|
22269
|
+
const sharedData = this.widgetDeps.slideApiDeps.getWidgetsSharedData(this.cardId, "vote" /* Widgets.Vote */);
|
|
20473
22270
|
if (sharedData && sharedData[this.elementId] != null && (isObject$1(sharedData[this.elementId]) || isArray(sharedData[this.elementId]))) {
|
|
20474
22271
|
voteAllocation = sharedData[this.elementId];
|
|
20475
22272
|
if (isObject$1(sharedData[this.elementId])) {
|