From 1f34f63f97389937bc3e24c3c29ce8119fb455cb Mon Sep 17 00:00:00 2001 From: Max Ogden Date: Fri, 1 Jul 2011 11:47:13 -0700 Subject: [PATCH] hooking up last button --- attachments/pages/index.html | 8 ++++---- attachments/script/removalist.js | 9 ++++++++- attachments/script/site.js | 9 ++++++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/attachments/pages/index.html b/attachments/pages/index.html index 0bea4252..38ea828a 100644 --- a/attachments/pages/index.html +++ b/attachments/pages/index.html @@ -88,13 +88,13 @@
- « first - ‹ previous + « first + 1 - 10 - next › - last » + + last »
diff --git a/attachments/script/removalist.js b/attachments/script/removalist.js index 41a43d6a..961103d0 100644 --- a/attachments/script/removalist.js +++ b/attachments/script/removalist.js @@ -5,7 +5,9 @@ var removalist = function() { } function renderRows(rows) { + var tableRows = []; + rows.map(function(row) { var cells = []; app.headers.map(function(header) { @@ -18,19 +20,22 @@ var removalist = function() { }) tableRows.push({cells: cells}); }) + util.render('dataTable', 'dataTableContainer', { rows: tableRows, headers: app.headers }) + app.newest = rows[0].id; app.oldest = rows[rows.length - 1].id; + } function getPageSize() { return parseInt($(".viewpanel-pagesize .selected").text()); } - function fetchRows(id) { + function fetchRows(id, skip) { var query = { "limit" : getPageSize() @@ -41,6 +46,8 @@ var removalist = function() { if (id !== app.newest) $.extend( query, {"skip": 1}); } + if (skip) $.extend( query, {"skip": skip}); + var req = {url: app.baseURL + 'api/rows?' + $.param(query)}; couch.request(req).then(function(response) { diff --git a/attachments/script/site.js b/attachments/script/site.js index 8b1e1f5d..0c16a067 100644 --- a/attachments/script/site.js +++ b/attachments/script/site.js @@ -23,7 +23,7 @@ app.routes = { }, page: function(id) { - removalist.getPageSize() + removalist.getPageSize(); } } @@ -35,8 +35,11 @@ app.after = { removalist.fetchRows(app.newest); }); $( '.viewpanel-paging a' ).click(function( e ) { - // var action = $(e.target).attr('id').split('paging-')[1]; - removalist.fetchRows(app.oldest); + var action = $(e.target); + if (action.hasClass("last")) removalist.fetchRows(false, app.dbInfo.doc_count - removalist.getPageSize()); + if (action.hasClass("next")) removalist.fetchRows(app.oldest); + if (action.hasClass("previous")) removalist.fetchRows(app.oldest); + if (action.hasClass("first")) removalist.fetchRows(); }); }