From e01bd1ebc6fffd837db7a04990486d6cb2b05e5d Mon Sep 17 00:00:00 2001 From: Chris Hallberg <crhallberg@gmail.com> Date: Wed, 2 Mar 2016 16:39:08 -0500 Subject: [PATCH] Switch to module object style for the VuFind namespace. --- themes/bootstrap3/js/common.js | 35 ++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/themes/bootstrap3/js/common.js b/themes/bootstrap3/js/common.js index 17c7aeed7ed..257938d1fc0 100644 --- a/themes/bootstrap3/js/common.js +++ b/themes/bootstrap3/js/common.js @@ -3,18 +3,29 @@ // IE 9< console polyfill window.console = window.console || {log: function () {}}; -var VuFind = { - defaultSearchBackend: null, - path: null, - translations: {}, +var VuFind = (function() { + var defaultSearchBackend = null; + var path = null; + var _translations = {}; - addTranslations: function(s) { + var addTranslations = function(s) { for (var i in s) { - this.translations[i] = s[i]; + _translations[i] = s[i]; } - }, - translate: function(op) { return this.translations[op] || op; } -} + }; + var translate = function(op) { + return _translations[op] || op; + }; + + //Reveal + return { + defaultSearchBackend: defaultSearchBackend, + path: path, + + addTranslations: addTranslations, + translate: translate + }; +})(); /* --- GLOBAL FUNCTIONS --- */ function htmlEncode(value) { @@ -381,14 +392,14 @@ function keyboardShortcuts() { } } -// This can be called with a container e.g. when combined results fetched with AJAX +// This can be called with a container e.g. when combined results fetched with AJAX // are loaded function setupSaveRecordLinks(container) { if (typeof(container) == 'undefined') { container = $('body'); } - + // Save record links container.find('.result .save-record').click(function() { var parts = this.href.split('/'); @@ -407,7 +418,7 @@ $(document).ready(function() { keyboardShortcuts(); // Save record links setupSaveRecordLinks(); - + // support "jump menu" dropdown boxes $('select.jumpMenu').change(function(){ $(this).parent('form').submit(); }); -- GitLab