-
Notifications
You must be signed in to change notification settings - Fork 0
/
initiate.js
39 lines (32 loc) · 1.21 KB
/
initiate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict';
window.addEventListener('load', () => {
const topAppBarElement = document.querySelector('.mdc-top-app-bar');
const topAppBar = mdc.topAppBar.MDCTopAppBar.attachTo(topAppBarElement);
const drawerElement = document.querySelector('.mdc-drawer');
if (drawerElement) {
const drawer = mdc.drawer.MDCDrawer.attachTo(drawerElement);
drawer.open = true;
topAppBar.listen('MDCTopAppBar:nav', () => {
drawer.open = !drawer.open;
});
}
const buttons = document.querySelectorAll('.mdc-button');
buttons.forEach(button => {
mdc.ripple.MDCRipple.attachTo(button);
});
const textFields = document.querySelectorAll('.mdc-text-field');
textFields.forEach(textField => {
mdc.textField.MDCTextField.attachTo(textField);
});
// FormFields with checkbox
const formfields = document.querySelectorAll('.mdc-form-field');
formfields.forEach(field => {
const formfield = mdc.formField.MDCFormField.attachTo(field);
const checkbox = mdc.checkbox.MDCCheckbox.attachTo(field.querySelector('.mdc-checkbox'));
field.input = checkbox;
});
const selects = document.querySelectorAll('.mdc-select');
selects.forEach(select => {
mdc.select.MDCSelect.attachTo(select);
});
});