From: Owen Leonard Date: Tue, 19 Apr 2016 16:40:29 +0000 (-0400) Subject: Bug 16297 - Remove the use of "onclick" from OAI sets configuration template X-Git-Tag: v16.05.00-beta~145 X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=commitdiff_plain;h=29292c9f8deead33c07c5c46ba27e749de648e8f;hp=a196dfc4f0ba674eb649c35bbc761c750f25579f;p=koha_ffzg Bug 16297 - Remove the use of "onclick" from OAI sets configuration template 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 --- 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