mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40:08 +00:00
Add auto away function
This commit is contained in:
parent
43100bcdf9
commit
ea693dae00
@ -46,6 +46,7 @@ exposed by a function if necessary.
|
||||
hidePrivateChannelTopic = no
|
||||
|
||||
isJoining = no
|
||||
awayStatus = null
|
||||
fileUploaded = no
|
||||
errorVisible = false
|
||||
inputErrorHidingTimer = null
|
||||
@ -284,6 +285,10 @@ Reset autocompleter to default status, when the input is `click`ed, as the posit
|
||||
value: null
|
||||
caret: null
|
||||
|
||||
$('#timsChatInput').on 'input change', (event) ->
|
||||
do pe.autoAway?.resume unless userList.current?[WCF.User.userID]?.awayStatus?
|
||||
|
||||
|
||||
Bind user menu functions
|
||||
|
||||
$('#dropdownMenuContainer').on 'click', '.jsTimsChatUserMenuQuery', -> openPrivateChannel $(@).parents('ul').data 'userID'
|
||||
@ -489,6 +494,7 @@ Initialize the `PeriodicalExecuter`s
|
||||
|
||||
pe.refreshRoomList = new WCF.PeriodicalExecuter refreshRoomList, 60e3
|
||||
pe.getMessages = new WCF.PeriodicalExecuter getMessages, v.config.reloadTime * 1e3
|
||||
pe.autoAway = new WCF.PeriodicalExecuter autoAway, v.config.autoAwayTime * 1e3 if v.config.autoAwayTime > 0
|
||||
|
||||
Initialize the [**Push**](https://github.com/wbbaddons/Push) integration of **Tims Chat**. Once
|
||||
the browser is connected to **Push** periodic message loading will be disabled and **Tims Chat** will
|
||||
@ -537,6 +543,29 @@ Hides the error message below the input.
|
||||
|
||||
do $('#timsChatInputContainer').removeClass('formError').find('.innerError').hide
|
||||
|
||||
|
||||
Sets user’s status to away
|
||||
|
||||
autoAway = ->
|
||||
do pe.autoAway?.stop
|
||||
|
||||
return if userList.current[WCF.User.userID].awayStatus?
|
||||
|
||||
text = $('#timsChatInput').val()
|
||||
caret = do $('#timsChatInput').getCaret
|
||||
|
||||
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.
|
||||
|
||||
freeTheFish = ->
|
||||
@ -765,6 +794,14 @@ Move the user to the new position if he was found in the old list.
|
||||
element.removeAttr 'title'
|
||||
element.data 'tooltip', ''
|
||||
|
||||
if user.userID is WCF.User.userID and user.awayStatus isnt awayStatus
|
||||
if user.awayStatus?
|
||||
do pe.autoAway?.stop # Away
|
||||
else
|
||||
do pe.autoAway?.resume # Back
|
||||
|
||||
awayStatus = user.awayStatus
|
||||
|
||||
if user.suspended
|
||||
element.addClass 'suspended'
|
||||
else
|
||||
@ -828,6 +865,7 @@ the existing text. If `options.submit` is true the message will be sent to the s
|
||||
prepend: false
|
||||
append: true
|
||||
submit: false
|
||||
caret: false
|
||||
, options
|
||||
|
||||
text = text + $('#timsChatInput').val() if options.prepend
|
||||
@ -843,6 +881,8 @@ the existing text. If `options.submit` is true the message will be sent to the s
|
||||
if options.submit
|
||||
do $('#timsChatForm').submit
|
||||
else
|
||||
$('#timsChatInput').setCaret options.caret if options.caret
|
||||
|
||||
do $('#timsChatInput').focus
|
||||
|
||||
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.
|
||||
|
@ -186,6 +186,8 @@ Probieren Sie, den Chat neu zu laden<!-- , bei Risiken und Nebenwirkungen fragen
|
||||
<item name="chat.global.message"><![CDATA[Nachricht]]></item>
|
||||
<item name="chat.global.whispers"><![CDATA[Flüstert]]></item>
|
||||
|
||||
<item name="chat.global.autoAway"><![CDATA[{literal}Automatische Abwesenheit{if $time}: {$time}{/if}{/literal}]]></item>
|
||||
|
||||
<item name="chat.global.information"><![CDATA[Information]]></item>
|
||||
<item name="chat.global.information.chatUpdate"><![CDATA[Der Chat wurde aktualisiert. Bitte laden Sie die Seite neu, da es sonst zu Fehlern kommen kann.]]></item>
|
||||
<item name="chat.global.information.suspension"><![CDATA[{lang}chat.suspension.{$suspension->type}{/lang} ({if $room}{$room}{else}{lang}chat.room.global{/lang}{/if})]]></item>
|
||||
|
@ -94,7 +94,7 @@
|
||||
<item name="wcf.acp.option.category.chat.general"><![CDATA[General]]></item>
|
||||
<item name="wcf.acp.option.module_chat"><![CDATA[Tim’s Chat]]></item>
|
||||
<item name="wcf.acp.option.chat_reloadtime"><![CDATA[Reload time]]></item>
|
||||
<item name="wcf.acp.option.chat_reloadtime.description"><![CDATA[Time between to requests to the server [time in seconds]]]></item>
|
||||
<item name="wcf.acp.option.chat_reloadtime.description"><![CDATA[Time between two requests to the server [time in seconds]]]></item>
|
||||
<item name="wcf.acp.option.chat_lastmessages"><![CDATA[Number of old messages]]></item>
|
||||
<item name="wcf.acp.option.chat_lastmessages.description"><![CDATA[Number of messages that will be shown when entering a chat room.]]></item>
|
||||
<item name="wcf.acp.option.chat_display_join_leave"><![CDATA[Show join and leaves]]></item>
|
||||
@ -186,6 +186,8 @@ Please try to reload the chat.]]></item>
|
||||
<item name="chat.global.message"><![CDATA[Message]]></item>
|
||||
<item name="chat.global.whispers"><![CDATA[Whispers]]></item>
|
||||
|
||||
<item name="chat.global.autoAway"><![CDATA[{literal}Automatically set to away{if $time} at {$time}{/if}{/literal}]]></item>
|
||||
|
||||
<item name="chat.global.information"><![CDATA[Information]]></item>
|
||||
<item name="chat.global.information.chatUpdate"><![CDATA[The chat was updated. Please reload the page.]]></item>
|
||||
<item name="chat.global.information.suspension"><![CDATA[{lang}chat.suspension.{$suspension->type}{/lang} ({if $room}{$room}{else}{lang}chat.room.global{/lang}{/if})]]></item>
|
||||
|
@ -36,6 +36,12 @@
|
||||
<minvalue>1</minvalue>
|
||||
<maxvalue>15</maxvalue>
|
||||
</option>
|
||||
<option name="chat_autoaway">
|
||||
<categoryname>chat.general</categoryname>
|
||||
<optiontype>integer</optiontype>
|
||||
<defaultvalue>1800</defaultvalue>
|
||||
<minvalue>0</minvalue>
|
||||
</option>
|
||||
<option name="chat_lastmessages">
|
||||
<categoryname>chat.general</categoryname>
|
||||
<optiontype>integer</optiontype>
|
||||
|
@ -11,6 +11,7 @@
|
||||
(function ($, window) {
|
||||
$(function(){
|
||||
WCF.Language.addObject({
|
||||
'chat.global.autoAway': '{lang}chat.global.autoAway{/lang}',
|
||||
'chat.global.ban': '{lang}chat.global.ban{/lang}',
|
||||
'chat.global.closePrivateChannel': '{lang}chat.global.closePrivateChannel{/lang}',
|
||||
'chat.global.closeTopic': '{lang}chat.global.closeTopic{/lang}',
|
||||
@ -56,7 +57,8 @@
|
||||
reloadTime: {@CHAT_RELOADTIME},
|
||||
messageURL: '{link application="chat" controller="NewMessages"}{/link}',
|
||||
installedCommands: [ {implode from=$commands item='command'}'{$command|encodeJS}'{/implode} ],
|
||||
messageTypes: { {implode from=$messageTypes key='name' item='messageType'}'{$name|substr:5|encodeJS}': {$messageType}{/implode} }
|
||||
messageTypes: { {implode from=$messageTypes key='name' item='messageType'}'{$name|substr:5|encodeJS}': {$messageType}{/implode} },
|
||||
autoAwayTime: {@CHAT_AUTOAWAY}
|
||||
};
|
||||
|
||||
{event name='beforeInit'}
|
||||
|
Loading…
Reference in New Issue
Block a user