Nav menu RTL js fixes. Props filosofo. see #13525

git-svn-id: https://develop.svn.wordpress.org/trunk@15039 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2010-05-28 16:57:47 +00:00
parent e0e67c56ba
commit 44621fee7d
2 changed files with 14 additions and 3 deletions

View File

@ -22,6 +22,7 @@ var wpNavMenu;
menuList : undefined, // Set in init.
targetList : undefined, // Set in init.
menusChanged : false,
isRTL: !! ( 'undefined' != typeof isRtl && isRtl ),
// Functions that run on init.
init : function() {
@ -52,7 +53,7 @@ var wpNavMenu;
// jQuery extensions
$.fn.extend({
menuItemDepth : function() {
var margin = this.eq(0).css('margin-left');
var margin = api.isRTL ? this.eq(0).css('margin-right') : this.eq(0).css('margin-left');
return api.pxToDepth( margin && -1 != margin.indexOf('px') ? margin.slice(0, -2) : 0 );
},
updateDepthClass : function(current, prev) {
@ -244,6 +245,10 @@ var wpNavMenu;
placeholder: 'sortable-placeholder',
start: function(e, ui) {
var height, width, parent, children, maxChildDepth, tempHolder;
// handle placement for rtl orientation
if ( api.isRTL )
ui.item[0].style.right = 'auto';
transport = ui.item.children('.menu-item-transport');
@ -306,6 +311,12 @@ var wpNavMenu;
// address sortable's incorrectly-calculated top in opera
ui.item[0].style.top = 0;
// handle drop placement for rtl orientation
if ( api.isRTL ) {
ui.item[0].style.left = 'auto';
ui.item[0].style.right = 0;
}
},
change: function(e, ui) {
// Make sure the placeholder is inside the menu.
@ -317,7 +328,7 @@ var wpNavMenu;
},
sort: function(e, ui) {
var offset = ui.helper.offset(),
depth = api.pxToDepth( offset.left - menuLeft );
depth = ( api.isRTL ? -1 : 1 ) * api.pxToDepth( offset.left - menuLeft );
// Check and correct if depth is not within range.
// Also, if the dragged element is dragged upwards over
// an item, shift the placeholder to a child position.

File diff suppressed because one or more lines are too long