editCursor=Class.create();
editCursor.prototype={initialize:function(_1,_2,_3,_4,_5){
var _6=true;
if(_5!=undefined){
_6=_5;
}
this.target=_1;
this.onSubmit=_2;
this.cursor=null;
this.initializeCursor();
if(_3){
this.defaultVal=_3;
}
if(_4){
this.vertical=true;
}
this.setCursorContents();
if(_6){
this.setCursorLocation();
}else{
this.cursor.style.top=0;
}
},keyCheck:function(e){
if(e==null){
e=event;
}
var _8=(window.event)?event.keyCode:e.keyCode;
switch(_8){
case 13:
this.submitChange();
break;
case 27:
this.cancelChange();
break;
default:
return true;
}
return false;
},setDefaultVal:function(_9){
this.defaultVal=_9;
this.cursor.value=this.defaultVal;
},submitChange:function(){
this.onSubmit(this.cursor.value);
this.reset();
},cancelChange:function(){
this.reset();
},initializeCursor:function(){
if(this.cursor==null){
this.cursor=$("editCursor");
if(!this.cursor){
this.cursor=Element.extend(document.createElement("textarea"));
this.cursor.id="editCursor";
document.body.appendChild(this.cursor);
this.cursor.appendChild(document.createTextNode("new name"));
this.cursor.enable();
this.cursor.hide();
this.cursor.addClassName("editCursor");
this.cursor.style.zIndex=100;
this.cursor.style.height=this.target.style.height;
this.cursor.style.width=this.target.style.width;
this.cursor.style.left=this.target.style.left;
this.cursor.style.top=this.target.style.top;
this.cursor.style.overflow="hidden";
this.cursor.observe("keydown",this.keyCheck.bindAsEventListener(this));
}
}
},setCursorLocation:function(){
var _a=this.target;
var _b=_a.cumulativeOffset();
if(is.ie){
this.cursor.style.left=(_b[0]-1)+"px";
this.cursor.style.top=(_b[1]-1)+"px";
if(!this.vertical){
this.cursor.style.width=(_a.offsetWidth-3)+"px";
this.cursor.style.height=(_a.offsetHeight-3)+"px";
}else{
this.cursor.style.height=(_a.offsetWidth)+"px";
this.cursor.style.width=(_a.offsetHeight)+"px";
this.target.hide();
}
}else{
this.cursor.style.left=(_b[0]-1)+"px";
this.cursor.style.top=(_b[1]-1)+"px";
if(!this.vertical){
this.cursor.style.width=(_a.offsetWidth-1)+"px";
this.cursor.style.height=(_a.offsetHeight-1)+"px";
}else{
this.cursor.style.height=(_a.offsetWidth+10)+"px";
this.cursor.style.width=(_a.offsetHeight+10)+"px";
this.target.hide();
}
}
},setCursorContents:function(){
if(this.defaulVal){
this.cursor.value=this.defaultVal;
}else{
}
var _c=$w(this.target.className);
for(var i=0;i<_c.length;i++){
this.cursor.addClassName(_c[i]);
}
this.cursor.show();
this.cursor.activate();
},reset:function(){
this.cursor.stopObserving("blur",this.submitChangeListener);
var _e=$w(this.target.className);
for(var i=0;i<_e.length;i++){
this.cursor.removeClassName(_e[i]);
}
this.cursor.hide();
if(this.vertical){
this.target.show();
}
},isActive:function(){
if(this.cursor.visible()){
return true;
}
return false;
}};
