ext-all-debug.js
资源名称:ext-3.1.0.zip [点击查看]
上传用户:dawnssy
上传日期:2022-08-06
资源大小:9345k
文件大小:1167k
源码类别:
JavaScript
开发平台:
JavaScript
- 'exception'
- );
- Ext.direct.Provider.superclass.constructor.call(this, config);
- },
- isConnected: function(){
- return false;
- },
- connect: Ext.emptyFn,
- disconnect: Ext.emptyFn
- });
- Ext.direct.JsonProvider = Ext.extend(Ext.direct.Provider, {
- parseResponse: function(xhr){
- if(!Ext.isEmpty(xhr.responseText)){
- if(typeof xhr.responseText == 'object'){
- return xhr.responseText;
- }
- return Ext.decode(xhr.responseText);
- }
- return null;
- },
- getEvents: function(xhr){
- var data = null;
- try{
- data = this.parseResponse(xhr);
- }catch(e){
- var event = new Ext.Direct.ExceptionEvent({
- data: e,
- xhr: xhr,
- code: Ext.Direct.exceptions.PARSE,
- message: 'Error parsing json response: nn ' + data
- })
- return [event];
- }
- var events = [];
- if(Ext.isArray(data)){
- for(var i = 0, len = data.length; i < len; i++){
- events.push(Ext.Direct.createEvent(data[i]));
- }
- }else{
- events.push(Ext.Direct.createEvent(data));
- }
- return events;
- }
- });
- Ext.direct.PollingProvider = Ext.extend(Ext.direct.JsonProvider, {
- priority: 3,
- interval: 3000,
- constructor : function(config){
- Ext.direct.PollingProvider.superclass.constructor.call(this, config);
- this.addEvents(
- 'beforepoll',
- 'poll'
- );
- },
- isConnected: function(){
- return !!this.pollTask;
- },
- connect: function(){
- if(this.url && !this.pollTask){
- this.pollTask = Ext.TaskMgr.start({
- run: function(){
- if(this.fireEvent('beforepoll', this) !== false){
- if(typeof this.url == 'function'){
- this.url(this.baseParams);
- }else{
- Ext.Ajax.request({
- url: this.url,
- callback: this.onData,
- scope: this,
- params: this.baseParams
- });
- }
- }
- },
- interval: this.interval,
- scope: this
- });
- this.fireEvent('connect', this);
- }else if(!this.url){
- throw 'Error initializing PollingProvider, no url configured.';
- }
- },
- disconnect: function(){
- if(this.pollTask){
- Ext.TaskMgr.stop(this.pollTask);
- delete this.pollTask;
- this.fireEvent('disconnect', this);
- }
- },
- onData: function(opt, success, xhr){
- if(success){
- var events = this.getEvents(xhr);
- for(var i = 0, len = events.length; i < len; i++){
- var e = events[i];
- this.fireEvent('data', this, e);
- }
- }else{
- var e = new Ext.Direct.ExceptionEvent({
- data: e,
- code: Ext.Direct.exceptions.TRANSPORT,
- message: 'Unable to connect to the server.',
- xhr: xhr
- });
- this.fireEvent('data', this, e);
- }
- }
- });
- Ext.Direct.PROVIDERS['polling'] = Ext.direct.PollingProvider;
- Ext.direct.RemotingProvider = Ext.extend(Ext.direct.JsonProvider, {
- enableBuffer: 10,
- maxRetries: 1,
- timeout: undefined,
- constructor : function(config){
- Ext.direct.RemotingProvider.superclass.constructor.call(this, config);
- this.addEvents(
- 'beforecall',
- 'call'
- );
- this.namespace = (Ext.isString(this.namespace)) ? Ext.ns(this.namespace) : this.namespace || window;
- this.transactions = {};
- this.callBuffer = [];
- },
- initAPI : function(){
- var o = this.actions;
- for(var c in o){
- var cls = this.namespace[c] || (this.namespace[c] = {}),
- ms = o[c];
- for(var i = 0, len = ms.length; i < len; i++){
- var m = ms[i];
- cls[m.name] = this.createMethod(c, m);
- }
- }
- },
- isConnected: function(){
- return !!this.connected;
- },
- connect: function(){
- if(this.url){
- this.initAPI();
- this.connected = true;
- this.fireEvent('connect', this);
- }else if(!this.url){
- throw 'Error initializing RemotingProvider, no url configured.';
- }
- },
- disconnect: function(){
- if(this.connected){
- this.connected = false;
- this.fireEvent('disconnect', this);
- }
- },
- onData: function(opt, success, xhr){
- if(success){
- var events = this.getEvents(xhr);
- for(var i = 0, len = events.length; i < len; i++){
- var e = events[i],
- t = this.getTransaction(e);
- this.fireEvent('data', this, e);
- if(t){
- this.doCallback(t, e, true);
- Ext.Direct.removeTransaction(t);
- }
- }
- }else{
- var ts = [].concat(opt.ts);
- for(var i = 0, len = ts.length; i < len; i++){
- var t = this.getTransaction(ts[i]);
- if(t && t.retryCount < this.maxRetries){
- t.retry();
- }else{
- var e = new Ext.Direct.ExceptionEvent({
- data: e,
- transaction: t,
- code: Ext.Direct.exceptions.TRANSPORT,
- message: 'Unable to connect to the server.',
- xhr: xhr
- });
- this.fireEvent('data', this, e);
- if(t){
- this.doCallback(t, e, false);
- Ext.Direct.removeTransaction(t);
- }
- }
- }
- }
- },
- getCallData: function(t){
- return {
- action: t.action,
- method: t.method,
- data: t.data,
- type: 'rpc',
- tid: t.tid
- };
- },
- doSend : function(data){
- var o = {
- url: this.url,
- callback: this.onData,
- scope: this,
- ts: data,
- timeout: this.timeout
- }, callData;
- if(Ext.isArray(data)){
- callData = [];
- for(var i = 0, len = data.length; i < len; i++){
- callData.push(this.getCallData(data[i]));
- }
- }else{
- callData = this.getCallData(data);
- }
- if(this.enableUrlEncode){
- var params = {};
- params[Ext.isString(this.enableUrlEncode) ? this.enableUrlEncode : 'data'] = Ext.encode(callData);
- o.params = params;
- }else{
- o.jsonData = callData;
- }
- Ext.Ajax.request(o);
- },
- combineAndSend : function(){
- var len = this.callBuffer.length;
- if(len > 0){
- this.doSend(len == 1 ? this.callBuffer[0] : this.callBuffer);
- this.callBuffer = [];
- }
- },
- queueTransaction: function(t){
- if(t.form){
- this.processForm(t);
- return;
- }
- this.callBuffer.push(t);
- if(this.enableBuffer){
- if(!this.callTask){
- this.callTask = new Ext.util.DelayedTask(this.combineAndSend, this);
- }
- this.callTask.delay(Ext.isNumber(this.enableBuffer) ? this.enableBuffer : 10);
- }else{
- this.combineAndSend();
- }
- },
- doCall : function(c, m, args){
- var data = null, hs = args[m.len], scope = args[m.len+1];
- if(m.len !== 0){
- data = args.slice(0, m.len);
- }
- var t = new Ext.Direct.Transaction({
- provider: this,
- args: args,
- action: c,
- method: m.name,
- data: data,
- cb: scope && Ext.isFunction(hs) ? hs.createDelegate(scope) : hs
- });
- if(this.fireEvent('beforecall', this, t) !== false){
- Ext.Direct.addTransaction(t);
- this.queueTransaction(t);
- this.fireEvent('call', this, t);
- }
- },
- doForm : function(c, m, form, callback, scope){
- var t = new Ext.Direct.Transaction({
- provider: this,
- action: c,
- method: m.name,
- args:[form, callback, scope],
- cb: scope && Ext.isFunction(callback) ? callback.createDelegate(scope) : callback,
- isForm: true
- });
- if(this.fireEvent('beforecall', this, t) !== false){
- Ext.Direct.addTransaction(t);
- var isUpload = String(form.getAttribute("enctype")).toLowerCase() == 'multipart/form-data',
- params = {
- extTID: t.tid,
- extAction: c,
- extMethod: m.name,
- extType: 'rpc',
- extUpload: String(isUpload)
- };
- Ext.apply(t, {
- form: Ext.getDom(form),
- isUpload: isUpload,
- params: callback && Ext.isObject(callback.params) ? Ext.apply(params, callback.params) : params
- });
- this.fireEvent('call', this, t);
- this.processForm(t);
- }
- },
- processForm: function(t){
- Ext.Ajax.request({
- url: this.url,
- params: t.params,
- callback: this.onData,
- scope: this,
- form: t.form,
- isUpload: t.isUpload,
- ts: t
- });
- },
- createMethod : function(c, m){
- var f;
- if(!m.formHandler){
- f = function(){
- this.doCall(c, m, Array.prototype.slice.call(arguments, 0));
- }.createDelegate(this);
- }else{
- f = function(form, callback, scope){
- this.doForm(c, m, form, callback, scope);
- }.createDelegate(this);
- }
- f.directCfg = {
- action: c,
- method: m
- };
- return f;
- },
- getTransaction: function(opt){
- return opt && opt.tid ? Ext.Direct.getTransaction(opt.tid) : null;
- },
- doCallback: function(t, e){
- var fn = e.status ? 'success' : 'failure';
- if(t && t.cb){
- var hs = t.cb,
- result = Ext.isDefined(e.result) ? e.result : e.data;
- if(Ext.isFunction(hs)){
- hs(result, e);
- } else{
- Ext.callback(hs[fn], hs.scope, [result, e]);
- Ext.callback(hs.callback, hs.scope, [result, e]);
- }
- }
- }
- });
- Ext.Direct.PROVIDERS['remoting'] = Ext.direct.RemotingProvider;
- Ext.Resizable = function(el, config){
- this.el = Ext.get(el);
- if(config && config.wrap){
- config.resizeChild = this.el;
- this.el = this.el.wrap(typeof config.wrap == 'object' ? config.wrap : {cls:'xresizable-wrap'});
- this.el.id = this.el.dom.id = config.resizeChild.id + '-rzwrap';
- this.el.setStyle('overflow', 'hidden');
- this.el.setPositioning(config.resizeChild.getPositioning());
- config.resizeChild.clearPositioning();
- if(!config.width || !config.height){
- var csize = config.resizeChild.getSize();
- this.el.setSize(csize.width, csize.height);
- }
- if(config.pinned && !config.adjustments){
- config.adjustments = 'auto';
- }
- }
- this.proxy = this.el.createProxy({tag: 'div', cls: 'x-resizable-proxy', id: this.el.id + '-rzproxy'}, Ext.getBody());
- this.proxy.unselectable();
- this.proxy.enableDisplayMode('block');
- Ext.apply(this, config);
- if(this.pinned){
- this.disableTrackOver = true;
- this.el.addClass('x-resizable-pinned');
- }
- var position = this.el.getStyle('position');
- if(position != 'absolute' && position != 'fixed'){
- this.el.setStyle('position', 'relative');
- }
- if(!this.handles){
- this.handles = 's,e,se';
- if(this.multiDirectional){
- this.handles += ',n,w';
- }
- }
- if(this.handles == 'all'){
- this.handles = 'n s e w ne nw se sw';
- }
- var hs = this.handles.split(/s*?[,;]s*?| /);
- var ps = Ext.Resizable.positions;
- for(var i = 0, len = hs.length; i < len; i++){
- if(hs[i] && ps[hs[i]]){
- var pos = ps[hs[i]];
- this[pos] = new Ext.Resizable.Handle(this, pos, this.disableTrackOver, this.transparent);
- }
- }
- this.corner = this.southeast;
- if(this.handles.indexOf('n') != -1 || this.handles.indexOf('w') != -1){
- this.updateBox = true;
- }
- this.activeHandle = null;
- if(this.resizeChild){
- if(typeof this.resizeChild == 'boolean'){
- this.resizeChild = Ext.get(this.el.dom.firstChild, true);
- }else{
- this.resizeChild = Ext.get(this.resizeChild, true);
- }
- }
- if(this.adjustments == 'auto'){
- var rc = this.resizeChild;
- var hw = this.west, he = this.east, hn = this.north, hs = this.south;
- if(rc && (hw || hn)){
- rc.position('relative');
- rc.setLeft(hw ? hw.el.getWidth() : 0);
- rc.setTop(hn ? hn.el.getHeight() : 0);
- }
- this.adjustments = [
- (he ? -he.el.getWidth() : 0) + (hw ? -hw.el.getWidth() : 0),
- (hn ? -hn.el.getHeight() : 0) + (hs ? -hs.el.getHeight() : 0) -1
- ];
- }
- if(this.draggable){
- this.dd = this.dynamic ?
- this.el.initDD(null) : this.el.initDDProxy(null, {dragElId: this.proxy.id});
- this.dd.setHandleElId(this.resizeChild ? this.resizeChild.id : this.el.id);
- if(this.constrainTo){
- this.dd.constrainTo(this.constrainTo);
- }
- }
- this.addEvents(
- 'beforeresize',
- 'resize'
- );
- if(this.width !== null && this.height !== null){
- this.resizeTo(this.width, this.height);
- }else{
- this.updateChildSize();
- }
- if(Ext.isIE){
- this.el.dom.style.zoom = 1;
- }
- Ext.Resizable.superclass.constructor.call(this);
- };
- Ext.extend(Ext.Resizable, Ext.util.Observable, {
- adjustments : [0, 0],
- animate : false,
- disableTrackOver : false,
- draggable: false,
- duration : 0.35,
- dynamic : false,
- easing : 'easeOutStrong',
- enabled : true,
- handles : false,
- multiDirectional : false,
- height : null,
- width : null,
- heightIncrement : 0,
- widthIncrement : 0,
- minHeight : 5,
- minWidth : 5,
- maxHeight : 10000,
- maxWidth : 10000,
- minX: 0,
- minY: 0,
- pinned : false,
- preserveRatio : false,
- resizeChild : false,
- transparent: false,
- resizeTo : function(width, height){
- this.el.setSize(width, height);
- this.updateChildSize();
- this.fireEvent('resize', this, width, height, null);
- },
- startSizing : function(e, handle){
- this.fireEvent('beforeresize', this, e);
- if(this.enabled){
- if(!this.overlay){
- this.overlay = this.el.createProxy({tag: 'div', cls: 'x-resizable-overlay', html: ' '}, Ext.getBody());
- this.overlay.unselectable();
- this.overlay.enableDisplayMode('block');
- this.overlay.on({
- scope: this,
- mousemove: this.onMouseMove,
- mouseup: this.onMouseUp
- });
- }
- this.overlay.setStyle('cursor', handle.el.getStyle('cursor'));
- this.resizing = true;
- this.startBox = this.el.getBox();
- this.startPoint = e.getXY();
- this.offsets = [(this.startBox.x + this.startBox.width) - this.startPoint[0],
- (this.startBox.y + this.startBox.height) - this.startPoint[1]];
- this.overlay.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
- this.overlay.show();
- if(this.constrainTo) {
- var ct = Ext.get(this.constrainTo);
- this.resizeRegion = ct.getRegion().adjust(
- ct.getFrameWidth('t'),
- ct.getFrameWidth('l'),
- -ct.getFrameWidth('b'),
- -ct.getFrameWidth('r')
- );
- }
- this.proxy.setStyle('visibility', 'hidden');
- this.proxy.show();
- this.proxy.setBox(this.startBox);
- if(!this.dynamic){
- this.proxy.setStyle('visibility', 'visible');
- }
- }
- },
- onMouseDown : function(handle, e){
- if(this.enabled){
- e.stopEvent();
- this.activeHandle = handle;
- this.startSizing(e, handle);
- }
- },
- onMouseUp : function(e){
- this.activeHandle = null;
- var size = this.resizeElement();
- this.resizing = false;
- this.handleOut();
- this.overlay.hide();
- this.proxy.hide();
- this.fireEvent('resize', this, size.width, size.height, e);
- },
- updateChildSize : function(){
- if(this.resizeChild){
- var el = this.el;
- var child = this.resizeChild;
- var adj = this.adjustments;
- if(el.dom.offsetWidth){
- var b = el.getSize(true);
- child.setSize(b.width+adj[0], b.height+adj[1]);
- }
- if(Ext.isIE){
- setTimeout(function(){
- if(el.dom.offsetWidth){
- var b = el.getSize(true);
- child.setSize(b.width+adj[0], b.height+adj[1]);
- }
- }, 10);
- }
- }
- },
- snap : function(value, inc, min){
- if(!inc || !value){
- return value;
- }
- var newValue = value;
- var m = value % inc;
- if(m > 0){
- if(m > (inc/2)){
- newValue = value + (inc-m);
- }else{
- newValue = value - m;
- }
- }
- return Math.max(min, newValue);
- },
- resizeElement : function(){
- var box = this.proxy.getBox();
- if(this.updateBox){
- this.el.setBox(box, false, this.animate, this.duration, null, this.easing);
- }else{
- this.el.setSize(box.width, box.height, this.animate, this.duration, null, this.easing);
- }
- this.updateChildSize();
- if(!this.dynamic){
- this.proxy.hide();
- }
- if(this.draggable && this.constrainTo){
- this.dd.resetConstraints();
- this.dd.constrainTo(this.constrainTo);
- }
- return box;
- },
- constrain : function(v, diff, m, mx){
- if(v - diff < m){
- diff = v - m;
- }else if(v - diff > mx){
- diff = v - mx;
- }
- return diff;
- },
- onMouseMove : function(e){
- if(this.enabled && this.activeHandle){
- try{
- if(this.resizeRegion && !this.resizeRegion.contains(e.getPoint())) {
- return;
- }
- var curSize = this.curSize || this.startBox,
- x = this.startBox.x, y = this.startBox.y,
- ox = x,
- oy = y,
- w = curSize.width,
- h = curSize.height,
- ow = w,
- oh = h,
- mw = this.minWidth,
- mh = this.minHeight,
- mxw = this.maxWidth,
- mxh = this.maxHeight,
- wi = this.widthIncrement,
- hi = this.heightIncrement,
- eventXY = e.getXY(),
- diffX = -(this.startPoint[0] - Math.max(this.minX, eventXY[0])),
- diffY = -(this.startPoint[1] - Math.max(this.minY, eventXY[1])),
- pos = this.activeHandle.position,
- tw,
- th;
- switch(pos){
- case 'east':
- w += diffX;
- w = Math.min(Math.max(mw, w), mxw);
- break;
- case 'south':
- h += diffY;
- h = Math.min(Math.max(mh, h), mxh);
- break;
- case 'southeast':
- w += diffX;
- h += diffY;
- w = Math.min(Math.max(mw, w), mxw);
- h = Math.min(Math.max(mh, h), mxh);
- break;
- case 'north':
- diffY = this.constrain(h, diffY, mh, mxh);
- y += diffY;
- h -= diffY;
- break;
- case 'west':
- diffX = this.constrain(w, diffX, mw, mxw);
- x += diffX;
- w -= diffX;
- break;
- case 'northeast':
- w += diffX;
- w = Math.min(Math.max(mw, w), mxw);
- diffY = this.constrain(h, diffY, mh, mxh);
- y += diffY;
- h -= diffY;
- break;
- case 'northwest':
- diffX = this.constrain(w, diffX, mw, mxw);
- diffY = this.constrain(h, diffY, mh, mxh);
- y += diffY;
- h -= diffY;
- x += diffX;
- w -= diffX;
- break;
- case 'southwest':
- diffX = this.constrain(w, diffX, mw, mxw);
- h += diffY;
- h = Math.min(Math.max(mh, h), mxh);
- x += diffX;
- w -= diffX;
- break;
- }
- var sw = this.snap(w, wi, mw);
- var sh = this.snap(h, hi, mh);
- if(sw != w || sh != h){
- switch(pos){
- case 'northeast':
- y -= sh - h;
- break;
- case 'north':
- y -= sh - h;
- break;
- case 'southwest':
- x -= sw - w;
- break;
- case 'west':
- x -= sw - w;
- break;
- case 'northwest':
- x -= sw - w;
- y -= sh - h;
- break;
- }
- w = sw;
- h = sh;
- }
- if(this.preserveRatio){
- switch(pos){
- case 'southeast':
- case 'east':
- h = oh * (w/ow);
- h = Math.min(Math.max(mh, h), mxh);
- w = ow * (h/oh);
- break;
- case 'south':
- w = ow * (h/oh);
- w = Math.min(Math.max(mw, w), mxw);
- h = oh * (w/ow);
- break;
- case 'northeast':
- w = ow * (h/oh);
- w = Math.min(Math.max(mw, w), mxw);
- h = oh * (w/ow);
- break;
- case 'north':
- tw = w;
- w = ow * (h/oh);
- w = Math.min(Math.max(mw, w), mxw);
- h = oh * (w/ow);
- x += (tw - w) / 2;
- break;
- case 'southwest':
- h = oh * (w/ow);
- h = Math.min(Math.max(mh, h), mxh);
- tw = w;
- w = ow * (h/oh);
- x += tw - w;
- break;
- case 'west':
- th = h;
- h = oh * (w/ow);
- h = Math.min(Math.max(mh, h), mxh);
- y += (th - h) / 2;
- tw = w;
- w = ow * (h/oh);
- x += tw - w;
- break;
- case 'northwest':
- tw = w;
- th = h;
- h = oh * (w/ow);
- h = Math.min(Math.max(mh, h), mxh);
- w = ow * (h/oh);
- y += th - h;
- x += tw - w;
- break;
- }
- }
- this.proxy.setBounds(x, y, w, h);
- if(this.dynamic){
- this.resizeElement();
- }
- }catch(ex){}
- }
- },
- handleOver : function(){
- if(this.enabled){
- this.el.addClass('x-resizable-over');
- }
- },
- handleOut : function(){
- if(!this.resizing){
- this.el.removeClass('x-resizable-over');
- }
- },
- getEl : function(){
- return this.el;
- },
- getResizeChild : function(){
- return this.resizeChild;
- },
- destroy : function(removeEl){
- Ext.destroy(this.dd, this.overlay, this.proxy);
- this.overlay = null;
- this.proxy = null;
- var ps = Ext.Resizable.positions;
- for(var k in ps){
- if(typeof ps[k] != 'function' && this[ps[k]]){
- this[ps[k]].destroy();
- }
- }
- if(removeEl){
- this.el.update('');
- Ext.destroy(this.el);
- this.el = null;
- }
- this.purgeListeners();
- },
- syncHandleHeight : function(){
- var h = this.el.getHeight(true);
- if(this.west){
- this.west.el.setHeight(h);
- }
- if(this.east){
- this.east.el.setHeight(h);
- }
- }
- });
- Ext.Resizable.positions = {
- n: 'north', s: 'south', e: 'east', w: 'west', se: 'southeast', sw: 'southwest', nw: 'northwest', ne: 'northeast'
- };
- Ext.Resizable.Handle = function(rz, pos, disableTrackOver, transparent){
- if(!this.tpl){
- var tpl = Ext.DomHelper.createTemplate(
- {tag: 'div', cls: 'x-resizable-handle x-resizable-handle-{0}'}
- );
- tpl.compile();
- Ext.Resizable.Handle.prototype.tpl = tpl;
- }
- this.position = pos;
- this.rz = rz;
- this.el = this.tpl.append(rz.el.dom, [this.position], true);
- this.el.unselectable();
- if(transparent){
- this.el.setOpacity(0);
- }
- this.el.on('mousedown', this.onMouseDown, this);
- if(!disableTrackOver){
- this.el.on({
- scope: this,
- mouseover: this.onMouseOver,
- mouseout: this.onMouseOut
- });
- }
- };
- Ext.Resizable.Handle.prototype = {
- afterResize : function(rz){
- },
- onMouseDown : function(e){
- this.rz.onMouseDown(this, e);
- },
- onMouseOver : function(e){
- this.rz.handleOver(this, e);
- },
- onMouseOut : function(e){
- this.rz.handleOut(this, e);
- },
- destroy : function(){
- Ext.destroy(this.el);
- this.el = null;
- }
- };
- Ext.Window = Ext.extend(Ext.Panel, {
- baseCls : 'x-window',
- resizable : true,
- draggable : true,
- closable : true,
- closeAction : 'close',
- constrain : false,
- constrainHeader : false,
- plain : false,
- minimizable : false,
- maximizable : false,
- minHeight : 100,
- minWidth : 200,
- expandOnShow : true,
- collapsible : false,
- initHidden : undefined,
- hidden : true,
- monitorResize : true,
- elements : 'header,body',
- frame : true,
- floating : true,
- initComponent : function(){
- this.initTools();
- Ext.Window.superclass.initComponent.call(this);
- this.addEvents(
- 'resize',
- 'maximize',
- 'minimize',
- 'restore'
- );
- if(Ext.isDefined(this.initHidden)){
- this.hidden = this.initHidden;
- }
- if(this.hidden === false){
- this.hidden = true;
- this.show();
- }
- },
- getState : function(){
- return Ext.apply(Ext.Window.superclass.getState.call(this) || {}, this.getBox(true));
- },
- onRender : function(ct, position){
- Ext.Window.superclass.onRender.call(this, ct, position);
- if(this.plain){
- this.el.addClass('x-window-plain');
- }
- this.focusEl = this.el.createChild({
- tag: 'a', href:'#', cls:'x-dlg-focus',
- tabIndex:'-1', html: ' '});
- this.focusEl.swallowEvent('click', true);
- this.proxy = this.el.createProxy('x-window-proxy');
- this.proxy.enableDisplayMode('block');
- if(this.modal){
- this.mask = this.container.createChild({cls:'ext-el-mask'}, this.el.dom);
- this.mask.enableDisplayMode('block');
- this.mask.hide();
- this.mon(this.mask, 'click', this.focus, this);
- }
- if(this.maximizable){
- this.mon(this.header, 'dblclick', this.toggleMaximize, this);
- }
- },
- initEvents : function(){
- Ext.Window.superclass.initEvents.call(this);
- if(this.animateTarget){
- this.setAnimateTarget(this.animateTarget);
- }
- if(this.resizable){
- this.resizer = new Ext.Resizable(this.el, {
- minWidth: this.minWidth,
- minHeight:this.minHeight,
- handles: this.resizeHandles || 'all',
- pinned: true,
- resizeElement : this.resizerAction
- });
- this.resizer.window = this;
- this.mon(this.resizer, 'beforeresize', this.beforeResize, this);
- }
- if(this.draggable){
- this.header.addClass('x-window-draggable');
- }
- this.mon(this.el, 'mousedown', this.toFront, this);
- this.manager = this.manager || Ext.WindowMgr;
- this.manager.register(this);
- if(this.maximized){
- this.maximized = false;
- this.maximize();
- }
- if(this.closable){
- var km = this.getKeyMap();
- km.on(27, this.onEsc, this);
- km.disable();
- }
- },
- initDraggable : function(){
- this.dd = new Ext.Window.DD(this);
- },
- onEsc : function(){
- this[this.closeAction]();
- },
- beforeDestroy : function(){
- if (this.rendered){
- this.hide();
- if(this.doAnchor){
- Ext.EventManager.removeResizeListener(this.doAnchor, this);
- Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
- }
- Ext.destroy(
- this.focusEl,
- this.resizer,
- this.dd,
- this.proxy,
- this.mask
- );
- }
- Ext.Window.superclass.beforeDestroy.call(this);
- },
- onDestroy : function(){
- if(this.manager){
- this.manager.unregister(this);
- }
- Ext.Window.superclass.onDestroy.call(this);
- },
- initTools : function(){
- if(this.minimizable){
- this.addTool({
- id: 'minimize',
- handler: this.minimize.createDelegate(this, [])
- });
- }
- if(this.maximizable){
- this.addTool({
- id: 'maximize',
- handler: this.maximize.createDelegate(this, [])
- });
- this.addTool({
- id: 'restore',
- handler: this.restore.createDelegate(this, []),
- hidden:true
- });
- }
- if(this.closable){
- this.addTool({
- id: 'close',
- handler: this[this.closeAction].createDelegate(this, [])
- });
- }
- },
- resizerAction : function(){
- var box = this.proxy.getBox();
- this.proxy.hide();
- this.window.handleResize(box);
- return box;
- },
- beforeResize : function(){
- this.resizer.minHeight = Math.max(this.minHeight, this.getFrameHeight() + 40);
- this.resizer.minWidth = Math.max(this.minWidth, this.getFrameWidth() + 40);
- this.resizeBox = this.el.getBox();
- },
- updateHandles : function(){
- if(Ext.isIE && this.resizer){
- this.resizer.syncHandleHeight();
- this.el.repaint();
- }
- },
- handleResize : function(box){
- var rz = this.resizeBox;
- if(rz.x != box.x || rz.y != box.y){
- this.updateBox(box);
- }else{
- this.setSize(box);
- }
- this.focus();
- this.updateHandles();
- this.saveState();
- },
- focus : function(){
- var f = this.focusEl, db = this.defaultButton, t = typeof db;
- if(Ext.isDefined(db)){
- if(Ext.isNumber(db) && this.fbar){
- f = this.fbar.items.get(db);
- }else if(Ext.isString(db)){
- f = Ext.getCmp(db);
- }else{
- f = db;
- }
- }
- f = f || this.focusEl;
- f.focus.defer(10, f);
- },
- setAnimateTarget : function(el){
- el = Ext.get(el);
- this.animateTarget = el;
- },
- beforeShow : function(){
- delete this.el.lastXY;
- delete this.el.lastLT;
- if(this.x === undefined || this.y === undefined){
- var xy = this.el.getAlignToXY(this.container, 'c-c');
- var pos = this.el.translatePoints(xy[0], xy[1]);
- this.x = this.x === undefined? pos.left : this.x;
- this.y = this.y === undefined? pos.top : this.y;
- }
- this.el.setLeftTop(this.x, this.y);
- if(this.expandOnShow){
- this.expand(false);
- }
- if(this.modal){
- Ext.getBody().addClass('x-body-masked');
- this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
- this.mask.show();
- }
- },
- show : function(animateTarget, cb, scope){
- if(!this.rendered){
- this.render(Ext.getBody());
- }
- if(this.hidden === false){
- this.toFront();
- return this;
- }
- if(this.fireEvent('beforeshow', this) === false){
- return this;
- }
- if(cb){
- this.on('show', cb, scope, {single:true});
- }
- this.hidden = false;
- if(Ext.isDefined(animateTarget)){
- this.setAnimateTarget(animateTarget);
- }
- this.beforeShow();
- if(this.animateTarget){
- this.animShow();
- }else{
- this.afterShow();
- }
- return this;
- },
- afterShow : function(isAnim){
- this.proxy.hide();
- this.el.setStyle('display', 'block');
- this.el.show();
- if(this.maximized){
- this.fitContainer();
- }
- if(Ext.isMac && Ext.isGecko2){
- this.cascade(this.setAutoScroll);
- }
- if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
- Ext.EventManager.onWindowResize(this.onWindowResize, this);
- }
- this.doConstrain();
- this.doLayout();
- if(this.keyMap){
- this.keyMap.enable();
- }
- this.toFront();
- this.updateHandles();
- if(isAnim && (Ext.isIE || Ext.isWebKit)){
- var sz = this.getSize();
- this.onResize(sz.width, sz.height);
- }
- this.onShow();
- this.fireEvent('show', this);
- },
- animShow : function(){
- this.proxy.show();
- this.proxy.setBox(this.animateTarget.getBox());
- this.proxy.setOpacity(0);
- var b = this.getBox();
- this.el.setStyle('display', 'none');
- this.proxy.shift(Ext.apply(b, {
- callback: this.afterShow.createDelegate(this, [true], false),
- scope: this,
- easing: 'easeNone',
- duration: 0.25,
- opacity: 0.5
- }));
- },
- hide : function(animateTarget, cb, scope){
- if(this.hidden || this.fireEvent('beforehide', this) === false){
- return this;
- }
- if(cb){
- this.on('hide', cb, scope, {single:true});
- }
- this.hidden = true;
- if(animateTarget !== undefined){
- this.setAnimateTarget(animateTarget);
- }
- if(this.modal){
- this.mask.hide();
- Ext.getBody().removeClass('x-body-masked');
- }
- if(this.animateTarget){
- this.animHide();
- }else{
- this.el.hide();
- this.afterHide();
- }
- return this;
- },
- afterHide : function(){
- this.proxy.hide();
- if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
- Ext.EventManager.removeResizeListener(this.onWindowResize, this);
- }
- if(this.keyMap){
- this.keyMap.disable();
- }
- this.onHide();
- this.fireEvent('hide', this);
- },
- animHide : function(){
- this.proxy.setOpacity(0.5);
- this.proxy.show();
- var tb = this.getBox(false);
- this.proxy.setBox(tb);
- this.el.hide();
- this.proxy.shift(Ext.apply(this.animateTarget.getBox(), {
- callback: this.afterHide,
- scope: this,
- duration: 0.25,
- easing: 'easeNone',
- opacity: 0
- }));
- },
- onShow : Ext.emptyFn,
- onHide : Ext.emptyFn,
- onWindowResize : function(){
- if(this.maximized){
- this.fitContainer();
- }
- if(this.modal){
- this.mask.setSize('100%', '100%');
- var force = this.mask.dom.offsetHeight;
- this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
- }
- this.doConstrain();
- },
- doConstrain : function(){
- if(this.constrain || this.constrainHeader){
- var offsets;
- if(this.constrain){
- offsets = {
- right:this.el.shadowOffset,
- left:this.el.shadowOffset,
- bottom:this.el.shadowOffset
- };
- }else {
- var s = this.getSize();
- offsets = {
- right:-(s.width - 100),
- bottom:-(s.height - 25)
- };
- }
- var xy = this.el.getConstrainToXY(this.container, true, offsets);
- if(xy){
- this.setPosition(xy[0], xy[1]);
- }
- }
- },
- ghost : function(cls){
- var ghost = this.createGhost(cls);
- var box = this.getBox(true);
- ghost.setLeftTop(box.x, box.y);
- ghost.setWidth(box.width);
- this.el.hide();
- this.activeGhost = ghost;
- return ghost;
- },
- unghost : function(show, matchPosition){
- if(!this.activeGhost) {
- return;
- }
- if(show !== false){
- this.el.show();
- this.focus();
- if(Ext.isMac && Ext.isGecko2){
- this.cascade(this.setAutoScroll);
- }
- }
- if(matchPosition !== false){
- this.setPosition(this.activeGhost.getLeft(true), this.activeGhost.getTop(true));
- }
- this.activeGhost.hide();
- this.activeGhost.remove();
- delete this.activeGhost;
- },
- minimize : function(){
- this.fireEvent('minimize', this);
- return this;
- },
- close : function(){
- if(this.fireEvent('beforeclose', this) !== false){
- if(this.hidden){
- this.doClose();
- }else{
- this.hide(null, this.doClose, this);
- }
- }
- },
- doClose : function(){
- this.fireEvent('close', this);
- this.destroy();
- },
- maximize : function(){
- if(!this.maximized){
- this.expand(false);
- this.restoreSize = this.getSize();
- this.restorePos = this.getPosition(true);
- if (this.maximizable){
- this.tools.maximize.hide();
- this.tools.restore.show();
- }
- this.maximized = true;
- this.el.disableShadow();
- if(this.dd){
- this.dd.lock();
- }
- if(this.collapsible){
- this.tools.toggle.hide();
- }
- this.el.addClass('x-window-maximized');
- this.container.addClass('x-window-maximized-ct');
- this.setPosition(0, 0);
- this.fitContainer();
- this.fireEvent('maximize', this);
- }
- return this;
- },
- restore : function(){
- if(this.maximized){
- var t = this.tools;
- this.el.removeClass('x-window-maximized');
- if(t.restore){
- t.restore.hide();
- }
- if(t.maximize){
- t.maximize.show();
- }
- this.setPosition(this.restorePos[0], this.restorePos[1]);
- this.setSize(this.restoreSize.width, this.restoreSize.height);
- delete this.restorePos;
- delete this.restoreSize;
- this.maximized = false;
- this.el.enableShadow(true);
- if(this.dd){
- this.dd.unlock();
- }
- if(this.collapsible && t.toggle){
- t.toggle.show();
- }
- this.container.removeClass('x-window-maximized-ct');
- this.doConstrain();
- this.fireEvent('restore', this);
- }
- return this;
- },
- toggleMaximize : function(){
- return this[this.maximized ? 'restore' : 'maximize']();
- },
- fitContainer : function(){
- var vs = this.container.getViewSize(false);
- this.setSize(vs.width, vs.height);
- },
- setZIndex : function(index){
- if(this.modal){
- this.mask.setStyle('z-index', index);
- }
- this.el.setZIndex(++index);
- index += 5;
- if(this.resizer){
- this.resizer.proxy.setStyle('z-index', ++index);
- }
- this.lastZIndex = index;
- },
- alignTo : function(element, position, offsets){
- var xy = this.el.getAlignToXY(element, position, offsets);
- this.setPagePosition(xy[0], xy[1]);
- return this;
- },
- anchorTo : function(el, alignment, offsets, monitorScroll){
- if(this.doAnchor){
- Ext.EventManager.removeResizeListener(this.doAnchor, this);
- Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
- }
- this.doAnchor = function(){
- this.alignTo(el, alignment, offsets);
- };
- Ext.EventManager.onWindowResize(this.doAnchor, this);
- var tm = typeof monitorScroll;
- if(tm != 'undefined'){
- Ext.EventManager.on(window, 'scroll', this.doAnchor, this,
- {buffer: tm == 'number' ? monitorScroll : 50});
- }
- this.doAnchor();
- return this;
- },
- toFront : function(e){
- if(this.manager.bringToFront(this)){
- if(!e || !e.getTarget().focus){
- this.focus();
- }
- }
- return this;
- },
- setActive : function(active){
- if(active){
- if(!this.maximized){
- this.el.enableShadow(true);
- }
- this.fireEvent('activate', this);
- }else{
- this.el.disableShadow();
- this.fireEvent('deactivate', this);
- }
- },
- toBack : function(){
- this.manager.sendToBack(this);
- return this;
- },
- center : function(){
- var xy = this.el.getAlignToXY(this.container, 'c-c');
- this.setPagePosition(xy[0], xy[1]);
- return this;
- }
- });
- Ext.reg('window', Ext.Window);
- Ext.Window.DD = function(win){
- this.win = win;
- Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id);
- this.setHandleElId(win.header.id);
- this.scroll = false;
- };
- Ext.extend(Ext.Window.DD, Ext.dd.DD, {
- moveOnly:true,
- headerOffsets:[100, 25],
- startDrag : function(){
- var w = this.win;
- this.proxy = w.ghost();
- if(w.constrain !== false){
- var so = w.el.shadowOffset;
- this.constrainTo(w.container, {right: so, left: so, bottom: so});
- }else if(w.constrainHeader !== false){
- var s = this.proxy.getSize();
- this.constrainTo(w.container, {right: -(s.width-this.headerOffsets[0]), bottom: -(s.height-this.headerOffsets[1])});
- }
- },
- b4Drag : Ext.emptyFn,
- onDrag : function(e){
- this.alignElWithMouse(this.proxy, e.getPageX(), e.getPageY());
- },
- endDrag : function(e){
- this.win.unghost();
- this.win.saveState();
- }
- });
- Ext.WindowGroup = function(){
- var list = {};
- var accessList = [];
- var front = null;
- var sortWindows = function(d1, d2){
- return (!d1._lastAccess || d1._lastAccess < d2._lastAccess) ? -1 : 1;
- };
- var orderWindows = function(){
- var a = accessList, len = a.length;
- if(len > 0){
- a.sort(sortWindows);
- var seed = a[0].manager.zseed;
- for(var i = 0; i < len; i++){
- var win = a[i];
- if(win && !win.hidden){
- win.setZIndex(seed + (i*10));
- }
- }
- }
- activateLast();
- };
- var setActiveWin = function(win){
- if(win != front){
- if(front){
- front.setActive(false);
- }
- front = win;
- if(win){
- win.setActive(true);
- }
- }
- };
- var activateLast = function(){
- for(var i = accessList.length-1; i >=0; --i) {
- if(!accessList[i].hidden){
- setActiveWin(accessList[i]);
- return;
- }
- }
- setActiveWin(null);
- };
- return {
- zseed : 9000,
- register : function(win){
- if(win.manager){
- win.manager.unregister(win);
- }
- win.manager = this;
- list[win.id] = win;
- accessList.push(win);
- win.on('hide', activateLast);
- },
- unregister : function(win){
- delete win.manager;
- delete list[win.id];
- win.un('hide', activateLast);
- accessList.remove(win);
- },
- get : function(id){
- return typeof id == "object" ? id : list[id];
- },
- bringToFront : function(win){
- win = this.get(win);
- if(win != front){
- win._lastAccess = new Date().getTime();
- orderWindows();
- return true;
- }
- return false;
- },
- sendToBack : function(win){
- win = this.get(win);
- win._lastAccess = -(new Date().getTime());
- orderWindows();
- return win;
- },
- hideAll : function(){
- for(var id in list){
- if(list[id] && typeof list[id] != "function" && list[id].isVisible()){
- list[id].hide();
- }
- }
- },
- getActive : function(){
- return front;
- },
- getBy : function(fn, scope){
- var r = [];
- for(var i = accessList.length-1; i >=0; --i) {
- var win = accessList[i];
- if(fn.call(scope||win, win) !== false){
- r.push(win);
- }
- }
- return r;
- },
- each : function(fn, scope){
- for(var id in list){
- if(list[id] && typeof list[id] != "function"){
- if(fn.call(scope || list[id], list[id]) === false){
- return;
- }
- }
- }
- }
- };
- };
- Ext.WindowMgr = new Ext.WindowGroup();
- Ext.MessageBox = function(){
- var dlg, opt, mask, waitTimer,
- bodyEl, msgEl, textboxEl, textareaEl, progressBar, pp, iconEl, spacerEl,
- buttons, activeTextEl, bwidth, bufferIcon = '', iconCls = '',
- buttonNames = ['ok', 'yes', 'no', 'cancel'];
- var handleButton = function(button){
- buttons[button].blur();
- if(dlg.isVisible()){
- dlg.hide();
- handleHide();
- Ext.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value, opt], 1);
- }
- };
- var handleHide = function(){
- if(opt && opt.cls){
- dlg.el.removeClass(opt.cls);
- }
- progressBar.reset();
- };
- var handleEsc = function(d, k, e){
- if(opt && opt.closable !== false){
- dlg.hide();
- handleHide();
- }
- if(e){
- e.stopEvent();
- }
- };
- var updateButtons = function(b){
- var width = 0,
- cfg;
- if(!b){
- Ext.each(buttonNames, function(name){
- buttons[name].hide();
- });
- return width;
- }
- dlg.footer.dom.style.display = '';
- Ext.iterate(buttons, function(name, btn){
- cfg = b[name];
- if(cfg){
- btn.show();
- btn.setText(Ext.isString(cfg) ? cfg : Ext.MessageBox.buttonText[name]);
- width += btn.getEl().getWidth() + 15;
- }else{
- btn.hide();
- }
- });
- return width;
- };
- return {
- getDialog : function(titleText){
- if(!dlg){
- var btns = [];
- buttons = {};
- Ext.each(buttonNames, function(name){
- btns.push(buttons[name] = new Ext.Button({
- text: this.buttonText[name],
- handler: handleButton.createCallback(name),
- hideMode: 'offsets'
- }));
- }, this);
- dlg = new Ext.Window({
- autoCreate : true,
- title:titleText,
- resizable:false,
- constrain:true,
- constrainHeader:true,
- minimizable : false,
- maximizable : false,
- stateful: false,
- modal: true,
- shim:true,
- buttonAlign:"center",
- width:400,
- height:100,
- minHeight: 80,
- plain:true,
- footer:true,
- closable:true,
- close : function(){
- if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
- handleButton("no");
- }else{
- handleButton("cancel");
- }
- },
- fbar: new Ext.Toolbar({
- items: btns,
- enableOverflow: false
- })
- });
- dlg.render(document.body);
- dlg.getEl().addClass('x-window-dlg');
- mask = dlg.mask;
- bodyEl = dlg.body.createChild({
- html:'<div class="ext-mb-icon"></div><div class="ext-mb-content"><span class="ext-mb-text"></span><br /><div class="ext-mb-fix-cursor"><input type="text" class="ext-mb-input" /><textarea class="ext-mb-textarea"></textarea></div></div>'
- });
- iconEl = Ext.get(bodyEl.dom.firstChild);
- var contentEl = bodyEl.dom.childNodes[1];
- msgEl = Ext.get(contentEl.firstChild);
- textboxEl = Ext.get(contentEl.childNodes[2].firstChild);
- textboxEl.enableDisplayMode();
- textboxEl.addKeyListener([10,13], function(){
- if(dlg.isVisible() && opt && opt.buttons){
- if(opt.buttons.ok){
- handleButton("ok");
- }else if(opt.buttons.yes){
- handleButton("yes");
- }
- }
- });
- textareaEl = Ext.get(contentEl.childNodes[2].childNodes[1]);
- textareaEl.enableDisplayMode();
- progressBar = new Ext.ProgressBar({
- renderTo:bodyEl
- });
- bodyEl.createChild({cls:'x-clear'});
- }
- return dlg;
- },
- updateText : function(text){
- if(!dlg.isVisible() && !opt.width){
- dlg.setSize(this.maxWidth, 100);
- }
- msgEl.update(text || ' ');
- var iw = iconCls != '' ? (iconEl.getWidth() + iconEl.getMargins('lr')) : 0;
- var mw = msgEl.getWidth() + msgEl.getMargins('lr');
- var fw = dlg.getFrameWidth('lr');
- var bw = dlg.body.getFrameWidth('lr');
- if (Ext.isIE && iw > 0){
- iw += 3;
- }
- var w = Math.max(Math.min(opt.width || iw+mw+fw+bw, this.maxWidth),
- Math.max(opt.minWidth || this.minWidth, bwidth || 0));
- if(opt.prompt === true){
- activeTextEl.setWidth(w-iw-fw-bw);
- }
- if(opt.progress === true || opt.wait === true){
- progressBar.setSize(w-iw-fw-bw);
- }
- if(Ext.isIE && w == bwidth){
- w += 4;
- }
- dlg.setSize(w, 'auto').center();
- return this;
- },
- updateProgress : function(value, progressText, msg){
- progressBar.updateProgress(value, progressText);
- if(msg){
- this.updateText(msg);
- }
- return this;
- },
- isVisible : function(){
- return dlg && dlg.isVisible();
- },
- hide : function(){
- var proxy = dlg ? dlg.activeGhost : null;
- if(this.isVisible() || proxy){
- dlg.hide();
- handleHide();
- if (proxy){
- dlg.unghost(false, false);
- }
- }
- return this;
- },
- show : function(options){
- if(this.isVisible()){
- this.hide();
- }
- opt = options;
- var d = this.getDialog(opt.title || " ");
- d.setTitle(opt.title || " ");
- var allowClose = (opt.closable !== false && opt.progress !== true && opt.wait !== true);
- d.tools.close.setDisplayed(allowClose);
- activeTextEl = textboxEl;
- opt.prompt = opt.prompt || (opt.multiline ? true : false);
- if(opt.prompt){
- if(opt.multiline){
- textboxEl.hide();
- textareaEl.show();
- textareaEl.setHeight(Ext.isNumber(opt.multiline) ? opt.multiline : this.defaultTextHeight);
- activeTextEl = textareaEl;
- }else{
- textboxEl.show();
- textareaEl.hide();
- }
- }else{
- textboxEl.hide();
- textareaEl.hide();
- }
- activeTextEl.dom.value = opt.value || "";
- if(opt.prompt){
- d.focusEl = activeTextEl;
- }else{
- var bs = opt.buttons;
- var db = null;
- if(bs && bs.ok){
- db = buttons["ok"];
- }else if(bs && bs.yes){
- db = buttons["yes"];
- }
- if (db){
- d.focusEl = db;
- }
- }
- if(opt.iconCls){
- d.setIconClass(opt.iconCls);
- }
- this.setIcon(Ext.isDefined(opt.icon) ? opt.icon : bufferIcon);
- bwidth = updateButtons(opt.buttons);
- progressBar.setVisible(opt.progress === true || opt.wait === true);
- this.updateProgress(0, opt.progressText);
- this.updateText(opt.msg);
- if(opt.cls){
- d.el.addClass(opt.cls);
- }
- d.proxyDrag = opt.proxyDrag === true;
- d.modal = opt.modal !== false;
- d.mask = opt.modal !== false ? mask : false;
- if(!d.isVisible()){
- document.body.appendChild(dlg.el.dom);
- d.setAnimateTarget(opt.animEl);
- d.on('show', function(){
- if(allowClose === true){
- d.keyMap.enable();
- }else{
- d.keyMap.disable();
- }
- }, this, {single:true});
- d.show(opt.animEl);
- }
- if(opt.wait === true){
- progressBar.wait(opt.waitConfig);
- }
- return this;
- },
- setIcon : function(icon){
- if(!dlg){
- bufferIcon = icon;
- return;
- }
- bufferIcon = undefined;
- if(icon && icon != ''){
- iconEl.removeClass('x-hidden');
- iconEl.replaceClass(iconCls, icon);
- bodyEl.addClass('x-dlg-icon');
- iconCls = icon;
- }else{
- iconEl.replaceClass(iconCls, 'x-hidden');
- bodyEl.removeClass('x-dlg-icon');
- iconCls = '';
- }
- return this;
- },
- progress : function(title, msg, progressText){
- this.show({
- title : title,
- msg : msg,
- buttons: false,
- progress:true,
- closable:false,
- minWidth: this.minProgressWidth,
- progressText: progressText
- });
- return this;
- },
- wait : function(msg, title, config){
- this.show({
- title : title,
- msg : msg,
- buttons: false,
- closable:false,
- wait:true,
- modal:true,
- minWidth: this.minProgressWidth,
- waitConfig: config
- });
- return this;
- },
- alert : function(title, msg, fn, scope){
- this.show({
- title : title,
- msg : msg,
- buttons: this.OK,
- fn: fn,
- scope : scope
- });
- return this;
- },
- confirm : function(title, msg, fn, scope){
- this.show({
- title : title,
- msg : msg,
- buttons: this.YESNO,
- fn: fn,
- scope : scope,
- icon: this.QUESTION
- });
- return this;
- },
- prompt : function(title, msg, fn, scope, multiline, value){
- this.show({
- title : title,
- msg : msg,
- buttons: this.OKCANCEL,
- fn: fn,
- minWidth:250,
- scope : scope,
- prompt:true,
- multiline: multiline,
- value: value
- });
- return this;
- },
- OK : {ok:true},
- CANCEL : {cancel:true},
- OKCANCEL : {ok:true, cancel:true},
- YESNO : {yes:true, no:true},
- YESNOCANCEL : {yes:true, no:true, cancel:true},
- INFO : 'ext-mb-info',
- WARNING : 'ext-mb-warning',
- QUESTION : 'ext-mb-question',
- ERROR : 'ext-mb-error',
- defaultTextHeight : 75,
- maxWidth : 600,
- minWidth : 100,
- minProgressWidth : 250,
- buttonText : {
- ok : "OK",
- cancel : "Cancel",
- yes : "Yes",
- no : "No"
- }
- };
- }();
- Ext.Msg = Ext.MessageBox;
- Ext.dd.PanelProxy = function(panel, config){
- this.panel = panel;
- this.id = this.panel.id +'-ddproxy';
- Ext.apply(this, config);
- };
- Ext.dd.PanelProxy.prototype = {
- insertProxy : true,
- setStatus : Ext.emptyFn,
- reset : Ext.emptyFn,
- update : Ext.emptyFn,
- stop : Ext.emptyFn,
- sync: Ext.emptyFn,
- getEl : function(){
- return this.ghost;
- },
- getGhost : function(){
- return this.ghost;
- },
- getProxy : function(){
- return this.proxy;
- },
- hide : function(){
- if(this.ghost){
- if(this.proxy){
- this.proxy.remove();
- delete this.proxy;
- }
- this.panel.el.dom.style.display = '';
- this.ghost.remove();
- delete this.ghost;
- }
- },
- show : function(){
- if(!this.ghost){
- this.ghost = this.panel.createGhost(undefined, undefined, Ext.getBody());
- this.ghost.setXY(this.panel.el.getXY())
- if(this.insertProxy){
- this.proxy = this.panel.el.insertSibling({cls:'x-panel-dd-spacer'});
- this.proxy.setSize(this.panel.getSize());
- }
- this.panel.el.dom.style.display = 'none';
- }
- },
- repair : function(xy, callback, scope){
- this.hide();
- if(typeof callback == "function"){
- callback.call(scope || this);
- }
- },
- moveProxy : function(parentNode, before){
- if(this.proxy){
- parentNode.insertBefore(this.proxy.dom, before);
- }
- }
- };
- Ext.Panel.DD = function(panel, cfg){
- this.panel = panel;
- this.dragData = {panel: panel};
- this.proxy = new Ext.dd.PanelProxy(panel, cfg);
- Ext.Panel.DD.superclass.constructor.call(this, panel.el, cfg);
- var h = panel.header;
- if(h){
- this.setHandleElId(h.id);
- }
- (h ? h : this.panel.body).setStyle('cursor', 'move');
- this.scroll = false;
- };
- Ext.extend(Ext.Panel.DD, Ext.dd.DragSource, {
- showFrame: Ext.emptyFn,
- startDrag: Ext.emptyFn,
- b4StartDrag: function(x, y) {
- this.proxy.show();
- },
- b4MouseDown: function(e) {
- var x = e.getPageX();
- var y = e.getPageY();
- this.autoOffset(x, y);
- },
- onInitDrag : function(x, y){
- this.onStartDrag(x, y);
- return true;
- },
- createFrame : Ext.emptyFn,
- getDragEl : function(e){
- return this.proxy.ghost.dom;
- },
- endDrag : function(e){
- this.proxy.hide();
- this.panel.saveState();
- },
- autoOffset : function(x, y) {
- x -= this.startPageX;
- y -= this.startPageY;
- this.setDelta(x, y);
- }
- });
- Ext.state.Provider = function(){
- this.addEvents("statechange");
- this.state = {};
- Ext.state.Provider.superclass.constructor.call(this);
- };
- Ext.extend(Ext.state.Provider, Ext.util.Observable, {
- get : function(name, defaultValue){
- return typeof this.state[name] == "undefined" ?
- defaultValue : this.state[name];
- },
- clear : function(name){
- delete this.state[name];
- this.fireEvent("statechange", this, name, null);
- },
- set : function(name, value){
- this.state[name] = value;
- this.fireEvent("statechange", this, name, value);
- },
- decodeValue : function(cookie){
- var re = /^(a|n|d|b|s|o):(.*)$/;
- var matches = re.exec(unescape(cookie));
- if(!matches || !matches[1]) return;
- var type = matches[1];
- var v = matches[2];
- switch(type){
- case "n":
- return parseFloat(v);
- case "d":
- return new Date(Date.parse(v));
- case "b":
- return (v == "1");
- case "a":
- var all = [];
- if(v != ''){
- Ext.each(v.split('^'), function(val){
- all.push(this.decodeValue(val));
- }, this);
- }
- return all;
- case "o":
- var all = {};
- if(v != ''){
- Ext.each(v.split('^'), function(val){
- var kv = val.split('=');
- all[kv[0]] = this.decodeValue(kv[1]);
- }, this);
- }
- return all;
- default:
- return v;
- }
- },
- encodeValue : function(v){
- var enc;
- if(typeof v == "number"){
- enc = "n:" + v;
- }else if(typeof v == "boolean"){
- enc = "b:" + (v ? "1" : "0");
- }else if(Ext.isDate(v)){
- enc = "d:" + v.toGMTString();
- }else if(Ext.isArray(v)){
- var flat = "";
- for(var i = 0, len = v.length; i < len; i++){
- flat += this.encodeValue(v[i]);
- if(i != len-1) flat += "^";
- }
- enc = "a:" + flat;
- }else if(typeof v == "object"){
- var flat = "";
- for(var key in v){
- if(typeof v[key] != "function" && v[key] !== undefined){
- flat += key + "=" + this.encodeValue(v[key]) + "^";
- }
- }
- enc = "o:" + flat.substring(0, flat.length-1);
- }else{
- enc = "s:" + v;
- }
- return escape(enc);
- }
- });
- Ext.state.Manager = function(){
- var provider = new Ext.state.Provider();
- return {
- setProvider : function(stateProvider){
- provider = stateProvider;
- },
- get : function(key, defaultValue){
- return provider.get(key, defaultValue);
- },
- set : function(key, value){
- provider.set(key, value);
- },
- clear : function(key){
- provider.clear(key);
- },
- getProvider : function(){
- return provider;
- }
- };
- }();
- Ext.state.CookieProvider = function(config){
- Ext.state.CookieProvider.superclass.constructor.call(this);
- this.path = "/";
- this.expires = new Date(new Date().getTime()+(1000*60*60*24*7));
- this.domain = null;
- this.secure = false;
- Ext.apply(this, config);
- this.state = this.readCookies();
- };
- Ext.extend(Ext.state.CookieProvider, Ext.state.Provider, {
- set : function(name, value){
- if(typeof value == "undefined" || value === null){
- this.clear(name);
- return;
- }
- this.setCookie(name, value);
- Ext.state.CookieProvider.superclass.set.call(this, name, value);
- },
- clear : function(name){
- this.clearCookie(name);
- Ext.state.CookieProvider.superclass.clear.call(this, name);
- },
- readCookies : function(){
- var cookies = {};
- var c = document.cookie + ";";
- var re = /s?(.*?)=(.*?);/g;
- var matches;
- while((matches = re.exec(c)) != null){
- var name = matches[1];
- var value = matches[2];
- if(name && name.substring(0,3) == "ys-"){
- cookies[name.substr(3)] = this.decodeValue(value);
- }
- }
- return cookies;
- },
- setCookie : function(name, value){
- document.cookie = "ys-"+ name + "=" + this.encodeValue(value) +
- ((this.expires == null) ? "" : ("; expires=" + this.expires.toGMTString())) +
- ((this.path == null) ? "" : ("; path=" + this.path)) +
- ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
- ((this.secure == true) ? "; secure" : "");
- },
- clearCookie : function(name){
- document.cookie = "ys-" + name + "=null; expires=Thu, 01-Jan-70 00:00:01 GMT" +
- ((this.path == null) ? "" : ("; path=" + this.path)) +
- ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
- ((this.secure == true) ? "; secure" : "");
- }
- });
- Ext.DataView = Ext.extend(Ext.BoxComponent, {
- selectedClass : "x-view-selected",
- emptyText : "",
- deferEmptyText: true,
- trackOver: false,
- last: false,
- initComponent : function(){
- Ext.DataView.superclass.initComponent.call(this);
- if(Ext.isString(this.tpl) || Ext.isArray(this.tpl)){
- this.tpl = new Ext.XTemplate(this.tpl);
- }
- this.addEvents(
- "beforeclick",
- "click",
- "mouseenter",
- "mouseleave",
- "containerclick",
- "dblclick",
- "contextmenu",
- "containercontextmenu",
- "selectionchange",
- "beforeselect"
- );
- this.store = Ext.StoreMgr.lookup(this.store);
- this.all = new Ext.CompositeElementLite();
- this.selected = new Ext.CompositeElementLite();
- },
- afterRender : function(){
- Ext.DataView.superclass.afterRender.call(this);
- this.mon(this.getTemplateTarget(), {
- "click": this.onClick,
- "dblclick": this.onDblClick,
- "contextmenu": this.onContextMenu,
- scope:this
- });
- if(this.overClass || this.trackOver){
- this.mon(this.getTemplateTarget(), {
- "mouseover": this.onMouseOver,
- "mouseout": this.onMouseOut,
- scope:this
- });
- }
- if(this.store){
- this.bindStore(this.store, true);
- }
- },
- refresh : function(){
- this.clearSelections(false, true);
- var el = this.getTemplateTarget();
- el.update("");
- var records = this.store.getRange();
- if(records.length < 1){
- if(!this.deferEmptyText || this.hasSkippedEmptyText){
- el.update(this.emptyText);
- }
- this.all.clear();
- }else{
- this.tpl.overwrite(el, this.collectData(records, 0));
- this.all.fill(Ext.query(this.itemSelector, el.dom));
- this.updateIndexes(0);
- }
- this.hasSkippedEmptyText = true;
- },
- getTemplateTarget: function(){
- return this.el;
- },
- prepareData : function(data){
- return data;
- },
- collectData : function(records, startIndex){
- var r = [];
- for(var i = 0, len = records.length; i < len; i++){
- r[r.length] = this.prepareData(records[i].data, startIndex+i, records[i]);
- }
- return r;
- },
- bufferRender : function(records){
- var div = document.createElement('div');
- this.tpl.overwrite(div, this.collectData(records));
- return Ext.query(this.itemSelector, div);
- },
- onUpdate : function(ds, record){
- var index = this.store.indexOf(record);
- if(index > -1){
- var sel = this.isSelected(index);
- var original = this.all.elements[index];
- var node = this.bufferRender([record], index)[0];
- this.all.replaceElement(index, node, true);
- if(sel){
- this.selected.replaceElement(original, node);
- this.all.item(index).addClass(this.selectedClass);
- }
- this.updateIndexes(index, index);
- }
- },
- onAdd : function(ds, records, index){
- if(this.all.getCount() === 0){
- this.refresh();
- return;
- }
- var nodes = this.bufferRender(records, index), n, a = this.all.elements;
- if(index < this.all.getCount()){
- n = this.all.item(index).insertSibling(nodes, 'before', true);
- a.splice.apply(a, [index, 0].concat(nodes));
- }else{
- n = this.all.last().insertSibling(nodes, 'after', true);
- a.push.apply(a, nodes);
- }
- this.updateIndexes(index);
- },
- onRemove : function(ds, record, index){
- this.deselect(index);
- this.all.removeElement(index, true);
- this.updateIndexes(index);
- if (this.store.getCount() === 0){
- this.refresh();
- }
- },
- refreshNode : function(index){
- this.onUpdate(this.store, this.store.getAt(index));
- },
- updateIndexes : function(startIndex, endIndex){
- var ns = this.all.elements;
- startIndex = startIndex || 0;
- endIndex = endIndex || ((endIndex === 0) ? 0 : (ns.length - 1));
- for(var i = startIndex; i <= endIndex; i++){
- ns[i].viewIndex = i;
- }
- },
- getStore : function(){
- return this.store;
- },
- bindStore : function(store, initial){
- if(!initial && this.store){
- if(store !== this.store && this.store.autoDestroy){
- this.store.destroy();
- }else{
- this.store.un("beforeload", this.onBeforeLoad, this);
- this.store.un("datachanged", this.refresh, this);
- this.store.un("add", this.onAdd, this);
- this.store.un("remove", this.onRemove, this);
- this.store.un("update", this.onUpdate, this);
- this.store.un("clear", this.refresh, this);
- }
- if(!store){
- this.store = null;
- }
- }
- if(store){
- store = Ext.StoreMgr.lookup(store);
- store.on({
- scope: this,
- beforeload: this.onBeforeLoad,
- datachanged: this.refresh,
- add: this.onAdd,
- remove: this.onRemove,
- update: this.onUpdate,
- clear: this.refresh
- });
- }
- this.store = store;
- if(store){
- this.refresh();
- }
- },
- findItemFromChild : function(node){
- return Ext.fly(node).findParent(this.itemSelector, this.getTemplateTarget());
- },
- onClick : function(e){
- var item = e.getTarget(this.itemSelector, this.getTemplateTarget());
- if(item){
- var index = this.indexOf(item);
- if(this.onItemClick(item, index, e) !== false){
- this.fireEvent("click", this, index, item, e);
- }
- }else{
- if(this.fireEvent("containerclick", this, e) !== false){
- this.onContainerClick(e);
- }
- }
- },
- onContainerClick : function(e){
- this.clearSelections();
- },
- onContextMenu : function(e){
- var item = e.getTarget(this.itemSelector, this.getTemplateTarget());
- if(item){
- this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
- }else{
- this.fireEvent("containercontextmenu", this, e);
- }
- },
- onDblClick : function(e){
- var item = e.getTarget(this.itemSelector, this.getTemplateTarget());
- if(item){
- this.fireEvent("dblclick", this, this.indexOf(item), item, e);
- }
- },
- onMouseOver : function(e){
- var item = e.getTarget(this.itemSelector, this.getTemplateTarget());
- if(item && item !== this.lastItem){
- this.lastItem = item;
- Ext.fly(item).addClass(this.overClass);
- this.fireEvent("mouseenter", this, this.indexOf(item), item, e);
- }
- },
- onMouseOut : function(e){
- if(this.lastItem){
- if(!e.within(this.lastItem, true, true)){
- Ext.fly(this.lastItem).removeClass(this.overClass);
- this.fireEvent("mouseleave", this, this.indexOf(this.lastItem), this.lastItem, e);
- delete this.lastItem;
- }
- }
- },
- onItemClick : function(item, index, e){
- if(this.fireEvent("beforeclick", this, index, item, e) === false){
- return false;
- }
- if(this.multiSelect){
- this.doMultiSelection(item, index, e);
- e.preventDefault();
- }else if(this.singleSelect){
- this.doSingleSelection(item, index, e);
- e.preventDefault();
- }
- return true;
- },
- doSingleSelection : function(item, index, e){
- if(e.ctrlKey && this.isSelected(index)){
- this.deselect(index);
- }else{
- this.select(index, false);
- }
- },
- doMultiSelection : function(item, index, e){
- if(e.shiftKey && this.last !== false){
- var last = this.last;
- this.selectRange(last, index, e.ctrlKey);
- this.last = last;
- }else{
- if((e.ctrlKey||this.simpleSelect) && this.isSelected(index)){
- this.deselect(index);
- }else{
- this.select(index, e.ctrlKey || e.shiftKey || this.simpleSelect);
- }
- }
- },
- getSelectionCount : function(){
- return this.selected.getCount();
- },
- getSelectedNodes : function(){
- return this.selected.elements;
- },
- getSelectedIndexes : function(){
- var indexes = [], s = this.selected.elements;
- for(var i = 0, len = s.length; i < len; i++){
- indexes.push(s[i].viewIndex);
- }
- return indexes;
- },
- getSelectedRecords : function(){
- var r = [], s = this.selected.elements;
- for(var i = 0, len = s.length; i < len; i++){
- r[r.length] = this.store.getAt(s[i].viewIndex);
- }
- return r;
- },
- getRecords : function(nodes){
- var r = [], s = nodes;
- for(var i = 0, len = s.length; i < len; i++){
- r[r.length] = this.store.getAt(s[i].viewIndex);
- }
- return r;
- },
- getRecord : function(node){
- return this.store.getAt(node.viewIndex);
- },
- clearSelections : function(suppressEvent, skipUpdate){
- if((this.multiSelect || this.singleSelect) && this.selected.getCount() > 0){
- if(!skipUpdate){
- this.selected.removeClass(this.selectedClass);
- }
- this.selected.clear();
- this.last = false;
- if(!suppressEvent){
- this.fireEvent("selectionchange", this, this.selected.elements);
- }
- }
- },
- isSelected : function(node){
- return this.selected.contains(this.getNode(node));
- },
- deselect : function(node){
- if(this.isSelected(node)){
- node = this.getNode(node);
- this.selected.removeElement(node);
- if(this.last == node.viewIndex){
- this.last = false;
- }
- Ext.fly(node).removeClass(this.selectedClass);
- this.fireEvent("selectionchange", this, this.selected.elements);
- }
- },
- select : function(nodeInfo, keepExisting, suppressEvent){
- if(Ext.isArray(nodeInfo)){
- if(!keepExisting){
- this.clearSelections(true);
- }
- for(var i = 0, len = nodeInfo.length; i < len; i++){
- this.select(nodeInfo[i], true, true);
- }
- if(!suppressEvent){
- this.fireEvent("selectionchange", this, this.selected.elements);
- }
- } else{
- var node = this.getNode(nodeInfo);
- if(!keepExisting){
- this.clearSelections(true);
- }
- if(node && !this.isSelected(node)){
- if(this.fireEvent("beforeselect", this, node, this.selected.elements) !== false){
- Ext.fly(node).addClass(this.selectedClass);
- this.selected.add(node);
- this.last = node.viewIndex;
- if(!suppressEvent){
- this.fireEvent("selectionchange", this, this.selected.elements);
- }
- }
- }
- }
- },
- selectRange : function(start, end, keepExisting){
- if(!keepExisting){
- this.clearSelections(true);
- }
- this.select(this.getNodes(start, end), true);
- },
- getNode : function(nodeInfo){
- if(Ext.isString(nodeInfo)){
- return document.getElementById(nodeInfo);
- }else if(Ext.isNumber(nodeInfo)){
- return this.all.elements[nodeInfo];
- }
- return nodeInfo;
- },
- getNodes : function(start, end){
- var ns = this.all.elements;
- start = start || 0;
- end = !Ext.isDefined(end) ? Math.max(ns.length - 1, 0) : end;
- var nodes = [], i;
- if(start <= end){
- for(i = start; i <= end && ns[i]; i++){
- nodes.push(ns[i]);
- }
- } else{
- for(i = start; i >= end && ns[i]; i--){
- nodes.push(ns[i]);
- }
- }
- return nodes;
- },
- indexOf : function(node){
- node = this.getNode(node);
- if(Ext.isNumber(node.viewIndex)){
- return node.viewIndex;
- }
- return this.all.indexOf(node);
- },
- onBeforeLoad : function(){
- if(this.loadingText){
- this.clearSelections(false, true);
- this.getTemplateTarget().update('<div class="loading-indicator">'+this.loadingText+'</div>');
- this.all.clear();
- }
- },
- onDestroy : function(){
- this.all.clear();
- this.selected.clear();
- Ext.DataView.superclass.onDestroy.call(this);
- this.bindStore(null);
- }
- });
- Ext.DataView.prototype.setStore = Ext.DataView.prototype.bindStore;
- Ext.reg('dataview', Ext.DataView);
- Ext.list.ListView = Ext.extend(Ext.DataView, {
- itemSelector: 'dl',
- selectedClass:'x-list-selected',
- overClass:'x-list-over',
- scrollOffset : undefined,
- columnResize: true,
- columnSort: true,
- maxWidth: Ext.isIE ? 99 : 100,
- initComponent : function(){
- if(this.columnResize){
- this.colResizer = new Ext.list.ColumnResizer(this.colResizer);
- this.colResizer.init(this);
- }
- if(this.columnSort){
- this.colSorter = new Ext.list.Sorter(this.columnSort);
- this.colSorter.init(this);
- }
- if(!this.internalTpl){
- this.internalTpl = new Ext.XTemplate(
- '<div class="x-list-header"><div class="x-list-header-inner">',
- '<tpl for="columns">',
- '<div style="width:{[values.width*100]}%;text-align:{align};"><em unselectable="on" id="',this.id, '-xlhd-{#}">',
- '{header}',
- '</em></div>',
- '</tpl>',
- '<div class="x-clear"></div>',
- '</div></div>',
- '<div class="x-list-body"><div class="x-list-body-inner">',
- '</div></div>'
- );
- }
- if(!this.tpl){
- this.tpl = new Ext.XTemplate(
- '<tpl for="rows">',
- '<dl>',
- '<tpl for="parent.columns">',
- '<dt style="width:{[values.width*100]}%;text-align:{align};">',
- '<em unselectable="on"<tpl if="cls"> class="{cls}</tpl>">',
- '{[values.tpl.apply(parent)]}',
- '</em></dt>',
- '</tpl>',
- '<div class="x-clear"></div>',
- '</dl>',
- '</tpl>'
- );
- };
- var cs = this.columns,
- allocatedWidth = 0,
- colsWithWidth = 0,
- len = cs.length,
- columns = [];
- for(var i = 0; i < len; i++){
- var c = cs[i];
- if(!c.isColumn) {
- c.xtype = c.xtype ? (/^lv/.test(c.xtype) ? c.xtype : 'lv' + c.xtype) : 'lvcolumn';
- c = Ext.create(c);
- }
- if(c.width) {
- allocatedWidth += c.width*100;
- colsWithWidth++;
- }
- columns.push(c);
- }
- cs = this.columns = columns;
- if(colsWithWidth < len){
- var remaining = len - colsWithWidth;
- if(allocatedWidth < this.maxWidth){
- var perCol = ((this.maxWidth-allocatedWidth) / remaining)/100;
- for(var j = 0; j < len; j++){
- var c = cs[j];
- if(!c.width){
- c.width = perCol;
- }
- }
- }
- }
- Ext.list.ListView.superclass.initComponent.call(this);
- },
- onRender : function(){
- this.autoEl = {
- cls: 'x-list-wrap'
- };
- Ext.list.ListView.superclass.onRender.apply(this, arguments);
- this.internalTpl.overwrite(this.el, {columns: this.columns});
- this.innerBody = Ext.get(this.el.dom.childNodes[1].firstChild);
- this.innerHd = Ext.get(this.el.dom.firstChild.firstChild);
- if(this.hideHeaders){
- this.el.dom.firstChild.style.display = 'none';
- }
- },
- getTemplateTarget : function(){
- return this.innerBody;
- },
- collectData : function(){
- var rs = Ext.list.ListView.superclass.collectData.apply(this, arguments);
- return {
- columns: this.columns,
- rows: rs
- }
- },
- verifyInternalSize : function(){
- if(this.lastSize){
- this.onResize(this.lastSize.width, this.lastSize.height);
- }
- },
- onResize : function(w, h){
- var bd = this.innerBody.dom;
- var hd = this.innerHd.dom
- if(!bd){
- return;
- }
- var bdp = bd.parentNode;
- if(Ext.isNumber(w)){
- var sw = w - Ext.num(this.scrollOffset, Ext.getScrollBarWidth());
- if(this.reserveScrollOffset || ((bdp.offsetWidth - bdp.clientWidth) > 10)){
- bd.style.width = sw + 'px';
- hd.style.width = sw + 'px';
- }else{
- bd.style.width = w + 'px';
- hd.style.width = w + 'px';
- setTimeout(function(){
- if((bdp.offsetWidth - bdp.clientWidth) > 10){
- bd.style.width = sw + 'px';
- hd.style.width = sw + 'px';
- }
- }, 10);
- }
- }
- if(Ext.isNumber(h)){
- bdp.style.height = (h - hd.parentNode.offsetHeight) + 'px';
- }
- },
- updateIndexes : function(){
- Ext.list.ListView.superclass.updateIndexes.apply(this, arguments);
- this.verifyInternalSize();
- },
- findHeaderIndex : function(hd){
- hd = hd.dom || hd;
- var pn = hd.parentNode, cs = pn.parentNode.childNodes;
- for(var i = 0, c; c = cs[i]; i++){
- if(c == pn){
- return i;
- }
- }
- return -1;
- },
- setHdWidths : function(){
- var els = this.innerHd.dom.getElementsByTagName('div');
- for(var i = 0, cs = this.columns, len = cs.length; i < len; i++){
- els[i].style.width = (cs[i].width*100) + '%';
- }
- }
- });
- Ext.reg('listview', Ext.list.ListView);
- Ext.ListView = Ext.list.ListView;
- Ext.list.Column = Ext.extend(Object, {
- isColumn: true,
- align: 'left',
- header: '',
- width: null,
- cls: '',
- constructor : function(c){
- if(!c.tpl){
- c.tpl = new Ext.XTemplate('{' + c.dataIndex + '}');
- }
- else if(Ext.isString(c.tpl)){
- c.tpl = new Ext.XTemplate(c.tpl);
- }
- Ext.apply(this, c);
- }
- });
- Ext.reg('lvcolumn', Ext.list.Column);
- Ext.list.NumberColumn = Ext.extend(Ext.list.Column, {
- format: '0,000.00',
- constructor : function(c) {
- c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':number("' + (c.format || this.format) + '")}');
- Ext.list.NumberColumn.superclass.constructor.call(this, c);
- }
- });
- Ext.reg('lvnumbercolumn', Ext.list.NumberColumn);
- Ext.list.DateColumn = Ext.extend(Ext.list.Column, {
- format: 'm/d/Y',
- constructor : function(c) {
- c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':date("' + (c.format || this.format) + '")}');
- Ext.list.DateColumn.superclass.constructor.call(this, c);
- }
- });
- Ext.reg('lvdatecolumn', Ext.list.DateColumn);
- Ext.list.BooleanColumn = Ext.extend(Ext.list.Column, {
- trueText: 'true',
- falseText: 'false',
- undefinedText: ' ',
- constructor : function(c) {
- c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':this.format}');
- var t = this.trueText, f = this.falseText, u = this.undefinedText;
- c.tpl.format = function(v){
- if(v === undefined){
- return u;
- }
- if(!v || v === 'false'){
- return f;
- }
- return t;
- };
- Ext.list.DateColumn.superclass.constructor.call(this, c);
- }
- });
- Ext.reg('lvbooleancolumn', Ext.list.BooleanColumn);
- Ext.list.ColumnResizer = Ext.extend(Ext.util.Observable, {
- minPct: .05,
- constructor: function(config){
- Ext.apply(this, config);
- Ext.list.ColumnResizer.superclass.constructor.call(this);
- },
- init : function(listView){
- this.view = listView;
- listView.on('render', this.initEvents, this);
- },
- initEvents : function(view){
- view.mon(view.innerHd, 'mousemove', this.handleHdMove, this);
- this.tracker = new Ext.dd.DragTracker({
- onBeforeStart: this.onBeforeStart.createDelegate(this),
- onStart: this.onStart.createDelegate(this),
- onDrag: this.onDrag.createDelegate(this),
- onEnd: this.onEnd.createDelegate(this),
- tolerance: 3,
- autoStart: 300
- });
- this.tracker.initEl(view.innerHd);
- view.on('beforedestroy', this.tracker.destroy, this.tracker);
- },
- handleHdMove : function(e, t){
- var hw = 5,
- x = e.getPageX(),
- hd = e.getTarget('em', 3, true);
- if(hd){
- var r = hd.getRegion(),
- ss = hd.dom.style,
- pn = hd.dom.parentNode;
- if(x - r.left <= hw && pn != pn.parentNode.firstChild){
- this.activeHd = Ext.get(pn.previousSibling.firstChild);
- ss.cursor = Ext.isWebKit ? 'e-resize' : 'col-resize';
- } else if(r.right - x <= hw && pn != pn.parentNode.lastChild.previousSibling){
- this.activeHd = hd;
- ss.cursor = Ext.isWebKit ? 'w-resize' : 'col-resize';
- } else{
- delete this.activeHd;
- ss.cursor = '';
- }
- }
- },
- onBeforeStart : function(e){
- this.dragHd = this.activeHd;
- return !!this.dragHd;
- },
- onStart: function(e){
- this.view.disableHeaders = true;
- this.proxy = this.view.el.createChild({cls:'x-list-resizer'});
- this.proxy.setHeight(this.view.el.getHeight());
- var x = this.tracker.getXY()[0],
- w = this.view.innerHd.getWidth();
- this.hdX = this.dragHd.getX();
- this.hdIndex = this.view.findHeaderIndex(this.dragHd);
- this.proxy.setX(this.hdX);
- this.proxy.setWidth(x-this.hdX);
- this.minWidth = w*this.minPct;
- this.maxWidth = w - (this.minWidth*(this.view.columns.length-1-this.hdIndex));
- },
- onDrag: function(e){
- var cursorX = this.tracker.getXY()[0];
- this.proxy.setWidth((cursorX-this.hdX).constrain(this.minWidth, this.maxWidth));
- },
- onEnd: function(e){
- var nw = this.proxy.getWidth();
- this.proxy.remove();
- var index = this.hdIndex,
- vw = this.view,
- cs = vw.columns,
- len = cs.length,
- w = this.view.innerHd.getWidth(),
- minPct = this.minPct * 100,
- pct = Math.ceil((nw * vw.maxWidth) / w),
- diff = (cs[index].width * 100) - pct,
- each = Math.floor(diff / (len-1-index)),
- mod = diff - (each * (len-1-index));
- for(var i = index+1; i < len; i++){
- var cw = (cs[i].width * 100) + each,
- ncw = Math.max(minPct, cw);
- if(cw != ncw){
- mod += cw - ncw;
- }
- cs[i].width = ncw / 100;
- }
- cs[index].width = pct / 100;
- cs[index+1].width += (mod / 100);
- delete this.dragHd;
- vw.setHdWidths();
- vw.refresh();
- setTimeout(function(){
- vw.disableHeaders = false;
- }, 100);
- }
- });
- Ext.ListView.ColumnResizer = Ext.list.ColumnResizer;
- Ext.list.Sorter = Ext.extend(Ext.util.Observable, {
- sortClasses : ["sort-asc", "sort-desc"],
- constructor: function(config){
- Ext.apply(this, config);
- Ext.list.Sorter.superclass.constructor.call(this);
- },
- init : function(listView){
- this.view = listView;
- listView.on('render', this.initEvents, this);
- },
- initEvents : function(view){
- view.mon(view.innerHd, 'click', this.onHdClick, this);
- view.innerHd.setStyle('cursor', 'pointer');
- view.mon(view.store, 'datachanged', this.updateSortState, this);
- this.updateSortState.defer(10, this, [view.store]);
- },
- updateSortState : function(store){
- var state = store.getSortState();
- if(!state){
- return;
- }
- this.sortState = state;
- var cs = this.view.columns, sortColumn = -1;
- for(var i = 0, len = cs.length; i < len; i++){
- if(cs[i].dataIndex == state.field){
- sortColumn = i;
- break;
- }
- }
- if(sortColumn != -1){
- var sortDir = state.direction;
- this.updateSortIcon(sortColumn, sortDir);
- }
- },
- updateSortIcon : function(col, dir){
- var sc = this.sortClasses;
- var hds = this.view.innerHd.select('em').removeClass(sc);
- hds.item(col).addClass(sc[dir == "DESC" ? 1 : 0]);
- },
- onHdClick : function(e){
- var hd = e.getTarget('em', 3);
- if(hd && !this.view.disableHeaders){
- var index = this.view.findHeaderIndex(hd);
- this.view.store.sort(this.view.columns[index].dataIndex);
- }
- }
- });
- Ext.ListView.Sorter = Ext.list.Sorter;
- Ext.TabPanel = Ext.extend(Ext.Panel, {
- monitorResize : true,
- deferredRender : true,
- tabWidth : 120,
- minTabWidth : 30,
- resizeTabs : false,
- enableTabScroll : false,
- scrollIncrement : 0,
- scrollRepeatInterval : 400,
- scrollDuration : 0.35,
- animScroll : true,
- tabPosition : 'top',
- baseCls : 'x-tab-panel',
- autoTabs : false,
- autoTabSelector : 'div.x-tab',
- activeTab : undefined,
- tabMargin : 2,
- plain : false,
- wheelIncrement : 20,
- idDelimiter : '__',
- itemCls : 'x-tab-item',
- elements : 'body',
- headerAsText : false,
- frame : false,
- hideBorders :true,
- initComponent : function(){
- this.frame = false;
- Ext.TabPanel.superclass.initComponent.call(this);
- this.addEvents(
- 'beforetabchange',
- 'tabchange',
- 'contextmenu'
- );
- this.setLayout(new Ext.layout.CardLayout(Ext.apply({
- layoutOnCardChange: this.layoutOnTabChange,
- deferredRender: this.deferredRender
- }, this.layoutConfig)));
- if(this.tabPosition == 'top'){
- this.elements += ',header';
- this.stripTarget = 'header';
- }else {
- this.elements += ',footer';
- this.stripTarget = 'footer';
- }
- if(!this.stack){
- this.stack = Ext.TabPanel.AccessStack();
- }
- this.initItems();
- },
- onRender : function(ct, position){
- Ext.TabPanel.superclass.onRender.call(this, ct, position);
- if(this.plain){
- var pos = this.tabPosition == 'top' ? 'header' : 'footer';
- this[pos].addClass('x-tab-panel-'+pos+'-plain');
- }
- var st = this[this.stripTarget];
- this.stripWrap = st.createChild({cls:'x-tab-strip-wrap', cn:{
- tag:'ul', cls:'x-tab-strip x-tab-strip-'+this.tabPosition}});
- var beforeEl = (this.tabPosition=='bottom' ? this.stripWrap : null);
- st.createChild({cls:'x-tab-strip-spacer'}, beforeEl);
- this.strip = new Ext.Element(this.stripWrap.dom.firstChild);
- this.edge = this.strip.createChild({tag:'li', cls:'x-tab-edge', cn: [{tag: 'span', cls: 'x-tab-strip-text', cn: ' '}]});
- this.strip.createChild({cls:'x-clear'});
- this.body.addClass('x-tab-panel-body-'+this.tabPosition);
- if(!this.itemTpl){
- var tt = new Ext.Template(
- '<li class="{cls}" id="{id}"><a class="x-tab-strip-close"></a>',
- '<a class="x-tab-right" href="#"><em class="x-tab-left">',
- '<span class="x-tab-strip-inner"><span class="x-tab-strip-text {iconCls}">{text}</span></span>',
- '</em></a></li>'
- );
- tt.disableFormats = true;
- tt.compile();
- Ext.TabPanel.prototype.itemTpl = tt;
- }
- this.items.each(this.initTab, this);
- },
- afterRender : function(){
- Ext.TabPanel.superclass.afterRender.call(this);
- if(this.autoTabs){
- this.readTabs(false);
- }
- if(this.activeTab !== undefined){
- var item = Ext.isObject(this.activeTab) ? this.activeTab : this.items.get(this.activeTab);
- delete this.activeTab;
- this.setActiveTab(item);
- }
- },
- initEvents : function(){
- Ext.TabPanel.superclass.initEvents.call(this);
- this.mon(this.strip, {
- scope: this,
- mousedown: this.onStripMouseDown,
- contextmenu: this.onStripContextMenu
- });
- if(this.enableTabScroll){
- this.mon(this.strip, 'mousewheel', this.onWheel, this);
- }
- },
- findTargets : function(e){
- var item = null;
- var itemEl = e.getTarget('li', this.strip);
- if(itemEl){
- item = this.getComponent(itemEl.id.split(this.idDelimiter)[1]);
- if(item.disabled){
- return {
- close : null,
- item : null,
- el : null
- };
- }
- }
- return {
- close : e.getTarget('.x-tab-strip-close', this.strip),
- item : item,
- el : itemEl
- };
- },
- onStripMouseDown : function(e){
- if(e.button !== 0){
- return;
- }
- e.preventDefault();
- var t = this.findTargets(e);
- if(t.close){
- if (t.item.fireEvent('beforeclose', t.item) !== false) {
- t.item.fireEvent('close', t.item);
- this.remove(t.item);
- }
- return;
- }
- if(t.item && t.item != this.activeTab){
- this.setActiveTab(t.item);
- }
- },
- onStripContextMenu : function(e){
- e.preventDefault();
- var t = this.findTargets(e);
- if(t.item){
- this.fireEvent('contextmenu', this, t.item, e);
- }
- },
- readTabs : function(removeExisting){
- if(removeExisting === true){
- this.items.each(function(item){
- this.remove(item);
- }, this);
- }
- var tabs = this.el.query(this.autoTabSelector);
- for(var i = 0, len = tabs.length; i < len; i++){
- var tab = tabs[i],
- title = tab.getAttribute('title');
- tab.removeAttribute('title');
- this.add({
- title: title,
- contentEl: tab
- });
- }
- },
- initTab : function(item, index){
- var before = this.strip.dom.childNodes[index],
- p = this.getTemplateArgs(item),
- el = before ?
- this.itemTpl.insertBefore(before, p) :
- this.itemTpl.append(this.strip, p),
- cls = 'x-tab-strip-over',
- tabEl = Ext.get(el);
- tabEl.hover(function(){
- if(!item.disabled){
- tabEl.addClass(cls);
- }
- }, function(){
- tabEl.removeClass(cls);
- });
- if(item.tabTip){
- tabEl.child('span.x-tab-strip-text', true).qtip = item.tabTip;
- }
- item.tabEl = el;
- tabEl.select('a').on('click', function(e){
- if(!e.getPageX()){
- this.onStripMouseDown(e);
- }
- }, this, {preventDefault: true});
- item.on({
- scope: this,
- disable: this.onItemDisabled,
- enable: this.onItemEnabled,
- titlechange: this.onItemTitleChanged,
- iconchange: this.onItemIconChanged,
- beforeshow: this.onBeforeShowItem
- });
- },
- getTemplateArgs : function(item) {
- var cls = item.closable ? 'x-tab-strip-closable' : '';
- if(item.disabled){
- cls += ' x-item-disabled';
- }
- if(item.iconCls){
- cls += ' x-tab-with-icon';
- }
- if(item.tabCls){
- cls += ' ' + item.tabCls;
- }
- return {
- id: this.id + this.idDelimiter + item.getItemId(),
- text: item.title,
- cls: cls,
- iconCls: item.iconCls || ''
- };
- },
- onAdd : function(c){
- Ext.TabPanel.superclass.onAdd.call(this, c);
- if(this.rendered){
- var items = this.items;
- this.initTab(c, items.indexOf(c));
- if(items.getCount() == 1){
- this.syncSize();
- }
- this.delegateUpdates();
- }
- },
- onBeforeAdd : function(item){
- var existing = item.events ? (this.items.containsKey(item.getItemId()) ? item : null) : this.items.get(item);
- if(existing){
- this.setActiveTab(item);
- return false;
- }
- Ext.TabPanel.superclass.onBeforeAdd.apply(this, arguments);
- var es = item.elements;
- item.elements = es ? es.replace(',header', '') : es;
- item.border = (item.border === true);
- },
- onRemove : function(c){
- var te = Ext.get(c.tabEl);
- if(te){
- te.select('a').removeAllListeners();
- Ext.destroy(te);
- }
- Ext.TabPanel.superclass.onRemove.call(this, c);
- this.stack.remove(c);
- delete c.tabEl;
- c.un('disable', this.onItemDisabled, this);
- c.un('enable', this.onItemEnabled, this);
- c.un('titlechange', this.onItemTitleChanged, this);
- c.un('iconchange', this.onItemIconChanged, this);
- c.un('beforeshow', this.onBeforeShowItem, this);
- if(c == this.activeTab){
- var next = this.stack.next();
- if(next){
- this.setActiveTab(next);
- }else if(this.items.getCount() > 0){
- this.setActiveTab(0);
- }else{
- this.setActiveTab(null);
- }
- }
- if(!this.destroying){
- this.delegateUpdates();
- }
- },
- onBeforeShowItem : function(item){
- if(item != this.activeTab){
- this.setActiveTab(item);
- return false;
- }
- },
- onItemDisabled : function(item){
- var el = this.getTabEl(item);
- if(el){
- Ext.fly(el).addClass('x-item-disabled');
- }
- this.stack.remove(item);
- },
- onItemEnabled : function(item){
- var el = this.getTabEl(item);
- if(el){
- Ext.fly(el).removeClass('x-item-disabled');
- }
- },
- onItemTitleChanged : function(item){
- var el = this.getTabEl(item);
- if(el){
- Ext.fly(el).child('span.x-tab-strip-text', true).innerHTML = item.title;
- }
- },
- onItemIconChanged : function(item, iconCls, oldCls){
- var el = this.getTabEl(item);
- if(el){
- el = Ext.get(el);
- el.child('span.x-tab-strip-text').replaceClass(oldCls, iconCls);
- el[Ext.isEmpty(iconCls) ? 'removeClass' : 'addClass']('x-tab-with-icon');
- }
- },
- getTabEl : function(item){
- var c = this.getComponent(item);
- return c ? c.tabEl : null;
- },
- onResize : function(){
- Ext.TabPanel.superclass.onResize.apply(this, arguments);
- this.delegateUpdates();
- },
- beginUpdate : function(){
- this.suspendUpdates = true;
- },
- endUpdate : function(){
- this.suspendUpdates = false;
- this.delegateUpdates();
- },
- hideTabStripItem : function(item){
- item = this.getComponent(item);
- var el = this.getTabEl(item);
- if(el){
- el.style.display = 'none';
- this.delegateUpdates();
- }
- this.stack.remove(item);
- },
- unhideTabStripItem : function(item){
- item = this.getComponent(item);
- var el = this.getTabEl(item);
- if(el){
- el.style.display = '';
- this.delegateUpdates();
- }
- },
- delegateUpdates : function(){
- if(this.suspendUpdates){
- return;
- }
- if(this.resizeTabs && this.rendered){
- this.autoSizeTabs();
- }
- if(this.enableTabScroll && this.rendered){
- this.autoScrollTabs();
- }
- },
- autoSizeTabs : function(){
- var count = this.items.length,
- ce = this.tabPosition != 'bottom' ? 'header' : 'footer',
- ow = this[ce].dom.offsetWidth,
- aw = this[ce].dom.clientWidth;
- if(!this.resizeTabs || count < 1 || !aw){
- return;
- }
- var each = Math.max(Math.min(Math.floor((aw-4) / count) - this.tabMargin, this.tabWidth), this.minTabWidth);
- this.lastTabWidth = each;
- var lis = this.strip.query("li:not([className^=x-tab-edge])");
- for(var i = 0, len = lis.length; i < len; i++) {
- var li = lis[i],
- inner = Ext.fly(li).child('.x-tab-strip-inner', true),
- tw = li.offsetWidth,
- iw = inner.offsetWidth;
- inner.style.width = (each - (tw-iw)) + 'px';
- }
- },
- adjustBodyWidth : function(w){
- if(this.header){
- this.header.setWidth(w);
- }
- if(this.footer){
- this.footer.setWidth(w);
- }
- return w;
- },
- setActiveTab : function(item){
- item = this.getComponent(item);
- if(this.fireEvent('beforetabchange', this, item, this.activeTab) === false){
- return;
- }
- if(!this.rendered){
- this.activeTab = item;
- return;
- }
- if(this.activeTab != item){
- if(this.activeTab){
- var oldEl = this.getTabEl(this.activeTab);
- if(oldEl){
- Ext.fly(oldEl).removeClass('x-tab-strip-active');
- }
- }
- if(item){
- var el = this.getTabEl(item);
- Ext.fly(el).addClass('x-tab-strip-active');
- this.activeTab = item;
- this.stack.add(item);
- this.layout.setActiveItem(item);
- if(this.scrolling){
- this.scrollToTab(item, this.animScroll);
- }
- }
- this.fireEvent('tabchange', this, item);
- }
- },
- getActiveTab : function(){
- return this.activeTab || null;
- },
- getItem : function(item){
- return this.getComponent(item);
- },
- autoScrollTabs : function(){
- this.pos = this.tabPosition=='bottom' ? this.footer : this.header;
- var count = this.items.length,
- ow = this.pos.dom.offsetWidth,
- tw = this.pos.dom.clientWidth,
- wrap = this.stripWrap,
- wd = wrap.dom,
- cw = wd.offsetWidth,
- pos = this.getScrollPos(),
- l = this.edge.getOffsetsTo(this.stripWrap)[0] + pos;
- if(!this.enableTabScroll || count < 1 || cw < 20){
- return;
- }
- if(l <= tw){
- wd.scrollLeft = 0;
- wrap.setWidth(tw);
- if(this.scrolling){
- this.scrolling = false;
- this.pos.removeClass('x-tab-scrolling');
- this.scrollLeft.hide();
- this.scrollRight.hide();
- if(Ext.isAir || Ext.isWebKit){
- wd.style.marginLeft = '';
- wd.style.marginRight = '';
- }
- }
- }else{
- if(!this.scrolling){
- this.pos.addClass('x-tab-scrolling');
- if(Ext.isAir || Ext.isWebKit){
- wd.style.marginLeft = '18px';
- wd.style.marginRight = '18px';
- }
- }
- tw -= wrap.getMargins('lr');
- wrap.setWidth(tw > 20 ? tw : 20);
- if(!this.scrolling){
- if(!this.scrollLeft){
- this.createScrollers();
- }else{
- this.scrollLeft.show();
- this.scrollRight.show();
- }
- }
- this.scrolling = true;
- if(pos > (l-tw)){
- wd.scrollLeft = l-tw;
- }else{
- this.scrollToTab(this.activeTab, false);
- }
- this.updateScrollButtons();
- }
- },
- createScrollers : function(){
- this.pos.addClass('x-tab-scrolling-' + this.tabPosition);
- var h = this.stripWrap.dom.offsetHeight;
- var sl = this.pos.insertFirst({
- cls:'x-tab-scroller-left'
- });
- sl.setHeight(h);
- sl.addClassOnOver('x-tab-scroller-left-over');
- this.leftRepeater = new Ext.util.ClickRepeater(sl, {
- interval : this.scrollRepeatInterval,
- handler: this.onScrollLeft,
- scope: this
- });
- this.scrollLeft = sl;
- var sr = this.pos.insertFirst({
- cls:'x-tab-scroller-right'
- });
- sr.setHeight(h);
- sr.addClassOnOver('x-tab-scroller-right-over');
- this.rightRepeater = new Ext.util.ClickRepeater(sr, {
- interval : this.scrollRepeatInterval,
- handler: this.onScrollRight,
- scope: this
- });
- this.scrollRight = sr;
- },
- getScrollWidth : function(){
- return this.edge.getOffsetsTo(this.stripWrap)[0] + this.getScrollPos();
- },
- getScrollPos : function(){
- return parseInt(this.stripWrap.dom.scrollLeft, 10) || 0;
- },
- getScrollArea : function(){
- return parseInt(this.stripWrap.dom.clientWidth, 10) || 0;
- },
- getScrollAnim : function(){
- return {duration:this.scrollDuration, callback: this.updateScrollButtons, scope: this};
- },
- getScrollIncrement : function(){
- return this.scrollIncrement || (this.resizeTabs ? this.lastTabWidth+2 : 100);
- },
- scrollToTab : function(item, animate){
- if(!item){
- return;
- }
- var el = this.getTabEl(item),
- pos = this.getScrollPos(),
- area = this.getScrollArea(),
- left = Ext.fly(el).getOffsetsTo(this.stripWrap)[0] + pos,
- right = left + el.offsetWidth;
- if(left < pos){
- this.scrollTo(left, animate);
- }else if(right > (pos + area)){
- this.scrollTo(right - area, animate);
- }
- },
- scrollTo : function(pos, animate){
- this.stripWrap.scrollTo('left', pos, animate ? this.getScrollAnim() : false);
- if(!animate){
- this.updateScrollButtons();
- }
- },
- onWheel : function(e){
- var d = e.getWheelDelta()*this.wheelIncrement*-1;
- e.stopEvent();
- var pos = this.getScrollPos(),
- newpos = pos + d,
- sw = this.getScrollWidth()-this.getScrollArea();
- var s = Math.max(0, Math.min(sw, newpos));
- if(s != pos){
- this.scrollTo(s, false);
- }
- },
- onScrollRight : function(){
- var sw = this.getScrollWidth()-this.getScrollArea(),
- pos = this.getScrollPos(),
- s = Math.min(sw, pos + this.getScrollIncrement());
- if(s != pos){
- this.scrollTo(s, this.animScroll);
- }
- },
- onScrollLeft : function(){
- var pos = this.getScrollPos(),
- s = Math.max(0, pos - this.getScrollIncrement());
- if(s != pos){
- this.scrollTo(s, this.animScroll);
- }
- },
- updateScrollButtons : function(){
- var pos = this.getScrollPos();
- this.scrollLeft[pos === 0 ? 'addClass' : 'removeClass']('x-tab-scroller-left-disabled');
- this.scrollRight[pos >= (this.getScrollWidth()-this.getScrollArea()) ? 'addClass' : 'removeClass']('x-tab-scroller-right-disabled');
- },
- beforeDestroy : function() {
- Ext.destroy(this.leftRepeater, this.rightRepeater);
- this.deleteMembers('strip', 'edge', 'scrollLeft', 'scrollRight', 'stripWrap');
- this.activeTab = null;
- Ext.TabPanel.superclass.beforeDestroy.apply(this);
- }
- });
- Ext.reg('tabpanel', Ext.TabPanel);
- Ext.TabPanel.prototype.activate = Ext.TabPanel.prototype.setActiveTab;
- Ext.TabPanel.AccessStack = function(){
- var items = [];
- return {
- add : function(item){
- items.push(item);
- if(items.length > 10){
- items.shift();
- }
- },
- remove : function(item){
- var s = [];
- for(var i = 0, len = items.length; i < len; i++) {
- if(items[i] != item){
- s.push(items[i]);
- }
- }
- items = s;
- },
- next : function(){
- return items.pop();
- }
- };
- };
- Ext.Button = Ext.extend(Ext.BoxComponent, {
- hidden : false,
- disabled : false,
- pressed : false,
- enableToggle : false,
- menuAlign : 'tl-bl?',
- type : 'button',
- menuClassTarget : 'tr:nth(2)',
- clickEvent : 'click',
- handleMouseEvents : true,
- tooltipType : 'qtip',
- buttonSelector : 'button:first-child',
- scale : 'small',
- iconAlign : 'left',
- arrowAlign : 'right',
- initComponent : function(){
- Ext.Button.superclass.initComponent.call(this);
- this.addEvents(
- 'click',
- 'toggle',
- 'mouseover',
- 'mouseout',
- 'menushow',
- 'menuhide',
- 'menutriggerover',
- 'menutriggerout'
- );
- if(this.menu){
- this.menu = Ext.menu.MenuMgr.get(this.menu);
- }
- if(Ext.isString(this.toggleGroup)){
- this.enableToggle = true;
- }
- },
- getTemplateArgs : function(){
- return [this.type, 'x-btn-' + this.scale + ' x-btn-icon-' + this.scale + '-' + this.iconAlign, this.getMenuClass(), this.cls, this.id];
- },
- setButtonClass : function(){
- if(this.useSetClass){
- if(!Ext.isEmpty(this.oldCls)){
- this.el.removeClass([this.oldCls, 'x-btn-pressed']);
- }
- this.oldCls = (this.iconCls || this.icon) ? (this.text ? ' x-btn-text-icon' : ' x-btn-icon') : ' x-btn-noicon';
- this.el.addClass([this.oldCls, this.pressed ? 'x-btn-pressed' : null]);
- }
- },
- getMenuClass : function(){
- return this.menu ? (this.arrowAlign != 'bottom' ? 'x-btn-arrow' : 'x-btn-arrow-bottom') : '';
- },
- onRender : function(ct, position){
- if(!this.template){
- if(!Ext.Button.buttonTemplate){
- Ext.Button.buttonTemplate = new Ext.Template(
- '<table id="{4}" cellspacing="0" class="x-btn {3}"><tbody class="{1}">',
- '<tr><td class="x-btn-tl"><i> </i></td><td class="x-btn-tc"></td><td class="x-btn-tr"><i> </i></td></tr>',
- '<tr><td class="x-btn-ml"><i> </i></td><td class="x-btn-mc"><em class="{2}" unselectable="on"><button type="{0}"></button></em></td><td class="x-btn-mr"><i> </i></td></tr>',
- '<tr><td class="x-btn-bl"><i> </i></td><td class="x-btn-bc"></td><td class="x-btn-br"><i> </i></td></tr>',
- '</tbody></table>');
- Ext.Button.buttonTemplate.compile();
- }
- this.template = Ext.Button.buttonTemplate;
- }
- var btn, targs = this.getTemplateArgs();
- if(position){
- btn = this.template.insertBefore(position, targs, true);
- }else{
- btn = this.template.append(ct, targs, true);
- }
- this.btnEl = btn.child(this.buttonSelector);
- this.mon(this.btnEl, {
- scope: this,
- focus: this.onFocus,
- blur: this.onBlur
- });
- this.initButtonEl(btn, this.btnEl);
- Ext.ButtonToggleMgr.register(this);
- },
- initButtonEl : function(btn, btnEl){
- this.el = btn;
- this.setIcon(this.icon);
- this.setText(this.text);
- this.setIconClass(this.iconCls);
- if(Ext.isDefined(this.tabIndex)){
- btnEl.dom.tabIndex = this.tabIndex;
- }
- if(this.tooltip){
- this.setTooltip(this.tooltip, true);
- }
- if(this.handleMouseEvents){
- this.mon(btn, {
- scope: this,
- mouseover: this.onMouseOver,
- mousedown: this.onMouseDown
- });
- }
- if(this.menu){
- this.mon(this.menu, {
- scope: this,
- show: this.onMenuShow,
- hide: this.onMenuHide
- });
- }
- if(this.repeat){
- var repeater = new Ext.util.ClickRepeater(btn, Ext.isObject(this.repeat) ? this.repeat : {});
- this.mon(repeater, 'click', this.onClick, this);
- }
- this.mon(btn, this.clickEvent, this.onClick, this);
- },
- afterRender : function(){
- Ext.Button.superclass.afterRender.call(this);
- this.useSetClass = true;
- this.setButtonClass();
- this.doc = Ext.getDoc();
- this.doAutoWidth();
- },
- setIconClass : function(cls){
- this.iconCls = cls;
- if(this.el){
- this.btnEl.dom.className = '';
- this.btnEl.addClass(['x-btn-text', cls || '']);
- this.setButtonClass();
- }
- return this;
- },
- setTooltip : function(tooltip, initial){
- if(this.rendered){
- if(!initial){
- this.clearTip();
- }
- if(Ext.isObject(tooltip)){
- Ext.QuickTips.register(Ext.apply({
- target: this.btnEl.id
- }, tooltip));
- this.tooltip = tooltip;
- }else{
- this.btnEl.dom[this.tooltipType] = tooltip;
- }
- }else{
- this.tooltip = tooltip;
- }
- return this;
- },
- clearTip : function(){
- if(Ext.isObject(this.tooltip)){
- Ext.QuickTips.unregister(this.btnEl);
- }
- },
- beforeDestroy : function(){
- if(this.rendered){
- this.clearTip();
- }
- if(this.menu && this.menu.autoDestroy) {
- Ext.destroy(this.menu);
- }
- Ext.destroy(this.repeater);
- },
- onDestroy : function(){
- if(this.rendered){
- this.doc.un('mouseover', this.monitorMouseOver, this);
- this.doc.un('mouseup', this.onMouseUp, this);
- delete this.doc;
- delete this.btnEl;
- Ext.ButtonToggleMgr.unregister(this);
- }
- },