ext-all-debug.js
资源名称:EXT_study.rar [点击查看]
上传用户:zaktkj
上传日期:2022-08-08
资源大小:5770k
文件大小:910k
源码类别:
JavaScript
开发平台:
JavaScript
- if(this.hideEl !== false){
- this.boundEl.show();
- }
- },
- setValue : function(v){
- this.field.setValue(v);
- },
- getValue : function(){
- return this.field.getValue();
- },
- beforeDestroy : function(){
- this.field.destroy();
- this.field = null;
- }
- });
- Ext.reg('editor', Ext.Editor);
- Ext.MessageBox = function(){
- var dlg, opt, mask, waitTimer;
- var bodyEl, msgEl, textboxEl, textareaEl, progressBar, pp, iconEl, spacerEl;
- var buttons, activeTextEl, bwidth, iconCls = '';
- var handleButton = function(button){
- dlg.hide();
- Ext.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
- };
- var handleHide = function(){
- if(opt && opt.cls){
- dlg.el.removeClass(opt.cls);
- }
- progressBar.reset();
- };
- var handleEsc = function(d, k, e){
- if(opt && opt.closable !== false){
- dlg.hide();
- }
- if(e){
- e.stopEvent();
- }
- };
- var updateButtons = function(b){
- var width = 0;
- if(!b){
- buttons["ok"].hide();
- buttons["cancel"].hide();
- buttons["yes"].hide();
- buttons["no"].hide();
- return width;
- }
- dlg.footer.dom.style.display = '';
- for(var k in buttons){
- if(typeof buttons[k] != "function"){
- if(b[k]){
- buttons[k].show();
- buttons[k].setText(typeof b[k] == "string" ? b[k] : Ext.MessageBox.buttonText[k]);
- width += buttons[k].el.getWidth()+15;
- }else{
- buttons[k].hide();
- }
- }
- }
- return width;
- };
- return {
- getDialog : function(titleText){
- if(!dlg){
- dlg = new Ext.Window({
- autoCreate : true,
- title:titleText,
- resizable:false,
- constrain:true,
- constrainHeader:true,
- minimizable : false,
- maximizable : false,
- stateful: false,
- modal: true,
- shim:true,
- buttonAlign:"center",
- width:400,
- height:100,
- minHeight: 80,
- plain:true,
- footer:true,
- closable:true,
- close : function(){
- if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
- handleButton("no");
- }else{
- handleButton("cancel");
- }
- }
- });
- buttons = {};
- var bt = this.buttonText;
- buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
- buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
- buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
- buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
- buttons["ok"].hideMode = buttons["yes"].hideMode = buttons["no"].hideMode = buttons["cancel"].hideMode = 'offsets';
- dlg.render(document.body);
- dlg.getEl().addClass('x-window-dlg');
- mask = dlg.mask;
- bodyEl = dlg.body.createChild({
- html:'<div class="ext-mb-icon"></div><div class="ext-mb-content"><span class="ext-mb-text"></span><br /><input type="text" class="ext-mb-input" /><textarea class="ext-mb-textarea"></textarea></div>'
- });
- iconEl = Ext.get(bodyEl.dom.firstChild);
- var contentEl = bodyEl.dom.childNodes[1];
- msgEl = Ext.get(contentEl.firstChild);
- textboxEl = Ext.get(contentEl.childNodes[2]);
- textboxEl.enableDisplayMode();
- textboxEl.addKeyListener([10,13], function(){
- if(dlg.isVisible() && opt && opt.buttons){
- if(opt.buttons.ok){
- handleButton("ok");
- }else if(opt.buttons.yes){
- handleButton("yes");
- }
- }
- });
- textareaEl = Ext.get(contentEl.childNodes[3]);
- textareaEl.enableDisplayMode();
- progressBar = new Ext.ProgressBar({
- renderTo:bodyEl
- });
- bodyEl.createChild({cls:'x-clear'});
- }
- return dlg;
- },
- updateText : function(text){
- if(!dlg.isVisible() && !opt.width){
- dlg.setSize(this.maxWidth, 100);
- }
- msgEl.update(text || ' ');
- var iw = iconCls != '' ? (iconEl.getWidth() + iconEl.getMargins('lr')) : 0;
- var mw = msgEl.getWidth() + msgEl.getMargins('lr');
- var fw = dlg.getFrameWidth('lr');
- var bw = dlg.body.getFrameWidth('lr');
- if (Ext.isIE && iw > 0){
- iw += 3;
- }
- var w = Math.max(Math.min(opt.width || iw+mw+fw+bw, this.maxWidth),
- Math.max(opt.minWidth || this.minWidth, bwidth || 0));
- if(opt.prompt === true){
- activeTextEl.setWidth(w-iw-fw-bw);
- }
- if(opt.progress === true || opt.wait === true){
- progressBar.setSize(w-iw-fw-bw);
- }
- dlg.setSize(w, 'auto').center();
- return this;
- },
- updateProgress : function(value, progressText, msg){
- progressBar.updateProgress(value, progressText);
- if(msg){
- this.updateText(msg);
- }
- return this;
- },
- isVisible : function(){
- return dlg && dlg.isVisible();
- },
- hide : function(){
- if(this.isVisible()){
- dlg.hide();
- handleHide();
- }
- return this;
- },
- show : function(options){
- if(this.isVisible()){
- this.hide();
- }
- opt = options;
- var d = this.getDialog(opt.title || " ");
- d.setTitle(opt.title || " ");
- var allowClose = (opt.closable !== false && opt.progress !== true && opt.wait !== true);
- d.tools.close.setDisplayed(allowClose);
- activeTextEl = textboxEl;
- opt.prompt = opt.prompt || (opt.multiline ? true : false);
- if(opt.prompt){
- if(opt.multiline){
- textboxEl.hide();
- textareaEl.show();
- textareaEl.setHeight(typeof opt.multiline == "number" ?
- opt.multiline : this.defaultTextHeight);
- activeTextEl = textareaEl;
- }else{
- textboxEl.show();
- textareaEl.hide();
- }
- }else{
- textboxEl.hide();
- textareaEl.hide();
- }
- activeTextEl.dom.value = opt.value || "";
- if(opt.prompt){
- d.focusEl = activeTextEl;
- }else{
- var bs = opt.buttons;
- var db = null;
- if(bs && bs.ok){
- db = buttons["ok"];
- }else if(bs && bs.yes){
- db = buttons["yes"];
- }
- if (db){
- d.focusEl = db;
- }
- }
- this.setIcon(opt.icon);
- bwidth = updateButtons(opt.buttons);
- progressBar.setVisible(opt.progress === true || opt.wait === true);
- this.updateProgress(0, opt.progressText);
- this.updateText(opt.msg);
- if(opt.cls){
- d.el.addClass(opt.cls);
- }
- d.proxyDrag = opt.proxyDrag === true;
- d.modal = opt.modal !== false;
- d.mask = opt.modal !== false ? mask : false;
- if(!d.isVisible()){
- document.body.appendChild(dlg.el.dom);
- d.setAnimateTarget(opt.animEl);
- d.show(opt.animEl);
- }
- d.on('show', function(){
- if(allowClose === true){
- d.keyMap.enable();
- }else{
- d.keyMap.disable();
- }
- }, this, {single:true});
- if(opt.wait === true){
- progressBar.wait(opt.waitConfig);
- }
- return this;
- },
- setIcon : function(icon){
- if(icon && icon != ''){
- iconEl.removeClass('x-hidden');
- iconEl.replaceClass(iconCls, icon);
- iconCls = icon;
- }else{
- iconEl.replaceClass(iconCls, 'x-hidden');
- iconCls = '';
- }
- return this;
- },
- progress : function(title, msg, progressText){
- this.show({
- title : title,
- msg : msg,
- buttons: false,
- progress:true,
- closable:false,
- minWidth: this.minProgressWidth,
- progressText: progressText
- });
- return this;
- },
- wait : function(msg, title, config){
- this.show({
- title : title,
- msg : msg,
- buttons: false,
- closable:false,
- wait:true,
- modal:true,
- minWidth: this.minProgressWidth,
- waitConfig: config
- });
- return this;
- },
- alert : function(title, msg, fn, scope){
- this.show({
- title : title,
- msg : msg,
- buttons: this.OK,
- fn: fn,
- scope : scope
- });
- return this;
- },
- confirm : function(title, msg, fn, scope){
- this.show({
- title : title,
- msg : msg,
- buttons: this.YESNO,
- fn: fn,
- scope : scope,
- icon: this.QUESTION
- });
- return this;
- },
- prompt : function(title, msg, fn, scope, multiline){
- this.show({
- title : title,
- msg : msg,
- buttons: this.OKCANCEL,
- fn: fn,
- minWidth:250,
- scope : scope,
- prompt:true,
- multiline: multiline
- });
- return this;
- },
- OK : {ok:true},
- CANCEL : {cancel:true},
- OKCANCEL : {ok:true, cancel:true},
- YESNO : {yes:true, no:true},
- YESNOCANCEL : {yes:true, no:true, cancel:true},
- INFO : 'ext-mb-info',
- WARNING : 'ext-mb-warning',
- QUESTION : 'ext-mb-question',
- ERROR : 'ext-mb-error',
- defaultTextHeight : 75,
- maxWidth : 600,
- minWidth : 100,
- minProgressWidth : 250,
- buttonText : {
- ok : "OK",
- cancel : "Cancel",
- yes : "Yes",
- no : "No"
- }
- };
- }();
- Ext.Msg = Ext.MessageBox;
- Ext.Tip = Ext.extend(Ext.Panel, {
- minWidth : 40,
- maxWidth : 300,
- shadow : "sides",
- defaultAlign : "tl-bl?",
- autoRender: true,
- quickShowInterval : 250,
- frame:true,
- hidden:true,
- baseCls: 'x-tip',
- floating:{shadow:true,shim:true,useDisplay:true,constrain:false},
- autoHeight:true,
- initComponent : function(){
- Ext.Tip.superclass.initComponent.call(this);
- if(this.closable && !this.title){
- this.elements += ',header';
- }
- },
- afterRender : function(){
- Ext.Tip.superclass.afterRender.call(this);
- if(this.closable){
- this.addTool({
- id: 'close',
- handler: this.hide,
- scope: this
- });
- }
- },
- showAt : function(xy){
- Ext.Tip.superclass.show.call(this);
- if(this.measureWidth !== false && (!this.initialConfig || typeof this.initialConfig.width != 'number')){
- var bw = this.body.getTextWidth();
- if(this.title){
- bw = Math.max(bw, this.header.child('span').getTextWidth(this.title));
- }
- bw += this.getFrameWidth() + (this.closable ? 20 : 0) + this.body.getPadding("lr");
- this.setWidth(bw.constrain(this.minWidth, this.maxWidth));
- }
- if(this.constrainPosition){
- xy = this.el.adjustForConstraints(xy);
- }
- this.setPagePosition(xy[0], xy[1]);
- },
- showBy : function(el, pos){
- if(!this.rendered){
- this.render(Ext.getBody());
- }
- this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign));
- },
- initDraggable : function(){
- this.dd = new Ext.Tip.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);
- this.header.addClass('x-tip-draggable');
- }
- });
- Ext.Tip.DD = function(tip, config){
- Ext.apply(this, config);
- this.tip = tip;
- Ext.Tip.DD.superclass.constructor.call(this, tip.el.id, 'WindowDD-'+tip.id);
- this.setHandleElId(tip.header.id);
- this.scroll = false;
- };
- Ext.extend(Ext.Tip.DD, Ext.dd.DD, {
- moveOnly:true,
- scroll:false,
- headerOffsets:[100, 25],
- startDrag : function(){
- this.tip.el.disableShadow();
- },
- endDrag : function(e){
- this.tip.el.enableShadow(true);
- }
- });
- Ext.ToolTip = Ext.extend(Ext.Tip, {
- showDelay: 500,
- hideDelay: 200,
- dismissDelay: 5000,
- mouseOffset: [15,18],
- trackMouse : false,
- constrainPosition: true,
- initComponent: function(){
- Ext.ToolTip.superclass.initComponent.call(this);
- this.lastActive = new Date();
- this.initTarget();
- },
- initTarget : function(){
- if(this.target){
- this.target = Ext.get(this.target);
- this.target.on('mouseover', this.onTargetOver, this);
- this.target.on('mouseout', this.onTargetOut, this);
- this.target.on('mousemove', this.onMouseMove, this);
- }
- },
- onMouseMove : function(e){
- this.targetXY = e.getXY();
- if(!this.hidden && this.trackMouse){
- this.setPagePosition(this.getTargetXY());
- }
- },
- getTargetXY : function(){
- return [this.targetXY[0]+this.mouseOffset[0], this.targetXY[1]+this.mouseOffset[1]];
- },
- onTargetOver : function(e){
- if(this.disabled || e.within(this.target.dom, true)){
- return;
- }
- this.clearTimer('hide');
- this.targetXY = e.getXY();
- this.delayShow();
- },
- 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();
- }
- },
- onTargetOut : function(e){
- if(this.disabled || e.within(this.target.dom, true)){
- return;
- }
- this.clearTimer('show');
- if(this.autoHide !== false){
- this.delayHide();
- }
- },
- delayHide : function(){
- if(!this.hidden && !this.hideTimer){
- this.hideTimer = this.hide.defer(this.hideDelay, this);
- }
- },
- hide: function(){
- this.clearTimer('dismiss');
- this.lastActive = new Date();
- Ext.ToolTip.superclass.hide.call(this);
- },
- show : function(){
- this.showAt(this.getTargetXY());
- },
- 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);
- }
- },
- clearTimer : function(name){
- name = name + 'Timer';
- clearTimeout(this[name]);
- delete this[name];
- },
- clearTimers : function(){
- this.clearTimer('show');
- this.clearTimer('dismiss');
- this.clearTimer('hide');
- },
- onShow : function(){
- Ext.ToolTip.superclass.onShow.call(this);
- Ext.getDoc().on('mousedown', this.onDocMouseDown, this);
- },
- onHide : function(){
- Ext.ToolTip.superclass.onHide.call(this);
- Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
- },
- onDocMouseDown : function(e){
- if(this.autoHide !== false && !e.within(this.el.dom)){
- this.disable();
- this.enable.defer(100, this);
- }
- },
- onDisable : function(){
- this.clearTimers();
- this.hide();
- },
- adjustPosition : function(x, y){
- var ay = this.targetXY[1], h = this.getSize().height;
- if(this.constrainPosition && y <= ay && (y+h) >= ay){
- y = ay-h-5;
- }
- return {x : x, y: y};
- },
- onDestroy : function(){
- Ext.ToolTip.superclass.onDestroy.call(this);
- if(this.target){
- this.target.un('mouseover', this.onTargetOver, this);
- this.target.un('mouseout', this.onTargetOut, this);
- this.target.un('mousemove', this.onMouseMove, this);
- }
- }
- });
- Ext.QuickTip = Ext.extend(Ext.ToolTip, {
- interceptTitles : false,
- tagConfig : {
- namespace : "ext",
- attribute : "qtip",
- width : "qwidth",
- target : "target",
- title : "qtitle",
- hide : "hide",
- cls : "qclass",
- align : "qalign"
- },
- initComponent : function(){
- this.target = this.target || Ext.getDoc();
- this.targets = this.targets || {};
- Ext.QuickTip.superclass.initComponent.call(this);
- },
- 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;
- }
- }
- }
- },
- unregister : function(el){
- delete this.targets[Ext.id(el)];
- },
- 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.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.getAttributeNS(ns, cfg.attribute);
- }
- if(ttp){
- var autoHide = et.getAttributeNS(ns, cfg.hide);
- this.activeTarget = {
- el: t,
- text: ttp,
- width: et.getAttributeNS(ns, cfg.width),
- autoHide: autoHide != "user" && autoHide !== 'false',
- title: et.getAttributeNS(ns, cfg.title),
- cls: et.getAttributeNS(ns, cfg.cls),
- align: et.getAttributeNS(ns, cfg.align)
- };
- this.delayShow();
- }
- },
- onTargetOut : function(e){
- this.clearTimer('show');
- if(this.autoHide !== false){
- this.delayHide();
- }
- },
- 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(t.align){
- xy = this.el.getAlignToXY(t.el, t.align);
- this.constrainPosition = false;
- } else{
- this.constrainPosition = true;
- }
- }
- Ext.QuickTip.superclass.showAt.call(this, xy);
- },
- hide: function(){
- delete this.activeTarget;
- Ext.QuickTip.superclass.hide.call(this);
- }
- });
- Ext.QuickTips = function(){
- var tip, locks = [];
- return {
- init : function(){
- if(!tip){
- tip = new Ext.QuickTip({elements:'header,body'});
- }
- },
- enable : function(){
- if(tip){
- locks.pop();
- if(locks.length < 1){
- tip.enable();
- }
- }
- },
- disable : function(){
- if(tip){
- tip.disable();
- }
- locks.push(1);
- },
- isEnabled : function(){
- return tip && !tip.disabled;
- },
- getQuickTip : function(){
- return tip;
- },
- register : function(){
- tip.register.apply(tip, arguments);
- },
- unregister : function(){
- tip.unregister.apply(tip, arguments);
- },
- tips :function(){
- tip.register.apply(tip, arguments);
- }
- }
- }();
- 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);
- }
- this.nodeHash = {};
- if(this.root){
- this.setRootNode(this.root);
- }
- this.addEvents(
- "append",
- "remove",
- "movenode",
- "insert",
- "beforeappend",
- "beforeremove",
- "beforemovenode",
- "beforeinsert",
- "beforeload",
- "load",
- "textchange",
- "beforeexpandnode",
- "beforecollapsenode",
- "expandnode",
- "disabledchange",
- "collapsenode",
- "beforeclick",
- "click",
- "checkchange",
- "dblclick",
- "contextmenu",
- "beforechildrenrendered",
- "startdrag",
- "enddrag",
- "dragdrop",
- "beforenodedrop",
- "nodedrop",
- "nodedragover"
- );
- if(this.singleExpand){
- this.on("beforeexpandnode", this.restrictExpand, this);
- }
- },
- 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';
- }
- return this.fireEvent(ename, a1, a2, a3, a4, a5, a6);
- },
- getRootNode : function(){
- return this.root;
- },
- setRootNode : function(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);
- }
- return node;
- },
- getNodeById : function(id){
- return this.nodeHash[id];
- },
- registerNode : function(node){
- this.nodeHash[node.id] = node;
- },
- unregisterNode : function(node){
- delete this.nodeHash[node.id];
- },
- toString : function(){
- return "[Tree"+(this.id?" "+this.id:"")+"]";
- },
- restrictExpand : function(node){
- var p = node.parentNode;
- if(p){
- if(p.expandedChild && p.expandedChild.parentNode == p){
- p.expandedChild.collapse();
- }
- p.expandedChild = node;
- }
- },
- 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;
- },
- getEl : function(){
- return this.el;
- },
- getLoader : function(){
- return this.loader;
- },
- expandAll : function(){
- this.root.expand(true);
- },
- collapseAll : function(){
- this.root.collapse(true);
- },
- getSelectionModel : function(){
- if(!this.selModel){
- this.selModel = new Ext.tree.DefaultSelectionModel();
- }
- return this.selModel;
- },
- expandPath : function(path, attr, callback){
- attr = attr || "id";
- var keys = path.split(this.pathSeparator);
- var curNode = this.root;
- if(curNode.attributes[attr] != keys[1]){
- 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);
- },
- 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);
- }
- }
- },
- getTreeEl : function(){
- return this.body;
- },
- 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")});
- },
- 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){
- this.dropZone = new Ext.tree.TreeDropZone(this, this.dropConfig || {
- ddGroup: this.ddGroup || "TreeDD", appendOnly: this.ddAppendOnly === true
- });
- }
- if((this.enableDD || this.enableDrag) && !this.dragZone){
- this.dragZone = new Ext.tree.TreeDragZone(this, this.dragConfig || {
- ddGroup: this.ddGroup || "TreeDD",
- scroll: this.ddScroll
- });
- }
- this.getSelectionModel().init(this);
- },
- 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);
- }
- });
- Ext.reg('treepanel', Ext.tree.TreePanel);
- Ext.tree.TreeEventModel = function(tree){
- this.tree = tree;
- this.tree.on('render', this.initEvents, this);
- }
- Ext.tree.TreeEventModel.prototype = {
- initEvents : function(){
- var el = this.tree.getTreeEl();
- el.on('click', this.delegateClick, this);
- if(this.tree.trackMouseOver !== false){
- el.on('mouseover', this.delegateOver, this);
- el.on('mouseout', this.delegateOut, this);
- }
- el.on('dblclick', this.delegateDblClick, this);
- el.on('contextmenu', this.delegateContextMenu, this);
- },
- getNode : function(e){
- var t;
- if(t = e.getTarget('.x-tree-node-el', 10)){
- var id = Ext.fly(t, '_treeEvents').getAttributeNS('ext', 'tree-node-id');
- if(id){
- return this.tree.getNodeById(id);
- }
- }
- return null;
- },
- getNodeTarget : function(e){
- var t = e.getTarget('.x-tree-node-icon', 1);
- if(!t){
- t = e.getTarget('.x-tree-node-el', 6);
- }
- return t;
- },
- delegateOut : function(e, t){
- if(!this.beforeEvent(e)){
- return;
- }
- if(e.getTarget('.x-tree-ec-icon', 1)){
- var n = this.getNode(e);
- this.onIconOut(e, n);
- if(n == this.lastEcOver){
- delete this.lastEcOver;
- }
- }
- if((t = this.getNodeTarget(e)) && !e.within(t, true)){
- this.onNodeOut(e, this.getNode(e));
- }
- },
- delegateOver : function(e, t){
- if(!this.beforeEvent(e)){
- return;
- }
- if(this.lastEcOver){
- this.onIconOut(e, this.lastEcOver);
- delete this.lastEcOver;
- }
- if(e.getTarget('.x-tree-ec-icon', 1)){
- this.lastEcOver = this.getNode(e);
- this.onIconOver(e, this.lastEcOver);
- }
- if(t = this.getNodeTarget(e)){
- this.onNodeOver(e, this.getNode(e));
- }
- },
- delegateClick : function(e, t){
- if(!this.beforeEvent(e)){
- return;
- }
- if(e.getTarget('input[type=checkbox]', 1)){
- this.onCheckboxClick(e, this.getNode(e));
- }
- else if(e.getTarget('.x-tree-ec-icon', 1)){
- this.onIconClick(e, this.getNode(e));
- }
- else if(this.getNodeTarget(e)){
- this.onNodeClick(e, this.getNode(e));
- }
- },
- delegateDblClick : function(e, t){
- if(this.beforeEvent(e) && this.getNodeTarget(e)){
- this.onNodeDblClick(e, this.getNode(e));
- }
- },
- delegateContextMenu : function(e, t){
- if(this.beforeEvent(e) && this.getNodeTarget(e)){
- this.onNodeContextMenu(e, this.getNode(e));
- }
- },
- onNodeClick : function(e, node){
- node.ui.onClick(e);
- },
- onNodeOver : function(e, node){
- node.ui.onOver(e);
- },
- onNodeOut : function(e, node){
- node.ui.onOut(e);
- },
- onIconOver : function(e, node){
- node.ui.addClass('x-tree-ec-over');
- },
- onIconOut : function(e, node){
- node.ui.removeClass('x-tree-ec-over');
- },
- onIconClick : function(e, node){
- node.ui.ecClick(e);
- },
- onCheckboxClick : function(e, node){
- node.ui.onCheckChange(e);
- },
- onNodeDblClick : function(e, node){
- node.ui.onDblClick(e);
- },
- onNodeContextMenu : function(e, node){
- node.ui.onContextMenu(e);
- },
- beforeEvent : function(e){
- if(this.disabled){
- e.stopEvent();
- return false;
- }
- return true;
- },
- disable: function(){
- this.disabled = true;
- },
- enable: function(){
- this.disabled = false;
- }
- };
- Ext.tree.DefaultSelectionModel = function(config){
- this.selNode = null;
- this.addEvents(
- "selectionchange",
- "beforeselect"
- );
- Ext.apply(this, config);
- Ext.tree.DefaultSelectionModel.superclass.constructor.call(this);
- };
- Ext.extend(Ext.tree.DefaultSelectionModel, Ext.util.Observable, {
- init : function(tree){
- this.tree = tree;
- tree.getTreeEl().on("keydown", this.onKeyDown, this);
- tree.on("click", this.onNodeClick, this);
- },
- onNodeClick : function(node, e){
- this.select(node);
- },
- select : function(node){
- var last = this.selNode;
- if(last != node && this.fireEvent('beforeselect', this, node, last) !== false){
- if(last){
- last.ui.onSelectedChange(false);
- }
- this.selNode = node;
- node.ui.onSelectedChange(true);
- this.fireEvent("selectionchange", this, node, last);
- }
- return node;
- },
- unselect : function(node){
- if(this.selNode == node){
- this.clearSelections();
- }
- },
- clearSelections : function(){
- var n = this.selNode;
- if(n){
- n.ui.onSelectedChange(false);
- this.selNode = null;
- this.fireEvent("selectionchange", this, null);
- }
- return n;
- },
- getSelectedNode : function(){
- return this.selNode;
- },
- isSelected : function(node){
- return this.selNode == node;
- },
- selectPrevious : function(){
- var s = this.selNode || this.lastSelNode;
- if(!s){
- return null;
- }
- var ps = s.previousSibling;
- if(ps){
- if(!ps.isExpanded() || ps.childNodes.length < 1){
- return this.select(ps);
- } else{
- var lc = ps.lastChild;
- while(lc && lc.isExpanded() && lc.childNodes.length > 0){
- lc = lc.lastChild;
- }
- return this.select(lc);
- }
- } else if(s.parentNode && (this.tree.rootVisible || !s.parentNode.isRoot)){
- return this.select(s.parentNode);
- }
- return null;
- },
- selectNext : function(){
- var s = this.selNode || this.lastSelNode;
- if(!s){
- return null;
- }
- if(s.firstChild && s.isExpanded()){
- return this.select(s.firstChild);
- }else if(s.nextSibling){
- return this.select(s.nextSibling);
- }else if(s.parentNode){
- var newS = null;
- s.parentNode.bubble(function(){
- if(this.nextSibling){
- newS = this.getOwnerTree().selModel.select(this.nextSibling);
- return false;
- }
- });
- return newS;
- }
- return null;
- },
- onKeyDown : function(e){
- var s = this.selNode || this.lastSelNode;
- var sm = this;
- if(!s){
- return;
- }
- var k = e.getKey();
- switch(k){
- case e.DOWN:
- e.stopEvent();
- this.selectNext();
- break;
- case e.UP:
- e.stopEvent();
- this.selectPrevious();
- break;
- case e.RIGHT:
- e.preventDefault();
- if(s.hasChildNodes()){
- if(!s.isExpanded()){
- s.expand();
- }else if(s.firstChild){
- this.select(s.firstChild, e);
- }
- }
- break;
- case e.LEFT:
- e.preventDefault();
- if(s.hasChildNodes() && s.isExpanded()){
- s.collapse();
- }else if(s.parentNode && (this.tree.rootVisible || s.parentNode != this.tree.getRootNode())){
- this.select(s.parentNode, e);
- }
- break;
- };
- }
- });
- Ext.tree.MultiSelectionModel = function(config){
- this.selNodes = [];
- this.selMap = {};
- this.addEvents(
- "selectionchange"
- );
- Ext.apply(this, config);
- Ext.tree.MultiSelectionModel.superclass.constructor.call(this);
- };
- Ext.extend(Ext.tree.MultiSelectionModel, Ext.util.Observable, {
- init : function(tree){
- this.tree = tree;
- tree.getTreeEl().on("keydown", this.onKeyDown, this);
- tree.on("click", this.onNodeClick, this);
- },
- onNodeClick : function(node, e){
- this.select(node, e, e.ctrlKey);
- },
- select : function(node, e, keepExisting){
- if(keepExisting !== true){
- this.clearSelections(true);
- }
- if(this.isSelected(node)){
- this.lastSelNode = node;
- return node;
- }
- this.selNodes.push(node);
- this.selMap[node.id] = node;
- this.lastSelNode = node;
- node.ui.onSelectedChange(true);
- this.fireEvent("selectionchange", this, this.selNodes);
- return node;
- },
- unselect : function(node){
- if(this.selMap[node.id]){
- node.ui.onSelectedChange(false);
- var sn = this.selNodes;
- var index = sn.indexOf(node);
- if(index != -1){
- this.selNodes.splice(index, 1);
- }
- delete this.selMap[node.id];
- this.fireEvent("selectionchange", this, this.selNodes);
- }
- },
- clearSelections : function(suppressEvent){
- var sn = this.selNodes;
- if(sn.length > 0){
- for(var i = 0, len = sn.length; i < len; i++){
- sn[i].ui.onSelectedChange(false);
- }
- this.selNodes = [];
- this.selMap = {};
- if(suppressEvent !== true){
- this.fireEvent("selectionchange", this, this.selNodes);
- }
- }
- },
- isSelected : function(node){
- return this.selMap[node.id] ? true : false;
- },
- getSelectedNodes : function(){
- return this.selNodes;
- },
- onKeyDown : Ext.tree.DefaultSelectionModel.prototype.onKeyDown,
- selectNext : Ext.tree.DefaultSelectionModel.prototype.selectNext,
- selectPrevious : Ext.tree.DefaultSelectionModel.prototype.selectPrevious
- });
- Ext.tree.TreeNode = function(attributes){
- attributes = attributes || {};
- if(typeof attributes == "string"){
- attributes = {text: attributes};
- }
- this.childrenRendered = false;
- this.rendered = false;
- Ext.tree.TreeNode.superclass.constructor.call(this, attributes);
- this.expanded = attributes.expanded === true;
- this.isTarget = attributes.isTarget !== false;
- this.draggable = attributes.draggable !== false && attributes.allowDrag !== false;
- this.allowChildren = attributes.allowChildren !== false && attributes.allowDrop !== false;
- this.text = attributes.text;
- this.disabled = attributes.disabled === true;
- this.addEvents(
- "textchange",
- "beforeexpand",
- "beforecollapse",
- "expand",
- "disabledchange",
- "collapse",
- "beforeclick",
- "click",
- "checkchange",
- "dblclick",
- "contextmenu",
- "beforechildrenrendered"
- );
- var uiClass = this.attributes.uiProvider || this.defaultUI || Ext.tree.TreeNodeUI;
- this.ui = new uiClass(this);
- };
- Ext.extend(Ext.tree.TreeNode, Ext.data.Node, {
- preventHScroll: true,
- isExpanded : function(){
- return this.expanded;
- },
- getUI : function(){
- return this.ui;
- },
- setFirstChild : function(node){
- var of = this.firstChild;
- Ext.tree.TreeNode.superclass.setFirstChild.call(this, node);
- if(this.childrenRendered && of && node != of){
- of.renderIndent(true, true);
- }
- if(this.rendered){
- this.renderIndent(true, true);
- }
- },
- setLastChild : function(node){
- var ol = this.lastChild;
- Ext.tree.TreeNode.superclass.setLastChild.call(this, node);
- if(this.childrenRendered && ol && node != ol){
- ol.renderIndent(true, true);
- }
- if(this.rendered){
- this.renderIndent(true, true);
- }
- },
- appendChild : function(){
- var node = Ext.tree.TreeNode.superclass.appendChild.apply(this, arguments);
- if(node && this.childrenRendered){
- node.render();
- }
- this.ui.updateExpandIcon();
- return node;
- },
- removeChild : function(node){
- this.ownerTree.getSelectionModel().unselect(node);
- Ext.tree.TreeNode.superclass.removeChild.apply(this, arguments);
- if(this.childrenRendered){
- node.ui.remove();
- }
- if(this.childNodes.length < 1){
- this.collapse(false, false);
- }else{
- this.ui.updateExpandIcon();
- }
- if(!this.firstChild && !this.isHiddenRoot()) {
- this.childrenRendered = false;
- }
- return node;
- },
- insertBefore : function(node, refNode){
- var newNode = Ext.tree.TreeNode.superclass.insertBefore.apply(this, arguments);
- if(newNode && refNode && this.childrenRendered){
- node.render();
- }
- this.ui.updateExpandIcon();
- return newNode;
- },
- setText : function(text){
- var oldText = this.text;
- this.text = text;
- this.attributes.text = text;
- if(this.rendered){
- this.ui.onTextChange(this, text, oldText);
- }
- this.fireEvent("textchange", this, text, oldText);
- },
- select : function(){
- this.getOwnerTree().getSelectionModel().select(this);
- },
- unselect : function(){
- this.getOwnerTree().getSelectionModel().unselect(this);
- },
- isSelected : function(){
- return this.getOwnerTree().getSelectionModel().isSelected(this);
- },
- expand : function(deep, anim, callback){
- if(!this.expanded){
- if(this.fireEvent("beforeexpand", this, deep, anim) === false){
- return;
- }
- if(!this.childrenRendered){
- this.renderChildren();
- }
- this.expanded = true;
- if(!this.isHiddenRoot() && (this.getOwnerTree().animate && anim !== false) || anim){
- this.ui.animExpand(function(){
- this.fireEvent("expand", this);
- if(typeof callback == "function"){
- callback(this);
- }
- if(deep === true){
- this.expandChildNodes(true);
- }
- }.createDelegate(this));
- return;
- }else{
- this.ui.expand();
- this.fireEvent("expand", this);
- if(typeof callback == "function"){
- callback(this);
- }
- }
- }else{
- if(typeof callback == "function"){
- callback(this);
- }
- }
- if(deep === true){
- this.expandChildNodes(true);
- }
- },
- isHiddenRoot : function(){
- return this.isRoot && !this.getOwnerTree().rootVisible;
- },
- collapse : function(deep, anim){
- if(this.expanded && !this.isHiddenRoot()){
- if(this.fireEvent("beforecollapse", this, deep, anim) === false){
- return;
- }
- this.expanded = false;
- if((this.getOwnerTree().animate && anim !== false) || anim){
- this.ui.animCollapse(function(){
- this.fireEvent("collapse", this);
- if(deep === true){
- this.collapseChildNodes(true);
- }
- }.createDelegate(this));
- return;
- }else{
- this.ui.collapse();
- this.fireEvent("collapse", this);
- }
- }
- if(deep === true){
- var cs = this.childNodes;
- for(var i = 0, len = cs.length; i < len; i++) {
- cs[i].collapse(true, false);
- }
- }
- },
- delayedExpand : function(delay){
- if(!this.expandProcId){
- this.expandProcId = this.expand.defer(delay, this);
- }
- },
- cancelExpand : function(){
- if(this.expandProcId){
- clearTimeout(this.expandProcId);
- }
- this.expandProcId = false;
- },
- toggle : function(){
- if(this.expanded){
- this.collapse();
- }else{
- this.expand();
- }
- },
- ensureVisible : function(callback){
- var tree = this.getOwnerTree();
- tree.expandPath(this.parentNode.getPath(), false, function(){
- var node = tree.getNodeById(this.id);
- tree.getTreeEl().scrollChildIntoView(node.ui.anchor);
- Ext.callback(callback);
- }.createDelegate(this));
- },
- expandChildNodes : function(deep){
- var cs = this.childNodes;
- for(var i = 0, len = cs.length; i < len; i++) {
- cs[i].expand(deep);
- }
- },
- collapseChildNodes : function(deep){
- var cs = this.childNodes;
- for(var i = 0, len = cs.length; i < len; i++) {
- cs[i].collapse(deep);
- }
- },
- disable : function(){
- this.disabled = true;
- this.unselect();
- if(this.rendered && this.ui.onDisableChange){
- this.ui.onDisableChange(this, true);
- }
- this.fireEvent("disabledchange", this, true);
- },
- enable : function(){
- this.disabled = false;
- if(this.rendered && this.ui.onDisableChange){
- this.ui.onDisableChange(this, false);
- }
- this.fireEvent("disabledchange", this, false);
- },
- renderChildren : function(suppressEvent){
- if(suppressEvent !== false){
- this.fireEvent("beforechildrenrendered", this);
- }
- var cs = this.childNodes;
- for(var i = 0, len = cs.length; i < len; i++){
- cs[i].render(true);
- }
- this.childrenRendered = true;
- },
- sort : function(fn, scope){
- Ext.tree.TreeNode.superclass.sort.apply(this, arguments);
- if(this.childrenRendered){
- var cs = this.childNodes;
- for(var i = 0, len = cs.length; i < len; i++){
- cs[i].render(true);
- }
- }
- },
- render : function(bulkRender){
- this.ui.render(bulkRender);
- if(!this.rendered){
- this.getOwnerTree().registerNode(this);
- this.rendered = true;
- if(this.expanded){
- this.expanded = false;
- this.expand(false, false);
- }
- }
- },
- renderIndent : function(deep, refresh){
- if(refresh){
- this.ui.childIndent = null;
- }
- this.ui.renderIndent();
- if(deep === true && this.childrenRendered){
- var cs = this.childNodes;
- for(var i = 0, len = cs.length; i < len; i++){
- cs[i].renderIndent(true, refresh);
- }
- }
- },
- beginUpdate : function(){
- this.childrenRendered = false;
- },
- endUpdate : function(){
- if(this.expanded){
- this.renderChildren();
- }
- },
- destroy : function(){
- for(var i = 0,l = this.childNodes.length; i < l; i++){
- this.childNodes[i].destroy();
- }
- this.childNodes = null;
- if(this.ui.destroy){
- this.ui.destroy();
- }
- }
- });
- Ext.tree.AsyncTreeNode = function(config){
- this.loaded = false;
- this.loading = false;
- Ext.tree.AsyncTreeNode.superclass.constructor.apply(this, arguments);
- this.addEvents('beforeload', 'load');
- };
- Ext.extend(Ext.tree.AsyncTreeNode, Ext.tree.TreeNode, {
- expand : function(deep, anim, callback){
- if(this.loading){
- var timer;
- var f = function(){
- if(!this.loading){
- clearInterval(timer);
- this.expand(deep, anim, callback);
- }
- }.createDelegate(this);
- timer = setInterval(f, 200);
- return;
- }
- if(!this.loaded){
- if(this.fireEvent("beforeload", this) === false){
- return;
- }
- this.loading = true;
- this.ui.beforeLoad(this);
- var loader = this.loader || this.attributes.loader || this.getOwnerTree().getLoader();
- if(loader){
- loader.load(this, this.loadComplete.createDelegate(this, [deep, anim, callback]));
- return;
- }
- }
- Ext.tree.AsyncTreeNode.superclass.expand.call(this, deep, anim, callback);
- },
- isLoading : function(){
- return this.loading;
- },
- loadComplete : function(deep, anim, callback){
- this.loading = false;
- this.loaded = true;
- this.ui.afterLoad(this);
- this.fireEvent("load", this);
- this.expand(deep, anim, callback);
- },
- isLoaded : function(){
- return this.loaded;
- },
- hasChildNodes : function(){
- if(!this.isLeaf() && !this.loaded){
- return true;
- }else{
- return Ext.tree.AsyncTreeNode.superclass.hasChildNodes.call(this);
- }
- },
- reload : function(callback){
- this.collapse(false, false);
- while(this.firstChild){
- this.removeChild(this.firstChild);
- }
- this.childrenRendered = false;
- this.loaded = false;
- if(this.isHiddenRoot()){
- this.expanded = false;
- }
- this.expand(false, false, callback);
- }
- });
- 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 = {
- removeChild : function(node){
- if(this.rendered){
- this.ctNode.removeChild(node.ui.getEl());
- }
- },
- beforeLoad : function(){
- this.addClass("x-tree-node-loading");
- },
- afterLoad : function(){
- this.removeClass("x-tree-node-loading");
- },
- onTextChange : function(node, text, oldText){
- if(this.rendered){
- this.textNode.innerHTML = text;
- }
- },
- onDisableChange : function(node, state){
- this.disabled = state;
- if (this.checkbox) {
- this.checkbox.disabled = state;
- }
- if(state){
- this.addClass("x-tree-node-disabled");
- }else{
- this.removeClass("x-tree-node-disabled");
- }
- },
- onSelectedChange : function(state){
- if(state){
- this.focus();
- this.addClass("x-tree-selected");
- }else{
- this.removeClass("x-tree-selected");
- }
- },
- onMove : function(tree, node, oldParent, newParent, index, refNode){
- this.childIndent = null;
- if(this.rendered){
- var targetNode = newParent.ui.getContainer();
- if(!targetNode){
- this.holder = document.createElement("div");
- this.holder.appendChild(this.wrap);
- return;
- }
- var insertBefore = refNode ? refNode.ui.getEl() : null;
- if(insertBefore){
- targetNode.insertBefore(this.wrap, insertBefore);
- }else{
- targetNode.appendChild(this.wrap);
- }
- this.node.renderIndent(true);
- }
- },
- addClass : function(cls){
- if(this.elNode){
- Ext.fly(this.elNode).addClass(cls);
- }
- },
- removeClass : function(cls){
- if(this.elNode){
- Ext.fly(this.elNode).removeClass(cls);
- }
- },
- remove : function(){
- if(this.rendered){
- this.holder = document.createElement("div");
- this.holder.appendChild(this.wrap);
- }
- },
- fireEvent : function(){
- return this.node.fireEvent.apply(this.node, arguments);
- },
- initEvents : function(){
- this.node.on("move", this.onMove, this);
- if(this.node.disabled){
- this.addClass("x-tree-node-disabled");
- if (this.checkbox) {
- this.checkbox.disabled = true;
- }
- }
- if(this.node.hidden){
- this.hide();
- }
- var ot = this.node.getOwnerTree();
- var dd = ot.enableDD || ot.enableDrag || ot.enableDrop;
- if(dd && (!this.node.isRoot || ot.rootVisible)){
- Ext.dd.Registry.register(this.elNode, {
- node: this.node,
- handles: this.getDDHandles(),
- isHandle: false
- });
- }
- },
- getDDHandles : function(){
- return [this.iconNode, this.textNode, this.elNode];
- },
- hide : function(){
- this.node.hidden = true;
- if(this.wrap){
- this.wrap.style.display = "none";
- }
- },
- show : function(){
- this.node.hidden = false;
- if(this.wrap){
- this.wrap.style.display = "";
- }
- },
- onContextMenu : function(e){
- if (this.node.hasListener("contextmenu") || this.node.getOwnerTree().hasListener("contextmenu")) {
- e.preventDefault();
- this.focus();
- this.fireEvent("contextmenu", this.node, e);
- }
- },
- onClick : function(e){
- if(this.dropping){
- e.stopEvent();
- return;
- }
- if(this.fireEvent("beforeclick", this.node, e) !== false){
- var a = e.getTarget('a');
- if(!this.disabled && this.node.attributes.href && a){
- this.fireEvent("click", this.node, e);
- return;
- }else if(a && e.ctrlKey){
- e.stopEvent();
- }
- e.preventDefault();
- if(this.disabled){
- return;
- }
- if(this.node.attributes.singleClickExpand && !this.animating && this.node.hasChildNodes()){
- this.node.toggle();
- }
- this.fireEvent("click", this.node, e);
- }else{
- e.stopEvent();
- }
- },
- onDblClick : function(e){
- e.preventDefault();
- if(this.disabled){
- return;
- }
- if(this.checkbox){
- this.toggleCheck();
- }
- if(!this.animating && this.node.hasChildNodes()){
- this.node.toggle();
- }
- this.fireEvent("dblclick", this.node, e);
- },
- onOver : function(e){
- this.addClass('x-tree-node-over');
- },
- onOut : function(e){
- this.removeClass('x-tree-node-over');
- },
- onCheckChange : function(){
- var checked = this.checkbox.checked;
- this.node.attributes.checked = checked;
- this.fireEvent('checkchange', this.node, checked);
- },
- ecClick : function(e){
- if(!this.animating && (this.node.hasChildNodes() || this.node.attributes.expandable)){
- this.node.toggle();
- }
- },
- startDrop : function(){
- this.dropping = true;
- },
- endDrop : function(){
- setTimeout(function(){
- this.dropping = false;
- }.createDelegate(this), 50);
- },
- expand : function(){
- this.updateExpandIcon();
- this.ctNode.style.display = "";
- },
- focus : function(){
- if(!this.node.preventHScroll){
- try{this.anchor.focus();
- }catch(e){}
- }else if(!Ext.isIE){
- try{
- var noscroll = this.node.getOwnerTree().getTreeEl().dom;
- var l = noscroll.scrollLeft;
- this.anchor.focus();
- noscroll.scrollLeft = l;
- }catch(e){}
- }
- },
- toggleCheck : function(value){
- var cb = this.checkbox;
- if(cb){
- cb.checked = (value === undefined ? !cb.checked : value);
- }
- },
- blur : function(){
- try{
- this.anchor.blur();
- }catch(e){}
- },
- animExpand : function(callback){
- var ct = Ext.get(this.ctNode);
- ct.stopFx();
- if(!this.node.hasChildNodes()){
- this.updateExpandIcon();
- this.ctNode.style.display = "";
- Ext.callback(callback);
- return;
- }
- this.animating = true;
- this.updateExpandIcon();
- ct.slideIn('t', {
- callback : function(){
- this.animating = false;
- Ext.callback(callback);
- },
- scope: this,
- duration: this.node.ownerTree.duration || .25
- });
- },
- highlight : function(){
- var tree = this.node.getOwnerTree();
- Ext.fly(this.wrap).highlight(
- tree.hlColor || "C3DAF9",
- {endColor: tree.hlBaseColor}
- );
- },
- collapse : function(){
- this.updateExpandIcon();
- this.ctNode.style.display = "none";
- },
- animCollapse : function(callback){
- var ct = Ext.get(this.ctNode);
- ct.enableDisplayMode('block');
- ct.stopFx();
- this.animating = true;
- this.updateExpandIcon();
- ct.slideOut('t', {
- callback : function(){
- this.animating = false;
- Ext.callback(callback);
- },
- scope: this,
- duration: this.node.ownerTree.duration || .25
- });
- },
- getContainer : function(){
- return this.ctNode;
- },
- getEl : function(){
- return this.wrap;
- },
- appendDDGhost : function(ghostNode){
- ghostNode.appendChild(this.elNode.cloneNode(true));
- },
- getDDRepairXY : function(){
- return Ext.lib.Dom.getXY(this.iconNode);
- },
- onRender : function(){
- this.render();
- },
- render : function(bulkRender){
- var n = this.node, a = n.attributes;
- var targetNode = n.parentNode ?
- n.parentNode.ui.getContainer() : n.ownerTree.innerCt.dom;
- if(!this.rendered){
- this.rendered = true;
- 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);
- }
- }
- }else if(a.qtipCfg){
- a.qtipCfg.target = Ext.id(this.textNode);
- Ext.QuickTips.register(a.qtipCfg);
- }
- this.initEvents();
- if(!this.node.expanded){
- this.updateExpandIcon(true);
- }
- }else{
- if(bulkRender === true) {
- targetNode.appendChild(this.wrap);
- }
- }
- },
- renderElements : function(n, a, targetNode, bulkRender){
- this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
- var cb = typeof a.checked == 'boolean';
- var href = a.href ? a.href : Ext.isGecko ? "" : "#";
- var buf = ['<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf x-unselectable ', a.cls,'" unselectable="on">',
- '<span class="x-tree-node-indent">',this.indentMarkup,"</span>",
- '<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow" />',
- '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon',(a.icon ? " x-tree-node-inline-icon" : ""),(a.iconCls ? " "+a.iconCls : ""),'" unselectable="on" />',
- cb ? ('<input class="x-tree-node-cb" type="checkbox" ' + (a.checked ? 'checked="checked" />' : '/>')) : '',
- '<a hidefocus="on" class="x-tree-node-anchor" href="',href,'" tabIndex="1" ',
- a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "", '><span unselectable="on">',n.text,"</span></a></div>",
- '<ul class="x-tree-node-ct" style="display:none;"></ul>',
- "</li>"].join('');
- var nel;
- if(bulkRender !== true && n.nextSibling && (nel = n.nextSibling.ui.getEl())){
- this.wrap = Ext.DomHelper.insertHtml("beforeBegin", nel, buf);
- }else{
- this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf);
- }
- this.elNode = this.wrap.childNodes[0];
- this.ctNode = this.wrap.childNodes[1];
- var cs = this.elNode.childNodes;
- this.indentNode = cs[0];
- this.ecNode = cs[1];
- this.iconNode = cs[2];
- var index = 3;
- if(cb){
- this.checkbox = cs[3];
- index++;
- }
- this.anchor = cs[index];
- this.textNode = cs[index].firstChild;
- },
- getAnchor : function(){
- return this.anchor;
- },
- getTextEl : function(){
- return this.textNode;
- },
- getIconEl : function(){
- return this.iconNode;
- },
- isChecked : function(){
- return this.checkbox ? this.checkbox.checked : false;
- },
- updateExpandIcon : function(){
- if(this.rendered){
- var n = this.node, c1, c2;
- var cls = n.isLast() ? "x-tree-elbow-end" : "x-tree-elbow";
- var hasChild = n.hasChildNodes();
- if(hasChild || n.attributes.expandable){
- if(n.expanded){
- cls += "-minus";
- c1 = "x-tree-node-collapsed";
- c2 = "x-tree-node-expanded";
- }else{
- cls += "-plus";
- c1 = "x-tree-node-expanded";
- c2 = "x-tree-node-collapsed";
- }
- if(this.wasLeaf){
- this.removeClass("x-tree-node-leaf");
- this.wasLeaf = false;
- }
- if(this.c1 != c1 || this.c2 != c2){
- Ext.fly(this.elNode).replaceClass(c1, c2);
- this.c1 = c1; this.c2 = c2;
- }
- }else{
- if(!this.wasLeaf){
- Ext.fly(this.elNode).replaceClass("x-tree-node-expanded", "x-tree-node-leaf");
- delete this.c1;
- delete this.c2;
- this.wasLeaf = true;
- }
- }
- var ecc = "x-tree-ec-icon "+cls;
- if(this.ecc != ecc){
- this.ecNode.className = ecc;
- this.ecc = ecc;
- }
- }
- },
- getChildIndent : function(){
- if(!this.childIndent){
- var buf = [];
- var p = this.node;
- while(p){
- if(!p.isRoot || (p.isRoot && p.ownerTree.rootVisible)){
- if(!p.isLast()) {
- buf.unshift('<img src="'+this.emptyIcon+'" class="x-tree-elbow-line" />');
- } else {
- buf.unshift('<img src="'+this.emptyIcon+'" class="x-tree-icon" />');
- }
- }
- p = p.parentNode;
- }
- this.childIndent = buf.join("");
- }
- return this.childIndent;
- },
- renderIndent : function(){
- if(this.rendered){
- var indent = "";
- var p = this.node.parentNode;
- if(p){
- indent = p.ui.getChildIndent();
- }
- if(this.indentMarkup != indent){
- this.indentNode.innerHTML = indent;
- this.indentMarkup = indent;
- }
- this.updateExpandIcon();
- }
- },
- destroy : function(){
- if(this.elNode){
- Ext.dd.Registry.unregister(this.elNode.id);
- }
- delete this.elNode;
- delete this.ctNode;
- delete this.indentNode;
- delete this.ecNode;
- delete this.iconNode;
- delete this.checkbox;
- delete this.anchor;
- delete this.textNode;
- Ext.removeNode(this.ctNode);
- }
- };
- Ext.tree.RootTreeNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
- render : function(){
- if(!this.rendered){
- var targetNode = this.node.ownerTree.innerCt.dom;
- this.node.expanded = true;
- targetNode.innerHTML = '<div class="x-tree-root-node"></div>';
- this.wrap = this.ctNode = targetNode.firstChild;
- }
- },
- collapse : Ext.emptyFn,
- expand : Ext.emptyFn
- });
- Ext.tree.TreeLoader = function(config){
- this.baseParams = {};
- this.requestMethod = "POST";
- Ext.apply(this, config);
- this.addEvents(
- "beforeload",
- "load",
- "loadexception"
- );
- Ext.tree.TreeLoader.superclass.constructor.call(this);
- };
- Ext.extend(Ext.tree.TreeLoader, Ext.util.Observable, {
- uiProviders : {},
- clearOnLoad : true,
- load : function(node, callback){
- if(this.clearOnLoad){
- while(node.firstChild){
- node.removeChild(node.firstChild);
- }
- }
- if(this.doPreload(node)){
- if(typeof callback == "function"){
- callback();
- }
- }else if(this.dataUrl||this.url){
- this.requestData(node, callback);
- }
- },
- doPreload : function(node){
- if(node.attributes.children){
- if(node.childNodes.length < 1){
- var cs = node.attributes.children;
- node.beginUpdate();
- for(var i = 0, len = cs.length; i < len; i++){
- var cn = node.appendChild(this.createNode(cs[i]));
- if(this.preloadChildren){
- this.doPreload(cn);
- }
- }
- node.endUpdate();
- }
- return true;
- }else {
- return false;
- }
- },
- getParams: function(node){
- var buf = [], bp = this.baseParams;
- for(var key in bp){
- if(typeof bp[key] != "function"){
- buf.push(encodeURIComponent(key), "=", encodeURIComponent(bp[key]), "&");
- }
- }
- buf.push("node=", encodeURIComponent(node.id));
- return buf.join("");
- },
- requestData : function(node, callback){
- if(this.fireEvent("beforeload", this, node, callback) !== false){
- this.transId = Ext.Ajax.request({
- method:this.requestMethod,
- url: this.dataUrl||this.url,
- success: this.handleResponse,
- failure: this.handleFailure,
- scope: this,
- argument: {callback: callback, node: node},
- params: this.getParams(node)
- });
- }else{
- if(typeof callback == "function"){
- callback();
- }
- }
- },
- isLoading : function(){
- return this.transId ? true : false;
- },
- abort : function(){
- if(this.isLoading()){
- Ext.Ajax.abort(this.transId);
- }
- },
- createNode : function(attr){
- if(this.baseAttrs){
- Ext.applyIf(attr, this.baseAttrs);
- }
- if(this.applyLoader !== false){
- attr.loader = this;
- }
- if(typeof attr.uiProvider == 'string'){
- attr.uiProvider = this.uiProviders[attr.uiProvider] || eval(attr.uiProvider);
- }
- return(attr.leaf ?
- new Ext.tree.TreeNode(attr) :
- new Ext.tree.AsyncTreeNode(attr));
- },
- processResponse : function(response, node, callback){
- var json = response.responseText;
- try {
- var o = eval("("+json+")");
- node.beginUpdate();
- for(var i = 0, len = o.length; i < len; i++){
- var n = this.createNode(o[i]);
- if(n){
- node.appendChild(n);
- }
- }
- node.endUpdate();
- if(typeof callback == "function"){
- callback(this, node);
- }
- }catch(e){
- this.handleFailure(response);
- }
- },
- handleResponse : function(response){
- this.transId = false;
- var a = response.argument;
- this.processResponse(response, a.node, a.callback);
- this.fireEvent("load", this, a.node, response);
- },
- handleFailure : function(response){
- this.transId = false;
- var a = response.argument;
- this.fireEvent("loadexception", this, a.node, response);
- if(typeof a.callback == "function"){
- a.callback(this, a.node);
- }
- }
- });
- Ext.tree.TreeFilter = function(tree, config){
- this.tree = tree;
- this.filtered = {};
- Ext.apply(this, config);
- };
- Ext.tree.TreeFilter.prototype = {
- clearBlank:false,
- reverse:false,
- autoClear:false,
- remove:false,
- filter : function(value, attr, startNode){
- attr = attr || "text";
- var f;
- if(typeof value == "string"){
- var vlen = value.length;
- if(vlen == 0 && this.clearBlank){
- this.clear();
- return;
- }
- value = value.toLowerCase();
- f = function(n){
- return n.attributes[attr].substr(0, vlen).toLowerCase() == value;
- };
- }else if(value.exec){
- f = function(n){
- return value.test(n.attributes[attr]);
- };
- }else{
- throw 'Illegal filter type, must be string or regex';
- }
- this.filterBy(f, null, startNode);
- },
- filterBy : function(fn, scope, startNode){
- startNode = startNode || this.tree.root;
- if(this.autoClear){
- this.clear();
- }
- var af = this.filtered, rv = this.reverse;
- var f = function(n){
- if(n == startNode){
- return true;
- }
- if(af[n.id]){
- return false;
- }
- var m = fn.call(scope || n, n);
- if(!m || rv){
- af[n.id] = n;
- n.ui.hide();
- return false;
- }
- return true;
- };
- startNode.cascade(f);
- if(this.remove){
- for(var id in af){
- if(typeof id != "function"){
- var n = af[id];
- if(n && n.parentNode){
- n.parentNode.removeChild(n);
- }
- }
- }
- }
- },
- clear : function(){
- var t = this.tree;
- var af = this.filtered;
- for(var id in af){
- if(typeof id != "function"){
- var n = af[id];
- if(n){
- n.ui.show();
- }
- }
- }
- this.filtered = {};
- }
- };
- Ext.tree.TreeSorter = function(tree, config){
- Ext.apply(this, config);
- tree.on("beforechildrenrendered", this.doSort, this);
- tree.on("append", this.updateSort, this);
- tree.on("insert", this.updateSort, this);
- tree.on("textchange", this.updateSortParent, this);
- var dsc = this.dir && this.dir.toLowerCase() == "desc";
- var p = this.property || "text";
- var sortType = this.sortType;
- var fs = this.folderSort;
- var cs = this.caseSensitive === true;
- var leafAttr = this.leafAttr || 'leaf';
- this.sortFn = function(n1, n2){
- if(fs){
- if(n1.attributes[leafAttr] && !n2.attributes[leafAttr]){
- return 1;
- }
- if(!n1.attributes[leafAttr] && n2.attributes[leafAttr]){
- return -1;
- }
- }
- var v1 = sortType ? sortType(n1) : (cs ? n1.attributes[p] : n1.attributes[p].toUpperCase());
- var v2 = sortType ? sortType(n2) : (cs ? n2.attributes[p] : n2.attributes[p].toUpperCase());
- if(v1 < v2){
- return dsc ? +1 : -1;
- }else if(v1 > v2){
- return dsc ? -1 : +1;
- }else{
- return 0;
- }
- };
- };
- Ext.tree.TreeSorter.prototype = {
- doSort : function(node){
- node.sort(this.sortFn);
- },
- compareNodes : function(n1, n2){
- return (n1.text.toUpperCase() > n2.text.toUpperCase() ? 1 : -1);
- },
- updateSort : function(tree, node){
- if(node.childrenRendered){
- this.doSort.defer(1, this, [node]);
- }
- },
- updateSortParent : function(node){
- var p = node.parentNode;
- if(p && p.childrenRendered){
- this.doSort.defer(1, this, [p]);
- }
- }
- };
- if(Ext.dd.DropZone){
- Ext.tree.TreeDropZone = function(tree, config){
- this.allowParentInsert = false;
- this.allowContainerDrop = false;
- this.appendOnly = false;
- Ext.tree.TreeDropZone.superclass.constructor.call(this, tree.innerCt, config);
- this.tree = tree;
- this.dragOverData = {};
- this.lastInsertClass = "x-tree-no-status";
- };
- Ext.extend(Ext.tree.TreeDropZone, Ext.dd.DropZone, {
- ddGroup : "TreeDD",
- expandDelay : 1000,
- expandNode : function(node){
- if(node.hasChildNodes() && !node.isExpanded()){
- node.expand(false, null, this.triggerCacheRefresh.createDelegate(this));
- }
- },
- queueExpand : function(node){
- this.expandProcId = this.expandNode.defer(this.expandDelay, this, [node]);
- },
- cancelExpand : function(){
- if(this.expandProcId){
- clearTimeout(this.expandProcId);
- this.expandProcId = false;
- }
- },
- isValidDropPoint : function(n, pt, dd, e, data){
- if(!n || !data){ return false; }
- var targetNode = n.node;
- var dropNode = data.node;
- if(!(targetNode && targetNode.isTarget && pt)){
- return false;
- }
- if(pt == "append" && targetNode.allowChildren === false){
- return false;
- }
- if((pt == "above" || pt == "below") && (targetNode.parentNode && targetNode.parentNode.allowChildren === false)){
- return false;
- }
- if(dropNode && (targetNode == dropNode || dropNode.contains(targetNode))){
- return false;
- }
- var overEvent = this.dragOverData;
- overEvent.tree = this.tree;
- overEvent.target = targetNode;
- overEvent.data = data;
- overEvent.point = pt;
- overEvent.source = dd;
- overEvent.rawEvent = e;
- overEvent.dropNode = dropNode;
- overEvent.cancel = false;
- var result = this.tree.fireEvent("nodedragover", overEvent);
- return overEvent.cancel === false && result !== false;
- },
- getDropPoint : function(e, n, dd){
- var tn = n.node;
- if(tn.isRoot){
- return tn.allowChildren !== false ? "append" : false;
- }
- var dragEl = n.ddel;
- var t = Ext.lib.Dom.getY(dragEl), b = t + dragEl.offsetHeight;
- var y = Ext.lib.Event.getPageY(e);
- var noAppend = tn.allowChildren === false || tn.isLeaf();
- if(this.appendOnly || tn.parentNode.allowChildren === false){
- return noAppend ? false : "append";
- }
- var noBelow = false;
- if(!this.allowParentInsert){
- noBelow = tn.hasChildNodes() && tn.isExpanded();
- }
- var q = (b - t) / (noAppend ? 2 : 3);
- if(y >= t && y < (t + q)){
- return "above";
- }else if(!noBelow && (noAppend || y >= b-q && y <= b)){
- return "below";
- }else{
- return "append";
- }
- },
- onNodeEnter : function(n, dd, e, data){
- this.cancelExpand();
- },
- onNodeOver : function(n, dd, e, data){
- var pt = this.getDropPoint(e, n, dd);
- var node = n.node;
- if(!this.expandProcId && pt == "append" && node.hasChildNodes() && !n.node.isExpanded()){
- this.queueExpand(node);
- }else if(pt != "append"){
- this.cancelExpand();
- }
- var returnCls = this.dropNotAllowed;
- if(this.isValidDropPoint(n, pt, dd, e, data)){
- if(pt){
- var el = n.ddel;
- var cls;
- if(pt == "above"){
- returnCls = n.node.isFirst() ? "x-tree-drop-ok-above" : "x-tree-drop-ok-between";
- cls = "x-tree-drag-insert-above";
- }else if(pt == "below"){
- returnCls = n.node.isLast() ? "x-tree-drop-ok-below" : "x-tree-drop-ok-between";
- cls = "x-tree-drag-insert-below";
- }else{
- returnCls = "x-tree-drop-ok-append";
- cls = "x-tree-drag-append";
- }
- if(this.lastInsertClass != cls){
- Ext.fly(el).replaceClass(this.lastInsertClass, cls);
- this.lastInsertClass = cls;
- }
- }
- }
- return returnCls;
- },
- onNodeOut : function(n, dd, e, data){
- this.cancelExpand();
- this.removeDropIndicators(n);
- },
- onNodeDrop : function(n, dd, e, data){
- var point = this.getDropPoint(e, n, dd);
- var targetNode = n.node;
- targetNode.ui.startDrop();
- if(!this.isValidDropPoint(n, point, dd, e, data)){
- targetNode.ui.endDrop();
- return false;
- }
- var dropNode = data.node || (dd.getTreeNode ? dd.getTreeNode(data, targetNode, point, e) : null);
- var dropEvent = {
- tree : this.tree,
- target: targetNode,
- data: data,
- point: point,
- source: dd,
- rawEvent: e,
- dropNode: dropNode,
- cancel: !dropNode,
- dropStatus: false
- };
- var retval = this.tree.fireEvent("beforenodedrop", dropEvent);
- if(retval === false || dropEvent.cancel === true || !dropEvent.dropNode){
- targetNode.ui.endDrop();
- return dropEvent.dropStatus;
- }
- targetNode = dropEvent.target;
- if(point == "append" && !targetNode.isExpanded()){
- targetNode.expand(false, null, function(){
- this.completeDrop(dropEvent);
- }.createDelegate(this));
- }else{
- this.completeDrop(dropEvent);
- }
- return true;
- },
- completeDrop : function(de){
- var ns = de.dropNode, p = de.point, t = de.target;
- if(!Ext.isArray(ns)){
- ns = [ns];
- }
- var n;
- for(var i = 0, len = ns.length; i < len; i++){
- n = ns[i];
- if(p == "above"){
- t.parentNode.insertBefore(n, t);
- }else if(p == "below"){
- t.parentNode.insertBefore(n, t.nextSibling);
- }else{
- t.appendChild(n);
- }
- }
- n.ui.focus();
- if(this.tree.hlDrop){
- n.ui.highlight();
- }
- t.ui.endDrop();
- this.tree.fireEvent("nodedrop", de);
- },
- afterNodeMoved : function(dd, data, e, targetNode, dropNode){
- if(this.tree.hlDrop){
- dropNode.ui.focus();
- dropNode.ui.highlight();
- }
- this.tree.fireEvent("nodedrop", this.tree, targetNode, data, dd, e);
- },
- getTree : function(){
- return this.tree;
- },
- removeDropIndicators : function(n){
- if(n && n.ddel){
- var el = n.ddel;
- Ext.fly(el).removeClass([
- "x-tree-drag-insert-above",
- "x-tree-drag-insert-below",
- "x-tree-drag-append"]);
- this.lastInsertClass = "_noclass";
- }
- },
- beforeDragDrop : function(target, e, id){
- this.cancelExpand();
- return true;
- },
- afterRepair : function(data){
- if(data && Ext.enableFx){
- data.node.ui.highlight();
- }
- this.hideProxy();
- }
- });
- }
- if(Ext.dd.DragZone){
- Ext.tree.TreeDragZone = function(tree, config){
- Ext.tree.TreeDragZone.superclass.constructor.call(this, tree.getTreeEl(), config);
- this.tree = tree;
- };
- Ext.extend(Ext.tree.TreeDragZone, Ext.dd.DragZone, {
- ddGroup : "TreeDD",
- onBeforeDrag : function(data, e){
- var n = data.node;
- return n && n.draggable && !n.disabled;
- },
- onInitDrag : function(e){
- var data = this.dragData;
- this.tree.getSelectionModel().select(data.node);
- this.tree.eventModel.disable();
- this.proxy.update("");
- data.node.ui.appendDDGhost(this.proxy.ghost.dom);
- this.tree.fireEvent("startdrag", this.tree, data.node, e);
- },
- getRepairXY : function(e, data){
- return data.node.ui.getDDRepairXY();
- },
- onEndDrag : function(data, e){
- this.tree.eventModel.enable.defer(100, this.tree.eventModel);
- this.tree.fireEvent("enddrag", this.tree, data.node, e);
- },
- onValidDrop : function(dd, e, id){
- this.tree.fireEvent("dragdrop", this.tree, this.dragData.node, dd, e);
- this.hideProxy();
- },
- beforeInvalidDrop : function(e, id){
- var sm = this.tree.getSelectionModel();
- sm.clearSelections();
- sm.select(this.dragData.node);
- }
- });
- }
- Ext.tree.TreeEditor = function(tree, config){
- config = config || {};
- var field = config.events ? config : new Ext.form.TextField(config);
- Ext.tree.TreeEditor.superclass.constructor.call(this, field);
- this.tree = tree;
- if(!tree.rendered){
- tree.on('render', this.initEditor, this);
- }else{
- this.initEditor(tree);
- }
- };
- Ext.extend(Ext.tree.TreeEditor, Ext.Editor, {
- alignment: "l-l",
- autoSize: false,
- hideEl : false,
- cls: "x-small-editor x-tree-editor",
- shim:false,
- shadow:"frame",
- maxWidth: 250,
- editDelay : 350,
- initEditor : function(tree){
- tree.on('beforeclick', this.beforeNodeClick, this);
- tree.on('dblclick', this.onNodeDblClick, this);
- this.on('complete', this.updateNode, this);
- this.on('beforestartedit', this.fitToTree, this);
- this.on('startedit', this.bindScroll, this, {delay:10});
- this.on('specialkey', this.onSpecialKey, this);
- },
- fitToTree : function(ed, el){
- var td = this.tree.getTreeEl().dom, nd = el.dom;
- if(td.scrollLeft > nd.offsetLeft){ td.scrollLeft = nd.offsetLeft;
- }
- var w = Math.min(
- this.maxWidth,
- (td.clientWidth > 20 ? td.clientWidth : td.offsetWidth) - Math.max(0, nd.offsetLeft-td.scrollLeft) - 5);
- this.setSize(w, '');
- },
- triggerEdit : function(node, defer){
- this.completeEdit();
- if(node.attributes.editable !== false){
- this.editNode = node;
- this.autoEditTimer = this.startEdit.defer(this.editDelay, this, [node.ui.textNode, node.text]);
- return false;
- }
- },
- bindScroll : function(){
- this.tree.getTreeEl().on('scroll', this.cancelEdit, this);
- },
- beforeNodeClick : function(node, e){
- clearTimeout(this.autoEditTimer);
- if(this.tree.getSelectionModel().isSelected(node)){
- e.stopEvent();
- return this.triggerEdit(node);
- }
- },
- onNodeDblClick : function(node, e){
- clearTimeout(this.autoEditTimer);
- },
- updateNode : function(ed, value){
- this.tree.getTreeEl().un('scroll', this.cancelEdit, this);
- this.editNode.setText(value);
- },
- onHide : function(){
- Ext.tree.TreeEditor.superclass.onHide.call(this);
- if(this.editNode){
- this.editNode.ui.focus.defer(50, this.editNode.ui);
- }
- },
- onSpecialKey : function(field, e){
- var k = e.getKey();
- if(k == e.ESC){
- e.stopEvent();
- this.cancelEdit();
- }else if(k == e.ENTER && !e.hasModifier()){
- e.stopEvent();
- this.completeEdit();
- }
- }
- });
- Ext.menu.Menu = function(config){
- if(Ext.isArray(config)){
- config = {items:config};
- }
- Ext.apply(this, config);
- this.id = this.id || Ext.id();
- this.addEvents(
- 'beforeshow',
- 'beforehide',
- 'show',
- 'hide',
- 'click',
- 'mouseover',
- 'mouseout',
- 'itemclick'
- );
- Ext.menu.MenuMgr.register(this);
- Ext.menu.Menu.superclass.constructor.call(this);
- var mis = this.items;
- this.items = new Ext.util.MixedCollection();
- if(mis){
- this.add.apply(this, mis);
- }
- };
- Ext.extend(Ext.menu.Menu, Ext.util.Observable, {
- minWidth : 120,
- shadow : "sides",
- subMenuAlign : "tl-tr?",
- defaultAlign : "tl-bl?",
- allowOtherMenus : false,
- hidden:true,
- createEl : function(){
- return new Ext.Layer({
- cls: "x-menu",
- shadow:this.shadow,
- constrain: false,
- parentEl: this.parentEl || document.body,
- zindex:15000
- });
- },
- render : function(){
- if(this.el){
- return;
- }
- var el = this.el = this.createEl();
- if(!this.keyNav){
- this.keyNav = new Ext.menu.MenuNav(this);
- }
- if(this.plain){
- el.addClass("x-menu-plain");
- }
- if(this.cls){
- el.addClass(this.cls);
- }
- this.focusEl = el.createChild({
- tag: "a", cls: "x-menu-focus", href: "#", onclick: "return false;", tabIndex:"-1"
- });
- var ul = el.createChild({tag: "ul", cls: "x-menu-list"});
- ul.on("click", this.onClick, this);
- ul.on("mouseover", this.onMouseOver, this);
- ul.on("mouseout", this.onMouseOut, this);
- this.items.each(function(item){
- var li = document.createElement("li");
- li.className = "x-menu-list-item";
- ul.dom.appendChild(li);
- item.render(li, this);
- }, this);
- this.ul = ul;
- this.autoWidth();
- },
- autoWidth : function(){
- var el = this.el, ul = this.ul;
- if(!el){
- return;
- }
- var w = this.width;
- if(w){
- el.setWidth(w);
- }else if(Ext.isIE){
- el.setWidth(this.minWidth);
- var t = el.dom.offsetWidth; el.setWidth(ul.getWidth()+el.getFrameWidth("lr"));
- }
- },
- delayAutoWidth : function(){
- if(this.el){
- if(!this.awTask){
- this.awTask = new Ext.util.DelayedTask(this.autoWidth, this);
- }
- this.awTask.delay(20);
- }
- },
- findTargetItem : function(e){
- var t = e.getTarget(".x-menu-list-item", this.ul, true);
- if(t && t.menuItemId){
- return this.items.get(t.menuItemId);
- }
- },
- onClick : function(e){
- var t;
- if(t = this.findTargetItem(e)){
- t.onClick(e);
- this.fireEvent("click", this, t, e);
- }
- },
- setActiveItem : function(item, autoExpand){
- if(item != this.activeItem){
- if(this.activeItem){
- this.activeItem.deactivate();
- }
- this.activeItem = item;
- item.activate(autoExpand);
- }else if(autoExpand){
- item.expandMenu();
- }
- },
- tryActivate : function(start, step){
- var items = this.items;
- for(var i = start, len = items.length; i >= 0 && i < len; i+= step){
- var item = items.get(i);
- if(!item.disabled && item.canActivate){
- this.setActiveItem(item, false);
- return item;
- }
- }
- return false;
- },
- onMouseOver : function(e){
- var t;
- if(t = this.findTargetItem(e)){
- if(t.canActivate && !t.disabled){
- this.setActiveItem(t, true);
- }
- }
- this.fireEvent("mouseover", this, e, t);
- },
- onMouseOut : function(e){
- var t;
- if(t = this.findTargetItem(e)){
- if(t == this.activeItem && t.shouldDeactivate(e)){
- this.activeItem.deactivate();
- delete this.activeItem;
- }
- }
- this.fireEvent("mouseout", this, e, t);
- },
- isVisible : function(){
- return this.el && !this.hidden;
- },
- show : function(el, pos, parentMenu){
- this.parentMenu = parentMenu;
- if(!this.el){
- this.render();
- }
- this.fireEvent("beforeshow", this);
- this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign), parentMenu, false);
- },
- showAt : function(xy, parentMenu, _e){
- this.parentMenu = parentMenu;
- if(!this.el){
- this.render();
- }
- if(_e !== false){
- this.fireEvent("beforeshow", this);
- xy = this.el.adjustForConstraints(xy);
- }
- this.el.setXY(xy);
- this.el.show();
- this.hidden = false;
- this.focus();
- this.fireEvent("show", this);
- },
- focus : function(){
- if(!this.hidden){
- this.doFocus.defer(50, this);
- }
- },
- doFocus : function(){
- if(!this.hidden){
- this.focusEl.focus();
- }
- },
- hide : function(deep){
- if(this.el && this.isVisible()){
- this.fireEvent("beforehide", this);
- if(this.activeItem){
- this.activeItem.deactivate();
- this.activeItem = null;
- }
- this.el.hide();
- this.hidden = true;
- this.fireEvent("hide", this);
- }
- if(deep === true && this.parentMenu){
- this.parentMenu.hide(true);
- }
- },
- add : function(){
- var a = arguments, l = a.length, item;
- for(var i = 0; i < l; i++){
- var el = a[i];
- if(el.render){ item = this.addItem(el);
- }else if(typeof el == "string"){ if(el == "separator" || el == "-"){
- item = this.addSeparator();
- }else{
- item = this.addText(el);
- }
- }else if(el.tagName || el.el){ item = this.addElement(el);
- }else if(typeof el == "object"){ Ext.applyIf(el, this.defaults);
- item = this.addMenuItem(el);
- }
- }
- return item;
- },
- getEl : function(){
- if(!this.el){
- this.render();
- }
- return this.el;
- },
- addSeparator : function(){
- return this.addItem(new Ext.menu.Separator());
- },
- addElement : function(el){
- return this.addItem(new Ext.menu.BaseItem(el));
- },
- addItem : function(item){
- this.items.add(item);
- if(this.ul){
- var li = document.createElement("li");
- li.className = "x-menu-list-item";
- this.ul.dom.appendChild(li);
- item.render(li, this);
- this.delayAutoWidth();
- }
- return item;
- },
- addMenuItem : function(config){
- if(!(config instanceof Ext.menu.Item)){
- if(typeof config.checked == "boolean"){ config = new Ext.menu.CheckItem(config);
- }else{
- config = new Ext.menu.Item(config);
- }
- }
- return this.addItem(config);
- },
- addText : function(text){
- return this.addItem(new Ext.menu.TextItem(text));
- },
- insert : function(index, item){
- this.items.insert(index, item);
- if(this.ul){
- var li = document.createElement("li");
- li.className = "x-menu-list-item";
- this.ul.dom.insertBefore(li, this.ul.dom.childNodes[index]);
- item.render(li, this);
- this.delayAutoWidth();
- }
- return item;
- },
- remove : function(item){
- this.items.removeKey(item.id);
- item.destroy();
- },
- removeAll : function(){
- var f;
- while(f = this.items.first()){
- this.remove(f);
- }
- },
- destroy : function(){
- this.beforeDestroy();
- Ext.menu.MenuMgr.unregister(this);
- if (this.keyNav) {
- this.keyNav.disable();
- }
- this.removeAll();
- if (this.ul) {
- this.ul.removeAllListeners();
- }
- if (this.el) {
- this.el.destroy();
- }
- },
- beforeDestroy : Ext.emptyFn
- });
- Ext.menu.MenuNav = function(menu){
- Ext.menu.MenuNav.superclass.constructor.call(this, menu.el);
- this.scope = this.menu = menu;
- };
- Ext.extend(Ext.menu.MenuNav, Ext.KeyNav, {
- doRelay : function(e, h){
- var k = e.getKey();
- if(!this.menu.activeItem && e.isNavKeyPress() && k != e.SPACE && k != e.RETURN){
- this.menu.tryActivate(0, 1);
- return false;
- }
- return h.call(this.scope || this, e, this.menu);
- },
- up : function(e, m){
- if(!m.tryActivate(m.items.indexOf(m.activeItem)-1, -1)){
- m.tryActivate(m.items.length-1, -1);
- }
- },
- down : function(e, m){
- if(!m.tryActivate(m.items.indexOf(m.activeItem)+1, 1)){
- m.tryActivate(0, 1);
- }
- },
- right : function(e, m){
- if(m.activeItem){
- m.activeItem.expandMenu(true);
- }
- },
- left : function(e, m){
- m.hide();
- if(m.parentMenu && m.parentMenu.activeItem){
- m.parentMenu.activeItem.activate();
- }
- },
- enter : function(e, m){
- if(m.activeItem){
- e.stopPropagation();
- m.activeItem.onClick(e);
- m.fireEvent("click", this, m.activeItem);
- return true;
- }
- }
- });
- Ext.menu.MenuMgr = function(){
- var menus, active, groups = {}, attached = false, lastShow = new Date();
- function init(){
- menus = {};
- active = new Ext.util.MixedCollection();
- Ext.getDoc().addKeyListener(27, function(){
- if(active.length > 0){
- hideAll();
- }
- });
- }
- function hideAll(){
- if(active && active.length > 0){
- var c = active.clone();
- c.each(function(m){
- m.hide();
- });
- }
- }
- function onHide(m){
- active.remove(m);
- if(active.length < 1){
- Ext.getDoc().un("mousedown", onMouseDown);
- attached = false;
- }
- }
- function onShow(m){
- var last = active.last();
- lastShow = new Date();
- active.add(m);
- if(!attached){
- Ext.getDoc().on("mousedown", onMouseDown);
- attached = true;
- }
- if(m.parentMenu){
- m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
- m.parentMenu.activeChild = m;
- }else if(last && last.isVisible()){
- m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
- }
- }
- function onBeforeHide(m){
- if(m.activeChild){
- m.activeChild.hide();
- }
- if(m.autoHideTimer){
- clearTimeout(m.autoHideTimer);
- delete m.autoHideTimer;
- }
- }
- function onBeforeShow(m){
- var pm = m.parentMenu;
- if(!pm && !m.allowOtherMenus){
- hideAll();
- }else if(pm && pm.activeChild){
- pm.activeChild.hide();
- }
- }
- function onMouseDown(e){
- if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".x-menu")){
- hideAll();
- }
- }
- function onBeforeCheck(mi, state){
- if(state){
- var g = groups[mi.group];
- for(var i = 0, l = g.length; i < l; i++){
- if(g[i] != mi){
- g[i].setChecked(false);
- }
- }
- }
- }
- return {
- hideAll : function(){
- hideAll();
- },
- register : function(menu){
- if(!menus){
- init();
- }
- menus[menu.id] = menu;
- menu.on("beforehide", onBeforeHide);
- menu.on("hide", onHide);
- menu.on("beforeshow", onBeforeShow);
- menu.on("show", onShow);
- var g = menu.group;
- if(g && menu.events["checkchange"]){
- if(!groups[g]){
- groups[g] = [];
- }
- groups[g].push(menu);
- menu.on("checkchange", onCheck);
- }
- },
- get : function(menu){
- if(typeof menu == "string"){ if(!menus){ return null;
- }
- return menus[menu];
- }else if(menu.events){ return menu;
- }else if(typeof menu.length == 'number'){ return new Ext.menu.Menu({items:menu});
- }else{ return new Ext.menu.Menu(menu);
- }
- },
- unregister : function(menu){
- delete menus[menu.id];
- menu.un("beforehide", onBeforeHide);
- menu.un("hide", onHide);
- menu.un("beforeshow", onBeforeShow);
- menu.un("show", onShow);
- var g = menu.group;
- if(g && menu.events["checkchange"]){
- groups[g].remove(menu);
- menu.un("checkchange", onCheck);
- }
- },
- registerCheckable : function(menuItem){
- var g = menuItem.group;
- if(g){
- if(!groups[g]){
- groups[g] = [];
- }
- groups[g].push(menuItem);
- menuItem.on("beforecheckchange", onBeforeCheck);
- }
- },
- unregisterCheckable : function(menuItem){
- var g = menuItem.group;
- if(g){
- groups[g].remove(menuItem);
- menuItem.un("beforecheckchange", onBeforeCheck);
- }
- },
- getCheckedItem : function(groupId){
- var g = groups[groupId];
- if(g){
- for(var i = 0, l = g.length; i < l; i++){
- if(g[i].checked){
- return g[i];
- }
- }
- }
- return null;
- },
- setCheckedItem : function(groupId, itemId){
- var g = groups[groupId];
- if(g){
- for(var i = 0, l = g.length; i < l; i++){
- if(g[i].id == itemId){
- g[i].setChecked(true);
- }
- }
- }
- return null;
- }
- };
- }();
- Ext.menu.BaseItem = function(config){
- Ext.menu.BaseItem.superclass.constructor.call(this, config);
- this.addEvents(
- 'click',
- 'activate',
- 'deactivate'
- );
- if(this.handler){
- this.on("click", this.handler, this.scope);
- }
- };
- Ext.extend(Ext.menu.BaseItem, Ext.Component, {
- canActivate : false,
- activeClass : "x-menu-item-active",
- hideOnClick : true,
- hideDelay : 100,
- ctype: "Ext.menu.BaseItem",
- actionMode : "container",
- render : function(container, parentMenu){
- this.parentMenu = parentMenu;
- Ext.menu.BaseItem.superclass.render.call(this, container);
- this.container.menuItemId = this.id;
- },
- onRender : function(container, position){
- this.el = Ext.get(this.el);
- container.dom.appendChild(this.el.dom);
- },
- setHandler : function(handler, scope){
- if(this.handler){
- this.un("click", this.handler, this.scope);
- }
- this.on("click", this.handler = handler, this.scope = scope);
- },
- onClick : function(e){
- if(!this.disabled && this.fireEvent("click", this, e) !== false
- && this.parentMenu.fireEvent("itemclick", this, e) !== false){
- this.handleClick(e);
- }else{
- e.stopEvent();
- }
- },
- activate : function(){
- if(this.disabled){
- return false;
- }
- var li = this.container;
- li.addClass(this.activeClass);
- this.region = li.getRegion().adjust(2, 2, -2, -2);
- this.fireEvent("activate", this);
- return true;
- },
- deactivate : function(){
- this.container.removeClass(this.activeClass);
- this.fireEvent("deactivate", this);
- },
- shouldDeactivate : function(e){
- return !this.region || !this.region.contains(e.getPoint());
- },
- handleClick : function(e){
- if(this.hideOnClick){
- this.parentMenu.hide.defer(this.hideDelay, this.parentMenu, [true]);
- }
- },
- expandMenu : function(autoActivate){
- },
- hideMenu : function(){
- }
- });
- Ext.menu.TextItem = function(text){
- this.text = text;
- Ext.menu.TextItem.superclass.constructor.call(this);
- };
- Ext.extend(Ext.menu.TextItem, Ext.menu.BaseItem, {
- hideOnClick : false,
- itemCls : "x-menu-text",
- onRender : function(){
- var s = document.createElement("span");
- s.className = this.itemCls;
- s.innerHTML = this.text;
- this.el = s;
- Ext.menu.TextItem.superclass.onRender.apply(this, arguments);
- }
- });
- Ext.menu.Separator = function(config){
- Ext.menu.Separator.superclass.constructor.call(this, config);
- };
- Ext.extend(Ext.menu.Separator, Ext.menu.BaseItem, {
- itemCls : "x-menu-sep",
- hideOnClick : false,
- onRender : function(li){
- var s = document.createElement("span");
- s.className = this.itemCls;
- s.innerHTML = " ";
- this.el = s;
- li.addClass("x-menu-sep-li");
- Ext.menu.Separator.superclass.onRender.apply(this, arguments);
- }
- });
- Ext.menu.Item = function(config){
- Ext.menu.Item.superclass.constructor.call(this, config);
- if(this.menu){
- this.menu = Ext.menu.MenuMgr.get(this.menu);
- }
- };
- Ext.extend(Ext.menu.Item, Ext.menu.BaseItem, {
- itemCls : "x-menu-item",
- canActivate : true,
- showDelay: 200,
- hideDelay: 200,
- ctype: "Ext.menu.Item",
- onRender : function(container, position){
- var el = document.createElement("a");
- el.hideFocus = true;
- el.unselectable = "on";
- el.href = this.href || "#";
- if(this.hrefTarget){
- el.target = this.hrefTarget;
- }
- el.className = this.itemCls + (this.menu ? " x-menu-item-arrow" : "") + (this.cls ? " " + this.cls : "");
- el.innerHTML = String.format(
- '<img src="{0}" class="x-menu-item-icon {2}" />{1}',
- this.icon || Ext.BLANK_IMAGE_URL, this.itemText||this.text, this.iconCls || '');
- this.el = el;
- Ext.menu.Item.superclass.onRender.call(this, container, position);
- },
- setText : function(text){
- this.text = text;
- if(this.rendered){
- this.el.update(String.format(
- '<img src="{0}" class="x-menu-item-icon {2}">{1}',
- this.icon || Ext.BLANK_IMAGE_URL, this.text, this.iconCls || ''));
- this.parentMenu.autoWidth();
- }
- },
- setIconClass : function(cls){
- var oldCls = this.iconCls;
- this.iconCls = cls;
- if(this.rendered){
- this.el.child('img.x-menu-item-icon').replaceClass(oldCls, this.iconCls);
- }
- },
- handleClick : function(e){
- if(!this.href){ e.stopEvent();
- }
- Ext.menu.Item.superclass.handleClick.apply(this, arguments);
- },
- activate : function(autoExpand){
- if(Ext.menu.Item.superclass.activate.apply(this, arguments)){
- this.focus();
- if(autoExpand){
- this.expandMenu();
- }
- }
- return true;
- },
- shouldDeactivate : function(e){
- if(Ext.menu.Item.superclass.shouldDeactivate.call(this, e)){
- if(this.menu && this.menu.isVisible()){
- return !this.menu.getEl().getRegion().contains(e.getPoint());
- }
- return true;
- }
- return false;
- },
- deactivate : function(){
- Ext.menu.Item.superclass.deactivate.apply(this, arguments);
- this.hideMenu();
- },
- expandMenu : function(autoActivate){
- if(!this.disabled && this.menu){
- clearTimeout(this.hideTimer);
- delete this.hideTimer;
- if(!this.menu.isVisible() && !this.showTimer){
- this.showTimer = this.deferExpand.defer(this.showDelay, this, [autoActivate]);
- }else if (this.menu.isVisible() && autoActivate){
- this.menu.tryActivate(0, 1);
- }
- }
- },
- deferExpand : function(autoActivate){
- delete this.showTimer;
- this.menu.show(this.container, this.parentMenu.subMenuAlign || "tl-tr?", this.parentMenu);
- if(autoActivate){
- this.menu.tryActivate(0, 1);
- }
- },
- hideMenu : function(){
- clearTimeout(this.showTimer);
- delete this.showTimer;
- if(!this.hideTimer && this.menu && this.menu.isVisible()){
- this.hideTimer = this.deferHide.defer(this.hideDelay, this);
- }
- },
- deferHide : function(){
- delete this.hideTimer;
- this.menu.hide();
- }
- });
- Ext.menu.CheckItem = function(config){
- Ext.menu.CheckItem.superclass.constructor.call(this, config);
- this.addEvents(
- "beforecheckchange" ,
- "checkchange"
- );
- if(this.checkHandler){
- this.on('checkchange', this.checkHandler, this.scope);
- }
- Ext.menu.MenuMgr.registerCheckable(this);
- };
- Ext.extend(Ext.menu.CheckItem, Ext.menu.Item, {
- itemCls : "x-menu-item x-menu-check-item",
- groupClass : "x-menu-group-item",
- checked: false,
- ctype: "Ext.menu.CheckItem",
- onRender : function(c){
- Ext.menu.CheckItem.superclass.onRender.apply(this, arguments);
- if(this.group){
- this.el.addClass(this.groupClass);
- }
- if(this.checked){
- this.checked = false;
- this.setChecked(true, true);
- }
- },
- destroy : function(){
- Ext.menu.MenuMgr.unregisterCheckable(this);
- Ext.menu.CheckItem.superclass.destroy.apply(this, arguments);
- },
- setChecked : function(state, suppressEvent){
- if(this.checked != state && this.fireEvent("beforecheckchange", this, state) !== false){
- if(this.container){
- this.container[state ? "addClass" : "removeClass"]("x-menu-item-checked");
- }
- this.checked = state;
- if(suppressEvent !== true){
- this.fireEvent("checkchange", this, state);
- }
- }
- },
- handleClick : function(e){
- if(!this.disabled && !(this.checked && this.group)){ this.setChecked(!this.checked);
- }
- Ext.menu.CheckItem.superclass.handleClick.apply(this, arguments);
- }
- });