Merge pull request #6953 from svbergerem/fix-typeahead-mentions
Fix typeahead mentions
This commit is contained in:
commit
c1bd072e76
7 changed files with 2484 additions and 15 deletions
4
.pronto.yml
Normal file
4
.pronto.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
all:
|
||||
exclude:
|
||||
- "vendor/**/*"
|
||||
consolidate_comments: true
|
||||
1
Gemfile
1
Gemfile
|
|
@ -106,7 +106,6 @@ source "https://rails-assets.org" do
|
|||
gem "rails-assets-markdown-it-sub", "1.0.0"
|
||||
gem "rails-assets-markdown-it-sup", "1.0.0"
|
||||
gem "rails-assets-highlightjs", "9.4.0"
|
||||
gem "rails-assets-typeahead.js", "0.11.1"
|
||||
|
||||
# jQuery plugins
|
||||
|
||||
|
|
|
|||
|
|
@ -679,8 +679,6 @@ GEM
|
|||
rails-assets-markdown-it-sub (1.0.0)
|
||||
rails-assets-markdown-it-sup (1.0.0)
|
||||
rails-assets-perfect-scrollbar (0.6.11)
|
||||
rails-assets-typeahead.js (0.11.1)
|
||||
rails-assets-jquery (>= 1.7)
|
||||
rails-deprecated_sanitizer (1.0.3)
|
||||
activesupport (>= 4.2.0.alpha)
|
||||
rails-dom-testing (1.0.7)
|
||||
|
|
@ -1011,7 +1009,6 @@ DEPENDENCIES
|
|||
rails-assets-markdown-it-sub (= 1.0.0)!
|
||||
rails-assets-markdown-it-sup (= 1.0.0)!
|
||||
rails-assets-perfect-scrollbar (= 0.6.11)!
|
||||
rails-assets-typeahead.js (= 0.11.1)!
|
||||
rails-i18n (= 4.0.8)
|
||||
rails-timeago (= 2.11.0)
|
||||
rails_admin (= 0.8.1)
|
||||
|
|
|
|||
|
|
@ -43,14 +43,14 @@ app.views.SearchBase = app.views.Base.extend({
|
|||
setupCustomSearch: function() {
|
||||
var self = this;
|
||||
this.bloodhound.customSearch = function(query, sync, async) {
|
||||
var _sync = function(datums) {
|
||||
var _async = function(datums) {
|
||||
var results = datums.filter(function(datum) {
|
||||
return datum.handle !== undefined && self.ignoreDiasporaIds.indexOf(datum.handle) === -1;
|
||||
});
|
||||
sync(results);
|
||||
async(results);
|
||||
};
|
||||
|
||||
self.bloodhound.search(query, _sync, async);
|
||||
self.bloodhound.search(query, sync, _async);
|
||||
};
|
||||
},
|
||||
|
||||
|
|
@ -59,9 +59,8 @@ app.views.SearchBase = app.views.Base.extend({
|
|||
hint: false,
|
||||
highlight: true,
|
||||
minLength: 2
|
||||
},
|
||||
{
|
||||
name: "search",
|
||||
}, {
|
||||
async: true,
|
||||
display: "name",
|
||||
limit: 5,
|
||||
source: this.bloodhound.customSearch !== undefined ? this.bloodhound.customSearch : this.bloodhound,
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
//= require markdown-it-sup
|
||||
//= require highlightjs
|
||||
//= require clear-form
|
||||
//= require typeahead.js
|
||||
//= require typeahead.bundle.js
|
||||
//= require app/app
|
||||
//= require diaspora
|
||||
//= require_tree ./helpers
|
||||
|
|
|
|||
|
|
@ -109,22 +109,26 @@ describe("app.views.SearchBase", function() {
|
|||
this.view = new app.views.SearchBase({
|
||||
el: "#search_people_form",
|
||||
typeaheadInput: $("#q"),
|
||||
customSearch: true
|
||||
customSearch: true,
|
||||
remoteRoute: "/contacts"
|
||||
});
|
||||
this.view.bloodhound.add(this.bloodhoundData);
|
||||
this.view.bloodhound.search = function(query, sync, async) {
|
||||
sync([]);
|
||||
async(this.bloodhoundData);
|
||||
}.bind(this);
|
||||
});
|
||||
|
||||
it("returns all results if none of them should be ignored", function() {
|
||||
var spy = jasmine.createSpyObj("callbacks", ["syncCallback", "asyncCallback"]);
|
||||
this.view.bloodhound.customSearch("user", spy.syncCallback, spy.asyncCallback);
|
||||
expect(spy.syncCallback).toHaveBeenCalledWith(this.bloodhoundData);
|
||||
expect(spy.asyncCallback).toHaveBeenCalledWith(this.bloodhoundData);
|
||||
});
|
||||
|
||||
it("doesn't return results that should be ignored", function() {
|
||||
var spy = jasmine.createSpyObj("callbacks", ["syncCallback", "asyncCallback"]);
|
||||
this.view.ignorePersonForSuggestions({handle: "user1@pod.tld"});
|
||||
this.view.bloodhound.customSearch("user", spy.syncCallback, spy.asyncCallback);
|
||||
expect(spy.syncCallback).toHaveBeenCalledWith([this.bloodhoundData[1]]);
|
||||
expect(spy.asyncCallback).toHaveBeenCalledWith([this.bloodhoundData[1]]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
2466
vendor/assets/javascripts/typeahead.bundle.js
vendored
Normal file
2466
vendor/assets/javascripts/typeahead.bundle.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue