PageSourceSearch

https://www.gladiator.nl/assets/js/jquery.bootpag2.js

js gladiator.nl collected 2026-10-09 01:18:14 UTC 9,257 bytes, 204 lines download raw bytes

1/**
2 * @preserve
3 * bootpag - jQuery plugin for dynamic pagination
4 *
5 * Copyright (c) 2013 [email protected]
6 *
7 * Licensed under the MIT license:
8 *   http://www.opensource.org/licenses/mit-license.php
9 *
10 * Project home:
11 *   http://botmonster.com/jquery-bootpag/
12 *
13 * Version:  1.1 (Howie)
14 *
15 *
16 * If you want to use items per page / total items instead of total pages
17 * do not define 'total' in settings, instead define itemsPerPage and totalItems
18 *
19 * To toggle directional buttons such as First, Prev, Next and Last, set showHideDirections to TRUE
20 *
21 * To leap from page 1 to the first page of the next set, set 'leap' to TRUE
22 *
23 * Declare 'on' method first since we want to be listening for first event before it's triggered
24 * Declare 'on' method after instantiating bootpag to skip the initial page event
25 * or
26 * Set 'skipInitPageEvent' to TRUE to skip the initial page event
27 *
28 */
29//(function($, window) {
30(function($) {
31    'use strict';
32    $.fn.bootpag = function(options) {
33        var $owner = this,
34            initPageEvent = false,
35            settings = $.extend({
36                total: null,
37                itemsPerPage: 15,
38                totalItems: 0,
39                page: 1,
40                skipInitPageEvent: true,
41                maxVisible: null,
42                leaps: true,
43                href: 'javascript:void(0);',
44                hrefVariable: '{{number}}',
45                classPrefix: 'bootpag-',
46                activeClass: '',
47                showHideDirections: false,
48                hidePagerForSinglePage: true,
49                first: '«',
50                prev: '‹',
51                next: '›',
52                last: '»',
53                debug: false
54            }, $owner.data('settings') || {}, options || {}), renderPage = function($bootpag, page, button) {
55
56				var current_page = false;
57				var hash = location.hash;
58				// get saved page nr from session
59				var matches = location.hash.match( /page-([^&]+)/i );
60				if (matches) {
61					page = parseInt(matches[1]);
62					logDebug('render hash page: ' + page);
63				} else {
64					logDebug('render page: ' + page);
65				}
66
67                var lp, maxV = settings.maxVisible == 0 ? 1 : settings.maxVisible,
68                    step = settings.maxVisible == 1 ? 0 : 1,
69                    vis = Math.floor((page - 1) / maxV) * maxV,
70                    $page = $bootpag.find('li'),
71                    activeClass = (settings.activeClass) ? settings.activeClass : settings.classPrefix + 'active';
72
73                //settings.page = page = page < 0 ? 0 : page > settings.total ? settings.total : page;
74				settings.page = page < 0 ? 1 : page > settings.total ? settings.total : page;
75
76				//current page
77                $page.removeClass('disabled ' + activeClass);
78                lp = page - 1 < 1 ? 1 : settings.leaps && page - 1 >= settings.maxVisible ? Math.floor((page - 1) / maxV) * maxV : page - 1;
79
80                //first page
81                $page.parent().find('.' + settings.classPrefix + 'first').toggle((page !== 1 && settings.showHideDirections) || !settings.showHideDirections);
82                //prev page
83                $page.parent().find('.' + settings.classPrefix + 'prev').toggleClass('disabled', page === 1).attr('data-lp', lp).find('a').attr('href', href(lp)).toggle((page !== 1 && settings.showHideDirections) || !settings.showHideDirections);
84                var step = settings.maxVisible == 1 ? 0 : 1;
85                lp = page + 1 > settings.total ? settings.total : settings.leaps && settings.maxVisible > 1 && page + 1 < settings.total - settings.maxVisible ? vis + settings.maxVisible + step : page + 1;
86
87                // next
88                $page.parent().find('.' + settings.classPrefix + 'next') //.last()
89                .toggleClass('disabled', page === settings.total).attr('data-lp', lp).find('a').attr('href', href(lp)).toggle((page !== settings.total && settings.showHideDirections) || !settings.showHideDirections);
90                // last
91                $page.parent().find('.' + settings.classPrefix + 'last').toggle((page !== settings.total && settings.showHideDirections) || !sett
91ings.showHideDirections);
92                var $currPage = $page.filter('[data-lp=' + page + ']');
93                var class_exceptions = '.' + settings.classPrefix + 'next,.' + settings.classPrefix + 'prev,.' + settings.classPrefix + 'first,.' + settings.classPrefix + 'last';
94                if (!$currPage.not(class_exceptions).length) {
95                    var d = page <= vis ? -settings.maxVisible : 0;
96                    $page.not(class_exceptions).each(function(index) {
97                        lp = index + 1 + vis + d;
98                        //console.log('reassign lp: ' + lp);
99                        $(this).attr('data-lp', lp).toggle(lp <= settings.total).find('a').html(lp).attr('href', href(lp));
100                    });
101                    $currPage = $page.filter('[data-lp=' + page + ']');
102                }
103                $currPage.filter('[data-button-type=page]').addClass(activeClass);
104                $currPage.addClass('disabled');
105                $owner.data('settings', settings);
106
107                // check if event should be triggered
108                // normally we don't trigger the event on init becuase it may cause a loop
109                if ((!settings.skipInitPageEvent && !initPageEvent) || initPageEvent) {
110                  var params = {
111                    page: page,
112                    button: (button) ? button.data('button-type') : 'init'
113                  };
114                  $owner.trigger('page', params);
115                  logDebug('triggering end');
116                }
117                initPageEvent = true;
118            },
119            //function href(c){
120            href = function(c) {
121				//console.log('Gebeurd aLTIJD');
122                return settings.href.replace(settings.hrefVariable, c);
123            };
124
125        $owner.init = function() {
126
127            logDebug('init', settings);
128            if ($.isNumeric(settings.itemsPerPage) && $.isNumeric(settings.totalItems)) {
129                settings.total = Math.ceil(settings.totalItems / settings.itemsPerPage);
130            }
131            if (settings.total <= 0) {
132                return $owner;
133            }
134            if (!$.isNumeric(settings.maxVisible) && !settings.maxVisible) {
135                settings.maxVisible = settings.total;
136            }
137
138            $owner.data('settings', settings);
139            $owner.each(function() {
140
141                var $bootpag, lp, me = $(this),
142                    p = ['<ul class="pagination bootpag">'];
143
144                me.find('ul.bootpag').remove();
145
146				if (settings.hidePagerForSinglePage && settings.total == 1) {
147                  return $owner;
148                }
149
150                if (settings.first) {
151                    p.push('<li data-button-type="first" data-lp="1" class="' + settings.classPrefix + 'first"><a href="' + href(1) + '">' + settings.first + '</a></li>');
152                }
153                if (settings.prev) {
154                    p.push('<li data-button-type="prev" data-lp="1" class="' + settings.classPrefix + 'prev"><a href="' + href(1) + '">' + settings.prev + '</a></li>');
155                }
156                for (var c = 1; c <= Math.min(settings.total, settings.maxVisible); c++) {
157                    p.push('<li data-button-type="page" data-lp="' + c + '" class="' + settings.classPrefix + 'page-' + c + '"><a href="' + href(c) + '">' + c + '</a></li>');
158                }
159                if (settings.next) {
160                    lp = settings.leaps && settings.total + 1 > settings.maxVisible ? Math.min(settings.maxVisible + 1, settings.total) : 2;
161                    logDebug('lp: ' + lp);
162                    p.push('<li data-button-type="next" data-lp="' + lp + '" class="' + settings.classPrefix + 'next"><a href="' + href(lp) + '">' + settings.next + '</a></li>');
163                }
164                if (settings.last) {
165                    p.push('<li data-button-type="last" data-lp="' + settings.total + '" class="' + settings.classPrefix + 'last"><a href="' + href(settings.total) + '">' + settings.last + '</a></li>');
166                }
167
168                p.push('</ul>');
169
170                me.append(p.join(''));
171                $bootpag = me.find('ul.bootpag');
172                me.find('li').bind('click', function paginationClick(index) {
173                    var me = $(this);
174
175					if (me.hasClass('disabled')) {
176                    	return;
177                    }
178                    var page = parseInt(me.attr('data-lp'), 10);
179					logDebug('paginationClick');
180					//so save current page nr to session storage
181					window.location.hash = '#page-' + page;
182
183					$('html, body').animate({scrollTop: 300 }, 200);
184                    renderPage($bootpag, page, me);
185                });
186
187				$('html, body').animate({scrollTop: 300 }, 200);
188                renderPage($bootpag, settings.page, null);
189
190            });
191        };
192
193        var logDebug = function() {
194          if (settings.debug) {
195            var message = Array.prototype.slice.call(arguments, 0);
196            console.log.apply(console, message);
197          }
198        }
199
200        $owner.init();
201        return;
202    }
203}(jQuery));
204

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.