Browse Source

Bug 19777: Move template JavaScript to the footer: Serials, part 3

This patch modifies even more staff client serials templates so
that JavaScript is included in the footer instead of the header.

This patch adds a new JavaScript include, serials-toolbar.js, which is
required on pages which include serials-toolbar.inc.

To test, apply the patch and test the JavaScript-driven features of the
modified templates: All button controls, DataTables functionality, tabs,
etc.

 - Serials
   - Search for a subscription
     - Tabs, datatables, date pickers
     - Open a subscription for viewing
       - Tabs, toolbar buttons for delete, renew, and close.
   - Serial collection (in the sidebar menu)
     - Select all / clear all
     - Datatable
     - Print slip
     - Generate next

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
18.05.x
Owen Leonard 4 years ago
committed by Jonathan Druart
parent
commit
666a1b2760
  1. 37
      koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc
  2. 133
      koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt
  3. 14
      koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-home.tt
  4. 81
      koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt
  5. 50
      koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt
  6. 43
      koha-tmpl/intranet-tmpl/prog/js/serials-toolbar.js

37
koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc

@ -1,40 +1,3 @@
<script type="text/javascript">
//<![CDATA[
function confirm_close() {
var is_confirmed = confirm(_("Are you sure you want to close this subscription?"));
if (is_confirmed) {
window.location="subscription-detail.pl?subscriptionid=[% subscriptionid %]&op=close";
}
}
function confirm_reopen() {
var is_confirmed = confirm(_("Are you sure you want to reopen this subscription?"));
if (is_confirmed) {
window.location="subscription-detail.pl?subscriptionid=[% subscriptionid %]&op=reopen";
}
}
$(document).ready(function() {
$("#deletesub").click(function(){
confirm_deletion();
return false;
});
$("#reopen").click(function(){
confirm_reopen();
return false;
});
$("#close").click(function(){
confirm_close();
return false;
});
$("#renew").click(function(){
popup([% subscriptionid %]);
return false;
})
});
//]]>
</script>
[% IF subscriptionid and ( CAN_user_serials_edit_subscription || CAN_user_serials_create_subscription || CAN_user_serials_delete_subscription || CAN_user_serials_receive_serials ) %]
<div id="toolbar" class="btn-toolbar">
[% IF CAN_user_serials_create_subscription %]

133
koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt

