Version Description
- Initial release of Meteor Slides.
Download this release
Release Info
Developer | jleuze |
Plugin | Meteor Slides |
Version | 1.0 |
Comparing to | |
See all releases |
Version 1.0
- css/meteor-slides-admin.css +3 -0
- images/slides-icon-20x20.png +0 -0
- images/slides-icon-32x32.png +0 -0
- js/jquery.cycle.all.js +1304 -0
- js/slideshow.js +18 -0
- meteor-slides-plugin.php +386 -0
- meteor-slides-settings.php +103 -0
- meteor-slideshow.php +27 -0
- readme.txt +49 -0
- screenshot-1.jpg +0 -0
- screenshot-2.jpg +0 -0
css/meteor-slides-admin.css
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
#wpwrap #icon-edit {
|
2 |
+
background: url('../images/slides-icon-32x32.png') no-repeat top left;
|
3 |
+
}
|
images/slides-icon-20x20.png
ADDED
Binary file
|
images/slides-icon-32x32.png
ADDED
Binary file
|
js/jquery.cycle.all.js
ADDED
@@ -0,0 +1,1304 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*!
|
2 |
+
* jQuery Cycle Plugin (with Transition Definitions)
|
3 |
+
* Examples and documentation at: http://jquery.malsup.com/cycle/
|
4 |
+
* Copyright (c) 2007-2010 M. Alsup
|
5 |
+
* Version: 2.86 (05-APR-2010)
|
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.2.6 or later
|
10 |
+
*/
|
11 |
+
;(function($) {
|
12 |
+
|
13 |
+
var ver = '2.86';
|
14 |
+
|
15 |
+
// if $.support is not defined (pre jQuery 1.3) add what I need
|
16 |
+
if ($.support == undefined) {
|
17 |
+
$.support = {
|
18 |
+
opacity: !($.browser.msie)
|
19 |
+
};
|
20 |
+
}
|
21 |
+
|
22 |
+
function debug(s) {
|
23 |
+
if ($.fn.cycle.debug)
|
24 |
+
log(s);
|
25 |
+
}
|
26 |
+
function log() {
|
27 |
+
if (window.console && window.console.log)
|
28 |
+
window.console.log('[cycle] ' + Array.prototype.join.call(arguments,' '));
|
29 |
+
};
|
30 |
+
|
31 |
+
// the options arg can be...
|
32 |
+
// a number - indicates an immediate transition should occur to the given slide index
|
33 |
+
// a string - 'pause', 'resume', 'toggle', 'next', 'prev', 'stop', 'destroy' or the name of a transition effect (ie, 'fade', 'zoom', etc)
|
34 |
+
// an object - properties to control the slideshow
|
35 |
+
//
|
36 |
+
// the arg2 arg can be...
|
37 |
+
// the name of an fx (only used in conjunction with a numeric value for 'options')
|
38 |
+
// the value true (only used in first arg == 'resume') and indicates
|
39 |
+
// that the resume should occur immediately (not wait for next timeout)
|
40 |
+
|
41 |
+
$.fn.cycle = function(options, arg2) {
|
42 |
+
var o = { s: this.selector, c: this.context };
|
43 |
+
|
44 |
+
// in 1.3+ we can fix mistakes with the ready state
|
45 |
+
if (this.length === 0 && options != 'stop') {
|
46 |
+
if (!$.isReady && o.s) {
|
47 |
+
log('DOM not ready, queuing slideshow');
|
48 |
+
$(function() {
|
49 |
+
$(o.s,o.c).cycle(options,arg2);
|
50 |
+
});
|
51 |
+
return this;
|
52 |
+
}
|
53 |
+
// is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
|
54 |
+
log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
|
55 |
+
return this;
|
56 |
+
}
|
57 |
+
|
58 |
+
// iterate the matched nodeset
|
59 |
+
return this.each(function() {
|
60 |
+
var opts = handleArguments(this, options, arg2);
|
61 |
+
if (opts === false)
|
62 |
+
return;
|
63 |
+
|
64 |
+
opts.updateActivePagerLink = opts.updateActivePagerLink || $.fn.cycle.updateActivePagerLink;
|
65 |
+
|
66 |
+
// stop existing slideshow for this container (if there is one)
|
67 |
+
if (this.cycleTimeout)
|
68 |
+
clearTimeout(this.cycleTimeout);
|
69 |
+
this.cycleTimeout = this.cyclePause = 0;
|
70 |
+
|
71 |
+
var $cont = $(this);
|
72 |
+
var $slides = opts.slideExpr ? $(opts.slideExpr, this) : $cont.children();
|
73 |
+
var els = $slides.get();
|
74 |
+
if (els.length < 2) {
|
75 |
+
log('terminating; too few slides: ' + els.length);
|
76 |
+
return;
|
77 |
+
}
|
78 |
+
|
79 |
+
var opts2 = buildOptions($cont, $slides, els, opts, o);
|
80 |
+
if (opts2 === false)
|
81 |
+
return;
|
82 |
+
|
83 |
+
var startTime = opts2.continuous ? 10 : getTimeout(opts2.currSlide, opts2.nextSlide, opts2, !opts2.rev);
|
84 |
+
|
85 |
+
// if it's an auto slideshow, kick it off
|
86 |
+
if (startTime) {
|
87 |
+
startTime += (opts2.delay || 0);
|
88 |
+
if (startTime < 10)
|
89 |
+
startTime = 10;
|
90 |
+
debug('first timeout: ' + startTime);
|
91 |
+
this.cycleTimeout = setTimeout(function(){go(els,opts2,0,!opts2.rev)}, startTime);
|
92 |
+
}
|
93 |
+
});
|
94 |
+
};
|
95 |
+
|
96 |
+
// process the args that were passed to the plugin fn
|
97 |
+
function handleArguments(cont, options, arg2) {
|
98 |
+
if (cont.cycleStop == undefined)
|
99 |
+
cont.cycleStop = 0;
|
100 |
+
if (options === undefined || options === null)
|
101 |
+
options = {};
|
102 |
+
if (options.constructor == String) {
|
103 |
+
switch(options) {
|
104 |
+
case 'destroy':
|
105 |
+
case 'stop':
|
106 |
+
var opts = $(cont).data('cycle.opts');
|
107 |
+
if (!opts)
|
108 |
+
return false;
|
109 |
+
cont.cycleStop++; // callbacks look for change
|
110 |
+
if (cont.cycleTimeout)
|
111 |
+
clearTimeout(cont.cycleTimeout);
|
112 |
+
cont.cycleTimeout = 0;
|
113 |
+
$(cont).removeData('cycle.opts');
|
114 |
+
if (options == 'destroy')
|
115 |
+
destroy(opts);
|
116 |
+
return false;
|
117 |
+
case 'toggle':
|
118 |
+
cont.cyclePause = (cont.cyclePause === 1) ? 0 : 1;
|
119 |
+
checkInstantResume(cont.cyclePause, arg2, cont);
|
120 |
+
return false;
|
121 |
+
case 'pause':
|
122 |
+
cont.cyclePause = 1;
|
123 |
+
return false;
|
124 |
+
case 'resume':
|
125 |
+
cont.cyclePause = 0;
|
126 |
+
checkInstantResume(false, arg2, cont);
|
127 |
+
return false;
|
128 |
+
case 'prev':
|
129 |
+
case 'next':
|
130 |
+
var opts = $(cont).data('cycle.opts');
|
131 |
+
if (!opts) {
|
132 |
+
log('options not found, "prev/next" ignored');
|
133 |
+
return false;
|
134 |
+
}
|
135 |
+
$.fn.cycle[options](opts);
|
136 |
+
return false;
|
137 |
+
default:
|
138 |
+
options = { fx: options };
|
139 |
+
};
|
140 |
+
return options;
|
141 |
+
}
|
142 |
+
else if (options.constructor == Number) {
|
143 |
+
// go to the requested slide
|
144 |
+
var num = options;
|
145 |
+
options = $(cont).data('cycle.opts');
|
146 |
+
if (!options) {
|
147 |
+
log('options not found, can not advance slide');
|
148 |
+
return false;
|
149 |
+
}
|
150 |
+
if (num < 0 || num >= options.elements.length) {
|
151 |
+
log('invalid slide index: ' + num);
|
152 |
+
return false;
|
153 |
+
}
|
154 |
+
options.nextSlide = num;
|
155 |
+
if (cont.cycleTimeout) {
|
156 |
+
clearTimeout(cont.cycleTimeout);
|
157 |
+
cont.cycleTimeout = 0;
|
158 |
+
}
|
159 |
+
if (typeof arg2 == 'string')
|
160 |
+
options.oneTimeFx = arg2;
|
161 |
+
go(options.elements, options, 1, num >= options.currSlide);
|
162 |
+
return false;
|
163 |
+
}
|
164 |
+
return options;
|
165 |
+
|
166 |
+
function checkInstantResume(isPaused, arg2, cont) {
|
167 |
+
if (!isPaused && arg2 === true) { // resume now!
|
168 |
+
var options = $(cont).data('cycle.opts');
|
169 |
+
if (!options) {
|
170 |
+
log('options not found, can not resume');
|
171 |
+
return false;
|
172 |
+
}
|
173 |
+
if (cont.cycleTimeout) {
|
174 |
+
clearTimeout(cont.cycleTimeout);
|
175 |
+
cont.cycleTimeout = 0;
|
176 |
+
}
|
177 |
+
go(options.elements, options, 1, 1);
|
178 |
+
}
|
179 |
+
}
|
180 |
+
};
|
181 |
+
|
182 |
+
function removeFilter(el, opts) {
|
183 |
+
if (!$.support.opacity && opts.cleartype && el.style.filter) {
|
184 |
+
try { el.style.removeAttribute('filter'); }
|
185 |
+
catch(smother) {} // handle old opera versions
|
186 |
+
}
|
187 |
+
};
|
188 |
+
|
189 |
+
// unbind event handlers
|
190 |
+
function destroy(opts) {
|
191 |
+
if (opts.next)
|
192 |
+
$(opts.next).unbind(opts.prevNextEvent);
|
193 |
+
if (opts.prev)
|
194 |
+
$(opts.prev).unbind(opts.prevNextEvent);
|
195 |
+
|
196 |
+
if (opts.pager || opts.pagerAnchorBuilder)
|
197 |
+
$.each(opts.pagerAnchors || [], function() {
|
198 |
+
this.unbind().remove();
|
199 |
+
});
|
200 |
+
opts.pagerAnchors = null;
|
201 |
+
if (opts.destroy) // callback
|
202 |
+
opts.destroy(opts);
|
203 |
+
};
|
204 |
+
|
205 |
+
// one-time initialization
|
206 |
+
function buildOptions($cont, $slides, els, options, o) {
|
207 |
+
// support metadata plugin (v1.0 and v2.0)
|
208 |
+
var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {});
|
209 |
+
if (opts.autostop)
|
210 |
+
opts.countdown = opts.autostopCount || els.length;
|
211 |
+
|
212 |
+
var cont = $cont[0];
|
213 |
+
$cont.data('cycle.opts', opts);
|
214 |
+
opts.$cont = $cont;
|
215 |
+
opts.stopCount = cont.cycleStop;
|
216 |
+
opts.elements = els;
|
217 |
+
opts.before = opts.before ? [opts.before] : [];
|
218 |
+
opts.after = opts.after ? [opts.after] : [];
|
219 |
+
opts.after.unshift(function(){ opts.busy=0; });
|
220 |
+
|
221 |
+
// push some after callbacks
|
222 |
+
if (!$.support.opacity && opts.cleartype)
|
223 |
+
opts.after.push(function() { removeFilter(this, opts); });
|
224 |
+
if (opts.continuous)
|
225 |
+
opts.after.push(function() { go(els,opts,0,!opts.rev); });
|
226 |
+
|
227 |
+
saveOriginalOpts(opts);
|
228 |
+
|
229 |
+
// clearType corrections
|
230 |
+
if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
|
231 |
+
clearTypeFix($slides);
|
232 |
+
|
233 |
+
// container requires non-static position so that slides can be position within
|
234 |
+
if ($cont.css('position') == 'static')
|
235 |
+
$cont.css('position', 'relative');
|
236 |
+
if (opts.width)
|
237 |
+
$cont.width(opts.width);
|
238 |
+
if (opts.height && opts.height != 'auto')
|
239 |
+
$cont.height(opts.height);
|
240 |
+
|
241 |
+
if (opts.startingSlide)
|
242 |
+
opts.startingSlide = parseInt(opts.startingSlide);
|
243 |
+
|
244 |
+
// if random, mix up the slide array
|
245 |
+
if (opts.random) {
|
246 |
+
opts.randomMap = [];
|
247 |
+
for (var i = 0; i < els.length; i++)
|
248 |
+
opts.randomMap.push(i);
|
249 |
+
opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;});
|
250 |
+
opts.randomIndex = 1;
|
251 |
+
opts.startingSlide = opts.randomMap[1];
|
252 |
+
}
|
253 |
+
else if (opts.startingSlide >= els.length)
|
254 |
+
opts.startingSlide = 0; // catch bogus input
|
255 |
+
opts.currSlide = opts.startingSlide || 0;
|
256 |
+
var first = opts.startingSlide;
|
257 |
+
|
258 |
+
// set position and zIndex on all the slides
|
259 |
+
$slides.css({position: 'absolute', top:0, left:0}).hide().each(function(i) {
|
260 |
+
var z = first ? i >= first ? els.length - (i-first) : first-i : els.length-i;
|
261 |
+
$(this).css('z-index', z)
|
262 |
+
});
|
263 |
+
|
264 |
+
// make sure first slide is visible
|
265 |
+
$(els[first]).css('opacity',1).show(); // opacity bit needed to handle restart use case
|
266 |
+
removeFilter(els[first], opts);
|
267 |
+
|
268 |
+
// stretch slides
|
269 |
+
if (opts.fit && opts.width)
|
270 |
+
$slides.width(opts.width);
|
271 |
+
if (opts.fit && opts.height && opts.height != 'auto')
|
272 |
+
$slides.height(opts.height);
|
273 |
+
|
274 |
+
// stretch container
|
275 |
+
var reshape = opts.containerResize && !$cont.innerHeight();
|
276 |
+
if (reshape) { // do this only if container has no size http://tinyurl.com/da2oa9
|
277 |
+
var maxw = 0, maxh = 0;
|
278 |
+
for(var j=0; j < els.length; j++) {
|
279 |
+
var $e = $(els[j]), e = $e[0], w = $e.outerWidth(), h = $e.outerHeight();
|
280 |
+
if (!w) w = e.offsetWidth || e.width || $e.attr('width')
|
281 |
+
if (!h) h = e.offsetHeight || e.height || $e.attr('height');
|
282 |
+
maxw = w > maxw ? w : maxw;
|
283 |
+
maxh = h > maxh ? h : maxh;
|
284 |
+
}
|
285 |
+
if (maxw > 0 && maxh > 0)
|
286 |
+
$cont.css({width:maxw+'px',height:maxh+'px'});
|
287 |
+
}
|
288 |
+
|
289 |
+
if (opts.pause)
|
290 |
+
$cont.hover(function(){this.cyclePause++;},function(){this.cyclePause--;});
|
291 |
+
|
292 |
+
if (supportMultiTransitions(opts) === false)
|
293 |
+
return false;
|
294 |
+
|
295 |
+
// apparently a lot of people use image slideshows without height/width attributes on the images.
|
296 |
+
// Cycle 2.50+ requires the sizing info for every slide; this block tries to deal with that.
|
297 |
+
var requeue = false;
|
298 |
+
options.requeueAttempts = options.requeueAttempts || 0;
|
299 |
+
$slides.each(function() {
|
300 |
+
// try to get height/width of each slide
|
301 |
+
var $el = $(this);
|
302 |
+
this.cycleH = (opts.fit && opts.height) ? opts.height : ($el.height() || this.offsetHeight || this.height || $el.attr('height') || 0);
|
303 |
+
this.cycleW = (opts.fit && opts.width) ? opts.width : ($el.width() || this.offsetWidth || this.width || $el.attr('width') || 0);
|
304 |
+
|
305 |
+
if ( $el.is('img') ) {
|
306 |
+
// sigh.. sniffing, hacking, shrugging... this crappy hack tries to account for what browsers do when
|
307 |
+
// an image is being downloaded and the markup did not include sizing info (height/width attributes);
|
308 |
+
// there seems to be some "default" sizes used in this situation
|
309 |
+
var loadingIE = ($.browser.msie && this.cycleW == 28 && this.cycleH == 30 && !this.complete);
|
310 |
+
var loadingFF = ($.browser.mozilla && this.cycleW == 34 && this.cycleH == 19 && !this.complete);
|
311 |
+
var loadingOp = ($.browser.opera && ((this.cycleW == 42 && this.cycleH == 19) || (this.cycleW == 37 && this.cycleH == 17)) && !this.complete);
|
312 |
+
var loadingOther = (this.cycleH == 0 && this.cycleW == 0 && !this.complete);
|
313 |
+
// don't requeue for images that are still loading but have a valid size
|
314 |
+
if (loadingIE || loadingFF || loadingOp || loadingOther) {
|
315 |
+
if (o.s && opts.requeueOnImageNotLoaded && ++options.requeueAttempts < 100) { // track retry count so we don't loop forever
|
316 |
+
log(options.requeueAttempts,' - img slide not loaded, requeuing slideshow: ', this.src, this.cycleW, this.cycleH);
|
317 |
+
setTimeout(function() {$(o.s,o.c).cycle(options)}, opts.requeueTimeout);
|
318 |
+
requeue = true;
|
319 |
+
return false; // break each loop
|
320 |
+
}
|
321 |
+
else {
|
322 |
+
log('could not determine size of image: '+this.src, this.cycleW, this.cycleH);
|
323 |
+
}
|
324 |
+
}
|
325 |
+
}
|
326 |
+
return true;
|
327 |
+
});
|
328 |
+
|
329 |
+
if (requeue)
|
330 |
+
return false;
|
331 |
+
|
332 |
+
opts.cssBefore = opts.cssBefore || {};
|
333 |
+
opts.animIn = opts.animIn || {};
|
334 |
+
opts.animOut = opts.animOut || {};
|
335 |
+
|
336 |
+
$slides.not(':eq('+first+')').css(opts.cssBefore);
|
337 |
+
if (opts.cssFirst)
|
338 |
+
$($slides[first]).css(opts.cssFirst);
|
339 |
+
|
340 |
+
if (opts.timeout) {
|
341 |
+
opts.timeout = parseInt(opts.timeout);
|
342 |
+
// ensure that timeout and speed settings are sane
|
343 |
+
if (opts.speed.constructor == String)
|
344 |
+
opts.speed = $.fx.speeds[opts.speed] || parseInt(opts.speed);
|
345 |
+
if (!opts.sync)
|
346 |
+
opts.speed = opts.speed / 2;
|
347 |
+
|
348 |
+
var buffer = opts.fx == 'shuffle' ? 500 : 250;
|
349 |
+
while((opts.timeout - opts.speed) < buffer) // sanitize timeout
|
350 |
+
opts.timeout += opts.speed;
|
351 |
+
}
|
352 |
+
if (opts.easing)
|
353 |
+
opts.easeIn = opts.easeOut = opts.easing;
|
354 |
+
if (!opts.speedIn)
|
355 |
+
opts.speedIn = opts.speed;
|
356 |
+
if (!opts.speedOut)
|
357 |
+
opts.speedOut = opts.speed;
|
358 |
+
|
359 |
+
opts.slideCount = els.length;
|
360 |
+
opts.currSlide = opts.lastSlide = first;
|
361 |
+
if (opts.random) {
|
362 |
+
if (++opts.randomIndex == els.length)
|
363 |
+
opts.randomIndex = 0;
|
364 |
+
opts.nextSlide = opts.randomMap[opts.randomIndex];
|
365 |
+
}
|
366 |
+
else
|
367 |
+
opts.nextSlide = opts.startingSlide >= (els.length-1) ? 0 : opts.startingSlide+1;
|
368 |
+
|
369 |
+
// run transition init fn
|
370 |
+
if (!opts.multiFx) {
|
371 |
+
var init = $.fn.cycle.transitions[opts.fx];
|
372 |
+
if ($.isFunction(init))
|
373 |
+
init($cont, $slides, opts);
|
374 |
+
else if (opts.fx != 'custom' && !opts.multiFx) {
|
375 |
+
log('unknown transition: ' + opts.fx,'; slideshow terminating');
|
376 |
+
return false;
|
377 |
+
}
|
378 |
+
}
|
379 |
+
|
380 |
+
// fire artificial events
|
381 |
+
var e0 = $slides[first];
|
382 |
+
if (opts.before.length)
|
383 |
+
opts.before[0].apply(e0, [e0, e0, opts, true]);
|
384 |
+
if (opts.after.length > 1)
|
385 |
+
opts.after[1].apply(e0, [e0, e0, opts, true]);
|
386 |
+
|
387 |
+
if (opts.next)
|
388 |
+
$(opts.next).bind(opts.prevNextEvent,function(){return advance(opts,opts.rev?-1:1)});
|
389 |
+
if (opts.prev)
|
390 |
+
$(opts.prev).bind(opts.prevNextEvent,function(){return advance(opts,opts.rev?1:-1)});
|
391 |
+
if (opts.pager || opts.pagerAnchorBuilder)
|
392 |
+
buildPager(els,opts);
|
393 |
+
|
394 |
+
exposeAddSlide(opts, els);
|
395 |
+
|
396 |
+
return opts;
|
397 |
+
};
|
398 |
+
|
399 |
+
// save off original opts so we can restore after clearing state
|
400 |
+
function saveOriginalOpts(opts) {
|
401 |
+
opts.original = { before: [], after: [] };
|
402 |
+
opts.original.cssBefore = $.extend({}, opts.cssBefore);
|
403 |
+
opts.original.cssAfter = $.extend({}, opts.cssAfter);
|
404 |
+
opts.original.animIn = $.extend({}, opts.animIn);
|
405 |
+
opts.original.animOut = $.extend({}, opts.animOut);
|
406 |
+
$.each(opts.before, function() { opts.original.before.push(this); });
|
407 |
+
$.each(opts.after, function() { opts.original.after.push(this); });
|
408 |
+
};
|
409 |
+
|
410 |
+
function supportMultiTransitions(opts) {
|
411 |
+
var i, tx, txs = $.fn.cycle.transitions;
|
412 |
+
// look for multiple effects
|
413 |
+
if (opts.fx.indexOf(',') > 0) {
|
414 |
+
opts.multiFx = true;
|
415 |
+
opts.fxs = opts.fx.replace(/\s*/g,'').split(',');
|
416 |
+
// discard any bogus effect names
|
417 |
+
for (i=0; i < opts.fxs.length; i++) {
|
418 |
+
var fx = opts.fxs[i];
|
419 |
+
tx = txs[fx];
|
420 |
+
if (!tx || !txs.hasOwnProperty(fx) || !$.isFunction(tx)) {
|
421 |
+
log('discarding unknown transition: ',fx);
|
422 |
+
opts.fxs.splice(i,1);
|
423 |
+
i--;
|
424 |
+
}
|
425 |
+
}
|
426 |
+
// if we have an empty list then we threw everything away!
|
427 |
+
if (!opts.fxs.length) {
|
428 |
+
log('No valid transitions named; slideshow terminating.');
|
429 |
+
return false;
|
430 |
+
}
|
431 |
+
}
|
432 |
+
else if (opts.fx == 'all') { // auto-gen the list of transitions
|
433 |
+
opts.multiFx = true;
|
434 |
+
opts.fxs = [];
|
435 |
+
for (p in txs) {
|
436 |
+
tx = txs[p];
|
437 |
+
if (txs.hasOwnProperty(p) && $.isFunction(tx))
|
438 |
+
opts.fxs.push(p);
|
439 |
+
}
|
440 |
+
}
|
441 |
+
if (opts.multiFx && opts.randomizeEffects) {
|
442 |
+
// munge the fxs array to make effect selection random
|
443 |
+
var r1 = Math.floor(Math.random() * 20) + 30;
|
444 |
+
for (i = 0; i < r1; i++) {
|
445 |
+
var r2 = Math.floor(Math.random() * opts.fxs.length);
|
446 |
+
opts.fxs.push(opts.fxs.splice(r2,1)[0]);
|
447 |
+
}
|
448 |
+
debug('randomized fx sequence: ',opts.fxs);
|
449 |
+
}
|
450 |
+
return true;
|
451 |
+
};
|
452 |
+
|
453 |
+
// provide a mechanism for adding slides after the slideshow has started
|
454 |
+
function exposeAddSlide(opts, els) {
|
455 |
+
opts.addSlide = function(newSlide, prepend) {
|
456 |
+
var $s = $(newSlide), s = $s[0];
|
457 |
+
if (!opts.autostopCount)
|
458 |
+
opts.countdown++;
|
459 |
+
els[prepend?'unshift':'push'](s);
|
460 |
+
if (opts.els)
|
461 |
+
opts.els[prepend?'unshift':'push'](s); // shuffle needs this
|
462 |
+
opts.slideCount = els.length;
|
463 |
+
|
464 |
+
$s.css('position','absolute');
|
465 |
+
$s[prepend?'prependTo':'appendTo'](opts.$cont);
|
466 |
+
|
467 |
+
if (prepend) {
|
468 |
+
opts.currSlide++;
|
469 |
+
opts.nextSlide++;
|
470 |
+
}
|
471 |
+
|
472 |
+
if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
|
473 |
+
clearTypeFix($s);
|
474 |
+
|
475 |
+
if (opts.fit && opts.width)
|
476 |
+
$s.width(opts.width);
|
477 |
+
if (opts.fit && opts.height && opts.height != 'auto')
|
478 |
+
$slides.height(opts.height);
|
479 |
+
s.cycleH = (opts.fit && opts.height) ? opts.height : $s.height();
|
480 |
+
s.cycleW = (opts.fit && opts.width) ? opts.width : $s.width();
|
481 |
+
|
482 |
+
$s.css(opts.cssBefore);
|
483 |
+
|
484 |
+
if (opts.pager || opts.pagerAnchorBuilder)
|
485 |
+
$.fn.cycle.createPagerAnchor(els.length-1, s, $(opts.pager), els, opts);
|
486 |
+
|
487 |
+
if ($.isFunction(opts.onAddSlide))
|
488 |
+
opts.onAddSlide($s);
|
489 |
+
else
|
490 |
+
$s.hide(); // default behavior
|
491 |
+
};
|
492 |
+
}
|
493 |
+
|
494 |
+
// reset internal state; we do this on every pass in order to support multiple effects
|
495 |
+
$.fn.cycle.resetState = function(opts, fx) {
|
496 |
+
fx = fx || opts.fx;
|
497 |
+
opts.before = []; opts.after = [];
|
498 |
+
opts.cssBefore = $.extend({}, opts.original.cssBefore);
|
499 |
+
opts.cssAfter = $.extend({}, opts.original.cssAfter);
|
500 |
+
opts.animIn = $.extend({}, opts.original.animIn);
|
501 |
+
opts.animOut = $.extend({}, opts.original.animOut);
|
502 |
+
opts.fxFn = null;
|
503 |
+
$.each(opts.original.before, function() { opts.before.push(this); });
|
504 |
+
$.each(opts.original.after, function() { opts.after.push(this); });
|
505 |
+
|
506 |
+
// re-init
|
507 |
+
var init = $.fn.cycle.transitions[fx];
|
508 |
+
if ($.isFunction(init))
|
509 |
+
init(opts.$cont, $(opts.elements), opts);
|
510 |
+
};
|
511 |
+
|
512 |
+
// this is the main engine fn, it handles the timeouts, callbacks and slide index mgmt
|
513 |
+
function go(els, opts, manual, fwd) {
|
514 |
+
// opts.busy is true if we're in the middle of an animation
|
515 |
+
if (manual && opts.busy && opts.manualTrump) {
|
516 |
+
// let manual transitions requests trump active ones
|
517 |
+
debug('manualTrump in go(), stopping active transition');
|
518 |
+
$(els).stop(true,true);
|
519 |
+
opts.busy = false;
|
520 |
+
}
|
521 |
+
// don't begin another timeout-based transition if there is one active
|
522 |
+
if (opts.busy) {
|
523 |
+
debug('transition active, ignoring new tx request');
|
524 |
+
return;
|
525 |
+
}
|
526 |
+
|
527 |
+
var p = opts.$cont[0], curr = els[opts.currSlide], next = els[opts.nextSlide];
|
528 |
+
|
529 |
+
// stop cycling if we have an outstanding stop request
|
530 |
+
if (p.cycleStop != opts.stopCount || p.cycleTimeout === 0 && !manual)
|
531 |
+
return;
|
532 |
+
|
533 |
+
// check to see if we should stop cycling based on autostop options
|
534 |
+
if (!manual && !p.cyclePause &&
|
535 |
+
((opts.autostop && (--opts.countdown <= 0)) ||
|
536 |
+
(opts.nowrap && !opts.random && opts.nextSlide < opts.currSlide))) {
|
537 |
+
if (opts.end)
|
538 |
+
opts.end(opts);
|
539 |
+
return;
|
540 |
+
}
|
541 |
+
|
542 |
+
// if slideshow is paused, only transition on a manual trigger
|
543 |
+
var changed = false;
|
544 |
+
if ((manual || !p.cyclePause) && (opts.nextSlide != opts.currSlide)) {
|
545 |
+
changed = true;
|
546 |
+
var fx = opts.fx;
|
547 |
+
// keep trying to get the slide size if we don't have it yet
|
548 |
+
curr.cycleH = curr.cycleH || $(curr).height();
|
549 |
+
curr.cycleW = curr.cycleW || $(curr).width();
|
550 |
+
next.cycleH = next.cycleH || $(next).height();
|
551 |
+
next.cycleW = next.cycleW || $(next).width();
|
552 |
+
|
553 |
+
// support multiple transition types
|
554 |
+
if (opts.multiFx) {
|
555 |
+
if (opts.lastFx == undefined || ++opts.lastFx >= opts.fxs.length)
|
556 |
+
opts.lastFx = 0;
|
557 |
+
fx = opts.fxs[opts.lastFx];
|
558 |
+
opts.currFx = fx;
|
559 |
+
}
|
560 |
+
|
561 |
+
// one-time fx overrides apply to: $('div').cycle(3,'zoom');
|
562 |
+
if (opts.oneTimeFx) {
|
563 |
+
fx = opts.oneTimeFx;
|
564 |
+
opts.oneTimeFx = null;
|
565 |
+
}
|
566 |
+
|
567 |
+
$.fn.cycle.resetState(opts, fx);
|
568 |
+
|
569 |
+
// run the before callbacks
|
570 |
+
if (opts.before.length)
|
571 |
+
$.each(opts.before, function(i,o) {
|
572 |
+
if (p.cycleStop != opts.stopCount) return;
|
573 |
+
o.apply(next, [curr, next, opts, fwd]);
|
574 |
+
});
|
575 |
+
|
576 |
+
// stage the after callacks
|
577 |
+
var after = function() {
|
578 |
+
$.each(opts.after, function(i,o) {
|
579 |
+
if (p.cycleStop != opts.stopCount) return;
|
580 |
+
o.apply(next, [curr, next, opts, fwd]);
|
581 |
+
});
|
582 |
+
};
|
583 |
+
|
584 |
+
debug('tx firing; currSlide: ' + opts.currSlide + '; nextSlide: ' + opts.nextSlide);
|
585 |
+
|
586 |
+
// get ready to perform the transition
|
587 |
+
opts.busy = 1;
|
588 |
+
if (opts.fxFn) // fx function provided?
|
589 |
+
opts.fxFn(curr, next, opts, after, fwd, manual && opts.fastOnEvent);
|
590 |
+
else if ($.isFunction($.fn.cycle[opts.fx])) // fx plugin ?
|
591 |
+
$.fn.cycle[opts.fx](curr, next, opts, after, fwd, manual && opts.fastOnEvent);
|
592 |
+
else
|
593 |
+
$.fn.cycle.custom(curr, next, opts, after, fwd, manual && opts.fastOnEvent);
|
594 |
+
}
|
595 |
+
|
596 |
+
if (changed || opts.nextSlide == opts.currSlide) {
|
597 |
+
// calculate the next slide
|
598 |
+
opts.lastSlide = opts.currSlide;
|
599 |
+
if (opts.random) {
|
600 |
+
opts.currSlide = opts.nextSlide;
|
601 |
+
if (++opts.randomIndex == els.length)
|
602 |
+
opts.randomIndex = 0;
|
603 |
+
opts.nextSlide = opts.randomMap[opts.randomIndex];
|
604 |
+
if (opts.nextSlide == opts.currSlide)
|
605 |
+
opts.nextSlide = (opts.currSlide == opts.slideCount - 1) ? 0 : opts.currSlide + 1;
|
606 |
+
}
|
607 |
+
else { // sequence
|
608 |
+
var roll = (opts.nextSlide + 1) == els.length;
|
609 |
+
opts.nextSlide = roll ? 0 : opts.nextSlide+1;
|
610 |
+
opts.currSlide = roll ? els.length-1 : opts.nextSlide-1;
|
611 |
+
}
|
612 |
+
}
|
613 |
+
if (changed && opts.pager)
|
614 |
+
opts.updateActivePagerLink(opts.pager, opts.currSlide, opts.activePagerClass);
|
615 |
+
|
616 |
+
// stage the next transition
|
617 |
+
var ms = 0;
|
618 |
+
if (opts.timeout && !opts.continuous)
|
619 |
+
ms = getTimeout(curr, next, opts, fwd);
|
620 |
+
else if (opts.continuous && p.cyclePause) // continuous shows work off an after callback, not this timer logic
|
621 |
+
ms = 10;
|
622 |
+
if (ms > 0)
|
623 |
+
p.cycleTimeout = setTimeout(function(){ go(els, opts, 0, !opts.rev) }, ms);
|
624 |
+
};
|
625 |
+
|
626 |
+
// invoked after transition
|
627 |
+
$.fn.cycle.updateActivePagerLink = function(pager, currSlide, clsName) {
|
628 |
+
$(pager).each(function() {
|
629 |
+
$(this).children().removeClass(clsName).eq(currSlide).addClass(clsName);
|
630 |
+
});
|
631 |
+
};
|
632 |
+
|
633 |
+
// calculate timeout value for current transition
|
634 |
+
function getTimeout(curr, next, opts, fwd) {
|
635 |
+
if (opts.timeoutFn) {
|
636 |
+
// call user provided calc fn
|
637 |
+
var t = opts.timeoutFn(curr,next,opts,fwd);
|
638 |
+
while ((t - opts.speed) < 250) // sanitize timeout
|
639 |
+
t += opts.speed;
|
640 |
+
debug('calculated timeout: ' + t + '; speed: ' + opts.speed);
|
641 |
+
if (t !== false)
|
642 |
+
return t;
|
643 |
+
}
|
644 |
+
return opts.timeout;
|
645 |
+
};
|
646 |
+
|
647 |
+
// expose next/prev function, caller must pass in state
|
648 |
+
$.fn.cycle.next = function(opts) { advance(opts, opts.rev?-1:1); };
|
649 |
+
$.fn.cycle.prev = function(opts) { advance(opts, opts.rev?1:-1);};
|
650 |
+
|
651 |
+
// advance slide forward or back
|
652 |
+
function advance(opts, val) {
|
653 |
+
var els = opts.elements;
|
654 |
+
var p = opts.$cont[0], timeout = p.cycleTimeout;
|
655 |
+
if (timeout) {
|
656 |
+
clearTimeout(timeout);
|
657 |
+
p.cycleTimeout = 0;
|
658 |
+
}
|
659 |
+
if (opts.random && val < 0) {
|
660 |
+
// move back to the previously display slide
|
661 |
+
opts.randomIndex--;
|
662 |
+
if (--opts.randomIndex == -2)
|
663 |
+
opts.randomIndex = els.length-2;
|
664 |
+
else if (opts.randomIndex == -1)
|
665 |
+
opts.randomIndex = els.length-1;
|
666 |
+
opts.nextSlide = opts.randomMap[opts.randomIndex];
|
667 |
+
}
|
668 |
+
else if (opts.random) {
|
669 |
+
opts.nextSlide = opts.randomMap[opts.randomIndex];
|
670 |
+
}
|
671 |
+
else {
|
672 |
+
opts.nextSlide = opts.currSlide + val;
|
673 |
+
if (opts.nextSlide < 0) {
|
674 |
+
if (opts.nowrap) return false;
|
675 |
+
opts.nextSlide = els.length - 1;
|
676 |
+
}
|
677 |
+
else if (opts.nextSlide >= els.length) {
|
678 |
+
if (opts.nowrap) return false;
|
679 |
+
opts.nextSlide = 0;
|
680 |
+
}
|
681 |
+
}
|
682 |
+
|
683 |
+
var cb = opts.onPrevNextEvent || opts.prevNextClick; // prevNextClick is deprecated
|
684 |
+
if ($.isFunction(cb))
|
685 |
+
cb(val > 0, opts.nextSlide, els[opts.nextSlide]);
|
686 |
+
go(els, opts, 1, val>=0);
|
687 |
+
return false;
|
688 |
+
};
|
689 |
+
|
690 |
+
function buildPager(els, opts) {
|
691 |
+
var $p = $(opts.pager);
|
692 |
+
$.each(els, function(i,o) {
|
693 |
+
$.fn.cycle.createPagerAnchor(i,o,$p,els,opts);
|
694 |
+
});
|
695 |
+
opts.updateActivePagerLink(opts.pager, opts.startingSlide, opts.activePagerClass);
|
696 |
+
};
|
697 |
+
|
698 |
+
$.fn.cycle.createPagerAnchor = function(i, el, $p, els, opts) {
|
699 |
+
var a;
|
700 |
+
if ($.isFunction(opts.pagerAnchorBuilder)) {
|
701 |
+
a = opts.pagerAnchorBuilder(i,el);
|
702 |
+
debug('pagerAnchorBuilder('+i+', el) returned: ' + a);
|
703 |
+
}
|
704 |
+
else
|
705 |
+
a = '<a href="#">'+(i+1)+'</a>';
|
706 |
+
|
707 |
+
if (!a)
|
708 |
+
return;
|
709 |
+
var $a = $(a);
|
710 |
+
// don't reparent if anchor is in the dom
|
711 |
+
if ($a.parents('body').length === 0) {
|
712 |
+
var arr = [];
|
713 |
+
if ($p.length > 1) {
|
714 |
+
$p.each(function() {
|
715 |
+
var $clone = $a.clone(true);
|
716 |
+
$(this).append($clone);
|
717 |
+
arr.push($clone[0]);
|
718 |
+
});
|
719 |
+
$a = $(arr);
|
720 |
+
}
|
721 |
+
else {
|
722 |
+
$a.appendTo($p);
|
723 |
+
}
|
724 |
+
}
|
725 |
+
|
726 |
+
opts.pagerAnchors = opts.pagerAnchors || [];
|
727 |
+
opts.pagerAnchors.push($a);
|
728 |
+
$a.bind(opts.pagerEvent, function(e) {
|
729 |
+
e.preventDefault();
|
730 |
+
opts.nextSlide = i;
|
731 |
+
var p = opts.$cont[0], timeout = p.cycleTimeout;
|
732 |
+
if (timeout) {
|
733 |
+
clearTimeout(timeout);
|
734 |
+
p.cycleTimeout = 0;
|
735 |
+
}
|
736 |
+
var cb = opts.onPagerEvent || opts.pagerClick; // pagerClick is deprecated
|
737 |
+
if ($.isFunction(cb))
|
738 |
+
cb(opts.nextSlide, els[opts.nextSlide]);
|
739 |
+
go(els,opts,1,opts.currSlide < i); // trigger the trans
|
740 |
+
// return false; // <== allow bubble
|
741 |
+
});
|
742 |
+
|
743 |
+
if ( ! /^click/.test(opts.pagerEvent) && !opts.allowPagerClickBubble)
|
744 |
+
$a.bind('click.cycle', function(){return false;}); // suppress click
|
745 |
+
|
746 |
+
if (opts.pauseOnPagerHover)
|
747 |
+
$a.hover(function() { opts.$cont[0].cyclePause++; }, function() { opts.$cont[0].cyclePause--; } );
|
748 |
+
};
|
749 |
+
|
750 |
+
// helper fn to calculate the number of slides between the current and the next
|
751 |
+
$.fn.cycle.hopsFromLast = function(opts, fwd) {
|
752 |
+
var hops, l = opts.lastSlide, c = opts.currSlide;
|
753 |
+
if (fwd)
|
754 |
+
hops = c > l ? c - l : opts.slideCount - l;
|
755 |
+
else
|
756 |
+
hops = c < l ? l - c : l + opts.slideCount - c;
|
757 |
+
return hops;
|
758 |
+
};
|
759 |
+
|
760 |
+
// fix clearType problems in ie6 by setting an explicit bg color
|
761 |
+
// (otherwise text slides look horrible during a fade transition)
|
762 |
+
function clearTypeFix($slides) {
|
763 |
+
debug('applying clearType background-color hack');
|
764 |
+
function hex(s) {
|
765 |
+
s = parseInt(s).toString(16);
|
766 |
+
return s.length < 2 ? '0'+s : s;
|
767 |
+
};
|
768 |
+
function getBg(e) {
|
769 |
+
for ( ; e && e.nodeName.toLowerCase() != 'html'; e = e.parentNode) {
|
770 |
+
var v = $.css(e,'background-color');
|
771 |
+
if (v.indexOf('rgb') >= 0 ) {
|
772 |
+
var rgb = v.match(/\d+/g);
|
773 |
+
return '#'+ hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]);
|
774 |
+
}
|
775 |
+
if (v && v != 'transparent')
|
776 |
+
return v;
|
777 |
+
}
|
778 |
+
return '#ffffff';
|
779 |
+
};
|
780 |
+
$slides.each(function() { $(this).css('background-color', getBg(this)); });
|
781 |
+
};
|
782 |
+
|
783 |
+
// reset common props before the next transition
|
784 |
+
$.fn.cycle.commonReset = function(curr,next,opts,w,h,rev) {
|
785 |
+
$(opts.elements).not(curr).hide();
|
786 |
+
opts.cssBefore.opacity = 1;
|
787 |
+
opts.cssBefore.display = 'block';
|
788 |
+
if (w !== false && next.cycleW > 0)
|
789 |
+
opts.cssBefore.width = next.cycleW;
|
790 |
+
if (h !== false && next.cycleH > 0)
|
791 |
+
opts.cssBefore.height = next.cycleH;
|
792 |
+
opts.cssAfter = opts.cssAfter || {};
|
793 |
+
opts.cssAfter.display = 'none';
|
794 |
+
$(curr).css('zIndex',opts.slideCount + (rev === true ? 1 : 0));
|
795 |
+
$(next).css('zIndex',opts.slideCount + (rev === true ? 0 : 1));
|
796 |
+
};
|
797 |
+
|
798 |
+
// the actual fn for effecting a transition
|
799 |
+
$.fn.cycle.custom = function(curr, next, opts, cb, fwd, speedOverride) {
|
800 |
+
var $l = $(curr), $n = $(next);
|
801 |
+
var speedIn = opts.speedIn, speedOut = opts.speedOut, easeIn = opts.easeIn, easeOut = opts.easeOut;
|
802 |
+
$n.css(opts.cssBefore);
|
803 |
+
if (speedOverride) {
|
804 |
+
if (typeof speedOverride == 'number')
|
805 |
+
speedIn = speedOut = speedOverride;
|
806 |
+
else
|
807 |
+
speedIn = speedOut = 1;
|
808 |
+
easeIn = easeOut = null;
|
809 |
+
}
|
810 |
+
var fn = function() {$n.animate(opts.animIn, speedIn, easeIn, cb)};
|
811 |
+
$l.animate(opts.animOut, speedOut, easeOut, function() {
|
812 |
+
if (opts.cssAfter) $l.css(opts.cssAfter);
|
813 |
+
if (!opts.sync) fn();
|
814 |
+
});
|
815 |
+
if (opts.sync) fn();
|
816 |
+
};
|
817 |
+
|
818 |
+
// transition definitions - only fade is defined here, transition pack defines the rest
|
819 |
+
$.fn.cycle.transitions = {
|
820 |
+
fade: function($cont, $slides, opts) {
|
821 |
+
$slides.not(':eq('+opts.currSlide+')').css('opacity',0);
|
822 |
+
opts.before.push(function(curr,next,opts) {
|
823 |
+
$.fn.cycle.commonReset(curr,next,opts);
|
824 |
+
opts.cssBefore.opacity = 0;
|
825 |
+
});
|
826 |
+
opts.animIn = { opacity: 1 };
|
827 |
+
opts.animOut = { opacity: 0 };
|
828 |
+
opts.cssBefore = { top: 0, left: 0 };
|
829 |
+
}
|
830 |
+
};
|
831 |
+
|
832 |
+
$.fn.cycle.ver = function() { return ver; };
|
833 |
+
|
834 |
+
// override these globally if you like (they are all optional)
|
835 |
+
$.fn.cycle.defaults = {
|
836 |
+
fx: 'fade', // name of transition effect (or comma separated names, ex: 'fade,scrollUp,shuffle')
|
837 |
+
timeout: 4000, // milliseconds between slide transitions (0 to disable auto advance)
|
838 |
+
timeoutFn: null, // callback for determining per-slide timeout value: function(currSlideElement, nextSlideElement, options, forwardFlag)
|
839 |
+
continuous: 0, // true to start next transition immediately after current one completes
|
840 |
+
speed: 1000, // speed of the transition (any valid fx speed value)
|
841 |
+
speedIn: null, // speed of the 'in' transition
|
842 |
+
speedOut: null, // speed of the 'out' transition
|
843 |
+
next: null, // selector for element to use as event trigger for next slide
|
844 |
+
prev: null, // selector for element to use as event trigger for previous slide
|
845 |
+
// prevNextClick: null, // @deprecated; please use onPrevNextEvent instead
|
846 |
+
onPrevNextEvent: null, // callback fn for prev/next events: function(isNext, zeroBasedSlideIndex, slideElement)
|
847 |
+
prevNextEvent:'click.cycle',// event which drives the manual transition to the previous or next slide
|
848 |
+
pager: null, // selector for element to use as pager container
|
849 |
+
//pagerClick null, // @deprecated; please use onPagerEvent instead
|
850 |
+
onPagerEvent: null, // callback fn for pager events: function(zeroBasedSlideIndex, slideElement)
|
851 |
+
pagerEvent: 'click.cycle', // name of event which drives the pager navigation
|
852 |
+
allowPagerClickBubble: false, // allows or prevents click event on pager anchors from bubbling
|
853 |
+
pagerAnchorBuilder: null, // callback fn for building anchor links: function(index, DOMelement)
|
854 |
+
before: null, // transition callback (scope set to element to be shown): function(currSlideElement, nextSlideElement, options, forwardFlag)
|
855 |
+
after: null, // transition callback (scope set to element that was shown): function(currSlideElement, nextSlideElement, options, forwardFlag)
|
856 |
+
end: null, // callback invoked when the slideshow terminates (use with autostop or nowrap options): function(options)
|
857 |
+
easing: null, // easing method for both in and out transitions
|
858 |
+
easeIn: null, // easing for "in" transition
|
859 |
+
easeOut: null, // easing for "out" transition
|
860 |
+
shuffle: null, // coords for shuffle animation, ex: { top:15, left: 200 }
|
861 |
+
animIn: null, // properties that define how the slide animates in
|
862 |
+
animOut: null, // properties that define how the slide animates out
|
863 |
+
cssBefore: null, // properties that define the initial state of the slide before transitioning in
|
864 |
+
cssAfter: null, // properties that defined the state of the slide after transitioning out
|
865 |
+
fxFn: null, // function used to control the transition: function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag)
|
866 |
+
height: 'auto', // container height
|
867 |
+
startingSlide: 0, // zero-based index of the first slide to be displayed
|
868 |
+
sync: 1, // true if in/out transitions should occur simultaneously
|
869 |
+
random: 0, // true for random, false for sequence (not applicable to shuffle fx)
|
870 |
+
fit: 0, // force slides to fit container
|
871 |
+
containerResize: 1, // resize container to fit largest slide
|
872 |
+
pause: 0, // true to enable "pause on hover"
|
873 |
+
pauseOnPagerHover: 0, // true to pause when hovering over pager link
|
874 |
+
autostop: 0, // true to end slideshow after X transitions (where X == slide count)
|
875 |
+
autostopCount: 0, // number of transitions (optionally used with autostop to define X)
|
876 |
+
delay: 0, // additional delay (in ms) for first transition (hint: can be negative)
|
877 |
+
slideExpr: null, // expression for selecting slides (if something other than all children is required)
|
878 |
+
cleartype: !$.support.opacity, // true if clearType corrections should be applied (for IE)
|
879 |
+
cleartypeNoBg: false, // set to true to disable extra cleartype fixing (leave false to force background color setting on slides)
|
880 |
+
nowrap: 0, // true to prevent slideshow from wrapping
|
881 |
+
fastOnEvent: 0, // force fast transitions when triggered manually (via pager or prev/next); value == time in ms
|
882 |
+
randomizeEffects: 1, // valid when multiple effects are used; true to make the effect sequence random
|
883 |
+
rev: 0, // causes animations to transition in reverse
|
884 |
+
manualTrump: true, // causes manual transition to stop an active transition instead of being ignored
|
885 |
+
requeueOnImageNotLoaded: true, // requeue the slideshow if any image slides are not yet loaded
|
886 |
+
requeueTimeout: 250, // ms delay for requeue
|
887 |
+
activePagerClass: 'activeSlide', // class name used for the active pager link
|
888 |
+
updateActivePagerLink: null // callback fn invoked to update the active pager link (adds/removes activePagerClass style)
|
889 |
+
};
|
890 |
+
|
891 |
+
})(jQuery);
|
892 |
+
|
893 |
+
|
894 |
+
/*!
|
895 |
+
* jQuery Cycle Plugin Transition Definitions
|
896 |
+
* This script is a plugin for the jQuery Cycle Plugin
|
897 |
+
* Examples and documentation at: http://malsup.com/jquery/cycle/
|
898 |
+
* Copyright (c) 2007-2008 M. Alsup
|
899 |
+
* Version: 2.72
|
900 |
+
* Dual licensed under the MIT and GPL licenses:
|
901 |
+
* http://www.opensource.org/licenses/mit-license.php
|
902 |
+
* http://www.gnu.org/licenses/gpl.html
|
903 |
+
*/
|
904 |
+
(function($) {
|
905 |
+
|
906 |
+
//
|
907 |
+
// These functions define one-time slide initialization for the named
|
908 |
+
// transitions. To save file size feel free to remove any of these that you
|
909 |
+
// don't need.
|
910 |
+
//
|
911 |
+
$.fn.cycle.transitions.none = function($cont, $slides, opts) {
|
912 |
+
opts.fxFn = function(curr,next,opts,after){
|
913 |
+
$(next).show();
|
914 |
+
$(curr).hide();
|
915 |
+
after();
|
916 |
+
};
|
917 |
+
}
|
918 |
+
|
919 |
+
// scrollUp/Down/Left/Right
|
920 |
+
$.fn.cycle.transitions.scrollUp = function($cont, $slides, opts) {
|
921 |
+
$cont.css('overflow','hidden');
|
922 |
+
opts.before.push($.fn.cycle.commonReset);
|
923 |
+
var h = $cont.height();
|
924 |
+
opts.cssBefore ={ top: h, left: 0 };
|
925 |
+
opts.cssFirst = { top: 0 };
|
926 |
+
opts.animIn = { top: 0 };
|
927 |
+
opts.animOut = { top: -h };
|
928 |
+
};
|
929 |
+
$.fn.cycle.transitions.scrollDown = function($cont, $slides, opts) {
|
930 |
+
$cont.css('overflow','hidden');
|
931 |
+
opts.before.push($.fn.cycle.commonReset);
|
932 |
+
var h = $cont.height();
|
933 |
+
opts.cssFirst = { top: 0 };
|
934 |
+
opts.cssBefore= { top: -h, left: 0 };
|
935 |
+
opts.animIn = { top: 0 };
|
936 |
+
opts.animOut = { top: h };
|
937 |
+
};
|
938 |
+
$.fn.cycle.transitions.scrollLeft = function($cont, $slides, opts) {
|
939 |
+
$cont.css('overflow','hidden');
|
940 |
+
opts.before.push($.fn.cycle.commonReset);
|
941 |
+
var w = $cont.width();
|
942 |
+
opts.cssFirst = { left: 0 };
|
943 |
+
opts.cssBefore= { left: w, top: 0 };
|
944 |
+
opts.animIn = { left: 0 };
|
945 |
+
opts.animOut = { left: 0-w };
|
946 |
+
};
|
947 |
+
$.fn.cycle.transitions.scrollRight = function($cont, $slides, opts) {
|
948 |
+
$cont.css('overflow','hidden');
|
949 |
+
opts.before.push($.fn.cycle.commonReset);
|
950 |
+
var w = $cont.width();
|
951 |
+
opts.cssFirst = { left: 0 };
|
952 |
+
opts.cssBefore= { left: -w, top: 0 };
|
953 |
+
opts.animIn = { left: 0 };
|
954 |
+
opts.animOut = { left: w };
|
955 |
+
};
|
956 |
+
$.fn.cycle.transitions.scrollHorz = function($cont, $slides, opts) {
|
957 |
+
$cont.css('overflow','hidden').width();
|
958 |
+
opts.before.push(function(curr, next, opts, fwd) {
|
959 |
+
$.fn.cycle.commonReset(curr,next,opts);
|
960 |
+
opts.cssBefore.left = fwd ? (next.cycleW-1) : (1-next.cycleW);
|
961 |
+
opts.animOut.left = fwd ? -curr.cycleW : curr.cycleW;
|
962 |
+
});
|
963 |
+
opts.cssFirst = { left: 0 };
|
964 |
+
opts.cssBefore= { top: 0 };
|
965 |
+
opts.animIn = { left: 0 };
|
966 |
+
opts.animOut = { top: 0 };
|
967 |
+
};
|
968 |
+
$.fn.cycle.transitions.scrollVert = function($cont, $slides, opts) {
|
969 |
+
$cont.css('overflow','hidden');
|
970 |
+
opts.before.push(function(curr, next, opts, fwd) {
|
971 |
+
$.fn.cycle.commonReset(curr,next,opts);
|
972 |
+
opts.cssBefore.top = fwd ? (1-next.cycleH) : (next.cycleH-1);
|
973 |
+
opts.animOut.top = fwd ? curr.cycleH : -curr.cycleH;
|
974 |
+
});
|
975 |
+
opts.cssFirst = { top: 0 };
|
976 |
+
opts.cssBefore= { left: 0 };
|
977 |
+
opts.animIn = { top: 0 };
|
978 |
+
opts.animOut = { left: 0 };
|
979 |
+
};
|
980 |
+
|
981 |
+
// slideX/slideY
|
982 |
+
$.fn.cycle.transitions.slideX = function($cont, $slides, opts) {
|
983 |
+
opts.before.push(function(curr, next, opts) {
|
984 |
+
$(opts.elements).not(curr).hide();
|
985 |
+
$.fn.cycle.commonReset(curr,next,opts,false,true);
|
986 |
+
opts.animIn.width = next.cycleW;
|
987 |
+
});
|
988 |
+
opts.cssBefore = { left: 0, top: 0, width: 0 };
|
989 |
+
opts.animIn = { width: 'show' };
|
990 |
+
opts.animOut = { width: 0 };
|
991 |
+
};
|
992 |
+
$.fn.cycle.transitions.slideY = function($cont, $slides, opts) {
|
993 |
+
opts.before.push(function(curr, next, opts) {
|
994 |
+
$(opts.elements).not(curr).hide();
|
995 |
+
$.fn.cycle.commonReset(curr,next,opts,true,false);
|
996 |
+
opts.animIn.height = next.cycleH;
|
997 |
+
});
|
998 |
+
opts.cssBefore = { left: 0, top: 0, height: 0 };
|
999 |
+
opts.animIn = { height: 'show' };
|
1000 |
+
opts.animOut = { height: 0 };
|
1001 |
+
};
|
1002 |
+
|
1003 |
+
// shuffle
|
1004 |
+
$.fn.cycle.transitions.shuffle = function($cont, $slides, opts) {
|
1005 |
+
var i, w = $cont.css('overflow', 'visible').width();
|
1006 |
+
$slides.css({left: 0, top: 0});
|
1007 |
+
opts.before.push(function(curr,next,opts) {
|
1008 |
+
$.fn.cycle.commonReset(curr,next,opts,true,true,true);
|
1009 |
+
});
|
1010 |
+
// only adjust speed once!
|
1011 |
+
if (!opts.speedAdjusted) {
|
1012 |
+
opts.speed = opts.speed / 2; // shuffle has 2 transitions
|
1013 |
+
opts.speedAdjusted = true;
|
1014 |
+
}
|
1015 |
+
opts.random = 0;
|
1016 |
+
opts.shuffle = opts.shuffle || {left:-w, top:15};
|
1017 |
+
opts.els = [];
|
1018 |
+
for (i=0; i < $slides.length; i++)
|
1019 |
+
opts.els.push($slides[i]);
|
1020 |
+
|
1021 |
+
for (i=0; i < opts.currSlide; i++)
|
1022 |
+
opts.els.push(opts.els.shift());
|
1023 |
+
|
1024 |
+
// custom transition fn (hat tip to Benjamin Sterling for this bit of sweetness!)
|
1025 |
+
opts.fxFn = function(curr, next, opts, cb, fwd) {
|
1026 |
+
var $el = fwd ? $(curr) : $(next);
|
1027 |
+
$(next).css(opts.cssBefore);
|
1028 |
+
var count = opts.slideCount;
|
1029 |
+
$el.animate(opts.shuffle, opts.speedIn, opts.easeIn, function() {
|
1030 |
+
var hops = $.fn.cycle.hopsFromLast(opts, fwd);
|
1031 |
+
for (var k=0; k < hops; k++)
|
1032 |
+
fwd ? opts.els.push(opts.els.shift()) : opts.els.unshift(opts.els.pop());
|
1033 |
+
if (fwd) {
|
1034 |
+
for (var i=0, len=opts.els.length; i < len; i++)
|
1035 |
+
$(opts.els[i]).css('z-index', len-i+count);
|
1036 |
+
}
|
1037 |
+
else {
|
1038 |
+
var z = $(curr).css('z-index');
|
1039 |
+
$el.css('z-index', parseInt(z)+1+count);
|
1040 |
+
}
|
1041 |
+
$el.animate({left:0, top:0}, opts.speedOut, opts.easeOut, function() {
|
1042 |
+
$(fwd ? this : curr).hide();
|
1043 |
+
if (cb) cb();
|
1044 |
+
});
|
1045 |
+
});
|
1046 |
+
};
|
1047 |
+
opts.cssBefore = { display: 'block', opacity: 1, top: 0, left: 0 };
|
1048 |
+
};
|
1049 |
+
|
1050 |
+
// turnUp/Down/Left/Right
|
1051 |
+
$.fn.cycle.transitions.turnUp = function($cont, $slides, opts) {
|
1052 |
+
opts.before.push(function(curr, next, opts) {
|
1053 |
+
$.fn.cycle.commonReset(curr,next,opts,true,false);
|
1054 |
+
opts.cssBefore.top = next.cycleH;
|
1055 |
+
opts.animIn.height = next.cycleH;
|
1056 |
+
});
|
1057 |
+
opts.cssFirst = { top: 0 };
|
1058 |
+
opts.cssBefore = { left: 0, height: 0 };
|
1059 |
+
opts.animIn = { top: 0 };
|
1060 |
+
opts.animOut = { height: 0 };
|
1061 |
+
};
|
1062 |
+
$.fn.cycle.transitions.turnDown = function($cont, $slides, opts) {
|
1063 |
+
opts.before.push(function(curr, next, opts) {
|
1064 |
+
$.fn.cycle.commonReset(curr,next,opts,true,false);
|
1065 |
+
opts.animIn.height = next.cycleH;
|
1066 |
+
opts.animOut.top = curr.cycleH;
|
1067 |
+
});
|
1068 |
+
opts.cssFirst = { top: 0 };
|
1069 |
+
opts.cssBefore = { left: 0, top: 0, height: 0 };
|
1070 |
+
opts.animOut = { height: 0 };
|
1071 |
+
};
|
1072 |
+
$.fn.cycle.transitions.turnLeft = function($cont, $slides, opts) {
|
1073 |
+
opts.before.push(function(curr, next, opts) {
|
1074 |
+
$.fn.cycle.commonReset(curr,next,opts,false,true);
|
1075 |
+
opts.cssBefore.left = next.cycleW;
|
1076 |
+
opts.animIn.width = next.cycleW;
|
1077 |
+
});
|
1078 |
+
opts.cssBefore = { top: 0, width: 0 };
|
1079 |
+
opts.animIn = { left: 0 };
|
1080 |
+
opts.animOut = { width: 0 };
|
1081 |
+
};
|
1082 |
+
$.fn.cycle.transitions.turnRight = function($cont, $slides, opts) {
|
1083 |
+
opts.before.push(function(curr, next, opts) {
|
1084 |
+
$.fn.cycle.commonReset(curr,next,opts,false,true);
|
1085 |
+
opts.animIn.width = next.cycleW;
|
1086 |
+
opts.animOut.left = curr.cycleW;
|
1087 |
+
});
|
1088 |
+
opts.cssBefore = { top: 0, left: 0, width: 0 };
|
1089 |
+
opts.animIn = { left: 0 };
|
1090 |
+
opts.animOut = { width: 0 };
|
1091 |
+
};
|
1092 |
+
|
1093 |
+
// zoom
|
1094 |
+
$.fn.cycle.transitions.zoom = function($cont, $slides, opts) {
|
1095 |
+
opts.before.push(function(curr, next, opts) {
|
1096 |
+
$.fn.cycle.commonReset(curr,next,opts,false,false,true);
|
1097 |
+
opts.cssBefore.top = next.cycleH/2;
|
1098 |
+
opts.cssBefore.left = next.cycleW/2;
|
1099 |
+
opts.animIn = { top: 0, left: 0, width: next.cycleW, height: next.cycleH };
|
1100 |
+
opts.animOut = { width: 0, height: 0, top: curr.cycleH/2, left: curr.cycleW/2 };
|
1101 |
+
});
|
1102 |
+
opts.cssFirst = { top:0, left: 0 };
|
1103 |
+
opts.cssBefore = { width: 0, height: 0 };
|
1104 |
+
};
|
1105 |
+
|
1106 |
+
// fadeZoom
|
1107 |
+
$.fn.cycle.transitions.fadeZoom = function($cont, $slides, opts) {
|
1108 |
+
opts.before.push(function(curr, next, opts) {
|
1109 |
+
$.fn.cycle.commonReset(curr,next,opts,false,false);
|
1110 |
+
opts.cssBefore.left = next.cycleW/2;
|
1111 |
+
opts.cssBefore.top = next.cycleH/2;
|
1112 |
+
opts.animIn = { top: 0, left: 0, width: next.cycleW, height: next.cycleH };
|
1113 |
+
});
|
1114 |
+
opts.cssBefore = { width: 0, height: 0 };
|
1115 |
+
opts.animOut = { opacity: 0 };
|
1116 |
+
};
|
1117 |
+
|
1118 |
+
// blindX
|
1119 |
+
$.fn.cycle.transitions.blindX = function($cont, $slides, opts) {
|
1120 |
+
var w = $cont.css('overflow','hidden').width();
|
1121 |
+
opts.before.push(function(curr, next, opts) {
|
1122 |
+
$.fn.cycle.commonReset(curr,next,opts);
|
1123 |
+
opts.animIn.width = next.cycleW;
|
1124 |
+
opts.animOut.left = curr.cycleW;
|
1125 |
+
});
|
1126 |
+
opts.cssBefore = { left: w, top: 0 };
|
1127 |
+
opts.animIn = { left: 0 };
|
1128 |
+
opts.animOut = { left: w };
|
1129 |
+
};
|
1130 |
+
// blindY
|
1131 |
+
$.fn.cycle.transitions.blindY = function($cont, $slides, opts) {
|
1132 |
+
var h = $cont.css('overflow','hidden').height();
|
1133 |
+
opts.before.push(function(curr, next, opts) {
|
1134 |
+
$.fn.cycle.commonReset(curr,next,opts);
|
1135 |
+
opts.animIn.height = next.cycleH;
|
1136 |
+
opts.animOut.top = curr.cycleH;
|
1137 |
+
});
|
1138 |
+
opts.cssBefore = { top: h, left: 0 };
|
1139 |
+
opts.animIn = { top: 0 };
|
1140 |
+
opts.animOut = { top: h };
|
1141 |
+
};
|
1142 |
+
// blindZ
|
1143 |
+
$.fn.cycle.transitions.blindZ = function($cont, $slides, opts) {
|
1144 |
+
var h = $cont.css('overflow','hidden').height();
|
1145 |
+
var w = $cont.width();
|
1146 |
+
opts.before.push(function(curr, next, opts) {
|
1147 |
+
$.fn.cycle.commonReset(curr,next,opts);
|
1148 |
+
opts.animIn.height = next.cycleH;
|
1149 |
+
opts.animOut.top = curr.cycleH;
|
1150 |
+
});
|
1151 |
+
opts.cssBefore = { top: h, left: w };
|
1152 |
+
opts.animIn = { top: 0, left: 0 };
|
1153 |
+
opts.animOut = { top: h, left: w };
|
1154 |
+
};
|
1155 |
+
|
1156 |
+
// growX - grow horizontally from centered 0 width
|
1157 |
+
$.fn.cycle.transitions.growX = function($cont, $slides, opts) {
|
1158 |
+
opts.before.push(function(curr, next, opts) {
|
1159 |
+
$.fn.cycle.commonReset(curr,next,opts,false,true);
|
1160 |
+
opts.cssBefore.left = this.cycleW/2;
|
1161 |
+
opts.animIn = { left: 0, width: this.cycleW };
|
1162 |
+
opts.animOut = { left: 0 };
|
1163 |
+
});
|
1164 |
+
opts.cssBefore = { width: 0, top: 0 };
|
1165 |
+
};
|
1166 |
+
// growY - grow vertically from centered 0 height
|
1167 |
+
$.fn.cycle.transitions.growY = function($cont, $slides, opts) {
|
1168 |
+
opts.before.push(function(curr, next, opts) {
|
1169 |
+
$.fn.cycle.commonReset(curr,next,opts,true,false);
|
1170 |
+
opts.cssBefore.top = this.cycleH/2;
|
1171 |
+
opts.animIn = { top: 0, height: this.cycleH };
|
1172 |
+
opts.animOut = { top: 0 };
|
1173 |
+
});
|
1174 |
+
opts.cssBefore = { height: 0, left: 0 };
|
1175 |
+
};
|
1176 |
+
|
1177 |
+
// curtainX - squeeze in both edges horizontally
|
1178 |
+
$.fn.cycle.transitions.curtainX = function($cont, $slides, opts) {
|
1179 |
+
opts.before.push(function(curr, next, opts) {
|
1180 |
+
$.fn.cycle.commonReset(curr,next,opts,false,true,true);
|
1181 |
+
opts.cssBefore.left = next.cycleW/2;
|
1182 |
+
opts.animIn = { left: 0, width: this.cycleW };
|
1183 |
+
opts.animOut = { left: curr.cycleW/2, width: 0 };
|
1184 |
+
});
|
1185 |
+
opts.cssBefore = { top: 0, width: 0 };
|
1186 |
+
};
|
1187 |
+
// curtainY - squeeze in both edges vertically
|
1188 |
+
$.fn.cycle.transitions.curtainY = function($cont, $slides, opts) {
|
1189 |
+
opts.before.push(function(curr, next, opts) {
|
1190 |
+
$.fn.cycle.commonReset(curr,next,opts,true,false,true);
|
1191 |
+
opts.cssBefore.top = next.cycleH/2;
|
1192 |
+
opts.animIn = { top: 0, height: next.cycleH };
|
1193 |
+
opts.animOut = { top: curr.cycleH/2, height: 0 };
|
1194 |
+
});
|
1195 |
+
opts.cssBefore = { left: 0, height: 0 };
|
1196 |
+
};
|
1197 |
+
|
1198 |
+
// cover - curr slide covered by next slide
|
1199 |
+
$.fn.cycle.transitions.cover = function($cont, $slides, opts) {
|
1200 |
+
var d = opts.direction || 'left';
|
1201 |
+
var w = $cont.css('overflow','hidden').width();
|
1202 |
+
var h = $cont.height();
|
1203 |
+
opts.before.push(function(curr, next, opts) {
|
1204 |
+
$.fn.cycle.commonReset(curr,next,opts);
|
1205 |
+
if (d == 'right')
|
1206 |
+
opts.cssBefore.left = -w;
|
1207 |
+
else if (d == 'up')
|
1208 |
+
opts.cssBefore.top = h;
|
1209 |
+
else if (d == 'down')
|
1210 |
+
opts.cssBefore.top = -h;
|
1211 |
+
else
|
1212 |
+
opts.cssBefore.left = w;
|
1213 |
+
});
|
1214 |
+
opts.animIn = { left: 0, top: 0};
|
1215 |
+
opts.animOut = { opacity: 1 };
|
1216 |
+
opts.cssBefore = { top: 0, left: 0 };
|
1217 |
+
};
|
1218 |
+
|
1219 |
+
// uncover - curr slide moves off next slide
|
1220 |
+
$.fn.cycle.transitions.uncover = function($cont, $slides, opts) {
|
1221 |
+
var d = opts.direction || 'left';
|
1222 |
+
var w = $cont.css('overflow','hidden').width();
|
1223 |
+
var h = $cont.height();
|
1224 |
+
opts.before.push(function(curr, next, opts) {
|
1225 |
+
$.fn.cycle.commonReset(curr,next,opts,true,true,true);
|
1226 |
+
if (d == 'right')
|
1227 |
+
opts.animOut.left = w;
|
1228 |
+
else if (d == 'up')
|
1229 |
+
opts.animOut.top = -h;
|
1230 |
+
else if (d == 'down')
|
1231 |
+
opts.animOut.top = h;
|
1232 |
+
else
|
1233 |
+
opts.animOut.left = -w;
|
1234 |
+
});
|
1235 |
+
opts.animIn = { left: 0, top: 0 };
|
1236 |
+
opts.animOut = { opacity: 1 };
|
1237 |
+
opts.cssBefore = { top: 0, left: 0 };
|
1238 |
+
};
|
1239 |
+
|
1240 |
+
// toss - move top slide and fade away
|
1241 |
+
$.fn.cycle.transitions.toss = function($cont, $slides, opts) {
|
1242 |
+
var w = $cont.css('overflow','visible').width();
|
1243 |
+
var h = $cont.height();
|
1244 |
+
opts.before.push(function(curr, next, opts) {
|
1245 |
+
$.fn.cycle.commonReset(curr,next,opts,true,true,true);
|
1246 |
+
// provide default toss settings if animOut not provided
|
1247 |
+
if (!opts.animOut.left && !opts.animOut.top)
|
1248 |
+
opts.animOut = { left: w*2, top: -h/2, opacity: 0 };
|
1249 |
+
else
|
1250 |
+
opts.animOut.opacity = 0;
|
1251 |
+
});
|
1252 |
+
opts.cssBefore = { left: 0, top: 0 };
|
1253 |
+
opts.animIn = { left: 0 };
|
1254 |
+
};
|
1255 |
+
|
1256 |
+
// wipe - clip animation
|
1257 |
+
$.fn.cycle.transitions.wipe = function($cont, $slides, opts) {
|
1258 |
+
var w = $cont.css('overflow','hidden').width();
|
1259 |
+
var h = $cont.height();
|
1260 |
+
opts.cssBefore = opts.cssBefore || {};
|
1261 |
+
var clip;
|
1262 |
+
if (opts.clip) {
|
1263 |
+
if (/l2r/.test(opts.clip))
|
1264 |
+
clip = 'rect(0px 0px '+h+'px 0px)';
|
1265 |
+
else if (/r2l/.test(opts.clip))
|
1266 |
+
clip = 'rect(0px '+w+'px '+h+'px '+w+'px)';
|
1267 |
+
else if (/t2b/.test(opts.clip))
|
1268 |
+
clip = 'rect(0px '+w+'px 0px 0px)';
|
1269 |
+
else if (/b2t/.test(opts.clip))
|
1270 |
+
clip = 'rect('+h+'px '+w+'px '+h+'px 0px)';
|
1271 |
+
else if (/zoom/.test(opts.clip)) {
|
1272 |
+
var top = parseInt(h/2);
|
1273 |
+
var left = parseInt(w/2);
|
1274 |
+
clip = 'rect('+top+'px '+left+'px '+top+'px '+left+'px)';
|
1275 |
+
}
|
1276 |
+
}
|
1277 |
+
|
1278 |
+
opts.cssBefore.clip = opts.cssBefore.clip || clip || 'rect(0px 0px 0px 0px)';
|
1279 |
+
|
1280 |
+
var d = opts.cssBefore.clip.match(/(\d+)/g);
|
1281 |
+
var t = parseInt(d[0]), r = parseInt(d[1]), b = parseInt(d[2]), l = parseInt(d[3]);
|
1282 |
+
|
1283 |
+
opts.before.push(function(curr, next, opts) {
|
1284 |
+
if (curr == next) return;
|
1285 |
+
var $curr = $(curr), $next = $(next);
|
1286 |
+
$.fn.cycle.commonReset(curr,next,opts,true,true,false);
|
1287 |
+
opts.cssAfter.display = 'block';
|
1288 |
+
|
1289 |
+
var step = 1, count = parseInt((opts.speedIn / 13)) - 1;
|
1290 |
+
(function f() {
|
1291 |
+
var tt = t ? t - parseInt(step * (t/count)) : 0;
|
1292 |
+
var ll = l ? l - parseInt(step * (l/count)) : 0;
|
1293 |
+
var bb = b < h ? b + parseInt(step * ((h-b)/count || 1)) : h;
|
1294 |
+
var rr = r < w ? r + parseInt(step * ((w-r)/count || 1)) : w;
|
1295 |
+
$next.css({ clip: 'rect('+tt+'px '+rr+'px '+bb+'px '+ll+'px)' });
|
1296 |
+
(step++ <= count) ? setTimeout(f, 13) : $curr.css('display', 'none');
|
1297 |
+
})();
|
1298 |
+
});
|
1299 |
+
opts.cssBefore = { display: 'block', opacity: 1, top: 0, left: 0 };
|
1300 |
+
opts.animIn = { left: 0 };
|
1301 |
+
opts.animOut = { left: 0 };
|
1302 |
+
};
|
1303 |
+
|
1304 |
+
})(jQuery);
|
js/slideshow.js
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// jQuery Cycle script which powers the Slideshow: http://jquery.malsup.com/cycle/
|
2 |
+
|
3 |
+
var $j = jQuery.noConflict();
|
4 |
+
|
5 |
+
var $slidespeed = parseInt( meteorslidessettings.meteorslideshowspeed );
|
6 |
+
|
7 |
+
var $slidetimeout = parseInt( meteorslidessettings.meteorslideshowduration );
|
8 |
+
|
9 |
+
var $slidetransition = meteorslidessettings.meteorslideshowtransition;
|
10 |
+
|
11 |
+
$j(document).ready(function() {
|
12 |
+
$j('.mete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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Meteor Slides
|
4 |
+
Description: Adds a custom post type for slides to WordPress. Use Meteor Slides to create a quick little slideshow for your site.
|
5 |
+
Plugin URI: http://www.jleuze.com/plugins/meteor-slides
|
6 |
+
Author: Josh Leuze
|
7 |
+
Author URI: http://www.jleuze.com/
|
8 |
+
License: GPL2
|
9 |
+
Version: 1.0
|
10 |
+
*/
|
11 |
+
|
12 |
+
/* Copyright 2010 Josh Leuze (email : mail@jleuze.com)
|
13 |
+
|
14 |
+
This program is free software; you can redistribute it and/or modify
|
15 |
+
it under the terms of the GNU General Public License, version 2, as
|
16 |
+
published by the Free Software Foundation.
|
17 |
+
|
18 |
+
This program is distributed in the hope that it will be useful,
|
19 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21 |
+
GNU General Public License for more details.
|
22 |
+
|
23 |
+
You should have received a copy of the GNU General Public License
|
24 |
+
along with this program; if not, write to the Free Software
|
25 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
26 |
+
*/
|
27 |
+
|
28 |
+
// Adds featured image functionality
|
29 |
+
|
30 |
+
add_action( 'plugins_loaded', 'meteorslides_featured_image' );
|
31 |
+
|
32 |
+
function meteorslides_featured_image() {
|
33 |
+
|
34 |
+
add_theme_support( 'post-thumbnails', array( 'slide' ) );
|
35 |
+
|
36 |
+
$options = get_option( 'meteorslides_options' );
|
37 |
+
|
38 |
+
add_image_size( 'featured-slide', $options['slide_width'], $options['slide_height'], true );
|
39 |
+
|
40 |
+
}
|
41 |
+
|
42 |
+
// Adds custom post type
|
43 |
+
|
44 |
+
add_action( 'init', 'meteorslides_register_slides' );
|
45 |
+
|
46 |
+
function meteorslides_register_slides() {
|
47 |
+
|
48 |
+
$labels = array(
|
49 |
+
|
50 |
+
'name' => _x('Slides', 'post type general name'),
|
51 |
+
'singular_name' => _x('Slide', 'post type singular name'),
|
52 |
+
'add_new' => _x('Add New', 'slides'),
|
53 |
+
'add_new_item' => __('Add New Slide'),
|
54 |
+
'edit_item' => __('Edit Slide'),
|
55 |
+
'edit' => _x('Edit', 'slides'),
|
56 |
+
'new_item' => __('New Slide'),
|
57 |
+
'view_item' => __('View Slide'),
|
58 |
+
'search_items' => __('Search Slides'),
|
59 |
+
'not_found' => __('No slides found'),
|
60 |
+
'not_found_in_trash' => __('No slides found in Trash'),
|
61 |
+
'view' => __('View Slide'),
|
62 |
+
'parent_item_colon' => ''
|
63 |
+
|
64 |
+
);
|
65 |
+
|
66 |
+
$args = array(
|
67 |
+
|
68 |
+
'labels' => $labels,
|
69 |
+
'public' => true,
|
70 |
+
'publicly_queryable' => true,
|
71 |
+
'show_ui' => true,
|
72 |
+
'query_var' => 'slides',
|
73 |
+
'rewrite' => true,
|
74 |
+
'capability_type' => 'page',
|
75 |
+
'hierarchical' => false,
|
76 |
+
'menu_position' => 25,
|
77 |
+
'supports' => array('title', 'thumbnail'),
|
78 |
+
'menu_icon' => ''. plugins_url('/images/slides-icon-20x20.png', __FILE__)
|
79 |
+
|
80 |
+
);
|
81 |
+
|
82 |
+
register_post_type( 'slide',$args );
|
83 |
+
|
84 |
+
}
|
85 |
+
|
86 |
+
// Customize and move featured image box to main column
|
87 |
+
|
88 |
+
add_action( 'do_meta_boxes', 'meteorslides_image_box' );
|
89 |
+
|
90 |
+
function meteorslides_image_box() {
|
91 |
+
|
92 |
+
remove_meta_box( 'postimagediv', 'slide', 'side' );
|
93 |
+
|
94 |
+
add_meta_box( 'postimagediv', __('Slide Image'), 'post_thumbnail_meta_box', 'slide', 'normal', 'high' );
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
// Adds meta box for slide URL
|
99 |
+
|
100 |
+
add_action( 'admin_menu', 'meteorslides_create_url_meta_box' );
|
101 |
+
add_action( 'save_post', 'meteorslides_save_postdata' );
|
102 |
+
|
103 |
+
$meteorslides_new_meta_box =
|
104 |
+
|
105 |
+
array(
|
106 |
+
|
107 |
+
'slide_url' => array(
|
108 |
+
|
109 |
+
'name' => 'slide_url',
|
110 |
+
'std' => '',
|
111 |
+
'description' => 'Add the URL this slide should link to.'
|
112 |
+
|
113 |
+
)
|
114 |
+
|
115 |
+
);
|
116 |
+
|
117 |
+
function meteorslides_new_meta_box() {
|
118 |
+
|
119 |
+
global $post, $meteorslides_new_meta_box;
|
120 |
+
|
121 |
+
foreach( $meteorslides_new_meta_box as $meteorslides_meta_box ) {
|
122 |
+
|
123 |
+
$meteorslides_meta_box_value = get_post_meta( $post->ID, $meteorslides_meta_box['name'].'_value', true );
|
124 |
+
|
125 |
+
if( $meteorslides_meta_box_value == "" ) $meteorslides_meta_box_value = $meteorslides_meta_box['std'];
|
126 |
+
|
127 |
+
echo'<input type="hidden" name="'.$meteorslides_meta_box['name'].'_noncename" id="'.$meteorslides_meta_box['name'].'_noncename" value="'.wp_create_nonce( plugin_basename(__FILE__) ).'" />';
|
128 |
+
|
129 |
+
echo'<input type="text" name="'.$meteorslides_meta_box['name'].'_value" value="'.$meteorslides_meta_box_value.'" size="55" /><br />';
|
130 |
+
|
131 |
+
echo'<p>'.$meteorslides_meta_box['description'].'</p>';
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
}
|
136 |
+
|
137 |
+
function meteorslides_create_url_meta_box() {
|
138 |
+
|
139 |
+
global $theme_name;
|
140 |
+
|
141 |
+
if( function_exists('add_meta_box') ) {
|
142 |
+
|
143 |
+
add_meta_box( 'meteorslides-url-box', 'Slide Link', 'meteorslides_new_meta_box', 'slide', 'normal', 'low' );
|
144 |
+
|
145 |
+
}
|
146 |
+
|
147 |
+
}
|
148 |
+
|
149 |
+
function meteorslides_save_postdata( $post_id ) {
|
150 |
+
|
151 |
+
global $post, $meteorslides_new_meta_box;
|
152 |
+
|
153 |
+
foreach( $meteorslides_new_meta_box as $meteorslides_meta_box ) {
|
154 |
+
|
155 |
+
if( !wp_verify_nonce( $_POST[$meteorslides_meta_box['name'].'_noncename'], plugin_basename(__FILE__) ) ) {
|
156 |
+
|
157 |
+
return $post_id;
|
158 |
+
|
159 |
+
}
|
160 |
+
|
161 |
+
if( 'page' == $_POST['post_type'] ) {
|
162 |
+
|
163 |
+
if( !current_user_can( 'edit_page', $post_id ) )
|
164 |
+
|
165 |
+
return $post_id;
|
166 |
+
|
167 |
+
}
|
168 |
+
|
169 |
+
else {
|
170 |
+
|
171 |
+
if( !current_user_can( 'edit_post', $post_id ) )
|
172 |
+
|
173 |
+
return $post_id;
|
174 |
+
|
175 |
+
}
|
176 |
+
|
177 |
+
$data = $_POST[$meteorslides_meta_box['name'].'_value'];
|
178 |
+
|
179 |
+
if( get_post_meta( $post_id, $meteorslides_meta_box['name'].'_value' ) == "" ) {
|
180 |
+
|
181 |
+
add_post_meta( $post_id, $meteorslides_meta_box['name'].'_value', $data, true );
|
182 |
+
|
183 |
+
}
|
184 |
+
|
185 |
+
elseif( $data != get_post_meta( $post_id, $meteorslides_meta_box['name'].'_value', true ) ) {
|
186 |
+
|
187 |
+
update_post_meta( $post_id, $meteorslides_meta_box['name'].'_value', $data );
|
188 |
+
|
189 |
+
}
|
190 |
+
|
191 |
+
elseif( $data == "" ) {
|
192 |
+
|
193 |
+
delete_post_meta( $post_id, $meteorslides_meta_box['name'].'_value', get_post_meta( $post_id, $meteorslides_meta_box['name'].'_value', true ) );
|
194 |
+
|
195 |
+
}
|
196 |
+
|
197 |
+
}
|
198 |
+
|
199 |
+
}
|
200 |
+
|
201 |
+
// Adds settings page
|
202 |
+
|
203 |
+
add_action( 'admin_menu', 'meteorslides_menu' );
|
204 |
+
|
205 |
+
function meteorslides_menu() {
|
206 |
+
|
207 |
+
add_submenu_page( 'edit.php?post_type=slide', 'Slides Settings', 'Settings', 'manage_options', 'slides-settings', 'meteorslides_settings_page' );
|
208 |
+
|
209 |
+
}
|
210 |
+
|
211 |
+
function meteorslides_settings_page() {
|
212 |
+
|
213 |
+
include( 'meteor-slides-settings.php' );
|
214 |
+
|
215 |
+
}
|
216 |
+
|
217 |
+
// Register options for settings page
|
218 |
+
|
219 |
+
add_action('admin_init', 'meteorslides_register_settings');
|
220 |
+
|
221 |
+
function meteorslides_register_settings(){
|
222 |
+
|
223 |
+
register_setting( 'meteorslides_options', 'meteorslides_options', 'meteorslides_options_validate' );
|
224 |
+
|
225 |
+
add_settings_section('meteorslides_slideshow', 'Configure Slideshow', 'meteorslides_section_text', 'meteorslides');
|
226 |
+
|
227 |
+
add_settings_field('slideshow_quantity', 'Slideshow Quantity', 'slideshow_quantity', 'meteorslides', 'meteorslides_slideshow');
|
228 |
+
|
229 |
+
add_settings_field('slide_height', 'Slide Height', 'slide_height', 'meteorslides', 'meteorslides_slideshow');
|
230 |
+
|
231 |
+
add_settings_field('slide_width', 'Slide Width', 'slide_width', 'meteorslides', 'meteorslides_slideshow');
|
232 |
+
|
233 |
+
add_settings_field('transition_style', 'Transition Style', 'transition_style', 'meteorslides', 'meteorslides_slideshow');
|
234 |
+
|
235 |
+
add_settings_field('transition_speed', 'Transition Speed', 'transition_speed', 'meteorslides', 'meteorslides_slideshow');
|
236 |
+
|
237 |
+
add_settings_field('slide_duration', 'Slide Duration', 'slide_duration', 'meteorslides', 'meteorslides_slideshow');
|
238 |
+
|
239 |
+
}
|
240 |
+
|
241 |
+
// Adds default values for options on settings page
|
242 |
+
|
243 |
+
register_activation_hook(__FILE__, 'meteorslides_default_options');
|
244 |
+
|
245 |
+
function meteorslides_default_options() {
|
246 |
+
|
247 |
+
$tmp = get_option('meteorslides_options');
|
248 |
+
|
249 |
+
if(($tmp['chkbox1']=='on')||(!is_array($tmp))) {
|
250 |
+
|
251 |
+
$arr = array("slideshow_quantity" => "5", "slide_height" => "200", "slide_width" => "940", "transition_style" => "fade", "transition_speed" => "2", "slide_duration" => "5");
|
252 |
+
|
253 |
+
update_option('meteorslides_options', $arr);
|
254 |
+
|
255 |
+
}
|
256 |
+
|
257 |
+
}
|
258 |
+
|
259 |
+
// Validates values for options on settings page
|
260 |
+
|
261 |
+
function meteorslides_options_validate($input) {
|
262 |
+
|
263 |
+
$options = get_option('meteorslides_options');
|
264 |
+
|
265 |
+
$options['slideshow_quantity'] = trim($input['slideshow_quantity']);
|
266 |
+
|
267 |
+
if(!preg_match('/^[0-9]{1,3}$/i', $options['slideshow_quantity'])) {
|
268 |
+
|
269 |
+
$options['slideshow_quantity'] = '';
|
270 |
+
|
271 |
+
}
|
272 |
+
|
273 |
+
$options['slide_height'] = trim($input['slide_height']);
|
274 |
+
|
275 |
+
if(!preg_match('/^[0-9]{1,4}$/i', $options['slide_height'])) {
|
276 |
+
|
277 |
+
$options['slide_height'] = '';
|
278 |
+
|
279 |
+
}
|
280 |
+
|
281 |
+
$options['slide_width'] = trim($input['slide_width']);
|
282 |
+
|
283 |
+
if(!preg_match('/^[0-9]{1,5}$/i', $options['slide_width'])) {
|
284 |
+
|
285 |
+
$options['slide_width'] = '';
|
286 |
+
|
287 |
+
}
|
288 |
+
|
289 |
+
$options['transition_style'] = trim($input['transition_style']);
|
290 |
+
|
291 |
+
if(!preg_match('/^[a-z]{4,20}$/i', $options['transition_style'])) {
|
292 |
+
|
293 |
+
$options['transition_style'] = '';
|
294 |
+
|
295 |
+
}
|
296 |
+
|
297 |
+
$options['transition_speed'] = trim($input['transition_speed']);
|
298 |
+
|
299 |
+
if(!preg_match('/^[0-9]{1,3}$/i', $options['transition_speed'])) {
|
300 |
+
|
301 |
+
$options['transition_speed'] = '';
|
302 |
+
|
303 |
+
}
|
304 |
+
|
305 |
+
$options['slide_duration'] = trim($input['slide_duration']);
|
306 |
+
|
307 |
+
if(!preg_match('/^[0-9]{1,3}$/i', $options['slide_duration'])) {
|
308 |
+
|
309 |
+
$options['slide_duration'] = '';
|
310 |
+
|
311 |
+
}
|
312 |
+
|
313 |
+
return $options;
|
314 |
+
|
315 |
+
}
|
316 |
+
|
317 |
+
// Adds CSS for the admin pages
|
318 |
+
|
319 |
+
add_action('admin_head', 'meteorslides_admin_css');
|
320 |
+
|
321 |
+
function meteorslides_admin_css() {
|
322 |
+
|
323 |
+
global $post_type; if (($_GET['post_type'] == 'slide') || ($post_type == 'slide')) :
|
324 |
+
|
325 |
+
echo "<link type='text/css' rel='stylesheet' href='" . plugins_url('/css/meteor-slides-admin.css', __FILE__) . "' />";
|
326 |
+
|
327 |
+
endif;
|
328 |
+
|
329 |
+
}
|
330 |
+
|
331 |
+
// Adds JavaScript for the slideshow
|
332 |
+
|
333 |
+
add_action( 'wp_print_scripts', 'meteorslides_javascript' );
|
334 |
+
|
335 |
+
function meteorslides_javascript() {
|
336 |
+
|
337 |
+
$meteorslides_plugin_url = trailingslashit( get_bloginfo('wpurl') ).PLUGINDIR.'/'. dirname( plugin_basename(__FILE__) );
|
338 |
+
|
339 |
+
$options = get_option( 'meteorslides_options' );
|
340 |
+
|
341 |
+
if( !is_admin() ) {
|
342 |
+
|
343 |
+
wp_enqueue_script( 'jquery' );
|
344 |
+
wp_enqueue_script( 'jquery-cycle', $meteorslides_plugin_url.'/js/jquery.cycle.all.js', array( 'jquery' ) );
|
345 |
+
wp_enqueue_script( 'meteorslides-script', $meteorslides_plugin_url.'/js/slideshow.js', array( 'jquery', 'jquery-cycle' ) );
|
346 |
+
wp_localize_script( 'meteorslides-script', 'meteorslidessettings',
|
347 |
+
|
348 |
+
array(
|
349 |
+
|
350 |
+
'meteorslideshowspeed' => $options['transition_speed'] * 1000,
|
351 |
+
'meteorslideshowduration' => $options['slide_duration'] * 1000,
|
352 |
+
'meteorslideshowtransition' => $options['transition_style']
|
353 |
+
|
354 |
+
)
|
355 |
+
|
356 |
+
);
|
357 |
+
|
358 |
+
}
|
359 |
+
|
360 |
+
}
|
361 |
+
|
362 |
+
// Adds function to load slideshow in theme
|
363 |
+
|
364 |
+
function meteor_slideshow() {
|
365 |
+
|
366 |
+
include( 'meteor-slideshow.php' );
|
367 |
+
|
368 |
+
}
|
369 |
+
|
370 |
+
/* To load the slideshow, add this line to your theme:
|
371 |
+
|
372 |
+
<?php if(function_exists('meteor_slideshow')) { meteor_slideshow(); } ?>
|
373 |
+
|
374 |
+
*/
|
375 |
+
|
376 |
+
// Adds shortcode to load slideshow in content
|
377 |
+
|
378 |
+
add_shortcode( 'meteor_slideshow', 'meteor_slideshow' );
|
379 |
+
|
380 |
+
/* To load the slideshow, add this line to your page or post:
|
381 |
+
|
382 |
+
[meteor_slideshow]
|
383 |
+
|
384 |
+
*/
|
385 |
+
|
386 |
+
?>
|
meteor-slides-settings.php
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Populate the sections and settings of the options page
|
4 |
+
|
5 |
+
function meteorslides_section_text() {
|
6 |
+
|
7 |
+
echo "<p>Set up your slideshow using the options below.</p>";
|
8 |
+
|
9 |
+
}
|
10 |
+
|
11 |
+
function slideshow_quantity() {
|
12 |
+
|
13 |
+
$options = get_option('meteorslides_options');
|
14 |
+
|
15 |
+
echo "<input id='slideshow_quantity' name='meteorslides_options[slideshow_quantity]' size='20' type='text' value='{$options['slideshow_quantity']}' />";
|
16 |
+
|
17 |
+
}
|
18 |
+
|
19 |
+
function slide_height() {
|
20 |
+
|
21 |
+
$options = get_option('meteorslides_options');
|
22 |
+
|
23 |
+
echo "<input id='slide_height' name='meteorslides_options[slide_height]' size='20' type='text' value='{$options['slide_height']}' /> px";
|
24 |
+
|
25 |
+
}
|
26 |
+
|
27 |
+
function slide_width() {
|
28 |
+
|
29 |
+
$options = get_option('meteorslides_options');
|
30 |
+
|
31 |
+
echo "<input id='slide_width' name='meteorslides_options[slide_width]' size='20' type='text' value='{$options['slide_width']}' /> px";
|
32 |
+
|
33 |
+
}
|
34 |
+
|
35 |
+
function transition_style() {
|
36 |
+
|
37 |
+
$options = get_option('meteorslides_options');
|
38 |
+
|
39 |
+
$items = array("blindX", "blindY", "blindZ", "cover", "curtainX", "curtainY", "fade", "fadeZoom", "growX", "growY", "none", "scrollUp", "scrollDown", "scrollLeft", "scrollRight", "scrollHorz", "scrollVert", "slideX", "slideY", "shuffle", "turnUp", "turnDown", "turnLeft", "turnRight", "uncover", "wipe", "zoom");
|
40 |
+
|
41 |
+
echo "<select id='transition_style' name='meteorslides_options[transition_style]' style='width:142px;'>";
|
42 |
+
|
43 |
+
foreach($items as $item) {
|
44 |
+
|
45 |
+
$selected = ($options['transition_style']==$item) ? 'selected="selected"' : '';
|
46 |
+
|
47 |
+
echo "<option value='$item' $selected>$item</option>";
|
48 |
+
|
49 |
+
}
|
50 |
+
|
51 |
+
echo "</select>";
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
function transition_speed() {
|
56 |
+
|
57 |
+
$options = get_option('meteorslides_options');
|
58 |
+
|
59 |
+
echo "<input id='transition_speed' name='meteorslides_options[transition_speed]' size='20' type='text' value='{$options['transition_speed']}' /> seconds";
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
+
function slide_duration() {
|
64 |
+
|
65 |
+
$options = get_option('meteorslides_options');
|
66 |
+
|
67 |
+
echo "<input id='slide_duration' name='meteorslides_options[slide_duration]' size='20' type='text' value='{$options['slide_duration']}' /> seconds";
|
68 |
+
|
69 |
+
}
|
70 |
+
|
71 |
+
?>
|
72 |
+
|
73 |
+
<div class="wrap">
|
74 |
+
|
75 |
+
<div id="icon-edit" class="icon32"><br /></div>
|
76 |
+
|
77 |
+
<h2>Meteor Slides Settings</h2>
|
78 |
+
|
79 |
+
<form action="options.php" method="post">
|
80 |
+
|
81 |
+
<?php
|
82 |
+
|
83 |
+
settings_fields('meteorslides_options');
|
84 |
+
|
85 |
+
do_settings_sections('meteorslides');
|
86 |
+
|
87 |
+
?>
|
88 |
+
|
89 |
+
<p class="submit">
|
90 |
+
|
91 |
+
<input name="Submit" type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
92 |
+
|
93 |
+
</p>
|
94 |
+
|
95 |
+
</form>
|
96 |
+
|
97 |
+
<h3>Install Slideshow</h3>
|
98 |
+
|
99 |
+
<p>Use <code><?php if(function_exists('meteor_slideshow')) { meteor_slideshow(); } ?></code> to add this slideshow to your theme, or use <code>[meteor_slideshow]</code> to add it to your Post or Page content.
|
100 |
+
|
101 |
+
<p><em>Please <a title="Post a question or problem in the forums" href="http://wordpress.org/tags/meteor-slides?forum_id=10#postform">post any questions or problems</a> in the WordPress.org support forums.</em></p>
|
102 |
+
|
103 |
+
</div><!-- .wrap -->
|
meteor-slideshow.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php global $post;
|
2 |
+
|
3 |
+
$options = get_option( 'meteorslides_options' );
|
4 |
+
|
5 |
+
$loop = new WP_Query( array( 'post_type' => 'slide', 'posts_per_page' => $options['slideshow_quantity'] ) ); ?>
|
6 |
+
|
7 |
+
<div class="meteor-slideshow" style="height:<?php echo $options['slide_height'] ?>px; width:<?php echo $options['slide_width'] ?>px; overflow:hidden">
|
8 |
+
|
9 |
+
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
|
10 |
+
|
11 |
+
<div class="slide">
|
12 |
+
|
13 |
+
<?php if(get_post_meta($post->ID, "slide_url_value", $single = true) != ""): ?>
|
14 |
+
|
15 |
+
<a href="<?php echo get_post_meta($post->ID, "slide_url_value", $single = true); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail('featured-slide'); ?></a>
|
16 |
+
|
17 |
+
<?php else: ?>
|
18 |
+
|
19 |
+
<?php the_post_thumbnail('featured-slide'); ?>
|
20 |
+
|
21 |
+
<?php endif; ?>
|
22 |
+
|
23 |
+
</div><!-- .slide -->
|
24 |
+
|
25 |
+
<?php endwhile; ?>
|
26 |
+
|
27 |
+
</div><!-- .meteor-slideshow -->
|
readme.txt
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Plugin Name ===
|
2 |
+
Contributors: JLeuze
|
3 |
+
Tags: slide, slider, slideshow, custom post types, jquery
|
4 |
+
Requires at least: 3.0
|
5 |
+
Tested up to: 3.0
|
6 |
+
Stable tag: 1.0
|
7 |
+
|
8 |
+
Adds a custom post type for slides to WordPress. Use Meteor Slides to create a quick little slideshow for your site.
|
9 |
+
|
10 |
+
== Description ==
|
11 |
+
|
12 |
+
This plugin makes it simple to manage a slideshow with WordPress by adding a custom post type for slides. The slideshow is powered by [jQuery Cycle](http://jquery.malsup.com/cycle/) and has over twenty transition styles to choose from.
|
13 |
+
|
14 |
+
The slides are managed as featured images through the media library; they will automatically be cropped to the dimensions specified on the settings page. Optionally, each slide can link to any Post, Page, or external URL of your choice.
|
15 |
+
|
16 |
+
= Features =
|
17 |
+
|
18 |
+
* **Easy integration:** Add the slideshow to your site using a template tag or shortcode.
|
19 |
+
* **Slideshow settings page:** Control the slide height and width, the number of slides, and the slideshow speed and transition style.
|
20 |
+
* **Slideshow transition styles:** blindX, blindY, blindZ, cover, curtainX, curtainY, fade, fadeZoom, growX, growY, none, scrollUp, scrollDown, scrollLeft, scrollRight, scrollHorz, scrollVert, slideX, slideY, turnUp, turnDown, turnLeft, turnRight, uncover, wipe, zoom.
|
21 |
+
|
22 |
+
= Future Features =
|
23 |
+
|
24 |
+
* Multiple slideshows.
|
25 |
+
* Choose which slides display.
|
26 |
+
* Reorder slides.
|
27 |
+
* Slideshow widget.
|
28 |
+
|
29 |
+
[*Got an idea for a feature?*](http://wordpress.org/tags/meteor-slides?forum_id=10#postform "Post feedback or ideas in the forums")
|
30 |
+
|
31 |
+
== Installation ==
|
32 |
+
|
33 |
+
1. Upload the `meteor-slides` folder to your `/wp-content/plugins/` directory.
|
34 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress
|
35 |
+
3. Use `<?php if(function_exists('meteor_slideshow')) { meteor_slideshow(); } ?>` to add this slideshow to your theme, or use `[meteor_slideshow]` to add it to your Post or Page content.
|
36 |
+
|
37 |
+
Before adding any slides, go to the Meteor Slides Settings page and set the slide height and width so that those slides are cropped to the correct size.
|
38 |
+
|
39 |
+
*Please [post any questions or problems](http://wordpress.org/tags/meteor-slides?forum_id=10#postform "Post a question or problem in the forums") in the WordPress.org support forums.*
|
40 |
+
|
41 |
+
== Screenshots ==
|
42 |
+
|
43 |
+
1. New Slide Page
|
44 |
+
2. Meteor Slides Settings
|
45 |
+
|
46 |
+
== Changelog ==
|
47 |
+
|
48 |
+
= 1.0 =
|
49 |
+
* Initial release of Meteor Slides.
|
screenshot-1.jpg
ADDED
Binary file
|
screenshot-2.jpg
ADDED
Binary file
|