meta+[] shortcut keys for switching between panels
authorDarren <darren@Darrens-MacBook-Pro.local>
Sat, 4 May 2013 16:42:13 +0000 (17:42 +0100)
committerDarren <darren@Darrens-MacBook-Pro.local>
Sat, 4 May 2013 16:42:13 +0000 (17:42 +0100)
client/assets/dev/view.js

index 383a2c512ba3311c7563b84d332cb434f9dad431..8f702a275250bc301a5e914061cc29fae0b9fa66 100644 (file)
@@ -849,19 +849,6 @@ _kiwi.view.Tabs = Backbone.View.extend({
         } else {\r
             panel.close();\r
         }\r
-    },\r
-\r
-    next: function () {\r
-        var next = this.$tab_container.find('.active').next();\r
-        if (!next.length) next = $('li:first', this.$tab_container);\r
-\r
-        next.click();\r
-    },\r
-    prev: function () {\r
-        var prev = this.$tab_container.find('.active').prev();\r
-        if (!prev.length) prev = $('li:last', this.$tab_container);\r
-\r
-        prev.click();\r
     }\r
 });\r
 \r
@@ -1002,11 +989,43 @@ _kiwi.view.ControlBox = Backbone.View.extend({
             break;\r
 \r
         case (ev.keyCode === 219 && meta):            // [ + meta\r
-            _kiwi.app.panels.view.prev();\r
+            // Find all the tab elements and get the index of the active tab\r
+            var $tabs = $('#kiwi #tabs').find('li[class!=connection]');\r
+            var cur_tab_ind = (function() {\r
+                for (var idx=0; idx<$tabs.length; idx++){\r
+                    if ($($tabs[idx]).hasClass('active'))\r
+                        return idx;\r
+                }\r
+            })();\r
+\r
+            // Work out the previous tab along. Wrap around if needed\r
+            if (cur_tab_ind === 0) {\r
+                $prev_tab = $($tabs[$tabs.length - 1]);\r
+            } else {\r
+                $prev_tab = $($tabs[cur_tab_ind - 1]);\r
+            }\r
+\r
+            $prev_tab.click();\r
             return false;\r
 \r
         case (ev.keyCode === 221 && meta):            // ] + meta\r
-            _kiwi.app.panels.view.next();\r
+            // Find all the tab elements and get the index of the active tab\r
+            var $tabs = $('#kiwi #tabs').find('li[class!=connection]');\r
+            var cur_tab_ind = (function() {\r
+                for (var idx=0; idx<$tabs.length; idx++){\r
+                    if ($($tabs[idx]).hasClass('active'))\r
+                        return idx;\r
+                }\r
+            })();\r
+\r
+            // Work out the next tab along. Wrap around if needed\r
+            if (cur_tab_ind === $tabs.length - 1) {\r
+                $next_tab = $($tabs[0]);\r
+            } else {\r
+                $next_tab = $($tabs[cur_tab_ind + 1]);\r
+            }\r
+\r
+            $next_tab.click();\r
             return false;\r
 \r
         case (ev.keyCode === 9):                     // tab\r