Drupal . behaviors . roblib _search _solr _site _guides = {
attach : function ( context , settings ) {
$url = settings . roblib _search _solr _site _guides . search _url ;
query = settings . roblib _search _solr _site _results . search _query ;
baseUrl = settings . roblib _search _solr _site _results . base _url ;
default _site _type = settings . roblib _search _solr _site _results . default _site _type + '/' ;
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' ) ;
jQuery ( '.' + 'pane-roblib-search-solr-site-roblib-search-solr-site-guides' ) . hide ( ) ;
} else {
jQuery ( '#' + 'roblib-search-content-solr-site-guides' ) . empty ( ) ;
var counter = 0 ;
var divs = new Array ( ) ;
var content = new Array ( ) ;
jQuery . each ( data . response . docs , function ( key , val ) {
id = 'roblib_search_solr_guides_' + counter ;
content [ counter ] = val . teaser ;
divs [ counter ++ ] = id ;
items . push ( '<div class ="roblib-search-row" id="' + id + ' " > \ n \
< div class = "roblib-title guides" > \ n \
< a href = "' + val.url + '" > ' + val.label + ' < / a > < / d i v > < / d i v > ' ) ;
} ) ;
jQuery ( '#' + 'roblib-search-content-solr-site-guides' ) . empty ( ) . append ( items . join ( '' ) ) ;
qtipify ( divs , content , 'Description' ) ;
}
if ( numberOfDocs > 0 )
{
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>' ) ;
}
} ) ;
}
}