Changeset 27892
- Timestamp:
- 04/01/2014 03:25:56 PM (12 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
-
wp-admin/js/customize-widgets.js (modified) (5 diffs)
-
wp-includes/js/customize-preview-widgets.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/customize-widgets.js
r27891 r27892 141 141 self.init = function () { 142 142 this.availableWidgetsPanel.setup(); 143 144 // Highlight widget control 145 this.previewer.bind( 'highlight-widget-control', self.highlightWidgetFormControl ); 146 147 // Open and focus widget control 148 this.previewer.bind( 'focus-widget-control', self.focusWidgetFormControl ); 143 149 }; 144 150 wp.customize.bind( 'ready', function () { … … 925 931 // Highlight whenever hovering or clicking over the form 926 932 control.container.on( 'mouseenter click', function () { 927 control.highlightPreviewWidget(); 933 control.setting.previewer.send( 'highlight-widget', control.params.widget_id ); 934 //control.highlightPreviewWidget(); 928 935 } ); 929 936 930 937 // Highlight when the setting is updated 931 938 control.setting.bind( function () { 932 control.s crollPreviewWidgetIntoView();933 control.highlightPreviewWidget();939 control.setting.previewer.send( 'highlight-widget', control.params.widget_id ); 940 //control.highlightPreviewWidget(); 934 941 } ); 935 942 … … 1483 1490 1484 1491 /** 1485 * Inverse of WidgetCustomizer.getControlInstanceForWidget1486 * @return {jQuery}1487 */1488 getPreviewWidgetElement: function () {1489 var control = this,1490 widget_customizer_preview = self.getPreviewWindow().wp.customize.WidgetCustomizerPreview;1491 return widget_customizer_preview.getWidgetElement( control.params.widget_id );1492 },1493 1494 /**1495 1492 * Inside of the customizer preview, scroll the widget into view 1496 1493 */ … … 1515 1512 setTimeout( function () { 1516 1513 target_element.removeClass( 'widget-customizer-highlighted' ); 1517 }, 500 );1518 },1519 1520 /**1521 * Add the widget-customizer-highlighted-widget class to the widget for 500ms1522 */1523 highlightPreviewWidget: function () {1524 var control = this, widget_el, root_el;1525 1526 widget_el = control.getPreviewWidgetElement();1527 root_el = widget_el.closest( 'html' );1528 root_el.find( '.widget-customizer-highlighted-widget' ).removeClass( 'widget-customizer-highlighted-widget' );1529 widget_el.addClass( 'widget-customizer-highlighted-widget' );1530 setTimeout( function () {1531 widget_el.removeClass( 'widget-customizer-highlighted-widget' );1532 1514 }, 500 ); 1533 1515 } … … 1546 1528 } 1547 1529 } ); 1530 1531 /** 1532 * Highlight a widget control. 1533 * 1534 * @param {string} widgetId 1535 */ 1536 self.highlightWidgetFormControl = function( widgetId ) { 1537 var control = self.getWidgetFormControlForWidget( widgetId ); 1538 1539 if ( control ) { 1540 control.highlightSectionAndControl(); 1541 } 1542 }, 1543 1544 /** 1545 * Focus a widget control. 1546 * 1547 * @param {string} widgetId 1548 */ 1549 self.focusWidgetFormControl = function( widgetId ) { 1550 var control = self.getWidgetFormControlForWidget( widgetId ); 1551 1552 if ( control ) { 1553 control.focus(); 1554 } 1555 }, 1548 1556 1549 1557 /** -
trunk/src/wp-includes/js/customize-preview-widgets.js
r27653 r27892 28 28 self.preview.send( 'rendered-widgets', self.renderedWidgets ); // @todo Only send array of IDs 29 29 } ); 30 31 this.preview.bind( 'highlight-widget', self.highlightWidget ); 30 32 }, 31 33 … … 59 61 60 62 /** 61 * Obtain a rendered widget element. Assumes standard practice of using 62 * the widget ID as the ID for the DOM element. To eliminate this 63 * assumption, additional data-* attributes would need to be injected 64 * onto the rendered widget root element. 63 * Highlight the widget on widget updates or widget control mouse overs. 65 64 * 66 * @param {String} widget_id 67 * @return {jQuery} 65 * @param {string} widgetId ID of the widget. 68 66 */ 69 getWidgetElement: function ( widget_id ) { 70 return $( '#' + widget_id ); 67 highlightWidget: function( widgetId ) { 68 var $body = $( document.body ), 69 $widget = $( '#' + widgetId ); 70 71 $body.find( '.widget-customizer-highlighted-widget' ).removeClass( 'widget-customizer-highlighted-widget' ); 72 73 $widget.addClass( 'widget-customizer-highlighted-widget' ); 74 setTimeout( function () { 75 $widget.removeClass( 'widget-customizer-highlighted-widget' ); 76 }, 500 ); 71 77 }, 72 78 73 79 /** 74 * 80 * Show a title and highlight widgets on hover. On shift+clicking 81 * focus the widget control. 75 82 */ 76 83 highlightControls: function() { 77 var selector = this.widgetSelectors.join(','); 84 var self = this, 85 selector = this.widgetSelectors.join(','); 78 86 79 87 $(selector).attr( 'title', this.l10n.widgetTooltip ); 80 88 81 89 $(document).on( 'mouseenter', selector, function () { 82 var control = parent.WidgetCustomizer.getWidgetFormControlForWidget( $(this).prop('id') ); 83 if ( control ) { 84 control.highlightSectionAndControl(); 85 } 90 self.preview.send( 'highlight-widget-control', $( this ).prop( 'id' ) ); 86 91 }); 87 92 … … 92 97 } 93 98 e.preventDefault(); 94 var control = parent.WidgetCustomizer.getWidgetFormControlForWidget( $(this).prop('id') ); 95 if ( control ) { 96 control.focus(); 97 } 99 100 self.preview.send( 'focus-widget-control', $( this ).prop( 'id' ) ); 98 101 }); 99 102 }
Note: See TracChangeset
for help on using the changeset viewer.