Introdução
Compatível com o IE6+ e os navegadores modernos, ele suporta várias páginas na mesma página.
usar
Navegador
<link rel = "Stylesheet" href = "css/gb-paging.css"> <script src = "js/gb-paging.js"> </sCript>
Paginação normal
Html
<div id = "gbPaging">
JS
gbPaging ({total: 101, paramname: 'P', Curpage: getPage ('p', '#'), tamanho: 5, prevText: '<', nextText: '' ', PageInfo:' <b> {{curtPage}} </b>/<b> {{totalpages}} {};Outra página para a mesma página
Html
<div id = "paging1"> </div>
JS
GBPAGING ({eleid: 'paging1', Total: 54, tamanho: 10, PrevText: false, NextText: false, paramName: 'P1', Curpage: getPage ('P1', '#'), PageInfo: false, EventType: 'Click'});Atualize com parâmetros
Html
<div id = "paging2"> </div>
JS
GBPAGING ({eleid: 'PAGING2', TOTAL: 2500, ParamName: 'Page', Curpage: getPage ('Page', '? Type = 1 & Name = 2 &'), Gourl: '? Type = 1 & Name = 2 & {{{n}}'});Funções auxiliares
function getPage (pname, outros) {var page = window.location.search.replace (outro + pname + '=', '') || 1; Retornar parseint (página);}Opções
O recipiente de paginação Eleid, suporta apenas ID, o padrão é: 'GBPAGING'
Total: Total de registros
Paramname: Nome do parâmetro da paginação || 'P'
Curpagem: número atual da página
Tamanho: Número de registros por página || 10
ANTESTEXT: Cópia da página anterior || 'Página anterior', o valor é falso e não é exibido
NextText: 'Próxima página Cópia || O valor 'Próxima página' é false não exibido
PageInfo: Informações de paginação, {{currentPage}} número da página atual, {{totalpages}} Número da página total || Atual {{currentPage}} página/total {{totalpages}} página, o valor é false não exibido
EventType: Modo de Evento, 'Clique' || 'link'
gourl: link url, '? tipo = 1 & name = 2 & {{n}}' || '', {{n}} é o nome do parâmetro da página + valor, como: 'p = 1'
Github
https://github.com/givebest/gb-paging
Código completo
/** * gb-paging.js * @class gbpaging * @see https://github.com/givebest/gb-paging * @author [email protected] * @(c) 2016 **/(function () {var $, defaultConfig, Paging = null, args;/** [** ** [) {var $, defaultconfig, Paging = null, args;/** [** ** [) {var $, defaultconfig, Paging = null, args;/** [** ** [) {var $, defaultconfig, Paging = null, args;/** [** ** [) {var $, defaultConfig, Paging = NULT, ** ** ** [) defaultConfig = {EventType: 'Link', Curpage: 1, // Tamanho atual da página: 10, // N ParamName por página: 'P', // Parâmetro do número da página PrevText: 'Página anterior', NextText: 'Next Pages', PageInfo: 'Current <b> {{{}} </b> pages', / ** * [$ Descrição] * @param {string} id * @return {object} html [html elemento] * / $ = function (id) {return document.getElementById (id); Opta (isto); { args.paramName = args.paramName || defaultConfig.paramName; args.goUrl = args.goUrl || ''; args.pages = Math.ceil(args.total / args.size || 0); args.isPrev = (args.prevText !== false) ? true : false; args.prevText = args.prevText || defaultConfig.PrevText; / ** * [Paginação html] * @return {[type]} [descrição] * / gbpaging.protype.build = function () {var html = []; >>> 0 <= 0) retornar; para (var i = 1; i <ii; i ++) {if (args.curpage - i> 1) {html.unshift ('<a href = "' + urlparam + (args.curpage - i) + '">' + (args.curpage - i) + '</aa>); html.push ('<a href = "' + urlparam + (args.curpage + i) + '">' + (args.curpage + i) + '</a>'); html.unshift ('<a href = "' + urlparam + '1"> 1 </a>'); html.unshift ('<a>' + args.prevtext + '</a>'); + '">' + args.pages + '</a>'); args.isNext && html.push ('<a href ="' + urlparam + (args.curpage + 1) + '' '' ' + args.nextText +' </a>);} mais {arg arg. '</a>'); args.container.innerhtml = html.Join (''); E || {args.curpage = Target.getAttribute ('href'). Substitua (parseurl (arg.gourl, args.paramname), ''); _This.build (); '='); ele.addeventListener (evento, fn, false); Unbind (ele, evento, fn) {if (typeof removeventListener === 'function') {ele.removeEventListener (evento, fn, false); {String} cls className * @return {boolean} */função hasclass (ele, cls) {if (! Ele ||! Cls) retorna false; '(// S | $)'); ))) else {ele.className = ele.classname.replace (novo regexp ('(^| // b)' + className.split ('') .Join ('|') + '(// b | $),' gi '),' '); Gbpaging (); } ());