By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,282 Members | 1,526 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,282 IT Pros & Developers. It's quick & easy.

JQuery Paginate Plugin

Fary4u
100+
P: 273
I've recently find some Paginate Plugin
but it's only came with NEXT & PRV

HERE IS THE CODE

Expand|Select|Wrap|Line Numbers
  1. eval(function(p,a,c,k,e,r){e=function(c)
  2.     {
  3.         return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))
  4.     };
  5.     if(!''.replace(/^/,String))
  6.         {
  7.             while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function()
  8.                 {
  9.                     return'\\w+'};c=1
  10.                 };
  11.             while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);
  12.             return p
  13.             }
  14.             ('o.L.M=5(c){c=o.N({3:6,2:C,s:t,u:"O",w:"P",p:"Q",x:"R",D:"S"},c);0 d;0 e;0 f=q;0 g=t;0 h=o(T);0 i;0 j;0 k=5(){h.y();e=h.z();4(h.z()>c.3){h.U(":V("+(c.3-1)+")").A();d=c.3;n()}};0 l=5(){4(!f){0 a=d+c.3;h.A();h.E(d,a).y();d=a;4(d>=e){f=t;i.B("r")}4(c.s)c.2.7("."+c.p).v(d/c.3);j.F("r");g=q}};0 m=5(){4(!g){0 a=d-c.3;h.A();h.E((a-c.3),a).y();d=a;4(d==c.3){g=t;j.B("r")}4(c.s)c.2.7("."+c.p).v(d/c.3);i.F("r");f=q}};0 n=5(){4(c.2===C){c.2=o(\'<G 8="W"></G>\');h.X(h.z()-1).H(c.2)}0 a=$(\'<a 8="\'+c.u+\'" I="#">&Y; Z</a><a 8="\'+c.w+\'" I="#">10 &11;</a>\');o(c.2).12(a);4(c.s){0 b=\'<9 8="\'+c.D+\'"><9 8="\'+c.p+\'"></9> / <9 8="\'+c.x+\'"></9></9>\';c.2.7("."+c.u).H(b);c.2.7("."+c.p).v(1);c.2.7("."+c.x).v(13.14(e/c.3))}i=c.2.7("."+c.w);j=c.2.7("."+c.u);j.B("r");i.J(5(){l();K q});j.J(5(){m();K q})};k()};',62,67,'var||pager|perpage|if|function||find|class|span|||||||||||||||jQuery|pagenumber|false|qp_disabled|showcounter|true|prev|text|next|totalnumber|show|size|hide|addClass|null|counter|slice|removeClass|div|after|href|click|return|fn|quickpaginate|extend|qp_next|qp_prev|qp_pagenumber|qp_totalnumber|qp_counter|this|filter|gt|qc_pager|eq|laquo|Prev|Next|raquo|append|Math|ceil'.split('|'),0,{}))
  15.  
it's return the page no.

Expand|Select|Wrap|Line Numbers
  1. $(function(){
  2. $("#shopping_list li").quickpaginate({ perpage: 4, pager : $("#shopping_list_counter") });
  3.     });
  4.  
i want something like next with page no.
Sep 24 '09 #1

✓ answered by Fary4u

