salix/front/core/components/textarea/index.js

38 lines
902 B
JavaScript
Raw Permalink Normal View History

2019-10-09 22:47:29 +00:00
import ngModule from '../../module';
import Field from '../field';
2020-06-05 11:14:14 +00:00
import './style.scss';
2019-10-09 22:47:29 +00:00
export default class Textarea extends Field {
constructor($element, $scope, $compile) {
super($element, $scope, $compile);
let html = `<textarea ng-model="$ctrl.field"></textarea>`;
2019-10-28 20:40:24 +00:00
this.input = this.$compile(html)($scope)[0];
2019-10-09 22:47:29 +00:00
}
set rows(value) {
this.input.rows = typeof value == 'number' && value > 0 ? value : 3;
}
get rows() {
return this.input.rows;
}
2020-01-14 08:10:54 +00:00
set maxlength(value) {
let length = typeof value == 'number' && value > 1 ? value : 50;
this.input.setAttribute('maxlength', length);
}
get maxlength() {
return this.input.getAttribute('maxlength', length);
}
2019-10-09 22:47:29 +00:00
}
ngModule.vnComponent('vnTextarea', {
controller: Textarea,
bindings: {
2020-01-14 08:10:54 +00:00
rows: '<?',
maxlength: '<?'
2019-10-09 22:47:29 +00:00
}
});