Changeset 51010
- Timestamp:
- 05/25/2021 07:13:38 PM (4 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/lib/nav-menu.js
r51009 r51010 876 876 var that = this; 877 877 878 $( '.bulk-select-switcher').on( 'change', function(){879 if ( this.checked ){880 $( '.bulk-select-switcher').prop('checked',true);878 $( '.bulk-select-switcher' ).on( 'change', function() { 879 if ( this.checked ) { 880 $( '.bulk-select-switcher' ).prop( 'checked', true ); 881 881 that.enableBulkSelection(); 882 } else{883 $( '.bulk-select-switcher').prop('checked',false);882 } else { 883 $( '.bulk-select-switcher' ).prop( 'checked', false ); 884 884 that.disableBulkSelection(); 885 885 } … … 893 893 */ 894 894 enableBulkSelection : function() { 895 $('#menu-to-edit').addClass('bulk-selection'); 896 $('#nav-menu-bulk-actions-top').addClass('bulk-selection'); 897 $('#nav-menu-bulk-actions-bottom').addClass('bulk-selection'); 898 899 var checkbox = $('#menu-to-edit .menu-item-checkbox'); 900 $.each( checkbox, function(){ 901 $(this).prop('disabled',false); 895 var checkbox = $( '#menu-to-edit .menu-item-checkbox' ); 896 897 $( '#menu-to-edit' ).addClass( 'bulk-selection' ); 898 $( '#nav-menu-bulk-actions-top' ).addClass( 'bulk-selection' ); 899 $( '#nav-menu-bulk-actions-bottom' ).addClass( 'bulk-selection' ); 900 901 $.each( checkbox, function() { 902 $(this).prop( 'disabled', false ); 902 903 }); 903 904 }, … … 909 910 */ 910 911 disableBulkSelection : function() { 911 $('#menu-to-edit').removeClass('bulk-selection'); 912 $('#nav-menu-bulk-actions-top').removeClass('bulk-selection'); 913 $('#nav-menu-bulk-actions-bottom').removeClass('bulk-selection'); 914 915 if ( $('.menu-items-delete').is('[aria-describedby="pending-menu-items-to-delete"]') ) { 916 $('.menu-items-delete').removeAttr( 'aria-describedby' ); 917 } 918 919 var checkbox = $('#menu-to-edit .menu-item-checkbox'); 920 $.each( checkbox, function(){ 921 $(this).prop('disabled',true).prop('checked',false); 922 }); 923 $('.menu-items-delete').addClass('disabled'); 924 $('#pending-menu-items-to-delete ul').empty(); 912 var checkbox = $( '#menu-to-edit .menu-item-checkbox' ); 913 914 $( '#menu-to-edit' ).removeClass( 'bulk-selection' ); 915 $( '#nav-menu-bulk-actions-top' ).removeClass( 'bulk-selection' ); 916 $( '#nav-menu-bulk-actions-bottom' ).removeClass( 'bulk-selection' ); 917 918 if ( $( '.menu-items-delete' ).is( '[aria-describedby="pending-menu-items-to-delete"]' ) ) { 919 $( '.menu-items-delete' ).removeAttr( 'aria-describedby' ); 920 } 921 922 $.each( checkbox, function() { 923 $(this).prop( 'disabled', true ).prop( 'checked', false ); 924 }); 925 926 $( '.menu-items-delete' ).addClass( 'disabled' ); 927 $( '#pending-menu-items-to-delete ul' ).empty(); 925 928 }, 926 929 … … 933 936 var that = this; 934 937 935 $( '#menu-to-edit' ).on( 'change', '.menu-item-checkbox', function() {938 $( '#menu-to-edit' ).on( 'change', '.menu-item-checkbox', function() { 936 939 that.setRemoveSelectedButtonStatus(); 937 940 }); … … 946 949 var that = this; 947 950 948 $( document ).on('click', '.menu-items-delete', function(e){ 951 $( document ).on( 'click', '.menu-items-delete', function( e ) { 952 var itemsPendingDeletion, itemsPendingDeletionList, deletionSpeech; 953 949 954 e.preventDefault(); 950 955 951 if ( ! $(this).hasClass('disabled') ){952 $.each( $( '.menu-item-checkbox:checked'), function( index, element ) {956 if ( ! $(this).hasClass( 'disabled' ) ) { 957 $.each( $( '.menu-item-checkbox:checked' ), function( index, element ) { 953 958 $( element ).parents( 'li' ).find( 'a.item-delete' ).trigger( 'click' ); 954 959 }); 955 960 956 $( '.menu-items-delete').addClass('disabled');957 $( '.bulk-select-switcher').prop('checked',false);958 959 var itemsPendingDeletion= '';960 var itemsPendingDeletionList = $('#pending-menu-items-to-delete ul li');961 $( '.menu-items-delete' ).addClass( 'disabled' ); 962 $( '.bulk-select-switcher' ).prop( 'checked', false ); 963 964 itemsPendingDeletion = ''; 965 itemsPendingDeletionList = $( '#pending-menu-items-to-delete ul li' ); 961 966 962 967 $.each( itemsPendingDeletionList, function( index, element ) { 963 968 var itemName = $( element ).find( '.pending-menu-item-name' ).text(); 964 969 var itemSpeech = menus.menuItemDeletion.replace( '%s', itemName ); 965 itemsPendingDeletion += itemSpeech ; 966 if( ( index + 1 ) < itemsPendingDeletionList.length ){ 967 itemsPendingDeletion += ', ' ; 970 971 itemsPendingDeletion += itemSpeech; 972 if ( ( index + 1 ) < itemsPendingDeletionList.length ) { 973 itemsPendingDeletion += ', '; 968 974 } 969 975 }); 970 976 971 vardeletionSpeech = menus.itemsDeleted.replace( '%s', itemsPendingDeletion );977 deletionSpeech = menus.itemsDeleted.replace( '%s', itemsPendingDeletion ); 972 978 wp.a11y.speak( deletionSpeech, 'polite' ); 973 979 that.disableBulkSelection(); … … 981 987 * @since 5.8.0 982 988 */ 983 attachPendingMenuItemsListForDeletion : function(){ 984 $('#post-body-content').on( 'change', '.menu-item-checkbox', function(){ 985 986 if( ! $('.menu-items-delete').is('[aria-describedby="pending-menu-items-to-delete"]') ){ $('.menu-items-delete').attr( 'aria-describedby', 'pending-menu-items-to-delete' ); } 987 988 var menuItemName = $(this).next().text(); 989 var menuItemType = $(this).parent().next('.item-controls').find('.item-type').text(); 990 var menuItemID = $(this).attr('data-menu-item-id'); 991 992 var ListedMenuItem = $('#pending-menu-items-to-delete ul').find('[data-menu-item-id=' + menuItemID + ']'); 993 if( ListedMenuItem.length > 0 ){ 994 ListedMenuItem.remove(); 995 } 996 if( this.checked === true ){ 997 $('#pending-menu-items-to-delete ul').append( '<li data-menu-item-id="' + menuItemID + '"><span class="pending-menu-item-name">' + menuItemName + '</span> <span class="pending-menu-item-type">(' + menuItemType + ')</span><span class="separator"></span></li>' ); 998 } 999 1000 $('#pending-menu-items-to-delete li .separator').html(', '); 1001 $('#pending-menu-items-to-delete li .separator').last().html('.'); 989 attachPendingMenuItemsListForDeletion : function() { 990 $( '#post-body-content' ).on( 'change', '.menu-item-checkbox', function() { 991 var menuItemName, menuItemType, menuItemID, listedMenuItem; 992 993 if ( ! $( '.menu-items-delete' ).is( '[aria-describedby="pending-menu-items-to-delete"]' ) ) { 994 $( '.menu-items-delete' ).attr( 'aria-describedby', 'pending-menu-items-to-delete' ); 995 } 996 997 menuItemName = $(this).next().text(); 998 menuItemType = $(this).parent().next( '.item-controls' ).find( '.item-type' ).text(); 999 menuItemID = $(this).attr( 'data-menu-item-id' ); 1000 1001 listedMenuItem = $( '#pending-menu-items-to-delete ul' ).find( '[data-menu-item-id=' + menuItemID + ']' ); 1002 if ( listedMenuItem.length > 0 ) { 1003 listedMenuItem.remove(); 1004 } 1005 1006 if ( this.checked === true ) { 1007 $( '#pending-menu-items-to-delete ul' ).append( 1008 '<li data-menu-item-id="' + menuItemID + '">' + 1009 '<span class="pending-menu-item-name">' + menuItemName + '</span> ' + 1010 '<span class="pending-menu-item-type">(' + menuItemType + ')</span>' + 1011 '<span class="separator"></span>' + 1012 '</li>' 1013 ); 1014 } 1015 1016 $( '#pending-menu-items-to-delete li .separator' ).html( ', ' ); 1017 $( '#pending-menu-items-to-delete li .separator' ).last().html( '.' ); 1002 1018 }); 1003 1019 }, … … 1008 1024 * @since 5.8.0 1009 1025 */ 1010 setBulkDeleteCheckboxStatus : function(){ 1011 1026 setBulkDeleteCheckboxStatus : function() { 1012 1027 var that = this; 1013 var checkbox = $('#menu-to-edit .menu-item-checkbox'); 1014 1015 $.each( checkbox, function(){ 1016 1017 if( $(this).prop('disabled') == true ){ 1028 var checkbox = $( '#menu-to-edit .menu-item-checkbox' ); 1029 1030 $.each( checkbox, function() { 1031 if ( $(this).prop( 'disabled' ) ) { 1018 1032 $(this).prop( 'disabled', false ); 1019 } else{1033 } else { 1020 1034 $(this).prop( 'disabled', true ); 1021 1035 } 1022 1036 1023 if ( $(this).is(':checked')) {1024 $(this).prop( 'checked',false);1037 if ( $(this).is( ':checked' ) ) { 1038 $(this).prop( 'checked', false ); 1025 1039 } 1026 1040 }); … … 1034 1048 * @since 5.8.0 1035 1049 */ 1036 setRemoveSelectedButtonStatus : function(){ 1037 1038 var button = $('.menu-items-delete'); 1039 1040 if( $('.menu-item-checkbox:checked').length > 0 ) { 1041 button.removeClass('disabled'); 1050 setRemoveSelectedButtonStatus : function() { 1051 var button = $( '.menu-items-delete' ); 1052 1053 if ( $( '.menu-item-checkbox:checked' ).length > 0 ) { 1054 button.removeClass( 'disabled' ); 1042 1055 } else { 1043 button.addClass( 'disabled');1056 button.addClass( 'disabled' ); 1044 1057 } 1045 1058 }, -
trunk/src/wp-admin/includes/class-walker-nav-menu-edit.php
r51006 r51010 119 119 <div class="menu-item-bar"> 120 120 <div class="menu-item-handle"> 121 <label class="item-title" for="menu-item-checkbox-<?php echo $item_id; ?>"><input id="menu-item-checkbox-<?php echo $item_id; ?>" type="checkbox" class="menu-item-checkbox" data-menu-item-id="<?php echo $item_id; ?>" disabled="disabled"/><span class="menu-item-title"><?php echo esc_html( $title ); ?></span> <span class="is-submenu" <?php echo $submenu_text; ?>><?php _e( 'sub item' ); ?></span></label> 121 <label class="item-title" for="menu-item-checkbox-<?php echo $item_id; ?>"> 122 <input id="menu-item-checkbox-<?php echo $item_id; ?>" type="checkbox" class="menu-item-checkbox" data-menu-item-id="<?php echo $item_id; ?>" disabled="disabled" /> 123 <span class="menu-item-title"><?php echo esc_html( $title ); ?></span> 124 <span class="is-submenu" <?php echo $submenu_text; ?>><?php _e( 'sub item' ); ?></span> 125 </label> 122 126 <span class="item-controls"> 123 127 <span class="item-type"><?php echo esc_html( $item->type_label ); ?></span> -
trunk/src/wp-admin/nav-menus.php
r51009 r51010 985 985 <label class="bulk-select-button" for="bulk-select-switcher-top"> 986 986 <input type="checkbox" id="bulk-select-switcher-top" name="bulk-select-switcher-top" class="bulk-select-switcher"> 987 <span class="bulk-select-button-label"><?php echo __( 'Bulk Select' ); ?></span>987 <span class="bulk-select-button-label"><?php _e( 'Bulk Select' ); ?></span> 988 988 </label> 989 989 </div> … … 1016 1016 <label class="bulk-select-button" for="bulk-select-switcher-bottom"> 1017 1017 <input type="checkbox" id="bulk-select-switcher-bottom" name="bulk-select-switcher-top" class="bulk-select-switcher"> 1018 <span class="bulk-select-button-label"><?php echo __( 'Bulk Select' ); ?></span>1018 <span class="bulk-select-button-label"><?php _e( 'Bulk Select' ); ?></span> 1019 1019 </label> 1020 1020 <input type="button" class="deletion menu-items-delete disabled" value="<?php _e( 'Remove Selected Items' ); ?>">
Note: See TracChangeset
for help on using the changeset viewer.