From f7be6930cf3ed6b768deb18da5f0e80f5b01d570 Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Fri, 20 Apr 2012 18:12:56 -0400 Subject: Tentative implementation of the tabs almost there! --- alias-angular/app/js/controllers.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'alias-angular/app/js/controllers.js') diff --git a/alias-angular/app/js/controllers.js b/alias-angular/app/js/controllers.js index 1eb53e7..8768915 100644 --- a/alias-angular/app/js/controllers.js +++ b/alias-angular/app/js/controllers.js @@ -36,7 +36,7 @@ function ConnectCtl($scope, StropheSrv, $log, $rootScope) { ConnectCtl.$inject = ['$scope', 'StropheSrv', '$log', '$rootScope']; -function RosterCtl($scope, StropheSrv, $log) { +function RosterCtl($scope, StropheSrv, $log, $rootScope) { $scope.contacts = {}; $scope.get_contacts = function() { return _.toArray($scope.contacts); @@ -82,10 +82,26 @@ function RosterCtl($scope, StropheSrv, $log) { $scope.getRoster(); }); - $scope.getRoster = function () { + $scope.getRoster = function() { var query = $iq({type : 'get'}).c('query', {xmlns : Strophe.NS.ROSTER}); StropheSrv.sendIQ(query, onRoster); }; + + $scope.chatWith = function(contact) { + $rootScope.$broadcast('msgrequest', {jid: contact.jid, name:contact.name}); + }; } -RosterCtl.$inject = ['$scope','StropheSrv','$log']; +RosterCtl.$inject = ['$scope','StropheSrv','$log', '$rootScope']; + +function MsgCtl($scope, $log) { + $scope.conversations = []; + $scope.$on('msgrequest', function(event, contact){ + $log.log(contact); + if (_.indexOf($scope.conversations, contact)) { + $scope.conversations.push(contact); + } + }); +} + +MsgCtl.$inject = ['$scope','$log']; \ No newline at end of file -- cgit v1.2.3-70-g09d2