@ -1,83 +1,13 @@
[% USE AuthorisedValues %]
[% USE Branches %]
[% USE KohaDates %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Serials &rsaquo; Serial collection information for [% bibliotitle %]</title>
[% INCLUDE 'doc-head-close.inc' %]
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
[% INCLUDE 'datatables.inc' %]
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
<script type="text/javascript">
//<![CDATA[
function generateReceive(subscriptionid) {
if(nbissues=prompt(_("How many issues do you want to receive ?"))){
document.location = 'serials-collection.pl?op=gennext&subscriptionid='+subscriptionid+'&nbissues='+nbissues;
}
}
function print_slip(subscriptionid,issue){
var myurl = 'routing-preview.pl?ok=1&subscriptionid='+subscriptionid+'&issue='+issue;
window.open(myurl,'PrintSlip','width=500,height=500,toolbar=no,scrollbars=yes');
}
function addsubscriptionid()
{
var tab=new Array();
var serialids = document.edition.serialid;
for (i=0; i<serialids.length; i++){
if (serialids[i].checked == true){
var found=false;
for (var val in tab){
if (tab[val] == document.getElementsByName("subs")[i].getAttribute('val')){found = true;}
}
if (found == false){
tab=tab.concat((document.getElementsByName("subs")[i].getAttribute('val')));
}
}
}
var string="";
for (var val in tab){
string = string + tab[val] + ",";
}
string=string.substring(0,string.length -1);
document.edition.subscriptionid.value=string;
}
function popup(subscriptionid) {
newin=window.open('subscription-renew.pl?mode=popup&subscriptionid='+subscriptionid,'popup','width=500,height=400,toolbar=false,scrollbars=yes');
}
function generateNext(subscriptionid) {
if(confirm(_("Do you really want to generate next serial?"))){
document.location = 'serials-collection.pl?op=gennext&subscriptionid='+subscriptionid;
}
}
function CheckAll( node ) {
$("#"+node).checkCheckboxes();
return false;
}
function CheckNone( node ) {
$("#"+node).unCheckCheckboxes();
return false;
}
$(document).ready(function() {
$('#subscription_years').tabs();
$(".subscription-year-table").dataTable($.extend(true, {}, dataTablesDefaults, {
"aoColumnDefs": [
{ "aTargets": [ 0,-1 ], "bSortable": false, "bSearchable": false },
{ "sType": "title-string", "aTargets" : [ "title-string" ] }
],
"aaSorting": [[0, 'desc']],
"sDom": 't',
"bAutoWidth": false,
"bPaginate": false,
"bInfo": false,
"bFilter": false,
} ));
});
//]]>
</script>
</head>
<body id="ser_serials-collection" class="ser">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'serials-search.inc' %]
@ -331,4 +261,63 @@ $(document).ready(function() {
[% INCLUDE 'serials-menu.inc' %]
</div>
</div>
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
<script type="text/javascript">
var subscriptionid = "[% subscriptionid %]";
var MSG_CLOSE_SUBSCRIPTION = _("Are you sure you want to close this subscription?");
var MSG_REOPEN_SUBSCRIPTION = _("Are you sure you want to reopen this subscription?");
var CONFIRM_DELETE_SUBSCRIPTION = _("Are you sure you want to delete this subscription?");
</script>
<script type="text/javascript" src="[% interface %]/[% theme %]/js/serials-toolbar.js"></script>
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
<script type="text/javascript">
function generateReceive(subscriptionid) {
if(nbissues=prompt(_("How many issues do you want to receive ?"))){
document.location = 'serials-collection.pl?op=gennext&subscriptionid='+subscriptionid+'&nbissues='+nbissues;
}
}
function print_slip(subscriptionid,issue){
var myurl = 'routing-preview.pl?ok=1&subscriptionid='+subscriptionid+'&issue='+issue;
window.open(myurl,'PrintSlip','width=500,height=500,toolbar=no,scrollbars=yes');
}
function popup(subscriptionid) {
newin=window.open('subscription-renew.pl?mode=popup&subscriptionid='+subscriptionid,'popup','width=500,height=400,toolbar=false,scrollbars=yes');
}
function generateNext(subscriptionid) {
if(confirm(_("Do you really want to generate next serial?"))){
document.location = 'serials-collection.pl?op=gennext&subscriptionid='+subscriptionid;
}
}
function CheckAll( node ) {
$("#"+node).checkCheckboxes();
return false;
}
function CheckNone( node ) {
$("#"+node).unCheckCheckboxes();
return false;
}
$(document).ready(function() {
$('#subscription_years').tabs();
$(".subscription-year-table").dataTable($.extend(true, {}, dataTablesDefaults, {
"aoColumnDefs": [
{ "aTargets": [ 0,-1 ], "bSortable": false, "bSearchable": false },
{ "sType": "title-string", "aTargets" : [ "title-string" ] }
],
"aaSorting": [[0, 'desc']],
"sDom": 't',
"bAutoWidth": false,
"bPaginate": false,
"bInfo": false,
"bFilter": false,
} ));
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]

14
koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-home.tt

@ -1,5 +1,6 @@
[% INCLUDE 'doc-head-open.inc' %]
[% USE KohaDates %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Serials [% biblionumber %]</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
@ -20,4 +21,15 @@
[% INCLUDE 'serials-menu.inc' %]
</div>
</div>
[% MACRO jsinclude BLOCK %]
<script type="text/javascript" src="[% interface %]/[% theme %]/js/serials-toolbar.js"></script>
<script type="text/javascript">
var subscriptionid = "[% subscriptionid %]";
var MSG_CLOSE_SUBSCRIPTION = _("Are you sure you want to close this subscription?");
var MSG_REOPEN_SUBSCRIPTION = _("Are you sure you want to reopen this subscription?");
var CONFIRM_DELETE_SUBSCRIPTION = _("Are you sure you want to delete this subscription?");
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]

81
koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt

@ -1,45 +1,14 @@
[% USE AuthorisedValues %]
[% USE Branches %]
[% INCLUDE 'doc-head-open.inc' %]
[% USE KohaDates %]
[% USE AuthorisedValues %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Serials [% biblionumber %]</title>
[% INCLUDE 'doc-head-close.inc' %]
[% INCLUDE 'calendar.inc' %]
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
[% INCLUDE 'datatables.inc' %]
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
var osrlt = $("#osrlt").dataTable($.extend(true, {}, dataTablesDefaults, {
"sPaginationType": "four_button",
"aoColumnDefs": [
{ 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
{ "sType": "title-string", "aTargets" : [ "title-string" ] },
{ 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
]
} ) );
var csrlt = $("#csrlt").dataTable($.extend(true, {}, dataTablesDefaults, {
// FIXME sort function of additional_fields!
"sPaginationType": "four_button",
"aoColumnDefs": [
{ 'bSortable': false, 'aTargets': [ 'NoSort' ] },
{ 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
]
} ) );
osrlt.fnAddFilters("dt-filter", 750);
csrlt.fnAddFilters("dt-filter", 750);
$('#serialstabs').tabs();
$("#reopensub").click(function(){
return confirm(_("Are you sure you want to reopen this subscription?"));
});
});
//]]>
</script>
<style type="text/css">input.dt-filter { width : 100%; font-size : 85%; }</style>
</head>
<body id="ser_serials-home" class="ser">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'serials-search.inc' %]
@ -445,4 +414,46 @@
[% END %]
</div>
</div>
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
<script type="text/javascript">
var subscriptionid = "[% subscriptionid %]";
var MSG_CLOSE_SUBSCRIPTION = _("Are you sure you want to close this subscription?");
var MSG_REOPEN_SUBSCRIPTION = _("Are you sure you want to reopen this subscription?");
var CONFIRM_DELETE_SUBSCRIPTION = _("Are you sure you want to delete this subscription?");
</script>
<script type="text/javascript" src="[% interface %]/[% theme %]/js/serials-toolbar.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var osrlt = $("#osrlt").dataTable($.extend(true, {}, dataTablesDefaults, {
"sPaginationType": "four_button",
"aoColumnDefs": [
{ 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
{ "sType": "title-string", "aTargets" : [ "title-string" ] },
{ 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
]
}));
var csrlt = $("#csrlt").dataTable($.extend(true, {}, dataTablesDefaults, {
// FIXME sort function of additional_fields!
"sPaginationType": "four_button",
"aoColumnDefs": [
{ 'bSortable': false, 'aTargets': [ 'NoSort' ] },
{ 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
]
}));
osrlt.fnAddFilters("dt-filter", 750);
csrlt.fnAddFilters("dt-filter", 750);
$('#serialstabs').tabs();
$("#reopensub").click(function(){
return confirm(_("Are you sure you want to reopen this subscription?"));
});
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]

50
koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt

@ -1,35 +1,12 @@
[% USE Koha %]
[% USE Branches %]
[% USE AuthorisedValues %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Serials &rsaquo; Details for subscription #[% subscriptionid %]</title>
[% INCLUDE 'doc-head-close.inc' %]
<script type="text/javascript">
//<![CDATA[
// the english words used in display purposes
var text = new Array(_("Number"),_("Volume"),_("Issue"),_("Month"),_("Week"),_("Starting with:"),_("Rollover at:"),_("Choose Hemisphere:"),_("Northern"),_("Southern",
"Autumn"),_("Winter"),_("Spring"),_("Summer"),_("Fall"),_("Season"),_("Year"));
function confirm_deletion() {
var is_confirmed = confirm(_("Are you sure you want to delete this subscription?"));
if (is_confirmed) {
window.location="subscription-detail.pl?subscriptionid=[% subscriptionid %]&op=del";
}
}
function popup(subscriptionid) {
newin=window.open("subscription-renew.pl?mode=popup&subscriptionid="+subscriptionid,'popup','width=590,height=440,toolbar=false,scrollbars=yes');
}
$(document).ready(function() {
$("#subscription_description").tabs();
$("#renewsub").click(function(){
popup([% subscriptionid %]);
return false;
})
});
//]]>
</script>
</head>
<body id="ser_subscription-detail" class="ser">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'serials-search.inc' %]
@ -393,4 +370,27 @@ $(document).ready(function() {
[% INCLUDE 'serials-menu.inc' %]
</div>
</div>
[% MACRO jsinclude BLOCK %]
<script type="text/javascript">
var subscriptionid = "[% subscriptionid %]";
var MSG_CLOSE_SUBSCRIPTION = _("Are you sure you want to close this subscription?");
var MSG_REOPEN_SUBSCRIPTION = _("Are you sure you want to reopen this subscription?");
var CONFIRM_DELETE_SUBSCRIPTION = _("Are you sure you want to delete this subscription?");
</script>
<script type="text/javascript" src="[% interface %]/[% theme %]/js/serials-toolbar.js"></script>
<script type="text/javascript">
// the english words used in display purposes
var text = new Array(_("Number"),_("Volume"),_("Issue"),_("Month"),_("Week"),_("Starting with:"),_("Rollover at:"),_("Choose Hemisphere:"),_("Northern"),_("Southern",
"Autumn"),_("Winter"),_("Spring"),_("Summer"),_("Fall"),_("Season"),_("Year"));
$(document).ready(function() {
$("#subscription_description").tabs();
$("#renewsub").click(function(){
popup([% subscriptionid %]);
return false;
})
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]

43
koha-tmpl/intranet-tmpl/prog/js/serials-toolbar.js

@ -0,0 +1,43 @@
/* global MSG_CLOSE_SUBSCRIPTION MSG_REOPEN_SUBSCRIPTION CONFIRM_DELETE_SUBSCRIPTION subscriptionid */
function confirm_close() {
var is_confirmed = confirm( MSG_CLOSE_SUBSCRIPTION );
if (is_confirmed) {
window.location="subscription-detail.pl?subscriptionid=" + subscriptionid + "&op=close";
}
}
function confirm_reopen() {
var is_confirmed = confirm( MSG_REOPEN_SUBSCRIPTION );
if (is_confirmed) {
window.location="subscription-detail.pl?subscriptionid=" + subscriptionid + "&op=reopen";
}
}
function confirm_deletion() {
var is_confirmed = confirm( CONFIRM_DELETE_SUBSCRIPTION );
if (is_confirmed) {
window.location="subscription-detail.pl?subscriptionid=[% subscriptionid %]&op=del";
}
}
function popup(subscriptionid) {
newin=window.open("subscription-renew.pl?mode=popup&subscriptionid="+subscriptionid,'popup','width=590,height=440,toolbar=false,scrollbars=yes');
}
$(document).ready(function() {
$("#deletesub").click(function(){
confirm_deletion();
return false;
});
$("#reopen").click(function(){
confirm_reopen();
return false;
});
$("#close").click(function(){
confirm_close();
return false;
});
$("#renew").click(function(){
popup( subscriptionid );
return false;
});
});
Loading…
Cancel
Save