more menu

This commit is contained in:
Rolux 2010-02-05 23:07:15 +05:30
parent 18c222efb4
commit 8cb264bb57

View File

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