Ticket #39074: 39074.5.diff
| File 39074.5.diff, 8.2 KB (added by , 6 years ago) |
|---|
-
src/js/_enqueues/admin/postbox.js
diff --git a/src/js/_enqueues/admin/postbox.js b/src/js/_enqueues/admin/postbox.js index 9789518b65..7bfd0852fb 100644
a b 39 39 */ 40 40 handle_click : function () { 41 41 var $el = $( this ), 42 p = $el. parent( '.postbox' ),42 p = $el.closest( '.postbox' ), 43 43 id = p.attr( 'id' ), 44 44 ariaExpandedValue; 45 45 … … 86 86 $document.trigger( 'postbox-toggled', p ); 87 87 }, 88 88 89 /** 90 * Handles clicks on the order up/down icons inside the postbox heading. 91 * 92 * @since 5.4.0 93 * @memberof postboxes 94 * 95 * @return {void} 96 */ 97 handle_order: function() { 98 var el = $( this ), 99 closestPostbox = el.closest( '.postbox' ), 100 closestPostboxId = closestPostbox.attr( 'id' ); 101 102 if ( 'dashboard_browser_nag' === closestPostboxId ) { 103 return; 104 } 105 106 if ( el.hasClass( 'handle-order-higher' ) ) { 107 closestPostbox.prev().before( closestPostbox ); 108 } 109 110 if ( el.hasClass( 'handle-order-lower' ) ) { 111 closestPostbox.next().after( closestPostbox ); 112 } 113 114 el.focus(); 115 116 postboxes.enable_disable_order_buttons(); 117 118 postboxes.save_order( postboxes.page ); 119 }, 120 121 /** 122 * Adjusts the aria-disabled attribute for the up/down sorting arrows within the page. 123 * 124 * @return {void} 125 */ 126 enable_disable_order_buttons: function() { 127 128 $( 'body' ).find( '.meta-box-sortables' ).each( function() { 129 // we need to count -1 since indexing starts from 0. 130 var postBoxesCount = $( this ).children( '.postbox' ).length - 1; 131 132 $( this ).children( '.postbox' ).each( function() { 133 var postboxIndex = $( this ).index(); 134 135 if ( 0 === postboxIndex ) { 136 $( this ).find( '.handle-order-higher' ).attr( 'aria-disabled', 'true' ); 137 $( this ).find( '.handle-order-lower' ).attr( 'aria-disabled', 'false' ); 138 } else if ( postBoxesCount === postboxIndex ) { 139 $( this ).find( '.handle-order-higher' ).attr( 'aria-disabled', 'false' ); 140 $( this ).find( '.handle-order-lower' ).attr( 'aria-disabled', 'true' ); 141 } else { 142 $( this ).find( '.handle-order-higher' ).attr( 'aria-disabled', 'false' ); 143 $( this ).find( '.handle-order-lower' ).attr( 'aria-disabled', 'false' ); 144 } 145 }); 146 }); 147 }, 148 89 149 /** 90 150 * Adds event handlers to all postboxes and screen option on the current page. 91 151 * … … 99 159 * @return {void} 100 160 */ 101 161 add_postbox_toggles : function (page, args) { 102 var $handles = $( '.postbox .hndle, .postbox .handlediv' ); 162 var $handles = $( '.postbox .hndle, .postbox .handlediv' ), 163 $order_buttons = $( '.postbox .handle-order-higher, .postbox .handle-order-lower' ); 103 164 104 165 this.page = page; 105 166 this.init( page, args ); 106 167 107 168 $handles.on( 'click.postboxes', this.handle_click ); 108 169 170 $order_buttons.on( 'click.postboxes', this.handle_order ); 171 109 172 /** 110 173 * @since 2.7.0 111 174 */ … … 240 303 return; 241 304 } 242 305 306 postboxes.enable_disable_order_buttons(); 243 307 postboxes.save_order(page); 244 308 }, 245 309 receive: function(e,ui) { -
src/wp-admin/css/common.css
diff --git a/src/wp-admin/css/common.css b/src/wp-admin/css/common.css index a8b8112b00..34ff1079c4 100644
a b html.wp-toolbar { 2057 2057 font-weight: 400; 2058 2058 } 2059 2059 2060 .postbox .handle-actions { 2061 float: right; 2062 display: inline-block; 2063 height: 36px; 2064 } 2065 2066 .postbox .handle-order-higher, 2067 .postbox .handle-order-lower, 2060 2068 .postbox .handlediv { 2061 2069 display: none; 2062 float: right;2063 2070 width: 36px; 2064 2071 height: 36px; 2065 2072 margin: 0; … … html.wp-toolbar { 2069 2076 cursor: pointer; 2070 2077 } 2071 2078 2079 .js .postbox .handle-order-higher, 2080 .js .postbox .handle-order-lower, 2072 2081 .js .postbox .handlediv { 2073 display: block;2082 display: inline-block; 2074 2083 } 2075 2084 2076 2085 .sortable-placeholder { … … img { 3030 3039 /* Metabox collapse arrow indicators */ 3031 3040 .sidebar-name .toggle-indicator:before, 3032 3041 .js .meta-box-sortables .postbox .toggle-indicator:before, 3042 .js .meta-box-sortables .postbox .order-higher-indicator:before, 3043 .js .meta-box-sortables .postbox .order-lower-indicator:before, 3033 3044 .bulk-action-notice .toggle-indicator:before, 3034 3045 .privacy-text-box .toggle-indicator:before { 3035 3046 content: "\f142"; … … img { 3048 3059 content: "\f140"; 3049 3060 } 3050 3061 3062 .js .postbox .handle-order-higher .order-higher-indicator:before { 3063 content: "\f343"; 3064 } 3065 3066 .js .postbox .handle-order-lower .order-lower-indicator:before { 3067 content: "\f347"; 3068 } 3069 3070 .js .postbox .handle-order-higher[aria-disabled=true] .order-higher-indicator:before, 3071 .js .postbox .handle-order-lower[aria-disabled=true] .order-lower-indicator:before { 3072 cursor: default; 3073 pointer-events: none; 3074 opacity: .5; 3075 } 3076 3077 .js .postbox .handle-order-higher .order-higher-indicator:before, 3078 .js .postbox .handle-order-lower .order-lower-indicator:before, 3051 3079 .js .postbox .handlediv .toggle-indicator:before { 3052 3080 margin-top: 4px; 3053 3081 width: 20px; … … img { 3055 3083 text-indent: -1px; /* account for the dashicon alignment */ 3056 3084 } 3057 3085 3086 .rtl.js .postbox .handle-order-higher .order-higher-indicator:before, 3087 .rtl.js .postbox .handle-order-lower .order-lower-indicator:before, 3058 3088 .rtl.js .postbox .handlediv .toggle-indicator:before { 3059 3089 text-indent: 1px; /* account for the dashicon alignment */ 3060 3090 } … … img { 3065 3095 color: #72777c; 3066 3096 } 3067 3097 3098 .js .postbox .handle-order-higher:focus, 3099 .js .postbox .handle-order-lower:focus, 3068 3100 .js .postbox .handlediv:focus { 3069 3101 box-shadow: none; 3070 3102 outline: none; 3071 3103 } 3072 3104 3105 .js .postbox .handle-order-higher:focus .order-higher-indicator:before, 3106 .js .postbox .handle-order-lower:focus .order-lower-indicator:before, 3073 3107 .js .postbox .handlediv:focus .toggle-indicator:before { 3074 3108 box-shadow: 3075 3109 0 0 0 1px #5b9dd9, … … img { 3375 3409 .postbox .handlediv.button-link, 3376 3410 .item-edit, 3377 3411 .toggle-indicator, 3412 .order-higher-indicator, 3413 .order-lower-indicator, 3378 3414 .accordion-section-title:after { 3379 3415 color: #72777c; 3380 3416 } -
src/wp-admin/includes/template.php
diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php index 3ed611d0c4..209344d4ff 100644
a b function do_meta_boxes( $screen, $context, $object ) { 1264 1264 if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) { 1265 1265 foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) { 1266 1266 if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { 1267 $total_postboxes = count( $wp_meta_boxes[ $page ][ $context ][ $priority ] ); 1268 1267 1269 foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { 1268 1270 if ( false == $box || ! $box['title'] ) { 1269 1271 continue; … … function do_meta_boxes( $screen, $context, $object ) { 1306 1308 unset( $box['args']['__widget_basename'] ); 1307 1309 } 1308 1310 1311 $disable_order_higher = 'false'; 1312 $disable_order_lower = 'false'; 1313 1314 if ( 1 === $i ) { 1315 $disable_order_higher = 'true'; 1316 } 1317 1318 if ( $total_postboxes === $i ) { 1319 $disable_order_lower = 'true'; 1320 } 1321 1322 echo '<div class="handle-actions">'; 1323 echo '<button type="button" class="handle-order-higher" aria-disabled="' . $disable_order_higher . '">'; 1324 echo '<span class="screen-reader-text">' . sprintf( 1325 /* translators: Meta box title. */ 1326 __( 'Order %s panel higher' ), 1327 $widget_title 1328 ) . '</span>'; 1329 echo '<span class="order-higher-indicator" aria-hidden="true"></span>'; 1330 echo '</button>'; 1331 1332 echo '<button type="button" class="handle-order-lower" aria-disabled="' . $disable_order_lower . '">'; 1333 echo '<span class="screen-reader-text">' . sprintf( 1334 /* translators: Meta box title. */ 1335 __( 'Order %s panel lower' ), 1336 $widget_title 1337 ) . '</span>'; 1338 echo '<span class="order-lower-indicator" aria-hidden="true"></span>'; 1339 echo '</button>'; 1340 1309 1341 echo '<button type="button" class="handlediv" aria-expanded="true">'; 1310 1342 echo '<span class="screen-reader-text">' . sprintf( 1311 1343 /* translators: %s: Meta box title. */ … … function do_meta_boxes( $screen, $context, $object ) { 1314 1346 ) . '</span>'; 1315 1347 echo '<span class="toggle-indicator" aria-hidden="true"></span>'; 1316 1348 echo '</button>'; 1349 1350 echo '</div>'; 1317 1351 } 1318 1352 echo '<h2 class="hndle">'; 1319 1353 if ( 'dashboard_php_nag' === $box['id'] ) {