Last active
December 20, 2015 04:59
-
-
Save macgyver/6074511 to your computer and use it in GitHub Desktop.
Add keyboard shortcuts for http://tmtheme-editor.herokuapp.com/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(win, doc, $){ | |
var next = function() { | |
var $next = $gallery.find('li.ng-scope.selected').next('li.ng-scope'); | |
if ($next.length === 0) { | |
$next = $gallery.find('li.ng-scope').filter(':first'); | |
} | |
$next.trigger('click'); | |
}, prev = function() { | |
var $prev = $gallery.find('li.ng-scope.selected').prev('li.ng-scope'); | |
if ($prev.length === 0) { | |
$prev = $gallery.find('li.ng-scope').filter(':last'); | |
} | |
$prev.trigger('click'); | |
}, $gallery = $('#gallery'); | |
$gallery.on('keyup', function(e){ | |
// J = 74, K = 75 | |
// Add cursor keys if you want but I dislike how it gloms onto native browser commands | |
// LEFT = 37, UP = 38, RIGHT = 39, DOWN = 40 | |
if ([/*39, 40, */74].indexOf(e.which) !== -1) { | |
next(); | |
} | |
else if ([/*37, 38, */75].indexOf(e.which) !== -1) { | |
prev(); | |
} | |
}); | |
})(window, document, $); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment