From fea1db099759253c873cb093c31a034b7f993cbc Mon Sep 17 00:00:00 2001 From: Chris Hallberg <crhallberg@gmail.com> Date: Wed, 2 Dec 2015 12:55:12 -0500 Subject: [PATCH] JS checkstyles. --- themes/bootstrap3/js/common.js | 10 +++++----- themes/bootstrap3/js/lightbox.js | 2 +- themes/bootstrap3/js/record.js | 7 ++++--- themes/bootstrap3/templates/layout/layout.phtml | 12 ++++++------ 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/themes/bootstrap3/js/common.js b/themes/bootstrap3/js/common.js index c19527cad48..f2aa4983560 100644 --- a/themes/bootstrap3/js/common.js +++ b/themes/bootstrap3/js/common.js @@ -4,14 +4,14 @@ function VuFindNamespace(p, s) { var path = p; var strings = s; - var getPath = function() { return path; } - var translate = function(op) { return strings[op]; } + var getPath = function() { return path; }; + var translate = function(op) { return strings[op]; }; return { getPath: getPath, translate: translate }; -}; +} /* --- GLOBAL FUNCTIONS --- */ function htmlEncode(value) { @@ -184,7 +184,7 @@ function newAccountHandler(html) { Lightbox.getByUrl(Lightbox.openingURL); Lightbox.openingURL = false; } - return valid == true; + return false; } // This is a full handler for the login form @@ -346,7 +346,7 @@ function keyboardShortcuts() { if ($('.pager').length > 0) { $(window).keydown(function(e) { if (!$searchform.is(':focus')) { - $target = null; + var $target = null; switch (e.keyCode) { case 37: // left arrow key $target = $('.pager').find('a.previous'); diff --git a/themes/bootstrap3/js/lightbox.js b/themes/bootstrap3/js/lightbox.js index a0176a5ea46..26900eac3e9 100644 --- a/themes/bootstrap3/js/lightbox.js +++ b/themes/bootstrap3/js/lightbox.js @@ -1,4 +1,4 @@ -/*global checkSaveStatuses, console, deparam, Recaptcha, VuFind */ +/*global ajaxLogin, checkSaveStatuses, console, deparam, newAccountHandler, Recaptcha, refreshPageForLogin, registerLightboxEvents, VuFind */ var Lightbox = { /** diff --git a/themes/bootstrap3/js/record.js b/themes/bootstrap3/js/record.js index fb0ab767abb..540c983fe7a 100644 --- a/themes/bootstrap3/js/record.js +++ b/themes/bootstrap3/js/record.js @@ -140,15 +140,16 @@ function ajaxLoadTab($newTab, tabid, setHash) { var urlParts = document.URL.split(/[?#]/); var urlWithoutFragment = urlParts[0]; var path = VuFind.getPath(); + var urlroot = null; if (path === '') { // special case -- VuFind installed at site root: var chunks = urlWithoutFragment.split('/'); - var urlroot = '/' + chunks[3] + '/' + chunks[4]; + urlroot = '/' + chunks[3] + '/' + chunks[4]; } else { // standard case -- VuFind has its own path under site: var pathInUrl = urlWithoutFragment.indexOf(path); - var chunks = urlWithoutFragment.substring(pathInUrl + path.length + 1).split('/'); - var urlroot = '/' + chunks[0] + '/' + chunks[1]; + var parts = urlWithoutFragment.substring(pathInUrl + path.length + 1).split('/'); + urlroot = '/' + parts[0] + '/' + parts[1]; } // Request the tab via AJAX: diff --git a/themes/bootstrap3/templates/layout/layout.phtml b/themes/bootstrap3/templates/layout/layout.phtml index 4f8140b1425..1a39cce2449 100644 --- a/themes/bootstrap3/templates/layout/layout.phtml +++ b/themes/bootstrap3/templates/layout/layout.phtml @@ -95,12 +95,12 @@ } ?> <?=$this->headScript()?> - <script> - var VuFind = new VuFindNamespace( - '<?=rtrim($this->url('home'), '/') ?>', - <?=$this->jsTranslations()->getJSON() ?> - ); - </script> + <? + $root = rtrim($this->url('home'), '/'); + $translations = $this->jsTranslations()->getJSON(); + $setupJS = "var VuFind = new VuFindNamespace('{$root}', {$translations});"; + ?> + <?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $setupJS, 'SET'); ?> </head> <body class="<?=$this->layoutClass('offcanvas-row')?><? if ($this->layout()->rtl): ?> rtl<? endif; ?>"> <? // Set up the search box -- there are three possible cases: -- GitLab