Bug 16602 - Remove the use of "onclick" from several templates

This patch removes the use of "onclick" from several templates, instead
defining click events in JavaScript.

Also changed: Some markup corrections.

To test, apply the patch and:

- Go to Circulation -> Upload offline circulation file
  - Browse for an offline circulation file.
  - Clicking the 'Upload file' button should work correctly.
    - After uploading a file, both the 'Add to offline circulation
      queue' and 'Apply directly' buttons should work to trigger their
      corresponding processes (keeping Bug 16603 in mind).

- Go to Patrons -> Patron lists.
  - For any patron list containing patrons, click the 'Print patron
    cards' menu item. This should trigger a modal window which exports
    the correct list.

- Go to Tools -> Batch item modification.
  - Submit a batch of items for modification.
  - Clicking the 'Save' button should trigger the background job and the
    items should be successfully modified.

- Go to Tools -> Batch item deletion.
  - Submit a batch of items for deletion.
  - Clicking the 'Delete' button should trigger the background job and
    the items should be successfully deleted.

- Go to Tools -> Calendar.
  - Trigger the 'Add new holiday' panel by clicking a day on the
    calendar which has no holiday defined.
  - Clicking the 'Cancel' link should hide the panel.
  - Trigger the 'Edit this holiday' panel by clicking a day which has a
    holiday defined.
  - Clicking the 'Cancel' link should hide the panel.

Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
  Everything works as previously.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Owen Leonard 2016-05-11 08:56:15 -04:00 committed by Kyle M Hall
parent 718a0a7d14
commit 458ce34a1d
5 changed files with 46 additions and 14 deletions

View File

@ -10,6 +10,17 @@ var xhr;
$(document).ready(function(){
$("#enqueuefile").hide();
$("#processfile").hide();
$("#upload_file").on("click",function(){
StartUpload();
});
$("#queueformsubmit").on("click",function(){
var processfile = document.getElementById("processfile");
return CheckForm( processfile );
});
$("#mainformsubmit").on("click",function(){
var enqueuefile = document.getElementById("enqueuefile");
return CheckForm( enqueuefile );
});
});
function StartUpload() {
@ -89,11 +100,13 @@ function CheckForm(f) {
<h2>Upload offline circulation data</h2>
<div id="fileuploadform">
<form method="post" action="[% SCRIPT_NAME %]" enctype="multipart/form-data">
<form method="post" action="/cgi-bin/koha/offline_circ/process_koc.pl" enctype="multipart/form-data" class="validated">
<fieldset class="brief">
<ol><li><label for="fileToUpload">Choose .koc file: </label>
<input type="file" id="fileToUpload" size="50" name="fileToUpload" /></li></ol>
<fieldset class="action"><input type="button" class="submit" value="Upload file" onclick="StartUpload();return false;" /></fieldset>
<input class="required" required="required" type="file" id="fileToUpload" size="50" name="fileToUpload" />
<span class="required">Required</span>
</li></ol>
<fieldset class="action"><input type="button" class="submit" value="Upload file" id="upload_file" /></fieldset>
</fieldset>
</form>
<div id="fileuploadstatus" style="display:none">Upload progress: <progress id="fileuploadprogress" min="0" max="100" value="0"></progress> <span class="fileuploadpercent">0</span>%</div>

View File

@ -20,6 +20,11 @@
var list = $(this).data("list-name");
return confirmDelete( _("Are you sure you want to delete the list %s?").format(list) );
});
$(".print_cards").on("click",function(e){
e.preventDefault();
var patron_list_id = $(this).data("patron_list_id");
GB_showCenter(_("Print patron cards from list"), "/cgi-bin/koha/patroncards/print.pl?patronlist_id=" + patron_list_id, 400, 800);
});
});
//]]>
</script>
@ -71,18 +76,18 @@
<li><a class="delete_patron" href="/cgi-bin/koha/patron_lists/delete.pl?patron_list_id=[% l.patron_list_id %]" data-list-name="[% l.name %]"><i class="fa fa-trash"></i> Delete list</a></li>
[% IF ( l.patron_list_patrons_rs.count ) %]
<li class="divider"></li>
<li><a href="#" onclick='GB_showCenter(_("Print patron cards from list"), "/cgi-bin/koha/patroncards/print.pl?patronlist_id=[% l.patron_list_id %]", 400, 800);return false;'><i class="fa fa-print"></i> Print patron cards</a></li>
<li><a href="#" class="print_cards" data-patron_list_id="[% l.patron_list_id %]"><i class="fa fa-print"></i> Print patron cards</a></li>
[% IF CAN_user_tools_edit_patrons %]
<li>
<a href="/cgi-bin/koha/tools/modborrowers.pl?patron_list_id=[% l.patron_list_id %]&op=show">
<i class="fa fa-pencil"></i> Batch edit patrons</i>
<i class="fa fa-pencil"></i> Batch edit patrons
</a>
</li>
[% END %]
[% IF CAN_user_tools_delete_anonymize_patrons %]
<li>
<a href="/cgi-bin/koha/tools/cleanborrowers.pl?step=2&patron_list_id=[% l.patron_list_id %]&checkbox=borrower">
<i class="fa fa-trash"></i> Batch delete patrons</i>
<i class="fa fa-trash"></i> Batch delete patrons
</a>
</li>
[% END %]

