summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2016-12-05 11:21:42 -0800
committerSteve Manuel <nilslice@gmail.com>2016-12-05 11:21:42 -0800
commit0113eb3f35c7a5e9edf12815736d1e1233b4388b (patch)
tree432c8f5f8f9da062242576713a39052420302733
parent4439971245ee470fca74f2e0c07d2f049290fce9 (diff)
moving script to pre-defined script element, moving total & count comparison higher again to be evaluated earlier
-rw-r--r--system/admin/handlers.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/system/admin/handlers.go b/system/admin/handlers.go
index fb4d555..81b8723 100644
--- a/system/admin/handlers.go
+++ b/system/admin/handlers.go
@@ -956,10 +956,15 @@ func postsHandler(res http.ResponseWriter, req *http.Request) {
statusDisabled := "disabled"
prevStatus := ""
nextStatus := ""
+ // total may be less than 10 (default count), so reset count to match total
+ if total < count {
+ count = total
+ }
+ // nothing previous to current list
if offset == 0 {
prevStatus = statusDisabled
}
-
+ // nothing after current list
if offset*count >= total {
nextStatus = statusDisabled
}
@@ -968,10 +973,6 @@ func postsHandler(res http.ResponseWriter, req *http.Request) {
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)
- // total may be less than 10 (default count), so reset count to match total
- if total < count {
- count = total
- }
start := 1 + count*offset
end := start + count - 1
@@ -981,14 +982,6 @@ func postsHandler(res http.ResponseWriter, req *http.Request) {
<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>`))
@@ -1003,6 +996,13 @@ func postsHandler(res http.ResponseWriter, req *http.Request) {
}
});
});
+
+ // disable link from being clicked if parent is 'disabled'
+ $(function() {
+ $('ul.pagination li.disabled a').on('click', function(e) {
+ e.preventDefault();
+ });
+ });
</script>
`