[Koha-bugs] [Bug 17498] New: Expose system preference values to JavaScript in the OPAC
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Tue Oct 25 19:30:50 CEST 2016
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17498
Bug ID: 17498
Summary: Expose system preference values to JavaScript in the
OPAC
Change sponsored?: ---
Product: Koha
Version: master
Hardware: All
OS: All
Status: ASSIGNED
Severity: enhancement
Priority: P5 - low
Component: OPAC
Assignee: oleonard at myacpl.org
Reporter: oleonard at myacpl.org
QA Contact: testopia at bugs.koha-community.org
We process a lot of JavaScript in the OPAC templates, usually because there are
template variable which need to be processed. Some of these variable, like
system preferences, are a global setting which is common to many pages in the
OPAC. I propose that these settings be defined in embedded JavaScript so that
the scripts themselves can be moved to a separate file.
In my proposal, opac-bottom.inc will contain a section like this:
<script type="text/javascript">
if (typeof KOHA == "undefined" || !KOHA) {
var KOHA = {};
}
KOHA.paths = {
"interface_theme":"[% interface %]/[% theme %]"
}
KOHA.preferences = {
"BakerTaylorEnabled" : [% IF ( Koha.Preference( 'BakerTaylorEnabled' )
== 1 ) %]1[% ELSE %]0[% END %],
...and then an separate JS file will use those variables to conditionally load
resources:
if( KOHA.preferences.Coce && KOHA.preferences.CoceProviders ){
KOHA.externalResources.push( KOHA.paths.interface_theme + "/js/coce.js" );
var NO_COCE_JACKET = _("No cover image available");
}
if( KOHA.externalResources.length > 0 ){
Modernizr.load({
load: KOHA.externalResources
});
}
I'd appreciate comments anyone might have on this system. My goal, if this
works well, is to then add a JavaScript concatenation/minification task for
OPAC js assets. Moving as much JS as possible out of the templates will help us
take advantage of that minification.
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list