rewrit: bug fix to chat not posting. this may cause perf issues, revisit

This commit is contained in:
Tyler Renelle
2013-09-01 19:23:16 -04:00
parent 273968b2b3
commit 8142241544
2 changed files with 19 additions and 22 deletions
+17 -20
View File
@@ -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';
+2 -2
View File
@@ -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')