Sha256: e5ff3cd3c65b1a689655a74525bcb399214c66623b1f850010f1b323afdeb631

Contents?: true

Size: 976 Bytes

Versions: 9

Compression:

Stored size: 976 Bytes

Contents

import {MDCMenu} from '@material/menu';
import {Corner} from '@material/menu';


function createMenuHandler(menu, element) {
    return function () {
        var offset = parseInt(element.dataset.rightOffset);
        menu.setAnchorMargin({left: offset});
        menu.open = !menu.open;
    };
}

export function initMenus() {
    console.log('\tMenus');

    var components = document.querySelectorAll('.v-menu');
    if (components) {
        for (var i = 0; i < components.length; i++) {
            var component = components[i];
            if (!component.mdcComponent) {
                component.mdcComponent = new MDCMenu(component);
                var anchor = component.closest('.mdc-menu-anchor');
                if (anchor) {
                    var menulink = anchor.querySelector('.v-menu-click');
                    menulink.addEventListener('click', createMenuHandler(component.mdcComponent, component));
                }

            }
        }
    }
}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
voom-presenters-0.1.8 views/mdc/assets/js/components/menus.js
voom-presenters-0.1.7 views/mdc/assets/js/components/menus.js
voom-presenters-0.1.6 views/mdc/assets/js/components/menus.js
voom-presenters-0.1.5 views/mdc/assets/js/components/menus.js
voom-presenters-0.1.4 views/mdc/assets/js/components/menus.js
voom-presenters-0.1.3 views/mdc/assets/js/components/menus.js
voom-presenters-0.1.2 views/mdc/assets/js/components/menus.js
voom-presenters-0.1.1 views/mdc/assets/js/components/menus.js
voom-presenters-0.1.0 views/mdc/assets/js/components/menus.js