pane.js

CandyChats are not dead yet.

Authors

Copyright

© 2011 Amiado Group AG.  All rights reserved.  © 2012-2014 Patrick Stadler & Michael Weibel.  All rights reserved.

Summary
pane.js
Candy.View.PaneCandy view pane handles everything regarding DOM updates etc.
Candy.View.Pane.WindowWindow related view updates
Variables
autoscrollBoolean whether autoscroll is enabled
Functions
hasFocusChecks if window has focus
increaseUnreadMessagesIncreases unread message count in window title by one.
reduceUnreadMessagesReduce unread message count in window title by `num`.
clearUnreadMessagesClear unread message count in window title.
renderUnreadMessagesUpdate window title to show message count.
onFocusWindow focus event handler.
onBlurWindow blur event handler.
Candy.View.Pane.ChatChat-View related view updates
Variables
roomsContains opened room elements
Functions
addTabAdd a tab to the chat pane.
getTabGet tab by JID.
removeTabRemove tab element.
setActiveTabSet the active tab.
increaseUnreadMessagesIncrease unread message count in a tab by one.
clearUnreadMessagesClear unread message count in a tab.
tabClickTab click event: show the room associated with the tab and stops the event from doing the default.
tabCloseTab close (click) event: Leave the room (groupchat) or simply close the tab (chat).
allTabsClosedAll tabs closed event: Disconnect from service.
fitTabsFit tab size according to window size
adminMessageDisplay admin message
Events
candy:view.chat.admin-messageAfter admin message display
Functions
infoMessageDisplay info message.
onInfoMessageDisplay info message.
Candy.View.Pane.ToolbarChat toolbar for things like emoticons toolbar, room management etc.
Functions
initRegister handler and enable or disable sound and status messages.
showShow toolbar.
hideHide toolbar.
updateUpdate toolbar for specific room
playSoundPlay sound (default method).
onPlaySoundSound play event handler.
onSoundControlClickSound control click event handler.
onAutoscrollControlClickAutoscroll control event handler.
onStatusMessageControlClickStatus message control event handler.
updateUserCountUpdate usercount element with count.
Candy.View.Pane.ModalModal window
Functions
showDisplay modal window
hideHide modal window
showSpinnerShow loading spinner
hideSpinnerHide loading spinner
showCloseControlShow a close button
hideCloseControlHide the close button
showLoginFormShow the login form modal
showEnterPasswordFormShows a form for entering room password
showNicknameConflictFormShows a form indicating that the nickname is already taken and for chosing a new nickname
showErrorShow modal containing error message
Candy.View.Pane.TooltipClass to display tooltips over specific elements
Functions
showShow a tooltip on event.currentTarget with content specified or content within the target’s attribute data-tooltip.
Candy.View.Pane.ContextContext menu for actions and settings
Functions
initInitialize context menu and setup mouseleave handler.
showShow context menu (positions it according to the window height/width)
Events
candy:view.roster.after-context-menuAfter context menu display
Functions
getMenuLinksExtends initialMenuLinks with menu links gathered from candy:view.roster.contextmenu
Events
candy:view.roster.context-menuModify existing menu links (add links)
Functions
initialMenuLinks
showEmoticonsMenuShows the special emoticons menu
Candy.View.Pane.RoomEverything which belongs to room view things belongs here.
Functions
initInitialize a new room and inserts the room html into the DOM
Events
candy:view.room.before-addBefore initialising a room
candy:view.room.after-addAfter initialising a room
Functions
showShow a specific room and hides the other rooms (if there are any)
Events
candy:view.room.after-showAfter showing a room
candy:view.room.after-hideAfter hiding a room
Functions
setSubjectCalled when someone changes the subject in the channel
Events
candy:view.room.after-subject-changeAfter changing the subject of a room
Functions
closeClose a room and remove everything in the DOM belonging to this room.
Events
candy:view.room.after-closeAfter closing a room
Functions
appendToMessagePaneAppend a new message to the message pane.
sliceMessagePaneSlices the message pane after the max amount of messages specified in the Candy View options (limit setting).
scrollToBottomScroll to bottom wrapper for onScrollToBottom to be able to disable it by overwriting the function.
onScrollToBottomScrolls to the latest message received/sent.
onScrollToStoredPositionWhen autoscroll is off, the position where the scrollbar is has to be stored for each room, because it otherwise goes to the top in the message window.
setFocusToFormSet focus to the message input field within the message form.
setUserSets or updates the current user in the specified room (called by <Candy.View.Pane.Roster.update>) and set specific informations (roles and affiliations) on the room tab (chat-pane).
getUserGet the current user in the room specified with the jid
ignoreUserIgnore specified user and add the ignore icon to the roster item of the user
unignoreUserUnignore an ignored user and remove the ignore icon of the roster item.
addIgnoreIconAdd the ignore icon to the roster item of the specified user
removeIgnoreIconRemove the ignore icon to the roster item of the specified user
getPaneGet the chat room pane or a subPane of it (if subPane is specified)
changeDataUserJidIfUserIsMeChanges the room’s data-userjid attribute if the specified user is the current user.
Candy.View.Pane.PrivateRoomPrivate room handling
Functions
openOpens a new private room
Events
candy:view.private-room.before-openBefore opening a new private room
candy:view.private-room.after-openAfter opening a new private room
Functions
setStatusSet offline or online status for private rooms (when one of the participants leaves the room)
changeNickChanges the nick for every private room opened with this roomJid.
updateCalled by Candy.View.Observer.Presence.update to update the roster if needed.
Events
candy:view.roster.before-updateBefore updating the roster of a room
candy:view.roster.after-updateAfter updating a room’s roster
Functions
userClickClick handler for opening a private room
showJoinAnimationShows join animation if needed
joinAnimationAnimates specified elementId on join
leaveAnimationLeave animation for specified element id and removes the DOM element on completion.
changeNickChange nick of an existing user in the roster
Candy.View.Pane.MessageMessage submit/show handling
Functions
submiton submit handler for message field sends the message to the server and if it’s a private chat, shows the message immediately because the server doesn’t send back those message.
Events
candy:view.message.before-sendBefore sending a message
Functions
showShow a message in the message pane
Events
candy:view.message.before-showBefore showing a new message
candy:view.message.before-renderBefore rendering the message element
candy:view.message.after-showTriggered after showing a message

