aboutsummaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
Diffstat (limited to 'views')
-rw-r--r--views/departments.jade2
-rw-r--r--views/employees.jade2
-rw-r--r--views/employees_in_department.jade2
-rw-r--r--views/lib/pager.jade21
4 files changed, 15 insertions, 12 deletions
diff --git a/views/departments.jade b/views/departments.jade
index bdcb0ae..14d4a31 100644
--- a/views/departments.jade
+++ b/views/departments.jade
@@ -12,4 +12,4 @@ block content
tr
td: a(href=urlgenerator.department(department.dept_no)) #{department.dept_name}
- mixin pager(pager, departments.length, urlgenerator.departments)
+ mixin pager(pager, urlgenerator.departments)
diff --git a/views/employees.jade b/views/employees.jade
index d7d9005..cea80ed 100644
--- a/views/employees.jade
+++ b/views/employees.jade
@@ -12,4 +12,4 @@ block content
tr
td: a(href=urlgenerator.employee(employee.emp_no)) #{employee.first_name} #{employee.last_name}
- mixin pager(pager, employees.length, urlgenerator.employees)
+ mixin pager(pager, urlgenerator.employees)
diff --git a/views/employees_in_department.jade b/views/employees_in_department.jade
index c341647..8313b2c 100644
--- a/views/employees_in_department.jade
+++ b/views/employees_in_department.jade
@@ -18,4 +18,4 @@ block content
tr
td: a(href=urlgenerator.employee(employee.emp_no)) #{employee.first_name} #{employee.last_name}
- mixin pager(pager, employees.length, function(offset) { return urlgenerator.employees_in_department(dept_no, offset) })
+ mixin pager(pager, function(offset) { return urlgenerator.employees_in_department(dept_no, offset) })
diff --git a/views/lib/pager.jade b/views/lib/pager.jade
index a762735..1a47e12 100644
--- a/views/lib/pager.jade
+++ b/views/lib/pager.jade
@@ -1,14 +1,17 @@
-mixin pager(pager, length, f)
+mixin pager(pager, f)
p
- if pager.offset > 0
- a(href=f(pager.prevOffset)) prev
- |
+ if typeof pager.prevOffset == 'number'
+ a(href=f(pager.prevOffset)) << Previous
else
- | prev
+ | Previous
- - var nextOffset = pager.nextOffset(length)
- if nextOffset > 0
- a(href=f(nextOffset)) next
+ |
+ | #{pager.offset / pager.pageSize + 1} /
+ | #{Math.round(pager.count / pager.pageSize)}
+ |
+
+ if typeof pager.nextOffset == 'number'
+ a(href=f(pager.nextOffset)) Next >>
else
- | next
+ | Next