jquery.pagination.js添加跳转页
2021-06-15 09:04
标签:eve star height off span orm .sh 技术 ++ 原作者github地址:https://github.com/gbirke/jquery_pagination 在这基础上加入了跳转到指定页。 修改后的jquery.pagination.js 样式pagination.css 展示: jquery.pagination.js添加跳转页 标签:eve star height off span orm .sh 技术 ++ 原文地址:http://www.cnblogs.com/lyxy/p/7275971.html/**
* This jQuery plugin displays pagination links inside the selected elements.
*
* This plugin needs at least jQuery 1.4.2
*
* @author Gabriel Birke (birke *at* d-scribe *dot* de)
* @version 2.2
* @param {int} maxentries Number of entries to paginate
* @param {Object} opts Several options (see README for documentation)
* @return {Object} jQuery Object
*/
(function($){
/**
* @class Class for calculating pagination values
*/
$.PaginationCalculator = function(maxentries, opts) {
this.maxentries = maxentries;
this.opts = opts;
};
$.extend($.PaginationCalculator.prototype, {
/**
* Calculate the maximum number of pages
* @method
* @returns {Number}
*/
numPages:function() {
return Math.ceil(this.maxentries/this.opts.items_per_page);
},
/**
* Calculate start and end point of pagination links depending on
* current_page and num_display_entries.
* @returns {Array}
*/
getInterval:function(current_page) {
var ne_half = Math.floor(this.opts.num_display_entries/2);
var np = this.numPages();
var upper_limit = np - this.opts.num_display_entries;
var start = current_page > ne_half ? Math.max( Math.min(current_page - ne_half, upper_limit), 0 ) : 0;
var end = current_page > ne_half?Math.min(current_page+ne_half + (this.opts.num_display_entries % 2), np):Math.min(this.opts.num_display_entries, np);
return {start:start, end:end};
}
});
// Initialize jQuery object container for pagination renderers
$.PaginationRenderers = {};
/**
* @class Default renderer for rendering pagination links
*/
$.PaginationRenderers.defaultRenderer = function(maxentries, opts) {
this.maxentries = maxentries;
this.opts = opts;
this.pc = new $.PaginationCalculator(maxentries, opts);
};
$.extend($.PaginationRenderers.defaultRenderer.prototype, {
/**
* Helper function for generating a single link (or a span tag if it‘s the current page)
* @param {Number} page_id The page id for the new item
* @param {Number} current_page
* @param {Object} appendopts Options for the new item: text and classes
* @returns {jQuery} jQuery object containing the link
*/
createLink:function(page_id, current_page, appendopts){
var lnk, np = this.pc.numPages();
page_id = page_id// Normalize page id to sane value
appendopts = $.extend({text:page_id+1, classes:""}, appendopts||{});
if(page_id == current_page){
lnk = $("" + appendopts.text + "");
}
else
{
lnk = $("" + appendopts.text + "")
.attr(‘href‘, this.opts.link_to.replace(/__id__/,page_id));
}
if(appendopts.classes){ lnk.addClass(appendopts.classes); }
if(appendopts.rel){ lnk.attr(‘rel‘, appendopts.rel); }
lnk.data(‘page_id‘, page_id);
return lnk;
},
// Generate a range of numeric links
appendRange:function(container, current_page, start, end, opts) {
var i;
for(i=start; i
.pagination {
font-size: 80%;
}
.pagination a {
text-decoration: none;
border: solid 1px #AAE;
color: #15B;
}
.pagination a, .pagination span, .pagination input {
display: block;
float: left;
padding: 0.3em 0.5em;
margin-right: 5px;
margin-bottom: 5px;
min-width:1em;
text-align:center;
}
.pagination .current {
background: #26B;
color: #fff;
border: solid 1px #AAE;
}
.pagination .current.prev, .pagination .current.next , .pagination .current.jump{
color:#999;
border-color:#999;
background:#fff;
}
.pagination .jump_page{
width:25px;
height:17px;
border: solid 1px #AAE;
}
文章标题:jquery.pagination.js添加跳转页
文章链接:http://soscw.com/index.php/essay/94119.html