mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40:08 +00:00
Merge branch 'master' of github.com:wbbaddons/Tims-Chat
Conflicts: file/js/TimWolla.WCF.Chat.coffee
This commit is contained in:
commit
b024554c29
@ -13,7 +13,9 @@ TimWolla.WCF ?= {}
|
|||||||
(($) ->
|
(($) ->
|
||||||
TimWolla.WCF.Chat =
|
TimWolla.WCF.Chat =
|
||||||
titleTemplate: null
|
titleTemplate: null
|
||||||
|
title: document.title
|
||||||
messageTemplate: null
|
messageTemplate: null
|
||||||
|
newMessageCount: null
|
||||||
init: () ->
|
init: () ->
|
||||||
@bindEvents()
|
@bindEvents()
|
||||||
@refreshRoomList()
|
@refreshRoomList()
|
||||||
@ -25,6 +27,19 @@ TimWolla.WCF ?= {}
|
|||||||
# Binds all the events needed for Tims Chat.
|
# Binds all the events needed for Tims Chat.
|
||||||
###
|
###
|
||||||
bindEvents: () ->
|
bindEvents: () ->
|
||||||
|
@isActive = true
|
||||||
|
$(window).focus $.proxy () ->
|
||||||
|
document.title = @title
|
||||||
|
@newMessageCount = 0
|
||||||
|
clearTimeout @timeout
|
||||||
|
@isActive = true
|
||||||
|
, this
|
||||||
|
|
||||||
|
$(window).blur $.proxy () ->
|
||||||
|
@title = document.title
|
||||||
|
@isActive = false
|
||||||
|
, this
|
||||||
|
|
||||||
$('.smiley').click $.proxy (event) ->
|
$('.smiley').click $.proxy (event) ->
|
||||||
@insertText ' ' + $(event.target).attr('alt') + ' '
|
@insertText ' ' + $(event.target).attr('alt') + ' '
|
||||||
, this
|
, this
|
||||||
@ -120,15 +135,20 @@ TimWolla.WCF ?= {}
|
|||||||
fish.appendTo $ 'body'
|
fish.appendTo $ 'body'
|
||||||
new WCF.PeriodicalExecuter(() ->
|
new WCF.PeriodicalExecuter(() ->
|
||||||
left = (Math.random() * 100 - 50)
|
left = (Math.random() * 100 - 50)
|
||||||
|
top = (Math.random() * 100 - 50)
|
||||||
|
fish = $('#fish')
|
||||||
|
|
||||||
$('#fish').text('><((((°>') if (left > 0)
|
left *= -1 if((fish.position().left + left) < (0 + fish.width()) or (fish.position().left + left) > ($(document).width() - fish.width()))
|
||||||
$('#fish').text('<°))))><') if (left < 0)
|
top *= -1 if((fish.position().top + top) < (0 + fish.height()) or (fish.position().top + top) > ($(document).height() - fish.height()))
|
||||||
|
|
||||||
$('#fish').animate
|
fish.text('><((((°>') if (left > 0)
|
||||||
top: '+=' + (Math.random() * 100 - 50)
|
fish.text('<°))))><') if (left < 0)
|
||||||
|
|
||||||
|
fish.animate
|
||||||
|
top: '+=' + top
|
||||||
left: '+=' + left
|
left: '+=' + left
|
||||||
, 1000
|
, 1000
|
||||||
, 3e3);
|
, 1.5e3);
|
||||||
###
|
###
|
||||||
# Loads new messages.
|
# Loads new messages.
|
||||||
###
|
###
|
||||||
@ -137,6 +157,15 @@ TimWolla.WCF ?= {}
|
|||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
type: 'POST'
|
type: 'POST'
|
||||||
success: $.proxy((data, textStatus, jqXHR) ->
|
success: $.proxy((data, textStatus, jqXHR) ->
|
||||||
|
if (!@isActive)
|
||||||
|
@newMessageCount += data.messages.length
|
||||||
|
if (@newMessageCount > 0)
|
||||||
|
@timeout = setTimeout $.proxy(() ->
|
||||||
|
document.title = @newMessageCount + WCF.Language.get('wcf.chat.newMessages')
|
||||||
|
setTimeout $.proxy(() ->
|
||||||
|
document.title = @title
|
||||||
|
, this), 3000
|
||||||
|
, this), 1000
|
||||||
@handleMessages(data.messages)
|
@handleMessages(data.messages)
|
||||||
, this)
|
, this)
|
||||||
###
|
###
|
||||||
|
Loading…
Reference in New Issue
Block a user