From c81c45641321300ef3fcea5f07ffcf2d0e917ff3 Mon Sep 17 00:00:00 2001 From: Chris Hallberg <crhallberg@gmail.com> Date: Fri, 10 Jun 2016 09:53:56 -0400 Subject: [PATCH] Auto-fix eslint formatting. --- themes/bootstrap3/js/advanced_search.js | 72 +++---- themes/bootstrap3/js/autocomplete.js | 138 ++++++------ themes/bootstrap3/js/cart.js | 56 ++--- themes/bootstrap3/js/check_item_statuses.js | 8 +- themes/bootstrap3/js/check_save_statuses.js | 6 +- themes/bootstrap3/js/collection_record.js | 2 +- themes/bootstrap3/js/common.js | 104 ++++----- themes/bootstrap3/js/facets.js | 20 +- themes/bootstrap3/js/hierarchyTree.js | 16 +- themes/bootstrap3/js/hold.js | 4 +- themes/bootstrap3/js/lightbox.js | 20 +- themes/bootstrap3/js/preview.js | 226 ++++++++++---------- themes/bootstrap3/js/pubdate_vis.js | 20 +- themes/bootstrap3/js/record.js | 24 +-- 14 files changed, 358 insertions(+), 358 deletions(-) diff --git a/themes/bootstrap3/js/advanced_search.js b/themes/bootstrap3/js/advanced_search.js index b4eac3c5963..d363c6ae3ee 100644 --- a/themes/bootstrap3/js/advanced_search.js +++ b/themes/bootstrap3/js/advanced_search.js @@ -2,33 +2,33 @@ var nextGroup = 0; var groupLength = []; function addSearch(group, fieldValues) { - if(typeof fieldValues === "undefined") { + if (typeof fieldValues === "undefined") { fieldValues = {}; } // Build the new search - var inputID = group+'_'+groupLength[group]; + var inputID = group + '_' + groupLength[group]; var $newSearch = $($('#new_search_template').html()); - $newSearch.attr('id', 'search'+inputID); + $newSearch.attr('id', 'search' + inputID); $newSearch.find('input.form-control') - .attr('id', 'search_lookfor'+inputID) - .attr('name', 'lookfor'+group+'[]') + .attr('id', 'search_lookfor' + inputID) + .attr('name', 'lookfor' + group + '[]') .attr('value', ''); $newSearch.find('select.type option:first-child').attr('selected', 1); $newSearch.find('select.type') - .attr('id', 'search_type'+inputID) - .attr('name', 'type'+group+'[]'); + .attr('id', 'search_type' + inputID) + .attr('name', 'type' + group + '[]'); $newSearch.find('.close a') - .attr('onClick', 'deleteSearch('+group+','+groupLength[group]+')'); + .attr('onClick', 'deleteSearch(' + group + ',' + groupLength[group] + ')'); // Preset Values - if(typeof fieldValues.term !== "undefined") { + if (typeof fieldValues.term !== "undefined") { $newSearch.find('input.form-control').attr('value', fieldValues.term); } - if(typeof fieldValues.field !== "undefined") { - $newSearch.find('select.type option[value="'+fieldValues.field+'"]').attr('selected', 1); + if (typeof fieldValues.field !== "undefined") { + $newSearch.find('select.type option[value="' + fieldValues.field + '"]').attr('selected', 1); } if (typeof fieldValues.op !== "undefined") { - $newSearch.find('select.op option[value="'+fieldValues.op+'"]').attr('selected', 1); + $newSearch.find('select.op option[value="' + fieldValues.op + '"]').attr('selected', 1); } // Insert it $("#group" + group + "Holder").before($newSearch); @@ -46,52 +46,52 @@ function addSearch(group, fieldValues) { $newSearch.find('.first-op').remove(); $newSearch.find('label').remove(); // Show x if we have more than one search inputs - $('#group'+group+' .search .close').removeClass('hidden'); + $('#group' + group + ' .search .close').removeClass('hidden'); } groupLength[group]++; } function deleteSearch(group, sindex) { - for(var i=sindex;i<groupLength[group]-1;i++) { - var $search0 = $('#search'+group+'_'+i); - var $search1 = $('#search'+group+'_'+(i+1)); + for (var i = sindex; i < groupLength[group] - 1; i++) { + var $search0 = $('#search' + group + '_' + i); + var $search1 = $('#search' + group + '_' + (i + 1)); $search0.find('input').val($search1.find('input').val()); var select0 = $search0.find('select')[0]; var select1 = $search1.find('select')[0]; select0.selectedIndex = select1.selectedIndex; } - if(groupLength[group] > 1) { + if (groupLength[group] > 1) { groupLength[group]--; - $('#search'+group+'_'+groupLength[group]).remove(); - if(groupLength[group] == 1) { - $('#group'+group+' .search .close').addClass('hidden'); // Hide x + $('#search' + group + '_' + groupLength[group]).remove(); + if (groupLength[group] == 1) { + $('#group' + group + ' .search .close').addClass('hidden'); // Hide x } } } function addGroup(firstTerm, firstField, join) { - if (firstTerm == undefined) {firstTerm = '';} - if (firstField == undefined) {firstField = '';} - if (join == undefined) {join = '';} + if (firstTerm == undefined) { firstTerm = ''; } + if (firstField == undefined) { firstField = ''; } + if (join == undefined) { join = ''; } var $newGroup = $($('#new_group_template').html()); - $newGroup.attr('id', 'group'+nextGroup); + $newGroup.attr('id', 'group' + nextGroup); $newGroup.find('.search_place_holder') - .attr('id', 'group'+nextGroup+'Holder') + .attr('id', 'group' + nextGroup + 'Holder') .removeClass('hidden'); $newGroup.find('.add_search_link') - .attr('id', 'add_search_link_'+nextGroup) - .attr('onClick', 'addSearch('+nextGroup+')') + .attr('id', 'add_search_link_' + nextGroup) + .attr('onClick', 'addSearch(' + nextGroup + ')') .removeClass('hidden'); $newGroup.find('.group-close') - .attr('onClick', 'deleteGroup('+nextGroup+')'); + .attr('onClick', 'deleteGroup(' + nextGroup + ')'); $newGroup.find('select.form-control') - .attr('id', 'search_bool'+nextGroup) - .attr('name', 'bool'+nextGroup+'[]'); + .attr('id', 'search_bool' + nextGroup) + .attr('name', 'bool' + nextGroup + '[]'); $newGroup.find('.search_bool') - .attr('for', 'search_bool'+nextGroup); - if(join.length > 0) { - $newGroup.find('option[value="'+join+'"]').attr('selected', 1); + .attr('for', 'search_bool' + nextGroup); + if (join.length > 0) { + $newGroup.find('option[value="' + join + '"]').attr('selected', 1); } // Insert $('#groupPlaceHolder').before($newGroup); @@ -99,7 +99,7 @@ function addGroup(firstTerm, firstField, join) { groupLength[nextGroup] = 0; addSearch(nextGroup, {term:firstTerm, field:firstField}); // Show join menu - if(nextGroup > 0) { + if (nextGroup > 0) { $('#groupJoin').removeClass('hidden'); // Show x $('.group .group-close').removeClass('hidden'); @@ -111,9 +111,9 @@ function deleteGroup(group) { // Find the group and remove it $("#group" + group).remove(); // If the last group was removed, add an empty group - if($('.group').length == 0) { + if ($('.group').length == 0) { addGroup(); - } else if($('#advSearchForm .group').length == 1) { + } else if ($('#advSearchForm .group').length == 1) { $('#groupJoin').addClass('hidden'); // Hide join menu $('.group .group-close').addClass('hidden'); // Hide x } diff --git a/themes/bootstrap3/js/autocomplete.js b/themes/bootstrap3/js/autocomplete.js index 43f84437b92..4c97afcbbc7 100644 --- a/themes/bootstrap3/js/autocomplete.js +++ b/themes/bootstrap3/js/autocomplete.js @@ -5,17 +5,17 @@ */ (function ( $ ) { var cache = {}, - element = false, - input = false, - options = { - ajaxDelay: 200, - cache: true, - hidingClass: 'hidden', - highlight: true, - loadingString: 'Loading...', - maxResults: 20, - minLength: 3 - }; + element = false, + input = false, + options = { + ajaxDelay: 200, + cache: true, + hidingClass: 'hidden', + highlight: true, + loadingString: 'Loading...', + maxResults: 20, + minLength: 3 + }; var xhr = false; @@ -52,9 +52,9 @@ // highlighting setup // escape term for regex - https://github.com/sindresorhus/escape-string-regexp/blob/master/index.js var escapedTerm = input.val().replace(/[|\\{}()\[\]\^$+*?.]/g, '\\$&'); - var regex = new RegExp('('+escapedTerm+')', 'ig'); + var regex = new RegExp('(' + escapedTerm + ')', 'ig'); var shell = $('<div/>'); - for (var i=0; i<data.length; i++) { + for (var i = 0; i < data.length; i++) { if (typeof data[i] === 'string') { data[i] = {value: data[i]}; } @@ -92,7 +92,7 @@ function search(input) { if (xhr) { xhr.abort(); } if (input.val().length >= options.minLength) { - element.html('<i class="item loading">'+options.loadingString+'</i>'); + element.html('<i class="item loading">' + options.loadingString + '</i>'); show(); align(input); var term = input.val(); @@ -123,7 +123,7 @@ if (typeof element === 'undefined') { element = $('<div/>') .addClass('autocomplete-results hidden') - .html('<i class="item loading">'+options.loadingString+'</i>'); + .html('<i class="item loading">' + options.loadingString + '</i>'); align(input); $(document.body).append(element); } @@ -132,7 +132,7 @@ input.data('length', 0); if (options.cache) { - var cid = Math.floor(Math.random()*1000); + var cid = Math.floor(Math.random() * 1000); input.data('cache-id', cid); cache[cid] = {}; } @@ -161,26 +161,26 @@ return; } switch (event.which) { - case 9: // tab - case 13: // enter - case 16: // shift - case 20: // caps lock - case 27: // esc - case 33: // page up - case 34: // page down - case 35: // end - case 36: // home - case 37: // arrows - case 38: - case 39: - case 40: - case 45: // insert - case 144: // num lock - case 145: // scroll lock - case 19: // pause/break - return; - default: - search(input, element); + case 9: // tab + case 13: // enter + case 16: // shift + case 20: // caps lock + case 27: // esc + case 33: // page up + case 34: // page down + case 35: // end + case 36: // home + case 37: // arrows + case 38: + case 39: + case 40: + case 45: // insert + case 144: // num lock + case 145: // scroll lock + case 19: // pause/break + return; + default: + search(input, element); } }); input.keydown(function(event) { @@ -191,45 +191,45 @@ var position = $(this).data('selected'); switch (event.which) { // arrow keys through items - case 38: // up key - event.preventDefault(); + case 38: // up key + event.preventDefault(); + element.find('.item.selected').removeClass('selected'); + if (position-- > 0) { + element.find('.item:eq(' + position + ')').addClass('selected'); + } + $(this).data('selected', position); + break; + case 40: // down key + event.preventDefault(); + if (element.hasClass(options.hidingClass)) { + search(input, element); + } else if (position < input.data('length') - 1) { + position++; element.find('.item.selected').removeClass('selected'); - if (position-- > 0) { - element.find('.item:eq('+position+')').addClass('selected'); - } + element.find('.item:eq(' + position + ')').addClass('selected'); $(this).data('selected', position); - break; - case 40: // down key + } + break; + // enter to nav or populate + case 9: + case 13: + var selected = element.find('.item.selected'); + if (selected.length > 0) { event.preventDefault(); - if (element.hasClass(options.hidingClass)) { - search(input, element); - } else if (position < input.data('length')-1) { - position++; + if (event.which === 13 && selected.attr('href')) { + window.location.assign(selected.attr('href')); + } else { + populate(selected.data(), $(this), {key: true}); element.find('.item.selected').removeClass('selected'); - element.find('.item:eq('+position+')').addClass('selected'); - $(this).data('selected', position); - } - break; - // enter to nav or populate - case 9: - case 13: - var selected = element.find('.item.selected'); - if (selected.length > 0) { - event.preventDefault(); - if (event.which === 13 && selected.attr('href')) { - window.location.assign(selected.attr('href')); - } else { - populate(selected.data(), $(this), {key: true}); - element.find('.item.selected').removeClass('selected'); - $(this).data('selected', -1); - } + $(this).data('selected', -1); } - break; + } + break; // hide on escape - case 27: - hide(); - $(this).data('selected', -1); - break; + case 27: + hide(); + $(this).data('selected', -1); + break; } }); diff --git a/themes/bootstrap3/js/cart.js b/themes/bootstrap3/js/cart.js index c79f58b1f30..52b4d839ab8 100644 --- a/themes/bootstrap3/js/cart.js +++ b/themes/bootstrap3/js/cart.js @@ -12,8 +12,8 @@ VuFind.register('cart', function() { var _uniqueArray = function(op) { var ret = []; - for(var i=0;i<op.length;i++) { - if(ret.indexOf(op[i]) < 0) { + for (var i = 0; i < op.length; i++) { + if (ret.indexOf(op[i]) < 0) { ret.push(op[i]); } } @@ -22,14 +22,14 @@ VuFind.register('cart', function() { var _getItems = function() { var items = Cookies.getItem(_COOKIE); - if(items) { + if (items) { return items.split(_COOKIE_DELIM); } return []; }; var _getSources = function() { var items = Cookies.getItem(_COOKIE_SOURCES); - if(items) { + if (items) { return items.split(_COOKIE_DELIM); } return []; @@ -38,11 +38,11 @@ VuFind.register('cart', function() { var items = _getItems(); var sources = _getSources(); var full = []; - if(items.length == 0) { + if (items.length == 0) { return []; } - for(var i=items.length;i--;) { - full[full.length] = sources[items[i].charCodeAt(0)-65]+'|'+items[i].substr(1); + for (var i = items.length; i--;) { + full[full.length] = sources[items[i].charCodeAt(0) - 65] + '|' + items[i].substr(1); } return full; }; @@ -53,19 +53,19 @@ VuFind.register('cart', function() { }; var addItem = function(id,source) { - if(!source) { + if (!source) { source = VuFind.defaultSearchBackend; } var cartItems = _getItems(); var cartSources = _getSources(); var sIndex = cartSources.indexOf(source); - if(sIndex < 0) { + if (sIndex < 0) { // Add source to source cookie - cartItems[cartItems.length] = String.fromCharCode(65+cartSources.length) + id; + cartItems[cartItems.length] = String.fromCharCode(65 + cartSources.length) + id; cartSources[cartSources.length] = source; Cookies.setItem(_COOKIE_SOURCES, cartSources.join(_COOKIE_DELIM), false, '/', _COOKIE_DOMAIN); } else { - cartItems[cartItems.length] = String.fromCharCode(65+sIndex) + id; + cartItems[cartItems.length] = String.fromCharCode(65 + sIndex) + id; } Cookies.setItem(_COOKIE, $.unique(cartItems).join(_COOKIE_DELIM), false, '/', _COOKIE_DOMAIN); updateCount(); @@ -75,34 +75,34 @@ VuFind.register('cart', function() { var cartItems = _getItems(); var cartSources = _getSources(); // Find - var cartIndex = cartItems.indexOf(String.fromCharCode(65+cartSources.indexOf(source))+id); - if(cartIndex > -1) { - var sourceIndex = cartItems[cartIndex].charCodeAt(0)-65; + var cartIndex = cartItems.indexOf(String.fromCharCode(65 + cartSources.indexOf(source)) + id); + if (cartIndex > -1) { + var sourceIndex = cartItems[cartIndex].charCodeAt(0) - 65; var cartItem = cartItems[cartIndex]; var saveSource = false; - for(var i=cartItems.length;i--;) { - if(i==cartIndex) { + for (var i = cartItems.length; i--;) { + if (i == cartIndex) { continue; } // If this source is shared by another, keep it - if(cartItems[i].charCodeAt(0)-65 == sourceIndex) { + if (cartItems[i].charCodeAt(0) - 65 == sourceIndex) { saveSource = true; break; } } cartItems.splice(cartIndex,1); // Remove unused sources - if(!saveSource) { + if (!saveSource) { var oldSources = cartSources.slice(0); cartSources.splice(sourceIndex,1); // Adjust source index characters - for(var j=cartItems.length;j--;) { - var si = cartItems[j].charCodeAt(0)-65; + for (var j = cartItems.length; j--;) { + var si = cartItems[j].charCodeAt(0) - 65; var ni = cartSources.indexOf(oldSources[si]); - cartItems[j] = String.fromCharCode(65+ni)+cartItems[j].substring(1); + cartItems[j] = String.fromCharCode(65 + ni) + cartItems[j].substring(1); } } - if(cartItems.length > 0) { + if (cartItems.length > 0) { Cookies.setItem(_COOKIE, _uniqueArray(cartItems).join(_COOKIE_DELIM), false, '/', _COOKIE_DOMAIN); Cookies.setItem(_COOKIE_SOURCES, _uniqueArray(cartSources).join(_COOKIE_DELIM), false, '/', _COOKIE_DOMAIN); } else { @@ -117,7 +117,7 @@ VuFind.register('cart', function() { var _cartNotificationTimeout = false; var _registerUpdate = function($form) { - if($form) { + if ($form) { $("#updateCart, #bottom_updateCart").unbind('click').click(function(){ var elId = this.id; var selectedBoxes = $("input[name='ids[]']:checked", $form); @@ -148,17 +148,17 @@ VuFind.register('cart', function() { if (updated.length >= VuFind.translate('bookbagMax')) { msg += "<br/>" + VuFind.translate('bookbagFull'); } - $('#'+elId).data('bs.popover').options.content = msg; + $('#' + elId).data('bs.popover').options.content = msg; $('#cartItems strong').html(updated.length); } else { - $('#'+elId).data('bs.popover').options.content = VuFind.translate('bulk_noitems_advice'); + $('#' + elId).data('bs.popover').options.content = VuFind.translate('bulk_noitems_advice'); } - $('#'+elId).popover('show'); + $('#' + elId).popover('show'); if (_cartNotificationTimeout !== false) { clearTimeout(_cartNotificationTimeout); } _cartNotificationTimeout = setTimeout(function() { - $('#'+elId).popover('hide'); + $('#' + elId).popover('hide'); }, 5000); return false; }); @@ -168,7 +168,7 @@ VuFind.register('cart', function() { var init = function() { // Record buttons var $cartId = $('.cartId'); - if($cartId.length > 0) { + if ($cartId.length > 0) { $cartId.each(function() { var cartId = this.value.split('|'); var currentId = cartId[1]; diff --git a/themes/bootstrap3/js/check_item_statuses.js b/themes/bootstrap3/js/check_item_statuses.js index 5b0da0b91a5..fd8ab281f9b 100644 --- a/themes/bootstrap3/js/check_item_statuses.js +++ b/themes/bootstrap3/js/check_item_statuses.js @@ -12,7 +12,7 @@ function checkItemStatuses(container) { } var datum = $(record).find('.hiddenId').val(); if (typeof elements[datum] === 'undefined') { - elements[datum] = $(); + elements[datum] = $(); } elements[datum] = elements[datum].add($(record)); return datum; @@ -58,7 +58,7 @@ function checkItemStatuses(container) { item.find('.hideIfDetailed').addClass('hidden'); item.find('.location').addClass('hidden'); var locationListHTML = ""; - for (var x=0; x<result.locationList.length; x++) { + for (var x = 0; x < result.locationList.length; x++) { locationListHTML += '<div class="groupLocation">'; if (result.locationList[x].availability) { locationListHTML += '<i class="fa fa-ok text-success" aria-hidden="true"></i> <span class="text-success">' @@ -77,14 +77,14 @@ function checkItemStatuses(container) { locationListHTML += '</div>'; locationListHTML += '<div class="groupCallnumber">'; locationListHTML += (result.locationList[x].callnumbers) - ? result.locationList[x].callnumbers : ''; + ? result.locationList[x].callnumbers : ''; locationListHTML += '</div>'; } item.find('.locationDetails').removeClass('hidden'); item.find('.locationDetails').empty().append(locationListHTML); } else { // Default case -- load call number and location into appropriate containers: - item.find('.callnumber').empty().append(result.callnumber+'<br/>'); + item.find('.callnumber').empty().append(result.callnumber + '<br/>'); item.find('.location').empty().append( result.reserve == 'true' ? result.reserve_message diff --git a/themes/bootstrap3/js/check_save_statuses.js b/themes/bootstrap3/js/check_save_statuses.js index bc6dbf878de..7e663d16d86 100644 --- a/themes/bootstrap3/js/check_save_statuses.js +++ b/themes/bootstrap3/js/check_save_statuses.js @@ -14,7 +14,7 @@ function checkSaveStatuses(container) { return null; } var datum = {'id':$(record).find('.hiddenId').val(), 'source':$(record).find('.hiddenSource')[0].value}; - var key = datum.source+'|'+datum.id; + var key = datum.source + '|' + datum.id; if (typeof elements[key] === 'undefined') { elements[key] = $(); } @@ -40,8 +40,8 @@ function checkSaveStatuses(container) { if (!list) { list = $('.savedLists'); } - var html = list.find('strong')[0].outerHTML+'<ul>'; - for (var i=0; i<response.data[sel].length; i++) { + var html = list.find('strong')[0].outerHTML + '<ul>'; + for (var i = 0; i < response.data[sel].length; i++) { html += '<li><a href="' + response.data[sel][i].list_url + '">' + htmlEncode(response.data[sel][i].list_title) + '</a></li>'; } diff --git a/themes/bootstrap3/js/collection_record.js b/themes/bootstrap3/js/collection_record.js index 9574b6f9c7b..a953842acd4 100644 --- a/themes/bootstrap3/js/collection_record.js +++ b/themes/bootstrap3/js/collection_record.js @@ -5,7 +5,7 @@ function toggleCollectionInfo() { function showMoreInfoToggle() { // no rows in table? don't bother! if ($("#collectionInfo").find('tr').length < 1) { - return; + return; } toggleCollectionInfo(); $("#moreInfoToggle").removeClass('hidden'); diff --git a/themes/bootstrap3/js/common.js b/themes/bootstrap3/js/common.js index ea537828641..1ed03ead223 100644 --- a/themes/bootstrap3/js/common.js +++ b/themes/bootstrap3/js/common.js @@ -21,7 +21,7 @@ var VuFind = (function() { } }; var init = function() { - for (var i=0; i<_submodules.length; i++) { + for (var i = 0; i < _submodules.length; i++) { if (this[_submodules[i]].init) { this[_submodules[i]].init(); } @@ -65,7 +65,7 @@ function extractClassParams(str) { } var params = {}; var classes = str.split(/\s+/); - for(var i = 0; i < classes.length; i++) { + for (var i = 0; i < classes.length; i++) { if (classes[i].indexOf(':') > 0) { var pair = classes[i].split(':'); params[pair[0]] = pair[1]; @@ -75,7 +75,7 @@ function extractClassParams(str) { } // Turn GET string into array function deparam(url) { - if(!url.match(/\?|&/)) { + if (!url.match(/\?|&/)) { return []; } var request = {}; @@ -83,12 +83,12 @@ function deparam(url) { for (var i = 0; i < pairs.length; i++) { var pair = pairs[i].split('='); var name = decodeURIComponent(pair[0].replace(/\+/g, ' ')); - if(name.length == 0) { + if (name.length == 0) { continue; } - if(name.substring(name.length-2) == '[]') { - name = name.substring(0,name.length-2); - if(!request[name]) { + if (name.substring(name.length - 2) == '[]') { + name = name.substring(0,name.length - 2); + if (!request[name]) { request[name] = []; } request[name].push(decodeURIComponent(pair[1].replace(/\+/g, ' '))); @@ -101,13 +101,13 @@ function deparam(url) { // Sidebar function moreFacets(id) { - $('.'+id).removeClass('hidden'); - $('#more-'+id).addClass('hidden'); + $('.' + id).removeClass('hidden'); + $('#more-' + id).addClass('hidden'); return false; } function lessFacets(id) { - $('.'+id).addClass('hidden'); - $('#more-'+id).removeClass('hidden'); + $('.' + id).addClass('hidden'); + $('#more-' + id).removeClass('hidden'); return false; } @@ -116,8 +116,8 @@ function phoneNumberFormHandler(numID, regionCode) { var phoneInput = document.getElementById(numID); var number = phoneInput.value; var valid = isPhoneNumberValid(number, regionCode); - if(valid != true) { - if(typeof valid === 'string') { + if (valid != true) { + if (typeof valid === 'string') { valid = VuFind.translate(valid); } else { valid = VuFind.translate('libphonenumber_invalid'); @@ -146,12 +146,12 @@ function bulkFormHandler(event, data) { // Ready functions function setupOffcanvas() { - if($('.sidebar').length > 0) { + if ($('.sidebar').length > 0) { $('[data-toggle="offcanvas"]').click(function () { $('body.offcanvas').toggleClass('active'); var active = $('body.offcanvas').hasClass('active'); var right = $('body.offcanvas').hasClass('offcanvas-right'); - if((active && !right) || (!active && right)) { + if ((active && !right) || (!active && right)) { $('.offcanvas-toggle .fa').removeClass('fa-chevron-right').addClass('fa-chevron-left'); } else { $('.offcanvas-toggle .fa').removeClass('fa-chevron-left').addClass('fa-chevron-right'); @@ -169,7 +169,7 @@ function setupAutocomplete() { $('.autocomplete').each(function(i, op) { $(op).autocomplete({ maxResults: 10, - loadingString: VuFind.translate('loading')+'...', + loadingString: VuFind.translate('loading') + '...', handler: function(input, cb) { var query = input.val(); var searcher = extractClassParams(input); @@ -190,7 +190,7 @@ function setupAutocomplete() { success: function(json) { if (json.data.length > 0) { var datums = []; - for (var i=0;i<json.data.length;i++) { + for (var i = 0; i < json.data.length; i++) { datums.push(json.data[i]); } cb(datums); @@ -214,41 +214,41 @@ function setupAutocomplete() { * @returns {undefined} */ function keyboardShortcuts() { - var $searchform = $('.searchForm_lookfor'); - if ($('.pager').length > 0) { - $(window).keydown(function(e) { - if (!$searchform.is(':focus')) { - var $target = null; - switch (e.keyCode) { - case 37: // left arrow key - $target = $('.pager').find('a.previous'); - if ($target.length > 0) { - $target[0].click(); - return; - } - break; - case 38: // up arrow key - if (e.ctrlKey) { - $target = $('.pager').find('a.backtosearch'); - if ($target.length > 0) { - $target[0].click(); - return; - } - } - break; - case 39: //right arrow key - $target = $('.pager').find('a.next'); - if ($target.length > 0) { - $target[0].click(); - return; - } - break; - case 40: // down arrow key - break; + var $searchform = $('.searchForm_lookfor'); + if ($('.pager').length > 0) { + $(window).keydown(function(e) { + if (!$searchform.is(':focus')) { + var $target = null; + switch (e.keyCode) { + case 37: // left arrow key + $target = $('.pager').find('a.previous'); + if ($target.length > 0) { + $target[0].click(); + return; + } + break; + case 38: // up arrow key + if (e.ctrlKey) { + $target = $('.pager').find('a.backtosearch'); + if ($target.length > 0) { + $target[0].click(); + return; } } - }); - } + break; + case 39: //right arrow key + $target = $('.pager').find('a.next'); + if ($target.length > 0) { + $target[0].click(); + return; + } + break; + case 40: // down arrow key + break; + } + } + }); + } } $(document).ready(function() { @@ -292,7 +292,7 @@ $(document).ready(function() { // Print var url = window.location.href; - if(url.indexOf('?' + 'print' + '=') != -1 || url.indexOf('&' + 'print' + '=') != -1) { + if (url.indexOf('?' + 'print' + '=') != -1 || url.indexOf('&' + 'print' + '=') != -1) { $("link[media='print']").attr("media", "all"); $(document).ajaxStop(function() { window.print(); @@ -303,7 +303,7 @@ $(document).ready(function() { // Advanced facets $('.facetOR').click(function() { - $(this).closest('.collapse').html('<div class="list-group-item">'+VuFind.translate('loading')+'...</div>'); + $(this).closest('.collapse').html('<div class="list-group-item">' + VuFind.translate('loading') + '...</div>'); window.location.assign($(this).attr('href')); }); }); diff --git a/themes/bootstrap3/js/facets.js b/themes/bootstrap3/js/facets.js index 3a878564f65..89874b8c1c3 100644 --- a/themes/bootstrap3/js/facets.js +++ b/themes/bootstrap3/js/facets.js @@ -11,7 +11,7 @@ function buildFacetNodes(data, currentPath, allowExclude, excludeTitle, counts) var excludeURL = currentPath + this.exclude; excludeURL.replace("'", "\\'"); // Just to be safe - html += ' <a href="' + excludeURL + '" onclick="document.location.href=\'' + excludeURL + '\'; return false;" title="' + htmlEncode(excludeTitle) + '"><i class="fa fa-times" title="'+VuFind.translate('Selected')+'"></i></a>'; + html += ' <a href="' + excludeURL + '" onclick="document.location.href=\'' + excludeURL + '\'; return false;" title="' + htmlEncode(excludeTitle) + '"><i class="fa fa-times" title="' + VuFind.translate('Selected') + '"></i></a>'; } html += '</span>'; } @@ -23,12 +23,12 @@ function buildFacetNodes(data, currentPath, allowExclude, excludeTitle, counts) + ' onclick="document.location.href=\'' + url + '\'; return false;">'; if (this.operator == 'OR') { if (this.isApplied) { - html += '<i class="fa fa-check-square-o" title="'+VuFind.translate('Selected')+'"></i>'; + html += '<i class="fa fa-check-square-o" title="' + VuFind.translate('Selected') + '"></i>'; } else { html += '<i class="fa fa-square-o" aria-hidden="true"></i>'; } } else if (this.isApplied) { - html += '<i class="fa fa-check pull-right" title="'+VuFind.translate('Selected')+'"></i>'; + html += '<i class="fa fa-check pull-right" title="' + VuFind.translate('Selected') + '"></i>'; } html += ' ' + this.displayText; html += '</span>'; @@ -106,12 +106,12 @@ VuFind.register('lightbox_facets', function LightboxFacets() { var sortButtons = $('.js-facet-sort'); var lastsort, lastlimit; function sortAjax(sort) { - var list = $('#facet-list-'+sort); + var list = $('#facet-list-' + sort); if (list.find('.js-facet-item').length === 0) { - list.find('.js-facet-next-page').text(VuFind.translate('loading')+'...'); - $.ajax(ajaxUrl + '&layout=lightbox&facetsort='+sort) + list.find('.js-facet-next-page').text(VuFind.translate('loading') + '...'); + $.ajax(ajaxUrl + '&layout=lightbox&facetsort=' + sort) .done(function facetSortTitleDone(data) { - list.prepend($('<span>'+data+'</span>').find('.js-facet-item')); + list.prepend($('<span>' + data + '</span>').find('.js-facet-item')); list.find('.js-facet-next-page').text(VuFind.translate('more') + ' ...'); }); } @@ -136,10 +136,10 @@ VuFind.register('lightbox_facets', function LightboxFacets() { return false; } button.attr('disabled', 1); - button.text(VuFind.translate('loading')+'...'); - $.ajax(ajaxUrl + '&layout=lightbox&facetpage='+page+'&facetsort='+this.dataset.sort) + button.text(VuFind.translate('loading') + '...'); + $.ajax(ajaxUrl + '&layout=lightbox&facetpage=' + page + '&facetsort=' + this.dataset.sort) .done(function facetLightboxMoreDone(data) { - var htmlDiv = $('<div>'+data+'</div>'); + var htmlDiv = $('<div>' + data + '</div>'); var list = htmlDiv.find('.js-facet-item'); button.before(list); if (list.length && htmlDiv.find('.js-facet-next-page').length) { diff --git a/themes/bootstrap3/js/hierarchyTree.js b/themes/bootstrap3/js/hierarchyTree.js index 3c228b4f896..5cb07e6910c 100644 --- a/themes/bootstrap3/js/hierarchyTree.js +++ b/themes/bootstrap3/js/hierarchyTree.js @@ -34,7 +34,7 @@ function getRecord(recordID) { // Remove the old path highlighting $('#hierarchyTree a').removeClass("jstree-highlight"); // Add Current path highlighting - var jsTreeNode = $(":input[value='"+recordID+"']").parent(); + var jsTreeNode = $(":input[value='" + recordID + "']").parent(); jsTreeNode.children("a").addClass("jstree-highlight"); jsTreeNode.parents("li").children("a").addClass("jstree-highlight"); }); @@ -61,14 +61,14 @@ function doTreeSearch() { $('#treeSearchLoadingImg').removeClass('hidden'); var keyword = $("#treeSearchText").val(); var type = $("#treeSearchType").val(); - if(keyword.length == 0) { + if (keyword.length == 0) { $('#hierarchyTree').find('.jstree-search').removeClass('jstree-search'); var tree = $('#hierarchyTree').jstree(true); tree.close_all(); tree._open_to(htmlID); $('#treeSearchLoadingImg').addClass('hidden'); } else { - if(searchAjax) { + if (searchAjax) { searchAjax.abort(); } searchAjax = $.ajax({ @@ -79,17 +79,17 @@ function doTreeSearch() { }) + "&format=true" }) .done(function(data) { - if(data.results.length > 0) { + if (data.results.length > 0) { $('#hierarchyTree').find('.jstree-search').removeClass('jstree-search'); var tree = $('#hierarchyTree').jstree(true); tree.close_all(); - for(var i=data.results.length;i--;) { + for (var i = data.results.length; i--;) { var id = htmlEncodeId(data.results[i]); tree._open_to(id); } - for(i=data.results.length;i--;) { + for (i = data.results.length; i--;) { var tid = htmlEncodeId(data.results[i]); - $('#hierarchyTree').find('#'+tid).addClass('jstree-search'); + $('#hierarchyTree').find('#' + tid).addClass('jstree-search'); } changeNoResultLabel(false); changeLimitReachedLabel(data.limitReached); @@ -221,7 +221,7 @@ $(document).ready(function() { $('#treeSearch [type=submit]').click(doTreeSearch); $('#treeSearchText').keyup(function (e) { var code = (e.keyCode ? e.keyCode : e.which); - if(code == 13 || $(this).val().length == 0) { + if (code == 13 || $(this).val().length == 0) { doTreeSearch(); } }); diff --git a/themes/bootstrap3/js/hold.js b/themes/bootstrap3/js/hold.js index 8e9b8594813..1df01fcef9e 100644 --- a/themes/bootstrap3/js/hold.js +++ b/themes/bootstrap3/js/hold.js @@ -4,8 +4,8 @@ function setUpHoldRequestForm(recordId) { var $emptyOption = $("#pickUpLocation option[value='']"); $("#pickUpLocation option[value!='']").remove(); if ($('#requestGroupId').val() === '') { - $('#pickUpLocation').attr('disabled', 'disabled'); - return; + $('#pickUpLocation').attr('disabled', 'disabled'); + return; } $('#pickUpLocationLabel i').addClass("fa fa-spinner icon-spin"); var params = { diff --git a/themes/bootstrap3/js/lightbox.js b/themes/bootstrap3/js/lightbox.js index fa6590564da..24d282b9f58 100644 --- a/themes/bootstrap3/js/lightbox.js +++ b/themes/bootstrap3/js/lightbox.js @@ -31,7 +31,7 @@ VuFind.register('lightbox', function() { // Fallback to document.createEvent() if creating a new CustomEvent fails (e.g. IE 11) var event; try { - event = new CustomEvent(msg, { + event = new CustomEvent(msg, { detail: details, bubbles: true, cancelable: true @@ -63,14 +63,14 @@ VuFind.register('lightbox', function() { if ('undefined' == typeof type) { type = 'info'; } - _html('<div class="flash-message alert alert-'+type+'">'+message+'</div>' + _html('<div class="flash-message alert alert-' + type + '">' + message + '</div>' + '<button class="btn btn-default" data-dismiss="modal">' + VuFind.translate('close') + '</button>'); _modal.modal('show'); }; var flashMessage = function(message, type) { _modalBody.find('.flash-message,.fa.fa-spinner').remove(); _modalBody.find('h2:first-of-type') - .after('<div class="flash-message alert alert-'+type+'">'+message+'</div>'); + .after('<div class="flash-message alert alert-' + type + '">' + message + '</div>'); }; /** @@ -106,7 +106,7 @@ VuFind.register('lightbox', function() { _modalBody.find('[type=submit]').click(_storeClickedStatus); var forms = _modalBody.find('form:not([data-lightbox-ignore])'); - for (var i=0;i<forms.length;i++) { + for (var i = 0; i < forms.length; i++) { $(forms[i]).on('submit', _formSubmit); } // Select all checkboxes @@ -131,10 +131,10 @@ VuFind.register('lightbox', function() { if (!obj.url.match(/layout=lightbox/)) { var parts = obj.url.split('#'); obj.url = parts[0].indexOf('?') < 0 - ? parts[0]+'?' - : parts[0]+'&'; - obj.url += 'layout=lightbox&lbreferer='+encodeURIComponent(_currentUrl); - obj.url += parts.length < 2 ? '' : '#'+parts[1]; + ? parts[0] + '?' + : parts[0] + '&'; + obj.url += 'layout=lightbox&lbreferer=' + encodeURIComponent(_currentUrl); + obj.url += parts.length < 2 ? '' : '#' + parts[1]; } _xhr = $.ajax(obj); _xhr.always(function() { _xhr = false; }) @@ -209,7 +209,7 @@ VuFind.register('lightbox', function() { if (this.href.length > 1) { event.preventDefault(); var obj = {url: $(this).data('lightboxHref') || this.href}; - if("string" === typeof $(this).data('lightboxPost')) { + if ("string" === typeof $(this).data('lightboxPost')) { obj.type = 'POST'; obj.data = $(this).data('lightboxPost'); } @@ -268,7 +268,7 @@ VuFind.register('lightbox', function() { }, false); } // Loading - _modalBody.prepend('<i class="fa fa-spinner fa-spin pull-right" title="'+VuFind.translate('loading')+'"></i>'); + _modalBody.prepend('<i class="fa fa-spinner fa-spin pull-right" title="' + VuFind.translate('loading') + '"></i>'); // Prevent multiple submission of submit button in lightbox if (submit.closest(_modal).length > 0) { submit.attr('disabled', 'disabled'); diff --git a/themes/bootstrap3/js/preview.js b/themes/bootstrap3/js/preview.js index 513ec2667a8..74a21a7373e 100644 --- a/themes/bootstrap3/js/preview.js +++ b/themes/bootstrap3/js/preview.js @@ -1,96 +1,96 @@ // functions to get rights codes for previews function getHathiOptions() { - return $('[class*="hathiPreviewSpan"]').attr("class").split('__')[1].split(','); + return $('[class*="hathiPreviewSpan"]').attr("class").split('__')[1].split(','); } function getGoogleOptions() { - var opts_temp = $('[class*="googlePreviewSpan"]').attr("class").split('__')[1].split(';'); - var options = {}; - for(var key in opts_temp) { - var arr = opts_temp[key].split(':'); - options[arr[0]] = arr[1].split(','); - } - return options; + var opts_temp = $('[class*="googlePreviewSpan"]').attr("class").split('__')[1].split(';'); + var options = {}; + for (var key in opts_temp) { + var arr = opts_temp[key].split(':'); + options[arr[0]] = arr[1].split(','); + } + return options; } function getOLOptions() { - return $('[class*="olPreviewSpan"]').attr("class").split('__')[1].split(','); + return $('[class*="olPreviewSpan"]').attr("class").split('__')[1].split(','); } function getHTPreviews(skeys) { - skeys = skeys.replace(/(ISBN|LCCN|OCLC)/gi, '$1:').toLowerCase(); - var bibkeys = skeys.split(/\s+/); + skeys = skeys.replace(/(ISBN|LCCN|OCLC)/gi, '$1:').toLowerCase(); + var bibkeys = skeys.split(/\s+/); // fetch 20 books at time if there are more than 20 // since hathitrust only allows 20 at a time // as per https://vufind.org/jira/browse/VUFIND-317 - var batch = []; - for(var i = 0; i < bibkeys.length; i++) { - batch.push(bibkeys[i]); - if ((i > 0 && i % 20 == 0) || i == bibkeys.length-1) { - var script = 'https://catalog.hathitrust.org/api/volumes/brief/json/' + var batch = []; + for (var i = 0; i < bibkeys.length; i++) { + batch.push(bibkeys[i]); + if ((i > 0 && i % 20 == 0) || i == bibkeys.length - 1) { + var script = 'https://catalog.hathitrust.org/api/volumes/brief/json/' + batch.join('|') + '&callback=processHTBookInfo'; - $.getScript(script); - batch = []; - } + $.getScript(script); + batch = []; } + } } function applyPreviewUrl($link, url) { // Update the preview button: - $link.attr('href', url).removeClass('hidden'); + $link.attr('href', url).removeClass('hidden'); // Update associated record thumbnail, if any: - $link.parents('.result,.record') + $link.parents('.result,.record') .find('.recordcover').parents('a').attr('href', url); } function processBookInfo(booksInfo, previewClass, viewOptions) { - for (var bibkey in booksInfo) { - var bookInfo = booksInfo[bibkey]; - if (bookInfo) { - if (viewOptions.indexOf(bookInfo.preview)>= 0) { - applyPreviewUrl( + for (var bibkey in booksInfo) { + var bookInfo = booksInfo[bibkey]; + if (bookInfo) { + if (viewOptions.indexOf(bookInfo.preview) >= 0) { + applyPreviewUrl( $('.' + previewClass + '.' + bibkey), bookInfo.preview_url ); - } - } + } } + } } function processGBSBookInfo(booksInfo) { - var viewOptions = getGoogleOptions(); - if (viewOptions['link'] && viewOptions['link'].length > 0) { - processBookInfo(booksInfo, 'previewGBS', viewOptions['link']); - } - if (viewOptions['tab'] && viewOptions['tab'].length > 0) { + var viewOptions = getGoogleOptions(); + if (viewOptions['link'] && viewOptions['link'].length > 0) { + processBookInfo(booksInfo, 'previewGBS', viewOptions['link']); + } + if (viewOptions['tab'] && viewOptions['tab'].length > 0) { // check for "embeddable: true" in bookinfo - for (var bibkey in booksInfo) { - var bookInfo = booksInfo[bibkey]; - if (bookInfo) { - if (viewOptions['tab'].indexOf(bookInfo.preview)>= 0 + for (var bibkey in booksInfo) { + var bookInfo = booksInfo[bibkey]; + if (bookInfo) { + if (viewOptions['tab'].indexOf(bookInfo.preview) >= 0 && (bookInfo.embeddable)) { // make tab visible - $('ul.nav-tabs li.hidden a.preview').parent().removeClass('hidden'); - } - } + $('ul.nav-tabs li.hidden a.preview').parent().removeClass('hidden'); } + } } + } } function processOLBookInfo(booksInfo) { - processBookInfo(booksInfo, 'previewOL', getOLOptions()); + processBookInfo(booksInfo, 'previewOL', getOLOptions()); } function processHTBookInfo(booksInfo) { - for (var b in booksInfo) { - var bibkey = b.replace(/:/, '').toUpperCase(); - var $link = $('.previewHT.' + bibkey); - var items = booksInfo[b].items; - for (var i = 0; i < items.length; i++) { + for (var b in booksInfo) { + var bibkey = b.replace(/:/, '').toUpperCase(); + var $link = $('.previewHT.' + bibkey); + var items = booksInfo[b].items; + for (var i = 0; i < items.length; i++) { // check if items possess an eligible rights code - if (getHathiOptions().indexOf(items[i].rightsCode) >= 0) { - applyPreviewUrl($link, items[i].itemURL); - } - } + if (getHathiOptions().indexOf(items[i].rightsCode) >= 0) { + applyPreviewUrl($link, items[i].itemURL); + } } + } } /** @@ -100,94 +100,94 @@ function processHTBookInfo(booksInfo) { * developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/indexOf */ function setIndexOf() { - Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) { - "use strict"; - if (this == null) { - throw new TypeError(); - } - var t = Object(this); + Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) { + "use strict"; + if (this == null) { + throw new TypeError(); + } + var t = Object(this); /*jslint bitwise: false*/ - var len = t.length >>> 0; + var len = t.length >>> 0; /*jslint bitwise: true*/ - if (len === 0) { - return -1; - } - var n = 0; - if (arguments.length > 1) { - n = Number(arguments[1]); - if (n != n) { // shortcut for verifying if it's NaN - n = 0; - } else if (n != 0 && n != Infinity && n != -Infinity) { - n = (n > 0 || -1) * Math.floor(Math.abs(n)); - } - } - if (n >= len) { - return -1; - } - var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0); - for (; k < len; k++) { - if (k in t && t[k] === searchElement) { - return k; - } - } - return -1; - }; + if (len === 0) { + return -1; + } + var n = 0; + if (arguments.length > 1) { + n = Number(arguments[1]); + if (n != n) { // shortcut for verifying if it's NaN + n = 0; + } else if (n != 0 && n != Infinity && n != -Infinity) { + n = (n > 0 || -1) * Math.floor(Math.abs(n)); + } + } + if (n >= len) { + return -1; + } + var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0); + for (; k < len; k++) { + if (k in t && t[k] === searchElement) { + return k; + } + } + return -1; + }; } function getBibKeyString() { - var skeys = ''; - $('.previewBibkeys').each(function(){ - skeys += $(this).attr('class'); - }); - return skeys.replace(/previewBibkeys/g, '').replace(/^\s+|\s+$/g, ''); + var skeys = ''; + $('.previewBibkeys').each(function(){ + skeys += $(this).attr('class'); + }); + return skeys.replace(/previewBibkeys/g, '').replace(/^\s+|\s+$/g, ''); } function getBookPreviews() { - var skeys = getBibKeyString(); - var bibkeys = skeys.split(/\s+/); - var script; + var skeys = getBibKeyString(); + var bibkeys = skeys.split(/\s+/); + var script; // fetch Google preview if enabled - if ($('[class*="googlePreviewSpan"]').length > 0) { + if ($('[class*="googlePreviewSpan"]').length > 0) { // checks if query string might break URI limit - if not, run as normal - if (bibkeys.length <= 150){ - script = 'https://encrypted.google.com/books?jscmd=viewapi&bibkeys=' + if (bibkeys.length <= 150){ + script = 'https://encrypted.google.com/books?jscmd=viewapi&bibkeys=' + bibkeys.join(',') + '&callback=processGBSBookInfo'; - $.getScript(script); - } else { + $.getScript(script); + } else { // if so, break request into chunks of 100 - var keyString = ''; + var keyString = ''; // loop through array - for (var i=0; i < bibkeys.length; i++){ - keyString += bibkeys[i] + ','; + for (var i = 0; i < bibkeys.length; i++){ + keyString += bibkeys[i] + ','; // send request when there are 100 requests ready or when there are no // more elements to be sent - if ((i > 0 && i % 100 == 0) || i == bibkeys.length-1) { - script = 'https://encrypted.google.com/books?jscmd=viewapi&bibkeys=' + if ((i > 0 && i % 100 == 0) || i == bibkeys.length - 1) { + script = 'https://encrypted.google.com/books?jscmd=viewapi&bibkeys=' + keyString + '&callback=processGBSBookInfo'; - $.getScript(script); - keyString = ''; - } - } + $.getScript(script); + keyString = ''; } + } } + } // fetch OpenLibrary preview if enabled - if ($('[class*="olPreviewSpan"]').length > 0) { - script = '//openlibrary.org/api/books?bibkeys=' + if ($('[class*="olPreviewSpan"]').length > 0) { + script = '//openlibrary.org/api/books?bibkeys=' + bibkeys.join(',') + '&callback=processOLBookInfo'; - $.getScript(script); - } + $.getScript(script); + } // fetch HathiTrust preview if enabled - if ($('[class*="hathiPreviewSpan"]').length > 0) { - getHTPreviews(skeys); - } + if ($('[class*="hathiPreviewSpan"]').length > 0) { + getHTPreviews(skeys); + } } $(document).ready(function() { - if (!Array.prototype.indexOf) { - setIndexOf(); - } - getBookPreviews(); + if (!Array.prototype.indexOf) { + setIndexOf(); + } + getBookPreviews(); }); diff --git a/themes/bootstrap3/js/pubdate_vis.js b/themes/bootstrap3/js/pubdate_vis.js index b75ca010120..c7d3ff5fa86 100644 --- a/themes/bootstrap3/js/pubdate_vis.js +++ b/themes/bootstrap3/js/pubdate_vis.js @@ -2,13 +2,13 @@ function PadDigits(n, totalDigits) { if (n <= 0){ - n= 1; + n = 1; } n = n.toString(); var pd = ''; if (totalDigits > n.length) { - for (var i=0; i < (totalDigits-n.length); i++) + for (var i = 0; i < (totalDigits - n.length); i++) { pd += '0'; } @@ -25,10 +25,10 @@ function loadVis(facetFields, searchParams, baseURL, zooming) { 'outline-color': '#c38835' // selection color }; var $dateVisColorSettings = $('#dateVisColorSettings'); - for(var rule in cssColorSettings) { - if($dateVisColorSettings.css(rule)) { + for (var rule in cssColorSettings) { + if ($dateVisColorSettings.css(rule)) { var match = $dateVisColorSettings.css(rule).match(/rgb[a]?\([^\)]+\)|#[a-fA-F0-9]+/); - if(null != match) { + if (null != match) { cssColorSettings[rule] = match[0]; } } @@ -68,7 +68,7 @@ function loadVis(facetFields, searchParams, baseURL, zooming) { var hasFilter = true; //set the has filter - if (val['min'] == 0 && val['max']== 0) { + if (val['min'] == 0 && val['max'] == 0) { hasFilter = false; } @@ -76,8 +76,8 @@ function loadVis(facetFields, searchParams, baseURL, zooming) { if (val['min'] == 0) { val['min'] = val['data'][0][0] - 5; } - if (val['max']== 0) { - val['max'] = parseInt(val['data'][val['data'].length - 1][0], 10) + 5; + if (val['max'] == 0) { + val['max'] = parseInt(val['data'][val['data'].length - 1][0], 10) + 5; } if (zooming) { @@ -90,8 +90,8 @@ function loadVis(facetFields, searchParams, baseURL, zooming) { val['data'].push([val['min'] - 5, -1]); } //check for values outside the selected range and remove them by setting them to null - for (var i=0; i<val['data'].length; i++) { - if (val['data'][i][0] < val['min'] -5 || val['data'][i][0] > parseInt(val['max'], 10) + 5) { + for (var i = 0; i < val['data'].length; i++) { + if (val['data'][i][0] < val['min'] - 5 || val['data'][i][0] > parseInt(val['max'], 10) + 5) { //remove this val['data'].splice(i,1); i--; diff --git a/themes/bootstrap3/js/record.js b/themes/bootstrap3/js/record.js index 5f2c2dd4f48..f8e9cdb734a 100644 --- a/themes/bootstrap3/js/record.js +++ b/themes/bootstrap3/js/record.js @@ -18,7 +18,7 @@ function checkRequestIsValid(element, requestType) { if (response.data.status) { $(element).removeClass('disabled') .attr('title', response.data.msg) - .html('<i class="fa fa-flag" aria-hidden="true"></i> '+response.data.msg); + .html('<i class="fa fa-flag" aria-hidden="true"></i> ' + response.data.msg); } else { $(element).remove(); } @@ -115,7 +115,7 @@ function registerTabEvents() { // Logged in AJAX registerAjaxCommentRecord(); // Delete links - $('.delete').click(function(){deleteRecordComment(this, $('.hiddenId').val(), $('.hiddenSource').val(), this.id.substr(13));return false;}); + $('.delete').click(function(){ deleteRecordComment(this, $('.hiddenId').val(), $('.hiddenSource').val(), this.id.substr(13)); return false; }); setUpCheckRequest(); @@ -148,7 +148,7 @@ function ajaxLoadTab($newTab, tabid, setHash) { .done(function(data) { $newTab.html(data); registerTabEvents(); - if(typeof syn_get_widget === "function") { + if (typeof syn_get_widget === "function") { syn_get_widget(); } if (typeof setHash == 'undefined' || setHash) { @@ -175,7 +175,7 @@ function refreshTagList(target, loggedin) { .done(function(response) { $tagList.empty(); $tagList.replaceWith(response); - if(loggedin) { + if (loggedin) { $tagList.addClass('loggedin'); } else { $tagList.removeClass('loggedin'); @@ -185,10 +185,10 @@ function refreshTagList(target, loggedin) { } function ajaxTagUpdate(link, tag, remove) { - if(typeof link === "undefined") { + if (typeof link === "undefined") { link = document; } - if(typeof remove === "undefined") { + if (typeof remove === "undefined") { remove = false; } var $target = $(link).closest('.record'); @@ -198,7 +198,7 @@ function ajaxTagUpdate(link, tag, remove) { url:VuFind.path + '/AJAX/JSON?method=tagRecord', method:'POST', data:{ - tag:'"'+tag.replace(/\+/g, ' ')+'"', + tag:'"' + tag.replace(/\+/g, ' ') + '"', id:recordId, source:recordSource, remove:remove @@ -219,7 +219,7 @@ function applyRecordTabHash() { if (newTab.length == 0 || newTab == '#tabnav') { $initiallyActiveTab.click(); } else if (newTab.length > 0 && '#' + activeTab != newTab) { - $('.'+newTab.substr(1)).click(); + $('.' + newTab.substr(1)).click(); } } @@ -241,7 +241,7 @@ function recordDocReady() { if ($li.hasClass('initiallyActive')) { $(this).tab('show'); $top.find('.tab-pane.active').removeClass('active'); - $top.find('.'+tabid+'-tab').addClass('active'); + $top.find('.' + tabid + '-tab').addClass('active'); window.location.hash = 'tabnav'; return false; } @@ -250,12 +250,12 @@ function recordDocReady() { } $top.find('.tab-pane.active').removeClass('active'); $(this).tab('show'); - if ($top.find('.'+tabid+'-tab').length > 0) { - $top.find('.'+tabid+'-tab').addClass('active'); + if ($top.find('.' + tabid + '-tab').length > 0) { + $top.find('.' + tabid + '-tab').addClass('active'); window.location.hash = tabid; return false; } else { - var newTab = $('<div class="tab-pane active '+tabid+'-tab"><i class="fa fa-spinner fa-spin" aria-hidden="true"></i> '+VuFind.translate('loading')+'...</div>'); + var newTab = $('<div class="tab-pane active ' + tabid + '-tab"><i class="fa fa-spinner fa-spin" aria-hidden="true"></i> ' + VuFind.translate('loading') + '...</div>'); $top.find('.tab-content').append(newTab); return ajaxLoadTab(newTab, tabid, !$(this).parent().hasClass('initiallyActive')); } -- GitLab