NIHVIVO-1948 Pulled pagination out into its own function so it can be called by the default file and any product extension. Also introduced scrolling to getIndividuals(). Not sure if we'll keep this.
This commit is contained in:
parent
32fed86027
commit
10a9f8750b
1 changed files with 10 additions and 35 deletions
|
@ -6,7 +6,7 @@
|
||||||
var getPersonIndividuals = browseByVClass.getIndividuals;
|
var getPersonIndividuals = browseByVClass.getIndividuals;
|
||||||
|
|
||||||
// Assigning the proxy function
|
// Assigning the proxy function
|
||||||
browseByVClass.getIndividuals = function(vclassUri, alpha, page) {
|
browseByVClass.getIndividuals = function(vclassUri, alpha, page, scroll) {
|
||||||
url = this.dataServiceUrl + encodeURIComponent(vclassUri);
|
url = this.dataServiceUrl + encodeURIComponent(vclassUri);
|
||||||
if ( alpha && alpha != "all") {
|
if ( alpha && alpha != "all") {
|
||||||
url = url + '&alpha=' + alpha;
|
url = url + '&alpha=' + alpha;
|
||||||
|
@ -16,6 +16,9 @@ browseByVClass.getIndividuals = function(vclassUri, alpha, page) {
|
||||||
} else {
|
} else {
|
||||||
page = 1;
|
page = 1;
|
||||||
}
|
}
|
||||||
|
if ( typeof scroll === "undefined" ) {
|
||||||
|
scroll = true;
|
||||||
|
}
|
||||||
|
|
||||||
// First wipe currently displayed individuals and existing pagination
|
// First wipe currently displayed individuals and existing pagination
|
||||||
this.individualsInVClass.empty();
|
this.individualsInVClass.empty();
|
||||||
|
@ -25,35 +28,7 @@ browseByVClass.getIndividuals = function(vclassUri, alpha, page) {
|
||||||
// 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;
|
pages = results.pages;
|
||||||
|
browseByVClass.pagination(pages, page);
|
||||||
pagination = '<nav class="pagination menupage">';
|
|
||||||
pagination += '<h3>page</h3>';
|
|
||||||
pagination += '<ul>';
|
|
||||||
$.each(pages, function(i, item) {
|
|
||||||
anchorOpen = '<a class="page'+ pages[i].text +' round" href="#" title="View page '+ pages[i].text +' of the results">';
|
|
||||||
anchorClose = '</a>';
|
|
||||||
|
|
||||||
pagination += '<li class="page'+ pages[i].text;
|
|
||||||
pagination += ' round';
|
|
||||||
// Test for active page
|
|
||||||
if ( pages[i].text == page) {
|
|
||||||
pagination += ' selected';
|
|
||||||
anchorOpen = "";
|
|
||||||
anchorClose = "";
|
|
||||||
}
|
|
||||||
pagination += '" role="listitem">';
|
|
||||||
pagination += anchorOpen;
|
|
||||||
pagination += pages[i].text;
|
|
||||||
pagination += anchorClose;
|
|
||||||
pagination += '</li>';
|
|
||||||
})
|
|
||||||
pagination += '</ul>';
|
|
||||||
// browseByVClass.paginationNav.remove();
|
|
||||||
|
|
||||||
// Add the pagination above the list of individuals and call the listener
|
|
||||||
browseByVClass.individualsContainer.prepend(pagination);
|
|
||||||
browseByVClass.paginationListener();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$.each(results.individuals, function(i, item) {
|
$.each(results.individuals, function(i, item) {
|
||||||
|
@ -97,13 +72,13 @@ browseByVClass.getIndividuals = function(vclassUri, alpha, page) {
|
||||||
browseByVClass.individualsInVClass.append(listItem);
|
browseByVClass.individualsInVClass.append(listItem);
|
||||||
})
|
})
|
||||||
|
|
||||||
// Add the pagination below the list as well
|
|
||||||
if ( results.pages.length ) {
|
|
||||||
browseByVClass.individualsContainer.append(pagination);
|
|
||||||
}
|
|
||||||
|
|
||||||
// set selected class, alpha and page
|
// set selected class, alpha and page
|
||||||
browseByVClass.selectedVClass(results.vclass.URI);
|
browseByVClass.selectedVClass(results.vclass.URI);
|
||||||
browseByVClass.selectedAlpha(alpha);
|
browseByVClass.selectedAlpha(alpha);
|
||||||
|
|
||||||
|
// Scroll to the top of the browse section unless told otherwise
|
||||||
|
if ( scroll != false ) {
|
||||||
|
$.scrollTo('#browse-by', 500);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
Loading…
Add table
Add a link
Reference in a new issue