* @license MIT license: github.com/shower/shower/wiki/MIT-License
*/
window.shower=window.shower||function(e,t,i){varr={},n=e.location,s=t.body,l=[],o=[],a,u=!!(e.history&&e.history.pushState);functiond(e){for(vartine){if(e.hasOwnProperty(t)){this[t]=e[t]}}}d.prototype={getSlideNumber:function(){returnthis.number},isLast:function(){returnr.slideList.length===this.number+1},isFinished:function(){returnthis.innerComplete>=this.innerLength},process:function(e){if(this.timing){this.initTimer(e);returnthis}this.next(e);returnthis},initTimer:function(e){vart=this;if(!t.timing){returnfalse}t.stopTimer();if(t.isFinished()){a=setInterval(function(){t.stopTimer();e.next()},t.timing*(t.innerLength||1))}else{a=setInterval(function(){if(t.isFinished()){t.stopTimer();e.next()}else{t.next(e)}},t.timing)}returnthis},stopTimer:function(){if(a){clearInterval(a);a=false}returnthis},prev:function(e){vari,r=this;if(!r.hasInnerNavigation||r.isFinished()||r.innerComplete===0){e.prev();returnfalse}i=t.getElementById(r.id).querySelectorAll(".next.active");if(!i||i.length<1){returnfalse}if(r.innerComplete>0){r.innerComplete--;i[i.length-1].classList.remove("active")}else{e.prev()}returnthis},next:function(e){vari,r=this;if(!r.hasInnerNavigation||r.isFinished()){e.next();returnfalse}if(!r.isFinished()){i=t.getElementById(r.id).querySelectorAll(".next:not(.active)");i[0].classList.add("active");r.innerComplete++}returnthis}};r._getData=function(e,t){returne.dataset?e.dataset[t]:e.getAttribute("data-"+t)};r.slideList=[];r.init=function(e,i){varn;e=e||".slide";i=i||"div.progress div";l=t.querySelectorAll(e);o=t.querySelector(i);for(vars=0;s<l.length;s++){if(!l[s].id){l[s].id=s+1}n=r._getData(l[s],"timing");if(n&&/^(\d{1,2}:)?\d{1,3}$/.test(n)){if(n.indexOf(":")!==-1){n=n.split(":");n=(parseInt(n[0],10)*60+parseInt(n[1],10))*1e3}else{n=parseInt(n,10)*1e3}if(n===0){n=false}}else{n=false}r.slideList.push(newd({id:l[s].id,number:s,hasInnerNavigation:null!==l[s].querySelector(".next"),timing:n,innerLength:l[s].querySelectorAll(".next").length,innerComplete:0}))}returnr};r._getTransform=function(){vart=Math.max(s.clientWidth/e.innerWidth,s.clientHeight/e.innerHeight);return"scale("+1/t+")"};r._applyTransform=function(e){["WebkitTransform","MozTransform","msTransform","OTransform","transform"].forEach(function(t){s.style[t]=e});returntrue};r._isNumber=function(e){return!isNaN(parseFloat(e))&&isFinite(e)};r._normalizeSlideNumber=function(e){if(!r._isNumber(e)){thrownewError("Gimme slide number as Number, baby!")}if(e<0){e=0}if(e>=r.slideList.length){e=r.slideList.length-1}returne};r._getSlideIdByEl=function(e){while("BODY"!==e.nodeName&&"HTML"!==e.nodeName){if(e.classList.contains("slide")){returne.id}else{e=e.parentNode}}return""};r._checkInteractiveElement=function(e){return"A"===e.target.nodeName};r.getSlideNumber=function(e){vart=r.slideList.length-1,i;if(e===""){i=0}for(;t>=0;--t){if(e===r.slideList[t].id){i=t;break}}returni};r.go=function(e,t){vari;if(!r._isNumber(e)){thrownewError("Gimme slide number as Number, baby!")}if(!r.slideList[e]){returnfalse}n.hash=r.getSlideHash(e);r.updateProgress(e);r.updateActiveAndVisitedSlides(e);if(r.isSlideMode()){r.showPresenterNotes(e);i=r.slideList[e];if(i.timing){i.initTimer(r)}}if(typeoft==="function"){t()}returne};r.next=function(e){vart=r.getCurrentSlideNumber(),i=r.slideList[t+1];if(!i){returnfalse}r.go(t+1);if(typeofe==="function"){e()}returnthis};r._turnNextSlide=function(e){vart=r.getCurrentSlideNumber(),i=r.slideList[t];if(r.isSlideMode()){i.stopTimer();i.next(r)}else{r.go(t+1)}if(typeofe==="function"){e()}return};r.prev=r.previous=function(e){vart=r.getCurrentSlideNumber();if(t<1){returnfalse}r.go(t-1);if(typeofe==="function"){e()}returntrue};r._turnPreviousSlide=function(e){vart=r.getCurrentSlideNumber(),i=r.slideList[t];i.stopTimer();if(r.isSlideMode()){i.prev(r)}else{r.go(t-1)}if(typeofe==="function"){e()}returntrue};r.first=function(e){vart=r.slideList[r.getCurrentSlideNumber()];t.timing&&t.stopTimer();r.go(0);if(typeofe==="function"){e()}};r.last=function(e){vart=r.slideList[r.getCurrentSlideNumber()];t.timing&&t.stopTimer();r.go(r.slideList.length-1);if(typeofe==="function"){e()}};r.enterSlideMode=function(e){vart=r.getCurrentSlideNumber();s.classList.remove("list");s.classList.add("full");if(r.isListMode()&&u){history.pushState(null,null,n.pathname+"?full"+r.getSlideHash(t))}r._applyTransform(r._getTransform());if(typeofe==="function"){e()}returntrue};r.enterListMode=function(e){vart;s.classList.remove("full");s.classList.add("list");r.clearPresenterNotes();if(r.isListMode()){returnfalse}t=r.getCurrentSlideNumber();r.slideList[t].stopTimer();if(r.isSlideMode()&&u){history.pushState(null,null,n.pathname+r.getSlideHash(t))}r.scrollToSlide(t);r._applyTransform("none");if(typeofe==="function"){e()}returntrue};r.toggleMode=function(e){if(r.isListMode()){r.enterSlideMode()}else{r.enterListMode()}if(typeofe==="function"){e()}returntrue};r.getCurrentSlideNumber=function(){vare=r.slideList.length-1,t=n.hash.substr(1);for(;e>=0;--e){if(t===r.slideList[e].id){returne}}return-1};r.scrollToSlide=function(i){varn,s=false;if(!r._isNumber(i)){thrownewError("Gimme slide number as Number, baby!")}if(r.isSlideMode()){thrownewError("You can't scroll to because you in slide mode. Please, switch to list mode.")}if(-1===i){returns}if(r.slideList[i]){n=t.getElementById(r.slideList[i].id);e.scrollTo(0,n.offsetTop);s=true}else{thrownewError("There is no slide with number "+i)}returns};r.isListMode=function(){returnu?!/^full.*/.test(n.search.substr(1)):s.classList.contains("list")};r.isSlideMode=function(){returnu?/^full.*/.test(n.search.substr(1)):s.classList.contains("full")};r.updateProgress=function(e){if(null===o){returnfalse}if(!r._isNumber(e)){thrownewError("Gimme slide number as Number, baby!")}o.style.width=(100/(r.slideList.length-1)*r._normalizeSlideNumber(e)).toFixed(2)+"%";returntrue};r.updateActiveAndVisitedSlides=function(e){vari,n,s=r.slideList.length;e=r._normalizeSlideNumber(e);if(!r._isNumber(e)){thrownewError("Gimme slide number as Number, baby!")}for(i=0;i<s;++i){n=t.getElementById(r.slideList[i].id);if(i<e){n.classList.remove("active");n.classList.add("visited")}elseif(i>e){n.classList.remove("visited");n.classList.remove("active")}else{n.classList.remove("visited");n.classList.add("active")}}returntrue};r.clearPresenterNotes=function(){if(e.console&&e.console.clear){console.clear()}};r.showPresenterNotes=function(i){r.clearPresenterNotes();if(e.console){i=r._normalizeSlideNumber(i);varn=r.slideList[i].id,s=r.slideList[i+1]?r.slideList[i+1].id:null,l=t.getElementById(n).querySelector("footer");if(l&&l.innerHTML){console.info(l.innerHTML.replace(/\n\s+/g,"\n"))}if(s){varo=t.getElementById(s).querySelector("h2");if(o){o=o.innerHTML.replace(/^\s+|<[^>]+>/g,"");console.info("NEXT: "+o)}}}};r.getSlideHash=function(e){if(!r._isNumber(e)){thrownewError("Gimme slide number as Number, baby!")}e=r._normalizeSlideNumber(e);return"#"+r.slideList[e].id};e.addEventListener("DOMContentLoaded",function(){if(s.classList.contains("full")||r.isSlideMode()){r.go(r.getCurrentSlideNumber());r.enterSlideMode()}},false);e.addEventListener("popstate",function(){if(r.isListMode()){r.enterListMode()}else{r.enterSlideMode()}},false);e.addEventListener("resize",function(){if(r.isSlideMode()){r._applyTransform(r._getTransform())}},false);t.addEventListener("keydown",function(e){vart,i;if(e.altKey||e.ctrlKey||e.metaKey){return}t=r.getCurrentSlideNumber();i=r.slideList[t];switch(e.which){case116:e.preventDefault();if(r.isListMode()){varn=e.shiftKey?t:0,i;r.go(n);r.enterSlideMode();r.showPresenterNotes(n);i=r.slideList[t];i.timing&&i.initTimer(r)}else{r.enterListMode()}break;case13:if(r.isListMode()&&-1!==t){e.preventDefault();r.enterSlideMode();r.showPresenterNotes(t);if(i.timing){i.initTimer(r)}}break;case27:if(r.isSlideMode()){e.preventDefault();r.enterListMode()}break;case33:case38:case37:case72:case75:e.preventDefault();r._turnPreviousSlide();break;case34:case40:case39:case76:case74:e.preventDefault();r._turnNextSlide();break;case36:e.preventDefault();r.first();break;case35:e.preventDefault();r.last();break;case9:case32:e.preventDefault();r[e.shiftKey?"_turnPreviousSlide":"_turnNextSlide"]();break;default:}},false);r.init();t.addEventListener("click",function(e){vart=r.getSlideNumber(r._getSlideIdByEl(e.target)),i;if(r.isListMode()&&r._getSlideIdByEl(e.target)){r.go(t);r.enterSlideMode();r.showPresenterNotes(t);i=r.slideList[t];if(i.timing){i.initTimer(r)}}},false);t.addEventListener("touchstart",function(t){vari=r.getSlideNumber(r._getSlideIdByEl(t.target)),n,s;if(r._getSlideIdByEl(t.target)){if(r.isSlideMode()&&!r._checkInteractiveElement(t)){s=t.touches[0].pageX;if(s>e.innerWidth/2){r._turnNextSlide()}else{r._turnPreviousSlide()}}if(r.isListMode()){r.go(r.getSlideNumber(r._getSlideIdByEl(t.target)));r.enterSlideMode();r.showPresenterNotes(i);n=r.slideList[i];if(n.timing){n.initTimer(r)}}}},false);t.addEventListener("touchmove",function(e){if(r.isSlideMode()){e.preventDefault()}},false);returnr}(this,this.document);
\ No newline at end of file
window.shower=window.shower||function(e,i,t){varr={},n=e.location,s=i.body,l=[],o=[],d,a=!!(e.history&&e.history.pushState);functionu(e){for(variine){if(e.hasOwnProperty(i)){this[i]=e[i]}}}u.prototype={getSlideNumber:function(){returnthis.number},isLast:function(){returnr.slideList.length===this.number+1},isFinished:function(){returnthis.innerComplete>=this.innerLength},process:function(e){if(this.timing){this.initTimer(e);returnthis}this.next(e);returnthis},initTimer:function(e){vari=this;if(!i.timing){returnfalse}i.stopTimer();if(i.isFinished()){d=setInterval(function(){i.stopTimer();e.next()},i.timing*(i.innerLength||1))}else{d=setInterval(function(){if(i.isFinished()){i.stopTimer();e.next()}else{i.next(e)}},i.timing)}returnthis},stopTimer:function(){if(d){clearInterval(d);d=false}returnthis},prev:function(e){vart,r=this;if(!r.hasInnerNavigation||r.isFinished()||r.innerComplete===0){e.prev();returnfalse}t=i.getElementById(r.id).querySelectorAll(".next.active");if(!t||t.length<1){returnfalse}if(r.innerComplete>0){r.innerComplete--;t[t.length-1].classList.remove("active")}else{e.prev()}returnthis},next:function(e){vart,r=this;if(!r.hasInnerNavigation||r.isFinished()){e.next();returnfalse}if(!r.isFinished()){t=i.getElementById(r.id).querySelectorAll(".next:not(.active)");t[0].classList.add("active");r.innerComplete++}returnthis}};r._getData=function(e,i){returne.dataset?e.dataset[i]:e.getAttribute("data-"+i)};r.slideList=[];r.init=function(e,t){varn;e=e||".slide";t=t||"div.progress div";l=i.querySelectorAll(e);o=i.querySelector(t);for(vars=0;s<l.length;s++){if(!l[s].id){l[s].id=s+1}n=r._getData(l[s],"timing");if(n&&/^(\d{1,2}:)?\d{1,3}$/.test(n)){if(n.indexOf(":")!==-1){n=n.split(":");n=(parseInt(n[0],10)*60+parseInt(n[1],10))*1e3}else{n=parseInt(n,10)*1e3}if(n===0){n=false}}else{n=false}r.slideList.push(newu({id:l[s].id,number:s,hasInnerNavigation:null!==l[s].querySelector(".next"),timing:n,innerLength:l[s].querySelectorAll(".next").length,innerComplete:0}))}returnr};r._getTransform=function(){vari=Math.max(s.clientWidth/e.innerWidth,s.clientHeight/e.innerHeight);return"scale("+1/i+")"};r._applyTransform=function(e){["WebkitTransform","MozTransform","msTransform","OTransform","transform"].forEach(function(i){s.style[i]=e});returntrue};r._isNumber=function(e){return!isNaN(parseFloat(e))&&isFinite(e)};r._normalizeSlideNumber=function(e){if(!r._isNumber(e)){thrownewError("Gimme slide number as Number, baby!")}if(e<0){e=0}if(e>=r.slideList.length){e=r.slideList.length-1}returne};r._getSlideIdByEl=function(e){while("BODY"!==e.nodeName&&"HTML"!==e.nodeName){if(e.classList.contains("slide")){returne.id}else{e=e.parentNode}}return""};r._checkInteractiveElement=function(e){return"A"===e.target.nodeName};r.getSlideNumber=function(e){vari=r.slideList.length-1,t;if(e===""){t=0}for(;i>=0;--i){if(e===r.slideList[i].id){t=i;break}}returnt};r.go=function(e,i){vart;if(!r._isNumber(e)){thrownewError("Gimme slide number as Number, baby!")}if(!r.slideList[e]){returnfalse}n.hash=r.getSlideHash(e);r.updateProgress(e);r.updateActiveAndVisitedSlides(e);if(r.isSlideMode()){r.showPresenterNotes(e);t=r.slideList[e];if(t.timing){t.initTimer(r)}}if(typeofi==="function"){i()}returne};r.next=function(e){vari=r.getCurrentSlideNumber(),t=r.slideList[i+1];if(!t){returnfalse}r.go(i+1);if(typeofe==="function"){e()}returnthis};r._turnNextSlide=function(e){vari=r.getCurrentSlideNumber(),t=r.slideList[i];if(r.isSlideMode()){t.stopTimer();t.next(r)}else{r.go(i+1)}if(typeofe==="function"){e()}return};r.prev=r.previous=function(e){vari=r.getCurrentSlideNumber();if(i<1){returnfalse}r.go(i-1);if(typeofe==="function"){e()}returntrue};r._turnPreviousSlide=function(e){vari=r.getCurrentSlideNumber(),t=r.slideList[i];t.stopTimer();if(r.isSlideMode()){t.prev(r)}else{r.go(i-1)}if(typeofe==="function"){e()}returntrue};r.first=function(e){vari=r.slideList[r.getCurrentSlideNumber()];i.timing&&i.stopTimer();r.go(0);if(typeofe==="function"){e()}};r.last=function(e){vari=r.slideList[r.getCurrentSlideNumber()];i.timing&&i.stopTimer();r.go(r.slideList.length-1);if(typeofe==="function"){e()}};r.enterSlideMode=function(e){vari=r.getCurrentSlideNumber();s.classList.remove("list");s.classList.add("full");if(r.isListMode()&&a){history.pushState(null,null,n.pathname+"?full"+r.getSlideHash(i))}r._applyTransform(r._getTransform());if(typeofe==="function"){e()}returntrue};r.enterListMode=function(e){vari;s.classList.remove("full");s.classList.add("list");r.clearPresenterNotes();if(r.isListMode()){returnfalse}i=r.getCurrentSlideNumber();r.slideList[i].stopTimer();if(r.isSlideMode()&&a){history.pushState(null,null,n.pathname+r.getSlideHash(i))}r.scrollToSlide(i);r._applyTransform("none");if(typeofe==="function"){e()}returntrue};r.toggleMode=function(e){if(r.isListMode()){r.enterSlideMode()}else{r.enterListMode()}if(typeofe==="function"){e()}returntrue};r.getCurrentSlideNumber=function(){vare=r.slideList.length-1,i=n.hash.substr(1);for(;e>=0;--e){if(i===r.slideList[e].id){returne}}return-1};r.scrollToSlide=function(t){varn,s=false;if(!r._isNumber(t)){thrownewError("Gimme slide number as Number, baby!")}if(r.isSlideMode()){thrownewError("You can't scroll to because you in slide mode. Please, switch to list mode.")}if(-1===t){returns}if(r.slideList[t]){n=i.getElementById(r.slideList[t].id);e.scrollTo(0,n.offsetTop);s=true}else{thrownewError("There is no slide with number "+t)}returns};r.isListMode=function(){returna?!/^full.*/.test(n.search.substr(1)):s.classList.contains("list")};r.isSlideMode=function(){returna?/^full.*/.test(n.search.substr(1)):s.classList.contains("full")};r.updateProgress=function(e){if(null===o){returnfalse}if(!r._isNumber(e)){thrownewError("Gimme slide number as Number, baby!")}o.style.width=(100/(r.slideList.length-1)*r._normalizeSlideNumber(e)).toFixed(2)+"%";returntrue};r.updateActiveAndVisitedSlides=function(e){vart,n,s=r.slideList.length;e=r._normalizeSlideNumber(e);if(!r._isNumber(e)){thrownewError("Gimme slide number as Number, baby!")}for(t=0;t<s;++t){n=i.getElementById(r.slideList[t].id);if(t<e){n.classList.remove("active");n.classList.add("visited")}elseif(t>e){n.classList.remove("visited");n.classList.remove("active")}else{n.classList.remove("visited");n.classList.add("active")}}returntrue};r.clearPresenterNotes=function(){if(e.console&&e.console.clear){console.clear()}};r.showPresenterNotes=function(t){r.clearPresenterNotes();if(e.console){t=r._normalizeSlideNumber(t);varn=r.slideList[t].id,s=r.slideList[t+1]?r.slideList[t+1].id:null,l=i.getElementById(n).querySelector("footer");if(l&&l.innerHTML){console.info(l.innerHTML.replace(/\n\s+/g,"\n"))}if(s){varo=i.getElementById(s).querySelector("h2");if(o){o=o.innerHTML.replace(/^\s+|<[^>]+>/g,"");console.info("NEXT: "+o)}}}};r.getSlideHash=function(e){if(!r._isNumber(e)){thrownewError("Gimme slide number as Number, baby!")}e=r._normalizeSlideNumber(e);return"#"+r.slideList[e].id};e.addEventListener("DOMContentLoaded",function(){if(s.classList.contains("full")||r.isSlideMode()){r.go(r.getCurrentSlideNumber());r.enterSlideMode()}},false);e.addEventListener("popstate",function(){if(r.isListMode()){r.enterListMode()}else{r.enterSlideMode()}},false);e.addEventListener("resize",function(){if(r.isSlideMode()){r._applyTransform(r._getTransform())}},false);i.addEventListener("keydown",function(e){vari,t;if(e.altKey||e.ctrlKey||e.metaKey){return}i=r.getCurrentSlideNumber();t=r.slideList[i];switch(e.which){case116:e.preventDefault();if(r.isListMode()){varn=e.shiftKey?i:0,t;r.go(n);r.enterSlideMode();r.showPresenterNotes(n);t=r.slideList[i];t.timing&&t.initTimer(r)}else{r.enterListMode()}break;case13:if(r.isListMode()&&-1!==i){e.preventDefault();r.enterSlideMode();r.showPresenterNotes(i);if(t.timing){t.initTimer(r)}}break;case27:if(r.isSlideMode()){e.preventDefault();r.enterListMode()}break;case33:case38:case37:case72:case75:if(r.isSlideMode()){e.preventDefault();r._turnPreviousSlide()}break;case34:case40:case39:case76:case74:if(r.isSlideMode()){e.preventDefault();r._turnNextSlide()}break;case36:if(r.isSlideMode()){e.preventDefault();r.first()}break;case35:if(r.isSlideMode()){e.preventDefault();r.last()}break;case9:case32:if(r.isSlideMode()){e.preventDefault();r[e.shiftKey?"_turnPreviousSlide":"_turnNextSlide"]()}break;default:}},false);r.init();i.addEventListener("click",function(e){vari=r.getSlideNumber(r._getSlideIdByEl(e.target)),t;if(r.isListMode()&&r._getSlideIdByEl(e.target)){r.go(i);r.enterSlideMode();r.showPresenterNotes(i);t=r.slideList[i];if(t.timing){t.initTimer(r)}}},false);i.addEventListener("touchstart",function(i){vart=r.getSlideNumber(r._getSlideIdByEl(i.target)),n,s;if(r._getSlideIdByEl(i.target)){if(r.isSlideMode()&&!r._checkInteractiveElement(i)){s=i.touches[0].pageX;if(s>e.innerWidth/2){r._turnNextSlide()}else{r._turnPreviousSlide()}}if(r.isListMode()){r.go(r.getSlideNumber(r._getSlideIdByEl(i.target)));r.enterSlideMode();r.showPresenterNotes(t);n=r.slideList[t];if(n.timing){n.initTimer(r)}}}},false);i.addEventListener("touchmove",function(e){if(r.isSlideMode()){e.preventDefault()}},false);returnr}(this,this.document);