components_pagination.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* ------------------------------------------------------------------------------
  2. *
  3. * # Pagination
  4. *
  5. * Specific JS code additions for components_pagination.html page
  6. *
  7. * ---------------------------------------------------------------------------- */
  8. // Setup module
  9. // ------------------------------
  10. var Pagination = function () {
  11. //
  12. // Setup module components
  13. //
  14. // Dynamic pagination
  15. var _componentPaginationDynamic = function() {
  16. if (!$().twbsPagination) {
  17. console.warn('Warning - sweet_alert.min.js is not loaded.');
  18. return;
  19. }
  20. // Basic
  21. $('.twbs-default').twbsPagination({
  22. totalPages: 35,
  23. visiblePages: 4,
  24. prev: 'Prev',
  25. first: null,
  26. last: null,
  27. onPageClick: function (event, page) {
  28. $('.twbs-content-default').text('Page #' + page + ' content');
  29. }
  30. });
  31. // Flat style
  32. $('.twbs-flat').twbsPagination({
  33. totalPages: 35,
  34. visiblePages: 4,
  35. prev: 'Prev',
  36. first: null,
  37. last: null,
  38. onPageClick: function (event, page) {
  39. $('.twbs-content-flat').text('Page #' + page + ' content');
  40. }
  41. });
  42. // Separated style
  43. $('.twbs-separated').twbsPagination({
  44. totalPages: 35,
  45. visiblePages: 4,
  46. prev: 'Prev',
  47. first: null,
  48. last: null,
  49. onPageClick: function (event, page) {
  50. $('.twbs-content-separated').text('Page #' + page + ' content');
  51. }
  52. });
  53. // Custom button text
  54. $('.twbs-prev-next').twbsPagination({
  55. totalPages: 35,
  56. visiblePages: 3,
  57. prev: '⇠',
  58. next: '⇢',
  59. first: '⇤',
  60. last: '⇥',
  61. onPageClick: function (event, page) {
  62. $('.twbs-content-prev-next').text('Page #' + page + ' content');
  63. }
  64. });
  65. // Custom start page
  66. $('.twbs-page-start').twbsPagination({
  67. totalPages: 35,
  68. visiblePages: 4,
  69. startPage: 3,
  70. prev: 'Prev',
  71. first: null,
  72. last: null,
  73. onPageClick: function (event, page) {
  74. $('.twbs-content-page-start').text('Page #' + page + ' content');
  75. }
  76. });
  77. // Set number of visible pages
  78. $('.twbs-visible-pages').twbsPagination({
  79. totalPages: 35,
  80. visiblePages: 2,
  81. prev: '←',
  82. next: '→',
  83. first: null,
  84. last: null,
  85. onPageClick: function (event, page) {
  86. $('.twbs-content-visible-pages').text('Page #' + page + ' content');
  87. }
  88. });
  89. };
  90. //
  91. // Return objects assigned to module
  92. //
  93. return {
  94. initComponents: function() {
  95. _componentPaginationDynamic();
  96. }
  97. }
  98. }();
  99. // Initialize module
  100. // ------------------------------
  101. document.addEventListener('DOMContentLoaded', function() {
  102. Pagination.initComponents();
  103. });