Candy.View.Pane

Candy view pane handles everything regarding DOM updates etc.

Parameters

(Candy.View.Pane) selfitself
(jQuery) $jQuery

Candy.View.Pane.Window

Window related view updates

Summary
Variables
autoscrollBoolean whether autoscroll is enabled
Functions
hasFocusChecks if window has focus
increaseUnreadMessagesIncreases unread message count in window title by one.
reduceUnreadMessagesReduce unread message count in window title by `num`.
clearUnreadMessagesClear unread message count in window title.
renderUnreadMessagesUpdate window title to show message count.
onFocusWindow focus event handler.
onBlurWindow blur event handler.

Variables

autoscroll

autoscroll: true

Boolean whether autoscroll is enabled

Functions

hasFocus

hasFocus: function()

Checks if window has focus

Returns

(Boolean)

increaseUnreadMessages

increaseUnreadMessages: function()

Increases unread message count in window title by one.

reduceUnreadMessages

reduceUnreadMessages: function(num)

Reduce unread message count in window title by `num`.

Parameters

(Integer) numUnread message count will be reduced by this value

clearUnreadMessages

clearUnreadMessages: function()

Clear unread message count in window title.

renderUnreadMessages

renderUnreadMessages: function(count)

Update window title to show message count.

Parameters

(Integer) countNumber of unread messages to show in window title

onFocus

onFocus: function()

Window focus event handler.

onBlur

onBlur: function()

Window blur event handler.

Candy.View.Pane.Chat

Chat-View related view updates

Summary
Variables
roomsContains opened room elements
Functions
addTabAdd a tab to the chat pane.
getTabGet tab by JID.
removeTabRemove tab element.
setActiveTabSet the active tab.
increaseUnreadMessagesIncrease unread message count in a tab by one.
clearUnreadMessagesClear unread message count in a tab.
tabClickTab click event: show the room associated with the tab and stops the event from doing the default.
tabCloseTab close (click) event: Leave the room (groupchat) or simply close the tab (chat).
allTabsClosedAll tabs closed event: Disconnect from service.
fitTabsFit tab size according to window size
adminMessageDisplay admin message
Events
candy:view.chat.admin-messageAfter admin message display
Functions
infoMessageDisplay info message.
onInfoMessageDisplay info message.

Variables

rooms

rooms: []

Contains opened room elements

Functions

addTab

addTab: function(roomJid,
roomName,
roomType)

Add a tab to the chat pane.

Parameters

(String) roomJidJID of room
(String) roomNameTab label
(String) roomTypeType of room: `groupchat` or `chat`

getTab

getTab: function(roomJid)

Get tab by JID.

Parameters

(String) roomJidJID of room

Returns

(jQuery object)Tab element

removeTab

removeTab: function(roomJid)

Remove tab element.

Parameters

(String) roomJidJID of room

setActiveTab

setActiveTab: function(roomJid)

Set the active tab.

Add CSS classname `active` to the choosen tab and remove `active` from all other.

Parameters

(String) roomJidJID of room

increaseUnreadMessages

increaseUnreadMessages: function(roomJid)

