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