admin-foogallery-attachment-autosave.js
1 day ago
admin-foogallery-divi.js
1 day ago
admin-foogallery-edit.js
1 day ago
admin-foogallery-editor.js
1 day ago
admin-foogallery-elementor.js
1 day ago
admin-page-foogallery-extensions-modal.js
1 day ago
admin-page-foogallery-extensions.js
1 day ago
admin-page-foogallery-settings.js
1 day ago
admin-tinymce.js
1 day ago
admin-uploader.js
1 day ago
foogallery-command-palette.js
1 day ago
foogallery.admin.datasources.js
1 day ago
foogallery.admin.min.js
1 day ago
foogallery.admin.template.js
1 day ago
admin-foogallery-divi.js
76 lines
| 1 | ( function ( window, document ) { |
| 2 | 'use strict'; |
| 3 | |
| 4 | let observer; |
| 5 | let scheduled = false; |
| 6 | |
| 7 | /** |
| 8 | * Initialize galleries copied into the Divi canvas without their jQuery data. |
| 9 | * |
| 10 | * Divi renders legacy modules in a hidden preview document and copies their |
| 11 | * HTML into the visual builder. Shortcodes inside native modules are cloned |
| 12 | * in the same way. The copied elements retain FooGallery's CSS state classes, |
| 13 | * but JavaScript instances and event handlers cannot survive that copy. |
| 14 | */ |
| 15 | function initializeCopiedGalleries() { |
| 16 | const FooGallery = window.FooGallery; |
| 17 | |
| 18 | scheduled = false; |
| 19 | |
| 20 | if ( ! FooGallery || ! FooGallery.$ || ! FooGallery.Template ) { |
| 21 | return; |
| 22 | } |
| 23 | |
| 24 | FooGallery.$( '.foogallery[id^="foogallery-gallery-"]' ).each( |
| 25 | function () { |
| 26 | const instance = FooGallery.get( this ); |
| 27 | |
| 28 | if ( instance instanceof FooGallery.Template ) { |
| 29 | return; |
| 30 | } |
| 31 | |
| 32 | FooGallery.$( this ).foogallery( FooGallery.autoDefaults ); |
| 33 | } |
| 34 | ); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Debounce repeated mutations generated while Divi updates a module. |
| 39 | */ |
| 40 | function scheduleInitialization() { |
| 41 | if ( scheduled ) { |
| 42 | return; |
| 43 | } |
| 44 | |
| 45 | scheduled = true; |
| 46 | window.setTimeout( initializeCopiedGalleries, 50 ); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Watch the visual builder canvas for shortcode and legacy module previews. |
| 51 | */ |
| 52 | function observeBuilder() { |
| 53 | if ( observer || ! document.body ) { |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | observer = new window.MutationObserver( scheduleInitialization ); |
| 58 | observer.observe( document.body, { |
| 59 | childList: true, |
| 60 | subtree: true, |
| 61 | } ); |
| 62 | |
| 63 | scheduleInitialization(); |
| 64 | } |
| 65 | |
| 66 | if ( 'loading' === document.readyState ) { |
| 67 | document.addEventListener( 'DOMContentLoaded', observeBuilder, { |
| 68 | once: true, |
| 69 | } ); |
| 70 | } else { |
| 71 | observeBuilder(); |
| 72 | } |
| 73 | |
| 74 | document.addEventListener( 'foogallery-ready', scheduleInitialization ); |
| 75 | } )( window, document ); |
| 76 |