yep sure & i always be there 4 evey one : )
also i've changed this code with my own requirments here's the code
Expand|Select|Wrap|Line Numbers
  1. jQuery.fn.quickpaginate = function (c) {
  2.     c = jQuery.extend({
  3.         perpage: 6,
  4.         pager: null,
  5.         showcounter: true,
  6.         prev: "qp_next",
  7.         next: "qp_prev",
  8.         pagenumber: "qp_pagenumber",
  9.         totalnumber: "qp_totalnumber",
  10.         counter: "qp_counter"
  11.     },
  12.     c);
  13.     var d;
  14.     var e;
  15.     var f = false;
  16.     var g = true;
  17.     var h = jQuery(this);
  18.     var i;
  19.     var j;
  20.     var k = function () {
  21.         h.show();
  22.         e = h.size();
  23.         if (h.size() > c.perpage) {
  24.             h.filter(":gt(" + (c.perpage - 1) + ")").hide();
  25.             d = c.perpage;
  26.             n()
  27.         }
  28.     };
  29.     var l = function () {
  30.         if (!f) {
  31.             var a = d + c.perpage;
  32.             h.hide();
  33.             h.slice(d, a).show();
  34.             d = a;
  35.             if (d >= e) {
  36.                 f = true;
  37.                 i.addClass("qp_disabled")
  38.             }
  39.             if (c.showcounter) c.pager.find("." + c.pagenumber).text(d / c.perpage);
  40.             j.removeClass("qp_disabled");
  41.             g = false
  42.         }
  43.     };
  44.     var m = function () {
  45.         if (!g) {
  46.             var a = d - c.perpage;
  47.             h.hide();
  48.             h.slice((a - c.perpage), a).show();
  49.             d = a;
  50.             if (d == c.perpage) {
  51.                 g = true;
  52.                 j.addClass("qp_disabled")
  53.             }
  54.             if (c.showcounter) c.pager.find("." + c.pagenumber).text(d / c.perpage);
  55.             i.removeClass("qp_disabled");
  56.             f = false
  57.         }
  58.     };
  59.     var n = function () {
  60.         if (c.pager === null) {
  61.             c.pager = jQuery('<div class="qc_pager"></div>');
  62.             h.eq(h.size() - 1).after(c.pager)
  63.         }
  64.         var a = $('<a class="' + c.prev + '" href="#"><img border=0 src=libs/L.jpg></a><a class="' + c.next + '" href="#"><img border=0 src=libs/R.jpg></a>');
  65.         jQuery(c.pager).append(a);
  66.         if (c.showcounter) {
  67.             var b = '<span class="' + c.counter + '"><span class="' + c.pagenumber + '"></span> / <span class="' + c.totalnumber + '"></span></span>';
  68.             c.pager.find("." + c.prev).after(b);
  69.             c.pager.find("." + c.pagenumber).text(1);
  70.             c.pager.find("." + c.totalnumber).text(Math.ceil(e / c.perpage))
  71.         }
  72.         i = c.pager.find("." + c.next);
  73.         j = c.pager.find("." + c.prev);
  74.         j.addClass("qp_disabled");
  75.         i.click(function () {
  76.             l();
  77.         });
  78.         j.click(function () {
  79.             m();
  80.         })
  81.     };
  82.     k()
  83. };

Share this Question
Share on Google+
10 Replies


Fary4u
100+
P: 273
the file name called jQuery.quickpaginate.packed.js

& Example is jQuery Quick Pagination
Sep 28 '09 #2

acoder
Expert Mod 15k+
P: 16,027
Your post is confusing. Does it come with next/prev or page numbers? You've said both:
but it's only came with NEXT & PRV
it's return the page no.
Usually, when code is obfuscated like this, you're better off writing your own, or finding one that already has the functionality, or is easily extendable.
Sep 28 '09 #3

Fary4u
100+
P: 273
Thanks for reply

regarding my post it's executed fine only problem with getting per page links
it's only brining result with NEXT & PREV

variables are followings

prev : The class name for the 'prev' link(s) => "qp_next"
next : The class name for the 'next' link(s) => "qp_prev"
counter : The class name for the span that wraps the counter => qp_counter
totalnumber : The class name for the span that wraps the total number of pages => "qp_totalnumber"
pagenumber : The class name for the span that wraps the current page count => "qp_pagenumber"
& " return page no " mean how many items you want to show on per page.

i'm sure you know about " jquery pagination " but have a look following link it's also based on same methord but in different way it's call " jquery quick paginate "

http://plugins.jquery.com/project/quick_paginate

http://projects.allmarkedup.com/jquery_quick_paginate/
Sep 29 '09 #4

acoder
Expert Mod 15k+
P: 16,027
Since this is not built-in, and you haven't written it, I would recommend that you just use one of the other plugins that does support page numbers.
Oct 1 '09 #5

Fary4u
100+
P: 273
well there is few plugins available for this pagnation

but now recently i came accross 1 advance thing that mostly JQuery came as packed code & it's very hard to read & understand, if you need to do something then all you need is to make it as unpacked & do you own programming.

