From c352d2b483f546f371fe5bf07214b2be6c718906 Mon Sep 17 00:00:00 2001 From: Christine Ho Date: Mon, 12 Jan 2015 00:04:18 +0100 Subject: [PATCH] - Removed a movim_log from roster.php - Fixed onclick listener on moved contact --- app/widgets/Roster/Roster.php | 1 - app/widgets/Roster/roster.js | 25 ++++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app/widgets/Roster/Roster.php b/app/widgets/Roster/Roster.php index fbd9c0a1d..1c385a302 100644 --- a/app/widgets/Roster/Roster.php +++ b/app/widgets/Roster/Roster.php @@ -214,7 +214,6 @@ class Roster extends WidgetBase * @returns $result: a json for the contacts and one for the groups */ function prepareRoster(){ - movim_log(__METHOD__); //Contacts $contactdao = new \Modl\ContactDAO(); $contacts = $contactdao->getRoster(); diff --git a/app/widgets/Roster/roster.js b/app/widgets/Roster/roster.js index 51c93f9c8..fca488d55 100644 --- a/app/widgets/Roster/roster.js +++ b/app/widgets/Roster/roster.js @@ -118,6 +118,9 @@ $scope.pushInPlace(el, $scope.lookupgroups[list.groupname].agroupitems, jidAvalCompare); } $scope.$apply(); + + //a new li is created, a new listener has to be created... + document.getElementById(list.jid).onclick = function(e){Roster.clickOnContact(e);}; }; this.showHideGroup = function(g){ @@ -293,16 +296,11 @@ var Roster = { }, refresh: function() { var items = document.querySelectorAll('#rosterlist div > li:not(.subheader)'); - var i = 0; - while(i < items.length -1) + + while(i < items.length) { - items[i].onclick = function(e) { - Contact_ajaxGetContact(this.id); - Roster.reset(items); - movim_add_class(this, 'active'); - document.querySelector('#roster').className = ''; - } + items[i].onclick = function(e){Roster.clickOnContact(e);}; i++; } }, @@ -315,7 +313,16 @@ var Roster = { setFound : function(jid) { document.querySelector('input[name=searchjid]').value = jid; - } + }, + + clickOnContact : function(e) { + Contact_ajaxGetContact(e.target.id); + /*recalculated at each click*/ + var it = document.querySelectorAll('#rosterlist div > li:not(.subheader)'); + Roster.reset(it); + movim_add_class(e.target, 'active'); + //document.querySelector('#roster').className = ''; + }, } MovimWebsocket.attach(function() {