Permalink
Browse files

Fixed issue #50, added keyboard shortcut for next/previous tab

  • Loading branch information...
1 parent b928cb9 commit bc2011f8e3fb17d9666edea87816fbef8ad3ecec @LeaVerou committed Dec 17, 2011
Showing with 37 additions and 2 deletions.
  1. +29 −2 code/dabblet.js
  2. +8 −0 index.html
View
@@ -863,6 +863,10 @@ Dabblet.previewer('abslength', function(previewer, code) {
});
Dabblet.previewer('time', function(previewer, code) {
+ if(code === '0s') {
+ return false;
+ }
+
$$('animate', previewer).forEach(function(animation) {
animation.setAttribute('dur', code);
});
@@ -1286,11 +1290,34 @@ document.onkeydown = function(evt) {
break;
}
+ var currentPage = Dabblet.settings.current('page');
+
+ if(evt.shiftKey) {
+ if(character === '[' || code === 219) {
+ if(evt.shiftKey) {
+ // Go to previous tab
+ var page = ({
+ 'html': 'css',
+ 'result': 'html'
+ })[currentPage];
+ }
+ }
+ else if (character === ']' || code === 221) {
+ if(evt.shiftKey) {
+ // Go to next tab
+ var page = ({
+ 'css': 'html',
+ 'html': 'result'
+ })[currentPage];
+ }
+ }
+ }
+
if(page) {
- var currentPage = Dabblet.settings.current('page');
-
if(currentPage !== page) {
Dabblet.settings.apply('page', page);
+
+ evt.stopPropagation();
return false;
}
}
View
@@ -148,6 +148,14 @@ <h1>Keyboard shortcuts</h1>
<td><kbd title="Cmd">⌘</kbd><kbd>3</kbd></td>
<td>Go to result</td>
</tr>
+ <tr>
+ <td><kbd title="Cmd">⌘</kbd><kbd title="Shift">⇧</kbd><kbd>[</kbd></td>
+ <td>Go to previous tab</td>
+ </tr>
+ <tr>
+ <td><kbd title="Cmd">⌘</kbd><kbd title="Shift">⇧</kbd><kbd>]</kbd></td>
+ <td>Go to next tab</td>
+ </tr>
<tr>
<td><kbd title="Tab">⇥</kbd><div class="note">in editing mode</div></td>
<td>Enters a Tab (<code>\t</code>) character</td>

0 comments on commit bc2011f

Please sign in to comment.