views/mdc/assets/js/components/icon-toggles.js in voom-presenters-0.1.13 vs views/mdc/assets/js/components/icon-toggles.js in voom-presenters-0.2.0
- old
+ new
@@ -1,21 +1,14 @@
import {MDCIconToggle} from '@material/icon-toggle';
+import {hookupComponents, VBaseComponent} from './base-component';
+import {eventHandlerMixin} from './mixins/event-handler';
export function initIconToggles() {
console.log('\tIcon Toggles');
+ hookupComponents('.v-icon-toggle', VIconToggle, MDCIconToggle);
+}
- var components = document.querySelectorAll('.mdc-icon-toggle');
- for (var i = 0; i < components.length; i++) {
- var component = components[i];
- if (!component.mdcComponent) {
- component.mdcComponent = new MDCIconToggle(component);
- }
+export class VIconToggle extends eventHandlerMixin(VBaseComponent) {
+ constructor(element, mdcComponent) {
+ super(element, mdcComponent);
}
}
-
-// TODO: Add event handler
-// var addToFavorites = document.getElementById('add-to-favorites');
-// var favoritedStatus = document.getElementById('favorited-status');
-// addToFavorites.addEventListener('MDCIconToggle:change', function(evt) {
-// var newStatus = evt.detail.isOn ? 'yes' : 'no';
-// favoritedStatus.textContent = newStatus;
-// });