mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40:08 +00:00
More JSDoc
This commit is contained in:
parent
d275f86498
commit
d2f9858734
@ -1,10 +1,10 @@
|
|||||||
###
|
###
|
||||||
TimWolla.WCF.Chat
|
# TimWolla.WCF.Chat
|
||||||
|
#
|
||||||
@author Tim Düsterhus
|
# @author Tim Düsterhus
|
||||||
@copyright 2010-2011 Tim Düsterhus
|
# @copyright 2010-2011 Tim Düsterhus
|
||||||
@license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
# @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
||||||
@package timwolla.wcf.chat
|
# @package timwolla.wcf.chat
|
||||||
###
|
###
|
||||||
|
|
||||||
TimWolla ?= {}
|
TimWolla ?= {}
|
||||||
@ -20,6 +20,9 @@ TimWolla.WCF ?= {}
|
|||||||
new WCF.PeriodicalExecuter $.proxy(this.refreshRoomList, this), 10e3
|
new WCF.PeriodicalExecuter $.proxy(this.refreshRoomList, this), 10e3
|
||||||
|
|
||||||
$('#chatInput').focus()
|
$('#chatInput').focus()
|
||||||
|
###
|
||||||
|
# Binds all the events needed for Tims Chat.
|
||||||
|
###
|
||||||
bindEvents: () ->
|
bindEvents: () ->
|
||||||
$('.smiley').click $.proxy (event) ->
|
$('.smiley').click $.proxy (event) ->
|
||||||
this.insertText ' ' + $(event.target).attr('alt') + ' '
|
this.insertText ' ' + $(event.target).attr('alt') + ' '
|
||||||
@ -56,6 +59,11 @@ TimWolla.WCF ?= {}
|
|||||||
element.data 'status', 1
|
element.data 'status', 1
|
||||||
icon.attr 'src', icon.attr('src').replace /disabled(\d?).([a-z]{3})$/, 'enabled$1.$2'
|
icon.attr 'src', icon.attr('src').replace /disabled(\d?).([a-z]{3})$/, 'enabled$1.$2'
|
||||||
element.attr 'title', element.data 'disableMessage'
|
element.attr 'title', element.data 'disableMessage'
|
||||||
|
###
|
||||||
|
# Changes the chat-room.
|
||||||
|
#
|
||||||
|
# @param jQuery-object target
|
||||||
|
###
|
||||||
changeRoom: (target) ->
|
changeRoom: (target) ->
|
||||||
window.history.replaceState {}, '', target.attr('href')
|
window.history.replaceState {}, '', target.attr('href')
|
||||||
|
|
||||||
@ -94,7 +102,15 @@ TimWolla.WCF ?= {}
|
|||||||
this.loading = true
|
this.loading = true
|
||||||
target.parent().addClass 'ajaxLoad'
|
target.parent().addClass 'ajaxLoad'
|
||||||
, this)
|
, this)
|
||||||
|
###
|
||||||
|
# Loads new messages.
|
||||||
|
###
|
||||||
getMessages: () ->
|
getMessages: () ->
|
||||||
|
###
|
||||||
|
# Inserts the new messages.
|
||||||
|
#
|
||||||
|
# @param array<object> messages
|
||||||
|
###
|
||||||
handleMessages: (messages) ->
|
handleMessages: (messages) ->
|
||||||
for message in messages
|
for message in messages
|
||||||
output = this.messageTemplate.fetch message
|
output = this.messageTemplate.fetch message
|
||||||
@ -107,6 +123,12 @@ TimWolla.WCF ?= {}
|
|||||||
$('.chatMessageContainer').animate
|
$('.chatMessageContainer').animate
|
||||||
scrollTop: $('.chatMessageContainer ul').height()
|
scrollTop: $('.chatMessageContainer ul').height()
|
||||||
, 1000
|
, 1000
|
||||||
|
###
|
||||||
|
# Inserts text into our input.
|
||||||
|
#
|
||||||
|
# @param string text
|
||||||
|
# @param object options
|
||||||
|
###
|
||||||
insertText: (text, options) ->
|
insertText: (text, options) ->
|
||||||
options = $.extend
|
options = $.extend
|
||||||
append: true
|
append: true
|
||||||
@ -121,6 +143,9 @@ TimWolla.WCF ?= {}
|
|||||||
$('#chatForm').submit()
|
$('#chatForm').submit()
|
||||||
else
|
else
|
||||||
$('#chatInput').focus()
|
$('#chatInput').focus()
|
||||||
|
###
|
||||||
|
# Refreshes the room-list.
|
||||||
|
###
|
||||||
refreshRoomList: () ->
|
refreshRoomList: () ->
|
||||||
$('.chatRoom').unbind 'click'
|
$('.chatRoom').unbind 'click'
|
||||||
$('#toggleRooms a').addClass 'ajaxLoad'
|
$('#toggleRooms a').addClass 'ajaxLoad'
|
||||||
@ -142,6 +167,11 @@ TimWolla.WCF ?= {}
|
|||||||
this.changeRoom $ event.target
|
this.changeRoom $ event.target
|
||||||
, this
|
, this
|
||||||
, this)
|
, this)
|
||||||
|
###
|
||||||
|
# Handles submitting of messages.
|
||||||
|
#
|
||||||
|
# @param jQuery-object target
|
||||||
|
###
|
||||||
submit: (target) ->
|
submit: (target) ->
|
||||||
# break if input contains only whitespace
|
# break if input contains only whitespace
|
||||||
return false if $('#chatInput').val().trim().length == 0
|
return false if $('#chatInput').val().trim().length == 0
|
||||||
@ -159,6 +189,11 @@ TimWolla.WCF ?= {}
|
|||||||
, this)
|
, this)
|
||||||
complete: () ->
|
complete: () ->
|
||||||
$('#chatInput').removeClass 'ajaxLoad'
|
$('#chatInput').removeClass 'ajaxLoad'
|
||||||
|
###
|
||||||
|
# Toggles between user- and room-list.
|
||||||
|
#
|
||||||
|
# @param jQuery-object target
|
||||||
|
###
|
||||||
toggleSidebarContents: (target) ->
|
toggleSidebarContents: (target) ->
|
||||||
return if target.parent().hasClass 'active'
|
return if target.parent().hasClass 'active'
|
||||||
|
|
||||||
@ -174,6 +209,11 @@ TimWolla.WCF ?= {}
|
|||||||
|
|
||||||
$('#chatUserList').hide()
|
$('#chatUserList').hide()
|
||||||
$('#chatRoomList').show()
|
$('#chatRoomList').show()
|
||||||
|
###
|
||||||
|
# Toggles the user-menu.
|
||||||
|
#
|
||||||
|
# @param jQuery-object target
|
||||||
|
###
|
||||||
toggleUserMenu: (target) ->
|
toggleUserMenu: (target) ->
|
||||||
liUserID = '#' + target.parent().parent().attr 'id'
|
liUserID = '#' + target.parent().parent().attr 'id'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user