vendor/assets/javascripts/material.js in material_design_lite-rails-1.1.2 vs vendor/assets/javascripts/material.js in material_design_lite-rails-1.1.3
- old
+ new
@@ -228,12 +228,19 @@
} else {
throw new Error(
'Unable to find a registered component for the given class.');
}
- var ev = document.createEvent('Events');
- ev.initEvent('mdl-componentupgraded', true, true);
+ var ev;
+ if ('CustomEvent' in window && typeof window.CustomEvent === 'function') {
+ ev = new Event('mdl-componentupgraded', {
+ 'bubbles': true, 'cancelable': false
+ });
+ } else {
+ ev = document.createEvent('Events');
+ ev.initEvent('mdl-componentupgraded', true, true);
+ }
element.dispatchEvent(ev);
}
}
/**
@@ -352,13 +359,19 @@
var upgrades = component.element_.getAttribute('data-upgraded').split(',');
var componentPlace = upgrades.indexOf(component[componentConfigProperty_].classAsString);
upgrades.splice(componentPlace, 1);
component.element_.setAttribute('data-upgraded', upgrades.join(','));
- var ev = document.createEvent('Events');
- ev.initEvent('mdl-componentdowngraded', true, true);
- component.element_.dispatchEvent(ev);
+ var ev;
+ if ('CustomEvent' in window && typeof window.CustomEvent === 'function') {
+ ev = new Event('mdl-componentdowngraded', {
+ 'bubbles': true, 'cancelable': false
+ });
+ } else {
+ ev = document.createEvent('Events');
+ ev.initEvent('mdl-componentdowngraded', true, true);
+ }
}
}
/**
* Downgrade either a given node, an array of nodes, or a NodeList.
@@ -3565,18 +3578,9 @@
e.preventDefault();
selectTab();
}
});
tab.show = selectTab;
- tab.addEventListener('click', function (e) {
- e.preventDefault();
- var href = tab.href.split('#')[1];
- var panel = layout.content_.querySelector('#' + href);
- layout.resetTabState_(tabs);
- layout.resetPanelState_(panels);
- tab.classList.add(layout.CssClasses_.IS_ACTIVE);
- panel.classList.add(layout.CssClasses_.IS_ACTIVE);
- });
}
window['MaterialLayoutTab'] = MaterialLayoutTab;
// The component registers itself. It can assume componentHandler is available
// in the global scope.
componentHandler.register({