fix a bug where menus would modify item objects passed by reference

This commit is contained in:
rlx 2011-09-19 06:33:52 +00:00
parent 17d842c64c
commit 636f772820
3 changed files with 6 additions and 11 deletions

View file

@ -139,12 +139,9 @@ Ox.Filter = function(options, self) {
width: 120 width: 120
}), }),
Ox.Select({ Ox.Select({
/*
items: self.options.sortKeys.map(function(sortKey) { items: self.options.sortKeys.map(function(sortKey) {
return {id: sortKey.id, title: sortKey.title[0]}; // fixme: title should not have become an array return {id: sortKey.id, title: sortKey.title};
}), }),
*/
items: self.options.sortKeys,
width: 128 width: 128
}), }),
Ox.FormElementGroup({ Ox.FormElementGroup({
@ -188,7 +185,7 @@ Ox.Filter = function(options, self) {
] ]
}); });
/* ///*
// fixme: sortKeys have been altered, probably by some select // fixme: sortKeys have been altered, probably by some select
Ox.print('s.o.sK', self.options.sortKeys) Ox.print('s.o.sK', self.options.sortKeys)
self.$sort = Ox.InputGroup({ self.$sort = Ox.InputGroup({
@ -205,7 +202,7 @@ Ox.Filter = function(options, self) {
{title: 'By default, sort by', width: 112} {title: 'By default, sort by', width: 112}
] ]
}); });
*/ //*/
self.$save = Ox.InputGroup({ self.$save = Ox.InputGroup({
inputs: [ inputs: [
@ -222,7 +219,7 @@ Ox.Filter = function(options, self) {
] ]
}); });
self.$items = [self.$operator, self.$limit, self.$view/*, self.$sort*/, self.$save]; self.$items = [self.$operator, self.$limit, self.$view, self.$sort, self.$save];
self.$form = Ox.Form({ self.$form = Ox.Form({
items: self.$items items: self.$items

View file

@ -2,6 +2,7 @@
/*@ /*@
Ox.OptionGroup <f> OptionGroup Ox.OptionGroup <f> OptionGroup
Helper object, used by ButtonGroup, CheckboxGroup, Select and Menu
(items, min, max, property) -> <f> OptionGroup (items, min, max, property) -> <f> OptionGroup
items <a> array of items items <a> array of items
min <n> minimum number of selected items min <n> minimum number of selected items
@ -11,9 +12,6 @@ Ox.OptionGroup <f> OptionGroup
Ox.OptionGroup = function(items, min, max, property) { Ox.OptionGroup = function(items, min, max, property) {
/*
to be used by ButtonGroup, CheckboxGroup, Select and Menu
*/
var length = items.length; var length = items.length;
property = property || 'checked'; property = property || 'checked';
max = max == -1 ? length : max; max = max == -1 ? length : max;

View file

@ -36,7 +36,7 @@ Ox.MenuItem = function(options, self) {
position: 0, position: 0,
title: [], title: [],
}) })
.options(Ox.extend(options, { .options(Ox.extend(Ox.clone(options), {
keyboard: parseKeyboard(options.keyboard || self.defaults.keyboard), keyboard: parseKeyboard(options.keyboard || self.defaults.keyboard),
title: Ox.toArray(options.title || self.defaults.title) title: Ox.toArray(options.title || self.defaults.title)
})) }))