From 1b2b10877abd0d77bee12b756df5350437381356 Mon Sep 17 00:00:00 2001 From: Steffen van Bergerem Date: Mon, 9 Mar 2015 21:11:36 +0100 Subject: [PATCH] Fix services char counter --- app/assets/javascripts/app/views/publisher_view.js | 2 ++ app/assets/stylesheets/publisher.scss | 1 + spec/javascripts/app/views/publisher_view_spec.js | 11 +++++++++++ 3 files changed, 14 insertions(+) diff --git a/app/assets/javascripts/app/views/publisher_view.js b/app/assets/javascripts/app/views/publisher_view.js index b3457916d..6c6e86372 100644 --- a/app/assets/javascripts/app/views/publisher_view.js +++ b/app/assets/javascripts/app/views/publisher_view.js @@ -361,6 +361,8 @@ app.views.Publisher = Backbone.View.extend({ // clear text(s) this.el_input.val(''); this.el_hiddenInput.val(''); + this.el_input.trigger('keyup') + .trigger('keydown'); // remove mentions this.el_input.mentionsInput('reset'); diff --git a/app/assets/stylesheets/publisher.scss b/app/assets/stylesheets/publisher.scss index 7287500fd..ceb40b995 100644 --- a/app/assets/stylesheets/publisher.scss +++ b/app/assets/stylesheets/publisher.scss @@ -7,6 +7,7 @@ #location_container, #hide_publisher, #photodropzone_container, + .counter, .options_and_submit { display: none !important; } diff --git a/spec/javascripts/app/views/publisher_view_spec.js b/spec/javascripts/app/views/publisher_view_spec.js index 9f1d98cf0..bcb73ee13 100644 --- a/spec/javascripts/app/views/publisher_view_spec.js +++ b/spec/javascripts/app/views/publisher_view_spec.js @@ -264,6 +264,17 @@ describe("app.views.Publisher", function() { expect(this.view.$('input[name="services[]"][value="'+prov1+'"]').length).toBe(0); expect(this.view.$('input[name="services[]"][value="'+prov2+'"]').length).toBe(1); }); + + describe("#clear", function() { + it("resets the char counter", function() { + this.view.$(".service_icon").first().trigger("click"); + expect(parseInt(this.view.$(".counter").text(), 10)).toBeGreaterThan(0); + this.view.$(".counter").text("0"); + expect(parseInt(this.view.$(".counter").text(), 10)).not.toBeGreaterThan(0); + this.view.clear($.Event()); + expect(parseInt(this.view.$(".counter").text(), 10)).toBeGreaterThan(0); + }); + }); }); context("aspect selection", function(){