Skip to content

Commit

Permalink
Paging, yeah!
Browse files Browse the repository at this point in the history
  • Loading branch information
apage43 committed Sep 16, 2010
1 parent 592c961 commit 1cdf9cf
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
24 changes: 20 additions & 4 deletions _attachments/index.html
Expand Up @@ -59,19 +59,37 @@
}

var sammyapp = $.sammy(function() {
this.get('#/', function() {
this.get('#/', function() { this.redirect('#/Z'); });

this.get('#/:key', function(ctx) {
$('#titlebar').text('mailbag!');
var start = ctx.params["key"];
var skips = 0;
var amt = 15;
if(start != "Z") {
skips = 1;
}

db.view('mailbag/mail-items', {
limit: 50,
limit: amt,
skip: skips,
startkey: [start],
descending: true,
success: function(data)
{
console.log(data);
$('#mainpane').html($.mustache(templates.messages, data, null));
if(data.rows.length == amt) {
$('#mainpane').append('<a class="next" href="#/' + data.rows[data.rows.length-1].key + '">next</a>');
}
if(start != "Z") {
$('#mainpane').append('<a class="prev" href="javascript: history.go(-1);">prev</a>');
}
}
});
});


this.get('#/message/:id', function(ctx) {
db.openDoc(ctx.params["id"], {success: function(data) {
$('#titlebar').text('mailbag! - ' + data.subject);
Expand All @@ -90,9 +108,7 @@
{
if(others.rows.length == 0)
{
//Short circuit.
render_message(data, {"class": "picked"});
console.log("Not a thread!");
return;
}
var max = 0;
Expand Down
13 changes: 13 additions & 0 deletions _attachments/style/main.css
Expand Up @@ -328,3 +328,16 @@ button { width: auto; overflow: visible; }

.picked {
}

.next {
float: right;
text-size: 1.2em;
font-weight: bold;
}

.prev {
float: right;
text-size: 1.2em;
font-weight: bold;
margin-right: 1em;
}

0 comments on commit 1cdf9cf

Please sign in to comment.