-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontentNavigationCarousel.min.js
More file actions
8 lines (8 loc) · 2.43 KB
/
contentNavigationCarousel.min.js
File metadata and controls
8 lines (8 loc) · 2.43 KB
1
2
3
4
5
6
7
8
/*!
* contentNavigationCarousel v1.0.1 (https://github.com/TechTarget/contentNavigationCarousel)
* Author: Morgan Wigmanich <okize123@gmail.com> (http://github.com/okize)
* Copyright (c) 2013 | Licensed under the MIT license
* http://www.opensource.org/licenses/mit-license.php
*/
!function(t,e){"use strict";function n(e,n){this.element=e,this.options=t.extend({},a,n),this._defaults=a,this._name=i,this.init()}var i="contentNavigationCarousel",a={autoplay:!0,autoplaySpeed:1e4,mouseEvent:"click",switchSpeed:500,equalizeHeights:!0};n.prototype.init=function(){var n,i,a=this.options,o=t(this.element),s=o.find(".contentCollection"),u=0,h=s.find(".contentItem"),c=0,r=0,l=h.find(".contentLink"),p=t("<div />",{"class":"contentNavigation"}),d=0,f=0,m=-1,g=0,v=o.attr("data-autoplay"),y={start:function(){this.timer=setTimeout(t.proxy(this.pause,this),a.autoplaySpeed)},pause:function(){this.interval=e.setInterval(t.proxy(this.checkMouseLocation,this),500)},checkMouseLocation:function(){"on"!==n.eq(m).find("a").data("mouse")&&(clearInterval(this.interval),this.getNextItem())},getNextItem:function(){g=g===f-1?0:g+1,x(g)},stop:function(){clearTimeout(this.timer)}},x=function(t){n.eq(t).find("a").trigger(a.mouseEvent,["triggered"])},q=function(e,o){a.autoplay&&y.stop(),"click"===a.mouseEvent&&e.preventDefault(),i=t(this),"triggered"===o&&i.data("mouse","off"),g=i.data("index"),n.removeClass("active"),n.eq(g).addClass("active"),g!==m&&(h.eq(m).fadeOut(a.switchSpeed/2,function(){h.eq(g).fadeIn(a.switchSpeed/2)}),m=g),a.autoplay&&y.start()};v&&(v>0?(a.autoplay=!0,a.autoplaySpeed=v):(a.autoplay=!1,a.autoplaySpeed=0)),l.length<=1||("hover"===a.mouseEvent&&(a.mouseEvent="mouseenter"),n=t.map(l,function(t,e){return f++,'<li><a href="'+t.href+'" data-index="'+e+'">'+(t.textContent||t.innerText)+"</a></li>"}),n=t(n.join("")),p.append(t("<ul>").append(n)).insertAfter(s),d=p.height(),u=Math.max.apply(null,h.map(function(){return t(this).height()}).get()),"hidden"===s.css("overflow")&&s.height(u),a.equalizeHeights&&(d>u?s.height(d):p.height(u)),h.each(function(){c=t(this).height(),r=Math.round((d-c)/2),t(this).css({display:"none",top:r+"px"})}),n.on({mouseenter:function(){t(this).data("mouse","on")},mouseleave:function(){t(this).data("mouse","off")}},"a"),n.on(a.mouseEvent,"a",q),x(g))},t.fn[i]=function(e){return this.each(function(){t.data(this,"plugin_"+i)||t.data(this,"plugin_"+i,new n(this,e))})}}(jQuery,window);
//# sourceMappingURL=contentNavigationCarousel.min.js.map