thanx for ur reply
Oct 9 '09 #6

acoder
Expert Mod 15k+
P: 16,027
Yes, you posted the packed version (p,a,c,k,e,r should've been the clue), but an unpacked version is also available.
Oct 12 '09 #7

Fary4u
100+
P: 273
yep i've done my job what i'm looking for.
Oct 12 '09 #8

acoder
Expert Mod 15k+
P: 16,027
That's good to hear. Perhaps you could post your code for the benefit of others.
Oct 13 '09 #9

Fary4u
100+
P: 273
yep sure & i always be there 4 evey one : )
also i've changed this code with my own requirments here's the code
Expand|Select|Wrap|Line Numbers
  1. jQuery.fn.quickpaginate = function (c) {
  2.     c = jQuery.extend({
  3.         perpage: 6,
  4.         pager: null,
  5.         showcounter: true,
  6.         prev: "qp_next",
  7.         next: "qp_prev",
  8.         pagenumber: "qp_pagenumber",
  9.         totalnumber: "qp_totalnumber",
  10.         counter: "qp_counter"
  11.     },
  12.     c);
  13.     var d;
  14.     var e;
  15.     var f = false;
  16.     var g = true;
  17.     var h = jQuery(this);
  18.     var i;
  19.     var j;
  20.     var k = function () {
  21.         h.show();
  22.         e = h.size();
  23.         if (h.size() > c.perpage) {
  24.             h.filter(":gt(" + (c.perpage - 1) + ")").hide();
  25.             d = c.perpage;
  26.             n()
  27.         }
  28.     };
  29.     var l = function () {
  30.         if (!f) {
  31.             var a = d + c.perpage;
  32.             h.hide();
  33.             h.slice(d, a).show();
  34.             d = a;
  35.             if (d >= e) {
  36.                 f = true;
  37.                 i.addClass("qp_disabled")
  38.             }
  39.             if (c.showcounter) c.pager.find("." + c.pagenumber).text(d / c.perpage);
  40.             j.removeClass("qp_disabled");
  41.             g = false
  42.         }
  43.     };
  44.     var m = function () {
  45.         if (!g) {
  46.             var a = d - c.perpage;
  47.             h.hide();
  48.             h.slice((a - c.perpage), a).show();
  49.             d = a;
  50.             if (d == c.perpage) {
  51.                 g = true;
  52.                 j.addClass("qp_disabled")
  53.             }
  54.             if (c.showcounter) c.pager.find("." + c.pagenumber).text(d / c.perpage);
  55.             i.removeClass("qp_disabled");
  56.             f = false
  57.         }
  58.     };
  59.     var n = function () {
  60.         if (c.pager === null) {
  61.             c.pager = jQuery('<div class="qc_pager"></div>');
  62.             h.eq(h.size() - 1).after(c.pager)
  63.         }
  64.         var a = $('<a class="' + c.prev + '" href="#"><img border=0 src=libs/L.jpg></a><a class="' + c.next + '" href="#"><img border=0 src=libs/R.jpg></a>');
  65.         jQuery(c.pager).append(a);
  66.         if (c.showcounter) {
  67.             var b = '<span class="' + c.counter + '"><span class="' + c.pagenumber + '"></span> / <span class="' + c.totalnumber + '"></span></span>';
  68.             c.pager.find("." + c.prev).after(b);
  69.             c.pager.find("." + c.pagenumber).text(1);
  70.             c.pager.find("." + c.totalnumber).text(Math.ceil(e / c.perpage))
  71.         }
  72.         i = c.pager.find("." + c.next);
  73.         j = c.pager.find("." + c.prev);
  74.         j.addClass("qp_disabled");
  75.         i.click(function () {
  76.             l();
  77.         });
  78.         j.click(function () {
  79.             m();
  80.         })
  81.     };
  82.     k()
  83. };
Oct 19 '09 #10

acoder
Expert Mod 15k+
P: 16,027
Thanks for posting. I haven't checked the code, but if it's working well, it must be good.
Oct 26 '09 #11

Post your reply

Sign in to post your reply or Sign up for a free account.