1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-10-31 14:10:08 +00:00

Clean up CoffeeScript a bit

This commit is contained in:
Tim Düsterhus 2013-09-15 22:53:53 +02:00
parent cd926813bc
commit 14b453495c

View File

@ -93,8 +93,7 @@ When **Tims Chat** becomes focused mark the chat as active and remove the number
When **Tims Chat** loses the focus mark the chat as inactive.
$(window).blur ->
isActive = false
$(window).blur -> isActive = false
Make the user leave the chat when **Tims Chat** is about to be unloaded.
@ -113,13 +112,11 @@ Make the user leave the chat when **Tims Chat** is about to be unloaded.
Insert the appropriate smiley code into the input when a smiley is clicked.
$('#smilies').on 'click', 'img', ->
insertText " #{$(@).attr('alt')} "
$('#smilies').on 'click', 'img', -> insertText " #{$(@).attr('alt')} "
Handle private channel menu
$('#privateChannelsMenu').on 'click', '.privateChannel', ->
openPrivateChannel $(@).data 'privateChannelID'
$('#privateChannelsMenu').on 'click', '.privateChannel', -> openPrivateChannel $(@).data 'privateChannelID'
Handle submitting the form. The message will be validated by some basic checks, passed to the `submit` eventlisteners
and afterwards sent to the server by an AJAX request.
@ -132,8 +129,7 @@ and afterwards sent to the server by an AJAX request.
return false if text.length is 0
unless openChannel is 0
text = "/whisper #{userList.allTime[openChannel].username}, #{text}"
text = "/whisper #{userList.allTime[openChannel].username}, #{text}" unless openChannel is 0
# Free the fish!
do freeTheFish if text.toLowerCase() is '/free the fish'
@ -222,8 +218,7 @@ Reset autocompleter to default status, when the input is `click`ed, as the posit
Refresh the room list when the associated button is `click`ed.
$('#timsChatRoomList button').click ->
do refreshRoomList
$('#timsChatRoomList button').click -> do refreshRoomList
Clear the chat by removing every single message once the clear button is `clicked`.
@ -261,7 +256,7 @@ Toggle fullscreen mode.
# Force dropdowns to reorientate
$('.dropdownMenu').data 'orientationX', ''
if $('#timsChatFullscreen').data 'status'
if $(@).data 'status'
$('html').addClass 'fullscreen'
else
$('html').removeClass 'fullscreen'
@ -326,7 +321,7 @@ Ask for permissions to use Desktop notifications when notifications are activate
if window.Notification?
$('#timsChatNotify').click (event) ->
return unless $(@).data 'status'
if window.Notification.permission isnt 'granted'
unless window.Notification.permission is 'granted'
window.Notification.requestPermission (permission) ->
window.Notification.permission ?= permission
@ -682,9 +677,9 @@ Shows an unrecoverable error with the given text.
""").appendTo 'body'
formSubmit = $("""<div class="formSubmit"></div>""").appendTo errorDialog
reloadButton = $("""<button class="buttonPrimary">#{WCF.Language.get 'chat.error.reload'}</button>""").appendTo formSubmit
reloadButton.on 'click', ->
do window.location.reload
reloadButton.on 'click', -> do window.location.reload
$('#timsChatLoadingErrorDialog').wcfDialog
closable: false
@ -743,6 +738,7 @@ Open private channel
$('#timsChatMessageContainer0').after div
$('.privateChannel').removeClass 'active'
if userID isnt 0
$('#timsChatTopic').removeClass 'hidden empty'
$('#timsChatTopic > .topic').text WCF.Language.get 'chat.general.privateChannelTopic', {username: userList.allTime[userID].username}