Best JavaScript code snippet using appium-xcuitest-driver
DoubleArrowAnnotation.js.consoleStripped.js
Source:DoubleArrowAnnotation.js.consoleStripped.js
1define("dojox/sketch/DoubleArrowAnnotation", ["dojo/_base/kernel", "dojo/_base/lang", "./Annotation", "./Anchor"], function(dojo){2 dojo.getObject("sketch", true, dojox);3 var ta=dojox.sketch;4 0 && console.log(ta);5 ta.DoubleArrowAnnotation=function(figure, id){6 ta.Annotation.call(this, figure, id);7 this.transform={ dx:0, dy:0 };8 this.start={x:0, y:0};9 this.control={x:100, y:-50};10 this.end={x:200, y:0};11 this.textPosition={ x:0, y:0 };12 this.textOffset=6;13 this.textYOffset=10;14 this.textAlign="middle";15 this.startRotation=0;16 this.endRotation=0;17// this.property('label',this.id);18 this.labelShape=null;19 this.pathShape=null;20 this.startArrow=null;21 this.startArrowGroup=null;22 this.endArrow=null;23 this.endArrowGroup=null;24 this.anchors.start=new ta.Anchor(this, "start");25 this.anchors.control=new ta.Anchor(this, "control");26 this.anchors.end=new ta.Anchor(this, "end");27 };28 ta.DoubleArrowAnnotation.prototype=new ta.Annotation;29 var p=ta.DoubleArrowAnnotation.prototype;30 p.constructor=ta.DoubleArrowAnnotation;31 p.type=function(){ return 'DoubleArrow'; };32 p.getType=function(){ return ta.DoubleArrowAnnotation; };33 p._rot=function(){34 // arrowhead rotation35 var opp=this.control.y-this.start.y;36 var adj=this.control.x-this.start.x;37 this.startRotation=Math.atan2(opp,adj);38 opp=this.end.y-this.control.y;39 adj=this.end.x-this.control.x;40 this.endRotation=Math.atan2(opp,adj);41 };42 p._pos=function(){43 // text position44 var offset=this.textOffset;45 // figure out the pull of the curve and place accordingly46 if(this.control.y<this.end.y){ offset*=-1; }47 else { offset+=this.textYOffset; }48 var ab={49 x:((this.control.x-this.start.x)*.5)+this.start.x,50 y:((this.control.y-this.start.y)*.5)+this.start.y51 };52 var bc={53 x:((this.end.x-this.control.x)*.5)+this.control.x,54 y:((this.end.y-this.control.y)*.5)+this.control.y55 };56 this.textPosition={57 x:((bc.x-ab.x)*.5)+ab.x,58 y:(((bc.y-ab.y)*.5)+ab.y)+offset59 };60 };61 62 p.apply=function(obj){63 if(!obj){ return; }64 if(obj.documentElement){ obj=obj.documentElement; }65 this.readCommonAttrs(obj);66 67 for(var i=0; i<obj.childNodes.length; i++){68 var c=obj.childNodes[i];69 if(c.localName=="text"){ this.property('label',c.childNodes.length?c.childNodes[0].nodeValue:''); }70 else if(c.localName=="path"){71 // the line72 var d=c.getAttribute('d').split(" ");73 var s=d[0].split(",");74 this.start.x=parseFloat(s[0].substr(1),10);75 this.start.y=parseFloat(s[1],10);76 s=d[1].split(",");77 this.control.x=parseFloat(s[0].substr(1),10);78 this.control.y=parseFloat(s[1],10);79 s=d[2].split(",");80 this.end.x=parseFloat(s[0],10);81 this.end.y=parseFloat(s[1],10);82 var stroke=this.property('stroke');83 var style=c.getAttribute('style');84 var m=style.match(/stroke:([^;]+);/);85 if(m){86 stroke.color=m[1];87 this.property('fill',m[1]);88 }89 m=style.match(/stroke-width:([^;]+);/);90 if(m){91 stroke.width=m[1];92 }93 this.property('stroke',stroke);94 }95 }96 };97 p.initialize=function(obj){98 // create, based on passed DOM node if available.99 var font=(ta.Annotation.labelFont)?ta.Annotation.labelFont:{family:"Times", size:"16px"};100 this.apply(obj);101 // calculate the other positions102 this._rot();103 this._pos();104 // rotation matrix105 var rot=this.startRotation;106 var startRot=dojox.gfx.matrix.rotate(rot);107 rot=this.endRotation;108 var endRot=dojox.gfx.matrix.rotateAt(rot, this.end.x, this.end.y);109 // draw the shapes110 this.shape=this.figure.group.createGroup();111 this.shape.getEventSource().setAttribute("id", this.id);112 //if(this.transform.dx||this.transform.dy){ this.shape.setTransform(this.transform); }113 this.pathShape=this.shape.createPath("M"+this.start.x+" "+this.start.y+"Q"+this.control.x+" "+this.control.y+" "+this.end.x+" "+this.end.y + " l0,0")114 //.setStroke(this.property('stroke'));115 116 this.startArrowGroup=this.shape.createGroup().setTransform({ dx:this.start.x, dy:this.start.y });117 this.startArrowGroup.applyTransform(startRot);118 this.startArrow=this.startArrowGroup.createPath();//"M0,0 l20,-5 -3,5 3,5 Z").setFill(this.property('fill'));119 120 this.endArrowGroup=this.shape.createGroup().setTransform(endRot);121 this.endArrow=this.endArrowGroup.createPath();//("M" + this.end.x + "," + this.end.y + " l-20,-5 3,5 -3,5 Z").setFill(this.property('fill'));122 this.labelShape=this.shape.createText({123 x:this.textPosition.x,124 y:this.textPosition.y,125 text:this.property('label'),126 align:this.textAlign127 })128 //.setFont(font)129 .setFill(this.property('fill'));130 this.labelShape.getEventSource().setAttribute('id',this.id+"-labelShape");131 this.draw();132 };133 p.destroy=function(){134 if(!this.shape){ return; }135 this.startArrowGroup.remove(this.startArrow);136 this.endArrowGroup.remove(this.endArrow);137 this.shape.remove(this.startArrowGroup);138 this.shape.remove(this.endArrowGroup);139 this.shape.remove(this.pathShape);140 this.shape.remove(this.labelShape);141 this.figure.group.remove(this.shape);142 this.shape=this.pathShape=this.labelShape=this.startArrowGroup=this.startArrow=this.endArrowGroup=this.endArrow=null;143 };144 p.draw=function(obj){145 this.apply(obj);146 this._rot();147 this._pos();148 // rotation matrix149 var rot=this.startRotation;150 var startRot=dojox.gfx.matrix.rotate(rot);151 rot=this.endRotation;152 var endRot=dojox.gfx.matrix.rotateAt(rot, this.end.x, this.end.y);153 this.shape.setTransform(this.transform);154 this.pathShape.setShape("M"+this.start.x+" "+this.start.y+" Q"+this.control.x+" "+this.control.y+" "+this.end.x+" "+this.end.y + " l0,0")155 //.setStroke(this.property('stroke'));156 this.startArrowGroup.setTransform({ dx:this.start.x, dy:this.start.y }).applyTransform(startRot);157 this.startArrow.setFill(this.property('fill'));158 159 this.endArrowGroup.setTransform(endRot);160 this.endArrow.setFill(this.property('fill'));161 this.labelShape.setShape({162 x:this.textPosition.x,163 y:this.textPosition.y,164 text:this.property('label')165 })166 .setFill(this.property('fill'));167 this.zoom();168 };169 p.zoom=function(pct){170 if(this.startArrow){171 pct = pct || this.figure.zoomFactor;172 ta.Annotation.prototype.zoom.call(this,pct);173 var l=pct>1?20:Math.floor(20/pct), w=pct>1?5:Math.floor(5/pct),h=pct>1?3:Math.floor(3/pct);174 this.startArrow.setShape("M0,0 l"+l+",-"+w+" -"+h+","+w+" "+h+","+w+" Z");//.setFill(this.property('fill'));175 this.endArrow.setShape("M" + this.end.x + "," + this.end.y + " l-"+l+",-"+w+" "+h+","+w+" -"+h+","+w+" Z");176 }177 };178 179 p.getBBox=function(){180 var x=Math.min(this.start.x, this.control.x, this.end.x);181 var y=Math.min(this.start.y, this.control.y, this.end.y);182 var w=Math.max(this.start.x, this.control.x, this.end.x)-x;183 var h=Math.max(this.start.y, this.control.y, this.end.y)-y;184 return { x:x, y:y, width:w, height:h };185 };186 p.serialize=function(){187 var s=this.property('stroke');188 return '<g '+this.writeCommonAttrs()+'>'189 + '<path style="stroke:'+s.color+';stroke-width:'+s.width+';fill:none;" d="'190 + "M"+this.start.x+","+this.start.y+" "191 + "Q"+this.control.x+","+this.control.y+" "192 + this.end.x+","+this.end.y193 + '" />'194 + '<g transform="translate(' + this.start.x + "," + this.start.y + ") "195 + 'rotate(' + (Math.round((this.startRotation*(180/Math.PI))*Math.pow(10,4))/Math.pow(10,4)) + ')">'196 + '<path style="fill:'+s.color+';" d="M0,0 l20,-5, -3,5, 3,5 Z" />'197 + '</g>'198 + '<g transform="rotate('199 + (Math.round((this.endRotation*(180/Math.PI))*Math.pow(10,4))/Math.pow(10,4))200 + ", "+this.end.x+", "+this.end.y201 + ')">'202 + '<path style="fill:'+s.color+';" d="M'+this.end.x+","+this.end.y+' l-20,-5, 3,5, -3,5 Z" />'203 + '</g>'204 + '<text style="fill:'+s.color+';text-anchor:'+this.textAlign+'" font-weight="bold" '205 + 'x="' + this.textPosition.x + '" '206 + 'y="' + this.textPosition.y + '">'207 + this.property('label')208 + '</text>'209 + '</g>';210 };211 ta.Annotation.register("DoubleArrow");212 return dojox.sketch.DoubleArrowAnnotation;...
DoubleArrowAnnotation.js.uncompressed.js
Source:DoubleArrowAnnotation.js.uncompressed.js
1define("dojox/sketch/DoubleArrowAnnotation", ["dojo/_base/kernel", "dojo/_base/lang", "./Annotation", "./Anchor"], function(dojo){2 dojo.getObject("sketch", true, dojox);3 var ta=dojox.sketch;4 console.log(ta);5 ta.DoubleArrowAnnotation=function(figure, id){6 ta.Annotation.call(this, figure, id);7 this.transform={ dx:0, dy:0 };8 this.start={x:0, y:0};9 this.control={x:100, y:-50};10 this.end={x:200, y:0};11 this.textPosition={ x:0, y:0 };12 this.textOffset=6;13 this.textYOffset=10;14 this.textAlign="middle";15 this.startRotation=0;16 this.endRotation=0;17// this.property('label',this.id);18 this.labelShape=null;19 this.pathShape=null;20 this.startArrow=null;21 this.startArrowGroup=null;22 this.endArrow=null;23 this.endArrowGroup=null;24 this.anchors.start=new ta.Anchor(this, "start");25 this.anchors.control=new ta.Anchor(this, "control");26 this.anchors.end=new ta.Anchor(this, "end");27 };28 ta.DoubleArrowAnnotation.prototype=new ta.Annotation;29 var p=ta.DoubleArrowAnnotation.prototype;30 p.constructor=ta.DoubleArrowAnnotation;31 p.type=function(){ return 'DoubleArrow'; };32 p.getType=function(){ return ta.DoubleArrowAnnotation; };33 p._rot=function(){34 // arrowhead rotation35 var opp=this.control.y-this.start.y;36 var adj=this.control.x-this.start.x;37 this.startRotation=Math.atan2(opp,adj);38 opp=this.end.y-this.control.y;39 adj=this.end.x-this.control.x;40 this.endRotation=Math.atan2(opp,adj);41 };42 p._pos=function(){43 // text position44 var offset=this.textOffset;45 // figure out the pull of the curve and place accordingly46 if(this.control.y<this.end.y){ offset*=-1; }47 else { offset+=this.textYOffset; }48 var ab={49 x:((this.control.x-this.start.x)*.5)+this.start.x,50 y:((this.control.y-this.start.y)*.5)+this.start.y51 };52 var bc={53 x:((this.end.x-this.control.x)*.5)+this.control.x,54 y:((this.end.y-this.control.y)*.5)+this.control.y55 };56 this.textPosition={57 x:((bc.x-ab.x)*.5)+ab.x,58 y:(((bc.y-ab.y)*.5)+ab.y)+offset59 };60 };61 62 p.apply=function(obj){63 if(!obj){ return; }64 if(obj.documentElement){ obj=obj.documentElement; }65 this.readCommonAttrs(obj);66 67 for(var i=0; i<obj.childNodes.length; i++){68 var c=obj.childNodes[i];69 if(c.localName=="text"){ this.property('label',c.childNodes.length?c.childNodes[0].nodeValue:''); }70 else if(c.localName=="path"){71 // the line72 var d=c.getAttribute('d').split(" ");73 var s=d[0].split(",");74 this.start.x=parseFloat(s[0].substr(1),10);75 this.start.y=parseFloat(s[1],10);76 s=d[1].split(",");77 this.control.x=parseFloat(s[0].substr(1),10);78 this.control.y=parseFloat(s[1],10);79 s=d[2].split(",");80 this.end.x=parseFloat(s[0],10);81 this.end.y=parseFloat(s[1],10);82 var stroke=this.property('stroke');83 var style=c.getAttribute('style');84 var m=style.match(/stroke:([^;]+);/);85 if(m){86 stroke.color=m[1];87 this.property('fill',m[1]);88 }89 m=style.match(/stroke-width:([^;]+);/);90 if(m){91 stroke.width=m[1];92 }93 this.property('stroke',stroke);94 }95 }96 };97 p.initialize=function(obj){98 // create, based on passed DOM node if available.99 var font=(ta.Annotation.labelFont)?ta.Annotation.labelFont:{family:"Times", size:"16px"};100 this.apply(obj);101 // calculate the other positions102 this._rot();103 this._pos();104 // rotation matrix105 var rot=this.startRotation;106 var startRot=dojox.gfx.matrix.rotate(rot);107 rot=this.endRotation;108 var endRot=dojox.gfx.matrix.rotateAt(rot, this.end.x, this.end.y);109 // draw the shapes110 this.shape=this.figure.group.createGroup();111 this.shape.getEventSource().setAttribute("id", this.id);112 //if(this.transform.dx||this.transform.dy){ this.shape.setTransform(this.transform); }113 this.pathShape=this.shape.createPath("M"+this.start.x+" "+this.start.y+"Q"+this.control.x+" "+this.control.y+" "+this.end.x+" "+this.end.y + " l0,0")114 //.setStroke(this.property('stroke'));115 116 this.startArrowGroup=this.shape.createGroup().setTransform({ dx:this.start.x, dy:this.start.y });117 this.startArrowGroup.applyTransform(startRot);118 this.startArrow=this.startArrowGroup.createPath();//"M0,0 l20,-5 -3,5 3,5 Z").setFill(this.property('fill'));119 120 this.endArrowGroup=this.shape.createGroup().setTransform(endRot);121 this.endArrow=this.endArrowGroup.createPath();//("M" + this.end.x + "," + this.end.y + " l-20,-5 3,5 -3,5 Z").setFill(this.property('fill'));122 this.labelShape=this.shape.createText({123 x:this.textPosition.x,124 y:this.textPosition.y,125 text:this.property('label'),126 align:this.textAlign127 })128 //.setFont(font)129 .setFill(this.property('fill'));130 this.labelShape.getEventSource().setAttribute('id',this.id+"-labelShape");131 this.draw();132 };133 p.destroy=function(){134 if(!this.shape){ return; }135 this.startArrowGroup.remove(this.startArrow);136 this.endArrowGroup.remove(this.endArrow);137 this.shape.remove(this.startArrowGroup);138 this.shape.remove(this.endArrowGroup);139 this.shape.remove(this.pathShape);140 this.shape.remove(this.labelShape);141 this.figure.group.remove(this.shape);142 this.shape=this.pathShape=this.labelShape=this.startArrowGroup=this.startArrow=this.endArrowGroup=this.endArrow=null;143 };144 p.draw=function(obj){145 this.apply(obj);146 this._rot();147 this._pos();148 // rotation matrix149 var rot=this.startRotation;150 var startRot=dojox.gfx.matrix.rotate(rot);151 rot=this.endRotation;152 var endRot=dojox.gfx.matrix.rotateAt(rot, this.end.x, this.end.y);153 this.shape.setTransform(this.transform);154 this.pathShape.setShape("M"+this.start.x+" "+this.start.y+" Q"+this.control.x+" "+this.control.y+" "+this.end.x+" "+this.end.y + " l0,0")155 //.setStroke(this.property('stroke'));156 this.startArrowGroup.setTransform({ dx:this.start.x, dy:this.start.y }).applyTransform(startRot);157 this.startArrow.setFill(this.property('fill'));158 159 this.endArrowGroup.setTransform(endRot);160 this.endArrow.setFill(this.property('fill'));161 this.labelShape.setShape({162 x:this.textPosition.x,163 y:this.textPosition.y,164 text:this.property('label')165 })166 .setFill(this.property('fill'));167 this.zoom();168 };169 p.zoom=function(pct){170 if(this.startArrow){171 pct = pct || this.figure.zoomFactor;172 ta.Annotation.prototype.zoom.call(this,pct);173 var l=pct>1?20:Math.floor(20/pct), w=pct>1?5:Math.floor(5/pct),h=pct>1?3:Math.floor(3/pct);174 this.startArrow.setShape("M0,0 l"+l+",-"+w+" -"+h+","+w+" "+h+","+w+" Z");//.setFill(this.property('fill'));175 this.endArrow.setShape("M" + this.end.x + "," + this.end.y + " l-"+l+",-"+w+" "+h+","+w+" -"+h+","+w+" Z");176 }177 };178 179 p.getBBox=function(){180 var x=Math.min(this.start.x, this.control.x, this.end.x);181 var y=Math.min(this.start.y, this.control.y, this.end.y);182 var w=Math.max(this.start.x, this.control.x, this.end.x)-x;183 var h=Math.max(this.start.y, this.control.y, this.end.y)-y;184 return { x:x, y:y, width:w, height:h };185 };186 p.serialize=function(){187 var s=this.property('stroke');188 return '<g '+this.writeCommonAttrs()+'>'189 + '<path style="stroke:'+s.color+';stroke-width:'+s.width+';fill:none;" d="'190 + "M"+this.start.x+","+this.start.y+" "191 + "Q"+this.control.x+","+this.control.y+" "192 + this.end.x+","+this.end.y193 + '" />'194 + '<g transform="translate(' + this.start.x + "," + this.start.y + ") "195 + 'rotate(' + (Math.round((this.startRotation*(180/Math.PI))*Math.pow(10,4))/Math.pow(10,4)) + ')">'196 + '<path style="fill:'+s.color+';" d="M0,0 l20,-5, -3,5, 3,5 Z" />'197 + '</g>'198 + '<g transform="rotate('199 + (Math.round((this.endRotation*(180/Math.PI))*Math.pow(10,4))/Math.pow(10,4))200 + ", "+this.end.x+", "+this.end.y201 + ')">'202 + '<path style="fill:'+s.color+';" d="M'+this.end.x+","+this.end.y+' l-20,-5, 3,5, -3,5 Z" />'203 + '</g>'204 + '<text style="fill:'+s.color+';text-anchor:'+this.textAlign+'" font-weight="bold" '205 + 'x="' + this.textPosition.x + '" '206 + 'y="' + this.textPosition.y + '">'207 + this.property('label')208 + '</text>'209 + '</g>';210 };211 ta.Annotation.register("DoubleArrow");212 return dojox.sketch.DoubleArrowAnnotation;...
DoubleArrowAnnotation.js
Source:DoubleArrowAnnotation.js
1dojo.provide("dojox.sketch.DoubleArrowAnnotation");2dojo.require("dojox.sketch.Annotation");3dojo.require("dojox.sketch.Anchor");4(function(){5 var ta=dojox.sketch;6 ta.DoubleArrowAnnotation=function(figure, id){7 ta.Annotation.call(this, figure, id);8 this.transform={ dx:0, dy:0 };9 this.start={x:0, y:0};10 this.control={x:100, y:-50};11 this.end={x:200, y:0};12 this.textPosition={ x:0, y:0 };13 this.textOffset=6;14 this.textYOffset=10;15 this.textAlign="middle";16 this.startRotation=0;17 this.endRotation=0;18// this.property('label',this.id);19 this.labelShape=null;20 this.pathShape=null;21 this.startArrow=null;22 this.startArrowGroup=null;23 this.endArrow=null;24 this.endArrowGroup=null;25 this.anchors.start=new ta.Anchor(this, "start");26 this.anchors.control=new ta.Anchor(this, "control");27 this.anchors.end=new ta.Anchor(this, "end");28 };29 ta.DoubleArrowAnnotation.prototype=new ta.Annotation;30 var p=ta.DoubleArrowAnnotation.prototype;31 p.constructor=ta.DoubleArrowAnnotation;32 p.type=function(){ return 'DoubleArrow'; };33 p.getType=function(){ return ta.DoubleArrowAnnotation; };34 p._rot=function(){35 // arrowhead rotation36 var opp=this.control.y-this.start.y;37 var adj=this.control.x-this.start.x;38 this.startRotation=Math.atan2(opp,adj);39 opp=this.end.y-this.control.y;40 adj=this.end.x-this.control.x;41 this.endRotation=Math.atan2(opp,adj);42 };43 p._pos=function(){44 // text position45 var offset=this.textOffset;46 // figure out the pull of the curve and place accordingly47 if(this.control.y<this.end.y){ offset*=-1; }48 else { offset+=this.textYOffset; }49 var ab={50 x:((this.control.x-this.start.x)*.5)+this.start.x, 51 y:((this.control.y-this.start.y)*.5)+this.start.y52 };53 var bc={54 x:((this.end.x-this.control.x)*.5)+this.control.x, 55 y:((this.end.y-this.control.y)*.5)+this.control.y56 };57 this.textPosition={58 x:((bc.x-ab.x)*.5)+ab.x, 59 y:(((bc.y-ab.y)*.5)+ab.y)+offset60 };61 };62 63 p.apply=function(obj){64 if(!obj){ return; }65 if(obj.documentElement){ obj=obj.documentElement; }66 this.readCommonAttrs(obj);67 68 for(var i=0; i<obj.childNodes.length; i++){69 var c=obj.childNodes[i];70 if(c.localName=="text"){ this.property('label',c.childNodes.length?c.childNodes[0].nodeValue:''); }71 else if(c.localName=="path"){72 // the line73 var d=c.getAttribute('d').split(" ");74 var s=d[0].split(",");75 this.start.x=parseFloat(s[0].substr(1),10);76 this.start.y=parseFloat(s[1],10);77 s=d[1].split(",");78 this.control.x=parseFloat(s[0].substr(1),10);79 this.control.y=parseFloat(s[1],10);80 s=d[2].split(",");81 this.end.x=parseFloat(s[0],10);82 this.end.y=parseFloat(s[1],10);83 var stroke=this.property('stroke');84 var style=c.getAttribute('style');85 var m=style.match(/stroke:([^;]+);/);86 if(m){87 stroke.color=m[1];88 this.property('fill',m[1]);89 }90 m=style.match(/stroke-width:([^;]+);/);91 if(m){92 stroke.width=m[1];93 }94 this.property('stroke',stroke);95 }96 }97 };98 p.initialize=function(obj){99 // create, based on passed DOM node if available.100 var font=(ta.Annotation.labelFont)?ta.Annotation.labelFont:{family:"Times", size:"16px"};101 this.apply(obj);102 // calculate the other positions103 this._rot();104 this._pos();105 // rotation matrix106 var rot=this.startRotation;107 var startRot=dojox.gfx.matrix.rotate(rot);108 rot=this.endRotation;109 var endRot=dojox.gfx.matrix.rotateAt(rot, this.end.x, this.end.y);110 // draw the shapes111 this.shape=this.figure.group.createGroup();112 this.shape.getEventSource().setAttribute("id", this.id);113 //if(this.transform.dx||this.transform.dy){ this.shape.setTransform(this.transform); }114 this.pathShape=this.shape.createPath("M"+this.start.x+" "+this.start.y+"Q"+this.control.x+" "+this.control.y+" "+this.end.x+" "+this.end.y + " l0,0")115 //.setStroke(this.property('stroke'));116 117 this.startArrowGroup=this.shape.createGroup().setTransform({ dx:this.start.x, dy:this.start.y });118 this.startArrowGroup.applyTransform(startRot);119 this.startArrow=this.startArrowGroup.createPath();//"M0,0 l20,-5 -3,5 3,5 Z").setFill(this.property('fill'));120 121 this.endArrowGroup=this.shape.createGroup().setTransform(endRot);122 this.endArrow=this.endArrowGroup.createPath();//("M" + this.end.x + "," + this.end.y + " l-20,-5 3,5 -3,5 Z").setFill(this.property('fill'));123 this.labelShape=this.shape.createText({124 x:this.textPosition.x, 125 y:this.textPosition.y, 126 text:this.property('label'), 127 align:this.textAlign128 })129 //.setFont(font)130 .setFill(this.property('fill'));131 this.labelShape.getEventSource().setAttribute('id',this.id+"-labelShape");132 this.draw();133 };134 p.destroy=function(){135 if(!this.shape){ return; }136 this.startArrowGroup.remove(this.startArrow);137 this.endArrowGroup.remove(this.endArrow);138 this.shape.remove(this.startArrowGroup);139 this.shape.remove(this.endArrowGroup);140 this.shape.remove(this.pathShape);141 this.shape.remove(this.labelShape);142 this.figure.group.remove(this.shape);143 this.shape=this.pathShape=this.labelShape=this.startArrowGroup=this.startArrow=this.endArrowGroup=this.endArrow=null;144 };145 p.draw=function(obj){146 this.apply(obj);147 this._rot();148 this._pos();149 // rotation matrix150 var rot=this.startRotation;151 var startRot=dojox.gfx.matrix.rotate(rot);152 rot=this.endRotation;153 var endRot=dojox.gfx.matrix.rotateAt(rot, this.end.x, this.end.y);154 this.shape.setTransform(this.transform);155 this.pathShape.setShape("M"+this.start.x+" "+this.start.y+" Q"+this.control.x+" "+this.control.y+" "+this.end.x+" "+this.end.y + " l0,0")156 //.setStroke(this.property('stroke'));157 this.startArrowGroup.setTransform({ dx:this.start.x, dy:this.start.y }).applyTransform(startRot);158 this.startArrow.setFill(this.property('fill'));159 160 this.endArrowGroup.setTransform(endRot);161 this.endArrow.setFill(this.property('fill'));162 this.labelShape.setShape({163 x:this.textPosition.x, 164 y:this.textPosition.y, 165 text:this.property('label')166 })167 .setFill(this.property('fill'));168 this.zoom();169 };170 p.zoom=function(pct){171 if(this.startArrow){172 pct = pct || this.figure.zoomFactor;173 ta.Annotation.prototype.zoom.call(this,pct);174 var l=pct>1?20:Math.floor(20/pct), w=pct>1?5:Math.floor(5/pct),h=pct>1?3:Math.floor(3/pct);175 this.startArrow.setShape("M0,0 l"+l+",-"+w+" -"+h+","+w+" "+h+","+w+" Z");//.setFill(this.property('fill'));176 this.endArrow.setShape("M" + this.end.x + "," + this.end.y + " l-"+l+",-"+w+" "+h+","+w+" -"+h+","+w+" Z");177 }178 };179 180 p.getBBox=function(){181 var x=Math.min(this.start.x, this.control.x, this.end.x);182 var y=Math.min(this.start.y, this.control.y, this.end.y);183 var w=Math.max(this.start.x, this.control.x, this.end.x)-x;184 var h=Math.max(this.start.y, this.control.y, this.end.y)-y;185 return { x:x, y:y, width:w, height:h };186 };187 p.serialize=function(){188 var s=this.property('stroke');189 return '<g '+this.writeCommonAttrs()+'>'190 + '<path style="stroke:'+s.color+';stroke-width:'+s.width+';fill:none;" d="'191 + "M"+this.start.x+","+this.start.y+" "192 + "Q"+this.control.x+","+this.control.y+" "193 + this.end.x+","+this.end.y194 + '" />'195 + '<g transform="translate(' + this.start.x + "," + this.start.y + ") "196 + 'rotate(' + (Math.round((this.startRotation*(180/Math.PI))*Math.pow(10,4))/Math.pow(10,4)) + ')">'197 + '<path style="fill:'+s.color+';" d="M0,0 l20,-5, -3,5, 3,5 Z" />'198 + '</g>'199 + '<g transform="rotate('200 + (Math.round((this.endRotation*(180/Math.PI))*Math.pow(10,4))/Math.pow(10,4))201 + ", "+this.end.x+", "+this.end.y202 + ')">'203 + '<path style="fill:'+s.color+';" d="M'+this.end.x+","+this.end.y+' l-20,-5, 3,5, -3,5 Z" />'204 + '</g>'205 + '<text style="fill:'+s.color+';text-anchor:'+this.textAlign+'" font-weight="bold" '206 + 'x="' + this.textPosition.x + '" '207 + 'y="' + this.textPosition.y + '">'208 + this.property('label')209 + '</text>'210 + '</g>';211 };212 ta.Annotation.register("DoubleArrow");...
PreexistingAnnotation.js.uncompressed.js
Source:PreexistingAnnotation.js.uncompressed.js
1define("dojox/sketch/PreexistingAnnotation", ["dojo/_base/kernel", "dojo/_base/lang", "./Annotation", "./Anchor"], function(dojo){2 dojo.getObject("sketch", true, dojox);3 var ta=dojox.sketch;4 ta.PreexistingAnnotation=function(figure, id){5 ta.Annotation.call(this, figure, id);6 this.transform={dx:0, dy:0};7 this.start={ x:0, y:0 };8 this.end={ x:200, y:200 };9 this.radius=8;10 this.textPosition={ x:196, y:196 };11 this.textOffset=4;12 this.textAlign="end";13 //this.property('label',this.id);14 this.rectShape=null;15 this.labelShape=null;16 this.anchors.start=new ta.Anchor(this, "start");17 this.anchors.end=new ta.Anchor(this, "end");18 };19 ta.PreexistingAnnotation.prototype=new ta.Annotation;20 var p=ta.PreexistingAnnotation.prototype;21 p.constructor=ta.PreexistingAnnotation;22 p.type=function(){ return 'Preexisting' };23 p.getType=function(){ return ta.PreexistingAnnotation; };24 p._pos=function(){25 var x=Math.min(this.start.x, this.end.x);26 var y=Math.min(this.start.y, this.end.y);27 var w=Math.max(this.start.x, this.end.x);28 var h=Math.max(this.start.y, this.end.y);29 this.start={ x:x, y:y };30 this.end={ x:w, y:h };31 this.textPosition={ x:this.end.x-this.textOffset, y:this.end.y-this.textOffset };32 };33 p.apply=function(obj){34 if(!obj){ return; }35 if(obj.documentElement){ obj=obj.documentElement; }36 this.readCommonAttrs(obj);37 38 for(var i=0; i<obj.childNodes.length; i++){39 var c=obj.childNodes[i];40 if(c.localName=="text"){41 this.property('label',c.childNodes.length?c.childNodes[0].nodeValue:'');42 }43 else if(c.localName=="rect"){44 if(c.getAttribute('x')!==null){ this.start.x=parseFloat(c.getAttribute('x'), 10); }45 if(c.getAttribute('width')!==null){ this.end.x=parseFloat(c.getAttribute('width'), 10)+parseFloat(c.getAttribute('x'), 10); }46 if(c.getAttribute('y')!==null){ this.start.y=parseFloat(c.getAttribute('y'), 10); }47 if(c.getAttribute('height')!==null){ this.end.y=parseFloat(c.getAttribute('height'), 10)+parseFloat(c.getAttribute('y'), 10); }48 if(c.getAttribute('r')!==null){ this.radius=parseFloat(c.getAttribute('r'),10); }49 var stroke=this.property('stroke');50 var style=c.getAttribute('style');51 var m=style.match(/stroke:([^;]+);/);52 if(m){53 stroke.color=m[1];54 this.property('fill',m[1]);55 }56 m=style.match(/stroke-width:([^;]+);/);57 if(m){58 stroke.width=m[1];59 }60 this.property('stroke',stroke);61 }62 }63 };64 p.initialize=function(obj){65 this.apply(obj);66 this._pos();67 // create either from scratch or based on the passed node68 this.shape=this.figure.group.createGroup();69 this.shape.getEventSource().setAttribute("id", this.id);70 //if(this.transform.dx || this.transform.dy){ this.shape.setTransform(this.transform); }71 this.rectShape=this.shape.createRect({72 x:this.start.x,73 y: this.start.y,74 width: this.end.x-this.start.x,75 height:this.end.y-this.start.y,76 r:this.radius77 })78 //.setStroke({color:this.property('fill'), width:1})79 .setFill([255,255,255,0.1]);80 this.rectShape.getEventSource().setAttribute("shape-rendering","crispEdges");81 this.labelShape=this.shape.createText({82 x:this.textPosition.x,83 y:this.textPosition.y,84 text:this.property('label'),85 align:this.textAlign86 })87 //.setFont(font)88 .setFill(this.property('fill'));89 this.labelShape.getEventSource().setAttribute('id',this.id+"-labelShape");90 this.draw();91 };92 p.destroy=function(){93 if(!this.shape){ return; }94 this.shape.remove(this.rectShape);95 this.shape.remove(this.labelShape);96 this.figure.group.remove(this.shape);97 this.shape=this.rectShape=this.labelShape=null;98 };99 p.getBBox=function(){100 var x=Math.min(this.start.x, this.end.x);101 var y=Math.min(this.start.y, this.end.y);102 var w=Math.max(this.start.x, this.end.x)-x;103 var h=Math.max(this.start.y, this.end.y)-y;104 return { x:x-2, y:y-2, width:w+4, height:h+4 };105 };106 p.draw=function(obj){107 this.apply(obj);108 this._pos();109 this.shape.setTransform(this.transform);110 this.rectShape.setShape({111 x:this.start.x,112 y: this.start.y,113 width: this.end.x-this.start.x,114 height:this.end.y-this.start.y,115 r:this.radius116 })117 //.setStroke({ color:this.property('fill'), width:1 })118 .setFill([255,255,255,0.1]);119 this.labelShape.setShape({120 x:this.textPosition.x,121 y:this.textPosition.y,122 text:this.property('label')123 })124 .setFill(this.property('fill'));125 this.zoom();126 };127 p.zoom=function(pct){128 if(this.rectShape){129 pct = pct || this.figure.zoomFactor;130 ta.Annotation.prototype.zoom.call(this,pct);131 pct = dojox.gfx.renderer=='vml'?1:pct;132 this.rectShape.setStroke({color:this.property('fill'), width:1/pct});133 }134 };135 p.serialize=function(){136 var s=this.property('stroke');137 return '<g '+this.writeCommonAttrs()+'>'138 + '<rect style="stroke:'+s.color+';stroke-width:1;fill:none;" '139 + 'x="' + this.start.x + '" '140 + 'width="' + (this.end.x-this.start.x) + '" '141 + 'y="' + this.start.y + '" '142 + 'height="' + (this.end.y-this.start.y) + '" '143 + 'rx="' + this.radius + '" '144 + 'ry="' + this.radius + '" '145 + ' />'146 + '<text style="fill:'+s.color+';text-anchor:'+this.textAlign+'" font-weight="bold" '147 + 'x="' + this.textPosition.x + '" '148 + 'y="' + this.textPosition.y + '">'149 + this.property('label')150 + '</text>'151 + '</g>';152 };153 ta.Annotation.register("Preexisting");154 return dojox.sketch.PreexistingAnnotation;...
PreexistingAnnotation.js.consoleStripped.js
Source:PreexistingAnnotation.js.consoleStripped.js
1define("dojox/sketch/PreexistingAnnotation", ["dojo/_base/kernel", "dojo/_base/lang", "./Annotation", "./Anchor"], function(dojo){2 dojo.getObject("sketch", true, dojox);3 var ta=dojox.sketch;4 ta.PreexistingAnnotation=function(figure, id){5 ta.Annotation.call(this, figure, id);6 this.transform={dx:0, dy:0};7 this.start={ x:0, y:0 };8 this.end={ x:200, y:200 };9 this.radius=8;10 this.textPosition={ x:196, y:196 };11 this.textOffset=4;12 this.textAlign="end";13 //this.property('label',this.id);14 this.rectShape=null;15 this.labelShape=null;16 this.anchors.start=new ta.Anchor(this, "start");17 this.anchors.end=new ta.Anchor(this, "end");18 };19 ta.PreexistingAnnotation.prototype=new ta.Annotation;20 var p=ta.PreexistingAnnotation.prototype;21 p.constructor=ta.PreexistingAnnotation;22 p.type=function(){ return 'Preexisting' };23 p.getType=function(){ return ta.PreexistingAnnotation; };24 p._pos=function(){25 var x=Math.min(this.start.x, this.end.x);26 var y=Math.min(this.start.y, this.end.y);27 var w=Math.max(this.start.x, this.end.x);28 var h=Math.max(this.start.y, this.end.y);29 this.start={ x:x, y:y };30 this.end={ x:w, y:h };31 this.textPosition={ x:this.end.x-this.textOffset, y:this.end.y-this.textOffset };32 };33 p.apply=function(obj){34 if(!obj){ return; }35 if(obj.documentElement){ obj=obj.documentElement; }36 this.readCommonAttrs(obj);37 38 for(var i=0; i<obj.childNodes.length; i++){39 var c=obj.childNodes[i];40 if(c.localName=="text"){41 this.property('label',c.childNodes.length?c.childNodes[0].nodeValue:'');42 }43 else if(c.localName=="rect"){44 if(c.getAttribute('x')!==null){ this.start.x=parseFloat(c.getAttribute('x'), 10); }45 if(c.getAttribute('width')!==null){ this.end.x=parseFloat(c.getAttribute('width'), 10)+parseFloat(c.getAttribute('x'), 10); }46 if(c.getAttribute('y')!==null){ this.start.y=parseFloat(c.getAttribute('y'), 10); }47 if(c.getAttribute('height')!==null){ this.end.y=parseFloat(c.getAttribute('height'), 10)+parseFloat(c.getAttribute('y'), 10); }48 if(c.getAttribute('r')!==null){ this.radius=parseFloat(c.getAttribute('r'),10); }49 var stroke=this.property('stroke');50 var style=c.getAttribute('style');51 var m=style.match(/stroke:([^;]+);/);52 if(m){53 stroke.color=m[1];54 this.property('fill',m[1]);55 }56 m=style.match(/stroke-width:([^;]+);/);57 if(m){58 stroke.width=m[1];59 }60 this.property('stroke',stroke);61 }62 }63 };64 p.initialize=function(obj){65 this.apply(obj);66 this._pos();67 // create either from scratch or based on the passed node68 this.shape=this.figure.group.createGroup();69 this.shape.getEventSource().setAttribute("id", this.id);70 //if(this.transform.dx || this.transform.dy){ this.shape.setTransform(this.transform); }71 this.rectShape=this.shape.createRect({72 x:this.start.x,73 y: this.start.y,74 width: this.end.x-this.start.x,75 height:this.end.y-this.start.y,76 r:this.radius77 })78 //.setStroke({color:this.property('fill'), width:1})79 .setFill([255,255,255,0.1]);80 this.rectShape.getEventSource().setAttribute("shape-rendering","crispEdges");81 this.labelShape=this.shape.createText({82 x:this.textPosition.x,83 y:this.textPosition.y,84 text:this.property('label'),85 align:this.textAlign86 })87 //.setFont(font)88 .setFill(this.property('fill'));89 this.labelShape.getEventSource().setAttribute('id',this.id+"-labelShape");90 this.draw();91 };92 p.destroy=function(){93 if(!this.shape){ return; }94 this.shape.remove(this.rectShape);95 this.shape.remove(this.labelShape);96 this.figure.group.remove(this.shape);97 this.shape=this.rectShape=this.labelShape=null;98 };99 p.getBBox=function(){100 var x=Math.min(this.start.x, this.end.x);101 var y=Math.min(this.start.y, this.end.y);102 var w=Math.max(this.start.x, this.end.x)-x;103 var h=Math.max(this.start.y, this.end.y)-y;104 return { x:x-2, y:y-2, width:w+4, height:h+4 };105 };106 p.draw=function(obj){107 this.apply(obj);108 this._pos();109 this.shape.setTransform(this.transform);110 this.rectShape.setShape({111 x:this.start.x,112 y: this.start.y,113 width: this.end.x-this.start.x,114 height:this.end.y-this.start.y,115 r:this.radius116 })117 //.setStroke({ color:this.property('fill'), width:1 })118 .setFill([255,255,255,0.1]);119 this.labelShape.setShape({120 x:this.textPosition.x,121 y:this.textPosition.y,122 text:this.property('label')123 })124 .setFill(this.property('fill'));125 this.zoom();126 };127 p.zoom=function(pct){128 if(this.rectShape){129 pct = pct || this.figure.zoomFactor;130 ta.Annotation.prototype.zoom.call(this,pct);131 pct = dojox.gfx.renderer=='vml'?1:pct;132 this.rectShape.setStroke({color:this.property('fill'), width:1/pct});133 }134 };135 p.serialize=function(){136 var s=this.property('stroke');137 return '<g '+this.writeCommonAttrs()+'>'138 + '<rect style="stroke:'+s.color+';stroke-width:1;fill:none;" '139 + 'x="' + this.start.x + '" '140 + 'width="' + (this.end.x-this.start.x) + '" '141 + 'y="' + this.start.y + '" '142 + 'height="' + (this.end.y-this.start.y) + '" '143 + 'rx="' + this.radius + '" '144 + 'ry="' + this.radius + '" '145 + ' />'146 + '<text style="fill:'+s.color+';text-anchor:'+this.textAlign+'" font-weight="bold" '147 + 'x="' + this.textPosition.x + '" '148 + 'y="' + this.textPosition.y + '">'149 + this.property('label')150 + '</text>'151 + '</g>';152 };153 ta.Annotation.register("Preexisting");154 return dojox.sketch.PreexistingAnnotation;...
PreexistingAnnotation.js
Source:PreexistingAnnotation.js
1dojo.provide("dojox.sketch.PreexistingAnnotation");2dojo.require("dojox.sketch.Annotation");3dojo.require("dojox.sketch.Anchor");4(function(){5 var ta=dojox.sketch;6 ta.PreexistingAnnotation=function(figure, id){7 ta.Annotation.call(this, figure, id);8 this.transform={dx:0, dy:0};9 this.start={ x:0, y:0 };10 this.end={ x:200, y:200 };11 this.radius=8;12 this.textPosition={ x:196, y:196 };13 this.textOffset=4;14 this.textAlign="end";15 //this.property('label',this.id);16 this.rectShape=null;17 this.labelShape=null;18 this.anchors.start=new ta.Anchor(this, "start");19 this.anchors.end=new ta.Anchor(this, "end");20 };21 ta.PreexistingAnnotation.prototype=new ta.Annotation;22 var p=ta.PreexistingAnnotation.prototype;23 p.constructor=ta.PreexistingAnnotation;24 p.type=function(){ return 'Preexisting' };25 p.getType=function(){ return ta.PreexistingAnnotation; };26 p._pos=function(){27 var x=Math.min(this.start.x, this.end.x);28 var y=Math.min(this.start.y, this.end.y);29 var w=Math.max(this.start.x, this.end.x);30 var h=Math.max(this.start.y, this.end.y);31 this.start={ x:x, y:y };32 this.end={ x:w, y:h };33 this.textPosition={ x:this.end.x-this.textOffset, y:this.end.y-this.textOffset };34 };35 p.apply=function(obj){36 if(!obj){ return; }37 if(obj.documentElement){ obj=obj.documentElement; }38 this.readCommonAttrs(obj);39 40 for(var i=0; i<obj.childNodes.length; i++){41 var c=obj.childNodes[i];42 if(c.localName=="text"){ 43 this.property('label',c.childNodes.length?c.childNodes[0].nodeValue:'');44 }45 else if(c.localName=="rect"){46 if(c.getAttribute('x')!==null){ this.start.x=parseFloat(c.getAttribute('x'), 10); }47 if(c.getAttribute('width')!==null){ this.end.x=parseFloat(c.getAttribute('width'), 10)+parseFloat(c.getAttribute('x'), 10); }48 if(c.getAttribute('y')!==null){ this.start.y=parseFloat(c.getAttribute('y'), 10); }49 if(c.getAttribute('height')!==null){ this.end.y=parseFloat(c.getAttribute('height'), 10)+parseFloat(c.getAttribute('y'), 10); }50 if(c.getAttribute('r')!==null){ this.radius=parseFloat(c.getAttribute('r'),10); }51 var stroke=this.property('stroke');52 var style=c.getAttribute('style');53 var m=style.match(/stroke:([^;]+);/);54 if(m){55 stroke.color=m[1];56 this.property('fill',m[1]);57 }58 m=style.match(/stroke-width:([^;]+);/);59 if(m){60 stroke.width=m[1];61 }62 this.property('stroke',stroke);63 }64 }65 };66 p.initialize=function(obj){67 this.apply(obj);68 this._pos();69 // create either from scratch or based on the passed node70 this.shape=this.figure.group.createGroup();71 this.shape.getEventSource().setAttribute("id", this.id);72 //if(this.transform.dx || this.transform.dy){ this.shape.setTransform(this.transform); }73 this.rectShape=this.shape.createRect({74 x:this.start.x, 75 y: this.start.y, 76 width: this.end.x-this.start.x, 77 height:this.end.y-this.start.y, 78 r:this.radius79 })80 //.setStroke({color:this.property('fill'), width:1})81 .setFill([255,255,255,0.1]);82 this.rectShape.getEventSource().setAttribute("shape-rendering","crispEdges");83 this.labelShape=this.shape.createText({84 x:this.textPosition.x, 85 y:this.textPosition.y, 86 text:this.property('label'), 87 align:this.textAlign88 })89 //.setFont(font)90 .setFill(this.property('fill'));91 this.labelShape.getEventSource().setAttribute('id',this.id+"-labelShape");92 this.draw();93 };94 p.destroy=function(){95 if(!this.shape){ return; }96 this.shape.remove(this.rectShape);97 this.shape.remove(this.labelShape);98 this.figure.group.remove(this.shape);99 this.shape=this.rectShape=this.labelShape=null;100 };101 p.getBBox=function(){102 var x=Math.min(this.start.x, this.end.x);103 var y=Math.min(this.start.y, this.end.y);104 var w=Math.max(this.start.x, this.end.x)-x;105 var h=Math.max(this.start.y, this.end.y)-y;106 return { x:x-2, y:y-2, width:w+4, height:h+4 };107 };108 p.draw=function(obj){109 this.apply(obj);110 this._pos();111 this.shape.setTransform(this.transform);112 this.rectShape.setShape({113 x:this.start.x, 114 y: this.start.y, 115 width: this.end.x-this.start.x, 116 height:this.end.y-this.start.y, 117 r:this.radius118 })119 //.setStroke({ color:this.property('fill'), width:1 })120 .setFill([255,255,255,0.1]);121 this.labelShape.setShape({ 122 x:this.textPosition.x, 123 y:this.textPosition.y, 124 text:this.property('label') 125 })126 .setFill(this.property('fill'));127 this.zoom();128 };129 p.zoom=function(pct){130 if(this.rectShape){131 pct = pct || this.figure.zoomFactor;132 ta.Annotation.prototype.zoom.call(this,pct);133 pct = dojox.gfx.renderer=='vml'?1:pct;134 this.rectShape.setStroke({color:this.property('fill'), width:1/pct});135 }136 };137 p.serialize=function(){138 var s=this.property('stroke');139 return '<g '+this.writeCommonAttrs()+'>'140 + '<rect style="stroke:'+s.color+';stroke-width:1;fill:none;" '141 + 'x="' + this.start.x + '" '142 + 'width="' + (this.end.x-this.start.x) + '" '143 + 'y="' + this.start.y + '" '144 + 'height="' + (this.end.y-this.start.y) + '" '145 + 'rx="' + this.radius + '" '146 + 'ry="' + this.radius + '" '147 + ' />'148 + '<text style="fill:'+s.color+';text-anchor:'+this.textAlign+'" font-weight="bold" '149 + 'x="' + this.textPosition.x + '" '150 + 'y="' + this.textPosition.y + '">'151 + this.property('label')152 + '</text>'153 + '</g>';154 };155 ta.Annotation.register("Preexisting");...
range.js
Source:range.js
1/* ***** BEGIN LICENSE BLOCK *****2 * Version: MPL 1.1/GPL 2.0/LGPL 2.13 *4 * The contents of this file are subject to the Mozilla Public License Version5 * 1.1 (the "License"); you may not use this file except in compliance with6 * the License. You may obtain a copy of the License at7 * http://www.mozilla.org/MPL/8 *9 * Software distributed under the License is distributed on an "AS IS" basis,10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License11 * for the specific language governing rights and limitations under the12 * License.13 *14 * The Original Code is Ajax.org Code Editor (ACE).15 *16 * The Initial Developer of the Original Code is17 * Ajax.org Services B.V.18 * Portions created by the Initial Developer are Copyright (C) 201019 * the Initial Developer. All Rights Reserved.20 *21 * Contributor(s):22 * Fabian Jakobs <fabian AT ajax DOT org>23 *24 * Alternatively, the contents of this file may be used under the terms of25 * either the GNU General Public License Version 2 or later (the "GPL"), or26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),27 * in which case the provisions of the GPL or the LGPL are applicable instead28 * of those above. If you wish to allow use of your version of this file only29 * under the terms of either the GPL or the LGPL, and not to allow others to30 * use your version of this file under the terms of the MPL, indicate your31 * decision by deleting the provisions above and replace them with the notice32 * and other provisions required by the GPL or the LGPL. If you do not delete33 * the provisions above, a recipient may use your version of this file under34 * the terms of any one of the MPL, the GPL or the LGPL.35 *36 * ***** END LICENSE BLOCK ***** */37define(function(require, exports, module) {38var Range = function(startRow, startColumn, endRow, endColumn) {39 this.start = {40 row: startRow,41 column: startColumn42 };43 this.end = {44 row: endRow,45 column: endColumn46 };47};48(function() {49 this.toString = function() {50 return ("Range: [" + this.start.row + "/" + this.start.column +51 "] -> [" + this.end.row + "/" + this.end.column + "]");52 };53 this.contains = function(row, column) {54 return this.compare(row, column) == 0;55 };56 this.compare = function(row, column) {57 if (!this.isMultiLine()) {58 if (row === this.start.row) {59 return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);60 };61 }62 if (row < this.start.row)63 return -1;64 if (row > this.end.row)65 return 1;66 if (this.start.row === row)67 return column >= this.start.column ? 0 : -1;68 if (this.end.row === row)69 return column <= this.end.column ? 0 : 1;70 return 0;71 };72 this.clipRows = function(firstRow, lastRow) {73 if (this.end.row > lastRow) {74 var end = {75 row: lastRow+1,76 column: 077 };78 }79 if (this.start.row > lastRow) {80 var start = {81 row: lastRow+1,82 column: 083 };84 }85 if (this.start.row < firstRow) {86 var start = {87 row: firstRow,88 column: 089 };90 }91 if (this.end.row < firstRow) {92 var end = {93 row: firstRow,94 column: 095 };96 }97 return Range.fromPoints(start || this.start, end || this.end);98 };99 this.extend = function(row, column) {100 var cmp = this.compare(row, column);101 if (cmp == 0)102 return this;103 else if (cmp == -1)104 var start = {row: row, column: column};105 else106 var end = {row: row, column: column};107 return Range.fromPoints(start || this.start, end || this.end);108 };109 this.isEmpty = function() {110 return (this.start.row == this.end.row && this.start.column == this.end.column);111 };112 this.isMultiLine = function() {113 return (this.start.row !== this.end.row);114 };115 this.clone = function() {116 return Range.fromPoints(this.start, this.end);117 };118 119 this.collapseRows = function() {120 if (this.end.column == 0)121 return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0)122 else123 return new Range(this.start.row, 0, this.end.row, 0)124 };125 this.toScreenRange = function(doc) {126 return new Range(127 this.start.row, doc.documentToScreenColumn(this.start.row, this.start.column),128 this.end.row, doc.documentToScreenColumn(this.end.row, this.end.column)129 );130 };131}).call(Range.prototype);132Range.fromPoints = function(start, end) {133 return new Range(start.row, start.column, end.row, end.column);134};135exports.Range = Range;...
buffer.js
Source:buffer.js
1var Buffer = HTML5.Buffer = function Buffer() {2 this.data = '';3 this.start = 0;4 this.committed = 0;5 this.eof = false;6};7Buffer.prototype = {8 slice: function() {9 if(this.start >= this.data.length) {10 if(!this.eof) throw HTML5.DRAIN;11 return HTML5.EOF;12 }13 return this.data.slice(this.start, this.data.length);14 },15 char: function() {16 if(!this.eof && this.start >= this.data.length - 1) throw HTML5.DRAIN;17 if(this.start >= this.data.length) {18 return HTML5.EOF;19 }20 return this.data[this.start++];21 },22 advance: function(amount) {23 this.start += amount;24 if(this.start >= this.data.length) {25 if(!this.eof) throw HTML5.DRAIN;26 return HTML5.EOF;27 } else {28 if(this.committed > this.data.length / 2) {29 // Sliiiide30 this.data = this.data.slice(this.committed);31 this.start = this.start - this.committed;32 this.committed = 0;33 }34 }35 },36 matchWhile: function(re) {37 if(this.eof && this.start >= this.data.length ) return '';38 var r = new RegExp("^"+re+"+");39 var m = r.exec(this.slice());40 if(m) {41 if(!this.eof && m[0].length == this.data.length - this.start) throw HTML5.DRAIN;42 this.advance(m[0].length);43 return m[0];44 } else {45 return '';46 }47 },48 matchUntil: function(re) {49 var m, s;50 s = this.slice();51 if(s === HTML5.EOF) {52 return '';53 } else if(m = new RegExp(re + (this.eof ? "|\0|$" : "|\0")).exec(this.slice())) {54 var t = this.data.slice(this.start, this.start + m.index);55 this.advance(m.index);56 return t.toString();57 } else {58 throw HTML5.DRAIN;59 }60 },61 append: function(data) {62 this.data += data;63 },64 shift: function(n) {65 if(!this.eof && this.start + n >= this.data.length) throw HTML5.DRAIN;66 if(this.eof && this.start >= this.data.length) return HTML5.EOF;67 var d = this.data.slice(this.start, this.start + n).toString();68 this.advance(Math.min(n, this.data.length - this.start));69 return d;70 },71 peek: function(n) {72 if(!this.eof && this.start + n >= this.data.length) throw HTML5.DRAIN;73 if(this.eof && this.start >= this.data.length) return HTML5.EOF;74 return this.data.slice(this.start, Math.min(this.start + n, this.data.length)).toString();75 },76 length: function() {77 return this.data.length - this.start - 1;78 },79 unget: function(d) {80 if(d === HTML5.EOF) return;81 this.start -= (d.length);82 },83 undo: function() {84 this.start = this.committed;85 },86 commit: function() {87 this.committed = this.start;88 }...
Using AI Code Generation
1const wd = require('wd');2const chai = require('chai');3const chaiAsPromised = require('chai-as-promised');4chai.use(chaiAsPromised);5const should = chai.should();6const assert = chai.assert;7const expect = chai.expect;8const XCUITestDriver = require('appium-xcuitest-driver');9const caps = {
Using AI Code Generation
1const webdriver = require("nativescript-dev-appium");2const assert = require("chai").assert;3describe("sample scenario", () => {4 const driver = webdriver.driver;5 before(async () => {6 await driver.init(webdriver.capabilities);7 });8 it("should find an element", async () => {9 const text = await driver.findElementByClassName("UIATextField").text();10 assert.equal(text, "TextField");11 });12 after(async () => {13 await driver.quit();14 });15});161 passing (5s)
Using AI Code Generation
1import { start } from 'appium-xcuitest-driver';2appium = await start({3 capabilities: {4 }5});6await appium.stop();7import { start } from 'appium-xcuitest-driver';8appium = await start({9 capabilities: {10 }11});12await appium.stop();13import { start } from 'appium-xcuitest-driver';14appium = await start({15 capabilities: {16 }17});18await appium.stop();19import { start } from 'appium-xcuitest-driver';20appium = await start({21 capabilities: {22 }23});24await appium.stop();25import { start } from 'appium-xcuitest-driver';26appium = await start({
Using AI Code Generation
1describe('Test', function() {2 it('should do something', function() {3 this.timeout(60000)4 .elementByAccessibilityId('Search')5 .click()6 .elementByAccessibilityId('Search')7 .type('test')8 .elementByAccessibilityId('Search')9 .type('\ue007')10 .waitForElementByAccessibilityId('test', 10000)11 })12})13describe('Test', function() {14 it('should do something', function() {15 this.timeout(60000)16 .elementByAccessibilityId('Search')17 .click()18 .elementByAccessibilityId('Search')19 .type('test')20 .elementByAccessibilityId('Search')21 .type('\ue007')22 .waitForElementByAccessibilityId('test', 10000)23 })24})25driver.waitForElementByAccessibilityId('test', 10000)26driver.waitForElementByAccessibilityId('test', 10000)27this.timeout(60000)28this.timeout(60000)29driver.waitForElementByAccessibilityId('test', 10000)30driver.waitForElementByAccessibilityId('test', 10000)31driver.waitForElementByAccessibilityId('test', 10000)32driver.waitForElementByAccessibilityId('test', 10000)33driver.waitForElementByAccessibilityId('test', 10000)34driver.waitForElementByAccessibilityId('test', 10000)35this.timeout(60000)36this.timeout(60000)37driver.waitForElementByAccessibilityId('test', 10000)38driver.waitForElementByAccessibilityId('test', 10000)39driver.waitForElementByAccessibilityId('test', 10000)40driver.waitForElementByAccessibilityId('test', 10000)
Using AI Code Generation
1var wd = require('wd');2var XCUITestDriver = require('appium-xcuitest-driver');3driver.init({4}).then(function () {5 console.log('Application Launched');6 driver.quit();7});8var wd = require('wd');9var XCUITestDriver = require('appium-xcuitest-driver');10driver.init({11}).then(function () {12 console.log('Application Launched');13 driver.quit();14});
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!