ppound
3 years ago
8 changed files with 88 additions and 59 deletions
@ -1,37 +1,34 @@ |
|||||||
Drupal.behaviors.roblib_search_solr_site_bestbet = { |
Drupal.behaviors.roblib_search_solr_bestbet_results = { |
||||||
attach: function (context, settings) { |
attach: function (context, settings) { |
||||||
url = settings.roblib_search_solr_site_bestbet.search_url; |
if (context == document) { |
||||||
default_site_type = settings.roblib_search_solr_site_results.default_site_type |
query = drupalSettings.path.currentPath.replace('roblib_search/', ''); |
||||||
jQuery.getJSON(url, function(data) { |
solrUrl = settings.solr_site_search_url + query; |
||||||
|
baseUrl = settings.solr_bestbet_base_url + query; |
||||||
|
jQuery.getJSON(baseUrl, function (data) { |
||||||
var items = []; |
var items = []; |
||||||
var numberOfDocs = 0; |
total_found = data.resultCount; |
||||||
try { |
|
||||||
numberOfDocs = data.response.docs.length; |
if (total_found < 1) { |
||||||
} catch (err) { |
|
||||||
// do nothing leave docLength at 0
|
|
||||||
} |
|
||||||
if (numberOfDocs < 1) { |
|
||||||
jQuery('#' + 'roblib-search-content-solr-site-bestbet').empty().append('No Results'); |
jQuery('#' + 'roblib-search-content-solr-site-bestbet').empty().append('No Results'); |
||||||
jQuery('.' + 'pane-roblib-search-solr-site-roblib-search-solr-site-bestbet').hide(); |
jQuery('.' + 'pane-roblib-search-solr-site-roblib-search-solr-site-' . solrType).hide(); |
||||||
} else { |
} else { |
||||||
|
|
||||||
jQuery('#' + 'roblib-search-content-solr-site-bestbet').empty(); |
jQuery('#' + 'roblib-search-content-solr-site-bestbet').empty(); |
||||||
var counter = 0; |
var counter = 0; |
||||||
var divs = new Array(); |
var divs = new Array(); |
||||||
var content = new Array(); |
var content = new Array(); |
||||||
jQuery.each(data.response.docs, function(key, val) { |
jQuery.each(data.results, function (key, val) { |
||||||
id = 'roblib_search_solr_bestbets_' + counter; |
id = 'roblib_search_solr_results_bestbet-' + counter; |
||||||
content[counter] = val.teaser; |
content[counter] = val.teaser; |
||||||
divs[counter++] = id; |
divs[counter++] = id; |
||||||
items.push('<div class ="roblib-search-row" id="' + id + '">\n\ |
items.push('<div class ="roblib-search-row" id="' + id + '">\n\ |
||||||
<div class="roblib-title solr_site">\n\ |
<span class="roblib-title results">\n\ |
||||||
<a href="' + val.url + '">' + val.content + '</a></div></div>'); |
<a href="' + val.field_link + '">' + val.title + '</a></span>' + |
||||||
|
'\n\<span class="roblib-solr-bundle">(' + val.type + ')</span> <span class="roblib-solr-teaser"> ' + val.body + '</span></div>'); |
||||||
}); |
}); |
||||||
jQuery('#' + 'roblib-search-content-solr-site-bestbet').empty().append(items.join('')); |
jQuery('#' + 'roblib-search-content-solr-site-bestbet').empty().append(items.join('')); |
||||||
} |
} |
||||||
}); |
}); |
||||||
} |
} |
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
|
} |
||||||
|
@ -0,0 +1,8 @@ |
|||||||
|
|
||||||
|
<div class ="roblib-search-more" id="roblib-search-solr-site-{{ solr_type }}-more"></div> |
||||||
|
<div class ="roblib-search-content solr-site-{{ solr_type }}" id="roblib-search-content-solr-site-{{ solr_type }}"> |
||||||
|
<img src="{{ spinner_path }}"/> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div id="roblib-solr-more-results-{{ solr_type }}" class="roblib-solr-more-button "></div> |
||||||
|
<div id="roblib-solr-search-toc-{{ solr_type }}" class="roblib-bento-toc moveme-please"></div> |
Loading…
Reference in new issue