All Downloads are FREE. Search and download functionalities are using the official Maven repository.

www.reboot.netflix.js Maven / Gradle / Ivy

There is a newer version: 0.1.20
Show newest version
var nf=typeof nf!=="undefined"?nf:{};nf.utils=function(){var createRow=function(data,isSafeHTML,isHeader){var tr=document.createElement("tr");data.forEach(function(item){var nodeType=isHeader?"th":"td",td=document.createElement(nodeType);if(item instanceof HTMLElement||item instanceof DocumentFragment){td.appendChild(item)}else if(isSafeHTML){td.innerHTML=item}else{td.textContent=item}tr.appendChild(td)});return tr};var arrayToSet=function(array){var set=new Set;array.forEach(function(item){set.add(item)});return set};var setToArray=function(set){var array=[];set.forEach(function(item){array.push(item)});return array};var extend=function(objects){var extended={};var merge=function(obj){for(var prop in obj){if(Object.prototype.hasOwnProperty.call(obj,prop)){extended[prop]=obj[prop]}}};merge(arguments[0]);for(var i=1;i=0){a=this.walk(a,d)}else{b=this.walk(b,-d)}while(a&&b&&a!==b){a=a.parentNode||a.host;b=b.parentNode||b.host}return a},walk:function(n,u){for(var i=0;n&&i-1){this.values[i]=inEvent}else{this.keys.push(inId);this.values.push(inEvent)}},has:function(inId){return this.keys.indexOf(inId)>-1},"delete":function(inId){var i=this.keys.indexOf(inId);if(i>-1){this.keys.splice(i,1);this.values.splice(i,1)}},get:function(inId){var i=this.keys.indexOf(inId);return this.values[i]},clear:function(){this.keys.length=0;this.values.length=0},forEach:function(callback,thisArg){this.values.forEach(function(v,i){callback.call(thisArg,v,this.keys[i],this)},this)},pointers:function(){return this.keys.length}};scope.PointerMap=PointerMap})(window.PolymerGestures);(function(scope){var CLONE_PROPS=["bubbles","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget","buttons","pointerId","width","height","pressure","tiltX","tiltY","pointerType","hwTimestamp","isPrimary","type","target","currentTarget","which","pageX","pageY","timeStamp","preventTap","tapPrevented","_source"];var CLONE_DEFAULTS=[false,false,null,null,0,0,0,0,false,false,false,false,0,null,0,0,0,0,0,0,0,"",0,false,"",null,null,0,0,0,0,function(){},false];var HAS_SVG_INSTANCE=typeof SVGElementInstance!=="undefined";var eventFactory=scope.eventFactory;var currentGestures;var dispatcher={IS_IOS:false,pointermap:new scope.PointerMap,requiredGestures:new scope.PointerMap,eventMap:Object.create(null),eventSources:Object.create(null),eventSourceList:[],gestures:[],dependencyMap:{down:{listeners:0,index:-1},up:{listeners:0,index:-1}},gestureQueue:[],registerSource:function(name,source){var s=source;var newEvents=s.events;if(newEvents){newEvents.forEach(function(e){if(s[e]){this.eventMap[e]=s[e].bind(s)}},this);this.eventSources[name]=s;this.eventSourceList.push(s)}},registerGesture:function(name,source){var obj=Object.create(null);obj.listeners=0;obj.index=this.gestures.length;for(var i=0,g;i0){r=this.dependencyMap[g];ri=r?r.index:-1;currentGestures[ri]=true}}}},eventHandler:function(inEvent){var type=inEvent.type;if(type==="touchstart"||type==="mousedown"||type==="pointerdown"||type==="MSPointerDown"){if(!inEvent._handledByPG){currentGestures={}}if(this.IS_IOS){var ev=inEvent;if(type==="touchstart"){var ct=inEvent.changedTouches[0];ev={target:inEvent.target,clientX:ct.clientX,clientY:ct.clientY,path:inEvent.path}}var nodes=inEvent.path||scope.targetFinding.path(ev);for(var i=0,n;i0){node._pgListeners--}if(node._pgListeners===0){dispatcher.unregister(node)}if(node._pgEvents){if(node._pgEvents[g]>0){node._pgEvents[g]--}else{node._pgEvents[g]=0}}}return Boolean(dep)};scope.removeEventListener=function(node,gesture,handler,capture){if(handler){scope.deactivateGesture(node,gesture);node.removeEventListener(gesture,handler,capture)}}})(window.PolymerGestures);(function(scope){var dispatcher=scope.dispatcher;var pointermap=dispatcher.pointermap;var DEDUP_DIST=25;var WHICH_TO_BUTTONS=[0,1,4,2];var CURRENT_BUTTONS=0;var HAS_BUTTONS=false;try{HAS_BUTTONS=new MouseEvent("test",{buttons:1}).buttons===1}catch(e){}var mouseEvents={POINTER_ID:1,POINTER_TYPE:"mouse",events:["mousedown","mousemove","mouseup"],exposes:["down","up","move"],register:function(target){dispatcher.listen(target,this.events)},unregister:function(target){if(target===document){return}dispatcher.unlisten(target,this.events)},lastTouches:[],isEventSimulatedFromTouch:function(inEvent){var lts=this.lastTouches;var x=inEvent.clientX,y=inEvent.clientY;for(var i=0,l=lts.length,t;i=doa}return ret}},findTouch:function(inTL,inId){for(var i=0,l=inTL.length,t;i=tl.length){var d=[];pointermap.forEach(function(value,key){if(key!==1&&!this.findTouch(tl,key-2)){var p=value;d.push(p)}},this);d.forEach(function(p){this.cancel(p);pointermap.delete(p.pointerId)})}},touchstart:function(inEvent){this.vacuumTouches(inEvent);this.setPrimaryTouch(inEvent.changedTouches[0]);this.dedupSynthMouse(inEvent);if(!this.scrolling){this.clickCount++;this.processTouches(inEvent,this.down)}},down:function(inPointer){dispatcher.down(inPointer)},touchmove:function(inEvent){if(HAS_TOUCH_ACTION){if(inEvent.cancelable){this.processTouches(inEvent,this.move)}}else{if(!this.scrolling){if(this.scrolling===null&&this.shouldScroll(inEvent)){this.scrolling=true}else{this.scrolling=false;inEvent.preventDefault();this.processTouches(inEvent,this.move)}}else if(this.firstXY){var t=inEvent.changedTouches[0];var dx=t.clientX-this.firstXY.X;var dy=t.clientY-this.firstXY.Y;var dd=Math.sqrt(dx*dx+dy*dy);if(dd>=HYSTERESIS){this.touchcancel(inEvent);this.scrolling=true;this.firstXY=null}}}},move:function(inPointer){dispatcher.move(inPointer)},touchend:function(inEvent){this.dedupSynthMouse(inEvent);this.processTouches(inEvent,this.up)},up:function(inPointer){inPointer.relatedTarget=scope.findTarget(inPointer);dispatcher.up(inPointer)},cancel:function(inPointer){dispatcher.cancel(inPointer)},touchcancel:function(inEvent){inEvent._cancel=true;this.processTouches(inEvent,this.cancel)},cleanUpPointer:function(inPointer){pointermap["delete"](inPointer.pointerId);this.removePrimaryPointer(inPointer)},dedupSynthMouse:function(inEvent){var lts=scope.mouseEvents.lastTouches;var t=inEvent.changedTouches[0];if(this.isPrimaryTouch(t)){var lt={x:t.clientX,y:t.clientY};lts.push(lt);var fn=function(lts,lt){var i=lts.indexOf(lt);if(i>-1){lts.splice(i,1)}}.bind(null,lts,lt);setTimeout(fn,DEDUP_TIMEOUT)}}};var STOP_PROP_FN=Event.prototype.stopImmediatePropagation||Event.prototype.stopPropagation;document.addEventListener("click",function(ev){var x=ev.clientX,y=ev.clientY;var closeTo=function(touch){var dx=Math.abs(x-touch.x),dy=Math.abs(y-touch.y);return dx<=DEDUP_DIST&&dy<=DEDUP_DIST};var wasTouched=scope.mouseEvents.lastTouches.some(closeTo);var path=scope.targetFinding.path(ev);if(wasTouched){for(var i=0;i0?1:-1},calcPositionDelta:function(inA,inB){var x=0,y=0;if(inA&&inB){x=inB.pageX-inA.pageX;y=inB.pageY-inA.pageY}return{x:x,y:y}},fireTrack:function(inType,inEvent,inTrackingData){var t=inTrackingData;var d=this.calcPositionDelta(t.downEvent,inEvent);var dd=this.calcPositionDelta(t.lastMoveEvent,inEvent);if(dd.x){t.xDirection=this.clampDir(dd.x)}else if(inType==="trackx"){return}if(dd.y){t.yDirection=this.clampDir(dd.y)}else if(inType==="tracky"){return}var gestureProto={bubbles:true,cancelable:true,trackInfo:t.trackInfo,relatedTarget:inEvent.relatedTarget,pointerType:inEvent.pointerType,pointerId:inEvent.pointerId,_source:"track"};if(inType!=="tracky"){gestureProto.x=inEvent.x;gestureProto.dx=d.x;gestureProto.ddx=dd.x;gestureProto.clientX=inEvent.clientX;gestureProto.pageX=inEvent.pageX;gestureProto.screenX=inEvent.screenX;gestureProto.xDirection=t.xDirection}if(inType!=="trackx"){gestureProto.dy=d.y;gestureProto.ddy=dd.y;gestureProto.y=inEvent.y;gestureProto.clientY=inEvent.clientY;gestureProto.pageY=inEvent.pageY;gestureProto.screenY=inEvent.screenY;gestureProto.yDirection=t.yDirection}var e=eventFactory.makeGestureEvent(inType,gestureProto);t.downTarget.dispatchEvent(e)},down:function(inEvent){if(inEvent.isPrimary&&(inEvent.pointerType==="mouse"?inEvent.buttons===1:true)){var p={downEvent:inEvent,downTarget:inEvent.target,trackInfo:{},lastMoveEvent:null,xDirection:0,yDirection:0,tracking:false};pointermap.set(inEvent.pointerId,p)}},move:function(inEvent){var p=pointermap.get(inEvent.pointerId);if(p){if(!p.tracking){var d=this.calcPositionDelta(p.downEvent,inEvent);var move=d.x*d.x+d.y*d.y;if(move>this.WIGGLE_THRESHOLD){p.tracking=true;p.lastMoveEvent=p.downEvent;this.fireTrack("trackstart",inEvent,p)}}if(p.tracking){this.fireTrack("track",inEvent,p);this.fireTrack("trackx",inEvent,p);this.fireTrack("tracky",inEvent,p)}p.lastMoveEvent=inEvent}},up:function(inEvent){var p=pointermap.get(inEvent.pointerId);if(p){if(p.tracking){this.fireTrack("trackend",inEvent,p)}pointermap.delete(inEvent.pointerId)}}};dispatcher.registerGesture("track",track)})(window.PolymerGestures);(function(scope){var dispatcher=scope.dispatcher;var eventFactory=scope.eventFactory;var hold={HOLD_DELAY:200,WIGGLE_THRESHOLD:16,events:["down","move","up"],exposes:["hold","holdpulse","release"],heldPointer:null,holdJob:null,pulse:function(){var hold=Date.now()-this.heldPointer.timeStamp;var type=this.held?"holdpulse":"hold";this.fireHold(type,hold);this.held=true},cancel:function(){clearInterval(this.holdJob);if(this.held){this.fireHold("release")}this.held=false;this.heldPointer=null;this.target=null;this.holdJob=null},down:function(inEvent){if(inEvent.isPrimary&&!this.heldPointer){this.heldPointer=inEvent;this.target=inEvent.target;this.holdJob=setInterval(this.pulse.bind(this),this.HOLD_DELAY)}},up:function(inEvent){if(this.heldPointer&&this.heldPointer.pointerId===inEvent.pointerId){this.cancel()}},move:function(inEvent){if(this.heldPointer&&this.heldPointer.pointerId===inEvent.pointerId){var x=inEvent.clientX-this.heldPointer.clientX;var y=inEvent.clientY-this.heldPointer.clientY;if(x*x+y*y>this.WIGGLE_THRESHOLD){this.cancel()}}},fireHold:function(inType,inHoldTime){var p={bubbles:true,cancelable:true,pointerType:this.heldPointer.pointerType,pointerId:this.heldPointer.pointerId,x:this.heldPointer.clientX,y:this.heldPointer.clientY,_source:"hold"};if(inHoldTime){p.holdTime=inHoldTime}var e=eventFactory.makeGestureEvent(inType,p);this.target.dispatchEvent(e)}};dispatcher.registerGesture("hold",hold)})(window.PolymerGestures);(function(scope){var dispatcher=scope.dispatcher;var eventFactory=scope.eventFactory;var pointermap=new scope.PointerMap;var tap={events:["down","up"],exposes:["tap"],down:function(inEvent){if(inEvent.isPrimary&&!inEvent.tapPrevented){pointermap.set(inEvent.pointerId,{target:inEvent.target,buttons:inEvent.buttons,x:inEvent.clientX,y:inEvent.clientY})}},shouldTap:function(e,downState){var tap=true;if(e.pointerType==="mouse"){tap=e.buttons^1&&downState.buttons&1}return tap&&!e.tapPrevented},up:function(inEvent){var start=pointermap.get(inEvent.pointerId);if(start&&this.shouldTap(inEvent,start)){var t=scope.targetFinding.LCA(start.target,inEvent.relatedTarget);if(t){var e=eventFactory.makeGestureEvent("tap",{bubbles:true,cancelable:true,x:inEvent.clientX,y:inEvent.clientY,detail:inEvent.detail,pointerType:inEvent.pointerType,pointerId:inEvent.pointerId,altKey:inEvent.altKey,ctrlKey:inEvent.ctrlKey,metaKey:inEvent.metaKey,shiftKey:inEvent.shiftKey,_source:"tap"});t.dispatchEvent(e)}}pointermap.delete(inEvent.pointerId)}};eventFactory.preventTap=function(e){return function(){e.tapPrevented=true;pointermap.delete(e.pointerId)}};dispatcher.registerGesture("tap",tap)})(window.PolymerGestures);(function(scope){var dispatcher=scope.dispatcher;var eventFactory=scope.eventFactory;var pointermap=new scope.PointerMap;var RAD_TO_DEG=180/Math.PI;var pinch={events:["down","up","move","cancel"],exposes:["pinch","rotate"],defaultActions:{pinch:"none",rotate:"none"},reference:{},down:function(inEvent){pointermap.set(inEvent.pointerId,inEvent);if(pointermap.pointers()==2){var points=this.calcChord();var angle=this.calcAngle(points);this.reference={angle:angle,diameter:points.diameter,target:scope.targetFinding.LCA(points.a.target,points.b.target)}}},up:function(inEvent){var p=pointermap.get(inEvent.pointerId);if(p){pointermap.delete(inEvent.pointerId)}},move:function(inEvent){if(pointermap.has(inEvent.pointerId)){pointermap.set(inEvent.pointerId,inEvent);if(pointermap.pointers()>1){this.calcPinchRotate()}}},cancel:function(inEvent){this.up(inEvent)},firePinch:function(diameter,points){var zoom=diameter/this.reference.diameter;var e=eventFactory.makeGestureEvent("pinch",{bubbles:true,cancelable:true,scale:zoom,centerX:points.center.x,centerY:points.center.y,_source:"pinch"});this.reference.target.dispatchEvent(e)},fireRotate:function(angle,points){var diff=Math.round((angle-this.reference.angle)%360);var e=eventFactory.makeGestureEvent("rotate",{bubbles:true,cancelable:true,angle:diff,centerX:points.center.x,centerY:points.center.y,_source:"pinch"});
this.reference.target.dispatchEvent(e)},calcPinchRotate:function(){var points=this.calcChord();var diameter=points.diameter;var angle=this.calcAngle(points);if(diameter!=this.reference.diameter){this.firePinch(diameter,points)}if(angle!=this.reference.angle){this.fireRotate(angle,points)}},calcChord:function(){var pointers=[];pointermap.forEach(function(p){pointers.push(p)});var dist=0;var points={a:pointers[0],b:pointers[1]};var x,y,d;for(var i=0;idist){dist=d;points={a:a,b:b}}}}x=Math.abs(points.a.clientX+points.b.clientX)/2;y=Math.abs(points.a.clientY+points.b.clientY)/2;points.center={x:x,y:y};points.diameter=dist;return points},calcAngle:function(points){var x=points.a.clientX-points.b.clientX;var y=points.a.clientY-points.b.clientY;return(360+Math.atan2(y,x)*RAD_TO_DEG)%360}};dispatcher.registerGesture("pinch",pinch)})(window.PolymerGestures);(function(global){"use strict";var Token,TokenName,Syntax,Messages,source,index,length,delegate,lookahead,state;Token={BooleanLiteral:1,EOF:2,Identifier:3,Keyword:4,NullLiteral:5,NumericLiteral:6,Punctuator:7,StringLiteral:8};TokenName={};TokenName[Token.BooleanLiteral]="Boolean";TokenName[Token.EOF]="";TokenName[Token.Identifier]="Identifier";TokenName[Token.Keyword]="Keyword";TokenName[Token.NullLiteral]="Null";TokenName[Token.NumericLiteral]="Numeric";TokenName[Token.Punctuator]="Punctuator";TokenName[Token.StringLiteral]="String";Syntax={ArrayExpression:"ArrayExpression",BinaryExpression:"BinaryExpression",CallExpression:"CallExpression",ConditionalExpression:"ConditionalExpression",EmptyStatement:"EmptyStatement",ExpressionStatement:"ExpressionStatement",Identifier:"Identifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",ObjectExpression:"ObjectExpression",Program:"Program",Property:"Property",ThisExpression:"ThisExpression",UnaryExpression:"UnaryExpression"};Messages={UnexpectedToken:"Unexpected token %0",UnknownLabel:"Undefined label '%0'",Redeclaration:"%0 '%1' has already been declared"};function assert(condition,message){if(!condition){throw new Error("ASSERT: "+message)}}function isDecimalDigit(ch){return ch>=48&&ch<=57}function isWhiteSpace(ch){return ch===32||ch===9||ch===11||ch===12||ch===160||ch>=5760&&" ᠎              ".indexOf(String.fromCharCode(ch))>0}function isLineTerminator(ch){return ch===10||ch===13||ch===8232||ch===8233}function isIdentifierStart(ch){return ch===36||ch===95||ch>=65&&ch<=90||ch>=97&&ch<=122}function isIdentifierPart(ch){return ch===36||ch===95||ch>=65&&ch<=90||ch>=97&&ch<=122||ch>=48&&ch<=57}function isKeyword(id){return id==="this"}function skipWhitespace(){while(index=0){index+=2;return{type:Token.Punctuator,value:ch1+ch2,range:[start,index]}}if("<>=!+-*%&|^/".indexOf(ch1)>=0){++index;return{type:Token.Punctuator,value:ch1,range:[start,index]}}throwError({},Messages.UnexpectedToken,"ILLEGAL")}function scanNumericLiteral(){var number,start,ch;ch=source[index];assert(isDecimalDigit(ch.charCodeAt(0))||ch===".","Numeric literal must start with a decimal digit or a decimal point");start=index;number="";if(ch!=="."){number=source[index++];ch=source[index];if(number==="0"){if(ch&&isDecimalDigit(ch.charCodeAt(0))){throwError({},Messages.UnexpectedToken,"ILLEGAL")}}while(isDecimalDigit(source.charCodeAt(index))){number+=source[index++]}ch=source[index]}if(ch==="."){number+=source[index++];while(isDecimalDigit(source.charCodeAt(index))){number+=source[index++]}ch=source[index]}if(ch==="e"||ch==="E"){number+=source[index++];ch=source[index];if(ch==="+"||ch==="-"){number+=source[index++]}if(isDecimalDigit(source.charCodeAt(index))){while(isDecimalDigit(source.charCodeAt(index))){number+=source[index++]}}else{throwError({},Messages.UnexpectedToken,"ILLEGAL")}}if(isIdentifierStart(source.charCodeAt(index))){throwError({},Messages.UnexpectedToken,"ILLEGAL")}return{type:Token.NumericLiteral,value:parseFloat(number),range:[start,index]}}function scanStringLiteral(){var str="",quote,start,ch,octal=false;quote=source[index];assert(quote==="'"||quote==='"',"String literal must starts with a quote");start=index;++index;while(index=length){return{type:Token.EOF,range:[index,index]}}ch=source.charCodeAt(index);if(ch===40||ch===41||ch===58){return scanPunctuator()}if(ch===39||ch===34){return scanStringLiteral()}if(isIdentifierStart(ch)){return scanIdentifier()}if(ch===46){if(isDecimalDigit(source.charCodeAt(index+1))){return scanNumericLiteral()}return scanPunctuator()}if(isDecimalDigit(ch)){return scanNumericLiteral()}return scanPunctuator()}function lex(){var token;token=lookahead;index=token.range[1];lookahead=advance();index=token.range[1];return token}function peek(){var pos;pos=index;lookahead=advance();index=pos}function throwError(token,messageFormat){var error,args=Array.prototype.slice.call(arguments,2),msg=messageFormat.replace(/%(\d)/g,function(whole,index){assert(index":case"<=":case">=":case"instanceof":prec=7;break;case"in":prec=7;break;case"+":case"-":prec=9;break;case"*":case"/":case"%":prec=11;break;default:break}return prec}function parseBinaryExpression(){var expr,token,prec,stack,right,operator,left,i;left=parseUnaryExpression();token=lookahead;prec=binaryPrecedence(token);if(prec===0){return left}token.prec=prec;lex();right=parseUnaryExpression();stack=[left,token,right];while((prec=binaryPrecedence(lookahead))>0){while(stack.length>2&&prec<=stack[stack.length-2].prec){right=stack.pop();operator=stack.pop().value;left=stack.pop();expr=delegate.createBinaryExpression(operator,left,right);stack.push(expr)}token=lex();token.prec=prec;stack.push(token);expr=parseUnaryExpression();stack.push(expr)}i=stack.length-1;expr=stack[i];while(i>1){expr=delegate.createBinaryExpression(stack[i-1].value,stack[i-2],expr);i-=2}return expr}function parseConditionalExpression(){var expr,consequent,alternate;expr=parseBinaryExpression();if(match("?")){lex();consequent=parseConditionalExpression();expect(":");alternate=parseConditionalExpression();expr=delegate.createConditionalExpression(expr,consequent,alternate)}return expr}var parseExpression=parseConditionalExpression;function parseFilter(){var identifier,args;identifier=lex();if(identifier.type!==Token.Identifier){throwUnexpected(identifier)}args=match("(")?parseArguments():[];return delegate.createFilter(identifier.value,args)}function parseFilters(){while(match("|")){lex();parseFilter()}}function parseTopLevel(){skipWhitespace();peek();var expr=parseExpression();if(expr){if(lookahead.value===","||lookahead.value=="in"&&expr.type===Syntax.Identifier){parseInExpression(expr)}else{parseFilters();if(lookahead.value==="as"){parseAsExpression(expr)}else{delegate.createTopLevel(expr)}}}if(lookahead.type!==Token.EOF){throwUnexpected(lookahead)}}function parseAsExpression(expr){lex();var identifier=lex().value;delegate.createAsExpression(expr,identifier)}function parseInExpression(identifier){var indexName;if(lookahead.value===","){lex();if(lookahead.type!==Token.Identifier)throwUnexpected(lookahead);indexName=lex().value}lex();var expr=parseExpression();parseFilters();delegate.createInExpression(identifier.name,indexName,expr)}function parse(code,inDelegate){delegate=inDelegate;source=code;index=0;length=source.length;lookahead=null;state={labelSet:{}};return parseTopLevel()}global.esprima={parse:parse}})(this);(function(global){"use strict";function prepareBinding(expressionText,name,node,filterRegistry){var expression;try{expression=getExpression(expressionText);if(expression.scopeIdent&&(node.nodeType!==Node.ELEMENT_NODE||node.tagName!=="TEMPLATE"||name!=="bind"&&name!=="repeat")){throw Error("as and in can only be used within