Ticket #13525: 13525.tabs.diff
File 13525.tabs.diff, 5.4 KB (added by , 15 years ago) |
---|
-
wp-admin/js/nav-menu.dev.js
23 23 targetList : undefined, // Set in init. 24 24 menusChanged : false, 25 25 isRTL: !! ( 'undefined' != typeof isRtl && isRtl ), 26 negateIfRTL: ( 'undefined' != typeof isRtl && isRtl ) ? -1 : 1, 26 27 27 28 // Functions that run on init. 28 29 init : function() { … … 331 332 }, 332 333 sort: function(e, ui) { 333 334 var offset = ui.helper.offset(), 334 depth = ( api.isRTL ? -1 : 1 )* api.pxToDepth( offset.left - menuLeft );335 depth = api.negateIfRTL * api.pxToDepth( offset.left - menuLeft ); 335 336 // Check and correct if depth is not within range. 336 337 // Also, if the dragged element is dragged upwards over 337 338 // an item, shift the placeholder to a child position. … … 658 659 tabs = fluid.children('.nav-tab'), 659 660 tabsWidth = 0, 660 661 fixedRight, fixedLeft, 661 arrowLeft, arrowRight, 662 resizing = false; 662 arrowLeft, arrowRight, resizeTimer, css = {}, 663 marginFluid = api.isRTL ? 'margin-right' : 'margin-left', 664 marginFixed = api.isRTL ? 'margin-left' : 'margin-right', 665 msPerPx = 2; 663 666 664 667 function resetMenuTabs() { 668 var fixedWidth = fixed.width(), 669 margin = 0, css = {}; 665 670 fixedLeft = fixed.offset().left; 666 fixedRight = fixedLeft + fixed .width();671 fixedRight = fixedLeft + fixedWidth; 667 672 active.makeTabVisible(); 673 674 // Prevent space from building up next to the last tab if there's more to show 675 if( tabs.last().isTabVisible() ) { 676 margin = fixed.width() - tabsWidth; 677 margin = margin > 0 ? 0 : margin; 678 css[marginFluid] = margin + 'px'; 679 fluid.animate( css, 100, "linear" ); 680 } 681 682 // Show the arrows only when necessary 683 if( fixedWidth > tabsWidth ) 684 arrowLeft.add( arrowRight ).hide(); 685 else 686 arrowLeft.add( arrowRight ).show(); 668 687 } 669 688 670 689 $.fn.extend({ 671 690 makeTabVisible : function() { 672 var t = this.eq(0), left, right; 673 if( ! t.length ) return; 691 var t = this.eq(0), left, right, css = {}, shift = 0; 692 693 if( ! t.length ) return this; 694 674 695 left = t.offset().left; 675 696 right = left + t.outerWidth(); 697 676 698 if( right > fixedRight ) 677 fluid.animate({ 'margin-left' : "+=" + (fixedRight - right) + 'px' }, 'fast');699 shift = fixedRight - right; 678 700 else if ( left < fixedLeft ) 679 fluid.animate({ 'margin-left' : "-=" + (left - fixedLeft) + 'px' }, 'fast'); 680 return t; 701 shift = fixedLeft - left; 702 703 if( ! shift ) return this; 704 705 css[marginFluid] = "+=" + api.negateIfRTL * shift + 'px'; 706 fluid.animate( css, Math.abs( shift ) * msPerPx, "linear" ); 707 return this; 681 708 }, 682 709 isTabVisible : function() { 683 710 var t = this.eq(0), … … 692 719 tabsWidth += $(this).outerWidth(true); 693 720 }); 694 721 695 // Check if we need the tab manager 696 if( tabsWidth <= fixed.width() 697 - fluid.css('padding-left').slice(0,-2) 698 - fluid.css('padding-right').slice(0,-2) ) 699 return; 722 // Set up fixed margin for overflow, unset padding 723 css['padding'] = 0; 724 css[marginFixed] = (-1 * tabsWidth) + 'px'; 725 fluid.css( css ); 700 726 701 // Set up right margin for overflow, unset padding702 fluid.css({703 'margin-right' : (-1 * tabsWidth) + 'px',704 'padding' : 0705 });706 707 727 // Build tab navigation 708 728 arrowLeft = $('<div class="nav-tabs-arrow nav-tabs-arrow-left"><a>«</a></div>'); 709 729 arrowRight = $('<div class="nav-tabs-arrow nav-tabs-arrow-right"><a>»</a></div>'); … … 714 734 resetMenuTabs(); 715 735 // Make sure the tabs reset on resize 716 736 $(window).resize(function() { 717 if( resizing ) return; 718 resizing = true; 719 setTimeout(function(){ 720 resetMenuTabs(); 721 resizing = false; 722 }, 1000); 737 if( resizeTimer ) clearTimeout(resizeTimer); 738 resizeTimer = setTimeout( resetMenuTabs, 200); 723 739 }); 724 740 725 741 // Build arrow functions … … 736 752 }], function(){ 737 753 var that = this; 738 754 this.arrow.mousedown(function(){ 739 var last = tabs[that.last](), 740 fn = function() { 741 if( ! last.isTabVisible() ) 742 fluid.animate({ 'margin-left' : that.operator + '90px' }, 300, "linear", fn); 743 }; 744 fn(); 755 var marginFluidVal = Math.abs( parseInt( fluid.css(marginFluid) ) ), 756 shift = marginFluidVal, 757 css = {}; 758 759 if( "-=" == that.operator ) 760 shift = Math.abs( tabsWidth - fixed.width() ) - marginFluidVal; 761 762 if( ! shift ) return; 763 764 css[marginFluid] = that.operator + shift + 'px'; 765 fluid.animate( css, shift * msPerPx, "linear" ); 745 766 }).mouseup(function(){ 746 767 var tab, next; 747 768 fluid.stop(true); -
wp-admin/css/nav-menu-rtl.dev.css
40 40 } 41 41 42 42 #menu-management .nav-tabs { 43 padding-right: 30px;43 padding-right: 20px; 44 44 padding-left: 10px; 45 45 } 46 46 .js #menu-management .nav-tabs { -
wp-admin/css/nav-menu.dev.css
140 140 } 141 141 142 142 #menu-management .nav-tabs { 143 padding-left: 30px;143 padding-left: 20px; 144 144 padding-right: 10px; 145 145 } 146 146 .js #menu-management .nav-tabs {