ext-all-debug.js
资源名称:demo.zip [点击查看]
上传用户:chliyg
上传日期:2016-05-15
资源大小:3196k
文件大小:951k
源码类别:
Jsp/Servlet
开发平台:
Java
- 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(Ext.isIE ? 'styleFloat' : 'cssFloat', '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;
- }
- };
- 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.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'
- );
- 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"}; } 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; 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); } 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;
- },
- isExpandable : function(){
- return this.attributes.expandable || this.hasChildNodes();
- },
- 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; // this will be called a lot internally, shorthand to keep the bytes down 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] = this.initPlugin(this.plugins[i]); } }else{ this.plugins = this.initPlugin(this.plugins); } } 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]; }, initPlugin : function(p){ p.init(this); return p; }, 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(); } if(this.stateful !== false){ 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); } if(this.overCls) { this.el.addClassOnOver(this.overCls); } } }, 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; }); }, mon : function(item, ename, fn, scope, opt){ if(!this.mons){ this.mons = []; this.on('beforedestroy', function(){ for(var i= 0, len = this.mons.length; i < len; i++){ var m = this.mons[i]; m.item.un(m.ename, m.fn, m.scope); } }, this); } this.mons.push({ item: item, ename: ename, fn: fn, scope: scope }); item.on(ename, fn, scope, opt); } }); 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]);
- },
- each : function(fn, scope){
- Ext.each(this.items, fn, scope);
- },
- callEach : function(fnName, args){
- var cs = this.items;
- for(var i = 0, len = cs.length; i < len; i++){
- cs[i][fnName].apply(cs[i], args);
- }
- },
- addComponent : function(comp){
- this.items.push(comp);
- comp.on('destroy', this.removeComponent, this);
- },
- removeComponent : function(comp){
- this.items.remove(comp);
- },
- execute : function(){
- this.initialConfig.handler.apply(this.initialConfig.scope || window, arguments);
- }
- };
- (function(){
- Ext.Layer = function(config, existingEl){
- config = config || {};
- var dh = Ext.DomHelper;
- var cp = config.parentEl, pel = cp ? Ext.getDom(cp) : document.body;
- if(existingEl){
- this.dom = Ext.getDom(existingEl);
- }
- if(!this.dom){
- var o = config.dh || {tag: "div", cls: "x-layer"};
- this.dom = dh.append(pel, o);
- }
- if(config.cls){
- this.addClass(config.cls);
- }
- this.constrain = config.constrain !== false;
- this.visibilityMode = Ext.Element.VISIBILITY;
- if(config.id){
- this.id = this.dom.id = config.id;
- }else{
- this.id = Ext.id(this.dom);
- }
- this.zindex = config.zindex || this.getZIndex();
- this.position("absolute", this.zindex);
- if(config.shadow){
- this.shadowOffset = config.shadowOffset || 4;
- this.shadow = new Ext.Shadow({
- offset : this.shadowOffset,
- mode : config.shadow
- });
- }else{
- this.shadowOffset = 0;
- }
- this.useShim = config.shim !== false && Ext.useShims;
- this.useDisplay = config.useDisplay;
- this.hide();
- };
- var supr = Ext.Element.prototype;
- var shims = [];
- Ext.extend(Ext.Layer, Ext.Element, {
- getZIndex : function(){
- return this.zindex || parseInt(this.getStyle("z-index"), 10) || 11000;
- },
- getShim : function(){
- if(!this.useShim){
- return null;
- }
- if(this.shim){
- return this.shim;
- }
- var shim = shims.shift();
- if(!shim){
- shim = this.createShim();
- shim.enableDisplayMode('block');
- shim.dom.style.display = 'none';
- shim.dom.style.visibility = 'visible';
- }
- var pn = this.dom.parentNode;
- if(shim.dom.parentNode != pn){
- pn.insertBefore(shim.dom, this.dom);
- }
- shim.setStyle('z-index', this.getZIndex()-2);
- this.shim = shim;
- return shim;
- },
- hideShim : function(){
- if(this.shim){
- this.shim.setDisplayed(false);
- shims.push(this.shim);
- delete this.shim;
- }
- },
- disableShadow : function(){
- if(this.shadow){
- this.shadowDisabled = true;
- this.shadow.hide();
- this.lastShadowOffset = this.shadowOffset;
- this.shadowOffset = 0;
- }
- },
- enableShadow : function(show){
- if(this.shadow){
- this.shadowDisabled = false;
- this.shadowOffset = this.lastShadowOffset;
- delete this.lastShadowOffset;
- if(show){
- this.sync(true);
- }
- }
- },
- sync : function(doShow){
- var sw = this.shadow;
- if(!this.updating && this.isVisible() && (sw || this.useShim)){
- var sh = this.getShim();
- var w = this.getWidth(),
- h = this.getHeight();
- var l = this.getLeft(true),
- t = this.getTop(true);
- if(sw && !this.shadowDisabled){
- if(doShow && !sw.isVisible()){
- sw.show(this);
- }else{
- sw.realign(l, t, w, h);
- }
- if(sh){
- if(doShow){
- sh.show();
- }
- var a = sw.adjusts, s = sh.dom.style;
- s.left = (Math.min(l, l+a.l))+"px";
- s.top = (Math.min(t, t+a.t))+"px";
- s.width = (w+a.w)+"px";
- s.height = (h+a.h)+"px";
- }
- }else if(sh){
- if(doShow){
- sh.show();
- }
- sh.setSize(w, h);
- sh.setLeftTop(l, t);
- }
- }
- },
- destroy : function(){
- this.hideShim();
- if(this.shadow){
- this.shadow.hide();
- }
- this.removeAllListeners();
- Ext.removeNode(this.dom);
- Ext.Element.uncache(this.id);
- },
- remove : function(){
- this.destroy();
- },
- beginUpdate : function(){