mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-10-31 14:10:08 +00:00
Directly send auto away message
This avoids problems when “Channel 0” is not opened
This commit is contained in:
parent
e2aebcf7a2
commit
47f23090a5
@ -207,25 +207,17 @@ and afterwards sent to the server by an AJAX request.
|
|||||||
|
|
||||||
obj.text
|
obj.text
|
||||||
|
|
||||||
new WCF.Action.Proxy
|
sendMessage text,
|
||||||
autoSend: true
|
|
||||||
data:
|
|
||||||
actionName: 'send'
|
|
||||||
className: 'chat\\data\\message\\MessageAction'
|
|
||||||
parameters:
|
|
||||||
text: text
|
|
||||||
enableSmilies: $('#timsChatSmilies').data 'status'
|
|
||||||
showLoadingOverlay: false
|
|
||||||
success: ->
|
|
||||||
do hideInputError
|
|
||||||
|
|
||||||
do getMessages
|
|
||||||
failure: (data) ->
|
failure: (data) ->
|
||||||
return true unless (data?.returnValues?.errorType?) or (data?.message?)
|
if data.returnValues?.errorType?
|
||||||
|
error = data.returnValues.errorType
|
||||||
|
else if data.returnValues?.errorMessage
|
||||||
|
error = data.returnValues.errorMessage
|
||||||
|
else if data.message?
|
||||||
|
error = data.message
|
||||||
|
|
||||||
showInputError (data?.returnValues?.errorType) ? data.message
|
showInputError error if error
|
||||||
|
|
||||||
false
|
|
||||||
|
|
||||||
Autocomplete a username when TAB is pressed. The name to autocomplete is based on the current caret position.
|
Autocomplete a username when TAB is pressed. The name to autocomplete is based on the current caret position.
|
||||||
The the word the caret is in will be passed to `autocomplete` and replaced if a match was found.
|
The the word the caret is in will be passed to `autocomplete` and replaced if a match was found.
|
||||||
@ -525,6 +517,36 @@ Finished! Enable the input now and join the chat.
|
|||||||
|
|
||||||
true
|
true
|
||||||
|
|
||||||
|
Send messages
|
||||||
|
|
||||||
|
sendMessage = (text, options) ->
|
||||||
|
options = $.extend
|
||||||
|
showLoadingOverlay: false
|
||||||
|
suppressErrors: false
|
||||||
|
, options
|
||||||
|
|
||||||
|
new WCF.Action.Proxy
|
||||||
|
autoSend: true
|
||||||
|
data:
|
||||||
|
actionName: 'send'
|
||||||
|
className: 'chat\\data\\message\\MessageAction'
|
||||||
|
parameters:
|
||||||
|
text: text
|
||||||
|
enableSmilies: $('#timsChatSmilies').data 'status'
|
||||||
|
showLoadingOverlay: options.showLoadingOverlay
|
||||||
|
suppressErrors: options.suppressErrors
|
||||||
|
success: ->
|
||||||
|
do hideInputError
|
||||||
|
options.success?()
|
||||||
|
do getMessages
|
||||||
|
|
||||||
|
failure: (data) ->
|
||||||
|
return true unless (data?.returnValues?.errorType?) or (data?.message?)
|
||||||
|
|
||||||
|
options.failure? data
|
||||||
|
|
||||||
|
false
|
||||||
|
|
||||||
Shows an error message below the input.
|
Shows an error message below the input.
|
||||||
|
|
||||||
showInputError = (message) ->
|
showInputError = (message) ->
|
||||||
@ -551,19 +573,8 @@ Sets user’s status to away
|
|||||||
|
|
||||||
return if userList.current[WCF.User.userID].awayStatus?
|
return if userList.current[WCF.User.userID].awayStatus?
|
||||||
|
|
||||||
text = $('#timsChatInput').val()
|
sendMessage "/away #{WCF.Language.get 'chat.global.autoAway', { time: do (new Date).toTimeString }}",
|
||||||
caret = do $('#timsChatInput').getCaret
|
suppressErrors: true
|
||||||
|
|
||||||
insertText "/away #{WCF.Language.get 'chat.global.autoAway', {time: do (new Date).toTimeString}}",
|
|
||||||
prepend: false
|
|
||||||
append: false
|
|
||||||
submit: true
|
|
||||||
|
|
||||||
if text.length > 0
|
|
||||||
insertText text,
|
|
||||||
prepend: false
|
|
||||||
append: false
|
|
||||||
caret: caret
|
|
||||||
|
|
||||||
|
|
||||||
Free the fish.
|
Free the fish.
|
||||||
@ -883,7 +894,7 @@ the existing text. If `options.submit` is true the message will be sent to the s
|
|||||||
|
|
||||||
# do not insert text if it would exceed the allowed length
|
# do not insert text if it would exceed the allowed length
|
||||||
maxLength = $('#timsChatInput').attr 'maxlength'
|
maxLength = $('#timsChatInput').attr 'maxlength'
|
||||||
return if maxLength? and text.length > maxLength
|
return false if maxLength? and text.length > maxLength
|
||||||
|
|
||||||
$('#timsChatInput').val text
|
$('#timsChatInput').val text
|
||||||
$('#timsChatInput').trigger 'change'
|
$('#timsChatInput').trigger 'change'
|
||||||
@ -895,6 +906,9 @@ the existing text. If `options.submit` is true the message will be sent to the s
|
|||||||
|
|
||||||
do $('#timsChatInput').focus
|
do $('#timsChatInput').focus
|
||||||
|
|
||||||
|
true
|
||||||
|
|
||||||
|
|
||||||
Send out notifications for the given `message`. The number of unread messages will be prepended to `document.title` and if available desktop notifications will be sent.
|
Send out notifications for the given `message`. The number of unread messages will be prepended to `document.title` and if available desktop notifications will be sent.
|
||||||
|
|
||||||
notify = (message) ->
|
notify = (message) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user