mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2025-01-09 00:20:08 +00:00
parent
ca123d62b0
commit
6de9a985bc
@ -45,6 +45,7 @@ window.console ?=
|
|||||||
# Autocompleter
|
# Autocompleter
|
||||||
autocompleteOffset: 0
|
autocompleteOffset: 0
|
||||||
autocompleteValue: null
|
autocompleteValue: null
|
||||||
|
autocompleteCaret: 0
|
||||||
|
|
||||||
# Autoscroll
|
# Autoscroll
|
||||||
oldScrollTop: null
|
oldScrollTop: null
|
||||||
@ -134,20 +135,39 @@ window.console ?=
|
|||||||
# tab key
|
# tab key
|
||||||
if event.keyCode is 9
|
if event.keyCode is 9
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
if @autocompleteValue is null
|
@autocompleteValue = $('#timsChatInput').val() if @autocompleteValue is null
|
||||||
@autocompleteValue = $('#timsChatInput').val()
|
@autocompleteCaret = $('#timsChatInput').getCaret() if @autocompleteCaret is null
|
||||||
|
|
||||||
firstChars = @autocompleteValue.substring(@autocompleteValue.lastIndexOf(' ')+1)
|
beforeCaret = @autocompleteValue.substring 0, @autocompleteCaret
|
||||||
|
lastSpace = beforeCaret.lastIndexOf ' '
|
||||||
|
beforeComplete = @autocompleteValue.substring 0, lastSpace + 1
|
||||||
|
toComplete = @autocompleteValue.substring lastSpace + 1
|
||||||
|
nextSpace = toComplete.indexOf ' '
|
||||||
|
if nextSpace is -1
|
||||||
|
afterComplete = '';
|
||||||
|
else
|
||||||
|
afterComplete = toComplete.substring nextSpace + 1
|
||||||
|
toComplete = toComplete.substring 0, nextSpace
|
||||||
|
|
||||||
console.log 'Autocompleting "' + firstChars + '"'
|
return if toComplete.length is 0
|
||||||
return if firstChars.length is 0
|
console.log 'Autocompleting "' + toComplete + '"'
|
||||||
|
|
||||||
# Insert name and increment offset
|
# Insert name and increment offset
|
||||||
$('#timsChatInput').val(@autocompleteValue.substring(0, @autocompleteValue.lastIndexOf(' ') + 1) + @autocomplete(firstChars))
|
name = @autocomplete toComplete
|
||||||
|
|
||||||
|
$('#timsChatInput').val beforeComplete + name + ' ' + afterComplete
|
||||||
|
$('#timsChatInput').setCaret((beforeComplete + name).length + 1);
|
||||||
@autocompleteOffset++
|
@autocompleteOffset++
|
||||||
else
|
else
|
||||||
@autocompleteOffset = 0
|
@autocompleteOffset = 0
|
||||||
@autocompleteValue = null
|
@autocompleteValue = null
|
||||||
|
@autocompleteCaret = null
|
||||||
|
, @
|
||||||
|
|
||||||
|
$('#timsChatInput').click $.proxy (event) ->
|
||||||
|
@autocompleteOffset = 0
|
||||||
|
@autocompleteValue = null
|
||||||
|
@autocompleteCaret = null
|
||||||
, @
|
, @
|
||||||
|
|
||||||
# Refreshes the roomlist
|
# Refreshes the roomlist
|
||||||
|
Loading…
Reference in New Issue
Block a user