salix/front/core/components/input-range/index.js

80 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-08-23 12:10:54 +00:00
import ngModule from '../../module';
import Input from '../../lib/input';
import './style.scss';
2018-08-29 07:45:37 +00:00
export default class inputRange extends Input {
constructor($element, $scope) {
2018-08-23 12:10:54 +00:00
super($element, $scope);
2018-08-29 07:45:37 +00:00
this.mdlElement = this.element.querySelector('.mdl-slider');
componentHandler.upgradeElement(this.mdlElement);
this.mdlElement.addEventListener('change', () => {
this._value = this.input.value;
this.$.$applyAsync();
if (this._value && this.onChange)
2019-01-15 11:06:19 +00:00
this.emit('change', {value: this._value});
2018-08-29 07:45:37 +00:00
});
}
get value() {
return this._value;
}
set value(value) {
this._value = value;
this.mdlElement.MaterialSlider.change(value);
}
get max() {
return this.input.max;
}
set max(value) {
this.input.max = value;
}
get min() {
return this.input.min;
}
set min(value) {
this.input.min = value;
}
get step() {
return this.input.step;
}
set step(value) {
this.input.step = value;
}
get() {
return this._model;
}
set model(value) {
this._model = value;
2018-08-23 12:10:54 +00:00
}
2018-09-05 11:56:07 +00:00
set disabled(value) {
this.input.disabled = value;
}
2018-08-23 12:10:54 +00:00
}
2018-08-29 07:45:37 +00:00
inputRange.$inject = ['$element', '$scope'];
2018-08-23 12:10:54 +00:00
ngModule.component('vnInputRange', {
template: require('./index.html'),
2018-08-29 07:45:37 +00:00
controller: inputRange,
2018-08-23 12:10:54 +00:00
bindings: {
label: '@?',
disabled: '<?',
2018-08-29 07:45:37 +00:00
min: '<?',
max: '<?',
step: '<?',
value: '=',
model: '=',
onChange: '&'
2018-08-23 12:10:54 +00:00
}
});