From 32bc423217f512fd1692d308afea3af45df474a0 Mon Sep 17 00:00:00 2001 From: Chris Hallberg <crhallberg@gmail.com> Date: Wed, 1 Jun 2016 14:43:39 -0400 Subject: [PATCH] dot-notation --- themes/bootstrap3/js/common.js | 4 +-- themes/bootstrap3/js/preview.js | 8 +++--- themes/bootstrap3/js/pubdate_vis.js | 42 ++++++++++++++--------------- themes/bootstrap3/js/record.js | 2 +- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/themes/bootstrap3/js/common.js b/themes/bootstrap3/js/common.js index 5cf978fe5f5..266c0c41aa7 100644 --- a/themes/bootstrap3/js/common.js +++ b/themes/bootstrap3/js/common.js @@ -182,8 +182,8 @@ function setupAutocomplete() { data: { q:query, method:'getACSuggestions', - searcher:searcher['searcher'], - type:searcher['type'] ? searcher['type'] : $(input).closest('.searchForm').find('.searchForm_type').val(), + searcher:searcher.searcher, + type:searcher.type ? searcher.type : $(input).closest('.searchForm').find('.searchForm_type').val(), hiddenFilters:hiddenFilters }, dataType:'json', diff --git a/themes/bootstrap3/js/preview.js b/themes/bootstrap3/js/preview.js index 3fdb6dcd5ce..dbbd15cbef4 100644 --- a/themes/bootstrap3/js/preview.js +++ b/themes/bootstrap3/js/preview.js @@ -57,15 +57,15 @@ function processBookInfo(booksInfo, previewClass, viewOptions) { function processGBSBookInfo(booksInfo) { var viewOptions = getGoogleOptions(); - if (viewOptions['link'] && viewOptions['link'].length > 0) { - processBookInfo(booksInfo, 'previewGBS', viewOptions['link']); + if (viewOptions.link && viewOptions.link.length > 0) { + processBookInfo(booksInfo, 'previewGBS', viewOptions.link); } - if (viewOptions['tab'] && viewOptions['tab'].length > 0) { + 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 + if (viewOptions.tab.indexOf(bookInfo.preview) >= 0 && (bookInfo.embeddable)) { // make tab visible $('ul.nav-tabs li.hidden a.preview').parent().removeClass('hidden'); diff --git a/themes/bootstrap3/js/pubdate_vis.js b/themes/bootstrap3/js/pubdate_vis.js index c35abc09614..61f7f59f9cb 100644 --- a/themes/bootstrap3/js/pubdate_vis.js +++ b/themes/bootstrap3/js/pubdate_vis.js @@ -40,10 +40,10 @@ function loadVis(facetFields, searchParams, baseURL, zooming) { show: true, align: "center", fill: true, - fillColor: cssColorSettings['fill'] + fillColor: cssColorSettings.fill } }, - colors: [cssColorSettings['stroke']], + colors: [cssColorSettings.stroke], legend: { noColumns: 2 }, xaxis: { tickDecimals: 0 }, yaxis: { min: 0, ticks: [] }, @@ -54,9 +54,9 @@ function loadVis(facetFields, searchParams, baseURL, zooming) { // AJAX call var url = baseURL + '/AJAX/json?method=getVisData&facetFields=' + encodeURIComponent(facetFields) + '&' + searchParams; $.getJSON(url, function getVisDataJSON(data) { - $.each(data['data'], function getVisDataEach(key, val) { + $.each(data.data, function getVisDataEach(key, val) { //check if there is data to display, if there isn't hide the box - if (val['data'] === undefined || val['data'].length === 0) { + if (val.data === undefined || val.data.length === 0) { return; } $("#datevis" + key + "xWrapper").removeClass('hidden'); @@ -68,32 +68,32 @@ 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; } //check if the min and max value have been set otherwise set them to the ends of the graph - if (val['min'] === 0) { - val['min'] = val['data'][0][0] - 5; + 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) { //check the first and last elements of the data array against min and max value (+padding) //if the element exists leave it, otherwise create a new marker with a minus one value - if (val['data'][val['data'].length - 1][0] !== parseInt(val['max'], 10) + 5) { - val['data'].push([parseInt(val['max'], 10) + 5, -1]); + if (val.data[val.data.length - 1][0] !== parseInt(val.max, 10) + 5) { + val.data.push([parseInt(val.max, 10) + 5, -1]); } - if (val['data'][0][0] !== val['min'] - 5) { - val['data'].push([val['min'] - 5, -1]); + if (val.data[0][0] !== val.min - 5) { + 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); + val.data.splice(i,1); i--; } } @@ -101,29 +101,29 @@ function loadVis(facetFields, searchParams, baseURL, zooming) { } else { //no zooming means that we need to specifically set the margins //do the last one first to avoid getting the new last element - val['data'].push([parseInt(val['data'][val['data'].length - 1][0], 10) + 5, -1]); + val.data.push([parseInt(val.data[val.data.length - 1][0], 10) + 5, -1]); //now get the first element - val['data'].push([val['data'][0][0] - 5, -1]); + val.data.push([val.data[0][0] - 5, -1]); } var plot = $.plot(placeholder, [val], options); if (hasFilter) { // mark pre-selected area - plot.setSelection({ x1: val['min'] , x2: val['max']}); + plot.setSelection({ x1: val.min , x2: val.max}); } // selection handler placeholder.bind("plotselected", function plotselected(event, ranges) { var from = Math.floor(ranges.xaxis.from); var to = Math.ceil(ranges.xaxis.to); - location.href = val['removalURL'] + '&daterange[]=' + key + '&' + key + 'to=' + PadDigits(to,4) + '&' + key + 'from=' + PadDigits(from,4); + location.href = val.removalURL + '&daterange[]=' + key + '&' + key + 'to=' + PadDigits(to,4) + '&' + key + 'from=' + PadDigits(from,4); }); if (hasFilter) { var newdiv = document.createElement('span'); var text = document.getElementById("clearButtonText").innerHTML; newdiv.setAttribute('id', 'clearButton' + key); - newdiv.innerHTML = '<a href="' + htmlEncode(val['removalURL']) + '">' + text + '</a>'; + newdiv.innerHTML = '<a href="' + htmlEncode(val.removalURL) + '">' + text + '</a>'; newdiv.className += "dateVisClear"; placeholder.before(newdiv); } diff --git a/themes/bootstrap3/js/record.js b/themes/bootstrap3/js/record.js index 39ef2fda639..d625ff8946b 100644 --- a/themes/bootstrap3/js/record.js +++ b/themes/bootstrap3/js/record.js @@ -6,7 +6,7 @@ function checkRequestIsValid(element, requestType) { var recordId = element.href.match(/\/Record\/([^\/]+)\//)[1]; var vars = deparam(element.href); - vars['id'] = recordId; + vars.id = recordId; var url = VuFind.path + '/AJAX/JSON?' + $.param({method:'checkRequestIsValid', id: recordId, requestType: requestType, data: vars}); $.ajax({ -- GitLab