Make WordPress Core

Ticket #13525: nav-menu-rtl-js.13525.3.diff

File nav-menu-rtl-js.13525.3.diff, 1.9 KB (added by filosofo, 15 years ago)
  • wp-admin/js/nav-menu.dev.js

     
    2222                menuList : undefined,   // Set in init.
    2323                targetList : undefined, // Set in init.
    2424                menusChanged : false,
     25                isRTL: !! ( 'undefined' != typeof isRtl && isRtl ),
    2526
    2627                // Functions that run on init.
    2728                init : function() {
     
    5253                        // jQuery extensions
    5354                        $.fn.extend({
    5455                                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');
    5657                                        return api.pxToDepth( margin && -1 != margin.indexOf('px') ? margin.slice(0, -2) : 0 );
    5758                                },
    5859                                updateDepthClass : function(current, prev) {
     
    244245                                placeholder: 'sortable-placeholder',
    245246                                start: function(e, ui) {
    246247                                        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';
    247252
    248253                                        transport = ui.item.children('.menu-item-transport');
    249254
     
    306311                                        // address sortable's incorrectly-calculated top in opera
    307312                                        ui.item[0].style.top = 0;
    308313
     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
    309320                                },
    310321                                change: function(e, ui) {
    311322                                        // Make sure the placeholder is inside the menu.
     
    317328                                },
    318329                                sort: function(e, ui) {
    319330                                        var offset = ui.helper.offset(),
    320                                                 depth = api.pxToDepth( offset.left - menuLeft );
     331                                                depth = ( api.isRTL ? -1 : 1 ) * api.pxToDepth( offset.left - menuLeft );
    321332                                        // Check and correct if depth is not within range.
    322333                                        // Also, if the dragged element is dragged upwards over
    323334                                        // an item, shift the placeholder to a child position.