campagne-adhesion-2015-www/javascripts/carousel.js

23 lines
2.5 KiB
JavaScript

/*
@licstart The following is the entire license notice for the JavaScript code in this page.
simple carousel, easily add a carousel on your web pages
Copyright (C) 2013 acoeuro
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
@licend The above is the entire license notice for the JavaScript code in this page.
*/
(function(){var e,t,n,a;n=document.documentElement.style,e=void 0!==n.webkitTransition||void 0!==n.MozTransition||void 0!==n.OTransition||void 0!==n.MsTransition||void 0!==n.transition,jQuery(function(){return $(".simpleCarousel").each(function(){var e,n;return(e=$(this)).data("slideIndex",0).data("delay",null!=(n=e.data("delay"))?n:5e3).append(e.children().first().clone()).wrap('<div class="simpleCarouselViewport" />').parent().before($('<span class="prev">&lt</span>').click(function(){return t(e,-1)})).after($('<span class="next">&gt</span>').click(function(){return t(e,1)})).children().click(function(n){return 0===$(n.target).closest("a, pre, code").size()?t(e,1):void 0}),e.contents().filter(function(){return 3===this.nodeType}).remove(),a(e)})}),a=function(e){return e.data("delay")>0?e.data("timeOut",setTimeout(function(){return t(e)},e.data("delay"))):void 0},t=function(n,i){var r,d;if(null==i&&(i=0),0===i){if(n.parent().is(":hover")||n.parent().prev().is(":hover")||n.parent().next().is(":hover"))return void a(n);i=1}else clearTimeout(n.data("timeOut"));return n.data("slideIndex",n.data("slideIndex")+i),0<=(d=n.data("slideIndex"))&&d<n.children().size()?(r=""+-100*n.data("slideIndex")+"%",e?n.addClass("animate").css("margin-left",r):(n.parent().width(n.parent().parent().width()),n.animate({marginLeft:-1*n.data("slideIndex")*n.width()})),a(n)):(i>0?n.data("slideIndex",0):n.data("slideIndex",n.children().size()-1),n.removeClass("animate").css("margin-left",""+-100*n.data("slideIndex")+"%",function(){}),n.css("marginLeft"),t(n,i))}}).call(this);