scroll menu on keyboard navigation

This commit is contained in:
Rolux 2010-02-05 20:56:23 +05:30
parent 42fdba68b8
commit f21dc4404c

View File

@ -1934,7 +1934,8 @@ requires
}
function selectNextItem() {
var selected = self.options.selected;
var offset,
selected = self.options.selected;
if (!isLastEnabledItem()) {
if (selected > -1) {
that.items[selected].trigger("mouseleave");
@ -1943,11 +1944,29 @@ requires
selected++;
} while (that.items[selected].options("disabled"))
that.items[selected].trigger("mouseenter");
offset = that.items[selected].offset().top + itemHeight -
that.$container.offset().top - that.$container.height();
if (offset > 0) {
if (that.$scrollbars.up.is(":hidden")) {
that.$scrollbars.up.show();
that.$container.height(that.$container.height() - itemHeight);
offset += itemHeight;
}
if (selected == that.items.length - 1) {
that.$scrollbars.down.hide();
that.$container.height(that.$container.height() + itemHeight);
} else {
that.$content.css({
top: ((parseInt(that.$content.css("top")) || 0) - offset) + "px"
});
}
}
}
}
function selectPreviousItem() {
var selected = self.options.selected;
var offset,
selected = self.options.selected;
if (!isFirstEnabledItem()) {
that.items[selected].trigger("mouseleave");
do {
@ -1955,6 +1974,21 @@ requires
} while (that.items[selected].options("disabled"))
that.items[selected].trigger("mouseenter");
}
offset = that.items[selected].offset().top - that.$container.offset().top;
Ox.print(offset);
if (offset < 0) {
if (that.$scrollbars.down.is(":hidden")) {
that.$scrollbars.down.show();
that.$container.height(that.$container.height() - itemHeight);
}
if (selected == 0) {
that.$scrollbars.up.hide();
that.$container.height(that.$container.height() + itemHeight);
}
that.$content.css({
top: ((parseInt(that.$content.css("top")) || 0) - offset) + "px"
});
}
}
function selectSubmenu() {
@ -1996,7 +2030,6 @@ requires
return false;
}
});
// fixme: scroll menu back up!
if (that.$scrollbars.up.is(":visible")) {
that.$content.css({
top: "0px"