Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed uglify from breaking shit

  • Loading branch information...
commit bda504dcab44b664e9545b6a403287328769d846 1 parent 498df12
TJ Holowaychuk authored July 28, 2011
2  Makefile
@@ -13,7 +13,7 @@ build/texty.js: $(OUT)
13 13
 	cat head $< tail > $@ 
14 14
 
15 15
 build/texty.min.js: build/texty.js
16  
-	uglifyjs $< > $@
  16
+	uglifyjs --no-mangle $< > $@
17 17
 
18 18
 clean:
19 19
 	rm -fr build $(OUT)
2  build/texty.min.js
... ...
@@ -1 +1 @@
1  
--function(){a=function a(a){this.text=a,this.pos=0,this.color("#888"),this.softLeft=/([A-Z][a-z0-9]*|[a-z0-9]+|_+| +)$/,this.softRight=/^([A-Z][a-z0-9]*|[a-z0-9]+|_+| +)/,this.hardLeft=/(\w+| +)$/,this.hardRight=/^(\w+| +)/,this.show()},a.prototype.show=function(){this.visible=!0;return this},a.prototype.hide=function(){this.visible=!1;return this},a.prototype.color=function(a){if(!a)return this;this._color=a;return this},a.prototype.move=function(a){var b=this.text._text.length;this.pos+=a,this.pos<0?this.pos=0:this.pos>b&&(this.pos=b);return this},a.prototype.moveLeft=function(a){return this.move(-(a||1))},a.prototype.moveRight=function(a){return this.move(a||1)},a.prototype.moveUp=function(){var a=this.text._text.slice(0,this.pos).split("\n"),b=a.pop(),c=a.pop()||"",d=c.slice(b.length).length;return this.moveLeft(b.length+d+1)},a.prototype.moveDown=function(){var a=this.text._text.slice(this.pos).split("\n"),b=a.shift(),c=a.shift()||"",d=c.slice(b.length).length;return this.moveRight(b.length+d+1)},a.prototype.moveTo=function(a,b){2==arguments.length?this.moveTo(this.text.indexOf(a,b)):this.pos=a;return this},a.prototype.moveWithPattern=function(a,b){var c=this.text._text,d,e=1;-1==b?c=c.slice(0,this.pos):c=c.slice(this.pos);if(d=a.exec(c))e=d[1].length;this.move(-1==b?-e:e);return e},a.prototype.moveLeftSoft=function(){return this.moveWithPattern(this.softLeft,-1)},a.prototype.moveRightSoft=function(){return this.moveWithPattern(this.softRight,1)},a.prototype.moveLeftHard=function(){return this.moveWithPattern(this.hardLeft,-1)},a.prototype.moveRightHard=function(){return this.moveWithPattern(this.hardRight,1)}}(),-function(){function a(a){var b=[];for(var c=0,d=a.length;c<d;++c)b.push(a[c]);return b}b=function b(){this.callbacks={}},b.prototype.on=function(a,b){(this.callbacks[a]=this.callbacks[a]||[]).push(b);return this},b.prototype.emit=function(b){var c=a(arguments).slice(1),d=this.callbacks[b];if(d)for(var e=0,f=d.length;e<f;++e)d[e].apply(this,c);return this}}(),-function(){selectorStyle=function a(b,c){var d=a.cache=a.cache||{},e=b+":"+c;if(d[e])return d[e];var f=b.split(/ +/),g=f.length,h=root=document.createElement("div"),i,j;for(var k=0;k<g;++k)j=f[k],i=document.createElement("div"),h.appendChild(i),h=i,"#"==j[0]?i.setAttribute("id",j.substr(1)):"."==j[0]&&i.setAttribute("class",j.substr(1));document.body.appendChild(root);var l=getComputedStyle(i)[c];document.body.removeChild(root);return d[e]=l}}(),-function(){a=function a(a){this.caret=new Caret(this),this.hide().listStyle("none").text(a||"").size(20).font("Helvetica").color("#000").selectionBackground("#DFF3FC").lineHeight(this._size)},a.prototype.inheritCSS=function(){var a=selectorStyle;this.size(parseInt(a(".text","font-size"),10)).font(a(".text","font-family")).color(a(".text","color")).selectionBackground(a(".text .selection","background-color")),this.listStyle(a(".text .line","list-style-type")).lineHeight(parseInt(a(".text .line","line-height"),10)),this.caret.color(a(".text .caret","color"))},a.prototype.lineHeight=function(a){this._lineHeight=a;return this},a.prototype.toString=function(){return this.text()},a.prototype.listStyle=function(a){if(0==arguments.length)return this._listStyle;if(!a)return this;this._listStyle=a;return this},a.prototype.text=function(a){if(arguments.length){this._text=a;return this}return this._text},a.prototype.color=function(a){if(!a)return this;this._textColor=a;return this},a.prototype.selectionBackground=function(a){if(!a)return this;this._selectionBackgroundColor=a;return this},a.prototype.remove=function(a){return this.removeAt(a,this.caret.pos)},a.prototype.removeAt=function(a,b){this._text=this._text.substr(0,b-a)+this._text.substr(b);return this.caret.move(-a)},a.prototype.removeRange=function(a,b){this._text=this._text.substr(0,a)+this._text.substr(b);return this.deselect().caret.moveTo(a)},a.prototype.selection=function(){if(!!this.selected){var a=this.selected.from,b=this.selected.to;return{string:this._text.slice(a,b),from:a,to:b}}},a.prototype.removeSelection=function(){if(!this.selected)throw new Error("no selection is made");var a=this.selected.from,b=this.selected.to;return this.removeRange(a,b)},a.prototype.clear=function(){return this.text("")},a.prototype.insert=function(a){return this.insertAt(a,this.caret.pos)},a.prototype.insertAt=function(a,b){this._text=this._text.substr(0,b)+a+this._text.substr(b);return this.caret.move(a.length)},a.prototype.indexOf=function(a,b){var c=this.text(),d=this._width,e=this._lineHeight,f=e||this._size,g=c.split("\n"),h=g.length*f,i=d/c.length,j=g.length,a=a-this.x,b=b-this.y,k=10;if(a<-k||a>d+k)return 0;if(b<-k||b>h+k)return 0;b<f&&(b=f),b=Math.ceil(b/f),b>j&&(b=j);var l=g.slice(0,b-1).join("\n").length;b&&++l;var m=l+a/i|0;return m},a.prototype.select=function(a,b,c,d){var e=this.indexOf(a,b),f=this.indexOf(c,d);return this.selectRange(e,f).caret.moveTo(c,d).text},a.prototype.selectWordAt=function(a,b){var c=this.indexOf(a,b);this.caret.moveTo(c);var d=this.caret.moveLeftHard();this.selectLeft(d),this.caret.moveTo(c);var e=this.caret.moveRightHard();this.selectRight(e),this.caret.moveTo(c);return this},a.prototype.selectLeft=function(a){var b=this.caret.pos,a=a||1,c;(c=this.selection())?this.selectRange(c.from-a,c.to):this.selectRange(b,b+a);return this},a.prototype.selectRight=function(a){var b=this.caret.pos,a=a||1,c;(c=this.selection())?this.selectRange(c.from,c.to+a):this.selectRange(b-a,b);return this},a.prototype.selectAll=function(){return this.selectRange(0,this._text.length)},a.prototype.selectRange=function(a,b){var c=this._text.length,d;a>b&&(d=a,a=b,b=d),this.selected={from:a>0?a:0,to:b<c?b:c};return this},a.prototype.deselect=function(){this.selected=null;return this},a.prototype.moveTo=function(a,b){this.x=a,this.y=b;return this},a.prototype.hide=function(){this.visible=!1;return this},a.prototype.show=function(){this.visible=!0;return this},a.prototype.font=function(a){if(0==arguments.length)return this._families;if(!a)return this;this._families=a;return this},a.prototype.size=function(a){if(0==arguments.length)return this._size;if(!a)return this;this._size=a;return this},a.prototype.drawSelection=function(a,b,c,d,e){var f=this.selection(),g=f.from,h=f.to,i=e.slice(0,g).split("\n"),j=i.length,k=i[j-1],l=e.slice(g,h).split("\n"),m=l.length,n=d/2,o=b,p=c,q,r;a.fillStyle=this._selectionBackgroundColor,c+=(j-1)*d,q=a.measureText(l[0]).width,k=a.measureText(k).width,a.fillRect(b+k,c-n,q,d);for(var s=1,t=m-1;s<t;++s)c+=d,q=a.measureText(l[s]).width,a.fillRect(b,c-n,q,d);m<2||(c+=d,k=l[m-1],q=a.measureText(k).width,a.fillRect(b,c-n,q,d))},a.prototype.drawCaret=function(a,b,c,d,e){if(!!this.caret.visible){var f=e.substr(0,this.caret.pos).split("\n"),g=f.length,h=f[g-1],i=d/2,j=a.measureText(h).width+2,c=c+ --g*d;a.strokeStyle=this.caret._color,a.beginPath(),a.moveTo(b+j,c-i-2),a.lineTo(b+j,c+i+2),a.stroke()}},a.prototype.drawText=function(a,b,c,d,e){var f=e.split("\n"),g=b;a.fillStyle=this._textColor,a.textBaseline="middle",a.font=this._size+"px "+this._families;for(var h=0,i=f.length;h<i;++h)a.fillText(f[h],b,c),b=g,c+=d},a.prototype.drawLineDecoration=function(a,b,c,d,e,f){var g=e.split("\n").length,h=a.measureText("M").width;a.save(),a.font=this._size*.65+"px "+this._families,b-=h;for(var i=0;i<g;++i)a.fillText("function"==typeof f?f(i):f,b,c),c+=d;a.restore()},a.prototype.draw=function(a){if(!this.visible)return this;var b=this._text,c=this._lineHeight,d=c||this._size,e=this.x,f=this.y;this._width=a.measureText(b).width,this.selected&&this.drawSelection(a,e,f,d,b),this.drawCaret(a,e,f,d,b),this.drawText(a,e,f,d,b);var g;switch(this._listStyle){case"decimal":g=function(a){return++a+"."};break;case"square":g="■";break;case"circle":g="○";break;case"disc":g="●"}g&&this.drawLineDecoration(a,e,f,d,b,g);return this}}()
  1
