parent
260272cbee
commit
ffb442266f
2 changed files with 1 additions and 34 deletions
|
|
@ -5,8 +5,6 @@ app.views.SearchBase = app.views.Base.extend({
|
|||
this.setupBloodhound(options);
|
||||
if(options.customSearch) { this.setupCustomSearch(); }
|
||||
this.setupTypeahead();
|
||||
// TODO: Remove this as soon as corejavascript/typeahead.js has its first release
|
||||
this.setupMouseSelectionEvents();
|
||||
if(options.autoselect) { this.setupAutoselect(); }
|
||||
},
|
||||
|
||||
|
|
@ -98,19 +96,6 @@ app.views.SearchBase = app.views.Base.extend({
|
|||
suggestion.addClass("tt-cursor");
|
||||
},
|
||||
|
||||
// TODO: Remove this as soon as corejavascript/typeahead.js has its first release
|
||||
setupMouseSelectionEvents: function() {
|
||||
var self = this,
|
||||
selectSuggestion = function(e) { self._selectSuggestion($(e.target).closest(".tt-suggestion")); },
|
||||
deselectAllSuggestions = function() { self._deselectAllSuggestions(); };
|
||||
|
||||
this.typeaheadInput.on("typeahead:render", function() {
|
||||
self.$(".tt-menu .tt-suggestion").off("mouseover").on("mouseover", selectSuggestion);
|
||||
self.$(".tt-menu .tt-suggestion *").off("mouseover").on("mouseover", selectSuggestion);
|
||||
self.$(".tt-menu .tt-suggestion").off("mouseleave").on("mouseleave", deselectAllSuggestions);
|
||||
});
|
||||
},
|
||||
|
||||
// Selects the first result when the result dropdown opens
|
||||
setupAutoselect: function() {
|
||||
var self = this;
|
||||
|
|
|
|||
|
|
@ -41,12 +41,6 @@ describe("app.views.SearchBase", function() {
|
|||
expect(app.views.SearchBase.prototype.setupTypeahead).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("calls setupMouseSelectionEvents", function() {
|
||||
spyOn(app.views.SearchBase.prototype, "setupMouseSelectionEvents");
|
||||
this.view = new app.views.SearchBase({el: "#search_people_form", typeaheadInput: $("#q")});
|
||||
expect(app.views.SearchBase.prototype.setupMouseSelectionEvents).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("initializes the array of diaspora ids that should be excluded from the search results", function() {
|
||||
this.view = new app.views.SearchBase({el: "#search_people_form", typeaheadInput: $("#q")});
|
||||
expect(this.view.ignoreDiasporaIds.length).toBe(0);
|
||||
|
|
@ -165,24 +159,12 @@ describe("app.views.SearchBase", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("setupMouseSelectionEvents", function() {
|
||||
describe("typeahead mouse events", function() {
|
||||
beforeEach(function() {
|
||||
this.view = new app.views.SearchBase({el: "#search_people_form", typeaheadInput: $("#q")});
|
||||
this.view.bloodhound.add(this.bloodhoundData);
|
||||
});
|
||||
|
||||
it("binds mouseover and mouseleave events only once", function() {
|
||||
this.search(this.view, "user");
|
||||
$("#q").trigger("focusout");
|
||||
expect($._data($(".tt-menu .tt-suggestion")[0], "events").mouseover.length).toBe(1);
|
||||
expect($._data($(".tt-menu .tt-suggestion")[0], "events").mouseout.length).toBe(1);
|
||||
|
||||
this.search(this.view, "user");
|
||||
$("#q").trigger("focusout");
|
||||
expect($._data($(".tt-menu .tt-suggestion")[0], "events").mouseover.length).toBe(1);
|
||||
expect($._data($(".tt-menu .tt-suggestion")[0], "events").mouseout.length).toBe(1);
|
||||
});
|
||||
|
||||
it("allows selecting results with the mouse", function() {
|
||||
this.search(this.view, "user");
|
||||
this.view.$(".tt-menu .tt-suggestion:eq(0)").trigger("mouseover");
|
||||
|
|
|
|||
Loading…
Reference in a new issue