File Editor
Directories:
.. (Back)
crop
imgareaselect
jcrop
jquery
mediaelement
plupload
swfupload
thickbox
tinymce
Files:
admin-bar.js
admin-bar.min.js
autosave.js
autosave.min.js
backbone.min.js
colorpicker.js
colorpicker.min.js
comment-reply.js
comment-reply.min.js
customize-base.js
customize-base.min.js
customize-loader.js
customize-loader.min.js
customize-models.js
customize-models.min.js
customize-preview-nav-menus.js
customize-preview-nav-menus.min.js
customize-preview-widgets.js
customize-preview-widgets.min.js
customize-preview.js
customize-preview.min.js
customize-selective-refresh.js
customize-selective-refresh.min.js
customize-views.js
customize-views.min.js
heartbeat.js
heartbeat.min.js
hoverIntent.js
hoverIntent.min.js
imagesloaded.min.js
json2.js
json2.min.js
masonry.min.js
mce-view.js
mce-view.min.js
media-audiovideo.js
media-audiovideo.min.js
media-editor.js
media-editor.min.js
media-grid.js
media-grid.min.js
media-models.js
media-models.min.js
media-views.js
media-views.min.js
quicktags.js
quicktags.min.js
shortcode.js
shortcode.min.js
swfobject.js
tw-sack.js
tw-sack.min.js
twemoji.js
twemoji.min.js
underscore.min.js
utils.js
utils.min.js
wp-a11y.js
wp-a11y.min.js
wp-ajax-response.js
wp-ajax-response.min.js
wp-auth-check.js
wp-auth-check.min.js
wp-backbone.js
wp-backbone.min.js
wp-embed-template.js
wp-embed-template.min.js
wp-embed.js
wp-embed.min.js
wp-emoji-loader.js
wp-emoji-loader.min.js
wp-emoji-release.min.js
wp-emoji.js
wp-emoji.min.js
wp-list-revisions.js
wp-list-revisions.min.js
wp-lists.js
wp-lists.min.js
wp-pointer.js
wp-pointer.min.js
wp-util.js
wp-util.min.js
wpdialog.js
wpdialog.min.js
wplink.js
wplink.min.js
zxcvbn-async.js
zxcvbn-async.min.js
zxcvbn.min.js
Create New File
Create
Edit File: customize-loader.js
/* global _wpCustomizeLoaderSettings, confirm */ /* * Expose a public API that allows the customizer to be * loaded on any page. */ window.wp = window.wp || {}; (function( exports, $ ){ var api = wp.customize, Loader; $.extend( $.support, { history: !! ( window.history && history.pushState ), hashchange: ('onhashchange' in window) && (document.documentMode === undefined || document.documentMode > 7) }); /** * Allows the Customizer to be overlayed on any page. * * By default, any element in the body with the load-customize class will open * an iframe overlay with the URL specified. * * e.g. <a class="load-customize" href="<?php echo wp_customize_url(); ?>">Open Customizer</a> * * @augments wp.customize.Events */ Loader = $.extend( {}, api.Events, { /** * Setup the Loader; triggered on document#ready. */ initialize: function() { this.body = $( document.body ); // Ensure the loader is supported. // Check for settings, postMessage support, and whether we require CORS support. if ( ! Loader.settings || ! $.support.postMessage || ( ! $.support.cors && Loader.settings.isCrossDomain ) ) { return; } this.window = $( window ); this.element = $( '<div id="customize-container" />' ).appendTo( this.body ); // Bind events for opening and closing the overlay. this.bind( 'open', this.overlay.show ); this.bind( 'close', this.overlay.hide ); // Any element in the body with the `load-customize` class opens // the Customizer. $('#wpbody').on( 'click', '.load-customize', function( event ) { event.preventDefault(); // Store a reference to the link that opened the Customizer. Loader.link = $(this); // Load the theme. Loader.open( Loader.link.attr('href') ); }); // Add navigation listeners. if ( $.support.history ) { this.window.on( 'popstate', Loader.popstate ); } if ( $.support.hashchange ) { this.window.on( 'hashchange', Loader.hashchange ); this.window.triggerHandler( 'hashchange' ); } }, popstate: function( e ) { var state = e.originalEvent.state; if ( state && state.customize ) { Loader.open( state.customize ); } else if ( Loader.active ) { Loader.close(); } }, hashchange: function() { var hash = window.location.toString().split('#')[1]; if ( hash && 0 === hash.indexOf( 'wp_customize=on' ) ) { Loader.open( Loader.settings.url + '?' + hash ); } if ( ! hash && ! $.support.history ) { Loader.close(); } }, beforeunload: function () { if ( ! Loader.saved() ) { return Loader.settings.l10n.saveAlert; } }, /** * Open the Customizer overlay for a specific URL. * * @param string src URL to load in the Customizer. */ open: function( src ) { if ( this.active ) { return; } // Load the full page on mobile devices. if ( Loader.settings.browser.mobile ) { return window.location = src; } // Store the document title prior to opening the Live Preview this.originalDocumentTitle = document.title; this.active = true; this.body.addClass('customize-loading'); /* * Track the dirtiness state (whether the drafted changes have been published) * of the Customizer in the iframe. This is used to decide whether to display * an AYS alert if the user tries to close the window before saving changes. */ this.saved = new api.Value( true ); this.iframe = $( '<iframe />', { 'src': src, 'title': Loader.settings.l10n.mainIframeTitle } ).appendTo( this.element ); this.iframe.one( 'load', this.loaded ); // Create a postMessage connection with the iframe. this.messenger = new api.Messenger({ url: src, channel: 'loader', targetWindow: this.iframe[0].contentWindow }); // Wait for the connection from the iframe before sending any postMessage events. this.messenger.bind( 'ready', function() { Loader.messenger.send( 'back' ); }); this.messenger.bind( 'close', function() { if ( $.support.history ) { history.back(); } else if ( $.support.hashchange ) { window.location.hash = ''; } else { Loader.close(); } }); // Prompt AYS dialog when navigating away $( window ).on( 'beforeunload', this.beforeunload ); this.messenger.bind( 'saved', function () { Loader.saved( true ); } ); this.messenger.bind( 'change', function () { Loader.saved( false ); } ); this.messenger.bind( 'title', function( newTitle ){ window.document.title = newTitle; }); this.pushState( src ); this.trigger( 'open' ); }, pushState: function ( src ) { var hash = src.split( '?' )[1]; // Ensure we don't call pushState if the user hit the forward button. if ( $.support.history && window.location.href !== src ) { history.pushState( { customize: src }, '', src ); } else if ( ! $.support.history && $.support.hashchange && hash ) { window.location.hash = 'wp_customize=on&' + hash; } this.trigger( 'open' ); }, /** * Callback after the Customizer has been opened. */ opened: function() { Loader.body.addClass( 'customize-active full-overlay-active' ); }, /** * Close the Customizer overlay and return focus to the link that opened it. */ close: function() { if ( ! this.active ) { return; } // Display AYS dialog if Customizer is dirty if ( ! this.saved() && ! confirm( Loader.settings.l10n.saveAlert ) ) { // Go forward since Customizer is exited by history.back() history.forward(); return; } this.active = false; this.trigger( 'close' ); // Restore document title prior to opening the Live Preview if ( this.originalDocumentTitle ) { document.title = this.originalDocumentTitle; } // Return focus to link that was originally clicked. if ( this.link ) { this.link.focus(); } }, /** * Callback after the Customizer has been closed. */ closed: function() { Loader.iframe.remove(); Loader.messenger.destroy(); Loader.iframe = null; Loader.messenger = null; Loader.saved = null; Loader.body.removeClass( 'customize-active full-overlay-active' ).removeClass( 'customize-loading' ); $( window ).off( 'beforeunload', Loader.beforeunload ); }, /** * Callback for the `load` event on the Customizer iframe. */ loaded: function() { Loader.body.removeClass('customize-loading'); }, /** * Overlay hide/show utility methods. */ overlay: { show: function() { this.element.fadeIn( 200, Loader.opened ); }, hide: function() { this.element.fadeOut( 200, Loader.closed ); } } }); // Bootstrap the Loader on document#ready. $( function() { Loader.settings = _wpCustomizeLoaderSettings; Loader.initialize(); }); // Expose the API publicly on window.wp.customize.Loader api.Loader = Loader; })( wp, jQuery );
Save Changes
Rename File
Rename