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

Built from https://develop.svn.wordpress.org/trunk@26516


git-svn-id: http://core.svn.wordpress.org/trunk@26409 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2013-12-02 03:19:11 +00:00
parent f1f6cec5e8
commit 830bcf9957
6 changed files with 53 additions and 7 deletions

View File

@ -11823,6 +11823,14 @@ li#wp-admin-bar-menu-toggle {
display: block;
}
.auto-fold #adminmenu a.menu-top:focus + .wp-submenu,
.auto-fold #adminmenu .wp-has-current-submenu a.menu-top:focus + .wp-submenu {
position: relative;
right: -1px;
left: 0;
top: 0;
}
/* Remove submenu headers and adjust sub meu*/
#adminmenu .wp-submenu .wp-submenu-head {
display: none;

File diff suppressed because one or more lines are too long

View File

@ -11823,6 +11823,14 @@ li#wp-admin-bar-menu-toggle {
display: block;
}
.auto-fold #adminmenu a.menu-top:focus + .wp-submenu,
.auto-fold #adminmenu .wp-has-current-submenu a.menu-top:focus + .wp-submenu {
position: relative;
left: -1px;
right: 0;
top: 0;
}
/* Remove submenu headers and adjust sub meu*/
#adminmenu .wp-submenu .wp-submenu-head {
display: none;

File diff suppressed because one or more lines are too long

View File

@ -251,6 +251,11 @@ $(document).ready( function() {
if ( isNaN(top) || top > -5 ) // meaning the submenu is visible
return;
if ( menu.data('wp-responsive') ) {
// The menu is in responsive mode, bail
return;
}
menutop = $(this).offset().top;
wintop = $(window).scrollTop();
maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar
@ -275,6 +280,11 @@ $(document).ready( function() {
$(this).addClass('opensub');
},
out: function(){
if ( menu.data('wp-responsive') ) {
// The menu is in responsive mode, bail
return;
}
$(this).removeClass('opensub').find('.wp-submenu').css('margin-top', '');
},
timeout: 200,
@ -283,8 +293,18 @@ $(document).ready( function() {
});
menu.on('focus.adminmenu', '.wp-submenu a', function(e){
if ( menu.data('wp-responsive') ) {
// The menu is in responsive mode, bail
return;
}
$(e.target).closest('li.menu-top').addClass('opensub');
}).on('blur.adminmenu', '.wp-submenu a', function(e){
if ( menu.data('wp-responsive') ) {
// The menu is in responsive mode, bail
return;
}
$(e.target).closest('li.menu-top').removeClass('opensub');
});
@ -541,18 +561,28 @@ $(document).ready( function() {
// Add menu events
$adminmenu.on( 'touchstart.wp-responsive', 'li.wp-has-submenu > a', function() {
scrollStart = $window.scrollTop();
}).on( 'touchend.wp-responsive', 'li.wp-has-submenu > a', function( event ) {
if ( ! $adminmenu.data('wp-responsive') || $window.scrollTop() !== scrollStart ) {
}).on( 'touchend.wp-responsive click.wp-responsive', 'li.wp-has-submenu > a', function( event ) {
if ( ! $adminmenu.data('wp-responsive') ||
( event.type === 'touchend' && $window.scrollTop() !== scrollStart ) ) {
return;
}
$( this ).find( 'li.wp-has-submenu' ).removeClass( 'selected' );
$( this ).parent( 'li' ).addClass( 'selected' );
$( this ).parent( 'li' ).toggleClass( 'selected' );
event.preventDefault();
});
self.trigger();
$document.on( 'wp-window-resized.wp-responsive', $.proxy( this.trigger, this ) );
// This needs to run later as UI Sortable may be initialized later on $(document).ready()
$window.on( 'load.wp-responsive', function() {
var width = navigator.userAgent.indexOf('AppleWebKit/') > -1 ? $window.width() : window.innerWidth;
if ( width <= 782 ) {
self.disableSortables();
}
});
},
activate: function() {

File diff suppressed because one or more lines are too long