Bug 19628: Move course reserves templates JS to the footer
This patch modifies the staff client course reserves templates so that JavaScript is included in the footer instead of the header. To test, apply the patch and test the JavaScript-driven features of each page: All button controls, DataTables, autocomplete, etc. 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>
This commit is contained in:
parent
1e40274411
commit
cf79a2694e
|
|
@ -1,51 +1,12 @@
|
|||
[% USE AuthorisedValues %]
|
||||
[% USE ItemTypes %]
|
||||
[% USE Branches %]
|
||||
[% SET footerjs = 1 %]
|
||||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
<title>Koha › Course reserves › Course details for [% course.course_name %]</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">
|
||||
//<![CDATA[
|
||||
$(document).ready(function(){
|
||||
$("#course_reserves_table").dataTable($.extend(true, {}, dataTablesDefaults, {
|
||||
"sPaginationType": "four_button",
|
||||
"aoColumnDefs": [
|
||||
{ 'bSortable': false, 'aTargets': [ 'NoSort' ] },
|
||||
{ 'sType': "anti-the", 'aTargets' : [ 'antithe'] }
|
||||
]
|
||||
}));
|
||||
|
||||
$(".delete_item").click(function(){
|
||||
return confirmDelete(_("Are you sure you want to remove this item from the course?"));
|
||||
});
|
||||
|
||||
$("#delete_course").click(function(){
|
||||
[% SET count = course_reserves.size %]
|
||||
[% IF count == 1 %]
|
||||
return confirmDelete(_("Are you sure you want to delete this course? There is [% count %] attached item.") );
|
||||
[% ELSIF count > 1 %]
|
||||
return confirmDelete(_("Are you sure you want to delete this course? There are [% count %] attached items.") );
|
||||
[% ELSE %]
|
||||
return confirmDelete(_("Are you sure you want to delete this course?"));
|
||||
[% END %]
|
||||
});
|
||||
$(".disabled").tooltip().on("click", function(e){
|
||||
e.preventDefault();
|
||||
if( $(this).hasClass("checkedout") ){
|
||||
alert(_("This item cannot be removed. It is checked out"));
|
||||
}
|
||||
if( $(this).hasClass("itemlost") ) {
|
||||
alert(_("This item cannot be removed. It is lost"));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body id="courses_course_details" class="course">
|
||||
|
|
@ -233,4 +194,43 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
[% MACRO jsinclude BLOCK %]
|
||||
[% INCLUDE 'datatables.inc' %]
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$("#course_reserves_table").dataTable($.extend(true, {}, dataTablesDefaults, {
|
||||
"sPaginationType": "four_button",
|
||||
"aoColumnDefs": [
|
||||
{ 'bSortable': false, 'aTargets': [ 'NoSort' ] },
|
||||
{ 'sType': "anti-the", 'aTargets' : [ 'antithe'] }
|
||||
]
|
||||
}));
|
||||
|
||||
$(".delete_item").click(function(){
|
||||
return confirmDelete(_("Are you sure you want to remove this item from the course?"));
|
||||
});
|
||||
|
||||
$("#delete_course").click(function(){
|
||||
[% SET count = course_reserves.size %]
|
||||
[% IF count == 1 %]
|
||||
return confirmDelete(_("Are you sure you want to delete this course? There is [% count %] attached item.") );
|
||||
[% ELSIF count > 1 %]
|
||||
return confirmDelete(_("Are you sure you want to delete this course? There are [% count %] attached items.") );
|
||||
[% ELSE %]
|
||||
return confirmDelete(_("Are you sure you want to delete this course?"));
|
||||
[% END %]
|
||||
});
|
||||
$(".disabled").tooltip().on("click", function(e){
|
||||
e.preventDefault();
|
||||
if( $(this).hasClass("checkedout") ){
|
||||
alert(_("This item cannot be removed. It is checked out"));
|
||||
}
|
||||
if( $(this).hasClass("itemlost") ) {
|
||||
alert(_("This item cannot be removed. It is lost"));
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
|
||||
[% INCLUDE 'intranet-bottom.inc' %]
|
||||
|
|
|
|||
|
|
@ -1,19 +1,12 @@
|
|||
[% USE AuthorisedValues %]
|
||||
[% SET footerjs = 1 %]
|
||||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
<title>Koha › Course reserves</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" id="js">
|
||||
$(document).ready(function() {
|
||||
$("#course_reserves_table").dataTable($.extend(true, {}, dataTablesDefaults, {
|
||||
"sPaginationType": "four_button"
|
||||
}));
|
||||
});
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body id="courses_course_reserves" class="course">
|
||||
|
||||
[% INCLUDE 'header.inc' %]
|
||||
|
|
@ -106,5 +99,15 @@ $(document).ready(function() {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
[% MACRO jsinclude BLOCK %]
|
||||
[% INCLUDE 'datatables.inc' %]
|
||||
<script type="text/javascript" id="js">
|
||||
$(document).ready(function() {
|
||||
$("#course_reserves_table").dataTable($.extend(true, {}, dataTablesDefaults, {
|
||||
"sPaginationType": "four_button"
|
||||
}));
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
|
||||
[% INCLUDE 'intranet-bottom.inc' %]
|
||||
|
|
|
|||
|
|
@ -1,60 +1,7 @@
|
|||
[% SET footerjs = 1 %]
|
||||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
<title>Koha › Course reserves › [% IF course_name %] Edit [% course_name %] [% ELSE %] New course [% END %]</title>
|
||||
[% INCLUDE 'doc-head-close.inc' %]
|
||||
|
||||
[% IF ( departments ) %]
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
$(document).ready(function(){
|
||||
$( "#find_instructor" ).autocomplete({
|
||||
source: "/cgi-bin/koha/circ/ysearch.pl",
|
||||
minLength: 3,
|
||||
select: function( event, ui ) {
|
||||
AddInstructor( ui.item.surname + ", " + ui.item.firstname, ui.item.cardnumber );
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.data( "ui-autocomplete" )._renderItem = function( ul, item ) {
|
||||
return $( "<li></li>" )
|
||||
.data( "ui-autocomplete-item", item )
|
||||
.append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" )
|
||||
.appendTo( ul );
|
||||
};
|
||||
|
||||
if ( ! $('#instructors').html() ) {
|
||||
$('#course_instructors').hide();
|
||||
}
|
||||
|
||||
$("body").on("click",".removeInstructor",function(e){
|
||||
e.preventDefault();
|
||||
var divid = $(this).parent().attr("id");
|
||||
var cardnumber = divid.replace("borrower_","");
|
||||
RemoveInstructor(cardnumber);
|
||||
});
|
||||
});
|
||||
|
||||
function AddInstructor( name, cardnumber ) {
|
||||
div = "<div id='borrower_" + cardnumber + "'>" + name + " ( <a href='#' class='removeInstructor'> " + _("Remove")+ " </a> ) <input type='hidden' name='instructors' value='" + cardnumber + "' /></div>";
|
||||
$('#instructors').append( div );
|
||||
|
||||
$('#find_instructor').val('').focus();
|
||||
$('#course_instructors').show();
|
||||
}
|
||||
|
||||
function RemoveInstructor( cardnumber ) {
|
||||
$( '#borrower_' + cardnumber ).remove();
|
||||
|
||||
if ( ! $('#instructors').html() ) {
|
||||
$('#course_instructors').hide( 800 );
|
||||
}
|
||||
}
|
||||
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
[% END %]
|
||||
|
||||
</head>
|
||||
|
||||
<body id="courses_course" class="course">
|
||||
|
|
@ -188,4 +135,54 @@
|
|||
|
||||
[% END %]
|
||||
|
||||
[% IF ( departments ) %]
|
||||
[% MACRO jsinclude BLOCK %]
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$( "#find_instructor" ).autocomplete({
|
||||
source: "/cgi-bin/koha/circ/ysearch.pl",
|
||||
minLength: 3,
|
||||
select: function( event, ui ) {
|
||||
AddInstructor( ui.item.surname + ", " + ui.item.firstname, ui.item.cardnumber );
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.data( "ui-autocomplete" )._renderItem = function( ul, item ) {
|
||||
return $( "<li></li>" )
|
||||
.data( "ui-autocomplete-item", item )
|
||||
.append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" )
|
||||
.appendTo( ul );
|
||||
};
|
||||
|
||||
if ( ! $('#instructors').html() ) {
|
||||
$('#course_instructors').hide();
|
||||
}
|
||||
|
||||
$("body").on("click",".removeInstructor",function(e){
|
||||
e.preventDefault();
|
||||
var divid = $(this).parent().attr("id");
|
||||
var cardnumber = divid.replace("borrower_","");
|
||||
RemoveInstructor(cardnumber);
|
||||
});
|
||||
});
|
||||
|
||||
function AddInstructor( name, cardnumber ) {
|
||||
div = "<div id='borrower_" + cardnumber + "'>" + name + " ( <a href='#' class='removeInstructor'> " + _("Remove")+ " </a> ) <input type='hidden' name='instructors' value='" + cardnumber + "' /></div>";
|
||||
$('#instructors').append( div );
|
||||
|
||||
$('#find_instructor').val('').focus();
|
||||
$('#course_instructors').show();
|
||||
}
|
||||
|
||||
function RemoveInstructor( cardnumber ) {
|
||||
$( '#borrower_' + cardnumber ).remove();
|
||||
|
||||
if ( ! $('#instructors').html() ) {
|
||||
$('#course_instructors').hide( 800 );
|
||||
}
|
||||
}
|
||||
</script>
|
||||
[% END %]
|
||||
[% END %]
|
||||
|
||||
[% INCLUDE 'intranet-bottom.inc' %]
|
||||
|
|
|
|||
Loading…
Reference in New Issue