From: Jakub Skoczen Date: Mon, 2 Apr 2007 09:44:34 +0000 (+0000) Subject: Pager will now show only a fixed window of pages. X-Git-Tag: PAZPAR2.1.0.0~372 X-Git-Url: http://jsfdemo.indexdata.com/?a=commitdiff_plain;h=d45dbfa66943da7990daab434881e4a3bfee3fae;p=pazpar2-moved-to-github.git Pager will now show only a fixed window of pages. --- diff --git a/www/masterkey/js/client.js b/www/masterkey/js/client.js index 94c2193..f70d98c 100644 --- a/www/masterkey/js/client.js +++ b/www/masterkey/js/client.js @@ -1,5 +1,5 @@ /* -** $Id: client.js,v 1.8 2007-04-02 08:41:51 jakub Exp $ +** $Id: client.js,v 1.9 2007-04-02 09:44:34 jakub Exp $ ** MasterKey - pazpar2's javascript client . */ @@ -365,8 +365,13 @@ function drawPager(max, hits) pager.append('Previous'); var numPages = Math.ceil(max / currentResultsPerPage); + + var start = ( currentPage - 5 > 0 ? currentPage - 5 : 1 ); + var stop = ( start + 12 < numPages ? start + 12 : numPages ); + + if (start > 1) $('... ').appendTo(pager); - for(var i = 1; i <= numPages; i++) + for(var i = start; i <= stop; i++) { if( i == (currentPage + 1) ){ $(''+i+'').appendTo(pager); @@ -390,6 +395,8 @@ function drawPager(max, hits) pager.eq(1).append(plClone); } + if (stop < numPages) $(' ...').appendTo(pager); + if ( currentPage < (numPages-1) ){ $('Next').click(function() { my_paz.showNext(1); currentPage++; }).appendTo(pager.eq(0)); $('Next').click(function() { my_paz.showNext(1); currentPage++; }).appendTo(pager.eq(1));