Make WordPress Core

Changeset 26516


Ignore:
Timestamp:
12/02/2013 03:18:40 AM (13 years ago)
Author:
azaozz
Message:

Make the responsive menu usable with a mouse, fix non-folded and :focus styles, toggle the submenus on touchend/click. Fixes #26086.

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/wp-admin.css

    r26507 r26516  
    1182411824        }
    1182511825
     11826        .auto-fold #adminmenu a.menu-top:focus + .wp-submenu,
     11827        .auto-fold #adminmenu .wp-has-current-submenu a.menu-top:focus + .wp-submenu {
     11828                position: relative;
     11829                left: -1px;
     11830                right: 0;
     11831                top: 0;
     11832        }
     11833
    1182611834        /* Remove submenu headers and adjust sub meu*/
    1182711835        #adminmenu .wp-submenu .wp-submenu-head {
  • trunk/src/wp-admin/js/common.js

    r26421 r26516  
    252252                                return;
    253253
     254                        if ( menu.data('wp-responsive') ) {
     255                                // The menu is in responsive mode, bail
     256                                return;
     257                        }
     258
    254259                        menutop = $(this).offset().top;
    255260                        wintop = $(window).scrollTop();
     
    276281                },
    277282                out: function(){
     283                        if ( menu.data('wp-responsive') ) {
     284                                // The menu is in responsive mode, bail
     285                                return;
     286                        }
     287
    278288                        $(this).removeClass('opensub').find('.wp-submenu').css('margin-top', '');
    279289                },
     
    284294
    285295        menu.on('focus.adminmenu', '.wp-submenu a', function(e){
     296                if ( menu.data('wp-responsive') ) {
     297                        // The menu is in responsive mode, bail
     298                        return;
     299                }
     300
    286301                $(e.target).closest('li.menu-top').addClass('opensub');
    287302        }).on('blur.adminmenu', '.wp-submenu a', function(e){
     303                if ( menu.data('wp-responsive') ) {
     304                        // The menu is in responsive mode, bail
     305                        return;
     306                }
     307
    288308                $(e.target).closest('li.menu-top').removeClass('opensub');
    289309        });
     
    542562                        $adminmenu.on( 'touchstart.wp-responsive', 'li.wp-has-submenu > a', function() {
    543563                                scrollStart = $window.scrollTop();
    544                         }).on( 'touchend.wp-responsive', 'li.wp-has-submenu > a', function( event ) {
    545                                 if ( ! $adminmenu.data('wp-responsive') || $window.scrollTop() !== scrollStart ) {
     564                        }).on( 'touchend.wp-responsive click.wp-responsive', 'li.wp-has-submenu > a', function( event ) {
     565                                if ( ! $adminmenu.data('wp-responsive') ||
     566                                        ( event.type === 'touchend' && $window.scrollTop() !== scrollStart ) ) {
     567
    546568                                        return;
    547569                                }
    548570
    549                                 $( this ).find( 'li.wp-has-submenu' ).removeClass( 'selected' );
    550                                 $( this ).parent( 'li' ).addClass( 'selected' );
     571                                $( this ).parent( 'li' ).toggleClass( 'selected' );
    551572                                event.preventDefault();
    552573                        });
     
    554575                        self.trigger();
    555576                        $document.on( 'wp-window-resized.wp-responsive', $.proxy( this.trigger, this ) );
     577
     578                        // This needs to run later as UI Sortable may be initialized later on $(document).ready()
     579                        $window.on( 'load.wp-responsive', function() {
     580                                var width = navigator.userAgent.indexOf('AppleWebKit/') > -1 ? $window.width() : window.innerWidth;
     581
     582                                if ( width <= 782 ) {
     583                                        self.disableSortables();
     584                                }
     585                        });
    556586                },
    557587
Note: See TracChangeset for help on using the changeset viewer.