chat: keyup to trigger send message. ng-model on chat box is painfully

slow! using jquery as workaround for now
This commit is contained in:
Tyler Renelle 2013-08-31 20:52:41 -04:00
parent e069718da7
commit 524457b5d7
5 changed files with 11 additions and 4 deletions

View file

@ -1,7 +1,7 @@
"use strict";
window.habitrpg = angular.module('habitrpg',
['ngRoute', 'ngResource', 'userServices', 'groupServices', 'sharedServices', 'authServices', 'notificationServices', 'ui.bootstrap'])
['ngRoute', 'ngResource', 'userServices', 'groupServices', 'sharedServices', 'authServices', 'notificationServices', 'ui.bootstrap', 'ui.keypress'])
.constant("API_URL", "")
.constant("STORAGE_USER_ID", 'habitrpg-user')

View file

@ -9,11 +9,14 @@ habitrpg
$scope.members = groups.members;
});
$scope.postChat = function(group, message){
//FIXME ng-model makes this painfully slow! using jquery for now, which is really non-angular-like
message = $('.chat-textarea').val();
if (_.isEmpty(message)) return
$('.chat-btn').addClass('disabled');
$http.post('/api/v1/groups/'+group._id+'/chat', {message:message})
.success(function(data){
$scope._chatMessage = '';
//$scope._chatMessage = '';
$('.chat-textarea').val('');
group.chat = data;
$('.chat-btn').removeClass('disabled');
});

View file

@ -31,7 +31,8 @@
"sticky": "*",
"bootstrap-datepicker": "~1.2.0",
"bootstrap": "v2.3.2",
"angular-route": "1.2.0-rc.1"
"angular-route": "1.2.0-rc.1",
"angular-ui-utils": "~0.0.4"
},
"resolutions": {
"jquery": "~2.0.3",

View file

@ -29,6 +29,7 @@ html
script(type='text/javascript', src='/bower_components/angular-route/angular-route.js')
script(type='text/javascript', src='/bower_components/angular-resource/angular-resource.js')
script(type='text/javascript', src='/bower_components/angular-ui/build/angular-ui.js')
script(type='text/javascript', src='/bower_components/angular-ui-utils/modules/keypress/keypress.js')
// we'll remove this once angular-bootstrap is fixed
script(type='text/javascript', src='/bower_components/bootstrap/docs/assets/js/bootstrap.min.js')
script(type='text/javascript', src='/bower_components/angular-bootstrap/ui-bootstrap.js')

View file

@ -1,4 +1,6 @@
form(ng-submit='postChat(group,_chatMessage)')
textarea.span6(rows='3', x-bind='keyup:chatKeyup', ng-model='_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,_chatMessage)"}')
br
input.btn.chat-btn(type='submit', value='Send Chat')