Bug 19600: Move admin templates JavaScript to the footer: Other catalog pages

This patch modifies the staff client catalog-related administration
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 modified template: All button controls, DataTables functionality,
tabs, etc.

Signed-off-by: Simon Pouchol <simon.pouchol@biblibre.com>

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:
Owen Leonard 2017-11-09 13:24:04 +00:00 committed by Jonathan Druart
parent 9a20024653
commit eaa3287705
6 changed files with 250 additions and 227 deletions

View File

@ -1,3 +1,4 @@
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Administration &rsaquo; Classification sources
[% IF ( class_source_form ) %]
@ -265,4 +266,8 @@
[% INCLUDE 'admin-menu.inc' %]
</div>
</div>
[% MACRO jsinclude BLOCK %]
<script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]

View File

@ -1,3 +1,4 @@
[% SET footerjs = 1 %]
[% USE AuthorisedValues %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Administration &rsaquo; Item search fields</title>
@ -39,4 +40,8 @@
</div>
</div>
[% INCLUDE 'intranet-bottom.inc' %]
[% MACRO jsinclude BLOCK %]
<script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]

View File

@ -1,12 +1,10 @@
[% SET footerjs = 1 %]
[% USE AuthorisedValues %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Administration &rsaquo; Item search fields</title>
[% INCLUDE 'doc-head-close.inc' %]
<script type="text/javascript">
var MSG_ITEM_SEARCH_DELETE_CONFIRM = _("Are you sure you want to delete this field?");
</script>
<script type="text/javascript" src="[% interface %]/[% theme %]/js/item_search_fields.js"></script>
</head>
<body id="admin_itemssearchfields" class="admin">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'prefs-admin-search.inc' %]
@ -110,4 +108,12 @@
</div>
</div>
[% INCLUDE 'intranet-bottom.inc' %]
[% MACRO jsinclude BLOCK %]
<script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script>
<script type="text/javascript">
var MSG_ITEM_SEARCH_DELETE_CONFIRM = _("Are you sure you want to delete this field?");
</script>
<script type="text/javascript" src="[% interface %]/[% theme %]/js/item_search_fields.js"></script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]

View File

