Bugzilla – Attachment 69055 Details for
Bug 19601
Move admin templates JavaScript to the footer: Additional parameters
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19601: Move admin templates JavaScript to the footer: Additional parameters
Bug-19601-Move-admin-templates-JavaScript-to-the-f.patch (text/plain), 21.40 KB, created by
Owen Leonard
on 2017-11-09 13:58:15 UTC
(
hide
)
Description:
Bug 19601: Move admin templates JavaScript to the footer: Additional parameters
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2017-11-09 13:58:15 UTC
Size:
21.40 KB
patch
obsolete
>From 73789e55855789e86e05a86f26d9a86f7bee7fc2 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Thu, 9 Nov 2017 13:53:19 +0000 >Subject: [PATCH] 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. >--- > .../prog/en/modules/admin/audio_alerts.tt | 17 ++- > .../prog/en/modules/admin/columns_settings.tt | 36 ++--- > .../prog/en/modules/admin/didyoumean.tt | 98 +++++++------- > .../prog/en/modules/admin/sms_providers.tt | 21 +-- > .../prog/en/modules/admin/usage_statistics.tt | 83 ++++++------ > .../prog/en/modules/admin/z3950servers.tt | 147 +++++++++++---------- > 6 files changed, 213 insertions(+), 189 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/audio_alerts.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/audio_alerts.tt >index a1d3309..0ebf15f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/audio_alerts.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/audio_alerts.tt >@@ -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' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/columns_settings.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/columns_settings.tt >index 884cc77..d7faa30 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/columns_settings.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/columns_settings.tt >@@ -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' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/didyoumean.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/didyoumean.tt >index fa4e52b..9604316 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/didyoumean.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/didyoumean.tt >@@ -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' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/sms_providers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/sms_providers.tt >index c974417..15c4de2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/sms_providers.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/sms_providers.tt >@@ -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' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/usage_statistics.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/usage_statistics.tt >index f210049..6ae0314 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/usage_statistics.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/usage_statistics.tt >@@ -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' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt >index d25cc36..f610cd4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt >@@ -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' %] >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19601
:
69055
|
69078
|
69499