X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6a7e4474cba9d8be4b2ec445e10f1691f7277c50..6b044c28b5f26fb99c86c237ffad19741c0f7f3d:/src/widgets/tree/TreeNodeUI.js?ds=sidebyside diff --git a/src/widgets/tree/TreeNodeUI.js b/src/widgets/tree/TreeNodeUI.js index 0e67c8e4..6c1aa086 100644 --- a/src/widgets/tree/TreeNodeUI.js +++ b/src/widgets/tree/TreeNodeUI.js @@ -1,8 +1,8 @@ /*! - * Ext JS Library 3.2.0 - * Copyright(c) 2006-2010 Ext JS, Inc. - * licensing@extjs.com - * http://www.extjs.com/license + * Ext JS Library 3.3.1 + * Copyright(c) 2006-2010 Sencha Inc. + * licensing@sencha.com + * http://www.sencha.com/license */ /** * @class Ext.tree.TreeNodeUI @@ -17,16 +17,19 @@ * This class provides access to the user interface components of an Ext TreeNode, through * {@link Ext.tree.TreeNode#getUI} */ -Ext.tree.TreeNodeUI = function(node){ - this.node = node; - this.rendered = false; - this.animating = false; - this.wasLeaf = true; - this.ecc = 'x-tree-ec-icon x-tree-elbow'; - this.emptyIcon = Ext.BLANK_IMAGE_URL; -}; - -Ext.tree.TreeNodeUI.prototype = { +Ext.tree.TreeNodeUI = Ext.extend(Object, { + + constructor : function(node){ + Ext.apply(this, { + node: node, + rendered: false, + animating: false, + wasLeaf: true, + ecc: 'x-tree-ec-icon x-tree-elbow', + emptyIcon: Ext.BLANK_IMAGE_URL + }); + }, + // private removeChild : function(node){ if(this.rendered){ @@ -50,6 +53,58 @@ Ext.tree.TreeNodeUI.prototype = { this.textNode.innerHTML = text; } }, + + // private + onIconClsChange : function(node, cls, oldCls){ + if(this.rendered){ + Ext.fly(this.iconNode).replaceClass(oldCls, cls); + } + }, + + // private + onIconChange : function(node, icon){ + if(this.rendered){ + //'', + var empty = Ext.isEmpty(icon); + this.iconNode.src = empty ? this.emptyIcon : icon; + Ext.fly(this.iconNode)[empty ? 'removeClass' : 'addClass']('x-tree-node-inline-icon'); + } + }, + + // private + onTipChange : function(node, tip, title){ + if(this.rendered){ + var hasTitle = Ext.isDefined(title); + if(this.textNode.setAttributeNS){ + this.textNode.setAttributeNS("ext", "qtip", tip); + if(hasTitle){ + this.textNode.setAttributeNS("ext", "qtitle", title); + } + }else{ + this.textNode.setAttribute("ext:qtip", tip); + if(hasTitle){ + this.textNode.setAttribute("ext:qtitle", title); + } + } + } + }, + + // private + onHrefChange : function(node, href, target){ + if(this.rendered){ + this.anchor.href = this.getHref(href); + if(Ext.isDefined(target)){ + this.anchor.target = target; + } + } + }, + + // private + onClsChange : function(node, cls, oldCls){ + if(this.rendered){ + Ext.fly(this.elNode).replaceClass(oldCls, cls); + } + }, // private onDisableChange : function(node, state){ @@ -57,11 +112,7 @@ Ext.tree.TreeNodeUI.prototype = { if (this.checkbox) { this.checkbox.disabled = state; } - if(state){ - this.addClass("x-tree-node-disabled"); - }else{ - this.removeClass("x-tree-node-disabled"); - } + this[state ? 'addClass' : 'removeClass']('x-tree-node-disabled'); }, // private @@ -404,17 +455,7 @@ Ext.tree.TreeNodeUI.prototype = { this.renderElements(n, a, targetNode, bulkRender); if(a.qtip){ - if(this.textNode.setAttributeNS){ - this.textNode.setAttributeNS("ext", "qtip", a.qtip); - if(a.qtipTitle){ - this.textNode.setAttributeNS("ext", "qtitle", a.qtipTitle); - } - }else{ - this.textNode.setAttribute("ext:qtip", a.qtip); - if(a.qtipTitle){ - this.textNode.setAttribute("ext:qtitle", a.qtipTitle); - } - } + this.onTipChange(n, a.qtip, a.qtipTitle); }else if(a.qtipCfg){ a.qtipCfg.target = Ext.id(this.textNode); Ext.QuickTips.register(a.qtipCfg); @@ -437,11 +478,11 @@ Ext.tree.TreeNodeUI.prototype = { var cb = Ext.isBoolean(a.checked), nel, - href = a.href ? a.href : Ext.isGecko ? "" : "#", + href = this.getHref(a.href), buf = ['
  • ', '',this.indentMarkup,"", - '', - '', + '', + '', cb ? ('' : '/>')) : '', '',n.text,"
    ", @@ -470,6 +511,14 @@ Ext.tree.TreeNodeUI.prototype = { this.anchor = cs[index]; this.textNode = cs[index].firstChild; }, + + /** + * @private Gets a normalized href for the node. + * @param {String} href + */ + getHref : function(href){ + return Ext.isEmpty(href) ? (Ext.isGecko ? '' : '#') : href; + }, /** * Returns the <a> element that provides focus for the node's UI. @@ -561,9 +610,9 @@ Ext.tree.TreeNodeUI.prototype = { while(p){ if(!p.isRoot || (p.isRoot && p.ownerTree.rootVisible)){ if(!p.isLast()) { - buf.unshift(''); + buf.unshift(''); } else { - buf.unshift(''); + buf.unshift(''); } } p = p.parentNode; @@ -602,7 +651,7 @@ Ext.tree.TreeNodeUI.prototype = { }, this); delete this.node; } -}; +}); /** * @class Ext.tree.RootTreeNodeUI