From 29292c9f8deead33c07c5c46ba27e749de648e8f Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 19 Apr 2016 12:40:29 -0400 Subject: [PATCH] Bug 16297 - Remove the use of "onclick" from OAI sets configuration template MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 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 Signed-off-by: Kyle M Hall --- .../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 2406e0dd6d..dc3010348c 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
  • -- 2.39.2