From 88863b3986c0f7cff578d5a99471644dd520fdca Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 19 Apr 2016 21:02:05 -0400 Subject: [PATCH] [PASSED QA] Bug 16305 - Remove the use of "onclick" from transport cost matrix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch updates the transport cost matrix template to eliminate the use of event attributes (onclick and onblur) in favor of JS separate from the markup. To test, apply the patch and go to Administration -> Transport cost matrix. - Click in any table cell. Form fields in the cell should activate. - Check and uncheck the "disable" checkbox. The form field should be correctly disabled and enabled. - Fill various enabled fields and submit the form to confirm that data is saved correctly. Signed-off-by: Marc VĂ©ron Signed-off-by: Katrin Fischer --- .../prog/en/modules/admin/transport-cost-matrix.tt | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/transport-cost-matrix.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/transport-cost-matrix.tt index 1a52a3f..2bd6d11 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/transport-cost-matrix.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/transport-cost-matrix.tt @@ -11,7 +11,9 @@ function check_transport_cost(e) { } alert(_("Cost must be expressed as a decimal number >= 0")); } -function disable_transport_cost_chg(e, cost_id) { +function disable_transport_cost_chg(e) { + var input_name = e.name; + var cost_id = input_name.replace(/disable_/,''); // Parse the code_id out of the input name disable_transport_cost(cost_id, e.checked); } function disable_transport_cost(cost_id, disable) { @@ -28,8 +30,8 @@ function enable_cost_input(cost_id) { $(cell).removeClass('disabled-transfer'); $('#celldiv_'+cost_id).html( - ''+ - '
Disable ' + ''+ + '
Disable ' ); disable_transport_cost(cost_id, disabled); } @@ -38,6 +40,18 @@ function form_submit (f) { $(f).find('input:disabled').removeAttr("disabled"); return true; } +$(document).ready(function(){ + $(".enable_cost_input").on("click",function(){ + var cost_id = $(this).data("cost-id"); + enable_cost_input( cost_id ); + }); + $("body").on("blur",".cost_input",function(){ + check_transport_cost(this); + }); + $("body").on("change",".disable_transport_cost",function(){ + disable_transport_cost_chg(this); + }); +}) //]]>