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.

689 lines
24 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-TreeNodeUI'>/**
  19. </span> * @class Ext.tree.TreeNodeUI
  20. * This class provides the default UI implementation for Ext TreeNodes.
  21. * The TreeNode UI implementation is separate from the
  22. * tree implementation, and allows customizing of the appearance of
  23. * tree nodes.&lt;br&gt;
  24. * &lt;p&gt;
  25. * If you are customizing the Tree's user interface, you
  26. * may need to extend this class, but you should never need to instantiate this class.&lt;br&gt;
  27. * &lt;p&gt;
  28. * This class provides access to the user interface components of an Ext TreeNode, through
  29. * {@link Ext.tree.TreeNode#getUI}
  30. */
  31. Ext.tree.TreeNodeUI = Ext.extend(Object, {
  32. <span id='Ext-tree-TreeNodeUI-method-constructor'> constructor : function(node){
  33. </span> Ext.apply(this, {
  34. node: node,
  35. rendered: false,
  36. animating: false,
  37. wasLeaf: true,
  38. ecc: 'x-tree-ec-icon x-tree-elbow',
  39. emptyIcon: Ext.BLANK_IMAGE_URL
  40. });
  41. },
  42. <span id='Ext-tree-TreeNodeUI-method-removeChild'> // private
  43. </span> removeChild : function(node){
  44. if(this.rendered){
  45. this.ctNode.removeChild(node.ui.getEl());
  46. }
  47. },
  48. <span id='Ext-tree-TreeNodeUI-method-beforeLoad'> // private
  49. </span> beforeLoad : function(){
  50. this.addClass(&quot;x-tree-node-loading&quot;);
  51. },
  52. <span id='Ext-tree-TreeNodeUI-method-afterLoad'> // private
  53. </span> afterLoad : function(){
  54. this.removeClass(&quot;x-tree-node-loading&quot;);
  55. },
  56. <span id='Ext-tree-TreeNodeUI-method-onTextChange'> // private
  57. </span> onTextChange : function(node, text, oldText){
  58. if(this.rendered){
  59. this.textNode.innerHTML = text;
  60. }
  61. },
  62. <span id='Ext-tree-TreeNodeUI-method-onIconClsChange'> // private
  63. </span> onIconClsChange : function(node, cls, oldCls){
  64. if(this.rendered){
  65. Ext.fly(this.iconNode).replaceClass(oldCls, cls);
  66. }
  67. },
  68. <span id='Ext-tree-TreeNodeUI-method-onIconChange'> // private
  69. </span> onIconChange : function(node, icon){
  70. if(this.rendered){
  71. //'&lt;img src=&quot;', a.icon || this.emptyIcon, '&quot; class=&quot;x-tree-node-icon',(a.icon ? &quot; x-tree-node-inline-icon&quot; : &quot;&quot;),(a.iconCls ? &quot; &quot;+a.iconCls : &quot;&quot;),'&quot; unselectable=&quot;on&quot; /&gt;',
  72. var empty = Ext.isEmpty(icon);
  73. this.iconNode.src = empty ? this.emptyIcon : icon;
  74. Ext.fly(this.iconNode)[empty ? 'removeClass' : 'addClass']('x-tree-node-inline-icon');
  75. }
  76. },
  77. <span id='Ext-tree-TreeNodeUI-method-onTipChange'> // private
  78. </span> onTipChange : function(node, tip, title){
  79. if(this.rendered){
  80. var hasTitle = Ext.isDefined(title);
  81. if(this.textNode.setAttributeNS){
  82. this.textNode.setAttributeNS(&quot;ext&quot;, &quot;qtip&quot;, tip);
  83. if(hasTitle){
  84. this.textNode.setAttributeNS(&quot;ext&quot;, &quot;qtitle&quot;, title);
  85. }
  86. }else{
  87. this.textNode.setAttribute(&quot;ext:qtip&quot;, tip);
  88. if(hasTitle){
  89. this.textNode.setAttribute(&quot;ext:qtitle&quot;, title);
  90. }
  91. }
  92. }
  93. },
  94. <span id='Ext-tree-TreeNodeUI-method-onHrefChange'> // private
  95. </span> onHrefChange : function(node, href, target){
  96. if(this.rendered){
  97. this.anchor.href = this.getHref(href);
  98. if(Ext.isDefined(target)){
  99. this.anchor.target = target;
  100. }
  101. }
  102. },
  103. <span id='Ext-tree-TreeNodeUI-method-onClsChange'> // private
  104. </span> onClsChange : function(node, cls, oldCls){
  105. if(this.rendered){
  106. Ext.fly(this.elNode).replaceClass(oldCls, cls);
  107. }
  108. },
  109. <span id='Ext-tree-TreeNodeUI-method-onDisableChange'> // private
  110. </span> onDisableChange : function(node, state){
  111. this.disabled = state;
  112. if (this.checkbox) {
  113. this.checkbox.disabled = state;
  114. }
  115. this[state ? 'addClass' : 'removeClass']('x-tree-node-disabled');
  116. },
  117. <span id='Ext-tree-TreeNodeUI-method-onSelectedChange'> // private
  118. </span> onSelectedChange : function(state){
  119. if(state){
  120. this.focus();
  121. this.addClass(&quot;x-tree-selected&quot;);
  122. }else{
  123. //this.blur();
  124. this.removeClass(&quot;x-tree-selected&quot;);
  125. }
  126. },
  127. <span id='Ext-tree-TreeNodeUI-method-onMove'> // private
  128. </span> onMove : function(tree, node, oldParent, newParent, index, refNode){
  129. this.childIndent = null;
  130. if(this.rendered){
  131. var targetNode = newParent.ui.getContainer();
  132. if(!targetNode){//target not rendered
  133. this.holder = document.createElement(&quot;div&quot;);
  134. this.holder.appendChild(this.wrap);
  135. return;
  136. }
  137. var insertBefore = refNode ? refNode.ui.getEl() : null;
  138. if(insertBefore){
  139. targetNode.insertBefore(this.wrap, insertBefore);
  140. }else{
  141. targetNode.appendChild(this.wrap);
  142. }
  143. this.node.renderIndent(true, oldParent != newParent);
  144. }
  145. },
  146. <span id='Ext-tree-TreeNodeUI-method-addClass'>/**
  147. </span> * Adds one or more CSS classes to the node's UI element.
  148. * Duplicate classes are automatically filtered out.
  149. * @param {String/Array} className The CSS class to add, or an array of classes
  150. */
  151. addClass : function(cls){
  152. if(this.elNode){
  153. Ext.fly(this.elNode).addClass(cls);
  154. }
  155. },
  156. <span id='Ext-tree-TreeNodeUI-method-removeClass'>/**
  157. </span> * Removes one or more CSS classes from the node's UI element.
  158. * @param {String/Array} className The CSS class to remove, or an array of classes
  159. */
  160. removeClass : function(cls){
  161. if(this.elNode){
  162. Ext.fly(this.elNode).removeClass(cls);
  163. }
  164. },
  165. <span id='Ext-tree-TreeNodeUI-method-remove'> // private
  166. </span> remove : function(){
  167. if(this.rendered){
  168. this.holder = document.createElement(&quot;div&quot;);
  169. this.holder.appendChild(this.wrap);
  170. }
  171. },
  172. <span id='Ext-tree-TreeNodeUI-method-fireEvent'> // private
  173. </span> fireEvent : function(){
  174. return this.node.fireEvent.apply(this.node, arguments);
  175. },
  176. <span id='Ext-tree-TreeNodeUI-method-initEvents'> // private
  177. </span> initEvents : function(){
  178. this.node.on(&quot;move&quot;, this.onMove, this);
  179. if(this.node.disabled){
  180. this.onDisableChange(this.node, true);
  181. }
  182. if(this.node.hidden){
  183. this.hide();
  184. }
  185. var ot = this.node.getOwnerTree();
  186. var dd = ot.enableDD || ot.enableDrag || ot.enableDrop;
  187. if(dd &amp;&amp; (!this.node.isRoot || ot.rootVisible)){
  188. Ext.dd.Registry.register(this.elNode, {
  189. node: this.node,
  190. handles: this.getDDHandles(),
  191. isHandle: false
  192. });
  193. }
  194. },
  195. <span id='Ext-tree-TreeNodeUI-method-getDDHandles'> // private
  196. </span> getDDHandles : function(){
  197. return [this.iconNode, this.textNode, this.elNode];
  198. },
  199. <span id='Ext-tree-TreeNodeUI-method-hide'>/**
  200. </span> * Hides this node.
  201. */
  202. hide : function(){
  203. this.node.hidden = true;
  204. if(this.wrap){
  205. this.wrap.style.display = &quot;none&quot;;
  206. }
  207. },
  208. <span id='Ext-tree-TreeNodeUI-method-show'>/**
  209. </span> * Shows this node.
  210. */
  211. show : function(){
  212. this.node.hidden = false;
  213. if(this.wrap){
  214. this.wrap.style.display = &quot;&quot;;
  215. }
  216. },
  217. <span id='Ext-tree-TreeNodeUI-method-onContextMenu'> // private
  218. </span> onContextMenu : function(e){
  219. if (this.node.hasListener(&quot;contextmenu&quot;) || this.node.getOwnerTree().hasListener(&quot;contextmenu&quot;)) {
  220. e.preventDefault();
  221. this.focus();
  222. this.fireEvent(&quot;contextmenu&quot;, this.node, e);
  223. }
  224. },
  225. <span id='Ext-tree-TreeNodeUI-method-onClick'> // private
  226. </span> onClick : function(e){
  227. if(this.dropping){
  228. e.stopEvent();
  229. return;
  230. }
  231. if(this.fireEvent(&quot;beforeclick&quot;, this.node, e) !== false){
  232. var a = e.getTarget('a');
  233. if(!this.disabled &amp;&amp; this.node.attributes.href &amp;&amp; a){
  234. this.fireEvent(&quot;click&quot;, this.node, e);
  235. return;
  236. }else if(a &amp;&amp; e.ctrlKey){
  237. e.stopEvent();
  238. }
  239. e.preventDefault();
  240. if(this.disabled){
  241. return;
  242. }
  243. if(this.node.attributes.singleClickExpand &amp;&amp; !this.animating &amp;&amp; this.node.isExpandable()){
  244. this.node.toggle();
  245. }
  246. this.fireEvent(&quot;click&quot;, this.node, e);
  247. }else{
  248. e.stopEvent();
  249. }
  250. },
  251. <span id='Ext-tree-TreeNodeUI-method-onDblClick'> // private
  252. </span> onDblClick : function(e){
  253. e.preventDefault();
  254. if(this.disabled){
  255. return;
  256. }
  257. if(this.fireEvent(&quot;beforedblclick&quot;, this.node, e) !== false){
  258. if(this.checkbox){
  259. this.toggleCheck();
  260. }
  261. if(!this.animating &amp;&amp; this.node.isExpandable()){
  262. this.node.toggle();
  263. }
  264. this.fireEvent(&quot;dblclick&quot;, this.node, e);
  265. }
  266. },
  267. <span id='Ext-tree-TreeNodeUI-method-onOver'> onOver : function(e){
  268. </span> this.addClass('x-tree-node-over');
  269. },
  270. <span id='Ext-tree-TreeNodeUI-method-onOut'> onOut : function(e){
  271. </span> this.removeClass('x-tree-node-over');
  272. },
  273. <span id='Ext-tree-TreeNodeUI-method-onCheckChange'> // private
  274. </span> onCheckChange : function(){
  275. var checked = this.checkbox.checked;
  276. // fix for IE6
  277. this.checkbox.defaultChecked = checked;
  278. this.node.attributes.checked = checked;
  279. this.fireEvent('checkchange', this.node, checked);
  280. },
  281. <span id='Ext-tree-TreeNodeUI-method-ecClick'> // private
  282. </span> ecClick : function(e){
  283. if(!this.animating &amp;&amp; this.node.isExpandable()){
  284. this.node.toggle();
  285. }
  286. },
  287. <span id='Ext-tree-TreeNodeUI-method-startDrop'> // private
  288. </span> startDrop : function(){
  289. this.dropping = true;
  290. },
  291. <span id='Ext-tree-TreeNodeUI-method-endDrop'> // delayed drop so the click event doesn't get fired on a drop
  292. </span> endDrop : function(){
  293. setTimeout(function(){
  294. this.dropping = false;
  295. }.createDelegate(this), 50);
  296. },
  297. <span id='Ext-tree-TreeNodeUI-method-expand'> // private
  298. </span> expand : function(){
  299. this.updateExpandIcon();
  300. this.ctNode.style.display = &quot;&quot;;
  301. },
  302. <span id='Ext-tree-TreeNodeUI-method-focus'> // private
  303. </span> focus : function(){
  304. if(!this.node.preventHScroll){
  305. try{this.anchor.focus();
  306. }catch(e){}
  307. }else{
  308. try{
  309. var noscroll = this.node.getOwnerTree().getTreeEl().dom;
  310. var l = noscroll.scrollLeft;
  311. this.anchor.focus();
  312. noscroll.scrollLeft = l;
  313. }catch(e){}
  314. }
  315. },
  316. <span id='Ext-tree-TreeNodeUI-method-toggleCheck'>/**
  317. </span> * Sets the checked status of the tree node to the passed value, or, if no value was passed,
  318. * toggles the checked status. If the node was rendered with no checkbox, this has no effect.
  319. * @param {Boolean} value (optional) The new checked status.
  320. */
  321. toggleCheck : function(value){
  322. var cb = this.checkbox;
  323. if(cb){
  324. cb.checked = (value === undefined ? !cb.checked : value);
  325. this.onCheckChange();
  326. }
  327. },
  328. <span id='Ext-tree-TreeNodeUI-method-blur'> // private
  329. </span> blur : function(){
  330. try{
  331. this.anchor.blur();
  332. }catch(e){}
  333. },
  334. <span id='Ext-tree-TreeNodeUI-method-animExpand'> // private
  335. </span> animExpand : function(callback){
  336. var ct = Ext.get(this.ctNode);
  337. ct.stopFx();
  338. if(!this.node.isExpandable()){
  339. this.updateExpandIcon();
  340. this.ctNode.style.display = &quot;&quot;;
  341. Ext.callback(callback);
  342. return;
  343. }
  344. this.animating = true;
  345. this.updateExpandIcon();
  346. ct.slideIn('t', {
  347. callback : function(){
  348. this.animating = false;
  349. Ext.callback(callback);
  350. },
  351. scope: this,
  352. duration: this.node.ownerTree.duration || .25
  353. });
  354. },
  355. <span id='Ext-tree-TreeNodeUI-method-highlight'> // private
  356. </span> highlight : function(){
  357. var tree = this.node.getOwnerTree();
  358. Ext.fly(this.wrap).highlight(
  359. tree.hlColor || &quot;C3DAF9&quot;,
  360. {endColor: tree.hlBaseColor}
  361. );
  362. },
  363. <span id='Ext-tree-TreeNodeUI-method-collapse'> // private
  364. </span> collapse : function(){
  365. this.updateExpandIcon();
  366. this.ctNode.style.display = &quot;none&quot;;
  367. },
  368. <span id='Ext-tree-TreeNodeUI-method-animCollapse'> // private
  369. </span> animCollapse : function(callback){
  370. var ct = Ext.get(this.ctNode);
  371. ct.enableDisplayMode('block');
  372. ct.stopFx();
  373. this.animating = true;
  374. this.updateExpandIcon();
  375. ct.slideOut('t', {
  376. callback : function(){
  377. this.animating = false;
  378. Ext.callback(callback);
  379. },
  380. scope: this,
  381. duration: this.node.ownerTree.duration || .25
  382. });
  383. },
  384. <span id='Ext-tree-TreeNodeUI-method-getContainer'> // private
  385. </span> getContainer : function(){
  386. return this.ctNode;
  387. },
  388. <span id='Ext-tree-TreeNodeUI-method-getEl'>/**
  389. </span> * Returns the element which encapsulates this node.
  390. * @return {HtmlElement} The DOM element. The default implementation uses a &lt;code&gt;&amp;lt;li&gt;&lt;/code&gt;.
  391. */
  392. getEl : function(){
  393. return this.wrap;
  394. },
  395. <span id='Ext-tree-TreeNodeUI-method-appendDDGhost'> // private
  396. </span> appendDDGhost : function(ghostNode){
  397. ghostNode.appendChild(this.elNode.cloneNode(true));
  398. },
  399. <span id='Ext-tree-TreeNodeUI-method-getDDRepairXY'> // private
  400. </span> getDDRepairXY : function(){
  401. return Ext.lib.Dom.getXY(this.iconNode);
  402. },
  403. <span id='Ext-tree-TreeNodeUI-method-onRender'> // private
  404. </span> onRender : function(){
  405. this.render();
  406. },
  407. <span id='Ext-tree-TreeNodeUI-method-render'> // private
  408. </span> render : function(bulkRender){
  409. var n = this.node, a = n.attributes;
  410. var targetNode = n.parentNode ?
  411. n.parentNode.ui.getContainer() : n.ownerTree.innerCt.dom;
  412. if(!this.rendered){
  413. this.rendered = true;
  414. this.renderElements(n, a, targetNode, bulkRender);
  415. if(a.qtip){
  416. this.onTipChange(n, a.qtip, a.qtipTitle);
  417. }else if(a.qtipCfg){
  418. a.qtipCfg.target = Ext.id(this.textNode);
  419. Ext.QuickTips.register(a.qtipCfg);
  420. }
  421. this.initEvents();
  422. if(!this.node.expanded){
  423. this.updateExpandIcon(true);
  424. }
  425. }else{
  426. if(bulkRender === true) {
  427. targetNode.appendChild(this.wrap);
  428. }
  429. }
  430. },
  431. <span id='Ext-tree-TreeNodeUI-method-renderElements'> // private
  432. </span> renderElements : function(n, a, targetNode, bulkRender){
  433. // add some indent caching, this helps performance when rendering a large tree
  434. this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
  435. var cb = Ext.isBoolean(a.checked),
  436. nel,
  437. href = this.getHref(a.href),
  438. buf = ['&lt;li class=&quot;x-tree-node&quot;&gt;&lt;div ext:tree-node-id=&quot;',n.id,'&quot; class=&quot;x-tree-node-el x-tree-node-leaf x-unselectable ', a.cls,'&quot; unselectable=&quot;on&quot;&gt;',
  439. '&lt;span class=&quot;x-tree-node-indent&quot;&gt;',this.indentMarkup,&quot;&lt;/span&gt;&quot;,
  440. '&lt;img alt=&quot;&quot; src=&quot;', this.emptyIcon, '&quot; class=&quot;x-tree-ec-icon x-tree-elbow&quot; /&gt;',
  441. '&lt;img alt=&quot;&quot; src=&quot;', a.icon || this.emptyIcon, '&quot; class=&quot;x-tree-node-icon',(a.icon ? &quot; x-tree-node-inline-icon&quot; : &quot;&quot;),(a.iconCls ? &quot; &quot;+a.iconCls : &quot;&quot;),'&quot; unselectable=&quot;on&quot; /&gt;',
  442. cb ? ('&lt;input class=&quot;x-tree-node-cb&quot; type=&quot;checkbox&quot; ' + (a.checked ? 'checked=&quot;checked&quot; /&gt;' : '/&gt;')) : '',
  443. '&lt;a hidefocus=&quot;on&quot; class=&quot;x-tree-node-anchor&quot; href=&quot;',href,'&quot; tabIndex=&quot;1&quot; ',
  444. a.hrefTarget ? ' target=&quot;'+a.hrefTarget+'&quot;' : &quot;&quot;, '&gt;&lt;span unselectable=&quot;on&quot;&gt;',n.text,&quot;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&quot;,
  445. '&lt;ul class=&quot;x-tree-node-ct&quot; style=&quot;display:none;&quot;&gt;&lt;/ul&gt;',
  446. &quot;&lt;/li&gt;&quot;].join('');
  447. if(bulkRender !== true &amp;&amp; n.nextSibling &amp;&amp; (nel = n.nextSibling.ui.getEl())){
  448. this.wrap = Ext.DomHelper.insertHtml(&quot;beforeBegin&quot;, nel, buf);
  449. }else{
  450. this.wrap = Ext.DomHelper.insertHtml(&quot;beforeEnd&quot;, targetNode, buf);
  451. }
  452. this.elNode = this.wrap.childNodes[0];
  453. this.ctNode = this.wrap.childNodes[1];
  454. var cs = this.elNode.childNodes;
  455. this.indentNode = cs[0];
  456. this.ecNode = cs[1];
  457. this.iconNode = cs[2];
  458. var index = 3;
  459. if(cb){
  460. this.checkbox = cs[3];
  461. // fix for IE6
  462. this.checkbox.defaultChecked = this.checkbox.checked;
  463. index++;
  464. }
  465. this.anchor = cs[index];
  466. this.textNode = cs[index].firstChild;
  467. },
  468. <span id='Ext-tree-TreeNodeUI-method-getHref'> /**
  469. </span> * @private Gets a normalized href for the node.
  470. * @param {String} href
  471. */
  472. getHref : function(href){
  473. return Ext.isEmpty(href) ? (Ext.isGecko ? '' : '#') : href;
  474. },
  475. <span id='Ext-tree-TreeNodeUI-method-getAnchor'>/**
  476. </span> * Returns the &amp;lt;a&gt; element that provides focus for the node's UI.
  477. * @return {HtmlElement} The DOM anchor element.
  478. */
  479. getAnchor : function(){
  480. return this.anchor;
  481. },
  482. <span id='Ext-tree-TreeNodeUI-method-getTextEl'>/**
  483. </span> * Returns the text node.
  484. * @return {HtmlNode} The DOM text node.
  485. */
  486. getTextEl : function(){
  487. return this.textNode;
  488. },
  489. <span id='Ext-tree-TreeNodeUI-method-getIconEl'>/**
  490. </span> * Returns the icon &amp;lt;img&gt; element.
  491. * @return {HtmlElement} The DOM image element.
  492. */
  493. getIconEl : function(){
  494. return this.iconNode;
  495. },
  496. <span id='Ext-tree-TreeNodeUI-method-isChecked'>/**
  497. </span> * Returns the checked status of the node. If the node was rendered with no
  498. * checkbox, it returns false.
  499. * @return {Boolean} The checked flag.
  500. */
  501. isChecked : function(){
  502. return this.checkbox ? this.checkbox.checked : false;
  503. },
  504. <span id='Ext-tree-TreeNodeUI-method-updateExpandIcon'> // private
  505. </span> updateExpandIcon : function(){
  506. if(this.rendered){
  507. var n = this.node,
  508. c1,
  509. c2,
  510. cls = n.isLast() ? &quot;x-tree-elbow-end&quot; : &quot;x-tree-elbow&quot;,
  511. hasChild = n.hasChildNodes();
  512. if(hasChild || n.attributes.expandable){
  513. if(n.expanded){
  514. cls += &quot;-minus&quot;;
  515. c1 = &quot;x-tree-node-collapsed&quot;;
  516. c2 = &quot;x-tree-node-expanded&quot;;
  517. }else{
  518. cls += &quot;-plus&quot;;
  519. c1 = &quot;x-tree-node-expanded&quot;;
  520. c2 = &quot;x-tree-node-collapsed&quot;;
  521. }
  522. if(this.wasLeaf){
  523. this.removeClass(&quot;x-tree-node-leaf&quot;);
  524. this.wasLeaf = false;
  525. }
  526. if(this.c1 != c1 || this.c2 != c2){
  527. Ext.fly(this.elNode).replaceClass(c1, c2);
  528. this.c1 = c1; this.c2 = c2;
  529. }
  530. }else{
  531. if(!this.wasLeaf){
  532. Ext.fly(this.elNode).replaceClass(&quot;x-tree-node-expanded&quot;, &quot;x-tree-node-collapsed&quot;);
  533. delete this.c1;
  534. delete this.c2;
  535. this.wasLeaf = true;
  536. }
  537. }
  538. var ecc = &quot;x-tree-ec-icon &quot;+cls;
  539. if(this.ecc != ecc){
  540. this.ecNode.className = ecc;
  541. this.ecc = ecc;
  542. }
  543. }
  544. },
  545. <span id='Ext-tree-TreeNodeUI-method-onIdChange'> // private
  546. </span> onIdChange: function(id){
  547. if(this.rendered){
  548. this.elNode.setAttribute('ext:tree-node-id', id);
  549. }
  550. },
  551. <span id='Ext-tree-TreeNodeUI-method-getChildIndent'> // private
  552. </span> getChildIndent : function(){
  553. if(!this.childIndent){
  554. var buf = [],
  555. p = this.node;
  556. while(p){
  557. if(!p.isRoot || (p.isRoot &amp;&amp; p.ownerTree.rootVisible)){
  558. if(!p.isLast()) {
  559. buf.unshift('&lt;img alt=&quot;&quot; src=&quot;'+this.emptyIcon+'&quot; class=&quot;x-tree-elbow-line&quot; /&gt;');
  560. } else {
  561. buf.unshift('&lt;img alt=&quot;&quot; src=&quot;'+this.emptyIcon+'&quot; class=&quot;x-tree-icon&quot; /&gt;');
  562. }
  563. }
  564. p = p.parentNode;
  565. }
  566. this.childIndent = buf.join(&quot;&quot;);
  567. }
  568. return this.childIndent;
  569. },
  570. <span id='Ext-tree-TreeNodeUI-method-renderIndent'> // private
  571. </span> renderIndent : function(){
  572. if(this.rendered){
  573. var indent = &quot;&quot;,
  574. p = this.node.parentNode;
  575. if(p){
  576. indent = p.ui.getChildIndent();
  577. }
  578. if(this.indentMarkup != indent){ // don't rerender if not required
  579. this.indentNode.innerHTML = indent;
  580. this.indentMarkup = indent;
  581. }
  582. this.updateExpandIcon();
  583. }
  584. },
  585. <span id='Ext-tree-TreeNodeUI-method-destroy'> destroy : function(){
  586. </span> if(this.elNode){
  587. Ext.dd.Registry.unregister(this.elNode.id);
  588. }
  589. Ext.each(['textnode', 'anchor', 'checkbox', 'indentNode', 'ecNode', 'iconNode', 'elNode', 'ctNode', 'wrap', 'holder'], function(el){
  590. if(this[el]){
  591. Ext.fly(this[el]).remove();
  592. delete this[el];
  593. }
  594. }, this);
  595. delete this.node;
  596. }
  597. });
  598. <span id='Ext-tree-RootTreeNodeUI'>/**
  599. </span> * @class Ext.tree.RootTreeNodeUI
  600. * This class provides the default UI implementation for &lt;b&gt;root&lt;/b&gt; Ext TreeNodes.
  601. * The RootTreeNode UI implementation allows customizing the appearance of the root tree node.&lt;br&gt;
  602. * &lt;p&gt;
  603. * If you are customizing the Tree's user interface, you
  604. * may need to extend this class, but you should never need to instantiate this class.&lt;br&gt;
  605. */
  606. Ext.tree.RootTreeNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
  607. <span id='Ext-tree-RootTreeNodeUI-method-render'> // private
  608. </span> render : function(){
  609. if(!this.rendered){
  610. var targetNode = this.node.ownerTree.innerCt.dom;
  611. this.node.expanded = true;
  612. targetNode.innerHTML = '&lt;div class=&quot;x-tree-root-node&quot;&gt;&lt;/div&gt;';
  613. this.wrap = this.ctNode = targetNode.firstChild;
  614. }
  615. },
  616. <span id='Ext-tree-RootTreeNodeUI-method-collapse'> collapse : Ext.emptyFn,
  617. </span><span id='Ext-tree-RootTreeNodeUI-method-expand'> expand : Ext.emptyFn
  618. </span>});</pre>
  619. </body>
  620. </html>