Increase unread message count in a tab by one.

Parameters

(String) roomJidJID of room

Uses

clearUnreadMessages

clearUnreadMessages: function(roomJid)

Clear unread message count in a tab.

Parameters

(String) roomJidJID of room

Uses

tabClick

tabClick: function(e)

Tab click event: show the room associated with the tab and stops the event from doing the default.

tabClose

tabClose: function()

Tab close (click) event: Leave the room (groupchat) or simply close the tab (chat).

Parameters

(DOMEvent) eEvent triggered

Returns

(Boolean)false, this will stop the event from bubbling

allTabsClosed

allTabsClosed: function()

All tabs closed event: Disconnect from service.  Hide sound control.

TODO: Handle window close

Returns

(Boolean)false, this will stop the event from bubbling

fitTabs

fitTabs: function()

Fit tab size according to window size

adminMessage

adminMessage: function(subject,
message)

Display admin message

Parameters

(String) subjectAdmin message subject
(String) messageMessage to be displayed

Triggers

candy:view.chat.admin-message using {subject, message}

Events

candy:view.chat.admin-message

After admin message display

Parameters

(String) presetJidPreset user JID

Functions

infoMessage

infoMessage: function(roomJid,
subject,
message)

Display info message.  This is a wrapper for onInfoMessage to be able to disable certain info messages.

Parameters

(String) roomJidRoom JID
(String) subjectSubject
(String) messageMessage

onInfoMessage

onInfoMessage: function(roomJid,
subject,
message)

Display info message.  Used by infoMessage and several other functions which do not wish that their info message can be disabled (such as kick/ban message or leave/join message in private chats).

Parameters

(String) roomJidRoom JID
(String) subjectSubject
(String) messageMessage

Candy.View.Pane.Toolbar

Chat toolbar for things like emoticons toolbar, room management etc.

Summary
Functions
initRegister handler and enable or disable sound and status messages.
showShow toolbar.
hideHide toolbar.
updateUpdate toolbar for specific room
playSoundPlay sound (default method).
onPlaySoundSound play event handler.
onSoundControlClickSound control click event handler.
onAutoscrollControlClickAutoscroll control event handler.
onStatusMessageControlClickStatus message control event handler.
updateUserCountUpdate usercount element with count.

Functions

init

init: function()

Register handler and enable or disable sound and status messages.

show

show: function()

Show toolbar.

hide

hide: function()

Hide toolbar.

update

update: function(roomJid)

Update toolbar for specific room

playSound

playSound: function()

Play sound (default method).

onPlaySound

onPlaySound: function()

Sound play event handler.  Uses native (HTML5) audio if supported

Don’t call this method directly.  Call `playSound()` instead.  `playSound()` will only call this method if sound is enabled.

onSoundControlClick

onSoundControlClick: function()

Sound control click event handler.

Toggle sound (overwrite `playSound()`) and handle cookies.

onAutoscrollControlClick

onAutoscrollControlClick: function()

Autoscroll control event handler.

Toggle autoscroll

onStatusMessageControlClick

onStatusMessageControlClick: function()

Status message control event handler.

Toggle status message

updateUserCount

Update usercount element with count.

Parameters

(Integer) countCurrent usercount

Candy.View.Pane.Modal

Modal window

Summary
Functions
showDisplay modal window
hideHide modal window
showSpinnerShow loading spinner
hideSpinnerHide loading spinner
showCloseControlShow a close button
hideCloseControlHide the close button
showLoginFormShow the login form modal
showEnterPasswordFormShows a form for entering room password
showNicknameConflictFormShows a form indicating that the nickname is already taken and for chosing a new nickname
showErrorShow modal containing error message

Functions

show

show: function(html,
showCloseControl,
showSpinner)

Display modal window

Parameters

(String) htmlHTML code to put into the modal window
(Boolean) showCloseControlset to true if a close button should be displayed [default false]
(Boolean) showSpinnerset to true if a loading spinner should be shown [default false]

hide

hide: function(callback)

Hide modal window

Parameters

(Function) callbackCalls the specified function after modal window has been hidden.

showSpinner

showSpinner: function()

Show loading spinner

hideSpinner

hideSpinner: function()

Hide loading spinner

showCloseControl

showCloseControl: function()

Show a close button

hideCloseControl

hideCloseControl: function()

Hide the close button

showLoginForm

showLoginForm: function(message,
presetJid)

Show the login form modal

Parameters

(String) messageoptional message to display above the form
(String) presetJidoptional user jid. if set, the user will only be prompted for password.

showEnterPasswordForm

showEnterPasswordForm: function(roomJid,
roomName,
message)

Shows a form for entering room password

Parameters

