Created
March 16, 2012 00:10
-
-
Save karlbright/2047784 to your computer and use it in GitHub Desktop.
Which one looks nicer?
This file contains hidden or 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
keyDown: (event) -> | |
switch event.keyCode | |
# Backspace | |
when 8 | |
if @el.val() is '' | |
token = @tokens.pop() | |
token.remove() | |
# Enter | |
when 13 then Houston.nextStep() if @el.autocomplete 'option', 'disabled' | |
# @ | |
when 50 @enableAutocomplete if event.shiftKey is true | |
else setTimeout @check, 100 unless event.keyCode in @ignoredKeys | |
keyDown: (event) -> | |
# Backspace | |
if @el.val() is '' and event.keyCode is 8 | |
if @tokens.length > 0 | |
token = @tokens.pop() | |
token.remove() | |
else if @el.autocomplete('option','disabled') | |
# Onto the next step if enter has been pressed | |
Houston.nextStep() if event.keyCode is 13 | |
# Enable autocomplete if the user enters a '@' symbol | |
@enableAutocomplete() if event.keyCode is 50 and event.shiftKey is true | |
else | |
# Set timeout before checking this string. If we check too quickly the value will not be grabbed correctly. | |
setTimeout @check, 100 unless event.keyCode in @ignoredKeys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment