jquery.flexslider.js 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128
  1. /*
  2. * jQuery FlexSlider v2.2.0
  3. * Copyright 2012 WooThemes
  4. * Contributing Author: Tyler Smith
  5. */
  6. ;
  7. (function ($) {
  8. //FlexSlider: Object Instance
  9. $.flexslider = function(el, options) {
  10. var slider = $(el);
  11. // making variables public
  12. slider.vars = $.extend({}, $.flexslider.defaults, options);
  13. var namespace = slider.vars.namespace,
  14. msGesture = window.navigator && window.navigator.msPointerEnabled && window.MSGesture,
  15. touch = (( "ontouchstart" in window ) || msGesture || window.DocumentTouch && document instanceof DocumentTouch) && slider.vars.touch,
  16. // depricating this idea, as devices are being released with both of these events
  17. //eventType = (touch) ? "touchend" : "click",
  18. eventType = "click touchend MSPointerUp",
  19. watchedEvent = "",
  20. watchedEventClearTimer,
  21. vertical = slider.vars.direction === "vertical",
  22. reverse = slider.vars.reverse,
  23. carousel = (slider.vars.itemWidth > 0),
  24. fade = slider.vars.animation === "fade",
  25. asNav = slider.vars.asNavFor !== "",
  26. methods = {},
  27. focused = true;
  28. // Store a reference to the slider object
  29. $.data(el, "flexslider", slider);
  30. // Private slider methods
  31. methods = {
  32. init: function() {
  33. slider.animating = false;
  34. // Get current slide and make sure it is a number
  35. slider.currentSlide = parseInt( ( slider.vars.startAt ? slider.vars.startAt : 0) );
  36. if ( isNaN( slider.currentSlide ) ) slider.currentSlide = 0;
  37. slider.animatingTo = slider.currentSlide;
  38. slider.atEnd = (slider.currentSlide === 0 || slider.currentSlide === slider.last);
  39. slider.containerSelector = slider.vars.selector.substr(0,slider.vars.selector.search(' '));
  40. slider.slides = $(slider.vars.selector, slider);
  41. slider.container = $(slider.containerSelector, slider);
  42. slider.count = slider.slides.length;
  43. // SYNC:
  44. slider.syncExists = $(slider.vars.sync).length > 0;
  45. // SLIDE:
  46. if (slider.vars.animation === "slide") slider.vars.animation = "swing";
  47. slider.prop = (vertical) ? "top" : "marginLeft";
  48. slider.args = {};
  49. // SLIDESHOW:
  50. slider.manualPause = false;
  51. slider.stopped = false;
  52. //PAUSE WHEN INVISIBLE
  53. slider.started = false;
  54. slider.startTimeout = null;
  55. // TOUCH/USECSS:
  56. slider.transitions = !slider.vars.video && !fade && slider.vars.useCSS && (function() {
  57. var obj = document.createElement('div'),
  58. props = ['perspectiveProperty', 'WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective'];
  59. for (var i in props) {
  60. if ( obj.style[ props[i] ] !== undefined ) {
  61. slider.pfx = props[i].replace('Perspective','').toLowerCase();
  62. slider.prop = "-" + slider.pfx + "-transform";
  63. return true;
  64. }
  65. }
  66. return false;
  67. }());
  68. // CONTROLSCONTAINER:
  69. if (slider.vars.controlsContainer !== "") slider.controlsContainer = $(slider.vars.controlsContainer).length > 0 && $(slider.vars.controlsContainer);
  70. // MANUAL:
  71. if (slider.vars.manualControls !== "") slider.manualControls = $(slider.vars.manualControls).length > 0 && $(slider.vars.manualControls);
  72. // RANDOMIZE:
  73. if (slider.vars.randomize) {
  74. slider.slides.sort(function() { return (Math.round(Math.random())-0.5); });
  75. slider.container.empty().append(slider.slides);
  76. }
  77. slider.doMath();
  78. // INIT
  79. slider.setup("init");
  80. // CONTROLNAV:
  81. if (slider.vars.controlNav) methods.controlNav.setup();
  82. // DIRECTIONNAV:
  83. if (slider.vars.directionNav) methods.directionNav.setup();
  84. // KEYBOARD:
  85. if (slider.vars.keyboard && ($(slider.containerSelector).length === 1 || slider.vars.multipleKeyboard)) {
  86. $(document).bind('keyup', function(event) {
  87. var keycode = event.keyCode;
  88. if (!slider.animating && (keycode === 39 || keycode === 37)) {
  89. var target = (keycode === 39) ? slider.getTarget('next') :
  90. (keycode === 37) ? slider.getTarget('prev') : false;
  91. slider.flexAnimate(target, slider.vars.pauseOnAction);
  92. }
  93. });
  94. }
  95. // MOUSEWHEEL:
  96. if (slider.vars.mousewheel) {
  97. slider.bind('mousewheel', function(event, delta, deltaX, deltaY) {
  98. event.preventDefault();
  99. var target = (delta < 0) ? slider.getTarget('next') : slider.getTarget('prev');
  100. slider.flexAnimate(target, slider.vars.pauseOnAction);
  101. });
  102. }
  103. // PAUSEPLAY
  104. if (slider.vars.pausePlay) methods.pausePlay.setup();
  105. //PAUSE WHEN INVISIBLE
  106. if (slider.vars.slideshow && slider.vars.pauseInvisible) methods.pauseInvisible.init();
  107. // SLIDSESHOW
  108. if (slider.vars.slideshow) {
  109. if (slider.vars.pauseOnHover) {
  110. slider.hover(function() {
  111. if (!slider.manualPlay && !slider.manualPause) slider.pause();
  112. }, function() {
  113. if (!slider.manualPause && !slider.manualPlay && !slider.stopped) slider.play();
  114. });
  115. }
  116. // initialize animation
  117. //If we're visible, or we don't use PageVisibility API
  118. if(!slider.vars.pauseInvisible || !methods.pauseInvisible.isHidden()) {
  119. (slider.vars.initDelay > 0) ? slider.startTimeout = setTimeout(slider.play, slider.vars.initDelay) : slider.play();
  120. }
  121. }
  122. // ASNAV:
  123. if (asNav) methods.asNav.setup();
  124. // TOUCH
  125. if (touch && slider.vars.touch) methods.touch();
  126. // FADE&&SMOOTHHEIGHT || SLIDE:
  127. if (!fade || (fade && slider.vars.smoothHeight)) $(window).bind("resize orientationchange focus", methods.resize);
  128. slider.find("img").attr("draggable", "false");
  129. // API: start() Callback
  130. setTimeout(function(){
  131. slider.vars.start(slider);
  132. }, 200);
  133. },
  134. asNav: {
  135. setup: function() {
  136. slider.asNav = true;
  137. slider.animatingTo = Math.floor(slider.currentSlide/slider.move);
  138. slider.currentItem = slider.currentSlide;
  139. slider.slides.removeClass(namespace + "active-slide").eq(slider.currentItem).addClass(namespace + "active-slide");
  140. if(!msGesture){
  141. slider.slides.click(function(e){
  142. e.preventDefault();
  143. var $slide = $(this),
  144. target = $slide.index();
  145. var posFromLeft = $slide.offset().left - $(slider).scrollLeft(); // Find position of slide relative to left of slider container
  146. if( posFromLeft <= 0 && $slide.hasClass( namespace + 'active-slide' ) ) {
  147. slider.flexAnimate(slider.getTarget("prev"), true);
  148. } else if (!$(slider.vars.asNavFor).data('flexslider').animating && !$slide.hasClass(namespace + "active-slide")) {
  149. slider.direction = (slider.currentItem < target) ? "next" : "prev";
  150. slider.flexAnimate(target, slider.vars.pauseOnAction, false, true, true);
  151. }
  152. });
  153. }else{
  154. el._slider = slider;
  155. slider.slides.each(function (){
  156. var that = this;
  157. that._gesture = new MSGesture();
  158. that._gesture.target = that;
  159. that.addEventListener("MSPointerDown", function (e){
  160. e.preventDefault();
  161. if(e.currentTarget._gesture)
  162. e.currentTarget._gesture.addPointer(e.pointerId);
  163. }, false);
  164. that.addEventListener("MSGestureTap", function (e){
  165. e.preventDefault();
  166. var $slide = $(this),
  167. target = $slide.index();
  168. if (!$(slider.vars.asNavFor).data('flexslider').animating && !$slide.hasClass('active')) {
  169. slider.direction = (slider.currentItem < target) ? "next" : "prev";
  170. slider.flexAnimate(target, slider.vars.pauseOnAction, false, true, true);
  171. }
  172. });
  173. });
  174. }
  175. }
  176. },
  177. controlNav: {
  178. setup: function() {
  179. if (!slider.manualControls) {
  180. methods.controlNav.setupPaging();
  181. } else { // MANUALCONTROLS:
  182. methods.controlNav.setupManual();
  183. }
  184. },
  185. setupPaging: function() {
  186. var type = (slider.vars.controlNav === "thumbnails") ? 'control-thumbs' : 'control-paging',
  187. j = 1,
  188. item,
  189. slide;
  190. slider.controlNavScaffold = $('<ol class="'+ namespace + 'control-nav ' + namespace + type + '"></ol>');
  191. if (slider.pagingCount > 1) {
  192. for (var i = 0; i < slider.pagingCount; i++) {
  193. slide = slider.slides.eq(i);
  194. item = (slider.vars.controlNav === "thumbnails") ? '<img src="' + slide.attr( 'data-thumb' ) + '"/>' : '<a>' + j + '</a>';
  195. if ( 'thumbnails' === slider.vars.controlNav && true === slider.vars.thumbCaptions ) {
  196. var captn = slide.attr( 'data-thumbcaption' );
  197. if ( '' != captn && undefined != captn ) item += '<span class="' + namespace + 'caption">' + captn + '</span>';
  198. }
  199. slider.controlNavScaffold.append('<li>' + item + '</li>');
  200. j++;
  201. }
  202. }
  203. // CONTROLSCONTAINER:
  204. (slider.controlsContainer) ? $(slider.controlsContainer).append(slider.controlNavScaffold) : slider.append(slider.controlNavScaffold);
  205. methods.controlNav.set();
  206. methods.controlNav.active();
  207. slider.controlNavScaffold.delegate('a, img', eventType, function(event) {
  208. event.preventDefault();
  209. if (watchedEvent === "" || watchedEvent === event.type) {
  210. var $this = $(this),
  211. target = slider.controlNav.index($this);
  212. if (!$this.hasClass(namespace + 'active')) {
  213. slider.direction = (target > slider.currentSlide) ? "next" : "prev";
  214. slider.flexAnimate(target, slider.vars.pauseOnAction);
  215. }
  216. }
  217. // setup flags to prevent event duplication
  218. if (watchedEvent === "") {
  219. watchedEvent = event.type;
  220. }
  221. methods.setToClearWatchedEvent();
  222. });
  223. },
  224. setupManual: function() {
  225. slider.controlNav = slider.manualControls;
  226. methods.controlNav.active();
  227. slider.controlNav.bind(eventType, function(event) {
  228. event.preventDefault();
  229. if (watchedEvent === "" || watchedEvent === event.type) {
  230. var $this = $(this),
  231. target = slider.controlNav.index($this);
  232. if (!$this.hasClass(namespace + 'active')) {
  233. (target > slider.currentSlide) ? slider.direction = "next" : slider.direction = "prev";
  234. slider.flexAnimate(target, slider.vars.pauseOnAction);
  235. }
  236. }
  237. // setup flags to prevent event duplication
  238. if (watchedEvent === "") {
  239. watchedEvent = event.type;
  240. }
  241. methods.setToClearWatchedEvent();
  242. });
  243. },
  244. set: function() {
  245. var selector = (slider.vars.controlNav === "thumbnails") ? 'img' : 'a';
  246. slider.controlNav = $('.' + namespace + 'control-nav li ' + selector, (slider.controlsContainer) ? slider.controlsContainer : slider);
  247. },
  248. active: function() {
  249. slider.controlNav.removeClass(namespace + "active").eq(slider.animatingTo).addClass(namespace + "active");
  250. },
  251. update: function(action, pos) {
  252. if (slider.pagingCount > 1 && action === "add") {
  253. slider.controlNavScaffold.append($('<li><a>' + slider.count + '</a></li>'));
  254. } else if (slider.pagingCount === 1) {
  255. slider.controlNavScaffold.find('li').remove();
  256. } else {
  257. slider.controlNav.eq(pos).closest('li').remove();
  258. }
  259. methods.controlNav.set();
  260. (slider.pagingCount > 1 && slider.pagingCount !== slider.controlNav.length) ? slider.update(pos, action) : methods.controlNav.active();
  261. }
  262. },
  263. directionNav: {
  264. setup: function() {
  265. var directionNavScaffold = $('<ul class="' + namespace + 'direction-nav"><li><a class="' + namespace + 'prev" href="#">' + slider.vars.prevText + '</a></li><li><a class="' + namespace + 'next" href="#">' + slider.vars.nextText + '</a></li></ul>');
  266. // CONTROLSCONTAINER:
  267. if (slider.controlsContainer) {
  268. $(slider.controlsContainer).append(directionNavScaffold);
  269. slider.directionNav = $('.' + namespace + 'direction-nav li a', slider.controlsContainer);
  270. } else {
  271. slider.append(directionNavScaffold);
  272. slider.directionNav = $('.' + namespace + 'direction-nav li a', slider);
  273. }
  274. methods.directionNav.update();
  275. slider.directionNav.bind(eventType, function(event) {
  276. event.preventDefault();
  277. var target;
  278. if (watchedEvent === "" || watchedEvent === event.type) {
  279. target = ($(this).hasClass(namespace + 'next')) ? slider.getTarget('next') : slider.getTarget('prev');
  280. slider.flexAnimate(target, slider.vars.pauseOnAction);
  281. }
  282. // setup flags to prevent event duplication
  283. if (watchedEvent === "") {
  284. watchedEvent = event.type;
  285. }
  286. methods.setToClearWatchedEvent();
  287. });
  288. },
  289. update: function() {
  290. var disabledClass = namespace + 'disabled';
  291. if (slider.pagingCount === 1) {
  292. slider.directionNav.addClass(disabledClass).attr('tabindex', '-1');
  293. } else if (!slider.vars.animationLoop) {
  294. if (slider.animatingTo === 0) {
  295. slider.directionNav.removeClass(disabledClass).filter('.' + namespace + "prev").addClass(disabledClass).attr('tabindex', '-1');
  296. } else if (slider.animatingTo === slider.last) {
  297. slider.directionNav.removeClass(disabledClass).filter('.' + namespace + "next").addClass(disabledClass).attr('tabindex', '-1');
  298. } else {
  299. slider.directionNav.removeClass(disabledClass).removeAttr('tabindex');
  300. }
  301. } else {
  302. slider.directionNav.removeClass(disabledClass).removeAttr('tabindex');
  303. }
  304. }
  305. },
  306. pausePlay: {
  307. setup: function() {
  308. var pausePlayScaffold = $('<div class="' + namespace + 'pauseplay"><a></a></div>');
  309. // CONTROLSCONTAINER:
  310. if (slider.controlsContainer) {
  311. slider.controlsContainer.append(pausePlayScaffold);
  312. slider.pausePlay = $('.' + namespace + 'pauseplay a', slider.controlsContainer);
  313. } else {
  314. slider.append(pausePlayScaffold);
  315. slider.pausePlay = $('.' + namespace + 'pauseplay a', slider);
  316. }
  317. methods.pausePlay.update((slider.vars.slideshow) ? namespace + 'pause' : namespace + 'play');
  318. slider.pausePlay.bind(eventType, function(event) {
  319. event.preventDefault();
  320. if (watchedEvent === "" || watchedEvent === event.type) {
  321. if ($(this).hasClass(namespace + 'pause')) {
  322. slider.manualPause = true;
  323. slider.manualPlay = false;
  324. slider.pause();
  325. } else {
  326. slider.manualPause = false;
  327. slider.manualPlay = true;
  328. slider.play();
  329. }
  330. }
  331. // setup flags to prevent event duplication
  332. if (watchedEvent === "") {
  333. watchedEvent = event.type;
  334. }
  335. methods.setToClearWatchedEvent();
  336. });
  337. },
  338. update: function(state) {
  339. (state === "play") ? slider.pausePlay.removeClass(namespace + 'pause').addClass(namespace + 'play').html(slider.vars.playText) : slider.pausePlay.removeClass(namespace + 'play').addClass(namespace + 'pause').html(slider.vars.pauseText);
  340. }
  341. },
  342. touch: function() {
  343. var startX,
  344. startY,
  345. offset,
  346. cwidth,
  347. dx,
  348. startT,
  349. scrolling = false,
  350. localX = 0,
  351. localY = 0,
  352. accDx = 0;
  353. if(!msGesture){
  354. el.addEventListener('touchstart', onTouchStart, false);
  355. function onTouchStart(e) {
  356. if (slider.animating) {
  357. e.preventDefault();
  358. } else if ( ( window.navigator.msPointerEnabled ) || e.touches.length === 1 ) {
  359. slider.pause();
  360. // CAROUSEL:
  361. cwidth = (vertical) ? slider.h : slider. w;
  362. startT = Number(new Date());
  363. // CAROUSEL:
  364. // Local vars for X and Y points.
  365. localX = e.touches[0].pageX;
  366. localY = e.touches[0].pageY;
  367. offset = (carousel && reverse && slider.animatingTo === slider.last) ? 0 :
  368. (carousel && reverse) ? slider.limit - (((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.animatingTo) :
  369. (carousel && slider.currentSlide === slider.last) ? slider.limit :
  370. (carousel) ? ((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.currentSlide :
  371. (reverse) ? (slider.last - slider.currentSlide + slider.cloneOffset) * cwidth : (slider.currentSlide + slider.cloneOffset) * cwidth;
  372. startX = (vertical) ? localY : localX;
  373. startY = (vertical) ? localX : localY;
  374. el.addEventListener('touchmove', onTouchMove, false);
  375. el.addEventListener('touchend', onTouchEnd, false);
  376. }
  377. }
  378. function onTouchMove(e) {
  379. // Local vars for X and Y points.
  380. localX = e.touches[0].pageX;
  381. localY = e.touches[0].pageY;
  382. dx = (vertical) ? startX - localY : startX - localX;
  383. scrolling = (vertical) ? (Math.abs(dx) < Math.abs(localX - startY)) : (Math.abs(dx) < Math.abs(localY - startY));
  384. var fxms = 500;
  385. if ( ! scrolling || Number( new Date() ) - startT > fxms ) {
  386. e.preventDefault();
  387. if (!fade && slider.transitions) {
  388. if (!slider.vars.animationLoop) {
  389. dx = dx/((slider.currentSlide === 0 && dx < 0 || slider.currentSlide === slider.last && dx > 0) ? (Math.abs(dx)/cwidth+2) : 1);
  390. }
  391. slider.setProps(offset + dx, "setTouch");
  392. }
  393. }
  394. }
  395. function onTouchEnd(e) {
  396. // finish the touch by undoing the touch session
  397. el.removeEventListener('touchmove', onTouchMove, false);
  398. if (slider.animatingTo === slider.currentSlide && !scrolling && !(dx === null)) {
  399. var updateDx = (reverse) ? -dx : dx,
  400. target = (updateDx > 0) ? slider.getTarget('next') : slider.getTarget('prev');
  401. if (slider.canAdvance(target) && (Number(new Date()) - startT < 550 && Math.abs(updateDx) > 50 || Math.abs(updateDx) > cwidth/2)) {
  402. slider.flexAnimate(target, slider.vars.pauseOnAction);
  403. } else {
  404. if (!fade) slider.flexAnimate(slider.currentSlide, slider.vars.pauseOnAction, true);
  405. }
  406. }
  407. el.removeEventListener('touchend', onTouchEnd, false);
  408. startX = null;
  409. startY = null;
  410. dx = null;
  411. offset = null;
  412. }
  413. }else{
  414. el.style.msTouchAction = "none";
  415. el._gesture = new MSGesture();
  416. el._gesture.target = el;
  417. el.addEventListener("MSPointerDown", onMSPointerDown, false);
  418. el._slider = slider;
  419. el.addEventListener("MSGestureChange", onMSGestureChange, false);
  420. el.addEventListener("MSGestureEnd", onMSGestureEnd, false);
  421. function onMSPointerDown(e){
  422. e.stopPropagation();
  423. if (slider.animating) {
  424. e.preventDefault();
  425. }else{
  426. slider.pause();
  427. el._gesture.addPointer(e.pointerId);
  428. accDx = 0;
  429. cwidth = (vertical) ? slider.h : slider. w;
  430. startT = Number(new Date());
  431. // CAROUSEL:
  432. offset = (carousel && reverse && slider.animatingTo === slider.last) ? 0 :
  433. (carousel && reverse) ? slider.limit - (((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.animatingTo) :
  434. (carousel && slider.currentSlide === slider.last) ? slider.limit :
  435. (carousel) ? ((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.currentSlide :
  436. (reverse) ? (slider.last - slider.currentSlide + slider.cloneOffset) * cwidth : (slider.currentSlide + slider.cloneOffset) * cwidth;
  437. }
  438. }
  439. function onMSGestureChange(e) {
  440. e.stopPropagation();
  441. var slider = e.target._slider;
  442. if(!slider){
  443. return;
  444. }
  445. var transX = -e.translationX,
  446. transY = -e.translationY;
  447. //Accumulate translations.
  448. accDx = accDx + ((vertical) ? transY : transX);
  449. dx = accDx;
  450. scrolling = (vertical) ? (Math.abs(accDx) < Math.abs(-transX)) : (Math.abs(accDx) < Math.abs(-transY));
  451. if(e.detail === e.MSGESTURE_FLAG_INERTIA){
  452. setImmediate(function (){
  453. el._gesture.stop();
  454. });
  455. return;
  456. }
  457. if (!scrolling || Number(new Date()) - startT > 500) {
  458. e.preventDefault();
  459. if (!fade && slider.transitions) {
  460. if (!slider.vars.animationLoop) {
  461. dx = accDx / ((slider.currentSlide === 0 && accDx < 0 || slider.currentSlide === slider.last && accDx > 0) ? (Math.abs(accDx) / cwidth + 2) : 1);
  462. }
  463. slider.setProps(offset + dx, "setTouch");
  464. }
  465. }
  466. }
  467. function onMSGestureEnd(e) {
  468. e.stopPropagation();
  469. var slider = e.target._slider;
  470. if(!slider){
  471. return;
  472. }
  473. if (slider.animatingTo === slider.currentSlide && !scrolling && !(dx === null)) {
  474. var updateDx = (reverse) ? -dx : dx,
  475. target = (updateDx > 0) ? slider.getTarget('next') : slider.getTarget('prev');
  476. if (slider.canAdvance(target) && (Number(new Date()) - startT < 550 && Math.abs(updateDx) > 50 || Math.abs(updateDx) > cwidth/2)) {
  477. slider.flexAnimate(target, slider.vars.pauseOnAction);
  478. } else {
  479. if (!fade) slider.flexAnimate(slider.currentSlide, slider.vars.pauseOnAction, true);
  480. }
  481. }
  482. startX = null;
  483. startY = null;
  484. dx = null;
  485. offset = null;
  486. accDx = 0;
  487. }
  488. }
  489. },
  490. resize: function() {
  491. if (!slider.animating && slider.is(':visible')) {
  492. if (!carousel) slider.doMath();
  493. if (fade) {
  494. // SMOOTH HEIGHT:
  495. methods.smoothHeight();
  496. } else if (carousel) { //CAROUSEL:
  497. slider.slides.width(slider.computedW);
  498. slider.update(slider.pagingCount);
  499. slider.setProps();
  500. }
  501. else if (vertical) { //VERTICAL:
  502. slider.viewport.height(slider.h);
  503. slider.setProps(slider.h, "setTotal");
  504. } else {
  505. // SMOOTH HEIGHT:
  506. if (slider.vars.smoothHeight) methods.smoothHeight();
  507. slider.newSlides.width(slider.computedW);
  508. slider.setProps(slider.computedW, "setTotal");
  509. }
  510. }
  511. },
  512. smoothHeight: function(dur) {
  513. if (!vertical || fade) {
  514. var $obj = (fade) ? slider : slider.viewport;
  515. (dur) ? $obj.animate({"height": slider.slides.eq(slider.animatingTo).height()}, dur) : $obj.height(slider.slides.eq(slider.animatingTo).height());
  516. }
  517. },
  518. sync: function(action) {
  519. var $obj = $(slider.vars.sync).data("flexslider"),
  520. target = slider.animatingTo;
  521. switch (action) {
  522. case "animate": $obj.flexAnimate(target, slider.vars.pauseOnAction, false, true); break;
  523. case "play": if (!$obj.playing && !$obj.asNav) { $obj.play(); } break;
  524. case "pause": $obj.pause(); break;
  525. }
  526. },
  527. pauseInvisible: {
  528. visProp: null,
  529. init: function() {
  530. var prefixes = ['webkit','moz','ms','o'];
  531. if ('hidden' in document) return 'hidden';
  532. for (var i = 0; i < prefixes.length; i++) {
  533. if ((prefixes[i] + 'Hidden') in document)
  534. methods.pauseInvisible.visProp = prefixes[i] + 'Hidden';
  535. }
  536. if (methods.pauseInvisible.visProp) {
  537. var evtname = methods.pauseInvisible.visProp.replace(/[H|h]idden/,'') + 'visibilitychange';
  538. document.addEventListener(evtname, function() {
  539. if (methods.pauseInvisible.isHidden()) {
  540. if(slider.startTimeout) clearTimeout(slider.startTimeout); //If clock is ticking, stop timer and prevent from starting while invisible
  541. else slider.pause(); //Or just pause
  542. }
  543. else {
  544. if(slider.started) slider.play(); //Initiated before, just play
  545. else (slider.vars.initDelay > 0) ? setTimeout(slider.play, slider.vars.initDelay) : slider.play(); //Didn't init before: simply init or wait for it
  546. }
  547. });
  548. }
  549. },
  550. isHidden: function() {
  551. return document[methods.pauseInvisible.visProp] || false;
  552. }
  553. },
  554. setToClearWatchedEvent: function() {
  555. clearTimeout(watchedEventClearTimer);
  556. watchedEventClearTimer = setTimeout(function() {
  557. watchedEvent = "";
  558. }, 3000);
  559. }
  560. }
  561. // public methods
  562. slider.flexAnimate = function(target, pause, override, withSync, fromNav) {
  563. if (!slider.vars.animationLoop && target !== slider.currentSlide) {
  564. slider.direction = (target > slider.currentSlide) ? "next" : "prev";
  565. }
  566. if (asNav && slider.pagingCount === 1) slider.direction = (slider.currentItem < target) ? "next" : "prev";
  567. if (!slider.animating && (slider.canAdvance(target, fromNav) || override) && slider.is(":visible")) {
  568. if (asNav && withSync) {
  569. var master = $(slider.vars.asNavFor).data('flexslider');
  570. slider.atEnd = target === 0 || target === slider.count - 1;
  571. master.flexAnimate(target, true, false, true, fromNav);
  572. slider.direction = (slider.currentItem < target) ? "next" : "prev";
  573. master.direction = slider.direction;
  574. if (Math.ceil((target + 1)/slider.visible) - 1 !== slider.currentSlide && target !== 0) {
  575. slider.currentItem = target;
  576. slider.slides.removeClass(namespace + "active-slide").eq(target).addClass(namespace + "active-slide");
  577. target = Math.floor(target/slider.visible);
  578. } else {
  579. slider.currentItem = target;
  580. slider.slides.removeClass(namespace + "active-slide").eq(target).addClass(namespace + "active-slide");
  581. return false;
  582. }
  583. }
  584. slider.animating = true;
  585. slider.animatingTo = target;
  586. // SLIDESHOW:
  587. if (pause) slider.pause();
  588. // API: before() animation Callback
  589. slider.vars.before(slider);
  590. // SYNC:
  591. if (slider.syncExists && !fromNav) methods.sync("animate");
  592. // CONTROLNAV
  593. if (slider.vars.controlNav) methods.controlNav.active();
  594. // !CAROUSEL:
  595. // CANDIDATE: slide active class (for add/remove slide)
  596. if (!carousel) slider.slides.removeClass(namespace + 'active-slide').eq(target).addClass(namespace + 'active-slide');
  597. // INFINITE LOOP:
  598. // CANDIDATE: atEnd
  599. slider.atEnd = target === 0 || target === slider.last;
  600. // DIRECTIONNAV:
  601. if (slider.vars.directionNav) methods.directionNav.update();
  602. if (target === slider.last) {
  603. // API: end() of cycle Callback
  604. slider.vars.end(slider);
  605. // SLIDESHOW && !INFINITE LOOP:
  606. if (!slider.vars.animationLoop) slider.pause();
  607. }
  608. // SLIDE:
  609. if (!fade) {
  610. var dimension = (vertical) ? slider.slides.filter(':first').height() : slider.computedW,
  611. margin, slideString, calcNext;
  612. // INFINITE LOOP / REVERSE:
  613. if (carousel) {
  614. //margin = (slider.vars.itemWidth > slider.w) ? slider.vars.itemMargin * 2 : slider.vars.itemMargin;
  615. margin = slider.vars.itemMargin;
  616. calcNext = ((slider.itemW + margin) * slider.move) * slider.animatingTo;
  617. slideString = (calcNext > slider.limit && slider.visible !== 1) ? slider.limit : calcNext;
  618. } else if (slider.currentSlide === 0 && target === slider.count - 1 && slider.vars.animationLoop && slider.direction !== "next") {
  619. slideString = (reverse) ? (slider.count + slider.cloneOffset) * dimension : 0;
  620. } else if (slider.currentSlide === slider.last && target === 0 && slider.vars.animationLoop && slider.direction !== "prev") {
  621. slideString = (reverse) ? 0 : (slider.count + 1) * dimension;
  622. } else {
  623. slideString = (reverse) ? ((slider.count - 1) - target + slider.cloneOffset) * dimension : (target + slider.cloneOffset) * dimension;
  624. }
  625. slider.setProps(slideString, "", slider.vars.animationSpeed);
  626. if (slider.transitions) {
  627. if (!slider.vars.animationLoop || !slider.atEnd) {
  628. slider.animating = false;
  629. slider.currentSlide = slider.animatingTo;
  630. }
  631. slider.container.unbind("webkitTransitionEnd transitionend");
  632. slider.container.bind("webkitTransitionEnd transitionend", function() {
  633. slider.wrapup(dimension);
  634. });
  635. } else {
  636. slider.container.animate(slider.args, slider.vars.animationSpeed, slider.vars.easing, function(){
  637. slider.wrapup(dimension);
  638. });
  639. }
  640. } else { // FADE:
  641. if (!touch) {
  642. //slider.slides.eq(slider.currentSlide).fadeOut(slider.vars.animationSpeed, slider.vars.easing);
  643. //slider.slides.eq(target).fadeIn(slider.vars.animationSpeed, slider.vars.easing, slider.wrapup);
  644. slider.slides.eq(slider.currentSlide).css({"zIndex": 1}).animate({"opacity": 0}, slider.vars.animationSpeed, slider.vars.easing);
  645. slider.slides.eq(target).css({"zIndex": 2}).animate({"opacity": 1}, slider.vars.animationSpeed, slider.vars.easing, slider.wrapup);
  646. } else {
  647. slider.slides.eq(slider.currentSlide).css({ "opacity": 0, "zIndex": 1 });
  648. slider.slides.eq(target).css({ "opacity": 1, "zIndex": 2 });
  649. slider.wrapup(dimension);
  650. }
  651. }
  652. // SMOOTH HEIGHT:
  653. if (slider.vars.smoothHeight) methods.smoothHeight(slider.vars.animationSpeed);
  654. }
  655. }
  656. slider.wrapup = function(dimension) {
  657. // SLIDE:
  658. if (!fade && !carousel) {
  659. if (slider.currentSlide === 0 && slider.animatingTo === slider.last && slider.vars.animationLoop) {
  660. slider.setProps(dimension, "jumpEnd");
  661. } else if (slider.currentSlide === slider.last && slider.animatingTo === 0 && slider.vars.animationLoop) {
  662. slider.setProps(dimension, "jumpStart");
  663. }
  664. }
  665. slider.animating = false;
  666. slider.currentSlide = slider.animatingTo;
  667. // API: after() animation Callback
  668. slider.vars.after(slider);
  669. }
  670. // SLIDESHOW:
  671. slider.animateSlides = function() {
  672. if (!slider.animating && focused ) slider.flexAnimate(slider.getTarget("next"));
  673. }
  674. // SLIDESHOW:
  675. slider.pause = function() {
  676. clearInterval(slider.animatedSlides);
  677. slider.animatedSlides = null;
  678. slider.playing = false;
  679. // PAUSEPLAY:
  680. if (slider.vars.pausePlay) methods.pausePlay.update("play");
  681. // SYNC:
  682. if (slider.syncExists) methods.sync("pause");
  683. }
  684. // SLIDESHOW:
  685. slider.play = function() {
  686. if (slider.playing) clearInterval(slider.animatedSlides);
  687. slider.animatedSlides = slider.animatedSlides || setInterval(slider.animateSlides, slider.vars.slideshowSpeed);
  688. slider.started = slider.playing = true;
  689. // PAUSEPLAY:
  690. if (slider.vars.pausePlay) methods.pausePlay.update("pause");
  691. // SYNC:
  692. if (slider.syncExists) methods.sync("play");
  693. }
  694. // STOP:
  695. slider.stop = function () {
  696. slider.pause();
  697. slider.stopped = true;
  698. }
  699. slider.canAdvance = function(target, fromNav) {
  700. // ASNAV:
  701. var last = (asNav) ? slider.pagingCount - 1 : slider.last;
  702. return (fromNav) ? true :
  703. (asNav && slider.currentItem === slider.count - 1 && target === 0 && slider.direction === "prev") ? true :
  704. (asNav && slider.currentItem === 0 && target === slider.pagingCount - 1 && slider.direction !== "next") ? false :
  705. (target === slider.currentSlide && !asNav) ? false :
  706. (slider.vars.animationLoop) ? true :
  707. (slider.atEnd && slider.currentSlide === 0 && target === last && slider.direction !== "next") ? false :
  708. (slider.atEnd && slider.currentSlide === last && target === 0 && slider.direction === "next") ? false :
  709. true;
  710. }
  711. slider.getTarget = function(dir) {
  712. slider.direction = dir;
  713. if (dir === "next") {
  714. return (slider.currentSlide === slider.last) ? 0 : slider.currentSlide + 1;
  715. } else {
  716. return (slider.currentSlide === 0) ? slider.last : slider.currentSlide - 1;
  717. }
  718. }
  719. // SLIDE:
  720. slider.setProps = function(pos, special, dur) {
  721. var target = (function() {
  722. var posCheck = (pos) ? pos : ((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.animatingTo,
  723. posCalc = (function() {
  724. if (carousel) {
  725. return (special === "setTouch") ? pos :
  726. (reverse && slider.animatingTo === slider.last) ? 0 :
  727. (reverse) ? slider.limit - (((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.animatingTo) :
  728. (slider.animatingTo === slider.last) ? slider.limit : posCheck;
  729. } else {
  730. switch (special) {
  731. case "setTotal": return (reverse) ? ((slider.count - 1) - slider.currentSlide + slider.cloneOffset) * pos : (slider.currentSlide + slider.cloneOffset) * pos;
  732. case "setTouch": return (reverse) ? pos : pos;
  733. case "jumpEnd": return (reverse) ? pos : slider.count * pos;
  734. case "jumpStart": return (reverse) ? slider.count * pos : pos;
  735. default: return pos;
  736. }
  737. }
  738. }());
  739. return (posCalc * -1) + "px";
  740. }());
  741. if (slider.transitions) {
  742. target = (vertical) ? "translate3d(0," + target + ",0)" : "translate3d(" + target + ",0,0)";
  743. dur = (dur !== undefined) ? (dur/1000) + "s" : "0s";
  744. slider.container.css("-" + slider.pfx + "-transition-duration", dur);
  745. }
  746. slider.args[slider.prop] = target;
  747. if (slider.transitions || dur === undefined) slider.container.css(slider.args);
  748. }
  749. slider.setup = function(type) {
  750. // SLIDE:
  751. if (!fade) {
  752. var sliderOffset, arr;
  753. if (type === "init") {
  754. slider.viewport = $('<div class="' + namespace + 'viewport"></div>').css({"overflow": "hidden", "position": "relative"}).appendTo(slider).append(slider.container);
  755. // INFINITE LOOP:
  756. slider.cloneCount = 0;
  757. slider.cloneOffset = 0;
  758. // REVERSE:
  759. if (reverse) {
  760. arr = $.makeArray(slider.slides).reverse();
  761. slider.slides = $(arr);
  762. slider.container.empty().append(slider.slides);
  763. }
  764. }
  765. // INFINITE LOOP && !CAROUSEL:
  766. if (slider.vars.animationLoop && !carousel) {
  767. slider.cloneCount = 2;
  768. slider.cloneOffset = 1;
  769. // clear out old clones
  770. if (type !== "init") slider.container.find('.clone').remove();
  771. slider.container.append(slider.slides.first().clone().addClass('clone').attr('aria-hidden', 'true')).prepend(slider.slides.last().clone().addClass('clone').attr('aria-hidden', 'true'));
  772. }
  773. slider.newSlides = $(slider.vars.selector, slider);
  774. sliderOffset = (reverse) ? slider.count - 1 - slider.currentSlide + slider.cloneOffset : slider.currentSlide + slider.cloneOffset;
  775. // VERTICAL:
  776. if (vertical && !carousel) {
  777. slider.container.height((slider.count + slider.cloneCount) * 200 + "%").css("position", "absolute").width("100%");
  778. setTimeout(function(){
  779. slider.newSlides.css({"display": "block"});
  780. slider.doMath();
  781. slider.viewport.height(slider.h);
  782. slider.setProps(sliderOffset * slider.h, "init");
  783. }, (type === "init") ? 100 : 0);
  784. } else {
  785. slider.container.width((slider.count + slider.cloneCount) * 200 + "%");
  786. slider.setProps(sliderOffset * slider.computedW, "init");
  787. setTimeout(function(){
  788. slider.doMath();
  789. slider.newSlides.css({"width": slider.computedW, "float": "left", "display": "block"});
  790. // SMOOTH HEIGHT:
  791. if (slider.vars.smoothHeight) methods.smoothHeight();
  792. }, (type === "init") ? 100 : 0);
  793. }
  794. } else { // FADE:
  795. slider.slides.css({"width": "100%", "float": "left", "marginRight": "-100%", "position": "relative"});
  796. if (type === "init") {
  797. if (!touch) {
  798. //slider.slides.eq(slider.currentSlide).fadeIn(slider.vars.animationSpeed, slider.vars.easing);
  799. slider.slides.css({ "opacity": 0, "display": "block", "zIndex": 1 }).eq(slider.currentSlide).css({"zIndex": 2}).animate({"opacity": 1},slider.vars.animationSpeed,slider.vars.easing);
  800. } else {
  801. slider.slides.css({ "opacity": 0, "display": "block", "webkitTransition": "opacity " + slider.vars.animationSpeed / 1000 + "s ease", "zIndex": 1 }).eq(slider.currentSlide).css({ "opacity": 1, "zIndex": 2});
  802. }
  803. }
  804. // SMOOTH HEIGHT:
  805. if (slider.vars.smoothHeight) methods.smoothHeight();
  806. }
  807. // !CAROUSEL:
  808. // CANDIDATE: active slide
  809. if (!carousel) slider.slides.removeClass(namespace + "active-slide").eq(slider.currentSlide).addClass(namespace + "active-slide");
  810. }
  811. slider.doMath = function() {
  812. var slide = slider.slides.first(),
  813. slideMargin = slider.vars.itemMargin,
  814. minItems = slider.vars.minItems,
  815. maxItems = slider.vars.maxItems;
  816. slider.w = (slider.viewport===undefined) ? slider.width() : slider.viewport.width();
  817. slider.h = slide.height();
  818. slider.boxPadding = slide.outerWidth() - slide.width();
  819. // CAROUSEL:
  820. if (carousel) {
  821. slider.itemT = slider.vars.itemWidth + slideMargin;
  822. slider.minW = (minItems) ? minItems * slider.itemT : slider.w;
  823. slider.maxW = (maxItems) ? (maxItems * slider.itemT) - slideMargin : slider.w;
  824. slider.itemW = (slider.minW > slider.w) ? (slider.w - (slideMargin * (minItems - 1)))/minItems :
  825. (slider.maxW < slider.w) ? (slider.w - (slideMargin * (maxItems - 1)))/maxItems :
  826. (slider.vars.itemWidth > slider.w) ? slider.w : slider.vars.itemWidth;
  827. slider.visible = Math.floor(slider.w/(slider.itemW));
  828. slider.move = (slider.vars.move > 0 && slider.vars.move < slider.visible ) ? slider.vars.move : slider.visible;
  829. slider.pagingCount = Math.ceil(((slider.count - slider.visible)/slider.move) + 1);
  830. slider.last = slider.pagingCount - 1;
  831. slider.limit = (slider.pagingCount === 1) ? 0 :
  832. (slider.vars.itemWidth > slider.w) ? (slider.itemW * (slider.count - 1)) + (slideMargin * (slider.count - 1)) : ((slider.itemW + slideMargin) * slider.count) - slider.w - slideMargin;
  833. } else {
  834. slider.itemW = slider.w;
  835. slider.pagingCount = slider.count;
  836. slider.last = slider.count - 1;
  837. }
  838. slider.computedW = slider.itemW - slider.boxPadding;
  839. }
  840. slider.update = function(pos, action) {
  841. slider.doMath();
  842. // update currentSlide and slider.animatingTo if necessary
  843. if (!carousel) {
  844. if (pos < slider.currentSlide) {
  845. slider.currentSlide += 1;
  846. } else if (pos <= slider.currentSlide && pos !== 0) {
  847. slider.currentSlide -= 1;
  848. }
  849. slider.animatingTo = slider.currentSlide;
  850. }
  851. // update controlNav
  852. if (slider.vars.controlNav && !slider.manualControls) {
  853. if ((action === "add" && !carousel) || slider.pagingCount > slider.controlNav.length) {
  854. methods.controlNav.update("add");
  855. } else if ((action === "remove" && !carousel) || slider.pagingCount < slider.controlNav.length) {
  856. if (carousel && slider.currentSlide > slider.last) {
  857. slider.currentSlide -= 1;
  858. slider.animatingTo -= 1;
  859. }
  860. methods.controlNav.update("remove", slider.last);
  861. }
  862. }
  863. // update directionNav
  864. if (slider.vars.directionNav) methods.directionNav.update();
  865. }
  866. slider.addSlide = function(obj, pos) {
  867. var $obj = $(obj);
  868. slider.count += 1;
  869. slider.last = slider.count - 1;
  870. // append new slide
  871. if (vertical && reverse) {
  872. (pos !== undefined) ? slider.slides.eq(slider.count - pos).after($obj) : slider.container.prepend($obj);
  873. } else {
  874. (pos !== undefined) ? slider.slides.eq(pos).before($obj) : slider.container.append($obj);
  875. }
  876. // update currentSlide, animatingTo, controlNav, and directionNav
  877. slider.update(pos, "add");
  878. // update slider.slides
  879. slider.slides = $(slider.vars.selector + ':not(.clone)', slider);
  880. // re-setup the slider to accomdate new slide
  881. slider.setup();
  882. //FlexSlider: added() Callback
  883. slider.vars.added(slider);
  884. }
  885. slider.removeSlide = function(obj) {
  886. var pos = (isNaN(obj)) ? slider.slides.index($(obj)) : obj;
  887. // update count
  888. slider.count -= 1;
  889. slider.last = slider.count - 1;
  890. // remove slide
  891. if (isNaN(obj)) {
  892. $(obj, slider.slides).remove();
  893. } else {
  894. (vertical && reverse) ? slider.slides.eq(slider.last).remove() : slider.slides.eq(obj).remove();
  895. }
  896. // update currentSlide, animatingTo, controlNav, and directionNav
  897. slider.doMath();
  898. slider.update(pos, "remove");
  899. // update slider.slides
  900. slider.slides = $(slider.vars.selector + ':not(.clone)', slider);
  901. // re-setup the slider to accomdate new slide
  902. slider.setup();
  903. // FlexSlider: removed() Callback
  904. slider.vars.removed(slider);
  905. }
  906. //FlexSlider: Initialize
  907. methods.init();
  908. }
  909. // Ensure the slider isn't focussed if the window loses focus.
  910. $( window ).blur( function ( e ) {
  911. focused = false;
  912. }).focus( function ( e ) {
  913. focused = true;
  914. });
  915. //FlexSlider: Default Settings
  916. $.flexslider.defaults = {
  917. namespace: "flex-", //{NEW} String: Prefix string attached to the class of every element generated by the plugin
  918. selector: ".slides > li", //{NEW} Selector: Must match a simple pattern. '{container} > {slide}' -- Ignore pattern at your own peril
  919. animation: "fade", //String: Select your animation type, "fade" or "slide"
  920. easing: "swing", //{NEW} String: Determines the easing method used in jQuery transitions. jQuery easing plugin is supported!
  921. direction: "horizontal", //String: Select the sliding direction, "horizontal" or "vertical"
  922. reverse: false, //{NEW} Boolean: Reverse the animation direction
  923. animationLoop: true, //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end
  924. smoothHeight: false, //{NEW} Boolean: Allow height of the slider to animate smoothly in horizontal mode
  925. startAt: 0, //Integer: The slide that the slider should start on. Array notation (0 = first slide)
  926. slideshow: true, //Boolean: Animate slider automatically
  927. slideshowSpeed: 7000, //Integer: Set the speed of the slideshow cycling, in milliseconds
  928. animationSpeed: 600, //Integer: Set the speed of animations, in milliseconds
  929. initDelay: 0, //{NEW} Integer: Set an initialization delay, in milliseconds
  930. randomize: false, //Boolean: Randomize slide order
  931. thumbCaptions: false, //Boolean: Whether or not to put captions on thumbnails when using the "thumbnails" controlNav.
  932. // Usability features
  933. pauseOnAction: true, //Boolean: Pause the slideshow when interacting with control elements, highly recommended.
  934. pauseOnHover: false, //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering
  935. pauseInvisible: true, //{NEW} Boolean: Pause the slideshow when tab is invisible, resume when visible. Provides better UX, lower CPU usage.
  936. useCSS: true, //{NEW} Boolean: Slider will use CSS3 transitions if available
  937. touch: true, //{NEW} Boolean: Allow touch swipe navigation of the slider on touch-enabled devices
  938. video: false, //{NEW} Boolean: If using video in the slider, will prevent CSS3 3D Transforms to avoid graphical glitches
  939. // Primary Controls
  940. controlNav: true, //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage
  941. directionNav: true, //Boolean: Create navigation for previous/next navigation? (true/false)
  942. prevText: "Previous", //String: Set the text for the "previous" directionNav item
  943. nextText: "Next", //String: Set the text for the "next" directionNav item
  944. // Secondary Navigation
  945. keyboard: true, //Boolean: Allow slider navigating via keyboard left/right keys
  946. multipleKeyboard: false, //{NEW} Boolean: Allow keyboard navigation to affect multiple sliders. Default behavior cuts out keyboard navigation with more than one slider present.
  947. mousewheel: false, //{UPDATED} Boolean: Requires jquery.mousewheel.js (https://github.com/brandonaaron/jquery-mousewheel) - Allows slider navigating via mousewheel
  948. pausePlay: false, //Boolean: Create pause/play dynamic element
  949. pauseText: "Pause", //String: Set the text for the "pause" pausePlay item
  950. playText: "Play", //String: Set the text for the "play" pausePlay item
  951. // Special properties
  952. controlsContainer: "", //{UPDATED} jQuery Object/Selector: Declare which container the navigation elements should be appended too. Default container is the FlexSlider element. Example use would be $(".flexslider-container"). Property is ignored if given element is not found.
  953. manualControls: "", //{UPDATED} jQuery Object/Selector: Declare custom control navigation. Examples would be $(".flex-control-nav li") or "#tabs-nav li img", etc. The number of elements in your controlNav should match the number of slides/tabs.
  954. sync: "", //{NEW} Selector: Mirror the actions performed on this slider with another slider. Use with care.
  955. asNavFor: "", //{NEW} Selector: Internal property exposed for turning the slider into a thumbnail navigation for another slider
  956. // Carousel Options
  957. itemWidth: 0, //{NEW} Integer: Box-model width of individual carousel items, including horizontal borders and padding.
  958. itemMargin: 0, //{NEW} Integer: Margin between carousel items.
  959. minItems: 1, //{NEW} Integer: Minimum number of carousel items that should be visible. Items will resize fluidly when below this.
  960. maxItems: 0, //{NEW} Integer: Maxmimum number of carousel items that should be visible. Items will resize fluidly when above this limit.
  961. move: 0, //{NEW} Integer: Number of carousel items that should move on animation. If 0, slider will move all visible items.
  962. allowOneSlide: true, //{NEW} Boolean: Whether or not to allow a slider comprised of a single slide
  963. // Callback API
  964. start: function(){}, //Callback: function(slider) - Fires when the slider loads the first slide
  965. before: function(){}, //Callback: function(slider) - Fires asynchronously with each slider animation
  966. after: function(){}, //Callback: function(slider) - Fires after each slider animation completes
  967. end: function(){}, //Callback: function(slider) - Fires when the slider reaches the last slide (asynchronous)
  968. added: function(){}, //{NEW} Callback: function(slider) - Fires after a slide is added
  969. removed: function(){} //{NEW} Callback: function(slider) - Fires after a slide is removed
  970. }
  971. //FlexSlider: Plugin Function
  972. $.fn.flexslider = function(options) {
  973. if (options === undefined) options = {};
  974. if (typeof options === "object") {
  975. return this.each(function() {
  976. var $this = $(this),
  977. selector = (options.selector) ? options.selector : ".slides > li",
  978. $slides = $this.find(selector);
  979. if ( ( $slides.length === 1 && options.allowOneSlide === true ) || $slides.length === 0 ) {
  980. $slides.fadeIn(400);
  981. if (options.start) options.start($this);
  982. } else if ($this.data('flexslider') === undefined) {
  983. new $.flexslider(this, options);
  984. }
  985. });
  986. } else {
  987. // Helper strings to quickly perform functions on the slider
  988. var $slider = $(this).data('flexslider');
  989. switch (options) {
  990. case "play": $slider.play(); break;
  991. case "pause": $slider.pause(); break;
  992. case "stop": $slider.stop(); break;
  993. case "next": $slider.flexAnimate($slider.getTarget("next"), true); break;
  994. case "prev":
  995. case "previous": $slider.flexAnimate($slider.getTarget("prev"), true); break;
  996. default: if (typeof options === "number") $slider.flexAnimate(options, true);
  997. }
  998. }
  999. }
  1000. })(jQuery);