Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
Show main libraries first
Browse files Browse the repository at this point in the history
  • Loading branch information
edanchenkov committed Mar 18, 2014
1 parent f454b85 commit 62a48d8
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions js/libs/jquery.facetview.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ var selectedOpts = {};
'<select id="facet-filters-branchtypes" placeholder="' + _("Select...") + '" multiple></select>';


_filterTmpl += '<label class="checkbox">' +
'<input id="main-libraries" type="checkbox">' +
'Show main libraries first' +
'</label>'

for(var idx in filters) {

var filter = {
Expand Down Expand Up @@ -378,6 +383,11 @@ var selectedOpts = {};

$('#facetview_filters').html("").append(filterheader+_filterTmpl)

$('input#main-libraries').click(function(evt){
dosearch();
})



// get geolocation and show location-filter, if applicable
if (navigator.geolocation) {
Expand Down Expand Up @@ -1078,11 +1088,11 @@ var selectedOpts = {};

// sort results by geolocation, if available and requested
if (ld_position) {
var lat = ld_position_coords.latitude
var lon = ld_position_coords.longitude
var lat = ld_position_coords.latitude
var lon = ld_position_coords.longitude

qs.sort = [ { "_geo_distance": { "contact.coordinates": { "lat": lat, "lon": lon }, "order": "asc" } } ]
}
qs.sort = [ { "_geo_distance": { "contact.coordinates": { "lat": lat, "lon": lon }, "order": "asc" } } ]
}

// consortium pre-selection from widget #1
if (options.areafilter != undefined && options.areafilter != "") {
Expand Down Expand Up @@ -1133,6 +1143,24 @@ var selectedOpts = {};
qs['facets'][obj['field']] = {"terms":obj}
}

if ($('input#main-libraries').is(':checked')) {
qs.sort = {}

qs.rescore = {
"query": {
"rescore_query": {
"match": {
"branch_type": {
"query": "main_library"
}
}
},
"query_weight": 0.7,
"rescore_query_weight": 1.2
}
}
}

return JSON.stringify(qs)
}

Expand Down

0 comments on commit 62a48d8

Please sign in to comment.