You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.8 KiB
43 lines
1.8 KiB
11 years ago
|
Drupal.behaviors.roblib_search_solr_site_guides = {
|
||
|
attach: function(context, settings) {
|
||
|
$url = settings.roblib_search_solr_site_guides.search_url;
|
||
11 years ago
|
query = settings.roblib_search_solr_site_results.search_query;
|
||
|
baseUrl = settings.roblib_search_solr_site_results.base_url;
|
||
11 years ago
|
default_site_type = settings.roblib_search_solr_site_results.default_site_type + '/';
|
||
11 years ago
|
jQuery.getJSON($url, function(data) {
|
||
|
var items = [];
|
||
|
var numberOfDocs = 0;
|
||
|
try {
|
||
|
numberOfDocs = data.response.docs.length;
|
||
|
} catch (err) {
|
||
|
// do nothing leave docLength at 0
|
||
|
}
|
||
|
if (numberOfDocs < 1) {
|
||
|
jQuery('#' + 'roblib-search-content-solr-site-guides').empty().append('No Results');
|
||
11 years ago
|
jQuery('.' + 'pane-roblib-search-solr-site-roblib-search-solr-site-guides').hide();
|
||
11 years ago
|
} else {
|
||
|
|
||
|
jQuery('#' + 'roblib-search-content-solr-site-guides').empty();
|
||
11 years ago
|
var counter = 0;
|
||
|
var divs = new Array();
|
||
|
var content = new Array();
|
||
11 years ago
|
jQuery.each(data.response.docs, function(key, val) {
|
||
11 years ago
|
id = 'roblib_search_solr_guides_' + counter;
|
||
|
content[counter] = val.teaser;
|
||
|
divs[counter++] = id;
|
||
|
items.push('<div class ="roblib-search-row" id="' + id + '">\n\
|
||
11 years ago
|
<div class="roblib-title guides">\n\
|
||
|
<a href="' + val.url + '">' + val.label + '</a></div></div>');
|
||
|
});
|
||
|
jQuery('#' + 'roblib-search-content-solr-site-guides').empty().append(items.join(''));
|
||
8 years ago
|
//qtipify(divs, content, 'Description');
|
||
11 years ago
|
}
|
||
11 years ago
|
if (numberOfDocs > 0)
|
||
|
{
|
||
11 years ago
|
jQuery('#' + 'roblib-search-solr-site-guides-more').empty().append('<a href="'+ baseUrl + '/search/' + default_site_type + query +'?f[0]=im_field_keywords%3A627">see all results</a>');
|
||
11 years ago
|
}
|
||
11 years ago
|
});
|
||
|
}
|
||
|
|
||
|
}
|