aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2012-05-02 01:46:25 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2012-05-02 01:46:25 -0400
commitb496488568fd5a00e36f5d3b7b4f9a0db6ac204b (patch)
tree4a9086053eb45dace2c8268a91b2854acc7b125f
parent8ffa261653584518f11b733fd224c0ff46b8a4b1 (diff)
downloadalias-b496488568fd5a00e36f5d3b7b4f9a0db6ac204b.tar.gz
cleanups
-rw-r--r--alias-angular/app/index.html1
-rw-r--r--alias-angular/app/js/controllers.js12
-rw-r--r--alias-angular/app/js/directives.js14
3 files changed, 12 insertions, 15 deletions
diff --git a/alias-angular/app/index.html b/alias-angular/app/index.html
index 5cabe92..2f9ab62 100644
--- a/alias-angular/app/index.html
+++ b/alias-angular/app/index.html
@@ -55,7 +55,6 @@
<div id="main" ng-controller="MsgCtl">
<ul class="nav nav-tabs">
<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>
diff --git a/alias-angular/app/js/controllers.js b/alias-angular/app/js/controllers.js
index 3aab6d8..7e68e41 100644
--- a/alias-angular/app/js/controllers.js
+++ b/alias-angular/app/js/controllers.js
@@ -106,8 +106,11 @@ function RosterCtl($scope, StropheSrv, $log, $rootScope) {
RosterCtl.$inject = ['$scope','StropheSrv','$log', '$rootScope'];
function MsgCtl($scope, $log) {
+
$scope.conversations = [];
+
$scope.activeConversation = '';
+
$scope.$on('msgrequest', function(event, contact) {
$log.log(contact);
if (_.indexOf($scope.conversations, contact)==-1) {
@@ -115,19 +118,18 @@ function MsgCtl($scope, $log) {
}
$scope.activeConversation = contact;
});
+
$scope.delete = function(conversation) {
$scope.conversations.splice(_.indexOf($scope.conversations, conversation),1);
};
+
$scope.activate = function(conversation) {
$log.log(conversation+' was clicked');
$scope.activeConversation = conversation;
};
+
$scope.isActive = function(conversation) {
- if ($scope.activeConversation == conversation){
- return "active"
- } else {
- return ""
- }
+ return $scope.activeConversation == conversation ? 'active' : '';
};
}
diff --git a/alias-angular/app/js/directives.js b/alias-angular/app/js/directives.js
index ffa618c..d650c23 100644
--- a/alias-angular/app/js/directives.js
+++ b/alias-angular/app/js/directives.js
@@ -3,14 +3,10 @@
angular.module('Alias.directives', []).
- directive('navTabs', function($log) {
- var directiveDefinition = {
- restrict: 'C',
- link: function(scope, elm, attrs) {
- elm.on('click', function(event) {
- event.preventDefault();
- });
- }
+ directive('navTabs', function() {
+ return function(scope, elm, attrs) {
+ elm.on('click', function(event) {
+ event.preventDefault();
+ });
};
- return directiveDefinition;
});