(String) roomJidRoom jid to join
(String) roomNameRoom name
(String) message[optional] Message to show as the label

showNicknameConflictForm

showNicknameConflictForm: function(roomJid)

Shows a form indicating that the nickname is already taken and for chosing a new nickname

Parameters

(String) roomJidRoom jid to join

showError

showError: function(message,
replacements)

Show modal containing error message

Parameters

(String) messagekey of translation to display
(Array) replacementsarray containing replacements for translation (%s)

Candy.View.Pane.Tooltip

Class to display tooltips over specific elements

Summary
Functions
showShow a tooltip on event.currentTarget with content specified or content within the target’s attribute data-tooltip.

Functions

show

show: function(event,
content)

Show a tooltip on event.currentTarget with content specified or content within the target’s attribute data-tooltip.

On mouseleave on the target, hide the tooltip.

Parameters

(Event) eventTriggered event
(String) contentContent to display [optional]

Candy.View.Pane.Context

Context menu for actions and settings

Summary
Functions
initInitialize context menu and setup mouseleave handler.
showShow context menu (positions it according to the window height/width)
Events
candy:view.roster.after-context-menuAfter context menu display
Functions
getMenuLinksExtends initialMenuLinks with menu links gathered from candy:view.roster.contextmenu
Events
candy:view.roster.context-menuModify existing menu links (add links)
Functions
initialMenuLinks
showEmoticonsMenuShows the special emoticons menu

Functions

init

init: function()

Initialize context menu and setup mouseleave handler.

show

show: function(elem,
roomJid,
user)

Show context menu (positions it according to the window height/width)

Parameters

(Element) elemOn which element it should be shown
(String) roomJidRoom Jid of the room it should be shown
(Candy.Core.chatUser) userUser

Uses

getMenuLinks for getting menulinks the user has access to Candy.Util.getPosLeftAccordingToWindowBounds for positioning Candy.Util.getPosTopAccordingToWindowBounds for positioning

Triggers

candy:view.roster.after-context-menu using {roomJid, user, elements}

Events

candy:view.roster.after-context-menu

After context menu display

Parameters

(String) roomJidroom where the context menu has been triggered
(Candy.Core.ChatUser) userUser
(jQuery.Element) elementMenu element

Functions

getMenuLinks

getMenuLinks: function(roomJid,
user,
elem)

Extends initialMenuLinks with menu links gathered from candy:view.roster.contextmenu

Parameters

(String) roomJidRoom in which the menu will be displayed
(Candy.Core.ChatUser) userUser
(jQuery.Element) elemParent element of the context menu

Triggers

candy:view.roster.context-menu using {roomJid, user, elem}

Returns

(Object)object containing the extended menulinks.

Events

candy:view.roster.context-menu

Modify existing menu links (add links)

In order to modify the links you need to change the object passed with an additional key “menulinks” containing the menulink object.

Parameters

(String) roomJidRoom on which the menu should be displayed
(Candy.Core.ChatUser) userUser
(jQuery.Element) elemParent element of the context menu

Functions

initialMenuLinks

initialMenuLinks: function()

Returns initial menulinks.  The following are initial

  • Private Chat
  • Ignore
  • Unignore
  • Kick
  • Ban
  • Change Subject

Returns

(Object)object containing those menulinks

showEmoticonsMenu

showEmoticonsMenu: function(elem)

Shows the special emoticons menu

Parameters

(Element) elemElement on which it should be positioned to.

Returns

(Boolean)true

Candy.View.Pane.Room

Everything which belongs to room view things belongs here.

Summary
Functions
initInitialize a new room and inserts the room html into the DOM
Events
candy:view.room.before-addBefore initialising a room
candy:view.room.after-addAfter initialising a room
Functions
showShow a specific room and hides the other rooms (if there are any)
Events
candy:view.room.after-showAfter showing a room
candy:view.room.after-hideAfter hiding a room
Functions
setSubjectCalled when someone changes the subject in the channel
Events
candy:view.room.after-subject-changeAfter changing the subject of a room
Functions
closeClose a room and remove everything in the DOM belonging to this room.
Events
candy:view.room.after-closeAfter closing a room
Functions
appendToMessagePaneAppend a new message to the message pane.
sliceMessagePaneSlices the message pane after the max amount of messages specified in the Candy View options (limit setting).
scrollToBottomScroll to bottom wrapper for onScrollToBottom to be able to disable it by overwriting the function.
onScrollToBottomScrolls to the latest message received/sent.
onScrollToStoredPositionWhen autoscroll is off, the position where the scrollbar is has to be stored for each room, because it otherwise goes to the top in the message window.
setFocusToFormSet focus to the message input field within the message form.
setUserSets or updates the current user in the specified room (called by <Candy.View.Pane.Roster.update>) and set specific informations (roles and affiliations) on the room tab (chat-pane).
getUserGet the current user in the room specified with the jid
ignoreUserIgnore specified user and add the ignore icon to the roster item of the user
unignoreUserUnignore an ignored user and remove the ignore icon of the roster item.
addIgnoreIconAdd the ignore icon to the roster item of the specified user
removeIgnoreIconRemove the ignore icon to the roster item of the specified user
getPaneGet the chat room pane or a subPane of it (if subPane is specified)
changeDataUserJidIfUserIsMeChanges the room’s data-userjid attribute if the specified user is the current user.

