| Linux webm007.cluster106.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 Path : /home/eglisebaa/www/wp-content/themes/hallelujah/plugins/gutenberg/ |
| Current File : /home/eglisebaa/www/wp-content/themes/hallelujah/plugins/gutenberg/gutenberg-preview.js |
/* global jQuery:false */
/* global HALLELUJAH_STORAGE:false */
jQuery( window ).load(function() {
"use strict";
hallelujah_gutenberg_first_init();
// Create the observer to reinit visual editor after switch from code editor to visual editor
var hallelujah_observers = {};
if (typeof window.MutationObserver !== 'undefined') {
hallelujah_create_observer('check_visual_editor', jQuery('.block-editor').eq(0), function(mutationsList) {
var gutenberg_editor = jQuery('.edit-post-visual-editor:not(.hallelujah_inited)').eq(0);
if (gutenberg_editor.length > 0) hallelujah_gutenberg_first_init();
});
}
function hallelujah_gutenberg_first_init() {
var gutenberg_editor = jQuery( '.edit-post-visual-editor:not(.hallelujah_inited)' ).eq( 0 );
if ( 0 == gutenberg_editor.length ) {
return;
}
jQuery( '.editor-block-list__layout' ).addClass( 'scheme_' + HALLELUJAH_STORAGE['color_scheme'] );
gutenberg_editor.addClass( 'sidebar_position_' + HALLELUJAH_STORAGE['sidebar_position'] );
if ( HALLELUJAH_STORAGE['expand_content'] > 0 ) {
gutenberg_editor.addClass( 'expand_content' );
}
if ( HALLELUJAH_STORAGE['sidebar_position'] == 'left' ) {
gutenberg_editor.prepend( '<div class="editor-post-sidebar-holder"></div>' );
} else if ( HALLELUJAH_STORAGE['sidebar_position'] == 'right' ) {
gutenberg_editor.append( '<div class="editor-post-sidebar-holder"></div>' );
}
gutenberg_editor.addClass('hallelujah_inited');
}
// Create mutations observer
function hallelujah_create_observer(id, obj, callback) {
if (typeof window.MutationObserver !== 'undefined' && obj.length > 0) {
if (typeof hallelujah_observers[id] == 'undefined') {
hallelujah_observers[id] = new MutationObserver(callback);
hallelujah_observers[id].observe(obj.get(0), { attributes: false, childList: true, subtree: true });
}
return true;
}
return false;
}
} );