ext-all-debug.js
资源名称:ext-3.1.0.zip [点击查看]
上传用户:dawnssy
上传日期:2022-08-06
资源大小:9345k
文件大小:1167k
源码类别:
JavaScript
开发平台:
JavaScript
- csLen = cs.length;
- for (i = 0 ; i < csLen; i++) {
- c = cs[i];
- cm = c.margins;
- margin = cm.top + cm.bottom;
- maxWidth = Math.max(maxWidth, c.getWidth() + cm.left + cm.right);
- }
- var innerCtWidth = maxWidth + this.padding.left + this.padding.right;
- switch(this.align){
- case 'stretch':
- this.innerCt.setSize(w, h);
- break;
- case 'stretchmax':
- case 'left':
- this.innerCt.setSize(innerCtWidth, h);
- break;
- case 'center':
- this.innerCt.setSize(w = Math.max(w, innerCtWidth), h);
- break;
- }
- var availableWidth = Math.max(0, w - this.padding.left - this.padding.right);
- for (i = 0 ; i < csLen; i++) {
- c = cs[i];
- cm = c.margins;
- if(this.align == 'stretch'){
- c.setWidth((stretchWidth - (cm.left + cm.right)).constrain(
- c.minWidth || 0, c.maxWidth || 1000000));
- }else if(this.align == 'stretchmax'){
- c.setWidth((maxWidth - (cm.left + cm.right)).constrain(
- c.minWidth || 0, c.maxWidth || 1000000));
- }else if(isStart && c.flex){
- c.setWidth();
- }
- }
- for (i = 0 ; i < csLen; i++) {
- c = cs[i];
- cm = c.margins;
- totalFlex += c.flex || 0;
- ch = c.getHeight();
- margin = cm.top + cm.bottom;
- extraHeight += ch + margin;
- flexHeight += margin + (c.flex ? 0 : ch);
- }
- extraHeight = h - extraHeight - this.padding.top - this.padding.bottom;
- var availHeight = Math.max(0, h - this.padding.top - this.padding.bottom - flexHeight),
- leftOver = availHeight;
- for (i = 0 ; i < csLen; i++) {
- c = cs[i];
- if(isStart && c.flex){
- ch = Math.floor(availHeight * (c.flex / totalFlex));
- leftOver -= ch;
- heights.push(ch);
- }
- }
- if(this.pack == 'center'){
- t += extraHeight ? extraHeight / 2 : 0;
- }else if(this.pack == 'end'){
- t += extraHeight;
- }
- idx = 0;
- for (i = 0 ; i < csLen; i++) {
- c = cs[i];
- cm = c.margins;
- t += cm.top;
- aw = availableWidth;
- cl = l + cm.left
- if(this.align == 'center'){
- if((diff = availableWidth - (c.getWidth() + cm.left + cm.right)) > 0){
- cl += (diff/2);
- aw -= diff;
- }
- }
- c.setPosition(cl, t);
- if(isStart && c.flex){
- ch = Math.max(0, heights[idx++] + (leftOver-- > 0 ? 1 : 0));
- c.setSize(aw, ch);
- }else{
- ch = c.getHeight();
- }
- t += ch + cm.bottom;
- }
- }
- });
- Ext.Container.LAYOUTS.vbox = Ext.layout.VBoxLayout;
- Ext.layout.HBoxLayout = Ext.extend(Ext.layout.BoxLayout, {
- align : 'top',
- onLayout : function(ct, target){
- Ext.layout.HBoxLayout.superclass.onLayout.call(this, ct, target);
- var cs = this.getItems(ct), cm, cw, margin, ch, diff,
- size = target.getViewSize(true),
- w = size.width - this.scrollOffset,
- h = size.height,
- l = this.padding.left, t = this.padding.top,
- isStart = this.pack == 'start',
- isRestore = ['stretch', 'stretchmax'].indexOf(this.align) == -1,
- stretchHeight = h - (this.padding.top + this.padding.bottom),
- extraWidth = 0,
- maxHeight = 0,
- totalFlex = 0,
- flexWidth = 0,
- usedWidth = 0;
- Ext.each(cs, function(c){
- cm = c.margins;
- totalFlex += c.flex || 0;
- cw = c.getWidth();
- margin = cm.left + cm.right;
- extraWidth += cw + margin;
- flexWidth += margin + (c.flex ? 0 : cw);
- maxHeight = Math.max(maxHeight, c.getHeight() + cm.top + cm.bottom);
- });
- extraWidth = w - extraWidth - this.padding.left - this.padding.right;
- var innerCtHeight = maxHeight + this.padding.top + this.padding.bottom;
- switch(this.align){
- case 'stretch':
- this.innerCt.setSize(w, h);
- break;
- case 'stretchmax':
- case 'top':
- this.innerCt.setSize(w, innerCtHeight);
- break;
- case 'middle':
- this.innerCt.setSize(w, h = Math.max(h, innerCtHeight));
- break;
- }
- var availWidth = Math.max(0, w - this.padding.left - this.padding.right - flexWidth),
- leftOver = availWidth,
- widths = [],
- restore = [],
- idx = 0,
- availableHeight = Math.max(0, h - this.padding.top - this.padding.bottom);
- Ext.each(cs, function(c){
- if(isStart && c.flex){
- cw = Math.floor(availWidth * (c.flex / totalFlex));
- leftOver -= cw;
- widths.push(cw);
- }
- });
- if(this.pack == 'center'){
- l += extraWidth ? extraWidth / 2 : 0;
- }else if(this.pack == 'end'){
- l += extraWidth;
- }
- Ext.each(cs, function(c){
- cm = c.margins;
- l += cm.left;
- c.setPosition(l, t + cm.top);
- if(isStart && c.flex){
- cw = Math.max(0, widths[idx++] + (leftOver-- > 0 ? 1 : 0));
- if(isRestore){
- restore.push(c.getHeight());
- }
- c.setSize(cw, availableHeight);
- }else{
- cw = c.getWidth();
- }
- l += cw + cm.right;
- });
- idx = 0;
- Ext.each(cs, function(c){
- cm = c.margins;
- ch = c.getHeight();
- if(isStart && c.flex){
- ch = restore[idx++];
- }
- if(this.align == 'stretch'){
- c.setHeight((stretchHeight - (cm.top + cm.bottom)).constrain(
- c.minHeight || 0, c.maxHeight || 1000000));
- }else if(this.align == 'stretchmax'){
- c.setHeight((maxHeight - (cm.top + cm.bottom)).constrain(
- c.minHeight || 0, c.maxHeight || 1000000));
- }else{
- if(this.align == 'middle'){
- diff = availableHeight - (ch + cm.top + cm.bottom);
- ch = t + cm.top + (diff/2);
- if(diff > 0){
- c.setPosition(c.x, ch);
- }
- }
- if(isStart && c.flex){
- c.setHeight(ch);
- }
- }
- }, this);
- }
- });
- Ext.Container.LAYOUTS.hbox = Ext.layout.HBoxLayout;
- Ext.Viewport = Ext.extend(Ext.Container, {
- initComponent : function() {
- Ext.Viewport.superclass.initComponent.call(this);
- document.getElementsByTagName('html')[0].className += ' x-viewport';
- this.el = Ext.getBody();
- this.el.setHeight = Ext.emptyFn;
- this.el.setWidth = Ext.emptyFn;
- this.el.setSize = Ext.emptyFn;
- this.el.dom.scroll = 'no';
- this.allowDomMove = false;
- this.autoWidth = true;
- this.autoHeight = true;
- Ext.EventManager.onWindowResize(this.fireResize, this);
- this.renderTo = this.el;
- },
- fireResize : function(w, h){
- this.onResize(w, h, w, h);
- }
- });
- Ext.reg('viewport', Ext.Viewport);
- Ext.Panel = Ext.extend(Ext.Container, {
- baseCls : 'x-panel',
- collapsedCls : 'x-panel-collapsed',
- maskDisabled : true,
- animCollapse : Ext.enableFx,
- headerAsText : true,
- buttonAlign : 'right',
- collapsed : false,
- collapseFirst : true,
- minButtonWidth : 75,
- elements : 'body',
- preventBodyReset : false,
- padding: undefined,
- resizeEvent: 'bodyresize',
- toolTarget : 'header',
- collapseEl : 'bwrap',
- slideAnchor : 't',
- disabledClass : '',
- deferHeight : true,
- expandDefaults: {
- duration : 0.25
- },
- collapseDefaults : {
- duration : 0.25
- },
- initComponent : function(){
- Ext.Panel.superclass.initComponent.call(this);
- this.addEvents(
- 'bodyresize',
- 'titlechange',
- 'iconchange',
- 'collapse',
- 'expand',
- 'beforecollapse',
- 'beforeexpand',
- 'beforeclose',
- 'close',
- 'activate',
- 'deactivate'
- );
- if(this.unstyled){
- this.baseCls = 'x-plain';
- }
- this.toolbars = [];
- if(this.tbar){
- this.elements += ',tbar';
- this.topToolbar = this.createToolbar(this.tbar);
- delete this.tbar;
- }
- if(this.bbar){
- this.elements += ',bbar';
- this.bottomToolbar = this.createToolbar(this.bbar);
- delete this.bbar;
- }
- if(this.header === true){
- this.elements += ',header';
- delete this.header;
- }else if(this.headerCfg || (this.title && this.header !== false)){
- this.elements += ',header';
- }
- if(this.footerCfg || this.footer === true){
- this.elements += ',footer';
- delete this.footer;
- }
- if(this.buttons){
- this.fbar = this.buttons;
- delete this.buttons;
- }
- if(this.fbar){
- this.createFbar(this.fbar);
- }
- if(this.autoLoad){
- this.on('render', this.doAutoLoad, this, {delay:10});
- }
- },
- createFbar : function(fbar){
- var min = this.minButtonWidth;
- this.elements += ',footer';
- this.fbar = this.createToolbar(fbar, {
- buttonAlign: this.buttonAlign,
- toolbarCls: 'x-panel-fbar',
- enableOverflow: false,
- defaults: function(c){
- return {
- minWidth: c.minWidth || min
- };
- }
- });
- //@compat addButton and buttons could possibly be removed
- //@target 4.0
- this.fbar.items.each(function(c){
- c.minWidth = c.minWidth || this.minButtonWidth;
- }, this);
- this.buttons = this.fbar.items.items;
- },
- createToolbar: function(tb, options){
- var result;
- if(Ext.isArray(tb)){
- tb = {
- items: tb
- };
- }
- result = tb.events ? Ext.apply(tb, options) : this.createComponent(Ext.apply({}, tb, options), 'toolbar');
- result.ownerCt = this;
- result.bufferResize = false;
- this.toolbars.push(result);
- return result;
- },
- createElement : function(name, pnode){
- if(this[name]){
- pnode.appendChild(this[name].dom);
- return;
- }
- if(name === 'bwrap' || this.elements.indexOf(name) != -1){
- if(this[name+'Cfg']){
- this[name] = Ext.fly(pnode).createChild(this[name+'Cfg']);
- }else{
- var el = document.createElement('div');
- el.className = this[name+'Cls'];
- this[name] = Ext.get(pnode.appendChild(el));
- }
- if(this[name+'CssClass']){
- this[name].addClass(this[name+'CssClass']);
- }
- if(this[name+'Style']){
- this[name].applyStyles(this[name+'Style']);
- }
- }
- },
- onRender : function(ct, position){
- Ext.Panel.superclass.onRender.call(this, ct, position);
- this.createClasses();
- var el = this.el,
- d = el.dom,
- bw,
- ts;
- if(this.collapsible && !this.hideCollapseTool){
- this.tools = this.tools ? this.tools.slice(0) : [];
- this.tools[this.collapseFirst?'unshift':'push']({
- id: 'toggle',
- handler : this.toggleCollapse,
- scope: this
- });
- }
- if(this.tools){
- ts = this.tools;
- this.elements += (this.header !== false) ? ',header' : '';
- }
- this.tools = {};
- el.addClass(this.baseCls);
- if(d.firstChild){
- this.header = el.down('.'+this.headerCls);
- this.bwrap = el.down('.'+this.bwrapCls);
- var cp = this.bwrap ? this.bwrap : el;
- this.tbar = cp.down('.'+this.tbarCls);
- this.body = cp.down('.'+this.bodyCls);
- this.bbar = cp.down('.'+this.bbarCls);
- this.footer = cp.down('.'+this.footerCls);
- this.fromMarkup = true;
- }
- if (this.preventBodyReset === true) {
- el.addClass('x-panel-reset');
- }
- if(this.cls){
- el.addClass(this.cls);
- }
- if(this.buttons){
- this.elements += ',footer';
- }
- if(this.frame){
- el.insertHtml('afterBegin', String.format(Ext.Element.boxMarkup, this.baseCls));
- this.createElement('header', d.firstChild.firstChild.firstChild);
- this.createElement('bwrap', d);
- bw = this.bwrap.dom;
- var ml = d.childNodes[1], bl = d.childNodes[2];
- bw.appendChild(ml);
- bw.appendChild(bl);
- var mc = bw.firstChild.firstChild.firstChild;
- this.createElement('tbar', mc);
- this.createElement('body', mc);
- this.createElement('bbar', mc);
- this.createElement('footer', bw.lastChild.firstChild.firstChild);
- if(!this.footer){
- this.bwrap.dom.lastChild.className += ' x-panel-nofooter';
- }
- this.ft = Ext.get(this.bwrap.dom.lastChild);
- this.mc = Ext.get(mc);
- }else{
- this.createElement('header', d);
- this.createElement('bwrap', d);
- bw = this.bwrap.dom;
- this.createElement('tbar', bw);
- this.createElement('body', bw);
- this.createElement('bbar', bw);
- this.createElement('footer', bw);
- if(!this.header){
- this.body.addClass(this.bodyCls + '-noheader');
- if(this.tbar){
- this.tbar.addClass(this.tbarCls + '-noheader');
- }
- }
- }
- if(Ext.isDefined(this.padding)){
- this.body.setStyle('padding', this.body.addUnits(this.padding));
- }
- if(this.border === false){
- this.el.addClass(this.baseCls + '-noborder');
- this.body.addClass(this.bodyCls + '-noborder');
- if(this.header){
- this.header.addClass(this.headerCls + '-noborder');
- }
- if(this.footer){
- this.footer.addClass(this.footerCls + '-noborder');
- }
- if(this.tbar){
- this.tbar.addClass(this.tbarCls + '-noborder');
- }
- if(this.bbar){
- this.bbar.addClass(this.bbarCls + '-noborder');
- }
- }
- if(this.bodyBorder === false){
- this.body.addClass(this.bodyCls + '-noborder');
- }
- this.bwrap.enableDisplayMode('block');
- if(this.header){
- this.header.unselectable();
- if(this.headerAsText){
- this.header.dom.innerHTML =
- '<span class="' + this.headerTextCls + '">'+this.header.dom.innerHTML+'</span>';
- if(this.iconCls){
- this.setIconClass(this.iconCls);
- }
- }
- }
- if(this.floating){
- this.makeFloating(this.floating);
- }
- if(this.collapsible && this.titleCollapse && this.header){
- this.mon(this.header, 'click', this.toggleCollapse, this);
- this.header.setStyle('cursor', 'pointer');
- }
- if(ts){
- this.addTool.apply(this, ts);
- }
- if(this.fbar){
- this.footer.addClass('x-panel-btns');
- this.fbar.render(this.footer);
- this.footer.createChild({cls:'x-clear'});
- }
- if(this.tbar && this.topToolbar){
- this.topToolbar.render(this.tbar);
- }
- if(this.bbar && this.bottomToolbar){
- this.bottomToolbar.render(this.bbar);
- }
- },
- setIconClass : function(cls){
- var old = this.iconCls;
- this.iconCls = cls;
- if(this.rendered && this.header){
- if(this.frame){
- this.header.addClass('x-panel-icon');
- this.header.replaceClass(old, this.iconCls);
- }else{
- var hd = this.header,
- img = hd.child('img.x-panel-inline-icon');
- if(img){
- Ext.fly(img).replaceClass(old, this.iconCls);
- }else{
- Ext.DomHelper.insertBefore(hd.dom.firstChild, {
- tag:'img', src: Ext.BLANK_IMAGE_URL, cls:'x-panel-inline-icon '+this.iconCls
- });
- }
- }
- }
- this.fireEvent('iconchange', this, cls, old);
- },
- makeFloating : function(cfg){
- this.floating = true;
- this.el = new Ext.Layer(Ext.apply({}, cfg, {
- shadow: Ext.isDefined(this.shadow) ? this.shadow : 'sides',
- shadowOffset: this.shadowOffset,
- constrain:false,
- shim: this.shim === false ? false : undefined
- }), this.el);
- },
- getTopToolbar : function(){
- return this.topToolbar;
- },
- getBottomToolbar : function(){
- return this.bottomToolbar;
- },
- addButton : function(config, handler, scope){
- if(!this.fbar){
- this.createFbar([]);
- }
- if(handler){
- if(Ext.isString(config)){
- config = {text: config};
- }
- config = Ext.apply({
- handler: handler,
- scope: scope
- }, config)
- }
- return this.fbar.add(config);
- },
- addTool : function(){
- if(!this.rendered){
- if(!this.tools){
- this.tools = [];
- }
- Ext.each(arguments, function(arg){
- this.tools.push(arg)
- }, this);
- return;
- }
- if(!this[this.toolTarget]){
- return;
- }
- if(!this.toolTemplate){
- var tt = new Ext.Template(
- '<div class="x-tool x-tool-{id}"> </div>'
- );
- tt.disableFormats = true;
- tt.compile();
- Ext.Panel.prototype.toolTemplate = tt;
- }
- for(var i = 0, a = arguments, len = a.length; i < len; i++) {
- var tc = a[i];
- if(!this.tools[tc.id]){
- var overCls = 'x-tool-'+tc.id+'-over';
- var t = this.toolTemplate.insertFirst((tc.align !== 'left') ? this[this.toolTarget] : this[this.toolTarget].child('span'), tc, true);
- this.tools[tc.id] = t;
- t.enableDisplayMode('block');
- this.mon(t, 'click', this.createToolHandler(t, tc, overCls, this));
- if(tc.on){
- this.mon(t, tc.on);
- }
- if(tc.hidden){
- t.hide();
- }
- if(tc.qtip){
- if(Ext.isObject(tc.qtip)){
- Ext.QuickTips.register(Ext.apply({
- target: t.id
- }, tc.qtip));
- } else {
- t.dom.qtip = tc.qtip;
- }
- }
- t.addClassOnOver(overCls);
- }
- }
- },
- onLayout : function(shallow, force){
- if(this.hasLayout && this.toolbars.length > 0){
- Ext.each(this.toolbars, function(tb){
- tb.doLayout(undefined, force);
- });
- this.syncHeight();
- }
- },
- syncHeight : function(){
- var h = this.toolbarHeight,
- bd = this.body,
- lsh = this.lastSize.height,
- sz;
- if(this.autoHeight || !Ext.isDefined(lsh) || lsh == 'auto'){
- return;
- }
- if(h != this.getToolbarHeight()){
- h = Math.max(0, this.adjustBodyHeight(lsh - this.getFrameHeight()));
- bd.setHeight(h);
- sz = bd.getSize();
- this.toolbarHeight = this.getToolbarHeight();
- this.onBodyResize(sz.width, sz.height);
- }
- },
- onShow : function(){
- if(this.floating){
- return this.el.show();
- }
- Ext.Panel.superclass.onShow.call(this);
- },
- onHide : function(){
- if(this.floating){
- return this.el.hide();
- }
- Ext.Panel.superclass.onHide.call(this);
- },
- createToolHandler : function(t, tc, overCls, panel){
- return function(e){
- t.removeClass(overCls);
- if(tc.stopEvent !== false){
- e.stopEvent();
- }
- if(tc.handler){
- tc.handler.call(tc.scope || t, e, t, panel, tc);
- }
- };
- },
- afterRender : function(){
- if(this.floating && !this.hidden){
- this.el.show();
- }
- if(this.title){
- this.setTitle(this.title);
- }
- if(this.collapsed){
- this.collapsed = false;
- this.collapse(false);
- }
- Ext.Panel.superclass.afterRender.call(this);
- this.initEvents();
- },
- getKeyMap : function(){
- if(!this.keyMap){
- this.keyMap = new Ext.KeyMap(this.el, this.keys);
- }
- return this.keyMap;
- },
- initEvents : function(){
- if(this.keys){
- this.getKeyMap();
- }
- if(this.draggable){
- this.initDraggable();
- }
- if(this.toolbars.length > 0){
- Ext.each(this.toolbars, function(tb){
- tb.doLayout();
- tb.on({
- scope: this,
- afterlayout: this.syncHeight,
- remove: this.syncHeight
- });
- }, this);
- if(!this.ownerCt){
- this.syncHeight();
- }
- }
- },
- initDraggable : function(){
- this.dd = new Ext.Panel.DD(this, Ext.isBoolean(this.draggable) ? null : this.draggable);
- },
- beforeEffect : function(anim){
- if(this.floating){
- this.el.beforeAction();
- }
- if(anim !== false){
- this.el.addClass('x-panel-animated');
- }
- },
- afterEffect : function(anim){
- this.syncShadow();
- if(anim !== false){
- this.el.removeClass('x-panel-animated');
- }
- },
- createEffect : function(a, cb, scope){
- var o = {
- scope:scope,
- block:true
- };
- if(a === true){
- o.callback = cb;
- return o;
- }else if(!a.callback){
- o.callback = cb;
- }else {
- o.callback = function(){
- cb.call(scope);
- Ext.callback(a.callback, a.scope);
- };
- }
- return Ext.applyIf(o, a);
- },
- collapse : function(animate){
- if(this.collapsed || this.el.hasFxBlock() || this.fireEvent('beforecollapse', this, animate) === false){
- return;
- }
- var doAnim = animate === true || (animate !== false && this.animCollapse);
- this.beforeEffect(doAnim);
- this.onCollapse(doAnim, animate);
- return this;
- },
- onCollapse : function(doAnim, animArg){
- if(doAnim){
- this[this.collapseEl].slideOut(this.slideAnchor,
- Ext.apply(this.createEffect(animArg||true, this.afterCollapse, this),
- this.collapseDefaults));
- }else{
- this[this.collapseEl].hide();
- this.afterCollapse(false);
- }
- },
- afterCollapse : function(anim){
- this.collapsed = true;
- this.el.addClass(this.collapsedCls);
- this.afterEffect(anim);
- this.fireEvent('collapse', this);
- },
- expand : function(animate){
- if(!this.collapsed || this.el.hasFxBlock() || this.fireEvent('beforeexpand', this, animate) === false){
- return;
- }
- var doAnim = animate === true || (animate !== false && this.animCollapse);
- this.el.removeClass(this.collapsedCls);
- this.beforeEffect(doAnim);
- this.onExpand(doAnim, animate);
- return this;
- },
- onExpand : function(doAnim, animArg){
- if(doAnim){
- this[this.collapseEl].slideIn(this.slideAnchor,
- Ext.apply(this.createEffect(animArg||true, this.afterExpand, this),
- this.expandDefaults));
- }else{
- this[this.collapseEl].show();
- this.afterExpand(false);
- }
- },
- afterExpand : function(anim){
- this.collapsed = false;
- this.afterEffect(anim);
- if(Ext.isDefined(this.deferLayout)){
- this.doLayout(true);
- }
- this.fireEvent('expand', this);
- },
- toggleCollapse : function(animate){
- this[this.collapsed ? 'expand' : 'collapse'](animate);
- return this;
- },
- onDisable : function(){
- if(this.rendered && this.maskDisabled){
- this.el.mask();
- }
- Ext.Panel.superclass.onDisable.call(this);
- },
- onEnable : function(){
- if(this.rendered && this.maskDisabled){
- this.el.unmask();
- }
- Ext.Panel.superclass.onEnable.call(this);
- },
- onResize : function(w, h){
- if(Ext.isDefined(w) || Ext.isDefined(h)){
- if(!this.collapsed){
- if(Ext.isNumber(w)){
- this.body.setWidth(w = this.adjustBodyWidth(w - this.getFrameWidth()));
- } else if (w == 'auto') {
- w = this.body.setWidth('auto').dom.offsetWidth;
- } else {
- w = this.body.dom.offsetWidth;
- }
- if(this.tbar){
- this.tbar.setWidth(w);
- if(this.topToolbar){
- this.topToolbar.setSize(w);
- }
- }
- if(this.bbar){
- this.bbar.setWidth(w);
- if(this.bottomToolbar){
- this.bottomToolbar.setSize(w);
- if (Ext.isIE) {
- this.bbar.setStyle('position', 'static');
- this.bbar.setStyle('position', '');
- }
- }
- }
- if(this.footer){
- this.footer.setWidth(w);
- if(this.fbar){
- this.fbar.setSize(Ext.isIE ? (w - this.footer.getFrameWidth('lr')) : 'auto');
- }
- }
- if(Ext.isNumber(h)){
- h = Math.max(0, this.adjustBodyHeight(h - this.getFrameHeight()));
- this.body.setHeight(h);
- }else if(h == 'auto'){
- this.body.setHeight(h);
- }
- if(this.disabled && this.el._mask){
- this.el._mask.setSize(this.el.dom.clientWidth, this.el.getHeight());
- }
- }else{
- this.queuedBodySize = {width: w, height: h};
- if(!this.queuedExpand && this.allowQueuedExpand !== false){
- this.queuedExpand = true;
- this.on('expand', function(){
- delete this.queuedExpand;
- this.onResize(this.queuedBodySize.width, this.queuedBodySize.height);
- }, this, {single:true});
- }
- }
- this.onBodyResize(w, h);
- }
- this.syncShadow();
- Ext.Panel.superclass.onResize.call(this);
- },
- onBodyResize: function(w, h){
- this.fireEvent('bodyresize', this, w, h);
- },
- getToolbarHeight: function(){
- var h = 0;
- if(this.rendered){
- Ext.each(this.toolbars, function(tb){
- h += tb.getHeight();
- }, this);
- }
- return h;
- },
- adjustBodyHeight : function(h){
- return h;
- },
- adjustBodyWidth : function(w){
- return w;
- },
- onPosition : function(){
- this.syncShadow();
- },
- getFrameWidth : function(){
- var w = this.el.getFrameWidth('lr') + this.bwrap.getFrameWidth('lr');
- if(this.frame){
- var l = this.bwrap.dom.firstChild;
- w += (Ext.fly(l).getFrameWidth('l') + Ext.fly(l.firstChild).getFrameWidth('r'));
- w += this.mc.getFrameWidth('lr');
- }
- return w;
- },
- getFrameHeight : function(){
- var h = this.el.getFrameWidth('tb') + this.bwrap.getFrameWidth('tb');
- h += (this.tbar ? this.tbar.getHeight() : 0) +
- (this.bbar ? this.bbar.getHeight() : 0);
- if(this.frame){
- h += this.el.dom.firstChild.offsetHeight + this.ft.dom.offsetHeight + this.mc.getFrameWidth('tb');
- }else{
- h += (this.header ? this.header.getHeight() : 0) +
- (this.footer ? this.footer.getHeight() : 0);
- }
- return h;
- },
- getInnerWidth : function(){
- return this.getSize().width - this.getFrameWidth();
- },
- getInnerHeight : function(){
- return this.getSize().height - this.getFrameHeight();
- },
- syncShadow : function(){
- if(this.floating){
- this.el.sync(true);
- }
- },
- getLayoutTarget : function(){
- return this.body;
- },
- getContentTarget : function(){
- return this.body;
- },
- setTitle : function(title, iconCls){
- this.title = title;
- if(this.header && this.headerAsText){
- this.header.child('span').update(title);
- }
- if(iconCls){
- this.setIconClass(iconCls);
- }
- this.fireEvent('titlechange', this, title);
- return this;
- },
- getUpdater : function(){
- return this.body.getUpdater();
- },
- load : function(){
- var um = this.body.getUpdater();
- um.update.apply(um, arguments);
- return this;
- },
- beforeDestroy : function(){
- Ext.Panel.superclass.beforeDestroy.call(this);
- if(this.header){
- this.header.removeAllListeners();
- }
- if(this.tools){
- for(var k in this.tools){
- Ext.destroy(this.tools[k]);
- }
- }
- if(Ext.isArray(this.buttons)){
- while(this.buttons.length) {
- Ext.destroy(this.buttons[0]);
- }
- }
- if(this.rendered){
- Ext.destroy(
- this.ft,
- this.header,
- this.footer,
- this.toolbars,
- this.tbar,
- this.bbar,
- this.body,
- this.mc,
- this.bwrap
- );
- if (this.fbar) {
- Ext.destroy(
- this.fbar,
- this.fbar.el
- );
- }
- }else{
- Ext.destroy(
- this.topToolbar,
- this.bottomToolbar
- );
- }
- },
- createClasses : function(){
- this.headerCls = this.baseCls + '-header';
- this.headerTextCls = this.baseCls + '-header-text';
- this.bwrapCls = this.baseCls + '-bwrap';
- this.tbarCls = this.baseCls + '-tbar';
- this.bodyCls = this.baseCls + '-body';
- this.bbarCls = this.baseCls + '-bbar';
- this.footerCls = this.baseCls + '-footer';
- },
- createGhost : function(cls, useShim, appendTo){
- var el = document.createElement('div');
- el.className = 'x-panel-ghost ' + (cls ? cls : '');
- if(this.header){
- el.appendChild(this.el.dom.firstChild.cloneNode(true));
- }
- Ext.fly(el.appendChild(document.createElement('ul'))).setHeight(this.bwrap.getHeight());
- el.style.width = this.el.dom.offsetWidth + 'px';;
- if(!appendTo){
- this.container.dom.appendChild(el);
- }else{
- Ext.getDom(appendTo).appendChild(el);
- }
- if(useShim !== false && this.el.useShim !== false){
- var layer = new Ext.Layer({shadow:false, useDisplay:true, constrain:false}, el);
- layer.show();
- return layer;
- }else{
- return new Ext.Element(el);
- }
- },
- doAutoLoad : function(){
- var u = this.body.getUpdater();
- if(this.renderer){
- u.setRenderer(this.renderer);
- }
- u.update(Ext.isObject(this.autoLoad) ? this.autoLoad : {url: this.autoLoad});
- },
- getTool : function(id) {
- return this.tools[id];
- }
- });
- Ext.reg('panel', Ext.Panel);
- Ext.Editor = function(field, config){
- if(field.field){
- this.field = Ext.create(field.field, 'textfield');
- config = Ext.apply({}, field);
- delete config.field;
- }else{
- this.field = field;
- }
- Ext.Editor.superclass.constructor.call(this, config);
- };
- Ext.extend(Ext.Editor, Ext.Component, {
- value : "",
- alignment: "c-c?",
- offsets: [0, 0],
- shadow : "frame",
- constrain : false,
- swallowKeys : true,
- completeOnEnter : true,
- cancelOnEsc : true,
- updateEl : false,
- initComponent : function(){
- Ext.Editor.superclass.initComponent.call(this);
- this.addEvents(
- "beforestartedit",
- "startedit",
- "beforecomplete",
- "complete",
- "canceledit",
- "specialkey"
- );
- },
- onRender : function(ct, position){
- this.el = new Ext.Layer({
- shadow: this.shadow,
- cls: "x-editor",
- parentEl : ct,
- shim : this.shim,
- shadowOffset: this.shadowOffset || 4,
- id: this.id,
- constrain: this.constrain
- });
- if(this.zIndex){
- this.el.setZIndex(this.zIndex);
- }
- this.el.setStyle("overflow", Ext.isGecko ? "auto" : "hidden");
- if(this.field.msgTarget != 'title'){
- this.field.msgTarget = 'qtip';
- }
- this.field.inEditor = true;
- this.mon(this.field, {
- scope: this,
- blur: this.onBlur,
- specialkey: this.onSpecialKey
- });
- if(this.field.grow){
- this.mon(this.field, "autosize", this.el.sync, this.el, {delay:1});
- }
- this.field.render(this.el).show();
- this.field.getEl().dom.name = '';
- if(this.swallowKeys){
- this.field.el.swallowEvent([
- 'keypress',
- 'keydown'
- ]);
- }
- },
- onSpecialKey : function(field, e){
- var key = e.getKey(),
- complete = this.completeOnEnter && key == e.ENTER,
- cancel = this.cancelOnEsc && key == e.ESC;
- if(complete || cancel){
- e.stopEvent();
- if(complete){
- this.completeEdit();
- }else{
- this.cancelEdit();
- }
- if(field.triggerBlur){
- field.triggerBlur();
- }
- }
- this.fireEvent('specialkey', field, e);
- },
- startEdit : function(el, value){
- if(this.editing){
- this.completeEdit();
- }
- this.boundEl = Ext.get(el);
- var v = value !== undefined ? value : this.boundEl.dom.innerHTML;
- if(!this.rendered){
- this.render(this.parentEl || document.body);
- }
- if(this.fireEvent("beforestartedit", this, this.boundEl, v) !== false){
- this.startValue = v;
- this.field.reset();
- this.field.setValue(v);
- this.realign(true);
- this.editing = true;
- this.show();
- }
- },
- doAutoSize : function(){
- if(this.autoSize){
- var sz = this.boundEl.getSize(),
- fs = this.field.getSize();
- switch(this.autoSize){
- case "width":
- this.setSize(sz.width, fs.height);
- break;
- case "height":
- this.setSize(fs.width, sz.height);
- break;
- case "none":
- this.setSize(fs.width, fs.height);
- break;
- default:
- this.setSize(sz.width, sz.height);
- }
- }
- },
- setSize : function(w, h){
- delete this.field.lastSize;
- this.field.setSize(w, h);
- if(this.el){
- if(Ext.isGecko2 || Ext.isOpera){
- this.el.setSize(w, h);
- }
- this.el.sync();
- }
- },
- realign : function(autoSize){
- if(autoSize === true){
- this.doAutoSize();
- }
- this.el.alignTo(this.boundEl, this.alignment, this.offsets);
- },
- completeEdit : function(remainVisible){
- if(!this.editing){
- return;
- }
- var v = this.getValue();
- if(!this.field.isValid()){
- if(this.revertInvalid !== false){
- this.cancelEdit(remainVisible);
- }
- return;
- }
- if(String(v) === String(this.startValue) && this.ignoreNoChange){
- this.hideEdit(remainVisible);
- return;
- }
- if(this.fireEvent("beforecomplete", this, v, this.startValue) !== false){
- v = this.getValue();
- if(this.updateEl && this.boundEl){
- this.boundEl.update(v);
- }
- this.hideEdit(remainVisible);
- this.fireEvent("complete", this, v, this.startValue);
- }
- },
- onShow : function(){
- this.el.show();
- if(this.hideEl !== false){
- this.boundEl.hide();
- }
- this.field.show().focus(false, true);
- this.fireEvent("startedit", this.boundEl, this.startValue);
- },
- cancelEdit : function(remainVisible){
- if(this.editing){
- var v = this.getValue();
- this.setValue(this.startValue);
- this.hideEdit(remainVisible);
- this.fireEvent("canceledit", this, v, this.startValue);
- }
- },
- hideEdit: function(remainVisible){
- if(remainVisible !== true){
- this.editing = false;
- this.hide();
- }
- },
- onBlur : function(){
- if(this.allowBlur !== true && this.editing){
- this.completeEdit();
- }
- },
- onHide : function(){
- if(this.editing){
- this.completeEdit();
- return;
- }
- this.field.blur();
- if(this.field.collapse){
- this.field.collapse();
- }
- this.el.hide();
- if(this.hideEl !== false){
- this.boundEl.show();
- }
- },
- setValue : function(v){
- this.field.setValue(v);
- },
- getValue : function(){
- return this.field.getValue();
- },
- beforeDestroy : function(){
- Ext.destroyMembers(this, 'field');
- delete this.parentEl;
- delete this.boundEl;
- }
- });
- Ext.reg('editor', Ext.Editor);
- Ext.ColorPalette = Ext.extend(Ext.Component, {
- itemCls : 'x-color-palette',
- value : null,
- clickEvent :'click',
- ctype : 'Ext.ColorPalette',
- allowReselect : false,
- colors : [
- '000000', '993300', '333300', '003300', '003366', '000080', '333399', '333333',
- '800000', 'FF6600', '808000', '008000', '008080', '0000FF', '666699', '808080',
- 'FF0000', 'FF9900', '99CC00', '339966', '33CCCC', '3366FF', '800080', '969696',
- 'FF00FF', 'FFCC00', 'FFFF00', '00FF00', '00FFFF', '00CCFF', '993366', 'C0C0C0',
- 'FF99CC', 'FFCC99', 'FFFF99', 'CCFFCC', 'CCFFFF', '99CCFF', 'CC99FF', 'FFFFFF'
- ],
- initComponent : function(){
- Ext.ColorPalette.superclass.initComponent.call(this);
- this.addEvents(
- 'select'
- );
- if(this.handler){
- this.on('select', this.handler, this.scope, true);
- }
- },
- onRender : function(container, position){
- this.autoEl = {
- tag: 'div',
- cls: this.itemCls
- };
- Ext.ColorPalette.superclass.onRender.call(this, container, position);
- var t = this.tpl || new Ext.XTemplate(
- '<tpl for="."><a href="#" class="color-{.}" hidefocus="on"><em><span style="background:#{.}" unselectable="on"> </span></em></a></tpl>'
- );
- t.overwrite(this.el, this.colors);
- this.mon(this.el, this.clickEvent, this.handleClick, this, {delegate: 'a'});
- if(this.clickEvent != 'click'){
- this.mon(this.el, 'click', Ext.emptyFn, this, {delegate: 'a', preventDefault: true});
- }
- },
- afterRender : function(){
- Ext.ColorPalette.superclass.afterRender.call(this);
- if(this.value){
- var s = this.value;
- this.value = null;
- this.select(s);
- }
- },
- handleClick : function(e, t){
- e.preventDefault();
- if(!this.disabled){
- var c = t.className.match(/(?:^|s)color-(.{6})(?:s|$)/)[1];
- this.select(c.toUpperCase());
- }
- },
- select : function(color){
- color = color.replace('#', '');
- if(color != this.value || this.allowReselect){
- var el = this.el;
- if(this.value){
- el.child('a.color-'+this.value).removeClass('x-color-palette-sel');
- }
- el.child('a.color-'+color).addClass('x-color-palette-sel');
- this.value = color;
- this.fireEvent('select', this, color);
- }
- }
- });
- Ext.reg('colorpalette', Ext.ColorPalette);
- Ext.DatePicker = Ext.extend(Ext.BoxComponent, {
- todayText : 'Today',
- okText : ' OK ',
- cancelText : 'Cancel',
- todayTip : '{0} (Spacebar)',
- minText : 'This date is before the minimum date',
- maxText : 'This date is after the maximum date',
- format : 'm/d/y',
- disabledDaysText : 'Disabled',
- disabledDatesText : 'Disabled',
- monthNames : Date.monthNames,
- dayNames : Date.dayNames,
- nextText : 'Next Month (Control+Right)',
- prevText : 'Previous Month (Control+Left)',
- monthYearText : 'Choose a month (Control+Up/Down to move years)',
- startDay : 0,
- showToday : true,
- focusOnSelect: true,
- initComponent : function(){
- Ext.DatePicker.superclass.initComponent.call(this);
- this.value = this.value ?
- this.value.clearTime(true) : new Date().clearTime();
- this.addEvents(
- 'select'
- );
- if(this.handler){
- this.on('select', this.handler, this.scope || this);
- }
- this.initDisabledDays();
- },
- initDisabledDays : function(){
- if(!this.disabledDatesRE && this.disabledDates){
- var dd = this.disabledDates,
- len = dd.length - 1,
- re = '(?:';
- Ext.each(dd, function(d, i){
- re += Ext.isDate(d) ? '^' + Ext.escapeRe(d.dateFormat(this.format)) + '$' : dd[i];
- if(i != len){
- re += '|';
- }
- }, this);
- this.disabledDatesRE = new RegExp(re + ')');
- }
- },
- setDisabledDates : function(dd){
- if(Ext.isArray(dd)){
- this.disabledDates = dd;
- this.disabledDatesRE = null;
- }else{
- this.disabledDatesRE = dd;
- }
- this.initDisabledDays();
- this.update(this.value, true);
- },
- setDisabledDays : function(dd){
- this.disabledDays = dd;
- this.update(this.value, true);
- },
- setMinDate : function(dt){
- this.minDate = dt;
- this.update(this.value, true);
- },
- setMaxDate : function(dt){
- this.maxDate = dt;
- this.update(this.value, true);
- },
- setValue : function(value){
- this.value = value.clearTime(true);
- this.update(this.value);
- },
- getValue : function(){
- return this.value;
- },
- focus : function(){
- this.update(this.activeDate);
- },
- onEnable: function(initial){
- Ext.DatePicker.superclass.onEnable.call(this);
- this.doDisabled(false);
- this.update(initial ? this.value : this.activeDate);
- if(Ext.isIE){
- this.el.repaint();
- }
- },
- onDisable : function(){
- Ext.DatePicker.superclass.onDisable.call(this);
- this.doDisabled(true);
- if(Ext.isIE && !Ext.isIE8){
- Ext.each([].concat(this.textNodes, this.el.query('th span')), function(el){
- Ext.fly(el).repaint();
- });
- }
- },
- doDisabled : function(disabled){
- this.keyNav.setDisabled(disabled);
- this.prevRepeater.setDisabled(disabled);
- this.nextRepeater.setDisabled(disabled);
- if(this.showToday){
- this.todayKeyListener.setDisabled(disabled);
- this.todayBtn.setDisabled(disabled);
- }
- },
- onRender : function(container, position){
- var m = [
- '<table cellspacing="0">',
- '<tr><td class="x-date-left"><a href="#" title="', this.prevText ,'"> </a></td><td class="x-date-middle" align="center"></td><td class="x-date-right"><a href="#" title="', this.nextText ,'"> </a></td></tr>',
- '<tr><td colspan="3"><table class="x-date-inner" cellspacing="0"><thead><tr>'],
- dn = this.dayNames,
- i;
- for(i = 0; i < 7; i++){
- var d = this.startDay+i;
- if(d > 6){
- d = d-7;
- }
- m.push('<th><span>', dn[d].substr(0,1), '</span></th>');
- }
- m[m.length] = '</tr></thead><tbody><tr>';
- for(i = 0; i < 42; i++) {
- if(i % 7 === 0 && i !== 0){
- m[m.length] = '</tr><tr>';
- }
- m[m.length] = '<td><a href="#" hidefocus="on" class="x-date-date" tabIndex="1"><em><span></span></em></a></td>';
- }
- m.push('</tr></tbody></table></td></tr>',
- this.showToday ? '<tr><td colspan="3" class="x-date-bottom" align="center"></td></tr>' : '',
- '</table><div class="x-date-mp"></div>');
- var el = document.createElement('div');
- el.className = 'x-date-picker';
- el.innerHTML = m.join('');
- container.dom.insertBefore(el, position);
- this.el = Ext.get(el);
- this.eventEl = Ext.get(el.firstChild);
- this.prevRepeater = new Ext.util.ClickRepeater(this.el.child('td.x-date-left a'), {
- handler: this.showPrevMonth,
- scope: this,
- preventDefault:true,
- stopDefault:true
- });
- this.nextRepeater = new Ext.util.ClickRepeater(this.el.child('td.x-date-right a'), {
- handler: this.showNextMonth,
- scope: this,
- preventDefault:true,
- stopDefault:true
- });
- this.monthPicker = this.el.down('div.x-date-mp');
- this.monthPicker.enableDisplayMode('block');
- this.keyNav = new Ext.KeyNav(this.eventEl, {
- 'left' : function(e){
- if(e.ctrlKey){
- this.showPrevMonth();
- }else{
- this.update(this.activeDate.add('d', -1));
- }
- },
- 'right' : function(e){
- if(e.ctrlKey){
- this.showNextMonth();
- }else{
- this.update(this.activeDate.add('d', 1));
- }
- },
- 'up' : function(e){
- if(e.ctrlKey){
- this.showNextYear();
- }else{
- this.update(this.activeDate.add('d', -7));
- }
- },
- 'down' : function(e){
- if(e.ctrlKey){
- this.showPrevYear();
- }else{
- this.update(this.activeDate.add('d', 7));
- }
- },
- 'pageUp' : function(e){
- this.showNextMonth();
- },
- 'pageDown' : function(e){
- this.showPrevMonth();
- },
- 'enter' : function(e){
- e.stopPropagation();
- return true;
- },
- scope : this
- });
- this.el.unselectable();
- this.cells = this.el.select('table.x-date-inner tbody td');
- this.textNodes = this.el.query('table.x-date-inner tbody span');
- this.mbtn = new Ext.Button({
- text: ' ',
- tooltip: this.monthYearText,
- renderTo: this.el.child('td.x-date-middle', true)
- });
- this.mbtn.el.child('em').addClass('x-btn-arrow');
- if(this.showToday){
- this.todayKeyListener = this.eventEl.addKeyListener(Ext.EventObject.SPACE, this.selectToday, this);
- var today = (new Date()).dateFormat(this.format);
- this.todayBtn = new Ext.Button({
- renderTo: this.el.child('td.x-date-bottom', true),
- text: String.format(this.todayText, today),
- tooltip: String.format(this.todayTip, today),
- handler: this.selectToday,
- scope: this
- });
- }
- this.mon(this.eventEl, 'mousewheel', this.handleMouseWheel, this);
- this.mon(this.eventEl, 'click', this.handleDateClick, this, {delegate: 'a.x-date-date'});
- this.mon(this.mbtn, 'click', this.showMonthPicker, this);
- this.onEnable(true);
- },
- createMonthPicker : function(){
- if(!this.monthPicker.dom.firstChild){
- var buf = ['<table border="0" cellspacing="0">'];
- for(var i = 0; i < 6; i++){
- buf.push(
- '<tr><td class="x-date-mp-month"><a href="#">', Date.getShortMonthName(i), '</a></td>',
- '<td class="x-date-mp-month x-date-mp-sep"><a href="#">', Date.getShortMonthName(i + 6), '</a></td>',
- i === 0 ?
- '<td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-prev"></a></td><td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-next"></a></td></tr>' :
- '<td class="x-date-mp-year"><a href="#"></a></td><td class="x-date-mp-year"><a href="#"></a></td></tr>'
- );
- }
- buf.push(
- '<tr class="x-date-mp-btns"><td colspan="4"><button type="button" class="x-date-mp-ok">',
- this.okText,
- '</button><button type="button" class="x-date-mp-cancel">',
- this.cancelText,
- '</button></td></tr>',
- '</table>'
- );
- this.monthPicker.update(buf.join(''));
- this.mon(this.monthPicker, 'click', this.onMonthClick, this);
- this.mon(this.monthPicker, 'dblclick', this.onMonthDblClick, this);
- this.mpMonths = this.monthPicker.select('td.x-date-mp-month');
- this.mpYears = this.monthPicker.select('td.x-date-mp-year');
- this.mpMonths.each(function(m, a, i){
- i += 1;
- if((i%2) === 0){
- m.dom.xmonth = 5 + Math.round(i * 0.5);
- }else{
- m.dom.xmonth = Math.round((i-1) * 0.5);
- }
- });
- }
- },
- showMonthPicker : function(){
- if(!this.disabled){
- this.createMonthPicker();
- var size = this.el.getSize();
- this.monthPicker.setSize(size);
- this.monthPicker.child('table').setSize(size);
- this.mpSelMonth = (this.activeDate || this.value).getMonth();
- this.updateMPMonth(this.mpSelMonth);
- this.mpSelYear = (this.activeDate || this.value).getFullYear();
- this.updateMPYear(this.mpSelYear);
- this.monthPicker.slideIn('t', {duration:0.2});
- }
- },
- updateMPYear : function(y){
- this.mpyear = y;
- var ys = this.mpYears.elements;
- for(var i = 1; i <= 10; i++){
- var td = ys[i-1], y2;
- if((i%2) === 0){
- y2 = y + Math.round(i * 0.5);
- td.firstChild.innerHTML = y2;
- td.xyear = y2;
- }else{
- y2 = y - (5-Math.round(i * 0.5));
- td.firstChild.innerHTML = y2;
- td.xyear = y2;
- }
- this.mpYears.item(i-1)[y2 == this.mpSelYear ? 'addClass' : 'removeClass']('x-date-mp-sel');
- }
- },
- updateMPMonth : function(sm){
- this.mpMonths.each(function(m, a, i){
- m[m.dom.xmonth == sm ? 'addClass' : 'removeClass']('x-date-mp-sel');
- });
- },
- selectMPMonth : function(m){
- },
- onMonthClick : function(e, t){
- e.stopEvent();
- var el = new Ext.Element(t), pn;
- if(el.is('button.x-date-mp-cancel')){
- this.hideMonthPicker();
- }
- else if(el.is('button.x-date-mp-ok')){
- var d = new Date(this.mpSelYear, this.mpSelMonth, (this.activeDate || this.value).getDate());
- if(d.getMonth() != this.mpSelMonth){
- d = new Date(this.mpSelYear, this.mpSelMonth, 1).getLastDateOfMonth();
- }
- this.update(d);
- this.hideMonthPicker();
- }
- else if((pn = el.up('td.x-date-mp-month', 2))){
- this.mpMonths.removeClass('x-date-mp-sel');
- pn.addClass('x-date-mp-sel');
- this.mpSelMonth = pn.dom.xmonth;
- }
- else if((pn = el.up('td.x-date-mp-year', 2))){
- this.mpYears.removeClass('x-date-mp-sel');
- pn.addClass('x-date-mp-sel');
- this.mpSelYear = pn.dom.xyear;
- }
- else if(el.is('a.x-date-mp-prev')){
- this.updateMPYear(this.mpyear-10);
- }
- else if(el.is('a.x-date-mp-next')){
- this.updateMPYear(this.mpyear+10);
- }
- },
- onMonthDblClick : function(e, t){
- e.stopEvent();
- var el = new Ext.Element(t), pn;
- if((pn = el.up('td.x-date-mp-month', 2))){
- this.update(new Date(this.mpSelYear, pn.dom.xmonth, (this.activeDate || this.value).getDate()));
- this.hideMonthPicker();
- }
- else if((pn = el.up('td.x-date-mp-year', 2))){
- this.update(new Date(pn.dom.xyear, this.mpSelMonth, (this.activeDate || this.value).getDate()));
- this.hideMonthPicker();
- }
- },
- hideMonthPicker : function(disableAnim){
- if(this.monthPicker){
- if(disableAnim === true){
- this.monthPicker.hide();
- }else{
- this.monthPicker.slideOut('t', {duration:0.2});
- }
- }
- },
- showPrevMonth : function(e){
- this.update(this.activeDate.add('mo', -1));
- },
- showNextMonth : function(e){
- this.update(this.activeDate.add('mo', 1));
- },
- showPrevYear : function(){
- this.update(this.activeDate.add('y', -1));
- },
- showNextYear : function(){
- this.update(this.activeDate.add('y', 1));
- },
- handleMouseWheel : function(e){
- e.stopEvent();
- if(!this.disabled){
- var delta = e.getWheelDelta();
- if(delta > 0){
- this.showPrevMonth();
- } else if(delta < 0){
- this.showNextMonth();
- }
- }
- },
- handleDateClick : function(e, t){
- e.stopEvent();
- if(!this.disabled && t.dateValue && !Ext.fly(t.parentNode).hasClass('x-date-disabled')){
- this.cancelFocus = this.focusOnSelect === false;
- this.setValue(new Date(t.dateValue));
- delete this.cancelFocus;
- this.fireEvent('select', this, this.value);
- }
- },
- selectToday : function(){
- if(this.todayBtn && !this.todayBtn.disabled){
- this.setValue(new Date().clearTime());
- this.fireEvent('select', this, this.value);
- }
- },
- update : function(date, forceRefresh){
- if(this.rendered){
- var vd = this.activeDate, vis = this.isVisible();
- this.activeDate = date;
- if(!forceRefresh && vd && this.el){
- var t = date.getTime();
- if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
- this.cells.removeClass('x-date-selected');
- this.cells.each(function(c){
- if(c.dom.firstChild.dateValue == t){
- c.addClass('x-date-selected');
- if(vis && !this.cancelFocus){
- Ext.fly(c.dom.firstChild).focus(50);
- }
- return false;
- }
- }, this);
- return;
- }
- }
- var days = date.getDaysInMonth(),
- firstOfMonth = date.getFirstDateOfMonth(),
- startingPos = firstOfMonth.getDay()-this.startDay;
- if(startingPos < 0){
- startingPos += 7;
- }
- days += startingPos;
- var pm = date.add('mo', -1),
- prevStart = pm.getDaysInMonth()-startingPos,
- cells = this.cells.elements,
- textEls = this.textNodes,
- day = 86400000,
- d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime(),
- today = new Date().clearTime().getTime(),
- sel = date.clearTime(true).getTime(),
- min = this.minDate ? this.minDate.clearTime(true) : Number.NEGATIVE_INFINITY,
- max = this.maxDate ? this.maxDate.clearTime(true) : Number.POSITIVE_INFINITY,
- ddMatch = this.disabledDatesRE,
- ddText = this.disabledDatesText,
- ddays = this.disabledDays ? this.disabledDays.join('') : false,
- ddaysText = this.disabledDaysText,
- format = this.format;
- if(this.showToday){
- var td = new Date().clearTime(),
- disable = (td < min || td > max ||
- (ddMatch && format && ddMatch.test(td.dateFormat(format))) ||
- (ddays && ddays.indexOf(td.getDay()) != -1));
- if(!this.disabled){
- this.todayBtn.setDisabled(disable);
- this.todayKeyListener[disable ? 'disable' : 'enable']();
- }
- }
- var setCellClass = function(cal, cell){
- cell.title = '';
- var t = d.getTime();
- cell.firstChild.dateValue = t;
- if(t == today){
- cell.className += ' x-date-today';
- cell.title = cal.todayText;
- }
- if(t == sel){
- cell.className += ' x-date-selected';
- if(vis){
- Ext.fly(cell.firstChild).focus(50);
- }
- }
- if(t < min) {
- cell.className = ' x-date-disabled';
- cell.title = cal.minText;
- return;
- }
- if(t > max) {
- cell.className = ' x-date-disabled';
- cell.title = cal.maxText;
- return;
- }
- if(ddays){
- if(ddays.indexOf(d.getDay()) != -1){
- cell.title = ddaysText;
- cell.className = ' x-date-disabled';
- }
- }
- if(ddMatch && format){
- var fvalue = d.dateFormat(format);
- if(ddMatch.test(fvalue)){
- cell.title = ddText.replace('%0', fvalue);
- cell.className = ' x-date-disabled';
- }
- }
- };
- var i = 0;
- for(; i < startingPos; i++) {
- textEls[i].innerHTML = (++prevStart);
- d.setDate(d.getDate()+1);
- cells[i].className = 'x-date-prevday';
- setCellClass(this, cells[i]);
- }
- for(; i < days; i++){
- var intDay = i - startingPos + 1;
- textEls[i].innerHTML = (intDay);
- d.setDate(d.getDate()+1);
- cells[i].className = 'x-date-active';
- setCellClass(this, cells[i]);
- }
- var extraDays = 0;
- for(; i < 42; i++) {
- textEls[i].innerHTML = (++extraDays);
- d.setDate(d.getDate()+1);
- cells[i].className = 'x-date-nextday';
- setCellClass(this, cells[i]);
- }
- this.mbtn.setText(this.monthNames[date.getMonth()] + ' ' + date.getFullYear());
- if(!this.internalRender){
- var main = this.el.dom.firstChild,
- w = main.offsetWidth;
- this.el.setWidth(w + this.el.getBorderWidth('lr'));
- Ext.fly(main).setWidth(w);
- this.internalRender = true;
- if(Ext.isOpera && !this.secondPass){
- main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + 'px';
- this.secondPass = true;
- this.update.defer(10, this, [date]);
- }
- }
- }
- },
- beforeDestroy : function() {
- if(this.rendered){
- Ext.destroy(
- this.keyNav,
- this.monthPicker,
- this.eventEl,
- this.mbtn,
- this.nextRepeater,
- this.prevRepeater,
- this.cells.el,
- this.todayBtn
- );
- delete this.textNodes;
- delete this.cells.elements;
- }
- }
- });
- Ext.reg('datepicker', Ext.DatePicker);
- Ext.LoadMask = function(el, config){
- this.el = Ext.get(el);
- Ext.apply(this, config);
- if(this.store){
- this.store.on({
- scope: this,
- beforeload: this.onBeforeLoad,
- load: this.onLoad,
- exception: this.onLoad
- });
- this.removeMask = Ext.value(this.removeMask, false);
- }else{
- var um = this.el.getUpdater();
- um.showLoadIndicator = false;
- um.on({
- scope: this,
- beforeupdate: this.onBeforeLoad,
- update: this.onLoad,
- failure: this.onLoad
- });
- this.removeMask = Ext.value(this.removeMask, true);
- }
- };
- Ext.LoadMask.prototype = {
- msg : 'Loading...',
- msgCls : 'x-mask-loading',
- disabled: false,
- disable : function(){
- this.disabled = true;
- },
- enable : function(){
- this.disabled = false;
- },
- onLoad : function(){
- this.el.unmask(this.removeMask);
- },
- onBeforeLoad : function(){
- if(!this.disabled){
- this.el.mask(this.msg, this.msgCls);
- }
- },
- show: function(){
- this.onBeforeLoad();
- },
- hide: function(){
- this.onLoad();
- },
- destroy : function(){
- if(this.store){
- this.store.un('beforeload', this.onBeforeLoad, this);
- this.store.un('load', this.onLoad, this);
- this.store.un('exception', this.onLoad, this);
- }else{
- var um = this.el.getUpdater();
- um.un('beforeupdate', this.onBeforeLoad, this);
- um.un('update', this.onLoad, this);
- um.un('failure', this.onLoad, this);
- }
- }
- };
- Ext.Slider = Ext.extend(Ext.BoxComponent, {
- vertical: false,
- minValue: 0,
- maxValue: 100,
- decimalPrecision: 0,
- keyIncrement: 1,
- increment: 0,
- clickRange: [5,15],
- clickToChange : true,
- animate: true,
- dragging: false,
- initComponent : function(){
- if(!Ext.isDefined(this.value)){
- this.value = this.minValue;
- }
- Ext.Slider.superclass.initComponent.call(this);
- this.keyIncrement = Math.max(this.increment, this.keyIncrement);
- this.addEvents(
- 'beforechange',
- 'change',
- 'changecomplete',
- 'dragstart',
- 'drag',
- 'dragend'
- );
- if(this.vertical){
- Ext.apply(this, Ext.Slider.Vertical);
- }
- },
- onRender : function(){
- this.autoEl = {
- cls: 'x-slider ' + (this.vertical ? 'x-slider-vert' : 'x-slider-horz'),
- cn:{cls:'x-slider-end',cn:{cls:'x-slider-inner',cn:[{cls:'x-slider-thumb'},{tag:'a', cls:'x-slider-focus', href:"#", tabIndex: '-1', hidefocus:'on'}]}}
- };
- Ext.Slider.superclass.onRender.apply(this, arguments);
- this.endEl = this.el.first();
- this.innerEl = this.endEl.first();
- this.thumb = this.innerEl.first();
- this.halfThumb = (this.vertical ? this.thumb.getHeight() : this.thumb.getWidth())/2;
- this.focusEl = this.thumb.next();
- this.initEvents();
- },
- initEvents : function(){
- this.thumb.addClassOnOver('x-slider-thumb-over');
- this.mon(this.el, {
- scope: this,
- mousedown: this.onMouseDown,
- keydown: this.onKeyDown
- });
- this.focusEl.swallowEvent("click", true);
- this.tracker = new Ext.dd.DragTracker({
- onBeforeStart: this.onBeforeDragStart.createDelegate(this),
- onStart: this.onDragStart.createDelegate(this),
- onDrag: this.onDrag.createDelegate(this),
- onEnd: this.onDragEnd.createDelegate(this),
- tolerance: 3,
- autoStart: 300
- });
- this.tracker.initEl(this.thumb);
- },
- onMouseDown : function(e){
- if(this.disabled){
- return;
- }
- if(this.clickToChange && e.target != this.thumb.dom){
- var local = this.innerEl.translatePoints(e.getXY());
- this.onClickChange(local);
- }
- this.focus();
- },
- onClickChange : function(local){
- if(local.top > this.clickRange[0] && local.top < this.clickRange[1]){
- this.setValue(Ext.util.Format.round(this.reverseValue(local.left), this.decimalPrecision), undefined, true);
- }
- },
- onKeyDown : function(e){
- if(this.disabled){e.preventDefault();return;}
- var k = e.getKey();
- switch(k){
- case e.UP:
- case e.RIGHT:
- e.stopEvent();
- if(e.ctrlKey){
- this.setValue(this.maxValue, undefined, true);
- }else{
- this.setValue(this.value+this.keyIncrement, undefined, true);
- }
- break;
- case e.DOWN:
- case e.LEFT:
- e.stopEvent();
- if(e.ctrlKey){
- this.setValue(this.minValue, undefined, true);
- }else{
- this.setValue(this.value-this.keyIncrement, undefined, true);
- }
- break;
- default:
- e.preventDefault();
- }
- },
- doSnap : function(value){
- if(!(this.increment && value)){
- return value;
- }
- var newValue = value,
- inc = this.increment,
- m = value % inc;
- if(m != 0){
- newValue -= m;
- if(m * 2 > inc){
- newValue += inc;
- }else if(m * 2 < -inc){
- newValue -= inc;
- }
- }
- return newValue.constrain(this.minValue, this.maxValue);
- },
- afterRender : function(){
- Ext.Slider.superclass.afterRender.apply(this, arguments);
- if(this.value !== undefined){
- var v = this.normalizeValue(this.value);
- if(v !== this.value){
- delete this.value;
- this.setValue(v, false);
- }else{
- this.moveThumb(this.translateValue(v), false);
- }
- }
- },
- getRatio : function(){
- var w = this.innerEl.getWidth(),
- v = this.maxValue - this.minValue;
- return v == 0 ? w : (w/v);
- },
- normalizeValue : function(v){
- v = this.doSnap(v);
- v = Ext.util.Format.round(v, this.decimalPrecision);
- v = v.constrain(this.minValue, this.maxValue);
- return v;
- },
- setValue : function(v, animate, changeComplete){
- v = this.normalizeValue(v);
- if(v !== this.value && this.fireEvent('beforechange', this, v, this.value) !== false){
- this.value = v;
- this.moveThumb(this.translateValue(v), animate !== false);
- this.fireEvent('change', this, v);
- if(changeComplete){
- this.fireEvent('changecomplete', this, v);
- }
- }
- },
- translateValue : function(v){
- var ratio = this.getRatio();
- return (v * ratio) - (this.minValue * ratio) - this.halfThumb;
- },
- reverseValue : function(pos){
- var ratio = this.getRatio();
- return (pos + this.halfThumb + (this.minValue * ratio)) / ratio;
- },
- moveThumb: function(v, animate){
- if(!animate || this.animate === false){
- this.thumb.setLeft(v);
- }else{
- this.thumb.shift({left: v, stopFx: true, duration:.35});
- }
- },
- focus : function(){
- this.focusEl.focus(10);
- },
- onBeforeDragStart : function(e){
- return !this.disabled;
- },
- onDragStart: function(e){
- this.thumb.addClass('x-slider-thumb-drag');
- this.dragging = true;
- this.dragStartValue = this.value;
- this.fireEvent('dragstart', this, e);
- },
- onDrag: function(e){
- var pos = this.innerEl.translatePoints(this.tracker.getXY());
- this.setValue(Ext.util.Format.round(this.reverseValue(pos.left), this.decimalPrecision), false);
- this.fireEvent('drag', this, e);
- },
- onDragEnd: function(e){
- this.thumb.removeClass('x-slider-thumb-drag');
- this.dragging = false;
- this.fireEvent('dragend', this, e);
- if(this.dragStartValue != this.value){
- this.fireEvent('changecomplete', this, this.value);
- }
- },
- onResize : function(w, h){
- this.innerEl.setWidth(w - (this.el.getPadding('l') + this.endEl.getPadding('r')));
- this.syncThumb();
- },
- onDisable: function(){
- Ext.Slider.superclass.onDisable.call(this);
- this.thumb.addClass(this.disabledClass);
- if(Ext.isIE){
- var xy = this.thumb.getXY();
- this.thumb.hide();
- this.innerEl.addClass(this.disabledClass).dom.disabled = true;
- if (!this.thumbHolder){
- this.thumbHolder = this.endEl.createChild({cls: 'x-slider-thumb ' + this.disabledClass});
- }
- this.thumbHolder.show().setXY(xy);
- }
- },
- onEnable: function(){
- Ext.Slider.superclass.onEnable.call(this);
- this.thumb.removeClass(this.disabledClass);
- if(Ext.isIE){
- this.innerEl.removeClass(this.disabledClass).dom.disabled = false;
- if(this.thumbHolder){
- this.thumbHolder.hide();
- }
- this.thumb.show();
- this.syncThumb();
- }
- },
- syncThumb : function(){
- if(this.rendered){
- this.moveThumb(this.translateValue(this.value));
- }
- },
- getValue : function(){
- return this.value;
- },
- beforeDestroy : function(){
- Ext.destroyMembers(this, 'endEl', 'innerEl', 'thumb', 'halfThumb', 'focusEl', 'tracker', 'thumbHolder');
- Ext.Slider.superclass.beforeDestroy.call(this);
- }
- });
- Ext.reg('slider', Ext.Slider);
- Ext.Slider.Vertical = {
- onResize : function(w, h){
- this.innerEl.setHeight(h - (this.el.getPadding('t') + this.endEl.getPadding('b')));
- this.syncThumb();
- },
- getRatio : function(){
- var h = this.innerEl.getHeight(),
- v = this.maxValue - this.minValue;
- return h/v;
- },
- moveThumb: function(v, animate){
- if(!animate || this.animate === false){
- this.thumb.setBottom(v);
- }else{
- this.thumb.shift({bottom: v, stopFx: true, duration:.35});
- }
- },
- onDrag: function(e){
- var pos = this.innerEl.translatePoints(this.tracker.getXY()),
- bottom = this.innerEl.getHeight()-pos.top;
- this.setValue(this.minValue + Ext.util.Format.round(bottom/this.getRatio(), this.decimalPrecision), false);
- this.fireEvent('drag', this, e);
- },
- onClickChange : function(local){
- if(local.left > this.clickRange[0] && local.left < this.clickRange[1]){
- var bottom = this.innerEl.getHeight() - local.top;
- this.setValue(this.minValue + Ext.util.Format.round(bottom/this.getRatio(), this.decimalPrecision), undefined, true);
- }
- }
- };
- Ext.ProgressBar = Ext.extend(Ext.BoxComponent, {
- baseCls : 'x-progress',
- animate : false,
- waitTimer : null,
- initComponent : function(){
- Ext.ProgressBar.superclass.initComponent.call(this);
- this.addEvents(
- "update"
- );
- },
- onRender : function(ct, position){
- var tpl = new Ext.Template(
- '<div class="{cls}-wrap">',
- '<div class="{cls}-inner">',
- '<div class="{cls}-bar">',
- '<div class="{cls}-text">',
- '<div> </div>',
- '</div>',
- '</div>',
- '<div class="{cls}-text {cls}-text-back">',
- '<div> </div>',
- '</div>',
- '</div>',
- '</div>'
- );
- this.el = position ? tpl.insertBefore(position, {cls: this.baseCls}, true)
- : tpl.append(ct, {cls: this.baseCls}, true);
- if(this.id){
- this.el.dom.id = this.id;
- }
- var inner = this.el.dom.firstChild;
- this.progressBar = Ext.get(inner.firstChild);
- if(this.textEl){
- this.textEl = Ext.get(this.textEl);
- delete this.textTopEl;
- }else{
- this.textTopEl = Ext.get(this.progressBar.dom.firstChild);
- var textBackEl = Ext.get(inner.childNodes[1]);
- this.textTopEl.setStyle("z-index", 99).addClass('x-hidden');
- this.textEl = new Ext.CompositeElement([this.textTopEl.dom.firstChild, textBackEl.dom.firstChild]);
- this.textEl.setWidth(inner.offsetWidth);
- }
- this.progressBar.setHeight(inner.offsetHeight);
- },
- afterRender : function(){
- Ext.ProgressBar.superclass.afterRender.call(this);
- if(this.value){
- this.updateProgress(this.value, this.text);
- }else{
- this.updateText(this.text);
- }
- },
- updateProgress : function(value, text, animate){
- this.value = value || 0;
- if(text){
- this.updateText(text);
- }
- if(this.rendered){
- var w = Math.floor(value*this.el.dom.firstChild.offsetWidth);
- this.progressBar.setWidth(w, animate === true || (animate !== false && this.animate));
- if(this.textTopEl){
- this.textTopEl.removeClass('x-hidden').setWidth(w);
- }
- }
- this.fireEvent('update', this, value, text);
- return this;
- },
- wait : function(o){
- if(!this.waitTimer){
- var scope = this;
- o = o || {};
- this.updateText(o.text);
- this.waitTimer = Ext.TaskMgr.start({
- run: function(i){
- var inc = o.increment || 10;
- i -= 1;
- this.updateProgress(((((i+inc)%inc)+1)*(100/inc))*0.01, null, o.animate);
- },
- interval: o.interval || 1000,
- duration: o.duration,
- onStop: function(){
- if(o.fn){
- o.fn.apply(o.scope || this);
- }
- this.reset();
- },
- scope: scope
- });
- }
- return this;
- },
- isWaiting : function(){
- return this.waitTimer !== null;
- },
- updateText : function(text){
- this.text = text || ' ';
- if(this.rendered){
- this.textEl.update(this.text);
- }
- return this;
- },
- syncProgressBar : function(){
- if(this.value){
- this.updateProgress(this.value, this.text);
- }
- return this;
- },
- setSize : function(w, h){
- Ext.ProgressBar.superclass.setSize.call(this, w, h);
- if(this.textTopEl){
- var inner = this.el.dom.firstChild;
- this.textEl.setSize(inner.offsetWidth, inner.offsetHeight);
- }
- this.syncProgressBar();
- return this;
- },
- reset : function(hide){
- this.updateProgress(0);
- if(this.textTopEl){
- this.textTopEl.addClass('x-hidden');
- }
- if(this.waitTimer){
- this.waitTimer.onStop = null;
- Ext.TaskMgr.stop(this.waitTimer);
- this.waitTimer = null;
- }
- if(hide === true){
- this.hide();
- }
- return this;
- },
- onDestroy: function(){
- if(this.rendered){
- if(this.textEl.isComposite){
- this.textEl.clear();
- }
- Ext.destroyMembers(this, 'textEl', 'progressBar', 'textTopEl');
- }
- Ext.ProgressBar.superclass.onDestroy.call(this);
- }
- });
- Ext.reg('progress', Ext.ProgressBar);
- (function() {
- var Event=Ext.EventManager;
- var Dom=Ext.lib.Dom;
- Ext.dd.DragDrop = function(id, sGroup, config) {
- if(id) {
- this.init(id, sGroup, config);
- }
- };
- Ext.dd.DragDrop.prototype = {
- id: null,
- config: null,
- dragElId: null,
- handleElId: null,
- invalidHandleTypes: null,
- invalidHandleIds: null,
- invalidHandleClasses: null,
- startPageX: 0,
- startPageY: 0,
- groups: null,
- locked: false,
- lock: function() { this.locked = true; },
- moveOnly: false,
- unlock: function() { this.locked = false; },
- isTarget: true,
- padding: null,
- _domRef: null,
- __ygDragDrop: true,
- constrainX: false,
- constrainY: false,
- minX: 0,
- maxX: 0,
- minY: 0,
- maxY: 0,
- maintainOffset: false,
- xTicks: null,
- yTicks: null,
- primaryButtonOnly: true,
- available: false,
- hasOuterHandles: false,
- b4StartDrag: function(x, y) { },
- startDrag: function(x, y) { },
- b4Drag: function(e) { },
- onDrag: function(e) { },
- onDragEnter: function(e, id) { },
- b4DragOver: function(e) { },
- onDragOver: function(e, id) { },
- b4DragOut: function(e) { },
- onDragOut: function(e, id) { },
- b4DragDrop: function(e) { },
- onDragDrop: function(e, id) { },
- onInvalidDrop: function(e) { },
- b4EndDrag: function(e) { },
- endDrag: function(e) { },
- b4MouseDown: function(e) { },
- onMouseDown: function(e) { },
- onMouseUp: function(e) { },
- onAvailable: function () {
- },
- defaultPadding : {left:0, right:0, top:0, bottom:0},
- constrainTo : function(constrainTo, pad, inContent){
- if(Ext.isNumber(pad)){
- pad = {left: pad, right:pad, top:pad, bottom:pad};
- }
- pad = pad || this.defaultPadding;
- var b = Ext.get(this.getEl()).getBox(),
- ce = Ext.get(constrainTo),
- s = ce.getScroll(),
- c,
- cd = ce.dom;
- if(cd == document.body){
- c = { x: s.left, y: s.top, width: Ext.lib.Dom.getViewWidth(), height: Ext.lib.Dom.getViewHeight()};
- }else{
- var xy = ce.getXY();
- c = {x : xy[0], y: xy[1], width: cd.clientWidth, height: cd.clientHeight};
- }
- var topSpace = b.y - c.y,
- leftSpace = b.x - c.x;
- this.resetConstraints();
- this.setXConstraint(leftSpace - (pad.left||0),
- c.width - leftSpace - b.width - (pad.right||0),
- this.xTickSize
- );
- this.setYConstraint(topSpace - (pad.top||0),
- c.height - topSpace - b.height - (pad.bottom||0),
- this.yTickSize
- );
- },
- getEl: function() {
- if (!this._domRef) {
- this._domRef = Ext.getDom(this.id);
- }
- return this._domRef;
- },
- getDragEl: function() {
- return Ext.getDom(this.dragElId);
- },
- init: function(id, sGroup, config) {
- this.initTarget(id, sGroup, config);
- Event.on(this.id, "mousedown", this.handleMouseDown, this);
- },
- initTarget: function(id, sGroup, config) {
- this.config = config || {};
- this.DDM = Ext.dd.DDM;
- this.groups = {};
- if (typeof id !== "string") {
- id = Ext.id(id);
- }
- this.id = id;
- this.addToGroup((sGroup) ? sGroup : "default");
- this.handleElId = id;
- this.setDragElId(id);
- this.invalidHandleTypes = { A: "A" };
- this.invalidHandleIds = {};
- this.invalidHandleClasses = [];
- this.applyConfig();
- this.handleOnAvailable();
- },
- applyConfig: function() {
- this.padding = this.config.padding || [0, 0, 0, 0];
- this.isTarget = (this.config.isTarget !== false);
- this.maintainOffset = (this.config.maintainOffset);
- this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);
- },
- handleOnAvailable: function() {
- this.available = true;
- this.resetConstraints();
- this.onAvailable();
- },
- setPadding: function(iTop, iRight, iBot, iLeft) {
- if (!iRight && 0 !== iRight) {
- this.padding = [iTop, iTop, iTop, iTop];
- } else if (!iBot && 0 !== iBot) {
- this.padding = [iTop, iRight, iTop, iRight];
- } else {
- this.padding = [iTop, iRight, iBot, iLeft];
- }
- },
- setInitPosition: function(diffX, diffY) {
- var el = this.getEl();
- if (!this.DDM.verifyEl(el)) {
- return;
- }
- var dx = diffX || 0;
- var dy = diffY || 0;
- var p = Dom.getXY( el );
- this.initPageX = p[0] - dx;
- this.initPageY = p[1] - dy;
- this.lastPageX = p[0];
- this.lastPageY = p[1];
- this.setStartPosition(p);
- },
- setStartPosition: function(pos) {
- var p = pos || Dom.getXY( this.getEl() );
- this.deltaSetXY = null;
- this.startPageX = p[0];
- this.startPageY = p[1];
- },
- addToGroup: function(sGroup) {
- this.groups[sGroup] = true;
- this.DDM.regDragDrop(this, sGroup);
- },
- removeFromGroup: function(sGroup) {
- if (this.groups[sGroup]) {
- delete this.groups[sGroup];
- }
- this.DDM.removeDDFromGroup(this, sGroup);
- },
- setDragElId: function(id) {
- this.dragElId = id;
- },
- setHandleElId: function(id) {
- if (typeof id !== "string") {
- id = Ext.id(id);
- }
- this.handleElId = id;
- this.DDM.regHandle(this.id, id);
- },
- setOuterHandleElId: function(id) {
- if (typeof id !== "string") {
- id = Ext.id(id);
- }
- Event.on(id, "mousedown",
- this.handleMouseDown, this);
- this.setHandleElId(id);
- this.hasOuterHandles = true;
- },
- unreg: function() {
- Event.un(this.id, "mousedown",
- this.handleMouseDown);
- this._domRef = null;
- this.DDM._remove(this);
- },
- destroy : function(){
- this.unreg();
- },
- isLocked: function() {
- return (this.DDM.isLocked() || this.locked);
- },
- handleMouseDown: function(e, oDD){
- if (this.primaryButtonOnly && e.button != 0) {
- return;
- }
- if (this.isLocked()) {
- return;
- }
- this.DDM.refreshCache(this.groups);
- var pt = new Ext.lib.Point(Ext.lib.Event.getPageX(e), Ext.lib.Event.getPageY(e));
- if (!this.hasOuterHandles && !this.DDM.isOverTarget(pt, this) ) {
- } else {
- if (this.clickValidator(e)) {
- this.setStartPosition();
- this.b4MouseDown(e);
- this.onMouseDown(e);
- this.DDM.handleMouseDown(e, this);
- this.DDM.stopEvent(e);
- } else {
- }
- }
- },
- clickValidator: function(e) {
- var target = e.getTarget();
- return ( this.isValidHandleChild(target) &&
- (this.id == this.handleElId ||
- this.DDM.handleWasClicked(target, this.id)) );
- },
- addInvalidHandleType: function(tagName) {
- var type = tagName.toUpperCase();
- this.invalidHandleTypes[type] = type;
- },
- addInvalidHandleId: function(id) {
- if (typeof id !== "string") {
- id = Ext.id(id);
- }
- this.invalidHandleIds[id] = id;
- },
- addInvalidHandleClass: function(cssClass) {
- this.invalidHandleClasses.push(cssClass);
- },
- removeInvalidHandleType: function(tagName) {
- var type = tagName.toUpperCase();
- delete this.invalidHandleTypes[type];
- },
- removeInvalidHandleId: function(id) {
- if (typeof id !== "string") {
- id = Ext.id(id);
- }
- delete this.invalidHandleIds[id];
- },
- removeInvalidHandleClass: function(cssClass) {
- for (var i=0, len=this.invalidHandleClasses.length; i<len; ++i) {
- if (this.invalidHandleClasses[i] == cssClass) {
- delete this.invalidHandleClasses[i];
- }
- }
- },
- isValidHandleChild: function(node) {
- var valid = true;
- var nodeName;
- try {
- nodeName = node.nodeName.toUpperCase();
- } catch(e) {
- nodeName = node.nodeName;
- }
- valid = valid && !this.invalidHandleTypes[nodeName];
- valid = valid && !this.invalidHandleIds[node.id];
- for (var i=0, len=this.invalidHandleClasses.length; valid && i<len; ++i) {
- valid = !Ext.fly(node).hasClass(this.invalidHandleClasses[i]);
- }
- return valid;
- },
- setXTicks: function(iStartX, iTickSize) {
- this.xTicks = [];
- this.xTickSize = iTickSize;
- var tickMap = {};
- for (var i = this.initPageX; i >= this.minX; i = i - iTickSize) {
- if (!tickMap[i]) {
- this.xTicks[this.xTicks.length] = i;
- tickMap[i] = true;
- }
- }
- for (i = this.initPageX; i <= this.maxX; i = i + iTickSize) {
- if (!tickMap[i]) {
- this.xTicks[this.xTicks.length] = i;
- tickMap[i] = true;
- }
- }
- this.xTicks.sort(this.DDM.numericSort) ;
- },
- setYTicks: function(iStartY, iTickSize) {
- this.yTicks = [];
- this.yTickSize = iTickSize;
- var tickMap = {};
- for (var i = this.initPageY; i >= this.minY; i = i - iTickSize) {
- if (!tickMap[i]) {
- this.yTicks[this.yTicks.length] = i;
- tickMap[i] = true;
- }
- }
- for (i = this.initPageY; i <= this.maxY; i = i + iTickSize) {
- if (!tickMap[i]) {
- this.yTicks[this.yTicks.length] = i;
- tickMap[i] = true;
- }
- }
- this.yTicks.sort(this.DDM.numericSort) ;
- },
- setXConstraint: function(iLeft, iRight, iTickSize) {
- this.leftConstraint = iLeft;
- this.rightConstraint = iRight;
- this.minX = this.initPageX - iLeft;
- this.maxX = this.initPageX + iRight;
- if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); }
- this.constrainX = true;
- },
- clearConstraints: function() {
- this.constrainX = false;
- this.constrainY = false;
- this.clearTicks();
- },
- clearTicks: function() {
- this.xTicks = null;
- this.yTicks = null;
- this.xTickSize = 0;
- this.yTickSize = 0;
- },
- setYConstraint: function(iUp, iDown, iTickSize) {
- this.topConstraint = iUp;
- this.bottomConstraint = iDown;
- this.minY = this.initPageY - iUp;
- this.maxY = this.initPageY + iDown;
- if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); }
- this.constrainY = true;
- },
- resetConstraints: function() {
- if (this.initPageX || this.initPageX === 0) {
- var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0;
- var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0;
- this.setInitPosition(dx, dy);
- } else {
- this.setInitPosition();
- }
- if (this.constrainX) {
- this.setXConstraint( this.leftConstraint,
- this.rightConstraint,
- this.xTickSize );
- }
- if (this.constrainY) {
- this.setYConstraint( this.topConstraint,
- this.bottomConstraint,
- this.yTickSize );
- }
- },
- getTick: function(val, tickArray) {
- if (!tickArray) {
- return val;
- } else if (tickArray[0] >= val) {
- return tickArray[0];
- } else {
- for (var i=0, len=tickArray.length; i<len; ++i) {
- var next = i + 1;
- if (tickArray[next] && tickArray[next] >= val) {
- var diff1 = val - tickArray[i];
- var diff2 = tickArray[next] - val;
- return (diff2 > diff1) ? tickArray[i] : tickArray[next];
- }
- }
- return tickArray[tickArray.length - 1];
- }
- },
- toString: function() {
- return ("DragDrop " + this.id);
- }
- };
- })();
- if (!Ext.dd.DragDropMgr) {
- Ext.dd.DragDropMgr = function() {
- var Event = Ext.EventManager;
- return {
- ids: {},
- handleIds: {},
- dragCurrent: null,
- dragOvers: {},
- deltaX: 0,
- deltaY: 0,
- preventDefault: true,
- stopPropagation: true,
- initialized: false,
- locked: false,
- init: function() {
- this.initialized = true;
- },
- POINT: 0,
- INTERSECT: 1,
- mode: 0,
- _execOnAll: function(sMethod, args) {
- for (var i in this.ids) {
- for (var j in this.ids[i]) {
- var oDD = this.ids[i][j];
- if (! this.isTypeOfDD(oDD)) {
- continue;
- }
- oDD[sMethod].apply(oDD, args);
- }
- }
- },
- _onLoad: function() {
- this.init();
- Event.on(document, "mouseup", this.handleMouseUp, this, true);
- Event.on(document, "mousemove", this.handleMouseMove, this, true);
- Event.on(window, "unload", this._onUnload, this, true);
- Event.on(window, "resize", this._onResize, this, true);
- },
- _onResize: function(e) {
- this._execOnAll("resetConstraints", []);
- },
- lock: function() { this.locked = true; },
- unlock: function() { this.locked = false; },
- isLocked: function() { return this.locked; },
- locationCache: {},
- useCache: true,
- clickPixelThresh: 3,
- clickTimeThresh: 350,
- dragThreshMet: false,
- clickTimeout: null,
- startX: 0,
- startY: 0,
- regDragDrop: function(oDD, sGroup) {
- if (!this.initialized) { this.init(); }
- if (!this.ids[sGroup]) {
- this.ids[sGroup] = {};
- }
- this.ids[sGroup][oDD.id] = oDD;
- },
- removeDDFromGroup: function(oDD, sGroup) {
- if (!this.ids[sGroup]) {
- this.ids[sGroup] = {};
- }
- var obj = this.ids[sGroup];
- if (obj && obj[oDD.id]) {
- delete obj[oDD.id];
- }
- },
- _remove: function(oDD) {
- for (var g in oDD.groups) {
- if (g && this.ids[g] && this.ids[g][oDD.id]) {
- delete this.ids[g][oDD.id];
- }
- }
- delete this.handleIds[oDD.id];
- },
- regHandle: function(sDDId, sHandleId) {
- if (!this.handleIds[sDDId]) {
- this.handleIds[sDDId] = {};
- }
- this.handleIds[sDDId][sHandleId] = sHandleId;
- },
- isDragDrop: function(id) {
- return ( this.getDDById(id) ) ? true : false;
- },
- getRelated: function(p_oDD, bTargetsOnly) {
- var oDDs = [];
- for (var i in p_oDD.groups) {
- for (var j in this.ids[i]) {
- var dd = this.ids[i][j];
- if (! this.isTypeOfDD(dd)) {
- continue;
- }
- if (!bTargetsOnly || dd.isTarget) {
- oDDs[oDDs.length] = dd;
- }
- }
- }
- return oDDs;
- },
- isLegalTarget: function (oDD, oTargetDD) {
- var targets = this.getRelated(oDD, true);
- for (var i=0, len=targets.length;i<len;++i) {
- if (targets[i].id == oTargetDD.id) {
- return true;
- }
- }
- return false;
- },
- isTypeOfDD: function (oDD) {
- return (oDD && oDD.__ygDragDrop);
- },
- isHandle: function(sDDId, sHandleId) {
- return ( this.handleIds[sDDId] &&
- this.handleIds[sDDId][sHandleId] );
- },
- getDDById: function(id) {
- for (var i in this.ids) {
- if (this.ids[i][id]) {
- return this.ids[i][id];
- }
- }
- return null;
- },
- handleMouseDown: function(e, oDD) {
- if(Ext.QuickTips){
- Ext.QuickTips.disable();
- }
- if(this.dragCurrent){
- this.handleMouseUp(e);
- }
- this.currentTarget = e.getTarget();
- this.dragCurrent = oDD;
- var el = oDD.getEl();
- this.startX = e.getPageX();
- this.startY = e.getPageY();
- this.deltaX = this.startX - el.offsetLeft;
- this.deltaY = this.startY - el.offsetTop;
- this.dragThreshMet = false;
- this.clickTimeout = setTimeout(
- function() {
- var DDM = Ext.dd.DDM;
- DDM.startDrag(DDM.startX, DDM.startY);
- },
- this.clickTimeThresh );
- },
- startDrag: function(x, y) {
- clearTimeout(this.clickTimeout);
- if (this.dragCurrent) {
- this.dragCurrent.b4StartDrag(x, y);
- this.dragCurrent.startDrag(x, y);
- }
- this.dragThreshMet = true;
- },
- handleMouseUp: function(e) {
- if(Ext.QuickTips){
- Ext.QuickTips.enable();
- }
- if (! this.dragCurrent) {
- return;
- }
- clearTimeout(this.clickTimeout);
- if (this.dragThreshMet) {
- this.fireEvents(e, true);
- } else {
- }
- this.stopDrag(e);
- this.stopEvent(e);
- },
- stopEvent: function(e){
- if(this.stopPropagation) {
- e.stopPropagation();
- }
- if (this.preventDefault) {
- e.preventDefault();
- }
- },
- stopDrag: function(e) {
- if (this.dragCurrent) {
- if (this.dragThreshMet) {
- this.dragCurrent.b4EndDrag(e);
- this.dragCurrent.endDrag(e);
- }
- this.dragCurrent.onMouseUp(e);
- }
- this.dragCurrent = null;
- this.dragOvers = {};
- },
- handleMouseMove: function(e) {
- if (! this.dragCurrent) {
- return true;
- }
- if (Ext.isIE && (e.button !== 0 && e.button !== 1 && e.button !== 2)) {
- this.stopEvent(e);
- return this.handleMouseUp(e);
- }
- if (!this.dragThreshMet) {
- var diffX = Math.abs(this.startX - e.getPageX());
- var diffY = Math.abs(this.startY - e.getPageY());
- if (diffX > this.clickPixelThresh ||
- diffY > this.clickPixelThresh) {
- this.startDrag(this.startX, this.startY);
- }
- }
- if (this.dragThreshMet) {
- this.dragCurrent.b4Drag(e);
- this.dragCurrent.onDrag(e);
- if(!this.dragCurrent.moveOnly){
- this.fireEvents(e, false);
- }
- }
- this.stopEvent(e);
- return true;
- },
- fireEvents: function(e, isDrop) {
- var dc = this.dragCurrent;
- if (!dc || dc.isLocked()) {
- return;
- }
- var pt = e.getPoint();
- var oldOvers = [];
- var outEvts = [];
- var overEvts = [];
- var dropEvts = [];
- var enterEvts = [];
- for (var i in this.dragOvers) {
- var ddo = this.dragOvers[i];
- if (! this.isTypeOfDD(ddo)) {
- continue;
- }
- if (! this.isOverTarget(pt, ddo, this.mode)) {
- outEvts.push( ddo );
- }
- oldOvers[i] = true;
- delete this.dragOvers[i];
- }
- for (var sGroup in dc.groups) {
- if ("string" != typeof sGroup) {
- continue;
- }
- for (i in this.ids[sGroup]) {
- var oDD = this.ids[sGroup][i];
- if (! this.isTypeOfDD(oDD)) {
- continue;
- }
- if (oDD.isTarget && !oDD.isLocked() && ((oDD != dc) || (dc.ignoreSelf === false))) {
- if (this.isOverTarget(pt, oDD, this.mode)) {
- if (isDrop) {
- dropEvts.push( oDD );
- } else {
- if (!oldOvers[oDD.id]) {
- enterEvts.push( oDD );
- } else {
- overEvts.push( oDD );
- }
- this.dragOvers[oDD.id] = oDD;
- }
- }
- }
- }
- }
- if (this.mode) {
- if (outEvts.length) {
- dc.b4DragOut(e, outEvts);
- dc.onDragOut(e, outEvts);
- }
- if (enterEvts.length) {
- dc.onDragEnter(e, enterEvts);
- }
- if (overEvts.length) {
- dc.b4DragOver(e, overEvts);
- dc.onDragOver(e, overEvts);
- }
- if (dropEvts.length) {
- dc.b4DragDrop(e, dropEvts);
- dc.onDragDrop(e, dropEvts);
- }
- } else {
- var len = 0;
- for (i=0, len=outEvts.length; i<len; ++i) {
- dc.b4DragOut(e, outEvts[i].id);
- dc.onDragOut(e, outEvts[i].id);
- }
- for (i=0,len=enterEvts.length; i<len; ++i) {
- dc.onDragEnter(e, enterEvts[i].id);
- }
- for (i=0,len=overEvts.length; i<len; ++i) {
- dc.b4DragOver(e, overEvts[i].id);
- dc.onDragOver(e, overEvts[i].id);
- }
- for (i=0, len=dropEvts.length; i<len; ++i) {
- dc.b4DragDrop(e, dropEvts[i].id);
- dc.onDragDrop(e, dropEvts[i].id);
- }
- }
- if (isDrop && !dropEvts.length) {
- dc.onInvalidDrop(e);
- }
- },
- getBestMatch: function(dds) {
- var winner = null;
- var len = dds.length;
- if (len == 1) {
- winner = dds[0];
- } else {
- for (var i=0; i<len; ++i) {
- var dd = dds[i];
- if (dd.cursorIsOver) {
- winner = dd;
- break;
- } else {
- if (!winner ||
- winner.overlap.getArea() < dd.overlap.getArea()) {
- winner = dd;
- }
- }
- }
- }
- return winner;
- },
- refreshCache: function(groups) {
- for (var sGroup in groups) {
- if ("string" != typeof sGroup) {
- continue;
- }
- for (var i in this.ids[sGroup]) {
- var oDD = this.ids[sGroup][i];
- if (this.isTypeOfDD(oDD)) {
- var loc = this.getLocation(oDD);
- if (loc) {
- this.locationCache[oDD.id] = loc;
- } else {
- delete this.locationCache[oDD.id];
- }
- }
- }
- }
- },
- verifyEl: function(el) {
- if (el) {
- var parent;
- if(Ext.isIE){
- try{
- parent = el.offsetParent;
- }catch(e){}
- }else{
- parent = el.offsetParent;
- }
- if (parent) {
- return true;
- }
- }
- return false;
- },
- getLocation: function(oDD) {
- if (! this.isTypeOfDD(oDD)) {
- return null;
- }
- var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l;
- try {
- pos= Ext.lib.Dom.getXY(el);
- } catch (e) { }
- if (!pos) {
- return null;
- }
- x1 = pos[0];
- x2 = x1 + el.offsetWidth;
- y1 = pos[1];
- y2 = y1 + el.offsetHeight;
- t = y1 - oDD.padding[0];
- r = x2 + oDD.padding[1];
- b = y2 + oDD.padding[2];
- l = x1 - oDD.padding[3];
- return new Ext.lib.Region( t, r, b, l );
- },
- isOverTarget: function(pt, oTarget, intersect) {
- var loc = this.locationCache[oTarget.id];
- if (!loc || !this.useCache) {
- loc = this.getLocation(oTarget);
- this.locationCache[oTarget.id] = loc;
- }
- if (!loc) {
- return false;
- }
- oTarget.cursorIsOver = loc.contains( pt );
- var dc = this.dragCurrent;
- if (!dc || !dc.getTargetCoord ||
- (!intersect && !dc.constrainX && !dc.constrainY)) {
- return oTarget.cursorIsOver;
- }
- oTarget.overlap = null;
- var pos = dc.getTargetCoord(pt.x, pt.y);
- var el = dc.getDragEl();
- var curRegion = new Ext.lib.Region( pos.y,
- pos.x + el.offsetWidth,
- pos.y + el.offsetHeight,
- pos.x );
- var overlap = curRegion.intersect(loc);
- if (overlap) {
- oTarget.overlap = overlap;
- return (intersect) ? true : oTarget.cursorIsOver;
- } else {
- return false;
- }
- },
- _onUnload: function(e, me) {
- Ext.dd.DragDropMgr.unregAll();
- },
- unregAll: function() {
- if (this.dragCurrent) {
- this.stopDrag();
- this.dragCurrent = null;
- }
- this._execOnAll("unreg", []);
- for (var i in this.elementCache) {
- delete this.elementCache[i];
- }
- this.elementCache = {};
- this.ids = {};
- },
- elementCache: {},
- getElWrapper: function(id) {
- var oWrapper = this.elementCache[id];
- if (!oWrapper || !oWrapper.el) {
- oWrapper = this.elementCache[id] =
- new this.ElementWrapper(Ext.getDom(id));
- }
- return oWrapper;
- },
- getElement: function(id) {
- return Ext.getDom(id);
- },
- getCss: function(id) {
- var el = Ext.getDom(id);
- return (el) ? el.style : null;
- },
- ElementWrapper: function(el) {
- this.el = el || null;
- this.id = this.el && el.id;
- this.css = this.el && el.style;
- },
- getPosX: function(el) {
- return Ext.lib.Dom.getX(el);
- },
- getPosY: function(el) {
- return Ext.lib.Dom.getY(el);
- },
- swapNode: function(n1, n2) {
- if (n1.swapNode) {
- n1.swapNode(n2);
- } else {
- var p = n2.parentNode;
- var s = n2.nextSibling;
- if (s == n1) {
- p.insertBefore(n1, n2);
- } else if (n2 == n1.nextSibling) {
- p.insertBefore(n2, n1);
- } else {
- n1.parentNode.replaceChild(n2, n1);
- p.insertBefore(n1, s);
- }
- }
- },
- getScroll: function () {
- var t, l, dde=document.documentElement, db=document.body;
- if (dde && (dde.scrollTop || dde.scrollLeft)) {
- t = dde.scrollTop;
- l = dde.scrollLeft;
- } else if (db) {
- t = db.scrollTop;
- l = db.scrollLeft;
- } else {
- }
- return { top: t, left: l };
- },
- getStyle: function(el, styleProp) {
- return Ext.fly(el).getStyle(styleProp);
- },
- getScrollTop: function () { return this.getScroll().top; },
- getScrollLeft: function () { return this.getScroll().left; },
- moveToEl: function (moveEl, targetEl) {
- var aCoord = Ext.lib.Dom.getXY(targetEl);
- Ext.lib.Dom.setXY(moveEl, aCoord);
- },
- numericSort: function(a, b) { return (a - b); },
- _timeoutCount: 0,
- _addListeners: function() {
- var DDM = Ext.dd.DDM;
- if ( Ext.lib.Event && document ) {
- DDM._onLoad();
- } else {
- if (DDM._timeoutCount > 2000) {
- } else {
- setTimeout(DDM._addListeners, 10);
- if (document && document.body) {
- DDM._timeoutCount += 1;
- }
- }
- }
- },
- handleWasClicked: function(node, id) {
- if (this.isHandle(id, node.id)) {
- return true;
- } else {
- var p = node.parentNode;
- while (p) {
- if (this.isHandle(id, p.id)) {
- return true;
- } else {
- p = p.parentNode;
- }
- }
- }
- return false;
- }
- };
- }();
- Ext.dd.DDM = Ext.dd.DragDropMgr;
- Ext.dd.DDM._addListeners();
- }
- Ext.dd.DD = function(id, sGroup, config) {
- if (id) {
- this.init(id, sGroup, config);
- }
- };
- Ext.extend(Ext.dd.DD, Ext.dd.DragDrop, {
- scroll: true,
- autoOffset: function(iPageX, iPageY) {
- var x = iPageX - this.startPageX;
- var y = iPageY - this.startPageY;
- this.setDelta(x, y);
- },
- setDelta: function(iDeltaX, iDeltaY) {
- this.deltaX = iDeltaX;
- this.deltaY = iDeltaY;
- },
- setDragElPos: function(iPageX, iPageY) {
- var el = this.getDragEl();
- this.alignElWithMouse(el, iPageX, iPageY);
- },
- alignElWithMouse: function(el, iPageX, iPageY) {
- var oCoord = this.getTargetCoord(iPageX, iPageY);
- var fly = el.dom ? el : Ext.fly(el, '_dd');
- if (!this.deltaSetXY) {
- var aCoord = [oCoord.x, oCoord.y];
- fly.setXY(aCoord);
- var newLeft = fly.getLeft(true);
- var newTop = fly.getTop(true);
- this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ];
- } else {
- fly.setLeftTop(oCoord.x + this.deltaSetXY[0], oCoord.y + this.deltaSetXY[1]);
- }
- this.cachePosition(oCoord.x, oCoord.y);
- this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
- return oCoord;
- },
- cachePosition: function(iPageX, iPageY) {
- if (iPageX) {
- this.lastPageX = iPageX;
- this.lastPageY = iPageY;
- } else {
- var aCoord = Ext.lib.Dom.getXY(this.getEl());
- this.lastPageX = aCoord[0];
- this.lastPageY = aCoord[1];
- }
- },
- autoScroll: function(x, y, h, w) {
- if (this.scroll) {
- var clientH = Ext.lib.Dom.getViewHeight();
- var clientW = Ext.lib.Dom.getViewWidth();
- var st = this.DDM.getScrollTop();
- var sl = this.DDM.getScrollLeft();
- var bot = h + y;
- var right = w + x;
- var toBot = (clientH + st - y - this.deltaY);
- var toRight = (clientW + sl - x - this.deltaX);
- var thresh = 40;
- var scrAmt = (document.all) ? 80 : 30;
- if ( bot > clientH && toBot < thresh ) {
- window.scrollTo(sl, st + scrAmt);
- }
- if ( y < st && st > 0 && y - st < thresh ) {
- window.scrollTo(sl, st - scrAmt);
- }
- if ( right > clientW && toRight < thresh ) {
- window.scrollTo(sl + scrAmt, st);
- }
- if ( x < sl && sl > 0 && x - sl < thresh ) {
- window.scrollTo(sl - scrAmt, st);
- }
- }
- },
- getTargetCoord: function(iPageX, iPageY) {
- var x = iPageX - this.deltaX;
- var y = iPageY - this.deltaY;
- if (this.constrainX) {
- if (x < this.minX) { x = this.minX; }
- if (x > this.maxX) { x = this.maxX; }
- }
- if (this.constrainY) {
- if (y < this.minY) { y = this.minY; }
- if (y > this.maxY) { y = this.maxY; }
- }
- x = this.getTick(x, this.xTicks);
- y = this.getTick(y, this.yTicks);
- return {x:x, y:y};
- },
- applyConfig: function() {
- Ext.dd.DD.superclass.applyConfig.call(this);
- this.scroll = (this.config.scroll !== false);
- },
- b4MouseDown: function(e) {
- this.autoOffset(e.getPageX(),
- e.getPageY());
- },