2019-10-18 19:36:30 +00:00
|
|
|
import ngModule from '../../module';
|
|
|
|
import FormInput from '../form-input';
|
|
|
|
import './style.scss';
|
|
|
|
|
|
|
|
export default class Range extends FormInput {
|
|
|
|
constructor($element, $scope) {
|
|
|
|
super($element, $scope);
|
|
|
|
this.input = this.element.querySelector('input');
|
2019-12-17 12:03:09 +00:00
|
|
|
this.input.addEventListener('change', () => this.onValueUpdate());
|
|
|
|
}
|
|
|
|
|
|
|
|
get field() {
|
|
|
|
return super.field;
|
|
|
|
}
|
|
|
|
|
|
|
|
set field(value) {
|
|
|
|
this.input.value = value;
|
|
|
|
super.field = value;
|
2019-10-18 19:36:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
refreshTabIndex() {
|
|
|
|
this.input.tabIndex = this.disabled ? -1 : this.tabIndex;
|
|
|
|
}
|
2019-12-17 12:03:09 +00:00
|
|
|
|
|
|
|
onValueUpdate() {
|
2020-05-13 13:04:57 +00:00
|
|
|
this.change(parseInt(this.input.value));
|
2019-12-17 12:03:09 +00:00
|
|
|
this.$.$applyAsync();
|
|
|
|
}
|
2019-10-18 19:36:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.vnComponent('vnRange', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Range,
|
|
|
|
bindings: {
|
|
|
|
min: '<?',
|
|
|
|
max: '<?',
|
|
|
|
step: '<?',
|
|
|
|
minLabel: '@?',
|
|
|
|
maxLabel: '@?'
|
|
|
|
}
|
|
|
|
});
|