View File

@ -15,6 +15,11 @@ var allColumns = new Array([% FOREACH item_header_loo IN item_header_loop %]'[%
for( x=0; x<allColumns.length; x++ ){
allColumns[x] = Number(allColumns[x]) + 2;
}
$(document).ready(function(){
$("#mainformsubmit").on("click",function(){
return submitBackgroundJob(this.form);
});
});
//]]>
</script>
<!--[if IE]>
@ -137,9 +142,9 @@ for( x=0; x<allColumns.length; x++ ){
</div>
<input type="checkbox" name="del_records" id="del_records" /> <label for="del_records">Delete records if no items remain.</label>
[% IF too_many_items %]
<input type="submit" name="mainformsubmit" value="Delete ALL submitted items" onclick="return submitBackgroundJob(this.form);" />
<input type="submit" id="mainformsubmit" name="mainformsubmit" value="Delete ALL submitted items" />
[% ELSE %]
<input type="submit" name="mainformsubmit" value="Delete selected items" onclick="return submitBackgroundJob(this.form);" />
<input type="submit" id="mainformsubmit" name="mainformsubmit" value="Delete selected items" />
[% END %]
<a href="/cgi-bin/koha/tools/batchMod.pl?del=1" class="cancel">Cancel</a>

View File

@ -32,7 +32,9 @@ $(document).ready(function(){
$("#"+row).html("");
}
});
$("#mainformsubmit").on("click",function(){
return submitBackgroundJob(this.form);
});
});
//]]>
</script>
@ -236,8 +238,8 @@ $(document).ready(function(){
<div id="jobstatus">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
<div id="jobfailed"></div>
</div>
<input type="submit" name="mainformsubmit" value="Save" onclick="return submitBackgroundJob(this.form);" />
<a href="/cgi-bin/koha/tools/batchMod.pl" class="cancel" onclick="history.back();return false;">Cancel</a>
<input type="submit" id="mainformsubmit" value="Save" />
<a href="/cgi-bin/koha/tools/batchMod.pl" class="cancel">Cancel</a>
</fieldset>
</div>
[% ELSE %]

View File

@ -191,7 +191,14 @@
dateChanged($(this).datepicker("getDate"));
},
defaultDate: new Date("[% keydate %]")
});
});
$(".hidePanel").on("click",function(){
if( $(this).hasClass("showHoliday") ){
hidePanel("showHoliday");
} else {
hidePanel("newHoliday");
}
})
});
//]]>
</script>
@ -309,7 +316,7 @@ td.repeatableyearly a.ui-state-default { background: #FFCC66 none; color : Bl
</ol>
<fieldset class="action">
<input type="submit" name="submit" value="Save" />
<a href="#" class="cancel" onclick=" hidePanel('showHoliday');">Cancel</a>
<a href="#" class="cancel hidePanel showHoliday">Cancel</a>
</fieldset>
</fieldset>
</form>
@ -380,7 +387,7 @@ td.repeatableyearly a.ui-state-default { background: #FFCC66 none; color : Bl
</li></ol>
<fieldset class="action">
<input type="submit" name="submit" value="Save" />
<a href="#" class="cancel" onclick=" hidePanel('newHoliday');">Cancel</a>
<a href="#" class="cancel hidePanel newHoliday">Cancel</a>
</fieldset>
</fieldset>
</form>