Sha256: 1cd3eb77b0257a92008063001bb01b31c373d799ed90d9c52750a024ac3ea65b

Contents?: true

Size: 856 Bytes

Versions: 1

Compression:

Stored size: 856 Bytes

Contents

import {VBaseComponent, hookupComponents} from './base-component';
import {eventHandlerMixin} from './mixins/event-handler';
import {MDCSwitch} from '@material/switch';

export function initSwitches() {
    console.log('\tSwitches');
    hookupComponents('.v-switch', VSwitch, MDCSwitch);
}

export class VSwitch extends eventHandlerMixin(VBaseComponent) {
    constructor(element, mdcComponent) {
        super(element, mdcComponent);
        this.input = element.querySelector('input');
    }

    prepareSubmit(params) {
        if (this.input.checked) {
            params.push([this.name(), this.value()]);
        }
    }

    name() {
        return this.input.name;
    }

    value() {
        return this.input.value;
    }

    clear() {
        this.input.checked = false;
    }

    setValue(value) {
        this.input.value = value;
    }
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
voom-presenters-0.2.0 views/mdc/assets/js/components/switches.js