From 1a4367f64d36904e85167af683ad03fde0772c66 Mon Sep 17 00:00:00 2001 From: MFTCMBP2 Date: Wed, 5 Mar 2014 11:19:05 -0500 Subject: [PATCH] Squashed commit of the following: commit 494adcbf08accd3528f9686c29dd592617243bd3 Author: Eric McDaniel Date: Wed Mar 5 10:54:32 2014 -0500 Changed '==' to '===' commit 5eefe9b4a21de7b05a9832d1ccc06a05d16cdb5e Author: Eric McDaniel Date: Wed Mar 5 10:50:53 2014 -0500 Changed options declaration commit b3d8980e782e685c1b8a930d56a99b57e6af189d Author: Eric McDaniel Date: Wed Mar 5 10:47:09 2014 -0500 Fixed variable declarations commit 037791268d5eacb766573e29a05c52b191b4bfba Author: Eric McDaniel Date: Wed Mar 5 10:43:11 2014 -0500 Update push.js commit ee7681ed11cab9ca956eae7a44744bd34b736a1f Author: Eric McDaniel Date: Wed Mar 5 10:39:13 2014 -0500 Support for CustomEvent on 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. --- js/push.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/js/push.js b/js/push.js index da45507..a954ea1 100644 --- a/js/push.js +++ b/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); };