diff --git a/app/assets/javascripts/app/views/publisher/mention_view.js b/app/assets/javascripts/app/views/publisher/mention_view.js index d678a6bf5..55efafbe2 100644 --- a/app/assets/javascripts/app/views/publisher/mention_view.js +++ b/app/assets/javascripts/app/views/publisher/mention_view.js @@ -6,18 +6,17 @@ app.views.PublisherMention = app.views.SearchBase.extend({ mentionSyntaxTemplate: function(person) { return "@{" + person.handle + "}"; }, events: { - "keydown #status_message_fake_text": "onInputBoxKeyDown", - "input #status_message_fake_text": "onInputBoxInput", - "click #status_message_fake_text": "onInputBoxClick", - "blur #status_message_fake_text": "onInputBoxBlur" + "keydown #status_message_text": "onInputBoxKeyDown", + "input #status_message_text": "onInputBoxInput", + "click #status_message_text": "onInputBoxClick", + "blur #status_message_text": "onInputBoxBlur" }, initialize: function() { this.mentionedPeople = []; - // contains the 'fake text' displayed to the user - // also has a data-messageText attribute with the original text - this.inputBox = this.$("#status_message_fake_text"); + // has a data-messageText attribute with the original text + this.inputBox = this.$("#status_message_text"); this.typeaheadInput = this.$(".typeahead-mention-box"); this.bindTypeaheadEvents(); diff --git a/app/assets/javascripts/app/views/publisher_view.js b/app/assets/javascripts/app/views/publisher_view.js index de9245027..7d789f998 100644 --- a/app/assets/javascripts/app/views/publisher_view.js +++ b/app/assets/javascripts/app/views/publisher_view.js @@ -18,11 +18,11 @@ app.views.Publisher = Backbone.View.extend({ el : "#publisher", events : { - "keydown #status_message_fake_text" : "keyDown", + "keydown #status_message_text": "keyDown", "focus textarea" : "open", "submit form" : "createStatusMessage", "click #submit" : "createStatusMessage", - "textchange #status_message_fake_text": "handleTextchange", + "textchange #status_message_text": "handleTextchange", "click #locator" : "showLocation", "click #poll_creator" : "togglePollCreator", "click #hide_location" : "destroyLocation", @@ -35,8 +35,7 @@ app.views.Publisher = Backbone.View.extend({ this.disabled = false; // init shortcut references to the various elements - this.inputEl = this.$("#status_message_fake_text"); - this.hiddenInputEl = this.$("#status_message_text"); + this.inputEl = this.$("#status_message_text"); this.wrapperEl = this.$("#publisher_textarea_wrapper"); this.submitEl = this.$("input[type=submit], button#submit"); this.photozoneEl = this.$("#photodropzone"); @@ -46,14 +45,6 @@ app.views.Publisher = Backbone.View.extend({ $(window).on("beforeunload", _.bind(this._beforeUnload, this)); $(window).unload(this.clear.bind(this)); - // sync textarea content - if( this.hiddenInputEl.val() === "" ) { - this.hiddenInputEl.val( this.inputEl.val() ); - } - if( this.inputEl.val() === "" ) { - this.inputEl.val( this.hiddenInputEl.val() ); - } - // hide close and preview buttons and manage services link // in case publisher is standalone // (e.g. bookmarklet, mentions popup) @@ -175,7 +166,6 @@ app.views.Publisher = Backbone.View.extend({ // inject content into the publisher textarea setText: function(txt) { this.inputEl.val(txt); - this.hiddenInputEl.val(txt); this.prefillText = txt; this.inputEl.trigger("input"); @@ -381,11 +371,10 @@ app.views.Publisher = Backbone.View.extend({ // remove mentions this.mention.reset(); - // clear text(s) + // clear text this.inputEl.val(""); - this.hiddenInputEl.val(""); this.inputEl.trigger("keyup") - .trigger("keydown"); + .trigger("keydown"); autosize.update(this.inputEl); // remove photos @@ -421,7 +410,6 @@ app.views.Publisher = Backbone.View.extend({ // force textchange plugin to update lastValue this.inputEl.data("lastValue", ""); - this.hiddenInputEl.data("lastValue", ""); return this; }, @@ -487,10 +475,8 @@ app.views.Publisher = Backbone.View.extend({ setInputEnabled: function(bool) { if (bool) { this.inputEl.removeAttr("disabled"); - this.hiddenInputEl.removeAttr("disabled"); } else { this.inputEl.prop("disabled", true); - this.hiddenInputEl.prop("disabled", true); } }, @@ -505,7 +491,6 @@ app.views.Publisher = Backbone.View.extend({ handleTextchange: function() { this.checkSubmitAvailability(); - this.hiddenInputEl.val(this.mention.getTextForSubmit()); }, _beforeUnload: function(e) { diff --git a/app/helpers/interim_stream_hackiness_helper.rb b/app/helpers/interim_stream_hackiness_helper.rb index b531871f2..4283a8126 100644 --- a/app/helpers/interim_stream_hackiness_helper.rb +++ b/app/helpers/interim_stream_hackiness_helper.rb @@ -21,16 +21,6 @@ module InterimStreamHackinessHelper end end - def publisher_hidden_text - if params[:prefill].present? - params[:prefill] - elsif defined?(@stream) - @stream.publisher.prefill - else - nil - end - end - def from_group(post) if defined?(@stream) && params[:controller] == 'multis' @stream.post_from_group(post) diff --git a/app/views/publisher/_publisher.html.haml b/app/views/publisher/_publisher.html.haml index 6fc8669cc..9ed2ae2ee 100644 --- a/app/views/publisher/_publisher.html.haml +++ b/app/views/publisher/_publisher.html.haml @@ -6,17 +6,16 @@ .publisher-textarea-wrapper#publisher_textarea_wrapper .mentions-input-box - if current_user.getting_started? - = status.text_area :fake_text, :rows => 2, :value => h(publisher_formatted_text), + = status.text_area :text, :rows => 2, :value => h(publisher_formatted_text), :tabindex => 1, :placeholder => "#{t('contacts.index.start_a_conversation')}...", "data-title" => popover_with_close_html("1. " + t("shared.public_explain.share")), "data-content" => t("shared.public_explain.new_user_welcome_message"), "class" => "form-control" - else - = status.text_area :fake_text, :rows => 2, :value => h(publisher_formatted_text), + = status.text_area :text, :rows => 2, :value => h(publisher_formatted_text), :tabindex => 1, :placeholder => "#{t('contacts.index.start_a_conversation')}...", "class" => "form-control" %input.typeahead-mention-box.hidden{type: "text"} - = status.hidden_field :text, value: h(publisher_hidden_text), class: "clear_on_submit" .container-fluid.photodropzone-container#photodropzone_container %ul#photodropzone diff --git a/features/desktop/post_preview.feature b/features/desktop/post_preview.feature index 827b36d36..d2a69b687 100644 --- a/features/desktop/post_preview.feature +++ b/features/desktop/post_preview.feature @@ -44,7 +44,7 @@ Feature: preview posts in the stream Given I expand the publisher And I attach "spec/fixtures/button.png" to the publisher When I fill in the following: - | status_message_fake_text | Look at this dog | + | status_message_text | Look at this dog | And I preview the post Then I should see a "img" within ".md-preview .stream-element .photo_attachments" And I should see "Look at this dog" within ".md-preview .stream-element" @@ -63,7 +63,7 @@ Feature: preview posts in the stream Then I should see "Samuel Beckett" When I expand the publisher And I fill in the following: - | status_message_fake_text | This preview rocks | + | status_message_text | This preview rocks | And I preview the post Then I should see "This preview rocks" in the preview And I close the publisher @@ -71,11 +71,11 @@ Feature: preview posts in the stream Scenario: preview a post with the poll Given I expand the publisher When I fill in the following: - | status_message_fake_text | I am eating yogurt | + | status_message_text | I am eating yogurt | And I click on selector "#poll_creator" When I fill in the following: - | status_message_fake_text | I am eating yogurt | - | poll_question | What kind of yogurt do you like? | + | status_message_text | I am eating yogurt | + | poll_question | What kind of yogurt do you like? | And I fill in the following for the options: | normal | | not normal | @@ -87,12 +87,12 @@ Feature: preview posts in the stream Scenario: preview a post with location Given I expand the publisher When I fill in the following: - | status_message_fake_text | I am eating yogurt | + | status_message_text | I am eating yogurt | And I allow geolocation And I click on selector "#locator" When I fill in the following: - | status_message_fake_text | I am eating yogurt | - | location_address | Some cool place | + | status_message_text | I am eating yogurt | + | location_address | Some cool place | And I preview the post Then I should see a ".near-from" within ".md-preview .stream-element" And I should see "Some cool place" within ".md-preview .stream-element .near-from" diff --git a/features/desktop/post_with_a_poll.feature b/features/desktop/post_with_a_poll.feature index b5b3a0ff8..5a27fc7ee 100644 --- a/features/desktop/post_with_a_poll.feature +++ b/features/desktop/post_with_a_poll.feature @@ -40,8 +40,8 @@ Feature: posting with a poll Given I expand the publisher And I click on selector "#poll_creator" When I fill in the following: - | status_message_fake_text | I am eating yogurt | - | poll_question | What kind of yogurt do you like? | + | status_message_text | I am eating yogurt | + | poll_question | What kind of yogurt do you like? | And I fill in the following for the options: | normal | | not normal | @@ -53,8 +53,8 @@ Feature: posting with a poll Given I expand the publisher And I click on selector "#poll_creator" When I fill in the following: - | status_message_fake_text | I am eating yogurt | - | poll_question | What kind of yogurt do you like? | + | status_message_text | I am eating yogurt | + | poll_question | What kind of yogurt do you like? | And I fill in the following for the options: | normal | | not normal | @@ -70,8 +70,8 @@ Feature: posting with a poll Given I expand the publisher And I click on selector "#poll_creator" When I fill in the following: - | status_message_fake_text | I am eating yogurt | - | poll_question | What kind of yogurt do you like? | + | status_message_text | I am eating yogurt | + | poll_question | What kind of yogurt do you like? | And I fill in the following for the options: | normal | | not normal | @@ -83,8 +83,8 @@ Feature: posting with a poll Given I expand the publisher And I click on selector "#poll_creator" When I fill in the following: - | status_message_fake_text | I am eating yogurt | - | poll_question | What kind of yogurt do you like? | + | status_message_text | I am eating yogurt | + | poll_question | What kind of yogurt do you like? | And I fill in the following for the options: | normal | | | diff --git a/features/mobile/posts_from_main_page.feature b/features/mobile/posts_from_main_page.feature index 22fb6195a..9afee520d 100644 --- a/features/mobile/posts_from_main_page.feature +++ b/features/mobile/posts_from_main_page.feature @@ -20,7 +20,7 @@ Feature: posting from the mobile main page Scenario: post and delete some text Given I visit the mobile publisher page - And I append "I am eating yogurt" to the mobile publisher + And I append "I am eating yogurt" to the publisher And I select "Unicorns" from "aspect_ids_" And I press "Share" When I go to the stream page @@ -52,7 +52,7 @@ Feature: posting from the mobile main page Scenario: back out of uploading a picture when another has been attached Given I visit the mobile publisher page - And I append "I am eating yogurt" to the mobile publisher + And I append "I am eating yogurt" to the publisher And I attach the file "spec/fixtures/button.gif" to hidden "qqfile" within "#file-upload-publisher" And I attach the file "spec/fixtures/button.png" to hidden "qqfile" within "#file-upload-publisher" And I click to delete the first uploaded photo diff --git a/features/step_definitions/keyboard_navigation_steps.rb b/features/step_definitions/keyboard_navigation_steps.rb index e0109902d..32188aff3 100644 --- a/features/step_definitions/keyboard_navigation_steps.rb +++ b/features/step_definitions/keyboard_navigation_steps.rb @@ -5,7 +5,7 @@ When /^I press the "([^\"]*)" key somewhere$/ do |key| end When /^I press the "([^\"]*)" key in the publisher$/ do |key| - find("#status_message_fake_text").native.send_key(key) + find("#status_message_text").native.send_key(key) end Then /^post (\d+) should be highlighted$/ do |position| diff --git a/features/step_definitions/posts_steps.rb b/features/step_definitions/posts_steps.rb index 34df49e49..a13779a2c 100644 --- a/features/step_definitions/posts_steps.rb +++ b/features/step_definitions/posts_steps.rb @@ -33,7 +33,7 @@ Then /^I should not be able to submit the publisher$/ do end Then /^I should see "([^"]*)" in the publisher$/ do |text| - expect(page).to have_field("status_message[fake_text]", with: text) + expect(page).to have_field("status_message[text]", with: text) end Given /^I have a limited post with text "([^\"]*)" in the aspect "([^"]*)"$/ do |text, aspect_name| @@ -118,10 +118,6 @@ When /^I append "([^"]*)" to the publisher$/ do |text| append_to_publisher(text) end -When /^I append "([^"]*)" to the mobile publisher$/ do |text| - append_to_publisher(text, '#status_message_text') -end - When /^I attach "([^"]*)" to the publisher$/ do |path| upload_file_with_publisher(path) end diff --git a/features/support/publishing_cuke_helpers.rb b/features/support/publishing_cuke_helpers.rb index 046f8e332..ff5f91d43 100644 --- a/features/support/publishing_cuke_helpers.rb +++ b/features/support/publishing_cuke_helpers.rb @@ -1,21 +1,12 @@ module PublishingCukeHelpers def write_in_publisher(txt) - fill_in 'status_message_fake_text', with: txt + fill_in "status_message_text", with: txt end - def append_to_publisher(txt, input_selector='#status_message_fake_text') - status_message_text = find("#status_message_text", visible: false).value - find(input_selector).native.send_key(" #{txt}") - - # make sure the other text field got the new contents - if input_selector == "#status_message_fake_text" - begin - expect(page).to have_selector("#status_message_text[value='#{status_message_text} #{txt}']", visible: false) - rescue RSpec::Expectations::ExpectationNotMetError - puts "Value was instead: #{find('#status_message_text', visible: false).value.inspect}" - raise - end - end + def append_to_publisher(txt) + status_message_text = find("#status_message_text").value + find("#status_message_text").native.send_key(" #{txt}") + expect(page).to have_field("status_message[text]", with: "#{status_message_text} #{txt}") end def upload_file_with_publisher(path) @@ -33,7 +24,7 @@ module PublishingCukeHelpers end def submit_publisher - txt = find("#publisher #status_message_fake_text").value + txt = find("#publisher #status_message_text").value find("#publisher .btn-primary").click # wait for the content to appear expect(find("#main_stream")).to have_content(txt) @@ -45,7 +36,7 @@ module PublishingCukeHelpers end def click_publisher - find("#status_message_fake_text").click + find("#status_message_text").click expect(find("#publisher")).to have_css(".publisher-textarea-wrapper.active") end diff --git a/spec/javascripts/app/views/bookmarklet_view_spec.js b/spec/javascripts/app/views/bookmarklet_view_spec.js index d5de57466..9d12f998c 100644 --- a/spec/javascripts/app/views/bookmarklet_view_spec.js +++ b/spec/javascripts/app/views/bookmarklet_view_spec.js @@ -29,23 +29,18 @@ describe("app.views.Bookmarklet", function() { it("prefills the publisher", function() { init_bookmarklet(test_data); - expect($.trim(app.publisher.inputEl.val())).not.toEqual(""); - expect($.trim(app.publisher.hiddenInputEl.val())).not.toEqual(""); }); it("handles dirty input well", function() { init_bookmarklet(evil_test_data); - expect($.trim(app.publisher.inputEl.val())).not.toEqual(""); - expect($.trim(app.publisher.hiddenInputEl.val())).not.toEqual(""); }); it("allows changing a prefilled publisher", function() { init_bookmarklet(test_data); app.publisher.setText(app.publisher.inputEl.val()+"A"); - - expect(app.publisher.hiddenInputEl.val()).toMatch(/.+A$/); + expect(app.publisher.inputEl.val()).toMatch(/.+A$/); }); it("keeps the publisher disabled after successful post creation", function() { diff --git a/spec/javascripts/app/views/publisher_view_spec.js b/spec/javascripts/app/views/publisher_view_spec.js index c672b33fa..a0bd9c292 100644 --- a/spec/javascripts/app/views/publisher_view_spec.js +++ b/spec/javascripts/app/views/publisher_view_spec.js @@ -82,9 +82,9 @@ describe("app.views.Publisher", function() { }); it("resets the element's height", function() { - $(this.view.el).find("#status_message_fake_text").height(100); + $(this.view.el).find("#status_message_text").height(100); this.view.close($.Event()); - expect($(this.view.el).find("#status_message_fake_text").attr("style")).not.toContain("height"); + expect($(this.view.el).find("#status_message_text").attr("style")).not.toContain("height"); }); it("calls autosize.update", function() { @@ -235,9 +235,7 @@ describe("app.views.Publisher", function() { describe('#setText', function() { it("sets the content text", function() { this.view.setText("FOO bar"); - expect(this.view.inputEl.val()).toEqual("FOO bar"); - expect(this.view.hiddenInputEl.val()).toEqual("FOO bar"); }); }); @@ -248,7 +246,6 @@ describe("app.views.Publisher", function() { expect(this.view.disabled).toBeTruthy(); expect(this.view.inputEl.prop("disabled")).toBeTruthy(); - expect(this.view.hiddenInputEl.prop("disabled")).toBeTruthy(); }); it("disables submitting", function() {