mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Customizer: Improve parity between JS Setting models in preview with JS Setting models in pane.
* Ensure that Setting `Value` objects in preview get initial `_dirty` flag set if values among POST data. * Upon `saved` event, send `saved` message to preview with the `response` to trigger `saved` event there. * Reset `_dirty` flag for all setting `Value` objects in preview upon `saved`. * Continue to create settings synced from pane even after initial bootstrap, and create them as dirty. * Ensure that `id` property is set for setting `Value` objects in preview. See #27355. Fixes #35616. Built from https://develop.svn.wordpress.org/trunk@36407 git-svn-id: http://core.svn.wordpress.org/trunk@36374 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
972215f9f9
commit
c7923b2c9d
@ -3345,6 +3345,8 @@
|
||||
value._dirty = false;
|
||||
} );
|
||||
|
||||
api.previewer.send( 'saved', response );
|
||||
|
||||
api.trigger( 'saved', response );
|
||||
} );
|
||||
};
|
||||
|
2
wp-admin/js/customize-controls.min.js
vendored
2
wp-admin/js/customize-controls.min.js
vendored
File diff suppressed because one or more lines are too long
@ -805,6 +805,7 @@ final class WP_Customize_Manager {
|
||||
'activePanels' => array(),
|
||||
'activeSections' => array(),
|
||||
'activeControls' => array(),
|
||||
'_dirty' => array_keys( $this->unsanitized_post_values() ),
|
||||
);
|
||||
|
||||
if ( 2 == $this->nonce_tick ) {
|
||||
|
@ -84,35 +84,58 @@
|
||||
});
|
||||
|
||||
$( function() {
|
||||
api.settings = window._wpCustomizeSettings;
|
||||
if ( ! api.settings )
|
||||
return;
|
||||
var bg, setValue;
|
||||
|
||||
var bg;
|
||||
api.settings = window._wpCustomizeSettings;
|
||||
if ( ! api.settings ) {
|
||||
return;
|
||||
}
|
||||
|
||||
api.preview = new api.Preview({
|
||||
url: window.location.href,
|
||||
channel: api.settings.channel
|
||||
});
|
||||
|
||||
/**
|
||||
* Create/update a setting value.
|
||||
*
|
||||
* @param {string} id - Setting ID.
|
||||
* @param {*} value - Setting value.
|
||||
* @param {boolean} [createDirty] - Whether to create a setting as dirty. Defaults to false.
|
||||
*/
|
||||
setValue = function( id, value, createDirty ) {
|
||||
var setting = api( id );
|
||||
if ( setting ) {
|
||||
setting.set( value );
|
||||
} else {
|
||||
createDirty = createDirty || false;
|
||||
setting = api.create( id, value, {
|
||||
id: id
|
||||
} );
|
||||
|
||||
// Mark dynamically-created settings as dirty so they will get posted.
|
||||
if ( createDirty ) {
|
||||
setting._dirty = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
api.preview.bind( 'settings', function( values ) {
|
||||
$.each( values, function( id, value ) {
|
||||
if ( api.has( id ) )
|
||||
api( id ).set( value );
|
||||
else
|
||||
api.create( id, value );
|
||||
});
|
||||
$.each( values, setValue );
|
||||
});
|
||||
|
||||
api.preview.trigger( 'settings', api.settings.values );
|
||||
|
||||
$.each( api.settings._dirty, function( i, id ) {
|
||||
var setting = api( id );
|
||||
if ( setting ) {
|
||||
setting._dirty = true;
|
||||
}
|
||||
} );
|
||||
|
||||
api.preview.bind( 'setting', function( args ) {
|
||||
var value;
|
||||
|
||||
args = args.slice();
|
||||
|
||||
if ( value = api( args.shift() ) )
|
||||
value.set.apply( value, args );
|
||||
var createDirty = true;
|
||||
setValue.apply( null, args.concat( createDirty ) );
|
||||
});
|
||||
|
||||
api.preview.bind( 'sync', function( events ) {
|
||||
@ -130,6 +153,16 @@
|
||||
api.preview.send( 'documentTitle', document.title );
|
||||
});
|
||||
|
||||
api.preview.bind( 'saved', function( response ) {
|
||||
api.trigger( 'saved', response );
|
||||
} );
|
||||
|
||||
api.bind( 'saved', function() {
|
||||
api.each( function( setting ) {
|
||||
setting._dirty = false;
|
||||
} );
|
||||
} );
|
||||
|
||||
/*
|
||||
* Send a message to the parent customize frame with a list of which
|
||||
* containers and controls are active.
|
||||
|
2
wp-includes/js/customize-preview.min.js
vendored
2
wp-includes/js/customize-preview.min.js
vendored
@ -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(){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")}),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('<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){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.settings.nonce&&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.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('<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.5-alpha-36406';
|
||||
$wp_version = '4.5-alpha-36407';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user