ext-all-debug.js
资源名称:EXT_study.rar [点击查看]
上传用户:zaktkj
上传日期:2022-08-08
资源大小:5770k
文件大小:910k
源码类别:
JavaScript
开发平台:
JavaScript
- el.afterFx(o);
- };
- var a, zero = {to: 0};
- switch(anchor.toLowerCase()){
- case "t":
- st.left = st.bottom = "0";
- a = {height: zero};
- break;
- case "l":
- st.right = st.top = "0";
- a = {width: zero};
- break;
- case "r":
- st.left = st.top = "0";
- a = {width: zero, points: {to:[b.right, b.y]}};
- break;
- case "b":
- st.left = st.top = "0";
- a = {height: zero, points: {to:[b.x, b.bottom]}};
- break;
- case "tl":
- st.right = st.bottom = "0";
- a = {width: zero, height: zero};
- break;
- case "bl":
- st.right = st.top = "0";
- a = {width: zero, height: zero, points: {to:[b.x, b.bottom]}};
- break;
- case "br":
- st.left = st.top = "0";
- a = {width: zero, height: zero, points: {to:[b.x+b.width, b.bottom]}};
- break;
- case "tr":
- st.left = st.bottom = "0";
- a = {width: zero, height: zero, points: {to:[b.right, b.y]}};
- break;
- }
- arguments.callee.anim = wrap.fxanim(a,
- o,
- 'motion',
- .5,
- "easeOut", after);
- });
- return this;
- },
- puff : function(o){
- var el = this.getFxEl();
- o = o || {};
- el.queueFx(o, function(){
- this.clearOpacity();
- this.show();
- var r = this.getFxRestore();
- var st = this.dom.style;
- var after = function(){
- if(o.useDisplay){
- el.setDisplayed(false);
- }else{
- el.hide();
- }
- el.clearOpacity();
- el.setPositioning(r.pos);
- st.width = r.width;
- st.height = r.height;
- st.fontSize = '';
- el.afterFx(o);
- };
- var width = this.getWidth();
- var height = this.getHeight();
- arguments.callee.anim = this.fxanim({
- width : {to: this.adjustWidth(width * 2)},
- height : {to: this.adjustHeight(height * 2)},
- points : {by: [-(width * .5), -(height * .5)]},
- opacity : {to: 0},
- fontSize: {to:200, unit: "%"}
- },
- o,
- 'motion',
- .5,
- "easeOut", after);
- });
- return this;
- },
- switchOff : function(o){
- var el = this.getFxEl();
- o = o || {};
- el.queueFx(o, function(){
- this.clearOpacity();
- this.clip();
- var r = this.getFxRestore();
- var st = this.dom.style;
- var after = function(){
- if(o.useDisplay){
- el.setDisplayed(false);
- }else{
- el.hide();
- }
- el.clearOpacity();
- el.setPositioning(r.pos);
- st.width = r.width;
- st.height = r.height;
- el.afterFx(o);
- };
- this.fxanim({opacity:{to:0.3}}, null, null, .1, null, function(){
- this.clearOpacity();
- (function(){
- this.fxanim({
- height:{to:1},
- points:{by:[0, this.getHeight() * .5]}
- }, o, 'motion', 0.3, 'easeIn', after);
- }).defer(100, this);
- });
- });
- return this;
- },
- highlight : function(color, o){
- var el = this.getFxEl();
- o = o || {};
- el.queueFx(o, function(){
- color = color || "ffff9c";
- var attr = o.attr || "backgroundColor";
- this.clearOpacity();
- this.show();
- var origColor = this.getColor(attr);
- var restoreColor = this.dom.style[attr];
- var endColor = (o.endColor || origColor) || "ffffff";
- var after = function(){
- el.dom.style[attr] = restoreColor;
- el.afterFx(o);
- };
- var a = {};
- a[attr] = {from: color, to: endColor};
- arguments.callee.anim = this.fxanim(a,
- o,
- 'color',
- 1,
- 'easeIn', after);
- });
- return this;
- },
- frame : function(color, count, o){
- var el = this.getFxEl();
- o = o || {};
- el.queueFx(o, function(){
- color = color || "#C3DAF9";
- if(color.length == 6){
- color = "#" + color;
- }
- count = count || 1;
- var duration = o.duration || 1;
- this.show();
- var b = this.getBox();
- var animFn = function(){
- var proxy = Ext.getBody().createChild({
- style:{
- visbility:"hidden",
- position:"absolute",
- "z-index":"35000", border:"0px solid " + color
- }
- });
- var scale = Ext.isBorderBox ? 2 : 1;
- proxy.animate({
- top:{from:b.y, to:b.y - 20},
- left:{from:b.x, to:b.x - 20},
- borderWidth:{from:0, to:10},
- opacity:{from:1, to:0},
- height:{from:b.height, to:(b.height + (20*scale))},
- width:{from:b.width, to:(b.width + (20*scale))}
- }, duration, function(){
- proxy.remove();
- if(--count > 0){
- animFn();
- }else{
- el.afterFx(o);
- }
- });
- };
- animFn.call(this);
- });
- return this;
- },
- pause : function(seconds){
- var el = this.getFxEl();
- var o = {};
- el.queueFx(o, function(){
- setTimeout(function(){
- el.afterFx(o);
- }, seconds * 1000);
- });
- return this;
- },
- fadeIn : function(o){
- var el = this.getFxEl();
- o = o || {};
- el.queueFx(o, function(){
- this.setOpacity(0);
- this.fixDisplay();
- this.dom.style.visibility = 'visible';
- var to = o.endOpacity || 1;
- arguments.callee.anim = this.fxanim({opacity:{to:to}},
- o, null, .5, "easeOut", function(){
- if(to == 1){
- this.clearOpacity();
- }
- el.afterFx(o);
- });
- });
- return this;
- },
- fadeOut : function(o){
- var el = this.getFxEl();
- o = o || {};
- el.queueFx(o, function(){
- arguments.callee.anim = this.fxanim({opacity:{to:o.endOpacity || 0}},
- o, null, .5, "easeOut", function(){
- if(this.visibilityMode == Ext.Element.DISPLAY || o.useDisplay){
- this.dom.style.display = "none";
- }else{
- this.dom.style.visibility = "hidden";
- }
- this.clearOpacity();
- el.afterFx(o);
- });
- });
- return this;
- },
- scale : function(w, h, o){
- this.shift(Ext.apply({}, o, {
- width: w,
- height: h
- }));
- return this;
- },
- shift : function(o){
- var el = this.getFxEl();
- o = o || {};
- el.queueFx(o, function(){
- var a = {}, w = o.width, h = o.height, x = o.x, y = o.y, op = o.opacity;
- if(w !== undefined){
- a.width = {to: this.adjustWidth(w)};
- }
- if(h !== undefined){
- a.height = {to: this.adjustHeight(h)};
- }
- if(x !== undefined || y !== undefined){
- a.points = {to: [
- x !== undefined ? x : this.getX(),
- y !== undefined ? y : this.getY()
- ]};
- }
- if(op !== undefined){
- a.opacity = {to: op};
- }
- if(o.xy !== undefined){
- a.points = {to: o.xy};
- }
- arguments.callee.anim = this.fxanim(a,
- o, 'motion', .35, "easeOut", function(){
- el.afterFx(o);
- });
- });
- return this;
- },
- ghost : function(anchor, o){
- var el = this.getFxEl();
- o = o || {};
- el.queueFx(o, function(){
- anchor = anchor || "b";
- var r = this.getFxRestore();
- var w = this.getWidth(),
- h = this.getHeight();
- var st = this.dom.style;
- var after = function(){
- if(o.useDisplay){
- el.setDisplayed(false);
- }else{
- el.hide();
- }
- el.clearOpacity();
- el.setPositioning(r.pos);
- st.width = r.width;
- st.height = r.height;
- el.afterFx(o);
- };
- var a = {opacity: {to: 0}, points: {}}, pt = a.points;
- switch(anchor.toLowerCase()){
- case "t":
- pt.by = [0, -h];
- break;
- case "l":
- pt.by = [-w, 0];
- break;
- case "r":
- pt.by = [w, 0];
- break;
- case "b":
- pt.by = [0, h];
- break;
- case "tl":
- pt.by = [-w, -h];
- break;
- case "bl":
- pt.by = [-w, h];
- break;
- case "br":
- pt.by = [w, h];
- break;
- case "tr":
- pt.by = [w, -h];
- break;
- }
- arguments.callee.anim = this.fxanim(a,
- o,
- 'motion',
- .5,
- "easeOut", after);
- });
- return this;
- },
- syncFx : function(){
- this.fxDefaults = Ext.apply(this.fxDefaults || {}, {
- block : false,
- concurrent : true,
- stopFx : false
- });
- return this;
- },
- sequenceFx : function(){
- this.fxDefaults = Ext.apply(this.fxDefaults || {}, {
- block : false,
- concurrent : false,
- stopFx : false
- });
- return this;
- },
- nextFx : function(){
- var ef = this.fxQueue[0];
- if(ef){
- ef.call(this);
- }
- },
- hasActiveFx : function(){
- return this.fxQueue && this.fxQueue[0];
- },
- stopFx : function(){
- if(this.hasActiveFx()){
- var cur = this.fxQueue[0];
- if(cur && cur.anim && cur.anim.isAnimated()){
- this.fxQueue = [cur]; cur.anim.stop(true);
- }
- }
- return this;
- },
- beforeFx : function(o){
- if(this.hasActiveFx() && !o.concurrent){
- if(o.stopFx){
- this.stopFx();
- return true;
- }
- return false;
- }
- return true;
- },
- hasFxBlock : function(){
- var q = this.fxQueue;
- return q && q[0] && q[0].block;
- },
- queueFx : function(o, fn){
- if(!this.fxQueue){
- this.fxQueue = [];
- }
- if(!this.hasFxBlock()){
- Ext.applyIf(o, this.fxDefaults);
- if(!o.concurrent){
- var run = this.beforeFx(o);
- fn.block = o.block;
- this.fxQueue.push(fn);
- if(run){
- this.nextFx();
- }
- }else{
- fn.call(this);
- }
- }
- return this;
- },
- fxWrap : function(pos, o, vis){
- var wrap;
- if(!o.wrap || !(wrap = Ext.get(o.wrap))){
- var wrapXY;
- if(o.fixPosition){
- wrapXY = this.getXY();
- }
- var div = document.createElement("div");
- div.style.visibility = vis;
- wrap = Ext.get(this.dom.parentNode.insertBefore(div, this.dom));
- wrap.setPositioning(pos);
- if(wrap.getStyle("position") == "static"){
- wrap.position("relative");
- }
- this.clearPositioning('auto');
- wrap.clip();
- wrap.dom.appendChild(this.dom);
- if(wrapXY){
- wrap.setXY(wrapXY);
- }
- }
- return wrap;
- },
- fxUnwrap : function(wrap, pos, o){
- this.clearPositioning();
- this.setPositioning(pos);
- if(!o.wrap){
- wrap.dom.parentNode.insertBefore(this.dom, wrap.dom);
- wrap.remove();
- }
- },
- getFxRestore : function(){
- var st = this.dom.style;
- return {pos: this.getPositioning(), width: st.width, height : st.height};
- },
- afterFx : function(o){
- if(o.afterStyle){
- this.applyStyles(o.afterStyle);
- }
- if(o.afterCls){
- this.addClass(o.afterCls);
- }
- if(o.remove === true){
- this.remove();
- }
- Ext.callback(o.callback, o.scope, [this]);
- if(!o.concurrent){
- this.fxQueue.shift();
- this.nextFx();
- }
- },
- getFxEl : function(){ return Ext.get(this.dom);
- },
- fxanim : function(args, opt, animType, defaultDur, defaultEase, cb){
- animType = animType || 'run';
- opt = opt || {};
- var anim = Ext.lib.Anim[animType](
- this.dom, args,
- (opt.duration || defaultDur) || .35,
- (opt.easing || defaultEase) || 'easeOut',
- function(){
- Ext.callback(cb, this);
- },
- this
- );
- opt.anim = anim;
- return anim;
- }
- };
- Ext.Fx.resize = Ext.Fx.scale;
- Ext.apply(Ext.Element.prototype, Ext.Fx);
- Ext.CompositeElement = function(els){
- this.elements = [];
- this.addElements(els);
- };
- Ext.CompositeElement.prototype = {
- isComposite: true,
- addElements : function(els){
- if(!els) return this;
- if(typeof els == "string"){
- els = Ext.Element.selectorFunction(els);
- }
- var yels = this.elements;
- var index = yels.length-1;
- for(var i = 0, len = els.length; i < len; i++) {
- yels[++index] = Ext.get(els[i]);
- }
- return this;
- },
- fill : function(els){
- this.elements = [];
- this.add(els);
- return this;
- },
- filter : function(selector){
- var els = [];
- this.each(function(el){
- if(el.is(selector)){
- els[els.length] = el.dom;
- }
- });
- this.fill(els);
- return this;
- },
- invoke : function(fn, args){
- var els = this.elements;
- for(var i = 0, len = els.length; i < len; i++) {
- Ext.Element.prototype[fn].apply(els[i], args);
- }
- return this;
- },
- add : function(els){
- if(typeof els == "string"){
- this.addElements(Ext.Element.selectorFunction(els));
- }else if(els.length !== undefined){
- this.addElements(els);
- }else{
- this.addElements([els]);
- }
- return this;
- },
- each : function(fn, scope){
- var els = this.elements;
- for(var i = 0, len = els.length; i < len; i++){
- if(fn.call(scope || els[i], els[i], this, i) === false) {
- break;
- }
- }
- return this;
- },
- item : function(index){
- return this.elements[index] || null;
- },
- first : function(){
- return this.item(0);
- },
- last : function(){
- return this.item(this.elements.length-1);
- },
- getCount : function(){
- return this.elements.length;
- },
- contains : function(el){
- return this.indexOf(el) !== -1;
- },
- indexOf : function(el){
- return this.elements.indexOf(Ext.get(el));
- },
- removeElement : function(el, removeDom){
- if(Ext.isArray(el)){
- for(var i = 0, len = el.length; i < len; i++){
- this.removeElement(el[i]);
- }
- return this;
- }
- var index = typeof el == 'number' ? el : this.indexOf(el);
- if(index !== -1 && this.elements[index]){
- if(removeDom){
- var d = this.elements[index];
- if(d.dom){
- d.remove();
- }else{
- Ext.removeNode(d);
- }
- }
- this.elements.splice(index, 1);
- }
- return this;
- },
- replaceElement : function(el, replacement, domReplace){
- var index = typeof el == 'number' ? el : this.indexOf(el);
- if(index !== -1){
- if(domReplace){
- this.elements[index].replaceWith(replacement);
- }else{
- this.elements.splice(index, 1, Ext.get(replacement))
- }
- }
- return this;
- },
- clear : function(){
- this.elements = [];
- }
- };
- (function(){
- Ext.CompositeElement.createCall = function(proto, fnName){
- if(!proto[fnName]){
- proto[fnName] = function(){
- return this.invoke(fnName, arguments);
- };
- }
- };
- for(var fnName in Ext.Element.prototype){
- if(typeof Ext.Element.prototype[fnName] == "function"){
- Ext.CompositeElement.createCall(Ext.CompositeElement.prototype, fnName);
- }
- };
- })();
- Ext.CompositeElementLite = function(els){
- Ext.CompositeElementLite.superclass.constructor.call(this, els);
- this.el = new Ext.Element.Flyweight();
- };
- Ext.extend(Ext.CompositeElementLite, Ext.CompositeElement, {
- addElements : function(els){
- if(els){
- if(Ext.isArray(els)){
- this.elements = this.elements.concat(els);
- }else{
- var yels = this.elements;
- var index = yels.length-1;
- for(var i = 0, len = els.length; i < len; i++) {
- yels[++index] = els[i];
- }
- }
- }
- return this;
- },
- invoke : function(fn, args){
- var els = this.elements;
- var el = this.el;
- for(var i = 0, len = els.length; i < len; i++) {
- el.dom = els[i];
- Ext.Element.prototype[fn].apply(el, args);
- }
- return this;
- },
- item : function(index){
- if(!this.elements[index]){
- return null;
- }
- this.el.dom = this.elements[index];
- return this.el;
- },
- addListener : function(eventName, handler, scope, opt){
- var els = this.elements;
- for(var i = 0, len = els.length; i < len; i++) {
- Ext.EventManager.on(els[i], eventName, handler, scope || els[i], opt);
- }
- return this;
- },
- each : function(fn, scope){
- var els = this.elements;
- var el = this.el;
- for(var i = 0, len = els.length; i < len; i++){
- el.dom = els[i];
- if(fn.call(scope || el, el, this, i) === false){
- break;
- }
- }
- return this;
- },
- indexOf : function(el){
- return this.elements.indexOf(Ext.getDom(el));
- },
- replaceElement : function(el, replacement, domReplace){
- var index = typeof el == 'number' ? el : this.indexOf(el);
- if(index !== -1){
- replacement = Ext.getDom(replacement);
- if(domReplace){
- var d = this.elements[index];
- d.parentNode.insertBefore(replacement, d);
- Ext.removeNode(d);
- }
- this.elements.splice(index, 1, replacement);
- }
- return this;
- }
- });
- Ext.CompositeElementLite.prototype.on = Ext.CompositeElementLite.prototype.addListener;
- if(Ext.DomQuery){
- Ext.Element.selectorFunction = Ext.DomQuery.select;
- }
- Ext.Element.select = function(selector, unique, root){
- var els;
- if(typeof selector == "string"){
- els = Ext.Element.selectorFunction(selector, root);
- }else if(selector.length !== undefined){
- els = selector;
- }else{
- throw "Invalid selector";
- }
- if(unique === true){
- return new Ext.CompositeElement(els);
- }else{
- return new Ext.CompositeElementLite(els);
- }
- };
- Ext.select = Ext.Element.select;
- Ext.data.Connection = function(config){
- Ext.apply(this, config);
- this.addEvents(
- "beforerequest",
- "requestcomplete",
- "requestexception"
- );
- Ext.data.Connection.superclass.constructor.call(this);
- };
- Ext.extend(Ext.data.Connection, Ext.util.Observable, {
- timeout : 30000,
- autoAbort:false,
- disableCaching: true,
- request : function(o){
- if(this.fireEvent("beforerequest", this, o) !== false){
- var p = o.params;
- if(typeof p == "function"){
- p = p.call(o.scope||window, o);
- }
- if(typeof p == "object"){
- p = Ext.urlEncode(p);
- }
- if(this.extraParams){
- var extras = Ext.urlEncode(this.extraParams);
- p = p ? (p + '&' + extras) : extras;
- }
- var url = o.url || this.url;
- if(typeof url == 'function'){
- url = url.call(o.scope||window, o);
- }
- if(o.form){
- var form = Ext.getDom(o.form);
- url = url || form.action;
- var enctype = form.getAttribute("enctype");
- if(o.isUpload || (enctype && enctype.toLowerCase() == 'multipart/form-data')){
- return this.doFormUpload(o, p, url);
- }
- var f = Ext.lib.Ajax.serializeForm(form);
- p = p ? (p + '&' + f) : f;
- }
- var hs = o.headers;
- if(this.defaultHeaders){
- hs = Ext.apply(hs || {}, this.defaultHeaders);
- if(!o.headers){
- o.headers = hs;
- }
- }
- var cb = {
- success: this.handleResponse,
- failure: this.handleFailure,
- scope: this,
- argument: {options: o},
- timeout : o.timeout || this.timeout
- };
- var method = o.method||this.method||(p ? "POST" : "GET");
- if(method == 'GET' && (this.disableCaching && o.disableCaching !== false) || o.disableCaching === true){
- url += (url.indexOf('?') != -1 ? '&' : '?') + '_dc=' + (new Date().getTime());
- }
- if(typeof o.autoAbort == 'boolean'){
- if(o.autoAbort){
- this.abort();
- }
- }else if(this.autoAbort !== false){
- this.abort();
- }
- if((method == 'GET' && p) || o.xmlData || o.jsonData){
- url += (url.indexOf('?') != -1 ? '&' : '?') + p;
- p = '';
- }
- this.transId = Ext.lib.Ajax.request(method, url, cb, p, o);
- return this.transId;
- }else{
- Ext.callback(o.callback, o.scope, [o, null, null]);
- return null;
- }
- },
- isLoading : function(transId){
- if(transId){
- return Ext.lib.Ajax.isCallInProgress(transId);
- }else{
- return this.transId ? true : false;
- }
- },
- abort : function(transId){
- if(transId || this.isLoading()){
- Ext.lib.Ajax.abort(transId || this.transId);
- }
- },
- handleResponse : function(response){
- this.transId = false;
- var options = response.argument.options;
- response.argument = options ? options.argument : null;
- this.fireEvent("requestcomplete", this, response, options);
- Ext.callback(options.success, options.scope, [response, options]);
- Ext.callback(options.callback, options.scope, [options, true, response]);
- },
- handleFailure : function(response, e){
- this.transId = false;
- var options = response.argument.options;
- response.argument = options ? options.argument : null;
- this.fireEvent("requestexception", this, response, options, e);
- Ext.callback(options.failure, options.scope, [response, options]);
- Ext.callback(options.callback, options.scope, [options, false, response]);
- },
- doFormUpload : function(o, ps, url){
- var id = Ext.id();
- var frame = document.createElement('iframe');
- frame.id = id;
- frame.name = id;
- frame.className = 'x-hidden';
- if(Ext.isIE){
- frame.src = Ext.SSL_SECURE_URL;
- }
- document.body.appendChild(frame);
- if(Ext.isIE){
- document.frames[id].name = id;
- }
- var form = Ext.getDom(o.form);
- form.target = id;
- form.method = 'POST';
- form.enctype = form.encoding = 'multipart/form-data';
- if(url){
- form.action = url;
- }
- var hiddens, hd;
- if(ps){
- hiddens = [];
- ps = Ext.urlDecode(ps, false);
- for(var k in ps){
- if(ps.hasOwnProperty(k)){
- hd = document.createElement('input');
- hd.type = 'hidden';
- hd.name = k;
- hd.value = ps[k];
- form.appendChild(hd);
- hiddens.push(hd);
- }
- }
- }
- function cb(){
- var r = {
- responseText : '',
- responseXML : null
- };
- r.argument = o ? o.argument : null;
- try {
- var doc;
- if(Ext.isIE){
- doc = frame.contentWindow.document;
- }else {
- doc = (frame.contentDocument || window.frames[id].document);
- }
- if(doc && doc.body){
- r.responseText = doc.body.innerHTML;
- }
- if(doc && doc.XMLDocument){
- r.responseXML = doc.XMLDocument;
- }else {
- r.responseXML = doc;
- }
- }
- catch(e) {
- }
- Ext.EventManager.removeListener(frame, 'load', cb, this);
- this.fireEvent("requestcomplete", this, r, o);
- Ext.callback(o.success, o.scope, [r, o]);
- Ext.callback(o.callback, o.scope, [o, true, r]);
- setTimeout(function(){Ext.removeNode(frame);}, 100);
- }
- Ext.EventManager.on(frame, 'load', cb, this);
- form.submit();
- if(hiddens){
- for(var i = 0, len = hiddens.length; i < len; i++){
- Ext.removeNode(hiddens[i]);
- }
- }
- }
- });
- Ext.Ajax = new Ext.data.Connection({
- autoAbort : false,
- serializeForm : function(form){
- return Ext.lib.Ajax.serializeForm(form);
- }
- });
- Ext.Updater = function(el, forceNew){
- el = Ext.get(el);
- if(!forceNew && el.updateManager){
- return el.updateManager;
- }
- this.el = el;
- this.defaultUrl = null;
- this.addEvents(
- "beforeupdate",
- "update",
- "failure"
- );
- var d = Ext.Updater.defaults;
- this.sslBlankUrl = d.sslBlankUrl;
- this.disableCaching = d.disableCaching;
- this.indicatorText = d.indicatorText;
- this.showLoadIndicator = d.showLoadIndicator;
- this.timeout = d.timeout;
- this.loadScripts = d.loadScripts;
- this.transaction = null;
- this.autoRefreshProcId = null;
- this.refreshDelegate = this.refresh.createDelegate(this);
- this.updateDelegate = this.update.createDelegate(this);
- this.formUpdateDelegate = this.formUpdate.createDelegate(this);
- if(!this.renderer){
- this.renderer = new Ext.Updater.BasicRenderer();
- }
- Ext.Updater.superclass.constructor.call(this);
- };
- Ext.extend(Ext.Updater, Ext.util.Observable, {
- getEl : function(){
- return this.el;
- },
- update : function(url, params, callback, discardUrl){
- if(this.fireEvent("beforeupdate", this.el, url, params) !== false){
- var method = this.method, cfg, callerScope;
- if(typeof url == "object"){
- cfg = url;
- url = cfg.url;
- params = params || cfg.params;
- callback = callback || cfg.callback;
- discardUrl = discardUrl || cfg.discardUrl;
- callerScope = cfg.scope;
- if(typeof cfg.method != "undefined"){method = cfg.method;};
- if(typeof cfg.nocache != "undefined"){this.disableCaching = cfg.nocache;};
- if(typeof cfg.text != "undefined"){this.indicatorText = '<div class="loading-indicator">'+cfg.text+"</div>";};
- if(typeof cfg.scripts != "undefined"){this.loadScripts = cfg.scripts;};
- if(typeof cfg.timeout != "undefined"){this.timeout = cfg.timeout;};
- }
- this.showLoading();
- if(!discardUrl){
- this.defaultUrl = url;
- }
- if(typeof url == "function"){
- url = url.call(this);
- }
- method = method || (params ? "POST" : "GET");
- if(method == "GET"){
- url = this.prepareUrl(url);
- }
- var o = Ext.apply(cfg ||{}, {
- url : url,
- params: (typeof params == "function" && callerScope) ? params.createDelegate(callerScope) : params,
- success: this.processSuccess,
- failure: this.processFailure,
- scope: this,
- callback: undefined,
- timeout: (this.timeout*1000),
- argument: {
- "options": cfg,
- "url": url,
- "form": null,
- "callback": callback,
- "scope": callerScope || window,
- "params": params
- }
- });
- this.transaction = Ext.Ajax.request(o);
- }
- },
- formUpdate : function(form, url, reset, callback){
- if(this.fireEvent("beforeupdate", this.el, form, url) !== false){
- if(typeof url == "function"){
- url = url.call(this);
- }
- form = Ext.getDom(form)
- this.transaction = Ext.Ajax.request({
- form: form,
- url:url,
- success: this.processSuccess,
- failure: this.processFailure,
- scope: this,
- timeout: (this.timeout*1000),
- argument: {
- "url": url,
- "form": form,
- "callback": callback,
- "reset": reset
- }
- });
- this.showLoading.defer(1, this);
- }
- },
- refresh : function(callback){
- if(this.defaultUrl == null){
- return;
- }
- this.update(this.defaultUrl, null, callback, true);
- },
- startAutoRefresh : function(interval, url, params, callback, refreshNow){
- if(refreshNow){
- this.update(url || this.defaultUrl, params, callback, true);
- }
- if(this.autoRefreshProcId){
- clearInterval(this.autoRefreshProcId);
- }
- this.autoRefreshProcId = setInterval(this.update.createDelegate(this, [url || this.defaultUrl, params, callback, true]), interval*1000);
- },
- stopAutoRefresh : function(){
- if(this.autoRefreshProcId){
- clearInterval(this.autoRefreshProcId);
- delete this.autoRefreshProcId;
- }
- },
- isAutoRefreshing : function(){
- return this.autoRefreshProcId ? true : false;
- },
- showLoading : function(){
- if(this.showLoadIndicator){
- this.el.update(this.indicatorText);
- }
- },
- prepareUrl : function(url){
- if(this.disableCaching){
- var append = "_dc=" + (new Date().getTime());
- if(url.indexOf("?") !== -1){
- url += "&" + append;
- }else{
- url += "?" + append;
- }
- }
- return url;
- },
- processSuccess : function(response){
- this.transaction = null;
- if(response.argument.form && response.argument.reset){
- try{
- response.argument.form.reset();
- }catch(e){}
- }
- if(this.loadScripts){
- this.renderer.render(this.el, response, this,
- this.updateComplete.createDelegate(this, [response]));
- }else{
- this.renderer.render(this.el, response, this);
- this.updateComplete(response);
- }
- },
- updateComplete : function(response){
- this.fireEvent("update", this.el, response);
- if(typeof response.argument.callback == "function"){
- response.argument.callback.call(response.argument.scope, this.el, true, response, response.argument.options);
- }
- },
- processFailure : function(response){
- this.transaction = null;
- this.fireEvent("failure", this.el, response);
- if(typeof response.argument.callback == "function"){
- response.argument.callback.call(response.argument.scope, this.el, false, response, response.argument.options);
- }
- },
- setRenderer : function(renderer){
- this.renderer = renderer;
- },
- getRenderer : function(){
- return this.renderer;
- },
- setDefaultUrl : function(defaultUrl){
- this.defaultUrl = defaultUrl;
- },
- abort : function(){
- if(this.transaction){
- Ext.Ajax.abort(this.transaction);
- }
- },
- isUpdating : function(){
- if(this.transaction){
- return Ext.Ajax.isLoading(this.transaction);
- }
- return false;
- }
- });
- Ext.Updater.defaults = {
- timeout : 30,
- loadScripts : false,
- sslBlankUrl : (Ext.SSL_SECURE_URL || "javascript:false"),
- disableCaching : false,
- showLoadIndicator : true,
- indicatorText : '<div class="loading-indicator">Loading...</div>'
- };
- Ext.Updater.updateElement = function(el, url, params, options){
- var um = Ext.get(el).getUpdater();
- Ext.apply(um, options);
- um.update(url, params, options ? options.callback : null);
- };
- Ext.Updater.update = Ext.Updater.updateElement;
- Ext.Updater.BasicRenderer = function(){};
- Ext.Updater.BasicRenderer.prototype = {
- render : function(el, response, updateManager, callback){
- el.update(response.responseText, updateManager.loadScripts, callback);
- }
- };
- Ext.UpdateManager = Ext.Updater;
- Date.parseFunctions = {count:0};
- Date.parseRegexes = [];
- Date.formatFunctions = {count:0};
- Date.prototype.dateFormat = function(format) {
- if (Date.formatFunctions[format] == null) {
- Date.createNewFormat(format);
- }
- var func = Date.formatFunctions[format];
- return this[func]();
- };
- Date.prototype.format = Date.prototype.dateFormat;
- Date.createNewFormat = function(format) {
- var funcName = "format" + Date.formatFunctions.count++;
- Date.formatFunctions[format] = funcName;
- var code = "Date.prototype." + funcName + " = function(){return ";
- var special = false;
- var ch = '';
- for (var i = 0; i < format.length; ++i) {
- ch = format.charAt(i);
- if (!special && ch == "\") {
- special = true;
- }
- else if (special) {
- special = false;
- code += "'" + String.escape(ch) + "' + ";
- }
- else {
- code += Date.getFormatCode(ch);
- }
- }
- eval(code.substring(0, code.length - 3) + ";}");
- };
- Date.getFormatCode = function(character) {
- switch (character) {
- case "d":
- return "String.leftPad(this.getDate(), 2, '0') + ";
- case "D":
- return "Date.getShortDayName(this.getDay()) + "; case "j":
- return "this.getDate() + ";
- case "l":
- return "Date.dayNames[this.getDay()] + ";
- case "N":
- return "(this.getDay() ? this.getDay() : 7) + ";
- case "S":
- return "this.getSuffix() + ";
- case "w":
- return "this.getDay() + ";
- case "z":
- return "this.getDayOfYear() + ";
- case "W":
- return "String.leftPad(this.getWeekOfYear(), 2, '0') + ";
- case "F":
- return "Date.monthNames[this.getMonth()] + ";
- case "m":
- return "String.leftPad(this.getMonth() + 1, 2, '0') + ";
- case "M":
- return "Date.getShortMonthName(this.getMonth()) + "; case "n":
- return "(this.getMonth() + 1) + ";
- case "t":
- return "this.getDaysInMonth() + ";
- case "L":
- return "(this.isLeapYear() ? 1 : 0) + ";
- case "o":
- return "(this.getFullYear() + (this.getWeekOfYear() == 1 && this.getMonth() > 0 ? +1 : (this.getWeekOfYear() >= 52 && this.getMonth() < 11 ? -1 : 0))) + ";
- case "Y":
- return "this.getFullYear() + ";
- case "y":
- return "('' + this.getFullYear()).substring(2, 4) + ";
- case "a":
- return "(this.getHours() < 12 ? 'am' : 'pm') + ";
- case "A":
- return "(this.getHours() < 12 ? 'AM' : 'PM') + ";
- case "g":
- return "((this.getHours() % 12) ? this.getHours() % 12 : 12) + ";
- case "G":
- return "this.getHours() + ";
- case "h":
- return "String.leftPad((this.getHours() % 12) ? this.getHours() % 12 : 12, 2, '0') + ";
- case "H":
- return "String.leftPad(this.getHours(), 2, '0') + ";
- case "i":
- return "String.leftPad(this.getMinutes(), 2, '0') + ";
- case "s":
- return "String.leftPad(this.getSeconds(), 2, '0') + ";
- case "u":
- return "String.leftPad(this.getMilliseconds(), 3, '0') + ";
- case "O":
- return "this.getGMTOffset() + ";
- case "P":
- return "this.getGMTOffset(true) + ";
- case "T":
- return "this.getTimezone() + ";
- case "Z":
- return "(this.getTimezoneOffset() * -60) + ";
- case "c":
- for (var df = Date.getFormatCode, c = "Y-m-dTH:i:sP", code = "", i = 0, l = c.length; i < l; ++i) {
- var e = c.charAt(i);
- code += e == "T" ? "'T' + " : df(e); }
- return code;
- case "U":
- return "Math.round(this.getTime() / 1000) + ";
- default:
- return "'" + String.escape(character) + "' + ";
- }
- };
- Date.parseDate = function(input, format) {
- if (Date.parseFunctions[format] == null) {
- Date.createParser(format);
- }
- var func = Date.parseFunctions[format];
- return Date[func](input);
- };
- Date.createParser = function(format) {
- var funcName = "parse" + Date.parseFunctions.count++;
- var regexNum = Date.parseRegexes.length;
- var currentGroup = 1;
- Date.parseFunctions[format] = funcName;
- var code = "Date." + funcName + " = function(input){n"
- + "var y = -1, m = -1, d = -1, h = -1, i = -1, s = -1, ms = -1, o, z, u, v;n"
- + "input = String(input);var d = new Date();n"
- + "y = d.getFullYear();n"
- + "m = d.getMonth();n"
- + "d = d.getDate();n"
- + "var results = input.match(Date.parseRegexes[" + regexNum + "]);n"
- + "if (results && results.length > 0) {";
- var regex = "";
- var special = false;
- var ch = '';
- for (var i = 0; i < format.length; ++i) {
- ch = format.charAt(i);
- if (!special && ch == "\") {
- special = true;
- }
- else if (special) {
- special = false;
- regex += String.escape(ch);
- }
- else {
- var obj = Date.formatCodeToRegex(ch, currentGroup);
- currentGroup += obj.g;
- regex += obj.s;
- if (obj.g && obj.c) {
- code += obj.c;
- }
- }
- }
- code += "if (u)n"
- + "{v = new Date(u * 1000);}" + "else if (y >= 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0 && ms >= 0)n"
- + "{v = new Date(y, m, d, h, i, s, ms);}n"
- + "else if (y >= 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)n"
- + "{v = new Date(y, m, d, h, i, s);}n"
- + "else if (y >= 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)n"
- + "{v = new Date(y, m, d, h, i);}n"
- + "else if (y >= 0 && m >= 0 && d > 0 && h >= 0)n"
- + "{v = new Date(y, m, d, h);}n"
- + "else if (y >= 0 && m >= 0 && d > 0)n"
- + "{v = new Date(y, m, d);}n"
- + "else if (y >= 0 && m >= 0)n"
- + "{v = new Date(y, m);}n"
- + "else if (y >= 0)n"
- + "{v = new Date(y);}n"
- + "}return (v && (z || o))?n" + " (z ? v.add(Date.SECOND, (v.getTimezoneOffset() * 60) + (z*1)) :n" + " v.add(Date.HOUR, (v.getGMTOffset() / 100) + (o / -100))) : vn" + ";}";
- Date.parseRegexes[regexNum] = new RegExp("^" + regex + "$", "i");
- eval(code);
- };
- Date.formatCodeToRegex = function(character, currentGroup) {
- switch (character) {
- case "d":
- return {g:1,
- c:"d = parseInt(results[" + currentGroup + "], 10);n",
- s:"(\d{2})"}; case "D":
- for (var a = [], i = 0; i < 7; a.push(Date.getShortDayName(i)), ++i); return {g:0,
- c:null,
- s:"(?:" + a.join("|") +")"};
- case "j":
- return {g:1,
- c:"d = parseInt(results[" + currentGroup + "], 10);n",
- s:"(\d{1,2})"}; case "l":
- return {g:0,
- c:null,
- s:"(?:" + Date.dayNames.join("|") + ")"};
- case "N":
- return {g:0,
- c:null,
- s:"[1-7]"}; case "S":
- return {g:0,
- c:null,
- s:"(?:st|nd|rd|th)"};
- case "w":
- return {g:0,
- c:null,
- s:"[0-6]"}; case "z":
- return {g:0,
- c:null,
- s:"(?:\d{1,3}"}; case "W":
- return {g:0,
- c:null,
- s:"(?:\d{2})"}; case "F":
- return {g:1,
- c:"m = parseInt(Date.getMonthNumber(results[" + currentGroup + "]), 10);n", s:"(" + Date.monthNames.join("|") + ")"};
- case "m":
- return {g:1,
- c:"m = parseInt(results[" + currentGroup + "], 10) - 1;n",
- s:"(\d{2})"}; case "M":
- for (var a = [], i = 0; i < 12; a.push(Date.getShortMonthName(i)), ++i); return {g:1,
- c:"m = parseInt(Date.getMonthNumber(results[" + currentGroup + "]), 10);n", s:"(" + a.join("|") + ")"};
- case "n":
- return {g:1,
- c:"m = parseInt(results[" + currentGroup + "], 10) - 1;n",
- s:"(\d{1,2})"}; case "t":
- return {g:0,
- c:null,
- s:"(?:\d{2})"}; case "L":
- return {g:0,
- c:null,
- s:"(?:1|0)"};
- case "o":
- case "Y":
- return {g:1,
- c:"y = parseInt(results[" + currentGroup + "], 10);n",
- s:"(\d{4})"}; case "y":
- return {g:1,
- c:"var ty = parseInt(results[" + currentGroup + "], 10);n"
- + "y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;n",
- s:"(\d{1,2})"}; case "a":
- return {g:1,
- c:"if (results[" + currentGroup + "] == 'am') {n"
- + "if (h == 12) { h = 0; }n"
- + "} else { if (h < 12) { h += 12; }}",
- s:"(am|pm)"};
- case "A":
- return {g:1,
- c:"if (results[" + currentGroup + "] == 'AM') {n"
- + "if (h == 12) { h = 0; }n"
- + "} else { if (h < 12) { h += 12; }}",
- s:"(AM|PM)"};
- case "g":
- case "G":
- return {g:1,
- c:"h = parseInt(results[" + currentGroup + "], 10);n",
- s:"(\d{1,2})"}; case "h":
- case "H":
- return {g:1,
- c:"h = parseInt(results[" + currentGroup + "], 10);n",
- s:"(\d{2})"}; case "i":
- return {g:1,
- c:"i = parseInt(results[" + currentGroup + "], 10);n",
- s:"(\d{2})"}; case "s":
- return {g:1,
- c:"s = parseInt(results[" + currentGroup + "], 10);n",
- s:"(\d{2})"}; case "u":
- return {g:1,
- c:"ms = parseInt(results[" + currentGroup + "], 10);n",
- s:"(\d{3})"}; case "O":
- return {g:1,
- c:[
- "o = results[", currentGroup, "];n",
- "var sn = o.substring(0,1);n", "var hr = o.substring(1,3)*1 + Math.floor(o.substring(3,5) / 60);n", "var mn = o.substring(3,5) % 60;n", "o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))?n", " (sn + String.leftPad(hr, 2, '0') + String.leftPad(mn, 2, '0')) : null;n"
- ].join(""),
- s: "([+-]\d{4})"}; case "P":
- return {g:1,
- c:[
- "o = results[", currentGroup, "];n",
- "var sn = o.substring(0,1);n", "var hr = o.substring(1,3)*1 + Math.floor(o.substring(4,6) / 60);n", "var mn = o.substring(4,6) % 60;n", "o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))?n", " (sn + String.leftPad(hr, 2, '0') + String.leftPad(mn, 2, '0')) : null;n"
- ].join(""),
- s: "([+-]\d{2}:\d{2})"}; case "T":
- return {g:0,
- c:null,
- s:"[A-Z]{1,4}"}; case "Z":
- return {g:1,
- c:"z = results[" + currentGroup + "] * 1;n" + "z = (-43200 <= z && z <= 50400)? z : null;n",
- s:"([+-]?\d{1,5})"}; case "c":
- var df = Date.formatCodeToRegex, calc = [];
- var arr = [df("Y", 1), df("m", 2), df("d", 3), df("h", 4), df("i", 5), df("s", 6), df("P", 7)];
- for (var i = 0, l = arr.length; i < l; ++i) {
- calc.push(arr[i].c);
- }
- return {g:1,
- c:calc.join(""),
- s:arr[0].s + "-" + arr[1].s + "-" + arr[2].s + "T" + arr[3].s + ":" + arr[4].s + ":" + arr[5].s + arr[6].s};
- case "U":
- return {g:1,
- c:"u = parseInt(results[" + currentGroup + "], 10);n",
- s:"(-?\d+)"}; default:
- return {g:0,
- c:null,
- s:Ext.escapeRe(character)};
- }
- };
- Date.prototype.getTimezone = function() {
- return this.toString().replace(/^.* (?:((.*))|([A-Z]{1,4})(?:[-+][0-9]{4})?(?: -?d+)?)$/, "$1$2").replace(/[^A-Z]/g, "");
- };
- Date.prototype.getGMTOffset = function(colon) {
- return (this.getTimezoneOffset() > 0 ? "-" : "+")
- + String.leftPad(Math.abs(Math.floor(this.getTimezoneOffset() / 60)), 2, "0")
- + (colon ? ":" : "")
- + String.leftPad(this.getTimezoneOffset() % 60, 2, "0");
- };
- Date.prototype.getDayOfYear = function() {
- var num = 0;
- Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
- for (var i = 0; i < this.getMonth(); ++i) {
- num += Date.daysInMonth[i];
- }
- return num + this.getDate() - 1;
- };
- Date.prototype.getWeekOfYear = function() {
- var ms1d = 864e5; var ms7d = 7 * ms1d; var DC3 = Date.UTC(this.getFullYear(), this.getMonth(), this.getDate() + 3) / ms1d; var AWN = Math.floor(DC3 / 7); var Wyr = new Date(AWN * ms7d).getUTCFullYear();
- return AWN - Math.floor(Date.UTC(Wyr, 0, 7) / ms7d) + 1;
- };
- Date.prototype.isLeapYear = function() {
- var year = this.getFullYear();
- return !!((year & 3) == 0 && (year % 100 || (year % 400 == 0 && year)));
- };
- Date.prototype.getFirstDayOfMonth = function() {
- var day = (this.getDay() - (this.getDate() - 1)) % 7;
- return (day < 0) ? (day + 7) : day;
- };
- Date.prototype.getLastDayOfMonth = function() {
- var day = (this.getDay() + (Date.daysInMonth[this.getMonth()] - this.getDate())) % 7;
- return (day < 0) ? (day + 7) : day;
- };
- Date.prototype.getFirstDateOfMonth = function() {
- return new Date(this.getFullYear(), this.getMonth(), 1);
- };
- Date.prototype.getLastDateOfMonth = function() {
- return new Date(this.getFullYear(), this.getMonth(), this.getDaysInMonth());
- };
- Date.prototype.getDaysInMonth = function() {
- Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
- return Date.daysInMonth[this.getMonth()];
- };
- Date.prototype.getSuffix = function() {
- switch (this.getDate()) {
- case 1:
- case 21:
- case 31:
- return "st";
- case 2:
- case 22:
- return "nd";
- case 3:
- case 23:
- return "rd";
- default:
- return "th";
- }
- };
- Date.daysInMonth = [31,28,31,30,31,30,31,31,30,31,30,31];
- Date.monthNames =
- ["January",
- "February",
- "March",
- "April",
- "May",
- "June",
- "July",
- "August",
- "September",
- "October",
- "November",
- "December"];
- Date.getShortMonthName = function(month) {
- return Date.monthNames[month].substring(0, 3);
- }
- Date.dayNames =
- ["Sunday",
- "Monday",
- "Tuesday",
- "Wednesday",
- "Thursday",
- "Friday",
- "Saturday"];
- Date.getShortDayName = function(day) {
- return Date.dayNames[day].substring(0, 3);
- }
- Date.y2kYear = 50;
- Date.monthNumbers = {
- Jan:0,
- Feb:1,
- Mar:2,
- Apr:3,
- May:4,
- Jun:5,
- Jul:6,
- Aug:7,
- Sep:8,
- Oct:9,
- Nov:10,
- Dec:11};
- Date.getMonthNumber = function(name) {
- return Date.monthNumbers[name.substring(0, 1).toUpperCase() + name.substring(1, 3).toLowerCase()];
- }
- Date.prototype.clone = function() {
- return new Date(this.getTime());
- };
- Date.prototype.clearTime = function(clone){
- if(clone){
- return this.clone().clearTime();
- }
- this.setHours(0);
- this.setMinutes(0);
- this.setSeconds(0);
- this.setMilliseconds(0);
- return this;
- };
- if(Ext.isSafari){
- Date.brokenSetMonth = Date.prototype.setMonth;
- Date.prototype.setMonth = function(num){
- if(num <= -1){
- var n = Math.ceil(-num);
- var back_year = Math.ceil(n/12);
- var month = (n % 12) ? 12 - n % 12 : 0 ;
- this.setFullYear(this.getFullYear() - back_year);
- return Date.brokenSetMonth.call(this, month);
- } else {
- return Date.brokenSetMonth.apply(this, arguments);
- }
- };
- }
- Date.MILLI = "ms";
- Date.SECOND = "s";
- Date.MINUTE = "mi";
- Date.HOUR = "h";
- Date.DAY = "d";
- Date.MONTH = "mo";
- Date.YEAR = "y";
- Date.prototype.add = function(interval, value){
- var d = this.clone();
- if (!interval || value === 0) return d;
- switch(interval.toLowerCase()){
- case Date.MILLI:
- d.setMilliseconds(this.getMilliseconds() + value);
- break;
- case Date.SECOND:
- d.setSeconds(this.getSeconds() + value);
- break;
- case Date.MINUTE:
- d.setMinutes(this.getMinutes() + value);
- break;
- case Date.HOUR:
- d.setHours(this.getHours() + value);
- break;
- case Date.DAY:
- d.setDate(this.getDate() + value);
- break;
- case Date.MONTH:
- var day = this.getDate();
- if(day > 28){
- day = Math.min(day, this.getFirstDateOfMonth().add('mo', value).getLastDateOfMonth().getDate());
- }
- d.setDate(day);
- d.setMonth(this.getMonth() + value);
- break;
- case Date.YEAR:
- d.setFullYear(this.getFullYear() + value);
- break;
- }
- return d;
- };
- Date.prototype.between = function(start, end){
- var t = this.getTime();
- return start.getTime() <= t && t <= end.getTime();
- }
- Ext.util.DelayedTask = function(fn, scope, args){
- var id = null, d, t;
- var call = function(){
- var now = new Date().getTime();
- if(now - t >= d){
- clearInterval(id);
- id = null;
- fn.apply(scope, args || []);
- }
- };
- this.delay = function(delay, newFn, newScope, newArgs){
- if(id && delay != d){
- this.cancel();
- }
- d = delay;
- t = new Date().getTime();
- fn = newFn || fn;
- scope = newScope || scope;
- args = newArgs || args;
- if(!id){
- id = setInterval(call, d);
- }
- };
- this.cancel = function(){
- if(id){
- clearInterval(id);
- id = null;
- }
- };
- };
- Ext.util.TaskRunner = function(interval){
- interval = interval || 10;
- var tasks = [], removeQueue = [];
- var id = 0;
- var running = false;
- var stopThread = function(){
- running = false;
- clearInterval(id);
- id = 0;
- };
- var startThread = function(){
- if(!running){
- running = true;
- id = setInterval(runTasks, interval);
- }
- };
- var removeTask = function(t){
- removeQueue.push(t);
- if(t.onStop){
- t.onStop.apply(t.scope || t);
- }
- };
- var runTasks = function(){
- if(removeQueue.length > 0){
- for(var i = 0, len = removeQueue.length; i < len; i++){
- tasks.remove(removeQueue[i]);
- }
- removeQueue = [];
- if(tasks.length < 1){
- stopThread();
- return;
- }
- }
- var now = new Date().getTime();
- for(var i = 0, len = tasks.length; i < len; ++i){
- var t = tasks[i];
- var itime = now - t.taskRunTime;
- if(t.interval <= itime){
- var rt = t.run.apply(t.scope || t, t.args || [++t.taskRunCount]);
- t.taskRunTime = now;
- if(rt === false || t.taskRunCount === t.repeat){
- removeTask(t);
- return;
- }
- }
- if(t.duration && t.duration <= (now - t.taskStartTime)){
- removeTask(t);
- }
- }
- };
- this.start = function(task){
- tasks.push(task);
- task.taskStartTime = new Date().getTime();
- task.taskRunTime = 0;
- task.taskRunCount = 0;
- startThread();
- return task;
- };
- this.stop = function(task){
- removeTask(task);
- return task;
- };
- this.stopAll = function(){
- stopThread();
- for(var i = 0, len = tasks.length; i < len; i++){
- if(tasks[i].onStop){
- tasks[i].onStop();
- }
- }
- tasks = [];
- removeQueue = [];
- };
- };
- Ext.TaskMgr = new Ext.util.TaskRunner();
- Ext.util.MixedCollection = function(allowFunctions, keyFn){
- this.items = [];
- this.map = {};
- this.keys = [];
- this.length = 0;
- this.addEvents(
- "clear",
- "add",
- "replace",
- "remove",
- "sort"
- );
- this.allowFunctions = allowFunctions === true;
- if(keyFn){
- this.getKey = keyFn;
- }
- Ext.util.MixedCollection.superclass.constructor.call(this);
- };
- Ext.extend(Ext.util.MixedCollection, Ext.util.Observable, {
- allowFunctions : false,
- add : function(key, o){
- if(arguments.length == 1){
- o = arguments[0];
- key = this.getKey(o);
- }
- if(typeof key == "undefined" || key === null){
- this.length++;
- this.items.push(o);
- this.keys.push(null);
- }else{
- var old = this.map[key];
- if(old){
- return this.replace(key, o);
- }
- this.length++;
- this.items.push(o);
- this.map[key] = o;
- this.keys.push(key);
- }
- this.fireEvent("add", this.length-1, o, key);
- return o;
- },
- getKey : function(o){
- return o.id;
- },
- replace : function(key, o){
- if(arguments.length == 1){
- o = arguments[0];
- key = this.getKey(o);
- }
- var old = this.item(key);
- if(typeof key == "undefined" || key === null || typeof old == "undefined"){
- return this.add(key, o);
- }
- var index = this.indexOfKey(key);
- this.items[index] = o;
- this.map[key] = o;
- this.fireEvent("replace", key, old, o);
- return o;
- },
- addAll : function(objs){
- if(arguments.length > 1 || Ext.isArray(objs)){
- var args = arguments.length > 1 ? arguments : objs;
- for(var i = 0, len = args.length; i < len; i++){
- this.add(args[i]);
- }
- }else{
- for(var key in objs){
- if(this.allowFunctions || typeof objs[key] != "function"){
- this.add(key, objs[key]);
- }
- }
- }
- },
- each : function(fn, scope){
- var items = [].concat(this.items);
- for(var i = 0, len = items.length; i < len; i++){
- if(fn.call(scope || items[i], items[i], i, len) === false){
- break;
- }
- }
- },
- eachKey : function(fn, scope){
- for(var i = 0, len = this.keys.length; i < len; i++){
- fn.call(scope || window, this.keys[i], this.items[i], i, len);
- }
- },
- find : function(fn, scope){
- for(var i = 0, len = this.items.length; i < len; i++){
- if(fn.call(scope || window, this.items[i], this.keys[i])){
- return this.items[i];
- }
- }
- return null;
- },
- insert : function(index, key, o){
- if(arguments.length == 2){
- o = arguments[1];
- key = this.getKey(o);
- }
- if(index >= this.length){
- return this.add(key, o);
- }
- this.length++;
- this.items.splice(index, 0, o);
- if(typeof key != "undefined" && key != null){
- this.map[key] = o;
- }
- this.keys.splice(index, 0, key);
- this.fireEvent("add", index, o, key);
- return o;
- },
- remove : function(o){
- return this.removeAt(this.indexOf(o));
- },
- removeAt : function(index){
- if(index < this.length && index >= 0){
- this.length--;
- var o = this.items[index];
- this.items.splice(index, 1);
- var key = this.keys[index];
- if(typeof key != "undefined"){
- delete this.map[key];
- }
- this.keys.splice(index, 1);
- this.fireEvent("remove", o, key);
- return o;
- }
- return false;
- },
- removeKey : function(key){
- return this.removeAt(this.indexOfKey(key));
- },
- getCount : function(){
- return this.length;
- },
- indexOf : function(o){
- return this.items.indexOf(o);
- },
- indexOfKey : function(key){
- return this.keys.indexOf(key);
- },
- item : function(key){
- var item = typeof this.map[key] != "undefined" ? this.map[key] : this.items[key];
- return typeof item != 'function' || this.allowFunctions ? item : null;
- },
- itemAt : function(index){
- return this.items[index];
- },
- key : function(key){
- return this.map[key];
- },
- contains : function(o){
- return this.indexOf(o) != -1;
- },
- containsKey : function(key){
- return typeof this.map[key] != "undefined";
- },
- clear : function(){
- this.length = 0;
- this.items = [];
- this.keys = [];
- this.map = {};
- this.fireEvent("clear");
- },
- first : function(){
- return this.items[0];
- },
- last : function(){
- return this.items[this.length-1];
- },
- _sort : function(property, dir, fn){
- var dsc = String(dir).toUpperCase() == "DESC" ? -1 : 1;
- fn = fn || function(a, b){
- return a-b;
- };
- var c = [], k = this.keys, items = this.items;
- for(var i = 0, len = items.length; i < len; i++){
- c[c.length] = {key: k[i], value: items[i], index: i};
- }
- c.sort(function(a, b){
- var v = fn(a[property], b[property]) * dsc;
- if(v == 0){
- v = (a.index < b.index ? -1 : 1);
- }
- return v;
- });
- for(var i = 0, len = c.length; i < len; i++){
- items[i] = c[i].value;
- k[i] = c[i].key;
- }
- this.fireEvent("sort", this);
- },
- sort : function(dir, fn){
- this._sort("value", dir, fn);
- },
- keySort : function(dir, fn){
- this._sort("key", dir, fn || function(a, b){
- return String(a).toUpperCase()-String(b).toUpperCase();
- });
- },
- getRange : function(start, end){
- var items = this.items;
- if(items.length < 1){
- return [];
- }
- start = start || 0;
- end = Math.min(typeof end == "undefined" ? this.length-1 : end, this.length-1);
- var r = [];
- if(start <= end){
- for(var i = start; i <= end; i++) {
- r[r.length] = items[i];
- }
- }else{
- for(var i = start; i >= end; i--) {
- r[r.length] = items[i];
- }
- }
- return r;
- },
- filter : function(property, value, anyMatch, caseSensitive){
- if(Ext.isEmpty(value, false)){
- return this.clone();
- }
- value = this.createValueMatcher(value, anyMatch, caseSensitive);
- return this.filterBy(function(o){
- return o && value.test(o[property]);
- });
- },
- filterBy : function(fn, scope){
- var r = new Ext.util.MixedCollection();
- r.getKey = this.getKey;
- var k = this.keys, it = this.items;
- for(var i = 0, len = it.length; i < len; i++){
- if(fn.call(scope||this, it[i], k[i])){
- r.add(k[i], it[i]);
- }
- }
- return r;
- },
- findIndex : function(property, value, start, anyMatch, caseSensitive){
- if(Ext.isEmpty(value, false)){
- return -1;
- }
- value = this.createValueMatcher(value, anyMatch, caseSensitive);
- return this.findIndexBy(function(o){
- return o && value.test(o[property]);
- }, null, start);
- },
- findIndexBy : function(fn, scope, start){
- var k = this.keys, it = this.items;
- for(var i = (start||0), len = it.length; i < len; i++){
- if(fn.call(scope||this, it[i], k[i])){
- return i;
- }
- }
- if(typeof start == 'number' && start > 0){
- for(var i = 0; i < start; i++){
- if(fn.call(scope||this, it[i], k[i])){
- return i;
- }
- }
- }
- return -1;
- },
- createValueMatcher : function(value, anyMatch, caseSensitive){
- if(!value.exec){
- value = String(value);
- value = new RegExp((anyMatch === true ? '' : '^') + Ext.escapeRe(value), caseSensitive ? '' : 'i');
- }
- return value;
- },
- clone : function(){
- var r = new Ext.util.MixedCollection();
- var k = this.keys, it = this.items;
- for(var i = 0, len = it.length; i < len; i++){
- r.add(k[i], it[i]);
- }
- r.getKey = this.getKey;
- return r;
- }
- });
- Ext.util.MixedCollection.prototype.get = Ext.util.MixedCollection.prototype.item;
- Ext.util.JSON = new (function(){
- var useHasOwn = {}.hasOwnProperty ? true : false;
- var pad = function(n) {
- return n < 10 ? "0" + n : n;
- };
- var m = {
- "b": '\b',
- "t": '\t',
- "n": '\n',
- "f": '\f',
- "r": '\r',
- '"' : '\"',
- "\": '\\'
- };
- var encodeString = function(s){
- if (/["\x00-x1f]/.test(s)) {
- return '"' + s.replace(/([x00-x1f\"])/g, function(a, b) {
- var c = m[b];
- if(c){
- return c;
- }
- c = b.charCodeAt();
- return "\u00" +
- Math.floor(c / 16).toString(16) +
- (c % 16).toString(16);
- }) + '"';
- }
- return '"' + s + '"';
- };
- var encodeArray = function(o){
- var a = ["["], b, i, l = o.length, v;
- for (i = 0; i < l; i += 1) {
- v = o[i];
- switch (typeof v) {
- case "undefined":
- case "function":
- case "unknown":
- break;
- default:
- if (b) {
- a.push(',');
- }
- a.push(v === null ? "null" : Ext.util.JSON.encode(v));
- b = true;
- }
- }
- a.push("]");
- return a.join("");
- };
- var encodeDate = function(o){
- return '"' + o.getFullYear() + "-" +
- pad(o.getMonth() + 1) + "-" +
- pad(o.getDate()) + "T" +
- pad(o.getHours()) + ":" +
- pad(o.getMinutes()) + ":" +
- pad(o.getSeconds()) + '"';
- };
- this.encode = function(o){
- if(typeof o == "undefined" || o === null){
- return "null";
- }else if(Ext.isArray(o)){
- return encodeArray(o);
- }else if(Ext.isDate(o)){
- return encodeDate(o);
- }else if(typeof o == "string"){
- return encodeString(o);
- }else if(typeof o == "number"){
- return isFinite(o) ? String(o) : "null";
- }else if(typeof o == "boolean"){
- return String(o);
- }else {
- var a = ["{"], b, i, v;
- for (i in o) {
- if(!useHasOwn || o.hasOwnProperty(i)) {
- v = o[i];
- switch (typeof v) {
- case "undefined":
- case "function":
- case "unknown":
- break;
- default:
- if(b){
- a.push(',');
- }
- a.push(this.encode(i), ":",
- v === null ? "null" : this.encode(v));
- b = true;
- }
- }
- }
- a.push("}");
- return a.join("");
- }
- };
- this.decode = function(json){
- return eval("(" + json + ')');
- };
- })();
- Ext.encode = Ext.util.JSON.encode;
- Ext.decode = Ext.util.JSON.decode;
- Ext.util.Format = function(){
- var trimRe = /^s+|s+$/g;
- return {
- ellipsis : function(value, len){
- if(value && value.length > len){
- return value.substr(0, len-3)+"...";
- }
- return value;
- },
- undef : function(value){
- return value !== undefined ? value : "";
- },
- defaultValue : function(value, defaultValue){
- return value !== undefined && value !== '' ? value : defaultValue;
- },
- htmlEncode : function(value){
- return !value ? value : String(value).replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, """);
- },
- htmlDecode : function(value){
- return !value ? value : String(value).replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, '"');
- },
- trim : function(value){
- return String(value).replace(trimRe, "");
- },
- substr : function(value, start, length){
- return String(value).substr(start, length);
- },
- lowercase : function(value){
- return String(value).toLowerCase();
- },
- uppercase : function(value){
- return String(value).toUpperCase();
- },
- capitalize : function(value){
- return !value ? value : value.charAt(0).toUpperCase() + value.substr(1).toLowerCase();
- },
- call : function(value, fn){
- if(arguments.length > 2){
- var args = Array.prototype.slice.call(arguments, 2);
- args.unshift(value);
- return eval(fn).apply(window, args);
- }else{
- return eval(fn).call(window, value);
- }
- },
- usMoney : function(v){
- v = (Math.round((v-0)*100))/100;
- v = (v == Math.floor(v)) ? v + ".00" : ((v*10 == Math.floor(v*10)) ? v + "0" : v);
- v = String(v);
- var ps = v.split('.');
- var whole = ps[0];
- var sub = ps[1] ? '.'+ ps[1] : '.00';
- var r = /(d+)(d{3})/;
- while (r.test(whole)) {
- whole = whole.replace(r, '$1' + ',' + '$2');
- }
- v = whole + sub;
- if(v.charAt(0) == '-'){
- return '-$' + v.substr(1);
- }
- return "$" + v;
- },
- date : function(v, format){
- if(!v){
- return "";
- }
- if(!Ext.isDate(v)){
- v = new Date(Date.parse(v));
- }
- return v.dateFormat(format || "m/d/Y");
- },
- dateRenderer : function(format){
- return function(v){
- return Ext.util.Format.date(v, format);
- };
- },
- stripTagsRE : /</?[^>]+>/gi,
- stripTags : function(v){
- return !v ? v : String(v).replace(this.stripTagsRE, "");
- },
- stripScriptsRe : /(?:<script.*?>)((n|r|.)*?)(?:</script>)/ig,
- stripScripts : function(v){
- return !v ? v : String(v).replace(this.stripScriptsRe, "");
- },
- fileSize : function(size){
- if(size < 1024) {
- return size + " bytes";
- } else if(size < 1048576) {
- return (Math.round(((size*10) / 1024))/10) + " KB";
- } else {
- return (Math.round(((size*10) / 1048576))/10) + " MB";
- }
- },
- math : function(){
- var fns = {};
- return function(v, a){
- if(!fns[a]){
- fns[a] = new Function('v', 'return v ' + a + ';');
- }
- return fns[a](v);
- }
- }()
- };
- }();
- Ext.XTemplate = function(){
- Ext.XTemplate.superclass.constructor.apply(this, arguments);
- var s = this.html;
- s = ['<tpl>', s, '</tpl>'].join('');
- var re = /<tplb[^>]*>((?:(?=([^<]+))2|<(?!tplb[^>]*>))*?)</tpl>/;
- var nameRe = /^<tplb[^>]*?for="(.*?)"/;
- var ifRe = /^<tplb[^>]*?if="(.*?)"/;
- var execRe = /^<tplb[^>]*?exec="(.*?)"/;
- var m, id = 0;
- var tpls = [];
- while(m = s.match(re)){
- var m2 = m[0].match(nameRe);
- var m3 = m[0].match(ifRe);
- var m4 = m[0].match(execRe);
- var exp = null, fn = null, exec = null;
- var name = m2 && m2[1] ? m2[1] : '';
- if(m3){
- exp = m3 && m3[1] ? m3[1] : null;
- if(exp){
- fn = new Function('values', 'parent', 'xindex', 'xcount', 'with(values){ return '+(Ext.util.Format.htmlDecode(exp))+'; }');
- }
- }
- if(m4){
- exp = m4 && m4[1] ? m4[1] : null;
- if(exp){
- exec = new Function('values', 'parent', 'xindex', 'xcount', 'with(values){ '+(Ext.util.Format.htmlDecode(exp))+'; }');
- }
- }
- if(name){
- switch(name){
- case '.': name = new Function('values', 'parent', 'with(values){ return values; }'); break;
- case '..': name = new Function('values', 'parent', 'with(values){ return parent; }'); break;
- default: name = new Function('values', 'parent', 'with(values){ return '+name+'; }');
- }
- }
- tpls.push({
- id: id,
- target: name,
- exec: exec,
- test: fn,
- body: m[1]||''
- });
- s = s.replace(m[0], '{xtpl'+ id + '}');
- ++id;
- }
- for(var i = tpls.length-1; i >= 0; --i){
- this.compileTpl(tpls[i]);
- }
- this.master = tpls[tpls.length-1];
- this.tpls = tpls;
- };
- Ext.extend(Ext.XTemplate, Ext.Template, {
- re : /{([w-.#]+)(?::([w.]*)(?:((.*?)?))?)?(s?[+-*\]s?[d.+-*\()]+)?}/g,
- codeRe : /{[((?:\]|.|n)*?)]}/g,
- applySubTemplate : function(id, values, parent, xindex, xcount){
- var t = this.tpls[id];
- if(t.test && !t.test.call(this, values, parent, xindex, xcount)){
- return '';
- }
- if(t.exec && t.exec.call(this, values, parent, xindex, xcount)){
- return '';
- }
- var vs = t.target ? t.target.call(this, values, parent) : values;
- parent = t.target ? values : parent;
- if(t.target && Ext.isArray(vs)){
- var buf = [];
- for(var i = 0, len = vs.length; i < len; i++){
- buf[buf.length] = t.compiled.call(this, vs[i], parent, i+1, len);
- }
- return buf.join('');
- }
- return t.compiled.call(this, vs, parent, xindex, xcount);
- },
- compileTpl : function(tpl){
- var fm = Ext.util.Format;
- var useF = this.disableFormats !== true;
- var sep = Ext.isGecko ? "+" : ",";
- var fn = function(m, name, format, args, math){
- if(name.substr(0, 4) == 'xtpl'){
- return "'"+ sep +'this.applySubTemplate('+name.substr(4)+', values, parent, xindex, xcount)'+sep+"'";
- }
- var v;
- if(name === '.'){
- v = 'values';
- }else if(name === '#'){
- v = 'xindex';
- }else if(name.indexOf('.') != -1){
- v = name;
- }else{
- v = "values['" + name + "']";
- }
- if(math){
- v = '(' + v + math + ')';
- }
- if(format && useF){
- args = args ? ',' + args : "";
- if(format.substr(0, 5) != "this."){
- format = "fm." + format + '(';
- }else{
- format = 'this.call("'+ format.substr(5) + '", ';
- args = ", values";
- }
- }else{
- args= ''; format = "("+v+" === undefined ? '' : ";
- }
- return "'"+ sep + format + v + args + ")"+sep+"'";
- };
- var codeFn = function(m, code){
- return "'"+ sep +'('+code+')'+sep+"'";
- };
- var body;
- if(Ext.isGecko){
- body = "tpl.compiled = function(values, parent, xindex, xcount){ return '" +
- tpl.body.replace(/(rn|n)/g, '\n').replace(/'/g, "\'").replace(this.re, fn).replace(this.codeRe, codeFn) +
- "';};";
- }else{
- body = ["tpl.compiled = function(values, parent, xindex, xcount){ return ['"];
- body.push(tpl.body.replace(/(rn|n)/g, '\n').replace(/'/g, "\'").replace(this.re, fn).replace(this.codeRe, codeFn));
- body.push("'].join('');};");
- body = body.join('');
- }
- eval(body);
- return this;
- },
- apply : function(values){
- return this.master.compiled.call(this, values, {}, 1, 1);
- },
- applyTemplate : function(values){
- return this.master.compiled.call(this, values, {}, 1, 1);
- },
- compile : function(){return this;}
- });
- Ext.XTemplate.from = function(el){
- el = Ext.getDom(el);
- return new Ext.XTemplate(el.value || el.innerHTML);
- };
- Ext.util.CSS = function(){
- var rules = null;
- var doc = document;
- var camelRe = /(-[a-z])/gi;
- var camelFn = function(m, a){ return a.charAt(1).toUpperCase(); };
- return {
- createStyleSheet : function(cssText, id){
- var ss;
- var head = doc.getElementsByTagName("head")[0];
- var rules = doc.createElement("style");
- rules.setAttribute("type", "text/css");
- if(id){
- rules.setAttribute("id", id);
- }
- if(Ext.isIE){
- head.appendChild(rules);
- ss = rules.styleSheet;
- ss.cssText = cssText;
- }else{
- try{
- rules.appendChild(doc.createTextNode(cssText));
- }catch(e){
- rules.cssText = cssText;
- }
- head.appendChild(rules);
- ss = rules.styleSheet ? rules.styleSheet : (rules.sheet || doc.styleSheets[doc.styleSheets.length-1]);
- }
- this.cacheStyleSheet(ss);
- return ss;
- },
- removeStyleSheet : function(id){
- var existing = doc.getElementById(id);
- if(existing){
- existing.parentNode.removeChild(existing);
- }
- },
- swapStyleSheet : function(id, url){
- this.removeStyleSheet(id);
- var ss = doc.createElement("link");
- ss.setAttribute("rel", "stylesheet");
- ss.setAttribute("type", "text/css");
- ss.setAttribute("id", id);
- ss.setAttribute("href", url);
- doc.getElementsByTagName("head")[0].appendChild(ss);
- },
- refreshCache : function(){
- return this.getRules(true);
- },
- cacheStyleSheet : function(ss){
- if(!rules){
- rules = {};
- }
- try{
- var ssRules = ss.cssRules || ss.rules;
- for(var j = ssRules.length-1; j >= 0; --j){
- rules[ssRules[j].selectorText] = ssRules[j];
- }
- }catch(e){}
- },
- getRules : function(refreshCache){
- if(rules == null || refreshCache){
- rules = {};
- var ds = doc.styleSheets;
- for(var i =0, len = ds.length; i < len; i++){
- try{
- this.cacheStyleSheet(ds[i]);
- }catch(e){}
- }
- }
- return rules;
- },
- getRule : function(selector, refreshCache){
- var rs = this.getRules(refreshCache);
- if(!Ext.isArray(selector)){
- return rs[selector];
- }
- for(var i = 0; i < selector.length; i++){
- if(rs[selector[i]]){
- return rs[selector[i]];
- }
- }
- return null;
- },
- updateRule : function(selector, property, value){
- if(!Ext.isArray(selector)){
- var rule = this.getRule(selector);
- if(rule){
- rule.style[property.replace(camelRe, camelFn)] = value;
- return true;
- }
- }else{
- for(var i = 0; i < selector.length; i++){
- if(this.updateRule(selector[i], property, value)){
- return true;
- }
- }
- }
- return false;
- }
- };
- }();
- Ext.util.ClickRepeater = function(el, config)
- {
- this.el = Ext.get(el);
- this.el.unselectable();
- Ext.apply(this, config);
- this.addEvents(
- "mousedown",
- "click",
- "mouseup"
- );
- this.el.on("mousedown", this.handleMouseDown, this);
- if(this.preventDefault || this.stopDefault){
- this.el.on("click", function(e){
- if(this.preventDefault){
- e.preventDefault();
- }
- if(this.stopDefault){
- e.stopEvent();
- }
- }, this);
- }
- if(this.handler){
- this.on("click", this.handler, this.scope || this);
- }
- Ext.util.ClickRepeater.superclass.constructor.call(this);
- };
- Ext.extend(Ext.util.ClickRepeater, Ext.util.Observable, {
- interval : 20,
- delay: 250,
- preventDefault : true,
- stopDefault : false,
- timer : 0,
- handleMouseDown : function(){
- clearTimeout(this.timer);
- this.el.blur();
- if(this.pressClass){
- this.el.addClass(this.pressClass);
- }
- this.mousedownTime = new Date();
- Ext.getDoc().on("mouseup", this.handleMouseUp, this);
- this.el.on("mouseout", this.handleMouseOut, this);
- this.fireEvent("mousedown", this);
- this.fireEvent("click", this);
- if (this.accelerate) {
- this.delay = 400;
- }
- this.timer = this.click.defer(this.delay || this.interval, this);
- },
- click : function(){
- this.fireEvent("click", this);
- this.timer = this.click.defer(this.accelerate ?
- this.easeOutExpo(this.mousedownTime.getElapsed(),
- 400,
- -390,
- 12000) :
- this.interval, this);
- },
- easeOutExpo : function (t, b, c, d) {
- return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
- },
- handleMouseOut : function(){
- clearTimeout(this.timer);
- if(this.pressClass){
- this.el.removeClass(this.pressClass);
- }
- this.el.on("mouseover", this.handleMouseReturn, this);
- },
- handleMouseReturn : function(){
- this.el.un("mouseover", this.handleMouseReturn);
- if(this.pressClass){
- this.el.addClass(this.pressClass);
- }
- this.click();
- },
- handleMouseUp : function(){
- clearTimeout(this.timer);
- this.el.un("mouseover", this.handleMouseReturn);
- this.el.un("mouseout", this.handleMouseOut);
- Ext.getDoc().un("mouseup", this.handleMouseUp);
- this.el.removeClass(this.pressClass);
- this.fireEvent("mouseup", this);
- }
- });
- Ext.KeyNav = function(el, config){
- this.el = Ext.get(el);
- Ext.apply(this, config);
- if(!this.disabled){
- this.disabled = true;
- this.enable();
- }
- };
- Ext.KeyNav.prototype = {
- disabled : false,
- defaultEventAction: "stopEvent",
- forceKeyDown : false,
- prepareEvent : function(e){
- var k = e.getKey();
- var h = this.keyToHandler[k];
- if(Ext.isSafari && h && k >= 37 && k <= 40){
- e.stopEvent();
- }
- },
- relay : function(e){
- var k = e.getKey();
- var h = this.keyToHandler[k];
- if(h && this[h]){
- if(this.doRelay(e, this[h], h) !== true){
- e[this.defaultEventAction]();
- }
- }
- },
- doRelay : function(e, h, hname){
- return h.call(this.scope || this, e);
- },
- enter : false,
- left : false,
- right : false,
- up : false,
- down : false,
- tab : false,
- esc : false,
- pageUp : false,
- pageDown : false,
- del : false,
- home : false,
- end : false,
- keyToHandler : {
- 37 : "left",
- 39 : "right",
- 38 : "up",
- 40 : "down",
- 33 : "pageUp",
- 34 : "pageDown",
- 46 : "del",
- 36 : "home",
- 35 : "end",
- 13 : "enter",
- 27 : "esc",
- 9 : "tab"
- },
- enable: function(){
- if(this.disabled){
- if(this.forceKeyDown || Ext.isIE || Ext.isAir){
- this.el.on("keydown", this.relay, this);
- }else{
- this.el.on("keydown", this.prepareEvent, this);
- this.el.on("keypress", this.relay, this);
- }
- this.disabled = false;
- }
- },
- disable: function(){
- if(!this.disabled){
- if(this.forceKeyDown || Ext.isIE || Ext.isAir){
- this.el.un("keydown", this.relay);
- }else{
- this.el.un("keydown", this.prepareEvent);
- this.el.un("keypress", this.relay);
- }
- this.disabled = true;
- }
- }
- };
- Ext.KeyMap = function(el, config, eventName){
- this.el = Ext.get(el);
- this.eventName = eventName || "keydown";
- this.bindings = [];
- if(config){
- this.addBinding(config);
- }
- this.enable();
- };
- Ext.KeyMap.prototype = {
- stopEvent : false,
- addBinding : function(config){
- if(Ext.isArray(config)){
- for(var i = 0, len = config.length; i < len; i++){
- this.addBinding(config[i]);
- }
- return;
- }
- var keyCode = config.key,
- shift = config.shift,
- ctrl = config.ctrl,
- alt = config.alt,
- fn = config.fn || config.handler,
- scope = config.scope;
- if(typeof keyCode == "string"){
- var ks = [];
- var keyString = keyCode.toUpperCase();
- for(var j = 0, len = keyString.length; j < len; j++){
- ks.push(keyString.charCodeAt(j));
- }
- keyCode = ks;
- }
- var keyArray = Ext.isArray(keyCode);
- var handler = function(e){
- if((!shift || e.shiftKey) && (!ctrl || e.ctrlKey) && (!alt || e.altKey)){
- var k = e.getKey();
- if(keyArray){
- for(var i = 0, len = keyCode.length; i < len; i++){
- if(keyCode[i] == k){
- if(this.stopEvent){
- e.stopEvent();
- }
- fn.call(scope || window, k, e);
- return;
- }
- }
- }else{
- if(k == keyCode){
- if(this.stopEvent){
- e.stopEvent();
- }
- fn.call(scope || window, k, e);
- }
- }
- }
- };
- this.bindings.push(handler);
- },
- on : function(key, fn, scope){
- var keyCode, shift, ctrl, alt;
- if(typeof key == "object" && !Ext.isArray(key)){
- keyCode = key.key;
- shift = key.shift;
- ctrl = key.ctrl;
- alt = key.alt;
- }else{
- keyCode = key;
- }
- this.addBinding({
- key: keyCode,
- shift: shift,
- ctrl: ctrl,
- alt: alt,
- fn: fn,
- scope: scope
- })
- },
- handleKeyDown : function(e){
- if(this.enabled){
- var b = this.bindings;
- for(var i = 0, len = b.length; i < len; i++){
- b[i].call(this, e);
- }
- }
- },
- isEnabled : function(){
- return this.enabled;
- },
- enable: function(){
- if(!this.enabled){
- this.el.on(this.eventName, this.handleKeyDown, this);
- this.enabled = true;
- }
- },
- disable: function(){
- if(this.enabled){
- this.el.removeListener(this.eventName, this.handleKeyDown, this);
- this.enabled = false;
- }
- }
- };
- Ext.util.TextMetrics = function(){
- var shared;
- return {
- measure : function(el, text, fixedWidth){
- if(!shared){
- shared = Ext.util.TextMetrics.Instance(el, fixedWidth);
- }
- shared.bind(el);
- shared.setFixedWidth(fixedWidth || 'auto');
- return shared.getSize(text);
- },
- createInstance : function(el, fixedWidth){
- return Ext.util.TextMetrics.Instance(el, fixedWidth);
- }
- };
- }();
- Ext.util.TextMetrics.Instance = function(bindTo, fixedWidth){
- var ml = new Ext.Element(document.createElement('div'));
- document.body.appendChild(ml.dom);
- ml.position('absolute');
- ml.setLeftTop(-1000, -1000);
- ml.hide();
- if(fixedWidth){
- ml.setWidth(fixedWidth);
- }
- var instance = {
- getSize : function(text){
- ml.update(text);
- var s = ml.getSize();
- ml.update('');
- return s;
- },
- bind : function(el){
- ml.setStyle(
- Ext.fly(el).getStyles('font-size','font-style', 'font-weight', 'font-family','line-height')
- );
- },
- setFixedWidth : function(width){
- ml.setWidth(width);
- },
- getWidth : function(text){
- ml.dom.style.width = 'auto';
- return this.getSize(text).width;
- },
- getHeight : function(text){
- return this.getSize(text).height;
- }
- };
- instance.bind(bindTo);
- return instance;
- };
- Ext.Element.measureText = Ext.util.TextMetrics.measure;
- (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; },
- 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(typeof pad == "number"){
- pad = {left: pad, right:pad, top:pad, bottom:pad};
- }
- pad = pad || this.defaultPadding;
- var b = Ext.get(this.getEl()).getBox();
- var ce = Ext.get(constrainTo);
- var s = ce.getScroll();
- var 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]+s.left, y: xy[1]+s.top, width: cd.clientWidth, height: cd.clientHeight};
- }
- var topSpace = b.y - c.y;
- var 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 = !Dom.hasClass(node, 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,
- initalized: 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][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 (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();
- }
- 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());