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.
107 lines
4.5 KiB
107 lines
4.5 KiB
12 years ago
|
Drupal.behaviors.roblib_search_evergreen = {
|
||
|
attach: function(context, settings) {
|
||
12 years ago
|
url = settings.roblib_search_evergreen.search_url;
|
||
|
jQuery.getJSON(url, function(data) {
|
||
11 years ago
|
var items = [];
|
||
11 years ago
|
var numberOfDocs = 0;
|
||
|
try {
|
||
|
numberOfDocs = data.numberOfRecords;
|
||
|
} catch (err) {
|
||
8 years ago
|
numberOfDocs = 0;
|
||
11 years ago
|
}
|
||
8 years ago
|
if(numberOfDocs === undefined || numberOfDocs < 1){
|
||
11 years ago
|
jQuery('#' + 'roblib-search-content-evergreen').empty().append('No Results');
|
||
|
jQuery('.pane-roblib-search-evergreen-roblib-search-evergreen-results').hide();
|
||
12 years ago
|
} else {
|
||
11 years ago
|
var counter = 0;
|
||
|
var divs = new Array();
|
||
|
var content = new Array();
|
||
12 years ago
|
jQuery.each(data, function(key, val) {
|
||
11 years ago
|
id = 'roblib_search_evergreen_' + counter;
|
||
|
populatePopupDivs(content, val, counter);
|
||
|
divs[counter++] = id;
|
||
|
items.push('<div class ="roblib-search-row" id="' + id + '">');
|
||
12 years ago
|
items.push('<div class="roblib-title evergreen">');
|
||
12 years ago
|
if (typeof val.title !== 'undefined') {
|
||
|
items.push('<a href = "'+val.url+'">'+val.title);
|
||
|
}
|
||
|
if (typeof val.subtitle !== 'undefined') {
|
||
|
items.push(' ' + val.subtitle);
|
||
|
}
|
||
|
items.push('</a></div>');
|
||
|
if (typeof val.sor !== 'undefined') {
|
||
|
items.push('<div class="evergreen-sor">' + val.sor +'</div>');
|
||
|
}
|
||
|
if (typeof val.date !== 'undefined') {
|
||
|
items.push('<div class="evergreen-date">' + val.date + '</div>')
|
||
|
}
|
||
|
if(typeof val.holdings !== 'undefined'){
|
||
|
items.push('<div class="evergreen-holdings">');
|
||
|
jQuery.each(val.holdings, function(key2, val2){
|
||
|
roblibEvergreenAddHoldings(val2, items);
|
||
|
})
|
||
|
items.push('</div>')
|
||
|
}
|
||
12 years ago
|
if(typeof val.electronic_holdings !== 'undefined'){
|
||
|
items.push('<div class="evergreen-holdings">');
|
||
|
jQuery.each(val.electronic_holdings, function(key2, val2){
|
||
|
roblibEvergreenAddElectronicHoldings(val2, items);
|
||
|
})
|
||
|
items.push('</div>')
|
||
|
}
|
||
12 years ago
|
items.push('</div>');
|
||
11 years ago
|
});
|
||
|
jQuery('#roblib-search-content-evergreen').empty().append(items.join(''));
|
||
|
qtipify(divs, content, 'More Info');
|
||
12 years ago
|
}
|
||
11 years ago
|
|
||
10 years ago
|
jQuery('#roblib-search-evergreen-more').empty().append('<a href = "' + data.catalogBaseSearchUrl + '">See all results</a>');
|
||
12 years ago
|
});
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
11 years ago
|
function populatePopupDivs(content, val, counter){
|
||
|
content[counter] = '';
|
||
11 years ago
|
var placeOfPublication = '';
|
||
11 years ago
|
if(typeof val.pop !== 'undefined'){
|
||
|
content[counter] += '<div class="evergreen-publisher">Publisher: ' + val.pop ;
|
||
11 years ago
|
placeOfPublication = '</div>';
|
||
11 years ago
|
}
|
||
11 years ago
|
if(typeof val.pop !== 'undefined' ){
|
||
11 years ago
|
placeOfPublication = val.publisher + ' ' +placeOfPublication;
|
||
11 years ago
|
}
|
||
11 years ago
|
content[counter] += placeOfPublication;
|
||
|
|
||
11 years ago
|
if(typeof val.numofpages !== 'undefined'){
|
||
|
content[counter] += '<div class="evergreen-nop">Number of Pages: ' + val.numofpages +'</div>';
|
||
|
}
|
||
|
if(typeof val.date !== 'undefined'){
|
||
|
content[counter] += '<div class="evergreen-popup-date">Publication Year: ' + val.date +'</div>';
|
||
|
}
|
||
|
var subjects = '';
|
||
|
if(typeof val.subjectsa !== 'undefined'){
|
||
|
subjects += val.subjectsa;
|
||
|
}
|
||
|
if(typeof val.subjectsb !== 'undefined'){
|
||
|
subjects += ' ' + val.subjectsb;
|
||
|
}
|
||
|
if(typeof val.subjectsc !== 'undefined'){
|
||
|
subjects += ' ' + val.subjectsc;
|
||
|
}
|
||
|
if(subjects){
|
||
|
content[counter] += '<div class="evergreen-subjects">Subjects: ' + subjects + '</div>';
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
12 years ago
|
function roblibEvergreenAddHoldings(holdings, items){
|
||
12 years ago
|
items.push('<div class="evergreen-holdings-item">' + holdings.call_number + ' - ' + holdings.location +' (' + holdings.availability + ')</div>');
|
||
|
}
|
||
|
function roblibEvergreenAddElectronicHoldings(holdings, items){
|
||
|
items.push('<div class="evergreen-holdings-item"><a href="' + holdings.url + '">' + holdings.label + '</div>');
|
||
12 years ago
|
}
|
||
12 years ago
|
|
||
|
|