Wordpress/wp-includes/js/customize-loader.dev.js
Daryl Koopersmith 31caea7b9b Theme Customizer: Improve the customize loader and themes list table markup. see #19910.
* Use event delegation for triggering the customize loader (so we play nicely with infinite scroll).
* Use data attributes on .load-customize links instead of parsing the href.
* Properly translate the 'Customize' string instead of injecting the replacement with JS.

git-svn-id: https://develop.svn.wordpress.org/trunk@20352 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-04 21:02:29 +00:00

60 lines
1.4 KiB
JavaScript

if ( typeof wp === 'undefined' )
var wp = {};
(function( exports, $ ){
var Loader = {
initialize: function() {
this.body = $( document.body );
this.element = $( '#customize-container' );
this.base = $( '.admin-url', this.element ).val();
this.element.on( 'click', '.close-full-overlay', function() {
Loader.close();
return false;
});
this.element.on( 'click', '.collapse-sidebar', function() {
Loader.element.toggleClass('collapsed');
return false;
});
},
open: function( params ) {
params.customize = 'on';
this.iframe = $( '<iframe />', {
src: this.base + '?' + jQuery.param( params )
}).appendTo( this.element );
this.element.fadeIn( 200, function() {
Loader.body.addClass( 'customize-active full-overlay-active' );
});
},
close: function() {
this.element.fadeOut( 200, function() {
Loader.iframe.remove();
Loader.iframe = null;
Loader.body.removeClass( 'customize-active full-overlay-active' );
});
}
};
$( function() {
Loader.initialize();
$('#current-theme, #availablethemes').on( 'click', '.load-customize', function( event ) {
var load = $(this);
event.preventDefault();
// Load the theme.
Loader.open({
template: load.data('customizeTemplate'),
stylesheet: load.data('customizeStylesheet')
});
});
});
// Expose the API to the world.
exports.CustomizeLoader = Loader;
})( wp, jQuery );