Switch admin menus to flyouts from dropdowns. First pass, see #18382.

git-svn-id: https://develop.svn.wordpress.org/trunk@18621 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Daryl Koopersmith
2011-08-30 01:12:26 +00:00
parent 8e64c7199c
commit 43d6595503
9 changed files with 159 additions and 101 deletions

View File

@@ -5,14 +5,6 @@ adminMenu = {
init : function() {
var menu = $('#adminmenu');
$('.wp-menu-toggle', menu).each( function() {
var t = $(this), sub = t.siblings('.wp-submenu');
if ( sub.length )
t.click(function(){ adminMenu.toggle( sub ); });
else
t.hide();
});
this.favorites();
$('#collapse-menu', menu).click(function(){
@@ -26,63 +18,63 @@ adminMenu = {
return false;
});
if ( $('body').hasClass('folded') )
this.fold();
this.flyout( $('#adminmenu li.wp-has-submenu') );
this.fold( ! $('body').hasClass('folded') );
},
restoreMenuState : function() {
// (perhaps) needed for back-compat
},
toggle : function(el) {
el.slideToggle(150, function() {
var id = el.css('display','').parent().toggleClass( 'wp-menu-open' ).attr('id');
if ( id ) {
$('li.wp-has-submenu', '#adminmenu').each(function(i, e) {
if ( id == e.id ) {
var v = $(e).hasClass('wp-menu-open') ? 'o' : 'c';
setUserSetting( 'm'+i, v );
}
});
}
});
flyout: function( el, unbind ) {
if ( unbind ) {
el.unbind(); // Unbind flyout
return;
}
return false;
el.hoverIntent({
over: function(e){
var m, b, h, o, f;
m = $(this).find('.wp-submenu');
b = $(this).offset().top + m.height() + 1; // Bottom offset of the menu
h = $('#wpwrap').height(); // Height of the entire page
o = 60 + b - h;
f = $(window).height() + $(window).scrollTop() - 15; // The fold
if ( f < (b - o) ) {
o = b - f;
}
if ( o > 1 ) {
m.css({'marginTop':'-'+o+'px'});
} else if ( m.css('marginTop') ) {
m.css({'marginTop':''});
}
m.addClass('sub-open');
},
out: function(){
$(this).find('.wp-submenu').removeClass('sub-open');
},
timeout: 220,
sensitivity: 8,
interval: 100
});
},
fold : function(off) {
if (off) {
$('body').removeClass('folded');
$('#adminmenu li.wp-has-submenu').unbind();
} else {
$('body').addClass('folded');
$('#adminmenu li.wp-has-submenu').hoverIntent({
over: function(e){
var m, b, h, o, f;
m = $(this).find('.wp-submenu');
b = $(this).offset().top + m.height() + 1; // Bottom offset of the menu
h = $('#wpwrap').height(); // Height of the entire page
o = 60 + b - h;
f = $(window).height() + $(window).scrollTop() - 15; // The fold
if ( f < (b - o) ) {
o = b - f;
}
if ( o > 1 ) {
m.css({'marginTop':'-'+o+'px'});
} else if ( m.css('marginTop') ) {
m.css({'marginTop':''});
}
m.addClass('sub-open');
},
out: function(){
$(this).find('.wp-submenu').removeClass('sub-open');
},
timeout: 220,
sensitivity: 8,
interval: 100
});
toggle : function() {
// Removed in 3.3.
// (perhaps) needed for back-compat
},
}
fold : function( off ) {
var current = $('#adminmenu li.wp-has-current-submenu');
$('body').toggleClass( 'folded', ! off );
$('body').toggleClass( 'expanded', off );
this.flyout( current, off );
// Remove any potentially remaining hoverIntent positioning.
if ( off )
current.find('.wp-submenu').css( 'marginTop', '0' );
},
favorites : function() {

File diff suppressed because one or more lines are too long