more menu

This commit is contained in:
Rolux 2010-02-05 23:07:15 +05:30
parent 5473d0502c
commit ed5667de85

View file

@ -1763,6 +1763,7 @@ requires
" Ox" + Ox.toTitleCase(self.options.size) " Ox" + Ox.toTitleCase(self.options.size)
), ),
itemHeight = self.options.size == "small" ? 12 : (self.options.size == "medium" ? 16 : 20), itemHeight = self.options.size == "small" ? 12 : (self.options.size == "medium" ? 16 : 20),
menuHeight,
scrollSpeed = 1, // fixme: should this be self.scrollSpeed? scrollSpeed = 1, // fixme: should this be self.scrollSpeed?
$item; // fixme: used? $item; // fixme: used?
@ -1937,11 +1938,27 @@ requires
}); });
} }
function scrollMenuUp() {
if (that.$scrollbars.up.is(":visible")) {
that.$content.css({
top: "0px"
});
that.$scrollbars.up.hide();
if (that.$scrollbars.down.is(":hidden")) {
that.$scrollbars.down.show();
} else {
that.$container.height(that.$container.height() + itemHeight);
}
}
}
function selectNextItem() { function selectNextItem() {
var offset, var offset,
selected = self.options.selected; selected = self.options.selected;
if (!isLastEnabledItem()) { if (!isLastEnabledItem()) {
if (selected > -1) { if (selected == -1) {
scrollMenuUp();
} else {
that.items[selected].trigger("mouseleave"); that.items[selected].trigger("mouseleave");
} }
do { do {
@ -1971,36 +1988,40 @@ requires
function selectPreviousItem() { function selectPreviousItem() {
var offset, var offset,
selected = self.options.selected; selected = self.options.selected;
if (!isFirstEnabledItem()) { if (selected > - 1) {
that.items[selected].trigger("mouseleave"); if (!isFirstEnabledItem()) {
do { that.items[selected].trigger("mouseleave");
selected--; do {
} while (that.items[selected].options("disabled")) selected--;
that.items[selected].trigger("mouseenter"); } 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) { offset = that.items[selected].offset().top - that.$container.offset().top;
that.$scrollbars.up.hide(); Ox.print(offset);
that.$container.height(that.$container.height() + itemHeight); 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"
});
} }
that.$content.css({
top: ((parseInt(that.$content.css("top")) || 0) - offset) + "px"
});
} }
} }
function selectSubmenu() { function selectSubmenu() {
var submenu = that.submenus[that.items[self.options.selected].options("id")]; if (self.options.selected > -1) {
if (submenu && submenu.hasEnabledItems()) { var submenu = that.submenus[that.items[self.options.selected].options("id")];
that.loseFocus(); if (submenu && submenu.hasEnabledItems()) {
submenu.gainFocus(); that.loseFocus();
submenu.selectFirstItem(); submenu.gainFocus();
submenu.selectFirstItem();
}
} }
} }
@ -2034,13 +2055,7 @@ requires
return false; return false;
} }
}); });
if (that.$scrollbars.up.is(":visible")) { scrollMenuUp();
that.$content.css({
top: "0px"
});
that.$scrollbars.up.hide();
that.$container.height(that.$container.height() + itemHeight);
}
that.hide(); that.hide();
if (self.options.selected > -1) { if (self.options.selected > -1) {
that.items[self.options.selected].trigger("mouseleave"); that.items[self.options.selected].trigger("mouseleave");
@ -2061,6 +2076,7 @@ requires
}; };
that.selectFirstItem = function() { that.selectFirstItem = function() {
Ox.print("selectFirstItem")
selectNextItem(); selectNextItem();
}; };
@ -2072,15 +2088,22 @@ requires
height = self.options.element.outerHeight(), height = self.options.element.outerHeight(),
left = offset.left + self.options.offset.left + (self.options.side == "bottom" ? 0 : width), left = offset.left + self.options.offset.left + (self.options.side == "bottom" ? 0 : width),
top = offset.top + self.options.offset.top + (self.options.side == "bottom" ? height : 0), top = offset.top + self.options.offset.top + (self.options.side == "bottom" ? height : 0),
menuHeight = that.outerHeight(),
maxHeight = Math.floor($window.height() - top - 16); maxHeight = Math.floor($window.height() - top - 16);
Ox.print("height", height, "maxHeight", maxHeight); menuHeight = menuHeight || that.outerHeight();
Ox.print("menuHeight", menuHeight, "maxHeight", maxHeight);
if (self.options.parent) {
if (menuHeight > maxHeight) {
top = Ox.limit(top - menuHeight + maxHeight, self.options.parent.offset().top, top);
maxHeight = Math.floor($window.height() - top - 16);
}
}
that.css({ that.css({
left: left + "px", left: left + "px",
top: top + "px" top: top + "px"
}).show(); }).show();
if (menuHeight > maxHeight) { if (menuHeight > maxHeight) {
that.$container.height(maxHeight - itemHeight); Ox.print(maxHeight - itemHeight);
that.$container.height(maxHeight - itemHeight - 8); // margin
that.$scrollbars.down.show(); that.$scrollbars.down.show();
} }
if (!self.options.parent) { if (!self.options.parent) {