ext-all-debug.js
资源名称:ext-3.1.0.zip [点击查看]
上传用户:dawnssy
上传日期:2022-08-06
资源大小:9345k
文件大小:1167k
源码类别:
JavaScript
开发平台:
JavaScript
- );
- },
- collapse : function(){
- this.updateExpandIcon();
- this.ctNode.style.display = "none";
- },
- animCollapse : function(callback){
- var ct = Ext.get(this.ctNode);
- ct.enableDisplayMode('block');
- ct.stopFx();
- this.animating = true;
- this.updateExpandIcon();
- ct.slideOut('t', {
- callback : function(){
- this.animating = false;
- Ext.callback(callback);
- },
- scope: this,
- duration: this.node.ownerTree.duration || .25
- });
- },
- getContainer : function(){
- return this.ctNode;
- },
- getEl : function(){
- return this.wrap;
- },
- appendDDGhost : function(ghostNode){
- ghostNode.appendChild(this.elNode.cloneNode(true));
- },
- getDDRepairXY : function(){
- return Ext.lib.Dom.getXY(this.iconNode);
- },
- onRender : function(){
- this.render();
- },
- render : function(bulkRender){
- var n = this.node, a = n.attributes;
- var targetNode = n.parentNode ?
- n.parentNode.ui.getContainer() : n.ownerTree.innerCt.dom;
- if(!this.rendered){
- this.rendered = true;
- this.renderElements(n, a, targetNode, bulkRender);
- if(a.qtip){
- if(this.textNode.setAttributeNS){
- this.textNode.setAttributeNS("ext", "qtip", a.qtip);
- if(a.qtipTitle){
- this.textNode.setAttributeNS("ext", "qtitle", a.qtipTitle);
- }
- }else{
- this.textNode.setAttribute("ext:qtip", a.qtip);
- if(a.qtipTitle){
- this.textNode.setAttribute("ext:qtitle", a.qtipTitle);
- }
- }
- }else if(a.qtipCfg){
- a.qtipCfg.target = Ext.id(this.textNode);
- Ext.QuickTips.register(a.qtipCfg);
- }
- this.initEvents();
- if(!this.node.expanded){
- this.updateExpandIcon(true);
- }
- }else{
- if(bulkRender === true) {
- targetNode.appendChild(this.wrap);
- }
- }
- },
- renderElements : function(n, a, targetNode, bulkRender){
- this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
- var cb = Ext.isBoolean(a.checked),
- nel,
- href = a.href ? a.href : Ext.isGecko ? "" : "#",
- buf = ['<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf x-unselectable ', a.cls,'" unselectable="on">',
- '<span class="x-tree-node-indent">',this.indentMarkup,"</span>",
- '<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow" />',
- '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon',(a.icon ? " x-tree-node-inline-icon" : ""),(a.iconCls ? " "+a.iconCls : ""),'" unselectable="on" />',
- cb ? ('<input class="x-tree-node-cb" type="checkbox" ' + (a.checked ? 'checked="checked" />' : '/>')) : '',
- '<a hidefocus="on" class="x-tree-node-anchor" href="',href,'" tabIndex="1" ',
- a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "", '><span unselectable="on">',n.text,"</span></a></div>",
- '<ul class="x-tree-node-ct" style="display:none;"></ul>',
- "</li>"].join('');
- if(bulkRender !== true && n.nextSibling && (nel = n.nextSibling.ui.getEl())){
- this.wrap = Ext.DomHelper.insertHtml("beforeBegin", nel, buf);
- }else{
- this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf);
- }
- this.elNode = this.wrap.childNodes[0];
- this.ctNode = this.wrap.childNodes[1];
- var cs = this.elNode.childNodes;
- this.indentNode = cs[0];
- this.ecNode = cs[1];
- this.iconNode = cs[2];
- var index = 3;
- if(cb){
- this.checkbox = cs[3];
- this.checkbox.defaultChecked = this.checkbox.checked;
- index++;
- }
- this.anchor = cs[index];
- this.textNode = cs[index].firstChild;
- },
- getAnchor : function(){
- return this.anchor;
- },
- getTextEl : function(){
- return this.textNode;
- },
- getIconEl : function(){
- return this.iconNode;
- },
- isChecked : function(){
- return this.checkbox ? this.checkbox.checked : false;
- },
- updateExpandIcon : function(){
- if(this.rendered){
- var n = this.node,
- c1,
- c2,
- cls = n.isLast() ? "x-tree-elbow-end" : "x-tree-elbow",
- hasChild = n.hasChildNodes();
- if(hasChild || n.attributes.expandable){
- if(n.expanded){
- cls += "-minus";
- c1 = "x-tree-node-collapsed";
- c2 = "x-tree-node-expanded";
- }else{
- cls += "-plus";
- c1 = "x-tree-node-expanded";
- c2 = "x-tree-node-collapsed";
- }
- if(this.wasLeaf){
- this.removeClass("x-tree-node-leaf");
- this.wasLeaf = false;
- }
- if(this.c1 != c1 || this.c2 != c2){
- Ext.fly(this.elNode).replaceClass(c1, c2);
- this.c1 = c1; this.c2 = c2;
- }
- }else{
- if(!this.wasLeaf){
- Ext.fly(this.elNode).replaceClass("x-tree-node-expanded", "x-tree-node-leaf");
- delete this.c1;
- delete this.c2;
- this.wasLeaf = true;
- }
- }
- var ecc = "x-tree-ec-icon "+cls;
- if(this.ecc != ecc){
- this.ecNode.className = ecc;
- this.ecc = ecc;
- }
- }
- },
- onIdChange: function(id){
- if(this.rendered){
- this.elNode.setAttribute('ext:tree-node-id', id);
- }
- },
- getChildIndent : function(){
- if(!this.childIndent){
- var buf = [],
- p = this.node;
- while(p){
- if(!p.isRoot || (p.isRoot && p.ownerTree.rootVisible)){
- if(!p.isLast()) {
- buf.unshift('<img src="'+this.emptyIcon+'" class="x-tree-elbow-line" />');
- } else {
- buf.unshift('<img src="'+this.emptyIcon+'" class="x-tree-icon" />');
- }
- }
- p = p.parentNode;
- }
- this.childIndent = buf.join("");
- }
- return this.childIndent;
- },
- renderIndent : function(){
- if(this.rendered){
- var indent = "",
- p = this.node.parentNode;
- if(p){
- indent = p.ui.getChildIndent();
- }
- if(this.indentMarkup != indent){
- this.indentNode.innerHTML = indent;
- this.indentMarkup = indent;
- }
- this.updateExpandIcon();
- }
- },
- destroy : function(){
- if(this.elNode){
- Ext.dd.Registry.unregister(this.elNode.id);
- }
- Ext.each(['textnode', 'anchor', 'checkbox', 'indentNode', 'ecNode', 'iconNode', 'elNode', 'ctNode', 'wrap', 'holder'], function(el){
- if(this[el]){
- Ext.fly(this[el]).remove();
- delete this[el];
- }
- }, this);
- delete this.node;
- }
- };
- Ext.tree.RootTreeNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
- render : function(){
- if(!this.rendered){
- var targetNode = this.node.ownerTree.innerCt.dom;
- this.node.expanded = true;
- targetNode.innerHTML = '<div class="x-tree-root-node"></div>';
- this.wrap = this.ctNode = targetNode.firstChild;
- }
- },
- collapse : Ext.emptyFn,
- expand : Ext.emptyFn
- });
- Ext.tree.TreeLoader = function(config){
- this.baseParams = {};
- Ext.apply(this, config);
- this.addEvents(
- "beforeload",
- "load",
- "loadexception"
- );
- Ext.tree.TreeLoader.superclass.constructor.call(this);
- if(Ext.isString(this.paramOrder)){
- this.paramOrder = this.paramOrder.split(/[s,|]/);
- }
- };
- Ext.extend(Ext.tree.TreeLoader, Ext.util.Observable, {
- uiProviders : {},
- clearOnLoad : true,
- paramOrder: undefined,
- paramsAsHash: false,
- nodeParameter: 'node',
- directFn : undefined,
- load : function(node, callback, scope){
- if(this.clearOnLoad){
- while(node.firstChild){
- node.removeChild(node.firstChild);
- }
- }
- if(this.doPreload(node)){
- this.runCallback(callback, scope || node, [node]);
- }else if(this.directFn || this.dataUrl || this.url){
- this.requestData(node, callback, scope || node);
- }
- },
- doPreload : function(node){
- if(node.attributes.children){
- if(node.childNodes.length < 1){
- var cs = node.attributes.children;
- node.beginUpdate();
- for(var i = 0, len = cs.length; i < len; i++){
- var cn = node.appendChild(this.createNode(cs[i]));
- if(this.preloadChildren){
- this.doPreload(cn);
- }
- }
- node.endUpdate();
- }
- return true;
- }
- return false;
- },
- getParams: function(node){
- var buf = [], bp = this.baseParams;
- if(this.directFn){
- buf.push(node.id);
- if(bp){
- if(this.paramOrder){
- for(var i = 0, len = this.paramOrder.length; i < len; i++){
- buf.push(bp[this.paramOrder[i]]);
- }
- }else if(this.paramsAsHash){
- buf.push(bp);
- }
- }
- return buf;
- }else{
- var o = Ext.apply({}, bp);
- o[this.nodeParameter] = node.id;
- return o;
- }
- },
- requestData : function(node, callback, scope){
- if(this.fireEvent("beforeload", this, node, callback) !== false){
- if(this.directFn){
- var args = this.getParams(node);
- args.push(this.processDirectResponse.createDelegate(this, [{callback: callback, node: node, scope: scope}], true));
- this.directFn.apply(window, args);
- }else{
- this.transId = Ext.Ajax.request({
- method:this.requestMethod,
- url: this.dataUrl||this.url,
- success: this.handleResponse,
- failure: this.handleFailure,
- scope: this,
- argument: {callback: callback, node: node, scope: scope},
- params: this.getParams(node)
- });
- }
- }else{
- this.runCallback(callback, scope || node, []);
- }
- },
- processDirectResponse: function(result, response, args){
- if(response.status){
- this.handleResponse({
- responseData: Ext.isArray(result) ? result : null,
- responseText: result,
- argument: args
- });
- }else{
- this.handleFailure({
- argument: args
- });
- }
- },
- runCallback: function(cb, scope, args){
- if(Ext.isFunction(cb)){
- cb.apply(scope, args);
- }
- },
- isLoading : function(){
- return !!this.transId;
- },
- abort : function(){
- if(this.isLoading()){
- Ext.Ajax.abort(this.transId);
- }
- },
- createNode : function(attr){
- if(this.baseAttrs){
- Ext.applyIf(attr, this.baseAttrs);
- }
- if(this.applyLoader !== false && !attr.loader){
- attr.loader = this;
- }
- if(Ext.isString(attr.uiProvider)){
- attr.uiProvider = this.uiProviders[attr.uiProvider] || eval(attr.uiProvider);
- }
- if(attr.nodeType){
- return new Ext.tree.TreePanel.nodeTypes[attr.nodeType](attr);
- }else{
- return attr.leaf ?
- new Ext.tree.TreeNode(attr) :
- new Ext.tree.AsyncTreeNode(attr);
- }
- },
- processResponse : function(response, node, callback, scope){
- var json = response.responseText;
- try {
- var o = response.responseData || Ext.decode(json);
- node.beginUpdate();
- for(var i = 0, len = o.length; i < len; i++){
- var n = this.createNode(o[i]);
- if(n){
- node.appendChild(n);
- }
- }
- node.endUpdate();
- this.runCallback(callback, scope || node, [node]);
- }catch(e){
- this.handleFailure(response);
- }
- },
- handleResponse : function(response){
- this.transId = false;
- var a = response.argument;
- this.processResponse(response, a.node, a.callback, a.scope);
- this.fireEvent("load", this, a.node, response);
- },
- handleFailure : function(response){
- this.transId = false;
- var a = response.argument;
- this.fireEvent("loadexception", this, a.node, response);
- this.runCallback(a.callback, a.scope || a.node, [a.node]);
- },
- destroy : function(){
- this.purgeListeners();
- }
- });
- Ext.tree.TreeFilter = function(tree, config){
- this.tree = tree;
- this.filtered = {};
- Ext.apply(this, config);
- };
- Ext.tree.TreeFilter.prototype = {
- clearBlank:false,
- reverse:false,
- autoClear:false,
- remove:false,
- filter : function(value, attr, startNode){
- attr = attr || "text";
- var f;
- if(typeof value == "string"){
- var vlen = value.length;
- if(vlen == 0 && this.clearBlank){
- this.clear();
- return;
- }
- value = value.toLowerCase();
- f = function(n){
- return n.attributes[attr].substr(0, vlen).toLowerCase() == value;
- };
- }else if(value.exec){
- f = function(n){
- return value.test(n.attributes[attr]);
- };
- }else{
- throw 'Illegal filter type, must be string or regex';
- }
- this.filterBy(f, null, startNode);
- },
- filterBy : function(fn, scope, startNode){
- startNode = startNode || this.tree.root;
- if(this.autoClear){
- this.clear();
- }
- var af = this.filtered, rv = this.reverse;
- var f = function(n){
- if(n == startNode){
- return true;
- }
- if(af[n.id]){
- return false;
- }
- var m = fn.call(scope || n, n);
- if(!m || rv){
- af[n.id] = n;
- n.ui.hide();
- return false;
- }
- return true;
- };
- startNode.cascade(f);
- if(this.remove){
- for(var id in af){
- if(typeof id != "function"){
- var n = af[id];
- if(n && n.parentNode){
- n.parentNode.removeChild(n);
- }
- }
- }
- }
- },
- clear : function(){
- var t = this.tree;
- var af = this.filtered;
- for(var id in af){
- if(typeof id != "function"){
- var n = af[id];
- if(n){
- n.ui.show();
- }
- }
- }
- this.filtered = {};
- }
- };
- Ext.tree.TreeSorter = function(tree, config){
- Ext.apply(this, config);
- tree.on("beforechildrenrendered", this.doSort, this);
- tree.on("append", this.updateSort, this);
- tree.on("insert", this.updateSort, this);
- tree.on("textchange", this.updateSortParent, this);
- var dsc = this.dir && this.dir.toLowerCase() == "desc";
- var p = this.property || "text";
- var sortType = this.sortType;
- var fs = this.folderSort;
- var cs = this.caseSensitive === true;
- var leafAttr = this.leafAttr || 'leaf';
- this.sortFn = function(n1, n2){
- if(fs){
- if(n1.attributes[leafAttr] && !n2.attributes[leafAttr]){
- return 1;
- }
- if(!n1.attributes[leafAttr] && n2.attributes[leafAttr]){
- return -1;
- }
- }
- var v1 = sortType ? sortType(n1.attributes[p]) : (cs ? n1.attributes[p] : n1.attributes[p].toUpperCase());
- var v2 = sortType ? sortType(n2.attributes[p]) : (cs ? n2.attributes[p] : n2.attributes[p].toUpperCase());
- if(v1 < v2){
- return dsc ? +1 : -1;
- }else if(v1 > v2){
- return dsc ? -1 : +1;
- }else{
- return 0;
- }
- };
- };
- Ext.tree.TreeSorter.prototype = {
- doSort : function(node){
- node.sort(this.sortFn);
- },
- compareNodes : function(n1, n2){
- return (n1.text.toUpperCase() > n2.text.toUpperCase() ? 1 : -1);
- },
- updateSort : function(tree, node){
- if(node.childrenRendered){
- this.doSort.defer(1, this, [node]);
- }
- },
- updateSortParent : function(node){
- var p = node.parentNode;
- if(p && p.childrenRendered){
- this.doSort.defer(1, this, [p]);
- }
- }
- };
- if(Ext.dd.DropZone){
- Ext.tree.TreeDropZone = function(tree, config){
- this.allowParentInsert = config.allowParentInsert || false;
- this.allowContainerDrop = config.allowContainerDrop || false;
- this.appendOnly = config.appendOnly || false;
- Ext.tree.TreeDropZone.superclass.constructor.call(this, tree.getTreeEl(), config);
- this.tree = tree;
- this.dragOverData = {};
- this.lastInsertClass = "x-tree-no-status";
- };
- Ext.extend(Ext.tree.TreeDropZone, Ext.dd.DropZone, {
- ddGroup : "TreeDD",
- expandDelay : 1000,
- expandNode : function(node){
- if(node.hasChildNodes() && !node.isExpanded()){
- node.expand(false, null, this.triggerCacheRefresh.createDelegate(this));
- }
- },
- queueExpand : function(node){
- this.expandProcId = this.expandNode.defer(this.expandDelay, this, [node]);
- },
- cancelExpand : function(){
- if(this.expandProcId){
- clearTimeout(this.expandProcId);
- this.expandProcId = false;
- }
- },
- isValidDropPoint : function(n, pt, dd, e, data){
- if(!n || !data){ return false; }
- var targetNode = n.node;
- var dropNode = data.node;
- if(!(targetNode && targetNode.isTarget && pt)){
- return false;
- }
- if(pt == "append" && targetNode.allowChildren === false){
- return false;
- }
- if((pt == "above" || pt == "below") && (targetNode.parentNode && targetNode.parentNode.allowChildren === false)){
- return false;
- }
- if(dropNode && (targetNode == dropNode || dropNode.contains(targetNode))){
- return false;
- }
- var overEvent = this.dragOverData;
- overEvent.tree = this.tree;
- overEvent.target = targetNode;
- overEvent.data = data;
- overEvent.point = pt;
- overEvent.source = dd;
- overEvent.rawEvent = e;
- overEvent.dropNode = dropNode;
- overEvent.cancel = false;
- var result = this.tree.fireEvent("nodedragover", overEvent);
- return overEvent.cancel === false && result !== false;
- },
- getDropPoint : function(e, n, dd){
- var tn = n.node;
- if(tn.isRoot){
- return tn.allowChildren !== false ? "append" : false;
- }
- var dragEl = n.ddel;
- var t = Ext.lib.Dom.getY(dragEl), b = t + dragEl.offsetHeight;
- var y = Ext.lib.Event.getPageY(e);
- var noAppend = tn.allowChildren === false || tn.isLeaf();
- if(this.appendOnly || tn.parentNode.allowChildren === false){
- return noAppend ? false : "append";
- }
- var noBelow = false;
- if(!this.allowParentInsert){
- noBelow = tn.hasChildNodes() && tn.isExpanded();
- }
- var q = (b - t) / (noAppend ? 2 : 3);
- if(y >= t && y < (t + q)){
- return "above";
- }else if(!noBelow && (noAppend || y >= b-q && y <= b)){
- return "below";
- }else{
- return "append";
- }
- },
- onNodeEnter : function(n, dd, e, data){
- this.cancelExpand();
- },
- onContainerOver : function(dd, e, data) {
- if (this.allowContainerDrop && this.isValidDropPoint({ ddel: this.tree.getRootNode().ui.elNode, node: this.tree.getRootNode() }, "append", dd, e, data)) {
- return this.dropAllowed;
- }
- return this.dropNotAllowed;
- },
- onNodeOver : function(n, dd, e, data){
- var pt = this.getDropPoint(e, n, dd);
- var node = n.node;
- if(!this.expandProcId && pt == "append" && node.hasChildNodes() && !n.node.isExpanded()){
- this.queueExpand(node);
- }else if(pt != "append"){
- this.cancelExpand();
- }
- var returnCls = this.dropNotAllowed;
- if(this.isValidDropPoint(n, pt, dd, e, data)){
- if(pt){
- var el = n.ddel;
- var cls;
- if(pt == "above"){
- returnCls = n.node.isFirst() ? "x-tree-drop-ok-above" : "x-tree-drop-ok-between";
- cls = "x-tree-drag-insert-above";
- }else if(pt == "below"){
- returnCls = n.node.isLast() ? "x-tree-drop-ok-below" : "x-tree-drop-ok-between";
- cls = "x-tree-drag-insert-below";
- }else{
- returnCls = "x-tree-drop-ok-append";
- cls = "x-tree-drag-append";
- }
- if(this.lastInsertClass != cls){
- Ext.fly(el).replaceClass(this.lastInsertClass, cls);
- this.lastInsertClass = cls;
- }
- }
- }
- return returnCls;
- },
- onNodeOut : function(n, dd, e, data){
- this.cancelExpand();
- this.removeDropIndicators(n);
- },
- onNodeDrop : function(n, dd, e, data){
- var point = this.getDropPoint(e, n, dd);
- var targetNode = n.node;
- targetNode.ui.startDrop();
- if(!this.isValidDropPoint(n, point, dd, e, data)){
- targetNode.ui.endDrop();
- return false;
- }
- var dropNode = data.node || (dd.getTreeNode ? dd.getTreeNode(data, targetNode, point, e) : null);
- return this.processDrop(targetNode, data, point, dd, e, dropNode);
- },
- onContainerDrop : function(dd, e, data){
- if (this.allowContainerDrop && this.isValidDropPoint({ ddel: this.tree.getRootNode().ui.elNode, node: this.tree.getRootNode() }, "append", dd, e, data)) {
- var targetNode = this.tree.getRootNode();
- targetNode.ui.startDrop();
- var dropNode = data.node || (dd.getTreeNode ? dd.getTreeNode(data, targetNode, 'append', e) : null);
- return this.processDrop(targetNode, data, 'append', dd, e, dropNode);
- }
- return false;
- },
- processDrop: function(target, data, point, dd, e, dropNode){
- var dropEvent = {
- tree : this.tree,
- target: target,
- data: data,
- point: point,
- source: dd,
- rawEvent: e,
- dropNode: dropNode,
- cancel: !dropNode,
- dropStatus: false
- };
- var retval = this.tree.fireEvent("beforenodedrop", dropEvent);
- if(retval === false || dropEvent.cancel === true || !dropEvent.dropNode){
- target.ui.endDrop();
- return dropEvent.dropStatus;
- }
- target = dropEvent.target;
- if(point == 'append' && !target.isExpanded()){
- target.expand(false, null, function(){
- this.completeDrop(dropEvent);
- }.createDelegate(this));
- }else{
- this.completeDrop(dropEvent);
- }
- return true;
- },
- completeDrop : function(de){
- var ns = de.dropNode, p = de.point, t = de.target;
- if(!Ext.isArray(ns)){
- ns = [ns];
- }
- var n;
- for(var i = 0, len = ns.length; i < len; i++){
- n = ns[i];
- if(p == "above"){
- t.parentNode.insertBefore(n, t);
- }else if(p == "below"){
- t.parentNode.insertBefore(n, t.nextSibling);
- }else{
- t.appendChild(n);
- }
- }
- n.ui.focus();
- if(Ext.enableFx && this.tree.hlDrop){
- n.ui.highlight();
- }
- t.ui.endDrop();
- this.tree.fireEvent("nodedrop", de);
- },
- afterNodeMoved : function(dd, data, e, targetNode, dropNode){
- if(Ext.enableFx && this.tree.hlDrop){
- dropNode.ui.focus();
- dropNode.ui.highlight();
- }
- this.tree.fireEvent("nodedrop", this.tree, targetNode, data, dd, e);
- },
- getTree : function(){
- return this.tree;
- },
- removeDropIndicators : function(n){
- if(n && n.ddel){
- var el = n.ddel;
- Ext.fly(el).removeClass([
- "x-tree-drag-insert-above",
- "x-tree-drag-insert-below",
- "x-tree-drag-append"]);
- this.lastInsertClass = "_noclass";
- }
- },
- beforeDragDrop : function(target, e, id){
- this.cancelExpand();
- return true;
- },
- afterRepair : function(data){
- if(data && Ext.enableFx){
- data.node.ui.highlight();
- }
- this.hideProxy();
- }
- });
- }
- if(Ext.dd.DragZone){
- Ext.tree.TreeDragZone = function(tree, config){
- Ext.tree.TreeDragZone.superclass.constructor.call(this, tree.innerCt, config);
- this.tree = tree;
- };
- Ext.extend(Ext.tree.TreeDragZone, Ext.dd.DragZone, {
- ddGroup : "TreeDD",
- onBeforeDrag : function(data, e){
- var n = data.node;
- return n && n.draggable && !n.disabled;
- },
- onInitDrag : function(e){
- var data = this.dragData;
- this.tree.getSelectionModel().select(data.node);
- this.tree.eventModel.disable();
- this.proxy.update("");
- data.node.ui.appendDDGhost(this.proxy.ghost.dom);
- this.tree.fireEvent("startdrag", this.tree, data.node, e);
- },
- getRepairXY : function(e, data){
- return data.node.ui.getDDRepairXY();
- },
- onEndDrag : function(data, e){
- this.tree.eventModel.enable.defer(100, this.tree.eventModel);
- this.tree.fireEvent("enddrag", this.tree, data.node, e);
- },
- onValidDrop : function(dd, e, id){
- this.tree.fireEvent("dragdrop", this.tree, this.dragData.node, dd, e);
- this.hideProxy();
- },
- beforeInvalidDrop : function(e, id){
- var sm = this.tree.getSelectionModel();
- sm.clearSelections();
- sm.select(this.dragData.node);
- },
- afterRepair : function(){
- if (Ext.enableFx && this.tree.hlDrop) {
- Ext.Element.fly(this.dragData.ddel).highlight(this.hlColor || "c3daf9");
- }
- this.dragging = false;
- }
- });
- }
- Ext.tree.TreeEditor = function(tree, fc, config){
- fc = fc || {};
- var field = fc.events ? fc : new Ext.form.TextField(fc);
- Ext.tree.TreeEditor.superclass.constructor.call(this, field, config);
- this.tree = tree;
- if(!tree.rendered){
- tree.on('render', this.initEditor, this);
- }else{
- this.initEditor(tree);
- }
- };
- Ext.extend(Ext.tree.TreeEditor, Ext.Editor, {
- alignment: "l-l",
- autoSize: false,
- hideEl : false,
- cls: "x-small-editor x-tree-editor",
- shim:false,
- shadow:"frame",
- maxWidth: 250,
- editDelay : 350,
- initEditor : function(tree){
- tree.on({
- scope: this,
- beforeclick: this.beforeNodeClick,
- dblclick: this.onNodeDblClick
- });
- this.on({
- scope: this,
- complete: this.updateNode,
- beforestartedit: this.fitToTree,
- specialkey: this.onSpecialKey
- });
- this.on('startedit', this.bindScroll, this, {delay:10});
- },
- fitToTree : function(ed, el){
- var td = this.tree.getTreeEl().dom, nd = el.dom;
- if(td.scrollLeft > nd.offsetLeft){
- td.scrollLeft = nd.offsetLeft;
- }
- var w = Math.min(
- this.maxWidth,
- (td.clientWidth > 20 ? td.clientWidth : td.offsetWidth) - Math.max(0, nd.offsetLeft-td.scrollLeft) - 5);
- this.setSize(w, '');
- },
- triggerEdit : function(node, defer){
- this.completeEdit();
- if(node.attributes.editable !== false){
- this.editNode = node;
- if(this.tree.autoScroll){
- Ext.fly(node.ui.getEl()).scrollIntoView(this.tree.body);
- }
- var value = node.text || '';
- if (!Ext.isGecko && Ext.isEmpty(node.text)){
- node.setText(' ');
- }
- this.autoEditTimer = this.startEdit.defer(this.editDelay, this, [node.ui.textNode, value]);
- return false;
- }
- },
- bindScroll : function(){
- this.tree.getTreeEl().on('scroll', this.cancelEdit, this);
- },
- beforeNodeClick : function(node, e){
- clearTimeout(this.autoEditTimer);
- if(this.tree.getSelectionModel().isSelected(node)){
- e.stopEvent();
- return this.triggerEdit(node);
- }
- },
- onNodeDblClick : function(node, e){
- clearTimeout(this.autoEditTimer);
- },
- updateNode : function(ed, value){
- this.tree.getTreeEl().un('scroll', this.cancelEdit, this);
- this.editNode.setText(value);
- },
- onHide : function(){
- Ext.tree.TreeEditor.superclass.onHide.call(this);
- if(this.editNode){
- this.editNode.ui.focus.defer(50, this.editNode.ui);
- }
- },
- onSpecialKey : function(field, e){
- var k = e.getKey();
- if(k == e.ESC){
- e.stopEvent();
- this.cancelEdit();
- }else if(k == e.ENTER && !e.hasModifier()){
- e.stopEvent();
- this.completeEdit();
- }
- },
- onDestroy : function(){
- clearTimeout(this.autoEditTimer);
- Ext.tree.TreeEditor.superclass.onDestroy.call(this);
- var tree = this.tree;
- tree.un('beforeclick', this.beforeNodeClick, this);
- tree.un('dblclick', this.onNodeDblClick, this);
- }
- });
- var swfobject = function() {
- var UNDEF = "undefined",
- OBJECT = "object",
- SHOCKWAVE_FLASH = "Shockwave Flash",
- SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
- FLASH_MIME_TYPE = "application/x-shockwave-flash",
- EXPRESS_INSTALL_ID = "SWFObjectExprInst",
- ON_READY_STATE_CHANGE = "onreadystatechange",
- win = window,
- doc = document,
- nav = navigator,
- plugin = false,
- domLoadFnArr = [main],
- regObjArr = [],
- objIdArr = [],
- listenersArr = [],
- storedAltContent,
- storedAltContentId,
- storedCallbackFn,
- storedCallbackObj,
- isDomLoaded = false,
- isExpressInstallActive = false,
- dynamicStylesheet,
- dynamicStylesheetMedia,
- autoHideShow = true,
- ua = function() {
- var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
- u = nav.userAgent.toLowerCase(),
- p = nav.platform.toLowerCase(),
- windows = p ? /win/.test(p) : /win/.test(u),
- mac = p ? /mac/.test(p) : /mac/.test(u),
- webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit/(d+(.d+)?).*$/, "$1")) : false,
- ie = !+"v1",
- playerVersion = [0,0,0],
- d = null;
- if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
- d = nav.plugins[SHOCKWAVE_FLASH].description;
- if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) {
- plugin = true;
- ie = false;
- d = d.replace(/^.*s+(S+s+S+$)/, "$1");
- playerVersion[0] = parseInt(d.replace(/^(.*)..*$/, "$1"), 10);
- playerVersion[1] = parseInt(d.replace(/^.*.(.*)s.*$/, "$1"), 10);
- playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0;
- }
- }
- else if (typeof win.ActiveXObject != UNDEF) {
- try {
- var a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
- if (a) {
- d = a.GetVariable("$version");
- if (d) {
- ie = true;
- d = d.split(" ")[1].split(",");
- playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
- }
- }
- }
- catch(e) {}
- }
- return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac };
- }(),
- onDomLoad = function() {
- if (!ua.w3) { return; }
- if ((typeof doc.readyState != UNDEF && doc.readyState == "complete") || (typeof doc.readyState == UNDEF && (doc.getElementsByTagName("body")[0] || doc.body))) {
- callDomLoadFunctions();
- }
- if (!isDomLoaded) {
- if (typeof doc.addEventListener != UNDEF) {
- doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, false);
- }
- if (ua.ie && ua.win) {
- doc.attachEvent(ON_READY_STATE_CHANGE, function() {
- if (doc.readyState == "complete") {
- doc.detachEvent(ON_READY_STATE_CHANGE, arguments.callee);
- callDomLoadFunctions();
- }
- });
- if (win == top) {
- (function(){
- if (isDomLoaded) { return; }
- try {
- doc.documentElement.doScroll("left");
- }
- catch(e) {
- setTimeout(arguments.callee, 0);
- return;
- }
- callDomLoadFunctions();
- })();
- }
- }
- if (ua.wk) {
- (function(){
- if (isDomLoaded) { return; }
- if (!/loaded|complete/.test(doc.readyState)) {
- setTimeout(arguments.callee, 0);
- return;
- }
- callDomLoadFunctions();
- })();
- }
- addLoadEvent(callDomLoadFunctions);
- }
- }();
- function callDomLoadFunctions() {
- if (isDomLoaded) { return; }
- try {
- var t = doc.getElementsByTagName("body")[0].appendChild(createElement("span"));
- t.parentNode.removeChild(t);
- }
- catch (e) { return; }
- isDomLoaded = true;
- var dl = domLoadFnArr.length;
- for (var i = 0; i < dl; i++) {
- domLoadFnArr[i]();
- }
- }
- function addDomLoadEvent(fn) {
- if (isDomLoaded) {
- fn();
- }
- else {
- domLoadFnArr[domLoadFnArr.length] = fn;
- }
- }
- function addLoadEvent(fn) {
- if (typeof win.addEventListener != UNDEF) {
- win.addEventListener("load", fn, false);
- }
- else if (typeof doc.addEventListener != UNDEF) {
- doc.addEventListener("load", fn, false);
- }
- else if (typeof win.attachEvent != UNDEF) {
- addListener(win, "onload", fn);
- }
- else if (typeof win.onload == "function") {
- var fnOld = win.onload;
- win.onload = function() {
- fnOld();
- fn();
- };
- }
- else {
- win.onload = fn;
- }
- }
- function main() {
- if (plugin) {
- testPlayerVersion();
- }
- else {
- matchVersions();
- }
- }
- function testPlayerVersion() {
- var b = doc.getElementsByTagName("body")[0];
- var o = createElement(OBJECT);
- o.setAttribute("type", FLASH_MIME_TYPE);
- var t = b.appendChild(o);
- if (t) {
- var counter = 0;
- (function(){
- if (typeof t.GetVariable != UNDEF) {
- var d = t.GetVariable("$version");
- if (d) {
- d = d.split(" ")[1].split(",");
- ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
- }
- }
- else if (counter < 10) {
- counter++;
- setTimeout(arguments.callee, 10);
- return;
- }
- b.removeChild(o);
- t = null;
- matchVersions();
- })();
- }
- else {
- matchVersions();
- }
- }
- function matchVersions() {
- var rl = regObjArr.length;
- if (rl > 0) {
- for (var i = 0; i < rl; i++) {
- var id = regObjArr[i].id;
- var cb = regObjArr[i].callbackFn;
- var cbObj = {success:false, id:id};
- if (ua.pv[0] > 0) {
- var obj = getElementById(id);
- if (obj) {
- if (hasPlayerVersion(regObjArr[i].swfVersion) && !(ua.wk && ua.wk < 312)) {
- setVisibility(id, true);
- if (cb) {
- cbObj.success = true;
- cbObj.ref = getObjectById(id);
- cb(cbObj);
- }
- }
- else if (regObjArr[i].expressInstall && canExpressInstall()) {
- var att = {};
- att.data = regObjArr[i].expressInstall;
- att.width = obj.getAttribute("width") || "0";
- att.height = obj.getAttribute("height") || "0";
- if (obj.getAttribute("class")) { att.styleclass = obj.getAttribute("class"); }
- if (obj.getAttribute("align")) { att.align = obj.getAttribute("align"); }
- var par = {};
- var p = obj.getElementsByTagName("param");
- var pl = p.length;
- for (var j = 0; j < pl; j++) {
- if (p[j].getAttribute("name").toLowerCase() != "movie") {
- par[p[j].getAttribute("name")] = p[j].getAttribute("value");
- }
- }
- showExpressInstall(att, par, id, cb);
- }
- else {
- displayAltContent(obj);
- if (cb) { cb(cbObj); }
- }
- }
- }
- else {
- setVisibility(id, true);
- if (cb) {
- var o = getObjectById(id);
- if (o && typeof o.SetVariable != UNDEF) {
- cbObj.success = true;
- cbObj.ref = o;
- }
- cb(cbObj);
- }
- }
- }
- }
- }
- function getObjectById(objectIdStr) {
- var r = null;
- var o = getElementById(objectIdStr);
- if (o && o.nodeName == "OBJECT") {
- if (typeof o.SetVariable != UNDEF) {
- r = o;
- }
- else {
- var n = o.getElementsByTagName(OBJECT)[0];
- if (n) {
- r = n;
- }
- }
- }
- return r;
- }
- function canExpressInstall() {
- return !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac) && !(ua.wk && ua.wk < 312);
- }
- function showExpressInstall(att, par, replaceElemIdStr, callbackFn) {
- isExpressInstallActive = true;
- storedCallbackFn = callbackFn || null;
- storedCallbackObj = {success:false, id:replaceElemIdStr};
- var obj = getElementById(replaceElemIdStr);
- if (obj) {
- if (obj.nodeName == "OBJECT") {
- storedAltContent = abstractAltContent(obj);
- storedAltContentId = null;
- }
- else {
- storedAltContent = obj;
- storedAltContentId = replaceElemIdStr;
- }
- att.id = EXPRESS_INSTALL_ID;
- if (typeof att.width == UNDEF || (!/%$/.test(att.width) && parseInt(att.width, 10) < 310)) { att.width = "310"; }
- if (typeof att.height == UNDEF || (!/%$/.test(att.height) && parseInt(att.height, 10) < 137)) { att.height = "137"; }
- doc.title = doc.title.slice(0, 47) + " - Flash Player Installation";
- var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn",
- fv = "MMredirectURL=" + win.location.toString().replace(/&/g,"%26") + "&MMplayerType=" + pt + "&MMdoctitle=" + doc.title;
- if (typeof par.flashvars != UNDEF) {
- par.flashvars += "&" + fv;
- }
- else {
- par.flashvars = fv;
- }
- if (ua.ie && ua.win && obj.readyState != 4) {
- var newObj = createElement("div");
- replaceElemIdStr += "SWFObjectNew";
- newObj.setAttribute("id", replaceElemIdStr);
- obj.parentNode.insertBefore(newObj, obj);
- obj.style.display = "none";
- (function(){
- if (obj.readyState == 4) {
- obj.parentNode.removeChild(obj);
- }
- else {
- setTimeout(arguments.callee, 10);
- }
- })();
- }
- createSWF(att, par, replaceElemIdStr);
- }
- }
- function displayAltContent(obj) {
- if (ua.ie && ua.win && obj.readyState != 4) {
- var el = createElement("div");
- obj.parentNode.insertBefore(el, obj);
- el.parentNode.replaceChild(abstractAltContent(obj), el);
- obj.style.display = "none";
- (function(){
- if (obj.readyState == 4) {
- obj.parentNode.removeChild(obj);
- }
- else {
- setTimeout(arguments.callee, 10);
- }
- })();
- }
- else {
- obj.parentNode.replaceChild(abstractAltContent(obj), obj);
- }
- }
- function abstractAltContent(obj) {
- var ac = createElement("div");
- if (ua.win && ua.ie) {
- ac.innerHTML = obj.innerHTML;
- }
- else {
- var nestedObj = obj.getElementsByTagName(OBJECT)[0];
- if (nestedObj) {
- var c = nestedObj.childNodes;
- if (c) {
- var cl = c.length;
- for (var i = 0; i < cl; i++) {
- if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) {
- ac.appendChild(c[i].cloneNode(true));
- }
- }
- }
- }
- }
- return ac;
- }
- function createSWF(attObj, parObj, id) {
- var r, el = getElementById(id);
- if (ua.wk && ua.wk < 312) { return r; }
- if (el) {
- if (typeof attObj.id == UNDEF) {
- attObj.id = id;
- }
- if (ua.ie && ua.win) {
- var att = "";
- for (var i in attObj) {
- if (attObj[i] != Object.prototype[i]) {
- if (i.toLowerCase() == "data") {
- parObj.movie = attObj[i];
- }
- else if (i.toLowerCase() == "styleclass") {
- att += ' class="' + attObj[i] + '"';
- }
- else if (i.toLowerCase() != "classid") {
- att += ' ' + i + '="' + attObj[i] + '"';
- }
- }
- }
- var par = "";
- for (var j in parObj) {
- if (parObj[j] != Object.prototype[j]) {
- par += '<param name="' + j + '" value="' + parObj[j] + '" />';
- }
- }
- el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + '>' + par + '</object>';
- objIdArr[objIdArr.length] = attObj.id;
- r = getElementById(attObj.id);
- }
- else {
- var o = createElement(OBJECT);
- o.setAttribute("type", FLASH_MIME_TYPE);
- for (var m in attObj) {
- if (attObj[m] != Object.prototype[m]) {
- if (m.toLowerCase() == "styleclass") {
- o.setAttribute("class", attObj[m]);
- }
- else if (m.toLowerCase() != "classid") {
- o.setAttribute(m, attObj[m]);
- }
- }
- }
- for (var n in parObj) {
- if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") {
- createObjParam(o, n, parObj[n]);
- }
- }
- el.parentNode.replaceChild(o, el);
- r = o;
- }
- }
- return r;
- }
- function createObjParam(el, pName, pValue) {
- var p = createElement("param");
- p.setAttribute("name", pName);
- p.setAttribute("value", pValue);
- el.appendChild(p);
- }
- function removeSWF(id) {
- var obj = getElementById(id);
- if (obj && obj.nodeName == "OBJECT") {
- if (ua.ie && ua.win) {
- obj.style.display = "none";
- (function(){
- if (obj.readyState == 4) {
- removeObjectInIE(id);
- }
- else {
- setTimeout(arguments.callee, 10);
- }
- })();
- }
- else {
- obj.parentNode.removeChild(obj);
- }
- }
- }
- function removeObjectInIE(id) {
- var obj = getElementById(id);
- if (obj) {
- for (var i in obj) {
- if (typeof obj[i] == "function") {
- obj[i] = null;
- }
- }
- obj.parentNode.removeChild(obj);
- }
- }
- function getElementById(id) {
- var el = null;
- try {
- el = doc.getElementById(id);
- }
- catch (e) {}
- return el;
- }
- function createElement(el) {
- return doc.createElement(el);
- }
- function addListener(target, eventType, fn) {
- target.attachEvent(eventType, fn);
- listenersArr[listenersArr.length] = [target, eventType, fn];
- }
- function hasPlayerVersion(rv) {
- var pv = ua.pv, v = rv.split(".");
- v[0] = parseInt(v[0], 10);
- v[1] = parseInt(v[1], 10) || 0;
- v[2] = parseInt(v[2], 10) || 0;
- return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
- }
- function createCSS(sel, decl, media, newStyle) {
- if (ua.ie && ua.mac) { return; }
- var h = doc.getElementsByTagName("head")[0];
- if (!h) { return; }
- var m = (media && typeof media == "string") ? media : "screen";
- if (newStyle) {
- dynamicStylesheet = null;
- dynamicStylesheetMedia = null;
- }
- if (!dynamicStylesheet || dynamicStylesheetMedia != m) {
- var s = createElement("style");
- s.setAttribute("type", "text/css");
- s.setAttribute("media", m);
- dynamicStylesheet = h.appendChild(s);
- if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) {
- dynamicStylesheet = doc.styleSheets[doc.styleSheets.length - 1];
- }
- dynamicStylesheetMedia = m;
- }
- if (ua.ie && ua.win) {
- if (dynamicStylesheet && typeof dynamicStylesheet.addRule == OBJECT) {
- dynamicStylesheet.addRule(sel, decl);
- }
- }
- else {
- if (dynamicStylesheet && typeof doc.createTextNode != UNDEF) {
- dynamicStylesheet.appendChild(doc.createTextNode(sel + " {" + decl + "}"));
- }
- }
- }
- function setVisibility(id, isVisible) {
- if (!autoHideShow) { return; }
- var v = isVisible ? "visible" : "hidden";
- if (isDomLoaded && getElementById(id)) {
- getElementById(id).style.visibility = v;
- }
- else {
- createCSS("#" + id, "visibility:" + v);
- }
- }
- function urlEncodeIfNecessary(s) {
- var regex = /[\"<>.;]/;
- var hasBadChars = regex.exec(s) != null;
- return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s;
- }
- var cleanup = function() {
- if (ua.ie && ua.win) {
- window.attachEvent("onunload", function() {
- var ll = listenersArr.length;
- for (var i = 0; i < ll; i++) {
- listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]);
- }
- var il = objIdArr.length;
- for (var j = 0; j < il; j++) {
- removeSWF(objIdArr[j]);
- }
- for (var k in ua) {
- ua[k] = null;
- }
- ua = null;
- for (var l in swfobject) {
- swfobject[l] = null;
- }
- swfobject = null;
- });
- }
- }();
- return {
- registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr, callbackFn) {
- if (ua.w3 && objectIdStr && swfVersionStr) {
- var regObj = {};
- regObj.id = objectIdStr;
- regObj.swfVersion = swfVersionStr;
- regObj.expressInstall = xiSwfUrlStr;
- regObj.callbackFn = callbackFn;
- regObjArr[regObjArr.length] = regObj;
- setVisibility(objectIdStr, false);
- }
- else if (callbackFn) {
- callbackFn({success:false, id:objectIdStr});
- }
- },
- getObjectById: function(objectIdStr) {
- if (ua.w3) {
- return getObjectById(objectIdStr);
- }
- },
- embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) {
- var callbackObj = {success:false, id:replaceElemIdStr};
- if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) {
- setVisibility(replaceElemIdStr, false);
- addDomLoadEvent(function() {
- widthStr += "";
- heightStr += "";
- var att = {};
- if (attObj && typeof attObj === OBJECT) {
- for (var i in attObj) {
- att[i] = attObj[i];
- }
- }
- att.data = swfUrlStr;
- att.width = widthStr;
- att.height = heightStr;
- var par = {};
- if (parObj && typeof parObj === OBJECT) {
- for (var j in parObj) {
- par[j] = parObj[j];
- }
- }
- if (flashvarsObj && typeof flashvarsObj === OBJECT) {
- for (var k in flashvarsObj) {
- if (typeof par.flashvars != UNDEF) {
- par.flashvars += "&" + k + "=" + flashvarsObj[k];
- }
- else {
- par.flashvars = k + "=" + flashvarsObj[k];
- }
- }
- }
- if (hasPlayerVersion(swfVersionStr)) {
- var obj = createSWF(att, par, replaceElemIdStr);
- if (att.id == replaceElemIdStr) {
- setVisibility(replaceElemIdStr, true);
- }
- callbackObj.success = true;
- callbackObj.ref = obj;
- }
- else if (xiSwfUrlStr && canExpressInstall()) {
- att.data = xiSwfUrlStr;
- showExpressInstall(att, par, replaceElemIdStr, callbackFn);
- return;
- }
- else {
- setVisibility(replaceElemIdStr, true);
- }
- if (callbackFn) { callbackFn(callbackObj); }
- });
- }
- else if (callbackFn) { callbackFn(callbackObj); }
- },
- switchOffAutoHideShow: function() {
- autoHideShow = false;
- },
- ua: ua,
- getFlashPlayerVersion: function() {
- return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] };
- },
- hasFlashPlayerVersion: hasPlayerVersion,
- createSWF: function(attObj, parObj, replaceElemIdStr) {
- if (ua.w3) {
- return createSWF(attObj, parObj, replaceElemIdStr);
- }
- else {
- return undefined;
- }
- },
- showExpressInstall: function(att, par, replaceElemIdStr, callbackFn) {
- if (ua.w3 && canExpressInstall()) {
- showExpressInstall(att, par, replaceElemIdStr, callbackFn);
- }
- },
- removeSWF: function(objElemIdStr) {
- if (ua.w3) {
- removeSWF(objElemIdStr);
- }
- },
- createCSS: function(selStr, declStr, mediaStr, newStyleBoolean) {
- if (ua.w3) {
- createCSS(selStr, declStr, mediaStr, newStyleBoolean);
- }
- },
- addDomLoadEvent: addDomLoadEvent,
- addLoadEvent: addLoadEvent,
- getQueryParamValue: function(param) {
- var q = doc.location.search || doc.location.hash;
- if (q) {
- if (/?/.test(q)) { q = q.split("?")[1]; }
- if (param == null) {
- return urlEncodeIfNecessary(q);
- }
- var pairs = q.split("&");
- for (var i = 0; i < pairs.length; i++) {
- if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
- return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=") + 1)));
- }
- }
- }
- return "";
- },
- expressInstallCallback: function() {
- if (isExpressInstallActive) {
- var obj = getElementById(EXPRESS_INSTALL_ID);
- if (obj && storedAltContent) {
- obj.parentNode.replaceChild(storedAltContent, obj);
- if (storedAltContentId) {
- setVisibility(storedAltContentId, true);
- if (ua.ie && ua.win) { storedAltContent.style.display = "block"; }
- }
- if (storedCallbackFn) { storedCallbackFn(storedCallbackObj); }
- }
- isExpressInstallActive = false;
- }
- }
- };
- }();
- Ext.FlashComponent = Ext.extend(Ext.BoxComponent, {
- flashVersion : '9.0.115',
- backgroundColor: '#ffffff',
- wmode: 'opaque',
- flashVars: undefined,
- flashParams: undefined,
- url: undefined,
- swfId : undefined,
- swfWidth: '100%',
- swfHeight: '100%',
- expressInstall: false,
- initComponent : function(){
- Ext.FlashComponent.superclass.initComponent.call(this);
- this.addEvents(
- 'initialize'
- );
- },
- onRender : function(){
- Ext.FlashComponent.superclass.onRender.apply(this, arguments);
- var params = Ext.apply({
- allowScriptAccess: 'always',
- bgcolor: this.backgroundColor,
- wmode: this.wmode
- }, this.flashParams), vars = Ext.apply({
- allowedDomain: document.location.hostname,
- elementID: this.getId(),
- eventHandler: 'Ext.FlashEventProxy.onEvent'
- }, this.flashVars);
- new swfobject.embedSWF(this.url, this.id, this.swfWidth, this.swfHeight, this.flashVersion,
- this.expressInstall ? Ext.FlashComponent.EXPRESS_INSTALL_URL : undefined, vars, params);
- this.swf = Ext.getDom(this.id);
- this.el = Ext.get(this.swf);
- },
- getSwfId : function(){
- return this.swfId || (this.swfId = "extswf" + (++Ext.Component.AUTO_ID));
- },
- getId : function(){
- return this.id || (this.id = "extflashcmp" + (++Ext.Component.AUTO_ID));
- },
- onFlashEvent : function(e){
- switch(e.type){
- case "swfReady":
- this.initSwf();
- return;
- case "log":
- return;
- }
- e.component = this;
- this.fireEvent(e.type.toLowerCase().replace(/event$/, ''), e);
- },
- initSwf : function(){
- this.onSwfReady(!!this.isInitialized);
- this.isInitialized = true;
- this.fireEvent('initialize', this);
- },
- beforeDestroy: function(){
- if(this.rendered){
- swfobject.removeSWF(this.swf.id);
- }
- Ext.FlashComponent.superclass.beforeDestroy.call(this);
- },
- onSwfReady : Ext.emptyFn
- });
- Ext.FlashComponent.EXPRESS_INSTALL_URL = 'http:/' + '/swfobject.googlecode.com/svn/trunk/swfobject/expressInstall.swf';
- Ext.reg('flash', Ext.FlashComponent);
- Ext.FlashEventProxy = {
- onEvent : function(id, e){
- var fp = Ext.getCmp(id);
- if(fp){
- fp.onFlashEvent(e);
- }else{
- arguments.callee.defer(10, this, [id, e]);
- }
- }
- }
- Ext.chart.Chart = Ext.extend(Ext.FlashComponent, {
- refreshBuffer: 100,
- chartStyle: {
- padding: 10,
- animationEnabled: true,
- font: {
- name: 'Tahoma',
- color: 0x444444,
- size: 11
- },
- dataTip: {
- padding: 5,
- border: {
- color: 0x99bbe8,
- size:1
- },
- background: {
- color: 0xDAE7F6,
- alpha: .9
- },
- font: {
- name: 'Tahoma',
- color: 0x15428B,
- size: 10,
- bold: true
- }
- }
- },
- extraStyle: null,
- seriesStyles: null,
- disableCaching: Ext.isIE || Ext.isOpera,
- disableCacheParam: '_dc',
- initComponent : function(){
- Ext.chart.Chart.superclass.initComponent.call(this);
- if(!this.url){
- this.url = Ext.chart.Chart.CHART_URL;
- }
- if(this.disableCaching){
- this.url = Ext.urlAppend(this.url, String.format('{0}={1}', this.disableCacheParam, new Date().getTime()));
- }
- this.addEvents(
- 'itemmouseover',
- 'itemmouseout',
- 'itemclick',
- 'itemdoubleclick',
- 'itemdragstart',
- 'itemdrag',
- 'itemdragend',
- 'beforerefresh',
- 'refresh'
- );
- this.store = Ext.StoreMgr.lookup(this.store);
- },
- setStyle: function(name, value){
- this.swf.setStyle(name, Ext.encode(value));
- },
- setStyles: function(styles){
- this.swf.setStyles(Ext.encode(styles));
- },
- setSeriesStyles: function(styles){
- this.seriesStyles = styles;
- var s = [];
- Ext.each(styles, function(style){
- s.push(Ext.encode(style));
- });
- this.swf.setSeriesStyles(s);
- },
- setCategoryNames : function(names){
- this.swf.setCategoryNames(names);
- },
- setTipRenderer : function(fn){
- var chart = this;
- this.tipFnName = this.createFnProxy(function(item, index, series){
- var record = chart.store.getAt(index);
- return fn(chart, record, index, series);
- }, this.tipFnName);
- this.swf.setDataTipFunction(this.tipFnName);
- },
- setSeries : function(series){
- this.series = series;
- this.refresh();
- },
- bindStore : function(store, initial){
- if(!initial && this.store){
- if(store !== this.store && this.store.autoDestroy){
- this.store.destroy();
- }else{
- this.store.un("datachanged", this.refresh, this);
- this.store.un("add", this.delayRefresh, this);
- this.store.un("remove", this.delayRefresh, this);
- this.store.un("update", this.delayRefresh, this);
- this.store.un("clear", this.refresh, this);
- }
- }
- if(store){
- store = Ext.StoreMgr.lookup(store);
- store.on({
- scope: this,
- datachanged: this.refresh,
- add: this.delayRefresh,
- remove: this.delayRefresh,
- update: this.delayRefresh,
- clear: this.refresh
- });
- }
- this.store = store;
- if(store && !initial){
- this.refresh();
- }
- },
- onSwfReady : function(isReset){
- Ext.chart.Chart.superclass.onSwfReady.call(this, isReset);
- this.swf.setType(this.type);
- if(this.chartStyle){
- this.setStyles(Ext.apply({}, this.extraStyle, this.chartStyle));
- }
- if(this.categoryNames){
- this.setCategoryNames(this.categoryNames);
- }
- if(this.tipRenderer){
- this.setTipRenderer(this.tipRenderer);
- }
- if(!isReset){
- this.bindStore(this.store, true);
- }
- this.refresh.defer(10, this);
- },
- delayRefresh : function(){
- if(!this.refreshTask){
- this.refreshTask = new Ext.util.DelayedTask(this.refresh, this);
- }
- this.refreshTask.delay(this.refreshBuffer);
- },
- refresh : function(){
- if(this.fireEvent('beforerefresh', this) !== false){
- var styleChanged = false;
- var data = [], rs = this.store.data.items;
- for(var j = 0, len = rs.length; j < len; j++){
- data[j] = rs[j].data;
- }
- var dataProvider = [];
- var seriesCount = 0;
- var currentSeries = null;
- var i = 0;
- if(this.series){
- seriesCount = this.series.length;
- for(i = 0; i < seriesCount; i++){
- currentSeries = this.series[i];
- var clonedSeries = {};
- for(var prop in currentSeries){
- if(prop == "style" && currentSeries.style !== null){
- clonedSeries.style = Ext.encode(currentSeries.style);
- styleChanged = true;
- } else{
- clonedSeries[prop] = currentSeries[prop];
- }
- }
- dataProvider.push(clonedSeries);
- }
- }
- if(seriesCount > 0){
- for(i = 0; i < seriesCount; i++){
- currentSeries = dataProvider[i];
- if(!currentSeries.type){
- currentSeries.type = this.type;
- }
- currentSeries.dataProvider = data;
- }
- } else{
- dataProvider.push({type: this.type, dataProvider: data});
- }
- this.swf.setDataProvider(dataProvider);
- if(this.seriesStyles){
- this.setSeriesStyles(this.seriesStyles);
- }
- this.fireEvent('refresh', this);
- }
- },
- createFnProxy : function(fn, old){
- if(old){
- delete window[old];
- }
- var fnName = "extFnProxy" + (++Ext.chart.Chart.PROXY_FN_ID);
- window[fnName] = fn;
- return fnName;
- },
- onDestroy: function(){
- Ext.chart.Chart.superclass.onDestroy.call(this);
- this.bindStore(null);
- var tip = this.tipFnName;
- if(!Ext.isEmpty(tip)){
- delete window[tip];
- }
- }
- });
- Ext.reg('chart', Ext.chart.Chart);
- Ext.chart.Chart.PROXY_FN_ID = 0;
- Ext.chart.Chart.CHART_URL = 'http:/' + '/yui.yahooapis.com/2.7.0/build/charts/assets/charts.swf';
- Ext.chart.PieChart = Ext.extend(Ext.chart.Chart, {
- type: 'pie',
- onSwfReady : function(isReset){
- Ext.chart.PieChart.superclass.onSwfReady.call(this, isReset);
- this.setDataField(this.dataField);
- this.setCategoryField(this.categoryField);
- },
- setDataField : function(field){
- this.dataField = field;
- this.swf.setDataField(field);
- },
- setCategoryField : function(field){
- this.categoryField = field;
- this.swf.setCategoryField(field);
- }
- });
- Ext.reg('piechart', Ext.chart.PieChart);
- Ext.chart.CartesianChart = Ext.extend(Ext.chart.Chart, {
- onSwfReady : function(isReset){
- Ext.chart.CartesianChart.superclass.onSwfReady.call(this, isReset);
- if(this.xField){
- this.setXField(this.xField);
- }
- if(this.yField){
- this.setYField(this.yField);
- }
- if(this.xAxis){
- this.setXAxis(this.xAxis);
- }
- if(this.yAxis){
- this.setYAxis(this.yAxis);
- }
- },
- setXField : function(value){
- this.xField = value;
- this.swf.setHorizontalField(value);
- },
- setYField : function(value){
- this.yField = value;
- this.swf.setVerticalField(value);
- },
- setXAxis : function(value){
- this.xAxis = this.createAxis('xAxis', value);
- this.swf.setHorizontalAxis(this.xAxis);
- },
- setYAxis : function(value){
- this.yAxis = this.createAxis('yAxis', value);
- this.swf.setVerticalAxis(this.yAxis);
- },
- createAxis : function(axis, value){
- var o = Ext.apply({}, value), oldFn = null;
- if(this[axis]){
- oldFn = this[axis].labelFunction;
- }
- if(o.labelRenderer){
- var fn = o.labelRenderer;
- o.labelFunction = this.createFnProxy(function(v){
- return fn(v);
- }, oldFn);
- delete o.labelRenderer;
- }
- return o;
- }
- });
- Ext.reg('cartesianchart', Ext.chart.CartesianChart);
- Ext.chart.LineChart = Ext.extend(Ext.chart.CartesianChart, {
- type: 'line'
- });
- Ext.reg('linechart', Ext.chart.LineChart);
- Ext.chart.ColumnChart = Ext.extend(Ext.chart.CartesianChart, {
- type: 'column'
- });
- Ext.reg('columnchart', Ext.chart.ColumnChart);
- Ext.chart.StackedColumnChart = Ext.extend(Ext.chart.CartesianChart, {
- type: 'stackcolumn'
- });
- Ext.reg('stackedcolumnchart', Ext.chart.StackedColumnChart);
- Ext.chart.BarChart = Ext.extend(Ext.chart.CartesianChart, {
- type: 'bar'
- });
- Ext.reg('barchart', Ext.chart.BarChart);
- Ext.chart.StackedBarChart = Ext.extend(Ext.chart.CartesianChart, {
- type: 'stackbar'
- });
- Ext.reg('stackedbarchart', Ext.chart.StackedBarChart);
- Ext.chart.Axis = function(config){
- Ext.apply(this, config);
- };
- Ext.chart.Axis.prototype =
- {
- type: null,
- orientation: "horizontal",
- reverse: false,
- labelFunction: null,
- hideOverlappingLabels: true
- };
- Ext.chart.NumericAxis = Ext.extend(Ext.chart.Axis, {
- type: "numeric",
- minimum: NaN,
- maximum: NaN,
- majorUnit: NaN,
- minorUnit: NaN,
- snapToUnits: true,
- alwaysShowZero: true,
- scale: "linear"
- });
- Ext.chart.TimeAxis = Ext.extend(Ext.chart.Axis, {
- type: "time",
- minimum: null,
- maximum: null,
- majorUnit: NaN,
- majorTimeUnit: null,
- minorUnit: NaN,
- minorTimeUnit: null,
- snapToUnits: true
- });
- Ext.chart.CategoryAxis = Ext.extend(Ext.chart.Axis, {
- type: "category",
- categoryNames: null
- });
- Ext.chart.Series = function(config) { Ext.apply(this, config); };
- Ext.chart.Series.prototype =
- {
- type: null,
- displayName: null
- };
- Ext.chart.CartesianSeries = Ext.extend(Ext.chart.Series, {
- xField: null,
- yField: null
- });
- Ext.chart.ColumnSeries = Ext.extend(Ext.chart.CartesianSeries, {
- type: "column"
- });
- Ext.chart.LineSeries = Ext.extend(Ext.chart.CartesianSeries, {
- type: "line"
- });
- Ext.chart.BarSeries = Ext.extend(Ext.chart.CartesianSeries, {
- type: "bar"
- });
- Ext.chart.PieSeries = Ext.extend(Ext.chart.Series, {
- type: "pie",
- dataField: null,
- categoryField: null
- });
- Ext.layout.MenuLayout = Ext.extend(Ext.layout.ContainerLayout, {
- monitorResize : true,
- setContainer : function(ct){
- this.monitorResize = !ct.floating;
- ct.on('autosize', this.doAutoSize, this);
- Ext.layout.MenuLayout.superclass.setContainer.call(this, ct);
- },
- renderItem : function(c, position, target){
- if (!this.itemTpl) {
- this.itemTpl = Ext.layout.MenuLayout.prototype.itemTpl = new Ext.XTemplate(
- '<li id="{itemId}" class="{itemCls}">',
- '<tpl if="needsIcon">',
- '<img src="{icon}" class="{iconCls}"/>',
- '</tpl>',
- '</li>'
- );
- }
- if(c && !c.rendered){
- if(Ext.isNumber(position)){
- position = target.dom.childNodes[position];
- }
- var a = this.getItemArgs(c);
- c.render(c.positionEl = position ?
- this.itemTpl.insertBefore(position, a, true) :
- this.itemTpl.append(target, a, true));
- c.positionEl.menuItemId = c.getItemId();
- if (!a.isMenuItem && a.needsIcon) {
- c.positionEl.addClass('x-menu-list-item-indent');
- }
- this.configureItem(c, position);
- }else if(c && !this.isValidParent(c, target)){
- if(Ext.isNumber(position)){
- position = target.dom.childNodes[position];
- }
- target.dom.insertBefore(c.getActionEl().dom, position || null);
- }
- },
- getItemArgs : function(c) {
- var isMenuItem = c instanceof Ext.menu.Item;
- return {
- isMenuItem: isMenuItem,
- needsIcon: !isMenuItem && (c.icon || c.iconCls),
- icon: c.icon || Ext.BLANK_IMAGE_URL,
- iconCls: 'x-menu-item-icon ' + (c.iconCls || ''),
- itemId: 'x-menu-el-' + c.id,
- itemCls: 'x-menu-list-item '
- };
- },
- isValidParent : function(c, target) {
- return c.el.up('li.x-menu-list-item', 5).dom.parentNode === (target.dom || target);
- },
- onLayout : function(ct, target){
- this.renderAll(ct, target);
- this.doAutoSize();
- },
- doAutoSize : function(){
- var ct = this.container, w = ct.width;
- if(ct.floating){
- if(w){
- ct.setWidth(w);
- }else if(Ext.isIE){
- ct.setWidth(Ext.isStrict && (Ext.isIE7 || Ext.isIE8) ? 'auto' : ct.minWidth);
- var el = ct.getEl(), t = el.dom.offsetWidth;
- ct.setWidth(ct.getLayoutTarget().getWidth() + el.getFrameWidth('lr'));
- }
- }
- }
- });
- Ext.Container.LAYOUTS['menu'] = Ext.layout.MenuLayout;
- Ext.menu.Menu = Ext.extend(Ext.Container, {
- minWidth : 120,
- shadow : 'sides',
- subMenuAlign : 'tl-tr?',
- defaultAlign : 'tl-bl?',
- allowOtherMenus : false,
- ignoreParentClicks : false,
- enableScrolling : true,
- maxHeight : null,
- scrollIncrement : 24,
- showSeparator : true,
- defaultOffsets : [0, 0],
- plain : false,
- floating : true,
- hidden : true,
- layout : 'menu',
- hideMode : 'offsets',
- scrollerHeight : 8,
- autoLayout : true,
- defaultType : 'menuitem',
- bufferResize : false,
- initComponent : function(){
- if(Ext.isArray(this.initialConfig)){
- Ext.apply(this, {items:this.initialConfig});
- }
- this.addEvents(
- 'click',
- 'mouseover',
- 'mouseout',
- 'itemclick'
- );
- Ext.menu.MenuMgr.register(this);
- if(this.floating){
- Ext.EventManager.onWindowResize(this.hide, this);
- }else{
- if(this.initialConfig.hidden !== false){
- this.hidden = false;
- }
- this.internalDefaults = {hideOnClick: false};
- }
- Ext.menu.Menu.superclass.initComponent.call(this);
- if(this.autoLayout){
- this.on({
- add: this.doLayout,
- remove: this.doLayout,
- scope: this
- });
- }
- },
- getLayoutTarget : function() {
- return this.ul;
- },
- onRender : function(ct, position){
- if(!ct){
- ct = Ext.getBody();
- }
- var dh = {
- id: this.getId(),
- cls: 'x-menu ' + ((this.floating) ? 'x-menu-floating x-layer ' : '') + (this.cls || '') + (this.plain ? ' x-menu-plain' : '') + (this.showSeparator ? '' : ' x-menu-nosep'),
- style: this.style,
- cn: [
- {tag: 'a', cls: 'x-menu-focus', href: '#', onclick: 'return false;', tabIndex: '-1'},
- {tag: 'ul', cls: 'x-menu-list'}
- ]
- };
- if(this.floating){
- this.el = new Ext.Layer({
- shadow: this.shadow,
- dh: dh,
- constrain: false,
- parentEl: ct,
- zindex:15000
- });
- }else{
- this.el = ct.createChild(dh);
- }
- Ext.menu.Menu.superclass.onRender.call(this, ct, position);
- if(!this.keyNav){
- this.keyNav = new Ext.menu.MenuNav(this);
- }
- this.focusEl = this.el.child('a.x-menu-focus');
- this.ul = this.el.child('ul.x-menu-list');
- this.mon(this.ul, {
- scope: this,
- click: this.onClick,
- mouseover: this.onMouseOver,
- mouseout: this.onMouseOut
- });
- if(this.enableScrolling){
- this.mon(this.el, {
- scope: this,
- delegate: '.x-menu-scroller',
- click: this.onScroll,
- mouseover: this.deactivateActive
- });
- }
- },
- findTargetItem : function(e){
- var t = e.getTarget('.x-menu-list-item', this.ul, true);
- if(t && t.menuItemId){
- return this.items.get(t.menuItemId);
- }
- },
- onClick : function(e){
- var t = this.findTargetItem(e);
- if(t){
- if(t.isFormField){
- this.setActiveItem(t);
- }else if(t instanceof Ext.menu.BaseItem){
- if(t.menu && this.ignoreParentClicks){
- t.expandMenu();
- e.preventDefault();
- }else if(t.onClick){
- t.onClick(e);
- this.fireEvent('click', this, t, e);
- }
- }
- }
- },
- setActiveItem : function(item, autoExpand){
- if(item != this.activeItem){
- this.deactivateActive();
- if((this.activeItem = item).isFormField){
- item.focus();
- }else{
- item.activate(autoExpand);
- }
- }else if(autoExpand){
- item.expandMenu();
- }
- },
- deactivateActive : function(){
- var a = this.activeItem;
- if(a){
- if(a.isFormField){
- if(a.collapse){
- a.collapse();
- }
- }else{
- a.deactivate();
- }
- delete this.activeItem;
- }
- },
- tryActivate : function(start, step){
- var items = this.items;
- for(var i = start, len = items.length; i >= 0 && i < len; i+= step){
- var item = items.get(i);
- if(!item.disabled && (item.canActivate || item.isFormField)){
- this.setActiveItem(item, false);
- return item;
- }
- }
- return false;
- },
- onMouseOver : function(e){
- var t = this.findTargetItem(e);
- if(t){
- if(t.canActivate && !t.disabled){
- this.setActiveItem(t, true);
- }
- }
- this.over = true;
- this.fireEvent('mouseover', this, e, t);
- },
- onMouseOut : function(e){
- var t = this.findTargetItem(e);
- if(t){
- if(t == this.activeItem && t.shouldDeactivate && t.shouldDeactivate(e)){
- this.activeItem.deactivate();
- delete this.activeItem;
- }
- }
- this.over = false;
- this.fireEvent('mouseout', this, e, t);
- },
- onScroll : function(e, t){
- if(e){
- e.stopEvent();
- }
- var ul = this.ul.dom, top = Ext.fly(t).is('.x-menu-scroller-top');
- ul.scrollTop += this.scrollIncrement * (top ? -1 : 1);
- if(top ? ul.scrollTop <= 0 : ul.scrollTop + this.activeMax >= ul.scrollHeight){
- this.onScrollerOut(null, t);
- }
- },
- onScrollerIn : function(e, t){
- var ul = this.ul.dom, top = Ext.fly(t).is('.x-menu-scroller-top');
- if(top ? ul.scrollTop > 0 : ul.scrollTop + this.activeMax < ul.scrollHeight){
- Ext.fly(t).addClass(['x-menu-item-active', 'x-menu-scroller-active']);
- }
- },
- onScrollerOut : function(e, t){
- Ext.fly(t).removeClass(['x-menu-item-active', 'x-menu-scroller-active']);
- },
- show : function(el, pos, parentMenu){
- if(this.floating){
- this.parentMenu = parentMenu;
- if(!this.el){
- this.render();
- this.doLayout(false, true);
- }
- this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign, this.defaultOffsets), parentMenu);
- }else{
- Ext.menu.Menu.superclass.show.call(this);
- }
- },
- showAt : function(xy, parentMenu){
- if(this.fireEvent('beforeshow', this) !== false){
- this.parentMenu = parentMenu;
- if(!this.el){
- this.render();
- }
- if(this.enableScrolling){
- this.el.setXY(xy);
- this.constrainScroll(xy[1]);
- xy = [this.el.adjustForConstraints(xy)[0], xy[1]];
- }else{
- xy = this.el.adjustForConstraints(xy);
- }
- this.el.setXY(xy);
- this.el.show();
- Ext.menu.Menu.superclass.onShow.call(this);
- if(Ext.isIE){
- this.fireEvent('autosize', this);
- if(!Ext.isIE8){
- this.el.repaint();
- }
- }
- this.hidden = false;
- this.focus();
- this.fireEvent('show', this);
- }
- },
- constrainScroll : function(y){
- var max, full = this.ul.setHeight('auto').getHeight();
- if(this.floating){
- max = this.maxHeight ? this.maxHeight : Ext.fly(this.el.dom.parentNode).getViewSize(false).height - y;
- }else{
- max = this.getHeight();
- }
- if(full > max && max > 0){
- this.activeMax = max - this.scrollerHeight * 2 - this.el.getFrameWidth('tb') - Ext.num(this.el.shadowOffset, 0);
- this.ul.setHeight(this.activeMax);
- this.createScrollers();
- this.el.select('.x-menu-scroller').setDisplayed('');
- }else{
- this.ul.setHeight(full);
- this.el.select('.x-menu-scroller').setDisplayed('none');
- }
- this.ul.dom.scrollTop = 0;
- },
- createScrollers : function(){
- if(!this.scroller){
- this.scroller = {
- pos: 0,
- top: this.el.insertFirst({
- tag: 'div',
- cls: 'x-menu-scroller x-menu-scroller-top',
- html: ' '
- }),
- bottom: this.el.createChild({
- tag: 'div',
- cls: 'x-menu-scroller x-menu-scroller-bottom',
- html: ' '
- })
- };
- this.scroller.top.hover(this.onScrollerIn, this.onScrollerOut, this);
- this.scroller.topRepeater = new Ext.util.ClickRepeater(this.scroller.top, {
- listeners: {
- click: this.onScroll.createDelegate(this, [null, this.scroller.top], false)
- }
- });
- this.scroller.bottom.hover(this.onScrollerIn, this.onScrollerOut, this);
- this.scroller.bottomRepeater = new Ext.util.ClickRepeater(this.scroller.bottom, {
- listeners: {
- click: this.onScroll.createDelegate(this, [null, this.scroller.bottom], false)
- }
- });
- }
- },
- onLayout : function(){
- if(this.isVisible()){
- if(this.enableScrolling){
- this.constrainScroll(this.el.getTop());
- }
- if(this.floating){
- this.el.sync();
- }
- }
- },
- focus : function(){
- if(!this.hidden){
- this.doFocus.defer(50, this);
- }
- },
- doFocus : function(){
- if(!this.hidden){
- this.focusEl.focus();
- }
- },
- hide : function(deep){
- this.deepHide = deep;
- Ext.menu.Menu.superclass.hide.call(this);
- delete this.deepHide;
- },
- onHide : function(){
- Ext.menu.Menu.superclass.onHide.call(this);
- this.deactivateActive();
- if(this.el && this.floating){
- this.el.hide();
- }
- var pm = this.parentMenu;
- if(this.deepHide === true && pm){
- if(pm.floating){
- pm.hide(true);
- }else{
- pm.deactivateActive();
- }
- }
- },
- lookupComponent : function(c){
- if(Ext.isString(c)){
- c = (c == 'separator' || c == '-') ? new Ext.menu.Separator() : new Ext.menu.TextItem(c);
- this.applyDefaults(c);
- }else{
- if(Ext.isObject(c)){
- c = this.getMenuItem(c);
- }else if(c.tagName || c.el){
- c = new Ext.BoxComponent({
- el: c
- });
- }
- }
- return c;
- },
- applyDefaults : function(c){
- if(!Ext.isString(c)){
- c = Ext.menu.Menu.superclass.applyDefaults.call(this, c);
- var d = this.internalDefaults;
- if(d){
- if(c.events){
- Ext.applyIf(c.initialConfig, d);
- Ext.apply(c, d);
- }else{
- Ext.applyIf(c, d);
- }
- }
- }
- return c;
- },
- getMenuItem : function(config){
- if(!config.isXType){
- if(!config.xtype && Ext.isBoolean(config.checked)){
- return new Ext.menu.CheckItem(config)
- }
- return Ext.create(config, this.defaultType);
- }
- return config;
- },
- addSeparator : function(){
- return this.add(new Ext.menu.Separator());
- },
- addElement : function(el){
- return this.add(new Ext.menu.BaseItem(el));
- },
- addItem : function(item){
- return this.add(item);
- },
- addMenuItem : function(config){
- return this.add(this.getMenuItem(config));
- },
- addText : function(text){
- return this.add(new Ext.menu.TextItem(text));
- },
- onDestroy : function(){
- var pm = this.parentMenu;
- if(pm && pm.activeChild == this){
- delete pm.activeChild;
- }
- delete this.parentMenu;
- Ext.menu.Menu.superclass.onDestroy.call(this);
- Ext.menu.MenuMgr.unregister(this);
- Ext.EventManager.removeResizeListener(this.hide, this);
- if(this.keyNav) {
- this.keyNav.disable();
- }
- var s = this.scroller;
- if(s){
- Ext.destroy(s.topRepeater, s.bottomRepeater, s.top, s.bottom);
- }
- Ext.destroy(
- this.el,
- this.focusEl,
- this.ul
- );
- }
- });
- Ext.reg('menu', Ext.menu.Menu);
- Ext.menu.MenuNav = Ext.extend(Ext.KeyNav, function(){
- function up(e, m){
- if(!m.tryActivate(m.items.indexOf(m.activeItem)-1, -1)){
- m.tryActivate(m.items.length-1, -1);
- }
- }
- function down(e, m){
- if(!m.tryActivate(m.items.indexOf(m.activeItem)+1, 1)){
- m.tryActivate(0, 1);
- }
- }
- return {
- constructor : function(menu){
- Ext.menu.MenuNav.superclass.constructor.call(this, menu.el);
- this.scope = this.menu = menu;
- },
- doRelay : function(e, h){
- var k = e.getKey();
- if (this.menu.activeItem && this.menu.activeItem.isFormField && k != e.TAB) {
- return false;
- }
- if(!this.menu.activeItem && e.isNavKeyPress() && k != e.SPACE && k != e.RETURN){
- this.menu.tryActivate(0, 1);
- return false;
- }
- return h.call(this.scope || this, e, this.menu);
- },
- tab: function(e, m) {
- e.stopEvent();
- if (e.shiftKey) {
- up(e, m);
- } else {
- down(e, m);
- }
- },
- up : up,
- down : down,
- right : function(e, m){
- if(m.activeItem){
- m.activeItem.expandMenu(true);
- }
- },
- left : function(e, m){
- m.hide();
- if(m.parentMenu && m.parentMenu.activeItem){
- m.parentMenu.activeItem.activate();
- }
- },
- enter : function(e, m){
- if(m.activeItem){
- e.stopPropagation();
- m.activeItem.onClick(e);
- m.fireEvent('click', this, m.activeItem);
- return true;
- }
- }
- };
- }());
- Ext.menu.MenuMgr = function(){
- var menus, active, groups = {}, attached = false, lastShow = new Date();
- function init(){
- menus = {};
- active = new Ext.util.MixedCollection();
- Ext.getDoc().addKeyListener(27, function(){
- if(active.length > 0){
- hideAll();
- }
- });
- }
- function hideAll(){
- if(active && active.length > 0){
- var c = active.clone();
- c.each(function(m){
- m.hide();
- });
- return true;
- }
- return false;
- }
- function onHide(m){
- active.remove(m);
- if(active.length < 1){
- Ext.getDoc().un("mousedown", onMouseDown);
- attached = false;
- }
- }
- function onShow(m){
- var last = active.last();
- lastShow = new Date();
- active.add(m);
- if(!attached){
- Ext.getDoc().on("mousedown", onMouseDown);
- attached = true;
- }
- if(m.parentMenu){
- m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
- m.parentMenu.activeChild = m;
- }else if(last && last.isVisible()){
- m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
- }
- }
- function onBeforeHide(m){
- if(m.activeChild){
- m.activeChild.hide();
- }
- if(m.autoHideTimer){
- clearTimeout(m.autoHideTimer);
- delete m.autoHideTimer;
- }
- }
- function onBeforeShow(m){
- var pm = m.parentMenu;
- if(!pm && !m.allowOtherMenus){
- hideAll();
- }else if(pm && pm.activeChild){
- pm.activeChild.hide();
- }
- }
- function onMouseDown(e){
- if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".x-menu")){
- hideAll();
- }
- }
- function onBeforeCheck(mi, state){
- if(state){
- var g = groups[mi.group];
- for(var i = 0, l = g.length; i < l; i++){
- if(g[i] != mi){
- g[i].setChecked(false);
- }
- }
- }
- }
- return {
- hideAll : function(){
- return hideAll();
- },
- register : function(menu){
- if(!menus){
- init();
- }
- menus[menu.id] = menu;
- menu.on({
- beforehide: onBeforeHide,
- hide: onHide,
- beforeshow: onBeforeShow,
- show: onShow
- });
- },
- get : function(menu){
- if(typeof menu == "string"){
- if(!menus){
- return null;
- }
- return menus[menu];
- }else if(menu.events){
- return menu;
- }else if(typeof menu.length == 'number'){
- return new Ext.menu.Menu({items:menu});
- }else{
- return Ext.create(menu, 'menu');
- }
- },
- unregister : function(menu){
- delete menus[menu.id];
- menu.un("beforehide", onBeforeHide);
- menu.un("hide", onHide);
- menu.un("beforeshow", onBeforeShow);
- menu.un("show", onShow);
- },
- registerCheckable : function(menuItem){
- var g = menuItem.group;
- if(g){
- if(!groups[g]){
- groups[g] = [];
- }
- groups[g].push(menuItem);
- menuItem.on("beforecheckchange", onBeforeCheck);
- }
- },
- unregisterCheckable : function(menuItem){
- var g = menuItem.group;
- if(g){
- groups[g].remove(menuItem);
- menuItem.un("beforecheckchange", onBeforeCheck);
- }
- },
- getCheckedItem : function(groupId){
- var g = groups[groupId];
- if(g){
- for(var i = 0, l = g.length; i < l; i++){
- if(g[i].checked){
- return g[i];
- }
- }
- }
- return null;
- },
- setCheckedItem : function(groupId, itemId){
- var g = groups[groupId];
- if(g){
- for(var i = 0, l = g.length; i < l; i++){
- if(g[i].id == itemId){
- g[i].setChecked(true);
- }
- }
- }
- return null;
- }
- };
- }();
- Ext.menu.BaseItem = Ext.extend(Ext.Component, {
- canActivate : false,
- activeClass : "x-menu-item-active",
- hideOnClick : true,
- clickHideDelay : 1,
- ctype : "Ext.menu.BaseItem",
- actionMode : "container",
- initComponent : function(){
- Ext.menu.BaseItem.superclass.initComponent.call(this);
- this.addEvents(
- 'click',
- 'activate',
- 'deactivate'
- );
- if(this.handler){
- this.on("click", this.handler, this.scope);
- }
- },
- onRender : function(container, position){
- Ext.menu.BaseItem.superclass.onRender.apply(this, arguments);
- if(this.ownerCt && this.ownerCt instanceof Ext.menu.Menu){
- this.parentMenu = this.ownerCt;
- }else{
- this.container.addClass('x-menu-list-item');
- this.mon(this.el, {
- scope: this,
- click: this.onClick,
- mouseenter: this.activate,
- mouseleave: this.deactivate
- });
- }
- },
- setHandler : function(handler, scope){
- if(this.handler){
- this.un("click", this.handler, this.scope);
- }
- this.on("click", this.handler = handler, this.scope = scope);
- },
- onClick : function(e){
- if(!this.disabled && this.fireEvent("click", this, e) !== false
- && (this.parentMenu && this.parentMenu.fireEvent("itemclick", this, e) !== false)){
- this.handleClick(e);
- }else{
- e.stopEvent();
- }
- },
- activate : function(){
- if(this.disabled){
- return false;
- }
- var li = this.container;
- li.addClass(this.activeClass);
- this.region = li.getRegion().adjust(2, 2, -2, -2);
- this.fireEvent("activate", this);
- return true;
- },
- deactivate : function(){
- this.container.removeClass(this.activeClass);
- this.fireEvent("deactivate", this);
- },
- shouldDeactivate : function(e){
- return !this.region || !this.region.contains(e.getPoint());
- },
- handleClick : function(e){
- var pm = this.parentMenu;
- if(this.hideOnClick){
- if(pm.floating){
- pm.hide.defer(this.clickHideDelay, pm, [true]);
- }else{
- pm.deactivateActive();
- }
- }
- },
- expandMenu : Ext.emptyFn,
- hideMenu : Ext.emptyFn
- });
- Ext.reg('menubaseitem', Ext.menu.BaseItem);
- Ext.menu.TextItem = Ext.extend(Ext.menu.BaseItem, {
- hideOnClick : false,
- itemCls : "x-menu-text",
- constructor : function(config){
- if(typeof config == 'string'){
- config = {text: config}
- }
- Ext.menu.TextItem.superclass.constructor.call(this, config);
- },
- onRender : function(){
- var s = document.createElement("span");
- s.className = this.itemCls;
- s.innerHTML = this.text;
- this.el = s;
- Ext.menu.TextItem.superclass.onRender.apply(this, arguments);
- }
- });
- Ext.reg('menutextitem', Ext.menu.TextItem);
- Ext.menu.Separator = Ext.extend(Ext.menu.BaseItem, {
- itemCls : "x-menu-sep",
- hideOnClick : false,
- activeClass: '',
- onRender : function(li){
- var s = document.createElement("span");
- s.className = this.itemCls;
- s.innerHTML = " ";
- this.el = s;
- li.addClass("x-menu-sep-li");
- Ext.menu.Separator.superclass.onRender.apply(this, arguments);
- }
- });
- Ext.reg('menuseparator', Ext.menu.Separator);
- Ext.menu.Item = Ext.extend(Ext.menu.BaseItem, {
- itemCls : 'x-menu-item',
- canActivate : true,
- showDelay: 200,
- hideDelay: 200,
- ctype: 'Ext.menu.Item',
- initComponent : function(){
- Ext.menu.Item.superclass.initComponent.call(this);
- if(this.menu){
- this.menu = Ext.menu.MenuMgr.get(this.menu);
- this.menu.ownerCt = this;
- }
- },
- onRender : function(container, position){
- if (!this.itemTpl) {
- this.itemTpl = Ext.menu.Item.prototype.itemTpl = new Ext.XTemplate(
- '<a id="{id}" class="{cls}" hidefocus="true" unselectable="on" href="{href}"',
- '<tpl if="hrefTarget">',
- ' target="{hrefTarget}"',
- '</tpl>',
- '>',
- '<img src="{icon}" class="x-menu-item-icon {iconCls}"/>',
- '<span class="x-menu-item-text">{text}</span>',
- '</a>'
- );
- }
- var a = this.getTemplateArgs();
- this.el = position ? this.itemTpl.insertBefore(position, a, true) : this.itemTpl.append(container, a, true);
- this.iconEl = this.el.child('img.x-menu-item-icon');
- this.textEl = this.el.child('.x-menu-item-text');
- if(!this.href) {
- this.mon(this.el, 'click', Ext.emptyFn, null, { preventDefault: true });
- }
- Ext.menu.Item.superclass.onRender.call(this, container, position);
- },
- getTemplateArgs: function() {
- return {
- id: this.id,
- cls: this.itemCls + (this.menu ? ' x-menu-item-arrow' : '') + (this.cls ? ' ' + this.cls : ''),
- href: this.href || '#',
- hrefTarget: this.hrefTarget,
- icon: this.icon || Ext.BLANK_IMAGE_URL,
- iconCls: this.iconCls || '',
- text: this.itemText||this.text||' '
- };
- },
- setText : function(text){
- this.text = text||' ';
- if(this.rendered){
- this.textEl.update(this.text);
- this.parentMenu.layout.doAutoSize();
- }
- },
- setIconClass : function(cls){
- var oldCls = this.iconCls;
- this.iconCls = cls;
- if(this.rendered){
- this.iconEl.replaceClass(oldCls, this.iconCls);
- }
- },
- beforeDestroy: function(){
- if (this.menu){
- delete this.menu.ownerCt;
- this.menu.destroy();
- }
- Ext.menu.Item.superclass.beforeDestroy.call(this);
- },
- handleClick : function(e){
- if(!this.href){
- e.stopEvent();
- }
- Ext.menu.Item.superclass.handleClick.apply(this, arguments);
- },
- activate : function(autoExpand){
- if(Ext.menu.Item.superclass.activate.apply(this, arguments)){
- this.focus();
- if(autoExpand){
- this.expandMenu();
- }
- }
- return true;
- },
- shouldDeactivate : function(e){
- if(Ext.menu.Item.superclass.shouldDeactivate.call(this, e)){
- if(this.menu && this.menu.isVisible()){
- return !this.menu.getEl().getRegion().contains(e.getPoint());
- }
- return true;
- }
- return false;
- },
- deactivate : function(){
- Ext.menu.Item.superclass.deactivate.apply(this, arguments);
- this.hideMenu();
- },
- expandMenu : function(autoActivate){
- if(!this.disabled && this.menu){
- clearTimeout(this.hideTimer);
- delete this.hideTimer;
- if(!this.menu.isVisible() && !this.showTimer){
- this.showTimer = this.deferExpand.defer(this.showDelay, this, [autoActivate]);
- }else if (this.menu.isVisible() && autoActivate){
- this.menu.tryActivate(0, 1);
- }
- }
- },
- deferExpand : function(autoActivate){
- delete this.showTimer;
- this.menu.show(this.container, this.parentMenu.subMenuAlign || 'tl-tr?', this.parentMenu);
- if(autoActivate){
- this.menu.tryActivate(0, 1);
- }
- },
- hideMenu : function(){
- clearTimeout(this.showTimer);
- delete this.showTimer;
- if(!this.hideTimer && this.menu && this.menu.isVisible()){
- this.hideTimer = this.deferHide.defer(this.hideDelay, this);
- }
- },
- deferHide : function(){
- delete this.hideTimer;
- if(this.menu.over){
- this.parentMenu.setActiveItem(this, false);
- }else{
- this.menu.hide();
- }
- }
- });
- Ext.reg('menuitem', Ext.menu.Item);
- Ext.menu.CheckItem = Ext.extend(Ext.menu.Item, {
- itemCls : "x-menu-item x-menu-check-item",
- groupClass : "x-menu-group-item",
- checked: false,
- ctype: "Ext.menu.CheckItem",
- initComponent : function(){
- Ext.menu.CheckItem.superclass.initComponent.call(this);
- this.addEvents(
- "beforecheckchange" ,
- "checkchange"
- );
- if(this.checkHandler){
- this.on('checkchange', this.checkHandler, this.scope);
- }
- Ext.menu.MenuMgr.registerCheckable(this);
- },
- onRender : function(c){
- Ext.menu.CheckItem.superclass.onRender.apply(this, arguments);
- if(this.group){
- this.el.addClass(this.groupClass);
- }
- if(this.checked){
- this.checked = false;
- this.setChecked(true, true);
- }
- },
- destroy : function(){
- Ext.menu.MenuMgr.unregisterCheckable(this);
- Ext.menu.CheckItem.superclass.destroy.apply(this, arguments);
- },
- setChecked : function(state, suppressEvent){
- if(this.checked != state && this.fireEvent("beforecheckchange", this, state) !== false){
- if(this.container){
- this.container[state ? "addClass" : "removeClass"]("x-menu-item-checked");
- }
- this.checked = state;
- if(suppressEvent !== true){
- this.fireEvent("checkchange", this, state);
- }
- }
- },
- handleClick : function(e){
- if(!this.disabled && !(this.checked && this.group)){
- this.setChecked(!this.checked);
- }
- Ext.menu.CheckItem.superclass.handleClick.apply(this, arguments);
- }
- });
- Ext.reg('menucheckitem', Ext.menu.CheckItem);
- Ext.menu.DateMenu = Ext.extend(Ext.menu.Menu, {
- enableScrolling : false,
- hideOnClick : true,
- pickerId : null,
- cls : 'x-date-menu',
- initComponent : function(){
- this.on('beforeshow', this.onBeforeShow, this);
- if(this.strict = (Ext.isIE7 && Ext.isStrict)){
- this.on('show', this.onShow, this, {single: true, delay: 20});
- }
- Ext.apply(this, {
- plain: true,
- showSeparator: false,
- items: this.picker = new Ext.DatePicker(Ext.applyIf({
- internalRender: this.strict || !Ext.isIE,
- ctCls: 'x-menu-date-item',
- id: this.pickerId
- }, this.initialConfig))
- });
- this.picker.purgeListeners();
- Ext.menu.DateMenu.superclass.initComponent.call(this);
- this.relayEvents(this.picker, ['select']);
- this.on('show', this.picker.focus, this.picker);
- this.on('select', this.menuHide, this);
- if(this.handler){
- this.on('select', this.handler, this.scope || this);
- }
- },
- menuHide : function() {
- if(this.hideOnClick){
- this.hide(true);
- }
- },
- onBeforeShow : function(){
- if(this.picker){
- this.picker.hideMonthPicker(true);
- }
- },
- onShow : function(){
- var el = this.picker.getEl();
- el.setWidth(el.getWidth());
- }
- });
- Ext.reg('datemenu', Ext.menu.DateMenu);
- Ext.menu.ColorMenu = Ext.extend(Ext.menu.Menu, {
- enableScrolling : false,
- hideOnClick : true,
- cls : 'x-color-menu',
- paletteId : null,
- initComponent : function(){
- Ext.apply(this, {
- plain: true,
- showSeparator: false,
- items: this.palette = new Ext.ColorPalette(Ext.applyIf({
- id: this.paletteId
- }, this.initialConfig))
- });
- this.palette.purgeListeners();
- Ext.menu.ColorMenu.superclass.initComponent.call(this);
- this.relayEvents(this.palette, ['select']);
- this.on('select', this.menuHide, this);
- if(this.handler){
- this.on('select', this.handler, this.scope || this);
- }
- },
- menuHide : function(){
- if(this.hideOnClick){
- this.hide(true);
- }
- }
- });
- Ext.reg('colormenu', Ext.menu.ColorMenu);
- Ext.form.Field = Ext.extend(Ext.BoxComponent, {
- invalidClass : 'x-form-invalid',
- invalidText : 'The value in this field is invalid',
- focusClass : 'x-form-focus',
- validationEvent : 'keyup',
- validateOnBlur : true,
- validationDelay : 250,
- defaultAutoCreate : {tag: 'input', type: 'text', size: '20', autocomplete: 'off'},
- fieldClass : 'x-form-field',
- msgTarget : 'qtip',
- msgFx : 'normal',
- readOnly : false,
- disabled : false,
- submitValue: true,
- isFormField : true,
- msgDisplay: '',
- hasFocus : false,
- initComponent : function(){
- Ext.form.Field.superclass.initComponent.call(this);
- this.addEvents(
- 'focus',
- 'blur',
- 'specialkey',
- 'change',
- 'invalid',
- 'valid'
- );
- },
- getName : function(){
- return this.rendered && this.el.dom.name ? this.el.dom.name : this.name || this.id || '';
- },
- onRender : function(ct, position){
- if(!this.el){
- var cfg = this.getAutoCreate();
- if(!cfg.name){
- cfg.name = this.name || this.id;
- }
- if(this.inputType){
- cfg.type = this.inputType;
- }
- this.autoEl = cfg;
- }
- Ext.form.Field.superclass.onRender.call(this, ct, position);
- if(this.submitValue === false){
- this.el.dom.removeAttribute('name');
- }
- var type = this.el.dom.type;
- if(type){
- if(type == 'password'){
- type = 'text';
- }
- this.el.addClass('x-form-'+type);
- }
- if(this.readOnly){
- this.setReadOnly(true);
- }
- if(this.tabIndex !== undefined){
- this.el.dom.setAttribute('tabIndex', this.tabIndex);
- }
- this.el.addClass([this.fieldClass, this.cls]);
- },
- getItemCt : function(){
- return this.itemCt;
- },
- initValue : function(){
- if(this.value !== undefined){
- this.setValue(this.value);
- }else if(!Ext.isEmpty(this.el.dom.value) && this.el.dom.value != this.emptyText){
- this.setValue(this.el.dom.value);
- }
- this.originalValue = this.getValue();
- },
- isDirty : function() {
- if(this.disabled || !this.rendered) {
- return false;
- }
- return String(this.getValue()) !== String(this.originalValue);
- },
- setReadOnly : function(readOnly){
- if(this.rendered){
- this.el.dom.readOnly = readOnly;
- }
- this.readOnly = readOnly;
- },
- afterRender : function(){
- Ext.form.Field.superclass.afterRender.call(this);
- this.initEvents();
- this.initValue();
- },
- fireKey : function(e){
- if(e.isSpecialKey()){
- this.fireEvent('specialkey', this, e);
- }
- },
- reset : function(){
- this.setValue(this.originalValue);
- this.clearInvalid();
- },
- initEvents : function(){
- this.mon(this.el, Ext.EventManager.useKeydown ? 'keydown' : 'keypress', this.fireKey, this);
- this.mon(this.el, 'focus', this.onFocus, this);
- this.mon(this.el, 'blur', this.onBlur, this, this.inEditor ? {buffer:10} : null);
- },
- preFocus: Ext.emptyFn,
- onFocus : function(){
- this.preFocus();
- if(this.focusClass){
- this.el.addClass(this.focusClass);
- }
- if(!this.hasFocus){
- this.hasFocus = true;
- this.startValue = this.getValue();
- this.fireEvent('focus', this);
- }
- },
- beforeBlur : Ext.emptyFn,
- onBlur : function(){
- this.beforeBlur();
- if(this.focusClass){
- this.el.removeClass(this.focusClass);
- }
- this.hasFocus = false;
- if(this.validationEvent !== false && (this.validateOnBlur || this.validationEvent == 'blur')){
- this.validate();
- }
- var v = this.getValue();
- if(String(v) !== String(this.startValue)){
- this.fireEvent('change', this, v, this.startValue);
- }
- this.fireEvent('blur', this);
- this.postBlur();
- },
- postBlur : Ext.emptyFn,
- isValid : function(preventMark){
- if(this.disabled){
- return true;
- }
- var restore = this.preventMark;
- this.preventMark = preventMark === true;
- var v = this.validateValue(this.processValue(this.getRawValue()));
- this.preventMark = restore;
- return v;
- },
- validate : function(){
- if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
- this.clearInvalid();
- return true;
- }
- return false;
- },
- processValue : function(value){
- return value;
- },
- validateValue : function(value){
- return true;
- },
- getActiveError : function(){
- return this.activeError || '';
- },
- markInvalid : function(msg){
- if(!this.rendered || this.preventMark){
- return;
- }
- msg = msg || this.invalidText;
- var mt = this.getMessageHandler();
- if(mt){
- mt.mark(this, msg);
- }else if(this.msgTarget){
- this.el.addClass(this.invalidClass);
- var t = Ext.getDom(this.msgTarget);
- if(t){
- t.innerHTML = msg;
- t.style.display = this.msgDisplay;
- }
- }
- this.activeError = msg;
- this.fireEvent('invalid', this, msg);
- },
- clearInvalid : function(){
- if(!this.rendered || this.preventMark){
- return;
- }
- this.el.removeClass(this.invalidClass);
- var mt = this.getMessageHandler();
- if(mt){
- mt.clear(this);
- }else if(this.msgTarget){
- this.el.removeClass(this.invalidClass);
- var t = Ext.getDom(this.msgTarget);
- if(t){
- t.innerHTML = '';
- t.style.display = 'none';
- }
- }
- delete this.activeError;
- this.fireEvent('valid', this);
- },
- getMessageHandler : function(){
- return Ext.form.MessageTargets[this.msgTarget];
- },
- getErrorCt : function(){
- return this.el.findParent('.x-form-element', 5, true) ||
- this.el.findParent('.x-form-field-wrap', 5, true);
- },
- alignErrorIcon : function(){
- this.errorIcon.alignTo(this.el, 'tl-tr', [2, 0]);
- },
- getRawValue : function(){
- var v = this.rendered ? this.el.getValue() : Ext.value(this.value, '');
- if(v === this.emptyText){
- v = '';
- }
- return v;
- },
- getValue : function(){
- if(!this.rendered) {
- return this.value;
- }
- var v = this.el.getValue();
- if(v === this.emptyText || v === undefined){
- v = '';
- }
- return v;
- },
- setRawValue : function(v){
- return this.rendered ? (this.el.dom.value = (Ext.isEmpty(v) ? '' : v)) : '';
- },
- setValue : function(v){
- this.value = v;
- if(this.rendered){
- this.el.dom.value = (Ext.isEmpty(v) ? '' : v);
- this.validate();
- }
- return this;
- },
- append : function(v){
- this.setValue([this.getValue(), v].join(''));
- }
- });
- Ext.form.MessageTargets = {
- 'qtip' : {
- mark: function(field, msg){
- field.el.addClass(field.invalidClass);
- field.el.dom.qtip = msg;
- field.el.dom.qclass = 'x-form-invalid-tip';
- if(Ext.QuickTips){
- Ext.QuickTips.enable();
- }
- },
- clear: function(field){
- field.el.removeClass(field.invalidClass);
- field.el.dom.qtip = '';
- }
- },
- 'title' : {
- mark: function(field, msg){
- field.el.addClass(field.invalidClass);
- field.el.dom.title = msg;
- },
- clear: function(field){
- field.el.dom.title = '';
- }
- },
- 'under' : {
- mark: function(field, msg){
- field.el.addClass(field.invalidClass);
- if(!field.errorEl){
- var elp = field.getErrorCt();
- if(!elp){
- field.el.dom.title = msg;
- return;
- }
- field.errorEl = elp.createChild({cls:'x-form-invalid-msg'});
- field.errorEl.setWidth(elp.getWidth(true)-20);
- }
- field.errorEl.update(msg);
- Ext.form.Field.msgFx[field.msgFx].show(field.errorEl, field);
- },
- clear: function(field){
- field.el.removeClass(field.invalidClass);
- if(field.errorEl){
- Ext.form.Field.msgFx[field.msgFx].hide(field.errorEl, field);
- }else{
- field.el.dom.title = '';
- }
- }
- },
- 'side' : {
- mark: function(field, msg){
- field.el.addClass(field.invalidClass);
- if(!field.errorIcon){
- var elp = field.getErrorCt();
- if(!elp){
- field.el.dom.title = msg;
- return;
- }
- field.errorIcon = elp.createChild({cls:'x-form-invalid-icon'});
- }
- field.alignErrorIcon();
- field.errorIcon.dom.qtip = msg;
- field.errorIcon.dom.qclass = 'x-form-invalid-tip';
- field.errorIcon.show();
- field.on('resize', field.alignErrorIcon, field);
- },
- clear: function(field){
- field.el.removeClass(field.invalidClass);
- if(field.errorIcon){
- field.errorIcon.dom.qtip = '';
- field.errorIcon.hide();
- field.un('resize', field.alignErrorIcon, field);
- }else{
- field.el.dom.title = '';
- }
- }
- }
- };
- Ext.form.Field.msgFx = {
- normal : {
- show: function(msgEl, f){
- msgEl.setDisplayed('block');
- },
- hide : function(msgEl, f){
- msgEl.setDisplayed(false).update('');
- }
- },
- slide : {
- show: function(msgEl, f){
- msgEl.slideIn('t', {stopFx:true});
- },
- hide : function(msgEl, f){
- msgEl.slideOut('t', {stopFx:true,useDisplay:true});
- }
- },
- slideRight : {
- show: function(msgEl, f){
- msgEl.fixDisplay();
- msgEl.alignTo(f.el, 'tl-tr');
- msgEl.slideIn('l', {stopFx:true});
- },
- hide : function(msgEl, f){
- msgEl.slideOut('l', {stopFx:true,useDisplay:true});
- }
- }
- };
- Ext.reg('field', Ext.form.Field);
- Ext.form.TextField = Ext.extend(Ext.form.Field, {
- grow : false,
- growMin : 30,
- growMax : 800,
- vtype : null,
- maskRe : null,
- disableKeyFilter : false,
- allowBlank : true,
- minLength : 0,
- maxLength : Number.MAX_VALUE,
- minLengthText : 'The minimum length for this field is {0}',
- maxLengthText : 'The maximum length for this field is {0}',
- selectOnFocus : false,
- blankText : 'This field is required',
- validator : null,
- regex : null,
- regexText : '',
- emptyText : null,
- emptyClass : 'x-form-empty-field',
- initComponent : function(){
- Ext.form.TextField.superclass.initComponent.call(this);
- this.addEvents(
- 'autosize',
- 'keydown',
- 'keyup',
- 'keypress'
- );
- },
- initEvents : function(){
- Ext.form.TextField.superclass.initEvents.call(this);
- if(this.validationEvent == 'keyup'){
- this.validationTask = new Ext.util.DelayedTask(this.validate, this);
- this.mon(this.el, 'keyup', this.filterValidation, this);
- }
- else if(this.validationEvent !== false && this.validationEvent != 'blur'){
- this.mon(this.el, this.validationEvent, this.validate, this, {buffer: this.validationDelay});
- }
- if(this.selectOnFocus || this.emptyText){
- this.mon(this.el, 'mousedown', this.onMouseDown, this);
- if(this.emptyText){
- this.applyEmptyText();
- }
- }
- if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Ext.form.VTypes[this.vtype+'Mask']))){
- this.mon(this.el, 'keypress', this.filterKeys, this);
- }
- if(this.grow){
- this.mon(this.el, 'keyup', this.onKeyUpBuffered, this, {buffer: 50});
- this.mon(this.el, 'click', this.autoSize, this);
- }
- if(this.enableKeyEvents){
- this.mon(this.el, {
- scope: this,
- keyup: this.onKeyUp,
- keydown: this.onKeyDown,
- keypress: this.onKeyPress
- });
- }
- },
- onMouseDown: function(e){
- if(!this.hasFocus){
- this.mon(this.el, 'mouseup', Ext.emptyFn, this, { single: true, preventDefault: true });
- }
- },
- processValue : function(value){
- if(this.stripCharsRe){
- var newValue = value.replace(this.stripCharsRe, '');
- if(newValue !== value){
- this.setRawValue(newValue);
- return newValue;
- }
- }
- return value;
- },
- filterValidation : function(e){
- if(!e.isNavKeyPress()){
- this.validationTask.delay(this.validationDelay);
- }
- },
- onDisable: function(){
- Ext.form.TextField.superclass.onDisable.call(this);
- if(Ext.isIE){
- this.el.dom.unselectable = 'on';
- }
- },
- onEnable: function(){
- Ext.form.TextField.superclass.onEnable.call(this);
- if(Ext.isIE){
- this.el.dom.unselectable = '';
- }
- },
- onKeyUpBuffered : function(e){
- if(this.doAutoSize(e)){
- this.autoSize();
- }
- },
- doAutoSize : function(e){
- return !e.isNavKeyPress();
- },
- onKeyUp : function(e){
- this.fireEvent('keyup', this, e);
- },
- onKeyDown : function(e){
- this.fireEvent('keydown', this, e);
- },
- onKeyPress : function(e){
- this.fireEvent('keypress', this, e);
- },
- reset : function(){
- Ext.form.TextField.superclass.reset.call(this);
- this.applyEmptyText();
- },
- applyEmptyText : function(){
- if(this.rendered && this.emptyText && this.getRawValue().length < 1 && !this.hasFocus){
- this.setRawValue(this.emptyText);
- this.el.addClass(this.emptyClass);
- }
- },
- preFocus : function(){
- var el = this.el;
- if(this.emptyText){
- if(el.dom.value == this.emptyText){
- this.setRawValue('');
- }
- el.removeClass(this.emptyClass);
- }
- if(this.selectOnFocus){
- el.dom.select();
- }
- },
- postBlur : function(){
- this.applyEmptyText();
- },
- filterKeys : function(e){
- if(e.ctrlKey){
- return;
- }
- var k = e.getKey();
- if(Ext.isGecko && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
- return;
- }
- var cc = String.fromCharCode(e.getCharCode());
- if(!Ext.isGecko && e.isSpecialKey() && !cc){
- return;
- }
- if(!this.maskRe.test(cc)){
- e.stopEvent();
- }
- },
- setValue : function(v){
- if(this.emptyText && this.el && !Ext.isEmpty(v)){
- this.el.removeClass(this.emptyClass);
- }
- Ext.form.TextField.superclass.setValue.apply(this, arguments);
- this.applyEmptyText();
- this.autoSize();
- return this;
- },
- validateValue : function(value){
- if(Ext.isFunction(this.validator)){
- var msg = this.validator(value);
- if(msg !== true){
- this.markInvalid(msg);
- return false;
- }
- }
- if(value.length < 1 || value === this.emptyText){
- if(this.allowBlank){
- this.clearInvalid();
- return true;
- }else{
- this.markInvalid(this.blankText);
- return false;
- }
- }
- if(value.length < this.minLength){
- this.markInvalid(String.format(this.minLengthText, this.minLength));
- return false;
- }
- if(value.length > this.maxLength){
- this.markInvalid(String.format(this.maxLengthText, this.maxLength));
- return false;
- }
- if(this.vtype){
- var vt = Ext.form.VTypes;
- if(!vt[this.vtype](value, this)){
- this.markInvalid(this.vtypeText || vt[this.vtype +'Text']);
- return false;
- }
- }
- if(this.regex && !this.regex.test(value)){
- this.markInvalid(this.regexText);
- return false;
- }
- return true;
- },
- selectText : function(start, end){
- var v = this.getRawValue();
- var doFocus = false;
- if(v.length > 0){
- start = start === undefined ? 0 : start;
- end = end === undefined ? v.length : end;
- var d = this.el.dom;
- if(d.setSelectionRange){
- d.setSelectionRange(start, end);
- }else if(d.createTextRange){
- var range = d.createTextRange();
- range.moveStart('character', start);
- range.moveEnd('character', end-v.length);
- range.select();
- }
- doFocus = Ext.isGecko || Ext.isOpera;
- }else{
- doFocus = true;
- }
- if(doFocus){