Functions

init

init: function(roomJid,
roomName,
roomType)

Initialize a new room and inserts the room html into the DOM

Parameters

(String) roomJidRoom JID
(String) roomNameRoom name
(String) roomTypeType: either “groupchat” or “chat” (private chat)

Uses

Triggers

candy:view.room.after-add using {roomJid, type, element}

Returns

(String)the room id of the element created.

Events

candy:view.room.before-add

Before initialising a room

Parameters

(String) roomJidRoom JID
(String) typeRoom Type

Returns

Booleanif you don’t want to initialise the room, return false.

candy:view.room.after-add

After initialising a room

Parameters

(String) roomJidRoom JID
(String) typeRoom Type
(jQuery.Element) elementRoom element

Functions

show

show: function(roomJid)

Show a specific room and hides the other rooms (if there are any)

Parameters

(String) roomJidroom jid to show

Triggers

candy:view.room.after-show using {roomJid, element} candy:view.room.after-hide using {roomJid, element}

Events

candy:view.room.after-show

After showing a room

Parameters

(String) roomJidRoom JID
(jQuery.Element) elementRoom element

candy:view.room.after-hide

After hiding a room

Parameters

(String) roomJidRoom JID
(jQuery.Element) elementRoom element

Functions

setSubject

setSubject: function(roomJid,
subject)

Called when someone changes the subject in the channel

Triggers

candy:view.room.after-subject-change using {roomJid, element, subject}

Parameters

(String) roomJidRoom Jid
(String) subjectThe new subject

Events

candy:view.room.after-subject-change

After changing the subject of a room

Parameters

(String) roomJidRoom JID
(jQuery.Element) elementRoom element
(String) subjectNew subject

Functions

close

close: function(roomJid)

Close a room and remove everything in the DOM belonging to this room.

NOTICE: There’s a rendering bug in Opera when all rooms have been closed.  (Take a look in the source for a more detailed description)

Triggers

candy:view.room.after-close using {roomJid}

Parameters

(String) roomJidRoom to close

Events

candy:view.room.after-close

After closing a room

Parameters

(String) roomJidRoom JID

Functions

appendToMessagePane

appendToMessagePane: function(roomJid,
html)

Append a new message to the message pane.

Parameters

(String) roomJidRoom JID
(String) htmlrendered message html

sliceMessagePane

sliceMessagePane: function(roomJid)

Slices the message pane after the max amount of messages specified in the Candy View options (limit setting).

This is done to hopefully prevent browsers from getting slow after a certain amount of messages in the DOM.

The slice is only done when autoscroll is on, because otherwise someone might lose exactly the message he want to look for.

Parameters

(String) roomJidRoom JID

scrollToBottom

scrollToBottom: function(roomJid)

Scroll to bottom wrapper for onScrollToBottom to be able to disable it by overwriting the function.

Parameters

(String) roomJidRoom JID

Uses

onScrollToBottom

onScrollToBottom: function(roomJid)

Scrolls to the latest message received/sent.

Parameters

(String) roomJidRoom JID

onScrollToStoredPosition

onScrollToStoredPosition: function(roomJid)

When autoscroll is off, the position where the scrollbar is has to be stored for each room, because it otherwise goes to the top in the message window.

Parameters

(String) roomJidRoom JID

setFocusToForm

setFocusToForm: function(roomJid)

Set focus to the message input field within the message form.

Parameters

(String) roomJidRoom JID

setUser

setUser: function(roomJid,
user)

Sets or updates the current user in the specified room (called by <Candy.View.Pane.Roster.update>) and set specific informations (roles and affiliations) on the room tab (chat-pane).

Parameters

(String) roomJidRoom in which the user is set to.
(Candy.Core.ChatUser) userThe user

getUser

getUser: function(roomJid)

Get the current user in the room specified with the jid

Parameters

(String) roomJidRoom of which the user should be returned from

Returns

(Candy.Core.ChatUser)user

ignoreUser

ignoreUser: function(roomJid,
userJid)

Ignore specified user and add the ignore icon to the roster item of the user

Parameters

(String) roomJidRoom in which the user should be ignored
(String) userJidUser which should be ignored

