From 814224154425762df54a311e45f8f70c52f79e69 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sun, 1 Sep 2013 19:23:16 -0400 Subject: [PATCH] rewrit: bug fix to chat not posting. this may cause perf issues, revisit --- assets/js/controllers/groupsCtrl.js | 37 +++++++++++++---------------- views/options/groups/chat-box.jade | 4 ++-- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/assets/js/controllers/groupsCtrl.js b/assets/js/controllers/groupsCtrl.js index 90de57da22..dff29a5acf 100644 --- a/assets/js/controllers/groupsCtrl.js +++ b/assets/js/controllers/groupsCtrl.js @@ -1,12 +1,10 @@ "use strict"; -habitrpg - - .controller("GroupsCtrl", ['$scope', '$rootScope', 'Groups', '$http', 'API_URL', '$q', - function($scope, $rootScope, Groups, $http, API_URL, $q) { +habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Groups', '$http', 'API_URL', '$q', + function($scope, $rootScope, Groups, $http, API_URL, $q) { $scope.isMember = function(user, group){ - return ~group.members.indexOf(user._id); + return ~(group.members.indexOf(user._id)); } // The user may not visit the public guilds, personal guilds, and tavern pages. So @@ -48,23 +46,8 @@ habitrpg }) }); - //$scope._chatMessage = ''; - $scope.postChat = function(group, $event){ - //FIXME ng-model makes this painfully slow! using jquery for now, which is really non-angular-like - var message = $($event.target).val(); - if (_.isEmpty(message)) return - $('.chat-btn').addClass('disabled'); - group.$postChat({message:message}, function(data){ - //$scope._chatMessage = ''; - $($event.target).val(''); - group.chat = data.chat; - $('.chat-btn').removeClass('disabled'); - }); - } - $scope.invitee = ''; $scope.invite = function(group, uuid){ - debugger group.$invite({uuid:uuid}, function(){ $scope.invitee = ''; }); @@ -72,6 +55,20 @@ habitrpg } ]) + .controller('ChatCtrl', ['$scope', 'Groups', function($scope, Groups){ + $scope._chatMessage = ''; + $scope.postChat = function(group, message){ + if (_.isEmpty(message)) return + $('.chat-btn').addClass('disabled'); + group.$postChat({message:message}, function(data){ + $scope._chatMessage = ''; + group.chat = data.chat; + $('.chat-btn').removeClass('disabled'); + }); + } + + }]) + .controller("GuildsCtrl", ['$scope', 'Groups', function($scope, Groups) { $scope.type = 'guild'; diff --git a/views/options/groups/chat-box.jade b/views/options/groups/chat-box.jade index c99e5b8e0b..6c20b3c62d 100644 --- a/views/options/groups/chat-box.jade +++ b/views/options/groups/chat-box.jade @@ -1,6 +1,6 @@ -form(ng-submit='postChat(group,_chatMessage)') +form(ng-controller='ChatCtrl', ng-submit='postChat(group,_chatMessage)') //FIXME ng-model makes this painfully slow! using jquery for now, which is really non-angular-like //textarea.span6(rows='3', ui-keypress='{13:"postChat(group,_chatMessage)"}', ng-model='_chatMessage') - textarea.span6.chat-textarea(rows='3', ui-keypress='{13:"postChat(group,$event)"}') + textarea.span6.chat-textarea(rows='3', ui-keypress='{13:"postChat(group,_chatMessage)"}', ng-model='_chatMessage') br input.btn.chat-btn(type='submit', value='Send Chat')