Make WordPress Core

Changeset 27584


Ignore:
Timestamp:
03/18/2014 03:20:38 PM (11 years ago)
Author:
ocean90
Message:

Widget Customizer: Restore highlighting of widgets in preview.

props westonruter.
see #27358.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/customize-widgets.js

    r27540 r27584  
    14431443            var control = this,
    14441444                widget_customizer_preview = self.getPreviewWindow().WidgetCustomizerPreview;
    1445             return widget_customizer_preview.getSidebarWidgetElement( control.params.sidebar_id, control.params.widget_id );
     1445            return widget_customizer_preview.getWidgetElement( control.params.widget_id );
    14461446        },
    14471447
  • trunk/src/wp-includes/class-wp-customize-widgets.php

    r27543 r27584  
    757757        );
    758758
    759         /*
    760         wp_enqueue_style(
    761             'widget-customizer-preview',
    762             'widget-customizer-preview.css'
    763         );
    764         */
     759        add_action( 'wp_print_styles', array( __CLASS__, 'inject_preview_css' ), 1 );
    765760
    766761        // Why not wp_localize_script? Because we're not localizing, and it forces values into strings
     
    782777            sprintf( 'var WidgetCustomizerPreview_exports = %s;', json_encode( $exports ) )
    783778        );
     779    }
     780
     781    /**
     782     * Insert default style for highlighted widget at early point so theme
     783     * stylesheet can override.
     784     *
     785     * @action wp_print_styles
     786     */
     787    static function inject_preview_css() {
     788        ?>
     789        <style>
     790        .widget-customizer-highlighted-widget {
     791            border-radius: 2px;
     792            outline: none;
     793            box-shadow: 0 0 3px #ce0000;
     794        }
     795        </style>
     796        <?php
    784797    }
    785798
  • trunk/src/wp-includes/js/customize-preview-widgets.js

    r27436 r27584  
    5353
    5454        /**
    55          * Obtain a widget instance if it was added to the provided sidebar
    56          * This addresses a race condition where a widget is moved between sidebars
    57          * We cannot use ID selector because jQuery will only return the first one
    58          * that matches. We have to resort to an [id] attribute selector
     55         * Obtain a rendered widget element. Assumes standard practice of using
     56         * the widget ID as the ID for the DOM element. To eliminate this
     57         * assumption, additional data-* attributes would need to be injected
     58         * onto the rendered widget root element.
    5959         *
    60          * @param {String} sidebar_id
    6160         * @param {String} widget_id
    6261         * @return {jQuery}
    6362         */
    64         getSidebarWidgetElement: function ( sidebar_id, widget_id ) {
    65             return $( '[id=' + widget_id + ']' ).filter( function () {
    66                 return $( this ).data( 'widget_customizer_sidebar_id' ) === sidebar_id;
    67             } );
     63        getWidgetElement: function ( widget_id ) {
     64            return $( '#' + widget_id );
    6865        },
    6966
Note: See TracChangeset for help on using the changeset viewer.