unignoreUser

unignoreUser: function(roomJid,
userJid)

Unignore an ignored user and remove the ignore icon of the roster item.

Parameters

(String) roomJidRoom in which the user should be unignored
(String) userJidUser which should be unignored

addIgnoreIcon

addIgnoreIcon: function(roomJid,
userJid)

Add the ignore icon to the roster item of the specified user

Parameters

(String) roomJidRoom in which the roster item should be updated
(String) userJidUser of which the roster item should be updated

removeIgnoreIcon

removeIgnoreIcon: function(roomJid,
userJid)

Remove the ignore icon to the roster item of the specified user

Parameters

(String) roomJidRoom in which the roster item should be updated
(String) userJidUser of which the roster item should be updated

getPane

getPane: function(roomJid,
subPane)

Get the chat room pane or a subPane of it (if subPane is specified)

Parameters

(String) roomJidRoom in which the pane lies
(String) subPaneSub pane of the chat room pane if needed [optional]

changeDataUserJidIfUserIsMe

changeDataUserJidIfUserIsMe: function(roomId,
user)

Changes the room’s data-userjid attribute if the specified user is the current user.

Parameters

(String) roomIdId of the room
(Candy.Core.ChatUser) userUser

Candy.View.Pane.PrivateRoom

Private room handling

Summary
Functions
openOpens a new private room
Events
candy:view.private-room.before-openBefore opening a new private room
candy:view.private-room.after-openAfter opening a new private room
Functions
setStatusSet offline or online status for private rooms (when one of the participants leaves the room)
changeNickChanges the nick for every private room opened with this roomJid.
updateCalled by Candy.View.Observer.Presence.update to update the roster if needed.
Events
candy:view.roster.before-updateBefore updating the roster of a room
candy:view.roster.after-updateAfter updating a room’s roster
Functions
userClickClick handler for opening a private room
showJoinAnimationShows join animation if needed
joinAnimationAnimates specified elementId on join
leaveAnimationLeave animation for specified element id and removes the DOM element on completion.
changeNickChange nick of an existing user in the roster

Functions

open

open: function(roomJid,
roomName,
switchToRoom,
isNoConferenceRoomJid)

Opens a new private room

Parameters

(String) roomJidRoom jid to open
(String) roomNameRoom name
(Boolean) switchToRoomIf true, displayed room switches automatically to this room (e.g. when user clicks itself on another user to open a private chat)
(Boolean) isNoConferenceRoomJidtrue if a 3rd-party client sends a direct message to this user (not via the room) then the username is the node and not the resource.  This param addresses this case.

Triggers

candy:view.private-room.after-open using {roomJid, type, element}

Events

candy:view.private-room.before-open

Before opening a new private room

Parameters

(String) roomJidRoom JID
(String) roomNameRoom name
(String) type’chat’

Returns

Booleanif you don’t want to open the private room, return false

candy:view.private-room.after-open

After opening a new private room

Parameters

(String) roomJidRoom JID
(String) type’chat’
(jQuery.Element) elementUser element

Functions

setStatus

setStatus: function(roomJid,
status)

Set offline or online status for private rooms (when one of the participants leaves the room)

Parameters

(String) roomJidPrivate room jid
(String) status”leave”/”join”

changeNick

changeNick: function changeNick(roomJid,
user)

Changes the nick for every private room opened with this roomJid.

Parameters

(String) roomJidPublic room jid
(Candy.Core.ChatUser) userUser which changes his nick

update

update: function(roomJid,
user,
action,
currentUser)

Called by Candy.View.Observer.Presence.update to update the roster if needed.  Adds/removes users from the roster list or updates informations on their items (roles, affiliations etc.)

TODO: Refactoring, this method has too much LOC.

Parameters

(String) roomJidRoom JID in which the update happens
(Candy.Core.ChatUser) userUser on which the update happens
(String) actionone of “join”, “leave”, “kick” and “ban”
(Candy.Core.ChatUser) currentUserCurrent user

Triggers

candy:view.roster.before-update using {roomJid, user, action, element} candy:view.roster.after-update using {roomJid, user, action, element}

Events

candy:view.roster.before-update

Before updating the roster of a room

Parameters

(String) roomJidRoom JID
(Candy.Core.ChatUser) userUser
(String) action[join, leave, kick, ban]
(jQuery.Element) elementUser element

candy:view.roster.after-update

After updating a room’s roster

Parameters

(String) roomJidRoom JID
(Candy.Core.ChatUser) userUser
(String) action[join, leave, kick, ban]
(jQuery.Element) elementUser element

Functions

userClick

userClick: function()

Click handler for opening a private room

showJoinAnimation

showJoinAnimation: function(user,
userId,
roomId,
roomJid,
currentUser)

