Ox.Checkbox: add indeterminate option
This commit is contained in:
parent
0327947864
commit
368ae04fe0
2 changed files with 16 additions and 1 deletions
|
@ -190,6 +190,10 @@ Ox.load({Geo: {}, UI: {}, Unicode: {}}, function() {
|
||||||
description: 'Checkbox with title',
|
description: 'Checkbox with title',
|
||||||
title: 'Check me',
|
title: 'Check me',
|
||||||
width: 128
|
width: 128
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: 'Checkbox, indeterminate',
|
||||||
|
indeterminate: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,6 +5,7 @@ Ox.Checkbox <f> Checkbox Element
|
||||||
options <o> Options object
|
options <o> Options object
|
||||||
disabled <b> if true, checkbox is disabled
|
disabled <b> if true, checkbox is disabled
|
||||||
group <b> if true, checkbox is part of a group
|
group <b> if true, checkbox is part of a group
|
||||||
|
indeterminate <b> if true, checkbox appears as indeterminate
|
||||||
label <s> Label (on the left side)
|
label <s> Label (on the left side)
|
||||||
labelWidth <n|64> Label width
|
labelWidth <n|64> Label width
|
||||||
title <s> Title (on the right side)
|
title <s> Title (on the right side)
|
||||||
|
@ -22,6 +23,7 @@ Ox.Checkbox = function(options, self) {
|
||||||
.defaults({
|
.defaults({
|
||||||
disabled: false,
|
disabled: false,
|
||||||
group: false,
|
group: false,
|
||||||
|
indeterminate: false,
|
||||||
label: '',
|
label: '',
|
||||||
labelWidth: 64,
|
labelWidth: 64,
|
||||||
overlap: 'none',
|
overlap: 'none',
|
||||||
|
@ -38,6 +40,13 @@ Ox.Checkbox = function(options, self) {
|
||||||
self.$button.options({disabled: disabled});
|
self.$button.options({disabled: disabled});
|
||||||
self.$title && self.$title.options({disabled: disabled});
|
self.$title && self.$title.options({disabled: disabled});
|
||||||
},
|
},
|
||||||
|
indeterminate: function() {
|
||||||
|
if (self.options.indeterminate) {
|
||||||
|
self.$button.options({value: 'minus'});
|
||||||
|
} else {
|
||||||
|
self.$button.toggle();
|
||||||
|
}
|
||||||
|
},
|
||||||
label: function() {
|
label: function() {
|
||||||
self.$label.options({title: self.options.label});
|
self.$label.options({title: self.options.label});
|
||||||
},
|
},
|
||||||
|
@ -96,7 +105,8 @@ Ox.Checkbox = function(options, self) {
|
||||||
id: self.options.id + 'Button',
|
id: self.options.id + 'Button',
|
||||||
style: self.options.style != 'rounded' ? self.options.style : '',
|
style: self.options.style != 'rounded' ? self.options.style : '',
|
||||||
type: 'image',
|
type: 'image',
|
||||||
value: self.options.value ? 'check' : 'none',
|
value: self.options.indeterminate ? 'minus'
|
||||||
|
: self.options.value ? 'check' : 'none',
|
||||||
values: ['none', 'check']
|
values: ['none', 'check']
|
||||||
})
|
})
|
||||||
.addClass('OxCheckbox')
|
.addClass('OxCheckbox')
|
||||||
|
@ -107,6 +117,7 @@ Ox.Checkbox = function(options, self) {
|
||||||
|
|
||||||
function clickButton() {
|
function clickButton() {
|
||||||
self.options.value = !self.options.value;
|
self.options.value = !self.options.value;
|
||||||
|
self.options.indeterminate = false;
|
||||||
that.triggerEvent('change', {
|
that.triggerEvent('change', {
|
||||||
value: self.options.value
|
value: self.options.value
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue