diff --git a/wp-includes/js/customize-preview.js b/wp-includes/js/customize-preview.js index 39ac5f4be1..ac77551bfd 100644 --- a/wp-includes/js/customize-preview.js +++ b/wp-includes/js/customize-preview.js @@ -226,57 +226,15 @@ /** * Custom Logo * - * The custom logo setting only contains the attachment ID. To avoid having to send an AJAX request to get more - * data, we send a separate message with the attachment data we get from the Customizer's media modal. - * Therefore first callback handles only the event of a new logo being selected. - * - * We don't need any information about a removed logo, so the second callback only handles that. + * Toggle the wp-custom-logo body class when a logo is added or removed. * * @since 4.5.0 */ - api.preview.bind( 'custom_logo-attachment-data', function( attachment ) { - var $logo = $( '.custom-logo' ), - size = $logo.data( 'size' ), - srcset = []; - - // If the source was smaller than the size required by the theme, give the biggest we've got. - if ( ! attachment.sizes[ size ] ) { - size = 'full'; - } - - _.each( attachment.sizes, function( size ) { - srcset.push( size.url + ' ' + size.width + 'w' ); - } ); - - $logo.attr( { - height: attachment.sizes[ size ].height, - width: attachment.sizes[ size ].width, - src: attachment.sizes[ size ].url, - srcset: srcset - } ); - - $( '.custom-logo-link' ).show(); - $( 'body' ).addClass( 'wp-custom-logo' ); - } ); - api( 'custom_logo', function( setting ) { - setting.bind( function( newValue ) { - if ( ! newValue ) { - $( '.custom-logo-link' ).hide(); - $( 'body' ).removeClass( 'wp-custom-logo' ); - } + $( 'body' ).toggleClass( 'wp-custom-logo', !! setting.get() ); + setting.bind( function( attachmentId ) { + $( 'body' ).toggleClass( 'wp-custom-logo', !! attachmentId ); } ); - - // Focus on the control when the logo is clicked, if there is no custom_logo partial. - if ( ! api.selectiveRefresh || ! api.selectiveRefresh.partial.has( 'custom_logo' ) ) { - $( document.body ).on( 'click', '.custom-logo-link', function( e ) { - if ( ! e.shiftKey ) { - return; - } - api.preview.send( 'focus-control-for-setting', 'custom_logo' ); - } ); - $( '.custom-logo-link' ).attr( 'title', api.settings.l10n.shiftClickToEdit ); - } } ); api.trigger( 'preview-ready' ); diff --git a/wp-includes/js/customize-preview.min.js b/wp-includes/js/customize-preview.min.js index eeeb16e3f7..d3fd1df2ac 100644 --- a/wp-includes/js/customize-preview.min.js +++ b/wp-includes/js/customize-preview.min.js @@ -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){var c,d;c=b(this),d="#"===c.attr("href").substr(0,1),a.preventDefault(),d&&"#"!==c.attr("href")&&b(c.attr("href")).each(function(){this.scrollIntoView()}),a.shiftKey||d||(f.send("scroll",0),f.send("url",c.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(){var a,c;d.settings=window._wpCustomizeSettings,d.settings&&(d.preview=new d.Preview({url:window.location.href,channel:d.settings.channel}),c=function(a,b,c){var e=d(a);e?e.set(b):(c=c||!1,e=d.create(a,b,{id:a}),c&&(e._dirty=!0))},d.preview.bind("settings",function(a){b.each(a,c)}),d.preview.trigger("settings",d.settings.values),b.each(d.settings._dirty,function(a,b){var c=d(b);c&&(c._dirty=!0)}),d.preview.bind("setting",function(a){var b=!0;c.apply(null,a.concat(b))}),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.preview.send("nonce",d.settings.nonce),d.preview.send("documentTitle",document.title)}),d.preview.bind("saved",function(a){d.trigger("saved",a)}),d.bind("saved",function(){d.each(function(a){a._dirty=!1})}),d.preview.bind("nonce-refresh",function(a){b.extend(d.settings.nonce,a)}),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")}),d.preview.bind("loading-failed",function(){b("body").removeClass("wp-customizer-unloading")}),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('").appendTo(i)},b.each(arguments,function(){this.bind(g)})}),d.preview.bind("custom_logo-attachment-data",function(a){var c=b(".custom-logo"),d=c.data("size"),e=[];a.sizes[d]||(d="full"),_.each(a.sizes,function(a){e.push(a.url+" "+a.width+"w")}),c.attr({height:a.sizes[d].height,width:a.sizes[d].width,src:a.sizes[d].url,srcset:e}),b(".custom-logo-link").show(),b("body").addClass("wp-custom-logo")}),d("custom_logo",function(a){a.bind(function(a){a||(b(".custom-logo-link").hide(),b("body").removeClass("wp-custom-logo"))}),d.selectiveRefresh&&d.selectiveRefresh.partial.has("custom_logo")||(b(document.body).on("click",".custom-logo-link",function(a){a.shiftKey&&d.preview.send("focus-control-for-setting","custom_logo")}),b(".custom-logo-link").attr("title",d.settings.l10n.shiftClickToEdit))}),d.trigger("preview-ready"))})}(wp,jQuery); \ No newline at end of file +!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){var c,d;c=b(this),d="#"===c.attr("href").substr(0,1),a.preventDefault(),d&&"#"!==c.attr("href")&&b(c.attr("href")).each(function(){this.scrollIntoView()}),a.shiftKey||d||(f.send("scroll",0),f.send("url",c.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(){var a,c;d.settings=window._wpCustomizeSettings,d.settings&&(d.preview=new d.Preview({url:window.location.href,channel:d.settings.channel}),c=function(a,b,c){var e=d(a);e?e.set(b):(c=c||!1,e=d.create(a,b,{id:a}),c&&(e._dirty=!0))},d.preview.bind("settings",function(a){b.each(a,c)}),d.preview.trigger("settings",d.settings.values),b.each(d.settings._dirty,function(a,b){var c=d(b);c&&(c._dirty=!0)}),d.preview.bind("setting",function(a){var b=!0;c.apply(null,a.concat(b))}),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.preview.send("nonce",d.settings.nonce),d.preview.send("documentTitle",document.title)}),d.preview.bind("saved",function(a){d.trigger("saved",a)}),d.bind("saved",function(){d.each(function(a){a._dirty=!1})}),d.preview.bind("nonce-refresh",function(a){b.extend(d.settings.nonce,a)}),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")}),d.preview.bind("loading-failed",function(){b("body").removeClass("wp-customizer-unloading")}),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('").appendTo(i)},b.each(arguments,function(){this.bind(g)})}),d("custom_logo",function(a){b("body").toggleClass("wp-custom-logo",!!a.get()),a.bind(function(a){b("body").toggleClass("wp-custom-logo",!!a)})}),d.trigger("preview-ready"))})}(wp,jQuery); \ No newline at end of file diff --git a/wp-includes/version.php b/wp-includes/version.php index da0901a8c1..614feede97 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.5-beta3-36989'; +$wp_version = '4.5-beta3-36990'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.