1/* 2* DISCLAIMER 3* 4* Do not edit or add to this file if you wish to upgrade PrestaShop to newer 5* versions in the future. If you wish to customize PrestaShop for your 6* needs please refer to http://www.prestashop.com for more information. 7* 8* @author PrestaShop SA <[email protected]> 9* Copyright (c) 2017 Klaus Hartl (stilbuero.de) 10* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 11* International Registered Trademark & Property of PrestaShop SA 12*/ 13 14(function($){ 15$.fn.easyPaginate = function (options) { 16 var defaults = { 17 paginateElement: 'li', 18 hashPage: 'page', 19 elementsPerPage: 10, 20 effect: 'default', 21 slideOffset: 200, 22 firstButton: true, 23 firstButtonText: '<<', 24 lastButton: true, 25 lastButtonText: '>>', 26 prevButton: true, 27 prevButtonText: '<', 28 nextButton: true, 29 nextButtonText: '>' 30 } 31 32 return this.each (function (instance) { 33 34 var plugin = Object; 35 plugin.el = $(this); 36 plugin.el.addClass('easyPaginateList'); 37 38 plugin.settings = { 39 pages: 0, 40 objElements: Object, 41 currentPage: 1 42 } 43 44 var getNbOfPages = function() { 45 return Math.ceil(plugin.settings.objElements.length / plugin.settings.elementsPerPage); 46 }; 47 48 var displayNav = function() { 49 htmlNav = '<div class="easyPaginateNav">'; 50 51 if(plugin.settings.firstButton) { 52 htmlNav += '<a href="#'+plugin.settings.hashPage+':1" title="First page" rel="1" class="first">'+plugin.settings.firstButtonText+'</a>'; 53 } 54 55 if(plugin.settings.prevButton) { 56 htmlNav += '<a href="" title="Previous" rel="" class="prev">'+plugin.settings.prevButtonText+'</a>'; 57 } 58 59 for(i = 1;i <= plugin.settings.pages;i++) { 60 htmlNav += '<a href="#'+plugin.settings.hashPage+':'+i+'" title="Page '+i+'" rel="'+i+'" class="page">'+i+'</a>'; 61 }; 62 63 if(plugin.settings.nextButton) { 64 htmlNav += '<a href="" title="Next" rel="" class="next">'+plugin.settings.nextButtonText+'</a>'; 65 } 66 67 if(plugin.settings.lastButton) { 68 htmlNav += '<a href="#'+plugin.settings.hashPage+':'+plugin.settings.pages+'" title="Last page" rel="'+plugin.settings.pages+'" class="last">'+plugin.settings.lastButtonText+'</a>'; 69 } 70 71 htmlNav += '</div>'; 72 plugin.nav = $(htmlNav); 73 plugin.nav.css({ 74 'width': plugin.el.width() 75 }); 76 plugin.el.after(plugin.nav); 77 78 $('.easyPaginateNav a.page, .easyPaginateNav a.first, .easyPaginateNav a.last', plugin).on('click', function(e) { 79 e.preventDefault(); 80 displayPage($(this).attr('rel')); 81 }); 82 83 $('.easyPaginateNav a.prev', plugin).on('click', function(e) { 84 e.preventDefault(); 85 page = plugin.settings.currentPage > 1?parseInt(plugin.settings.currentPage) - 1:1; 86 displayPage(page); 87 }); 88 89 $('.easyPaginateNav a.next', plugin).on('click', function(e) { 90 e.preventDefault(); 91 page = plugin.settings.currentPage < plugin.settings.pages?parseInt(plugin.settings.currentPage) + 1:plugin.settings.pages; 92 displayPage(page); 93 }); 94 }; 95 96 var displayPage = function(page, forceEffect) { 97 if(plugin.settings.currentPage != page) { 98 plugin.settings.currentPage = parseInt(page); 99 offsetStart = (page - 1) * plugin.settings.elementsPerPage; 100 offsetEnd = page * plugin.settings.elementsPerPage; 101 if(typeof(forceEffect) != 'undefined') { 102 eval("transition_"+forceEffect+"("+offsetStart+", "+offsetEnd+")"); 103 }else { 104 eval("transition_"+plugin.settings.effect+"("+offsetStart+", "+offsetEnd+")"); 105 } 106 107 plugin.nav.find('.current').removeClass('current'); 108 plugin.nav.find('a.page:eq('+(page - 1)+')').addClass('current'); 109 110 switch(plugin.settings.currentPage) { 111 case 1: 112 $('.easyPaginateNav a', plugin).removeClass('disabled'); 113 $('.easyPaginateNav a.first, .easyPaginateNav a.prev', plugin).addClass('disabled'); 114 break; 115 case plugin.settings.pages: 116 $('.easyPaginateNav a', plugin).removeClass('disabled'); 117 $('.easyPaginateNav a.last, .easyPaginateNav a.next', plugin).addClass('disabled'); 118 break; 119 default: 120 $('.easyPaginateNav a', plugin).removeClass('disabled'); 121 break; 122 } 123 } 124 }; 125 126 var transition_default = function(offsetStart, offsetEnd) { 127 plugin.currentElements.hide(); 128 plugin.currentElements = plugin.settings.objElements.slice(offsetStart, offsetEnd).clone(); 129 plugin.el.html(plugin.currentElements); 130 plugin.currentElements.show(); 131 }; 132 133 var transition_fade = function(offsetStart, offsetEnd) { 134 plugin.currentElements.fadeOut(); 135 plugin.currentElements = plugin.settings.objElements.slice(offsetStart, offsetEnd).clone(); 136 plugin.el.html(plugin.currentElements); 137 plugin.currentElements.fadeIn(); 138 }; 139 140 var transition_slide = function(offsetStart, offsetEnd) { 141 plugin.currentElements.animate({ 142 'margin-left': plugin.settings.slideOffset * -1, 143 'opacity': 0 144 }, function() { 145 $(this).remove(); 146 }); 147 148 plugin.currentElements = plugin.settings.objElements.slice(offsetStart, offsetEnd).clone(); 149 plugin.currentElements.css({ 150 'margin-left': plugin.settings.slideOffset, 151 'display': 'block', 152 'opacity': 0, 153 'min-width': plugin.el.width() / 2 154 }); 155 plugin.el.html(plugin.currentElements); 156 plugin.currentElements.animate({ 157 'margin-left': 0, 158 'opacity': 1 159 }); 160 }; 161 162 var transition_climb = function(offsetStart, offsetEnd) { 163 plugin.currentElements.each(function(i) { 164 var $objThis = $(this); 165 setTimeout(function() { 166 $objThis.animate({ 167 'margin-left': plugin.settings.slideOffset * -1, 168 'opacity': 0 169 }, function() { 170 $(this).remove(); 171 }); 172 }, i * 200); 173 }); 174 175 plugin.currentElements = plugin.settings.objElements.slice(offsetStart, offsetEnd).clone(); 176 plugin.currentElements.css({ 177 'margin-left': plugin.settings.slideOffset, 178 'display': 'block', 179 'opacity': 0, 180 'min-width': plugin.el.width() / 2 181 }); 182 plugin.el.html(plugin.currentElements); 183 plugin.currentElements.each(function(i) { 184 var $objThis = $(this); 185 setTimeout(function() { 186 $objThis.animate({ 187 'margin-left': 0, 188 'opacity': 1 189 }); 190 }, i * 200); 191 }); 192 }; 193 194 plugin.settings = $.extend({}, defaults, options); 195 196 plugin.currentElements = $([]); 197 plugin.settings.objElements = plugin.el.find(plugin.settings.paginateElement); 198 plugin.settings.pages = getNbOfPages(); 199 if(plugin.settings.pages > 1) { 200 plugin.el.html(); 201 202 // Here we go 203 displayNav(); 204 205 page = 1; 206 if(document.location.hash.indexOf('#'+plugin.settings.hashPage+':') != -1) { 207 page = parseInt(document.location.hash.replace('#'+plugin.settings.hashPage+':', '')); 208 if(page.length <= 0 || page < 1 || page > plugin.settings.pages) { 209 page = 1; 210 } 211 } 212 213 displayPage(page, 'default'); 214 } 215 }); 216}; 217})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.