Widget Customizer: Restore highlighting of widgets in preview.
props westonruter. see #27358. Built from https://develop.svn.wordpress.org/trunk@27584 git-svn-id: http://core.svn.wordpress.org/trunk@27427 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
181c2d091e
commit
64af78ca43
|
@ -1442,7 +1442,7 @@ var WidgetCustomizer = ( function ($) {
|
||||||
getPreviewWidgetElement: function () {
|
getPreviewWidgetElement: function () {
|
||||||
var control = this,
|
var control = this,
|
||||||
widget_customizer_preview = self.getPreviewWindow().WidgetCustomizerPreview;
|
widget_customizer_preview = self.getPreviewWindow().WidgetCustomizerPreview;
|
||||||
return widget_customizer_preview.getSidebarWidgetElement( control.params.sidebar_id, control.params.widget_id );
|
return widget_customizer_preview.getWidgetElement( control.params.widget_id );
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -756,12 +756,7 @@ class WP_Customize_Widgets {
|
||||||
array( 'jquery', 'wp-util', 'customize-preview' )
|
array( 'jquery', 'wp-util', 'customize-preview' )
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
add_action( 'wp_print_styles', array( __CLASS__, 'inject_preview_css' ), 1 );
|
||||||
wp_enqueue_style(
|
|
||||||
'widget-customizer-preview',
|
|
||||||
'widget-customizer-preview.css'
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Why not wp_localize_script? Because we're not localizing, and it forces values into strings
|
// Why not wp_localize_script? Because we're not localizing, and it forces values into strings
|
||||||
global $wp_scripts;
|
global $wp_scripts;
|
||||||
|
@ -783,6 +778,24 @@ class WP_Customize_Widgets {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert default style for highlighted widget at early point so theme
|
||||||
|
* stylesheet can override.
|
||||||
|
*
|
||||||
|
* @action wp_print_styles
|
||||||
|
*/
|
||||||
|
static function inject_preview_css() {
|
||||||
|
?>
|
||||||
|
<style>
|
||||||
|
.widget-customizer-highlighted-widget {
|
||||||
|
border-radius: 2px;
|
||||||
|
outline: none;
|
||||||
|
box-shadow: 0 0 3px #ce0000;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* At the very end of the page, at the very end of the wp_footer, communicate the sidebars that appeared on the page
|
* At the very end of the page, at the very end of the wp_footer, communicate the sidebars that appeared on the page
|
||||||
*
|
*
|
||||||
|
|
|
@ -52,19 +52,16 @@ var WidgetCustomizerPreview = (function ($) {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain a widget instance if it was added to the provided sidebar
|
* Obtain a rendered widget element. Assumes standard practice of using
|
||||||
* This addresses a race condition where a widget is moved between sidebars
|
* the widget ID as the ID for the DOM element. To eliminate this
|
||||||
* We cannot use ID selector because jQuery will only return the first one
|
* assumption, additional data-* attributes would need to be injected
|
||||||
* that matches. We have to resort to an [id] attribute selector
|
* onto the rendered widget root element.
|
||||||
*
|
*
|
||||||
* @param {String} sidebar_id
|
|
||||||
* @param {String} widget_id
|
* @param {String} widget_id
|
||||||
* @return {jQuery}
|
* @return {jQuery}
|
||||||
*/
|
*/
|
||||||
getSidebarWidgetElement: function ( sidebar_id, widget_id ) {
|
getWidgetElement: function ( widget_id ) {
|
||||||
return $( '[id=' + widget_id + ']' ).filter( function () {
|
return $( '#' + widget_id );
|
||||||
return $( this ).data( 'widget_customizer_sidebar_id' ) === sidebar_id;
|
|
||||||
} );
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
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);
|
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)})},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);
|
Loading…
Reference in New Issue