Bug 19601: Move admin templates JavaScript to the footer: Additional parameters
This patch modifies the staff client "additional parameters" 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 page: 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:
parent
634c55aacb
commit
1e40274411
6 changed files with 213 additions and 189 deletions
|
@ -1,13 +1,8 @@
|
|||
[% USE Koha %]
|
||||
[% SET footerjs = 1 %]
|
||||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
<title>Koha › Administration › Audio alerts</title>
|
||||
[% INCLUDE 'doc-head-close.inc' %]
|
||||
<script type="text/javascript">
|
||||
var MSG_AUDIO_EMPTY_SOUND = _("Please select or enter a sound.");
|
||||
var MSG_AUDIO_CONFIRM_DELETE = _("Are you sure you want to delete the selected audio alerts?");
|
||||
var MSG_AUDIO_CHECK_CHECKBOXES = _("Check the box next to the alert you want to delete.")
|
||||
</script>
|
||||
<script type="text/javascript" src="[% interface %]/[% theme %]/js/audio_alerts.js"></script>
|
||||
</head>
|
||||
|
||||
<body id="admin_audio_alerts" class="admin">
|
||||
|
@ -135,4 +130,14 @@
|
|||
[% 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 MSG_AUDIO_EMPTY_SOUND = _("Please select or enter a sound.");
|
||||
var MSG_AUDIO_CONFIRM_DELETE = _("Are you sure you want to delete the selected audio alerts?");
|
||||
var MSG_AUDIO_CHECK_CHECKBOXES = _("Check the box next to the alert you want to delete.")
|
||||
</script>
|
||||
<script type="text/javascript" src="[% interface %]/[% theme %]/js/audio_alerts.js"></script>
|
||||
[% END %]
|
||||
[% INCLUDE 'intranet-bottom.inc' %]
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
[% SET footerjs = 1 %]
|
||||
[% SET panel_id = 0 %]
|
||||
[% BLOCK pagelist %]
|
||||
<div class="pagelist">
|
||||
|
@ -87,22 +88,8 @@
|
|||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
<title>Koha › Administration › Columns settings</title>
|
||||
[% INCLUDE 'doc-head-close.inc' %]
|
||||
<script type="text/javascript">
|
||||
$(document).ready( function() {
|
||||
var accordion = $( "#modules" ).accordion({
|
||||
collapsible: true,
|
||||
autoHeight: false,
|
||||
header: "h3",
|
||||
[%- IF panel -%]
|
||||
[%# we were asked to show a specific panel, usually on update %]
|
||||
active: [%- panel -%]
|
||||
[%- ELSE -%]
|
||||
active: false
|
||||
[%- END -%]
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body id="admin_tables" class="admin">
|
||||
[% INCLUDE 'header.inc' %]
|
||||
[% INCLUDE 'prefs-admin-search.inc' %]
|
||||
|
@ -176,4 +163,23 @@
|
|||
[% 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() {
|
||||
var accordion = $( "#modules" ).accordion({
|
||||
collapsible: true,
|
||||
autoHeight: false,
|
||||
header: "h3",
|
||||
[%- IF panel -%]
|
||||
[%# we were asked to show a specific panel, usually on update %]
|
||||
active: [%- panel -%]
|
||||
[%- ELSE -%]
|
||||
active: false
|
||||
[%- END -%]
|
||||
});
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
[% INCLUDE 'intranet-bottom.inc' %]
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
[% SET footerjs = 1 %]
|
||||
[% BLOCK pluginlist %]
|
||||
<div class="pluginlist">
|
||||
[% FOREACH plugin IN plugins %]
|
||||
|
@ -21,53 +22,8 @@
|
|||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
<title>Koha › Administration › Did you mean?</title>
|
||||
[% INCLUDE 'doc-head-close.inc' %]
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$( ".pluginlist" ).sortable();
|
||||
$( ".plugin" ).addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" )
|
||||
.find( ".pluginname" )
|
||||
.addClass( "ui-widget-header ui-corner-all" )
|
||||
.end()
|
||||
.find( ".plugindesc" );
|
||||
$(".save-all").on("click",function(e){
|
||||
e.preventDefault();
|
||||
yesimeant();
|
||||
});
|
||||
$(".force_reload").on("click",function(e){
|
||||
e.preventDefault();
|
||||
window.location.reload(true);
|
||||
});
|
||||
});
|
||||
|
||||
function yesimeant() {
|
||||
var OPACdidyoumean = serialize_plugins('opac');
|
||||
var INTRAdidyoumean = serialize_plugins('intranet');
|
||||
|
||||
var data = "pref_OPACdidyoumean=" + encodeURIComponent(OPACdidyoumean) + "&pref_INTRAdidyoumean=" + encodeURIComponent(INTRAdidyoumean);
|
||||
|
||||
$.ajax({
|
||||
data: data,
|
||||
type: 'POST',
|
||||
url: '/cgi-bin/koha/svc/config/systempreferences/',
|
||||
success: function () { alert("Successfully saved configuration"); },
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function serialize_plugins(interface) {
|
||||
var serializedconfig = '[';
|
||||
$('#didyoumean' + interface + ' .pluginlist .plugin').each(function(index) {
|
||||
var name = $(this).find('.pluginlabel').text();
|
||||
var enabled = $(this).find('input:checkbox:checked').length ?
|
||||
', "enabled": 1' : '';
|
||||
serializedconfig += '{ "name": "' + name + '"' + enabled + '}, ';
|
||||
});
|
||||
serializedconfig = serializedconfig.substring(0, serializedconfig.length - 2);
|
||||
serializedconfig += ']';
|
||||
return serializedconfig;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body id="admin_didyoumean" class="admin">
|
||||
[% INCLUDE 'header.inc' %]
|
||||
[% INCLUDE 'prefs-admin-search.inc' %]
|
||||
|
@ -110,4 +66,54 @@
|
|||
[% 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() {
|
||||
$( ".pluginlist" ).sortable();
|
||||
$( ".plugin" ).addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" )
|
||||
.find( ".pluginname" )
|
||||
.addClass( "ui-widget-header ui-corner-all" )
|
||||
.end()
|
||||
.find( ".plugindesc" );
|
||||
$(".save-all").on("click",function(e){
|
||||
e.preventDefault();
|
||||
yesimeant();
|
||||
});
|
||||
$(".force_reload").on("click",function(e){
|
||||
e.preventDefault();
|
||||
window.location.reload(true);
|
||||
});
|
||||
});
|
||||
|
||||
function yesimeant() {
|
||||
var OPACdidyoumean = serialize_plugins('opac');
|
||||
var INTRAdidyoumean = serialize_plugins('intranet');
|
||||
|
||||
var data = "pref_OPACdidyoumean=" + encodeURIComponent(OPACdidyoumean) + "&pref_INTRAdidyoumean=" + encodeURIComponent(INTRAdidyoumean);
|
||||
|
||||
$.ajax({
|
||||
data: data,
|
||||
type: 'POST',
|
||||
url: '/cgi-bin/koha/svc/config/systempreferences/',
|
||||
success: function () { alert("Successfully saved configuration"); },
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function serialize_plugins(interface) {
|
||||
var serializedconfig = '[';
|
||||
$('#didyoumean' + interface + ' .pluginlist .plugin').each(function(index) {
|
||||
var name = $(this).find('.pluginlabel').text();
|
||||
var enabled = $(this).find('input:checkbox:checked').length ?
|
||||
', "enabled": 1' : '';
|
||||
serializedconfig += '{ "name": "' + name + '"' + enabled + '}, ';
|
||||
});
|
||||
serializedconfig = serializedconfig.substring(0, serializedconfig.length - 2);
|
||||
serializedconfig += ']';
|
||||
return serializedconfig;
|
||||
}
|
||||
</script>
|
||||
[% END %]
|
||||
[% INCLUDE 'intranet-bottom.inc' %]
|
||||
|
|
|
@ -1,15 +1,7 @@
|
|||
[% SET footerjs = 1 %]
|
||||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
<title>Koha › Administration › SMS cellular providers</title>
|
||||
[% INCLUDE 'doc-head-close.inc' %]
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
var MSG_SMS_PATRONS_USING = _("Are you sure you want to delete %s? %s patron(s) are using it!");
|
||||
var MSG_SMS_DELETE_CONFIRM = _("Are you sure you want to delete %s?");
|
||||
var LABEL_SMS_ADD_PROVIDER = _("Add an SMS cellular provider");
|
||||
var LABEL_SMS_EDIT_PROVIDER = _("Edit provider %s");
|
||||
//]]>
|
||||
</script>
|
||||
<script type="text/javascript" src="[% interface %]/[% theme %]/js/sms_providers.js"></script>
|
||||
</head>
|
||||
|
||||
<body id="admin_sms_providers" class="admin">
|
||||
|
@ -102,4 +94,15 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
[% MACRO jsinclude BLOCK %]
|
||||
<script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script>
|
||||
<script type="text/javascript">
|
||||
var MSG_SMS_PATRONS_USING = _("Are you sure you want to delete %s? %s patron(s) are using it!");
|
||||
var MSG_SMS_DELETE_CONFIRM = _("Are you sure you want to delete %s?");
|
||||
var LABEL_SMS_ADD_PROVIDER = _("Add an SMS cellular provider");
|
||||
var LABEL_SMS_EDIT_PROVIDER = _("Edit provider %s");
|
||||
</script>
|
||||
<script type="text/javascript" src="[% interface %]/[% theme %]/js/sms_providers.js"></script>
|
||||
[% END %]
|
||||
[% INCLUDE 'intranet-bottom.inc' %]
|
||||
|
|
|
@ -1,44 +1,11 @@
|
|||
[% SET footerjs = 1 %]
|
||||
[% USE Koha %]
|
||||
[% USE KohaDates %]
|
||||
[% USE Price %]
|
||||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
<title>Koha › Administration › Koha usage statistics</title>
|
||||
[% INCLUDE 'doc-head-close.inc' %]
|
||||
[% INCLUDE 'calendar.inc' %]
|
||||
<link rel="stylesheet" href="[% interface %]/lib/leaflet/leaflet.css" />
|
||||
<script src="[% interface %]/lib/leaflet/leaflet.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function positionMap() {
|
||||
var tbh = $("#mapid");
|
||||
var mapContainer = tbh.parent();
|
||||
mapContainer.css('position', 'relative');
|
||||
mapContainer.css('min-height', tbh.outerHeight(true));
|
||||
tbh.css('position', 'absolute');
|
||||
tbh.css('right', 0);
|
||||
|
||||
var offsetTop = mapContainer.offset().top;
|
||||
var s = parseInt($(window).scrollTop(), 10);
|
||||
tbh.css('top', '').css('bottom', '');
|
||||
if (s > offsetTop) {
|
||||
var mapContainerOffsetBottom = offsetTop + mapContainer.innerHeight();
|
||||
if (s + tbh.outerHeight(true) > mapContainerOffsetBottom) {
|
||||
tbh.css('bottom', 0);
|
||||
} else {
|
||||
tbh.css('top', s - offsetTop);
|
||||
}
|
||||
} else {
|
||||
tbh.css('top', 0);
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(window).scroll(positionMap);
|
||||
positionMap();
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body id="admin_usage_statistics" class="admin">
|
||||
|
@ -252,8 +219,46 @@
|
|||
<a class="cancel" href="/cgi-bin/koha/admin/usage_statistics.pl">Cancel</a>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui-b">
|
||||
[% INCLUDE 'admin-menu.inc' %]
|
||||
</div>
|
||||
</div>
|
||||
|
||||
[% MACRO jsinclude BLOCK %]
|
||||
[% INCLUDE 'calendar.inc' %]
|
||||
<script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script>
|
||||
<script src="[% interface %]/lib/leaflet/leaflet.js"></script>
|
||||
<script type="text/javascript">
|
||||
function positionMap() {
|
||||
var tbh = $("#mapid");
|
||||
var mapContainer = tbh.parent();
|
||||
mapContainer.css('position', 'relative');
|
||||
mapContainer.css('min-height', tbh.outerHeight(true));
|
||||
tbh.css('position', 'absolute');
|
||||
tbh.css('right', 0);
|
||||
|
||||
var offsetTop = mapContainer.offset().top;
|
||||
var s = parseInt($(window).scrollTop(), 10);
|
||||
tbh.css('top', '').css('bottom', '');
|
||||
if (s > offsetTop) {
|
||||
var mapContainerOffsetBottom = offsetTop + mapContainer.innerHeight();
|
||||
if (s + tbh.outerHeight(true) > mapContainerOffsetBottom) {
|
||||
tbh.css('bottom', 0);
|
||||
} else {
|
||||
tbh.css('top', s - offsetTop);
|
||||
}
|
||||
} else {
|
||||
tbh.css('top', 0);
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(window).scroll(positionMap);
|
||||
positionMap();
|
||||
});
|
||||
|
||||
<script>
|
||||
var map = L.map('mapid').setView([0,0], 1);
|
||||
|
||||
L.tileLayer('https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
|
@ -329,11 +334,5 @@
|
|||
});
|
||||
|
||||
</script>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui-b">
|
||||
[% INCLUDE 'admin-menu.inc' %]
|
||||
</div>
|
||||
</div>
|
||||
[% END %]
|
||||
[% INCLUDE 'intranet-bottom.inc' %]
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
[% SET footerjs = 1 %]
|
||||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
|
||||
[% BLOCK ServerType %]
|
||||
|
@ -16,79 +17,9 @@
|
|||
|
||||
[% IF op == 'list' %]
|
||||
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
|
||||
[% INCLUDE 'datatables.inc' %]
|
||||
[% END %]
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
[% IF ( add_form ) %]
|
||||
$(document).ready(function(){
|
||||
// Update selects for syntax, encoding and recordtype
|
||||
[% IF server %]
|
||||
$("#syntax").val('[% server.syntax %]');
|
||||
$("#encoding").val('[% server.encoding %]');
|
||||
$("#recordtype").val('[% server.recordtype %]');
|
||||
[% END %]
|
||||
// Disable recordtype (and default to bib) for non-Z3950 servers until auth is supported
|
||||
[% UNLESS (server.servertype||type) == 'zed' %]
|
||||
$("#recordtype").prop('disabled',true);
|
||||
[% END %]
|
||||
$( "#serverentry" ).validate({
|
||||
rules: {
|
||||
servername: { required: true },
|
||||
host: { required: true },
|
||||
port: {
|
||||
required: true,
|
||||
number: true
|
||||
},
|
||||
db: { required: true },
|
||||
rank: { number: true },
|
||||
timeout: { number: true }
|
||||
}
|
||||
});
|
||||
$("#serverentry").submit(function( event ) {
|
||||
// first test if show_sru_fields exists
|
||||
if( $('#show_sru_fields').length && $('#show_sru_fields').val()=='' && !confirm( _("No SRU search field mappings have been defined. This means that all field searches will go through the whole record. Continue?"))) {
|
||||
return false;
|
||||
}
|
||||
// copy show_sru_fields to hidden counterpart
|
||||
$('#sru_fields').val( $('#show_sru_fields').val() );
|
||||
// enable recordtype to include field in post
|
||||
$('#recordtype').prop('disabled',false);
|
||||
});
|
||||
$("#servername").on("blur",function(){
|
||||
toUC(this);
|
||||
});
|
||||
$("#modify_sru_fields").on("click",function(){
|
||||
ModMapping();
|
||||
});
|
||||
});
|
||||
function ModMapping () {
|
||||
var map= $('#show_sru_fields').val();
|
||||
window.open('/cgi-bin/koha/admin/sru_modmapping.pl?mapping='+map,'popup','width=800,height=400,resizable=yes,toolbar=false,scrollbars=yes,top');
|
||||
}
|
||||
[% ELSE %]
|
||||
$(document).ready(function() {
|
||||
$("#serverst").dataTable($.extend(true, {}, dataTablesDefaults, {
|
||||
"aoColumnDefs": [
|
||||
{ "aTargets": [2,3,4,7,8,9,10,11], "bSortable": false, "bSearchable": false },
|
||||
],
|
||||
"sPaginationType": "four_button"
|
||||
}));
|
||||
$(".delete").on("click",function(e){
|
||||
var servername = $(this).data("servername");
|
||||
if( confirm( _("Are you sure you want to delete server %s?").format(servername) ) ) {
|
||||
return true;
|
||||
} else {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
[% END %]
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body id="admin_z3950servers" class="admin">
|
||||
[% INCLUDE 'header.inc' %]
|
||||
[% INCLUDE 'z3950-admin-search.inc' %]
|
||||
|
@ -265,4 +196,78 @@
|
|||
[% INCLUDE 'admin-menu.inc' %]
|
||||
</div>
|
||||
</div>
|
||||
|
||||
[% MACRO jsinclude BLOCK %]
|
||||
<script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script>
|
||||
[% IF op == 'list' %]
|
||||
[% INCLUDE 'datatables.inc' %]
|
||||
[% END %]
|
||||
|
||||
<script type="text/javascript">
|
||||
[% IF ( add_form ) %]
|
||||
$(document).ready(function(){
|
||||
// Update selects for syntax, encoding and recordtype
|
||||
[% IF server %]
|
||||
$("#syntax").val('[% server.syntax %]');
|
||||
$("#encoding").val('[% server.encoding %]');
|
||||
$("#recordtype").val('[% server.recordtype %]');
|
||||
[% END %]
|
||||
// Disable recordtype (and default to bib) for non-Z3950 servers until auth is supported
|
||||
[% UNLESS (server.servertype||type) == 'zed' %]
|
||||
$("#recordtype").prop('disabled',true);
|
||||
[% END %]
|
||||
$( "#serverentry" ).validate({
|
||||
rules: {
|
||||
servername: { required: true },
|
||||
host: { required: true },
|
||||
port: {
|
||||
required: true,
|
||||
number: true
|
||||
},
|
||||
db: { required: true },
|
||||
rank: { number: true },
|
||||
timeout: { number: true }
|
||||
}
|
||||
});
|
||||
$("#serverentry").submit(function( event ) {
|
||||
// first test if show_sru_fields exists
|
||||
if( $('#show_sru_fields').length && $('#show_sru_fields').val()=='' && !confirm( _("No SRU search field mappings have been defined. This means that all field searches will go through the whole record. Continue?"))) {
|
||||
return false;
|
||||
}
|
||||
// copy show_sru_fields to hidden counterpart
|
||||
$('#sru_fields').val( $('#show_sru_fields').val() );
|
||||
// enable recordtype to include field in post
|
||||
$('#recordtype').prop('disabled',false);
|
||||
});
|
||||
$("#servername").on("blur",function(){
|
||||
toUC(this);
|
||||
});
|
||||
$("#modify_sru_fields").on("click",function(){
|
||||
ModMapping();
|
||||
});
|
||||
});
|
||||
function ModMapping () {
|
||||
var map= $('#show_sru_fields').val();
|
||||
window.open('/cgi-bin/koha/admin/sru_modmapping.pl?mapping='+map,'popup','width=800,height=400,resizable=yes,toolbar=false,scrollbars=yes,top');
|
||||
}
|
||||
[% ELSE %]
|
||||
$(document).ready(function() {
|
||||
$("#serverst").dataTable($.extend(true, {}, dataTablesDefaults, {
|
||||
"aoColumnDefs": [
|
||||
{ "aTargets": [2,3,4,7,8,9,10,11], "bSortable": false, "bSearchable": false },
|
||||
],
|
||||
"sPaginationType": "four_button"
|
||||
}));
|
||||
$(".delete").on("click",function(e){
|
||||
var servername = $(this).data("servername");
|
||||
if( confirm( _("Are you sure you want to delete server %s?").format(servername) ) ) {
|
||||
return true;
|
||||
} else {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
[% END %]
|
||||
</script>
|
||||
[% END %]
|
||||
[% INCLUDE 'intranet-bottom.inc' %]
|
||||
|
|
Loading…
Reference in a new issue