MS DG; mentions work in new publisher

This commit is contained in:
danielgrippi 2012-03-08 17:24:00 -08:00 committed by Dennis Collinson
parent fd0065598c
commit 4c46cc4246
8 changed files with 52 additions and 10 deletions

View file

@ -31,6 +31,7 @@ javascripts:
- public/javascripts/vendor/jquery.idle-timer.js - public/javascripts/vendor/jquery.idle-timer.js
- public/javascripts/jquery.infinitescroll-custom.js - public/javascripts/jquery.infinitescroll-custom.js
- public/javascripts/jquery.autocomplete-custom.js - public/javascripts/jquery.autocomplete-custom.js
- public/javascripts/vendor/jquery.textchange.min.js
- public/javascripts/keycodes.js - public/javascripts/keycodes.js
- public/javascripts/fileuploader-custom.js - public/javascripts/fileuploader-custom.js
@ -93,7 +94,6 @@ javascripts:
- public/javascripts/friend-finder.js - public/javascripts/friend-finder.js
home: home:
- public/javascripts/publisher.js - public/javascripts/publisher.js
- public/javascripts/vendor/jquery.textchange.min.js
- public/javascripts/aspect-edit-pane.js - public/javascripts/aspect-edit-pane.js
- public/javascripts/fileuploader-custom.js - public/javascripts/fileuploader-custom.js
people: people:

View file

@ -6,6 +6,17 @@ When /^I write "([^"]*)"$/ do |text|
fill_in :text, :with => text fill_in :text, :with => text
end 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 def aspects_dropdown
find(".dropdown-toggle") find(".dropdown-toggle")
end end

View file

@ -20,3 +20,12 @@ Feature: Creating a new post
When I go to "/stream" When I go to "/stream"
Then I should see "This is super skrunkle" as the first post in my 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 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"

View file

@ -7,13 +7,30 @@ app.forms.Post = app.forms.Base.extend({
}, },
formAttrs : { formAttrs : {
"textarea.text" : "text", "textarea#text_with_markup" : "text",
"input.aspect_ids" : "aspect_ids", "input.aspect_ids" : "aspect_ids",
'input.service:checked' : 'services' 'input.service:checked' : 'services'
}, },
initialize : function(){ initialize : function() {
this.aspectsDropdown = new app.views.AspectsDropdown(); this.aspectsDropdown = new app.views.AspectsDropdown();
this.servicesSelector = new app.views.ServicesSelector(); 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);
});
} }
}); });

View file

@ -17,6 +17,7 @@ app.models.StatusMessage = app.models.Post.extend({
} }
function mungeServices (values) { function mungeServices (values) {
if(!values) { return; }
return values.length > 1 ? values : [values] return values.length > 1 ? values : [values]
} }
} }

View file

@ -1,12 +1,16 @@
<div class='row'> <div class='row'>
<div class='span12'> <div class='span12'>
<form class="new-post well"> <form class="new-post well">
<label>text<textarea class="text"/></label> <label>
<div class="service_selector"/> text
<div class="aspect_selector"/> <textarea class="text span8"/>
<textarea id="text_with_markup" style="display:none;"/>
</label>
<div class="service_selector"></div>
<div class="aspect_selector"></div>
<br/> <br/>
<input type="submit" class="btn-primary" value="Share"></input> <input type="submit" class="btn-primary" value="Share" />
</form> </form>
</div> </div>
</div> </div>

View file

@ -1,10 +1,10 @@
var Mentions = { var Mentions = {
initialize: function(mentionsInput) { initialize: function(mentionsInput) {
mentionsInput.mentionsInput(Mentions.options); return mentionsInput.mentionsInput(Mentions.options);
}, },
fetchContacts : function(){ fetchContacts : function(){
Mentions.contacts || $.getJSON($(".selected_contacts_link").attr("href"), function(data) { Mentions.contacts || $.getJSON("/contacts", function(data) {
Mentions.contacts = data; Mentions.contacts = data;
}); });
}, },

View file

@ -11,7 +11,7 @@ describe("app.forms.Post", function(){
describe("submitting a valid form", function(){ describe("submitting a valid form", function(){
beforeEach(function(){ beforeEach(function(){
this.view.$("form .text").val("Oh My") this.view.$("form #text_with_markup").val("Oh My")
this.view.$("form .aspect_ids").val("public") this.view.$("form .aspect_ids").val("public")
/* appending checkboxes */ /* appending checkboxes */