re-indented algolia_search.js so that it uses 4-space indents.
This commit is contained in:
@@ -28,15 +28,21 @@ $(document).ready(function() {
|
|||||||
var params = {
|
var params = {
|
||||||
hitsPerPage: HITS_PER_PAGE,
|
hitsPerPage: HITS_PER_PAGE,
|
||||||
maxValuesPerFacet: MAX_VALUES_PER_FACET,
|
maxValuesPerFacet: MAX_VALUES_PER_FACET,
|
||||||
facets: $.map(FACET_CONFIG, function(facet) { return !facet.disjunctive ? facet.name : null; }),
|
facets: $.map(FACET_CONFIG, function(facet) {
|
||||||
disjunctiveFacets: $.map(FACET_CONFIG, function(facet) { return facet.disjunctive ? facet.name : null; })
|
return !facet.disjunctive ? facet.name : null;
|
||||||
|
}),
|
||||||
|
disjunctiveFacets: $.map(FACET_CONFIG, function(facet) {
|
||||||
|
return facet.disjunctive ? facet.name : null;
|
||||||
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
// Setup the search helper
|
// Setup the search helper
|
||||||
var helper = algoliasearchHelper(algolia, INDEX_NAME, params);
|
var helper = algoliasearchHelper(algolia, INDEX_NAME, params);
|
||||||
|
|
||||||
// Check if we passed hidden facets in the FACET_CONFIG
|
// Check if we passed hidden facets in the FACET_CONFIG
|
||||||
var result = $.grep(FACET_CONFIG, function(e){ return e.hidden && e.hidden == true; });
|
var result = $.grep(FACET_CONFIG, function(e) {
|
||||||
|
return e.hidden && e.hidden == true;
|
||||||
|
});
|
||||||
for (var i = 0; i < result.length; i++) {
|
for (var i = 0; i < result.length; i++) {
|
||||||
var f = result[i];
|
var f = result[i];
|
||||||
helper.addFacetRefinement(f.name, f.value);
|
helper.addFacetRefinement(f.name, f.value);
|
||||||
@@ -174,11 +180,21 @@ $(document).ready(function() {
|
|||||||
var values = [];
|
var values = [];
|
||||||
for (var v in facetResult.data) {
|
for (var v in facetResult.data) {
|
||||||
var label = '';
|
var label = '';
|
||||||
if (v === 'true') { label = 'Yes'; }
|
if (v === 'true') {
|
||||||
else if (v === 'false') { label = 'No'; }
|
label = 'Yes';
|
||||||
|
} else if (v === 'false') {
|
||||||
|
label = 'No';
|
||||||
|
}
|
||||||
// Remove any underscore from the value
|
// Remove any underscore from the value
|
||||||
else { label = v.replace(/_/g," "); }
|
else {
|
||||||
values.push({ label: label, value: v, count: facetResult.data[v], refined: helper.isRefined(facetParams.name, v) });
|
label = v.replace(/_/g, " ");
|
||||||
|
}
|
||||||
|
values.push({
|
||||||
|
label: label,
|
||||||
|
value: v,
|
||||||
|
count: facetResult.data[v],
|
||||||
|
refined: helper.isRefined(facetParams.name, v)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
var sortFunction = facetParams.sortFunction || sortByCountDesc;
|
var sortFunction = facetParams.sortFunction || sortByCountDesc;
|
||||||
if (facetParams.topListIfRefined) sortFunction = sortByRefined(sortFunction);
|
if (facetParams.topListIfRefined) sortFunction = sortByRefined(sortFunction);
|
||||||
@@ -214,7 +230,10 @@ $(document).ready(function() {
|
|||||||
// Process pagination
|
// Process pagination
|
||||||
var pages = [];
|
var pages = [];
|
||||||
if (content.page > maxPages) {
|
if (content.page > maxPages) {
|
||||||
pages.push({ current: false, number: 1 });
|
pages.push({
|
||||||
|
current: false,
|
||||||
|
number: 1
|
||||||
|
});
|
||||||
// They don't really add much...
|
// They don't really add much...
|
||||||
// pages.push({ current: false, number: '...', disabled: true });
|
// pages.push({ current: false, number: '...', disabled: true });
|
||||||
}
|
}
|
||||||
@@ -222,12 +241,18 @@ $(document).ready(function() {
|
|||||||
if (p < 0 || p >= content.nbPages) {
|
if (p < 0 || p >= content.nbPages) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pages.push({ current: content.page === p, number: (p + 1) });
|
pages.push({
|
||||||
|
current: content.page === p,
|
||||||
|
number: (p + 1)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (content.page + maxPages < content.nbPages) {
|
if (content.page + maxPages < content.nbPages) {
|
||||||
// They don't really add much...
|
// They don't really add much...
|
||||||
// pages.push({ current: false, number: '...', disabled: true });
|
// pages.push({ current: false, number: '...', disabled: true });
|
||||||
pages.push({ current: false, number: content.nbPages });
|
pages.push({
|
||||||
|
current: false,
|
||||||
|
number: content.nbPages
|
||||||
|
});
|
||||||
}
|
}
|
||||||
var pagination = {
|
var pagination = {
|
||||||
pages: pages,
|
pages: pages,
|
||||||
@@ -264,7 +289,9 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
$(document).on('click', '.gotoPage', function() {
|
$(document).on('click', '.gotoPage', function() {
|
||||||
helper.setCurrentPage(+$(this).data('page') - 1).search();
|
helper.setCurrentPage(+$(this).data('page') - 1).search();
|
||||||
$("html, body").animate({scrollTop:0}, '500', 'swing');
|
$("html, body").animate({
|
||||||
|
scrollTop: 0
|
||||||
|
}, '500', 'swing');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$(document).on('click', '.sortBy', function() {
|
$(document).on('click', '.sortBy', function() {
|
||||||
@@ -293,12 +320,12 @@ $(document).ready(function() {
|
|||||||
if (isEmpty) {
|
if (isEmpty) {
|
||||||
$('#input-loop').addClass('glyphicon-loop');
|
$('#input-loop').addClass('glyphicon-loop');
|
||||||
$('#input-loop').removeClass('glyphicon-remove');
|
$('#input-loop').removeClass('glyphicon-remove');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$('#input-loop').removeClass('glyphicon-loop');
|
$('#input-loop').removeClass('glyphicon-loop');
|
||||||
$('#input-loop').addClass('glyphicon-remove');
|
$('#input-loop').addClass('glyphicon-remove');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function numberWithDelimiter(number, delimiter) {
|
function numberWithDelimiter(number, delimiter) {
|
||||||
number = number + '';
|
number = number + '';
|
||||||
delimiter = delimiter || ',';
|
delimiter = delimiter || ',';
|
||||||
@@ -306,7 +333,9 @@ $(document).ready(function() {
|
|||||||
split[0] = split[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1' + delimiter);
|
split[0] = split[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1' + delimiter);
|
||||||
return split.join('.');
|
return split.join('.');
|
||||||
}
|
}
|
||||||
var sortByCountDesc = function sortByCountDesc (a, b) { return b.count - a.count; };
|
var sortByCountDesc = function sortByCountDesc(a, b) {
|
||||||
|
return b.count - a.count;
|
||||||
|
};
|
||||||
var sortByName = function sortByName(a, b) {
|
var sortByName = function sortByName(a, b) {
|
||||||
return a.value.localeCompare(b.value);
|
return a.value.localeCompare(b.value);
|
||||||
};
|
};
|
||||||
@@ -319,11 +348,16 @@ $(document).ready(function() {
|
|||||||
return sortFunction(a, b);
|
return sortFunction(a, b);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
function initWithUrlParams() {
|
function initWithUrlParams() {
|
||||||
var sPageURL = location.hash;
|
var sPageURL = location.hash;
|
||||||
if (!sPageURL || sPageURL.length === 0) { return true; }
|
if (!sPageURL || sPageURL.length === 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
var sURLVariables = sPageURL.split('&');
|
var sURLVariables = sPageURL.split('&');
|
||||||
if (!sURLVariables || sURLVariables.length === 0) { return true; }
|
if (!sURLVariables || sURLVariables.length === 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
var query = decodeURIComponent(sURLVariables[0].split('=')[1]);
|
var query = decodeURIComponent(sURLVariables[0].split('=')[1]);
|
||||||
$inputField.val(query);
|
$inputField.val(query);
|
||||||
helper.setQuery(query);
|
helper.setQuery(query);
|
||||||
@@ -338,6 +372,7 @@ $(document).ready(function() {
|
|||||||
helper.setCurrentPage(page);
|
helper.setCurrentPage(page);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setURLParams(state) {
|
function setURLParams(state) {
|
||||||
var urlParams = '#';
|
var urlParams = '#';
|
||||||
var currentQuery = state.query;
|
var currentQuery = state.query;
|
||||||
@@ -356,4 +391,3 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user