Ticket #13525: 13525.horizontal.scrolling.and.friends.diff
File 13525.horizontal.scrolling.and.friends.diff, 8.8 KB (added by , 15 years ago) |
---|
-
wp-admin/includes/nav-menu.php
38 38 * @param object $args 39 39 */ 40 40 function start_el(&$output, $item, $depth, $args) { 41 global $_wp_nav_menu_max_depth; 42 $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth; 43 41 44 $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; 42 45 43 46 ob_start(); -
wp-admin/js/nav-menu.dev.js
242 242 initSortables : function() { 243 243 var currentDepth = 0, originalDepth, minDepth, maxDepth, 244 244 prev, next, prevBottom, nextThreshold, helperHeight, transport, 245 menuLeft = api.menuList.offset().left; 245 menuEdge = api.menuList.offset().left, 246 body = $('body'), maxChildDepth, 247 menuMaxDepth = initialMenuMaxDepth(); 246 248 249 // Use the right edge if RTL. 250 menuEdge += api.isRTL ? api.menuList.width() : 0; 251 247 252 api.menuList.sortable({ 248 253 handle: '.menu-item-handle', 249 254 placeholder: 'sortable-placeholder', 250 255 start: function(e, ui) { 251 var height, width, parent, children, maxChildDepth,tempHolder;256 var height, width, parent, children, tempHolder; 252 257 253 258 // handle placement for rtl orientation 254 259 if ( api.isRTL ) … … 307 312 if( depthChange != 0 ) { 308 313 ui.item.updateDepthClass( currentDepth ); 309 314 children.shiftDepthClass( depthChange ); 310 api.registerChange();315 updateMenuMaxDepth( depthChange ); 311 316 } 317 // Register a change 318 api.registerChange(); 312 319 // Update the item data. 313 320 ui.item.updateParentMenuItemDBId(); 314 321 … … 321 328 ui.item[0].style.right = 0; 322 329 } 323 330 331 // The width of the tab bar might have changed. Just in case. 332 api.refreshMenuTabs( true ); 324 333 }, 325 334 change: function(e, ui) { 326 335 // Make sure the placeholder is inside the menu. … … 332 341 }, 333 342 sort: function(e, ui) { 334 343 var offset = ui.helper.offset(), 335 depth = api.negateIfRTL * api.pxToDepth( offset.left - menuLeft ); 344 edge = api.isRTL ? offset.left + ui.helper.width() : offset.left, 345 depth = api.negateIfRTL * api.pxToDepth( edge - menuEdge ); 336 346 // Check and correct if depth is not within range. 337 347 // Also, if the dragged element is dragged upwards over 338 348 // an item, shift the placeholder to a child position. … … 348 358 updateSharedVars( ui ); 349 359 $(this).sortable( "refreshPositions" ); 350 360 } 351 },352 update: function(e, ui) {353 api.registerChange();354 361 } 355 362 }); 356 363 … … 378 385 ui.placeholder.updateDepthClass( depth, currentDepth ); 379 386 currentDepth = depth; 380 387 } 388 389 function initialMenuMaxDepth() { 390 if( ! body[0].className ) return 0; 391 var match = body[0].className.match(/menu-max-depth-(\d+)/); 392 return match && match[1] ? parseInt(match[1]) : 0; 393 } 394 395 function updateMenuMaxDepth( depthChange ) { 396 var depth, newDepth = menuMaxDepth; 397 if ( depthChange === 0 ) { 398 return; 399 } else if ( depthChange > 0 ) { 400 depth = maxChildDepth + depthChange; 401 if( depth > menuMaxDepth ) 402 newDepth = depth; 403 } else if ( depthChange < 0 && maxChildDepth == menuMaxDepth ) { 404 while( ! $('.menu-item-depth-' + newDepth, api.menuList).length && newDepth > 0 ) 405 newDepth--; 406 } 407 // Update the depth class. 408 body.removeClass( 'menu-max-depth-' + menuMaxDepth ).addClass( 'menu-max-depth-' + newDepth ); 409 menuMaxDepth = newDepth; 410 } 381 411 }, 382 412 383 413 attachMenuEditListeners : function() { … … 664 694 marginFixed = api.isRTL ? 'margin-left' : 'margin-right', 665 695 msPerPx = 2; 666 696 667 function resetMenuTabs() { 697 /** 698 * Refreshes the menu tabs. 699 * Will show and hide arrows where necessary. 700 * Scrolls to the active tab by default. 701 * 702 * @param savePosition {boolean} Optional. Prevents scrolling so 703 * that the current position is maintained. Default false. 704 **/ 705 api.refreshMenuTabs = function( savePosition ) { 668 706 var fixedWidth = fixed.width(), 669 707 margin = 0, css = {}; 670 708 fixedLeft = fixed.offset().left; 671 709 fixedRight = fixedLeft + fixedWidth; 672 active.makeTabVisible();673 710 711 if( !savePosition ) 712 active.makeTabVisible(); 713 674 714 // Prevent space from building up next to the last tab if there's more to show 675 715 if( tabs.last().isTabVisible() ) { 676 716 margin = fixed.width() - tabsWidth; … … 731 771 fixed.wrap('<div class="nav-tabs-nav"/>').parent().prepend( arrowLeft ).append( arrowRight ); 732 772 733 773 // Set the menu tabs 734 resetMenuTabs();774 api.refreshMenuTabs(); 735 775 // Make sure the tabs reset on resize 736 776 $(window).resize(function() { 737 777 if( resizeTimer ) clearTimeout(resizeTimer); 738 resizeTimer = setTimeout( resetMenuTabs, 200);778 resizeTimer = setTimeout( api.refreshMenuTabs, 200); 739 779 }); 740 780 741 781 // Build arrow functions -
wp-admin/nav-menus.php
430 430 $nav_menus[$key]->truncated_name = $_nav_menu->truncated_name; 431 431 } 432 432 433 // Ensure the user will be able to scroll horizontally 434 // by adding a class for the max menu depth. 435 global $_wp_nav_menu_max_depth; 436 $_wp_nav_menu_max_depth = 0; 437 438 // Calling wp_get_nav_menu_to_edit generates $_wp_nav_menu_max_depth 439 if ( is_nav_menu( $nav_menu_selected_id ) ) 440 $edit_markup = wp_get_nav_menu_to_edit( $nav_menu_selected_id ); 441 442 function wp_nav_menu_max_depth() { 443 global $_wp_nav_menu_max_depth; 444 return "menu-max-depth-$_wp_nav_menu_max_depth"; 445 } 446 447 add_action('admin_body_class','wp_nav_menu_max_depth'); 448 433 449 wp_nav_menu_setup(); 434 450 wp_initial_nav_menu_meta_boxes(); 435 451 … … 564 580 <div id="post-body"> 565 581 <div id="post-body-content"> 566 582 <?php 567 if ( is_nav_menu( $nav_menu_selected_id ) ) : 568 $edit_markup = wp_get_nav_menu_to_edit( $nav_menu_selected_id ); 569 if ( ! is_wp_error( $edit_markup ) ) : 583 if ( isset( $edit_markup ) ) { 584 if ( ! is_wp_error( $edit_markup ) ) 570 585 echo $edit_markup; 571 endif; 572 elseif ( empty( $nav_menu_selected_id ) ) : 586 } else if ( empty( $nav_menu_selected_id ) ) { 573 587 echo '<div class="post-body-plain">'; 574 588 echo '<p>' . __('To create a custom menu, give it a name above and click Create Menu. Then choose items like pages, categories or custom links from the left column to add to this menu.') . '</p>'; 575 589 echo '<p>' . __('After you have added your items, drag and drop to put them in the order you want. You can also click each item to reveal additional configuration options.') . '</p>'; 576 590 echo '<p>' . __('When you have finished building your custom menu, make sure you click the Save Menu button.') . '</p>'; 577 591 echo '</div>'; 578 endif;592 } 579 593 ?> 580 594 </div><!-- /#post-body-content --> 581 595 </div><!-- /#post-body --> -
wp-admin/css/nav-menu-rtl.dev.css
103 103 padding-left: 0; 104 104 } 105 105 .menu-item-edit-active .menu-item-handle { 106 -moz-border-radius: 6px 0 0 6px;106 -moz-border-radius: 6px 6px 0 0; 107 107 -webkit-border-bottom-left-radius: 0; 108 108 -webkit-border-bottom-right-radius: 0; 109 109 -khtml-border-bottom-left-radius: 0; -
wp-admin/css/nav-menu.dev.css
377 377 .menu-item-depth-10 .menu-item-transport { margin-left: -300px; } 378 378 .menu-item-depth-11 .menu-item-transport { margin-left: -330px; } 379 379 380 body.menu-max-depth-0 { min-width: 950px !important; } 381 body.menu-max-depth-1 { min-width: 980px !important; } 382 body.menu-max-depth-2 { min-width: 1010px !important; } 383 body.menu-max-depth-3 { min-width: 1040px !important; } 384 body.menu-max-depth-4 { min-width: 1070px !important; } 385 body.menu-max-depth-5 { min-width: 1100px !important; } 386 body.menu-max-depth-6 { min-width: 1130px !important; } 387 body.menu-max-depth-7 { min-width: 1160px !important; } 388 body.menu-max-depth-8 { min-width: 1190px !important; } 389 body.menu-max-depth-9 { min-width: 1220px !important; } 390 body.menu-max-depth-10 { min-width: 1250px !important; } 391 body.menu-max-depth-11 { min-width: 1280px !important; } 392 380 393 /* Menu item controls */ 381 394 .item-type { text-transform: uppercase; font-size: 11px; color: #999999; padding-right: 10px; } 382 395 .item-controls { font-size: 11px; position: absolute; right: 20px; top: -1px; }