Component-Builder/admin/custom/uikit/js/components/slideshow.min.js

2 lines
8.9 KiB
JavaScript
Raw Normal View History

2016-01-30 20:28:43 +00:00
/*! UIkit 2.21.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
!function(i){var s;window.UIkit&&(s=i(UIkit)),"function"==typeof define&&define.amd&&define("uikit-slideshow",["uikit"],function(){return s||i(UIkit)})}(function(i){"use strict";var s,t=0;i.component("slideshow",{defaults:{animation:"fade",duration:500,height:"auto",start:0,autoplay:!1,autoplayInterval:7e3,videoautoplay:!0,videomute:!0,slices:15,pauseOnHover:!0,kenburns:!1,kenburnsanimations:["uk-animation-middle-left","uk-animation-top-right","uk-animation-bottom-left","uk-animation-top-center","","uk-animation-bottom-right"]},current:!1,interval:null,hovering:!1,boot:function(){i.ready(function(s){i.$("[data-uk-slideshow]",s).each(function(){var s=i.$(this);if(!s.data("slideshow")){i.slideshow(s,i.Utils.options(s.attr("data-uk-slideshow")))}})})},init:function(){var s,e,n=this;this.container=this.element.hasClass("uk-slideshow")?this.element:i.$(this.find(".uk-slideshow")),this.slides=this.container.children(),this.slidesCount=this.slides.length,this.current=this.options.start,this.animating=!1,this.triggers=this.find("[data-uk-slideshow-item]"),this.fixFullscreen=navigator.userAgent.match(/(iPad|iPhone|iPod)/g)&&this.container.hasClass("uk-slideshow-fullscreen"),this.options.kenburns&&(e=this.options.kenburns===!0?"15s":this.options.kenburns,String(e).match(/(ms|s)$/)||(e+="ms"),"string"==typeof this.options.kenburnsanimations&&(this.options.kenburnsanimations=this.options.kenburnsanimations.split(","))),this.slides.each(function(a){var o=i.$(this),r=o.children("img,video,iframe").eq(0);if(o.data("media",r),o.data("sizer",r),r.length){var d;switch(r[0].nodeName){case"IMG":var u=i.$('<div class="uk-cover-background uk-position-cover"></div>').css({"background-image":"url("+r.attr("src")+")"});r.css({width:"100%",height:"auto"}),o.prepend(u).data("cover",u);break;case"IFRAME":var h=r[0].src,c="sw-"+ ++t;r.attr("src","").on("load",function(){if((a!==n.current||a==n.current&&!n.options.videoautoplay)&&n.pausemedia(r),n.options.videomute){n.mutemedia(r);var i=setInterval(function(s){return function(){n.mutemedia(r),++s>=4&&clearInterval(i)}}(0),250)}}).data("slideshow",n).attr("data-player-id",c).attr("src",[h,h.indexOf("?")>-1?"&":"?","enablejsapi=1&api=1&player_id="+c].join("")).addClass("uk-position-absolute"),i.support.touch||r.css("pointer-events","none"),d=!0,i.cover&&(i.cover(r),r.attr("data-uk-cover","{}"));break;case"VIDEO":r.addClass("uk-cover-object uk-position-absolute"),d=!0,n.options.videomute&&n.mutemedia(r)}if(d){s=i.$("<canvas></canvas>").attr({width:r[0].width,height:r[0].height});var l=i.$('<img style="width:100%;height:auto;">').attr("src",s[0].toDataURL());o.prepend(l),o.data("sizer",l)}}else o.data("sizer",o);n.hasKenBurns(o)&&o.data("cover").css({"-webkit-animation-duration":e,"animation-duration":e})}),this.on("click.uikit.slideshow","[data-uk-slideshow-item]",function(s){s.preventDefault();var t=i.$(this).attr("data-uk-slideshow-item");if(n.current!=t){switch(t){case"next":case"previous":n["next"==t?"next":"previous"]();break;default:n.show(parseInt(t,10))}n.stop()}}),this.slides.attr("aria-hidden","true").eq(this.current).addClass("uk-active").attr("aria-hidden","false"),this.triggers.filter('[data-uk-slideshow-item="'+this.current+'"]').addClass("uk-active"),i.$win.on("resize load",i.Utils.debounce(function(){n.resize(),n.fixFullscreen&&(n.container.css("height",window.innerHeight),n.slides.css("height",window.innerHeight))},100)),setTimeout(function(){n.resize()},80),this.options.autoplay&&this.start(),this.options.videoautoplay&&this.slides.eq(this.current).data("media")&&this.playmedia(this.slides.eq(this.current).data("media")),this.options.kenburns&&this.applyKenBurns(this.slides.eq(this.current)),this.container.on({mouseenter:function(){n.options.pauseOnHover&&(n.hovering=!0)},mouseleave:function(){n.hovering=!1}}),this.on("swipeRight swipeLeft",function(i){n["swipeLeft"==i.type?"next":"previous"]()}),this.on("display.uk.check",function(){n.element.is(":visible")&&(n.resize(),n.fixFullscreen&&(n.container.css("height",window.innerHeight),n.slides.css("height",window.innerHeight)))})},resiz