From 331bcf30497594c5511f8bc87bae8e3fe70f2054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 21 Jan 2012 17:45:53 +0100 Subject: [PATCH] Code format and removing unneeded templatelistener --- file/js/TimWolla.WCF.Chat.coffee | 43 +++++++++++++++--------------- file/lib/page/ChatPage.class.php | 2 +- template/chat.tpl | 11 +++++++- template/chatJavascriptInclude.tpl | 4 +-- templatelistener.xml | 6 ----- 5 files changed, 34 insertions(+), 32 deletions(-) diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index fc0d442..ced68e3 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -23,8 +23,8 @@ TimWolla.WCF ?= {} console.log('[TimWolla.WCF.Chat] Initializing'); @bindEvents() @refreshRoomList() - new WCF.PeriodicalExecuter $.proxy(@refreshRoomList, this), 60e3 - new WCF.PeriodicalExecuter $.proxy(@getMessages, this), @config.reloadTime * 1000 + new WCF.PeriodicalExecuter $.proxy(@refreshRoomList, @), 60e3 + new WCF.PeriodicalExecuter $.proxy(@getMessages, @), @config.reloadTime * 1000 @getMessages() console.log '[TimWolla.WCF.Chat] Finished initializing' @@ -38,26 +38,26 @@ TimWolla.WCF ?= {} @newMessageCount = 0 clearTimeout @timeout @isActive = true - , this + , @ $(window).blur $.proxy () -> @title = document.title @isActive = false - , this + , @ $('.smiley').click $.proxy (event) -> @insertText ' ' + $(event.target).attr('alt') + ' ' - , this + , @ $('.chatSidebarTabs li').click $.proxy (event) -> event.preventDefault() @toggleSidebarContents $ event.target - , this + , @ $('#chatForm').submit $.proxy (event) -> event.preventDefault() @submit $ event.target - , this + , @ $('#chatClear').click (event) -> event.preventDefault() @@ -65,7 +65,7 @@ TimWolla.WCF ?= {} $('#chatInput').focus() $('.chatToggle').click (event) -> - element = $ this + element = $ @ icon = element.find 'img' if element.data('status') is 1 element.data 'status', 0 @@ -101,13 +101,14 @@ TimWolla.WCF ?= {} return if $('#topic').text().trim() is '' $('#topic').wcfBlindOut 'vertical', () -> - $(this).text '' + $(@).text '' else $('#topic').text data.topic $('#topic').wcfBlindIn() if $('#topic').text().trim() isnt '' and $('#topic').is(':hidden') $('title').text @titleTemplate.fetch(data) - , this) + @getMessages() + , @) error: () -> # reload page to change the room the old fashion-way # inclusive the error-message :) @@ -117,7 +118,7 @@ TimWolla.WCF ?= {} @loading = true target.parent().addClass 'ajaxLoad' - , this) + , @) ### # Frees the fish ### @@ -165,11 +166,11 @@ TimWolla.WCF ?= {} document.title = @newMessageCount + WCF.Language.get('wcf.chat.newMessages') setTimeout $.proxy(() -> document.title = @title - , this), 3000 - , this), 1000 + , @), 3000 + , @), 1000 @handleMessages(data.messages) @handleUsers(data.users) - , this) + , @) ### # Inserts the new messages. # @@ -207,7 +208,7 @@ TimWolla.WCF ?= {} a.click $.proxy (event) -> event.preventDefault() @toggleUserMenu $ event.target - , this + , @ li.append a menu = $ '' menu.addClass 'chatUserMenu' @@ -222,8 +223,8 @@ TimWolla.WCF ?= {} foundUsers[id] = true $('.chatUser').each () -> - if typeof foundUsers[$(this).attr('id')] is 'undefined' - $(this).remove() + if typeof foundUsers[$(@).attr('id')] is 'undefined' + $(@).remove() $('#toggleUsers .badge').text(users.length); ### @@ -271,10 +272,10 @@ TimWolla.WCF ?= {} return if typeof window.history.replaceState is 'undefined' event.preventDefault() @changeRoom $ event.target - , this + , @ console.log '[TimWolla.WCF.Chat] Found ' + data.length + ' rooms' - , this) + , @) ### # Handles submitting of messages. # @@ -297,7 +298,7 @@ TimWolla.WCF ?= {} @getMessages() $('#chatInput').val('').focus() $('#chatInput').keyup() - , this) + , @) complete: () -> $('#chatInput').removeClass 'ajaxLoad' ### @@ -334,4 +335,4 @@ TimWolla.WCF ?= {} else li.addClass 'activeMenuItem' li.find('.chatUserMenu').wcfBlindIn 'vertical' -)(jQuery, this) +)(jQuery, @) diff --git a/file/lib/page/ChatPage.class.php b/file/lib/page/ChatPage.class.php index 7c21fbd..a3922fb 100644 --- a/file/lib/page/ChatPage.class.php +++ b/file/lib/page/ChatPage.class.php @@ -63,7 +63,7 @@ public function readChatVersion() { public function readData() { parent::readData(); - $this->readRoom(); + $this->readRoom(); $this->userData['color'] = \wcf\util\ChatUtil::readUserData('color'); \wcf\util\ChatUtil::writeUserData(array('roomID' => $this->room->roomID)); $this->newestMessages = chat\message\ChatMessageList::getNewestMessages($this->room, CHAT_LASTMESSAGES); diff --git a/template/chat.tpl b/template/chat.tpl index 1ed3c21..bf8687e 100755 --- a/template/chat.tpl +++ b/template/chat.tpl @@ -183,13 +183,17 @@ +{include file='chatJavascriptInclude'} - -{/if} \ No newline at end of file + \ No newline at end of file diff --git a/templatelistener.xml b/templatelistener.xml index b9a38cc..e05fa92 100644 --- a/templatelistener.xml +++ b/templatelistener.xml @@ -1,12 +1,6 @@ - - user - headInclude - javascriptInclude - - user header