From bc712b274200c81f4b99141a85b541916bec69c9 Mon Sep 17 00:00:00 2001 From: Zaran Date: Sun, 27 Mar 2011 12:30:38 +0200 Subject: Basic tab system and design : * clicking on a contact creates a tab containing chat layout --- webclient/lib/basic.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'webclient/lib') diff --git a/webclient/lib/basic.js b/webclient/lib/basic.js index 52a494a..610afd1 100644 --- a/webclient/lib/basic.js +++ b/webclient/lib/basic.js @@ -61,6 +61,13 @@ var Alias = { return contact.find('.roster-jid').text(); }, + /** + * Return the name of a contact + */ + getName : function(contact) { + return contact.find('.roster-name').text(); + }, + /** * Get the home node of a contact * @param contact jquery object @@ -233,6 +240,13 @@ $(document).ready(function(){ $(this).next().slideToggle(); }); + $('#tabs').tabs(); + + $('#tabs').bind('tabsshow',function(event,ui){ + $(ui.panel).find('input').focus(); + $(ui.tab).parent().removeClass('ui-state-focus'); + }); + $('#rosterfilter').keyup(function() { var filter = $(this).val(); $('#roster ul li div.roster-name:not(:Contains("' + filter + '"))').parent().hide(); @@ -240,7 +254,21 @@ $(document).ready(function(){ }); $('.roster-contact').live('click', function(){ - Alias.getHome($(this)); + log('test'); + var jid = Alias.getID($(this)); + var name = Alias.getName($(this)); + var id = Alias.jid_to_id(jid); + + if ($('#chat-' + id).length === 0) { + $('#tabs').tabs('add', '#chat-' + id, name); + $('#chat-' + id).append( + "
" + + ""); + $('#chat-' + id).data('jid', jid); + } + $('#tabs').tabs('select', '#chat-' + id); + + $('#chat-' + id + ' input').focus(); }); }); -- cgit v1.2.3-70-g09d2