Shows join animation if needed

FIXME: Refactor.  Part of this will be done by the big room improvements

joinAnimation

joinAnimation: function(elementId)

Animates specified elementId on join

Parameters

(String) elementIdSpecific element to do the animation on

leaveAnimation

leaveAnimation: function(elementId)

Leave animation for specified element id and removes the DOM element on completion.

Parameters

(String) elementIdSpecific element to do the animation on

changeNick

changeNick: function(roomId,
user)

Change nick of an existing user in the roster

UserId has to be recalculated from the user because at the time of this call, the user is already set with the new jid & nick.

Parameters

(String) roomIdId of the room
(Candy.Core.ChatUser) userUser object

Candy.View.Pane.Message

Message submit/show handling

Summary
Functions
submiton submit handler for message field sends the message to the server and if it’s a private chat, shows the message immediately because the server doesn’t send back those message.
Events
candy:view.message.before-sendBefore sending a message
Functions
showShow a message in the message pane
Events
candy:view.message.before-showBefore showing a new message
candy:view.message.before-renderBefore rendering the message element
candy:view.message.after-showTriggered after showing a message

Functions

submit

submit: function(event)

on submit handler for message field sends the message to the server and if it’s a private chat, shows the message immediately because the server doesn’t send back those message.

Parameters

(Event) eventTriggered event

Triggers

candy:view.message.before-send using {message}

FIXME: as everywhere, `roomJid` might be slightly incorrect in this case

  • maybe rename this as part of a refactoring.

Events

candy:view.message.before-send

Before sending a message

Parameters

(String) roomJidroom to which the message should be sent
(String) messageMessage text
(String) xhtmlMessageXHTML formatted message [default: undefined]

Returns

Boolean|undefinedif you like to stop sending the message, return false.

Functions

show

show: function(roomJid,
name,
message,
xhtmlMessage,
timestamp)

Show a message in the message pane

Parameters

(String) roomJidroom in which the message has been sent to
(String) nameName of the user which sent the message
(String) messageMessage
(String) xhtmlMessageXHTML formatted message [if options enableXHTML is true]
(String) timestamp[optional] Timestamp of the message, if not present, current date.

Triggers

candy:view.message.before-show using {roomJid, name, message} candy.view.message.before-render using {template, templateData} candy:view.message.after-show using {roomJid, name, message, element}

Events

candy:view.message.before-show

Before showing a new message

Parameters

(String) roomJidRoom JID
(String) nameName of the sending user
(String) messageMessage text

Returns

Booleanif you don’t want to show the message, return false

candy:view.message.before-render

Before rendering the message element

Parameters

(String) templateTemplate to use
(Object) templateDataTemplate data consists of:
  • (String) name - Name of the sending user
  • (String) displayName - Cropped name of the sending user
  • (String) message - Message text
  • (String) time - Localized time

candy:view.message.after-show

Triggered after showing a message

Parameters

