ext-all-debug.js
上传用户:chliyg
上传日期:2016-05-15
资源大小:3196k
文件大小:951k
源码类别:

Jsp/Servlet

开发平台:

Java

  1.                         buf.unshift('<img src="'+this.emptyIcon+'" class="x-tree-elbow-line" />');
  2.                     } else {
  3.                         buf.unshift('<img src="'+this.emptyIcon+'" class="x-tree-icon" />');
  4.                     }
  5.                 }
  6.                 p = p.parentNode;
  7.             }
  8.             this.childIndent = buf.join("");
  9.         }
  10.         return this.childIndent;
  11.     },
  12.          renderIndent : function(){
  13.         if(this.rendered){
  14.             var indent = "";
  15.             var p = this.node.parentNode;
  16.             if(p){
  17.                 indent = p.ui.getChildIndent();
  18.             }
  19.             if(this.indentMarkup != indent){                  this.indentNode.innerHTML = indent;
  20.                 this.indentMarkup = indent;
  21.             }
  22.             this.updateExpandIcon();
  23.         }
  24.     },
  25.     destroy : function(){
  26.         if(this.elNode){
  27.             Ext.dd.Registry.unregister(this.elNode.id);
  28.         }
  29.         delete this.elNode;
  30.         delete this.ctNode;
  31.         delete this.indentNode;
  32.         delete this.ecNode;
  33.         delete this.iconNode;
  34.         delete this.checkbox;
  35.         delete this.anchor;
  36.         delete this.textNode;
  37.         Ext.removeNode(this.ctNode);
  38.     }
  39. };
  40. Ext.tree.RootTreeNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
  41.          render : function(){
  42.         if(!this.rendered){
  43.             var targetNode = this.node.ownerTree.innerCt.dom;
  44.             this.node.expanded = true;
  45.             targetNode.innerHTML = '<div class="x-tree-root-node"></div>';
  46.             this.wrap = this.ctNode = targetNode.firstChild;
  47.         }
  48.     },
  49.     collapse : Ext.emptyFn,
  50.     expand : Ext.emptyFn
  51. });
  52. Ext.tree.TreeLoader = function(config){
  53.     this.baseParams = {};
  54.     Ext.apply(this, config);
  55.     this.addEvents(
  56.         
  57.         "beforeload",
  58.         
  59.         "load",
  60.         
  61.         "loadexception"
  62.     );
  63.     Ext.tree.TreeLoader.superclass.constructor.call(this);
  64. };
  65. Ext.extend(Ext.tree.TreeLoader, Ext.util.Observable, {
  66.     
  67.     
  68.     
  69.     
  70.     
  71.     
  72.     
  73.     uiProviders : {},
  74.     
  75.     clearOnLoad : true,
  76.     
  77.     load : function(node, callback){
  78.         if(this.clearOnLoad){
  79.             while(node.firstChild){
  80.                 node.removeChild(node.firstChild);
  81.             }
  82.         }
  83.         if(this.doPreload(node)){              if(typeof callback == "function"){
  84.                 callback();
  85.             }
  86.         }else if(this.dataUrl||this.url){
  87.             this.requestData(node, callback);
  88.         }
  89.     },
  90.     doPreload : function(node){
  91.         if(node.attributes.children){
  92.             if(node.childNodes.length < 1){                  var cs = node.attributes.children;
  93.                 node.beginUpdate();
  94.                 for(var i = 0, len = cs.length; i < len; i++){
  95.                     var cn = node.appendChild(this.createNode(cs[i]));
  96.                     if(this.preloadChildren){
  97.                         this.doPreload(cn);
  98.                     }
  99.                 }
  100.                 node.endUpdate();
  101.             }
  102.             return true;
  103.         }else {
  104.             return false;
  105.         }
  106.     },
  107.     getParams: function(node){
  108.         var buf = [], bp = this.baseParams;
  109.         for(var key in bp){
  110.             if(typeof bp[key] != "function"){
  111.                 buf.push(encodeURIComponent(key), "=", encodeURIComponent(bp[key]), "&");
  112.             }
  113.         }
  114.         buf.push("node=", encodeURIComponent(node.id));
  115.         return buf.join("");
  116.     },
  117.     requestData : function(node, callback){
  118.         if(this.fireEvent("beforeload", this, node, callback) !== false){
  119.             this.transId = Ext.Ajax.request({
  120.                 method:this.requestMethod,
  121.                 url: this.dataUrl||this.url,
  122.                 success: this.handleResponse,
  123.                 failure: this.handleFailure,
  124.                 scope: this,
  125.                 argument: {callback: callback, node: node},
  126.                 params: this.getParams(node)
  127.             });
  128.         }else{
  129.                                       if(typeof callback == "function"){
  130.                 callback();
  131.             }
  132.         }
  133.     },
  134.     isLoading : function(){
  135.         return !!this.transId;
  136.     },
  137.     abort : function(){
  138.         if(this.isLoading()){
  139.             Ext.Ajax.abort(this.transId);
  140.         }
  141.     },
  142.     
  143.     createNode : function(attr){
  144.                  if(this.baseAttrs){
  145.             Ext.applyIf(attr, this.baseAttrs);
  146.         }
  147.         if(this.applyLoader !== false){
  148.             attr.loader = this;
  149.         }
  150.         if(typeof attr.uiProvider == 'string'){
  151.            attr.uiProvider = this.uiProviders[attr.uiProvider] || eval(attr.uiProvider);
  152.         }
  153.         if(attr.nodeType){
  154.             return new Ext.tree.TreePanel.nodeTypes[attr.nodeType](attr);
  155.         }else{
  156.             return attr.leaf ?
  157.                         new Ext.tree.TreeNode(attr) :
  158.                         new Ext.tree.AsyncTreeNode(attr);
  159.         }
  160.     },
  161.     processResponse : function(response, node, callback){
  162.         var json = response.responseText;
  163.         try {
  164.             var o = eval("("+json+")");
  165.             node.beginUpdate();
  166.             for(var i = 0, len = o.length; i < len; i++){
  167.                 var n = this.createNode(o[i]);
  168.                 if(n){
  169.                     node.appendChild(n);
  170.                 }
  171.             }
  172.             node.endUpdate();
  173.             if(typeof callback == "function"){
  174.                 callback(this, node);
  175.             }
  176.         }catch(e){
  177.             this.handleFailure(response);
  178.         }
  179.     },
  180.     handleResponse : function(response){
  181.         this.transId = false;
  182.         var a = response.argument;
  183.         this.processResponse(response, a.node, a.callback);
  184.         this.fireEvent("load", this, a.node, response);
  185.     },
  186.     handleFailure : function(response){
  187.         this.transId = false;
  188.         var a = response.argument;
  189.         this.fireEvent("loadexception", this, a.node, response);
  190.         if(typeof a.callback == "function"){
  191.             a.callback(this, a.node);
  192.         }
  193.     }
  194. });
  195. Ext.tree.TreeFilter = function(tree, config){
  196.     this.tree = tree;
  197.     this.filtered = {};
  198.     Ext.apply(this, config);
  199. };
  200. Ext.tree.TreeFilter.prototype = {
  201.     clearBlank:false,
  202.     reverse:false,
  203.     autoClear:false,
  204.     remove:false,
  205.      
  206.     filter : function(value, attr, startNode){
  207.         attr = attr || "text";
  208.         var f;
  209.         if(typeof value == "string"){
  210.             var vlen = value.length;
  211.                          if(vlen == 0 && this.clearBlank){
  212.                 this.clear();
  213.                 return;
  214.             }
  215.             value = value.toLowerCase();
  216.             f = function(n){
  217.                 return n.attributes[attr].substr(0, vlen).toLowerCase() == value;
  218.             };
  219.         }else if(value.exec){              f = function(n){
  220.                 return value.test(n.attributes[attr]);
  221.             };
  222.         }else{
  223.             throw 'Illegal filter type, must be string or regex';
  224.         }
  225.         this.filterBy(f, null, startNode);
  226. },
  227.     
  228.     
  229.     filterBy : function(fn, scope, startNode){
  230.         startNode = startNode || this.tree.root;
  231.         if(this.autoClear){
  232.             this.clear();
  233.         }
  234.         var af = this.filtered, rv = this.reverse;
  235.         var f = function(n){
  236.             if(n == startNode){
  237.                 return true;
  238.             }
  239.             if(af[n.id]){
  240.                 return false;
  241.             }
  242.             var m = fn.call(scope || n, n);
  243.             if(!m || rv){
  244.                 af[n.id] = n;
  245.                 n.ui.hide();
  246.                 return false;
  247.             }
  248.             return true;
  249.         };
  250.         startNode.cascade(f);
  251.         if(this.remove){
  252.            for(var id in af){
  253.                if(typeof id != "function"){
  254.                    var n = af[id];
  255.                    if(n && n.parentNode){
  256.                        n.parentNode.removeChild(n);
  257.                    }
  258.                }
  259.            } 
  260.         }
  261.     },
  262.     
  263.     
  264.     clear : function(){
  265.         var t = this.tree;
  266.         var af = this.filtered;
  267.         for(var id in af){
  268.             if(typeof id != "function"){
  269.                 var n = af[id];
  270.                 if(n){
  271.                     n.ui.show();
  272.                 }
  273.             }
  274.         }
  275.         this.filtered = {}; 
  276.     }
  277. };
  278. Ext.tree.TreeSorter = function(tree, config){
  279.     
  280.     
  281.     
  282.     
  283.     
  284.     
  285.     Ext.apply(this, config);
  286.     tree.on("beforechildrenrendered", this.doSort, this);
  287.     tree.on("append", this.updateSort, this);
  288.     tree.on("insert", this.updateSort, this);
  289.     tree.on("textchange", this.updateSortParent, this);
  290.     
  291.     var dsc = this.dir && this.dir.toLowerCase() == "desc";
  292.     var p = this.property || "text";
  293.     var sortType = this.sortType;
  294.     var fs = this.folderSort;
  295.     var cs = this.caseSensitive === true;
  296.     var leafAttr = this.leafAttr || 'leaf';
  297.     this.sortFn = function(n1, n2){
  298.         if(fs){
  299.             if(n1.attributes[leafAttr] && !n2.attributes[leafAttr]){
  300.                 return 1;
  301.             }
  302.             if(!n1.attributes[leafAttr] && n2.attributes[leafAttr]){
  303.                 return -1;
  304.             }
  305.         }
  306.      var v1 = sortType ? sortType(n1) : (cs ? n1.attributes[p] : n1.attributes[p].toUpperCase());
  307.      var v2 = sortType ? sortType(n2) : (cs ? n2.attributes[p] : n2.attributes[p].toUpperCase());
  308.      if(v1 < v2){
  309. return dsc ? +1 : -1;
  310. }else if(v1 > v2){
  311. return dsc ? -1 : +1;
  312.         }else{
  313.      return 0;
  314.         }
  315.     };
  316. };
  317. Ext.tree.TreeSorter.prototype = {
  318.     doSort : function(node){
  319.         node.sort(this.sortFn);
  320.     },
  321.     
  322.     compareNodes : function(n1, n2){
  323.         return (n1.text.toUpperCase() > n2.text.toUpperCase() ? 1 : -1);
  324.     },
  325.     
  326.     updateSort : function(tree, node){
  327.         if(node.childrenRendered){
  328.             this.doSort.defer(1, this, [node]);
  329.         }
  330.     },
  331.     
  332.     updateSortParent : function(node){
  333. var p = node.parentNode;
  334. if(p && p.childrenRendered){
  335.             this.doSort.defer(1, this, [p]);
  336.         }
  337.     }
  338. };
  339. if(Ext.dd.DropZone){
  340.     
  341. Ext.tree.TreeDropZone = function(tree, config){
  342.     
  343.     this.allowParentInsert = false;
  344.     
  345.     this.allowContainerDrop = false;
  346.     
  347.     this.appendOnly = false;
  348.     Ext.tree.TreeDropZone.superclass.constructor.call(this, tree.innerCt, config);
  349.     
  350.     this.tree = tree;
  351.     
  352.     this.dragOverData = {};
  353.          this.lastInsertClass = "x-tree-no-status";
  354. };
  355. Ext.extend(Ext.tree.TreeDropZone, Ext.dd.DropZone, {
  356.     
  357.     ddGroup : "TreeDD",
  358.     
  359.     expandDelay : 1000,
  360.          expandNode : function(node){
  361.         if(node.hasChildNodes() && !node.isExpanded()){
  362.             node.expand(false, null, this.triggerCacheRefresh.createDelegate(this));
  363.         }
  364.     },
  365.          queueExpand : function(node){
  366.         this.expandProcId = this.expandNode.defer(this.expandDelay, this, [node]);
  367.     },
  368.          cancelExpand : function(){
  369.         if(this.expandProcId){
  370.             clearTimeout(this.expandProcId);
  371.             this.expandProcId = false;
  372.         }
  373.     },
  374.          isValidDropPoint : function(n, pt, dd, e, data){
  375.         if(!n || !data){ return false; }
  376.         var targetNode = n.node;
  377.         var dropNode = data.node;
  378.                  if(!(targetNode && targetNode.isTarget && pt)){
  379.             return false;
  380.         }
  381.         if(pt == "append" && targetNode.allowChildren === false){
  382.             return false;
  383.         }
  384.         if((pt == "above" || pt == "below") && (targetNode.parentNode && targetNode.parentNode.allowChildren === false)){
  385.             return false;
  386.         }
  387.         if(dropNode && (targetNode == dropNode || dropNode.contains(targetNode))){
  388.             return false;
  389.         }
  390.                  var overEvent = this.dragOverData;
  391.         overEvent.tree = this.tree;
  392.         overEvent.target = targetNode;
  393.         overEvent.data = data;
  394.         overEvent.point = pt;
  395.         overEvent.source = dd;
  396.         overEvent.rawEvent = e;
  397.         overEvent.dropNode = dropNode;
  398.         overEvent.cancel = false;  
  399.         var result = this.tree.fireEvent("nodedragover", overEvent);
  400.         return overEvent.cancel === false && result !== false;
  401.     },
  402.          getDropPoint : function(e, n, dd){
  403.         var tn = n.node;
  404.         if(tn.isRoot){
  405.             return tn.allowChildren !== false ? "append" : false;          }
  406.         var dragEl = n.ddel;
  407.         var t = Ext.lib.Dom.getY(dragEl), b = t + dragEl.offsetHeight;
  408.         var y = Ext.lib.Event.getPageY(e);
  409.         var noAppend = tn.allowChildren === false || tn.isLeaf();
  410.         if(this.appendOnly || tn.parentNode.allowChildren === false){
  411.             return noAppend ? false : "append";
  412.         }
  413.         var noBelow = false;
  414.         if(!this.allowParentInsert){
  415.             noBelow = tn.hasChildNodes() && tn.isExpanded();
  416.         }
  417.         var q = (b - t) / (noAppend ? 2 : 3);
  418.         if(y >= t && y < (t + q)){
  419.             return "above";
  420.         }else if(!noBelow && (noAppend || y >= b-q && y <= b)){
  421.             return "below";
  422.         }else{
  423.             return "append";
  424.         }
  425.     },
  426.          onNodeEnter : function(n, dd, e, data){
  427.         this.cancelExpand();
  428.     },
  429.          onNodeOver : function(n, dd, e, data){
  430.         var pt = this.getDropPoint(e, n, dd);
  431.         var node = n.node;
  432.         
  433.                  if(!this.expandProcId && pt == "append" && node.hasChildNodes() && !n.node.isExpanded()){
  434.             this.queueExpand(node);
  435.         }else if(pt != "append"){
  436.             this.cancelExpand();
  437.         }
  438.         
  439.                  var returnCls = this.dropNotAllowed;
  440.         if(this.isValidDropPoint(n, pt, dd, e, data)){
  441.            if(pt){
  442.                var el = n.ddel;
  443.                var cls;
  444.                if(pt == "above"){
  445.                    returnCls = n.node.isFirst() ? "x-tree-drop-ok-above" : "x-tree-drop-ok-between";
  446.                    cls = "x-tree-drag-insert-above";
  447.                }else if(pt == "below"){
  448.                    returnCls = n.node.isLast() ? "x-tree-drop-ok-below" : "x-tree-drop-ok-between";
  449.                    cls = "x-tree-drag-insert-below";
  450.                }else{
  451.                    returnCls = "x-tree-drop-ok-append";
  452.                    cls = "x-tree-drag-append";
  453.                }
  454.                if(this.lastInsertClass != cls){
  455.                    Ext.fly(el).replaceClass(this.lastInsertClass, cls);
  456.                    this.lastInsertClass = cls;
  457.                }
  458.            }
  459.        }
  460.        return returnCls;
  461.     },
  462.          onNodeOut : function(n, dd, e, data){
  463.         this.cancelExpand();
  464.         this.removeDropIndicators(n);
  465.     },
  466.          onNodeDrop : function(n, dd, e, data){
  467.         var point = this.getDropPoint(e, n, dd);
  468.         var targetNode = n.node;
  469.         targetNode.ui.startDrop();
  470.         if(!this.isValidDropPoint(n, point, dd, e, data)){
  471.             targetNode.ui.endDrop();
  472.             return false;
  473.         }
  474.                  var dropNode = data.node || (dd.getTreeNode ? dd.getTreeNode(data, targetNode, point, e) : null);
  475.         var dropEvent = {
  476.             tree : this.tree,
  477.             target: targetNode,
  478.             data: data,
  479.             point: point,
  480.             source: dd,
  481.             rawEvent: e,
  482.             dropNode: dropNode,
  483.             cancel: !dropNode,
  484.             dropStatus: false
  485.         };
  486.         var retval = this.tree.fireEvent("beforenodedrop", dropEvent);
  487.         if(retval === false || dropEvent.cancel === true || !dropEvent.dropNode){
  488.             targetNode.ui.endDrop();
  489.             return dropEvent.dropStatus;
  490.         }
  491.                  targetNode = dropEvent.target;
  492.         if(point == "append" && !targetNode.isExpanded()){
  493.             targetNode.expand(false, null, function(){
  494.                 this.completeDrop(dropEvent);
  495.             }.createDelegate(this));
  496.         }else{
  497.             this.completeDrop(dropEvent);
  498.         }
  499.         return true;
  500.     },
  501.          completeDrop : function(de){
  502.         var ns = de.dropNode, p = de.point, t = de.target;
  503.         if(!Ext.isArray(ns)){
  504.             ns = [ns];
  505.         }
  506.         var n;
  507.         for(var i = 0, len = ns.length; i < len; i++){
  508.             n = ns[i];
  509.             if(p == "above"){
  510.                 t.parentNode.insertBefore(n, t);
  511.             }else if(p == "below"){
  512.                 t.parentNode.insertBefore(n, t.nextSibling);
  513.             }else{
  514.                 t.appendChild(n);
  515.             }
  516.         }
  517.         n.ui.focus();
  518.         if(Ext.enableFx && this.tree.hlDrop){
  519.             n.ui.highlight();
  520.         }
  521.         t.ui.endDrop();
  522.         this.tree.fireEvent("nodedrop", de);
  523.     },
  524.          afterNodeMoved : function(dd, data, e, targetNode, dropNode){
  525.         if(Ext.enableFx && this.tree.hlDrop){
  526.             dropNode.ui.focus();
  527.             dropNode.ui.highlight();
  528.         }
  529.         this.tree.fireEvent("nodedrop", this.tree, targetNode, data, dd, e);
  530.     },
  531.          getTree : function(){
  532.         return this.tree;
  533.     },
  534.          removeDropIndicators : function(n){
  535.         if(n && n.ddel){
  536.             var el = n.ddel;
  537.             Ext.fly(el).removeClass([
  538.                     "x-tree-drag-insert-above",
  539.                     "x-tree-drag-insert-below",
  540.                     "x-tree-drag-append"]);
  541.             this.lastInsertClass = "_noclass";
  542.         }
  543.     },
  544.          beforeDragDrop : function(target, e, id){
  545.         this.cancelExpand();
  546.         return true;
  547.     },
  548.          afterRepair : function(data){
  549.         if(data && Ext.enableFx){
  550.             data.node.ui.highlight();
  551.         }
  552.         this.hideProxy();
  553.     }    
  554. });
  555. }
  556. if(Ext.dd.DragZone){
  557. Ext.tree.TreeDragZone = function(tree, config){
  558.     Ext.tree.TreeDragZone.superclass.constructor.call(this, tree.getTreeEl(), config);
  559.     
  560.     this.tree = tree;
  561. };
  562. Ext.extend(Ext.tree.TreeDragZone, Ext.dd.DragZone, {
  563.     
  564.     ddGroup : "TreeDD",
  565.          onBeforeDrag : function(data, e){
  566.         var n = data.node;
  567.         return n && n.draggable && !n.disabled;
  568.     },
  569.          onInitDrag : function(e){
  570.         var data = this.dragData;
  571.         this.tree.getSelectionModel().select(data.node);
  572.         this.tree.eventModel.disable();
  573.         this.proxy.update("");
  574.         data.node.ui.appendDDGhost(this.proxy.ghost.dom);
  575.         this.tree.fireEvent("startdrag", this.tree, data.node, e);
  576.     },
  577.          getRepairXY : function(e, data){
  578.         return data.node.ui.getDDRepairXY();
  579.     },
  580.          onEndDrag : function(data, e){
  581.         this.tree.eventModel.enable.defer(100, this.tree.eventModel);
  582.         this.tree.fireEvent("enddrag", this.tree, data.node, e);
  583.     },
  584.          onValidDrop : function(dd, e, id){
  585.         this.tree.fireEvent("dragdrop", this.tree, this.dragData.node, dd, e);
  586.         this.hideProxy();
  587.     },
  588.          beforeInvalidDrop : function(e, id){
  589.                  var sm = this.tree.getSelectionModel();
  590.         sm.clearSelections();
  591.         sm.select(this.dragData.node);
  592.     },
  593.     
  594.          afterRepair : function(){
  595.         if (Ext.enableFx && this.tree.hlDrop) {
  596.             Ext.Element.fly(this.dragData.ddel).highlight(this.hlColor || "c3daf9");
  597.         }
  598.         this.dragging = false;
  599.     }
  600. });
  601. } 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('beforeclick', this.beforeNodeClick, this);         tree.on('dblclick', this.onNodeDblClick, this);         this.on('complete', this.updateNode, this);         this.on('beforestartedit', this.fitToTree, this);         this.on('startedit', this.bindScroll, this, {delay:10});         this.on('specialkey', this.onSpecialKey, this);     },         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){                 node.ui.getEl().scrollIntoView(this.tree.body);             }             this.autoEditTimer = this.startEdit.defer(this.editDelay, this, [node.ui.textNode, node.text]);             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();         }     } }); Ext.menu.Menu = function(config){     if(Ext.isArray(config)){         config = {items:config};     }     Ext.apply(this, config);     this.id = this.id || Ext.id();     this.addEvents(                  'beforeshow',                  'beforehide',                  'show',                  'hide',                  'click',                  'mouseover',                  'mouseout',                  'itemclick'     );     Ext.menu.MenuMgr.register(this);     Ext.menu.Menu.superclass.constructor.call(this);     var mis = this.items;          this.items = new Ext.util.MixedCollection();     if(mis){         this.add.apply(this, mis);     } }; Ext.extend(Ext.menu.Menu, Ext.util.Observable, {                    minWidth : 120,          shadow : "sides",          subMenuAlign : "tl-tr?",          defaultAlign : "tl-bl?",          allowOtherMenus : false,          ignoreParentClicks : false,         hidden:true,         createEl : function(){         return new Ext.Layer({             cls: "x-menu",             shadow:this.shadow,             constrain: false,             parentEl: this.parentEl || document.body,             zindex:15000         });     },         render : function(){         if(this.el){             return;         }         var el = this.el = this.createEl();         if(!this.keyNav){             this.keyNav = new Ext.menu.MenuNav(this);         }         if(this.plain){             el.addClass("x-menu-plain");         }         if(this.cls){             el.addClass(this.cls);         }                 this.focusEl = el.createChild({             tag: "a", cls: "x-menu-focus", href: "#", onclick: "return false;", tabIndex:"-1"         });         var ul = el.createChild({tag: "ul", cls: "x-menu-list"});         ul.on("click", this.onClick, this);         ul.on("mouseover", this.onMouseOver, this);         ul.on("mouseout", this.onMouseOut, this);         this.items.each(function(item){             var li = document.createElement("li");             li.className = "x-menu-list-item";             ul.dom.appendChild(li);             item.render(li, this);         }, this);         this.ul = ul;         this.autoWidth();     },         autoWidth : function(){         var el = this.el, ul = this.ul;         if(!el){             return;         }         var w = this.width;         if(w){             el.setWidth(w);         }else if(Ext.isIE){             el.setWidth(this.minWidth);             var t = el.dom.offsetWidth;             el.setWidth(ul.getWidth()+el.getFrameWidth("lr"));         }     },         delayAutoWidth : function(){         if(this.el){             if(!this.awTask){                 this.awTask = new Ext.util.DelayedTask(this.autoWidth, this);             }             this.awTask.delay(20);         }     },         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;         if(t = this.findTargetItem(e)){             if(t.menu && this.ignoreParentClicks){                 t.expandMenu();             }else{                 t.onClick(e);                 this.fireEvent("click", this, t, e);             }         }     },         setActiveItem : function(item, autoExpand){         if(item != this.activeItem){             if(this.activeItem){                 this.activeItem.deactivate();             }             this.activeItem = item;             item.activate(autoExpand);         }else if(autoExpand){             item.expandMenu();         }     },         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){                 this.setActiveItem(item, false);                 return item;             }         }         return false;     },         onMouseOver : function(e){         var t;         if(t = this.findTargetItem(e)){             if(t.canActivate && !t.disabled){                 this.setActiveItem(t, true);             }         }         this.over = true;         this.fireEvent("mouseover", this, e, t);     },         onMouseOut : function(e){         var t;         if(t = this.findTargetItem(e)){             if(t == this.activeItem && t.shouldDeactivate(e)){                 this.activeItem.deactivate();                 delete this.activeItem;             }         }         this.over = false;         this.fireEvent("mouseout", this, e, t);     },          isVisible : function(){         return this.el && !this.hidden;     },          show : function(el, pos, parentMenu){         this.parentMenu = parentMenu;         if(!this.el){             this.render();         }         this.fireEvent("beforeshow", this);         this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign), parentMenu, false);     },          showAt : function(xy, parentMenu, _e){         this.parentMenu = parentMenu;         if(!this.el){             this.render();         }         if(_e !== false){             this.fireEvent("beforeshow", this);             xy = this.el.adjustForConstraints(xy);         }         this.el.setXY(xy);         this.el.show();         this.hidden = false;         this.focus();         this.fireEvent("show", this);     },          focus : function(){         if(!this.hidden){             this.doFocus.defer(50, this);         }     },     doFocus : function(){         if(!this.hidden){             this.focusEl.focus();         }     },          hide : function(deep){         if(this.el && this.isVisible()){             this.fireEvent("beforehide", this);             if(this.activeItem){                 this.activeItem.deactivate();                 this.activeItem = null;             }             this.el.hide();             this.hidden = true;             this.fireEvent("hide", this);         }         if(deep === true && this.parentMenu){             this.parentMenu.hide(true);         }     },          add : function(){         var a = arguments, l = a.length, item;         for(var i = 0; i < l; i++){             var el = a[i];             if(el.render){                 item = this.addItem(el);             }else if(typeof el == "string"){                 if(el == "separator" || el == "-"){                     item = this.addSeparator();                 }else{                     item = this.addText(el);                 }             }else if(el.tagName || el.el){                 item = this.addElement(el);             }else if(typeof el == "object"){                 Ext.applyIf(el, this.defaults);                 item = this.addMenuItem(el);             }         }         return item;     },          getEl : function(){         if(!this.el){             this.render();         }         return this.el;     },          addSeparator : function(){         return this.addItem(new Ext.menu.Separator());     },          addElement : function(el){         return this.addItem(new Ext.menu.BaseItem(el));     },          addItem : function(item){         this.items.add(item);         if(this.ul){             var li = document.createElement("li");             li.className = "x-menu-list-item";             this.ul.dom.appendChild(li);             item.render(li, this);             this.delayAutoWidth();         }         return item;     },          addMenuItem : function(config){         if(!(config instanceof Ext.menu.Item)){             if(typeof config.checked == "boolean"){                 config = new Ext.menu.CheckItem(config);             }else{                 config = new Ext.menu.Item(config);             }         }         return this.addItem(config);     },          addText : function(text){         return this.addItem(new Ext.menu.TextItem(text));     },          insert : function(index, item){         this.items.insert(index, item);         if(this.ul){             var li = document.createElement("li");             li.className = "x-menu-list-item";             this.ul.dom.insertBefore(li, this.ul.dom.childNodes[index]);             item.render(li, this);             this.delayAutoWidth();         }         return item;     },          remove : function(item){         this.items.removeKey(item.id);         item.destroy();     },          removeAll : function(){      if(this.items){         var f;         while(f = this.items.first()){             this.remove(f);         }      }     },          destroy : function(){         this.beforeDestroy();         Ext.menu.MenuMgr.unregister(this);         if (this.keyNav) {          this.keyNav.disable();         }         this.removeAll();         if (this.ul) {          this.ul.removeAllListeners();         }         if (this.el) {          this.el.destroy();         }     },     beforeDestroy : Ext.emptyFn }); Ext.menu.MenuNav = function(menu){     Ext.menu.MenuNav.superclass.constructor.call(this, menu.el);     this.scope = this.menu = menu; }; Ext.extend(Ext.menu.MenuNav, Ext.KeyNav, {     doRelay : function(e, h){         var k = e.getKey();         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);     },     up : function(e, m){         if(!m.tryActivate(m.items.indexOf(m.activeItem)-1, -1)){             m.tryActivate(m.items.length-1, -1);         }     },     down : function(e, m){         if(!m.tryActivate(m.items.indexOf(m.activeItem)+1, 1)){             m.tryActivate(0, 1);         }     },     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();            });        }    }       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(){             hideAll();          },               register : function(menu){            if(!menus){                init();            }            menus[menu.id] = menu;            menu.on("beforehide", onBeforeHide);            menu.on("hide", onHide);            menu.on("beforeshow", onBeforeShow);            menu.on("show", onShow);            var g = menu.group;            if(g && menu.events["checkchange"]){                if(!groups[g]){                    groups[g] = [];                }                groups[g].push(menu);                menu.on("checkchange", onCheck);            }        },                 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 new Ext.menu.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);            var g = menu.group;            if(g && menu.events["checkchange"]){                groups[g].remove(menu);                menu.un("checkchange", onCheck);            }        },               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 = function(config){     Ext.menu.BaseItem.superclass.constructor.call(this, config);     this.addEvents(                  'click',                  'activate',                  'deactivate'     );     if(this.handler){         this.on("click", this.handler, this.scope);     } }; Ext.extend(Ext.menu.BaseItem, Ext.Component, {                    canActivate : false,          activeClass : "x-menu-item-active",          hideOnClick : true,          hideDelay : 100,         ctype: "Ext.menu.BaseItem",         actionMode : "container",         render : function(container, parentMenu){                  this.parentMenu = parentMenu;         Ext.menu.BaseItem.superclass.render.call(this, container);         this.container.menuItemId = this.id;     },         onRender : function(container, position){         this.el = Ext.get(this.el);         container.dom.appendChild(this.el.dom);     },          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.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){         if(this.hideOnClick){             this.parentMenu.hide.defer(this.hideDelay, this.parentMenu, [true]);         }     },         expandMenu : function(autoActivate){             },         hideMenu : function(){             } }); Ext.menu.TextItem = function(cfg){     if(typeof cfg == 'string'){         cfg = {text: cfg}     }     Ext.menu.TextItem.superclass.constructor.call(this, cfg); }; Ext.extend(Ext.menu.TextItem, Ext.menu.BaseItem, {               hideOnClick : false,          itemCls : "x-menu-text",         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.menu.Separator = function(config){     Ext.menu.Separator.superclass.constructor.call(this, config); }; Ext.extend(Ext.menu.Separator, Ext.menu.BaseItem, {          itemCls : "x-menu-sep",          hideOnClick : false,         onRender : function(li){         var s = document.createElement("span");         s.className = this.itemCls;         s.innerHTML = "&#160;";         this.el = s;         li.addClass("x-menu-sep-li");         Ext.menu.Separator.superclass.onRender.apply(this, arguments);     } }); Ext.menu.Item = function(config){     Ext.menu.Item.superclass.constructor.call(this, config);     if(this.menu){         this.menu = Ext.menu.MenuMgr.get(this.menu);     } }; Ext.extend(Ext.menu.Item, Ext.menu.BaseItem, {                                        itemCls : "x-menu-item",          canActivate : true,          showDelay: 200,         hideDelay: 200,         ctype: "Ext.menu.Item",         onRender : function(container, position){         var el = document.createElement("a");         el.hideFocus = true;         el.unselectable = "on";         el.href = this.href || "#";         if(this.hrefTarget){             el.target = this.hrefTarget;         }         el.className = this.itemCls + (this.menu ?  " x-menu-item-arrow" : "") + (this.cls ?  " " + this.cls : "");         el.innerHTML = String.format(                 '<img src="{0}" class="x-menu-item-icon {2}" />{1}',                 this.icon || Ext.BLANK_IMAGE_URL, this.itemText||this.text, this.iconCls || '');         this.el = el;         Ext.menu.Item.superclass.onRender.call(this, container, position);     },          setText : function(text){         this.text = text;         if(this.rendered){             this.el.update(String.format(                 '<img src="{0}" class="x-menu-item-icon {2}">{1}',                 this.icon || Ext.BLANK_IMAGE_URL, this.text, this.iconCls || ''));             this.parentMenu.autoWidth();         }     },          setIconClass : function(cls){         var oldCls = this.iconCls;         this.iconCls = cls;         if(this.rendered){             this.el.child('img.x-menu-item-icon').replaceClass(oldCls, this.iconCls);         }     },         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.menu.CheckItem = function(config){     Ext.menu.CheckItem.superclass.constructor.call(this, config);     this.addEvents(                  "beforecheckchange" ,                  "checkchange"     );          if(this.checkHandler){         this.on('checkchange', this.checkHandler, this.scope);     }     Ext.menu.MenuMgr.registerCheckable(this); }; Ext.extend(Ext.menu.CheckItem, Ext.menu.Item, {               itemCls : "x-menu-item x-menu-check-item",          groupClass : "x-menu-group-item",          checked: false,         ctype: "Ext.menu.CheckItem",         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.menu.Adapter = function(component, config){     Ext.menu.Adapter.superclass.constructor.call(this, config);     this.component = component; }; Ext.extend(Ext.menu.Adapter, Ext.menu.BaseItem, {         canActivate : true,         onRender : function(container, position){         this.component.render(container);         this.el = this.component.getEl();     },         activate : function(){         if(this.disabled){             return false;         }         this.component.focus();         this.fireEvent("activate", this);         return true;     },         deactivate : function(){         this.fireEvent("deactivate", this);     },         disable : function(){         this.component.disable();         Ext.menu.Adapter.superclass.disable.call(this);     },         enable : function(){         this.component.enable();         Ext.menu.Adapter.superclass.enable.call(this);     } }); Ext.menu.DateItem = function(config){     Ext.menu.DateItem.superclass.constructor.call(this, new Ext.DatePicker(config), config);          this.picker = this.component;     this.addEvents('select');          this.picker.on("render", function(picker){         picker.getEl().swallowEvent("click");         picker.container.addClass("x-menu-date-item");     });     this.picker.on("select", this.onSelect, this); }; Ext.extend(Ext.menu.DateItem, Ext.menu.Adapter, {         onSelect : function(picker, date){         this.fireEvent("select", this, date, picker);         Ext.menu.DateItem.superclass.handleClick.call(this);     } }); Ext.menu.ColorItem = function(config){     Ext.menu.ColorItem.superclass.constructor.call(this, new Ext.ColorPalette(config), config);          this.palette = this.component;     this.relayEvents(this.palette, ["select"]);     if(this.selectHandler){         this.on('select', this.selectHandler, this.scope);     } }; Ext.extend(Ext.menu.ColorItem, Ext.menu.Adapter); Ext.menu.DateMenu = function(config){     Ext.menu.DateMenu.superclass.constructor.call(this, config);     this.plain = true;     var di = new Ext.menu.DateItem(config);     this.add(di);          this.picker = di.picker;          this.relayEvents(di, ["select"]);     this.on('beforeshow', function(){         if(this.picker){             this.picker.hideMonthPicker(true);         }     }, this); }; Ext.extend(Ext.menu.DateMenu, Ext.menu.Menu, {     cls:'x-date-menu',         beforeDestroy : function() {         this.picker.destroy();     } }); Ext.menu.ColorMenu = function(config){     Ext.menu.ColorMenu.superclass.constructor.call(this, config);     this.plain = true;     var ci = new Ext.menu.ColorItem(config);     this.add(ci);          this.palette = ci.palette;          this.relayEvents(ci, ["select"]); }; Ext.extend(Ext.menu.ColorMenu, Ext.menu.Menu); 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,              isFormField : true,              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.hiddenName || '');     },         onRender : function(ct, position){         Ext.form.Field.superclass.onRender.call(this, 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.el = ct.createChild(cfg, position);         }         var type = this.el.dom.type;         if(type){             if(type == 'password'){                 type = 'text';             }             this.el.addClass('x-form-'+type);         }         if(this.readOnly){             this.el.dom.readOnly = true;         }         if(this.tabIndex !== undefined){             this.el.dom.setAttribute('tabIndex', this.tabIndex);         }         this.el.addClass([this.fieldClass, this.cls]);     },         initValue : function(){         if(this.value !== undefined){             this.setValue(this.value);         }else if(this.el.dom.value.length > 0 && this.el.dom.value != this.emptyText){             this.setValue(this.el.dom.value);         }                 this.originalValue = this.getValue();     },          isDirty : function() {         if(this.disabled) {             return false;         }         return String(this.getValue()) !== String(this.originalValue);     },         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.el.on(Ext.isIE || Ext.isSafari3 ? "keydown" : "keypress", this.fireKey,  this);         this.el.on("focus", this.onFocus,  this);                          var o = this.inEditor && Ext.isWindows && Ext.isGecko ? {buffer:10} : null;         this.el.on("blur", this.onBlur,  this, o);                 this.originalValue = this.getValue();     },         onFocus : function(){         if(!Ext.isOpera && 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(!Ext.isOpera && 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);     },          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;     },          markInvalid : function(msg){         if(!this.rendered || this.preventMark){             return;         }         this.el.addClass(this.invalidClass);         msg = msg || this.invalidText;         switch(this.msgTarget){             case 'qtip':                 this.el.dom.qtip = msg;                 this.el.dom.qclass = 'x-form-invalid-tip';                 if(Ext.QuickTips){                     Ext.QuickTips.enable();                 }                 break;             case 'title':                 this.el.dom.title = msg;                 break;             case 'under':                 if(!this.errorEl){                     var elp = this.getErrorCt();                     if(!elp){                         this.el.dom.title = msg;                         break;                     }                     this.errorEl = elp.createChild({cls:'x-form-invalid-msg'});                     this.errorEl.setWidth(elp.getWidth(true)-20);                 }                 this.errorEl.update(msg);                 Ext.form.Field.msgFx[this.msgFx].show(this.errorEl, this);                 break;             case 'side':                 if(!this.errorIcon){                     var elp = this.getErrorCt();                     if(!elp){                         this.el.dom.title = msg;                         break;                     }                     this.errorIcon = elp.createChild({cls:'x-form-invalid-icon'});                 }                 this.alignErrorIcon();                 this.errorIcon.dom.qtip = msg;                 this.errorIcon.dom.qclass = 'x-form-invalid-tip';                 this.errorIcon.show();                 this.on('resize', this.alignErrorIcon, this);                 break;             default:                 var t = Ext.getDom(this.msgTarget);                 t.innerHTML = msg;                 t.style.display = this.msgDisplay;                 break;         }         this.fireEvent('invalid', this, msg);     },              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]);     },          clearInvalid : function(){         if(!this.rendered || this.preventMark){             return;         }         this.el.removeClass(this.invalidClass);         switch(this.msgTarget){             case 'qtip':                 this.el.dom.qtip = '';                 break;             case 'title':                 this.el.dom.title = '';                 break;             case 'under':                 if(this.errorEl){                     Ext.form.Field.msgFx[this.msgFx].hide(this.errorEl, this);                 }                 break;             case 'side':                 if(this.errorIcon){                     this.errorIcon.dom.qtip = '';                     this.errorIcon.hide();                     this.un('resize', this.alignErrorIcon, this);                 }                 break;             default:                 var t = Ext.getDom(this.msgTarget);                 t.innerHTML = '';                 t.style.display = 'none';                 break;         }         this.fireEvent('valid', this);     },          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.el.dom.value = (v === null || v === undefined ? '' : v);     },          setValue : function(v){         this.value = v;         if(this.rendered){             this.el.dom.value = (v === null || v === undefined ? '' : v);             this.validate();         }     },         adjustSize : function(w, h){         var s = Ext.form.Field.superclass.adjustSize.call(this, w, h);         s.width = this.adjustWidth(this.el.dom.tagName, s.width);         return s;     },         adjustWidth : function(tag, w){         tag = tag.toLowerCase();         if(typeof w == 'number' && !Ext.isSafari){             if(Ext.isIE && (tag == 'input' || tag == 'textarea')){                 if(tag == 'input' && !Ext.isStrict){                     return this.inEditor ? w : w - 3;                 }                 if(tag == 'input' && Ext.isStrict){                     return w - (Ext.isIE6 ? 4 : 1);                 }                 if(tag == 'textarea' && Ext.isStrict){                     return w-2;                 }             }else if(Ext.isOpera && Ext.isStrict){                 if(tag == 'input'){                     return w + 2;                 }                 if(tag == 'textarea'){                     return w-2;                 }             }         }         return w;     }                }); Ext.form.MessageTargets = {     'qtip' : {         mark: function(f){             this.el.dom.qtip = msg;             this.el.dom.qclass = 'x-form-invalid-tip';             if(Ext.QuickTips){                 Ext.QuickTips.enable();             }         },         clear: function(f){             this.el.dom.qtip = '';         }     },     'title' : {         mark: function(f){             this.el.dom.title = msg;         },         clear: function(f){             this.el.dom.title = '';         }     },     'under' : {         mark: function(f){             if(!this.errorEl){                 var elp = this.getErrorCt();                 if(!elp){                     this.el.dom.title = msg;                     return;                 }                 this.errorEl = elp.createChild({cls:'x-form-invalid-msg'});                 this.errorEl.setWidth(elp.getWidth(true)-20);             }             this.errorEl.update(msg);             Ext.form.Field.msgFx[this.msgFx].show(this.errorEl, this);         },         clear: function(f){             if(this.errorEl){                 Ext.form.Field.msgFx[this.msgFx].hide(this.errorEl, this);             }else{                 this.el.dom.title = '';             }         }     },     'side' : {         mark: function(f){             if(!this.errorIcon){                 var elp = this.getErrorCt();                 if(!elp){                     this.el.dom.title = msg;                     return;                 }                 this.errorIcon = elp.createChild({cls:'x-form-invalid-icon'});             }             this.alignErrorIcon();             this.errorIcon.dom.qtip = msg;             this.errorIcon.dom.qclass = 'x-form-invalid-tip';             this.errorIcon.show();             this.on('resize', this.alignErrorIcon, this);         },         clear: function(f){             if(this.errorIcon){                 this.errorIcon.dom.qtip = '';                 this.errorIcon.hide();                 this.un('resize', this.alignErrorIcon, this);             }else{                 this.el.dom.title = '';             }         }     },     'around' : {         mark: function(f){         },         clear: function(f){         }     } }; 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.el.on('keyup', this.filterValidation, this);         }         else if(this.validationEvent !== false){             this.el.on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});         }         if(this.selectOnFocus || this.emptyText){             this.on("focus", this.preFocus, this);             this.el.on('mousedown', function(){                 if(!this.hasFocus){                     this.el.on('mouseup', function(e){                         e.preventDefault();                     }, this, {single:true});                 }             }, this);             if(this.emptyText){                 this.on('blur', this.postBlur, this);                 this.applyEmptyText();             }         }         if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Ext.form.VTypes[this.vtype+'Mask']))){             this.el.on("keypress", this.filterKeys, this);         }         if(this.grow){             this.el.on("keyup", this.onKeyUpBuffered,  this, {buffer:50});             this.el.on("click", this.autoSize,  this);         }         if(this.enableKeyEvents){             this.el.on("keyup", this.onKeyUp, this);             this.el.on("keydown", this.onKeyDown, this);             this.el.on("keypress", this.onKeyPress, this);         }     },     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);         }     },         onKeyUpBuffered : function(e){         if(!e.isNavKeyPress()){             this.autoSize();         }     },         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.setRawValue(this.emptyText);             this.el.addClass(this.emptyClass);         }     },         preFocus : function(){         if(this.emptyText){             if(this.el.dom.value == this.emptyText){                 this.setRawValue('');             }             this.el.removeClass(this.emptyClass);         }         if(this.selectOnFocus){             this.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 c = e.getCharCode(), cc = String.fromCharCode(c);         if(!Ext.isGecko && e.isSpecialKey() && !cc){             return;         }         if(!this.maskRe.test(cc)){             e.stopEvent();         }     },     setValue : function(v){         if(this.emptyText && this.el && v !== undefined && v !== null && v !== ''){             this.el.removeClass(this.emptyClass);         }         Ext.form.TextField.superclass.setValue.apply(this, arguments);         this.applyEmptyText();         this.autoSize();     },          validateValue : function(value){         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(typeof this.validator == "function"){             var msg = this.validator(value);             if(msg !== true){                 this.markInvalid(msg);                 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();         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();             }         }     },          autoSize : function(){         if(!this.grow || !this.rendered){             return;         }         if(!this.metrics){             this.metrics = Ext.util.TextMetrics.createInstance(this.el);         }         var el = this.el;         var v = el.dom.value;         var d = document.createElement('div');         d.appendChild(document.createTextNode(v));         v = d.innerHTML;         d = null;         v += "&#160;";         var w = Math.min(this.growMax, Math.max(this.metrics.getWidth(v) +  10, this.growMin));         this.el.setWidth(w);         this.fireEvent("autosize", this, w);     } }); Ext.reg('textfield', Ext.form.TextField); Ext.form.TriggerField = Ext.extend(Ext.form.TextField,  {               defaultAutoCreate : {tag: "input", type: "text", size: "16", autocomplete: "off"},          hideTrigger:false,          autoSize: Ext.emptyFn,         monitorTab : true,         deferHeight : true,         mimicing : false,         onResize : function(w, h){         Ext.form.TriggerField.superclass.onResize.call(this, w, h);         if(typeof w == 'number'){             this.el.setWidth(this.adjustWidth('input', w - this.trigger.getWidth()));         }         this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());     },         adjustSize : Ext.BoxComponent.prototype.adjustSize,         getResizeEl : function(){         return this.wrap;     },         getPositionEl : function(){         return this.wrap;     },         alignErrorIcon : function(){         if(this.wrap){             this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);         }     },         onRender : function(ct, position){         Ext.form.TriggerField.superclass.onRender.call(this, ct, position);         this.wrap = this.el.wrap({cls: "x-form-field-wrap"});         this.trigger = this.wrap.createChild(this.triggerConfig ||                 {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.triggerClass});         if(this.hideTrigger){             this.trigger.setDisplayed(false);         }         this.initTrigger();         if(!this.width){             this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());         }     },     afterRender : function(){         Ext.form.TriggerField.superclass.afterRender.call(this);         var y;         if(Ext.isIE && this.el.getY() != (y = this.trigger.getY())){             this.el.position();             this.el.setY(y);         }     },         initTrigger : function(){         this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});         this.trigger.addClassOnOver('x-form-trigger-over');         this.trigger.addClassOnClick('x-form-trigger-click');     },         onDestroy : function(){         if(this.trigger){             this.trigger.removeAllListeners();             this.trigger.remove();         }         if(this.wrap){             this.wrap.remove();         }         Ext.form.TriggerField.superclass.onDestroy.call(this);     },         onFocus : function(){         Ext.form.TriggerField.superclass.onFocus.call(this);         if(!this.mimicing){             this.wrap.addClass('x-trigger-wrap-focus');             this.mimicing = true;             Ext.get(Ext.isIE ? document.body : document).on("mousedown", this.mimicBlur, this, {delay: 10});             if(this.monitorTab){                 this.el.on("keydown", this.checkTab, this);             }         }     },         checkTab : function(e){         if(e.getKey() == e.TAB){             this.triggerBlur();         }     },         onBlur : function(){             },         mimicBlur : function(e){         if(!this.wrap.contains(e.target) && this.validateBlur(e)){             this.triggerBlur();         }     },         triggerBlur : function(){         this.mimicing = false;         Ext.get(Ext.isIE ? document.body : document).un("mousedown", this.mimicBlur, this);         if(this.monitorTab){             this.el.un("keydown", this.checkTab, this);         }         this.beforeBlur();         this.wrap.removeClass('x-trigger-wrap-focus');         Ext.form.TriggerField.superclass.onBlur.call(this);     },     beforeBlur : Ext.emptyFn,              validateBlur : function(e){         return true;     },         onDisable : function(){         Ext.form.TriggerField.superclass.onDisable.call(this);         if(this.wrap){             this.wrap.addClass(this.disabledClass);             this.el.removeClass(this.disabledClass);         }     },         onEnable : function(){         Ext.form.TriggerField.superclass.onEnable.call(this);         if(this.wrap){             this.wrap.removeClass(this.disabledClass);         }     },         onShow : function(){         if(this.wrap){             this.wrap.dom.style.display = '';             this.wrap.dom.style.visibility = 'visible';         }     },         onHide : function(){         this.wrap.dom.style.display = 'none';     },          onTriggerClick : Ext.emptyFn                }); Ext.form.TwinTriggerField = Ext.extend(Ext.form.TriggerField, {     initComponent : function(){         Ext.form.TwinTriggerField.superclass.initComponent.call(this);         this.triggerConfig = {             tag:'span', cls:'x-form-twin-triggers', cn:[             {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.trigger1Class},             {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.trigger2Class}         ]};     },     getTrigger : function(index){         return this.triggers[index];     },     initTrigger : function(){         var ts = this.trigger.select('.x-form-trigger', true);         this.wrap.setStyle('overflow', 'hidden');         var triggerField = this;         ts.each(function(t, all, index){             t.hide = function(){                 var w = triggerField.wrap.getWidth();                 this.dom.style.display = 'none';                 triggerField.el.setWidth(w-triggerField.trigger.getWidth());             };             t.show = function(){                 var w = triggerField.wrap.getWidth();                 this.dom.style.display = '';                 triggerField.el.setWidth(w-triggerField.trigger.getWidth());             };             var triggerIndex = 'Trigger'+(index+1);             if(this['hide'+triggerIndex]){                 t.dom.style.display = 'none';             }             t.on("click", this['on'+triggerIndex+'Click'], this, {preventDefault:true});             t.addClassOnOver('x-form-trigger-over');             t.addClassOnClick('x-form-trigger-click');         }, this);         this.triggers = ts.elements;     },     onTrigger1Click : Ext.emptyFn,     onTrigger2Click : Ext.emptyFn }); Ext.reg('trigger', Ext.form.TriggerField); Ext.form.TextArea = Ext.extend(Ext.form.TextField,  {          growMin : 60,          growMax: 1000,     growAppend : '&#160;n&#160;',     growPad : 0,     enterIsSpecial : false,          preventScrollbars: false,              onRender : function(ct, position){         if(!this.el){             this.defaultAutoCreate = {                 tag: "textarea",                 style:"width:100px;height:60px;",                 autocomplete: "off"             };         }         Ext.form.TextArea.superclass.onRender.call(this, ct, position);         if(this.grow){             this.textSizeEl = Ext.DomHelper.append(document.body, {                 tag: "pre", cls: "x-form-grow-sizer"             });             if(this.preventScrollbars){                 this.el.setStyle("overflow", "hidden");             }             this.el.setHeight(this.growMin);         }     },     onDestroy : function(){         if(this.textSizeEl){             Ext.removeNode(this.textSizeEl);         }         Ext.form.TextArea.superclass.onDestroy.call(this);     },     fireKey : function(e){         if(e.isSpecialKey() && (this.enterIsSpecial || (e.getKey() != e.ENTER || e.hasModifier()))){             this.fireEvent("specialkey", this, e);         }     },         onKeyUp : function(e){         if(!e.isNavKeyPress() || e.getKey() == e.ENTER){             this.autoSize();         }         Ext.form.TextArea.superclass.onKeyUp.call(this, e);     },          autoSize : function(){         if(!this.grow || !this.textSizeEl){             return;         }         var el = this.el;         var v = el.dom.value;         var ts = this.textSizeEl;         ts.innerHTML = '';         ts.appendChild(document.createTextNode(v));         v = ts.innerHTML;         Ext.fly(ts).setWidth(this.el.getWidth());         if(v.length < 1){             v = "&#160;&#160;";         }else{             if(Ext.isIE){                 v = v.replace(/n/g, '<p>&#160;</p>');             }             v += this.growAppend;         }         ts.innerHTML = v;         var h = Math.min(this.growMax, Math.max(ts.offsetHeight, this.growMin)+this.growPad);         if(h != this.lastHeight){             this.lastHeight = h;             this.el.setHeight(h);             this.fireEvent("autosize", this, h);         }     } }); Ext.reg('textarea', Ext.form.TextArea); Ext.form.NumberField = Ext.extend(Ext.form.TextField,  {          fieldClass: "x-form-field x-form-num-field",          allowDecimals : true,          decimalSeparator : ".",          decimalPrecision : 2,          allowNegative : true,          minValue : Number.NEGATIVE_INFINITY,          maxValue : Number.MAX_VALUE,          minText : "The minimum value for this field is {0}",          maxText : "The maximum value for this field is {0}",          nanText : "{0} is not a valid number",          baseChars : "0123456789",         initEvents : function(){         Ext.form.NumberField.superclass.initEvents.call(this);         var allowed = this.baseChars+'';         if(this.allowDecimals){             allowed += this.decimalSeparator;         }         if(this.allowNegative){             allowed += "-";         }         this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');         var keyPress = function(e){             var k = e.getKey();             if(!Ext.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){                 return;             }             var c = e.getCharCode();             if(allowed.indexOf(String.fromCharCode(c)) === -1){                 e.stopEvent();             }         };         this.el.on("keypress", keyPress, this);     },         validateValue : function(value){         if(!Ext.form.NumberField.superclass.validateValue.call(this, value)){             return false;         }         if(value.length < 1){              return true;         }         value = String(value).replace(this.decimalSeparator, ".");         if(isNaN(value)){             this.markInvalid(String.format(this.nanText, value));             return false;         }         var num = this.parseValue(value);         if(num < this.minValue){             this.markInvalid(String.format(this.minText, this.minValue));             return false;         }         if(num > this.maxValue){             this.markInvalid(String.format(this.maxText, this.maxValue));             return false;         }         return true;     },     getValue : function(){         return this.fixPrecision(this.parseValue(Ext.form.NumberField.superclass.getValue.call(this)));     },     setValue : function(v){      v = typeof v == 'number' ? v : parseFloat(String(v).replace(this.decimalSeparator, "."));         v = isNaN(v) ? '' : String(v).replace(".", this.decimalSeparator);         Ext.form.NumberField.superclass.setValue.call(this, v);     },         parseValue : function(value){         value = parseFloat(String(value).replace(this.decimalSeparator, "."));         return isNaN(value) ? '' : value;     },         fixPrecision : function(value){         var nan = isNaN(value);         if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){            return nan ? '' : value;         }         return parseFloat(parseFloat(value).toFixed(this.decimalPrecision));     },     beforeBlur : function(){         var v = this.parseValue(this.getRawValue());         if(v){             this.setValue(this.fixPrecision(v));         }     } }); Ext.reg('numberfield', Ext.form.NumberField); Ext.form.DateField = Ext.extend(Ext.form.TriggerField,  {          format : "m/d/Y",          altFormats : "m/d/Y|n/j/Y|n/j/y|m/j/y|n/d/y|m/j/Y|n/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d|Y-m-d",          disabledDaysText : "Disabled",          disabledDatesText : "Disabled",          minText : "The date in this field must be equal to or after {0}",          maxText : "The date in this field must be equal to or before {0}",          invalidText : "{0} is not a valid date - it must be in the format {1}",          triggerClass : 'x-form-date-trigger',          showToday : true,                                  defaultAutoCreate : {tag: "input", type: "text", size: "10", autocomplete: "off"},     initComponent : function(){         Ext.form.DateField.superclass.initComponent.call(this);         if(typeof this.minValue == "string"){             this.minValue = this.parseDate(this.minValue);         }         if(typeof this.maxValue == "string"){             this.maxValue = this.parseDate(this.maxValue);         }         this.ddMatch = null;         this.initDisabledDays();     },         initDisabledDays : function(){         if(this.disabledDates){             var dd = this.disabledDates;             var re = "(?:";             for(var i = 0; i < dd.length; i++){                 re += dd[i];                 if(i != dd.length-1) re += "|";             }             this.disabledDatesRE = new RegExp(re + ")");         }     },          setDisabledDates : function(dd){         this.disabledDates = dd;         this.initDisabledDays();         if(this.menu){             this.menu.picker.setDisabledDates(this.disabledDatesRE);         }     },          setDisabledDays : function(dd){         this.disabledDays = dd;         if(this.menu){             this.menu.picker.setDisabledDays(dd);         }     },          setMinValue : function(dt){         this.minValue = (typeof dt == "string" ? this.parseDate(dt) : dt);         if(this.menu){             this.menu.picker.setMinDate(this.minValue);         }     },          setMaxValue : function(dt){         this.maxValue = (typeof dt == "string" ? this.parseDate(dt) : dt);         if(this.menu){             this.menu.picker.setMaxDate(this.maxValue);         }     },         validateValue : function(value){         value = this.formatDate(value);         if(!Ext.form.DateField.superclass.validateValue.call(this, value)){             return false;         }         if(value.length < 1){              return true;         }         var svalue = value;         value = this.parseDate(value);         if(!value){             this.markInvalid(String.format(this.invalidText, svalue, this.format));             return false;         }         var time = value.getTime();         if(this.minValue && time < this.minValue.getTime()){             this.markInvalid(String.format(this.minText, this.formatDate(this.minValue)));             return false;         }         if(this.maxValue && time > this.maxValue.getTime()){             this.markInvalid(String.format(this.maxText, this.formatDate(this.maxValue)));             return false;         }         if(this.disabledDays){             var day = value.getDay();             for(var i = 0; i < this.disabledDays.length; i++) {              if(day === this.disabledDays[i]){                  this.markInvalid(this.disabledDaysText);                     return false;              }             }         }         var fvalue = this.formatDate(value);         if(this.ddMatch && this.ddMatch.test(fvalue)){             this.markInvalid(String.format(this.disabledDatesText, fvalue));             return false;         }         return true;     },             validateBlur : function(){         return !this.menu || !this.menu.isVisible();     },          getValue : function(){         return this.parseDate(Ext.form.DateField.superclass.getValue.call(this)) || "";     },          setValue : function(date){         Ext.form.DateField.superclass.setValue.call(this, this.formatDate(this.parseDate(date)));     },         parseDate : function(value){         if(!value || Ext.isDate(value)){             return value;         }         var v = Date.parseDate(value, this.format);         if(!v && this.altFormats){             if(!this.altFormatsArray){                 this.altFormatsArray = this.altFormats.split("|");             }             for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){                 v = Date.parseDate(value, this.altFormatsArray[i]);             }         }         return v;     },         onDestroy : function(){         if(this.menu) {             this.menu.destroy();         }         if(this.wrap){             this.wrap.remove();         }         Ext.form.DateField.superclass.onDestroy.call(this);     },         formatDate : function(date){         return Ext.isDate(date) ? date.dateFormat(this.format) : date;     },         menuListeners : {         select: function(m, d){             this.setValue(d);         },         show : function(){             this.onFocus();         },         hide : function(){             this.focus.defer(10, this);             var ml = this.menuListeners;             this.menu.un("select", ml.select,  this);             this.menu.un("show", ml.show,  this);             this.menu.un("hide", ml.hide,  this);         }     },                  onTriggerClick : function(){         if(this.disabled){             return;         }         if(this.menu == null){             this.menu = new Ext.menu.DateMenu();         }         Ext.apply(this.menu.picker,  {             minDate : this.minValue,             maxDate : this.maxValue,             disabledDatesRE : this.ddMatch,             disabledDatesText : this.disabledDatesText,             disabledDays : this.disabledDays,             disabledDaysText : this.disabledDaysText,             format : this.format,             showToday : this.showToday,             minText : String.format(this.minText, this.formatDate(this.minValue)),             maxText : String.format(this.maxText, this.formatDate(this.maxValue))         });         this.menu.on(Ext.apply({}, this.menuListeners, {             scope:this         }));         this.menu.picker.setValue(this.getValue() || new Date());         this.menu.show(this.el, "tl-bl?");     },         beforeBlur : function(){         var v = this.parseDate(this.getRawValue());         if(v){             this.setValue(v);         }     }                     }); Ext.reg('datefield', Ext.form.DateField); Ext.form.ComboBox = Ext.extend(Ext.form.TriggerField, {                                  defaultAutoCreate : {tag: "input", type: "text", size: "24", autocomplete: "off"},                                   listClass: '',          selectedClass: 'x-combo-selected',          triggerClass : 'x-form-arrow-trigger',          shadow:'sides',          listAlign: 'tl-bl?',          maxHeight: 300,          minHeight: 90,          triggerAction: 'query',          minChars : 4,          typeAhead: false,          queryDelay: 500,          pageSize: 0,          selectOnFocus:false,          queryParam: 'query',          loadingText: 'Loading...',          resizable: false,          handleHeight : 8,          editable: true,          allQuery: '',          mode: 'remote',          minListWidth : 70,          forceSelection:false,          typeAheadDelay : 250,               lazyInit : true,         initComponent : function(){         Ext.form.ComboBox.superclass.initComponent.call(this);         this.addEvents(                          'expand',                          'collapse',                          'beforeselect',                          'select',                          'beforequery'         );         if(this.transform){             this.allowDomMove = false;             var s = Ext.getDom(this.transform);             if(!this.hiddenName){                 this.hiddenName = s.name;             }             if(!this.store){                 this.mode = 'local';                 var d = [], opts = s.options;                 for(var i = 0, len = opts.length;i < len; i++){                     var o = opts[i];                     var value = (Ext.isIE ? o.getAttributeNode('value').specified : o.hasAttribute('value')) ? o.value : o.text;                     if(o.selected) {                         this.value = value;                     }                     d.push([value, o.text]);                 }                 this.store = new Ext.data.SimpleStore({                     'id': 0,                     fields: ['value', 'text'],                     data : d                 });                 this.valueField = 'value';                 this.displayField = 'text';             }             s.name = Ext.id();             if(!this.lazyRender){                 this.target = true;                 this.el = Ext.DomHelper.insertBefore(s, this.autoCreate || this.defaultAutoCreate);                 Ext.removeNode(s);                 this.render(this.el.parentNode);             }else{                 Ext.removeNode(s);             }         }                 else if(Ext.isArray(this.store)){ if (Ext.isArray(this.store[0])){ this.store = new Ext.data.SimpleStore({     fields: ['value','text'],     data: this.store });         this.valueField = 'value'; }else{ this.store = new Ext.data.SimpleStore({     fields: ['text'],     data: this.store,     expandData: true });         this.valueField = 'text'; } this.displayField = 'text'; this.mode = 'local'; }         this.selectedIndex = -1;         if(this.mode == 'local'){             if(this.initialConfig.queryDelay === undefined){                 this.queryDelay = 10;             }             if(this.initialConfig.minChars === undefined){                 this.minChars = 0;             }         }     },         onRender : function(ct, position){         Ext.form.ComboBox.superclass.onRender.call(this, ct, position);         if(this.hiddenName){             this.hiddenField = this.el.insertSibling({tag:'input', type:'hidden', name: this.hiddenName,                     id: (this.hiddenId||this.hiddenName)}, 'before', true);                         this.el.dom.removeAttribute('name');         }         if(Ext.isGecko){             this.el.dom.setAttribute('autocomplete', 'off');         }         if(!this.lazyInit){             this.initList();         }else{             this.on('focus', this.initList, this, {single: true});         }         if(!this.editable){             this.editable = true;             this.setEditable(false);         }     },         initValue : function(){         Ext.form.ComboBox.superclass.initValue.call(this);         if(this.hiddenField){     this.hiddenField.value =         this.hiddenValue !== undefined ? this.hiddenValue :         this.value !== undefined ? this.value : '';         }     },         initList : function(){         if(!this.list){             var cls = 'x-combo-list';             this.list = new Ext.Layer({                 shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false             });             var lw = this.listWidth || Math.max(this.wrap.getWidth(), this.minListWidth);             this.list.setWidth(lw);             this.list.swallowEvent('mousewheel');             this.assetHeight = 0;             if(this.title){                 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});                 this.assetHeight += this.header.getHeight();             }             this.innerList = this.list.createChild({cls:cls+'-inner'});             this.innerList.on('mouseover', this.onViewOver, this);             this.innerList.on('mousemove', this.onViewMove, this);             this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));             if(this.pageSize){                 this.footer = this.list.createChild({cls:cls+'-ft'});                 this.pageTb = new Ext.PagingToolbar({                     store:this.store,                     pageSize: this.pageSize,                     renderTo:this.footer                 });                 this.assetHeight += this.footer.getHeight();             }             if(!this.tpl){                                  this.tpl = '<tpl for="."><div class="'+cls+'-item">{' + this.displayField + '}</div></tpl>';                              }                          this.view = new Ext.DataView({                 applyTo: this.innerList,                 tpl: this.tpl,                 singleSelect: true,                 selectedClass: this.selectedClass,                 itemSelector: this.itemSelector || '.' + cls + '-item'             });             this.view.on('click', this.onViewClick, this);             this.bindStore(this.store, true);             if(this.resizable){                 this.resizer = new Ext.Resizable(this.list,  {                    pinned:true, handles:'se'                 });                 this.resizer.on('resize', function(r, w, h){                     this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;                     this.listWidth = w;                     this.innerList.setWidth(w - this.list.getFrameWidth('lr'));                     this.restrictHeight();                 }, this);                 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');             }         }     },         bindStore : function(store, initial){         if(this.store && !initial){             this.store.un('beforeload', this.onBeforeLoad, this);             this.store.un('load', this.onLoad, this);             this.store.un('loadexception', this.collapse, this);             if(!store){                 this.store = null;                 if(this.view){                     this.view.setStore(null);                 }             }         }         if(store){             this.store = Ext.StoreMgr.lookup(store);             this.store.on('beforeload', this.onBeforeLoad, this);             this.store.on('load', this.onLoad, this);             this.store.on('loadexception', this.collapse, this);             if(this.view){                 this.view.setStore(store);             }         }     },         initEvents : function(){         Ext.form.ComboBox.superclass.initEvents.call(this);         this.keyNav = new Ext.KeyNav(this.el, {             "up" : function(e){                 this.inKeyMode = true;                 this.selectPrev();             },             "down" : function(e){                 if(!this.isExpanded()){                     this.onTriggerClick();                 }else{                     this.inKeyMode = true;                     this.selectNext();                 }             },             "enter" : function(e){                 this.onViewClick();                 this.delayedCheck = true;                 this.unsetDelayCheck.defer(10, this);             },             "esc" : function(e){                 this.collapse();             },             "tab" : function(e){                 this.onViewClick(false);                 return true;             },             scope : this,             doRelay : function(foo, bar, hname){                 if(hname == 'down' || this.scope.isExpanded()){                    return Ext.KeyNav.prototype.doRelay.apply(this, arguments);                 }                 return true;             },             forceKeyDown : true         });         this.queryDelay = Math.max(this.queryDelay || 10,                 this.mode == 'local' ? 10 : 250);         this.dqTask = new Ext.util.DelayedTask(this.initQuery, this);         if(this.typeAhead){             this.taTask = new Ext.util.DelayedTask(this.onTypeAhead, this);         }         if(this.editable !== false){             this.el.on("keyup", this.onKeyUp, this);         }         if(this.forceSelection){             this.on('blur', this.doForce, this);         }     },         onDestroy : function(){         if(this.view){             this.view.el.removeAllListeners();             this.view.el.remove();             this.view.purgeListeners();         }         if(this.list){             this.list.destroy();         }         this.bindStore(null);         Ext.form.ComboBox.superclass.onDestroy.call(this);     },         unsetDelayCheck : function(){         delete this.delayedCheck;     },         fireKey : function(e){         if(e.isNavKeyPress() && !this.isExpanded() && !this.delayedCheck){             this.fireEvent("specialkey", this, e);         }     },         onResize: function(w, h){         Ext.form.ComboBox.superclass.onResize.apply(this, arguments);         if(this.list && this.listWidth === undefined){             var lw = Math.max(w, this.minListWidth);             this.list.setWidth(lw);             this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));         }     },         onEnable: function(){         Ext.form.ComboBox.superclass.onEnable.apply(this, arguments);         if(this.hiddenField){             this.hiddenField.disabled = false;         }     },         onDisable: function(){         Ext.form.ComboBox.superclass.onDisable.apply(this, arguments);         if(this.hiddenField){             this.hiddenField.disabled = true;         }     },          setEditable : function(value){         if(value == this.editable){             return;         }         this.editable = value;         if(!value){             this.el.dom.setAttribute('readOnly', true);             this.el.on('mousedown', this.onTriggerClick,  this);             this.el.addClass('x-combo-noedit');         }else{             this.el.dom.setAttribute('readOnly', false);             this.el.un('mousedown', this.onTriggerClick,  this);             this.el.removeClass('x-combo-noedit');         }     },         onBeforeLoad : function(){         if(!this.hasFocus){             return;         }         this.innerList.update(this.loadingText ?                '<div class="loading-indicator">'+this.loadingText+'</div>' : '');         this.restrictHeight();         this.selectedIndex = -1;     },         onLoad : function(){         if(!this.hasFocus){             return;         }         if(this.store.getCount() > 0){             this.expand();             this.restrictHeight();             if(this.lastQuery == this.allQuery){                 if(this.editable){                     this.el.dom.select();                 }                 if(!this.selectByValue(this.value, true)){                     this.select(0, true);                 }             }else{                 this.selectNext();                 if(this.typeAhead && this.lastKey != Ext.EventObject.BACKSPACE && this.lastKey != Ext.EventObject.DELETE){                     this.taTask.delay(this.typeAheadDelay);                 }             }         }else{             this.onEmptyResults();         }             },         onTypeAhead : function(){         if(this.store.getCount() > 0){             var r = this.store.getAt(0);             var newValue = r.data[this.displayField];             var len = newValue.length;             var selStart = this.getRawValue().length;             if(selStart != len){                 this.setRawValue(newValue);                 this.selectText(selStart, newValue.length);             }         }     },         onSelect : function(record, index){         if(this.fireEvent('beforeselect', this, record, index) !== false){             this.setValue(record.data[this.valueField || this.displayField]);             this.collapse();             this.fireEvent('select', this, record, index);         }     },          getValue : function(){         if(this.valueField){             return typeof this.value != 'undefined' ? this.value : '';         }else{             return Ext.form.ComboBox.superclass.getValue.call(this);         }     },          clearValue : function(){         if(this.hiddenField){             this.hiddenField.value = '';         }         this.setRawValue('');         this.lastSelectionText = '';         this.applyEmptyText();         this.value = '';     },          setValue : function(v){         var text = v;         if(this.valueField){             var r = this.findRecord(this.valueField, v);             if(r){                 text = r.data[this.displayField];             }else if(this.valueNotFoundText !== undefined){                 text = this.valueNotFoundText;             }         }         this.lastSelectionText = text;         if(this.hiddenField){             this.hiddenField.value = v;         }         Ext.form.ComboBox.superclass.setValue.call(this, text);         this.value = v;     },         findRecord : function(prop, value){         var record;         if(this.store.getCount() > 0){             this.store.each(function(r){                 if(r.data[prop] == value){                     record = r;                     return false;                 }             });         }         return record;     },         onViewMove : function(e, t){         this.inKeyMode = false;     },         onViewOver : function(e, t){         if(this.inKeyMode){             return;         }         var item = this.view.findItemFromChild(t);         if(item){             var index = this.view.indexOf(item);             this.select(index, false);         }     },         onViewClick : function(doFocus){         var index = this.view.getSelectedIndexes()[0];         var r = this.store.getAt(index);         if(r){             this.onSelect(r, index);         }         if(doFocus !== false){             this.el.focus();         }     },         restrictHeight : function(){         this.innerList.dom.style.height = '';         var inner = this.innerList.dom;         var pad = this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight;         var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);         var ha = this.getPosition()[1]-Ext.getBody().getScroll().top;         var hb = Ext.lib.Dom.getViewHeight()-ha-this.getSize().height;         var space = Math.max(ha, hb, this.minHeight || 0)-this.list.shadowOffset-pad-5;         h = Math.min(h, space, this.maxHeight);         this.innerList.setHeight(h);         this.list.beginUpdate();         this.list.setHeight(h+pad);         this.list.alignTo(this.wrap, this.listAlign);         this.list.endUpdate();     },         onEmptyResults : function(){         this.collapse();     },          isExpanded : function(){         return this.list && this.list.isVisible();     },          selectByValue : function(v, scrollIntoView){         if(v !== undefined && v !== null){             var r = this.findRecord(this.valueField || this.displayField, v);             if(r){                 this.select(this.store.indexOf(r), scrollIntoView);                 return true;             }         }         return false;     },          select : function(index, scrollIntoView){         this.selectedIndex = index;         this.view.select(index);         if(scrollIntoView !== false){             var el = this.view.getNode(index);             if(el){                 this.innerList.scrollChildIntoView(el, false);             }         }     },         selectNext : function(){         var ct = this.store.getCount();         if(ct > 0){             if(this.selectedIndex == -1){                 this.select(0);             }else if(this.selectedIndex < ct-1){                 this.select(this.selectedIndex+1);             }         }     },         selectPrev : function(){         var ct = this.store.getCount();         if(ct > 0){             if(this.selectedIndex == -1){                 this.select(0);             }else if(this.selectedIndex != 0){                 this.select(this.selectedIndex-1);             }         }     },         onKeyUp : function(e){         if(this.editable !== false && !e.isSpecialKey()){             this.lastKey = e.getKey();             this.dqTask.delay(this.queryDelay);         }     },         validateBlur : function(){         return !this.list || !this.list.isVisible();     },         initQuery : function(){         this.doQuery(this.getRawValue());     },         doForce : function(){         if(this.el.dom.value.length > 0){             this.el.dom.value =                 this.lastSelectionText === undefined ? '' : this.lastSelectionText;             this.applyEmptyText();         }     },          doQuery : function(q, forceAll){         if(q === undefined || q === null){             q = '';         }         var qe = {             query: q,             forceAll: forceAll,             combo: this,             cancel:false         };         if(this.fireEvent('beforequery', qe)===false || qe.cancel){             return false;         }         q = qe.query;         forceAll = qe.forceAll;         if(forceAll === true || (q.length >= this.minChars)){             if(this.lastQuery !== q){                 this.lastQuery = q;                 if(this.mode == 'local'){                     this.selectedIndex = -1;                     if(forceAll){                         this.store.clearFilter();                     }else{                         this.store.filter(this.displayField, q);                     }                     this.onLoad();                 }else{                     this.store.baseParams[this.queryParam] = q;                     this.store.load({                         params: this.getParams(q)                     });                     this.expand();                 }             }else{                 this.selectedIndex = -1;                 this.onLoad();             }         }     },         getParams : function(q){         var p = {};                 if(this.pageSize){             p.start = 0;             p.limit = this.pageSize;         }         return p;     },          collapse : function(){         if(!this.isExpanded()){             return;         }         this.list.hide();         Ext.getDoc().un('mousewheel', this.collapseIf, this);         Ext.getDoc().un('mousedown', this.collapseIf, this);         this.fireEvent('collapse', this);     },         collapseIf : function(e){         if(!e.within(this.wrap) && !e.within(this.list)){             this.collapse();         }     },          expand : function(){         if(this.isExpanded() || !this.hasFocus){             return;         }         this.list.alignTo(this.wrap, this.listAlign);         this.list.show();         this.innerList.setOverflow('auto');         Ext.getDoc().on('mousewheel', this.collapseIf, this);         Ext.getDoc().on('mousedown', this.collapseIf, this);         this.fireEvent('expand', this);     },                  onTriggerClick : function(){         if(this.disabled){             return;         }         if(this.isExpanded()){             this.collapse();             this.el.focus();         }else {             this.onFocus({});             if(this.triggerAction == 'all') {                 this.doQuery(this.allQuery, true);             } else {                 this.doQuery(this.getRawValue());             }             this.el.focus();         }     }                     }); Ext.reg('combo', Ext.form.ComboBox); Ext.form.Checkbox = Ext.extend(Ext.form.Field,  {          checkedCls: 'x-form-check-checked',          focusCls: 'x-form-check-focus',          overCls: 'x-form-check-over',          mouseDownCls: 'x-form-check-down',          tabIndex: 0,          checked: false,          defaultAutoCreate: {tag: 'input', type: 'checkbox', autocomplete: 'off'},                        baseCls: 'x-form-check',         initComponent : function(){         Ext.form.Checkbox.superclass.initComponent.call(this);         this.addEvents(                          'check'         );     },         initEvents : function(){         Ext.form.Checkbox.superclass.initEvents.call(this);         this.initCheckEvents();     },         initCheckEvents : function(){         this.innerWrap.removeAllListeners();         this.innerWrap.addClassOnOver(this.overCls);         this.innerWrap.addClassOnClick(this.mouseDownCls);         this.innerWrap.on('click', this.onClick, this);         this.innerWrap.on('keyup', this.onKeyUp, this);     },         onRender : function(ct, position){         Ext.form.Checkbox.superclass.onRender.call(this, ct, position);         if(this.inputValue !== undefined){             this.el.dom.value = this.inputValue;         }         this.el.addClass('x-hidden');         this.innerWrap = this.el.wrap({             tabIndex: this.tabIndex,             cls: this.baseCls+'-wrap-inner'         });         this.wrap = this.innerWrap.wrap({cls: this.baseCls+'-wrap'});         if(this.boxLabel){             this.labelEl = this.innerWrap.createChild({                 tag: 'label',                 htmlFor: this.el.id,                 cls: 'x-form-cb-label',                 html: this.boxLabel             });         }         this.imageEl = this.innerWrap.createChild({             tag: 'img',             src: Ext.BLANK_IMAGE_URL,             cls: this.baseCls         }, this.el);         if(this.checked){             this.setValue(true);         }else{             this.checked = this.el.dom.checked;         }         this.originalValue = this.checked;     },         onDestroy : function(){         if(this.rendered){             Ext.destroy(this.imageEl, this.labelEl, this.innerWrap, this.wrap);         }         Ext.form.Checkbox.superclass.onDestroy.call(this);     },         onFocus: function(e) {         Ext.form.Checkbox.superclass.onFocus.call(this, e);         this.el.addClass(this.focusCls);     },         onBlur: function(e) {         Ext.form.Checkbox.superclass.onBlur.call(this, e);         this.el.removeClass(this.focusCls);     },         onResize : function(){         Ext.form.Checkbox.superclass.onResize.apply(this, arguments);         if(!this.boxLabel && !this.fieldLabel){             this.el.alignTo(this.wrap, 'c-c');         }     },         onKeyUp : function(e){         if(e.getKey() == Ext.EventObject.SPACE){             this.onClick(e);         }     },         onClick : function(e){         if (!this.disabled && !this.readOnly) {             this.toggleValue();         }         e.stopEvent();     },         onEnable : function(){         Ext.form.Checkbox.superclass.onEnable.call(this);         this.initCheckEvents();     },         onDisable : function(){         Ext.form.Checkbox.superclass.onDisable.call(this);         this.innerWrap.removeAllListeners();     },     toggleValue : function(){         this.setValue(!this.checked);     },         getResizeEl : function(){         if(!this.resizeEl){             this.resizeEl = Ext.isSafari ? this.wrap : (this.wrap.up('.x-form-element', 5) || this.wrap);         }         return this.resizeEl;     },         getPositionEl : function(){         return this.wrap;     },         getActionEl : function(){         return this.wrap;     },          markInvalid : Ext.emptyFn,          clearInvalid : Ext.emptyFn,         initValue : Ext.emptyFn,          getValue : function(){         if(this.rendered){             return this.el.dom.checked;         }         return false;     },          setValue : function(v) {         var checked = this.checked;         this.checked = (v === true || v === 'true' || v == '1' || String(v).toLowerCase() == 'on');                  if(this.el && this.el.dom){             this.el.dom.checked = this.checked;             this.el.dom.defaultChecked = this.checked;         }         this.wrap[this.checked? 'addClass' : 'removeClass'](this.checkedCls);                  if(checked != this.checked){             this.fireEvent("check", this, this.checked);             if(this.handler){                 this.handler.call(this.scope || this, this, this.checked);             }         }     }                }); Ext.reg('checkbox', Ext.form.Checkbox); Ext.form.CheckboxGroup = Ext.extend(Ext.form.Field, {          columns : 'auto',          vertical : false,          allowBlank : true,          blankText : "You must select at least one item in this group",              defaultType : 'checkbox',              groupCls: 'x-form-check-group',              onRender : function(ct, position){         if(!this.el){             var panelCfg = {                 cls: this.groupCls,                 layout: 'column',                 border: false,                 renderTo: ct             };             var colCfg = {                 defaultType: this.defaultType,                 layout: 'form',                 border: false,                 defaults: {                     hideLabel: true,                     anchor: '100%'                 }             }                          if(this.items[0].items){                                                                   Ext.apply(panelCfg, {                     layoutConfig: {columns: this.items.length},                     defaults: this.defaults,                     items: this.items                 })                 for(var i=0, len=this.items.length; i<len; i++){                     Ext.applyIf(this.items[i], colCfg);                 };                              }else{                                                                                   var numCols, cols = [];                                  if(typeof this.columns == 'string'){                     this.columns = this.items.length;                 }                 if(!Ext.isArray(this.columns)){                     var cs = [];                     for(var i=0; i<this.columns; i++){                         cs.push((100/this.columns)*.01);                     }                     this.columns = cs;                 }                                  numCols = this.columns.length;                                                  for(var i=0; i<numCols; i++){                     var cc = Ext.apply({items:[]}, colCfg);                     cc[this.columns[i] <= 1 ? 'columnWidth' : 'width'] = this.columns[i];                     if(this.defaults){                         cc.defaults = Ext.apply(cc.defaults || {}, this.defaults)                     }                     cols.push(cc);                 };                                                  if(this.vertical){                     var rows = Math.ceil(this.items.length / numCols), ri = 0;                     for(var i=0, len=this.items.length; i<len; i++){                         if(i>0 && i%rows==0){                             ri++;                         }                         if(this.items[i].fieldLabel){                             this.items[i].hideLabel = false;                         }                         cols[ri].items.push(this.items[i]);                     };                 }else{                     for(var i=0, len=this.items.length; i<len; i++){                         var ci = i % numCols;                         if(this.items[i].fieldLabel){                             this.items[i].hideLabel = false;                         }                         cols[ci].items.push(this.items[i]);                     };                 }                                  Ext.apply(panelCfg, {                     layoutConfig: {columns: numCols},                     items: cols                 });             }                          this.panel = new Ext.Panel(panelCfg);             this.el = this.panel.getEl();                          if(this.forId && this.itemCls){                 var l = this.el.up(this.itemCls).child('label', true);                 if(l){                     l.setAttribute('htmlFor', this.forId);                 }             }                          var fields = this.panel.findBy(function(c){                 return c.isFormField;             }, this);                          this.items = new Ext.util.MixedCollection();             this.items.addAll(fields);         }         Ext.form.CheckboxGroup.superclass.onRender.call(this, ct, position);     },              validateValue : function(value){         if(!this.allowBlank){             var blank = true;             this.items.each(function(f){                 if(f.checked){                     return blank = false;                 }             }, this);             if(blank){                 this.markInvalid(this.blankText);                 return false;             }         }         return true;     },              onDisable : function(){         this.items.each(function(item){             item.disable();         })     },         onEnable : function(){         this.items.each(function(item){             item.enable();         })     },              onResize : function(w, h){         this.panel.setSize(w, h);         this.panel.doLayout();     },              reset : function(){         Ext.form.CheckboxGroup.superclass.reset.call(this);         this.items.each(function(c){             if(c.reset){                 c.reset();             }         }, this);     },                    initValue : Ext.emptyFn,          getValue : Ext.emptyFn,          getRawValue : Ext.emptyFn,          setValue : Ext.emptyFn,          setRawValue : Ext.emptyFn      }); Ext.reg('checkboxgroup', Ext.form.CheckboxGroup); Ext.form.Radio = Ext.extend(Ext.form.Checkbox, {         inputType: 'radio',         baseCls: 'x-form-radio',               getGroupValue : function(){         var c = this.getParent().child('input[name='+this.el.dom.name+']:checked', true);         return c ? c.value : null;     },              getParent : function(){         return this.el.up('form') || Ext.getBody();     },         toggleValue : function() {         if(!this.checked){             var els = this.getParent().select('input[name='+this.el.dom.name+']');             els.each(function(el){                 if(el.dom.id == this.id){                     this.setValue(true);                 }else{                     Ext.getCmp(el.dom.id).setValue(false);                 }             }, this);         }     },               setValue : function(v){         if(typeof v=='boolean') {             Ext.form.Radio.superclass.setValue.call(this, v);         }else{             var r = this.getParent().child('input[name='+this.el.dom.name+'][value='+v+']', true);             if(r && !r.checked){                 Ext.getCmp(r.id).toggleValue();             };         }     },               markInvalid : Ext.emptyFn,          clearInvalid : Ext.emptyFn      }); Ext.reg('radio', Ext.form.Radio); Ext.form.RadioGroup = Ext.extend(Ext.form.CheckboxGroup, {          allowBlank : true,          blankText : "You must select one item in this group",              defaultType : 'radio',              groupCls: 'x-form-radio-group' }); Ext.reg('radiogroup', Ext.form.RadioGroup);
  602. Ext.form.Hidden = Ext.extend(Ext.form.Field, {
  603.          inputType : 'hidden',
  604.          onRender : function(){
  605.         Ext.form.Hidden.superclass.onRender.apply(this, arguments);
  606.     },
  607.          initEvents : function(){
  608.         this.originalValue = this.getValue();
  609.     },
  610.          setSize : Ext.emptyFn,
  611.     setWidth : Ext.emptyFn,
  612.     setHeight : Ext.emptyFn,
  613.     setPosition : Ext.emptyFn,
  614.     setPagePosition : Ext.emptyFn,
  615.     markInvalid : Ext.emptyFn,
  616.     clearInvalid : Ext.emptyFn
  617. });
  618. Ext.reg('hidden', Ext.form.Hidden); Ext.form.BasicForm = function(el, config){     Ext.apply(this, config);          this.items = new Ext.util.MixedCollection(false, function(o){         return o.id || (o.id = Ext.id());     });     this.addEvents(                  'beforeaction',                  'actionfailed',                  'actioncomplete'     );     if(el){         this.initEl(el);     }     Ext.form.BasicForm.superclass.constructor.call(this); }; Ext.extend(Ext.form.BasicForm, Ext.util.Observable, {                                        timeout: 30,         activeAction : null,          trackResetOnLoad : false,                   initEl : function(el){         this.el = Ext.get(el);         this.id = this.el.id || Ext.id();         if(!this.standardSubmit){             this.el.on('submit', this.onSubmit, this);         }         this.el.addClass('x-form');     },          getEl: function(){         return this.el;     },         onSubmit : function(e){         e.stopEvent();     },      destroy: function() {         this.items.each(function(f){             Ext.destroy(f);         });         if(this.el){ this.el.removeAllListeners(); this.el.remove();         } this.purgeListeners(); },          isValid : function(){         var valid = true;         this.items.each(function(f){            if(!f.validate()){                valid = false;            }         });         return valid;     },          isDirty : function(){         var dirty = false;         this.items.each(function(f){            if(f.isDirty()){                dirty = true;                return false;            }         });         return dirty;     },          doAction : function(action, options){         if(typeof action == 'string'){             action = new Ext.form.Action.ACTION_TYPES[action](this, options);         }         if(this.fireEvent('beforeaction', this, action) !== false){             this.beforeAction(action);             action.run.defer(100, action);         }         return this;     },          submit : function(options){         if(this.standardSubmit){             var v = this.isValid();             if(v){                 this.el.dom.submit();             }             return v;         }         this.doAction('submit', options);         return this;     },          load : function(options){         this.doAction('load', options);         return this;     },          updateRecord : function(record){         record.beginEdit();         var fs = record.fields;         fs.each(function(f){             var field = this.findField(f.name);             if(field){                 record.set(f.name, field.getValue());             }         }, this);         record.endEdit();         return this;     },          loadRecord : function(record){         this.setValues(record.data);         return this;     },         beforeAction : function(action){         var o = action.options;         if(o.waitMsg){             if(this.waitMsgTarget === true){                 this.el.mask(o.waitMsg, 'x-mask-loading');             }else if(this.waitMsgTarget){                 this.waitMsgTarget = Ext.get(this.waitMsgTarget);                 this.waitMsgTarget.mask(o.waitMsg, 'x-mask-loading');             }else{                 Ext.MessageBox.wait(o.waitMsg, o.waitTitle || this.waitTitle || 'Please Wait...');             }         }     },         afterAction : function(action, success){         this.activeAction = null;         var o = action.options;         if(o.waitMsg){             if(this.waitMsgTarget === true){                 this.el.unmask();             }else if(this.waitMsgTarget){                 this.waitMsgTarget.unmask();             }else{                 Ext.MessageBox.updateProgress(1);                 Ext.MessageBox.hide();             }         }         if(success){             if(o.reset){                 this.reset();             }             Ext.callback(o.success, o.scope, [this, action]);             this.fireEvent('actioncomplete', this, action);         }else{             Ext.callback(o.failure, o.scope, [this, action]);             this.fireEvent('actionfailed', this, action);         }     },          findField : function(id){         var field = this.items.get(id);         if(!field){             this.items.each(function(f){                 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){                     field = f;                     return false;                 }             });         }         return field || null;     },          markInvalid : function(errors){         if(Ext.isArray(errors)){             for(var i = 0, len = errors.length; i < len; i++){                 var fieldError = errors[i];                 var f = this.findField(fieldError.id);                 if(f){                     f.markInvalid(fieldError.msg);                 }             }         }else{             var field, id;             for(id in errors){                 if(typeof errors[id] != 'function' && (field = this.findField(id))){                     field.markInvalid(errors[id]);                 }             }         }         return this;     },          setValues : function(values){         if(Ext.isArray(values)){             for(var i = 0, len = values.length; i < len; i++){                 var v = values[i];                 var f = this.findField(v.id);                 if(f){                     f.setValue(v.value);                     if(this.trackResetOnLoad){                         f.originalValue = f.getValue();                     }                 }             }         }else{             var field, id;             for(id in values){                 if(typeof values[id] != 'function' && (field = this.findField(id))){                     field.setValue(values[id]);                     if(this.trackResetOnLoad){                         field.originalValue = field.getValue();                     }                 }             }         }         return this;     },          getValues : function(asString){         var fs = Ext.lib.Ajax.serializeForm(this.el.dom);         if(asString === true){             return fs;         }         return Ext.urlDecode(fs);     },          clearInvalid : function(){         this.items.each(function(f){            f.clearInvalid();         });         return this;     },          reset : function(){         this.items.each(function(f){             f.reset();         });         return this;     },          add : function(){         this.items.addAll(Array.prototype.slice.call(arguments, 0));         return this;     },          remove : function(field){         this.items.remove(field);         return this;     },          render : function(){         this.items.each(function(f){             if(f.isFormField && !f.rendered && document.getElementById(f.id)){                 f.applyToMarkup(f.id);             }         });         return this;     },          applyToFields : function(o){         this.items.each(function(f){            Ext.apply(f, o);         });         return this;     },          applyIfToFields : function(o){         this.items.each(function(f){            Ext.applyIf(f, o);         });         return this;     } }); Ext.BasicForm = Ext.form.BasicForm; Ext.FormPanel = Ext.extend(Ext.Panel, {                    buttonAlign:'center',          minButtonWidth:75,          labelAlign:'left',          monitorValid : false,          monitorPoll : 200,          layout: 'form',         initComponent :function(){         this.form = this.createForm();         this.bodyCfg = {             tag: 'form',             cls: this.baseCls + '-body',             method : this.method || 'POST',             id : this.formId || Ext.id()         };         if(this.fileUpload) {             this.bodyCfg.enctype = 'multipart/form-data';         }         Ext.FormPanel.superclass.initComponent.call(this);         this.addEvents(                          'clientvalidation'         );         this.relayEvents(this.form, ['beforeaction', 'actionfailed', 'actioncomplete']);     },         createForm: function(){         delete this.initialConfig.listeners;         return new Ext.form.BasicForm(null, this.initialConfig);     },         initFields : function(){         var f = this.form;         var formPanel = this;         var fn = function(c){             if(c.isFormField){                 f.add(c);             }else if(c.doLayout && c != formPanel){                 Ext.applyIf(c, {                     labelAlign: c.ownerCt.labelAlign,                     labelWidth: c.ownerCt.labelWidth,                     itemCls: c.ownerCt.itemCls                 });                 if(c.items){                     c.items.each(fn);                 }             }         }         this.items.each(fn);     },         getLayoutTarget : function(){         return this.form.el;     },          getForm : function(){         return this.form;     },         onRender : function(ct, position){         this.initFields();         Ext.FormPanel.superclass.onRender.call(this, ct, position);         this.form.initEl(this.body);     },              beforeDestroy: function(){         Ext.FormPanel.superclass.beforeDestroy.call(this);         this.stopMonitoring();         Ext.destroy(this.form);     },         initEvents : function(){         Ext.FormPanel.superclass.initEvents.call(this); this.items.on('remove', this.onRemove, this); this.items.on('add', this.onAdd, this);         if(this.monitorValid){             this.startMonitoring();         }     },           onAdd : function(ct, c) { if (c.isFormField) { this.form.add(c); } }, onRemove : function(c) { if (c.isFormField) { Ext.destroy(c.container.up('.x-form-item')); this.form.remove(c); } },          startMonitoring : function(){         if(!this.bound){             this.bound = true;             Ext.TaskMgr.start({                 run : this.bindHandler,                 interval : this.monitorPoll || 200,                 scope: this             });         }     },          stopMonitoring : function(){         this.bound = false;     },          load : function(){         this.form.load.apply(this.form, arguments);       },         onDisable : function(){         Ext.FormPanel.superclass.onDisable.call(this);         if(this.form){             this.form.items.each(function(){                  this.disable();             });         }     },         onEnable : function(){         Ext.FormPanel.superclass.onEnable.call(this);         if(this.form){             this.form.items.each(function(){                  this.enable();             });         }     },         bindHandler : function(){         if(!this.bound){             return false;         }         var valid = true;         this.form.items.each(function(f){             if(!f.isValid(true)){                 valid = false;                 return false;             }         });         if(this.buttons){             for(var i = 0, len = this.buttons.length; i < len; i++){                 var btn = this.buttons[i];                 if(btn.formBind === true && btn.disabled === valid){                     btn.setDisabled(!valid);                 }             }         }         this.fireEvent('clientvalidation', this, valid);     } }); Ext.reg('form', Ext.FormPanel); Ext.form.FormPanel = Ext.FormPanel;
  619. Ext.form.FieldSet = Ext.extend(Ext.Panel, {
  620.     
  621.     
  622.     
  623.     
  624.     
  625.     baseCls:'x-fieldset',
  626.     
  627.     layout: 'form',
  628.          onRender : function(ct, position){
  629.         if(!this.el){
  630.             this.el = document.createElement('fieldset');
  631.             this.el.id = this.id;
  632.             if (this.title || this.header || this.checkboxToggle) {
  633.                 this.el.appendChild(document.createElement('legend')).className = 'x-fieldset-header';
  634.             }
  635.         }
  636.         Ext.form.FieldSet.superclass.onRender.call(this, ct, position);
  637.         if(this.checkboxToggle){
  638.             var o = typeof this.checkboxToggle == 'object' ?
  639.                     this.checkboxToggle :
  640.                     {tag: 'input', type: 'checkbox', name: this.checkboxName || this.id+'-checkbox'};
  641.             this.checkbox = this.header.insertFirst(o);
  642.             this.checkbox.dom.checked = !this.collapsed;
  643.             this.checkbox.on('click', this.onCheckClick, this);
  644.         }
  645.     },
  646.          onCollapse : function(doAnim, animArg){
  647.         if(this.checkbox){
  648.             this.checkbox.dom.checked = false;
  649.         }
  650.         this.afterCollapse();
  651.     },
  652.          onExpand : function(doAnim, animArg){
  653.         if(this.checkbox){
  654.             this.checkbox.dom.checked = true;
  655.         }
  656.         this.afterExpand();
  657.     },
  658.     
  659.     onCheckClick : function(){
  660.         this[this.checkbox.dom.checked ? 'expand' : 'collapse']();
  661.     }
  662.     
  663.     
  664.     
  665.     
  666.     
  667.     
  668.     
  669.     
  670.     
  671.     
  672.     
  673.     
  674.     
  675.     
  676.     
  677.     
  678.     
  679.     
  680.     
  681.     
  682.     
  683.     
  684.     
  685.     
  686.     
  687.     
  688.     
  689.     
  690.     
  691.     
  692.     
  693.     
  694.     
  695.     
  696.     
  697.     
  698.     
  699. });
  700. Ext.reg('fieldset', Ext.form.FieldSet);
  701. Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, {
  702.     
  703.     enableFormat : true,
  704.     
  705.     enableFontSize : true,
  706.     
  707.     enableColors : true,
  708.     
  709.     enableAlignments : true,
  710.     
  711.     enableLists : true,
  712.     
  713.     enableSourceEdit : true,
  714.     
  715.     enableLinks : true,
  716.     
  717.     enableFont : true,
  718.     
  719.     createLinkText : 'Please enter the URL for the link:',
  720.     
  721.     defaultLinkValue : 'http:/'+'/',
  722.     
  723.     fontFamilies : [
  724.         'Arial',
  725.         'Courier New',
  726.         'Tahoma',
  727.         'Times New Roman',
  728.         'Verdana'
  729.     ],
  730.     defaultFont: 'tahoma',
  731.          validationEvent : false,
  732.     deferHeight: true,
  733.     initialized : false,
  734.     activated : false,
  735.     sourceEditMode : false,
  736.     onFocus : Ext.emptyFn,
  737.     iframePad:3,
  738.     hideMode:'offsets',
  739.     defaultAutoCreate : {
  740.         tag: "textarea",
  741.         style:"width:500px;height:300px;",
  742.         autocomplete: "off"
  743.     },
  744.          initComponent : function(){
  745.         this.addEvents(
  746.             
  747.             'initialize',
  748.             
  749.             'activate',
  750.              
  751.             'beforesync',
  752.              
  753.             'beforepush',
  754.              
  755.             'sync',
  756.              
  757.             'push',
  758.              
  759.             'editmodechange'
  760.         )
  761.     },
  762.          createFontOptions : function(){
  763.         var buf = [], fs = this.fontFamilies, ff, lc;
  764.         for(var i = 0, len = fs.length; i< len; i++){
  765.             ff = fs[i];
  766.             lc = ff.toLowerCase();
  767.             buf.push(
  768.                 '<option value="',lc,'" style="font-family:',ff,';"',
  769.                     (this.defaultFont == lc ? ' selected="true">' : '>'),
  770.                     ff,
  771.                 '</option>'
  772.             );
  773.         }
  774.         return buf.join('');
  775.     },
  776.     
  777.     
  778.     createToolbar : function(editor){
  779.         
  780.         var tipsEnabled = Ext.QuickTips && Ext.QuickTips.isEnabled();
  781.         
  782.         function btn(id, toggle, handler){
  783.             return {
  784.                 itemId : id,
  785.                 cls : 'x-btn-icon x-edit-'+id,
  786.                 enableToggle:toggle !== false,
  787.                 scope: editor,
  788.                 handler:handler||editor.relayBtnCmd,
  789.                 clickEvent:'mousedown',
  790.                 tooltip: tipsEnabled ? editor.buttonTips[id] || undefined : undefined,
  791.                 tabIndex:-1
  792.             };
  793.         }
  794.                  var tb = new Ext.Toolbar({
  795.             renderTo:this.wrap.dom.firstChild
  796.         });
  797.                  tb.el.on('click', function(e){
  798.             e.preventDefault();
  799.         });
  800.         if(this.enableFont && !Ext.isSafari2){
  801.             this.fontSelect = tb.el.createChild({
  802.                 tag:'select',
  803.                 cls:'x-font-select',
  804.                 html: this.createFontOptions()
  805.             });
  806.             this.fontSelect.on('change', function(){
  807.                 var font = this.fontSelect.dom.value;
  808.                 this.relayCmd('fontname', font);
  809.                 this.deferFocus();
  810.             }, this);
  811.             tb.add(
  812.                 this.fontSelect.dom,
  813.                 '-'
  814.             );
  815.         };
  816.         if(this.enableFormat){
  817.             tb.add(
  818.                 btn('bold'),
  819.                 btn('italic'),
  820.                 btn('underline')
  821.             );
  822.         };
  823.         if(this.enableFontSize){
  824.             tb.add(
  825.                 '-',
  826.                 btn('increasefontsize', false, this.adjustFont),
  827.                 btn('decreasefontsize', false, this.adjustFont)
  828.             );
  829.         };
  830.         if(this.enableColors){
  831.             tb.add(
  832.                 '-', {
  833.                     itemId:'forecolor',
  834.                     cls:'x-btn-icon x-edit-forecolor',
  835.                     clickEvent:'mousedown',
  836.                     tooltip: tipsEnabled ? editor.buttonTips['forecolor'] || undefined : undefined,
  837.                     tabIndex:-1,
  838.                     menu : new Ext.menu.ColorMenu({
  839.                         allowReselect: true,
  840.                         focus: Ext.emptyFn,
  841.                         value:'000000',
  842.                         plain:true,
  843.                         selectHandler: function(cp, color){
  844.                             this.execCmd('forecolor', Ext.isSafari || Ext.isIE ? '#'+color : color);
  845.                             this.deferFocus();
  846.                         },
  847.                         scope: this,
  848.                         clickEvent:'mousedown'
  849.                     })
  850.                 }, {
  851.                     itemId:'backcolor',
  852.                     cls:'x-btn-icon x-edit-backcolor',
  853.                     clickEvent:'mousedown',
  854.                     tooltip: tipsEnabled ? editor.buttonTips['backcolor'] || undefined : undefined,
  855.                     tabIndex:-1,
  856.                     menu : new Ext.menu.ColorMenu({
  857.                         focus: Ext.emptyFn,
  858.                         value:'FFFFFF',
  859.                         plain:true,
  860.                         allowReselect: true,
  861.                         selectHandler: function(cp, color){
  862.                             if(Ext.isGecko){
  863.                                 this.execCmd('useCSS', false);
  864.                                 this.execCmd('hilitecolor', color);
  865.                                 this.execCmd('useCSS', true);
  866.                                 this.deferFocus();
  867.                             }else{
  868.                                 this.execCmd(Ext.isOpera ? 'hilitecolor' : 'backcolor', Ext.isSafari || Ext.isIE ? '#'+color : color);
  869.                                 this.deferFocus();
  870.                             }
  871.                         },
  872.                         scope:this,
  873.                         clickEvent:'mousedown'
  874.                     })
  875.                 }
  876.             );
  877.         };
  878.         if(this.enableAlignments){
  879.             tb.add(
  880.                 '-',
  881.                 btn('justifyleft'),
  882.                 btn('justifycenter'),
  883.                 btn('justifyright')
  884.             );
  885.         };
  886.         if(!Ext.isSafari2){
  887.             if(this.enableLinks){
  888.                 tb.add(
  889.                     '-',
  890.                     btn('createlink', false, this.createLink)
  891.                 );
  892.             };
  893.             if(this.enableLists){
  894.                 tb.add(
  895.                     '-',
  896.                     btn('insertorderedlist'),
  897.                     btn('insertunorderedlist')
  898.                 );
  899.             }
  900.             if(this.enableSourceEdit){
  901.                 tb.add(
  902.                     '-',
  903.                     btn('sourceedit', true, function(btn){
  904.                         this.toggleSourceEdit(btn.pressed);
  905.                     })
  906.                 );
  907.             }
  908.         }
  909.         this.tb = tb;
  910.     },
  911.     
  912.     getDocMarkup : function(){
  913.         return '<html><head><style type="text/css">body{border:0;margin:0;padding:3px;height:98%;cursor:text;}</style></head><body></body></html>';
  914.     },
  915.          getEditorBody : function(){
  916.         return this.doc.body || this.doc.documentElement;
  917.     },
  918.          getDoc : function(){
  919.         return Ext.isIE ? this.getWin().document : (this.iframe.contentDocument || this.getWin().document);
  920.     },
  921.          getWin : function(){
  922.         return Ext.isIE ? this.iframe.contentWindow : window.frames[this.iframe.name];
  923.     },
  924.          onRender : function(ct, position){
  925.         Ext.form.HtmlEditor.superclass.onRender.call(this, ct, position);
  926.         this.el.dom.style.border = '0 none';
  927.         this.el.dom.setAttribute('tabIndex', -1);
  928.         this.el.addClass('x-hidden');
  929.         if(Ext.isIE){              this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
  930.         }
  931.         this.wrap = this.el.wrap({
  932.             cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
  933.         });
  934.         this.createToolbar(this);
  935.         this.tb.items.each(function(item){
  936.            if(item.itemId != 'sourceedit'){
  937.                 item.disable();
  938.             }
  939.         });
  940.         var iframe = document.createElement('iframe');
  941.         iframe.name = Ext.id();
  942.         iframe.frameBorder = '0';
  943.         iframe.src = Ext.isIE ? Ext.SSL_SECURE_URL : "javascript:;";
  944.         this.wrap.dom.appendChild(iframe);
  945.         this.iframe = iframe;
  946.         this.initFrame();
  947.         if(this.autoMonitorDesignMode !== false){
  948.             this.monitorTask = Ext.TaskMgr.start({
  949.                 run: this.checkDesignMode,
  950.                 scope: this,
  951.                 interval:100
  952.             });
  953.         }
  954.         if(!this.width){
  955.             var sz = this.el.getSize();
  956.             this.setSize(sz.width, this.height || sz.height);
  957.         }
  958.     },
  959.     initFrame : function(){
  960.         this.doc = this.getDoc();
  961.         this.win = this.getWin();
  962.         this.doc.open();
  963.         this.doc.write(this.getDocMarkup());
  964.         this.doc.close();
  965.         var task = {              run : function(){
  966.                 if(this.doc.body || this.doc.readyState == 'complete'){
  967.                     Ext.TaskMgr.stop(task);
  968.                     this.doc.designMode="on";
  969.                     this.initEditor.defer(10, this);
  970.                 }
  971.             },
  972.             interval : 10,
  973.             duration:10000,
  974.             scope: this
  975.         };
  976.         Ext.TaskMgr.start(task);
  977.     },
  978.     checkDesignMode : function(){
  979.         if(this.wrap && this.wrap.dom.offsetWidth){
  980.             var doc = this.getDoc();
  981.             if(!doc){
  982.                 return;
  983.             }
  984.             if(!doc.editorInitialized || String(doc.designMode).toLowerCase() != 'on'){
  985.                 this.initFrame();
  986.             }
  987.         }
  988.     },
  989.          onResize : function(w, h){
  990.         Ext.form.HtmlEditor.superclass.onResize.apply(this, arguments);
  991.         if(this.el && this.iframe){
  992.             if(typeof w == 'number'){
  993.                 var aw = w - this.wrap.getFrameWidth('lr');
  994.                 this.el.setWidth(this.adjustWidth('textarea', aw));
  995.                 this.iframe.style.width = aw + 'px';
  996.             }
  997.             if(typeof h == 'number'){
  998.                 var ah = h - this.wrap.getFrameWidth('tb') - this.tb.el.getHeight();
  999.                 this.el.setHeight(this.adjustWidth('textarea', ah));
  1000.                 this.iframe.style.height = ah + 'px';
  1001.                 if(this.doc){
  1002.                     this.getEditorBody().style.height = (ah - (this.iframePad*2)) + 'px';
  1003.                 }
  1004.             }
  1005.         }
  1006.     },
  1007.     
  1008.     toggleSourceEdit : function(sourceEditMode){
  1009.         if(sourceEditMode === undefined){
  1010.             sourceEditMode = !this.sourceEditMode;
  1011.         }
  1012.         this.sourceEditMode = sourceEditMode === true;
  1013.         var btn = this.tb.items.get('sourceedit');
  1014.         if(btn.pressed !== this.sourceEditMode){
  1015.             btn.toggle(this.sourceEditMode);
  1016.             return;
  1017.         }
  1018.         if(this.sourceEditMode){
  1019.             this.tb.items.each(function(item){
  1020.                 if(item.itemId != 'sourceedit'){
  1021.                     item.disable();
  1022.                 }
  1023.             });
  1024.             this.syncValue();
  1025.             this.iframe.className = 'x-hidden';
  1026.             this.el.removeClass('x-hidden');
  1027.             this.el.dom.removeAttribute('tabIndex');
  1028.             this.el.focus();
  1029.         }else{
  1030.             if(this.initialized){
  1031.                 this.tb.items.each(function(item){
  1032.                     item.enable();
  1033.                 });
  1034.             }
  1035.             this.pushValue();
  1036.             this.iframe.className = '';
  1037.             this.el.addClass('x-hidden');
  1038.             this.el.dom.setAttribute('tabIndex', -1);
  1039.             this.deferFocus();
  1040.         }
  1041.         var lastSize = this.lastSize;
  1042.         if(lastSize){
  1043.             delete this.lastSize;
  1044.             this.setSize(lastSize);
  1045.         }
  1046.         this.fireEvent('editmodechange', this, this.sourceEditMode);
  1047.     },
  1048.          createLink : function(){
  1049.         var url = prompt(this.createLinkText, this.defaultLinkValue);
  1050.         if(url && url != 'http:/'+'/'){
  1051.             this.relayCmd('createlink', url);
  1052.         }
  1053.     },
  1054.          adjustSize : Ext.BoxComponent.prototype.adjustSize,
  1055.          getResizeEl : function(){
  1056.         return this.wrap;
  1057.     },
  1058.          getPositionEl : function(){
  1059.         return this.wrap;
  1060.     },
  1061.          initEvents : function(){
  1062.         this.originalValue = this.getValue();
  1063.     },
  1064.     
  1065.     markInvalid : Ext.emptyFn,
  1066.     
  1067.     
  1068.     clearInvalid : Ext.emptyFn,
  1069.          setValue : function(v){
  1070.         Ext.form.HtmlEditor.superclass.setValue.call(this, v);
  1071.         this.pushValue();
  1072.     },
  1073.     
  1074.     cleanHtml : function(html){
  1075.         html = String(html);
  1076.         if(html.length > 5){
  1077.             if(Ext.isSafari){                  html = html.replace(/sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
  1078.             }
  1079.         }
  1080.         if(html == '&nbsp;'){
  1081.             html = '';
  1082.         }
  1083.         return html;
  1084.     },
  1085.     
  1086.     syncValue : function(){
  1087.         if(this.initialized){
  1088.             var bd = this.getEditorBody();
  1089.             var html = bd.innerHTML;
  1090.             if(Ext.isSafari){
  1091.                 var bs = bd.getAttribute('style');                  var m = bs.match(/text-align:(.*?);/i);
  1092.                 if(m && m[1]){
  1093.                     html = '<div style="'+m[0]+'">' + html + '</div>';
  1094.                 }
  1095.             }
  1096.             html = this.cleanHtml(html);
  1097.             if(this.fireEvent('beforesync', this, html) !== false){
  1098.                 this.el.dom.value = html;
  1099.                 this.fireEvent('sync', this, html);
  1100.             }
  1101.         }
  1102.     },
  1103.     
  1104.     pushValue : function(){
  1105.         if(this.initialized){
  1106.             var v = this.el.dom.value;
  1107.             if(!this.activated && v.length < 1){
  1108.                 v = '&nbsp;';
  1109.             }
  1110.             if(this.fireEvent('beforepush', this, v) !== false){
  1111.                 this.getEditorBody().innerHTML = v;
  1112.                 this.fireEvent('push', this, v);
  1113.             }
  1114.         }
  1115.     },
  1116.          deferFocus : function(){
  1117.         this.focus.defer(10, this);
  1118.     },
  1119.          focus : function(){
  1120.         if(this.win && !this.sourceEditMode){
  1121.             this.win.focus();
  1122.         }else{
  1123.             this.el.focus();
  1124.         }
  1125.     },
  1126.          initEditor : function(){
  1127.         var dbody = this.getEditorBody();
  1128.         var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
  1129.         ss['background-attachment'] = 'fixed';          dbody.bgProperties = 'fixed'; 
  1130.         Ext.DomHelper.applyStyles(dbody, ss);
  1131.         if(this.doc){
  1132.             try{
  1133.                 Ext.EventManager.removeAll(this.doc);
  1134.             }catch(e){}
  1135.         }
  1136.         this.doc = this.getDoc();
  1137.         Ext.EventManager.on(this.doc, {
  1138.             'mousedown': this.onEditorEvent,
  1139.             'dblclick': this.onEditorEvent,
  1140.             'click': this.onEditorEvent,
  1141.             'keyup': this.onEditorEvent,
  1142.             buffer:100,
  1143.             scope: this
  1144.         });
  1145.         if(Ext.isGecko){
  1146.             Ext.EventManager.on(this.doc, 'keypress', this.applyCommand, this);
  1147.         }
  1148.         if(Ext.isIE || Ext.isSafari || Ext.isOpera){
  1149.             Ext.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
  1150.         }
  1151.         this.initialized = true;
  1152.         this.fireEvent('initialize', this);
  1153.         this.doc.editorInitialized = true;
  1154.         this.pushValue();
  1155.     },
  1156.          onDestroy : function(){
  1157.         if(this.monitorTask){
  1158.             Ext.TaskMgr.stop(this.monitorTask);
  1159.         }
  1160.         if(this.rendered){
  1161.             this.tb.items.each(function(item){
  1162.                 if(item.menu){
  1163.                     item.menu.removeAll();
  1164.                     if(item.menu.el){
  1165.                         item.menu.el.destroy();
  1166.                     }
  1167.                 }
  1168.                 item.destroy();
  1169.             });
  1170.             this.wrap.dom.innerHTML = '';
  1171.             this.wrap.remove();
  1172.         }
  1173.     },
  1174.          onFirstFocus : function(){
  1175.         this.activated = true;
  1176.         this.tb.items.each(function(item){
  1177.            item.enable();
  1178.         });
  1179.         if(Ext.isGecko){              this.win.focus();
  1180.             var s = this.win.getSelection();
  1181.             if(!s.focusNode || s.focusNode.nodeType != 3){
  1182.                 var r = s.getRangeAt(0);
  1183.                 r.selectNodeContents(this.getEditorBody());
  1184.                 r.collapse(true);
  1185.                 this.deferFocus();
  1186.             }
  1187.             try{
  1188.                 this.execCmd('useCSS', true);
  1189.                 this.execCmd('styleWithCSS', false);
  1190.             }catch(e){}
  1191.         }
  1192.         this.fireEvent('activate', this);
  1193.     },
  1194.          adjustFont: function(btn){
  1195.         var adjust = btn.itemId == 'increasefontsize' ? 1 : -1;
  1196.         var v = parseInt(this.doc.queryCommandValue('FontSize') || 2, 10);
  1197.         if(Ext.isSafari3 || Ext.isAir){
  1198.                                       if(v <= 10){
  1199.                 v = 1 + adjust;
  1200.             }else if(v <= 13){
  1201.                 v = 2 + adjust;
  1202.             }else if(v <= 16){
  1203.                 v = 3 + adjust;
  1204.             }else if(v <= 18){
  1205.                 v = 4 + adjust;
  1206.             }else if(v <= 24){
  1207.                 v = 5 + adjust;
  1208.             }else {
  1209.                 v = 6 + adjust;
  1210.             }
  1211.             v = v.constrain(1, 6);
  1212.         }else{
  1213.             if(Ext.isSafari){                  adjust *= 2;
  1214.             }
  1215.             v = Math.max(1, v+adjust) + (Ext.isSafari ? 'px' : 0);
  1216.         }
  1217.         this.execCmd('FontSize', v);
  1218.     },
  1219.          onEditorEvent : function(e){
  1220.         this.updateToolbar();
  1221.     },
  1222.     
  1223.     updateToolbar: function(){
  1224.         if(!this.activated){
  1225.             this.onFirstFocus();
  1226.             return;
  1227.         }
  1228.         var btns = this.tb.items.map, doc = this.doc;
  1229.         if(this.enableFont && !Ext.isSafari2){
  1230.             var name = (this.doc.queryCommandValue('FontName')||this.defaultFont).toLowerCase();
  1231.             if(name != this.fontSelect.dom.value){
  1232.                 this.fontSelect.dom.value = name;
  1233.             }
  1234.         }
  1235.         if(this.enableFormat){
  1236.             btns.bold.toggle(doc.queryCommandState('bold'));
  1237.             btns.italic.toggle(doc.queryCommandState('italic'));
  1238.             btns.underline.toggle(doc.queryCommandState('underline'));
  1239.         }
  1240.         if(this.enableAlignments){
  1241.             btns.justifyleft.toggle(doc.queryCommandState('justifyleft'));
  1242.             btns.justifycenter.toggle(doc.queryCommandState('justifycenter'));
  1243.             btns.justifyright.toggle(doc.queryCommandState('justifyright'));
  1244.         }
  1245.         if(!Ext.isSafari2 && this.enableLists){
  1246.             btns.insertorderedlist.toggle(doc.queryCommandState('insertorderedlist'));
  1247.             btns.insertunorderedlist.toggle(doc.queryCommandState('insertunorderedlist'));
  1248.         }
  1249.         
  1250.         Ext.menu.MenuMgr.hideAll();
  1251.         this.syncValue();
  1252.     },
  1253.          relayBtnCmd : function(btn){
  1254.         this.relayCmd(btn.itemId);
  1255.     },
  1256.     
  1257.     relayCmd : function(cmd, value){
  1258.         (function(){
  1259.             this.focus();
  1260.             this.execCmd(cmd, value);
  1261.             this.updateToolbar();
  1262.         }).defer(10, this);
  1263.     },
  1264.     
  1265.     execCmd : function(cmd, value){
  1266.         this.doc.execCommand(cmd, false, value === undefined ? null : value);
  1267.         this.syncValue();
  1268.     },
  1269.          applyCommand : function(e){
  1270.         if(e.ctrlKey){
  1271.             var c = e.getCharCode(), cmd;
  1272.             if(c > 0){
  1273.                 c = String.fromCharCode(c);
  1274.                 switch(c){
  1275.                     case 'b':
  1276.                         cmd = 'bold';
  1277.                     break;
  1278.                     case 'i':
  1279.                         cmd = 'italic';
  1280.                     break;
  1281.                     case 'u':
  1282.                         cmd = 'underline';
  1283.                     break;
  1284.                 }
  1285.                 if(cmd){
  1286.                     this.win.focus();
  1287.                     this.execCmd(cmd);
  1288.                     this.deferFocus();
  1289.                     e.preventDefault();
  1290.                 }
  1291.             }
  1292.         }
  1293.     },
  1294.     
  1295.     insertAtCursor : function(text){
  1296.         if(!this.activated){
  1297.             return;
  1298.         }
  1299.         if(Ext.isIE){
  1300.             this.win.focus();
  1301.             var r = this.doc.selection.createRange();
  1302.             if(r){
  1303.                 r.collapse(true);
  1304.                 r.pasteHTML(text);
  1305.                 this.syncValue();
  1306.                 this.deferFocus();
  1307.             }
  1308.         }else if(Ext.isGecko || Ext.isOpera){
  1309.             this.win.focus();
  1310.             this.execCmd('InsertHTML', text);
  1311.             this.deferFocus();
  1312.         }else if(Ext.isSafari){
  1313.             this.execCmd('InsertText', text);
  1314.             this.deferFocus();
  1315.         }
  1316.     },
  1317.          fixKeys : function(){          if(Ext.isIE){
  1318.             return function(e){
  1319.                 var k = e.getKey(), r;
  1320.                 if(k == e.TAB){
  1321.                     e.stopEvent();
  1322.                     r = this.doc.selection.createRange();
  1323.                     if(r){
  1324.                         r.collapse(true);
  1325.                         r.pasteHTML('&nbsp;&nbsp;&nbsp;&nbsp;');
  1326.                         this.deferFocus();
  1327.                     }
  1328.                 }else if(k == e.ENTER){
  1329.                     r = this.doc.selection.createRange();
  1330.                     if(r){
  1331.                         var target = r.parentElement();
  1332.                         if(!target || target.tagName.toLowerCase() != 'li'){
  1333.                             e.stopEvent();
  1334.                             r.pasteHTML('<br />');
  1335.                             r.collapse(false);
  1336.                             r.select();
  1337.                         }
  1338.                     }
  1339.                 }
  1340.             };
  1341.         }else if(Ext.isOpera){
  1342.             return function(e){
  1343.                 var k = e.getKey();
  1344.                 if(k == e.TAB){
  1345.                     e.stopEvent();
  1346.                     this.win.focus();
  1347.                     this.execCmd('InsertHTML','&nbsp;&nbsp;&nbsp;&nbsp;');
  1348.                     this.deferFocus();
  1349.                 }
  1350.             };
  1351.         }else if(Ext.isSafari){
  1352.             return function(e){
  1353.                 var k = e.getKey();
  1354.                 if(k == e.TAB){
  1355.                     e.stopEvent();
  1356.                     this.execCmd('InsertText','t');
  1357.                     this.deferFocus();
  1358.                 }
  1359.              };
  1360.         }
  1361.     }(),
  1362.     
  1363.     getToolbar : function(){
  1364.         return this.tb;
  1365.     },
  1366.     
  1367.     buttonTips : {
  1368.         bold : {
  1369.             title: 'Bold (Ctrl+B)',
  1370.             text: 'Make the selected text bold.',
  1371.             cls: 'x-html-editor-tip'
  1372.         },
  1373.         italic : {
  1374.             title: 'Italic (Ctrl+I)',
  1375.             text: 'Make the selected text italic.',
  1376.             cls: 'x-html-editor-tip'
  1377.         },
  1378.         underline : {
  1379.             title: 'Underline (Ctrl+U)',
  1380.             text: 'Underline the selected text.',
  1381.             cls: 'x-html-editor-tip'
  1382.         },
  1383.         increasefontsize : {
  1384.             title: 'Grow Text',
  1385.             text: 'Increase the font size.',
  1386.             cls: 'x-html-editor-tip'
  1387.         },
  1388.         decreasefontsize : {
  1389.             title: 'Shrink Text',
  1390.             text: 'Decrease the font size.',
  1391.             cls: 'x-html-editor-tip'
  1392.         },
  1393.         backcolor : {
  1394.             title: 'Text Highlight Color',
  1395.             text: 'Change the background color of the selected text.',
  1396.             cls: 'x-html-editor-tip'
  1397.         },
  1398.         forecolor : {
  1399.             title: 'Font Color',
  1400.             text: 'Change the color of the selected text.',
  1401.             cls: 'x-html-editor-tip'
  1402.         },
  1403.         justifyleft : {
  1404.             title: 'Align Text Left',
  1405.             text: 'Align text to the left.',
  1406.             cls: 'x-html-editor-tip'
  1407.         },
  1408.         justifycenter : {
  1409.             title: 'Center Text',
  1410.             text: 'Center text in the editor.',
  1411.             cls: 'x-html-editor-tip'
  1412.         },
  1413.         justifyright : {
  1414.             title: 'Align Text Right',
  1415.             text: 'Align text to the right.',
  1416.             cls: 'x-html-editor-tip'
  1417.         },
  1418.         insertunorderedlist : {
  1419.             title: 'Bullet List',
  1420.             text: 'Start a bulleted list.',
  1421.             cls: 'x-html-editor-tip'
  1422.         },
  1423.         insertorderedlist : {
  1424.             title: 'Numbered List',
  1425.             text: 'Start a numbered list.',
  1426.             cls: 'x-html-editor-tip'
  1427.         },
  1428.         createlink : {
  1429.             title: 'Hyperlink',
  1430.             text: 'Make the selected text a hyperlink.',
  1431.             cls: 'x-html-editor-tip'
  1432.         },
  1433.         sourceedit : {
  1434.             title: 'Source Edit',
  1435.             text: 'Switch to source editing mode.',
  1436.             cls: 'x-html-editor-tip'
  1437.         }
  1438.     }
  1439.          
  1440.     
  1441.     
  1442.     
  1443.     
  1444.     
  1445.     
  1446.     
  1447.     
  1448.     
  1449.     
  1450.     
  1451.     
  1452.     
  1453.     
  1454.     
  1455.     
  1456.     
  1457.     
  1458.     
  1459.     
  1460.     
  1461.     
  1462.     
  1463.     
  1464.     
  1465.     
  1466.     
  1467.     
  1468.     
  1469.     
  1470.     
  1471.     
  1472. });
  1473. Ext.reg('htmleditor', Ext.form.HtmlEditor);
  1474. Ext.form.TimeField = Ext.extend(Ext.form.ComboBox, {
  1475.     
  1476.     minValue : null,
  1477.     
  1478.     maxValue : null,
  1479.     
  1480.     minText : "The time in this field must be equal to or after {0}",
  1481.     
  1482.     maxText : "The time in this field must be equal to or before {0}",
  1483.     
  1484.     invalidText : "{0} is not a valid time",
  1485.     
  1486.     format : "g:i A",
  1487.     
  1488.     altFormats : "g:ia|g:iA|g:i a|g:i A|h:i|g:i|H:i|ga|ha|gA|h a|g a|g A|gi|hi|gia|hia|g|H",
  1489.     
  1490.     increment: 15,
  1491.          mode: 'local',
  1492.          triggerAction: 'all',
  1493.          typeAhead: false,
  1494.     
  1495.                    initDate: '1/1/2008',
  1496.          initComponent : function(){
  1497.         Ext.form.TimeField.superclass.initComponent.call(this);
  1498.         if(typeof this.minValue == "string"){
  1499.             this.minValue = this.parseDate(this.minValue);
  1500.         }
  1501.         if(typeof this.maxValue == "string"){
  1502.             this.maxValue = this.parseDate(this.maxValue);
  1503.         }
  1504.         if(!this.store){
  1505.             var min = this.parseDate(this.minValue);
  1506.             if(!min){
  1507.                 min = new Date(this.initDate).clearTime();
  1508.             }
  1509.             var max = this.parseDate(this.maxValue);
  1510.             if(!max){
  1511.                 max = new Date(this.initDate).clearTime().add('mi', (24 * 60) - 1);
  1512.             }
  1513.             var times = [];
  1514.             while(min <= max){
  1515.                 times.push([min.dateFormat(this.format)]);
  1516.                 min = min.add('mi', this.increment);
  1517.             }
  1518.             this.store = new Ext.data.SimpleStore({
  1519.                 fields: ['text'],
  1520.                 data : times
  1521.             });
  1522.             this.displayField = 'text';
  1523.         }
  1524.     },
  1525.          getValue : function(){
  1526.         var v = Ext.form.TimeField.superclass.getValue.call(this);
  1527.         return this.formatDate(this.parseDate(v)) || '';
  1528.     },
  1529.          setValue : function(value){
  1530.         Ext.form.TimeField.superclass.setValue.call(this, this.formatDate(this.parseDate(value)));
  1531.     },
  1532.          validateValue : Ext.form.DateField.prototype.validateValue,
  1533.     parseDate : Ext.form.DateField.prototype.parseDate,
  1534.     formatDate : Ext.form.DateField.prototype.formatDate,
  1535.          beforeBlur : function(){
  1536.         var v = this.parseDate(this.getRawValue());
  1537.         if(v){
  1538.             this.setValue(v.dateFormat(this.format));
  1539.         }
  1540.     }