NIHVIVO-2844 Updated to javascript to account for potential multiple mostSpecificTypes and allow an override property to be passed as an argument to be used in lieu of the mostSpecificType. For people menu page, preferredTitle is passed as the override property.

This commit is contained in:
cappadona 2011-07-15 19:07:57 +00:00
parent 7d5ce28f07
commit ca619e72c4

View file

@ -7,7 +7,7 @@ var getPersonIndividuals = browseByVClass.getIndividuals;
// Assigning the proxy function // Assigning the proxy function
browseByVClass.getIndividuals = function(vclassUri, alpha, page, scroll) { browseByVClass.getIndividuals = function(vclassUri, alpha, page, scroll) {
url = this.dataServiceUrl + encodeURIComponent(vclassUri); var url = this.dataServiceUrl + encodeURIComponent(vclassUri);
if ( alpha && alpha != "all") { if ( alpha && alpha != "all") {
url = url + '&alpha=' + alpha; url = url + '&alpha=' + alpha;
} }
@ -23,8 +23,8 @@ browseByVClass.getIndividuals = function(vclassUri, alpha, page, scroll) {
// Scroll to #menupage-intro page unless told otherwise // Scroll to #menupage-intro page unless told otherwise
if ( scroll != false ) { if ( scroll != false ) {
// only scroll back up if we're past the top of the #browse-by section // only scroll back up if we're past the top of the #browse-by section
scrollPosition = browseByVClass.getPageScroll(); var scrollPosition = browseByVClass.getPageScroll();
browseByOffset = $('#browse-by').offset(); var browseByOffset = $('#browse-by').offset();
if ( scrollPosition[1] > browseByOffset.top) { if ( scrollPosition[1] > browseByOffset.top) {
$.scrollTo('#menupage-intro', 500); $.scrollTo('#menupage-intro', 500);
} }
@ -38,14 +38,16 @@ browseByVClass.getIndividuals = function(vclassUri, alpha, page, scroll) {
if ( results.individuals.length == 0 ) { if ( results.individuals.length == 0 ) {
browseByVClass.emptyResultSet(results.vclass, alpha) browseByVClass.emptyResultSet(results.vclass, alpha)
} else { } else {
var vclassName = results.vclass.name;
$.each(results.individuals, function(i, item) { $.each(results.individuals, function(i, item) {
var individual, var individual,
label, label,
firstName, firstName,
lastName, lastName,
fullName, fullName,
vclassName, mostSpecificTypes,
preferredTitle, preferredTitle,
moreInfo,
uri, uri,
profileUrl, profileUrl,
image, image,
@ -60,9 +62,12 @@ browseByVClass.getIndividuals = function(vclassUri, alpha, page, scroll) {
} else { } else {
fullName = label; fullName = label;
} }
vclassName = individual.vclassName; mostSpecificTypes = individual.mostSpecificTypes;
if ( individual.preferredTitle ) { if ( individual.preferredTitle ) {
preferredTitle = individual.preferredTitle; preferredTitle = individual.preferredTitle;
moreInfo = browseByVClass.getMoreInfo(mostSpecificTypes, vclassName, preferredTitle);
} else {
moreInfo = browseByVClass.getMoreInfo(mostSpecificTypes, vclassName);
} }
uri = individual.URI; uri = individual.URI;
profileUrl = individual.profileUrl; profileUrl = individual.profileUrl;
@ -75,12 +80,10 @@ browseByVClass.getIndividuals = function(vclassUri, alpha, page, scroll) {
listItem = '<li class="vcard individual foaf-person" role="listitem" role="navigation">'; listItem = '<li class="vcard individual foaf-person" role="listitem" role="navigation">';
listItem += '<img src="'+ image +'" width="90" alt="'+ fullName +'" />'; listItem += '<img src="'+ image +'" width="90" alt="'+ fullName +'" />';
listItem += '<h1 class="fn thumb"><a href="'+ profileUrl +'" title="View the profile page for '+ fullName +'">'+ fullName +'</a></h1>'; listItem += '<h1 class="fn thumb"><a href="'+ profileUrl +'" title="View the profile page for '+ fullName +'">'+ fullName +'</a></h1>';
// Include the calculated preferred title (see above) only if it's not empty if ( moreInfo != '' ) {
if ( preferredTitle ) { listItem += '<span class="title">'+ moreInfo +'</span>';
listItem += '<span class="title">'+ preferredTitle +'</span>';
} }
listItem += '</li>'; listItem += '</li>';
// browseByVClass.individualsInVClass.append(listItem);
individualList += listItem; individualList += listItem;
}) })
@ -92,7 +95,7 @@ browseByVClass.getIndividuals = function(vclassUri, alpha, page, scroll) {
// Check to see if we're dealing with pagination // Check to see if we're dealing with pagination
if ( results.pages.length ) { if ( results.pages.length ) {
pages = results.pages; var pages = results.pages;
browseByVClass.pagination(pages, page); browseByVClass.pagination(pages, page);
} }