Skip to content
Snippets Groups Projects
Commit cb500403 authored by Ere Maijala's avatar Ere Maijala Committed by Robert Lange
Browse files

Collect Cart scripts and several others to a single block.

This cleans up and compresses the result by putting all the small scripts to a single block.
parent a1112ec9
Branches
Tags
No related merge requests found
......@@ -25,6 +25,9 @@
<?=$this->headLink()?>
<?=$this->headStyle()?>
<?php
// Collect small scripts together and append as one block:
$appendScripts = [];
if (!isset($this->renderingError)) {
// Add translation strings
$this->jsTranslations()->addStrings(
......@@ -72,21 +75,15 @@
$this->headScript()->appendFile("cart.js");
$domain = $cart->getCookieDomain();
if (!empty($domain)) {
$this->headScript()->appendScript(
'VuFind.cart.setDomain("' . $domain . '");'
);
$appendScripts[] = 'VuFind.cart.setDomain("' . $domain . '");';
}
$cookiePath = $cart->getCookiePath();
if (!empty($cookiePath)) {
$this->headScript()->appendScript(
'VuFind.cart.setCookiePath("' . $cookiePath . '");'
);
$appendScripts[] = 'VuFind.cart.setCookiePath("' . $cookiePath . '");';
}
$cookieSameSite = $cart->getCookieSameSite();
if (null !== $cookieSameSite) {
$this->headScript()->appendScript(
'VuFind.cart.setCookieSameSite("' . $cookieSameSite . '");'
);
$appendScripts[] = 'VuFind.cart.setCookieSameSite("' . $cookieSameSite . '");';
}
$this->jsTranslations()->addStrings(
[
......@@ -110,8 +107,7 @@
// Session keep-alive
if ($this->keepAlive()) {
$this->headScript()->appendScript('var keepAliveInterval = '
. $this->keepAlive());
$appendScripts[] = 'var keepAliveInterval = ' . $this->keepAlive() . ';';
$this->headScript()->appendFile("keep_alive.js");
}
......@@ -134,12 +130,13 @@
$root = rtrim($this->url('home'), '/');
$translations = $this->jsTranslations()->getJSON();
$dsb = DEFAULT_SEARCH_BACKEND;
$setupJS = <<<JS
$appendScripts[] = <<<JS
VuFind.path = '{$root}';
VuFind.defaultSearchBackend = '{$dsb}';
VuFind.addTranslations({$translations});
JS;
$this->headScript()->appendScript($setupJS);
$this->headScript()->appendScript(implode("\n", $appendScripts));
if ($this->config()->ajaxCoversEnabled()) {
$this->headScript()->appendFile("covers.js");
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment