PluginProbe
Elementor Website Builder – more than just a page builder / trunk
Elementor Website Builder – more than just a page builder vtrunk
4.3.3 4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 All 456 releases
elementor / modules / atomic-widgets / elements / atomic-background-video / handlers / editor-background-video-state.js

editor-background-video-state.js in Elementor Website Builder – more than just a page builder trunk, at modules/atomic-widgets/elements/atomic-background-video/handlers/editor-background-video-state.js

42 lines 1005 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { Alpine } from '@elementor/alpinejs';
2
3 const STORE_NAME = 'editor-background-video-state';
4 const PLAYING_STATE = 'playing';
5 const PAUSED_STATE = 'paused';
6
7 /**
8 * @typedef {Record<string, 'playing' | 'paused' | ''>} BackgroundVideoState
9 */
10
11 function ensureStore() {
12 if ( ! Alpine.store( STORE_NAME ) ) {
13 Alpine.store( STORE_NAME, /** @type {BackgroundVideoState} */ ( {} ) );
14 }
15
16 return /** @type {BackgroundVideoState} */ ( Alpine.store( STORE_NAME ) );
17 }
18
19 export function resolveDesignTimeState( state ) {
20 if ( PAUSED_STATE === state || '' === state ) {
21 return state;
22 }
23
24 return PLAYING_STATE;
25 }
26
27 export function getEditorState( elementId, fallback = PLAYING_STATE ) {
28 const store = ensureStore();
29
30 return store[ elementId ] ?? fallback;
31 }
32
33 export function setEditorState( elementId, state ) {
34 const store = ensureStore();
35
36 store[ elementId ] = state;
37 }
38
39 export function isEditorPreview() {
40 return Boolean( window.elementorFrontend?.isEditMode?.() || window.parent?.elementor );
41 }
42