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

1 line
1.6 KiB
JavaScript
Raw Normal View History

!function(e,o){var t,r;e&&e.customize&&((t=e.customize).WidgetCustomizerPreview={renderedSidebars:{},renderedWidgets:{},registeredSidebars:[],registeredWidgets:{},widgetSelectors:[],preview:null,l10n:{},init:function(){this.buildWidgetSelectors(),this.highlightControls(),this.preview.bind("highlight-widget",this.highlightWidget)},buildWidgetSelectors:function(){var r=this;o.each(this.registeredSidebars,function(e,i){var t=[i.before_widget.replace("%1$s","").replace("%2$s",""),i.before_title,i.after_title,i.after_widget].join(""),i=o(t),t=i.prop("tagName"),i=i.prop("className");i&&((i=i.replace(/^\s+|\s+$/g,""))&&(t+="."+i.split(/\s+/).join(".")),r.widgetSelectors.push(t))})},highlightWidget:function(e){var i=o(document.body),t=o("#"+e);i.find(".widget-customizer-highlighted-widget").removeClass("widget-customizer-highlighted-widget"),t.addClass("widget-customizer-highlighted-widget"),setTimeout(function(){t.removeClass("widget-customizer-highlighted-widget")},500)},highlightControls:function(){var i=this,e=this.widgetSelectors.join(",");o(e).attr("title",this.l10n.widgetTooltip),o(document).on("mouseenter",e,function(){i.preview.send("highlight-widget-control",o(this).prop("id"))}),o(document).on("click",e,function(e){e.shiftKey&&(e.preventDefault(),i.preview.send("focus-widget-control",o(this).prop("id")))})}},r=t.Preview,t.Preview=r.extend({initialize:function(e,i){t.WidgetCustomizerPreview.preview=this,r.prototype.initialize.call(this,e,i)}}),o(function(){var e=window._wpWidgetCustomizerPreviewSettings;e&&(o.extend(t.WidgetCustomizerPreview,e),t.WidgetCustomizerPreview.init())}))}(window.wp,jQuery);