aboutsummaryrefslogtreecommitdiffstats
path: root/library/jquery.AreYouSure/ays-beforeunload-shim.js
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-01-01 21:49:01 -0800
committerfriendica <info@friendica.com>2015-01-01 21:49:01 -0800
commit545e47933a0816699c68d98a7742a03260d6a54f (patch)
tree1590e642e1eb48c76dd7c82b4bab4bb93ddf344d /library/jquery.AreYouSure/ays-beforeunload-shim.js
parent0286c5a35b7f6fb0f02e50110deb78ae66a028cf (diff)
parent9d4c4efb5176afe5284bc5c22df277510c64786b (diff)
downloadvolse-hubzilla-545e47933a0816699c68d98a7742a03260d6a54f.tar.gz
volse-hubzilla-545e47933a0816699c68d98a7742a03260d6a54f.tar.bz2
volse-hubzilla-545e47933a0816699c68d98a7742a03260d6a54f.zip
Merge https://github.com/friendica/red into pending_merge
Diffstat (limited to 'library/jquery.AreYouSure/ays-beforeunload-shim.js')
-rw-r--r--library/jquery.AreYouSure/ays-beforeunload-shim.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/library/jquery.AreYouSure/ays-beforeunload-shim.js b/library/jquery.AreYouSure/ays-beforeunload-shim.js
new file mode 100644
index 000000000..cb864cdeb
--- /dev/null
+++ b/library/jquery.AreYouSure/ays-beforeunload-shim.js
@@ -0,0 +1,31 @@
+/*!
+ * An experimental shim to partially emulate onBeforeUnload on iOS.
+ * Part of https://github.com/codedance/jquery.AreYouSure/
+ *
+ * Copyright (c) 2012-2014, Chris Dance and PaperCut Software http://www.papercut.com/
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * Author: chris.dance@papercut.com
+ * Date: 19th May 2014
+ */
+$(function() {
+ if (!navigator.userAgent.toLowerCase().match(/iphone|ipad|ipod|opera/)) {
+ return;
+ }
+ $('a').bind('click', function(evt) {
+ var href = $(evt.target).closest('a').attr('href');
+ if (href !== undefined && !(href.match(/^#/) || href.trim() == '')) {
+ var response = $(window).triggerHandler('beforeunload', response);
+ if (response && response != "") {
+ var msg = response + "\n\n"
+ + "Press OK to leave this page or Cancel to stay.";
+ if (!confirm(msg)) {
+ return false;
+ }
+ }
+ window.location.href = href;
+ return false;
+ }
+ });
+});