/*! laypage v1.1 - 分页插件 by 贤心 http://sentsin.com/layui/laypage mit license */ string.prototype.format = function (args) { var result = this; if (arguments.length > 0) { if (arguments.length == 1 && typeof (args) == "object") { for (var key in args) { if (args[key] != undefined) { var reg = new regexp("({" + key + "})", "g"); result = result.replace(reg, args[key]); } } } else { for (var i = 0; i < arguments.length; i++) { if (arguments[i] != undefined) { var reg = new regexp("({)" + i + "(})", "g"); result = result.replace(reg, arguments[i]); } } } } return result; } ; !function () { "use strict"; function a(d) { var e = "laypagecss"; a.dir = "dir" in a ? a.dir : f.getpath + "skin/laypage.css", new f(d), a.dir && !b[c](e) && f.use(a.dir, e) } var b, c, d, e, f; a.v = "1.1", b = document, c = "getelementbyid", d = "getelementsbytagname", e = 0, f = function (a) { var b = this, c = b.config = a || {}; c.item = e++, b.render() }, f.on = function (a, b, c) { return a.attachevent ? a.attachevent("on" + b, function () { c.call(a, window.even) }) : a.addeventlistener(b, c, !1), f }, f.getpath = function () { var a = document.scripts, b = a[a.length - 1].src; return b.substring(0, b.lastindexof("/") + 1) }(), f.use = function (c, e) { var f = b.createelement("link"); f.type = "text/css", f.rel = "stylesheet", f.href = a.dir, e && (f.id = e), b[d]("head")[0].appendchild(f), f = null }, f.prototype.type = function () { var a = this.config; return "object" == typeof a.cont ? void 0 === a.cont.length ? 2 : 3 : void 0 }, f.prototype.view = function () { var b = this, c = b.config, d = [], e = {}; var getpageurl = function (page) { return page < 2 ? "" : (c.pagenum ? c.pagenum : "_page_") + page; } c.pages = 0 | c.pages, c.curr = 0 | c.curr || 1, c.groups = "groups" in c ? 0 | c.groups : 5, c.first = "first" in c ? c.first : 1, c.last = "last" in c ? c.last : c.pages, c.prev = "prev" in c ? c.prev : "上一页", c.next = "next" in c ? c.next : "下一页", c.groups > c.pages && (c.groups = c.pages), e.index = math.ceil((c.curr + (c.groups > 1 && c.groups !== c.pages ? 1 : 0)) / (0 === c.groups ? 1 : c.groups)), c.curr > 1 && c.prev && d.push('' + c.prev + ""), e.index > 1 && c.first && 0 !== c.groups && d.push('' + c.first + ""), e.poor = math.floor((c.groups - 1) / 2), e.start = e.index > 1 ? c.curr - e.poor : 1, e.end = e.index > 1 ? function () { var a = c.curr + (c.groups - e.poor - 1); return a > c.pages ? c.pages : a }() : c.groups, e.end - e.start < c.groups - 1 && (e.start = e.end - c.groups + 1); for (; e.start <= e.end; e.start++) e.start === c.curr ? d.push('" + e.start + "") : d.push('' + e.start + ""); return c.pages > c.groups && e.end < c.pages && c.last && 0 !== c.groups && d.push('' + c.last + ""), e.flow = !c.prev && 0 === c.groups, (c.curr !== c.pages && c.next || e.flow) && d.push(function () { return e.flow && c.curr === c.pages ? '' + c.next + "" : '' + c.next + "" }()), '
' + d.join("") + function () { return c.skip ? '' : "" }() + "
" }, f.prototype.jump = function (a) { if (a == null) return false; var i, j, b = this, c = b.config, e = a.children, g = a[d]("button")[0], h = a[d]("input")[0]; for (i = 0, j = e.length; j > i; i++) "a" === e[i].nodename.tolowercase() && f.on(e[i], "click", function () { var a = 0 | this.getattribute("data-page"); c.curr = a, b.render() }); g && f.on(g, "click", function () { var a = 0 | h.value.replace(/\s|\d/g, ""); a && a <= c.pages && (/*c.curr = a, b.render()*/location.href = c.formaturl.format({ page: a < 2 ? '' : (c.pagenum ? c.pagenum : "_page_") + a })); }) }, f.prototype.render = function () { var a = this, d = a.config, e = a.type(), f = a.view(); 2 === e ? d.cont.innerhtml = f : 3 === e ? d.cont.html(f) : b[c](d.cont).innerhtml = f, d.jump && d.jump(d), a.jump(b[c]("laypage_" + d.item)), d.hash && (location.hash = "!laypage_" + d.item + "=" + d.curr) }, "function" == typeof define ? define(function () { return a }) : "undefined" != typeof exports ? module.exports = a : window.laypage = a }();