diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-12-05 11:12:37 -0800 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-12-05 11:12:37 -0800 |
commit | b0398c7db06fa63d54d805b7e8858db5332b4ce1 (patch) | |
tree | 095987814a9ed1059d8ce6d3f60c61a34801df1d | |
parent | 99f2a17e3f7f1d5b193a2061840434d8598e871f (diff) |
adding link click prevention for disabled pagination elements, fixing case where count > total and reassigning total = count
-rw-r--r-- | system/admin/handlers.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/system/admin/handlers.go b/system/admin/handlers.go index e91c5db..c505914 100644 --- a/system/admin/handlers.go +++ b/system/admin/handlers.go @@ -964,17 +964,30 @@ func postsHandler(res http.ResponseWriter, req *http.Request) { nextStatus = statusDisabled } + // set up pagination values urlFmt := req.URL.Path + "?count=%d&offset=%d&status=%s&type=%s" prevURL := fmt.Sprintf(urlFmt, count, offset-1, status, t) nextURL := fmt.Sprintf(urlFmt, count, offset+1, status, t) start := 1 + count*offset - end := start + count + end := start + count - 1 + if total < count { + total = count + } + pagination := fmt.Sprintf(` <ul class="pagination row"> <li class="waves-effect col s4 %s"><a href="%s"><i class="material-icons">chevron_left</i></a></li> <li class="col s4">%d to %d of %d</li> <li class="waves-effect col s4 %s"><a href="%s"><i class="material-icons">chevron_right</i></a></li> </ul> + <script> + // disable link from being clicked if parent is 'disabled' + $(function() { + $('li.disabled a').on('click', function(e) { + e.preventDefault(); + }); + }); + </script> `, prevStatus, prevURL, start, end, total, nextStatus, nextURL) b.Write([]byte(pagination + `</div></div>`)) |