Created
October 16, 2010 22:24
-
-
Save rwaldron/630341 to your computer and use it in GitHub Desktop.
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
<!doctype html> | |
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery.js"></script> | |
<script src="script.js"></script> | |
</head> | |
<body> | |
<textarea id="whatever">foo bar #hash</textarea> | |
Proof Of Concept: If you arrow right until just before the #hash and type shift-@, a "faked" autocomplete will trigger and insert @user - but will retain the string following. Currently, if you try this in #newTwitter, it will blow away any text following the autocompleted @user. | |
</body> | |
</html> |
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() { | |
// Proof of concept | |
var handleCurrentInput = function (e) { | |
var $this = $(this), | |
valStr = $this.val(), | |
valArr, lastIndexAt, lastItem; | |
if ( e.shiftKey && e.which === 50 ) { | |
lastIndexAt = valStr.lastIndexOf('@'); | |
valArr = valStr.split('@'); | |
lastItem = valArr.pop(); | |
// fake logic that pretends to be twitter user autocomplete | |
valArr.push('@user ') | |
valArr.push(lastItem); | |
$this.val(valArr.map(function(str) { | |
return $.trim(str); | |
}).join(' ')); | |
} | |
}; | |
$('textarea') | |
.bind('keyup', handleCurrentInput) | |
.trigger('focus'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment