(function(a) { jQuery.fn.raPaging = function(a) { function h(a) { if (a.data.isnext) { c++ } else if (a.data.isprev) { c-- } else { c = a.data.page } g(); var e = false, i = false; if (b.rotate) { e = true; i = true; if (c + 1 == 0) { c = f - 1 } if (c == f) { c = 0 } } var j = c == 0; var k = c + 1 == f; if (!b.rotate) { if (!j) { e = true } if (!k) { i = true } } if (b.prev && e) { b.prev.bind("click", { isprev: true }, h) } if (b.next && i) { b.next.bind("click", { isnext: true }, h) } var l = 0; d.each(function(a) { if (a + 1 > c * b.pagesize && l < b.pagesize) { if (b.fadein) { jQuery(this).fadeIn(1e3, function() { }) } else { jQuery(this).show() } l++ } else { jQuery(this).hide() } }); if (b.onchange) { var m = (c + 1) * b.pagesize - b.pagesize; var n = m + l - 1; b.onchange(d, { cfirst: m, clast: n, pageindex: c, viscount: l, isprev: a.data.isprev, isnext: a.data.isnext, isfirst: j, islast: k }) } return false } function g() { if (b.prev) { b.prev.unbind("click") } if (b.next) { b.next.unbind("click") } } var b = jQuery.extend({ pagesize: 1, prev: null, next: null, onchange: null, rotate: true, fadein: true }, a); var c = 0; var d = this; var e = d.length; var f = Math.ceil(e / b.pagesize); if (e > b.pagesize) { this.each(function(a) { if (a < b.pagesize) { jQuery(this).show() } else { jQuery(this).hide() } }) } if (b.prev) { b.prev = jQuery(b.prev) } if (b.next) { b.next = jQuery(b.next) } this.state = { pagecount: f, itemcount: e, prev: b.prev, next: b.next, pagesize: b.pagesize }; this.gotoPage = function(a) { if (a + 1 > f || a < 0) { alert("out of index"); return false } return h({ data: { page: a} }) }; g(); if (b.prev && b.rotate) { b.prev.bind("click", { isprev: true }, h) } if (b.next) { b.next.bind("click", { isnext: true }, h) } return d } })(jQuery)
