some menu scrolling

This commit is contained in:
Rolux 2010-02-05 20:29:24 +05:30
parent 4d24f9baa3
commit d3fc6207de
2 changed files with 51 additions and 30 deletions

View file

@ -458,6 +458,7 @@ requires
$(function() {
$document.keydown(keydown);
$document.keypress(keydown);
});
function keydown(event) {
var key,
@ -1757,9 +1758,9 @@ requires
"OxMenu Ox" + Ox.toTitleCase(self.options.side) +
" Ox" + Ox.toTitleCase(self.options.size)
),
itemHeight = options.size == "small" ? 12 : (options.size == "medium" ? 16 : 20),
scrollSpeed = 1,
$item;
itemHeight = self.options.size == "small" ? 12 : (self.options.size == "medium" ? 16 : 20),
scrollSpeed = 1, // fixme: should this be self.scrollSpeed?
$item; // fixme: used?
// construct
that.items = [];
@ -1835,7 +1836,8 @@ requires
}
function constructScrollbar(direction) {
var interval;
var interval,
speed = direction == "up" ? -1 : 1;
return $("<div/>", {
"class": "OxScrollbar Ox" + Ox.toTitleCase(direction),
html: oxui.symbols["triangle_" + direction],
@ -1858,9 +1860,9 @@ requires
});
}
}
scrollMenu(direction == "up" ? -1 : 1);
scrollMenu(speed);
interval = setInterval(function() {
scrollMenu(direction == "up" ? -1 : 1);
scrollMenu(speed);
}, 100);
},
mouseleave: function() {
@ -1918,22 +1920,17 @@ requires
if (top <= min) {
top = min;
that.$scrollbars.down.hide().trigger("mouseleave");
that.$container.css({
height: (containerHeight + itemHeight) + "px"
});
that.$items[that.$items.length - 1].trigger("mouseover");
that.$container.height(containerHeight + itemHeight);
that.items[that.items.length - 1].trigger("mouseover");
} else if (top >= max - itemHeight) {
top = max;
that.$scrollbars.up.hide().trigger("mouseleave");
that.$container.css({
height: (containerHeight + itemHeight) + "px"
});
that.$items[0].trigger("mouseover");
that.$container.height(containerHeight + itemHeight);
that.items[0].trigger("mouseover");
}
that.$content.css({
top: top + "px"
});
}
function selectNextItem() {
@ -1994,12 +1991,19 @@ requires
that.hideMenu = function() {
Ox.print("hideMenu")
$.each(that.submenus, function(i, submenu) {
if (!submenu.is(":hidden")) {
if (submenu.is(":visible")) {
submenu.hideMenu();
return false;
}
});
// fixme: scroll menu back up!
if (that.$scrollbars.up.is(":visible")) {
that.$content.css({
top: "0px"
});
that.$scrollbars.up.hide();
that.$container.height(that.$container.height() + itemHeight);
}
that.hide();
if (self.options.selected > -1) {
that.items[self.options.selected].trigger("mouseleave");
@ -2028,12 +2032,14 @@ 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),
maxHeight = Math.floor(($window.height() - top - 12) / itemHeight) * itemHeight;
menuHeight = that.outerHeight(),
maxHeight = Math.floor($window.height() - top - 16);
Ox.print("height", height, "maxHeight", maxHeight);
that.css({
left: left + "px",
top: top + "px"
}).show();
if (height > maxHeight) {
if (menuHeight > maxHeight) {
that.$container.height(maxHeight - itemHeight);
that.$scrollbars.down.show();
}
@ -2133,11 +2139,12 @@ requires
);
function click() {
if (!that.hasClass("OxDisabled") && !self.options.items.length) {
if (!that.hasClass("OxDisabled")) {
self.options.menu.hideMenu();
if (self.options.menu.options("parent")) {
self.options.menu.options("parent").hideMenu();
}
if (!self.options.items.length) {
if (self.options.checked !== null && (!self.options.group || !self.options.checked)) {
that.options({
checked: !self.options.checked
@ -2152,6 +2159,7 @@ requires
});
}
}
}
function isSelected() {
return self.options.position == self.options.menu.options("selected");

View file

@ -97,7 +97,20 @@ $(function() {
title: "Twelfth"
},
],
title: "Even More",
title: "Even More"
},
{},
{
id: "foo",
title: "Foo"
},
{
id: "bar",
title: "Bar"
},
{
id: "baz",
title: "Baz"
}
]
});