Disabled page refresh keyboard shortcuts causing accidental page refreshes
authorDarren <darren@darrenwhitlen.com>
Sun, 30 Oct 2011 11:44:32 +0000 (11:44 +0000)
committerDarren <darren@darrenwhitlen.com>
Sun, 30 Oct 2011 11:44:32 +0000 (11:44 +0000)
client/js/front.events.js
client/js/front.ui.js

index 54499d8f15ca77da160180e450a2a48c0d01c75b..bc24356d63b2b9ca463c6643503b6a999d5087d9 100644 (file)
@@ -215,13 +215,7 @@ kiwi.front.events = {
         }\r
 \r
         // Now that we're connected, warn the user if they really want to quit\r
-        // TODO: disable page refreshing or at least just f5\r
-        // This brakes the socket.io connection currently :(\r
-        /*\r
-        window.onbeforeunload = function() {\r
-            return "Are you sure you leave Kiwi IRC?";\r
-        };\r
-        */\r
+        kiwi.front.ui.preventRefresh();\r
     },\r
     /**\r
     *   Handles the connectFail event\r
index f7159c45880c87d1789bec9498feaa76a6fb77f7..37dbbf6c806f32f20250d4d61664ce82d385175a 100644 (file)
@@ -256,6 +256,21 @@ kiwi.front.ui = {
 \r
     },\r
 \r
+    preventRefresh: function () {\r
+        $(document).keydown(function (e) {\r
+            // meta + r || F5\r
+            if ((e.metaKey && e.which == 82) || e.which == 116) {\r
+                e.preventDefault();\r
+                e.stopPropagation();\r
+\r
+                // Reset IE keyCode\r
+                event.keyCode = 0;\r
+\r
+                return false;\r
+            }\r
+        });\r
+    },\r
+\r
     /**\r
     *   Prompts user for a new nick\r
     */\r