ext-all-debug.js
资源名称:ext-3.1.0.zip [点击查看]
上传用户:dawnssy
上传日期:2022-08-06
资源大小:9345k
文件大小:1167k
源码类别:
JavaScript
开发平台:
JavaScript
- 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, {
- getDragEl: Ext.emptyFn,
- isValidHandleChild: Ext.emptyFn,
- startDrag: Ext.emptyFn,
- endDrag: Ext.emptyFn,
- onDrag: Ext.emptyFn,
- onDragDrop: Ext.emptyFn,
- onDragEnter: Ext.emptyFn,
- onDragOut: Ext.emptyFn,
- onDragOver: Ext.emptyFn,
- onInvalidDrop: Ext.emptyFn,
- onMouseDown: Ext.emptyFn,
- onMouseUp: Ext.emptyFn,
- setXConstraint: Ext.emptyFn,
- setYConstraint: Ext.emptyFn,
- resetConstraints: Ext.emptyFn,
- clearConstraints: Ext.emptyFn,
- clearTicks: Ext.emptyFn,
- setInitPosition: Ext.emptyFn,
- setDragElId: Ext.emptyFn,
- setHandleElId: Ext.emptyFn,
- setOuterHandleElId: Ext.emptyFn,
- addInvalidHandleClass: Ext.emptyFn,
- addInvalidHandleId: Ext.emptyFn,
- addInvalidHandleType: Ext.emptyFn,
- removeInvalidHandleClass: Ext.emptyFn,
- removeInvalidHandleId: Ext.emptyFn,
- removeInvalidHandleType: Ext.emptyFn,
- toString: function() {
- return ("DDTarget " + this.id);
- }
- });
- Ext.dd.DragTracker = Ext.extend(Ext.util.Observable, {
- active: false,
- tolerance: 5,
- autoStart: false,
- constructor : 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.dd.DragTracker.superclass.constructor.call(this, config);
- },
- 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;
- if(this.preventDefault !== false){
- 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){
- if(this.active && Ext.isIE && !e.browserEvent.button){
- e.preventDefault();
- this.onMouseUp(e);
- return;
- }
- 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();
- var wasActive = this.active;
- this.active = false;
- delete this.elRegion;
- this.fireEvent('mouseup', this, e);
- if(wasActive){
- 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;
- var freq = (el.ddScrollConfig && el.ddScrollConfig.frequency) ?
- el.ddScrollConfig.frequency : Ext.dd.ScrollManager.frequency;
- proc.id = setInterval(doScroll, freq);
- };
- 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);
- }
- var el = this.ghost.dom.firstChild;
- if(el){
- Ext.fly(el).setStyle('float', 'none');
- }
- },
- 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;
- },
- destroy: function(){
- Ext.destroy(this.ghost, this.el);
- }
- };
- 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);
- },
- destroy: function(){
- Ext.dd.DragSource.superclass.destroy.call(this);
- Ext.destroy(this.proxy);
- }
- });
- 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.Element.addMethods({
- initDD : function(group, config, overrides){
- var dd = new Ext.dd.DD(Ext.id(this.dom), group, config);
- return Ext.apply(dd, overrides);
- },
- initDDProxy : function(group, config, overrides){
- var dd = new Ext.dd.DDProxy(Ext.id(this.dom), group, config);
- return Ext.apply(dd, overrides);
- },
- initDDTarget : function(group, config, overrides){
- var dd = new Ext.dd.DDTarget(Ext.id(this.dom), group, config);
- return Ext.apply(dd, overrides);
- }
- });
- Ext.data.Api = (function() {
- var validActions = {};
- return {
- actions : {
- create : 'create',
- read : 'read',
- update : 'update',
- destroy : 'destroy'
- },
- restActions : {
- create : 'POST',
- read : 'GET',
- update : 'PUT',
- destroy : 'DELETE'
- },
- isAction : function(action) {
- return (Ext.data.Api.actions[action]) ? true : false;
- },
- getVerb : function(name) {
- if (validActions[name]) {
- return validActions[name];
- }
- for (var verb in this.actions) {
- if (this.actions[verb] === name) {
- validActions[name] = verb;
- break;
- }
- }
- return (validActions[name] !== undefined) ? validActions[name] : null;
- },
- isValid : function(api){
- var invalid = [];
- var crud = this.actions;
- for (var action in api) {
- if (!(action in crud)) {
- invalid.push(action);
- }
- }
- return (!invalid.length) ? true : invalid;
- },
- hasUniqueUrl : function(proxy, verb) {
- var url = (proxy.api[verb]) ? proxy.api[verb].url : null;
- var unique = true;
- for (var action in proxy.api) {
- if ((unique = (action === verb) ? true : (proxy.api[action].url != url) ? true : false) === false) {
- break;
- }
- }
- return unique;
- },
- prepare : function(proxy) {
- if (!proxy.api) {
- proxy.api = {};
- }
- for (var verb in this.actions) {
- var action = this.actions[verb];
- proxy.api[action] = proxy.api[action] || proxy.url || proxy.directFn;
- if (typeof(proxy.api[action]) == 'string') {
- proxy.api[action] = {
- url: proxy.api[action],
- method: (proxy.restful === true) ? Ext.data.Api.restActions[action] : undefined
- };
- }
- }
- },
- restify : function(proxy) {
- proxy.restful = true;
- for (var verb in this.restActions) {
- proxy.api[this.actions[verb]].method = this.restActions[verb];
- }
- proxy.onWrite = proxy.onWrite.createInterceptor(function(action, o, response, rs) {
- var reader = o.reader;
- var res = new Ext.data.Response({
- action: action,
- raw: response
- });
- switch (response.status) {
- case 200:
- return true;
- break;
- case 201:
- res.success = true;
- break;
- case 204:
- res.success = true;
- res.data = null;
- break;
- default:
- return true;
- break;
- }
- if (res.success === true) {
- this.fireEvent("write", this, action, res.data, res, rs, o.request.arg);
- } else {
- this.fireEvent('exception', this, 'remote', action, o, res, rs);
- }
- o.request.callback.call(o.request.scope, res.data, res, res.success);
- return false;
- }, proxy);
- }
- };
- })();
- Ext.data.Response = function(params, response) {
- Ext.apply(this, params, {
- raw: response
- });
- };
- Ext.data.Response.prototype = {
- message : null,
- success : false,
- status : null,
- root : null,
- raw : null,
- getMessage : function() {
- return this.message;
- },
- getSuccess : function() {
- return this.success;
- },
- getStatus : function() {
- return this.status
- },
- getRoot : function() {
- return this.root;
- },
- getRawResponse : function() {
- return this.raw;
- }
- };
- Ext.data.Api.Error = Ext.extend(Ext.Error, {
- constructor : function(message, arg) {
- this.arg = arg;
- Ext.Error.call(this, message);
- },
- name: 'Ext.data.Api'
- });
- Ext.apply(Ext.data.Api.Error.prototype, {
- lang: {
- 'action-url-undefined': 'No fallback url defined for this action. When defining a DataProxy api, please be sure to define an url for each CRUD action in Ext.data.Api.actions or define a default url in addition to your api-configuration.',
- 'invalid': 'received an invalid API-configuration. Please ensure your proxy API-configuration contains only the actions defined in Ext.data.Api.actions',
- 'invalid-url': 'Invalid url. Please review your proxy configuration.',
- 'execute': 'Attempted to execute an unknown action. Valid API actions are defined in Ext.data.Api.actions"'
- }
- });
- 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, ""));
- return isNaN(val) ? 0 : val;
- },
- asInt : function(s) {
- var val = parseInt(String(s).replace(/,/g, ""), 10);
- return isNaN(val) ? 0 : val;
- }
- };
- Ext.data.Record = function(data, id){
- this.id = (id || id === 0) ? id : Ext.data.Record.id(this);
- 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.PREFIX = 'ext-record';
- Ext.data.Record.AUTO_ID = 1;
- Ext.data.Record.EDIT = 'edit';
- Ext.data.Record.REJECT = 'reject';
- Ext.data.Record.COMMIT = 'commit';
- Ext.data.Record.id = function(rec) {
- rec.phantom = true;
- return [Ext.data.Record.PREFIX, '-', Ext.data.Record.AUTO_ID++].join('');
- };
- Ext.data.Record.prototype = {
- dirty : false,
- editing : false,
- error : null,
- modified : null,
- phantom : false,
- join : function(store){
- this.store = store;
- },
- set : function(name, value){
- var encode = Ext.isPrimitive(value) ? String : Ext.encode;
- if(encode(this.data[name]) == encode(value)) {
- return;
- }
- this.dirty = true;
- if(!this.modified){
- this.modified = {};
- }
- if(this.modified[name] === undefined){
- this.modified[name] = this.data[name];
- }
- this.data[name] = value;
- if(!this.editing){
- this.afterEdit();
- }
- },
- afterEdit : function(){
- if(this.store){
- this.store.afterEdit(this);
- }
- },
- afterReject : function(){
- if(this.store){
- this.store.afterReject(this);
- }
- },
- afterCommit : function(){
- if(this.store){
- this.store.afterCommit(this);
- }
- },
- get : function(name){
- return this.data[name];
- },
- beginEdit : function(){
- this.editing = true;
- this.modified = this.modified || {};
- },
- cancelEdit : function(){
- this.editing = false;
- delete this.modified;
- },
- endEdit : function(){
- this.editing = false;
- if(this.dirty){
- this.afterEdit();
- }
- },
- 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(silent !== true){
- this.afterReject();
- }
- },
- commit : function(silent){
- this.dirty = false;
- delete this.modified;
- this.editing = false;
- if(silent !== true){
- this.afterCommit();
- }
- },
- 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));
- },
- isValid : function() {
- return this.fields.find(function(f) {
- return (f.allowBlank === false && Ext.isEmpty(this.data[f.name])) ? true : false;
- },this) ? false : true;
- },
- markDirty : function(){
- this.dirty = true;
- if(!this.modified){
- this.modified = {};
- }
- this.fields.each(function(f) {
- this.modified[f.name] = this.data[f.name];
- },this);
- }
- };
- 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){
- if(Ext.isArray(id)){
- var fields = ['field1'], expand = !Ext.isArray(id[0]);
- if(!expand){
- for(var i = 2, len = id[0].length; i <= len; ++i){
- fields.push('field' + i);
- }
- }
- return new Ext.data.ArrayStore({
- fields: fields,
- data: id,
- expandData: expand,
- autoDestroy: true,
- autoCreated: true
- });
- }
- return Ext.isObject(id) ? (id.events ? id : Ext.create(id, 'store')) : this.get(id);
- },
- getKey : function(o){
- return o.storeId;
- }
- });
- Ext.data.Store = Ext.extend(Ext.util.Observable, {
- writer : undefined,
- remoteSort : false,
- autoDestroy : false,
- pruneModifiedRecords : false,
- lastOptions : null,
- autoSave : true,
- batch : true,
- restful: false,
- paramNames : undefined,
- defaultParamNames : {
- start : 'start',
- limit : 'limit',
- sort : 'sort',
- dir : 'dir'
- },
- batchKey : '_ext_batch_',
- constructor : function(config){
- this.data = new Ext.util.MixedCollection(false);
- this.data.getKey = function(o){
- return o.id;
- };
- this.baseParams = {};
- this.removed = [];
- if(config && config.data){
- this.inlineData = config.data;
- delete config.data;
- }
- Ext.apply(this, config);
- this.paramNames = Ext.applyIf(this.paramNames || {}, this.defaultParamNames);
- if((this.url || this.api) && !this.proxy){
- this.proxy = new Ext.data.HttpProxy({url: this.url, api: this.api});
- }
- if (this.restful === true && this.proxy) {
- this.batch = false;
- Ext.data.Api.restify(this.proxy);
- }
- if(this.reader){
- if(!this.recordType){
- this.recordType = this.reader.recordType;
- }
- if(this.reader.onMetaChange){
- this.reader.onMetaChange = this.reader.onMetaChange.createSequence(this.onMetaChange, this);
- }
- if (this.writer) {
- if (this.writer instanceof(Ext.data.DataWriter) === false) {
- this.writer = this.buildWriter(this.writer);
- }
- this.writer.meta = this.reader.meta;
- this.pruneModifiedRecords = true;
- }
- }
- if(this.recordType){
- this.fields = this.recordType.prototype.fields;
- }
- this.modified = [];
- this.addEvents(
- 'datachanged',
- 'metachange',
- 'add',
- 'remove',
- 'update',
- 'clear',
- 'exception',
- 'beforeload',
- 'load',
- 'loadexception',
- 'beforewrite',
- 'write',
- 'beforesave',
- 'save'
- );
- if(this.proxy){
- this.relayEvents(this.proxy, ['loadexception', 'exception']);
- }
- if (this.writer) {
- this.on({
- scope: this,
- add: this.createRecords,
- remove: this.destroyRecord,
- update: this.updateRecord,
- clear: this.onClear
- });
- }
- this.sortToggle = {};
- if(this.sortField){
- this.setDefaultSort(this.sortField, this.sortDir);
- }else if(this.sortInfo){
- this.setDefaultSort(this.sortInfo.field, this.sortInfo.direction);
- }
- Ext.data.Store.superclass.constructor.call(this);
- if(this.id){
- this.storeId = this.id;
- delete this.id;
- }
- if(this.storeId){
- 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]);
- }
- this.batchCounter = 0;
- this.batches = {};
- },
- buildWriter : function(config) {
- var klass = undefined;
- type = (config.format || 'json').toLowerCase();
- switch (type) {
- case 'json':
- klass = Ext.data.JsonWriter;
- break;
- case 'xml':
- klass = Ext.data.XmlWriter;
- break;
- default:
- klass = Ext.data.JsonWriter;
- }
- return new klass(config);
- },
- destroy : function(){
- if(!this.isDestroyed){
- if(this.storeId){
- Ext.StoreMgr.unregister(this);
- }
- this.clearData();
- this.data = null;
- Ext.destroy(this.proxy);
- this.reader = this.writer = null;
- this.purgeListeners();
- this.isDestroyed = true;
- }
- },
- 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){
- if(Ext.isArray(record)){
- Ext.each(record, function(r){
- this.remove(r);
- }, this);
- }
- var index = this.data.indexOf(record);
- if(index > -1){
- record.join(null);
- this.data.removeAt(index);
- }
- if(this.pruneModifiedRecords){
- this.modified.remove(record);
- }
- if(this.snapshot){
- this.snapshot.remove(record);
- }
- if(index > -1){
- this.fireEvent('remove', this, record, index);
- }
- },
- removeAt : function(index){
- this.remove(this.getAt(index));
- },
- removeAll : function(silent){
- var items = [];
- this.each(function(rec){
- items.push(rec);
- });
- this.clearData();
- if(this.snapshot){
- this.snapshot.clear();
- }
- if(this.pruneModifiedRecords){
- this.modified = [];
- }
- if (silent !== true) {
- this.fireEvent('clear', this, items);
- }
- },
- onClear: function(store, records){
- Ext.each(records, function(rec, index){
- this.destroyRecord(this, rec, index);
- }, 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);
- }
- if(this.snapshot){
- this.snapshot.addAll(records);
- }
- 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.snapshot || 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;
- },
- clearData: function(){
- this.data.each(function(rec) {
- rec.join(null);
- });
- this.data.clear();
- },
- load : function(options) {
- options = options || {};
- this.storeOptions(options);
- if(this.sortInfo && this.remoteSort){
- var pn = this.paramNames;
- options.params = options.params || {};
- options.params[pn.sort] = this.sortInfo.field;
- options.params[pn.dir] = this.sortInfo.direction;
- }
- try {
- return this.execute('read', null, options);
- } catch(e) {
- this.handleException(e);
- return false;
- }
- },
- updateRecord : function(store, record, action) {
- if (action == Ext.data.Record.EDIT && this.autoSave === true && (!record.phantom || (record.phantom && record.isValid()))) {
- this.save();
- }
- },
- createRecords : function(store, rs, index) {
- for (var i = 0, len = rs.length; i < len; i++) {
- if (rs[i].phantom && rs[i].isValid()) {
- rs[i].markDirty();
- this.modified.push(rs[i]);
- }
- }
- if (this.autoSave === true) {
- this.save();
- }
- },
- destroyRecord : function(store, record, index) {
- if (this.modified.indexOf(record) != -1) {
- this.modified.remove(record);
- }
- if (!record.phantom) {
- this.removed.push(record);
- record.lastIndex = index;
- if (this.autoSave === true) {
- this.save();
- }
- }
- },
- execute : function(action, rs, options, batch) {
- if (!Ext.data.Api.isAction(action)) {
- throw new Ext.data.Api.Error('execute', action);
- }
- options = Ext.applyIf(options||{}, {
- params: {}
- });
- if(batch !== undefined){
- this.addToBatch(batch);
- }
- var doRequest = true;
- if (action === 'read') {
- Ext.applyIf(options.params, this.baseParams);
- doRequest = this.fireEvent('beforeload', this, options);
- }
- else {
- if (this.writer.listful === true && this.restful !== true) {
- rs = (Ext.isArray(rs)) ? rs : [rs];
- }
- else if (Ext.isArray(rs) && rs.length == 1) {
- rs = rs.shift();
- }
- if ((doRequest = this.fireEvent('beforewrite', this, action, rs, options)) !== false) {
- this.writer.apply(options.params, this.baseParams, action, rs);
- }
- }
- if (doRequest !== false) {
- if (this.writer && this.proxy.url && !this.proxy.restful && !Ext.data.Api.hasUniqueUrl(this.proxy, action)) {
- options.params.xaction = action;
- }
- this.proxy.request(Ext.data.Api.actions[action], rs, options.params, this.reader, this.createCallback(action, rs, batch), this, options);
- }
- return doRequest;
- },
- save : function() {
- if (!this.writer) {
- throw new Ext.data.Store.Error('writer-undefined');
- }
- var queue = [],
- len,
- trans,
- batch,
- data = {};
- if(this.removed.length){
- queue.push(['destroy', this.removed]);
- }
- var rs = [].concat(this.getModifiedRecords());
- if(rs.length){
- var phantoms = [];
- for(var i = rs.length-1; i >= 0; i--){
- if(rs[i].phantom === true){
- var rec = rs.splice(i, 1).shift();
- if(rec.isValid()){
- phantoms.push(rec);
- }
- }else if(!rs[i].isValid()){
- rs.splice(i,1);
- }
- }
- if(phantoms.length){
- queue.push(['create', phantoms]);
- }
- if(rs.length){
- queue.push(['update', rs]);
- }
- }
- len = queue.length;
- if(len){
- batch = ++this.batchCounter;
- for(var i = 0; i < len; ++i){
- trans = queue[i];
- data[trans[0]] = trans[1];
- }
- if(this.fireEvent('beforesave', this, data) !== false){
- for(var i = 0; i < len; ++i){
- trans = queue[i];
- this.doTransaction(trans[0], trans[1], batch);
- }
- return batch;
- }
- }
- return -1;
- },
- doTransaction : function(action, rs, batch) {
- function transaction(records) {
- try{
- this.execute(action, records, undefined, batch);
- }catch (e){
- this.handleException(e);
- }
- }
- if(this.batch === false){
- for(var i = 0, len = rs.length; i < len; i++){
- transaction.call(this, rs[i]);
- }
- }else{
- transaction.call(this, rs);
- }
- },
- addToBatch : function(batch){
- var b = this.batches,
- key = this.batchKey + batch,
- o = b[key];
- if(!o){
- b[key] = o = {
- id: batch,
- count: 0,
- data: {}
- }
- }
- ++o.count;
- },
- removeFromBatch : function(batch, action, data){
- var b = this.batches,
- key = this.batchKey + batch,
- o = b[key],
- data,
- arr;
- if(o){
- arr = o.data[action] || [];
- o.data[action] = arr.concat(data);
- if(o.count === 1){
- data = o.data;
- delete b[key];
- this.fireEvent('save', this, batch, data);
- }else{
- --o.count;
- }
- }
- },
- createCallback : function(action, rs, batch) {
- var actions = Ext.data.Api.actions;
- return (action == 'read') ? this.loadRecords : function(data, response, success) {
- this['on' + Ext.util.Format.capitalize(action) + 'Records'](success, rs, [].concat(data));
- if (success === true) {
- this.fireEvent('write', this, action, data, response, rs);
- }
- this.removeFromBatch(batch, action, data);
- };
- },
- clearModified : function(rs) {
- if (Ext.isArray(rs)) {
- for (var n=rs.length-1;n>=0;n--) {
- this.modified.splice(this.modified.indexOf(rs[n]), 1);
- }
- } else {
- this.modified.splice(this.modified.indexOf(rs), 1);
- }
- },
- reMap : function(record) {
- if (Ext.isArray(record)) {
- for (var i = 0, len = record.length; i < len; i++) {
- this.reMap(record[i]);
- }
- } else {
- delete this.data.map[record._phid];
- this.data.map[record.id] = record;
- var index = this.data.keys.indexOf(record._phid);
- this.data.keys.splice(index, 1, record.id);
- delete record._phid;
- }
- },
- onCreateRecords : function(success, rs, data) {
- if (success === true) {
- try {
- this.reader.realize(rs, data);
- this.reMap(rs);
- }
- catch (e) {
- this.handleException(e);
- if (Ext.isArray(rs)) {
- this.onCreateRecords(success, rs, data);
- }
- }
- }
- },
- onUpdateRecords : function(success, rs, data) {
- if (success === true) {
- try {
- this.reader.update(rs, data);
- } catch (e) {
- this.handleException(e);
- if (Ext.isArray(rs)) {
- this.onUpdateRecords(success, rs, data);
- }
- }
- }
- },
- onDestroyRecords : function(success, rs, data) {
- rs = (rs instanceof Ext.data.Record) ? [rs] : [].concat(rs);
- for (var i=0,len=rs.length;i<len;i++) {
- this.removed.splice(this.removed.indexOf(rs[i]), 1);
- }
- if (success === false) {
- for (i=rs.length-1;i>=0;i--) {
- this.insert(rs[i].lastIndex, rs[i]);
- }
- }
- },
- handleException : function(e) {
- Ext.handleError(e);
- },
- reload : function(options){
- this.load(Ext.applyIf(options||{}, this.lastOptions));
- },
- loadRecords : function(o, options, success){
- if (this.isDestroyed === true) {
- return;
- }
- if(!o || success === false){
- if(success !== false){
- this.fireEvent('load', this, [], options);
- }
- if(options.callback){
- options.callback.call(options.scope || this, [], options, false, o);
- }
- 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.clearData();
- 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;
- },
- findExact: function(property, value, start){
- return this.data.findIndexBy(function(rec){
- return rec.get(property) === value;
- }, this, start);
- },
- 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();
- }
- var m = this.removed.slice(0).reverse();
- this.removed = [];
- for(var i = 0, len = m.length; i < len; i++){
- this.insert(m[i].lastIndex||0, m[i]);
- m[i].reject();
- }
- },
- onMetaChange : function(meta){
- this.recordType = this.reader.recordType;
- this.fields = this.recordType.prototype.fields;
- delete this.snapshot;
- if(this.reader.meta.sortInfo){
- this.sortInfo = this.reader.meta.sortInfo;
- }else if(this.sortInfo && !this.fields.get(this.sortInfo.field)){
- delete this.sortInfo;
- }
- if(this.writer){
- this.writer.meta = this.reader.meta;
- }
- 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;
- },
- setBaseParam : function (name, value){
- this.baseParams = this.baseParams || {};
- this.baseParams[name] = value;
- }
- });
- Ext.reg('store', Ext.data.Store);
- Ext.data.Store.Error = Ext.extend(Ext.Error, {
- name: 'Ext.data.Store'
- });
- Ext.apply(Ext.data.Store.Error.prototype, {
- lang: {
- 'writer-undefined' : 'Attempted to execute a write-action without a DataWriter installed.'
- }
- });
- 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":
- 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;
- default:
- cv = function(v){ return v; };
- break;
- }
- this.convert = cv;
- }
- };
- Ext.data.Field.prototype = {
- dateFormat: null,
- defaultValue: "",
- mapping: null,
- sortType : null,
- sortDir : "ASC",
- allowBlank : true
- };
- Ext.data.DataReader = function(meta, recordType){
- this.meta = meta;
- this.recordType = Ext.isArray(recordType) ?
- Ext.data.Record.create(recordType) : recordType;
- if (this.recordType){
- this.buildExtractors();
- }
- };
- Ext.data.DataReader.prototype = {
- getTotal: Ext.emptyFn,
- getRoot: Ext.emptyFn,
- getMessage: Ext.emptyFn,
- getSuccess: Ext.emptyFn,
- getId: Ext.emptyFn,
- buildExtractors : Ext.emptyFn,
- extractData : Ext.emptyFn,
- extractValues : Ext.emptyFn,
- realize: function(rs, data){
- if (Ext.isArray(rs)) {
- for (var i = rs.length - 1; i >= 0; i--) {
- if (Ext.isArray(data)) {
- this.realize(rs.splice(i,1).shift(), data.splice(i,1).shift());
- }
- else {
- this.realize(rs.splice(i,1).shift(), data);
- }
- }
- }
- else {
- if (Ext.isArray(data) && data.length == 1) {
- data = data.shift();
- }
- if (!this.isData(data)) {
- throw new Ext.data.DataReader.Error('realize', rs);
- }
- rs.phantom = false;
- rs._phid = rs.id;
- rs.id = this.getId(data);
- rs.fields.each(function(f) {
- if (data[f.name] !== f.defaultValue) {
- rs.data[f.name] = data[f.name];
- }
- });
- rs.commit();
- }
- },
- update : function(rs, data) {
- if (Ext.isArray(rs)) {
- for (var i=rs.length-1; i >= 0; i--) {
- if (Ext.isArray(data)) {
- this.update(rs.splice(i,1).shift(), data.splice(i,1).shift());
- }
- else {
- this.update(rs.splice(i,1).shift(), data);
- }
- }
- }
- else {
- if (Ext.isArray(data) && data.length == 1) {
- data = data.shift();
- }
- if (this.isData(data)) {
- rs.fields.each(function(f) {
- if (data[f.name] !== f.defaultValue) {
- rs.data[f.name] = data[f.name];
- }
- });
- }
- rs.commit();
- }
- },
- extractData : function(root, returnRecords) {
- var rawName = (this instanceof Ext.data.JsonReader) ? 'json' : 'node';
- var rs = [];
- if (this.isData(root) && !(this instanceof Ext.data.XmlReader)) {
- root = [root];
- }
- var f = this.recordType.prototype.fields,
- fi = f.items,
- fl = f.length,
- rs = [];
- if (returnRecords === true) {
- var Record = this.recordType;
- for (var i = 0; i < root.length; i++) {
- var n = root[i];
- var record = new Record(this.extractValues(n, fi, fl), this.getId(n));
- record[rawName] = n;
- rs.push(record);
- }
- }
- else {
- for (var i = 0; i < root.length; i++) {
- var data = this.extractValues(root[i], fi, fl);
- data[this.meta.idProperty] = this.getId(root[i]);
- rs.push(data);
- }
- }
- return rs;
- },
- isData : function(data) {
- return (data && Ext.isObject(data) && !Ext.isEmpty(this.getId(data))) ? true : false;
- },
- onMetaChange : function(meta){
- delete this.ef;
- this.meta = meta;
- this.recordType = Ext.data.Record.create(meta.fields);
- this.buildExtractors();
- }
- };
- Ext.data.DataReader.Error = Ext.extend(Ext.Error, {
- constructor : function(message, arg) {
- this.arg = arg;
- Ext.Error.call(this, message);
- },
- name: 'Ext.data.DataReader'
- });
- Ext.apply(Ext.data.DataReader.Error.prototype, {
- lang : {
- 'update': "#update received invalid data from server. Please see docs for DataReader#update and review your DataReader configuration.",
- 'realize': "#realize was called with invalid remote-data. Please see the docs for DataReader#realize and review your DataReader configuration.",
- 'invalid-response': "#readResponse received an invalid response from the server."
- }
- });
- Ext.data.DataWriter = function(config){
- Ext.apply(this, config);
- };
- Ext.data.DataWriter.prototype = {
- writeAllFields : false,
- listful : false,
- apply : function(params, baseParams, action, rs) {
- var data = [],
- renderer = action + 'Record';
- if (Ext.isArray(rs)) {
- Ext.each(rs, function(rec){
- data.push(this[renderer](rec));
- }, this);
- }
- else if (rs instanceof Ext.data.Record) {
- data = this[renderer](rs);
- }
- this.render(params, baseParams, data);
- },
- render : Ext.emptyFn,
- updateRecord : Ext.emptyFn,
- createRecord : Ext.emptyFn,
- destroyRecord : Ext.emptyFn,
- toHash : function(rec, config) {
- var map = rec.fields.map,
- data = {},
- raw = (this.writeAllFields === false && rec.phantom === false) ? rec.getChanges() : rec.data,
- m;
- Ext.iterate(raw, function(prop, value){
- if((m = map[prop])){
- data[m.mapping ? m.mapping : m.name] = value;
- }
- });
- if (rec.phantom) {
- if (rec.fields.containsKey(this.meta.idProperty) && Ext.isEmpty(rec.data[this.meta.idProperty])) {
- delete data[this.meta.idProperty];
- }
- } else {
- data[this.meta.idProperty] = rec.id
- }
- return data;
- },
- toArray : function(data) {
- var fields = [];
- Ext.iterate(data, function(k, v) {fields.push({name: k, value: v});},this);
- return fields;
- }
- };
- Ext.data.DataProxy = function(conn){
- conn = conn || {};
- this.api = conn.api;
- this.url = conn.url;
- this.restful = conn.restful;
- this.listeners = conn.listeners;
- this.prettyUrls = conn.prettyUrls;
- this.addEvents(
- 'exception',
- 'beforeload',
- 'load',
- 'loadexception',
- 'beforewrite',
- 'write'
- );
- Ext.data.DataProxy.superclass.constructor.call(this);
- try {
- Ext.data.Api.prepare(this);
- } catch (e) {
- if (e instanceof Ext.data.Api.Error) {
- e.toConsole();
- }
- }
- Ext.data.DataProxy.relayEvents(this, ['beforewrite', 'write', 'exception']);
- };
- Ext.extend(Ext.data.DataProxy, Ext.util.Observable, {
- restful: false,
- setApi : function() {
- if (arguments.length == 1) {
- var valid = Ext.data.Api.isValid(arguments[0]);
- if (valid === true) {
- this.api = arguments[0];
- }
- else {
- throw new Ext.data.Api.Error('invalid', valid);
- }
- }
- else if (arguments.length == 2) {
- if (!Ext.data.Api.isAction(arguments[0])) {
- throw new Ext.data.Api.Error('invalid', arguments[0]);
- }
- this.api[arguments[0]] = arguments[1];
- }
- Ext.data.Api.prepare(this);
- },
- isApiAction : function(action) {
- return (this.api[action]) ? true : false;
- },
- request : function(action, rs, params, reader, callback, scope, options) {
- if (!this.api[action] && !this.load) {
- throw new Ext.data.DataProxy.Error('action-undefined', action);
- }
- params = params || {};
- if ((action === Ext.data.Api.actions.read) ? this.fireEvent("beforeload", this, params) : this.fireEvent("beforewrite", this, action, rs, params) !== false) {
- this.doRequest.apply(this, arguments);
- }
- else {
- callback.call(scope || this, null, options, false);
- }
- },
- load : null,
- doRequest : function(action, rs, params, reader, callback, scope, options) {
- this.load(params, reader, callback, scope, options);
- },
- onRead : Ext.emptyFn,
- onWrite : Ext.emptyFn,
- buildUrl : function(action, record) {
- record = record || null;
- var url = (this.conn && this.conn.url) ? this.conn.url : (this.api[action]) ? this.api[action].url : this.url;
- if (!url) {
- throw new Ext.data.Api.Error('invalid-url', action);
- }
- var provides = null;
- var m = url.match(/(.*)(.json|.xml|.html)$/);
- if (m) {
- provides = m[2];
- url = m[1];
- }
- if ((this.restful === true || this.prettyUrls === true) && record instanceof Ext.data.Record && !record.phantom) {
- url += '/' + record.id;
- }
- return (provides === null) ? url : url + provides;
- },
- destroy: function(){
- this.purgeListeners();
- }
- });
- Ext.apply(Ext.data.DataProxy, Ext.util.Observable.prototype);
- Ext.util.Observable.call(Ext.data.DataProxy);
- Ext.data.DataProxy.Error = Ext.extend(Ext.Error, {
- constructor : function(message, arg) {
- this.arg = arg;
- Ext.Error.call(this, message);
- },
- name: 'Ext.data.DataProxy'
- });
- Ext.apply(Ext.data.DataProxy.Error.prototype, {
- lang: {
- 'action-undefined': "DataProxy attempted to execute an API-action but found an undefined url / function. Please review your Proxy url/api-configuration.",
- 'api-invalid': 'Recieved an invalid API-configuration. Please ensure your proxy API-configuration contains only the actions from Ext.data.Api.actions.'
- }
- });
- Ext.data.Request = function(params) {
- Ext.apply(this, params);
- };
- Ext.data.Request.prototype = {
- action : undefined,
- rs : undefined,
- params: undefined,
- callback : Ext.emptyFn,
- scope : undefined,
- reader : undefined
- };
- Ext.data.Response = function(params) {
- Ext.apply(this, params);
- };
- Ext.data.Response.prototype = {
- action: undefined,
- success : undefined,
- message : undefined,
- data: undefined,
- raw: undefined,
- records: undefined
- };
- Ext.data.ScriptTagProxy = function(config){
- Ext.apply(this, config);
- Ext.data.ScriptTagProxy.superclass.constructor.call(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,
- doRequest : function(action, rs, params, reader, callback, scope, arg) {
- var p = Ext.urlEncode(Ext.apply(params, this.extraParams));
- var url = this.buildUrl(action, rs);
- if (!url) {
- throw new Ext.data.Api.Error('invalid-url', url);
- }
- url = Ext.urlAppend(url, p);
- if(this.nocache){
- url = Ext.urlAppend(url, '_dc=' + (new Date().getTime()));
- }
- var transId = ++Ext.data.ScriptTagProxy.TRANS_ID;
- var trans = {
- id : transId,
- action: action,
- cb : "stcCallback"+transId,
- scriptId : "stcScript"+transId,
- params : params,
- arg : arg,
- url : url,
- callback : callback,
- scope : scope,
- reader : reader
- };
- window[trans.cb] = this.createCallback(action, rs, 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;
- },
- createCallback : function(action, rs, trans) {
- var self = this;
- return function(res) {
- self.trans = false;
- self.destroyTrans(trans, true);
- if (action === Ext.data.Api.actions.read) {
- self.onRead.call(self, action, trans, res);
- } else {
- self.onWrite.call(self, action, trans, res, rs);
- }
- };
- },
- onRead : function(action, trans, res) {
- var result;
- try {
- result = trans.reader.readRecords(res);
- }catch(e){
- this.fireEvent("loadexception", this, trans, res, e);
- this.fireEvent('exception', this, 'response', action, trans, res, e);
- trans.callback.call(trans.scope||window, null, trans.arg, false);
- return;
- }
- if (result.success === false) {
- this.fireEvent('loadexception', this, trans, res);
- this.fireEvent('exception', this, 'remote', action, trans, res, null);
- } else {
- this.fireEvent("load", this, res, trans.arg);
- }
- trans.callback.call(trans.scope||window, result, trans.arg, result.success);
- },
- onWrite : function(action, trans, response, rs) {
- var reader = trans.reader;
- try {
- var res = reader.readResponse(action, response);
- } catch (e) {
- this.fireEvent('exception', this, 'response', action, trans, res, e);
- trans.callback.call(trans.scope||window, null, res, false);
- return;
- }
- if(!res.success === true){
- this.fireEvent('exception', this, 'remote', action, trans, res, rs);
- trans.callback.call(trans.scope||window, null, res, false);
- return;
- }
- this.fireEvent("write", this, action, res.data, res, rs, trans.arg );
- trans.callback.call(trans.scope||window, res.data, res, true);
- },
- 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){}
- };
- }
- },
- handleFailure : function(trans){
- this.trans = false;
- this.destroyTrans(trans, false);
- if (trans.action === Ext.data.Api.actions.read) {
- this.fireEvent("loadexception", this, null, trans.arg);
- }
- this.fireEvent('exception', this, 'response', trans.action, {
- response: null,
- options: trans.arg
- });
- trans.callback.call(trans.scope||window, null, trans.arg, false);
- },
- destroy: function(){
- this.abort();
- Ext.data.ScriptTagProxy.superclass.destroy.call(this);
- }
- });
- Ext.data.HttpProxy = function(conn){
- Ext.data.HttpProxy.superclass.constructor.call(this, conn);
- this.conn = conn;
- this.conn.url = null;
- this.useAjax = !conn || !conn.events;
- var actions = Ext.data.Api.actions;
- this.activeRequest = {};
- for (var verb in actions) {
- this.activeRequest[actions[verb]] = undefined;
- }
- };
- Ext.extend(Ext.data.HttpProxy, Ext.data.DataProxy, {
- getConnection : function() {
- return this.useAjax ? Ext.Ajax : this.conn;
- },
- setUrl : function(url, makePermanent) {
- this.conn.url = url;
- if (makePermanent === true) {
- this.url = url;
- this.api = null;
- Ext.data.Api.prepare(this);
- }
- },
- doRequest : function(action, rs, params, reader, cb, scope, arg) {
- var o = {
- method: (this.api[action]) ? this.api[action]['method'] : undefined,
- request: {
- callback : cb,
- scope : scope,
- arg : arg
- },
- reader: reader,
- callback : this.createCallback(action, rs),
- scope: this
- };
- if (params.jsonData) {
- o.jsonData = params.jsonData;
- } else if (params.xmlData) {
- o.xmlData = params.xmlData;
- } else {
- o.params = params || {};
- }
- this.conn.url = this.buildUrl(action, rs);
- if(this.useAjax){
- Ext.applyIf(o, this.conn);
- if (this.activeRequest[action]) {
- }
- this.activeRequest[action] = Ext.Ajax.request(o);
- }else{
- this.conn.request(o);
- }
- this.conn.url = null;
- },
- createCallback : function(action, rs) {
- return function(o, success, response) {
- this.activeRequest[action] = undefined;
- if (!success) {
- if (action === Ext.data.Api.actions.read) {
- this.fireEvent('loadexception', this, o, response);
- }
- this.fireEvent('exception', this, 'response', action, o, response);
- o.request.callback.call(o.request.scope, null, o.request.arg, false);
- return;
- }
- if (action === Ext.data.Api.actions.read) {
- this.onRead(action, o, response);
- } else {
- this.onWrite(action, o, response, rs);
- }
- }
- },
- onRead : function(action, o, response) {
- var result;
- try {
- result = o.reader.read(response);
- }catch(e){
- this.fireEvent('loadexception', this, o, response, e);
- this.fireEvent('exception', this, 'response', action, o, response, e);
- o.request.callback.call(o.request.scope, null, o.request.arg, false);
- return;
- }
- if (result.success === false) {
- this.fireEvent('loadexception', this, o, response);
- var res = o.reader.readResponse(action, response);
- this.fireEvent('exception', this, 'remote', action, o, res, null);
- }
- else {
- this.fireEvent('load', this, o, o.request.arg);
- }
- o.request.callback.call(o.request.scope, result, o.request.arg, result.success);
- },
- onWrite : function(action, o, response, rs) {
- var reader = o.reader;
- var res;
- try {
- res = reader.readResponse(action, response);
- } catch (e) {
- this.fireEvent('exception', this, 'response', action, o, response, e);
- o.request.callback.call(o.request.scope, null, o.request.arg, false);
- return;
- }
- if (res.success === false) {
- this.fireEvent('exception', this, 'remote', action, o, res, rs);
- } else {
- this.fireEvent('write', this, action, res.data, res, rs, o.request.arg);
- }
- o.request.callback.call(o.request.scope, res.data, res, res.success);
- },
- destroy: function(){
- if(!this.useAjax){
- this.conn.abort();
- }else if(this.activeRequest){
- var actions = Ext.data.Api.actions;
- for (var verb in actions) {
- if(this.activeRequest[actions[verb]]){
- Ext.Ajax.abort(this.activeRequest[actions[verb]]);
- }
- }
- }
- Ext.data.HttpProxy.superclass.destroy.call(this);
- }
- });
- Ext.data.MemoryProxy = function(data){
- var api = {};
- api[Ext.data.Api.actions.read] = true;
- Ext.data.MemoryProxy.superclass.constructor.call(this, {
- api: api
- });
- this.data = data;
- };
- Ext.extend(Ext.data.MemoryProxy, Ext.data.DataProxy, {
- doRequest : function(action, rs, params, reader, callback, scope, arg) {
- params = params || {};
- var result;
- try {
- result = reader.readRecords(this.data);
- }catch(e){
- this.fireEvent("loadexception", this, null, arg, e);
- this.fireEvent('exception', this, 'response', action, arg, null, e);
- callback.call(scope, null, arg, false);
- return;
- }
- callback.call(scope, result, arg, true);
- }
- });
- Ext.data.JsonWriter = function(config) {
- Ext.data.JsonWriter.superclass.constructor.call(this, config);
- if (this.returnJson != undefined) {
- this.encode = this.returnJson;
- }
- }
- Ext.extend(Ext.data.JsonWriter, Ext.data.DataWriter, {
- returnJson : undefined,
- encode : true,
- render : function(params, baseParams, data) {
- if (this.encode === true) {
- Ext.apply(params, baseParams);
- params[this.meta.root] = Ext.encode(data);
- } else {
- var jdata = Ext.apply({}, baseParams);
- jdata[this.meta.root] = data;
- params.jsonData = jdata;
- }
- },
- createRecord : function(rec) {
- return this.toHash(rec);
- },
- updateRecord : function(rec) {
- return this.toHash(rec);
- },
- destroyRecord : function(rec) {
- return rec.id;
- }
- });
- Ext.data.JsonReader = function(meta, recordType){
- meta = meta || {};
- Ext.applyIf(meta, {
- idProperty: 'id',
- successProperty: 'success',
- totalProperty: 'total'
- });
- 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 = Ext.decode(json);
- if(!o) {
- throw {message: 'JsonReader.read: Json object not found'};
- }
- return this.readRecords(o);
- },
- readResponse : function(action, response) {
- var o = (response.responseText !== undefined) ? Ext.decode(response.responseText) : response;
- if(!o) {
- throw new Ext.data.JsonReader.Error('response');
- }
- var root = this.getRoot(o);
- if (action === Ext.data.Api.actions.create) {
- var def = Ext.isDefined(root);
- if (def && Ext.isEmpty(root)) {
- throw new Ext.data.JsonReader.Error('root-empty', this.meta.root);
- }
- else if (!def) {
- throw new Ext.data.JsonReader.Error('root-undefined-response', this.meta.root);
- }
- }
- var res = new Ext.data.Response({
- action: action,
- success: this.getSuccess(o),
- data: (root) ? this.extractData(root, false) : [],
- message: this.getMessage(o),
- raw: o
- });
- if (Ext.isEmpty(res.success)) {
- throw new Ext.data.JsonReader.Error('successProperty-response', this.meta.successProperty);
- }
- return res;
- },
- readRecords : function(o){
- this.jsonData = o;
- if(o.metaData){
- this.onMetaChange(o.metaData);
- }
- var s = this.meta, Record = this.recordType,
- f = Record.prototype.fields, fi = f.items, fl = f.length, v;
- var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
- if(s.totalProperty){
- v = parseInt(this.getTotal(o), 10);
- if(!isNaN(v)){
- totalRecords = v;
- }
- }
- if(s.successProperty){
- v = this.getSuccess(o);
- if(v === false || v === 'false'){
- success = false;
- }
- }
- return {
- success : success,
- records : this.extractData(root, true),
- totalRecords : totalRecords
- };
- },
- buildExtractors : function() {
- if(this.ef){
- return;
- }
- var s = this.meta, Record = this.recordType,
- f = Record.prototype.fields, fi = f.items, fl = f.length;
- if(s.totalProperty) {
- this.getTotal = this.createAccessor(s.totalProperty);
- }
- if(s.successProperty) {
- this.getSuccess = this.createAccessor(s.successProperty);
- }
- if (s.messageProperty) {
- this.getMessage = this.createAccessor(s.messageProperty);
- }
- this.getRoot = s.root ? this.createAccessor(s.root) : function(p){return p;};
- if (s.id || s.idProperty) {
- var g = this.createAccessor(s.id || s.idProperty);
- this.getId = function(rec) {
- var r = g(rec);
- return (r === undefined || r === '') ? null : r;
- };
- } else {
- this.getId = function(){return null;};
- }
- var ef = [];
- for(var i = 0; i < fl; i++){
- f = fi[i];
- var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
- ef.push(this.createAccessor(map));
- }
- this.ef = ef;
- },
- simpleAccess : function(obj, subsc) {
- return obj[subsc];
- },
- createAccessor : 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;
- };
- }(),
- extractValues : function(data, items, len) {
- var f, values = {};
- for(var j = 0; j < len; j++){
- f = items[j];
- var v = this.ef[j](data);
- values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue, data);
- }
- return values;
- }
- });
- Ext.data.JsonReader.Error = Ext.extend(Ext.Error, {
- constructor : function(message, arg) {
- this.arg = arg;
- Ext.Error.call(this, message);
- },
- name : 'Ext.data.JsonReader'
- });
- Ext.apply(Ext.data.JsonReader.Error.prototype, {
- lang: {
- 'response': 'An error occurred while json-decoding your server response',
- 'successProperty-response': 'Could not locate your "successProperty" in your server response. Please review your JsonReader config to ensure the config-property "successProperty" matches the property in your server-response. See the JsonReader docs.',
- 'root-undefined-config': 'Your JsonReader was configured without a "root" property. Please review your JsonReader config and make sure to define the root property. See the JsonReader docs.',
- 'idProperty-undefined' : 'Your JsonReader was configured without an "idProperty" Please review your JsonReader configuration and ensure the "idProperty" is set (e.g.: "id"). See the JsonReader docs.',
- 'root-empty': 'Data was expected to be returned by the server in the "root" property of the response. Please review your JsonReader configuration to ensure the "root" property matches that returned in the server-response. See JsonReader docs.'
- }
- });
- Ext.data.ArrayReader = Ext.extend(Ext.data.JsonReader, {
- readRecords : function(o){
- this.arrayData = o;
- var s = this.meta,
- sid = s ? Ext.num(s.idIndex, s.id) : null,
- recordType = this.recordType,
- fields = recordType.prototype.fields,
- records = [],
- v;
- var root = this.getRoot(o);
- for(var i = 0, len = root.length; i < len; i++) {
- var n = root[i],
- values = {},
- 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],
- k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
- 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;
- }
- var totalRecords = records.length;
- if(s.totalProperty) {
- v = parseInt(this.getTotal(o), 10);
- if(!isNaN(v)) {
- totalRecords = v;
- }
- }
- return {
- records : records,
- totalRecords : totalRecords
- };
- }
- });
- Ext.data.ArrayStore = Ext.extend(Ext.data.Store, {
- constructor: function(config){
- Ext.data.ArrayStore.superclass.constructor.call(this, Ext.apply(config, {
- reader: new Ext.data.ArrayReader(config)
- }));
- },
- 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.ArrayStore.superclass.loadData.call(this, data, append);
- }
- });
- Ext.reg('arraystore', Ext.data.ArrayStore);
- Ext.data.SimpleStore = Ext.data.ArrayStore;
- Ext.reg('simplestore', Ext.data.SimpleStore);
- Ext.data.JsonStore = Ext.extend(Ext.data.Store, {
- constructor: function(config){
- Ext.data.JsonStore.superclass.constructor.call(this, Ext.apply(config, {
- reader: new Ext.data.JsonReader(config)
- }));
- }
- });
- Ext.reg('jsonstore', Ext.data.JsonStore);
- Ext.data.XmlWriter = function(params) {
- Ext.data.XmlWriter.superclass.constructor.apply(this, arguments);
- this.tpl = (typeof(this.tpl) === 'string') ? new Ext.XTemplate(this.tpl).compile() : this.tpl.compile();
- };
- Ext.extend(Ext.data.XmlWriter, Ext.data.DataWriter, {
- documentRoot: 'xrequest',
- forceDocumentRoot: false,
- root: 'records',
- xmlVersion : '1.0',
- xmlEncoding: 'ISO-8859-15',
- tpl: '<tpl for="."><' + '?xml version="{version}" encoding="{encoding}"?' + '><tpl if="documentRoot"><{documentRoot}><tpl for="baseParams"><tpl for="."><{name}>{value}</{name}</tpl></tpl></tpl><tpl if="records.length>1"><{root}></tpl><tpl for="records"><{parent.record}><tpl for="."><{name}>{value}</{name}></tpl></{parent.record}></tpl><tpl if="records.length>1"></{root}></tpl><tpl if="documentRoot"></{documentRoot}></tpl></tpl>',
- render : function(params, baseParams, data) {
- baseParams = this.toArray(baseParams);
- params.xmlData = this.tpl.applyTemplate({
- version: this.xmlVersion,
- encoding: this.xmlEncoding,
- documentRoot: (baseParams.length > 0 || this.forceDocumentRoot === true) ? this.documentRoot : false,
- record: this.meta.record,
- root: this.root,
- baseParams: baseParams,
- records: (Ext.isArray(data[0])) ? data : [data]
- });
- },
- createRecord : function(rec) {
- return this.toArray(this.toHash(rec));
- },
- updateRecord : function(rec) {
- return this.toArray(this.toHash(rec));
- },
- destroyRecord : function(rec) {
- var data = {};
- data[this.meta.idProperty] = rec.id;
- return this.toArray(data);
- }
- });
- Ext.data.XmlReader = function(meta, recordType){
- meta = meta || {};
- Ext.applyIf(meta, {
- idProperty: meta.idProperty || meta.idPath || meta.id,
- successProperty: meta.successProperty || meta.success
- });
- 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,
- q = Ext.DomQuery,
- totalRecords = 0,
- success = true;
- if(this.meta.totalProperty){
- totalRecords = this.getTotal(root, 0);
- }
- if(this.meta.successProperty){
- success = this.getSuccess(root);
- }
- var records = this.extractData(q.select(this.meta.record, root), true);
- return {
- success : success,
- records : records,
- totalRecords : totalRecords || records.length
- };
- },
- readResponse : function(action, response) {
- var q = Ext.DomQuery,
- doc = response.responseXML;
- var res = new Ext.data.Response({
- action: action,
- success : this.getSuccess(doc),
- message: this.getMessage(doc),
- data: this.extractData(q.select(this.meta.record, doc) || q.select(this.meta.root, doc), false),
- raw: doc
- });
- if (Ext.isEmpty(res.success)) {
- throw new Ext.data.DataReader.Error('successProperty-response', this.meta.successProperty);
- }
- if (action === Ext.data.Api.actions.create) {
- var def = Ext.isDefined(res.data);
- if (def && Ext.isEmpty(res.data)) {
- throw new Ext.data.JsonReader.Error('root-empty', this.meta.root);
- }
- else if (!def) {
- throw new Ext.data.JsonReader.Error('root-undefined-response', this.meta.root);
- }
- }
- return res;
- },
- getSuccess : function() {
- return true;
- },
- buildExtractors : function() {
- if(this.ef){
- return;
- }
- var s = this.meta,
- Record = this.recordType,
- f = Record.prototype.fields,
- fi = f.items,
- fl = f.length;
- if(s.totalProperty) {
- this.getTotal = this.createAccessor(s.totalProperty);
- }
- if(s.successProperty) {
- this.getSuccess = this.createAccessor(s.successProperty);
- }
- if (s.messageProperty) {
- this.getMessage = this.createAccessor(s.messageProperty);
- }
- this.getRoot = function(res) {
- return (!Ext.isEmpty(res[this.meta.record])) ? res[this.meta.record] : res[this.meta.root];
- }
- if (s.idPath || s.idProperty) {
- var g = this.createAccessor(s.idPath || s.idProperty);
- this.getId = function(rec) {
- var id = g(rec) || rec.id;
- return (id === undefined || id === '') ? null : id;
- };
- } else {
- this.getId = function(){return null;};
- }
- var ef = [];
- for(var i = 0; i < fl; i++){
- f = fi[i];
- var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
- ef.push(this.createAccessor(map));
- }
- this.ef = ef;
- },
- createAccessor : function(){
- var q = Ext.DomQuery;
- return function(key) {
- switch(key) {
- case this.meta.totalProperty:
- return function(root, def){
- return q.selectNumber(key, root, def);
- }
- break;
- case this.meta.successProperty:
- return function(root, def) {
- var sv = q.selectValue(key, root, true);
- var success = sv !== false && sv !== 'false';
- return success;
- }
- break;
- default:
- return function(root, def) {
- return q.selectValue(key, root, def);
- }
- break;
- }
- };
- }(),
- extractValues : function(data, items, len) {
- var f, values = {};
- for(var j = 0; j < len; j++){
- f = items[j];
- var v = this.ef[j](data);
- values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue, data);
- }
- return values;
- }
- });
- Ext.data.XmlStore = Ext.extend(Ext.data.Store, {
- constructor: function(config){
- Ext.data.XmlStore.superclass.constructor.call(this, Ext.apply(config, {
- reader: new Ext.data.XmlReader(config)
- }));
- }
- });
- Ext.reg('xmlstore', Ext.data.XmlStore);
- Ext.data.GroupingStore = Ext.extend(Ext.data.Store, {
- constructor: function(config){
- Ext.data.GroupingStore.superclass.constructor.call(this, config);
- this.applyGroupField();
- },
- remoteGroup : false,
- groupOnSort:false,
- groupDir : 'ASC',
- clearGrouping : function(){
- this.groupField = false;
- if(this.remoteGroup){
- if(this.baseParams){
- delete this.baseParams.groupBy;
- }
- var lo = this.lastOptions;
- if(lo && lo.params){
- delete lo.params.groupBy;
- }
- this.reload();
- }else{
- this.applySort();
- this.fireEvent('datachanged', this);
- }
- },
- groupBy : function(field, forceRegroup, direction){
- direction = direction ? (String(direction).toUpperCase() == 'DESC' ? 'DESC' : 'ASC') : this.groupDir;
- if(this.groupField == field && this.groupDir == direction && !forceRegroup){
- return;
- }
- this.groupField = field;
- this.groupDir = direction;
- this.applyGroupField();
- if(this.groupOnSort){
- this.sort(field, direction);
- return;
- }
- if(this.remoteGroup){
- this.reload();
- }else{
- var si = this.sortInfo || {};
- if(si.field != field || si.direction != direction){
- this.applySort();
- }else{
- this.sortData(field, direction);
- }
- this.fireEvent('datachanged', this);
- }
- },
- applyGroupField: function(){
- if(this.remoteGroup){
- if(!this.baseParams){
- this.baseParams = {};
- }
- this.baseParams.groupBy = this.groupField;
- this.baseParams.groupDir = this.groupDir;
- }
- },
- 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.groupDir != this.sortInfo.direction)){
- this.sortData(this.groupField, this.groupDir);
- }
- }
- },
- applyGrouping : function(alwaysFireChange){
- if(this.groupField !== false){
- this.groupBy(this.groupField, true, this.groupDir);
- 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.reg('groupingstore', Ext.data.GroupingStore);
- Ext.data.DirectProxy = function(config){
- Ext.apply(this, config);
- if(typeof this.paramOrder == 'string'){
- this.paramOrder = this.paramOrder.split(/[s,|]/);
- }
- Ext.data.DirectProxy.superclass.constructor.call(this, config);
- };
- Ext.extend(Ext.data.DirectProxy, Ext.data.DataProxy, {
- paramOrder: undefined,
- paramsAsHash: true,
- directFn : undefined,
- doRequest : function(action, rs, params, reader, callback, scope, options) {
- var args = [],
- directFn = this.api[action] || this.directFn;
- switch (action) {
- case Ext.data.Api.actions.create:
- args.push(params.jsonData);
- break;
- case Ext.data.Api.actions.read:
- if(directFn.directCfg.method.len > 0){
- if(this.paramOrder){
- for(var i = 0, len = this.paramOrder.length; i < len; i++){
- args.push(params[this.paramOrder[i]]);
- }
- }else if(this.paramsAsHash){
- args.push(params);
- }
- }
- break;
- case Ext.data.Api.actions.update:
- args.push(params.jsonData);
- break;
- case Ext.data.Api.actions.destroy:
- args.push(params.jsonData);
- break;
- }
- var trans = {
- params : params || {},
- request: {
- callback : callback,
- scope : scope,
- arg : options
- },
- reader: reader
- };
- args.push(this.createCallback(action, rs, trans), this);
- directFn.apply(window, args);
- },
- createCallback : function(action, rs, trans) {
- return function(result, res) {
- if (!res.status) {
- if (action === Ext.data.Api.actions.read) {
- this.fireEvent("loadexception", this, trans, res, null);
- }
- this.fireEvent('exception', this, 'remote', action, trans, res, null);
- trans.request.callback.call(trans.request.scope, null, trans.request.arg, false);
- return;
- }
- if (action === Ext.data.Api.actions.read) {
- this.onRead(action, trans, result, res);
- } else {
- this.onWrite(action, trans, result, res, rs);
- }
- };
- },
- onRead : function(action, trans, result, res) {
- var records;
- try {
- records = trans.reader.readRecords(result);
- }
- catch (ex) {
- this.fireEvent("loadexception", this, trans, res, ex);
- this.fireEvent('exception', this, 'response', action, trans, res, ex);
- trans.request.callback.call(trans.request.scope, null, trans.request.arg, false);
- return;
- }
- this.fireEvent("load", this, res, trans.request.arg);
- trans.request.callback.call(trans.request.scope, records, trans.request.arg, true);
- },
- onWrite : function(action, trans, result, res, rs) {
- var data = trans.reader.extractData(result, false);
- this.fireEvent("write", this, action, data, res, rs, trans.request.arg);
- trans.request.callback.call(trans.request.scope, data, res, true);
- }
- });
- Ext.data.DirectStore = function(c){
- c.batchTransactions = false;
- Ext.data.DirectStore.superclass.constructor.call(this, Ext.apply(c, {
- proxy: (typeof(c.proxy) == 'undefined') ? new Ext.data.DirectProxy(Ext.copyTo({}, c, 'paramOrder,paramsAsHash,directFn,api')) : c.proxy,
- reader: (typeof(c.reader) == 'undefined' && typeof(c.fields) == 'object') ? new Ext.data.JsonReader(Ext.copyTo({}, c, 'totalProperty,root,idProperty'), c.fields) : c.reader
- }));
- };
- Ext.extend(Ext.data.DirectStore, Ext.data.Store, {});
- Ext.reg('directstore', Ext.data.DirectStore);
- Ext.Direct = Ext.extend(Ext.util.Observable, {
- exceptions: {
- TRANSPORT: 'xhr',
- PARSE: 'parse',
- LOGIN: 'login',
- SERVER: 'exception'
- },
- constructor: function(){
- this.addEvents(
- 'event',
- 'exception'
- );
- this.transactions = {};
- this.providers = {};
- },
- addProvider : function(provider){
- var a = arguments;
- if(a.length > 1){
- for(var i = 0, len = a.length; i < len; i++){
- this.addProvider(a[i]);
- }
- return;
- }
- if(!provider.events){
- provider = new Ext.Direct.PROVIDERS[provider.type](provider);
- }
- provider.id = provider.id || Ext.id();
- this.providers[provider.id] = provider;
- provider.on('data', this.onProviderData, this);
- provider.on('exception', this.onProviderException, this);
- if(!provider.isConnected()){
- provider.connect();
- }
- return provider;
- },
- getProvider : function(id){
- return this.providers[id];
- },
- removeProvider : function(id){
- var provider = id.id ? id : this.providers[id.id];
- provider.un('data', this.onProviderData, this);
- provider.un('exception', this.onProviderException, this);
- delete this.providers[provider.id];
- return provider;
- },
- addTransaction: function(t){
- this.transactions[t.tid] = t;
- return t;
- },
- removeTransaction: function(t){
- delete this.transactions[t.tid || t];
- return t;
- },
- getTransaction: function(tid){
- return this.transactions[tid.tid || tid];
- },
- onProviderData : function(provider, e){
- if(Ext.isArray(e)){
- for(var i = 0, len = e.length; i < len; i++){
- this.onProviderData(provider, e[i]);
- }
- return;
- }
- if(e.name && e.name != 'event' && e.name != 'exception'){
- this.fireEvent(e.name, e);
- }else if(e.type == 'exception'){
- this.fireEvent('exception', e);
- }
- this.fireEvent('event', e, provider);
- },
- createEvent : function(response, extraProps){
- return new Ext.Direct.eventTypes[response.type](Ext.apply(response, extraProps));
- }
- });
- Ext.Direct = new Ext.Direct();
- Ext.Direct.TID = 1;
- Ext.Direct.PROVIDERS = {};
- Ext.Direct.Transaction = function(config){
- Ext.apply(this, config);
- this.tid = ++Ext.Direct.TID;
- this.retryCount = 0;
- };
- Ext.Direct.Transaction.prototype = {
- send: function(){
- this.provider.queueTransaction(this);
- },
- retry: function(){
- this.retryCount++;
- this.send();
- },
- getProvider: function(){
- return this.provider;
- }
- };Ext.Direct.Event = function(config){
- Ext.apply(this, config);
- }
- Ext.Direct.Event.prototype = {
- status: true,
- getData: function(){
- return this.data;
- }
- };
- Ext.Direct.RemotingEvent = Ext.extend(Ext.Direct.Event, {
- type: 'rpc',
- getTransaction: function(){
- return this.transaction || Ext.Direct.getTransaction(this.tid);
- }
- });
- Ext.Direct.ExceptionEvent = Ext.extend(Ext.Direct.RemotingEvent, {
- status: false,
- type: 'exception'
- });
- Ext.Direct.eventTypes = {
- 'rpc': Ext.Direct.RemotingEvent,
- 'event': Ext.Direct.Event,
- 'exception': Ext.Direct.ExceptionEvent
- };
- Ext.direct.Provider = Ext.extend(Ext.util.Observable, {
- priority: 1,
- constructor : function(config){
- Ext.apply(this, config);
- this.addEvents(
- 'connect',
- 'disconnect',
- 'data',