PageSourceSearch

https://mosgu.ru/local/templates/x5/js/jquery.jcarousel-pagination.js?17702873886383

js mosgu.ru collected 2026-10-02 06:58:31 UTC 6,383 bytes, 200 lines download raw bytes

vendor: 4,214 bytes, lines 1-124
1/*! jCarousel - v0.3.1 - 2014-04-26
2* http://sorgalla.com/jcarousel
3* Copyright (c) 2014 Jan Sorgalla; Licensed MIT */
4(function($) {
5    'use strict';
6
7    $.jCarousel.plugin('jcarouselPagination', {
8        _options: {
9            perPage: null,
10            item: function(page) {
11                return '<a href="#' + page + '">' + page + '</a>';
12            },
13            event:  'click',
14            method: 'scroll'
15        },
16        _carouselItems: null,
17        _pages: {},
18        _items: {},
19        _currentPage: null,
20        _init: function() {
21            this.onDestroy = $.proxy(function() {
22                this._destroy();
23                this.carousel()
24                    .one('jcarousel:createend', $.proxy(this._create, this));
25            }, this);
26            this.onReload = $.proxy(this._reload, this);
27            this.onScroll = $.proxy(this._update, this);
28        },
29        _create: function() {
30            this.carousel()
31                .one('jcarousel:destroy', this.onDestroy)
32                .on('jcarousel:reloadend', this.onReload)
33                .on('jcarousel:scrollend', this.onScroll);
34
35            this._reload();
36        },
37        _destroy: function() {
38            this._clear();
39
40            this.carousel()
41                .off('jcarousel:destroy', this.onDestroy)
42                .off('jcarousel:reloadend', this.onReload)
43                .off('jcarousel:scrollend', this.onScroll);
44
45            this._carouselItems = null;
46        },
47        _reload: function() {
48            var perPage = this.options('perPage');
49
50            this._pages = {};
51            this._items = {};
52
53            // Calculate pages
54            if ($.isFunction(perPage)) {
55                perPage = perPage.call(this);
56            }
57
58            if (perPage == null) {
59                this._pages = this._calculatePages();
60            } else {
61                var pp    = parseInt(perPage, 10) || 0,
62                    items = this._getCarouselItems(),
63                    page  = 1,
64                    i     = 0,
65                    curr;
66
67                while (true) {
68                    curr = items.eq(i++);
69
70                    if (curr.length === 0) {
71                        break;
72                    }
73
74                    if (!this._pages[page]) {
75                        this._pages[page] = curr;
76                    } else {
77                        this._pages[page] = this._pages[page].add(curr);
78                    }
79
80                    if (i % pp === 0) {
81                        page++;
82                    }
83                }
84            }
85
86            this._clear();
87
88            var self     = this,
89                carousel = this.carousel().data('jcarousel'),
90                element  = this._element,
91                item     = this.options('item'),
92                numCarouselItems = this._getCarouselItems().length;
93
94            $.each(this._pages, function(page, carouselItems) {
95                var currItem = self._items[page] = $(item.call(self, page, carouselItems));
96
97                currItem.on(self.options('event') + '.jcarouselpagination', $.proxy(function() {
98                    var target = carouselItems.eq(0);
99
100                    // If circular wrapping enabled, ensure correct scrolling direction
101                    if (carousel.circular) {
102                        var currentIndex = carousel.index(carousel.target()),
103                            newIndex     = carousel.index(target);
104
105                        if (parseFloat(page) > parseFloat(self._currentPage)) {
106                            if (newIndex < currentIndex) {
107                                target = '+=' + (numCarouselItems - currentIndex + newIndex);
108                            }
109                        } else {
110                            if (newIndex > currentIndex) {
111                                target = '-=' + (currentIndex + (numCarouselItems - newIndex));
112                            }
113                        }
114                    }
115
116                    carousel[this.options('method')](target);
117                }, self));
118
119                element.append(currItem);
120            });
121
122            this._update();
123        },
124        _update: function() {
vendor: 2,169 bytes, lines 125-200
125            var target = this.carousel().jcarousel('target'),
126                currentPage;
127
128            $.each(this._pages, function(page, carouselItems) {
129                carouselItems.each(function() {
130                    if (target.is(this)) {
131                        currentPage = page;
132                        return false;
133                    }
134                });
135
136                if (currentPage) {
137                    return false;
138                }
139            });
140
141            if (this._currentPage !== currentPage) {
142                this._trigger('inactive', this._items[this._currentPage]);
143                this._trigger('active', this._items[currentPage]);
144            }
145
146            this._currentPage = currentPage;
147        },
148        items: function() {
149            return this._items;
150        },
151        reloadCarouselItems: function() {
152            this._carouselItems = null;
153            return this;
154        },
155        _clear: function() {
156            this._element.empty();
157            this._currentPage = null;
158        },
159        _calculatePages: function() {
160            var carousel = this.carousel().data('jcarousel'),
161                items    = this._getCarouselItems(),
162                clip     = carousel.clipping(),
163                wh       = 0,
164                idx      = 0,
165                page     = 1,
166                pages    = {},
167                curr;
168
169            while (true) {
170                curr = items.eq(idx++);
171
172                if (curr.length === 0) {
173                    break;
174                }
175
176                if (!pages[page]) {
177                    pages[page] = curr;
178                } else {
179                    pages[page] = pages[page].add(curr);
180                }
181
182                wh += carousel.dimension(curr);
183
184                if (wh >= clip) {
185                    page++;
186                    wh = 0;
187                }
188            }
189
190            return pages;
191        },
192        _getCarouselItems: function() {
193            if (!this._carouselItems) {
194                this._carouselItems = this.carousel().jcarousel('items');
195            }
196
197            return this._carouselItems;
198        }
199    });
200}(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.