/*! * ==================================================== * Hot Box UI - v1.0.15 - 2017-05-05 * https://github.com/fex-team/hotbox * GitHub: https://github.com/fex-team/hotbox.git * Copyright (c) 2017 Baidu FEX; Licensed BSD * ==================================================== */ !function(){function a(a){b.r([c[a]])}var b={r:function(a){if(b[a].inited)return b[a].value;if("function"!=typeof b[a].value)return b[a].inited=!0,b[a].value;var c={exports:{}},d=b[a].value(null,c.exports,c);if(b[a].inited=!0,b[a].value=d,void 0!==d)return d;for(var e in c.exports)if(c.exports.hasOwnProperty(e))return b[a].inited=!0,b[a].value=c.exports,c.exports}};b[0]={value:function(a,c,d){d.exports=window.HotBox=b.r(1)}},b[1]={value:function(a,c,d){function e(a){return document.createElement(a)}function f(a,b){a.classList.add(b)}function g(a,b){a.classList.remove(b)}function h(a,b){a.appendChild(b)}function i(a,b){return"object"!=typeof b&&(b=[].slice.apply(arguments,1)),String(a).replace(/\{(\w+)\}/g,function(a,c){return b[c]||a})}function j(a){function b(a){return q?void q.active():(a=a||m,q=new a(v),q.active(),p.onmousedown=function(a){a.stopPropagation(),a.preventDefault()},v)}function c(b){var c=b.type.toLowerCase();if(b.keyHash=l.hash(b),b.isKey=function(a){if(!a)return!1;for(var c=a.split(/\s*\|\s*/);c.length;)if(b.keyHash==l.hash(c.shift()))return!0;return!1},b[c]=!0,b.keyup&&v.activeKey&&b.isKey(v.activeKey)&&t==n&&s)return void g("main",{x:a.clientWidth/2,y:a.clientHeight/2});var d=t==n?s:t;if(d){var e=d.handleKeyEvent(b);return"function"==typeof v.onkeyevent&&(b.handleResult=e,v.onkeyevent(b,e)),e}return null}function d(a){if(!a)return t;if(a==n)throw new Error("Can not define or use the `idle` state.");return r[a]=r[a]||new k(this,a),"main"==a&&(s=r[a]),r[a]}function g(a,b){if(v.position=b,a==n)t!=n&&(u.shift().deactive(),u=[]),t=n;else if("back"==a)t!=n&&(t.deactive(),u.shift(),t=u[0],t?t.active():t="idle");else{t!=n&&t.deactive();var c=r[a];u.unshift(c),"function"==typeof v.position&&(b=v.position(b)),c.active(b),t=c}}function i(a){v._parentFSM=a}function j(){return v._parentFSM}if("string"==typeof a&&(a=document.querySelector(a)),!(a&&a instanceof HTMLElement))throw new Error("No container or not invalid container for hot box");var p=e(o);f(p,"hotbox"),h(a,p),this.$element=p,this.$container=a,this.isIME=!1,this.browser={sg:/se[\s\S]+metasr/.test(navigator.userAgent.toLowerCase())},this._parentFSM={},this.position={};var q,r={},s=null,t=n,u=[],v=this;this.control=b,this.state=d,this.active=g,this.dispatch=c,this.setParentFSM=i,this.getParentFSM=j,this.activeKey="space",this.actionKey="space"}function k(a,b){function c(){function a(a){var b=B.ring,c=2*Math.PI/b.length;B.center&&(B.center.indexedPosition=[0,0]),y.style.marginLeft=y.style.marginTop=-a+"px",y.style.width=y.style.height=a+a+"px";for(var d,e,f,g,h=0;h2&&(g.push(d>0?"right":"left"),g.push(f+m(e))),m(e)>2&&(g.push(e>0?"down":"up"),g.push(f+m(d)));g.length;)h=g.shift(),j=g.shift(),(!i[h]||j{label}{key}',{label:b.label,key:b.key&&b.key.split("|")[0]})}function l(b){b=b||{x:a.$container.clientWidth/2,y:a.$container.clientHeight/2},b&&(v.style.left=b.x+"px",v.style.top=b.y+"px"),C.forEach(function(a){var b=a.$button;b&&b.classList[a.enable()?"add":"remove"]("enabled"),a.beforeShow&&a.beforeShow()}),f(v,u),G&&c(),D||q(B.center||B.ring[0]||B.top[0]||B.bottom[0]),F=!0}function m(){g(v,u),q(null),F=!1}function p(a){E&&E.$button&&g(E.$button,t),E=a,E&&E.$button&&f(E.$button,t)}function q(a){D&&D.$button&&D.$button&&g(D.$button,s),D=a,D&&D.$button&&f(D.$button,s)}function r(b){b&&((!b.enable||b.enable())&&(b.action&&b.action(b),a.active(b.next||n,a.position)),p(null),q(null))}var s="selected",t="pressed",u="active",v=e(o),w=e(o),x=e(o),y=e("div"),z=e(o),A=e(o);f(v,"state"),f(v,b),f(w,"center"),f(x,"ring"),f(y,"ring-shape"),f(z,"top"),f(A,"bottom"),h(a.$element,v),h(v,y),h(v,w),h(v,x),h(v,z),h(v,A),this.name=b;var B={center:null,ring:[],top:[],bottom:[],behind:[]},C=[],D=null,E=null,F=!1,G=!0;this.button=function(a){var b=j(a);"center"==a.position?B.center=b:B[a.position]&&B[a.position].push(b),C.push(b),G=!0},this.active=l,this.deactive=m,v.onmouseup=function(a){if(!a.button)for(var b=a.target;b&&b!=v;)b.classList.contains("button")&&C.forEach(function(a){a.$button==b&&r(a)}),b=b.parentNode},this.handleKeyEvent=function(c){var d=null;if(a.browser.sg&&c.isKey("esc"))return E?c.isKey(E.key)||p(null):a.active("back",a.position),"back";if(c.keydown||a.isIME&&c.keyup){if(C.forEach(function(e){if(e.enable()&&c.isKey(e.key)){if(F||a.hintDeactiveMainState){if(q(e),p(e),d="buttonpress",c.keyup)return r(e),d="execute"}else r(e),d="execute";c.preventDefault(),c.stopPropagation(),!F&&a.hintDeactiveMainState&&a.active(b,a.position)}}),F){if(c.isKey("esc"))return E?c.isKey(E.key)||p(null):a.active("back",a.position),"back";["up","down","left","right"].forEach(function(a){if(c.isKey(a)){if(!D)return void q(B.center||B.ring[0]||B.top[0]||B.bottom[0]);for(var b=D.neighbor[a];b&&!b.enable();)b=b.neighbor[a];b&&q(b),d="navigate"}}),c.isKey("space")&&c.keyup?(r(D),c.preventDefault(),c.stopPropagation(),d="execute"):c.isKey("space")&&D?(p(D),d="buttonpress"):E&&E!=D&&(p(null),d="selectcancel")}}else!c.keyup||!F&&a.hintDeactiveMainState||E&&(c.isKey("space")&&D==E||c.isKey(E.key))&&(r(E),c.preventDefault(),c.stopPropagation(),d="execute");return a.isIME=229==c.keyCode&&c.keydown,d}}var l=b.r(2),m=b.r(3),n=j.STATE_IDLE="idle",o="div";d.exports=j}},b[2]={value:function(a,c,d){function e(a){return"string"==typeof a?h(a):g(a)}function f(a,b){return a&&b&&e(a)==e(b)}function g(a){var b=0;return(a.ctrlKey||a.metaKey)&&(b|=j),a.altKey&&(b|=k),a.shiftKey&&(b|=l),-1==[16,17,18,91].indexOf(a.keyCode)&&(b|=a.keyCode),b}function h(a){var b=0;return a.toLowerCase().split(/\s*\+\s*/).forEach(function(a){switch(a){case"ctrl":case"cmd":b|=j;break;case"alt":b|=k;break;case"shift":b|=l;break;default:b|=i[a]}}),b}var i=b.r(4),j=4096,k=8192,l=16384;c.hash=e,c.is=f}},b[3]={value:function(a,c,d){function e(a){function b(){j=document.createElement("input"),j.classList.add(g),m.appendChild(j),l=!0}function c(){j.onkeyup=e,j.onkeypress=e,j.onkeydown=e,j.onfocus=h,j.onblur=i,l&&(j.oninput=function(a){j.value=null})}function d(){m.onmousedown=function(a){h(),a.preventDefault()}}function e(b){k&&a.dispatch(b)}function h(){j.select(),j.focus(),k=!0,m.classList.add(f)}function i(){j.blur(),k=!1,m.classList.remove(f)}var j,k=!0,l=!1,m=a.$container;b(),c(),d(),h(),this.handle=e,this.active=h,this.deactive=i}var f=(b.r(2),"hotbox-focus"),g="hotbox-key-receiver";d.exports=e}},b[4]={value:function(a,b,c){var d={Shift:16,Control:17,Alt:18,CapsLock:20,BackSpace:8,Tab:9,Enter:13,Esc:27,Space:32,PageUp:33,PageDown:34,End:35,Home:36,Insert:45,Left:37,Up:38,Right:39,Down:40,Direction:{37:1,38:1,39:1,40:1},Delete:46,NumLock:144,Cmd:91,CmdFF:224,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,"`":192,"=":187,"-":189,"/":191,".":190};for(var e in d)d.hasOwnProperty(e)&&(d[e.toLowerCase()]=d[e]);var f=65,g="a".charCodeAt(0);"abcdefghijklmnopqrstuvwxyz".split("").forEach(function(a){d[a]=f+(a.charCodeAt(0)-g)});var h=9;do d[h.toString()]=h+48;while(h--);c.exports=d}};var c={expose:0};a("expose")}();