Ticket #23119: 23119-A.diff
| File 23119-A.diff, 9.1 KB (added by lessbloat, 5 months ago) |
|---|
-
wp-admin/js/nav-menu.js
47 47 48 48 this.initToggles(); 49 49 50 this.init TabManager();50 this.initSelectMenuDropdown(); 51 51 }, 52 52 53 53 jQueryExtensions : function() { … … 222 222 } 223 223 }); 224 224 }, 225 226 initSelectMenuDropdown : function () { 227 var menuSelector = $('.menu-selector select'); 228 229 menuSelector.on('change', function () { 230 var url = $(this).val(); 231 232 if (url && '--' !== url) { 233 $('.menu-selector .spinner').show(); 234 window.location = url; 235 } 236 }); 237 }, 225 238 226 239 initToggles : function() { 227 240 // init postboxes … … 688 701 }); 689 702 }, 690 703 691 initTabManager : function() {692 var fixed = $('.nav-tabs-wrapper'),693 fluid = fixed.children('.nav-tabs'),694 active = fluid.children('.nav-tab-active'),695 tabs = fluid.children('.nav-tab'),696 tabsWidth = 0,697 fixedRight, fixedLeft,698 arrowLeft, arrowRight, resizeTimer, css = {},699 marginFluid = api.isRTL ? 'margin-right' : 'margin-left',700 marginFixed = api.isRTL ? 'margin-left' : 'margin-right',701 msPerPx = 2;702 703 /**704 * Refreshes the menu tabs.705 * Will show and hide arrows where necessary.706 * Scrolls to the active tab by default.707 *708 * @param savePosition {boolean} Optional. Prevents scrolling so709 * that the current position is maintained. Default false.710 **/711 api.refreshMenuTabs = function( savePosition ) {712 var fixedWidth = fixed.width(),713 margin = 0, css = {};714 fixedLeft = fixed.offset().left;715 fixedRight = fixedLeft + fixedWidth;716 717 if( !savePosition )718 active.makeTabVisible();719 720 // Prevent space from building up next to the last tab if there's more to show721 if( tabs.last().isTabVisible() ) {722 margin = fixed.width() - tabsWidth;723 margin = margin > 0 ? 0 : margin;724 css[marginFluid] = margin + 'px';725 fluid.animate( css, 100, "linear" );726 }727 728 // Show the arrows only when necessary729 if( fixedWidth > tabsWidth )730 arrowLeft.add( arrowRight ).hide();731 else732 arrowLeft.add( arrowRight ).show();733 }734 735 $.fn.extend({736 makeTabVisible : function() {737 var t = this.eq(0), left, right, css = {}, shift = 0;738 739 if( ! t.length ) return this;740 741 left = t.offset().left;742 right = left + t.outerWidth();743 744 if( right > fixedRight )745 shift = fixedRight - right;746 else if ( left < fixedLeft )747 shift = fixedLeft - left;748 749 if( ! shift ) return this;750 751 css[marginFluid] = "+=" + api.negateIfRTL * shift + 'px';752 fluid.animate( css, Math.abs( shift ) * msPerPx, "linear" );753 return this;754 },755 isTabVisible : function() {756 var t = this.eq(0),757 left = t.offset().left,758 right = left + t.outerWidth();759 return ( right <= fixedRight && left >= fixedLeft ) ? true : false;760 }761 });762 763 // Find the width of all tabs764 tabs.each(function(){765 tabsWidth += $(this).outerWidth(true);766 });767 768 // Set up fixed margin for overflow, unset padding769 css['padding'] = 0;770 css[marginFixed] = (-1 * tabsWidth) + 'px';771 fluid.css( css );772 773 // Build tab navigation774 arrowLeft = $('<div class="nav-tabs-arrow nav-tabs-arrow-left"><a>«</a></div>');775 arrowRight = $('<div class="nav-tabs-arrow nav-tabs-arrow-right"><a>»</a></div>');776 // Attach to the document777 fixed.wrap('<div class="nav-tabs-nav"/>').parent().prepend( arrowLeft ).append( arrowRight );778 779 // Set the menu tabs780 api.refreshMenuTabs();781 // Make sure the tabs reset on resize782 $(window).resize(function() {783 if( resizeTimer ) clearTimeout(resizeTimer);784 resizeTimer = setTimeout( api.refreshMenuTabs, 200);785 });786 787 // Build arrow functions788 $.each([{789 arrow : arrowLeft,790 next : "next",791 last : "first",792 operator : "+="793 },{794 arrow : arrowRight,795 next : "prev",796 last : "last",797 operator : "-="798 }], function(){799 var that = this;800 this.arrow.mousedown(function(){801 var marginFluidVal = Math.abs( parseInt( fluid.css(marginFluid) ) ),802 shift = marginFluidVal,803 css = {};804 805 if( "-=" == that.operator )806 shift = Math.abs( tabsWidth - fixed.width() ) - marginFluidVal;807 808 if( ! shift ) return;809 810 css[marginFluid] = that.operator + shift + 'px';811 fluid.animate( css, shift * msPerPx, "linear" );812 }).mouseup(function(){813 var tab, next;814 fluid.stop(true);815 tab = tabs[that.last]();816 while( (next = tab[that.next]()) && next.length && ! next.isTabVisible() ) {817 tab = next;818 }819 tab.makeTabVisible();820 });821 });822 },823 824 704 eventOnClickEditLink : function(clickedEl) { 825 705 var settings, item, 826 706 matchedSection = /#(.*)$/.exec(clickedEl.href); -
wp-admin/nav-menus.php
460 460 ?> 461 461 <div class="wrap"> 462 462 <?php screen_icon(); ?> 463 <h2><?php esc_html_e('Menus'); ?></h2> 463 <h2><?php esc_html_e('Menus'); ?> <a href="<?php 464 echo esc_url(add_query_arg( 465 array( 466 'action' => 'edit', 467 'menu' => 0, 468 ), 469 admin_url( 'nav-menus.php' ) 470 )); 471 ?>" class="add-new-h2">Add New</a></h2> 464 472 <?php 465 473 foreach( $messages as $message ) : 466 474 echo $message . "\n"; 467 475 endforeach; 468 476 ?> 477 <?php if ( 1 < count( $nav_menus ) ) : ?> 478 <p class="menu-selector"> 479 <span class="spinner"></span> 480 <select> 481 <option value="" selected="selected">Select a menu</option> 482 <?php 483 foreach( (array) $nav_menus as $_nav_menu ) : ?> 484 <option value="<?php 485 echo esc_url(add_query_arg( 486 array( 487 'action' => 'edit', 488 'menu' => $_nav_menu->term_id, 489 ), 490 admin_url( 'nav-menus.php' ) 491 )); 492 ?>"> 493 <?php echo esc_html( $_nav_menu->truncated_name ); ?> 494 </option> 495 <?php endforeach; ?> 496 </select> 497 </p> 498 <?php endif; ?> 469 499 <div id="nav-menus-frame"> 470 500 <div id="menu-settings-column" class="metabox-holder<?php if ( !$nav_menu_selected_id ) { echo ' metabox-holder-disabled'; } ?>"> 471 501 … … 494 524 <?php submit_button( __( 'Select' ), 'secondary', 'select_menu', false ); ?> 495 525 </form> 496 526 </div> 497 <div class="nav-tabs-wrapper">498 <div class="nav-tabs">499 <?php500 foreach( (array) $nav_menus as $_nav_menu ) :501 if ( $nav_menu_selected_id == $_nav_menu->term_id ) : ?><span class="nav-tab nav-tab-active">502 <?php echo esc_html( $_nav_menu->truncated_name ); ?>503 </span><?php else : ?><a href="<?php504 echo esc_url(add_query_arg(505 array(506 'action' => 'edit',507 'menu' => $_nav_menu->term_id,508 ),509 admin_url( 'nav-menus.php' )510 ));511 ?>" class="nav-tab hide-if-no-js">512 <?php echo esc_html( $_nav_menu->truncated_name ); ?>513 </a><?php endif;514 endforeach;515 if ( 0 == $nav_menu_selected_id ) : ?><span class="nav-tab menu-add-new nav-tab-active">516 <?php printf( '<abbr title="%s">+</abbr>', esc_html__( 'Add menu' ) ); ?>517 </span><?php else : ?><a href="<?php518 echo esc_url(add_query_arg(519 array(520 'action' => 'edit',521 'menu' => 0,522 ),523 admin_url( 'nav-menus.php' )524 ));525 ?>" class="nav-tab menu-add-new">526 <?php printf( '<abbr title="%s">+</abbr>', esc_html__( 'Add menu' ) ); ?>527 </a><?php endif; ?>528 </div>529 </div>530 527 <div class="menu-edit"> 531 528 <form id="update-nav-menu" action="<?php echo admin_url( 'nav-menus.php' ); ?>" method="post" enctype="multipart/form-data"> 532 529 <div id="nav-menu-header"> -
wp-admin/css/wp-admin.css
6760 6760 margin-left: -300px; 6761 6761 clear: both; 6762 6762 float: left; 6763 padding-top: 24px;6763 padding-top: 0; 6764 6764 } 6765 6765 6766 6766 .no-js #wpbody-content #menu-settings-column { … … 6785 6785 position: relative; 6786 6786 } 6787 6787 6788 .menu-selector { 6789 float: right; 6790 } 6791 6792 .menu-selector .spinner { 6793 float: left; 6794 } 6795 6788 6796 /* Menu Container */ 6789 6797 #menu-management-liquid { 6790 6798 float: left; 6791 6799 min-width: 100%; 6800 margin-top: 3px; 6792 6801 } 6793 6802 6794 6803 #menu-management { … … 6835 6844 font-weight:bold; 6836 6845 } 6837 6846 6838 /* Menu Tabs */6839 6840 #menu-management .nav-tabs-nav {6841 margin: 0 20px;6842 }6843 6844 #menu-management .nav-tabs-arrow {6845 width: 10px;6846 padding: 0 5px 4px;6847 cursor: pointer;6848 position: absolute;6849 top: 0;6850 line-height: 22px;6851 font-size: 18px;6852 text-shadow: 0 1px 0 #fff;6853 }6854 6855 #menu-management .nav-tabs-arrow-left {6856 left: 0;6857 }6858 6859 #menu-management .nav-tabs-arrow-right {6860 right: 0;6861 text-align: right;6862 }6863 6864 #menu-management .nav-tabs-wrapper {6865 width: 100%;6866 height: 28px;6867 margin-bottom: -1px;6868 overflow: hidden;6869 }6870 6871 #menu-management .nav-tabs {6872 padding-left: 20px;6873 padding-right: 10px;6874 }6875 6876 .js #menu-management .nav-tabs {6877 float: left;6878 margin-left: 0px;6879 margin-right: -400px;6880 }6881 6882 #menu-management .nav-tab {6883 margin-bottom: 0;6884 font-size: 14px;6885 }6886 6887 6847 #select-nav-menu-container { 6888 6848 text-align: right; 6889 6849 padding: 0 10px 3px 10px;
