mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Menu: Further refactoring of next/previousPage
This commit is contained in:
parent
c55977d2ef
commit
8959057ecc
20
ui/jquery.ui.menu.js
vendored
20
ui/jquery.ui.menu.js
vendored
@ -192,18 +192,14 @@ $.widget("ui.menu", {
|
|||||||
height = this.element.height(),
|
height = this.element.height(),
|
||||||
result;
|
result;
|
||||||
this.active.nextAll( ".ui-menu-item" ).each( function() {
|
this.active.nextAll( ".ui-menu-item" ).each( function() {
|
||||||
var close = $( this ).offset().top - base - height;
|
|
||||||
if (close >= 0) {
|
|
||||||
result = $( this );
|
result = $( this );
|
||||||
return false;
|
return $( this ).offset().top - base - height < 0;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.activate( event, result || this.element.children( ".ui-menu-item" ).last() );
|
this.activate( event, result );
|
||||||
} else {
|
} else {
|
||||||
this.activate( event, this.element.children( ".ui-menu-item" )
|
this.activate( event, this.element.children( ".ui-menu-item" )
|
||||||
// TODO use .first()/.last()
|
[ !this.active || this.last() ? "first" : "last" ]() );
|
||||||
.filter( !this.active || this.last() ? ":first" : ":last" ) );
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -219,18 +215,14 @@ $.widget("ui.menu", {
|
|||||||
height = this.element.height(),
|
height = this.element.height(),
|
||||||
result;
|
result;
|
||||||
this.active.prevAll( ".ui-menu-item" ).each( function() {
|
this.active.prevAll( ".ui-menu-item" ).each( function() {
|
||||||
var close = $(this).offset().top - base + height;
|
|
||||||
if (close <= 0) {
|
|
||||||
result = $( this );
|
result = $( this );
|
||||||
return false;
|
return $(this).offset().top - base + height > 0;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.activate( event, result || this.element.children( ".ui-menu-item" ).first() );
|
this.activate( event, result );
|
||||||
} else {
|
} else {
|
||||||
this.activate( event, this.element.children( ".ui-menu-item" )
|
this.activate( event, this.element.children( ".ui-menu-item" )
|
||||||
// TODO use .first()/.last()
|
[ !this.active || this.first() ? ":last" : ":first" ]() );
|
||||||
.filter( !this.active || this.first() ? ":last" : ":first" ) );
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user