Customizer: Add loading indicators for the Customizer preview.
props Fab1en, westonruter. fixes #31196. Built from https://develop.svn.wordpress.org/trunk@31697 git-svn-id: http://core.svn.wordpress.org/trunk@31678 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
13ad2d4e16
commit
3349b7d25b
|
@ -1352,6 +1352,16 @@ body.full-overlay-active {
|
|||
height: 100%;
|
||||
}
|
||||
|
||||
#customize-preview.wp-full-overlay-main {
|
||||
background: url(../images/spinner.gif) no-repeat center center;
|
||||
-webkit-background-size: 20px 20px;
|
||||
background-size: 20px 20px;
|
||||
}
|
||||
|
||||
#customize-preview.wp-full-overlay-main.iframe-ready {
|
||||
background: none;
|
||||
}
|
||||
|
||||
.wp-full-overlay-sidebar .wp-full-overlay-header {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
|
@ -1710,6 +1720,7 @@ body.full-overlay-active {
|
|||
background-size: 15px 123px;
|
||||
}
|
||||
|
||||
#customize-preview.wp-full-overlay-main,
|
||||
.customize-loading #customize-container,
|
||||
.theme-install-overlay .wp-full-overlay-main {
|
||||
background-image: url(../images/spinner-2x.gif);
|
||||
|
|
|
@ -1352,6 +1352,16 @@ body.full-overlay-active {
|
|||
height: 100%;
|
||||
}
|
||||
|
||||
#customize-preview.wp-full-overlay-main {
|
||||
background: url(../images/spinner.gif) no-repeat center center;
|
||||
-webkit-background-size: 20px 20px;
|
||||
background-size: 20px 20px;
|
||||
}
|
||||
|
||||
#customize-preview.wp-full-overlay-main.iframe-ready {
|
||||
background: none;
|
||||
}
|
||||
|
||||
.wp-full-overlay-sidebar .wp-full-overlay-header {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
|
@ -1710,6 +1720,7 @@ body.full-overlay-active {
|
|||
background-size: 15px 123px;
|
||||
}
|
||||
|
||||
#customize-preview.wp-full-overlay-main,
|
||||
.customize-loading #customize-container,
|
||||
.theme-install-overlay .wp-full-overlay-main {
|
||||
background-image: url(../images/spinner-2x.gif);
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1914,6 +1914,9 @@
|
|||
this.bind( 'ready', this._ready );
|
||||
|
||||
this.bind( 'ready', function ( data ) {
|
||||
|
||||
this.container.addClass( 'iframe-ready' );
|
||||
|
||||
if ( ! data ) {
|
||||
return;
|
||||
}
|
||||
|
@ -2217,6 +2220,9 @@
|
|||
refresh: function() {
|
||||
var self = this;
|
||||
|
||||
// Display loading indicator
|
||||
this.send( 'loading-initiated' );
|
||||
|
||||
this.abort();
|
||||
|
||||
this.loading = new api.PreviewFrame({
|
||||
|
@ -2249,8 +2255,10 @@
|
|||
});
|
||||
|
||||
this.loading.fail( function( reason, location ) {
|
||||
if ( 'redirect' === reason && location )
|
||||
self.send( 'loading-failed' );
|
||||
if ( 'redirect' === reason && location ) {
|
||||
self.previewUrl( location );
|
||||
}
|
||||
|
||||
if ( 'logged out' === reason ) {
|
||||
if ( self.preview ) {
|
||||
|
@ -2261,8 +2269,9 @@
|
|||
self.login().done( self.refresh );
|
||||
}
|
||||
|
||||
if ( 'cheatin' === reason )
|
||||
if ( 'cheatin' === reason ) {
|
||||
self.cheatin();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -501,6 +501,7 @@ final class WP_Customize_Manager {
|
|||
add_action( 'wp', array( $this, 'customize_preview_override_404_status' ) );
|
||||
add_action( 'wp_head', array( $this, 'customize_preview_base' ) );
|
||||
add_action( 'wp_head', array( $this, 'customize_preview_html5' ) );
|
||||
add_action( 'wp_head', array( $this, 'customize_preview_loading_style' ) );
|
||||
add_action( 'wp_footer', array( $this, 'customize_preview_settings' ), 20 );
|
||||
add_action( 'shutdown', array( $this, 'customize_preview_signature' ), 1000 );
|
||||
add_filter( 'wp_die_handler', array( $this, 'remove_preview_signature' ) );
|
||||
|
@ -543,7 +544,7 @@ final class WP_Customize_Manager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Print a workaround to handle HTML5 tags in IE < 9
|
||||
* Print a workaround to handle HTML5 tags in IE < 9.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*/
|
||||
|
@ -560,6 +561,25 @@ final class WP_Customize_Manager {
|
|||
<![endif]--><?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Print CSS for loading indicators for the Customizer preview.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*/
|
||||
public function customize_preview_loading_style() {
|
||||
?><style>
|
||||
body.wp-customizer-unloading {
|
||||
opacity: 0.25;
|
||||
cursor: progress !important;
|
||||
-webkit-transition: opacity 0.5s;
|
||||
transition: opacity 0.5s;
|
||||
}
|
||||
body.wp-customizer-unloading * {
|
||||
pointer-events: none !important;
|
||||
}
|
||||
</style><?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Print JavaScript settings for preview frame.
|
||||
*
|
||||
|
@ -572,6 +592,9 @@ final class WP_Customize_Manager {
|
|||
'activePanels' => array(),
|
||||
'activeSections' => array(),
|
||||
'activeControls' => array(),
|
||||
'l10n' => array(
|
||||
'loading' => __( 'Loading ...' ),
|
||||
),
|
||||
);
|
||||
|
||||
if ( 2 == $this->nonce_tick ) {
|
||||
|
|
|
@ -115,6 +115,16 @@
|
|||
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;
|
||||
|
|
|
@ -1 +1 @@
|
|||
!function(a,b){var c,d=wp.customize;c=function(a,b,c){var d;return function(){var e=arguments;c=c||this,clearTimeout(d),d=setTimeout(function(){d=null,a.apply(c,e)},b)}},d.Preview=d.Messenger.extend({initialize:function(a,e){var f=this;d.Messenger.prototype.initialize.call(this,a,e),this.body=b(document.body),this.body.on("click.preview","a",function(a){a.preventDefault(),f.send("scroll",0),f.send("url",b(this).prop("href"))}),this.body.on("submit.preview","form",function(a){a.preventDefault()}),this.window=b(window),this.window.on("scroll.preview",c(function(){f.send("scroll",f.window.scrollTop())},200)),this.bind("scroll",function(a){f.window.scrollTop(a)})}}),b(function(){if(d.settings=window._wpCustomizeSettings,d.settings){var a;d.preview=new d.Preview({url:window.location.href,channel:d.settings.channel}),d.preview.bind("settings",function(a){b.each(a,function(a,b){d.has(a)?d(a).set(b):d.create(a,b)})}),d.preview.trigger("settings",d.settings.values),d.preview.bind("setting",function(a){var b;a=a.slice(),(b=d(a.shift()))&&b.set.apply(b,a)}),d.preview.bind("sync",function(a){b.each(a,function(a,b){d.preview.trigger(a,b)}),d.preview.send("synced")}),d.preview.bind("active",function(){d.settings.nonce&&d.preview.send("nonce",d.settings.nonce),d.preview.send("documentTitle",document.title)}),d.preview.send("ready",{activePanels:d.settings.activePanels,activeSections:d.settings.activeSections,activeControls:d.settings.activeControls}),a=b.map(["color","image","position_x","repeat","attachment"],function(a){return"background_"+a}),d.when.apply(d,a).done(function(a,c,d,e,f){var g,h=b(document.body),i=b("head"),j=b("#custom-background-css");g=function(){var g="";h.toggleClass("custom-background",!(!a()&&!c())),a()&&(g+="background-color: "+a()+";"),c()&&(g+='background-image: url("'+c()+'");',g+="background-position: top "+d()+";",g+="background-repeat: "+e()+";",g+="background-attachment: "+f()+";"),j.remove(),j=b('<style type="text/css" id="custom-background-css">body.custom-background { '+g+" }</style>").appendTo(i)},b.each(arguments,function(){this.bind(g)})}),d.trigger("preview-ready")}})}(wp,jQuery);
|
||||
!function(a,b){var c,d=wp.customize;c=function(a,b,c){var d;return function(){var e=arguments;c=c||this,clearTimeout(d),d=setTimeout(function(){d=null,a.apply(c,e)},b)}},d.Preview=d.Messenger.extend({initialize:function(a,e){var f=this;d.Messenger.prototype.initialize.call(this,a,e),this.body=b(document.body),this.body.on("click.preview","a",function(a){a.preventDefault(),f.send("scroll",0),f.send("url",b(this).prop("href"))}),this.body.on("submit.preview","form",function(a){a.preventDefault()}),this.window=b(window),this.window.on("scroll.preview",c(function(){f.send("scroll",f.window.scrollTop())},200)),this.bind("scroll",function(a){f.window.scrollTop(a)})}}),b(function(){if(d.settings=window._wpCustomizeSettings,d.settings){var a;d.preview=new d.Preview({url:window.location.href,channel:d.settings.channel}),d.preview.bind("settings",function(a){b.each(a,function(a,b){d.has(a)?d(a).set(b):d.create(a,b)})}),d.preview.trigger("settings",d.settings.values),d.preview.bind("setting",function(a){var b;a=a.slice(),(b=d(a.shift()))&&b.set.apply(b,a)}),d.preview.bind("sync",function(a){b.each(a,function(a,b){d.preview.trigger(a,b)}),d.preview.send("synced")}),d.preview.bind("active",function(){d.settings.nonce&&d.preview.send("nonce",d.settings.nonce),d.preview.send("documentTitle",document.title)}),d.preview.send("ready",{activePanels:d.settings.activePanels,activeSections:d.settings.activeSections,activeControls:d.settings.activeControls}),d.preview.bind("loading-initiated",function(){b("body").addClass("wp-customizer-unloading"),b("html").prop("title",d.settings.l10n.loading)}),d.preview.bind("loading-failed",function(){b("body").removeClass("wp-customizer-unloading"),b("html").prop("title","")}),a=b.map(["color","image","position_x","repeat","attachment"],function(a){return"background_"+a}),d.when.apply(d,a).done(function(a,c,d,e,f){var g,h=b(document.body),i=b("head"),j=b("#custom-background-css");g=function(){var g="";h.toggleClass("custom-background",!(!a()&&!c())),a()&&(g+="background-color: "+a()+";"),c()&&(g+='background-image: url("'+c()+'");',g+="background-position: top "+d()+";",g+="background-repeat: "+e()+";",g+="background-attachment: "+f()+";"),j.remove(),j=b('<style type="text/css" id="custom-background-css">body.custom-background { '+g+" }</style>").appendTo(i)},b.each(arguments,function(){this.bind(g)})}),d.trigger("preview-ready")}})}(wp,jQuery);
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.2-alpha-31696';
|
||||
$wp_version = '4.2-alpha-31697';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue