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