1var def_box="2.0"; // box.js version 2 3function Dimension(width,height) 4{ 5 this.width = width; 6 this.height = height; 7} 8 9Dimension.prototype.toString = function() 10{ 11 return this.width+"x"+this.height; 12}; 13 14 15function Boundry(top,left,width,height) 16{ 17 this.dimension = new Dimension(width-(left<0?left:0),height-(top<0?top:0)); 18 this.top = (top<0?0:top); 19 this.left = (left<0?0:left); 20 this.right = this.left+this.dimension.width; 21 this.bottom = this.top+this.dimension.height; 22} 23Boundry.prototype.toString = function() 24{ 25 return this.top+","+this.right+","+this.bottom+","+this.left+" - "+this.dimension.toString(); 26}; 27Boundry.prototype.pointInBounds = function( dimension ) 28{ 29 30 return (this.left <= dimension.width && dimension.width <= this.right) && 31 (this.top <= dimension.height && dimension.height <= this.bottom ); 32}; 33Boundry.prototype.center = function( offsetX, offsetY ) 34{ 35 offsetX = isNaN(parseInt(offsetX,10))?50:offsetX; 36 offsetY = isNaN(parseInt(offsetY,10))?50:offsetY; 37 return new Dimension( (this.left + Math.round(this.dimension.width*(offsetX/100)) ), (this.top + Math.round(this.dimension.height*(offsetY/100)) ) ); 38}; 39Boundry.prototype.topLeft = function() 40{ 41 return new Dimension( this.left, this.top ); 42}; 43 44Boundry.prototype.moveTo = function( dimension, offsetX, offsetY ) 45{ 46 offsetX = isNaN(parseInt(offsetX,10))?50:offsetX; 47 offsetY = isNaN(parseInt(offsetY,10))?50:offsetY; 48 this.left = dimension.width - (this.dimension.width*(offsetX/100)); 49 this.right = this.left + this.dimension.width; 50 this.top = dimension.height - (this.dimension.height*(offsetY/100)); 51 this.right = this.top + this.dimension.height; 52 return this; 53}; 54 55Boundry.prototype.grow = function( pixelX, pixelY ) 56{ 57 this.left = Math.max(0, this.left-(pixelX/2)); 58 this.dimension.width = this.dimension.width+pixelX; 59 this.top = Math.max(0, this.top-(pixelY/2)); 60 this.dimension.height = this.dimension.height+pixelY; 61 62 this.right = this.left+this.dimension.width; 63 this.bottom = this.top+this.dimension.height; 64 return this; 65}; 66 67Boundry.prototype.growToFit = function( pixelStep, fitDim ) 68{ 69 var percentGrowth = 0; 70 var center = this.center(); 71 var newWidth = 0; 72 var newHeight = 0; 73 74 if( fitDim.width > fitDim.height ) 75 { 76 percentGrowth = (pixelStep / (fitDim.width-this.dimension.width)); 77 newWidth = Math.round( Math.min(fitDim.width, this.dimension.width + pixelStep) ); 78 newHeight = Math.round( Math.min(fitDim.height, this.dimension.height + ((fitDim.height-this.dimension.height)*percentGrowth)) ); 79 } 80 else 81 { 82 percentGrowth = (pixelStep / (fitDim.height-this.dimension.height)); 83 newHeight = Math.round( Math.min(fitDim.height, this.dimension.height + pixelStep) ); 84 newWidth = Math.round( Math.min(fitDim.width, this.dimension.width + ((fitDim.width-this.dimension.width)*percentGrowth)) ); 85 } 86 87 this.left = Math.max(0, center.width - Math.round(newWidth/2) ); 88 this.dimension.width = newWidth; 89 this.top = Math.max(0, center.height - Math.round(newHeight/2) ); 90 this.dimension.height = newHeight; 91 92 this.right = this.left+this.dimension.width; 93 this.bottom = this.top+this.dimension.height; 94 return this; 95}; 96 97Boundry.prototype.shrink = function( pixelX, pixelY ) 98{ 99 this.left = this.left+(pixelX/2); 100 this.dimension.width = Math.max(0, this.dimension.width-pixelX); 101 this.top = this.top+(pixelY/2); 102 this.dimension.height = Math.max(0, this.dimension.height-pixelY); 103 104 this.right = this.left+this.dimension.width; 105 this.bottom = this.top+this.dimension.height; 106 return this; 107}; 108 109Boundry.fromElem = function( sel ) 110{ 111 var elem = $(sel), elemOffset = elem.offset(); 112 return new Boundry( elemOffset.top, 113 elemOffset.left, 114 elem.outerWidth(), 115 elem.outerHeight() 116 ); 117}; 118 119Boundry.prototype.setLayer = function( sel ) 120{ 121 $(sel).width(this.dimension.width).height(this.dimension.height); 122 $(sel).css({"left":this.left, "top":this.top}); 123 return this; 124}; 125 126Boundry.fromElemClip = function( sel ) 127{ 128 var clip = $(sel).clip(); 129 return new Boundry( clip.top, clip.left, (clip.right-clip.left), (clip.bottom-clip.top) ); 130}; 131 132Boundry.prototype.setElemClip = function( sel ) 133{ 134 $(sel).clip({top:this.top, left:this.left, bottom:this.bottom, right:this.right} ); 135 return this; 136}; 137 138Boundry.prototype.setWidth = function( width ) 139{ 140 var diff = width-this.dimension.width; 141 this.dimension.width = width; 142 this.left -= (diff/2); 143 if(this.left < 0){ this.left = 0; } 144 this.right = this.left + width; 145 return this; 146}; 147 148Boundry.prototype.setHeight = function( height ) 149{ 150 var diff = height-this.dimension.height; 151 this.dimension.height = height; 152 this.top -= (diff/2); 153 if(this.top < 0){ this.top = 0; } 154 this.bottom = this.top + height; 155 return this; 156}; 157 158
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.