Sha256: 1bf69d81ba7b28a632c5f09790c426e672d1299177acce275c2bf071f0bf357a

Contents?: true

Size: 990 Bytes

Versions: 8

Compression:

Stored size: 990 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.checked]);
        }
    }
}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
voom-presenters-0.1.13 views/mdc/assets/js/components/switches.js
voom-presenters-0.1.12 views/mdc/assets/js/components/switches.js
voom-presenters-0.1.11 views/mdc/assets/js/components/switches.js
voom-presenters-0.1.10 views/mdc/assets/js/components/switches.js
voom-presenters-0.1.9 views/mdc/assets/js/components/switches.js
voom-presenters-0.1.8 views/mdc/assets/js/components/switches.js
voom-presenters-0.1.7 views/mdc/assets/js/components/switches.js
voom-presenters-0.1.6 views/mdc/assets/js/components/switches.js