ext-all-debug.js
资源名称:ext-3.1.0.zip [点击查看]
上传用户:dawnssy
上传日期:2022-08-06
资源大小:9345k
文件大小:1167k
源码类别:
JavaScript
开发平台:
JavaScript
- doAutoWidth : function(){
- if(this.el && this.text && this.width === undefined){
- this.el.setWidth('auto');
- if(Ext.isIE7 && Ext.isStrict){
- var ib = this.btnEl;
- if(ib && ib.getWidth() > 20){
- ib.clip();
- ib.setWidth(Ext.util.TextMetrics.measure(ib, this.text).width+ib.getFrameWidth('lr'));
- }
- }
- if(this.minWidth){
- if(this.el.getWidth() < this.minWidth){
- this.el.setWidth(this.minWidth);
- }
- }
- }
- },
- setHandler : function(handler, scope){
- this.handler = handler;
- this.scope = scope;
- return this;
- },
- setText : function(text){
- this.text = text;
- if(this.el){
- this.btnEl.update(text || ' ');
- this.setButtonClass();
- }
- this.doAutoWidth();
- return this;
- },
- setIcon : function(icon){
- this.icon = icon;
- if(this.el){
- this.btnEl.setStyle('background-image', icon ? 'url(' + icon + ')' : '');
- this.setButtonClass();
- }
- return this;
- },
- getText : function(){
- return this.text;
- },
- toggle : function(state, suppressEvent){
- state = state === undefined ? !this.pressed : !!state;
- if(state != this.pressed){
- if(this.rendered){
- this.el[state ? 'addClass' : 'removeClass']('x-btn-pressed');
- }
- this.pressed = state;
- if(!suppressEvent){
- this.fireEvent('toggle', this, state);
- if(this.toggleHandler){
- this.toggleHandler.call(this.scope || this, this, state);
- }
- }
- }
- return this;
- },
- focus : function(){
- this.btnEl.focus();
- },
- onDisable : function(){
- this.onDisableChange(true);
- },
- onEnable : function(){
- this.onDisableChange(false);
- },
- onDisableChange : function(disabled){
- if(this.el){
- if(!Ext.isIE6 || !this.text){
- this.el[disabled ? 'addClass' : 'removeClass'](this.disabledClass);
- }
- this.el.dom.disabled = disabled;
- }
- this.disabled = disabled;
- },
- showMenu : function(){
- if(this.rendered && this.menu){
- if(this.tooltip){
- Ext.QuickTips.getQuickTip().cancelShow(this.btnEl);
- }
- this.menu.show(this.el, this.menuAlign);
- }
- return this;
- },
- hideMenu : function(){
- if(this.menu){
- this.menu.hide();
- }
- return this;
- },
- hasVisibleMenu : function(){
- return this.menu && this.menu.isVisible();
- },
- onClick : function(e){
- if(e){
- e.preventDefault();
- }
- if(e.button !== 0){
- return;
- }
- if(!this.disabled){
- if(this.enableToggle && (this.allowDepress !== false || !this.pressed)){
- this.toggle();
- }
- if(this.menu && !this.menu.isVisible() && !this.ignoreNextClick){
- this.showMenu();
- }
- this.fireEvent('click', this, e);
- if(this.handler){
- this.handler.call(this.scope || this, this, e);
- }
- }
- },
- isMenuTriggerOver : function(e, internal){
- return this.menu && !internal;
- },
- isMenuTriggerOut : function(e, internal){
- return this.menu && !internal;
- },
- onMouseOver : function(e){
- if(!this.disabled){
- var internal = e.within(this.el, true);
- if(!internal){
- this.el.addClass('x-btn-over');
- if(!this.monitoringMouseOver){
- this.doc.on('mouseover', this.monitorMouseOver, this);
- this.monitoringMouseOver = true;
- }
- this.fireEvent('mouseover', this, e);
- }
- if(this.isMenuTriggerOver(e, internal)){
- this.fireEvent('menutriggerover', this, this.menu, e);
- }
- }
- },
- monitorMouseOver : function(e){
- if(e.target != this.el.dom && !e.within(this.el)){
- if(this.monitoringMouseOver){
- this.doc.un('mouseover', this.monitorMouseOver, this);
- this.monitoringMouseOver = false;
- }
- this.onMouseOut(e);
- }
- },
- onMouseOut : function(e){
- var internal = e.within(this.el) && e.target != this.el.dom;
- this.el.removeClass('x-btn-over');
- this.fireEvent('mouseout', this, e);
- if(this.isMenuTriggerOut(e, internal)){
- this.fireEvent('menutriggerout', this, this.menu, e);
- }
- },
- focus : function() {
- this.btnEl.focus();
- },
- blur : function() {
- this.btnEl.blur();
- },
- onFocus : function(e){
- if(!this.disabled){
- this.el.addClass('x-btn-focus');
- }
- },
- onBlur : function(e){
- this.el.removeClass('x-btn-focus');
- },
- getClickEl : function(e, isUp){
- return this.el;
- },
- onMouseDown : function(e){
- if(!this.disabled && e.button === 0){
- this.getClickEl(e).addClass('x-btn-click');
- this.doc.on('mouseup', this.onMouseUp, this);
- }
- },
- onMouseUp : function(e){
- if(e.button === 0){
- this.getClickEl(e, true).removeClass('x-btn-click');
- this.doc.un('mouseup', this.onMouseUp, this);
- }
- },
- onMenuShow : function(e){
- this.menu.ownerCt = this;
- this.ignoreNextClick = 0;
- this.el.addClass('x-btn-menu-active');
- this.fireEvent('menushow', this, this.menu);
- },
- onMenuHide : function(e){
- this.el.removeClass('x-btn-menu-active');
- this.ignoreNextClick = this.restoreClick.defer(250, this);
- this.fireEvent('menuhide', this, this.menu);
- delete this.menu.ownerCt;
- },
- restoreClick : function(){
- this.ignoreNextClick = 0;
- }
- });
- Ext.reg('button', Ext.Button);
- Ext.ButtonToggleMgr = function(){
- var groups = {};
- function toggleGroup(btn, state){
- if(state){
- var g = groups[btn.toggleGroup];
- for(var i = 0, l = g.length; i < l; i++){
- if(g[i] != btn){
- g[i].toggle(false);
- }
- }
- }
- }
- return {
- register : function(btn){
- if(!btn.toggleGroup){
- return;
- }
- var g = groups[btn.toggleGroup];
- if(!g){
- g = groups[btn.toggleGroup] = [];
- }
- g.push(btn);
- btn.on('toggle', toggleGroup);
- },
- unregister : function(btn){
- if(!btn.toggleGroup){
- return;
- }
- var g = groups[btn.toggleGroup];
- if(g){
- g.remove(btn);
- btn.un('toggle', toggleGroup);
- }
- },
- getPressed : function(group){
- var g = groups[group];
- if(g){
- for(var i = 0, len = g.length; i < len; i++){
- if(g[i].pressed === true){
- return g[i];
- }
- }
- }
- return null;
- }
- };
- }();
- Ext.SplitButton = Ext.extend(Ext.Button, {
- arrowSelector : 'em',
- split: true,
- initComponent : function(){
- Ext.SplitButton.superclass.initComponent.call(this);
- this.addEvents("arrowclick");
- },
- onRender : function(){
- Ext.SplitButton.superclass.onRender.apply(this, arguments);
- if(this.arrowTooltip){
- this.el.child(this.arrowSelector).dom[this.tooltipType] = this.arrowTooltip;
- }
- },
- setArrowHandler : function(handler, scope){
- this.arrowHandler = handler;
- this.scope = scope;
- },
- getMenuClass : function(){
- return 'x-btn-split' + (this.arrowAlign == 'bottom' ? '-bottom' : '');
- },
- isClickOnArrow : function(e){
- if (this.arrowAlign != 'bottom') {
- var visBtn = this.el.child('em.x-btn-split');
- var right = visBtn.getRegion().right - visBtn.getPadding('r');
- return e.getPageX() > right;
- } else {
- return e.getPageY() > this.btnEl.getRegion().bottom;
- }
- },
- onClick : function(e, t){
- e.preventDefault();
- if(!this.disabled){
- if(this.isClickOnArrow(e)){
- if(this.menu && !this.menu.isVisible() && !this.ignoreNextClick){
- this.showMenu();
- }
- this.fireEvent("arrowclick", this, e);
- if(this.arrowHandler){
- this.arrowHandler.call(this.scope || this, this, e);
- }
- }else{
- if(this.enableToggle){
- this.toggle();
- }
- this.fireEvent("click", this, e);
- if(this.handler){
- this.handler.call(this.scope || this, this, e);
- }
- }
- }
- },
- isMenuTriggerOver : function(e){
- return this.menu && e.target.tagName == this.arrowSelector;
- },
- isMenuTriggerOut : function(e, internal){
- return this.menu && e.target.tagName != this.arrowSelector;
- }
- });
- Ext.reg('splitbutton', Ext.SplitButton);
- Ext.CycleButton = Ext.extend(Ext.SplitButton, {
- getItemText : function(item){
- if(item && this.showText === true){
- var text = '';
- if(this.prependText){
- text += this.prependText;
- }
- text += item.text;
- return text;
- }
- return undefined;
- },
- setActiveItem : function(item, suppressEvent){
- if(!Ext.isObject(item)){
- item = this.menu.getComponent(item);
- }
- if(item){
- if(!this.rendered){
- this.text = this.getItemText(item);
- this.iconCls = item.iconCls;
- }else{
- var t = this.getItemText(item);
- if(t){
- this.setText(t);
- }
- this.setIconClass(item.iconCls);
- }
- this.activeItem = item;
- if(!item.checked){
- item.setChecked(true, true);
- }
- if(this.forceIcon){
- this.setIconClass(this.forceIcon);
- }
- if(!suppressEvent){
- this.fireEvent('change', this, item);
- }
- }
- },
- getActiveItem : function(){
- return this.activeItem;
- },
- initComponent : function(){
- this.addEvents(
- "change"
- );
- if(this.changeHandler){
- this.on('change', this.changeHandler, this.scope||this);
- delete this.changeHandler;
- }
- this.itemCount = this.items.length;
- this.menu = {cls:'x-cycle-menu', items:[]};
- var checked;
- Ext.each(this.items, function(item, i){
- Ext.apply(item, {
- group: item.group || this.id,
- itemIndex: i,
- checkHandler: this.checkHandler,
- scope: this,
- checked: item.checked || false
- });
- this.menu.items.push(item);
- if(item.checked){
- checked = item;
- }
- }, this);
- this.setActiveItem(checked, true);
- Ext.CycleButton.superclass.initComponent.call(this);
- this.on('click', this.toggleSelected, this);
- },
- checkHandler : function(item, pressed){
- if(pressed){
- this.setActiveItem(item);
- }
- },
- toggleSelected : function(){
- var m = this.menu;
- m.render();
- if(!m.hasLayout){
- m.doLayout();
- }
- var nextIdx, checkItem;
- for (var i = 1; i < this.itemCount; i++) {
- nextIdx = (this.activeItem.itemIndex + i) % this.itemCount;
- checkItem = m.items.itemAt(nextIdx);
- if (!checkItem.disabled) {
- checkItem.setChecked(true);
- break;
- }
- }
- }
- });
- Ext.reg('cycle', Ext.CycleButton);
- Ext.layout.ToolbarLayout = Ext.extend(Ext.layout.ContainerLayout, {
- monitorResize : true,
- triggerWidth : 18,
- lastOverflow : false,
- forceLayout: true,
- noItemsMenuText : '<div class="x-toolbar-no-items">(None)</div>',
- onLayout : function(ct, target){
- if(!this.leftTr){
- var align = ct.buttonAlign == 'center' ? 'center' : 'left';
- target.addClass('x-toolbar-layout-ct');
- target.insertHtml('beforeEnd',
- '<table cellspacing="0" class="x-toolbar-ct"><tbody><tr><td class="x-toolbar-left" align="' + align + '"><table cellspacing="0"><tbody><tr class="x-toolbar-left-row"></tr></tbody></table></td><td class="x-toolbar-right" align="right"><table cellspacing="0" class="x-toolbar-right-ct"><tbody><tr><td><table cellspacing="0"><tbody><tr class="x-toolbar-right-row"></tr></tbody></table></td><td><table cellspacing="0"><tbody><tr class="x-toolbar-extras-row"></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table>');
- this.leftTr = target.child('tr.x-toolbar-left-row', true);
- this.rightTr = target.child('tr.x-toolbar-right-row', true);
- this.extrasTr = target.child('tr.x-toolbar-extras-row', true);
- }
- var side = ct.buttonAlign == 'right' ? this.rightTr : this.leftTr,
- pos = 0,
- items = ct.items.items;
- for(var i = 0, len = items.length, c; i < len; i++, pos++) {
- c = items[i];
- if(c.isFill){
- side = this.rightTr;
- pos = -1;
- }else if(!c.rendered){
- c.render(this.insertCell(c, side, pos));
- }else{
- if(!c.xtbHidden && !this.isValidParent(c, side.childNodes[pos])){
- var td = this.insertCell(c, side, pos);
- td.appendChild(c.getPositionEl().dom);
- c.container = Ext.get(td);
- }
- }
- }
- this.cleanup(this.leftTr);
- this.cleanup(this.rightTr);
- this.cleanup(this.extrasTr);
- this.fitToSize(target);
- },
- cleanup : function(row){
- var cn = row.childNodes;
- for(var i = cn.length-1, c; i >= 0 && (c = cn[i]); i--){
- if(!c.firstChild){
- row.removeChild(c);
- }
- }
- },
- insertCell : function(c, side, pos){
- var td = document.createElement('td');
- td.className='x-toolbar-cell';
- side.insertBefore(td, side.childNodes[pos]||null);
- return td;
- },
- hideItem : function(item){
- var h = (this.hiddens = this.hiddens || []);
- h.push(item);
- item.xtbHidden = true;
- item.xtbWidth = item.getPositionEl().dom.parentNode.offsetWidth;
- item.hide();
- },
- unhideItem : function(item){
- item.show();
- item.xtbHidden = false;
- this.hiddens.remove(item);
- if(this.hiddens.length < 1){
- delete this.hiddens;
- }
- },
- getItemWidth : function(c){
- return c.hidden ? (c.xtbWidth || 0) : c.getPositionEl().dom.parentNode.offsetWidth;
- },
- fitToSize : function(t){
- if(this.container.enableOverflow === false){
- return;
- }
- var w = t.dom.clientWidth,
- lw = this.lastWidth || 0,
- iw = t.dom.firstChild.offsetWidth,
- clipWidth = w - this.triggerWidth,
- hideIndex = -1;
- this.lastWidth = w;
- if(iw > w || (this.hiddens && w >= lw)){
- var i, items = this.container.items.items,
- len = items.length, c,
- loopWidth = 0;
- for(i = 0; i < len; i++) {
- c = items[i];
- if(!c.isFill){
- loopWidth += this.getItemWidth(c);
- if(loopWidth > clipWidth){
- if(!(c.hidden || c.xtbHidden)){
- this.hideItem(c);
- }
- }else if(c.xtbHidden){
- this.unhideItem(c);
- }
- }
- }
- }
- if(this.hiddens){
- this.initMore();
- if(!this.lastOverflow){
- this.container.fireEvent('overflowchange', this.container, true);
- this.lastOverflow = true;
- }
- }else if(this.more){
- this.clearMenu();
- this.more.destroy();
- delete this.more;
- if(this.lastOverflow){
- this.container.fireEvent('overflowchange', this.container, false);
- this.lastOverflow = false;
- }
- }
- },
- createMenuConfig : function(c, hideOnClick){
- var cfg = Ext.apply({}, c.initialConfig),
- group = c.toggleGroup;
- Ext.apply(cfg, {
- text: c.overflowText || c.text,
- iconCls: c.iconCls,
- icon: c.icon,
- itemId: c.itemId,
- disabled: c.disabled,
- handler: c.handler,
- scope: c.scope,
- menu: c.menu,
- hideOnClick: hideOnClick
- });
- if(group || c.enableToggle){
- Ext.apply(cfg, {
- group: group,
- checked: c.pressed,
- listeners: {
- checkchange: function(item, checked){
- c.toggle(checked);
- }
- }
- });
- }
- delete cfg.ownerCt;
- delete cfg.xtype;
- delete cfg.id;
- return cfg;
- },
- addComponentToMenu : function(m, c){
- if(c instanceof Ext.Toolbar.Separator){
- m.add('-');
- }else if(Ext.isFunction(c.isXType)){
- if(c.isXType('splitbutton')){
- m.add(this.createMenuConfig(c, true));
- }else if(c.isXType('button')){
- m.add(this.createMenuConfig(c, !c.menu));
- }else if(c.isXType('buttongroup')){
- c.items.each(function(item){
- this.addComponentToMenu(m, item);
- }, this);
- }
- }
- },
- clearMenu : function(){
- var m = this.moreMenu;
- if(m && m.items){
- m.items.each(function(item){
- delete item.menu;
- });
- }
- },
- beforeMoreShow : function(m){
- var h = this.container.items.items,
- len = h.length,
- c,
- prev,
- needsSep = function(group, item){
- return group.isXType('buttongroup') && !(item instanceof Ext.Toolbar.Separator);
- };
- this.clearMenu();
- m.removeAll();
- for(var i = 0; i < len; i++){
- c = h[i];
- if(c.xtbHidden){
- if(prev && (needsSep(c, prev) || needsSep(prev, c))){
- m.add('-');
- }
- this.addComponentToMenu(m, c);
- prev = c;
- }
- }
- if(m.items.length < 1){
- m.add(this.noItemsMenuText);
- }
- },
- initMore : function(){
- if(!this.more){
- this.moreMenu = new Ext.menu.Menu({
- listeners: {
- beforeshow: this.beforeMoreShow,
- scope: this
- }
- });
- this.moreMenu.ownerCt = this.container;
- this.more = new Ext.Button({
- iconCls: 'x-toolbar-more-icon',
- cls: 'x-toolbar-more',
- menu: this.moreMenu
- });
- var td = this.insertCell(this.more, this.extrasTr, 100);
- this.more.render(td);
- }
- },
- onRemove : function(c){
- delete this.leftTr;
- delete this.rightTr;
- delete this.extrasTr;
- Ext.layout.ToolbarLayout.superclass.onRemove.call(this, c);
- },
- destroy : function(){
- Ext.destroy(this.more, this.moreMenu);
- delete this.leftTr;
- delete this.rightTr;
- delete this.extrasTr;
- Ext.layout.ToolbarLayout.superclass.destroy.call(this);
- }
- });
- Ext.Container.LAYOUTS.toolbar = Ext.layout.ToolbarLayout;
- Ext.Toolbar = function(config){
- if(Ext.isArray(config)){
- config = {items: config, layout: 'toolbar'};
- } else {
- config = Ext.apply({
- layout: 'toolbar'
- }, config);
- if(config.buttons) {
- config.items = config.buttons;
- }
- }
- Ext.Toolbar.superclass.constructor.call(this, config);
- };
- (function(){
- var T = Ext.Toolbar;
- Ext.extend(T, Ext.Container, {
- defaultType: 'button',
- trackMenus : true,
- internalDefaults: {removeMode: 'container', hideParent: true},
- toolbarCls: 'x-toolbar',
- initComponent : function(){
- T.superclass.initComponent.call(this);
- this.addEvents('overflowchange');
- },
- onRender : function(ct, position){
- if(!this.el){
- if(!this.autoCreate){
- this.autoCreate = {
- cls: this.toolbarCls + ' x-small-editor'
- };
- }
- this.el = ct.createChild(Ext.apply({ id: this.id },this.autoCreate), position);
- Ext.Toolbar.superclass.onRender.apply(this, arguments);
- }
- },
- lookupComponent : function(c){
- if(Ext.isString(c)){
- if(c == '-'){
- c = new T.Separator();
- }else if(c == ' '){
- c = new T.Spacer();
- }else if(c == '->'){
- c = new T.Fill();
- }else{
- c = new T.TextItem(c);
- }
- this.applyDefaults(c);
- }else{
- if(c.isFormField || c.render){
- c = this.createComponent(c);
- }else if(c.tag){
- c = new T.Item({autoEl: c});
- }else if(c.tagName){
- c = new T.Item({el:c});
- }else if(Ext.isObject(c)){
- c = c.xtype ? this.createComponent(c) : this.constructButton(c);
- }
- }
- return c;
- },
- applyDefaults : function(c){
- if(!Ext.isString(c)){
- c = Ext.Toolbar.superclass.applyDefaults.call(this, c);
- var d = this.internalDefaults;
- if(c.events){
- Ext.applyIf(c.initialConfig, d);
- Ext.apply(c, d);
- }else{
- Ext.applyIf(c, d);
- }
- }
- return c;
- },
- addSeparator : function(){
- return this.add(new T.Separator());
- },
- addSpacer : function(){
- return this.add(new T.Spacer());
- },
- addFill : function(){
- this.add(new T.Fill());
- },
- addElement : function(el){
- return this.addItem(new T.Item({el:el}));
- },
- addItem : function(item){
- return this.add.apply(this, arguments);
- },
- addButton : function(config){
- if(Ext.isArray(config)){
- var buttons = [];
- for(var i = 0, len = config.length; i < len; i++) {
- buttons.push(this.addButton(config[i]));
- }
- return buttons;
- }
- return this.add(this.constructButton(config));
- },
- addText : function(text){
- return this.addItem(new T.TextItem(text));
- },
- addDom : function(config){
- return this.add(new T.Item({autoEl: config}));
- },
- addField : function(field){
- return this.add(field);
- },
- insertButton : function(index, item){
- if(Ext.isArray(item)){
- var buttons = [];
- for(var i = 0, len = item.length; i < len; i++) {
- buttons.push(this.insertButton(index + i, item[i]));
- }
- return buttons;
- }
- return Ext.Toolbar.superclass.insert.call(this, index, item);
- },
- trackMenu : function(item, remove){
- if(this.trackMenus && item.menu){
- var method = remove ? 'mun' : 'mon';
- this[method](item, 'menutriggerover', this.onButtonTriggerOver, this);
- this[method](item, 'menushow', this.onButtonMenuShow, this);
- this[method](item, 'menuhide', this.onButtonMenuHide, this);
- }
- },
- constructButton : function(item){
- var b = item.events ? item : this.createComponent(item, item.split ? 'splitbutton' : this.defaultType);
- return b;
- },
- onAdd : function(c){
- Ext.Toolbar.superclass.onAdd.call(this);
- this.trackMenu(c);
- },
- onRemove : function(c){
- Ext.Toolbar.superclass.onRemove.call(this);
- this.trackMenu(c, true);
- },
- onDisable : function(){
- this.items.each(function(item){
- if(item.disable){
- item.disable();
- }
- });
- },
- onEnable : function(){
- this.items.each(function(item){
- if(item.enable){
- item.enable();
- }
- });
- },
- onButtonTriggerOver : function(btn){
- if(this.activeMenuBtn && this.activeMenuBtn != btn){
- this.activeMenuBtn.hideMenu();
- btn.showMenu();
- this.activeMenuBtn = btn;
- }
- },
- onButtonMenuShow : function(btn){
- this.activeMenuBtn = btn;
- },
- onButtonMenuHide : function(btn){
- delete this.activeMenuBtn;
- }
- });
- Ext.reg('toolbar', Ext.Toolbar);
- T.Item = Ext.extend(Ext.BoxComponent, {
- hideParent: true,
- enable:Ext.emptyFn,
- disable:Ext.emptyFn,
- focus:Ext.emptyFn
- });
- Ext.reg('tbitem', T.Item);
- T.Separator = Ext.extend(T.Item, {
- onRender : function(ct, position){
- this.el = ct.createChild({tag:'span', cls:'xtb-sep'}, position);
- }
- });
- Ext.reg('tbseparator', T.Separator);
- T.Spacer = Ext.extend(T.Item, {
- onRender : function(ct, position){
- this.el = ct.createChild({tag:'div', cls:'xtb-spacer', style: this.width?'width:'+this.width+'px':''}, position);
- }
- });
- Ext.reg('tbspacer', T.Spacer);
- T.Fill = Ext.extend(T.Item, {
- render : Ext.emptyFn,
- isFill : true
- });
- Ext.reg('tbfill', T.Fill);
- T.TextItem = Ext.extend(T.Item, {
- constructor: function(config){
- T.TextItem.superclass.constructor.call(this, Ext.isString(config) ? {text: config} : config);
- },
- onRender : function(ct, position) {
- this.autoEl = {cls: 'xtb-text', html: this.text || ''};
- T.TextItem.superclass.onRender.call(this, ct, position);
- },
- setText : function(t) {
- if(this.rendered){
- this.el.update(t);
- }else{
- this.text = t;
- }
- }
- });
- Ext.reg('tbtext', T.TextItem);
- T.Button = Ext.extend(Ext.Button, {});
- T.SplitButton = Ext.extend(Ext.SplitButton, {});
- Ext.reg('tbbutton', T.Button);
- Ext.reg('tbsplit', T.SplitButton);
- })();
- Ext.ButtonGroup = Ext.extend(Ext.Panel, {
- baseCls: 'x-btn-group',
- layout:'table',
- defaultType: 'button',
- frame: true,
- internalDefaults: {removeMode: 'container', hideParent: true},
- initComponent : function(){
- this.layoutConfig = this.layoutConfig || {};
- Ext.applyIf(this.layoutConfig, {
- columns : this.columns
- });
- if(!this.title){
- this.addClass('x-btn-group-notitle');
- }
- this.on('afterlayout', this.onAfterLayout, this);
- Ext.ButtonGroup.superclass.initComponent.call(this);
- },
- applyDefaults : function(c){
- c = Ext.ButtonGroup.superclass.applyDefaults.call(this, c);
- var d = this.internalDefaults;
- if(c.events){
- Ext.applyIf(c.initialConfig, d);
- Ext.apply(c, d);
- }else{
- Ext.applyIf(c, d);
- }
- return c;
- },
- onAfterLayout : function(){
- var bodyWidth = this.body.getFrameWidth('lr') + this.body.dom.firstChild.offsetWidth;
- this.body.setWidth(bodyWidth);
- this.el.setWidth(bodyWidth + this.getFrameWidth());
- }
- });
- Ext.reg('buttongroup', Ext.ButtonGroup);
- (function() {
- var T = Ext.Toolbar;
- Ext.PagingToolbar = Ext.extend(Ext.Toolbar, {
- pageSize : 20,
- displayMsg : 'Displaying {0} - {1} of {2}',
- emptyMsg : 'No data to display',
- beforePageText : 'Page',
- afterPageText : 'of {0}',
- firstText : 'First Page',
- prevText : 'Previous Page',
- nextText : 'Next Page',
- lastText : 'Last Page',
- refreshText : 'Refresh',
- initComponent : function(){
- var pagingItems = [this.first = new T.Button({
- tooltip: this.firstText,
- overflowText: this.firstText,
- iconCls: 'x-tbar-page-first',
- disabled: true,
- handler: this.moveFirst,
- scope: this
- }), this.prev = new T.Button({
- tooltip: this.prevText,
- overflowText: this.prevText,
- iconCls: 'x-tbar-page-prev',
- disabled: true,
- handler: this.movePrevious,
- scope: this
- }), '-', this.beforePageText,
- this.inputItem = new Ext.form.NumberField({
- cls: 'x-tbar-page-number',
- allowDecimals: false,
- allowNegative: false,
- enableKeyEvents: true,
- selectOnFocus: true,
- submitValue: false,
- listeners: {
- scope: this,
- keydown: this.onPagingKeyDown,
- blur: this.onPagingBlur
- }
- }), this.afterTextItem = new T.TextItem({
- text: String.format(this.afterPageText, 1)
- }), '-', this.next = new T.Button({
- tooltip: this.nextText,
- overflowText: this.nextText,
- iconCls: 'x-tbar-page-next',
- disabled: true,
- handler: this.moveNext,
- scope: this
- }), this.last = new T.Button({
- tooltip: this.lastText,
- overflowText: this.lastText,
- iconCls: 'x-tbar-page-last',
- disabled: true,
- handler: this.moveLast,
- scope: this
- }), '-', this.refresh = new T.Button({
- tooltip: this.refreshText,
- overflowText: this.refreshText,
- iconCls: 'x-tbar-loading',
- handler: this.doRefresh,
- scope: this
- })];
- var userItems = this.items || this.buttons || [];
- if (this.prependButtons) {
- this.items = userItems.concat(pagingItems);
- }else{
- this.items = pagingItems.concat(userItems);
- }
- delete this.buttons;
- if(this.displayInfo){
- this.items.push('->');
- this.items.push(this.displayItem = new T.TextItem({}));
- }
- Ext.PagingToolbar.superclass.initComponent.call(this);
- this.addEvents(
- 'change',
- 'beforechange'
- );
- this.on('afterlayout', this.onFirstLayout, this, {single: true});
- this.cursor = 0;
- this.bindStore(this.store, true);
- },
- onFirstLayout : function(){
- if(this.dsLoaded){
- this.onLoad.apply(this, this.dsLoaded);
- }
- },
- updateInfo : function(){
- if(this.displayItem){
- var count = this.store.getCount();
- var msg = count == 0 ?
- this.emptyMsg :
- String.format(
- this.displayMsg,
- this.cursor+1, this.cursor+count, this.store.getTotalCount()
- );
- this.displayItem.setText(msg);
- }
- },
- onLoad : function(store, r, o){
- if(!this.rendered){
- this.dsLoaded = [store, r, o];
- return;
- }
- var p = this.getParams();
- this.cursor = (o.params && o.params[p.start]) ? o.params[p.start] : 0;
- var d = this.getPageData(), ap = d.activePage, ps = d.pages;
- this.afterTextItem.setText(String.format(this.afterPageText, d.pages));
- this.inputItem.setValue(ap);
- this.first.setDisabled(ap == 1);
- this.prev.setDisabled(ap == 1);
- this.next.setDisabled(ap == ps);
- this.last.setDisabled(ap == ps);
- this.refresh.enable();
- this.updateInfo();
- this.fireEvent('change', this, d);
- },
- getPageData : function(){
- var total = this.store.getTotalCount();
- return {
- total : total,
- activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
- pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
- };
- },
- changePage : function(page){
- this.doLoad(((page-1) * this.pageSize).constrain(0, this.store.getTotalCount()));
- },
- onLoadError : function(){
- if(!this.rendered){
- return;
- }
- this.refresh.enable();
- },
- readPage : function(d){
- var v = this.inputItem.getValue(), pageNum;
- if (!v || isNaN(pageNum = parseInt(v, 10))) {
- this.inputItem.setValue(d.activePage);
- return false;
- }
- return pageNum;
- },
- onPagingFocus : function(){
- this.inputItem.select();
- },
- onPagingBlur : function(e){
- this.inputItem.setValue(this.getPageData().activePage);
- },
- onPagingKeyDown : function(field, e){
- var k = e.getKey(), d = this.getPageData(), pageNum;
- if (k == e.RETURN) {
- e.stopEvent();
- pageNum = this.readPage(d);
- if(pageNum !== false){
- pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
- this.doLoad(pageNum * this.pageSize);
- }
- }else if (k == e.HOME || k == e.END){
- e.stopEvent();
- pageNum = k == e.HOME ? 1 : d.pages;
- field.setValue(pageNum);
- }else if (k == e.UP || k == e.PAGEUP || k == e.DOWN || k == e.PAGEDOWN){
- e.stopEvent();
- if((pageNum = this.readPage(d))){
- var increment = e.shiftKey ? 10 : 1;
- if(k == e.DOWN || k == e.PAGEDOWN){
- increment *= -1;
- }
- pageNum += increment;
- if(pageNum >= 1 & pageNum <= d.pages){
- field.setValue(pageNum);
- }
- }
- }
- },
- getParams : function(){
- return this.paramNames || this.store.paramNames;
- },
- beforeLoad : function(){
- if(this.rendered && this.refresh){
- this.refresh.disable();
- }
- },
- doLoad : function(start){
- var o = {}, pn = this.getParams();
- o[pn.start] = start;
- o[pn.limit] = this.pageSize;
- if(this.fireEvent('beforechange', this, o) !== false){
- this.store.load({params:o});
- }
- },
- moveFirst : function(){
- this.doLoad(0);
- },
- movePrevious : function(){
- this.doLoad(Math.max(0, this.cursor-this.pageSize));
- },
- moveNext : function(){
- this.doLoad(this.cursor+this.pageSize);
- },
- moveLast : function(){
- var total = this.store.getTotalCount(),
- extra = total % this.pageSize;
- this.doLoad(extra ? (total - extra) : total - this.pageSize);
- },
- doRefresh : function(){
- this.doLoad(this.cursor);
- },
- bindStore : function(store, initial){
- var doLoad;
- if(!initial && this.store){
- if(store !== this.store && this.store.autoDestroy){
- this.store.destroy();
- }else{
- this.store.un('beforeload', this.beforeLoad, this);
- this.store.un('load', this.onLoad, this);
- this.store.un('exception', this.onLoadError, this);
- }
- if(!store){
- this.store = null;
- }
- }
- if(store){
- store = Ext.StoreMgr.lookup(store);
- store.on({
- scope: this,
- beforeload: this.beforeLoad,
- load: this.onLoad,
- exception: this.onLoadError
- });
- doLoad = true;
- }
- this.store = store;
- if(doLoad){
- this.onLoad(store, null, {});
- }
- },
- unbind : function(store){
- this.bindStore(null);
- },
- bind : function(store){
- this.bindStore(store);
- },
- onDestroy : function(){
- this.bindStore(null);
- Ext.PagingToolbar.superclass.onDestroy.call(this);
- }
- });
- })();
- Ext.reg('paging', Ext.PagingToolbar);
- Ext.History = (function () {
- var iframe, hiddenField;
- var ready = false;
- var currentToken;
- function getHash() {
- var href = top.location.href, i = href.indexOf("#");
- return i >= 0 ? href.substr(i + 1) : null;
- }
- function doSave() {
- hiddenField.value = currentToken;
- }
- function handleStateChange(token) {
- currentToken = token;
- Ext.History.fireEvent('change', token);
- }
- function updateIFrame (token) {
- var html = ['<html><body><div id="state">',Ext.util.Format.htmlEncode(token),'</div></body></html>'].join('');
- try {
- var doc = iframe.contentWindow.document;
- doc.open();
- doc.write(html);
- doc.close();
- return true;
- } catch (e) {
- return false;
- }
- }
- function checkIFrame() {
- if (!iframe.contentWindow || !iframe.contentWindow.document) {
- setTimeout(checkIFrame, 10);
- return;
- }
- var doc = iframe.contentWindow.document;
- var elem = doc.getElementById("state");
- var token = elem ? elem.innerText : null;
- var hash = getHash();
- setInterval(function () {
- doc = iframe.contentWindow.document;
- elem = doc.getElementById("state");
- var newtoken = elem ? elem.innerText : null;
- var newHash = getHash();
- if (newtoken !== token) {
- token = newtoken;
- handleStateChange(token);
- top.location.hash = token;
- hash = token;
- doSave();
- } else if (newHash !== hash) {
- hash = newHash;
- updateIFrame(newHash);
- }
- }, 50);
- ready = true;
- Ext.History.fireEvent('ready', Ext.History);
- }
- function startUp() {
- currentToken = hiddenField.value ? hiddenField.value : getHash();
- if (Ext.isIE) {
- checkIFrame();
- } else {
- var hash = getHash();
- setInterval(function () {
- var newHash = getHash();
- if (newHash !== hash) {
- hash = newHash;
- handleStateChange(hash);
- doSave();
- }
- }, 50);
- ready = true;
- Ext.History.fireEvent('ready', Ext.History);
- }
- }
- return {
- fieldId: 'x-history-field',
- iframeId: 'x-history-frame',
- events:{},
- init: function (onReady, scope) {
- if(ready) {
- Ext.callback(onReady, scope, [this]);
- return;
- }
- if(!Ext.isReady){
- Ext.onReady(function(){
- Ext.History.init(onReady, scope);
- });
- return;
- }
- hiddenField = Ext.getDom(Ext.History.fieldId);
- if (Ext.isIE) {
- iframe = Ext.getDom(Ext.History.iframeId);
- }
- this.addEvents(
- 'ready',
- 'change'
- );
- if(onReady){
- this.on('ready', onReady, scope, {single:true});
- }
- startUp();
- },
- add: function (token, preventDup) {
- if(preventDup !== false){
- if(this.getToken() == token){
- return true;
- }
- }
- if (Ext.isIE) {
- return updateIFrame(token);
- } else {
- top.location.hash = token;
- return true;
- }
- },
- back: function(){
- history.go(-1);
- },
- forward: function(){
- history.go(1);
- },
- getToken: function() {
- return ready ? currentToken : getHash();
- }
- };
- })();
- Ext.apply(Ext.History, new Ext.util.Observable());
- 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,
- closeAction: 'hide',
- 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[this.closeAction],
- scope: this
- });
- }
- },
- showAt : function(xy){
- Ext.Tip.superclass.show.call(this);
- if(this.measureWidth !== false && (!this.initialConfig || typeof this.initialConfig.width != 'number')){
- this.doAutoWidth();
- }
- if(this.constrainPosition){
- xy = this.el.adjustForConstraints(xy);
- }
- this.setPagePosition(xy[0], xy[1]);
- },
- doAutoWidth : function(adjust){
- adjust = adjust || 0;
- 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") + adjust;
- this.setWidth(bw.constrain(this.minWidth, this.maxWidth));
- if(Ext.isIE7 && !this.repainted){
- this.el.repaint();
- this.repainted = true;
- }
- },
- 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.reg('tip', Ext.Tip);
- 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,
- trackMouse : false,
- anchorToTarget : true,
- anchorOffset : 0,
- targetCounter : 0,
- constrainPosition : false,
- initComponent : function(){
- Ext.ToolTip.superclass.initComponent.call(this);
- this.lastActive = new Date();
- this.initTarget(this.target);
- this.origAnchor = this.anchor;
- },
- onRender : function(ct, position){
- Ext.ToolTip.superclass.onRender.call(this, ct, position);
- this.anchorCls = 'x-tip-anchor-' + this.getAnchorPosition();
- this.anchorEl = this.el.createChild({
- cls: 'x-tip-anchor ' + this.anchorCls
- });
- },
- afterRender : function(){
- Ext.ToolTip.superclass.afterRender.call(this);
- this.anchorEl.setStyle('z-index', this.el.getZIndex() + 1);
- },
- initTarget : function(target){
- var t;
- if((t = Ext.get(target))){
- if(this.target){
- var tg = Ext.get(this.target);
- this.mun(tg, 'mouseover', this.onTargetOver, this);
- this.mun(tg, 'mouseout', this.onTargetOut, this);
- this.mun(tg, '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;
- }
- },
- 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();
- }
- },
- getTargetXY : function(){
- if(this.delegate){
- this.anchorTarget = this.triggerElement;
- }
- if(this.anchor){
- this.targetCounter++;
- var offsets = this.getOffsets(),
- xy = (this.anchorToTarget && !this.trackMouse) ? this.el.getAlignToXY(this.anchorTarget, this.getAnchorAlign()) : this.targetXY,
- dw = Ext.lib.Dom.getViewWidth() - 5,
- dh = Ext.lib.Dom.getViewHeight() - 5,
- de = document.documentElement,
- bd = document.body,
- scrollX = (de.scrollLeft || bd.scrollLeft || 0) + 5,
- scrollY = (de.scrollTop || bd.scrollTop || 0) + 5,
- axy = [xy[0] + offsets[0], xy[1] + offsets[1]]
- 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;
- },
- 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';
- },
- getAnchorAlign : function(){
- switch(this.anchor){
- case 'top' : return 'tl-bl';
- case 'left' : return 'tl-tr';
- case 'right': return 'tr-tl';
- default : return 'bl-tl';
- }
- },
- 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;
- },
- 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();
- }
- },
- 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();
- if(this.anchorEl){
- this.anchorEl.hide();
- }
- Ext.ToolTip.superclass.hide.call(this);
- delete this.triggerElement;
- },
- show : function(){
- if(this.anchor){
- 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();
- }
- },
- 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);
- }
- if(this.anchor && !this.anchorEl.isVisible()){
- this.syncAnchor();
- this.anchorEl.show();
- }
- },
- 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);
- },
- setPagePosition : function(x, y){
- Ext.ToolTip.superclass.setPagePosition.call(this, x, y);
- if(this.anchor){
- this.syncAnchor();
- }
- },
- 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 !== true && !this.closable && !e.within(this.el.dom)){
- this.disable();
- this.enable.defer(100, this);
- }
- },
- onDisable : function(){
- this.clearTimers();
- this.hide();
- },
- 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};
- },
- beforeDestroy : function(){
- this.clearTimers();
- Ext.destroy(this.anchorEl);
- delete this.anchorEl;
- delete this.target;
- delete this.anchorTarget;
- delete this.triggerElement;
- Ext.ToolTip.superclass.beforeDestroy.call(this);
- },
- onDestroy : function(){
- Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
- Ext.ToolTip.superclass.onDestroy.call(this);
- }
- });
- Ext.reg('tooltip', Ext.ToolTip);
- 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",
- anchor : "anchor"
- },
- 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)];
- },
- 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');
- }
- },
- getTipCfg: function(e) {
- var t = e.getTarget(),
- ttp,
- cfg;
- if(this.interceptTitles && t.title && Ext.isString(t.title)){
- ttp = t.title;
- t.qtip = ttp;
- t.removeAttribute("title");
- e.preventDefault();
- }else{
- cfg = this.tagConfig;
- ttp = t.qtip || Ext.fly(t).getAttribute(cfg.attribute, cfg.namespace);
- }
- return ttp;
- },
- 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) || Ext.fly(this.activeTarget.el).contains(t))){
- 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, ns = cfg.namespace;
- if(ttp = this.getTipCfg(e)){
- 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();
- }
- },
- onTargetOut : function(e){
- if (this.activeTarget && e.within(this.activeTarget.el) && !this.getTipCfg(e)) {
- return;
- }
- 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(this.anchor){
- this.constrainPosition = false;
- }else 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.reg('quicktip', Ext.QuickTip);
- Ext.QuickTips = function(){
- var tip, locks = [];
- return {
- 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 : function(){
- if(tip){
- locks.pop();
- if(locks.length < 1){
- tip.enable();
- }
- }
- },
- disable : function(){
- if(tip){
- tip.disable();
- }
- locks.push(1);
- },
- isEnabled : function(){
- return tip !== undefined && !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 : '/',
- bubbleEvents : [],
- initComponent : function(){
- Ext.tree.TreePanel.superclass.initComponent.call(this);
- if(!this.eventModel){
- this.eventModel = new Ext.tree.TreeEventModel(this);
- }
- var l = this.loader;
- if(!l){
- l = new Ext.tree.TreeLoader({
- dataUrl: this.dataUrl,
- requestMethod: this.requestMethod
- });
- }else if(Ext.isObject(l) && !l.load){
- l = new Ext.tree.TreeLoader(l);
- }
- this.loader = l;
- this.nodeHash = {};
- if(this.root){
- var r = this.root;
- delete this.root;
- this.setRootNode(r);
- }
- this.addEvents(
- 'append',
- 'remove',
- 'movenode',
- 'insert',
- 'beforeappend',
- 'beforeremove',
- 'beforemovenode',
- 'beforeinsert',
- 'beforeload',
- 'load',
- 'textchange',
- 'beforeexpandnode',
- 'beforecollapsenode',
- 'expandnode',
- 'disabledchange',
- 'collapsenode',
- 'beforeclick',
- 'click',
- 'containerclick',
- 'checkchange',
- 'beforedblclick',
- 'dblclick',
- 'containerdblclick',
- 'contextmenu',
- 'containercontextmenu',
- '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){
- Ext.destroy(this.root);
- if(!node.render){
- 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;
- },
- 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;
- },
- 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),
- v = keys.pop();
- if(keys.length > 1){
- 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();
- }
- },
- beforeDestroy : function(){
- if(this.rendered){
- Ext.dd.ScrollManager.unregister(this.body);
- Ext.destroy(this.dropZone, this.dragZone);
- }
- Ext.destroy(this.root, this.loader);
- this.nodeHash = this.root = this.loader = null;
- Ext.tree.TreePanel.superclass.beforeDestroy.call(this);
- }
- });
- 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);
- }
- Ext.tree.TreeEventModel.prototype = {
- initEvents : function(){
- var t = this.tree;
- if(t.trackMouseOver !== false){
- t.mon(t.innerCt, {
- scope: this,
- mouseover: this.delegateOver,
- mouseout: this.delegateOut
- });
- }
- t.mon(t.getTreeEl(), {
- scope: this,
- click: this.delegateClick,
- dblclick: this.delegateDblClick,
- contextmenu: this.delegateContextMenu
- });
- },
- getNode : function(e){
- var t;
- if(t = e.getTarget('.x-tree-node-el', 10)){
- var id = Ext.fly(t, '_treeEvents').getAttribute('tree-node-id', 'ext');
- 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(Ext.isGecko && !this.trackingDoc){
- Ext.getBody().on('mouseover', this.trackExit, this);
- this.trackingDoc = true;
- }
- 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));
- }
- },
- trackExit : function(e){
- if(this.lastOverNode && !e.within(this.lastOverNode.ui.getEl())){
- this.onNodeOut(e, this.lastOverNode);
- delete this.lastOverNode;
- Ext.getBody().un('mouseover', this.trackExit, this);
- this.trackingDoc = false;
- }
- },
- delegateClick : function(e, t){
- if(this.beforeEvent(e)){
- 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));
- }else{
- this.onContainerEvent(e, 'click');
- }
- }
- },
- delegateDblClick : function(e, t){
- if(this.beforeEvent(e)){
- if(this.getNodeTarget(e)){
- this.onNodeDblClick(e, this.getNode(e));
- }else{
- this.onContainerEvent(e, 'dblclick');
- }
- }
- },
- delegateContextMenu : function(e, t){
- if(this.beforeEvent(e)){
- if(this.getNodeTarget(e)){
- this.onNodeContextMenu(e, this.getNode(e));
- }else{
- this.onContainerEvent(e, 'contextmenu');
- }
- }
- },
- onContainerEvent: function(e, type){
- this.tree.fireEvent('container' + type, this.tree, e);
- },
- onNodeClick : function(e, node){
- node.ui.onClick(e);
- },
- onNodeOver : function(e, node){
- this.lastOverNode = 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.mon(tree.getTreeEl(), 'keydown', this.onKeyDown, this);
- tree.on('click', this.onNodeClick, this);
- },
- onNodeClick : function(node, e){
- this.select(node);
- },
- select : function(node, selectNextNode){
- if (!Ext.fly(node.ui.wrap).isVisible() && selectNextNode) {
- return selectNextNode.call(this, node);
- }
- var last = this.selNode;
- if(node == last){
- node.ui.onSelectedChange(true);
- }else if(this.fireEvent('beforeselect', this, node, last) !== false){
- if(last && last.ui){
- last.ui.onSelectedChange(false);
- }
- this.selNode = node;
- node.ui.onSelectedChange(true);
- this.fireEvent('selectionchange', this, node, last);
- }
- return node;
- },
- unselect : function(node, silent){
- if(this.selNode == node){
- this.clearSelections(silent);
- }
- },
- clearSelections : function(silent){
- var n = this.selNode;
- if(n){
- n.ui.onSelectedChange(false);
- this.selNode = null;
- if(silent !== true){
- this.fireEvent('selectionchange', this, null);
- }
- }
- return n;
- },
- getSelectedNode : function(){
- return this.selNode;
- },
- isSelected : function(node){
- return this.selNode == node;
- },
- selectPrevious : function( s){
- if(!(s = s || this.selNode || this.lastSelNode)){
- return null;
- }
- var ps = s.previousSibling;
- if(ps){
- if(!ps.isExpanded() || ps.childNodes.length < 1){
- return this.select(ps, this.selectPrevious);
- } else{
- var lc = ps.lastChild;
- while(lc && lc.isExpanded() && Ext.fly(lc.ui.wrap).isVisible() && lc.childNodes.length > 0){
- lc = lc.lastChild;
- }
- return this.select(lc, this.selectPrevious);
- }
- } else if(s.parentNode && (this.tree.rootVisible || !s.parentNode.isRoot)){
- return this.select(s.parentNode, this.selectPrevious);
- }
- return null;
- },
- selectNext : function( s){
- if(!(s = s || this.selNode || this.lastSelNode)){
- return null;
- }
- if(s.firstChild && s.isExpanded() && Ext.fly(s.ui.wrap).isVisible()){
- return this.select(s.firstChild, this.selectNext);
- }else if(s.nextSibling){
- return this.select(s.nextSibling, this.selectNext);
- }else if(s.parentNode){
- var newS = null;
- s.parentNode.bubble(function(){
- if(this.nextSibling){
- newS = this.getOwnerTree().selModel.select(this.nextSibling, this.selectNext);
- 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.mon(tree.getTreeEl(), 'keydown', this.onKeyDown, this);
- tree.on('click', this.onNodeClick, this);
- },
- onNodeClick : function(node, e){
- if(e.ctrlKey && this.isSelected(node)){
- this.unselect(node);
- }else{
- 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.data.Tree = function(root){
- this.nodeHash = {};
- this.root = null;
- if(root){
- this.setRootNode(root);
- }
- this.addEvents(
- "append",
- "remove",
- "move",
- "insert",
- "beforeappend",
- "beforeremove",
- "beforemove",
- "beforeinsert"
- );
- Ext.data.Tree.superclass.constructor.call(this);
- };
- Ext.extend(Ext.data.Tree, Ext.util.Observable, {
- pathSeparator: "/",
- proxyNodeEvent : function(){
- return this.fireEvent.apply(this, arguments);
- },
- getRootNode : function(){
- return this.root;
- },
- setRootNode : function(node){
- this.root = node;
- node.ownerTree = this;
- node.isRoot = true;
- this.registerNode(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:"")+"]";
- }
- });
- Ext.data.Node = function(attributes){
- this.attributes = attributes || {};
- this.leaf = this.attributes.leaf;
- this.id = this.attributes.id;
- if(!this.id){
- this.id = Ext.id(null, "xnode-");
- this.attributes.id = this.id;
- }
- this.childNodes = [];
- if(!this.childNodes.indexOf){
- this.childNodes.indexOf = function(o){
- for(var i = 0, len = this.length; i < len; i++){
- if(this[i] == o){
- return i;
- }
- }
- return -1;
- };
- }
- this.parentNode = null;
- this.firstChild = null;
- this.lastChild = null;
- this.previousSibling = null;
- this.nextSibling = null;
- this.addEvents({
- "append" : true,
- "remove" : true,
- "move" : true,
- "insert" : true,
- "beforeappend" : true,
- "beforeremove" : true,
- "beforemove" : true,
- "beforeinsert" : true
- });
- this.listeners = this.attributes.listeners;
- Ext.data.Node.superclass.constructor.call(this);
- };
- Ext.extend(Ext.data.Node, Ext.util.Observable, {
- fireEvent : function(evtName){
- if(Ext.data.Node.superclass.fireEvent.apply(this, arguments) === false){
- return false;
- }
- var ot = this.getOwnerTree();
- if(ot){
- if(ot.proxyNodeEvent.apply(ot, arguments) === false){
- return false;
- }
- }
- return true;
- },
- isLeaf : function(){
- return this.leaf === true;
- },
- setFirstChild : function(node){
- this.firstChild = node;
- },
- setLastChild : function(node){
- this.lastChild = node;
- },
- isLast : function(){
- return (!this.parentNode ? true : this.parentNode.lastChild == this);
- },
- isFirst : function(){
- return (!this.parentNode ? true : this.parentNode.firstChild == this);
- },
- hasChildNodes : function(){
- return !this.isLeaf() && this.childNodes.length > 0;
- },
- isExpandable : function(){
- return this.attributes.expandable || this.hasChildNodes();
- },
- appendChild : function(node){
- var multi = false;
- if(Ext.isArray(node)){
- multi = node;
- }else if(arguments.length > 1){
- multi = arguments;
- }
- if(multi){
- for(var i = 0, len = multi.length; i < len; i++) {
- this.appendChild(multi[i]);
- }
- }else{
- if(this.fireEvent("beforeappend", this.ownerTree, this, node) === false){
- return false;
- }
- var index = this.childNodes.length;
- var oldParent = node.parentNode;
- if(oldParent){
- if(node.fireEvent("beforemove", node.getOwnerTree(), node, oldParent, this, index) === false){
- return false;
- }
- oldParent.removeChild(node);
- }
- index = this.childNodes.length;
- if(index === 0){
- this.setFirstChild(node);
- }
- this.childNodes.push(node);
- node.parentNode = this;
- var ps = this.childNodes[index-1];
- if(ps){
- node.previousSibling = ps;
- ps.nextSibling = node;
- }else{
- node.previousSibling = null;
- }
- node.nextSibling = null;
- this.setLastChild(node);
- node.setOwnerTree(this.getOwnerTree());
- this.fireEvent("append", this.ownerTree, this, node, index);
- if(oldParent){
- node.fireEvent("move", this.ownerTree, node, oldParent, this, index);
- }
- return node;
- }
- },
- removeChild : function(node, destroy){
- var index = this.childNodes.indexOf(node);
- if(index == -1){
- return false;
- }
- if(this.fireEvent("beforeremove", this.ownerTree, this, node) === false){
- return false;
- }
- this.childNodes.splice(index, 1);
- if(node.previousSibling){
- node.previousSibling.nextSibling = node.nextSibling;
- }
- if(node.nextSibling){
- node.nextSibling.previousSibling = node.previousSibling;
- }
- if(this.firstChild == node){
- this.setFirstChild(node.nextSibling);
- }
- if(this.lastChild == node){
- this.setLastChild(node.previousSibling);
- }
- node.clear();
- this.fireEvent("remove", this.ownerTree, this, node);
- if(destroy){
- node.destroy();
- }
- return node;
- },
- clear : function(destroy){
- this.setOwnerTree(null, destroy);
- this.parentNode = this.previousSibling = this.nextSibling = null
- if(destroy){
- this.firstChild = this.lastChild = null;
- }
- },
- destroy : function(){
- this.purgeListeners();
- this.clear(true);
- Ext.each(this.childNodes, function(n){
- n.destroy();
- });
- this.childNodes = null;
- },
- insertBefore : function(node, refNode){
- if(!refNode){
- return this.appendChild(node);
- }
- if(node == refNode){
- return false;
- }
- if(this.fireEvent("beforeinsert", this.ownerTree, this, node, refNode) === false){
- return false;
- }
- var index = this.childNodes.indexOf(refNode);
- var oldParent = node.parentNode;
- var refIndex = index;
- if(oldParent == this && this.childNodes.indexOf(node) < index){
- refIndex--;
- }
- if(oldParent){
- if(node.fireEvent("beforemove", node.getOwnerTree(), node, oldParent, this, index, refNode) === false){
- return false;
- }
- oldParent.removeChild(node);
- }
- if(refIndex === 0){
- this.setFirstChild(node);
- }
- this.childNodes.splice(refIndex, 0, node);
- node.parentNode = this;
- var ps = this.childNodes[refIndex-1];
- if(ps){
- node.previousSibling = ps;
- ps.nextSibling = node;
- }else{
- node.previousSibling = null;
- }
- node.nextSibling = refNode;
- refNode.previousSibling = node;
- node.setOwnerTree(this.getOwnerTree());
- this.fireEvent("insert", this.ownerTree, this, node, refNode);
- if(oldParent){
- node.fireEvent("move", this.ownerTree, node, oldParent, this, refIndex, refNode);
- }
- return node;
- },
- remove : function(destroy){
- this.parentNode.removeChild(this, destroy);
- return this;
- },
- item : function(index){
- return this.childNodes[index];
- },
- replaceChild : function(newChild, oldChild){
- var s = oldChild ? oldChild.nextSibling : null;
- this.removeChild(oldChild);
- this.insertBefore(newChild, s);
- return oldChild;
- },
- indexOf : function(child){
- return this.childNodes.indexOf(child);
- },
- getOwnerTree : function(){
- if(!this.ownerTree){
- var p = this;
- while(p){
- if(p.ownerTree){
- this.ownerTree = p.ownerTree;
- break;
- }
- p = p.parentNode;
- }
- }
- return this.ownerTree;
- },
- getDepth : function(){
- var depth = 0;
- var p = this;
- while(p.parentNode){
- ++depth;
- p = p.parentNode;
- }
- return depth;
- },
- setOwnerTree : function(tree, destroy){
- if(tree != this.ownerTree){
- if(this.ownerTree){
- this.ownerTree.unregisterNode(this);
- }
- this.ownerTree = tree;
- if(destroy !== true){
- Ext.each(this.childNodes, function(n){
- n.setOwnerTree(tree);
- });
- }
- if(tree){
- tree.registerNode(this);
- }
- }
- },
- setId: function(id){
- if(id !== this.id){
- var t = this.ownerTree;
- if(t){
- t.unregisterNode(this);
- }
- this.id = this.attributes.id = id;
- if(t){
- t.registerNode(this);
- }
- this.onIdChange(id);
- }
- },
- onIdChange: Ext.emptyFn,
- getPath : function(attr){
- attr = attr || "id";
- var p = this.parentNode;
- var b = [this.attributes[attr]];
- while(p){
- b.unshift(p.attributes[attr]);
- p = p.parentNode;
- }
- var sep = this.getOwnerTree().pathSeparator;
- return sep + b.join(sep);
- },
- bubble : function(fn, scope, args){
- var p = this;
- while(p){
- if(fn.apply(scope || p, args || [p]) === false){
- break;
- }
- p = p.parentNode;
- }
- },
- cascade : function(fn, scope, args){
- if(fn.apply(scope || this, args || [this]) !== false){
- var cs = this.childNodes;
- for(var i = 0, len = cs.length; i < len; i++) {
- cs[i].cascade(fn, scope, args);
- }
- }
- },
- eachChild : function(fn, scope, args){
- var cs = this.childNodes;
- for(var i = 0, len = cs.length; i < len; i++) {
- if(fn.apply(scope || this, args || [cs[i]]) === false){
- break;
- }
- }
- },
- findChild : function(attribute, value){
- var cs = this.childNodes;
- for(var i = 0, len = cs.length; i < len; i++) {
- if(cs[i].attributes[attribute] == value){
- return cs[i];
- }
- }
- return null;
- },
- findChildBy : function(fn, scope){
- var cs = this.childNodes;
- for(var i = 0, len = cs.length; i < len; i++) {
- if(fn.call(scope||cs[i], cs[i]) === true){
- return cs[i];
- }
- }
- return null;
- },
- sort : function(fn, scope){
- var cs = this.childNodes;
- var len = cs.length;
- if(len > 0){
- var sortFn = scope ? function(){fn.apply(scope, arguments);} : fn;
- cs.sort(sortFn);
- for(var i = 0; i < len; i++){
- var n = cs[i];
- n.previousSibling = cs[i-1];
- n.nextSibling = cs[i+1];
- if(i === 0){
- this.setFirstChild(n);
- }
- if(i == len-1){
- this.setLastChild(n);
- }
- }
- }
- },
- contains : function(node){
- return node.isAncestor(this);
- },
- isAncestor : function(node){
- var p = this.parentNode;
- while(p){
- if(p == node){
- return true;
- }
- p = p.parentNode;
- }
- return false;
- },
- toString : function(){
- return "[Node"+(this.id?" "+this.id:"")+"]";
- }
- });
- Ext.tree.TreeNode = function(attributes){
- attributes = attributes || {};
- if(Ext.isString(attributes)){
- 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.hidden = attributes.hidden === true;
- this.addEvents(
- 'textchange',
- 'beforeexpand',
- 'beforecollapse',
- 'expand',
- 'disabledchange',
- 'collapse',
- 'beforeclick',
- 'click',
- 'checkchange',
- 'beforedblclick',
- '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;
- },
- getLoader : function(){
- var owner;
- return this.loader || ((owner = this.getOwnerTree()) && owner.loader ? owner.loader : (this.loader = new Ext.tree.TreeLoader()));
- },
- 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(n){
- if(!n.render && !Ext.isArray(n)){
- n = this.getLoader().createNode(n);
- }
- var node = Ext.tree.TreeNode.superclass.appendChild.call(this, n);
- if(node && this.childrenRendered){
- node.render();
- }
- this.ui.updateExpandIcon();
- return node;
- },
- removeChild : function(node, destroy){
- this.ownerTree.getSelectionModel().unselect(node);
- Ext.tree.TreeNode.superclass.removeChild.apply(this, arguments);
- if(node.ui.rendered){
- 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){
- if(!node.render){
- node = this.getLoader().createNode(node);
- }
- var newNode = Ext.tree.TreeNode.superclass.insertBefore.call(this, node, refNode);
- if(newNode && refNode && this.childrenRendered){
- node.render();
- }
- this.ui.updateExpandIcon();
- return newNode;
- },
- setText : function(text){
- var oldText = this.text;
- this.text = this.attributes.text = text;
- if(this.rendered){
- this.ui.onTextChange(this, text, oldText);
- }
- this.fireEvent('textchange', this, text, oldText);
- },
- select : function(){
- var t = this.getOwnerTree();
- if(t){
- t.getSelectionModel().select(this);
- }
- },
- unselect : function(silent){
- var t = this.getOwnerTree();
- if(t){
- t.getSelectionModel().unselect(this, silent);
- }
- },
- isSelected : function(){
- var t = this.getOwnerTree();
- return t ? t.getSelectionModel().isSelected(this) : false;
- },
- expand : function(deep, anim, callback, scope){
- 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);
- this.runCallback(callback, scope || this, [this]);
- if(deep === true){
- this.expandChildNodes(true);
- }
- }.createDelegate(this));
- return;
- }else{
- this.ui.expand();
- this.fireEvent('expand', this);
- this.runCallback(callback, scope || this, [this]);
- }
- }else{
- this.runCallback(callback, scope || this, [this]);
- }
- if(deep === true){
- this.expandChildNodes(true);
- }
- },
- runCallback : function(cb, scope, args){
- if(Ext.isFunction(cb)){
- cb.apply(scope, args);
- }
- },
- isHiddenRoot : function(){
- return this.isRoot && !this.getOwnerTree().rootVisible;
- },
- collapse : function(deep, anim, callback, scope){
- 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);
- this.runCallback(callback, scope || this, [this]);
- if(deep === true){
- this.collapseChildNodes(true);
- }
- }.createDelegate(this));
- return;
- }else{
- this.ui.collapse();
- this.fireEvent('collapse', this);
- this.runCallback(callback, scope || this, [this]);
- }
- }else if(!this.expanded){
- this.runCallback(callback, scope || this, [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, scope){
- var tree = this.getOwnerTree();
- tree.expandPath(this.parentNode ? this.parentNode.getPath() : this.getPath(), false, function(){
- var node = tree.getNodeById(this.id);
- tree.getTreeEl().scrollChildIntoView(node.ui.anchor);
- this.runCallback(callback, scope || this, [this]);
- }.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.rendered){
- this.renderChildren();
- }
- },
- destroy : function(){
- this.unselect(true);
- Ext.tree.TreeNode.superclass.destroy.call(this);
- Ext.destroy(this.ui, this.loader);
- this.ui = this.loader = null;
- },
- onIdChange : function(id){
- this.ui.onIdChange(id);
- }
- });
- Ext.tree.TreePanel.nodeTypes.node = Ext.tree.TreeNode;
- Ext.tree.AsyncTreeNode = function(config){
- this.loaded = config && config.loaded === true;
- 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, scope){
- if(this.loading){
- var timer;
- var f = function(){
- if(!this.loading){
- clearInterval(timer);
- this.expand(deep, anim, callback, scope);
- }
- }.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, scope]), this);
- return;
- }
- }
- Ext.tree.AsyncTreeNode.superclass.expand.call(this, deep, anim, callback, scope);
- },
- isLoading : function(){
- return this.loading;
- },
- loadComplete : function(deep, anim, callback, scope){
- this.loading = false;
- this.loaded = true;
- this.ui.afterLoad(this);
- this.fireEvent("load", this);
- this.expand(deep, anim, callback, scope);
- },
- 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, scope){
- this.collapse(false, false);
- while(this.firstChild){
- this.removeChild(this.firstChild).destroy();
- }
- this.childrenRendered = false;
- this.loaded = false;
- if(this.isHiddenRoot()){
- this.expanded = false;
- }
- this.expand(false, false, callback, scope);
- }
- });
- Ext.tree.TreePanel.nodeTypes.async = Ext.tree.AsyncTreeNode;
- 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, oldParent != newParent);
- }
- },
- 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.onDisableChange(this.node, 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.isExpandable()){
- this.node.toggle();
- }
- this.fireEvent("click", this.node, e);
- }else{
- e.stopEvent();
- }
- },
- onDblClick : function(e){
- e.preventDefault();
- if(this.disabled){
- return;
- }
- if(this.fireEvent("beforedblclick", this.node, e) !== false){
- if(this.checkbox){
- this.toggleCheck();
- }
- if(!this.animating && this.node.isExpandable()){
- 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.checkbox.defaultChecked = checked;
- this.node.attributes.checked = checked;
- this.fireEvent('checkchange', this.node, checked);
- },
- ecClick : function(e){
- if(!this.animating && this.node.isExpandable()){
- 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{
- 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);
- this.onCheckChange();
- }
- },
- blur : function(){
- try{
- this.anchor.blur();
- }catch(e){}
- },
- animExpand : function(callback){
- var ct = Ext.get(this.ctNode);
- ct.stopFx();
- if(!this.node.isExpandable()){
- 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}