WordPress/wp-includes/js/customize-preview-widgets.m...

2 lines
7.7 KiB
JavaScript
Raw Normal View History

/*! This file is auto-generated */
wp.customize.widgetsPreview=wp.customize.WidgetCustomizerPreview=function(s,c,e,l){var d;return(d={renderedSidebars:{},renderedWidgets:{},registeredSidebars:[],registeredWidgets:{},widgetSelectors:[],preview:null,l10n:{widgetTooltip:""},selectiveRefreshableWidgets:{},init:function(){var i=this;i.preview=l.preview,c.isEmpty(i.selectiveRefreshableWidgets)||i.addPartials(),i.buildWidgetSelectors(),i.highlightControls(),i.preview.bind("highlight-widget",i.highlightWidget),l.preview.bind("active",function(){i.highlightControls()}),l.preview.bind("refresh-widget-partial",function(e){var t="widget["+e+"]";l.selectiveRefresh.partial.has(t)?l.selectiveRefresh.partial(t).refresh():i.renderedWidgets[e]&&l.preview.send("refresh")})}}).WidgetPartial=l.selectiveRefresh.Partial.extend({initialize:function(e,t){var i,r=this;if(!(i=e.match(/^widget\[(.+)]$/)))throw new Error("Illegal id for widget partial.");r.widgetId=i[1],r.widgetIdParts=d.parseWidgetId(r.widgetId),(t=t||{}).params=c.extend({settings:[d.getWidgetSettingId(r.widgetId)],containerInclusive:!0},t.params||{}),l.selectiveRefresh.Partial.prototype.initialize.call(r,e,t)},refresh:function(){var e,t=this;return d.selectiveRefreshableWidgets[t.widgetIdParts.idBase]?l.selectiveRefresh.Partial.prototype.refresh.call(t):((e=s.Deferred()).reject(),t.fallback(),e.promise())},renderContent:function(e){var t=this;l.selectiveRefresh.Partial.prototype.renderContent.call(t,e)&&(l.preview.send("widget-updated",t.widgetId),l.selectiveRefresh.trigger("widget-updated",t))}}),d.SidebarPartial=l.selectiveRefresh.Partial.extend({initialize:function(e,t){var i,r=this;if(!(i=e.match(/^sidebar\[(.+)]$/)))throw new Error("Illegal id for sidebar partial.");if(r.sidebarId=i[1],(t=t||{}).params=c.extend({settings:["sidebars_widgets["+r.sidebarId+"]"]},t.params||{}),l.selectiveRefresh.Partial.prototype.initialize.call(r,e,t),!r.params.sidebarArgs)throw new Error("The sidebarArgs param was not provided.");if(1<r.params.settings.length)throw new Error("Expected SidebarPartial to only have one associated setting")},ready:function(){var r=this;c.each(r.settings(),function(e){l(e).bind(c.bind(r.handleSettingChange,r))}),l.selectiveRefresh.bind("partial-content-rendered",function(e){e.partial.extended(d.WidgetPartial)&&-1!==c.indexOf(r.getWidgetIds(),e.partial.widgetId)&&l.selectiveRefresh.trigger("sidebar-updated",r)}),l.bind("change",function(e){var t,i;(i=d.parseWidgetSettingId(e.id))&&(t=i.idBase,i.number&&(t+="-"+String(i.number)),-1!==c.indexOf(r.getWidgetIds(),t)&&r.ensureWidgetPlacementContainers(t))})},findDynamicSidebarBoundaryNodes:function(){var i,r,n=this,a={};return i=/^(dynamic_sidebar_before|dynamic_sidebar_after):(.+):(\d+)$/,(r=function(e){c.each(e,function(e){var t;if(8===e.nodeType){if(!(t=e.nodeValue.match(i))||t[2]!==n.sidebarId)return;c.isUndefined(a[t[3]])&&(a[t[3]]={before:null,after:null,instanceNumber:parseInt(t[3],10)}),"dynamic_sidebar_before"===t[1]?a[t[3]].before=e:a[t[3]].after=e}else 1===e.nodeType&&r(e.childNodes)})})(document.body.childNodes),c.values(a)},placements:function(){var t=this;return c.map(t.findDynamicSidebarBoundaryNodes(),function(e){return new l.selectiveRefresh.Placement({partial:t,container:null,startNode:e.before,endNode:e.after,context:{instanceNumber:e.instanceNumber}})})},getWidgetIds:function(){var e,t;if(!(e=this.settings()[0]))throw new Error("Missing associated setting.");if(!l.has(e))throw new Error("Setting does not exist.");if(t=l(e).get(),!c.isArray(t))throw new Error("Expected setting to be array of widget IDs");return t.slice(0)},reflowWidgets:function(){var e,t,s,i=this,o=[];return t=i.getWidgetIds(),e=i.placements(),s={},c.each(t,function(e){var t=l.selectiveRefresh.partial("widget["+e+"]");t&&(s[e]=t)}),c.each(e,function(i){var r,n=[],a=!1,d=-1;c.each(s,function(t){c.each(t.placements(),function(e){i.context.instanceNumber===e.context.sidebar_instance_number&&(r=e.container.index(),n.push({partial:t,placement:e,position:r}),r<d&&(a=!0),d=r)})}),a&&(c.each(n,function(e){i.endNode.parentNode.insertBefore(e.placement.container[0],i.endNode),l.