| Candy | Chats are not dead yet. |
© 2011 Amiado Group AG. All rights reserved. © 2012-2014 Patrick Stadler & Michael Weibel. All rights reserved.
| pane.js | |
| Candy. | Candy view pane handles everything regarding DOM updates etc. |
| Candy. | Window related view updates |
| Variables | |
| autoscroll | Boolean whether autoscroll is enabled |
| Functions | |
| hasFocus | Checks if window has focus |
| increaseUnreadMessages | Increases unread message count in window title by one. |
| reduceUnreadMessages | Reduce unread message count in window title by `num`. |
| clearUnreadMessages | Clear unread message count in window title. |
| renderUnreadMessages | Update window title to show message count. |
| onFocus | Window focus event handler. |
| onBlur | Window blur event handler. |
| Candy. | Chat-View related view updates |
| Variables | |
| rooms | Contains opened room elements |
| Functions | |
| addTab | Add a tab to the chat pane. |
| getTab | Get tab by JID. |
| removeTab | Remove tab element. |
| setActiveTab | Set the active tab. |
| increaseUnreadMessages | Increase unread message count in a tab by one. |
| clearUnreadMessages | Clear unread message count in a tab. |
| tabClick | Tab click event: show the room associated with the tab and stops the event from doing the default. |
| tabClose | Tab close (click) event: Leave the room (groupchat) or simply close the tab (chat). |
| allTabsClosed | All tabs closed event: Disconnect from service. |
| fitTabs | Fit tab size according to window size |
| adminMessage | Display admin message |
| Events | |
| candy: | After admin message display |
| Functions | |
| infoMessage | Display info message. |
| onInfoMessage | Display info message. |
| Candy. | Chat toolbar for things like emoticons toolbar, room management etc. |
| Functions | |
| init | Register handler and enable or disable sound and status messages. |
| show | Show toolbar. |
| hide | Hide toolbar. |
| update | Update toolbar for specific room |
| playSound | Play sound (default method). |
| onPlaySound | Sound play event handler. |
| onSoundControlClick | Sound control click event handler. |
| onAutoscrollControlClick | Autoscroll control event handler. |
| onStatusMessageControlClick | Status message control event handler. |
| updateUserCount | Update usercount element with count. |
| Candy. | Modal window |
| Functions | |
| show | Display modal window |
| hide | Hide modal window |
| showSpinner | Show loading spinner |
| hideSpinner | Hide loading spinner |
| showCloseControl | Show a close button |
| hideCloseControl | Hide the close button |
| showLoginForm | Show the login form modal |
| showEnterPasswordForm | Shows a form for entering room password |
| showNicknameConflictForm | Shows a form indicating that the nickname is already taken and for chosing a new nickname |
| showError | Show modal containing error message |
| Candy. | Class to display tooltips over specific elements |
| Functions | |
| show | Show a tooltip on event.currentTarget with content specified or content within the target’s attribute data-tooltip. |
| Candy. | Context menu for actions and settings |
| Functions | |
| init | Initialize context menu and setup mouseleave handler. |
| show | Show context menu (positions it according to the window height/width) |
| Events | |
| candy: | After context menu display |
| Functions | |
| getMenuLinks | Extends initialMenuLinks with menu links gathered from candy:view.roster.contextmenu |
| Events | |
| candy: | Modify existing menu links (add links) |
| Functions | |
| initialMenuLinks | |
| showEmoticonsMenu | Shows the special emoticons menu |
| Candy. | Everything which belongs to room view things belongs here. |
| Functions | |
| init | Initialize a new room and inserts the room html into the DOM |
| Events | |
| candy: | Before initialising a room |
| candy: | After initialising a room |
| Functions | |
| show | Show a specific room and hides the other rooms (if there are any) |
| Events | |
| candy: | After showing a room |
| candy: | After hiding a room |
| Functions | |
| setSubject | Called when someone changes the subject in the channel |
| Events | |
| candy: | After changing the subject of a room |
| Functions | |
| close | Close a room and remove everything in the DOM belonging to this room. |
| Events | |
| candy: | After closing a room |
| Functions | |
| appendToMessagePane | Append a new message to the message pane. |
| sliceMessagePane | Slices the message pane after the max amount of messages specified in the Candy View options (limit setting). |
| scrollToBottom | Scroll to bottom wrapper for onScrollToBottom to be able to disable it by overwriting the function. |
| onScrollToBottom | Scrolls to the latest message received/sent. |
| onScrollToStoredPosition | 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 | Set focus to the message input field within the message form. |
| setUser | 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 | Get the current user in the room specified with the jid |
| ignoreUser | Ignore specified user and add the ignore icon to the roster item of the user |
| unignoreUser | Unignore an ignored user and remove the ignore icon of the roster item. |
| addIgnoreIcon | Add the ignore icon to the roster item of the specified user |
| removeIgnoreIcon | Remove the ignore icon to the roster item of the specified user |
| getPane | Get the chat room pane or a subPane of it (if subPane is specified) |
| changeDataUserJidIfUserIsMe | Changes the room’s data-userjid attribute if the specified user is the current user. |
| Candy. | Private room handling |
| Functions | |
| open | Opens a new private room |
| Events | |
| candy: | Before opening a new private room |
| candy: | After opening a new private room |
| Functions | |
| setStatus | Set offline or online status for private rooms (when one of the participants leaves the room) |
| changeNick | Changes the nick for every private room opened with this roomJid. |
| update | Called by Candy.View.Observer.Presence.update to update the roster if needed. |
| Events | |
| candy: | Before updating the roster of a room |
| candy: | After updating a room’s roster |
| Functions | |
| userClick | Click handler for opening a private room |
| showJoinAnimation | Shows join animation if needed |
| joinAnimation | Animates specified elementId on join |
| leaveAnimation | Leave animation for specified element id and removes the DOM element on completion. |
| changeNick | Change nick of an existing user in the roster |
| Candy. | Message submit/show handling |
| Functions | |
| submit | 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. |
| Events | |
| candy: | Before sending a message |
| Functions | |
| show | Show a message in the message pane |
| Events | |
| candy: | Before showing a new message |
| candy: | Before rendering the message element |
| candy: | Triggered after showing a message |
Window related view updates
| Variables | |
| autoscroll | Boolean whether autoscroll is enabled |
| Functions | |
| hasFocus | Checks if window has focus |
| increaseUnreadMessages | Increases unread message count in window title by one. |
| reduceUnreadMessages | Reduce unread message count in window title by `num`. |
| clearUnreadMessages | Clear unread message count in window title. |
| renderUnreadMessages | Update window title to show message count. |
| onFocus | Window focus event handler. |
| onBlur | Window blur event handler. |
Chat-View related view updates
| Variables | |
| rooms | Contains opened room elements |
| Functions | |
| addTab | Add a tab to the chat pane. |
| getTab | Get tab by JID. |
| removeTab | Remove tab element. |
| setActiveTab | Set the active tab. |
| increaseUnreadMessages | Increase unread message count in a tab by one. |
| clearUnreadMessages | Clear unread message count in a tab. |
| tabClick | Tab click event: show the room associated with the tab and stops the event from doing the default. |
| tabClose | Tab close (click) event: Leave the room (groupchat) or simply close the tab (chat). |
| allTabsClosed | All tabs closed event: Disconnect from service. |
| fitTabs | Fit tab size according to window size |
| adminMessage | Display admin message |
| Events | |
| candy: | After admin message display |
| Functions | |
| infoMessage | Display info message. |
| onInfoMessage | Display info message. |
infoMessage: function( roomJid, subject, message )
Display info message. This is a wrapper for onInfoMessage to be able to disable certain info messages.
| (String) roomJid | Room JID |
| (String) subject | Subject |
| (String) message | Message |
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).
| (String) roomJid | Room JID |
| (String) subject | Subject |
| (String) message | Message |
Chat toolbar for things like emoticons toolbar, room management etc.
| Functions | |
| init | Register handler and enable or disable sound and status messages. |
| show | Show toolbar. |
| hide | Hide toolbar. |
| update | Update toolbar for specific room |
| playSound | Play sound (default method). |
| onPlaySound | Sound play event handler. |
| onSoundControlClick | Sound control click event handler. |
| onAutoscrollControlClick | Autoscroll control event handler. |
| onStatusMessageControlClick | Status message control event handler. |
| updateUserCount | Update usercount element with count. |
Modal window
| Functions | |
| show | Display modal window |
| hide | Hide modal window |
| showSpinner | Show loading spinner |
| hideSpinner | Hide loading spinner |
| showCloseControl | Show a close button |
| hideCloseControl | Hide the close button |
| showLoginForm | Show the login form modal |
| showEnterPasswordForm | Shows a form for entering room password |
| showNicknameConflictForm | Shows a form indicating that the nickname is already taken and for chosing a new nickname |
| showError | Show modal containing error message |
show: function( html, showCloseControl, showSpinner )
Display modal window
| (String) html | HTML code to put into the modal window |
| (Boolean) showCloseControl | set to true if a close button should be displayed [default false] |
| (Boolean) showSpinner | set to true if a loading spinner should be shown [default false] |
Context menu for actions and settings
| Functions | |
| init | Initialize context menu and setup mouseleave handler. |
| show | Show context menu (positions it according to the window height/width) |
| Events | |
| candy: | After context menu display |
| Functions | |
| getMenuLinks | Extends initialMenuLinks with menu links gathered from candy:view.roster.contextmenu |
| Events | |
| candy: | Modify existing menu links (add links) |
| Functions | |
| initialMenuLinks | |
| showEmoticonsMenu | Shows the special emoticons menu |
show: function( elem, roomJid, user )
Show context menu (positions it according to the window height/width)
| (Element) elem | On which element it should be shown |
| (String) roomJid | Room Jid of the room it should be shown |
| (Candy.Core.chatUser) user | User |
getMenuLinks for getting menulinks the user has access to Candy.Util.getPosLeftAccordingToWindowBounds for positioning Candy.Util.getPosTopAccordingToWindowBounds for positioning
candy:view.roster.after-context-menu using {roomJid, user, elements}
getMenuLinks: function( roomJid, user, elem )
Extends initialMenuLinks with menu links gathered from candy:view.roster.contextmenu
| (String) roomJid | Room in which the menu will be displayed |
| (Candy.Core.ChatUser) user | User |
| (jQuery.Element) elem | Parent element of the context menu |
candy:view.roster.context-menu using {roomJid, user, elem}
| (Object) | object containing the extended menulinks. |
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.
| (String) roomJid | Room on which the menu should be displayed |
| (Candy.Core.ChatUser) user | User |
| (jQuery.Element) elem | Parent element of the context menu |
Everything which belongs to room view things belongs here.
| Functions | |
| init | Initialize a new room and inserts the room html into the DOM |
| Events | |
| candy: | Before initialising a room |
| candy: | After initialising a room |
| Functions | |
| show | Show a specific room and hides the other rooms (if there are any) |
| Events | |
| candy: | After showing a room |
| candy: | After hiding a room |
| Functions | |
| setSubject | Called when someone changes the subject in the channel |
| Events | |
| candy: | After changing the subject of a room |
| Functions | |
| close | Close a room and remove everything in the DOM belonging to this room. |
| Events | |
| candy: | After closing a room |
| Functions | |
| appendToMessagePane | Append a new message to the message pane. |
| sliceMessagePane | Slices the message pane after the max amount of messages specified in the Candy View options (limit setting). |
| scrollToBottom | Scroll to bottom wrapper for onScrollToBottom to be able to disable it by overwriting the function. |
| onScrollToBottom | Scrolls to the latest message received/sent. |
| onScrollToStoredPosition | 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 | Set focus to the message input field within the message form. |
| setUser | 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 | Get the current user in the room specified with the jid |
| ignoreUser | Ignore specified user and add the ignore icon to the roster item of the user |
| unignoreUser | Unignore an ignored user and remove the ignore icon of the roster item. |
| addIgnoreIcon | Add the ignore icon to the roster item of the specified user |
| removeIgnoreIcon | Remove the ignore icon to the roster item of the specified user |
| getPane | Get the chat room pane or a subPane of it (if subPane is specified) |
| changeDataUserJidIfUserIsMe | Changes the room’s data-userjid attribute if the specified user is the current user. |
init: function( roomJid, roomName, roomType )
Initialize a new room and inserts the room html into the DOM
| (String) roomJid | Room JID |
| (String) roomName | Room name |
| (String) roomType | Type: either “groupchat” or “chat” (private chat) |
candy:view.room.after-add using {roomJid, type, element}
| (String) | the room id of the element created. |
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)
candy:view.room.after-close using {roomJid}
| (String) roomJid | Room to close |
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.
| (String) roomJid | Room JID |
scrollToBottom: function( roomJid )
Scroll to bottom wrapper for onScrollToBottom to be able to disable it by overwriting the function.
| (String) roomJid | Room JID |
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).
| (String) roomJid | Room in which the user is set to. |
| (Candy.Core.ChatUser) user | The user |
Private room handling
| Functions | |
| open | Opens a new private room |
| Events | |
| candy: | Before opening a new private room |
| candy: | After opening a new private room |
| Functions | |
| setStatus | Set offline or online status for private rooms (when one of the participants leaves the room) |
| changeNick | Changes the nick for every private room opened with this roomJid. |
| update | Called by Candy.View.Observer.Presence.update to update the roster if needed. |
| Events | |
| candy: | Before updating the roster of a room |
| candy: | After updating a room’s roster |
| Functions | |
| userClick | Click handler for opening a private room |
| showJoinAnimation | Shows join animation if needed |
| joinAnimation | Animates specified elementId on join |
| leaveAnimation | Leave animation for specified element id and removes the DOM element on completion. |
| changeNick | Change nick of an existing user in the roster |
open: function( roomJid, roomName, switchToRoom, isNoConferenceRoomJid )
Opens a new private room
| (String) roomJid | Room jid to open |
| (String) roomName | Room name |
| (Boolean) switchToRoom | If true, displayed room switches automatically to this room (e.g. when user clicks itself on another user to open a private chat) |
| (Boolean) isNoConferenceRoomJid | true 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. |
candy:view.private-room.after-open using {roomJid, type, element}
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.
| (String) roomJid | Room JID in which the update happens |
| (Candy.Core.ChatUser) user | User on which the update happens |
| (String) action | one of “join”, “leave”, “kick” and “ban” |
| (Candy.Core.ChatUser) currentUser | Current user |
candy:view.roster.before-update using {roomJid, user, action, element} candy:view.roster.after-update using {roomJid, user, action, element}
Message submit/show handling
| Functions | |
| submit | 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. |
| Events | |
| candy: | Before sending a message |
| Functions | |
| show | Show a message in the message pane |
| Events | |
| candy: | Before showing a new message |
| candy: | Before rendering the message element |
| candy: | Triggered after showing a message |
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.
| (Event) event | Triggered event |
candy:view.message.before-send using {message}
FIXME: as everywhere, `roomJid` might be slightly incorrect in this case
show: function( roomJid, name, message, xhtmlMessage, timestamp )
Show a message in the message pane
| (String) roomJid | room in which the message has been sent to |
| (String) name | Name of the user which sent the message |
| (String) message | Message |
| (String) xhtmlMessage | XHTML formatted message [if options enableXHTML is true] |
| (String) timestamp | [optional] Timestamp of the message, if not present, current date. |
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}
Before rendering the message element
| (String) template | Template to use |
| (Object) templateData | Template data consists of: |
Boolean whether autoscroll is enabled
autoscroll: true
Checks if window has focus
hasFocus: function()
Increases unread message count in window title by one.
increaseUnreadMessages: function()
Reduce unread message count in window title by `num`.
reduceUnreadMessages: function( num )
Clear unread message count in window title.
clearUnreadMessages: function()
Update window title to show message count.
renderUnreadMessages: function( count )
Window focus event handler.
onFocus: function()
Window blur event handler.
onBlur: function()
Contains opened room elements
rooms: []
Add a tab to the chat pane.
addTab: function( roomJid, roomName, roomType )
Get tab by JID.
getTab: function( roomJid )
Remove tab element.
removeTab: function( roomJid )
Set the active tab.
setActiveTab: function( roomJid )
Increase unread message count in a tab by one.
increaseUnreadMessages: function( roomJid )
Clear unread message count in a tab.
clearUnreadMessages: function( roomJid )
Tab click event: show the room associated with the tab and stops the event from doing the default.
tabClick: function( e )
Tab close (click) event: Leave the room (groupchat) or simply close the tab (chat).
tabClose: function()
All tabs closed event: Disconnect from service.
allTabsClosed: function()
Fit tab size according to window size
fitTabs: function()
Display admin message
adminMessage: function( subject, message )
Display info message.
infoMessage: function( roomJid, subject, message )
Display info message.
onInfoMessage: function( roomJid, subject, message )
Register handler and enable or disable sound and status messages.
init: function()
Show toolbar.
show: function()
Hide toolbar.
hide: function()
Update toolbar for specific room
update: function( roomJid )
Play sound (default method).
playSound: function()
Sound play event handler.
onPlaySound: function()
Sound control click event handler.
onSoundControlClick: function()
Autoscroll control event handler.
onAutoscrollControlClick: function()
Status message control event handler.
onStatusMessageControlClick: function()
Display modal window
show: function( html, showCloseControl, showSpinner )
Hide modal window
hide: function( callback )
Show loading spinner
showSpinner: function()
Hide loading spinner
hideSpinner: function()
Show a close button
showCloseControl: function()
Hide the close button
hideCloseControl: function()
Show the login form modal
showLoginForm: function( message, presetJid )
Shows a form for entering room password
showEnterPasswordForm: function( roomJid, roomName, message )
Shows a form indicating that the nickname is already taken and for chosing a new nickname
showNicknameConflictForm: function( roomJid )
Show modal containing error message
showError: function( message, replacements )
Show a tooltip on event.currentTarget with content specified or content within the target’s attribute data-tooltip.
show: function( event, content )
Initialize context menu and setup mouseleave handler.
init: function()
Show context menu (positions it according to the window height/width)
show: function( elem, roomJid, user )
Extends initialMenuLinks with menu links gathered from candy:view.roster.contextmenu
getMenuLinks: function( roomJid, user, elem )
initialMenuLinks: function()
Shows the special emoticons menu
showEmoticonsMenu: function( elem )
Initialize a new room and inserts the room html into the DOM
init: function( roomJid, roomName, roomType )
Show a specific room and hides the other rooms (if there are any)
show: function( roomJid )
Called when someone changes the subject in the channel
setSubject: function( roomJid, subject )
Close a room and remove everything in the DOM belonging to this room.
close: function( roomJid )
Append a new message to the message pane.
appendToMessagePane: function( roomJid, html )
Slices the message pane after the max amount of messages specified in the Candy View options (limit setting).
sliceMessagePane: function( roomJid )
Scroll to bottom wrapper for onScrollToBottom to be able to disable it by overwriting the function.
scrollToBottom: function( roomJid )
Scrolls to the latest message received/sent.
onScrollToBottom: 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.
onScrollToStoredPosition: function( roomJid )
Set focus to the message input field within the message form.
setFocusToForm: function( roomJid )
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).
setUser: function( roomJid, user )
Get the current user in the room specified with the jid
getUser: function( roomJid )
Ignore specified user and add the ignore icon to the roster item of the user
ignoreUser: function( roomJid, userJid )
Unignore an ignored user and remove the ignore icon of the roster item.
unignoreUser: function( roomJid, userJid )
Add the ignore icon to the roster item of the specified user
addIgnoreIcon: function( roomJid, userJid )
Remove the ignore icon to the roster item of the specified user
removeIgnoreIcon: function( roomJid, userJid )
Get the chat room pane or a subPane of it (if subPane is specified)
getPane: function( roomJid, subPane )
Changes the room’s data-userjid attribute if the specified user is the current user.
changeDataUserJidIfUserIsMe: function( roomId, user )
Opens a new private room
open: function( roomJid, roomName, switchToRoom, isNoConferenceRoomJid )
Set offline or online status for private rooms (when one of the participants leaves the room)
setStatus: function( roomJid, status )
Changes the nick for every private room opened with this roomJid.
changeNick: function changeNick( roomJid, user )
Called by Candy.View.Observer.Presence.update to update the roster if needed.
update: function( roomJid, user, action, currentUser )
Every presence update gets dispatched from this method.
update: function( event, args )
Click handler for opening a private room
userClick: function()
Shows join animation if needed
showJoinAnimation: function( user, userId, roomId, roomJid, currentUser )
Animates specified elementId on join
joinAnimation: function( elementId )
Leave animation for specified element id and removes the DOM element on completion.
leaveAnimation: function( elementId )
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.
submit: function( event )
Show a message in the message pane
show: function( roomJid, name, message, xhtmlMessage, timestamp )
Fetches the window width and element width and checks if specified position + element width is bigger than the window width.
self.getPosLeftAccordingToWindowBounds = function( elem, pos )
Fetches the window height and element height and checks if specified position + element height is bigger than the window height.
self.getPosTopAccordingToWindowBounds = function( elem, pos )
Translates a jid to a MD5-Id
self.jidToId = function( jid )