X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Felements%2Fpager.html;h=a53300f53754f2e6966be7dd3d7b710134095ed0;hb=382c8b58aa2dc26d653fc306b04ec716dc5670c0;hp=db9ff83bf9fcddbf2f2fba10aaf76630d848526c;hpb=e283ab567e6890727e4d8e35c1d8097398678753;p=freeside.git
diff --git a/httemplate/elements/pager.html b/httemplate/elements/pager.html
index db9ff83bf..a53300f53 100644
--- a/httemplate/elements/pager.html
+++ b/httemplate/elements/pager.html
@@ -1,42 +1,55 @@
-<%
-
- my %opt = @_;
-
- my $pager = '';
- if ( $opt{'total'} != $opt{'num_rows'} && $opt{'maxrecords'} ) {
- unless ( $opt{'offset'} == 0 ) {
- $cgi->param('offset', $opt{'offset'} - $opt{'maxrecords'});
-%>
-
- Previous
-
-<%
- }
- my $page = 0;
- for ( my $poff = 0; $poff < $opt{'total'}; $poff += $opt{'maxrecords'} ) {
- $page++;
- if ( $opt{'offset'} == $poff ) {
-%>
-
- <%= $page %>
-
-<%
- } else {
- $cgi->param('offset', $poff);
-%>
-
- $page
-
-<%
- }
- }
- unless ( $opt{'offset'} + $opt{'maxrecords'} > $opt{'total'} ) {
- $cgi->param('offset', $opt{'offset'} + $opt{'maxrecords'});
-%>
-
- Next
-
-<%
- }
- }
-%>
+% my %opt = @_;
+% my $pager = '';
+%
+% if ( $opt{'total'} != $opt{'num_rows'} && $opt{'maxrecords'} ) {
+%
+% unless ( $opt{'offset'} == 0 ) {
+% $cgi->param('offset', $opt{'offset'} - $opt{'maxrecords'});
+
+ Previous
+
+% }
+%
+% my $page = 0;
+% my $prevpage = 0;
+% my $over = 0;
+% my $step = $opt{total} / 10; # 10 evenly spaced
+% for ( my $poff = 0; $poff < $opt{total}; $poff += $opt{maxrecords} ) {
+% $page++;
+%
+% next unless
+% $page <= 4 #first four
+% || $page >= ( $opt{total} / $opt{maxrecords} ) - 3 #last four
+% || abs( ($opt{offset}-$poff) / $opt{maxrecords} ) <= 3 #w/i 3 of current
+% || $poff > $over # evenly spaced
+% ;
+%
+% $over += $step if $poff > $over;
+%
+% if ( $opt{'offset'} == $poff ) {
+
+ <% $page %>
+
+% } else {
+% $cgi->param('offset', $poff);
+%
+% if ( $page > $prevpage+1 ) {
+ ...
+% }
+
+ <% $page %>
+
+% }
+%
+% $prevpage = $page;
+%
+% }
+%
+% unless ( $opt{'offset'} + $opt{'maxrecords'} > $opt{'total'} ) {
+% $cgi->param('offset', $opt{'offset'} + $opt{'maxrecords'});
+
+ Next
+%
+% }
+%
+% }