+-function(){Caret=function Caret(text){this.text=text,this.pos=0,this.color("#888"),this.softLeft=/([A-Z][a-z0-9]*|[a-z0-9]+|_+| +)$/,this.softRight=/^([A-Z][a-z0-9]*|[a-z0-9]+|_+| +)/,this.hardLeft=/(\w+| +)$/,this.hardRight=/^(\w+| +)/,this.show()},Caret.prototype.show=function(){this.visible=!0;return this},Caret.prototype.hide=function(){this.visible=!1;return this},Caret.prototype.color=function(color){if(!color)return this;this._color=color;return this},Caret.prototype.move=function(n){var len=this.text._text.length;this.pos+=n,this.pos<0?this.pos=0:this.pos>len&&(this.pos=len);return this},Caret.prototype.moveLeft=function(n){return this.move(-(n||1))},Caret.prototype.moveRight=function(n){return this.move(n||1)},Caret.prototype.moveUp=function(){var lines=this.text._text.slice(0,this.pos).split("\n"),curr=lines.pop(),prev=lines.pop()||"",n=prev.slice(curr.length).length;return this.moveLeft(curr.length+n+1)},Caret.prototype.moveDown=function(){var lines=this.text._text.slice(this.pos).split("\n"),curr=lines.shift(),next=lines.shift()||"",n=next.slice(curr.length).length;return this.moveRight(curr.length+n+1)},Caret.prototype.moveTo=function(x,y){2==arguments.length?this.moveTo(this.text.indexOf(x,y)):this.pos=x;return this},Caret.prototype.moveWithPattern=function(regexp,direction){var text=this.text._text,captures,n=1;-1==direction?text=text.slice(0,this.pos):text=text.slice(this.pos);if(captures=regexp.exec(text))n=captures[1].length;this.move(-1==direction?-n:n);return n},Caret.prototype.moveLeftSoft=function(){return this.moveWithPattern(this.softLeft,-1)},Caret.prototype.moveRightSoft=function(){return this.moveWithPattern(this.softRight,1)},Caret.prototype.moveLeftHard=function(){return this.moveWithPattern(this.hardLeft,-1)},Caret.prototype.moveRightHard=function(){return this.moveWithPattern(this.hardRight,1)}}(),-function(){function toArray(args){var ret=[];for(var i=0,len=args.length;i<len;++i)ret.push(args[i]);return ret}EventEmitter=function EventEmitter(){this.callbacks={}},EventEmitter.prototype.on=function(event,fn){(this.callbacks[event]=this.callbacks[event]||[]).push(fn);return this},EventEmitter.prototype.emit=function(event){var args=toArray(arguments).slice(1),callbacks=this.callbacks[event];if(callbacks)for(var i=0,len=callbacks.length;i<len;++i)callbacks[i].apply(this,args);return this}}(),-function(){selectorStyle=function style(selector,prop){var cache=style.cache=style.cache||{},cid=selector+":"+prop;if(cache[cid])return cache[cid];var parts=selector.split(/ +/),len=parts.length,parent=root=document.createElement("div"),child,part;for(var i=0;i<len;++i)part=parts[i],child=document.createElement("div"),parent.appendChild(child),parent=child,"#"==part[0]?child.setAttribute("id",part.substr(1)):"."==part[0]&&child.setAttribute("class",part.substr(1));document.body.appendChild(root);var ret=getComputedStyle(child)[prop];document.body.removeChild(root);return cache[cid]=ret}}(),-function(){Text=function Text(str){this.caret=new Caret(this),this.hide().listStyle("none").text(str||"").size(20).font("Helvetica").color("#000").selectionBackground("#DFF3FC").lineHeight(this._size)},Text.prototype.inheritCSS=function(){var s=selectorStyle;this.size(parseInt(s(".text","font-size"),10)).font(s(".text","font-family")).color(s(".text","color")).selectionBackground(s(".text .selection","background-color")),this.listStyle(s(".text .line","list-style-type")).lineHeight(parseInt(s(".text .line","line-height"),10)),this.caret.color(s(".text .caret","color"))},Text.prototype.lineHeight=function(n){this._lineHeight=n;return this},Text.prototype.toString=function(){return this.text()},Text.prototype.listStyle=function(style){if(0==arguments.length)return this._listStyle;if(!style)return this;this._listStyle=style;return this},Text.prototype.text=function(str){if(arguments.length){this._text=str;return this}return this._text},Text.prototype.color=function(color){if(!color)return this;this._textColor=color;return this},Text.prototype.selectionBackground=function(color){if(!color)return this;this._selectionBackgroundColor=color;return this},Text.prototype.remove=function(n){return this.removeAt(n,this.caret.pos)},Text.prototype.removeAt=function(n,pos){this._text=this._text.substr(0,pos-n)+this._text.substr(pos);return this.caret.move(-n)},Text.prototype.removeRange=function(from,to){this._text=this._text.substr(0,from)+this._text.substr(to);return this.deselect().caret.moveTo(from)},Text.prototype.selection=function(){if(!!this.selected){var from=this.selected.from,to=this.selected.to;return{string:this._text.slice(from,to),from:from,to:to}}},Text.prototype.removeSelection=function(){if(!this.selected)throw new Error("no selection is made");var from=this.selected.from,to=this.selected.to;return this.removeRange(from,to)},Text.prototype.clear=function(){return this.text("")},Text.prototype.insert=function(str){return this.insertAt(str,this.caret.pos)},Text.prototype.insertAt=function(str,pos){this._text=this._text.substr(0,pos)+str+this._text.substr(pos);return this.caret.move(str.length)},Text.prototype.indexOf=function(x,y){var text=this.text(),width=this._width,lineHeight=this._lineHeight,size=lineHeight||this._size,lines=text.split("\n"),height=lines.length*size,charWidth=width/text.length,len=lines.length,x=x-this.x,y=y-this.y,pad=10;if(x<-pad||x>width+pad)return 0;if(y<-pad||y>height+pad)return 0;y<size&&(y=size),y=Math.ceil(y/size),y>len&&(y=len);var preceding=lines.slice(0,y-1).join("\n").length;y&&++preceding;var i=preceding+x/charWidth|0;return i},Text.prototype.select=function(x,y,x2,y2){var from=this.indexOf(x,y),to=this.indexOf(x2,y2);return this.selectRange(from,to).caret.moveTo(x2,y2).text},Text.prototype.selectWordAt=function(x,y){var i=this.indexOf(x,y);this.caret.moveTo(i);var left=this.caret.moveLeftHard();this.selectLeft(left),this.caret.moveTo(i);var right=this.caret.moveRightHard();this.selectRight(right),this.caret.moveTo(i);return this},Text.prototype.selectLeft=function(n){var pos=this.caret.pos,n=n||1,selection;(selection=this.selection())?this.selectRange(selection.from-n,selection.to):this.selectRange(pos,pos+n);return this},Text.prototype.selectRight=function(n){var pos=this.caret.pos,n=n||1,selection;(selection=this.selection())?this.selectRange(selection.from,selection.to+n):this.selectRange(pos-n,pos);return this},Text.prototype.selectAll=function(){return this.selectRange(0,this._text.length)},Text.prototype.selectRange=function(from,to){var len=this._text.length,tmp;from>to&&(tmp=from,from=to,to=tmp),this.selected={from:from>0?from:0,to:to<len?to:len};return this},Text.prototype.deselect=function(){this.selected=null;return this},Text.prototype.moveTo=function(x,y){this.x=x,this.y=y;return this},Text.prototype.hide=function(){this.visible=!1;return this},Text.prototype.show=function(){this.visible=!0;return this},Text.prototype.font=function(families){if(0==arguments.length)return this._families;if(!families)return this;this._families=families;return this},Text.prototype.size=function(n){if(0==arguments.length)return this._size;if(!n)return this;this._size=n;return this},Text.prototype.drawSelection=function(ctx,x,y,height,text){var selection=this.selection(),from=selection.from,to=selection.to,before=text.slice(0,from).split("\n"),beforeLen=before.length,last=before[beforeLen-1],selected=text.slice(from,to).split("\n"),selectionLen=selected.length,px=height/2,ox=x,oy=y,width,line;ctx.fillStyle=this._selectionBackgroundColor,y+=(beforeLen-1)*height,width=ctx.measureText(selected[0]).width,last=ctx.measureText(last).width,ctx.fillRect(x+last,y-px,width,height);for(var i=1,len=selectionLen-1;i<len;++i)y+=height,width=ctx.measureText(selected[i]).width,ctx.fillRect(x,y-px,width,height);selectionLen<2||(y+=height,last=selected[selectionLen-1],width=ctx.measureText(last).width,ctx.fillRect(x,y-px,width,height))},Text.prototype.drawCaret=function(ctx,x,y,height,text){if(!!this.caret.visible){var lines=text.substr(0,this.caret.pos).split("\n"),len=lines.length,line=lines[len-1],px=height/2,caret=ctx.measureText(line).width+2,y=y+ --len*height;ctx.strokeStyle=this.caret._color,ctx.beginPath(),ctx.moveTo(x+caret,y-px-2),ctx.lineTo(x+caret,y+px+2),ctx.stroke()}},Text.prototype.drawText=function(ctx,x,y,height,text){var lines=text.split("\n"),ox=x;ctx.fillStyle=this._textColor,ctx.textBaseline="middle",ctx.font=this._size+"px "+this._families;for(var i=0,len=lines.length;i<len;++i)ctx.fillText(lines[i],x,y),x=ox,y+=height},Text.prototype.drawLineDecoration=function(ctx,x,y,height,text,c){var len=text.split("\n").length,em=ctx.measureText("M").width;ctx.save(),ctx.font=this._size*.65+"px "+this._families,x-=em;for(var i=0;i<len;++i)ctx.fillText("function"==typeof c?c(i):c,x,y),y+=height;ctx.restore()},Text.prototype.draw=function(ctx){if(!this.visible)return this;var text=this._text,lineHeight=this._lineHeight,height=lineHeight||this._size,x=this.x,y=this.y;this._width=ctx.measureText(text).width,this.selected&&this.drawSelection(ctx,x,y,height,text),this.drawCaret(ctx,x,y,height,text),this.drawText(ctx,x,y,height,text);var decoration;switch(this._listStyle){case"decimal":decoration=function(i){return++i+"."};break;case"square":decoration="■";break;case"circle":decoration="○";break;case"disc":decoration="●"}decoration&&this.drawLineDecoration(ctx,x,y,height,text,decoration);return this}}()

0 notes on commit bda504d

Please sign in to comment.
Something went wrong with that request. Please try again.