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 || {}) .options(options || {})
.update({ .update({
disabled: function() {
that[
self.options.disabled ? 'addClass' : 'removeClass'
]('OxDisabled');
},
title: function() { title: function() {
that.html(self.options.title); that.html(self.options.title);
}, },

View file

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