]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11283: iOS doesn't support beforeunload, use recommended pagehide for that platform
authorChad Phillips <chad@apartmentlines.com>
Thu, 26 Jul 2018 19:19:28 +0000 (14:19 -0500)
committerChad Phillips <chad@apartmentlines.com>
Thu, 26 Jul 2018 19:19:28 +0000 (14:19 -0500)
$.verto.unloadJobs queue leverages the 'beforeunload' event to perform work
prior to browser page unload.

However, iOS does not support that event. Its equivalent event is 'pagehide'.

This patch uses the pagehide event on iOS, and beforeunload for all others.

html5/verto/js/src/jquery.verto.js

index c913ca41404ed45275a15b18f2f97e0e22fd99ed..a2e02e4bdcd72025089ebee63fe1d30252ca2a21 100644 (file)
     
     $.verto.unloadJobs = [];
 
-    $(window).bind('beforeunload', function() {
-       for (var f in $.verto.unloadJobs) {
-           $.verto.unloadJobs[f]();
-       }
+    var unloadEventName = 'beforeunload';
+    // Hacks for Mobile Safari
+    var iOS = ['iPad', 'iPhone', 'iPod'].indexOf(navigator.platform) >= 0;
+    if (iOS) {
+      unloadEventName = 'pagehide';
+    }
+
+    $(window).bind(unloadEventName, function() {
+        for (var f in $.verto.unloadJobs) {
+          $.verto.unloadJobs[f]();
+        }
 
         if ($.verto.haltClosure)
           return $.verto.haltClosure();