Make WordPress Core

Ticket #35576: 35576.diff

File 35576.diff, 2.4 KB (added by sayedwp, 9 years ago)
  • nav-menu.js

     
    6161                        this.initToggles();
    6262
    6363                        this.initPreviewing();
     64
     65                        this.hideButtonControlsIfSearchEmpty();
    6466                },
    6567
     68                /**
     69                 * Hides the button controls when the user comes back to the page when page is refreshed.
     70                 */
     71                hideButtonControlsIfSearchEmpty : function(){
     72                        var activePanel = $('.control-section.open .tabs-panel-active'),
     73                                hashValue = window.location.hash.substr(1);
     74
     75                        if( activePanel.length && hashValue && hashValue.indexOf( 'search' ) > 1 ){
     76                                if( ! activePanel.find('li').length )
     77                                        activePanel.closest('.posttypediv, .taxonomydiv').find('.button-controls').hide();
     78                        }
     79                },
     80
    6681                jQueryExtensions : function() {
    6782                        // jQuery extensions
    6883                        $.fn.extend({
     
    10211036
    10221037                attachTabsPanelListeners : function() {
    10231038                        $('#menu-settings-column').bind('click', function(e) {
    1024                                 var selectAreaMatch, panelId, wrapper, items,
     1039                                var selectAreaMatch, panelId, wrapper, items, postTypeDiv, button_controls,
    10251040                                        target = $(e.target);
    10261041
    10271042                                if ( target.hasClass('nav-tab-link') ) {
     
    10421057                                        // select the search bar
    10431058                                        $('.quick-search', wrapper).focus();
    10441059
     1060                                        postTypeDiv = target.closest('.posttypediv, .taxonomydiv');
     1061                                        button_controls = postTypeDiv.find('.button-controls');
     1062
     1063                                        //hide select All if no items are in search panel
     1064                                        if( ! postTypeDiv.find('.tabs-panel-active li').length && panelId.indexOf('search') >= 0 ){
     1065                                                button_controls.hide();
     1066                                        }
     1067                                        else{
     1068                                                button_controls.show();
     1069                                        }
     1070
    10451071                                        e.preventDefault();
    10461072                                } else if ( target.hasClass('select-all') ) {
    10471073                                        selectAreaMatch = /#(.*)$/.exec(e.target.href);
     
    11741200                        form = document.getElementById('nav-menu-meta'),
    11751201                        pattern = /menu-item[(\[^]\]*/,
    11761202                        $items = $('<div>').html(resp).find('li'),
     1203                        button_controls = panel.closest('.posttypediv, .taxonomydiv').find('.button-controls'),
    11771204                        $item;
    11781205
    11791206                        if( ! $items.length ) {
    11801207                                $('.categorychecklist', panel).html( '<li><p>' + navMenuL10n.noResultsFound + '</p></li>' );
    11811208                                $( '.spinner', panel ).removeClass( 'is-active' );
     1209                                button_controls.hide();
    11821210                                return;
    11831211                        }
    11841212
     
    12061234
    12071235                        $('.categorychecklist', panel).html( $items );
    12081236                        $( '.spinner', panel ).removeClass( 'is-active' );
     1237                        button_controls.show();
    12091238                },
    12101239
    12111240                removeMenuItem : function(el) {