diff --git a/wp-includes/js/customize-selective-refresh.js b/wp-includes/js/customize-selective-refresh.js index d3b81db6d7..4f7165656a 100644 --- a/wp-includes/js/customize-selective-refresh.js +++ b/wp-includes/js/customize-selective-refresh.js @@ -849,7 +849,7 @@ wp.customize.selectiveRefresh = ( function( $, api ) { containerElements = containerElements.add( rootElement ); } containerElements.each( function() { - var containerElement = $( this ), partial, id, Constructor, partialOptions, containerContext; + var containerElement = $( this ), partial, placement, id, Constructor, partialOptions, containerContext; id = containerElement.data( 'customize-partial-id' ); if ( ! id ) { return; @@ -874,14 +874,19 @@ wp.customize.selectiveRefresh = ( function( $, api ) { */ if ( options.triggerRendered && ! containerElement.data( 'customize-partial-content-rendered' ) ) { - /** - * Announce when a partial's nested placement has been re-rendered. - */ - self.trigger( 'partial-content-rendered', new Placement( { + placement = new Placement( { partial: partial, context: containerContext, container: containerElement - } ) ); + } ); + + $( placement.container ).attr( 'title', self.data.l10n.shiftClickToEdit ); + partial.createEditShortcutForPlacement( placement ); + + /** + * Announce when a partial's nested placement has been re-rendered. + */ + self.trigger( 'partial-content-rendered', placement ); } containerElement.data( 'customize-partial-content-rendered', true ); } ); diff --git a/wp-includes/js/customize-selective-refresh.min.js b/wp-includes/js/customize-selective-refresh.min.js index a551401e2d..1572c080b9 100644 --- a/wp-includes/js/customize-selective-refresh.min.js +++ b/wp-includes/js/customize-selective-refresh.min.js @@ -1 +1 @@ -wp.customize.selectiveRefresh=function(a,b){"use strict";var c,d,e;return c={ready:a.Deferred(),editShortcutVisibility:new b.Value,data:{partials:{},renderQueryVar:"",l10n:{shiftClickToEdit:""}},currentRequest:null},_.extend(c,b.Events),d=c.Partial=b.Class.extend({id:null,initialize:function(b,c){var d=this;c=c||{},d.id=b,d.params=_.extend({selector:null,settings:[],primarySetting:null,containerInclusive:!1,fallbackRefresh:!0},c.params||{}),d.deferred={},d.deferred.ready=a.Deferred(),d.deferred.ready.done(function(){d.ready()})},ready:function(){var b=this;_.each(b.placements(),function(d){a(d.container).attr("title",c.data.l10n.shiftClickToEdit),b.createEditShortcutForPlacement(d)}),a(document).on("click",b.params.selector,function(c){c.shiftKey&&(c.preventDefault(),_.each(b.placements(),function(d){a(d.container).is(c.currentTarget)&&b.showControl()}))})},createEditShortcutForPlacement:function(b){var c,d,e,f,g=this;b.container&&(d=a(b.container),e="head",f="area, audio, base, bdi, bdo, br, button, canvas, col, colgroup, command, datalist, embed, head, hr, html, iframe, img, input, keygen, label, link, map, math, menu, meta, noscript, object, optgroup, option, param, progress, rp, rt, ruby, script, select, source, style, svg, table, tbody, textarea, tfoot, thead, title, tr, track, video, wbr",!d.length||d.is(f)||d.closest(e).length||(c=g.createEditShortcut(),c.on("click",function(a){a.preventDefault(),a.stopPropagation(),g.showControl()}),g.addEditShortcutToPlacement(b,c)))},addEditShortcutToPlacement:function(b,c){var d=a(b.container);d.prepend(c),d.is(":visible")&&"none"!==d.css("display")||c.addClass("customize-partial-edit-shortcut-hidden")},getEditShortcutClassName:function(){var a,b=this;return a=b.id.replace(/]/g,"").replace(/\[/g,"-"),"customize-partial-edit-shortcut-"+a},getEditShortcutTitle:function(){var a=this,b=c.data.l10n;switch(a.getType()){case"widget":return b.clickEditWidget;case"blogname":return b.clickEditTitle;case"blogdescription":return b.clickEditTitle;case"nav_menu":return b.clickEditMenu;default:return b.clickEditMisc}},getType:function(){var a,b=this;return a=b.params.primarySetting||_.first(b.settings())||"unknown",b.params.type?b.params.type:a.match(/^nav_menu_instance\[/)?"nav_menu":a.match(/^widget_.+\[\d+]$/)?"widget":a},createEditShortcut:function(){var b,c,d,e,f=this;return b=f.getEditShortcutTitle(),c=a("",{"class":"customize-partial-edit-shortcut "+f.getEditShortcutClassName()}),d=a("