UNPKG

magcore-osd-pip

Version:

Mag osd PiP.

2 lines 28.3 kB
!function(t){var e={};function i(s){if(e[s])return e[s].exports;var o=e[s]={i:s,l:!1,exports:{}};return t[s].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=t,i.c=e,i.d=function(t,e,s){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)i.d(s,o,function(e){return t[e]}.bind(null,o));return s},i.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=9)}([function(t,e,i){"use strict";var s=i(4),o=i(12).parse,n=new s;n.query=o(document.location.search.substring(1)),n.config=i(5),n.activePage=null,n.route=function(t,e){var i,s=n.activePage;return!(!t||t.active)&&(t.name,t.id,t.name,t.id,(i=n.activePage)&&i.active&&(i.$node.classList.remove("active"),i.active=!1,n.activePage=null,i.name,i.id,i.name,i.id,i.events["hide"]&&i.emit("hide")),function(t,e){!t||t.active||(t.$node.classList.add("active"),t.active=!0,n.activePage=t,t.name,t.id,t.name,t.id,t.events["show"]&&t.emit("show",{data:e}))}(t,e),this.events["route"]&&this.emit("route",{from:s,to:t}),!0)},t.exports=n},function(t,e,i){"use strict";t.exports={leftTop:0,rightTop:1,rightBottom:2,leftBottom:3,none:4}},function(t,e,i){"use strict";var s=i(0),o=i(4),n=0;function a(t){var e,i=this;if(t=t||{},this.visible=!0,this.focusable=!0,this.$node=null,this.$body=null,this.parent=null,this.children=[],this.propagate=!!t.propagate,o.call(this),this.$node=t.$node||document.createElement("div"),this.$body=t.$body||this.$node,this.$node.className=this.name+" "+(t.className||""),this.id=t.id||this.$node.id||"cid"+n++,t.parent&&t.parent.add(this),!1===t.visible&&this.hide(),!1===t.focusable&&(this.focusable=!1),this.defaultEvents)for(e in t.events=t.events||{},this.defaultEvents)t.events[e]=t.events[e]||this.defaultEvents[e];t.events&&Object.keys(t.events).forEach(function(e){i.addListener(e,t.events[e])}),t.children&&this.add.apply(this,t.children),this.$node.addEventListener("click",function(t){i.focus(),i.events["click"]&&i.emit("click",t),t.stopPropagation()}),this.name,this.id,this.name,this.id}a.prototype=Object.create(o.prototype),a.prototype.constructor=a,a.prototype.defaultEvents=null,a.prototype.add=function(t){var e;for(e=0;e<arguments.length;e++)t=arguments[e],this.children.push(t),t.parent=this,t.$node&&null===t.$node.parentNode&&this.$body.appendChild(t.$node),t.name,t.id,this.name,this.id,this.name,this.id,t.name,t.id,this.events["add"]&&this.emit("add",{item:t})},a.prototype.remove=function(){this.parent&&(s.activePage.activeComponent===this&&(this.blur(),this.parent.focus()),this.parent.children.splice(this.parent.children.indexOf(this),1)),this.children.forEach(function(t){t.remove()}),this.$node.parentNode.removeChild(this.$node),this.events["remove"]&&this.emit("remove"),this.events={},this.name,this.id,this.name,this.id},a.prototype.focus=function(t){var e=s.activePage,i=e.activeComponent;return!(!this.focusable||this===i)&&(i&&i.blur(),e.activeComponent=i=this,i.$node.classList.add("focus"),this.name,this.id,this.name,this.id,i.events["focus"]&&i.emit("focus",t),!0)},a.prototype.blur=function(){var t=s.activePage,e=t.activeComponent;return this.$node.classList.remove("focus"),this===e?(t.activeComponent=null,this.name,this.id,this.name,this.id,this.events["blur"]&&this.emit("blur"),!0):(this.name,this.id,this.name,this.id,!1)},a.prototype.show=function(t,e){return!this.visible&&(this.$node.classList.remove("hidden"),this.visible=!0,this.name,this.id,this.name,this.id,this.events["show"]&&this.emit("show",t),"function"==typeof e&&setTimeout(e),!0)},a.prototype.hide=function(t){return!!this.visible&&(this.$node.classList.add("hidden"),this.visible=!1,this.name,this.id,this.name,this.id,this.events["hide"]&&this.emit("hide"),"function"==typeof t&&setTimeout(t),!0)},t.exports=a},function(t,e,i){"use strict";t.exports={backspace:8,tab:9,enter:13,escape:27,space:32,pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,del:46}},function(t,e,i){"use strict";function s(){this.events={}}s.prototype={addListener:function(t,e){this.events[t]=this.events[t]||[],this.events[t].push(e)},once:function(t,e){var i=this;this.events[t]=this.events[t]||[],this.events[t].push(function s(){i.removeListener(t,s),e.apply(i,arguments)})},addListeners:function(t){var e;for(e in t)t.hasOwnProperty(e)&&this.addListener(e,t[e])},removeListener:function(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(function(t){return t!==e}),0===this.events[t].length&&(this.events[t]=void 0))},emit:function(t){var e,i=this.events[t];if(i)for(e=0;e<i.length;e++)i[e].apply(this,Array.prototype.slice.call(arguments,1))}},s.prototype.constructor=s,t.exports=s},function(t,e,i){"use strict";t.exports={viewports:i(13),positions:i(1)}},function(t,e,i){"use strict";var s=i(1),o={480:{},576:{},720:{},1080:{}};o[480][s.leftTop]={width:200,height:160,x:60,y:40},o[480][s.rightTop]={width:o[480][s.leftTop].width,height:o[480][s.leftTop].height,x:460,y:40},o[480][s.rightBottom]={width:o[480][s.leftTop].width,height:o[480][s.leftTop].height,x:460,y:296},o[480][s.leftBottom]={width:o[480][s.leftTop].width,height:o[480][s.leftTop].height,x:60,y:296},o[576]=o[480],o[720]=o[480],o[1080]=o[480],t.exports=o},function(t,e,i){"use strict";var s=i(1),o={480:{},576:{},720:{},1080:{}};o[480][s.leftTop]={width:300,height:170,x:80,y:70},o[480][s.rightTop]={width:o[480][s.leftTop].width,height:o[480][s.leftTop].height,x:900,y:70},o[480][s.rightBottom]={width:o[480][s.leftTop].width,height:o[480][s.leftTop].height,x:900,y:480},o[480][s.leftBottom]={width:o[480][s.leftTop].width,height:o[480][s.leftTop].height,x:80,y:480},o[576][s.leftTop]={width:350,height:194,x:110,y:54},o[576][s.rightTop]={width:o[576][s.leftTop].width,height:o[576][s.leftTop].height,x:820,y:54},o[576][s.rightBottom]={width:o[576][s.leftTop].width,height:o[576][s.leftTop].height,x:820,y:373},o[576][s.leftBottom]={width:o[576][s.leftTop].width,height:o[576][s.leftTop].height,x:110,y:373},o[720][s.leftTop]={width:300,height:170,x:80,y:70},o[720][s.rightTop]={width:o[720][s.leftTop].width,height:o[720][s.leftTop].height,x:900,y:70},o[720][s.rightBottom]={width:o[720][s.leftTop].width,height:o[720][s.leftTop].height,x:900,y:480},o[720][s.leftBottom]={width:o[720][s.leftTop].width,height:o[720][s.leftTop].height,x:80,y:480},o[1080]=o[720],t.exports=o},function(t,e,i){"use strict";var s=i(0);t.exports=function(t){var e=document.createElement("link");e.rel="stylesheet",e.href="css/"+t+"."+s.metrics.height+".css",document.head.appendChild(e)}},function(t,e,i){"use strict";var s=i(10);s.once("load",function(){s.pages={init:i(20)},s.route(s.pages.init),s.ready()})},function(t,e,i){"use strict";var s=i(11);t.exports=s},function(t,e,i){"use strict";var s=i(0),o=i(15);window.core=window.parent.getCoreInstance(window,s),i(16),i(17),i(8)("sdk"),i(19),i(8)("app"),s.platform="mag",s.ready=function(){window.core.call("app:ready")},s.exit=function(){s.events["exit"]&&s.emit("exit"),core.call("exit")},o.load=function(t){document.body.setAttribute("platform",s.platform),core.ready?s.events["load"]&&s.emit("load",{}):core.once("load",function(){s.events[t.type]&&s.emit(t.type,t)})},o.contextmenu=function(t){t.preventDefault()},Object.keys(o).forEach(function(t){window.addEventListener(t,o[t])}),t.exports=s},function(t,e,i){"use strict";t.exports={parse:function(t){var e={};return t.split("&").forEach(function(t){2===(t=t.split("=")).length&&(e[t[0]]=decodeURIComponent(t[1]))}),e},stringify:function(t){var e=[];return Object.keys(t).forEach(function(i){e.push(i+"="+encodeURIComponent(t[i]))}),e.join("&")}}},function(t,e,i){"use strict";t.exports={480:i(6),576:i(6),720:i(7),1080:i(14)}},function(t,e,i){"use strict";var s=i(1),o=i(7),n={480:{},576:{},720:{},1080:{}};n[480][s.leftTop]={width:1.5*o[480][s.leftTop].width,height:1.5*o[480][s.leftTop].height,x:1.5*o[480][s.leftTop].x,y:1.5*o[480][s.leftTop].y},n[480][s.rightTop]={width:n[480][s.leftTop].width,height:n[480][s.leftTop].height,x:1.5*o[480][s.rightTop].x,y:1.5*o[480][s.rightTop].y},n[480][s.rightBottom]={width:n[480][s.leftTop].width,height:n[480][s.leftTop].height,x:1.5*o[480][s.rightBottom].x,y:1.5*o[480][s.rightBottom].y},n[480][s.leftBottom]={width:n[480][s.leftTop].width,height:n[480][s.leftTop].height,x:1.5*o[480][s.leftBottom].x,y:1.5*o[480][s.leftBottom].y},n[576][s.leftTop]={width:1.5*o[576][s.leftTop].width,height:1.5*o[576][s.leftTop].height,x:1.5*o[576][s.leftTop].x,y:1.5*o[576][s.leftTop].y},n[576][s.rightTop]={width:n[576][s.leftTop].width,height:n[576][s.leftTop].height,x:1.5*o[576][s.rightTop].x,y:1.5*o[576][s.rightTop].y},n[576][s.rightBottom]={width:n[576][s.leftTop].width,height:n[576][s.leftTop].height,x:1.5*o[576][s.rightBottom].x,y:1.5*o[576][s.rightBottom].y},n[576][s.leftBottom]={width:n[576][s.leftTop].width,height:n[576][s.leftTop].height,x:1.5*o[576][s.leftBottom].x,y:1.5*o[576][s.leftBottom].y},n[720][s.leftTop]={width:1.5*o[720][s.leftTop].width,height:1.5*o[720][s.leftTop].height,x:1.5*o[720][s.leftTop].x,y:1.5*o[720][s.leftTop].y},n[720][s.rightTop]={width:n[720][s.leftTop].width,height:n[720][s.leftTop].height,x:1.5*o[720][s.rightTop].x,y:1.5*o[720][s.rightTop].y},n[720][s.rightBottom]={width:n[720][s.leftTop].width,height:n[720][s.leftTop].height,x:1.5*o[720][s.rightBottom].x,y:1.5*o[720][s.rightBottom].y},n[720][s.leftBottom]={width:n[720][s.leftTop].width,height:n[720][s.leftTop].height,x:1.5*o[720][s.leftBottom].x,y:1.5*o[720][s.leftBottom].y},n[1080]=n[720],t.exports=n},function(t,e,i){"use strict";var s=i(0);t.exports={DOMContentLoaded:function(t){s.events["dom"]&&s.emit("dom",t)},load:function(t){s.events[t.type]&&s.emit(t.type,t)},unload:function(t){s.events[t.type]&&s.emit(t.type,t)},error:function(t){},keydown:function(t){var e,i=s.activePage,o={code:t.keyCode,stop:!1};t.ctrlKey&&(o.code+="c"),t.altKey&&(o.code+="a"),t.shiftKey&&(o.code+="s"),(e=i.activeComponent)&&e!==i&&(e.events[t.type]&&e.emit(t.type,o,t),!o.stop&&e.propagate&&e.parent&&e.parent.events[t.type]&&e.parent.emit(t.type,o,t)),o.stop||(i.events[t.type]&&i.emit(t.type,o,t),t.stop||s.events[t.type]&&s.emit(t.type,o,t))},keypress:function(t){var e=s.activePage;e.activeComponent&&e.activeComponent!==e&&e.activeComponent.events[t.type]&&e.activeComponent.emit(t.type,t)},mousewheel:function(t){var e=s.activePage;e.activeComponent&&e.activeComponent!==e&&e.activeComponent.events[t.type]&&e.activeComponent.emit(t.type,t),t.stop||e.events[t.type]&&e.emit(t.type,t)}}},function(t,e,i){"use strict";if(!document.documentElement.classList){var s=Array.prototype,o=s.indexOf,n=s.slice,a=s.push,r=s.splice,c=s.join;window.DOMTokenList=function(t){if(this._element=t,t.className!==this._classCache){if(this._classCache=t.className,!this._classCache)return;var e,i=this._classCache.replace(/^\s+|\s+$/g,"").split(/\s+/);for(e=0;e<i.length;e++)a.call(this,i[e])}},window.DOMTokenList.prototype={add:function(t){this.contains(t)||(a.call(this,t),this._element.className=n.call(this,0).join(" "))},contains:function(t){return-1!==o.call(this,t)},item:function(t){return this[t]||null},remove:function(t){var e=o.call(this,t);-1!==e&&(r.call(this,e,1),this._element.className=n.call(this,0).join(" "))},toString:function(){return c.call(this," ")},toggle:function(t){return this.contains(t)?this.remove(t):this.add(t),this.contains(t)}},Object.defineProperty(Element.prototype,"classList",{get:function(){return new window.DOMTokenList(this)}})}},function(t,e,i){"use strict";var s=i(0),o=i(18);s.metrics=o[s.query.screenHeight]||o[screen.height]||o[720],s.metrics.availHeight=s.metrics.height-(s.metrics.availTop+s.metrics.availBottom),s.metrics.availWidth=s.metrics.width-(s.metrics.availLeft+s.metrics.availRight)},function(t,e,i){"use strict";t.exports={480:{height:480,width:720,availTop:24,availBottom:24,availRight:32,availLeft:48},576:{height:576,width:720,availTop:24,availBottom:24,availRight:26,availLeft:54},720:{height:720,width:1280,availTop:30,availBottom:30,availRight:40,availLeft:40},1080:{height:1080,width:1920,availTop:45,availBottom:45,availRight:60,availLeft:60}}},function(t,e,i){"use strict";var s,o=i(0);(s=document.createElement("link")).rel="stylesheet",s.href=window.core.theme.path+o.metrics.height+".css",document.head.appendChild(s),t.exports=s},function(t,e,i){"use strict";var s,o,n,a,r=i(21),c=i(22),h=i(23),d=i(25),l=i(27),p=i(5),u=document.getElementById("playerSpaceLeftTop"),m=document.getElementById("playerSpaceRightTop"),f=document.getElementById("playerSpaceRightBottom"),v=document.getElementById("playerSpaceLeftBottom"),y=document.getElementById("playerSpaceNone"),g=document.getElementById("pageMain"),w=document.getElementById("playerSpace"),b=document.getElementById("player"),x=3,T={},I=p.positions.rightBottom,$=-1,L=null,k=!1,B=!1,C=!1;function E(){B?(T[I].classList.remove("active","paused","audio"),g.className="stb-component-page active",w.classList.add("active"),a.focus()):(T[I].classList.add("active"),L&&L.audio&&(C?T[I].classList.remove("paused"):T[I].classList.add("paused")),g.className="stb-component-page active reposition",w.classList.remove("active"),s.focus(),I===p.positions.none&&(w.classList.add("active"),w.innerHTML=L.data.title)),B=!B}function N(t){var e=parent.gSTB.RDir("vmode").match(/^(\d)*/g)[0],i=p.viewports[e][screen.height][t];switch(t){case p.positions.leftBottom:w.innerHTML="",b.className="lb";break;case p.positions.rightTop:w.innerHTML="",b.className="rt";break;case p.positions.leftTop:w.innerHTML="",b.className="lt";break;case p.positions.rightBottom:w.innerHTML="",b.className="rb";break;case p.positions.none:b.className="none",i={width:0,height:0,x:0,y:0},w.classList.add("active"),w.innerHTML=L.data.title}return L.emit("viewport",i),I=t,i}function z(t){o.init({max:t,value:0}),o.show(),a.focusItem(n),n.classList.remove("disabled"),a.data[1].disabled=!1}function O(){a.focusItem(a.$body.children[0]),a.data[1].disabled=!0,n.classList.add("disabled")}T[p.positions.leftBottom]=v,T[p.positions.leftTop]=u,T[p.positions.rightBottom]=f,T[p.positions.rightTop]=m,T[p.positions.none]=y,s=new l({$node:g}),o=new c({$node:document.getElementById("progressBar"),parent:s}),a=new d({$node:document.getElementById("buttonList"),parent:s,size:4,type:d.prototype.TYPE_HORIZONTAL,data:[{className:"button-maximize",onclick:function(){k=!1,clearInterval($),w.classList.remove("audio"),L.emit("maximize"),L.close(!0),core.call("hide"),core.call("blur"),L=null}},{className:"button-pause",onclick:function(t){C?(L.emit("pause"),t.$item.classList.add("paused")):(L.emit("resume"),t.$item.classList.remove("paused")),C=!C,L&&L.audio&&(C?w.classList.remove("paused"):w.classList.add("paused"))}},{className:"button-layout",onclick:function(){setTimeout(function(){B||E()},0)}},{className:"button-close",onclick:function(){L.emit("stop"),core.call("hide"),core.call("blur"),k=!1,C=!1,clearInterval($),core.active=!1,L=null}}],render:function(t,e){t.button=new h({$node:t,className:e.className})},events:{"click:item":function(t){t.$item.data.onclick(t)},keydown:function(t){var e;switch(t.code){case r.up:case r.down:case r.right:case r.left:case r.pageUp:case r.pageDown:case r.home:case r.end:this.move(t.code),this.$focusItem.data.disabled&&this.move(t.code);break;case r.ok:this.events["click:item"]&&this.emit("click:item",{$item:this.$focusItem,event:t});break;case r.playPause:L&&!a.data[1].disabled&&(e=a.$focusItem===n,C?(L.emit("pause"),n.className="stb-component-button button-pause paused "+(e?"focus":"")):(L.emit("resume"),n.className="stb-component-button button-pause "+(e?"focus":"")),C=!C,L.audio&&(C?w.classList.remove("paused"):w.classList.add("paused")))}}}}),n=a.$body.children[1],s.addListener("show",function(){a.focus(),a.focusIndex(2)}),s.addListener("keydown",function(t){var e=null;if(B){switch(t.code){case r.back:case r.ok:E();break;case r.left:switch(I){case p.positions.rightTop:e=p.positions.leftTop;break;case p.positions.rightBottom:e=p.positions.leftBottom}break;case r.right:switch(I){case p.positions.leftTop:e=p.positions.rightTop;break;case p.positions.leftBottom:e=p.positions.rightBottom}break;case r.up:switch(I){case p.positions.rightBottom:e=p.positions.rightTop;break;case p.positions.leftBottom:e=p.positions.leftTop;break;case p.positions.none:e=p.positions.rightBottom}break;case r.down:switch(I){case p.positions.rightBottom:b.className="none",e=p.positions.none;break;case p.positions.leftTop:e=p.positions.leftBottom;break;case p.positions.rightTop:e=p.positions.rightBottom}}null!==e&&(T[I].classList.remove("active","audio","paused"),N(e),T[e].classList.add("active"),L&&L.audio&&(C?T[e].classList.remove("paused"):T[e].classList.add("paused")))}}),core.addListener("hide",function(){B&&E(),g.classList.remove("active"),k=!1}),core.addListener("intent",function(t,e){"pip"===t.action&&((L=t).addListener("exit",function(){g.classList.remove("active"),k=!1,core.call("hide"),core.call("blur"),clearInterval($),L=null}),L.data.viewport=N(I),w.classList.remove("audio","paused"),t.audio=!1,n.className="stb-component-button button-pause",setTimeout(function(){t.mime&&"content/audio"===t.mime&&(w.classList.add("audio"),t.audio=!0,t.data.playerState===x&&(w.classList.add("paused"),n.classList.add("paused"),C=!1))},0),t.data?t.data.duration?(z(t.data.duration),n.className="stb-component-button button-pause focus"):(O(),o.hide(),setTimeout(function(){t.data.duration&&z(t.data.duration)},2e3)):o.hide(),g.className="stb-component-page",k=!1,C=!0,core.call("show"),e(!1,{}))}),core.addListener("keydown:"+r.refresh,function(){L&&(k?(core.call("blur"),B&&E(),g.classList.remove("active"),k=!1):(g.classList.add("active"),clearInterval($),L.data&&L.data.position?$=setInterval(function(){o.set(L.data.position),L.data.position===L.data.duration&&(clearInterval($),w.classList.add("paused"),n.classList.add("paused"),O(),L.emit("pause"))},900):o.hide(),core.call("show"),core.call("focus"),k=!0))}),core.addListener("keydown:"+r.web,function(){core.call("hide"),k=!1}),t.exports=s},function(t,e,i){"use strict";var s=i(3);s.back=s.backspace,s.channelNext=s.tab,s.channelPrev=s.tab+"s",s.ok=s.enter,s.exit=s.escape,s.volumeUp=107,s.volumeDown=109,s.f1="112c",s.f2="113c",s.f3="114c",s.f4="115c",s.refresh="116c",s.frame="117c",s.phone="119c",s.set="120c",s.tv="121c",s.menu="122c",s.app="123c",s.rewind="66a",s.forward="70a",s.audio="71a",s.standby="74a",s.keyboard="76a",s.usbMounted="80a",s.usbUnmounted="81a",s.playPause="82a",s.play=-1,s.pause=-1,s.stop="83a",s.power="85a",s.record="87a",s.info="89a",s.mute="192a",s.digit0=48,s.digit1=49,s.digit2=50,s.digit3=51,s.digit4=52,s.digit5=53,s.digit6=54,s.digit7=55,s.digit8=56,s.digit9=57,t.exports=s},function(t,e,i){"use strict";var s=i(2);function o(t){t=t||{},this.max=100,this.min=0,this.value=0,this.step=1,t.focusable=t.focusable||!1,s.call(this,t),this.$value=this.$body.appendChild(document.createElement("div")),this.$value.className="value",this.init(t)}o.prototype=Object.create(s.prototype),o.prototype.constructor=o,o.prototype.name="spa-component-progress-bar",o.prototype.set=function(t){var e=this.value;return this.value!==t&&t<=this.max&&t>=this.min&&(this.value=t,100===(t=Math.abs(this.value-this.min)/this.step)&&this.events["done"]&&this.emit("done"),this.$value.style.width=t+"%",this.events["change"]&&this.emit("change",{curr:this.value,prev:e}),!0)},o.prototype.init=function(t){void 0!==t.max&&(this.max=t.max),void 0!==t.min&&(this.min=t.min),void 0!==t.value&&(this.value=t.value),this.step=Math.abs(this.max-this.min)/100,this.$value.style.width=Math.abs(this.min-this.value)/this.step+"%"},t.exports=o},function(t,e,i){"use strict";t.exports=i(24),t.exports.prototype.name="stb-component-button"},function(t,e,i){"use strict";var s=i(2),o=i(3);function n(t){t=t||{},s.call(this,t),t.icon&&(this.$icon=this.$body.appendChild(document.createElement("div")),this.$icon.className="icon "+t.icon),this.$text=this.$body.appendChild(document.createElement("div")),this.$text.classList.add("text"),t.value&&(this.$text.innerText=t.value)}n.prototype=Object.create(s.prototype),n.prototype.constructor=n,n.prototype.name="spa-component-button",n.prototype.clickDuration=200,n.prototype.defaultEvents={click:function(){var t=this;this.$node.classList.add("click"),setTimeout(function(){t.$node.classList.remove("click")},this.clickDuration)},keydown:function(t){t.code===o.enter&&this.events["click"]&&this.emit("click",{event:t})}},t.exports=n},function(t,e,i){"use strict";t.exports=i(26),t.exports.prototype.name="stb-component-list"},function(t,e,i){"use strict";var s=i(2),o=i(3);function n(t){t=t||{},this.$focusItem=null,this.viewIndex=null,this.data=[],this.type=this.TYPE_VERTICAL,this.size=5,this.cycle=!1,this.scroll=null,t.type&&(this.type=t.type),this.provider=null,this.type===this.TYPE_HORIZONTAL&&(t.className+=" horizontal"),s.call(this,t),this.init(t)}n.prototype=Object.create(s.prototype),n.prototype.constructor=n,n.prototype.name="spa-component-list",n.prototype.TYPE_VERTICAL=1,n.prototype.TYPE_HORIZONTAL=2,n.prototype.renderItemDefault=function(t,e){t.innerText=e.value},n.prototype.renderItem=n.prototype.renderItemDefault,n.prototype.defaultEvents={mousewheel:function(t){this.type===this.TYPE_VERTICAL&&t.wheelDeltaY&&this.move(t.wheelDeltaY>0?o.up:o.down),this.type===this.TYPE_HORIZONTAL&&t.wheelDeltaX&&this.move(t.wheelDeltaX>0?o.left:o.right)},keydown:function(t){switch(t.code){case o.up:case o.down:case o.right:case o.left:case o.pageUp:case o.pageDown:case o.home:case o.end:this.move(t.code);break;case o.enter:this.events["click:item"]&&this.$focusItem&&this.emit("click:item",{$item:this.$focusItem,event:t})}}},n.prototype.init=function(t){var e,i,s=this,o=this.$body.children.length,n=function(t){this.data&&(s.focusItem(this),s.events["click:item"]&&s.emit("click:item",{$item:this,event:t}))};if(void 0!==t.cycle&&(this.cycle=t.cycle),t.scroll&&(this.scroll=t.scroll),t.provider&&(this.provider=t.provider),t.render&&(this.renderItem=t.render),t.size&&(this.size=t.size),this.size!==o)for(o>0&&(this.$body.innerText=null),i=0;i<this.size;i++)(e=document.createElement("div")).index=i,e.className="item",e.addEventListener("click",n),this.$body.appendChild(e);this.provider?this.provider.get(null,function(e,i){e?s.events["data:error"]&&s.emit("data:error",e):(i&&(t.data=i,s.setData(t),s.scroll&&s.scroll.init({realSize:s.provider.maxCount,viewSize:s.provider.size,value:s.provider.head+s.provider.pos})),s.events["data:get"]&&s.emit("data:get"))}):t.data&&this.setData(t)},n.prototype.setData=function(t){t.data&&(this.data=function(t){var e;for(e=0;e<t.length;e++)"object"!=typeof t[e]&&(t[e]={value:t[e]});return t}(t.data)),this.viewIndex=null,this.$focusItem&&this.blurItem(this.$focusItem),this.scroll&&(this.provider?this.scroll.realSize!==this.provider.maxCount&&this.scroll.init({realSize:this.provider.maxCount,viewSize:this.provider.size,value:this.provider.head+this.provider.pos}):this.scroll.init({realSize:this.data.length,viewSize:this.size,value:t.viewIndex||0})),void 0!==t.focusIndex&&this.data.length?this.focusIndex(t.focusIndex):this.renderView(t.viewIndex||0)},n.prototype.renderView=function(t){var e,i,s,o,n;if(this.viewIndex!==t){for(o=this.viewIndex,this.viewIndex=n=t,i=0;i<this.size;i++)e=this.$body.children[i],(s=this.data[t])?(e.data=s,e.index=t,this.renderItem(e,s),s.mark?e.classList.add("mark"):e.classList.remove("mark")):(e.data=e.index=void 0,e.innerHTML="&nbsp;",e.ready=!1),t++;return this.events["move:view"]&&this.emit("move:view",{prevIndex:o,currIndex:n}),this.events["select:item"]&&this.emit("select:item",{$item:e}),this.scroll&&this.scroll.scrollTo(this.provider?this.provider.head+this.provider.pos:this.viewIndex),!0}return!1},n.prototype.move=function(t){var e=this,i=!1;if(this.data.length)switch(t){case o.left:if(this.type!==this.TYPE_HORIZONTAL)break;i=!0;case o.up:(i||this.type===this.TYPE_VERTICAL)&&(this.$focusItem&&this.$focusItem.index>0?this.$focusItem===this.$body.firstChild?this.renderView(this.viewIndex-1):this.focusItem(this.$focusItem.previousSibling):this.provider?this.provider.get(t,function(t,i,s){t?e.events["data:error"]&&e.emit("data:error",t):i&&e.setData({data:i,focusIndex:s||0===s?s:e.$focusItem.index})}):(this.cycle&&this.move(o.end),this.events["overflow"]&&this.emit("overflow",{direction:t,cycle:this.cycle})));break;case o.right:if(this.type!==this.TYPE_HORIZONTAL)break;i=!0;case o.down:(i||this.type===this.TYPE_VERTICAL)&&(this.$focusItem&&this.$focusItem.index<this.data.length-1?this.$focusItem===this.$body.lastChild?this.renderView(this.viewIndex+1):this.focusItem(this.$focusItem.nextSibling):this.provider?this.provider.get(t,function(t,i,s){t?e.events["data:error"]&&e.emit("data:error",t):i&&e.setData({data:i,focusIndex:s||0===s?s:e.$focusItem.index})}):(this.cycle&&this.move(o.home),this.events["overflow"]&&this.emit("overflow",{direction:t,cycle:this.cycle})));break;case o.pageUp:if(this.provider)return void this.provider.get(t,function(t,i,s){t?e.events["data:error"]&&e.emit("data:error",t):i&&e.setData({data:i,focusIndex:s||0})});this.viewIndex<this.size?this.renderView(0):this.renderView(this.viewIndex-this.size+1),this.focusItem(this.$body.firstChild);break;case o.pageDown:if(this.provider){this.provider.get(t,function(t,i,s){t?e.events["data:error"]&&e.emit("data:error",t):i&&e.setData({data:i,focusIndex:s||0===s?s:i.length<e.size?i.length-1:e.size-1})});break}this.data.length>this.size?(this.viewIndex>this.data.length-2*this.size?this.renderView(this.data.length-this.size):this.renderView(this.viewIndex+this.size-1),this.focusItem(this.$body.lastChild)):this.focusItem(this.$body.children[this.data.length-1]);break;case o.home:if(this.provider){this.provider.get(t,function(t,i,s){t?e.events["data:error"]&&e.emit("data:error",t):i&&e.setData({data:i,focusIndex:s||0})});break}this.renderView(0),this.focusItem(this.$body.firstChild);break;case o.end:if(this.provider){this.provider.get(t,function(t,i,s){t?e.events["data:error"]&&e.emit("data:error",t):i&&e.setData({data:i,focusIndex:s||0===s?s:i.length<e.size?i.length-1:e.size-1})});break}this.data.length>this.size?(this.renderView(this.data.length-this.size),this.focusItem(this.$body.lastChild)):this.focusItem(this.$body.children[this.data.length-1])}},n.prototype.focusItem=function(t){var e=this.$focusItem;return!(!t||e===t)&&(null!==e&&(e.classList.remove("focus"),this.events["blur:item"]&&this.emit("blur:item",{$item:e})),this.$focusItem=t,this.$focusItem.data=this.data[this.$focusItem.index],t.classList.add("focus"),this.events["focus:item"]&&this.emit("focus:item",{$prev:e,$curr:t}),this.events["select:item"]&&this.emit("select:item",{$item:t}),!0)},n.prototype.blurItem=function(t){return!!t&&(t===this.$focusItem&&(this.$focusItem=null),t.classList.remove("focus"),this.events["blur:item"]&&this.emit("blur:item",{$item:t}),!0)},n.prototype.focusIndex=function(t){var e=this.viewIndex||0;t>=e+this.size?(t=t<this.data.length-1?t:this.data.length-1,this.renderView(t-this.size+1),this.focusItem(this.$body.lastChild)):t<e?(t=t>0?t:0,this.renderView(t),this.focusItem(this.$body.firstChild)):(null===this.viewIndex&&this.renderView(0),this.focusItem(this.$body.children[t-e]))},n.prototype.markItem=function(t,e){e?t.classList.add("mark"):t.classList.remove("mark"),t.data.mark=e},t.exports=n},function(t,e,i){"use strict";t.exports=i(28),t.exports.prototype.name="stb-component-page"},function(t,e,i){"use strict";var s=i(2);function o(t){t=t||{},this.active=!1,this.activeComponent=null,s.call(this,t),this.active=this.$node.classList.contains("active"),null===this.$node.parentNode&&document.body.appendChild(this.$node),this.page=this}o.prototype=Object.create(s.prototype),o.prototype.constructor=o,o.prototype.name="spa-component-page",t.exports=o}]); //# sourceMappingURL=main.js.map