@inappstory/slide-api 0.1.23 → 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 +1636 -393
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +143 -42
- package/dist/index.d.ts +143 -42
- package/dist/index.js +1636 -393
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -563,8 +563,8 @@ const getWinWidth = function (env) {
|
|
|
563
563
|
const getWinHeight = function (env) {
|
|
564
564
|
return env.innerHeight || env.document.documentElement.clientHeight || env.document.body.clientHeight;
|
|
565
565
|
};
|
|
566
|
-
const sendStatisticEventToApp = function (
|
|
567
|
-
|
|
566
|
+
const sendStatisticEventToApp = function (slideApiDeps, name, data, devPayload, options) {
|
|
567
|
+
slideApiDeps.sendStatisticEvent(name, data, devPayload, options?.forceEnableStatisticV2 ?? false);
|
|
568
568
|
};
|
|
569
569
|
const getValueOrException = function (value, message) {
|
|
570
570
|
if (value == null) {
|
|
@@ -821,13 +821,18 @@ var getAnimationFunction = function (element) {
|
|
|
821
821
|
return function () { };
|
|
822
822
|
};
|
|
823
823
|
const animationApi = {
|
|
824
|
+
init: function (slide, animate = false) {
|
|
825
|
+
if (supportAnimate && animate)
|
|
826
|
+
return;
|
|
827
|
+
addClass(slide, "animation-fallback");
|
|
828
|
+
},
|
|
824
829
|
start: function (slide, animate = false) {
|
|
825
830
|
if (supportAnimate && animate) {
|
|
831
|
+
const elements = toArray(slide.querySelectorAll(".narrative-element-animation"));
|
|
826
832
|
// for editor, todo add .reset-animation to narrative-editor-slide && clear that
|
|
827
833
|
if (!hasClass(slide, "narrative-slide")) {
|
|
828
834
|
addClass(slide, "reset-animation");
|
|
829
835
|
}
|
|
830
|
-
const elements = toArray(slide.querySelectorAll(".narrative-element-animation"));
|
|
831
836
|
elements.forEach(element => {
|
|
832
837
|
var width = element.offsetWidth;
|
|
833
838
|
var height = element.offsetHeight;
|
|
@@ -913,7 +918,6 @@ const animationApi = {
|
|
|
913
918
|
}
|
|
914
919
|
}
|
|
915
920
|
else {
|
|
916
|
-
addClass(slide, "animation-fallback");
|
|
917
921
|
const animations = [];
|
|
918
922
|
// просто Array
|
|
919
923
|
var elements = slide.querySelectorAll(".narrative-element-animation");
|
|
@@ -1171,6 +1175,13 @@ class EsModuleSdkApi {
|
|
|
1171
1175
|
isSdkSupportCorrectPauseResumeLifecycle() {
|
|
1172
1176
|
return true;
|
|
1173
1177
|
}
|
|
1178
|
+
emitEvent(name, event) {
|
|
1179
|
+
this.sdkBinding.onEvent(name, event);
|
|
1180
|
+
}
|
|
1181
|
+
onCardLoadingStateChange(state, reason) {
|
|
1182
|
+
console.log("onCardLoadingStateChange", { state });
|
|
1183
|
+
this.sdkBinding.onCardLoadingStateChange(state, reason);
|
|
1184
|
+
}
|
|
1174
1185
|
static get [Symbol.for("___CTOR_ARGS___")]() { return [`SDKInterface`]; }
|
|
1175
1186
|
}
|
|
1176
1187
|
|
|
@@ -1197,6 +1208,9 @@ class DataInput {
|
|
|
1197
1208
|
return element instanceof DataInput;
|
|
1198
1209
|
}
|
|
1199
1210
|
mediaElementsLoadingPromises = [];
|
|
1211
|
+
get nodeRef() {
|
|
1212
|
+
return this._elementNodeRef;
|
|
1213
|
+
}
|
|
1200
1214
|
init(localData) {
|
|
1201
1215
|
try {
|
|
1202
1216
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1247,6 +1261,9 @@ class Barcode {
|
|
|
1247
1261
|
this._widgetDeps = _widgetDeps;
|
|
1248
1262
|
}
|
|
1249
1263
|
mediaElementsLoadingPromises = [];
|
|
1264
|
+
get nodeRef() {
|
|
1265
|
+
return this._elementNodeRef;
|
|
1266
|
+
}
|
|
1250
1267
|
init(localData) {
|
|
1251
1268
|
try {
|
|
1252
1269
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1284,36 +1301,311 @@ class ClickableBase {
|
|
|
1284
1301
|
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`]; }
|
|
1285
1302
|
}
|
|
1286
1303
|
|
|
1304
|
+
class PromocodeNetworkError extends Error {
|
|
1305
|
+
}
|
|
1306
|
+
class PromocodeServiceError extends Error {
|
|
1307
|
+
}
|
|
1308
|
+
class PromocodeNoMoreCodes extends Error {
|
|
1309
|
+
}
|
|
1310
|
+
class PromocodeApi {
|
|
1311
|
+
sdkApi;
|
|
1312
|
+
messages;
|
|
1313
|
+
constructor(sdkApi, messages) {
|
|
1314
|
+
this.sdkApi = sdkApi;
|
|
1315
|
+
this.messages = messages;
|
|
1316
|
+
}
|
|
1317
|
+
async fetchPromoCode(params) {
|
|
1318
|
+
const path = this.getPromotionalCodeFetchPath(params);
|
|
1319
|
+
const headers = {
|
|
1320
|
+
accept: "application/json",
|
|
1321
|
+
"Content-Type": "application/json",
|
|
1322
|
+
};
|
|
1323
|
+
const [response] = await Promise.all([
|
|
1324
|
+
this.sdkApi.sendApiRequest(path, "POST", null, headers, null, "fetch-promo-code"),
|
|
1325
|
+
new Promise(resolve => setTimeout(resolve, 300)),
|
|
1326
|
+
]);
|
|
1327
|
+
const { status, data } = response;
|
|
1328
|
+
if (status === 200 || status === 201) {
|
|
1329
|
+
const promocode = data?.code;
|
|
1330
|
+
if (promocode) {
|
|
1331
|
+
return { promocode, status };
|
|
1332
|
+
}
|
|
1333
|
+
throw new PromocodeNoMoreCodes(this.messages.noMoreCodes);
|
|
1334
|
+
}
|
|
1335
|
+
if (status === 12163 || status === 12002) {
|
|
1336
|
+
throw new PromocodeNetworkError(this.messages.networkError);
|
|
1337
|
+
}
|
|
1338
|
+
throw new PromocodeServiceError(this.messages.serviceError);
|
|
1339
|
+
}
|
|
1340
|
+
getPromotionalCodeFetchPath(params) {
|
|
1341
|
+
switch (params.card.type) {
|
|
1342
|
+
case 4 /* CARD_TYPE.IN_APP_MESSAGING */:
|
|
1343
|
+
return `inappmessaging/message/${params.card.id}/widget/${params.elementId}/promo-code/${params.promocodeId}`;
|
|
1344
|
+
default:
|
|
1345
|
+
return `story/${params.card.id}/widget/${params.elementId}/promo-code/${params.promocodeId}`;
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`Pick`, `{
|
|
1349
|
+
noMoreCodes?: string;
|
|
1350
|
+
networkError?: string;
|
|
1351
|
+
serviceError?: string;
|
|
1352
|
+
}`]; }
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
class PromocodeLocalRepository {
|
|
1356
|
+
elementId;
|
|
1357
|
+
sdkApi;
|
|
1358
|
+
localData = {};
|
|
1359
|
+
constructor(elementId, sdkApi) {
|
|
1360
|
+
this.elementId = elementId;
|
|
1361
|
+
this.sdkApi = sdkApi;
|
|
1362
|
+
}
|
|
1363
|
+
init({ localData, cardId }) {
|
|
1364
|
+
const savedData = this.sdkApi.getCardServerData(cardId) ?? {};
|
|
1365
|
+
this.localData = extend({}, savedData, localData ?? {});
|
|
1366
|
+
}
|
|
1367
|
+
getPromocode() {
|
|
1368
|
+
return this.localData["_pcl_g_" + this.elementId + "_pc"];
|
|
1369
|
+
}
|
|
1370
|
+
savePromocodeByStatus(promocode, status) {
|
|
1371
|
+
if (status === 201)
|
|
1372
|
+
this.savePromocodeWithTime(promocode);
|
|
1373
|
+
else
|
|
1374
|
+
this.savePromocode(promocode);
|
|
1375
|
+
}
|
|
1376
|
+
savePromocodeWithTime(promocode) {
|
|
1377
|
+
this.localData["_pcl_g_" + this.elementId + "_pc_fetched_at"] = Math.round(new Date().getTime() / 1000);
|
|
1378
|
+
this.localData["_&ts_pcl_g_" + this.elementId + "_pc_fetched_at"] = Math.round(new Date().getTime() / 1000);
|
|
1379
|
+
this.savePromocode(promocode);
|
|
1380
|
+
}
|
|
1381
|
+
savePromocode(promocode) {
|
|
1382
|
+
this.localData["_pcl_g_" + this.elementId + "_pc"] = promocode;
|
|
1383
|
+
this.setCardLocalData(this.localData);
|
|
1384
|
+
}
|
|
1385
|
+
async setCardLocalData(newLocalData) {
|
|
1386
|
+
const localData = await this.sdkApi.getCardLocalData();
|
|
1387
|
+
const mergedData = extend({}, localData, newLocalData);
|
|
1388
|
+
await this.sdkApi.setCardLocalData(mergedData, true);
|
|
1389
|
+
}
|
|
1390
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`string`, `ISlideApiDeps`]; }
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
var PromocodeLinkState;
|
|
1394
|
+
(function (PromocodeLinkState) {
|
|
1395
|
+
PromocodeLinkState[PromocodeLinkState["Idle"] = 0] = "Idle";
|
|
1396
|
+
PromocodeLinkState[PromocodeLinkState["Fetched"] = 1] = "Fetched";
|
|
1397
|
+
PromocodeLinkState[PromocodeLinkState["Error"] = 2] = "Error";
|
|
1398
|
+
})(PromocodeLinkState || (PromocodeLinkState = {}));
|
|
1399
|
+
const PROMOCODE_PLACEHOLDER = "%__ias_pc%";
|
|
1400
|
+
class PromocodeLink {
|
|
1401
|
+
element;
|
|
1402
|
+
layer;
|
|
1403
|
+
widgetDeps;
|
|
1404
|
+
state = PromocodeLinkState.Idle;
|
|
1405
|
+
promocode = null;
|
|
1406
|
+
promocodeId;
|
|
1407
|
+
linkTemplate;
|
|
1408
|
+
textContent;
|
|
1409
|
+
button;
|
|
1410
|
+
elementId;
|
|
1411
|
+
card;
|
|
1412
|
+
api;
|
|
1413
|
+
localRepository;
|
|
1414
|
+
constructor(element, layer, widgetDeps) {
|
|
1415
|
+
this.element = element;
|
|
1416
|
+
this.layer = layer;
|
|
1417
|
+
this.widgetDeps = widgetDeps;
|
|
1418
|
+
this.elementId = getValueOrException(getTagData(this.element, "elementId"), "Empty elementId");
|
|
1419
|
+
this.promocodeId = getTagData(this.element, "linkTarget") ?? "";
|
|
1420
|
+
this.linkTemplate = getTagData(this.element, "linkTemplate") ?? "";
|
|
1421
|
+
this.button = this.element.querySelector(".narrative-element-text-lines");
|
|
1422
|
+
this.textContent = this.button?.textContent ?? "";
|
|
1423
|
+
this.card = this.getCard();
|
|
1424
|
+
this.api = new PromocodeApi(this.widgetDeps.slideApiDeps, {
|
|
1425
|
+
networkError: getTagData(this.element, "msgNetworkError") ?? "",
|
|
1426
|
+
serviceError: getTagData(this.element, "msgServiceError") ?? "",
|
|
1427
|
+
noMoreCodes: getTagData(this.element, "msgNoMoreCodes") ?? "",
|
|
1428
|
+
});
|
|
1429
|
+
this.localRepository = new PromocodeLocalRepository(this.elementId, this.widgetDeps.slideApiDeps);
|
|
1430
|
+
}
|
|
1431
|
+
get nodeRef() {
|
|
1432
|
+
return this.element;
|
|
1433
|
+
}
|
|
1434
|
+
mediaElementsLoadingPromises = [];
|
|
1435
|
+
init(localData) {
|
|
1436
|
+
this.localRepository.init({ localData: localData ?? {}, cardId: this.card.id });
|
|
1437
|
+
this.state = PromocodeLinkState.Idle;
|
|
1438
|
+
const promocode = this.localRepository.getPromocode();
|
|
1439
|
+
if (promocode) {
|
|
1440
|
+
this.state = PromocodeLinkState.Fetched;
|
|
1441
|
+
this.showPromocode(promocode);
|
|
1442
|
+
this.promocode = promocode;
|
|
1443
|
+
}
|
|
1444
|
+
return Promise.resolve(true);
|
|
1445
|
+
}
|
|
1446
|
+
onPause() { }
|
|
1447
|
+
onResume() { }
|
|
1448
|
+
onStop() { }
|
|
1449
|
+
onBeforeUnmount() {
|
|
1450
|
+
return Promise.resolve();
|
|
1451
|
+
}
|
|
1452
|
+
handleClick() {
|
|
1453
|
+
switch (this.state) {
|
|
1454
|
+
case PromocodeLinkState.Idle:
|
|
1455
|
+
return false;
|
|
1456
|
+
case PromocodeLinkState.Fetched:
|
|
1457
|
+
this.openPromocodeUrl();
|
|
1458
|
+
return true;
|
|
1459
|
+
case PromocodeLinkState.Error:
|
|
1460
|
+
this.loadPromocode(this.promocodeId).catch(() => { });
|
|
1461
|
+
break;
|
|
1462
|
+
}
|
|
1463
|
+
return false;
|
|
1464
|
+
}
|
|
1465
|
+
get isLayerForcePaused() {
|
|
1466
|
+
return false;
|
|
1467
|
+
}
|
|
1468
|
+
onStart() {
|
|
1469
|
+
this.element.classList.add("active");
|
|
1470
|
+
this.loadPromocode(this.promocodeId).catch(() => { });
|
|
1471
|
+
}
|
|
1472
|
+
openPromocodeUrl() {
|
|
1473
|
+
if (!this.promocode)
|
|
1474
|
+
return;
|
|
1475
|
+
const target = this.linkTemplate.replaceAll(PROMOCODE_PLACEHOLDER, this.promocode);
|
|
1476
|
+
this.layer.layoutService.env.setTimeout(() => {
|
|
1477
|
+
this.widgetDeps.slideApiDeps.openUrl({ type: "link", link: { type: "url", target } });
|
|
1478
|
+
});
|
|
1479
|
+
}
|
|
1480
|
+
async loadPromocode(promocodeId) {
|
|
1481
|
+
try {
|
|
1482
|
+
this.state = PromocodeLinkState.Idle;
|
|
1483
|
+
this.showLoader();
|
|
1484
|
+
const promocode = await this.getPromocode({
|
|
1485
|
+
promocodeId,
|
|
1486
|
+
card: this.card,
|
|
1487
|
+
elementId: this.elementId,
|
|
1488
|
+
});
|
|
1489
|
+
this.state = PromocodeLinkState.Fetched;
|
|
1490
|
+
this.promocode = promocode;
|
|
1491
|
+
this.showPromocode(promocode);
|
|
1492
|
+
return promocode;
|
|
1493
|
+
}
|
|
1494
|
+
catch (error) {
|
|
1495
|
+
this.handleLoadPromocodeError(error);
|
|
1496
|
+
throw error;
|
|
1497
|
+
}
|
|
1498
|
+
finally {
|
|
1499
|
+
this.hideLoader();
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
async getPromocode(params) {
|
|
1503
|
+
if (this.promocode)
|
|
1504
|
+
return this.promocode;
|
|
1505
|
+
let promocode = this.localRepository.getPromocode();
|
|
1506
|
+
if (!promocode) {
|
|
1507
|
+
const result = await this.api.fetchPromoCode(params);
|
|
1508
|
+
promocode = result.promocode;
|
|
1509
|
+
this.localRepository.savePromocodeByStatus(promocode, result.status);
|
|
1510
|
+
}
|
|
1511
|
+
this.promocode = promocode;
|
|
1512
|
+
return promocode;
|
|
1513
|
+
}
|
|
1514
|
+
handleLoadPromocodeError(error) {
|
|
1515
|
+
this.state = PromocodeLinkState.Error;
|
|
1516
|
+
this.showErrorMessage(getTagData(this.element, "msgTryAgain") ?? "");
|
|
1517
|
+
if (error.message.length) {
|
|
1518
|
+
this.widgetDeps.slideApiDeps.showToast(error.message);
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
showPromocode(promocode) {
|
|
1522
|
+
if (!this.button)
|
|
1523
|
+
return;
|
|
1524
|
+
this.button.textContent = this.textContent.replaceAll(PROMOCODE_PLACEHOLDER, promocode);
|
|
1525
|
+
}
|
|
1526
|
+
showErrorMessage(message) {
|
|
1527
|
+
if (!this.button)
|
|
1528
|
+
return;
|
|
1529
|
+
this.button.textContent = message;
|
|
1530
|
+
}
|
|
1531
|
+
getCard() {
|
|
1532
|
+
const slide = getValueOrException(this.element.closest(".narrative-slide"), "Empty slide");
|
|
1533
|
+
return {
|
|
1534
|
+
id: getValueOrException(getTagDataAsNumber(slide, "id"), "Empty cardId"),
|
|
1535
|
+
type: getValueOrException(getTagDataAsNumber(slide, "cardType"), "Empty card type"),
|
|
1536
|
+
};
|
|
1537
|
+
}
|
|
1538
|
+
showLoader() {
|
|
1539
|
+
if (!this.isTransparentElement())
|
|
1540
|
+
addClass(this.element, "loader");
|
|
1541
|
+
}
|
|
1542
|
+
hideLoader() {
|
|
1543
|
+
removeClass(this.element, "loader");
|
|
1544
|
+
}
|
|
1545
|
+
isTransparentElement() {
|
|
1546
|
+
if (this.element) {
|
|
1547
|
+
try {
|
|
1548
|
+
const color = window.getComputedStyle(this.element).color;
|
|
1549
|
+
if (color === "transparent" || color === "rgba(0, 0, 0, 0)" || color === "rgba(0,0,0,0)") {
|
|
1550
|
+
return true;
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
catch (err) {
|
|
1554
|
+
console.error(err);
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
return false;
|
|
1558
|
+
}
|
|
1559
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `WidgetDeps`]; }
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1287
1562
|
class Button extends ClickableBase {
|
|
1288
1563
|
_elementNodeRef;
|
|
1289
|
-
|
|
1564
|
+
layer;
|
|
1565
|
+
widgetDeps;
|
|
1290
1566
|
static _className = "narrative-element-link";
|
|
1567
|
+
isPromotionalCode;
|
|
1568
|
+
promocodeLink = null;
|
|
1291
1569
|
static className() {
|
|
1292
1570
|
return Button._className;
|
|
1293
1571
|
}
|
|
1294
|
-
|
|
1572
|
+
static isTypeOf(element) {
|
|
1573
|
+
return element instanceof Button;
|
|
1574
|
+
}
|
|
1575
|
+
constructor(_elementNodeRef, layer, widgetDeps) {
|
|
1295
1576
|
super(_elementNodeRef);
|
|
1296
1577
|
this._elementNodeRef = _elementNodeRef;
|
|
1297
|
-
this.
|
|
1578
|
+
this.layer = layer;
|
|
1579
|
+
this.widgetDeps = widgetDeps;
|
|
1580
|
+
this.isPromotionalCode = getTagData(_elementNodeRef, "linkType") === "promocode";
|
|
1581
|
+
if (this.isPromotionalCode) {
|
|
1582
|
+
this.promocodeLink = new PromocodeLink(_elementNodeRef, layer, widgetDeps);
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
get nodeRef() {
|
|
1586
|
+
return this._elementNodeRef;
|
|
1298
1587
|
}
|
|
1299
1588
|
mediaElementsLoadingPromises = [];
|
|
1300
|
-
init(localData) {
|
|
1301
|
-
|
|
1589
|
+
async init(localData) {
|
|
1590
|
+
await this.promocodeLink?.init(localData);
|
|
1591
|
+
return true;
|
|
1302
1592
|
}
|
|
1303
1593
|
onPause() { }
|
|
1304
1594
|
onResume() { }
|
|
1305
|
-
onStart() {
|
|
1595
|
+
onStart() {
|
|
1596
|
+
this.promocodeLink?.onStart();
|
|
1597
|
+
}
|
|
1306
1598
|
onStop() { }
|
|
1307
1599
|
onBeforeUnmount() {
|
|
1308
1600
|
return Promise.resolve();
|
|
1309
1601
|
}
|
|
1310
1602
|
handleClick() {
|
|
1311
|
-
return
|
|
1603
|
+
return this.promocodeLink?.handleClick() ?? true;
|
|
1312
1604
|
}
|
|
1313
1605
|
get isLayerForcePaused() {
|
|
1314
1606
|
return false;
|
|
1315
1607
|
}
|
|
1316
|
-
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`]; }
|
|
1608
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `WidgetDeps`]; }
|
|
1317
1609
|
}
|
|
1318
1610
|
|
|
1319
1611
|
class Copy {
|
|
@@ -1334,6 +1626,9 @@ class Copy {
|
|
|
1334
1626
|
this._widgetDeps = _widgetDeps;
|
|
1335
1627
|
}
|
|
1336
1628
|
mediaElementsLoadingPromises = [];
|
|
1629
|
+
get nodeRef() {
|
|
1630
|
+
return this._elementNodeRef;
|
|
1631
|
+
}
|
|
1337
1632
|
init(localData) {
|
|
1338
1633
|
try {
|
|
1339
1634
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1383,6 +1678,9 @@ class DateCountdown {
|
|
|
1383
1678
|
this._widgetDeps = _widgetDeps;
|
|
1384
1679
|
}
|
|
1385
1680
|
mediaElementsLoadingPromises = [];
|
|
1681
|
+
get nodeRef() {
|
|
1682
|
+
return this._elementNodeRef;
|
|
1683
|
+
}
|
|
1386
1684
|
init(localData) {
|
|
1387
1685
|
try {
|
|
1388
1686
|
this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1437,6 +1735,9 @@ class Poll {
|
|
|
1437
1735
|
return element instanceof Poll;
|
|
1438
1736
|
}
|
|
1439
1737
|
mediaElementsLoadingPromises = [];
|
|
1738
|
+
get nodeRef() {
|
|
1739
|
+
return this._elementNodeRef;
|
|
1740
|
+
}
|
|
1440
1741
|
init(localData) {
|
|
1441
1742
|
try {
|
|
1442
1743
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1492,6 +1793,9 @@ class PollLayers {
|
|
|
1492
1793
|
return element instanceof PollLayers;
|
|
1493
1794
|
}
|
|
1494
1795
|
mediaElementsLoadingPromises = [];
|
|
1796
|
+
get nodeRef() {
|
|
1797
|
+
return this._elementNodeRef;
|
|
1798
|
+
}
|
|
1495
1799
|
init(localData) {
|
|
1496
1800
|
try {
|
|
1497
1801
|
this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1542,6 +1846,9 @@ class Products {
|
|
|
1542
1846
|
return element instanceof Products;
|
|
1543
1847
|
}
|
|
1544
1848
|
mediaElementsLoadingPromises = [];
|
|
1849
|
+
get nodeRef() {
|
|
1850
|
+
return this._elementNodeRef;
|
|
1851
|
+
}
|
|
1545
1852
|
init(localData) {
|
|
1546
1853
|
try {
|
|
1547
1854
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1601,6 +1908,9 @@ class Quest {
|
|
|
1601
1908
|
return element instanceof Quest;
|
|
1602
1909
|
}
|
|
1603
1910
|
mediaElementsLoadingPromises = [];
|
|
1911
|
+
get nodeRef() {
|
|
1912
|
+
return this._elementNodeRef;
|
|
1913
|
+
}
|
|
1604
1914
|
init(localData) {
|
|
1605
1915
|
return this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
1606
1916
|
}
|
|
@@ -1649,6 +1959,9 @@ class Quiz {
|
|
|
1649
1959
|
return element instanceof Quiz;
|
|
1650
1960
|
}
|
|
1651
1961
|
mediaElementsLoadingPromises = [];
|
|
1962
|
+
get nodeRef() {
|
|
1963
|
+
return this._elementNodeRef;
|
|
1964
|
+
}
|
|
1652
1965
|
init(localData) {
|
|
1653
1966
|
try {
|
|
1654
1967
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1702,6 +2015,9 @@ class QuizGrouped {
|
|
|
1702
2015
|
return element instanceof QuizGrouped;
|
|
1703
2016
|
}
|
|
1704
2017
|
mediaElementsLoadingPromises = [];
|
|
2018
|
+
get nodeRef() {
|
|
2019
|
+
return this._elementNodeRef;
|
|
2020
|
+
}
|
|
1705
2021
|
init(localData) {
|
|
1706
2022
|
try {
|
|
1707
2023
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1755,6 +2071,9 @@ class RangeSlider {
|
|
|
1755
2071
|
return element instanceof RangeSlider;
|
|
1756
2072
|
}
|
|
1757
2073
|
mediaElementsLoadingPromises = [];
|
|
2074
|
+
get nodeRef() {
|
|
2075
|
+
return this._elementNodeRef;
|
|
2076
|
+
}
|
|
1758
2077
|
init(localData) {
|
|
1759
2078
|
try {
|
|
1760
2079
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1808,6 +2127,9 @@ class Rate {
|
|
|
1808
2127
|
return element instanceof Rate;
|
|
1809
2128
|
}
|
|
1810
2129
|
mediaElementsLoadingPromises = [];
|
|
2130
|
+
get nodeRef() {
|
|
2131
|
+
return this._elementNodeRef;
|
|
2132
|
+
}
|
|
1811
2133
|
init(localData) {
|
|
1812
2134
|
try {
|
|
1813
2135
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1864,6 +2186,9 @@ class Share {
|
|
|
1864
2186
|
return element instanceof Share;
|
|
1865
2187
|
}
|
|
1866
2188
|
mediaElementsLoadingPromises = [];
|
|
2189
|
+
get nodeRef() {
|
|
2190
|
+
return this._elementNodeRef;
|
|
2191
|
+
}
|
|
1867
2192
|
init(localData) {
|
|
1868
2193
|
try {
|
|
1869
2194
|
this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -1911,6 +2236,9 @@ class SwipeUpItems {
|
|
|
1911
2236
|
return element instanceof SwipeUpItems;
|
|
1912
2237
|
}
|
|
1913
2238
|
mediaElementsLoadingPromises = [];
|
|
2239
|
+
get nodeRef() {
|
|
2240
|
+
return this._elementNodeRef;
|
|
2241
|
+
}
|
|
1914
2242
|
init(localData) {
|
|
1915
2243
|
return Promise.resolve(true);
|
|
1916
2244
|
}
|
|
@@ -1954,6 +2282,9 @@ class Test {
|
|
|
1954
2282
|
return element instanceof Test;
|
|
1955
2283
|
}
|
|
1956
2284
|
mediaElementsLoadingPromises = [];
|
|
2285
|
+
get nodeRef() {
|
|
2286
|
+
return this._elementNodeRef;
|
|
2287
|
+
}
|
|
1957
2288
|
init(localData) {
|
|
1958
2289
|
try {
|
|
1959
2290
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -2007,6 +2338,9 @@ class Tooltip {
|
|
|
2007
2338
|
this._widgetDeps = _widgetDeps;
|
|
2008
2339
|
}
|
|
2009
2340
|
mediaElementsLoadingPromises = [];
|
|
2341
|
+
get nodeRef() {
|
|
2342
|
+
return this._elementNodeRef;
|
|
2343
|
+
}
|
|
2010
2344
|
init(localData) {
|
|
2011
2345
|
try {
|
|
2012
2346
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -2054,6 +2388,9 @@ class Vote {
|
|
|
2054
2388
|
this._widgetDeps = _widgetDeps;
|
|
2055
2389
|
}
|
|
2056
2390
|
mediaElementsLoadingPromises = [];
|
|
2391
|
+
get nodeRef() {
|
|
2392
|
+
return this._elementNodeRef;
|
|
2393
|
+
}
|
|
2057
2394
|
init(localData) {
|
|
2058
2395
|
try {
|
|
2059
2396
|
this._widgetApi.init(this._elementNodeRef, localData, this._widgetCallbacks, this._widgetDeps);
|
|
@@ -2095,6 +2432,9 @@ class Text {
|
|
|
2095
2432
|
this._layer = _layer;
|
|
2096
2433
|
}
|
|
2097
2434
|
mediaElementsLoadingPromises = [];
|
|
2435
|
+
get nodeRef() {
|
|
2436
|
+
return this._elementNodeRef;
|
|
2437
|
+
}
|
|
2098
2438
|
init(localData) {
|
|
2099
2439
|
return Promise.resolve(true);
|
|
2100
2440
|
}
|
|
@@ -2218,6 +2558,9 @@ class Image extends ClickableBase {
|
|
|
2218
2558
|
this.mediaElementsLoadingPromises = mediaElements.map(waitForImageHtmlElementLoad);
|
|
2219
2559
|
}
|
|
2220
2560
|
mediaElementsLoadingPromises = [];
|
|
2561
|
+
get nodeRef() {
|
|
2562
|
+
return this._elementNodeRef;
|
|
2563
|
+
}
|
|
2221
2564
|
init(localData) {
|
|
2222
2565
|
return Promise.resolve(true);
|
|
2223
2566
|
}
|
|
@@ -2252,6 +2595,9 @@ class SwipeUp {
|
|
|
2252
2595
|
return element instanceof SwipeUp;
|
|
2253
2596
|
}
|
|
2254
2597
|
mediaElementsLoadingPromises = [];
|
|
2598
|
+
get nodeRef() {
|
|
2599
|
+
return this._elementNodeRef;
|
|
2600
|
+
}
|
|
2255
2601
|
init(localData) {
|
|
2256
2602
|
return Promise.resolve(true);
|
|
2257
2603
|
}
|
|
@@ -2278,7 +2624,7 @@ class Video {
|
|
|
2278
2624
|
_elementNodeRef;
|
|
2279
2625
|
_layer;
|
|
2280
2626
|
_VideoPlayer;
|
|
2281
|
-
|
|
2627
|
+
_slideApiDeps;
|
|
2282
2628
|
static _className = "narrative-element-video";
|
|
2283
2629
|
static className() {
|
|
2284
2630
|
return Video._className;
|
|
@@ -2288,11 +2634,11 @@ class Video {
|
|
|
2288
2634
|
_vodData;
|
|
2289
2635
|
_vodPlayerInstance = null;
|
|
2290
2636
|
_videoStateAdapter = null;
|
|
2291
|
-
constructor(_elementNodeRef, _layer, _VideoPlayer,
|
|
2637
|
+
constructor(_elementNodeRef, _layer, _VideoPlayer, _slideApiDeps) {
|
|
2292
2638
|
this._elementNodeRef = _elementNodeRef;
|
|
2293
2639
|
this._layer = _layer;
|
|
2294
2640
|
this._VideoPlayer = _VideoPlayer;
|
|
2295
|
-
this.
|
|
2641
|
+
this._slideApiDeps = _slideApiDeps;
|
|
2296
2642
|
const _video = this._elementNodeRef.querySelector("video");
|
|
2297
2643
|
if (!_video) {
|
|
2298
2644
|
return;
|
|
@@ -2348,6 +2694,9 @@ class Video {
|
|
|
2348
2694
|
return element instanceof Video;
|
|
2349
2695
|
}
|
|
2350
2696
|
mediaElementsLoadingPromises = [];
|
|
2697
|
+
get nodeRef() {
|
|
2698
|
+
return this._elementNodeRef;
|
|
2699
|
+
}
|
|
2351
2700
|
init(localData) {
|
|
2352
2701
|
return Promise.resolve(true);
|
|
2353
2702
|
}
|
|
@@ -2367,6 +2716,9 @@ class Video {
|
|
|
2367
2716
|
// console.log("onBeforeUnmount")
|
|
2368
2717
|
return await this._destroyVODPlayer();
|
|
2369
2718
|
}
|
|
2719
|
+
get durationMs() {
|
|
2720
|
+
return this._video.duration * 1000;
|
|
2721
|
+
}
|
|
2370
2722
|
_initVOD(vodData) {
|
|
2371
2723
|
const onWaiting = () => {
|
|
2372
2724
|
/**
|
|
@@ -2392,7 +2744,7 @@ class Video {
|
|
|
2392
2744
|
// TODO via class instead of data attr
|
|
2393
2745
|
if (this._video.getAttribute("data-waiting") === "1") {
|
|
2394
2746
|
this._video.setAttribute("data-waiting", "0");
|
|
2395
|
-
this._layer.timeline.slideResumed(this._video.currentTime * 1000);
|
|
2747
|
+
this._layer.timeline.slideResumed(() => this._video.currentTime * 1000);
|
|
2396
2748
|
// @ts-ignore
|
|
2397
2749
|
// _log(`playing: ${this._video.currentTime}`, true);
|
|
2398
2750
|
// clearTimeout(window.synthErrorId);
|
|
@@ -2476,13 +2828,13 @@ class Video {
|
|
|
2476
2828
|
});
|
|
2477
2829
|
}
|
|
2478
2830
|
_convertMpdUrls(mpd_) {
|
|
2479
|
-
if (this.
|
|
2831
|
+
if (this._slideApiDeps.isWeb) {
|
|
2480
2832
|
return mpd_;
|
|
2481
2833
|
}
|
|
2482
2834
|
if (isObject(mpd_) && mpd_.adaptiveFormats != null && Array.isArray(mpd_.adaptiveFormats)) {
|
|
2483
2835
|
const mpd = { ...mpd_ };
|
|
2484
2836
|
for (let i = 0; i < mpd.adaptiveFormats.length; ++i) {
|
|
2485
|
-
mpd.adaptiveFormats[i].url = `${this.
|
|
2837
|
+
mpd.adaptiveFormats[i].url = `${this._slideApiDeps.isAndroid ? `http://vod-asset/` : `vod-asset://`}${mpd.adaptiveFormats[i].cacheName}`;
|
|
2486
2838
|
}
|
|
2487
2839
|
return mpd;
|
|
2488
2840
|
}
|
|
@@ -2517,7 +2869,13 @@ class Video {
|
|
|
2517
2869
|
get videoStartedPromise() {
|
|
2518
2870
|
return this._videoStartedPromise;
|
|
2519
2871
|
}
|
|
2520
|
-
|
|
2872
|
+
get isLooped() {
|
|
2873
|
+
if (this._video != null) {
|
|
2874
|
+
return this._video?.loop;
|
|
2875
|
+
}
|
|
2876
|
+
return false;
|
|
2877
|
+
}
|
|
2878
|
+
start(muted = true, getIsLooped) {
|
|
2521
2879
|
this._videoStartedPromise = new Promise(async (resolve) => {
|
|
2522
2880
|
// invariant - always wait for mediaElementsLoadingPromises
|
|
2523
2881
|
// else call of _initVOD can start and onAllMediaLoaded failed
|
|
@@ -2531,7 +2889,7 @@ class Video {
|
|
|
2531
2889
|
// console.log("Video:start => this._video.pause()");
|
|
2532
2890
|
this._video.pause();
|
|
2533
2891
|
this._video.currentTime = 0;
|
|
2534
|
-
this._video.loop =
|
|
2892
|
+
this._video.loop = getIsLooped();
|
|
2535
2893
|
// remove init class
|
|
2536
2894
|
// if vod - create VoD player
|
|
2537
2895
|
if (this._video.getAttribute("data-default-muted") !== "1") {
|
|
@@ -2544,13 +2902,13 @@ class Video {
|
|
|
2544
2902
|
this._video.currentTime = 0;
|
|
2545
2903
|
this._elementNodeRef.classList.remove("init");
|
|
2546
2904
|
resolve({
|
|
2547
|
-
|
|
2905
|
+
getVideoCurrentTime: () => this._video.currentTime,
|
|
2548
2906
|
});
|
|
2549
2907
|
})
|
|
2550
2908
|
.catch(error => {
|
|
2551
2909
|
console.error(error);
|
|
2552
2910
|
resolve({
|
|
2553
|
-
|
|
2911
|
+
getVideoCurrentTime: () => this._video.currentTime,
|
|
2554
2912
|
});
|
|
2555
2913
|
});
|
|
2556
2914
|
}
|
|
@@ -2559,14 +2917,14 @@ class Video {
|
|
|
2559
2917
|
this._video.currentTime = 0;
|
|
2560
2918
|
this._elementNodeRef.classList.remove("init");
|
|
2561
2919
|
resolve({
|
|
2562
|
-
|
|
2920
|
+
getVideoCurrentTime: () => this._video.currentTime,
|
|
2563
2921
|
});
|
|
2564
2922
|
}, 0);
|
|
2565
2923
|
}
|
|
2566
2924
|
}
|
|
2567
2925
|
else {
|
|
2568
2926
|
resolve({
|
|
2569
|
-
|
|
2927
|
+
getVideoCurrentTime: () => 0,
|
|
2570
2928
|
});
|
|
2571
2929
|
}
|
|
2572
2930
|
});
|
|
@@ -2602,7 +2960,7 @@ class Video {
|
|
|
2602
2960
|
// console.log("resolve 1.1", { ts });
|
|
2603
2961
|
this._video.currentTime = ts;
|
|
2604
2962
|
}
|
|
2605
|
-
resolve({
|
|
2963
|
+
resolve({ getVideoCurrentTime: () => this._video.currentTime });
|
|
2606
2964
|
})
|
|
2607
2965
|
.catch(error => {
|
|
2608
2966
|
console.error(error);
|
|
@@ -2610,7 +2968,7 @@ class Video {
|
|
|
2610
2968
|
if (this._video.currentTime < ts) {
|
|
2611
2969
|
this._video.currentTime = ts;
|
|
2612
2970
|
}
|
|
2613
|
-
resolve({
|
|
2971
|
+
resolve({ getVideoCurrentTime: () => this._video.currentTime });
|
|
2614
2972
|
});
|
|
2615
2973
|
}
|
|
2616
2974
|
else {
|
|
@@ -2619,7 +2977,7 @@ class Video {
|
|
|
2619
2977
|
if (this._video.currentTime < ts) {
|
|
2620
2978
|
this._video.currentTime = ts;
|
|
2621
2979
|
}
|
|
2622
|
-
resolve({
|
|
2980
|
+
resolve({ getVideoCurrentTime: () => this._video.currentTime });
|
|
2623
2981
|
}, 0);
|
|
2624
2982
|
}
|
|
2625
2983
|
});
|
|
@@ -2673,7 +3031,7 @@ class Video {
|
|
|
2673
3031
|
this._video.muted = true;
|
|
2674
3032
|
}
|
|
2675
3033
|
}
|
|
2676
|
-
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof VideoPlayer | undefined`, `
|
|
3034
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof VideoPlayer | undefined`, `ISlideApiDeps`]; }
|
|
2677
3035
|
}
|
|
2678
3036
|
// class VideoStateAdapter {
|
|
2679
3037
|
//
|
|
@@ -2767,7 +3125,12 @@ class VideoStateAdapter {
|
|
|
2767
3125
|
}
|
|
2768
3126
|
// todo - add debounce
|
|
2769
3127
|
this._playingCheckerId = window.setTimeout(() => {
|
|
3128
|
+
// console.log({now: Date.now(), _timeupdate: this._timeupdate, currentTime: this._video.currentTime, duration: this._video.duration});
|
|
2770
3129
|
if (Date.now() - this._timeupdate >= this._maxDiff / 2) {
|
|
3130
|
+
// prevent onWaiting triggering if the video has ended
|
|
3131
|
+
if (Math.round(this._video.currentTime) >= Math.round(this._video.duration)) {
|
|
3132
|
+
return;
|
|
3133
|
+
}
|
|
2771
3134
|
this._state = 2 /* VIDEO_STATE.WAITING */;
|
|
2772
3135
|
this._triggerUpdate();
|
|
2773
3136
|
}
|
|
@@ -2850,7 +3213,7 @@ const tryCreateFromHtmlElement = (nodeRef, layer, widgetCallbacks, widgetDeps) =
|
|
|
2850
3213
|
case Text.className():
|
|
2851
3214
|
return new Text(nodeRef, layer);
|
|
2852
3215
|
case Button.className():
|
|
2853
|
-
return new Button(nodeRef, layer);
|
|
3216
|
+
return new Button(nodeRef, layer, widgetDeps);
|
|
2854
3217
|
case Image.className():
|
|
2855
3218
|
return new Image(nodeRef, layer);
|
|
2856
3219
|
case SwipeUp.className():
|
|
@@ -2858,7 +3221,7 @@ const tryCreateFromHtmlElement = (nodeRef, layer, widgetCallbacks, widgetDeps) =
|
|
|
2858
3221
|
case SwipeUpItems.className():
|
|
2859
3222
|
return new SwipeUpItems(nodeRef, layer);
|
|
2860
3223
|
case Video.className():
|
|
2861
|
-
return new Video(nodeRef, layer, layoutApi.VideoPlayer, layer.
|
|
3224
|
+
return new Video(nodeRef, layer, layoutApi.VideoPlayer, layer.slideApiDeps);
|
|
2862
3225
|
//////// widgets ///////
|
|
2863
3226
|
case Copy.className():
|
|
2864
3227
|
return layoutApi.widgetCopyApi ? new Copy(nodeRef, layer, layoutApi.widgetCopyApi, widgetCallbacks, widgetDeps) : null;
|
|
@@ -2916,20 +3279,23 @@ class SlideTimeline {
|
|
|
2916
3279
|
slideDisabledTimer;
|
|
2917
3280
|
slideReady;
|
|
2918
3281
|
_afterAppResumeQueuePush;
|
|
2919
|
-
|
|
2920
|
-
constructor(slideIndex, slideDuration, slideDisabledTimer, slideReady, _afterAppResumeQueuePush,
|
|
3282
|
+
slideApiDeps;
|
|
3283
|
+
constructor(slideIndex, slideDuration, slideDisabledTimer, slideReady, _afterAppResumeQueuePush, slideApiDeps) {
|
|
2921
3284
|
this.slideIndex = slideIndex;
|
|
2922
3285
|
this.slideDuration = slideDuration;
|
|
2923
3286
|
this.slideDisabledTimer = slideDisabledTimer;
|
|
2924
3287
|
this.slideReady = slideReady;
|
|
2925
3288
|
this._afterAppResumeQueuePush = _afterAppResumeQueuePush;
|
|
2926
|
-
this.
|
|
3289
|
+
this.slideApiDeps = slideApiDeps;
|
|
2927
3290
|
this.timelineDisabledState = this.slideDisabledTimer ? TimelineDisabledState.disabled : TimelineDisabledState.enabled;
|
|
2928
3291
|
}
|
|
2929
3292
|
resumedAt = new Date().getTime();
|
|
2930
3293
|
timeSpent = 0;
|
|
2931
3294
|
timelineDisabledState;
|
|
2932
3295
|
currentState = "stop" /* TIMELINE_ACTION.STOP */;
|
|
3296
|
+
deferredDataWaitingStateTimerId = null;
|
|
3297
|
+
deferredResumeStateTimerId = null;
|
|
3298
|
+
dataWaitingStartedAt = null;
|
|
2933
3299
|
static get layoutService() {
|
|
2934
3300
|
return container.get({ identifier: "LayoutService" });
|
|
2935
3301
|
}
|
|
@@ -2937,14 +3303,14 @@ class SlideTimeline {
|
|
|
2937
3303
|
return SlideTimeline.layoutService;
|
|
2938
3304
|
}
|
|
2939
3305
|
get isSDKSupportUpdateTimeline() {
|
|
2940
|
-
if (this.
|
|
3306
|
+
if (this.slideApiDeps.isAndroid) {
|
|
2941
3307
|
return Boolean(SlideTimeline.layoutService.env.Android && "updateTimeline" in SlideTimeline.layoutService.env.Android);
|
|
2942
3308
|
}
|
|
2943
|
-
else if (this.
|
|
3309
|
+
else if (this.slideApiDeps.isIOS) {
|
|
2944
3310
|
const mh = SlideTimeline.layoutService.env?.webkit?.messageHandlers ?? {};
|
|
2945
3311
|
return "updateTimeline" in mh;
|
|
2946
3312
|
}
|
|
2947
|
-
else if (this.
|
|
3313
|
+
else if (this.slideApiDeps.isWeb) {
|
|
2948
3314
|
return true;
|
|
2949
3315
|
}
|
|
2950
3316
|
else {
|
|
@@ -2952,7 +3318,7 @@ class SlideTimeline {
|
|
|
2952
3318
|
}
|
|
2953
3319
|
}
|
|
2954
3320
|
get isSdkSupportTimelineOnBeforeStart() {
|
|
2955
|
-
return this.
|
|
3321
|
+
return this.slideApiDeps.isSdkSupportTimelineOnBeforeStart();
|
|
2956
3322
|
}
|
|
2957
3323
|
get index() {
|
|
2958
3324
|
return this.slideIndex;
|
|
@@ -2960,6 +3326,9 @@ class SlideTimeline {
|
|
|
2960
3326
|
get isTimelineDisabled() {
|
|
2961
3327
|
return this.timelineDisabledState === TimelineDisabledState.disabled;
|
|
2962
3328
|
}
|
|
3329
|
+
get durationMs() {
|
|
3330
|
+
return this.slideDuration;
|
|
3331
|
+
}
|
|
2963
3332
|
async updateTimeline(action, showLoader = false, showError = false) {
|
|
2964
3333
|
// два кейса
|
|
2965
3334
|
// когда есть слои и у слоя вызываем showLayer который вызывает startTimer до старта слайда, потом start от sdk
|
|
@@ -2988,13 +3357,15 @@ class SlideTimeline {
|
|
|
2988
3357
|
//@ts-ignore
|
|
2989
3358
|
// window._log(`updateTimeline 1, a: ${action} ct: ${currentTime} d: ${duration} tds: ${this.timelineDisabledState}`, true);
|
|
2990
3359
|
await this.slideReady.then();
|
|
2991
|
-
//@ts-ignore
|
|
2992
3360
|
// window._log(`updateTimeline, a: ${action} ct: ${currentTime} d: ${duration} tds: ${this.timelineDisabledState}`, true);
|
|
2993
|
-
// console.trace(`updateTimeline ${action} slideIndex: ${this.slideIndex} currentTime:${currentTime} duration:${duration} tds: ${this.timelineDisabledState}`);
|
|
2994
|
-
this.
|
|
3361
|
+
// console.trace(`updateTimeline ${action} slideIndex: ${this.slideIndex} currentTime:${currentTime} duration:${duration} tds: ${this.timelineDisabledState} showLoader: ${showLoader} showError: ${showError}`);
|
|
3362
|
+
this.slideApiDeps.updateTimeline(this.slideIndex, action, currentTime, duration, showLoader, showError);
|
|
3363
|
+
if (action === "pause" /* TIMELINE_ACTION.PAUSE */ && showLoader) {
|
|
3364
|
+
this.dataWaitingStartedAt = Date.now();
|
|
3365
|
+
}
|
|
2995
3366
|
}
|
|
2996
3367
|
/**
|
|
2997
|
-
* trigger timeline update for new slide in sdk, before slide
|
|
3368
|
+
* trigger timeline update for new slide in sdk, before slide start event (prevent timeout in timeline while we wait for video start)
|
|
2998
3369
|
*/
|
|
2999
3370
|
triggerSlideLoadState() {
|
|
3000
3371
|
if (this.isSDKSupportUpdateTimeline && this.isSdkSupportTimelineOnBeforeStart) {
|
|
@@ -3007,7 +3378,7 @@ class SlideTimeline {
|
|
|
3007
3378
|
if (this.timelineDisabledState === TimelineDisabledState.disabled) {
|
|
3008
3379
|
duration = 0;
|
|
3009
3380
|
}
|
|
3010
|
-
this.
|
|
3381
|
+
this.slideApiDeps.updateTimeline(this.slideIndex, "before_start" /* TIMELINE_ACTION.BEFORE_START */, 0, duration, false, false);
|
|
3011
3382
|
}
|
|
3012
3383
|
}
|
|
3013
3384
|
/**
|
|
@@ -3016,6 +3387,7 @@ class SlideTimeline {
|
|
|
3016
3387
|
*/
|
|
3017
3388
|
slideStarted() {
|
|
3018
3389
|
// console.trace("slideStarted");
|
|
3390
|
+
this.onBeforeStateChanged();
|
|
3019
3391
|
if (this.isSDKSupportUpdateTimeline) {
|
|
3020
3392
|
this.resumedAt = new Date().getTime();
|
|
3021
3393
|
this.timeSpent = 0; // for case when instance exists, but we return to slide again
|
|
@@ -3024,6 +3396,7 @@ class SlideTimeline {
|
|
|
3024
3396
|
}
|
|
3025
3397
|
slideRestarted() {
|
|
3026
3398
|
// console.trace("slideRestarted");
|
|
3399
|
+
this.onBeforeStateChanged();
|
|
3027
3400
|
if (this.isSDKSupportUpdateTimeline) {
|
|
3028
3401
|
this.resumedAt = new Date().getTime();
|
|
3029
3402
|
this.timeSpent = 0;
|
|
@@ -3033,11 +3406,12 @@ class SlideTimeline {
|
|
|
3033
3406
|
/**
|
|
3034
3407
|
*
|
|
3035
3408
|
*/
|
|
3036
|
-
slidePaused(
|
|
3409
|
+
slidePaused(currentTime) {
|
|
3037
3410
|
// console.trace("slidePaused");
|
|
3411
|
+
this.onBeforeStateChanged();
|
|
3038
3412
|
if (this.isSDKSupportUpdateTimeline) {
|
|
3039
|
-
if (
|
|
3040
|
-
this.timeSpent = Math.round(
|
|
3413
|
+
if (currentTime != null) {
|
|
3414
|
+
this.timeSpent = Math.round(currentTime);
|
|
3041
3415
|
}
|
|
3042
3416
|
else {
|
|
3043
3417
|
const globalCurrentTime = new Date().getTime();
|
|
@@ -3047,26 +3421,43 @@ class SlideTimeline {
|
|
|
3047
3421
|
this.updateTimeline("pause" /* TIMELINE_ACTION.PAUSE */);
|
|
3048
3422
|
}
|
|
3049
3423
|
else {
|
|
3050
|
-
this.
|
|
3424
|
+
this.slideApiDeps.cardPausedCallback(currentTime);
|
|
3051
3425
|
}
|
|
3052
3426
|
}
|
|
3053
|
-
slideResumed(
|
|
3427
|
+
slideResumed(getVideoCurrentTime) {
|
|
3054
3428
|
// console.trace("slideResumed");
|
|
3429
|
+
this.onBeforeStateChanged();
|
|
3055
3430
|
// @ts-ignore
|
|
3056
3431
|
// window._log(`updateTimeline slideResumed ${videoCurrentTime}`, true);
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3432
|
+
// dataWaitingStartedAt
|
|
3433
|
+
const slideResume = () => {
|
|
3434
|
+
if (this.isSDKSupportUpdateTimeline) {
|
|
3435
|
+
if (getVideoCurrentTime != null) {
|
|
3436
|
+
this.timeSpent = Math.round(getVideoCurrentTime());
|
|
3437
|
+
}
|
|
3438
|
+
this.resumedAt = new Date().getTime();
|
|
3439
|
+
this.updateTimeline("start" /* TIMELINE_ACTION.START */);
|
|
3060
3440
|
}
|
|
3061
|
-
|
|
3062
|
-
|
|
3441
|
+
else {
|
|
3442
|
+
this.slideApiDeps.cardResumedCallback(getVideoCurrentTime != null ? getVideoCurrentTime() : null);
|
|
3443
|
+
}
|
|
3444
|
+
};
|
|
3445
|
+
// prevent micro loaders in UI
|
|
3446
|
+
const delay = 300;
|
|
3447
|
+
let dataWaitingLoaderSpent = delay;
|
|
3448
|
+
if (this.dataWaitingStartedAt != null) {
|
|
3449
|
+
dataWaitingLoaderSpent = Date.now() - this.dataWaitingStartedAt;
|
|
3450
|
+
}
|
|
3451
|
+
if (dataWaitingLoaderSpent < delay) {
|
|
3452
|
+
this.deferredResumeStateTimerId = window.setTimeout(slideResume, dataWaitingLoaderSpent - delay);
|
|
3063
3453
|
}
|
|
3064
3454
|
else {
|
|
3065
|
-
|
|
3455
|
+
slideResume();
|
|
3066
3456
|
}
|
|
3067
3457
|
}
|
|
3068
3458
|
slideStopped() {
|
|
3069
3459
|
// console.trace("slideStopped");
|
|
3460
|
+
this.onBeforeStateChanged();
|
|
3070
3461
|
if (this.isSDKSupportUpdateTimeline) {
|
|
3071
3462
|
this.updateTimeline("stop" /* TIMELINE_ACTION.STOP */);
|
|
3072
3463
|
}
|
|
@@ -3076,6 +3467,7 @@ class SlideTimeline {
|
|
|
3076
3467
|
* used by widgets
|
|
3077
3468
|
*/
|
|
3078
3469
|
startDisabledTimeline(fallback) {
|
|
3470
|
+
this.onBeforeStateChanged();
|
|
3079
3471
|
// if app is paused (in background) - don't call start timeline (Android issues)
|
|
3080
3472
|
// @ts-ignore
|
|
3081
3473
|
// window._log(`Push startDisabledTimeline to queue at state: ${window.slideApi.state}, time: ${new Date().getTime()}`, true);
|
|
@@ -3095,6 +3487,7 @@ class SlideTimeline {
|
|
|
3095
3487
|
}
|
|
3096
3488
|
onSlideDataWaiting(videoCurrentTime) {
|
|
3097
3489
|
// console.trace("onSlideDataWaiting");
|
|
3490
|
+
this.onBeforeStateChanged();
|
|
3098
3491
|
// @ts-ignore
|
|
3099
3492
|
// window._log(`updateTimeline onSlideDataWaiting ${videoCurrentTime}`, true);
|
|
3100
3493
|
if (videoCurrentTime != null) {
|
|
@@ -3105,10 +3498,20 @@ class SlideTimeline {
|
|
|
3105
3498
|
let spent = globalCurrentTime - this.resumedAt;
|
|
3106
3499
|
this.timeSpent += spent;
|
|
3107
3500
|
}
|
|
3108
|
-
|
|
3501
|
+
// prevent micro loaders in UI
|
|
3502
|
+
if (this.currentState === "start" /* TIMELINE_ACTION.START */) {
|
|
3503
|
+
this.updateTimeline("pause" /* TIMELINE_ACTION.PAUSE */, false, false);
|
|
3504
|
+
this.deferredDataWaitingStateTimerId = window.setTimeout(() => {
|
|
3505
|
+
this.updateTimeline("pause" /* TIMELINE_ACTION.PAUSE */, true, false);
|
|
3506
|
+
}, 300);
|
|
3507
|
+
}
|
|
3508
|
+
else {
|
|
3509
|
+
this.updateTimeline("pause" /* TIMELINE_ACTION.PAUSE */, true, false);
|
|
3510
|
+
}
|
|
3109
3511
|
}
|
|
3110
3512
|
onSlideError(videoCurrentTime) {
|
|
3111
3513
|
// console.trace("onSlideError");
|
|
3514
|
+
this.onBeforeStateChanged();
|
|
3112
3515
|
if (videoCurrentTime != null) {
|
|
3113
3516
|
this.timeSpent = Math.round(videoCurrentTime);
|
|
3114
3517
|
}
|
|
@@ -3119,7 +3522,21 @@ class SlideTimeline {
|
|
|
3119
3522
|
}
|
|
3120
3523
|
this.updateTimeline("stop" /* TIMELINE_ACTION.STOP */, false, true);
|
|
3121
3524
|
}
|
|
3122
|
-
|
|
3525
|
+
clearDeferredDataWaitingStateTimerId() {
|
|
3526
|
+
if (this.deferredDataWaitingStateTimerId != null) {
|
|
3527
|
+
window.clearTimeout(this.deferredDataWaitingStateTimerId);
|
|
3528
|
+
}
|
|
3529
|
+
}
|
|
3530
|
+
clearDeferredResumeStateTimerId() {
|
|
3531
|
+
if (this.deferredResumeStateTimerId != null) {
|
|
3532
|
+
window.clearTimeout(this.deferredResumeStateTimerId);
|
|
3533
|
+
}
|
|
3534
|
+
}
|
|
3535
|
+
onBeforeStateChanged() {
|
|
3536
|
+
this.clearDeferredDataWaitingStateTimerId();
|
|
3537
|
+
this.clearDeferredResumeStateTimerId();
|
|
3538
|
+
}
|
|
3539
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`number`, `number`, `boolean`, `Promise`, `(cb: () => void) => void`, `ISlideApiDeps`]; }
|
|
3123
3540
|
}
|
|
3124
3541
|
|
|
3125
3542
|
class Layer {
|
|
@@ -3128,8 +3545,7 @@ class Layer {
|
|
|
3128
3545
|
_slideReadyPromise;
|
|
3129
3546
|
_afterAppResumeQueuePush;
|
|
3130
3547
|
_afterStartInitQueuePush;
|
|
3131
|
-
|
|
3132
|
-
sdkApi;
|
|
3548
|
+
slideApiDeps;
|
|
3133
3549
|
_slideRoot;
|
|
3134
3550
|
_getLayoutDirection;
|
|
3135
3551
|
_slidePauseUI;
|
|
@@ -3145,14 +3561,13 @@ class Layer {
|
|
|
3145
3561
|
_elements = [];
|
|
3146
3562
|
_timeline;
|
|
3147
3563
|
_widgetDeps;
|
|
3148
|
-
constructor(_nodeRef, _slide, _slideReadyPromise, _afterAppResumeQueuePush, _afterStartInitQueuePush,
|
|
3564
|
+
constructor(_nodeRef, _slide, _slideReadyPromise, _afterAppResumeQueuePush, _afterStartInitQueuePush, slideApiDeps, _slideRoot, _getLayoutDirection, _slidePauseUI, _slideResumeUI, _getSdkClientVariables) {
|
|
3149
3565
|
this._nodeRef = _nodeRef;
|
|
3150
3566
|
this._slide = _slide;
|
|
3151
3567
|
this._slideReadyPromise = _slideReadyPromise;
|
|
3152
3568
|
this._afterAppResumeQueuePush = _afterAppResumeQueuePush;
|
|
3153
3569
|
this._afterStartInitQueuePush = _afterStartInitQueuePush;
|
|
3154
|
-
this.
|
|
3155
|
-
this.sdkApi = sdkApi;
|
|
3570
|
+
this.slideApiDeps = slideApiDeps;
|
|
3156
3571
|
this._slideRoot = _slideRoot;
|
|
3157
3572
|
this._getLayoutDirection = _getLayoutDirection;
|
|
3158
3573
|
this._slidePauseUI = _slidePauseUI;
|
|
@@ -3165,16 +3580,16 @@ class Layer {
|
|
|
3165
3580
|
this._duration = parseInt(this._nodeRef.getAttribute("data-duration") ?? "") || DEFAULT_SLIDE_DURATION;
|
|
3166
3581
|
this._disabledTimer = this._nodeRef.getAttribute("data-disable-timer") === "1";
|
|
3167
3582
|
this._disabledNavigation = this._nodeRef.getAttribute("data-disable-navigation") === "1";
|
|
3168
|
-
this._timeline = new SlideTimeline(this._slideIndex, this._duration, this._disabledTimer, this._slideReadyPromise, this._afterAppResumeQueuePush, this.
|
|
3583
|
+
this._timeline = new SlideTimeline(this._slideIndex, this._duration, this._disabledTimer, this._slideReadyPromise, this._afterAppResumeQueuePush, this.slideApiDeps);
|
|
3169
3584
|
this._widgetDeps = {
|
|
3170
|
-
|
|
3585
|
+
slideApiDeps: this.slideApiDeps,
|
|
3171
3586
|
slideRoot: this._slideRoot,
|
|
3172
3587
|
getLayoutDirection: this._getLayoutDirection,
|
|
3173
3588
|
getSdkClientVariables: this._getSdkClientVariables,
|
|
3174
3589
|
};
|
|
3175
3590
|
const onWidgetComplete = (cardId, slideIndex) => {
|
|
3176
3591
|
// todo if nothing more widgets with disabled timers - we can start layer timeline
|
|
3177
|
-
const fallback = () => this.
|
|
3592
|
+
const fallback = () => this.slideApiDeps.showNextSlide(DEFAULT_SLIDE_DURATION);
|
|
3178
3593
|
// для android sdk важно чтобы этот метод вызывался только после slide_start
|
|
3179
3594
|
this._afterStartInitQueuePush(() => {
|
|
3180
3595
|
this._timeline.startDisabledTimeline(fallback);
|
|
@@ -3216,16 +3631,17 @@ class Layer {
|
|
|
3216
3631
|
}
|
|
3217
3632
|
}
|
|
3218
3633
|
init(localData) {
|
|
3219
|
-
if (this.
|
|
3634
|
+
if (this.slideApiDeps.isIOS || this.slideApiDeps.isAndroid) {
|
|
3220
3635
|
this._nodeRef.classList.add("_app");
|
|
3221
|
-
this.
|
|
3222
|
-
this.
|
|
3636
|
+
this.slideApiDeps.isIOS && this._nodeRef.classList.add("_isIos");
|
|
3637
|
+
this.slideApiDeps.isAndroid && this._nodeRef.classList.add("_isAndroid");
|
|
3223
3638
|
}
|
|
3639
|
+
this.slideApiDeps.cardAnimation?.init(this._nodeRef);
|
|
3224
3640
|
const promises = this._elements.map(element => element.init(localData));
|
|
3225
3641
|
return promises;
|
|
3226
3642
|
}
|
|
3227
3643
|
onAfterAllMediaResourcesLoaded() {
|
|
3228
|
-
if (this.
|
|
3644
|
+
if (this.slideApiDeps.isIOS) ;
|
|
3229
3645
|
this._initTextFit();
|
|
3230
3646
|
}
|
|
3231
3647
|
get nodeRef() {
|
|
@@ -3244,7 +3660,10 @@ class Layer {
|
|
|
3244
3660
|
return container.get({ identifier: "LayoutService" });
|
|
3245
3661
|
}
|
|
3246
3662
|
getLocalData() {
|
|
3247
|
-
return this.
|
|
3663
|
+
return this.slideApiDeps.getCardLocalData();
|
|
3664
|
+
}
|
|
3665
|
+
findElementByNodeRef(nodeRef) {
|
|
3666
|
+
return this._elements.find(element => element.nodeRef === nodeRef);
|
|
3248
3667
|
}
|
|
3249
3668
|
get isQuest() {
|
|
3250
3669
|
return this._nodeRef.getAttribute("data-quest-count") != null;
|
|
@@ -3397,14 +3816,19 @@ class Layer {
|
|
|
3397
3816
|
const videoElement = this.videoElement;
|
|
3398
3817
|
let currentTime = 0;
|
|
3399
3818
|
if (videoElement != null) {
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3819
|
+
const getVideoIsLooped = () => {
|
|
3820
|
+
let videoLoop = false;
|
|
3821
|
+
if (this.timeline.isTimelineDisabled || this.timeline.durationMs > videoElement.durationMs) {
|
|
3822
|
+
videoLoop = true;
|
|
3823
|
+
}
|
|
3824
|
+
// console.log({videoLoop, isTimelineDisabled: this.timeline.isTimelineDisabled, timelineDurationMs: this.timeline.durationMs, videoElementDurationMs: videoElement.durationMs});
|
|
3825
|
+
return videoLoop;
|
|
3826
|
+
};
|
|
3827
|
+
// todo - need to convert to ms ?
|
|
3828
|
+
currentTime = (await videoElement.start(muted, getVideoIsLooped)).getVideoCurrentTime();
|
|
3405
3829
|
}
|
|
3406
|
-
if (this.
|
|
3407
|
-
this._animationPauseCb = this.
|
|
3830
|
+
if (this.slideApiDeps.cardAnimation) {
|
|
3831
|
+
this._animationPauseCb = this.slideApiDeps.cardAnimation.start(this._nodeRef);
|
|
3408
3832
|
}
|
|
3409
3833
|
for (const element of this._elements) {
|
|
3410
3834
|
element.onStart();
|
|
@@ -3420,7 +3844,7 @@ class Layer {
|
|
|
3420
3844
|
}
|
|
3421
3845
|
async stop(options) {
|
|
3422
3846
|
this.videoElement?.stop(options);
|
|
3423
|
-
this.
|
|
3847
|
+
this.slideApiDeps.cardAnimation?.stop(this._nodeRef);
|
|
3424
3848
|
for (const element of this._elements) {
|
|
3425
3849
|
element.onPause();
|
|
3426
3850
|
}
|
|
@@ -3431,7 +3855,7 @@ class Layer {
|
|
|
3431
3855
|
}
|
|
3432
3856
|
stopInternal(options) {
|
|
3433
3857
|
this.videoElement?.stop(options);
|
|
3434
|
-
this.
|
|
3858
|
+
this.slideApiDeps.cardAnimation?.stop(this._nodeRef);
|
|
3435
3859
|
for (const element of this._elements) {
|
|
3436
3860
|
element.onPause();
|
|
3437
3861
|
}
|
|
@@ -3443,17 +3867,21 @@ class Layer {
|
|
|
3443
3867
|
return new Promise(resolve => {
|
|
3444
3868
|
const cb = () => {
|
|
3445
3869
|
let currentTime = this.videoElement?.pause(resetVideoTime) ?? null;
|
|
3870
|
+
if (this.videoElement?.isLooped) {
|
|
3871
|
+
// skip currentTime from looped video (bcz in that case video time does not associated with timeline)
|
|
3872
|
+
currentTime = null;
|
|
3873
|
+
}
|
|
3874
|
+
if (currentTime != null) {
|
|
3875
|
+
currentTime *= 1000;
|
|
3876
|
+
}
|
|
3446
3877
|
if (stopAnimation) {
|
|
3447
|
-
this.
|
|
3878
|
+
this.slideApiDeps.cardAnimation?.stop(this._nodeRef);
|
|
3448
3879
|
}
|
|
3449
3880
|
else {
|
|
3450
3881
|
if (this._animationPauseCb != null && isFunction(this._animationPauseCb)) {
|
|
3451
3882
|
this._animationResumeCb = this._animationPauseCb(false);
|
|
3452
3883
|
}
|
|
3453
3884
|
}
|
|
3454
|
-
if (currentTime != null) {
|
|
3455
|
-
currentTime *= 1000;
|
|
3456
|
-
}
|
|
3457
3885
|
for (const element of this._elements) {
|
|
3458
3886
|
element.onPause();
|
|
3459
3887
|
}
|
|
@@ -3473,26 +3901,23 @@ class Layer {
|
|
|
3473
3901
|
}
|
|
3474
3902
|
async resume() {
|
|
3475
3903
|
return new Promise(resolve => {
|
|
3476
|
-
const cb = ({
|
|
3904
|
+
const cb = ({ getVideoCurrentTime }) => {
|
|
3477
3905
|
// console.log("resumed cb with currentTime", { currentTime });
|
|
3478
|
-
if (currentTime != null) {
|
|
3479
|
-
currentTime *= 1000;
|
|
3480
|
-
}
|
|
3481
3906
|
if (isFunction(this._animationResumeCb)) {
|
|
3482
3907
|
this._animationResumeCb();
|
|
3483
3908
|
}
|
|
3484
3909
|
for (const element of this._elements) {
|
|
3485
3910
|
element.onResume();
|
|
3486
3911
|
}
|
|
3487
|
-
this.timeline.slideResumed(
|
|
3488
|
-
resolve({ currentTime });
|
|
3912
|
+
this.timeline.slideResumed(getVideoCurrentTime != null ? () => getVideoCurrentTime() * 1000 : undefined);
|
|
3913
|
+
resolve({ currentTime: getVideoCurrentTime != null ? getVideoCurrentTime() : null });
|
|
3489
3914
|
};
|
|
3490
3915
|
const videoStartedPromise = this.videoElement?.resume();
|
|
3491
3916
|
if (videoStartedPromise != null && videoStartedPromise.then != null) {
|
|
3492
3917
|
videoStartedPromise.then(cb);
|
|
3493
3918
|
}
|
|
3494
3919
|
else {
|
|
3495
|
-
cb({
|
|
3920
|
+
cb({ getVideoCurrentTime: undefined });
|
|
3496
3921
|
}
|
|
3497
3922
|
});
|
|
3498
3923
|
}
|
|
@@ -3508,7 +3933,7 @@ class Layer {
|
|
|
3508
3933
|
get isLayerForcePaused() {
|
|
3509
3934
|
return this.elements.some(element => element.isLayerForcePaused);
|
|
3510
3935
|
}
|
|
3511
|
-
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Slide`, `Promise`, `(cb: () => void) => void`, `(cb: () => void) => void`, `
|
|
3936
|
+
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`]; }
|
|
3512
3937
|
}
|
|
3513
3938
|
const TextFit = (function () {
|
|
3514
3939
|
const defaultSettings = {
|
|
@@ -3699,8 +4124,7 @@ class Slide {
|
|
|
3699
4124
|
_slideReadyPromise;
|
|
3700
4125
|
_afterAppResumeQueuePush;
|
|
3701
4126
|
_afterStartInitQueuePush;
|
|
3702
|
-
|
|
3703
|
-
sdkApi;
|
|
4127
|
+
slideApiDeps;
|
|
3704
4128
|
_slideRoot;
|
|
3705
4129
|
_getLayoutDirection;
|
|
3706
4130
|
_slidePauseUI;
|
|
@@ -3708,13 +4132,12 @@ class Slide {
|
|
|
3708
4132
|
_getSdkClientVariables;
|
|
3709
4133
|
_layers;
|
|
3710
4134
|
_start;
|
|
3711
|
-
constructor(_slidesNodesRefs, _slideReadyPromise, _afterAppResumeQueuePush, _afterStartInitQueuePush,
|
|
4135
|
+
constructor(_slidesNodesRefs, _slideReadyPromise, _afterAppResumeQueuePush, _afterStartInitQueuePush, slideApiDeps, _slideRoot, _getLayoutDirection, _slidePauseUI, _slideResumeUI, _getSdkClientVariables) {
|
|
3712
4136
|
this._slidesNodesRefs = _slidesNodesRefs;
|
|
3713
4137
|
this._slideReadyPromise = _slideReadyPromise;
|
|
3714
4138
|
this._afterAppResumeQueuePush = _afterAppResumeQueuePush;
|
|
3715
4139
|
this._afterStartInitQueuePush = _afterStartInitQueuePush;
|
|
3716
|
-
this.
|
|
3717
|
-
this.sdkApi = sdkApi;
|
|
4140
|
+
this.slideApiDeps = slideApiDeps;
|
|
3718
4141
|
this._slideRoot = _slideRoot;
|
|
3719
4142
|
this._getLayoutDirection = _getLayoutDirection;
|
|
3720
4143
|
this._slidePauseUI = _slidePauseUI;
|
|
@@ -3724,7 +4147,7 @@ class Slide {
|
|
|
3724
4147
|
if (!this._slidesNodesRefs.length) {
|
|
3725
4148
|
throw new Error("No slides found.");
|
|
3726
4149
|
}
|
|
3727
|
-
this._layers = this._slidesNodesRefs.map(item => new Layer(item, this, this._slideReadyPromise, this._afterAppResumeQueuePush, this._afterStartInitQueuePush, this.
|
|
4150
|
+
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));
|
|
3728
4151
|
this._activeLayer = this._layers[0];
|
|
3729
4152
|
}
|
|
3730
4153
|
_activeLayer;
|
|
@@ -3744,7 +4167,7 @@ class Slide {
|
|
|
3744
4167
|
if (multiSlideApi != null && this.layers.length > 1) {
|
|
3745
4168
|
try {
|
|
3746
4169
|
multiSlideApi.init(this.layersNodesRefs, localData, {
|
|
3747
|
-
|
|
4170
|
+
slideApiDeps: this.slideApiDeps,
|
|
3748
4171
|
slideRoot: this._slideRoot,
|
|
3749
4172
|
getLayoutDirection: this._getLayoutDirection,
|
|
3750
4173
|
getSdkClientVariables: this._getSdkClientVariables,
|
|
@@ -3821,10 +4244,10 @@ class Slide {
|
|
|
3821
4244
|
get disabledNavigation() {
|
|
3822
4245
|
return this._activeLayer.disabledNavigation;
|
|
3823
4246
|
}
|
|
3824
|
-
static get [Symbol.for("___CTOR_ARGS___")]() { return [`Array`, `Promise`, `(cb: () => void) => void`, `(cb: () => void) => void`, `
|
|
4247
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`Array`, `Promise`, `(cb: () => void) => void`, `(cb: () => void) => void`, `ISlideApiDeps`, `HTMLElement`, `() => "ltr" | "rtl"`, `() => Promise<void>`, `() => Promise<void>`, `GetSdkClientVariables`]; }
|
|
3825
4248
|
}
|
|
3826
4249
|
|
|
3827
|
-
class
|
|
4250
|
+
let SlideApi$1 = class SlideApi {
|
|
3828
4251
|
config;
|
|
3829
4252
|
get layoutDirection() {
|
|
3830
4253
|
// warning, detection in ctor not working, bcz sdk changes layout later
|
|
@@ -3839,10 +4262,10 @@ class CardApi {
|
|
|
3839
4262
|
_overlappingActionBarHeight;
|
|
3840
4263
|
_separateUserAndAppPause;
|
|
3841
4264
|
_index;
|
|
3842
|
-
|
|
4265
|
+
slideApiDeps;
|
|
3843
4266
|
constructor(config) {
|
|
3844
4267
|
this.config = config;
|
|
3845
|
-
this.
|
|
4268
|
+
this.slideApiDeps = config.slideApiDeps;
|
|
3846
4269
|
this._slideWrapper = config.slideWrapper;
|
|
3847
4270
|
this._viewport = config.viewport;
|
|
3848
4271
|
this._getViewportWidth = config.getViewportWidth;
|
|
@@ -3851,7 +4274,15 @@ class CardApi {
|
|
|
3851
4274
|
this._separateUserAndAppPause = config.separateUserAndAppPause;
|
|
3852
4275
|
this._index = config.index;
|
|
3853
4276
|
}
|
|
3854
|
-
|
|
4277
|
+
static checkPreloadedInLayoutSlide() {
|
|
4278
|
+
// for sdk backward compatibility
|
|
4279
|
+
const slideBox = document.getElementById("narrative-slide-box");
|
|
4280
|
+
if (slideBox && slideBox.innerText.trim() !== "{%content}".replace("{", "{{").replace("}", "}}")) {
|
|
4281
|
+
return true;
|
|
4282
|
+
}
|
|
4283
|
+
return false;
|
|
4284
|
+
}
|
|
4285
|
+
initPreloadedInLayoutSlide(slideLoadedCb) {
|
|
3855
4286
|
// for sdk backward compatibility
|
|
3856
4287
|
const slideBox = document.getElementById("narrative-slide-box");
|
|
3857
4288
|
// todo via first child and its innerText - faster variant
|
|
@@ -3866,7 +4297,7 @@ class CardApi {
|
|
|
3866
4297
|
});
|
|
3867
4298
|
}
|
|
3868
4299
|
}
|
|
3869
|
-
onUpdateSizeMetrics({ fontSize, xOffset, yOffset, isFullscreen, }) {
|
|
4300
|
+
onUpdateSizeMetrics({ fontSize, xOffset, yOffset, isFullscreen, slideOffsetMargin }) {
|
|
3870
4301
|
// todo CSP violation
|
|
3871
4302
|
this._slideWrapper.style.fontSize = fontSize;
|
|
3872
4303
|
if (this.slideOffsetElement != null) {
|
|
@@ -3879,6 +4310,7 @@ class CardApi {
|
|
|
3879
4310
|
else {
|
|
3880
4311
|
this.slideOffsetElement.classList.remove("narrative-slide-offset-fullscreen");
|
|
3881
4312
|
}
|
|
4313
|
+
this.slideOffsetElement.style.margin = slideOffsetMargin;
|
|
3882
4314
|
}
|
|
3883
4315
|
}
|
|
3884
4316
|
get slideWrapperElement() {
|
|
@@ -3897,8 +4329,8 @@ class CardApi {
|
|
|
3897
4329
|
this._state = 13 /* STATE.DESTROYED */;
|
|
3898
4330
|
}
|
|
3899
4331
|
async showSlide(html) {
|
|
3900
|
-
const slideBox = this._slideWrapper.querySelector(`.${
|
|
3901
|
-
const slideBoxPrerender = this._slideWrapper.querySelector(`.${
|
|
4332
|
+
const slideBox = this._slideWrapper.querySelector(`.${SlideApi.renderedBoxClassName}`);
|
|
4333
|
+
const slideBoxPrerender = this._slideWrapper.querySelector(`.${SlideApi.prerenderBoxClassName}`);
|
|
3902
4334
|
const _result = { cardId: this.slide?.cardId ?? 0, slideIndex: this.slide?.slideIndex ?? 0, result: false, reason: "" };
|
|
3903
4335
|
if (slideBox && slideBoxPrerender) {
|
|
3904
4336
|
if (this._slideInRender) {
|
|
@@ -3918,7 +4350,7 @@ class CardApi {
|
|
|
3918
4350
|
}
|
|
3919
4351
|
else {
|
|
3920
4352
|
_result.result = false;
|
|
3921
|
-
_result.reason = `Element .${
|
|
4353
|
+
_result.reason = `Element .${SlideApi.renderedBoxClassName} or .${SlideApi.prerenderBoxClassName} does not found in DOM`;
|
|
3922
4354
|
}
|
|
3923
4355
|
_result.cardId = this.slide.cardId;
|
|
3924
4356
|
_result.slideIndex = this.slide.slideIndex;
|
|
@@ -3931,7 +4363,7 @@ class CardApi {
|
|
|
3931
4363
|
return container.get({ identifier: "LayoutService" });
|
|
3932
4364
|
}
|
|
3933
4365
|
getLocalData() {
|
|
3934
|
-
return this.
|
|
4366
|
+
return this.slideApiDeps.getCardLocalData();
|
|
3935
4367
|
}
|
|
3936
4368
|
_fontsInit = false;
|
|
3937
4369
|
_initAndLoadFonts(fonts) {
|
|
@@ -4023,9 +4455,9 @@ class CardApi {
|
|
|
4023
4455
|
/**
|
|
4024
4456
|
* For case when SlideApi instance was created before root was attached to DOM
|
|
4025
4457
|
*/
|
|
4026
|
-
this.config.refreshSizes();
|
|
4027
|
-
const slideNodeRef = this._slideWrapper.querySelector(`.${
|
|
4028
|
-
const slidesNodesRefs = Array.prototype.slice.call(this._slideWrapper.querySelectorAll(`.${
|
|
4458
|
+
// this.config.refreshSizes(this);
|
|
4459
|
+
const slideNodeRef = this._slideWrapper.querySelector(`.${SlideApi.prerenderBoxClassName} .narrative-slide`);
|
|
4460
|
+
const slidesNodesRefs = Array.prototype.slice.call(this._slideWrapper.querySelectorAll(`.${SlideApi.prerenderBoxClassName} .narrative-slide.narrative-multi-slide`));
|
|
4029
4461
|
if (!slidesNodesRefs.length && slideNodeRef != null) {
|
|
4030
4462
|
slidesNodesRefs.push(slideNodeRef);
|
|
4031
4463
|
}
|
|
@@ -4036,17 +4468,18 @@ class CardApi {
|
|
|
4036
4468
|
const slideReadyPromise = new Promise(resolve => {
|
|
4037
4469
|
slideReadyResolve = resolve;
|
|
4038
4470
|
});
|
|
4039
|
-
const slide = new Slide(slidesNodesRefs, slideReadyPromise, this.afterAppResumeQueuePush.bind(this), this.afterStartInitQueuePush.bind(this), this.
|
|
4471
|
+
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);
|
|
4040
4472
|
this._slideInInit = slide;
|
|
4473
|
+
// todo - call via DI
|
|
4041
4474
|
slide.activeLayer.timeline.triggerSlideLoadState();
|
|
4042
|
-
if (this.
|
|
4475
|
+
if (this.slideApiDeps.isAndroid) {
|
|
4043
4476
|
this._afterStartInitQueue = [];
|
|
4044
4477
|
}
|
|
4045
4478
|
this._afterAppResumeQueue = [];
|
|
4046
4479
|
const result = { slide, result: false, reason: "" };
|
|
4047
4480
|
try {
|
|
4048
4481
|
const onAllMediaLoaded = this._onAllMediaLoaded(slide);
|
|
4049
|
-
const fontsPromise = this._initAndLoadFonts(this.
|
|
4482
|
+
const fontsPromise = this._initAndLoadFonts(this.slideApiDeps.getCardFonts());
|
|
4050
4483
|
const mediaAndFontsPromise = Promise.all([onAllMediaLoaded, fontsPromise]).then(() => {
|
|
4051
4484
|
this.layoutService.env.clearTimeout(mediaResourcesTimeoutId);
|
|
4052
4485
|
});
|
|
@@ -4098,12 +4531,12 @@ class CardApi {
|
|
|
4098
4531
|
return;
|
|
4099
4532
|
}
|
|
4100
4533
|
return new Promise(resolve => {
|
|
4101
|
-
const slideBox = this._slideWrapper.querySelector(`.${
|
|
4102
|
-
const slideBoxPrerender = this._slideWrapper.querySelector(`.${
|
|
4534
|
+
const slideBox = this._slideWrapper.querySelector(`.${SlideApi.renderedBoxClassName}`);
|
|
4535
|
+
const slideBoxPrerender = this._slideWrapper.querySelector(`.${SlideApi.prerenderBoxClassName}`);
|
|
4103
4536
|
if (slideBox && slideBoxPrerender) {
|
|
4104
|
-
slideBoxPrerender.classList.remove(
|
|
4105
|
-
slideBox.classList.remove(
|
|
4106
|
-
slideBox.classList.add(
|
|
4537
|
+
slideBoxPrerender.classList.remove(SlideApi.prerenderBoxClassName);
|
|
4538
|
+
slideBox.classList.remove(SlideApi.renderedBoxClassName);
|
|
4539
|
+
slideBox.classList.add(SlideApi.prerenderBoxClassName);
|
|
4107
4540
|
// pause Video - prevent triggering onDataWaiting from VODPlayer
|
|
4108
4541
|
prevSlide?.activeLayer.pause(false, true, false);
|
|
4109
4542
|
// 2 RAF - wait for browser render complete (CSS changes, etc.)
|
|
@@ -4127,7 +4560,7 @@ class CardApi {
|
|
|
4127
4560
|
else {
|
|
4128
4561
|
resolve();
|
|
4129
4562
|
}
|
|
4130
|
-
slideBoxPrerender.classList.add(
|
|
4563
|
+
slideBoxPrerender.classList.add(SlideApi.renderedBoxClassName);
|
|
4131
4564
|
}
|
|
4132
4565
|
else {
|
|
4133
4566
|
resolve();
|
|
@@ -4145,7 +4578,7 @@ class CardApi {
|
|
|
4145
4578
|
this._slideConfig = config;
|
|
4146
4579
|
// start deferred fncs from widgets
|
|
4147
4580
|
// important - Android only
|
|
4148
|
-
if (this.
|
|
4581
|
+
if (this.slideApiDeps.isAndroid && this._afterStartInitQueue && Array.isArray(this._afterStartInitQueue)) {
|
|
4149
4582
|
for (const job of this._afterStartInitQueue) {
|
|
4150
4583
|
if (isFunction(job)) {
|
|
4151
4584
|
job();
|
|
@@ -4199,7 +4632,7 @@ class CardApi {
|
|
|
4199
4632
|
this._state = 9 /* STATE.USER_PAUSED */;
|
|
4200
4633
|
};
|
|
4201
4634
|
// todo move to Android adapter
|
|
4202
|
-
if (this.
|
|
4635
|
+
if (this.slideApiDeps.isAndroid && !this.slideApiDeps.isSdkSupportCorrectPauseResumeLifecycle()) {
|
|
4203
4636
|
this._pauseCbTimer = this.layoutService.env.setTimeout(pauseCb, 300);
|
|
4204
4637
|
}
|
|
4205
4638
|
else {
|
|
@@ -4273,10 +4706,10 @@ class CardApi {
|
|
|
4273
4706
|
const defaultAction = () => {
|
|
4274
4707
|
const nextSlideIndex = this.slide.slideIndex + 1;
|
|
4275
4708
|
if (nextSlideIndex >= 0 && nextSlideIndex < this.slide.slideCount) {
|
|
4276
|
-
this.
|
|
4709
|
+
this.slideApiDeps.showCardSlide(nextSlideIndex);
|
|
4277
4710
|
}
|
|
4278
4711
|
else {
|
|
4279
|
-
this.
|
|
4712
|
+
this.slideApiDeps.cardShowNext();
|
|
4280
4713
|
}
|
|
4281
4714
|
};
|
|
4282
4715
|
if (this.activeLayer.questElement) {
|
|
@@ -4323,7 +4756,7 @@ class CardApi {
|
|
|
4323
4756
|
if (!isFunction(cb)) {
|
|
4324
4757
|
return false;
|
|
4325
4758
|
}
|
|
4326
|
-
if (this.
|
|
4759
|
+
if (this.slideApiDeps.isAndroid && this._state === 0 /* STATE.INIT */) {
|
|
4327
4760
|
this._afterStartInitQueue.push(cb);
|
|
4328
4761
|
}
|
|
4329
4762
|
else {
|
|
@@ -4452,7 +4885,7 @@ class CardApi {
|
|
|
4452
4885
|
if (this.layoutService.layoutApi.widgetVoteApi) {
|
|
4453
4886
|
if (this.layoutService.layoutApi.widgetVoteApi.click(element)) {
|
|
4454
4887
|
this.layoutService.env.setTimeout(() => {
|
|
4455
|
-
this.
|
|
4888
|
+
this.slideApiDeps.showNextSlide(0);
|
|
4456
4889
|
});
|
|
4457
4890
|
}
|
|
4458
4891
|
result.canClickNext = false;
|
|
@@ -4476,7 +4909,7 @@ class CardApi {
|
|
|
4476
4909
|
}
|
|
4477
4910
|
if (element) {
|
|
4478
4911
|
this.layoutService.env.setTimeout(() => {
|
|
4479
|
-
this.
|
|
4912
|
+
this.slideApiDeps.showNextSlide(0);
|
|
4480
4913
|
});
|
|
4481
4914
|
result.canClickNext = false;
|
|
4482
4915
|
return result;
|
|
@@ -4504,7 +4937,7 @@ class CardApi {
|
|
|
4504
4937
|
if (this.layoutService.layoutApi.widgetRangeSliderApi) {
|
|
4505
4938
|
if (this.layoutService.layoutApi.widgetRangeSliderApi.click(element)) {
|
|
4506
4939
|
this.layoutService.env.setTimeout(() => {
|
|
4507
|
-
this.
|
|
4940
|
+
this.slideApiDeps.showNextSlide(0);
|
|
4508
4941
|
});
|
|
4509
4942
|
}
|
|
4510
4943
|
result.canClickNext = false;
|
|
@@ -4711,18 +5144,18 @@ class CardApi {
|
|
|
4711
5144
|
}
|
|
4712
5145
|
if (element) {
|
|
4713
5146
|
propagation = false;
|
|
4714
|
-
this.
|
|
4715
|
-
this.
|
|
5147
|
+
this.slideApiDeps.setCardLocalData({}, true);
|
|
5148
|
+
this.slideApiDeps.updateCardServerDataLocally(this.slide.cardId, {});
|
|
4716
5149
|
// window._resetTimers();
|
|
4717
5150
|
// сделать async в ios
|
|
4718
5151
|
let slideIndex = this.slide.slideIndex;
|
|
4719
5152
|
// prevent simultaneous call _showNarrativeSlide and _showLayer - prevent 2 calls of initAfterLoad (break video start on iOS)
|
|
4720
5153
|
if (slideIndex === 0) {
|
|
4721
5154
|
// for story repeat on the first slide with layers
|
|
4722
|
-
this.
|
|
5155
|
+
this.slideApiDeps.showLayer(0);
|
|
4723
5156
|
}
|
|
4724
5157
|
else {
|
|
4725
|
-
this.
|
|
5158
|
+
this.slideApiDeps.showCardSlide(0); // сделать ее async
|
|
4726
5159
|
}
|
|
4727
5160
|
}
|
|
4728
5161
|
// todo в каждом виджете делать выход через
|
|
@@ -4810,44 +5243,44 @@ class CardApi {
|
|
|
4810
5243
|
// this.activeLayer.timeline.slidePaused(0);
|
|
4811
5244
|
// return {handled: true};
|
|
4812
5245
|
}
|
|
4813
|
-
if (this.
|
|
5246
|
+
if (this.slideApiDeps.isAndroid && linkTargetAndroid) {
|
|
4814
5247
|
linkTarget = linkTargetAndroid;
|
|
4815
5248
|
}
|
|
4816
|
-
if (this.
|
|
5249
|
+
if (this.slideApiDeps.isIOS && linkTargetIos) {
|
|
4817
5250
|
linkTarget = linkTargetIos;
|
|
4818
5251
|
}
|
|
4819
|
-
if (this.
|
|
5252
|
+
if (this.slideApiDeps.isWeb && linkTargetWeb) {
|
|
4820
5253
|
linkTarget = linkTargetWeb;
|
|
4821
5254
|
}
|
|
4822
5255
|
// for btn(link) without url (openGame, openStory, closeCard, products, goods, etc)
|
|
4823
5256
|
let statisticWidgetValue = linkType;
|
|
4824
5257
|
let statisticWidgetEventType = "w-link";
|
|
4825
5258
|
if (linkType === "closeStory" || linkType === "closeIAM") {
|
|
4826
|
-
this.layoutService.env.setTimeout(() => this.
|
|
5259
|
+
this.layoutService.env.setTimeout(() => this.slideApiDeps.closeCard("click"));
|
|
4827
5260
|
handled = true;
|
|
4828
5261
|
}
|
|
4829
5262
|
else if (linkType && linkTarget) {
|
|
4830
5263
|
if (linkType === "story") {
|
|
4831
5264
|
// storyId: number, slideIndex: number
|
|
4832
|
-
this.layoutService.env.setTimeout(() => this.
|
|
5265
|
+
this.layoutService.env.setTimeout(() => this.slideApiDeps.openStory(parseInt(linkTarget), 0));
|
|
4833
5266
|
handled = true;
|
|
4834
5267
|
}
|
|
4835
5268
|
else if (linkType === "slide") {
|
|
4836
5269
|
const __slideIndex = parseInt(linkTarget);
|
|
4837
5270
|
const __slideCount = this.slide.slideCount;
|
|
4838
5271
|
if (__slideIndex >= 0 && __slideIndex < __slideCount) {
|
|
4839
|
-
this.layoutService.env.setTimeout(() => this.
|
|
5272
|
+
this.layoutService.env.setTimeout(() => this.slideApiDeps.showCardSlide(__slideIndex));
|
|
4840
5273
|
handled = true;
|
|
4841
5274
|
}
|
|
4842
5275
|
}
|
|
4843
5276
|
else if (linkType === "game") {
|
|
4844
|
-
this.layoutService.env.setTimeout(() => this.
|
|
5277
|
+
this.layoutService.env.setTimeout(() => this.slideApiDeps.openGame(linkTarget));
|
|
4845
5278
|
handled = true;
|
|
4846
5279
|
}
|
|
4847
5280
|
else if (linkType === "layer") {
|
|
4848
5281
|
const layerIndex = parseInt(linkTarget);
|
|
4849
5282
|
if (layerIndex >= 0) {
|
|
4850
|
-
this.layoutService.env.setTimeout(() => this.
|
|
5283
|
+
this.layoutService.env.setTimeout(() => this.slideApiDeps.showLayer(layerIndex));
|
|
4851
5284
|
handled = true;
|
|
4852
5285
|
}
|
|
4853
5286
|
}
|
|
@@ -4855,7 +5288,7 @@ class CardApi {
|
|
|
4855
5288
|
// traditional link, with url
|
|
4856
5289
|
statisticWidgetValue = linkTarget;
|
|
4857
5290
|
this.layoutService.env.setTimeout(() => {
|
|
4858
|
-
this.
|
|
5291
|
+
this.slideApiDeps.openUrl({
|
|
4859
5292
|
type: isSwipeUpAction ? "swipeUpLink" : "link",
|
|
4860
5293
|
link: {
|
|
4861
5294
|
type: "url",
|
|
@@ -4865,6 +5298,12 @@ class CardApi {
|
|
|
4865
5298
|
});
|
|
4866
5299
|
handled = true;
|
|
4867
5300
|
}
|
|
5301
|
+
else if (linkType === "promocode") {
|
|
5302
|
+
handled = this.activeLayer.findElementByNodeRef(element)?.handleClick() ?? true;
|
|
5303
|
+
if (!handled) {
|
|
5304
|
+
return { handled: true };
|
|
5305
|
+
}
|
|
5306
|
+
}
|
|
4868
5307
|
else if (linkType === "products") {
|
|
4869
5308
|
if (this.layoutService.layoutApi.widgetProductsApi) {
|
|
4870
5309
|
this.layoutService.layoutApi.widgetProductsApi.click(element);
|
|
@@ -4874,7 +5313,7 @@ class CardApi {
|
|
|
4874
5313
|
else if (linkType === "swipe-up-items") {
|
|
4875
5314
|
const target = linkTarget;
|
|
4876
5315
|
this.layoutService.env.setTimeout(() => {
|
|
4877
|
-
this.
|
|
5316
|
+
this.slideApiDeps.openUrl({
|
|
4878
5317
|
type: "swipeUpItems",
|
|
4879
5318
|
link: {
|
|
4880
5319
|
type: "json",
|
|
@@ -4910,7 +5349,7 @@ class CardApi {
|
|
|
4910
5349
|
baseFields.message_id = cardId;
|
|
4911
5350
|
break;
|
|
4912
5351
|
}
|
|
4913
|
-
this.
|
|
5352
|
+
this.slideApiDeps.sendStatisticEvent(statisticWidgetEventType, {
|
|
4914
5353
|
i: cardId,
|
|
4915
5354
|
si: slideIndex,
|
|
4916
5355
|
wi: elementId,
|
|
@@ -4967,7 +5406,7 @@ class CardApi {
|
|
|
4967
5406
|
}
|
|
4968
5407
|
}
|
|
4969
5408
|
static get [Symbol.for("___CTOR_ARGS___")]() { return [`{
|
|
4970
|
-
|
|
5409
|
+
slideApiDeps: ISlideApiDeps;
|
|
4971
5410
|
slideWrapper: HTMLElement;
|
|
4972
5411
|
viewport: Window;
|
|
4973
5412
|
userResizeHandler?: (data: { viewportWidth: number; viewportHeight: number; fontSize: number }) => void;
|
|
@@ -4979,29 +5418,435 @@ class CardApi {
|
|
|
4979
5418
|
separateUserAndAppPause: boolean;
|
|
4980
5419
|
root: HTMLElement;
|
|
4981
5420
|
nonce?: string;
|
|
4982
|
-
refreshSizes: () => void;
|
|
5421
|
+
// refreshSizes: (slide: SlideApi) => void;
|
|
4983
5422
|
index: number;
|
|
4984
5423
|
getSdkClientVariables: GetSdkClientVariables;
|
|
4985
5424
|
}`]; }
|
|
5425
|
+
};
|
|
5426
|
+
|
|
5427
|
+
class SlideApiDepsMultiSlideMode {
|
|
5428
|
+
sdkApi;
|
|
5429
|
+
slider;
|
|
5430
|
+
constructor(sdkApi, slider) {
|
|
5431
|
+
this.sdkApi = sdkApi;
|
|
5432
|
+
this.slider = slider;
|
|
5433
|
+
}
|
|
5434
|
+
getWidgetsSharedData(cardId, widget) {
|
|
5435
|
+
return this.sdkApi.getWidgetsSharedData(cardId, widget);
|
|
5436
|
+
}
|
|
5437
|
+
showToast(text) {
|
|
5438
|
+
return this.sdkApi.showToast(text);
|
|
5439
|
+
}
|
|
5440
|
+
writeToClipboard(data) {
|
|
5441
|
+
return this.sdkApi.writeToClipboard(data);
|
|
5442
|
+
}
|
|
5443
|
+
get isExistsShare() {
|
|
5444
|
+
return this.sdkApi.isExistsShare;
|
|
5445
|
+
}
|
|
5446
|
+
share(id, config) {
|
|
5447
|
+
this.sdkApi.share(id, config);
|
|
5448
|
+
}
|
|
5449
|
+
get sdkCanSendShareComplete() {
|
|
5450
|
+
return this.sdkApi.sdkCanSendShareComplete;
|
|
5451
|
+
}
|
|
5452
|
+
shareSlideScreenshot(shareId, hideElementsSelector, shareText) {
|
|
5453
|
+
this.sdkApi.shareSlideScreenshot(shareId, hideElementsSelector, shareText);
|
|
5454
|
+
}
|
|
5455
|
+
setCardSessionValue(element, key, value) {
|
|
5456
|
+
this.sdkApi.setCardSessionValue(element, key, value);
|
|
5457
|
+
}
|
|
5458
|
+
getCardSessionValue(element, key) {
|
|
5459
|
+
return this.sdkApi.getCardSessionValue(element, key);
|
|
5460
|
+
}
|
|
5461
|
+
getCardFonts() {
|
|
5462
|
+
return this.sdkApi.getCardFonts();
|
|
5463
|
+
}
|
|
5464
|
+
disableVerticalSwipeGesture() {
|
|
5465
|
+
this.sdkApi.disableVerticalSwipeGesture();
|
|
5466
|
+
}
|
|
5467
|
+
enableVerticalSwipeGesture() {
|
|
5468
|
+
this.sdkApi.enableVerticalSwipeGesture();
|
|
5469
|
+
}
|
|
5470
|
+
disableBackpress() {
|
|
5471
|
+
this.sdkApi.disableBackpress();
|
|
5472
|
+
}
|
|
5473
|
+
enableBackpress() {
|
|
5474
|
+
this.sdkApi.enableBackpress();
|
|
5475
|
+
}
|
|
5476
|
+
closeCard(reason) {
|
|
5477
|
+
this.sdkApi.closeCard(reason);
|
|
5478
|
+
}
|
|
5479
|
+
openStory(id, index) {
|
|
5480
|
+
// TODO rewrite with Promise - for usage story loading states in Button
|
|
5481
|
+
this.sdkApi.openStory(id, index);
|
|
5482
|
+
}
|
|
5483
|
+
openGame(gameInstanceId) {
|
|
5484
|
+
// TODO rewrite with Promise - for usage game loading states in Button
|
|
5485
|
+
this.sdkApi.openGame(gameInstanceId);
|
|
5486
|
+
}
|
|
5487
|
+
openUrl(data) {
|
|
5488
|
+
this.sdkApi.openUrl(data);
|
|
5489
|
+
}
|
|
5490
|
+
get isAndroid() {
|
|
5491
|
+
return this.sdkApi.isAndroid;
|
|
5492
|
+
}
|
|
5493
|
+
get isWeb() {
|
|
5494
|
+
return this.sdkApi.isWeb;
|
|
5495
|
+
}
|
|
5496
|
+
get isIOS() {
|
|
5497
|
+
return this.sdkApi.isIOS;
|
|
5498
|
+
}
|
|
5499
|
+
get isExistsShowCardTextInput() {
|
|
5500
|
+
return this.sdkApi.isExistsShowCardTextInput;
|
|
5501
|
+
}
|
|
5502
|
+
showCardTextInput(id, data) {
|
|
5503
|
+
this.sdkApi.showCardTextInput(id, data);
|
|
5504
|
+
}
|
|
5505
|
+
vibrate(pattern) {
|
|
5506
|
+
this.sdkApi.vibrate(pattern);
|
|
5507
|
+
}
|
|
5508
|
+
sendApiRequest(url, method, params, headers, data, profilingKey) {
|
|
5509
|
+
return this.sdkApi.sendApiRequest(url, method, params, headers, data, profilingKey);
|
|
5510
|
+
}
|
|
5511
|
+
sendStatisticEvent(name, data, devPayload, forceEnableStatisticV2) {
|
|
5512
|
+
this.sdkApi.sendStatisticEvent(name, data, devPayload, forceEnableStatisticV2);
|
|
5513
|
+
}
|
|
5514
|
+
setCardLocalData(keyValue, sendToServer) {
|
|
5515
|
+
this.sdkApi.setCardLocalData(keyValue, sendToServer);
|
|
5516
|
+
}
|
|
5517
|
+
getCardLocalData() {
|
|
5518
|
+
return this.sdkApi.getCardLocalData();
|
|
5519
|
+
}
|
|
5520
|
+
getCardServerData(cardId) {
|
|
5521
|
+
return this.sdkApi.getCardServerData(cardId);
|
|
5522
|
+
}
|
|
5523
|
+
get cardAnimation() {
|
|
5524
|
+
return this.sdkApi.cardAnimation;
|
|
5525
|
+
}
|
|
5526
|
+
updateCardServerDataLocally(cardId, data) {
|
|
5527
|
+
this.sdkApi.updateCardServerDataLocally(cardId, data);
|
|
5528
|
+
}
|
|
5529
|
+
get isExistsShowNextCard() {
|
|
5530
|
+
return this.sdkApi.isExistsShowNextCard;
|
|
5531
|
+
}
|
|
5532
|
+
cardShowNext() {
|
|
5533
|
+
this.sdkApi.cardShowNext();
|
|
5534
|
+
}
|
|
5535
|
+
/** @deprecated, used only in native sdk **/
|
|
5536
|
+
cardPausedCallback(currentTime) {
|
|
5537
|
+
this.sdkApi.cardPausedCallback(currentTime);
|
|
5538
|
+
}
|
|
5539
|
+
/** @deprecated, used only in native sdk **/
|
|
5540
|
+
cardResumedCallback(currentTime) {
|
|
5541
|
+
this.sdkApi.cardResumedCallback(currentTime);
|
|
5542
|
+
}
|
|
5543
|
+
disableHorizontalSwipeGesture() {
|
|
5544
|
+
this.sdkApi.disableHorizontalSwipeGesture();
|
|
5545
|
+
}
|
|
5546
|
+
enableHorizontalSwipeGesture() {
|
|
5547
|
+
this.sdkApi.enableHorizontalSwipeGesture();
|
|
5548
|
+
}
|
|
5549
|
+
isExistsShowLayer() {
|
|
5550
|
+
return this.sdkApi.isExistsShowLayer();
|
|
5551
|
+
}
|
|
5552
|
+
showLayer(index) {
|
|
5553
|
+
this.sdkApi.showLayer(index);
|
|
5554
|
+
}
|
|
5555
|
+
/**
|
|
5556
|
+
* For single slide mode - proxy these methods via SDKApi
|
|
5557
|
+
* =================================================================================================================
|
|
5558
|
+
*/
|
|
5559
|
+
get isExistsShowCardSlide() {
|
|
5560
|
+
return true;
|
|
5561
|
+
}
|
|
5562
|
+
showCardSlide(index) {
|
|
5563
|
+
this.slider.showByIndex(index);
|
|
5564
|
+
}
|
|
5565
|
+
updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError) {
|
|
5566
|
+
this.slider.updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError);
|
|
5567
|
+
}
|
|
5568
|
+
isSdkSupportTimelineOnBeforeStart() {
|
|
5569
|
+
return true;
|
|
5570
|
+
}
|
|
5571
|
+
isSdkSupportCorrectPauseResumeLifecycle() {
|
|
5572
|
+
return true;
|
|
5573
|
+
}
|
|
5574
|
+
showNextSlide(duration) {
|
|
5575
|
+
this.slider.showNextSlide();
|
|
5576
|
+
}
|
|
5577
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`SDKApi`, `ISlider`]; }
|
|
4986
5578
|
}
|
|
4987
5579
|
|
|
4988
|
-
class
|
|
5580
|
+
class SlideApiDepsSingleSlideMode {
|
|
4989
5581
|
sdkApi;
|
|
4990
|
-
constructor(sdkApi
|
|
5582
|
+
constructor(sdkApi) {
|
|
4991
5583
|
this.sdkApi = sdkApi;
|
|
4992
|
-
|
|
4993
|
-
|
|
5584
|
+
}
|
|
5585
|
+
getWidgetsSharedData(cardId, widget) {
|
|
5586
|
+
return this.sdkApi.getWidgetsSharedData(cardId, widget);
|
|
5587
|
+
}
|
|
5588
|
+
showToast(text) {
|
|
5589
|
+
return this.sdkApi.showToast(text);
|
|
5590
|
+
}
|
|
5591
|
+
writeToClipboard(data) {
|
|
5592
|
+
return this.sdkApi.writeToClipboard(data);
|
|
5593
|
+
}
|
|
5594
|
+
get isExistsShare() {
|
|
5595
|
+
return this.sdkApi.isExistsShare;
|
|
5596
|
+
}
|
|
5597
|
+
share(id, config) {
|
|
5598
|
+
this.sdkApi.share(id, config);
|
|
5599
|
+
}
|
|
5600
|
+
get sdkCanSendShareComplete() {
|
|
5601
|
+
return this.sdkApi.sdkCanSendShareComplete;
|
|
5602
|
+
}
|
|
5603
|
+
shareSlideScreenshot(shareId, hideElementsSelector, shareText) {
|
|
5604
|
+
this.sdkApi.shareSlideScreenshot(shareId, hideElementsSelector, shareText);
|
|
5605
|
+
}
|
|
5606
|
+
setCardSessionValue(element, key, value) {
|
|
5607
|
+
this.sdkApi.setCardSessionValue(element, key, value);
|
|
5608
|
+
}
|
|
5609
|
+
getCardSessionValue(element, key) {
|
|
5610
|
+
return this.sdkApi.getCardSessionValue(element, key);
|
|
5611
|
+
}
|
|
5612
|
+
getCardFonts() {
|
|
5613
|
+
return this.sdkApi.getCardFonts();
|
|
5614
|
+
}
|
|
5615
|
+
disableVerticalSwipeGesture() {
|
|
5616
|
+
this.sdkApi.disableVerticalSwipeGesture();
|
|
5617
|
+
}
|
|
5618
|
+
enableVerticalSwipeGesture() {
|
|
5619
|
+
this.sdkApi.enableVerticalSwipeGesture();
|
|
5620
|
+
}
|
|
5621
|
+
disableBackpress() {
|
|
5622
|
+
this.sdkApi.disableBackpress();
|
|
5623
|
+
}
|
|
5624
|
+
enableBackpress() {
|
|
5625
|
+
this.sdkApi.enableBackpress();
|
|
5626
|
+
}
|
|
5627
|
+
closeCard(reason) {
|
|
5628
|
+
this.sdkApi.closeCard(reason);
|
|
5629
|
+
}
|
|
5630
|
+
openStory(id, index) {
|
|
5631
|
+
// TODO rewrite with Promise - for usage story loading states in Button
|
|
5632
|
+
this.sdkApi.openStory(id, index);
|
|
5633
|
+
}
|
|
5634
|
+
openGame(gameInstanceId) {
|
|
5635
|
+
// TODO rewrite with Promise - for usage game loading states in Button
|
|
5636
|
+
this.sdkApi.openGame(gameInstanceId);
|
|
5637
|
+
}
|
|
5638
|
+
openUrl(data) {
|
|
5639
|
+
this.sdkApi.openUrl(data);
|
|
5640
|
+
}
|
|
5641
|
+
get isAndroid() {
|
|
5642
|
+
return this.sdkApi.isAndroid;
|
|
5643
|
+
}
|
|
5644
|
+
get isWeb() {
|
|
5645
|
+
return this.sdkApi.isWeb;
|
|
5646
|
+
}
|
|
5647
|
+
get isIOS() {
|
|
5648
|
+
return this.sdkApi.isIOS;
|
|
5649
|
+
}
|
|
5650
|
+
get isExistsShowCardTextInput() {
|
|
5651
|
+
return this.sdkApi.isExistsShowCardTextInput;
|
|
5652
|
+
}
|
|
5653
|
+
showCardTextInput(id, data) {
|
|
5654
|
+
this.sdkApi.showCardTextInput(id, data);
|
|
5655
|
+
}
|
|
5656
|
+
vibrate(pattern) {
|
|
5657
|
+
this.sdkApi.vibrate(pattern);
|
|
5658
|
+
}
|
|
5659
|
+
sendApiRequest(url, method, params, headers, data, profilingKey) {
|
|
5660
|
+
return this.sdkApi.sendApiRequest(url, method, params, headers, data, profilingKey);
|
|
5661
|
+
}
|
|
5662
|
+
sendStatisticEvent(name, data, devPayload, forceEnableStatisticV2) {
|
|
5663
|
+
this.sdkApi.sendStatisticEvent(name, data, devPayload, forceEnableStatisticV2);
|
|
5664
|
+
}
|
|
5665
|
+
setCardLocalData(keyValue, sendToServer) {
|
|
5666
|
+
this.sdkApi.setCardLocalData(keyValue, sendToServer);
|
|
5667
|
+
}
|
|
5668
|
+
getCardLocalData() {
|
|
5669
|
+
return this.sdkApi.getCardLocalData();
|
|
5670
|
+
}
|
|
5671
|
+
getCardServerData(cardId) {
|
|
5672
|
+
return this.sdkApi.getCardServerData(cardId);
|
|
5673
|
+
}
|
|
5674
|
+
get cardAnimation() {
|
|
5675
|
+
return this.sdkApi.cardAnimation;
|
|
5676
|
+
}
|
|
5677
|
+
updateCardServerDataLocally(cardId, data) {
|
|
5678
|
+
this.sdkApi.updateCardServerDataLocally(cardId, data);
|
|
5679
|
+
}
|
|
5680
|
+
get isExistsShowNextCard() {
|
|
5681
|
+
return this.sdkApi.isExistsShowNextCard;
|
|
5682
|
+
}
|
|
5683
|
+
cardShowNext() {
|
|
5684
|
+
this.sdkApi.cardShowNext();
|
|
5685
|
+
}
|
|
5686
|
+
/** @deprecated, used only in native sdk **/
|
|
5687
|
+
cardPausedCallback(currentTime) {
|
|
5688
|
+
this.sdkApi.cardPausedCallback(currentTime);
|
|
5689
|
+
}
|
|
5690
|
+
/** @deprecated, used only in native sdk **/
|
|
5691
|
+
cardResumedCallback(currentTime) {
|
|
5692
|
+
this.sdkApi.cardResumedCallback(currentTime);
|
|
5693
|
+
}
|
|
5694
|
+
disableHorizontalSwipeGesture() {
|
|
5695
|
+
this.sdkApi.disableHorizontalSwipeGesture();
|
|
5696
|
+
}
|
|
5697
|
+
enableHorizontalSwipeGesture() {
|
|
5698
|
+
this.sdkApi.enableHorizontalSwipeGesture();
|
|
5699
|
+
}
|
|
5700
|
+
isExistsShowLayer() {
|
|
5701
|
+
return this.sdkApi.isExistsShowLayer();
|
|
5702
|
+
}
|
|
5703
|
+
showLayer(index) {
|
|
5704
|
+
this.sdkApi.showLayer(index);
|
|
5705
|
+
}
|
|
5706
|
+
/**
|
|
5707
|
+
* For single slide mode - proxy these methods via SDKApi
|
|
5708
|
+
*/
|
|
5709
|
+
get isExistsShowCardSlide() {
|
|
5710
|
+
return this.sdkApi.isExistsShowCardSlide;
|
|
5711
|
+
}
|
|
5712
|
+
showCardSlide(index) {
|
|
5713
|
+
this.sdkApi.showCardSlide(index);
|
|
5714
|
+
}
|
|
5715
|
+
updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError) {
|
|
5716
|
+
this.sdkApi.updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError);
|
|
5717
|
+
}
|
|
5718
|
+
isSdkSupportTimelineOnBeforeStart() {
|
|
5719
|
+
return this.sdkApi.isSdkSupportTimelineOnBeforeStart();
|
|
5720
|
+
}
|
|
5721
|
+
isSdkSupportCorrectPauseResumeLifecycle() {
|
|
5722
|
+
return this.sdkApi.isSdkSupportCorrectPauseResumeLifecycle();
|
|
5723
|
+
}
|
|
5724
|
+
showNextSlide(duration) {
|
|
5725
|
+
this.sdkApi.showNextSlide(duration);
|
|
5726
|
+
}
|
|
5727
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`SDKApi`]; }
|
|
5728
|
+
}
|
|
5729
|
+
|
|
5730
|
+
class SlideTimer {
|
|
5731
|
+
requestStartTimer;
|
|
5732
|
+
requestCancelTimer;
|
|
5733
|
+
updateCb;
|
|
5734
|
+
doneCb;
|
|
5735
|
+
constructor(requestStartTimer, requestCancelTimer, updateCb, doneCb) {
|
|
5736
|
+
this.requestStartTimer = requestStartTimer;
|
|
5737
|
+
this.requestCancelTimer = requestCancelTimer;
|
|
5738
|
+
this.updateCb = updateCb;
|
|
5739
|
+
this.doneCb = doneCb;
|
|
5740
|
+
}
|
|
5741
|
+
duration;
|
|
5742
|
+
timeLeft;
|
|
5743
|
+
_pause = true;
|
|
5744
|
+
_stop = true;
|
|
5745
|
+
_started = false;
|
|
5746
|
+
start(duration) {
|
|
5747
|
+
this.duration = duration;
|
|
5748
|
+
this.stop();
|
|
5749
|
+
this.timeLeft = this.duration;
|
|
5750
|
+
this._pause = false;
|
|
5751
|
+
this._stop = false;
|
|
5752
|
+
this._started = true;
|
|
5753
|
+
this.tick();
|
|
5754
|
+
}
|
|
5755
|
+
stop() {
|
|
5756
|
+
this._stop = true;
|
|
5757
|
+
this._started = false;
|
|
5758
|
+
if (this.timerId != null) {
|
|
5759
|
+
this.requestCancelTimer(this.timerId);
|
|
5760
|
+
this.timerId = null;
|
|
5761
|
+
}
|
|
5762
|
+
// this.updateCb(0);
|
|
5763
|
+
}
|
|
5764
|
+
pause() {
|
|
5765
|
+
this._pause = true;
|
|
5766
|
+
if (this.timerId != null) {
|
|
5767
|
+
this.requestCancelTimer(this.timerId);
|
|
5768
|
+
this.timerId = null;
|
|
5769
|
+
}
|
|
5770
|
+
}
|
|
5771
|
+
resume(duration = 0) {
|
|
5772
|
+
this._pause = false;
|
|
5773
|
+
if (!this._started) {
|
|
5774
|
+
this.start(duration);
|
|
5775
|
+
}
|
|
5776
|
+
else {
|
|
5777
|
+
this.tick();
|
|
5778
|
+
}
|
|
5779
|
+
}
|
|
5780
|
+
timerId;
|
|
5781
|
+
tick() {
|
|
5782
|
+
if (this._stop) {
|
|
5783
|
+
return;
|
|
5784
|
+
}
|
|
5785
|
+
const rafStartTime = new Date().getTime();
|
|
5786
|
+
this.timerId = this.requestStartTimer(() => {
|
|
5787
|
+
if (this._stop) {
|
|
5788
|
+
return;
|
|
5789
|
+
}
|
|
5790
|
+
const dtDiff = new Date().getTime() - rafStartTime;
|
|
5791
|
+
this.timeLeft -= dtDiff;
|
|
5792
|
+
let progress = Math.round(((this.duration - this.timeLeft) / this.duration) * 100 * 10000) / 10000;
|
|
5793
|
+
if (progress > 100) {
|
|
5794
|
+
progress = 100;
|
|
5795
|
+
}
|
|
5796
|
+
this.updateCb(progress);
|
|
5797
|
+
if (progress < 100) {
|
|
5798
|
+
if (this._pause !== true) {
|
|
5799
|
+
this.tick();
|
|
5800
|
+
}
|
|
5801
|
+
}
|
|
5802
|
+
else {
|
|
5803
|
+
this.doneCb();
|
|
5804
|
+
}
|
|
5805
|
+
});
|
|
5806
|
+
}
|
|
5807
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`(callback: () => void) => number`, `(timerId: number) => void`, `(progress: number) => void`, `() => void`]; }
|
|
5808
|
+
}
|
|
5809
|
+
|
|
5810
|
+
class Slider {
|
|
5811
|
+
config;
|
|
5812
|
+
constructor(config) {
|
|
5813
|
+
this.config = config;
|
|
5814
|
+
for (let i = 0; i < config.slides.length; ++i) {
|
|
5815
|
+
const item = {
|
|
5816
|
+
called: false,
|
|
5817
|
+
firstRenderCall: null,
|
|
5818
|
+
firstRenderCallPromise: null,
|
|
5819
|
+
};
|
|
5820
|
+
item.firstRenderCallPromise = new Promise(resolver => {
|
|
5821
|
+
item.firstRenderCall = resolver;
|
|
5822
|
+
});
|
|
5823
|
+
this.slidesFirstRenders[i] = item;
|
|
5824
|
+
}
|
|
5825
|
+
const slideWrapper = this.createSliderElement({
|
|
5826
|
+
slides: config.slides,
|
|
5827
|
+
nonce: config.nonce,
|
|
5828
|
+
slideRender: config.slideRender,
|
|
5829
|
+
});
|
|
4994
5830
|
config.root.appendChild(slideWrapper);
|
|
5831
|
+
this.slideWrapperElement = slideWrapper;
|
|
4995
5832
|
// cardMounted: (card: HTMLElement) => Promise<void>
|
|
4996
5833
|
requestAnimationFrame(async () => {
|
|
4997
|
-
|
|
4998
|
-
await config.onCardMounted(this.cardsElements[i], i);
|
|
4999
|
-
}
|
|
5834
|
+
await Promise.all(this.slides.map((slide, index) => config.onSlideMounted(slide.element, index)));
|
|
5000
5835
|
});
|
|
5001
5836
|
}
|
|
5002
|
-
|
|
5837
|
+
isAnimating = false;
|
|
5838
|
+
activeIndex = -1;
|
|
5839
|
+
get activeSlide() {
|
|
5840
|
+
return this.slides[this.activeIndex];
|
|
5841
|
+
}
|
|
5842
|
+
slides = [];
|
|
5003
5843
|
sliderTrack = null;
|
|
5004
|
-
|
|
5844
|
+
bulletsContainer = null;
|
|
5845
|
+
slidesFirstRenders = [];
|
|
5846
|
+
slideWrapperElement;
|
|
5847
|
+
updateBulletActiveIndex;
|
|
5848
|
+
updateTimelineProgress;
|
|
5849
|
+
createSliderElement = ({ slides, nonce, slideRender }) => {
|
|
5005
5850
|
const style = document.createElement("style");
|
|
5006
5851
|
if (nonce != null) {
|
|
5007
5852
|
style.nonce = nonce;
|
|
@@ -5015,35 +5860,255 @@ class CardsSlider {
|
|
|
5015
5860
|
const slide = document.createElement("div");
|
|
5016
5861
|
slide.classList.add("cards-slider__slide");
|
|
5017
5862
|
slide.setAttribute("data-index", String(i));
|
|
5018
|
-
this.
|
|
5019
|
-
|
|
5863
|
+
this.slides[i] = {
|
|
5864
|
+
element: slideRender(slides[i], i, this.slidesFirstRenders[i].firstRenderCallPromise),
|
|
5865
|
+
timer: new SlideTimer(cb => window.requestAnimationFrame(cb), handle => window.cancelAnimationFrame(handle), this.onSlideTimerUpdate.bind(this), this.onSlideTimerEnd.bind(this)),
|
|
5866
|
+
};
|
|
5867
|
+
slide.appendChild(this.slides[i].element);
|
|
5020
5868
|
track.appendChild(slide);
|
|
5021
5869
|
}
|
|
5022
|
-
const bullets =
|
|
5023
|
-
bullets
|
|
5870
|
+
const [bullets, updateBulletActiveIndex, updateTimelineProgress] = this.createBulletPoints(slides.length);
|
|
5871
|
+
this.bulletsContainer = bullets;
|
|
5872
|
+
this.updateBulletActiveIndex = updateBulletActiveIndex.bind(this);
|
|
5873
|
+
this.updateTimelineProgress = updateTimelineProgress.bind(this);
|
|
5024
5874
|
slider.appendChild(track);
|
|
5025
5875
|
slider.appendChild(bullets);
|
|
5026
5876
|
slider.appendChild(style);
|
|
5027
5877
|
return slider;
|
|
5028
5878
|
};
|
|
5029
|
-
|
|
5030
|
-
const
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5879
|
+
createBulletPoints(count) {
|
|
5880
|
+
const bullets = document.createElement("div");
|
|
5881
|
+
bullets.classList.toggle("cards-slider__bullets");
|
|
5882
|
+
for (let i = 0; i < count; ++i) {
|
|
5883
|
+
const bullet = document.createElement("div");
|
|
5884
|
+
bullet.classList.add("cards-slider__bullet");
|
|
5885
|
+
bullet.setAttribute("data-index", String(i));
|
|
5886
|
+
bullet.onclick = (e) => {
|
|
5887
|
+
e.stopPropagation();
|
|
5888
|
+
e.preventDefault();
|
|
5889
|
+
const bullet = e.target;
|
|
5890
|
+
if (bullet != null) {
|
|
5891
|
+
const index = bullet.dataset.index;
|
|
5892
|
+
if (index != null) {
|
|
5893
|
+
this.showByIndex(parseInt(index));
|
|
5894
|
+
}
|
|
5895
|
+
}
|
|
5896
|
+
};
|
|
5897
|
+
const bulletFill = document.createElement("div");
|
|
5898
|
+
bulletFill.classList.add("cards-slider__bullet-fill");
|
|
5899
|
+
bullet.append(bulletFill);
|
|
5900
|
+
bullets.appendChild(bullet);
|
|
5901
|
+
}
|
|
5902
|
+
const onUpdateActiveIndex = (activeIndex) => {
|
|
5903
|
+
if (activeIndex >= 0 && activeIndex < count) {
|
|
5904
|
+
for (const bullet of bullets.querySelectorAll(".cards-slider__bullet--active")) {
|
|
5905
|
+
bullet.classList.toggle("cards-slider__bullet--active");
|
|
5906
|
+
}
|
|
5907
|
+
bullets.querySelector(`.cards-slider__bullet[data-index="${activeIndex}"]`)?.classList.toggle("cards-slider__bullet--active");
|
|
5908
|
+
}
|
|
5909
|
+
};
|
|
5910
|
+
const onUpdateTimelineProgress = (index, progress) => {
|
|
5911
|
+
if (index >= 0 && index < count) {
|
|
5912
|
+
const bullet = bullets.querySelector(`.cards-slider__bullet:nth-child(${index + 1}) .cards-slider__bullet-fill`);
|
|
5913
|
+
if (bullet != null) {
|
|
5914
|
+
// todo RTL
|
|
5915
|
+
//need (in css) right: 100% instead of left -100%;
|
|
5916
|
+
// todo remove progress after slide changed?
|
|
5917
|
+
bullet.style.setProperty("transform", `translateX(${progress}%)`);
|
|
5918
|
+
// transform: `translateZ(0) translateX(${
|
|
5919
|
+
// index < this.$props.index
|
|
5920
|
+
// ? "100%"
|
|
5921
|
+
// : index === this.$props.index
|
|
5922
|
+
// ? `${this.$props.timePercent}%`
|
|
5923
|
+
// : "0%"
|
|
5924
|
+
// })`,
|
|
5925
|
+
}
|
|
5926
|
+
}
|
|
5927
|
+
};
|
|
5928
|
+
return [bullets, onUpdateActiveIndex, onUpdateTimelineProgress];
|
|
5929
|
+
}
|
|
5930
|
+
async showByIndex(newIndex) {
|
|
5931
|
+
const prevIndex = this.activeIndex;
|
|
5932
|
+
if (this.isAnimating)
|
|
5933
|
+
return prevIndex;
|
|
5934
|
+
if (prevIndex !== -1) {
|
|
5935
|
+
// skip for slider start
|
|
5936
|
+
this.config.onSlideLeft(this.slides[prevIndex].element, prevIndex);
|
|
5937
|
+
this.config.onSlideStop();
|
|
5938
|
+
}
|
|
5939
|
+
const { index, loadingError } = await this.initAndRenderSlide(newIndex);
|
|
5940
|
+
if (loadingError) {
|
|
5941
|
+
// todo via updateTimeline ????
|
|
5942
|
+
this.config.onSlideLoadingError(index, loadingError);
|
|
5943
|
+
}
|
|
5944
|
+
await this.slideTo(index);
|
|
5945
|
+
if (!loadingError) {
|
|
5946
|
+
this.onShowSlide(index);
|
|
5947
|
+
}
|
|
5948
|
+
return newIndex;
|
|
5949
|
+
}
|
|
5950
|
+
async showNextSlide() {
|
|
5951
|
+
const prevIndex = this.activeIndex;
|
|
5952
|
+
if (this.isAnimating)
|
|
5953
|
+
return prevIndex;
|
|
5954
|
+
const newIndex = prevIndex + 1;
|
|
5955
|
+
if (newIndex < 0 || newIndex >= this.slides.length) {
|
|
5956
|
+
return null;
|
|
5957
|
+
}
|
|
5958
|
+
if (prevIndex !== -1) {
|
|
5959
|
+
// skip for slider start
|
|
5960
|
+
this.config.onSlideLeft(this.slides[prevIndex].element, prevIndex);
|
|
5961
|
+
this.config.onSlideStop();
|
|
5962
|
+
}
|
|
5963
|
+
const { index, loadingError } = await this.initAndRenderSlide(newIndex);
|
|
5964
|
+
if (loadingError) {
|
|
5965
|
+
// todo via updateTimeline ????
|
|
5966
|
+
this.config.onSlideLoadingError(index, loadingError);
|
|
5967
|
+
}
|
|
5968
|
+
await this.slideTo(index);
|
|
5969
|
+
if (!loadingError) {
|
|
5970
|
+
this.onShowSlide(index);
|
|
5971
|
+
}
|
|
5972
|
+
return newIndex;
|
|
5973
|
+
}
|
|
5974
|
+
async initAndRenderSlide(index) {
|
|
5975
|
+
this.config.onBeforeLoadSlide(index);
|
|
5976
|
+
let showSlidePromise;
|
|
5977
|
+
if (!this.slidesFirstRenders[index].called) {
|
|
5978
|
+
// first render call
|
|
5979
|
+
this.slidesFirstRenders[index].called = true;
|
|
5980
|
+
showSlidePromise = new Promise(resolve => {
|
|
5981
|
+
this.slidesFirstRenders[index].firstRenderCall(resolve);
|
|
5982
|
+
}).then(_ => _);
|
|
5983
|
+
}
|
|
5984
|
+
else {
|
|
5985
|
+
showSlidePromise = this.config.onBeforeShowSlide(this.slides[index].element, index);
|
|
5986
|
+
}
|
|
5987
|
+
try {
|
|
5988
|
+
const { moveToIndex } = await showSlidePromise;
|
|
5989
|
+
if (moveToIndex !== index) {
|
|
5990
|
+
index = moveToIndex;
|
|
5991
|
+
// jump to necessary slide (from WidgetQuest for instance)
|
|
5992
|
+
return this.initAndRenderSlide(index);
|
|
5993
|
+
}
|
|
5994
|
+
else {
|
|
5995
|
+
return { index, loadingError: undefined };
|
|
5996
|
+
}
|
|
5997
|
+
}
|
|
5998
|
+
catch (loadingError) {
|
|
5999
|
+
// catch loading error
|
|
6000
|
+
// this.config.onSlideLoadingError(index, e as string);
|
|
6001
|
+
console.error(loadingError);
|
|
6002
|
+
return { index, loadingError: loadingError };
|
|
6003
|
+
}
|
|
6004
|
+
}
|
|
6005
|
+
onShowSlide(index) {
|
|
6006
|
+
this.updateBulletActiveIndex(index);
|
|
6007
|
+
this.config.onShowSlide(this.slides[index].element, index);
|
|
6008
|
+
this.config.onSlideStart();
|
|
5044
6009
|
}
|
|
5045
|
-
|
|
5046
|
-
|
|
6010
|
+
onUpdateSizeMetrics(metrics) {
|
|
6011
|
+
// this.slideTo(this.activeIndex, 0);
|
|
6012
|
+
}
|
|
6013
|
+
getSlideOffset(index) {
|
|
6014
|
+
if (!this.slides.length)
|
|
6015
|
+
return 0;
|
|
6016
|
+
const k = this.config.getLayoutDirection() === "ltr" ? -1 : 1;
|
|
6017
|
+
const cardWidth = this.slides[0].element.clientWidth;
|
|
6018
|
+
return k * index * cardWidth;
|
|
6019
|
+
}
|
|
6020
|
+
async slideTo(index, speed = 300) {
|
|
6021
|
+
if (index < 0 || index > this.slides.length - 1 || this.isAnimating)
|
|
6022
|
+
return;
|
|
6023
|
+
const cardOffset = this.getSlideOffset(index);
|
|
6024
|
+
await this.translateTo(cardOffset, speed);
|
|
6025
|
+
this.activeIndex = index;
|
|
6026
|
+
}
|
|
6027
|
+
setTranslate(value) {
|
|
6028
|
+
this.sliderTrack?.style.setProperty("transform", `translateX(${value}px)`);
|
|
6029
|
+
}
|
|
6030
|
+
setTransition(duration = 300) {
|
|
6031
|
+
this.sliderTrack?.style.setProperty("transition", `transform ${duration}ms`);
|
|
6032
|
+
}
|
|
6033
|
+
async translateTo(translate, speed) {
|
|
6034
|
+
if (this.isAnimating)
|
|
6035
|
+
return;
|
|
6036
|
+
this.setTransition(speed);
|
|
6037
|
+
this.setTranslate(translate);
|
|
6038
|
+
if (speed > 0) {
|
|
6039
|
+
this.isAnimating = true;
|
|
6040
|
+
await this.waitTransitionEnd();
|
|
6041
|
+
this.isAnimating = false;
|
|
6042
|
+
}
|
|
6043
|
+
}
|
|
6044
|
+
waitTransitionEnd() {
|
|
6045
|
+
const sliderTrack = this.sliderTrack;
|
|
6046
|
+
if (!sliderTrack)
|
|
6047
|
+
return Promise.resolve();
|
|
6048
|
+
return new Promise(resolve => {
|
|
6049
|
+
const handler = (e) => {
|
|
6050
|
+
if (e.propertyName === "transform") {
|
|
6051
|
+
sliderTrack.style.transitionDuration = "0ms";
|
|
6052
|
+
resolve();
|
|
6053
|
+
}
|
|
6054
|
+
};
|
|
6055
|
+
sliderTrack.addEventListener("transitionend", handler, { once: true });
|
|
6056
|
+
});
|
|
6057
|
+
}
|
|
6058
|
+
destroy() {
|
|
6059
|
+
this.activeSlide?.timer.stop();
|
|
6060
|
+
if (this.slideWrapperElement != null && this.config.root != null) {
|
|
6061
|
+
this.config.root.removeChild(this.slideWrapperElement);
|
|
6062
|
+
}
|
|
6063
|
+
}
|
|
6064
|
+
updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError) {
|
|
6065
|
+
switch (action) {
|
|
6066
|
+
case "before_start" /* TIMELINE_ACTION.BEFORE_START */: {
|
|
6067
|
+
// switch timeline to active slide and wait for start (wait VOD loading)
|
|
6068
|
+
console.log("TIMELINE_ACTION.BEFORE_START", { activeSlide: this.activeSlide, duration });
|
|
6069
|
+
break;
|
|
6070
|
+
}
|
|
6071
|
+
case "start" /* TIMELINE_ACTION.START */: {
|
|
6072
|
+
this.config.onSlideDataResume();
|
|
6073
|
+
// also start after data waiting or pause
|
|
6074
|
+
// window.setTimeout(() => {
|
|
6075
|
+
// this.config.onSlideStop();
|
|
6076
|
+
// this.config.onSlideTimerEnd();
|
|
6077
|
+
// }, 10000);
|
|
6078
|
+
// destroy on IAM closing
|
|
6079
|
+
console.log("TIMELINE_ACTION.START", { activeSlide: this.activeSlide, index: this.activeIndex, duration });
|
|
6080
|
+
this.activeSlide?.timer.resume(duration);
|
|
6081
|
+
break;
|
|
6082
|
+
}
|
|
6083
|
+
case "pause" /* TIMELINE_ACTION.PAUSE */: {
|
|
6084
|
+
if (showLoader) {
|
|
6085
|
+
this.config.onSlideDataWaiting();
|
|
6086
|
+
}
|
|
6087
|
+
this.activeSlide?.timer.pause();
|
|
6088
|
+
console.log("TIMELINE_ACTION.PAUSE", { activeSlide: this.activeSlide, duration });
|
|
6089
|
+
break;
|
|
6090
|
+
}
|
|
6091
|
+
case "stop" /* TIMELINE_ACTION.STOP */: {
|
|
6092
|
+
// loading error
|
|
6093
|
+
if (showError) {
|
|
6094
|
+
this.config.onSlideDataError();
|
|
6095
|
+
}
|
|
6096
|
+
this.activeSlide?.timer.stop();
|
|
6097
|
+
// todo нужен STOP когда вручную переключаем слайд на другой
|
|
6098
|
+
console.log("TIMELINE_ACTION.STOP", { activeSlide: this.activeSlide, duration });
|
|
6099
|
+
break;
|
|
6100
|
+
}
|
|
6101
|
+
}
|
|
6102
|
+
}
|
|
6103
|
+
onSlideTimerUpdate(progress) {
|
|
6104
|
+
this.updateTimelineProgress(this.activeIndex, progress);
|
|
6105
|
+
}
|
|
6106
|
+
onSlideTimerEnd() {
|
|
6107
|
+
this.config.onSlideStop();
|
|
6108
|
+
this.config.onSlideTimerEnd();
|
|
6109
|
+
}
|
|
6110
|
+
static get [Symbol.for("___CTOR_ARGS___")]() { return [`{
|
|
6111
|
+
slides: Array<T>;
|
|
5047
6112
|
root: HTMLElement;
|
|
5048
6113
|
// isFullscreen: boolean;
|
|
5049
6114
|
nonce?: string;
|
|
@@ -5051,15 +6116,28 @@ class CardsSlider {
|
|
|
5051
6116
|
// userResizeHandler?: (data: { viewportWidth: number; viewportHeight: number; fontSize: number }) => void;
|
|
5052
6117
|
// VODPlayer?: typeof VODPlayer;
|
|
5053
6118
|
// overlappingActionBarHeight?: number;
|
|
5054
|
-
|
|
5055
|
-
|
|
6119
|
+
slideRender: SlideRender<T>;
|
|
6120
|
+
onSlideMounted: OnSlideMounted;
|
|
6121
|
+
onBeforeShowSlide: OnBeforeShowSlide;
|
|
6122
|
+
onBeforeLoadSlide: OnBeforeLoadSlide;
|
|
6123
|
+
onSlideLoadingError: OnSlideLoadingError;
|
|
6124
|
+
onShowSlide: OnShowSlide;
|
|
6125
|
+
onSlideLeft: OnSlideLeft;
|
|
6126
|
+
getLayoutDirection: GetLayoutDirection;
|
|
6127
|
+
|
|
6128
|
+
onSlideTimerEnd: OnSlideTimerEnd;
|
|
6129
|
+
onSlideStart: OnSlideStart;
|
|
6130
|
+
onSlideStop: OnSlideStop;
|
|
6131
|
+
onSlideDataWaiting: OnSlideDataWaiting;
|
|
6132
|
+
onSlideDataResume: OnSlideDataResume;
|
|
6133
|
+
onSlideDataError: OnSlideDataError;
|
|
5056
6134
|
}`]; }
|
|
5057
6135
|
}
|
|
5058
6136
|
|
|
5059
|
-
|
|
6137
|
+
class CardApi {
|
|
5060
6138
|
config;
|
|
5061
6139
|
get layoutDirection() {
|
|
5062
|
-
return this.
|
|
6140
|
+
return this.activeSlide.layoutDirection;
|
|
5063
6141
|
}
|
|
5064
6142
|
static renderedBoxClassName = "narrative-slide-box-rendered";
|
|
5065
6143
|
static prerenderBoxClassName = "narrative-slide-box-prerender";
|
|
@@ -5069,10 +6147,18 @@ let SlideApi$1 = class SlideApi {
|
|
|
5069
6147
|
_getViewportHeight;
|
|
5070
6148
|
_overlappingActionBarHeight;
|
|
5071
6149
|
_separateUserAndAppPause;
|
|
6150
|
+
_useSdkCacheForMultislideMode;
|
|
5072
6151
|
sdkApi;
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
6152
|
+
activeSlide = null;
|
|
6153
|
+
slides = [];
|
|
6154
|
+
slidesMode = 0 /* SLIDES_MODE.SINGLE */;
|
|
6155
|
+
sizeMetrics = {
|
|
6156
|
+
fontSize: "0px",
|
|
6157
|
+
isFullscreen: false,
|
|
6158
|
+
slideOffsetMargin: "0px",
|
|
6159
|
+
xOffset: "0px",
|
|
6160
|
+
yOffset: "0px",
|
|
6161
|
+
};
|
|
5076
6162
|
constructor(config) {
|
|
5077
6163
|
this.config = config;
|
|
5078
6164
|
this.sdkApi = config.sdkApi;
|
|
@@ -5082,12 +6168,14 @@ let SlideApi$1 = class SlideApi {
|
|
|
5082
6168
|
this._getViewportHeight = config.getViewportHeight;
|
|
5083
6169
|
this._overlappingActionBarHeight = config.overlappingActionBarHeight ?? 0;
|
|
5084
6170
|
this._separateUserAndAppPause = config.separateUserAndAppPause;
|
|
6171
|
+
this._useSdkCacheForMultislideMode = config.useSdkCacheForMultislideMode;
|
|
5085
6172
|
this.refreshSizes = proxy(this.refreshSizes, this);
|
|
5086
6173
|
this.getSdkClientVariables = proxy(this.getSdkClientVariables, this);
|
|
5087
|
-
|
|
5088
|
-
//
|
|
5089
|
-
|
|
5090
|
-
|
|
6174
|
+
this.refreshSizes();
|
|
6175
|
+
// todo - возможность не создавать slideApi в ctor (это не нужно для multislide mode)
|
|
6176
|
+
// но тогда все методы должны обходить случай когда activeSlide undefined
|
|
6177
|
+
this.activeSlide = new SlideApi$1({
|
|
6178
|
+
slideApiDeps: new SlideApiDepsSingleSlideMode(this.config.sdkApi),
|
|
5091
6179
|
slideWrapper: this.config.slideWrapper,
|
|
5092
6180
|
viewport: this.config.viewport,
|
|
5093
6181
|
userResizeHandler: this.config.userResizeHandler,
|
|
@@ -5098,32 +6186,36 @@ let SlideApi$1 = class SlideApi {
|
|
|
5098
6186
|
overlappingActionBarHeight: this.config.overlappingActionBarHeight,
|
|
5099
6187
|
separateUserAndAppPause: this.config.separateUserAndAppPause,
|
|
5100
6188
|
root: this.config.root,
|
|
5101
|
-
refreshSizes: this.refreshSizes,
|
|
5102
6189
|
index: 0,
|
|
5103
6190
|
getSdkClientVariables: this.getSdkClientVariables,
|
|
5104
6191
|
});
|
|
5105
|
-
this.
|
|
6192
|
+
this.activeSlide.onUpdateSizeMetrics(this.sizeMetrics);
|
|
6193
|
+
if (SlideApi$1.checkPreloadedInLayoutSlide()) {
|
|
6194
|
+
this.activeSlide.initPreloadedInLayoutSlide(this.config.slideLoadedCb);
|
|
6195
|
+
}
|
|
5106
6196
|
this.initListeners();
|
|
5107
|
-
this.refreshSizes();
|
|
5108
6197
|
}
|
|
5109
6198
|
get state() {
|
|
5110
6199
|
// TODO remove usage from web-sdk
|
|
5111
|
-
return this.
|
|
6200
|
+
return this.activeSlide.state;
|
|
5112
6201
|
}
|
|
5113
6202
|
async destroy() {
|
|
5114
|
-
await this.
|
|
5115
|
-
await Promise.all(this.
|
|
5116
|
-
if (
|
|
5117
|
-
return
|
|
6203
|
+
await this.activeSlide.destroy();
|
|
6204
|
+
await Promise.all(this.slides.map(({ slide }) => {
|
|
6205
|
+
if (slide !== this.activeSlide) {
|
|
6206
|
+
return slide?.destroy();
|
|
5118
6207
|
}
|
|
5119
6208
|
}));
|
|
5120
6209
|
this.destroyListeners();
|
|
5121
6210
|
}
|
|
5122
6211
|
initListeners() {
|
|
6212
|
+
// @ts-ignore
|
|
5123
6213
|
this._viewport.addEventListener("resize", this.refreshSizes);
|
|
5124
6214
|
}
|
|
5125
6215
|
destroyListeners() {
|
|
6216
|
+
// @ts-ignore
|
|
5126
6217
|
this._viewport.removeEventListener("resize", this.refreshSizes);
|
|
6218
|
+
// todo call via activeSlide.refreshSizes
|
|
5127
6219
|
}
|
|
5128
6220
|
_savedViewportWidth = null;
|
|
5129
6221
|
_savedViewportHeight = null;
|
|
@@ -5141,12 +6233,10 @@ let SlideApi$1 = class SlideApi {
|
|
|
5141
6233
|
// _ratio = 310 / 480,
|
|
5142
6234
|
const _ratio = this.config.slideRatio;
|
|
5143
6235
|
let _isFullscreen = this.config.isFullscreen;
|
|
5144
|
-
const slideOffset = this.activeCard.slideOffsetElement;
|
|
5145
6236
|
let offset = 0;
|
|
5146
6237
|
let xOffset = "0px";
|
|
5147
6238
|
// for elements with bottom anchor (absolute position)
|
|
5148
6239
|
let yOffset = "0px";
|
|
5149
|
-
// alert(viewportHeight);
|
|
5150
6240
|
// todo - mobile only (or isIos or isAndroid)
|
|
5151
6241
|
if (this.sdkApi.isAndroid || this.sdkApi.isIOS) {
|
|
5152
6242
|
if (viewportRatio > _ratio) {
|
|
@@ -5154,6 +6244,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
5154
6244
|
_isFullscreen = false;
|
|
5155
6245
|
}
|
|
5156
6246
|
}
|
|
6247
|
+
let slideOffsetMargin = "";
|
|
5157
6248
|
if (_isFullscreen) {
|
|
5158
6249
|
// более квадратное чем надо (desktop)
|
|
5159
6250
|
if (viewportRatio > _ratio) {
|
|
@@ -5161,9 +6252,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
5161
6252
|
slideHeight = viewportHeight;
|
|
5162
6253
|
slideWidth = Math.ceil(slideHeight * _ratio);
|
|
5163
6254
|
offset = Math.ceil(slideWidth - viewportWidth) / 2;
|
|
5164
|
-
|
|
5165
|
-
slideOffset.style.margin = "0 " + -offset + "px"; // -8.5
|
|
5166
|
-
}
|
|
6255
|
+
slideOffsetMargin = "0 " + -offset + "px"; // -8.5
|
|
5167
6256
|
xOffset = offset + "px";
|
|
5168
6257
|
}
|
|
5169
6258
|
else {
|
|
@@ -5171,9 +6260,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
5171
6260
|
slideWidth = viewportWidth;
|
|
5172
6261
|
slideHeight = Math.ceil(viewportWidth / _ratio);
|
|
5173
6262
|
offset = Math.ceil(slideHeight - viewportHeight) / 2;
|
|
5174
|
-
|
|
5175
|
-
slideOffset.style.margin = -1 * offset + "px" + " 0 ";
|
|
5176
|
-
}
|
|
6263
|
+
slideOffsetMargin = -1 * offset + "px" + " 0 ";
|
|
5177
6264
|
// offset from viewport bottom to StoryBottom plus safe area offset bottom
|
|
5178
6265
|
yOffset = `calc(${offset + this._overlappingActionBarHeight}px + env(safe-area-inset-bottom))`;
|
|
5179
6266
|
// detect safe area offset
|
|
@@ -5186,9 +6273,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
5186
6273
|
slideWidth = viewportWidth;
|
|
5187
6274
|
slideHeight = Math.ceil(viewportWidth / _ratio);
|
|
5188
6275
|
offset = Math.ceil(slideHeight - viewportHeight) / 2;
|
|
5189
|
-
|
|
5190
|
-
slideOffset.style.margin = -offset + "px" + " 0 ";
|
|
5191
|
-
}
|
|
6276
|
+
slideOffsetMargin = -offset + "px" + " 0 ";
|
|
5192
6277
|
yOffset = offset + this._overlappingActionBarHeight + "px";
|
|
5193
6278
|
}
|
|
5194
6279
|
else {
|
|
@@ -5197,32 +6282,144 @@ let SlideApi$1 = class SlideApi {
|
|
|
5197
6282
|
slideHeight = viewportHeight;
|
|
5198
6283
|
slideWidth = Math.ceil(slideHeight * _ratio);
|
|
5199
6284
|
offset = Math.ceil(slideWidth - viewportWidth) / 2;
|
|
5200
|
-
|
|
5201
|
-
slideOffset.style.margin = "0 " + -offset + "px"; // -8.5
|
|
5202
|
-
}
|
|
6285
|
+
slideOffsetMargin = "0 " + -offset + "px"; // -8.5
|
|
5203
6286
|
xOffset = offset + "px";
|
|
5204
6287
|
}
|
|
5205
6288
|
}
|
|
5206
6289
|
const fontSizeNumber = slideWidth / 20;
|
|
5207
6290
|
const fontSize = `${fontSizeNumber}px`;
|
|
5208
|
-
|
|
5209
|
-
this.
|
|
5210
|
-
|
|
5211
|
-
|
|
6291
|
+
const sizeMetrics = { fontSize, xOffset, yOffset, isFullscreen: _isFullscreen, slideOffsetMargin };
|
|
6292
|
+
this.sizeMetrics = sizeMetrics;
|
|
6293
|
+
this.activeSlide?.onUpdateSizeMetrics(sizeMetrics);
|
|
6294
|
+
this.slides.forEach(({ slide }) => {
|
|
6295
|
+
if (slide !== this.activeSlide) {
|
|
6296
|
+
slide?.onUpdateSizeMetrics(sizeMetrics);
|
|
5212
6297
|
}
|
|
5213
6298
|
});
|
|
6299
|
+
this.slider?.onUpdateSizeMetrics(sizeMetrics);
|
|
5214
6300
|
if (this.config.userResizeHandler != null) {
|
|
5215
6301
|
this.config.userResizeHandler({ viewportWidth, viewportHeight, fontSize: fontSizeNumber });
|
|
5216
6302
|
}
|
|
5217
6303
|
}
|
|
5218
6304
|
async showSlide(html) {
|
|
5219
|
-
this.
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
6305
|
+
this.slidesMode = 0 /* SLIDES_MODE.SINGLE */;
|
|
6306
|
+
if (this.activeSlide == null) {
|
|
6307
|
+
this.activeSlide = new SlideApi$1({
|
|
6308
|
+
slideApiDeps: new SlideApiDepsSingleSlideMode(this.config.sdkApi),
|
|
6309
|
+
slideWrapper: this.config.slideWrapper,
|
|
6310
|
+
viewport: this.config.viewport,
|
|
6311
|
+
userResizeHandler: this.config.userResizeHandler,
|
|
6312
|
+
slideRatio: this.config.slideRatio,
|
|
6313
|
+
isFullscreen: this.config.isFullscreen,
|
|
6314
|
+
getViewportWidth: this.config.getViewportWidth,
|
|
6315
|
+
getViewportHeight: this.config.getViewportHeight,
|
|
6316
|
+
overlappingActionBarHeight: this.config.overlappingActionBarHeight,
|
|
6317
|
+
separateUserAndAppPause: this.config.separateUserAndAppPause,
|
|
6318
|
+
root: this.config.root,
|
|
6319
|
+
// refreshSizes: this.refreshSizes,
|
|
6320
|
+
index: 0,
|
|
6321
|
+
getSdkClientVariables: this.getSdkClientVariables,
|
|
6322
|
+
});
|
|
6323
|
+
this.activeSlide.onUpdateSizeMetrics(this.sizeMetrics);
|
|
6324
|
+
}
|
|
6325
|
+
return this.activeSlide.showSlide(html);
|
|
6326
|
+
}
|
|
6327
|
+
slider = null;
|
|
6328
|
+
async showSlides(slides, cardAppearance, index = 0) {
|
|
6329
|
+
this.slidesMode = 1 /* SLIDES_MODE.MULTIPLE */;
|
|
6330
|
+
this.sdkApi.onCardLoadingStateChange(0 /* CARD_LOADING_STATE.LOADING */);
|
|
6331
|
+
slides.forEach((content, index) => {
|
|
6332
|
+
if (this.slides[index] == null) {
|
|
6333
|
+
const item = { content, resourcesReadyPromise: null };
|
|
6334
|
+
if (this._useSdkCacheForMultislideMode) {
|
|
6335
|
+
item.resourcesReadyPromise = new Promise((resolve, reject) => {
|
|
6336
|
+
item.resourcesReadyPromisesResolver = { resolve, reject };
|
|
6337
|
+
});
|
|
6338
|
+
}
|
|
6339
|
+
else {
|
|
6340
|
+
item.resourcesReadyPromise = Promise.resolve();
|
|
6341
|
+
}
|
|
6342
|
+
this.slides[index] = item;
|
|
6343
|
+
}
|
|
6344
|
+
else {
|
|
6345
|
+
// for case when sdk call setSlideInCacheStatus before showSlides and for slideReloading (after loading error)
|
|
6346
|
+
this.slides[index].content = content;
|
|
6347
|
+
if (this.slides[index].resourcesReadyPromise == null) {
|
|
6348
|
+
if (this._useSdkCacheForMultislideMode) {
|
|
6349
|
+
this.slides[index].resourcesReadyPromise = new Promise((resolve, reject) => {
|
|
6350
|
+
this.slides[index].resourcesReadyPromisesResolver = { resolve, reject };
|
|
6351
|
+
});
|
|
6352
|
+
}
|
|
6353
|
+
else {
|
|
6354
|
+
this.slides[index].resourcesReadyPromise = Promise.resolve();
|
|
6355
|
+
}
|
|
6356
|
+
}
|
|
6357
|
+
}
|
|
6358
|
+
});
|
|
6359
|
+
const onBeforeShowSlide = (slideElement, index) => {
|
|
6360
|
+
if (this.slides[index].slide == null) {
|
|
6361
|
+
const slideApi = new SlideApi$1({
|
|
6362
|
+
slideApiDeps: new SlideApiDepsMultiSlideMode(this.config.sdkApi, this.slider),
|
|
6363
|
+
slideWrapper: slideElement,
|
|
6364
|
+
viewport: this.config.viewport,
|
|
6365
|
+
userResizeHandler: this.config.userResizeHandler,
|
|
6366
|
+
slideRatio: this.config.slideRatio,
|
|
6367
|
+
isFullscreen: this.config.isFullscreen,
|
|
6368
|
+
getViewportWidth: this.config.getViewportWidth,
|
|
6369
|
+
getViewportHeight: this.config.getViewportHeight,
|
|
6370
|
+
overlappingActionBarHeight: this.config.overlappingActionBarHeight,
|
|
6371
|
+
separateUserAndAppPause: this.config.separateUserAndAppPause,
|
|
6372
|
+
root: this.config.root,
|
|
6373
|
+
index,
|
|
6374
|
+
getSdkClientVariables: this.getSdkClientVariables,
|
|
6375
|
+
});
|
|
6376
|
+
slideApi.onUpdateSizeMetrics(this.sizeMetrics);
|
|
6377
|
+
this.slides[index].slide = slideApi;
|
|
6378
|
+
// TODO для виджета квест нужно при каждом показе слайда инициализировать виджет???
|
|
6379
|
+
// пока вызов убран из за того что init жестко завязан на single slide mode
|
|
6380
|
+
this.activeSlide = this.slides[index].slide;
|
|
6381
|
+
return this.slides[index].slide.showSlide().then(_ => ({ moveToIndex: index }));
|
|
6382
|
+
}
|
|
6383
|
+
this.activeSlide = this.slides[index].slide;
|
|
6384
|
+
// TODO handle moveToIndex
|
|
6385
|
+
// return resolve or reject with reason
|
|
6386
|
+
// TODO для виджета квест нужно при каждом показе слайда инициализировать виджет???
|
|
6387
|
+
// пока вызов убран из за того что init жестко завязан на single slide mode
|
|
6388
|
+
// return this.slides[index].slide.showSlide().then(_ => ({ moveToIndex: index }));
|
|
6389
|
+
return Promise.resolve({ moveToIndex: index });
|
|
6390
|
+
// вызываем здесь cardLoadingState - loading
|
|
6391
|
+
// новый cb - onSlideShowError - там вызов cardLoadingState error - через cardLoadingStateManager
|
|
6392
|
+
// в onShowSlide- cardLoadingState load done
|
|
6393
|
+
// внутри слайдера - обрабатываем moveToIndex
|
|
6394
|
+
};
|
|
6395
|
+
const onBeforeLoadSlide = index => {
|
|
6396
|
+
this.sdkApi.onCardLoadingStateChange(0 /* CARD_LOADING_STATE.LOADING */);
|
|
6397
|
+
};
|
|
6398
|
+
const onSlideLoadingError = (index, reason) => {
|
|
6399
|
+
this.sdkApi.onCardLoadingStateChange(2 /* CARD_LOADING_STATE.LOADING_ERROR */, reason);
|
|
6400
|
+
};
|
|
6401
|
+
const onShowSlide = (slide, index) => {
|
|
6402
|
+
this.sdkApi.onCardLoadingStateChange(1 /* CARD_LOADING_STATE.LOADED */);
|
|
6403
|
+
this.sdkApi.emitEvent("showSlide", { cardId: this.slides[index]?.slide?.slide.cardId ?? 0, index });
|
|
6404
|
+
// if (index === 0) {
|
|
6405
|
+
// this.activeSlide = slideApi;
|
|
6406
|
+
// }
|
|
6407
|
+
// const { result, cardId, slideIndex, reason } = await slideApi.showSlide();
|
|
6408
|
+
// if (index === 0) {
|
|
6409
|
+
// if (result) {
|
|
6410
|
+
// this.sdkApi.onCardLoadingStateChange(CARD_LOADING_STATE.LOADED);
|
|
6411
|
+
// this.sdkApi.emitEvent("showSlide", { cardId: this.activeSlide.slide.cardId, index });
|
|
6412
|
+
// } else {
|
|
6413
|
+
// this.sdkApi.onCardLoadingStateChange(CARD_LOADING_STATE.LOADING, reason);
|
|
6414
|
+
// }
|
|
6415
|
+
// }
|
|
6416
|
+
//
|
|
6417
|
+
// onShowActiveCardResolver({ cardId, slideIndex });
|
|
6418
|
+
};
|
|
6419
|
+
const onSlideLeft = (slide, index) => {
|
|
6420
|
+
this.sdkApi.emitEvent("slideLeft", { cardId: this.slides[index]?.slide?.slide.cardId ?? 0, index });
|
|
6421
|
+
};
|
|
6422
|
+
const slideRender = ({ content, canMediaMount }, index, onBeforeShowSlideDuringMounting) => {
|
|
5226
6423
|
const slideWrapper = document.createElement("div");
|
|
5227
6424
|
slideWrapper.classList.add("narrative-slide-wrapper");
|
|
5228
6425
|
slideWrapper.classList.add("stories-viewer");
|
|
@@ -5245,53 +6442,78 @@ let SlideApi$1 = class SlideApi {
|
|
|
5245
6442
|
// style.sheet?.insertRule(`.narrative-slide-box {padding: ${paddingTop} 0 0 0;`);
|
|
5246
6443
|
slideBoxRendered.style.padding = `${paddingTop} 0 0 0`;
|
|
5247
6444
|
slideBoxPrerender.style.padding = `${paddingTop} 0 0 0`;
|
|
5248
|
-
slideBoxPrerender.innerHTML = card;
|
|
6445
|
+
// slideBoxPrerender.innerHTML = card;
|
|
6446
|
+
// extract and mount solid or gradient bg color (w/o bg image)
|
|
6447
|
+
onBeforeShowSlideDuringMounting.then(callback => {
|
|
6448
|
+
callback(canMediaMount.then(() => {
|
|
6449
|
+
// mount slide media content (after cache is ready event)
|
|
6450
|
+
slideBoxPrerender.innerHTML = content;
|
|
6451
|
+
// create slideApi
|
|
6452
|
+
// call init, init should return moveToIndex
|
|
6453
|
+
return onBeforeShowSlide(slideWrapper, index);
|
|
6454
|
+
}));
|
|
6455
|
+
});
|
|
5249
6456
|
slideOffset.appendChild(slideBoxPrerender);
|
|
5250
6457
|
slideOffset.appendChild(slideBoxRendered);
|
|
5251
6458
|
slideWrapper.appendChild(slideOffset);
|
|
5252
6459
|
slideWrapper.appendChild(style);
|
|
5253
6460
|
return slideWrapper;
|
|
5254
6461
|
};
|
|
5255
|
-
|
|
5256
|
-
const onShowActiveCard = new Promise(resolve => {
|
|
5257
|
-
onShowActiveCardResolver = resolve;
|
|
6462
|
+
new Promise(resolve => {
|
|
5258
6463
|
});
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
}
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
this.activeCard = cardApi;
|
|
5279
|
-
}
|
|
5280
|
-
const result = await cardApi.showSlide();
|
|
5281
|
-
onShowActiveCardResolver(result);
|
|
5282
|
-
// console.log({ result, index });
|
|
6464
|
+
// onContentMounted
|
|
6465
|
+
const onSlideMounted = async (slideElement, index) => {
|
|
6466
|
+
// if (index === 0) {
|
|
6467
|
+
// this.activeSlide = slideApi;
|
|
6468
|
+
// }
|
|
6469
|
+
//
|
|
6470
|
+
// const { result, cardId, slideIndex, reason } = await slideApi.showSlide();
|
|
6471
|
+
//
|
|
6472
|
+
//
|
|
6473
|
+
// if (index === 0) {
|
|
6474
|
+
// if (result) {
|
|
6475
|
+
// this.sdkApi.onCardLoadingStateChange(CARD_LOADING_STATE.LOADED);
|
|
6476
|
+
// this.sdkApi.emitEvent("showSlide", { cardId: this.activeSlide.slide.cardId, index });
|
|
6477
|
+
// } else {
|
|
6478
|
+
// this.sdkApi.onCardLoadingStateChange(CARD_LOADING_STATE.LOADING, reason);
|
|
6479
|
+
// }
|
|
6480
|
+
// }
|
|
6481
|
+
//
|
|
6482
|
+
// onShowActiveCardResolver({ cardId, slideIndex });
|
|
5283
6483
|
};
|
|
5284
|
-
this.
|
|
6484
|
+
if (this.slider != null) {
|
|
6485
|
+
this.slider.destroy();
|
|
6486
|
+
}
|
|
6487
|
+
this.slider = new Slider({
|
|
5285
6488
|
root: this.config.root,
|
|
5286
|
-
|
|
6489
|
+
slides: this.slides.map(({ content, resourcesReadyPromise }) => ({
|
|
6490
|
+
content,
|
|
6491
|
+
canMediaMount: resourcesReadyPromise,
|
|
6492
|
+
})),
|
|
5287
6493
|
nonce: this.config.nonce,
|
|
5288
|
-
|
|
5289
|
-
|
|
6494
|
+
slideRender,
|
|
6495
|
+
onSlideMounted,
|
|
6496
|
+
onBeforeShowSlide,
|
|
6497
|
+
onBeforeLoadSlide,
|
|
6498
|
+
onSlideLoadingError,
|
|
6499
|
+
onShowSlide,
|
|
6500
|
+
onSlideLeft,
|
|
6501
|
+
getLayoutDirection: () => this.layoutDirection,
|
|
6502
|
+
onSlideTimerEnd: () => this.activeSlide.slideTimerEnd(),
|
|
6503
|
+
onSlideStart: () => {
|
|
6504
|
+
this.sdkApi.onCardLoadingStateChange(1 /* CARD_LOADING_STATE.LOADED */);
|
|
6505
|
+
return this.activeSlide.slideStart({ muted: true });
|
|
6506
|
+
},
|
|
6507
|
+
onSlideStop: () => this.activeSlide.slideStop({ prepareForRestart: 1 /* ON_SLIDE_STOP_PREPARE_FOR_RESTART.PREPARE */ }),
|
|
6508
|
+
onSlideDataWaiting: () => this.sdkApi.onCardLoadingStateChange(0 /* CARD_LOADING_STATE.LOADING */),
|
|
6509
|
+
onSlideDataResume: () => this.sdkApi.onCardLoadingStateChange(1 /* CARD_LOADING_STATE.LOADED */),
|
|
6510
|
+
onSlideDataError: () => this.sdkApi.onCardLoadingStateChange(2 /* CARD_LOADING_STATE.LOADING_ERROR */),
|
|
5290
6511
|
});
|
|
5291
|
-
|
|
6512
|
+
await this.slider.showByIndex(index);
|
|
6513
|
+
// return await onShowActiveCard;
|
|
5292
6514
|
}
|
|
5293
6515
|
handleBackpress() {
|
|
5294
|
-
this.
|
|
6516
|
+
this.activeSlide.handleBackpress();
|
|
5295
6517
|
}
|
|
5296
6518
|
get layoutService() {
|
|
5297
6519
|
return container.get({ identifier: "LayoutService" });
|
|
@@ -5300,89 +6522,91 @@ let SlideApi$1 = class SlideApi {
|
|
|
5300
6522
|
return this.sdkApi.getCardLocalData();
|
|
5301
6523
|
}
|
|
5302
6524
|
async slideStart(config) {
|
|
5303
|
-
return this.
|
|
6525
|
+
return this.activeSlide.slideStart(config);
|
|
5304
6526
|
}
|
|
5305
6527
|
async slideRestart(config) {
|
|
5306
|
-
return this.
|
|
6528
|
+
return this.activeSlide.slideRestart(config);
|
|
5307
6529
|
}
|
|
5308
6530
|
async slideUserPause() {
|
|
5309
|
-
return this.
|
|
6531
|
+
return this.activeSlide.slideUserPause();
|
|
5310
6532
|
}
|
|
5311
6533
|
async slideUserResume() {
|
|
5312
|
-
return this.
|
|
6534
|
+
return this.activeSlide.slideUserResume();
|
|
5313
6535
|
}
|
|
5314
6536
|
/**
|
|
5315
6537
|
* Call on app gone background
|
|
5316
6538
|
*/
|
|
5317
6539
|
async slideAppPause() {
|
|
5318
|
-
return this.
|
|
6540
|
+
return this.activeSlide.slideAppPause();
|
|
5319
6541
|
}
|
|
5320
6542
|
/**
|
|
5321
6543
|
* Call on app gone foreground after a background
|
|
5322
6544
|
*/
|
|
5323
6545
|
async slideAppResume() {
|
|
5324
|
-
return this.
|
|
6546
|
+
return this.activeSlide.slideAppResume();
|
|
5325
6547
|
}
|
|
5326
6548
|
async slideStop(options) {
|
|
5327
|
-
return this.
|
|
6549
|
+
return this.activeSlide.slideStop(options);
|
|
5328
6550
|
}
|
|
5329
6551
|
slideTimerEnd() {
|
|
5330
|
-
this.
|
|
6552
|
+
this.activeSlide.slideTimerEnd();
|
|
5331
6553
|
}
|
|
5332
6554
|
enableAudio() {
|
|
5333
|
-
this.
|
|
6555
|
+
this.activeSlide.enableAudio();
|
|
5334
6556
|
}
|
|
5335
6557
|
disableAudio() {
|
|
5336
|
-
this.
|
|
6558
|
+
this.activeSlide.disableAudio();
|
|
5337
6559
|
}
|
|
5338
6560
|
get isStopped() {
|
|
5339
|
-
return this.
|
|
6561
|
+
return this.activeSlide.isStopped;
|
|
5340
6562
|
}
|
|
5341
6563
|
afterStartInitQueuePush(cb) {
|
|
5342
|
-
return this.
|
|
6564
|
+
return this.activeSlide.afterStartInitQueuePush(cb);
|
|
5343
6565
|
}
|
|
5344
6566
|
afterAppResumeQueuePush(cb) {
|
|
5345
|
-
return this.
|
|
6567
|
+
return this.activeSlide.afterAppResumeQueuePush(cb);
|
|
5346
6568
|
}
|
|
5347
6569
|
get activeLayer() {
|
|
5348
|
-
return this.
|
|
6570
|
+
return this.activeSlide.slide.activeLayer;
|
|
5349
6571
|
}
|
|
5350
6572
|
get slide() {
|
|
5351
|
-
return this.
|
|
6573
|
+
return this.activeSlide.slide;
|
|
5352
6574
|
}
|
|
5353
6575
|
showLayer(index) {
|
|
5354
|
-
this.
|
|
6576
|
+
this.activeSlide.showLayer(index);
|
|
5355
6577
|
}
|
|
5356
6578
|
slideClickHandler(targetElement, navigationDirection) {
|
|
5357
|
-
const result = this.
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
result.canClickNext = false;
|
|
5361
|
-
const currentIndex = this.
|
|
6579
|
+
const result = this.activeSlide.slideClickHandler(targetElement, navigationDirection);
|
|
6580
|
+
// todo make via strategy pattern, singleSlide and multiSlide impl
|
|
6581
|
+
if (this.slidesMode === 1 /* SLIDES_MODE.MULTIPLE */ && result.canClickNext) {
|
|
6582
|
+
result.canClickNext = false; // handle nav click via CardsSlider, not via SDK
|
|
6583
|
+
const currentIndex = this.activeSlide.index;
|
|
5362
6584
|
let index = navigationDirection === "forward" ? currentIndex + 1 : currentIndex - 1;
|
|
5363
|
-
if (index >= this.
|
|
6585
|
+
if (index >= this.slides.length) {
|
|
5364
6586
|
index = 0;
|
|
5365
6587
|
}
|
|
5366
6588
|
else if (index < 0) {
|
|
5367
|
-
index = this.
|
|
6589
|
+
index = this.slides.length - 1;
|
|
5368
6590
|
}
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
6591
|
+
this.slider.showByIndex(index).then(index => {
|
|
6592
|
+
if (currentIndex === index)
|
|
6593
|
+
return;
|
|
6594
|
+
this.activeSlide = this.slides[index].slide;
|
|
6595
|
+
});
|
|
5372
6596
|
}
|
|
5373
6597
|
return result;
|
|
5374
6598
|
}
|
|
5375
6599
|
slideSwipeUpHandler() {
|
|
5376
|
-
return this.
|
|
6600
|
+
return this.activeSlide.slideSwipeUpHandler();
|
|
5377
6601
|
}
|
|
5378
6602
|
setTextInputResult(id, text) {
|
|
5379
|
-
this.
|
|
6603
|
+
this.activeSlide.setTextInputResult(id, text);
|
|
5380
6604
|
}
|
|
5381
6605
|
setShareComplete(id, isSuccess) {
|
|
5382
|
-
this.
|
|
6606
|
+
this.activeSlide.setShareComplete(id, isSuccess);
|
|
5383
6607
|
}
|
|
5384
6608
|
setWidgetGoodsComplete(elementId) {
|
|
5385
|
-
this.
|
|
6609
|
+
this.activeSlide.setWidgetGoodsComplete(elementId);
|
|
5386
6610
|
}
|
|
5387
6611
|
_sdkClientVariables = {};
|
|
5388
6612
|
getSdkClientVariables() {
|
|
@@ -5391,6 +6615,23 @@ let SlideApi$1 = class SlideApi {
|
|
|
5391
6615
|
setSdkClientVariables(variables) {
|
|
5392
6616
|
this._sdkClientVariables = variables;
|
|
5393
6617
|
}
|
|
6618
|
+
setSlideInCacheStatus(index, status) {
|
|
6619
|
+
if (this.slides[index] != null && this.slides[index].resourcesReadyPromisesResolver != null) {
|
|
6620
|
+
if (status === 1 /* SLIDE_IN_CACHE_STATUS.SUCCESS */) {
|
|
6621
|
+
this.slides[index].resourcesReadyPromisesResolver.resolve();
|
|
6622
|
+
}
|
|
6623
|
+
else {
|
|
6624
|
+
this.slides[index].resourcesReadyPromisesResolver.reject();
|
|
6625
|
+
}
|
|
6626
|
+
}
|
|
6627
|
+
else {
|
|
6628
|
+
// for call setSlideInCacheStatus before showSlides
|
|
6629
|
+
this.slides[index] = {
|
|
6630
|
+
content: "",
|
|
6631
|
+
resourcesReadyPromise: Promise.resolve(),
|
|
6632
|
+
};
|
|
6633
|
+
}
|
|
6634
|
+
}
|
|
5394
6635
|
static get [Symbol.for("___CTOR_ARGS___")]() { return [`{
|
|
5395
6636
|
sdkApi: SDKApi;
|
|
5396
6637
|
slideWrapper: HTMLElement;
|
|
@@ -5405,8 +6646,9 @@ let SlideApi$1 = class SlideApi {
|
|
|
5405
6646
|
separateUserAndAppPause: boolean;
|
|
5406
6647
|
root: HTMLElement;
|
|
5407
6648
|
nonce?: string;
|
|
6649
|
+
useSdkCacheForMultislideMode: boolean;
|
|
5408
6650
|
}`]; }
|
|
5409
|
-
}
|
|
6651
|
+
}
|
|
5410
6652
|
|
|
5411
6653
|
const slideApiPeerDeps = {};
|
|
5412
6654
|
const createSlideWrapper = ({ slideBoxRatio, nonce }) => {
|
|
@@ -5438,7 +6680,7 @@ const createSlideWrapper = ({ slideBoxRatio, nonce }) => {
|
|
|
5438
6680
|
slideWrapper.appendChild(style);
|
|
5439
6681
|
return slideWrapper;
|
|
5440
6682
|
};
|
|
5441
|
-
class SlideApi extends
|
|
6683
|
+
class SlideApi extends CardApi {
|
|
5442
6684
|
root;
|
|
5443
6685
|
slideWrapper;
|
|
5444
6686
|
constructor(_sdkInterface, config) {
|
|
@@ -5458,6 +6700,7 @@ class SlideApi extends SlideApi$1 {
|
|
|
5458
6700
|
separateUserAndAppPause: true,
|
|
5459
6701
|
root: config.root,
|
|
5460
6702
|
nonce: config.nonce,
|
|
6703
|
+
useSdkCacheForMultislideMode: config.useSdkCacheForMultislideMode,
|
|
5461
6704
|
});
|
|
5462
6705
|
this.root = config.root;
|
|
5463
6706
|
this.slideWrapper = slideWrapper;
|
|
@@ -5478,6 +6721,7 @@ class SlideApi extends SlideApi$1 {
|
|
|
5478
6721
|
userResizeHandler?: (data: { viewportWidth: number; viewportHeight: number; fontSize: number }) => void;
|
|
5479
6722
|
VODPlayer?: typeof VODPlayer;
|
|
5480
6723
|
overlappingActionBarHeight?: number;
|
|
6724
|
+
useSdkCacheForMultislideMode: boolean;
|
|
5481
6725
|
}`]; }
|
|
5482
6726
|
}
|
|
5483
6727
|
|
|
@@ -14907,7 +16151,7 @@ class WidgetBase {
|
|
|
14907
16151
|
this.submitButtonView = this.submitButtonAnimatedView.querySelector(".submit-button-view");
|
|
14908
16152
|
}
|
|
14909
16153
|
}
|
|
14910
|
-
this.savedData = this.widgetDeps.
|
|
16154
|
+
this.savedData = this.widgetDeps.slideApiDeps.getCardServerData(this.cardId);
|
|
14911
16155
|
this.localData = extend({}, this.savedData ?? {}, this.options.localData ?? {});
|
|
14912
16156
|
this.id = `w_${this.elementId}_${WidgetBase.widgetIndex}`;
|
|
14913
16157
|
++WidgetBase.widgetIndex;
|
|
@@ -14929,7 +16173,7 @@ class WidgetBase {
|
|
|
14929
16173
|
* @param localData
|
|
14930
16174
|
*/
|
|
14931
16175
|
onRefreshUserData(localData) {
|
|
14932
|
-
this.savedData = this.widgetDeps.
|
|
16176
|
+
this.savedData = this.widgetDeps.slideApiDeps.getCardServerData(this.cardId);
|
|
14933
16177
|
this.localData = extend({}, this.savedData ?? {}, localData);
|
|
14934
16178
|
}
|
|
14935
16179
|
onStart() {
|
|
@@ -14979,13 +16223,13 @@ class WidgetBase {
|
|
|
14979
16223
|
static get widgetsService() {
|
|
14980
16224
|
return container.get({ identifier: "WidgetsService" });
|
|
14981
16225
|
}
|
|
14982
|
-
static getLocalData(
|
|
14983
|
-
return
|
|
16226
|
+
static getLocalData(slideApiDeps) {
|
|
16227
|
+
return slideApiDeps.getCardLocalData();
|
|
14984
16228
|
}
|
|
14985
16229
|
getLocalData() {
|
|
14986
|
-
return this.constructor.getLocalData(this.widgetDeps.
|
|
16230
|
+
return this.constructor.getLocalData(this.widgetDeps.slideApiDeps);
|
|
14987
16231
|
}
|
|
14988
|
-
static setLocalData(
|
|
16232
|
+
static setLocalData(slideApiDeps, keyValue, sendToServer, syncWithRuntimeLocalData) {
|
|
14989
16233
|
// push json object as string
|
|
14990
16234
|
if (sendToServer === undefined) {
|
|
14991
16235
|
sendToServer = true;
|
|
@@ -15000,20 +16244,20 @@ class WidgetBase {
|
|
|
15000
16244
|
syncWithRuntimeLocalData = Boolean(syncWithRuntimeLocalData);
|
|
15001
16245
|
}
|
|
15002
16246
|
if (syncWithRuntimeLocalData) {
|
|
15003
|
-
this.getLocalData(
|
|
16247
|
+
this.getLocalData(slideApiDeps).then(localData => {
|
|
15004
16248
|
// 1 - old values, 2 - new values
|
|
15005
16249
|
keyValue = extend({}, localData, keyValue);
|
|
15006
16250
|
// todo make async via promise or async
|
|
15007
|
-
|
|
16251
|
+
slideApiDeps.setCardLocalData(keyValue, sendToServer);
|
|
15008
16252
|
});
|
|
15009
16253
|
}
|
|
15010
16254
|
else {
|
|
15011
16255
|
// todo make async via promise or async
|
|
15012
|
-
|
|
16256
|
+
slideApiDeps.setCardLocalData(keyValue, sendToServer);
|
|
15013
16257
|
}
|
|
15014
16258
|
}
|
|
15015
16259
|
setLocalData(keyValue, sendToServer, syncWithRuntimeLocalData) {
|
|
15016
|
-
return this.constructor.setLocalData(this.widgetDeps.
|
|
16260
|
+
return this.constructor.setLocalData(this.widgetDeps.slideApiDeps, keyValue, sendToServer, syncWithRuntimeLocalData);
|
|
15017
16261
|
}
|
|
15018
16262
|
get statisticEventBaseFieldsShortForm() {
|
|
15019
16263
|
return WidgetBase.getStatisticEventBaseFieldsShortForm(this.cardId, this.cardType, this.slideIndex);
|
|
@@ -15044,11 +16288,11 @@ class WidgetBase {
|
|
|
15044
16288
|
}
|
|
15045
16289
|
return data;
|
|
15046
16290
|
}
|
|
15047
|
-
static sendStatisticEventToApp(
|
|
15048
|
-
sendStatisticEventToApp(
|
|
16291
|
+
static sendStatisticEventToApp(slideApiDeps, name, data, devPayload, options) {
|
|
16292
|
+
sendStatisticEventToApp(slideApiDeps, name, data, devPayload, options);
|
|
15049
16293
|
}
|
|
15050
16294
|
sendStatisticEventToApp(name, data, devPayload, options) {
|
|
15051
|
-
this.constructor.sendStatisticEventToApp(this.widgetDeps.
|
|
16295
|
+
this.constructor.sendStatisticEventToApp(this.widgetDeps.slideApiDeps, name, data, devPayload, options);
|
|
15052
16296
|
}
|
|
15053
16297
|
onWidgetComplete() {
|
|
15054
16298
|
this._widgetCallbacks.onWidgetComplete(this.cardId, this.slideIndex);
|
|
@@ -15060,14 +16304,14 @@ class WidgetBase {
|
|
|
15060
16304
|
this._widgetCallbacks.onWidgetRequireResumeUI(this.cardId, this.slideIndex);
|
|
15061
16305
|
}
|
|
15062
16306
|
_showLayer(layers, selectIndex, withStatEvent = false) {
|
|
15063
|
-
if (this.widgetDeps.
|
|
15064
|
-
this.widgetDeps.
|
|
16307
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowLayer()) {
|
|
16308
|
+
this.widgetDeps.slideApiDeps.showLayer(selectIndex);
|
|
15065
16309
|
}
|
|
15066
16310
|
else {
|
|
15067
16311
|
forEach(layers, (layer, index) => {
|
|
15068
16312
|
if (index === selectIndex) {
|
|
15069
16313
|
layer.classList.remove("hidden");
|
|
15070
|
-
this.widgetDeps.
|
|
16314
|
+
this.widgetDeps.slideApiDeps.cardAnimation?.start(layer);
|
|
15071
16315
|
}
|
|
15072
16316
|
else {
|
|
15073
16317
|
layer.classList.add("hidden");
|
|
@@ -15217,7 +16461,7 @@ class WidgetBarcode extends WidgetBase {
|
|
|
15217
16461
|
}
|
|
15218
16462
|
catch (e) {
|
|
15219
16463
|
if (this.msgBarcodeRenderError) {
|
|
15220
|
-
this.widgetDeps.
|
|
16464
|
+
this.widgetDeps.slideApiDeps.showToast(this.msgBarcodeRenderError);
|
|
15221
16465
|
}
|
|
15222
16466
|
console.error(e);
|
|
15223
16467
|
}
|
|
@@ -15280,7 +16524,7 @@ class WidgetBarcode extends WidgetBase {
|
|
|
15280
16524
|
};
|
|
15281
16525
|
const profileKey = "fetch-promo-code";
|
|
15282
16526
|
Promise.all([
|
|
15283
|
-
this.widgetDeps.
|
|
16527
|
+
this.widgetDeps.slideApiDeps.sendApiRequest(path, "POST", null, headers, null, profileKey),
|
|
15284
16528
|
new Promise(function (t, e) {
|
|
15285
16529
|
return setTimeout(t, 300);
|
|
15286
16530
|
}),
|
|
@@ -15308,14 +16552,14 @@ class WidgetBarcode extends WidgetBase {
|
|
|
15308
16552
|
this.setLocalData(this.localData, true);
|
|
15309
16553
|
}
|
|
15310
16554
|
else {
|
|
15311
|
-
this.msgNoMoreCodes && this.widgetDeps.
|
|
16555
|
+
this.msgNoMoreCodes && this.widgetDeps.slideApiDeps.showToast(this.msgNoMoreCodes);
|
|
15312
16556
|
}
|
|
15313
16557
|
}
|
|
15314
16558
|
else if (status === 12163 || status === 12002) {
|
|
15315
|
-
this.msgNetworkError && this.widgetDeps.
|
|
16559
|
+
this.msgNetworkError && this.widgetDeps.slideApiDeps.showToast(this.msgNetworkError);
|
|
15316
16560
|
}
|
|
15317
16561
|
else {
|
|
15318
|
-
this.msgServiceError && this.widgetDeps.
|
|
16562
|
+
this.msgServiceError && this.widgetDeps.slideApiDeps.showToast(this.msgServiceError);
|
|
15319
16563
|
}
|
|
15320
16564
|
if (!success) {
|
|
15321
16565
|
this.state = 3;
|
|
@@ -15361,13 +16605,13 @@ class WidgetBarcode extends WidgetBase {
|
|
|
15361
16605
|
}
|
|
15362
16606
|
});
|
|
15363
16607
|
if (this.copiedText) {
|
|
15364
|
-
this.widgetDeps.
|
|
16608
|
+
this.widgetDeps.slideApiDeps.showToast(this.copiedText);
|
|
15365
16609
|
}
|
|
15366
16610
|
}
|
|
15367
16611
|
copyToClipboard(element) {
|
|
15368
16612
|
this._select();
|
|
15369
16613
|
const textValue = this.clipboardTarget ?? "";
|
|
15370
|
-
this.widgetDeps.
|
|
16614
|
+
this.widgetDeps.slideApiDeps.writeToClipboard({ type: "text", textValue });
|
|
15371
16615
|
this.completeWidget();
|
|
15372
16616
|
this._statEventCopyClick(textValue);
|
|
15373
16617
|
}
|
|
@@ -15539,7 +16783,7 @@ class WidgetCopy extends WidgetBase {
|
|
|
15539
16783
|
};
|
|
15540
16784
|
const profileKey = "fetch-promo-code";
|
|
15541
16785
|
Promise.all([
|
|
15542
|
-
this.widgetDeps.
|
|
16786
|
+
this.widgetDeps.slideApiDeps.sendApiRequest(path, "POST", null, headers, null, profileKey),
|
|
15543
16787
|
new Promise(function (t, e) {
|
|
15544
16788
|
return setTimeout(t, 300);
|
|
15545
16789
|
}),
|
|
@@ -15566,14 +16810,14 @@ class WidgetCopy extends WidgetBase {
|
|
|
15566
16810
|
this.setLocalData(this.localData, true);
|
|
15567
16811
|
}
|
|
15568
16812
|
else {
|
|
15569
|
-
this.msgNoMoreCodes && this.widgetDeps.
|
|
16813
|
+
this.msgNoMoreCodes && this.widgetDeps.slideApiDeps.showToast(this.msgNoMoreCodes);
|
|
15570
16814
|
}
|
|
15571
16815
|
}
|
|
15572
16816
|
else if (status === 12163 || status === 12002) {
|
|
15573
|
-
this.msgNetworkError && this.widgetDeps.
|
|
16817
|
+
this.msgNetworkError && this.widgetDeps.slideApiDeps.showToast(this.msgNetworkError);
|
|
15574
16818
|
}
|
|
15575
16819
|
else {
|
|
15576
|
-
this.msgServiceError && this.widgetDeps.
|
|
16820
|
+
this.msgServiceError && this.widgetDeps.slideApiDeps.showToast(this.msgServiceError);
|
|
15577
16821
|
}
|
|
15578
16822
|
if (!success) {
|
|
15579
16823
|
this.state = 3;
|
|
@@ -15625,7 +16869,7 @@ class WidgetCopy extends WidgetBase {
|
|
|
15625
16869
|
copyToClipboard(element) {
|
|
15626
16870
|
this._select();
|
|
15627
16871
|
const textValue = this.clipboardTarget ?? "";
|
|
15628
|
-
this.widgetDeps.
|
|
16872
|
+
this.widgetDeps.slideApiDeps.writeToClipboard({ type: "text", textValue });
|
|
15629
16873
|
this.completeWidget();
|
|
15630
16874
|
this._statEventCopyClick(textValue);
|
|
15631
16875
|
}
|
|
@@ -15767,12 +17011,12 @@ class WidgetDataInput extends WidgetBase {
|
|
|
15767
17011
|
return true;
|
|
15768
17012
|
}
|
|
15769
17013
|
this.elementRect = this.element.getBoundingClientRect();
|
|
15770
|
-
if (this.widgetDeps.
|
|
17014
|
+
if (this.widgetDeps.slideApiDeps.isAndroid || this.widgetDeps.slideApiDeps.isWeb) {
|
|
15771
17015
|
this.slide.classList.add("blured");
|
|
15772
17016
|
}
|
|
15773
17017
|
this.slide.classList.add("data-input-editing");
|
|
15774
17018
|
const dataString = this.element.dataset["clientdialogwidgetconfig"];
|
|
15775
|
-
if (this.widgetDeps.
|
|
17019
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowCardTextInput && dataString) {
|
|
15776
17020
|
const data = JSON.parse(dataString);
|
|
15777
17021
|
data.size = getElementBounding(this.env, this.elementRect);
|
|
15778
17022
|
if (!this.disableTimer) {
|
|
@@ -15793,7 +17037,7 @@ class WidgetDataInput extends WidgetBase {
|
|
|
15793
17037
|
catch (e) {
|
|
15794
17038
|
console.error(e);
|
|
15795
17039
|
}
|
|
15796
|
-
this.widgetDeps.
|
|
17040
|
+
this.widgetDeps.slideApiDeps.showCardTextInput(this.id, data);
|
|
15797
17041
|
this._statEventFocusIn();
|
|
15798
17042
|
}
|
|
15799
17043
|
return false;
|
|
@@ -16092,7 +17336,7 @@ class WidgetDateCountdown extends WidgetBase {
|
|
|
16092
17336
|
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `WidgetCallbacks`, `WidgetDeps`]; }
|
|
16093
17337
|
}
|
|
16094
17338
|
|
|
16095
|
-
const displaySlide = function (slides, localData,
|
|
17339
|
+
const displaySlide = function (slides, localData, slideApiDeps) {
|
|
16096
17340
|
const multiSlideItem = slides[0];
|
|
16097
17341
|
let cardId = undefined;
|
|
16098
17342
|
let cardType = 1 /* CARD_TYPE.STORY */;
|
|
@@ -16157,7 +17401,7 @@ const displaySlide = function (slides, localData, sdkApi) {
|
|
|
16157
17401
|
if (slides.length > 0) {
|
|
16158
17402
|
var slide = slides[0];
|
|
16159
17403
|
slide.classList.remove("hidden");
|
|
16160
|
-
|
|
17404
|
+
slideApiDeps.cardAnimation?.start(slide);
|
|
16161
17405
|
return;
|
|
16162
17406
|
}
|
|
16163
17407
|
score = 0;
|
|
@@ -16186,19 +17430,19 @@ const displaySlide = function (slides, localData, sdkApi) {
|
|
|
16186
17430
|
if (index === selectedIndex) {
|
|
16187
17431
|
slide.classList.remove("hidden");
|
|
16188
17432
|
undefinedResult = false;
|
|
16189
|
-
|
|
16190
|
-
_sendStatEvent(
|
|
17433
|
+
slideApiDeps.cardAnimation?.start(slide);
|
|
17434
|
+
_sendStatEvent(slideApiDeps, cardId, cardType, slideIndex, selectedIndex);
|
|
16191
17435
|
}
|
|
16192
17436
|
});
|
|
16193
17437
|
}
|
|
16194
17438
|
if (undefinedResult) {
|
|
16195
17439
|
console.warn("undefinedResult layer index");
|
|
16196
|
-
|
|
17440
|
+
slideApiDeps.showLayer(0);
|
|
16197
17441
|
}
|
|
16198
17442
|
};
|
|
16199
|
-
const _sendStatEvent = function (
|
|
17443
|
+
const _sendStatEvent = function (slideApiDeps, cardId, cardType, slideIndex, layerIndex) {
|
|
16200
17444
|
try {
|
|
16201
|
-
WidgetBase.sendStatisticEventToApp(
|
|
17445
|
+
WidgetBase.sendStatisticEventToApp(slideApiDeps, "layout-show", {
|
|
16202
17446
|
...WidgetBase.getStatisticEventBaseFieldsShortForm(cardId, cardType, slideIndex),
|
|
16203
17447
|
li: layerIndex,
|
|
16204
17448
|
}, {
|
|
@@ -16213,7 +17457,7 @@ const _sendStatEvent = function (sdkApi, cardId, cardType, slideIndex, layerInde
|
|
|
16213
17457
|
class WidgetMultiSlide {
|
|
16214
17458
|
static api = {
|
|
16215
17459
|
init: function (slides, localData, widgetDeps) {
|
|
16216
|
-
displaySlide(slides, localData, widgetDeps.
|
|
17460
|
+
displaySlide(slides, localData, widgetDeps.slideApiDeps);
|
|
16217
17461
|
},
|
|
16218
17462
|
};
|
|
16219
17463
|
}
|
|
@@ -16381,13 +17625,13 @@ class WidgetPoll extends WidgetBase {
|
|
|
16381
17625
|
if (index !== -1) {
|
|
16382
17626
|
this.elementRect = this.element.getBoundingClientRect();
|
|
16383
17627
|
if (this.getUseResponseOnFirstButton && index === 0) {
|
|
16384
|
-
if (this.widgetDeps.
|
|
17628
|
+
if (this.widgetDeps.slideApiDeps.isAndroid) {
|
|
16385
17629
|
this.slide.classList.add("blured");
|
|
16386
17630
|
}
|
|
16387
17631
|
this.slide.classList.add("data-input-editing");
|
|
16388
17632
|
const dataString = this.element.dataset["clientdialogwidgetconfig"];
|
|
16389
17633
|
this.selectedVariant = index;
|
|
16390
|
-
if (this.widgetDeps.
|
|
17634
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowCardTextInput && dataString) {
|
|
16391
17635
|
const data = JSON.parse(dataString);
|
|
16392
17636
|
data.size = getElementBounding(this.env, this.elementRect);
|
|
16393
17637
|
if (!this.disableTimer) {
|
|
@@ -16409,19 +17653,19 @@ class WidgetPoll extends WidgetBase {
|
|
|
16409
17653
|
catch (e) {
|
|
16410
17654
|
console.error(e);
|
|
16411
17655
|
}
|
|
16412
|
-
this.widgetDeps.
|
|
17656
|
+
this.widgetDeps.slideApiDeps.showCardTextInput(`${this.id}_first`, data);
|
|
16413
17657
|
}
|
|
16414
17658
|
this._statEventPollAnswer();
|
|
16415
17659
|
return false;
|
|
16416
17660
|
}
|
|
16417
17661
|
else if (this.getUseResponseOnSecondButton && index === 1) {
|
|
16418
|
-
if (this.widgetDeps.
|
|
17662
|
+
if (this.widgetDeps.slideApiDeps.isAndroid) {
|
|
16419
17663
|
this.slide.classList.add("blured");
|
|
16420
17664
|
}
|
|
16421
17665
|
this.slide.classList.add("data-input-editing");
|
|
16422
17666
|
const dataString = this.element.dataset["clientdialogwidgetconfig"];
|
|
16423
17667
|
this.selectedVariant = index;
|
|
16424
|
-
if (this.widgetDeps.
|
|
17668
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowCardTextInput && dataString) {
|
|
16425
17669
|
const data = JSON.parse(dataString);
|
|
16426
17670
|
data.size = getElementBounding(this.env, this.elementRect);
|
|
16427
17671
|
if (!this.disableTimer) {
|
|
@@ -16442,7 +17686,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
16442
17686
|
catch (e) {
|
|
16443
17687
|
console.error(e);
|
|
16444
17688
|
}
|
|
16445
|
-
this.widgetDeps.
|
|
17689
|
+
this.widgetDeps.slideApiDeps.showCardTextInput(`${this.id}_second`, data);
|
|
16446
17690
|
}
|
|
16447
17691
|
this._statEventPollAnswer();
|
|
16448
17692
|
return false;
|
|
@@ -16485,7 +17729,7 @@ class WidgetPoll extends WidgetBase {
|
|
|
16485
17729
|
displayPercents(selectedVariantIndex, filled = false) {
|
|
16486
17730
|
let pollAllocation = [0, 0];
|
|
16487
17731
|
let pollAllocationTs = undefined;
|
|
16488
|
-
const sharedData = this.widgetDeps.
|
|
17732
|
+
const sharedData = this.widgetDeps.slideApiDeps.getWidgetsSharedData(this.cardId, "poll" /* Widgets.Poll */);
|
|
16489
17733
|
if (sharedData && sharedData[this.elementId] != null && (isObject$1(sharedData[this.elementId]) || isArray(sharedData[this.elementId]))) {
|
|
16490
17734
|
pollAllocation = sharedData[this.elementId];
|
|
16491
17735
|
if (isObject$1(sharedData[this.elementId])) {
|
|
@@ -17654,20 +18898,19 @@ class WidgetProducts extends WidgetBase {
|
|
|
17654
18898
|
if (!this.linkTarget.length) {
|
|
17655
18899
|
return { message: this.msgServiceError ?? "", models: [] };
|
|
17656
18900
|
}
|
|
17657
|
-
|
|
17658
|
-
searchParams.set("id", this.linkTarget.join(","));
|
|
18901
|
+
let qs = `id=${this.linkTarget.join(",")}`;
|
|
17659
18902
|
const sdkClientVariables = this.widgetDeps.getSdkClientVariables();
|
|
17660
18903
|
if (sdkClientVariables != null && sdkClientVariables.pos != null) {
|
|
17661
|
-
|
|
18904
|
+
qs += `&pos=${String(sdkClientVariables.pos)}`;
|
|
17662
18905
|
}
|
|
17663
|
-
const path = `product/offer?${
|
|
18906
|
+
const path = `product/offer?${qs}`;
|
|
17664
18907
|
const headers = {
|
|
17665
18908
|
accept: "application/json",
|
|
17666
18909
|
"Content-Type": "application/json",
|
|
17667
18910
|
};
|
|
17668
18911
|
const profileKey = "fetch-products";
|
|
17669
18912
|
try {
|
|
17670
|
-
const response = await this.widgetDeps.
|
|
18913
|
+
const response = await this.widgetDeps.slideApiDeps.sendApiRequest(path, "GET", null, headers, null, profileKey);
|
|
17671
18914
|
// console.log({response});
|
|
17672
18915
|
const status = response.status;
|
|
17673
18916
|
if (status === 200 || status === 201) {
|
|
@@ -17793,15 +19036,15 @@ class WidgetProducts extends WidgetBase {
|
|
|
17793
19036
|
this.isOpen = true;
|
|
17794
19037
|
// prevent next slide navigation gesture
|
|
17795
19038
|
this.isClickCapturedByWidget = true;
|
|
17796
|
-
this.widgetDeps.
|
|
17797
|
-
this.widgetDeps.
|
|
17798
|
-
this.widgetDeps.
|
|
19039
|
+
this.widgetDeps.slideApiDeps.disableHorizontalSwipeGesture();
|
|
19040
|
+
this.widgetDeps.slideApiDeps.disableVerticalSwipeGesture();
|
|
19041
|
+
this.widgetDeps.slideApiDeps.disableBackpress();
|
|
17799
19042
|
this._statEventWidgetOpen(this.currentModels);
|
|
17800
19043
|
this.initSwipeGestureDetector();
|
|
17801
19044
|
}
|
|
17802
19045
|
else {
|
|
17803
19046
|
if (result.message) {
|
|
17804
|
-
this.widgetDeps.
|
|
19047
|
+
this.widgetDeps.slideApiDeps.showToast(result.message);
|
|
17805
19048
|
}
|
|
17806
19049
|
}
|
|
17807
19050
|
this.element.classList.remove("loader");
|
|
@@ -17813,13 +19056,13 @@ class WidgetProducts extends WidgetBase {
|
|
|
17813
19056
|
this.productsView?.classList.add("ias-products-container-view--hidden");
|
|
17814
19057
|
this.element.classList.remove("hidden");
|
|
17815
19058
|
this.isClickCapturedByWidget = false;
|
|
17816
|
-
this.widgetDeps.
|
|
19059
|
+
this.widgetDeps.slideApiDeps.enableHorizontalSwipeGesture();
|
|
17817
19060
|
if (this.swipeGestureDetector != null) {
|
|
17818
19061
|
this.swipeGestureDetector.destroy();
|
|
17819
19062
|
this.swipeGestureDetector = null;
|
|
17820
19063
|
}
|
|
17821
|
-
this.widgetDeps.
|
|
17822
|
-
this.widgetDeps.
|
|
19064
|
+
this.widgetDeps.slideApiDeps.enableVerticalSwipeGesture();
|
|
19065
|
+
this.widgetDeps.slideApiDeps.enableBackpress();
|
|
17823
19066
|
const onClosed = () => {
|
|
17824
19067
|
this.productsView?.removeEventListener("animationend", onClosed);
|
|
17825
19068
|
this.productsView?.parentElement?.removeChild(this.productsView);
|
|
@@ -17879,7 +19122,7 @@ class WidgetProducts extends WidgetBase {
|
|
|
17879
19122
|
e.preventDefault();
|
|
17880
19123
|
this._statEventWidgetCardClick(offer);
|
|
17881
19124
|
if (offer.url) {
|
|
17882
|
-
this.widgetDeps.
|
|
19125
|
+
this.widgetDeps.slideApiDeps.openUrl({ type: "link", link: { type: "url", target: offer.url } });
|
|
17883
19126
|
}
|
|
17884
19127
|
};
|
|
17885
19128
|
card.appendChild(figure);
|
|
@@ -18110,10 +19353,10 @@ class WidgetQuest extends WidgetBase {
|
|
|
18110
19353
|
super.onRefreshUserData(localData);
|
|
18111
19354
|
}
|
|
18112
19355
|
setCardSessionValue(name, value) {
|
|
18113
|
-
this.widgetDeps.
|
|
19356
|
+
this.widgetDeps.slideApiDeps.setCardSessionValue(this.element, name, value);
|
|
18114
19357
|
}
|
|
18115
19358
|
getCardSessionValue(name) {
|
|
18116
|
-
return this.widgetDeps.
|
|
19359
|
+
return this.widgetDeps.slideApiDeps.getCardSessionValue(this.element, name);
|
|
18117
19360
|
}
|
|
18118
19361
|
init() {
|
|
18119
19362
|
if (this.localData) {
|
|
@@ -18132,8 +19375,8 @@ class WidgetQuest extends WidgetBase {
|
|
|
18132
19375
|
// global flag - был сделан переход на нужный слайд, больше не нужно повторять за эту сессию
|
|
18133
19376
|
// perform showStorySlide with lastSlideIdx only on story open first time (not on second slide, etc)
|
|
18134
19377
|
this.setCardSessionValue("__storyQuestSlideChanged", "1");
|
|
18135
|
-
if (this.widgetDeps.
|
|
18136
|
-
this.widgetDeps.
|
|
19378
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
19379
|
+
this.widgetDeps.slideApiDeps.showCardSlide(lastSlideIdx);
|
|
18137
19380
|
return false;
|
|
18138
19381
|
}
|
|
18139
19382
|
}
|
|
@@ -18144,8 +19387,8 @@ class WidgetQuest extends WidgetBase {
|
|
|
18144
19387
|
// если этого слайда нет в роутинге (сработал переход по таймеру в app)
|
|
18145
19388
|
const routes = this._getRoutes();
|
|
18146
19389
|
if (routes[0].indexOf(this.slideIndex) === -1 && this.finalSlide) {
|
|
18147
|
-
if (this.widgetDeps.
|
|
18148
|
-
this.widgetDeps.
|
|
19390
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowNextCard) {
|
|
19391
|
+
this.widgetDeps.slideApiDeps.cardShowNext();
|
|
18149
19392
|
return false;
|
|
18150
19393
|
}
|
|
18151
19394
|
}
|
|
@@ -18191,10 +19434,10 @@ class WidgetQuest extends WidgetBase {
|
|
|
18191
19434
|
this._selectAnswer(index, slideIndex);
|
|
18192
19435
|
this.setLocalData(this.localData, true);
|
|
18193
19436
|
this.env.setTimeout(() => {
|
|
18194
|
-
if (slideIndex >= 0 && slideIndex < this.slideCount && this.widgetDeps.
|
|
19437
|
+
if (slideIndex >= 0 && slideIndex < this.slideCount && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
18195
19438
|
// global flag - был сделан переход на нужный слайд, больше не нужно повторять за эту сессию
|
|
18196
19439
|
this.setCardSessionValue("__storyQuestSlideChanged", "1");
|
|
18197
|
-
this.widgetDeps.
|
|
19440
|
+
this.widgetDeps.slideApiDeps.showCardSlide(slideIndex);
|
|
18198
19441
|
}
|
|
18199
19442
|
}, 100);
|
|
18200
19443
|
}
|
|
@@ -18266,12 +19509,12 @@ class WidgetQuest extends WidgetBase {
|
|
|
18266
19509
|
else {
|
|
18267
19510
|
// by routing - move back
|
|
18268
19511
|
moveTo = this._routeMvPtrBack();
|
|
18269
|
-
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.
|
|
18270
|
-
this.widgetDeps.
|
|
19512
|
+
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
19513
|
+
this.widgetDeps.slideApiDeps.showCardSlide(moveTo);
|
|
18271
19514
|
}
|
|
18272
|
-
if (moveTo === false && this.widgetDeps.
|
|
19515
|
+
if (moveTo === false && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
18273
19516
|
// allow move to start - for broken route history
|
|
18274
|
-
this.widgetDeps.
|
|
19517
|
+
this.widgetDeps.slideApiDeps.showCardSlide(0);
|
|
18275
19518
|
}
|
|
18276
19519
|
}
|
|
18277
19520
|
return result;
|
|
@@ -18287,8 +19530,8 @@ class WidgetQuest extends WidgetBase {
|
|
|
18287
19530
|
if (directionForward) {
|
|
18288
19531
|
if (this.navigationNextSlide === -1) {
|
|
18289
19532
|
// this is the final slide - exit from this quest
|
|
18290
|
-
if (this.widgetDeps.
|
|
18291
|
-
this.widgetDeps.
|
|
19533
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowNextCard) {
|
|
19534
|
+
this.widgetDeps.slideApiDeps.cardShowNext();
|
|
18292
19535
|
}
|
|
18293
19536
|
result.continueDefaultNavigation = false;
|
|
18294
19537
|
return result;
|
|
@@ -18297,11 +19540,11 @@ class WidgetQuest extends WidgetBase {
|
|
|
18297
19540
|
if (nextSlideIndex < this.slideCount) {
|
|
18298
19541
|
this._addNewRouteHistory(nextSlideIndex);
|
|
18299
19542
|
this.setLocalData(this.localData, true);
|
|
18300
|
-
this.widgetDeps.
|
|
19543
|
+
this.widgetDeps.slideApiDeps.showCardSlide(nextSlideIndex);
|
|
18301
19544
|
}
|
|
18302
19545
|
else {
|
|
18303
|
-
if (this.widgetDeps.
|
|
18304
|
-
this.widgetDeps.
|
|
19546
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowNextCard) {
|
|
19547
|
+
this.widgetDeps.slideApiDeps.cardShowNext();
|
|
18305
19548
|
}
|
|
18306
19549
|
}
|
|
18307
19550
|
}
|
|
@@ -18314,12 +19557,12 @@ class WidgetQuest extends WidgetBase {
|
|
|
18314
19557
|
else {
|
|
18315
19558
|
// by routing - move back
|
|
18316
19559
|
moveTo = this._routeMvPtrBack();
|
|
18317
|
-
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.
|
|
18318
|
-
this.widgetDeps.
|
|
19560
|
+
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
19561
|
+
this.widgetDeps.slideApiDeps.showCardSlide(moveTo);
|
|
18319
19562
|
}
|
|
18320
|
-
if (moveTo === false && this.widgetDeps.
|
|
19563
|
+
if (moveTo === false && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
18321
19564
|
// allow move to start - for broken route history
|
|
18322
|
-
this.widgetDeps.
|
|
19565
|
+
this.widgetDeps.slideApiDeps.showCardSlide(0);
|
|
18323
19566
|
}
|
|
18324
19567
|
}
|
|
18325
19568
|
}
|
|
@@ -18334,11 +19577,11 @@ class WidgetQuest extends WidgetBase {
|
|
|
18334
19577
|
if (nextSlideIndex < this.slideCount) {
|
|
18335
19578
|
this._addNewRouteHistory(nextSlideIndex);
|
|
18336
19579
|
this.setLocalData(this.localData, true);
|
|
18337
|
-
this.widgetDeps.
|
|
19580
|
+
this.widgetDeps.slideApiDeps.showCardSlide(nextSlideIndex);
|
|
18338
19581
|
}
|
|
18339
19582
|
else {
|
|
18340
|
-
if (this.widgetDeps.
|
|
18341
|
-
this.widgetDeps.
|
|
19583
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowNextCard) {
|
|
19584
|
+
this.widgetDeps.slideApiDeps.cardShowNext();
|
|
18342
19585
|
}
|
|
18343
19586
|
}
|
|
18344
19587
|
}
|
|
@@ -18351,12 +19594,12 @@ class WidgetQuest extends WidgetBase {
|
|
|
18351
19594
|
else {
|
|
18352
19595
|
// by routing - move back
|
|
18353
19596
|
moveTo = this._routeMvPtrBack();
|
|
18354
|
-
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.
|
|
18355
|
-
this.widgetDeps.
|
|
19597
|
+
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
19598
|
+
this.widgetDeps.slideApiDeps.showCardSlide(moveTo);
|
|
18356
19599
|
}
|
|
18357
|
-
if (moveTo === false && this.widgetDeps.
|
|
19600
|
+
if (moveTo === false && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
18358
19601
|
// allow move to start - for broken route history
|
|
18359
|
-
this.widgetDeps.
|
|
19602
|
+
this.widgetDeps.slideApiDeps.showCardSlide(0);
|
|
18360
19603
|
}
|
|
18361
19604
|
}
|
|
18362
19605
|
}
|
|
@@ -18371,20 +19614,20 @@ class WidgetQuest extends WidgetBase {
|
|
|
18371
19614
|
// setLocalData(this.localData, true);
|
|
18372
19615
|
// window._showNarrativeSlide(nextSlideIndex);
|
|
18373
19616
|
// } else {
|
|
18374
|
-
if (this.widgetDeps.
|
|
18375
|
-
this.widgetDeps.
|
|
19617
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowNextCard) {
|
|
19618
|
+
this.widgetDeps.slideApiDeps.cardShowNext();
|
|
18376
19619
|
}
|
|
18377
19620
|
// }
|
|
18378
19621
|
}
|
|
18379
19622
|
else {
|
|
18380
19623
|
// by routing - move back
|
|
18381
19624
|
moveTo = this._routeMvPtrBack();
|
|
18382
|
-
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.
|
|
18383
|
-
this.widgetDeps.
|
|
19625
|
+
if (moveTo !== false && moveTo >= 0 && moveTo < event.slideCount && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
19626
|
+
this.widgetDeps.slideApiDeps.showCardSlide(moveTo);
|
|
18384
19627
|
}
|
|
18385
|
-
if (moveTo === false && this.widgetDeps.
|
|
19628
|
+
if (moveTo === false && this.widgetDeps.slideApiDeps.isExistsShowCardSlide) {
|
|
18386
19629
|
// allow move to start - for broken route history
|
|
18387
|
-
this.widgetDeps.
|
|
19630
|
+
this.widgetDeps.slideApiDeps.showCardSlide(0);
|
|
18388
19631
|
}
|
|
18389
19632
|
}
|
|
18390
19633
|
}
|
|
@@ -19174,7 +20417,7 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
19174
20417
|
total_user: 0,
|
|
19175
20418
|
};
|
|
19176
20419
|
let answerAllocationTs = undefined;
|
|
19177
|
-
const sharedData = this.widgetDeps.
|
|
20420
|
+
const sharedData = this.widgetDeps.slideApiDeps.getWidgetsSharedData(this.cardId, "rangeSlider" /* Widgets.RangeSlider */);
|
|
19178
20421
|
if (sharedData && sharedData[this.elementId] != null && (isObject$1(sharedData[this.elementId]) || isArray(sharedData[this.elementId]))) {
|
|
19179
20422
|
answerAllocation = sharedData[this.elementId];
|
|
19180
20423
|
answerAllocationTs = sharedData.ts;
|
|
@@ -19274,7 +20517,7 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
19274
20517
|
}
|
|
19275
20518
|
e.preventDefault();
|
|
19276
20519
|
this.isClickCapturedBySlider = true;
|
|
19277
|
-
this.widgetDeps.
|
|
20520
|
+
this.widgetDeps.slideApiDeps.disableHorizontalSwipeGesture();
|
|
19278
20521
|
if (!this.maxHandlePos) {
|
|
19279
20522
|
this.update(true, false);
|
|
19280
20523
|
}
|
|
@@ -19304,7 +20547,7 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
19304
20547
|
handleEnd(e) {
|
|
19305
20548
|
this.env.requestAnimationFrame(() => {
|
|
19306
20549
|
this.isClickCapturedBySlider = false;
|
|
19307
|
-
this.widgetDeps.
|
|
20550
|
+
this.widgetDeps.slideApiDeps.enableHorizontalSwipeGesture();
|
|
19308
20551
|
});
|
|
19309
20552
|
// e.preventDefault();
|
|
19310
20553
|
this.widgetDeps.slideRoot.removeEventListener("touchmove", this.handleMove);
|
|
@@ -19369,7 +20612,7 @@ class WidgetRangeSlider extends WidgetBase {
|
|
|
19369
20612
|
if (this.value !== this.prevSnapValue) {
|
|
19370
20613
|
this.prevSnapValue = this.value;
|
|
19371
20614
|
try {
|
|
19372
|
-
this.widgetDeps.
|
|
20615
|
+
this.widgetDeps.slideApiDeps.vibrate(20);
|
|
19373
20616
|
}
|
|
19374
20617
|
catch (e) {
|
|
19375
20618
|
console.error(e);
|
|
@@ -19616,12 +20859,12 @@ class WidgetRate extends WidgetBase {
|
|
|
19616
20859
|
if (this.showDialogOnLowRate) {
|
|
19617
20860
|
this.elementRect = this.element.getBoundingClientRect();
|
|
19618
20861
|
this._selectStar(this.selectedStar, false);
|
|
19619
|
-
if (this.widgetDeps.
|
|
20862
|
+
if (this.widgetDeps.slideApiDeps.isAndroid) {
|
|
19620
20863
|
this.slide.classList.add("blured");
|
|
19621
20864
|
}
|
|
19622
20865
|
this.slide.classList.add("data-input-editing");
|
|
19623
20866
|
const dataString = this.element.dataset["clientdialogwidgetconfig"];
|
|
19624
|
-
if (this.widgetDeps.
|
|
20867
|
+
if (this.widgetDeps.slideApiDeps.isExistsShowCardTextInput && dataString) {
|
|
19625
20868
|
const data = JSON.parse(dataString);
|
|
19626
20869
|
data.size = getElementBounding(this.env, this.elementRect);
|
|
19627
20870
|
if (!this.disableTimer) {
|
|
@@ -19643,7 +20886,7 @@ class WidgetRate extends WidgetBase {
|
|
|
19643
20886
|
catch (e) {
|
|
19644
20887
|
console.error(e);
|
|
19645
20888
|
}
|
|
19646
|
-
this.widgetDeps.
|
|
20889
|
+
this.widgetDeps.slideApiDeps.showCardTextInput(this.id, data);
|
|
19647
20890
|
}
|
|
19648
20891
|
}
|
|
19649
20892
|
else {
|
|
@@ -19655,17 +20898,17 @@ class WidgetRate extends WidgetBase {
|
|
|
19655
20898
|
}
|
|
19656
20899
|
else if (value + 1 >= this.submitToStoresMin && value + 1 <= this.submitToStoresMax) {
|
|
19657
20900
|
let target = null;
|
|
19658
|
-
if (this.widgetDeps.
|
|
20901
|
+
if (this.widgetDeps.slideApiDeps.isAndroid) {
|
|
19659
20902
|
target = getTagData(this.element, "androidLink");
|
|
19660
20903
|
}
|
|
19661
|
-
else if (this.widgetDeps.
|
|
20904
|
+
else if (this.widgetDeps.slideApiDeps.isIOS) {
|
|
19662
20905
|
target = getTagData(this.element, "appleLink");
|
|
19663
20906
|
}
|
|
19664
20907
|
this._selectStar(value, true);
|
|
19665
20908
|
this.completeWidget();
|
|
19666
20909
|
this._statEventRateUsAnswer("");
|
|
19667
20910
|
if (this.submitToStores && target) {
|
|
19668
|
-
this.widgetDeps.
|
|
20911
|
+
this.widgetDeps.slideApiDeps.openUrl({ type: "link", link: { type: "url", target } });
|
|
19669
20912
|
}
|
|
19670
20913
|
}
|
|
19671
20914
|
else {
|
|
@@ -19814,12 +21057,12 @@ class WidgetShare extends WidgetBase {
|
|
|
19814
21057
|
}
|
|
19815
21058
|
share() {
|
|
19816
21059
|
if (!this.btnDisabled) {
|
|
19817
|
-
if (this.widgetDeps.
|
|
19818
|
-
if (this.widgetDeps.
|
|
21060
|
+
if (this.widgetDeps.slideApiDeps.isExistsShare) {
|
|
21061
|
+
if (this.widgetDeps.slideApiDeps.sdkCanSendShareComplete) {
|
|
19819
21062
|
this.btnDisabled = true;
|
|
19820
21063
|
}
|
|
19821
21064
|
if (this.shareType === "url" || this.shareType === "story") {
|
|
19822
|
-
this.widgetDeps.
|
|
21065
|
+
this.widgetDeps.slideApiDeps.share(this.id, {
|
|
19823
21066
|
url: this.shareTarget, // sdk old versions
|
|
19824
21067
|
text: this.shareTarget,
|
|
19825
21068
|
title: null,
|
|
@@ -19827,7 +21070,7 @@ class WidgetShare extends WidgetBase {
|
|
|
19827
21070
|
});
|
|
19828
21071
|
}
|
|
19829
21072
|
else if (this.shareType === "slide") {
|
|
19830
|
-
this.widgetDeps.
|
|
21073
|
+
this.widgetDeps.slideApiDeps.shareSlideScreenshot(this.id, "[data-element-id='" + this.elementId + "']", this.shareTarget ? this.shareTarget : undefined);
|
|
19831
21074
|
}
|
|
19832
21075
|
}
|
|
19833
21076
|
}
|
|
@@ -20433,9 +21676,9 @@ class WidgetTooltip extends WidgetBase {
|
|
|
20433
21676
|
copyToClipboard(element) {
|
|
20434
21677
|
const textValue = this.template1ClipboardTarget ?? "";
|
|
20435
21678
|
if (textValue) {
|
|
20436
|
-
this.widgetDeps.
|
|
21679
|
+
this.widgetDeps.slideApiDeps.writeToClipboard({ type: "text", textValue });
|
|
20437
21680
|
if (this.template1CopiedText) {
|
|
20438
|
-
this.widgetDeps.
|
|
21681
|
+
this.widgetDeps.slideApiDeps.showToast(this.template1CopiedText);
|
|
20439
21682
|
}
|
|
20440
21683
|
}
|
|
20441
21684
|
this._statEventWidgetCopyClick(textValue);
|
|
@@ -20814,7 +22057,7 @@ class WidgetVote extends WidgetBase {
|
|
|
20814
22057
|
// voteAllocation[7]
|
|
20815
22058
|
let voteAllocation = [];
|
|
20816
22059
|
let voteAllocationTs = undefined;
|
|
20817
|
-
const sharedData = this.widgetDeps.
|
|
22060
|
+
const sharedData = this.widgetDeps.slideApiDeps.getWidgetsSharedData(this.cardId, "vote" /* Widgets.Vote */);
|
|
20818
22061
|
if (sharedData && sharedData[this.elementId] != null && (isObject$1(sharedData[this.elementId]) || isArray(sharedData[this.elementId]))) {
|
|
20819
22062
|
voteAllocation = sharedData[this.elementId];
|
|
20820
22063
|
if (isObject$1(sharedData[this.elementId])) {
|