Sha256: c5d5e5c978a462e61c417b1f19125a1247feee761df3c15c5c68c259223404e2

Contents?: true

Size: 988 Bytes

Versions: 4

Compression:

Stored size: 988 Bytes

Contents

import {VBaseComponent} from './base-component';
import {eventHandlerMixin} from './mixins/event-handler';

export function initSwitches() {
    console.log('\tSwitches');

    let components = document.querySelectorAll('.v-switch');
    if (components) {
        for (let i = 0; i < components.length; i++) {
            let component = components[i];
            if (!component.vComponent) {
                let input = component.querySelector('input');
                let vSwitch = new VSwitch(component, input);
                component.vComponent = vSwitch;
                input.vComponent = vSwitch;
            }
        }
    }
}

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

    validate(_formData) {
        return true;
    }

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
voom-presenters-0.1.5 views/mdc/assets/js/components/switches.js
voom-presenters-0.1.4 views/mdc/assets/js/components/switches.js
voom-presenters-0.1.3 views/mdc/assets/js/components/switches.js
voom-presenters-0.1.2 views/mdc/assets/js/components/switches.js