|
@@ -48,19 +48,19 @@ module.exports = function(opts) { |
|
@@ -48,19 +48,19 @@ module.exports = function(opts) { |
48
|
pageVar + '=';
|
48
|
pageVar + '=';
|
49
|
|
49
|
|
50
|
function getPageNums(ntype) {
|
50
|
function getPageNums(ntype) {
|
|
|
51
|
+ /** 分页展示页码个数begin 规则:展示最靠近当前页的指定个数 **/
|
|
|
52
|
+ var pageShowMax = num % 2 === 0 ? page - 1 : page;
|
|
|
53
|
+ var pageShowMin = page;
|
51
|
var pageNums = [];
|
54
|
var pageNums = [];
|
52
|
var num = showNum;
|
55
|
var num = showNum;
|
|
|
56
|
+ var i, n;
|
53
|
|
57
|
|
54
|
if (ntype === 'e') {
|
58
|
if (ntype === 'e') {
|
55
|
num = num - 2;
|
59
|
num = num - 2;
|
56
|
num = num > 2 ? num : 2;
|
60
|
num = num > 2 ? num : 2;
|
57
|
}
|
61
|
}
|
58
|
|
62
|
|
59
|
- /** 分页展示页码个数begin 规则:展示最靠近当前页的指定个数 **/
|
|
|
60
|
- var pageShowMax = num % 2 === 0 ? page - 1 : page;
|
|
|
61
|
- var pageShowMin = page;
|
|
|
62
|
-
|
|
|
63
|
- for (var i = 0; i < Math.floor(num / 2); i++) {
|
63
|
+ for (i = 0; i < Math.floor(num / 2); i++) {
|
64
|
pageShowMax++;
|
64
|
pageShowMax++;
|
65
|
pageShowMin--;
|
65
|
pageShowMin--;
|
66
|
if (pageShowMax > totalPages) {
|
66
|
if (pageShowMax > totalPages) {
|
|
@@ -77,7 +77,7 @@ module.exports = function(opts) { |
|
@@ -77,7 +77,7 @@ module.exports = function(opts) { |
77
|
}
|
77
|
}
|
78
|
}
|
78
|
}
|
79
|
|
79
|
|
80
|
- for (var n = pageShowMin; n <= pageShowMax; n++) {
|
80
|
+ for (n = pageShowMin; n <= pageShowMax; n++) {
|
81
|
pageNums.push(n);
|
81
|
pageNums.push(n);
|
82
|
}
|
82
|
}
|
83
|
|
83
|
|
|
@@ -112,9 +112,9 @@ module.exports = function(opts) { |
|
@@ -112,9 +112,9 @@ module.exports = function(opts) { |
112
|
if (val === '.') {
|
112
|
if (val === '.') {
|
113
|
ret += '<a>...</a>';
|
113
|
ret += '<a>...</a>';
|
114
|
} else {
|
114
|
} else {
|
115
|
- ret += '<a href="javascript:void(0)" data-page="'+ base + val +'"' +
|
|
|
116
|
- (page === val ? 'class="'+ currentClass +'"' : '') +
|
|
|
117
|
- ' title="第'+ val +'页">'+ val + '</a>';
|
115
|
+ ret += '<a href="javascript:void(0)" data-page="' + base + val + '"' +
|
|
|
116
|
+ (page === val ? 'class="' + currentClass + '"' : '') +
|
|
|
117
|
+ ' title="第' + val + '页">' + val + '</a>';
|
118
|
}
|
118
|
}
|
119
|
});
|
119
|
});
|
120
|
}
|
120
|
}
|
|
@@ -143,32 +143,32 @@ module.exports = function(opts) { |
|
@@ -143,32 +143,32 @@ module.exports = function(opts) { |
143
|
items = $.isArray(items) ? items : (items || ALL_TYPES.stand).split('-');
|
143
|
items = $.isArray(items) ? items : (items || ALL_TYPES.stand).split('-');
|
144
|
|
144
|
|
145
|
var hasPage = false; // 配置中如果配置了多次 page/pe 则将忽略,只第一次有效
|
145
|
var hasPage = false; // 配置中如果配置了多次 page/pe 则将忽略,只第一次有效
|
146
|
- var ret = '<div class="pager'+' '+theme +'">';
|
146
|
+ var ret = '<div class="pager' + ' ' + theme + '">';
|
147
|
items.forEach(function(val) {
|
147
|
items.forEach(function(val) {
|
148
|
|
148
|
|
149
|
switch (val) {
|
149
|
switch (val) {
|
150
|
case 'f' :
|
150
|
case 'f' :
|
151
|
if (page > 1) {
|
151
|
if (page > 1) {
|
152
|
|
152
|
|
153
|
- ret += '<a href="javascript:void(0)" title="首页" data-page="'+ base +'1">首页</a>';
|
153
|
+ ret += '<a href="javascript:void(0)" title="首页" data-page="' + base + '1">首页</a>';
|
154
|
}
|
154
|
}
|
155
|
break;
|
155
|
break;
|
156
|
case 'p' :
|
156
|
case 'p' :
|
157
|
if (page > 1) {
|
157
|
if (page > 1) {
|
158
|
|
158
|
|
159
|
- ret += '<a href="javascript:void(0)" data-page="'+ base + (page - 1) +
|
159
|
+ ret += '<a href="javascript:void(0)" data-page="' + base + (page - 1) +
|
160
|
'" title="上一页"><span class="iconfont"></span>上一页</a>';
|
160
|
'" title="上一页"><span class="iconfont"></span>上一页</a>';
|
161
|
}
|
161
|
}
|
162
|
break;
|
162
|
break;
|
163
|
case 'n' :
|
163
|
case 'n' :
|
164
|
if (page < totalPages) {
|
164
|
if (page < totalPages) {
|
165
|
- ret += '<a href="javascript:void(0)" data-page="'+ base + (page + 1) +
|
165
|
+ ret += '<a href="javascript:void(0)" data-page="' + base + (page + 1) +
|
166
|
'" title="下一页">下一页<span class="iconfont"></span></a>';
|
166
|
'" title="下一页">下一页<span class="iconfont"></span></a>';
|
167
|
}
|
167
|
}
|
168
|
break;
|
168
|
break;
|
169
|
case 'l' :
|
169
|
case 'l' :
|
170
|
if (page < totalPages) {
|
170
|
if (page < totalPages) {
|
171
|
- ret += '<a href="javascript:void(0)" data-page="'+ base + totalPages +'" title="尾页">尾页</a>';
|
171
|
+ ret += '<a href="javascript:void(0)" data-page="' + base + totalPages + '" title="尾页">尾页</a>';
|
172
|
}
|
172
|
}
|
173
|
break;
|
173
|
break;
|
174
|
case 'info' :
|
174
|
case 'info' :
|