Make WordPress Core

Ticket #36908: 36908.diff

File 36908.diff, 15.5 KB (added by afercia, 8 years ago)
  • src/wp-admin/css/customize-controls.css

     
    14091409        overflow: auto;
    14101410        bottom: 0;
    14111411        width: 100%;
     1412        border-top: 1px solid #ddd;
    14121413}
    14131414
     1415.no-widgets-found #available-widgets-list {
     1416        border-top: none;
     1417}
     1418
    14141419#available-widgets-filter {
    14151420        position: fixed;
    14161421        top: 0;
     
    14171422        z-index: 1;
    14181423        width: 300px;
    14191424        background: #eee;
    1420         border-bottom: 1px solid #e5e5e5;
    14211425}
    14221426
    14231427/* search field container */
    14241428#available-widgets-filter,
    14251429#available-menu-items-search .accordion-section-title {
    1426         padding: 12px 15px;
     1430        padding: 13px 15px;
    14271431        -webkit-box-sizing: border-box;
    14281432        -moz-box-sizing: border-box;
    14291433        box-sizing: border-box;
     
    14311435
    14321436#available-widgets-filter input,
    14331437#available-menu-items-search input {
    1434         padding: 6px 10px;
    14351438        width: 100%;
     1439        height: 32px;
     1440        margin: 1px 0;
     1441        padding: 6px 30px;
    14361442}
    14371443
     1444#available-widgets-filter input::-ms-clear,
     1445#available-menu-items-search input::-ms-clear {
     1446        display: none; /* remove the "x" in IE, which conflicts with the "x" icon on button.clear-results */
     1447}
     1448
     1449#available-menu-items-search .search-icon,
     1450#available-widgets-filter .search-icon {
     1451        display: block;
     1452        position: absolute;
     1453        top: 15px; /* 13 container padding +1 input margin +1 input border */
     1454        left: 16px;
     1455        width: 30px;
     1456        height: 30px;
     1457        line-height: 28px;
     1458        text-align: center;
     1459        color: #72777c;
     1460}
     1461
     1462#available-widgets-filter .clear-results,
     1463#available-menu-items-search .clear-results {
     1464        position: absolute;
     1465        top: 15px; /* 13 container padding +1 input margin +1 input border */
     1466        right: 16px;
     1467        width: 30px;
     1468        height: 30px;
     1469        padding: 0;
     1470        border: 0;
     1471        cursor: pointer;
     1472        background: none;
     1473        color: #a00;
     1474        text-decoration: none;
     1475        outline: 0;
     1476}
     1477
     1478#available-widgets-filter .clear-results,
     1479#available-menu-items-search .clear-results,
     1480#available-menu-items-search.loading .clear-results.is-visible {
     1481        display: none;
     1482}
     1483
     1484#available-widgets-filter .clear-results.is-visible,
     1485#available-menu-items-search .clear-results.is-visible {
     1486        display: block;
     1487}
     1488
     1489#available-widgets-filter .clear-results:before,
     1490#available-menu-items-search .clear-results:before {
     1491        content: "\f335";
     1492        font: normal 20px/1 dashicons;
     1493        vertical-align: middle;
     1494        -webkit-font-smoothing: antialiased;
     1495        -moz-osx-font-smoothing: grayscale;
     1496}
     1497
     1498#available-widgets-filter .clear-results:hover,
     1499#available-widgets-filter .clear-results:focus,
     1500#available-menu-items-search .clear-results:hover,
     1501#available-menu-items-search .clear-results:focus {
     1502        color: #dc3232;
     1503}
     1504
     1505#available-widgets-filter .clear-results:focus,
     1506#available-menu-items-search .clear-results:focus {
     1507        -webkit-box-shadow:
     1508                0 0 0 1px #5b9dd9,
     1509                0 0 2px 1px rgba(30, 140, 190, .8);
     1510        box-shadow:
     1511                0 0 0 1px #5b9dd9,
     1512                0 0 2px 1px rgba(30, 140, 190, .8);
     1513}
     1514
     1515#available-menu-items-search .search-icon:after,
     1516#available-widgets-filter .search-icon:after {
     1517        content: "\f179";
     1518        font: normal 20px/1 dashicons;
     1519        vertical-align: middle;
     1520        -webkit-font-smoothing: antialiased;
     1521        -moz-osx-font-smoothing: grayscale;
     1522}
     1523
     1524.no-widgets-found-message {
     1525        display: none;
     1526        margin: 0;
     1527        padding: 0 15px;
     1528        line-height: inherit;
     1529}
     1530
     1531.no-widgets-found .no-widgets-found-message {
     1532        display: block;
     1533}
     1534
    14381535#available-widgets .widget-top,
    14391536#available-widgets .widget-top:hover,
    14401537#available-menu-items .item-top,
     
    14501547        position: relative;
    14511548        padding: 20px 15px 20px 60px;
    14521549        background: #fff;
    1453         border-bottom: 1px solid #e5e5e5;
     1550        border-bottom: 1px solid #ddd;
    14541551        border-left: 4px solid #fff;
    14551552        cursor: pointer;
    14561553        display: none;
     
    16281725        #available-widgets-filter {
    16291726                position: relative;
    16301727                width: 100%;
    1631                 background: #fff;
    16321728                height: auto;
    1633                 padding: 10px 15px;
    16341729        }
    16351730
    16361731        #available-widgets-list {
    1637                 top: 140px;
     1732                top: 130px;
    16381733        }
     1734
     1735        #available-menu-items-search .clear-results,
     1736        #available-menu-items-search .search-icon {
     1737                top: 85px; /* 70 section title height + 13 container padding +1 input margin +1 input border */
     1738        }
    16391739}
  • src/wp-admin/css/customize-nav-menus.css

     
    688688        margin: 0 20px;
    689689}
    690690
    691 #available-menu-items-search .clear-results {
    692         position: absolute;
    693         top: 18px; /* 12 container padding +1 input margin +1 input border +4 ( 4 is ( 28 input height - 20 button height ) / 2 ) */
    694         right: 20px;
    695         width: 20px;
    696         height: 20px;
    697         padding: 0;
    698         border: 0;
    699         cursor: pointer;
    700         background: none;
    701         color: #a00;
    702         text-decoration: none;
    703         outline: 0;
    704 }
    705 
    706 #available-menu-items-search .clear-results,
    707 #available-menu-items-search.loading .clear-results.is-visible {
    708         display: none;
    709 }
    710 
    711 #available-menu-items-search .clear-results.is-visible {
    712         display: block;
    713 }
    714 
    715 .ie8 #available-menu-items-search.loading .clear-results:before {
    716         content: ""; /* help IE8 redraw the pseudo element */
    717 }
    718 
    719 #available-menu-items-search .clear-results:before {
    720         content: "\f335";
    721         font: normal 20px/1 dashicons;
    722         vertical-align: middle;
    723         -webkit-font-smoothing: antialiased;
    724         -moz-osx-font-smoothing: grayscale;
    725 }
    726 
    727 #available-menu-items-search .clear-results:hover,
    728 #available-menu-items-search .clear-results:focus {
    729         color: #f00;
    730 }
    731 
    732691#available-menu-items-search .spinner {
    733692        position: absolute;
    734         top: 18px; /* 12 container padding +1 input margin +1 input border +4 ( ( 28 input height - 20 button height ) / 2 ) */
    735         right: 20px;
     693        top: 20px; /* 13 container padding +1 input margin +6 ( ( 32 input height - 20 spinner height ) / 2 ) */
     694        right: 21px;
    736695        margin: 0 !important;
    737696}
    738697
     
    739698/* search results list */
    740699#available-menu-items #available-menu-items-search .accordion-section-content {
    741700        position: absolute;
    742         left: 1px;
     701        left: 0;
    743702        top: 60px; /* below title div / search input */
    744703        bottom: 0px; /* 100% height that still triggers lazy load */
    745704        max-height: none;
     
    750709        box-sizing: border-box;
    751710}
    752711
     712#available-menu-items-search .nothing-found {
     713        /* Compensate the 1px top padding of the container. */
     714        margin-top: -1px;
     715}
     716
    753717#available-menu-items-search .accordion-section-title:after {
    754718        display: none;
    755719}
     
    920884.customize-screen-options-toggle:focus:before,
    921885#customize-controls .customize-info .customize-help-toggle:focus:before,
    922886.wp-customizer button:focus .toggle-indicator:after,
    923 #available-menu-items-search .clear-results:focus,
    924887.menu-delete:focus,
    925888.menu-item-bar .item-delete:focus:before,
    926889#available-menu-items .item-add:focus:before {
     
    937900        #available-menu-items #available-menu-items-search .accordion-section-content {
    938901                top: 63px;
    939902        }
    940 
    941         #available-menu-items-search .spinner,
    942         #available-menu-items-search .clear-results {
    943                 top: 20px; /* 12 container padding +1 input margin +1 input border +5.5 ( 5.5 rounded to 6 is ( 31 input height - 20 button height ) / 2 ) */
    944         }
    945903}
    946904
    947905@media screen and ( max-width: 640px ) {
    948906        #available-menu-items #available-menu-items-search .accordion-section-content {
    949                 top: 133px;
     907                top: 130px;
    950908        }
    951 
    952         #available-menu-items-search .clear-results {
    953                 top: 90px; /* 70 section title height + 12 container padding +1 input margin +1 input border +5.5 ( 5.5 rounded to 6 is ( 31 input height - 20 button height ) / 2 ) */
    954         }
    955909}
  • src/wp-admin/js/customize-nav-menus.js

     
    170170                currentMenuControl: null,
    171171                debounceSearch: null,
    172172                $search: null,
     173                $clearResults: null,
    173174                searchTerm: '',
    174175                rendered: false,
    175176                pages: {},
     
    185186                        }
    186187
    187188                        this.$search = $( '#menu-items-search' );
     189                        this.$clearResults = this.$el.find( '.clear-results' );
    188190                        this.sectionContent = this.$el.find( '.available-menu-items-list' );
    189191
    190192                        this.debounceSearch = _.debounce( self.search, 500 );
     
    202204                                }
    203205                        } );
    204206
    205                         // Clear the search results.
    206                         $( '.clear-results' ).on( 'click', function() {
     207                        // Clear the search results and trigger a `keyup` event to fire a new search.
     208                        this.$clearResults.on( 'click', function() {
    207209                                self.$search.val( '' ).focus().trigger( 'keyup' );
    208210                        } );
    209211
     
    261263                                $otherSections.fadeOut( 100 );
    262264                                $searchSection.find( '.accordion-section-content' ).slideDown( 'fast' );
    263265                                $searchSection.addClass( 'open' );
    264                                 $searchSection.find( '.clear-results' ).addClass( 'is-visible' );
     266                                this.$clearResults.addClass( 'is-visible' );
    265267                        } else if ( '' === event.target.value ) {
    266268                                $searchSection.removeClass( 'open' );
    267269                                $otherSections.show();
    268                                 $searchSection.find( '.clear-results' ).removeClass( 'is-visible' );
     270                                this.$clearResults.removeClass( 'is-visible' );
    269271                        }
    270272
    271273                        this.searchTerm = event.target.value;
     
    337339                        self.currentRequest.fail(function( data ) {
    338340                                // data.message may be undefined, for example when typing slow and the request is aborted.
    339341                                if ( data.message ) {
    340                                         $content.empty().append( $( '<p class="nothing-found"></p>' ).text( data.message ) );
     342                                        $content.empty().append( $( '<li class="nothing-found"></li>' ).text( data.message ) );
    341343                                        wp.a11y.speak( data.message );
    342344                                }
    343345                                self.pages.search = -1;
  • src/wp-admin/js/customize-widgets.js

     
    7070                                this.search( this.terms );
    7171                        }
    7272
    73                         // If search is blank, show all themes
    74                         // Useful for resetting the views when you clean the input
     73                        // If search is blank, set all the widgets as they matched the search to reset the views.
    7574                        if ( this.terms === '' ) {
    7675                                this.each( function ( widget ) {
    7776                                        widget.set( 'search_matched', true );
     
    149148                events: {
    150149                        'input #widgets-search': 'search',
    151150                        'keyup #widgets-search': 'search',
    152                         'change #widgets-search': 'search',
    153                         'search #widgets-search': 'search',
    154151                        'focus .widget-tpl' : 'focus',
    155152                        'click .widget-tpl' : '_submit',
    156153                        'keypress .widget-tpl' : '_submit',
     
    163160                // Cache sidebar control which has opened panel
    164161                currentSidebarControl: null,
    165162                $search: null,
     163                $clearResults: null,
     164                searchMatchesCount: null,
    166165
    167166                initialize: function() {
    168167                        var self = this;
     
    169168
    170169                        this.$search = $( '#widgets-search' );
    171170
     171                        this.$clearResults = this.$el.find( '.clear-results' );
     172
    172173                        _.bindAll( this, 'close' );
    173174
    174175                        this.listenTo( this.collection, 'change', this.updateList );
     
    175176
    176177                        this.updateList();
    177178
     179                        // Set the initial search count to the number of available widgets.
     180                        this.searchMatchesCount = this.collection.length;
     181
    178182                        // If the available widgets panel is open and the customize controls are
    179183                        // interacted with (i.e. available widgets panel is blurred) then close the
    180184                        // available widgets panel. Also close on back button click.
     
    185189                                }
    186190                        } );
    187191
     192                        // Clear the search results and trigger a `keyup` event to fire a new search.
     193                        this.$clearResults.on( 'click', function() {
     194                                self.$search.val( '' ).focus().trigger( 'keyup' );
     195                        } );
     196
    188197                        // Close the panel if the URL in the preview changes
    189198                        api.previewer.bind( 'url', this.close );
    190199                },
     
    194203                        var firstVisible;
    195204
    196205                        this.collection.doSearch( event.target.value );
     206                        // Update the search matches count.
     207                        this.updateSearchMatchesCount();
     208                        // Announce how many search results.
     209                        this.announceSearchMatches();
    197210
    198211                        // Remove a widget from being selected if it is no longer visible
    199212                        if ( this.selected && ! this.selected.is( ':visible' ) ) {
     
    214227                                        this.select( firstVisible );
    215228                                }
    216229                        }
     230
     231                        // Toggle the clear search results button.
     232                        if ( '' !== event.target.value ) {
     233                                this.$clearResults.addClass( 'is-visible' );
     234                        } else if ( '' === event.target.value ) {
     235                                this.$clearResults.removeClass( 'is-visible' );
     236                        }
     237
     238                        // Set a CSS class on the search container when there are no search results.
     239                        if ( ! this.searchMatchesCount ) {
     240                                this.$el.addClass( 'no-widgets-found' );
     241                        } else {
     242                                this.$el.removeClass( 'no-widgets-found' );
     243                        }
    217244                },
    218245
     246                // Update the count of the available widgets that have the `search_matched` attribute.
     247                updateSearchMatchesCount: function() {
     248                        this.searchMatchesCount = this.collection.where({ search_matched: true }).length;
     249                },
     250
     251                // Send a message to the aria-live region to announce how many search results.
     252                announceSearchMatches: _.debounce( function() {
     253                        var message = l10n.widgetsFound.replace( '%d', this.searchMatchesCount ) ;
     254
     255                        if ( ! this.searchMatchesCount ) {
     256                                message = l10n.noWidgetsFound;
     257                        }
     258
     259                        wp.a11y.speak( message );
     260                }, 500 ),
     261
    219262                // Changes visibility of available widgets
    220263                updateList: function() {
    221264                        this.collection.each( function( widget ) {
  • src/wp-includes/class-wp-customize-nav-menus.php

     
    891891                                        <p class="screen-reader-text" id="menu-items-search-desc"><?php _e( 'The search results will be updated as you type.' ); ?></p>
    892892                                        <span class="spinner"></span>
    893893                                </div>
     894                                <div class="search-icon" aria-hidden="true"></div>
    894895                                <button type="button" class="clear-results"><span class="screen-reader-text"><?php _e( 'Clear Results' ); ?></span></button>
    895896                                <ul class="accordion-section-content available-menu-items-list" data-type="search"></ul>
    896897                        </div>
  • src/wp-includes/class-wp-customize-widgets.php

     
    733733                                'reorderModeOn'    => __( 'Reorder mode enabled' ),
    734734                                'reorderModeOff'   => __( 'Reorder mode closed' ),
    735735                                'reorderLabelOn'   => esc_attr__( 'Reorder widgets' ),
    736                                 'reorderLabelOff'  => esc_attr__( 'Close reorder mode' ),
     736                                'widgetsFound'     => __( 'Number of widgets found: %d' ),
     737                                'noWidgetsFound'   => __( 'No widgets found.' ),
    737738                        ),
    738739                        'tpl' => array(
    739740                                'widgetReorderNav' => $widget_reorder_nav_tpl,
     
    777778                        </div>
    778779                        <div id="available-widgets-filter">
    779780                                <label class="screen-reader-text" for="widgets-search"><?php _e( 'Search Widgets' ); ?></label>
    780                                 <input type="search" id="widgets-search" placeholder="<?php esc_attr_e( 'Search widgets&hellip;' ) ?>" />
     781                                <input type="text" id="widgets-search" placeholder="<?php esc_attr_e( 'Search widgets&hellip;' ) ?>" aria-describedby="widgets-search-desc" />
     782                                <div class="search-icon" aria-hidden="true"></div>
     783                                <button type="button" class="clear-results"><span class="screen-reader-text"><?php _e( 'Clear Results' ); ?></span></button>
     784                                <p class="screen-reader-text" id="widgets-search-desc"><?php _e( 'The search results will be updated as you type.' ); ?></p>
    781785                        </div>
    782786                        <div id="available-widgets-list">
    783787                        <?php foreach ( $this->get_available_widgets() as $available_widget ): ?>
     
    785789                                        <?php echo $available_widget['control_tpl']; ?>
    786790                                </div>
    787791                        <?php endforeach; ?>
     792                        <p class="no-widgets-found-message"><?php _e( 'No widgets found.' ); ?></p>
    788793                        </div><!-- #available-widgets-list -->
    789794                </div><!-- #available-widgets -->
    790795                </div><!-- #widgets-left -->