3
* Copyright(c) 2006-2008, Ext JS, LLC.
6
* http://extjs.com/license
10
* @class Ext.tree.TreeEditor
12
* Provides editor functionality for inline tree node editing. Any valid {@link Ext.form.Field} subclass can be used
13
* as the editor field.
15
* @param {TreePanel} tree
16
* @param {Object} fieldConfig (optional) Either a prebuilt {@link Ext.form.Field} instance or a Field config object
17
* that will be applied to the default field instance (defaults to a {@link Ext.form.TextField}).
18
* @param {Object} config (optional) A TreeEditor config object
20
Ext.tree.TreeEditor = function(tree, fc, config){
22
var field = fc.events ? fc : new Ext.form.TextField(fc);
23
Ext.tree.TreeEditor.superclass.constructor.call(this, field, config);
28
tree.on('render', this.initEditor, this);
30
this.initEditor(tree);
34
Ext.extend(Ext.tree.TreeEditor, Ext.Editor, {
36
* @cfg {String} alignment
37
* The position to align to (see {@link Ext.Element#alignTo} for more details, defaults to "l-l").
43
* @cfg {Boolean} hideEl
44
* True to hide the bound element while the editor is displayed (defaults to false)
49
* CSS class to apply to the editor (defaults to "x-small-editor x-tree-editor")
51
cls: "x-small-editor x-tree-editor",
54
* True to shim the editor if selects/iframes could be displayed beneath it (defaults to false)
60
* @cfg {Number} maxWidth
61
* The maximum width in pixels of the editor field (defaults to 250). Note that if the maxWidth would exceed
62
* the containing tree element's size, it will be automatically limited for you to the container width, taking
63
* scroll and client offsets into account prior to each edit.
67
* @cfg {Number} editDelay The number of milliseconds between clicks to register a double-click that will trigger
68
* editing on the current node (defaults to 350). If two clicks occur on the same node within this time span,
69
* the editor for the node will display, otherwise it will be processed as a regular click.
73
initEditor : function(tree){
74
tree.on('beforeclick', this.beforeNodeClick, this);
75
tree.on('dblclick', this.onNodeDblClick, this);
76
this.on('complete', this.updateNode, this);
77
this.on('beforestartedit', this.fitToTree, this);
78
this.on('startedit', this.bindScroll, this, {delay:10});
79
this.on('specialkey', this.onSpecialKey, this);
83
fitToTree : function(ed, el){
84
var td = this.tree.getTreeEl().dom, nd = el.dom;
85
if(td.scrollLeft > nd.offsetLeft){ // ensure the node left point is visible
86
td.scrollLeft = nd.offsetLeft;
90
(td.clientWidth > 20 ? td.clientWidth : td.offsetWidth) - Math.max(0, nd.offsetLeft-td.scrollLeft) - /*cushion*/5);
95
triggerEdit : function(node, defer){
97
if(node.attributes.editable !== false){
99
* The tree node this editor is bound to. Read-only.
100
* @type Ext.tree.TreeNode
103
this.editNode = node;
104
if(this.tree.autoScroll){
105
node.ui.getEl().scrollIntoView(this.tree.body);
107
this.autoEditTimer = this.startEdit.defer(this.editDelay, this, [node.ui.textNode, node.text]);
113
bindScroll : function(){
114
this.tree.getTreeEl().on('scroll', this.cancelEdit, this);
118
beforeNodeClick : function(node, e){
119
clearTimeout(this.autoEditTimer);
120
if(this.tree.getSelectionModel().isSelected(node)){
122
return this.triggerEdit(node);
126
onNodeDblClick : function(node, e){
127
clearTimeout(this.autoEditTimer);
131
updateNode : function(ed, value){
132
this.tree.getTreeEl().un('scroll', this.cancelEdit, this);
133
this.editNode.setText(value);
138
Ext.tree.TreeEditor.superclass.onHide.call(this);
140
this.editNode.ui.focus.defer(50, this.editNode.ui);
145
onSpecialKey : function(field, e){
150
}else if(k == e.ENTER && !e.hasModifier()){
b'\\ No newline at end of file'