WordPress/wp-includes/js/customize-preview-widgets.min.js
2014-03-06 16:45:15 +00:00

1 line
1.6 KiB
JavaScript

var WidgetCustomizerPreview=function(a){"use strict";var b,c={rendered_sidebars:{},rendered_widgets:{},registered_sidebars:[],registered_widgets:{},widget_selectors:[],render_widget_ajax_action:null,render_widget_nonce_value:null,render_widget_nonce_post_key:null,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)})},getSidebarWidgetElement:function(b,c){return a("[id="+c+"]").filter(function(){return a(this).data("widget_customizer_sidebar_id")===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);