mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-03 22:27:04 +00:00
Theme Customizer: Allow the customize iframe to be accessed directly (with full feature support). see #19910.
* Move the 'Return to Manage Themes' and 'Collapse Sidebar' actions from themes.php to customize-controls.php. * Create a postMessage connection between themes.php and customize-controls.php. * Allow the theme customizer to be accessed directly (independent of themes.php and the customize loader). * Add wp_customize_href() and wp_customize_url(). * Remove wp_customize_loader(). To include the loader, use wp_enqueue_script( 'customize-loader' ). * The theme customizer now requires postMessage browser support. * Add .hide-if-customize and .hide-if-no-customize CSS classes. * Clean up customize-preview.js. git-svn-id: https://develop.svn.wordpress.org/trunk@20476 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -2,28 +2,35 @@ if ( typeof wp === 'undefined' )
|
||||
var wp = {};
|
||||
|
||||
(function( exports, $ ){
|
||||
var Loader = {
|
||||
var api = wp.customize,
|
||||
Loader;
|
||||
|
||||
Loader = {
|
||||
initialize: function() {
|
||||
this.body = $( document.body );
|
||||
this.element = $( '#customize-container' );
|
||||
this.base = $( '.admin-url', this.element ).val();
|
||||
this.body = $( document.body ).addClass('customize-support');
|
||||
this.element = $( '<div id="customize-container" class="wp-full-overlay" />' ).appendTo( this.body );
|
||||
|
||||
this.element.on( 'click', '.close-full-overlay', function() {
|
||||
Loader.close();
|
||||
return false;
|
||||
});
|
||||
$('#wpbody').on( 'click', '.load-customize', function( event ) {
|
||||
event.preventDefault();
|
||||
|
||||
this.element.on( 'click', '.collapse-sidebar', function() {
|
||||
Loader.element.toggleClass('collapsed');
|
||||
return false;
|
||||
// Load the theme.
|
||||
Loader.open( $(this).attr('href') );
|
||||
});
|
||||
},
|
||||
open: function( params ) {
|
||||
params.customize = 'on';
|
||||
open: function( src ) {
|
||||
this.iframe = $( '<iframe />', { src: src }).appendTo( this.element );
|
||||
|
||||
this.iframe = $( '<iframe />', {
|
||||
src: this.base + '?' + jQuery.param( params )
|
||||
}).appendTo( this.element );
|
||||
// Create a postMessage connection with the iframe.
|
||||
this.messenger = new api.Messenger( src, 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', wpCustomizeLoaderL10n.back );
|
||||
});
|
||||
|
||||
this.messenger.bind( 'close', function() {
|
||||
Loader.close();
|
||||
});
|
||||
|
||||
this.element.fadeIn( 200, function() {
|
||||
Loader.body.addClass( 'customize-active full-overlay-active' );
|
||||
@@ -32,28 +39,18 @@ if ( typeof wp === 'undefined' )
|
||||
close: function() {
|
||||
this.element.fadeOut( 200, function() {
|
||||
Loader.iframe.remove();
|
||||
Loader.iframe = null;
|
||||
Loader.iframe = null;
|
||||
Loader.messenger = null;
|
||||
Loader.body.removeClass( 'customize-active full-overlay-active' );
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$( function() {
|
||||
Loader.initialize();
|
||||
|
||||
$('#wpbody').on( 'click', '.load-customize', function( event ) {
|
||||
var load = $(this);
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
// Load the theme.
|
||||
Loader.open({
|
||||
template: load.data('customizeTemplate'),
|
||||
stylesheet: load.data('customizeStylesheet')
|
||||
});
|
||||
});
|
||||
if ( !! window.postMessage )
|
||||
Loader.initialize();
|
||||
});
|
||||
|
||||
// Expose the API to the world.
|
||||
exports.CustomizeLoader = Loader;
|
||||
api.Loader = Loader;
|
||||
})( wp, jQuery );
|
||||
|
||||
Reference in New Issue
Block a user