ext-all-debug.js
资源名称:EXT_study.rar [点击查看]
上传用户:zaktkj
上传日期:2022-08-08
资源大小:5770k
文件大小:910k
源码类别:
JavaScript
开发平台:
JavaScript
- var diffY = Math.abs(this.startY - e.getPageY());
- if (diffX > this.clickPixelThresh ||
- diffY > this.clickPixelThresh) {
- this.startDrag(this.startX, this.startY);
- }
- }
- if (this.dragThreshMet) {
- this.dragCurrent.b4Drag(e);
- this.dragCurrent.onDrag(e);
- if(!this.dragCurrent.moveOnly){
- this.fireEvents(e, false);
- }
- }
- this.stopEvent(e);
- return true;
- },
- fireEvents: function(e, isDrop) {
- var dc = this.dragCurrent;
- if (!dc || dc.isLocked()) {
- return;
- }
- var pt = e.getPoint();
- var oldOvers = [];
- var outEvts = [];
- var overEvts = [];
- var dropEvts = [];
- var enterEvts = [];
- for (var i in this.dragOvers) {
- var ddo = this.dragOvers[i];
- if (! this.isTypeOfDD(ddo)) {
- continue;
- }
- if (! this.isOverTarget(pt, ddo, this.mode)) {
- outEvts.push( ddo );
- }
- oldOvers[i] = true;
- delete this.dragOvers[i];
- }
- for (var sGroup in dc.groups) {
- if ("string" != typeof sGroup) {
- continue;
- }
- for (i in this.ids[sGroup]) {
- var oDD = this.ids[sGroup][i];
- if (! this.isTypeOfDD(oDD)) {
- continue;
- }
- if (oDD.isTarget && !oDD.isLocked() && oDD != dc) {
- if (this.isOverTarget(pt, oDD, this.mode)) {
- if (isDrop) {
- dropEvts.push( oDD );
- } else {
- if (!oldOvers[oDD.id]) {
- enterEvts.push( oDD );
- } else {
- overEvts.push( oDD );
- }
- this.dragOvers[oDD.id] = oDD;
- }
- }
- }
- }
- }
- if (this.mode) {
- if (outEvts.length) {
- dc.b4DragOut(e, outEvts);
- dc.onDragOut(e, outEvts);
- }
- if (enterEvts.length) {
- dc.onDragEnter(e, enterEvts);
- }
- if (overEvts.length) {
- dc.b4DragOver(e, overEvts);
- dc.onDragOver(e, overEvts);
- }
- if (dropEvts.length) {
- dc.b4DragDrop(e, dropEvts);
- dc.onDragDrop(e, dropEvts);
- }
- } else {
- var len = 0;
- for (i=0, len=outEvts.length; i<len; ++i) {
- dc.b4DragOut(e, outEvts[i].id);
- dc.onDragOut(e, outEvts[i].id);
- }
- for (i=0,len=enterEvts.length; i<len; ++i) {
- dc.onDragEnter(e, enterEvts[i].id);
- }
- for (i=0,len=overEvts.length; i<len; ++i) {
- dc.b4DragOver(e, overEvts[i].id);
- dc.onDragOver(e, overEvts[i].id);
- }
- for (i=0, len=dropEvts.length; i<len; ++i) {
- dc.b4DragDrop(e, dropEvts[i].id);
- dc.onDragDrop(e, dropEvts[i].id);
- }
- }
- if (isDrop && !dropEvts.length) {
- dc.onInvalidDrop(e);
- }
- },
- getBestMatch: function(dds) {
- var winner = null;
- var len = dds.length;
- if (len == 1) {
- winner = dds[0];
- } else {
- for (var i=0; i<len; ++i) {
- var dd = dds[i];
- if (dd.cursorIsOver) {
- winner = dd;
- break;
- } else {
- if (!winner ||
- winner.overlap.getArea() < dd.overlap.getArea()) {
- winner = dd;
- }
- }
- }
- }
- return winner;
- },
- refreshCache: function(groups) {
- for (var sGroup in groups) {
- if ("string" != typeof sGroup) {
- continue;
- }
- for (var i in this.ids[sGroup]) {
- var oDD = this.ids[sGroup][i];
- if (this.isTypeOfDD(oDD)) {
- var loc = this.getLocation(oDD);
- if (loc) {
- this.locationCache[oDD.id] = loc;
- } else {
- delete this.locationCache[oDD.id];
- }
- }
- }
- }
- },
- verifyEl: function(el) {
- if (el) {
- var parent;
- if(Ext.isIE){
- try{
- parent = el.offsetParent;
- }catch(e){}
- }else{
- parent = el.offsetParent;
- }
- if (parent) {
- return true;
- }
- }
- return false;
- },
- getLocation: function(oDD) {
- if (! this.isTypeOfDD(oDD)) {
- return null;
- }
- var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l;
- try {
- pos= Ext.lib.Dom.getXY(el);
- } catch (e) { }
- if (!pos) {
- return null;
- }
- x1 = pos[0];
- x2 = x1 + el.offsetWidth;
- y1 = pos[1];
- y2 = y1 + el.offsetHeight;
- t = y1 - oDD.padding[0];
- r = x2 + oDD.padding[1];
- b = y2 + oDD.padding[2];
- l = x1 - oDD.padding[3];
- return new Ext.lib.Region( t, r, b, l );
- },
- isOverTarget: function(pt, oTarget, intersect) {
- var loc = this.locationCache[oTarget.id];
- if (!loc || !this.useCache) {
- loc = this.getLocation(oTarget);
- this.locationCache[oTarget.id] = loc;
- }
- if (!loc) {
- return false;
- }
- oTarget.cursorIsOver = loc.contains( pt );
- var dc = this.dragCurrent;
- if (!dc || !dc.getTargetCoord ||
- (!intersect && !dc.constrainX && !dc.constrainY)) {
- return oTarget.cursorIsOver;
- }
- oTarget.overlap = null;
- var pos = dc.getTargetCoord(pt.x, pt.y);
- var el = dc.getDragEl();
- var curRegion = new Ext.lib.Region( pos.y,
- pos.x + el.offsetWidth,
- pos.y + el.offsetHeight,
- pos.x );
- var overlap = curRegion.intersect(loc);
- if (overlap) {
- oTarget.overlap = overlap;
- return (intersect) ? true : oTarget.cursorIsOver;
- } else {
- return false;
- }
- },
- _onUnload: function(e, me) {
- Ext.dd.DragDropMgr.unregAll();
- },
- unregAll: function() {
- if (this.dragCurrent) {
- this.stopDrag();
- this.dragCurrent = null;
- }
- this._execOnAll("unreg", []);
- for (var i in this.elementCache) {
- delete this.elementCache[i];
- }
- this.elementCache = {};
- this.ids = {};
- },
- elementCache: {},
- getElWrapper: function(id) {
- var oWrapper = this.elementCache[id];
- if (!oWrapper || !oWrapper.el) {
- oWrapper = this.elementCache[id] =
- new this.ElementWrapper(Ext.getDom(id));
- }
- return oWrapper;
- },
- getElement: function(id) {
- return Ext.getDom(id);
- },
- getCss: function(id) {
- var el = Ext.getDom(id);
- return (el) ? el.style : null;
- },
- ElementWrapper: function(el) {
- this.el = el || null;
- this.id = this.el && el.id;
- this.css = this.el && el.style;
- },
- getPosX: function(el) {
- return Ext.lib.Dom.getX(el);
- },
- getPosY: function(el) {
- return Ext.lib.Dom.getY(el);
- },
- swapNode: function(n1, n2) {
- if (n1.swapNode) {
- n1.swapNode(n2);
- } else {
- var p = n2.parentNode;
- var s = n2.nextSibling;
- if (s == n1) {
- p.insertBefore(n1, n2);
- } else if (n2 == n1.nextSibling) {
- p.insertBefore(n2, n1);
- } else {
- n1.parentNode.replaceChild(n2, n1);
- p.insertBefore(n1, s);
- }
- }
- },
- getScroll: function () {
- var t, l, dde=document.documentElement, db=document.body;
- if (dde && (dde.scrollTop || dde.scrollLeft)) {
- t = dde.scrollTop;
- l = dde.scrollLeft;
- } else if (db) {
- t = db.scrollTop;
- l = db.scrollLeft;
- } else {
- }
- return { top: t, left: l };
- },
- getStyle: function(el, styleProp) {
- return Ext.fly(el).getStyle(styleProp);
- },
- getScrollTop: function () { return this.getScroll().top; },
- getScrollLeft: function () { return this.getScroll().left; },
- moveToEl: function (moveEl, targetEl) {
- var aCoord = Ext.lib.Dom.getXY(targetEl);
- Ext.lib.Dom.setXY(moveEl, aCoord);
- },
- numericSort: function(a, b) { return (a - b); },
- _timeoutCount: 0,
- _addListeners: function() {
- var DDM = Ext.dd.DDM;
- if ( Ext.lib.Event && document ) {
- DDM._onLoad();
- } else {
- if (DDM._timeoutCount > 2000) {
- } else {
- setTimeout(DDM._addListeners, 10);
- if (document && document.body) {
- DDM._timeoutCount += 1;
- }
- }
- }
- },
- handleWasClicked: function(node, id) {
- if (this.isHandle(id, node.id)) {
- return true;
- } else {
- var p = node.parentNode;
- while (p) {
- if (this.isHandle(id, p.id)) {
- return true;
- } else {
- p = p.parentNode;
- }
- }
- }
- return false;
- }
- };
- }();
- Ext.dd.DDM = Ext.dd.DragDropMgr;
- Ext.dd.DDM._addListeners();
- }
- Ext.dd.DD = function(id, sGroup, config) {
- if (id) {
- this.init(id, sGroup, config);
- }
- };
- Ext.extend(Ext.dd.DD, Ext.dd.DragDrop, {
- scroll: true,
- autoOffset: function(iPageX, iPageY) {
- var x = iPageX - this.startPageX;
- var y = iPageY - this.startPageY;
- this.setDelta(x, y);
- },
- setDelta: function(iDeltaX, iDeltaY) {
- this.deltaX = iDeltaX;
- this.deltaY = iDeltaY;
- },
- setDragElPos: function(iPageX, iPageY) {
- var el = this.getDragEl();
- this.alignElWithMouse(el, iPageX, iPageY);
- },
- alignElWithMouse: function(el, iPageX, iPageY) {
- var oCoord = this.getTargetCoord(iPageX, iPageY);
- var fly = el.dom ? el : Ext.fly(el, '_dd');
- if (!this.deltaSetXY) {
- var aCoord = [oCoord.x, oCoord.y];
- fly.setXY(aCoord);
- var newLeft = fly.getLeft(true);
- var newTop = fly.getTop(true);
- this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ];
- } else {
- fly.setLeftTop(oCoord.x + this.deltaSetXY[0], oCoord.y + this.deltaSetXY[1]);
- }
- this.cachePosition(oCoord.x, oCoord.y);
- this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
- return oCoord;
- },
- cachePosition: function(iPageX, iPageY) {
- if (iPageX) {
- this.lastPageX = iPageX;
- this.lastPageY = iPageY;
- } else {
- var aCoord = Ext.lib.Dom.getXY(this.getEl());
- this.lastPageX = aCoord[0];
- this.lastPageY = aCoord[1];
- }
- },
- autoScroll: function(x, y, h, w) {
- if (this.scroll) {
- var clientH = Ext.lib.Dom.getViewHeight();
- var clientW = Ext.lib.Dom.getViewWidth();
- var st = this.DDM.getScrollTop();
- var sl = this.DDM.getScrollLeft();
- var bot = h + y;
- var right = w + x;
- var toBot = (clientH + st - y - this.deltaY);
- var toRight = (clientW + sl - x - this.deltaX);
- var thresh = 40;
- var scrAmt = (document.all) ? 80 : 30;
- if ( bot > clientH && toBot < thresh ) {
- window.scrollTo(sl, st + scrAmt);
- }
- if ( y < st && st > 0 && y - st < thresh ) {
- window.scrollTo(sl, st - scrAmt);
- }
- if ( right > clientW && toRight < thresh ) {
- window.scrollTo(sl + scrAmt, st);
- }
- if ( x < sl && sl > 0 && x - sl < thresh ) {
- window.scrollTo(sl - scrAmt, st);
- }
- }
- },
- getTargetCoord: function(iPageX, iPageY) {
- var x = iPageX - this.deltaX;
- var y = iPageY - this.deltaY;
- if (this.constrainX) {
- if (x < this.minX) { x = this.minX; }
- if (x > this.maxX) { x = this.maxX; }
- }
- if (this.constrainY) {
- if (y < this.minY) { y = this.minY; }
- if (y > this.maxY) { y = this.maxY; }
- }
- x = this.getTick(x, this.xTicks);
- y = this.getTick(y, this.yTicks);
- return {x:x, y:y};
- },
- applyConfig: function() {
- Ext.dd.DD.superclass.applyConfig.call(this);
- this.scroll = (this.config.scroll !== false);
- },
- b4MouseDown: function(e) {
- this.autoOffset(e.getPageX(),
- e.getPageY());
- },
- b4Drag: function(e) {
- this.setDragElPos(e.getPageX(),
- e.getPageY());
- },
- toString: function() {
- return ("DD " + this.id);
- }
- });
- Ext.dd.DDProxy = function(id, sGroup, config) {
- if (id) {
- this.init(id, sGroup, config);
- this.initFrame();
- }
- };
- Ext.dd.DDProxy.dragElId = "ygddfdiv";
- Ext.extend(Ext.dd.DDProxy, Ext.dd.DD, {
- resizeFrame: true,
- centerFrame: false,
- createFrame: function() {
- var self = this;
- var body = document.body;
- if (!body || !body.firstChild) {
- setTimeout( function() { self.createFrame(); }, 50 );
- return;
- }
- var div = this.getDragEl();
- if (!div) {
- div = document.createElement("div");
- div.id = this.dragElId;
- var s = div.style;
- s.position = "absolute";
- s.visibility = "hidden";
- s.cursor = "move";
- s.border = "2px solid #aaa";
- s.zIndex = 999;
- body.insertBefore(div, body.firstChild);
- }
- },
- initFrame: function() {
- this.createFrame();
- },
- applyConfig: function() {
- Ext.dd.DDProxy.superclass.applyConfig.call(this);
- this.resizeFrame = (this.config.resizeFrame !== false);
- this.centerFrame = (this.config.centerFrame);
- this.setDragElId(this.config.dragElId || Ext.dd.DDProxy.dragElId);
- },
- showFrame: function(iPageX, iPageY) {
- var el = this.getEl();
- var dragEl = this.getDragEl();
- var s = dragEl.style;
- this._resizeProxy();
- if (this.centerFrame) {
- this.setDelta( Math.round(parseInt(s.width, 10)/2),
- Math.round(parseInt(s.height, 10)/2) );
- }
- this.setDragElPos(iPageX, iPageY);
- Ext.fly(dragEl).show();
- },
- _resizeProxy: function() {
- if (this.resizeFrame) {
- var el = this.getEl();
- Ext.fly(this.getDragEl()).setSize(el.offsetWidth, el.offsetHeight);
- }
- },
- b4MouseDown: function(e) {
- var x = e.getPageX();
- var y = e.getPageY();
- this.autoOffset(x, y);
- this.setDragElPos(x, y);
- },
- b4StartDrag: function(x, y) {
- this.showFrame(x, y);
- },
- b4EndDrag: function(e) {
- Ext.fly(this.getDragEl()).hide();
- },
- endDrag: function(e) {
- var lel = this.getEl();
- var del = this.getDragEl();
- del.style.visibility = "";
- this.beforeMove();
- lel.style.visibility = "hidden";
- Ext.dd.DDM.moveToEl(lel, del);
- del.style.visibility = "hidden";
- lel.style.visibility = "";
- this.afterDrag();
- },
- beforeMove : function(){
- },
- afterDrag : function(){
- },
- toString: function() {
- return ("DDProxy " + this.id);
- }
- });
- Ext.dd.DDTarget = function(id, sGroup, config) {
- if (id) {
- this.initTarget(id, sGroup, config);
- }
- };
- Ext.extend(Ext.dd.DDTarget, Ext.dd.DragDrop, {
- toString: function() {
- return ("DDTarget " + this.id);
- }
- });
- Ext.dd.DragTracker = function(config){
- Ext.apply(this, config);
- this.addEvents(
- 'mousedown',
- 'mouseup',
- 'mousemove',
- 'dragstart',
- 'dragend',
- 'drag'
- );
- this.dragRegion = new Ext.lib.Region(0,0,0,0);
- if(this.el){
- this.initEl(this.el);
- }
- }
- Ext.extend(Ext.dd.DragTracker, Ext.util.Observable, {
- active: false,
- tolerance: 5,
- autoStart: false,
- initEl: function(el){
- this.el = Ext.get(el);
- el.on('mousedown', this.onMouseDown, this,
- this.delegate ? {delegate: this.delegate} : undefined);
- },
- destroy : function(){
- this.el.un('mousedown', this.onMouseDown, this);
- },
- onMouseDown: function(e, target){
- if(this.fireEvent('mousedown', this, e) !== false && this.onBeforeStart(e) !== false){
- this.startXY = this.lastXY = e.getXY();
- this.dragTarget = this.delegate ? target : this.el.dom;
- e.preventDefault();
- var doc = Ext.getDoc();
- doc.on('mouseup', this.onMouseUp, this);
- doc.on('mousemove', this.onMouseMove, this);
- doc.on('selectstart', this.stopSelect, this);
- if(this.autoStart){
- this.timer = this.triggerStart.defer(this.autoStart === true ? 1000 : this.autoStart, this);
- }
- }
- },
- onMouseMove: function(e, target){
- e.preventDefault();
- var xy = e.getXY(), s = this.startXY;
- this.lastXY = xy;
- if(!this.active){
- if(Math.abs(s[0]-xy[0]) > this.tolerance || Math.abs(s[1]-xy[1]) > this.tolerance){
- this.triggerStart();
- }else{
- return;
- }
- }
- this.fireEvent('mousemove', this, e);
- this.onDrag(e);
- this.fireEvent('drag', this, e);
- },
- onMouseUp: function(e){
- var doc = Ext.getDoc();
- doc.un('mousemove', this.onMouseMove, this);
- doc.un('mouseup', this.onMouseUp, this);
- doc.un('selectstart', this.stopSelect, this);
- e.preventDefault();
- this.clearStart();
- this.active = false;
- delete this.elRegion;
- this.fireEvent('mouseup', this, e);
- this.onEnd(e);
- this.fireEvent('dragend', this, e);
- },
- triggerStart: function(isTimer){
- this.clearStart();
- this.active = true;
- this.onStart(this.startXY);
- this.fireEvent('dragstart', this, this.startXY);
- },
- clearStart : function(){
- if(this.timer){
- clearTimeout(this.timer);
- delete this.timer;
- }
- },
- stopSelect : function(e){
- e.stopEvent();
- return false;
- },
- onBeforeStart : function(e){
- },
- onStart : function(xy){
- },
- onDrag : function(e){
- },
- onEnd : function(e){
- },
- getDragTarget : function(){
- return this.dragTarget;
- },
- getDragCt : function(){
- return this.el;
- },
- getXY : function(constrain){
- return constrain ?
- this.constrainModes[constrain].call(this, this.lastXY) : this.lastXY;
- },
- getOffset : function(constrain){
- var xy = this.getXY(constrain);
- var s = this.startXY;
- return [s[0]-xy[0], s[1]-xy[1]];
- },
- constrainModes: {
- 'point' : function(xy){
- if(!this.elRegion){
- this.elRegion = this.getDragCt().getRegion();
- }
- var dr = this.dragRegion;
- dr.left = xy[0];
- dr.top = xy[1];
- dr.right = xy[0];
- dr.bottom = xy[1];
- dr.constrainTo(this.elRegion);
- return [dr.left, dr.top];
- }
- }
- });
- Ext.dd.ScrollManager = function(){
- var ddm = Ext.dd.DragDropMgr;
- var els = {};
- var dragEl = null;
- var proc = {};
- var onStop = function(e){
- dragEl = null;
- clearProc();
- };
- var triggerRefresh = function(){
- if(ddm.dragCurrent){
- ddm.refreshCache(ddm.dragCurrent.groups);
- }
- };
- var doScroll = function(){
- if(ddm.dragCurrent){
- var dds = Ext.dd.ScrollManager;
- var inc = proc.el.ddScrollConfig ?
- proc.el.ddScrollConfig.increment : dds.increment;
- if(!dds.animate){
- if(proc.el.scroll(proc.dir, inc)){
- triggerRefresh();
- }
- }else{
- proc.el.scroll(proc.dir, inc, true, dds.animDuration, triggerRefresh);
- }
- }
- };
- var clearProc = function(){
- if(proc.id){
- clearInterval(proc.id);
- }
- proc.id = 0;
- proc.el = null;
- proc.dir = "";
- };
- var startProc = function(el, dir){
- clearProc();
- proc.el = el;
- proc.dir = dir;
- proc.id = setInterval(doScroll, Ext.dd.ScrollManager.frequency);
- };
- var onFire = function(e, isDrop){
- if(isDrop || !ddm.dragCurrent){ return; }
- var dds = Ext.dd.ScrollManager;
- if(!dragEl || dragEl != ddm.dragCurrent){
- dragEl = ddm.dragCurrent;
- dds.refreshCache();
- }
- var xy = Ext.lib.Event.getXY(e);
- var pt = new Ext.lib.Point(xy[0], xy[1]);
- for(var id in els){
- var el = els[id], r = el._region;
- var c = el.ddScrollConfig ? el.ddScrollConfig : dds;
- if(r && r.contains(pt) && el.isScrollable()){
- if(r.bottom - pt.y <= c.vthresh){
- if(proc.el != el){
- startProc(el, "down");
- }
- return;
- }else if(r.right - pt.x <= c.hthresh){
- if(proc.el != el){
- startProc(el, "left");
- }
- return;
- }else if(pt.y - r.top <= c.vthresh){
- if(proc.el != el){
- startProc(el, "up");
- }
- return;
- }else if(pt.x - r.left <= c.hthresh){
- if(proc.el != el){
- startProc(el, "right");
- }
- return;
- }
- }
- }
- clearProc();
- };
- ddm.fireEvents = ddm.fireEvents.createSequence(onFire, ddm);
- ddm.stopDrag = ddm.stopDrag.createSequence(onStop, ddm);
- return {
- register : function(el){
- if(Ext.isArray(el)){
- for(var i = 0, len = el.length; i < len; i++) {
- this.register(el[i]);
- }
- }else{
- el = Ext.get(el);
- els[el.id] = el;
- }
- },
- unregister : function(el){
- if(Ext.isArray(el)){
- for(var i = 0, len = el.length; i < len; i++) {
- this.unregister(el[i]);
- }
- }else{
- el = Ext.get(el);
- delete els[el.id];
- }
- },
- vthresh : 25,
- hthresh : 25,
- increment : 100,
- frequency : 500,
- animate: true,
- animDuration: .4,
- refreshCache : function(){
- for(var id in els){
- if(typeof els[id] == 'object'){
- els[id]._region = els[id].getRegion();
- }
- }
- }
- };
- }();
- Ext.dd.Registry = function(){
- var elements = {};
- var handles = {};
- var autoIdSeed = 0;
- var getId = function(el, autogen){
- if(typeof el == "string"){
- return el;
- }
- var id = el.id;
- if(!id && autogen !== false){
- id = "extdd-" + (++autoIdSeed);
- el.id = id;
- }
- return id;
- };
- return {
- register : function(el, data){
- data = data || {};
- if(typeof el == "string"){
- el = document.getElementById(el);
- }
- data.ddel = el;
- elements[getId(el)] = data;
- if(data.isHandle !== false){
- handles[data.ddel.id] = data;
- }
- if(data.handles){
- var hs = data.handles;
- for(var i = 0, len = hs.length; i < len; i++){
- handles[getId(hs[i])] = data;
- }
- }
- },
- unregister : function(el){
- var id = getId(el, false);
- var data = elements[id];
- if(data){
- delete elements[id];
- if(data.handles){
- var hs = data.handles;
- for(var i = 0, len = hs.length; i < len; i++){
- delete handles[getId(hs[i], false)];
- }
- }
- }
- },
- getHandle : function(id){
- if(typeof id != "string"){
- id = id.id;
- }
- return handles[id];
- },
- getHandleFromEvent : function(e){
- var t = Ext.lib.Event.getTarget(e);
- return t ? handles[t.id] : null;
- },
- getTarget : function(id){
- if(typeof id != "string"){
- id = id.id;
- }
- return elements[id];
- },
- getTargetFromEvent : function(e){
- var t = Ext.lib.Event.getTarget(e);
- return t ? elements[t.id] || handles[t.id] : null;
- }
- };
- }();
- Ext.dd.StatusProxy = function(config){
- Ext.apply(this, config);
- this.id = this.id || Ext.id();
- this.el = new Ext.Layer({
- dh: {
- id: this.id, tag: "div", cls: "x-dd-drag-proxy "+this.dropNotAllowed, children: [
- {tag: "div", cls: "x-dd-drop-icon"},
- {tag: "div", cls: "x-dd-drag-ghost"}
- ]
- },
- shadow: !config || config.shadow !== false
- });
- this.ghost = Ext.get(this.el.dom.childNodes[1]);
- this.dropStatus = this.dropNotAllowed;
- };
- Ext.dd.StatusProxy.prototype = {
- dropAllowed : "x-dd-drop-ok",
- dropNotAllowed : "x-dd-drop-nodrop",
- setStatus : function(cssClass){
- cssClass = cssClass || this.dropNotAllowed;
- if(this.dropStatus != cssClass){
- this.el.replaceClass(this.dropStatus, cssClass);
- this.dropStatus = cssClass;
- }
- },
- reset : function(clearGhost){
- this.el.dom.className = "x-dd-drag-proxy " + this.dropNotAllowed;
- this.dropStatus = this.dropNotAllowed;
- if(clearGhost){
- this.ghost.update("");
- }
- },
- update : function(html){
- if(typeof html == "string"){
- this.ghost.update(html);
- }else{
- this.ghost.update("");
- html.style.margin = "0";
- this.ghost.dom.appendChild(html);
- }
- },
- getEl : function(){
- return this.el;
- },
- getGhost : function(){
- return this.ghost;
- },
- hide : function(clear){
- this.el.hide();
- if(clear){
- this.reset(true);
- }
- },
- stop : function(){
- if(this.anim && this.anim.isAnimated && this.anim.isAnimated()){
- this.anim.stop();
- }
- },
- show : function(){
- this.el.show();
- },
- sync : function(){
- this.el.sync();
- },
- repair : function(xy, callback, scope){
- this.callback = callback;
- this.scope = scope;
- if(xy && this.animRepair !== false){
- this.el.addClass("x-dd-drag-repair");
- this.el.hideUnders(true);
- this.anim = this.el.shift({
- duration: this.repairDuration || .5,
- easing: 'easeOut',
- xy: xy,
- stopFx: true,
- callback: this.afterRepair,
- scope: this
- });
- }else{
- this.afterRepair();
- }
- },
- afterRepair : function(){
- this.hide(true);
- if(typeof this.callback == "function"){
- this.callback.call(this.scope || this);
- }
- this.callback = null;
- this.scope = null;
- }
- };
- Ext.dd.DragSource = function(el, config){
- this.el = Ext.get(el);
- if(!this.dragData){
- this.dragData = {};
- }
- Ext.apply(this, config);
- if(!this.proxy){
- this.proxy = new Ext.dd.StatusProxy();
- }
- Ext.dd.DragSource.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group,
- {dragElId : this.proxy.id, resizeFrame: false, isTarget: false, scroll: this.scroll === true});
- this.dragging = false;
- };
- Ext.extend(Ext.dd.DragSource, Ext.dd.DDProxy, {
- dropAllowed : "x-dd-drop-ok",
- dropNotAllowed : "x-dd-drop-nodrop",
- getDragData : function(e){
- return this.dragData;
- },
- onDragEnter : function(e, id){
- var target = Ext.dd.DragDropMgr.getDDById(id);
- this.cachedTarget = target;
- if(this.beforeDragEnter(target, e, id) !== false){
- if(target.isNotifyTarget){
- var status = target.notifyEnter(this, e, this.dragData);
- this.proxy.setStatus(status);
- }else{
- this.proxy.setStatus(this.dropAllowed);
- }
- if(this.afterDragEnter){
- this.afterDragEnter(target, e, id);
- }
- }
- },
- beforeDragEnter : function(target, e, id){
- return true;
- },
- alignElWithMouse: function() {
- Ext.dd.DragSource.superclass.alignElWithMouse.apply(this, arguments);
- this.proxy.sync();
- },
- onDragOver : function(e, id){
- var target = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(id);
- if(this.beforeDragOver(target, e, id) !== false){
- if(target.isNotifyTarget){
- var status = target.notifyOver(this, e, this.dragData);
- this.proxy.setStatus(status);
- }
- if(this.afterDragOver){
- this.afterDragOver(target, e, id);
- }
- }
- },
- beforeDragOver : function(target, e, id){
- return true;
- },
- onDragOut : function(e, id){
- var target = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(id);
- if(this.beforeDragOut(target, e, id) !== false){
- if(target.isNotifyTarget){
- target.notifyOut(this, e, this.dragData);
- }
- this.proxy.reset();
- if(this.afterDragOut){
- this.afterDragOut(target, e, id);
- }
- }
- this.cachedTarget = null;
- },
- beforeDragOut : function(target, e, id){
- return true;
- },
- onDragDrop : function(e, id){
- var target = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(id);
- if(this.beforeDragDrop(target, e, id) !== false){
- if(target.isNotifyTarget){
- if(target.notifyDrop(this, e, this.dragData)){
- this.onValidDrop(target, e, id);
- }else{
- this.onInvalidDrop(target, e, id);
- }
- }else{
- this.onValidDrop(target, e, id);
- }
- if(this.afterDragDrop){
- this.afterDragDrop(target, e, id);
- }
- }
- delete this.cachedTarget;
- },
- beforeDragDrop : function(target, e, id){
- return true;
- },
- onValidDrop : function(target, e, id){
- this.hideProxy();
- if(this.afterValidDrop){
- this.afterValidDrop(target, e, id);
- }
- },
- getRepairXY : function(e, data){
- return this.el.getXY();
- },
- onInvalidDrop : function(target, e, id){
- this.beforeInvalidDrop(target, e, id);
- if(this.cachedTarget){
- if(this.cachedTarget.isNotifyTarget){
- this.cachedTarget.notifyOut(this, e, this.dragData);
- }
- this.cacheTarget = null;
- }
- this.proxy.repair(this.getRepairXY(e, this.dragData), this.afterRepair, this);
- if(this.afterInvalidDrop){
- this.afterInvalidDrop(e, id);
- }
- },
- afterRepair : function(){
- if(Ext.enableFx){
- this.el.highlight(this.hlColor || "c3daf9");
- }
- this.dragging = false;
- },
- beforeInvalidDrop : function(target, e, id){
- return true;
- },
- handleMouseDown : function(e){
- if(this.dragging) {
- return;
- }
- var data = this.getDragData(e);
- if(data && this.onBeforeDrag(data, e) !== false){
- this.dragData = data;
- this.proxy.stop();
- Ext.dd.DragSource.superclass.handleMouseDown.apply(this, arguments);
- }
- },
- onBeforeDrag : function(data, e){
- return true;
- },
- onStartDrag : Ext.emptyFn,
- startDrag : function(x, y){
- this.proxy.reset();
- this.dragging = true;
- this.proxy.update("");
- this.onInitDrag(x, y);
- this.proxy.show();
- },
- onInitDrag : function(x, y){
- var clone = this.el.dom.cloneNode(true);
- clone.id = Ext.id();
- this.proxy.update(clone);
- this.onStartDrag(x, y);
- return true;
- },
- getProxy : function(){
- return this.proxy;
- },
- hideProxy : function(){
- this.proxy.hide();
- this.proxy.reset(true);
- this.dragging = false;
- },
- triggerCacheRefresh : function(){
- Ext.dd.DDM.refreshCache(this.groups);
- },
- b4EndDrag: function(e) {
- },
- endDrag : function(e){
- this.onEndDrag(this.dragData, e);
- },
- onEndDrag : function(data, e){
- },
- autoOffset : function(x, y) {
- this.setDelta(-12, -20);
- }
- });
- Ext.dd.DropTarget = function(el, config){
- this.el = Ext.get(el);
- Ext.apply(this, config);
- if(this.containerScroll){
- Ext.dd.ScrollManager.register(this.el);
- }
- Ext.dd.DropTarget.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group,
- {isTarget: true});
- };
- Ext.extend(Ext.dd.DropTarget, Ext.dd.DDTarget, {
- dropAllowed : "x-dd-drop-ok",
- dropNotAllowed : "x-dd-drop-nodrop",
- isTarget : true,
- isNotifyTarget : true,
- notifyEnter : function(dd, e, data){
- if(this.overClass){
- this.el.addClass(this.overClass);
- }
- return this.dropAllowed;
- },
- notifyOver : function(dd, e, data){
- return this.dropAllowed;
- },
- notifyOut : function(dd, e, data){
- if(this.overClass){
- this.el.removeClass(this.overClass);
- }
- },
- notifyDrop : function(dd, e, data){
- return false;
- }
- });
- Ext.dd.DragZone = function(el, config){
- Ext.dd.DragZone.superclass.constructor.call(this, el, config);
- if(this.containerScroll){
- Ext.dd.ScrollManager.register(this.el);
- }
- };
- Ext.extend(Ext.dd.DragZone, Ext.dd.DragSource, {
- getDragData : function(e){
- return Ext.dd.Registry.getHandleFromEvent(e);
- },
- onInitDrag : function(x, y){
- this.proxy.update(this.dragData.ddel.cloneNode(true));
- this.onStartDrag(x, y);
- return true;
- },
- afterRepair : function(){
- if(Ext.enableFx){
- Ext.Element.fly(this.dragData.ddel).highlight(this.hlColor || "c3daf9");
- }
- this.dragging = false;
- },
- getRepairXY : function(e){
- return Ext.Element.fly(this.dragData.ddel).getXY();
- }
- });
- Ext.dd.DropZone = function(el, config){
- Ext.dd.DropZone.superclass.constructor.call(this, el, config);
- };
- Ext.extend(Ext.dd.DropZone, Ext.dd.DropTarget, {
- getTargetFromEvent : function(e){
- return Ext.dd.Registry.getTargetFromEvent(e);
- },
- onNodeEnter : function(n, dd, e, data){
- },
- onNodeOver : function(n, dd, e, data){
- return this.dropAllowed;
- },
- onNodeOut : function(n, dd, e, data){
- },
- onNodeDrop : function(n, dd, e, data){
- return false;
- },
- onContainerOver : function(dd, e, data){
- return this.dropNotAllowed;
- },
- onContainerDrop : function(dd, e, data){
- return false;
- },
- notifyEnter : function(dd, e, data){
- return this.dropNotAllowed;
- },
- notifyOver : function(dd, e, data){
- var n = this.getTargetFromEvent(e);
- if(!n){
- if(this.lastOverNode){
- this.onNodeOut(this.lastOverNode, dd, e, data);
- this.lastOverNode = null;
- }
- return this.onContainerOver(dd, e, data);
- }
- if(this.lastOverNode != n){
- if(this.lastOverNode){
- this.onNodeOut(this.lastOverNode, dd, e, data);
- }
- this.onNodeEnter(n, dd, e, data);
- this.lastOverNode = n;
- }
- return this.onNodeOver(n, dd, e, data);
- },
- notifyOut : function(dd, e, data){
- if(this.lastOverNode){
- this.onNodeOut(this.lastOverNode, dd, e, data);
- this.lastOverNode = null;
- }
- },
- notifyDrop : function(dd, e, data){
- if(this.lastOverNode){
- this.onNodeOut(this.lastOverNode, dd, e, data);
- this.lastOverNode = null;
- }
- var n = this.getTargetFromEvent(e);
- return n ?
- this.onNodeDrop(n, dd, e, data) :
- this.onContainerDrop(dd, e, data);
- },
- triggerCacheRefresh : function(){
- Ext.dd.DDM.refreshCache(this.groups);
- }
- });
- Ext.data.SortTypes = {
- none : function(s){
- return s;
- },
- stripTagsRE : /</?[^>]+>/gi,
- asText : function(s){
- return String(s).replace(this.stripTagsRE, "");
- },
- asUCText : function(s){
- return String(s).toUpperCase().replace(this.stripTagsRE, "");
- },
- asUCString : function(s) {
- return String(s).toUpperCase();
- },
- asDate : function(s) {
- if(!s){
- return 0;
- }
- if(Ext.isDate(s)){
- return s.getTime();
- }
- return Date.parse(String(s));
- },
- asFloat : function(s) {
- var val = parseFloat(String(s).replace(/,/g, ""));
- if(isNaN(val)) val = 0;
- return val;
- },
- asInt : function(s) {
- var val = parseInt(String(s).replace(/,/g, ""));
- if(isNaN(val)) val = 0;
- return val;
- }
- };
- Ext.data.Record = function(data, id){
- this.id = (id || id === 0) ? id : ++Ext.data.Record.AUTO_ID;
- this.data = data;
- };
- Ext.data.Record.create = function(o){
- var f = Ext.extend(Ext.data.Record, {});
- var p = f.prototype;
- p.fields = new Ext.util.MixedCollection(false, function(field){
- return field.name;
- });
- for(var i = 0, len = o.length; i < len; i++){
- p.fields.add(new Ext.data.Field(o[i]));
- }
- f.getField = function(name){
- return p.fields.get(name);
- };
- return f;
- };
- Ext.data.Record.AUTO_ID = 1000;
- Ext.data.Record.EDIT = 'edit';
- Ext.data.Record.REJECT = 'reject';
- Ext.data.Record.COMMIT = 'commit';
- Ext.data.Record.prototype = {
- dirty : false,
- editing : false,
- error: null,
- modified: null,
- join : function(store){
- this.store = store;
- },
- set : function(name, value){
- if(String(this.data[name]) == String(value)){
- return;
- }
- this.dirty = true;
- if(!this.modified){
- this.modified = {};
- }
- if(typeof this.modified[name] == 'undefined'){
- this.modified[name] = this.data[name];
- }
- this.data[name] = value;
- if(!this.editing && this.store){
- this.store.afterEdit(this);
- }
- },
- get : function(name){
- return this.data[name];
- },
- beginEdit : function(){
- this.editing = true;
- this.modified = {};
- },
- cancelEdit : function(){
- this.editing = false;
- delete this.modified;
- },
- endEdit : function(){
- this.editing = false;
- if(this.dirty && this.store){
- this.store.afterEdit(this);
- }
- },
- reject : function(silent){
- var m = this.modified;
- for(var n in m){
- if(typeof m[n] != "function"){
- this.data[n] = m[n];
- }
- }
- this.dirty = false;
- delete this.modified;
- this.editing = false;
- if(this.store && silent !== true){
- this.store.afterReject(this);
- }
- },
- commit : function(silent){
- this.dirty = false;
- delete this.modified;
- this.editing = false;
- if(this.store && silent !== true){
- this.store.afterCommit(this);
- }
- },
- getChanges : function(){
- var m = this.modified, cs = {};
- for(var n in m){
- if(m.hasOwnProperty(n)){
- cs[n] = this.data[n];
- }
- }
- return cs;
- },
- hasError : function(){
- return this.error != null;
- },
- clearError : function(){
- this.error = null;
- },
- copy : function(newId) {
- return new this.constructor(Ext.apply({}, this.data), newId || this.id);
- },
- isModified : function(fieldName){
- return this.modified && this.modified.hasOwnProperty(fieldName);
- }
- };
- Ext.StoreMgr = Ext.apply(new Ext.util.MixedCollection(), {
- register : function(){
- for(var i = 0, s; s = arguments[i]; i++){
- this.add(s);
- }
- },
- unregister : function(){
- for(var i = 0, s; s = arguments[i]; i++){
- this.remove(this.lookup(s));
- }
- },
- lookup : function(id){
- return typeof id == "object" ? id : this.get(id);
- },
- getKey : function(o){
- return o.storeId || o.id;
- }
- });
- Ext.data.Store = function(config){
- this.data = new Ext.util.MixedCollection(false);
- this.data.getKey = function(o){
- return o.id;
- };
- this.baseParams = {};
- this.paramNames = {
- "start" : "start",
- "limit" : "limit",
- "sort" : "sort",
- "dir" : "dir"
- };
- if(config && config.data){
- this.inlineData = config.data;
- delete config.data;
- }
- Ext.apply(this, config);
- if(this.url && !this.proxy){
- this.proxy = new Ext.data.HttpProxy({url: this.url});
- }
- if(this.reader){
- if(!this.recordType){
- this.recordType = this.reader.recordType;
- }
- if(this.reader.onMetaChange){
- this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
- }
- }
- if(this.recordType){
- this.fields = this.recordType.prototype.fields;
- }
- this.modified = [];
- this.addEvents(
- 'datachanged',
- 'metachange',
- 'add',
- 'remove',
- 'update',
- 'clear',
- 'beforeload',
- 'load',
- 'loadexception'
- );
- if(this.proxy){
- this.relayEvents(this.proxy, ["loadexception"]);
- }
- this.sortToggle = {};
- if(this.sortInfo){
- this.setDefaultSort(this.sortInfo.field, this.sortInfo.direction);
- }
- Ext.data.Store.superclass.constructor.call(this);
- if(this.storeId || this.id){
- Ext.StoreMgr.register(this);
- }
- if(this.inlineData){
- this.loadData(this.inlineData);
- delete this.inlineData;
- }else if(this.autoLoad){
- this.load.defer(10, this, [
- typeof this.autoLoad == 'object' ?
- this.autoLoad : undefined]);
- }
- };
- Ext.extend(Ext.data.Store, Ext.util.Observable, {
- remoteSort : false,
- pruneModifiedRecords : false,
- lastOptions : null,
- destroy : function(){
- if(this.id){
- Ext.StoreMgr.unregister(this);
- }
- this.data = null;
- this.purgeListeners();
- },
- add : function(records){
- records = [].concat(records);
- if(records.length < 1){
- return;
- }
- for(var i = 0, len = records.length; i < len; i++){
- records[i].join(this);
- }
- var index = this.data.length;
- this.data.addAll(records);
- if(this.snapshot){
- this.snapshot.addAll(records);
- }
- this.fireEvent("add", this, records, index);
- },
- addSorted : function(record){
- var index = this.findInsertIndex(record);
- this.insert(index, record);
- },
- remove : function(record){
- var index = this.data.indexOf(record);
- this.data.removeAt(index);
- if(this.pruneModifiedRecords){
- this.modified.remove(record);
- }
- if(this.snapshot){
- this.snapshot.remove(record);
- }
- this.fireEvent("remove", this, record, index);
- },
- removeAll : function(){
- this.data.clear();
- if(this.snapshot){
- this.snapshot.clear();
- }
- if(this.pruneModifiedRecords){
- this.modified = [];
- }
- this.fireEvent("clear", this);
- },
- insert : function(index, records){
- records = [].concat(records);
- for(var i = 0, len = records.length; i < len; i++){
- this.data.insert(index, records[i]);
- records[i].join(this);
- }
- this.fireEvent("add", this, records, index);
- },
- indexOf : function(record){
- return this.data.indexOf(record);
- },
- indexOfId : function(id){
- return this.data.indexOfKey(id);
- },
- getById : function(id){
- return this.data.key(id);
- },
- getAt : function(index){
- return this.data.itemAt(index);
- },
- getRange : function(start, end){
- return this.data.getRange(start, end);
- },
- storeOptions : function(o){
- o = Ext.apply({}, o);
- delete o.callback;
- delete o.scope;
- this.lastOptions = o;
- },
- load : function(options){
- options = options || {};
- if(this.fireEvent("beforeload", this, options) !== false){
- this.storeOptions(options);
- var p = Ext.apply(options.params || {}, this.baseParams);
- if(this.sortInfo && this.remoteSort){
- var pn = this.paramNames;
- p[pn["sort"]] = this.sortInfo.field;
- p[pn["dir"]] = this.sortInfo.direction;
- }
- this.proxy.load(p, this.reader, this.loadRecords, this, options);
- return true;
- } else {
- return false;
- }
- },
- reload : function(options){
- this.load(Ext.applyIf(options||{}, this.lastOptions));
- },
- loadRecords : function(o, options, success){
- if(!o || success === false){
- if(success !== false){
- this.fireEvent("load", this, [], options);
- }
- if(options.callback){
- options.callback.call(options.scope || this, [], options, false);
- }
- return;
- }
- var r = o.records, t = o.totalRecords || r.length;
- if(!options || options.add !== true){
- if(this.pruneModifiedRecords){
- this.modified = [];
- }
- for(var i = 0, len = r.length; i < len; i++){
- r[i].join(this);
- }
- if(this.snapshot){
- this.data = this.snapshot;
- delete this.snapshot;
- }
- this.data.clear();
- this.data.addAll(r);
- this.totalLength = t;
- this.applySort();
- this.fireEvent("datachanged", this);
- }else{
- this.totalLength = Math.max(t, this.data.length+r.length);
- this.add(r);
- }
- this.fireEvent("load", this, r, options);
- if(options.callback){
- options.callback.call(options.scope || this, r, options, true);
- }
- },
- loadData : function(o, append){
- var r = this.reader.readRecords(o);
- this.loadRecords(r, {add: append}, true);
- },
- getCount : function(){
- return this.data.length || 0;
- },
- getTotalCount : function(){
- return this.totalLength || 0;
- },
- getSortState : function(){
- return this.sortInfo;
- },
- applySort : function(){
- if(this.sortInfo && !this.remoteSort){
- var s = this.sortInfo, f = s.field;
- this.sortData(f, s.direction);
- }
- },
- sortData : function(f, direction){
- direction = direction || 'ASC';
- var st = this.fields.get(f).sortType;
- var fn = function(r1, r2){
- var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
- return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
- };
- this.data.sort(direction, fn);
- if(this.snapshot && this.snapshot != this.data){
- this.snapshot.sort(direction, fn);
- }
- },
- setDefaultSort : function(field, dir){
- dir = dir ? dir.toUpperCase() : "ASC";
- this.sortInfo = {field: field, direction: dir};
- this.sortToggle[field] = dir;
- },
- sort : function(fieldName, dir){
- var f = this.fields.get(fieldName);
- if(!f){
- return false;
- }
- if(!dir){
- if(this.sortInfo && this.sortInfo.field == f.name){
- dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
- }else{
- dir = f.sortDir;
- }
- }
- var st = (this.sortToggle) ? this.sortToggle[f.name] : null;
- var si = (this.sortInfo) ? this.sortInfo : null;
- this.sortToggle[f.name] = dir;
- this.sortInfo = {field: f.name, direction: dir};
- if(!this.remoteSort){
- this.applySort();
- this.fireEvent("datachanged", this);
- }else{
- if (!this.load(this.lastOptions)) {
- if (st) {
- this.sortToggle[f.name] = st;
- }
- if (si) {
- this.sortInfo = si;
- }
- }
- }
- },
- each : function(fn, scope){
- this.data.each(fn, scope);
- },
- getModifiedRecords : function(){
- return this.modified;
- },
- createFilterFn : function(property, value, anyMatch, caseSensitive){
- if(Ext.isEmpty(value, false)){
- return false;
- }
- value = this.data.createValueMatcher(value, anyMatch, caseSensitive);
- return function(r){
- return value.test(r.data[property]);
- };
- },
- sum : function(property, start, end){
- var rs = this.data.items, v = 0;
- start = start || 0;
- end = (end || end === 0) ? end : rs.length-1;
- for(var i = start; i <= end; i++){
- v += (rs[i].data[property] || 0);
- }
- return v;
- },
- filter : function(property, value, anyMatch, caseSensitive){
- var fn = this.createFilterFn(property, value, anyMatch, caseSensitive);
- return fn ? this.filterBy(fn) : this.clearFilter();
- },
- filterBy : function(fn, scope){
- this.snapshot = this.snapshot || this.data;
- this.data = this.queryBy(fn, scope||this);
- this.fireEvent("datachanged", this);
- },
- query : function(property, value, anyMatch, caseSensitive){
- var fn = this.createFilterFn(property, value, anyMatch, caseSensitive);
- return fn ? this.queryBy(fn) : this.data.clone();
- },
- queryBy : function(fn, scope){
- var data = this.snapshot || this.data;
- return data.filterBy(fn, scope||this);
- },
- find : function(property, value, start, anyMatch, caseSensitive){
- var fn = this.createFilterFn(property, value, anyMatch, caseSensitive);
- return fn ? this.data.findIndexBy(fn, null, start) : -1;
- },
- findBy : function(fn, scope, start){
- return this.data.findIndexBy(fn, scope, start);
- },
- collect : function(dataIndex, allowNull, bypassFilter){
- var d = (bypassFilter === true && this.snapshot) ?
- this.snapshot.items : this.data.items;
- var v, sv, r = [], l = {};
- for(var i = 0, len = d.length; i < len; i++){
- v = d[i].data[dataIndex];
- sv = String(v);
- if((allowNull || !Ext.isEmpty(v)) && !l[sv]){
- l[sv] = true;
- r[r.length] = v;
- }
- }
- return r;
- },
- clearFilter : function(suppressEvent){
- if(this.isFiltered()){
- this.data = this.snapshot;
- delete this.snapshot;
- if(suppressEvent !== true){
- this.fireEvent("datachanged", this);
- }
- }
- },
- isFiltered : function(){
- return this.snapshot && this.snapshot != this.data;
- },
- afterEdit : function(record){
- if(this.modified.indexOf(record) == -1){
- this.modified.push(record);
- }
- this.fireEvent("update", this, record, Ext.data.Record.EDIT);
- },
- afterReject : function(record){
- this.modified.remove(record);
- this.fireEvent("update", this, record, Ext.data.Record.REJECT);
- },
- afterCommit : function(record){
- this.modified.remove(record);
- this.fireEvent("update", this, record, Ext.data.Record.COMMIT);
- },
- commitChanges : function(){
- var m = this.modified.slice(0);
- this.modified = [];
- for(var i = 0, len = m.length; i < len; i++){
- m[i].commit();
- }
- },
- rejectChanges : function(){
- var m = this.modified.slice(0);
- this.modified = [];
- for(var i = 0, len = m.length; i < len; i++){
- m[i].reject();
- }
- },
- onMetaChange : function(meta, rtype, o){
- this.recordType = rtype;
- this.fields = rtype.prototype.fields;
- delete this.snapshot;
- this.sortInfo = meta.sortInfo;
- this.modified = [];
- this.fireEvent('metachange', this, this.reader.meta);
- },
- findInsertIndex : function(record){
- this.suspendEvents();
- var data = this.data.clone();
- this.data.add(record);
- this.applySort();
- var index = this.data.indexOf(record);
- this.data = data;
- this.resumeEvents();
- return index;
- }
- });
- Ext.data.SimpleStore = function(config){
- Ext.data.SimpleStore.superclass.constructor.call(this, Ext.apply(config, {
- reader: new Ext.data.ArrayReader({
- id: config.id
- },
- Ext.data.Record.create(config.fields)
- )
- }));
- };
- Ext.extend(Ext.data.SimpleStore, Ext.data.Store, {
- loadData : function(data, append){
- if(this.expandData === true){
- var r = [];
- for(var i = 0, len = data.length; i < len; i++){
- r[r.length] = [data[i]];
- }
- data = r;
- }
- Ext.data.SimpleStore.superclass.loadData.call(this, data, append);
- }
- });
- Ext.data.JsonStore = function(c){
- Ext.data.JsonStore.superclass.constructor.call(this, Ext.apply(c, {
- proxy: !c.data ? new Ext.data.HttpProxy({url: c.url}) : undefined,
- reader: new Ext.data.JsonReader(c, c.fields)
- }));
- };
- Ext.extend(Ext.data.JsonStore, Ext.data.Store);
- Ext.data.Field = function(config){
- if(typeof config == "string"){
- config = {name: config};
- }
- Ext.apply(this, config);
- if(!this.type){
- this.type = "auto";
- }
- var st = Ext.data.SortTypes;
- if(typeof this.sortType == "string"){
- this.sortType = st[this.sortType];
- }
- if(!this.sortType){
- switch(this.type){
- case "string":
- this.sortType = st.asUCString;
- break;
- case "date":
- this.sortType = st.asDate;
- break;
- default:
- this.sortType = st.none;
- }
- }
- var stripRe = /[$,%]/g;
- if(!this.convert){
- var cv, dateFormat = this.dateFormat;
- switch(this.type){
- case "":
- case "auto":
- case undefined:
- cv = function(v){ return v; };
- break;
- case "string":
- cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
- break;
- case "int":
- cv = function(v){
- return v !== undefined && v !== null && v !== '' ?
- parseInt(String(v).replace(stripRe, ""), 10) : '';
- };
- break;
- case "float":
- cv = function(v){
- return v !== undefined && v !== null && v !== '' ?
- parseFloat(String(v).replace(stripRe, ""), 10) : '';
- };
- break;
- case "bool":
- case "boolean":
- cv = function(v){ return v === true || v === "true" || v == 1; };
- break;
- case "date":
- cv = function(v){
- if(!v){
- return '';
- }
- if(Ext.isDate(v)){
- return v;
- }
- if(dateFormat){
- if(dateFormat == "timestamp"){
- return new Date(v*1000);
- }
- if(dateFormat == "time"){
- return new Date(parseInt(v, 10));
- }
- return Date.parseDate(v, dateFormat);
- }
- var parsed = Date.parse(v);
- return parsed ? new Date(parsed) : null;
- };
- break;
- }
- this.convert = cv;
- }
- };
- Ext.data.Field.prototype = {
- dateFormat: null,
- defaultValue: "",
- mapping: null,
- sortType : null,
- sortDir : "ASC"
- };
- Ext.data.DataReader = function(meta, recordType){
- this.meta = meta;
- this.recordType = Ext.isArray(recordType) ?
- Ext.data.Record.create(recordType) : recordType;
- };
- Ext.data.DataReader.prototype = {
- };
- Ext.data.DataProxy = function(){
- this.addEvents(
- 'beforeload',
- 'load',
- 'loadexception'
- );
- Ext.data.DataProxy.superclass.constructor.call(this);
- };
- Ext.extend(Ext.data.DataProxy, Ext.util.Observable);
- Ext.data.MemoryProxy = function(data){
- Ext.data.MemoryProxy.superclass.constructor.call(this);
- this.data = data;
- };
- Ext.extend(Ext.data.MemoryProxy, Ext.data.DataProxy, {
- load : function(params, reader, callback, scope, arg){
- params = params || {};
- var result;
- try {
- result = reader.readRecords(this.data);
- }catch(e){
- this.fireEvent("loadexception", this, arg, null, e);
- callback.call(scope, null, arg, false);
- return;
- }
- callback.call(scope, result, arg, true);
- },
- update : function(params, records){
- }
- });
- Ext.data.HttpProxy = function(conn){
- Ext.data.HttpProxy.superclass.constructor.call(this);
- this.conn = conn;
- this.useAjax = !conn || !conn.events;
- };
- Ext.extend(Ext.data.HttpProxy, Ext.data.DataProxy, {
- getConnection : function(){
- return this.useAjax ? Ext.Ajax : this.conn;
- },
- load : function(params, reader, callback, scope, arg){
- if(this.fireEvent("beforeload", this, params) !== false){
- var o = {
- params : params || {},
- request: {
- callback : callback,
- scope : scope,
- arg : arg
- },
- reader: reader,
- callback : this.loadResponse,
- scope: this
- };
- if(this.useAjax){
- Ext.applyIf(o, this.conn);
- if(this.activeRequest){
- Ext.Ajax.abort(this.activeRequest);
- }
- this.activeRequest = Ext.Ajax.request(o);
- }else{
- this.conn.request(o);
- }
- }else{
- callback.call(scope||this, null, arg, false);
- }
- },
- loadResponse : function(o, success, response){
- delete this.activeRequest;
- if(!success){
- this.fireEvent("loadexception", this, o, response);
- o.request.callback.call(o.request.scope, null, o.request.arg, false);
- return;
- }
- var result;
- try {
- result = o.reader.read(response);
- }catch(e){
- this.fireEvent("loadexception", this, o, response, e);
- o.request.callback.call(o.request.scope, null, o.request.arg, false);
- return;
- }
- this.fireEvent("load", this, o, o.request.arg);
- o.request.callback.call(o.request.scope, result, o.request.arg, true);
- },
- update : function(dataSet){
- },
- updateResponse : function(dataSet){
- }
- });
- Ext.data.ScriptTagProxy = function(config){
- Ext.data.ScriptTagProxy.superclass.constructor.call(this);
- Ext.apply(this, config);
- this.head = document.getElementsByTagName("head")[0];
- };
- Ext.data.ScriptTagProxy.TRANS_ID = 1000;
- Ext.extend(Ext.data.ScriptTagProxy, Ext.data.DataProxy, {
- timeout : 30000,
- callbackParam : "callback",
- nocache : true,
- load : function(params, reader, callback, scope, arg){
- if(this.fireEvent("beforeload", this, params) !== false){
- var p = Ext.urlEncode(Ext.apply(params, this.extraParams));
- var url = this.url;
- url += (url.indexOf("?") != -1 ? "&" : "?") + p;
- if(this.nocache){
- url += "&_dc=" + (new Date().getTime());
- }
- var transId = ++Ext.data.ScriptTagProxy.TRANS_ID;
- var trans = {
- id : transId,
- cb : "stcCallback"+transId,
- scriptId : "stcScript"+transId,
- params : params,
- arg : arg,
- url : url,
- callback : callback,
- scope : scope,
- reader : reader
- };
- var conn = this;
- window[trans.cb] = function(o){
- conn.handleResponse(o, trans);
- };
- url += String.format("&{0}={1}", this.callbackParam, trans.cb);
- if(this.autoAbort !== false){
- this.abort();
- }
- trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
- var script = document.createElement("script");
- script.setAttribute("src", url);
- script.setAttribute("type", "text/javascript");
- script.setAttribute("id", trans.scriptId);
- this.head.appendChild(script);
- this.trans = trans;
- }else{
- callback.call(scope||this, null, arg, false);
- }
- },
- isLoading : function(){
- return this.trans ? true : false;
- },
- abort : function(){
- if(this.isLoading()){
- this.destroyTrans(this.trans);
- }
- },
- destroyTrans : function(trans, isLoaded){
- this.head.removeChild(document.getElementById(trans.scriptId));
- clearTimeout(trans.timeoutId);
- if(isLoaded){
- window[trans.cb] = undefined;
- try{
- delete window[trans.cb];
- }catch(e){}
- }else{
- window[trans.cb] = function(){
- window[trans.cb] = undefined;
- try{
- delete window[trans.cb];
- }catch(e){}
- };
- }
- },
- handleResponse : function(o, trans){
- this.trans = false;
- this.destroyTrans(trans, true);
- var result;
- try {
- result = trans.reader.readRecords(o);
- }catch(e){
- this.fireEvent("loadexception", this, o, trans.arg, e);
- trans.callback.call(trans.scope||window, null, trans.arg, false);
- return;
- }
- this.fireEvent("load", this, o, trans.arg);
- trans.callback.call(trans.scope||window, result, trans.arg, true);
- },
- handleFailure : function(trans){
- this.trans = false;
- this.destroyTrans(trans, false);
- this.fireEvent("loadexception", this, null, trans.arg);
- trans.callback.call(trans.scope||window, null, trans.arg, false);
- }
- });
- Ext.data.JsonReader = function(meta, recordType){
- meta = meta || {};
- Ext.data.JsonReader.superclass.constructor.call(this, meta, recordType || meta.fields);
- };
- Ext.extend(Ext.data.JsonReader, Ext.data.DataReader, {
- read : function(response){
- var json = response.responseText;
- var o = eval("("+json+")");
- if(!o) {
- throw {message: "JsonReader.read: Json object not found"};
- }
- if(o.metaData){
- delete this.ef;
- this.meta = o.metaData;
- this.recordType = Ext.data.Record.create(o.metaData.fields);
- this.onMetaChange(this.meta, this.recordType, o);
- }
- return this.readRecords(o);
- },
- onMetaChange : function(meta, recordType, o){
- },
- simpleAccess: function(obj, subsc) {
- return obj[subsc];
- },
- getJsonAccessor: function(){
- var re = /[[.]/;
- return function(expr) {
- try {
- return(re.test(expr))
- ? new Function("obj", "return obj." + expr)
- : function(obj){
- return obj[expr];
- };
- } catch(e){}
- return Ext.emptyFn;
- };
- }(),
- readRecords : function(o){
- this.jsonData = o;
- var s = this.meta, Record = this.recordType,
- f = Record.prototype.fields, fi = f.items, fl = f.length;
- if (!this.ef) {
- if(s.totalProperty) {
- this.getTotal = this.getJsonAccessor(s.totalProperty);
- }
- if(s.successProperty) {
- this.getSuccess = this.getJsonAccessor(s.successProperty);
- }
- this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
- if (s.id) {
- var g = this.getJsonAccessor(s.id);
- this.getId = function(rec) {
- var r = g(rec);
- return (r === undefined || r === "") ? null : r;
- };
- } else {
- this.getId = function(){return null;};
- }
- this.ef = [];
- for(var i = 0; i < fl; i++){
- f = fi[i];
- var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
- this.ef[i] = this.getJsonAccessor(map);
- }
- }
- var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
- if(s.totalProperty){
- var v = parseInt(this.getTotal(o), 10);
- if(!isNaN(v)){
- totalRecords = v;
- }
- }
- if(s.successProperty){
- var v = this.getSuccess(o);
- if(v === false || v === 'false'){
- success = false;
- }
- }
- var records = [];
- for(var i = 0; i < c; i++){
- var n = root[i];
- var values = {};
- var id = this.getId(n);
- for(var j = 0; j < fl; j++){
- f = fi[j];
- var v = this.ef[j](n);
- values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue, n);
- }
- var record = new Record(values, id);
- record.json = n;
- records[i] = record;
- }
- return {
- success : success,
- records : records,
- totalRecords : totalRecords
- };
- }
- });
- Ext.data.XmlReader = function(meta, recordType){
- meta = meta || {};
- Ext.data.XmlReader.superclass.constructor.call(this, meta, recordType || meta.fields);
- };
- Ext.extend(Ext.data.XmlReader, Ext.data.DataReader, {
- read : function(response){
- var doc = response.responseXML;
- if(!doc) {
- throw {message: "XmlReader.read: XML Document not available"};
- }
- return this.readRecords(doc);
- },
- readRecords : function(doc){
- this.xmlData = doc;
- var root = doc.documentElement || doc;
- var q = Ext.DomQuery;
- var recordType = this.recordType, fields = recordType.prototype.fields;
- var sid = this.meta.id;
- var totalRecords = 0, success = true;
- if(this.meta.totalRecords){
- totalRecords = q.selectNumber(this.meta.totalRecords, root, 0);
- }
- if(this.meta.success){
- var sv = q.selectValue(this.meta.success, root, true);
- success = sv !== false && sv !== 'false';
- }
- var records = [];
- var ns = q.select(this.meta.record, root);
- for(var i = 0, len = ns.length; i < len; i++) {
- var n = ns[i];
- var values = {};
- var id = sid ? q.selectValue(sid, n) : undefined;
- for(var j = 0, jlen = fields.length; j < jlen; j++){
- var f = fields.items[j];
- var v = q.selectValue(f.mapping || f.name, n, f.defaultValue);
- v = f.convert(v, n);
- values[f.name] = v;
- }
- var record = new recordType(values, id);
- record.node = n;
- records[records.length] = record;
- }
- return {
- success : success,
- records : records,
- totalRecords : totalRecords || records.length
- };
- }
- });
- Ext.data.ArrayReader = Ext.extend(Ext.data.JsonReader, {
- readRecords : function(o){
- var sid = this.meta ? this.meta.id : null;
- var recordType = this.recordType, fields = recordType.prototype.fields;
- var records = [];
- var root = o;
- for(var i = 0; i < root.length; i++){
- var n = root[i];
- var values = {};
- var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
- for(var j = 0, jlen = fields.length; j < jlen; j++){
- var f = fields.items[j];
- var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
- var v = n[k] !== undefined ? n[k] : f.defaultValue;
- v = f.convert(v, n);
- values[f.name] = v;
- }
- var record = new recordType(values, id);
- record.json = n;
- records[records.length] = record;
- }
- return {
- records : records,
- totalRecords : records.length
- };
- }
- });
- Ext.data.Tree = function(root){
- this.nodeHash = {};
- this.root = null;
- if(root){
- this.setRootNode(root);
- }
- this.addEvents(
- "append",
- "remove",
- "move",
- "insert",
- "beforeappend",
- "beforeremove",
- "beforemove",
- "beforeinsert"
- );
- Ext.data.Tree.superclass.constructor.call(this);
- };
- Ext.extend(Ext.data.Tree, Ext.util.Observable, {
- pathSeparator: "/",
- proxyNodeEvent : function(){
- return this.fireEvent.apply(this, arguments);
- },
- getRootNode : function(){
- return this.root;
- },
- setRootNode : function(node){
- this.root = node;
- node.ownerTree = this;
- node.isRoot = true;
- this.registerNode(node);
- return node;
- },
- getNodeById : function(id){
- return this.nodeHash[id];
- },
- registerNode : function(node){
- this.nodeHash[node.id] = node;
- },
- unregisterNode : function(node){
- delete this.nodeHash[node.id];
- },
- toString : function(){
- return "[Tree"+(this.id?" "+this.id:"")+"]";
- }
- });
- Ext.data.Node = function(attributes){
- this.attributes = attributes || {};
- this.leaf = this.attributes.leaf;
- this.id = this.attributes.id;
- if(!this.id){
- this.id = Ext.id(null, "ynode-");
- this.attributes.id = this.id;
- }
- this.childNodes = [];
- if(!this.childNodes.indexOf){
- this.childNodes.indexOf = function(o){
- for(var i = 0, len = this.length; i < len; i++){
- if(this[i] == o) return i;
- }
- return -1;
- };
- }
- this.parentNode = null;
- this.firstChild = null;
- this.lastChild = null;
- this.previousSibling = null;
- this.nextSibling = null;
- this.addEvents({
- "append" : true,
- "remove" : true,
- "move" : true,
- "insert" : true,
- "beforeappend" : true,
- "beforeremove" : true,
- "beforemove" : true,
- "beforeinsert" : true
- });
- this.listeners = this.attributes.listeners;
- Ext.data.Node.superclass.constructor.call(this);
- };
- Ext.extend(Ext.data.Node, Ext.util.Observable, {
- fireEvent : function(evtName){
- if(Ext.data.Node.superclass.fireEvent.apply(this, arguments) === false){
- return false;
- }
- var ot = this.getOwnerTree();
- if(ot){
- if(ot.proxyNodeEvent.apply(ot, arguments) === false){
- return false;
- }
- }
- return true;
- },
- isLeaf : function(){
- return this.leaf === true;
- },
- setFirstChild : function(node){
- this.firstChild = node;
- },
- setLastChild : function(node){
- this.lastChild = node;
- },
- isLast : function(){
- return (!this.parentNode ? true : this.parentNode.lastChild == this);
- },
- isFirst : function(){
- return (!this.parentNode ? true : this.parentNode.firstChild == this);
- },
- hasChildNodes : function(){
- return !this.isLeaf() && this.childNodes.length > 0;
- },
- appendChild : function(node){
- var multi = false;
- if(Ext.isArray(node)){
- multi = node;
- }else if(arguments.length > 1){
- multi = arguments;
- }
- if(multi){
- for(var i = 0, len = multi.length; i < len; i++) {
- this.appendChild(multi[i]);
- }
- }else{
- if(this.fireEvent("beforeappend", this.ownerTree, this, node) === false){
- return false;
- }
- var index = this.childNodes.length;
- var oldParent = node.parentNode;
- if(oldParent){
- if(node.fireEvent("beforemove", node.getOwnerTree(), node, oldParent, this, index) === false){
- return false;
- }
- oldParent.removeChild(node);
- }
- index = this.childNodes.length;
- if(index == 0){
- this.setFirstChild(node);
- }
- this.childNodes.push(node);
- node.parentNode = this;
- var ps = this.childNodes[index-1];
- if(ps){
- node.previousSibling = ps;
- ps.nextSibling = node;
- }else{
- node.previousSibling = null;
- }
- node.nextSibling = null;
- this.setLastChild(node);
- node.setOwnerTree(this.getOwnerTree());
- this.fireEvent("append", this.ownerTree, this, node, index);
- if(oldParent){
- node.fireEvent("move", this.ownerTree, node, oldParent, this, index);
- }
- return node;
- }
- },
- removeChild : function(node){
- var index = this.childNodes.indexOf(node);
- if(index == -1){
- return false;
- }
- if(this.fireEvent("beforeremove", this.ownerTree, this, node) === false){
- return false;
- }
- this.childNodes.splice(index, 1);
- if(node.previousSibling){
- node.previousSibling.nextSibling = node.nextSibling;
- }
- if(node.nextSibling){
- node.nextSibling.previousSibling = node.previousSibling;
- }
- if(this.firstChild == node){
- this.setFirstChild(node.nextSibling);
- }
- if(this.lastChild == node){
- this.setLastChild(node.previousSibling);
- }
- node.setOwnerTree(null);
- node.parentNode = null;
- node.previousSibling = null;
- node.nextSibling = null;
- this.fireEvent("remove", this.ownerTree, this, node);
- return node;
- },
- insertBefore : function(node, refNode){
- if(!refNode){
- return this.appendChild(node);
- }
- if(node == refNode){
- return false;
- }
- if(this.fireEvent("beforeinsert", this.ownerTree, this, node, refNode) === false){
- return false;
- }
- var index = this.childNodes.indexOf(refNode);
- var oldParent = node.parentNode;
- var refIndex = index;
- if(oldParent == this && this.childNodes.indexOf(node) < index){
- refIndex--;
- }
- if(oldParent){
- if(node.fireEvent("beforemove", node.getOwnerTree(), node, oldParent, this, index, refNode) === false){
- return false;
- }
- oldParent.removeChild(node);
- }
- if(refIndex == 0){
- this.setFirstChild(node);
- }
- this.childNodes.splice(refIndex, 0, node);
- node.parentNode = this;
- var ps = this.childNodes[refIndex-1];
- if(ps){
- node.previousSibling = ps;
- ps.nextSibling = node;
- }else{
- node.previousSibling = null;
- }
- node.nextSibling = refNode;
- refNode.previousSibling = node;
- node.setOwnerTree(this.getOwnerTree());
- this.fireEvent("insert", this.ownerTree, this, node, refNode);
- if(oldParent){
- node.fireEvent("move", this.ownerTree, node, oldParent, this, refIndex, refNode);
- }
- return node;
- },
- remove : function(){
- this.parentNode.removeChild(this);
- return this;
- },
- item : function(index){
- return this.childNodes[index];
- },
- replaceChild : function(newChild, oldChild){
- this.insertBefore(newChild, oldChild);
- this.removeChild(oldChild);
- return oldChild;
- },
- indexOf : function(child){
- return this.childNodes.indexOf(child);
- },
- getOwnerTree : function(){
- if(!this.ownerTree){
- var p = this;
- while(p){
- if(p.ownerTree){
- this.ownerTree = p.ownerTree;
- break;
- }
- p = p.parentNode;
- }
- }
- return this.ownerTree;
- },
- getDepth : function(){
- var depth = 0;
- var p = this;
- while(p.parentNode){
- ++depth;
- p = p.parentNode;
- }
- return depth;
- },
- setOwnerTree : function(tree){
- if(tree != this.ownerTree){
- if(this.ownerTree){
- this.ownerTree.unregisterNode(this);
- }
- this.ownerTree = tree;
- var cs = this.childNodes;
- for(var i = 0, len = cs.length; i < len; i++) {
- cs[i].setOwnerTree(tree);
- }
- if(tree){
- tree.registerNode(this);
- }
- }
- },
- getPath : function(attr){
- attr = attr || "id";
- var p = this.parentNode;
- var b = [this.attributes[attr]];
- while(p){
- b.unshift(p.attributes[attr]);
- p = p.parentNode;
- }
- var sep = this.getOwnerTree().pathSeparator;
- return sep + b.join(sep);
- },
- bubble : function(fn, scope, args){
- var p = this;
- while(p){
- if(fn.apply(scope || p, args || [p]) === false){
- break;
- }
- p = p.parentNode;
- }
- },
- cascade : function(fn, scope, args){
- if(fn.apply(scope || this, args || [this]) !== false){
- var cs = this.childNodes;
- for(var i = 0, len = cs.length; i < len; i++) {
- cs[i].cascade(fn, scope, args);
- }
- }
- },
- eachChild : function(fn, scope, args){
- var cs = this.childNodes;
- for(var i = 0, len = cs.length; i < len; i++) {
- if(fn.apply(scope || this, args || [cs[i]]) === false){
- break;
- }
- }
- },
- findChild : function(attribute, value){
- var cs = this.childNodes;
- for(var i = 0, len = cs.length; i < len; i++) {
- if(cs[i].attributes[attribute] == value){
- return cs[i];
- }
- }
- return null;
- },
- findChildBy : function(fn, scope){
- var cs = this.childNodes;
- for(var i = 0, len = cs.length; i < len; i++) {
- if(fn.call(scope||cs[i], cs[i]) === true){
- return cs[i];
- }
- }
- return null;
- },
- sort : function(fn, scope){
- var cs = this.childNodes;
- var len = cs.length;
- if(len > 0){
- var sortFn = scope ? function(){fn.apply(scope, arguments);} : fn;
- cs.sort(sortFn);
- for(var i = 0; i < len; i++){
- var n = cs[i];
- n.previousSibling = cs[i-1];
- n.nextSibling = cs[i+1];
- if(i == 0){
- this.setFirstChild(n);
- }
- if(i == len-1){
- this.setLastChild(n);
- }
- }
- }
- },
- contains : function(node){
- return node.isAncestor(this);
- },
- isAncestor : function(node){
- var p = this.parentNode;
- while(p){
- if(p == node){
- return true;
- }
- p = p.parentNode;
- }
- return false;
- },
- toString : function(){
- return "[Node"+(this.id?" "+this.id:"")+"]";
- }
- });
- Ext.data.GroupingStore = Ext.extend(Ext.data.Store, {
- remoteGroup : false,
- groupOnSort:false,
- clearGrouping : function(){
- this.groupField = false;
- if(this.remoteGroup){
- if(this.baseParams){
- delete this.baseParams.groupBy;
- }
- this.reload();
- }else{
- this.applySort();
- this.fireEvent('datachanged', this);
- }
- },
- groupBy : function(field, forceRegroup){
- if(this.groupField == field && !forceRegroup){
- return;
- }
- this.groupField = field;
- if(this.remoteGroup){
- if(!this.baseParams){
- this.baseParams = {};
- }
- this.baseParams['groupBy'] = field;
- }
- if(this.groupOnSort){
- this.sort(field);
- return;
- }
- if(this.remoteGroup){
- this.reload();
- }else{
- var si = this.sortInfo || {};
- if(si.field != field){
- this.applySort();
- }else{
- this.sortData(field);
- }
- this.fireEvent('datachanged', this);
- }
- },
- applySort : function(){
- Ext.data.GroupingStore.superclass.applySort.call(this);
- if(!this.groupOnSort && !this.remoteGroup){
- var gs = this.getGroupState();
- if(gs && gs != this.sortInfo.field){
- this.sortData(this.groupField);
- }
- }
- },
- applyGrouping : function(alwaysFireChange){
- if(this.groupField !== false){
- this.groupBy(this.groupField, true);
- return true;
- }else{
- if(alwaysFireChange === true){
- this.fireEvent('datachanged', this);
- }
- return false;
- }
- },
- getGroupState : function(){
- return this.groupOnSort && this.groupField !== false ?
- (this.sortInfo ? this.sortInfo.field : undefined) : this.groupField;
- }
- });
- Ext.ComponentMgr = function(){
- var all = new Ext.util.MixedCollection();
- var types = {};
- return {
- register : function(c){
- all.add(c);
- },
- unregister : function(c){
- all.remove(c);
- },
- get : function(id){
- return all.get(id);
- },
- onAvailable : function(id, fn, scope){
- all.on("add", function(index, o){
- if(o.id == id){
- fn.call(scope || o, o);
- all.un("add", fn, scope);
- }
- });
- },
- all : all,
- registerType : function(xtype, cls){
- types[xtype] = cls;
- cls.xtype = xtype;
- },
- create : function(config, defaultType){
- return new types[config.xtype || defaultType](config);
- }
- };
- }();
- Ext.reg = Ext.ComponentMgr.registerType;
- Ext.Component = function(config){
- config = config || {};
- if(config.initialConfig){
- if(config.isAction){ this.baseAction = config;
- }
- config = config.initialConfig; }else if(config.tagName || config.dom || typeof config == "string"){ config = {applyTo: config, id: config.id || config};
- }
- this.initialConfig = config;
- Ext.apply(this, config);
- this.addEvents(
- 'disable',
- 'enable',
- 'beforeshow',
- 'show',
- 'beforehide',
- 'hide',
- 'beforerender',
- 'render',
- 'beforedestroy',
- 'destroy',
- 'beforestaterestore',
- 'staterestore',
- 'beforestatesave',
- 'statesave'
- );
- this.getId();
- Ext.ComponentMgr.register(this);
- Ext.Component.superclass.constructor.call(this);
- if(this.baseAction){
- this.baseAction.addComponent(this);
- }
- this.initComponent();
- if(this.plugins){
- if(Ext.isArray(this.plugins)){
- for(var i = 0, len = this.plugins.length; i < len; i++){
- this.plugins[i].init(this);
- }
- }else{
- this.plugins.init(this);
- }
- }
- if(this.stateful !== false){
- this.initState(config);
- }
- if(this.applyTo){
- this.applyToMarkup(this.applyTo);
- delete this.applyTo;
- }else if(this.renderTo){
- this.render(this.renderTo);
- delete this.renderTo;
- }
- };
- Ext.Component.AUTO_ID = 1000;
- Ext.extend(Ext.Component, Ext.util.Observable, {
- disabledClass : "x-item-disabled",
- allowDomMove : true,
- autoShow : false,
- hideMode: 'display',
- hideParent: false,
- hidden : false,
- disabled : false,
- rendered : false,
- ctype : "Ext.Component",
- actionMode : "el",
- getActionEl : function(){
- return this[this.actionMode];
- },
- initComponent : Ext.emptyFn,
- render : function(container, position){
- if(!this.rendered && this.fireEvent("beforerender", this) !== false){
- if(!container && this.el){
- this.el = Ext.get(this.el);
- container = this.el.dom.parentNode;
- this.allowDomMove = false;
- }
- this.container = Ext.get(container);
- if(this.ctCls){
- this.container.addClass(this.ctCls);
- }
- this.rendered = true;
- if(position !== undefined){
- if(typeof position == 'number'){
- position = this.container.dom.childNodes[position];
- }else{
- position = Ext.getDom(position);
- }
- }
- this.onRender(this.container, position || null);
- if(this.autoShow){
- this.el.removeClass(['x-hidden','x-hide-' + this.hideMode]);
- }
- if(this.cls){
- this.el.addClass(this.cls);
- delete this.cls;
- }
- if(this.style){
- this.el.applyStyles(this.style);
- delete this.style;
- }
- this.fireEvent("render", this);
- this.afterRender(this.container);
- if(this.hidden){
- this.hide();
- }
- if(this.disabled){
- this.disable();
- }
- this.initStateEvents();
- }
- return this;
- },
- initState : function(config){
- if(Ext.state.Manager){
- var state = Ext.state.Manager.get(this.stateId || this.id);
- if(state){
- if(this.fireEvent('beforestaterestore', this, state) !== false){
- this.applyState(state);
- this.fireEvent('staterestore', this, state);
- }
- }
- }
- },
- initStateEvents : function(){
- if(this.stateEvents){
- for(var i = 0, e; e = this.stateEvents[i]; i++){
- this.on(e, this.saveState, this, {delay:100});
- }
- }
- },
- applyState : function(state, config){
- if(state){
- Ext.apply(this, state);
- }
- },
- getState : function(){
- return null;
- },
- saveState : function(){
- if(Ext.state.Manager){
- var state = this.getState();
- if(this.fireEvent('beforestatesave', this, state) !== false){
- Ext.state.Manager.set(this.stateId || this.id, state);
- this.fireEvent('statesave', this, state);
- }
- }
- },
- applyToMarkup : function(el){
- this.allowDomMove = false;
- this.el = Ext.get(el);
- this.render(this.el.dom.parentNode);
- },
- addClass : function(cls){
- if(this.el){
- this.el.addClass(cls);
- }else{
- this.cls = this.cls ? this.cls + ' ' + cls : cls;
- }
- },
- removeClass : function(cls){
- if(this.el){
- this.el.removeClass(cls);
- }else if(this.cls){
- this.cls = this.cls.split(' ').remove(cls).join(' ');
- }
- },
- onRender : function(ct, position){
- if(this.autoEl){
- if(typeof this.autoEl == 'string'){
- this.el = document.createElement(this.autoEl);
- }else{
- var div = document.createElement('div');
- Ext.DomHelper.overwrite(div, this.autoEl);
- this.el = div.firstChild;
- }
- if (!this.el.id) {
- this.el.id = this.getId();
- }
- }
- if(this.el){
- this.el = Ext.get(this.el);
- if(this.allowDomMove !== false){
- ct.dom.insertBefore(this.el.dom, position);
- }
- }
- },
- getAutoCreate : function(){
- var cfg = typeof this.autoCreate == "object" ?
- this.autoCreate : Ext.apply({}, this.defaultAutoCreate);
- if(this.id && !cfg.id){
- cfg.id = this.id;
- }
- return cfg;
- },
- afterRender : Ext.emptyFn,
- destroy : function(){
- if(this.fireEvent("beforedestroy", this) !== false){
- this.beforeDestroy();
- if(this.rendered){
- this.el.removeAllListeners();
- this.el.remove();
- if(this.actionMode == "container"){
- this.container.remove();
- }
- }
- this.onDestroy();
- Ext.ComponentMgr.unregister(this);
- this.fireEvent("destroy", this);
- this.purgeListeners();
- }
- },
- beforeDestroy : Ext.emptyFn,
- onDestroy : Ext.emptyFn,
- getEl : function(){
- return this.el;
- },
- getId : function(){
- return this.id || (this.id = "ext-comp-" + (++Ext.Component.AUTO_ID));
- },
- getItemId : function(){
- return this.itemId || this.getId();
- },
- focus : function(selectText, delay){
- if(delay){
- this.focus.defer(typeof delay == 'number' ? delay : 10, this, [selectText, false]);
- return;
- }
- if(this.rendered){
- this.el.focus();
- if(selectText === true){
- this.el.dom.select();
- }
- }
- return this;
- },
- blur : function(){
- if(this.rendered){
- this.el.blur();
- }
- return this;
- },
- disable : function(){
- if(this.rendered){
- this.onDisable();
- }
- this.disabled = true;
- this.fireEvent("disable", this);
- return this;
- },
- onDisable : function(){
- this.getActionEl().addClass(this.disabledClass);
- this.el.dom.disabled = true;
- },
- enable : function(){
- if(this.rendered){
- this.onEnable();
- }
- this.disabled = false;
- this.fireEvent("enable", this);
- return this;
- },
- onEnable : function(){
- this.getActionEl().removeClass(this.disabledClass);
- this.el.dom.disabled = false;
- },
- setDisabled : function(disabled){
- this[disabled ? "disable" : "enable"]();
- },
- show: function(){
- if(this.fireEvent("beforeshow", this) !== false){
- this.hidden = false;
- if(this.autoRender){
- this.render(typeof this.autoRender == 'boolean' ? Ext.getBody() : this.autoRender);
- }
- if(this.rendered){
- this.onShow();
- }
- this.fireEvent("show", this);
- }
- return this;
- },
- onShow : function(){
- if(this.hideParent){
- this.container.removeClass('x-hide-' + this.hideMode);
- }else{
- this.getActionEl().removeClass('x-hide-' + this.hideMode);
- }
- },
- hide: function(){
- if(this.fireEvent("beforehide", this) !== false){
- this.hidden = true;
- if(this.rendered){
- this.onHide();
- }
- this.fireEvent("hide", this);
- }
- return this;
- },
- onHide : function(){
- if(this.hideParent){
- this.container.addClass('x-hide-' + this.hideMode);
- }else{
- this.getActionEl().addClass('x-hide-' + this.hideMode);
- }
- },
- setVisible: function(visible){
- if(visible) {
- this.show();
- }else{
- this.hide();
- }
- return this;
- },
- isVisible : function(){
- return this.rendered && this.getActionEl().isVisible();
- },
- cloneConfig : function(overrides){
- overrides = overrides || {};
- var id = overrides.id || Ext.id();
- var cfg = Ext.applyIf(overrides, this.initialConfig);
- cfg.id = id; return new this.constructor(cfg);
- },
- getXType : function(){
- return this.constructor.xtype;
- },
- isXType : function(xtype, shallow){
- return !shallow ?
- ('/' + this.getXTypes() + '/').indexOf('/' + xtype + '/') != -1 :
- this.constructor.xtype == xtype;
- },
- getXTypes : function(){
- var tc = this.constructor;
- if(!tc.xtypes){
- var c = [], sc = this;
- while(sc && sc.constructor.xtype){
- c.unshift(sc.constructor.xtype);
- sc = sc.constructor.superclass;
- }
- tc.xtypeChain = c;
- tc.xtypes = c.join('/');
- }
- return tc.xtypes;
- },
- findParentBy: function(fn) {
- for (var p = this.ownerCt; (p != null) && !fn(p, this); p = p.ownerCt);
- return p || null;
- },
- findParentByType: function(xtype) {
- return typeof xtype == 'function' ?
- this.findParentBy(function(p){
- return p.constructor === xtype;
- }) :
- this.findParentBy(function(p){
- return p.constructor.xtype === xtype;
- });
- }
- });
- Ext.reg('component', Ext.Component);
- Ext.Action = function(config){
- this.initialConfig = config;
- this.items = [];
- }
- Ext.Action.prototype = {
- isAction : true,
- setText : function(text){
- this.initialConfig.text = text;
- this.callEach('setText', [text]);
- },
- getText : function(){
- return this.initialConfig.text;
- },
- setIconClass : function(cls){
- this.initialConfig.iconCls = cls;
- this.callEach('setIconClass', [cls]);
- },
- getIconClass : function(){
- return this.initialConfig.iconCls;
- },
- setDisabled : function(v){
- this.initialConfig.disabled = v;
- this.callEach('setDisabled', [v]);
- },
- enable : function(){
- this.setDisabled(false);
- },
- disable : function(){
- this.setDisabled(true);
- },
- isDisabled : function(){
- return this.initialConfig.disabled;
- },
- setHidden : function(v){
- this.initialConfig.hidden = v;
- this.callEach('setVisible', [!v]);
- },
- show : function(){
- this.setHidden(false);
- },
- hide : function(){
- this.setHidden(true);
- },
- isHidden : function(){
- return this.initialConfig.hidden;
- },
- setHandler : function(fn, scope){
- this.initialConfig.handler = fn;
- this.initialConfig.scope = scope;
- this.callEach('setHandler', [fn, scope]);
- },