Ticket #13525: nav-menu-rtl-js.13525.diff
File nav-menu-rtl-js.13525.diff, 3.9 KB (added by , 15 years ago) |
---|
-
wp-admin/js/nav-menu.dev.js
22 22 menuList : undefined, // Set in init. 23 23 targetList : undefined, // Set in init. 24 24 menusChanged : false, 25 isRTL: !! ( 'undefined' != typeof isRtl && isRtl ), 25 26 26 27 // Functions that run on init. 27 28 init : function() { … … 52 53 // jQuery extensions 53 54 $.fn.extend({ 54 55 menuItemDepth : function() { 55 var margin = this.eq(0).css('margin-left');56 var margin = api.isRTL ? this.eq(0).css('margin-right') : this.eq(0).css('margin-left'); 56 57 return api.pxToDepth( margin && -1 != margin.indexOf('px') ? margin.slice(0, -2) : 0 ); 57 58 }, 58 59 updateDepthClass : function(current, prev) { … … 244 245 placeholder: 'sortable-placeholder', 245 246 start: function(e, ui) { 246 247 var height, width, parent, children, maxChildDepth, tempHolder; 248 249 // handle placement for rtl orientation 250 if ( api.isRTL ) 251 ui.item[0].style.right = 'auto'; 247 252 248 253 transport = ui.item.children('.menu-item-transport'); 249 254 … … 306 311 // address sortable's incorrectly-calculated top in opera 307 312 ui.item[0].style.top = 0; 308 313 314 // handle drop placement for rtl orientation 315 if ( api.isRTL ) { 316 ui.item[0].style.left = 'auto'; 317 ui.item[0].style.right = 0; 318 } 319 309 320 }, 310 321 change: function(e, ui) { 311 322 // Make sure the placeholder is inside the menu. … … 317 328 }, 318 329 sort: function(e, ui) { 319 330 var offset = ui.helper.offset(), 320 depth = api.pxToDepth( offset.left - menuLeft);331 depth = Math.abs( api.pxToDepth( offset.left - menuLeft ) ); 321 332 // Check and correct if depth is not within range. 322 333 // Also, if the dragged element is dragged upwards over 323 334 // an item, shift the placeholder to a child position. … … 656 667 if( ! t.length ) return; 657 668 left = t.offset().left; 658 669 right = left + t.outerWidth(); 659 if( right > fixedRight ) 660 fluid.animate({ 'margin-left' : "+=" + (fixedRight - right) + 'px' }, 'fast'); 661 else if ( left < fixedLeft ) 662 fluid.animate({ 'margin-left' : "-=" + (left - fixedLeft) + 'px' }, 'fast'); 670 if( right > fixedRight ) { 671 if ( api.isRTL ) 672 fluid.animate({ 'margin-right' : "+=" + (fixedRight - right) + 'px' }, 'fast'); 673 else 674 fluid.animate({ 'margin-left' : "+=" + (fixedRight - right) + 'px' }, 'fast'); 675 } else if ( left < fixedLeft ) { 676 if ( api.isRTL ) 677 fluid.animate({ 'margin-right' : "-=" + (left - fixedLeft) + 'px' }, 'fast'); 678 else 679 fluid.animate({ 'margin-left' : "-=" + (left - fixedLeft) + 'px' }, 'fast'); 680 } 663 681 return t; 664 682 }, 665 683 isTabVisible : function() { … … 681 699 - fluid.css('padding-right').slice(0,-2) ) 682 700 return; 683 701 684 // Set up right margin for overflow, unset padding 685 fluid.css({ 686 'margin-right' : (-1 * tabsWidth) + 'px', 687 'padding' : 0 688 }); 702 if ( api.isRTL ) { 703 fluid.css({ 704 'margin-left' : (-1 * tabsWidth) + 'px', 705 'padding' : 0 706 }); 707 } else { 708 // Set up right margin for overflow, unset padding 709 fluid.css({ 710 'margin-right' : (-1 * tabsWidth) + 'px', 711 'padding' : 0 712 }); 713 } 689 714 690 715 // Build tab navigation 691 716 arrowLeft = $('<div class="nav-tabs-arrow nav-tabs-arrow-left"><a>«</a></div>'); … … 722 747 var last = tabs[that.last](), 723 748 fn = function() { 724 749 if( ! last.isTabVisible() ) 725 fluid.animate({ 'margin-left' : that.operator + '90px' }, 300, "linear", fn); 750 if ( api.isRTL ) 751 fluid.animate({ 'margin-right' : that.operator + '90px' }, 300, "linear", fn); 752 else 753 fluid.animate({ 'margin-left' : that.operator + '90px' }, 300, "linear", fn); 726 754 }; 727 755 fn(); 728 756 }).mouseup(function(){