From 30cf9167d709d316668d8c8a4fb81ad9183cdc50 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 19 Apr 2016 12:40:29 -0400 Subject: [PATCH] [PASSED QA] Bug 16297 - Remove the use of "onclick" from OAI sets configuration template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order to bring the OAI sets configuration template into compliance with coding guideline JS9, this patch changes with way some JavaScript events are handled by moving JS handling out of the HTML markup. To test, apply the patch and go to Administration -> OAI sets configuration. - Create or edit a set. - Test the "Add description" link. Clicking it should add a description textarea. - Test the "Remove" link associated with multiple description lines. Click them should remove the corresponding textarea. - Test that additions and removals are saved correctly. Signed-off-by: Marc VĂ©ron Signed-off-by: Katrin Fischer --- .../intranet-tmpl/prog/en/modules/admin/oai_sets.tt | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_sets.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_sets.tt index 2406e0d..dc30103 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_sets.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_sets.tt @@ -7,13 +7,13 @@ function newDescField() { $("#adddescription").before( '
  • ' + '' + - ' Remove' + + ' Remove' + '
  • ' ); } function delDescField(minusButton) { - var li = $(minusButton).parent('li'); + var li = minusButton.parent('li'); $(li).remove(); } @@ -25,6 +25,17 @@ $(document).ready(function() { $(".delete_oai_set").on("click",function(){ return confirmDelete(); }); + + $("body").on("click", ".remove_description", function(e){ + e.preventDefault(); + delDescField($(this)); + }); + + $(".add_description").on("click", function(e){ + e.preventDefault(); + newDescField(); + }); + }); //]]> @@ -67,10 +78,10 @@ $(document).ready(function() {
  • - Remove + Remove
  • [% END %] -
  •   Add description
  • +
  •   Add description
  • -- 1.9.1