mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2025-01-09 00:20:08 +00:00
Simplify code a bit
This commit is contained in:
parent
a330127c0b
commit
3580ebfd5c
@ -710,12 +710,12 @@ Joins a room.
|
|||||||
showError WCF.Language.get 'chat.error.join'
|
showError WCF.Language.get 'chat.error.join'
|
||||||
|
|
||||||
Open private channel
|
Open private channel
|
||||||
|
|
||||||
openPrivateChannel = (userID) ->
|
openPrivateChannel = (userID) ->
|
||||||
userID = parseInt userID
|
userID = parseInt userID
|
||||||
|
|
||||||
console.log "Opening private channel #{userID}"
|
console.log "Opening private channel #{userID}"
|
||||||
|
|
||||||
unless $.wcfIsset "timsChatMessageContainer#{userID}"
|
unless $.wcfIsset "timsChatMessageContainer#{userID}"
|
||||||
return unless userList.allTime[userID]?
|
return unless userList.allTime[userID]?
|
||||||
|
|
||||||
@ -726,42 +726,28 @@ Open private channel
|
|||||||
div.addClass 'container'
|
div.addClass 'container'
|
||||||
div.wrapInner '<ul>'
|
div.wrapInner '<ul>'
|
||||||
$('#timsChatMessageContainer0').after div
|
$('#timsChatMessageContainer0').after div
|
||||||
|
|
||||||
channels = $ '#privateChannelsMenu li'
|
$('.privateChannel').removeClass 'active'
|
||||||
channels.removeClass 'active'
|
|
||||||
channels.each (key, channel) ->
|
|
||||||
channel = $ channel;
|
|
||||||
privateChannelID = channel.data 'privateChannelID'
|
|
||||||
|
|
||||||
if privateChannelID isnt 0
|
|
||||||
channel.find('.userAvatar > *').replaceWith userList.allTime[privateChannelID].avatar[16]
|
|
||||||
else
|
|
||||||
channel.find('.icon').removeClass('icon32').addClass 'icon16'
|
|
||||||
|
|
||||||
if userID isnt 0
|
if userID isnt 0
|
||||||
if $.wcfIsset "privateChannel#{userID}"
|
unless $.wcfIsset "privateChannel#{userID}"
|
||||||
$("#privateChannel#{userID} > .userAvatar > img").replaceWith userList.allTime[userID].avatar[32]
|
|
||||||
else
|
|
||||||
li = $ '<li>'
|
li = $ '<li>'
|
||||||
li.attr 'id', "privateChannel#{userID}"
|
li.attr 'id', "privateChannel#{userID}"
|
||||||
li.data 'privateChannelID', userID
|
li.data 'privateChannelID', userID
|
||||||
li.addClass 'privateChannel'
|
li.addClass 'privateChannel'
|
||||||
li.addClass 'active'
|
|
||||||
li.append userList.allTime[userID].avatar[32]
|
|
||||||
|
|
||||||
span = $ '<span class="userAvatar framed" />'
|
span = $ '<span class="userAvatar framed" />'
|
||||||
span.addClass 'jsTooltip'
|
span.addClass 'jsTooltip'
|
||||||
span.attr 'title', userList.allTime[userID].username
|
span.attr 'title', userList.allTime[userID].username
|
||||||
|
|
||||||
li.wrapInner span
|
li.append $(userList.allTime[userID].avatar[16]).wrap(span).parent().addClass 'small'
|
||||||
|
li.append $(userList.allTime[userID].avatar[32]).wrap(span).parent().addClass 'large'
|
||||||
|
|
||||||
$('#privateChannelsMenu ul').append li
|
$('#privateChannelsMenu ul').append li
|
||||||
|
|
||||||
do WCF.DOMNodeInsertedHandler.execute
|
do WCF.DOMNodeInsertedHandler.execute
|
||||||
|
|
||||||
$('#privateChannelsMenu').addClass 'shown'
|
$('#privateChannelsMenu').addClass 'shown'
|
||||||
else
|
|
||||||
$("#privateChannel0 > .userAvatar > .icon").removeClass('icon16').addClass 'icon32'
|
|
||||||
|
|
||||||
$('.timsChatMessageContainer').removeClass 'active'
|
$('.timsChatMessageContainer').removeClass 'active'
|
||||||
$("#timsChatMessageContainer#{userID}").addClass 'active'
|
$("#timsChatMessageContainer#{userID}").addClass 'active'
|
||||||
$("#privateChannel#{userID}").addClass 'active'
|
$("#privateChannel#{userID}").addClass 'active'
|
||||||
@ -773,7 +759,7 @@ Close private channel
|
|||||||
unless userID is 0
|
unless userID is 0
|
||||||
do $("#privateChannel#{userID}").remove
|
do $("#privateChannel#{userID}").remove
|
||||||
do $("#timsChatMessageContainer#{userID}").remove
|
do $("#timsChatMessageContainer#{userID}").remove
|
||||||
|
|
||||||
if $('#privateChannelsMenu li').length <= 1
|
if $('#privateChannelsMenu li').length <= 1
|
||||||
$('#privateChannelsMenu').removeClass 'shown'
|
$('#privateChannelsMenu').removeClass 'shown'
|
||||||
|
|
||||||
@ -809,7 +795,7 @@ And finally export the public methods and variables.
|
|||||||
listener:
|
listener:
|
||||||
add: addListener
|
add: addListener
|
||||||
remove: removeListener
|
remove: removeListener
|
||||||
|
|
||||||
window.be ?= {}
|
window.be ?= {}
|
||||||
be.bastelstu ?= {}
|
be.bastelstu ?= {}
|
||||||
window.be.bastelstu.Chat = Chat
|
window.be.bastelstu.Chat = Chat
|
||||||
|
@ -102,20 +102,40 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
> .userAvatar.framed {
|
> .userAvatar {
|
||||||
> .icon {
|
&.large {
|
||||||
background-color: @wcfContentBackgroundColor;
|
display: none;
|
||||||
border: 1px solid @wcfContainerBorderColor;
|
}
|
||||||
padding: 1px;
|
|
||||||
|
&.small {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.framed {
|
||||||
|
> .icon {
|
||||||
|
background-color: @wcfContentBackgroundColor;
|
||||||
|
border: 1px solid @wcfContainerBorderColor;
|
||||||
|
padding: 1px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
> .userAvatar.framed {
|
> .userAvatar {
|
||||||
> img, > canvas, > .icon {
|
&.large {
|
||||||
border-right-color: @wcfContentBackgroundColor;
|
display: block;
|
||||||
|
}
|
||||||
border-radius: @wcfContainerBorderRadius 0 0 @wcfContainerBorderRadius;
|
|
||||||
|
&.small {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.framed {
|
||||||
|
> img, > canvas, > .icon {
|
||||||
|
border-right-color: @wcfContentBackgroundColor;
|
||||||
|
|
||||||
|
border-radius: @wcfContainerBorderRadius 0 0 @wcfContainerBorderRadius;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,14 @@
|
|||||||
|
|
||||||
<div id="privateChannelsMenu">
|
<div id="privateChannelsMenu">
|
||||||
<ul>
|
<ul>
|
||||||
<li id="privateChannel0" class="privateChannel active" data-private-channel-id="0"><span class="userAvatar framed jsTooltip" title="{lang}chat.general.room{/lang}"><span class="icon icon32 icon-comment-alt"></span></span></li>
|
<li id="privateChannel0" class="privateChannel active" data-private-channel-id="0">
|
||||||
|
<span class="userAvatar framed jsTooltip small" title="{lang}chat.general.room{/lang}">
|
||||||
|
<span class="icon icon16 icon-comment-alt"></span>
|
||||||
|
</span>
|
||||||
|
<span class="userAvatar framed jsTooltip large" title="{lang}chat.general.room{/lang}">
|
||||||
|
<span class="icon icon32 icon-comment-alt"></span>
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user