From 953fc7ddb0730aaffac341a489c0e812ddc1891c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 7 Nov 2019 15:32:20 +0100 Subject: [PATCH 1/3] Update deprecated jQuery syntax These methods had already been superseeded by other methods since jQuery 1.7 or 1.8, and jQuery 3.0 will deprecate them. --- app/assets/javascripts/ckeditor/reinit.js | 2 +- app/assets/javascripts/forms.js | 6 +++--- app/assets/javascripts/table_sortable.js | 2 +- app/assets/javascripts/valuation_budget_investment_form.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/ckeditor/reinit.js b/app/assets/javascripts/ckeditor/reinit.js index 7d2d4233c2e..0ee51a90c3f 100644 --- a/app/assets/javascripts/ckeditor/reinit.js +++ b/app/assets/javascripts/ckeditor/reinit.js @@ -1,4 +1,4 @@ -$(document).bind("page:change", function() { +$(document).on("page:change", function() { if (typeof(CKEDITOR) != "undefined"){ for(name in CKEDITOR.instances){ try{CKEDITOR.replace(name);}catch(err){}; diff --git a/app/assets/javascripts/forms.js b/app/assets/javascripts/forms.js index d3120ab1da3..28a92bc6b21 100644 --- a/app/assets/javascripts/forms.js +++ b/app/assets/javascripts/forms.js @@ -9,13 +9,13 @@ }); }, submitOnChange: function() { - $(".js-submit-on-change").unbind("change").on("change", function() { + $(".js-submit-on-change").off("change").on("change", function() { $(this).closest("form").submit(); return false; }); }, toggleLink: function() { - $(".js-toggle-link").unbind("click").on("click", function() { + $(".js-toggle-link").off("click").on("click", function() { var toggle_txt; $($(this).data("toggle-selector")).toggle("down"); if ($(this).data("toggle-text") !== undefined) { @@ -54,7 +54,7 @@ } } }); - $("[name='progress_bar[kind]']").change(); + $("[name='progress_bar[kind]']").trigger("change"); }, initialize: function() { App.Forms.disableEnter(); diff --git a/app/assets/javascripts/table_sortable.js b/app/assets/javascripts/table_sortable.js index 7b4ebad8b61..f5aa31b747e 100644 --- a/app/assets/javascripts/table_sortable.js +++ b/app/assets/javascripts/table_sortable.js @@ -17,7 +17,7 @@ }; }, initialize: function() { - $("table.sortable th").click(function() { + $("table.sortable th").on("click", function() { var rows, table; table = $(this).parents("table").eq(0); rows = table.find("tbody tr").toArray().sort(App.TableSortable.comparer($(this).index())); diff --git a/app/assets/javascripts/valuation_budget_investment_form.js b/app/assets/javascripts/valuation_budget_investment_form.js index 3f8e72d84eb..122e8181b97 100644 --- a/app/assets/javascripts/valuation_budget_investment_form.js +++ b/app/assets/javascripts/valuation_budget_investment_form.js @@ -23,7 +23,7 @@ } }, showFeasibilityFieldsOnChange: function() { - $("#valuation_budget_investment_edit_form input[type=radio][name='budget_investment[feasibility]']").change(function() { + $("#valuation_budget_investment_edit_form input[type=radio][name='budget_investment[feasibility]']").on("change", function() { App.ValuationBudgetInvestmentForm.showAllFields(); App.ValuationBudgetInvestmentForm.showFeasibilityFields(); }); From d015362299cfa4732de00926dfce60234691c7f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 7 Nov 2019 15:50:58 +0100 Subject: [PATCH 2/3] Remove obsolete poltergeist code We moved to chromedriver a long time ago. --- spec/shared/features/nested_documentable.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/spec/shared/features/nested_documentable.rb b/spec/shared/features/nested_documentable.rb index 679cdfee138..ca45192a7d7 100644 --- a/spec/shared/features/nested_documentable.rb +++ b/spec/shared/features/nested_documentable.rb @@ -319,11 +319,6 @@ def documentable_attach_new_file(path, success = true) page.execute_script("$('##{document_input[:id]}').css('display','block')") attach_file(document_input[:id], path, visible: true) page.execute_script("$('##{document_input[:id]}').css('display','none')") - # Poltergeist is not removing this attribute after file upload at - # https://github.com/teampoltergeist/poltergeist/blob/master/lib/capybara/poltergeist/client/browser.coffee#L187 - # making https://github.com/teampoltergeist/poltergeist/blob/master/lib/capybara/poltergeist/client/browser.coffee#L186 - # always choose the previous used input. - page.execute_script("$('##{document_input[:id]}').removeAttr('_poltergeist_selected')") within document do if success From 849c081a1b601a39078de2d4d458ca0be7d35d8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 7 Nov 2019 15:58:24 +0100 Subject: [PATCH 3/3] Simplify the way we attach documents in tests Now we do it the same way we attach images in `nested_imageable`. Now we don't need to execute some JavaScript in the test, which by the way was causing an error when upgrading to jQuery 3. --- spec/shared/features/nested_documentable.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spec/shared/features/nested_documentable.rb b/spec/shared/features/nested_documentable.rb index ca45192a7d7..9ac59864c12 100644 --- a/spec/shared/features/nested_documentable.rb +++ b/spec/shared/features/nested_documentable.rb @@ -316,9 +316,7 @@ def documentable_attach_new_file(path, success = true) document = all("#new_document").last document_input = document.find("input[type=file]", visible: false) - page.execute_script("$('##{document_input[:id]}').css('display','block')") - attach_file(document_input[:id], path, visible: true) - page.execute_script("$('##{document_input[:id]}').css('display','none')") + attach_file(document_input[:id], path, make_visible: true) within document do if success