DG MS; only fetch contacts when focused in on Publisher.input(); limit autocomplete; added uma back; fixed jasmine tests.

This commit is contained in:
danielgrippi 2012-01-26 18:43:08 -08:00
parent fa1ee731af
commit a3d596a853
6 changed files with 13 additions and 5 deletions

View file

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 67 KiB

View file

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View file

@ -1,11 +1,10 @@
var Mentions = { var Mentions = {
initialize: function(mentionsInput) { initialize: function(mentionsInput) {
mentionsInput.mentionsInput(Mentions.options); mentionsInput.mentionsInput(Mentions.options);
Mentions.fetchContacts();
}, },
fetchContacts : function(){ fetchContacts : function(){
$.getJSON($(".selected_contacts_link").attr("href"), function(data) { Mentions.contacts || $.getJSON($(".selected_contacts_link").attr("href"), function(data) {
Mentions.contacts = data; Mentions.contacts = data;
}); });
}, },
@ -16,7 +15,7 @@ var Mentions = {
onDataRequest: function(mode, query, callback) { onDataRequest: function(mode, query, callback) {
var filteredResults = _.filter(Mentions.contacts, function(item) { return item.name.toLowerCase().indexOf(query.toLowerCase()) > -1 }); var filteredResults = _.filter(Mentions.contacts, function(item) { return item.name.toLowerCase().indexOf(query.toLowerCase()) > -1 });
callback.call(this, filteredResults); callback.call(this, filteredResults.slice(0,5));
}, },
templates: { templates: {

View file

@ -118,6 +118,7 @@ var Publisher = {
} }
} }
}, },
createCounter: function(service){ createCounter: function(service){
var counter = $("#publisher .counter"); var counter = $("#publisher .counter");
counter.remove(); counter.remove();
@ -205,6 +206,10 @@ var Publisher = {
Mentions.initialize(Publisher.input()); Mentions.initialize(Publisher.input());
Publisher.input().bind("focus", function(){
Mentions.fetchContacts();
})
if(Publisher.hiddenInput().val() === "") { if(Publisher.hiddenInput().val() === "") {
Publisher.hiddenInput().val(Publisher.input().val()); Publisher.hiddenInput().val(Publisher.input().val());
} }

View file

@ -986,6 +986,9 @@ label:not(.bootstrapped)
:position relative :position relative
:top -2px :top -2px
#status_message_fake_text
:min-height 20px
.content_creation .content_creation
:margin :margin
@ -1033,6 +1036,7 @@ label:not(.bootstrapped)
#publisher_textarea_wrapper #publisher_textarea_wrapper
#hide_publisher #hide_publisher
@include opacity(0.3) @include opacity(0.3)
:z-index 5
:padding 3px :padding 3px
:position absolute :position absolute
:right 6px :right 6px

View file

@ -11,7 +11,7 @@ describe("app.views.Comment", function(){
}) })
it("doesn't have a delete link if the author is not the current user", function(){ it("doesn't have a delete link if the author is not the current user", function(){
loginAs(_.extend(this.comment.get("author"), {diaspora_id : "notbob@bob.com"}) loginAs(factory.author({diaspora_id : "notbob@bob.com"}))
expect(this.view.render().$('.delete').length).toBe(0) expect(this.view.render().$('.delete').length).toBe(0)
}) })
@ -28,7 +28,7 @@ describe("app.views.Comment", function(){
}) })
it("returns false if the author diaspora_id != the current user's diaspora_id", function(){ it("returns false if the author diaspora_id != the current user's diaspora_id", function(){
loginAs(_.extend(this.comment.get("author"), {diaspora_id : "notbob@bob.com"}) loginAs(factory.author({diaspora_id : "notbob@bob.com"}))
expect(this.view.ownComment()).toBe(false); expect(this.view.ownComment()).toBe(false);
}) })