|
- /*! 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:"首页",n.last="last"in n?n.last:"尾页",n.prev="prev"in n?n.prev:"上一页",n.next="next"in n?n.next:"下一页",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="首页">'+n.first+"<\/a><span>…<\/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>…<\/span><a href="javascript:;" class="laypage_last" title="尾页" 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="已没有更多">'+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>到第<\/label><input type="number" min="1" onkeyup="this.value=this.value.replace(/\\D/, \'\');" class="laypage_skip"><label>页<\/label><button type="button" class="laypage_btn">确定<\/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
|