Sha256: 0352b4cec508d706f24ea8d866748efde6797a27c911d27435c3b6602e130062
Contents?: true
Size: 1.56 KB
Versions: 18
Compression:
Stored size: 1.56 KB
Contents
import {MDCSelect} from '@material/select'; import {VBaseComponent, hookupComponents} from './base-component'; import {visibilityObserverMixin} from "./mixins/visibility-observer"; import {dirtyableMixin} from './mixins/dirtyable'; export function initSelects(e) { console.debug('\tSelects'); hookupComponents(e, '.v-select', VSelect, MDCSelect); } export class VSelect extends dirtyableMixin(visibilityObserverMixin(VBaseComponent)) { constructor(element, mdcComponent) { super(element, mdcComponent); this.select = element.querySelector('select'); this.select.vComponent = this; this.recalcWhenVisible(this); this.originalValue = this.value(); } prepareSubmit(params) { params.push([this.name(), this.value()]); } name() { return this.select.name; } value() { return this.select.options.length === 0 || this.select.selectedIndex === -1 ? null : this.select.options[this.select.selectedIndex].value; } clear() { let before = this.select.selectedIndex; this.select.selectedIndex = 0; if (before !== 0) { var event = new InputEvent('input', { view: window, bubbles: true, cancelable: true }); this.select .dispatchEvent(event); } } reset() { this.select.value = this.originalValue; } setValue(value) { this.select.value = value; } isDirty() { return this.dirtyable && this.value() !== this.originalValue; } }
Version data entries
18 entries across 18 versions & 2 rubygems