mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-01 19:50:37 +00:00
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:
parent
e069718da7
commit
524457b5d7
5 changed files with 11 additions and 4 deletions
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Reference in a new issue