aboutsummaryrefslogtreecommitdiffstats
path: root/alias-angular/app
diff options
context:
space:
mode:
Diffstat (limited to 'alias-angular/app')
-rw-r--r--alias-angular/app/index.html4
-rw-r--r--alias-angular/app/js/controllers.js9
-rw-r--r--alias-angular/app/js/directives.js15
3 files changed, 10 insertions, 18 deletions
diff --git a/alias-angular/app/index.html b/alias-angular/app/index.html
index 6ed6488..5cabe92 100644
--- a/alias-angular/app/index.html
+++ b/alias-angular/app/index.html
@@ -54,13 +54,13 @@
</div>
<div id="main" ng-controller="MsgCtl">
<ul class="nav nav-tabs">
- <li ng-repeat="conversation in conversations" ng-click="activate(conversation)">
+ <li ng-repeat="conversation in conversations" ng-class="isActive(conversation)" ng-click="activate(conversation)">
<!-- why does writing ng-click="activeConversation=conversation" doesn't work? -->
<a href="#repeat">{{conversation}} <i class="icon-remove" ng-click="delete(conversation)"></i></a>
</li>
</ul>
<div class="tab-content">
- <div class="tab-pane" id="repeat">Je suis {{activeConversation}}</div>
+ <div class="tab-pane" ng-class="isActive(conversation)" ng-repeat="conversation in conversations">{{conversation}}</div>
</div>
</div>
<script src="lib/jquery-1.7.2.min.js"></script>
diff --git a/alias-angular/app/js/controllers.js b/alias-angular/app/js/controllers.js
index bbcd7f5..3aab6d8 100644
--- a/alias-angular/app/js/controllers.js
+++ b/alias-angular/app/js/controllers.js
@@ -112,8 +112,8 @@ function MsgCtl($scope, $log) {
$log.log(contact);
if (_.indexOf($scope.conversations, contact)==-1) {
$scope.conversations.push(contact);
- $scope.activeConversation = contact;
}
+ $scope.activeConversation = contact;
});
$scope.delete = function(conversation) {
$scope.conversations.splice(_.indexOf($scope.conversations, conversation),1);
@@ -122,6 +122,13 @@ function MsgCtl($scope, $log) {
$log.log(conversation+' was clicked');
$scope.activeConversation = conversation;
};
+ $scope.isActive = function(conversation) {
+ if ($scope.activeConversation == conversation){
+ return "active"
+ } else {
+ return ""
+ }
+ };
}
MsgCtl.$inject = ['$scope','$log']; \ No newline at end of file
diff --git a/alias-angular/app/js/directives.js b/alias-angular/app/js/directives.js
index 3b9b652..ffa618c 100644
--- a/alias-angular/app/js/directives.js
+++ b/alias-angular/app/js/directives.js
@@ -7,22 +7,7 @@ angular.module('Alias.directives', []).
var directiveDefinition = {
restrict: 'C',
link: function(scope, elm, attrs) {
- var tabs = elm.find('li');
- var selectedTab = tabs.filter('.active');
- if (!selectedTab.length) {
- selectedTab = tabs.filter(':first');
- selectedTab.addClass('active');
- }
- var selectedPane = $(selectedTab.find('a').attr('href'));
- selectedPane.addClass('active');
-
elm.on('click', function(event) {
- selectedTab.removeClass('active');
- selectedPane.removeClass('active');
- selectedTab = angular.element(event.target).parent();
- selectedPane = $(selectedTab.find('a').attr('href'));
- selectedTab.addClass('active');
- selectedPane.addClass('active');
event.preventDefault();
});
}