From a6e6e6de9125755251e05e15a931cab6a350c117 Mon Sep 17 00:00:00 2001 From: Steffen van Bergerem Date: Mon, 30 Jan 2017 14:09:55 +0100 Subject: [PATCH] Refactor publisher mentions backbone view --- .../app/views/publisher/mention_view.js | 11 ++--------- .../app/views/publisher_mention_view_spec.js | 16 ++-------------- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/app/assets/javascripts/app/views/publisher/mention_view.js b/app/assets/javascripts/app/views/publisher/mention_view.js index 36ab541cf..f30779c70 100644 --- a/app/assets/javascripts/app/views/publisher/mention_view.js +++ b/app/assets/javascripts/app/views/publisher/mention_view.js @@ -7,7 +7,7 @@ app.views.PublisherMention = app.views.SearchBase.extend({ events: { "keydown #status_message_text": "onInputBoxKeyDown", - "input #status_message_text": "onInputBoxInput", + "input #status_message_text": "updateTypeaheadInput", "click #status_message_text": "onInputBoxClick", "blur #status_message_text": "onInputBoxBlur" }, @@ -120,13 +120,6 @@ app.views.PublisherMention = app.views.SearchBase.extend({ this.typeaheadInput.trigger($.Event("keydown", {keyCode: e.keyCode, which: e.which})); }, - /** - * Listens for user input and opens results dropdown when input contains the trigger char - */ - onInputBoxInput: function() { - this.updateTypeaheadInput(); - }, - onInputBoxKeyDown: function(e) { // This also matches HOME/END on OSX which is CMD+LEFT, CMD+RIGHT if(e.which === Keycodes.LEFT || e.which === Keycodes.RIGHT || @@ -169,7 +162,7 @@ app.views.PublisherMention = app.views.SearchBase.extend({ reset: function() { this.inputBox.val(""); - this.onInputBoxInput(); + this.updateTypeaheadInput(); }, closeSuggestions: function() { diff --git a/spec/javascripts/app/views/publisher_mention_view_spec.js b/spec/javascripts/app/views/publisher_mention_view_spec.js index 666a62d96..5f53c110f 100644 --- a/spec/javascripts/app/views/publisher_mention_view_spec.js +++ b/spec/javascripts/app/views/publisher_mention_view_spec.js @@ -363,18 +363,6 @@ describe("app.views.PublisherMention", function() { }); }); - describe("onInputBoxInput", function() { - beforeEach(function() { - this.view = new app.views.PublisherMention({ el: "#publisher" }); - }); - - it("calls 'updateTypeaheadInput'", function() { - spyOn(this.view, "updateTypeaheadInput"); - this.view.onInputBoxInput(); - expect(this.view.updateTypeaheadInput).toHaveBeenCalled(); - }); - }); - describe("onInputBoxClick", function() { beforeEach(function() { this.view = new app.views.PublisherMention({ el: "#publisher" }); @@ -402,13 +390,13 @@ describe("app.views.PublisherMention", function() { describe("reset", function() { beforeEach(function() { this.view = new app.views.PublisherMention({ el: "#publisher" }); - spyOn(this.view, "onInputBoxInput"); + spyOn(this.view, "updateTypeaheadInput"); }); it("resets the mention box", function() { this.view.reset(); expect(this.view.inputBox.val()).toBe(""); - expect(this.view.onInputBoxInput).toHaveBeenCalled(); + expect(this.view.updateTypeaheadInput).toHaveBeenCalled(); }); });