From b496488568fd5a00e36f5d3b7b4f9a0db6ac204b Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Wed, 2 May 2012 01:46:25 -0400 Subject: cleanups --- alias-angular/app/index.html | 1 - alias-angular/app/js/controllers.js | 12 +++++++----- alias-angular/app/js/directives.js | 14 +++++--------- 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 @@
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; }); -- cgit v1.2.3-70-g09d2