2018-04-24 12:12:24 +00:00
|
|
|
!function(i){var t;window.UIkit2&&(t=i(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-slideshow",["uikit"],function(){return t||i(UIkit2)})}(function(i){"use strict";var t,s=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(t){i.$("[data-uk-slideshow]",t).each(function(){var t=i.$(this);t.data("slideshow")||i.slideshow(t,i.Utils.options(t.attr("data-uk-slideshow")))})})},init:function(){var t=this;this.container=this.element.hasClass("uk-slideshow")?this.element:i.$(this.find(".uk-slideshow:first")),this.current=this.options.start,this.animating=!1,this.fixFullscreen=navigator.userAgent.match(/(iPad|iPhone|iPod)/g)&&this.container.hasClass("uk-slideshow-fullscreen"),this.options.kenburns&&(this.kbanimduration=this.options.kenburns===!0?"15s":this.options.kenburns,String(this.kbanimduration).match(/(ms|s)$/)||(this.kbanimduration+="ms"),"string"==typeof this.options.kenburnsanimations&&(this.options.kenburnsanimations=this.options.kenburnsanimations.split(","))),this.update(),this.on("click.uk.slideshow","[data-uk-slideshow-item]",function(s){s.preventDefault();var e=i.$(this).attr("data-uk-slideshow-item");if(t.current!=e){switch(e){case"next":case"previous":t["next"==e?"next":"previous"]();break;default:t.show(parseInt(e,10))}t.stop()}}),i.$win.on("resize load",i.Utils.debounce(function(){t.resize(),t.fixFullscreen&&(t.container.css("height",window.innerHeight),t.slides.css("height",window.innerHeight))},100)),setTimeout(function(){t.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(){t.options.pauseOnHover&&(t.hovering=!0)},mouseleave:function(){t.hovering=!1}}),this.on("swipeRight swipeLeft",function(i){t["swipeLeft"==i.type?"next":"previous"]()}),this.on("display.uk.check",function(){t.element.is(":visible")&&(t.resize(),t.fixFullscreen&&(t.container.css("height",window.innerHeight),t.slides.css("height",window.innerHeight)))}),i.domObserve(this.element,function(){t.container.children(":not([data-slideshow-slide])").not(".uk-slideshow-ghost").length&&t.update(!0)})},update:function(t){var e,a=this,n=0;this.slides=this.container.children(),this.slidesCount=this.slides.length,this.slides.eq(this.current).length||(this.current=0),this.slides.each(function(t){var o=i.$(this);if(!o.data("processed")){var r=o.children("img,video,iframe").eq(0),d="html";if(o.data("media",r),o.data("sizer",r),r.length){var u;switch(d=r[0].nodeName.toLowerCase(),r[0].nodeName){case"IMG":var h=i.$('<div class="uk-cover-background uk-position-cover"></div>').css({"background-image":"url("+r.attr("src")+")"});r.attr("width")&&r.attr("height")&&(u=i.$("<canvas></canvas>").attr({width:r.attr("width"),height:r.attr("height")}),r.replaceWith(u),r=u,u=void 0),r.css({width:"100%",height:"auto",opacity:0}),o.prepend(h).data("cover",h);break;case"IFRAME":var c=r[0].src,l="sw-"+ ++s;r.attr("src","").on("load",function(){if((t!==a.current||t==a.current&&!a.options.videoautoplay)&&a.pausemedia(r),a.options.videomute){a.mutemedia(r);var i=setInterval(function(t){return function(){a.mutemedia(r),++t>=4&&clearInterval(i)}}(0),250)}}).data("slideshow",a).attr("data-player-id",l).attr("src",[c,c.indexOf("?")>-1?"&":"?","enablejsapi=1&api=1&player_id="+l].join("")).addClass("uk-position-absolute"),i.support.touch||r.css("pointer-events","none"),u=!0,i.cover&&(i.cover(r),r.attr("data-uk-cover","{}"));break;case"VIDEO":r.addClass("uk-cover-object uk-position-absolute"),u=!0,a.options.videomute&&a.mutemedia(r)}if(u){e=i.$("<canvas></canvas>").attr({wi
|