Skip to content
Permalink
Browse files

Menu: Further refactoring of next/previousPage

  • Loading branch information...
jzaefferer committed Oct 28, 2010
1 parent c55977d commit 8959057ecced5287d94d1edd219ec00cf4117ef8
Showing with 8 additions and 16 deletions.
  1. +8 −16 ui/jquery.ui.menu.js
@@ -192,18 +192,14 @@ $.widget("ui.menu", {
height = this.element.height(),
result;
this.active.nextAll( ".ui-menu-item" ).each( function() {
var close = $( this ).offset().top - base - height;
if (close >= 0) {
result = $( this );
return false;
}
result = $( this );
return $( this ).offset().top - base - height < 0;
});

this.activate( event, result || this.element.children( ".ui-menu-item" ).last() );
this.activate( event, result );
} else {
this.activate( event, this.element.children( ".ui-menu-item" )
// TODO use .first()/.last()
.filter( !this.active || this.last() ? ":first" : ":last" ) );
[ !this.active || this.last() ? "first" : "last" ]() );
}
},

@@ -219,18 +215,14 @@ $.widget("ui.menu", {
height = this.element.height(),
result;
this.active.prevAll( ".ui-menu-item" ).each( function() {
var close = $(this).offset().top - base + height;
if (close <= 0) {
result = $( this );
return false;
}
result = $( this );
return $(this).offset().top - base + height > 0;
});

this.activate( event, result || this.element.children( ".ui-menu-item" ).first() );
this.activate( event, result );
} else {
this.activate( event, this.element.children( ".ui-menu-item" )
// TODO use .first()/.last()
.filter( !this.active || this.first() ? ":last" : ":first" ) );
[ !this.active || this.first() ? ":last" : ":first" ]() );
}
},

0 comments on commit 8959057

Please sign in to comment.
You can’t perform that action at this time.