diff --git a/config/assets.yml b/config/assets.yml index 592896930..5212580a3 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -31,6 +31,7 @@ javascripts: - public/javascripts/vendor/jquery.idle-timer.js - public/javascripts/jquery.infinitescroll-custom.js - public/javascripts/jquery.autocomplete-custom.js + - public/javascripts/vendor/jquery.textchange.min.js - public/javascripts/keycodes.js - public/javascripts/fileuploader-custom.js @@ -93,7 +94,6 @@ javascripts: - public/javascripts/friend-finder.js home: - public/javascripts/publisher.js - - public/javascripts/vendor/jquery.textchange.min.js - public/javascripts/aspect-edit-pane.js - public/javascripts/fileuploader-custom.js people: diff --git a/features/step_definitions/trumpeter_steps.rb b/features/step_definitions/trumpeter_steps.rb index 3464df209..89c1e57ba 100644 --- a/features/step_definitions/trumpeter_steps.rb +++ b/features/step_definitions/trumpeter_steps.rb @@ -6,6 +6,17 @@ When /^I write "([^"]*)"$/ do |text| fill_in :text, :with => text end +Then /I mention "([^"]*)"$/ do |text| + fill_in_autocomplete('textarea.text', '@a') + sleep(5) + find("li.active").click +end + +def fill_in_autocomplete(selector, value) + page.execute_script %Q{$('#{selector}').val('#{value}').keyup()} +end + + def aspects_dropdown find(".dropdown-toggle") end diff --git a/features/trumpeter.feature b/features/trumpeter.feature index d60399688..68701d41c 100644 --- a/features/trumpeter.feature +++ b/features/trumpeter.feature @@ -20,3 +20,12 @@ Feature: Creating a new post When I go to "/stream" Then I should see "This is super skrunkle" as the first post in my stream Then "This is super skrunkle" should be a limited post in my stream + + Scenario: Mention a contact + Given a user named "Alice Smith" with email "alice@alice.alice" + And a user with email "bob@bob.bob" is connected with "alice@alice.alice" + And I mention "alice@alice.alice" + And I press "Share" + And I go to "/stream" + Then I follow "Alice Smith" + diff --git a/public/javascripts/app/forms/post_form.js b/public/javascripts/app/forms/post_form.js index afc5198c9..d2bc494c9 100644 --- a/public/javascripts/app/forms/post_form.js +++ b/public/javascripts/app/forms/post_form.js @@ -7,13 +7,30 @@ app.forms.Post = app.forms.Base.extend({ }, formAttrs : { - "textarea.text" : "text", + "textarea#text_with_markup" : "text", "input.aspect_ids" : "aspect_ids", 'input.service:checked' : 'services' }, - initialize : function(){ + initialize : function() { this.aspectsDropdown = new app.views.AspectsDropdown(); this.servicesSelector = new app.views.ServicesSelector(); + }, + + postRenderTemplate : function() { + this.prepAndBindMentions() + }, + + prepAndBindMentions : function(){ + Mentions.initialize(this.$("textarea.text")); + Mentions.fetchContacts(); + + this.$("textarea.text").bind("textchange", $.proxy(this.updateTextWithMarkup, this)) + }, + + updateTextWithMarkup : function() { + this.$("form textarea.text").mentionsInput('val', function(markup){ + $('#text_with_markup').val(markup); + }); } }); \ No newline at end of file diff --git a/public/javascripts/app/models/status_message.js b/public/javascripts/app/models/status_message.js index e9a6f3204..6359af399 100644 --- a/public/javascripts/app/models/status_message.js +++ b/public/javascripts/app/models/status_message.js @@ -17,6 +17,7 @@ app.models.StatusMessage = app.models.Post.extend({ } function mungeServices (values) { + if(!values) { return; } return values.length > 1 ? values : [values] } } diff --git a/public/javascripts/app/templates/post-form.handlebars b/public/javascripts/app/templates/post-form.handlebars index f41fe137a..6b8a32d95 100644 --- a/public/javascripts/app/templates/post-form.handlebars +++ b/public/javascripts/app/templates/post-form.handlebars @@ -1,12 +1,16 @@