Created
May 5, 2012 10:36
-
-
Save Satyam/2601422 to your computer and use it in GitHub Desktop.
TreeView Editor patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var TV = YAHOO.widget.TreeView, | |
TVProt = TV.prototype, | |
Event = YAHOO.util.Event, | |
Dom = YAHOO.util.Dom; | |
TVProt.draw = TVProt.render = function () { | |
var html = this.root.getHtml(), | |
el = this.getEl(), | |
ed = TV.editorData; | |
// If there is an editor, hide it and preserve it | |
if (ed && ed.editorPanel) { | |
ed.active = false; | |
ed.node = null; | |
ed = ed.editorPanel; | |
document.createElement('div').appendChild(ed); | |
Dom.setStyle(ed, 'display', 'none'); | |
} else { | |
ed = null; | |
} | |
// Set the contents of the tree | |
el.innerHTML = html; | |
// restore the preserved editor | |
if (ed) { | |
el.appendChild(ed); | |
} | |
if (!this._hasEvents) { | |
Event.on(el, 'click', this._onClickEvent, this, true); | |
Event.on(el, 'dblclick', this._onDblClickEvent, this, true); | |
Event.on(el, 'mouseover', this._onMouseOverEvent, this, true); | |
Event.on(el, 'mouseout', this._onMouseOutEvent, this, true); | |
Event.on(el, 'keydown', this._onKeyDownEvent, this, true); | |
} | |
this._hasEvents = true; | |
}; | |
TVProt._deleteNode = function (node) { | |
var el = node.getEl(), | |
ed = TV.editorData; | |
// If there is an editor and is attached to this node, close it | |
if (ed && ed.node === node) { | |
this._closeEditor(false); | |
ed.node = false; | |
} | |
// Remove all the child nodes first | |
this.removeChildren(node); | |
// Remove the node from the tree | |
this.popNode(node); | |
// The node won't be used, simply wipe it out | |
if (el) { | |
el.innerHTML = ''; | |
} | |
}; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment