diff --git a/app/assets/javascripts/app/views/search_base_view.js b/app/assets/javascripts/app/views/search_base_view.js index 72b032337..5769c7fb8 100644 --- a/app/assets/javascripts/app/views/search_base_view.js +++ b/app/assets/javascripts/app/views/search_base_view.js @@ -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; diff --git a/spec/javascripts/app/views/search_base_view_spec.js b/spec/javascripts/app/views/search_base_view_spec.js index 5ed6be4db..f53b52a1f 100644 --- a/spec/javascripts/app/views/search_base_view_spec.js +++ b/spec/javascripts/app/views/search_base_view_spec.js @@ -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");