rewrit: bug fix to chat not posting. this may cause perf issues, revisit
This commit is contained in:
@@ -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';
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user