allow for separators in option groups

This commit is contained in:
rlx 2011-11-10 09:54:33 +00:00
parent 76a79c669d
commit 08919e7b37
2 changed files with 4 additions and 7 deletions

View file

@ -21,16 +21,11 @@ Ox.OptionGroup = function(items, min, max, property) {
function getLastBefore(pos) {
// returns the position of the last checked item before position pos
var last = -1;
/*Ox.Log('Form', items, items.length, length, Ox.merge(
pos > 0 ? Ox.range(pos - 1, -1, -1) : [],
pos < items.length - 1 ? Ox.range(items.length - 1, pos, -1) : []
))*/
// fixme: why is length not == items.length here?
Ox.forEach(Ox.merge(
pos > 0 ? Ox.range(pos - 1, -1, -1) : [],
pos < items.length - 1 ? Ox.range(items.length - 1, pos, -1) : []
), function(v) {
//Ox.Log('Form', pos, v)
if (items[v][property]) {
last = v;
return false;

View file

@ -183,13 +183,15 @@ Ox.Menu = function(options, self) {
self.optionGroups = {};
items.forEach(function(item, i) {
if (item.group) {
items[i] = item.items.map(function(v, i) {
items[i] = item.items.map(function(v) {
return Ox.extend(v, {
group: item.group
});
});
self.optionGroups[item.group] = new Ox.OptionGroup(
items[i],
items[i].filter(function(v) {
return 'id' in v;
}),
'min' in item ? item.min : 1,
'max' in item ? item.max : 1
);