Browse Source

CustomEvent support for older devices.

Samsung Galaxy SII did not pass typeof CustomEvent == 'function' in a PhoneGap application. This broke Push and my app. This fix should be applied for all CustomEvents in Ratchet in order to work on older devices.
pull/427/head
Eric McDaniel 11 years ago
parent
commit
c15f6ea77c
  1. 18
      js/push.js

18
js/push.js

@ -382,11 +382,19 @@
};
var triggerStateChange = function () {
var e = new CustomEvent('push', {
detail: { state: getCached(PUSH.id) },
bubbles: true,
cancelable: true
});
var e;
var options = {};
options.detail = { state: getCached(PUSH.id) };
options.bubbles = true;
options.cancelable = true;
if (typeof CustomEvent === 'function') {
e = new CustomEvent('push', options);
} else if (document.createEvent) {
e = document.createEvent('CustomEvent');
e.initCustomEvent('push', options.bubbles, options.cancelable, options.detail);
}
window.dispatchEvent(e);
};

Loading…
Cancel
Save