48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
var Clay = require('pebble-clay');
|
|
var clayConfig = require('./config');
|
|
var clay = new Clay(clayConfig);
|
|
|
|
|
|
// Patch `select` to return integers instead of strings
|
|
|
|
function disable() {
|
|
if (this.$manipulatorTarget.get('disabled')) { return this; }
|
|
this.$element.set('+disabled');
|
|
this.$manipulatorTarget.set('disabled', true);
|
|
return this.trigger('disabled');
|
|
}
|
|
|
|
function enable() {
|
|
if (!this.$manipulatorTarget.get('disabled')) { return this; }
|
|
this.$element.set('-disabled');
|
|
this.$manipulatorTarget.set('disabled', false);
|
|
return this.trigger('enabled');
|
|
}
|
|
|
|
function hide() {
|
|
if (this.$element[0].classList.contains('hide')) { return this; }
|
|
this.$element.set('+hide');
|
|
return this.trigger('hide');
|
|
}
|
|
|
|
function show() {
|
|
if (!this.$element[0].classList.contains('hide')) { return this; }
|
|
this.$element.set('-hide');
|
|
return this.trigger('show');
|
|
}
|
|
|
|
clay.components.select.manipulator = {
|
|
get: function() {
|
|
return parseInt(this.$manipulatorTarget.get('value'));
|
|
},
|
|
set: function(value) {
|
|
if (this.get() === value) { return this; }
|
|
this.$manipulatorTarget.set('value', value);
|
|
return this.trigger('change');
|
|
},
|
|
disable: disable,
|
|
enable: enable,
|
|
hide: hide,
|
|
show: show
|
|
};
|
|
|