diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2012-04-21 17:38:19 -0400 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2012-04-21 17:38:19 -0400 |
| commit | a7459f66525f4b1016146824506b016b718def1b (patch) | |
| tree | 676a33c0eb89156bb7df0792b5907d3d5b92639b | |
| parent | f7be6930cf3ed6b768deb18da5f0e80f5b01d570 (diff) | |
| download | alias-a7459f66525f4b1016146824506b016b718def1b.tar.gz | |
Tabs finally working!
| -rw-r--r-- | alias-angular/app/index.html | 13 | ||||
| -rw-r--r-- | alias-angular/app/js/controllers.js | 18 |
2 files changed, 22 insertions, 9 deletions
diff --git a/alias-angular/app/index.html b/alias-angular/app/index.html index 4305308..676dd13 100644 --- a/alias-angular/app/index.html +++ b/alias-angular/app/index.html @@ -37,19 +37,20 @@ </ul> </div> <div id="main" ng-controller="MsgCtl"> - <ul class="tabs"> - <li ng-repeat="conversation in conversations" ng-class="isAsctive(conversation.jid)" ng-click="activetab=conversation.jid"> - <a ng-href="#{{conversation.jid}}">{{conversation.name||conversation.jid}} <i class="icon-remove"></i></a> + <ul class="nav nav-tabs"> + <li ng-init="activeConversation=''" ng-repeat="conversation in conversations" ng-class="isActive(conversation)" ng-click="activate(conversation)"> + <!-- why does writing ng-click="activeConversation=conversation" doesn't work? --> + <a ng-href="#repeat">{{conversation}} <i class="icon-remove" ng-click="delete(conversation)"></i></a> </li> </ul> <div class="tab-content"> - <div id="{{conversation.jid}}" ng-class="isActive(conversation.jid)" ng-repeat="conversation in conversations">Je suis {{conversation.jid}} - </div> + <div class="tab-pane active" id="repeat" ng-show="activeConversation.length">Je suis {{activeConversation}}</div> + </div> </div> <script src="lib/angular/angular.js"></script> <script src="lib/jquery-1.7.2.min.js"></script> <script src="lib/underscore-min.js"></script> - <script src="lib/bootstrap-tab.js"></script> + <!-- <script src="lib/bootstrap-tab.js"></script> --> <script src="lib/config.js"></script> <script src="js/alias.js"></script> <script src="lib/strophe.js"></script> diff --git a/alias-angular/app/js/controllers.js b/alias-angular/app/js/controllers.js index 8768915..3d88dcc 100644 --- a/alias-angular/app/js/controllers.js +++ b/alias-angular/app/js/controllers.js @@ -88,7 +88,7 @@ function RosterCtl($scope, StropheSrv, $log, $rootScope) { }; $scope.chatWith = function(contact) { - $rootScope.$broadcast('msgrequest', {jid: contact.jid, name:contact.name}); + $rootScope.$broadcast('msgrequest', contact.name||contact.jid); }; } @@ -96,12 +96,24 @@ RosterCtl.$inject = ['$scope','StropheSrv','$log', '$rootScope']; function MsgCtl($scope, $log) { $scope.conversations = []; - $scope.$on('msgrequest', function(event, contact){ + $scope.activeConversation = ''; + $scope.$on('msgrequest', function(event, contact) { $log.log(contact); - if (_.indexOf($scope.conversations, contact)) { + if (_.indexOf($scope.conversations, contact)==-1) { $scope.conversations.push(contact); + $scope.activeConversation = contact; } }); + $scope.isActive = function(conversation) { + return ($scope.activeConversation == conversation) ? 'active' : ''; + }; + $scope.delete = function(conversation) { + $scope.conversations.splice(_.indexOf($scope.conversations, conversation),1); + }; + $scope.activate = function(conversation) { + $log.log(conversation+' was clicked'); + $scope.activeConversation = conversation; + }; } MsgCtl.$inject = ['$scope','$log'];
\ No newline at end of file |
