From ba01595d5eb7e55d9e8b6a512613db15dad94f51 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=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 --- .../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.7.10.4