PageSourceSearch

https://garderivieredesoutaouais.ca/wp-content/themes/riverkeeper/jquery.cycle.lite.js?ver=7.1.2

js garderivieredesoutaouais.ca collected 2026-10-03 19:01:37 UTC 7,927 bytes, 235 lines download raw bytes

1/*!
2 * jQuery Cycle Lite Plugin
3 * http://malsup.com/jquery/cycle/lite/
4 * Copyright (c) 2008-2012 M. Alsup
5 * Version: 1.7 (20-FEB-2013)
6 * Dual licensed under the MIT and GPL licenses:
7 * http://www.opensource.org/licenses/mit-license.php
8 * http://www.gnu.org/licenses/gpl.html
9 * Requires: jQuery v1.3.2 or later
10 */
11;(function($) {
12"use strict";
13
14var ver = 'Lite-1.7';
15var msie = /MSIE/.test(navigator.userAgent);
16
17$.fn.cycle = function(options) {
18    return this.each(function() {
19        options = options || {};
20        
21        if (this.cycleTimeout) 
22            clearTimeout(this.cycleTimeout);
23
24        this.cycleTimeout = 0;
25        this.cyclePause = 0;
26        
27        var $cont = $(this);
28        var $slides = options.slideExpr ? $(options.slideExpr, this) : $cont.children();
29        var els = $slides.get();
30        if (els.length < 2) {
31            if (window.console)
32                console.log('terminating; too few slides: ' + els.length);
33            return; // don't bother
34        }
35
36        // support metadata plugin (v1.0 and v2.0)
37        var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {});
38        var meta = $.isFunction($cont.data) ? $cont.data(opts.metaAttr) : null;
39        if (meta)
40            opts = $.extend(opts, meta);
41            
42        opts.before = opts.before ? [opts.before] : [];
43        opts.after = opts.after ? [opts.after] : [];
44        opts.after.unshift(function(){ opts.busy=0; });
45            
46        // allow shorthand overrides of width, height and timeout
47        var cls = this.className;
48        opts.width = parseInt((cls.match(/w:(\d+)/)||[])[1], 10) || opts.width;
49        opts.height = parseInt((cls.match(/h:(\d+)/)||[])[1], 10) || opts.height;
50        opts.timeout = parseInt((cls.match(/t:(\d+)/)||[])[1], 10) || opts.timeout;
51
52        if ($cont.css('position') == 'static') 
53            $cont.css('position', 'relative');
54        if (opts.width) 
55            $cont.width(opts.width);
56        if (opts.height && opts.height != 'auto') 
57            $cont.height(opts.height);
58
59        var first = 0;
60        $slides.css({position: 'absolute', top:0}).each(function(i) {
61            $(this).css('z-index', els.length-i);
62        });
63        
64        $(els[first]).css('opacity',1).show(); // opacity bit needed to handle reinit case
65        if (msie) 
66            els[first].style.removeAttribute('filter');
67
68        if (opts.fit && opts.width) 
69            $slides.width(opts.width);
70        if (opts.fit && opts.height && opts.height != 'auto') 
71            $slides.height(opts.height);
72        if (opts.pause) 
73            $cont.hover(function(){this.cyclePause=1;}, function(){this.cyclePause=0;});
74
75        var txFn = $.fn.cycle.transitions[opts.fx];
76        if (txFn)
77            txFn($cont, $slides, opts);
78        
79        $slides.each(function() {
80            var $el = $(this);
81            this.cycleH = (opts.fit && opts.height) ? opts.height : $el.height();
82            this.cycleW = (opts.fit && opts.width) ? opts.width : $el.width();
83        });
84
85        if (opts.cssFirst)
86            $($slides[first]).css(opts.cssFirst);
87
88        if (opts.timeout) {
89            // ensure that timeout and speed settings are sane
90            if (opts.speed.constructor == String)
91                opts.speed = {slow: 600, fast: 200}[opts.speed] || 400;
92            if (!opts.sync)
93                opts.speed = opts.speed / 2;
94            while((opts.timeout - opts.speed) < 250)
95                opts.timeout += opts.speed;
96        }
97        opts.speedIn = opts.speed;
98        opts.speedOut = opts.speed;
99
100        opts.slideCount = els.length;
101        opts.currSlide = first;
102        opts.nextSlide = 1;
103
104        // fire artificial events
105        var e0 = $slides[first];
106        if (opts.before.length)
107            opts.before[0].apply(e0, [e0, e0, opts, true]);
108        if (opts.after.length > 1)
109            opts.after[1].apply(e0, [e0, e0, opts, true]);
110        
111        if (opts.click && !opts.next)
112            opts.next = opts.click;
113        if (opts.next)
114            $(opts.next).unbind('click.cycle').bind('click.cycle', function(){return advance(els,opts,opts.rev?-1:1);});
115        if (opts.prev)
116            $(opts.prev).unbind('click.cycle').bind('click.cycle', function(){return advance(els,opts,opts.rev?1:-1);});
117
118        if (opts.timeout)
119            this.cycleTimeout = setTimeout(function() {
120                go(els,opts,0,!opts.rev);
121            }, opts.timeout + (opts.delay||0));
122    });
123};
124
125function go(els, opts, manual, fwd) {
126    if (opts.busy) 
127        return;
128    var p = els[0].parentNode, curr = els[opts.currSlide], next = els[opts.nextSlide];
129    if (p.cycleTimeout === 0 && !manual) 
130        return;
131
132    if (manual || !p.cyclePause) {
133        if (opts.before.length)
134            $.each(opts.before, function(i,o) { o.apply(next, [curr, next, opts, fwd]); });
135        var after = function() {
136            if (msie)
137                this.style.removeAttribute('filter');
138            $.each(opts.after, function(i,o) { o.apply(next, [curr, next, opts, fwd]); });
139            queueNext(opts);
140        };
141
142        if (opts.nextSlide != opts.currSlide) {
143            opts.busy = 1;
144            $.fn.cycle.custom(curr, next, opts, after);
145        }
146        var roll = (opts.nextSlide + 1) == els.length;
147        opts.nextSlide = roll ? 0 : opts.nextSlide+1;
148        opts.currSlide = roll ? els.length-1 : opts.nextSlide-1;
149    } else {
150      queueNext(opts);
151    }
152
153    function queueNext(opts) {
154        if (opts.timeout)
155            p.cycleTimeout = setTimeout(function() { go(els,opts,0,!opts.rev); }, opts.timeout);
156    }
157}
158
159// advance slide forward or back
160function advance(els, opts, val) {
161    var p = els[0].parentNode, timeout = p.cycleTimeout;
162    if (timeout) {
163        clearTimeout(timeout);
164        p.cycleTimeout = 0;
165    }
166    opts.nextSlide = opts.currSlide + val;
167    if (opts.nextSlide < 0) {
168        opts.nextSlide = els.length - 1;
169    }
170    else if (opts.nextSlide >= els.length) {
171        opts.nextSlide = 0;
172    }
173    go(els, opts, 1, val>=0);
174    return false;
175}
176
177$.fn.cycle.custom = function(curr, next, opts, cb) {
178    var $l = $(curr), $n = $(next);
179    $n.css(opts.cssBefore);
180    var fn = function() {$n.animate(opts.animIn, opts.speedIn, opts.easeIn, cb);};
181    $l.animate(opts.animOut, opts.speedOut, opts.easeOut, function() {
182        $l.css(opts.cssAfter);
183        if (!opts.sync)
184            fn();
185    });
186    if (opts.sync)
187        fn();
188};
189
190$.fn.cycle.transitions = {
191    fade: function($cont, $slides, opts) {
192        $slides.not(':eq(0)').hide();
193        opts.cssBefore = { opacity: 0, display: 'block' };
194        opts.cssAfter  = { display: 'none' };
195        opts.animOut = { opacity: 0 };
196        opts.animIn = { opacity: 1 };
197    },
198    fadeout: function($cont, $slides, opts) {
199        opts.before.push(function(curr,next,opts,fwd) {
200            $(curr).css('zIndex',opts.slideCount + (fwd === true ? 1 : 0));
201            $(next).css('zIndex',opts.slideCount + (fwd === true ? 0 : 1));
202        });
203        $slides.not(':eq(0)').hide();
204        opts.cssBefore = { opacity: 1, display: 'block', zIndex: 1 };
205        opts.cssAfter  = { display: 'none', zIndex: 0 };
206        opts.animOut = { opacity: 0 };
207        opts.animIn = { opacity: 1 };
208    }
209};
210
211$.fn.cycle.ver = function() { return ver; };
212
213// @see: http://malsup.com/jquery/cycle/lite/
214$.fn.cycle.defaults = {
215    animIn:        {},
216    animOut:       {},
217    fx:           'fade',
218    after:         null,
219    before:        null,
220    cssBefore:     {},
221    cssAfter:      {},
222    delay:         0,
223    fit:           0,
224    height:       'auto',
225    metaAttr:     'cycle',
226    next:          null,
227    pause:         false,
228    prev:          null,
229    speed:         1000,
230    slideExpr:     null,
231    sync:          true,
232    timeout:       4000
233};
234
235})(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.