diff options
author | Michael Weibel <mweibel@users.noreply.github.com> | 2015-02-26 20:33:27 +0300 |
---|---|---|
committer | Michael Weibel <mweibel@users.noreply.github.com> | 2015-02-26 20:33:27 +0300 |
commit | 0b8e96c7c2d4bc0f602c7daeeea1d44b96f67495 (patch) | |
tree | 626c90fd8efe4eab35775ef51185dcaaef1f8ca7 | |
parent | 794bb8ea58e0e181db0381b43de6174a090ab194 (diff) | |
parent | 2d3b1830a1e00163d8aba53e1e65f91b5030f9a9 (diff) |
Merge pull request #367 from melissanoelle/feature/add_event_before_adding_tab
Add new event before adding tab
-rw-r--r-- | src/view/pane/chat.js | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/view/pane/chat.js b/src/view/pane/chat.js index 5e73d51..be040e0 100644 --- a/src/view/pane/chat.js +++ b/src/view/pane/chat.js @@ -40,8 +40,32 @@ Candy.View.Pane = (function(self, $) { * (String) roomType - Type of room: `groupchat` or `chat` */ addTab: function(roomJid, roomName, roomType) { - var roomId = Candy.Util.jidToId(roomJid), - html = Mustache.to_html(Candy.View.Template.Chat.tab, { + var roomId = Candy.Util.jidToId(roomJid); + + var evtData = { + roomJid: roomJid, + roomName: roomName, + roomType: roomType, + roomId: roomId + }; + + /** Event: candy:view.pane.before-tab + * Before sending a message + * + * Parameters: + * (String) roomJid - JID of the room the tab is for. + * (String) roomName - Name of the room. + * (String) roomType - What type of room: `groupchat` or `chat` + * + * Returns: + * Boolean|undefined - If you want to handle displaying the tab on your own, return false. + */ + if ($(Candy).triggerHandler('candy:view.pane.before-tab', evtData) === false) { + event.preventDefault(); + return; + } + + var html = Mustache.to_html(Candy.View.Template.Chat.tab, { roomJid: roomJid, roomId: roomId, name: roomName || Strophe.getNodeFromJid(roomJid), |