recent books
This commit is contained in:
parent
f9a2ce72d6
commit
00c02da766
@ -9,19 +9,20 @@ $.extend(ItemsCol.prototype,{
|
||||
bind: function() {
|
||||
var self = this;
|
||||
$('#'+this.id) .click(function() {
|
||||
toggleActive(this);
|
||||
home.pagination.page=0;
|
||||
home.pagination.perpage=10;
|
||||
self.load();
|
||||
});
|
||||
},
|
||||
load: function() {
|
||||
load: function(addparam) {
|
||||
var self = this;
|
||||
$.getJSON( this.url, home.pagination, function( data, textStatus, xhr ) {
|
||||
self.data = data;
|
||||
home.current = self;
|
||||
home.update();
|
||||
var linkHeader = xhr.getResponseHeader('link');
|
||||
home.updatePager(parse_link_header(linkHeader));
|
||||
$.getJSON( this.url, $.extend({}, home.pagination, addparam),
|
||||
function( data, textStatus, xhr ) {
|
||||
self.data = data;
|
||||
home.current = self;
|
||||
home.update();
|
||||
var linkHeader = xhr.getResponseHeader('link');
|
||||
home.updatePager(parse_link_header(linkHeader));
|
||||
});
|
||||
},
|
||||
renderRow: function(elt) {
|
||||
@ -78,6 +79,11 @@ var HomePage = function() {
|
||||
$.each([this.books,this.authors,this.series], function(ind, itemsCol) {
|
||||
itemsCol.bind();
|
||||
});
|
||||
$('#recent').click(function() {
|
||||
home.pagination.page=0;
|
||||
home.books.load({sort:'recent'});
|
||||
toggleActive(this);
|
||||
});
|
||||
$(".perpage").click(function() {
|
||||
home.pagination.perpage = $(this).attr("value");
|
||||
$('.perpage').removeClass('active');
|
||||
@ -167,6 +173,13 @@ function link(content, href, glyph) {
|
||||
}
|
||||
return link;
|
||||
}
|
||||
/**
|
||||
* Toggle Active buttons.
|
||||
*/
|
||||
function toggleActive(btn) {
|
||||
$(btn).siblings().removeClass('active');
|
||||
$(btn).addClass('active');
|
||||
}
|
||||
/*
|
||||
* parse_link_header()
|
||||
*
|
||||
|
@ -14,7 +14,11 @@ router.get('/', function(req, res) {
|
||||
' LEFT OUTER JOIN books_series_link ON books.id = books_series_link.book' +
|
||||
' LEFT OUTER JOIN series ON series.id = books_series_link.series';
|
||||
query = req.paginate.appendInitialQuery(query,'books.sort',qparams,true);
|
||||
query+= ' ORDER BY books.sort LIMIT ? OFFSET ?';
|
||||
if (req.query.sort == 'recent')
|
||||
query+= ' ORDER BY books.last_modified DESC';
|
||||
else
|
||||
query+= ' ORDER BY books.sort';
|
||||
query+= ' LIMIT ? OFFSET ?';
|
||||
qparams.push(req.paginate.perpage + 1);
|
||||
qparams.push(req.paginate.offset);
|
||||
req.db.each(query, qparams,
|
||||
|
@ -10,6 +10,8 @@ block content
|
||||
a#author.btn.btn-primary.btn-lg(href="#authors",role="button") Auteurs
|
||||
|
||||
a#serie.btn.btn-primary.btn-lg(href="#series",role="button") Series
|
||||
|
||||
a#recent.btn.btn-warning.btn-lg(href="#books",role="button") Derniers ajouts
|
||||
div#blkitems.container-fluid.hidden
|
||||
a#itemsanchor
|
||||
div.btn-group
|
||||
|
Loading…
Reference in New Issue
Block a user