Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Adds AMD support #547

Merged
merged 1 commit into from

2 participants

Chris Canal Matty Cohen
Chris Canal

No description provided.

Matty Cohen mattyza merged commit 775953d into from
Matty Cohen
Owner

Thanks @carcer! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 12, 2013
  1. Adds AMD support

    Chris Canal authored
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 36 deletions.
  1. +1 −34 jquery.flexslider-min.js
  2. +11 −2 jquery.flexslider.js
35 jquery.flexslider-min.js
View
@@ -3,37 +3,4 @@
* Copyright 2012 WooThemes
* Contributing Author: Tyler Smith
*/
- ;(function(c){c.flexslider=function(j,l){var a=c(j);a.vars=c.extend({},c.flexslider.defaults,l);var d=a.vars.namespace,s=("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)&&a.vars.touch,g="",t,n="vertical"===a.vars.direction,p=a.vars.reverse,k=0<a.vars.itemWidth,q="fade"===a.vars.animation,r=""!==a.vars.asNavFor,f={};c.data(j,"flexslider",a);f={init:function(){a.animating=!1;a.currentSlide=a.vars.startAt;a.animatingTo=a.currentSlide;a.atEnd=0===a.currentSlide||a.currentSlide===
-a.last;a.containerSelector=a.vars.selector.substr(0,a.vars.selector.search(" "));a.slides=c(a.vars.selector,a);a.container=c(a.containerSelector,a);a.count=a.slides.length;a.syncExists=0<c(a.vars.sync).length;"slide"===a.vars.animation&&(a.vars.animation="swing");a.prop=n?"top":"marginLeft";a.args={};a.manualPause=!1;var b=a,e;if(e=!a.vars.video)if(e=!q)if(e=a.vars.useCSS)a:{e=document.createElement("div");var h=["perspectiveProperty","WebkitPerspective","MozPerspective","OPerspective","msPerspective"],
-d;for(d in h)if(void 0!==e.style[h[d]]){a.pfx=h[d].replace("Perspective","").toLowerCase();a.prop="-"+a.pfx+"-transform";e=!0;break a}e=!1}b.transitions=e;""!==a.vars.controlsContainer&&(a.controlsContainer=0<c(a.vars.controlsContainer).length&&c(a.vars.controlsContainer));""!==a.vars.manualControls&&(a.manualControls=0<c(a.vars.manualControls).length&&c(a.vars.manualControls));a.vars.randomize&&(a.slides.sort(function(){return Math.round(Math.random())-0.5}),a.container.empty().append(a.slides));
-a.doMath();r&&f.asNav.setup();a.setup("init");a.vars.controlNav&&f.controlNav.setup();a.vars.directionNav&&f.directionNav.setup();a.vars.keyboard&&(1===c(a.containerSelector).length||a.vars.multipleKeyboard)&&c(document).bind("keyup",function(b){b=b.keyCode;if(!a.animating&&(39===b||37===b))b=39===b?a.getTarget("next"):37===b?a.getTarget("prev"):!1,a.flexAnimate(b,a.vars.pauseOnAction)});a.vars.mousewheel&&a.bind("mousewheel",function(b,e){b.preventDefault();var c=0>e?a.getTarget("next"):a.getTarget("prev");
-a.flexAnimate(c,a.vars.pauseOnAction)});a.vars.pausePlay&&f.pausePlay.setup();a.vars.slideshow&&(a.vars.pauseOnHover&&a.hover(function(){!a.manualPlay&&!a.manualPause&&a.pause()},function(){!a.manualPause&&!a.manualPlay&&a.play()}),0<a.vars.initDelay?setTimeout(a.play,a.vars.initDelay):a.play());s&&a.vars.touch&&f.touch();(!q||q&&a.vars.smoothHeight)&&c(window).bind("resize focus",f.resize);setTimeout(function(){a.vars.start(a)},200)},asNav:{setup:function(){a.asNav=!0;a.animatingTo=Math.floor(a.currentSlide/
-a.move);a.currentItem=a.currentSlide;a.slides.removeClass(d+"active-slide").eq(a.currentItem).addClass(d+"active-slide");a.slides.click(function(b){b.preventDefault();b=c(this);var e=b.index();!c(a.vars.asNavFor).data("flexslider").animating&&!b.hasClass("active")&&(a.direction=a.currentItem<e?"next":"prev",a.flexAnimate(e,a.vars.pauseOnAction,!1,!0,!0))})}},controlNav:{setup:function(){a.manualControls?f.controlNav.setupManual():f.controlNav.setupPaging()},setupPaging:function(){var b=1,e;a.controlNavScaffold=
-c('<ol class="'+d+"control-nav "+d+("thumbnails"===a.vars.controlNav?"control-thumbs":"control-paging")+'"></ol>');if(1<a.pagingCount)for(var h=0;h<a.pagingCount;h++)e="thumbnails"===a.vars.controlNav?'<img src="'+a.slides.eq(h).attr("data-thumb")+'"/>':"<a>"+b+"</a>",a.controlNavScaffold.append("<li>"+e+"</li>"),b++;a.controlsContainer?c(a.controlsContainer).append(a.controlNavScaffold):a.append(a.controlNavScaffold);f.controlNav.set();f.controlNav.active();a.controlNavScaffold.delegate("a, img",
-"click touchend",function(b){b.preventDefault();if(""===g||g===b.type){var e=c(this),h=a.controlNav.index(e);e.hasClass(d+"active")||(a.direction=h>a.currentSlide?"next":"prev",a.flexAnimate(h,a.vars.pauseOnAction))}""===g&&(g=b.type);f.setToClearWatchedEvent()})},setupManual:function(){a.controlNav=a.manualControls;f.controlNav.active();a.controlNav.bind("click touchend",function(b){b.preventDefault();if(""===g||g===b.type){var e=c(this),h=a.controlNav.index(e);e.hasClass(d+"active")||(h>a.currentSlide?
-a.direction="next":a.direction="prev",a.flexAnimate(h,a.vars.pauseOnAction))}""===g&&(g=b.type);f.setToClearWatchedEvent()})},set:function(){a.controlNav=c("."+d+"control-nav li "+("thumbnails"===a.vars.controlNav?"img":"a"),a.controlsContainer?a.controlsContainer:a)},active:function(){a.controlNav.removeClass(d+"active").eq(a.animatingTo).addClass(d+"active")},update:function(b,e){1<a.pagingCount&&"add"===b?a.controlNavScaffold.append(c("<li><a>"+a.count+"</a></li>")):1===a.pagingCount?a.controlNavScaffold.find("li").remove():
-a.controlNav.eq(e).closest("li").remove();f.controlNav.set();1<a.pagingCount&&a.pagingCount!==a.controlNav.length?a.update(e,b):f.controlNav.active()}},directionNav:{setup:function(){var b=c('<ul class="'+d+'direction-nav"><li><a class="'+d+'prev" href="#">'+a.vars.prevText+'</a></li><li><a class="'+d+'next" href="#">'+a.vars.nextText+"</a></li></ul>");a.controlsContainer?(c(a.controlsContainer).append(b),a.directionNav=c("."+d+"direction-nav li a",a.controlsContainer)):(a.append(b),a.directionNav=
-c("."+d+"direction-nav li a",a));f.directionNav.update();a.directionNav.bind("click touchend",function(b){b.preventDefault();var h;if(""===g||g===b.type)h=c(this).hasClass(d+"next")?a.getTarget("next"):a.getTarget("prev"),a.flexAnimate(h,a.vars.pauseOnAction);""===g&&(g=b.type);f.setToClearWatchedEvent()})},update:function(){var b=d+"disabled";1===a.pagingCount?a.directionNav.addClass(b):a.vars.animationLoop?a.directionNav.removeClass(b):0===a.animatingTo?a.directionNav.removeClass(b).filter("."+
-d+"prev").addClass(b):a.animatingTo===a.last?a.directionNav.removeClass(b).filter("."+d+"next").addClass(b):a.directionNav.removeClass(b)}},pausePlay:{setup:function(){var b=c('<div class="'+d+'pauseplay"><a></a></div>');a.controlsContainer?(a.controlsContainer.append(b),a.pausePlay=c("."+d+"pauseplay a",a.controlsContainer)):(a.append(b),a.pausePlay=c("."+d+"pauseplay a",a));f.pausePlay.update(a.vars.slideshow?d+"pause":d+"play");a.pausePlay.bind("click touchend",function(b){b.preventDefault();if(""===
-g||g===b.type)c(this).hasClass(d+"pause")?(a.manualPause=!0,a.manualPlay=!1,a.pause()):(a.manualPause=!1,a.manualPlay=!0,a.play());""===g&&(g=b.type);f.setToClearWatchedEvent()})},update:function(b){"play"===b?a.pausePlay.removeClass(d+"pause").addClass(d+"play").text(a.vars.playText):a.pausePlay.removeClass(d+"play").addClass(d+"pause").text(a.vars.pauseText)}},touch:function(){function b(b){m=n?c-b.touches[0].pageY:c-b.touches[0].pageX;r=n?Math.abs(m)<Math.abs(b.touches[0].pageX-d):Math.abs(m)<
-Math.abs(b.touches[0].pageY-d);if(!r||500<Number(new Date)-l)b.preventDefault(),!q&&a.transitions&&(a.vars.animationLoop||(m/=0===a.currentSlide&&0>m||a.currentSlide===a.last&&0<m?Math.abs(m)/g+2:1),a.setProps(f+m,"setTouch"))}function e(){j.removeEventListener("touchmove",b,!1);if(a.animatingTo===a.currentSlide&&!r&&null!==m){var k=p?-m:m,n=0<k?a.getTarget("next"):a.getTarget("prev");a.canAdvance(n)&&(550>Number(new Date)-l&&50<Math.abs(k)||Math.abs(k)>g/2)?a.flexAnimate(n,a.vars.pauseOnAction):
-q||a.flexAnimate(a.currentSlide,a.vars.pauseOnAction,!0)}j.removeEventListener("touchend",e,!1);f=m=d=c=null}var c,d,f,g,m,l,r=!1;j.addEventListener("touchstart",function(m){a.animating?m.preventDefault():1===m.touches.length&&(a.pause(),g=n?a.h:a.w,l=Number(new Date),f=k&&p&&a.animatingTo===a.last?0:k&&p?a.limit-(a.itemW+a.vars.itemMargin)*a.move*a.animatingTo:k&&a.currentSlide===a.last?a.limit:k?(a.itemW+a.vars.itemMargin)*a.move*a.currentSlide:p?(a.last-a.currentSlide+a.cloneOffset)*g:(a.currentSlide+
-a.cloneOffset)*g,c=n?m.touches[0].pageY:m.touches[0].pageX,d=n?m.touches[0].pageX:m.touches[0].pageY,j.addEventListener("touchmove",b,!1),j.addEventListener("touchend",e,!1))},!1)},resize:function(){!a.animating&&a.is(":visible")&&(k||a.doMath(),q?f.smoothHeight():k?(a.slides.width(a.computedW),a.update(a.pagingCount),a.setProps()):n?(a.viewport.height(a.h),a.setProps(a.h,"setTotal")):(a.vars.smoothHeight&&f.smoothHeight(),a.newSlides.width(a.computedW),a.setProps(a.computedW,"setTotal")))},smoothHeight:function(b){if(!n||
-q){var e=q?a:a.viewport;b?e.animate({height:a.slides.eq(a.animatingTo).height()},b):e.height(a.slides.eq(a.animatingTo).height())}},sync:function(b){var e=c(a.vars.sync).data("flexslider"),d=a.animatingTo;switch(b){case "animate":e.flexAnimate(d,a.vars.pauseOnAction,!1,!0);break;case "play":!e.playing&&!e.asNav&&e.play();break;case "pause":e.pause()}},setToClearWatchedEvent:function(){clearTimeout(t);t=setTimeout(function(){g=""},3E3)}};a.flexAnimate=function(b,e,h,g,j){r&&1===a.pagingCount&&(a.direction=
-a.currentItem<b?"next":"prev");if(!a.animating&&(a.canAdvance(b,j)||h)&&a.is(":visible")){if(r&&g)if(h=c(a.vars.asNavFor).data("flexslider"),a.atEnd=0===b||b===a.count-1,h.flexAnimate(b,!0,!1,!0,j),a.direction=a.currentItem<b?"next":"prev",h.direction=a.direction,Math.ceil((b+1)/a.visible)-1!==a.currentSlide&&0!==b)a.currentItem=b,a.slides.removeClass(d+"active-slide").eq(b).addClass(d+"active-slide"),b=Math.floor(b/a.visible);else return a.currentItem=b,a.slides.removeClass(d+"active-slide").eq(b).addClass(d+
-"active-slide"),!1;a.animating=!0;a.animatingTo=b;a.vars.before(a);e&&a.pause();a.syncExists&&!j&&f.sync("animate");a.vars.controlNav&&f.controlNav.active();k||a.slides.removeClass(d+"active-slide").eq(b).addClass(d+"active-slide");a.atEnd=0===b||b===a.last;a.vars.directionNav&&f.directionNav.update();b===a.last&&(a.vars.end(a),a.vars.animationLoop||a.pause());if(q)s?(a.slides.eq(a.currentSlide).css({opacity:0,zIndex:1}),a.slides.eq(b).css({opacity:1,zIndex:2}),a.animating=!1,a.currentSlide=a.animatingTo):
-(a.slides.eq(a.currentSlide).css({zIndex:1}).animate({opacity:0},a.vars.animationSpeed,a.vars.easing),a.slides.eq(b).css({zIndex:2}).animate({opacity:1},a.vars.animationSpeed,a.vars.easing,a.wrapup));else{var l=n?a.slides.filter(":first").height():a.computedW;k?(b=a.vars.itemMargin,b=(a.itemW+b)*a.move*a.animatingTo,b=b>a.limit&&1!==a.visible?a.limit:b):b=0===a.currentSlide&&b===a.count-1&&a.vars.animationLoop&&"next"!==a.direction?p?(a.count+a.cloneOffset)*l:0:a.currentSlide===a.last&&0===b&&a.vars.animationLoop&&
-"prev"!==a.direction?p?0:(a.count+1)*l:p?(a.count-1-b+a.cloneOffset)*l:(b+a.cloneOffset)*l;a.setProps(b,"",a.vars.animationSpeed);if(a.transitions){if(!a.vars.animationLoop||!a.atEnd)a.animating=!1,a.currentSlide=a.animatingTo;a.container.unbind("webkitTransitionEnd transitionend");a.container.bind("webkitTransitionEnd transitionend",function(){a.wrapup(l)})}else a.container.animate(a.args,a.vars.animationSpeed,a.vars.easing,function(){a.wrapup(l)})}a.vars.smoothHeight&&f.smoothHeight(a.vars.animationSpeed)}};
-a.wrapup=function(b){!q&&!k&&(0===a.currentSlide&&a.animatingTo===a.last&&a.vars.animationLoop?a.setProps(b,"jumpEnd"):a.currentSlide===a.last&&(0===a.animatingTo&&a.vars.animationLoop)&&a.setProps(b,"jumpStart"));a.animating=!1;a.currentSlide=a.animatingTo;a.vars.after(a)};a.animateSlides=function(){a.animating||a.flexAnimate(a.getTarget("next"))};a.pause=function(){clearInterval(a.animatedSlides);a.playing=!1;a.vars.pausePlay&&f.pausePlay.update("play");a.syncExists&&f.sync("pause")};a.play=function(){a.animatedSlides=
-setInterval(a.animateSlides,a.vars.slideshowSpeed);a.playing=!0;a.vars.pausePlay&&f.pausePlay.update("pause");a.syncExists&&f.sync("play")};a.canAdvance=function(b,e){var c=r?a.pagingCount-1:a.last;return e?!0:r&&a.currentItem===a.count-1&&0===b&&"prev"===a.direction?!0:r&&0===a.currentItem&&b===a.pagingCount-1&&"next"!==a.direction?!1:b===a.currentSlide&&!r?!1:a.vars.animationLoop?!0:a.atEnd&&0===a.currentSlide&&b===c&&"next"!==a.direction?!1:a.atEnd&&a.currentSlide===c&&0===b&&"next"===a.direction?
-!1:!0};a.getTarget=function(b){a.direction=b;return"next"===b?a.currentSlide===a.last?0:a.currentSlide+1:0===a.currentSlide?a.last:a.currentSlide-1};a.setProps=function(b,e,c){var d,f=b?b:(a.itemW+a.vars.itemMargin)*a.move*a.animatingTo;d=-1*function(){if(k)return"setTouch"===e?b:p&&a.animatingTo===a.last?0:p?a.limit-(a.itemW+a.vars.itemMargin)*a.move*a.animatingTo:a.animatingTo===a.last?a.limit:f;switch(e){case "setTotal":return p?(a.count-1-a.currentSlide+a.cloneOffset)*b:(a.currentSlide+a.cloneOffset)*
-b;case "setTouch":return b;case "jumpEnd":return p?b:a.count*b;case "jumpStart":return p?a.count*b:b;default:return b}}()+"px";a.transitions&&(d=n?"translate3d(0,"+d+",0)":"translate3d("+d+",0,0)",c=void 0!==c?c/1E3+"s":"0s",a.container.css("-"+a.pfx+"-transition-duration",c));a.args[a.prop]=d;(a.transitions||void 0===c)&&a.container.css(a.args)};a.setup=function(b){if(q)a.slides.css({width:"100%","float":"left",marginRight:"-100%",position:"relative"}),"init"===b&&(s?a.slides.css({opacity:0,display:"block",
-webkitTransition:"opacity "+a.vars.animationSpeed/1E3+"s ease",zIndex:1}).eq(a.currentSlide).css({opacity:1,zIndex:2}):a.slides.css({opacity:0,display:"block",zIndex:1}).eq(a.currentSlide).css({zIndex:2}).animate({opacity:1},a.vars.animationSpeed,a.vars.easing)),a.vars.smoothHeight&&f.smoothHeight();else{var e,h;"init"===b&&(a.viewport=c('<div class="'+d+'viewport"></div>').css({overflow:"hidden",position:"relative"}).appendTo(a).append(a.container),a.cloneCount=0,a.cloneOffset=0,p&&(h=c.makeArray(a.slides).reverse(),
-a.slides=c(h),a.container.empty().append(a.slides)));a.vars.animationLoop&&!k&&(a.cloneCount=2,a.cloneOffset=1,"init"!==b&&a.container.find(".clone").remove(),a.container.append(a.slides.first().clone().addClass("clone")).prepend(a.slides.last().clone().addClass("clone")));a.newSlides=c(a.vars.selector,a);e=p?a.count-1-a.currentSlide+a.cloneOffset:a.currentSlide+a.cloneOffset;n&&!k?(a.container.height(200*(a.count+a.cloneCount)+"%").css("position","absolute").width("100%"),setTimeout(function(){a.newSlides.css({display:"block"});
-a.doMath();a.viewport.height(a.h);a.setProps(e*a.h,"init")},"init"===b?100:0)):(a.container.width(200*(a.count+a.cloneCount)+"%"),a.setProps(e*a.computedW,"init"),setTimeout(function(){a.doMath();a.newSlides.css({width:a.computedW,"float":"left",display:"block"});a.vars.smoothHeight&&f.smoothHeight()},"init"===b?100:0))}k||a.slides.removeClass(d+"active-slide").eq(a.currentSlide).addClass(d+"active-slide")};a.doMath=function(){var b=a.slides.first(),e=a.vars.itemMargin,c=a.vars.minItems,d=a.vars.maxItems;
-a.w=a.width();a.h=b.height();a.boxPadding=b.outerWidth()-b.width();k?(a.itemT=a.vars.itemWidth+e,a.minW=c?c*a.itemT:a.w,a.maxW=d?d*a.itemT-e:a.w,a.itemW=a.minW>a.w?(a.w-e*(c-1))/c:a.maxW<a.w?(a.w-e*(d-1))/d:a.vars.itemWidth>a.w?a.w:a.vars.itemWidth,a.visible=Math.floor(a.w/a.itemW),a.move=0<a.vars.move&&a.vars.move<a.visible?a.vars.move:a.visible,a.pagingCount=Math.ceil((a.count-a.visible)/a.move+1),a.last=a.pagingCount-1,a.limit=1===a.pagingCount?0:a.vars.itemWidth>a.w?a.itemW*(a.count-1)+e*(a.count-
-1):(a.itemW+e)*a.count-a.w-e):(a.itemW=a.w,a.pagingCount=a.count,a.last=a.count-1);a.computedW=a.itemW-a.boxPadding};a.update=function(b,c){a.doMath();k||(b<a.currentSlide?a.currentSlide+=1:b<=a.currentSlide&&0!==b&&(a.currentSlide-=1),a.animatingTo=a.currentSlide);if(a.vars.controlNav&&!a.manualControls)if("add"===c&&!k||a.pagingCount>a.controlNav.length)f.controlNav.update("add");else if("remove"===c&&!k||a.pagingCount<a.controlNav.length)k&&a.currentSlide>a.last&&(a.currentSlide-=1,a.animatingTo-=
-1),f.controlNav.update("remove",a.last);a.vars.directionNav&&f.directionNav.update()};a.addSlide=function(b,e){var d=c(b);a.count+=1;a.last=a.count-1;n&&p?void 0!==e?a.slides.eq(a.count-e).after(d):a.container.prepend(d):void 0!==e?a.slides.eq(e).before(d):a.container.append(d);a.update(e,"add");a.slides=c(a.vars.selector+":not(.clone)",a);a.setup();a.vars.added(a)};a.removeSlide=function(b){var d=isNaN(b)?a.slides.index(c(b)):b;a.count-=1;a.last=a.count-1;isNaN(b)?c(b,a.slides).remove():n&&p?a.slides.eq(a.last).remove():
-a.slides.eq(b).remove();a.doMath();a.update(d,"remove");a.slides=c(a.vars.selector+":not(.clone)",a);a.setup();a.vars.removed(a)};f.init()};c.flexslider.defaults={namespace:"flex-",selector:".slides > li",animation:"fade",easing:"swing",direction:"horizontal",reverse:!1,animationLoop:!0,smoothHeight:!1,startAt:0,slideshow:!0,slideshowSpeed:7E3,animationSpeed:600,initDelay:0,randomize:!1,pauseOnAction:!0,pauseOnHover:!1,useCSS:!0,touch:!0,video:!1,controlNav:!0,directionNav:!0,prevText:"Previous",
-nextText:"Next",keyboard:!0,multipleKeyboard:!1,mousewheel:!1,pausePlay:!1,pauseText:"Pause",playText:"Play",controlsContainer:"",manualControls:"",sync:"",asNavFor:"",itemWidth:0,itemMargin:0,minItems:0,maxItems:0,move:0,start:function(){},before:function(){},after:function(){},end:function(){},added:function(){},removed:function(){}};c.fn.flexslider=function(j){void 0===j&&(j={});if("object"===typeof j)return this.each(function(){var a=c(this),d=a.find(j.selector?j.selector:".slides > li");1===
-d.length?(d.fadeIn(400),j.start&&j.start(a)):void 0===a.data("flexslider")&&new c.flexslider(this,j)});var l=c(this).data("flexslider");switch(j){case "play":l.play();break;case "pause":l.pause();break;case "next":l.flexAnimate(l.getTarget("next"),!0);break;case "prev":case "previous":l.flexAnimate(l.getTarget("prev"),!0);break;default:"number"===typeof j&&l.flexAnimate(j,!0)}}})(jQuery);
+ (function(e){if(typeof define==="function"&&define.amd){define(["jquery"],e)}else{e(jQuery)}})(function(e){e.flexslider=function(t,n){var r=e(t);r.vars=e.extend({},e.flexslider.defaults,n);var i=r.vars.namespace,s=("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)&&r.vars.touch,o="click touchend",u="",a,f=r.vars.direction==="vertical",l=r.vars.reverse,c=r.vars.itemWidth>0,h=r.vars.animation==="fade",p=r.vars.asNavFor!=="",d={};focused=true;e.data(t,"flexslider",r);d={init:function(){r.animating=false;r.currentSlide=r.vars.startAt;r.animatingTo=r.currentSlide;r.atEnd=r.currentSlide===0||r.currentSlide===r.last;r.containerSelector=r.vars.selector.substr(0,r.vars.selector.search(" "));r.slides=e(r.vars.selector,r);r.container=e(r.containerSelector,r);r.count=r.slides.length;r.syncExists=e(r.vars.sync).length>0;if(r.vars.animation==="slide")r.vars.animation="swing";r.prop=f?"top":"marginLeft";r.args={};r.manualPause=false;r.stopped=false;r.transitions=!r.vars.video&&!h&&r.vars.useCSS&&function(){var e=document.createElement("div"),t=["perspectiveProperty","WebkitPerspective","MozPerspective","OPerspective","msPerspective"];for(var n in t){if(e.style[t[n]]!==undefined){r.pfx=t[n].replace("Perspective","").toLowerCase();r.prop="-"+r.pfx+"-transform";return true}}return false}();if(r.vars.controlsContainer!=="")r.controlsContainer=e(r.vars.controlsContainer).length>0&&e(r.vars.controlsContainer);if(r.vars.manualControls!=="")r.manualControls=e(r.vars.manualControls).length>0&&e(r.vars.manualControls);if(r.vars.randomize){r.slides.sort(function(){return Math.round(Math.random())-.5});r.container.empty().append(r.slides)}r.doMath();if(p)d.asNav.setup();r.setup("init");if(r.vars.controlNav)d.controlNav.setup();if(r.vars.directionNav)d.directionNav.setup();if(r.vars.keyboard&&(e(r.containerSelector).length===1||r.vars.multipleKeyboard)){e(document).bind("keyup",function(e){var t=e.keyCode;if(!r.animating&&(t===39||t===37)){var n=t===39?r.getTarget("next"):t===37?r.getTarget("prev"):false;r.flexAnimate(n,r.vars.pauseOnAction)}})}if(r.vars.mousewheel){r.bind("mousewheel",function(e,t,n,i){e.preventDefault();var s=t<0?r.getTarget("next"):r.getTarget("prev");r.flexAnimate(s,r.vars.pauseOnAction)})}if(r.vars.pausePlay)d.pausePlay.setup();if(r.vars.slideshow){if(r.vars.pauseOnHover){r.hover(function(){if(!r.manualPlay&&!r.manualPause)r.pause()},function(){if(!r.manualPause&&!r.manualPlay&&!r.stopped)r.play()})}r.vars.initDelay>0?setTimeout(r.play,r.vars.initDelay):r.play()}if(s&&r.vars.touch)d.touch();if(!h||h&&r.vars.smoothHeight)e(window).bind("resize focus",d.resize);setTimeout(function(){r.vars.start(r)},200)},asNav:{setup:function(){r.asNav=true;r.animatingTo=Math.floor(r.currentSlide/r.move);r.currentItem=r.currentSlide;r.slides.removeClass(i+"active-slide").eq(r.currentItem).addClass(i+"active-slide");r.slides.click(function(t){t.preventDefault();var n=e(this),s=n.index();var o=n.offset().left-e(r).scrollLeft();if(o<=0&&n.hasClass(i+"active-slide")){r.flexAnimate(r.getTarget("prev"),true)}else if(!e(r.vars.asNavFor).data("flexslider").animating&&!n.hasClass(i+"active-slide")){r.direction=r.currentItem<s?"next":"prev";r.flexAnimate(s,r.vars.pauseOnAction,false,true,true)}})}},controlNav:{setup:function(){if(!r.manualControls){d.controlNav.setupPaging()}else{d.controlNav.setupManual()}},setupPaging:function(){var t=r.vars.controlNav==="thumbnails"?"control-thumbs":"control-paging",n=1,s;r.controlNavScaffold=e('<ol class="'+i+"control-nav "+i+t+'"></ol>');if(r.pagingCount>1){for(var a=0;a<r.pagingCount;a++){s=r.vars.controlNav==="thumbnails"?'<img src="'+r.slides.eq(a).attr("data-thumb")+'"/>':"<a>"+n+"</a>";r.controlNavScaffold.append("<li>"+s+"</li>");n++}}r.controlsContainer?e(r.controlsContainer).append(r.controlNavScaffold):r.append(r.controlNavScaffold);d.controlNav.set();d.controlNav.active();r.controlNavScaffold.delegate("a, img",o,function(t){t.preventDefault();if(u===""||u===t.type){var n=e(this),s=r.controlNav.index(n);if(!n.hasClass(i+"active")){r.direction=s>r.currentSlide?"next":"prev";r.flexAnimate(s,r.vars.pauseOnAction)}}if(u===""){u=t.type}d.setToClearWatchedEvent()})},setupManual:function(){r.controlNav=r.manualControls;d.controlNav.active();r.controlNav.bind(o,function(t){t.preventDefault();if(u===""||u===t.type){var n=e(this),s=r.controlNav.index(n);if(!n.hasClass(i+"active")){s>r.currentSlide?r.direction="next":r.direction="prev";r.flexAnimate(s,r.vars.pauseOnAction)}}if(u===""){u=t.type}d.setToClearWatchedEvent()})},set:function(){var t=r.vars.controlNav==="thumbnails"?"img":"a";r.controlNav=e("."+i+"control-nav li "+t,r.controlsContainer?r.controlsContainer:r)},active:function(){r.controlNav.removeClass(i+"active").eq(r.animatingTo).addClass(i+"active")},update:function(t,n){if(r.pagingCount>1&&t==="add"){r.controlNavScaffold.append(e("<li><a>"+r.count+"</a></li>"))}else if(r.pagingCount===1){r.controlNavScaffold.find("li").remove()}else{r.controlNav.eq(n).closest("li").remove()}d.controlNav.set();r.pagingCount>1&&r.pagingCount!==r.controlNav.length?r.update(n,t):d.controlNav.active()}},directionNav:{setup:function(){var t=e('<ul class="'+i+'direction-nav"><li><a class="'+i+'prev" href="#">'+r.vars.prevText+'</a></li><li><a class="'+i+'next" href="#">'+r.vars.nextText+"</a></li></ul>");if(r.controlsContainer){e(r.controlsContainer).append(t);r.directionNav=e("."+i+"direction-nav li a",r.controlsContainer)}else{r.append(t);r.directionNav=e("."+i+"direction-nav li a",r)}d.directionNav.update();r.directionNav.bind(o,function(t){t.preventDefault();var n;if(u===""||u===t.type){n=e(this).hasClass(i+"next")?r.getTarget("next"):r.getTarget("prev");r.flexAnimate(n,r.vars.pauseOnAction)}if(u===""){u=t.type}d.setToClearWatchedEvent()})},update:function(){var e=i+"disabled";if(r.pagingCount===1){r.directionNav.addClass(e).attr("tabindex","-1")}else if(!r.vars.animationLoop){if(r.animatingTo===0){r.directionNav.removeClass(e).filter("."+i+"prev").addClass(e).attr("tabindex","-1")}else if(r.animatingTo===r.last){r.directionNav.removeClass(e).filter("."+i+"next").addClass(e).attr("tabindex","-1")}else{r.directionNav.removeClass(e).removeAttr("tabindex")}}else{r.directionNav.removeClass(e).removeAttr("tabindex")}}},pausePlay:{setup:function(){var t=e('<div class="'+i+'pauseplay"><a></a></div>');if(r.controlsContainer){r.controlsContainer.append(t);r.pausePlay=e("."+i+"pauseplay a",r.controlsContainer)}else{r.append(t);r.pausePlay=e("."+i+"pauseplay a",r)}d.pausePlay.update(r.vars.slideshow?i+"pause":i+"play");r.pausePlay.bind(o,function(t){t.preventDefault();if(u===""||u===t.type){if(e(this).hasClass(i+"pause")){r.manualPause=true;r.manualPlay=false;r.pause()}else{r.manualPause=false;r.manualPlay=true;r.play()}}if(u===""){u=t.type}d.setToClearWatchedEvent()})},update:function(e){e==="play"?r.pausePlay.removeClass(i+"pause").addClass(i+"play").text(r.vars.playText):r.pausePlay.removeClass(i+"play").addClass(i+"pause").text(r.vars.pauseText)}},touch:function(){function p(o){if(r.animating){o.preventDefault()}else if(o.touches.length===1){r.pause();s=f?r.h:r.w;u=Number(new Date);i=c&&l&&r.animatingTo===r.last?0:c&&l?r.limit-(r.itemW+r.vars.itemMargin)*r.move*r.animatingTo:c&&r.currentSlide===r.last?r.limit:c?(r.itemW+r.vars.itemMargin)*r.move*r.currentSlide:l?(r.last-r.currentSlide+r.cloneOffset)*s:(r.currentSlide+r.cloneOffset)*s;e=f?o.touches[0].pageY:o.touches[0].pageX;n=f?o.touches[0].pageX:o.touches[0].pageY;t.addEventListener("touchmove",d,false);t.addEventListener("touchend",v,false)}}function d(t){o=f?e-t.touches[0].pageY:e-t.touches[0].pageX;a=f?Math.abs(o)<Math.abs(t.touches[0].pageX-n):Math.abs(o)<Math.abs(t.touches[0].pageY-n);if(!a||Number(new Date)-u>500){t.preventDefault();if(!h&&r.transitions){if(!r.vars.animationLoop){o=o/(r.currentSlide===0&&o<0||r.currentSlide===r.last&&o>0?Math.abs(o)/s+2:1)}r.setProps(i+o,"setTouch")}}}function v(f){t.removeEventListener("touchmove",d,false);if(r.animatingTo===r.currentSlide&&!a&&!(o===null)){var c=l?-o:o,p=c>0?r.getTarget("next"):r.getTarget("prev");if(r.canAdvance(p)&&(Number(new Date)-u<550&&Math.abs(c)>50||Math.abs(c)>s/2)){r.flexAnimate(p,r.vars.pauseOnAction)}else{if(!h)r.flexAnimate(r.currentSlide,r.vars.pauseOnAction,true)}}t.removeEventListener("touchend",v,false);e=null;n=null;o=null;i=null}var e,n,i,s,o,u,a=false;t.addEventListener("touchstart",p,false)},resize:function(){if(!r.animating&&r.is(":visible")){if(!c)r.doMath();if(h){d.smoothHeight()}else if(c){r.slides.width(r.computedW);r.update(r.pagingCount);r.setProps()}else if(f){r.viewport.height(r.h);r.setProps(r.h,"setTotal")}else{if(r.vars.smoothHeight)d.smoothHeight();r.newSlides.width(r.computedW);r.setProps(r.computedW,"setTotal")}}},smoothHeight:function(e){if(!f||h){var t=h?r:r.viewport;e?t.animate({height:r.slides.eq(r.animatingTo).height()},e):t.height(r.slides.eq(r.animatingTo).height())}},sync:function(t){var n=e(r.vars.sync).data("flexslider"),i=r.animatingTo;switch(t){case"animate":n.flexAnimate(i,r.vars.pauseOnAction,false,true);break;case"play":if(!n.playing&&!n.asNav){n.play()}break;case"pause":n.pause();break}},setToClearWatchedEvent:function(){clearTimeout(a);a=setTimeout(function(){u=""},3e3)}};r.flexAnimate=function(t,n,o,u,a){if(p&&r.pagingCount===1)r.direction=r.currentItem<t?"next":"prev";if(!r.animating&&(r.canAdvance(t,a)||o)&&r.is(":visible")){if(p&&u){var v=e(r.vars.asNavFor).data("flexslider");r.atEnd=t===0||t===r.count-1;v.flexAnimate(t,true,false,true,a);r.direction=r.currentItem<t?"next":"prev";v.direction=r.direction;if(Math.ceil((t+1)/r.visible)-1!==r.currentSlide&&t!==0){r.currentItem=t;r.slides.removeClass(i+"active-slide").eq(t).addClass(i+"active-slide");t=Math.floor(t/r.visible)}else{r.currentItem=t;r.slides.removeClass(i+"active-slide").eq(t).addClass(i+"active-slide");return false}}r.animating=true;r.animatingTo=t;r.vars.before(r);if(n)r.pause();if(r.syncExists&&!a)d.sync("animate");if(r.vars.controlNav)d.controlNav.active();if(!c)r.slides.removeClass(i+"active-slide").eq(t).addClass(i+"active-slide");r.atEnd=t===0||t===r.last;if(r.vars.directionNav)d.directionNav.update();if(t===r.last){r.vars.end(r);if(!r.vars.animationLoop)r.pause()}if(!h){var m=f?r.slides.filter(":first").height():r.computedW,g,y,b;if(c){g=r.vars.itemMargin;b=(r.itemW+g)*r.move*r.animatingTo;y=b>r.limit&&r.visible!==1?r.limit:b}else if(r.currentSlide===0&&t===r.count-1&&r.vars.animationLoop&&r.direction!=="next"){y=l?(r.count+r.cloneOffset)*m:0}else if(r.currentSlide===r.last&&t===0&&r.vars.animationLoop&&r.direction!=="prev"){y=l?0:(r.count+1)*m}else{y=l?(r.count-1-t+r.cloneOffset)*m:(t+r.cloneOffset)*m}r.setProps(y,"",r.vars.animationSpeed);if(r.transitions){if(!r.vars.animationLoop||!r.atEnd){r.animating=false;r.currentSlide=r.animatingTo}r.container.unbind("webkitTransitionEnd transitionend");r.container.bind("webkitTransitionEnd transitionend",function(){r.wrapup(m)})}else{r.container.animate(r.args,r.vars.animationSpeed,r.vars.easing,function(){r.wrapup(m)})}}else{if(!s){r.slides.eq(r.currentSlide).css({zIndex:1}).animate({opacity:0},r.vars.animationSpeed,r.vars.easing);r.slides.eq(t).css({zIndex:2}).animate({opacity:1},r.vars.animationSpeed,r.vars.easing,r.wrapup)}else{r.slides.eq(r.currentSlide).css({opacity:0,zIndex:1});r.slides.eq(t).css({opacity:1,zIndex:2});r.animating=false;r.currentSlide=r.animatingTo}}if(r.vars.smoothHeight)d.smoothHeight(r.vars.animationSpeed)}};r.wrapup=function(e){if(!h&&!c){if(r.currentSlide===0&&r.animatingTo===r.last&&r.vars.animationLoop){r.setProps(e,"jumpEnd")}else if(r.currentSlide===r.last&&r.animatingTo===0&&r.vars.animationLoop){r.setProps(e,"jumpStart")}}r.animating=false;r.currentSlide=r.animatingTo;r.vars.after(r)};r.animateSlides=function(){if(!r.animating&&focused)r.flexAnimate(r.getTarget("next"))};r.pause=function(){clearInterval(r.animatedSlides);r.animatedSlides=null;r.playing=false;if(r.vars.pausePlay)d.pausePlay.update("play");if(r.syncExists)d.sync("pause")};r.play=function(){r.animatedSlides=r.animatedSlides||setInterval(r.animateSlides,r.vars.slideshowSpeed);r.playing=true;if(r.vars.pausePlay)d.pausePlay.update("pause");if(r.syncExists)d.sync("play")};r.stop=function(){r.pause();r.stopped=true};r.canAdvance=function(e,t){var n=p?r.pagingCount-1:r.last;return t?true:p&&r.currentItem===r.count-1&&e===0&&r.direction==="prev"?true:p&&r.currentItem===0&&e===r.pagingCount-1&&r.direction!=="next"?false:e===r.currentSlide&&!p?false:r.vars.animationLoop?true:r.atEnd&&r.currentSlide===0&&e===n&&r.direction!=="next"?false:r.atEnd&&r.currentSlide===n&&e===0&&r.direction==="next"?false:true};r.getTarget=function(e){r.direction=e;if(e==="next"){return r.currentSlide===r.last?0:r.currentSlide+1}else{return r.currentSlide===0?r.last:r.currentSlide-1}};r.setProps=function(e,t,n){var i=function(){var n=e?e:(r.itemW+r.vars.itemMargin)*r.move*r.animatingTo,i=function(){if(c){return t==="setTouch"?e:l&&r.animatingTo===r.last?0:l?r.limit-(r.itemW+r.vars.itemMargin)*r.move*r.animatingTo:r.animatingTo===r.last?r.limit:n}else{switch(t){case"setTotal":return l?(r.count-1-r.currentSlide+r.cloneOffset)*e:(r.currentSlide+r.cloneOffset)*e;case"setTouch":return l?e:e;case"jumpEnd":return l?e:r.count*e;case"jumpStart":return l?r.count*e:e;default:return e}}}();return i*-1+"px"}();if(r.transitions){i=f?"translate3d(0,"+i+",0)":"translate3d("+i+",0,0)";n=n!==undefined?n/1e3+"s":"0s";r.container.css("-"+r.pfx+"-transition-duration",n)}r.args[r.prop]=i;if(r.transitions||n===undefined)r.container.css(r.args)};r.setup=function(t){if(!h){var n,o;if(t==="init"){r.viewport=e('<div class="'+i+'viewport"></div>').css({overflow:"hidden",position:"relative"}).appendTo(r).append(r.container);r.cloneCount=0;r.cloneOffset=0;if(l){o=e.makeArray(r.slides).reverse();r.slides=e(o);r.container.empty().append(r.slides)}}if(r.vars.animationLoop&&!c){r.cloneCount=2;r.cloneOffset=1;if(t!=="init")r.container.find(".clone").remove();r.container.append(r.slides.first().clone().addClass("clone").attr("aria-hidden","true")).prepend(r.slides.last().clone().addClass("clone").attr("aria-hidden","true"))}r.newSlides=e(r.vars.selector,r);n=l?r.count-1-r.currentSlide+r.cloneOffset:r.currentSlide+r.cloneOffset;if(f&&!c){r.container.height((r.count+r.cloneCount)*200+"%").css("position","absolute").width("100%");setTimeout(function(){r.newSlides.css({display:"block"});r.doMath();r.viewport.height(r.h);r.setProps(n*r.h,"init")},t==="init"?100:0)}else{r.container.width((r.count+r.cloneCount)*200+"%");r.setProps(n*r.computedW,"init");setTimeout(function(){r.doMath();r.newSlides.css({width:r.computedW,"float":"left",display:"block"});if(r.vars.smoothHeight)d.smoothHeight()},t==="init"?100:0)}}else{r.slides.css({width:"100%","float":"left",marginRight:"-100%",position:"relative"});if(t==="init"){if(!s){r.slides.css({opacity:0,display:"block",zIndex:1}).eq(r.currentSlide).css({zIndex:2}).animate({opacity:1},r.vars.animationSpeed,r.vars.easing)}else{r.slides.css({opacity:0,display:"block",webkitTransition:"opacity "+r.vars.animationSpeed/1e3+"s ease",zIndex:1}).eq(r.currentSlide).css({opacity:1,zIndex:2})}}if(r.vars.smoothHeight)d.smoothHeight()}if(!c)r.slides.removeClass(i+"active-slide").eq(r.currentSlide).addClass(i+"active-slide")};r.doMath=function(){var e=r.slides.first(),t=r.vars.itemMargin,n=r.vars.minItems,i=r.vars.maxItems;r.w=r.width();r.h=e.height();r.boxPadding=e.outerWidth()-e.width();if(c){r.itemT=r.vars.itemWidth+t;r.minW=n?n*r.itemT:r.w;r.maxW=i?i*r.itemT-t:r.w;r.itemW=r.minW>r.w?(r.w-t*(n-1))/n:r.maxW<r.w?(r.w-t*(i-1))/i:r.vars.itemWidth>r.w?r.w:r.vars.itemWidth;r.visible=Math.floor(r.w/r.itemW);r.move=r.vars.move>0&&r.vars.move<r.visible?r.vars.move:r.visible;r.pagingCount=Math.ceil((r.count-r.visible)/r.move+1);r.last=r.pagingCount-1;r.limit=r.pagingCount===1?0:r.vars.itemWidth>r.w?r.itemW*(r.count-1)+t*(r.count-1):(r.itemW+t)*r.count-r.w-t}else{r.itemW=r.w;r.pagingCount=r.count;r.last=r.count-1}r.computedW=r.itemW-r.boxPadding};r.update=function(e,t){r.doMath();if(!c){if(e<r.currentSlide){r.currentSlide+=1}else if(e<=r.currentSlide&&e!==0){r.currentSlide-=1}r.animatingTo=r.currentSlide}if(r.vars.controlNav&&!r.manualControls){if(t==="add"&&!c||r.pagingCount>r.controlNav.length){d.controlNav.update("add")}else if(t==="remove"&&!c||r.pagingCount<r.controlNav.length){if(c&&r.currentSlide>r.last){r.currentSlide-=1;r.animatingTo-=1}d.controlNav.update("remove",r.last)}}if(r.vars.directionNav)d.directionNav.update()};r.addSlide=function(t,n){var i=e(t);r.count+=1;r.last=r.count-1;if(f&&l){n!==undefined?r.slides.eq(r.count-n).after(i):r.container.prepend(i)}else{n!==undefined?r.slides.eq(n).before(i):r.container.append(i)}r.update(n,"add");r.slides=e(r.vars.selector+":not(.clone)",r);r.setup();r.vars.added(r)};r.removeSlide=function(t){var n=isNaN(t)?r.slides.index(e(t)):t;r.count-=1;r.last=r.count-1;if(isNaN(t)){e(t,r.slides).remove()}else{f&&l?r.slides.eq(r.last).remove():r.slides.eq(t).remove()}r.doMath();r.update(n,"remove");r.slides=e(r.vars.selector+":not(.clone)",r);r.setup();r.vars.removed(r)};d.init()};e(window).blur(function(e){focused=false}).focus(function(e){focused=true});e.flexslider.defaults={namespace:"flex-",selector:".slides > li",animation:"fade",easing:"swing",direction:"horizontal",reverse:false,animationLoop:true,smoothHeight:false,startAt:0,slideshow:true,slideshowSpeed:7e3,animationSpeed:600,initDelay:0,randomize:false,pauseOnAction:true,pauseOnHover:false,useCSS:true,touch:true,video:false,controlNav:true,directionNav:true,prevText:"Previous",nextText:"Next",keyboard:true,multipleKeyboard:false,mousewheel:false,pausePlay:false,pauseText:"Pause",playText:"Play",controlsContainer:"",manualControls:"",sync:"",asNavFor:"",itemWidth:0,itemMargin:0,minItems:0,maxItems:0,move:0,start:function(){},before:function(){},after:function(){},end:function(){},added:function(){},removed:function(){}};e.fn.flexslider=function(t){if(t===undefined)t={};if(typeof t==="object"){return this.each(function(){var n=e(this),r=t.selector?t.selector:".slides > li",i=n.find(r);if(i.length===1){i.fadeIn(400);if(t.start)t.start(n)}else if(n.data("flexslider")===undefined){new e.flexslider(this,t)}})}else{var n=e(this).data("flexslider");switch(t){case"play":n.play();break;case"pause":n.pause();break;case"stop":n.stop();break;case"next":n.flexAnimate(n.getTarget("next"),true);break;case"prev":case"previous":n.flexAnimate(n.getTarget("prev"),true);break;default:if(typeof t==="number")n.flexAnimate(t,true)}}}})(jQuery)
13 jquery.flexslider.js
View
@@ -3,7 +3,16 @@
* Copyright 2012 WooThemes
* Contributing Author: Tyler Smith
*/
-;(function ($) {
+;
+(function(factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD. Register as an anonymous module.
+ define(['jquery'], factory);
+ } else {
+ // Browser globals
+ factory(jQuery);
+ }
+}(function ($) {
//FlexSlider: Object Instance
$.flexslider = function(el, options) {
@@ -942,4 +951,4 @@
}
}
}
-})(jQuery);
+}))(jQuery);
Something went wrong with that request. Please try again.