4
Copyright DHTMLX LTD. http://www.dhtmlx.com
5
You allowed to use this component or parts of it under GPL terms
6
To use it on other terms or get Professional edition of the component please contact us at sales@dhtmlx.com
9
Purpose: item edit extension
14
* @desc: enable editing of item text
15
* @param: mode - true/false
19
dhtmlXTreeObject.prototype.enableItemEditor=function(mode){
20
this._eItEd=convertStringToBoolean(mode);
21
if (!this._eItEdFlag){
23
this._edn_click_IE=true;
24
this._edn_dblclick=true;
25
this._ie_aFunc=this.aFunc;
26
this._ie_dblclickFuncHandler=this.dblclickFuncHandler;
28
this.setOnDblClickHandler(function (a,b) {
29
if (this._edn_dblclick) this._editItem(a,b);
33
this.setOnClickHandler(function (a,b) {
34
this._stopEditItem(a,b);
35
if ((this.ed_hist_clcik==a)&&(this._edn_click_IE))
47
* @desc: set onEdit handler ( multi handler event)
48
* @param: func - function which will be called on edit related events
51
* @depricated: use grid.attachEvent("onEdit",func); instead
52
* @eventdesc: Event occurs on 4 different stages of edit process: before editing started (cancelable), after editing started, before closing (cancelable), after closed
53
* @eventparam: state - 0 before editing started , 1 after editing started, 2 before closing, 3 after closed
54
* @eventparam: id - id of edited items
55
* @eventparam: tree - tree object
56
* @eventparam: value - for stage 0 and 2, value of editor
57
* @eventreturn: for stages 0 and 2; true - confirm opening/closing, false - deny opening/closing; text - edit value
60
dhtmlXTreeObject.prototype.setOnEditHandler=function(func){
61
this.attachEvent("onEdit",func);
67
* @desc: define which events must start editing
68
* @param: click_IE - click on already selected item - true/false [true by default]
69
* @param: dblclick - on double click
73
dhtmlXTreeObject.prototype.setEditStartAction=function(click_IE, dblclick){
74
this._edn_click_IE=convertStringToBoolean(click_IE);
75
this._edn_dblclick=convertStringToBoolean(dblclick);
78
dhtmlXTreeObject.prototype._stopEdit=function(a){
80
this.dADTempOff=this.dADTempOffEd;
81
if (this._editCell.id!=a){
84
editText=this.callEvent("onEdit",[2,this._editCell.id,this,this._editCell.span.childNodes[0].value]);
86
editText=this._editCell.span.childNodes[0].value;
87
else if (editText===false) editText=this._editCell._oldValue;
89
this._editCell.span.innerHTML=editText;
90
this._editCell.label=this._editCell.span.innerHTML;
91
var cSS=this._editCell.i_sel?"selectedTreeRow":"standartTreeRow";
92
this._editCell.span.className=cSS;
93
this._editCell.span.parentNode.className="standartTreeRow";
94
this._editCell.span.onclick=function(){};
95
var id=this._editCell.id; this._editCell=null;
97
if (this.childCalc) this._fixChildCountLabel(this._editCell);
98
this.callEvent("onEdit",[3,id,this]);
101
this.parentObject.lastChild.focus();
102
this.parentObject.lastChild.focus();
108
dhtmlXTreeObject.prototype._stopEditItem=function(id,tree){
113
* @desc: switch currently edited item back to normal view
118
dhtmlXTreeObject.prototype.stopEdit=function(){
120
this._stopEdit(this._editCell.id+"_non");
124
* @desc: open editor for specified item
125
* @param: id - item ID
129
dhtmlXTreeObject.prototype.editItem=function(id){
130
this._editItem(id,this);
133
dhtmlXTreeObject.prototype._editItem=function(id,tree){
136
var temp=this._globalIdStorageFind(id);
139
editText=this.callEvent("onEdit",[0,id,this,temp.span.innerHTML]);
143
else if (editText===false) return;
145
this.dADTempOffEd=this.dADTempOff;
146
this.dADTempOff=false;
150
temp._oldValue=editText;
151
temp.span.innerHTML="<input type='text' class='intreeeditRow' />";
153
temp.span.childNodes[0].value=editText;
155
temp.span.childNodes[0].onselectstart=function(e){
156
(e||event).cancelBubble=true;
159
temp.span.childNodes[0].onmousedown=function(e){
160
(e||event).cancelBubble=true;
164
temp.span.childNodes[0].focus();
165
temp.span.childNodes[0].focus();
166
// temp.span.childNodes[0].select();
167
temp.span.onclick=function (e){ (e||event).cancelBubble=true; return false; };
168
temp.span.className="";
169
temp.span.parentNode.className="";
173
temp.span.childNodes[0].onkeydown=function(e){
174
(e||event).cancelBubble=true;
176
temp.span.childNodes[0].onkeypress=function(e){
177
if (!e) e=window.event;
181
else if (e.keyCode==27){
182
self._editCell.span.childNodes[0].value=self._editCell._oldValue;
186
this.callEvent("onEdit",[1,id,this]);
189
//(c)dhtmlx ltd. www.dhtmlx.com