Created
July 9, 2013 03:22
-
-
Save mlangens/5954449 to your computer and use it in GitHub Desktop.
wrap around box changer
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
this.inputChanger = function() { | |
$(window).on('keydown', function(event) { | |
if(event.which === 13) { | |
var target = $(event.target); | |
var thingie = target.closest('.lightbox-container'); | |
var inputs = thingie.find('input,textarea'); | |
var index = inputs.get().indexOf(event.target); | |
var nextIndex = (index + 1) % inputs.length; | |
$(inputs.get(nextIndex)).focus(); | |
return false; | |
} else if(event.which === 27) { | |
self.lightBox.close(); | |
return false; | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment