Ticket #13247: 13247.revert.to.checkboxes.1.patch
| File 13247.revert.to.checkboxes.1.patch, 11.0 KB (added by , 16 years ago) |
|---|
-
wp-includes/nav-menu-template.php
146 146 $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; 147 147 148 148 $output .= $indent . '<li>'; 149 $output .= '<ul class="potential-menu-item hide-if-no-js"><li><div>'; 150 $output .= '<span class="item-title">' . esc_html( $item->title ) . '</span>'; 151 $output .= '<span class="item-controls">'; 152 $output .= '<span class="item-type">' . esc_html( $item->append ) . '</span>'; 153 $output .= '<span class="item-edit">'; 154 $output .= '<img class="waiting" src="' . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . '" />'; 155 $output .= '</span></span>'; 156 $output .= '</div><ul class="additional-menu-items"></ul><ul class="menu-item-transport"></ul></li></ul>'; 157 $output .= '<label class="menu-item-title hide-if-js">'; 149 $output .= '<label class="menu-item-title">'; 158 150 $output .= '<input type="checkbox" class="menu-item-checkbox" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="'. esc_attr( $item->object_id ) .'" /> '; 159 151 $output .= esc_html( $item->title ) .'</label>'; 160 152 -
wp-admin/includes/nav-menu.php
665 665 return; 666 666 } 667 667 // paginate browsing for large numbers of objects 668 $per_page = 13;668 $per_page = 50; 669 669 $pagenum = isset( $_REQUEST[$taxonomy_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1; 670 670 $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0; 671 671 -
wp-admin/js/nav-menu.dev.js
114 114 115 115 this.initTabManager(); 116 116 117 this.initAddMenuItemDraggables();118 119 117 this.checkForEmptyMenu(); 120 118 }, 121 119 … … 177 175 }); 178 176 }); 179 177 }, 180 selectItem : function() {181 return this.each(function(){182 $(this).addClass('selected-menu-item')183 .next().children('input').attr('checked','checked');184 });185 },186 deselectItem : function() {187 return this.each(function(){188 $(this).removeClass('selected-menu-item')189 .next().children('input').removeAttr('checked');190 });191 },192 toggleItem : function() {193 return this.each(function(){194 var t = $(this);195 if( t.hasClass('selected-menu-item') )196 t.deselectItem();197 else198 t.selectItem();199 });200 },201 178 /** 202 179 * Adds selected menu items to the menu. 203 180 * … … 227 204 // Add the items 228 205 api.addItemToMenu(menuItems, processMethod, function(){ 229 206 // Deselect the items and hide the ajax spinner 230 checkboxes. parent().prev().deselectItem();207 checkboxes.removeAttr('checked'); 231 208 t.find('img.waiting').hide(); 232 209 }); 233 210 }); … … 263 240 var height, width, parent, children, maxChildDepth; 264 241 265 242 transport = ui.item.children('.menu-item-transport'); 266 // Check if the item is in the menu, or new267 newItem = ( ui.helper.hasClass('new-menu-item') );268 243 269 244 // Set depths. currentDepth must be set before children are located. 270 245 originalDepth = ( newItem ) ? 0 : ui.item.menuItemDepth(); 271 246 updateCurrentDepth(ui, originalDepth); 272 247 273 if( ! newItem ) { 274 // Attach child elements to parent 275 // Skip the placeholder 276 parent = ( ui.item.next()[0] == ui.placeholder[0] ) ? ui.item.next() : ui.item; 277 children = parent.childMenuItems(); 278 transport.append( children ); 279 } 248 // Attach child elements to parent 249 // Skip the placeholder 250 parent = ( ui.item.next()[0] == ui.placeholder[0] ) ? ui.item.next() : ui.item; 251 children = parent.childMenuItems(); 252 transport.append( children ); 280 253 281 254 // Now that the element is complete, we can update... 282 255 updateDepthRange(ui); … … 291 264 292 265 // Update the width of the placeholder to match the moving item. 293 266 maxChildDepth = originalDepth; 294 if( ! newItem ) { // Children have already been attached to new items 295 children.each(function(){ 296 var depth = $(this).menuItemDepth(); 297 maxChildDepth = (depth > maxChildDepth) ? depth : maxChildDepth; 298 }); 299 } 267 children.each(function(){ 268 var depth = $(this).menuItemDepth(); 269 maxChildDepth = (depth > maxChildDepth) ? depth : maxChildDepth; 270 }); 300 271 width = ui.helper.find('.menu-item-handle').outerWidth(); // Get original width 301 272 width += depthToPx(maxChildDepth - originalDepth); // Account for children 302 273 width -= 2; // Subtract 2 for borders … … 308 279 // Return child elements to the list 309 280 children = transport.children().insertAfter(ui.item); 310 281 311 if( newItem ) { 312 // Remove the helper item 313 ui.item.remove(); 314 // Update depth classes 315 if( depthChange != 0 ) 316 children.shiftDepthClass( depthChange ); 317 // All new menu items must be updated 318 children.updateParentMenuItemDBId(); 319 } else { 320 // Update depth classes 321 if( depthChange != 0 ) { 322 ui.item.updateDepthClass( currentDepth ); 323 children.shiftDepthClass( depthChange ); 324 } 325 // Update the item data. 326 ui.item.updateParentMenuItemDBId(); 282 // Update depth classes 283 if( depthChange != 0 ) { 284 ui.item.updateDepthClass( currentDepth ); 285 children.shiftDepthClass( depthChange ); 327 286 } 287 // Update the item data. 288 ui.item.updateParentMenuItemDBId(); 328 289 // Update positions 329 290 recalculateMenuItemPositions(); 330 291 }, … … 345 306 if( depth != currentDepth ) 346 307 updateCurrentDepth(ui, depth); 347 308 }, 348 receive: function(e, ui) {349 transport = ui.sender.children('.menu-item-transport');350 }351 309 }); 352 310 353 311 function updateDepthRange(ui) { … … 371 329 currentDepth = depth; 372 330 } 373 331 }, 374 375 initAddMenuItemDraggables : function() {376 var menuItems = $('.potential-menu-item');377 menuItems.click(function(e){378 $(this).toggleItem();379 }).children().draggable({380 helper: 'clone',381 connectToSortable: 'ul#menu-to-edit',382 distance: 5,383 zIndex: 100,384 start: function(e, ui) {385 var target = $(e.target),386 item = target.parent(),387 li = item.parent(),388 items;389 390 // Make sure the item we're dragging is selected.391 item.selectItem();392 // Set us to be the ajax target393 targetList = target.children('.menu-item-transport');394 // Get all checked elements and assemble selected items.395 items = li.parents('.tabs-panel').find('.selected-menu-item').children().not( ui.helper ).clone();396 ui.helper.children('.additional-menu-items').append( items );397 // This class tells the sortables to treat it as a new item.398 ui.helper.addClass('new-menu-item');399 400 // CSS tweaks to remove some unnecessary items401 ui.helper.children('div').hide();402 items.first().css('margin-top', 0);403 332 404 // Make the items look like menu items405 items.children('div').addClass('menu-item-handle');406 ui.helper.children('div').addClass('hidden-handle');407 408 // Trigger the ajax409 li.parents('.inside').find('.add-to-menu input').click();410 411 // Lock dimensions412 ui.helper.width( ui.helper.width() );413 ui.helper.height( ui.helper.height() );414 },415 stop: function(e, ui) {416 // Reset the targetList and unselect the menu items417 targetList = menuList;418 $(e.target).parents('.tabs-panel').find('.selected-menu-item').deselectItem();419 }420 });421 },422 423 333 attachMenuEditListeners : function() { 424 334 var that = this; 425 335 $('#update-nav-menu').bind('click', function(e) { … … 598 508 599 509 attachTabsPanelListeners : function() { 600 510 $('#menu-settings-column').bind('click', function(e) { 601 var selectAreaMatch, activePanel, panelIdMatch, wrapper, inputs, i ;511 var selectAreaMatch, activePanel, panelIdMatch, wrapper, inputs, i, items; 602 512 603 513 if ( e.target && e.target.className && -1 != e.target.className.indexOf('nav-tab-link') ) { 604 514 panelIdMatch = /#(.*)$/.exec(e.target.href); … … 630 540 631 541 return false; 632 542 } else if ( e.target && e.target.className && -1 != e.target.className.indexOf('select-all') ) { 633 selectAreaMatch = /#(.*)$/.exec(e.target.href) , items;543 selectAreaMatch = /#(.*)$/.exec(e.target.href); 634 544 if ( selectAreaMatch && selectAreaMatch[1] ) { 635 items = $('#' + selectAreaMatch[1] + ' .tabs-panel-active . potential-menu-item');636 if( items.length === items.filter(' .selected-menu-item').length )637 items. deselectItem();545 items = $('#' + selectAreaMatch[1] + ' .tabs-panel-active .menu-item-title input'); 546 if( items.length === items.filter(':checked').length ) 547 items.removeAttr('checked'); 638 548 else 639 items. selectItem();549 items.attr('checked', 'checked'); 640 550 return false; 641 551 } 642 552 } -
wp-admin/css/wp-admin.dev.css
2008 2008 .nav-menus-php .posttypediv div.tabs-panel, 2009 2009 .nav-menus-php .taxonomydiv div.tabs-panel { 2010 2010 height: auto; 2011 overflow: visible;2011 max-height: 205px; 2012 2012 } 2013 2013 2014 2014 div.tabs-panel-active { -
wp-admin/css/nav-menu.dev.css
205 205 height: 400px; 206 206 } 207 207 208 #side-sortables .potential-menu-item {209 margin-left: 0;210 position: relative;211 margin: 6px 0;212 }213 #side-sortables .potential-menu-item ul {214 margin-left: 0;215 216 }217 #side-sortables .potential-menu-item li {218 cursor: move;219 padding: 1px 6px;220 border-radius: 4px;221 -webkit-border-radius: 4px;222 -moz-border-radius: 4px;223 -khtml-border-radius: 4px;224 }225 .potential-menu-item li {226 background: #eee;227 border: 1px solid #dfdfdf;228 color: #646464;229 }230 .potential-menu-item li:hover {231 color: #222;232 border-color: #ccc;233 background: #f9f9f9;234 }235 .selected-menu-item li {236 background: #FFFFE0;237 border-color: #E6DB55;238 }239 .selected-menu-item li:hover {240 background: #ffffbe;241 border-color: #e2d537;242 }243 .potential-menu-item .item-controls,244 .potential-menu-item .menu-item-transport {245 display: none;246 }247 .potential-menu-item .ui-draggable-dragging div,248 .potential-menu-item .menu-item-handle .item-controls {249 display: block;250 }251 #side-sortables .new-menu-item,252 #side-sortables .new-menu-item li,253 #side-sortables .additional-menu-items li {254 background: transparent;255 border: 0;256 }257 #side-sortables .additional-menu-items li {258 margin-top: 13px;259 }260 .item-edit img.waiting {261 display: block;262 }263 264 208 /* Button Primary Actions */ 265 209 #menu-container .submit { margin: 0px 0px 10px; padding: 0px; } 266 210