From a989e4857914a162fcd80e2ebcae08fa407a039c Mon Sep 17 00:00:00 2001 From: Ere Maijala <ere.maijala@helsinki.fi> Date: Thu, 14 Jun 2018 17:28:08 +0300 Subject: [PATCH] Make js validate with eslint 4.x. (#1195) --- .travis.yml | 2 +- themes/bootstrap3/js/channels.js | 24 ++-- themes/bootstrap3/js/check_item_statuses.js | 26 ++-- themes/bootstrap3/js/check_save_statuses.js | 33 ++--- themes/bootstrap3/js/hierarchyTree.js | 64 ++++----- themes/bootstrap3/js/hold.js | 34 ++--- themes/bootstrap3/js/ill.js | 24 ++-- themes/bootstrap3/js/lightbox.js | 22 +-- themes/bootstrap3/js/openurl.js | 18 +-- themes/bootstrap3/js/preview.js | 42 +++--- themes/bootstrap3/js/pubdate_vis.js | 14 +- themes/bootstrap3/js/record.js | 142 ++++++++++---------- 12 files changed, 228 insertions(+), 217 deletions(-) diff --git a/.travis.yml b/.travis.yml index fef5d94d214..9284368abf2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ before_script: - phpenv config-rm xdebug.ini - phpenv rehash - composer install - - npm install -g eslint@"<3.0.0" + - npm install -g eslint@"<5.0.0" cache: directories: diff --git a/themes/bootstrap3/js/channels.js b/themes/bootstrap3/js/channels.js index 5a456b1e131..371687222cb 100644 --- a/themes/bootstrap3/js/channels.js +++ b/themes/bootstrap3/js/channels.js @@ -56,18 +56,18 @@ function setupChannelSlider(i, op) { type: 'POST', data: {tab: 'description'} }) - .done(function channelPopoverDone(data) { - record.data('bs.popover').options.content = '<h2>' + htmlEncode(record.text()) + '</h2>' - + '<div class="btn-group btn-group-justified">' - + '<a href="' + VuFind.path + '/Channels/Record?' - + 'id=' + encodeURIComponent(record.attr('data-record-id')) - + '&source=' + encodeURIComponent(record.attr('data-record-source')) - + '" class="btn btn-default">' + VuFind.translate('channel_expand') + '</a>' - + '<a href="' + record.attr('href') + '" class="btn btn-default">' + VuFind.translate('View Record') + '</a>' - + '</div>' - + data; - record.popover('show'); - }); + .done(function channelPopoverDone(data) { + record.data('bs.popover').options.content = '<h2>' + htmlEncode(record.text()) + '</h2>' + + '<div class="btn-group btn-group-justified">' + + '<a href="' + VuFind.path + '/Channels/Record?' + + 'id=' + encodeURIComponent(record.attr('data-record-id')) + + '&source=' + encodeURIComponent(record.attr('data-record-source')) + + '" class="btn btn-default">' + VuFind.translate('channel_expand') + '</a>' + + '<a href="' + record.attr('href') + '" class="btn btn-default">' + VuFind.translate('View Record') + '</a>' + + '</div>' + + data; + record.popover('show'); + }); } return false; }); diff --git a/themes/bootstrap3/js/check_item_statuses.js b/themes/bootstrap3/js/check_item_statuses.js index 1314a068389..b0856bcbf3f 100644 --- a/themes/bootstrap3/js/check_item_statuses.js +++ b/themes/bootstrap3/js/check_item_statuses.js @@ -50,7 +50,7 @@ function displayItemStatus(result, $item) { locationListHTML += '</div>'; locationListHTML += '<div class="groupCallnumber">'; locationListHTML += (result.locationList[x].callnumbers) - ? linkCallnumbers(result.locationList[x].callnumbers, result.locationList[x].callnumber_handler) : ''; + ? linkCallnumbers(result.locationList[x].callnumbers, result.locationList[x].callnumber_handler) : ''; locationListHTML += '</div>'; } $item.find('.locationDetails').removeClass('hidden'); @@ -93,18 +93,18 @@ function runItemAjaxForQueue() { url: VuFind.path + '/AJAX/JSON?method=getItemStatuses', data: { 'id': itemStatusIds } }) - .done(function checkItemStatusDone(response) { - for (var j = 0; j < response.data.statuses.length; j++) { - var status = response.data.statuses[j]; - displayItemStatus(status, itemStatusEls[status.id]); - itemStatusIds.splice(itemStatusIds.indexOf(status.id), 1); - } - itemStatusRunning = false; - }) - .fail(function checkItemStatusFail(response, textStatus) { - itemStatusFail(response, textStatus); - itemStatusRunning = false; - }); + .done(function checkItemStatusDone(response) { + for (var j = 0; j < response.data.statuses.length; j++) { + var status = response.data.statuses[j]; + displayItemStatus(status, itemStatusEls[status.id]); + itemStatusIds.splice(itemStatusIds.indexOf(status.id), 1); + } + itemStatusRunning = false; + }) + .fail(function checkItemStatusFail(response, textStatus) { + itemStatusFail(response, textStatus); + itemStatusRunning = false; + }); } function itemQueueAjax(id, el) { diff --git a/themes/bootstrap3/js/check_save_statuses.js b/themes/bootstrap3/js/check_save_statuses.js index 02d4e5a2268..07ff265e6ed 100644 --- a/themes/bootstrap3/js/check_save_statuses.js +++ b/themes/bootstrap3/js/check_save_statuses.js @@ -54,24 +54,25 @@ function runSaveAjaxForQueue() { 'source': sources } }) - .done(function checkSaveStatusDone(response) { - for (var id in response.data.statuses) { - if (response.data.statuses.hasOwnProperty(id)) { - displaySaveStatus(response.data.statuses[id], saveStatusEls[id]); - } - // Remove populated ids from the queue - for (var j = 0; j < saveStatusObjs; j++) { - if (saveStatusObjs[j].id === id) { - saveStatusObjs.splice(j, 1); + .done(function checkSaveStatusDone(response) { + for (var id in response.data.statuses) { + if (Object.prototype.hasOwnProperty.call(response.data.statuses, id)) { + displaySaveStatus(response.data.statuses[id], saveStatusEls[id]); + + // Remove populated ids from the queue + for (var j = 0; j < saveStatusObjs; j++) { + if (saveStatusObjs[j].id === id) { + saveStatusObjs.splice(j, 1); + } + } } } - } - saveStatusRunning = false; - }) - .fail(function checkItemStatusFail(response, textStatus) { - saveStatusFail(response, textStatus); - saveStatusRunning = false; - }); + saveStatusRunning = false; + }) + .fail(function checkItemStatusFail(response, textStatus) { + saveStatusFail(response, textStatus); + saveStatusRunning = false; + }); } function saveQueueAjax(obj, el) { if (el.hasClass('js-save-pending')) { diff --git a/themes/bootstrap3/js/hierarchyTree.js b/themes/bootstrap3/js/hierarchyTree.js index 6518eb69f7f..e49222f232c 100644 --- a/themes/bootstrap3/js/hierarchyTree.js +++ b/themes/bootstrap3/js/hierarchyTree.js @@ -30,15 +30,15 @@ function getRecord(id) { url: VuFind.path + '/Hierarchy/GetRecord?' + $.param({id: id}), dataType: 'html' }) - .done(function getRecordDone(response) { - $('#tree-preview').html(html_entity_decode(response)); - // Remove the old path highlighting - $('#hierarchyTree a').removeClass("jstree-highlight"); - // Add Current path highlighting - var jsTreeNode = $(":input[value='" + id + "']").parent(); - jsTreeNode.children("a").addClass("jstree-highlight"); - jsTreeNode.parents("li").children("a").addClass("jstree-highlight"); - }); + .done(function getRecordDone(response) { + $('#tree-preview').html(html_entity_decode(response)); + // Remove the old path highlighting + $('#hierarchyTree a').removeClass("jstree-highlight"); + // Add Current path highlighting + var jsTreeNode = $(":input[value='" + id + "']").parent(); + jsTreeNode.children("a").addClass("jstree-highlight"); + jsTreeNode.parents("li").children("a").addClass("jstree-highlight"); + }); } function changeNoResultLabel(display) { @@ -78,26 +78,26 @@ function doTreeSearch() { type: $("#treeSearchType").val() }) + "&format=true" }) - .done(function searchTreeAjaxDone(data) { - if (data.results.length > 0) { - $('#hierarchyTree').find('.jstree-search').removeClass('jstree-search'); - var jstree = $('#hierarchyTree').jstree(true); - jstree.close_all(); - for (var i = data.results.length; i--;) { - var id = htmlEncodeId(data.results[i]); - jstree._open_to(id); - } - for (var j = data.results.length; j--;) { - var tid = htmlEncodeId(data.results[j]); - $('#hierarchyTree').find('#' + tid).addClass('jstree-search'); + .done(function searchTreeAjaxDone(data) { + if (data.results.length > 0) { + $('#hierarchyTree').find('.jstree-search').removeClass('jstree-search'); + var jstree = $('#hierarchyTree').jstree(true); + jstree.close_all(); + for (var i = data.results.length; i--;) { + var id = htmlEncodeId(data.results[i]); + jstree._open_to(id); + } + for (var j = data.results.length; j--;) { + var tid = htmlEncodeId(data.results[j]); + $('#hierarchyTree').find('#' + tid).addClass('jstree-search'); + } + changeNoResultLabel(false); + changeLimitReachedLabel(data.limitReached); + } else { + changeNoResultLabel(true); } - changeNoResultLabel(false); - changeLimitReachedLabel(data.limitReached); - } else { - changeNoResultLabel(true); - } - $('#treeSearchLoadingImg').addClass('hidden'); - }); + $('#treeSearchLoadingImg').addClass('hidden'); + }); } } @@ -150,10 +150,10 @@ function buildTreeWithXml(cb) { mode: 'Tree' } }) - .done(function getTreeDone(xml) { - var nodes = buildJSONNodes($(xml).find('root')); - cb.call(this, nodes); - }); + .done(function getTreeDone(xml) { + var nodes = buildJSONNodes($(xml).find('root')); + cb.call(this, nodes); + }); } $(document).ready(function hierarchyTreeReady() { diff --git a/themes/bootstrap3/js/hold.js b/themes/bootstrap3/js/hold.js index 1359a489187..4879cc87522 100644 --- a/themes/bootstrap3/js/hold.js +++ b/themes/bootstrap3/js/hold.js @@ -20,24 +20,24 @@ function setUpHoldRequestForm(recordId) { cache: false, url: VuFind.path + '/AJAX/JSON' }) - .done(function holdPickupLocationsDone(response) { - var defaultValue = $('#pickUpLocation').data('default'); - $.each(response.data.locations, function holdPickupLocationEach() { - var option = $('<option></option>').attr('value', this.locationID).text(this.locationDisplay); - // Make sure to compare locationID and defaultValue as Strings since locationID may be an integer - if (String(this.locationID) === String(defaultValue) || (defaultValue === '' && this.isDefault && $emptyOption.length === 0)) { - option.attr('selected', 'selected'); - } - $('#pickUpLocation').append(option); - }); + .done(function holdPickupLocationsDone(response) { + var defaultValue = $('#pickUpLocation').data('default'); + $.each(response.data.locations, function holdPickupLocationEach() { + var option = $('<option></option>').attr('value', this.locationID).text(this.locationDisplay); + // Make sure to compare locationID and defaultValue as Strings since locationID may be an integer + if (String(this.locationID) === String(defaultValue) || (defaultValue === '' && this.isDefault && $emptyOption.length === 0)) { + option.attr('selected', 'selected'); + } + $('#pickUpLocation').append(option); + }); - $('#pickUpLocationLabel i').removeClass("fa fa-spinner icon-spin"); - $('#pickUpLocation').removeAttr('disabled'); - }) - .fail(function holdPickupLocationsFail(/*response*/) { - $('#pickUpLocationLabel i').removeClass("fa fa-spinner icon-spin"); - $('#pickUpLocation').removeAttr('disabled'); - }); + $('#pickUpLocationLabel i').removeClass("fa fa-spinner icon-spin"); + $('#pickUpLocation').removeAttr('disabled'); + }) + .fail(function holdPickupLocationsFail(/*response*/) { + $('#pickUpLocationLabel i').removeClass("fa fa-spinner icon-spin"); + $('#pickUpLocation').removeAttr('disabled'); + }); }); $('#requestGroupId').change(); } diff --git a/themes/bootstrap3/js/ill.js b/themes/bootstrap3/js/ill.js index bafc8f371f8..f0f7087aa0d 100644 --- a/themes/bootstrap3/js/ill.js +++ b/themes/bootstrap3/js/ill.js @@ -14,19 +14,19 @@ function setUpILLRequestForm(recordId) { cache: false, url: url }) - .done(function illPickupLocationsDone(response) { - $.each(response.data.locations, function illPickupLocationEach() { - var option = $("<option></option>").attr("value", this.id).text(this.name); - if (this.isDefault) { - option.attr("selected", "selected"); - } - $("#ILLRequestForm #pickupLibraryLocation").append(option); + .done(function illPickupLocationsDone(response) { + $.each(response.data.locations, function illPickupLocationEach() { + var option = $("<option></option>").attr("value", this.id).text(this.name); + if (this.isDefault) { + option.attr("selected", "selected"); + } + $("#ILLRequestForm #pickupLibraryLocation").append(option); + }); + $("#ILLRequestForm #pickupLibraryLocationLabel i").removeClass("fa fa-spinner icon-spin"); + }) + .fail(function illPickupLocationsFail(/*response*/) { + $("#ILLRequestForm #pickupLibraryLocationLabel i").removeClass("fa fa-spinner icon-spin"); }); - $("#ILLRequestForm #pickupLibraryLocationLabel i").removeClass("fa fa-spinner icon-spin"); - }) - .fail(function illPickupLocationsFail(/*response*/) { - $("#ILLRequestForm #pickupLibraryLocationLabel i").removeClass("fa fa-spinner icon-spin"); - }); }); $("#ILLRequestForm #pickupLibrary").change(); } diff --git a/themes/bootstrap3/js/lightbox.js b/themes/bootstrap3/js/lightbox.js index a063b48f4b0..0f017f29975 100644 --- a/themes/bootstrap3/js/lightbox.js +++ b/themes/bootstrap3/js/lightbox.js @@ -63,8 +63,9 @@ VuFind.register('lightbox', function Lightbox() { * * data-lightbox-ignore = do not submit this form in lightbox */ - var _constrainLink; // function declarations to avoid style warnings - var _formSubmit; // about circular references + // function declarations to avoid style warnings about circular references + var _constrainLink; + var _formSubmit; function render(content) { if (!content.match) { return; @@ -151,11 +152,16 @@ VuFind.register('lightbox', function Lightbox() { } } } - if ( // Close the lightbox after deliberate login - obj.method && ( // is a form - obj.url.match(/catalogLogin/) // catalog login for holds - || obj.url.match(/MyResearch\/(?!Bulk|Delete|Recover)/) // or that matches login/create account - ) && errorMsgs.length === 0 // skip failed logins + // Close the lightbox after deliberate login provided that: + // - is a form + // - catalog login for holds + // - or that matches login/create account + // - not a failed login + if ( + obj.method && ( + obj.url.match(/catalogLogin/) + || obj.url.match(/MyResearch\/(?!Bulk|Delete|Recover)/) + ) && errorMsgs.length === 0 ) { var eventResult = _emit('VuFind.lightbox.login', { @@ -224,7 +230,7 @@ VuFind.register('lightbox', function Lightbox() { if (typeof $(this).data('lightboxIgnore') != 'undefined' || typeof this.attributes.href === 'undefined' || this.attributes.href.value.charAt(0) === '#' - || this.href.match(/^[a-zA-Z]+\:[^\/]/) // ignore resource identifiers (mailto:, tel:, etc.) + || this.href.match(/^[a-zA-Z]+:[^/]/) // ignore resource identifiers (mailto:, tel:, etc.) ) { return true; } diff --git a/themes/bootstrap3/js/openurl.js b/themes/bootstrap3/js/openurl.js index 270bfebc0a6..6d26147839c 100644 --- a/themes/bootstrap3/js/openurl.js +++ b/themes/bootstrap3/js/openurl.js @@ -11,14 +11,14 @@ VuFind.register('openurl', function OpenUrl() { dataType: 'json', url: url }) - .done(function getResolverLinksDone(response) { - $target.removeClass('ajax_availability').empty().append(response.data.html); - }) - .fail(function getResolverLinksFail(response, textStatus) { - $target.removeClass('ajax_availability').addClass('text-danger').empty(); - if (textStatus === 'abort' || typeof response.responseJSON == 'undefined') { return; } - $target.append(response.responseJSON.data); - }); + .done(function getResolverLinksDone(response) { + $target.removeClass('ajax_availability').empty().append(response.data.html); + }) + .fail(function getResolverLinksFail(response, textStatus) { + $target.removeClass('ajax_availability').addClass('text-danger').empty(); + if (textStatus === 'abort' || typeof response.responseJSON == 'undefined') { return; } + $target.append(response.responseJSON.data); + }); } function embedOpenUrlLinks(el) { @@ -44,7 +44,7 @@ VuFind.register('openurl', function OpenUrl() { // combined results fetched with AJAX are loaded. function init(_container) { var container = _container || $('body'); - // assign action to the openUrlWindow link class + // assign action to the openUrlWindow link class container.find('a.openUrlWindow').unbind('click').click(function openUrlWindowClick() { var params = extractClassParams(this); var settings = params.window_settings; diff --git a/themes/bootstrap3/js/preview.js b/themes/bootstrap3/js/preview.js index 8d71e1bf15c..677118850de 100644 --- a/themes/bootstrap3/js/preview.js +++ b/themes/bootstrap3/js/preview.js @@ -22,9 +22,9 @@ function getOLOptions() { function getHTPreviews(keys) { var skeys = keys.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 + // 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]); @@ -40,12 +40,12 @@ function getHTPreviews(keys) { function applyPreviewUrl($link, url) { // Update the preview button: $link.attr('href', url).removeClass('hidden') - .attr('rel', 'noopener'); // Performance improvement + .attr('rel', 'noopener'); // Performance improvement // Update associated record thumbnail, if any: $link.parents('.result,.record') - .find('.recordcover[data-linkpreview="true"]').parents('a').attr('href', url) - .attr('rel', 'noopener'); + .find('.recordcover[data-linkpreview="true"]').parents('a').attr('href', url) + .attr('rel', 'noopener'); } function processBookInfo(booksInfo, previewClass, viewOptions) { @@ -66,7 +66,7 @@ function processGBSBookInfo(booksInfo) { processBookInfo(booksInfo, 'previewGBS', viewOptions.link); } if (viewOptions.tab && viewOptions.tab.length > 0) { - // check for "embeddable: true" in bookinfo + // check for "embeddable: true" in bookinfo for (var bibkey in booksInfo) { if (booksInfo[bibkey]) { if (viewOptions.tab.indexOf(booksInfo[bibkey].preview) >= 0 @@ -112,9 +112,9 @@ function setIndexOf() { throw new TypeError(); } var t = Object(this); - /*jslint bitwise: false*/ + /*jslint bitwise: false*/ var len = t.length >>> 0; - /*jslint bitwise: true*/ + /*jslint bitwise: true*/ if (len === 0) { return -1; } @@ -153,24 +153,24 @@ function getBookPreviews() { var bibkeys = skeys.split(/\s+/); var script; - // fetch Google preview if enabled + // fetch Google preview if enabled if ($('[class*="googlePreviewSpan"]').length > 0) { - // checks if query string might break URI limit - if not, run as normal - if (bibkeys.length <= 150){ + // 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=' - + bibkeys.join(',') + '&callback=processGBSBookInfo'; + + bibkeys.join(',') + '&callback=processGBSBookInfo'; $.getScript(script); } else { - // if so, break request into chunks of 100 + // if so, break request into chunks of 100 var keyString = ''; - // loop through array + // loop through array 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 + // 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=' - + keyString + '&callback=processGBSBookInfo'; + + keyString + '&callback=processGBSBookInfo'; $.getScript(script); keyString = ''; } @@ -178,14 +178,14 @@ function getBookPreviews() { } } - // fetch OpenLibrary preview if enabled + // fetch OpenLibrary preview if enabled if ($('[class*="olPreviewSpan"]').length > 0) { script = '//openlibrary.org/api/books?bibkeys=' - + bibkeys.join(',') + '&callback=processOLBookInfo'; + + bibkeys.join(',') + '&callback=processOLBookInfo'; $.getScript(script); } - // fetch HathiTrust preview if enabled + // fetch HathiTrust preview if enabled if ($('[class*="hathiPreviewSpan"]').length > 0) { getHTPreviews(skeys); } diff --git a/themes/bootstrap3/js/pubdate_vis.js b/themes/bootstrap3/js/pubdate_vis.js index 91aec13a876..cfe8de321b9 100644 --- a/themes/bootstrap3/js/pubdate_vis.js +++ b/themes/bootstrap3/js/pubdate_vis.js @@ -18,15 +18,19 @@ function PadDigits(number, totalDigits) { function loadVis(facetFields, searchParams, baseURL, zooming) { // Get colors from CSS var cssColorSettings = { - 'background-color': '#fff', // background of box - 'fill': '#eee', // box fill color - 'stroke': '#265680', // box outline color - 'outline-color': '#c38835' // selection color + // background of box + 'background-color': '#fff', + // box fill color + 'fill': '#eee', + // box outline color + 'stroke': '#265680', + // selection color + 'outline-color': '#c38835' }; var $dateVisColorSettings = $('#dateVisColorSettings'); for (var rule in cssColorSettings) { if ($dateVisColorSettings.css(rule)) { - var match = $dateVisColorSettings.css(rule).match(/rgb[a]?\([^\)]+\)|#[a-fA-F0-9]+/); + var match = $dateVisColorSettings.css(rule).match(/rgb[a]?\([^)]+\)|#[a-fA-F0-9]+/); if (null != match) { cssColorSettings[rule] = match[0]; } diff --git a/themes/bootstrap3/js/record.js b/themes/bootstrap3/js/record.js index 8226d48dbe1..8d23759822d 100644 --- a/themes/bootstrap3/js/record.js +++ b/themes/bootstrap3/js/record.js @@ -5,7 +5,7 @@ * Functions and event handlers specific to record pages. */ function checkRequestIsValid(element, requestType) { - var recordId = element.href.match(/\/Record\/([^\/]+)\//)[1]; + var recordId = element.href.match(/\/Record\/([^/]+)\//)[1]; var vars = deparam(element.href); vars.id = recordId; @@ -20,18 +20,18 @@ function checkRequestIsValid(element, requestType) { cache: false, url: url }) - .done(function checkValidDone(response) { - 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); - } else { + .done(function checkValidDone(response) { + 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); + } else { + $(element).remove(); + } + }) + .fail(function checkValidFail(/*response*/) { $(element).remove(); - } - }) - .fail(function checkValidFail(/*response*/) { - $(element).remove(); - }); + }); } function setUpCheckRequest() { @@ -52,9 +52,9 @@ function deleteRecordComment(element, recordId, recordSource, commentId) { dataType: 'json', url: url }) - .done(function deleteCommentDone(/*response*/) { - $($(element).closest('.comment')[0]).remove(); - }); + .done(function deleteCommentDone(/*response*/) { + $($(element).closest('.comment')[0]).remove(); + }); } function refreshCommentList($target, recordId, recordSource) { @@ -67,19 +67,19 @@ function refreshCommentList($target, recordId, recordSource) { dataType: 'json', url: url }) - .done(function refreshCommentListDone(response) { - // Update HTML - var $commentList = $target.find('.comment-list'); - $commentList.empty(); - $commentList.append(response.data.html); - $commentList.find('.delete').unbind('click').click(function commentRefreshDeleteClick() { - var commentId = $(this).attr('id').substr('recordComment'.length); - deleteRecordComment(this, recordId, recordSource, commentId); - return false; + .done(function refreshCommentListDone(response) { + // Update HTML + var $commentList = $target.find('.comment-list'); + $commentList.empty(); + $commentList.append(response.data.html); + $commentList.find('.delete').unbind('click').click(function commentRefreshDeleteClick() { + var commentId = $(this).attr('id').substr('recordComment'.length); + deleteRecordComment(this, recordId, recordSource, commentId); + return false; + }); + $target.find('.comment-form input[type="submit"]').button('reset'); + resetCaptcha($target); }); - $target.find('.comment-form input[type="submit"]').button('reset'); - resetCaptcha($target); - }); } function registerAjaxCommentRecord() { @@ -106,21 +106,21 @@ function registerAjaxCommentRecord() { data: data, dataType: 'json' }) - .done(function addCommentDone(/*response, textStatus*/) { - var $form = $(form); - var $tab = $form.closest('.list-tab-content'); - if (!$tab.length) { - $tab = $form.closest('.tab-pane'); - } - refreshCommentList($tab, id, recordSource); - $form.find('textarea[name="comment"]').val(''); - $form.find('input[type="submit"]').button('loading'); - resetCaptcha($form); - }) - .fail(function addCommentFail(response, textStatus) { - if (textStatus === 'abort' || typeof response.responseJSON === 'undefined') { return; } - VuFind.lightbox.alert(response.responseJSON.data, 'danger'); - }); + .done(function addCommentDone(/*response, textStatus*/) { + var $form = $(form); + var $tab = $form.closest('.list-tab-content'); + if (!$tab.length) { + $tab = $form.closest('.tab-pane'); + } + refreshCommentList($tab, id, recordSource); + $form.find('textarea[name="comment"]').val(''); + $form.find('input[type="submit"]').button('loading'); + resetCaptcha($form); + }) + .fail(function addCommentFail(response, textStatus) { + if (textStatus === 'abort' || typeof response.responseJSON === 'undefined') { return; } + VuFind.lightbox.alert(response.responseJSON.data, 'danger'); + }); return false; }); // Delete links @@ -165,23 +165,23 @@ function ajaxLoadTab($newTab, tabid, setHash) { type: 'POST', data: {tab: tabid} }) - .always(function ajaxLoadTabDone(data) { - if (typeof data === 'object') { - $newTab.html(data.responseText ? data.responseText : VuFind.translate('error_occurred')); - } else { - $newTab.html(data); - } - registerTabEvents(); - if (typeof syn_get_widget === "function") { - syn_get_widget(); - } - if (typeof setHash == 'undefined' || setHash) { - window.location.hash = tabid; - } else { - removeHashFromLocation(); - } - setupJumpMenus($newTab); - }); + .always(function ajaxLoadTabDone(data) { + if (typeof data === 'object') { + $newTab.html(data.responseText ? data.responseText : VuFind.translate('error_occurred')); + } else { + $newTab.html(data); + } + registerTabEvents(); + if (typeof syn_get_widget === "function") { + syn_get_widget(); + } + if (typeof setHash == 'undefined' || setHash) { + window.location.hash = tabid; + } else { + removeHashFromLocation(); + } + setupJumpMenus($newTab); + }); return false; } @@ -201,15 +201,15 @@ function refreshTagList(_target, _loggedin) { dataType: 'json', url: url }) - .done(function getRecordTagsDone(response) { - $tagList.empty(); - $tagList.replaceWith(response.data.html); - if (loggedin) { - $tagList.addClass('loggedin'); - } else { - $tagList.removeClass('loggedin'); - } - }); + .done(function getRecordTagsDone(response) { + $tagList.empty(); + $tagList.replaceWith(response.data.html); + if (loggedin) { + $tagList.addClass('loggedin'); + } else { + $tagList.removeClass('loggedin'); + } + }); } } function refreshTagListCallback() { @@ -232,9 +232,9 @@ function ajaxTagUpdate(_link, tag, _remove) { remove: remove } }) - .always(function tagRecordAlways() { - refreshTagList($target, false); - }); + .always(function tagRecordAlways() { + refreshTagList($target, false); + }); } function getNewRecordTab(tabid) { -- GitLab