ext-all-debug.js
资源名称:ext-3.0.0.zip [点击查看]
上传用户:shuoshiled
上传日期:2018-01-28
资源大小:10124k
文件大小:2341k
源码类别:
中间件编程
开发平台:
JavaScript
- afterRender : function(){
- Ext.ToolTip.superclass.afterRender.call(this);
- this.anchorEl.setStyle('z-index', this.el.getZIndex() + 1);
- },
- /**
- * Binds this ToolTip to the specified element. The tooltip will be displayed when the mouse moves over the element.
- * @param {Mixed} t The Element, HtmlElement, or ID of an element to bind to
- */
- initTarget : function(target){
- var t;
- if((t = Ext.get(target))){
- if(this.target){
- this.target = Ext.get(this.target);
- this.target.un('mouseover', this.onTargetOver, this);
- this.target.un('mouseout', this.onTargetOut, this);
- this.target.un('mousemove', this.onMouseMove, this);
- }
- this.mon(t, {
- mouseover: this.onTargetOver,
- mouseout: this.onTargetOut,
- mousemove: this.onMouseMove,
- scope: this
- });
- this.target = t;
- }
- if(this.anchor){
- this.anchorTarget = this.target;
- }
- },
- // private
- onMouseMove : function(e){
- var t = this.delegate ? e.getTarget(this.delegate) : this.triggerElement = true;
- if (t) {
- this.targetXY = e.getXY();
- if (t === this.triggerElement) {
- if(!this.hidden && this.trackMouse){
- this.setPagePosition(this.getTargetXY());
- }
- } else {
- this.hide();
- this.lastActive = new Date(0);
- this.onTargetOver(e);
- }
- } else if (!this.closable && this.isVisible()) {
- this.hide();
- }
- },
- // private
- getTargetXY : function(){
- if(this.anchor){
- this.targetCounter++;
- var offsets = this.getOffsets();
- var xy = (this.anchorToTarget && !this.trackMouse) ?
- this.el.getAlignToXY(this.anchorTarget, this.getAnchorAlign()) :
- this.targetXY;
- var dw = Ext.lib.Dom.getViewWidth()-5;
- var dh = Ext.lib.Dom.getViewHeight()-5;
- var scrollX = (document.documentElement.scrollLeft || document.body.scrollLeft || 0)+5;
- var scrollY = (document.documentElement.scrollTop || document.body.scrollTop || 0)+5;
- var axy = [xy[0] + offsets[0], xy[1] + offsets[1]];
- var sz = this.getSize();
- this.anchorEl.removeClass(this.anchorCls);
- if(this.targetCounter < 2){
- if(axy[0] < scrollX){
- if(this.anchorToTarget){
- this.defaultAlign = 'l-r';
- if(this.mouseOffset){this.mouseOffset[0] *= -1;}
- }
- this.anchor = 'left';
- return this.getTargetXY();
- }
- if(axy[0]+sz.width > dw){
- if(this.anchorToTarget){
- this.defaultAlign = 'r-l';
- if(this.mouseOffset){this.mouseOffset[0] *= -1;}
- }
- this.anchor = 'right';
- return this.getTargetXY();
- }
- if(axy[1] < scrollY){
- if(this.anchorToTarget){
- this.defaultAlign = 't-b';
- if(this.mouseOffset){this.mouseOffset[1] *= -1;}
- }
- this.anchor = 'top';
- return this.getTargetXY();
- }
- if(axy[1]+sz.height > dh){
- if(this.anchorToTarget){
- this.defaultAlign = 'b-t';
- if(this.mouseOffset){this.mouseOffset[1] *= -1;}
- }
- this.anchor = 'bottom';
- return this.getTargetXY();
- }
- }
- this.anchorCls = 'x-tip-anchor-'+this.getAnchorPosition();
- this.anchorEl.addClass(this.anchorCls);
- this.targetCounter = 0;
- return axy;
- }else{
- var mouseOffset = this.getMouseOffset();
- return [this.targetXY[0]+mouseOffset[0], this.targetXY[1]+mouseOffset[1]];
- }
- },
- getMouseOffset : function(){
- var offset = this.anchor ? [0,0] : [15,18];
- if(this.mouseOffset){
- offset[0] += this.mouseOffset[0];
- offset[1] += this.mouseOffset[1];
- }
- return offset;
- },
- // private
- getAnchorPosition : function(){
- if(this.anchor){
- this.tipAnchor = this.anchor.charAt(0);
- }else{
- var m = this.defaultAlign.match(/^([a-z]+)-([a-z]+)(?)?$/);
- if(!m){
- throw "AnchorTip.defaultAlign is invalid";
- }
- this.tipAnchor = m[1].charAt(0);
- }
- switch(this.tipAnchor){
- case 't': return 'top';
- case 'b': return 'bottom';
- case 'r': return 'right';
- }
- return 'left';
- },
- // private
- getAnchorAlign : function(){
- switch(this.anchor){
- case 'top' : return 'tl-bl';
- case 'left' : return 'tl-tr';
- case 'right': return 'tr-tl';
- default : return 'bl-tl';
- }
- },
- // private
- getOffsets: function(){
- var offsets, ap = this.getAnchorPosition().charAt(0);
- if(this.anchorToTarget && !this.trackMouse){
- switch(ap){
- case 't':
- offsets = [0, 9];
- break;
- case 'b':
- offsets = [0, -13];
- break;
- case 'r':
- offsets = [-13, 0];
- break;
- default:
- offsets = [9, 0];
- break;
- }
- }else{
- switch(ap){
- case 't':
- offsets = [-15-this.anchorOffset, 30];
- break;
- case 'b':
- offsets = [-19-this.anchorOffset, -13-this.el.dom.offsetHeight];
- break;
- case 'r':
- offsets = [-15-this.el.dom.offsetWidth, -13-this.anchorOffset];
- break;
- default:
- offsets = [25, -13-this.anchorOffset];
- break;
- }
- }
- var mouseOffset = this.getMouseOffset();
- offsets[0] += mouseOffset[0];
- offsets[1] += mouseOffset[1];
- return offsets;
- },
- // private
- onTargetOver : function(e){
- if(this.disabled || e.within(this.target.dom, true)){
- return;
- }
- var t = e.getTarget(this.delegate);
- if (t) {
- this.triggerElement = t;
- this.clearTimer('hide');
- this.targetXY = e.getXY();
- this.delayShow();
- }
- },
- // private
- delayShow : function(){
- if(this.hidden && !this.showTimer){
- if(this.lastActive.getElapsed() < this.quickShowInterval){
- this.show();
- }else{
- this.showTimer = this.show.defer(this.showDelay, this);
- }
- }else if(!this.hidden && this.autoHide !== false){
- this.show();
- }
- },
- // private
- onTargetOut : function(e){
- if(this.disabled || e.within(this.target.dom, true)){
- return;
- }
- this.clearTimer('show');
- if(this.autoHide !== false){
- this.delayHide();
- }
- },
- // private
- delayHide : function(){
- if(!this.hidden && !this.hideTimer){
- this.hideTimer = this.hide.defer(this.hideDelay, this);
- }
- },
- /**
- * Hides this tooltip if visible.
- */
- hide: function(){
- this.clearTimer('dismiss');
- this.lastActive = new Date();
- if(this.anchorEl){
- this.anchorEl.hide();
- }
- Ext.ToolTip.superclass.hide.call(this);
- delete this.triggerElement;
- },
- /**
- * Shows this tooltip at the current event target XY position.
- */
- show : function(){
- if(this.anchor){
- // pre-show it off screen so that the el will have dimensions
- // for positioning calcs when getting xy next
- this.showAt([-1000,-1000]);
- this.origConstrainPosition = this.constrainPosition;
- this.constrainPosition = false;
- this.anchor = this.origAnchor;
- }
- this.showAt(this.getTargetXY());
- if(this.anchor){
- this.syncAnchor();
- this.anchorEl.show();
- this.constrainPosition = this.origConstrainPosition;
- }else{
- this.anchorEl.hide();
- }
- },
- // inherit docs
- showAt : function(xy){
- this.lastActive = new Date();
- this.clearTimers();
- Ext.ToolTip.superclass.showAt.call(this, xy);
- if(this.dismissDelay && this.autoHide !== false){
- this.dismissTimer = this.hide.defer(this.dismissDelay, this);
- }
- },
- // private
- syncAnchor : function(){
- var anchorPos, targetPos, offset;
- switch(this.tipAnchor.charAt(0)){
- case 't':
- anchorPos = 'b';
- targetPos = 'tl';
- offset = [20+this.anchorOffset, 2];
- break;
- case 'r':
- anchorPos = 'l';
- targetPos = 'tr';
- offset = [-2, 11+this.anchorOffset];
- break;
- case 'b':
- anchorPos = 't';
- targetPos = 'bl';
- offset = [20+this.anchorOffset, -2];
- break;
- default:
- anchorPos = 'r';
- targetPos = 'tl';
- offset = [2, 11+this.anchorOffset];
- break;
- }
- this.anchorEl.alignTo(this.el, anchorPos+'-'+targetPos, offset);
- },
- // private
- setPagePosition : function(x, y){
- Ext.ToolTip.superclass.setPagePosition.call(this, x, y);
- if(this.anchor){
- this.syncAnchor();
- }
- },
- // private
- clearTimer : function(name){
- name = name + 'Timer';
- clearTimeout(this[name]);
- delete this[name];
- },
- // private
- clearTimers : function(){
- this.clearTimer('show');
- this.clearTimer('dismiss');
- this.clearTimer('hide');
- },
- // private
- onShow : function(){
- Ext.ToolTip.superclass.onShow.call(this);
- Ext.getDoc().on('mousedown', this.onDocMouseDown, this);
- },
- // private
- onHide : function(){
- Ext.ToolTip.superclass.onHide.call(this);
- Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
- },
- // private
- onDocMouseDown : function(e){
- if(this.autoHide !== true && !this.closable && !e.within(this.el.dom)){
- this.disable();
- this.enable.defer(100, this);
- }
- },
- // private
- onDisable : function(){
- this.clearTimers();
- this.hide();
- },
- // private
- adjustPosition : function(x, y){
- if(this.contstrainPosition){
- var ay = this.targetXY[1], h = this.getSize().height;
- if(y <= ay && (y+h) >= ay){
- y = ay-h-5;
- }
- }
- return {x : x, y: y};
- },
- // private
- onDestroy : function(){
- Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
- Ext.ToolTip.superclass.onDestroy.call(this);
- }
- });/**
- * @class Ext.QuickTip
- * @extends Ext.ToolTip
- * A specialized tooltip class for tooltips that can be specified in markup and automatically managed by the global
- * {@link Ext.QuickTips} instance. See the QuickTips class header for additional usage details and examples.
- * @constructor
- * Create a new Tip
- * @param {Object} config The configuration options
- */
- Ext.QuickTip = Ext.extend(Ext.ToolTip, {
- /**
- * @cfg {Mixed} target The target HTMLElement, Ext.Element or id to associate with this quicktip (defaults to the document).
- */
- /**
- * @cfg {Boolean} interceptTitles True to automatically use the element's DOM title value if available (defaults to false).
- */
- interceptTitles : false,
- // private
- tagConfig : {
- namespace : "ext",
- attribute : "qtip",
- width : "qwidth",
- target : "target",
- title : "qtitle",
- hide : "hide",
- cls : "qclass",
- align : "qalign",
- anchor : "anchor"
- },
- // private
- initComponent : function(){
- this.target = this.target || Ext.getDoc();
- this.targets = this.targets || {};
- Ext.QuickTip.superclass.initComponent.call(this);
- },
- /**
- * Configures a new quick tip instance and assigns it to a target element. The following config values are
- * supported (for example usage, see the {@link Ext.QuickTips} class header):
- * <div class="mdetail-params"><ul>
- * <li>autoHide</li>
- * <li>cls</li>
- * <li>dismissDelay (overrides the singleton value)</li>
- * <li>target (required)</li>
- * <li>text (required)</li>
- * <li>title</li>
- * <li>width</li></ul></div>
- * @param {Object} config The config object
- */
- register : function(config){
- var cs = Ext.isArray(config) ? config : arguments;
- for(var i = 0, len = cs.length; i < len; i++){
- var c = cs[i];
- var target = c.target;
- if(target){
- if(Ext.isArray(target)){
- for(var j = 0, jlen = target.length; j < jlen; j++){
- this.targets[Ext.id(target[j])] = c;
- }
- } else{
- this.targets[Ext.id(target)] = c;
- }
- }
- }
- },
- /**
- * Removes this quick tip from its element and destroys it.
- * @param {String/HTMLElement/Element} el The element from which the quick tip is to be removed.
- */
- unregister : function(el){
- delete this.targets[Ext.id(el)];
- },
- /**
- * Hides a visible tip or cancels an impending show for a particular element.
- * @param {String/HTMLElement/Element} el The element that is the target of the tip.
- */
- cancelShow: function(el){
- var at = this.activeTarget;
- el = Ext.get(el).dom;
- if(this.isVisible()){
- if(at && at.el == el){
- this.hide();
- }
- }else if(at && at.el == el){
- this.clearTimer('show');
- }
- },
- // private
- onTargetOver : function(e){
- if(this.disabled){
- return;
- }
- this.targetXY = e.getXY();
- var t = e.getTarget();
- if(!t || t.nodeType !== 1 || t == document || t == document.body){
- return;
- }
- if(this.activeTarget && t == this.activeTarget.el){
- this.clearTimer('hide');
- this.show();
- return;
- }
- if(t && this.targets[t.id]){
- this.activeTarget = this.targets[t.id];
- this.activeTarget.el = t;
- this.anchor = this.activeTarget.anchor;
- if(this.anchor){
- this.anchorTarget = t;
- }
- this.delayShow();
- return;
- }
- var ttp, et = Ext.fly(t), cfg = this.tagConfig;
- var ns = cfg.namespace;
- if(this.interceptTitles && t.title){
- ttp = t.title;
- t.qtip = ttp;
- t.removeAttribute("title");
- e.preventDefault();
- } else{
- ttp = t.qtip || et.getAttribute(cfg.attribute, ns);
- }
- if(ttp){
- var autoHide = et.getAttribute(cfg.hide, ns);
- this.activeTarget = {
- el: t,
- text: ttp,
- width: et.getAttribute(cfg.width, ns),
- autoHide: autoHide != "user" && autoHide !== 'false',
- title: et.getAttribute(cfg.title, ns),
- cls: et.getAttribute(cfg.cls, ns),
- align: et.getAttribute(cfg.align, ns)
- };
- this.anchor = et.getAttribute(cfg.anchor, ns);
- if(this.anchor){
- this.anchorTarget = t;
- }
- this.delayShow();
- }
- },
- // private
- onTargetOut : function(e){
- this.clearTimer('show');
- if(this.autoHide !== false){
- this.delayHide();
- }
- },
- // inherit docs
- showAt : function(xy){
- var t = this.activeTarget;
- if(t){
- if(!this.rendered){
- this.render(Ext.getBody());
- this.activeTarget = t;
- }
- if(t.width){
- this.setWidth(t.width);
- this.body.setWidth(this.adjustBodyWidth(t.width - this.getFrameWidth()));
- this.measureWidth = false;
- } else{
- this.measureWidth = true;
- }
- this.setTitle(t.title || '');
- this.body.update(t.text);
- this.autoHide = t.autoHide;
- this.dismissDelay = t.dismissDelay || this.dismissDelay;
- if(this.lastCls){
- this.el.removeClass(this.lastCls);
- delete this.lastCls;
- }
- if(t.cls){
- this.el.addClass(t.cls);
- this.lastCls = t.cls;
- }
- if(this.anchor){
- this.constrainPosition = false;
- }else if(t.align){ // TODO: this doesn't seem to work consistently
- xy = this.el.getAlignToXY(t.el, t.align);
- this.constrainPosition = false;
- }else{
- this.constrainPosition = true;
- }
- }
- Ext.QuickTip.superclass.showAt.call(this, xy);
- },
- // inherit docs
- hide: function(){
- delete this.activeTarget;
- Ext.QuickTip.superclass.hide.call(this);
- }
- });/**
- * @class Ext.QuickTips
- * <p>Provides attractive and customizable tooltips for any element. The QuickTips
- * singleton is used to configure and manage tooltips globally for multiple elements
- * in a generic manner. To create individual tooltips with maximum customizability,
- * you should consider either {@link Ext.Tip} or {@link Ext.ToolTip}.</p>
- * <p>Quicktips can be configured via tag attributes directly in markup, or by
- * registering quick tips programmatically via the {@link #register} method.</p>
- * <p>The singleton's instance of {@link Ext.QuickTip} is available via
- * {@link #getQuickTip}, and supports all the methods, and all the all the
- * configuration properties of Ext.QuickTip. These settings will apply to all
- * tooltips shown by the singleton.</p>
- * <p>Below is the summary of the configuration properties which can be used.
- * For detailed descriptions see {@link #getQuickTip}</p>
- * <p><b>QuickTips singleton configs (all are optional)</b></p>
- * <div class="mdetail-params"><ul><li>dismissDelay</li>
- * <li>hideDelay</li>
- * <li>maxWidth</li>
- * <li>minWidth</li>
- * <li>showDelay</li>
- * <li>trackMouse</li></ul></div>
- * <p><b>Target element configs (optional unless otherwise noted)</b></p>
- * <div class="mdetail-params"><ul><li>autoHide</li>
- * <li>cls</li>
- * <li>dismissDelay (overrides singleton value)</li>
- * <li>target (required)</li>
- * <li>text (required)</li>
- * <li>title</li>
- * <li>width</li></ul></div>
- * <p>Here is an example showing how some of these config options could be used:</p>
- * <pre><code>
- // Init the singleton. Any tag-based quick tips will start working.
- Ext.QuickTips.init();
- // Apply a set of config properties to the singleton
- Ext.apply(Ext.QuickTips.getQuickTip(), {
- maxWidth: 200,
- minWidth: 100,
- showDelay: 50,
- trackMouse: true
- });
- // Manually register a quick tip for a specific element
- Ext.QuickTips.register({
- target: 'my-div',
- title: 'My Tooltip',
- text: 'This tooltip was added in code',
- width: 100,
- dismissDelay: 20
- });
- </code></pre>
- * <p>To register a quick tip in markup, you simply add one or more of the valid QuickTip attributes prefixed with
- * the <b>ext:</b> namespace. The HTML element itself is automatically set as the quick tip target. Here is the summary
- * of supported attributes (optional unless otherwise noted):</p>
- * <ul><li><b>hide</b>: Specifying "user" is equivalent to setting autoHide = false. Any other value will be the
- * same as autoHide = true.</li>
- * <li><b>qclass</b>: A CSS class to be applied to the quick tip (equivalent to the 'cls' target element config).</li>
- * <li><b>qtip (required)</b>: The quick tip text (equivalent to the 'text' target element config).</li>
- * <li><b>qtitle</b>: The quick tip title (equivalent to the 'title' target element config).</li>
- * <li><b>qwidth</b>: The quick tip width (equivalent to the 'width' target element config).</li></ul>
- * <p>Here is an example of configuring an HTML element to display a tooltip from markup:</p>
- * <pre><code>
- // Add a quick tip to an HTML button
- <input type="button" value="OK" ext:qtitle="OK Button" ext:qwidth="100"
- ext:qtip="This is a quick tip from markup!"></input>
- </code></pre>
- * @singleton
- */
- Ext.QuickTips = function(){
- var tip, locks = [];
- return {
- /**
- * Initialize the global QuickTips instance and prepare any quick tips.
- * @param {Boolean} autoRender True to render the QuickTips container immediately to preload images. (Defaults to true)
- */
- init : function(autoRender){
- if(!tip){
- if(!Ext.isReady){
- Ext.onReady(function(){
- Ext.QuickTips.init(autoRender);
- });
- return;
- }
- tip = new Ext.QuickTip({elements:'header,body'});
- if(autoRender !== false){
- tip.render(Ext.getBody());
- }
- }
- },
- /**
- * Enable quick tips globally.
- */
- enable : function(){
- if(tip){
- locks.pop();
- if(locks.length < 1){
- tip.enable();
- }
- }
- },
- /**
- * Disable quick tips globally.
- */
- disable : function(){
- if(tip){
- tip.disable();
- }
- locks.push(1);
- },
- /**
- * Returns true if quick tips are enabled, else false.
- * @return {Boolean}
- */
- isEnabled : function(){
- return tip !== undefined && !tip.disabled;
- },
- /**
- * Gets the global QuickTips instance.
- */
- getQuickTip : function(){
- return tip;
- },
- /**
- * Configures a new quick tip instance and assigns it to a target element. See
- * {@link Ext.QuickTip#register} for details.
- * @param {Object} config The config object
- */
- register : function(){
- tip.register.apply(tip, arguments);
- },
- /**
- * Removes any registered quick tip from the target element and destroys it.
- * @param {String/HTMLElement/Element} el The element from which the quick tip is to be removed.
- */
- unregister : function(){
- tip.unregister.apply(tip, arguments);
- },
- /**
- * Alias of {@link #register}.
- * @param {Object} config The config object
- */
- tips :function(){
- tip.register.apply(tip, arguments);
- }
- }
- }();/**
- * @class Ext.tree.TreePanel
- * @extends Ext.Panel
- * <p>The TreePanel provides tree-structured UI representation of tree-structured data.</p>
- * <p>{@link Ext.tree.TreeNode TreeNode}s added to the TreePanel may each contain metadata
- * used by your application in their {@link Ext.tree.TreeNode#attributes attributes} property.</p>
- * <p><b>A TreePanel must have a {@link #root} node before it is rendered.</b> This may either be
- * specified using the {@link #root} config option, or using the {@link #setRootNode} method.
- * <p>An example of tree rendered to an existing div:</p><pre><code>
- var tree = new Ext.tree.TreePanel({
- renderTo: 'tree-div',
- useArrows: true,
- autoScroll: true,
- animate: true,
- enableDD: true,
- containerScroll: true,
- border: false,
- // auto create TreeLoader
- dataUrl: 'get-nodes.php',
- root: {
- nodeType: 'async',
- text: 'Ext JS',
- draggable: false,
- id: 'source'
- }
- });
- tree.getRootNode().expand();
- * </code></pre>
- * <p>The example above would work with a data packet similar to this:</p><pre><code>
- [{
- "text": "adapter",
- "id": "source/adapter",
- "cls": "folder"
- }, {
- "text": "dd",
- "id": "source/dd",
- "cls": "folder"
- }, {
- "text": "debug.js",
- "id": "source/debug.js",
- "leaf": true,
- "cls": "file"
- }]
- * </code></pre>
- * <p>An example of tree within a Viewport:</p><pre><code>
- new Ext.Viewport({
- layout: 'border',
- items: [{
- region: 'west',
- collapsible: true,
- title: 'Navigation',
- xtype: 'treepanel',
- width: 200,
- autoScroll: true,
- split: true,
- loader: new Ext.tree.TreeLoader(),
- root: new Ext.tree.AsyncTreeNode({
- expanded: true,
- children: [{
- text: 'Menu Option 1',
- leaf: true
- }, {
- text: 'Menu Option 2',
- leaf: true
- }, {
- text: 'Menu Option 3',
- leaf: true
- }]
- }),
- rootVisible: false,
- listeners: {
- click: function(n) {
- Ext.Msg.alert('Navigation Tree Click', 'You clicked: "' + n.attributes.text + '"');
- }
- }
- }, {
- region: 'center',
- xtype: 'tabpanel',
- // remaining code not shown ...
- }]
- });
- </code></pre>
- *
- * @cfg {Ext.tree.TreeNode} root The root node for the tree.
- * @cfg {Boolean} rootVisible <tt>false</tt> to hide the root node (defaults to <tt>true</tt>)
- * @cfg {Boolean} lines <tt>false</tt> to disable tree lines (defaults to <tt>true</tt>)
- * @cfg {Boolean} enableDD <tt>true</tt> to enable drag and drop
- * @cfg {Boolean} enableDrag <tt>true</tt> to enable just drag
- * @cfg {Boolean} enableDrop <tt>true</tt> to enable just drop
- * @cfg {Object} dragConfig Custom config to pass to the {@link Ext.tree.TreeDragZone} instance
- * @cfg {Object} dropConfig Custom config to pass to the {@link Ext.tree.TreeDropZone} instance
- * @cfg {String} ddGroup The DD group this TreePanel belongs to
- * @cfg {Boolean} ddAppendOnly <tt>true</tt> if the tree should only allow append drops (use for trees which are sorted)
- * @cfg {Boolean} ddScroll <tt>true</tt> to enable body scrolling
- * @cfg {Boolean} containerScroll <tt>true</tt> to register this container with ScrollManager
- * @cfg {Boolean} hlDrop <tt>false</tt> to disable node highlight on drop (defaults to the value of {@link Ext#enableFx})
- * @cfg {String} hlColor The color of the node highlight (defaults to <tt>'C3DAF9'</tt>)
- * @cfg {Boolean} animate <tt>true</tt> to enable animated expand/collapse (defaults to the value of {@link Ext#enableFx})
- * @cfg {Boolean} singleExpand <tt>true</tt> if only 1 node per branch may be expanded
- * @cfg {Object} selModel A tree selection model to use with this TreePanel (defaults to an {@link Ext.tree.DefaultSelectionModel})
- * @cfg {Boolean} trackMouseOver <tt>false</tt> to disable mouse over highlighting
- * @cfg {Ext.tree.TreeLoader} loader A {@link Ext.tree.TreeLoader} for use with this TreePanel
- * @cfg {String} pathSeparator The token used to separate sub-paths in path strings (defaults to <tt>'/'</tt>)
- * @cfg {Boolean} useArrows <tt>true</tt> to use Vista-style arrows in the tree (defaults to <tt>false</tt>)
- * @cfg {String} requestMethod The HTTP request method for loading data (defaults to the value of {@link Ext.Ajax#method}).
- *
- * @constructor
- * @param {Object} config
- * @xtype treepanel
- */
- Ext.tree.TreePanel = Ext.extend(Ext.Panel, {
- rootVisible : true,
- animate: Ext.enableFx,
- lines : true,
- enableDD : false,
- hlDrop : Ext.enableFx,
- pathSeparator: "/",
- initComponent : function(){
- Ext.tree.TreePanel.superclass.initComponent.call(this);
- if(!this.eventModel){
- this.eventModel = new Ext.tree.TreeEventModel(this);
- }
- // initialize the loader
- var l = this.loader;
- if(!l){
- l = new Ext.tree.TreeLoader({
- dataUrl: this.dataUrl,
- requestMethod: this.requestMethod
- });
- }else if(typeof l == 'object' && !l.load){
- l = new Ext.tree.TreeLoader(l);
- }
- this.loader = l;
- this.nodeHash = {};
- /**
- * The root node of this tree.
- * @type Ext.tree.TreeNode
- * @property root
- */
- if(this.root){
- var r = this.root;
- delete this.root;
- this.setRootNode(r);
- }
- this.addEvents(
- /**
- * @event append
- * Fires when a new child node is appended to a node in this tree.
- * @param {Tree} tree The owner tree
- * @param {Node} parent The parent node
- * @param {Node} node The newly appended node
- * @param {Number} index The index of the newly appended node
- */
- "append",
- /**
- * @event remove
- * Fires when a child node is removed from a node in this tree.
- * @param {Tree} tree The owner tree
- * @param {Node} parent The parent node
- * @param {Node} node The child node removed
- */
- "remove",
- /**
- * @event movenode
- * Fires when a node is moved to a new location in the tree
- * @param {Tree} tree The owner tree
- * @param {Node} node The node moved
- * @param {Node} oldParent The old parent of this node
- * @param {Node} newParent The new parent of this node
- * @param {Number} index The index it was moved to
- */
- "movenode",
- /**
- * @event insert
- * Fires when a new child node is inserted in a node in this tree.
- * @param {Tree} tree The owner tree
- * @param {Node} parent The parent node
- * @param {Node} node The child node inserted
- * @param {Node} refNode The child node the node was inserted before
- */
- "insert",
- /**
- * @event beforeappend
- * Fires before a new child is appended to a node in this tree, return false to cancel the append.
- * @param {Tree} tree The owner tree
- * @param {Node} parent The parent node
- * @param {Node} node The child node to be appended
- */
- "beforeappend",
- /**
- * @event beforeremove
- * Fires before a child is removed from a node in this tree, return false to cancel the remove.
- * @param {Tree} tree The owner tree
- * @param {Node} parent The parent node
- * @param {Node} node The child node to be removed
- */
- "beforeremove",
- /**
- * @event beforemovenode
- * Fires before a node is moved to a new location in the tree. Return false to cancel the move.
- * @param {Tree} tree The owner tree
- * @param {Node} node The node being moved
- * @param {Node} oldParent The parent of the node
- * @param {Node} newParent The new parent the node is moving to
- * @param {Number} index The index it is being moved to
- */
- "beforemovenode",
- /**
- * @event beforeinsert
- * Fires before a new child is inserted in a node in this tree, return false to cancel the insert.
- * @param {Tree} tree The owner tree
- * @param {Node} parent The parent node
- * @param {Node} node The child node to be inserted
- * @param {Node} refNode The child node the node is being inserted before
- */
- "beforeinsert",
- /**
- * @event beforeload
- * Fires before a node is loaded, return false to cancel
- * @param {Node} node The node being loaded
- */
- "beforeload",
- /**
- * @event load
- * Fires when a node is loaded
- * @param {Node} node The node that was loaded
- */
- "load",
- /**
- * @event textchange
- * Fires when the text for a node is changed
- * @param {Node} node The node
- * @param {String} text The new text
- * @param {String} oldText The old text
- */
- "textchange",
- /**
- * @event beforeexpandnode
- * Fires before a node is expanded, return false to cancel.
- * @param {Node} node The node
- * @param {Boolean} deep
- * @param {Boolean} anim
- */
- "beforeexpandnode",
- /**
- * @event beforecollapsenode
- * Fires before a node is collapsed, return false to cancel.
- * @param {Node} node The node
- * @param {Boolean} deep
- * @param {Boolean} anim
- */
- "beforecollapsenode",
- /**
- * @event expandnode
- * Fires when a node is expanded
- * @param {Node} node The node
- */
- "expandnode",
- /**
- * @event disabledchange
- * Fires when the disabled status of a node changes
- * @param {Node} node The node
- * @param {Boolean} disabled
- */
- "disabledchange",
- /**
- * @event collapsenode
- * Fires when a node is collapsed
- * @param {Node} node The node
- */
- "collapsenode",
- /**
- * @event beforeclick
- * Fires before click processing on a node. Return false to cancel the default action.
- * @param {Node} node The node
- * @param {Ext.EventObject} e The event object
- */
- "beforeclick",
- /**
- * @event click
- * Fires when a node is clicked
- * @param {Node} node The node
- * @param {Ext.EventObject} e The event object
- */
- "click",
- /**
- * @event checkchange
- * Fires when a node with a checkbox's checked property changes
- * @param {Node} this This node
- * @param {Boolean} checked
- */
- "checkchange",
- /**
- * @event dblclick
- * Fires when a node is double clicked
- * @param {Node} node The node
- * @param {Ext.EventObject} e The event object
- */
- "dblclick",
- /**
- * @event contextmenu
- * Fires when a node is right clicked. To display a context menu in response to this
- * event, first create a Menu object (see {@link Ext.menu.Menu} for details), then add
- * a handler for this event:<pre><code>
- new Ext.tree.TreePanel({
- title: 'My TreePanel',
- root: new Ext.tree.AsyncTreeNode({
- text: 'The Root',
- children: [
- { text: 'Child node 1', leaf: true },
- { text: 'Child node 2', leaf: true }
- ]
- }),
- contextMenu: new Ext.menu.Menu({
- items: [{
- id: 'delete-node',
- text: 'Delete Node'
- }],
- listeners: {
- itemclick: function(item) {
- switch (item.id) {
- case 'delete-node':
- var n = item.parentMenu.contextNode;
- if (n.parentNode) {
- n.remove();
- }
- break;
- }
- }
- }
- }),
- listeners: {
- contextmenu: function(node, e) {
- // Register the context node with the menu so that a Menu Item's handler function can access
- // it via its {@link Ext.menu.BaseItem#parentMenu parentMenu} property.
- node.select();
- var c = node.getOwnerTree().contextMenu;
- c.contextNode = node;
- c.showAt(e.getXY());
- }
- }
- });
- </code></pre>
- * @param {Node} node The node
- * @param {Ext.EventObject} e The event object
- */
- "contextmenu",
- /**
- * @event beforechildrenrendered
- * Fires right before the child nodes for a node are rendered
- * @param {Node} node The node
- */
- "beforechildrenrendered",
- /**
- * @event startdrag
- * Fires when a node starts being dragged
- * @param {Ext.tree.TreePanel} this
- * @param {Ext.tree.TreeNode} node
- * @param {event} e The raw browser event
- */
- "startdrag",
- /**
- * @event enddrag
- * Fires when a drag operation is complete
- * @param {Ext.tree.TreePanel} this
- * @param {Ext.tree.TreeNode} node
- * @param {event} e The raw browser event
- */
- "enddrag",
- /**
- * @event dragdrop
- * Fires when a dragged node is dropped on a valid DD target
- * @param {Ext.tree.TreePanel} this
- * @param {Ext.tree.TreeNode} node
- * @param {DD} dd The dd it was dropped on
- * @param {event} e The raw browser event
- */
- "dragdrop",
- /**
- * @event beforenodedrop
- * Fires when a DD object is dropped on a node in this tree for preprocessing. Return false to cancel the drop. The dropEvent
- * passed to handlers has the following properties:<br />
- * <ul style="padding:5px;padding-left:16px;">
- * <li>tree - The TreePanel</li>
- * <li>target - The node being targeted for the drop</li>
- * <li>data - The drag data from the drag source</li>
- * <li>point - The point of the drop - append, above or below</li>
- * <li>source - The drag source</li>
- * <li>rawEvent - Raw mouse event</li>
- * <li>dropNode - Drop node(s) provided by the source <b>OR</b> you can supply node(s)
- * to be inserted by setting them on this object.</li>
- * <li>cancel - Set this to true to cancel the drop.</li>
- * <li>dropStatus - If the default drop action is cancelled but the drop is valid, setting this to true
- * will prevent the animated "repair" from appearing.</li>
- * </ul>
- * @param {Object} dropEvent
- */
- "beforenodedrop",
- /**
- * @event nodedrop
- * Fires after a DD object is dropped on a node in this tree. The dropEvent
- * passed to handlers has the following properties:<br />
- * <ul style="padding:5px;padding-left:16px;">
- * <li>tree - The TreePanel</li>
- * <li>target - The node being targeted for the drop</li>
- * <li>data - The drag data from the drag source</li>
- * <li>point - The point of the drop - append, above or below</li>
- * <li>source - The drag source</li>
- * <li>rawEvent - Raw mouse event</li>
- * <li>dropNode - Dropped node(s).</li>
- * </ul>
- * @param {Object} dropEvent
- */
- "nodedrop",
- /**
- * @event nodedragover
- * Fires when a tree node is being targeted for a drag drop, return false to signal drop not allowed. The dragOverEvent
- * passed to handlers has the following properties:<br />
- * <ul style="padding:5px;padding-left:16px;">
- * <li>tree - The TreePanel</li>
- * <li>target - The node being targeted for the drop</li>
- * <li>data - The drag data from the drag source</li>
- * <li>point - The point of the drop - append, above or below</li>
- * <li>source - The drag source</li>
- * <li>rawEvent - Raw mouse event</li>
- * <li>dropNode - Drop node(s) provided by the source.</li>
- * <li>cancel - Set this to true to signal drop not allowed.</li>
- * </ul>
- * @param {Object} dragOverEvent
- */
- "nodedragover"
- );
- if(this.singleExpand){
- this.on("beforeexpandnode", this.restrictExpand, this);
- }
- },
- // private
- proxyNodeEvent : function(ename, a1, a2, a3, a4, a5, a6){
- if(ename == 'collapse' || ename == 'expand' || ename == 'beforecollapse' || ename == 'beforeexpand' || ename == 'move' || ename == 'beforemove'){
- ename = ename+'node';
- }
- // args inline for performance while bubbling events
- return this.fireEvent(ename, a1, a2, a3, a4, a5, a6);
- },
- /**
- * Returns this root node for this tree
- * @return {Node}
- */
- getRootNode : function(){
- return this.root;
- },
- /**
- * Sets the root node for this tree. If the TreePanel has already rendered a root node, the
- * previous root node (and all of its descendants) are destroyed before the new root node is rendered.
- * @param {Node} node
- * @return {Node}
- */
- setRootNode : function(node){
- Ext.destroy(this.root);
- if(!node.render){ // attributes passed
- node = this.loader.createNode(node);
- }
- this.root = node;
- node.ownerTree = this;
- node.isRoot = true;
- this.registerNode(node);
- if(!this.rootVisible){
- var uiP = node.attributes.uiProvider;
- node.ui = uiP ? new uiP(node) : new Ext.tree.RootTreeNodeUI(node);
- }
- if (this.innerCt) {
- this.innerCt.update('');
- this.afterRender();
- }
- return node;
- },
- /**
- * Gets a node in this tree by its id
- * @param {String} id
- * @return {Node}
- */
- getNodeById : function(id){
- return this.nodeHash[id];
- },
- // private
- registerNode : function(node){
- this.nodeHash[node.id] = node;
- },
- // private
- unregisterNode : function(node){
- delete this.nodeHash[node.id];
- },
- // private
- toString : function(){
- return "[Tree"+(this.id?" "+this.id:"")+"]";
- },
- // private
- restrictExpand : function(node){
- var p = node.parentNode;
- if(p){
- if(p.expandedChild && p.expandedChild.parentNode == p){
- p.expandedChild.collapse();
- }
- p.expandedChild = node;
- }
- },
- /**
- * Retrieve an array of checked nodes, or an array of a specific attribute of checked nodes (e.g. "id")
- * @param {String} attribute (optional) Defaults to null (return the actual nodes)
- * @param {TreeNode} startNode (optional) The node to start from, defaults to the root
- * @return {Array}
- */
- getChecked : function(a, startNode){
- startNode = startNode || this.root;
- var r = [];
- var f = function(){
- if(this.attributes.checked){
- r.push(!a ? this : (a == 'id' ? this.id : this.attributes[a]));
- }
- };
- startNode.cascade(f);
- return r;
- },
- /**
- * Returns the container element for this TreePanel.
- * @return {Element} The container element for this TreePanel.
- */
- getEl : function(){
- return this.el;
- },
- /**
- * Returns the default {@link Ext.tree.TreeLoader} for this TreePanel.
- * @return {Ext.tree.TreeLoader} The TreeLoader for this TreePanel.
- */
- getLoader : function(){
- return this.loader;
- },
- /**
- * Expand all nodes
- */
- expandAll : function(){
- this.root.expand(true);
- },
- /**
- * Collapse all nodes
- */
- collapseAll : function(){
- this.root.collapse(true);
- },
- /**
- * Returns the selection model used by this TreePanel.
- * @return {TreeSelectionModel} The selection model used by this TreePanel
- */
- getSelectionModel : function(){
- if(!this.selModel){
- this.selModel = new Ext.tree.DefaultSelectionModel();
- }
- return this.selModel;
- },
- /**
- * Expands a specified path in this TreePanel. A path can be retrieved from a node with {@link Ext.data.Node#getPath}
- * @param {String} path
- * @param {String} attr (optional) The attribute used in the path (see {@link Ext.data.Node#getPath} for more info)
- * @param {Function} callback (optional) The callback to call when the expand is complete. The callback will be called with
- * (bSuccess, oLastNode) where bSuccess is if the expand was successful and oLastNode is the last node that was expanded.
- */
- expandPath : function(path, attr, callback){
- attr = attr || "id";
- var keys = path.split(this.pathSeparator);
- var curNode = this.root;
- if(curNode.attributes[attr] != keys[1]){ // invalid root
- if(callback){
- callback(false, null);
- }
- return;
- }
- var index = 1;
- var f = function(){
- if(++index == keys.length){
- if(callback){
- callback(true, curNode);
- }
- return;
- }
- var c = curNode.findChild(attr, keys[index]);
- if(!c){
- if(callback){
- callback(false, curNode);
- }
- return;
- }
- curNode = c;
- c.expand(false, false, f);
- };
- curNode.expand(false, false, f);
- },
- /**
- * Selects the node in this tree at the specified path. A path can be retrieved from a node with {@link Ext.data.Node#getPath}
- * @param {String} path
- * @param {String} attr (optional) The attribute used in the path (see {@link Ext.data.Node#getPath} for more info)
- * @param {Function} callback (optional) The callback to call when the selection is complete. The callback will be called with
- * (bSuccess, oSelNode) where bSuccess is if the selection was successful and oSelNode is the selected node.
- */
- selectPath : function(path, attr, callback){
- attr = attr || "id";
- var keys = path.split(this.pathSeparator);
- var v = keys.pop();
- if(keys.length > 0){
- var f = function(success, node){
- if(success && node){
- var n = node.findChild(attr, v);
- if(n){
- n.select();
- if(callback){
- callback(true, n);
- }
- }else if(callback){
- callback(false, n);
- }
- }else{
- if(callback){
- callback(false, n);
- }
- }
- };
- this.expandPath(keys.join(this.pathSeparator), attr, f);
- }else{
- this.root.select();
- if(callback){
- callback(true, this.root);
- }
- }
- },
- /**
- * Returns the underlying Element for this tree
- * @return {Ext.Element} The Element
- */
- getTreeEl : function(){
- return this.body;
- },
- // private
- onRender : function(ct, position){
- Ext.tree.TreePanel.superclass.onRender.call(this, ct, position);
- this.el.addClass('x-tree');
- this.innerCt = this.body.createChild({tag:"ul",
- cls:"x-tree-root-ct " +
- (this.useArrows ? 'x-tree-arrows' : this.lines ? "x-tree-lines" : "x-tree-no-lines")});
- },
- // private
- initEvents : function(){
- Ext.tree.TreePanel.superclass.initEvents.call(this);
- if(this.containerScroll){
- Ext.dd.ScrollManager.register(this.body);
- }
- if((this.enableDD || this.enableDrop) && !this.dropZone){
- /**
- * The dropZone used by this tree if drop is enabled (see {@link #enableDD} or {@link #enableDrop})
- * @property dropZone
- * @type Ext.tree.TreeDropZone
- */
- this.dropZone = new Ext.tree.TreeDropZone(this, this.dropConfig || {
- ddGroup: this.ddGroup || "TreeDD", appendOnly: this.ddAppendOnly === true
- });
- }
- if((this.enableDD || this.enableDrag) && !this.dragZone){
- /**
- * The dragZone used by this tree if drag is enabled (see {@link #enableDD} or {@link #enableDrag})
- * @property dragZone
- * @type Ext.tree.TreeDragZone
- */
- this.dragZone = new Ext.tree.TreeDragZone(this, this.dragConfig || {
- ddGroup: this.ddGroup || "TreeDD",
- scroll: this.ddScroll
- });
- }
- this.getSelectionModel().init(this);
- },
- // private
- afterRender : function(){
- Ext.tree.TreePanel.superclass.afterRender.call(this);
- this.root.render();
- if(!this.rootVisible){
- this.root.renderChildren();
- }
- },
- onDestroy : function(){
- if(this.rendered){
- this.body.removeAllListeners();
- Ext.dd.ScrollManager.unregister(this.body);
- if(this.dropZone){
- this.dropZone.unreg();
- }
- if(this.dragZone){
- this.dragZone.unreg();
- }
- }
- this.root.destroy();
- this.nodeHash = null;
- Ext.tree.TreePanel.superclass.onDestroy.call(this);
- }
- /**
- * @cfg {String/Number} activeItem
- * @hide
- */
- /**
- * @cfg {Boolean} autoDestroy
- * @hide
- */
- /**
- * @cfg {Object/String/Function} autoLoad
- * @hide
- */
- /**
- * @cfg {Boolean} autoWidth
- * @hide
- */
- /**
- * @cfg {Boolean/Number} bufferResize
- * @hide
- */
- /**
- * @cfg {String} defaultType
- * @hide
- */
- /**
- * @cfg {Object} defaults
- * @hide
- */
- /**
- * @cfg {Boolean} hideBorders
- * @hide
- */
- /**
- * @cfg {Mixed} items
- * @hide
- */
- /**
- * @cfg {String} layout
- * @hide
- */
- /**
- * @cfg {Object} layoutConfig
- * @hide
- */
- /**
- * @cfg {Boolean} monitorResize
- * @hide
- */
- /**
- * @property items
- * @hide
- */
- /**
- * @method cascade
- * @hide
- */
- /**
- * @method doLayout
- * @hide
- */
- /**
- * @method find
- * @hide
- */
- /**
- * @method findBy
- * @hide
- */
- /**
- * @method findById
- * @hide
- */
- /**
- * @method findByType
- * @hide
- */
- /**
- * @method getComponent
- * @hide
- */
- /**
- * @method getLayout
- * @hide
- */
- /**
- * @method getUpdater
- * @hide
- */
- /**
- * @method insert
- * @hide
- */
- /**
- * @method load
- * @hide
- */
- /**
- * @method remove
- * @hide
- */
- /**
- * @event add
- * @hide
- */
- /**
- * @method removeAll
- * @hide
- */
- /**
- * @event afterLayout
- * @hide
- */
- /**
- * @event beforeadd
- * @hide
- */
- /**
- * @event beforeremove
- * @hide
- */
- /**
- * @event remove
- * @hide
- */
- /**
- * @cfg {String} allowDomMove @hide
- */
- /**
- * @cfg {String} autoEl @hide
- */
- /**
- * @cfg {String} applyTo @hide
- */
- /**
- * @cfg {String} contentEl @hide
- */
- /**
- * @cfg {String} disabledClass @hide
- */
- /**
- * @cfg {String} elements @hide
- */
- /**
- * @cfg {String} html @hide
- */
- /**
- * @cfg {Boolean} preventBodyReset
- * @hide
- */
- /**
- * @property disabled
- * @hide
- */
- /**
- * @method applyToMarkup
- * @hide
- */
- /**
- * @method enable
- * @hide
- */
- /**
- * @method disable
- * @hide
- */
- /**
- * @method setDisabled
- * @hide
- */
- });
- Ext.tree.TreePanel.nodeTypes = {};
- Ext.reg('treepanel', Ext.tree.TreePanel);Ext.tree.TreeEventModel = function(tree){
- this.tree = tree;
- this.tree.on('render', this.initEvents, this);