storyly-placement 1.0.0
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/README.md +52 -0
- package/dist/BaseStory-BBIm7KQ3.js +662 -0
- package/dist/create-product-feed-impl-bM1vply2.js +182 -0
- package/dist/index-0vaGlAUL.js +225 -0
- package/dist/index-89h_T8JG.js +211 -0
- package/dist/index-B28omzDH.js +301 -0
- package/dist/index-B2khaTGj.js +270 -0
- package/dist/index-BP7hmUrm.js +87 -0
- package/dist/index-BV8oGJSO.js +305 -0
- package/dist/index-BYYlLqJU.js +2677 -0
- package/dist/index-BYzPEcYu.js +138 -0
- package/dist/index-Bb6HH2gw.js +1835 -0
- package/dist/index-BtQfo9gV.js +319 -0
- package/dist/index-C-vW1Ub0.js +898 -0
- package/dist/index-C9j2XbJF.js +125 -0
- package/dist/index-CJNQLd4X.js +233 -0
- package/dist/index-CPUWP9Ab.js +2394 -0
- package/dist/index-CS4Sk7dj.js +1753 -0
- package/dist/index-CTlHkeix.js +227 -0
- package/dist/index-Cgk_IViy.js +97 -0
- package/dist/index-CmAVjM-t.js +631 -0
- package/dist/index-DEGPUoj9.js +167 -0
- package/dist/index-DHIwqpCn.js +352 -0
- package/dist/index-DSDAcOiN.js +260 -0
- package/dist/index-DU2wwsMh.js +877 -0
- package/dist/index-De2W1vFd.js +611 -0
- package/dist/index-Dg1MB9Rw.js +33 -0
- package/dist/index-DrXf4pHk.js +672 -0
- package/dist/index-DyNf3LKt.js +136 -0
- package/dist/index-RqfrQooT.js +1356 -0
- package/dist/index-gxurd5uA.js +696 -0
- package/dist/index-t5jR1m8J.js +803 -0
- package/dist/index-uuRKp1s1.js +1109 -0
- package/dist/intersection-observer-impl-DEw53rtl.js +3345 -0
- package/dist/nudge-story-groups-impl-DHZbfpyE.js +85 -0
- package/dist/ref-tJM320Lp.js +108 -0
- package/dist/src/StorylyPlacement.d.ts +33 -0
- package/dist/src/components/LoadingSpinner/index.d.ts +2 -0
- package/dist/src/components/LoadingSpinner/template/android.d.ts +2 -0
- package/dist/src/components/LoadingSpinner/template/ios.d.ts +2 -0
- package/dist/src/components/StoryProduct/util.d.ts +4 -0
- package/dist/src/components/Toast/index.d.ts +7 -0
- package/dist/src/components/Toast/template.d.ts +2 -0
- package/dist/src/constants/animations.d.ts +4 -0
- package/dist/src/constants/app-events.d.ts +6 -0
- package/dist/src/constants/availability-status.d.ts +2 -0
- package/dist/src/constants/bar-layouts.d.ts +5 -0
- package/dist/src/constants/browsers.d.ts +7 -0
- package/dist/src/constants/common.d.ts +20 -0
- package/dist/src/constants/custom-events.d.ts +4 -0
- package/dist/src/constants/directions.d.ts +5 -0
- package/dist/src/constants/icons.d.ts +26 -0
- package/dist/src/constants/layer-types.d.ts +42 -0
- package/dist/src/constants/os.d.ts +6 -0
- package/dist/src/constants/play-mode.d.ts +8 -0
- package/dist/src/constants/stories-events.d.ts +74 -0
- package/dist/src/constants/stories-layouts.d.ts +5 -0
- package/dist/src/constants/video-feed-types.d.ts +5 -0
- package/dist/src/constants/widget-types.d.ts +7 -0
- package/dist/src/constants/wishlist-icons.d.ts +6 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/lang/de.json.d.ts +75 -0
- package/dist/src/lang/en.json.d.ts +75 -0
- package/dist/src/lang/es.json.d.ts +75 -0
- package/dist/src/lang/he.json.d.ts +75 -0
- package/dist/src/lang/index.d.ts +7 -0
- package/dist/src/lang/pt.json.d.ts +75 -0
- package/dist/src/lang/tr.json.d.ts +75 -0
- package/dist/src/layers/BlankStory/index.d.ts +8 -0
- package/dist/src/layers/BlankStory/template/index.d.ts +2 -0
- package/dist/src/layers/CTA/dataConvertor.d.ts +3 -0
- package/dist/src/layers/CTA/index.d.ts +26 -0
- package/dist/src/layers/CTA/template/button.d.ts +3 -0
- package/dist/src/layers/CTA/template/swipe.d.ts +3 -0
- package/dist/src/layers/CTA/types/index.d.ts +92 -0
- package/dist/src/layers/Countdown/dataConvertor.d.ts +3 -0
- package/dist/src/layers/Countdown/index.d.ts +41 -0
- package/dist/src/layers/Countdown/template/index.d.ts +3 -0
- package/dist/src/layers/Countdown/types/index.d.ts +39 -0
- package/dist/src/layers/Emoji/dataConvertor.d.ts +3 -0
- package/dist/src/layers/Emoji/index.d.ts +49 -0
- package/dist/src/layers/Emoji/template/index.d.ts +3 -0
- package/dist/src/layers/Emoji/types/index.d.ts +47 -0
- package/dist/src/layers/ImageCTA/dataConvertor.d.ts +3 -0
- package/dist/src/layers/ImageCTA/index.d.ts +18 -0
- package/dist/src/layers/ImageCTA/template/index.d.ts +3 -0
- package/dist/src/layers/ImageCTA/types/index.d.ts +41 -0
- package/dist/src/layers/ImageQuiz/dataConvertor.d.ts +3 -0
- package/dist/src/layers/ImageQuiz/index.d.ts +72 -0
- package/dist/src/layers/ImageQuiz/template/index.d.ts +3 -0
- package/dist/src/layers/ImageQuiz/types/index.d.ts +42 -0
- package/dist/src/layers/Media/dataConvertor.d.ts +3 -0
- package/dist/src/layers/Media/index.d.ts +14 -0
- package/dist/src/layers/Media/template/index.d.ts +3 -0
- package/dist/src/layers/Media/types/index.d.ts +33 -0
- package/dist/src/layers/Poll/dataConvertor.d.ts +3 -0
- package/dist/src/layers/Poll/index.d.ts +31 -0
- package/dist/src/layers/Poll/template/index.d.ts +3 -0
- package/dist/src/layers/Poll/types/index.d.ts +47 -0
- package/dist/src/layers/ProductCard/dataConvertor.d.ts +3 -0
- package/dist/src/layers/ProductCard/index.d.ts +22 -0
- package/dist/src/layers/ProductCard/template/index.d.ts +3 -0
- package/dist/src/layers/ProductCard/types/index.d.ts +39 -0
- package/dist/src/layers/ProductCatalog/index.d.ts +55 -0
- package/dist/src/layers/ProductCatalog/template/index.d.ts +3 -0
- package/dist/src/layers/ProductCatalog/template/productCard.d.ts +4 -0
- package/dist/src/layers/ProductCatalog/template/productCatalog.d.ts +2 -0
- package/dist/src/layers/ProductCatalog/types/index.d.ts +36 -0
- package/dist/src/layers/ProductTag/dataConvertor.d.ts +3 -0
- package/dist/src/layers/ProductTag/index.d.ts +68 -0
- package/dist/src/layers/ProductTag/template/index.d.ts +3 -0
- package/dist/src/layers/ProductTag/types/index.d.ts +48 -0
- package/dist/src/layers/PromoCode/dataConvertor.d.ts +3 -0
- package/dist/src/layers/PromoCode/index.d.ts +16 -0
- package/dist/src/layers/PromoCode/template/index.d.ts +3 -0
- package/dist/src/layers/PromoCode/types/index.d.ts +36 -0
- package/dist/src/layers/Question/dataConvertor.d.ts +3 -0
- package/dist/src/layers/Question/index.d.ts +44 -0
- package/dist/src/layers/Question/template/layer.d.ts +3 -0
- package/dist/src/layers/Question/template/textbox.d.ts +3 -0
- package/dist/src/layers/Question/types/index.d.ts +47 -0
- package/dist/src/layers/Quiz/dataConvertor.d.ts +3 -0
- package/dist/src/layers/Quiz/index.d.ts +43 -0
- package/dist/src/layers/Quiz/template/index.d.ts +3 -0
- package/dist/src/layers/Quiz/types/index.d.ts +44 -0
- package/dist/src/layers/Rating/dataConvertor.d.ts +3 -0
- package/dist/src/layers/Rating/index.d.ts +57 -0
- package/dist/src/layers/Rating/template/index.d.ts +3 -0
- package/dist/src/layers/Rating/types/index.d.ts +43 -0
- package/dist/src/layers/Text/animation-impl.d.ts +23 -0
- package/dist/src/layers/Text/dataConvertor.d.ts +3 -0
- package/dist/src/layers/Text/index.d.ts +17 -0
- package/dist/src/layers/Text/template/index.d.ts +3 -0
- package/dist/src/layers/Text/types/index.d.ts +61 -0
- package/dist/src/lib/api.d.ts +25 -0
- package/dist/src/lib/copy-to-clipboard.d.ts +2 -0
- package/dist/src/lib/currencies.d.ts +190 -0
- package/dist/src/lib/event-utils.d.ts +4 -0
- package/dist/src/lib/storage.d.ts +26 -0
- package/dist/src/lib/util.d.ts +77 -0
- package/dist/src/plugins/vite-swiper-css.d.ts +5 -0
- package/dist/src/services/BarLayout/index.d.ts +14 -0
- package/dist/src/services/BarLayout/templates/energized-template.d.ts +45 -0
- package/dist/src/services/WidgetStyle/defaultValues.d.ts +6 -0
- package/dist/src/services/WidgetStyle/index.d.ts +103 -0
- package/dist/src/services/WidgetStyle/instanceStyleKeys.d.ts +57 -0
- package/dist/src/services/WidgetStyle/types.d.ts +55 -0
- package/dist/src/services/background-blur-impl.d.ts +1 -0
- package/dist/src/services/calculate-story-size-impl.d.ts +1 -0
- package/dist/src/services/create-product-feed-impl.d.ts +6 -0
- package/dist/src/services/create-user-property-impl.d.ts +1 -0
- package/dist/src/services/custom-story-group-design-impl.d.ts +14 -0
- package/dist/src/services/event-emitter.d.ts +10 -0
- package/dist/src/services/focal-point-impl.d.ts +13 -0
- package/dist/src/services/hls-player.d.ts +13 -0
- package/dist/src/services/intersection-observer-impl.d.ts +1 -0
- package/dist/src/services/json-layout-service.d.ts +23 -0
- package/dist/src/services/layout-impl.d.ts +3 -0
- package/dist/src/services/localization-impl.d.ts +17 -0
- package/dist/src/services/method-handler.d.ts +10 -0
- package/dist/src/services/nudge-story-groups-impl.d.ts +15 -0
- package/dist/src/services/platform-impl.d.ts +10 -0
- package/dist/src/services/read-accessibility-text-impl.d.ts +2 -0
- package/dist/src/services/rule-engine.d.ts +15 -0
- package/dist/src/services/scroll-indicator.d.ts +7 -0
- package/dist/src/services/story-event-impl.d.ts +33 -0
- package/dist/src/services/story-group-animation-impl.d.ts +21 -0
- package/dist/src/services/story-group-badge-impl.d.ts +7 -0
- package/dist/src/services/storyly-context.d.ts +19 -0
- package/dist/src/services/swiper-impl.d.ts +4 -0
- package/dist/src/services/wishlist-impl.d.ts +4 -0
- package/dist/src/types/config.d.ts +19 -0
- package/dist/src/types/keyframe.d.ts +6 -0
- package/dist/src/types/media.d.ts +37 -0
- package/dist/src/types/placement-payload.d.ts +25 -0
- package/dist/src/types/recipe.d.ts +27 -0
- package/dist/src/types/storyly-state.d.ts +53 -0
- package/dist/src/types/widgets/banner/types.d.ts +98 -0
- package/dist/src/types/widgets/stories/product-types.d.ts +53 -0
- package/dist/src/types/widgets/stories/stories-widget.d.ts +18 -0
- package/dist/src/types/widgets/stories/story-types.d.ts +164 -0
- package/dist/src/types/widgets/stories/style-types.d.ts +72 -0
- package/dist/src/types/widgets/stories/video-feed-widget.d.ts +18 -0
- package/dist/src/types/widgets/swipe-card/types.d.ts +45 -0
- package/dist/src/types/widgets/widget-data-types.d.ts +11 -0
- package/dist/src/widgets/Banner/defaultValues.d.ts +5 -0
- package/dist/src/widgets/Banner/events/index.d.ts +27 -0
- package/dist/src/widgets/Banner/events/types.d.ts +23 -0
- package/dist/src/widgets/Banner/index.d.ts +13 -0
- package/dist/src/widgets/Banner/layers/Button/dataConvertor.d.ts +3 -0
- package/dist/src/widgets/Banner/layers/Button/index.d.ts +28 -0
- package/dist/src/widgets/Banner/layers/Button/template/index.d.ts +3 -0
- package/dist/src/widgets/Banner/layers/Button/types/index.d.ts +46 -0
- package/dist/src/widgets/Banner/layers/Text/dataConvertor.d.ts +3 -0
- package/dist/src/widgets/Banner/layers/Text/index.d.ts +18 -0
- package/dist/src/widgets/Banner/layers/Text/template/index.d.ts +3 -0
- package/dist/src/widgets/Banner/layers/Text/types/index.d.ts +37 -0
- package/dist/src/widgets/Banner/templates/banner.d.ts +2 -0
- package/dist/src/widgets/Banner/templates/skeleton.d.ts +1 -0
- package/dist/src/widgets/Stories/index.d.ts +38 -0
- package/dist/src/widgets/Stories/storyly-stories.d.ts +67 -0
- package/dist/src/widgets/Stories/styles/group-styles.d.ts +6 -0
- package/dist/src/widgets/Stories/templates/group-template.d.ts +3 -0
- package/dist/src/widgets/SwipeCard/constants.d.ts +5 -0
- package/dist/src/widgets/SwipeCard/defaultValues.d.ts +33 -0
- package/dist/src/widgets/SwipeCard/dom.d.ts +2 -0
- package/dist/src/widgets/SwipeCard/events/index.d.ts +30 -0
- package/dist/src/widgets/SwipeCard/events/types.d.ts +26 -0
- package/dist/src/widgets/SwipeCard/gesture.d.ts +36 -0
- package/dist/src/widgets/SwipeCard/icons.d.ts +3 -0
- package/dist/src/widgets/SwipeCard/index.d.ts +13 -0
- package/dist/src/widgets/VideoFeed/Layouts/index.d.ts +15 -0
- package/dist/src/widgets/VideoFeed/Layouts/templates/bar.d.ts +13 -0
- package/dist/src/widgets/VideoFeed/Layouts/templates/grid.d.ts +13 -0
- package/dist/src/widgets/VideoFeed/index.d.ts +32 -0
- package/dist/src/widgets/VideoFeed/storyly-stories.d.ts +66 -0
- package/dist/src/widgets/VideoFeed/styles/group-styles.d.ts +6 -0
- package/dist/src/widgets/VideoFeed/templates/group-template.d.ts +3 -0
- package/dist/story-group-animation-impl-DtfjsPOB.js +3491 -0
- package/dist/storyly-placement.css +1 -0
- package/dist/storyly-placement.js +4 -0
- package/dist/storyly-placement.umd.cjs +3411 -0
- package/package.json +46 -0
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
import { S as T, s as _, k as a, H as L, l as y, h as d, Y as u, J as n, Z as f, b as v, _ as l, p as r, $ as h, N as c, m as S, V as w, a0 as x, I as b, d as I, a1 as O, f as p, j as q } from "./index-BYYlLqJU.js";
|
|
2
|
+
import { d as V, C as m, E as P, m as k } from "./story-group-animation-impl-DtfjsPOB.js";
|
|
3
|
+
import { H as W, C as B, r as g, A as R, S as G } from "./index-CS4Sk7dj.js";
|
|
4
|
+
class Q {
|
|
5
|
+
constructor({
|
|
6
|
+
story: t,
|
|
7
|
+
key: s,
|
|
8
|
+
group: e,
|
|
9
|
+
storiesContainer: o,
|
|
10
|
+
groupWrapper: i,
|
|
11
|
+
progressDoms: A,
|
|
12
|
+
instanceId: D,
|
|
13
|
+
condition: C,
|
|
14
|
+
getActiveStory: E
|
|
15
|
+
}) {
|
|
16
|
+
this.storyDom_ = null, this.layersContainer_ = document.createElement("div"), this.story_ = t, this.storyData_ = {}, this.layers_ = [], this.group_ = e, this.key_ = s, this.storiesContainer_ = o, this.groupWrapper_ = i, this.progressDoms_ = new Proxy(A, []), this.storyProgressSecond_ = 7, this.progressPaused_ = !0, this.imageAsset_ = null, this.videoAsset_ = null, this.videoAssetLoadingStarted_ = !1, this.storyProgressRemain_ = this.storyProgressSecond_, this.progressTime_ = 0, this.isBlankStory_ = !1, this.imageAssetLoaded_ = !1, this.instanceId_ = D, this.timedLayers_ = [], this.condition_ = C, this.getActiveStory = E, this.storylyContext = T.getContext(this.instanceId_), _(this.layersContainer_, "layers-container"), a(this.layersContainer_, "dir", V.LTR), this.attachCallbacksToElement_();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Attaches callbacks to the DOM element for them to be used by publishers.
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
attachCallbacksToElement_() {
|
|
23
|
+
this.onVideoLoadedData_ = this.onVideoLoadedData_.bind(this), this.onVideoEnded_ = this.onVideoEnded_.bind(this), this.onVideoWaiting_ = this.onVideoWaiting_.bind(this), this.onVideoPlaying_ = this.onVideoPlaying_.bind(this), this.handleSoundStory_ = this.handleSoundStory_.bind(this), this.playAndPauseStory = this.playAndPauseStory.bind(this), this.handleCloseGroup_ = this.handleCloseGroup_.bind(this), this.onImageLoad_ = this.onImageLoad_.bind(this), this.renderShareWidget = this.renderShareWidget.bind(this), this.handleLayersVisibility_ = this.handleLayersVisibility_.bind(this), this.handleTranscript_ = this.handleTranscript_.bind(this), this.handleAccessibilityOnOff_ = this.handleAccessibilityOnOff_.bind(this);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
28
|
+
setCustomEvents_() {
|
|
29
|
+
this.storyDom_.addEventListener("onPlayPause", this.playAndPauseStory);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* render story
|
|
33
|
+
* @param {Function} StoryTemplate
|
|
34
|
+
*/
|
|
35
|
+
render(t) {
|
|
36
|
+
const { storyData: s, layers: e, storyBg: o } = L(
|
|
37
|
+
this.story_.media.layers
|
|
38
|
+
);
|
|
39
|
+
this.storyData_ = s, this.layers_ = [...e];
|
|
40
|
+
const i = t({
|
|
41
|
+
story: { ...this.storyData_, story_id: this.story_.story_id },
|
|
42
|
+
type: this.storyData_.type,
|
|
43
|
+
altText: this.story_.alt_text,
|
|
44
|
+
mediaHost: this.group_.media_host,
|
|
45
|
+
storyBg: o
|
|
46
|
+
});
|
|
47
|
+
if (this.storyDom_ = y(i), this.storyDom_.appendChild(this.layersContainer_), this.condition_ ? this.key_ === 0 ? this.storiesContainer_.querySelectorAll(".storyly__story")[this.key_].before(this.storyDom_) : this.storiesContainer_.querySelectorAll(".storyly__story")[this.key_ - 1].after(this.storyDom_) : this.storiesContainer_.appendChild(this.storyDom_), this.loadLayers_(), this.storyData_.type === "video")
|
|
48
|
+
this.videoAsset_ = this.storyDom_.querySelector("video"), this.handleVideoEvents_();
|
|
49
|
+
else if (!this.isBlankStory_)
|
|
50
|
+
this.imageAsset_ = this.storyDom_.querySelector("img"), this.imageAsset_.addEventListener("load", this.onImageLoad_, {
|
|
51
|
+
once: !0
|
|
52
|
+
});
|
|
53
|
+
else if (this.isBlankStory_) {
|
|
54
|
+
const A = this.storyDom_.querySelector(".story-image");
|
|
55
|
+
d(A, ["opacity", "0"]);
|
|
56
|
+
}
|
|
57
|
+
return this.setCustomEvents_(), this.handleStoryEvent_(), Promise.resolve(this.storyDom_);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* on image loaded
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
63
|
+
onImageLoad_() {
|
|
64
|
+
if (!this.imageAssetLoaded_ && (this.handleProgressBar_(), this.imageAssetLoaded_ = !0, !this.storyData_.position && !this.storyData_.sizing)) {
|
|
65
|
+
const { clientHeight: t, clientWidth: s } = this.imageAsset_;
|
|
66
|
+
this.setStoryClassByAsset_({ height: t, width: s });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* set story class by video/image for 9:16
|
|
71
|
+
* @private
|
|
72
|
+
*/
|
|
73
|
+
setStoryClassByAsset_({ width: t, height: s }) {
|
|
74
|
+
+(s * 56.25 / t).toFixed(2) < 100 && _(this.storyDom_, "story-9_16");
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* handle video events listener
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
handleVideoEvents_() {
|
|
81
|
+
this.videoAsset_.addEventListener(
|
|
82
|
+
"loadedmetadata",
|
|
83
|
+
this.onVideoLoadedData_
|
|
84
|
+
), this.videoAsset_.addEventListener("ended", this.onVideoEnded_), this.videoAsset_.addEventListener("waiting", this.onVideoWaiting_), this.videoAsset_.addEventListener("playing", this.onVideoPlaying_);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* on video loaded event
|
|
88
|
+
* @private
|
|
89
|
+
*/
|
|
90
|
+
async onVideoLoadedData_() {
|
|
91
|
+
if (this.videoAssetLoaded_ = !0, this.setStoryClassByAsset_({
|
|
92
|
+
height: this.videoAsset_.videoHeight,
|
|
93
|
+
width: this.videoAsset_.videoWidth
|
|
94
|
+
}), this.storyProgressRemain_ = this.videoAsset_.duration, this.storyProgressSecond_ = this.videoAsset_.duration, this.videoAsset_.duration >= 120 && !u(this.storyData_.video_type)) {
|
|
95
|
+
const t = await (await import("./index-DSDAcOiN.js")).default;
|
|
96
|
+
this.videoSeekbar_ = new t({
|
|
97
|
+
storyDom: this.storyDom_,
|
|
98
|
+
videoDom: this.videoAsset_,
|
|
99
|
+
layers: this.timedLayers_,
|
|
100
|
+
playPauseStory: this.playAndPauseStory.bind(this),
|
|
101
|
+
setProgressTime: this.setProgressTime.bind(this),
|
|
102
|
+
instanceId: this.instanceId_
|
|
103
|
+
}), this.videoAsset_.addEventListener(
|
|
104
|
+
"seeking",
|
|
105
|
+
this.handleLayersVisibility_
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
this.videoAsset_.addEventListener(
|
|
109
|
+
"timeupdate",
|
|
110
|
+
this.handleLayersVisibility_
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* on video ended event
|
|
115
|
+
* @private
|
|
116
|
+
*/
|
|
117
|
+
onVideoEnded_() {
|
|
118
|
+
this.storylyContext.getState().accessibility || n(this.storyDom_, m.nextStory);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* on video waiting event
|
|
122
|
+
* @private
|
|
123
|
+
*/
|
|
124
|
+
onVideoWaiting_() {
|
|
125
|
+
this.progressPaused_ = !0;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* on video playing event
|
|
129
|
+
* @private
|
|
130
|
+
*/
|
|
131
|
+
onVideoPlaying_() {
|
|
132
|
+
if (!this.videoAssetLoaded_)
|
|
133
|
+
return;
|
|
134
|
+
const s = this.groupWrapper_.querySelector(
|
|
135
|
+
".storyly__story-actions"
|
|
136
|
+
).querySelector('button[data-type="sound"]');
|
|
137
|
+
f(this.videoAsset_) || (this.soundOn_ = !1, s.classList.replace("sound-on", "sound-off")), this.soundOn_ ? this.soundOn() : this.soundOff(), this.progressPaused_ = !1, this.handleProgressBar_();
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* handles video load and play events when story active
|
|
141
|
+
* @private
|
|
142
|
+
*/
|
|
143
|
+
async onVideoShown_() {
|
|
144
|
+
const t = this.videoAsset_.querySelector("source"), s = this.videoAsset_.querySelector("source").dataset.src;
|
|
145
|
+
u(this.storyData_.video_type) ? this.hls_ = await W({
|
|
146
|
+
source: s,
|
|
147
|
+
tag: this.videoAsset_,
|
|
148
|
+
thumbnail: this.storyData_.thumbnail_url
|
|
149
|
+
}) : (t.src = s, this.videoAsset_.load()), this.videoAsset_.oncanplay = () => {
|
|
150
|
+
this.videoPausedPromise_ ? this.videoPausedPromise_.then(() => {
|
|
151
|
+
this.videoPlayedPromise_ = this.videoAsset_.play();
|
|
152
|
+
}) : this.videoPlayedPromise_ = this.videoAsset_.play();
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* remove events
|
|
157
|
+
* @private
|
|
158
|
+
*/
|
|
159
|
+
removeEvents_() {
|
|
160
|
+
const t = this.groupWrapper_.querySelector(
|
|
161
|
+
".storyly__story-actions"
|
|
162
|
+
), s = t.querySelector('button[data-type="sound"]'), e = t.querySelector('button[data-type="share"]'), o = t.querySelector('button[data-type="close"]'), i = t.querySelector(
|
|
163
|
+
'button[data-type="transcript"]'
|
|
164
|
+
);
|
|
165
|
+
this.playPauseAction_ && !v() && l(this.playPauseAction_, this.playAndPauseStory), o && !o.hasAttribute("hidden") && l(o, this.handleCloseGroup_), l(s, this.handleSoundStory_), l(e, this.renderShareWidget), l(i, this.handleTranscript_);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* load layers of story
|
|
169
|
+
* @private
|
|
170
|
+
*/
|
|
171
|
+
async loadLayers_() {
|
|
172
|
+
this.layers_.forEach(async (t, s) => {
|
|
173
|
+
const e = t, o = {
|
|
174
|
+
layer: { ...t, z_index: s },
|
|
175
|
+
group: this.group_,
|
|
176
|
+
story: this.story_,
|
|
177
|
+
storyDom: this.layersContainer_,
|
|
178
|
+
instanceId: this.instanceId_
|
|
179
|
+
};
|
|
180
|
+
if (t.is_bg && (t.bg_color || t.gradient_colors)) {
|
|
181
|
+
this.isBlankStory_ = !0;
|
|
182
|
+
const i = (await import("./index-Dg1MB9Rw.js")).default;
|
|
183
|
+
e.instance = new i({ ...o });
|
|
184
|
+
}
|
|
185
|
+
if (t.type === r.EMOJI) {
|
|
186
|
+
const i = (await import("./index-CJNQLd4X.js")).default;
|
|
187
|
+
e.instance = new i({ ...o });
|
|
188
|
+
} else if (t.type === r.POLL) {
|
|
189
|
+
const i = (await import("./index-89h_T8JG.js")).default;
|
|
190
|
+
e.instance = new i({ ...o });
|
|
191
|
+
} else if (t.type === r.RATING) {
|
|
192
|
+
const i = (await import("./index-0vaGlAUL.js")).default;
|
|
193
|
+
e.instance = new i({ ...o });
|
|
194
|
+
} else if (t.type === r.QUIZ) {
|
|
195
|
+
const i = (await import("./index-CTlHkeix.js")).default;
|
|
196
|
+
e.instance = new i({ ...o });
|
|
197
|
+
} else if (t.type === r.COUNTDOWN) {
|
|
198
|
+
const i = (await import("./index-De2W1vFd.js")).default;
|
|
199
|
+
e.instance = new i({ ...o });
|
|
200
|
+
} else if (t.type === r.IMAGE_CTA) {
|
|
201
|
+
const i = (await import("./index-BYzPEcYu.js")).default;
|
|
202
|
+
e.instance = new i({
|
|
203
|
+
...o,
|
|
204
|
+
type: r.IMAGE_CTA
|
|
205
|
+
});
|
|
206
|
+
} else if (t.type === r.BUTTON || t.type === r.SWIPE)
|
|
207
|
+
this.ctaLayer_ = new B({
|
|
208
|
+
...o,
|
|
209
|
+
type: t.type === r.BUTTON ? r.BUTTON : r.SWIPE
|
|
210
|
+
}), e.instance = this.ctaLayer_;
|
|
211
|
+
else if ((t.image_path || t.video_path || t.image_url) && t.studio_component_type) {
|
|
212
|
+
const i = (await import("./index-BP7hmUrm.js")).default;
|
|
213
|
+
e.instance = new i({
|
|
214
|
+
...o,
|
|
215
|
+
mediaHost: this.group_.media_host
|
|
216
|
+
});
|
|
217
|
+
} else if (t.type === r.TEXT) {
|
|
218
|
+
const i = (await import("./index-BtQfo9gV.js")).default;
|
|
219
|
+
e.instance = new i({ ...o });
|
|
220
|
+
} else if (t.type === r.PRODUCT_TAG) {
|
|
221
|
+
const i = (await import("./index-B2khaTGj.js")).default;
|
|
222
|
+
e.instance = new i({ ...o });
|
|
223
|
+
} else if (t.type === r.PROMO_CODE) {
|
|
224
|
+
const i = (await import("./index-C9j2XbJF.js")).default;
|
|
225
|
+
e.instance = new i({ ...o });
|
|
226
|
+
} else if (t.type === r.QUESTION) {
|
|
227
|
+
const i = (await import("./index-BV8oGJSO.js")).default;
|
|
228
|
+
e.instance = new i({
|
|
229
|
+
...o,
|
|
230
|
+
storiesContainer: this.storiesContainer_
|
|
231
|
+
});
|
|
232
|
+
} else if (t.type === r.PRODUCT_CARD) {
|
|
233
|
+
const i = (await import("./index-DyNf3LKt.js")).default;
|
|
234
|
+
e.instance = new i({ ...o });
|
|
235
|
+
} else if (t.type === r.PRODUCT_CATALOG) {
|
|
236
|
+
const i = (await import("./index-DHIwqpCn.js")).default;
|
|
237
|
+
e.instance = new i({ ...o });
|
|
238
|
+
} else if (t.type === r.IMAGE_QUIZ) {
|
|
239
|
+
const i = (await import("./index-B28omzDH.js")).default;
|
|
240
|
+
e.instance = new i({ ...o });
|
|
241
|
+
}
|
|
242
|
+
(e.start_time || e.end_time) && (e.instance.hideLayer(), this.timedLayers_.push(e));
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* start story progress
|
|
247
|
+
* @private
|
|
248
|
+
* @returns {void}
|
|
249
|
+
*/
|
|
250
|
+
handleProgressBar_() {
|
|
251
|
+
if (this.progressInterval_)
|
|
252
|
+
return;
|
|
253
|
+
this.progressCount_ = 0;
|
|
254
|
+
const t = this.progressDoms_[this.key_].querySelector("span");
|
|
255
|
+
if (u(this.storyData_.video_type)) {
|
|
256
|
+
this.progressCount_ = 100, d(t, ["width", `${this.progressCount_}%`]);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
this.progressInterval_ = setInterval(() => {
|
|
260
|
+
this.progressPaused_ || (this.progressTime_ += 0.1, this.storyProgressRemain_ -= 0.1, this.videoAsset_ ? this.play() : (this.handleLayersVisibility_(), this.handleProgress_()), this.progressCount_ = this.progressTime_ * 100 / this.storyProgressSecond_, this.progressCount_ <= 100 && d(t, ["width", `${this.progressCount_}%`]));
|
|
261
|
+
}, 100);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* handle layer visibility by progress time
|
|
265
|
+
* @returns
|
|
266
|
+
*/
|
|
267
|
+
handleLayersVisibility_() {
|
|
268
|
+
if (this.progressPaused_ && !this.videoAsset_)
|
|
269
|
+
return;
|
|
270
|
+
const t = (this.videoAsset_ ? this.videoAsset_.currentTime : this.progressTime_) * 1e3;
|
|
271
|
+
this.timedLayers_.forEach((s) => {
|
|
272
|
+
const e = s.start_time ? s.start_time * 1e3 - 300 : 0, o = s.end_time ? s.end_time * 1e3 : this.videoAsset_ ? this.videoAsset_.duration * 1e3 : this.storyProgressSecond_ * 1e3;
|
|
273
|
+
t >= e && t <= o ? s.instance.showLayer() : s.instance.hideLayer();
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* handle story progress and dispatch event
|
|
278
|
+
* @private
|
|
279
|
+
*/
|
|
280
|
+
handleProgress_() {
|
|
281
|
+
this.storyProgressRemain_ <= 0 && !this.storylyContext.getState().accessibility && (n(this.storyDom_, m.nextStory), clearInterval(this.progressInterval_));
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* handle story actions(play, sound)
|
|
285
|
+
* @private
|
|
286
|
+
*/
|
|
287
|
+
handleStoryActions_() {
|
|
288
|
+
const t = this.groupWrapper_.querySelector(
|
|
289
|
+
".storyly__story-actions"
|
|
290
|
+
), s = t.querySelector('button[data-type="sound"]'), e = t.querySelector('button[data-type="share"]'), o = t.querySelector('button[data-type="close"]'), i = t.querySelector(
|
|
291
|
+
'button[data-type="transcript"]'
|
|
292
|
+
);
|
|
293
|
+
this.playPauseAction_ = t.querySelector(
|
|
294
|
+
'button[data-type="play-pause"]'
|
|
295
|
+
), o && (h(o, "hidden"), c(o, this.handleCloseGroup_)), v() ? (a(this.playPauseAction_, "hidden", !0), this.accessibilityAction_ = this.storiesContainer_.querySelector(
|
|
296
|
+
".accessibility-switch-button"
|
|
297
|
+
), this.accessibilityAction_ && (this.accessibilityAction_.addEventListener(
|
|
298
|
+
"pointerdown",
|
|
299
|
+
this.handleAccessibilityOnOff_
|
|
300
|
+
), this.storylyContext.getState().accessibility ? (this.accessibilityAction_.setAttribute("data-pressed", "true"), n(this.storyDom_, "onAccessibilityTriggered", {
|
|
301
|
+
accessibilityEnabled: !0
|
|
302
|
+
})) : (this.accessibilityAction_.setAttribute("data-pressed", "false"), n(this.storyDom_, "onAccessibilityTriggered", {
|
|
303
|
+
accessibilityEnabled: !1
|
|
304
|
+
})))) : (h(this.playPauseAction_, "hidden"), this.playPauseAction_.classList.replace("play", "pause"), c(this.playPauseAction_, this.playAndPauseStory)), this.videoAsset_ ? (h(s, "hidden"), c(s, this.handleSoundStory_), this.story_.alt_text && (h(i, "hidden"), c(i, this.handleTranscript_))) : (a(s, "hidden", !0), a(i, "hidden", !0)), !this.storylyContext.getState().videoMuted && this.videoAsset_ ? (this.videoAsset_.muted = !1, this.soundOn_ = !0, s.classList.replace("sound-off", "sound-on")) : this.videoAsset_ && (this.videoAsset_.muted = !0, this.soundOn_ = !1, s.classList.replace("sound-on", "sound-off")), this.story_.is_sharable && (h(e, "hidden"), c(e, this.renderShareWidget));
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* @param {PointerEvent} e
|
|
308
|
+
* @private
|
|
309
|
+
*/
|
|
310
|
+
handleAccessibilityOnOff_(t) {
|
|
311
|
+
const { target: s } = t, e = s.getAttribute("data-pressed") === "true";
|
|
312
|
+
t.target.setAttribute("data-pressed", String(!e)), this.storylyContext.getState().accessibility ? (this.storyDom_.hasAttribute("paused") ? this.play() : this.handleProgressBar_(), g(this.storyDom_, "Accessibility is off"), s.setAttribute(
|
|
313
|
+
"aria-label",
|
|
314
|
+
this.storylyContext.getState().languageJSON.a11y_dtap_enable_accessibility
|
|
315
|
+
), S.setItemToGlobal("accessibility", !1), this.storylyContext.setState({
|
|
316
|
+
accessibility: !1
|
|
317
|
+
}), n(this.storyDom_, "onAccessibilityTriggered", {
|
|
318
|
+
accessibilityEnabled: !1
|
|
319
|
+
})) : (this.storylyContext.setState({
|
|
320
|
+
accessibility: !0
|
|
321
|
+
}), g(this.storyDom_, "Accessibility is on"), this.pause(), s.setAttribute(
|
|
322
|
+
"aria-label",
|
|
323
|
+
this.storylyContext.getState().languageJSON.a11y_disable_accessibility
|
|
324
|
+
), S.setItemToGlobal("accessibility", !0), n(this.storyDom_, "onAccessibilityTriggered", {
|
|
325
|
+
accessibilityEnabled: !0
|
|
326
|
+
}));
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* handle video transcript if exists
|
|
330
|
+
*/
|
|
331
|
+
handleTranscript_() {
|
|
332
|
+
const t = y(
|
|
333
|
+
`<div style="white-space: pre-wrap; font-size: 14px; padding: 16px;">${this.story_.alt_text}</div>`
|
|
334
|
+
), s = y(
|
|
335
|
+
'<span style="display: none;"></span>'
|
|
336
|
+
), e = y(
|
|
337
|
+
'<span style="display: none;"></span>'
|
|
338
|
+
);
|
|
339
|
+
n(
|
|
340
|
+
this.storyDom_,
|
|
341
|
+
w(this.instanceId_),
|
|
342
|
+
{
|
|
343
|
+
header: s,
|
|
344
|
+
body: t,
|
|
345
|
+
rerender: !1,
|
|
346
|
+
footer: e
|
|
347
|
+
}
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* render share widget
|
|
352
|
+
* handle clicked close icon
|
|
353
|
+
* @private
|
|
354
|
+
*/
|
|
355
|
+
handleCloseGroup_() {
|
|
356
|
+
n(this.storyDom_, "onCloseGroup");
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* handle sound of active story
|
|
360
|
+
* @param {Event} e
|
|
361
|
+
* @private
|
|
362
|
+
*/
|
|
363
|
+
handleSoundStory_(t) {
|
|
364
|
+
if (!f(this.videoAsset_)) {
|
|
365
|
+
const i = y(R);
|
|
366
|
+
this.storyDom_.append(i), setTimeout(() => {
|
|
367
|
+
this.storyDom_.removeChild(i);
|
|
368
|
+
}, 1e3);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
const { target: s } = t;
|
|
372
|
+
let e = "sound-on", o = "sound-off";
|
|
373
|
+
s.classList.contains("sound-off") ? (g(this.storyDom_, "Story Unmuted"), s.setAttribute("aria-pressed", "false"), this.soundOn_ = !0, this.soundOn(), this.storylyContext.setState({
|
|
374
|
+
videoMuted: !1
|
|
375
|
+
})) : (g(this.storyDom_, "Story Muted"), s.setAttribute("aria-pressed", "true"), this.soundOn_ = !1, this.soundOff(), e = "sound-off", o = "sound-on", this.storylyContext.setState({
|
|
376
|
+
videoMuted: !0
|
|
377
|
+
})), s.classList.replace(o, e);
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* making ctas visible for assistive technologies
|
|
381
|
+
* @private
|
|
382
|
+
*/
|
|
383
|
+
exposeAccessibilityElements_() {
|
|
384
|
+
this.storyDom_.querySelectorAll(".cta-button").forEach((t) => {
|
|
385
|
+
a(t, "tabindex", "21"), a(t, "aria-hidden", "false");
|
|
386
|
+
}), this.storyDom_.querySelectorAll(".swipe-up-button").forEach((t) => {
|
|
387
|
+
a(t, "tabindex", "21"), a(t, "aria-hidden", "false");
|
|
388
|
+
}), this.storyDom_.querySelectorAll(".product-tag-tooltip").forEach((t) => {
|
|
389
|
+
a(t, "tabindex", "21"), a(t, "aria-hidden", "false");
|
|
390
|
+
}), this.storyDom_.querySelectorAll(".poll-component").forEach((t) => {
|
|
391
|
+
t.querySelectorAll("button").forEach((s) => a(s, "tabindex", "22")), a(t, "tabindex", "22"), a(t, "aria-hidden", "false");
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* hiding ctas for assistive technologies
|
|
396
|
+
* @private
|
|
397
|
+
*/
|
|
398
|
+
hideAccessibilityElements_() {
|
|
399
|
+
this.storyDom_.querySelectorAll(".cta-button").forEach((t) => {
|
|
400
|
+
h(t, "tabindex"), a(t, "aria-hidden", "true");
|
|
401
|
+
}), this.storyDom_.querySelectorAll(".swipe-up-button").forEach((t) => {
|
|
402
|
+
h(t, "tabindex"), a(t, "aria-hidden", "true");
|
|
403
|
+
}), this.storyDom_.querySelectorAll(".product-tag-tooltip").forEach((t) => {
|
|
404
|
+
h(t, "tabindex"), a(t, "aria-hidden", "true");
|
|
405
|
+
}), this.storyDom_.querySelectorAll(".poll-component").forEach((t) => {
|
|
406
|
+
t.querySelectorAll("button").forEach((s) => h(s, "tabindex")), h(t, "tabindex"), a(t, "aria-hidden", "true");
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* render share widget
|
|
411
|
+
* @public
|
|
412
|
+
*/
|
|
413
|
+
async renderShareWidget() {
|
|
414
|
+
this.shareWidget_ = await G({
|
|
415
|
+
dom: this.storyDom_,
|
|
416
|
+
group: this.group_,
|
|
417
|
+
story: this.story_,
|
|
418
|
+
playAndPauseStory: this.playAndPauseStory.bind(this)
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* handle video sound on
|
|
423
|
+
* @public
|
|
424
|
+
*/
|
|
425
|
+
soundOn() {
|
|
426
|
+
this.videoAsset_.muted = !1;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* handle video sound off
|
|
430
|
+
* @public
|
|
431
|
+
*/
|
|
432
|
+
soundOff() {
|
|
433
|
+
this.videoAsset_.muted = !0;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* pause image/video story
|
|
437
|
+
* @param { Boolean } tabChange
|
|
438
|
+
* @public
|
|
439
|
+
*/
|
|
440
|
+
pause(t = !1) {
|
|
441
|
+
t && this.hideShareWidget(), this.progressPaused_ = !0, this.storyDom_.setAttribute("paused", ""), this.videoAsset_ && (this.videoPlayedPromise_ ? this.videoPlayedPromise_.then(() => {
|
|
442
|
+
this.videoPausedPromise_ = this.videoAsset_.pause();
|
|
443
|
+
}) : this.videoPausedPromise_ = this.videoAsset_.pause());
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* play image/video story
|
|
447
|
+
* @param { Boolean } tabChange
|
|
448
|
+
* @public
|
|
449
|
+
*/
|
|
450
|
+
play(t = !1) {
|
|
451
|
+
t && this.playPauseAction_.classList.contains("play") && this.playPauseAction_.classList.replace("play", "pause"), this.progressPaused_ = !1, this.storyDom_.removeAttribute("paused"), this.videoAsset_ && !x(this.videoAsset_) && (this.videoPausedPromise_ ? this.videoPausedPromise_.then(() => {
|
|
452
|
+
this.videoPlayedPromise_ = this.videoAsset_.play();
|
|
453
|
+
}) : this.videoPlayedPromise_ = this.videoAsset_.play());
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
*
|
|
457
|
+
* sets video source if intersecting
|
|
458
|
+
* @public
|
|
459
|
+
*/
|
|
460
|
+
setVideoStoryAsset() {
|
|
461
|
+
if (this.storyData_.type !== "video" && !this.story_.media.thumbnail_url || u(this.storyData_.video_type))
|
|
462
|
+
return;
|
|
463
|
+
const t = b({
|
|
464
|
+
host: this.group_.media_host,
|
|
465
|
+
path: this.story_.media.thumbnail_url,
|
|
466
|
+
story: this.storyData_
|
|
467
|
+
});
|
|
468
|
+
a(this.storyDom_.querySelector("video"), "poster", t);
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* handle pause or play of active story
|
|
472
|
+
* @param {Event | undefined} event
|
|
473
|
+
* @public
|
|
474
|
+
*/
|
|
475
|
+
playAndPauseStory() {
|
|
476
|
+
if (this.storylyContext.getState().accessibility) return;
|
|
477
|
+
let t = "play", s = "pause";
|
|
478
|
+
this.playPauseAction_.classList.contains("pause") ? (this.pause(), this.playPauseAction_.setAttribute("aria-pressed", "true"), n(this.storyDom_, "onPlayPauseEvent", {
|
|
479
|
+
eventType: P.Paused
|
|
480
|
+
})) : (this.play(), this.playPauseAction_.setAttribute("aria-pressed", "false"), n(this.storyDom_, "onPlayPauseEvent", {
|
|
481
|
+
eventType: P.Resumed
|
|
482
|
+
}), t = "pause", s = "play"), this.playPauseAction_.classList.replace(s, t);
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* send story viewed event
|
|
486
|
+
*/
|
|
487
|
+
sendStoryViewedEvent_() {
|
|
488
|
+
const t = { ...this.getStoryData() };
|
|
489
|
+
n(this.storyDom_, "onCustomerEvent", {
|
|
490
|
+
eventName: m.storyViewed,
|
|
491
|
+
params: t
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* modifies story title with every story change
|
|
496
|
+
* @private
|
|
497
|
+
*/
|
|
498
|
+
handleStoryTitleOnChange_() {
|
|
499
|
+
const { title: t } = this.story_;
|
|
500
|
+
if (t) {
|
|
501
|
+
const s = this.groupWrapper_.querySelector(".storyly__sg-info h4");
|
|
502
|
+
s.textContent = t;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* handle story event
|
|
507
|
+
* @private
|
|
508
|
+
*/
|
|
509
|
+
handleStoryEvent_() {
|
|
510
|
+
this.storyDom_.addEventListener("onStoryEvent", (t) => {
|
|
511
|
+
const s = {
|
|
512
|
+
storyComponent: t.detail,
|
|
513
|
+
storyGroup: {
|
|
514
|
+
...this.group_,
|
|
515
|
+
iconUrl: this.group_.icon_image_url ?? this.group_.icon_video_url,
|
|
516
|
+
icon_image_url: void 0
|
|
517
|
+
},
|
|
518
|
+
story: {
|
|
519
|
+
...this.story_,
|
|
520
|
+
componentList: this.story_.media.layers,
|
|
521
|
+
currentTime: this.getWatchLength(),
|
|
522
|
+
media: void 0
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
n(this.storyDom_, "onCustomerEvent", {
|
|
526
|
+
eventName: k,
|
|
527
|
+
params: s
|
|
528
|
+
});
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* handle show story
|
|
533
|
+
* @public
|
|
534
|
+
*/
|
|
535
|
+
show() {
|
|
536
|
+
if (this.group_.type === I.REDIRECT) {
|
|
537
|
+
this.ctaLayer_.handleUrlForRedirectGroup();
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
this.storyDom_.setAttribute("show", ""), n(this.storyDom_, "storyChange", {
|
|
541
|
+
asset: this.isBlankStory_ ? "" : this.imageAsset_ ?? this.videoAsset_
|
|
542
|
+
}), O(
|
|
543
|
+
this.group_.group_id,
|
|
544
|
+
this.story_.story_id,
|
|
545
|
+
this.storylyContext.getState().shareParams
|
|
546
|
+
), this.handleStoryActions_(), this.handleStoryTitleOnChange_(), this.progressPaused_ = !1, this.storyProgressRemain_ = this.storyProgressSecond_, this.progressTime_ = 0, p(this.progressDoms_[this.key_], "seen"), this.videoAsset_ ? this.onVideoShown_() : this.isBlankStory_ || this.imageAssetLoaded_ ? this.handleProgressBar_() : this.imageAsset_.style.paddingBottom = "0.5px", this.storylyContext.getState().accessibility && d(this.playPauseAction_, ["display", "none"]), this.exposeAccessibilityElements_(), _(this.progressDoms_[this.key_], "active"), _(this.storyDom_, "active"), setTimeout(() => {
|
|
547
|
+
this.storyDom_.focus();
|
|
548
|
+
}, 500), this.sendStoryViewedEvent_(), n(this.storyDom_, "onShortcut", {
|
|
549
|
+
is_sharable: this.story_.is_sharable
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* handle hide story
|
|
554
|
+
* @param {Boolean} isBack
|
|
555
|
+
* @param {Boolean} holdActive
|
|
556
|
+
* @public
|
|
557
|
+
*/
|
|
558
|
+
hide({ isBack: t = !1, holdActive: s = !1 } = {}) {
|
|
559
|
+
var e;
|
|
560
|
+
if (this.storyDom_.removeAttribute("show"), this.storyDom_.hasAttribute("paused") && this.storyDom_.removeAttribute("paused"), this.hideAccessibilityElements_(), clearInterval(this.progressInterval_), clearInterval(this.startInterval_), this.progressInterval_ = null, this.startInterval_ = null, this.videoAsset_) {
|
|
561
|
+
if (this.videoAsset_.currentTime = 0, this.videoPlayedPromise_ ? this.videoPlayedPromise_.then(() => {
|
|
562
|
+
this.videoPausedPromise_ = this.videoAsset_.pause();
|
|
563
|
+
}) : this.videoPausedPromise_ = this.videoAsset_.pause(), this.hls_) {
|
|
564
|
+
this.hls_.stopLoad();
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
this.videoAsset_.querySelector("source").src = "", this.videoAsset_.load();
|
|
568
|
+
}
|
|
569
|
+
this.removeEvents_(), this.progressPaused_ = !0, p(this.progressDoms_[this.key_], "active"), s || p(this.storyDom_, "active"), q(this.progressDoms_[this.key_].querySelector("span"), ["width"]), t ? p(this.progressDoms_[this.key_], "seen") : _(this.progressDoms_[this.key_], "seen"), (e = this.shareWidget_) == null || e.hide(), this.timedLayers_.forEach((o) => o.instance.hideLayer());
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* get story watch length
|
|
573
|
+
* @public
|
|
574
|
+
* @returns {number}
|
|
575
|
+
*/
|
|
576
|
+
getWatchLength() {
|
|
577
|
+
const t = this.storyProgressRemain_ < 0 ? 0 : Math.round(this.storyProgressRemain_);
|
|
578
|
+
return (Math.round(this.storyProgressSecond_) - t) * 1e3;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* get story watch length
|
|
582
|
+
* @public
|
|
583
|
+
* @returns {Boolean}
|
|
584
|
+
*/
|
|
585
|
+
getProgressPausedStatus() {
|
|
586
|
+
return this.progressPaused_;
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* get story data
|
|
590
|
+
* @returns {Object}
|
|
591
|
+
*/
|
|
592
|
+
getStoryData() {
|
|
593
|
+
const t = b({
|
|
594
|
+
host: this.group_.media_host,
|
|
595
|
+
story: this.storyData_
|
|
596
|
+
});
|
|
597
|
+
return {
|
|
598
|
+
story_id: this.story_.story_id,
|
|
599
|
+
media: t,
|
|
600
|
+
group: this.group_,
|
|
601
|
+
index: this.key_,
|
|
602
|
+
title: this.story_.title,
|
|
603
|
+
name: this.story_.name
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* send story clicked event
|
|
608
|
+
* @param {String} type
|
|
609
|
+
*/
|
|
610
|
+
sendStoryClickedEvent(t) {
|
|
611
|
+
const s = {
|
|
612
|
+
...this.getStoryData()
|
|
613
|
+
};
|
|
614
|
+
n(this.storyDom_, "onCustomerEvent", {
|
|
615
|
+
eventName: t === "next" ? "CustomerEventTypes.nextStory" : m.previousStory,
|
|
616
|
+
params: s
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* set story key
|
|
621
|
+
* @param {Number} key
|
|
622
|
+
*/
|
|
623
|
+
setKey(t) {
|
|
624
|
+
this.key_ = t;
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* set progress time for timed interactives
|
|
628
|
+
* @param {Number} time
|
|
629
|
+
*/
|
|
630
|
+
setProgressTime(t) {
|
|
631
|
+
this.progressTime_ = +t.toFixed(1);
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* pause image story by touch
|
|
635
|
+
* @public
|
|
636
|
+
*/
|
|
637
|
+
pauseByTouch() {
|
|
638
|
+
this.pause(), d(this.storiesContainer_.querySelector(".storyly__story-header"), [
|
|
639
|
+
"opacity",
|
|
640
|
+
0
|
|
641
|
+
]);
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* play image story by touch
|
|
645
|
+
* @public
|
|
646
|
+
*/
|
|
647
|
+
playAfterTouch() {
|
|
648
|
+
d(this.storiesContainer_.querySelector(".storyly__story-header"), [
|
|
649
|
+
"opacity",
|
|
650
|
+
1
|
|
651
|
+
]), this.play();
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* hide share widget
|
|
655
|
+
*/
|
|
656
|
+
hideShareWidget() {
|
|
657
|
+
this.shareWidget_ && this.shareWidget_.hide();
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
export {
|
|
661
|
+
Q as B
|
|
662
|
+
};
|