/** * Core for Shower HTML presentation engine * shower-core v2.0.7, https://github.com/shower/core * @copyright 2010–2016 Vadim Makeev, http://pepelsbey.net/ * @license MIT */ !function(a){var b,c={NOT_RESOLVED:"NOT_RESOLVED",IN_RESOLVING:"IN_RESOLVING",RESOLVED:"RESOLVED"},d=function(){var l={trackCircularDependencies:!0,allowMultipleDeclarations:!0},m={},n=!1,o=[],p=function(a,d,e){e||(e=d,d=[]);var f=m[a];f||(f=m[a]={name:a,decl:b}),f.decl={name:a,prev:f.decl,fn:e,state:c.NOT_RESOLVED,deps:d,dependents:[],exports:b}},q=function(b,c,d){"string"==typeof b&&(b=[b]),n||(n=!0,k(v)),o.push({deps:b,cb:function(b,f){f?(d||e)(f):c.apply(a,b)}})},r=function(a){var b=m[a];return b?c[b.decl.state]:"NOT_DEFINED"},s=function(a){return!!m[a]},t=function(a){for(var b in a)a.hasOwnProperty(b)&&(l[b]=a[b])},u=function(){var a,b={};for(var c in m)m.hasOwnProperty(c)&&(a=m[c],(b[a.decl.state]||(b[a.decl.state]=[])).push(c));return b},v=function(){n=!1,w()},w=function(){var a,b=o,c=0;for(o=[];a=b[c++];)x(null,a.deps,[],a.cb)},x=function(a,b,c,d){var e=b.length;e||d([]);for(var g,h,i=[],j=function(a,b){if(b)return void d(null,b);if(!--e){for(var c,f=[],g=0;c=i[g++];)f.push(c.exports);d(f)}},k=0,l=e;k ")+'"')},h=function(a){return Error('Declaration of module "'+a.name+'" has already been provided')},i=function(a){return Error('Multiple declarations of module "'+a.name+'" have been detected')},j=function(a,b){for(var c,d=0;c=b[d++];)if(a===c)return!0;return!1},k=function(){var b=[],c=function(a){return 1===b.push(a)},d=function(){var a=b,c=0,d=b.length;for(b=[];c=0&&!b.defaultPrevented();){var d=a[c];d&&(d.context?d.callback.call(d.context,b):d.callback(b)),c--}}}),a(e)}),shower.modules.define("Plugins",["Emitter","util.extend"],function(a,b,c){function d(a){this.events=new b({context:this}),this._showerGlobal=a,this._showerInstances=a.getInited(),this._plugins={},this._instances=[],a.events.on("init",this._onShowerInit,this)}c(d.prototype,{destroy:function(){this._showerGlobal.events.off("init",this._onShowerInit,this),this._plugins=null},add:function(a,b){if(this._plugins.hasOwnProperty(a))throw new Error("Plugin "+a+" already exist.");return this._requireAndAdd({name:a,options:b}),this},remove:function(a){if(!this._plugins.hasOwnProperty(a))throw new Error("Plugin "+a+" not found.");return delete this._plugins[a],this.events.emit("remove",{name:a}),this},get:function(a,b){var c,d=this._plugins[a];if(d&&b)for(var e=0,f=this._instances.length;e=0;e--)if(d[e].getId()===a){b=d[e],c=e;break}return{slide:b,index:c}},_onSlideActivate:function(a){window.location.hash=a.get("slide").getId(),this._setTitle()},_onContainerSlideModeChange:function(){this._setTitle(),this.save()},_isSlideMode:function(){return this._shower.container.isSlideMode()},_onPopstate:function(){var a,b=this._shower,c=window.location.hash.substr(1),d=b.player.getCurrentSlide(),e=b.player.getCurrentSlideIndex();this._isSlideMode()&&e===-1?b.player.go(0):e===-1&&""!==window.location.hash&&b.player.go(0),d&&c!==d.getId()&&(a=this._getSlideById(c),b.player.go(a.index))},_setTitle:function(){var a=document.title,b=this._isSlideMode(),c=this._shower.player.getCurrentSlide();if(b&&c){var d=c.getTitle();document.title=d?d+" — "+this._documentTitle:this._documentTitle}else this._documentTitle!==a&&(document.title=this._documentTitle)}}),a(e)}),shower.modules.define("shower.Player",["Emitter","util.bound","util.extend"],function(a,b,c,d){function e(a){this.events=new b({context:this,parent:a.events}),this._shower=a,this._showerListeners=null,this._playerListeners=null,this._currentSlideNumber=-1,this._currentSlide=null,this.init()}d(e.prototype,{init:function(){this._showerListeners=this._shower.events.group().on("slideadd",this._onSlideAdd,this).on("slideremove",this._onSlideRemove,this).on("slidemodeenter",this._onSlideModeEnter,this),this._playerListeners=this.events.group().on("prev",this._onPrev,this).on("next",this._onNext,this),document.addEventListener("keydown",c(this,"_onKeyDown"))},destroy:function(){this._showerListeners.offAll(),this._playerListeners.offAll(),document.removeEventListener("keydown",c(this,"_onKeyDown")),this._currentSlide=null,this._currentSlideNumber=null,this._shower=null},next:function(){return this.events.emit("next"),this},prev:function(){return this.events.emit("prev"),this},first:function(){return this.go(0),this},last:function(){return this.go(this._shower.getSlidesCount()-1),this},go:function(a){"number"!=typeof a&&(a=this._shower.getSlideIndex(a));var b=this._shower.getSlidesCount(),c=this._currentSlide;return a!=this._currentSlideNumber&&a=0&&(c&&c.isActive()&&c.deactivate(),c=this._shower.get(a),this._currentSlide=c,this._currentSlideNumber=a,c.isActive()||c.activate(),this.events.emit("activate",{index:a,slide:c})),this},getCurrentSlide:function(){return this._currentSlide},getCurrentSlideIndex:function(){return this._currentSlideNumber},_onPrev:function(){this._changeSlide(this._currentSlideNumber-1)},_onNext:function(){this._changeSlide(this._currentSlideNumber+1)},_changeSlide:function(a){this.go(a)},_onSlideAdd:function(a){var b=a.get("slide");b.events.on("activate",this._onSlideActivate,this)},_onSlideRemove:function(a){var b=a.get("slide");b.events.off("activate",this._onSlideActivate,this)},_onSlideActivate:function(a){var b=a.get("slide"),c=this._shower.getSlideIndex(b);this.go(c)},_onKeyDown:function(a){if(this._shower.isHotkeysEnabled()&&!/^(?:button|input|select|textarea)$/i.test(a.target.tagName))switch(this.events.emit("keydown",{event:a}),a.which){case 33:case 38:case 37:case 72:case 75:if(a.altKey||a.ctrlKey||a.metaKey)return;a.preventDefault(),this.prev();break;case 34:case 40:case 39:case 76:case 74:if(a.altKey||a.ctrlKey||a.metaKey)return;a.preventDefault(),this.next();break;case 36:a.preventDefault(),this.first();break;case 35:a.preventDefault(),this.last();break;case 32:this._shower.container.isSlideMode()&&(a.shiftKey?this.prev():this.next())}},_onSlideModeEnter:function(){this._currentSlide||this.go(0)}}),a(e)}),shower.modules.define("shower.slidesParser",["Slide"],function(a,b){function c(a,c){var d=a.querySelectorAll(c);return d=Array.prototype.slice.call(d),d.map(function(a,c){var d=new b(a);return a.id||(a.id=c+1),d})}a(c)}),shower.modules.define("Slide",["shower.defaultOptions","Emitter","Options","slide.Layout","slide.layoutFactory","util.Store","util.extend"],function(a,b,c,d,e,f,g,h){function i(a,b,e){this.events=new c,this.options=new d(b),this.layout=null,this.state=new g({visited:0,index:null},e),this._content=a,this._isVisited=this.state.get("visited")>0,this._isActive=!1,this.init()}h(i.prototype,{init:function(){this.layout="string"==typeof this._content?new f.createLayout({content:this._content}):new e(this._content,this.options),this.layout.setParent(this),this._setupListeners()},destroy:function(){this._clearListeners(),this._isActive=null,this.options=null,this.layout.destroy()},activate:function(){this._isActive=!0;var a=this.state.get("visited");return this.state.set("visited",++a),this.events.emit("activate",{slide:this}),this},deactivate:function(){return this._isActive=!1,this.events.emit("deactivate",{slide:this}),this},isActive:function(){return this._isActive},isVisited:function(){return this.state.get("visited")>0},getTitle:function(){return this.layout.getTitle()},setTitle:function(a){return this.layout.setTitle(a),this},getId:function(){return this.layout.getElement().id},getContent:function(){return this.layout.getContent()},_setupListeners:function(){this.layoutListeners=this.layout.events.group().on("click",this._onSlideClick,this)},_clearListeners:function(){this.layoutListeners.offAll()},_onSlideClick:function(){this.activate(),this.events.emit("click",{slide:this})}}),a(i)}),shower.modules.define("slide.Layout",["Options","shower.defaultOptions","Emitter","util.bound","util.extend"],function(a,b,c,d,e,f){function g(a,e){this.options=new b({title_element_selector:c.slide_title_element_selector,active_classname:c.slide_active_classname,visited_classname:c.slide_visited_classname},e),this.events=new d,this._element=a,this._parent=null,this._parentElement=null,this.init()}f(g.prototype,{init:function(){var a=this._element.parentNode;a?this._parentElement=a:this.setParentElement(a)},destroy:function(){this.setParent(null)},setParent:function(a){this._parent!=a&&(this._clearListeners(),this._parent=a,this._parent&&this._setupListeners(),this.events.emit("parentchange",{parent:a}))},getParent:function(){return this._parent},setParentElement:function(a){a!=this._parentElement&&(this._parentElement=a,a.appendChild(this._element),this.events.emit("parentelementchange",{parentElement:a}))},getParentElement:function(){return this._parentElement},getElement:function(){return this._element},setTitle:function(a){var b=this.options.get("title_element_selector"),c=this._element.querySelector(b);c?c.innerHTML=a:(c=document.createElement(b),c.innerHTML=a,this._element.insertBefore(c,this._element.firstChild))},getTitle:function(){var a=this.options.get("title_element_selector"),b=this._element.querySelector(a);return b?b.textContent:null},getData:function(a){var b=this._element;return b.dataset?b.dataset[a]:b.getAttribute("data-"+a)},getContent:function(){return this._element.innerHTML},_setupListeners:function(){this._slideListeners=this._parent.events.group().on("activate",this._onSlideActivate,this).on("deactivate",this._onSlideDeactivate,this),this._element.addEventListener("click",e(this,"_onSlideClick"),!1)},_clearListeners:function(){this._slideListeners&&this._slideListeners.offAll(),this._element.removeEventListener("click",e(this,"_onSlideClick"))},_onSlideActivate:function(){this._element.classList.add(this.options.get("active_classname"))},_onSlideDeactivate:function(){var a=this._element.classList;a.remove(this.options.get("active_classname")),a.add(this.options.get("visited_classname"))},_onSlideClick:function(){this.events.emit("click")}}),a(g)}),shower.modules.define("slide.layoutFactory",["slide.Layout","util.extend"],function(a,b,c){var d={};c(d,{createLayout:function(a){a=a||{};var e=d._createElement(c({content:"",contentType:"slide"},a));return new b(e)},_createElement:function(a){var b=document.createElement("section");return b.innerHTML=a.content,b.classList.add(a.contentType),b}}),a(d)}),shower.modules.define("util.bound",function(a){function b(a,b){return a["__bound_"+b]||(a["__bound_"+b]=a[b].bind(a))}a(b)}),shower.modules.define("util.extend",function(a){function b(a){if(!a)throw new Error("util.extend: Target not found");return"undefined"==typeof Object.assign?c.apply(null,arguments):Object.assign.apply(null,arguments)}function c(a){for(var b=1,c=arguments.length;b0&&(a.preventDefault(),this.prev())},_go:function(){for(var a=0,b=this._elements.length;awindow.innerWidth/2?c.player.next():c.player.prev()),d||f.activate())},_onTouchMove:function(a){this._shower.container.isSlideMode()&&a.preventDefault()},_getSlideByElement:function(a){for(var b=this._shower.getSlides(),c=null,d=0,e=b.length;d