@ -1,3 +1,4 @@
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Administration &rsaquo; Record matching rules
[% IF ( matching_rule_form ) %]
@ -46,153 +47,6 @@
</select>
[% END %]
<script type="text/javascript">
//<![CDATA[
var maxMatchPoint = [% max_matchpoint %];
var maxMatchCheck = [% max_matchcheck %];
function InsertMatchpoint(loc, index) {
var original= $("#"+index);
var clone = original.clone();
clone.show();
// update IDs and form names
maxMatchPoint++;
clone.attr('id', 'mp_' + maxMatchPoint);
$("span.counter",clone).html(maxMatchPoint);
$("label",clone).each(function(){
var s = $(this).attr("for");
if (s.match(/mp_num/)) {
$(this).attr("for",s.replace(/mp_num/, 'mp_' + maxMatchPoint));
}
});
$("div",clone).each(function(){
var s = $(this).attr("id");
if (s.match(/mp_num/)) {
$(this).attr("id",s.replace(/mp_num/, 'mp_' + maxMatchPoint));
}
});
$("input",clone).each(function(){
var s = $(this).attr("id");
if(s.match(/mp_num/)){
$(this).attr("id",s.replace(/mp_num/, 'mp_' + maxMatchPoint));
}
var s = $(this).attr("name");
if(s.match(/mp_num/)){
$(this).attr("name",s.replace(/mp_num/, 'mp_' + maxMatchPoint));
}
});
$("#match_points").append(clone);
}
function InsertMatchcheck(loc, index) {
var original= $("#"+index);
var clone = original.clone();
clone.show();
// update IDs and form names
maxMatchCheck++;
clone.attr('id', 'mc_' + maxMatchCheck);
$("span.counter",clone).html(maxMatchCheck);
$("label",clone).each(function(){
var s = $(this).attr("for");
if (s.match(/mc_num/)) {
$(this).attr("for",s.replace(/mc_num/, 'mc_' + maxMatchCheck));
}
});
$("div",clone).each(function(){
var s = $(this).attr("id");
if (s.match(/mc_num/)) {
$(this).attr("id",s.replace(/mc_num/, 'mc_' + maxMatchCheck));
}
});
$("input",clone).each(function(){
var s = $(this).attr("id");
if(s.match(/mc_num/)){
$(this).attr("id",s.replace(/mc_num/, 'mc_' + maxMatchCheck));
}
var s = $(this).attr("name");
if(s.match(/mc_num/)){
$(this).attr("name",s.replace(/mc_num/, 'mc_' + maxMatchCheck));
}
});
$("#match_checks").append(clone);
}
function DeleteMatchpoint(loc) {
$(loc).parent().parent().parent().remove();
if($(".matchgroup",$("#match_points")).length == 0){
maxMatchPoint = 0;
$("#addMatchPoint").show();
}
}
function DeleteMatchcheck(loc) {
$(loc).parent().parent().parent().remove();
if($(".matchgroup",$("#match_checks")).length == 0){
maxMatchCheck = 0;
$("#addMatchCheck").show();
}
}
function DoCancel(f) {
f.op.value='';
document.Aform.submit();
}
function CheckMatchingRuleForm(f) {
var ok=1;
var _alertString="";
var alertString2;
if (f.code.value.length==0) {
_alertString += "\n- " + _("Matching rule code missing");
}
if (f.description.value.length==0) {
_alertString += "\n- " + _("Description missing");
}
if (f.threshold.value.length==0) {
_alertString += "\n- " + _("Threshold missing");
}
if (_alertString.length==0) {
document.Aform.submit();
} else {
alertString2 = _("Form not submitted because of the following problem(s)");
alertString2 += "\n------------------------------------------------------------------------------------\n";
alertString2 += _alertString;
alert(alertString2);
}
}
function CheckRuleForm(f) {
var ok=1;
var _alertString="";
var alertString2;
if (f.sort_rule.value.length==0) {
_alertString += "\n- " + _("Filing rule code missing");
}
if (f.description.value.length==0) {
_alertString += "\n- " + _("Description missing");
}
if (f.sort_routine.value.length==0) {
_alertString += "\n- " + _("Sort routine missing");
}
if (_alertString.length==0) {
document.Aform.submit();
} else {
alertString2 = _("Form not submitted because of the following problem(s)");
alertString2 += "\n------------------------------------------------------------------------------------\n";
alertString2 += _alertString;
alert(alertString2);
}
}
//]]>
</script>
<style type="text/css">
fieldset.rows fieldset.rows { border-width : 0; }
fieldset.rows fieldset.rows fieldset.rows { border-width : 1px; }
@ -723,4 +577,151 @@ function CheckRuleForm(f) {
[% INCLUDE 'admin-menu.inc' %]
</div>
</div>
[% MACRO jsinclude BLOCK %]
<script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script>
<script type="text/javascript">
var maxMatchPoint = [% max_matchpoint %];
var maxMatchCheck = [% max_matchcheck %];
function InsertMatchpoint(loc, index) {
var original= $("#"+index);
var clone = original.clone();
clone.show();
// update IDs and form names
maxMatchPoint++;
clone.attr('id', 'mp_' + maxMatchPoint);
$("span.counter",clone).html(maxMatchPoint);
$("label",clone).each(function(){
var s = $(this).attr("for");
if (s.match(/mp_num/)) {
$(this).attr("for",s.replace(/mp_num/, 'mp_' + maxMatchPoint));
}
});
$("div",clone).each(function(){
var s = $(this).attr("id");
if (s.match(/mp_num/)) {
$(this).attr("id",s.replace(/mp_num/, 'mp_' + maxMatchPoint));
}
});
$("input",clone).each(function(){
var s = $(this).attr("id");
if(s.match(/mp_num/)){
$(this).attr("id",s.replace(/mp_num/, 'mp_' + maxMatchPoint));
}
var s = $(this).attr("name");
if(s.match(/mp_num/)){
$(this).attr("name",s.replace(/mp_num/, 'mp_' + maxMatchPoint));
}
});
$("#match_points").append(clone);
}
function InsertMatchcheck(loc, index) {
var original= $("#"+index);
var clone = original.clone();
clone.show();
// update IDs and form names
maxMatchCheck++;
clone.attr('id', 'mc_' + maxMatchCheck);
$("span.counter",clone).html(maxMatchCheck);
$("label",clone).each(function(){
var s = $(this).attr("for");
if (s.match(/mc_num/)) {
$(this).attr("for",s.replace(/mc_num/, 'mc_' + maxMatchCheck));
}
});
$("div",clone).each(function(){
var s = $(this).attr("id");
if (s.match(/mc_num/)) {
$(this).attr("id",s.replace(/mc_num/, 'mc_' + maxMatchCheck));
}
});
$("input",clone).each(function(){
var s = $(this).attr("id");
if(s.match(/mc_num/)){
$(this).attr("id",s.replace(/mc_num/, 'mc_' + maxMatchCheck));
}
var s = $(this).attr("name");
if(s.match(/mc_num/)){
$(this).attr("name",s.replace(/mc_num/, 'mc_' + maxMatchCheck));
}
});
$("#match_checks").append(clone);
}
function DeleteMatchpoint(loc) {
$(loc).parent().parent().parent().remove();
if($(".matchgroup",$("#match_points")).length == 0){
maxMatchPoint = 0;
$("#addMatchPoint").show();
}
}
function DeleteMatchcheck(loc) {
$(loc).parent().parent().parent().remove();
if($(".matchgroup",$("#match_checks")).length == 0){
maxMatchCheck = 0;
$("#addMatchCheck").show();
}
}
function DoCancel(f) {
f.op.value='';
document.Aform.submit();
}
function CheckMatchingRuleForm(f) {
var ok=1;
var _alertString="";
var alertString2;
if (f.code.value.length==0) {
_alertString += "\n- " + _("Matching rule code missing");
}
if (f.description.value.length==0) {
_alertString += "\n- " + _("Description missing");
}
if (f.threshold.value.length==0) {
_alertString += "\n- " + _("Threshold missing");
}
if (_alertString.length==0) {
document.Aform.submit();
} else {
alertString2 = _("Form not submitted because of the following problem(s)");
alertString2 += "\n------------------------------------------------------------------------------------\n";
alertString2 += _alertString;
alert(alertString2);
}
}
function CheckRuleForm(f) {
var ok=1;
var _alertString="";
var alertString2;
if (f.sort_rule.value.length==0) {
_alertString += "\n- " + _("Filing rule code missing");
}
if (f.description.value.length==0) {
_alertString += "\n- " + _("Description missing");
}
if (f.sort_routine.value.length==0) {
_alertString += "\n- " + _("Sort routine missing");
}
if (_alertString.length==0) {
document.Aform.submit();
} else {
alertString2 = _("Form not submitted because of the following problem(s)");
alertString2 += "\n------------------------------------------------------------------------------------\n";
alertString2 += _alertString;
alert(alertString2);
}
}
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]

