Posted By

ryarwood on 01/30/12


Tagged

base site starter


Versions (?)

Javascript Base


 / Published in: JavaScript
 

  1. /*
  2.  
  3. ::: ::: ::: ::::::::: ::: ::: :::::::: :::::::: :::::::::
  4.   :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+:
  5.   +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+
  6.   +#++: +#++:++#++: +#++:++#: +#+ +:+ +#+ +#+ +:+ +#+ +:+ +#+ +:+
  7.   +#+ +#+ +#+ +#+ +#+ +#+ +#+#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+
  8.  #+# #+# #+# #+# #+# #+#+# #+#+# #+# #+# #+# #+# #+# #+#
  9. ### ### ### ### ### ### ### ######## ######## #########
  10.  
  11. Yarwood Interactive Development 2012 (yarwoodco.com). Easing thanks to George
  12. Smith (gsgd.co.uk). Cycle thanks to (malsup.com). Nothing to hide here, feel
  13. free to poke around.
  14.  
  15. */
  16.  
  17. /*================================
  18. >> BASE
  19. ================================*/
  20.  
  21. jQuery.easing['jswing'] = jQuery.easing['swing'];
  22.  
  23. jQuery.extend( jQuery.easing,
  24. {
  25. def: 'easeOutQuad',
  26. swing: function (x, t, b, c, d) {
  27. //alert(jQuery.easing.default);
  28. return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
  29. },
  30. easeInQuad: function (x, t, b, c, d) {
  31. return c*(t/=d)*t + b;
  32. },
  33. easeOutQuad: function (x, t, b, c, d) {
  34. return -c *(t/=d)*(t-2) + b;
  35. },
  36. easeInOutQuad: function (x, t, b, c, d) {
  37. if ((t/=d/2) < 1) return c/2*t*t + b;
  38. return -c/2 * ((--t)*(t-2) - 1) + b;
  39. },
  40. easeInCubic: function (x, t, b, c, d) {
  41. return c*(t/=d)*t*t + b;
  42. },
  43. easeOutCubic: function (x, t, b, c, d) {
  44. return c*((t=t/d-1)*t*t + 1) + b;
  45. },
  46. easeInOutCubic: function (x, t, b, c, d) {
  47. if ((t/=d/2) < 1) return c/2*t*t*t + b;
  48. return c/2*((t-=2)*t*t + 2) + b;
  49. },
  50. easeInQuart: function (x, t, b, c, d) {
  51. return c*(t/=d)*t*t*t + b;
  52. },
  53. easeOutQuart: function (x, t, b, c, d) {
  54. return -c * ((t=t/d-1)*t*t*t - 1) + b;
  55. },
  56. easeInOutQuart: function (x, t, b, c, d) {
  57. if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
  58. return -c/2 * ((t-=2)*t*t*t - 2) + b;
  59. },
  60. easeInQuint: function (x, t, b, c, d) {
  61. return c*(t/=d)*t*t*t*t + b;
  62. },
  63. easeOutQuint: function (x, t, b, c, d) {
  64. return c*((t=t/d-1)*t*t*t*t + 1) + b;
  65. },
  66. easeInOutQuint: function (x, t, b, c, d) {
  67. if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
  68. return c/2*((t-=2)*t*t*t*t + 2) + b;
  69. },
  70. easeInSine: function (x, t, b, c, d) {
  71. return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
  72. },
  73. easeOutSine: function (x, t, b, c, d) {
  74. return c * Math.sin(t/d * (Math.PI/2)) + b;
  75. },
  76. easeInOutSine: function (x, t, b, c, d) {
  77. return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
  78. },
  79. easeInExpo: function (x, t, b, c, d) {
  80. return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
  81. },
  82. easeOutExpo: function (x, t, b, c, d) {
  83. return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
  84. },
  85. easeInOutExpo: function (x, t, b, c, d) {
  86. if (t==0) return b;
  87. if (t==d) return b+c;
  88. if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
  89. return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
  90. },
  91. easeInCirc: function (x, t, b, c, d) {
  92. return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
  93. },
  94. easeOutCirc: function (x, t, b, c, d) {
  95. return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
  96. },
  97. easeInOutCirc: function (x, t, b, c, d) {
  98. if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
  99. return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
  100. },
  101. easeInElastic: function (x, t, b, c, d) {
  102. var s=1.70158;var p=0;var a=c;
  103. if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
  104. if (a < Math.abs(c)) { a=c; var s=p/4; }
  105. else var s = p/(2*Math.PI) * Math.asin (c/a);
  106. return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  107. },
  108. easeOutElastic: function (x, t, b, c, d) {
  109. var s=1.70158;var p=0;var a=c;
  110. if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
  111. if (a < Math.abs(c)) { a=c; var s=p/4; }
  112. else var s = p/(2*Math.PI) * Math.asin (c/a);
  113. return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
  114. },
  115. easeInOutElastic: function (x, t, b, c, d) {
  116. var s=1.70158;var p=0;var a=c;
  117. if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
  118. if (a < Math.abs(c)) { a=c; var s=p/4; }
  119. else var s = p/(2*Math.PI) * Math.asin (c/a);
  120. if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  121. return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
  122. },
  123. easeInBack: function (x, t, b, c, d, s) {
  124. if (s == undefined) s = 1.70158;
  125. return c*(t/=d)*t*((s+1)*t - s) + b;
  126. },
  127. easeOutBack: function (x, t, b, c, d, s) {
  128. if (s == undefined) s = 1.70158;
  129. return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
  130. },
  131. easeInOutBack: function (x, t, b, c, d, s) {
  132. if (s == undefined) s = 1.70158;
  133. if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
  134. return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
  135. },
  136. easeInBounce: function (x, t, b, c, d) {
  137. return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
  138. },
  139. easeOutBounce: function (x, t, b, c, d) {
  140. if ((t/=d) < (1/2.75)) {
  141. return c*(7.5625*t*t) + b;
  142. } else if (t < (2/2.75)) {
  143. return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
  144. } else if (t < (2.5/2.75)) {
  145. return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
  146. } else {
  147. return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
  148. }
  149. },
  150. easeInOutBounce: function (x, t, b, c, d) {
  151. if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
  152. return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
  153. }
  154. });
  155.  
  156. ;(function($, undefined) {
  157.  
  158. var ver = '2.9999';
  159.  
  160. // if $.support is not defined (pre jQuery 1.3) add what I need
  161. if ($.support == undefined) {
  162. $.support = {
  163. opacity: !($.browser.msie)
  164. };
  165. }
  166.  
  167. function debug(s) {
  168. $.fn.cycle.debug && log(s);
  169. }
  170. function log() {
  171. window.console && console.log && console.log('[cycle] ' + Array.prototype.join.call(arguments,' '));
  172. }
  173. $.expr[':'].paused = function(el) {
  174. return el.cyclePause;
  175. }
  176.  
  177. // the options arg can be...
  178. // a number - indicates an immediate transition should occur to the given slide index
  179. // a string - 'pause', 'resume', 'toggle', 'next', 'prev', 'stop', 'destroy' or the name of a transition effect (ie, 'fade', 'zoom', etc)
  180. // an object - properties to control the slideshow
  181. //
  182. // the arg2 arg can be...
  183. // the name of an fx (only used in conjunction with a numeric value for 'options')
  184. // the value true (only used in first arg == 'resume') and indicates
  185. // that the resume should occur immediately (not wait for next timeout)
  186.  
  187. $.fn.cycle = function(options, arg2) {
  188. var o = { s: this.selector, c: this.context };
  189.  
  190. // in 1.3+ we can fix mistakes with the ready state
  191. if (this.length === 0 && options != 'stop') {
  192. if (!$.isReady && o.s) {
  193. log('DOM not ready, queuing slideshow');
  194. $(function() {
  195. $(o.s,o.c).cycle(options,arg2);
  196. });
  197. return this;
  198. }
  199. // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
  200. log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
  201. return this;
  202. }
  203.  
  204. // iterate the matched nodeset
  205. return this.each(function() {
  206. var opts = handleArguments(this, options, arg2);
  207. if (opts === false)
  208. return;
  209.  
  210. opts.updateActivePagerLink = opts.updateActivePagerLink || $.fn.cycle.updateActivePagerLink;
  211.  
  212. // stop existing slideshow for this container (if there is one)
  213. if (this.cycleTimeout)
  214. clearTimeout(this.cycleTimeout);
  215. this.cycleTimeout = this.cyclePause = 0;
  216.  
  217. var $cont = $(this);
  218. var $slides = opts.slideExpr ? $(opts.slideExpr, this) : $cont.children();
  219. var els = $slides.get();
  220.  
  221. var opts2 = buildOptions($cont, $slides, els, opts, o);
  222. if (opts2 === false)
  223. return;
  224.  
  225. if (els.length < 2) {
  226. log('terminating; too few slides: ' + els.length);
  227. return;
  228. }
  229.  
  230. var startTime = opts2.continuous ? 10 : getTimeout(els[opts2.currSlide], els[opts2.nextSlide], opts2, !opts2.backwards);
  231.  
  232. // if it's an auto slideshow, kick it off
  233. if (startTime) {
  234. startTime += (opts2.delay || 0);
  235. if (startTime < 10)
  236. startTime = 10;
  237. debug('first timeout: ' + startTime);
  238. this.cycleTimeout = setTimeout(function(){go(els,opts2,0,!opts.backwards)}, startTime);
  239. }
  240. });
  241. };
  242.  
  243. function triggerPause(cont, byHover, onPager) {
  244. var opts = $(cont).data('cycle.opts');
  245. var paused = !!cont.cyclePause;
  246. if (paused && opts.paused)
  247. opts.paused(cont, opts, byHover, onPager);
  248. else if (!paused && opts.resumed)
  249. opts.resumed(cont, opts, byHover, onPager);
  250. }
  251.  
  252. // process the args that were passed to the plugin fn
  253. function handleArguments(cont, options, arg2) {
  254. if (cont.cycleStop == undefined)
  255. cont.cycleStop = 0;
  256. if (options === undefined || options === null)
  257. options = {};
  258. if (options.constructor == String) {
  259. switch(options) {
  260. case 'destroy':
  261. case 'stop':
  262. var opts = $(cont).data('cycle.opts');
  263. if (!opts)
  264. return false;
  265. cont.cycleStop++; // callbacks look for change
  266. if (cont.cycleTimeout)
  267. clearTimeout(cont.cycleTimeout);
  268. cont.cycleTimeout = 0;
  269. opts.elements && $(opts.elements).stop();
  270. $(cont).removeData('cycle.opts');
  271. if (options == 'destroy')
  272. destroy(opts);
  273. return false;
  274. case 'toggle':
  275. cont.cyclePause = (cont.cyclePause === 1) ? 0 : 1;
  276. checkInstantResume(cont.cyclePause, arg2, cont);
  277. triggerPause(cont);
  278. return false;
  279. case 'pause':
  280. cont.cyclePause = 1;
  281. triggerPause(cont);
  282. return false;
  283. case 'resume':
  284. cont.cyclePause = 0;
  285. checkInstantResume(false, arg2, cont);
  286. triggerPause(cont);
  287. return false;
  288. case 'prev':
  289. case 'next':
  290. var opts = $(cont).data('cycle.opts');
  291. if (!opts) {
  292. log('options not found, "prev/next" ignored');
  293. return false;
  294. }
  295. $.fn.cycle[options](opts);
  296. return false;
  297. default:
  298. options = { fx: options };
  299. };
  300. return options;
  301. }
  302. else if (options.constructor == Number) {
  303. // go to the requested slide
  304. var num = options;
  305. options = $(cont).data('cycle.opts');
  306. if (!options) {
  307. log('options not found, can not advance slide');
  308. return false;
  309. }
  310. if (num < 0 || num >= options.elements.length) {
  311. log('invalid slide index: ' + num);
  312. return false;
  313. }
  314. options.nextSlide = num;
  315. if (cont.cycleTimeout) {
  316. clearTimeout(cont.cycleTimeout);
  317. cont.cycleTimeout = 0;
  318. }
  319. if (typeof arg2 == 'string')
  320. options.oneTimeFx = arg2;
  321. go(options.elements, options, 1, num >= options.currSlide);
  322. return false;
  323. }
  324. return options;
  325.  
  326. function checkInstantResume(isPaused, arg2, cont) {
  327. if (!isPaused && arg2 === true) { // resume now!
  328. var options = $(cont).data('cycle.opts');
  329. if (!options) {
  330. log('options not found, can not resume');
  331. return false;
  332. }
  333. if (cont.cycleTimeout) {
  334. clearTimeout(cont.cycleTimeout);
  335. cont.cycleTimeout = 0;
  336. }
  337. go(options.elements, options, 1, !options.backwards);
  338. }
  339. }
  340. };
  341.  
  342. function removeFilter(el, opts) {
  343. if (!$.support.opacity && opts.cleartype && el.style.filter) {
  344. try { el.style.removeAttribute('filter'); }
  345. catch(smother) {} // handle old opera versions
  346. }
  347. };
  348.  
  349. // unbind event handlers
  350. function destroy(opts) {
  351. if (opts.next)
  352. $(opts.next).unbind(opts.prevNextEvent);
  353. if (opts.prev)
  354. $(opts.prev).unbind(opts.prevNextEvent);
  355.  
  356. if (opts.pager || opts.pagerAnchorBuilder)
  357. $.each(opts.pagerAnchors || [], function() {
  358. this.unbind().remove();
  359. });
  360. opts.pagerAnchors = null;
  361. if (opts.destroy) // callback
  362. opts.destroy(opts);
  363. };
  364.  
  365. // one-time initialization
  366. function buildOptions($cont, $slides, els, options, o) {
  367. var startingSlideSpecified;
  368. // support metadata plugin (v1.0 and v2.0)
  369. var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {});
  370. var meta = $.isFunction($cont.data) ? $cont.data(opts.metaAttr) : null;
  371. if (meta)
  372. opts = $.extend(opts, meta);
  373. if (opts.autostop)
  374. opts.countdown = opts.autostopCount || els.length;
  375.  
  376. var cont = $cont[0];
  377. $cont.data('cycle.opts', opts);
  378. opts.$cont = $cont;
  379. opts.stopCount = cont.cycleStop;
  380. opts.elements = els;
  381. opts.before = opts.before ? [opts.before] : [];
  382. opts.after = opts.after ? [opts.after] : [];
  383.  
  384. // push some after callbacks
  385. if (!$.support.opacity && opts.cleartype)
  386. opts.after.push(function() { removeFilter(this, opts); });
  387. if (opts.continuous)
  388. opts.after.push(function() { go(els,opts,0,!opts.backwards); });
  389.  
  390. saveOriginalOpts(opts);
  391.  
  392. // clearType corrections
  393. if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
  394. clearTypeFix($slides);
  395.  
  396. // container requires non-static position so that slides can be position within
  397. if ($cont.css('position') == 'static')
  398. $cont.css('position', 'relative');
  399. if (opts.width)
  400. $cont.width(opts.width);
  401. if (opts.height && opts.height != 'auto')
  402. $cont.height(opts.height);
  403.  
  404. if (opts.startingSlide != undefined) {
  405. opts.startingSlide = parseInt(opts.startingSlide,10);
  406. if (opts.startingSlide >= els.length || opts.startSlide < 0)
  407. opts.startingSlide = 0; // catch bogus input
  408. else
  409. startingSlideSpecified = true;
  410. }
  411. else if (opts.backwards)
  412. opts.startingSlide = els.length - 1;
  413. else
  414. opts.startingSlide = 0;
  415.  
  416. // if random, mix up the slide array
  417. if (opts.random) {
  418. opts.randomMap = [];
  419. for (var i = 0; i < els.length; i++)
  420. opts.randomMap.push(i);
  421. opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;});
  422. if (startingSlideSpecified) {
  423. // try to find the specified starting slide and if found set start slide index in the map accordingly
  424. for ( var cnt = 0; cnt < els.length; cnt++ ) {
  425. if ( opts.startingSlide == opts.randomMap[cnt] ) {
  426. opts.randomIndex = cnt;
  427. }
  428. }
  429. }
  430. else {
  431. opts.randomIndex = 1;
  432. opts.startingSlide = opts.randomMap[1];
  433. }
  434. }
  435. else if (opts.startingSlide >= els.length)
  436. opts.startingSlide = 0; // catch bogus input
  437. opts.currSlide = opts.startingSlide || 0;
  438. var first = opts.startingSlide;
  439.  
  440. // set position and zIndex on all the slides
  441. $slides.css({position: 'absolute', top:0, left:0}).hide().each(function(i) {
  442. var z;
  443. if (opts.backwards)
  444. z = first ? i <= first ? els.length + (i-first) : first-i : els.length-i;
  445. else
  446. z = first ? i >= first ? els.length - (i-first) : first-i : els.length-i;
  447. $(this).css('z-index', z)
  448. });
  449.  
  450. // make sure first slide is visible
  451. $(els[first]).css('opacity',1).show(); // opacity bit needed to handle restart use case
  452. removeFilter(els[first], opts);
  453.  
  454. // stretch slides
  455. if (opts.fit) {
  456. if (!opts.aspect) {
  457. if (opts.width)
  458. $slides.width(opts.width);
  459. if (opts.height && opts.height != 'auto')
  460. $slides.height(opts.height);
  461. } else {
  462. $slides.each(function(){
  463. var $slide = $(this);
  464. var ratio = (opts.aspect === true) ? $slide.width()/$slide.height() : opts.aspect;
  465. if( opts.width && $slide.width() != opts.width ) {
  466. $slide.width( opts.width );
  467. $slide.height( opts.width / ratio );
  468. }
  469.  
  470. if( opts.height && $slide.height() < opts.height ) {
  471. $slide.height( opts.height );
  472. $slide.width( opts.height * ratio );
  473. }
  474. });
  475. }
  476. }
  477.  
  478. if (opts.center && ((!opts.fit) || opts.aspect)) {
  479. $slides.each(function(){
  480. var $slide = $(this);
  481. $slide.css({
  482. "margin-left": opts.width ?
  483. ((opts.width - $slide.width()) / 2) + "px" :
  484. 0,
  485. "margin-top": opts.height ?
  486. ((opts.height - $slide.height()) / 2) + "px" :
  487. 0
  488. });
  489. });
  490. }
  491.  
  492. if (opts.center && !opts.fit && !opts.slideResize) {
  493. $slides.each(function(){
  494. var $slide = $(this);
  495. $slide.css({
  496. "margin-left": opts.width ? ((opts.width - $slide.width()) / 2) + "px" : 0,
  497. "margin-top": opts.height ? ((opts.height - $slide.height()) / 2) + "px" : 0
  498. });
  499. });
  500. }
  501.  
  502. // stretch container
  503. var reshape = opts.containerResize && !$cont.innerHeight();
  504. if (reshape) { // do this only if container has no size http://tinyurl.com/da2oa9
  505. var maxw = 0, maxh = 0;
  506. for(var j=0; j < els.length; j++) {
  507. var $e = $(els[j]), e = $e[0], w = $e.outerWidth(), h = $e.outerHeight();
  508. if (!w) w = e.offsetWidth || e.width || $e.attr('width');
  509. if (!h) h = e.offsetHeight || e.height || $e.attr('height');
  510. maxw = w > maxw ? w : maxw;
  511. maxh = h > maxh ? h : maxh;
  512. }
  513. if (maxw > 0 && maxh > 0)
  514. $cont.css({width:maxw+'px',height:maxh+'px'});
  515. }
  516.  
  517. var pauseFlag = false; // https://github.com/malsup/cycle/issues/44
  518. if (opts.pause)
  519. $cont.hover(
  520. function(){
  521. pauseFlag = true;
  522. this.cyclePause++;
  523. triggerPause(cont, true);
  524. },
  525. function(){
  526. pauseFlag && this.cyclePause--;
  527. triggerPause(cont, true);
  528. }
  529. );
  530.  
  531. if (supportMultiTransitions(opts) === false)
  532. return false;
  533.  
  534. // apparently a lot of people use image slideshows without height/width attributes on the images.
  535. // Cycle 2.50+ requires the sizing info for every slide; this block tries to deal with that.
  536. var requeue = false;
  537. options.requeueAttempts = options.requeueAttempts || 0;
  538. $slides.each(function() {
  539. // try to get height/width of each slide
  540. var $el = $(this);
  541. this.cycleH = (opts.fit && opts.height) ? opts.height : ($el.height() || this.offsetHeight || this.height || $el.attr('height') || 0);
  542. this.cycleW = (opts.fit && opts.width) ? opts.width : ($el.width() || this.offsetWidth || this.width || $el.attr('width') || 0);
  543.  
  544. if ( $el.is('img') ) {
  545. // sigh.. sniffing, hacking, shrugging... this crappy hack tries to account for what browsers do when
  546. // an image is being downloaded and the markup did not include sizing info (height/width attributes);
  547. // there seems to be some "default" sizes used in this situation
  548. var loadingIE = ($.browser.msie && this.cycleW == 28 && this.cycleH == 30 && !this.complete);
  549. var loadingFF = ($.browser.mozilla && this.cycleW == 34 && this.cycleH == 19 && !this.complete);
  550. var loadingOp = ($.browser.opera && ((this.cycleW == 42 && this.cycleH == 19) || (this.cycleW == 37 && this.cycleH == 17)) && !this.complete);
  551. var loadingOther = (this.cycleH == 0 && this.cycleW == 0 && !this.complete);
  552. // don't requeue for images that are still loading but have a valid size
  553. if (loadingIE || loadingFF || loadingOp || loadingOther) {
  554. if (o.s && opts.requeueOnImageNotLoaded && ++options.requeueAttempts < 100) { // track retry count so we don't loop forever
  555. log(options.requeueAttempts,' - img slide not loaded, requeuing slideshow: ', this.src, this.cycleW, this.cycleH);
  556. setTimeout(function() {$(o.s,o.c).cycle(options)}, opts.requeueTimeout);
  557. requeue = true;
  558. return false; // break each loop
  559. }
  560. else {
  561. log('could not determine size of image: '+this.src, this.cycleW, this.cycleH);
  562. }
  563. }
  564. }
  565. return true;
  566. });
  567.  
  568. if (requeue)
  569. return false;
  570.  
  571. opts.cssBefore = opts.cssBefore || {};
  572. opts.cssAfter = opts.cssAfter || {};
  573. opts.cssFirst = opts.cssFirst || {};
  574. opts.animIn = opts.animIn || {};
  575. opts.animOut = opts.animOut || {};
  576.  
  577. $slides.not(':eq('+first+')').css(opts.cssBefore);
  578. $($slides[first]).css(opts.cssFirst);
  579.  
  580. if (opts.timeout) {
  581. opts.timeout = parseInt(opts.timeout,10);
  582. // ensure that timeout and speed settings are sane
  583. if (opts.speed.constructor == String)
  584. opts.speed = $.fx.speeds[opts.speed] || parseInt(opts.speed,10);
  585. if (!opts.sync)
  586. opts.speed = opts.speed / 2;
  587.  
  588. var buffer = opts.fx == 'none' ? 0 : opts.fx == 'shuffle' ? 500 : 250;
  589. while((opts.timeout - opts.speed) < buffer) // sanitize timeout
  590. opts.timeout += opts.speed;
  591. }
  592. if (opts.easing)
  593. opts.easeIn = opts.easeOut = opts.easing;
  594. if (!opts.speedIn)
  595. opts.speedIn = opts.speed;
  596. if (!opts.speedOut)
  597. opts.speedOut = opts.speed;
  598.  
  599. opts.slideCount = els.length;
  600. opts.currSlide = opts.lastSlide = first;
  601. if (opts.random) {
  602. if (++opts.randomIndex == els.length)
  603. opts.randomIndex = 0;
  604. opts.nextSlide = opts.randomMap[opts.randomIndex];
  605. }
  606. else if (opts.backwards)
  607. opts.nextSlide = opts.startingSlide == 0 ? (els.length-1) : opts.startingSlide-1;
  608. else
  609. opts.nextSlide = opts.startingSlide >= (els.length-1) ? 0 : opts.startingSlide+1;
  610.  
  611. // run transition init fn
  612. if (!opts.multiFx) {
  613. var init = $.fn.cycle.transitions[opts.fx];
  614. if ($.isFunction(init))
  615. init($cont, $slides, opts);
  616. else if (opts.fx != 'custom' && !opts.multiFx) {
  617. log('unknown transition: ' + opts.fx,'; slideshow terminating');
  618. return false;
  619. }
  620. }
  621.  
  622. // fire artificial events
  623. var e0 = $slides[first];
  624. if (!opts.skipInitializationCallbacks) {
  625. if (opts.before.length)
  626. opts.before[0].apply(e0, [e0, e0, opts, true]);
  627. if (opts.after.length)
  628. opts.after[0].apply(e0, [e0, e0, opts, true]);
  629. }
  630. if (opts.next)
  631. $(opts.next).bind(opts.prevNextEvent,function(){return advance(opts,1)});
  632. if (opts.prev)
  633. $(opts.prev).bind(opts.prevNextEvent,function(){return advance(opts,0)});
  634. if (opts.pager || opts.pagerAnchorBuilder)
  635. buildPager(els,opts);
  636.  
  637. exposeAddSlide(opts, els);
  638.  
  639. return opts;
  640. };
  641.  
  642. // save off original opts so we can restore after clearing state
  643. function saveOriginalOpts(opts) {
  644. opts.original = { before: [], after: [] };
  645. opts.original.cssBefore = $.extend({}, opts.cssBefore);
  646. opts.original.cssAfter = $.extend({}, opts.cssAfter);
  647. opts.original.animIn = $.extend({}, opts.animIn);
  648. opts.original.animOut = $.extend({}, opts.animOut);
  649. $.each(opts.before, function() { opts.original.before.push(this); });
  650. $.each(opts.after, function() { opts.original.after.push(this); });
  651. };
  652.  
  653. function supportMultiTransitions(opts) {
  654. var i, tx, txs = $.fn.cycle.transitions;
  655. // look for multiple effects
  656. if (opts.fx.indexOf(',') > 0) {
  657. opts.multiFx = true;
  658. opts.fxs = opts.fx.replace(/\s*/g,'').split(',');
  659. // discard any bogus effect names
  660. for (i=0; i < opts.fxs.length; i++) {
  661. var fx = opts.fxs[i];
  662. tx = txs[fx];
  663. if (!tx || !txs.hasOwnProperty(fx) || !$.isFunction(tx)) {
  664. log('discarding unknown transition: ',fx);
  665. opts.fxs.splice(i,1);
  666. i--;
  667. }
  668. }
  669. // if we have an empty list then we threw everything away!
  670. if (!opts.fxs.length) {
  671. log('No valid transitions named; slideshow terminating.');
  672. return false;
  673. }
  674. }
  675. else if (opts.fx == 'all') { // auto-gen the list of transitions
  676. opts.multiFx = true;
  677. opts.fxs = [];
  678. for (p in txs) {
  679. tx = txs[p];
  680. if (txs.hasOwnProperty(p) && $.isFunction(tx))
  681. opts.fxs.push(p);
  682. }
  683. }
  684. if (opts.multiFx && opts.randomizeEffects) {
  685. // munge the fxs array to make effect selection random
  686. var r1 = Math.floor(Math.random() * 20) + 30;
  687. for (i = 0; i < r1; i++) {
  688. var r2 = Math.floor(Math.random() * opts.fxs.length);
  689. opts.fxs.push(opts.fxs.splice(r2,1)[0]);
  690. }
  691. debug('randomized fx sequence: ',opts.fxs);
  692. }
  693. return true;
  694. };
  695.  
  696. // provide a mechanism for adding slides after the slideshow has started
  697. function exposeAddSlide(opts, els) {
  698. opts.addSlide = function(newSlide, prepend) {
  699. var $s = $(newSlide), s = $s[0];
  700. if (!opts.autostopCount)
  701. opts.countdown++;
  702. els[prepend?'unshift':'push'](s);
  703. if (opts.els)
  704. opts.els[prepend?'unshift':'push'](s); // shuffle needs this
  705. opts.slideCount = els.length;
  706.  
  707. // add the slide to the random map and resort
  708. if (opts.random) {
  709. opts.randomMap.push(opts.slideCount-1);
  710. opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;});
  711. }
  712.  
  713. $s.css('position','absolute');
  714. $s[prepend?'prependTo':'appendTo'](opts.$cont);
  715.  
  716. if (prepend) {
  717. opts.currSlide++;
  718. opts.nextSlide++;
  719. }
  720.  
  721. if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
  722. clearTypeFix($s);
  723.  
  724. if (opts.fit && opts.width)
  725. $s.width(opts.width);
  726. if (opts.fit && opts.height && opts.height != 'auto')
  727. $s.height(opts.height);
  728. s.cycleH = (opts.fit && opts.height) ? opts.height : $s.height();
  729. s.cycleW = (opts.fit && opts.width) ? opts.width : $s.width();
  730.  
  731. $s.css(opts.cssBefore);
  732.  
  733. if (opts.pager || opts.pagerAnchorBuilder)
  734. $.fn.cycle.createPagerAnchor(els.length-1, s, $(opts.pager), els, opts);
  735.  
  736. if ($.isFunction(opts.onAddSlide))
  737. opts.onAddSlide($s);
  738. else
  739. $s.hide(); // default behavior
  740. };
  741. }
  742.  
  743. // reset internal state; we do this on every pass in order to support multiple effects
  744. $.fn.cycle.resetState = function(opts, fx) {
  745. fx = fx || opts.fx;
  746. opts.before = []; opts.after = [];
  747. opts.cssBefore = $.extend({}, opts.original.cssBefore);
  748. opts.cssAfter = $.extend({}, opts.original.cssAfter);
  749. opts.animIn = $.extend({}, opts.original.animIn);
  750. opts.animOut = $.extend({}, opts.original.animOut);
  751. opts.fxFn = null;
  752. $.each(opts.original.before, function() { opts.before.push(this); });
  753. $.each(opts.original.after, function() { opts.after.push(this); });
  754.  
  755. // re-init
  756. var init = $.fn.cycle.transitions[fx];
  757. if ($.isFunction(init))
  758. init(opts.$cont, $(opts.elements), opts);
  759. };
  760.  
  761. // this is the main engine fn, it handles the timeouts, callbacks and slide index mgmt
  762. function go(els, opts, manual, fwd) {
  763. // opts.busy is true if we're in the middle of an animation
  764. if (manual && opts.busy && opts.manualTrump) {
  765. // let manual transitions requests trump active ones
  766. debug('manualTrump in go(), stopping active transition');
  767. $(els).stop(true,true);
  768. opts.busy = 0;
  769. }
  770. // don't begin another timeout-based transition if there is one active
  771. if (opts.busy) {
  772. debug('transition active, ignoring new tx request');
  773. return;
  774. }
  775.  
  776. var p = opts.$cont[0], curr = els[opts.currSlide], next = els[opts.nextSlide];
  777.  
  778. // stop cycling if we have an outstanding stop request
  779. if (p.cycleStop != opts.stopCount || p.cycleTimeout === 0 && !manual)
  780. return;
  781.  
  782. // check to see if we should stop cycling based on autostop options
  783. if (!manual && !p.cyclePause && !opts.bounce &&
  784. ((opts.autostop && (--opts.countdown <= 0)) ||
  785. (opts.nowrap && !opts.random && opts.nextSlide < opts.currSlide))) {
  786. if (opts.end)
  787. opts.end(opts);
  788. return;
  789. }
  790.  
  791. // if slideshow is paused, only transition on a manual trigger
  792. var changed = false;
  793. if ((manual || !p.cyclePause) && (opts.nextSlide != opts.currSlide)) {
  794. changed = true;
  795. var fx = opts.fx;
  796. // keep trying to get the slide size if we don't have it yet
  797. curr.cycleH = curr.cycleH || $(curr).height();
  798. curr.cycleW = curr.cycleW || $(curr).width();
  799. next.cycleH = next.cycleH || $(next).height();
  800. next.cycleW = next.cycleW || $(next).width();
  801.  
  802. // support multiple transition types
  803. if (opts.multiFx) {
  804. if (fwd && (opts.lastFx == undefined || ++opts.lastFx >= opts.fxs.length))
  805. opts.lastFx = 0;
  806. else if (!fwd && (opts.lastFx == undefined || --opts.lastFx < 0))
  807. opts.lastFx = opts.fxs.length - 1;
  808. fx = opts.fxs[opts.lastFx];
  809. }
  810.  
  811. // one-time fx overrides apply to: $('div').cycle(3,'zoom');
  812. if (opts.oneTimeFx) {
  813. fx = opts.oneTimeFx;
  814. opts.oneTimeFx = null;
  815. }
  816.  
  817. $.fn.cycle.resetState(opts, fx);
  818.  
  819. // run the before callbacks
  820. if (opts.before.length)
  821. $.each(opts.before, function(i,o) {
  822. if (p.cycleStop != opts.stopCount) return;
  823. o.apply(next, [curr, next, opts, fwd]);
  824. });
  825.  
  826. // stage the after callacks
  827. var after = function() {
  828. opts.busy = 0;
  829. $.each(opts.after, function(i,o) {
  830. if (p.cycleStop != opts.stopCount) return;
  831. o.apply(next, [curr, next, opts, fwd]);
  832. });
  833. if (!p.cycleStop) {
  834. // queue next transition
  835. queueNext();
  836. }
  837. };
  838.  
  839. debug('tx firing('+fx+'); currSlide: ' + opts.currSlide + '; nextSlide: ' + opts.nextSlide);
  840.  
  841. // get ready to perform the transition
  842. opts.busy = 1;
  843. if (opts.fxFn) // fx function provided?
  844. opts.fxFn(curr, next, opts, after, fwd, manual && opts.fastOnEvent);
  845. else if ($.isFunction($.fn.cycle[opts.fx])) // fx plugin ?
  846. $.fn.cycle[opts.fx](curr, next, opts, after, fwd, manual && opts.fastOnEvent);
  847. else
  848. $.fn.cycle.custom(curr, next, opts, after, fwd, manual && opts.fastOnEvent);
  849. }
  850. else {
  851. queueNext();
  852. }
  853.  
  854. if (changed || opts.nextSlide == opts.currSlide) {
  855. // calculate the next slide
  856. opts.lastSlide = opts.currSlide;
  857. if (opts.random) {
  858. opts.currSlide = opts.nextSlide;
  859. if (++opts.randomIndex == els.length) {
  860. opts.randomIndex = 0;
  861. opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;});
  862. }
  863. opts.nextSlide = opts.randomMap[opts.randomIndex];
  864. if (opts.nextSlide == opts.currSlide)
  865. opts.nextSlide = (opts.currSlide == opts.slideCount - 1) ? 0 : opts.currSlide + 1;
  866. }
  867. else if (opts.backwards) {
  868. var roll = (opts.nextSlide - 1) < 0;
  869. if (roll && opts.bounce) {
  870. opts.backwards = !opts.backwards;
  871. opts.nextSlide = 1;
  872. opts.currSlide = 0;
  873. }
  874. else {
  875. opts.nextSlide = roll ? (els.length-1) : opts.nextSlide-1;
  876. opts.currSlide = roll ? 0 : opts.nextSlide+1;
  877. }
  878. }
  879. else { // sequence
  880. var roll = (opts.nextSlide + 1) == els.length;
  881. if (roll && opts.bounce) {
  882. opts.backwards = !opts.backwards;
  883. opts.nextSlide = els.length-2;
  884. opts.currSlide = els.length-1;
  885. }
  886. else {
  887. opts.nextSlide = roll ? 0 : opts.nextSlide+1;
  888. opts.currSlide = roll ? els.length-1 : opts.nextSlide-1;
  889. }
  890. }
  891. }
  892. if (changed && opts.pager)
  893. opts.updateActivePagerLink(opts.pager, opts.currSlide, opts.activePagerClass);
  894.  
  895. function queueNext() {
  896. // stage the next transition
  897. var ms = 0, timeout = opts.timeout;
  898. if (opts.timeout && !opts.continuous) {
  899. ms = getTimeout(els[opts.currSlide], els[opts.nextSlide], opts, fwd);
  900. if (opts.fx == 'shuffle')
  901. ms -= opts.speedOut;
  902. }
  903. else if (opts.continuous && p.cyclePause) // continuous shows work off an after callback, not this timer logic
  904. ms = 10;
  905. if (ms > 0)
  906. p.cycleTimeout = setTimeout(function(){ go(els, opts, 0, !opts.backwards) }, ms);
  907. }
  908. };
  909.  
  910. // invoked after transition
  911. $.fn.cycle.updateActivePagerLink = function(pager, currSlide, clsName) {
  912. $(pager).each(function() {
  913. $(this).children().removeClass(clsName).eq(currSlide).addClass(clsName);
  914. });
  915. };
  916.  
  917. // calculate timeout value for current transition
  918. function getTimeout(curr, next, opts, fwd) {
  919. if (opts.timeoutFn) {
  920. // call user provided calc fn
  921. var t = opts.timeoutFn.call(curr,curr,next,opts,fwd);
  922. while (opts.fx != 'none' && (t - opts.speed) < 250) // sanitize timeout
  923. t += opts.speed;
  924. debug('calculated timeout: ' + t + '; speed: ' + opts.speed);
  925. if (t !== false)
  926. return t;
  927. }
  928. return opts.timeout;
  929. };
  930.  
  931. // expose next/prev function, caller must pass in state
  932. $.fn.cycle.next = function(opts) { advance(opts,1); };
  933. $.fn.cycle.prev = function(opts) { advance(opts,0);};
  934.  
  935. // advance slide forward or back
  936. function advance(opts, moveForward) {
  937. var val = moveForward ? 1 : -1;
  938. var els = opts.elements;
  939. var p = opts.$cont[0], timeout = p.cycleTimeout;
  940. if (timeout) {
  941. clearTimeout(timeout);
  942. p.cycleTimeout = 0;
  943. }
  944. if (opts.random && val < 0) {
  945. // move back to the previously display slide
  946. opts.randomIndex--;
  947. if (--opts.randomIndex == -2)
  948. opts.randomIndex = els.length-2;
  949. else if (opts.randomIndex == -1)
  950. opts.randomIndex = els.length-1;
  951. opts.nextSlide = opts.randomMap[opts.randomIndex];
  952. }
  953. else if (opts.random) {
  954. opts.nextSlide = opts.randomMap[opts.randomIndex];
  955. }
  956. else {
  957. opts.nextSlide = opts.currSlide + val;
  958. if (opts.nextSlide < 0) {
  959. if (opts.nowrap) return false;
  960. opts.nextSlide = els.length - 1;
  961. }
  962. else if (opts.nextSlide >= els.length) {
  963. if (opts.nowrap) return false;
  964. opts.nextSlide = 0;
  965. }
  966. }
  967.  
  968. var cb = opts.onPrevNextEvent || opts.prevNextClick; // prevNextClick is deprecated
  969. if ($.isFunction(cb))
  970. cb(val > 0, opts.nextSlide, els[opts.nextSlide]);
  971. go(els, opts, 1, moveForward);
  972. return false;
  973. };
  974.  
  975. function buildPager(els, opts) {
  976. var $p = $(opts.pager);
  977. $.each(els, function(i,o) {
  978. $.fn.cycle.createPagerAnchor(i,o,$p,els,opts);
  979. });
  980. opts.updateActivePagerLink(opts.pager, opts.startingSlide, opts.activePagerClass);
  981. };
  982.  
  983. $.fn.cycle.createPagerAnchor = function(i, el, $p, els, opts) {
  984. var a;
  985. if ($.isFunction(opts.pagerAnchorBuilder)) {
  986. a = opts.pagerAnchorBuilder(i,el);
  987. debug('pagerAnchorBuilder('+i+', el) returned: ' + a);
  988. }
  989. else
  990. a = '<a href="#">'+(i+1)+'</a>';
  991.  
  992. if (!a)
  993. return;
  994. var $a = $(a);
  995. // don't reparent if anchor is in the dom
  996. if ($a.parents('body').length === 0) {
  997. var arr = [];
  998. if ($p.length > 1) {
  999. $p.each(function() {
  1000. var $clone = $a.clone(true);
  1001. $(this).append($clone);
  1002. arr.push($clone[0]);
  1003. });
  1004. $a = $(arr);
  1005. }
  1006. else {
  1007. $a.appendTo($p);
  1008. }
  1009. }
  1010.  
  1011. opts.pagerAnchors = opts.pagerAnchors || [];
  1012. opts.pagerAnchors.push($a);
  1013.  
  1014. var pagerFn = function(e) {
  1015. e.preventDefault();
  1016. opts.nextSlide = i;
  1017. var p = opts.$cont[0], timeout = p.cycleTimeout;
  1018. if (timeout) {
  1019. clearTimeout(timeout);
  1020. p.cycleTimeout = 0;
  1021. }
  1022. var cb = opts.onPagerEvent || opts.pagerClick; // pagerClick is deprecated
  1023. if ($.isFunction(cb))
  1024. cb(opts.nextSlide, els[opts.nextSlide]);
  1025. go(els,opts,1,opts.currSlide < i); // trigger the trans
  1026. // return false; // <== allow bubble
  1027. }
  1028.  
  1029. if ( /mouseenter|mouseover/i.test(opts.pagerEvent) ) {
  1030. $a.hover(pagerFn, function(){/* no-op */} );
  1031. }
  1032. else {
  1033. $a.bind(opts.pagerEvent, pagerFn);
  1034. }
  1035.  
  1036. if ( ! /^click/.test(opts.pagerEvent) && !opts.allowPagerClickBubble)
  1037. $a.bind('click.cycle', function(){return false;}); // suppress click
  1038.  
  1039. var cont = opts.$cont[0];
  1040. var pauseFlag = false; // https://github.com/malsup/cycle/issues/44
  1041. if (opts.pauseOnPagerHover) {
  1042. $a.hover(
  1043. function() {
  1044. pauseFlag = true;
  1045. cont.cyclePause++;
  1046. triggerPause(cont,true,true);
  1047. }, function() {
  1048. pauseFlag && cont.cyclePause--;
  1049. triggerPause(cont,true,true);
  1050. }
  1051. );
  1052. }
  1053. };
  1054.  
  1055. // helper fn to calculate the number of slides between the current and the next
  1056. $.fn.cycle.hopsFromLast = function(opts, fwd) {
  1057. var hops, l = opts.lastSlide, c = opts.currSlide;
  1058. if (fwd)
  1059. hops = c > l ? c - l : opts.slideCount - l;
  1060. else
  1061. hops = c < l ? l - c : l + opts.slideCount - c;
  1062. return hops;
  1063. };
  1064.  
  1065. // fix clearType problems in ie6 by setting an explicit bg color
  1066. // (otherwise text slides look horrible during a fade transition)
  1067. function clearTypeFix($slides) {
  1068. debug('applying clearType background-color hack');
  1069. function hex(s) {
  1070. s = parseInt(s,10).toString(16);
  1071. return s.length < 2 ? '0'+s : s;
  1072. };
  1073. function getBg(e) {
  1074. for ( ; e && e.nodeName.toLowerCase() != 'html'; e = e.parentNode) {
  1075. var v = $.css(e,'background-color');
  1076. if (v && v.indexOf('rgb') >= 0 ) {
  1077. var rgb = v.match(/\d+/g);
  1078. return '#'+ hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]);
  1079. }
  1080. if (v && v != 'transparent')
  1081. return v;
  1082. }
  1083. return '#ffffff';
  1084. };
  1085. $slides.each(function() { $(this).css('background-color', getBg(this)); });
  1086. };
  1087.  
  1088. // reset common props before the next transition
  1089. $.fn.cycle.commonReset = function(curr,next,opts,w,h,rev) {
  1090. $(opts.elements).not(curr).hide();
  1091. if (typeof opts.cssBefore.opacity == 'undefined')
  1092. opts.cssBefore.opacity = 1;
  1093. opts.cssBefore.display = 'block';
  1094. if (opts.slideResize && w !== false && next.cycleW > 0)
  1095. opts.cssBefore.width = next.cycleW;
  1096. if (opts.slideResize && h !== false && next.cycleH > 0)
  1097. opts.cssBefore.height = next.cycleH;
  1098. opts.cssAfter = opts.cssAfter || {};
  1099. opts.cssAfter.display = 'none';
  1100. $(curr).css('zIndex',opts.slideCount + (rev === true ? 1 : 0));
  1101. $(next).css('zIndex',opts.slideCount + (rev === true ? 0 : 1));
  1102. };
  1103.  
  1104. // the actual fn for effecting a transition
  1105. $.fn.cycle.custom = function(curr, next, opts, cb, fwd, speedOverride) {
  1106. var $l = $(curr), $n = $(next);
  1107. var speedIn = opts.speedIn, speedOut = opts.speedOut, easeIn = opts.easeIn, easeOut = opts.easeOut;
  1108. $n.css(opts.cssBefore);
  1109. if (speedOverride) {
  1110. if (typeof speedOverride == 'number')
  1111. speedIn = speedOut = speedOverride;
  1112. else
  1113. speedIn = speedOut = 1;
  1114. easeIn = easeOut = null;
  1115. }
  1116. var fn = function() {
  1117. $n.animate(opts.animIn, speedIn, easeIn, function() {
  1118. cb();
  1119. });
  1120. };
  1121. $l.animate(opts.animOut, speedOut, easeOut, function() {
  1122. $l.css(opts.cssAfter);
  1123. if (!opts.sync)
  1124. fn();
  1125. });
  1126. if (opts.sync) fn();
  1127. };
  1128.  
  1129. // transition definitions - only fade is defined here, transition pack defines the rest
  1130. $.fn.cycle.transitions = {
  1131. fade: function($cont, $slides, opts) {
  1132. $slides.not(':eq('+opts.currSlide+')').css('opacity',0);
  1133. opts.before.push(function(curr,next,opts) {
  1134. $.fn.cycle.commonReset(curr,next,opts);
  1135. opts.cssBefore.opacity = 0;
  1136. });
  1137. opts.animIn = { opacity: 1 };
  1138. opts.animOut = { opacity: 0 };
  1139. opts.cssBefore = { top: 0, left: 0 };
  1140. }
  1141. };
  1142.  
  1143. $.fn.cycle.ver = function() { return ver; };
  1144.  
  1145. // override these globally if you like (they are all optional)
  1146. $.fn.cycle.defaults = {
  1147. activePagerClass: 'activeSlide', // class name used for the active pager link
  1148. after: null, // transition callback (scope set to element that was shown): function(currSlideElement, nextSlideElement, options, forwardFlag)
  1149. allowPagerClickBubble: false, // allows or prevents click event on pager anchors from bubbling
  1150. animIn: null, // properties that define how the slide animates in
  1151. animOut: null, // properties that define how the slide animates out
  1152. aspect: false, // preserve aspect ratio during fit resizing, cropping if necessary (must be used with fit option)
  1153. autostop: 0, // true to end slideshow after X transitions (where X == slide count)
  1154. autostopCount: 0, // number of transitions (optionally used with autostop to define X)
  1155. backwards: false, // true to start slideshow at last slide and move backwards through the stack
  1156. before: null, // transition callback (scope set to element to be shown): function(currSlideElement, nextSlideElement, options, forwardFlag)
  1157. center: null, // set to true to have cycle add top/left margin to each slide (use with width and height options)
  1158. cleartype: !$.support.opacity, // true if clearType corrections should be applied (for IE)
  1159. cleartypeNoBg: false, // set to true to disable extra cleartype fixing (leave false to force background color setting on slides)
  1160. containerResize: 1, // resize container to fit largest slide
  1161. continuous: 0, // true to start next transition immediately after current one completes
  1162. cssAfter: null, // properties that defined the state of the slide after transitioning out
  1163. cssBefore: null, // properties that define the initial state of the slide before transitioning in
  1164. delay: 0, // additional delay (in ms) for first transition (hint: can be negative)
  1165. easeIn: null, // easing for "in" transition
  1166. easeOut: null, // easing for "out" transition
  1167. easing: null, // easing method for both in and out transitions
  1168. end: null, // callback invoked when the slideshow terminates (use with autostop or nowrap options): function(options)
  1169. fastOnEvent: 0, // force fast transitions when triggered manually (via pager or prev/next); value == time in ms
  1170. fit: 0, // force slides to fit container
  1171. fx: 'fade', // name of transition effect (or comma separated names, ex: 'fade,scrollUp,shuffle')
  1172. fxFn: null, // function used to control the transition: function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag)
  1173. height: 'auto', // container height (if the 'fit' option is true, the slides will be set to this height as well)
  1174. manualTrump: true, // causes manual transition to stop an active transition instead of being ignored
  1175. metaAttr: 'cycle',// data- attribute that holds the option data for the slideshow
  1176. next: null, // element, jQuery object, or jQuery selector string for the element to use as event trigger for next slide
  1177. nowrap: 0, // true to prevent slideshow from wrapping
  1178. onPagerEvent: null, // callback fn for pager events: function(zeroBasedSlideIndex, slideElement)
  1179. onPrevNextEvent: null,// callback fn for prev/next events: function(isNext, zeroBasedSlideIndex, slideElement)
  1180. pager: null, // element, jQuery object, or jQuery selector string for the element to use as pager container
  1181. pagerAnchorBuilder: null, // callback fn for building anchor links: function(index, DOMelement)
  1182. pagerEvent: 'click.cycle', // name of event which drives the pager navigation
  1183. pause: 0, // true to enable "pause on hover"
  1184. pauseOnPagerHover: 0, // true to pause when hovering over pager link
  1185. prev: null, // element, jQuery object, or jQuery selector string for the element to use as event trigger for previous slide
  1186. prevNextEvent:'click.cycle',// event which drives the manual transition to the previous or next slide
  1187. random: 0, // true for random, false for sequence (not applicable to shuffle fx)
  1188. randomizeEffects: 1, // valid when multiple effects are used; true to make the effect sequence random
  1189. requeueOnImageNotLoaded: true, // requeue the slideshow if any image slides are not yet loaded
  1190. requeueTimeout: 250, // ms delay for requeue
  1191. rev: 0, // causes animations to transition in reverse (for effects that support it such as scrollHorz/scrollVert/shuffle)
  1192. shuffle: null, // coords for shuffle animation, ex: { top:15, left: 200 }
  1193. skipInitializationCallbacks: false, // set to true to disable the first before/after callback that occurs prior to any transition
  1194. slideExpr: null, // expression for selecting slides (if something other than all children is required)
  1195. slideResize: 1, // force slide width/height to fixed size before every transition
  1196. speed: 1000, // speed of the transition (any valid fx speed value)
  1197. speedIn: null, // speed of the 'in' transition
  1198. speedOut: null, // speed of the 'out' transition
  1199. startingSlide: undefined, // zero-based index of the first slide to be displayed
  1200. sync: 1, // true if in/out transitions should occur simultaneously
  1201. timeout: 4000, // milliseconds between slide transitions (0 to disable auto advance)
  1202. timeoutFn: null, // callback for determining per-slide timeout value: function(currSlideElement, nextSlideElement, options, forwardFlag)
  1203. updateActivePagerLink: null, // callback fn invoked to update the active pager link (adds/removes activePagerClass style)
  1204. width: null // container width (if the 'fit' option is true, the slides will be set to this width as well)
  1205. };
  1206.  
  1207. })(jQuery);
  1208.  
  1209.  
  1210. /*!
  1211.  * jQuery Cycle Plugin Transition Definitions
  1212.  * This script is a plugin for the jQuery Cycle Plugin
  1213.  * Examples and documentation at: http://malsup.com/jquery/cycle/
  1214.  * Copyright (c) 2007-2010 M. Alsup
  1215.  * Version: 2.73
  1216.  * Dual licensed under the MIT and GPL licenses:
  1217.  * http://www.opensource.org/licenses/mit-license.php
  1218.  * http://www.gnu.org/licenses/gpl.html
  1219.  */
  1220. (function($) {
  1221.  
  1222. //
  1223. // These functions define slide initialization and properties for the named
  1224. // transitions. To save file size feel free to remove any of these that you
  1225. // don't need.
  1226. //
  1227. $.fn.cycle.transitions.none = function($cont, $slides, opts) {
  1228. opts.fxFn = function(curr,next,opts,after){
  1229. $(next).show();
  1230. $(curr).hide();
  1231. after();
  1232. };
  1233. };
  1234.  
  1235. // not a cross-fade, fadeout only fades out the top slide
  1236. $.fn.cycle.transitions.fadeout = function($cont, $slides, opts) {
  1237. $slides.not(':eq('+opts.currSlide+')').css({ display: 'block', 'opacity': 1 });
  1238. opts.before.push(function(curr,next,opts,w,h,rev) {
  1239. $(curr).css('zIndex',opts.slideCount + (!rev === true ? 1 : 0));
  1240. $(next).css('zIndex',opts.slideCount + (!rev === true ? 0 : 1));
  1241. });
  1242. opts.animIn.opacity = 1;
  1243. opts.animOut.opacity = 0;
  1244. opts.cssBefore.opacity = 1;
  1245. opts.cssBefore.display = 'block';
  1246. opts.cssAfter.zIndex = 0;
  1247. };
  1248.  
  1249. // scrollUp/Down/Left/Right
  1250. $.fn.cycle.transitions.scrollUp = function($cont, $slides, opts) {
  1251. $cont.css('overflow','hidden');
  1252. opts.before.push($.fn.cycle.commonReset);
  1253. var h = $cont.height();
  1254. opts.cssBefore.top = h;
  1255. opts.cssBefore.left = 0;
  1256. opts.cssFirst.top = 0;
  1257. opts.animIn.top = 0;
  1258. opts.animOut.top = -h;
  1259. };
  1260. $.fn.cycle.transitions.scrollDown = function($cont, $slides, opts) {
  1261. $cont.css('overflow','hidden');
  1262. opts.before.push($.fn.cycle.commonReset);
  1263. var h = $cont.height();
  1264. opts.cssFirst.top = 0;
  1265. opts.cssBefore.top = -h;
  1266. opts.cssBefore.left = 0;
  1267. opts.animIn.top = 0;
  1268. opts.animOut.top = h;
  1269. };
  1270. $.fn.cycle.transitions.scrollLeft = function($cont, $slides, opts) {
  1271. $cont.css('overflow','hidden');
  1272. opts.before.push($.fn.cycle.commonReset);
  1273. var w = $cont.width();
  1274. opts.cssFirst.left = 0;
  1275. opts.cssBefore.left = w;
  1276. opts.cssBefore.top = 0;
  1277. opts.animIn.left = 0;
  1278. opts.animOut.left = 0-w;
  1279. };
  1280. $.fn.cycle.transitions.scrollRight = function($cont, $slides, opts) {
  1281. $cont.css('overflow','hidden');
  1282. opts.before.push($.fn.cycle.commonReset);
  1283. var w = $cont.width();
  1284. opts.cssFirst.left = 0;
  1285. opts.cssBefore.left = -w;
  1286. opts.cssBefore.top = 0;
  1287. opts.animIn.left = 0;
  1288. opts.animOut.left = w;
  1289. };
  1290. $.fn.cycle.transitions.scrollHorz = function($cont, $slides, opts) {
  1291. $cont.css('overflow','hidden').width();
  1292. opts.before.push(function(curr, next, opts, fwd) {
  1293. if (opts.rev)
  1294. fwd = !fwd;
  1295. $.fn.cycle.commonReset(curr,next,opts);
  1296. opts.cssBefore.left = fwd ? (next.cycleW-1) : (1-next.cycleW);
  1297. opts.animOut.left = fwd ? -curr.cycleW : curr.cycleW;
  1298. });
  1299. opts.cssFirst.left = 0;
  1300. opts.cssBefore.top = 0;
  1301. opts.animIn.left = 0;
  1302. opts.animOut.top = 0;
  1303. };
  1304. $.fn.cycle.transitions.scrollVert = function($cont, $slides, opts) {
  1305. $cont.css('overflow','hidden');
  1306. opts.before.push(function(curr, next, opts, fwd) {
  1307. if (opts.rev)
  1308. fwd = !fwd;
  1309. $.fn.cycle.commonReset(curr,next,opts);
  1310. opts.cssBefore.top = fwd ? (1-next.cycleH) : (next.cycleH-1);
  1311. opts.animOut.top = fwd ? curr.cycleH : -curr.cycleH;
  1312. });
  1313. opts.cssFirst.top = 0;
  1314. opts.cssBefore.left = 0;
  1315. opts.animIn.top = 0;
  1316. opts.animOut.left = 0;
  1317. };
  1318.  
  1319. // slideX/slideY
  1320. $.fn.cycle.transitions.slideX = function($cont, $slides, opts) {
  1321. opts.before.push(function(curr, next, opts) {
  1322. $(opts.elements).not(curr).hide();
  1323. $.fn.cycle.commonReset(curr,next,opts,false,true);
  1324. opts.animIn.width = next.cycleW;
  1325. });
  1326. opts.cssBefore.left = 0;
  1327. opts.cssBefore.top = 0;
  1328. opts.cssBefore.width = 0;
  1329. opts.animIn.width = 'show';
  1330. opts.animOut.width = 0;
  1331. };
  1332. $.fn.cycle.transitions.slideY = function($cont, $slides, opts) {
  1333. opts.before.push(function(curr, next, opts) {
  1334. $(opts.elements).not(curr).hide();
  1335. $.fn.cycle.commonReset(curr,next,opts,true,false);
  1336. opts.animIn.height = next.cycleH;
  1337. });
  1338. opts.cssBefore.left = 0;
  1339. opts.cssBefore.top = 0;
  1340. opts.cssBefore.height = 0;
  1341. opts.animIn.height = 'show';
  1342. opts.animOut.height = 0;
  1343. };
  1344.  
  1345. // shuffle
  1346. $.fn.cycle.transitions.shuffle = function($cont, $slides, opts) {
  1347. var i, w = $cont.css('overflow', 'visible').width();
  1348. $slides.css({left: 0, top: 0});
  1349. opts.before.push(function(curr,next,opts) {
  1350. $.fn.cycle.commonReset(curr,next,opts,true,true,true);
  1351. });
  1352. // only adjust speed once!
  1353. if (!opts.speedAdjusted) {
  1354. opts.speed = opts.speed / 2; // shuffle has 2 transitions
  1355. opts.speedAdjusted = true;
  1356. }
  1357. opts.random = 0;
  1358. opts.shuffle = opts.shuffle || {left:-w, top:15};
  1359. opts.els = [];
  1360. for (i=0; i < $slides.length; i++)
  1361. opts.els.push($slides[i]);
  1362.  
  1363. for (i=0; i < opts.currSlide; i++)
  1364. opts.els.push(opts.els.shift());
  1365.  
  1366. // custom transition fn (hat tip to Benjamin Sterling for this bit of sweetness!)
  1367. opts.fxFn = function(curr, next, opts, cb, fwd) {
  1368. if (opts.rev)
  1369. fwd = !fwd;
  1370. var $el = fwd ? $(curr) : $(next);
  1371. $(next).css(opts.cssBefore);
  1372. var count = opts.slideCount;
  1373. $el.animate(opts.shuffle, opts.speedIn, opts.easeIn, function() {
  1374. var hops = $.fn.cycle.hopsFromLast(opts, fwd);
  1375. for (var k=0; k < hops; k++)
  1376. fwd ? opts.els.push(opts.els.shift()) : opts.els.unshift(opts.els.pop());
  1377. if (fwd) {
  1378. for (var i=0, len=opts.els.length; i < len; i++)
  1379. $(opts.els[i]).css('z-index', len-i+count);
  1380. }
  1381. else {
  1382. var z = $(curr).css('z-index');
  1383. $el.css('z-index', parseInt(z,10)+1+count);
  1384. }
  1385. $el.animate({left:0, top:0}, opts.speedOut, opts.easeOut, function() {
  1386. $(fwd ? this : curr).hide();
  1387. if (cb) cb();
  1388. });
  1389. });
  1390. };
  1391. $.extend(opts.cssBefore, { display: 'block', opacity: 1, top: 0, left: 0 });
  1392. };
  1393.  
  1394. // turnUp/Down/Left/Right
  1395. $.fn.cycle.transitions.turnUp = function($cont, $slides, opts) {
  1396. opts.before.push(function(curr, next, opts) {
  1397. $.fn.cycle.commonReset(curr,next,opts,true,false);
  1398. opts.cssBefore.top = next.cycleH;
  1399. opts.animIn.height = next.cycleH;
  1400. opts.animOut.width = next.cycleW;
  1401. });
  1402. opts.cssFirst.top = 0;
  1403. opts.cssBefore.left = 0;
  1404. opts.cssBefore.height = 0;
  1405. opts.animIn.top = 0;
  1406. opts.animOut.height = 0;
  1407. };
  1408. $.fn.cycle.transitions.turnDown = function($cont, $slides, opts) {
  1409. opts.before.push(function(curr, next, opts) {
  1410. $.fn.cycle.commonReset(curr,next,opts,true,false);
  1411. opts.animIn.height = next.cycleH;
  1412. opts.animOut.top = curr.cycleH;
  1413. });
  1414. opts.cssFirst.top = 0;
  1415. opts.cssBefore.left = 0;
  1416. opts.cssBefore.top = 0;
  1417. opts.cssBefore.height = 0;
  1418. opts.animOut.height = 0;
  1419. };
  1420. $.fn.cycle.transitions.turnLeft = function($cont, $slides, opts) {
  1421. opts.before.push(function(curr, next, opts) {
  1422. $.fn.cycle.commonReset(curr,next,opts,false,true);
  1423. opts.cssBefore.left = next.cycleW;
  1424. opts.animIn.width = next.cycleW;
  1425. });
  1426. opts.cssBefore.top = 0;
  1427. opts.cssBefore.width = 0;
  1428. opts.animIn.left = 0;
  1429. opts.animOut.width = 0;
  1430. };
  1431. $.fn.cycle.transitions.turnRight = function($cont, $slides, opts) {
  1432. opts.before.push(function(curr, next, opts) {
  1433. $.fn.cycle.commonReset(curr,next,opts,false,true);
  1434. opts.animIn.width = next.cycleW;
  1435. opts.animOut.left = curr.cycleW;
  1436. });
  1437. $.extend(opts.cssBefore, { top: 0, left: 0, width: 0 });
  1438. opts.animIn.left = 0;
  1439. opts.animOut.width = 0;
  1440. };
  1441.  
  1442. // zoom
  1443. $.fn.cycle.transitions.zoom = function($cont, $slides, opts) {
  1444. opts.before.push(function(curr, next, opts) {
  1445. $.fn.cycle.commonReset(curr,next,opts,false,false,true);
  1446. opts.cssBefore.top = next.cycleH/2;
  1447. opts.cssBefore.left = next.cycleW/2;
  1448. $.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH });
  1449. $.extend(opts.animOut, { width: 0, height: 0, top: curr.cycleH/2, left: curr.cycleW/2 });
  1450. });
  1451. opts.cssFirst.top = 0;
  1452. opts.cssFirst.left = 0;
  1453. opts.cssBefore.width = 0;
  1454. opts.cssBefore.height = 0;
  1455. };
  1456.  
  1457. // fadeZoom
  1458. $.fn.cycle.transitions.fadeZoom = function($cont, $slides, opts) {
  1459. opts.before.push(function(curr, next, opts) {
  1460. $.fn.cycle.commonReset(curr,next,opts,false,false);
  1461. opts.cssBefore.left = next.cycleW/2;
  1462. opts.cssBefore.top = next.cycleH/2;
  1463. $.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH });
  1464. });
  1465. opts.cssBefore.width = 0;
  1466. opts.cssBefore.height = 0;
  1467. opts.animOut.opacity = 0;
  1468. };
  1469.  
  1470. // blindX
  1471. $.fn.cycle.transitions.blindX = function($cont, $slides, opts) {
  1472. var w = $cont.css('overflow','hidden').width();
  1473. opts.before.push(function(curr, next, opts) {
  1474. $.fn.cycle.commonReset(curr,next,opts);
  1475. opts.animIn.width = next.cycleW;
  1476. opts.animOut.left = curr.cycleW;
  1477. });
  1478. opts.cssBefore.left = w;
  1479. opts.cssBefore.top = 0;
  1480. opts.animIn.left = 0;
  1481. opts.animOut.left = w;
  1482. };
  1483. // blindY
  1484. $.fn.cycle.transitions.blindY = function($cont, $slides, opts) {
  1485. var h = $cont.css('overflow','hidden').height();
  1486. opts.before.push(function(curr, next, opts) {
  1487. $.fn.cycle.commonReset(curr,next,opts);
  1488. opts.animIn.height = next.cycleH;
  1489. opts.animOut.top = curr.cycleH;
  1490. });
  1491. opts.cssBefore.top = h;
  1492. opts.cssBefore.left = 0;
  1493. opts.animIn.top = 0;
  1494. opts.animOut.top = h;
  1495. };
  1496. // blindZ
  1497. $.fn.cycle.transitions.blindZ = function($cont, $slides, opts) {
  1498. var h = $cont.css('overflow','hidden').height();
  1499. var w = $cont.width();
  1500. opts.before.push(function(curr, next, opts) {
  1501. $.fn.cycle.commonReset(curr,next,opts);
  1502. opts.animIn.height = next.cycleH;
  1503. opts.animOut.top = curr.cycleH;
  1504. });
  1505. opts.cssBefore.top = h;
  1506. opts.cssBefore.left = w;
  1507. opts.animIn.top = 0;
  1508. opts.animIn.left = 0;
  1509. opts.animOut.top = h;
  1510. opts.animOut.left = w;
  1511. };
  1512.  
  1513. // growX - grow horizontally from centered 0 width
  1514. $.fn.cycle.transitions.growX = function($cont, $slides, opts) {
  1515. opts.before.push(function(curr, next, opts) {
  1516. $.fn.cycle.commonReset(curr,next,opts,false,true);
  1517. opts.cssBefore.left = this.cycleW/2;
  1518. opts.animIn.left = 0;
  1519. opts.animIn.width = this.cycleW;
  1520. opts.animOut.left = 0;
  1521. });
  1522. opts.cssBefore.top = 0;
  1523. opts.cssBefore.width = 0;
  1524. };
  1525. // growY - grow vertically from centered 0 height
  1526. $.fn.cycle.transitions.growY = function($cont, $slides, opts) {
  1527. opts.before.push(function(curr, next, opts) {
  1528. $.fn.cycle.commonReset(curr,next,opts,true,false);
  1529. opts.cssBefore.top = this.cycleH/2;
  1530. opts.animIn.top = 0;
  1531. opts.animIn.height = this.cycleH;
  1532. opts.animOut.top = 0;
  1533. });
  1534. opts.cssBefore.height = 0;
  1535. opts.cssBefore.left = 0;
  1536. };
  1537.  
  1538. // curtainX - squeeze in both edges horizontally
  1539. $.fn.cycle.transitions.curtainX = function($cont, $slides, opts) {
  1540. opts.before.push(function(curr, next, opts) {
  1541. $.fn.cycle.commonReset(curr,next,opts,false,true,true);
  1542. opts.cssBefore.left = next.cycleW/2;
  1543. opts.animIn.left = 0;
  1544. opts.animIn.width = this.cycleW;
  1545. opts.animOut.left = curr.cycleW/2;
  1546. opts.animOut.width = 0;
  1547. });
  1548. opts.cssBefore.top = 0;
  1549. opts.cssBefore.width = 0;
  1550. };
  1551. // curtainY - squeeze in both edges vertically
  1552. $.fn.cycle.transitions.curtainY = function($cont, $slides, opts) {
  1553. opts.before.push(function(curr, next, opts) {
  1554. $.fn.cycle.commonReset(curr,next,opts,true,false,true);
  1555. opts.cssBefore.top = next.cycleH/2;
  1556. opts.animIn.top = 0;
  1557. opts.animIn.height = next.cycleH;
  1558. opts.animOut.top = curr.cycleH/2;
  1559. opts.animOut.height = 0;
  1560. });
  1561. opts.cssBefore.height = 0;
  1562. opts.cssBefore.left = 0;
  1563. };
  1564.  
  1565. // cover - curr slide covered by next slide
  1566. $.fn.cycle.transitions.cover = function($cont, $slides, opts) {
  1567. var d = opts.direction || 'left';
  1568. var w = $cont.css('overflow','hidden').width();
  1569. var h = $cont.height();
  1570. opts.before.push(function(curr, next, opts) {
  1571. $.fn.cycle.commonReset(curr,next,opts);
  1572. if (d == 'right')
  1573. opts.cssBefore.left = -w;
  1574. else if (d == 'up')
  1575. opts.cssBefore.top = h;
  1576. else if (d == 'down')
  1577. opts.cssBefore.top = -h;
  1578. else
  1579. opts.cssBefore.left = w;
  1580. });
  1581. opts.animIn.left = 0;
  1582. opts.animIn.top = 0;
  1583. opts.cssBefore.top = 0;
  1584. opts.cssBefore.left = 0;
  1585. };
  1586.  
  1587. // uncover - curr slide moves off next slide
  1588. $.fn.cycle.transitions.uncover = function($cont, $slides, opts) {
  1589. var d = opts.direction || 'left';
  1590. var w = $cont.css('overflow','hidden').width();
  1591. var h = $cont.height();
  1592. opts.before.push(function(curr, next, opts) {
  1593. $.fn.cycle.commonReset(curr,next,opts,true,true,true);
  1594. if (d == 'right')
  1595. opts.animOut.left = w;
  1596. else if (d == 'up')
  1597. opts.animOut.top = -h;
  1598. else if (d == 'down')
  1599. opts.animOut.top = h;
  1600. else
  1601. opts.animOut.left = -w;
  1602. });
  1603. opts.animIn.left = 0;
  1604. opts.animIn.top = 0;
  1605. opts.cssBefore.top = 0;
  1606. opts.cssBefore.left = 0;
  1607. };
  1608.  
  1609. // toss - move top slide and fade away
  1610. $.fn.cycle.transitions.toss = function($cont, $slides, opts) {
  1611. var w = $cont.css('overflow','visible').width();
  1612. var h = $cont.height();
  1613. opts.before.push(function(curr, next, opts) {
  1614. $.fn.cycle.commonReset(curr,next,opts,true,true,true);
  1615. // provide default toss settings if animOut not provided
  1616. if (!opts.animOut.left && !opts.animOut.top)
  1617. $.extend(opts.animOut, { left: w*2, top: -h/2, opacity: 0 });
  1618. else
  1619. opts.animOut.opacity = 0;
  1620. });
  1621. opts.cssBefore.left = 0;
  1622. opts.cssBefore.top = 0;
  1623. opts.animIn.left = 0;
  1624. };
  1625.  
  1626. // wipe - clip animation
  1627. $.fn.cycle.transitions.wipe = function($cont, $slides, opts) {
  1628. var w = $cont.css('overflow','hidden').width();
  1629. var h = $cont.height();
  1630. opts.cssBefore = opts.cssBefore || {};
  1631. var clip;
  1632. if (opts.clip) {
  1633. if (/l2r/.test(opts.clip))
  1634. clip = 'rect(0px 0px '+h+'px 0px)';
  1635. else if (/r2l/.test(opts.clip))
  1636. clip = 'rect(0px '+w+'px '+h+'px '+w+'px)';
  1637. else if (/t2b/.test(opts.clip))
  1638. clip = 'rect(0px '+w+'px 0px 0px)';
  1639. else if (/b2t/.test(opts.clip))
  1640. clip = 'rect('+h+'px '+w+'px '+h+'px 0px)';
  1641. else if (/zoom/.test(opts.clip)) {
  1642. var top = parseInt(h/2,10);
  1643. var left = parseInt(w/2,10);
  1644. clip = 'rect('+top+'px '+left+'px '+top+'px '+left+'px)';
  1645. }
  1646. }
  1647.  
  1648. opts.cssBefore.clip = opts.cssBefore.clip || clip || 'rect(0px 0px 0px 0px)';
  1649.  
  1650. var d = opts.cssBefore.clip.match(/(\d+)/g);
  1651. var t = parseInt(d[0],10), r = parseInt(d[1],10), b = parseInt(d[2],10), l = parseInt(d[3],10);
  1652.  
  1653. opts.before.push(function(curr, next, opts) {
  1654. if (curr == next) return;
  1655. var $curr = $(curr), $next = $(next);
  1656. $.fn.cycle.commonReset(curr,next,opts,true,true,false);
  1657. opts.cssAfter.display = 'block';
  1658.  
  1659. var step = 1, count = parseInt((opts.speedIn / 13),10) - 1;
  1660. (function f() {
  1661. var tt = t ? t - parseInt(step * (t/count),10) : 0;
  1662. var ll = l ? l - parseInt(step * (l/count),10) : 0;
  1663. var bb = b < h ? b + parseInt(step * ((h-b)/count || 1),10) : h;
  1664. var rr = r < w ? r + parseInt(step * ((w-r)/count || 1),10) : w;
  1665. $next.css({ clip: 'rect('+tt+'px '+rr+'px '+bb+'px '+ll+'px)' });
  1666. (step++ <= count) ? setTimeout(f, 13) : $curr.css('display', 'none');
  1667. })();
  1668. });
  1669. $.extend(opts.cssBefore, { display: 'block', opacity: 1, top: 0, left: 0 });
  1670. opts.animIn = { left: 0 };
  1671. opts.animOut = { left: 0 };
  1672. };
  1673.  
  1674. })(jQuery);
  1675.  
  1676. function MM_preloadImages() { //v3.0
  1677. var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  1678. var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  1679. if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  1680. }
  1681.  
  1682. function MM_swapImgRestore() { //v3.0
  1683. var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
  1684. }
  1685.  
  1686. function MM_findObj(n, d) { //v4.01
  1687. var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  1688. d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  1689. if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  1690. for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  1691. if(!x && d.getElementById) x=d.getElementById(n); return x;
  1692. }
  1693.  
  1694. function MM_swapImage() { //v3.0
  1695. var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  1696. if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
  1697. }
  1698.  
  1699. /*================================
  1700. >> ADDITIONS
  1701. ================================*/

Report this snippet  

You need to login to post a comment.