cycle2-rails 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/Gemfile.lock +19 -18
- data/README.md +24 -2
- data/Rakefile +64 -5
- data/app/assets/javascripts/jquery.cycle2.all.js +11 -0
- data/app/assets/javascripts/jquery.cycle2.autoheight.js +132 -0
- data/app/assets/javascripts/jquery.cycle2.caption.js +44 -0
- data/app/assets/javascripts/jquery.cycle2.caption2.js +69 -0
- data/app/assets/javascripts/jquery.cycle2.carousel.js +271 -0
- data/app/assets/javascripts/jquery.cycle2.center.js +65 -0
- data/app/assets/javascripts/jquery.cycle2.command.js +182 -0
- data/app/assets/javascripts/jquery.cycle2.core.js +654 -0
- data/app/assets/javascripts/jquery.cycle2.hash.js +53 -0
- data/app/assets/javascripts/jquery.cycle2.ie-fade.js +48 -0
- data/app/assets/javascripts/jquery.cycle2.js +11 -0
- data/app/assets/javascripts/jquery.cycle2.loader.js +107 -0
- data/app/assets/javascripts/jquery.cycle2.pager.js +95 -0
- data/app/assets/javascripts/jquery.cycle2.prevnext.js +67 -0
- data/app/assets/javascripts/jquery.cycle2.progressive.js +133 -0
- data/app/assets/javascripts/jquery.cycle2.scrollVert.js +17 -0
- data/app/assets/javascripts/jquery.cycle2.shuffle.js +64 -0
- data/app/assets/javascripts/jquery.cycle2.swipe.js +72 -0
- data/app/assets/javascripts/jquery.cycle2.tile.js +133 -0
- data/app/assets/javascripts/jquery.cycle2.tmpl.js +42 -0
- data/app/assets/javascripts/jquery.cycle2.video.js +68 -0
- data/lib/cycle2-rails/version.rb +1 -1
- metadata +31 -15
- data/vendor/assets/javascripts/cycle2-rails/jquery.cycle2.js +0 -1490
@@ -0,0 +1,271 @@
|
|
1
|
+
//= require jquery.cycle2
|
2
|
+
|
3
|
+
/*! carousel transition plugin for Cycle2; version: 20130528 */
|
4
|
+
(function($) {
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
$( document ).on('cycle-bootstrap', function( e, opts, API ) {
|
8
|
+
if ( opts.fx !== 'carousel' )
|
9
|
+
return;
|
10
|
+
|
11
|
+
API.getSlideIndex = function( el ) {
|
12
|
+
var slides = this.opts()._carouselWrap.children();
|
13
|
+
var i = slides.index( el );
|
14
|
+
return i % slides.length;
|
15
|
+
};
|
16
|
+
|
17
|
+
// override default 'next' function
|
18
|
+
API.next = function() {
|
19
|
+
var count = opts.reverse ? -1 : 1;
|
20
|
+
if ( opts.allowWrap === false && ( opts.currSlide + count ) > opts.slideCount - opts.carouselVisible )
|
21
|
+
return;
|
22
|
+
opts.API.advanceSlide( count );
|
23
|
+
opts.API.trigger('cycle-next', [ opts ]).log('cycle-next');
|
24
|
+
};
|
25
|
+
|
26
|
+
});
|
27
|
+
|
28
|
+
|
29
|
+
$.fn.cycle.transitions.carousel = {
|
30
|
+
// transition API impl
|
31
|
+
preInit: function( opts ) {
|
32
|
+
opts.hideNonActive = false;
|
33
|
+
|
34
|
+
opts.container.on('cycle-destroyed', $.proxy(this.onDestroy, opts.API));
|
35
|
+
// override default API implementation
|
36
|
+
opts.API.stopTransition = this.stopTransition;
|
37
|
+
|
38
|
+
// issue #10
|
39
|
+
for (var i=0; i < opts.startingSlide; i++) {
|
40
|
+
opts.container.append( opts.slides[0] );
|
41
|
+
}
|
42
|
+
},
|
43
|
+
|
44
|
+
// transition API impl
|
45
|
+
postInit: function( opts ) {
|
46
|
+
var i, j, slide, pagerCutoffIndex, wrap;
|
47
|
+
var vert = opts.carouselVertical;
|
48
|
+
if (opts.carouselVisible && opts.carouselVisible > opts.slideCount)
|
49
|
+
opts.carouselVisible = opts.slideCount - 1;
|
50
|
+
var visCount = opts.carouselVisible || opts.slides.length;
|
51
|
+
var slideCSS = { display: vert ? 'block' : 'inline-block', position: 'static' };
|
52
|
+
|
53
|
+
// required styles
|
54
|
+
opts.container.css({ position: 'relative', overflow: 'hidden' });
|
55
|
+
opts.slides.css( slideCSS );
|
56
|
+
|
57
|
+
opts._currSlide = opts.currSlide;
|
58
|
+
|
59
|
+
// wrap slides in a div; this div is what is animated
|
60
|
+
wrap = $('<div class="cycle-carousel-wrap"></div>')
|
61
|
+
.prependTo( opts.container )
|
62
|
+
.css({ margin: 0, padding: 0, top: 0, left: 0, position: 'absolute' })
|
63
|
+
.append( opts.slides );
|
64
|
+
|
65
|
+
opts._carouselWrap = wrap;
|
66
|
+
|
67
|
+
if ( !vert )
|
68
|
+
wrap.css('white-space', 'nowrap');
|
69
|
+
|
70
|
+
if ( opts.allowWrap !== false ) {
|
71
|
+
// prepend and append extra slides so we don't see any empty space when we
|
72
|
+
// near the end of the carousel. for fluid containers, add even more clones
|
73
|
+
// so there is plenty to fill the screen
|
74
|
+
// @todo: optimzie this based on slide sizes
|
75
|
+
|
76
|
+
for ( j=0; j < (opts.carouselVisible === undefined ? 2 : 1); j++ ) {
|
77
|
+
for ( i=0; i < opts.slideCount; i++ ) {
|
78
|
+
wrap.append( opts.slides[i].cloneNode(true) );
|
79
|
+
}
|
80
|
+
i = opts.slideCount;
|
81
|
+
while ( i-- ) { // #160, #209
|
82
|
+
wrap.prepend( opts.slides[i].cloneNode(true) );
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
wrap.find('.cycle-slide-active').removeClass('cycle-slide-active');
|
87
|
+
opts.slides.eq(opts.startingSlide).addClass('cycle-slide-active');
|
88
|
+
}
|
89
|
+
|
90
|
+
if ( opts.pager && opts.allowWrap === false ) {
|
91
|
+
// hide "extra" pagers
|
92
|
+
pagerCutoffIndex = opts.slideCount - visCount;
|
93
|
+
$( opts.pager ).children().filter( ':gt('+pagerCutoffIndex+')' ).hide();
|
94
|
+
}
|
95
|
+
|
96
|
+
opts._nextBoundry = opts.slideCount - opts.carouselVisible;
|
97
|
+
|
98
|
+
this.prepareDimensions( opts );
|
99
|
+
},
|
100
|
+
|
101
|
+
prepareDimensions: function( opts ) {
|
102
|
+
var dim, offset, pagerCutoffIndex, tmp;
|
103
|
+
var vert = opts.carouselVertical;
|
104
|
+
var visCount = opts.carouselVisible || opts.slides.length;
|
105
|
+
|
106
|
+
if ( opts.carouselFluid && opts.carouselVisible ) {
|
107
|
+
if ( ! opts._carouselResizeThrottle ) {
|
108
|
+
// fluid container AND fluid slides; slides need to be resized to fit container
|
109
|
+
this.fluidSlides( opts );
|
110
|
+
}
|
111
|
+
}
|
112
|
+
else if ( opts.carouselVisible && opts.carouselSlideDimension ) {
|
113
|
+
dim = visCount * opts.carouselSlideDimension;
|
114
|
+
opts.container[ vert ? 'height' : 'width' ]( dim );
|
115
|
+
}
|
116
|
+
else if ( opts.carouselVisible ) {
|
117
|
+
dim = visCount * $(opts.slides[0])[vert ? 'outerHeight' : 'outerWidth'](true);
|
118
|
+
opts.container[ vert ? 'height' : 'width' ]( dim );
|
119
|
+
}
|
120
|
+
// else {
|
121
|
+
// // fluid; don't size the container
|
122
|
+
// }
|
123
|
+
|
124
|
+
offset = ( opts.carouselOffset || 0 );
|
125
|
+
if ( opts.allowWrap !== false ) {
|
126
|
+
if ( opts.carouselSlideDimension ) {
|
127
|
+
offset -= ( (opts.slideCount + opts.currSlide) * opts.carouselSlideDimension );
|
128
|
+
}
|
129
|
+
else {
|
130
|
+
// calculate offset based on actual slide dimensions
|
131
|
+
tmp = opts._carouselWrap.children();
|
132
|
+
for (var j=0; j < (opts.slideCount + opts.currSlide); j++) {
|
133
|
+
offset -= $(tmp[j])[vert?'outerHeight':'outerWidth'](true);
|
134
|
+
}
|
135
|
+
}
|
136
|
+
}
|
137
|
+
|
138
|
+
opts._carouselWrap.css( vert ? 'top' : 'left', offset );
|
139
|
+
},
|
140
|
+
|
141
|
+
fluidSlides: function( opts ) {
|
142
|
+
var timeout;
|
143
|
+
var slide = opts.slides.eq(0);
|
144
|
+
var adjustment = slide.outerWidth() - slide.width();
|
145
|
+
var prepareDimensions = this.prepareDimensions;
|
146
|
+
|
147
|
+
// throttle resize event
|
148
|
+
$(window).on( 'resize', resizeThrottle);
|
149
|
+
|
150
|
+
opts._carouselResizeThrottle = resizeThrottle;
|
151
|
+
onResize();
|
152
|
+
|
153
|
+
function resizeThrottle() {
|
154
|
+
clearTimeout( timeout );
|
155
|
+
timeout = setTimeout( onResize, 20 );
|
156
|
+
}
|
157
|
+
|
158
|
+
function onResize() {
|
159
|
+
opts._carouselWrap.stop( false, true );
|
160
|
+
var slideWidth = opts.container.width() / opts.carouselVisible;
|
161
|
+
slideWidth = Math.ceil( slideWidth - adjustment );
|
162
|
+
opts._carouselWrap.children().width( slideWidth );
|
163
|
+
if ( opts._sentinel )
|
164
|
+
opts._sentinel.width( slideWidth );
|
165
|
+
prepareDimensions( opts );
|
166
|
+
}
|
167
|
+
},
|
168
|
+
|
169
|
+
// transition API impl
|
170
|
+
transition: function( opts, curr, next, fwd, callback ) {
|
171
|
+
var moveBy, props = {};
|
172
|
+
var hops = opts.nextSlide - opts.currSlide;
|
173
|
+
var vert = opts.carouselVertical;
|
174
|
+
var speed = opts.speed;
|
175
|
+
|
176
|
+
// handle all the edge cases for wrapping & non-wrapping
|
177
|
+
if ( opts.allowWrap === false ) {
|
178
|
+
fwd = hops > 0;
|
179
|
+
var currSlide = opts._currSlide;
|
180
|
+
var maxCurr = opts.slideCount - opts.carouselVisible;
|
181
|
+
if ( hops > 0 && opts.nextSlide > maxCurr && currSlide == maxCurr ) {
|
182
|
+
hops = 0;
|
183
|
+
}
|
184
|
+
else if ( hops > 0 && opts.nextSlide > maxCurr ) {
|
185
|
+
hops = opts.nextSlide - currSlide - (opts.nextSlide - maxCurr);
|
186
|
+
}
|
187
|
+
else if ( hops < 0 && opts.currSlide > maxCurr && opts.nextSlide > maxCurr ) {
|
188
|
+
hops = 0;
|
189
|
+
}
|
190
|
+
else if ( hops < 0 && opts.currSlide > maxCurr ) {
|
191
|
+
hops += opts.currSlide - maxCurr;
|
192
|
+
}
|
193
|
+
else
|
194
|
+
currSlide = opts.currSlide;
|
195
|
+
|
196
|
+
moveBy = this.getScroll( opts, vert, currSlide, hops );
|
197
|
+
opts.API.opts()._currSlide = opts.nextSlide > maxCurr ? maxCurr : opts.nextSlide;
|
198
|
+
}
|
199
|
+
else {
|
200
|
+
if ( fwd && opts.nextSlide === 0 ) {
|
201
|
+
// moving from last slide to first
|
202
|
+
moveBy = this.getDim( opts, opts.currSlide, vert );
|
203
|
+
callback = this.genCallback( opts, fwd, vert, callback );
|
204
|
+
}
|
205
|
+
else if ( !fwd && opts.nextSlide == opts.slideCount - 1 ) {
|
206
|
+
// moving from first slide to last
|
207
|
+
moveBy = this.getDim( opts, opts.currSlide, vert );
|
208
|
+
callback = this.genCallback( opts, fwd, vert, callback );
|
209
|
+
}
|
210
|
+
else {
|
211
|
+
moveBy = this.getScroll( opts, vert, opts.currSlide, hops );
|
212
|
+
}
|
213
|
+
}
|
214
|
+
|
215
|
+
props[ vert ? 'top' : 'left' ] = fwd ? ( "-=" + moveBy ) : ( "+=" + moveBy );
|
216
|
+
|
217
|
+
// throttleSpeed means to scroll slides at a constant rate, rather than
|
218
|
+
// a constant speed
|
219
|
+
if ( opts.throttleSpeed )
|
220
|
+
speed = (moveBy / $(opts.slides[0])[vert ? 'height' : 'width']() ) * opts.speed;
|
221
|
+
|
222
|
+
opts._carouselWrap.animate( props, speed, opts.easing, callback );
|
223
|
+
},
|
224
|
+
|
225
|
+
getDim: function( opts, index, vert ) {
|
226
|
+
var slide = $( opts.slides[index] );
|
227
|
+
return slide[ vert ? 'outerHeight' : 'outerWidth'](true);
|
228
|
+
},
|
229
|
+
|
230
|
+
getScroll: function( opts, vert, currSlide, hops ) {
|
231
|
+
var i, moveBy = 0;
|
232
|
+
|
233
|
+
if (hops > 0) {
|
234
|
+
for (i=currSlide; i < currSlide+hops; i++)
|
235
|
+
moveBy += this.getDim( opts, i, vert);
|
236
|
+
}
|
237
|
+
else {
|
238
|
+
for (i=currSlide; i > currSlide+hops; i--)
|
239
|
+
moveBy += this.getDim( opts, i, vert);
|
240
|
+
}
|
241
|
+
return moveBy;
|
242
|
+
},
|
243
|
+
|
244
|
+
genCallback: function( opts, fwd, vert, callback ) {
|
245
|
+
// returns callback fn that resets the left/top wrap position to the "real" slides
|
246
|
+
return function() {
|
247
|
+
var pos = $(opts.slides[opts.nextSlide]).position();
|
248
|
+
var offset = 0 - pos[vert?'top':'left'] + (opts.carouselOffset || 0);
|
249
|
+
opts._carouselWrap.css( opts.carouselVertical ? 'top' : 'left', offset );
|
250
|
+
callback();
|
251
|
+
};
|
252
|
+
},
|
253
|
+
|
254
|
+
// core API override
|
255
|
+
stopTransition: function() {
|
256
|
+
var opts = this.opts();
|
257
|
+
opts.slides.stop( false, true );
|
258
|
+
opts._carouselWrap.stop( false, true );
|
259
|
+
},
|
260
|
+
|
261
|
+
// core API supplement
|
262
|
+
onDestroy: function( e ) {
|
263
|
+
var opts = this.opts();
|
264
|
+
if ( opts._carouselResizeThrottle )
|
265
|
+
$( window ).off( 'resize', opts._carouselResizeThrottle );
|
266
|
+
opts.slides.prependTo( opts.container );
|
267
|
+
opts._carouselWrap.remove();
|
268
|
+
}
|
269
|
+
};
|
270
|
+
|
271
|
+
})(jQuery);
|
@@ -0,0 +1,65 @@
|
|
1
|
+
//= require jquery.cycle2
|
2
|
+
|
3
|
+
/*! center plugin for Cycle2; version: 20130324 */
|
4
|
+
(function($) {
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
$.extend($.fn.cycle.defaults, {
|
8
|
+
centerHorz: false,
|
9
|
+
centerVert: false
|
10
|
+
});
|
11
|
+
|
12
|
+
$(document).on( 'cycle-pre-initialize', function( e, opts ) {
|
13
|
+
if ( !opts.centerHorz && !opts.centerVert )
|
14
|
+
return;
|
15
|
+
|
16
|
+
// throttle resize event
|
17
|
+
var timeout, timeout2;
|
18
|
+
|
19
|
+
$(window).on( 'resize orientationchange', resize );
|
20
|
+
|
21
|
+
opts.container.on( 'cycle-destroyed', destroy );
|
22
|
+
|
23
|
+
opts.container.on( 'cycle-initialized cycle-slide-added cycle-slide-removed', function( e, opts, slideOpts, slide ) {
|
24
|
+
adjustActive();
|
25
|
+
});
|
26
|
+
|
27
|
+
adjustActive();
|
28
|
+
|
29
|
+
function resize() {
|
30
|
+
clearTimeout( timeout );
|
31
|
+
timeout = setTimeout( adjustActive, 50 );
|
32
|
+
}
|
33
|
+
|
34
|
+
function destroy( e, opts ) {
|
35
|
+
clearTimeout( timeout );
|
36
|
+
clearTimeout( timeout2 );
|
37
|
+
$( window ).off( 'resize orientationchange', resize );
|
38
|
+
}
|
39
|
+
|
40
|
+
function adjustAll() {
|
41
|
+
opts.slides.each( adjustSlide );
|
42
|
+
}
|
43
|
+
|
44
|
+
function adjustActive() {
|
45
|
+
/*jshint validthis: true */
|
46
|
+
adjustSlide.apply( opts.container.find( opts.slideActiveClass ) );
|
47
|
+
clearTimeout( timeout2 );
|
48
|
+
timeout2 = setTimeout( adjustAll, 50 );
|
49
|
+
}
|
50
|
+
|
51
|
+
function adjustSlide() {
|
52
|
+
/*jshint validthis: true */
|
53
|
+
var slide = $(this);
|
54
|
+
var contW = opts.container.width();
|
55
|
+
var contH = opts.container.height();
|
56
|
+
var w = slide.width();
|
57
|
+
var h = slide.height();
|
58
|
+
if (opts.centerHorz && w < contW)
|
59
|
+
slide.css( 'marginLeft', (contW - w) / 2 );
|
60
|
+
if (opts.centerVert && h < contH)
|
61
|
+
slide.css( 'marginTop', (contH - h) / 2 );
|
62
|
+
}
|
63
|
+
});
|
64
|
+
|
65
|
+
})(jQuery);
|
@@ -0,0 +1,182 @@
|
|
1
|
+
//= require jquery.cycle2.core
|
2
|
+
|
3
|
+
/*! command plugin for Cycle2; version: 20130525.1 */
|
4
|
+
(function($) {
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
var c2 = $.fn.cycle;
|
8
|
+
|
9
|
+
$.fn.cycle = function( options ) {
|
10
|
+
var cmd, cmdFn, opts;
|
11
|
+
var args = $.makeArray( arguments );
|
12
|
+
|
13
|
+
if ( $.type( options ) == 'number' ) {
|
14
|
+
return this.cycle( 'goto', options );
|
15
|
+
}
|
16
|
+
|
17
|
+
if ( $.type( options ) == 'string' ) {
|
18
|
+
return this.each(function() {
|
19
|
+
var cmdArgs;
|
20
|
+
cmd = options;
|
21
|
+
opts = $(this).data('cycle.opts');
|
22
|
+
|
23
|
+
if ( opts === undefined ) {
|
24
|
+
c2.log('slideshow must be initialized before sending commands; "' + cmd + '" ignored');
|
25
|
+
return;
|
26
|
+
}
|
27
|
+
else {
|
28
|
+
cmd = cmd == 'goto' ? 'jump' : cmd; // issue #3; change 'goto' to 'jump' internally
|
29
|
+
cmdFn = opts.API[ cmd ];
|
30
|
+
if ( $.isFunction( cmdFn )) {
|
31
|
+
cmdArgs = $.makeArray( args );
|
32
|
+
cmdArgs.shift();
|
33
|
+
return cmdFn.apply( opts.API, cmdArgs );
|
34
|
+
}
|
35
|
+
else {
|
36
|
+
c2.log( 'unknown command: ', cmd );
|
37
|
+
}
|
38
|
+
}
|
39
|
+
});
|
40
|
+
}
|
41
|
+
else {
|
42
|
+
return c2.apply( this, arguments );
|
43
|
+
}
|
44
|
+
};
|
45
|
+
|
46
|
+
// copy props
|
47
|
+
$.extend( $.fn.cycle, c2 );
|
48
|
+
|
49
|
+
$.extend( c2.API, {
|
50
|
+
next: function() {
|
51
|
+
var opts = this.opts();
|
52
|
+
if ( opts.busy && ! opts.manualTrump )
|
53
|
+
return;
|
54
|
+
|
55
|
+
var count = opts.reverse ? -1 : 1;
|
56
|
+
if ( opts.allowWrap === false && ( opts.currSlide + count ) >= opts.slideCount )
|
57
|
+
return;
|
58
|
+
|
59
|
+
opts.API.advanceSlide( count );
|
60
|
+
opts.API.trigger('cycle-next', [ opts ]).log('cycle-next');
|
61
|
+
},
|
62
|
+
|
63
|
+
prev: function() {
|
64
|
+
var opts = this.opts();
|
65
|
+
if ( opts.busy && ! opts.manualTrump )
|
66
|
+
return;
|
67
|
+
var count = opts.reverse ? 1 : -1;
|
68
|
+
if ( opts.allowWrap === false && ( opts.currSlide + count ) < 0 )
|
69
|
+
return;
|
70
|
+
|
71
|
+
opts.API.advanceSlide( count );
|
72
|
+
opts.API.trigger('cycle-prev', [ opts ]).log('cycle-prev');
|
73
|
+
},
|
74
|
+
|
75
|
+
destroy: function() {
|
76
|
+
this.stop(); //#204
|
77
|
+
|
78
|
+
var opts = this.opts();
|
79
|
+
var clean = $.isFunction( $._data ) ? $._data : $.noop; // hack for #184 and #201
|
80
|
+
clearTimeout(opts.timeoutId);
|
81
|
+
opts.timeoutId = 0;
|
82
|
+
opts.API.stop();
|
83
|
+
opts.API.trigger( 'cycle-destroyed', [ opts ] ).log('cycle-destroyed');
|
84
|
+
opts.container.removeData();
|
85
|
+
clean( opts.container[0], 'parsedAttrs', false );
|
86
|
+
|
87
|
+
// #75; remove inline styles
|
88
|
+
if ( ! opts.retainStylesOnDestroy ) {
|
89
|
+
opts.container.removeAttr( 'style' );
|
90
|
+
opts.slides.removeAttr( 'style' );
|
91
|
+
opts.slides.removeClass( 'cycle-slide-active' );
|
92
|
+
}
|
93
|
+
opts.slides.each(function() {
|
94
|
+
$(this).removeData();
|
95
|
+
clean( this, 'parsedAttrs', false );
|
96
|
+
});
|
97
|
+
},
|
98
|
+
|
99
|
+
jump: function( index ) {
|
100
|
+
// go to the requested slide
|
101
|
+
var fwd;
|
102
|
+
var opts = this.opts();
|
103
|
+
if ( opts.busy && ! opts.manualTrump )
|
104
|
+
return;
|
105
|
+
var num = parseInt( index, 10 );
|
106
|
+
if (isNaN(num) || num < 0 || num >= opts.slides.length) {
|
107
|
+
opts.API.log('goto: invalid slide index: ' + num);
|
108
|
+
return;
|
109
|
+
}
|
110
|
+
if (num == opts.currSlide) {
|
111
|
+
opts.API.log('goto: skipping, already on slide', num);
|
112
|
+
return;
|
113
|
+
}
|
114
|
+
opts.nextSlide = num;
|
115
|
+
clearTimeout(opts.timeoutId);
|
116
|
+
opts.timeoutId = 0;
|
117
|
+
opts.API.log('goto: ', num, ' (zero-index)');
|
118
|
+
fwd = opts.currSlide < opts.nextSlide;
|
119
|
+
opts.API.prepareTx( true, fwd );
|
120
|
+
},
|
121
|
+
|
122
|
+
stop: function() {
|
123
|
+
var opts = this.opts();
|
124
|
+
var pauseObj = opts.container;
|
125
|
+
clearTimeout(opts.timeoutId);
|
126
|
+
opts.timeoutId = 0;
|
127
|
+
opts.API.stopTransition();
|
128
|
+
if ( opts.pauseOnHover ) {
|
129
|
+
if ( opts.pauseOnHover !== true )
|
130
|
+
pauseObj = $( opts.pauseOnHover );
|
131
|
+
pauseObj.off('mouseenter mouseleave');
|
132
|
+
}
|
133
|
+
opts.API.trigger('cycle-stopped', [ opts ]).log('cycle-stopped');
|
134
|
+
},
|
135
|
+
|
136
|
+
reinit: function() {
|
137
|
+
var opts = this.opts();
|
138
|
+
opts.API.destroy();
|
139
|
+
opts.container.cycle();
|
140
|
+
},
|
141
|
+
|
142
|
+
remove: function( index ) {
|
143
|
+
var opts = this.opts();
|
144
|
+
var slide, slideToRemove, slides = [], slideNum = 1;
|
145
|
+
for ( var i=0; i < opts.slides.length; i++ ) {
|
146
|
+
slide = opts.slides[i];
|
147
|
+
if ( i == index ) {
|
148
|
+
slideToRemove = slide;
|
149
|
+
}
|
150
|
+
else {
|
151
|
+
slides.push( slide );
|
152
|
+
$( slide ).data('cycle.opts').slideNum = slideNum;
|
153
|
+
slideNum++;
|
154
|
+
}
|
155
|
+
}
|
156
|
+
if ( slideToRemove ) {
|
157
|
+
opts.slides = $( slides );
|
158
|
+
opts.slideCount--;
|
159
|
+
$( slideToRemove ).remove();
|
160
|
+
if (index == opts.currSlide) {
|
161
|
+
opts.API.advanceSlide( 1 );
|
162
|
+
}
|
163
|
+
|
164
|
+
opts.API.trigger('cycle-slide-removed', [ opts, index, slideToRemove ]).log('cycle-slide-removed');
|
165
|
+
opts.API.updateView();
|
166
|
+
}
|
167
|
+
}
|
168
|
+
|
169
|
+
});
|
170
|
+
|
171
|
+
// listen for clicks on elements with data-cycle-cmd attribute
|
172
|
+
$(document).on('click.cycle', '[data-cycle-cmd]', function(e) {
|
173
|
+
// issue cycle command
|
174
|
+
e.preventDefault();
|
175
|
+
var el = $(this);
|
176
|
+
var command = el.data('cycle-cmd');
|
177
|
+
var context = el.data('cycle-context') || '.cycle-slideshow';
|
178
|
+
$(context).cycle(command, el.data('cycle-arg'));
|
179
|
+
});
|
180
|
+
|
181
|
+
|
182
|
+
})(jQuery);
|