Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. jQuery(function($){
  2. var plimit=5; //Change this number to change the number of visible links in the pagination.
  3. var ellipsesHTML = "<li style=\"background-color:#FFF;\">...</li>";
  4. var paginator = $(".lcp_paginator li");
  5. var lencache = paginator.length;
  6. if(lencache > 0 && lencache>plimit+1)
  7. {
  8. if(paginator.eq(0).text()=="1")
  9. {
  10. var i=plimit-1;
  11. while(lencache>plimit+1)
  12. {
  13. paginator.eq(paginator.length-i).remove();
  14. i++;
  15. lencache--;
  16. }
  17. $(".lcp_paginator li").eq(plimit-3).after(ellipsesHTML);
  18. }
  19. else if(paginator.eq(lencache-1).text()==lencache-1)
  20. {
  21. var i=lencache-3;
  22. while(lencache > plimit)
  23. {
  24. paginator.eq(i).remove();
  25. i--;
  26. lencache--;
  27. }
  28. $(".lcp_paginator li").eq(plimit-3).after(ellipsesHTML);
  29. }
  30. else
  31. {
  32. for(var i=0;i<lencache;i++)
  33. {
  34. if(paginator.eq(i).html()==i)
  35. {
  36. var removals = [];
  37. var cachedElem = paginator.eq(i);
  38. var postEllipse = false;
  39. var preEllipse = false;
  40. //found our center point. Kill everything around it.
  41. for(var x=2;x<lencache;x++)
  42. {
  43. if(x!=i && x < lencache-2)
  44. {
  45. removals.push(x);
  46. }
  47. }
  48. if(i > 2)
  49. {
  50. preEllipse=true;
  51. }
  52. if(i<lencache-3)
  53. {
  54. postEllipse=true;
  55. }
  56. for(var z=0;z<removals.length;z++)
  57. {
  58. paginator.eq(removals[z]).remove();
  59. }
  60. if(postEllipse)
  61. {
  62. cachedElem.after(ellipsesHTML);
  63. }
  64. if(preEllipse)
  65. {
  66. cachedElem.before(ellipsesHTML);
  67. }
  68. break;
  69. }
  70. }
  71. }
  72. }
  73. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement