allow for separators in option groups
This commit is contained in:
parent
76a79c669d
commit
08919e7b37
2 changed files with 4 additions and 7 deletions
|
@ -21,16 +21,11 @@ Ox.OptionGroup = function(items, min, max, property) {
|
||||||
function getLastBefore(pos) {
|
function getLastBefore(pos) {
|
||||||
// returns the position of the last checked item before position pos
|
// returns the position of the last checked item before position pos
|
||||||
var last = -1;
|
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?
|
// fixme: why is length not == items.length here?
|
||||||
Ox.forEach(Ox.merge(
|
Ox.forEach(Ox.merge(
|
||||||
pos > 0 ? Ox.range(pos - 1, -1, -1) : [],
|
pos > 0 ? Ox.range(pos - 1, -1, -1) : [],
|
||||||
pos < items.length - 1 ? Ox.range(items.length - 1, pos, -1) : []
|
pos < items.length - 1 ? Ox.range(items.length - 1, pos, -1) : []
|
||||||
), function(v) {
|
), function(v) {
|
||||||
//Ox.Log('Form', pos, v)
|
|
||||||
if (items[v][property]) {
|
if (items[v][property]) {
|
||||||
last = v;
|
last = v;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -183,13 +183,15 @@ Ox.Menu = function(options, self) {
|
||||||
self.optionGroups = {};
|
self.optionGroups = {};
|
||||||
items.forEach(function(item, i) {
|
items.forEach(function(item, i) {
|
||||||
if (item.group) {
|
if (item.group) {
|
||||||
items[i] = item.items.map(function(v, i) {
|
items[i] = item.items.map(function(v) {
|
||||||
return Ox.extend(v, {
|
return Ox.extend(v, {
|
||||||
group: item.group
|
group: item.group
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
self.optionGroups[item.group] = new Ox.OptionGroup(
|
self.optionGroups[item.group] = new Ox.OptionGroup(
|
||||||
items[i],
|
items[i].filter(function(v) {
|
||||||
|
return 'id' in v;
|
||||||
|
}),
|
||||||
'min' in item ? item.min : 1,
|
'min' in item ? item.min : 1,
|
||||||
'max' in item ? item.max : 1
|
'max' in item ? item.max : 1
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue