...
|
...
|
@@ -8,12 +8,12 @@ |
|
|
|
|
|
// render pagination ellipse indicator
|
|
|
function _renderEllipse(templateStr) {
|
|
|
return templateStr + '<li><a>...</a></li>';
|
|
|
return templateStr + '<a>...</a>';
|
|
|
}
|
|
|
|
|
|
// render last page link
|
|
|
function _renderLastPage(templateStr, pageCount, queryParams) {
|
|
|
return templateStr + '<li><a href="?page=' + pageCount + queryParams + '">' + pageCount + '</a></li>';
|
|
|
return templateStr + '<a href="?page=' + pageCount + queryParams + '">' + pageCount + '</a>';
|
|
|
}
|
|
|
|
|
|
/*
|
...
|
...
|
@@ -32,8 +32,8 @@ exports.createPagination = function(pagination, options) { |
|
|
n, // page number ?page=n
|
|
|
queryParams = '', // paginate with query parameter
|
|
|
page = parseInt(pagination.page, 10), // current page number
|
|
|
leftText = '<i class="iconfont"></i>', // prev
|
|
|
rightText = '<i class="iconfont"></i>', // next
|
|
|
leftText = '<i class="iconfont"></i>', // prev
|
|
|
rightText = '<i class="iconfont"></i>', // next
|
|
|
paginationClass = 'blk-pagination'; // pagination <ul> default class
|
|
|
|
|
|
var pageCount,
|
...
|
...
|
@@ -88,12 +88,12 @@ exports.createPagination = function(pagination, options) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
template = '<ul class="' + paginationClass + '">';
|
|
|
template = '<div class="' + paginationClass + '">';
|
|
|
|
|
|
// ========= Previous Button ===============
|
|
|
if (page - 1) {
|
|
|
n = page - 1;
|
|
|
template = template + '<li><a href="?page=' + n + queryParams + '">' + leftText + '</a></li>';
|
|
|
template = template + '<a href="?page=' + n + queryParams + '">' + leftText + '</a>';
|
|
|
}
|
|
|
|
|
|
// ========= Page Numbers Middle ===============
|
...
|
...
|
@@ -117,13 +117,13 @@ exports.createPagination = function(pagination, options) { |
|
|
n = start;
|
|
|
|
|
|
if (start === page) {
|
|
|
template = template + '<li class="active"><a href="?page=' + n + queryParams + '">' + n + '</a></li>';
|
|
|
template = template + '<a class="active" href="?page=' + n + queryParams + '">' + n + '</a>';
|
|
|
} else {
|
|
|
// generate left style
|
|
|
if (leftCount >= 4) {
|
|
|
if (i === 0) {
|
|
|
// first page
|
|
|
template = template + '<li><a href="?page=1' + queryParams + '">1</a></li>';
|
|
|
template = template + '<a href="?page=1' + queryParams + '">1</a>';
|
|
|
} else if (i === 1 || (i === 7 && start <= pageCount - 2)) {
|
|
|
// left and right ...
|
|
|
template = _renderEllipse(template);
|
...
|
...
|
@@ -132,9 +132,9 @@ exports.createPagination = function(pagination, options) { |
|
|
} else {
|
|
|
// other links is normal
|
|
|
template = template +
|
|
|
'<li><a href="?page=' + n + queryParams + '">' +
|
|
|
'<a href="?page=' + n + queryParams + '">' +
|
|
|
n +
|
|
|
'</a></li>';
|
|
|
'</a>';
|
|
|
}
|
|
|
} else {
|
|
|
if (i === 7 && start <= pageCount - 2) {
|
...
|
...
|
@@ -144,9 +144,9 @@ exports.createPagination = function(pagination, options) { |
|
|
template = _renderLastPage(template, pageCount, queryParams);
|
|
|
} else {
|
|
|
template = template +
|
|
|
'<li><a href="?page=' + n + queryParams + '">' +
|
|
|
'<a href="?page=' + n + queryParams + '">' +
|
|
|
n +
|
|
|
'</a></li>';
|
|
|
'</a>';
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -159,10 +159,10 @@ exports.createPagination = function(pagination, options) { |
|
|
// ========= Next page ===============
|
|
|
if (pageCount - page) {
|
|
|
n = page + 1;
|
|
|
template = template + '<li><a href="?page=' + n + queryParams + '">' + rightText + '</a></li>';
|
|
|
template = template + '<a href="?page=' + n + queryParams + '">' + rightText + '</a>';
|
|
|
}
|
|
|
|
|
|
template = template + '</ul>';
|
|
|
template = template + '</div>';
|
|
|
|
|
|
// html template
|
|
|
return template;
|
...
|
...
|
|