aboutsummaryrefslogtreecommitdiffstats
path: root/uikit/static/js/components/slideshow.min.js
diff options
context:
space:
mode:
authorValentin Heinz <inktrap@users.noreply.github.com>2017-04-08 14:03:25 +0200
committerAlexis Metaireau <alexis@notmyidea.org>2017-04-08 14:03:25 +0200
commit5c231ceade17e7f5b1bba90e845dd2d17e54da1c (patch)
treef4f07dbbac2c51c8a0af1e1a24f11e030a2e4155 /uikit/static/js/components/slideshow.min.js
parent00986ab80df4b6be2d1306671907e2b2378e487f (diff)
downloadpelican-themes-5c231ceade17e7f5b1bba90e845dd2d17e54da1c.tar.gz
uikit demo theme ported to pelican (#385)
Diffstat (limited to 'uikit/static/js/components/slideshow.min.js')
-rw-r--r--uikit/static/js/components/slideshow.min.js2
1 files changed, 2 insertions, 0 deletions
diff --git a/uikit/static/js/components/slideshow.min.js b/uikit/static/js/components/slideshow.min.js
new file mode 100644
index 0000000..e7af4f0
--- /dev/null
+++ b/uikit/static/js/components/slideshow.min.js
@@ -0,0 +1,2 @@
+/*! 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)))})},resize:function(){if(!this.container.hasClass("uk-slideshow-fullscreen")){var s=this.options.height;"auto"===this.options.height&&(s=0,this.slides.css("height","").each(function(){s=Math.max(s,i.$(this).height())})),this.container.css("height",s),this.slides.css("height",s)}},show:function(t,e){if(!this.animating&&this.current!=t){this.animating=!0;var n=this,a=this.slides.eq(this.current),o=this.slides.eq(t),r=e?e:this.current<t?-1:1,d=a.data("media"),u=s[this.options.animation]?this.options.animation:"fade",h=o.data("media"),c=function(){n.animating&&(d&&d.is("video,iframe")&&n.pausemedia(d),h&&h.is("video,iframe")&&n.playmedia(h),o.addClass("uk-active").attr("aria-hidden","false"),a.removeClass("uk-active").attr("aria-hidden","true"),n.animating=!1,n.current=t,i.Utils.checkDisplay(o,'[class*="uk-animation-"]:not(.uk-cover-background.uk-position-cover)'),n.trigger("show.uk.slideshow",[o]))};n.applyKenBurns(o),i.support.animation||(u="none"),a=i.$(a),o=i.$(o),s[u].apply(this,[a,o,r]).then(c),n.triggers.removeClass("uk-active"),n.triggers.filter('[data-uk-slideshow-item="'+t+'"]').addClass("uk-active")}},applyKenBurns:function(i){if(this.hasKenBurns(i)){var s=this.options.kenburnsanimations,t=this.kbindex||0;i.data("cover").attr("class","uk-cover-background uk-position-cover").width(),i.data("cover").addClass(["uk-animation-scale","uk-animation-reverse",s[t].trim()].join(" ")),this.kbindex=s[t+1]?t+1:0}},hasKenBurns:function(i){return this.options.kenburns&&i.data("cover")},next:function(){this.show(this.slides[this.current+1]?this.current+1:0)},previous:function(){this.show(this.slides[this.current-1]?this.current-1:this.slides.length-1)},start:function(){this.stop();var i=this;this.interval=setInterval(function(){i.hovering||i.next()},this.options.autoplayInterval)},stop:function(){this.interval&&clearInterval(this.interval)},playmedia:function(i){if(i&&i[0])switch(i[0].nodeName){case"VIDEO":this.options.videomute||(i[0].muted=!1),i[0].play();break;case"IFRAME":this.options.videomute||i[0].contentWindow.postMessage('{ "event": "command", "func": "unmute", "method":"setVolume", "value":1}',"*"),i[0].contentWindow.postMessage('{ "event": "command", "func": "playVideo", "method":"play"}',"*")}},pausemedia:function(i){switch(i[0].nodeName){case"VIDEO":i[0].pause();break;case"IFRAME":i[0].contentWindow.postMessage('{ "event": "command", "func": "pauseVideo", "method":"pause"}',"*")}},mutemedia:function(i){switch(i[0].nodeName){case"VIDEO":i[0].muted=!0;break;case"IFRAME":i[0].contentWindow.postMessage('{ "event": "command", "func": "mute", "method":"setVolume", "value":0}',"*")}}}),s={none:function(){var s=i.$.Deferred();return s.resolve(),s.promise()},scroll:function(s,t,e){var n=i.$.Deferred();return s.css("animation-duration",this.options.duration+"ms"),t.css("animation-duration",this.options.duration+"ms"),t.css("opacity",1).one(i.support.animation.end,function(){s.removeClass(1===e?"uk-slideshow-scroll-backward-out":"uk-slideshow-scroll-forward-out"),t.css("opacity","").removeClass(1===e?"uk-slideshow-scroll-backward-in":"uk-slideshow-scroll-forward-in"),n.resolve()}.bind(this)),s.addClass(1==e?"uk-slideshow-scroll-backward-out":"uk-slideshow-scroll-forward-out"),t.addClass(1==e?"uk-slideshow-scroll-backward-in":"uk-slideshow-scroll-forward-in"),t.width(),n.promise()},swipe:function(s,t,e){var n=i.$.Deferred();return s.css("animation-duration",this.options.duration+"ms"),t.css("animation-duration",this.options.duration+"ms"),t.css("opacity",1).one(i.support.animation.end,function(){s.removeClass(1===e?"uk-slideshow-swipe-backward-out":"uk-slideshow-swipe-forward-out"),t.css("opacity","").removeClass(1===e?"uk-slideshow-swipe-backward-in":"uk-slideshow-swipe-forward-in"),n.resolve()}.bind(this)),s.addClass(1==e?"uk-slideshow-swipe-backward-out":"uk-slideshow-swipe-forward-out"),t.addClass(1==e?"uk-slideshow-swipe-backward-in":"uk-slideshow-swipe-forward-in"),t.width(),n.promise()},scale:function(s,t){var e=i.$.Deferred();return s.css("animation-duration",this.options.duration+"ms"),t.css("animation-duration",this.options.duration+"ms"),t.css("opacity",1),s.one(i.support.animation.end,function(){s.removeClass("uk-slideshow-scale-out"),t.css("opacity",""),e.resolve()}.bind(this)),s.addClass("uk-slideshow-scale-out"),s.width(),e.promise()},fade:function(s,t){var e=i.$.Deferred();return s.css("animation-duration",this.options.duration+"ms"),t.css("animation-duration",this.options.duration+"ms"),t.css("opacity",1),s.one(i.support.animation.end,function(){s.removeClass("uk-slideshow-fade-out"),t.css("opacity",""),e.resolve()}.bind(this)),s.addClass("uk-slideshow-fade-out"),s.width(),e.promise()}},i.slideshow.animations=s,window.addEventListener("message",function(s){var t,e=s.data;if("string"==typeof e)try{e=JSON.parse(e)}catch(n){e={}}s.origin&&s.origin.indexOf("vimeo")>-1&&"ready"==e.event&&e.player_id&&(t=i.$('[data-player-id="'+e.player_id+'"]'),t.length&&t.data("slideshow").mutemedia(t))},!1)}); \ No newline at end of file