diff options
Diffstat (limited to 'web/templates/list/components/pagination.tmpl')
-rw-r--r-- | web/templates/list/components/pagination.tmpl | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/web/templates/list/components/pagination.tmpl b/web/templates/list/components/pagination.tmpl new file mode 100644 index 0000000..5ff13bd --- /dev/null +++ b/web/templates/list/components/pagination.tmpl @@ -0,0 +1,44 @@ +{{define "pagination"}} + <nav class="pull-right"> + <ul class="pagination ag-pager"> + {{ if eq .CurrentPage 1}} + <li class="page-item disabled"> + <a class="page-link" href="#" aria-label="Previous"> + <span aria-hidden="true">«</span> + </a> + {{else}} + <li class="page-item"> + <a class="page-link" href="{{ sub .CurrentPage 1 }}" aria-label="Previous"> + <span aria-hidden="true">«</span> + </a> + {{end}} + </li> + {{ $min := max 1 (sub .CurrentPage 3) }} + {{ $max := min .MaxPages (add .CurrentPage 3) }} + {{if gt $min 3 }} + <li class="page-item"><a class="page-link" href="1">1</a></li> + <li class="page-item disabled"><a class="page-link" href="#">…</a></li> + {{end}} + + {{range (makeRange $min $max)}} + <li {{if eq . $.CurrentPage}}class="page-item active"{{end}}><a class="page-link" href="{{.}}">{{.}}</a></li> + {{end}} + {{if gt (sub .MaxPages $max) 3}} + <li class="page-item disabled"><a class="page-link" href="#">…</a></li> + <li class="page-item"><a class="page-link" href="{{.MaxPages}}">{{.MaxPages}}</a></li> + {{end}} + {{if eq .CurrentPage .MaxPages}} + <li class="page-item disabled"> + <a class="page-link" href="#" aria-label="Next"> + <span aria-hidden="true">»</span> + </a> + {{else}} + <li class="page-item"> + <a class="page-link" href="{{ add .CurrentPage 1 }}" aria-label="Next"> + <span aria-hidden="true">»</span> + </a> + {{end}} + </li> + </ul> + </nav> +{{end}} |