diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 5e7842945..e9d05e280 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -60,7 +60,6 @@ //= require moderator_budget_investments //= require moderator_proposal_notifications //= require moderator_legislation_proposals -//= require prevent_double_submission //= require gettext //= require annotator //= require tags @@ -126,7 +125,6 @@ var initialize_modules = function() { App.FoundationExtras.initialize(); App.LocationChanger.initialize(); App.CheckAllNone.initialize(); - App.PreventDoubleSubmission.initialize(); App.IeAlert.initialize(); App.AdvancedSearch.initialize(); App.RegistrationForm.initialize(); diff --git a/app/assets/javascripts/prevent_double_submission.js b/app/assets/javascripts/prevent_double_submission.js deleted file mode 100644 index 40b454d46..000000000 --- a/app/assets/javascripts/prevent_double_submission.js +++ /dev/null @@ -1,48 +0,0 @@ -(function() { - "use strict"; - App.PreventDoubleSubmission = { - disable_buttons: function(buttons) { - setTimeout(function() { - buttons.each(function() { - var button, loading, ref; - button = $(this); - if (!button.hasClass("disabled")) { - loading = (ref = button.data("loading")) != null ? ref : "..."; - button.addClass("disabled").attr("disabled", "disabled"); - button.data("text", button.val()); - button.val(loading); - } - }); - }, 1); - }, - reset_buttons: function(buttons) { - buttons.each(function() { - var button, button_text; - button = $(this); - if (button.hasClass("disabled")) { - button_text = button.data("text"); - button.removeClass("disabled").attr("disabled", null); - if (button_text) { - button.val(button_text); - button.data("text", null); - } - } - }); - }, - initialize: function() { - $("form").on("submit", function(event) { - var buttons; - if (!(event.target.id === "new_officing_voter" || event.target.id === "admin_download_emails")) { - buttons = $(this).find(":button, :submit"); - App.PreventDoubleSubmission.disable_buttons(buttons); - } - }).on("ajax:success", function(event) { - var buttons; - if (!(event.target.id === "new_officing_voter" || event.target.id === "admin_download_emails")) { - buttons = $(this).find(":button, :submit"); - App.PreventDoubleSubmission.reset_buttons(buttons); - } - }); - } - }; -}).call(this); diff --git a/spec/system/comments/debates_spec.rb b/spec/system/comments/debates_spec.rb index f3e38cfb4..48da9e79f 100644 --- a/spec/system/comments/debates_spec.rb +++ b/spec/system/comments/debates_spec.rb @@ -360,11 +360,9 @@ describe "Commenting debates" do fill_in "Leave your comment", with: "Testing submit button!" click_button "Publish comment" - # The button"s text should now be "..." - # This should be checked before the Ajax request is finished - expect(page).not_to have_button "Publish comment" - - expect(page).to have_content("Testing submit button!") + expect(page).to have_button "Publish comment", disabled: true + expect(page).to have_content "Testing submit button!" + expect(page).to have_button "Publish comment", disabled: false end describe "Moderators" do diff --git a/spec/system/comments/legislation_annotations_spec.rb b/spec/system/comments/legislation_annotations_spec.rb index 46f9d5baa..b6560f743 100644 --- a/spec/system/comments/legislation_annotations_spec.rb +++ b/spec/system/comments/legislation_annotations_spec.rb @@ -377,11 +377,9 @@ describe "Commenting legislation questions" do fill_in "Leave your comment", with: "Testing submit button!" click_button "Publish comment" - # The button's text should now be "..." - # This should be checked before the Ajax request is finished - expect(page).not_to have_button "Publish comment" - - expect(page).to have_content("Testing submit button!") + expect(page).to have_button "Publish comment", disabled: true + expect(page).to have_content "Testing submit button!" + expect(page).to have_button "Publish comment", disabled: false end describe "Moderators" do diff --git a/spec/system/comments/legislation_questions_spec.rb b/spec/system/comments/legislation_questions_spec.rb index 1750e9422..7ddf1e56d 100644 --- a/spec/system/comments/legislation_questions_spec.rb +++ b/spec/system/comments/legislation_questions_spec.rb @@ -339,11 +339,9 @@ describe "Commenting legislation questions" do fill_in "Leave your answer", with: "Testing submit button!" click_button "Publish answer" - # The button's text should now be "..." - # This should be checked before the Ajax request is finished - expect(page).not_to have_button "Publish answer" - - expect(page).to have_content("Testing submit button!") + expect(page).to have_button "Publish answer", disabled: true + expect(page).to have_content "Testing submit button!" + expect(page).to have_button "Publish answer", disabled: false end describe "Moderators" do