View File

@ -1,42 +1,7 @@
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Administration &rsaquo; OAI sets &rsaquo; OAI set mappings</title>
[% INCLUDE 'doc-head-close.inc' %]
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
$("#mappingform").submit(function(){
hideDialogBox();
});
$("body").on("click","#ORbutton", function(e){
e.preventDefault();
newCondition();
});
$("body").on("click",".clear-field",function(e){
e.preventDefault();
clearRow(e.target);
});
});
function newCondition() {
var tr = $('#ORbutton').parents('tr');
var clone = $(tr).clone();
$("#ORbutton").parent('td').replaceWith('<td style="text-align:center">OR</td>');
$(tr).parent('tbody').append(clone);
}
function clearRow(link){
var tr = $(link).parent().parent();
var found = tr.find('#ORbutton');
if( found.length ){
tr.find('input[type="text"]').attr("value","");
} else {
tr.find('input[type="text"]').attr("value","").end().hide();
}
}
function hideDialogBox() {
$('div.dialog').remove();
}
//]]>
</script>
</head>
<body id="admin_oai_set_mappings" class="admin">
@ -126,4 +91,42 @@ function hideDialogBox() {
[% INCLUDE 'admin-menu.inc' %]
</div>
</div>
[% MACRO jsinclude BLOCK %]
<script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#mappingform").submit(function(){
hideDialogBox();
});
$("body").on("click","#ORbutton", function(e){
e.preventDefault();
newCondition();
});
$("body").on("click",".clear-field",function(e){
e.preventDefault();
clearRow(e.target);
});
});
function newCondition() {
var tr = $('#ORbutton').parents('tr');
var clone = $(tr).clone();
$("#ORbutton").parent('td').replaceWith('<td style="text-align:center">OR</td>');
$(tr).parent('tbody').append(clone);
}
function clearRow(link){
var tr = $(link).parent().parent();
var found = tr.find('#ORbutton');
if( found.length ){
tr.find('input[type="text"]').attr("value","");
} else {
tr.find('input[type="text"]').attr("value","").end().hide();
}
}
function hideDialogBox() {
$('div.dialog').remove();
}
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]

