Ox.Range: add 'disabled' option; Ox.Label: support changing 'disabled' option

This commit is contained in:
rlx 2018-01-21 09:23:18 +01:00
parent c4a91f46ed
commit b158450d17
2 changed files with 17 additions and 0 deletions

View file

@ -21,6 +21,11 @@ Ox.Label = function(options, self) {
})
.options(options || {})
.update({
disabled: function() {
that[
self.options.disabled ? 'addClass' : 'removeClass'
]('OxDisabled');
},
title: function() {
that.html(self.options.title);
},

View file

@ -36,6 +36,7 @@ Ox.Range = function(options, self) {
arrowSymbols: ['left', 'right'],
arrowTooltips: ['', ''],
changeOnDrag: false,
disabled: false,
max: 100,
min: 0,
orientation: 'horizontal',
@ -53,6 +54,7 @@ Ox.Range = function(options, self) {
})
.options(options || {})
.update({
disabled: setDisabled,
max: setSizes,
min: setSizes,
step: setSizes,
@ -86,6 +88,7 @@ Ox.Range = function(options, self) {
self.$arrows = [];
Ox.range(0, 2).forEach(function(i) {
self.$arrows[i] = Ox.Button({
disabled: self.options.disabled,
overlap: i == 0 ? 'right' : 'left',
title: self.options.arrowSymbols[i],
tooltip: self.options.arrowTooltips[i],
@ -149,6 +152,7 @@ Ox.Range = function(options, self) {
}
self.$thumb = Ox.Button({
disabled: self.options.disabled,
id: self.options.id + 'Thumb',
width: self.thumbSize
})
@ -218,6 +222,14 @@ Ox.Range = function(options, self) {
return self.hasValues ? self.options.values[value] : value;
}
function setDisabled() {
if (self.options.arrows) {
self.$arrows[0].options({disabled: self.options.disabled});
self.$arrows[1].options({disabled: self.options.disabled});
}
self.$thumb.options({disabled: self.options.disabled});
}
function setSizes() {
self.values = (
self.options.max - self.options.min + self.options.step