You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

640 lines
25 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-tree-TreeNode-method-constructor'><span id='Ext-tree-TreeNode-cfg-editable'><span id='Ext-tree-TreeNode-cfg-allowChildren'><span id='Ext-tree-TreeNode-cfg-isTarget'><span id='Ext-tree-TreeNode-cfg-draggable'><span id='Ext-tree-TreeNode-cfg-checked'><span id='Ext-tree-TreeNode-cfg-uiProvider'><span id='Ext-tree-TreeNode-cfg-singleClickExpand'><span id='Ext-tree-TreeNode-cfg-qtipCfg'><span id='Ext-tree-TreeNode-cfg-expandable'><span id='Ext-tree-TreeNode-cfg-qtip'><span id='Ext-tree-TreeNode-cfg-hidden'><span id='Ext-tree-TreeNode-cfg-hrefTarget'><span id='Ext-tree-TreeNode-cfg-href'><span id='Ext-tree-TreeNode-cfg-iconCls'><span id='Ext-tree-TreeNode-cfg-cls'><span id='Ext-tree-TreeNode-cfg-icon'><span id='Ext-tree-TreeNode-cfg-disabled'><span id='Ext-tree-TreeNode-cfg-allowDrop'><span id='Ext-tree-TreeNode-cfg-allowDrag'><span id='Ext-tree-TreeNode-cfg-expanded'><span id='Ext-tree-TreeNode-cfg-text'><span id='Ext-tree-TreeNode'>/**
  19. </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> * @class Ext.tree.TreeNode
  20. * @extends Ext.data.Node
  21. * @cfg {String} text The text for this node
  22. * @cfg {Boolean} expanded true to start the node expanded
  23. * @cfg {Boolean} allowDrag False to make this node undraggable if {@link #draggable} = true (defaults to true)
  24. * @cfg {Boolean} allowDrop False if this node cannot have child nodes dropped on it (defaults to true)
  25. * @cfg {Boolean} disabled true to start the node disabled
  26. * @cfg {String} icon The path to an icon for the node. The preferred way to do this
  27. * is to use the cls or iconCls attributes and add the icon via a CSS background image.
  28. * @cfg {String} cls A css class to be added to the node
  29. * @cfg {String} iconCls A css class to be added to the nodes icon element for applying css background images
  30. * @cfg {String} href URL of the link used for the node (defaults to #)
  31. * @cfg {String} hrefTarget target frame for the link
  32. * @cfg {Boolean} hidden True to render hidden. (Defaults to false).
  33. * @cfg {String} qtip An Ext QuickTip for the node
  34. * @cfg {Boolean} expandable If set to true, the node will always show a plus/minus icon, even when empty
  35. * @cfg {String} qtipCfg An Ext QuickTip config for the node (used instead of qtip)
  36. * @cfg {Boolean} singleClickExpand True for single click expand on this node
  37. * @cfg {Function} uiProvider A UI &lt;b&gt;class&lt;/b&gt; to use for this node (defaults to Ext.tree.TreeNodeUI)
  38. * @cfg {Boolean} checked True to render a checked checkbox for this node, false to render an unchecked checkbox
  39. * (defaults to undefined with no checkbox rendered)
  40. * @cfg {Boolean} draggable True to make this node draggable (defaults to false)
  41. * @cfg {Boolean} isTarget False to not allow this node to act as a drop target (defaults to true)
  42. * @cfg {Boolean} allowChildren False to not allow this node to have child nodes (defaults to true)
  43. * @cfg {Boolean} editable False to not allow this node to be edited by an {@link Ext.tree.TreeEditor} (defaults to true)
  44. * @constructor
  45. * @param {Object/String} attributes The attributes/config for the node or just a string with the text for the node
  46. */
  47. Ext.tree.TreeNode = Ext.extend(Ext.data.Node, {
  48. constructor : function(attributes){
  49. attributes = attributes || {};
  50. if(Ext.isString(attributes)){
  51. attributes = {text: attributes};
  52. }
  53. this.childrenRendered = false;
  54. this.rendered = false;
  55. Ext.tree.TreeNode.superclass.constructor.call(this, attributes);
  56. this.expanded = attributes.expanded === true;
  57. this.isTarget = attributes.isTarget !== false;
  58. this.draggable = attributes.draggable !== false &amp;&amp; attributes.allowDrag !== false;
  59. this.allowChildren = attributes.allowChildren !== false &amp;&amp; attributes.allowDrop !== false;
  60. <span id='Ext-tree-TreeNode-property-text'> /**
  61. </span> * Read-only. The text for this node. To change it use &lt;code&gt;{@link #setText}&lt;/code&gt;.
  62. * @type String
  63. */
  64. this.text = attributes.text;
  65. <span id='Ext-tree-TreeNode-property-disabled'> /**
  66. </span> * True if this node is disabled.
  67. * @type Boolean
  68. */
  69. this.disabled = attributes.disabled === true;
  70. <span id='Ext-tree-TreeNode-property-hidden'> /**
  71. </span> * True if this node is hidden.
  72. * @type Boolean
  73. */
  74. this.hidden = attributes.hidden === true;
  75. this.addEvents(
  76. <span id='Ext-tree-TreeNode-event-textchange'> /**
  77. </span> * @event textchange
  78. * Fires when the text for this node is changed
  79. * @param {Node} this This node
  80. * @param {String} text The new text
  81. * @param {String} oldText The old text
  82. */
  83. 'textchange',
  84. <span id='Ext-tree-TreeNode-event-beforeexpand'> /**
  85. </span> * @event beforeexpand
  86. * Fires before this node is expanded, return false to cancel.
  87. * @param {Node} this This node
  88. * @param {Boolean} deep
  89. * @param {Boolean} anim
  90. */
  91. 'beforeexpand',
  92. <span id='Ext-tree-TreeNode-event-beforecollapse'> /**
  93. </span> * @event beforecollapse
  94. * Fires before this node is collapsed, return false to cancel.
  95. * @param {Node} this This node
  96. * @param {Boolean} deep
  97. * @param {Boolean} anim
  98. */
  99. 'beforecollapse',
  100. <span id='Ext-tree-TreeNode-event-expand'> /**
  101. </span> * @event expand
  102. * Fires when this node is expanded
  103. * @param {Node} this This node
  104. */
  105. 'expand',
  106. <span id='Ext-tree-TreeNode-event-disabledchange'> /**
  107. </span> * @event disabledchange
  108. * Fires when the disabled status of this node changes
  109. * @param {Node} this This node
  110. * @param {Boolean} disabled
  111. */
  112. 'disabledchange',
  113. <span id='Ext-tree-TreeNode-event-collapse'> /**
  114. </span> * @event collapse
  115. * Fires when this node is collapsed
  116. * @param {Node} this This node
  117. */
  118. 'collapse',
  119. <span id='Ext-tree-TreeNode-event-beforeclick'> /**
  120. </span> * @event beforeclick
  121. * Fires before click processing. Return false to cancel the default action.
  122. * @param {Node} this This node
  123. * @param {Ext.EventObject} e The event object
  124. */
  125. 'beforeclick',
  126. <span id='Ext-tree-TreeNode-event-click'> /**
  127. </span> * @event click
  128. * Fires when this node is clicked
  129. * @param {Node} this This node
  130. * @param {Ext.EventObject} e The event object
  131. */
  132. 'click',
  133. <span id='Ext-tree-TreeNode-event-checkchange'> /**
  134. </span> * @event checkchange
  135. * Fires when a node with a checkbox's checked property changes
  136. * @param {Node} this This node
  137. * @param {Boolean} checked
  138. */
  139. 'checkchange',
  140. <span id='Ext-tree-TreeNode-event-beforedblclick'> /**
  141. </span> * @event beforedblclick
  142. * Fires before double click processing. Return false to cancel the default action.
  143. * @param {Node} this This node
  144. * @param {Ext.EventObject} e The event object
  145. */
  146. 'beforedblclick',
  147. <span id='Ext-tree-TreeNode-event-dblclick'> /**
  148. </span> * @event dblclick
  149. * Fires when this node is double clicked
  150. * @param {Node} this This node
  151. * @param {Ext.EventObject} e The event object
  152. */
  153. 'dblclick',
  154. <span id='Ext-tree-TreeNode-event-contextmenu'> /**
  155. </span> * @event contextmenu
  156. * Fires when this node is right clicked
  157. * @param {Node} this This node
  158. * @param {Ext.EventObject} e The event object
  159. */
  160. 'contextmenu',
  161. <span id='Ext-tree-TreeNode-event-beforechildrenrendered'> /**
  162. </span> * @event beforechildrenrendered
  163. * Fires right before the child nodes for this node are rendered
  164. * @param {Node} this This node
  165. */
  166. 'beforechildrenrendered'
  167. );
  168. var uiClass = this.attributes.uiProvider || this.defaultUI || Ext.tree.TreeNodeUI;
  169. <span id='Ext-tree-TreeNode-property-ui'> /**
  170. </span> * Read-only. The UI for this node
  171. * @type TreeNodeUI
  172. */
  173. this.ui = new uiClass(this);
  174. },
  175. <span id='Ext-tree-TreeNode-property-preventHScroll'> preventHScroll : true,
  176. </span><span id='Ext-tree-TreeNode-method-isExpanded'> /**
  177. </span> * Returns true if this node is expanded
  178. * @return {Boolean}
  179. */
  180. isExpanded : function(){
  181. return this.expanded;
  182. },
  183. <span id='Ext-tree-TreeNode-method-getUI'>/**
  184. </span> * Returns the UI object for this node.
  185. * @return {TreeNodeUI} The object which is providing the user interface for this tree
  186. * node. Unless otherwise specified in the {@link #uiProvider}, this will be an instance
  187. * of {@link Ext.tree.TreeNodeUI}
  188. */
  189. getUI : function(){
  190. return this.ui;
  191. },
  192. <span id='Ext-tree-TreeNode-method-getLoader'> getLoader : function(){
  193. </span> var owner;
  194. return this.loader || ((owner = this.getOwnerTree()) &amp;&amp; owner.loader ? owner.loader : (this.loader = new Ext.tree.TreeLoader()));
  195. },
  196. <span id='Ext-tree-TreeNode-method-setFirstChild'> // private override
  197. </span> setFirstChild : function(node){
  198. var of = this.firstChild;
  199. Ext.tree.TreeNode.superclass.setFirstChild.call(this, node);
  200. if(this.childrenRendered &amp;&amp; of &amp;&amp; node != of){
  201. of.renderIndent(true, true);
  202. }
  203. if(this.rendered){
  204. this.renderIndent(true, true);
  205. }
  206. },
  207. <span id='Ext-tree-TreeNode-method-setLastChild'> // private override
  208. </span> setLastChild : function(node){
  209. var ol = this.lastChild;
  210. Ext.tree.TreeNode.superclass.setLastChild.call(this, node);
  211. if(this.childrenRendered &amp;&amp; ol &amp;&amp; node != ol){
  212. ol.renderIndent(true, true);
  213. }
  214. if(this.rendered){
  215. this.renderIndent(true, true);
  216. }
  217. },
  218. <span id='Ext-tree-TreeNode-method-appendChild'> // these methods are overridden to provide lazy rendering support
  219. </span> // private override
  220. appendChild : function(n){
  221. if(!n.render &amp;&amp; !Ext.isArray(n)){
  222. n = this.getLoader().createNode(n);
  223. }
  224. var node = Ext.tree.TreeNode.superclass.appendChild.call(this, n);
  225. if(node &amp;&amp; this.childrenRendered){
  226. node.render();
  227. }
  228. this.ui.updateExpandIcon();
  229. return node;
  230. },
  231. <span id='Ext-tree-TreeNode-method-removeChild'> // private override
  232. </span> removeChild : function(node, destroy){
  233. this.ownerTree.getSelectionModel().unselect(node);
  234. Ext.tree.TreeNode.superclass.removeChild.apply(this, arguments);
  235. // only update the ui if we're not destroying
  236. if(!destroy){
  237. var rendered = node.ui.rendered;
  238. // if it's been rendered remove dom node
  239. if(rendered){
  240. node.ui.remove();
  241. }
  242. if(rendered &amp;&amp; this.childNodes.length &lt; 1){
  243. this.collapse(false, false);
  244. }else{
  245. this.ui.updateExpandIcon();
  246. }
  247. if(!this.firstChild &amp;&amp; !this.isHiddenRoot()){
  248. this.childrenRendered = false;
  249. }
  250. }
  251. return node;
  252. },
  253. <span id='Ext-tree-TreeNode-method-insertBefore'> // private override
  254. </span> insertBefore : function(node, refNode){
  255. if(!node.render){
  256. node = this.getLoader().createNode(node);
  257. }
  258. var newNode = Ext.tree.TreeNode.superclass.insertBefore.call(this, node, refNode);
  259. if(newNode &amp;&amp; refNode &amp;&amp; this.childrenRendered){
  260. node.render();
  261. }
  262. this.ui.updateExpandIcon();
  263. return newNode;
  264. },
  265. <span id='Ext-tree-TreeNode-method-setText'> /**
  266. </span> * Sets the text for this node
  267. * @param {String} text
  268. */
  269. setText : function(text){
  270. var oldText = this.text;
  271. this.text = this.attributes.text = text;
  272. if(this.rendered){ // event without subscribing
  273. this.ui.onTextChange(this, text, oldText);
  274. }
  275. this.fireEvent('textchange', this, text, oldText);
  276. },
  277. <span id='Ext-tree-TreeNode-method-setIconCls'> /**
  278. </span> * Sets the icon class for this node.
  279. * @param {String} cls
  280. */
  281. setIconCls : function(cls){
  282. var old = this.attributes.iconCls;
  283. this.attributes.iconCls = cls;
  284. if(this.rendered){
  285. this.ui.onIconClsChange(this, cls, old);
  286. }
  287. },
  288. <span id='Ext-tree-TreeNode-method-setTooltip'> /**
  289. </span> * Sets the tooltip for this node.
  290. * @param {String} tip The text for the tip
  291. * @param {String} title (Optional) The title for the tip
  292. */
  293. setTooltip : function(tip, title){
  294. this.attributes.qtip = tip;
  295. this.attributes.qtipTitle = title;
  296. if(this.rendered){
  297. this.ui.onTipChange(this, tip, title);
  298. }
  299. },
  300. <span id='Ext-tree-TreeNode-method-setIcon'> /**
  301. </span> * Sets the icon for this node.
  302. * @param {String} icon
  303. */
  304. setIcon : function(icon){
  305. this.attributes.icon = icon;
  306. if(this.rendered){
  307. this.ui.onIconChange(this, icon);
  308. }
  309. },
  310. <span id='Ext-tree-TreeNode-method-setHref'> /**
  311. </span> * Sets the href for the node.
  312. * @param {String} href The href to set
  313. * @param {String} (Optional) target The target of the href
  314. */
  315. setHref : function(href, target){
  316. this.attributes.href = href;
  317. this.attributes.hrefTarget = target;
  318. if(this.rendered){
  319. this.ui.onHrefChange(this, href, target);
  320. }
  321. },
  322. <span id='Ext-tree-TreeNode-method-setCls'> /**
  323. </span> * Sets the class on this node.
  324. * @param {String} cls
  325. */
  326. setCls : function(cls){
  327. var old = this.attributes.cls;
  328. this.attributes.cls = cls;
  329. if(this.rendered){
  330. this.ui.onClsChange(this, cls, old);
  331. }
  332. },
  333. <span id='Ext-tree-TreeNode-method-select'> /**
  334. </span> * Triggers selection of this node
  335. */
  336. select : function(){
  337. var t = this.getOwnerTree();
  338. if(t){
  339. t.getSelectionModel().select(this);
  340. }
  341. },
  342. <span id='Ext-tree-TreeNode-method-unselect'> /**
  343. </span> * Triggers deselection of this node
  344. * @param {Boolean} silent (optional) True to stop selection change events from firing.
  345. */
  346. unselect : function(silent){
  347. var t = this.getOwnerTree();
  348. if(t){
  349. t.getSelectionModel().unselect(this, silent);
  350. }
  351. },
  352. <span id='Ext-tree-TreeNode-method-isSelected'> /**
  353. </span> * Returns true if this node is selected
  354. * @return {Boolean}
  355. */
  356. isSelected : function(){
  357. var t = this.getOwnerTree();
  358. return t ? t.getSelectionModel().isSelected(this) : false;
  359. },
  360. <span id='Ext-tree-TreeNode-method-expand'> /**
  361. </span> * Expand this node.
  362. * @param {Boolean} deep (optional) True to expand all children as well
  363. * @param {Boolean} anim (optional) false to cancel the default animation
  364. * @param {Function} callback (optional) A callback to be called when
  365. * expanding this node completes (does not wait for deep expand to complete).
  366. * Called with 1 parameter, this node.
  367. * @param {Object} scope (optional) The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the callback is executed. Defaults to this TreeNode.
  368. */
  369. expand : function(deep, anim, callback, scope){
  370. if(!this.expanded){
  371. if(this.fireEvent('beforeexpand', this, deep, anim) === false){
  372. return;
  373. }
  374. if(!this.childrenRendered){
  375. this.renderChildren();
  376. }
  377. this.expanded = true;
  378. if(!this.isHiddenRoot() &amp;&amp; (this.getOwnerTree().animate &amp;&amp; anim !== false) || anim){
  379. this.ui.animExpand(function(){
  380. this.fireEvent('expand', this);
  381. this.runCallback(callback, scope || this, [this]);
  382. if(deep === true){
  383. this.expandChildNodes(true, true);
  384. }
  385. }.createDelegate(this));
  386. return;
  387. }else{
  388. this.ui.expand();
  389. this.fireEvent('expand', this);
  390. this.runCallback(callback, scope || this, [this]);
  391. }
  392. }else{
  393. this.runCallback(callback, scope || this, [this]);
  394. }
  395. if(deep === true){
  396. this.expandChildNodes(true);
  397. }
  398. },
  399. <span id='Ext-tree-TreeNode-method-runCallback'> runCallback : function(cb, scope, args){
  400. </span> if(Ext.isFunction(cb)){
  401. cb.apply(scope, args);
  402. }
  403. },
  404. <span id='Ext-tree-TreeNode-method-isHiddenRoot'> isHiddenRoot : function(){
  405. </span> return this.isRoot &amp;&amp; !this.getOwnerTree().rootVisible;
  406. },
  407. <span id='Ext-tree-TreeNode-method-collapse'> /**
  408. </span> * Collapse this node.
  409. * @param {Boolean} deep (optional) True to collapse all children as well
  410. * @param {Boolean} anim (optional) false to cancel the default animation
  411. * @param {Function} callback (optional) A callback to be called when
  412. * expanding this node completes (does not wait for deep expand to complete).
  413. * Called with 1 parameter, this node.
  414. * @param {Object} scope (optional) The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the callback is executed. Defaults to this TreeNode.
  415. */
  416. collapse : function(deep, anim, callback, scope){
  417. if(this.expanded &amp;&amp; !this.isHiddenRoot()){
  418. if(this.fireEvent('beforecollapse', this, deep, anim) === false){
  419. return;
  420. }
  421. this.expanded = false;
  422. if((this.getOwnerTree().animate &amp;&amp; anim !== false) || anim){
  423. this.ui.animCollapse(function(){
  424. this.fireEvent('collapse', this);
  425. this.runCallback(callback, scope || this, [this]);
  426. if(deep === true){
  427. this.collapseChildNodes(true);
  428. }
  429. }.createDelegate(this));
  430. return;
  431. }else{
  432. this.ui.collapse();
  433. this.fireEvent('collapse', this);
  434. this.runCallback(callback, scope || this, [this]);
  435. }
  436. }else if(!this.expanded){
  437. this.runCallback(callback, scope || this, [this]);
  438. }
  439. if(deep === true){
  440. var cs = this.childNodes;
  441. for(var i = 0, len = cs.length; i &lt; len; i++) {
  442. cs[i].collapse(true, false);
  443. }
  444. }
  445. },
  446. <span id='Ext-tree-TreeNode-method-delayedExpand'> // private
  447. </span> delayedExpand : function(delay){
  448. if(!this.expandProcId){
  449. this.expandProcId = this.expand.defer(delay, this);
  450. }
  451. },
  452. <span id='Ext-tree-TreeNode-method-cancelExpand'> // private
  453. </span> cancelExpand : function(){
  454. if(this.expandProcId){
  455. clearTimeout(this.expandProcId);
  456. }
  457. this.expandProcId = false;
  458. },
  459. <span id='Ext-tree-TreeNode-method-toggle'> /**
  460. </span> * Toggles expanded/collapsed state of the node
  461. */
  462. toggle : function(){
  463. if(this.expanded){
  464. this.collapse();
  465. }else{
  466. this.expand();
  467. }
  468. },
  469. <span id='Ext-tree-TreeNode-method-ensureVisible'> /**
  470. </span> * Ensures all parent nodes are expanded, and if necessary, scrolls
  471. * the node into view.
  472. * @param {Function} callback (optional) A function to call when the node has been made visible.
  473. * @param {Object} scope (optional) The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the callback is executed. Defaults to this TreeNode.
  474. */
  475. ensureVisible : function(callback, scope){
  476. var tree = this.getOwnerTree();
  477. tree.expandPath(this.parentNode ? this.parentNode.getPath() : this.getPath(), false, function(){
  478. var node = tree.getNodeById(this.id); // Somehow if we don't do this, we lose changes that happened to node in the meantime
  479. tree.getTreeEl().scrollChildIntoView(node.ui.anchor);
  480. this.runCallback(callback, scope || this, [this]);
  481. }.createDelegate(this));
  482. },
  483. <span id='Ext-tree-TreeNode-method-expandChildNodes'> /**
  484. </span> * Expand all child nodes
  485. * @param {Boolean} deep (optional) true if the child nodes should also expand their child nodes
  486. */
  487. expandChildNodes : function(deep, anim) {
  488. var cs = this.childNodes,
  489. i,
  490. len = cs.length;
  491. for (i = 0; i &lt; len; i++) {
  492. cs[i].expand(deep, anim);
  493. }
  494. },
  495. <span id='Ext-tree-TreeNode-method-collapseChildNodes'> /**
  496. </span> * Collapse all child nodes
  497. * @param {Boolean} deep (optional) true if the child nodes should also collapse their child nodes
  498. */
  499. collapseChildNodes : function(deep){
  500. var cs = this.childNodes;
  501. for(var i = 0, len = cs.length; i &lt; len; i++) {
  502. cs[i].collapse(deep);
  503. }
  504. },
  505. <span id='Ext-tree-TreeNode-method-disable'> /**
  506. </span> * Disables this node
  507. */
  508. disable : function(){
  509. this.disabled = true;
  510. this.unselect();
  511. if(this.rendered &amp;&amp; this.ui.onDisableChange){ // event without subscribing
  512. this.ui.onDisableChange(this, true);
  513. }
  514. this.fireEvent('disabledchange', this, true);
  515. },
  516. <span id='Ext-tree-TreeNode-method-enable'> /**
  517. </span> * Enables this node
  518. */
  519. enable : function(){
  520. this.disabled = false;
  521. if(this.rendered &amp;&amp; this.ui.onDisableChange){ // event without subscribing
  522. this.ui.onDisableChange(this, false);
  523. }
  524. this.fireEvent('disabledchange', this, false);
  525. },
  526. <span id='Ext-tree-TreeNode-method-renderChildren'> // private
  527. </span> renderChildren : function(suppressEvent){
  528. if(suppressEvent !== false){
  529. this.fireEvent('beforechildrenrendered', this);
  530. }
  531. var cs = this.childNodes;
  532. for(var i = 0, len = cs.length; i &lt; len; i++){
  533. cs[i].render(true);
  534. }
  535. this.childrenRendered = true;
  536. },
  537. <span id='Ext-tree-TreeNode-method-sort'> // private
  538. </span> sort : function(fn, scope){
  539. Ext.tree.TreeNode.superclass.sort.apply(this, arguments);
  540. if(this.childrenRendered){
  541. var cs = this.childNodes;
  542. for(var i = 0, len = cs.length; i &lt; len; i++){
  543. cs[i].render(true);
  544. }
  545. }
  546. },
  547. <span id='Ext-tree-TreeNode-method-render'> // private
  548. </span> render : function(bulkRender){
  549. this.ui.render(bulkRender);
  550. if(!this.rendered){
  551. // make sure it is registered
  552. this.getOwnerTree().registerNode(this);
  553. this.rendered = true;
  554. if(this.expanded){
  555. this.expanded = false;
  556. this.expand(false, false);
  557. }
  558. }
  559. },
  560. <span id='Ext-tree-TreeNode-method-renderIndent'> // private
  561. </span> renderIndent : function(deep, refresh){
  562. if(refresh){
  563. this.ui.childIndent = null;
  564. }
  565. this.ui.renderIndent();
  566. if(deep === true &amp;&amp; this.childrenRendered){
  567. var cs = this.childNodes;
  568. for(var i = 0, len = cs.length; i &lt; len; i++){
  569. cs[i].renderIndent(true, refresh);
  570. }
  571. }
  572. },
  573. <span id='Ext-tree-TreeNode-method-beginUpdate'> beginUpdate : function(){
  574. </span> this.childrenRendered = false;
  575. },
  576. <span id='Ext-tree-TreeNode-method-endUpdate'> endUpdate : function(){
  577. </span> if(this.expanded &amp;&amp; this.rendered){
  578. this.renderChildren();
  579. }
  580. },
  581. <span id='Ext-tree-TreeNode-method-destroy'> //inherit docs
  582. </span> destroy : function(silent){
  583. if(silent === true){
  584. this.unselect(true);
  585. }
  586. Ext.tree.TreeNode.superclass.destroy.call(this, silent);
  587. Ext.destroy(this.ui, this.loader);
  588. this.ui = this.loader = null;
  589. },
  590. <span id='Ext-tree-TreeNode-method-onIdChange'> // private
  591. </span> onIdChange : function(id){
  592. this.ui.onIdChange(id);
  593. }
  594. });
  595. Ext.tree.TreePanel.nodeTypes.node = Ext.tree.TreeNode;</pre>
  596. </body>
  597. </html>