indeterminate checkboxes...

This commit is contained in:
rlx 2016-02-10 13:15:15 +05:30
parent 5ea5a5ee2b
commit ff30b32188

View file

@ -57,14 +57,14 @@ Ox.Button = function(options, self) {
}, },
title: setTitle, title: setTitle,
value: function() { value: function() {
if (self.options.values.length) { setValue();
self.options.title = Ox.getObjectById( setTitle();
self.options.values, self.options.value
).title;
setTitle();
}
self.options.selectable && setSelected(); self.options.selectable && setSelected();
}, },
values: function() {
setValue();
setTitle();
},
width: function() { width: function() {
that.css({width: (self.options.width - 14) + 'px'}); that.css({width: (self.options.width - 14) + 'px'});
} }
@ -105,6 +105,7 @@ Ox.Button = function(options, self) {
self.options.value = self.options.value || false; self.options.value = self.options.value || false;
} }
setValue();
setTitle(); setTitle();
if (Ox.isArray(options.tooltip)) { if (Ox.isArray(options.tooltip)) {
@ -171,6 +172,25 @@ Ox.Button = function(options, self) {
} }
} }
function setValue() {
if (self.options.values.length) {
self.options.values = self.options.values.map(function(value) {
return {
id: value.id || value,
title: value.title || value
};
});
self.value = Ox.getIndexById(self.options.values, self.options.value);
if (self.value == -1) {
self.value = 0;
self.options.value = self.options.values[0].id;
}
self.options.title = self.options.values[self.value].title;
} else if (self.options.selectable) {
self.options.value = self.options.value || false;
}
}
/*@ /*@
toggle <f> toggle toggle <f> toggle
() -> <o> toggle button () -> <o> toggle button