From f895dfeb979f1a98ea38a6a88f99ff63422d4348 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 1 Jul 2012 04:30:29 +0200 Subject: o Better error handling. --- views/departments.jade | 2 +- views/employees.jade | 2 +- views/employees_in_department.jade | 2 +- views/lib/pager.jade | 21 ++++++++++++--------- 4 files changed, 15 insertions(+), 12 deletions(-) (limited to 'views') 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 -- cgit v1.2.3