View File

@ -1,44 +1,7 @@
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Administration &rsaquo; [% IF ( op_new ) %]OAI sets configuration &rsaquo; Add a new OAI set[% ELSE %]OAI sets configuration[% END %]</title>
[% INCLUDE 'doc-head-close.inc' %]
<script type="text/javascript">
//<![CDATA[
function newDescField() {
$("#adddescription").before(
'<li><label>setDescription: </label>' +
'<textarea style="vertical-align:middle" rows="2" cols="30" name="description"></textarea>' +
'<a class="remove_description" href="#"><i class="fa fa-fw fa-trash"></i> Remove</a>' +
'</li>'
);
}
function delDescField(minusButton) {
var li = minusButton.parent('li');
$(li).remove();
}
function confirmDelete() {
return confirm(_("Are you sure you want to delete this OAI set?"));
}
$(document).ready(function() {
$(".delete_oai_set").on("click",function(){
return confirmDelete();
});
$("body").on("click", ".remove_description", function(e){
e.preventDefault();
delDescField($(this));
});
$(".add_description").on("click", function(e){
e.preventDefault();
newDescField();
});
});
//]]>
</script>
</head>
<body id="admin_oai_sets" class="admin">
@ -148,4 +111,44 @@ $(document).ready(function() {
[% INCLUDE 'admin-menu.inc' %]
</div>
</div>
[% MACRO jsinclude BLOCK %]
<script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script>
<script type="text/javascript">
function newDescField() {
$("#adddescription").before(
'<li><label>setDescription: </label>' +
'<textarea style="vertical-align:middle" rows="2" cols="30" name="description"></textarea>' +
'<a class="remove_description" href="#"><i class="fa fa-fw fa-trash"></i> Remove</a>' +
'</li>'
);
}
function delDescField(minusButton) {
var li = minusButton.parent('li');
$(li).remove();
}
function confirmDelete() {
return confirm(_("Are you sure you want to delete this OAI set?"));
}
$(document).ready(function() {
$(".delete_oai_set").on("click",function(){
return confirmDelete();
});
$("body").on("click", ".remove_description", function(e){
e.preventDefault();
delDescField($(this));
});
$(".add_description").on("click", function(e){
e.preventDefault();
newDescField();
});
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]