Bugzilla – Attachment 50450 Details for
Bug 16305
Remove the use of "onclick" from transport cost matrix
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16305 - Remove the use of "onclick" from transport cost matrix
Bug-16305---Remove-the-use-of-onclick-from-transpo.patch (text/plain), 3.65 KB, created by
Owen Leonard
on 2016-04-20 01:10:17 UTC
(
hide
)
Description:
Bug 16305 - Remove the use of "onclick" from transport cost matrix
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2016-04-20 01:10:17 UTC
Size:
3.65 KB
patch
obsolete
>From 2fda6b884581a95e46fa0997bd5bcaefd5196944 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Tue, 19 Apr 2016 21:02:05 -0400 >Subject: [PATCH] Bug 16305 - Remove the use of "onclick" from transport cost > matrix >Content-Type: text/plain; charset="utf-8" > >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. >--- > .../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( >- '<input type="text" name="cost_'+cost_id+'" onblur="check_transport_cost(this);" size="4" value="'+$.trim(cost)+'" />'+ >- '<br/>Disable <input name="disable_'+cost_id+'" value="1" onchange="disable_transport_cost_chg(this, \''+cost_id+'\');" type="checkbox" '+(disabled ? 'checked' : '')+' />' >+ '<input type="text" name="cost_'+cost_id+'" class="cost_input" size="4" value="'+$.trim(cost)+'" />'+ >+ '<br/>Disable <input name="disable_'+cost_id+'" value="1" class="disable_transport_cost" type="checkbox" '+(disabled ? 'checked' : '')+' />' > ); > 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); >+ }); >+}) > //]]> > </script> > <style type="text/css"> >@@ -103,7 +117,7 @@ function form_submit (f) { > [% ELSE %] > <div id="celldiv_[% bt.id %]"> > [% END %] >- <div onclick="enable_cost_input('[% bt.id %]');">[% bt.disabled ? ' ' : bt.value %]</div> >+ <div class="enable_cost_input" data-cost-id="[% bt.id %]">[% bt.disabled ? ' ' : bt.value %]</div> > <input type="hidden" name="cost_[% bt.id %]" value="[% bt.value %]" /> > [% IF bt.disabled %] > <input type="hidden" name="disable_[% bt.id %]" value="1" /> >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 16305
:
50450
|
50455
|
50624