Merge pull request #3233 from rabuzarus/20170314_-_pagination

limit pagination page buttons to  max 10
This commit is contained in:
Michael Vogel 2017-03-14 20:05:29 +01:00 committed by GitHub
commit e57bd5fe55
3 changed files with 56 additions and 21 deletions

View file

@ -291,8 +291,8 @@ function paginate_data(App $a, $count = null) {
} }
$url = $stripped; $url = $stripped;
$data = array(); $data = array();
function _l(&$d, $name, $url, $text, $class = '') { function _l(&$d, $name, $url, $text, $class = '') {
if (strpos($url, '?') === false && ($pos = strpos($url, '&')) !== false) { if (strpos($url, '?') === false && ($pos = strpos($url, '&')) !== false) {
$url = substr($url, 0, $pos) . '?' . substr($url, $pos + 1); $url = substr($url, 0, $pos) . '?' . substr($url, $pos + 1);
@ -318,9 +318,10 @@ function paginate_data(App $a, $count = null) {
$numstart = 1; $numstart = 1;
$numstop = $numpages; $numstop = $numpages;
if ($numpages > 14) { // Limit the number of displayed page number buttons.
$numstart = (($pagenum > 7) ? ($pagenum - 7) : 1); if ($numpages > 8) {
$numstop = (($pagenum > ($numpages - 7)) ? $numpages : ($numstart + 14)); $numstart = (($pagenum > 4) ? ($pagenum - 4) : 1);
$numstop = (($pagenum > ($numpages - 7)) ? $numpages : ($numstart + 8));
} }
$pages = array(); $pages = array();

View file

@ -2509,9 +2509,18 @@ body .tread-wrapper .hovercard:hover .hover-card-content a {
} }
/* Pagination improvements */ /* Pagination improvements */
.pagination {
text-align: center;
display: block;
}
.pagination > li > a, .pagination > li > a,
.pagination > li > span { .pagination > li > span {
color: $link_color; color: $link_color;
float: none;
}
.pagination>li>a:hover,
.pagination>li>span:hover {
color: $link_hover_color;
} }
.pagination > .active > a, .pagination > .active > a,
.pagination > .active > a:focus, .pagination > .active > a:focus,
@ -2521,9 +2530,32 @@ body .tread-wrapper .hovercard:hover .hover-card-content a {
.pagination > .active > span:hover { .pagination > .active > span:hover {
background-color: $link_color; background-color: $link_color;
border-color: $link_color; border-color: $link_color;
border-radius: 3px;
} }
.disabled > a { .pagination li.pager_n a {
pointer-events: none; margin-left: 3px;
border-radius: 3px;
}
.pagination .pager_prev a {
margin-left: -5px;
margin-right: 4px;
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
}
.pagination .pager_next a {
margin-left: 4px;
margin-right: -5px;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
}
.pager .next > a,
.pager .previous > a {
float: none;
border-radius: 3px;
}
.pagination .disabled > a,
.pager .disabled > a {
display: none;
} }
/* /*

View file

@ -1,14 +1,16 @@
{{* Pager template, uses output of paginate_data() in include/text.php *}} {{* Pager template, uses output of paginate_data() in include/text.php *}}
{{if $pager}} {{if $pager}}
<div class="{{$pager.class}}"> <ul class="{{$pager.class}} pagination-sm">
{{if $pager.first}}<li class="pager_first {{$pager.first.class}}"><a href="{{$pager.first.url}}">{{$pager.first.text}}</a></li>{{/if}} {{if $pager.first}}<li class="pager_first {{$pager.first.class}}"><a href="{{$pager.first.url}}" title="{{$pager.first.text}}">&#8739;&lt;</a></li>{{/if}}
{{if $pager.prev}}<li class="pager_prev {{$pager.prev.class}}"><a href="{{$pager.prev.url}}">{{$pager.prev.text}}</a></li>{{/if}} {{if $pager.prev}}<li class="pager_prev {{$pager.prev.class}}"><a href="{{$pager.prev.url}}" title="{{$pager.prev.text}}">&lt;</a></li>{{/if}}
{{foreach $pager.pages as $p}}<li class="pager_{{$p.class}}"><a href="{{$p.url}}">{{$p.text}}</a></li>{{/foreach}} {{foreach $pager.pages as $p}}<li class="pager_{{$p.class}} hidden-xs hidden-sm"><a href="{{$p.url}}">{{$p.text}}</a></li>{{/foreach}}
{{if $pager.next}}<li class="pager_next {{$pager.next.class}}"><a href="{{$pager.next.url}}">{{$pager.next.text}}</a></li>{{/if}} {{if $pager.next}}<li class="pager_next {{$pager.next.class}}"><a href="{{$pager.next.url}}" title="{{$pager.next.text}}">&gt;</a></li>{{/if}}
{{if $pager.last}}&nbsp;<li class="pager_last {{$pager.last.class}}"><a href="{{$pager.last.url}}">{{$pager.last.text}}</a></li>{{/if}} {{if $pager.last}}<li class="pager_last {{$pager.last.class}}"><a href="{{$pager.last.url}}" title="{{$pager.last.text}}">&gt;&#8739;</a></li>{{/if}}
</div> </ul>
{{/if}} {{/if}}