PageSourceSearch

https://aslpromo.com/JavaScript/jquery.carousel.js?rls=20260909

js aslpromo.com collected 2026-10-09 03:53:12 UTC 9,658 bytes, 227 lines download raw bytes

1if (typeof Object.create !== 'function') {
2    Object.create = function (o) {
3        function F() { }
4        F.prototype = o;
5        return new F();
6    };
7}
8(function ($) {
9    // ie alias
10    var headache = $.browser.msie && $.browser.version.substr(0, 1) < 9;
11
12    // carousel
13    var Carousel = {
14        settings: {
15            itemsPerPage: 1,
16            itemsPerTransition: 1,
17            noOfRows: 1,
18            pagination: true,
19            nextPrevLinks: true,
20            nextPrevLinksStyle: '',
21            pageInfo: true,
22            speed: 'normal',
23            easing: 'swing',
24            showingText: 'Showing',
25            entriesText: 'entries',
26            liWidth: '', // px or '%' (% will divide evenly within the mask)
27            callbackFunction: ''
28        },
29        init: function (el, options) {
30            if (!el.length) { return false; }
31            this.options = $.extend({}, this.settings, options);
32            this.itemIndex = 0;
33            this.container = el;
34            this.runner = this.container.find('ul');
35            this.runner.addClass('clearfix abs');
36            this.items = this.runner.children('li');
37            this.noOfItems = this.items.length;
38            if (this.options.noOfRows < 1) { this.options.noOfRows = 1; }
39
40            // if (this.noOfItems <= this.options.itemsPerPage) { return false; } // bail if there are too few items to paginate
41            this.setRunnerWidth();
42            this.noOfPages = Math.ceil((this.noOfItems - this.options.itemsPerPage) / this.options.itemsPerTransition) + 1;
43
44            /* WRAP THE items if there are multiple rows and number of items is greater than the amount on the page */
45            if (this.options.noOfRows > 1 && this.noOfItems > this.options.itemsPerPage) {
46                this.runner.wrapChildren({
47                    childElem: 'li',
48                    sets: this.options.itemsPerPage,
49                    wrapper: 'ul class="fltleft clearfix noMargin"'
50                });
51                this.insertMask();
52                maskwidth = this.mask.width();
53                divs = this.runner.find('ul').width(maskwidth);
54            } else {
55                this.insertMask();
56            }
57            /* set mask height so items can be of varying height */
58            this.mask.height(this.runner.height());
59
60            if (this.options.pagination) { this.insertPagination(); }
61            if (this.options.nextPrevLinks) { this.insertNextPrevLinks(); }
62            this.updateBtnStyles();
63            idx = this.itemIndex;
64            if ($.isFunction(this.options.callbackFunction)) {
65                this.options.callbackFunction.call(this, idx);
66            }
67        },
68        insertMask: function () {
69            this.runner.wrap('<div class="mask clearfix" />');
70            this.mask = this.container.find('div.mask');
71            this.toolbar = $('<div class="fg-toolbar ui-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix">')
72.insertAfter(this.mask);
73        },
74        setRunnerWidth: function () {
75            var perRowOnPage = Math.ceil(this.options.itemsPerPage / this.options.noOfRows);            
76            noOfItemsPerRow = (perRowOnPage * Math.ceil(this.noOfItems / this.options.itemsPerPage)); //Math.ceil(this.noOfItems / this.options.noOfRows);
77
78            if (this.options.liWidth.indexOf('%') >= 0) {
79
80                var outerWidth = this.container.outerWidth(true),
81                    liwidth = 0;
82
83                liwidth = (Math.ceil(this.container.outerWidth(true) / 3));
84
85                this.items.css('width', (liwidth === 0) ? 100 / perRowOnPage + '%' : liwidth);
86            } else if (this.options.liWidth) {
87                this.items.css('width', this.options.liWidth);
88                var liwidth = this.items.outerWidth(true);
89            } else {
90                var liwidth = this.items.outerWidth(true);
91            }
92
93            var width = liwidth * noOfItemsPerRow;
94            this.runner.width(width);
95        },
96        insertPagination: function () {
97            var i, links = [];
98            this.paginationLinks = $('<ol class="pagination-links fltleft" />');
99            for (i = 0; i < this.noOfPages; i++) {
100                links[i] = '<li><a href="#item-' + i + '">' + (i + 1) + '</a></li>';
101            }
102            this.paginationLinks
103.append(links.join(''))
104.appendTo(this.toolbar)
105.find('a')
106.bind('click.carousel', $.proxy(this, 'paginationHandler'));
107        },
108        paginationHandler: function (e) {
109            this.itemIndex = e.target.hash.substr(1).split('-')[1] * this.options.itemsPerTransition;
110            this.animate();
111            return false;
112        },
113        insertNextPrevLinks: function () {
114            this.prevLink = $('<a href="#" class="previous"><span class="' + this.options.nextPrevLinksStyle + ' iArrowRight">&lt;</span></a>')
115.bind('click.carousel', $.proxy(this, 'prevItem'));
116
117            this.nextLink = $('<a href="#" class="next"><span class="' + this.options.nextPrevLinksStyle + ' iArrowLeft">&gt;</span></a>')
118.bind('click.carousel', $.proxy(this, 'nextItem'));
119            if (this.options.pagination) {
120                this.prevLink.insertBefore(this.paginationLinks);
121                this.nextLink.insertAfter(this.paginationLinks);
122            } else {
123                this.prevLink.appendTo(this.toolbar)
124                this.nextLink.appendTo(this.toolbar)
125            }
126        },
127        insertInfo: function () {
128            var showingFrom = this.itemIndex + 1;
129            var showingTo = Math.ceil(this.itemIndex + this.options.itemsPerPage);
130
131            if (this.noOfItems == 0) { showingFrom = 0; }
132            if (showingTo > this.noOfItems || this.options.itemsPerPage > this.noOfItems) { showingTo = this.noOfItems; }
133
134            this.container.find('.dataTables_info').remove();
135            this.infoText = $('<div class="dataTables_info fltright">' + this.options.showingText + ' ' + showingFrom + ' to ' + showingTo + ' of ' + this.noOfItems + ' ' + this.options.entriesText + '</div>')
136.insertAfter(this.nextLink);
137        },
138        nextItem: function () {
139            this.itemIndex = this.itemIndex + this.options.itemsPerTransition;
140            this.animate();
141            return false;
142        },
143        prevItem: function () {
144            this.itemIndex = this.itemIndex - this.options.itemsPerTransition;
145            this.animate();
146            return false;
147        },
148        updateBtnStyles: function () {
149            if (this.options.pagination) {
150                this.paginationLinks
151.children('li')
152.removeClass('disabled')
153.eq(Math.ceil(this.itemIndex / this.options.itemsPerTransition))
154.addClass('disabled');
155                if (this.options.pageInfo) { this.insertInfo(); }
156            }
157
158            if (this.options.nextPrevLinks) {
159                this.toolbar.find('a span').removeClass('disabled');
160                if (this.itemIndex >= ((this.noOfPages * this.options.itemsPerPage) - this.options.itemsPerPage)) {
161                    this.toolbar.find('.next span').addClass('disabled');
162                }
163                if (this.itemIndex === 0) {
164                    this.toolbar.find('.previous span').addClass('disabled');
165                }
166            }
167        },
168        animate: function () {
169            var nextItem, pos;
170            // console.log('itemIndex' + this.itemIndex);
171            // console.log('what' + this.options.itemsPerPage * this.noOfPages-1);
172            // check whether there are enough items to animate to
173            if (this.itemIndex > (this.options.itemsPerPage * (this.noOfPages - 1))) {
174                this.itemIndex = this.options.itemsPerPage * (this.noOfPages - 1);
175                // console.log('itemIndexUb' + this.itemIndex);
176            }
177            if (this.itemIndex < 0) {
178                this.itemIndex = 0; // go to first
179            }
180            // console.log('itemIndex' + this.itemIndex);
181            var moveToPos = this.itemIndex;
182
183            nextItem = this.items.eq(moveToPos);
184            pos = nextItem.position();
185            idx = this.itemIndex;
186            this.updateBtnStyles();
187            if (headache) {
188                this.runner.stop().animate({ left: -pos.left }, this.options.speed, this.options.easing);
189            }
190            else {
191                this.mask.stop().animate({ scrollLeft: pos.left }, this.options.speed, this.options.easing);
192            }
193        }
194    };
195    // bridge
196    $.fn.carousel = function(options) {
197		return this.each(function() {
198			var obj = Object.create(Carousel);
199			obj.init($(this), options);
200			$.data(this, 'carousel', obj);
201		});
202	};
203})(jQuery);
204
205(function ($) {
206    $.fn.wrapChildren = function (options) {
207        var options = $.extend({
208            childElem: undefined,
209            sets: 1,
210            wrapper: 'div'
211        }, options || {});
212        if (options.childElem === undefined) return this;
213        return this.each(function () {
214            var elems = $(this).children(options.childElem);
215            var arr = [];
216
217            elems.each(function (i, value) {
218                arr.push(value);
219                if (((i + 1) % options.sets === 0) || (i === elems.length - 1)) {
220                    var set = $(arr);
221                    arr = [];
222                    set.wrapAll($("<" + options.wrapper + ">"));
223                }
224            });
225        });
226    }
227})(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.