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

1 line
1.5 KiB
JavaScript
Raw Normal View History

!function(a,b){if(b&&b.customize){var c,d=b.customize;d.WidgetCustomizerPreview={renderedSidebars:{},renderedWidgets:{},registeredSidebars:[],registeredWidgets:{},widgetSelectors:[],preview:null,l10n:{},init:function(){var a=this;this.buildWidgetSelectors(),this.highlightControls(),this.preview.bind("active",function(){a.preview.send("rendered-sidebars",a.renderedSidebars),a.preview.send("rendered-widgets",a.renderedWidgets)})},buildWidgetSelectors:function(){var b=this;a.each(this.registeredSidebars,function(c,d){var e,f,g,h=[d.before_widget.replace("%1$s","").replace("%2$s",""),d.before_title,d.after_title,d.after_widget].join("");e=a(h),f=e.prop("tagName"),g=e.prop("className").replace(/^\s+|\s+$/g,""),g&&(f+="."+g.split(/\s+/).join(".")),b.widgetSelectors.push(f)})},getWidgetElement:function(b){return a("#"+b)},highlightControls:function(){var b=this.widgetSelectors.join(",");a(b).attr("title",this.l10n.widgetTooltip),a(document).on("mouseenter",b,function(){var b=parent.WidgetCustomizer.getWidgetFormControlForWidget(a(this).prop("id"));b&&b.highlightSectionAndControl()}),a(document).on("click",b,function(b){if(b.shiftKey){b.preventDefault();var c=parent.WidgetCustomizer.getWidgetFormControlForWidget(a(this).prop("id"));c&&c.focus()}})}},c=d.Preview,d.Preview=c.extend({initialize:function(a,b){d.WidgetCustomizerPreview.preview=this,c.prototype.initialize.call(this,a,b)}}),a(function(){var b=window._wpWidgetCustomizerPreviewSettings;b&&(a.extend(d.WidgetCustomizerPreview,b),d.WidgetCustomizerPreview.init())})}}(jQuery,window.wp);