(String) roomJidRoom JID
(jQuery.Element) elementUser element
(String) nameName of the sending user
(String) messageMessage text
autoscroll: true
Boolean whether autoscroll is enabled
hasFocus: function()
Checks if window has focus
increaseUnreadMessages: function()
Increases unread message count in window title by one.
reduceUnreadMessages: function(num)
Reduce unread message count in window title by `num`.
clearUnreadMessages: function()
Clear unread message count in window title.
renderUnreadMessages: function(count)
Update window title to show message count.
onFocus: function()
Window focus event handler.
onBlur: function()
Window blur event handler.
rooms: []
Contains opened room elements
addTab: function(roomJid,
roomName,
roomType)
Add a tab to the chat pane.
getTab: function(roomJid)
Get tab by JID.
removeTab: function(roomJid)
Remove tab element.
setActiveTab: function(roomJid)
Set the active tab.
increaseUnreadMessages: function(roomJid)
Increase unread message count in a tab by one.
clearUnreadMessages: function(roomJid)
Clear unread message count in a tab.
tabClick: function(e)
Tab click event: show the room associated with the tab and stops the event from doing the default.
tabClose: function()
Tab close (click) event: Leave the room (groupchat) or simply close the tab (chat).
allTabsClosed: function()
All tabs closed event: Disconnect from service.
fitTabs: function()
Fit tab size according to window size
adminMessage: function(subject,
message)
Display admin message
infoMessage: function(roomJid,
subject,
message)
Display info message.
onInfoMessage: function(roomJid,
subject,
message)
Display info message.
init: function()
Register handler and enable or disable sound and status messages.
show: function()
Show toolbar.
hide: function()
Hide toolbar.
update: function(roomJid)
Update toolbar for specific room
playSound: function()
Play sound (default method).
onPlaySound: function()
Sound play event handler.
onSoundControlClick: function()
Sound control click event handler.
onAutoscrollControlClick: function()
Autoscroll control event handler.
onStatusMessageControlClick: function()
Status message control event handler.
show: function(html,
showCloseControl,
showSpinner)
Display modal window
hide: function(callback)
Hide modal window
showSpinner: function()
Show loading spinner
hideSpinner: function()
Hide loading spinner
showCloseControl: function()
Show a close button
hideCloseControl: function()
Hide the close button
showLoginForm: function(message,
presetJid)
Show the login form modal
showEnterPasswordForm: function(roomJid,
roomName,
message)
Shows a form for entering room password
showNicknameConflictForm: function(roomJid)
Shows a form indicating that the nickname is already taken and for chosing a new nickname
showError: function(message,
replacements)
Show modal containing error message
show: function(event,
content)
Show a tooltip on event.currentTarget with content specified or content within the target’s attribute data-tooltip.
init: function()
Initialize context menu and setup mouseleave handler.
show: function(elem,
roomJid,
user)
Show context menu (positions it according to the window height/width)
getMenuLinks: function(roomJid,
user,
elem)
Extends initialMenuLinks with menu links gathered from candy:view.roster.contextmenu
initialMenuLinks: function()
showEmoticonsMenu: function(elem)
Shows the special emoticons menu
init: function(roomJid,
roomName,
roomType)
Initialize a new room and inserts the room html into the DOM
show: function(roomJid)
Show a specific room and hides the other rooms (if there are any)
setSubject: function(roomJid,
subject)
Called when someone changes the subject in the channel
close: function(roomJid)
Close a room and remove everything in the DOM belonging to this room.
appendToMessagePane: function(roomJid,
html)
Append a new message to the message pane.
sliceMessagePane: function(roomJid)
Slices the message pane after the max amount of messages specified in the Candy View options (limit setting).
scrollToBottom: function(roomJid)
Scroll to bottom wrapper for onScrollToBottom to be able to disable it by overwriting the function.
onScrollToBottom: function(roomJid)
Scrolls to the latest message received/sent.
onScrollToStoredPosition: function(roomJid)
When autoscroll is off, the position where the scrollbar is has to be stored for each room, because it otherwise goes to the top in the message window.
setFocusToForm: function(roomJid)
Set focus to the message input field within the message form.
setUser: function(roomJid,
user)
Sets or updates the current user in the specified room (called by Candy.View.Pane.Roster.update) and set specific informations (roles and affiliations) on the room tab (chat-pane).
getUser: function(roomJid)
Get the current user in the room specified with the jid
ignoreUser: function(roomJid,
userJid)
Ignore specified user and add the ignore icon to the roster item of the user
unignoreUser: function(roomJid,
userJid)
Unignore an ignored user and remove the ignore icon of the roster item.
addIgnoreIcon: function(roomJid,
userJid)
Add the ignore icon to the roster item of the specified user
removeIgnoreIcon: function(roomJid,
userJid)
Remove the ignore icon to the roster item of the specified user
getPane: function(roomJid,
subPane)
Get the chat room pane or a subPane of it (if subPane is specified)
changeDataUserJidIfUserIsMe: function(roomId,
user)
Changes the room’s data-userjid attribute if the specified user is the current user.
open: function(roomJid,
roomName,
switchToRoom,
isNoConferenceRoomJid)
Opens a new private room
setStatus: function(roomJid,
status)
Set offline or online status for private rooms (when one of the participants leaves the room)
changeNick: function changeNick(roomJid,
user)
Changes the nick for every private room opened with this roomJid.
update: function(roomJid,
user,
action,
currentUser)
Called by Candy.View.Observer.Presence.update to update the roster if needed.
update: function(event,
args)
Every presence update gets dispatched from this method.
userClick: function()
Click handler for opening a private room
showJoinAnimation: function(user,
userId,
roomId,
roomJid,
currentUser)
Shows join animation if needed
joinAnimation: function(elementId)
Animates specified elementId on join
leaveAnimation: function(elementId)
Leave animation for specified element id and removes the DOM element on completion.
submit: function(event)
on submit handler for message field sends the message to the server and if it’s a private chat, shows the message immediately because the server doesn’t send back those message.
show: function(roomJid,
name,
message,
xhtmlMessage,
timestamp)
Show a message in the message pane
self.getPosLeftAccordingToWindowBounds = function(elem,
pos)
Fetches the window width and element width and checks if specified position + element width is bigger than the window width.
self.getPosTopAccordingToWindowBounds = function(elem,
pos)
Fetches the window height and element height and checks if specified position + element height is bigger than the window height.
self.jidToId = function(jid)
Translates a jid to a MD5-Id
Close