Ticket #13247: 13247.progress.1.patch
| File 13247.progress.1.patch, 15.4 KB (added by koopersmith, 3 years ago) |
|---|
-
wp-includes/nav-menu-template.php
142 142 $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; 143 143 144 144 $output .= $indent . '<li>'; 145 $output .= '<label class="menu-item-title">'; 146 $output .= '<input type="checkbox" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="'. esc_attr( $item->object_id ) .'" /> '; 147 $output .= $item->title .'</label>'; 145 $output .= '<ul class="potential-menu-item hide-if-no-js"><li><div>'; 146 $output .= '<span class="item-title">' . esc_html( $item->title ) . '</span>'; 147 $output .= '<span class="item-controls">'; 148 $output .= '<span class="item-type">' . esc_html( $item->append ) . '</span>'; 149 $output .= '<span class="item-edit">'; 150 $output .= '<img class="waiting" src="' . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . '" />'; 151 $output .= '</span></span>'; 152 $output .= '</div><ul class="additional-menu-items"></ul><ul class="menu-item-transport"></ul></li></ul>'; 153 $output .= '<label class="menu-item-title hide-if-js">'; 154 $output .= '<input type="checkbox" class="menu-item-checkbox" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="'. esc_attr( $item->object_id ) .'" /> '; 155 $output .= esc_html( $item->title ) .'</label>'; 148 156 149 157 // Menu item hidden fields 150 158 $output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />'; -
wp-admin/includes/nav-menu.php
59 59 } 60 60 ?> 61 61 <li id="menu-item-<?php echo $item_id; ?>" class="menu-item menu-item-depth-<?php echo $depth; ?> menu-item-<?php echo strtolower(esc_attr( $item->append )); ?>"> 62 <dl class=" <?php62 <dl class="menu-item-bar <?php 63 63 if ( isset($_GET['edit-menu-item']) && $item_id == $_GET['edit-menu-item'] ) 64 64 echo 'menu-item-edit-active'; 65 65 else 66 66 echo 'menu-item-edit-inactive'; 67 67 ?>"> 68 <dt >68 <dt class="menu-item-handle"> 69 69 <span class="item-title"><?php echo esc_html( $item->title ); ?></span> 70 70 <span class="item-controls"> 71 71 <span class="item-type"><?php echo esc_html( $item->append ); ?></span> … … 601 601 </div><!-- /.tabs-panel --> 602 602 603 603 604 <div id="<?php echo $post_type_name; ?>-all" class="tabs-panel <?php604 <div id="<?php echo $post_type_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php 605 605 echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); 606 606 ?>"> 607 607 <div class="add-menu-item-pagelinks"> … … 664 664 return; 665 665 } 666 666 // paginate browsing for large numbers of objects 667 $per_page = 50;667 $per_page = 13; 668 668 $pagenum = isset( $_REQUEST[$taxonomy_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1; 669 669 $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0; 670 670 … … 776 776 </ul> 777 777 </div><!-- /.tabs-panel --> 778 778 779 <div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel <?php779 <div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php 780 780 echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); 781 781 ?>"> 782 782 <div class="add-menu-item-pagelinks"> -
wp-admin/js/nav-menu.dev.js
87 87 return Math.floor(px / menuItemDepthPerLevel); 88 88 }, 89 89 90 menuList ;90 menuList, targetList; 91 91 92 92 // jQuery extensions 93 93 $.fn.extend({ … … 153 153 // Functions that run on init. 154 154 init : function() { 155 155 menuList = $('#menu-to-edit'); 156 targetList = menuList; 156 157 157 158 this.attachMenuEditListeners(); 158 159 … … 166 167 this.initToggles(); 167 168 168 169 this.initTabManager(); 170 171 this.initAddMenuItemDraggables(); 169 172 }, 170 173 171 174 initToggles : function() { … … 186 189 187 190 initSortables : function() { 188 191 var currentDepth = 0, originalDepth, minDepth, maxDepth, 189 menuLeft = menuList.offset().left; 192 menuLeft = menuList.offset().left, 193 newItem, transport; 190 194 191 195 menuList.sortable({ 192 handle: ' > dl',196 handle: '.menu-item-handle', 193 197 placeholder: 'sortable-placeholder', 194 198 start: function(e, ui) { 195 var next, height, width, parent, children, maxChildDepth,196 transport = ui.item.children('.menu-item-transport');199 console.log('sort start', e, ui); 200 var next, height, width, parent, children, maxChildDepth; 197 201 198 // Set depths 199 originalDepth = ui.item.menuItemDepth(); 202 transport = ui.item.children('.menu-item-transport'); 203 // Check if the item is in the menu, or new 204 newItem = ( ui.helper.hasClass('new-menu-item') ); 205 206 // Set depths. currentDepth must be set before children are located. 207 originalDepth = ( newItem ) ? 0 : ui.item.menuItemDepth(); 200 208 updateCurrentDepth(ui, originalDepth); 209 210 if( ! newItem ) { 211 // Attach child elements to parent 212 // Skip the placeholder 213 parent = ( ui.item.next()[0] == ui.placeholder[0] ) ? ui.item.next() : ui.item; 214 children = parent.childMenuItems(); 215 transport.append( children ); 216 } 201 217 202 // Attach child elements to parent203 // Skip the placeholder204 parent = ( ui.item.next()[0] == ui.placeholder[0] ) ? ui.item.next() : ui.item;205 children = parent.childMenuItems();206 transport.append( children );207 208 218 // Now that the element is complete, we can update... 209 219 updateDepthRange(ui); 210 220 … … 212 222 height = transport.outerHeight(); 213 223 // If there are children, account for distance between top of children and parent 214 224 height += ( height > 0 ) ? (ui.placeholder.css('margin-top').slice(0, -2) * 1) : 0; 215 height += ui. item.outerHeight();225 height += ui.helper.outerHeight(); 216 226 height -= 2; // Subtract 2 for borders 217 227 ui.placeholder.height(height); 218 228 219 229 // Update the width of the placeholder to match the moving item. 220 230 maxChildDepth = originalDepth; 221 children.each(function(){ 222 var depth = $(this).menuItemDepth(); 223 maxChildDepth = (depth > maxChildDepth) ? depth : maxChildDepth; 224 }); 225 width = ui.item.find('dl dt').outerWidth(); // Get original width 231 if( ! newItem ) { // Children have already been attached to new items 232 children.each(function(){ 233 var depth = $(this).menuItemDepth(); 234 maxChildDepth = (depth > maxChildDepth) ? depth : maxChildDepth; 235 }); 236 } 237 width = ui.helper.find('.menu-item-handle').outerWidth(); // Get original width 226 238 width += depthToPx(maxChildDepth - originalDepth); // Account for children 227 239 width -= 2; // Subtract 2 for borders 228 240 ui.placeholder.width(width); … … 231 243 var children, depthChange = currentDepth - originalDepth; 232 244 233 245 // Return child elements to the list 234 children = ui.item.children('.menu-item-transport').children().insertAfter(ui.item); 235 236 // Update depth classes 237 if( depthChange != 0 ) { 238 ui.item.updateDepthClass( currentDepth ); 239 children.shiftDepthClass( depthChange ); 246 children = transport.children().insertAfter(ui.item); 247 248 if( newItem ) { 249 // Remove the helper item 250 ui.item.remove(); 251 // Update depth classes 252 if( depthChange != 0 ) 253 children.shiftDepthClass( depthChange ); 254 // All new menu items must be updated 255 children.updateParentMenuItemDBId(); 256 } else { 257 // Update depth classes 258 if( depthChange != 0 ) { 259 ui.item.updateDepthClass( currentDepth ); 260 children.shiftDepthClass( depthChange ); 261 } 262 // Update the item data. 263 ui.item.updateParentMenuItemDBId(); 240 264 } 241 // Finally, update the item/menu data. 242 ui.item.updateParentMenuItemDBId(); 265 // Update positions 243 266 recalculateMenuItemPositions(); 244 267 }, 245 268 change: function(e, ui) { … … 251 274 updateDepthRange(ui); 252 275 }, 253 276 sort: function(e, ui) { 254 var depth = pxToDepth(ui. item.offset().left - menuLeft);277 var depth = pxToDepth(ui.helper.offset().left - menuLeft); 255 278 // Check and correct if depth is not within range. 256 279 if ( depth < minDepth ) depth = minDepth; 257 280 else if ( depth > maxDepth ) depth = maxDepth; 258 281 259 282 if( depth != currentDepth ) 260 283 updateCurrentDepth(ui, depth); 284 }, 285 receive: function(e, ui) { 286 transport = ui.sender.children('.menu-item-transport'); 261 287 } 262 288 }); 263 289 … … 282 308 currentDepth = depth; 283 309 } 284 310 }, 311 312 initAddMenuItemDraggables : function() { 313 $.fn.extend({ 314 checkItem : function() { 315 return this.each(function(){ 316 $(this).addClass('selected-menu-item') 317 .next().children('input').attr('checked','checked'); 318 }); 319 }, 320 uncheckItem : function() { 321 return this.each(function(){ 322 $(this).removeClass('selected-menu-item') 323 .next().children('input').removeAttr('checked'); 324 }); 325 }, 326 toggleItem : function() { 327 return this.each(function(){ 328 var t = $(this); 329 if( t.hasClass('selected-menu-item') ) 330 t.uncheckItem(); 331 else 332 t.checkItem(); 333 }); 334 } 335 }); 336 337 var menuItems = $('.potential-menu-item'); 338 menuItems.click(function(e){ 339 $(this).toggleItem(); 340 }).children().draggable({ 341 helper: 'clone', 342 connectToSortable: 'ul#menu-to-edit', 343 distance: 5, 344 zIndex: 100, 345 start: function(e, ui) { 346 var target = $(e.target), 347 item = target.parent(), 348 li = item.parent(), 349 items; 350 351 // Make sure the item we're dragging is selected. 352 item.checkItem(); 353 // Set us to be the ajax target 354 targetList = target.children('.menu-item-transport'); 355 // Get all checked elements and assemble selected items. 356 items = menuItems.filter('.selected-menu-item').children().not( ui.helper ).clone(); 357 ui.helper.children('.additional-menu-items').append( items ); 358 // This class tells the sortables to treat it as a new item. 359 ui.helper.addClass('new-menu-item'); 360 361 // CSS tweaks to remove some unnecessary items 362 ui.helper.children('div').hide(); 363 items.first().css('margin-top', 0); 285 364 365 // Make the items look like menu items 366 items.children('div').addClass('menu-item-handle'); 367 ui.helper.children('div').addClass('hidden-handle'); 368 369 // Trigger the ajax 370 li.parents('.inside').find('.add-to-menu input').trigger('submit'); 371 372 // Lock dimensions 373 ui.helper.width( ui.helper.width() ); 374 ui.helper.height( ui.helper.height() ); 375 }, 376 stop: function(e, ui) { 377 // Reset the targetList and unselect the menu items 378 targetList = menuList; 379 menuItems.filter('.selected-menu-item').uncheckItem(); 380 } 381 }); 382 }, 383 286 384 attachMenuEditListeners : function() { 287 385 var that = this; 288 386 $('#update-nav-menu').bind('click', function(e) { … … 599 697 */ 600 698 eventSubmitMetaForm : function(thisForm, e) { 601 699 var inputs = thisForm.getElementsByTagName('input'), 602 i= inputs.length,603 j,700 len = inputs.length, 701 i, j, 604 702 listItemData, 605 703 listItemDBID, 606 704 listItemDBIDMatch, … … 611 709 that = this; 612 710 params['action'] = ''; 613 711 614 while ( i--) {712 for ( i = 0; i < len; i++ ) { 615 713 if ( // we're submitting a checked item 616 714 inputs[i].name && 617 715 -1 != inputs[i].name.indexOf('menu-item-object-id') && … … 668 766 * @param object req The request arguments. 669 767 */ 670 768 processAddMenuItemResponse : function( menuMarkup, req ) { 671 $(menuMarkup).hideAdvancedMenuItemFields().appendTo( menuList );769 $(menuMarkup).hideAdvancedMenuItemFields().appendTo( targetList ); 672 770 673 771 /* set custom link form back to defaults */ 674 772 $('#custom-menu-item-name').val('').blur(); -
wp-admin/css/wp-admin.dev.css
2004 2004 border-width: 1px; 2005 2005 } 2006 2006 2007 .nav-menus-php .categorydiv div.tabs-panel,2008 2007 .nav-menus-php .customlinkdiv div.tabs-panel, 2009 2008 .nav-menus-php .posttypediv div.tabs-panel, 2010 .nav-menus-php .taxonomydiv div.tabs-panel, 2011 .nav-menus-php #linkcategorydiv div.tabs-panel { 2009 .nav-menus-php .taxonomydiv div.tabs-panel { 2012 2010 height: auto; 2013 max-height: 205px;2011 overflow: visible; 2014 2012 } 2015 2013 2016 2014 div.tabs-panel-active { -
wp-admin/css/nav-menu.dev.css
201 201 width: 210px; 202 202 } 203 203 204 .add-menu-item-view-all { 205 height: 400px; 206 } 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 204 264 /* Button Primary Actions */ 205 265 #menu-container .submit { margin: 0px 0px 10px; padding: 0px; } 206 266 … … 259 319 .menu li { 260 320 margin-bottom: 0; 261 321 } 262 .menu li dl{322 .menu-item-bar { 263 323 clear:both; 264 324 line-height:1.5em; 265 325 position:relative; 266 326 margin-top: 13px; 267 327 } 268 .menu li dl dt{328 .menu-item-handle { 269 329 background: url("../images/gray-grad.png") repeat-x scroll left top #DFDFDF; 270 330 border: 1px solid #E6E6E6; 271 clear:both;272 331 position: relative; 273 332 padding-left: 10px; 274 333 height: auto; … … 277 336 text-shadow: 0 1px 0 #FFFFFF; 278 337 font-weight:bold; 279 338 overflow: hidden; 280 }281 .menu li dl.menu-item-edit-inactive dt {282 339 border-radius: 6px; 283 340 -webkit-border-radius: 6px; 284 341 -moz-border-radius: 6px; 285 342 -khtml-border-radius: 6px; 286 343 } 287 .menu li dl.menu-item-edit-active dt{344 .menu-item-edit-active .menu-item-handle { 288 345 -moz-border-radius: 6px 6px 0 0; 289 346 -webkit-border-top-right-radius: 6px; 290 347 -webkit-border-top-left-radius: 6px; … … 293 350 border-top-right-radius: 6px; 294 351 border-top-left-radius: 6px; 295 352 } 296 .js .menu li dl dt{353 .js .menu-item-handle { 297 354 cursor: move; 298 355 } 299 .menu li dl dt:hover { 300 } 301 .menu li.deleting dl dt { 356 .menu li.deleting .menu-item-handle { 302 357 background-color:#faa; 303 358 } 304 359 305 .menu li.item-title {360 .menu-item-handle .item-title { 306 361 padding: 7px 0; 307 362 line-height: 20px; 308 363 display:block;
