Ticket #17698: 17698.diff

File 17698.diff, 2.0 KB (added by mitchoyoshitaka, 2 years ago)
  • wp-admin/js/nav-menu.dev.js

     
    4141                        this.attachTabsPanelListeners(); 
    4242 
    4343                        this.attachUnsavedChangesListener(); 
     44                         
     45                        this.attachValidators(); 
    4446 
    4547                        if( api.menuList.length ) // If no menu, we're in the + tab. 
    4648                                this.initSortables(); 
     
    108110                                                }); 
    109111                                        }); 
    110112                                }, 
     113 
     114                                validateSelections : function() { 
     115                                        return !! this.find('.tabs-panel-active .categorychecklist li input:checked').length; 
     116                                }, 
    111117                                /** 
    112118                                 * Adds selected menu items to the menu. 
    113119                                 * 
     
    516522                        }); 
    517523                }, 
    518524 
     525                validateCustomLink : function() { 
     526                        var url = $('#custom-menu-item-url').val(); 
     527                        return ! ( '' == url || 'http://' == url ); 
     528                }, 
     529                 
     530                attachValidators : function() { 
     531                        var onCustomLinkChange = function() { 
     532                                $('#submit-customlinkdiv').prop('disabled', !api.validateCustomLink()); 
     533                        }, 
     534                        onChecklistChange = function() { 
     535                                var t = $(this).closest('.posttypediv, .taxonomydiv'); 
     536                                t.find('.submit-add-to-menu').prop('disabled', !t.validateSelections()); 
     537                        }; 
     538                         
     539                        $('#custom-menu-item-url').change(onCustomLinkChange); 
     540                        onCustomLinkChange(); 
     541                         
     542                        $('.posttypediv, .taxonomydiv').each(function() { 
     543                                onChecklistChange.apply(this); 
     544                                $(this).delegate( '.tabs-panel .categorychecklist li input', 'change', onChecklistChange ); 
     545                        }); 
     546                }, 
     547 
    519548                addCustomLink : function( processMethod ) { 
    520549                        var url = $('#custom-menu-item-url').val(), 
    521550                                label = $('#custom-menu-item-name').val(); 
     
    621650                                        wrapper = target.parents('.inside').first(); 
    622651 
    623652                                        // upon changing tabs, we want to uncheck all checkboxes 
    624                                         $('input', wrapper).removeAttr('checked'); 
     653                                        $('input', wrapper).removeAttr('checked').change(); 
    625654 
    626655                                        $('.tabs-panel-active', wrapper).removeClass('tabs-panel-active').addClass('tabs-panel-inactive'); 
    627656                                        $('#' + panelId, wrapper).removeClass('tabs-panel-inactive').addClass('tabs-panel-active');