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,
value: function() {
if (self.options.values.length) {
self.options.title = Ox.getObjectById(
self.options.values, self.options.value
).title;
setTitle();
}
setValue();
setTitle();
self.options.selectable && setSelected();
},
values: function() {
setValue();
setTitle();
},
width: function() {
that.css({width: (self.options.width - 14) + 'px'});
}
@ -105,6 +105,7 @@ Ox.Button = function(options, self) {
self.options.value = self.options.value || false;
}
setValue();
setTitle();
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
() -> <o> toggle button