diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index a89c39d..79ec66d 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -64,6 +64,7 @@ consoleMock ?= # Binds all the events needed for Tims Chat. ### bindEvents: () -> + # Mark window as focused $(window).focus $.proxy () -> document.title = @titleTemplate.fetch title: $('#timsChatRoomList .activeMenuItem a').text() @@ -71,10 +72,16 @@ consoleMock ?= @isActive = true , @ + # Mark window as blurred $(window).blur $.proxy () -> @isActive = false , @ + # Unload the chat + $(window).unload $.proxy () -> + @unload() + , @ + # Insert a smiley $('.smiley').click $.proxy (event) -> @insertText ' ' + $(event.target).attr('alt') + ' ' @@ -449,4 +456,11 @@ consoleMock ?= else li.addClass 'activeMenuItem' li.find('.timsChatUserMenu').wcfBlindIn 'vertical' + ### + # Unloads the chat. + ### + unload: () -> + $.ajax @config.unloadURL, + type: 'POST' + async: false )(jQuery, @, consoleMock) diff --git a/template/chat.tpl b/template/chat.tpl index 3dd7fa4..4d4198a 100755 --- a/template/chat.tpl +++ b/template/chat.tpl @@ -186,8 +186,7 @@ // populate config TimWolla.WCF.Chat.config = { reloadTime: {@CHAT_RELOADTIME}, - animations: {@CHAT_ANIMATIONS}, - maxTextLength: {@CHAT_LENGTH} + unloadURL: '{link controller='Chat' action='Leave'}{/link}' } WCF.Language.addObject({ 'wcf.chat.query': '{lang}wcf.chat.query{/lang}',