cakejs2-spatial
Advanced tools
Comparing version 0.0.12 to 0.0.14
@@ -1,2 +0,2 @@ | ||
!function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){window.cake=require("../")},{"../":2}],2:[function(require,module,exports){module.exports=require("./lib/")},{"./lib/":8}],3:[function(require,module,exports){require("./zefir");var Cream=require("./cream"),Container=require("./container"),Mixer=require("./mixer"),bvd=require("./dom"),Cake=Cream.extend({_namespace:"cake",zefir:Container.inject("zefir"),tree:null,route:function(path,cream){return this.get("zefir").route(path,cream),this},create:function(opts){return opts=opts||{},this.set("opts",opts),this._createElement(opts.element),Mixer.run(),this._namespaceWatcher(),this._updateWatcher(),this.get("zefir").deviceWatcher(),this},destroy:function(){Mixer.stop(),this.set("zefir.current",null),this.set("zefir.routes",[]),this._removeTree()},render:function(){var cream=this.get("loaded");cream&&"function"==typeof cream.render&&(this.tree||this.opts.createRoot!==!1?this.tree&&this.opts.createRoot!==!1?bvd.patch(this.tree,bvd.diff(this.tree,this._createRoot(cream.render()))):bvd.patch(this.tree,bvd.diff(this.tree,cream.render())):(this.set("tree",cream.render()),this.element.appendChild(this.tree.render())),cream._didMount(this.tree),this._emitter.emit("didMount"))},_updateWatcher:function(){this.loaded&&this.loaded._updated===!0&&(this.render(),this.set("loaded._updated",!1)),Mixer.next(this._updateWatcher)},_namespaceWatcher:function(){var self=this,zefirRe=new RegExp(/^zefir.*/),cakeRe=new RegExp(/^cake.*/);this._emitter.on("setProp",function(name){if(self.loaded&&self.loaded._updated!==!0){if(name.match(zefirRe)||name.match(cakeRe))return;self.set("loaded._updated",!0)}}),this._emitter.on(/^register/,function(){self.get("zefir")&&(self.get("zefir").deviceWatcher(),self.get("zefir").locationWatcher(self.get("zefir.location")))})},_createElement:function(element){element||(element=document.getElementById("cake"),element&&document.body.removeChild(element),element=document.body),this.get("opts.createRoot")!==!1&&(this.set("tree",this._createRoot("")),element.appendChild(this.tree.render())),this.set("element",element)},_createRoot:function(children){return bvd.h("div",{className:this.opts.elementClass||"cake",id:this.opts.elementId||"cake"},children)},_removeTree:function(){this.tree&&(this.tree.el.parentNode.removeChild(this.tree.el),this.set("tree",null))},_unloadComponent:function(){if(this.get("loaded")){var cream=this.get("loaded");cream._didTransition(),delete cream.props,delete cream.params,this.set("loaded",null)}},_loadComponent:function(){var route=this.get("zefir.current");if(!route)return void this._unloadComponent();var cream=Container.inject(route.cream)();return cream?this.loaded===cream&&route.props===this.get("loaded.props")&&route.params===this.get("loaded.params")?(this.get("loaded")._didTransition(),void this.set("loaded._updated",!0)):(this._unloadComponent(),this.set("loaded",cream),cream.props=Container.inject("zefir.current.props"),cream.params=Container.inject("zefir.current.params"),cream._init(),cream._willTransition(),void this.set("loaded._updated",!0)):void this._unloadComponent()}.observes("zefir.current")});module.exports=Cake},{"./container":5,"./cream":6,"./dom":7,"./mixer":9,"./zefir":12}],4:[function(require,module,exports){var caramel=function(){this.listeners=[]};caramel.prototype.on=function(eventName,listener){this._subscribe(eventName,TYPE_MANY,listener)},caramel.prototype.once=function(eventName,listener){this._subscribe(eventName,TYPE_ONCE,listener)},caramel.prototype.emit=function(eventName,data){this._fireEvent(eventName,data)},caramel.prototype.has=function(eventName,listener){return!!this._listenerFor(eventName,listener)},caramel.prototype.off=function(eventName,listener){this._unsubscribe(eventName,listener)},caramel.prototype._fireEvent=function(eventName,data){if(("string"!=typeof eventName||eventName.length<1)&&!(eventName instanceof RegExp))throw new Error("Wrong arguments "+eventName);for(var i=0;i<this.listeners.length;i++){var event=this.listeners[i];(event.eventType===TYPE_REGEXP&&event.eventName.test(eventName)||event.eventType===TYPE_STRING&&event.eventName===eventName||event.eventType===TYPE_STRING&&eventName instanceof RegExp&&eventName.test(event.eventName))&&(event.listener(data),event.runType===TYPE_ONCE&&this._unsubscribe(event.eventName,event.listener))}},caramel.prototype._unsubscribe=function(eventName,listener){var i,toRemove=[];for(i=0;i<this.listeners.length;i++){var l=this.listeners[i],remove=!1;l.eventName===eventName?remove=!0:eventName instanceof RegExp&&eventName.test(l.eventName)&&(remove=!0),remove===!0&&("undefined"==typeof listener?toRemove.push(i):this.listeners[i].listener===listener&&toRemove.push(i))}for(i=toRemove.length-1;i>=0;i--)this.listeners.splice(toRemove[i],1)},caramel.prototype._subscribe=function(eventName,type,listener){if(!isValidProps(eventName,listener))throw new Error("Wrong arguments "+eventName+" "+listener);if(this.has(eventName,listener))throw new Error("Such listener already exists");if(this.listeners.length>=MAX_LISTENERS)throw new Error("Limit of the listeners exceed MAX_LISTENERS = "+MAX_LISTENERS);var event={eventName:eventName,listener:listener,runType:type,eventType:eventName instanceof RegExp?TYPE_REGEXP:TYPE_STRING};this.listeners.push(event)},caramel.prototype._listenerFor=function(eventName,listener){for(var i=0;i<this.listeners.length;i++)if(this.listeners[i].eventName===eventName&&this.listeners[i].listener===listener)return this.listeners[i]};var isValidEventName=function(eventName){return eventName&&("string"==typeof eventName||eventName instanceof RegExp)},isValidProps=function(eventName,listener){return isValidEventName(eventName)&&"function"==typeof listener},TYPE_ONCE=0,TYPE_MANY=1,TYPE_REGEXP=2,TYPE_STRING=3,MAX_LISTENERS=256;module.exports=caramel},{}],5:[function(require,module,exports){var Caramel=require("./caramel"),caramel=new Caramel,container={},observers=[];caramel.on("setProp",function(name){for(var i=0;i<observers.length;i++)for(var observer=observers[i],j=0;j<observer.prop.length;j++){var prop=observer.prop[j],longName=observer.cream._namespace+"."+prop;(longName===name||prop===name||prop instanceof RegExp&&prop.test(name))&&observer.fn()}});var createCream=function(name,obj){obj._namespace=name,observers=observers.concat(obj._observers),obj._emitter=caramel},removeCream=function(name,obj){obj._observers.length>0&&(observers=observers.filter(function(o){return obj._observers.indexOf(o)===-1})),obj._destroy()},register=function(name,obj,after){if("string"==typeof after&&!inject(after)())return void caramel.once("register:"+after,function(){register(name,obj)});for(var path=name.split("."),ref=container,i=0;i<path.length-1;i++)ref=ref[path[i]]?ref[path[i]]:ref[path[i]]={};ref[path[path.length-1]]?ref[path[path.length-1]].cream=obj:ref[path[path.length-1]]={cream:obj},createCream(name,obj),caramel.emit("register:"+name)},unregister=function(name){for(var path=name.split("."),ref=container,i=0;i<path.length-1;i++)if(!(ref=ref[path[i]]))return;"object"==typeof ref[path[path.length-1]]&&("Cream"===ref[path[path.length-1]]._type?removeCream(name,ref[path[path.length-1]].cream):ref[path[path.length-1]].cream&&"Cream"===ref[path[path.length-1]].cream._type&&(removeCream(name,ref[path[path.length-1]].cream),delete ref[path[path.length-1]].cream),delete ref[path[path.length-1]])},inject=function(name){var injection=function(){for(var path=name.split("."),ref=container,i=0;i<path.length;i++){if(!ref[path[i]]){if(ref.cream){ref=ref.cream,i--;continue}return}ref=ref[path[i]]}return ref.cream||ref};return injection.isInjection=!0,injection.namespace=name,injection};module.exports={_container:container,register:register,unregister:unregister,inject:inject}},{"./caramel":4}],6:[function(require,module,exports){require("./recipes/fn");var Container=require("./container"),Cream=function(){this._type="Cream",this._observers=[],this._namespace=null,this._emitter};Cream.prototype.get=function(name){for(var ref=this,path=name.split("."),i=0;i<path.length;i++)if("function"==typeof ref[path[i]]&&ref[path[i]].isInjection)ref=ref[path[i]]();else if(void 0===(ref=ref[path[i]]))return;return ref&&"object"==typeof ref&&ref.isProperty===!0?ref.fn.call(this):ref},Cream.prototype.set=function(name,value){return this._setProp(name,"set",value)},Cream.prototype.push=function(name){return this._setProp(name,"push",[].slice.call(arguments,1))},Cream.prototype.unshift=function(name){return this._setProp(name,"unshift",[].slice.call(arguments,1))},Cream.prototype.splice=function(name){return this._setProp(name,"splice",[].slice.call(arguments,1))},Cream.prototype.pop=function(name){return this._setProp(name,"pop",[].slice.call(arguments,1))},Cream.prototype.shift=function(name){return this._setProp(name,"shift",[].slice.call(arguments,1))},Cream.prototype._setProp=function(name,fnName,args){var result;if(this._isValidLocalProp(name))"set"===fnName?(this._getPropParent(name)[this._getPropName(name)]=args,result=!0):result=this.get(name)[fnName].apply(this.get(name),args),this.notifyPropertyChange(name);else{var nsRef=this._getPropertyRef(name);nsRef&&(result=nsRef.ref._setProp(nsRef.name,fnName,args))}return result},Cream.prototype._init=function(){"init"in this&&this.init()},Cream.prototype._destroy=function(){"destroy"in this&&this.destroy()},Cream.prototype._didTransition=function(){"didTransition"in this&&this.didTransition()},Cream.prototype._willTransition=function(){"willTransition"in this&&this.willTransition()},Cream.prototype._didMount=function(h){"didMount"in this&&this.didMount(h)},Cream.prototype.notifyPropertyChange=function(name){this._emitter.emit("setProp",this._namespace+"."+name)},Cream.prototype._isValidLocalProp=function(name){if(!this._namespace)throw new Error("Cream should be registered before you set something");if("string"!=typeof name||name.length<1)throw new Error("Tying to set value with wrong name");var prns=this._propNamespace(name);if(void 0===prns||prns===this._namespace)return!0},Cream.prototype._getPropertyRef=function(name){for(var nsRef,path=this._propAbsolutePath(name).split("."),i=path.length;i>=0;i--)if(nsRef=Container.inject(path.slice(0,i).join("."))(),nsRef instanceof Cream)return{ref:nsRef,name:path.slice(i).join(".")}},Cream.prototype._propAbsolutePath=function(name){var ns=this._propNamespace(name);if(ns){if(ns!==this._namespace){var nsName=name.split(".").slice(1).join(".");return nsName?ns+"."+name.split(".").slice(1).join("."):ns}return ns+"."+name}return name},Cream.prototype._getPropName=function(name){return name.split(".").pop()},Cream.prototype._getPropParent=function(name){for(var ref=this,path=name.split("."),i=0;i<path.length-1;i++)if(void 0===(ref=ref[path[i]]))return;return ref},Cream.prototype._propNamespace=function(name){var i,ref=this,path=name.split(".");for(i=0;i<path.length;i++){if(void 0===(ref=ref[path[i]]))return;if("function"==typeof ref&&ref.isInjection)return ref.namespace}return this._namespace},Cream.prototype._addObserver=function(observer){if(!(observer.prop.length<1)){var self=this;this._observers.push({cream:this,prop:observer.prop.map(function(p){return"string"==typeof p?self._propAbsolutePath(p):p}),fn:observer.fn.bind(this)})}},Cream.prototype.extend=function(obj){var newCream=Cream.extend(obj);for(var i in this)newCream[i]||(newCream[i]=this[i]);return newCream},Cream.extend=function(obj){var F=function(){};F.prototype=new Cream,F=new F;for(var i in obj){var descr=Object.getOwnPropertyDescriptor(obj,i);void 0!==descr&&(F[i]="function"!=typeof obj[i]||obj[i].isInjection?obj[i]:obj[i].bind(F),F[i]&&"object"==typeof F[i]&&F[i].isObserver===!0&&F._addObserver(F[i]))}return"_namespace"in obj&&("_after"in obj?Container.register(obj._namespace,F,obj._after):Container.register(obj._namespace,F)),F},module.exports=Cream},{"./container":5,"./recipes/fn":10}],7:[function(require,module,exports){var dom=require("spatial-virtual-dom");module.exports=dom},{"spatial-virtual-dom":13}],8:[function(require,module,exports){var Container=require("./container"),Cream=require("./cream"),Cake=require("./cake");module.exports={_container:Container._container,_mixer:require("./mixer"),h:require("./dom").h,spatial:require("./dom").spatial,next:require("./mixer").next,register:Container.register,unregister:Container.unregister,inject:Container.inject,Cream:Cream,create:Cake.create,destroy:Cake.destroy}},{"./cake":3,"./container":5,"./cream":6,"./dom":7,"./mixer":9}],9:[function(require,module,exports){var raf=require("./recipes/rafcaf").raf,caf=require("./recipes/rafcaf").caf,frame=null,nextQueue=[],isRunning=!1,nextTick=function(){for(var queue=nextQueue.splice(0),i=0;i<queue.length;i++){var task=queue[i];task&&"function"==typeof task&&task()}},run=function(){if(isRunning===!0)throw new Error("Mixer already running");isRunning=!0;var loop=function(){nextTick(),frame=raf(loop)};loop()},stop=function(){caf(frame),nextTick(),isRunning=!1},next=function(fn){nextQueue.push(fn)};module.exports={run:run,stop:stop,next:next}},{"./recipes/rafcaf":11}],10:[function(require,module,exports){Function.prototype.property=function(){return{isProperty:!0,fn:this}},Function.prototype.observes=function(){return{isProperty:!0,isObserver:!0,prop:[].slice.call(arguments),fn:this}}},{}],11:[function(require,module,exports){(function(global){var win;try{win=global.window||window}catch(e){win={}}var request=win.requestAnimationFrame||win.webkitRequestAnimationFrame||win.mozRequestAnimationFrame||win.oRequestAnimationFrame||win.msRequestAnimationFrame||function(callback){return setTimeout(function(){callback()},1e3/60)},cancel=win.cancelAnimationFrame||win.webkitCancelAnimationFrame||win.webkitCancelRequestAnimationFrame||win.mozCancelAnimationFrame||win.oCancelAnimationFrame||win.msCancelAnimationFrame||function(timeout){clearTimeout(timeout)},raf=function(){return request.apply(win,arguments)},caf=function(){return cancel.apply(win,arguments)};module.exports={raf:raf,caf:caf}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],12:[function(require,module,exports){var Cream=require("./cream"),next=require("./mixer").next,Zefir=Cream.extend({_namespace:"zefir",routes:[],location:"/",_createOrigin:function(url){var origin=url.replace(/^.+?\/\/+[^\/]+/,"").split(/[\/#]/).join("/").replace("//","").split(/[?]/);return{path:origin[0].replace(/\/$/g,"")||"/",params:decodeURIComponent(origin[1]||"")}},_pathProps:function(filter,path){if(path.match(new RegExp("^"+filter+"$")))return{};var f=new RegExp("^"+filter.replace(/:\w+/g,"(\\w+)").replace(/\//gi,"\\/")+"$"),props=path.match(f);if(props){var propNames={};return filter.match(/:\w+/).slice().map(function(p,i){p=p.replace(":",""),propNames[p]=props[i+1]}),propNames}},_queryProps:function(origin){for(var params={},tmp=origin.split(/[=&]/),i=0;i<tmp.length;i++)params[tmp[i]]=tmp[++i];return params},route:function(filter,cream){var r={filter:filter,cream:cream};"*"===filter?this.push("routes",r):this.unshift("routes",r),this.locationWatcher(this.location)},locationWatcher:function(location){var self=this,origin=this._createOrigin(location),route=this.get("routes").map(function(r){if("*"===r.filter)return{cream:r.cream,props:{},params:{}};var props=self._pathProps(r.filter,origin.path);return!!props&&{cream:r.cream,props:props,params:{}}}).filter(function(r){return r}).shift();route&&origin.params&&(route.params=this._queryProps(origin.params)),this.set("current",route)},deviceWatcher:function(){window&&window.location&&this.location!==window.location.href&&(this.location=String(window.location.href),this.locationWatcher(this.location)),next(this.deviceWatcher.bind(this))}});module.exports=Zefir},{"./cream":6,"./mixer":9}],13:[function(require,module,exports){exports.h=require("./lib/h").h,exports.diff=require("./lib/diff").diff,exports.patch=require("./lib/patch").patch,exports.spatial=require("./lib/h").spatial,exports.PATCH_CREATE=require("./lib/diff").PATCH_CREATE,exports.PATCH_REMOVE=require("./lib/diff").PATCH_REMOVE,exports.PATCH_REPLACE=require("./lib/diff").PATCH_REPLACE,exports.PATCH_REORDER=require("./lib/diff").PATCH_REORDER,exports.PATCH_PROPS=require("./lib/diff").PATCH_PROPS},{"./lib/diff":14,"./lib/h":15,"./lib/patch":16}],14:[function(require,module,exports){var PATCH_CREATE=0,PATCH_REMOVE=1,PATCH_REPLACE=2,PATCH_REORDER=3,PATCH_PROPS=4,diff=function(oldNode,newNode){if("undefined"==typeof oldNode||"undefined"==typeof newNode)throw new Error("cannot diff undefined nodes");if(!_isNodeSame(oldNode,newNode))throw new Error("unable create diff replace for root node");return _diffTree(oldNode,newNode,[])},_diffTree=function(a,b,patches){return _diffProps(a,b,patches),"text"===b.tag?void(b.children!==a.children&&patches.push({t:PATCH_REPLACE,node:a,with:b})):(Array.isArray(b.children)&&_diffChild(a.children,b.children,a,patches),patches)},_diffChild=function(a,b,pn,patches){var i,j,found,reorderMap=[];for(i=0;i<b.length;i++){for(found=!1,j=0;j<a.length;j++)if(_isNodeSame(a[j],b[i])&&reorderMap.indexOf(a[j])===-1){j!==i&&patches.push({t:PATCH_REORDER,from:j,to:i,node:_nodeId(pn),item:_nodeId(a[j])}),reorderMap.push(a[j]),_diffTree(a[j],b[i],patches),found=!0;break}found===!1&&(reorderMap.push(null),patches.push({t:PATCH_CREATE,to:i,node:_nodeId(pn),item:_nodeId("text"===b[i].tag?b[i]:b[i].clone())}))}for(i=0;i<a.length;i++)reorderMap.indexOf(a[i])===-1&&patches.push({t:PATCH_REMOVE,from:i,node:_nodeId(pn),item:_nodeId(a[i])})},_diffProps=function(a,b,patches){if(a&&b&&(a.props||b.props)){var i,toChange=[],toRemove=[],battrs=Object.keys(b.props),aattrs=Object.keys(a.props);for(i=0;i<battrs.length||i<aattrs.length;i++)i<battrs.length&&(battrs[i]in a.props&&b.props[battrs[i]]===a.props[battrs[i]]||toChange.push({name:battrs[i],value:b.props[battrs[i]]})),i<aattrs.length&&(aattrs[i]in b.props||toRemove.push({name:aattrs[i]}));toRemove.length>0&&patches.push({t:PATCH_PROPS,remove:toRemove,node:_nodeId(a)}),toChange.length>0&&patches.push({t:PATCH_PROPS,change:toChange,node:_nodeId(a)})}},_nodeId=function(node){return node},_isNodeSame=function(a,b){return a.tag===b.tag};exports.PATCH_CREATE=PATCH_CREATE,exports.PATCH_REMOVE=PATCH_REMOVE,exports.PATCH_REPLACE=PATCH_REPLACE,exports.PATCH_REORDER=PATCH_REORDER,exports.PATCH_PROPS=PATCH_PROPS,exports.diff=diff},{}],15:[function(require,module,exports){var sNavigator,spatial=function(config){var SpatialNavigator=require("./spatial");return config=config||{},sNavigator?sNavigator.setCollection(null):sNavigator=new SpatialNavigator(null,config),sNavigator.cfg=config,H},H=function(argv){return this instanceof H?argv[0]instanceof H?argv[0]:(this.tag=argv[0].toLowerCase(),this.props=argv[1]||{},void(null!==argv[2]&&void 0!==argv[2]&&argv.length>2&&("object"!=typeof argv[2]&&3===argv.length?this.children=[_createTextNode(argv[2])]:Array.isArray(argv[2])?this.children=argv[2]:this.children=[].concat.apply([],[].slice.call(argv,2,argv.length)).filter(function(n){return null!==n&&void 0!==n}).map(function(n){return n instanceof H?n:_createTextNode(n)})))):new H(arguments)};H.prototype.render=function(){var DOM=this.DOMrender.apply(this,arguments);return sNavigator&&(this.sn=sNavigator),DOM},H.prototype.removeSpatial=function(){sNavigator.remove(this.el)},H.prototype.DOMrender=function(node,parent){node=node||this,node.el=createElement(node.tag?node:this,parent);var children=node.children;if("object"==typeof children)for(var i=0;i<children.length;i++)node.el.appendChild(this.DOMrender(children[i],node.el));return node.el},H.prototype.setProp=function(name,value){"undefined"!=typeof this.el&&("className"===name?this.el.setAttribute("class",value):"style"===name&&"string"!=typeof value?this.el.setAttribute("style",_stylePropToString(value)):name.match(/^on/)?this.addEvent(name,value):"ref"===name?"function"==typeof value&&value(this.el):sNavigator&&"focusable"===name?(value===!0?(sNavigator.add(this.el),this.setProp("tabindex",0)):(sNavigator.remove(this.el),this.rmProp("tabindex")),this.el[name]=Boolean(value)):"boolean"==typeof value||"true"===value?(this.el.setAttribute(name,value),this.el[name]=Boolean(value)):this.el.setAttribute(name,value)),this.props[name]=value},H.prototype.setProps=function(props){for(var propNames=Object.keys(props),i=0;i<propNames.length;i++){var prop=propNames[i];this.setProp(prop,props[prop])}},H.prototype.rmProp=function(name){"undefined"!=typeof this.el&&("className"===name?this.el.removeAttribute("class"):name.match(/^on/)?this.removeEvent(name):"ref"===name||(sNavigator&&"focusable"===name?(sNavigator.remove(this.el),this.rmProp("tabindex"),delete this.el[name]):"boolean"==typeof value?(this.el.removeAttribute(name),delete this.el[name]):this.el.removeAttribute(name))),delete this.props[name]},H.prototype.addEvent=function(name,listener){name=name.slice(2).toLowerCase(),this.listeners=this.listeners||{},name in this.listeners&&this.removeEvent(name),this.listeners[name]=listener,this.el.addEventListener(name,listener)},H.prototype.removeEvent=function(name){name in this.listeners&&(this.el.removeEventListener(name,this.listeners[name]),delete this.listeners[name])},H.prototype.clone=function(){var node={tag:String(this.tag),props:_cloneProps(this.props)};return"undefined"!=typeof this.children&&(node.children="text"===this.tag?String(this.children):this.children.map(function(child){return"text"===child.tag?_createTextNode(child.children):child.clone()})),H(node.tag,node.props,node.children)};var _cloneProps=function(props,keepRefs){"undefined"==typeof keepRefs&&(keepRefs=!0);var i,name,attrs=Object.keys(props),cloned={};for(i=0;i<attrs.length;i++)name=attrs[i],"string"==typeof props[name]?cloned[name]=String(props[name]):"function"==typeof props[name]&&keepRefs===!0?cloned[name]=props[name]:"boolean"==typeof props[name]?cloned[name]=Boolean(props[name]):"object"==typeof props[name]&&(cloned[name]=_cloneProps(props[name]));return cloned},_stylePropToString=function(props){for(var out="",attrs=Object.keys(props),i=0;i<attrs.length;i++)out+=attrs[i].replace(/([A-Z])/g,"-$1").toLowerCase(),out+=":",out+=props[attrs[i]],out+=";";return out},_createTextNode=function(text){return{tag:"text",children:String(text)}},createElement=function(node,parent){return node.el="text"===node.tag?document.createTextNode(node.children):document.createElement(node.tag),"undefined"!=typeof node.props&&node.setProps(node.props),"undefined"!=typeof parent&&parent.appendChild(node.el),node.el};exports.h=H,exports.spatial=spatial,exports.createElement=createElement},{"./spatial":17}],16:[function(require,module,exports){var PATCH_CREATE=require("./diff").PATCH_CREATE,PATCH_REMOVE=require("./diff").PATCH_REMOVE,PATCH_REPLACE=require("./diff").PATCH_REPLACE,PATCH_REORDER=require("./diff").PATCH_REORDER,PATCH_PROPS=require("./diff").PATCH_PROPS,createElement=require("./h").createElement,patch=function(tree,patches){var render=!0;"undefined"==typeof tree.el&&(render=!1);for(var i=0;i<patches.length;i++){var p=patches[i];switch(p.t){case PATCH_REORDER:_patchReorder(p,render);break;case PATCH_CREATE:_patchCreate(p,render);break;case PATCH_REMOVE:_patchRemove(p,render);break;case PATCH_REPLACE:_patchReplace(p,render);break;case PATCH_PROPS:_patchProps(p,render)}}},_patchReplace=function(p,render){p.node.children=String(p.with.children),render===!0&&(p.node.el.nodeValue=String(p.with.children))},_patchReorder=function(p,render){render===!0&&p.node.el.insertBefore(p.item.el,p.node.el.childNodes[p.to]),p.node.children.splice(p.to,0,p.node.children.splice(p.node.children.indexOf(p.item),1)[0])},_patchCreate=function(p,render){var element;render===!0&&(element="text"===p.item.tag?createElement(p.item):p.item.render()),p.node.children.length-1<p.to?(p.node.children.push(p.item),render===!0&&p.node.el.appendChild(element)):(p.node.children.splice(p.to,0,p.item),render===!0&&p.node.el.insertBefore(element,p.node.el.childNodes[p.to]))},_patchRemove=function(p,render){render===!0&&(p.item.props&&"focusable"in p.item.props&&p.item.removeSpatial(),p.node.el.removeChild(p.item.el));for(var i=0;i<p.node.children.length;i++)p.node.children[i]===p.item&&p.node.children.splice(i,1)},_patchProps=function(p){var i;if("remove"in p)for(i=0;i<p.remove.length;i++)p.node.rmProp(p.remove[i].name);else if("change"in p)for(i=0;i<p.change.length;i++)p.node.setProp(p.change[i].name,p.change[i].value);else;};exports.patch=patch},{"./diff":14,"./h":15}],17:[function(require,module,exports){function SpatialNavigator(collection,config){this._focus=null,this._previous=null,config=config||{},this.setCollection(collection);for(var key in config)this[key]=config[key];window.addEventListener("click",this.evClick.bind(this),!0),window.addEventListener("keydown",this.evKey.bind(this),!0),this.autofocus&&this.autofocus===!0&&window.addEventListener("click",function(){this.focus()}.bind(this))}!function(){function CustomEvent(event,params){params=params||{bubbles:!1,cancelable:!1,detail:void 0};var evt=document.createEvent("CustomEvent");return evt.initCustomEvent(event,params.bubbles,params.cancelable,params.detail),evt}return"function"!=typeof window.CustomEvent&&(CustomEvent.prototype=window.Event.prototype,void(window.CustomEvent=CustomEvent))}(),SpatialNavigator.prototype={cfg:{},straightOnly:!1,straightOverlapThreshold:.5,ignoreHiddenElement:!1,rememberSource:!1,navigableFilter:null,silent:!1,evKey:function(evt){var code=evt.charCode||evt.keyCode;switch(code){case this.cfg.keys.DOWN:this.move("down");break;case this.cfg.keys.UP:this.move("up");break;case this.cfg.keys.LEFT:this.move("left");break;case this.cfg.keys.RIGHT:this.move("right");break;case this.cfg.keys.ENTER:this._collection.indexOf(evt.target)!==-1&&this.fire("enter",evt.target)}return!0},evClick:function(evt){return this.fire("enter",evt.target),this.focus(evt.target)},fire:function(evtName,elem){"unfocus"===evtName&&elem.blur(),"focus"===evtName&&elem.focus();var evt=new window.CustomEvent(evtName,{detail:{name:evtName,element:elem}});return elem.dispatchEvent(evt)},_getRect:function(elem){var rect=null;if(!this._isNavigable(elem))return null;if(elem.getBoundingClientRect){var cr=elem.getBoundingClientRect();rect={left:cr.left,top:cr.top,width:cr.width,height:cr.height}}else{if(void 0===elem.left)return null;rect={left:parseInt(elem.left||0,10),top:parseInt(elem.top||0,10),width:parseInt(elem.width||0,10),height:parseInt(elem.height||0,10)}}return rect.element=elem,rect.right=rect.left+rect.width,rect.bottom=rect.top+rect.height,rect.center={x:rect.left+Math.floor(rect.width/2),y:rect.top+Math.floor(rect.height/2)},rect.center.left=rect.center.right=rect.center.x,rect.center.top=rect.center.bottom=rect.center.y,rect},_getAllRects:function(excludedElem){var rects=[];return this._collection.forEach(function(elem){if(!excludedElem||excludedElem!==elem){var rect=this._getRect(elem);rect&&rects.push(rect)}},this),rects},_isNavigable:function(elem){if(this.ignoreHiddenElement&&elem instanceof window.HTMLElement){var computedStyle=window.getComputedStyle(elem);if(elem.offsetWidth<=0&&elem.offsetHeight<=0||"hidden"===computedStyle.getPropertyValue("visibility")||"none"===computedStyle.getPropertyValue("display")||elem.hasAttribute("aria-hidden"))return!1}return!(this.navigableFilter&&!this.navigableFilter(elem))},_partition:function(rects,targetRect){var groups=[[],[],[],[],[],[],[],[],[]],threshold=this.straightOverlapThreshold;return(threshold>1||threshold<0)&&(threshold=.5),rects.forEach(function(rect){var x,y,groupId,center=rect.center;x=center.x<targetRect.left?0:center.x<=targetRect.right?1:2,y=center.y<targetRect.top?0:center.y<=targetRect.bottom?1:2,groupId=3*y+x,groups[groupId].push(rect),[0,2,6,8].indexOf(groupId)!==-1&&(rect.left<=targetRect.right-targetRect.width*threshold&&(2===groupId?groups[1].push(rect):8===groupId&&groups[7].push(rect)),rect.right>=targetRect.left+targetRect.width*threshold&&(0===groupId?groups[1].push(rect):6===groupId&&groups[7].push(rect)),rect.top<=targetRect.bottom-targetRect.height*threshold&&(6===groupId?groups[3].push(rect):8===groupId&&groups[5].push(rect)),rect.bottom>=targetRect.top+targetRect.height*threshold&&(0===groupId?groups[3].push(rect):2===groupId&&groups[5].push(rect)))}),groups},_getDistanceFunction:function(targetRect){return{nearPlumbLineIsBetter:function(rect){var d;return d=rect.center.x<targetRect.center.x?targetRect.center.x-rect.right:rect.left-targetRect.center.x,d<0?0:d},nearHorizonIsBetter:function(rect){var d;return d=rect.center.y<targetRect.center.y?targetRect.center.y-rect.bottom:rect.top-targetRect.center.y,d<0?0:d},nearTargetLeftIsBetter:function(rect){var d;return d=rect.center.x<targetRect.center.x?targetRect.left-rect.right:rect.left-targetRect.left,d<0?0:d},nearTargetTopIsBetter:function(rect){var d;return d=rect.center.y<targetRect.center.y?targetRect.top-rect.bottom:rect.top-targetRect.top,d<0?0:d},topIsBetter:function(rect){return rect.top},bottomIsBetter:function(rect){return-1*rect.bottom},leftIsBetter:function(rect){return rect.left},rightIsBetter:function(rect){return-1*rect.right}}},_prioritize:function(priorities,target,direction){for(var destPriority=null,i=0;i<priorities.length;i++)if(priorities[i].group.length){destPriority=priorities[i];break}if(!destPriority)return null;if(this.rememberSource&&this._previous&&target===this._previous.destination&&direction===this._previous.reverse){var source=this._previous.source,found=destPriority.group.find(function(dest){return dest.element===source});if(found)return found}return destPriority.group.sort(function(a,b){return destPriority.distance.reduce(function(answer,distance){return answer||distance(a)-distance(b)},0)}),destPriority.group[0]},setCollection:function(collection){this.unfocus(),this._collection=[],collection&&this.multiAdd(collection)},add:function(elem){var index=this._collection.indexOf(elem);return!(index>=0)&&(this._collection.push(elem),!0)},multiAdd:function(elements){return elements.every(this.add,this)},remove:function(elem){var index=this._collection.indexOf(elem);return!(index<0)&&(this._focus===elem&&this.unfocus(),this._collection.splice(index,1),!0)},multiRemove:function(elements){return Array.from(elements).every(this.remove,this)},focus:function(elem){if(!elem&&this._focus&&this._isNavigable(this._focus)&&(elem=this._focus),!this._collection)return!1;if(elem){if(this._collection.indexOf(elem)<0||!this._isNavigable(elem))return!1}else{var navigableElems=this._collection.filter(this._isNavigable,this);if(!navigableElems.length)return!1;elem=navigableElems[0]}return this.unfocus(),this._focus=elem,this.silent||this.fire("focus",this._focus),!0},unfocus:function(){if(this._focus){var elem=this._focus;this._focus=null,this.silent||this.fire("unfocus",elem)}return!0},getFocusedElement:function(){return this._focus},move:function(direction){var reverse={left:"right",up:"down",right:"left",down:"up"};if(this._focus){var elem=this.navigate(this._focus,direction);if(!elem)return!1;this.rememberSource&&(this._previous={source:this._focus,destination:elem,reverse:reverse[direction.toLowerCase()]}),this.unfocus(),this.focus(elem)}else this._previous=null,this.focus();return!0},navigate:function(target,direction){if(!target||!direction||!this._collection)return null;direction=direction.toLowerCase();var rects=this._getAllRects(target),targetRect=this._getRect(target);if(!targetRect||!rects.length)return null;var priorities,distanceFunction=this._getDistanceFunction(targetRect),groups=this._partition(rects,targetRect),internalGroups=this._partition(groups[4],targetRect.center); | ||
switch(direction){case"left":priorities=[{group:internalGroups[0].concat(internalGroups[3]).concat(internalGroups[6]),distance:[distanceFunction.nearPlumbLineIsBetter,distanceFunction.topIsBetter]},{group:groups[3],distance:[distanceFunction.nearPlumbLineIsBetter,distanceFunction.topIsBetter]},{group:groups[0].concat(groups[6]),distance:[distanceFunction.nearHorizonIsBetter,distanceFunction.rightIsBetter,distanceFunction.nearTargetTopIsBetter]}];break;case"right":priorities=[{group:internalGroups[2].concat(internalGroups[5]).concat(internalGroups[8]),distance:[distanceFunction.nearPlumbLineIsBetter,distanceFunction.topIsBetter]},{group:groups[5],distance:[distanceFunction.nearPlumbLineIsBetter,distanceFunction.topIsBetter]},{group:groups[2].concat(groups[8]),distance:[distanceFunction.nearHorizonIsBetter,distanceFunction.leftIsBetter,distanceFunction.nearTargetTopIsBetter]}];break;case"up":priorities=[{group:internalGroups[0].concat(internalGroups[1]).concat(internalGroups[2]),distance:[distanceFunction.nearHorizonIsBetter,distanceFunction.leftIsBetter]},{group:groups[1],distance:[distanceFunction.nearHorizonIsBetter,distanceFunction.leftIsBetter]},{group:groups[0].concat(groups[2]),distance:[distanceFunction.nearPlumbLineIsBetter,distanceFunction.bottomIsBetter,distanceFunction.nearTargetLeftIsBetter]}];break;case"down":priorities=[{group:internalGroups[6].concat(internalGroups[7]).concat(internalGroups[8]),distance:[distanceFunction.nearHorizonIsBetter,distanceFunction.leftIsBetter]},{group:groups[7],distance:[distanceFunction.nearHorizonIsBetter,distanceFunction.leftIsBetter]},{group:groups[6].concat(groups[8]),distance:[distanceFunction.nearPlumbLineIsBetter,distanceFunction.topIsBetter,distanceFunction.nearTargetLeftIsBetter]}];break;default:return null}this.straightOnly&&priorities.pop();var dest=this._prioritize(priorities,target,direction);return dest?dest.element:null}},module.exports=SpatialNavigator},{}]},{},[1]); | ||
!function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){window.cake=require("../")},{"../":2}],2:[function(require,module,exports){module.exports=require("./lib/")},{"./lib/":8}],3:[function(require,module,exports){require("./zefir");var Cream=require("./cream"),Container=require("./container"),Mixer=require("./mixer"),bvd=require("./dom"),Cake=Cream.extend({_namespace:"cake",zefir:Container.inject("zefir"),tree:null,route:function(path,cream){return this.get("zefir").route(path,cream),this},create:function(opts){return opts=opts||{},this.set("opts",opts),this._createElement(opts.element),Mixer.run(),this._namespaceWatcher(),this._updateWatcher(),this.get("zefir").deviceWatcher(),this},destroy:function(){Mixer.stop(),this.set("zefir.current",null),this.set("zefir.routes",[]),this._removeTree()},render:function(){var cream=this.get("loaded");cream&&"function"==typeof cream.render&&(this.tree||this.opts.createRoot!==!1?this.tree&&this.opts.createRoot!==!1?bvd.patch(this.tree,bvd.diff(this.tree,this._createRoot(cream.render()))):bvd.patch(this.tree,bvd.diff(this.tree,cream.render())):(this.set("tree",cream.render()),this.element.appendChild(this.tree.render())),cream._didMount(this.tree),this._emitter.emit("didMount"))},_updateWatcher:function(){this.loaded&&this.loaded._updated===!0&&(this.render(),this.set("loaded._updated",!1)),Mixer.next(this._updateWatcher)},_namespaceWatcher:function(){var self=this,zefirRe=new RegExp(/^zefir.*/),cakeRe=new RegExp(/^cake.*/);this._emitter.on("setProp",function(name){if(self.loaded&&self.loaded._updated!==!0){if(name.match(zefirRe)||name.match(cakeRe))return;self.set("loaded._updated",!0)}}),this._emitter.on(/^register/,function(){self.get("zefir")&&(self.get("zefir").deviceWatcher(),self.get("zefir").locationWatcher(self.get("zefir.location")))})},_createElement:function(element){element||(element=document.getElementById("cake"),element&&document.body.removeChild(element),element=document.body),this.get("opts.createRoot")!==!1&&(this.set("tree",this._createRoot("")),element.appendChild(this.tree.render())),this.set("element",element)},_createRoot:function(children){return bvd.h("div",{className:this.opts.elementClass||"cake",id:this.opts.elementId||"cake"},children)},_removeTree:function(){this.tree&&(this.tree.el.parentNode.removeChild(this.tree.el),this.set("tree",null))},_unloadComponent:function(){if(this.get("loaded")){var cream=this.get("loaded");cream._didTransition(),delete cream.props,delete cream.params,this.set("loaded",null)}},_loadComponent:function(){var route=this.get("zefir.current");if(!route)return void this._unloadComponent();var cream=Container.inject(route.cream)();return cream?this.loaded===cream&&route.props===this.get("loaded.props")&&route.params===this.get("loaded.params")?(this.get("loaded")._didTransition(),void this.set("loaded._updated",!0)):(this._unloadComponent(),this.set("loaded",cream),cream.props=Container.inject("zefir.current.props"),cream.params=Container.inject("zefir.current.params"),cream._init(),cream._willTransition(),void this.set("loaded._updated",!0)):void this._unloadComponent()}.observes("zefir.current")});module.exports=Cake},{"./container":5,"./cream":6,"./dom":7,"./mixer":9,"./zefir":12}],4:[function(require,module,exports){var caramel=function(){this.listeners=[]};caramel.prototype.on=function(eventName,listener){this._subscribe(eventName,TYPE_MANY,listener)},caramel.prototype.once=function(eventName,listener){this._subscribe(eventName,TYPE_ONCE,listener)},caramel.prototype.emit=function(eventName,data){this._fireEvent(eventName,data)},caramel.prototype.has=function(eventName,listener){return!!this._listenerFor(eventName,listener)},caramel.prototype.off=function(eventName,listener){this._unsubscribe(eventName,listener)},caramel.prototype._fireEvent=function(eventName,data){if(("string"!=typeof eventName||eventName.length<1)&&!(eventName instanceof RegExp))throw new Error("Wrong arguments "+eventName);for(var i=0;i<this.listeners.length;i++){var event=this.listeners[i];(event.eventType===TYPE_REGEXP&&event.eventName.test(eventName)||event.eventType===TYPE_STRING&&event.eventName===eventName||event.eventType===TYPE_STRING&&eventName instanceof RegExp&&eventName.test(event.eventName))&&(event.listener(data),event.runType===TYPE_ONCE&&this._unsubscribe(event.eventName,event.listener))}},caramel.prototype._unsubscribe=function(eventName,listener){var i,toRemove=[];for(i=0;i<this.listeners.length;i++){var l=this.listeners[i],remove=!1;l.eventName===eventName?remove=!0:eventName instanceof RegExp&&eventName.test(l.eventName)&&(remove=!0),remove===!0&&("undefined"==typeof listener?toRemove.push(i):this.listeners[i].listener===listener&&toRemove.push(i))}for(i=toRemove.length-1;i>=0;i--)this.listeners.splice(toRemove[i],1)},caramel.prototype._subscribe=function(eventName,type,listener){if(!isValidProps(eventName,listener))throw new Error("Wrong arguments "+eventName+" "+listener);if(this.has(eventName,listener))throw new Error("Such listener already exists");if(this.listeners.length>=MAX_LISTENERS)throw new Error("Limit of the listeners exceed MAX_LISTENERS = "+MAX_LISTENERS);var event={eventName:eventName,listener:listener,runType:type,eventType:eventName instanceof RegExp?TYPE_REGEXP:TYPE_STRING};this.listeners.push(event)},caramel.prototype._listenerFor=function(eventName,listener){for(var i=0;i<this.listeners.length;i++)if(this.listeners[i].eventName===eventName&&this.listeners[i].listener===listener)return this.listeners[i]};var isValidEventName=function(eventName){return eventName&&("string"==typeof eventName||eventName instanceof RegExp)},isValidProps=function(eventName,listener){return isValidEventName(eventName)&&"function"==typeof listener},TYPE_ONCE=0,TYPE_MANY=1,TYPE_REGEXP=2,TYPE_STRING=3,MAX_LISTENERS=256;module.exports=caramel},{}],5:[function(require,module,exports){var Caramel=require("./caramel"),caramel=new Caramel,container={},observers=[];caramel.on("setProp",function(name){for(var i=0;i<observers.length;i++)for(var observer=observers[i],j=0;j<observer.prop.length;j++){var prop=observer.prop[j],longName=observer.cream._namespace+"."+prop;(longName===name||prop===name||prop instanceof RegExp&&prop.test(name))&&observer.fn()}});var createCream=function(name,obj){obj._namespace=name,observers=observers.concat(obj._observers),obj._emitter=caramel},removeCream=function(name,obj){obj._observers.length>0&&(observers=observers.filter(function(o){return obj._observers.indexOf(o)===-1})),obj._destroy()},register=function(name,obj,after){if("string"==typeof after&&!inject(after)())return void caramel.once("register:"+after,function(){register(name,obj)});for(var path=name.split("."),ref=container,i=0;i<path.length-1;i++)ref=ref[path[i]]?ref[path[i]]:ref[path[i]]={};ref[path[path.length-1]]?ref[path[path.length-1]].cream=obj:ref[path[path.length-1]]={cream:obj},createCream(name,obj),caramel.emit("register:"+name)},unregister=function(name){for(var path=name.split("."),ref=container,i=0;i<path.length-1;i++)if(!(ref=ref[path[i]]))return;"object"==typeof ref[path[path.length-1]]&&("Cream"===ref[path[path.length-1]]._type?removeCream(name,ref[path[path.length-1]].cream):ref[path[path.length-1]].cream&&"Cream"===ref[path[path.length-1]].cream._type&&(removeCream(name,ref[path[path.length-1]].cream),delete ref[path[path.length-1]].cream),delete ref[path[path.length-1]])},inject=function(name){var injection=function(){for(var path=name.split("."),ref=container,i=0;i<path.length;i++){if(!ref[path[i]]){if(ref.cream){ref=ref.cream,i--;continue}return}ref=ref[path[i]]}return ref.cream||ref};return injection.isInjection=!0,injection.namespace=name,injection};module.exports={_container:container,register:register,unregister:unregister,inject:inject}},{"./caramel":4}],6:[function(require,module,exports){require("./recipes/fn");var Container=require("./container"),Cream=function(){this._type="Cream",this._observers=[],this._namespace=null,this._emitter};Cream.prototype.get=function(name){for(var ref=this,path=name.split("."),i=0;i<path.length;i++)if("function"==typeof ref[path[i]]&&ref[path[i]].isInjection)ref=ref[path[i]]();else if(void 0===(ref=ref[path[i]]))return;return ref&&"object"==typeof ref&&ref.isProperty===!0?ref.fn.call(this):ref},Cream.prototype.set=function(name,value){return this._setProp(name,"set",value)},Cream.prototype.push=function(name){return this._setProp(name,"push",[].slice.call(arguments,1))},Cream.prototype.unshift=function(name){return this._setProp(name,"unshift",[].slice.call(arguments,1))},Cream.prototype.splice=function(name){return this._setProp(name,"splice",[].slice.call(arguments,1))},Cream.prototype.pop=function(name){return this._setProp(name,"pop",[].slice.call(arguments,1))},Cream.prototype.shift=function(name){return this._setProp(name,"shift",[].slice.call(arguments,1))},Cream.prototype._setProp=function(name,fnName,args){var result;if(this._isValidLocalProp(name))"set"===fnName?(this._getPropParent(name)[this._getPropName(name)]=args,result=!0):result=this.get(name)[fnName].apply(this.get(name),args),this.notifyPropertyChange(name);else{var nsRef=this._getPropertyRef(name);nsRef&&(result=nsRef.ref._setProp(nsRef.name,fnName,args))}return result},Cream.prototype._init=function(){"init"in this&&this.init()},Cream.prototype._destroy=function(){"destroy"in this&&this.destroy()},Cream.prototype._didTransition=function(){"didTransition"in this&&this.didTransition()},Cream.prototype._willTransition=function(){"willTransition"in this&&this.willTransition()},Cream.prototype._didMount=function(h){"didMount"in this&&this.didMount(h)},Cream.prototype.notifyPropertyChange=function(name){this._emitter.emit("setProp",this._namespace+"."+name)},Cream.prototype._isValidLocalProp=function(name){if(!this._namespace)throw new Error("Cream should be registered before you set something");if("string"!=typeof name||name.length<1)throw new Error("Tying to set value with wrong name");var prns=this._propNamespace(name);if(void 0===prns||prns===this._namespace)return!0},Cream.prototype._getPropertyRef=function(name){for(var nsRef,path=this._propAbsolutePath(name).split("."),i=path.length;i>=0;i--)if(nsRef=Container.inject(path.slice(0,i).join("."))(),nsRef instanceof Cream)return{ref:nsRef,name:path.slice(i).join(".")}},Cream.prototype._propAbsolutePath=function(name){var ns=this._propNamespace(name);if(ns){if(ns!==this._namespace){var nsName=name.split(".").slice(1).join(".");return nsName?ns+"."+name.split(".").slice(1).join("."):ns}return ns+"."+name}return name},Cream.prototype._getPropName=function(name){return name.split(".").pop()},Cream.prototype._getPropParent=function(name){for(var ref=this,path=name.split("."),i=0;i<path.length-1;i++)if(void 0===(ref=ref[path[i]]))return;return ref},Cream.prototype._propNamespace=function(name){var i,ref=this,path=name.split(".");for(i=0;i<path.length;i++){if(void 0===(ref=ref[path[i]]))return;if("function"==typeof ref&&ref.isInjection)return ref.namespace}return this._namespace},Cream.prototype._addObserver=function(observer){if(!(observer.prop.length<1)){var self=this;this._observers.push({cream:this,prop:observer.prop.map(function(p){return"string"==typeof p?self._propAbsolutePath(p):p}),fn:observer.fn.bind(this)})}},Cream.prototype.extend=function(obj){var newCream=Cream.extend(obj);for(var i in this)newCream[i]||(newCream[i]=this[i]);return newCream},Cream.extend=function(obj){var F=function(){};F.prototype=new Cream,F=new F;for(var i in obj){var descr=Object.getOwnPropertyDescriptor(obj,i);void 0!==descr&&(F[i]="function"!=typeof obj[i]||obj[i].isInjection?obj[i]:obj[i].bind(F),F[i]&&"object"==typeof F[i]&&F[i].isObserver===!0&&F._addObserver(F[i]))}return"_namespace"in obj&&("_after"in obj?Container.register(obj._namespace,F,obj._after):Container.register(obj._namespace,F)),F},module.exports=Cream},{"./container":5,"./recipes/fn":10}],7:[function(require,module,exports){var dom=require("spatial-virtual-dom");module.exports=dom},{"spatial-virtual-dom":13}],8:[function(require,module,exports){var Container=require("./container"),Cream=require("./cream"),Cake=require("./cake");module.exports={_container:Container._container,_mixer:require("./mixer"),h:require("./dom").h,spatial:require("./dom").spatial,next:require("./mixer").next,register:Container.register,unregister:Container.unregister,inject:Container.inject,Cream:Cream,create:Cake.create,destroy:Cake.destroy}},{"./cake":3,"./container":5,"./cream":6,"./dom":7,"./mixer":9}],9:[function(require,module,exports){var raf=require("./recipes/rafcaf").raf,caf=require("./recipes/rafcaf").caf,frame=null,nextQueue=[],isRunning=!1,nextTick=function(){for(var queue=nextQueue.splice(0),i=0;i<queue.length;i++){var task=queue[i];task&&"function"==typeof task&&task()}},run=function(){if(isRunning===!0)throw new Error("Mixer already running");isRunning=!0;var loop=function(){nextTick(),frame=raf(loop)};loop()},stop=function(){caf(frame),nextTick(),isRunning=!1},next=function(fn){nextQueue.push(fn)};module.exports={run:run,stop:stop,next:next}},{"./recipes/rafcaf":11}],10:[function(require,module,exports){Function.prototype.property=function(){return{isProperty:!0,fn:this}},Function.prototype.observes=function(){return{isProperty:!0,isObserver:!0,prop:[].slice.call(arguments),fn:this}}},{}],11:[function(require,module,exports){(function(global){var win;try{win=global.window||window}catch(e){win={}}var request=win.requestAnimationFrame||win.webkitRequestAnimationFrame||win.mozRequestAnimationFrame||win.oRequestAnimationFrame||win.msRequestAnimationFrame||function(callback){return setTimeout(function(){callback()},1e3/60)},cancel=win.cancelAnimationFrame||win.webkitCancelAnimationFrame||win.webkitCancelRequestAnimationFrame||win.mozCancelAnimationFrame||win.oCancelAnimationFrame||win.msCancelAnimationFrame||function(timeout){clearTimeout(timeout)},raf=function(){return request.apply(win,arguments)},caf=function(){return cancel.apply(win,arguments)};module.exports={raf:raf,caf:caf}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],12:[function(require,module,exports){var Cream=require("./cream"),next=require("./mixer").next,Zefir=Cream.extend({_namespace:"zefir",routes:[],location:"/",_createOrigin:function(url){var origin;return url.match(/\#/)&&(url="-//-/#"+url.split("#")[1]),origin=url.replace(/^.+?\/\/+[^\/]+/,"").split(/[\/#]/).join("/").replace("//","").split(/[?]/),{path:origin[0].replace(/\/$/g,"")||"/",params:decodeURIComponent(origin[1]||"")}},_pathProps:function(filter,path){if(path.match(new RegExp("^"+filter+"$")))return{};var f=new RegExp("^"+filter.replace(/:\w+/g,"(\\w+)").replace(/\//gi,"\\/")+"$"),props=path.match(f);if(props){var propNames={};return filter.match(/:\w+/).slice().map(function(p,i){p=p.replace(":",""),propNames[p]=props[i+1]}),propNames}},_queryProps:function(origin){for(var params={},tmp=origin.split(/[=&]/),i=0;i<tmp.length;i++)params[tmp[i]]=tmp[++i];return params},route:function(filter,cream){var r={filter:filter,cream:cream};"*"===filter?this.push("routes",r):this.unshift("routes",r),this.locationWatcher(this.location)},locationWatcher:function(location){var self=this,origin=this._createOrigin(location),route=this.get("routes").map(function(r){if("*"===r.filter)return{cream:r.cream,props:{},params:{}};var props=self._pathProps(r.filter,origin.path);return!!props&&{cream:r.cream,props:props,params:{}}}).filter(function(r){return r}).shift();route&&origin.params&&(route.params=this._queryProps(origin.params)),this.set("current",route)},deviceWatcher:function(){window&&window.location&&this.location!==window.location.href&&(this.location=String(window.location.href),this.locationWatcher(this.location)),next(this.deviceWatcher.bind(this))}});module.exports=Zefir},{"./cream":6,"./mixer":9}],13:[function(require,module,exports){exports.h=require("./lib/h").h,exports.diff=require("./lib/diff").diff,exports.patch=require("./lib/patch").patch,exports.spatial=require("./lib/h").spatial,exports.PATCH_CREATE=require("./lib/diff").PATCH_CREATE,exports.PATCH_REMOVE=require("./lib/diff").PATCH_REMOVE,exports.PATCH_REPLACE=require("./lib/diff").PATCH_REPLACE,exports.PATCH_REORDER=require("./lib/diff").PATCH_REORDER,exports.PATCH_PROPS=require("./lib/diff").PATCH_PROPS},{"./lib/diff":14,"./lib/h":15,"./lib/patch":16}],14:[function(require,module,exports){var PATCH_CREATE=0,PATCH_REMOVE=1,PATCH_REPLACE=2,PATCH_REORDER=3,PATCH_PROPS=4,diff=function(oldNode,newNode){if("undefined"==typeof oldNode||"undefined"==typeof newNode)throw new Error("cannot diff undefined nodes");if(!_isNodeSame(oldNode,newNode))throw new Error("unable create diff replace for root node");return _diffTree(oldNode,newNode,[])},_diffTree=function(a,b,patches){if(_diffProps(a,b,patches),"text"===b.tag)return void(b.children!==a.children&&patches.push({t:PATCH_REPLACE,node:a,with:b}));if(Array.isArray(b.children))_diffChild(a.children,b.children,a,patches);else if(Array.isArray(a.children))for(var i=0;i<a.children.length;i++)patches.push({t:PATCH_REMOVE,from:i,node:_nodeId(a),item:_nodeId(a.children[i])});return patches},_diffChild=function(a,b,pn,patches){var i,j,found,reorderMap=[];for(i=0;i<b.length;i++)if(found=!1,a){for(j=0;j<a.length;j++)if(_isNodeSame(a[j],b[i])&&reorderMap.indexOf(a[j])===-1){j!==i&&patches.push({t:PATCH_REORDER,from:j,to:i,node:_nodeId(pn),item:_nodeId(a[j])}),reorderMap.push(a[j]),_diffTree(a[j],b[i],patches),found=!0;break}found===!1&&(reorderMap.push(null),patches.push({t:PATCH_CREATE,to:i,node:_nodeId(pn),item:_nodeId("text"===b[i].tag?b[i]:b[i].clone())}))}else pn.children||(pn.children=[]),patches.push({t:PATCH_CREATE,to:i,node:_nodeId(pn),item:_nodeId(b[i].clone())});if(a)for(i=0;i<a.length;i++)reorderMap.indexOf(a[i])===-1&&patches.push({t:PATCH_REMOVE,from:i,node:_nodeId(pn),item:_nodeId(a[i])})},_diffProps=function(a,b,patches){if(a&&b&&(a.props||b.props)){var i,toChange=[],toRemove=[],battrs=Object.keys(b.props),aattrs=Object.keys(a.props);for(i=0;i<battrs.length||i<aattrs.length;i++)i<battrs.length&&(battrs[i]in a.props&&b.props[battrs[i]]===a.props[battrs[i]]||toChange.push({name:battrs[i],value:b.props[battrs[i]]})),i<aattrs.length&&(aattrs[i]in b.props||toRemove.push({name:aattrs[i]}));toRemove.length>0&&patches.push({t:PATCH_PROPS,remove:toRemove,node:_nodeId(a)}),toChange.length>0&&patches.push({t:PATCH_PROPS,change:toChange,node:_nodeId(a)})}},_nodeId=function(node){return node},_isNodeSame=function(a,b){return a.tag===b.tag};exports.PATCH_CREATE=PATCH_CREATE,exports.PATCH_REMOVE=PATCH_REMOVE,exports.PATCH_REPLACE=PATCH_REPLACE,exports.PATCH_REORDER=PATCH_REORDER,exports.PATCH_PROPS=PATCH_PROPS,exports.diff=diff},{}],15:[function(require,module,exports){var sNavigator,spatial=function(config,force){var SpatialNavigator=require("./spatial");return config=config||{},sNavigator&&!force?sNavigator.setCollection(null):sNavigator=new SpatialNavigator(null,config),sNavigator.cfg=config,H},H=function(argv){return this instanceof H?argv[0]instanceof H?argv[0]:(this.tag=argv[0].toLowerCase(),this.props=argv[1]||{},"focusable"in this.props&&this.props.focusable&&!("tabindex"in this.props)&&(this.props.tabindex=0),void(null!==argv[2]&&void 0!==argv[2]&&argv.length>2&&("object"!=typeof argv[2]&&3===argv.length?this.children=[_createTextNode(argv[2])]:Array.isArray(argv[2])?this.children=argv[2]:this.children=[].concat.apply([],[].slice.call(argv,2,argv.length)).filter(function(n){return null!==n&&void 0!==n&&n!==!1}).map(function(n){return n instanceof H?n:_createTextNode(n)})))):"function"==typeof argv?argv.apply(argv,[].slice.call(arguments,1,arguments.length)):new H(arguments)};H.prototype.render=function(){var DOM=this.DOMrender.apply(this,arguments);return sNavigator&&(this.sn=sNavigator),DOM},H.prototype.removeSpatial=function(){sNavigator.remove(this.el)},H.prototype.DOMrender=function(node,parent){node=node||this,node.el=createElement(node.tag?node:this,parent);var children=node.children;if("object"==typeof children)for(var i=0;i<children.length;i++)node.el.appendChild(this.DOMrender(children[i],node.el));return node.el},H.prototype.setProp=function(name,value){"undefined"!=typeof this.el&&("className"===name?this.el.setAttribute("class",value):"style"===name&&"string"!=typeof value?this.el.setAttribute("style",_stylePropToString(value)):name.match(/^on/)?this.addEvent(name,value):"ref"===name?"function"==typeof value&&value(this.el):sNavigator&&"focusable"===name?(value===!0?sNavigator.add(this.el):sNavigator.remove(this.el),this.el[name]=Boolean(value)):"boolean"==typeof value||"true"===value?(this.el.setAttribute(name,value),this.el[name]=Boolean(value)):this.el.setAttribute(name,value)),this.props[name]=value},H.prototype.setProps=function(props){for(var propNames=Object.keys(props),i=0;i<propNames.length;i++){var prop=propNames[i];this.setProp(prop,props[prop])}},H.prototype.rmProp=function(name){"undefined"!=typeof this.el&&("className"===name?this.el.removeAttribute("class"):name.match(/^on/)?this.removeEvent(name):"ref"===name||(sNavigator&&"focusable"===name?(sNavigator.remove(this.el),delete this.el[name]):"boolean"==typeof value?(this.el.removeAttribute(name),delete this.el[name]):this.el.removeAttribute(name))),delete this.props[name]},H.prototype.addEvent=function(name,listener){name=name.slice(2).toLowerCase(),this.listeners=this.listeners||{},name in this.listeners&&this.removeEvent(name),this.listeners[name]=listener,this.el.addEventListener(name,listener)},H.prototype.removeEvent=function(name){name in this.listeners&&(this.el.removeEventListener(name,this.listeners[name]),delete this.listeners[name])},H.prototype.clone=function(){var node={tag:String(this.tag),props:_cloneProps(this.props)};return"undefined"!=typeof this.children&&(node.children="text"===this.tag?String(this.children):this.children.map(function(child){return"text"===child.tag?_createTextNode(child.children):child.clone()})),H(node.tag,node.props,node.children)};var _cloneProps=function(props,keepRefs){"undefined"==typeof keepRefs&&(keepRefs=!0);var i,name,attrs=Object.keys(props),cloned={};for(i=0;i<attrs.length;i++)name=attrs[i],"string"==typeof props[name]?cloned[name]=String(props[name]):"function"==typeof props[name]&&keepRefs===!0?cloned[name]=props[name]:"boolean"==typeof props[name]?cloned[name]=Boolean(props[name]):"object"==typeof props[name]&&(cloned[name]=_cloneProps(props[name]));return cloned},_stylePropToString=function(props){for(var out="",attrs=Object.keys(props),i=0;i<attrs.length;i++)out+=attrs[i].replace(/([A-Z])/g,"-$1").toLowerCase(),out+=":",out+=props[attrs[i]],out+=";";return out},_createTextNode=function(text){return{tag:"text",children:String(text)}},createElement=function(node,parent){return node.el="text"===node.tag?document.createTextNode(node.children):document.createElement(node.tag),"undefined"!=typeof node.props&&node.setProps(node.props),"undefined"!=typeof parent&&parent.appendChild(node.el),node.el};exports.h=H,exports.spatial=spatial,exports.createElement=createElement},{"./spatial":17}],16:[function(require,module,exports){var PATCH_CREATE=require("./diff").PATCH_CREATE,PATCH_REMOVE=require("./diff").PATCH_REMOVE,PATCH_REPLACE=require("./diff").PATCH_REPLACE,PATCH_REORDER=require("./diff").PATCH_REORDER,PATCH_PROPS=require("./diff").PATCH_PROPS,createElement=require("./h").createElement,patch=function(tree,patches){var render=!0;"undefined"==typeof tree.el&&(render=!1);for(var i=0;i<patches.length;i++){var p=patches[i];switch(p.t){case PATCH_REORDER:_patchReorder(p,render);break;case PATCH_CREATE:_patchCreate(p,render);break;case PATCH_REMOVE:_patchRemove(p,render);break;case PATCH_REPLACE:_patchReplace(p,render);break;case PATCH_PROPS:_patchProps(p,render)}}},_patchReplace=function(p,render){p.node.children=String(p.with.children),render===!0&&(p.node.el.nodeValue=String(p.with.children))},_patchReorder=function(p,render){render===!0&&p.node.el.insertBefore(p.item.el,p.node.el.childNodes[p.to]),p.node.children.splice(p.to,0,p.node.children.splice(p.node.children.indexOf(p.item),1)[0])},_patchCreate=function(p,render){var element;render===!0&&(element="text"===p.item.tag?createElement(p.item):p.item.render()),p.node.children.length-1<p.to?(p.node.children.push(p.item),render===!0&&p.node.el.appendChild(element)):(p.node.children.splice(p.to,0,p.item),render===!0&&p.node.el.insertBefore(element,p.node.el.childNodes[p.to]))},_patchRemove=function(p,render){render===!0&&(p.item.props&&"focusable"in p.item.props&&p.item.removeSpatial(),p.node.el.removeChild(p.item.el));for(var i=0;i<p.node.children.length;i++)p.node.children[i]===p.item&&p.node.children.splice(i,1)},_patchProps=function(p){var i;if("remove"in p)for(i=0;i<p.remove.length;i++)p.node.rmProp(p.remove[i].name);else if("change"in p)for(i=0;i<p.change.length;i++)p.node.setProp(p.change[i].name,p.change[i].value);else;};exports.patch=patch},{"./diff":14,"./h":15}],17:[function(require,module,exports){function SpatialNavigator(collection,config){this._focus=null,this._previous=null,config=config||{},this.setCollection(collection);for(var key in config)this[key]=config[key];window.addEventListener("click",this.evClick.bind(this),!0),window.addEventListener("keydown",this.evKey.bind(this),!0),this.autofocus&&this.autofocus===!0&&window.addEventListener("click",function(){this.focus()}.bind(this))}!function(){function CustomEvent(event,params){params=params||{bubbles:!1,cancelable:!1,detail:void 0};var evt=document.createEvent("CustomEvent");return evt.initCustomEvent(event,params.bubbles,params.cancelable,params.detail),evt}return"function"!=typeof window.CustomEvent&&(CustomEvent.prototype=window.Event.prototype,void(window.CustomEvent=CustomEvent))}(),SpatialNavigator.prototype={cfg:{},straightOnly:!1,straightOverlapThreshold:.5,ignoreHiddenElement:!1,rememberSource:!1,evtNamePostfix:"sn",navigableFilter:null,silent:!1,evKey:function(evt){function preventKeyPress(){prevent===!0&&evt.preventDefault()}var code=evt.charCode||evt.keyCode,prevent=this.cfg.preventKeys;switch(code){case this.cfg.keys.DOWN:this.move("down"),preventKeyPress();break;case this.cfg.keys.UP:this.move("up"),preventKeyPress();break;case this.cfg.keys.LEFT:this.move("left"),preventKeyPress();break;case this.cfg.keys.RIGHT:this.move("right"),preventKeyPress();break;case this.cfg.keys.ENTER:this._collection.indexOf(evt.target)!==-1&&this.fire("enter",evt.target)}return!0},evClick:function(evt){return this.fire("enter",evt.target),this.focus(evt.target)},fire:function(evtName,elem){var evt=new window.CustomEvent(evtName+this.evtNamePostfix,{detail:{name:evtName,element:elem},cancelable:!0}),cancelled=!elem.dispatchEvent(evt);return cancelled||"unfocus"!==evtName||elem.blur(),cancelled||"focus"!==evtName||elem.focus(),cancelled},_getRect:function(elem){var rect=null;if(!this._isNavigable(elem))return null;if(elem.getBoundingClientRect){var cr=elem.getBoundingClientRect();rect={left:cr.left,top:cr.top,width:cr.width,height:cr.height}}else{if(void 0===elem.left)return null;rect={left:parseInt(elem.left||0,10),top:parseInt(elem.top||0,10),width:parseInt(elem.width||0,10),height:parseInt(elem.height||0,10)}}return rect.element=elem,rect.right=rect.left+rect.width,rect.bottom=rect.top+rect.height,rect.center={x:rect.left+Math.floor(rect.width/2),y:rect.top+Math.floor(rect.height/2)},rect.center.left=rect.center.right=rect.center.x,rect.center.top=rect.center.bottom=rect.center.y,rect},_getAllRects:function(excludedElem){var rects=[];return this._collection.forEach(function(elem){if(!excludedElem||excludedElem!==elem){var rect=this._getRect(elem);rect&&rects.push(rect)}},this),rects},_isNavigable:function(elem){if(this.ignoreHiddenElement&&elem instanceof window.HTMLElement){var computedStyle=window.getComputedStyle(elem);if(elem.offsetWidth<=0&&elem.offsetHeight<=0||"hidden"===computedStyle.getPropertyValue("visibility")||"none"===computedStyle.getPropertyValue("display")||elem.hasAttribute("aria-hidden"))return!1}return!(this.navigableFilter&&!this.navigableFilter(elem))},_partition:function(rects,targetRect){var groups=[[],[],[],[],[],[],[],[],[]],threshold=this.straightOverlapThreshold;return(threshold>1||threshold<0)&&(threshold=.5),rects.forEach(function(rect){var x,y,groupId,center=rect.center;x=center.x<targetRect.left?0:center.x<=targetRect.right?1:2,y=center.y<targetRect.top?0:center.y<=targetRect.bottom?1:2,groupId=3*y+x,groups[groupId].push(rect),[0,2,6,8].indexOf(groupId)!==-1&&(rect.left<=targetRect.right-targetRect.width*threshold&&(2===groupId?groups[1].push(rect):8===groupId&&groups[7].push(rect)),rect.right>=targetRect.left+targetRect.width*threshold&&(0===groupId?groups[1].push(rect):6===groupId&&groups[7].push(rect)),rect.top<=targetRect.bottom-targetRect.height*threshold&&(6===groupId?groups[3].push(rect):8===groupId&&groups[5].push(rect)),rect.bottom>=targetRect.top+targetRect.height*threshold&&(0===groupId?groups[3].push(rect):2===groupId&&groups[5].push(rect)))}),groups},_getDistanceFunction:function(targetRect){return{nearPlumbLineIsBetter:function(rect){var d;return d=rect.center.x<targetRect.center.x?targetRect.center.x-rect.right:rect.left-targetRect.center.x,d<0?0:d},nearHorizonIsBetter:function(rect){var d;return d=rect.center.y<targetRect.center.y?targetRect.center.y-rect.bottom:rect.top-targetRect.center.y,d<0?0:d},nearTargetLeftIsBetter:function(rect){var d;return d=rect.center.x<targetRect.center.x?targetRect.left-rect.right:rect.left-targetRect.left,d<0?0:d},nearTargetTopIsBetter:function(rect){var d;return d=rect.center.y<targetRect.center.y?targetRect.top-rect.bottom:rect.top-targetRect.top,d<0?0:d},topIsBetter:function(rect){return rect.top},bottomIsBetter:function(rect){return-1*rect.bottom},leftIsBetter:function(rect){return rect.left},rightIsBetter:function(rect){return-1*rect.right}}},_prioritize:function(priorities,target,direction){for(var destPriority=null,i=0;i<priorities.length;i++)if(priorities[i].group.length){destPriority=priorities[i];break}if(!destPriority)return null;if(this.rememberSource&&this._previous&&target===this._previous.destination&&direction===this._previous.reverse){var source=this._previous.source,found=destPriority.group.find(function(dest){return dest.element===source});if(found)return found}return destPriority.group.sort(function(a,b){return destPriority.distance.reduce(function(answer,distance){return answer||distance(a)-distance(b)},0)}),destPriority.group[0]},setCollection:function(collection){this.unfocus(),this._collection=[],collection&&this.multiAdd(collection)},add:function(elem){var index=this._collection.indexOf(elem);return!(index>=0)&&(this._collection.push(elem),!0)},multiAdd:function(elements){return elements.every(this.add,this)},remove:function(elem){var index=this._collection.indexOf(elem);return!(index<0)&&(this._focus===elem&&this.unfocus(),this._collection.splice(index,1),!0)},multiRemove:function(elements){return Array.from(elements).every(this.remove,this)},focus:function(elem){if(!elem&&this._focus&&this._isNavigable(this._focus)&&(elem=this._focus),!this._collection)return!1;if(elem){if(this._collection.indexOf(elem)<0||!this._isNavigable(elem))return!1}else{var navigableElems=this._collection.filter(this._isNavigable,this);if(!navigableElems.length)return!1;elem=navigableElems[0]}return this.unfocus(),this._focus=elem,this.silent||this.fire("focus",this._focus),!0},unfocus:function(){if(this._focus){var elem=this._focus;this._focus=null,this.silent||this.fire("unfocus",elem)}return!0; | ||
},getFocusedElement:function(){return this._focus},move:function(direction){var reverse={left:"right",up:"down",right:"left",down:"up"};if(this._focus){var elem=this.navigate(this._focus,direction);if(!elem)return!1;this.rememberSource&&(this._previous={source:this._focus,destination:elem,reverse:reverse[direction.toLowerCase()]}),this.unfocus(),this.focus(elem)}else this._previous=null,this.focus();return!0},navigate:function(target,direction){if(!target||!direction||!this._collection)return null;direction=direction.toLowerCase();var rects=this._getAllRects(target),targetRect=this._getRect(target);if(!targetRect||!rects.length)return null;var priorities,distanceFunction=this._getDistanceFunction(targetRect),groups=this._partition(rects,targetRect),internalGroups=this._partition(groups[4],targetRect.center);switch(direction){case"left":priorities=[{group:internalGroups[0].concat(internalGroups[3]).concat(internalGroups[6]),distance:[distanceFunction.nearPlumbLineIsBetter,distanceFunction.topIsBetter]},{group:groups[3],distance:[distanceFunction.nearPlumbLineIsBetter,distanceFunction.topIsBetter]},{group:groups[0].concat(groups[6]),distance:[distanceFunction.nearHorizonIsBetter,distanceFunction.rightIsBetter,distanceFunction.nearTargetTopIsBetter]}];break;case"right":priorities=[{group:internalGroups[2].concat(internalGroups[5]).concat(internalGroups[8]),distance:[distanceFunction.nearPlumbLineIsBetter,distanceFunction.topIsBetter]},{group:groups[5],distance:[distanceFunction.nearPlumbLineIsBetter,distanceFunction.topIsBetter]},{group:groups[2].concat(groups[8]),distance:[distanceFunction.nearHorizonIsBetter,distanceFunction.leftIsBetter,distanceFunction.nearTargetTopIsBetter]}];break;case"up":priorities=[{group:internalGroups[0].concat(internalGroups[1]).concat(internalGroups[2]),distance:[distanceFunction.nearHorizonIsBetter,distanceFunction.leftIsBetter]},{group:groups[1],distance:[distanceFunction.nearHorizonIsBetter,distanceFunction.leftIsBetter]},{group:groups[0].concat(groups[2]),distance:[distanceFunction.nearPlumbLineIsBetter,distanceFunction.bottomIsBetter,distanceFunction.nearTargetLeftIsBetter]}];break;case"down":priorities=[{group:internalGroups[6].concat(internalGroups[7]).concat(internalGroups[8]),distance:[distanceFunction.nearHorizonIsBetter,distanceFunction.leftIsBetter]},{group:groups[7],distance:[distanceFunction.nearHorizonIsBetter,distanceFunction.leftIsBetter]},{group:groups[6].concat(groups[8]),distance:[distanceFunction.nearPlumbLineIsBetter,distanceFunction.topIsBetter,distanceFunction.nearTargetLeftIsBetter]}];break;default:return null}this.straightOnly&&priorities.pop();var dest=this._prioritize(priorities,target,direction);return dest?dest.element:null}},module.exports=SpatialNavigator},{}]},{},[1]); |
@@ -35,3 +35,9 @@ /* | ||
_createOrigin : function(url) { | ||
var origin = url | ||
var origin; | ||
if (url.match(/\#/)) { | ||
url = '-//-/#' + url.split('#')[1]; | ||
} | ||
origin = url | ||
.replace(/^.+?\/\/+[^\/]+/, '') | ||
@@ -38,0 +44,0 @@ .split(/[/#]/).join('/').replace('//', '') |
{ | ||
"name": "cakejs2-spatial", | ||
"version": "0.0.12", | ||
"version": "0.0.14", | ||
"description": "CakeJS2 with spatial navigation.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is too big to display
179777
3439