1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-26 22:20:08 +00:00
Tims-Chat/file/acp/js/be.bastelstu.Chat.ACP.Log.litcoffee

93 lines
2.7 KiB
Plaintext
Raw Normal View History

Tims Chat 3
===========
This is the javascript file providing functions related to the message log for [##Tims Chat##](https://github.com/wbbaddons/Tims-Chat).
### Copyright Information
# @author Maximilian Mader
2014-02-27 22:05:09 +00:00
# @copyright 2010-2014 Tim Düsterhus
# @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
# @package be.bastelstu.chat
###
## Code
(($, window) ->
"use strict";
_messageLogContent = null
_hasContent = {}
_proxy = null
init = ->
2013-09-05 19:59:03 +00:00
_messageLogContent = $ '#messageLogContent'
activeMenuItem = _messageLogContent.data 'active'
enableProxy = false
_messageLogContent.find('div.tabMenuContent > .subTabMenuContent').each (index, container) ->
containerID = $(container).wcfIdentify()
2013-09-05 19:59:03 +00:00
unless $("##{containerID}").hasClass 'empty'
_hasContent[containerID] = true
else
_hasContent[containerID] = false
enableProxy = true
2013-09-05 19:59:03 +00:00
if enableProxy
_proxy = new WCF.Action.Proxy
success: _success
_messageLogContent.bind 'wcftabsbeforeactivate',
_loadContent
2013-09-05 19:59:03 +00:00
if not _hasContent[activeMenuItem]
_loadContent {},
newPanel: $("##{activeMenuItem}")
newTab: $("##{activeMenuItem}").parent().find(".menu > ul > li").first()
_loadContent = (event, ui) ->
containerID = $(ui.newPanel).attr 'id'
2013-09-05 19:59:03 +00:00
if $("##{$(ui.newPanel).attr('id')}").hasClass 'tabMenuContainer'
containerID = $("##{containerID} > .subTabMenuContent").first().attr 'id'
tab = $("##{containerID}").parent().find(".menu > ul > li").first()
else
2013-09-05 19:59:03 +00:00
tab = $ ui.newTab
unless _hasContent[containerID]
start = _messageLogContent.data('baseTime') + (tab.data('hour') * 3600) + (tab.data('minutes') * 60)
_proxy.setOption 'data',
actionName: 'getMessages'
className: 'chat\\data\\message\\MessageAction'
parameters:
containerID: containerID
start: start
end: start + 1799
2013-09-05 19:59:03 +00:00
roomID: _messageLogContent.data 'roomID'
do _proxy.sendRequest
_success = (data, textStatus, jqWHR) ->
containerID = data.returnValues.containerID
_hasContent[containerID] = true
content = _messageLogContent.find "##{containerID}"
2013-09-05 19:59:03 +00:00
unless data.returnValues.template is ''
$("<div>#{data.returnValues.template}</div>").hide().appendTo content
2013-09-05 19:59:03 +00:00
unless data.returnValues.noMessages
content.addClass 'tabularBox'
2013-09-05 19:59:03 +00:00
do content.children().first().show
Log =
TabMenu:
init: init
window.be ?= {}
be.bastelstu ?= {}
be.bastelstu.Chat ?= {}
be.bastelstu.Chat.ACP ?= {}
be.bastelstu.Chat.ACP.Log ?= {}
window.be.bastelstu.Chat.ACP.Log = Log
)(jQuery, @)