@inappstory/slide-api 0.1.24 → 0.1.25
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 +1937 -349
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +146 -70
- package/dist/index.d.ts +146 -70
- package/dist/index.js +1937 -349
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -561,8 +561,8 @@ const getWinWidth = function (env) {
|
|
|
561
561
|
const getWinHeight = function (env) {
|
|
562
562
|
return env.innerHeight || env.document.documentElement.clientHeight || env.document.body.clientHeight;
|
|
563
563
|
};
|
|
564
|
-
const sendStatisticEventToApp = function (
|
|
565
|
-
|
|
564
|
+
const sendStatisticEventToApp = function (slideApiDeps, name, data, devPayload, options) {
|
|
565
|
+
slideApiDeps.sendStatisticEvent(name, data, devPayload, options?.forceEnableStatisticV2 ?? false);
|
|
566
566
|
};
|
|
567
567
|
const getValueOrException = function (value, message) {
|
|
568
568
|
if (value == null) {
|
|
@@ -1173,6 +1173,13 @@ class EsModuleSdkApi {
|
|
|
1173
1173
|
isSdkSupportCorrectPauseResumeLifecycle() {
|
|
1174
1174
|
return true;
|
|
1175
1175
|
}
|
|
1176
|
+
emitEvent(name, event) {
|
|
1177
|
+
this.sdkBinding.onEvent(name, event);
|
|
1178
|
+
}
|
|
1179
|
+
onCardLoadingStateChange(state, reason) {
|
|
1180
|
+
console.log("onCardLoadingStateChange", { state });
|
|
1181
|
+
this.sdkBinding.onCardLoadingStateChange(state, reason);
|
|
1182
|
+
}
|
|
1176
1183
|
static get [Symbol.for("___CTOR_ARGS___")]() { return [`SDKInterface`]; }
|
|
1177
1184
|
}
|
|
1178
1185
|
|
|
@@ -1199,6 +1206,9 @@ class DataInput {
|
|
|
1199
1206
|
return element instanceof DataInput;
|
|
1200
1207
|
}
|
|
1201
1208
|
mediaElementsLoadingPromises = [];
|
|
1209
|
+
get nodeRef() {
|
|
1210
|
+
return this._elementNodeRef;
|
|
1211
|
+
}
|
|
1202
1212
|
init(localData) {
|
|
1203
1213
|
try {
|
|
1204
1214
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1249,6 +1259,9 @@ class Barcode {
|
|
|
1249
1259
|
this._widgetDeps = _widgetDeps;
|
|
1250
1260
|
}
|
|
1251
1261
|
mediaElementsLoadingPromises = [];
|
|
1262
|
+
get nodeRef() {
|
|
1263
|
+
return this._elementNodeRef;
|
|
1264
|
+
}
|
|
1252
1265
|
init(localData) {
|
|
1253
1266
|
try {
|
|
1254
1267
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1286,36 +1299,311 @@ class ClickableBase {
|
|
|
1286
1299
|
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`]; }
|
|
1287
1300
|
}
|
|
1288
1301
|
|
|
1302
|
+
class PromocodeNetworkError extends Error {
|
|
1303
|
+
}
|
|
1304
|
+
class PromocodeServiceError extends Error {
|
|
1305
|
+
}
|
|
1306
|
+
class PromocodeNoMoreCodes extends Error {
|
|
1307
|
+
}
|
|
1308
|
+
class PromocodeApi {
|
|
1309
|
+
sdkApi;
|
|
1310
|
+
messages;
|
|
1311
|
+
constructor(sdkApi, messages) {
|
|
1312
|
+
this.sdkApi = sdkApi;
|
|
1313
|
+
this.messages = messages;
|
|
1314
|
+
}
|
|
1315
|
+
async fetchPromoCode(params) {
|
|
1316
|
+
const path = this.getPromotionalCodeFetchPath(params);
|
|
1317
|
+
const headers = {
|
|
1318
|
+
accept: "application/json",
|
|
1319
|
+
"Content-Type": "application/json",
|
|
1320
|
+
};
|
|
1321
|
+
const [response] = await Promise.all([
|
|
1322
|
+
this.sdkApi.sendApiRequest(path, "POST", null, headers, null, "fetch-promo-code"),
|
|
1323
|
+
new Promise(resolve => setTimeout(resolve, 300)),
|
|
1324
|
+
]);
|
|
1325
|
+
const { status, data } = response;
|
|
1326
|
+
if (status === 200 || status === 201) {
|
|
1327
|
+
const promocode = data?.code;
|
|
1328
|
+
if (promocode) {
|
|
1329
|
+
return { promocode, status };
|
|
1330
|
+
}
|
|
1331
|
+
throw new PromocodeNoMoreCodes(this.messages.noMoreCodes);
|
|
1332
|
+
}
|
|
1333
|
+
if (status === 12163 || status === 12002) {
|
|
1334
|
+
throw new PromocodeNetworkError(this.messages.networkError);
|
|
1335
|
+
}
|
|
1336
|
+
throw new PromocodeServiceError(this.messages.serviceError);
|
|
1337
|
+
}
|
|
1338
|
+
getPromotionalCodeFetchPath(params) {
|
|
1339
|
+
switch (params.card.type) {
|
|
1340
|
+
case 4 /* CARD_TYPE.IN_APP_MESSAGING */:
|
|
1341
|
+
return `inappmessaging/message/${params.card.id}/widget/${params.elementId}/promo-code/${params.promocodeId}`;
|
|
1342
|
+
default:
|
|
1343
|
+
return `story/${params.card.id}/widget/${params.elementId}/promo-code/${params.promocodeId}`;
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`Pick`, `{
|
|
1347
|
+
noMoreCodes?: string;
|
|
1348
|
+
networkError?: string;
|
|
1349
|
+
serviceError?: string;
|
|
1350
|
+
}`]; }
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
class PromocodeLocalRepository {
|
|
1354
|
+
elementId;
|
|
1355
|
+
sdkApi;
|
|
1356
|
+
localData = {};
|
|
1357
|
+
constructor(elementId, sdkApi) {
|
|
1358
|
+
this.elementId = elementId;
|
|
1359
|
+
this.sdkApi = sdkApi;
|
|
1360
|
+
}
|
|
1361
|
+
init({ localData, cardId }) {
|
|
1362
|
+
const savedData = this.sdkApi.getCardServerData(cardId) ?? {};
|
|
1363
|
+
this.localData = extend({}, savedData, localData ?? {});
|
|
1364
|
+
}
|
|
1365
|
+
getPromocode() {
|
|
1366
|
+
return this.localData["_pcl_g_" + this.elementId + "_pc"];
|
|
1367
|
+
}
|
|
1368
|
+
savePromocodeByStatus(promocode, status) {
|
|
1369
|
+
if (status === 201)
|
|
1370
|
+
this.savePromocodeWithTime(promocode);
|
|
1371
|
+
else
|
|
1372
|
+
this.savePromocode(promocode);
|
|
1373
|
+
}
|
|
1374
|
+
savePromocodeWithTime(promocode) {
|
|
1375
|
+
this.localData["_pcl_g_" + this.elementId + "_pc_fetched_at"] = Math.round(new Date().getTime() / 1000);
|
|
1376
|
+
this.localData["_&ts_pcl_g_" + this.elementId + "_pc_fetched_at"] = Math.round(new Date().getTime() / 1000);
|
|
1377
|
+
this.savePromocode(promocode);
|
|
1378
|
+
}
|
|
1379
|
+
savePromocode(promocode) {
|
|
1380
|
+
this.localData["_pcl_g_" + this.elementId + "_pc"] = promocode;
|
|
1381
|
+
this.setCardLocalData(this.localData);
|
|
1382
|
+
}
|
|
1383
|
+
async setCardLocalData(newLocalData) {
|
|
1384
|
+
const localData = await this.sdkApi.getCardLocalData();
|
|
1385
|
+
const mergedData = extend({}, localData, newLocalData);
|
|
1386
|
+
await this.sdkApi.setCardLocalData(mergedData, true);
|
|
1387
|
+
}
|
|
1388
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`string`, `ISlideApiDeps`]; }
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
var PromocodeLinkState;
|
|
1392
|
+
(function (PromocodeLinkState) {
|
|
1393
|
+
PromocodeLinkState[PromocodeLinkState["Idle"] = 0] = "Idle";
|
|
1394
|
+
PromocodeLinkState[PromocodeLinkState["Fetched"] = 1] = "Fetched";
|
|
1395
|
+
PromocodeLinkState[PromocodeLinkState["Error"] = 2] = "Error";
|
|
1396
|
+
})(PromocodeLinkState || (PromocodeLinkState = {}));
|
|
1397
|
+
const PROMOCODE_PLACEHOLDER = "%__ias_pc%";
|
|
1398
|
+
class PromocodeLink {
|
|
1399
|
+
element;
|
|
1400
|
+
layer;
|
|
1401
|
+
widgetDeps;
|
|
1402
|
+
state = PromocodeLinkState.Idle;
|
|
1403
|
+
promocode = null;
|
|
1404
|
+
promocodeId;
|
|
1405
|
+
linkTemplate;
|
|
1406
|
+
textContent;
|
|
1407
|
+
button;
|
|
1408
|
+
elementId;
|
|
1409
|
+
card;
|
|
1410
|
+
api;
|
|
1411
|
+
localRepository;
|
|
1412
|
+
constructor(element, layer, widgetDeps) {
|
|
1413
|
+
this.element = element;
|
|
1414
|
+
this.layer = layer;
|
|
1415
|
+
this.widgetDeps = widgetDeps;
|
|
1416
|
+
this.elementId = getValueOrException(getTagData(this.element, "elementId"), "Empty elementId");
|
|
1417
|
+
this.promocodeId = getTagData(this.element, "linkTarget") ?? "";
|
|
1418
|
+
this.linkTemplate = getTagData(this.element, "linkTemplate") ?? "";
|
|
1419
|
+
this.button = this.element.querySelector(".narrative-element-text-lines");
|
|
1420
|
+
this.textContent = this.button?.textContent ?? "";
|
|
1421
|
+
this.card = this.getCard();
|
|
1422
|
+
this.api = new PromocodeApi(this.widgetDeps.slideApiDeps, {
|
|
1423
|
+
networkError: getTagData(this.element, "msgNetworkError") ?? "",
|
|
1424
|
+
serviceError: getTagData(this.element, "msgServiceError") ?? "",
|
|
1425
|
+
noMoreCodes: getTagData(this.element, "msgNoMoreCodes") ?? "",
|
|
1426
|
+
});
|
|
1427
|
+
this.localRepository = new PromocodeLocalRepository(this.elementId, this.widgetDeps.slideApiDeps);
|
|
1428
|
+
}
|
|
1429
|
+
get nodeRef() {
|
|
1430
|
+
return this.element;
|
|
1431
|
+
}
|
|
1432
|
+
mediaElementsLoadingPromises = [];
|
|
1433
|
+
init(localData) {
|
|
1434
|
+
this.localRepository.init({ localData: localData ?? {}, cardId: this.card.id });
|
|
1435
|
+
this.state = PromocodeLinkState.Idle;
|
|
1436
|
+
const promocode = this.localRepository.getPromocode();
|
|
1437
|
+
if (promocode) {
|
|
1438
|
+
this.state = PromocodeLinkState.Fetched;
|
|
1439
|
+
this.showPromocode(promocode);
|
|
1440
|
+
this.promocode = promocode;
|
|
1441
|
+
}
|
|
1442
|
+
return Promise.resolve(true);
|
|
1443
|
+
}
|
|
1444
|
+
onPause() { }
|
|
1445
|
+
onResume() { }
|
|
1446
|
+
onStop() { }
|
|
1447
|
+
onBeforeUnmount() {
|
|
1448
|
+
return Promise.resolve();
|
|
1449
|
+
}
|
|
1450
|
+
handleClick() {
|
|
1451
|
+
switch (this.state) {
|
|
1452
|
+
case PromocodeLinkState.Idle:
|
|
1453
|
+
return false;
|
|
1454
|
+
case PromocodeLinkState.Fetched:
|
|
1455
|
+
this.openPromocodeUrl();
|
|
1456
|
+
return true;
|
|
1457
|
+
case PromocodeLinkState.Error:
|
|
1458
|
+
this.loadPromocode(this.promocodeId).catch(() => { });
|
|
1459
|
+
break;
|
|
1460
|
+
}
|
|
1461
|
+
return false;
|
|
1462
|
+
}
|
|
1463
|
+
get isLayerForcePaused() {
|
|
1464
|
+
return false;
|
|
1465
|
+
}
|
|
1466
|
+
onStart() {
|
|
1467
|
+
this.element.classList.add("active");
|
|
1468
|
+
this.loadPromocode(this.promocodeId).catch(() => { });
|
|
1469
|
+
}
|
|
1470
|
+
openPromocodeUrl() {
|
|
1471
|
+
if (!this.promocode)
|
|
1472
|
+
return;
|
|
1473
|
+
const target = this.linkTemplate.replaceAll(PROMOCODE_PLACEHOLDER, this.promocode);
|
|
1474
|
+
this.layer.layoutService.env.setTimeout(() => {
|
|
1475
|
+
this.widgetDeps.slideApiDeps.openUrl({ type: "link", link: { type: "url", target } });
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
async loadPromocode(promocodeId) {
|
|
1479
|
+
try {
|
|
1480
|
+
this.state = PromocodeLinkState.Idle;
|
|
1481
|
+
this.showLoader();
|
|
1482
|
+
const promocode = await this.getPromocode({
|
|
1483
|
+
promocodeId,
|
|
1484
|
+
card: this.card,
|
|
1485
|
+
elementId: this.elementId,
|
|
1486
|
+
});
|
|
1487
|
+
this.state = PromocodeLinkState.Fetched;
|
|
1488
|
+
this.promocode = promocode;
|
|
1489
|
+
this.showPromocode(promocode);
|
|
1490
|
+
return promocode;
|
|
1491
|
+
}
|
|
1492
|
+
catch (error) {
|
|
1493
|
+
this.handleLoadPromocodeError(error);
|
|
1494
|
+
throw error;
|
|
1495
|
+
}
|
|
1496
|
+
finally {
|
|
1497
|
+
this.hideLoader();
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
async getPromocode(params) {
|
|
1501
|
+
if (this.promocode)
|
|
1502
|
+
return this.promocode;
|
|
1503
|
+
let promocode = this.localRepository.getPromocode();
|
|
1504
|
+
if (!promocode) {
|
|
1505
|
+
const result = await this.api.fetchPromoCode(params);
|
|
1506
|
+
promocode = result.promocode;
|
|
1507
|
+
this.localRepository.savePromocodeByStatus(promocode, result.status);
|
|
1508
|
+
}
|
|
1509
|
+
this.promocode = promocode;
|
|
1510
|
+
return promocode;
|
|
1511
|
+
}
|
|
1512
|
+
handleLoadPromocodeError(error) {
|
|
1513
|
+
this.state = PromocodeLinkState.Error;
|
|
1514
|
+
this.showErrorMessage(getTagData(this.element, "msgTryAgain") ?? "");
|
|
1515
|
+
if (error.message.length) {
|
|
1516
|
+
this.widgetDeps.slideApiDeps.showToast(error.message);
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
showPromocode(promocode) {
|
|
1520
|
+
if (!this.button)
|
|
1521
|
+
return;
|
|
1522
|
+
this.button.textContent = this.textContent.replaceAll(PROMOCODE_PLACEHOLDER, promocode);
|
|
1523
|
+
}
|
|
1524
|
+
showErrorMessage(message) {
|
|
1525
|
+
if (!this.button)
|
|
1526
|
+
return;
|
|
1527
|
+
this.button.textContent = message;
|
|
1528
|
+
}
|
|
1529
|
+
getCard() {
|
|
1530
|
+
const slide = getValueOrException(this.element.closest(".narrative-slide"), "Empty slide");
|
|
1531
|
+
return {
|
|
1532
|
+
id: getValueOrException(getTagDataAsNumber(slide, "id"), "Empty cardId"),
|
|
1533
|
+
type: getValueOrException(getTagDataAsNumber(slide, "cardType"), "Empty card type"),
|
|
1534
|
+
};
|
|
1535
|
+
}
|
|
1536
|
+
showLoader() {
|
|
1537
|
+
if (!this.isTransparentElement())
|
|
1538
|
+
addClass(this.element, "loader");
|
|
1539
|
+
}
|
|
1540
|
+
hideLoader() {
|
|
1541
|
+
removeClass(this.element, "loader");
|
|
1542
|
+
}
|
|
1543
|
+
isTransparentElement() {
|
|
1544
|
+
if (this.element) {
|
|
1545
|
+
try {
|
|
1546
|
+
const color = window.getComputedStyle(this.element).color;
|
|
1547
|
+
if (color === "transparent" || color === "rgba(0, 0, 0, 0)" || color === "rgba(0,0,0,0)") {
|
|
1548
|
+
return true;
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
catch (err) {
|
|
1552
|
+
console.error(err);
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
return false;
|
|
1556
|
+
}
|
|
1557
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `WidgetDeps`]; }
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1289
1560
|
class Button extends ClickableBase {
|
|
1290
1561
|
_elementNodeRef;
|
|
1291
|
-
|
|
1562
|
+
layer;
|
|
1563
|
+
widgetDeps;
|
|
1292
1564
|
static _className = "narrative-element-link";
|
|
1565
|
+
isPromotionalCode;
|
|
1566
|
+
promocodeLink = null;
|
|
1293
1567
|
static className() {
|
|
1294
1568
|
return Button._className;
|
|
1295
1569
|
}
|
|
1296
|
-
|
|
1570
|
+
static isTypeOf(element) {
|
|
1571
|
+
return element instanceof Button;
|
|
1572
|
+
}
|
|
1573
|
+
constructor(_elementNodeRef, layer, widgetDeps) {
|
|
1297
1574
|
super(_elementNodeRef);
|
|
1298
1575
|
this._elementNodeRef = _elementNodeRef;
|
|
1299
|
-
this.
|
|
1576
|
+
this.layer = layer;
|
|
1577
|
+
this.widgetDeps = widgetDeps;
|
|
1578
|
+
this.isPromotionalCode = getTagData(_elementNodeRef, "linkType") === "promocode";
|
|
1579
|
+
if (this.isPromotionalCode) {
|
|
1580
|
+
this.promocodeLink = new PromocodeLink(_elementNodeRef, layer, widgetDeps);
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
get nodeRef() {
|
|
1584
|
+
return this._elementNodeRef;
|
|
1300
1585
|
}
|
|
1301
1586
|
mediaElementsLoadingPromises = [];
|
|
1302
|
-
init(localData) {
|
|
1303
|
-
|
|
1587
|
+
async init(localData) {
|
|
1588
|
+
await this.promocodeLink?.init(localData);
|
|
1589
|
+
return true;
|
|
1304
1590
|
}
|
|
1305
1591
|
onPause() { }
|
|
1306
1592
|
onResume() { }
|
|
1307
|
-
onStart() {
|
|
1593
|
+
onStart() {
|
|
1594
|
+
this.promocodeLink?.onStart();
|
|
1595
|
+
}
|
|
1308
1596
|
onStop() { }
|
|
1309
1597
|
onBeforeUnmount() {
|
|
1310
1598
|
return Promise.resolve();
|
|
1311
1599
|
}
|
|
1312
1600
|
handleClick() {
|
|
1313
|
-
return
|
|
1601
|
+
return this.promocodeLink?.handleClick() ?? true;
|
|
1314
1602
|
}
|
|
1315
1603
|
get isLayerForcePaused() {
|
|
1316
1604
|
return false;
|
|
1317
1605
|
}
|
|
1318
|
-
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`]; }
|
|
1606
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `WidgetDeps`]; }
|
|
1319
1607
|
}
|
|
1320
1608
|
|
|
1321
1609
|
class Copy {
|
|
@@ -1336,6 +1624,9 @@ class Copy {
|
|
|
1336
1624
|
this._widgetDeps = _widgetDeps;
|
|
1337
1625
|
}
|
|
1338
1626
|
mediaElementsLoadingPromises = [];
|
|
1627
|
+
get nodeRef() {
|
|
1628
|
+
return this._elementNodeRef;
|
|
1629
|
+
}
|
|
1339
1630
|
init(localData) {
|
|
1340
1631
|
try {
|
|
1341
1632
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1385,6 +1676,9 @@ class DateCountdown {
|
|
|
1385
1676
|
this._widgetDeps = _widgetDeps;
|
|
1386
1677
|
}
|
|
1387
1678
|
mediaElementsLoadingPromises = [];
|
|
1679
|
+
get nodeRef() {
|
|
1680
|
+
return this._elementNodeRef;
|
|
1681
|
+
}
|
|
1388
1682
|
init(localData) {
|
|
1389
1683
|
try {
|
|
1390
1684
|
this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1439,6 +1733,9 @@ class Poll {
|
|
|
1439
1733
|
return element instanceof Poll;
|
|
1440
1734
|
}
|
|
1441
1735
|
mediaElementsLoadingPromises = [];
|
|
1736
|
+
get nodeRef() {
|
|
1737
|
+
return this._elementNodeRef;
|
|
1738
|
+
}
|
|
1442
1739
|
init(localData) {
|
|
1443
1740
|
try {
|
|
1444
1741
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1494,6 +1791,9 @@ class PollLayers {
|
|
|
1494
1791
|
return element instanceof PollLayers;
|
|
1495
1792
|
}
|
|
1496
1793
|
mediaElementsLoadingPromises = [];
|
|
1794
|
+
get nodeRef() {
|
|
1795
|
+
return this._elementNodeRef;
|
|
1796
|
+
}
|
|
1497
1797
|
init(localData) {
|
|
1498
1798
|
try {
|
|
1499
1799
|
this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1544,6 +1844,9 @@ class Products {
|
|
|
1544
1844
|
return element instanceof Products;
|
|
1545
1845
|
}
|
|
1546
1846
|
mediaElementsLoadingPromises = [];
|
|
1847
|
+
get nodeRef() {
|
|
1848
|
+
return this._elementNodeRef;
|
|
1849
|
+
}
|
|
1547
1850
|
init(localData) {
|
|
1548
1851
|
try {
|
|
1549
1852
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1603,6 +1906,9 @@ class Quest {
|
|
|
1603
1906
|
return element instanceof Quest;
|
|
1604
1907
|
}
|
|
1605
1908
|
mediaElementsLoadingPromises = [];
|
|
1909
|
+
get nodeRef() {
|
|
1910
|
+
return this._elementNodeRef;
|
|
1911
|
+
}
|
|
1606
1912
|
init(localData) {
|
|
1607
1913
|
return this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
1608
1914
|
}
|
|
@@ -1651,6 +1957,9 @@ class Quiz {
|
|
|
1651
1957
|
return element instanceof Quiz;
|
|
1652
1958
|
}
|
|
1653
1959
|
mediaElementsLoadingPromises = [];
|
|
1960
|
+
get nodeRef() {
|
|
1961
|
+
return this._elementNodeRef;
|
|
1962
|
+
}
|
|
1654
1963
|
init(localData) {
|
|
1655
1964
|
try {
|
|
1656
1965
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1704,6 +2013,9 @@ class QuizGrouped {
|
|
|
1704
2013
|
return element instanceof QuizGrouped;
|
|
1705
2014
|
}
|
|
1706
2015
|
mediaElementsLoadingPromises = [];
|
|
2016
|
+
get nodeRef() {
|
|
2017
|
+
return this._elementNodeRef;
|
|
2018
|
+
}
|
|
1707
2019
|
init(localData) {
|
|
1708
2020
|
try {
|
|
1709
2021
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1757,6 +2069,9 @@ class RangeSlider {
|
|
|
1757
2069
|
return element instanceof RangeSlider;
|
|
1758
2070
|
}
|
|
1759
2071
|
mediaElementsLoadingPromises = [];
|
|
2072
|
+
get nodeRef() {
|
|
2073
|
+
return this._elementNodeRef;
|
|
2074
|
+
}
|
|
1760
2075
|
init(localData) {
|
|
1761
2076
|
try {
|
|
1762
2077
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1810,6 +2125,9 @@ class Rate {
|
|
|
1810
2125
|
return element instanceof Rate;
|
|
1811
2126
|
}
|
|
1812
2127
|
mediaElementsLoadingPromises = [];
|
|
2128
|
+
get nodeRef() {
|
|
2129
|
+
return this._elementNodeRef;
|
|
2130
|
+
}
|
|
1813
2131
|
init(localData) {
|
|
1814
2132
|
try {
|
|
1815
2133
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1866,6 +2184,9 @@ class Share {
|
|
|
1866
2184
|
return element instanceof Share;
|
|
1867
2185
|
}
|
|
1868
2186
|
mediaElementsLoadingPromises = [];
|
|
2187
|
+
get nodeRef() {
|
|
2188
|
+
return this._elementNodeRef;
|
|
2189
|
+
}
|
|
1869
2190
|
init(localData) {
|
|
1870
2191
|
try {
|
|
1871
2192
|
this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1913,6 +2234,9 @@ class SwipeUpItems {
|
|
|
1913
2234
|
return element instanceof SwipeUpItems;
|
|
1914
2235
|
}
|
|
1915
2236
|
mediaElementsLoadingPromises = [];
|
|
2237
|
+
get nodeRef() {
|
|
2238
|
+
return this._elementNodeRef;
|
|
2239
|
+
}
|
|
1916
2240
|
init(localData) {
|
|
1917
2241
|
return Promise.resolve(true);
|
|
1918
2242
|
}
|
|
@@ -1956,6 +2280,9 @@ class Test {
|
|
|
1956
2280
|
return element instanceof Test;
|
|
1957
2281
|
}
|
|
1958
2282
|
mediaElementsLoadingPromises = [];
|
|
2283
|
+
get nodeRef() {
|
|
2284
|
+
return this._elementNodeRef;
|
|
2285
|
+
}
|
|
1959
2286
|
init(localData) {
|
|
1960
2287
|
try {
|
|
1961
2288
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -2009,6 +2336,9 @@ class Tooltip {
|
|
|
2009
2336
|
this._widgetDeps = _widgetDeps;
|
|
2010
2337
|
}
|
|
2011
2338
|
mediaElementsLoadingPromises = [];
|
|
2339
|
+
get nodeRef() {
|
|
2340
|
+
return this._elementNodeRef;
|
|
2341
|
+
}
|
|
2012
2342
|
init(localData) {
|
|
2013
2343
|
try {
|
|
2014
2344
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -2056,6 +2386,9 @@ class Vote {
|
|
|
2056
2386
|
this._widgetDeps = _widgetDeps;
|
|
2057
2387
|
}
|
|
2058
2388
|
mediaElementsLoadingPromises = [];
|
|
2389
|
+
get nodeRef() {
|
|
2390
|
+
return this._elementNodeRef;
|
|
2391
|
+
}
|
|
2059
2392
|
init(localData) {
|
|
2060
2393
|
try {
|
|
2061
2394
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -2097,6 +2430,9 @@ class Text {
|
|
|
2097
2430
|
this._layer = _layer;
|
|
2098
2431
|
}
|
|
2099
2432
|
mediaElementsLoadingPromises = [];
|
|
2433
|
+
get nodeRef() {
|
|
2434
|
+
return this._elementNodeRef;
|
|
2435
|
+
}
|
|
2100
2436
|
init(localData) {
|
|
2101
2437
|
return Promise.resolve(true);
|
|
2102
2438
|
}
|
|
@@ -2220,6 +2556,9 @@ class Image extends ClickableBase {
|
|
|
2220
2556
|
this.mediaElementsLoadingPromises = mediaElements.map(waitForImageHtmlElementLoad);
|
|
2221
2557
|
}
|
|
2222
2558
|
mediaElementsLoadingPromises = [];
|
|
2559
|
+
get nodeRef() {
|
|
2560
|
+
return this._elementNodeRef;
|
|
2561
|
+
}
|
|
2223
2562
|
init(localData) {
|
|
2224
2563
|
return Promise.resolve(true);
|
|
2225
2564
|
}
|
|
@@ -2254,6 +2593,9 @@ class SwipeUp {
|
|
|
2254
2593
|
return element instanceof SwipeUp;
|
|
2255
2594
|
}
|
|
2256
2595
|
mediaElementsLoadingPromises = [];
|
|
2596
|
+
get nodeRef() {
|
|
2597
|
+
return this._elementNodeRef;
|
|
2598
|
+
}
|
|
2257
2599
|
init(localData) {
|
|
2258
2600
|
return Promise.resolve(true);
|
|
2259
2601
|
}
|
|
@@ -2280,7 +2622,7 @@ class Video {
|
|
|
2280
2622
|
_elementNodeRef;
|
|
2281
2623
|
_layer;
|
|
2282
2624
|
_VideoPlayer;
|
|
2283
|
-
|
|
2625
|
+
_slideApiDeps;
|
|
2284
2626
|
static _className = "narrative-element-video";
|
|
2285
2627
|
static className() {
|
|
2286
2628
|
return Video._className;
|
|
@@ -2290,11 +2632,11 @@ class Video {
|
|
|
2290
2632
|
_vodData;
|
|
2291
2633
|
_vodPlayerInstance = null;
|
|
2292
2634
|
_videoStateAdapter = null;
|
|
2293
|
-
constructor(_elementNodeRef, _layer, _VideoPlayer,
|
|
2635
|
+
constructor(_elementNodeRef, _layer, _VideoPlayer, _slideApiDeps) {
|
|
2294
2636
|
this._elementNodeRef = _elementNodeRef;
|
|
2295
2637
|
this._layer = _layer;
|
|
2296
2638
|
this._VideoPlayer = _VideoPlayer;
|
|
2297
|
-
this.
|
|
2639
|
+
this._slideApiDeps = _slideApiDeps;
|
|
2298
2640
|
const _video = this._elementNodeRef.querySelector("video");
|
|
2299
2641
|
if (!_video) {
|
|
2300
2642
|
return;
|
|
@@ -2350,6 +2692,9 @@ class Video {
|
|
|
2350
2692
|
return element instanceof Video;
|
|
2351
2693
|
}
|
|
2352
2694
|
mediaElementsLoadingPromises = [];
|
|
2695
|
+
get nodeRef() {
|
|
2696
|
+
return this._elementNodeRef;
|
|
2697
|
+
}
|
|
2353
2698
|
init(localData) {
|
|
2354
2699
|
return Promise.resolve(true);
|
|
2355
2700
|
}
|
|
@@ -2369,6 +2714,9 @@ class Video {
|
|
|
2369
2714
|
// console.log("onBeforeUnmount")
|
|
2370
2715
|
return await this._destroyVODPlayer();
|
|
2371
2716
|
}
|
|
2717
|
+
get durationMs() {
|
|
2718
|
+
return this._video.duration * 1000;
|
|
2719
|
+
}
|
|
2372
2720
|
_initVOD(vodData) {
|
|
2373
2721
|
const onWaiting = () => {
|
|
2374
2722
|
/**
|
|
@@ -2394,7 +2742,7 @@ class Video {
|
|
|
2394
2742
|
// TODO via class instead of data attr
|
|
2395
2743
|
if (this._video.getAttribute("data-waiting") === "1") {
|
|
2396
2744
|
this._video.setAttribute("data-waiting", "0");
|
|
2397
|
-
this._layer.timeline.slideResumed(this._video.currentTime * 1000);
|
|
2745
|
+
this._layer.timeline.slideResumed(() => this._video.currentTime * 1000);
|
|
2398
2746
|
// @ts-ignore
|
|
2399
2747
|
// _log(`playing: ${this._video.currentTime}`, true);
|
|
2400
2748
|
// clearTimeout(window.synthErrorId);
|
|
@@ -2478,13 +2826,13 @@ class Video {
|
|
|
2478
2826
|
});
|
|
2479
2827
|
}
|
|
2480
2828
|
_convertMpdUrls(mpd_) {
|
|
2481
|
-
if (this.
|
|
2829
|
+
if (this._slideApiDeps.isWeb) {
|
|
2482
2830
|
return mpd_;
|
|
2483
2831
|
}
|
|
2484
2832
|
if (isObject(mpd_) && mpd_.adaptiveFormats != null && Array.isArray(mpd_.adaptiveFormats)) {
|
|
2485
2833
|
const mpd = { ...mpd_ };
|
|
2486
2834
|
for (let i = 0; i < mpd.adaptiveFormats.length; ++i) {
|
|
2487
|
-
mpd.adaptiveFormats[i].url = `${this.
|
|
2835
|
+
mpd.adaptiveFormats[i].url = `${this._slideApiDeps.isAndroid ? `http://vod-asset/` : `vod-asset://`}${mpd.adaptiveFormats[i].cacheName}`;
|
|
2488
2836
|
}
|
|
2489
2837
|
return mpd;
|
|
2490
2838
|
}
|
|
@@ -2519,7 +2867,13 @@ class Video {
|
|
|
2519
2867
|
get videoStartedPromise() {
|
|
2520
2868
|
return this._videoStartedPromise;
|
|
2521
2869
|
}
|
|
2522
|
-
|
|
2870
|
+
get isLooped() {
|
|
2871
|
+
if (this._video != null) {
|
|
2872
|
+
return this._video?.loop;
|
|
2873
|
+
}
|
|
2874
|
+
return false;
|
|
2875
|
+
}
|
|
2876
|
+
start(muted = true, getIsLooped) {
|
|
2523
2877
|
this._videoStartedPromise = new Promise(async (resolve) => {
|
|
2524
2878
|
// invariant - always wait for mediaElementsLoadingPromises
|
|
2525
2879
|
// else call of _initVOD can start and onAllMediaLoaded failed
|
|
@@ -2533,7 +2887,7 @@ class Video {
|
|
|
2533
2887
|
// console.log("Video:start => this._video.pause()");
|
|
2534
2888
|
this._video.pause();
|
|
2535
2889
|
this._video.currentTime = 0;
|
|
2536
|
-
this._video.loop =
|
|
2890
|
+
this._video.loop = getIsLooped();
|
|
2537
2891
|
// remove init class
|
|
2538
2892
|
// if vod - create VoD player
|
|
2539
2893
|
if (this._video.getAttribute("data-default-muted") !== "1") {
|
|
@@ -2546,13 +2900,13 @@ class Video {
|
|
|
2546
2900
|
this._video.currentTime = 0;
|
|
2547
2901
|
this._elementNodeRef.classList.remove("init");
|
|
2548
2902
|
resolve({
|
|
2549
|
-
|
|
2903
|
+
getVideoCurrentTime: () => this._video.currentTime,
|
|
2550
2904
|
});
|
|
2551
2905
|
})
|
|
2552
2906
|
.catch(error => {
|
|
2553
2907
|
console.error(error);
|
|
2554
2908
|
resolve({
|
|
2555
|
-
|
|
2909
|
+
getVideoCurrentTime: () => this._video.currentTime,
|
|
2556
2910
|
});
|
|
2557
2911
|
});
|
|
2558
2912
|
}
|
|
@@ -2561,14 +2915,14 @@ class Video {
|
|
|
2561
2915
|
this._video.currentTime = 0;
|
|
2562
2916
|
this._elementNodeRef.classList.remove("init");
|
|
2563
2917
|
resolve({
|
|
2564
|
-
|
|
2918
|
+
getVideoCurrentTime: () => this._video.currentTime,
|
|
2565
2919
|
});
|
|
2566
2920
|
}, 0);
|
|
2567
2921
|
}
|
|
2568
2922
|
}
|
|
2569
2923
|
else {
|
|
2570
2924
|
resolve({
|
|
2571
|
-
|
|
2925
|
+
getVideoCurrentTime: () => 0,
|
|
2572
2926
|
});
|
|
2573
2927
|
}
|
|
2574
2928
|
});
|
|
@@ -2604,7 +2958,7 @@ class Video {
|
|
|
2604
2958
|
// console.log("resolve 1.1", { ts });
|
|
2605
2959
|
this._video.currentTime = ts;
|
|
2606
2960
|
}
|
|
2607
|
-
resolve({
|
|
2961
|
+
resolve({ getVideoCurrentTime: () => this._video.currentTime });
|
|
2608
2962
|
})
|
|
2609
2963
|
.catch(error => {
|
|
2610
2964
|
console.error(error);
|
|
@@ -2612,7 +2966,7 @@ class Video {
|
|
|
2612
2966
|
if (this._video.currentTime < ts) {
|
|
2613
2967
|
this._video.currentTime = ts;
|
|
2614
2968
|
}
|
|
2615
|
-
resolve({
|
|
2969
|
+
resolve({ getVideoCurrentTime: () => this._video.currentTime });
|
|
2616
2970
|
});
|
|
2617
2971
|
}
|
|
2618
2972
|
else {
|
|
@@ -2621,7 +2975,7 @@ class Video {
|
|
|
2621
2975
|
if (this._video.currentTime < ts) {
|
|
2622
2976
|
this._video.currentTime = ts;
|
|
2623
2977
|
}
|
|
2624
|
-
resolve({
|
|
2978
|
+
resolve({ getVideoCurrentTime: () => this._video.currentTime });
|
|
2625
2979
|
}, 0);
|
|
2626
2980
|
}
|
|
2627
2981
|
});
|
|
@@ -2675,7 +3029,7 @@ class Video {
|
|
|
2675
3029
|
this._video.muted = true;
|
|
2676
3030
|
}
|
|
2677
3031
|
}
|
|
2678
|
-
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof VideoPlayer | undefined`, `
|
|
3032
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof VideoPlayer | undefined`, `ISlideApiDeps`]; }
|
|
2679
3033
|
}
|
|
2680
3034
|
// class VideoStateAdapter {
|
|
2681
3035
|
//
|
|
@@ -2769,7 +3123,12 @@ class VideoStateAdapter {
|
|
|
2769
3123
|
}
|
|
2770
3124
|
// todo - add debounce
|
|
2771
3125
|
this._playingCheckerId = window.setTimeout(() => {
|
|
3126
|
+
// console.log({now: Date.now(), _timeupdate: this._timeupdate, currentTime: this._video.currentTime, duration: this._video.duration});
|
|
2772
3127
|
if (Date.now() - this._timeupdate >= this._maxDiff / 2) {
|
|
3128
|
+
// prevent onWaiting triggering if the video has ended
|
|
3129
|
+
if (Math.round(this._video.currentTime) >= Math.round(this._video.duration)) {
|
|
3130
|
+
return;
|
|
3131
|
+
}
|
|
2773
3132
|
this._state = 2 /* VIDEO_STATE.WAITING */;
|
|
2774
3133
|
this._triggerUpdate();
|
|
2775
3134
|
}
|
|
@@ -2852,7 +3211,7 @@ const tryCreateFromHtmlElement = (nodeRef, layer, widgetCallbacks, widgetDeps) =
|
|
|
2852
3211
|
case Text.className():
|
|
2853
3212
|
return new Text(nodeRef, layer);
|
|
2854
3213
|
case Button.className():
|
|
2855
|
-
return new Button(nodeRef, layer);
|
|
3214
|
+
return new Button(nodeRef, layer, widgetDeps);
|
|
2856
3215
|
case Image.className():
|
|
2857
3216
|
return new Image(nodeRef, layer);
|
|
2858
3217
|
case SwipeUp.className():
|
|
@@ -2860,7 +3219,7 @@ const tryCreateFromHtmlElement = (nodeRef, layer, widgetCallbacks, widgetDeps) =
|
|
|
2860
3219
|
case SwipeUpItems.className():
|
|
2861
3220
|
return new SwipeUpItems(nodeRef, layer);
|
|
2862
3221
|
case Video.className():
|
|
2863
|
-
return new Video(nodeRef, layer, layoutApi.VideoPlayer, layer.
|
|
3222
|
+
return new Video(nodeRef, layer, layoutApi.VideoPlayer, layer.slideApiDeps);
|
|
2864
3223
|
//////// widgets ///////
|
|
2865
3224
|
case Copy.className():
|
|
2866
3225
|
return layoutApi.widgetCopyApi ? new Copy(nodeRef, layer, layoutApi.widgetCopyApi, widgetCallbacks, widgetDeps) : null;
|
|
@@ -2918,20 +3277,23 @@ class SlideTimeline {
|
|
|
2918
3277
|
slideDisabledTimer;
|
|
2919
3278
|
slideReady;
|
|
2920
3279
|
_afterAppResumeQueuePush;
|
|
2921
|
-
|
|
2922
|
-
constructor(slideIndex, slideDuration, slideDisabledTimer, slideReady, _afterAppResumeQueuePush,
|
|
3280
|
+
slideApiDeps;
|
|
3281
|
+
constructor(slideIndex, slideDuration, slideDisabledTimer, slideReady, _afterAppResumeQueuePush, slideApiDeps) {
|
|
2923
3282
|
this.slideIndex = slideIndex;
|
|
2924
3283
|
this.slideDuration = slideDuration;
|
|
2925
3284
|
this.slideDisabledTimer = slideDisabledTimer;
|
|
2926
3285
|
this.slideReady = slideReady;
|
|
2927
3286
|
this._afterAppResumeQueuePush = _afterAppResumeQueuePush;
|
|
2928
|
-
this.
|
|
3287
|
+
this.slideApiDeps = slideApiDeps;
|
|
2929
3288
|
this.timelineDisabledState = this.slideDisabledTimer ? TimelineDisabledState.disabled : TimelineDisabledState.enabled;
|
|
2930
3289
|
}
|
|
2931
3290
|
resumedAt = new Date().getTime();
|
|
2932
3291
|
timeSpent = 0;
|
|
2933
3292
|
timelineDisabledState;
|
|
2934
3293
|
currentState = "stop" /* TIMELINE_ACTION.STOP */;
|
|
3294
|
+
deferredDataWaitingStateTimerId = null;
|
|
3295
|
+
deferredResumeStateTimerId = null;
|
|
3296
|
+
dataWaitingStartedAt = null;
|
|
2935
3297
|
static get layoutService() {
|
|
2936
3298
|
return container.get({ identifier: "LayoutService" });
|
|
2937
3299
|
}
|
|
@@ -2939,14 +3301,14 @@ class SlideTimeline {
|
|
|
2939
3301
|
return SlideTimeline.layoutService;
|
|
2940
3302
|
}
|
|
2941
3303
|
get isSDKSupportUpdateTimeline() {
|
|
2942
|
-
if (this.
|
|
3304
|
+
if (this.slideApiDeps.isAndroid) {
|
|
2943
3305
|
return Boolean(SlideTimeline.layoutService.env.Android && "updateTimeline" in SlideTimeline.layoutService.env.Android);
|
|
2944
3306
|
}
|
|
2945
|
-
else if (this.
|
|
3307
|
+
else if (this.slideApiDeps.isIOS) {
|
|
2946
3308
|
const mh = SlideTimeline.layoutService.env?.webkit?.messageHandlers ?? {};
|
|
2947
3309
|
return "updateTimeline" in mh;
|
|
2948
3310
|
}
|
|
2949
|
-
else if (this.
|
|
3311
|
+
else if (this.slideApiDeps.isWeb) {
|
|
2950
3312
|
return true;
|
|
2951
3313
|
}
|
|
2952
3314
|
else {
|
|
@@ -2954,7 +3316,7 @@ class SlideTimeline {
|
|
|
2954
3316
|
}
|
|
2955
3317
|
}
|
|
2956
3318
|
get isSdkSupportTimelineOnBeforeStart() {
|
|
2957
|
-
return this.
|
|
3319
|
+
return this.slideApiDeps.isSdkSupportTimelineOnBeforeStart();
|
|
2958
3320
|
}
|
|
2959
3321
|
get index() {
|
|
2960
3322
|
return this.slideIndex;
|
|
@@ -2962,6 +3324,9 @@ class SlideTimeline {
|
|
|
2962
3324
|
get isTimelineDisabled() {
|
|
2963
3325
|
return this.timelineDisabledState === TimelineDisabledState.disabled;
|
|
2964
3326
|
}
|
|
3327
|
+
get durationMs() {
|
|
3328
|
+
return this.slideDuration;
|
|
3329
|
+
}
|
|
2965
3330
|
async updateTimeline(action, showLoader = false, showError = false) {
|
|
2966
3331
|
// два кейса
|
|
2967
3332
|
// когда есть слои и у слоя вызываем showLayer который вызывает startTimer до старта слайда, потом start от sdk
|
|
@@ -2990,13 +3355,15 @@ class SlideTimeline {
|
|
|
2990
3355
|
//@ts-ignore
|
|
2991
3356
|
// window._log(`updateTimeline 1, a: ${action} ct: ${currentTime} d: ${duration} tds: ${this.timelineDisabledState}`, true);
|
|
2992
3357
|
await this.slideReady.then();
|
|
2993
|
-
//@ts-ignore
|
|
2994
3358
|
// window._log(`updateTimeline, a: ${action} ct: ${currentTime} d: ${duration} tds: ${this.timelineDisabledState}`, true);
|
|
2995
|
-
// console.trace(`updateTimeline ${action} slideIndex: ${this.slideIndex} currentTime:${currentTime} duration:${duration} tds: ${this.timelineDisabledState}`);
|
|
2996
|
-
this.
|
|
3359
|
+
// console.trace(`updateTimeline ${action} slideIndex: ${this.slideIndex} currentTime:${currentTime} duration:${duration} tds: ${this.timelineDisabledState} showLoader: ${showLoader} showError: ${showError}`);
|
|
3360
|
+
this.slideApiDeps.updateTimeline(this.slideIndex, action, currentTime, duration, showLoader, showError);
|
|
3361
|
+
if (action === "pause" /* TIMELINE_ACTION.PAUSE */ && showLoader) {
|
|
3362
|
+
this.dataWaitingStartedAt = Date.now();
|
|
3363
|
+
}
|
|
2997
3364
|
}
|
|
2998
3365
|
/**
|
|
2999
|
-
* trigger timeline update for new slide in sdk, before slide
|
|
3366
|
+
* trigger timeline update for new slide in sdk, before slide start event (prevent timeout in timeline while we wait for video start)
|
|
3000
3367
|
*/
|
|
3001
3368
|
triggerSlideLoadState() {
|
|
3002
3369
|
if (this.isSDKSupportUpdateTimeline && this.isSdkSupportTimelineOnBeforeStart) {
|
|
@@ -3009,7 +3376,7 @@ class SlideTimeline {
|
|
|
3009
3376
|
if (this.timelineDisabledState === TimelineDisabledState.disabled) {
|
|
3010
3377
|
duration = 0;
|
|
3011
3378
|
}
|
|
3012
|
-
this.
|
|
3379
|
+
this.slideApiDeps.updateTimeline(this.slideIndex, "before_start" /* TIMELINE_ACTION.BEFORE_START */, 0, duration, false, false);
|
|
3013
3380
|
}
|
|
3014
3381
|
}
|
|
3015
3382
|
/**
|
|
@@ -3018,6 +3385,7 @@ class SlideTimeline {
|
|
|
3018
3385
|
*/
|
|
3019
3386
|
slideStarted() {
|
|
3020
3387
|
// console.trace("slideStarted");
|
|
3388
|
+
this.onBeforeStateChanged();
|
|
3021
3389
|
if (this.isSDKSupportUpdateTimeline) {
|
|
3022
3390
|
this.resumedAt = new Date().getTime();
|
|
3023
3391
|
this.timeSpent = 0; // for case when instance exists, but we return to slide again
|
|
@@ -3026,6 +3394,7 @@ class SlideTimeline {
|
|
|
3026
3394
|
}
|
|
3027
3395
|
slideRestarted() {
|
|
3028
3396
|
// console.trace("slideRestarted");
|
|
3397
|
+
this.onBeforeStateChanged();
|
|
3029
3398
|
if (this.isSDKSupportUpdateTimeline) {
|
|
3030
3399
|
this.resumedAt = new Date().getTime();
|
|
3031
3400
|
this.timeSpent = 0;
|
|
@@ -3035,11 +3404,12 @@ class SlideTimeline {
|
|
|
3035
3404
|
/**
|
|
3036
3405
|
*
|
|
3037
3406
|
*/
|
|
3038
|
-
slidePaused(
|
|
3407
|
+
slidePaused(currentTime) {
|
|
3039
3408
|
// console.trace("slidePaused");
|
|
3409
|
+
this.onBeforeStateChanged();
|
|
3040
3410
|
if (this.isSDKSupportUpdateTimeline) {
|
|
3041
|
-
if (
|
|
3042
|
-
this.timeSpent = Math.round(
|
|
3411
|
+
if (currentTime != null) {
|
|
3412
|
+
this.timeSpent = Math.round(currentTime);
|
|
3043
3413
|
}
|
|
3044
3414
|
else {
|
|
3045
3415
|
const globalCurrentTime = new Date().getTime();
|
|
@@ -3049,26 +3419,43 @@ class SlideTimeline {
|
|
|
3049
3419
|
this.updateTimeline("pause" /* TIMELINE_ACTION.PAUSE */);
|
|
3050
3420
|
}
|
|
3051
3421
|
else {
|
|
3052
|
-
this.
|
|
3422
|
+
this.slideApiDeps.cardPausedCallback(currentTime);
|
|
3053
3423
|
}
|
|
3054
3424
|
}
|
|
3055
|
-
slideResumed(
|
|
3425
|
+
slideResumed(getVideoCurrentTime) {
|
|
3056
3426
|
// console.trace("slideResumed");
|
|
3427
|
+
this.onBeforeStateChanged();
|
|
3057
3428
|
// @ts-ignore
|
|
3058
3429
|
// window._log(`updateTimeline slideResumed ${videoCurrentTime}`, true);
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3430
|
+
// dataWaitingStartedAt
|
|
3431
|
+
const slideResume = () => {
|
|
3432
|
+
if (this.isSDKSupportUpdateTimeline) {
|
|
3433
|
+
if (getVideoCurrentTime != null) {
|
|
3434
|
+
this.timeSpent = Math.round(getVideoCurrentTime());
|
|
3435
|
+
}
|
|
3436
|
+
this.resumedAt = new Date().getTime();
|
|
3437
|
+
this.updateTimeline("start" /* TIMELINE_ACTION.START */);
|
|
3062
3438
|
}
|
|
3063
|
-
|
|
3064
|
-
|
|
3439
|
+
else {
|
|
3440
|
+
this.slideApiDeps.cardResumedCallback(getVideoCurrentTime != null ? getVideoCurrentTime() : null);
|
|
3441
|
+
}
|
|
3442
|
+
};
|
|
3443
|
+
// prevent micro loaders in UI
|
|
3444
|
+
const delay = 300;
|
|
3445
|
+
let dataWaitingLoaderSpent = delay;
|
|
3446
|
+
if (this.dataWaitingStartedAt != null) {
|
|
3447
|
+
dataWaitingLoaderSpent = Date.now() - this.dataWaitingStartedAt;
|
|
3448
|
+
}
|
|
3449
|
+
if (dataWaitingLoaderSpent < delay) {
|
|
3450
|
+
this.deferredResumeStateTimerId = window.setTimeout(slideResume, dataWaitingLoaderSpent - delay);
|
|
3065
3451
|
}
|
|
3066
3452
|
else {
|
|
3067
|
-
|
|
3453
|
+
slideResume();
|
|
3068
3454
|
}
|
|
3069
3455
|
}
|
|
3070
3456
|
slideStopped() {
|
|
3071
3457
|
// console.trace("slideStopped");
|
|
3458
|
+
this.onBeforeStateChanged();
|
|
3072
3459
|
if (this.isSDKSupportUpdateTimeline) {
|
|
3073
3460
|
this.updateTimeline("stop" /* TIMELINE_ACTION.STOP */);
|
|
3074
3461
|
}
|
|
@@ -3078,6 +3465,7 @@ class SlideTimeline {
|
|
|
3078
3465
|
* used by widgets
|
|
3079
3466
|
*/
|
|
3080
3467
|
startDisabledTimeline(fallback) {
|
|
3468
|
+
this.onBeforeStateChanged();
|
|
3081
3469
|
// if app is paused (in background) - don't call start timeline (Android issues)
|
|
3082
3470
|
// @ts-ignore
|
|
3083
3471
|
// window._log(`Push startDisabledTimeline to queue at state: ${window.slideApi.state}, time: ${new Date().getTime()}`, true);
|
|
@@ -3097,6 +3485,7 @@ class SlideTimeline {
|
|
|
3097
3485
|
}
|
|
3098
3486
|
onSlideDataWaiting(videoCurrentTime) {
|
|
3099
3487
|
// console.trace("onSlideDataWaiting");
|
|
3488
|
+
this.onBeforeStateChanged();
|
|
3100
3489
|
// @ts-ignore
|
|
3101
3490
|
// window._log(`updateTimeline onSlideDataWaiting ${videoCurrentTime}`, true);
|
|
3102
3491
|
if (videoCurrentTime != null) {
|
|
@@ -3107,10 +3496,20 @@ class SlideTimeline {
|
|
|
3107
3496
|
let spent = globalCurrentTime - this.resumedAt;
|
|
3108
3497
|
this.timeSpent += spent;
|
|
3109
3498
|
}
|
|
3110
|
-
|
|
3499
|
+
// prevent micro loaders in UI
|
|
3500
|
+
if (this.currentState === "start" /* TIMELINE_ACTION.START */) {
|
|
3501
|
+
this.updateTimeline("pause" /* TIMELINE_ACTION.PAUSE */, false, false);
|
|
3502
|
+
this.deferredDataWaitingStateTimerId = window.setTimeout(() => {
|
|
3503
|
+
this.updateTimeline("pause" /* TIMELINE_ACTION.PAUSE */, true, false);
|
|
3504
|
+
}, 300);
|
|
3505
|
+
}
|
|
3506
|
+
else {
|
|
3507
|
+
this.updateTimeline("pause" /* TIMELINE_ACTION.PAUSE */, true, false);
|
|
3508
|
+
}
|
|
3111
3509
|
}
|
|
3112
3510
|
onSlideError(videoCurrentTime) {
|
|
3113
3511
|
// console.trace("onSlideError");
|
|
3512
|
+
this.onBeforeStateChanged();
|
|
3114
3513
|
if (videoCurrentTime != null) {
|
|
3115
3514
|
this.timeSpent = Math.round(videoCurrentTime);
|
|
3116
3515
|
}
|
|
@@ -3121,7 +3520,21 @@ class SlideTimeline {
|
|
|
3121
3520
|
}
|
|
3122
3521
|
this.updateTimeline("stop" /* TIMELINE_ACTION.STOP */, false, true);
|
|
3123
3522
|
}
|
|
3124
|
-
|
|
3523
|
+
clearDeferredDataWaitingStateTimerId() {
|
|
3524
|
+
if (this.deferredDataWaitingStateTimerId != null) {
|
|
3525
|
+
window.clearTimeout(this.deferredDataWaitingStateTimerId);
|
|
3526
|
+
}
|
|
3527
|
+
}
|
|
3528
|
+
clearDeferredResumeStateTimerId() {
|
|
3529
|
+
if (this.deferredResumeStateTimerId != null) {
|
|
3530
|
+
window.clearTimeout(this.deferredResumeStateTimerId);
|
|
3531
|
+
}
|
|
3532
|
+
}
|
|
3533
|
+
onBeforeStateChanged() {
|
|
3534
|
+
this.clearDeferredDataWaitingStateTimerId();
|
|
3535
|
+
this.clearDeferredResumeStateTimerId();
|
|
3536
|
+
}
|
|
3537
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`number`, `number`, `boolean`, `Promise`, `(cb: () => void) => void`, `ISlideApiDeps`]; }
|
|
3125
3538
|
}
|
|
3126
3539
|
|
|
3127
3540
|
class Layer {
|
|
@@ -3130,8 +3543,7 @@ class Layer {
|
|
|
3130
3543
|
_slideReadyPromise;
|
|
3131
3544
|
_afterAppResumeQueuePush;
|
|
3132
3545
|
_afterStartInitQueuePush;
|
|
3133
|
-
|
|
3134
|
-
sdkApi;
|
|
3546
|
+
slideApiDeps;
|
|
3135
3547
|
_slideRoot;
|
|
3136
3548
|
_getLayoutDirection;
|
|
3137
3549
|
_slidePauseUI;
|
|
@@ -3147,14 +3559,13 @@ class Layer {
|
|
|
3147
3559
|
_elements = [];
|
|
3148
3560
|
_timeline;
|
|
3149
3561
|
_widgetDeps;
|
|
3150
|
-
constructor(_nodeRef, _slide, _slideReadyPromise, _afterAppResumeQueuePush, _afterStartInitQueuePush,
|
|
3562
|
+
constructor(_nodeRef, _slide, _slideReadyPromise, _afterAppResumeQueuePush, _afterStartInitQueuePush, slideApiDeps, _slideRoot, _getLayoutDirection, _slidePauseUI, _slideResumeUI, _getSdkClientVariables) {
|
|
3151
3563
|
this._nodeRef = _nodeRef;
|
|
3152
3564
|
this._slide = _slide;
|
|
3153
3565
|
this._slideReadyPromise = _slideReadyPromise;
|
|
3154
3566
|
this._afterAppResumeQueuePush = _afterAppResumeQueuePush;
|
|
3155
3567
|
this._afterStartInitQueuePush = _afterStartInitQueuePush;
|
|
3156
|
-
this.
|
|
3157
|
-
this.sdkApi = sdkApi;
|
|
3568
|
+
this.slideApiDeps = slideApiDeps;
|
|
3158
3569
|
this._slideRoot = _slideRoot;
|
|
3159
3570
|
this._getLayoutDirection = _getLayoutDirection;
|
|
3160
3571
|
this._slidePauseUI = _slidePauseUI;
|
|
@@ -3167,16 +3578,16 @@ class Layer {
|
|
|
3167
3578
|
this._duration = parseInt(this._nodeRef.getAttribute("data-duration") ?? "") || DEFAULT_SLIDE_DURATION;
|
|
3168
3579
|
this._disabledTimer = this._nodeRef.getAttribute("data-disable-timer") === "1";
|
|
3169
3580
|
this._disabledNavigation = this._nodeRef.getAttribute("data-disable-navigation") === "1";
|
|
3170
|
-
this._timeline = new SlideTimeline(this._slideIndex, this._duration, this._disabledTimer, this._slideReadyPromise, this._afterAppResumeQueuePush, this.
|
|
3581
|
+
this._timeline = new SlideTimeline(this._slideIndex, this._duration, this._disabledTimer, this._slideReadyPromise, this._afterAppResumeQueuePush, this.slideApiDeps);
|
|
3171
3582
|
this._widgetDeps = {
|
|
3172
|
-
|
|
3583
|
+
slideApiDeps: this.slideApiDeps,
|
|
3173
3584
|
slideRoot: this._slideRoot,
|
|
3174
3585
|
getLayoutDirection: this._getLayoutDirection,
|
|
3175
3586
|
getSdkClientVariables: this._getSdkClientVariables,
|
|
3176
3587
|
};
|
|
3177
3588
|
const onWidgetComplete = (cardId, slideIndex) => {
|
|
3178
3589
|
// todo if nothing more widgets with disabled timers - we can start layer timeline
|
|
3179
|
-
const fallback = () => this.
|
|
3590
|
+
const fallback = () => this.slideApiDeps.showNextSlide(DEFAULT_SLIDE_DURATION);
|
|
3180
3591
|
// для android sdk важно чтобы этот метод вызывался только после slide_start
|
|
3181
3592
|
this._afterStartInitQueuePush(() => {
|
|
3182
3593
|
this._timeline.startDisabledTimeline(fallback);
|
|
@@ -3218,17 +3629,17 @@ class Layer {
|
|
|
3218
3629
|
}
|
|
3219
3630
|
}
|
|
3220
3631
|
init(localData) {
|
|
3221
|
-
if (this.
|
|
3632
|
+
if (this.slideApiDeps.isIOS || this.slideApiDeps.isAndroid) {
|
|
3222
3633
|
this._nodeRef.classList.add("_app");
|
|
3223
|
-
this.
|
|
3224
|
-
this.
|
|
3634
|
+
this.slideApiDeps.isIOS && this._nodeRef.classList.add("_isIos");
|
|
3635
|
+
this.slideApiDeps.isAndroid && this._nodeRef.classList.add("_isAndroid");
|
|
3225
3636
|
}
|
|
3226
|
-
this.
|
|
3637
|
+
this.slideApiDeps.cardAnimation?.init(this._nodeRef);
|
|
3227
3638
|
const promises = this._elements.map(element => element.init(localData));
|
|
3228
3639
|
return promises;
|
|
3229
3640
|
}
|
|
3230
3641
|
onAfterAllMediaResourcesLoaded() {
|
|
3231
|
-
if (this.
|
|
3642
|
+
if (this.slideApiDeps.isIOS) ;
|
|
3232
3643
|
this._initTextFit();
|
|
3233
3644
|
}
|
|
3234
3645
|
get nodeRef() {
|
|
@@ -3247,7 +3658,10 @@ class Layer {
|
|
|
3247
3658
|
return container.get({ identifier: "LayoutService" });
|
|
3248
3659
|
}
|
|
3249
3660
|
getLocalData() {
|
|
3250
|
-
return this.
|
|
3661
|
+
return this.slideApiDeps.getCardLocalData();
|
|
3662
|
+
}
|
|
3663
|
+
findElementByNodeRef(nodeRef) {
|
|
3664
|
+
return this._elements.find(element => element.nodeRef === nodeRef);
|
|
3251
3665
|
}
|
|
3252
3666
|
get isQuest() {
|
|
3253
3667
|
return this._nodeRef.getAttribute("data-quest-count") != null;
|
|
@@ -3400,14 +3814,19 @@ class Layer {
|
|
|
3400
3814
|
const videoElement = this.videoElement;
|
|
3401
3815
|
let currentTime = 0;
|
|
3402
3816
|
if (videoElement != null) {
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3817
|
+
const getVideoIsLooped = () => {
|
|
3818
|
+
let videoLoop = false;
|
|
3819
|
+
if (this.timeline.isTimelineDisabled || this.timeline.durationMs > videoElement.durationMs) {
|
|
3820
|
+
videoLoop = true;
|
|
3821
|
+
}
|
|
3822
|
+
// console.log({videoLoop, isTimelineDisabled: this.timeline.isTimelineDisabled, timelineDurationMs: this.timeline.durationMs, videoElementDurationMs: videoElement.durationMs});
|
|
3823
|
+
return videoLoop;
|
|
3824
|
+
};
|
|
3825
|
+
// todo - need to convert to ms ?
|
|
3826
|
+
currentTime = (await videoElement.start(muted, getVideoIsLooped)).getVideoCurrentTime();
|
|
3408
3827
|
}
|
|
3409
|
-
if (this.
|
|
3410
|
-
this._animationPauseCb = this.
|
|
3828
|
+
if (this.slideApiDeps.cardAnimation) {
|
|
3829
|
+
this._animationPauseCb = this.slideApiDeps.cardAnimation.start(this._nodeRef);
|
|
3411
3830
|
}
|
|
3412
3831
|
for (const element of this._elements) {
|
|
3413
3832
|
element.onStart();
|
|
@@ -3423,7 +3842,7 @@ class Layer {
|
|
|
3423
3842
|
}
|
|
3424
3843
|
async stop(options) {
|
|
3425
3844
|
this.videoElement?.stop(options);
|
|
3426
|
-
this.
|
|
3845
|
+
this.slideApiDeps.cardAnimation?.stop(this._nodeRef);
|
|
3427
3846
|
for (const element of this._elements) {
|
|
3428
3847
|
element.onPause();
|
|
3429
3848
|
}
|
|
@@ -3434,7 +3853,7 @@ class Layer {
|
|
|
3434
3853
|
}
|
|
3435
3854
|
stopInternal(options) {
|
|
3436
3855
|
this.videoElement?.stop(options);
|
|
3437
|
-
this.
|
|
3856
|
+
this.slideApiDeps.cardAnimation?.stop(this._nodeRef);
|
|
3438
3857
|
for (const element of this._elements) {
|
|
3439
3858
|
element.onPause();
|
|
3440
3859
|
}
|
|
@@ -3446,17 +3865,21 @@ class Layer {
|
|
|
3446
3865
|
return new Promise(resolve => {
|
|
3447
3866
|
const cb = () => {
|
|
3448
3867
|
let currentTime = this.videoElement?.pause(resetVideoTime) ?? null;
|
|
3868
|
+
if (this.videoElement?.isLooped) {
|
|
3869
|
+
// skip currentTime from looped video (bcz in that case video time does not associated with timeline)
|
|
3870
|
+
currentTime = null;
|
|
3871
|
+
}
|
|
3872
|
+
if (currentTime != null) {
|
|
3873
|
+
currentTime *= 1000;
|
|
3874
|
+
}
|
|
3449
3875
|
if (stopAnimation) {
|
|
3450
|
-
this.
|
|
3876
|
+
this.slideApiDeps.cardAnimation?.stop(this._nodeRef);
|
|
3451
3877
|
}
|
|
3452
3878
|
else {
|
|
3453
3879
|
if (this._animationPauseCb != null && isFunction(this._animationPauseCb)) {
|
|
3454
3880
|
this._animationResumeCb = this._animationPauseCb(false);
|
|
3455
3881
|
}
|
|
3456
3882
|
}
|
|
3457
|
-
if (currentTime != null) {
|
|
3458
|
-
currentTime *= 1000;
|
|
3459
|
-
}
|
|
3460
3883
|
for (const element of this._elements) {
|
|
3461
3884
|
element.onPause();
|
|
3462
3885
|
}
|
|
@@ -3476,26 +3899,23 @@ class Layer {
|
|
|
3476
3899
|
}
|
|
3477
3900
|
async resume() {
|
|
3478
3901
|
return new Promise(resolve => {
|
|
3479
|
-
const cb = ({
|
|
3902
|
+
const cb = ({ getVideoCurrentTime }) => {
|
|
3480
3903
|
// console.log("resumed cb with currentTime", { currentTime });
|
|
3481
|
-
if (currentTime != null) {
|
|
3482
|
-
currentTime *= 1000;
|
|
3483
|
-
}
|
|
3484
3904
|
if (isFunction(this._animationResumeCb)) {
|
|
3485
3905
|
this._animationResumeCb();
|
|
3486
3906
|
}
|
|
3487
3907
|
for (const element of this._elements) {
|
|
3488
3908
|
element.onResume();
|
|
3489
3909
|
}
|
|
3490
|
-
this.timeline.slideResumed(
|
|
3491
|
-
resolve({ currentTime });
|
|
3910
|
+
this.timeline.slideResumed(getVideoCurrentTime != null ? () => getVideoCurrentTime() * 1000 : undefined);
|
|
3911
|
+
resolve({ currentTime: getVideoCurrentTime != null ? getVideoCurrentTime() : null });
|
|
3492
3912
|
};
|
|
3493
3913
|
const videoStartedPromise = this.videoElement?.resume();
|
|
3494
3914
|
if (videoStartedPromise != null && videoStartedPromise.then != null) {
|
|
3495
3915
|
videoStartedPromise.then(cb);
|
|
3496
3916
|
}
|
|
3497
3917
|
else {
|
|
3498
|
-
cb({
|
|
3918
|
+
cb({ getVideoCurrentTime: undefined });
|
|
3499
3919
|
}
|
|
3500
3920
|
});
|
|
3501
3921
|
}
|
|
@@ -3511,7 +3931,7 @@ class Layer {
|
|
|
3511
3931
|
get isLayerForcePaused() {
|
|
3512
3932
|
return this.elements.some(element => element.isLayerForcePaused);
|
|
3513
3933
|
}
|
|
3514
|
-
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Slide`, `Promise`, `(cb: () => void) => void`, `(cb: () => void) => void`, `
|
|
3934
|
+
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`]; }
|
|
3515
3935
|
}
|
|
3516
3936
|
const TextFit = (function () {
|
|
3517
3937
|
const defaultSettings = {
|
|
@@ -3702,8 +4122,7 @@ class Slide {
|
|
|
3702
4122
|
_slideReadyPromise;
|
|
3703
4123
|
_afterAppResumeQueuePush;
|
|
3704
4124
|
_afterStartInitQueuePush;
|
|
3705
|
-
|
|
3706
|
-
sdkApi;
|
|
4125
|
+
slideApiDeps;
|
|
3707
4126
|
_slideRoot;
|
|
3708
4127
|
_getLayoutDirection;
|
|
3709
4128
|
_slidePauseUI;
|
|
@@ -3711,13 +4130,12 @@ class Slide {
|
|
|
3711
4130
|
_getSdkClientVariables;
|
|
3712
4131
|
_layers;
|
|
3713
4132
|
_start;
|
|
3714
|
-
constructor(_slidesNodesRefs, _slideReadyPromise, _afterAppResumeQueuePush, _afterStartInitQueuePush,
|
|
4133
|
+
constructor(_slidesNodesRefs, _slideReadyPromise, _afterAppResumeQueuePush, _afterStartInitQueuePush, slideApiDeps, _slideRoot, _getLayoutDirection, _slidePauseUI, _slideResumeUI, _getSdkClientVariables) {
|
|
3715
4134
|
this._slidesNodesRefs = _slidesNodesRefs;
|
|
3716
4135
|
this._slideReadyPromise = _slideReadyPromise;
|
|
3717
4136
|
this._afterAppResumeQueuePush = _afterAppResumeQueuePush;
|
|
3718
4137
|
this._afterStartInitQueuePush = _afterStartInitQueuePush;
|
|
3719
|
-
this.
|
|
3720
|
-
this.sdkApi = sdkApi;
|
|
4138
|
+
this.slideApiDeps = slideApiDeps;
|
|
3721
4139
|
this._slideRoot = _slideRoot;
|
|
3722
4140
|
this._getLayoutDirection = _getLayoutDirection;
|
|
3723
4141
|
this._slidePauseUI = _slidePauseUI;
|
|
@@ -3727,7 +4145,7 @@ class Slide {
|
|
|
3727
4145
|
if (!this._slidesNodesRefs.length) {
|
|
3728
4146
|
throw new Error("No slides found.");
|
|
3729
4147
|
}
|
|
3730
|
-
this._layers = this._slidesNodesRefs.map(item => new Layer(item, this, this._slideReadyPromise, this._afterAppResumeQueuePush, this._afterStartInitQueuePush, this.
|
|
4148
|
+
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));
|
|
3731
4149
|
this._activeLayer = this._layers[0];
|
|
3732
4150
|
}
|
|
3733
4151
|
_activeLayer;
|
|
@@ -3747,7 +4165,7 @@ class Slide {
|
|
|
3747
4165
|
if (multiSlideApi != null && this.layers.length > 1) {
|
|
3748
4166
|
try {
|
|
3749
4167
|
multiSlideApi.init(this.layersNodesRefs, localData, {
|
|
3750
|
-
|
|
4168
|
+
slideApiDeps: this.slideApiDeps,
|
|
3751
4169
|
slideRoot: this._slideRoot,
|
|
3752
4170
|
getLayoutDirection: this._getLayoutDirection,
|
|
3753
4171
|
getSdkClientVariables: this._getSdkClientVariables,
|
|
@@ -3824,7 +4242,7 @@ class Slide {
|
|
|
3824
4242
|
get disabledNavigation() {
|
|
3825
4243
|
return this._activeLayer.disabledNavigation;
|
|
3826
4244
|
}
|
|
3827
|
-
static get [Symbol.for("___CTOR_ARGS___")]() { return [`Array`, `Promise`, `(cb: () => void) => void`, `(cb: () => void) => void`, `
|
|
4245
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`Array`, `Promise`, `(cb: () => void) => void`, `(cb: () => void) => void`, `ISlideApiDeps`, `HTMLElement`, `() => "ltr" | "rtl"`, `() => Promise<void>`, `() => Promise<void>`, `GetSdkClientVariables`]; }
|
|
3828
4246
|
}
|
|
3829
4247
|
|
|
3830
4248
|
let SlideApi$1 = class SlideApi {
|
|
@@ -3841,20 +4259,29 @@ let SlideApi$1 = class SlideApi {
|
|
|
3841
4259
|
_getViewportHeight;
|
|
3842
4260
|
_overlappingActionBarHeight;
|
|
3843
4261
|
_separateUserAndAppPause;
|
|
3844
|
-
|
|
4262
|
+
_index;
|
|
4263
|
+
slideApiDeps;
|
|
3845
4264
|
constructor(config) {
|
|
3846
4265
|
this.config = config;
|
|
3847
|
-
this.
|
|
4266
|
+
this.slideApiDeps = config.slideApiDeps;
|
|
3848
4267
|
this._slideWrapper = config.slideWrapper;
|
|
3849
4268
|
this._viewport = config.viewport;
|
|
3850
4269
|
this._getViewportWidth = config.getViewportWidth;
|
|
3851
4270
|
this._getViewportHeight = config.getViewportHeight;
|
|
3852
4271
|
this._overlappingActionBarHeight = config.overlappingActionBarHeight ?? 0;
|
|
3853
4272
|
this._separateUserAndAppPause = config.separateUserAndAppPause;
|
|
3854
|
-
this.
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
4273
|
+
this._index = config.index;
|
|
4274
|
+
}
|
|
4275
|
+
static checkPreloadedInLayoutSlide() {
|
|
4276
|
+
// for sdk backward compatibility
|
|
4277
|
+
const slideBox = document.getElementById("narrative-slide-box");
|
|
4278
|
+
if (slideBox && slideBox.innerText.trim() !== "{%content}".replace("{", "{{").replace("}", "}}")) {
|
|
4279
|
+
return true;
|
|
4280
|
+
}
|
|
4281
|
+
return false;
|
|
4282
|
+
}
|
|
4283
|
+
initPreloadedInLayoutSlide(slideLoadedCb) {
|
|
4284
|
+
// for sdk backward compatibility
|
|
3858
4285
|
const slideBox = document.getElementById("narrative-slide-box");
|
|
3859
4286
|
// todo via first child and its innerText - faster variant
|
|
3860
4287
|
if (slideBox && slideBox.innerText.trim() !== "{%content}".replace("{", "{{").replace("}", "}}")) {
|
|
@@ -3862,117 +4289,42 @@ let SlideApi$1 = class SlideApi {
|
|
|
3862
4289
|
this._slideInRender = true;
|
|
3863
4290
|
this._init(() => this._slideBoxRenderComplete(null)).then(({ slide, result, reason }) => {
|
|
3864
4291
|
this._slide = slide;
|
|
3865
|
-
if (
|
|
3866
|
-
|
|
4292
|
+
if (slideLoadedCb != null) {
|
|
4293
|
+
slideLoadedCb({ cardId: slide.cardId, slideIndex: slide.slideIndex, result, reason });
|
|
3867
4294
|
}
|
|
3868
4295
|
});
|
|
3869
4296
|
}
|
|
3870
4297
|
}
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
}
|
|
3881
|
-
destroyListeners() {
|
|
3882
|
-
this._viewport.removeEventListener("resize", this.refreshSizes);
|
|
3883
|
-
}
|
|
3884
|
-
_savedViewportWidth = null;
|
|
3885
|
-
_savedViewportHeight = null;
|
|
3886
|
-
refreshSizes() {
|
|
3887
|
-
const viewportWidth = this._getViewportWidth();
|
|
3888
|
-
const viewportHeight = this._getViewportHeight();
|
|
3889
|
-
if (this._savedViewportWidth === viewportWidth && this._savedViewportHeight === viewportHeight) {
|
|
3890
|
-
return;
|
|
3891
|
-
}
|
|
3892
|
-
this._savedViewportWidth = viewportWidth;
|
|
3893
|
-
this._savedViewportHeight = viewportHeight;
|
|
3894
|
-
const viewportRatio = viewportWidth / viewportHeight;
|
|
3895
|
-
let slideWidth = 0;
|
|
3896
|
-
let slideHeight = 0;
|
|
3897
|
-
// _ratio = 310 / 480,
|
|
3898
|
-
const _ratio = this.config.slideRatio;
|
|
3899
|
-
let _isFullscreen = this.config.isFullscreen;
|
|
3900
|
-
const slideOffset = this._slideWrapper.querySelector(".narrative-slide-offset");
|
|
3901
|
-
let offset = 0;
|
|
3902
|
-
let xOffset = "0px";
|
|
3903
|
-
// for elements with bottom anchor (absolute position)
|
|
3904
|
-
let yOffset = "0px";
|
|
3905
|
-
// alert(viewportHeight);
|
|
3906
|
-
// todo - mobile only (or isIos or isAndroid)
|
|
3907
|
-
if (this.sdkApi.isAndroid || this.sdkApi.isIOS) {
|
|
3908
|
-
if (viewportRatio > _ratio) {
|
|
3909
|
-
// disable _isFullscreen if viewport small
|
|
3910
|
-
_isFullscreen = false;
|
|
3911
|
-
}
|
|
3912
|
-
}
|
|
3913
|
-
if (_isFullscreen) {
|
|
3914
|
-
// более квадратное чем надо (desktop)
|
|
3915
|
-
if (viewportRatio > _ratio) {
|
|
3916
|
-
// fit by height
|
|
3917
|
-
slideHeight = viewportHeight;
|
|
3918
|
-
slideWidth = Math.ceil(slideHeight * _ratio);
|
|
3919
|
-
offset = Math.ceil(slideWidth - viewportWidth) / 2;
|
|
3920
|
-
if (slideOffset != null) {
|
|
3921
|
-
slideOffset.style.margin = "0 " + -offset + "px"; // -8.5
|
|
3922
|
-
}
|
|
3923
|
-
xOffset = offset + "px";
|
|
3924
|
-
}
|
|
3925
|
-
else {
|
|
3926
|
-
// fit by width, top and bottom - to offscreen or fill with bg image
|
|
3927
|
-
slideWidth = viewportWidth;
|
|
3928
|
-
slideHeight = Math.ceil(viewportWidth / _ratio);
|
|
3929
|
-
offset = Math.ceil(slideHeight - viewportHeight) / 2;
|
|
3930
|
-
if (slideOffset != null) {
|
|
3931
|
-
slideOffset.style.margin = -1 * offset + "px" + " 0 ";
|
|
3932
|
-
}
|
|
3933
|
-
// offset from viewport bottom to StoryBottom plus safe area offset bottom
|
|
3934
|
-
yOffset = `calc(${offset + this._overlappingActionBarHeight}px + env(safe-area-inset-bottom))`;
|
|
3935
|
-
// detect safe area offset
|
|
3936
|
-
}
|
|
3937
|
-
}
|
|
3938
|
-
else {
|
|
3939
|
-
// более квадратное чем надо
|
|
3940
|
-
if (viewportRatio > _ratio) {
|
|
3941
|
-
// fit by width, top and bottom - to offscreen
|
|
3942
|
-
slideWidth = viewportWidth;
|
|
3943
|
-
slideHeight = Math.ceil(viewportWidth / _ratio);
|
|
3944
|
-
offset = Math.ceil(slideHeight - viewportHeight) / 2;
|
|
3945
|
-
if (slideOffset != null) {
|
|
3946
|
-
slideOffset.style.margin = -offset + "px" + " 0 ";
|
|
3947
|
-
}
|
|
3948
|
-
yOffset = offset + this._overlappingActionBarHeight + "px";
|
|
4298
|
+
onUpdateSizeMetrics({ fontSize, xOffset, yOffset, isFullscreen, slideOffsetMargin }) {
|
|
4299
|
+
// todo CSP violation
|
|
4300
|
+
this._slideWrapper.style.fontSize = fontSize;
|
|
4301
|
+
if (this.slideOffsetElement != null) {
|
|
4302
|
+
// todo CSP violation
|
|
4303
|
+
this.slideOffsetElement.style.setProperty("--y-offset", yOffset);
|
|
4304
|
+
this.slideOffsetElement.style.setProperty("--x-offset", xOffset);
|
|
4305
|
+
if (isFullscreen) {
|
|
4306
|
+
this.slideOffsetElement.classList.add("narrative-slide-offset-fullscreen");
|
|
3949
4307
|
}
|
|
3950
4308
|
else {
|
|
3951
|
-
|
|
3952
|
-
// fit by height, sides - to offscreen
|
|
3953
|
-
slideHeight = viewportHeight;
|
|
3954
|
-
slideWidth = Math.ceil(slideHeight * _ratio);
|
|
3955
|
-
offset = Math.ceil(slideWidth - viewportWidth) / 2;
|
|
3956
|
-
if (slideOffset != null) {
|
|
3957
|
-
slideOffset.style.margin = "0 " + -offset + "px"; // -8.5
|
|
3958
|
-
}
|
|
3959
|
-
xOffset = offset + "px";
|
|
4309
|
+
this.slideOffsetElement.classList.remove("narrative-slide-offset-fullscreen");
|
|
3960
4310
|
}
|
|
4311
|
+
this.slideOffsetElement.style.margin = slideOffsetMargin;
|
|
3961
4312
|
}
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
this._slideWrapper
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
if (this.
|
|
3974
|
-
this.
|
|
4313
|
+
}
|
|
4314
|
+
get slideWrapperElement() {
|
|
4315
|
+
return this._slideWrapper;
|
|
4316
|
+
}
|
|
4317
|
+
get slideOffsetElement() {
|
|
4318
|
+
return this._slideWrapper.querySelector(".narrative-slide-offset");
|
|
4319
|
+
}
|
|
4320
|
+
get index() {
|
|
4321
|
+
return this._index;
|
|
4322
|
+
}
|
|
4323
|
+
async destroy() {
|
|
4324
|
+
if (this.slide != null) {
|
|
4325
|
+
await this.slide.onBeforeUnmount();
|
|
3975
4326
|
}
|
|
4327
|
+
this._state = 13 /* STATE.DESTROYED */;
|
|
3976
4328
|
}
|
|
3977
4329
|
async showSlide(html) {
|
|
3978
4330
|
const slideBox = this._slideWrapper.querySelector(`.${SlideApi.renderedBoxClassName}`);
|
|
@@ -3985,7 +4337,9 @@ let SlideApi$1 = class SlideApi {
|
|
|
3985
4337
|
}
|
|
3986
4338
|
this._slideInInit = null;
|
|
3987
4339
|
this._slideInRender = true;
|
|
3988
|
-
|
|
4340
|
+
if (html != null) {
|
|
4341
|
+
slideBoxPrerender.innerHTML = html;
|
|
4342
|
+
}
|
|
3989
4343
|
const prevSlide = this.slide ? Object.assign(Object.create(Object.getPrototypeOf(this.slide)), this.slide) : null;
|
|
3990
4344
|
const { slide, result, reason } = await this._init(() => this._slideBoxRenderComplete(prevSlide));
|
|
3991
4345
|
this._slide = slide;
|
|
@@ -4007,7 +4361,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4007
4361
|
return container.get({ identifier: "LayoutService" });
|
|
4008
4362
|
}
|
|
4009
4363
|
getLocalData() {
|
|
4010
|
-
return this.
|
|
4364
|
+
return this.slideApiDeps.getCardLocalData();
|
|
4011
4365
|
}
|
|
4012
4366
|
_fontsInit = false;
|
|
4013
4367
|
_initAndLoadFonts(fonts) {
|
|
@@ -4099,7 +4453,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4099
4453
|
/**
|
|
4100
4454
|
* For case when SlideApi instance was created before root was attached to DOM
|
|
4101
4455
|
*/
|
|
4102
|
-
this.refreshSizes();
|
|
4456
|
+
// this.config.refreshSizes(this);
|
|
4103
4457
|
const slideNodeRef = this._slideWrapper.querySelector(`.${SlideApi.prerenderBoxClassName} .narrative-slide`);
|
|
4104
4458
|
const slidesNodesRefs = Array.prototype.slice.call(this._slideWrapper.querySelectorAll(`.${SlideApi.prerenderBoxClassName} .narrative-slide.narrative-multi-slide`));
|
|
4105
4459
|
if (!slidesNodesRefs.length && slideNodeRef != null) {
|
|
@@ -4112,17 +4466,18 @@ let SlideApi$1 = class SlideApi {
|
|
|
4112
4466
|
const slideReadyPromise = new Promise(resolve => {
|
|
4113
4467
|
slideReadyResolve = resolve;
|
|
4114
4468
|
});
|
|
4115
|
-
const slide = new Slide(slidesNodesRefs, slideReadyPromise, this.afterAppResumeQueuePush.bind(this), this.afterStartInitQueuePush.bind(this), this.
|
|
4469
|
+
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);
|
|
4116
4470
|
this._slideInInit = slide;
|
|
4471
|
+
// todo - call via DI
|
|
4117
4472
|
slide.activeLayer.timeline.triggerSlideLoadState();
|
|
4118
|
-
if (this.
|
|
4473
|
+
if (this.slideApiDeps.isAndroid) {
|
|
4119
4474
|
this._afterStartInitQueue = [];
|
|
4120
4475
|
}
|
|
4121
4476
|
this._afterAppResumeQueue = [];
|
|
4122
4477
|
const result = { slide, result: false, reason: "" };
|
|
4123
4478
|
try {
|
|
4124
4479
|
const onAllMediaLoaded = this._onAllMediaLoaded(slide);
|
|
4125
|
-
const fontsPromise = this._initAndLoadFonts(this.
|
|
4480
|
+
const fontsPromise = this._initAndLoadFonts(this.slideApiDeps.getCardFonts());
|
|
4126
4481
|
const mediaAndFontsPromise = Promise.all([onAllMediaLoaded, fontsPromise]).then(() => {
|
|
4127
4482
|
this.layoutService.env.clearTimeout(mediaResourcesTimeoutId);
|
|
4128
4483
|
});
|
|
@@ -4221,7 +4576,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4221
4576
|
this._slideConfig = config;
|
|
4222
4577
|
// start deferred fncs from widgets
|
|
4223
4578
|
// important - Android only
|
|
4224
|
-
if (this.
|
|
4579
|
+
if (this.slideApiDeps.isAndroid && this._afterStartInitQueue && Array.isArray(this._afterStartInitQueue)) {
|
|
4225
4580
|
for (const job of this._afterStartInitQueue) {
|
|
4226
4581
|
if (isFunction(job)) {
|
|
4227
4582
|
job();
|
|
@@ -4275,7 +4630,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4275
4630
|
this._state = 9 /* STATE.USER_PAUSED */;
|
|
4276
4631
|
};
|
|
4277
4632
|
// todo move to Android adapter
|
|
4278
|
-
if (this.
|
|
4633
|
+
if (this.slideApiDeps.isAndroid && !this.slideApiDeps.isSdkSupportCorrectPauseResumeLifecycle()) {
|
|
4279
4634
|
this._pauseCbTimer = this.layoutService.env.setTimeout(pauseCb, 300);
|
|
4280
4635
|
}
|
|
4281
4636
|
else {
|
|
@@ -4349,10 +4704,10 @@ let SlideApi$1 = class SlideApi {
|
|
|
4349
4704
|
const defaultAction = () => {
|
|
4350
4705
|
const nextSlideIndex = this.slide.slideIndex + 1;
|
|
4351
4706
|
if (nextSlideIndex >= 0 && nextSlideIndex < this.slide.slideCount) {
|
|
4352
|
-
this.
|
|
4707
|
+
this.slideApiDeps.showCardSlide(nextSlideIndex);
|
|
4353
4708
|
}
|
|
4354
4709
|
else {
|
|
4355
|
-
this.
|
|
4710
|
+
this.slideApiDeps.cardShowNext();
|
|
4356
4711
|
}
|
|
4357
4712
|
};
|
|
4358
4713
|
if (this.activeLayer.questElement) {
|
|
@@ -4399,7 +4754,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4399
4754
|
if (!isFunction(cb)) {
|
|
4400
4755
|
return false;
|
|
4401
4756
|
}
|
|
4402
|
-
if (this.
|
|
4757
|
+
if (this.slideApiDeps.isAndroid && this._state === 0 /* STATE.INIT */) {
|
|
4403
4758
|
this._afterStartInitQueue.push(cb);
|
|
4404
4759
|
}
|
|
4405
4760
|
else {
|
|
@@ -4528,7 +4883,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4528
4883
|
if (this.layoutService.layoutApi.widgetVoteApi) {
|
|
4529
4884
|
if (this.layoutService.layoutApi.widgetVoteApi.click(element)) {
|
|
4530
4885
|
this.layoutService.env.setTimeout(() => {
|
|
4531
|
-
this.
|
|
4886
|
+
this.slideApiDeps.showNextSlide(0);
|
|
4532
4887
|
});
|
|
4533
4888
|
}
|
|
4534
4889
|
result.canClickNext = false;
|
|
@@ -4552,7 +4907,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4552
4907
|
}
|
|
4553
4908
|
if (element) {
|
|
4554
4909
|
this.layoutService.env.setTimeout(() => {
|
|
4555
|
-
this.
|
|
4910
|
+
this.slideApiDeps.showNextSlide(0);
|
|
4556
4911
|
});
|
|
4557
4912
|
result.canClickNext = false;
|
|
4558
4913
|
return result;
|
|
@@ -4580,7 +4935,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4580
4935
|
if (this.layoutService.layoutApi.widgetRangeSliderApi) {
|
|
4581
4936
|
if (this.layoutService.layoutApi.widgetRangeSliderApi.click(element)) {
|
|
4582
4937
|
this.layoutService.env.setTimeout(() => {
|
|
4583
|
-
this.
|
|
4938
|
+
this.slideApiDeps.showNextSlide(0);
|
|
4584
4939
|
});
|
|
4585
4940
|
}
|
|
4586
4941
|
result.canClickNext = false;
|
|
@@ -4787,18 +5142,18 @@ let SlideApi$1 = class SlideApi {
|
|
|
4787
5142
|
}
|
|
4788
5143
|
if (element) {
|
|
4789
5144
|
propagation = false;
|
|
4790
|
-
this.
|
|
4791
|
-
this.
|
|
5145
|
+
this.slideApiDeps.setCardLocalData({}, true);
|
|
5146
|
+
this.slideApiDeps.updateCardServerDataLocally(this.slide.cardId, {});
|
|
4792
5147
|
// window._resetTimers();
|
|
4793
5148
|
// сделать async в ios
|
|
4794
5149
|
let slideIndex = this.slide.slideIndex;
|
|
4795
5150
|
// prevent simultaneous call _showNarrativeSlide and _showLayer - prevent 2 calls of initAfterLoad (break video start on iOS)
|
|
4796
5151
|
if (slideIndex === 0) {
|
|
4797
5152
|
// for story repeat on the first slide with layers
|
|
4798
|
-
this.
|
|
5153
|
+
this.slideApiDeps.showLayer(0);
|
|
4799
5154
|
}
|
|
4800
5155
|
else {
|
|
4801
|
-
this.
|
|
5156
|
+
this.slideApiDeps.showCardSlide(0); // сделать ее async
|
|
4802
5157
|
}
|
|
4803
5158
|
}
|
|
4804
5159
|
// todo в каждом виджете делать выход через
|
|
@@ -4886,44 +5241,44 @@ let SlideApi$1 = class SlideApi {
|
|
|
4886
5241
|
// this.activeLayer.timeline.slidePaused(0);
|
|
4887
5242
|
// return {handled: true};
|
|
4888
5243
|
}
|
|
4889
|
-
if (this.
|
|
5244
|
+
if (this.slideApiDeps.isAndroid && linkTargetAndroid) {
|
|
4890
5245
|
linkTarget = linkTargetAndroid;
|
|
4891
5246
|
}
|
|
4892
|
-
if (this.
|
|
5247
|
+
if (this.slideApiDeps.isIOS && linkTargetIos) {
|
|
4893
5248
|
linkTarget = linkTargetIos;
|
|
4894
5249
|
}
|
|
4895
|
-
if (this.
|
|
5250
|
+
if (this.slideApiDeps.isWeb && linkTargetWeb) {
|
|
4896
5251
|
linkTarget = linkTargetWeb;
|
|
4897
5252
|
}
|
|
4898
5253
|
// for btn(link) without url (openGame, openStory, closeCard, products, goods, etc)
|
|
4899
5254
|
let statisticWidgetValue = linkType;
|
|
4900
5255
|
let statisticWidgetEventType = "w-link";
|
|
4901
5256
|
if (linkType === "closeStory" || linkType === "closeIAM") {
|
|
4902
|
-
this.layoutService.env.setTimeout(() => this.
|
|
5257
|
+
this.layoutService.env.setTimeout(() => this.slideApiDeps.closeCard("click"));
|
|
4903
5258
|
handled = true;
|
|
4904
5259
|
}
|
|
4905
5260
|
else if (linkType && linkTarget) {
|
|
4906
5261
|
if (linkType === "story") {
|
|
4907
5262
|
// storyId: number, slideIndex: number
|
|
4908
|
-
this.layoutService.env.setTimeout(() => this.
|
|
5263
|
+
this.layoutService.env.setTimeout(() => this.slideApiDeps.openStory(parseInt(linkTarget), 0));
|
|
4909
5264
|
handled = true;
|
|
4910
5265
|
}
|
|
4911
5266
|
else if (linkType === "slide") {
|
|
4912
5267
|
const __slideIndex = parseInt(linkTarget);
|
|
4913
5268
|
const __slideCount = this.slide.slideCount;
|
|
4914
5269
|
if (__slideIndex >= 0 && __slideIndex < __slideCount) {
|
|
4915
|
-
this.layoutService.env.setTimeout(() => this.
|
|
5270
|
+
this.layoutService.env.setTimeout(() => this.slideApiDeps.showCardSlide(__slideIndex));
|
|
4916
5271
|
handled = true;
|
|
4917
5272
|
}
|
|
4918
5273
|
}
|
|
4919
5274
|
else if (linkType === "game") {
|
|
4920
|
-
this.layoutService.env.setTimeout(() => this.
|
|
5275
|
+
this.layoutService.env.setTimeout(() => this.slideApiDeps.openGame(linkTarget));
|
|
4921
5276
|
handled = true;
|
|
4922
5277
|
}
|
|
4923
5278
|
else if (linkType === "layer") {
|
|
4924
5279
|
const layerIndex = parseInt(linkTarget);
|
|
4925
5280
|
if (layerIndex >= 0) {
|
|
4926
|
-
this.layoutService.env.setTimeout(() => this.
|
|
5281
|
+
this.layoutService.env.setTimeout(() => this.slideApiDeps.showLayer(layerIndex));
|
|
4927
5282
|
handled = true;
|
|
4928
5283
|
}
|
|
4929
5284
|
}
|
|
@@ -4931,7 +5286,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4931
5286
|
// traditional link, with url
|
|
4932
5287
|
statisticWidgetValue = linkTarget;
|
|
4933
5288
|
this.layoutService.env.setTimeout(() => {
|
|
4934
|
-
this.
|
|
5289
|
+
this.slideApiDeps.openUrl({
|
|
4935
5290
|
type: isSwipeUpAction ? "swipeUpLink" : "link",
|
|
4936
5291
|
link: {
|
|
4937
5292
|
type: "url",
|
|
@@ -4941,6 +5296,12 @@ let SlideApi$1 = class SlideApi {
|
|
|
4941
5296
|
});
|
|
4942
5297
|
handled = true;
|
|
4943
5298
|
}
|
|
5299
|
+
else if (linkType === "promocode") {
|
|
5300
|
+
handled = this.activeLayer.findElementByNodeRef(element)?.handleClick() ?? true;
|
|
5301
|
+
if (!handled) {
|
|
5302
|
+
return { handled: true };
|
|
5303
|
+
}
|
|
5304
|
+
}
|
|
4944
5305
|
else if (linkType === "products") {
|
|
4945
5306
|
if (this.layoutService.layoutApi.widgetProductsApi) {
|
|
4946
5307
|
this.layoutService.layoutApi.widgetProductsApi.click(element);
|
|
@@ -4950,7 +5311,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4950
5311
|
else if (linkType === "swipe-up-items") {
|
|
4951
5312
|
const target = linkTarget;
|
|
4952
5313
|
this.layoutService.env.setTimeout(() => {
|
|
4953
|
-
this.
|
|
5314
|
+
this.slideApiDeps.openUrl({
|
|
4954
5315
|
type: "swipeUpItems",
|
|
4955
5316
|
link: {
|
|
4956
5317
|
type: "json",
|
|
@@ -4986,7 +5347,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4986
5347
|
baseFields.message_id = cardId;
|
|
4987
5348
|
break;
|
|
4988
5349
|
}
|
|
4989
|
-
this.
|
|
5350
|
+
this.slideApiDeps.sendStatisticEvent(statisticWidgetEventType, {
|
|
4990
5351
|
i: cardId,
|
|
4991
5352
|
si: slideIndex,
|
|
4992
5353
|
wi: elementId,
|
|
@@ -5042,28 +5403,1251 @@ let SlideApi$1 = class SlideApi {
|
|
|
5042
5403
|
}
|
|
5043
5404
|
}
|
|
5044
5405
|
}
|
|
5045
|
-
_sdkClientVariables = {};
|
|
5046
|
-
getSdkClientVariables() {
|
|
5047
|
-
return this._sdkClientVariables;
|
|
5048
|
-
}
|
|
5049
|
-
setSdkClientVariables(variables) {
|
|
5050
|
-
this._sdkClientVariables = variables;
|
|
5051
|
-
}
|
|
5052
5406
|
static get [Symbol.for("___CTOR_ARGS___")]() { return [`{
|
|
5053
|
-
|
|
5407
|
+
slideApiDeps: ISlideApiDeps;
|
|
5054
5408
|
slideWrapper: HTMLElement;
|
|
5055
5409
|
viewport: Window;
|
|
5056
5410
|
userResizeHandler?: (data: { viewportWidth: number; viewportHeight: number; fontSize: number }) => void;
|
|
5057
5411
|
slideRatio: number;
|
|
5058
5412
|
isFullscreen: boolean;
|
|
5059
|
-
slideLoadedCb?: (data: { cardId: number; slideIndex: number; result: boolean; reason?: string }) => void;
|
|
5060
5413
|
getViewportWidth: () => number;
|
|
5061
5414
|
getViewportHeight: () => number;
|
|
5062
5415
|
overlappingActionBarHeight?: number;
|
|
5063
5416
|
separateUserAndAppPause: boolean;
|
|
5417
|
+
root: HTMLElement;
|
|
5418
|
+
nonce?: string;
|
|
5419
|
+
// refreshSizes: (slide: SlideApi) => void;
|
|
5420
|
+
index: number;
|
|
5421
|
+
getSdkClientVariables: GetSdkClientVariables;
|
|
5064
5422
|
}`]; }
|
|
5065
5423
|
};
|
|
5066
5424
|
|
|
5425
|
+
class SlideApiDepsMultiSlideMode {
|
|
5426
|
+
sdkApi;
|
|
5427
|
+
slider;
|
|
5428
|
+
constructor(sdkApi, slider) {
|
|
5429
|
+
this.sdkApi = sdkApi;
|
|
5430
|
+
this.slider = slider;
|
|
5431
|
+
}
|
|
5432
|
+
getWidgetsSharedData(cardId, widget) {
|
|
5433
|
+
return this.sdkApi.getWidgetsSharedData(cardId, widget);
|
|
5434
|
+
}
|
|
5435
|
+
showToast(text) {
|
|
5436
|
+
return this.sdkApi.showToast(text);
|
|
5437
|
+
}
|
|
5438
|
+
writeToClipboard(data) {
|
|
5439
|
+
return this.sdkApi.writeToClipboard(data);
|
|
5440
|
+
}
|
|
5441
|
+
get isExistsShare() {
|
|
5442
|
+
return this.sdkApi.isExistsShare;
|
|
5443
|
+
}
|
|
5444
|
+
share(id, config) {
|
|
5445
|
+
this.sdkApi.share(id, config);
|
|
5446
|
+
}
|
|
5447
|
+
get sdkCanSendShareComplete() {
|
|
5448
|
+
return this.sdkApi.sdkCanSendShareComplete;
|
|
5449
|
+
}
|
|
5450
|
+
shareSlideScreenshot(shareId, hideElementsSelector, shareText) {
|
|
5451
|
+
this.sdkApi.shareSlideScreenshot(shareId, hideElementsSelector, shareText);
|
|
5452
|
+
}
|
|
5453
|
+
setCardSessionValue(element, key, value) {
|
|
5454
|
+
this.sdkApi.setCardSessionValue(element, key, value);
|
|
5455
|
+
}
|
|
5456
|
+
getCardSessionValue(element, key) {
|
|
5457
|
+
return this.sdkApi.getCardSessionValue(element, key);
|
|
5458
|
+
}
|
|
5459
|
+
getCardFonts() {
|
|
5460
|
+
return this.sdkApi.getCardFonts();
|
|
5461
|
+
}
|
|
5462
|
+
disableVerticalSwipeGesture() {
|
|
5463
|
+
this.sdkApi.disableVerticalSwipeGesture();
|
|
5464
|
+
}
|
|
5465
|
+
enableVerticalSwipeGesture() {
|
|
5466
|
+
this.sdkApi.enableVerticalSwipeGesture();
|
|
5467
|
+
}
|
|
5468
|
+
disableBackpress() {
|
|
5469
|
+
this.sdkApi.disableBackpress();
|
|
5470
|
+
}
|
|
5471
|
+
enableBackpress() {
|
|
5472
|
+
this.sdkApi.enableBackpress();
|
|
5473
|
+
}
|
|
5474
|
+
closeCard(reason) {
|
|
5475
|
+
this.sdkApi.closeCard(reason);
|
|
5476
|
+
}
|
|
5477
|
+
openStory(id, index) {
|
|
5478
|
+
// TODO rewrite with Promise - for usage story loading states in Button
|
|
5479
|
+
this.sdkApi.openStory(id, index);
|
|
5480
|
+
}
|
|
5481
|
+
openGame(gameInstanceId) {
|
|
5482
|
+
// TODO rewrite with Promise - for usage game loading states in Button
|
|
5483
|
+
this.sdkApi.openGame(gameInstanceId);
|
|
5484
|
+
}
|
|
5485
|
+
openUrl(data) {
|
|
5486
|
+
this.sdkApi.openUrl(data);
|
|
5487
|
+
}
|
|
5488
|
+
get isAndroid() {
|
|
5489
|
+
return this.sdkApi.isAndroid;
|
|
5490
|
+
}
|
|
5491
|
+
get isWeb() {
|
|
5492
|
+
return this.sdkApi.isWeb;
|
|
5493
|
+
}
|
|
5494
|
+
get isIOS() {
|
|
5495
|
+
return this.sdkApi.isIOS;
|
|
5496
|
+
}
|
|
5497
|
+
get isExistsShowCardTextInput() {
|
|
5498
|
+
return this.sdkApi.isExistsShowCardTextInput;
|
|
5499
|
+
}
|
|
5500
|
+
showCardTextInput(id, data) {
|
|
5501
|
+
this.sdkApi.showCardTextInput(id, data);
|
|
5502
|
+
}
|
|
5503
|
+
vibrate(pattern) {
|
|
5504
|
+
this.sdkApi.vibrate(pattern);
|
|
5505
|
+
}
|
|
5506
|
+
sendApiRequest(url, method, params, headers, data, profilingKey) {
|
|
5507
|
+
return this.sdkApi.sendApiRequest(url, method, params, headers, data, profilingKey);
|
|
5508
|
+
}
|
|
5509
|
+
sendStatisticEvent(name, data, devPayload, forceEnableStatisticV2) {
|
|
5510
|
+
this.sdkApi.sendStatisticEvent(name, data, devPayload, forceEnableStatisticV2);
|
|
5511
|
+
}
|
|
5512
|
+
setCardLocalData(keyValue, sendToServer) {
|
|
5513
|
+
this.sdkApi.setCardLocalData(keyValue, sendToServer);
|
|
5514
|
+
}
|
|
5515
|
+
getCardLocalData() {
|
|
5516
|
+
return this.sdkApi.getCardLocalData();
|
|
5517
|
+
}
|
|
5518
|
+
getCardServerData(cardId) {
|
|
5519
|
+
return this.sdkApi.getCardServerData(cardId);
|
|
5520
|
+
}
|
|
5521
|
+
get cardAnimation() {
|
|
5522
|
+
return this.sdkApi.cardAnimation;
|
|
5523
|
+
}
|
|
5524
|
+
updateCardServerDataLocally(cardId, data) {
|
|
5525
|
+
this.sdkApi.updateCardServerDataLocally(cardId, data);
|
|
5526
|
+
}
|
|
5527
|
+
get isExistsShowNextCard() {
|
|
5528
|
+
return this.sdkApi.isExistsShowNextCard;
|
|
5529
|
+
}
|
|
5530
|
+
cardShowNext() {
|
|
5531
|
+
this.sdkApi.cardShowNext();
|
|
5532
|
+
}
|
|
5533
|
+
/** @deprecated, used only in native sdk **/
|
|
5534
|
+
cardPausedCallback(currentTime) {
|
|
5535
|
+
this.sdkApi.cardPausedCallback(currentTime);
|
|
5536
|
+
}
|
|
5537
|
+
/** @deprecated, used only in native sdk **/
|
|
5538
|
+
cardResumedCallback(currentTime) {
|
|
5539
|
+
this.sdkApi.cardResumedCallback(currentTime);
|
|
5540
|
+
}
|
|
5541
|
+
disableHorizontalSwipeGesture() {
|
|
5542
|
+
this.sdkApi.disableHorizontalSwipeGesture();
|
|
5543
|
+
}
|
|
5544
|
+
enableHorizontalSwipeGesture() {
|
|
5545
|
+
this.sdkApi.enableHorizontalSwipeGesture();
|
|
5546
|
+
}
|
|
5547
|
+
isExistsShowLayer() {
|
|
5548
|
+
return this.sdkApi.isExistsShowLayer();
|
|
5549
|
+
}
|
|
5550
|
+
showLayer(index) {
|
|
5551
|
+
this.sdkApi.showLayer(index);
|
|
5552
|
+
}
|
|
5553
|
+
/**
|
|
5554
|
+
* For single slide mode - proxy these methods via SDKApi
|
|
5555
|
+
* =================================================================================================================
|
|
5556
|
+
*/
|
|
5557
|
+
get isExistsShowCardSlide() {
|
|
5558
|
+
return true;
|
|
5559
|
+
}
|
|
5560
|
+
showCardSlide(index) {
|
|
5561
|
+
this.slider.showByIndex(index);
|
|
5562
|
+
}
|
|
5563
|
+
updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError) {
|
|
5564
|
+
this.slider.updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError);
|
|
5565
|
+
}
|
|
5566
|
+
isSdkSupportTimelineOnBeforeStart() {
|
|
5567
|
+
return true;
|
|
5568
|
+
}
|
|
5569
|
+
isSdkSupportCorrectPauseResumeLifecycle() {
|
|
5570
|
+
return true;
|
|
5571
|
+
}
|
|
5572
|
+
showNextSlide(duration) {
|
|
5573
|
+
this.slider.showNextSlide();
|
|
5574
|
+
}
|
|
5575
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`SDKApi`, `ISlider`]; }
|
|
5576
|
+
}
|
|
5577
|
+
|
|
5578
|
+
class SlideApiDepsSingleSlideMode {
|
|
5579
|
+
sdkApi;
|
|
5580
|
+
constructor(sdkApi) {
|
|
5581
|
+
this.sdkApi = sdkApi;
|
|
5582
|
+
}
|
|
5583
|
+
getWidgetsSharedData(cardId, widget) {
|
|
5584
|
+
return this.sdkApi.getWidgetsSharedData(cardId, widget);
|
|
5585
|
+
}
|
|
5586
|
+
showToast(text) {
|
|
5587
|
+
return this.sdkApi.showToast(text);
|
|
5588
|
+
}
|
|
5589
|
+
writeToClipboard(data) {
|
|
5590
|
+
return this.sdkApi.writeToClipboard(data);
|
|
5591
|
+
}
|
|
5592
|
+
get isExistsShare() {
|
|
5593
|
+
return this.sdkApi.isExistsShare;
|
|
5594
|
+
}
|
|
5595
|
+
share(id, config) {
|
|
5596
|
+
this.sdkApi.share(id, config);
|
|
5597
|
+
}
|
|
5598
|
+
get sdkCanSendShareComplete() {
|
|
5599
|
+
return this.sdkApi.sdkCanSendShareComplete;
|
|
5600
|
+
}
|
|
5601
|
+
shareSlideScreenshot(shareId, hideElementsSelector, shareText) {
|
|
5602
|
+
this.sdkApi.shareSlideScreenshot(shareId, hideElementsSelector, shareText);
|
|
5603
|
+
}
|
|
5604
|
+
setCardSessionValue(element, key, value) {
|
|
5605
|
+
this.sdkApi.setCardSessionValue(element, key, value);
|
|
5606
|
+
}
|
|
5607
|
+
getCardSessionValue(element, key) {
|
|
5608
|
+
return this.sdkApi.getCardSessionValue(element, key);
|
|
5609
|
+
}
|
|
5610
|
+
getCardFonts() {
|
|
5611
|
+
return this.sdkApi.getCardFonts();
|
|
5612
|
+
}
|
|
5613
|
+
disableVerticalSwipeGesture() {
|
|
5614
|
+
this.sdkApi.disableVerticalSwipeGesture();
|
|
5615
|
+
}
|
|
5616
|
+
enableVerticalSwipeGesture() {
|
|
5617
|
+
this.sdkApi.enableVerticalSwipeGesture();
|
|
5618
|
+
}
|
|
5619
|
+
disableBackpress() {
|
|
5620
|
+
this.sdkApi.disableBackpress();
|
|
5621
|
+
}
|
|
5622
|
+
enableBackpress() {
|
|
5623
|
+
this.sdkApi.enableBackpress();
|
|
5624
|
+
}
|
|
5625
|
+
closeCard(reason) {
|
|
5626
|
+
this.sdkApi.closeCard(reason);
|
|
5627
|
+
}
|
|
5628
|
+
openStory(id, index) {
|
|
5629
|
+
// TODO rewrite with Promise - for usage story loading states in Button
|
|
5630
|
+
this.sdkApi.openStory(id, index);
|
|
5631
|
+
}
|
|
5632
|
+
openGame(gameInstanceId) {
|
|
5633
|
+
// TODO rewrite with Promise - for usage game loading states in Button
|
|
5634
|
+
this.sdkApi.openGame(gameInstanceId);
|
|
5635
|
+
}
|
|
5636
|
+
openUrl(data) {
|
|
5637
|
+
this.sdkApi.openUrl(data);
|
|
5638
|
+
}
|
|
5639
|
+
get isAndroid() {
|
|
5640
|
+
return this.sdkApi.isAndroid;
|
|
5641
|
+
}
|
|
5642
|
+
get isWeb() {
|
|
5643
|
+
return this.sdkApi.isWeb;
|
|
5644
|
+
}
|
|
5645
|
+
get isIOS() {
|
|
5646
|
+
return this.sdkApi.isIOS;
|
|
5647
|
+
}
|
|
5648
|
+
get isExistsShowCardTextInput() {
|
|
5649
|
+
return this.sdkApi.isExistsShowCardTextInput;
|
|
5650
|
+
}
|
|
5651
|
+
showCardTextInput(id, data) {
|
|
5652
|
+
this.sdkApi.showCardTextInput(id, data);
|
|
5653
|
+
}
|
|
5654
|
+
vibrate(pattern) {
|
|
5655
|
+
this.sdkApi.vibrate(pattern);
|
|
5656
|
+
}
|
|
5657
|
+
sendApiRequest(url, method, params, headers, data, profilingKey) {
|
|
5658
|
+
return this.sdkApi.sendApiRequest(url, method, params, headers, data, profilingKey);
|
|
5659
|
+
}
|
|
5660
|
+
sendStatisticEvent(name, data, devPayload, forceEnableStatisticV2) {
|
|
5661
|
+
this.sdkApi.sendStatisticEvent(name, data, devPayload, forceEnableStatisticV2);
|
|
5662
|
+
}
|
|
5663
|
+
setCardLocalData(keyValue, sendToServer) {
|
|
5664
|
+
this.sdkApi.setCardLocalData(keyValue, sendToServer);
|
|
5665
|
+
}
|
|
5666
|
+
getCardLocalData() {
|
|
5667
|
+
return this.sdkApi.getCardLocalData();
|
|
5668
|
+
}
|
|
5669
|
+
getCardServerData(cardId) {
|
|
5670
|
+
return this.sdkApi.getCardServerData(cardId);
|
|
5671
|
+
}
|
|
5672
|
+
get cardAnimation() {
|
|
5673
|
+
return this.sdkApi.cardAnimation;
|
|
5674
|
+
}
|
|
5675
|
+
updateCardServerDataLocally(cardId, data) {
|
|
5676
|
+
this.sdkApi.updateCardServerDataLocally(cardId, data);
|
|
5677
|
+
}
|
|
5678
|
+
get isExistsShowNextCard() {
|
|
5679
|
+
return this.sdkApi.isExistsShowNextCard;
|
|
5680
|
+
}
|
|
5681
|
+
cardShowNext() {
|
|
5682
|
+
this.sdkApi.cardShowNext();
|
|
5683
|
+
}
|
|
5684
|
+
/** @deprecated, used only in native sdk **/
|
|
5685
|
+
cardPausedCallback(currentTime) {
|
|
5686
|
+
this.sdkApi.cardPausedCallback(currentTime);
|
|
5687
|
+
}
|
|
5688
|
+
/** @deprecated, used only in native sdk **/
|
|
5689
|
+
cardResumedCallback(currentTime) {
|
|
5690
|
+
this.sdkApi.cardResumedCallback(currentTime);
|
|
5691
|
+
}
|
|
5692
|
+
disableHorizontalSwipeGesture() {
|
|
5693
|
+
this.sdkApi.disableHorizontalSwipeGesture();
|
|
5694
|
+
}
|
|
5695
|
+
enableHorizontalSwipeGesture() {
|
|
5696
|
+
this.sdkApi.enableHorizontalSwipeGesture();
|
|
5697
|
+
}
|
|
5698
|
+
isExistsShowLayer() {
|
|
5699
|
+
return this.sdkApi.isExistsShowLayer();
|
|
5700
|
+
}
|
|
5701
|
+
showLayer(index) {
|
|
5702
|
+
this.sdkApi.showLayer(index);
|
|
5703
|
+
}
|
|
5704
|
+
/**
|
|
5705
|
+
* For single slide mode - proxy these methods via SDKApi
|
|
5706
|
+
*/
|
|
5707
|
+
get isExistsShowCardSlide() {
|
|
5708
|
+
return this.sdkApi.isExistsShowCardSlide;
|
|
5709
|
+
}
|
|
5710
|
+
showCardSlide(index) {
|
|
5711
|
+
this.sdkApi.showCardSlide(index);
|
|
5712
|
+
}
|
|
5713
|
+
updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError) {
|
|
5714
|
+
this.sdkApi.updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError);
|
|
5715
|
+
}
|
|
5716
|
+
isSdkSupportTimelineOnBeforeStart() {
|
|
5717
|
+
return this.sdkApi.isSdkSupportTimelineOnBeforeStart();
|
|
5718
|
+
}
|
|
5719
|
+
isSdkSupportCorrectPauseResumeLifecycle() {
|
|
5720
|
+
return this.sdkApi.isSdkSupportCorrectPauseResumeLifecycle();
|
|
5721
|
+
}
|
|
5722
|
+
showNextSlide(duration) {
|
|
5723
|
+
this.sdkApi.showNextSlide(duration);
|
|
5724
|
+
}
|
|
5725
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`SDKApi`]; }
|
|
5726
|
+
}
|
|
5727
|
+
|
|
5728
|
+
class SlideTimer {
|
|
5729
|
+
requestStartTimer;
|
|
5730
|
+
requestCancelTimer;
|
|
5731
|
+
updateCb;
|
|
5732
|
+
doneCb;
|
|
5733
|
+
constructor(requestStartTimer, requestCancelTimer, updateCb, doneCb) {
|
|
5734
|
+
this.requestStartTimer = requestStartTimer;
|
|
5735
|
+
this.requestCancelTimer = requestCancelTimer;
|
|
5736
|
+
this.updateCb = updateCb;
|
|
5737
|
+
this.doneCb = doneCb;
|
|
5738
|
+
}
|
|
5739
|
+
duration;
|
|
5740
|
+
timeLeft;
|
|
5741
|
+
_pause = true;
|
|
5742
|
+
_stop = true;
|
|
5743
|
+
_started = false;
|
|
5744
|
+
start(duration) {
|
|
5745
|
+
this.duration = duration;
|
|
5746
|
+
this.stop();
|
|
5747
|
+
this.timeLeft = this.duration;
|
|
5748
|
+
this._pause = false;
|
|
5749
|
+
this._stop = false;
|
|
5750
|
+
this._started = true;
|
|
5751
|
+
this.tick();
|
|
5752
|
+
}
|
|
5753
|
+
stop() {
|
|
5754
|
+
this._stop = true;
|
|
5755
|
+
this._started = false;
|
|
5756
|
+
if (this.timerId != null) {
|
|
5757
|
+
this.requestCancelTimer(this.timerId);
|
|
5758
|
+
this.timerId = null;
|
|
5759
|
+
}
|
|
5760
|
+
// this.updateCb(0);
|
|
5761
|
+
}
|
|
5762
|
+
pause() {
|
|
5763
|
+
this._pause = true;
|
|
5764
|
+
if (this.timerId != null) {
|
|
5765
|
+
this.requestCancelTimer(this.timerId);
|
|
5766
|
+
this.timerId = null;
|
|
5767
|
+
}
|
|
5768
|
+
}
|
|
5769
|
+
resume(duration = 0) {
|
|
5770
|
+
this._pause = false;
|
|
5771
|
+
if (!this._started) {
|
|
5772
|
+
this.start(duration);
|
|
5773
|
+
}
|
|
5774
|
+
else {
|
|
5775
|
+
this.tick();
|
|
5776
|
+
}
|
|
5777
|
+
}
|
|
5778
|
+
timerId;
|
|
5779
|
+
tick() {
|
|
5780
|
+
if (this._stop) {
|
|
5781
|
+
return;
|
|
5782
|
+
}
|
|
5783
|
+
const rafStartTime = new Date().getTime();
|
|
5784
|
+
this.timerId = this.requestStartTimer(() => {
|
|
5785
|
+
if (this._stop) {
|
|
5786
|
+
return;
|
|
5787
|
+
}
|
|
5788
|
+
const dtDiff = new Date().getTime() - rafStartTime;
|
|
5789
|
+
this.timeLeft -= dtDiff;
|
|
5790
|
+
let progress = Math.round(((this.duration - this.timeLeft) / this.duration) * 100 * 10000) / 10000;
|
|
5791
|
+
if (progress > 100) {
|
|
5792
|
+
progress = 100;
|
|
5793
|
+
}
|
|
5794
|
+
this.updateCb(progress);
|
|
5795
|
+
if (progress < 100) {
|
|
5796
|
+
if (this._pause !== true) {
|
|
5797
|
+
this.tick();
|
|
5798
|
+
}
|
|
5799
|
+
}
|
|
5800
|
+
else {
|
|
5801
|
+
this.doneCb();
|
|
5802
|
+
}
|
|
5803
|
+
});
|
|
5804
|
+
}
|
|
5805
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`(callback: () => void) => number`, `(timerId: number) => void`, `(progress: number) => void`, `() => void`]; }
|
|
5806
|
+
}
|
|
5807
|
+
|
|
5808
|
+
class Slider {
|
|
5809
|
+
config;
|
|
5810
|
+
constructor(config) {
|
|
5811
|
+
this.config = config;
|
|
5812
|
+
for (let i = 0; i < config.slides.length; ++i) {
|
|
5813
|
+
const item = {
|
|
5814
|
+
called: false,
|
|
5815
|
+
firstRenderCall: null,
|
|
5816
|
+
firstRenderCallPromise: null,
|
|
5817
|
+
};
|
|
5818
|
+
item.firstRenderCallPromise = new Promise(resolver => {
|
|
5819
|
+
item.firstRenderCall = resolver;
|
|
5820
|
+
});
|
|
5821
|
+
this.slidesFirstRenders[i] = item;
|
|
5822
|
+
}
|
|
5823
|
+
const slideWrapper = this.createSliderElement({
|
|
5824
|
+
slides: config.slides,
|
|
5825
|
+
nonce: config.nonce,
|
|
5826
|
+
slideRender: config.slideRender,
|
|
5827
|
+
});
|
|
5828
|
+
config.root.appendChild(slideWrapper);
|
|
5829
|
+
this.slideWrapperElement = slideWrapper;
|
|
5830
|
+
// cardMounted: (card: HTMLElement) => Promise<void>
|
|
5831
|
+
requestAnimationFrame(async () => {
|
|
5832
|
+
await Promise.all(this.slides.map((slide, index) => config.onSlideMounted(slide.element, index)));
|
|
5833
|
+
});
|
|
5834
|
+
}
|
|
5835
|
+
isAnimating = false;
|
|
5836
|
+
activeIndex = -1;
|
|
5837
|
+
get activeSlide() {
|
|
5838
|
+
return this.slides[this.activeIndex];
|
|
5839
|
+
}
|
|
5840
|
+
slides = [];
|
|
5841
|
+
sliderTrack = null;
|
|
5842
|
+
bulletsContainer = null;
|
|
5843
|
+
slidesFirstRenders = [];
|
|
5844
|
+
slideWrapperElement;
|
|
5845
|
+
updateBulletActiveIndex;
|
|
5846
|
+
updateTimelineProgress;
|
|
5847
|
+
createSliderElement = ({ slides, nonce, slideRender }) => {
|
|
5848
|
+
const style = document.createElement("style");
|
|
5849
|
+
if (nonce != null) {
|
|
5850
|
+
style.nonce = nonce;
|
|
5851
|
+
}
|
|
5852
|
+
const slider = document.createElement("div");
|
|
5853
|
+
slider.classList.add("cards-slider");
|
|
5854
|
+
const track = document.createElement("div");
|
|
5855
|
+
track.classList.add("cards-slider__track");
|
|
5856
|
+
this.sliderTrack = track;
|
|
5857
|
+
for (let i = 0; i < slides.length; ++i) {
|
|
5858
|
+
const slide = document.createElement("div");
|
|
5859
|
+
slide.classList.add("cards-slider__slide");
|
|
5860
|
+
slide.setAttribute("data-index", String(i));
|
|
5861
|
+
this.slides[i] = {
|
|
5862
|
+
element: slideRender(slides[i], i, this.slidesFirstRenders[i].firstRenderCallPromise),
|
|
5863
|
+
timer: new SlideTimer(cb => window.requestAnimationFrame(cb), handle => window.cancelAnimationFrame(handle), this.onSlideTimerUpdate.bind(this), this.onSlideTimerEnd.bind(this)),
|
|
5864
|
+
};
|
|
5865
|
+
slide.appendChild(this.slides[i].element);
|
|
5866
|
+
track.appendChild(slide);
|
|
5867
|
+
}
|
|
5868
|
+
const [bullets, updateBulletActiveIndex, updateTimelineProgress] = this.createBulletPoints(slides.length);
|
|
5869
|
+
this.bulletsContainer = bullets;
|
|
5870
|
+
this.updateBulletActiveIndex = updateBulletActiveIndex.bind(this);
|
|
5871
|
+
this.updateTimelineProgress = updateTimelineProgress.bind(this);
|
|
5872
|
+
slider.appendChild(track);
|
|
5873
|
+
slider.appendChild(bullets);
|
|
5874
|
+
slider.appendChild(style);
|
|
5875
|
+
return slider;
|
|
5876
|
+
};
|
|
5877
|
+
createBulletPoints(count) {
|
|
5878
|
+
const bullets = document.createElement("div");
|
|
5879
|
+
bullets.classList.toggle("cards-slider__bullets");
|
|
5880
|
+
for (let i = 0; i < count; ++i) {
|
|
5881
|
+
const bullet = document.createElement("div");
|
|
5882
|
+
bullet.classList.add("cards-slider__bullet");
|
|
5883
|
+
bullet.setAttribute("data-index", String(i));
|
|
5884
|
+
bullet.onclick = (e) => {
|
|
5885
|
+
e.stopPropagation();
|
|
5886
|
+
e.preventDefault();
|
|
5887
|
+
const bullet = e.target;
|
|
5888
|
+
if (bullet != null) {
|
|
5889
|
+
const index = bullet.dataset.index;
|
|
5890
|
+
if (index != null) {
|
|
5891
|
+
this.showByIndex(parseInt(index));
|
|
5892
|
+
}
|
|
5893
|
+
}
|
|
5894
|
+
};
|
|
5895
|
+
const bulletFill = document.createElement("div");
|
|
5896
|
+
bulletFill.classList.add("cards-slider__bullet-fill");
|
|
5897
|
+
bullet.append(bulletFill);
|
|
5898
|
+
bullets.appendChild(bullet);
|
|
5899
|
+
}
|
|
5900
|
+
const onUpdateActiveIndex = (activeIndex) => {
|
|
5901
|
+
if (activeIndex >= 0 && activeIndex < count) {
|
|
5902
|
+
for (const bullet of bullets.querySelectorAll(".cards-slider__bullet--active")) {
|
|
5903
|
+
bullet.classList.toggle("cards-slider__bullet--active");
|
|
5904
|
+
}
|
|
5905
|
+
bullets.querySelector(`.cards-slider__bullet[data-index="${activeIndex}"]`)?.classList.toggle("cards-slider__bullet--active");
|
|
5906
|
+
}
|
|
5907
|
+
};
|
|
5908
|
+
const onUpdateTimelineProgress = (index, progress) => {
|
|
5909
|
+
if (index >= 0 && index < count) {
|
|
5910
|
+
const bullet = bullets.querySelector(`.cards-slider__bullet:nth-child(${index + 1}) .cards-slider__bullet-fill`);
|
|
5911
|
+
if (bullet != null) {
|
|
5912
|
+
// todo RTL
|
|
5913
|
+
//need (in css) right: 100% instead of left -100%;
|
|
5914
|
+
// todo remove progress after slide changed?
|
|
5915
|
+
bullet.style.setProperty("transform", `translateX(${progress}%)`);
|
|
5916
|
+
// transform: `translateZ(0) translateX(${
|
|
5917
|
+
// index < this.$props.index
|
|
5918
|
+
// ? "100%"
|
|
5919
|
+
// : index === this.$props.index
|
|
5920
|
+
// ? `${this.$props.timePercent}%`
|
|
5921
|
+
// : "0%"
|
|
5922
|
+
// })`,
|
|
5923
|
+
}
|
|
5924
|
+
}
|
|
5925
|
+
};
|
|
5926
|
+
return [bullets, onUpdateActiveIndex, onUpdateTimelineProgress];
|
|
5927
|
+
}
|
|
5928
|
+
async showByIndex(newIndex) {
|
|
5929
|
+
const prevIndex = this.activeIndex;
|
|
5930
|
+
if (this.isAnimating)
|
|
5931
|
+
return prevIndex;
|
|
5932
|
+
if (prevIndex !== -1) {
|
|
5933
|
+
// skip for slider start
|
|
5934
|
+
this.config.onSlideLeft(this.slides[prevIndex].element, prevIndex);
|
|
5935
|
+
this.config.onSlideStop();
|
|
5936
|
+
}
|
|
5937
|
+
const { index, loadingError } = await this.initAndRenderSlide(newIndex);
|
|
5938
|
+
if (loadingError) {
|
|
5939
|
+
// todo via updateTimeline ????
|
|
5940
|
+
this.config.onSlideLoadingError(index, loadingError);
|
|
5941
|
+
}
|
|
5942
|
+
await this.slideTo(index);
|
|
5943
|
+
if (!loadingError) {
|
|
5944
|
+
this.onShowSlide(index);
|
|
5945
|
+
}
|
|
5946
|
+
return newIndex;
|
|
5947
|
+
}
|
|
5948
|
+
async showNextSlide() {
|
|
5949
|
+
const prevIndex = this.activeIndex;
|
|
5950
|
+
if (this.isAnimating)
|
|
5951
|
+
return prevIndex;
|
|
5952
|
+
const newIndex = prevIndex + 1;
|
|
5953
|
+
if (newIndex < 0 || newIndex >= this.slides.length) {
|
|
5954
|
+
return null;
|
|
5955
|
+
}
|
|
5956
|
+
if (prevIndex !== -1) {
|
|
5957
|
+
// skip for slider start
|
|
5958
|
+
this.config.onSlideLeft(this.slides[prevIndex].element, prevIndex);
|
|
5959
|
+
this.config.onSlideStop();
|
|
5960
|
+
}
|
|
5961
|
+
const { index, loadingError } = await this.initAndRenderSlide(newIndex);
|
|
5962
|
+
if (loadingError) {
|
|
5963
|
+
// todo via updateTimeline ????
|
|
5964
|
+
this.config.onSlideLoadingError(index, loadingError);
|
|
5965
|
+
}
|
|
5966
|
+
await this.slideTo(index);
|
|
5967
|
+
if (!loadingError) {
|
|
5968
|
+
this.onShowSlide(index);
|
|
5969
|
+
}
|
|
5970
|
+
return newIndex;
|
|
5971
|
+
}
|
|
5972
|
+
async initAndRenderSlide(index) {
|
|
5973
|
+
this.config.onBeforeLoadSlide(index);
|
|
5974
|
+
let showSlidePromise;
|
|
5975
|
+
if (!this.slidesFirstRenders[index].called) {
|
|
5976
|
+
// first render call
|
|
5977
|
+
this.slidesFirstRenders[index].called = true;
|
|
5978
|
+
showSlidePromise = new Promise(resolve => {
|
|
5979
|
+
this.slidesFirstRenders[index].firstRenderCall(resolve);
|
|
5980
|
+
}).then(_ => _);
|
|
5981
|
+
}
|
|
5982
|
+
else {
|
|
5983
|
+
showSlidePromise = this.config.onBeforeShowSlide(this.slides[index].element, index);
|
|
5984
|
+
}
|
|
5985
|
+
try {
|
|
5986
|
+
const { moveToIndex } = await showSlidePromise;
|
|
5987
|
+
if (moveToIndex !== index) {
|
|
5988
|
+
index = moveToIndex;
|
|
5989
|
+
// jump to necessary slide (from WidgetQuest for instance)
|
|
5990
|
+
return this.initAndRenderSlide(index);
|
|
5991
|
+
}
|
|
5992
|
+
else {
|
|
5993
|
+
return { index, loadingError: undefined };
|
|
5994
|
+
}
|
|
5995
|
+
}
|
|
5996
|
+
catch (loadingError) {
|
|
5997
|
+
// catch loading error
|
|
5998
|
+
// this.config.onSlideLoadingError(index, e as string);
|
|
5999
|
+
console.error(loadingError);
|
|
6000
|
+
return { index, loadingError: loadingError };
|
|
6001
|
+
}
|
|
6002
|
+
}
|
|
6003
|
+
onShowSlide(index) {
|
|
6004
|
+
this.updateBulletActiveIndex(index);
|
|
6005
|
+
this.config.onShowSlide(this.slides[index].element, index);
|
|
6006
|
+
this.config.onSlideStart();
|
|
6007
|
+
}
|
|
6008
|
+
onUpdateSizeMetrics(metrics) {
|
|
6009
|
+
// this.slideTo(this.activeIndex, 0);
|
|
6010
|
+
}
|
|
6011
|
+
getSlideOffset(index) {
|
|
6012
|
+
if (!this.slides.length)
|
|
6013
|
+
return 0;
|
|
6014
|
+
const k = this.config.getLayoutDirection() === "ltr" ? -1 : 1;
|
|
6015
|
+
const cardWidth = this.slides[0].element.clientWidth;
|
|
6016
|
+
return k * index * cardWidth;
|
|
6017
|
+
}
|
|
6018
|
+
async slideTo(index, speed = 300) {
|
|
6019
|
+
if (index < 0 || index > this.slides.length - 1 || this.isAnimating)
|
|
6020
|
+
return;
|
|
6021
|
+
const cardOffset = this.getSlideOffset(index);
|
|
6022
|
+
await this.translateTo(cardOffset, speed);
|
|
6023
|
+
this.activeIndex = index;
|
|
6024
|
+
}
|
|
6025
|
+
setTranslate(value) {
|
|
6026
|
+
this.sliderTrack?.style.setProperty("transform", `translateX(${value}px)`);
|
|
6027
|
+
}
|
|
6028
|
+
setTransition(duration = 300) {
|
|
6029
|
+
this.sliderTrack?.style.setProperty("transition", `transform ${duration}ms`);
|
|
6030
|
+
}
|
|
6031
|
+
async translateTo(translate, speed) {
|
|
6032
|
+
if (this.isAnimating)
|
|
6033
|
+
return;
|
|
6034
|
+
this.setTransition(speed);
|
|
6035
|
+
this.setTranslate(translate);
|
|
6036
|
+
if (speed > 0) {
|
|
6037
|
+
this.isAnimating = true;
|
|
6038
|
+
await this.waitTransitionEnd();
|
|
6039
|
+
this.isAnimating = false;
|
|
6040
|
+
}
|
|
6041
|
+
}
|
|
6042
|
+
waitTransitionEnd() {
|
|
6043
|
+
const sliderTrack = this.sliderTrack;
|
|
6044
|
+
if (!sliderTrack)
|
|
6045
|
+
return Promise.resolve();
|
|
6046
|
+
return new Promise(resolve => {
|
|
6047
|
+
const handler = (e) => {
|
|
6048
|
+
if (e.propertyName === "transform") {
|
|
6049
|
+
sliderTrack.style.transitionDuration = "0ms";
|
|
6050
|
+
resolve();
|
|
6051
|
+
}
|
|
6052
|
+
};
|
|
6053
|
+
sliderTrack.addEventListener("transitionend", handler, { once: true });
|
|
6054
|
+
});
|
|
6055
|
+
}
|
|
6056
|
+
destroy() {
|
|
6057
|
+
this.activeSlide?.timer.stop();
|
|
6058
|
+
if (this.slideWrapperElement != null && this.config.root != null) {
|
|
6059
|
+
this.config.root.removeChild(this.slideWrapperElement);
|
|
6060
|
+
}
|
|
6061
|
+
}
|
|
6062
|
+
updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError) {
|
|
6063
|
+
switch (action) {
|
|
6064
|
+
case "before_start" /* TIMELINE_ACTION.BEFORE_START */: {
|
|
6065
|
+
// switch timeline to active slide and wait for start (wait VOD loading)
|
|
6066
|
+
console.log("TIMELINE_ACTION.BEFORE_START", { activeSlide: this.activeSlide, duration });
|
|
6067
|
+
break;
|
|
6068
|
+
}
|
|
6069
|
+
case "start" /* TIMELINE_ACTION.START */: {
|
|
6070
|
+
this.config.onSlideDataResume();
|
|
6071
|
+
// also start after data waiting or pause
|
|
6072
|
+
// window.setTimeout(() => {
|
|
6073
|
+
// this.config.onSlideStop();
|
|
6074
|
+
// this.config.onSlideTimerEnd();
|
|
6075
|
+
// }, 10000);
|
|
6076
|
+
// destroy on IAM closing
|
|
6077
|
+
console.log("TIMELINE_ACTION.START", { activeSlide: this.activeSlide, index: this.activeIndex, duration });
|
|
6078
|
+
this.activeSlide?.timer.resume(duration);
|
|
6079
|
+
break;
|
|
6080
|
+
}
|
|
6081
|
+
case "pause" /* TIMELINE_ACTION.PAUSE */: {
|
|
6082
|
+
if (showLoader) {
|
|
6083
|
+
this.config.onSlideDataWaiting();
|
|
6084
|
+
}
|
|
6085
|
+
this.activeSlide?.timer.pause();
|
|
6086
|
+
console.log("TIMELINE_ACTION.PAUSE", { activeSlide: this.activeSlide, duration });
|
|
6087
|
+
break;
|
|
6088
|
+
}
|
|
6089
|
+
case "stop" /* TIMELINE_ACTION.STOP */: {
|
|
6090
|
+
// loading error
|
|
6091
|
+
if (showError) {
|
|
6092
|
+
this.config.onSlideDataError();
|
|
6093
|
+
}
|
|
6094
|
+
this.activeSlide?.timer.stop();
|
|
6095
|
+
// todo нужен STOP когда вручную переключаем слайд на другой
|
|
6096
|
+
console.log("TIMELINE_ACTION.STOP", { activeSlide: this.activeSlide, duration });
|
|
6097
|
+
break;
|
|
6098
|
+
}
|
|
6099
|
+
}
|
|
6100
|
+
}
|
|
6101
|
+
onSlideTimerUpdate(progress) {
|
|
6102
|
+
this.updateTimelineProgress(this.activeIndex, progress);
|
|
6103
|
+
}
|
|
6104
|
+
onSlideTimerEnd() {
|
|
6105
|
+
this.config.onSlideStop();
|
|
6106
|
+
this.config.onSlideTimerEnd();
|
|
6107
|
+
}
|
|
6108
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`{
|
|
6109
|
+
slides: Array<T>;
|
|
6110
|
+
root: HTMLElement;
|
|
6111
|
+
// isFullscreen: boolean;
|
|
6112
|
+
nonce?: string;
|
|
6113
|
+
// viewport: Window;
|
|
6114
|
+
// userResizeHandler?: (data: { viewportWidth: number; viewportHeight: number; fontSize: number }) => void;
|
|
6115
|
+
// VODPlayer?: typeof VODPlayer;
|
|
6116
|
+
// overlappingActionBarHeight?: number;
|
|
6117
|
+
slideRender: SlideRender<T>;
|
|
6118
|
+
onSlideMounted: OnSlideMounted;
|
|
6119
|
+
onBeforeShowSlide: OnBeforeShowSlide;
|
|
6120
|
+
onBeforeLoadSlide: OnBeforeLoadSlide;
|
|
6121
|
+
onSlideLoadingError: OnSlideLoadingError;
|
|
6122
|
+
onShowSlide: OnShowSlide;
|
|
6123
|
+
onSlideLeft: OnSlideLeft;
|
|
6124
|
+
getLayoutDirection: GetLayoutDirection;
|
|
6125
|
+
|
|
6126
|
+
onSlideTimerEnd: OnSlideTimerEnd;
|
|
6127
|
+
onSlideStart: OnSlideStart;
|
|
6128
|
+
onSlideStop: OnSlideStop;
|
|
6129
|
+
onSlideDataWaiting: OnSlideDataWaiting;
|
|
6130
|
+
onSlideDataResume: OnSlideDataResume;
|
|
6131
|
+
onSlideDataError: OnSlideDataError;
|
|
6132
|
+
}`]; }
|
|
6133
|
+
}
|
|
6134
|
+
|
|
6135
|
+
class CardApi {
|
|
6136
|
+
config;
|
|
6137
|
+
get layoutDirection() {
|
|
6138
|
+
return this.activeSlide.layoutDirection;
|
|
6139
|
+
}
|
|
6140
|
+
static renderedBoxClassName = "narrative-slide-box-rendered";
|
|
6141
|
+
static prerenderBoxClassName = "narrative-slide-box-prerender";
|
|
6142
|
+
_singleCardSlideWrapper;
|
|
6143
|
+
_viewport;
|
|
6144
|
+
_getViewportWidth;
|
|
6145
|
+
_getViewportHeight;
|
|
6146
|
+
_overlappingActionBarHeight;
|
|
6147
|
+
_separateUserAndAppPause;
|
|
6148
|
+
_useSdkCacheForMultislideMode;
|
|
6149
|
+
sdkApi;
|
|
6150
|
+
activeSlide = null;
|
|
6151
|
+
slides = [];
|
|
6152
|
+
slidesMode = 0 /* SLIDES_MODE.SINGLE */;
|
|
6153
|
+
sizeMetrics = {
|
|
6154
|
+
fontSize: "0px",
|
|
6155
|
+
isFullscreen: false,
|
|
6156
|
+
slideOffsetMargin: "0px",
|
|
6157
|
+
xOffset: "0px",
|
|
6158
|
+
yOffset: "0px",
|
|
6159
|
+
};
|
|
6160
|
+
constructor(config) {
|
|
6161
|
+
this.config = config;
|
|
6162
|
+
this.sdkApi = config.sdkApi;
|
|
6163
|
+
this._singleCardSlideWrapper = config.slideWrapper;
|
|
6164
|
+
this._viewport = config.viewport;
|
|
6165
|
+
this._getViewportWidth = config.getViewportWidth;
|
|
6166
|
+
this._getViewportHeight = config.getViewportHeight;
|
|
6167
|
+
this._overlappingActionBarHeight = config.overlappingActionBarHeight ?? 0;
|
|
6168
|
+
this._separateUserAndAppPause = config.separateUserAndAppPause;
|
|
6169
|
+
this._useSdkCacheForMultislideMode = config.useSdkCacheForMultislideMode;
|
|
6170
|
+
this.refreshSizes = proxy(this.refreshSizes, this);
|
|
6171
|
+
this.getSdkClientVariables = proxy(this.getSdkClientVariables, this);
|
|
6172
|
+
this.refreshSizes();
|
|
6173
|
+
// todo - возможность не создавать slideApi в ctor (это не нужно для multislide mode)
|
|
6174
|
+
// но тогда все методы должны обходить случай когда activeSlide undefined
|
|
6175
|
+
this.activeSlide = new SlideApi$1({
|
|
6176
|
+
slideApiDeps: new SlideApiDepsSingleSlideMode(this.config.sdkApi),
|
|
6177
|
+
slideWrapper: this.config.slideWrapper,
|
|
6178
|
+
viewport: this.config.viewport,
|
|
6179
|
+
userResizeHandler: this.config.userResizeHandler,
|
|
6180
|
+
slideRatio: this.config.slideRatio,
|
|
6181
|
+
isFullscreen: this.config.isFullscreen,
|
|
6182
|
+
getViewportWidth: this.config.getViewportWidth,
|
|
6183
|
+
getViewportHeight: this.config.getViewportHeight,
|
|
6184
|
+
overlappingActionBarHeight: this.config.overlappingActionBarHeight,
|
|
6185
|
+
separateUserAndAppPause: this.config.separateUserAndAppPause,
|
|
6186
|
+
root: this.config.root,
|
|
6187
|
+
index: 0,
|
|
6188
|
+
getSdkClientVariables: this.getSdkClientVariables,
|
|
6189
|
+
});
|
|
6190
|
+
this.activeSlide.onUpdateSizeMetrics(this.sizeMetrics);
|
|
6191
|
+
if (SlideApi$1.checkPreloadedInLayoutSlide()) {
|
|
6192
|
+
this.activeSlide.initPreloadedInLayoutSlide(this.config.slideLoadedCb);
|
|
6193
|
+
}
|
|
6194
|
+
this.initListeners();
|
|
6195
|
+
}
|
|
6196
|
+
get state() {
|
|
6197
|
+
// TODO remove usage from web-sdk
|
|
6198
|
+
return this.activeSlide.state;
|
|
6199
|
+
}
|
|
6200
|
+
async destroy() {
|
|
6201
|
+
await this.activeSlide.destroy();
|
|
6202
|
+
await Promise.all(this.slides.map(({ slide }) => {
|
|
6203
|
+
if (slide !== this.activeSlide) {
|
|
6204
|
+
return slide?.destroy();
|
|
6205
|
+
}
|
|
6206
|
+
}));
|
|
6207
|
+
this.destroyListeners();
|
|
6208
|
+
}
|
|
6209
|
+
initListeners() {
|
|
6210
|
+
// @ts-ignore
|
|
6211
|
+
this._viewport.addEventListener("resize", this.refreshSizes);
|
|
6212
|
+
}
|
|
6213
|
+
destroyListeners() {
|
|
6214
|
+
// @ts-ignore
|
|
6215
|
+
this._viewport.removeEventListener("resize", this.refreshSizes);
|
|
6216
|
+
// todo call via activeSlide.refreshSizes
|
|
6217
|
+
}
|
|
6218
|
+
_savedViewportWidth = null;
|
|
6219
|
+
_savedViewportHeight = null;
|
|
6220
|
+
refreshSizes() {
|
|
6221
|
+
const viewportWidth = this._getViewportWidth();
|
|
6222
|
+
const viewportHeight = this._getViewportHeight();
|
|
6223
|
+
if (this._savedViewportWidth === viewportWidth && this._savedViewportHeight === viewportHeight) {
|
|
6224
|
+
return;
|
|
6225
|
+
}
|
|
6226
|
+
this._savedViewportWidth = viewportWidth;
|
|
6227
|
+
this._savedViewportHeight = viewportHeight;
|
|
6228
|
+
const viewportRatio = viewportWidth / viewportHeight;
|
|
6229
|
+
let slideWidth = 0;
|
|
6230
|
+
let slideHeight = 0;
|
|
6231
|
+
// _ratio = 310 / 480,
|
|
6232
|
+
const _ratio = this.config.slideRatio;
|
|
6233
|
+
let _isFullscreen = this.config.isFullscreen;
|
|
6234
|
+
let offset = 0;
|
|
6235
|
+
let xOffset = "0px";
|
|
6236
|
+
// for elements with bottom anchor (absolute position)
|
|
6237
|
+
let yOffset = "0px";
|
|
6238
|
+
// todo - mobile only (or isIos or isAndroid)
|
|
6239
|
+
if (this.sdkApi.isAndroid || this.sdkApi.isIOS) {
|
|
6240
|
+
if (viewportRatio > _ratio) {
|
|
6241
|
+
// disable _isFullscreen if viewport small
|
|
6242
|
+
_isFullscreen = false;
|
|
6243
|
+
}
|
|
6244
|
+
}
|
|
6245
|
+
let slideOffsetMargin = "";
|
|
6246
|
+
if (_isFullscreen) {
|
|
6247
|
+
// более квадратное чем надо (desktop)
|
|
6248
|
+
if (viewportRatio > _ratio) {
|
|
6249
|
+
// fit by height
|
|
6250
|
+
slideHeight = viewportHeight;
|
|
6251
|
+
slideWidth = Math.ceil(slideHeight * _ratio);
|
|
6252
|
+
offset = Math.ceil(slideWidth - viewportWidth) / 2;
|
|
6253
|
+
slideOffsetMargin = "0 " + -offset + "px"; // -8.5
|
|
6254
|
+
xOffset = offset + "px";
|
|
6255
|
+
}
|
|
6256
|
+
else {
|
|
6257
|
+
// fit by width, top and bottom - to offscreen or fill with bg image
|
|
6258
|
+
slideWidth = viewportWidth;
|
|
6259
|
+
slideHeight = Math.ceil(viewportWidth / _ratio);
|
|
6260
|
+
offset = Math.ceil(slideHeight - viewportHeight) / 2;
|
|
6261
|
+
slideOffsetMargin = -1 * offset + "px" + " 0 ";
|
|
6262
|
+
// offset from viewport bottom to StoryBottom plus safe area offset bottom
|
|
6263
|
+
yOffset = `calc(${offset + this._overlappingActionBarHeight}px + env(safe-area-inset-bottom))`;
|
|
6264
|
+
// detect safe area offset
|
|
6265
|
+
}
|
|
6266
|
+
}
|
|
6267
|
+
else {
|
|
6268
|
+
// более квадратное чем надо
|
|
6269
|
+
if (viewportRatio > _ratio) {
|
|
6270
|
+
// fit by width, top and bottom - to offscreen
|
|
6271
|
+
slideWidth = viewportWidth;
|
|
6272
|
+
slideHeight = Math.ceil(viewportWidth / _ratio);
|
|
6273
|
+
offset = Math.ceil(slideHeight - viewportHeight) / 2;
|
|
6274
|
+
slideOffsetMargin = -offset + "px" + " 0 ";
|
|
6275
|
+
yOffset = offset + this._overlappingActionBarHeight + "px";
|
|
6276
|
+
}
|
|
6277
|
+
else {
|
|
6278
|
+
// вьюпорт более вытянутый чем надо
|
|
6279
|
+
// fit by height, sides - to offscreen
|
|
6280
|
+
slideHeight = viewportHeight;
|
|
6281
|
+
slideWidth = Math.ceil(slideHeight * _ratio);
|
|
6282
|
+
offset = Math.ceil(slideWidth - viewportWidth) / 2;
|
|
6283
|
+
slideOffsetMargin = "0 " + -offset + "px"; // -8.5
|
|
6284
|
+
xOffset = offset + "px";
|
|
6285
|
+
}
|
|
6286
|
+
}
|
|
6287
|
+
const fontSizeNumber = slideWidth / 20;
|
|
6288
|
+
const fontSize = `${fontSizeNumber}px`;
|
|
6289
|
+
const sizeMetrics = { fontSize, xOffset, yOffset, isFullscreen: _isFullscreen, slideOffsetMargin };
|
|
6290
|
+
this.sizeMetrics = sizeMetrics;
|
|
6291
|
+
this.activeSlide?.onUpdateSizeMetrics(sizeMetrics);
|
|
6292
|
+
this.slides.forEach(({ slide }) => {
|
|
6293
|
+
if (slide !== this.activeSlide) {
|
|
6294
|
+
slide?.onUpdateSizeMetrics(sizeMetrics);
|
|
6295
|
+
}
|
|
6296
|
+
});
|
|
6297
|
+
this.slider?.onUpdateSizeMetrics(sizeMetrics);
|
|
6298
|
+
if (this.config.userResizeHandler != null) {
|
|
6299
|
+
this.config.userResizeHandler({ viewportWidth, viewportHeight, fontSize: fontSizeNumber });
|
|
6300
|
+
}
|
|
6301
|
+
}
|
|
6302
|
+
async showSlide(html) {
|
|
6303
|
+
this.slidesMode = 0 /* SLIDES_MODE.SINGLE */;
|
|
6304
|
+
if (this.activeSlide == null) {
|
|
6305
|
+
this.activeSlide = new SlideApi$1({
|
|
6306
|
+
slideApiDeps: new SlideApiDepsSingleSlideMode(this.config.sdkApi),
|
|
6307
|
+
slideWrapper: this.config.slideWrapper,
|
|
6308
|
+
viewport: this.config.viewport,
|
|
6309
|
+
userResizeHandler: this.config.userResizeHandler,
|
|
6310
|
+
slideRatio: this.config.slideRatio,
|
|
6311
|
+
isFullscreen: this.config.isFullscreen,
|
|
6312
|
+
getViewportWidth: this.config.getViewportWidth,
|
|
6313
|
+
getViewportHeight: this.config.getViewportHeight,
|
|
6314
|
+
overlappingActionBarHeight: this.config.overlappingActionBarHeight,
|
|
6315
|
+
separateUserAndAppPause: this.config.separateUserAndAppPause,
|
|
6316
|
+
root: this.config.root,
|
|
6317
|
+
// refreshSizes: this.refreshSizes,
|
|
6318
|
+
index: 0,
|
|
6319
|
+
getSdkClientVariables: this.getSdkClientVariables,
|
|
6320
|
+
});
|
|
6321
|
+
this.activeSlide.onUpdateSizeMetrics(this.sizeMetrics);
|
|
6322
|
+
}
|
|
6323
|
+
return this.activeSlide.showSlide(html);
|
|
6324
|
+
}
|
|
6325
|
+
slider = null;
|
|
6326
|
+
async showSlides(slides, cardAppearance, index = 0) {
|
|
6327
|
+
this.slidesMode = 1 /* SLIDES_MODE.MULTIPLE */;
|
|
6328
|
+
this.sdkApi.onCardLoadingStateChange(0 /* CARD_LOADING_STATE.LOADING */);
|
|
6329
|
+
slides.forEach((content, index) => {
|
|
6330
|
+
if (this.slides[index] == null) {
|
|
6331
|
+
const item = { content, resourcesReadyPromise: null };
|
|
6332
|
+
if (this._useSdkCacheForMultislideMode) {
|
|
6333
|
+
item.resourcesReadyPromise = new Promise((resolve, reject) => {
|
|
6334
|
+
item.resourcesReadyPromisesResolver = { resolve, reject };
|
|
6335
|
+
});
|
|
6336
|
+
}
|
|
6337
|
+
else {
|
|
6338
|
+
item.resourcesReadyPromise = Promise.resolve();
|
|
6339
|
+
}
|
|
6340
|
+
this.slides[index] = item;
|
|
6341
|
+
}
|
|
6342
|
+
else {
|
|
6343
|
+
// for case when sdk call setSlideInCacheStatus before showSlides and for slideReloading (after loading error)
|
|
6344
|
+
this.slides[index].content = content;
|
|
6345
|
+
if (this.slides[index].resourcesReadyPromise == null) {
|
|
6346
|
+
if (this._useSdkCacheForMultislideMode) {
|
|
6347
|
+
this.slides[index].resourcesReadyPromise = new Promise((resolve, reject) => {
|
|
6348
|
+
this.slides[index].resourcesReadyPromisesResolver = { resolve, reject };
|
|
6349
|
+
});
|
|
6350
|
+
}
|
|
6351
|
+
else {
|
|
6352
|
+
this.slides[index].resourcesReadyPromise = Promise.resolve();
|
|
6353
|
+
}
|
|
6354
|
+
}
|
|
6355
|
+
}
|
|
6356
|
+
});
|
|
6357
|
+
const onBeforeShowSlide = (slideElement, index) => {
|
|
6358
|
+
if (this.slides[index].slide == null) {
|
|
6359
|
+
const slideApi = new SlideApi$1({
|
|
6360
|
+
slideApiDeps: new SlideApiDepsMultiSlideMode(this.config.sdkApi, this.slider),
|
|
6361
|
+
slideWrapper: slideElement,
|
|
6362
|
+
viewport: this.config.viewport,
|
|
6363
|
+
userResizeHandler: this.config.userResizeHandler,
|
|
6364
|
+
slideRatio: this.config.slideRatio,
|
|
6365
|
+
isFullscreen: this.config.isFullscreen,
|
|
6366
|
+
getViewportWidth: this.config.getViewportWidth,
|
|
6367
|
+
getViewportHeight: this.config.getViewportHeight,
|
|
6368
|
+
overlappingActionBarHeight: this.config.overlappingActionBarHeight,
|
|
6369
|
+
separateUserAndAppPause: this.config.separateUserAndAppPause,
|
|
6370
|
+
root: this.config.root,
|
|
6371
|
+
index,
|
|
6372
|
+
getSdkClientVariables: this.getSdkClientVariables,
|
|
6373
|
+
});
|
|
6374
|
+
slideApi.onUpdateSizeMetrics(this.sizeMetrics);
|
|
6375
|
+
this.slides[index].slide = slideApi;
|
|
6376
|
+
// TODO для виджета квест нужно при каждом показе слайда инициализировать виджет???
|
|
6377
|
+
// пока вызов убран из за того что init жестко завязан на single slide mode
|
|
6378
|
+
this.activeSlide = this.slides[index].slide;
|
|
6379
|
+
return this.slides[index].slide.showSlide().then(_ => ({ moveToIndex: index }));
|
|
6380
|
+
}
|
|
6381
|
+
this.activeSlide = this.slides[index].slide;
|
|
6382
|
+
// TODO handle moveToIndex
|
|
6383
|
+
// return resolve or reject with reason
|
|
6384
|
+
// TODO для виджета квест нужно при каждом показе слайда инициализировать виджет???
|
|
6385
|
+
// пока вызов убран из за того что init жестко завязан на single slide mode
|
|
6386
|
+
// return this.slides[index].slide.showSlide().then(_ => ({ moveToIndex: index }));
|
|
6387
|
+
return Promise.resolve({ moveToIndex: index });
|
|
6388
|
+
// вызываем здесь cardLoadingState - loading
|
|
6389
|
+
// новый cb - onSlideShowError - там вызов cardLoadingState error - через cardLoadingStateManager
|
|
6390
|
+
// в onShowSlide- cardLoadingState load done
|
|
6391
|
+
// внутри слайдера - обрабатываем moveToIndex
|
|
6392
|
+
};
|
|
6393
|
+
const onBeforeLoadSlide = index => {
|
|
6394
|
+
this.sdkApi.onCardLoadingStateChange(0 /* CARD_LOADING_STATE.LOADING */);
|
|
6395
|
+
};
|
|
6396
|
+
const onSlideLoadingError = (index, reason) => {
|
|
6397
|
+
this.sdkApi.onCardLoadingStateChange(2 /* CARD_LOADING_STATE.LOADING_ERROR */, reason);
|
|
6398
|
+
};
|
|
6399
|
+
const onShowSlide = (slide, index) => {
|
|
6400
|
+
this.sdkApi.onCardLoadingStateChange(1 /* CARD_LOADING_STATE.LOADED */);
|
|
6401
|
+
this.sdkApi.emitEvent("showSlide", { cardId: this.slides[index]?.slide?.slide.cardId ?? 0, index });
|
|
6402
|
+
// if (index === 0) {
|
|
6403
|
+
// this.activeSlide = slideApi;
|
|
6404
|
+
// }
|
|
6405
|
+
// const { result, cardId, slideIndex, reason } = await slideApi.showSlide();
|
|
6406
|
+
// if (index === 0) {
|
|
6407
|
+
// if (result) {
|
|
6408
|
+
// this.sdkApi.onCardLoadingStateChange(CARD_LOADING_STATE.LOADED);
|
|
6409
|
+
// this.sdkApi.emitEvent("showSlide", { cardId: this.activeSlide.slide.cardId, index });
|
|
6410
|
+
// } else {
|
|
6411
|
+
// this.sdkApi.onCardLoadingStateChange(CARD_LOADING_STATE.LOADING, reason);
|
|
6412
|
+
// }
|
|
6413
|
+
// }
|
|
6414
|
+
//
|
|
6415
|
+
// onShowActiveCardResolver({ cardId, slideIndex });
|
|
6416
|
+
};
|
|
6417
|
+
const onSlideLeft = (slide, index) => {
|
|
6418
|
+
this.sdkApi.emitEvent("slideLeft", { cardId: this.slides[index]?.slide?.slide.cardId ?? 0, index });
|
|
6419
|
+
};
|
|
6420
|
+
const slideRender = ({ content, canMediaMount }, index, onBeforeShowSlideDuringMounting) => {
|
|
6421
|
+
const slideWrapper = document.createElement("div");
|
|
6422
|
+
slideWrapper.classList.add("narrative-slide-wrapper");
|
|
6423
|
+
slideWrapper.classList.add("stories-viewer");
|
|
6424
|
+
const slideOffset = document.createElement("div");
|
|
6425
|
+
slideOffset.classList.add("narrative-slide-offset");
|
|
6426
|
+
const slideBoxPrerender = document.createElement("div");
|
|
6427
|
+
slideBoxPrerender.classList.add("narrative-slide-box");
|
|
6428
|
+
slideBoxPrerender.classList.add("narrative-slide-box-prerender");
|
|
6429
|
+
const slideBoxRendered = document.createElement("div");
|
|
6430
|
+
slideBoxRendered.classList.add("narrative-slide-box");
|
|
6431
|
+
slideBoxRendered.classList.add("narrative-slide-box-rendered");
|
|
6432
|
+
const style = document.createElement("style");
|
|
6433
|
+
if (this.config.nonce != null) {
|
|
6434
|
+
style.nonce = this.config.nonce;
|
|
6435
|
+
}
|
|
6436
|
+
const paddingTop = `${String(100 / this.config.slideRatio)}%`;
|
|
6437
|
+
// .narrative-slide-box {
|
|
6438
|
+
// padding: <?= $slideRatioPadding ?> 0 0 0;
|
|
6439
|
+
// }
|
|
6440
|
+
// style.sheet?.insertRule(`.narrative-slide-box {padding: ${paddingTop} 0 0 0;`);
|
|
6441
|
+
slideBoxRendered.style.padding = `${paddingTop} 0 0 0`;
|
|
6442
|
+
slideBoxPrerender.style.padding = `${paddingTop} 0 0 0`;
|
|
6443
|
+
// slideBoxPrerender.innerHTML = card;
|
|
6444
|
+
// extract and mount solid or gradient bg color (w/o bg image)
|
|
6445
|
+
onBeforeShowSlideDuringMounting.then(callback => {
|
|
6446
|
+
callback(canMediaMount.then(() => {
|
|
6447
|
+
// mount slide media content (after cache is ready event)
|
|
6448
|
+
slideBoxPrerender.innerHTML = content;
|
|
6449
|
+
// create slideApi
|
|
6450
|
+
// call init, init should return moveToIndex
|
|
6451
|
+
return onBeforeShowSlide(slideWrapper, index);
|
|
6452
|
+
}));
|
|
6453
|
+
});
|
|
6454
|
+
slideOffset.appendChild(slideBoxPrerender);
|
|
6455
|
+
slideOffset.appendChild(slideBoxRendered);
|
|
6456
|
+
slideWrapper.appendChild(slideOffset);
|
|
6457
|
+
slideWrapper.appendChild(style);
|
|
6458
|
+
return slideWrapper;
|
|
6459
|
+
};
|
|
6460
|
+
new Promise(resolve => {
|
|
6461
|
+
});
|
|
6462
|
+
// onContentMounted
|
|
6463
|
+
const onSlideMounted = async (slideElement, index) => {
|
|
6464
|
+
// if (index === 0) {
|
|
6465
|
+
// this.activeSlide = slideApi;
|
|
6466
|
+
// }
|
|
6467
|
+
//
|
|
6468
|
+
// const { result, cardId, slideIndex, reason } = await slideApi.showSlide();
|
|
6469
|
+
//
|
|
6470
|
+
//
|
|
6471
|
+
// if (index === 0) {
|
|
6472
|
+
// if (result) {
|
|
6473
|
+
// this.sdkApi.onCardLoadingStateChange(CARD_LOADING_STATE.LOADED);
|
|
6474
|
+
// this.sdkApi.emitEvent("showSlide", { cardId: this.activeSlide.slide.cardId, index });
|
|
6475
|
+
// } else {
|
|
6476
|
+
// this.sdkApi.onCardLoadingStateChange(CARD_LOADING_STATE.LOADING, reason);
|
|
6477
|
+
// }
|
|
6478
|
+
// }
|
|
6479
|
+
//
|
|
6480
|
+
// onShowActiveCardResolver({ cardId, slideIndex });
|
|
6481
|
+
};
|
|
6482
|
+
if (this.slider != null) {
|
|
6483
|
+
this.slider.destroy();
|
|
6484
|
+
}
|
|
6485
|
+
this.slider = new Slider({
|
|
6486
|
+
root: this.config.root,
|
|
6487
|
+
slides: this.slides.map(({ content, resourcesReadyPromise }) => ({
|
|
6488
|
+
content,
|
|
6489
|
+
canMediaMount: resourcesReadyPromise,
|
|
6490
|
+
})),
|
|
6491
|
+
nonce: this.config.nonce,
|
|
6492
|
+
slideRender,
|
|
6493
|
+
onSlideMounted,
|
|
6494
|
+
onBeforeShowSlide,
|
|
6495
|
+
onBeforeLoadSlide,
|
|
6496
|
+
onSlideLoadingError,
|
|
6497
|
+
onShowSlide,
|
|
6498
|
+
onSlideLeft,
|
|
6499
|
+
getLayoutDirection: () => this.layoutDirection,
|
|
6500
|
+
onSlideTimerEnd: () => this.activeSlide.slideTimerEnd(),
|
|
6501
|
+
onSlideStart: () => {
|
|
6502
|
+
this.sdkApi.onCardLoadingStateChange(1 /* CARD_LOADING_STATE.LOADED */);
|
|
6503
|
+
return this.activeSlide.slideStart({ muted: true });
|
|
6504
|
+
},
|
|
6505
|
+
onSlideStop: () => this.activeSlide.slideStop({ prepareForRestart: 1 /* ON_SLIDE_STOP_PREPARE_FOR_RESTART.PREPARE */ }),
|
|
6506
|
+
onSlideDataWaiting: () => this.sdkApi.onCardLoadingStateChange(0 /* CARD_LOADING_STATE.LOADING */),
|
|
6507
|
+
onSlideDataResume: () => this.sdkApi.onCardLoadingStateChange(1 /* CARD_LOADING_STATE.LOADED */),
|
|
6508
|
+
onSlideDataError: () => this.sdkApi.onCardLoadingStateChange(2 /* CARD_LOADING_STATE.LOADING_ERROR */),
|
|
6509
|
+
});
|
|
6510
|
+
await this.slider.showByIndex(index);
|
|
6511
|
+
// return await onShowActiveCard;
|
|
6512
|
+
}
|
|
6513
|
+
handleBackpress() {
|
|
6514
|
+
this.activeSlide.handleBackpress();
|
|
6515
|
+
}
|
|
6516
|
+
get layoutService() {
|
|
6517
|
+
return container.get({ identifier: "LayoutService" });
|
|
6518
|
+
}
|
|
6519
|
+
getLocalData() {
|
|
6520
|
+
return this.sdkApi.getCardLocalData();
|
|
6521
|
+
}
|
|
6522
|
+
async slideStart(config) {
|
|
6523
|
+
return this.activeSlide.slideStart(config);
|
|
6524
|
+
}
|
|
6525
|
+
async slideRestart(config) {
|
|
6526
|
+
return this.activeSlide.slideRestart(config);
|
|
6527
|
+
}
|
|
6528
|
+
async slideUserPause() {
|
|
6529
|
+
return this.activeSlide.slideUserPause();
|
|
6530
|
+
}
|
|
6531
|
+
async slideUserResume() {
|
|
6532
|
+
return this.activeSlide.slideUserResume();
|
|
6533
|
+
}
|
|
6534
|
+
/**
|
|
6535
|
+
* Call on app gone background
|
|
6536
|
+
*/
|
|
6537
|
+
async slideAppPause() {
|
|
6538
|
+
return this.activeSlide.slideAppPause();
|
|
6539
|
+
}
|
|
6540
|
+
/**
|
|
6541
|
+
* Call on app gone foreground after a background
|
|
6542
|
+
*/
|
|
6543
|
+
async slideAppResume() {
|
|
6544
|
+
return this.activeSlide.slideAppResume();
|
|
6545
|
+
}
|
|
6546
|
+
async slideStop(options) {
|
|
6547
|
+
return this.activeSlide.slideStop(options);
|
|
6548
|
+
}
|
|
6549
|
+
slideTimerEnd() {
|
|
6550
|
+
this.activeSlide.slideTimerEnd();
|
|
6551
|
+
}
|
|
6552
|
+
enableAudio() {
|
|
6553
|
+
this.activeSlide.enableAudio();
|
|
6554
|
+
}
|
|
6555
|
+
disableAudio() {
|
|
6556
|
+
this.activeSlide.disableAudio();
|
|
6557
|
+
}
|
|
6558
|
+
get isStopped() {
|
|
6559
|
+
return this.activeSlide.isStopped;
|
|
6560
|
+
}
|
|
6561
|
+
afterStartInitQueuePush(cb) {
|
|
6562
|
+
return this.activeSlide.afterStartInitQueuePush(cb);
|
|
6563
|
+
}
|
|
6564
|
+
afterAppResumeQueuePush(cb) {
|
|
6565
|
+
return this.activeSlide.afterAppResumeQueuePush(cb);
|
|
6566
|
+
}
|
|
6567
|
+
get activeLayer() {
|
|
6568
|
+
return this.activeSlide.slide.activeLayer;
|
|
6569
|
+
}
|
|
6570
|
+
get slide() {
|
|
6571
|
+
return this.activeSlide.slide;
|
|
6572
|
+
}
|
|
6573
|
+
showLayer(index) {
|
|
6574
|
+
this.activeSlide.showLayer(index);
|
|
6575
|
+
}
|
|
6576
|
+
slideClickHandler(targetElement, navigationDirection) {
|
|
6577
|
+
const result = this.activeSlide.slideClickHandler(targetElement, navigationDirection);
|
|
6578
|
+
// todo make via strategy pattern, singleSlide and multiSlide impl
|
|
6579
|
+
if (this.slidesMode === 1 /* SLIDES_MODE.MULTIPLE */ && result.canClickNext) {
|
|
6580
|
+
result.canClickNext = false; // handle nav click via CardsSlider, not via SDK
|
|
6581
|
+
const currentIndex = this.activeSlide.index;
|
|
6582
|
+
let index = navigationDirection === "forward" ? currentIndex + 1 : currentIndex - 1;
|
|
6583
|
+
if (index >= this.slides.length) {
|
|
6584
|
+
index = 0;
|
|
6585
|
+
}
|
|
6586
|
+
else if (index < 0) {
|
|
6587
|
+
index = this.slides.length - 1;
|
|
6588
|
+
}
|
|
6589
|
+
this.slider.showByIndex(index).then(index => {
|
|
6590
|
+
if (currentIndex === index)
|
|
6591
|
+
return;
|
|
6592
|
+
this.activeSlide = this.slides[index].slide;
|
|
6593
|
+
});
|
|
6594
|
+
}
|
|
6595
|
+
return result;
|
|
6596
|
+
}
|
|
6597
|
+
slideSwipeUpHandler() {
|
|
6598
|
+
return this.activeSlide.slideSwipeUpHandler();
|
|
6599
|
+
}
|
|
6600
|
+
setTextInputResult(id, text) {
|
|
6601
|
+
this.activeSlide.setTextInputResult(id, text);
|
|
6602
|
+
}
|
|
6603
|
+
setShareComplete(id, isSuccess) {
|
|
6604
|
+
this.activeSlide.setShareComplete(id, isSuccess);
|
|
6605
|
+
}
|
|
6606
|
+
setWidgetGoodsComplete(elementId) {
|
|
6607
|
+
this.activeSlide.setWidgetGoodsComplete(elementId);
|
|
6608
|
+
}
|
|
6609
|
+
_sdkClientVariables = {};
|
|
6610
|
+
getSdkClientVariables() {
|
|
6611
|
+
return this._sdkClientVariables;
|
|
6612
|
+
}
|
|
6613
|
+
setSdkClientVariables(variables) {
|
|
6614
|
+
this._sdkClientVariables = variables;
|
|
6615
|
+
}
|
|
6616
|
+
setSlideInCacheStatus(index, status) {
|
|
6617
|
+
if (this.slides[index] != null && this.slides[index].resourcesReadyPromisesResolver != null) {
|
|
6618
|
+
if (status === 1 /* SLIDE_IN_CACHE_STATUS.SUCCESS */) {
|
|
6619
|
+
this.slides[index].resourcesReadyPromisesResolver.resolve();
|
|
6620
|
+
}
|
|
6621
|
+
else {
|
|
6622
|
+
this.slides[index].resourcesReadyPromisesResolver.reject();
|
|
6623
|
+
}
|
|
6624
|
+
}
|
|
6625
|
+
else {
|
|
6626
|
+
// for call setSlideInCacheStatus before showSlides
|
|
6627
|
+
this.slides[index] = {
|
|
6628
|
+
content: "",
|
|
6629
|
+
resourcesReadyPromise: Promise.resolve(),
|
|
6630
|
+
};
|
|
6631
|
+
}
|
|
6632
|
+
}
|
|
6633
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`{
|
|
6634
|
+
sdkApi: SDKApi;
|
|
6635
|
+
slideWrapper: HTMLElement;
|
|
6636
|
+
viewport: Window;
|
|
6637
|
+
userResizeHandler?: (data: { viewportWidth: number; viewportHeight: number; fontSize: number }) => void;
|
|
6638
|
+
slideRatio: number;
|
|
6639
|
+
isFullscreen: boolean;
|
|
6640
|
+
slideLoadedCb?: (data: { cardId: number; slideIndex: number; result: boolean; reason?: string }) => void;
|
|
6641
|
+
getViewportWidth: () => number;
|
|
6642
|
+
getViewportHeight: () => number;
|
|
6643
|
+
overlappingActionBarHeight?: number;
|
|
6644
|
+
separateUserAndAppPause: boolean;
|
|
6645
|
+
root: HTMLElement;
|
|
6646
|
+
nonce?: string;
|
|
6647
|
+
useSdkCacheForMultislideMode: boolean;
|
|
6648
|
+
}`]; }
|
|
6649
|
+
}
|
|
6650
|
+
|
|
5067
6651
|
const slideApiPeerDeps = {};
|
|
5068
6652
|
const createSlideWrapper = ({ slideBoxRatio, nonce }) => {
|
|
5069
6653
|
const slideWrapper = document.createElement("div");
|
|
@@ -5094,7 +6678,7 @@ const createSlideWrapper = ({ slideBoxRatio, nonce }) => {
|
|
|
5094
6678
|
slideWrapper.appendChild(style);
|
|
5095
6679
|
return slideWrapper;
|
|
5096
6680
|
};
|
|
5097
|
-
class SlideApi extends
|
|
6681
|
+
class SlideApi extends CardApi {
|
|
5098
6682
|
root;
|
|
5099
6683
|
slideWrapper;
|
|
5100
6684
|
constructor(_sdkInterface, config) {
|
|
@@ -5112,6 +6696,9 @@ class SlideApi extends SlideApi$1 {
|
|
|
5112
6696
|
getViewportHeight: () => slideWrapper.clientHeight,
|
|
5113
6697
|
overlappingActionBarHeight: config.overlappingActionBarHeight,
|
|
5114
6698
|
separateUserAndAppPause: true,
|
|
6699
|
+
root: config.root,
|
|
6700
|
+
nonce: config.nonce,
|
|
6701
|
+
useSdkCacheForMultislideMode: config.useSdkCacheForMultislideMode,
|
|
5115
6702
|
});
|
|
5116
6703
|
this.root = config.root;
|
|
5117
6704
|
this.slideWrapper = slideWrapper;
|
|
@@ -5132,6 +6719,7 @@ class SlideApi extends SlideApi$1 {
|
|
|
5132
6719
|
userResizeHandler?: (data: { viewportWidth: number; viewportHeight: number; fontSize: number }) => void;
|
|
5133
6720
|
VODPlayer?: typeof VODPlayer;
|
|
5134
6721
|
overlappingActionBarHeight?: number;
|
|
6722
|
+
useSdkCacheForMultislideMode: boolean;
|
|
5135
6723
|
}`]; }
|
|
5136
6724
|
}
|
|
5137
6725
|
|
|
@@ -14561,7 +16149,7 @@ class WidgetBase {
|
|
|
14561
16149
|
this.submitButtonView = this.submitButtonAnimatedView.querySelector(".submit-button-view");
|
|
14562
16150
|
}
|
|
14563
16151
|
}
|
|
14564
|
-
this.savedData = this.widgetDeps.
|
|
16152
|
+
this.savedData = this.widgetDeps.slideApiDeps.getCardServerData(this.cardId);
|
|
14565
16153
|
this.localData = extend({}, this.savedData ?? {}, this.options.localData ?? {});
|
|
14566
16154
|
this.id = `w_${this.elementId}_${WidgetBase.widgetIndex}`;
|
|
14567
16155
|
++WidgetBase.widgetIndex;
|
|
@@ -14583,7 +16171,7 @@ class WidgetBase {
|
|
|
14583
16171
|
* @param localData
|
|
14584
16172
|
*/
|
|
14585
16173
|
onRefreshUserData(localData) {
|
|
14586
|
-
this.savedData = this.widgetDeps.
|
|
16174
|
+
this.savedData = this.widgetDeps.slideApiDeps.getCardServerData(this.cardId);
|
|
14587
16175
|
this.localData = extend({}, this.savedData ?? {}, localData);
|
|
14588
16176
|
}
|
|
14589
16177
|
onStart() {
|
|
@@ -14633,13 +16221,13 @@ class WidgetBase {
|
|
|
14633
16221
|
static get widgetsService() {
|
|
14634
16222
|
return container.get({ identifier: "WidgetsService" });
|
|
14635
16223
|
}
|
|
14636
|
-
static getLocalData(
|
|
14637
|
-
return
|
|
16224
|
+
static getLocalData(slideApiDeps) {
|
|
16225
|
+
return slideApiDeps.getCardLocalData();
|
|
14638
16226
|
}
|
|
14639
16227
|
getLocalData() {
|
|
14640
|
-
return this.constructor.getLocalData(this.widgetDeps.
|
|
16228
|
+
return this.constructor.getLocalData(this.widgetDeps.slideApiDeps);
|
|
14641
16229
|
}
|
|
14642
|
-
static setLocalData(
|
|
16230
|
+
static setLocalData(slideApiDeps, keyValue, sendToServer, syncWithRuntimeLocalData) {
|
|
14643
16231
|
// push json object as string
|
|
14644
16232
|
if (sendToServer === undefined) {
|
|
14645
16233
|
sendToServer = true;
|
|
@@ -14654,20 +16242,20 @@ class WidgetBase {
|
|
|
14654
16242
|
syncWithRuntimeLocalData = Boolean(syncWithRuntimeLocalData);
|
|
14655
16243
|
}
|
|
14656
16244
|
if (syncWithRuntimeLocalData) {
|
|
14657
|
-
this.getLocalData(
|
|
16245
|
+
this.getLocalData(slideApiDeps).then(localData => {
|
|
14658
16246
|
// 1 - old values, 2 - new values
|
|
14659
16247
|
keyValue = extend({}, localData, keyValue);
|
|
14660
16248
|
// todo make async via promise or async
|
|
14661
|
-
|
|
16249
|
+
slideApiDeps.setCardLocalData(keyValue, sendToServer);
|
|
14662
16250
|
});
|
|
14663
16251
|
}
|
|
14664
16252
|
else {
|
|
14665
16253
|
// todo make async via promise or async
|
|
14666
|
-
|
|
16254
|
+
slideApiDeps.setCardLocalData(keyValue, sendToServer);
|
|
14667
16255
|
}
|
|
14668
16256
|
}
|
|
14669
16257
|
setLocalData(keyValue, sendToServer, syncWithRuntimeLocalData) {
|
|
14670
|
-
return this.constructor.setLocalData(this.widgetDeps.
|
|
16258
|
+
return this.constructor.setLocalData(this.widgetDeps.slideApiDeps, keyValue, sendToServer, syncWithRuntimeLocalData);
|
|
14671
16259
|
}
|
|
14672
16260
|
get statisticEventBaseFieldsShortForm() {
|
|
14673
16261
|
return WidgetBase.getStatisticEventBaseFieldsShortForm(this.cardId, this.cardType, this.slideIndex);
|
|
@@ -14698,11 +16286,11 @@ class WidgetBase {
|
|
|
14698
16286
|
}
|
|
14699
16287
|
return data;
|
|
14700
16288
|
}
|
|
14701
|
-
static sendStatisticEventToApp(
|
|
14702
|
-
sendStatisticEventToApp(
|
|
16289
|
+
static sendStatisticEventToApp(slideApiDeps, name, data, devPayload, options) {
|
|
16290
|
+
sendStatisticEventToApp(slideApiDeps, name, data, devPayload, options);
|
|
14703
16291
|
}
|
|
14704
16292
|
sendStatisticEventToApp(name, data, devPayload, options) {
|
|
14705
|
-
this.constructor.sendStatisticEventToApp(this.widgetDeps.
|
|
16293
|
+
this.constructor.sendStatisticEventToApp(this.widgetDeps.slideApiDeps, name, data, devPayload, options);
|
|
14706
16294
|
}
|
|
14707
16295
|
onWidgetComplete() {
|
|
14708
16296
|
this._widgetCallbacks.onWidgetComplete(this.cardId, this.slideIndex);
|
|
@@ -14714,14 +16302,14 @@ class WidgetBase {
|
|
|
14714
16302
|
this._widgetCallbacks.onWidgetRequireResumeUI(this.cardId, this.slideIndex);
|
|
14715
16303
|
}
|
|
14716
16304
|
_showLayer(layers, selectIndex, withStatEvent = false) {
|
|
14717
|
-
if (this.widgetDeps.
|
|
14718
|
-
this.widgetDeps.
|
|
16305
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowLayer()) {
|
|
16306
|
+
this.widgetDeps.slideApiDeps.showLayer(selectIndex);
|
|
14719
16307
|
}
|
|
14720
16308
|
else {
|
|
14721
16309
|
forEach(layers, (layer, index) => {
|
|
14722
16310
|
if (index === selectIndex) {
|
|
14723
16311
|
layer.classList.remove("hidden");
|
|
14724
|
-
this.widgetDeps.
|
|
16312
|
+
this.widgetDeps.slideApiDeps.cardAnimation?.start(layer);
|
|
14725
16313
|
}
|
|
14726
16314
|
else {
|
|
14727
16315
|
layer.classList.add("hidden");
|
|
@@ -14871,7 +16459,7 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14871
16459
|
}
|
|
14872
16460
|
catch (e) {
|
|
14873
16461
|
if (this.msgBarcodeRenderError) {
|
|
14874
|
-
this.widgetDeps.
|
|
16462
|
+
this.widgetDeps.slideApiDeps.showToast(this.msgBarcodeRenderError);
|
|
14875
16463
|
}
|
|
14876
16464
|
console.error(e);
|
|
14877
16465
|
}
|
|
@@ -14934,7 +16522,7 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14934
16522
|
};
|
|
14935
16523
|
const profileKey = "fetch-promo-code";
|
|
14936
16524
|
Promise.all([
|
|
14937
|
-
this.widgetDeps.
|
|
16525
|
+
this.widgetDeps.slideApiDeps.sendApiRequest(path, "POST", null, headers, null, profileKey),
|
|
14938
16526
|
new Promise(function (t, e) {
|
|
14939
16527
|
return setTimeout(t, 300);
|
|
14940
16528
|
}),
|
|
@@ -14962,14 +16550,14 @@ class WidgetBarcode extends WidgetBase {
|
|
|
14962
16550
|
this.setLocalData(this.localData, true);
|
|
14963
16551
|
}
|
|
14964
16552
|
else {
|
|
14965
|
-
this.msgNoMoreCodes && this.widgetDeps.
|
|
16553
|
+
this.msgNoMoreCodes && this.widgetDeps.slideApiDeps.showToast(this.msgNoMoreCodes);
|
|
14966
16554
|
}
|
|
14967
16555
|
}
|
|
14968
16556
|
else if (status === 12163 || status === 12002) {
|
|
14969
|
-
this.msgNetworkError && this.widgetDeps.
|
|
16557
|
+
this.msgNetworkError && this.widgetDeps.slideApiDeps.showToast(this.msgNetworkError);
|
|
14970
16558
|
}
|
|
14971
16559
|
else {
|
|
14972
|
-
this.msgServiceError && this.widgetDeps.
|
|
16560
|
+
this.msgServiceError && this.widgetDeps.slideApiDeps.showToast(this.msgServiceError);
|
|
14973
16561
|
}
|
|
14974
16562
|
if (!success) {
|
|
14975
16563
|
this.state = 3;
|
|
@@ -15015,13 +16603,13 @@ class WidgetBarcode extends WidgetBase {
|
|
|
15015
16603
|
}
|
|
15016
16604
|
});
|
|
15017
16605
|
if (this.copiedText) {
|
|
15018
|
-
this.widgetDeps.
|
|
16606
|
+
this.widgetDeps.slideApiDeps.showToast(this.copiedText);
|
|
15019
16607
|
}
|
|
15020
16608
|
}
|
|
15021
16609
|
copyToClipboard(element) {
|
|
15022
16610
|
this._select();
|
|
15023
16611
|
const textValue = this.clipboardTarget ?? "";
|
|
15024
|
-
this.widgetDeps.
|
|
16612
|
+
this.widgetDeps.slideApiDeps.writeToClipboard({ type: "text", textValue });
|
|
15025
16613
|
this.completeWidget();
|
|
15026
16614
|
this._statEventCopyClick(textValue);
|
|
15027
16615
|
}
|
|
@@ -15193,7 +16781,7 @@ class WidgetCopy extends WidgetBase {
|
|
|
15193
16781
|
};
|
|
15194
16782
|
const profileKey = "fetch-promo-code";
|
|
15195
16783
|
Promise.all([
|
|
15196
|
-
this.widgetDeps.
|
|
16784
|
+
this.widgetDeps.slideApiDeps.sendApiRequest(path, "POST", null, headers, null, profileKey),
|
|
15197
16785
|
new Promise(function (t, e) {
|
|
15198
16786
|
return setTimeout(t, 300);
|
|
15199
16787
|
}),
|
|
@@ -15220,14 +16808,14 @@ class WidgetCopy extends WidgetBase {
|
|
|
15220
16808
|
this.setLocalData(this.localData, true);
|
|
15221
16809
|
}
|
|
15222
16810
|
else {
|
|
15223
|
-
this.msgNoMoreCodes && this.widgetDeps.
|
|
16811
|
+
this.msgNoMoreCodes && this.widgetDeps.slideApiDeps.showToast(this.msgNoMoreCodes);
|
|
15224
16812
|
}
|
|
15225
16813
|
}
|
|
15226
16814
|
else if (status === 12163 || status === 12002) {
|
|
15227
|
-
this.msgNetworkError && this.widgetDeps.
|
|
16815
|
+
this.msgNetworkError && this.widgetDeps.slideApiDeps.showToast(this.msgNetworkError);
|
|
15228
16816
|
}
|
|
15229
16817
|
else {
|
|
15230
|
-
this.msgServiceError && this.widgetDeps.
|
|
16818
|
+
this.msgServiceError && this.widgetDeps.slideApiDeps.showToast(this.msgServiceError);
|
|
15231
16819
|
}
|
|
15232
16820
|
if (!success) {
|
|
15233
16821
|
this.state = 3;
|
|
@@ -15279,7 +16867,7 @@ class WidgetCopy extends WidgetBase {
|
|
|
15279
16867
|
copyToClipboard(element) {
|
|
15280
16868
|
this._select();
|
|
15281
16869
|
const textValue = this.clipboardTarget ?? "";
|
|
15282
|
-
this.widgetDeps.
|
|
16870
|
+
this.widgetDeps.slideApiDeps.writeToClipboard({ type: "text", textValue });
|
|
15283
16871
|
this.completeWidget();
|
|
15284
16872
|
this._statEventCopyClick(textValue);
|
|
15285
16873
|
}
|
|
@@ -15421,12 +17009,12 @@ class WidgetDataInput extends WidgetBase {
|
|
|
15421
17009
|
return true;
|
|
15422
17010
|
}
|
|
15423
17011
|
this.elementRect = this.element.getBoundingClientRect();
|
|
15424
|
-
if (this.widgetDeps.
|
|
17012
|
+
if (this.widgetDeps.slideApiDeps.isAndroid || this.widgetDeps.slideApiDeps.isWeb) {
|
|
15425
17013
|
this.slide.classList.add("blured");
|
|
15426
17014
|
}
|
|
15427
17015
|
this.slide.classList.add("data-input-editing");
|
|
15428
17016
|
const dataString = this.element.dataset["clientdialogwidgetconfig"];
|
|
15429
|
-
if (this.widgetDeps.
|
|
17017
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowCardTextInput && dataString) {
|
|
15430
17018
|
const data = JSON.parse(dataString);
|
|
15431
17019
|
data.size = getElementBounding(this.env, this.elementRect);
|
|
15432
17020
|
if (!this.disableTimer) {
|
|
@@ -15447,7 +17035,7 @@ class WidgetDataInput extends WidgetBase {
|
|
|
15447
17035
|
catch (e) {
|
|
15448
17036
|
console.error(e);
|
|
15449
17037
|
}
|
|
15450
|
-
this.widgetDeps.
|
|
17038
|
+
this.widgetDeps.slideApiDeps.showCardTextInput(this.id, data);
|
|
15451
17039
|
this._statEventFocusIn();
|
|
15452
17040
|
}
|
|
15453
17041
|
return false;
|
|
@@ -15746,7 +17334,7 @@ class WidgetDateCountdown extends WidgetBase {
|
|
|
15746
17334
|
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `WidgetCallbacks`, `WidgetDeps`]; }
|
|
15747
17335
|
}
|
|
15748
17336
|
|
|
15749
|
-
const displaySlide = function (slides, localData,
|
|
17337
|
+
const displaySlide = function (slides, localData, slideApiDeps) {
|
|
15750
17338
|
const multiSlideItem = slides[0];
|
|
15751
17339
|
let cardId = undefined;
|
|
15752
17340
|
let cardType = 1 /* CARD_TYPE.STORY */;
|
|
@@ -15811,7 +17399,7 @@ const displaySlide = function (slides, localData, sdkApi) {
|
|
|
15811
17399
|
if (slides.length > 0) {
|
|
15812
17400
|
var slide = slides[0];
|
|
15813
17401
|
slide.classList.remove("hidden");
|
|
15814
|
-
|
|
17402
|
+
slideApiDeps.cardAnimation?.start(slide);
|
|
15815
17403
|
return;
|
|
15816
17404
|
}
|
|
15817
17405
|
score = 0;
|
|
@@ -15840,19 +17428,19 @@ const displaySlide = function (slides, localData, sdkApi) {
|
|
|
15840
17428
|
if (index === selectedIndex) {
|
|
15841
17429
|
slide.classList.remove("hidden");
|
|
15842
17430
|
undefinedResult = false;
|
|
15843
|
-
|
|
15844
|
-
_sendStatEvent(
|
|
17431
|
+
slideApiDeps.cardAnimation?.start(slide);
|
|
17432
|
+
_sendStatEvent(slideApiDeps, cardId, cardType, slideIndex, selectedIndex);
|
|
15845
17433
|
}
|
|
15846
17434
|
});
|
|
15847
17435
|
}
|
|
15848
17436
|
if (undefinedResult) {
|
|
15849
17437
|
console.warn("undefinedResult layer index");
|
|
15850
|
-
|
|
17438
|
+
slideApiDeps.showLayer(0);
|
|
15851
17439
|
}
|
|
15852
17440
|
};
|
|
15853
|
-
const _sendStatEvent = function (
|
|
17441
|
+
const _sendStatEvent = function (slideApiDeps, cardId, cardType, slideIndex, layerIndex) {
|
|
15854
17442
|
try {
|
|
15855
|
-
WidgetBase.sendStatisticEventToApp(
|
|
17443
|
+
WidgetBase.sendStatisticEventToApp(slideApiDeps, "layout-show", {
|
|
15856
17444
|
...WidgetBase.getStatisticEventBaseFieldsShortForm(cardId, cardType, slideIndex),
|
|
15857
17445
|
li: layerIndex,
|
|
15858
17446
|
}, {
|
|
@@ -15867,7 +17455,7 @@ const _sendStatEvent = function (sdkApi, cardId, cardType, slideIndex, layerInde
|
|
|
15867
17455
|
class WidgetMultiSlide {
|
|
15868
17456
|
static api = {
|
|
15869
17457
|
init: function (slides, localData, widgetDeps) {
|
|
15870
|
-
displaySlide(slides, localData, widgetDeps.
|
|
17458
|
+
displaySlide(slides, localData, widgetDeps.slideApiDeps);
|
|
15871
17459
|
},
|
|
15872
17460
|
};
|
|
15873
17461
|
}
|
|
@@ -16035,13 +17623,13 @@ class WidgetPoll extends WidgetBase {
|
|
|
16035
17623
|
if (index !== -1) {
|
|
16036
17624
|
this.elementRect = this.element.getBoundingClientRect();
|
|
16037
17625
|
if (this.getUseResponseOnFirstButton && index === 0) {
|
|
16038
|
-
if (this.widgetDeps.
|
|
17626
|
+
if (this.widgetDeps.slideApiDeps.isAndroid) {
|
|
16039
17627
|
this.slide.classList.add("blured");
|
|
16040
17628
|
}
|
|
16041
17629
|
this.slide.classList.add("data-input-editing");
|
|
16042
17630
|
const dataString = this.element.dataset["clientdialogwidgetconfig"];
|
|
16043
17631
|
this.selectedVariant = index;
|
|
16044
|
-
if (this.widgetDeps.
|
|
17632
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowCardTextInput && dataString) {
|
|
16045
17633
|
const data = JSON.parse(dataString);
|
|
16046
17634
|
data.size = getElementBounding(this.env, this.elementRect);
|
|
16047
17635
|
if (!this.disableTimer) {
|
|
@@ -16063,19 +17651,19 @@ class WidgetPoll extends WidgetBase {
|
|
|
16063
17651
|
catch (e) {
|
|
16064
17652
|
console.error(e);
|
|
16065
17653
|
}
|
|
16066
|
-
this.widgetDeps.
|
|
17654
|
+
this.widgetDeps.slideApiDeps.showCardTextInput(`${this.id}_first`, data);
|
|
16067
17655
|
}
|
|
16068
17656
|
this._statEventPollAnswer();
|
|
16069
17657
|
return false;
|
|
16070
17658
|
}
|
|
16071
17659
|
else if (this.getUseResponseOnSecondButton && index === 1) {
|
|
16072
|
-
if (this.widgetDeps.
|
|
17660
|
+
if (this.widgetDeps.slideApiDeps.isAndroid) {
|
|
16073
17661
|
this.slide.classList.add("blured");
|
|
16074
17662
|
}
|
|
16075
17663
|
this.slide.classList.add("data-input-editing");
|
|
16076
17664
|
const dataString = this.element.dataset["clientdialogwidgetconfig"];
|
|
16077
17665
|
this.selectedVariant = index;
|
|
16078
|
-
if (this.widgetDeps.
|
|
17666
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowCardTextInput && dataString) {
|
|
16079
17667
|
const data = JSON.parse(dataString);
|
|
16080
17668
|
data.size = getElementBounding(this.env, this.elementRect);
|
|
16081
17669
|
if (!this.disableTimer) {
|
|
@@ -16096,7 +17684,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
16096
17684
|
catch (e) {
|
|
16097
17685
|
console.error(e);
|
|
16098
17686
|
}
|
|
16099
|
-
this.widgetDeps.
|
|
17687
|
+
this.widgetDeps.slideApiDeps.showCardTextInput(`${this.id}_second`, data);
|
|
16100
17688
|
}
|
|
16101
17689
|
this._statEventPollAnswer();
|
|
16102
17690
|
return false;
|
|
@@ -16139,7 +17727,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
16139
17727
|
displayPercents(selectedVariantIndex, filled = false) {
|
|
16140
17728
|
let pollAllocation = [0, 0];
|
|
16141
17729
|
let pollAllocationTs = undefined;
|
|
16142
|
-
const sharedData = this.widgetDeps.
|
|
17730
|
+
const sharedData = this.widgetDeps.slideApiDeps.getWidgetsSharedData(this.cardId, "poll" /* Widgets.Poll */);
|
|
16143
17731
|
if (sharedData && sharedData[this.elementId] != null && (isObject$1(sharedData[this.elementId]) || isArray(sharedData[this.elementId]))) {
|
|
16144
17732
|
pollAllocation = sharedData[this.elementId];
|
|
16145
17733
|
if (isObject$1(sharedData[this.elementId])) {
|
|
@@ -17320,7 +18908,7 @@ class WidgetProducts extends WidgetBase {
|
|
|
17320
18908
|
};
|
|
17321
18909
|
const profileKey = "fetch-products";
|
|
17322
18910
|
try {
|
|
17323
|
-
const response = await this.widgetDeps.
|
|
18911
|
+
const response = await this.widgetDeps.slideApiDeps.sendApiRequest(path, "GET", null, headers, null, profileKey);
|
|
17324
18912
|
// console.log({response});
|
|
17325
18913
|
const status = response.status;
|
|
17326
18914
|
if (status === 200 || status === 201) {
|
|
@@ -17446,15 +19034,15 @@ class WidgetProducts extends WidgetBase {
|
|
|
17446
19034
|
this.isOpen = true;
|
|
17447
19035
|
// prevent next slide navigation gesture
|
|
17448
19036
|
this.isClickCapturedByWidget = true;
|
|
17449
|
-
this.widgetDeps.
|
|
17450
|
-
this.widgetDeps.
|
|
17451
|
-
this.widgetDeps.
|
|
19037
|
+
this.widgetDeps.slideApiDeps.disableHorizontalSwipeGesture();
|
|
19038
|
+
this.widgetDeps.slideApiDeps.disableVerticalSwipeGesture();
|
|
19039
|
+
this.widgetDeps.slideApiDeps.disableBackpress();
|
|
17452
19040
|
this._statEventWidgetOpen(this.currentModels);
|
|
17453
19041
|
this.initSwipeGestureDetector();
|
|
17454
19042
|
}
|
|
17455
19043
|
else {
|
|
17456
19044
|
if (result.message) {
|
|
17457
|
-
this.widgetDeps.
|
|
19045
|
+
this.widgetDeps.slideApiDeps.showToast(result.message);
|
|
17458
19046
|
}
|
|
17459
19047
|
}
|
|
17460
19048
|
this.element.classList.remove("loader");
|
|
@@ -17466,13 +19054,13 @@ class WidgetProducts extends WidgetBase {
|
|
|
17466
19054
|
this.productsView?.classList.add("ias-products-container-view--hidden");
|
|
17467
19055
|
this.element.classList.remove("hidden");
|
|
17468
19056
|
this.isClickCapturedByWidget = false;
|
|
17469
|
-
this.widgetDeps.
|
|
19057
|
+
this.widgetDeps.slideApiDeps.enableHorizontalSwipeGesture();
|
|
17470
19058
|
if (this.swipeGestureDetector != null) {
|
|
17471
19059
|
this.swipeGestureDetector.destroy();
|
|
17472
19060
|
this.swipeGestureDetector = null;
|
|
17473
19061
|
}
|
|
17474
|
-
this.widgetDeps.
|
|
17475
|
-
this.widgetDeps.
|
|
19062
|
+
this.widgetDeps.slideApiDeps.enableVerticalSwipeGesture();
|
|
19063
|
+
this.widgetDeps.slideApiDeps.enableBackpress();
|
|
17476
19064
|
const onClosed = () => {
|
|
17477
19065
|
this.productsView?.removeEventListener("animationend", onClosed);
|
|
17478
19066
|
this.productsView?.parentElement?.removeChild(this.productsView);
|
|
@@ -17532,7 +19120,7 @@ class WidgetProducts extends WidgetBase {
|
|
|
17532
19120
|
e.preventDefault();
|
|
17533
19121
|
this._statEventWidgetCardClick(offer);
|
|
17534
19122
|
if (offer.url) {
|
|
17535
|
-
this.widgetDeps.
|
|
19123
|
+
this.widgetDeps.slideApiDeps.openUrl({ type: "link", link: { type: "url", target: offer.url } });
|
|
17536
19124
|
}
|
|
17537
19125
|
};
|
|
17538
19126
|
card.appendChild(figure);
|
|
@@ -17763,10 +19351,10 @@ class WidgetQuest extends WidgetBase {
|
|
|
17763
19351
|
super.onRefreshUserData(localData);
|
|
17764
19352
|
}
|
|
17765
19353
|
setCardSessionValue(name, value) {
|
|
17766
|
-
this.widgetDeps.
|
|
19354
|
+
this.widgetDeps.slideApiDeps.setCardSessionValue(this.element, name, value);
|
|
17767
19355
|
}
|
|
17768
19356
|
getCardSessionValue(name) {
|
|
17769
|
-
return this.widgetDeps.
|
|
19357
|
+
return this.widgetDeps.slideApiDeps.getCardSessionValue(this.element, name);
|
|
17770
19358
|
}
|
|
17771
19359
|
init() {
|
|
17772
19360
|
if (this.localData) {
|
|
@@ -17785,8 +19373,8 @@ class WidgetQuest extends WidgetBase {
|
|
|
17785
19373
|
// global flag - был сделан переход на нужный слайд, больше не нужно повторять за эту сессию
|
|
17786
19374
|
// perform showStorySlide with lastSlideIdx only on story open first time (not on second slide, etc)
|
|
17787
19375
|
this.setCardSessionValue("__storyQuestSlideChanged", "1");
|
|
17788
|
-
if (this.widgetDeps.
|
|
17789
|
-
this.widgetDeps.
|
|
19376
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
19377
|
+
this.widgetDeps.slideApiDeps.showCardSlide(lastSlideIdx);
|
|
17790
19378
|
return false;
|
|
17791
19379
|
}
|
|
17792
19380
|
}
|
|
@@ -17797,8 +19385,8 @@ class WidgetQuest extends WidgetBase {
|
|
|
17797
19385
|
// если этого слайда нет в роутинге (сработал переход по таймеру в app)
|
|
17798
19386
|
const routes = this._getRoutes();
|
|
17799
19387
|
if (routes[0].indexOf(this.slideIndex) === -1 && this.finalSlide) {
|
|
17800
|
-
if (this.widgetDeps.
|
|
17801
|
-
this.widgetDeps.
|
|
19388
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowNextCard) {
|
|
19389
|
+
this.widgetDeps.slideApiDeps.cardShowNext();
|
|
17802
19390
|
return false;
|
|
17803
19391
|
}
|
|
17804
19392
|
}
|
|
@@ -17844,10 +19432,10 @@ class WidgetQuest extends WidgetBase {
|
|
|
17844
19432
|
this._selectAnswer(index, slideIndex);
|
|
17845
19433
|
this.setLocalData(this.localData, true);
|
|
17846
19434
|
this.env.setTimeout(() => {
|
|
17847
|
-
if (slideIndex >= 0 && slideIndex < this.slideCount && this.widgetDeps.
|
|
19435
|
+
if (slideIndex >= 0 && slideIndex < this.slideCount && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
17848
19436
|
// global flag - был сделан переход на нужный слайд, больше не нужно повторять за эту сессию
|
|
17849
19437
|
this.setCardSessionValue("__storyQuestSlideChanged", "1");
|
|
17850
|
-
this.widgetDeps.
|
|
19438
|
+
this.widgetDeps.slideApiDeps.showCardSlide(slideIndex);
|
|
17851
19439
|
}
|
|
17852
19440
|
}, 100);
|
|
17853
19441
|
}
|
|
@@ -17919,12 +19507,12 @@ class WidgetQuest extends WidgetBase {
|
|
|
17919
19507
|
else {
|
|
17920
19508
|
// by routing - move back
|
|
17921
19509
|
moveTo = this._routeMvPtrBack();
|
|
17922
|
-
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.
|
|
17923
|
-
this.widgetDeps.
|
|
19510
|
+
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
19511
|
+
this.widgetDeps.slideApiDeps.showCardSlide(moveTo);
|
|
17924
19512
|
}
|
|
17925
|
-
if (moveTo === false && this.widgetDeps.
|
|
19513
|
+
if (moveTo === false && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
17926
19514
|
// allow move to start - for broken route history
|
|
17927
|
-
this.widgetDeps.
|
|
19515
|
+
this.widgetDeps.slideApiDeps.showCardSlide(0);
|
|
17928
19516
|
}
|
|
17929
19517
|
}
|
|
17930
19518
|
return result;
|
|
@@ -17940,8 +19528,8 @@ class WidgetQuest extends WidgetBase {
|
|
|
17940
19528
|
if (directionForward) {
|
|
17941
19529
|
if (this.navigationNextSlide === -1) {
|
|
17942
19530
|
// this is the final slide - exit from this quest
|
|
17943
|
-
if (this.widgetDeps.
|
|
17944
|
-
this.widgetDeps.
|
|
19531
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowNextCard) {
|
|
19532
|
+
this.widgetDeps.slideApiDeps.cardShowNext();
|
|
17945
19533
|
}
|
|
17946
19534
|
result.continueDefaultNavigation = false;
|
|
17947
19535
|
return result;
|
|
@@ -17950,11 +19538,11 @@ class WidgetQuest extends WidgetBase {
|
|
|
17950
19538
|
if (nextSlideIndex < this.slideCount) {
|
|
17951
19539
|
this._addNewRouteHistory(nextSlideIndex);
|
|
17952
19540
|
this.setLocalData(this.localData, true);
|
|
17953
|
-
this.widgetDeps.
|
|
19541
|
+
this.widgetDeps.slideApiDeps.showCardSlide(nextSlideIndex);
|
|
17954
19542
|
}
|
|
17955
19543
|
else {
|
|
17956
|
-
if (this.widgetDeps.
|
|
17957
|
-
this.widgetDeps.
|
|
19544
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowNextCard) {
|
|
19545
|
+
this.widgetDeps.slideApiDeps.cardShowNext();
|
|
17958
19546
|
}
|
|
17959
19547
|
}
|
|
17960
19548
|
}
|
|
@@ -17967,12 +19555,12 @@ class WidgetQuest extends WidgetBase {
|
|
|
17967
19555
|
else {
|
|
17968
19556
|
// by routing - move back
|
|
17969
19557
|
moveTo = this._routeMvPtrBack();
|
|
17970
|
-
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.
|
|
17971
|
-
this.widgetDeps.
|
|
19558
|
+
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
19559
|
+
this.widgetDeps.slideApiDeps.showCardSlide(moveTo);
|
|
17972
19560
|
}
|
|
17973
|
-
if (moveTo === false && this.widgetDeps.
|
|
19561
|
+
if (moveTo === false && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
17974
19562
|
// allow move to start - for broken route history
|
|
17975
|
-
this.widgetDeps.
|
|
19563
|
+
this.widgetDeps.slideApiDeps.showCardSlide(0);
|
|
17976
19564
|
}
|
|
17977
19565
|
}
|
|
17978
19566
|
}
|
|
@@ -17987,11 +19575,11 @@ class WidgetQuest extends WidgetBase {
|
|
|
17987
19575
|
if (nextSlideIndex < this.slideCount) {
|
|
17988
19576
|
this._addNewRouteHistory(nextSlideIndex);
|
|
17989
19577
|
this.setLocalData(this.localData, true);
|
|
17990
|
-
this.widgetDeps.
|
|
19578
|
+
this.widgetDeps.slideApiDeps.showCardSlide(nextSlideIndex);
|
|
17991
19579
|
}
|
|
17992
19580
|
else {
|
|
17993
|
-
if (this.widgetDeps.
|
|
17994
|
-
this.widgetDeps.
|
|
19581
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowNextCard) {
|
|
19582
|
+
this.widgetDeps.slideApiDeps.cardShowNext();
|
|
17995
19583
|
}
|
|
17996
19584
|
}
|
|
17997
19585
|
}
|
|
@@ -18004,12 +19592,12 @@ class WidgetQuest extends WidgetBase {
|
|
|
18004
19592
|
else {
|
|
18005
19593
|
// by routing - move back
|
|
18006
19594
|
moveTo = this._routeMvPtrBack();
|
|
18007
|
-
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.
|
|
18008
|
-
this.widgetDeps.
|
|
19595
|
+
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
19596
|
+
this.widgetDeps.slideApiDeps.showCardSlide(moveTo);
|
|
18009
19597
|
}
|
|
18010
|
-
if (moveTo === false && this.widgetDeps.
|
|
19598
|
+
if (moveTo === false && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
18011
19599
|
// allow move to start - for broken route history
|
|
18012
|
-
this.widgetDeps.
|
|
19600
|
+
this.widgetDeps.slideApiDeps.showCardSlide(0);
|
|
18013
19601
|
}
|
|
18014
19602
|
}
|
|
18015
19603
|
}
|
|
@@ -18024,20 +19612,20 @@ class WidgetQuest extends WidgetBase {
|
|
|
18024
19612
|
// setLocalData(this.localData, true);
|
|
18025
19613
|
// window._showNarrativeSlide(nextSlideIndex);
|
|
18026
19614
|
// } else {
|
|
18027
|
-
if (this.widgetDeps.
|
|
18028
|
-
this.widgetDeps.
|
|
19615
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowNextCard) {
|
|
19616
|
+
this.widgetDeps.slideApiDeps.cardShowNext();
|
|
18029
19617
|
}
|
|
18030
19618
|
// }
|
|
18031
19619
|
}
|
|
18032
19620
|
else {
|
|
18033
19621
|
// by routing - move back
|
|
18034
19622
|
moveTo = this._routeMvPtrBack();
|
|
18035
|
-
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.
|
|
18036
|
-
this.widgetDeps.
|
|
19623
|
+
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
19624
|
+
this.widgetDeps.slideApiDeps.showCardSlide(moveTo);
|
|
18037
19625
|
}
|
|
18038
|
-
if (moveTo === false && this.widgetDeps.
|
|
19626
|
+
if (moveTo === false && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
18039
19627
|
// allow move to start - for broken route history
|
|
18040
|
-
this.widgetDeps.
|
|
19628
|
+
this.widgetDeps.slideApiDeps.showCardSlide(0);
|
|
18041
19629
|
}
|
|
18042
19630
|
}
|
|
18043
19631
|
}
|
|
@@ -18827,7 +20415,7 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
18827
20415
|
total_user: 0,
|
|
18828
20416
|
};
|
|
18829
20417
|
let answerAllocationTs = undefined;
|
|
18830
|
-
const sharedData = this.widgetDeps.
|
|
20418
|
+
const sharedData = this.widgetDeps.slideApiDeps.getWidgetsSharedData(this.cardId, "rangeSlider" /* Widgets.RangeSlider */);
|
|
18831
20419
|
if (sharedData && sharedData[this.elementId] != null && (isObject$1(sharedData[this.elementId]) || isArray(sharedData[this.elementId]))) {
|
|
18832
20420
|
answerAllocation = sharedData[this.elementId];
|
|
18833
20421
|
answerAllocationTs = sharedData.ts;
|
|
@@ -18927,7 +20515,7 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
18927
20515
|
}
|
|
18928
20516
|
e.preventDefault();
|
|
18929
20517
|
this.isClickCapturedBySlider = true;
|
|
18930
|
-
this.widgetDeps.
|
|
20518
|
+
this.widgetDeps.slideApiDeps.disableHorizontalSwipeGesture();
|
|
18931
20519
|
if (!this.maxHandlePos) {
|
|
18932
20520
|
this.update(true, false);
|
|
18933
20521
|
}
|
|
@@ -18957,7 +20545,7 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
18957
20545
|
handleEnd(e) {
|
|
18958
20546
|
this.env.requestAnimationFrame(() => {
|
|
18959
20547
|
this.isClickCapturedBySlider = false;
|
|
18960
|
-
this.widgetDeps.
|
|
20548
|
+
this.widgetDeps.slideApiDeps.enableHorizontalSwipeGesture();
|
|
18961
20549
|
});
|
|
18962
20550
|
// e.preventDefault();
|
|
18963
20551
|
this.widgetDeps.slideRoot.removeEventListener("touchmove", this.handleMove);
|
|
@@ -19022,7 +20610,7 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
19022
20610
|
if (this.value !== this.prevSnapValue) {
|
|
19023
20611
|
this.prevSnapValue = this.value;
|
|
19024
20612
|
try {
|
|
19025
|
-
this.widgetDeps.
|
|
20613
|
+
this.widgetDeps.slideApiDeps.vibrate(20);
|
|
19026
20614
|
}
|
|
19027
20615
|
catch (e) {
|
|
19028
20616
|
console.error(e);
|
|
@@ -19269,12 +20857,12 @@ class WidgetRate extends WidgetBase {
|
|
|
19269
20857
|
if (this.showDialogOnLowRate) {
|
|
19270
20858
|
this.elementRect = this.element.getBoundingClientRect();
|
|
19271
20859
|
this._selectStar(this.selectedStar, false);
|
|
19272
|
-
if (this.widgetDeps.
|
|
20860
|
+
if (this.widgetDeps.slideApiDeps.isAndroid) {
|
|
19273
20861
|
this.slide.classList.add("blured");
|
|
19274
20862
|
}
|
|
19275
20863
|
this.slide.classList.add("data-input-editing");
|
|
19276
20864
|
const dataString = this.element.dataset["clientdialogwidgetconfig"];
|
|
19277
|
-
if (this.widgetDeps.
|
|
20865
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowCardTextInput && dataString) {
|
|
19278
20866
|
const data = JSON.parse(dataString);
|
|
19279
20867
|
data.size = getElementBounding(this.env, this.elementRect);
|
|
19280
20868
|
if (!this.disableTimer) {
|
|
@@ -19296,7 +20884,7 @@ class WidgetRate extends WidgetBase {
|
|
|
19296
20884
|
catch (e) {
|
|
19297
20885
|
console.error(e);
|
|
19298
20886
|
}
|
|
19299
|
-
this.widgetDeps.
|
|
20887
|
+
this.widgetDeps.slideApiDeps.showCardTextInput(this.id, data);
|
|
19300
20888
|
}
|
|
19301
20889
|
}
|
|
19302
20890
|
else {
|
|
@@ -19308,17 +20896,17 @@ class WidgetRate extends WidgetBase {
|
|
|
19308
20896
|
}
|
|
19309
20897
|
else if (value + 1 >= this.submitToStoresMin && value + 1 <= this.submitToStoresMax) {
|
|
19310
20898
|
let target = null;
|
|
19311
|
-
if (this.widgetDeps.
|
|
20899
|
+
if (this.widgetDeps.slideApiDeps.isAndroid) {
|
|
19312
20900
|
target = getTagData(this.element, "androidLink");
|
|
19313
20901
|
}
|
|
19314
|
-
else if (this.widgetDeps.
|
|
20902
|
+
else if (this.widgetDeps.slideApiDeps.isIOS) {
|
|
19315
20903
|
target = getTagData(this.element, "appleLink");
|
|
19316
20904
|
}
|
|
19317
20905
|
this._selectStar(value, true);
|
|
19318
20906
|
this.completeWidget();
|
|
19319
20907
|
this._statEventRateUsAnswer("");
|
|
19320
20908
|
if (this.submitToStores && target) {
|
|
19321
|
-
this.widgetDeps.
|
|
20909
|
+
this.widgetDeps.slideApiDeps.openUrl({ type: "link", link: { type: "url", target } });
|
|
19322
20910
|
}
|
|
19323
20911
|
}
|
|
19324
20912
|
else {
|
|
@@ -19467,12 +21055,12 @@ class WidgetShare extends WidgetBase {
|
|
|
19467
21055
|
}
|
|
19468
21056
|
share() {
|
|
19469
21057
|
if (!this.btnDisabled) {
|
|
19470
|
-
if (this.widgetDeps.
|
|
19471
|
-
if (this.widgetDeps.
|
|
21058
|
+
if (this.widgetDeps.slideApiDeps.isExistsShare) {
|
|
21059
|
+
if (this.widgetDeps.slideApiDeps.sdkCanSendShareComplete) {
|
|
19472
21060
|
this.btnDisabled = true;
|
|
19473
21061
|
}
|
|
19474
21062
|
if (this.shareType === "url" || this.shareType === "story") {
|
|
19475
|
-
this.widgetDeps.
|
|
21063
|
+
this.widgetDeps.slideApiDeps.share(this.id, {
|
|
19476
21064
|
url: this.shareTarget, // sdk old versions
|
|
19477
21065
|
text: this.shareTarget,
|
|
19478
21066
|
title: null,
|
|
@@ -19480,7 +21068,7 @@ class WidgetShare extends WidgetBase {
|
|
|
19480
21068
|
});
|
|
19481
21069
|
}
|
|
19482
21070
|
else if (this.shareType === "slide") {
|
|
19483
|
-
this.widgetDeps.
|
|
21071
|
+
this.widgetDeps.slideApiDeps.shareSlideScreenshot(this.id, "[data-element-id='" + this.elementId + "']", this.shareTarget ? this.shareTarget : undefined);
|
|
19484
21072
|
}
|
|
19485
21073
|
}
|
|
19486
21074
|
}
|
|
@@ -20086,9 +21674,9 @@ class WidgetTooltip extends WidgetBase {
|
|
|
20086
21674
|
copyToClipboard(element) {
|
|
20087
21675
|
const textValue = this.template1ClipboardTarget ?? "";
|
|
20088
21676
|
if (textValue) {
|
|
20089
|
-
this.widgetDeps.
|
|
21677
|
+
this.widgetDeps.slideApiDeps.writeToClipboard({ type: "text", textValue });
|
|
20090
21678
|
if (this.template1CopiedText) {
|
|
20091
|
-
this.widgetDeps.
|
|
21679
|
+
this.widgetDeps.slideApiDeps.showToast(this.template1CopiedText);
|
|
20092
21680
|
}
|
|
20093
21681
|
}
|
|
20094
21682
|
this._statEventWidgetCopyClick(textValue);
|
|
@@ -20467,7 +22055,7 @@ class WidgetVote extends WidgetBase {
|
|
|
20467
22055
|
// voteAllocation[7]
|
|
20468
22056
|
let voteAllocation = [];
|
|
20469
22057
|
let voteAllocationTs = undefined;
|
|
20470
|
-
const sharedData = this.widgetDeps.
|
|
22058
|
+
const sharedData = this.widgetDeps.slideApiDeps.getWidgetsSharedData(this.cardId, "vote" /* Widgets.Vote */);
|
|
20471
22059
|
if (sharedData && sharedData[this.elementId] != null && (isObject$1(sharedData[this.elementId]) || isArray(sharedData[this.elementId]))) {
|
|
20472
22060
|
voteAllocation = sharedData[this.elementId];
|
|
20473
22061
|
if (isObject$1(sharedData[this.elementId])) {
|