Merge pull request #5652 from svbergerem/add-hovercards-to-mentions
Add hovercards for mentions
This commit is contained in:
commit
ac75b476d0
4 changed files with 22 additions and 8 deletions
4
Gemfile
4
Gemfile
|
|
@ -89,9 +89,9 @@ gem 'rails-assets-jquery', '1.11.1' # Should be kep
|
|||
gem 'js_image_paths', '0.0.1'
|
||||
gem 'js-routes', '0.9.9'
|
||||
gem 'rails-assets-punycode', '1.3.2'
|
||||
gem 'rails-assets-markdown-it', '3.0.3'
|
||||
gem 'rails-assets-markdown-it', '3.0.5'
|
||||
gem 'rails-assets-markdown-it-hashtag', '0.2.3'
|
||||
gem 'rails-assets-markdown-it-diaspora-mention', '0.1.2'
|
||||
gem 'rails-assets-markdown-it-diaspora-mention', '0.2.0'
|
||||
gem 'rails-assets-markdown-it-sanitizer', '0.2.0'
|
||||
gem 'rails-assets-markdown-it--markdown-it-for-inline', '0.1.0'
|
||||
gem 'rails-assets-markdown-it-sub', '0.1.0'
|
||||
|
|
|
|||
|
|
@ -444,8 +444,8 @@ GEM
|
|||
rails-assets-jquery.slimscroll (1.3.3)
|
||||
rails-assets-jquery (>= 1.7)
|
||||
rails-assets-markdown-it--markdown-it-for-inline (0.1.0)
|
||||
rails-assets-markdown-it (3.0.3)
|
||||
rails-assets-markdown-it-diaspora-mention (0.1.2)
|
||||
rails-assets-markdown-it (3.0.5)
|
||||
rails-assets-markdown-it-diaspora-mention (0.2.0)
|
||||
rails-assets-markdown-it-hashtag (0.2.3)
|
||||
rails-assets-markdown-it-sanitizer (0.2.0)
|
||||
rails-assets-markdown-it-sub (0.1.0)
|
||||
|
|
@ -698,9 +698,9 @@ DEPENDENCIES
|
|||
rails-assets-jquery-idletimer (= 1.0.1)
|
||||
rails-assets-jquery-placeholder (= 2.0.8)
|
||||
rails-assets-jquery-textchange (= 0.2.3)
|
||||
rails-assets-markdown-it (= 3.0.3)
|
||||
rails-assets-markdown-it (= 3.0.5)
|
||||
rails-assets-markdown-it--markdown-it-for-inline (= 0.1.0)
|
||||
rails-assets-markdown-it-diaspora-mention (= 0.1.2)
|
||||
rails-assets-markdown-it-diaspora-mention (= 0.2.0)
|
||||
rails-assets-markdown-it-hashtag (= 0.2.3)
|
||||
rails-assets-markdown-it-sanitizer (= 0.2.0)
|
||||
rails-assets-markdown-it-sub (= 0.1.0)
|
||||
|
|
|
|||
|
|
@ -59,7 +59,11 @@
|
|||
});
|
||||
|
||||
var mentionPlugin = window.markdownitDiasporaMention;
|
||||
md.use(mentionPlugin, mentions);
|
||||
md.use(mentionPlugin, {
|
||||
mentions: mentions,
|
||||
allowHovercards: true,
|
||||
currentUserId: app.currentUser.get('guid')
|
||||
});
|
||||
|
||||
var subPlugin = window.markdownitSub;
|
||||
md.use(subPlugin);
|
||||
|
|
|
|||
|
|
@ -33,12 +33,14 @@ describe("app.helpers.textFormatter", function(){
|
|||
this.alice = factory.author({
|
||||
name : "Alice Smith",
|
||||
diaspora_id : "alice@example.com",
|
||||
guid: "555",
|
||||
id : "555"
|
||||
});
|
||||
|
||||
this.bob = factory.author({
|
||||
name : "Bob Grimm",
|
||||
diaspora_id : "bob@example.com",
|
||||
guid: "666",
|
||||
id : "666"
|
||||
});
|
||||
|
||||
|
|
@ -70,12 +72,20 @@ describe("app.helpers.textFormatter", function(){
|
|||
expect(wrapper.find("a[href='googlebot.com']").text()).toContain(freshBob.name);
|
||||
});
|
||||
|
||||
it('returns the name of the mention if the mention does not exist in the array', function(){
|
||||
it("returns the name of the mention if the mention does not exist in the array", function(){
|
||||
var text = "hey there @{Chris Smith; chris@example.com}";
|
||||
var formattedText = this.formatter(text, []);
|
||||
expect(formattedText.match(/<a/)).toBeNull();
|
||||
expect(formattedText).toContain('Chris Smith');
|
||||
});
|
||||
|
||||
it("makes mentions hovercardable unless the current user has been mentioned", function() {
|
||||
app.currentUser.get = jasmine.createSpy().and.returnValue(this.alice.guid);
|
||||
var formattedText = this.formatter(this.statusMessage.get("text"), this.statusMessage.get("mentioned_people"));
|
||||
var wrapper = $("<div>").html(formattedText);
|
||||
expect(wrapper.find("a[href='/people/" + this.alice.guid + "']")).not.toHaveClass('hovercardable');
|
||||
expect(wrapper.find("a[href='/people/" + this.bob.guid + "']")).toHaveClass('hovercardable');
|
||||
});
|
||||
});
|
||||
|
||||
context("markdown", function(){
|
||||
|
|
|
|||
Loading…
Reference in a new issue