* @license MIT license: github.com/shower/shower/wiki/MIT-License
* @license MIT license: github.com/shower/shower/wiki/MIT-License
*/
*/
window.shower=window.shower||function(a,b,c){functiond(a){for(varbina)a.hasOwnProperty(b)&&(this[b]=a[b])}vare,f={},g=a.location,h=b.body,i=[],j=[],k=!(!a.history||!a.history.pushState);returnd.prototype={getSlideNumber:function(){returnthis.number},isLast:function(){returnf.slideList.length===this.number+1},isFinished:function(){returnthis.innerComplete>=this.innerLength},process:function(a){returnthis.timing?(this.initTimer(a),this):(this.next(a),this)},initTimer:function(a){varb=this;returnb.timing?(b.stopTimer(),e=b.isFinished()?setInterval(function(){b.stopTimer(),a.next()},b.timing*(b.innerLength||1)):setInterval(function(){b.isFinished()?(b.stopTimer(),a.next()):b.next(a)},b.timing),this):!1},stopTimer:function(){returne&&(clearInterval(e),e=!1),this},prev:function(a){varc,d=this;return!d.hasInnerNavigation||d.isFinished()||0===d.innerComplete?(a.prev(),!1):(c=b.getElementById(d.id).querySelectorAll(".next.active"),!c||c.length<1?!1:(d.innerComplete>0?(d.innerComplete--,c[c.length-1].classList.remove("active")):a.prev(),this))},next:function(a){varc,d=this;return!d.hasInnerNavigation||d.isFinished()?(a.next(),!1):(d.isFinished()||(c=b.getElementById(d.id).querySelectorAll(".next:not(.active)"),c[0].classList.add("active"),d.innerComplete++),this)}},f._getData=function(a,b){returna.dataset?a.dataset[b]:a.getAttribute("data-"+b)},f.slideList=[],f.init=function(a,c){vare;a=a||".slide",c=c||"div.progress div",i=b.querySelectorAll(a),j=b.querySelector(c);for(varg=0;g<i.length;g++)i[g].id||(i[g].id=g+1),e=f._getData(i[g],"timing"),e&&/^(\d{1,2}:)?\d{1,3}$/.test(e)?(-1!==e.indexOf(":")?(e=e.split(":"),e=1e3*(60*parseInt(e[0],10)+parseInt(e[1],10))):e=1e3*parseInt(e,10),0===e&&(e=!1)):e=!1,f.slideList.push(newd({id:i[g].id,number:g,hasInnerNavigation:null!==i[g].querySelector(".next"),timing:e,innerLength:i[g].querySelectorAll(".next").length,innerComplete:0}));returnf},f._getTransform=function(){varb=Math.max(h.clientWidth/a.innerWidth,h.clientHeight/a.innerHeight);return"scale("+1/b+")"},f._applyTransform=function(a){return["WebkitTransform","MozTransform","msTransform","OTransform","transform"].forEach(function(b){h.style[b]=a}),!0},f._isNumber=function(a){return!isNaN(parseFloat(a))&&isFinite(a)},f._normalizeSlideNumber=function(a){if(!f._isNumber(a))thrownewError("Gimme slide number as Number, baby!");return0>a&&(a=0),a>=f.slideList.length&&(a=f.slideList.length-1),a},f._getSlideIdByEl=function(a){for(;"BODY"!==a.nodeName&&"HTML"!==a.nodeName;){if(a.classList.contains("slide"))returna.id;a=a.parentNode}return""},f._checkInteractiveElement=function(a){return"A"===a.target.nodeName},f.getSlideNumber=function(a){varb,c=f.slideList.length-1;for(""===a&&(b=0);c>=0;--c)if(a===f.slideList[c].id){b=c;break}returnb},f.go=function(a,b){varc;if(!f._isNumber(a))thrownewError("Gimme slide number as Number, baby!");returnf.slideList[a]?(g.hash=f.getSlideHash(a),f.updateProgress(a),f.updateActiveAndVisitedSlides(a),f.isSlideMode()&&(f.showPresenterNotes(a),c=f.slideList[a],c.timing&&c.initTimer(f)),"function"==typeofb&&b(),a):!1},f.next=function(a){varb=f.getCurrentSlideNumber(),c=f.slideList[b+1];returnc?(f.go(b+1),"function"==typeofa&&a(),this):!1},f._turnNextSlide=function(a){varb=f.getCurrentSlideNumber(),c=f.slideList[b];f.isSlideMode()?(c.stopTimer(),c.next(f)):f.go(b+1),"function"==typeofa&&a()},f.prev=f.previous=function(a){varb=f.getCurrentSlideNumber();return1>b?!1:(f.go(b-1),"function"==typeofa&&a(),!0)},f._turnPreviousSlide=function(a){varb=f.getCurrentSlideNumber(),c=f.slideList[b];returnc.stopTimer(),f.isSlideMode()?c.prev(f):f.go(b-1),"function"==typeofa&&a(),!0},f.first=function(a){varb=f.slideList[f.getCurrentSlideNumber()];b.timing&&b.stopTimer(),f.go(0),"function"==typeofa&&a()},f.last=function(a){varb=f.slideList[f.getCurrentSlideNumber()];b.timing&&b.stopTimer(),f.go(f.slideList.length-1),"function"==typeofa&&a()},f.enterSlideMode=function(a){varb=f.getCurrentSlideNumber();returnh.classList.remove("list"),h.classList.add("full"),f.isListMode()&&k&&history.pushState(null,null,g.pathname+"?full"+f.getSlideHash(b)),f._applyTransform(f._getTransform()),"function"==typeofa&&a(),!0},f.enterListMode=function(a){varb;returnh.classList.remove("full"),h.classList.add("list"),f.clearPresenterNotes(),f.isListMode()?!1:(b=f.getCurrentSlideNumber(),f.slideList[b].stopTimer(),f.isSlideMode()&&k&&history.pushState(null,null,g.pathname+f.getSlideHash(b)),f.scrollToSlide(b),f._applyTransform("none"),"function"==typeofa&&a(),!0)},f.toggleMode=function(a){returnf.isListMode()?f.enterSlideMode():f.enterListMode(),"function"==typeofa&&a(),!0},f.getCurrentSlideNumber=function(){for(vara=f.slideList.length-1,b=g.hash.substr(1);a>=0;--a)if(b===f.slideList[a].id)returna;return-1},f.scrollToSlide=function(c){vard,e=!1;if(!f._isNumber(c))thrownewError("Gimme slide number as Number, baby!");if(f.isSlideMode())thrownewError("You can't scroll to because you in slide mode. Please, switch to list mode.");if(-1===c)returne;if(!f.slideList[c])thrownewError("There is no slide with number "+c);returnd=b.getElementById(f.slideList[c].id),a.scrollTo(0,d.offsetTop),e=!0,e},f.isListMode=function(){returnk?!/^full.*/.test(g.search.substr(1)):h.classList.contains("list")},f.isSlideMode=function(){returnk?/^full.*/.test(g.search.substr(1)):h.classList.contains("full")},f.updateProgress=function(a){if(null===j)return!1;if(!f._isNumber(a))thrownewError("Gimme slide number as Number, baby!");returnj.style.width=(100/(f.slideList.length-1)*f._normalizeSlideNumber(a)).toFixed(2)+"%",!0},f.updateActiveAndVisitedSlides=function(a){varc,d,e=f.slideList.length;if(a=f._normalizeSlideNumber(a),!f._isNumber(a))thrownewError("Gimme slide number as Number, baby!");for(c=0;e>c;++c)d=b.getElementById(f.slideList[c].id),a>c?(d.classList.remove("active"),d.classList.add("visited")):c>a?(d.classList.remove("visited"),d.classList.remove("active")):(d.classList.remove("visited"),d.classList.add("active"));return!0},f.clearPresenterNotes=function(){f.isSlideMode()&&a.console&&a.console.clear&&console.clear()},f.showPresenterNotes=function(c){if(f.clearPresenterNotes(),a.console){c=f._normalizeSlideNumber(c);vard=f.slideList[c].id,e=f.slideList[c+1]?f.slideList[c+1].id:null,g=b.getElementById(d).querySelector("footer");if(g&&g.innerHTML&&console.info(g.innerHTML.replace(/\n\s+/g,"\n")),e){varh=b.getElementById(e).querySelector("h2");h&&(h=h.innerHTML.replace(/^\s+|<[^>]+>/g,""),console.info("NEXT: "+h))}}},f.getSlideHash=function(a){if(!f._isNumber(a))thrownewError("Gimme slide number as Number, baby!");returna=f._normalizeSlideNumber(a),"#"+f.slideList[a].id},f.wheel=function(a){vard,e=b.querySelector("body"),g="locked"===e.getAttribute("data-scroll");g||f.isListMode()||(e.setAttribute("data-scroll","locked"),d=a.deltaY===c?a.wheelDeltaY<0:a.deltaY>0,d?f._turnNextSlide():f._turnPreviousSlide(),setTimeout(function(){e.setAttribute("data-scroll","unlocked")},200))},a.addEventListener("DOMContentLoaded",function(){(h.classList.contains("full")||f.isSlideMode())&&(f.go(f.getCurrentSlideNumber()),f.enterSlideMode())},!1),a.addEventListener("popstate",function(){f.isListMode()?f.enterListMode():f.enterSlideMode()},!1),a.addEventListener("resize",function(){f.isSlideMode()&&f._applyTransform(f._getTransform())},!1),b.addEventListener("keydown",function(a){varb,c=f.getCurrentSlideNumber(),d=f.slideList[-1!==c?c:0];switch(a.which){case80:f.isListMode()&&a.altKey&&a.metaKey&&(a.preventDefault(),b=d.number,f.go(b),f.enterSlideMode(),f.showPresenterNotes(b),d.timing&&d.initTimer(f));break;case116:a.preventDefault(),f.isListMode()?(b=a.shiftKey?d.number:0,f.go(b),f.enterSlideMode(),f.showPresenterNotes(b),d.timing&&d.initTimer(f)):f.enterListMode();break;case13:f.isListMode()&&-1!==c&&(a.preventDefault(),f.enterSlideMode(),f.showPresenterNotes(c),d.timing&&d.initTimer(f));break;case27:f.isSlideMode()&&(a.preventDefault(),f.enterListMode());break;case33:case38:case37:case72:case75:if(a.altKey||a.ctrlKey||a.metaKey)return;a.preventDefault(),f._turnPreviousSlide();break;case34:case40:case39:case76:case74:if(a.altKey||a.ctrlKey||a.metaKey)return;a.preventDefault(),f._turnNextSlide();break;case36:a.preventDefault(),f.first();break;case35:a.preventDefault(),f.last();break;case9:case32:a.preventDefault(),f[a.shiftKey?"_turnPreviousSlide":"_turnNextSlide"]()}},!1),f.init(),b.addEventListener("click",function(a){varb,c,d=f._getSlideIdByEl(a.target);d&&f.isListMode()&&(b=f.getSlideNumber(d),f.go(b),f.enterSlideMode(),f.showPresenterNotes(b),c=f.slideList[b],c.timing&&c.initTimer(f))},!1),b.addEventListener("touchstart",function(b){varc,d,e,g=f._getSlideIdByEl(b.target);g&&(f.isSlideMode()&&!f._checkInteractiveElement(b)&&(e=b.touches[0].pageX,e>a.innerWidth/2?f._turnNextSlide():f._turnPreviousSlide()),f.isListMode()&&(c=f.getSlideNumber(g),f.go(c),f.enterSlideMode(),f.showPresenterNotes(c),d=f.slideList[c],d.timing&&d.initTimer(f)))},!1),b.addEventListener("touchmove",function(a){f.isSlideMode()&&a.preventDefault()},!1),b.addEventListener("wheel",f.wheel,!1),b.addEventListener("mousewheel",f.wheel,!1),f}(this,this.document);
window.shower=window.shower||function(a,b,c){functiond(a){for(varbina)a.hasOwnProperty(b)&&(this[b]=a[b])}vare,f={},g=a.location,h=b.body,i=[],j=[],k=!(!a.history||!a.history.pushState);returnd.prototype={getSlideNumber:function(){returnthis.number},isLast:function(){returnf.slideList.length===this.number+1},isFinished:function(){returnthis.innerComplete>=this.innerLength},process:function(a){returnthis.timing?(this.initTimer(a),this):(this.next(a),this)},initTimer:function(a){varb=this;returnb.timing?(b.stopTimer(),e=b.isFinished()?setInterval(function(){b.stopTimer(),a.next()},b.timing*(b.innerLength||1)):setInterval(function(){b.isFinished()?(b.stopTimer(),a.next()):b.next(a)},b.timing),this):!1},stopTimer:function(){returne&&(clearInterval(e),e=!1),this},prev:function(a){varc,d=this;return!d.hasInnerNavigation||d.isFinished()||0===d.innerComplete?(a.prev(),!1):(c=b.getElementById(d.id).querySelectorAll(".next.active"),!c||c.length<1?!1:(d.innerComplete>0?(d.innerComplete--,c[c.length-1].classList.remove("active")):a.prev(),this))},next:function(a){varc,d=this;return!d.hasInnerNavigation||d.isFinished()?(a.next(),!1):(d.isFinished()||(c=b.getElementById(d.id).querySelectorAll(".next:not(.active)"),c[0].classList.add("active"),d.innerComplete++),this)}},f._getData=function(a,b){returna.dataset?a.dataset[b]:a.getAttribute("data-"+b)},f.slideList=[],f.init=function(a,c){vare;a=a||".slide",c=c||"div.progress div",i=b.querySelectorAll(a),j=b.querySelector(c);for(varg=0;g<i.length;g++)i[g].id||(i[g].id=g+1),e=f._getData(i[g],"timing"),e&&/^(\d{1,2}:)?\d{1,3}$/.test(e)?(-1!==e.indexOf(":")?(e=e.split(":"),e=1e3*(60*parseInt(e[0],10)+parseInt(e[1],10))):e=1e3*parseInt(e,10),0===e&&(e=!1)):e=!1,f.slideList.push(newd({id:i[g].id,number:g,hasInnerNavigation:null!==i[g].querySelector(".next"),timing:e,innerLength:i[g].querySelectorAll(".next").length,innerComplete:0}));returnf},f._getTransform=function(){varb=Math.max(h.clientWidth/a.innerWidth,h.clientHeight/a.innerHeight);return"scale("+1/b+")"},f._applyTransform=function(a){return["WebkitTransform","MozTransform","msTransform","OTransform","transform"].forEach(function(b){h.style[b]=a}),!0},f._isNumber=function(a){return!isNaN(parseFloat(a))&&isFinite(a)},f._normalizeSlideNumber=function(a){if(!f._isNumber(a))thrownewError("Gimme slide number as Number, baby!");return0>a&&(a=0),a>=f.slideList.length&&(a=f.slideList.length-1),a},f._getSlideIdByEl=function(a){for(;"BODY"!==a.nodeName&&"HTML"!==a.nodeName;){if(a.classList.contains("slide"))returna.id;a=a.parentNode}return""},f._checkInteractiveElement=function(a){return"A"===a.target.nodeName},f.getSlideNumber=function(a){varb,c=f.slideList.length-1;for(""===a&&(b=0);c>=0;--c)if(a===f.slideList[c].id){b=c;break}returnb},f.go=function(a,b){varc;if(!f._isNumber(a))thrownewError("Gimme slide number as Number, baby!");returnf.slideList[a]?(g.hash=f.getSlideHash(a),f.updateProgress(a),f.updateActiveAndVisitedSlides(a),f.isSlideMode()&&(f.showPresenterNotes(a),c=f.slideList[a],c.timing&&c.initTimer(f)),"function"==typeofb&&b(),a):!1},f.next=function(a){varb=f.getCurrentSlideNumber(),c=f.slideList[b+1];returnc?(f.go(b+1),"function"==typeofa&&a(),this):!1},f._turnNextSlide=function(a){varb=f.getCurrentSlideNumber(),c=f.slideList[b];f.isSlideMode()?(c.stopTimer(),c.next(f)):f.go(b+1),"function"==typeofa&&a()},f.prev=f.previous=function(a){varb=f.getCurrentSlideNumber();return1>b?!1:(f.go(b-1),"function"==typeofa&&a(),!0)},f._turnPreviousSlide=function(a){varb=f.getCurrentSlideNumber(),c=f.slideList[b];returnc.stopTimer(),f.isSlideMode()?c.prev(f):f.go(b-1),"function"==typeofa&&a(),!0},f.first=function(a){varb=f.slideList[f.getCurrentSlideNumber()];b.timing&&b.stopTimer(),f.go(0),"function"==typeofa&&a()},f.last=function(a){varb=f.slideList[f.getCurrentSlideNumber()];b.timing&&b.stopTimer(),f.go(f.slideList.length-1),"function"==typeofa&&a()},f.enterSlideMode=function(a){varb=f.getCurrentSlideNumber();returnh.classList.remove("list"),h.classList.add("full"),f.isListMode()&&k&&history.pushState(null,null,g.pathname+"?full"+f.getSlideHash(b)),f._applyTransform(f._getTransform()),"function"==typeofa&&a(),!0},f.enterListMode=function(a){varb;returnh.classList.remove("full"),h.classList.add("list"),f.clearPresenterNotes(),f.isListMode()?!1:(b=f.getCurrentSlideNumber(),f.slideList[b].stopTimer(),f.isSlideMode()&&k&&history.pushState(null,null,g.pathname+f.getSlideHash(b)),f.scrollToSlide(b),f._applyTransform("none"),"function"==typeofa&&a(),!0)},f.toggleMode=function(a){returnf.isListMode()?f.enterSlideMode():f.enterListMode(),"function"==typeofa&&a(),!0},f.getCurrentSlideNumber=function(){vara=f.slideList.length-1,b=g.hash.substr(1);if(""===b)return-1;for(;a>=0;--a)if(b===f.slideList[a].id)returna;return0},f.scrollToSlide=function(c){vard,e=!1;if(!f._isNumber(c))thrownewError("Gimme slide number as Number, baby!");if(f.isSlideMode())thrownewError("You can't scroll to because you in slide mode. Please, switch to list mode.");if(-1===c)returne;if(!f.slideList[c])thrownewError("There is no slide with number "+c);returnd=b.getElementById(f.slideList[c].id),a.scrollTo(0,d.offsetTop),e=!0,e},f.isListMode=function(){returnk?!/^full.*/.test(g.search.substr(1)):h.classList.contains("list")},f.isSlideMode=function(){returnk?/^full.*/.test(g.search.substr(1)):h.classList.contains("full")},f.updateProgress=function(a){if(null===j)return!1;if(!f._isNumber(a))thrownewError("Gimme slide number as Number, baby!");returnj.style.width=(100/(f.slideList.length-1)*f._normalizeSlideNumber(a)).toFixed(2)+"%",!0},f.updateActiveAndVisitedSlides=function(a){varc,d,e=f.slideList.length;if(a=f._normalizeSlideNumber(a),!f._isNumber(a))thrownewError("Gimme slide number as Number, baby!");for(c=0;e>c;++c)d=b.getElementById(f.slideList[c].id),a>c?(d.classList.remove("active"),d.classList.add("visited")):c>a?(d.classList.remove("visited"),d.classList.remove("active")):(d.classList.remove("visited"),d.classList.add("active"));return!0},f.clearPresenterNotes=function(){f.isSlideMode()&&a.console&&a.console.clear&&console.clear()},f.showPresenterNotes=function(c){if(f.clearPresenterNotes(),a.console){c=f._normalizeSlideNumber(c);vard=f.slideList[c].id,e=f.slideList[c+1]?f.slideList[c+1].id:null,g=b.getElementById(d).querySelector("footer");if(g&&g.innerHTML&&console.info(g.innerHTML.replace(/\n\s+/g,"\n")),e){varh=b.getElementById(e).querySelector("h2");h&&(h=h.innerHTML.replace(/^\s+|<[^>]+>/g,""),console.info("NEXT: "+h))}}},f.getSlideHash=function(a){if(!f._isNumber(a))thrownewError("Gimme slide number as Number, baby!");returna=f._normalizeSlideNumber(a),"#"+f.slideList[a].id},f.wheel=function(a){vard,e=b.querySelector("body"),g="locked"===e.getAttribute("data-scroll");g||f.isListMode()||(e.setAttribute("data-scroll","locked"),d=a.deltaY===c?a.wheelDeltaY<0:a.deltaY>0,d?f._turnNextSlide():f._turnPreviousSlide(),setTimeout(function(){e.setAttribute("data-scroll","unlocked")},200))},a.addEventListener("DOMContentLoaded",function(){vara=f.getCurrentSlideNumber(),b=h.classList.contains("full")||f.isSlideMode();-1===a&&b?f.go(0):(0===a||b)&&f.go(a),b&&f.enterSlideMode()},!1),a.addEventListener("popstate",function(){vara=f.getCurrentSlideNumber();-1!==a&&f.go(a),f.isListMode()?f.enterListMode():f.enterSlideMode()},!1),a.addEventListener("resize",function(){f.isSlideMode()&&f._applyTransform(f._getTransform())},!1),b.addEventListener("keydown",function(a){varb,c=f.getCurrentSlideNumber(),d=f.slideList[-1!==c?c:0];switch(a.which){case80:f.isListMode()&&a.altKey&&a.metaKey&&(a.preventDefault(),b=d.number,f.go(b),f.enterSlideMode(),f.showPresenterNotes(b),d.timing&&d.initTimer(f));break;case116:a.preventDefault(),f.isListMode()?(b=a.shiftKey?d.number:0,f.go(b),f.enterSlideMode(),f.showPresenterNotes(b),d.timing&&d.initTimer(f)):f.enterListMode();break;case13:f.isListMode()&&-1!==c&&(a.preventDefault(),f.enterSlideMode(),f.showPresenterNotes(c),d.timing&&d.initTimer(f));break;case27:f.isSlideMode()&&(a.preventDefault(),f.enterListMode());break;case33:case38:case37:case72:case75:if(a.altKey||a.ctrlKey||a.metaKey)return;a.preventDefault(),f._turnPreviousSlide();break;case34:case40:case39:case76:case74:if(a.altKey||a.ctrlKey||a.metaKey)return;a.preventDefault(),f._turnNextSlide();break;case36:a.preventDefault(),f.first();break;case35:a.preventDefault(),f.last();break;case9:case32:a.preventDefault(),f[a.shiftKey?"_turnPreviousSlide":"_turnNextSlide"]()}},!1),f.init(),b.addEventListener("click",function(a){varb,c,d=f._getSlideIdByEl(a.target);d&&f.isListMode()&&(b=f.getSlideNumber(d),f.go(b),f.enterSlideMode(),f.showPresenterNotes(b),c=f.slideList[b],c.timing&&c.initTimer(f))},!1),b.addEventListener("touchstart",function(b){varc,d,e,g=f._getSlideIdByEl(b.target);g&&(f.isSlideMode()&&!f._checkInteractiveElement(b)&&(e=b.touches[0].pageX,e>a.innerWidth/2?f._turnNextSlide():f._turnPreviousSlide()),f.isListMode()&&(c=f.getSlideNumber(g),f.go(c),f.enterSlideMode(),f.showPresenterNotes(c),d=f.slideList[c],d.timing&&d.initTimer(f)))},!1),b.addEventListener("touchmove",function(a){f.isSlideMode()&&a.preventDefault()},!1),b.addEventListener("wheel",f.wheel,!1),b.addEventListener("mousewheel",f.wheel,!1),f}(this,this.document);