You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4 lines
3.8 KiB

3 years ago
/*! layPage-v1.3.0 分页组件 License MIT http://laypage.layui.com/ By 贤心 */
!function(){"use strict";function t(u){var f="laypagecss";t.dir="dir"in t?t.dir:n.getpath+"/skin/laypage.min.css";new n(u);t.dir&&!i[r](f)&&n.use(t.dir,f)}t.v="1.3";var i=document,r="getElementById",u="getElementsByTagName",f=0,n=function(n){var t=this,i=t.config=n||{};i.item=f++;t.render(!0)};n.on=function(t,i,r){return t.attachEvent?t.attachEvent("on"+i,function(){r.call(t,window.even)}):t.addEventListener(i,r,!1),n};n.getpath=function(){var n=document.scripts,t=n[n.length-1].src;return t.substring(0,t.lastIndexOf("/")+1)}();n.use=function(n,r){var f=i.createElement("link");f.type="text/css";f.rel="stylesheet";f.href=t.dir;r&&(f.id=r);i[u]("head")[0].appendChild(f);f=null};n.prototype.type=function(){var n=this.config;if("object"==typeof n.cont)return void 0===n.cont.length?2:3};n.prototype.view=function(){var u=this,n=u.config,r=[],i={};if(n.pages=0|n.pages,n.curr=0|n.curr||1,n.groups="groups"in n?0|n.groups:5,n.first="first"in n?n.first:"&#x9996;&#x9875;",n.last="last"in n?n.last:"&#x5C3E;&#x9875;",n.prev="prev"in n?n.prev:"&#x4E0A;&#x4E00;&#x9875;",n.next="next"in n?n.next:"&#x4E0B;&#x4E00;&#x9875;",n.pages<=1)return"";for(n.groups>n.pages&&(n.groups=n.pages),i.index=Math.ceil((n.curr+(n.groups>1&&n.groups!==n.pages?1:0))/(0===n.groups?1:n.groups)),n.curr>1&&n.prev&&r.push('<a href="javascript:;" class="laypage_prev" data-page="'+(n.curr-1)+'">'+n.prev+"<\/a>"),i.index>1&&n.first&&0!==n.groups&&r.push('<a href="javascript:;" class="laypage_first" data-page="1" title="&#x9996;&#x9875;">'+n.first+"<\/a><span>&#x2026;<\/span>"),i.poor=Math.floor((n.groups-1)/2),i.start=i.index>1?n.curr-i.poor:1,i.end=i.index>1?function(){var t=n.curr+(n.groups-i.poor-1);return t>n.pages?n.pages:t}():n.groups,i.end-i.start<n.groups-1&&(i.start=i.end-n.groups+1);i.start<=i.end;i.start++)i.start===n.curr?r.push('<span class="laypage_curr" '+(/^#/.test(n.skin)?'style="background-color:'+n.skin+'"':"")+">"+i.start+"<\/span>"):r.push('<a href="javascript:;" data-page="'+i.start+'">'+i.start+"<\/a>");return n.pages>n.groups&&i.end<n.pages&&n.last&&0!==n.groups&&r.push('<span>&#x2026;<\/span><a href="javascript:;" class="laypage_last" title="&#x5C3E;&#x9875;" data-page="'+n.pages+'">'+n.last+"<\/a>"),i.flow=!n.prev&&0===n.groups,(n.curr!==n.pages&&n.next||i.flow)&&r.push(function(){return i.flow&&n.curr===n.pages?'<span class="page_nomore" title="&#x5DF2;&#x6CA1;&#x6709;&#x66F4;&#x591A;">'+n.next+"<\/span>":'<a href="javascript:;" class="laypage_next" data-page="'+(n.curr+1)+'">'+n.next+"<\/a>"}()),'<div name="laypage'+t.v+'" class="laypage_main laypageskin_'+(n.skin?function(n){return/^#/.test(n)?"molv":n}(n.skin):"default")+'" id="laypage_'+u.config.item+'">'+r.join("")+function(){return n.skip?'<span class="laypage_total"><label>&#x5230;&#x7B2C;<\/label><input type="number" min="1" onkeyup="this.value=this.value.replace(/\\D/, \'\');" class="laypage_skip"><label>&#x9875;<\/label><button type="button" class="laypage_btn">&#x786e;&#x5b9a;<\/button><\/span>':""}()+"<\/div>"};n.prototype.jump=function(t){if(t){for(var r=this,f=r.config,e=t.children,o=t[u]("button")[0],s=t[u]("input")[0],i=0,h=e.length;h>i;i++)"a"===e[i].nodeName.toLowerCase()&&n.on(e[i],"click",function(){var n=0|this.getAttribute("data-page");f.curr=n;r.render()});o&&n.on(o,"click",function(){var n=0|s.value.replace(/\s|\D/g,"");n&&n<=f.pages&&(f.curr=n,r.render())})}};n.prototype.render=function(n){var u=this,t=u.config,e=u.type(),f=u.view();2===e?t.cont.innerHTML=f:3===e?t.cont.html(f):i[r](t.cont).innerHTML=f;t.jump&&t.jump(t,n);u.jump(i[r]("laypage_"+t.item));t.hash&&!n&&(location.hash="!"+t.hash+"="+t.curr)};"function"==typeof define?define(function(){return t}):"undefined"!=typeof exports?module.exports=t:window.laypage=t}();
//# sourceMappingURL=laypage.min.js.map