Merge branch 'joyclark-autocomplete-click-behavior' into develop

This commit is contained in:
Blade Barringer
2015-05-08 08:45:06 -05:00
3 changed files with 22 additions and 3 deletions

View File

@@ -219,6 +219,20 @@ describe("Autocomplete controller", function() {
});
});
describe("performCompletion", function() {
it('triggers autoComplete', function() {
scope.autoComplete = sinon.spy();
var msg = {user: "boo"}; // scope.autoComplete only cares about user
scope.query = {text: "b"};
scope.performCompletion(msg);
expect(scope.query).to.be.eq(null);
expect(scope.autoComplete.callCount).to.be.eq(1);
expect(scope.autoComplete).to.have.been.calledWith(msg);
});
});
describe("addNewUser", function() {
it('a new message from a new user will modify the usernames', function() {
expect(scope.response).to.be.empty;

View File

@@ -232,6 +232,11 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
return user.indexOf(text) == 0;
}
$scope.performCompletion = function(msg) {
$scope.autoComplete(msg);
$scope.query = null;
}
$scope.addNewUser = function(user) {
if($.inArray(user.user,$scope.usernames) == -1) {
user.username = user.user;

View File

@@ -13,9 +13,9 @@ div.chat-form.guidelines-not-accepted(ng-if='!user.flags.communityGuidelinesAcce
form.chat-form(ng-if='user.flags.communityGuidelinesAccepted' ng-submit='postChat(group,message.content)')
div(ng-controller='AutocompleteCtrl')
textarea.form-control(rows=4, ui-keydown='{"meta-enter":"postChat(group,message.content)"}', ui-keypress='{13:"postChat(group,message.content)"}', ng-model='message.content', updateinterval='250', flag='@', at-user, auto-complete placeholder="{{group._id == 'habitrpg' ? env.t('tavernCommunityGuidelinesPlaceholder') : ''}}")
span.user-list(ng-show='!isAtListHidden')
ul.list-at-user
li(ng-repeat='msg in response | filter:filterUser | limitTo: 5', ng-click='autoComplete(msg)')
span.user-list
ul.list-at-user(ng-show="query")
li(ng-repeat='msg in response | filter:filterUser | limitTo: 5', ng-click='performCompletion(msg)')
span.username.label.label-default(ng-class=':: userLevelStyle(msg)') {{::msg.user}}
.chat-controls
.chat-formatting