WordPress/wp-includes/js/customize-preview-widgets.min.js
2014-03-18 18:35:16 +00:00

1 line
1.4 KiB
JavaScript

var WidgetCustomizerPreview=function(a){"use strict";var b,c={rendered_sidebars:{},rendered_widgets:{},registered_sidebars:[],registered_widgets:{},widget_selectors:[],preview:null,i18n:{},init:function(){this.buildWidgetSelectors(),this.highlightControls(),c.preview.bind("active",function(){c.preview.send("rendered-sidebars",c.rendered_sidebars),c.preview.send("rendered-widgets",c.rendered_widgets)})},buildWidgetSelectors:function(){a.each(c.registered_sidebars,function(b,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(".")),c.widget_selectors.push(f)})},getWidgetElement:function(b){return a("#"+b)},highlightControls:function(){var b=this.widget_selectors.join(",");a(b).attr("title",c.i18n.widget_tooltip),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()}})}};return a.extend(c,WidgetCustomizerPreview_exports),b=wp.customize.Preview,wp.customize.Preview=b.extend({initialize:function(a,d){c.preview=this,b.prototype.initialize.call(this,a,d)}}),a(function(){c.init()}),c}(jQuery);