Created
May 3, 2012 22:10
-
-
Save georgestephanis/2589884 to your computer and use it in GitHub Desktop.
Add support for menus to WP7 and better support to Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if( 'undefined' != typeof( jQuery ) ){ | |
jQuery(document).ready(function($){ | |
var wpAdminBarChildren = $('#wpadminbar li.menupop'); | |
if( wpAdminBarChildren.length ){ | |
var wpAdminBarMobileHide = function(e){ | |
if( ! $(e.target).closest('#wpadminbar').length ){ | |
wpAdminBarChildren.removeClass('hover'); | |
$(document.body).unbind( 'click', wpAdminBarMobileHide ); | |
} | |
} | |
wpAdminBarChildren.click(function(e){ | |
if( ! $(this).hasClass('hover') ){ | |
e.preventDefault(); | |
wpAdminBarChildren.removeClass('hover'); | |
$(this).addClass('hover'); | |
$(document.body).bind( 'click', wpAdminBarMobileHide ); | |
return; | |
} | |
}); | |
} | |
var wpAdminMenuChildren = $('#adminmenu > li.wp-has-submenu.wp-not-current-submenu'); | |
if( wpAdminMenuChildren.length ){ | |
var wpAdminMenuMobileHide = function(e){ | |
if( ! $(e.target).closest('#adminmenu').length ){ | |
wpAdminMenuChildren.removeClass('hover').children('.wp-submenu.sub-open').removeClass('sub-open'); | |
$(document.body).unbind( 'click', wpAdminMenuMobileHide ); | |
} | |
} | |
wpAdminMenuChildren.click(function(e){ | |
if( ! $(this).hasClass('hover') ){ | |
e.preventDefault(); | |
wpAdminMenuChildren.removeClass('hover').children('.wp-submenu.sub-open').removeClass('sub-open'); | |
$(this).addClass('hover').children('.wp-submenu').addClass('sub-open'); | |
$(document.body).bind( 'click', wpAdminMenuMobileHide ); | |
return; | |
} | |
}); | |
} | |
}); | |
}else{ | |
// fallback? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment