X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/9e77185fafaf4e60e2b73821e0e4b9b1a11fb85f..6359b807ff8b4ffa151d8756cdefb861c6c1d4db:/wp-includes/js/customize-preview.js diff --git a/wp-includes/js/customize-preview.js b/wp-includes/js/customize-preview.js index 6da26f47..e58c8d6d 100644 --- a/wp-includes/js/customize-preview.js +++ b/wp-includes/js/customize-preview.js @@ -67,14 +67,14 @@ if ( ! api.settings ) return; - var preview, bg; + var bg; - preview = new api.Preview({ + api.preview = new api.Preview({ url: window.location.href, channel: api.settings.channel }); - preview.bind( 'settings', function( values ) { + api.preview.bind( 'settings', function( values ) { $.each( values, function( id, value ) { if ( api.has( id ) ) api( id ).set( value ); @@ -83,9 +83,9 @@ }); }); - preview.trigger( 'settings', api.settings.values ); + api.preview.trigger( 'settings', api.settings.values ); - preview.bind( 'setting', function( args ) { + api.preview.bind( 'setting', function( args ) { var value; args = args.slice(); @@ -94,22 +94,37 @@ value.set.apply( value, args ); }); - preview.bind( 'sync', function( events ) { + api.preview.bind( 'sync', function( events ) { $.each( events, function( event, args ) { - preview.trigger( event, args ); + api.preview.trigger( event, args ); }); - preview.send( 'synced' ); + api.preview.send( 'synced' ); }); - preview.bind( 'active', function() { - if ( api.settings.nonce ) - preview.send( 'nonce', api.settings.nonce ); - }); + api.preview.bind( 'active', function() { + if ( api.settings.nonce ) { + api.preview.send( 'nonce', api.settings.nonce ); + } - preview.send( 'ready', { + api.preview.send( 'documentTitle', document.title ); + }); + + api.preview.send( 'ready', { + activePanels: api.settings.activePanels, + activeSections: api.settings.activeSections, activeControls: api.settings.activeControls } ); + // Display a loading indicator when preview is reloading, and remove on failure. + api.preview.bind( 'loading-initiated', function () { + $( 'body' ).addClass( 'wp-customizer-unloading' ); + $( 'html' ).prop( 'title', api.settings.l10n.loading ); + }); + api.preview.bind( 'loading-failed', function () { + $( 'body' ).removeClass( 'wp-customizer-unloading' ); + $( 'html' ).prop( 'title', '' ); + }); + /* Custom Backgrounds */ bg = $.map(['color', 'image', 'position_x', 'repeat', 'attachment'], function( prop ) { return 'background_' + prop; @@ -149,6 +164,8 @@ this.bind( update ); }); }); + + api.trigger( 'preview-ready' ); }); })( wp, jQuery );