3 * Copyright(c) 2006-2009 Ext JS, LLC
5 * http://www.extjs.com/license
8 Ext.DomHelper = function(){
9 var tempTableEl = null,
10 emptyTags = /^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i,
11 tableRe = /^table|tbody|tr|td$/i,
14 afterbegin = 'afterbegin',
15 afterend = 'afterend',
16 beforebegin = 'beforebegin',
17 beforeend = 'beforeend',
26 function doInsert(el, o, returnElement, pos, sibling, append){
27 var newNode = pub.insertHtml(pos, Ext.getDom(el), createHtml(o));
28 return returnElement ? Ext.get(newNode, true) : newNode;
32 function createHtml(o){
42 } else if (Ext.isArray(o)) {
43 for (var i=0; i < o.length; i++) {
45 b += createHtml(o[i]);
49 b += '<' + (o.tag = o.tag || 'div');
50 Ext.iterate(o, function(attr, val){
51 if(!/tag|children|cn|html$/i.test(attr)){
52 if (Ext.isObject(val)) {
53 b += ' ' + attr + '="';
54 Ext.iterate(val, function(key, keyVal){
55 b += key + ':' + keyVal + ';';
59 b += ' ' + ({cls : 'class', htmlFor : 'for'}[attr] || attr) + '="' + val + '"';
64 if (emptyTags.test(o.tag)) {
68 if ((cn = o.children || o.cn)) {
73 b += '</' + o.tag + '>';
79 function ieTable(depth, s, h, e){
80 tempTableEl.innerHTML = [s, h, e].join('');
88 if(ns = el.nextSibling){
89 var df = document.createDocumentFragment();
101 function insertIntoTable(tag, where, el, html) {
105 tempTableEl = tempTableEl || document.createElement('div');
107 if(tag == 'td' && (where == afterbegin || where == beforeend) ||
108 !/td|tr|tbody/i.test(tag) && (where == beforebegin || where == afterend)) {
111 before = where == beforebegin ? el :
112 where == afterend ? el.nextSibling :
113 where == afterbegin ? el.firstChild : null;
115 if (where == beforebegin || where == afterend) {
119 if (tag == 'td' || (tag == 'tr' && (where == beforeend || where == afterbegin))) {
120 node = ieTable(4, trs, html, tre);
121 } else if ((tag == 'tbody' && (where == beforeend || where == afterbegin)) ||
122 (tag == 'tr' && (where == beforebegin || where == afterend))) {
123 node = ieTable(3, tbs, html, tbe);
125 node = ieTable(2, ts, html, te);
127 el.insertBefore(node, before);
134 markup : function(o){
135 return createHtml(o);
139 applyStyles : function(el, styles){
146 if(Ext.isFunction(styles)){
147 styles = styles.call();
149 if(Ext.isString(styles)){
150 styles = styles.trim().split(/\s*(?::|;)\s*/);
151 for(len = styles.length; i < len;){
152 el.setStyle(styles[i++], styles[i++]);
154 }else if (Ext.isObject(styles)){
161 insertHtml : function(where, el, html){
170 where = where.toLowerCase();
172 hash[beforebegin] = ['BeforeBegin', 'previousSibling'];
173 hash[afterend] = ['AfterEnd', 'nextSibling'];
175 if (el.insertAdjacentHTML) {
176 if(tableRe.test(el.tagName) && (rs = insertIntoTable(el.tagName.toLowerCase(), where, el, html))){
180 hash[afterbegin] = ['AfterBegin', 'firstChild'];
181 hash[beforeend] = ['BeforeEnd', 'lastChild'];
182 if ((hashVal = hash[where])) {
183 el.insertAdjacentHTML(hashVal[0], html);
184 return el[hashVal[1]];
187 range = el.ownerDocument.createRange();
188 setStart = 'setStart' + (/end/i.test(where) ? 'After' : 'Before');
191 frag = range.createContextualFragment(html);
192 el.parentNode.insertBefore(frag, where == beforebegin ? el : el.nextSibling);
193 return el[(where == beforebegin ? 'previous' : 'next') + 'Sibling'];
195 rangeEl = (where == afterbegin ? 'first' : 'last') + 'Child';
197 range[setStart](el[rangeEl]);
198 frag = range.createContextualFragment(html);
199 if(where == afterbegin){
200 el.insertBefore(frag, el.firstChild);
202 el.appendChild(frag);
210 throw 'Illegal insertion point -> "' + where + '"';
214 insertBefore : function(el, o, returnElement){
215 return doInsert(el, o, returnElement, beforebegin);
219 insertAfter : function(el, o, returnElement){
220 return doInsert(el, o, returnElement, afterend, 'nextSibling');
224 insertFirst : function(el, o, returnElement){
225 return doInsert(el, o, returnElement, afterbegin, 'firstChild');
229 append : function(el, o, returnElement){
230 return doInsert(el, o, returnElement, beforeend, '', true);
234 overwrite : function(el, o, returnElement){
236 el.innerHTML = createHtml(o);
237 return returnElement ? Ext.get(el.firstChild) : el.firstChild;
240 createHtml : createHtml
244 Ext.apply(Ext.DomHelper,
247 afterbegin = 'afterbegin',
248 afterend = 'afterend',
249 beforebegin = 'beforebegin',
250 beforeend = 'beforeend';
253 function doInsert(el, o, returnElement, pos, sibling, append){
257 newNode = createDom(o, null);
259 el.appendChild(newNode);
261 (sibling == 'firstChild' ? el : el.parentNode).insertBefore(newNode, el[sibling] || el);
264 newNode = Ext.DomHelper.insertHtml(pos, el, Ext.DomHelper.createHtml(o));
266 return returnElement ? Ext.get(newNode, true) : newNode;
271 function createDom(o, parentNode){
279 if (Ext.isArray(o)) {
280 el = doc.createDocumentFragment();
281 Ext.each(o, function(v) {
284 } else if (Ext.isString(o)) {
285 el = doc.createTextNode(o);
287 el = doc.createElement( o.tag || 'div' );
288 useSet = !!el.setAttribute;
289 Ext.iterate(o, function(attr, val){
290 if(!/tag|children|cn|html|style/.test(attr)){
295 el.setAttribute(attr, val);
302 Ext.DomHelper.applyStyles(el, o.style);
304 if ((cn = o.children || o.cn)) {
307 el.innerHTML = o.html;
311 parentNode.appendChild(el);
318 createTemplate : function(o){
319 var html = Ext.DomHelper.createHtml(o);
320 return new Ext.Template(html);
327 insertBefore : function(el, o, returnElement){
328 return doInsert(el, o, returnElement, beforebegin);
332 insertAfter : function(el, o, returnElement){
333 return doInsert(el, o, returnElement, afterend, 'nextSibling');
337 insertFirst : function(el, o, returnElement){
338 return doInsert(el, o, returnElement, afterbegin, 'firstChild');
342 append: function(el, o, returnElement){
343 return doInsert(el, o, returnElement, beforeend, '', true);
351 Ext.Template = function(html){
356 if (Ext.isArray(html)) {
357 html = html.join("");
358 } else if (a.length > 1) {
359 Ext.each(a, function(v) {
360 if (Ext.isObject(v)) {
376 Ext.Template.prototype = {
378 re : /\{([\w-]+)\}/g,
382 applyTemplate : function(values){
386 me.compiled(values) :
387 me.html.replace(me.re, function(m, name){
388 return values[name] !== undefined ? values[name] : "";
393 set : function(html, compile){
397 return compile ? me.compile() : me;
401 compile : function(){
403 sep = Ext.isGecko ? "+" : ",";
405 function fn(m, name){
406 name = "values['" + name + "']";
407 return "'"+ sep + '(' + name + " == undefined ? '' : " + name + ')' + sep + "'";
410 eval("this.compiled = function(values){ return " + (Ext.isGecko ? "'" : "['") +
411 me.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn) +
412 (Ext.isGecko ? "';};" : "'].join('');};"));
417 insertFirst: function(el, values, returnElement){
418 return this.doInsert('afterBegin', el, values, returnElement);
422 insertBefore: function(el, values, returnElement){
423 return this.doInsert('beforeBegin', el, values, returnElement);
427 insertAfter : function(el, values, returnElement){
428 return this.doInsert('afterEnd', el, values, returnElement);
432 append : function(el, values, returnElement){
433 return this.doInsert('beforeEnd', el, values, returnElement);
436 doInsert : function(where, el, values, returnEl){
438 var newNode = Ext.DomHelper.insertHtml(where, el, this.applyTemplate(values));
439 return returnEl ? Ext.get(newNode, true) : newNode;
443 overwrite : function(el, values, returnElement){
445 el.innerHTML = this.applyTemplate(values);
446 return returnElement ? Ext.get(el.firstChild, true) : el.firstChild;
450 Ext.Template.prototype.apply = Ext.Template.prototype.applyTemplate;
453 Ext.Template.from = function(el, config){
455 return new Ext.Template(el.value || el.innerHTML, config || '');
457 Ext.apply(Ext.Template.prototype, {
459 disableFormats : false,
463 re : /\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,
466 applyTemplate : function(values){
468 useF = me.disableFormats !== true,
469 fm = Ext.util.Format,
473 return me.compiled(values);
475 function fn(m, name, format, args){
476 if (format && useF) {
477 if (format.substr(0, 5) == "this.") {
478 return tpl.call(format.substr(5), values[name], values);
484 var re = /^\s*['"](.*)["']\s*$/;
485 args = args.split(',');
486 for(var i = 0, len = args.length; i < len; i++){
487 args[i] = args[i].replace(re, "$1");
489 args = [values[name]].concat(args);
491 args = [values[name]];
493 return fm[format].apply(fm, args);
496 return values[name] !== undefined ? values[name] : "";
499 return me.html.replace(me.re, fn);
503 compile : function(){
505 fm = Ext.util.Format,
506 useF = me.disableFormats !== true,
507 sep = Ext.isGecko ? "+" : ",",
510 function fn(m, name, format, args){
512 args = args ? ',' + args : "";
513 if(format.substr(0, 5) != "this."){
514 format = "fm." + format + '(';
516 format = 'this.call("'+ format.substr(5) + '", ';
520 args= ''; format = "(values['" + name + "'] == undefined ? '' : ";
522 return "'"+ sep + format + "values['" + name + "']" + args + ")"+sep+"'";
527 body = "this.compiled = function(values){ return '" +
528 me.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn) +
531 body = ["this.compiled = function(values){ return ['"];
532 body.push(me.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn));
533 body.push("'].join('');};");
534 body = body.join('');
541 call : function(fnName, value, allValues){
542 return this[fnName](value, allValues);
545 Ext.Template.prototype.apply = Ext.Template.prototype.applyTemplate;
547 Ext.DomQuery = function(){
552 trimRe = /^\s+|\s+$/g,
553 tplRe = /\{(\d+)\}/g,
554 modeRe = /^(\s?[\/>+~]\s?|\s|$)/,
555 tagTokenRe = /^(#)?([\w-\*]+)/,
556 nthRe = /(\d*)n\+?(\d*)/,
561 isIE = window.ActiveXObject ? true : false,
566 eval("var batch = 30803;");
568 function child(p, index){
583 while((n = n.nextSibling) && n.nodeType != 1);
588 while((n = n.previousSibling) && n.nodeType != 1);
592 function children(d){
593 var n = d.firstChild, ni = -1,
597 if(n.nodeType == 3 && !nonSpace.test(n.nodeValue)){
607 function byClassName(c, a, v){
611 var r = [], ri = -1, cn;
612 for(var i = 0, ci; ci = c[i]; i++){
613 if((' '+ci.className+' ').indexOf(v) != -1){
620 function attrValue(n, attr){
621 if(!n.tagName && typeof n.length != "undefined"){
630 if(attr == "class" || attr == "className"){
633 return n.getAttribute(attr) || n[attr];
637 function getNodes(ns, mode, tagName){
638 var result = [], ri = -1, cs;
642 tagName = tagName || "*";
643 if(typeof ns.getElementsByTagName != "undefined"){
647 for(var i = 0, ni; ni = ns[i]; i++){
648 cs = ni.getElementsByTagName(tagName);
649 for(var j = 0, ci; ci = cs[j]; j++){
653 }else if(mode == "/" || mode == ">"){
654 var utag = tagName.toUpperCase();
655 for(var i = 0, ni, cn; ni = ns[i]; i++){
657 for(var j = 0, cj; cj = cn[j]; j++){
658 if(cj.nodeName == utag || cj.nodeName == tagName || tagName == '*'){
663 }else if(mode == "+"){
664 var utag = tagName.toUpperCase();
665 for(var i = 0, n; n = ns[i]; i++){
666 while((n = n.nextSibling) && n.nodeType != 1);
667 if(n && (n.nodeName == utag || n.nodeName == tagName || tagName == '*')){
671 }else if(mode == "~"){
672 var utag = tagName.toUpperCase();
673 for(var i = 0, n; n = ns[i]; i++){
674 while((n = n.nextSibling)){
675 if (n.nodeName == utag || n.nodeName == tagName || tagName == '*'){
684 function concat(a, b){
688 for(var i = 0, l = b.length; i < l; i++){
694 function byTag(cs, tagName){
695 if(cs.tagName || cs == document){
702 tagName = tagName.toLowerCase();
703 for(var i = 0, ci; ci = cs[i]; i++){
704 if(ci.nodeType == 1 && ci.tagName.toLowerCase()==tagName){
711 function byId(cs, attr, id){
712 if(cs.tagName || cs == document){
719 for(var i = 0,ci; ci = cs[i]; i++){
720 if(ci && ci.id == id){
728 function byAttribute(cs, attr, value, op, custom){
732 f = Ext.DomQuery.operators[op];
733 for(var i = 0, ci; ci = cs[i]; i++){
734 if(ci.nodeType != 1){
739 a = Ext.DomQuery.getStyle(ci, attr);
741 else if(attr == "class" || attr == "className"){
743 }else if(attr == "for"){
745 }else if(attr == "href"){
746 a = ci.getAttribute("href", 2);
748 a = ci.getAttribute(attr);
750 if((f && f(a, value)) || (!f && a)){
757 function byPseudo(cs, name, value){
758 return Ext.DomQuery.pseudos[name](cs, value);
761 function nodupIEXml(cs){
764 cs[0].setAttribute("_nodup", d);
766 for(var i = 1, len = cs.length; i < len; i++){
768 if(!c.getAttribute("_nodup") != d){
769 c.setAttribute("_nodup", d);
773 for(var i = 0, len = cs.length; i < len; i++){
774 cs[i].removeAttribute("_nodup");
783 var len = cs.length, c, i, r = cs, cj, ri = -1;
784 if(!len || typeof cs.nodeType != "undefined" || len == 1){
787 if(isIE && typeof cs[0].selectSingleNode != "undefined"){
788 return nodupIEXml(cs);
792 for(i = 1; c = cs[i]; i++){
797 for(var j = 0; j < i; j++){
800 for(j = i+1; cj = cs[j]; j++){
812 function quickDiffIEXml(c1, c2){
815 for(var i = 0, len = c1.length; i < len; i++){
816 c1[i].setAttribute("_qdiff", d);
818 for(var i = 0, len = c2.length; i < len; i++){
819 if(c2[i].getAttribute("_qdiff") != d){
823 for(var i = 0, len = c1.length; i < len; i++){
824 c1[i].removeAttribute("_qdiff");
829 function quickDiff(c1, c2){
830 var len1 = c1.length,
836 if(isIE && typeof c1[0].selectSingleNode != "undefined"){
837 return quickDiffIEXml(c1, c2);
839 for(var i = 0; i < len1; i++){
842 for(var i = 0, len = c2.length; i < len; i++){
843 if(c2[i]._qdiff != d){
850 function quickId(ns, mode, root, id){
852 var d = root.ownerDocument || root;
853 return d.getElementById(id);
855 ns = getNodes(ns, mode, "*");
856 return byId(ns, null, id);
860 getStyle : function(el, name){
861 return Ext.fly(el).getStyle(name);
864 compile : function(path, type){
865 type = type || "select";
867 var fn = ["var f = function(root){\n var mode; ++batch; var n = root || document;\n"],
869 tk = Ext.DomQuery.matchers,
873 lmode = q.match(modeRe);
875 if(lmode && lmode[1]){
876 fn[fn.length] = 'mode="'+lmode[1].replace(trimRe, "")+'";';
877 q = q.replace(lmode[1], "");
880 while(path.substr(0, 1)=="/"){
881 path = path.substr(1);
886 var tm = q.match(tagTokenRe);
887 if(type == "select"){
890 fn[fn.length] = 'n = quickId(n, mode, root, "'+tm[2]+'");';
892 fn[fn.length] = 'n = getNodes(n, mode, "'+tm[2]+'");';
894 q = q.replace(tm[0], "");
895 }else if(q.substr(0, 1) != '@'){
896 fn[fn.length] = 'n = getNodes(n, mode, "*");';
901 fn[fn.length] = 'n = byId(n, null, "'+tm[2]+'");';
903 fn[fn.length] = 'n = byTag(n, "'+tm[2]+'");';
905 q = q.replace(tm[0], "");
908 while(!(mm = q.match(modeRe))){
910 for(var j = 0; j < tklen; j++){
912 var m = q.match(t.re);
914 fn[fn.length] = t.select.replace(tplRe, function(x, i){
917 q = q.replace(m[0], "");
924 throw 'Error parsing selector, parsing failed at "' + q + '"';
928 fn[fn.length] = 'mode="'+mm[1].replace(trimRe, "")+'";';
929 q = q.replace(mm[1], "");
932 fn[fn.length] = "return nodup(n);\n}";
938 select : function(path, root, type){
939 if(!root || root == document){
942 if(typeof root == "string"){
943 root = document.getElementById(root);
945 var paths = path.split(","),
947 for(var i = 0, len = paths.length; i < len; i++){
948 var p = paths[i].replace(trimRe, "");
950 cache[p] = Ext.DomQuery.compile(p);
952 throw p + " is not a valid selector";
955 var result = cache[p](root);
956 if(result && result != document){
957 results = results.concat(result);
960 if(paths.length > 1){
961 return nodup(results);
967 selectNode : function(path, root){
968 return Ext.DomQuery.select(path, root)[0];
972 selectValue : function(path, root, defaultValue){
973 path = path.replace(trimRe, "");
974 if(!valueCache[path]){
975 valueCache[path] = Ext.DomQuery.compile(path, "select");
977 var n = valueCache[path](root), v;
980 if (typeof n.normalize == 'function') n.normalize();
982 v = (n && n.firstChild ? n.firstChild.nodeValue : null);
983 return ((v === null||v === undefined||v==='') ? defaultValue : v);
987 selectNumber : function(path, root, defaultValue){
988 var v = Ext.DomQuery.selectValue(path, root, defaultValue || 0);
989 return parseFloat(v);
993 is : function(el, ss){
994 if(typeof el == "string"){
995 el = document.getElementById(el);
997 var isArray = Ext.isArray(el),
998 result = Ext.DomQuery.filter(isArray ? el : [el], ss);
999 return isArray ? (result.length == el.length) : (result.length > 0);
1003 filter : function(els, ss, nonMatches){
1004 ss = ss.replace(trimRe, "");
1005 if(!simpleCache[ss]){
1006 simpleCache[ss] = Ext.DomQuery.compile(ss, "simple");
1008 var result = simpleCache[ss](els);
1009 return nonMatches ? quickDiff(result, els) : result;
1015 select: 'n = byClassName(n, null, " {1} ");'
1017 re: /^\:([\w-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/,
1018 select: 'n = byPseudo(n, "{1}", "{2}");'
1020 re: /^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,
1021 select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
1024 select: 'n = byId(n, null, "{1}");'
1027 select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};'
1033 "=" : function(a, v){
1036 "!=" : function(a, v){
1039 "^=" : function(a, v){
1040 return a && a.substr(0, v.length) == v;
1042 "$=" : function(a, v){
1043 return a && a.substr(a.length-v.length) == v;
1045 "*=" : function(a, v){
1046 return a && a.indexOf(v) !== -1;
1048 "%=" : function(a, v){
1049 return (a % v) == 0;
1051 "|=" : function(a, v){
1052 return a && (a == v || a.substr(0, v.length+1) == v+'-');
1054 "~=" : function(a, v){
1055 return a && (' '+a+' ').indexOf(' '+v+' ') != -1;
1061 "first-child" : function(c){
1062 var r = [], ri = -1, n;
1063 for(var i = 0, ci; ci = n = c[i]; i++){
1064 while((n = n.previousSibling) && n.nodeType != 1);
1072 "last-child" : function(c){
1073 var r = [], ri = -1, n;
1074 for(var i = 0, ci; ci = n = c[i]; i++){
1075 while((n = n.nextSibling) && n.nodeType != 1);
1083 "nth-child" : function(c, a) {
1084 var r = [], ri = -1,
1085 m = nthRe.exec(a == "even" && "2n" || a == "odd" && "2n+1" || !nthRe2.test(a) && "n+" + a || a),
1086 f = (m[1] || 1) - 0, l = m[2] - 0;
1087 for(var i = 0, n; n = c[i]; i++){
1088 var pn = n.parentNode;
1089 if (batch != pn._batch) {
1091 for(var cn = pn.firstChild; cn; cn = cn.nextSibling){
1092 if(cn.nodeType == 1){
1099 if (l == 0 || n.nodeIndex == l){
1102 } else if ((n.nodeIndex + l) % f == 0){
1110 "only-child" : function(c){
1111 var r = [], ri = -1;;
1112 for(var i = 0, ci; ci = c[i]; i++){
1113 if(!prev(ci) && !next(ci)){
1120 "empty" : function(c){
1121 var r = [], ri = -1;
1122 for(var i = 0, ci; ci = c[i]; i++){
1123 var cns = ci.childNodes, j = 0, cn, empty = true;
1126 if(cn.nodeType == 1 || cn.nodeType == 3){
1138 "contains" : function(c, v){
1139 var r = [], ri = -1;
1140 for(var i = 0, ci; ci = c[i]; i++){
1141 if((ci.textContent||ci.innerText||'').indexOf(v) != -1){
1148 "nodeValue" : function(c, v){
1149 var r = [], ri = -1;
1150 for(var i = 0, ci; ci = c[i]; i++){
1151 if(ci.firstChild && ci.firstChild.nodeValue == v){
1158 "checked" : function(c){
1159 var r = [], ri = -1;
1160 for(var i = 0, ci; ci = c[i]; i++){
1161 if(ci.checked == true){
1168 "not" : function(c, ss){
1169 return Ext.DomQuery.filter(c, ss, true);
1172 "any" : function(c, selectors){
1173 var ss = selectors.split('|'),
1175 for(var i = 0, ci; ci = c[i]; i++){
1176 for(var j = 0; s = ss[j]; j++){
1177 if(Ext.DomQuery.is(ci, s)){
1186 "odd" : function(c){
1187 return this["nth-child"](c, "odd");
1190 "even" : function(c){
1191 return this["nth-child"](c, "even");
1194 "nth" : function(c, a){
1195 return c[a-1] || [];
1198 "first" : function(c){
1202 "last" : function(c){
1203 return c[c.length-1] || [];
1206 "has" : function(c, ss){
1207 var s = Ext.DomQuery.select,
1209 for(var i = 0, ci; ci = c[i]; i++){
1210 if(s(ss, ci).length > 0){
1217 "next" : function(c, ss){
1218 var is = Ext.DomQuery.is,
1220 for(var i = 0, ci; ci = c[i]; i++){
1229 "prev" : function(c, ss){
1230 var is = Ext.DomQuery.is,
1232 for(var i = 0, ci; ci = c[i]; i++){
1245 Ext.query = Ext.DomQuery.select;
1247 Ext.util.DelayedTask = function(fn, scope, args){
1253 fn.apply(scope, args || []);
1257 me.delay = function(delay, newFn, newScope, newArgs){
1260 scope = newScope || scope;
1261 args = newArgs || args;
1262 id = setInterval(call, delay);
1266 me.cancel = function(){
1274 var EXTUTIL = Ext.util,
1275 TOARRAY = Ext.toArray,
1277 ISOBJECT = Ext.isObject,
1281 EXTUTIL.Observable = function(){
1283 var me = this, e = me.events;
1285 me.on(me.listeners);
1286 delete me.listeners;
1288 me.events = e || {};
1291 EXTUTIL.Observable.prototype = {
1293 filterOptRe : /^(?:scope|delay|buffer|single)$/,
1296 fireEvent : function(){
1297 var a = TOARRAY(arguments),
1298 ename = a[0].toLowerCase(),
1301 ce = me.events[ename],
1304 if (me.eventsSuspended === TRUE) {
1305 if (q = me.eventQueue) {
1309 else if(ISOBJECT(ce) && ce.bubble){
1310 if(ce.fire.apply(ce, a.slice(1)) === FALSE) {
1313 c = me.getBubbleTarget && me.getBubbleTarget();
1314 if(c && c.enableBubble) {
1315 if(!c.events[ename] || !Ext.isObject(c.events[ename]) || !c.events[ename].bubble) {
1316 c.enableBubble(ename);
1318 return c.fireEvent.apply(c, a);
1324 ret = ce.fire.apply(ce, a);
1331 addListener : function(eventName, fn, scope, o){
1337 if (ISOBJECT(eventName)) {
1341 if (!me.filterOptRe.test(e)) {
1342 me.addListener(e, oe.fn || oe, oe.scope || o.scope, oe.fn ? oe : o);
1346 eventName = eventName.toLowerCase();
1347 ce = me.events[eventName] || TRUE;
1348 if (Ext.isBoolean(ce)) {
1349 me.events[eventName] = ce = new EXTUTIL.Event(me, eventName);
1351 ce.addListener(fn, scope, ISOBJECT(o) ? o : {});
1356 removeListener : function(eventName, fn, scope){
1357 var ce = this.events[eventName.toLowerCase()];
1359 ce.removeListener(fn, scope);
1364 purgeListeners : function(){
1365 var events = this.events,
1371 evt.clearListeners();
1377 addEvents : function(o){
1379 me.events = me.events || {};
1380 if (Ext.isString(o)) {
1384 me.events[a[i]] = me.events[a[i]] || TRUE;
1387 Ext.applyIf(me.events, o);
1392 hasListener : function(eventName){
1393 var e = this.events[eventName];
1394 return ISOBJECT(e) && e.listeners.length > 0;
1398 suspendEvents : function(queueSuspended){
1399 this.eventsSuspended = TRUE;
1400 if(queueSuspended && !this.eventQueue){
1401 this.eventQueue = [];
1406 resumeEvents : function(){
1408 queued = me.eventQueue || [];
1409 me.eventsSuspended = FALSE;
1410 delete me.eventQueue;
1411 EACH(queued, function(e) {
1412 me.fireEvent.apply(me, e);
1417 var OBSERVABLE = EXTUTIL.Observable.prototype;
1419 OBSERVABLE.on = OBSERVABLE.addListener;
1421 OBSERVABLE.un = OBSERVABLE.removeListener;
1424 EXTUTIL.Observable.releaseCapture = function(o){
1425 o.fireEvent = OBSERVABLE.fireEvent;
1428 function createTargeted(h, o, scope){
1430 if(o.target == arguments[0]){
1431 h.apply(scope, TOARRAY(arguments));
1436 function createBuffered(h, o, fn, scope){
1437 fn.task = new EXTUTIL.DelayedTask();
1439 fn.task.delay(o.buffer, h, scope, TOARRAY(arguments));
1443 function createSingle(h, e, fn, scope){
1445 e.removeListener(fn, scope);
1446 return h.apply(scope, arguments);
1450 function createDelayed(h, o, fn, scope){
1452 var task = new EXTUTIL.DelayedTask();
1456 fn.tasks.push(task);
1457 task.delay(o.delay || 10, h, scope, TOARRAY(arguments));
1461 EXTUTIL.Event = function(obj, name){
1464 this.listeners = [];
1467 EXTUTIL.Event.prototype = {
1468 addListener : function(fn, scope, options){
1471 scope = scope || me.obj;
1472 if(!me.isListening(fn, scope)){
1473 l = me.createListener(fn, scope, options);
1475 me.listeners = me.listeners.slice(0);
1477 me.listeners.push(l);
1481 createListener: function(fn, scope, o){
1482 o = o || {}, scope = scope || this.obj;
1489 h = createTargeted(h, o, scope);
1492 h = createDelayed(h, o, fn, scope);
1495 h = createSingle(h, this, fn, scope);
1498 h = createBuffered(h, o, fn, scope);
1504 findListener : function(fn, scope){
1505 var list = this.listeners,
1513 if(l.fn == fn && (s == scope || s == this.obj)){
1521 isListening : function(fn, scope){
1522 return this.findListener(fn, scope) != -1;
1525 removeListener : function(fn, scope){
1531 if((index = me.findListener(fn, scope)) != -1){
1533 me.listeners = me.listeners.slice(0);
1535 l = me.listeners[index].fn;
1542 k = l.tasks && l.tasks.length;
1545 l.tasks[k].cancel();
1549 me.listeners.splice(index, 1);
1556 clearListeners : function(){
1561 me.removeListener(l[i].fn, l[i].scope);
1567 args = TOARRAY(arguments),
1568 listeners = me.listeners,
1569 len = listeners.length,
1575 for (; i < len; i++) {
1577 if(l && l.fireFn.apply(l.scope || me.obj || window, args) === FALSE) {
1578 return (me.firing = FALSE);
1587 Ext.apply(Ext.util.Observable.prototype, function(){
1591 function getMethodEvent(method){
1592 var e = (this.methodEvents = this.methodEvents ||
1593 {})[method], returnValue, v, cancel, obj = this;
1596 this.methodEvents[method] = e = {};
1597 e.originalFn = this[method];
1598 e.methodName = method;
1602 var makeCall = function(fn, scope, args){
1603 if (!Ext.isEmpty(v = fn.apply(scope || obj, args))) {
1604 if (Ext.isObject(v)) {
1605 returnValue = !Ext.isEmpty(v.returnValue) ? v.returnValue : v;
1606 cancel = !!v.cancel;
1618 this[method] = function(){
1619 var args = Ext.toArray(arguments);
1620 returnValue = v = undefined;
1623 Ext.each(e.before, function(b){
1624 makeCall(b.fn, b.scope, args);
1630 if (!Ext.isEmpty(v = e.originalFn.apply(obj, args))) {
1633 Ext.each(e.after, function(a){
1634 makeCall(a.fn, a.scope, args);
1649 beforeMethod : function(method, fn, scope){
1650 getMethodEvent.call(this, method).before.push({
1657 afterMethod : function(method, fn, scope){
1658 getMethodEvent.call(this, method).after.push({
1664 removeMethodListener: function(method, fn, scope){
1665 var e = getMethodEvent.call(this, method), found = false;
1666 Ext.each(e.before, function(b, i, arr){
1667 if (b.fn == fn && b.scope == scope) {
1674 Ext.each(e.after, function(a, i, arr){
1675 if (a.fn == fn && a.scope == scope) {
1684 relayEvents : function(o, events){
1686 function createHandler(ename){
1688 return me.fireEvent.apply(me, [ename].concat(Ext.toArray(arguments)));
1691 Ext.each(events, function(ename){
1692 me.events[ename] = me.events[ename] || true;
1693 o.on(ename, createHandler(ename), me);
1698 enableBubble : function(events){
1700 if(!Ext.isEmpty(events)){
1701 events = Ext.isArray(events) ? events : Ext.toArray(arguments);
1702 Ext.each(events, function(ename){
1703 ename = ename.toLowerCase();
1704 var ce = me.events[ename] || true;
1705 if (Ext.isBoolean(ce)) {
1706 ce = new Ext.util.Event(me, ename);
1707 me.events[ename] = ce;
1718 Ext.util.Observable.capture = function(o, fn, scope){
1719 o.fireEvent = o.fireEvent.createInterceptor(fn, scope);
1724 Ext.util.Observable.observeClass = function(c, listeners){
1727 Ext.apply(c, new Ext.util.Observable());
1728 Ext.util.Observable.capture(c.prototype, c.fireEvent, c);
1730 if(Ext.isObject(listeners)){
1736 Ext.EventManager = function(){
1739 docReadyState = false,
1744 IEDEFERED = "ie-deferred-loader",
1745 DOMCONTENTLOADED = "DOMContentLoaded",
1746 propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,
1748 specialElCache = [];
1753 len = specialElCache.length,
1758 if(el.getElementById || el.navigator){
1760 for(; i < len; ++i){
1761 o = specialElCache[i];
1770 specialElCache.push({
1779 if(!Ext.elCache[id]){
1780 Ext.Element.addToCache(new Ext.Element(el), id);
1782 Ext.elCache[id].skipGC = true;
1790 function addListener(el, ename, fn, wrap, scope){
1791 el = Ext.getDom(el);
1793 es = Ext.elCache[id].events,
1796 wfn = E.on(el, ename, wrap);
1797 es[ename] = es[ename] || [];
1798 es[ename].push([fn, wrap, scope, wfn]);
1802 if(ename == "mousewheel" && el.addEventListener){
1803 var args = ["DOMMouseScroll", wrap, false];
1804 el.addEventListener.apply(el, args);
1805 Ext.EventManager.addListener(WINDOW, 'unload', function(){
1806 el.removeEventListener.apply(el, args);
1809 if(ename == "mousedown" && el == document){
1810 Ext.EventManager.stoppedMouseDownEvent.addListener(wrap);
1814 function fireDocReady(){
1816 Ext.isReady = docReadyState = true;
1818 clearInterval(docReadyProcId);
1820 if(Ext.isGecko || Ext.isOpera) {
1821 DOC.removeEventListener(DOMCONTENTLOADED, fireDocReady, false);
1824 var defer = DOC.getElementById(IEDEFERED);
1826 defer.onreadystatechange = null;
1827 defer.parentNode.removeChild(defer);
1831 docReadyEvent.fire();
1832 docReadyEvent.listeners = [];
1837 function initDocReady(){
1838 var COMPLETE = "complete";
1840 docReadyEvent = new Ext.util.Event();
1841 if (Ext.isGecko || Ext.isOpera) {
1842 DOC.addEventListener(DOMCONTENTLOADED, fireDocReady, false);
1843 } else if (Ext.isIE){
1844 DOC.write("<s"+'cript id=' + IEDEFERED + ' defer="defer" src="/'+'/:"></s'+"cript>");
1845 DOC.getElementById(IEDEFERED).onreadystatechange = function(){
1846 if(this.readyState == COMPLETE){
1850 } else if (Ext.isWebKit){
1851 docReadyProcId = setInterval(function(){
1852 if(DOC.readyState == COMPLETE) {
1858 E.on(WINDOW, "load", fireDocReady);
1861 function createTargeted(h, o){
1863 var args = Ext.toArray(arguments);
1864 if(o.target == Ext.EventObject.setEvent(args[0]).target){
1865 h.apply(this, args);
1870 function createBuffered(h, o, fn){
1871 fn.task = new Ext.util.DelayedTask(h);
1872 var w = function(e){
1874 fn.task.delay(o.buffer, h, null, [new Ext.EventObjectImpl(e)]);
1879 function createSingle(h, el, ename, fn, scope){
1881 Ext.EventManager.removeListener(el, ename, fn, scope);
1886 function createDelayed(h, o, fn){
1888 var task = new Ext.util.DelayedTask(h);
1892 fn.tasks.push(task);
1893 task.delay(o.delay || 10, h, null, [new Ext.EventObjectImpl(e)]);
1897 function listen(element, ename, opt, fn, scope){
1898 var o = !Ext.isObject(opt) ? {} : opt,
1899 el = Ext.getDom(element);
1902 scope = scope || o.scope;
1905 throw "Error listening for \"" + ename + '\". Element "' + element + '" doesn\'t exist.';
1912 e = Ext.EventObject.setEvent(e);
1915 if(!(t = e.getTarget(o.delegate, el))){
1924 if (o.preventDefault) {
1927 if (o.stopPropagation) {
1928 e.stopPropagation();
1934 fn.call(scope || el, e, t, o);
1937 h = createTargeted(h, o);
1940 h = createDelayed(h, o, fn);
1943 h = createSingle(h, el, ename, fn, scope);
1946 h = createBuffered(h, o, fn);
1949 addListener(el, ename, fn, h, scope);
1955 addListener : function(element, eventName, fn, scope, options){
1956 if(Ext.isObject(eventName)){
1957 var o = eventName, e, val;
1960 if(!propRe.test(e)){
1961 if(Ext.isFunction(val)){
1963 listen(element, e, o, val, o.scope);
1966 listen(element, e, val);
1971 listen(element, eventName, options, fn, scope);
1976 removeListener : function(el, eventName, fn, scope){
1977 el = Ext.getDom(el);
1979 f = el && (Ext.elCache[id].events)[eventName] || [],
1982 for (i = 0, len = f.length; i < len; i++) {
1983 if (Ext.isArray(f[i]) && f[i][0] == fn && (!scope || f[i][2] == scope)) {
1988 k = fn.tasks && fn.tasks.length;
1991 fn.tasks[k].cancel();
1995 wf = wrap = f[i][1];
1999 E.un(el, eventName, wf);
2001 if (f.length === 0) {
2002 delete Ext.elCache[id].events[eventName];
2004 for (k in Ext.elCache[id].events) {
2007 Ext.elCache[id].events = {};
2013 if(eventName == "mousewheel" && el.addEventListener && wrap){
2014 el.removeEventListener("DOMMouseScroll", wrap, false);
2017 if(eventName == "mousedown" && el == DOC && wrap){
2018 Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
2023 removeAll : function(el){
2024 el = Ext.getDom(el);
2026 ec = Ext.elCache[id] || {},
2027 es = ec.events || {},
2028 f, i, len, ename, fn, k;
2031 if(es.hasOwnProperty(ename)){
2033 for (i = 0, len = f.length; i < len; i++) {
2039 if(fn.tasks && (k = fn.tasks.length)) {
2041 fn.tasks[k].cancel();
2045 E.un(el, ename, E.extAdapter ? f[i][3] : f[i][1]);
2049 if (Ext.elCache[id]) {
2050 Ext.elCache[id].events = {};
2054 getListeners : function(el, eventName) {
2055 el = Ext.getDom(el);
2057 ec = Ext.elCache[id] || {},
2058 es = ec.events || {},
2060 if (es && es[eventName]) {
2061 return es[eventName];
2067 purgeElement : function(el, recurse, eventName) {
2068 el = Ext.getDom(el);
2070 ec = Ext.elCache[id] || {},
2071 es = ec.events || {},
2074 if (es && es.hasOwnProperty(eventName)) {
2076 for (i = 0, len = f.length; i < len; i++) {
2077 Ext.EventManager.removeListener(el, eventName, f[i][0]);
2081 Ext.EventManager.removeAll(el);
2083 if (recurse && el && el.childNodes) {
2084 for (i = 0, len = el.childNodes.length; i < len; i++) {
2085 Ext.EventManager.purgeElement(el.childNodes[i], recurse, eventName);
2090 _unload : function() {
2092 for (el in Ext.elCache) {
2093 Ext.EventManager.removeAll(el);
2097 onDocumentReady : function(fn, scope, options){
2099 docReadyEvent.addListener(fn, scope, options);
2100 docReadyEvent.fire();
2101 docReadyEvent.listeners = [];
2103 if(!docReadyEvent) initDocReady();
2104 options = options || {};
2105 options.delay = options.delay || 1;
2106 docReadyEvent.addListener(fn, scope, options);
2111 pub.on = pub.addListener;
2113 pub.un = pub.removeListener;
2115 pub.stoppedMouseDownEvent = new Ext.util.Event();
2119 Ext.onReady = Ext.EventManager.onDocumentReady;
2125 var initExtCss = function(){
2127 var bd = document.body || document.getElementsByTagName('body')[0];
2128 if(!bd){ return false; }
2130 Ext.isIE ? "ext-ie " + (Ext.isIE6 ? 'ext-ie6' : (Ext.isIE7 ? 'ext-ie7' : 'ext-ie8'))
2131 : Ext.isGecko ? "ext-gecko " + (Ext.isGecko2 ? 'ext-gecko2' : 'ext-gecko3')
2132 : Ext.isOpera ? "ext-opera"
2133 : Ext.isWebKit ? "ext-webkit" : ""];
2136 cls.push("ext-safari " + (Ext.isSafari2 ? 'ext-safari2' : (Ext.isSafari3 ? 'ext-safari3' : 'ext-safari4')));
2137 }else if(Ext.isChrome){
2138 cls.push("ext-chrome");
2142 cls.push("ext-mac");
2145 cls.push("ext-linux");
2148 if(Ext.isStrict || Ext.isBorderBox){
2149 var p = bd.parentNode;
2151 p.className += Ext.isStrict ? ' ext-strict' : ' ext-border-box';
2154 bd.className += cls.join(' ');
2159 Ext.onReady(initExtCss);
2165 Ext.EventObject = function(){
2166 var E = Ext.lib.Event,
2181 btnMap = Ext.isIE ? {1:0,4:1,2:2} :
2182 (Ext.isWebKit ? {1:0,2:1,3:2} : {0:0,1:1,2:2});
2184 Ext.EventObjectImpl = function(e){
2186 this.setEvent(e.browserEvent || e);
2190 Ext.EventObjectImpl.prototype = {
2192 setEvent : function(e){
2194 if(e == me || (e && e.browserEvent)){
2197 me.browserEvent = e;
2200 me.button = e.button ? btnMap[e.button] : (e.which ? e.which - 1 : -1);
2201 if(e.type == 'click' && me.button == -1){
2205 me.shiftKey = e.shiftKey;
2207 me.ctrlKey = e.ctrlKey || e.metaKey || false;
2208 me.altKey = e.altKey;
2210 me.keyCode = e.keyCode;
2211 me.charCode = e.charCode;
2213 me.target = E.getTarget(e);
2218 me.shiftKey = false;
2230 stopEvent : function(){
2232 if(me.browserEvent){
2233 if(me.browserEvent.type == 'mousedown'){
2234 Ext.EventManager.stoppedMouseDownEvent.fire(me);
2236 E.stopEvent(me.browserEvent);
2241 preventDefault : function(){
2242 if(this.browserEvent){
2243 E.preventDefault(this.browserEvent);
2248 stopPropagation : function(){
2250 if(me.browserEvent){
2251 if(me.browserEvent.type == 'mousedown'){
2252 Ext.EventManager.stoppedMouseDownEvent.fire(me);
2254 E.stopPropagation(me.browserEvent);
2259 getCharCode : function(){
2260 return this.charCode || this.keyCode;
2264 getKey : function(){
2265 return this.normalizeKey(this.keyCode || this.charCode)
2269 normalizeKey: function(k){
2270 return Ext.isSafari ? (safariKeys[k] || k) : k;
2274 getPageX : function(){
2279 getPageY : function(){
2289 getTarget : function(selector, maxDepth, returnEl){
2290 return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : (returnEl ? Ext.get(this.target) : this.target);
2294 getRelatedTarget : function(){
2295 return this.browserEvent ? E.getRelatedTarget(this.browserEvent) : null;
2299 getWheelDelta : function(){
2300 var e = this.browserEvent;
2303 delta = e.wheelDelta/120;
2305 delta = -e.detail/3;
2311 within : function(el, related, allowEl){
2313 var t = this[related ? "getRelatedTarget" : "getTarget"]();
2314 return t && ((allowEl ? (t == Ext.getDom(el)) : false) || Ext.fly(el).contains(t));
2320 return new Ext.EventObjectImpl();
2324 Ext.apply(Ext.EventManager, function(){
2330 propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,
2336 useKeydown = Ext.isWebKit ?
2337 Ext.num(navigator.userAgent.match(/AppleWebKit\/(\d+)/)[1]) >= 525 :
2338 !((Ext.isGecko && !Ext.isWindows) || Ext.isOpera);
2342 doResizeEvent: function(){
2343 var h = D.getViewHeight(),
2344 w = D.getViewWidth();
2347 if(curHeight != h || curWidth != w){
2348 resizeEvent.fire(curWidth = w, curHeight = h);
2353 onWindowResize : function(fn, scope, options){
2355 resizeEvent = new Ext.util.Event();
2356 resizeTask = new Ext.util.DelayedTask(this.doResizeEvent);
2357 Ext.EventManager.on(window, "resize", this.fireWindowResize, this);
2359 resizeEvent.addListener(fn, scope, options);
2363 fireWindowResize : function(){
2365 if((Ext.isIE||Ext.isAir) && resizeTask){
2366 resizeTask.delay(50);
2368 resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
2374 onTextResize : function(fn, scope, options){
2376 textEvent = new Ext.util.Event();
2377 var textEl = new Ext.Element(document.createElement('div'));
2378 textEl.dom.className = 'x-text-resize';
2379 textEl.dom.innerHTML = 'X';
2380 textEl.appendTo(document.body);
2381 textSize = textEl.dom.offsetHeight;
2382 setInterval(function(){
2383 if(textEl.dom.offsetHeight != textSize){
2384 textEvent.fire(textSize, textSize = textEl.dom.offsetHeight);
2386 }, this.textResizeInterval);
2388 textEvent.addListener(fn, scope, options);
2392 removeResizeListener : function(fn, scope){
2394 resizeEvent.removeListener(fn, scope);
2399 fireResize : function(){
2401 resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
2406 textResizeInterval : 50,
2413 useKeydown: useKeydown
2417 Ext.EventManager.on = Ext.EventManager.addListener;
2420 Ext.apply(Ext.EventObjectImpl.prototype, {
2600 isNavKeyPress : function(){
2602 k = this.normalizeKey(me.keyCode);
2603 return (k >= 33 && k <= 40) ||
2609 isSpecialKey : function(){
2610 var k = this.normalizeKey(this.keyCode);
2611 return (this.type == 'keypress' && this.ctrlKey) ||
2612 this.isNavKeyPress() ||
2613 (k == this.BACKSPACE) ||
2614 (k >= 16 && k <= 20) ||
2615 (k >= 44 && k <= 45);
2618 getPoint : function(){
2619 return new Ext.lib.Point(this.xy[0], this.xy[1]);
2623 hasModifier : function(){
2624 return ((this.ctrlKey || this.altKey) || this.shiftKey);
2630 Ext.Element = function(element, forceNew){
2631 var dom = typeof element == "string" ?
2632 DOC.getElementById(element) : element,
2635 if(!dom) return null;
2639 if(!forceNew && id && Ext.elCache[id]){
2640 return Ext.elCache[id].el;
2647 this.id = id || Ext.id(dom);
2650 var D = Ext.lib.Dom,
2659 set : function(o, useSet){
2663 useSet = (useSet !== false) && !!el.setAttribute;
2666 if (o.hasOwnProperty(attr)) {
2668 if (attr == 'style') {
2669 DH.applyStyles(el, val);
2670 } else if (attr == 'cls') {
2672 } else if (useSet) {
2673 el.setAttribute(attr, val);
2734 is : function(simpleSelector){
2735 return Ext.DomQuery.is(this.dom, simpleSelector);
2739 focus : function(defer, dom) {
2741 dom = dom || me.dom;
2744 me.focus.defer(defer, null, [null, dom]);
2761 getValue : function(asNumber){
2762 var val = this.dom.value;
2763 return asNumber ? parseInt(val, 10) : val;
2767 addListener : function(eventName, fn, scope, options){
2768 Ext.EventManager.on(this.dom, eventName, fn, scope || this, options);
2773 removeListener : function(eventName, fn, scope){
2774 Ext.EventManager.removeListener(this.dom, eventName, fn, scope || this);
2779 removeAllListeners : function(){
2780 Ext.EventManager.removeAll(this.dom);
2785 purgeAllListeners : function() {
2786 Ext.EventManager.purgeElement(this, true);
2790 addUnits : function(size){
2791 if(size === "" || size == "auto" || size === undefined){
2793 } else if(!isNaN(size) || !unitPattern.test(size)){
2794 size = size + (this.defaultUnit || 'px');
2800 load : function(url, params, cb){
2801 Ext.Ajax.request(Ext.apply({
2803 url: url.url || url,
2806 indicatorText: url.indicatorText || ''
2807 }, Ext.isObject(url) ? url : {}));
2812 isBorderBox : function(){
2813 return noBoxAdjust[(this.dom.tagName || "").toLowerCase()] || Ext.isBorderBox;
2817 remove : function(){
2823 Ext.removeNode(dom);
2828 hover : function(overFn, outFn, scope, options){
2830 me.on('mouseenter', overFn, scope || me.dom, options);
2831 me.on('mouseleave', outFn, scope || me.dom, options);
2836 contains : function(el){
2837 return !el ? false : Ext.lib.Dom.isAncestor(this.dom, el.dom ? el.dom : el);
2841 getAttributeNS : function(ns, name){
2842 return this.getAttribute(name, ns);
2846 getAttribute : Ext.isIE ? function(name, ns){
2848 type = typeof d[ns + ":" + name];
2850 if(['undefined', 'unknown'].indexOf(type) == -1){
2851 return d[ns + ":" + name];
2854 } : function(name, ns){
2856 return d.getAttributeNS(ns, name) || d.getAttribute(ns + ":" + name) || d.getAttribute(name) || d[name];
2860 update : function(html) {
2862 this.dom.innerHTML = html;
2868 var ep = El.prototype;
2870 El.addMethods = function(o){
2875 ep.on = ep.addListener;
2878 ep.un = ep.removeListener;
2881 ep.autoBoxAdjust = true;
2884 var unitPattern = /\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i,
2890 El.get = function(el){
2894 if(!el){ return null; }
2895 if (typeof el == "string") {
2896 if (!(elm = DOC.getElementById(el))) {
2899 if (EC[el] && EC[el].el) {
2903 ex = El.addToCache(new El(elm));
2906 } else if (el.tagName) {
2910 if (EC[id] && EC[id].el) {
2914 ex = El.addToCache(new El(el));
2917 } else if (el instanceof El) {
2919 el.dom = DOC.getElementById(el.id) || el.dom;
2923 } else if(el.isComposite) {
2925 } else if(Ext.isArray(el)) {
2926 return El.select(el);
2927 } else if(el == DOC) {
2930 var f = function(){};
2931 f.prototype = El.prototype;
2940 El.addToCache = function(el, id){
2951 El.data = function(el, key, value){
2956 var c = EC[el.id].data;
2957 if(arguments.length == 2){
2960 return (c[key] = value);
2967 function garbageCollect(){
2968 if(!Ext.enableGarbageCollector){
2969 clearInterval(El.collectorThreadId);
3000 if(!d || !d.parentNode || (!d.offsetParent && !DOC.getElementById(eid))){
3001 if(Ext.enableListenerCollection){
3002 Ext.EventManager.removeAll(d);
3013 EC = Ext.elCache = t;
3017 El.collectorThreadId = setInterval(garbageCollect, 30000);
3019 var flyFn = function(){};
3020 flyFn.prototype = El.prototype;
3023 El.Flyweight = function(dom){
3027 El.Flyweight.prototype = new flyFn();
3028 El.Flyweight.prototype.isFlyweight = true;
3029 El._flyweights = {};
3032 El.fly = function(el, named){
3034 named = named || '_global';
3036 if (el = Ext.getDom(el)) {
3037 (El._flyweights[named] = El._flyweights[named] || new El.Flyweight()).dom = el;
3038 ret = El._flyweights[named];
3050 var noBoxAdjust = Ext.isStrict ? {
3053 input:1, select:1, textarea:1
3055 if(Ext.isIE || Ext.isGecko){
3056 noBoxAdjust['button'] = 1;
3060 Ext.EventManager.on(window, 'unload', function(){
3062 delete El._flyweights;
3066 Ext.Element.addMethods({
3068 swallowEvent : function(eventName, preventDefault){
3071 e.stopPropagation();
3076 if(Ext.isArray(eventName)){
3077 Ext.each(eventName, function(e) {
3082 me.on(eventName, fn);
3087 relayEvent : function(eventName, observable){
3088 this.on(eventName, function(e){
3089 observable.fireEvent(eventName, e);
3094 clean : function(forceReclean){
3100 if(Ext.Element.data(dom, 'isCleaned') && forceReclean !== true){
3105 var nx = n.nextSibling;
3106 if(n.nodeType == 3 && !/\S/.test(n.nodeValue)){
3113 Ext.Element.data(dom, 'isCleaned', true);
3119 var um = this.getUpdater();
3120 um.update.apply(um, arguments);
3125 getUpdater : function(){
3126 return this.updateManager || (this.updateManager = new Ext.Updater(this));
3130 update : function(html, loadScripts, callback){
3136 if(loadScripts !== true){
3137 this.dom.innerHTML = html;
3138 if(Ext.isFunction(callback)){
3147 html += '<span id="' + id + '"></span>';
3149 Ext.lib.Event.onAvailable(id, function(){
3151 hd = DOC.getElementsByTagName("head")[0],
3152 re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig,
3153 srcRe = /\ssrc=([\'\"])(.*?)\1/i,
3154 typeRe = /\stype=([\'\"])(.*?)\1/i,
3162 while((match = re.exec(html))){
3164 srcMatch = attrs ? attrs.match(srcRe) : false;
3165 if(srcMatch && srcMatch[2]){
3166 s = DOC.createElement("script");
3167 s.src = srcMatch[2];
3168 typeMatch = attrs.match(typeRe);
3169 if(typeMatch && typeMatch[2]){
3170 s.type = typeMatch[2];
3173 }else if(match[2] && match[2].length > 0){
3174 if(window.execScript) {
3175 window.execScript(match[2]);
3177 window.eval(match[2]);
3181 el = DOC.getElementById(id);
3182 if(el){Ext.removeNode(el);}
3183 if(Ext.isFunction(callback)){
3187 dom.innerHTML = html.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig, "");
3192 removeAllListeners : function(){
3193 this.removeAnchor();
3194 Ext.EventManager.removeAll(this.dom);
3199 createProxy : function(config, renderTo, matchBox){
3200 config = Ext.isObject(config) ? config : {tag : "div", cls: config};
3203 proxy = renderTo ? Ext.DomHelper.append(renderTo, config, true) :
3204 Ext.DomHelper.insertBefore(me.dom, config, true);
3206 if(matchBox && me.setBox && me.getBox){
3207 proxy.setBox(me.getBox());
3213 Ext.Element.prototype.getUpdateManager = Ext.Element.prototype.getUpdater;
3215 Ext.Element.addMethods({
3217 getAnchorXY : function(anchor, local, s){
3220 anchor = (anchor || "tl").toLowerCase();
3224 vp = me.dom == document.body || me.dom == document,
3225 w = s.width || vp ? Ext.lib.Dom.getViewWidth() : me.getWidth(),
3226 h = s.height || vp ? Ext.lib.Dom.getViewHeight() : me.getHeight(),
3230 scroll = me.getScroll(),
3231 extraX = vp ? scroll.left : !local ? o[0] : 0,
3232 extraY = vp ? scroll.top : !local ? o[1] : 0,
3234 c : [r(w * 0.5), r(h * 0.5)],
3235 t : [r(w * 0.5), 0],
3236 l : [0, r(h * 0.5)],
3237 r : [w, r(h * 0.5)],
3238 b : [r(w * 0.5), h],
3246 return [xy[0] + extraX, xy[1] + extraY];
3250 anchorTo : function(el, alignment, offsets, animate, monitorScroll, callback){
3253 scroll = !Ext.isEmpty(monitorScroll),
3254 action = function(){
3255 Ext.fly(dom).alignTo(el, alignment, offsets, animate);
3256 Ext.callback(callback, Ext.fly(dom));
3258 anchor = this.getAnchor();
3261 this.removeAnchor();
3267 Ext.EventManager.onWindowResize(action, null);
3270 Ext.EventManager.on(window, 'scroll', action, null,
3271 {buffer: !isNaN(monitorScroll) ? monitorScroll : 50});
3278 removeAnchor : function(){
3280 anchor = this.getAnchor();
3282 if(anchor && anchor.fn){
3283 Ext.EventManager.removeResizeListener(anchor.fn);
3285 Ext.EventManager.un(window, 'scroll', anchor.fn);
3293 getAnchor : function(){
3294 var data = Ext.Element.data,
3299 var anchor = data(dom, '_anchor');
3302 anchor = data(dom, '_anchor', {});
3308 getAlignToXY : function(el, p, o){
3312 throw "Element.alignToXY with an element that doesn't exist";
3316 p = (!p || p == "?" ? "tl-bl?" : (!/-/.test(p) && p !== "" ? "tl-" + p : p || "tl-bl")).toLowerCase();
3328 dw = Ext.lib.Dom.getViewWidth() -10,
3329 dh = Ext.lib.Dom.getViewHeight()-10,
3337 docElement = doc.documentElement,
3339 scrollX = (docElement.scrollLeft || docBody.scrollLeft || 0)+5,
3340 scrollY = (docElement.scrollTop || docBody.scrollTop || 0)+5,
3344 m = p.match(/^([a-z]+)-([a-z]+)(\?)?$/);
3347 throw "Element.alignTo with an invalid alignment " + p;
3356 a1 = me.getAnchorXY(p1, true);
3357 a2 = el.getAnchorXY(p2, false);
3359 x = a2[0] - a1[0] + o[0];
3360 y = a2[1] - a1[1] + o[1];
3370 p1x = p1.charAt(p1.length-1);
3372 p2x = p2.charAt(p2.length-1);
3373 swapY = ((p1y=="t" && p2y=="b") || (p1y=="b" && p2y=="t"));
3374 swapX = ((p1x=="r" && p2x=="l") || (p1x=="l" && p2x=="r"));
3377 if (x + w > dw + scrollX) {
3378 x = swapX ? r.left-w : dw+scrollX-w;
3381 x = swapX ? r.right : scrollX;
3383 if (y + h > dh + scrollY) {
3384 y = swapY ? r.top-h : dh+scrollY-h;
3387 y = swapY ? r.bottom : scrollY;
3394 alignTo : function(element, position, offsets, animate){
3396 return me.setXY(me.getAlignToXY(element, position, offsets),
3397 me.preanim && !!animate ? me.preanim(arguments, 3) : false);
3401 adjustForConstraints : function(xy, parent, offsets){
3402 return this.getConstrainToXY(parent || document, false, offsets, xy) || xy;
3406 getConstrainToXY : function(el, local, offsets, proposedXY){
3407 var os = {top:0, left:0, bottom:0, right: 0};
3409 return function(el, local, offsets, proposedXY){
3411 offsets = offsets ? Ext.applyIf(offsets, os) : os;
3413 var vw, vh, vx = 0, vy = 0;
3414 if(el.dom == document.body || el.dom == document){
3415 vw =Ext.lib.Dom.getViewWidth();
3416 vh = Ext.lib.Dom.getViewHeight();
3418 vw = el.dom.clientWidth;
3419 vh = el.dom.clientHeight;
3421 var vxy = el.getXY();
3427 var s = el.getScroll();
3429 vx += offsets.left + s.left;
3430 vy += offsets.top + s.top;
3432 vw -= offsets.right;
3433 vh -= offsets.bottom;
3438 var xy = proposedXY || (!local ? this.getXY() : [this.getLeft(true), this.getTop(true)]);
3439 var x = xy[0], y = xy[1];
3440 var w = this.dom.offsetWidth, h = this.dom.offsetHeight;
3463 return moved ? [x, y] : false;
3523 getCenterXY : function(){
3524 return this.getAlignToXY(document, 'c-c');
3528 center : function(centerIn){
3529 return this.alignTo(centerIn || document, 'c-c');
3533 Ext.Element.addMethods(function(){
3534 var PARENTNODE = 'parentNode',
3535 NEXTSIBLING = 'nextSibling',
3536 PREVIOUSSIBLING = 'previousSibling',
3542 findParent : function(simpleSelector, maxDepth, returnEl){
3547 if(Ext.isGecko && Object.prototype.toString.call(p) == '[object XULElement]') {
3550 maxDepth = maxDepth || 50;
3551 if (isNaN(maxDepth)) {
3552 stopEl = Ext.getDom(maxDepth);
3553 maxDepth = Number.MAX_VALUE;
3555 while(p && p.nodeType == 1 && depth < maxDepth && p != b && p != stopEl){
3556 if(DQ.is(p, simpleSelector)){
3557 return returnEl ? GET(p) : p;
3566 findParentNode : function(simpleSelector, maxDepth, returnEl){
3567 var p = Ext.fly(this.dom.parentNode, '_internal');
3568 return p ? p.findParent(simpleSelector, maxDepth, returnEl) : null;
3572 up : function(simpleSelector, maxDepth){
3573 return this.findParentNode(simpleSelector, maxDepth, true);
3577 select : function(selector){
3578 return Ext.Element.select(selector, this.dom);
3582 query : function(selector){
3583 return DQ.select(selector, this.dom);
3587 child : function(selector, returnDom){
3588 var n = DQ.selectNode(selector, this.dom);
3589 return returnDom ? n : GET(n);
3593 down : function(selector, returnDom){
3594 var n = DQ.selectNode(" > " + selector, this.dom);
3595 return returnDom ? n : GET(n);
3599 parent : function(selector, returnDom){
3600 return this.matchNode(PARENTNODE, PARENTNODE, selector, returnDom);
3604 next : function(selector, returnDom){
3605 return this.matchNode(NEXTSIBLING, NEXTSIBLING, selector, returnDom);
3609 prev : function(selector, returnDom){
3610 return this.matchNode(PREVIOUSSIBLING, PREVIOUSSIBLING, selector, returnDom);
3615 first : function(selector, returnDom){
3616 return this.matchNode(NEXTSIBLING, 'firstChild', selector, returnDom);
3620 last : function(selector, returnDom){
3621 return this.matchNode(PREVIOUSSIBLING, 'lastChild', selector, returnDom);
3624 matchNode : function(dir, start, selector, returnDom){
3625 var n = this.dom[start];
3627 if(n.nodeType == 1 && (!selector || DQ.is(n, selector))){
3628 return !returnDom ? GET(n) : n;
3636 Ext.Element.addMethods({
3638 select : function(selector, unique){
3639 return Ext.Element.select(selector, unique, this.dom);
3642 Ext.Element.addMethods(
3644 var GETDOM = Ext.getDom,
3650 appendChild: function(el){
3651 return GET(el).appendTo(this);
3655 appendTo: function(el){
3656 GETDOM(el).appendChild(this.dom);
3661 insertBefore: function(el){
3662 (el = GETDOM(el)).parentNode.insertBefore(this.dom, el);
3667 insertAfter: function(el){
3668 (el = GETDOM(el)).parentNode.insertBefore(this.dom, el.nextSibling);
3673 insertFirst: function(el, returnDom){
3675 if(el.nodeType || el.dom || typeof el == 'string'){
3677 this.dom.insertBefore(el, this.dom.firstChild);
3678 return !returnDom ? GET(el) : el;
3680 return this.createChild(el, this.dom.firstChild, returnDom);
3685 replace: function(el){
3687 this.insertBefore(el);
3693 replaceWith: function(el){
3696 if(el.nodeType || el.dom || typeof el == 'string'){
3698 me.dom.parentNode.insertBefore(el, me.dom);
3700 el = DH.insertBefore(me.dom, el);
3703 delete Ext.elCache[me.id];
3704 Ext.removeNode(me.dom);
3705 me.id = Ext.id(me.dom = el);
3706 Ext.Element.addToCache(me.isFlyweight ? new Ext.Element(me.dom) : me);
3711 createChild: function(config, insertBefore, returnDom){
3712 config = config || {tag:'div'};
3713 return insertBefore ?
3714 DH.insertBefore(insertBefore, config, returnDom !== true) :
3715 DH[!this.dom.firstChild ? 'overwrite' : 'append'](this.dom, config, returnDom !== true);
3719 wrap: function(config, returnDom){
3720 var newEl = DH.insertBefore(this.dom, config || {tag: "div"}, !returnDom);
3721 newEl.dom ? newEl.dom.appendChild(this.dom) : newEl.appendChild(this.dom);
3726 insertHtml : function(where, html, returnEl){
3727 var el = DH.insertHtml(where, this.dom, html);
3728 return returnEl ? Ext.get(el) : el;
3732 Ext.apply(Ext.Element.prototype, function() {
3733 var GETDOM = Ext.getDom,
3739 insertSibling: function(el, where, returnDom){
3742 isAfter = (where || 'before').toLowerCase() == 'after',
3745 if(Ext.isArray(el)){
3747 Ext.each(el, function(e) {
3748 rt = Ext.fly(insertEl, '_internal').insertSibling(e, where, returnDom);
3758 if(el.nodeType || el.dom){
3759 rt = me.dom.parentNode.insertBefore(GETDOM(el), isAfter ? me.dom.nextSibling : me.dom);
3764 if (isAfter && !me.dom.nextSibling) {
3765 rt = DH.append(me.dom.parentNode, el, !returnDom);
3767 rt = DH[isAfter ? 'insertAfter' : 'insertBefore'](me.dom, el, !returnDom);
3774 Ext.Element.addMethods(function(){
3777 camelRe = /(-[a-z])/gi,
3779 view = document.defaultView,
3780 propFloat = Ext.isIE ? 'styleFloat' : 'cssFloat',
3781 opacityRe = /alpha\(opacity=(.*)\)/i,
3782 trimRe = /^\s+|\s+$/g,
3784 PADDING = "padding",
3794 ISCLIPPED = 'isClipped',
3795 OVERFLOW = 'overflow',
3796 OVERFLOWX = 'overflow-x',
3797 OVERFLOWY = 'overflow-y',
3798 ORIGINALCLIP = 'originalClip',
3800 borders = {l: BORDER + LEFT + WIDTH, r: BORDER + RIGHT + WIDTH, t: BORDER + TOP + WIDTH, b: BORDER + BOTTOM + WIDTH},
3801 paddings = {l: PADDING + LEFT, r: PADDING + RIGHT, t: PADDING + TOP, b: PADDING + BOTTOM},
3802 margins = {l: MARGIN + LEFT, r: MARGIN + RIGHT, t: MARGIN + TOP, b: MARGIN + BOTTOM},
3803 data = Ext.Element.data;
3807 function camelFn(m, a) {
3808 return a.charAt(1).toUpperCase();
3811 function chkCache(prop) {
3812 return propCache[prop] || (propCache[prop] = prop == 'float' ? propFloat : prop.replace(camelRe, camelFn));
3817 adjustWidth : function(width) {
3819 var isNum = Ext.isNumber(width);
3820 if(isNum && me.autoBoxAdjust && !me.isBorderBox()){
3821 width -= (me.getBorderWidth("lr") + me.getPadding("lr"));
3823 return (isNum && width < 0) ? 0 : width;
3827 adjustHeight : function(height) {
3829 var isNum = Ext.isNumber(height);
3830 if(isNum && me.autoBoxAdjust && !me.isBorderBox()){
3831 height -= (me.getBorderWidth("tb") + me.getPadding("tb"));
3833 return (isNum && height < 0) ? 0 : height;
3838 addClass : function(className){
3839 var me = this, i, len, v;
3840 className = Ext.isArray(className) ? className : [className];
3841 for (i=0, len = className.length; i < len; i++) {
3844 me.dom.className += (!me.hasClass(v) && v ? " " + v : "");
3851 radioClass : function(className){
3852 var cn = this.dom.parentNode.childNodes, v;
3853 className = Ext.isArray(className) ? className : [className];
3854 for (var i=0, len = cn.length; i < len; i++) {
3856 if(v && v.nodeType == 1) {
3857 Ext.fly(v, '_internal').removeClass(className);
3860 return this.addClass(className);
3864 removeClass : function(className){
3866 className = Ext.isArray(className) ? className : [className];
3867 if (me.dom && me.dom.className) {
3868 for (var i=0, len=className.length; i < len; i++) {
3871 me.dom.className = me.dom.className.replace(
3872 classReCache[v] = classReCache[v] || new RegExp('(?:^|\\s+)' + v + '(?:\\s+|$)', "g"), " "
3881 toggleClass : function(className){
3882 return this.hasClass(className) ? this.removeClass(className) : this.addClass(className);
3886 hasClass : function(className){
3887 return className && (' '+this.dom.className+' ').indexOf(' '+className+' ') != -1;
3891 replaceClass : function(oldClassName, newClassName){
3892 return this.removeClass(oldClassName).addClass(newClassName);
3895 isStyle : function(style, val) {
3896 return this.getStyle(style) == val;
3900 getStyle : function(){
3901 return view && view.getComputedStyle ?
3914 prop = chkCache(prop);
3916 if(wk && /marginRight/.test(prop)){
3917 display = this.getStyle('display');
3918 el.style.display = 'inline-block';
3920 out = (v = el.style[prop]) ? v :
3921 (cs = view.getComputedStyle(el, "")) ? cs[prop] : null;
3925 if(out == 'rgba(0, 0, 0, 0)'){
3926 out = 'transparent';
3928 el.style.display = display;
3938 if(el == document) return null;
3939 if (prop == 'opacity') {
3940 if (el.style.filter.match) {
3941 if(m = el.style.filter.match(opacityRe)){
3942 var fv = parseFloat(m[1]);
3944 return fv ? fv / 100 : 0;
3950 prop = chkCache(prop);
3951 return el.style[prop] || ((cs = el.currentStyle) ? cs[prop] : null);
3956 getColor : function(attr, defaultValue, prefix){
3957 var v = this.getStyle(attr),
3958 color = Ext.isDefined(prefix) ? prefix : '#',
3961 if(!v || /transparent|inherit/.test(v)){
3962 return defaultValue;
3965 Ext.each(v.slice(4, v.length -1).split(','), function(s){
3966 h = parseInt(s, 10);
3967 color += (h < 16 ? '0' : '') + h.toString(16);
3970 v = v.replace('#', '');
3971 color += v.length == 3 ? v.replace(/^(\w)(\w)(\w)$/, '$1$1$2$2$3$3') : v;
3973 return(color.length > 5 ? color.toLowerCase() : defaultValue);
3977 setStyle : function(prop, value){
3981 if (!Ext.isObject(prop)) {
3986 for (style in prop) {
3987 value = prop[style];
3988 style == 'opacity' ?
3989 this.setOpacity(value) :
3990 this.dom.style[chkCache(style)] = value;
3996 setOpacity : function(opacity, animate){
4000 if(!animate || !me.anim){
4002 var opac = opacity < 1 ? 'alpha(opacity=' + opacity * 100 + ')' : '',
4003 val = s.filter.replace(opacityRe, '').replace(trimRe, '');
4006 s.filter = val + (val.length > 0 ? ' ' : '') + opac;
4008 s.opacity = opacity;
4011 me.anim({opacity: {to: opacity}}, me.preanim(arguments, 1), null, .35, 'easeIn');
4017 clearOpacity : function(){
4018 var style = this.dom.style;
4020 if(!Ext.isEmpty(style.filter)){
4021 style.filter = style.filter.replace(opacityRe, '').replace(trimRe, '');
4024 style.opacity = style['-moz-opacity'] = style['-khtml-opacity'] = '';
4030 getHeight : function(contentHeight){
4033 hidden = Ext.isIE && me.isStyle('display', 'none'),
4034 h = MATH.max(dom.offsetHeight, hidden ? 0 : dom.clientHeight) || 0;
4036 h = !contentHeight ? h : h - me.getBorderWidth("tb") - me.getPadding("tb");
4037 return h < 0 ? 0 : h;
4041 getWidth : function(contentWidth){
4044 hidden = Ext.isIE && me.isStyle('display', 'none'),
4045 w = MATH.max(dom.offsetWidth, hidden ? 0 : dom.clientWidth) || 0;
4046 w = !contentWidth ? w : w - me.getBorderWidth("lr") - me.getPadding("lr");
4047 return w < 0 ? 0 : w;
4051 setWidth : function(width, animate){
4053 width = me.adjustWidth(width);
4054 !animate || !me.anim ?
4055 me.dom.style.width = me.addUnits(width) :
4056 me.anim({width : {to : width}}, me.preanim(arguments, 1));
4061 setHeight : function(height, animate){
4063 height = me.adjustHeight(height);
4064 !animate || !me.anim ?
4065 me.dom.style.height = me.addUnits(height) :
4066 me.anim({height : {to : height}}, me.preanim(arguments, 1));
4071 getBorderWidth : function(side){
4072 return this.addStyles(side, borders);
4076 getPadding : function(side){
4077 return this.addStyles(side, paddings);
4085 if(!data(dom, ISCLIPPED)){
4086 data(dom, ISCLIPPED, true);
4087 data(dom, ORIGINALCLIP, {
4088 o: me.getStyle(OVERFLOW),
4089 x: me.getStyle(OVERFLOWX),
4090 y: me.getStyle(OVERFLOWY)
4092 me.setStyle(OVERFLOW, HIDDEN);
4093 me.setStyle(OVERFLOWX, HIDDEN);
4094 me.setStyle(OVERFLOWY, HIDDEN);
4100 unclip : function(){
4104 if(data(dom, ISCLIPPED)){
4105 data(dom, ISCLIPPED, false);
4106 var o = data(dom, ORIGINALCLIP);
4108 me.setStyle(OVERFLOW, o.o);
4111 me.setStyle(OVERFLOWX, o.x);
4114 me.setStyle(OVERFLOWY, o.y);
4121 addStyles : function(sides, styles){
4123 m = sides.match(/\w/g),
4125 for (var i=0, len=m.length; i<len; i++) {
4126 s = m[i] && parseInt(this.getStyle(styles[m[i]]), 10);
4141 Ext.Element.boxMarkup = '<div class="{0}-tl"><div class="{0}-tr"><div class="{0}-tc"></div></div></div><div class="{0}-ml"><div class="{0}-mr"><div class="{0}-mc"></div></div></div><div class="{0}-bl"><div class="{0}-br"><div class="{0}-bc"></div></div></div>';
4143 Ext.Element.addMethods(function(){
4144 var INTERNAL = "_internal",
4145 pxMatch = /(\d+)px/;
4148 applyStyles : function(style){
4149 Ext.DomHelper.applyStyles(this.dom, style);
4154 getStyles : function(){
4156 Ext.each(arguments, function(v) {
4157 ret[v] = this.getStyle(v);
4164 getStyleSize : function(){
4170 if(s.width && s.width != 'auto'){
4171 w = parseInt(s.width, 10);
4172 if(me.isBorderBox()){
4173 w -= me.getFrameWidth('lr');
4176 if(s.height && s.height != 'auto'){
4177 h = parseInt(s.height, 10);
4178 if(me.isBorderBox()){
4179 h -= me.getFrameWidth('tb');
4182 return {width: w || me.getWidth(true), height: h || me.getHeight(true)};
4186 setOverflow : function(v){
4188 if(v=='auto' && Ext.isMac && Ext.isGecko2){
4189 dom.style.overflow = 'hidden';
4190 (function(){dom.style.overflow = 'auto';}).defer(1);
4192 dom.style.overflow = v;
4197 boxWrap : function(cls){
4198 cls = cls || 'x-box';
4199 var el = Ext.get(this.insertHtml("beforeBegin", "<div class='" + cls + "'>" + String.format(Ext.Element.boxMarkup, cls) + "</div>"));
4200 Ext.DomQuery.selectNode('.' + cls + '-mc', el.dom).appendChild(this.dom);
4205 setSize : function(width, height, animate){
4207 if(Ext.isObject(width)){
4208 height = width.height;
4209 width = width.width;
4211 width = me.adjustWidth(width);
4212 height = me.adjustHeight(height);
4213 if(!animate || !me.anim){
4214 me.dom.style.width = me.addUnits(width);
4215 me.dom.style.height = me.addUnits(height);
4217 me.anim({width: {to: width}, height: {to: height}}, me.preanim(arguments, 2));
4223 getComputedHeight : function(){
4225 h = Math.max(me.dom.offsetHeight, me.dom.clientHeight);
4227 h = parseInt(me.getStyle('height'), 10) || 0;
4228 if(!me.isBorderBox()){
4229 h += me.getFrameWidth('tb');
4236 getComputedWidth : function(){
4237 var w = Math.max(this.dom.offsetWidth, this.dom.clientWidth);
4239 w = parseInt(this.getStyle('width'), 10) || 0;
4240 if(!this.isBorderBox()){
4241 w += this.getFrameWidth('lr');
4248 getFrameWidth : function(sides, onlyContentBox){
4249 return onlyContentBox && this.isBorderBox() ? 0 : (this.getPadding(sides) + this.getBorderWidth(sides));
4253 addClassOnOver : function(className){
4256 Ext.fly(this, INTERNAL).addClass(className);
4259 Ext.fly(this, INTERNAL).removeClass(className);
4266 addClassOnFocus : function(className){
4267 this.on("focus", function(){
4268 Ext.fly(this, INTERNAL).addClass(className);
4270 this.on("blur", function(){
4271 Ext.fly(this, INTERNAL).removeClass(className);
4277 addClassOnClick : function(className){
4279 this.on("mousedown", function(){
4280 Ext.fly(dom, INTERNAL).addClass(className);
4281 var d = Ext.getDoc(),
4283 Ext.fly(dom, INTERNAL).removeClass(className);
4284 d.removeListener("mouseup", fn);
4286 d.on("mouseup", fn);
4292 getViewSize : function(contentBox){
4296 extdom = Ext.lib.Dom,
4297 isDoc = (d == doc || d == doc.body),
4298 isBB, w, h, tbBorder = 0, lrBorder = 0,
4299 tbPadding = 0, lrPadding = 0;
4301 return { width: extdom.getViewWidth(), height: extdom.getViewHeight() };
4303 isBB = me.isBorderBox();
4304 tbBorder = me.getBorderWidth('tb');
4305 lrBorder = me.getBorderWidth('lr');
4306 tbPadding = me.getPadding('tb');
4307 lrPadding = me.getPadding('lr');
4311 if (w = me.getStyle('width').match(pxMatch)){
4312 if ((w = parseInt(w[1], 10)) && isBB){
4314 w -= (lrBorder + lrPadding);
4320 if (!(w = d.clientWidth) && (w = d.offsetWidth)){
4323 if (w && contentBox){
4330 if (h = me.getStyle('height').match(pxMatch)){
4331 if ((h = parseInt(h[1], 10)) && isBB){
4333 h -= (tbBorder + tbPadding);
4339 if (!(h = d.clientHeight) && (h = d.offsetHeight)){
4342 if (h && contentBox){
4354 getSize : function(contentSize){
4355 return {width: this.getWidth(contentSize), height: this.getHeight(contentSize)};
4359 repaint : function(){
4361 this.addClass("x-repaint");
4362 setTimeout(function(){
4363 Ext.fly(dom).removeClass("x-repaint");
4369 unselectable : function(){
4370 this.dom.unselectable = "on";
4371 return this.swallowEvent("selectstart", true).
4372 applyStyles("-moz-user-select:none;-khtml-user-select:none;").
4373 addClass("x-unselectable");
4377 getMargins : function(side){
4380 hash = {t:"top", l:"left", r:"right", b: "bottom"},
4384 for (key in me.margins){
4385 o[hash[key]] = parseInt(me.getStyle(me.margins[key]), 10) || 0;
4389 return me.addStyles.call(me, side, me.margins);
4396 var D = Ext.lib.Dom,
4401 POSITION = "position",
4403 RELATIVE = "relative",
4407 Ext.Element.addMethods({
4410 return D.getX(this.dom);
4415 return D.getY(this.dom);
4420 return D.getXY(this.dom);
4424 getOffsetsTo : function(el){
4425 var o = this.getXY(),
4426 e = Ext.fly(el, '_internal').getXY();
4427 return [o[0]-e[0],o[1]-e[1]];
4431 setX : function(x, animate){
4432 return this.setXY([x, this.getY()], this.animTest(arguments, animate, 1));
4436 setY : function(y, animate){
4437 return this.setXY([this.getX(), y], this.animTest(arguments, animate, 1));
4441 setLeft : function(left){
4442 this.setStyle(LEFT, this.addUnits(left));
4447 setTop : function(top){
4448 this.setStyle(TOP, this.addUnits(top));
4453 setRight : function(right){
4454 this.setStyle(RIGHT, this.addUnits(right));
4459 setBottom : function(bottom){
4460 this.setStyle(BOTTOM, this.addUnits(bottom));
4465 setXY : function(pos, animate){
4467 if(!animate || !me.anim){
4468 D.setXY(me.dom, pos);
4470 me.anim({points: {to: pos}}, me.preanim(arguments, 1), 'motion');
4476 setLocation : function(x, y, animate){
4477 return this.setXY([x, y], this.animTest(arguments, animate, 2));
4481 moveTo : function(x, y, animate){
4482 return this.setXY([x, y], this.animTest(arguments, animate, 2));
4486 getLeft : function(local){
4487 return !local ? this.getX() : parseInt(this.getStyle(LEFT), 10) || 0;
4491 getRight : function(local){
4493 return !local ? me.getX() + me.getWidth() : (me.getLeft(true) + me.getWidth()) || 0;
4497 getTop : function(local) {
4498 return !local ? this.getY() : parseInt(this.getStyle(TOP), 10) || 0;
4502 getBottom : function(local){
4504 return !local ? me.getY() + me.getHeight() : (me.getTop(true) + me.getHeight()) || 0;
4508 position : function(pos, zIndex, x, y){
4511 if(!pos && me.isStyle(POSITION, STATIC)){
4512 me.setStyle(POSITION, RELATIVE);
4514 me.setStyle(POSITION, pos);
4517 me.setStyle(ZINDEX, zIndex);
4519 if(x || y) me.setXY([x || false, y || false]);
4523 clearPositioning : function(value){
4524 value = value || '';
4537 getPositioning : function(){
4538 var l = this.getStyle(LEFT);
4539 var t = this.getStyle(TOP);
4541 "position" : this.getStyle(POSITION),
4543 "right" : l ? "" : this.getStyle(RIGHT),
4545 "bottom" : t ? "" : this.getStyle(BOTTOM),
4546 "z-index" : this.getStyle(ZINDEX)
4551 setPositioning : function(pc){
4553 style = me.dom.style;
4557 if(pc.right == AUTO){
4560 if(pc.bottom == AUTO){
4568 translatePoints : function(x, y){
4569 y = isNaN(x[1]) ? y : x[1];
4570 x = isNaN(x[0]) ? x : x[0];
4572 relative = me.isStyle(POSITION, RELATIVE),
4574 l = parseInt(me.getStyle(LEFT), 10),
4575 t = parseInt(me.getStyle(TOP), 10);
4577 l = !isNaN(l) ? l : (relative ? 0 : me.dom.offsetLeft);
4578 t = !isNaN(t) ? t : (relative ? 0 : me.dom.offsetTop);
4580 return {left: (x - o[0] + l), top: (y - o[1] + t)};
4583 animTest : function(args, animate, i) {
4584 return !!animate && this.preanim ? this.preanim(args, i) : false;
4588 Ext.Element.addMethods({
4590 setBox : function(box, adjust, animate){
4594 if((adjust && !me.autoBoxAdjust) && !me.isBorderBox()){
4595 w -= (me.getBorderWidth("lr") + me.getPadding("lr"));
4596 h -= (me.getBorderWidth("tb") + me.getPadding("tb"));
4598 me.setBounds(box.x, box.y, w, h, me.animTest.call(me, arguments, animate, 2));
4603 getBox : function(contentBox, local) {
4608 getBorderWidth = me.getBorderWidth,
4609 getPadding = me.getPadding,
4617 left = parseInt(me.getStyle("left"), 10) || 0;
4618 top = parseInt(me.getStyle("top"), 10) || 0;
4621 var el = me.dom, w = el.offsetWidth, h = el.offsetHeight, bx;
4623 bx = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: w, height: h};
4625 l = getBorderWidth.call(me, "l") + getPadding.call(me, "l");
4626 r = getBorderWidth.call(me, "r") + getPadding.call(me, "r");
4627 t = getBorderWidth.call(me, "t") + getPadding.call(me, "t");
4628 b = getBorderWidth.call(me, "b") + getPadding.call(me, "b");
4629 bx = {x: xy[0]+l, y: xy[1]+t, 0: xy[0]+l, 1: xy[1]+t, width: w-(l+r), height: h-(t+b)};
4631 bx.right = bx.x + bx.width;
4632 bx.bottom = bx.y + bx.height;
4637 move : function(direction, distance, animate){
4642 left = [x - distance, y],
4643 right = [x + distance, y],
4644 top = [x, y - distance],
4645 bottom = [x, y + distance],
4659 direction = direction.toLowerCase();
4660 me.moveTo(hash[direction][0], hash[direction][1], me.animTest.call(me, arguments, animate, 2));
4664 setLeftTop : function(left, top){
4666 style = me.dom.style;
4667 style.left = me.addUnits(left);
4668 style.top = me.addUnits(top);
4673 getRegion : function(){
4674 return Ext.lib.Dom.getRegion(this.dom);
4678 setBounds : function(x, y, width, height, animate){
4680 if (!animate || !me.anim) {
4681 me.setSize(width, height);
4682 me.setLocation(x, y);
4684 me.anim({points: {to: [x, y]},
4685 width: {to: me.adjustWidth(width)},
4686 height: {to: me.adjustHeight(height)}},
4687 me.preanim(arguments, 4),
4694 setRegion : function(region, animate) {
4695 return this.setBounds(region.left, region.top, region.right-region.left, region.bottom-region.top, this.animTest.call(this, arguments, animate, 1));
4698 Ext.Element.addMethods({
4700 isScrollable : function(){
4702 return dom.scrollHeight > dom.clientHeight || dom.scrollWidth > dom.clientWidth;
4706 scrollTo : function(side, value){
4707 this.dom["scroll" + (/top/i.test(side) ? "Top" : "Left")] = value;
4712 getScroll : function(){
4716 docElement = doc.documentElement,
4721 if(d == doc || d == body){
4722 if(Ext.isIE && Ext.isStrict){
4723 l = docElement.scrollLeft;
4724 t = docElement.scrollTop;
4726 l = window.pageXOffset;
4727 t = window.pageYOffset;
4729 ret = {left: l || (body ? body.scrollLeft : 0), top: t || (body ? body.scrollTop : 0)};
4731 ret = {left: d.scrollLeft, top: d.scrollTop};
4736 Ext.Element.addMethods({
4738 scrollTo : function(side, value, animate){
4739 var top = /top/i.test(side),
4743 if (!animate || !me.anim) {
4744 prop = 'scroll' + (top ? 'Top' : 'Left'),
4747 prop = 'scroll' + (top ? 'Left' : 'Top'),
4748 me.anim({scroll: {to: top ? [dom[prop], value] : [value, dom[prop]]}},
4749 me.preanim(arguments, 2), 'scroll');
4755 scrollIntoView : function(container, hscroll){
4756 var c = Ext.getDom(container) || Ext.getBody().dom,
4758 o = this.getOffsetsTo(c),
4759 l = o[0] + c.scrollLeft,
4760 t = o[1] + c.scrollTop,
4761 b = t + el.offsetHeight,
4762 r = l + el.offsetWidth,
4763 ch = c.clientHeight,
4764 ct = parseInt(c.scrollTop, 10),
4765 cl = parseInt(c.scrollLeft, 10),
4767 cr = cl + c.clientWidth;
4769 if (el.offsetHeight > ch || t < ct) {
4774 c.scrollTop = c.scrollTop;
4776 if(hscroll !== false){
4777 if(el.offsetWidth > c.clientWidth || l < cl){
4780 c.scrollLeft = r - c.clientWidth;
4782 c.scrollLeft = c.scrollLeft;
4788 scrollChildIntoView : function(child, hscroll){
4789 Ext.fly(child, '_scrollChildIntoView').scrollIntoView(this, hscroll);
4793 scroll : function(direction, distance, animate){
4794 if(!this.isScrollable()){
4798 l = el.scrollLeft, t = el.scrollTop,
4799 w = el.scrollWidth, h = el.scrollHeight,
4800 cw = el.clientWidth, ch = el.clientHeight,
4801 scrolled = false, v,
4803 l: Math.min(l + distance, w-cw),
4804 r: v = Math.max(l - distance, 0),
4805 t: Math.max(t - distance, 0),
4806 b: Math.min(t + distance, h-ch)
4811 direction = direction.substr(0, 1);
4812 if((v = hash[direction]) > -1){
4814 this.scrollTo(direction == 'l' || direction == 'r' ? 'left' : 'top', v, this.preanim(arguments, 2));
4820 Ext.Element.VISIBILITY = 1;
4822 Ext.Element.DISPLAY = 2;
4824 Ext.Element.addMethods(function(){
4825 var VISIBILITY = "visibility",
4826 DISPLAY = "display",
4829 ORIGINALDISPLAY = 'originalDisplay',
4830 VISMODE = 'visibilityMode',
4831 ELDISPLAY = Ext.Element.DISPLAY,
4832 data = Ext.Element.data,
4833 getDisplay = function(dom){
4834 var d = data(dom, ORIGINALDISPLAY);
4835 if(d === undefined){
4836 data(dom, ORIGINALDISPLAY, d = '');
4840 getVisMode = function(dom){
4841 var m = data(dom, VISMODE);
4842 if(m === undefined){
4843 data(dom, VISMODE, m = 1)
4850 originalDisplay : "",
4854 setVisibilityMode : function(visMode){
4855 data(this.dom, VISMODE, visMode);
4860 animate : function(args, duration, onComplete, easing, animType){
4861 this.anim(args, {duration: duration, callback: onComplete, easing: easing}, animType);
4866 anim : function(args, opt, animType, defaultDur, defaultEase, cb){
4867 animType = animType || 'run';
4870 anim = Ext.lib.Anim[animType](
4873 (opt.duration || defaultDur) || .35,
4874 (opt.easing || defaultEase) || 'easeOut',
4877 if(opt.callback) opt.callback.call(opt.scope || me, me, opt);
4886 preanim : function(a, i){
4887 return !a[i] ? false : (Ext.isObject(a[i]) ? a[i]: {duration: a[i+1], callback: a[i+2], easing: a[i+3]});
4891 isVisible : function() {
4892 return !this.isStyle(VISIBILITY, HIDDEN) && !this.isStyle(DISPLAY, NONE);
4896 setVisible : function(visible, animate){
4899 isDisplay = getVisMode(this.dom) == ELDISPLAY;
4901 if (!animate || !me.anim) {
4903 me.setDisplayed(visible);
4906 dom.style.visibility = visible ? "visible" : HIDDEN;
4912 me.setVisible(true);
4914 me.anim({opacity: { to: (visible?1:0) }},
4915 me.preanim(arguments, 1),
4921 dom.style[isDisplay ? DISPLAY : VISIBILITY] = (isDisplay) ? NONE : HIDDEN;
4922 Ext.fly(dom).setOpacity(1);
4930 toggle : function(animate){
4932 me.setVisible(!me.isVisible(), me.preanim(arguments, 0));
4937 setDisplayed : function(value) {
4938 if(typeof value == "boolean"){
4939 value = value ? getDisplay(this.dom) : NONE;
4941 this.setStyle(DISPLAY, value);
4946 fixDisplay : function(){
4948 if(me.isStyle(DISPLAY, NONE)){
4949 me.setStyle(VISIBILITY, HIDDEN);
4950 me.setStyle(DISPLAY, getDisplay(this.dom));
4951 if(me.isStyle(DISPLAY, NONE)){
4952 me.setStyle(DISPLAY, "block");
4958 hide : function(animate){
4959 this.setVisible(false, this.preanim(arguments, 0));
4964 show : function(animate){
4965 this.setVisible(true, this.preanim(arguments, 0));
4970 Ext.Element.addMethods(
4972 var VISIBILITY = "visibility",
4973 DISPLAY = "display",
4976 XMASKED = "x-masked",
4977 XMASKEDRELATIVE = "x-masked-relative",
4978 data = Ext.Element.data;
4982 isVisible : function(deep) {
4983 var vis = !this.isStyle(VISIBILITY,HIDDEN) && !this.isStyle(DISPLAY,NONE),
4984 p = this.dom.parentNode;
4985 if(deep !== true || !vis){
4988 while(p && !/body/i.test(p.tagName)){
4989 if(!Ext.fly(p, '_isVisible').isVisible()){
4998 isDisplayed : function() {
4999 return !this.isStyle(DISPLAY, NONE);
5003 enableDisplayMode : function(display){
5004 this.setVisibilityMode(Ext.Element.DISPLAY);
5005 if(!Ext.isEmpty(display)){
5006 data(this.dom, 'originalDisplay', display);
5012 mask : function(msg, msgCls){
5016 EXTELMASKMSG = "ext-el-mask-msg",
5020 if(me.getStyle("position") == "static"){
5021 me.addClass(XMASKEDRELATIVE);
5023 if((el = data(dom, 'maskMsg'))){
5026 if((el = data(dom, 'mask'))){
5030 mask = dh.append(dom, {cls : "ext-el-mask"}, true);
5031 data(dom, 'mask', mask);
5033 me.addClass(XMASKED);
5034 mask.setDisplayed(true);
5035 if(typeof msg == 'string'){
5036 var mm = dh.append(dom, {cls : EXTELMASKMSG, cn:{tag:'div'}}, true);
5037 data(dom, 'maskMsg', mm);
5038 mm.dom.className = msgCls ? EXTELMASKMSG + " " + msgCls : EXTELMASKMSG;
5039 mm.dom.firstChild.innerHTML = msg;
5040 mm.setDisplayed(true);
5043 if(Ext.isIE && !(Ext.isIE7 && Ext.isStrict) && me.getStyle('height') == 'auto'){
5044 mask.setSize(undefined, me.getHeight());
5050 unmask : function(){
5053 mask = data(dom, 'mask'),
5054 maskMsg = data(dom, 'maskMsg');
5058 data(dom, 'maskMsg', undefined);
5061 data(dom, 'mask', undefined);
5063 me.removeClass([XMASKED, XMASKEDRELATIVE]);
5067 isMasked : function(){
5068 var m = data(this.dom, 'mask');
5069 return m && m.isVisible();
5073 createShim : function(){
5074 var el = document.createElement('iframe'),
5076 el.frameBorder = '0';
5077 el.className = 'ext-shim';
5078 el.src = Ext.SSL_SECURE_URL;
5079 shim = Ext.get(this.dom.parentNode.insertBefore(el, this.dom));
5080 shim.autoBoxAdjust = false;
5085 Ext.Element.addMethods({
5087 addKeyListener : function(key, fn, scope){
5089 if(!Ext.isObject(key) || Ext.isArray(key)){
5105 return new Ext.KeyMap(this, config);
5109 addKeyMap : function(config){
5110 return new Ext.KeyMap(this, config);
5115 UNDEFINED = undefined,
5129 ABSOLUTE = "absolute",
5130 VISIBLE = "visible",
5132 POSITION = "position",
5133 EASEOUT = "easeOut",
5135 flyEl = new Ext.Element.Flyweight(),
5137 getObject = function(o){
5140 fly = function(dom){
5142 flyEl.id = Ext.id(dom);
5146 getQueue = function(id){
5152 setQueue = function(id, value){
5157 Ext.enableFx = TRUE;
5164 switchStatements : function(key, fn, argHash){
5165 return fn.apply(this, argHash[key]);
5169 slideIn : function(anchor, o){
5185 anchor = anchor || "t";
5187 me.queueFx(o, function(){
5188 xy = fly(dom).getXY();
5190 fly(dom).fixDisplay();
5193 r = fly(dom).getFxRestore();
5194 b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight};
5195 b.right = b.x + b.width;
5196 b.bottom = b.y + b.height;
5199 fly(dom).setWidth(b.width).setHeight(b.height);
5202 wrap = fly(dom).fxWrap(r.pos, o, HIDDEN);
5204 st.visibility = VISIBLE;
5205 st.position = ABSOLUTE;
5209 fly(dom).fxUnwrap(wrap, r.pos, o);
5211 st.height = r.height;
5212 fly(dom).afterFx(o);
5216 pt = {to: [b.x, b.y]};
5218 bh = {to: b.height};
5220 function argCalc(wrap, style, ww, wh, sXY, sXYval, s1, s2, w, h, p){
5222 fly(wrap).setWidth(ww).setHeight(wh);
5224 fly(wrap)[sXY](sXYval);
5226 style[s1] = style[s2] = "0";
5239 args = fly(dom).switchStatements(anchor.toLowerCase(), argCalc, {
5240 t : [wrap, st, b.width, 0, NULL, NULL, LEFT, BOTTOM, NULL, bh, NULL],
5241 l : [wrap, st, 0, b.height, NULL, NULL, RIGHT, TOP, bw, NULL, NULL],
5242 r : [wrap, st, b.width, b.height, SETX, b.right, LEFT, TOP, NULL, NULL, pt],
5243 b : [wrap, st, b.width, b.height, SETY, b.bottom, LEFT, TOP, NULL, bh, pt],
5244 tl : [wrap, st, 0, 0, NULL, NULL, RIGHT, BOTTOM, bw, bh, pt],
5245 bl : [wrap, st, 0, 0, SETY, b.y + b.height, RIGHT, TOP, bw, bh, pt],
5246 br : [wrap, st, 0, 0, SETXY, [b.right, b.bottom], LEFT, TOP, bw, bh, pt],
5247 tr : [wrap, st, 0, 0, SETX, b.x + b.width, LEFT, BOTTOM, bw, bh, pt]
5250 st.visibility = VISIBLE;
5253 arguments.callee.anim = fly(wrap).fxanim(args,
5264 slideOut : function(anchor, o){
5276 anchor = anchor || "t";
5278 me.queueFx(o, function(){
5281 r = fly(dom).getFxRestore();
5282 b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight};
5283 b.right = b.x + b.width;
5284 b.bottom = b.y + b.height;
5287 fly(dom).setWidth(b.width).setHeight(b.height);
5290 wrap = fly(dom).fxWrap(r.pos, o, VISIBLE);
5292 st.visibility = VISIBLE;
5293 st.position = ABSOLUTE;
5294 fly(wrap).setWidth(b.width).setHeight(b.height);
5297 o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
5298 fly(dom).fxUnwrap(wrap, r.pos, o);
5300 st.height = r.height;
5301 fly(dom).afterFx(o);
5304 function argCalc(style, s1, s2, p1, v1, p2, v2, p3, v3){
5307 style[s1] = style[s2] = "0";
5319 a = fly(dom).switchStatements(anchor.toLowerCase(), argCalc, {
5320 t : [st, LEFT, BOTTOM, HEIGHT, zero],
5321 l : [st, RIGHT, TOP, WIDTH, zero],
5322 r : [st, LEFT, TOP, WIDTH, zero, POINTS, {to : [b.right, b.y]}],
5323 b : [st, LEFT, TOP, HEIGHT, zero, POINTS, {to : [b.x, b.bottom]}],
5324 tl : [st, RIGHT, BOTTOM, WIDTH, zero, HEIGHT, zero],
5325 bl : [st, RIGHT, TOP, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.x, b.bottom]}],
5326 br : [st, LEFT, TOP, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.x + b.width, b.bottom]}],
5327 tr : [st, LEFT, BOTTOM, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.right, b.y]}]
5330 arguments.callee.anim = fly(wrap).fxanim(a,
5350 me.queueFx(o, function(){
5351 width = fly(dom).getWidth();
5352 height = fly(dom).getHeight();
5353 fly(dom).clearOpacity();
5357 r = fly(dom).getFxRestore();
5360 o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
5361 fly(dom).clearOpacity();
5362 fly(dom).setPositioning(r.pos);
5364 st.height = r.height;
5366 fly(dom).afterFx(o);
5369 arguments.callee.anim = fly(dom).fxanim({
5370 width : {to : fly(dom).adjustWidth(width * 2)},
5371 height : {to : fly(dom).adjustHeight(height * 2)},
5372 points : {by : [-width * .5, -height * .5]},
5374 fontSize: {to : 200, unit: "%"}
5386 switchOff : function(o){
5393 me.queueFx(o, function(){
5394 fly(dom).clearOpacity();
5398 r = fly(dom).getFxRestore();
5401 o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
5402 fly(dom).clearOpacity();
5403 fly(dom).setPositioning(r.pos);
5405 st.height = r.height;
5406 fly(dom).afterFx(o);
5409 fly(dom).fxanim({opacity : {to : 0.3}},
5415 fly(dom).clearOpacity();
5419 points : {by : [0, fly(dom).getHeight() * .5]}
5433 highlight : function(color, o){
5437 attr = o.attr || "backgroundColor",
5441 me.queueFx(o, function(){
5442 fly(dom).clearOpacity();
5446 dom.style[attr] = restore;
5447 fly(dom).afterFx(o);
5449 restore = dom.style[attr];
5450 a[attr] = {from: color || "ffff9c", to: o.endColor || fly(dom).getColor(attr) || "ffffff"};
5451 arguments.callee.anim = fly(dom).fxanim(a,
5462 frame : function(color, count, o){
5469 me.queueFx(o, function(){
5470 color = color || '#C3DAF9';
5471 if(color.length == 6){
5472 color = '#' + color;
5477 var xy = fly(dom).getXY(),
5478 b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight},
5480 proxy = fly(document.body || document.documentElement).createChild({
5482 position : ABSOLUTE,
5484 border : '0px solid ' + color
5487 return proxy.queueFx({}, animFn);
5491 arguments.callee.anim = {
5500 var scale = Ext.isBorderBox ? 2 : 1;
5501 active = proxy.anim({
5502 top : {from : b.y, to : b.y - 20},
5503 left : {from : b.x, to : b.x - 20},
5504 borderWidth : {from : 0, to : 10},
5505 opacity : {from : 1, to : 0},
5506 height : {from : b.height, to : b.height + 20 * scale},
5507 width : {from : b.width, to : b.width + 20 * scale}
5509 duration: o.duration || 1,
5510 callback: function() {
5512 --count > 0 ? queue() : fly(dom).afterFx(o);
5515 arguments.callee.anim = {
5528 pause : function(seconds){
5532 this.queueFx({}, function(){
5533 t = setTimeout(function(){
5534 fly(dom).afterFx({});
5536 arguments.callee.anim = {
5540 fly(dom).afterFx({});
5548 fadeIn : function(o){
5552 to = o.endOpacity || 1;
5554 me.queueFx(o, function(){
5555 fly(dom).setOpacity(0);
5556 fly(dom).fixDisplay();
5557 dom.style.visibility = VISIBLE;
5558 arguments.callee.anim = fly(dom).fxanim({opacity:{to:to}},
5559 o, NULL, .5, EASEOUT, function(){
5561 fly(dom).clearOpacity();
5563 fly(dom).afterFx(o);
5570 fadeOut : function(o){
5575 to = o.endOpacity || 0;
5577 me.queueFx(o, function(){
5578 arguments.callee.anim = fly(dom).fxanim({
5579 opacity : {to : to}},
5586 Ext.Element.data(dom, 'visibilityMode') == Ext.Element.DISPLAY || o.useDisplay ?
5587 style.display = "none" :
5588 style.visibility = HIDDEN;
5590 fly(dom).clearOpacity();
5592 fly(dom).afterFx(o);
5599 scale : function(w, h, o){
5600 this.shift(Ext.apply({}, o, {
5608 shift : function(o){
5613 this.queueFx(o, function(){
5614 for (var prop in o) {
5615 if (o[prop] != UNDEFINED) {
5616 a[prop] = {to : o[prop]};
5620 a.width ? a.width.to = fly(dom).adjustWidth(o.width) : a;
5621 a.height ? a.height.to = fly(dom).adjustWidth(o.height) : a;
5623 if (a.x || a.y || a.xy) {
5625 {to : [ a.x ? a.x.to : fly(dom).getX(),
5626 a.y ? a.y.to : fly(dom).getY()]};
5629 arguments.callee.anim = fly(dom).fxanim(a,
5635 fly(dom).afterFx(o);
5642 ghost : function(anchor, o){
5647 a = {opacity: {to: 0}, points: {}},
5653 anchor = anchor || "b";
5655 me.queueFx(o, function(){
5657 r = fly(dom).getFxRestore();
5658 w = fly(dom).getWidth();
5659 h = fly(dom).getHeight();
5662 o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
5663 fly(dom).clearOpacity();
5664 fly(dom).setPositioning(r.pos);
5666 st.height = r.height;
5667 fly(dom).afterFx(o);
5670 pt.by = fly(dom).switchStatements(anchor.toLowerCase(), function(v1,v2){ return [v1, v2];}, {
5681 arguments.callee.anim = fly(dom).fxanim(a,
5691 syncFx : function(){
5693 me.fxDefaults = Ext.apply(me.fxDefaults || {}, {
5702 sequenceFx : function(){
5704 me.fxDefaults = Ext.apply(me.fxDefaults || {}, {
5713 nextFx : function(){
5714 var ef = getQueue(this.dom.id)[0];
5721 hasActiveFx : function(){
5722 return getQueue(this.dom.id)[0];
5726 stopFx : function(finish){
5729 if(me.hasActiveFx()){
5730 var cur = getQueue(id)[0];
5731 if(cur && cur.anim){
5732 if(cur.anim.isAnimated){
5733 setQueue(id, [cur]);
5734 cur.anim.stop(finish !== undefined ? finish : TRUE);
5744 beforeFx : function(o){
5745 if(this.hasActiveFx() && !o.concurrent){
5756 hasFxBlock : function(){
5757 var q = getQueue(this.dom.id);
5758 return q && q[0] && q[0].block;
5762 queueFx : function(o, fn){
5763 var me = fly(this.dom);
5764 if(!me.hasFxBlock()){
5765 Ext.applyIf(o, me.fxDefaults);
5767 var run = me.beforeFx(o);
5769 getQueue(me.dom.id).push(fn);
5781 fxWrap : function(pos, o, vis){
5785 if(!o.wrap || !(wrap = Ext.getDom(o.wrap))){
5787 wrapXY = fly(dom).getXY();
5789 var div = document.createElement("div");
5790 div.style.visibility = vis;
5791 wrap = dom.parentNode.insertBefore(div, dom);
5792 fly(wrap).setPositioning(pos);
5793 if(fly(wrap).isStyle(POSITION, "static")){
5794 fly(wrap).position("relative");
5796 fly(dom).clearPositioning('auto');
5798 wrap.appendChild(dom);
5800 fly(wrap).setXY(wrapXY);
5807 fxUnwrap : function(wrap, pos, o){
5809 fly(dom).clearPositioning();
5810 fly(dom).setPositioning(pos);
5812 var pn = fly(wrap).dom.parentNode;
5813 pn.insertBefore(dom, wrap);
5819 getFxRestore : function(){
5820 var st = this.dom.style;
5821 return {pos: this.getPositioning(), width: st.width, height : st.height};
5825 afterFx : function(o){
5829 fly(dom).setStyle(o.afterStyle);
5832 fly(dom).addClass(o.afterCls);
5834 if(o.remove == TRUE){
5838 o.callback.call(o.scope, fly(dom));
5841 getQueue(id).shift();
5847 fxanim : function(args, opt, animType, defaultDur, defaultEase, cb){
5848 animType = animType || 'run';
5850 var anim = Ext.lib.Anim[animType](
5853 (opt.duration || defaultDur) || .35,
5854 (opt.easing || defaultEase) || EASEOUT,
5864 Ext.Fx.resize = Ext.Fx.scale;
5868 Ext.Element.addMethods(Ext.Fx);
5871 Ext.CompositeElementLite = function(els, root){
5874 this.add(els, root);
5875 this.el = new Ext.Element.Flyweight();
5878 Ext.CompositeElementLite.prototype = {
5882 getElement : function(el){
5891 transformElement : function(el){
5892 return Ext.getDom(el);
5896 getCount : function(){
5897 return this.elements.length;
5900 add : function(els, root){
5902 elements = me.elements;
5906 if(Ext.isString(els)){
5907 els = Ext.Element.selectorFunction(els, root);
5908 }else if(els.isComposite){
5910 }else if(!Ext.isIterable(els)){
5914 for(var i = 0, len = els.length; i < len; ++i){
5915 elements.push(me.transformElement(els[i]));
5920 invoke : function(fn, args){
5926 for(i = 0; i<len; i++) {
5929 Ext.Element.prototype[fn].apply(me.getElement(e), args);
5935 item : function(index){
5937 el = me.elements[index],
5941 out = me.getElement(el);
5947 addListener : function(eventName, handler, scope, opt){
5948 var els = this.elements,
5952 for(i = 0; i<len; i++) {
5955 Ext.EventManager.on(e, eventName, handler, scope || e, opt);
5961 each : function(fn, scope){
5967 for(i = 0; i<len; i++) {
5970 e = this.getElement(e);
5971 if(fn.call(scope || e, e, me, i)){
5980 fill : function(els){
5988 filter : function(selector){
5991 elements = me.elements,
5992 fn = Ext.isFunction(selector) ? selector
5994 return el.is(selector);
5998 me.each(function(el, self, i){
5999 if(fn(el, i) !== false){
6000 els[els.length] = me.transformElement(el);
6008 indexOf : function(el){
6009 return this.elements.indexOf(this.transformElement(el));
6013 replaceElement : function(el, replacement, domReplace){
6014 var index = !isNaN(el) ? el : this.indexOf(el),
6017 replacement = Ext.getDom(replacement);
6019 d = this.elements[index];
6020 d.parentNode.insertBefore(replacement, d);
6023 this.elements.splice(index, 1, replacement);
6034 Ext.CompositeElementLite.prototype.on = Ext.CompositeElementLite.prototype.addListener;
6038 ElProto = Ext.Element.prototype,
6039 CelProto = Ext.CompositeElementLite.prototype;
6041 for(fnName in ElProto){
6042 if(Ext.isFunction(ElProto[fnName])){
6044 CelProto[fnName] = CelProto[fnName] || function(){
6045 return this.invoke(fnName, arguments);
6047 }).call(CelProto, fnName);
6054 Ext.Element.selectorFunction = Ext.DomQuery.select;
6058 Ext.Element.select = function(selector, root){
6060 if(typeof selector == "string"){
6061 els = Ext.Element.selectorFunction(selector, root);
6062 }else if(selector.length !== undefined){
6065 throw "Invalid selector";
6067 return new Ext.CompositeElementLite(els);
6070 Ext.select = Ext.Element.select;
6071 Ext.apply(Ext.CompositeElementLite.prototype, {
6072 addElements : function(els, root){
6076 if(typeof els == "string"){
6077 els = Ext.Element.selectorFunction(els, root);
6079 var yels = this.elements;
6080 Ext.each(els, function(e) {
6081 yels.push(Ext.get(e));
6088 return this.item(0);
6093 return this.item(this.getCount()-1);
6097 contains : function(el){
6098 return this.indexOf(el) != -1;
6102 removeElement : function(keys, removeDom){
6104 els = this.elements,
6106 Ext.each(keys, function(val){
6107 if ((el = (els[val] || els[val = me.indexOf(val)]))) {
6122 Ext.CompositeElement = function(els, root){
6124 this.add(els, root);
6127 Ext.extend(Ext.CompositeElement, Ext.CompositeElementLite, {
6130 getElement : function(el){
6136 transformElement : function(el){
6148 Ext.Element.select = function(selector, unique, root){
6150 if(typeof selector == "string"){
6151 els = Ext.Element.selectorFunction(selector, root);
6152 }else if(selector.length !== undefined){
6155 throw "Invalid selector";
6158 return (unique === true) ? new Ext.CompositeElement(els) : new Ext.CompositeElementLite(els);
6162 Ext.select = Ext.Element.select;(function(){
6163 var BEFOREREQUEST = "beforerequest",
6164 REQUESTCOMPLETE = "requestcomplete",
6165 REQUESTEXCEPTION = "requestexception",
6166 UNDEFINED = undefined,
6173 Ext.data.Connection = function(config){
6174 Ext.apply(this, config);
6183 Ext.data.Connection.superclass.constructor.call(this);
6186 Ext.extend(Ext.data.Connection, Ext.util.Observable, {
6197 disableCaching: true,
6200 disableCachingParam: '_dc',
6203 request : function(o){
6205 if(me.fireEvent(BEFOREREQUEST, me, o)){
6207 if(!Ext.isEmpty(o.indicatorText)){
6208 me.indicatorText = '<div class="loading-indicator">'+o.indicatorText+"</div>";
6210 if(me.indicatorText) {
6211 Ext.getDom(o.el).innerHTML = me.indicatorText;
6213 o.success = (Ext.isFunction(o.success) ? o.success : function(){}).createInterceptor(function(response) {
6214 Ext.getDom(o.el).innerHTML = response.responseText;
6219 url = o.url || me.url,
6221 cb = {success: me.handleResponse,
6222 failure: me.handleFailure,
6224 argument: {options: o},
6225 timeout : o.timeout || me.timeout
6231 if (Ext.isFunction(p)) {
6232 p = p.call(o.scope||WINDOW, o);
6235 p = Ext.urlEncode(me.extraParams, Ext.isObject(p) ? Ext.urlEncode(p) : p);
6237 if (Ext.isFunction(url)) {
6238 url = url.call(o.scope || WINDOW, o);
6241 if((form = Ext.getDom(o.form))){
6242 url = url || form.action;
6243 if(o.isUpload || /multipart\/form-data/i.test(form.getAttribute("enctype"))) {
6244 return me.doFormUpload.call(me, o, p, url);
6246 serForm = Ext.lib.Ajax.serializeForm(form);
6247 p = p ? (p + '&' + serForm) : serForm;
6250 method = o.method || me.method || ((p || o.xmlData || o.jsonData) ? POST : GET);
6252 if(method === GET && (me.disableCaching && o.disableCaching !== false) || o.disableCaching === true){
6253 var dcp = o.disableCachingParam || me.disableCachingParam;
6254 url = Ext.urlAppend(url, dcp + '=' + (new Date().getTime()));
6257 o.headers = Ext.apply(o.headers || {}, me.defaultHeaders || {});
6259 if(o.autoAbort === true || me.autoAbort) {
6263 if((method == GET || o.xmlData || o.jsonData) && p){
6264 url = Ext.urlAppend(url, p);
6267 return (me.transId = Ext.lib.Ajax.request(method, url, cb, p, o));
6269 return o.callback ? o.callback.apply(o.scope, [o,UNDEFINED,UNDEFINED]) : null;
6274 isLoading : function(transId){
6275 return transId ? Ext.lib.Ajax.isCallInProgress(transId) : !! this.transId;
6279 abort : function(transId){
6280 if(transId || this.isLoading()){
6281 Ext.lib.Ajax.abort(transId || this.transId);
6286 handleResponse : function(response){
6287 this.transId = false;
6288 var options = response.argument.options;
6289 response.argument = options ? options.argument : null;
6290 this.fireEvent(REQUESTCOMPLETE, this, response, options);
6291 if(options.success){
6292 options.success.call(options.scope, response, options);
6294 if(options.callback){
6295 options.callback.call(options.scope, options, true, response);
6300 handleFailure : function(response, e){
6301 this.transId = false;
6302 var options = response.argument.options;
6303 response.argument = options ? options.argument : null;
6304 this.fireEvent(REQUESTEXCEPTION, this, response, options, e);
6305 if(options.failure){
6306 options.failure.call(options.scope, response, options);
6308 if(options.callback){
6309 options.callback.call(options.scope, options, false, response);
6314 doFormUpload : function(o, ps, url){
6317 frame = doc.createElement('iframe'),
6318 form = Ext.getDom(o.form),
6321 encoding = 'multipart/form-data',
6323 target: form.target,
6324 method: form.method,
6325 encoding: form.encoding,
6326 enctype: form.enctype,
6330 Ext.fly(frame).set({
6334 src: Ext.SSL_SECURE_URL
6336 doc.body.appendChild(frame);
6340 document.frames[id].name = id;
6348 action: url || buf.action
6352 Ext.iterate(Ext.urlDecode(ps, false), function(k, v){
6353 hd = doc.createElement('input');
6359 form.appendChild(hd);
6366 r = {responseText : '',
6368 argument : o.argument},
6373 doc = frame.contentWindow.document || frame.contentDocument || WINDOW.frames[id].document;
6376 if(/textarea/i.test((firstChild = doc.body.firstChild || {}).tagName)){
6377 r.responseText = firstChild.value;
6379 r.responseText = doc.body.innerHTML;
6383 r.responseXML = doc.XMLDocument || doc;
6388 Ext.EventManager.removeListener(frame, LOAD, cb, me);
6390 me.fireEvent(REQUESTCOMPLETE, me, r, o);
6392 function runCallback(fn, scope, args){
6393 if(Ext.isFunction(fn)){
6394 fn.apply(scope, args);
6398 runCallback(o.success, o.scope, [r, o]);
6399 runCallback(o.callback, o.scope, [o, true, r]);
6401 if(!me.debugUploads){
6402 setTimeout(function(){Ext.removeNode(frame);}, 100);
6406 Ext.EventManager.on(frame, LOAD, cb, this);
6409 Ext.fly(form).set(buf);
6410 Ext.each(hiddens, function(h) {
6418 Ext.Ajax = new Ext.data.Connection({
6439 serializeForm : function(form){
6440 return Ext.lib.Ajax.serializeForm(form);
6444 Ext.UpdateManager = Ext.Updater = Ext.extend(Ext.util.Observable,
6446 var BEFOREUPDATE = "beforeupdate",
6448 FAILURE = "failure";
6451 function processSuccess(response){
6453 me.transaction = null;
6454 if (response.argument.form && response.argument.reset) {
6456 response.argument.form.reset();
6459 if (me.loadScripts) {
6460 me.renderer.render(me.el, response, me,
6461 updateComplete.createDelegate(me, [response]));
6463 me.renderer.render(me.el, response, me);
6464 updateComplete.call(me, response);
6469 function updateComplete(response, type, success){
6470 this.fireEvent(type || UPDATE, this.el, response);
6471 if(Ext.isFunction(response.argument.callback)){
6472 response.argument.callback.call(response.argument.scope, this.el, Ext.isEmpty(success) ? true : false, response, response.argument.options);
6477 function processFailure(response){
6478 updateComplete.call(this, response, FAILURE, !!(this.transaction = null));
6482 constructor: function(el, forceNew){
6485 if(!forceNew && el.updateManager){
6486 return el.updateManager;
6491 me.defaultUrl = null;
6502 Ext.apply(me, Ext.Updater.defaults);
6511 me.transaction = null;
6513 me.refreshDelegate = me.refresh.createDelegate(me);
6515 me.updateDelegate = me.update.createDelegate(me);
6517 me.formUpdateDelegate = (me.formUpdate || function(){}).createDelegate(me);
6520 me.renderer = me.renderer || me.getDefaultRenderer();
6522 Ext.Updater.superclass.constructor.call(me);
6526 setRenderer : function(renderer){
6527 this.renderer = renderer;
6531 getRenderer : function(){
6532 return this.renderer;
6536 getDefaultRenderer: function() {
6537 return new Ext.Updater.BasicRenderer();
6541 setDefaultUrl : function(defaultUrl){
6542 this.defaultUrl = defaultUrl;
6551 update : function(url, params, callback, discardUrl){
6556 if(me.fireEvent(BEFOREUPDATE, me.el, url, params) !== false){
6557 if(Ext.isObject(url)){
6560 params = params || cfg.params;
6561 callback = callback || cfg.callback;
6562 discardUrl = discardUrl || cfg.discardUrl;
6563 callerScope = cfg.scope;
6564 if(!Ext.isEmpty(cfg.nocache)){me.disableCaching = cfg.nocache;};
6565 if(!Ext.isEmpty(cfg.text)){me.indicatorText = '<div class="loading-indicator">'+cfg.text+"</div>";};
6566 if(!Ext.isEmpty(cfg.scripts)){me.loadScripts = cfg.scripts;};
6567 if(!Ext.isEmpty(cfg.timeout)){me.timeout = cfg.timeout;};
6572 me.defaultUrl = url;
6574 if(Ext.isFunction(url)){
6578 var o = Ext.apply({}, {
6580 params: (Ext.isFunction(params) && callerScope) ? params.createDelegate(callerScope) : params,
6581 success: processSuccess,
6582 failure: processFailure,
6584 callback: undefined,
6585 timeout: (me.timeout*1000),
6586 disableCaching: me.disableCaching,
6591 "callback": callback,
6592 "scope": callerScope || window,
6597 me.transaction = Ext.Ajax.request(o);
6602 formUpdate : function(form, url, reset, callback){
6604 if(me.fireEvent(BEFOREUPDATE, me.el, form, url) !== false){
6605 if(Ext.isFunction(url)){
6608 form = Ext.getDom(form)
6609 me.transaction = Ext.Ajax.request({
6612 success: processSuccess,
6613 failure: processFailure,
6615 timeout: (me.timeout*1000),
6619 "callback": callback,
6623 me.showLoading.defer(1, me);
6628 startAutoRefresh : function(interval, url, params, callback, refreshNow){
6631 me.update(url || me.defaultUrl, params, callback, true);
6633 if(me.autoRefreshProcId){
6634 clearInterval(me.autoRefreshProcId);
6636 me.autoRefreshProcId = setInterval(me.update.createDelegate(me, [url || me.defaultUrl, params, callback, true]), interval * 1000);
6640 stopAutoRefresh : function(){
6641 if(this.autoRefreshProcId){
6642 clearInterval(this.autoRefreshProcId);
6643 delete this.autoRefreshProcId;
6648 isAutoRefreshing : function(){
6649 return !!this.autoRefreshProcId;
6653 showLoading : function(){
6654 if(this.showLoadIndicator){
6655 this.el.dom.innerHTML = this.indicatorText;
6661 if(this.transaction){
6662 Ext.Ajax.abort(this.transaction);
6667 isUpdating : function(){
6668 return this.transaction ? Ext.Ajax.isLoading(this.transaction) : false;
6672 refresh : function(callback){
6673 if(this.defaultUrl){
6674 this.update(this.defaultUrl, null, callback, true);
6681 Ext.Updater.defaults = {
6685 disableCaching : false,
6687 showLoadIndicator : true,
6689 indicatorText : '<div class="loading-indicator">Loading...</div>',
6691 loadScripts : false,
6693 sslBlankUrl : Ext.SSL_SECURE_URL
6698 Ext.Updater.updateElement = function(el, url, params, options){
6699 var um = Ext.get(el).getUpdater();
6700 Ext.apply(um, options);
6701 um.update(url, params, options ? options.callback : null);
6705 Ext.Updater.BasicRenderer = function(){};
6707 Ext.Updater.BasicRenderer.prototype = {
6709 render : function(el, response, updateManager, callback){
6710 el.update(response.responseText, updateManager.loadScripts, callback);
6719 Date.useStrict = false;
6725 function xf(format) {
6726 var args = Array.prototype.slice.call(arguments, 1);
6727 return format.replace(/\{(\d+)\}/g, function(m, i) {
6734 Date.formatCodeToRegex = function(character, currentGroup) {
6736 var p = Date.parseCodes[character];
6739 p = typeof p == 'function'? p() : p;
6740 Date.parseCodes[character] = p;
6743 return p? Ext.applyIf({
6744 c: p.c? xf(p.c, currentGroup || "{0}") : p.c
6748 s:Ext.escapeRe(character)
6753 var $f = Date.formatCodeToRegex;
6758 "M$": function(input, strict) {
6761 var re = new RegExp('\\/Date\\(([-+])?(\\d+)(?:[+-]\\d{4})?\\)\\/');
6762 var r = (input || '').match(re);
6763 return r? new Date(((r[1] || '') + r[2]) * 1) : null;
6772 return '\\/Date(' + this.getTime() + ')\\/';
6846 getShortMonthName : function(month) {
6847 return Date.monthNames[month].substring(0, 3);
6851 getShortDayName : function(day) {
6852 return Date.dayNames[day].substring(0, 3);
6856 getMonthNumber : function(name) {
6858 return Date.monthNumbers[name.substring(0, 1).toUpperCase() + name.substring(1, 3).toLowerCase()];
6863 d: "String.leftPad(this.getDate(), 2, '0')",
6864 D: "Date.getShortDayName(this.getDay())",
6865 j: "this.getDate()",
6866 l: "Date.dayNames[this.getDay()]",
6867 N: "(this.getDay() ? this.getDay() : 7)",
6868 S: "this.getSuffix()",
6870 z: "this.getDayOfYear()",
6871 W: "String.leftPad(this.getWeekOfYear(), 2, '0')",
6872 F: "Date.monthNames[this.getMonth()]",
6873 m: "String.leftPad(this.getMonth() + 1, 2, '0')",
6874 M: "Date.getShortMonthName(this.getMonth())",
6875 n: "(this.getMonth() + 1)",
6876 t: "this.getDaysInMonth()",
6877 L: "(this.isLeapYear() ? 1 : 0)",
6878 o: "(this.getFullYear() + (this.getWeekOfYear() == 1 && this.getMonth() > 0 ? +1 : (this.getWeekOfYear() >= 52 && this.getMonth() < 11 ? -1 : 0)))",
6879 Y: "this.getFullYear()",
6880 y: "('' + this.getFullYear()).substring(2, 4)",
6881 a: "(this.getHours() < 12 ? 'am' : 'pm')",
6882 A: "(this.getHours() < 12 ? 'AM' : 'PM')",
6883 g: "((this.getHours() % 12) ? this.getHours() % 12 : 12)",
6884 G: "this.getHours()",
6885 h: "String.leftPad((this.getHours() % 12) ? this.getHours() % 12 : 12, 2, '0')",
6886 H: "String.leftPad(this.getHours(), 2, '0')",
6887 i: "String.leftPad(this.getMinutes(), 2, '0')",
6888 s: "String.leftPad(this.getSeconds(), 2, '0')",
6889 u: "String.leftPad(this.getMilliseconds(), 3, '0')",
6890 O: "this.getGMTOffset()",
6891 P: "this.getGMTOffset(true)",
6892 T: "this.getTimezone()",
6893 Z: "(this.getTimezoneOffset() * -60)",
6896 for (var c = "Y-m-dTH:i:sP", code = [], i = 0, l = c.length; i < l; ++i) {
6897 var e = c.charAt(i);
6898 code.push(e == "T" ? "'T'" : Date.getFormatCode(e));
6900 return code.join(" + ");
6904 U: "Math.round(this.getTime() / 1000)"
6908 isValid : function(y, m, d, h, i, s, ms) {
6915 var dt = new Date(y, m - 1, d, h, i, s, ms);
6917 return y == dt.getFullYear() &&
6918 m == dt.getMonth() + 1 &&
6919 d == dt.getDate() &&
6920 h == dt.getHours() &&
6921 i == dt.getMinutes() &&
6922 s == dt.getSeconds() &&
6923 ms == dt.getMilliseconds();
6927 parseDate : function(input, format, strict) {
6928 var p = Date.parseFunctions;
6929 if (p[format] == null) {
6930 Date.createParser(format);
6932 return p[format](input, Ext.isDefined(strict) ? strict : Date.useStrict);
6936 getFormatCode : function(character) {
6937 var f = Date.formatCodes[character];
6940 f = typeof f == 'function'? f() : f;
6941 Date.formatCodes[character] = f;
6945 return f || ("'" + String.escape(character) + "'");
6949 createFormat : function(format) {
6954 for (var i = 0; i < format.length; ++i) {
6955 ch = format.charAt(i);
6956 if (!special && ch == "\\") {
6958 } else if (special) {
6960 code.push("'" + String.escape(ch) + "'");
6962 code.push(Date.getFormatCode(ch))
6965 Date.formatFunctions[format] = new Function("return " + code.join('+'));
6969 createParser : function() {
6971 "var dt, y, m, d, h, i, s, ms, o, z, zz, u, v,",
6972 "def = Date.defaults,",
6973 "results = String(input).match(Date.parseRegexes[{0}]);",
6979 "v = new Date(u * 1000);",
6984 "dt = (new Date()).clearTime();",
6987 "y = y >= 0? y : Ext.num(def.y, dt.getFullYear());",
6988 "m = m >= 0? m : Ext.num(def.m - 1, dt.getMonth());",
6989 "d = d >= 0? d : Ext.num(def.d, dt.getDate());",
6992 "h = h || Ext.num(def.h, dt.getHours());",
6993 "i = i || Ext.num(def.i, dt.getMinutes());",
6994 "s = s || Ext.num(def.s, dt.getSeconds());",
6995 "ms = ms || Ext.num(def.ms, dt.getMilliseconds());",
6997 "if(z >= 0 && y >= 0){",
7002 "v = new Date(y, 0, 1, h, i, s, ms);",
7005 "v = !strict? v : (strict === true && (z <= 364 || (v.isLeapYear() && z <= 365))? v.add(Date.DAY, z) : null);",
7006 "}else if(strict === true && !Date.isValid(y, m + 1, d, h, i, s, ms)){",
7010 "v = new Date(y, m, d, h, i, s, ms);",
7019 "v = v.add(Date.SECOND, -v.getTimezoneOffset() * 60 - zz);",
7022 "v = v.add(Date.MINUTE, -v.getTimezoneOffset() + (sn == '+'? -1 : 1) * (hr * 60 + mn));",
7029 return function(format) {
7030 var regexNum = Date.parseRegexes.length,
7037 for (var i = 0; i < format.length; ++i) {
7038 ch = format.charAt(i);
7039 if (!special && ch == "\\") {
7041 } else if (special) {
7043 regex.push(String.escape(ch));
7045 var obj = $f(ch, currentGroup);
7046 currentGroup += obj.g;
7048 if (obj.g && obj.c) {
7054 Date.parseRegexes[regexNum] = new RegExp("^" + regex.join('') + "$", "i");
7055 Date.parseFunctions[format] = new Function("input", "strict", xf(code, regexNum, calc.join('')));
7064 c:"d = parseInt(results[{0}], 10);\n",
7069 c:"d = parseInt(results[{0}], 10);\n",
7073 for (var a = [], i = 0; i < 7; a.push(Date.getShortDayName(i)), ++i);
7077 s:"(?:" + a.join("|") +")"
7084 s:"(?:" + Date.dayNames.join("|") + ")"
7104 c:"z = parseInt(results[{0}], 10);\n",
7115 c:"m = parseInt(Date.getMonthNumber(results[{0}]), 10);\n",
7116 s:"(" + Date.monthNames.join("|") + ")"
7120 for (var a = [], i = 0; i < 12; a.push(Date.getShortMonthName(i)), ++i);
7121 return Ext.applyIf({
7122 s:"(" + a.join("|") + ")"
7127 c:"m = parseInt(results[{0}], 10) - 1;\n",
7132 c:"m = parseInt(results[{0}], 10) - 1;\n",
7150 c:"y = parseInt(results[{0}], 10);\n",
7155 c:"var ty = parseInt(results[{0}], 10);\n"
7156 + "y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",
7161 c:"if (results[{0}] == 'am') {\n"
7162 + "if (!h || h == 12) { h = 0; }\n"
7163 + "} else { if (!h || h < 12) { h = (h || 0) + 12; }}",
7168 c:"if (results[{0}] == 'AM') {\n"
7169 + "if (!h || h == 12) { h = 0; }\n"
7170 + "} else { if (!h || h < 12) { h = (h || 0) + 12; }}",
7178 c:"h = parseInt(results[{0}], 10);\n",
7186 c:"h = parseInt(results[{0}], 10);\n",
7191 c:"i = parseInt(results[{0}], 10);\n",
7196 c:"s = parseInt(results[{0}], 10);\n",
7201 c:"ms = results[{0}]; ms = parseInt(ms, 10)/Math.pow(10, ms.length - 3);\n",
7207 "o = results[{0}];",
7208 "var sn = o.substring(0,1),",
7209 "hr = o.substring(1,3)*1 + Math.floor(o.substring(3,5) / 60),",
7210 "mn = o.substring(3,5) % 60;",
7211 "o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))? (sn + String.leftPad(hr, 2, '0') + String.leftPad(mn, 2, '0')) : null;\n"
7218 "o = results[{0}];",
7219 "var sn = o.substring(0,1),",
7220 "hr = o.substring(1,3)*1 + Math.floor(o.substring(4,6) / 60),",
7221 "mn = o.substring(4,6) % 60;",
7222 "o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))? (sn + String.leftPad(hr, 2, '0') + String.leftPad(mn, 2, '0')) : null;\n"
7224 s: "([+\-]\\d{2}:\\d{2})"
7233 c:"zz = results[{0}] * 1;\n"
7234 + "zz = (-43200 <= zz && zz <= 50400)? zz : null;\n",
7235 s:"([+\-]?\\d{1,5})"
7246 {c:"ms = results[7] || '0'; ms = parseInt(ms, 10)/Math.pow(10, ms.length - 3);\n"},
7249 "if(results[8] == 'Z'){",
7251 "}else if (results[8].indexOf(':') > -1){",
7260 for (var i = 0, l = arr.length; i < l; ++i) {
7261 calc.push(arr[i].c);
7269 "(?:", "-", arr[1].s,
7270 "(?:", "-", arr[2].s,
7273 arr[3].s, ":", arr[4].s,
7274 "(?::", arr[5].s, ")?",
7275 "(?:(?:\\.|,)(\\d+))?",
7276 "(Z|(?:[-+]\\d{2}(?::)?\\d{2}))?",
7285 c:"u = parseInt(results[{0}], 10);\n",
7293 Ext.apply(Date.prototype, {
7295 dateFormat : function(format) {
7296 if (Date.formatFunctions[format] == null) {
7297 Date.createFormat(format);
7299 return Date.formatFunctions[format].call(this);
7303 getTimezone : function() {
7316 return this.toString().replace(/^.* (?:\((.*)\)|([A-Z]{1,4})(?:[\-+][0-9]{4})?(?: -?\d+)?)$/, "$1$2").replace(/[^A-Z]/g, "");
7320 getGMTOffset : function(colon) {
7321 return (this.getTimezoneOffset() > 0 ? "-" : "+")
7322 + String.leftPad(Math.floor(Math.abs(this.getTimezoneOffset()) / 60), 2, "0")
7323 + (colon ? ":" : "")
7324 + String.leftPad(Math.abs(this.getTimezoneOffset() % 60), 2, "0");
7328 getDayOfYear: function() {
7331 m = this.getMonth(),
7334 for (i = 0, d.setDate(1), d.setMonth(0); i < m; d.setMonth(++i)) {
7335 num += d.getDaysInMonth();
7337 return num + this.getDate() - 1;
7341 getWeekOfYear : function() {
7347 var DC3 = Date.UTC(this.getFullYear(), this.getMonth(), this.getDate() + 3) / ms1d,
7348 AWN = Math.floor(DC3 / 7),
7349 Wyr = new Date(AWN * ms7d).getUTCFullYear();
7351 return AWN - Math.floor(Date.UTC(Wyr, 0, 7) / ms7d) + 1;
7356 isLeapYear : function() {
7357 var year = this.getFullYear();
7358 return !!((year & 3) == 0 && (year % 100 || (year % 400 == 0 && year)));
7362 getFirstDayOfMonth : function() {
7363 var day = (this.getDay() - (this.getDate() - 1)) % 7;
7364 return (day < 0) ? (day + 7) : day;
7368 getLastDayOfMonth : function() {
7369 return this.getLastDateOfMonth().getDay();
7374 getFirstDateOfMonth : function() {
7375 return new Date(this.getFullYear(), this.getMonth(), 1);
7379 getLastDateOfMonth : function() {
7380 return new Date(this.getFullYear(), this.getMonth(), this.getDaysInMonth());
7384 getDaysInMonth: function() {
7385 var daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
7388 var m = this.getMonth();
7390 return m == 1 && this.isLeapYear() ? 29 : daysInMonth[m];
7395 getSuffix : function() {
7396 switch (this.getDate()) {
7413 clone : function() {
7414 return new Date(this.getTime());
7418 isDST : function() {
7421 return new Date(this.getFullYear(), 0, 1).getTimezoneOffset() != this.getTimezoneOffset();
7425 clearTime : function(clone) {
7427 return this.clone().clearTime();
7431 var d = this.getDate();
7437 this.setMilliseconds(0);
7439 if (this.getDate() != d) {
7444 for (var hr = 1, c = this.add(Date.HOUR, hr); c.getDate() != d; hr++, c = this.add(Date.HOUR, hr));
7447 this.setHours(c.getHours());
7454 add : function(interval, value) {
7455 var d = this.clone();
7456 if (!interval || value === 0) return d;
7458 switch(interval.toLowerCase()) {
7460 d.setMilliseconds(this.getMilliseconds() + value);
7463 d.setSeconds(this.getSeconds() + value);
7466 d.setMinutes(this.getMinutes() + value);
7469 d.setHours(this.getHours() + value);
7472 d.setDate(this.getDate() + value);
7475 var day = this.getDate();
7477 day = Math.min(day, this.getFirstDateOfMonth().add('mo', value).getLastDateOfMonth().getDate());
7480 d.setMonth(this.getMonth() + value);
7483 d.setFullYear(this.getFullYear() + value);
7490 between : function(start, end) {
7491 var t = this.getTime();
7492 return start.getTime() <= t && t <= end.getTime();
7498 Date.prototype.format = Date.prototype.dateFormat;
7502 if (Ext.isSafari && (navigator.userAgent.match(/WebKit\/(\d+)/)[1] || NaN) < 420) {
7503 Ext.apply(Date.prototype, {
7504 _xMonth : Date.prototype.setMonth,
7505 _xDate : Date.prototype.setDate,
7509 setMonth : function(num) {
7511 var n = Math.ceil(-num),
7512 back_year = Math.ceil(n / 12),
7513 month = (n % 12) ? 12 - n % 12 : 0;
7515 this.setFullYear(this.getFullYear() - back_year);
7517 return this._xMonth(month);
7519 return this._xMonth(num);
7526 setDate : function(d) {
7529 return this.setTime(this.getTime() - (this.getDate() - d) * 864e5);
7537 Ext.util.MixedCollection = function(allowFunctions, keyFn){
7553 this.allowFunctions = allowFunctions === true;
7555 this.getKey = keyFn;
7557 Ext.util.MixedCollection.superclass.constructor.call(this);
7560 Ext.extend(Ext.util.MixedCollection, Ext.util.Observable, {
7563 allowFunctions : false,
7566 add : function(key, o){
7567 if(arguments.length == 1){
7569 key = this.getKey(o);
7571 if(typeof key != 'undefined' && key !== null){
7572 var old = this.map[key];
7573 if(typeof old != 'undefined'){
7574 return this.replace(key, o);
7580 this.keys.push(key);
7581 this.fireEvent('add', this.length-1, o, key);
7586 getKey : function(o){
7591 replace : function(key, o){
7592 if(arguments.length == 1){
7594 key = this.getKey(o);
7596 var old = this.map[key];
7597 if(typeof key == 'undefined' || key === null || typeof old == 'undefined'){
7598 return this.add(key, o);
7600 var index = this.indexOfKey(key);
7601 this.items[index] = o;
7603 this.fireEvent('replace', key, old, o);
7608 addAll : function(objs){
7609 if(arguments.length > 1 || Ext.isArray(objs)){
7610 var args = arguments.length > 1 ? arguments : objs;
7611 for(var i = 0, len = args.length; i < len; i++){
7615 for(var key in objs){
7616 if(this.allowFunctions || typeof objs[key] != 'function'){
7617 this.add(key, objs[key]);
7624 each : function(fn, scope){
7625 var items = [].concat(this.items);
7626 for(var i = 0, len = items.length; i < len; i++){
7627 if(fn.call(scope || items[i], items[i], i, len) === false){
7634 eachKey : function(fn, scope){
7635 for(var i = 0, len = this.keys.length; i < len; i++){
7636 fn.call(scope || window, this.keys[i], this.items[i], i, len);
7641 find : function(fn, scope){
7642 for(var i = 0, len = this.items.length; i < len; i++){
7643 if(fn.call(scope || window, this.items[i], this.keys[i])){
7644 return this.items[i];
7651 insert : function(index, key, o){
7652 if(arguments.length == 2){
7654 key = this.getKey(o);
7656 if(this.containsKey(key)){
7657 this.suspendEvents();
7658 this.removeKey(key);
7659 this.resumeEvents();
7661 if(index >= this.length){
7662 return this.add(key, o);
7665 this.items.splice(index, 0, o);
7666 if(typeof key != 'undefined' && key !== null){
7669 this.keys.splice(index, 0, key);
7670 this.fireEvent('add', index, o, key);
7675 remove : function(o){
7676 return this.removeAt(this.indexOf(o));
7680 removeAt : function(index){
7681 if(index < this.length && index >= 0){
7683 var o = this.items[index];
7684 this.items.splice(index, 1);
7685 var key = this.keys[index];
7686 if(typeof key != 'undefined'){
7687 delete this.map[key];
7689 this.keys.splice(index, 1);
7690 this.fireEvent('remove', o, key);
7697 removeKey : function(key){
7698 return this.removeAt(this.indexOfKey(key));
7702 getCount : function(){
7707 indexOf : function(o){
7708 return this.items.indexOf(o);
7712 indexOfKey : function(key){
7713 return this.keys.indexOf(key);
7717 item : function(key){
7718 var mk = this.map[key],
7719 item = mk !== undefined ? mk : (typeof key == 'number') ? this.items[key] : undefined;
7720 return !Ext.isFunction(item) || this.allowFunctions ? item : null;
7724 itemAt : function(index){
7725 return this.items[index];
7729 key : function(key){
7730 return this.map[key];
7734 contains : function(o){
7735 return this.indexOf(o) != -1;
7739 containsKey : function(key){
7740 return typeof this.map[key] != 'undefined';
7749 this.fireEvent('clear');
7754 return this.items[0];
7759 return this.items[this.length-1];
7763 _sort : function(property, dir, fn){
7766 dsc = String(dir).toUpperCase() == 'DESC' ? -1 : 1,
7767 c = [], k = this.keys, items = this.items;
7769 fn = fn || function(a, b){
7772 for(i = 0, len = items.length; i < len; i++){
7773 c[c.length] = {key: k[i], value: items[i], index: i};
7775 c.sort(function(a, b){
7776 var v = fn(a[property], b[property]) * dsc;
7778 v = (a.index < b.index ? -1 : 1);
7782 for(i = 0, len = c.length; i < len; i++){
7783 items[i] = c[i].value;
7786 this.fireEvent('sort', this);
7790 sort : function(dir, fn){
7791 this._sort('value', dir, fn);
7795 keySort : function(dir, fn){
7796 this._sort('key', dir, fn || function(a, b){
7797 var v1 = String(a).toUpperCase(), v2 = String(b).toUpperCase();
7798 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
7803 getRange : function(start, end){
7804 var items = this.items;
7805 if(items.length < 1){
7809 end = Math.min(typeof end == 'undefined' ? this.length-1 : end, this.length-1);
7812 for(i = start; i <= end; i++) {
7813 r[r.length] = items[i];
7816 for(i = start; i >= end; i--) {
7817 r[r.length] = items[i];
7824 filter : function(property, value, anyMatch, caseSensitive){
7825 if(Ext.isEmpty(value, false)){
7826 return this.clone();
7828 value = this.createValueMatcher(value, anyMatch, caseSensitive);
7829 return this.filterBy(function(o){
7830 return o && value.test(o[property]);
7835 filterBy : function(fn, scope){
7836 var r = new Ext.util.MixedCollection();
7837 r.getKey = this.getKey;
7838 var k = this.keys, it = this.items;
7839 for(var i = 0, len = it.length; i < len; i++){
7840 if(fn.call(scope||this, it[i], k[i])){
7848 findIndex : function(property, value, start, anyMatch, caseSensitive){
7849 if(Ext.isEmpty(value, false)){
7852 value = this.createValueMatcher(value, anyMatch, caseSensitive);
7853 return this.findIndexBy(function(o){
7854 return o && value.test(o[property]);
7859 findIndexBy : function(fn, scope, start){
7860 var k = this.keys, it = this.items;
7861 for(var i = (start||0), len = it.length; i < len; i++){
7862 if(fn.call(scope||this, it[i], k[i])){
7870 createValueMatcher : function(value, anyMatch, caseSensitive, exactMatch) {
7872 var er = Ext.escapeRe;
7873 value = String(value);
7874 if (anyMatch === true) {
7877 value = '^' + er(value);
7878 if (exactMatch === true) {
7882 value = new RegExp(value, caseSensitive ? '' : 'i');
7889 var r = new Ext.util.MixedCollection();
7890 var k = this.keys, it = this.items;
7891 for(var i = 0, len = it.length; i < len; i++){
7894 r.getKey = this.getKey;
7899 Ext.util.MixedCollection.prototype.get = Ext.util.MixedCollection.prototype.item;
7900 Ext.util.JSON = new (function(){
7901 var useHasOwn = !!{}.hasOwnProperty,
7902 isNative = function() {
7903 var useNative = null;
7906 if (useNative === null) {
7907 useNative = Ext.USE_NATIVE_JSON && window.JSON && JSON.toString() == '[object JSON]';
7914 return n < 10 ? "0" + n : n;
7916 doDecode = function(json){
7917 return eval("(" + json + ')');
7919 doEncode = function(o){
7920 if(!Ext.isDefined(o) || o === null){
7922 }else if(Ext.isArray(o)){
7923 return encodeArray(o);
7924 }else if(Ext.isDate(o)){
7925 return Ext.util.JSON.encodeDate(o);
7926 }else if(Ext.isString(o)){
7927 return encodeString(o);
7928 }else if(typeof o == "number"){
7930 return isFinite(o) ? String(o) : "null";
7931 }else if(Ext.isBoolean(o)){
7934 var a = ["{"], b, i, v;
7937 if(!o.getElementsByTagName){
7938 if(!useHasOwn || o.hasOwnProperty(i)) {
7949 a.push(doEncode(i), ":",
7950 v === null ? "null" : doEncode(v));
7969 encodeString = function(s){
7970 if (/["\\\x00-\x1f]/.test(s)) {
7971 return '"' + s.replace(/([\x00-\x1f\\"])/g, function(a, b) {
7978 Math.floor(c / 16).toString(16) +
7979 (c % 16).toString(16);
7982 return '"' + s + '"';
7984 encodeArray = function(o){
7985 var a = ["["], b, i, l = o.length, v;
7986 for (i = 0; i < l; i += 1) {
7997 a.push(v === null ? "null" : Ext.util.JSON.encode(v));
8005 this.encodeDate = function(o){
8006 return '"' + o.getFullYear() + "-" +
8007 pad(o.getMonth() + 1) + "-" +
8008 pad(o.getDate()) + "T" +
8009 pad(o.getHours()) + ":" +
8010 pad(o.getMinutes()) + ":" +
8011 pad(o.getSeconds()) + '"';
8015 this.encode = function() {
8017 return function(o) {
8020 ec = isNative() ? JSON.stringify : doEncode;
8028 this.decode = function() {
8030 return function(json) {
8033 dc = isNative() ? JSON.parse : doDecode;
8041 Ext.encode = Ext.util.JSON.encode;
8043 Ext.decode = Ext.util.JSON.decode;
8045 Ext.util.Format = function(){
8046 var trimRe = /^\s+|\s+$/g,
8047 stripTagsRE = /<\/?[^>]+>/gi,
8048 stripScriptsRe = /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig,
8053 ellipsis : function(value, len, word){
8054 if(value && value.length > len){
8056 var vs = value.substr(0, len - 2),
8057 index = Math.max(vs.lastIndexOf(' '), vs.lastIndexOf('.'), vs.lastIndexOf('!'), vs.lastIndexOf('?'));
8058 if(index == -1 || index < (len - 15)){
8059 return value.substr(0, len - 3) + "...";
8061 return vs.substr(0, index) + "...";
8064 return value.substr(0, len - 3) + "...";
8071 undef : function(value){
8072 return value !== undefined ? value : "";
8076 defaultValue : function(value, defaultValue){
8077 return value !== undefined && value !== '' ? value : defaultValue;
8081 htmlEncode : function(value){
8082 return !value ? value : String(value).replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, """);
8086 htmlDecode : function(value){
8087 return !value ? value : String(value).replace(/>/g, ">").replace(/</g, "<").replace(/"/g, '"').replace(/&/g, "&");
8091 trim : function(value){
8092 return String(value).replace(trimRe, "");
8096 substr : function(value, start, length){
8097 return String(value).substr(start, length);
8101 lowercase : function(value){
8102 return String(value).toLowerCase();
8106 uppercase : function(value){
8107 return String(value).toUpperCase();
8111 capitalize : function(value){
8112 return !value ? value : value.charAt(0).toUpperCase() + value.substr(1).toLowerCase();
8116 call : function(value, fn){
8117 if(arguments.length > 2){
8118 var args = Array.prototype.slice.call(arguments, 2);
8119 args.unshift(value);
8120 return eval(fn).apply(window, args);
8122 return eval(fn).call(window, value);
8127 usMoney : function(v){
8128 v = (Math.round((v-0)*100))/100;
8129 v = (v == Math.floor(v)) ? v + ".00" : ((v*10 == Math.floor(v*10)) ? v + "0" : v);
8131 var ps = v.split('.'),
8133 sub = ps[1] ? '.'+ ps[1] : '.00',
8135 while (r.test(whole)) {
8136 whole = whole.replace(r, '$1' + ',' + '$2');
8139 if(v.charAt(0) == '-'){
8140 return '-$' + v.substr(1);
8146 date : function(v, format){
8151 v = new Date(Date.parse(v));
8153 return v.dateFormat(format || "m/d/Y");
8157 dateRenderer : function(format){
8159 return Ext.util.Format.date(v, format);
8164 stripTags : function(v){
8165 return !v ? v : String(v).replace(stripTagsRE, "");
8169 stripScripts : function(v){
8170 return !v ? v : String(v).replace(stripScriptsRe, "");
8174 fileSize : function(size){
8176 return size + " bytes";
8177 } else if(size < 1048576) {
8178 return (Math.round(((size*10) / 1024))/10) + " KB";
8180 return (Math.round(((size*10) / 1048576))/10) + " MB";
8187 return function(v, a){
8189 fns[a] = new Function('v', 'return v ' + a + ';');
8196 round : function(value, precision) {
8197 var result = Number(value);
8198 if (typeof precision == 'number') {
8199 precision = Math.pow(10, precision);
8200 result = Math.round(value * precision) / precision;
8206 number: function(v, format) {
8210 v = Ext.num(v, NaN);
8220 if(format.substr(format.length - 2) == '/i'){
8221 format = format.substr(0, format.length - 2);
8227 var hasComma = format.indexOf(comma) != -1,
8228 psplit = (i18n ? format.replace(/[^\d\,]/g, '') : format.replace(/[^\d\.]/g, '')).split(dec);
8230 if(1 < psplit.length){
8231 v = v.toFixed(psplit[1].length);
8232 }else if(2 < psplit.length){
8233 throw ('NumberFormatException: invalid format, formats should have no more than 1 period: ' + format);
8238 var fnum = v.toString();
8240 psplit = fnum.split('.');
8242 var cnum = psplit[0], parr = [], j = cnum.length, m = Math.floor(j / 3), n = cnum.length % 3 || 3;
8244 for(var i = 0; i < j; i += n){
8248 parr[parr.length] = cnum.substr(i, n);
8251 fnum = parr.join(comma);
8253 fnum += dec + psplit[1];
8257 return (neg ? '-' : '') + format.replace(/[\d,?\.?]+/, fnum);
8261 numberRenderer : function(format){
8263 return Ext.util.Format.number(v, format);
8268 plural : function(v, s, p){
8269 return v +' ' + (v == 1 ? s : (p ? p : s+'s'));
8273 nl2br : function(v){
8274 return Ext.isEmpty(v) ? '' : v.replace(nl2brRe, '<br/>');
8279 Ext.XTemplate = function(){
8280 Ext.XTemplate.superclass.constructor.apply(this, arguments);
8284 re = /<tpl\b[^>]*>((?:(?=([^<]+))\2|<(?!tpl\b[^>]*>))*?)<\/tpl>/,
8285 nameRe = /^<tpl\b[^>]*?for="(.*?)"/,
8286 ifRe = /^<tpl\b[^>]*?if="(.*?)"/,
8287 execRe = /^<tpl\b[^>]*?exec="(.*?)"/,
8296 WITHVALUES = 'with(values){ ';
8298 s = ['<tpl>', s, '</tpl>'].join('');
8300 while((m = s.match(re))){
8301 var m2 = m[0].match(nameRe),
8302 m3 = m[0].match(ifRe),
8303 m4 = m[0].match(execRe),
8307 name = m2 && m2[1] ? m2[1] : '';
8310 exp = m3 && m3[1] ? m3[1] : null;
8312 fn = new Function(VALUES, PARENT, XINDEX, XCOUNT, WITHVALUES + RETURN +(Ext.util.Format.htmlDecode(exp))+'; }');
8316 exp = m4 && m4[1] ? m4[1] : null;
8318 exec = new Function(VALUES, PARENT, XINDEX, XCOUNT, WITHVALUES +(Ext.util.Format.htmlDecode(exp))+'; }');
8323 case '.': name = new Function(VALUES, PARENT, WITHVALUES + RETURN + VALUES + '; }'); break;
8324 case '..': name = new Function(VALUES, PARENT, WITHVALUES + RETURN + PARENT + '; }'); break;
8325 default: name = new Function(VALUES, PARENT, WITHVALUES + RETURN + name + '; }');
8335 s = s.replace(m[0], '{xtpl'+ id + '}');
8338 Ext.each(tpls, function(t) {
8341 me.master = tpls[tpls.length-1];
8344 Ext.extend(Ext.XTemplate, Ext.Template, {
8346 re : /\{([\w-\.\#]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?(\s?[\+\-\*\\]\s?[\d\.\+\-\*\\\(\)]+)?\}/g,
8348 codeRe : /\{\[((?:\\\]|.|\n)*?)\]\}/g,
8351 applySubTemplate : function(id, values, parent, xindex, xcount){
8357 if ((t.test && !t.test.call(me, values, parent, xindex, xcount)) ||
8358 (t.exec && t.exec.call(me, values, parent, xindex, xcount))) {
8361 vs = t.target ? t.target.call(me, values, parent) : values;
8363 parent = t.target ? values : parent;
8364 if(t.target && Ext.isArray(vs)){
8365 Ext.each(vs, function(v, i) {
8366 buf[buf.length] = t.compiled.call(me, v, parent, i+1, len);
8368 return buf.join('');
8370 return t.compiled.call(me, vs, parent, xindex, xcount);
8374 compileTpl : function(tpl){
8375 var fm = Ext.util.Format,
8376 useF = this.disableFormats !== true,
8377 sep = Ext.isGecko ? "+" : ",",
8380 function fn(m, name, format, args, math){
8381 if(name.substr(0, 4) == 'xtpl'){
8382 return "'"+ sep +'this.applySubTemplate('+name.substr(4)+', values, parent, xindex, xcount)'+sep+"'";
8387 }else if(name === '#'){
8389 }else if(name.indexOf('.') != -1){
8392 v = "values['" + name + "']";
8395 v = '(' + v + math + ')';
8397 if (format && useF) {
8398 args = args ? ',' + args : "";
8399 if(format.substr(0, 5) != "this."){
8400 format = "fm." + format + '(';
8402 format = 'this.call("'+ format.substr(5) + '", ';
8406 args= ''; format = "("+v+" === undefined ? '' : ";
8408 return "'"+ sep + format + v + args + ")"+sep+"'";
8411 function codeFn(m, code){
8413 return "'" + sep + '(' + code.replace(/\\'/g, "'") + ')' + sep + "'";
8418 body = "tpl.compiled = function(values, parent, xindex, xcount){ return '" +
8419 tpl.body.replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn).replace(this.codeRe, codeFn) +
8422 body = ["tpl.compiled = function(values, parent, xindex, xcount){ return ['"];
8423 body.push(tpl.body.replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn).replace(this.codeRe, codeFn));
8424 body.push("'].join('');};");
8425 body = body.join('');
8432 applyTemplate : function(values){
8433 return this.master.compiled.call(this, values, {}, 1, 1);
8437 compile : function(){return this;}
8445 Ext.XTemplate.prototype.apply = Ext.XTemplate.prototype.applyTemplate;
8448 Ext.XTemplate.from = function(el){
8449 el = Ext.getDom(el);
8450 return new Ext.XTemplate(el.value || el.innerHTML);
8452 Ext.util.CSS = function(){
8456 var camelRe = /(-[a-z])/gi;
8457 var camelFn = function(m, a){ return a.charAt(1).toUpperCase(); };
8461 createStyleSheet : function(cssText, id){
8463 var head = doc.getElementsByTagName("head")[0];
8464 var rules = doc.createElement("style");
8465 rules.setAttribute("type", "text/css");
8467 rules.setAttribute("id", id);
8470 head.appendChild(rules);
8471 ss = rules.styleSheet;
8472 ss.cssText = cssText;
8475 rules.appendChild(doc.createTextNode(cssText));
8477 rules.cssText = cssText;
8479 head.appendChild(rules);
8480 ss = rules.styleSheet ? rules.styleSheet : (rules.sheet || doc.styleSheets[doc.styleSheets.length-1]);
8482 this.cacheStyleSheet(ss);
8487 removeStyleSheet : function(id){
8488 var existing = doc.getElementById(id);
8490 existing.parentNode.removeChild(existing);
8495 swapStyleSheet : function(id, url){
8496 this.removeStyleSheet(id);
8497 var ss = doc.createElement("link");
8498 ss.setAttribute("rel", "stylesheet");
8499 ss.setAttribute("type", "text/css");
8500 ss.setAttribute("id", id);
8501 ss.setAttribute("href", url);
8502 doc.getElementsByTagName("head")[0].appendChild(ss);
8506 refreshCache : function(){
8507 return this.getRules(true);
8511 cacheStyleSheet : function(ss){
8516 var ssRules = ss.cssRules || ss.rules;
8517 for(var j = ssRules.length-1; j >= 0; --j){
8518 rules[ssRules[j].selectorText.toLowerCase()] = ssRules[j];
8524 getRules : function(refreshCache){
8525 if(rules === null || refreshCache){
8527 var ds = doc.styleSheets;
8528 for(var i =0, len = ds.length; i < len; i++){
8530 this.cacheStyleSheet(ds[i]);
8538 getRule : function(selector, refreshCache){
8539 var rs = this.getRules(refreshCache);
8540 if(!Ext.isArray(selector)){
8541 return rs[selector.toLowerCase()];
8543 for(var i = 0; i < selector.length; i++){
8544 if(rs[selector[i]]){
8545 return rs[selector[i].toLowerCase()];
8553 updateRule : function(selector, property, value){
8554 if(!Ext.isArray(selector)){
8555 var rule = this.getRule(selector);
8557 rule.style[property.replace(camelRe, camelFn)] = value;
8561 for(var i = 0; i < selector.length; i++){
8562 if(this.updateRule(selector[i], property, value)){
8571 Ext.util.ClickRepeater = function(el, config)
8573 this.el = Ext.get(el);
8574 this.el.unselectable();
8576 Ext.apply(this, config);
8588 this.disabled = true;
8594 this.on("click", this.handler, this.scope || this);
8597 Ext.util.ClickRepeater.superclass.constructor.call(this);
8600 Ext.extend(Ext.util.ClickRepeater, Ext.util.Observable, {
8603 preventDefault : true,
8604 stopDefault : false,
8610 this.el.on('mousedown', this.handleMouseDown, this);
8611 if(this.preventDefault || this.stopDefault){
8612 this.el.on('click', this.eventOptions, this);
8615 this.disabled = false;
8619 disable: function( force){
8620 if(force || !this.disabled){
8621 clearTimeout(this.timer);
8622 if(this.pressClass){
8623 this.el.removeClass(this.pressClass);
8625 Ext.getDoc().un('mouseup', this.handleMouseUp, this);
8626 this.el.removeAllListeners();
8628 this.disabled = true;
8632 setDisabled: function(disabled){
8633 this[disabled ? 'disable' : 'enable']();
8636 eventOptions: function(e){
8637 if(this.preventDefault){
8640 if(this.stopDefault){
8646 destroy : function() {
8648 Ext.destroy(this.el);
8649 this.purgeListeners();
8653 handleMouseDown : function(){
8654 clearTimeout(this.timer);
8656 if(this.pressClass){
8657 this.el.addClass(this.pressClass);
8659 this.mousedownTime = new Date();
8661 Ext.getDoc().on("mouseup", this.handleMouseUp, this);
8662 this.el.on("mouseout", this.handleMouseOut, this);
8664 this.fireEvent("mousedown", this);
8665 this.fireEvent("click", this);
8668 if (this.accelerate) {
8671 this.timer = this.click.defer(this.delay || this.interval, this);
8676 this.fireEvent("click", this);
8677 this.timer = this.click.defer(this.accelerate ?
8678 this.easeOutExpo(this.mousedownTime.getElapsed(),
8682 this.interval, this);
8685 easeOutExpo : function (t, b, c, d) {
8686 return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
8690 handleMouseOut : function(){
8691 clearTimeout(this.timer);
8692 if(this.pressClass){
8693 this.el.removeClass(this.pressClass);
8695 this.el.on("mouseover", this.handleMouseReturn, this);
8699 handleMouseReturn : function(){
8700 this.el.un("mouseover", this.handleMouseReturn, this);
8701 if(this.pressClass){
8702 this.el.addClass(this.pressClass);
8708 handleMouseUp : function(){
8709 clearTimeout(this.timer);
8710 this.el.un("mouseover", this.handleMouseReturn, this);
8711 this.el.un("mouseout", this.handleMouseOut, this);
8712 Ext.getDoc().un("mouseup", this.handleMouseUp, this);
8713 this.el.removeClass(this.pressClass);
8714 this.fireEvent("mouseup", this);
8717 Ext.KeyNav = function(el, config){
8718 this.el = Ext.get(el);
8719 Ext.apply(this, config);
8721 this.disabled = true;
8726 Ext.KeyNav.prototype = {
8730 defaultEventAction: "stopEvent",
8732 forceKeyDown : false,
8735 relay : function(e){
8737 var h = this.keyToHandler[k];
8739 if(this.doRelay(e, this[h], h) !== true){
8740 e[this.defaultEventAction]();
8746 doRelay : function(e, h, hname){
8747 return h.call(this.scope || this, e);
8780 stopKeyUp: function(e) {
8783 if (k >= 37 && k <= 40) {
8791 destroy: function(){
8796 enable: function() {
8797 if (this.disabled) {
8798 if (Ext.isSafari2) {
8800 this.el.on('keyup', this.stopKeyUp, this);
8803 this.el.on(this.isKeydown()? 'keydown' : 'keypress', this.relay, this);
8804 this.disabled = false;
8809 disable: function() {
8810 if (!this.disabled) {
8811 if (Ext.isSafari2) {
8813 this.el.un('keyup', this.stopKeyUp, this);
8816 this.el.un(this.isKeydown()? 'keydown' : 'keypress', this.relay, this);
8817 this.disabled = true;
8822 setDisabled : function(disabled){
8823 this[disabled ? "disable" : "enable"]();
8827 isKeydown: function(){
8828 return this.forceKeyDown || Ext.EventManager.useKeydown;
8832 Ext.KeyMap = function(el, config, eventName){
8833 this.el = Ext.get(el);
8834 this.eventName = eventName || "keydown";
8837 this.addBinding(config);
8842 Ext.KeyMap.prototype = {
8847 addBinding : function(config){
8848 if(Ext.isArray(config)){
8849 Ext.each(config, function(c){
8854 var keyCode = config.key,
8855 fn = config.fn || config.handler,
8856 scope = config.scope;
8858 if (config.stopEvent) {
8859 this.stopEvent = config.stopEvent;
8862 if(typeof keyCode == "string"){
8864 var keyString = keyCode.toUpperCase();
8865 for(var j = 0, len = keyString.length; j < len; j++){
8866 ks.push(keyString.charCodeAt(j));
8870 var keyArray = Ext.isArray(keyCode);
8872 var handler = function(e){
8873 if(this.checkModifiers(config, e)){
8876 for(var i = 0, len = keyCode.length; i < len; i++){
8877 if(keyCode[i] == k){
8881 fn.call(scope || window, k, e);
8890 fn.call(scope || window, k, e);
8895 this.bindings.push(handler);
8899 checkModifiers: function(config, e){
8900 var val, key, keys = ['shift', 'ctrl', 'alt'];
8901 for (var i = 0, len = keys.length; i < len; ++i){
8904 if(!(val === undefined || (val === e[key + 'Key']))){
8912 on : function(key, fn, scope){
8913 var keyCode, shift, ctrl, alt;
8914 if(typeof key == "object" && !Ext.isArray(key)){
8933 handleKeyDown : function(e){
8935 var b = this.bindings;
8936 for(var i = 0, len = b.length; i < len; i++){
8943 isEnabled : function(){
8944 return this.enabled;
8950 this.el.on(this.eventName, this.handleKeyDown, this);
8951 this.enabled = true;
8956 disable: function(){
8958 this.el.removeListener(this.eventName, this.handleKeyDown, this);
8959 this.enabled = false;
8964 setDisabled : function(disabled){
8965 this[disabled ? "disable" : "enable"]();
8968 Ext.util.TextMetrics = function(){
8972 measure : function(el, text, fixedWidth){
8974 shared = Ext.util.TextMetrics.Instance(el, fixedWidth);
8977 shared.setFixedWidth(fixedWidth || 'auto');
8978 return shared.getSize(text);
8982 createInstance : function(el, fixedWidth){
8983 return Ext.util.TextMetrics.Instance(el, fixedWidth);
8988 Ext.util.TextMetrics.Instance = function(bindTo, fixedWidth){
8989 var ml = new Ext.Element(document.createElement('div'));
8990 document.body.appendChild(ml.dom);
8991 ml.position('absolute');
8992 ml.setLeftTop(-1000, -1000);
8996 ml.setWidth(fixedWidth);
9001 getSize : function(text){
9003 var s = ml.getSize();
9009 bind : function(el){
9011 Ext.fly(el).getStyles('font-size','font-style', 'font-weight', 'font-family','line-height', 'text-transform', 'letter-spacing')
9016 setFixedWidth : function(width){
9021 getWidth : function(text){
9022 ml.dom.style.width = 'auto';
9023 return this.getSize(text).width;
9027 getHeight : function(text){
9028 return this.getSize(text).height;
9032 instance.bind(bindTo);
9037 Ext.Element.addMethods({
9039 getTextWidth : function(text, min, max){
9040 return (Ext.util.TextMetrics.measure(this.dom, Ext.value(text, this.dom.innerHTML, true)).width).constrain(min || 0, max || 1000000);
9044 Ext.util.Cookies = {
9046 set : function(name, value){
9047 var argv = arguments;
9048 var argc = arguments.length;
9049 var expires = (argc > 2) ? argv[2] : null;
9050 var path = (argc > 3) ? argv[3] : '/';
9051 var domain = (argc > 4) ? argv[4] : null;
9052 var secure = (argc > 5) ? argv[5] : false;
9053 document.cookie = name + "=" + escape(value) + ((expires === null) ? "" : ("; expires=" + expires.toGMTString())) + ((path === null) ? "" : ("; path=" + path)) + ((domain === null) ? "" : ("; domain=" + domain)) + ((secure === true) ? "; secure" : "");
9057 get : function(name){
9058 var arg = name + "=";
9059 var alen = arg.length;
9060 var clen = document.cookie.length;
9065 if(document.cookie.substring(i, j) == arg){
9066 return Ext.util.Cookies.getCookieVal(j);
9068 i = document.cookie.indexOf(" ", i) + 1;
9077 clear : function(name){
9078 if(Ext.util.Cookies.get(name)){
9079 document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
9083 getCookieVal : function(offset){
9084 var endstr = document.cookie.indexOf(";", offset);
9086 endstr = document.cookie.length;
9088 return unescape(document.cookie.substring(offset, endstr));
9091 Ext.handleError = function(e) {
9096 Ext.Error = function(message) {
9098 this.message = (this.lang[message]) ? this.lang[message] : message;
9100 Ext.Error.prototype = new Error();
9101 Ext.apply(Ext.Error.prototype, {
9107 getName : function() {
9111 getMessage : function() {
9112 return this.message;
9115 toJson : function() {
9116 return Ext.encode(this);
9121 Ext.ComponentMgr = function(){
9122 var all = new Ext.util.MixedCollection();
9128 register : function(c){
9133 unregister : function(c){
9143 onAvailable : function(id, fn, scope){
9144 all.on("add", function(index, o){
9146 fn.call(scope || o, o);
9147 all.un("add", fn, scope);
9156 isRegistered : function(xtype){
9157 return types[xtype] !== undefined;
9161 registerType : function(xtype, cls){
9167 create : function(config, defaultType){
9168 return config.render ? config : new types[config.xtype || defaultType](config);
9172 registerPlugin : function(ptype, cls){
9173 ptypes[ptype] = cls;
9178 createPlugin : function(config, defaultType){
9179 var PluginCls = ptypes[config.ptype || defaultType];
9180 if (PluginCls.init) {
9183 return new PluginCls(config);
9190 Ext.reg = Ext.ComponentMgr.registerType;
9192 Ext.preg = Ext.ComponentMgr.registerPlugin;
9194 Ext.create = Ext.ComponentMgr.create;
9195 Ext.Component = function(config){
9196 config = config || {};
9197 if(config.initialConfig){
9198 if(config.isAction){
9199 this.baseAction = config;
9201 config = config.initialConfig;
9202 }else if(config.tagName || config.dom || Ext.isString(config)){
9203 config = {applyTo: config, id: config.id || config};
9207 this.initialConfig = config;
9209 Ext.apply(this, config);
9238 'beforestaterestore',
9247 Ext.ComponentMgr.register(this);
9248 Ext.Component.superclass.constructor.call(this);
9250 if(this.baseAction){
9251 this.baseAction.addComponent(this);
9254 this.initComponent();
9257 if(Ext.isArray(this.plugins)){
9258 for(var i = 0, len = this.plugins.length; i < len; i++){
9259 this.plugins[i] = this.initPlugin(this.plugins[i]);
9262 this.plugins = this.initPlugin(this.plugins);
9266 if(this.stateful !== false){
9271 this.applyToMarkup(this.applyTo);
9272 delete this.applyTo;
9273 }else if(this.renderTo){
9274 this.render(this.renderTo);
9275 delete this.renderTo;
9280 Ext.Component.AUTO_ID = 1000;
9282 Ext.extend(Ext.Component, Ext.util.Observable, {
9316 disabledClass : 'x-item-disabled',
9318 allowDomMove : true,
9322 hideMode : 'display',
9338 tplWriteMode : 'overwrite',
9344 ctype : 'Ext.Component',
9350 getActionEl : function(){
9351 return this[this.actionMode];
9354 initPlugin : function(p){
9355 if(p.ptype && !Ext.isFunction(p.init)){
9356 p = Ext.ComponentMgr.createPlugin(p);
9357 }else if(Ext.isString(p)){
9358 p = Ext.ComponentMgr.createPlugin({
9367 initComponent : Ext.emptyFn,
9370 render : function(container, position){
9371 if(!this.rendered && this.fireEvent('beforerender', this) !== false){
9372 if(!container && this.el){
9373 this.el = Ext.get(this.el);
9374 container = this.el.dom.parentNode;
9375 this.allowDomMove = false;
9377 this.container = Ext.get(container);
9379 this.container.addClass(this.ctCls);
9381 this.rendered = true;
9382 if(position !== undefined){
9383 if(Ext.isNumber(position)){
9384 position = this.container.dom.childNodes[position];
9386 position = Ext.getDom(position);
9389 this.onRender(this.container, position || null);
9391 this.el.removeClass(['x-hidden','x-hide-' + this.hideMode]);
9394 this.el.addClass(this.cls);
9398 this.el.applyStyles(this.style);
9402 this.el.addClassOnOver(this.overCls);
9404 this.fireEvent('render', this);
9409 var contentTarget = this.getContentTarget();
9411 contentTarget.update(Ext.DomHelper.markup(this.html));
9414 if (this.contentEl){
9415 var ce = Ext.getDom(this.contentEl);
9416 Ext.fly(ce).removeClass(['x-hidden', 'x-hide-display']);
9417 contentTarget.appendChild(ce);
9420 if (!this.tpl.compile) {
9421 this.tpl = new Ext.XTemplate(this.tpl);
9424 this.tpl[this.tplWriteMode](contentTarget, this.data);
9428 this.afterRender(this.container);
9440 if(this.stateful !== false){
9441 this.initStateEvents();
9443 this.fireEvent('afterrender', this);
9450 update: function(htmlOrData, loadScripts, cb) {
9451 var contentTarget = this.getContentTarget();
9452 if (this.tpl && typeof htmlOrData !== "string") {
9453 this.tpl[this.tplWriteMode](contentTarget, htmlOrData || {});
9455 var html = Ext.isObject(htmlOrData) ? Ext.DomHelper.markup(htmlOrData) : htmlOrData;
9456 contentTarget.update(html, loadScripts, cb);
9462 onAdded : function(container, pos) {
9463 this.ownerCt = container;
9465 this.fireEvent('added', this, container, pos);
9469 onRemoved : function() {
9471 this.fireEvent('removed', this, this.ownerCt);
9472 delete this.ownerCt;
9476 initRef : function() {
9478 if(this.ref && !this.refOwner){
9479 var levels = this.ref.split('/'),
9480 last = levels.length,
9484 while(t && i < last){
9489 t[this.refName = levels[--i]] = this;
9496 removeRef : function() {
9497 if (this.refOwner && this.refName) {
9498 delete this.refOwner[this.refName];
9499 delete this.refOwner;
9504 initState : function(){
9505 if(Ext.state.Manager){
9506 var id = this.getStateId();
9508 var state = Ext.state.Manager.get(id);
9510 if(this.fireEvent('beforestaterestore', this, state) !== false){
9511 this.applyState(Ext.apply({}, state));
9512 this.fireEvent('staterestore', this, state);
9520 getStateId : function(){
9521 return this.stateId || ((this.id.indexOf('ext-comp-') == 0 || this.id.indexOf('ext-gen') == 0) ? null : this.id);
9525 initStateEvents : function(){
9526 if(this.stateEvents){
9527 for(var i = 0, e; e = this.stateEvents[i]; i++){
9528 this.on(e, this.saveState, this, {delay:100});
9534 applyState : function(state){
9536 Ext.apply(this, state);
9541 getState : function(){
9546 saveState : function(){
9547 if(Ext.state.Manager && this.stateful !== false){
9548 var id = this.getStateId();
9550 var state = this.getState();
9551 if(this.fireEvent('beforestatesave', this, state) !== false){
9552 Ext.state.Manager.set(id, state);
9553 this.fireEvent('statesave', this, state);
9560 applyToMarkup : function(el){
9561 this.allowDomMove = false;
9562 this.el = Ext.get(el);
9563 this.render(this.el.dom.parentNode);
9567 addClass : function(cls){
9569 this.el.addClass(cls);
9571 this.cls = this.cls ? this.cls + ' ' + cls : cls;
9577 removeClass : function(cls){
9579 this.el.removeClass(cls);
9581 this.cls = this.cls.split(' ').remove(cls).join(' ');
9588 onRender : function(ct, position){
9589 if(!this.el && this.autoEl){
9590 if(Ext.isString(this.autoEl)){
9591 this.el = document.createElement(this.autoEl);
9593 var div = document.createElement('div');
9594 Ext.DomHelper.overwrite(div, this.autoEl);
9595 this.el = div.firstChild;
9598 this.el.id = this.getId();
9602 this.el = Ext.get(this.el);
9603 if(this.allowDomMove !== false){
9604 ct.dom.insertBefore(this.el.dom, position);
9606 Ext.removeNode(div);
9614 getAutoCreate : function(){
9615 var cfg = Ext.isObject(this.autoCreate) ?
9616 this.autoCreate : Ext.apply({}, this.defaultAutoCreate);
9617 if(this.id && !cfg.id){
9624 afterRender : Ext.emptyFn,
9627 destroy : function(){
9628 if(!this.isDestroyed){
9629 if(this.fireEvent('beforedestroy', this) !== false){
9630 this.destroying = true;
9631 this.beforeDestroy();
9632 if(this.ownerCt && this.ownerCt.remove){
9633 this.ownerCt.remove(this, false);
9637 if(this.actionMode == 'container' || this.removeMode == 'container'){
9638 this.container.remove();
9642 Ext.ComponentMgr.unregister(this);
9643 this.fireEvent('destroy', this);
9644 this.purgeListeners();
9645 this.destroying = false;
9646 this.isDestroyed = true;
9651 deleteMembers : function(){
9652 var args = arguments;
9653 for(var i = 0, len = args.length; i < len; ++i){
9654 delete this[args[i]];
9659 beforeDestroy : Ext.emptyFn,
9662 onDestroy : Ext.emptyFn,
9670 getContentTarget : function(){
9676 return this.id || (this.id = 'ext-comp-' + (++Ext.Component.AUTO_ID));
9680 getItemId : function(){
9681 return this.itemId || this.getId();
9685 focus : function(selectText, delay){
9687 this.focus.defer(Ext.isNumber(delay) ? delay : 10, this, [selectText, false]);
9692 if(selectText === true){
9693 this.el.dom.select();
9708 disable : function( silent){
9712 this.disabled = true;
9713 if(silent !== true){
9714 this.fireEvent('disable', this);
9720 onDisable : function(){
9721 this.getActionEl().addClass(this.disabledClass);
9722 this.el.dom.disabled = true;
9726 enable : function(){
9730 this.disabled = false;
9731 this.fireEvent('enable', this);
9736 onEnable : function(){
9737 this.getActionEl().removeClass(this.disabledClass);
9738 this.el.dom.disabled = false;
9742 setDisabled : function(disabled){
9743 return this[disabled ? 'disable' : 'enable']();
9748 if(this.fireEvent('beforeshow', this) !== false){
9749 this.hidden = false;
9750 if(this.autoRender){
9751 this.render(Ext.isBoolean(this.autoRender) ? Ext.getBody() : this.autoRender);
9756 this.fireEvent('show', this);
9762 onShow : function(){
9763 this.getVisibilityEl().removeClass('x-hide-' + this.hideMode);
9768 if(this.fireEvent('beforehide', this) !== false){
9770 this.fireEvent('hide', this);
9784 onHide : function(){
9785 this.getVisibilityEl().addClass('x-hide-' + this.hideMode);
9789 getVisibilityEl : function(){
9790 return this.hideParent ? this.container : this.getActionEl();
9794 setVisible : function(visible){
9795 return this[visible ? 'show' : 'hide']();
9799 isVisible : function(){
9800 return this.rendered && this.getVisibilityEl().isVisible();
9804 cloneConfig : function(overrides){
9805 overrides = overrides || {};
9806 var id = overrides.id || Ext.id();
9807 var cfg = Ext.applyIf(overrides, this.initialConfig);
9809 return new this.constructor(cfg);
9813 getXType : function(){
9814 return this.constructor.xtype;
9818 isXType : function(xtype, shallow){
9820 if (Ext.isFunction(xtype)){
9821 xtype = xtype.xtype;
9822 }else if (Ext.isObject(xtype)){
9823 xtype = xtype.constructor.xtype;
9826 return !shallow ? ('/' + this.getXTypes() + '/').indexOf('/' + xtype + '/') != -1 : this.constructor.xtype == xtype;
9830 getXTypes : function(){
9831 var tc = this.constructor;
9833 var c = [], sc = this;
9834 while(sc && sc.constructor.xtype){
9835 c.unshift(sc.constructor.xtype);
9836 sc = sc.constructor.superclass;
9839 tc.xtypes = c.join('/');
9845 findParentBy : function(fn) {
9846 for (var p = this.ownerCt; (p != null) && !fn(p, this); p = p.ownerCt);
9851 findParentByType : function(xtype) {
9852 return Ext.isFunction(xtype) ?
9853 this.findParentBy(function(p){
9854 return p.constructor === xtype;
9856 this.findParentBy(function(p){
9857 return p.constructor.xtype === xtype;
9862 getPositionEl : function(){
9863 return this.positionEl || this.el;
9867 purgeListeners : function(){
9868 Ext.Component.superclass.purgeListeners.call(this);
9870 this.on('beforedestroy', this.clearMons, this, {single: true});
9875 clearMons : function(){
9876 Ext.each(this.mons, function(m){
9877 m.item.un(m.ename, m.fn, m.scope);
9883 createMons: function(){
9886 this.on('beforedestroy', this.clearMons, this, {single: true});
9891 mon : function(item, ename, fn, scope, opt){
9893 if(Ext.isObject(ename)){
9894 var propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/;
9901 if(Ext.isFunction(o[e])){
9904 item: item, ename: e, fn: o[e], scope: o.scope
9906 item.on(e, o[e], o.scope, o);
9910 item: item, ename: e, fn: o[e], scope: o.scope
9919 item: item, ename: ename, fn: fn, scope: scope
9921 item.on(ename, fn, scope, opt);
9925 mun : function(item, ename, fn, scope){
9928 for(var i = 0, len = this.mons.length; i < len; ++i){
9930 if(item === mon.item && ename == mon.ename && fn === mon.fn && scope === mon.scope){
9931 this.mons.splice(i, 1);
9932 item.un(ename, fn, scope);
9941 nextSibling : function(){
9943 var index = this.ownerCt.items.indexOf(this);
9944 if(index != -1 && index+1 < this.ownerCt.items.getCount()){
9945 return this.ownerCt.items.itemAt(index+1);
9952 previousSibling : function(){
9954 var index = this.ownerCt.items.indexOf(this);
9956 return this.ownerCt.items.itemAt(index-1);
9963 getBubbleTarget : function(){
9964 return this.ownerCt;
9968 Ext.reg('component', Ext.Component);
9969 Ext.Action = Ext.extend(Object, {
9978 constructor : function(config){
9979 this.initialConfig = config;
9980 this.itemId = config.itemId = (config.itemId || config.id || Ext.id());
9988 setText : function(text){
9989 this.initialConfig.text = text;
9990 this.callEach('setText', [text]);
9994 getText : function(){
9995 return this.initialConfig.text;
9999 setIconClass : function(cls){
10000 this.initialConfig.iconCls = cls;
10001 this.callEach('setIconClass', [cls]);
10005 getIconClass : function(){
10006 return this.initialConfig.iconCls;
10010 setDisabled : function(v){
10011 this.initialConfig.disabled = v;
10012 this.callEach('setDisabled', [v]);
10016 enable : function(){
10017 this.setDisabled(false);
10021 disable : function(){
10022 this.setDisabled(true);
10026 isDisabled : function(){
10027 return this.initialConfig.disabled;
10031 setHidden : function(v){
10032 this.initialConfig.hidden = v;
10033 this.callEach('setVisible', [!v]);
10038 this.setHidden(false);
10043 this.setHidden(true);
10047 isHidden : function(){
10048 return this.initialConfig.hidden;
10052 setHandler : function(fn, scope){
10053 this.initialConfig.handler = fn;
10054 this.initialConfig.scope = scope;
10055 this.callEach('setHandler', [fn, scope]);
10059 each : function(fn, scope){
10060 Ext.each(this.items, fn, scope);
10064 callEach : function(fnName, args){
10065 var cs = this.items;
10066 for(var i = 0, len = cs.length; i < len; i++){
10067 cs[i][fnName].apply(cs[i], args);
10072 addComponent : function(comp){
10073 this.items.push(comp);
10074 comp.on('destroy', this.removeComponent, this);
10078 removeComponent : function(comp){
10079 this.items.remove(comp);
10083 execute : function(){
10084 this.initialConfig.handler.apply(this.initialConfig.scope || window, arguments);
10089 Ext.Layer = function(config, existingEl){
10090 config = config || {};
10091 var dh = Ext.DomHelper;
10092 var cp = config.parentEl, pel = cp ? Ext.getDom(cp) : document.body;
10094 this.dom = Ext.getDom(existingEl);
10097 var o = config.dh || {tag: 'div', cls: 'x-layer'};
10098 this.dom = dh.append(pel, o);
10101 this.addClass(config.cls);
10103 this.constrain = config.constrain !== false;
10104 this.setVisibilityMode(Ext.Element.VISIBILITY);
10106 this.id = this.dom.id = config.id;
10108 this.id = Ext.id(this.dom);
10110 this.zindex = config.zindex || this.getZIndex();
10111 this.position('absolute', this.zindex);
10113 this.shadowOffset = config.shadowOffset || 4;
10114 this.shadow = new Ext.Shadow({
10115 offset : this.shadowOffset,
10116 mode : config.shadow
10119 this.shadowOffset = 0;
10121 this.useShim = config.shim !== false && Ext.useShims;
10122 this.useDisplay = config.useDisplay;
10126 var supr = Ext.Element.prototype;
10131 Ext.extend(Ext.Layer, Ext.Element, {
10133 getZIndex : function(){
10134 return this.zindex || parseInt((this.getShim() || this).getStyle('z-index'), 10) || 11000;
10137 getShim : function(){
10144 var shim = shims.shift();
10146 shim = this.createShim();
10147 shim.enableDisplayMode('block');
10148 shim.dom.style.display = 'none';
10149 shim.dom.style.visibility = 'visible';
10151 var pn = this.dom.parentNode;
10152 if(shim.dom.parentNode != pn){
10153 pn.insertBefore(shim.dom, this.dom);
10155 shim.setStyle('z-index', this.getZIndex()-2);
10160 hideShim : function(){
10162 this.shim.setDisplayed(false);
10163 shims.push(this.shim);
10168 disableShadow : function(){
10170 this.shadowDisabled = true;
10171 this.shadow.hide();
10172 this.lastShadowOffset = this.shadowOffset;
10173 this.shadowOffset = 0;
10177 enableShadow : function(show){
10179 this.shadowDisabled = false;
10180 this.shadowOffset = this.lastShadowOffset;
10181 delete this.lastShadowOffset;
10191 sync : function(doShow){
10192 var sw = this.shadow;
10193 if(!this.updating && this.isVisible() && (sw || this.useShim)){
10194 var sh = this.getShim();
10196 var w = this.getWidth(),
10197 h = this.getHeight();
10199 var l = this.getLeft(true),
10200 t = this.getTop(true);
10202 if(sw && !this.shadowDisabled){
10203 if(doShow && !sw.isVisible()){
10206 sw.realign(l, t, w, h);
10213 var a = sw.adjusts, s = sh.dom.style;
10214 s.left = (Math.min(l, l+a.l))+'px';
10215 s.top = (Math.min(t, t+a.t))+'px';
10216 s.width = (w+a.w)+'px';
10217 s.height = (h+a.h)+'px';
10224 sh.setLeftTop(l, t);
10231 destroy : function(){
10234 this.shadow.hide();
10236 this.removeAllListeners();
10237 Ext.removeNode(this.dom);
10241 remove : function(){
10246 beginUpdate : function(){
10247 this.updating = true;
10251 endUpdate : function(){
10252 this.updating = false;
10257 hideUnders : function(negOffset){
10259 this.shadow.hide();
10265 constrainXY : function(){
10266 if(this.constrain){
10267 var vw = Ext.lib.Dom.getViewWidth(),
10268 vh = Ext.lib.Dom.getViewHeight();
10269 var s = Ext.getDoc().getScroll();
10271 var xy = this.getXY();
10272 var x = xy[0], y = xy[1];
10273 var so = this.shadowOffset;
10274 var w = this.dom.offsetWidth+so, h = this.dom.offsetHeight+so;
10278 if((x + w) > vw+s.left){
10282 if((y + h) > vh+s.top){
10297 var ay = this.avoidY;
10298 if(y <= ay && (y+h) >= ay){
10304 supr.setXY.call(this, xy);
10311 isVisible : function(){
10312 return this.visible;
10316 showAction : function(){
10317 this.visible = true;
10318 if(this.useDisplay === true){
10319 this.setDisplayed('');
10320 }else if(this.lastXY){
10321 supr.setXY.call(this, this.lastXY);
10322 }else if(this.lastLT){
10323 supr.setLeftTop.call(this, this.lastLT[0], this.lastLT[1]);
10328 hideAction : function(){
10329 this.visible = false;
10330 if(this.useDisplay === true){
10331 this.setDisplayed(false);
10333 this.setLeftTop(-10000,-10000);
10338 setVisible : function(v, a, d, c, e){
10343 var cb = function(){
10348 }.createDelegate(this);
10349 supr.setVisible.call(this, true, true, d, cb, e);
10352 this.hideUnders(true);
10361 }.createDelegate(this);
10363 supr.setVisible.call(this, v, a, d, cb, e);
10373 storeXY : function(xy){
10374 delete this.lastLT;
10378 storeLeftTop : function(left, top){
10379 delete this.lastXY;
10380 this.lastLT = [left, top];
10384 beforeFx : function(){
10385 this.beforeAction();
10386 return Ext.Layer.superclass.beforeFx.apply(this, arguments);
10390 afterFx : function(){
10391 Ext.Layer.superclass.afterFx.apply(this, arguments);
10392 this.sync(this.isVisible());
10396 beforeAction : function(){
10397 if(!this.updating && this.shadow){
10398 this.shadow.hide();
10403 setLeft : function(left){
10404 this.storeLeftTop(left, this.getTop(true));
10405 supr.setLeft.apply(this, arguments);
10410 setTop : function(top){
10411 this.storeLeftTop(this.getLeft(true), top);
10412 supr.setTop.apply(this, arguments);
10417 setLeftTop : function(left, top){
10418 this.storeLeftTop(left, top);
10419 supr.setLeftTop.apply(this, arguments);
10424 setXY : function(xy, a, d, c, e){
10426 this.beforeAction();
10428 var cb = this.createCB(c);
10429 supr.setXY.call(this, xy, a, d, cb, e);
10437 createCB : function(c){
10449 setX : function(x, a, d, c, e){
10450 this.setXY([x, this.getY()], a, d, c, e);
10455 setY : function(y, a, d, c, e){
10456 this.setXY([this.getX(), y], a, d, c, e);
10461 setSize : function(w, h, a, d, c, e){
10462 this.beforeAction();
10463 var cb = this.createCB(c);
10464 supr.setSize.call(this, w, h, a, d, cb, e);
10472 setWidth : function(w, a, d, c, e){
10473 this.beforeAction();
10474 var cb = this.createCB(c);
10475 supr.setWidth.call(this, w, a, d, cb, e);
10483 setHeight : function(h, a, d, c, e){
10484 this.beforeAction();
10485 var cb = this.createCB(c);
10486 supr.setHeight.call(this, h, a, d, cb, e);
10494 setBounds : function(x, y, w, h, a, d, c, e){
10495 this.beforeAction();
10496 var cb = this.createCB(c);
10498 this.storeXY([x, y]);
10499 supr.setXY.call(this, [x, y]);
10500 supr.setSize.call(this, w, h, a, d, cb, e);
10503 supr.setBounds.call(this, x, y, w, h, a, d, cb, e);
10509 setZIndex : function(zindex){
10510 this.zindex = zindex;
10511 this.setStyle('z-index', zindex + 2);
10513 this.shadow.setZIndex(zindex + 1);
10516 this.shim.setStyle('z-index', zindex);
10523 Ext.Shadow = function(config){
10524 Ext.apply(this, config);
10525 if(typeof this.mode != "string"){
10526 this.mode = this.defaultMode;
10528 var o = this.offset, a = {h: 0};
10529 var rad = Math.floor(this.offset/2);
10530 switch(this.mode.toLowerCase()){
10536 a.l -= this.offset + rad;
10537 a.t -= this.offset + rad;
10548 a.l -= (this.offset - rad);
10549 a.t -= this.offset + rad;
10551 a.w -= (this.offset - rad)*2;
10562 a.l -= (this.offset - rad);
10563 a.t -= (this.offset - rad);
10565 a.w -= (this.offset + rad + 1);
10566 a.h -= (this.offset + rad);
10575 Ext.Shadow.prototype = {
10581 defaultMode: "drop",
10584 show : function(target){
10585 target = Ext.get(target);
10587 this.el = Ext.Shadow.Pool.pull();
10588 if(this.el.dom.nextSibling != target.dom){
10589 this.el.insertBefore(target);
10592 this.el.setStyle("z-index", this.zIndex || parseInt(target.getStyle("z-index"), 10)-1);
10594 this.el.dom.style.filter="progid:DXImageTransform.Microsoft.alpha(opacity=50) progid:DXImageTransform.Microsoft.Blur(pixelradius="+(this.offset)+")";
10597 target.getLeft(true),
10598 target.getTop(true),
10602 this.el.dom.style.display = "block";
10606 isVisible : function(){
10607 return this.el ? true : false;
10611 realign : function(l, t, w, h){
10615 var a = this.adjusts, d = this.el.dom, s = d.style;
10617 s.left = (l+a.l)+"px";
10618 s.top = (t+a.t)+"px";
10619 var sw = (w+a.w), sh = (h+a.h), sws = sw +"px", shs = sh + "px";
10620 if(s.width != sws || s.height != shs){
10624 var cn = d.childNodes;
10625 var sww = Math.max(0, (sw-12))+"px";
10626 cn[0].childNodes[1].style.width = sww;
10627 cn[1].childNodes[1].style.width = sww;
10628 cn[2].childNodes[1].style.width = sww;
10629 cn[1].style.height = Math.max(0, (sh-12))+"px";
10637 this.el.dom.style.display = "none";
10638 Ext.Shadow.Pool.push(this.el);
10644 setZIndex : function(z){
10647 this.el.setStyle("z-index", z);
10653 Ext.Shadow.Pool = function(){
10655 var markup = Ext.isIE ?
10656 '<div class="x-ie-shadow"></div>' :
10657 '<div class="x-shadow"><div class="xst"><div class="xstl"></div><div class="xstc"></div><div class="xstr"></div></div><div class="xsc"><div class="xsml"></div><div class="xsmc"></div><div class="xsmr"></div></div><div class="xsb"><div class="xsbl"></div><div class="xsbc"></div><div class="xsbr"></div></div></div>';
10660 var sh = p.shift();
10662 sh = Ext.get(Ext.DomHelper.insertHtml("beforeBegin", document.body.firstChild, markup));
10663 sh.autoBoxAdjust = false;
10668 push : function(sh){
10673 Ext.BoxComponent = Ext.extend(Ext.Component, {
10698 initComponent : function(){
10699 Ext.BoxComponent.superclass.initComponent.call(this);
10711 deferHeight: false,
10714 setSize : function(w, h){
10717 if(typeof w == 'object'){
10718 h = w.height, w = w.width;
10720 if (Ext.isDefined(w) && Ext.isDefined(this.boxMinWidth) && (w < this.boxMinWidth)) {
10721 w = this.boxMinWidth;
10723 if (Ext.isDefined(h) && Ext.isDefined(this.boxMinHeight) && (h < this.boxMinHeight)) {
10724 h = this.boxMinHeight;
10726 if (Ext.isDefined(w) && Ext.isDefined(this.boxMaxWidth) && (w > this.boxMaxWidth)) {
10727 w = this.boxMaxWidth;
10729 if (Ext.isDefined(h) && Ext.isDefined(this.boxMaxHeight) && (h > this.boxMaxHeight)) {
10730 h = this.boxMaxHeight;
10733 if(!this.boxReady){
10734 this.width = w, this.height = h;
10739 if(this.cacheSizes !== false && this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
10742 this.lastSize = {width: w, height: h};
10743 var adj = this.adjustSize(w, h),
10747 if(aw !== undefined || ah !== undefined){
10748 rz = this.getResizeEl();
10749 if(!this.deferHeight && aw !== undefined && ah !== undefined){
10750 rz.setSize(aw, ah);
10751 }else if(!this.deferHeight && ah !== undefined){
10753 }else if(aw !== undefined){
10756 this.onResize(aw, ah, w, h);
10762 setWidth : function(width){
10763 return this.setSize(width);
10767 setHeight : function(height){
10768 return this.setSize(undefined, height);
10772 getSize : function(){
10773 return this.getResizeEl().getSize();
10777 getWidth : function(){
10778 return this.getResizeEl().getWidth();
10782 getHeight : function(){
10783 return this.getResizeEl().getHeight();
10787 getOuterSize : function(){
10788 var el = this.getResizeEl();
10789 return {width: el.getWidth() + el.getMargins('lr'),
10790 height: el.getHeight() + el.getMargins('tb')};
10794 getPosition : function(local){
10795 var el = this.getPositionEl();
10796 if(local === true){
10797 return [el.getLeft(true), el.getTop(true)];
10799 return this.xy || el.getXY();
10803 getBox : function(local){
10804 var pos = this.getPosition(local);
10805 var s = this.getSize();
10812 updateBox : function(box){
10813 this.setSize(box.width, box.height);
10814 this.setPagePosition(box.x, box.y);
10819 getResizeEl : function(){
10820 return this.resizeEl || this.el;
10824 setAutoScroll : function(scroll){
10826 this.getContentTarget().setOverflow(scroll ? 'auto' : '');
10828 this.autoScroll = scroll;
10833 setPosition : function(x, y){
10834 if(x && typeof x[1] == 'number'){
10840 if(!this.boxReady){
10843 var adj = this.adjustPosition(x, y);
10844 var ax = adj.x, ay = adj.y;
10846 var el = this.getPositionEl();
10847 if(ax !== undefined || ay !== undefined){
10848 if(ax !== undefined && ay !== undefined){
10849 el.setLeftTop(ax, ay);
10850 }else if(ax !== undefined){
10852 }else if(ay !== undefined){
10855 this.onPosition(ax, ay);
10856 this.fireEvent('move', this, ax, ay);
10862 setPagePosition : function(x, y){
10863 if(x && typeof x[1] == 'number'){
10869 if(!this.boxReady){
10872 if(x === undefined || y === undefined){
10875 var p = this.getPositionEl().translatePoints(x, y);
10876 this.setPosition(p.left, p.top);
10881 afterRender : function(){
10882 Ext.BoxComponent.superclass.afterRender.call(this);
10884 this.resizeEl = Ext.get(this.resizeEl);
10886 if(this.positionEl){
10887 this.positionEl = Ext.get(this.positionEl);
10889 this.boxReady = true;
10890 this.setAutoScroll(this.autoScroll);
10891 this.setSize(this.width, this.height);
10892 if(this.x || this.y){
10893 this.setPosition(this.x, this.y);
10894 }else if(this.pageX || this.pageY){
10895 this.setPagePosition(this.pageX, this.pageY);
10900 syncSize : function(){
10901 delete this.lastSize;
10902 this.setSize(this.autoWidth ? undefined : this.getResizeEl().getWidth(), this.autoHeight ? undefined : this.getResizeEl().getHeight());
10907 onResize : function(adjWidth, adjHeight, rawWidth, rawHeight){
10908 this.fireEvent('resize', this, adjWidth, adjHeight, rawWidth, rawHeight);
10912 onPosition : function(x, y){
10917 adjustSize : function(w, h){
10918 if(this.autoWidth){
10921 if(this.autoHeight){
10924 return {width : w, height: h};
10928 adjustPosition : function(x, y){
10929 return {x : x, y: y};
10932 Ext.reg('box', Ext.BoxComponent);
10936 Ext.Spacer = Ext.extend(Ext.BoxComponent, {
10939 Ext.reg('spacer', Ext.Spacer);
10940 Ext.SplitBar = function(dragElement, resizingElement, orientation, placement, existingProxy){
10943 this.el = Ext.get(dragElement, true);
10944 this.el.dom.unselectable = "on";
10946 this.resizingEl = Ext.get(resizingElement, true);
10949 this.orientation = orientation || Ext.SplitBar.HORIZONTAL;
10956 this.maxSize = 2000;
10959 this.animate = false;
10962 this.useShim = false;
10967 if(!existingProxy){
10969 this.proxy = Ext.SplitBar.createProxy(this.orientation);
10971 this.proxy = Ext.get(existingProxy).dom;
10974 this.dd = new Ext.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
10977 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
10980 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
10983 this.dragSpecs = {};
10986 this.adapter = new Ext.SplitBar.BasicLayoutAdapter();
10987 this.adapter.init(this);
10989 if(this.orientation == Ext.SplitBar.HORIZONTAL){
10991 this.placement = placement || (this.el.getX() > this.resizingEl.getX() ? Ext.SplitBar.LEFT : Ext.SplitBar.RIGHT);
10992 this.el.addClass("x-splitbar-h");
10995 this.placement = placement || (this.el.getY() > this.resizingEl.getY() ? Ext.SplitBar.TOP : Ext.SplitBar.BOTTOM);
10996 this.el.addClass("x-splitbar-v");
11010 Ext.SplitBar.superclass.constructor.call(this);
11013 Ext.extend(Ext.SplitBar, Ext.util.Observable, {
11014 onStartProxyDrag : function(x, y){
11015 this.fireEvent("beforeresize", this);
11016 this.overlay = Ext.DomHelper.append(document.body, {cls: "x-drag-overlay", html: " "}, true);
11017 this.overlay.unselectable();
11018 this.overlay.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
11019 this.overlay.show();
11020 Ext.get(this.proxy).setDisplayed("block");
11021 var size = this.adapter.getElementSize(this);
11022 this.activeMinSize = this.getMinimumSize();
11023 this.activeMaxSize = this.getMaximumSize();
11024 var c1 = size - this.activeMinSize;
11025 var c2 = Math.max(this.activeMaxSize - size, 0);
11026 if(this.orientation == Ext.SplitBar.HORIZONTAL){
11027 this.dd.resetConstraints();
11028 this.dd.setXConstraint(
11029 this.placement == Ext.SplitBar.LEFT ? c1 : c2,
11030 this.placement == Ext.SplitBar.LEFT ? c2 : c1,
11033 this.dd.setYConstraint(0, 0);
11035 this.dd.resetConstraints();
11036 this.dd.setXConstraint(0, 0);
11037 this.dd.setYConstraint(
11038 this.placement == Ext.SplitBar.TOP ? c1 : c2,
11039 this.placement == Ext.SplitBar.TOP ? c2 : c1,
11043 this.dragSpecs.startSize = size;
11044 this.dragSpecs.startPoint = [x, y];
11045 Ext.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
11049 onEndProxyDrag : function(e){
11050 Ext.get(this.proxy).setDisplayed(false);
11051 var endPoint = Ext.lib.Event.getXY(e);
11053 Ext.destroy(this.overlay);
11054 delete this.overlay;
11057 if(this.orientation == Ext.SplitBar.HORIZONTAL){
11058 newSize = this.dragSpecs.startSize +
11059 (this.placement == Ext.SplitBar.LEFT ?
11060 endPoint[0] - this.dragSpecs.startPoint[0] :
11061 this.dragSpecs.startPoint[0] - endPoint[0]
11064 newSize = this.dragSpecs.startSize +
11065 (this.placement == Ext.SplitBar.TOP ?
11066 endPoint[1] - this.dragSpecs.startPoint[1] :
11067 this.dragSpecs.startPoint[1] - endPoint[1]
11070 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
11071 if(newSize != this.dragSpecs.startSize){
11072 if(this.fireEvent('beforeapply', this, newSize) !== false){
11073 this.adapter.setElementSize(this, newSize);
11074 this.fireEvent("moved", this, newSize);
11075 this.fireEvent("resize", this, newSize);
11081 getAdapter : function(){
11082 return this.adapter;
11086 setAdapter : function(adapter){
11087 this.adapter = adapter;
11088 this.adapter.init(this);
11092 getMinimumSize : function(){
11093 return this.minSize;
11097 setMinimumSize : function(minSize){
11098 this.minSize = minSize;
11102 getMaximumSize : function(){
11103 return this.maxSize;
11107 setMaximumSize : function(maxSize){
11108 this.maxSize = maxSize;
11112 setCurrentSize : function(size){
11113 var oldAnimate = this.animate;
11114 this.animate = false;
11115 this.adapter.setElementSize(this, size);
11116 this.animate = oldAnimate;
11120 destroy : function(removeEl){
11121 Ext.destroy(this.shim, Ext.get(this.proxy));
11126 this.purgeListeners();
11131 Ext.SplitBar.createProxy = function(dir){
11132 var proxy = new Ext.Element(document.createElement("div"));
11133 document.body.appendChild(proxy.dom);
11134 proxy.unselectable();
11135 var cls = 'x-splitbar-proxy';
11136 proxy.addClass(cls + ' ' + (dir == Ext.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
11141 Ext.SplitBar.BasicLayoutAdapter = function(){
11144 Ext.SplitBar.BasicLayoutAdapter.prototype = {
11146 init : function(s){
11150 getElementSize : function(s){
11151 if(s.orientation == Ext.SplitBar.HORIZONTAL){
11152 return s.resizingEl.getWidth();
11154 return s.resizingEl.getHeight();
11159 setElementSize : function(s, newSize, onComplete){
11160 if(s.orientation == Ext.SplitBar.HORIZONTAL){
11162 s.resizingEl.setWidth(newSize);
11164 onComplete(s, newSize);
11167 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
11172 s.resizingEl.setHeight(newSize);
11174 onComplete(s, newSize);
11177 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
11184 Ext.SplitBar.AbsoluteLayoutAdapter = function(container){
11185 this.basic = new Ext.SplitBar.BasicLayoutAdapter();
11186 this.container = Ext.get(container);
11189 Ext.SplitBar.AbsoluteLayoutAdapter.prototype = {
11190 init : function(s){
11191 this.basic.init(s);
11194 getElementSize : function(s){
11195 return this.basic.getElementSize(s);
11198 setElementSize : function(s, newSize, onComplete){
11199 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
11202 moveSplitter : function(s){
11203 var yes = Ext.SplitBar;
11204 switch(s.placement){
11206 s.el.setX(s.resizingEl.getRight());
11209 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
11212 s.el.setY(s.resizingEl.getBottom());
11215 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
11222 Ext.SplitBar.VERTICAL = 1;
11225 Ext.SplitBar.HORIZONTAL = 2;
11228 Ext.SplitBar.LEFT = 1;
11231 Ext.SplitBar.RIGHT = 2;
11234 Ext.SplitBar.TOP = 3;
11237 Ext.SplitBar.BOTTOM = 4;
11239 Ext.Container = Ext.extend(Ext.BoxComponent, {
11252 autoDestroy : true,
11255 forceLayout: false,
11259 defaultType : 'panel',
11262 resizeEvent: 'resize',
11265 bubbleEvents: ['add', 'remove'],
11268 initComponent : function(){
11269 Ext.Container.superclass.initComponent.call(this);
11284 this.enableBubble(this.bubbleEvents);
11287 var items = this.items;
11295 initItems : function(){
11297 this.items = new Ext.util.MixedCollection(false, this.getComponentId);
11303 setLayout : function(layout){
11304 if(this.layout && this.layout != layout){
11305 this.layout.setContainer(null);
11308 this.layout = layout;
11309 layout.setContainer(this);
11312 afterRender: function(){
11313 this.layoutDone = false;
11315 this.layout = 'auto';
11317 if(Ext.isObject(this.layout) && !this.layout.layout){
11318 this.layoutConfig = this.layout;
11319 this.layout = this.layoutConfig.type;
11321 if(Ext.isString(this.layout)){
11322 this.layout = new Ext.Container.LAYOUTS[this.layout.toLowerCase()](this.layoutConfig);
11324 this.setLayout(this.layout);
11328 Ext.Container.superclass.afterRender.call(this);
11330 if(Ext.isDefined(this.activeItem)){
11331 var item = this.activeItem;
11332 delete this.activeItem;
11333 this.layout.setActiveItem(item);
11337 if(!this.ownerCt && !this.layoutDone){
11338 this.doLayout(false, true);
11341 if(this.monitorResize === true){
11342 Ext.EventManager.onWindowResize(this.doLayout, this, [false]);
11347 getLayoutTarget : function(){
11352 getComponentId : function(comp){
11353 return comp.getItemId();
11357 add : function(comp){
11359 var args = arguments.length > 1;
11360 if(args || Ext.isArray(comp)){
11362 Ext.each(args ? arguments : comp, function(c){
11363 result.push(this.add(c));
11367 var c = this.lookupComponent(this.applyDefaults(comp));
11368 var index = this.items.length;
11369 if(this.fireEvent('beforeadd', this, c, index) !== false && this.onBeforeAdd(c) !== false){
11372 c.onAdded(this, index);
11374 this.fireEvent('add', this, c, index);
11379 onAdd : function(c){
11384 onAdded : function(container, pos) {
11386 this.ownerCt = container;
11389 this.cascade(function(c){
11392 this.fireEvent('added', this, container, pos);
11396 insert : function(index, comp){
11398 var a = arguments, len = a.length;
11401 for(var i = len-1; i >= 1; --i) {
11402 result.push(this.insert(index, a[i]));
11406 var c = this.lookupComponent(this.applyDefaults(comp));
11407 index = Math.min(index, this.items.length);
11408 if(this.fireEvent('beforeadd', this, c, index) !== false && this.onBeforeAdd(c) !== false){
11409 if(c.ownerCt == this){
11410 this.items.remove(c);
11412 this.items.insert(index, c);
11413 c.onAdded(this, index);
11415 this.fireEvent('add', this, c, index);
11421 applyDefaults : function(c){
11422 var d = this.defaults;
11424 if(Ext.isFunction(d)){
11425 d = d.call(this, c);
11427 if(Ext.isString(c)){
11428 c = Ext.ComponentMgr.get(c);
11430 }else if(!c.events){
11440 onBeforeAdd : function(item){
11442 item.ownerCt.remove(item, false);
11444 if(this.hideBorders === true){
11445 item.border = (item.border === true);
11450 remove : function(comp, autoDestroy){
11452 var c = this.getComponent(comp);
11453 if(c && this.fireEvent('beforeremove', this, c) !== false){
11454 this.doRemove(c, autoDestroy);
11455 this.fireEvent('remove', this, c);
11460 onRemove: function(c){
11465 doRemove: function(c, autoDestroy){
11466 if(this.layout && this.rendered){
11467 this.layout.onRemove(c);
11469 this.items.remove(c);
11472 if(autoDestroy === true || (autoDestroy !== false && this.autoDestroy)){
11478 removeAll: function(autoDestroy){
11480 var item, rem = [], items = [];
11481 this.items.each(function(i){
11484 for (var i = 0, len = rem.length; i < len; ++i){
11486 this.remove(item, autoDestroy);
11487 if(item.ownerCt !== this){
11495 getComponent : function(comp){
11496 if(Ext.isObject(comp)){
11497 comp = comp.getItemId();
11499 return this.items.get(comp);
11503 lookupComponent : function(comp){
11504 if(Ext.isString(comp)){
11505 return Ext.ComponentMgr.get(comp);
11506 }else if(!comp.events){
11507 return this.createComponent(comp);
11513 createComponent : function(config, defaultType){
11516 var c = config.render ? config : Ext.create(Ext.apply({
11518 }, config), defaultType || this.defaultType);
11524 canLayout: function() {
11525 var el = this.getLayoutTarget(), vs;
11526 return !!(el && (vs = el.dom.offsetWidth || el.dom.offsetHeight));
11530 doLayout: function(shallow, force){
11531 var rendered = this.rendered,
11532 forceLayout = force || this.forceLayout,
11535 this.layoutDone = true;
11536 if(!this.canLayout() || this.collapsed){
11537 this.deferLayout = this.deferLayout || !shallow;
11541 shallow = shallow && !this.deferLayout;
11543 delete this.deferLayout;
11546 cs = (shallow !== true && this.items) ? this.items.items : [];
11549 for(i = 0, len = cs.length; i < len; i++){
11550 if ((c = cs[i]).layout) {
11551 c.suspendLayoutResize = true;
11557 if(rendered && this.layout){
11558 this.layout.layout();
11562 for(i = 0; i < len; i++){
11563 if((c = cs[i]).doLayout){
11564 c.doLayout(false, forceLayout);
11568 this.onLayout(shallow, forceLayout);
11571 this.hasLayout = true;
11572 delete this.forceLayout;
11575 for(i = 0; i < len; i++){
11576 if ((c = cs[i]).layout) {
11577 delete c.suspendLayoutResize;
11583 onLayout : Ext.emptyFn,
11585 onResize: function(adjWidth, adjHeight, rawWidth, rawHeight){
11586 Ext.Container.superclass.onResize.apply(this, arguments);
11587 if ((this.rendered && this.layout && this.layout.monitorResize) && !this.suspendLayoutResize) {
11588 this.layout.onResize();
11593 hasLayoutPending: function(){
11595 var pending = this.layoutPending;
11596 this.ownerCt.bubble(function(c){
11597 return !(pending = c.layoutPending);
11603 onShow : function(){
11604 Ext.Container.superclass.onShow.call(this);
11605 if(Ext.isDefined(this.deferLayout)){
11606 this.doLayout(true);
11611 getLayout : function(){
11613 var layout = new Ext.layout.ContainerLayout(this.layoutConfig);
11614 this.setLayout(layout);
11616 return this.layout;
11620 beforeDestroy : function(){
11623 while(c = this.items.first()){
11624 this.doRemove(c, true);
11627 if(this.monitorResize){
11628 Ext.EventManager.removeResizeListener(this.doLayout, this);
11630 Ext.destroy(this.layout);
11631 Ext.Container.superclass.beforeDestroy.call(this);
11635 bubble : function(fn, scope, args){
11638 if(fn.apply(scope || p, args || [p]) === false){
11647 cascade : function(fn, scope, args){
11648 if(fn.apply(scope || this, args || [this]) !== false){
11650 var cs = this.items.items;
11651 for(var i = 0, len = cs.length; i < len; i++){
11653 cs[i].cascade(fn, scope, args);
11655 fn.apply(scope || cs[i], args || [cs[i]]);
11664 findById : function(id){
11666 this.cascade(function(c){
11667 if(ct != c && c.id === id){
11676 findByType : function(xtype, shallow){
11677 return this.findBy(function(c){
11678 return c.isXType(xtype, shallow);
11683 find : function(prop, value){
11684 return this.findBy(function(c){
11685 return c[prop] === value;
11690 findBy : function(fn, scope){
11691 var m = [], ct = this;
11692 this.cascade(function(c){
11693 if(ct != c && fn.call(scope || c, c, ct) === true){
11701 get : function(key){
11702 return this.items.get(key);
11706 Ext.Container.LAYOUTS = {};
11707 Ext.reg('container', Ext.Container);
11709 Ext.layout.ContainerLayout = Ext.extend(Object, {
11716 monitorResize:false,
11720 constructor : function(config){
11721 Ext.apply(this, config);
11725 layout : function(){
11726 var target = this.container.getLayoutTarget();
11727 if(!(this.hasLayout || Ext.isEmpty(this.targetCls))){
11728 target.addClass(this.targetCls)
11730 this.onLayout(this.container, target);
11731 this.container.fireEvent('afterlayout', this.container, this);
11732 this.hasLayout = true;
11736 onLayout : function(ct, target){
11737 this.renderAll(ct, target);
11741 isValidParent : function(c, target){
11742 return target && c.getPositionEl().dom.parentNode == (target.dom || target);
11746 renderAll : function(ct, target){
11747 var items = ct.items.items;
11748 for(var i = 0, len = items.length; i < len; i++) {
11750 if(c && (!c.rendered || !this.isValidParent(c, target))){
11751 this.renderItem(c, i, target);
11757 renderItem : function(c, position, target){
11758 if(c && !c.rendered){
11759 c.render(target, position);
11760 this.configureItem(c, position);
11761 }else if(c && !this.isValidParent(c, target)){
11762 if(Ext.isNumber(position)){
11763 position = target.dom.childNodes[position];
11765 target.dom.insertBefore(c.getPositionEl().dom, position || null);
11766 c.container = target;
11767 this.configureItem(c, position);
11772 configureItem: function(c, position){
11774 var t = c.getPositionEl ? c.getPositionEl() : c;
11775 t.addClass(this.extraCls);
11778 if(c.doLayout && this.forceLayout){
11779 c.doLayout(false, true);
11781 if (this.renderHidden && c != this.activeItem) {
11786 onRemove: function(c){
11787 if(this.activeItem == c){
11788 delete this.activeItem;
11790 if(c.rendered && this.extraCls){
11791 var t = c.getPositionEl ? c.getPositionEl() : c;
11792 t.removeClass(this.extraCls);
11797 onResize: function(){
11798 var ct = this.container,
11799 b = ct.bufferResize;
11807 if (b && ct.ownerCt) {
11811 if (!ct.hasLayoutPending()){
11812 if(!this.resizeTask){
11813 this.resizeTask = new Ext.util.DelayedTask(this.runLayout, this);
11814 this.resizeBuffer = Ext.isNumber(b) ? b : 50;
11816 ct.layoutPending = true;
11817 this.resizeTask.delay(this.resizeBuffer);
11820 ct.doLayout(false, this.forceLayout);
11825 runLayout: function(){
11826 var ct = this.container;
11828 delete ct.layoutPending;
11832 setContainer : function(ct){
11835 this.container = ct;
11839 parseMargins : function(v){
11840 if(Ext.isNumber(v)){
11843 var ms = v.split(' ');
11844 var len = ms.length;
11858 top:parseInt(ms[0], 10) || 0,
11859 right:parseInt(ms[1], 10) || 0,
11860 bottom:parseInt(ms[2], 10) || 0,
11861 left:parseInt(ms[3], 10) || 0
11866 fieldTpl: (function() {
11867 var t = new Ext.Template(
11868 '<div class="x-form-item {itemCls}" tabIndex="-1">',
11869 '<label for="{id}" style="{labelStyle}" class="x-form-item-label">{label}{labelSeparator}</label>',
11870 '<div class="x-form-element" id="x-form-el-{id}" style="{elementStyle}">',
11871 '</div><div class="{clearCls}"></div>',
11874 t.disableFormats = true;
11875 return t.compile();
11879 destroy : function(){
11880 if(!Ext.isEmpty(this.targetCls)){
11881 var target = this.container.getLayoutTarget();
11883 target.removeClass(this.targetCls);
11888 Ext.Container.LAYOUTS['auto'] = Ext.layout.ContainerLayout;
11890 Ext.layout.FitLayout = Ext.extend(Ext.layout.ContainerLayout, {
11892 monitorResize:true,
11895 onLayout : function(ct, target){
11896 Ext.layout.FitLayout.superclass.onLayout.call(this, ct, target);
11897 if(!this.container.collapsed){
11898 this.setItemSize(this.activeItem || ct.items.itemAt(0), target.getViewSize(true));
11903 setItemSize : function(item, size){
11904 if(item && size.height > 0){
11905 item.setSize(size);
11909 Ext.Container.LAYOUTS['fit'] = Ext.layout.FitLayout;
11910 Ext.layout.CardLayout = Ext.extend(Ext.layout.FitLayout, {
11912 deferredRender : false,
11915 layoutOnCardChange : false,
11919 renderHidden : true,
11921 constructor: function(config){
11922 Ext.layout.CardLayout.superclass.constructor.call(this, config);
11927 setActiveItem : function(item){
11928 var ai = this.activeItem;
11929 item = this.container.getComponent(item);
11933 ai.fireEvent('deactivate', ai);
11935 var layout = item.doLayout && (this.layoutOnCardChange || !item.rendered);
11936 this.activeItem = item;
11941 if(item && layout){
11944 item.fireEvent('activate', item);
11949 renderAll : function(ct, target){
11950 if(this.deferredRender){
11951 this.renderItem(this.activeItem, undefined, target);
11953 Ext.layout.CardLayout.superclass.renderAll.call(this, ct, target);
11957 Ext.Container.LAYOUTS['card'] = Ext.layout.CardLayout;
11958 Ext.layout.AnchorLayout = Ext.extend(Ext.layout.ContainerLayout, {
11962 monitorResize:true,
11966 getAnchorViewSize : function(ct, target){
11967 return target.dom == document.body ?
11968 target.getViewSize(true) : target.getStyleSize();
11972 onLayout : function(ct, target){
11973 Ext.layout.AnchorLayout.superclass.onLayout.call(this, ct, target);
11975 var size = target.getViewSize(true);
11977 var w = size.width, h = size.height;
11979 if(w < 20 && h < 20){
11986 if(typeof ct.anchorSize == 'number'){
11987 aw = ct.anchorSize;
11989 aw = ct.anchorSize.width;
11990 ah = ct.anchorSize.height;
11993 aw = ct.initialConfig.width;
11994 ah = ct.initialConfig.height;
11997 var cs = ct.items.items, len = cs.length, i, c, a, cw, ch, el, vs;
11998 for(i = 0; i < len; i++){
12000 el = c.getPositionEl();
12004 vs = c.anchor.split(' ');
12005 c.anchorSpec = a = {
12006 right: this.parseAnchor(vs[0], c.initialConfig.width, aw),
12007 bottom: this.parseAnchor(vs[1], c.initialConfig.height, ah)
12010 cw = a.right ? this.adjustWidthAnchor(a.right(w) - el.getMargins('lr'), c) : undefined;
12011 ch = a.bottom ? this.adjustHeightAnchor(a.bottom(h) - el.getMargins('tb'), c) : undefined;
12014 c.setSize(cw || undefined, ch || undefined);
12021 parseAnchor : function(a, start, cstart){
12022 if(a && a != 'none'){
12024 if(/^(r|right|b|bottom)$/i.test(a)){
12025 var diff = cstart - start;
12026 return function(v){
12032 }else if(a.indexOf('%') != -1){
12033 var ratio = parseFloat(a.replace('%', ''))*.01;
12034 return function(v){
12037 return Math.floor(v*ratio);
12041 a = parseInt(a, 10);
12043 return function(v){
12056 adjustWidthAnchor : function(value, comp){
12061 adjustHeightAnchor : function(value, comp){
12067 Ext.Container.LAYOUTS['anchor'] = Ext.layout.AnchorLayout;
12069 Ext.layout.ColumnLayout = Ext.extend(Ext.layout.ContainerLayout, {
12071 monitorResize:true,
12073 extraCls: 'x-column',
12079 targetCls: 'x-column-layout-ct',
12081 isValidParent : function(c, target){
12082 return c.getPositionEl().dom.parentNode == this.innerCt.dom;
12086 onLayout : function(ct, target){
12087 var cs = ct.items.items, len = cs.length, c, i;
12092 this.innerCt = target.createChild({cls:'x-column-inner'});
12093 this.innerCt.createChild({cls:'x-clear'});
12095 this.renderAll(ct, this.innerCt);
12097 var size = target.getViewSize(true);
12099 if(size.width < 1 && size.height < 1){
12103 var w = size.width - this.scrollOffset,
12107 this.innerCt.setWidth(w);
12112 for(i = 0; i < len; i++){
12114 if(!c.columnWidth){
12115 pw -= (c.getSize().width + c.getPositionEl().getMargins('lr'));
12119 pw = pw < 0 ? 0 : pw;
12121 for(i = 0; i < len; i++){
12124 c.setSize(Math.floor(c.columnWidth * pw) - c.getPositionEl().getMargins('lr'));
12132 Ext.Container.LAYOUTS['column'] = Ext.layout.ColumnLayout;
12133 Ext.layout.BorderLayout = Ext.extend(Ext.layout.ContainerLayout, {
12135 monitorResize:true,
12139 targetCls: 'x-border-layout-ct',
12142 onLayout : function(ct, target){
12144 if(!this.rendered){
12145 var items = ct.items.items;
12147 for(var i = 0, len = items.length; i < len; i++) {
12149 var pos = c.region;
12153 c.collapsed = false;
12155 c.render(target, i);
12156 c.getPositionEl().addClass('x-border-panel');
12158 this[pos] = pos != 'center' && c.split ?
12159 new Ext.layout.BorderLayout.SplitRegion(this, c.initialConfig, pos) :
12160 new Ext.layout.BorderLayout.Region(this, c.initialConfig, pos);
12161 this[pos].render(target, c);
12163 this.rendered = true;
12166 var size = target.getViewSize(false);
12167 if(size.width < 20 || size.height < 20){
12169 this.restoreCollapsed = collapsed;
12172 }else if(this.restoreCollapsed){
12173 collapsed = this.restoreCollapsed;
12174 delete this.restoreCollapsed;
12177 var w = size.width, h = size.height;
12178 var centerW = w, centerH = h, centerY = 0, centerX = 0;
12180 var n = this.north, s = this.south, west = this.west, e = this.east, c = this.center;
12181 if(!c && Ext.layout.BorderLayout.WARN !== false){
12182 throw 'No center region defined in BorderLayout ' + ct.id;
12185 if(n && n.isVisible()){
12186 var b = n.getSize();
12187 var m = n.getMargins();
12188 b.width = w - (m.left+m.right);
12191 centerY = b.height + b.y + m.bottom;
12192 centerH -= centerY;
12195 if(s && s.isVisible()){
12196 var b = s.getSize();
12197 var m = s.getMargins();
12198 b.width = w - (m.left+m.right);
12200 var totalHeight = (b.height + m.top + m.bottom);
12201 b.y = h - totalHeight + m.top;
12202 centerH -= totalHeight;
12205 if(west && west.isVisible()){
12206 var b = west.getSize();
12207 var m = west.getMargins();
12208 b.height = centerH - (m.top+m.bottom);
12210 b.y = centerY + m.top;
12211 var totalWidth = (b.width + m.left + m.right);
12212 centerX += totalWidth;
12213 centerW -= totalWidth;
12214 west.applyLayout(b);
12216 if(e && e.isVisible()){
12217 var b = e.getSize();
12218 var m = e.getMargins();
12219 b.height = centerH - (m.top+m.bottom);
12220 var totalWidth = (b.width + m.left + m.right);
12221 b.x = w - totalWidth + m.left;
12222 b.y = centerY + m.top;
12223 centerW -= totalWidth;
12227 var m = c.getMargins();
12229 x: centerX + m.left,
12230 y: centerY + m.top,
12231 width: centerW - (m.left+m.right),
12232 height: centerH - (m.top+m.bottom)
12234 c.applyLayout(centerBox);
12237 for(var i = 0, len = collapsed.length; i < len; i++){
12238 collapsed[i].collapse(false);
12241 if(Ext.isIE && Ext.isStrict){
12246 destroy: function() {
12247 var r = ['north', 'south', 'east', 'west'];
12248 for (var i = 0; i < r.length; i++) {
12249 var region = this[r[i]];
12251 if(region.destroy){
12253 }else if (region.split){
12254 region.split.destroy(true);
12258 Ext.layout.BorderLayout.superclass.destroy.call(this);
12265 Ext.layout.BorderLayout.Region = function(layout, config, pos){
12266 Ext.apply(this, config);
12267 this.layout = layout;
12268 this.position = pos;
12270 if(typeof this.margins == 'string'){
12271 this.margins = this.layout.parseMargins(this.margins);
12273 this.margins = Ext.applyIf(this.margins || {}, this.defaultMargins);
12274 if(this.collapsible){
12275 if(typeof this.cmargins == 'string'){
12276 this.cmargins = this.layout.parseMargins(this.cmargins);
12278 if(this.collapseMode == 'mini' && !this.cmargins){
12279 this.cmargins = {left:0,top:0,right:0,bottom:0};
12281 this.cmargins = Ext.applyIf(this.cmargins || {},
12282 pos == 'north' || pos == 'south' ? this.defaultNSCMargins : this.defaultEWCMargins);
12287 Ext.layout.BorderLayout.Region.prototype = {
12294 collapsible : false,
12305 defaultMargins : {left:0,top:0,right:0,bottom:0},
12307 defaultNSCMargins : {left:5,top:5,right:5,bottom:5},
12309 defaultEWCMargins : {left:5,top:0,right:5,bottom:0},
12310 floatingZIndex: 100,
12313 isCollapsed : false,
12320 render : function(ct, p){
12322 p.el.enableDisplayMode();
12323 this.targetEl = ct;
12326 var gs = p.getState, ps = this.position;
12327 p.getState = function(){
12328 return Ext.apply(gs.call(p) || {}, this.state);
12329 }.createDelegate(this);
12331 if(ps != 'center'){
12332 p.allowQueuedExpand = false;
12334 beforecollapse: this.beforeCollapse,
12335 collapse: this.onCollapse,
12336 beforeexpand: this.beforeExpand,
12337 expand: this.onExpand,
12342 if(this.collapsible || this.floatable){
12343 p.collapseEl = 'el';
12344 p.slideAnchor = this.getSlideAnchor();
12346 if(p.tools && p.tools.toggle){
12347 p.tools.toggle.addClass('x-tool-collapse-'+ps);
12348 p.tools.toggle.addClassOnOver('x-tool-collapse-'+ps+'-over');
12354 getCollapsedEl : function(){
12355 if(!this.collapsedEl){
12356 if(!this.toolTemplate){
12357 var tt = new Ext.Template(
12358 '<div class="x-tool x-tool-{id}"> </div>'
12360 tt.disableFormats = true;
12362 Ext.layout.BorderLayout.Region.prototype.toolTemplate = tt;
12364 this.collapsedEl = this.targetEl.createChild({
12365 cls: "x-layout-collapsed x-layout-collapsed-"+this.position,
12366 id: this.panel.id + '-xcollapsed'
12368 this.collapsedEl.enableDisplayMode('block');
12370 if(this.collapseMode == 'mini'){
12371 this.collapsedEl.addClass('x-layout-cmini-'+this.position);
12372 this.miniCollapsedEl = this.collapsedEl.createChild({
12373 cls: "x-layout-mini x-layout-mini-"+this.position, html: " "
12375 this.miniCollapsedEl.addClassOnOver('x-layout-mini-over');
12376 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
12377 this.collapsedEl.on('click', this.onExpandClick, this, {stopEvent:true});
12379 if(this.collapsible !== false && !this.hideCollapseTool) {
12380 var t = this.toolTemplate.append(
12381 this.collapsedEl.dom,
12382 {id:'expand-'+this.position}, true);
12383 t.addClassOnOver('x-tool-expand-'+this.position+'-over');
12384 t.on('click', this.onExpandClick, this, {stopEvent:true});
12386 if(this.floatable !== false || this.titleCollapse){
12387 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
12388 this.collapsedEl.on("click", this[this.floatable ? 'collapseClick' : 'onExpandClick'], this);
12392 return this.collapsedEl;
12396 onExpandClick : function(e){
12398 this.panel.expand(false);
12400 this.panel.expand();
12405 onCollapseClick : function(e){
12406 this.panel.collapse();
12410 beforeCollapse : function(p, animate){
12411 this.lastAnim = animate;
12413 this.splitEl.hide();
12415 this.getCollapsedEl().show();
12416 var el = this.panel.getEl();
12417 this.originalZIndex = el.getStyle('z-index');
12418 el.setStyle('z-index', 100);
12419 this.isCollapsed = true;
12420 this.layout.layout();
12424 onCollapse : function(animate){
12425 this.panel.el.setStyle('z-index', 1);
12426 if(this.lastAnim === false || this.panel.animCollapse === false){
12427 this.getCollapsedEl().dom.style.visibility = 'visible';
12429 this.getCollapsedEl().slideIn(this.panel.slideAnchor, {duration:.2});
12431 this.state.collapsed = true;
12432 this.panel.saveState();
12436 beforeExpand : function(animate){
12438 this.afterSlideIn();
12440 var c = this.getCollapsedEl();
12442 if(this.position == 'east' || this.position == 'west'){
12443 this.panel.setSize(undefined, c.getHeight());
12445 this.panel.setSize(c.getWidth(), undefined);
12448 c.dom.style.visibility = 'hidden';
12449 this.panel.el.setStyle('z-index', this.floatingZIndex);
12453 onExpand : function(){
12454 this.isCollapsed = false;
12456 this.splitEl.show();
12458 this.layout.layout();
12459 this.panel.el.setStyle('z-index', this.originalZIndex);
12460 this.state.collapsed = false;
12461 this.panel.saveState();
12465 collapseClick : function(e){
12467 e.stopPropagation();
12470 e.stopPropagation();
12476 onHide : function(){
12477 if(this.isCollapsed){
12478 this.getCollapsedEl().hide();
12479 }else if(this.splitEl){
12480 this.splitEl.hide();
12485 onShow : function(){
12486 if(this.isCollapsed){
12487 this.getCollapsedEl().show();
12488 }else if(this.splitEl){
12489 this.splitEl.show();
12494 isVisible : function(){
12495 return !this.panel.hidden;
12499 getMargins : function(){
12500 return this.isCollapsed && this.cmargins ? this.cmargins : this.margins;
12504 getSize : function(){
12505 return this.isCollapsed ? this.getCollapsedEl().getSize() : this.panel.getSize();
12509 setPanel : function(panel){
12510 this.panel = panel;
12514 getMinWidth: function(){
12515 return this.minWidth;
12519 getMinHeight: function(){
12520 return this.minHeight;
12524 applyLayoutCollapsed : function(box){
12525 var ce = this.getCollapsedEl();
12526 ce.setLeftTop(box.x, box.y);
12527 ce.setSize(box.width, box.height);
12531 applyLayout : function(box){
12532 if(this.isCollapsed){
12533 this.applyLayoutCollapsed(box);
12535 this.panel.setPosition(box.x, box.y);
12536 this.panel.setSize(box.width, box.height);
12541 beforeSlide: function(){
12542 this.panel.beforeEffect();
12546 afterSlide : function(){
12547 this.panel.afterEffect();
12551 initAutoHide : function(){
12552 if(this.autoHide !== false){
12553 if(!this.autoHideHd){
12554 var st = new Ext.util.DelayedTask(this.slideIn, this);
12555 this.autoHideHd = {
12556 "mouseout": function(e){
12557 if(!e.within(this.el, true)){
12561 "mouseover" : function(e){
12567 this.el.on(this.autoHideHd);
12568 this.collapsedEl.on(this.autoHideHd);
12573 clearAutoHide : function(){
12574 if(this.autoHide !== false){
12575 this.el.un("mouseout", this.autoHideHd.mouseout);
12576 this.el.un("mouseover", this.autoHideHd.mouseover);
12577 this.collapsedEl.un("mouseout", this.autoHideHd.mouseout);
12578 this.collapsedEl.un("mouseover", this.autoHideHd.mouseover);
12583 clearMonitor : function(){
12584 Ext.getDoc().un("click", this.slideInIf, this);
12588 slideOut : function(){
12589 if(this.isSlid || this.el.hasActiveFx()){
12592 this.isSlid = true;
12593 var ts = this.panel.tools;
12594 if(ts && ts.toggle){
12598 if(this.position == 'east' || this.position == 'west'){
12599 this.panel.setSize(undefined, this.collapsedEl.getHeight());
12601 this.panel.setSize(this.collapsedEl.getWidth(), undefined);
12603 this.restoreLT = [this.el.dom.style.left, this.el.dom.style.top];
12604 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
12605 this.el.setStyle("z-index", this.floatingZIndex+2);
12606 this.panel.el.replaceClass('x-panel-collapsed', 'x-panel-floating');
12607 if(this.animFloat !== false){
12608 this.beforeSlide();
12609 this.el.slideIn(this.getSlideAnchor(), {
12610 callback: function(){
12612 this.initAutoHide();
12613 Ext.getDoc().on("click", this.slideInIf, this);
12619 this.initAutoHide();
12620 Ext.getDoc().on("click", this.slideInIf, this);
12625 afterSlideIn : function(){
12626 this.clearAutoHide();
12627 this.isSlid = false;
12628 this.clearMonitor();
12629 this.el.setStyle("z-index", "");
12630 this.panel.el.replaceClass('x-panel-floating', 'x-panel-collapsed');
12631 this.el.dom.style.left = this.restoreLT[0];
12632 this.el.dom.style.top = this.restoreLT[1];
12634 var ts = this.panel.tools;
12635 if(ts && ts.toggle){
12641 slideIn : function(cb){
12642 if(!this.isSlid || this.el.hasActiveFx()){
12646 this.isSlid = false;
12647 if(this.animFloat !== false){
12648 this.beforeSlide();
12649 this.el.slideOut(this.getSlideAnchor(), {
12650 callback: function(){
12653 this.afterSlideIn();
12661 this.afterSlideIn();
12666 slideInIf : function(e){
12667 if(!e.within(this.el)){
12697 getAnchor : function(){
12698 return this.anchors[this.position];
12702 getCollapseAnchor : function(){
12703 return this.canchors[this.position];
12707 getSlideAnchor : function(){
12708 return this.sanchors[this.position];
12712 getAlignAdj : function(){
12713 var cm = this.cmargins;
12714 switch(this.position){
12731 getExpandAdj : function(){
12732 var c = this.collapsedEl, cm = this.cmargins;
12733 switch(this.position){
12735 return [-(cm.right+c.getWidth()+cm.left), 0];
12738 return [cm.right+c.getWidth()+cm.left, 0];
12741 return [0, -(cm.top+cm.bottom+c.getHeight())];
12744 return [0, cm.top+cm.bottom+c.getHeight()];
12749 destroy : function(){
12750 Ext.destroy(this.miniCollapsedEl, this.collapsedEl);
12755 Ext.layout.BorderLayout.SplitRegion = function(layout, config, pos){
12756 Ext.layout.BorderLayout.SplitRegion.superclass.constructor.call(this, layout, config, pos);
12758 this.applyLayout = this.applyFns[pos];
12761 Ext.extend(Ext.layout.BorderLayout.SplitRegion, Ext.layout.BorderLayout.Region, {
12764 splitTip : "Drag to resize.",
12766 collapsibleSplitTip : "Drag to resize. Double click to hide.",
12768 useSplitTips : false,
12773 orientation: Ext.SplitBar.VERTICAL,
12774 placement: Ext.SplitBar.TOP,
12775 maxFn : 'getVMaxSize',
12776 minProp: 'minHeight',
12777 maxProp: 'maxHeight'
12780 orientation: Ext.SplitBar.VERTICAL,
12781 placement: Ext.SplitBar.BOTTOM,
12782 maxFn : 'getVMaxSize',
12783 minProp: 'minHeight',
12784 maxProp: 'maxHeight'
12787 orientation: Ext.SplitBar.HORIZONTAL,
12788 placement: Ext.SplitBar.RIGHT,
12789 maxFn : 'getHMaxSize',
12790 minProp: 'minWidth',
12791 maxProp: 'maxWidth'
12794 orientation: Ext.SplitBar.HORIZONTAL,
12795 placement: Ext.SplitBar.LEFT,
12796 maxFn : 'getHMaxSize',
12797 minProp: 'minWidth',
12798 maxProp: 'maxWidth'
12804 west : function(box){
12805 if(this.isCollapsed){
12806 return this.applyLayoutCollapsed(box);
12808 var sd = this.splitEl.dom, s = sd.style;
12809 this.panel.setPosition(box.x, box.y);
12810 var sw = sd.offsetWidth;
12811 s.left = (box.x+box.width-sw)+'px';
12812 s.top = (box.y)+'px';
12813 s.height = Math.max(0, box.height)+'px';
12814 this.panel.setSize(box.width-sw, box.height);
12816 east : function(box){
12817 if(this.isCollapsed){
12818 return this.applyLayoutCollapsed(box);
12820 var sd = this.splitEl.dom, s = sd.style;
12821 var sw = sd.offsetWidth;
12822 this.panel.setPosition(box.x+sw, box.y);
12823 s.left = (box.x)+'px';
12824 s.top = (box.y)+'px';
12825 s.height = Math.max(0, box.height)+'px';
12826 this.panel.setSize(box.width-sw, box.height);
12828 north : function(box){
12829 if(this.isCollapsed){
12830 return this.applyLayoutCollapsed(box);
12832 var sd = this.splitEl.dom, s = sd.style;
12833 var sh = sd.offsetHeight;
12834 this.panel.setPosition(box.x, box.y);
12835 s.left = (box.x)+'px';
12836 s.top = (box.y+box.height-sh)+'px';
12837 s.width = Math.max(0, box.width)+'px';
12838 this.panel.setSize(box.width, box.height-sh);
12840 south : function(box){
12841 if(this.isCollapsed){
12842 return this.applyLayoutCollapsed(box);
12844 var sd = this.splitEl.dom, s = sd.style;
12845 var sh = sd.offsetHeight;
12846 this.panel.setPosition(box.x, box.y+sh);
12847 s.left = (box.x)+'px';
12848 s.top = (box.y)+'px';
12849 s.width = Math.max(0, box.width)+'px';
12850 this.panel.setSize(box.width, box.height-sh);
12855 render : function(ct, p){
12856 Ext.layout.BorderLayout.SplitRegion.superclass.render.call(this, ct, p);
12858 var ps = this.position;
12860 this.splitEl = ct.createChild({
12861 cls: "x-layout-split x-layout-split-"+ps, html: " ",
12862 id: this.panel.id + '-xsplit'
12865 if(this.collapseMode == 'mini'){
12866 this.miniSplitEl = this.splitEl.createChild({
12867 cls: "x-layout-mini x-layout-mini-"+ps, html: " "
12869 this.miniSplitEl.addClassOnOver('x-layout-mini-over');
12870 this.miniSplitEl.on('click', this.onCollapseClick, this, {stopEvent:true});
12873 var s = this.splitSettings[ps];
12875 this.split = new Ext.SplitBar(this.splitEl.dom, p.el, s.orientation);
12876 this.split.tickSize = this.tickSize;
12877 this.split.placement = s.placement;
12878 this.split.getMaximumSize = this[s.maxFn].createDelegate(this);
12879 this.split.minSize = this.minSize || this[s.minProp];
12880 this.split.on("beforeapply", this.onSplitMove, this);
12881 this.split.useShim = this.useShim === true;
12882 this.maxSize = this.maxSize || this[s.maxProp];
12885 this.splitEl.hide();
12888 if(this.useSplitTips){
12889 this.splitEl.dom.title = this.collapsible ? this.collapsibleSplitTip : this.splitTip;
12891 if(this.collapsible){
12892 this.splitEl.on("dblclick", this.onCollapseClick, this);
12897 getSize : function(){
12898 if(this.isCollapsed){
12899 return this.collapsedEl.getSize();
12901 var s = this.panel.getSize();
12902 if(this.position == 'north' || this.position == 'south'){
12903 s.height += this.splitEl.dom.offsetHeight;
12905 s.width += this.splitEl.dom.offsetWidth;
12911 getHMaxSize : function(){
12912 var cmax = this.maxSize || 10000;
12913 var center = this.layout.center;
12914 return Math.min(cmax, (this.el.getWidth()+center.el.getWidth())-center.getMinWidth());
12918 getVMaxSize : function(){
12919 var cmax = this.maxSize || 10000;
12920 var center = this.layout.center;
12921 return Math.min(cmax, (this.el.getHeight()+center.el.getHeight())-center.getMinHeight());
12925 onSplitMove : function(split, newSize){
12926 var s = this.panel.getSize();
12927 this.lastSplitSize = newSize;
12928 if(this.position == 'north' || this.position == 'south'){
12929 this.panel.setSize(s.width, newSize);
12930 this.state.height = newSize;
12932 this.panel.setSize(newSize, s.height);
12933 this.state.width = newSize;
12935 this.layout.layout();
12936 this.panel.saveState();
12941 getSplitBar : function(){
12946 destroy : function() {
12947 Ext.destroy(this.miniSplitEl, this.split, this.splitEl);
12948 Ext.layout.BorderLayout.SplitRegion.superclass.destroy.call(this);
12952 Ext.Container.LAYOUTS['border'] = Ext.layout.BorderLayout;
12953 Ext.layout.FormLayout = Ext.extend(Ext.layout.AnchorLayout, {
12956 labelSeparator : ':',
12961 trackLabels: false,
12964 onRemove: function(c){
12965 Ext.layout.FormLayout.superclass.onRemove.call(this, c);
12966 if(this.trackLabels){
12967 c.un('show', this.onFieldShow, this);
12968 c.un('hide', this.onFieldHide, this);
12971 var el = c.getPositionEl(),
12972 ct = c.getItemCt && c.getItemCt();
12973 if(c.rendered && ct){
12974 if (el && el.dom) {
12975 el.insertAfter(ct);
12978 Ext.destroyMembers(c, 'label', 'itemCt');
12979 if(c.customItemCt){
12980 Ext.destroyMembers(c, 'getItemCt', 'customItemCt');
12986 setContainer : function(ct){
12987 Ext.layout.FormLayout.superclass.setContainer.call(this, ct);
12989 ct.addClass('x-form-label-'+ct.labelAlign);
12994 labelStyle: 'display:none',
12995 elementStyle: 'padding-left:0;',
12999 this.labelSeparator = ct.labelSeparator || this.labelSeparator;
13000 ct.labelWidth = ct.labelWidth || 100;
13001 if(Ext.isNumber(ct.labelWidth)){
13002 var pad = Ext.isNumber(ct.labelPad) ? ct.labelPad : 5;
13004 labelAdjust: ct.labelWidth + pad,
13005 labelStyle: 'width:' + ct.labelWidth + 'px;',
13006 elementStyle: 'padding-left:' + (ct.labelWidth + pad) + 'px'
13009 if(ct.labelAlign == 'top'){
13011 labelStyle: 'width:auto;',
13013 elementStyle: 'padding-left:0;'
13020 isHide: function(c){
13021 return c.hideLabel || this.container.hideLabels;
13024 onFieldShow: function(c){
13025 c.getItemCt().removeClass('x-hide-' + c.hideMode);
13028 onFieldHide: function(c){
13029 c.getItemCt().addClass('x-hide-' + c.hideMode);
13033 getLabelStyle: function(s){
13034 var ls = '', items = [this.labelStyle, s];
13035 for (var i = 0, len = items.length; i < len; ++i){
13038 if (ls.substr(-1, 1) != ';'){
13049 renderItem : function(c, position, target){
13050 if(c && (c.isFormField || c.fieldLabel) && c.inputType != 'hidden'){
13051 var args = this.getTemplateArgs(c);
13052 if(Ext.isNumber(position)){
13053 position = target.dom.childNodes[position] || null;
13056 c.itemCt = this.fieldTpl.insertBefore(position, args, true);
13058 c.itemCt = this.fieldTpl.append(target, args, true);
13064 getItemCt: function(){
13070 c.label = c.getItemCt().child('label.x-form-item-label');
13072 c.render('x-form-el-' + c.id);
13073 }else if(!this.isValidParent(c, target)){
13074 Ext.fly('x-form-el-' + c.id).appendChild(c.getPositionEl());
13076 if(this.trackLabels){
13078 this.onFieldHide(c);
13082 show: this.onFieldShow,
13083 hide: this.onFieldHide
13086 this.configureItem(c);
13088 Ext.layout.FormLayout.superclass.renderItem.apply(this, arguments);
13093 getTemplateArgs: function(field) {
13094 var noLabelSep = !field.fieldLabel || field.hideLabel;
13097 label: field.fieldLabel,
13098 labelStyle: this.getLabelStyle(field.labelStyle),
13099 elementStyle: this.elementStyle||'',
13100 labelSeparator: noLabelSep ? '' : (Ext.isDefined(field.labelSeparator) ? field.labelSeparator : this.labelSeparator),
13101 itemCls: (field.itemCls||this.container.itemCls||'') + (field.hideLabel ? ' x-hide-label' : ''),
13102 clearCls: field.clearCls || 'x-form-clear-left'
13107 adjustWidthAnchor: function(value, c){
13108 if(c.label && !this.isHide(c) && (this.container.labelAlign != 'top')){
13109 var adjust = Ext.isIE6 || (Ext.isIE && !Ext.isStrict);
13110 return value - this.labelAdjust + (adjust ? -3 : 0);
13115 adjustHeightAnchor : function(value, c){
13116 if(c.label && !this.isHide(c) && (this.container.labelAlign == 'top')){
13117 return value - c.label.getHeight();
13123 isValidParent : function(c, target){
13124 return target && this.container.getEl().contains(c.getPositionEl());
13130 Ext.Container.LAYOUTS['form'] = Ext.layout.FormLayout;
13132 Ext.layout.AccordionLayout = Ext.extend(Ext.layout.FitLayout, {
13138 titleCollapse : true,
13140 hideCollapseTool : false,
13142 collapseFirst : false,
13148 activeOnTop : false,
13150 renderItem : function(c){
13151 if(this.animate === false){
13152 c.animCollapse = false;
13154 c.collapsible = true;
13155 if(this.autoWidth){
13156 c.autoWidth = true;
13158 if(this.titleCollapse){
13159 c.titleCollapse = true;
13161 if(this.hideCollapseTool){
13162 c.hideCollapseTool = true;
13164 if(this.collapseFirst !== undefined){
13165 c.collapseFirst = this.collapseFirst;
13167 if(!this.activeItem && !c.collapsed){
13168 this.setActiveItem(c, true);
13169 }else if(this.activeItem && this.activeItem != c){
13170 c.collapsed = true;
13172 Ext.layout.AccordionLayout.superclass.renderItem.apply(this, arguments);
13173 c.header.addClass('x-accordion-hd');
13174 c.on('beforeexpand', this.beforeExpand, this);
13177 onRemove: function(c){
13178 Ext.layout.AccordionLayout.superclass.onRemove.call(this, c);
13180 c.header.removeClass('x-accordion-hd');
13182 c.un('beforeexpand', this.beforeExpand, this);
13186 beforeExpand : function(p, anim){
13187 var ai = this.activeItem;
13190 delete this.activeItem;
13191 if (!ai.collapsed){
13192 ai.collapse({callback:function(){
13193 p.expand(anim || true);
13198 ai.collapse(this.animate);
13202 if(this.activeOnTop){
13203 p.el.dom.parentNode.insertBefore(p.el.dom, p.el.dom.parentNode.firstChild);
13209 setItemSize : function(item, size){
13210 if(this.fill && item){
13212 this.container.items.each(function(p){
13214 hh += p.header.getHeight();
13218 item.setSize(size);
13223 setActiveItem : function(item){
13224 this.setActive(item, true);
13228 setActive : function(item, expand){
13229 var ai = this.activeItem;
13230 item = this.container.getComponent(item);
13232 if(item.rendered && item.collapsed && expand){
13236 ai.fireEvent('deactivate', ai);
13238 this.activeItem = item;
13239 item.fireEvent('activate', item);
13244 Ext.Container.LAYOUTS.accordion = Ext.layout.AccordionLayout;
13247 Ext.layout.Accordion = Ext.layout.AccordionLayout;
13248 Ext.layout.TableLayout = Ext.extend(Ext.layout.ContainerLayout, {
13252 monitorResize:false,
13254 targetCls: 'x-table-layout-ct',
13260 setContainer : function(ct){
13261 Ext.layout.TableLayout.superclass.setContainer.call(this, ct);
13263 this.currentRow = 0;
13264 this.currentColumn = 0;
13269 onLayout : function(ct, target){
13270 var cs = ct.items.items, len = cs.length, c, i;
13273 this.table = target.createChild(
13274 Ext.apply({tag:'table', cls:'x-table-layout', cellspacing: 0, cn: {tag: 'tbody'}}, this.tableAttrs), null, true);
13276 this.renderAll(ct, target);
13280 getRow : function(index){
13281 var row = this.table.tBodies[0].childNodes[index];
13283 row = document.createElement('tr');
13284 this.table.tBodies[0].appendChild(row);
13290 getNextCell : function(c){
13291 var cell = this.getNextNonSpan(this.currentColumn, this.currentRow);
13292 var curCol = this.currentColumn = cell[0], curRow = this.currentRow = cell[1];
13293 for(var rowIndex = curRow; rowIndex < curRow + (c.rowspan || 1); rowIndex++){
13294 if(!this.cells[rowIndex]){
13295 this.cells[rowIndex] = [];
13297 for(var colIndex = curCol; colIndex < curCol + (c.colspan || 1); colIndex++){
13298 this.cells[rowIndex][colIndex] = true;
13301 var td = document.createElement('td');
13305 var cls = 'x-table-layout-cell';
13307 cls += ' ' + c.cellCls;
13309 td.className = cls;
13311 td.colSpan = c.colspan;
13314 td.rowSpan = c.rowspan;
13316 this.getRow(curRow).appendChild(td);
13321 getNextNonSpan: function(colIndex, rowIndex){
13322 var cols = this.columns;
13323 while((cols && colIndex >= cols) || (this.cells[rowIndex] && this.cells[rowIndex][colIndex])) {
13324 if(cols && colIndex >= cols){
13331 return [colIndex, rowIndex];
13335 renderItem : function(c, position, target){
13336 if(c && !c.rendered){
13337 c.render(this.getNextCell(c));
13338 this.configureItem(c, position);
13339 }else if(c && !this.isValidParent(c, target)){
13340 var container = this.getNextCell(c);
13341 container.insertBefore(c.getPositionEl().dom, null);
13342 c.container = Ext.get(container);
13343 this.configureItem(c, position);
13348 isValidParent : function(c, target){
13349 return c.getPositionEl().up('table', 5).dom.parentNode === (target.dom || target);
13355 Ext.Container.LAYOUTS['table'] = Ext.layout.TableLayout;
13356 Ext.layout.AbsoluteLayout = Ext.extend(Ext.layout.AnchorLayout, {
13358 extraCls: 'x-abs-layout-item',
13360 onLayout : function(ct, target){
13362 this.paddingLeft = target.getPadding('l');
13363 this.paddingTop = target.getPadding('t');
13365 Ext.layout.AbsoluteLayout.superclass.onLayout.call(this, ct, target);
13369 adjustWidthAnchor : function(value, comp){
13370 return value ? value - comp.getPosition(true)[0] + this.paddingLeft : value;
13374 adjustHeightAnchor : function(value, comp){
13375 return value ? value - comp.getPosition(true)[1] + this.paddingTop : value;
13379 Ext.Container.LAYOUTS['absolute'] = Ext.layout.AbsoluteLayout;
13381 Ext.layout.BoxLayout = Ext.extend(Ext.layout.ContainerLayout, {
13383 defaultMargins : {left:0,top:0,right:0,bottom:0},
13390 monitorResize : true,
13392 extraCls : 'x-box-item',
13393 targetCls : 'x-box-layout-ct',
13394 innerCls : 'x-box-inner',
13396 constructor : function(config){
13397 Ext.layout.BoxLayout.superclass.constructor.call(this, config);
13398 if(Ext.isString(this.defaultMargins)){
13399 this.defaultMargins = this.parseMargins(this.defaultMargins);
13404 isValidParent : function(c, target){
13405 return c.getPositionEl().dom.parentNode == this.innerCt.dom;
13409 onLayout : function(ct, target){
13410 var cs = ct.items.items, len = cs.length, c, i, last = len-1, cm;
13415 this.innerCt = target.createChild({cls:this.innerCls});
13416 this.padding = this.parseMargins(this.padding);
13418 this.renderAll(ct, this.innerCt);
13422 renderItem : function(c){
13423 if(Ext.isString(c.margins)){
13424 c.margins = this.parseMargins(c.margins);
13425 }else if(!c.margins){
13426 c.margins = this.defaultMargins;
13428 Ext.layout.BoxLayout.superclass.renderItem.apply(this, arguments);
13432 getTargetSize : function(target){
13433 return (Ext.isIE6 && Ext.isStrict && target.dom == document.body) ? target.getStyleSize() : target.getViewSize(true);
13436 getItems: function(ct){
13438 ct.items.each(function(c){
13448 Ext.layout.VBoxLayout = Ext.extend(Ext.layout.BoxLayout, {
13455 onLayout : function(ct, target){
13456 Ext.layout.VBoxLayout.superclass.onLayout.call(this, ct, target);
13458 var cs = this.getItems(ct), cm, ch, margin, cl, diff, aw,
13459 size = target.getViewSize(true),
13461 h = size.height - this.scrollOffset,
13462 l = this.padding.left, t = this.padding.top,
13463 isStart = this.pack == 'start',
13464 stretchWidth = w - (this.padding.left + this.padding.right),
13477 for (i = 0 ; i < csLen; i++) {
13480 margin = cm.top + cm.bottom;
13481 maxWidth = Math.max(maxWidth, c.getWidth() + cm.left + cm.right);
13484 var innerCtWidth = maxWidth + this.padding.left + this.padding.right;
13485 switch(this.align){
13487 this.innerCt.setSize(w, h);
13491 this.innerCt.setSize(innerCtWidth, h);
13494 this.innerCt.setSize(w = Math.max(w, innerCtWidth), h);
13498 var availableWidth = Math.max(0, w - this.padding.left - this.padding.right);
13500 for (i = 0 ; i < csLen; i++) {
13503 if(this.align == 'stretch'){
13504 c.setWidth((stretchWidth - (cm.left + cm.right)).constrain(
13505 c.minWidth || 0, c.maxWidth || 1000000));
13506 }else if(this.align == 'stretchmax'){
13507 c.setWidth((maxWidth - (cm.left + cm.right)).constrain(
13508 c.minWidth || 0, c.maxWidth || 1000000));
13509 }else if(isStart && c.flex){
13516 for (i = 0 ; i < csLen; i++) {
13519 totalFlex += c.flex || 0;
13520 ch = c.getHeight();
13521 margin = cm.top + cm.bottom;
13522 extraHeight += ch + margin;
13523 flexHeight += margin + (c.flex ? 0 : ch);
13525 extraHeight = h - extraHeight - this.padding.top - this.padding.bottom;
13527 var availHeight = Math.max(0, h - this.padding.top - this.padding.bottom - flexHeight),
13528 leftOver = availHeight;
13529 for (i = 0 ; i < csLen; i++) {
13531 if(isStart && c.flex){
13532 ch = Math.floor(availHeight * (c.flex / totalFlex));
13537 if(this.pack == 'center'){
13538 t += extraHeight ? extraHeight / 2 : 0;
13539 }else if(this.pack == 'end'){
13544 for (i = 0 ; i < csLen; i++) {
13548 aw = availableWidth;
13552 if(this.align == 'center'){
13553 if((diff = availableWidth - (c.getWidth() + cm.left + cm.right)) > 0){
13559 c.setPosition(cl, t);
13560 if(isStart && c.flex){
13561 ch = Math.max(0, heights[idx++] + (leftOver-- > 0 ? 1 : 0));
13564 ch = c.getHeight();
13566 t += ch + cm.bottom;
13571 Ext.Container.LAYOUTS.vbox = Ext.layout.VBoxLayout;
13574 Ext.layout.HBoxLayout = Ext.extend(Ext.layout.BoxLayout, {
13581 onLayout : function(ct, target){
13582 Ext.layout.HBoxLayout.superclass.onLayout.call(this, ct, target);
13584 var cs = this.getItems(ct), cm, cw, margin, ch, diff,
13585 size = target.getViewSize(true),
13586 w = size.width - this.scrollOffset,
13588 l = this.padding.left, t = this.padding.top,
13589 isStart = this.pack == 'start',
13590 isRestore = ['stretch', 'stretchmax'].indexOf(this.align) == -1,
13591 stretchHeight = h - (this.padding.top + this.padding.bottom),
13598 Ext.each(cs, function(c){
13600 totalFlex += c.flex || 0;
13602 margin = cm.left + cm.right;
13603 extraWidth += cw + margin;
13604 flexWidth += margin + (c.flex ? 0 : cw);
13605 maxHeight = Math.max(maxHeight, c.getHeight() + cm.top + cm.bottom);
13607 extraWidth = w - extraWidth - this.padding.left - this.padding.right;
13609 var innerCtHeight = maxHeight + this.padding.top + this.padding.bottom;
13610 switch(this.align){
13612 this.innerCt.setSize(w, h);
13616 this.innerCt.setSize(w, innerCtHeight);
13619 this.innerCt.setSize(w, h = Math.max(h, innerCtHeight));
13624 var availWidth = Math.max(0, w - this.padding.left - this.padding.right - flexWidth),
13625 leftOver = availWidth,
13629 availableHeight = Math.max(0, h - this.padding.top - this.padding.bottom);
13632 Ext.each(cs, function(c){
13633 if(isStart && c.flex){
13634 cw = Math.floor(availWidth * (c.flex / totalFlex));
13640 if(this.pack == 'center'){
13641 l += extraWidth ? extraWidth / 2 : 0;
13642 }else if(this.pack == 'end'){
13645 Ext.each(cs, function(c){
13648 c.setPosition(l, t + cm.top);
13649 if(isStart && c.flex){
13650 cw = Math.max(0, widths[idx++] + (leftOver-- > 0 ? 1 : 0));
13652 restore.push(c.getHeight());
13654 c.setSize(cw, availableHeight);
13658 l += cw + cm.right;
13662 Ext.each(cs, function(c){
13664 ch = c.getHeight();
13665 if(isStart && c.flex){
13666 ch = restore[idx++];
13668 if(this.align == 'stretch'){
13669 c.setHeight((stretchHeight - (cm.top + cm.bottom)).constrain(
13670 c.minHeight || 0, c.maxHeight || 1000000));
13671 }else if(this.align == 'stretchmax'){
13672 c.setHeight((maxHeight - (cm.top + cm.bottom)).constrain(
13673 c.minHeight || 0, c.maxHeight || 1000000));
13675 if(this.align == 'middle'){
13676 diff = availableHeight - (ch + cm.top + cm.bottom);
13677 ch = t + cm.top + (diff/2);
13679 c.setPosition(c.x, ch);
13682 if(isStart && c.flex){
13690 Ext.Container.LAYOUTS.hbox = Ext.layout.HBoxLayout;
13692 Ext.Viewport = Ext.extend(Ext.Container, {
13706 initComponent : function() {
13707 Ext.Viewport.superclass.initComponent.call(this);
13708 document.getElementsByTagName('html')[0].className += ' x-viewport';
13709 this.el = Ext.getBody();
13710 this.el.setHeight = Ext.emptyFn;
13711 this.el.setWidth = Ext.emptyFn;
13712 this.el.setSize = Ext.emptyFn;
13713 this.el.dom.scroll = 'no';
13714 this.allowDomMove = false;
13715 this.autoWidth = true;
13716 this.autoHeight = true;
13717 Ext.EventManager.onWindowResize(this.fireResize, this);
13718 this.renderTo = this.el;
13721 fireResize : function(w, h){
13722 this.onResize(w, h, w, h);
13725 Ext.reg('viewport', Ext.Viewport);
13727 Ext.Panel = Ext.extend(Ext.Container, {
13772 baseCls : 'x-panel',
13774 collapsedCls : 'x-panel-collapsed',
13776 maskDisabled : true,
13778 animCollapse : Ext.enableFx,
13780 headerAsText : true,
13782 buttonAlign : 'right',
13786 collapseFirst : true,
13788 minButtonWidth : 75,
13793 preventBodyReset : false,
13796 padding: undefined,
13799 resizeEvent: 'bodyresize',
13804 toolTarget : 'header',
13805 collapseEl : 'bwrap',
13807 disabledClass : '',
13810 deferHeight : true,
13816 collapseDefaults : {
13821 initComponent : function(){
13822 Ext.Panel.superclass.initComponent.call(this);
13850 this.baseCls = 'x-plain';
13854 this.toolbars = [];
13857 this.elements += ',tbar';
13858 this.topToolbar = this.createToolbar(this.tbar);
13863 this.elements += ',bbar';
13864 this.bottomToolbar = this.createToolbar(this.bbar);
13868 if(this.header === true){
13869 this.elements += ',header';
13870 delete this.header;
13871 }else if(this.headerCfg || (this.title && this.header !== false)){
13872 this.elements += ',header';
13875 if(this.footerCfg || this.footer === true){
13876 this.elements += ',footer';
13877 delete this.footer;
13881 this.fbar = this.buttons;
13882 delete this.buttons;
13885 this.createFbar(this.fbar);
13888 this.on('render', this.doAutoLoad, this, {delay:10});
13893 createFbar : function(fbar){
13894 var min = this.minButtonWidth;
13895 this.elements += ',footer';
13896 this.fbar = this.createToolbar(fbar, {
13897 buttonAlign: this.buttonAlign,
13898 toolbarCls: 'x-panel-fbar',
13899 enableOverflow: false,
13900 defaults: function(c){
13902 minWidth: c.minWidth || min
13906 //@compat addButton and buttons could possibly be removed
13911 this.fbar.items.each(function(c){
13912 c.minWidth = c.minWidth || this.minButtonWidth;
13914 this.buttons = this.fbar.items.items;
13918 createToolbar: function(tb, options){
13921 if(Ext.isArray(tb)){
13926 result = tb.events ? Ext.apply(tb, options) : this.createComponent(Ext.apply({}, tb, options), 'toolbar');
13927 result.ownerCt = this;
13928 result.bufferResize = false;
13929 this.toolbars.push(result);
13934 createElement : function(name, pnode){
13936 pnode.appendChild(this[name].dom);
13940 if(name === 'bwrap' || this.elements.indexOf(name) != -1){
13941 if(this[name+'Cfg']){
13942 this[name] = Ext.fly(pnode).createChild(this[name+'Cfg']);
13944 var el = document.createElement('div');
13945 el.className = this[name+'Cls'];
13946 this[name] = Ext.get(pnode.appendChild(el));
13948 if(this[name+'CssClass']){
13949 this[name].addClass(this[name+'CssClass']);
13951 if(this[name+'Style']){
13952 this[name].applyStyles(this[name+'Style']);
13958 onRender : function(ct, position){
13959 Ext.Panel.superclass.onRender.call(this, ct, position);
13960 this.createClasses();
13968 if(this.collapsible && !this.hideCollapseTool){
13969 this.tools = this.tools ? this.tools.slice(0) : [];
13970 this.tools[this.collapseFirst?'unshift':'push']({
13972 handler : this.toggleCollapse,
13979 this.elements += (this.header !== false) ? ',header' : '';
13983 el.addClass(this.baseCls);
13985 this.header = el.down('.'+this.headerCls);
13986 this.bwrap = el.down('.'+this.bwrapCls);
13987 var cp = this.bwrap ? this.bwrap : el;
13988 this.tbar = cp.down('.'+this.tbarCls);
13989 this.body = cp.down('.'+this.bodyCls);
13990 this.bbar = cp.down('.'+this.bbarCls);
13991 this.footer = cp.down('.'+this.footerCls);
13992 this.fromMarkup = true;
13994 if (this.preventBodyReset === true) {
13995 el.addClass('x-panel-reset');
13998 el.addClass(this.cls);
14002 this.elements += ',footer';
14009 el.insertHtml('afterBegin', String.format(Ext.Element.boxMarkup, this.baseCls));
14011 this.createElement('header', d.firstChild.firstChild.firstChild);
14012 this.createElement('bwrap', d);
14015 bw = this.bwrap.dom;
14016 var ml = d.childNodes[1], bl = d.childNodes[2];
14017 bw.appendChild(ml);
14018 bw.appendChild(bl);
14020 var mc = bw.firstChild.firstChild.firstChild;
14021 this.createElement('tbar', mc);
14022 this.createElement('body', mc);
14023 this.createElement('bbar', mc);
14024 this.createElement('footer', bw.lastChild.firstChild.firstChild);
14027 this.bwrap.dom.lastChild.className += ' x-panel-nofooter';
14030 this.ft = Ext.get(this.bwrap.dom.lastChild);
14031 this.mc = Ext.get(mc);
14033 this.createElement('header', d);
14034 this.createElement('bwrap', d);
14037 bw = this.bwrap.dom;
14038 this.createElement('tbar', bw);
14039 this.createElement('body', bw);
14040 this.createElement('bbar', bw);
14041 this.createElement('footer', bw);
14044 this.body.addClass(this.bodyCls + '-noheader');
14046 this.tbar.addClass(this.tbarCls + '-noheader');
14051 if(Ext.isDefined(this.padding)){
14052 this.body.setStyle('padding', this.body.addUnits(this.padding));
14055 if(this.border === false){
14056 this.el.addClass(this.baseCls + '-noborder');
14057 this.body.addClass(this.bodyCls + '-noborder');
14059 this.header.addClass(this.headerCls + '-noborder');
14062 this.footer.addClass(this.footerCls + '-noborder');
14065 this.tbar.addClass(this.tbarCls + '-noborder');
14068 this.bbar.addClass(this.bbarCls + '-noborder');
14072 if(this.bodyBorder === false){
14073 this.body.addClass(this.bodyCls + '-noborder');
14076 this.bwrap.enableDisplayMode('block');
14079 this.header.unselectable();
14082 if(this.headerAsText){
14083 this.header.dom.innerHTML =
14084 '<span class="' + this.headerTextCls + '">'+this.header.dom.innerHTML+'</span>';
14087 this.setIconClass(this.iconCls);
14093 this.makeFloating(this.floating);
14096 if(this.collapsible && this.titleCollapse && this.header){
14097 this.mon(this.header, 'click', this.toggleCollapse, this);
14098 this.header.setStyle('cursor', 'pointer');
14101 this.addTool.apply(this, ts);
14104 this.footer.addClass('x-panel-btns');
14105 this.fbar.render(this.footer);
14106 this.footer.createChild({cls:'x-clear'});
14109 if(this.tbar && this.topToolbar){
14110 this.topToolbar.render(this.tbar);
14112 if(this.bbar && this.bottomToolbar){
14113 this.bottomToolbar.render(this.bbar);
14119 setIconClass : function(cls){
14120 var old = this.iconCls;
14121 this.iconCls = cls;
14122 if(this.rendered && this.header){
14124 this.header.addClass('x-panel-icon');
14125 this.header.replaceClass(old, this.iconCls);
14127 var hd = this.header,
14128 img = hd.child('img.x-panel-inline-icon');
14130 Ext.fly(img).replaceClass(old, this.iconCls);
14132 Ext.DomHelper.insertBefore(hd.dom.firstChild, {
14133 tag:'img', src: Ext.BLANK_IMAGE_URL, cls:'x-panel-inline-icon '+this.iconCls
14138 this.fireEvent('iconchange', this, cls, old);
14142 makeFloating : function(cfg){
14143 this.floating = true;
14144 this.el = new Ext.Layer(Ext.apply({}, cfg, {
14145 shadow: Ext.isDefined(this.shadow) ? this.shadow : 'sides',
14146 shadowOffset: this.shadowOffset,
14148 shim: this.shim === false ? false : undefined
14153 getTopToolbar : function(){
14154 return this.topToolbar;
14158 getBottomToolbar : function(){
14159 return this.bottomToolbar;
14163 addButton : function(config, handler, scope){
14165 this.createFbar([]);
14168 if(Ext.isString(config)){
14169 config = {text: config};
14171 config = Ext.apply({
14176 return this.fbar.add(config);
14180 addTool : function(){
14181 if(!this.rendered){
14185 Ext.each(arguments, function(arg){
14186 this.tools.push(arg)
14191 if(!this[this.toolTarget]){
14194 if(!this.toolTemplate){
14196 var tt = new Ext.Template(
14197 '<div class="x-tool x-tool-{id}"> </div>'
14199 tt.disableFormats = true;
14201 Ext.Panel.prototype.toolTemplate = tt;
14203 for(var i = 0, a = arguments, len = a.length; i < len; i++) {
14205 if(!this.tools[tc.id]){
14206 var overCls = 'x-tool-'+tc.id+'-over';
14207 var t = this.toolTemplate.insertFirst((tc.align !== 'left') ? this[this.toolTarget] : this[this.toolTarget].child('span'), tc, true);
14208 this.tools[tc.id] = t;
14209 t.enableDisplayMode('block');
14210 this.mon(t, 'click', this.createToolHandler(t, tc, overCls, this));
14212 this.mon(t, tc.on);
14218 if(Ext.isObject(tc.qtip)){
14219 Ext.QuickTips.register(Ext.apply({
14223 t.dom.qtip = tc.qtip;
14226 t.addClassOnOver(overCls);
14231 onLayout : function(shallow, force){
14232 if(this.hasLayout && this.toolbars.length > 0){
14233 Ext.each(this.toolbars, function(tb){
14234 tb.doLayout(undefined, force);
14240 syncHeight : function(){
14241 var h = this.toolbarHeight,
14243 lsh = this.lastSize.height,
14246 if(this.autoHeight || !Ext.isDefined(lsh) || lsh == 'auto'){
14251 if(h != this.getToolbarHeight()){
14252 h = Math.max(0, this.adjustBodyHeight(lsh - this.getFrameHeight()));
14255 this.toolbarHeight = this.getToolbarHeight();
14256 this.onBodyResize(sz.width, sz.height);
14261 onShow : function(){
14263 return this.el.show();
14265 Ext.Panel.superclass.onShow.call(this);
14269 onHide : function(){
14271 return this.el.hide();
14273 Ext.Panel.superclass.onHide.call(this);
14277 createToolHandler : function(t, tc, overCls, panel){
14278 return function(e){
14279 t.removeClass(overCls);
14280 if(tc.stopEvent !== false){
14284 tc.handler.call(tc.scope || t, e, t, panel, tc);
14290 afterRender : function(){
14291 if(this.floating && !this.hidden){
14295 this.setTitle(this.title);
14297 if(this.collapsed){
14298 this.collapsed = false;
14299 this.collapse(false);
14301 Ext.Panel.superclass.afterRender.call(this);
14306 getKeyMap : function(){
14308 this.keyMap = new Ext.KeyMap(this.el, this.keys);
14310 return this.keyMap;
14314 initEvents : function(){
14318 if(this.draggable){
14319 this.initDraggable();
14321 if(this.toolbars.length > 0){
14322 Ext.each(this.toolbars, function(tb){
14326 afterlayout: this.syncHeight,
14327 remove: this.syncHeight
14338 initDraggable : function(){
14340 this.dd = new Ext.Panel.DD(this, Ext.isBoolean(this.draggable) ? null : this.draggable);
14344 beforeEffect : function(anim){
14346 this.el.beforeAction();
14348 if(anim !== false){
14349 this.el.addClass('x-panel-animated');
14354 afterEffect : function(anim){
14356 if(anim !== false){
14357 this.el.removeClass('x-panel-animated');
14362 createEffect : function(a, cb, scope){
14370 }else if(!a.callback){
14373 o.callback = function(){
14375 Ext.callback(a.callback, a.scope);
14378 return Ext.applyIf(o, a);
14382 collapse : function(animate){
14383 if(this.collapsed || this.el.hasFxBlock() || this.fireEvent('beforecollapse', this, animate) === false){
14386 var doAnim = animate === true || (animate !== false && this.animCollapse);
14387 this.beforeEffect(doAnim);
14388 this.onCollapse(doAnim, animate);
14393 onCollapse : function(doAnim, animArg){
14395 this[this.collapseEl].slideOut(this.slideAnchor,
14396 Ext.apply(this.createEffect(animArg||true, this.afterCollapse, this),
14397 this.collapseDefaults));
14399 this[this.collapseEl].hide();
14400 this.afterCollapse(false);
14405 afterCollapse : function(anim){
14406 this.collapsed = true;
14407 this.el.addClass(this.collapsedCls);
14408 this.afterEffect(anim);
14409 this.fireEvent('collapse', this);
14413 expand : function(animate){
14414 if(!this.collapsed || this.el.hasFxBlock() || this.fireEvent('beforeexpand', this, animate) === false){
14417 var doAnim = animate === true || (animate !== false && this.animCollapse);
14418 this.el.removeClass(this.collapsedCls);
14419 this.beforeEffect(doAnim);
14420 this.onExpand(doAnim, animate);
14425 onExpand : function(doAnim, animArg){
14427 this[this.collapseEl].slideIn(this.slideAnchor,
14428 Ext.apply(this.createEffect(animArg||true, this.afterExpand, this),
14429 this.expandDefaults));
14431 this[this.collapseEl].show();
14432 this.afterExpand(false);
14437 afterExpand : function(anim){
14438 this.collapsed = false;
14439 this.afterEffect(anim);
14440 if(Ext.isDefined(this.deferLayout)){
14441 this.doLayout(true);
14443 this.fireEvent('expand', this);
14447 toggleCollapse : function(animate){
14448 this[this.collapsed ? 'expand' : 'collapse'](animate);
14453 onDisable : function(){
14454 if(this.rendered && this.maskDisabled){
14457 Ext.Panel.superclass.onDisable.call(this);
14461 onEnable : function(){
14462 if(this.rendered && this.maskDisabled){
14465 Ext.Panel.superclass.onEnable.call(this);
14469 onResize : function(w, h){
14470 if(Ext.isDefined(w) || Ext.isDefined(h)){
14471 if(!this.collapsed){
14476 if(Ext.isNumber(w)){
14477 this.body.setWidth(w = this.adjustBodyWidth(w - this.getFrameWidth()));
14478 } else if (w == 'auto') {
14479 w = this.body.setWidth('auto').dom.offsetWidth;
14481 w = this.body.dom.offsetWidth;
14485 this.tbar.setWidth(w);
14486 if(this.topToolbar){
14487 this.topToolbar.setSize(w);
14491 this.bbar.setWidth(w);
14492 if(this.bottomToolbar){
14493 this.bottomToolbar.setSize(w);
14496 this.bbar.setStyle('position', 'static');
14497 this.bbar.setStyle('position', '');
14502 this.footer.setWidth(w);
14504 this.fbar.setSize(Ext.isIE ? (w - this.footer.getFrameWidth('lr')) : 'auto');
14509 if(Ext.isNumber(h)){
14510 h = Math.max(0, this.adjustBodyHeight(h - this.getFrameHeight()));
14511 this.body.setHeight(h);
14512 }else if(h == 'auto'){
14513 this.body.setHeight(h);
14516 if(this.disabled && this.el._mask){
14517 this.el._mask.setSize(this.el.dom.clientWidth, this.el.getHeight());
14520 this.queuedBodySize = {width: w, height: h};
14521 if(!this.queuedExpand && this.allowQueuedExpand !== false){
14522 this.queuedExpand = true;
14523 this.on('expand', function(){
14524 delete this.queuedExpand;
14525 this.onResize(this.queuedBodySize.width, this.queuedBodySize.height);
14526 }, this, {single:true});
14529 this.onBodyResize(w, h);
14532 Ext.Panel.superclass.onResize.call(this);
14536 onBodyResize: function(w, h){
14537 this.fireEvent('bodyresize', this, w, h);
14541 getToolbarHeight: function(){
14544 Ext.each(this.toolbars, function(tb){
14545 h += tb.getHeight();
14552 adjustBodyHeight : function(h){
14557 adjustBodyWidth : function(w){
14562 onPosition : function(){
14567 getFrameWidth : function(){
14568 var w = this.el.getFrameWidth('lr') + this.bwrap.getFrameWidth('lr');
14571 var l = this.bwrap.dom.firstChild;
14572 w += (Ext.fly(l).getFrameWidth('l') + Ext.fly(l.firstChild).getFrameWidth('r'));
14573 w += this.mc.getFrameWidth('lr');
14579 getFrameHeight : function(){
14580 var h = this.el.getFrameWidth('tb') + this.bwrap.getFrameWidth('tb');
14581 h += (this.tbar ? this.tbar.getHeight() : 0) +
14582 (this.bbar ? this.bbar.getHeight() : 0);
14585 h += this.el.dom.firstChild.offsetHeight + this.ft.dom.offsetHeight + this.mc.getFrameWidth('tb');
14587 h += (this.header ? this.header.getHeight() : 0) +
14588 (this.footer ? this.footer.getHeight() : 0);
14594 getInnerWidth : function(){
14595 return this.getSize().width - this.getFrameWidth();
14599 getInnerHeight : function(){
14600 return this.getSize().height - this.getFrameHeight();
14604 syncShadow : function(){
14606 this.el.sync(true);
14611 getLayoutTarget : function(){
14616 getContentTarget : function(){
14621 setTitle : function(title, iconCls){
14622 this.title = title;
14623 if(this.header && this.headerAsText){
14624 this.header.child('span').update(title);
14627 this.setIconClass(iconCls);
14629 this.fireEvent('titlechange', this, title);
14634 getUpdater : function(){
14635 return this.body.getUpdater();
14640 var um = this.body.getUpdater();
14641 um.update.apply(um, arguments);
14646 beforeDestroy : function(){
14647 Ext.Panel.superclass.beforeDestroy.call(this);
14649 this.header.removeAllListeners();
14652 for(var k in this.tools){
14653 Ext.destroy(this.tools[k]);
14656 if(Ext.isArray(this.buttons)){
14657 while(this.buttons.length) {
14658 Ext.destroy(this.buttons[0]);
14688 createClasses : function(){
14689 this.headerCls = this.baseCls + '-header';
14690 this.headerTextCls = this.baseCls + '-header-text';
14691 this.bwrapCls = this.baseCls + '-bwrap';
14692 this.tbarCls = this.baseCls + '-tbar';
14693 this.bodyCls = this.baseCls + '-body';
14694 this.bbarCls = this.baseCls + '-bbar';
14695 this.footerCls = this.baseCls + '-footer';
14699 createGhost : function(cls, useShim, appendTo){
14700 var el = document.createElement('div');
14701 el.className = 'x-panel-ghost ' + (cls ? cls : '');
14703 el.appendChild(this.el.dom.firstChild.cloneNode(true));
14705 Ext.fly(el.appendChild(document.createElement('ul'))).setHeight(this.bwrap.getHeight());
14706 el.style.width = this.el.dom.offsetWidth + 'px';;
14708 this.container.dom.appendChild(el);
14710 Ext.getDom(appendTo).appendChild(el);
14712 if(useShim !== false && this.el.useShim !== false){
14713 var layer = new Ext.Layer({shadow:false, useDisplay:true, constrain:false}, el);
14717 return new Ext.Element(el);
14722 doAutoLoad : function(){
14723 var u = this.body.getUpdater();
14725 u.setRenderer(this.renderer);
14727 u.update(Ext.isObject(this.autoLoad) ? this.autoLoad : {url: this.autoLoad});
14731 getTool : function(id) {
14732 return this.tools[id];
14737 Ext.reg('panel', Ext.Panel);
14739 Ext.Editor = function(field, config){
14741 this.field = Ext.create(field.field, 'textfield');
14742 config = Ext.apply({}, field);
14743 delete config.field;
14745 this.field = field;
14747 Ext.Editor.superclass.constructor.call(this, config);
14750 Ext.extend(Ext.Editor, Ext.Component, {
14768 swallowKeys : true,
14770 completeOnEnter : true,
14772 cancelOnEsc : true,
14776 initComponent : function(){
14777 Ext.Editor.superclass.initComponent.call(this);
14795 onRender : function(ct, position){
14796 this.el = new Ext.Layer({
14797 shadow: this.shadow,
14801 shadowOffset: this.shadowOffset || 4,
14803 constrain: this.constrain
14806 this.el.setZIndex(this.zIndex);
14808 this.el.setStyle("overflow", Ext.isGecko ? "auto" : "hidden");
14809 if(this.field.msgTarget != 'title'){
14810 this.field.msgTarget = 'qtip';
14812 this.field.inEditor = true;
14813 this.mon(this.field, {
14816 specialkey: this.onSpecialKey
14818 if(this.field.grow){
14819 this.mon(this.field, "autosize", this.el.sync, this.el, {delay:1});
14821 this.field.render(this.el).show();
14822 this.field.getEl().dom.name = '';
14823 if(this.swallowKeys){
14824 this.field.el.swallowEvent([
14832 onSpecialKey : function(field, e){
14833 var key = e.getKey(),
14834 complete = this.completeOnEnter && key == e.ENTER,
14835 cancel = this.cancelOnEsc && key == e.ESC;
14836 if(complete || cancel){
14839 this.completeEdit();
14843 if(field.triggerBlur){
14844 field.triggerBlur();
14847 this.fireEvent('specialkey', field, e);
14851 startEdit : function(el, value){
14853 this.completeEdit();
14855 this.boundEl = Ext.get(el);
14856 var v = value !== undefined ? value : this.boundEl.dom.innerHTML;
14857 if(!this.rendered){
14858 this.render(this.parentEl || document.body);
14860 if(this.fireEvent("beforestartedit", this, this.boundEl, v) !== false){
14861 this.startValue = v;
14862 this.field.reset();
14863 this.field.setValue(v);
14864 this.realign(true);
14865 this.editing = true;
14871 doAutoSize : function(){
14873 var sz = this.boundEl.getSize(),
14874 fs = this.field.getSize();
14876 switch(this.autoSize){
14878 this.setSize(sz.width, fs.height);
14881 this.setSize(fs.width, sz.height);
14884 this.setSize(fs.width, fs.height);
14887 this.setSize(sz.width, sz.height);
14893 setSize : function(w, h){
14894 delete this.field.lastSize;
14895 this.field.setSize(w, h);
14897 if(Ext.isGecko2 || Ext.isOpera){
14899 this.el.setSize(w, h);
14906 realign : function(autoSize){
14907 if(autoSize === true){
14910 this.el.alignTo(this.boundEl, this.alignment, this.offsets);
14914 completeEdit : function(remainVisible){
14918 var v = this.getValue();
14919 if(!this.field.isValid()){
14920 if(this.revertInvalid !== false){
14921 this.cancelEdit(remainVisible);
14925 if(String(v) === String(this.startValue) && this.ignoreNoChange){
14926 this.hideEdit(remainVisible);
14929 if(this.fireEvent("beforecomplete", this, v, this.startValue) !== false){
14930 v = this.getValue();
14931 if(this.updateEl && this.boundEl){
14932 this.boundEl.update(v);
14934 this.hideEdit(remainVisible);
14935 this.fireEvent("complete", this, v, this.startValue);
14940 onShow : function(){
14942 if(this.hideEl !== false){
14943 this.boundEl.hide();
14945 this.field.show().focus(false, true);
14946 this.fireEvent("startedit", this.boundEl, this.startValue);
14950 cancelEdit : function(remainVisible){
14952 var v = this.getValue();
14953 this.setValue(this.startValue);
14954 this.hideEdit(remainVisible);
14955 this.fireEvent("canceledit", this, v, this.startValue);
14960 hideEdit: function(remainVisible){
14961 if(remainVisible !== true){
14962 this.editing = false;
14968 onBlur : function(){
14969 if(this.allowBlur !== true && this.editing){
14970 this.completeEdit();
14975 onHide : function(){
14977 this.completeEdit();
14981 if(this.field.collapse){
14982 this.field.collapse();
14985 if(this.hideEl !== false){
14986 this.boundEl.show();
14991 setValue : function(v){
14992 this.field.setValue(v);
14996 getValue : function(){
14997 return this.field.getValue();
15000 beforeDestroy : function(){
15001 Ext.destroyMembers(this, 'field');
15003 delete this.parentEl;
15004 delete this.boundEl;
15007 Ext.reg('editor', Ext.Editor);
15009 Ext.ColorPalette = Ext.extend(Ext.Component, {
15012 itemCls : 'x-color-palette',
15016 clickEvent :'click',
15018 ctype : 'Ext.ColorPalette',
15021 allowReselect : false,
15025 '000000', '993300', '333300', '003300', '003366', '000080', '333399', '333333',
15026 '800000', 'FF6600', '808000', '008000', '008080', '0000FF', '666699', '808080',
15027 'FF0000', 'FF9900', '99CC00', '339966', '33CCCC', '3366FF', '800080', '969696',
15028 'FF00FF', 'FFCC00', 'FFFF00', '00FF00', '00FFFF', '00CCFF', '993366', 'C0C0C0',
15029 'FF99CC', 'FFCC99', 'FFFF99', 'CCFFCC', 'CCFFFF', '99CCFF', 'CC99FF', 'FFFFFF'
15036 initComponent : function(){
15037 Ext.ColorPalette.superclass.initComponent.call(this);
15044 this.on('select', this.handler, this.scope, true);
15049 onRender : function(container, position){
15054 Ext.ColorPalette.superclass.onRender.call(this, container, position);
15055 var t = this.tpl || new Ext.XTemplate(
15056 '<tpl for="."><a href="#" class="color-{.}" hidefocus="on"><em><span style="background:#{.}" unselectable="on"> </span></em></a></tpl>'
15058 t.overwrite(this.el, this.colors);
15059 this.mon(this.el, this.clickEvent, this.handleClick, this, {delegate: 'a'});
15060 if(this.clickEvent != 'click'){
15061 this.mon(this.el, 'click', Ext.emptyFn, this, {delegate: 'a', preventDefault: true});
15066 afterRender : function(){
15067 Ext.ColorPalette.superclass.afterRender.call(this);
15069 var s = this.value;
15076 handleClick : function(e, t){
15077 e.preventDefault();
15078 if(!this.disabled){
15079 var c = t.className.match(/(?:^|\s)color-(.{6})(?:\s|$)/)[1];
15080 this.select(c.toUpperCase());
15085 select : function(color){
15086 color = color.replace('#', '');
15087 if(color != this.value || this.allowReselect){
15090 el.child('a.color-'+this.value).removeClass('x-color-palette-sel');
15092 el.child('a.color-'+color).addClass('x-color-palette-sel');
15093 this.value = color;
15094 this.fireEvent('select', this, color);
15100 Ext.reg('colorpalette', Ext.ColorPalette);
15102 Ext.DatePicker = Ext.extend(Ext.BoxComponent, {
15104 todayText : 'Today',
15106 okText : ' OK ',
15108 cancelText : 'Cancel',
15112 todayTip : '{0} (Spacebar)',
15114 minText : 'This date is before the minimum date',
15116 maxText : 'This date is after the maximum date',
15120 disabledDaysText : 'Disabled',
15122 disabledDatesText : 'Disabled',
15124 monthNames : Date.monthNames,
15126 dayNames : Date.dayNames,
15128 nextText : 'Next Month (Control+Right)',
15130 prevText : 'Previous Month (Control+Left)',
15132 monthYearText : 'Choose a month (Control+Up/Down to move years)',
15145 focusOnSelect: true,
15148 initComponent : function(){
15149 Ext.DatePicker.superclass.initComponent.call(this);
15151 this.value = this.value ?
15152 this.value.clearTime(true) : new Date().clearTime();
15160 this.on('select', this.handler, this.scope || this);
15163 this.initDisabledDays();
15167 initDisabledDays : function(){
15168 if(!this.disabledDatesRE && this.disabledDates){
15169 var dd = this.disabledDates,
15170 len = dd.length - 1,
15173 Ext.each(dd, function(d, i){
15174 re += Ext.isDate(d) ? '^' + Ext.escapeRe(d.dateFormat(this.format)) + '$' : dd[i];
15179 this.disabledDatesRE = new RegExp(re + ')');
15184 setDisabledDates : function(dd){
15185 if(Ext.isArray(dd)){
15186 this.disabledDates = dd;
15187 this.disabledDatesRE = null;
15189 this.disabledDatesRE = dd;
15191 this.initDisabledDays();
15192 this.update(this.value, true);
15196 setDisabledDays : function(dd){
15197 this.disabledDays = dd;
15198 this.update(this.value, true);
15202 setMinDate : function(dt){
15204 this.update(this.value, true);
15208 setMaxDate : function(dt){
15210 this.update(this.value, true);
15214 setValue : function(value){
15215 this.value = value.clearTime(true);
15216 this.update(this.value);
15220 getValue : function(){
15225 focus : function(){
15226 this.update(this.activeDate);
15230 onEnable: function(initial){
15231 Ext.DatePicker.superclass.onEnable.call(this);
15232 this.doDisabled(false);
15233 this.update(initial ? this.value : this.activeDate);
15241 onDisable : function(){
15242 Ext.DatePicker.superclass.onDisable.call(this);
15243 this.doDisabled(true);
15244 if(Ext.isIE && !Ext.isIE8){
15246 Ext.each([].concat(this.textNodes, this.el.query('th span')), function(el){
15247 Ext.fly(el).repaint();
15253 doDisabled : function(disabled){
15254 this.keyNav.setDisabled(disabled);
15255 this.prevRepeater.setDisabled(disabled);
15256 this.nextRepeater.setDisabled(disabled);
15257 if(this.showToday){
15258 this.todayKeyListener.setDisabled(disabled);
15259 this.todayBtn.setDisabled(disabled);
15264 onRender : function(container, position){
15266 '<table cellspacing="0">',
15267 '<tr><td class="x-date-left"><a href="#" title="', this.prevText ,'"> </a></td><td class="x-date-middle" align="center"></td><td class="x-date-right"><a href="#" title="', this.nextText ,'"> </a></td></tr>',
15268 '<tr><td colspan="3"><table class="x-date-inner" cellspacing="0"><thead><tr>'],
15269 dn = this.dayNames,
15271 for(i = 0; i < 7; i++){
15272 var d = this.startDay+i;
15276 m.push('<th><span>', dn[d].substr(0,1), '</span></th>');
15278 m[m.length] = '</tr></thead><tbody><tr>';
15279 for(i = 0; i < 42; i++) {
15280 if(i % 7 === 0 && i !== 0){
15281 m[m.length] = '</tr><tr>';
15283 m[m.length] = '<td><a href="#" hidefocus="on" class="x-date-date" tabIndex="1"><em><span></span></em></a></td>';
15285 m.push('</tr></tbody></table></td></tr>',
15286 this.showToday ? '<tr><td colspan="3" class="x-date-bottom" align="center"></td></tr>' : '',
15287 '</table><div class="x-date-mp"></div>');
15289 var el = document.createElement('div');
15290 el.className = 'x-date-picker';
15291 el.innerHTML = m.join('');
15293 container.dom.insertBefore(el, position);
15295 this.el = Ext.get(el);
15296 this.eventEl = Ext.get(el.firstChild);
15298 this.prevRepeater = new Ext.util.ClickRepeater(this.el.child('td.x-date-left a'), {
15299 handler: this.showPrevMonth,
15301 preventDefault:true,
15305 this.nextRepeater = new Ext.util.ClickRepeater(this.el.child('td.x-date-right a'), {
15306 handler: this.showNextMonth,
15308 preventDefault:true,
15312 this.monthPicker = this.el.down('div.x-date-mp');
15313 this.monthPicker.enableDisplayMode('block');
15315 this.keyNav = new Ext.KeyNav(this.eventEl, {
15316 'left' : function(e){
15318 this.showPrevMonth();
15320 this.update(this.activeDate.add('d', -1));
15324 'right' : function(e){
15326 this.showNextMonth();
15328 this.update(this.activeDate.add('d', 1));
15332 'up' : function(e){
15334 this.showNextYear();
15336 this.update(this.activeDate.add('d', -7));
15340 'down' : function(e){
15342 this.showPrevYear();
15344 this.update(this.activeDate.add('d', 7));
15348 'pageUp' : function(e){
15349 this.showNextMonth();
15352 'pageDown' : function(e){
15353 this.showPrevMonth();
15356 'enter' : function(e){
15357 e.stopPropagation();
15364 this.el.unselectable();
15366 this.cells = this.el.select('table.x-date-inner tbody td');
15367 this.textNodes = this.el.query('table.x-date-inner tbody span');
15369 this.mbtn = new Ext.Button({
15371 tooltip: this.monthYearText,
15372 renderTo: this.el.child('td.x-date-middle', true)
15374 this.mbtn.el.child('em').addClass('x-btn-arrow');
15376 if(this.showToday){
15377 this.todayKeyListener = this.eventEl.addKeyListener(Ext.EventObject.SPACE, this.selectToday, this);
15378 var today = (new Date()).dateFormat(this.format);
15379 this.todayBtn = new Ext.Button({
15380 renderTo: this.el.child('td.x-date-bottom', true),
15381 text: String.format(this.todayText, today),
15382 tooltip: String.format(this.todayTip, today),
15383 handler: this.selectToday,
15387 this.mon(this.eventEl, 'mousewheel', this.handleMouseWheel, this);
15388 this.mon(this.eventEl, 'click', this.handleDateClick, this, {delegate: 'a.x-date-date'});
15389 this.mon(this.mbtn, 'click', this.showMonthPicker, this);
15390 this.onEnable(true);
15394 createMonthPicker : function(){
15395 if(!this.monthPicker.dom.firstChild){
15396 var buf = ['<table border="0" cellspacing="0">'];
15397 for(var i = 0; i < 6; i++){
15399 '<tr><td class="x-date-mp-month"><a href="#">', Date.getShortMonthName(i), '</a></td>',
15400 '<td class="x-date-mp-month x-date-mp-sep"><a href="#">', Date.getShortMonthName(i + 6), '</a></td>',
15402 '<td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-prev"></a></td><td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-next"></a></td></tr>' :
15403 '<td class="x-date-mp-year"><a href="#"></a></td><td class="x-date-mp-year"><a href="#"></a></td></tr>'
15407 '<tr class="x-date-mp-btns"><td colspan="4"><button type="button" class="x-date-mp-ok">',
15409 '</button><button type="button" class="x-date-mp-cancel">',
15411 '</button></td></tr>',
15414 this.monthPicker.update(buf.join(''));
15416 this.mon(this.monthPicker, 'click', this.onMonthClick, this);
15417 this.mon(this.monthPicker, 'dblclick', this.onMonthDblClick, this);
15419 this.mpMonths = this.monthPicker.select('td.x-date-mp-month');
15420 this.mpYears = this.monthPicker.select('td.x-date-mp-year');
15422 this.mpMonths.each(function(m, a, i){
15425 m.dom.xmonth = 5 + Math.round(i * 0.5);
15427 m.dom.xmonth = Math.round((i-1) * 0.5);
15434 showMonthPicker : function(){
15435 if(!this.disabled){
15436 this.createMonthPicker();
15437 var size = this.el.getSize();
15438 this.monthPicker.setSize(size);
15439 this.monthPicker.child('table').setSize(size);
15441 this.mpSelMonth = (this.activeDate || this.value).getMonth();
15442 this.updateMPMonth(this.mpSelMonth);
15443 this.mpSelYear = (this.activeDate || this.value).getFullYear();
15444 this.updateMPYear(this.mpSelYear);
15446 this.monthPicker.slideIn('t', {duration:0.2});
15451 updateMPYear : function(y){
15453 var ys = this.mpYears.elements;
15454 for(var i = 1; i <= 10; i++){
15455 var td = ys[i-1], y2;
15457 y2 = y + Math.round(i * 0.5);
15458 td.firstChild.innerHTML = y2;
15461 y2 = y - (5-Math.round(i * 0.5));
15462 td.firstChild.innerHTML = y2;
15465 this.mpYears.item(i-1)[y2 == this.mpSelYear ? 'addClass' : 'removeClass']('x-date-mp-sel');
15470 updateMPMonth : function(sm){
15471 this.mpMonths.each(function(m, a, i){
15472 m[m.dom.xmonth == sm ? 'addClass' : 'removeClass']('x-date-mp-sel');
15477 selectMPMonth : function(m){
15482 onMonthClick : function(e, t){
15484 var el = new Ext.Element(t), pn;
15485 if(el.is('button.x-date-mp-cancel')){
15486 this.hideMonthPicker();
15488 else if(el.is('button.x-date-mp-ok')){
15489 var d = new Date(this.mpSelYear, this.mpSelMonth, (this.activeDate || this.value).getDate());
15490 if(d.getMonth() != this.mpSelMonth){
15492 d = new Date(this.mpSelYear, this.mpSelMonth, 1).getLastDateOfMonth();
15495 this.hideMonthPicker();
15497 else if((pn = el.up('td.x-date-mp-month', 2))){
15498 this.mpMonths.removeClass('x-date-mp-sel');
15499 pn.addClass('x-date-mp-sel');
15500 this.mpSelMonth = pn.dom.xmonth;
15502 else if((pn = el.up('td.x-date-mp-year', 2))){
15503 this.mpYears.removeClass('x-date-mp-sel');
15504 pn.addClass('x-date-mp-sel');
15505 this.mpSelYear = pn.dom.xyear;
15507 else if(el.is('a.x-date-mp-prev')){
15508 this.updateMPYear(this.mpyear-10);
15510 else if(el.is('a.x-date-mp-next')){
15511 this.updateMPYear(this.mpyear+10);
15516 onMonthDblClick : function(e, t){
15518 var el = new Ext.Element(t), pn;
15519 if((pn = el.up('td.x-date-mp-month', 2))){
15520 this.update(new Date(this.mpSelYear, pn.dom.xmonth, (this.activeDate || this.value).getDate()));
15521 this.hideMonthPicker();
15523 else if((pn = el.up('td.x-date-mp-year', 2))){
15524 this.update(new Date(pn.dom.xyear, this.mpSelMonth, (this.activeDate || this.value).getDate()));
15525 this.hideMonthPicker();
15530 hideMonthPicker : function(disableAnim){
15531 if(this.monthPicker){
15532 if(disableAnim === true){
15533 this.monthPicker.hide();
15535 this.monthPicker.slideOut('t', {duration:0.2});
15541 showPrevMonth : function(e){
15542 this.update(this.activeDate.add('mo', -1));
15546 showNextMonth : function(e){
15547 this.update(this.activeDate.add('mo', 1));
15551 showPrevYear : function(){
15552 this.update(this.activeDate.add('y', -1));
15556 showNextYear : function(){
15557 this.update(this.activeDate.add('y', 1));
15561 handleMouseWheel : function(e){
15563 if(!this.disabled){
15564 var delta = e.getWheelDelta();
15566 this.showPrevMonth();
15567 } else if(delta < 0){
15568 this.showNextMonth();
15574 handleDateClick : function(e, t){
15576 if(!this.disabled && t.dateValue && !Ext.fly(t.parentNode).hasClass('x-date-disabled')){
15577 this.cancelFocus = this.focusOnSelect === false;
15578 this.setValue(new Date(t.dateValue));
15579 delete this.cancelFocus;
15580 this.fireEvent('select', this, this.value);
15585 selectToday : function(){
15586 if(this.todayBtn && !this.todayBtn.disabled){
15587 this.setValue(new Date().clearTime());
15588 this.fireEvent('select', this, this.value);
15593 update : function(date, forceRefresh){
15595 var vd = this.activeDate, vis = this.isVisible();
15596 this.activeDate = date;
15597 if(!forceRefresh && vd && this.el){
15598 var t = date.getTime();
15599 if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
15600 this.cells.removeClass('x-date-selected');
15601 this.cells.each(function(c){
15602 if(c.dom.firstChild.dateValue == t){
15603 c.addClass('x-date-selected');
15604 if(vis && !this.cancelFocus){
15605 Ext.fly(c.dom.firstChild).focus(50);
15613 var days = date.getDaysInMonth(),
15614 firstOfMonth = date.getFirstDateOfMonth(),
15615 startingPos = firstOfMonth.getDay()-this.startDay;
15617 if(startingPos < 0){
15620 days += startingPos;
15622 var pm = date.add('mo', -1),
15623 prevStart = pm.getDaysInMonth()-startingPos,
15624 cells = this.cells.elements,
15625 textEls = this.textNodes,
15628 d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime(),
15629 today = new Date().clearTime().getTime(),
15630 sel = date.clearTime(true).getTime(),
15631 min = this.minDate ? this.minDate.clearTime(true) : Number.NEGATIVE_INFINITY,
15632 max = this.maxDate ? this.maxDate.clearTime(true) : Number.POSITIVE_INFINITY,
15633 ddMatch = this.disabledDatesRE,
15634 ddText = this.disabledDatesText,
15635 ddays = this.disabledDays ? this.disabledDays.join('') : false,
15636 ddaysText = this.disabledDaysText,
15637 format = this.format;
15639 if(this.showToday){
15640 var td = new Date().clearTime(),
15641 disable = (td < min || td > max ||
15642 (ddMatch && format && ddMatch.test(td.dateFormat(format))) ||
15643 (ddays && ddays.indexOf(td.getDay()) != -1));
15645 if(!this.disabled){
15646 this.todayBtn.setDisabled(disable);
15647 this.todayKeyListener[disable ? 'disable' : 'enable']();
15651 var setCellClass = function(cal, cell){
15653 var t = d.getTime();
15654 cell.firstChild.dateValue = t;
15656 cell.className += ' x-date-today';
15657 cell.title = cal.todayText;
15660 cell.className += ' x-date-selected';
15662 Ext.fly(cell.firstChild).focus(50);
15667 cell.className = ' x-date-disabled';
15668 cell.title = cal.minText;
15672 cell.className = ' x-date-disabled';
15673 cell.title = cal.maxText;
15677 if(ddays.indexOf(d.getDay()) != -1){
15678 cell.title = ddaysText;
15679 cell.className = ' x-date-disabled';
15682 if(ddMatch && format){
15683 var fvalue = d.dateFormat(format);
15684 if(ddMatch.test(fvalue)){
15685 cell.title = ddText.replace('%0', fvalue);
15686 cell.className = ' x-date-disabled';
15692 for(; i < startingPos; i++) {
15693 textEls[i].innerHTML = (++prevStart);
15694 d.setDate(d.getDate()+1);
15695 cells[i].className = 'x-date-prevday';
15696 setCellClass(this, cells[i]);
15698 for(; i < days; i++){
15699 var intDay = i - startingPos + 1;
15700 textEls[i].innerHTML = (intDay);
15701 d.setDate(d.getDate()+1);
15702 cells[i].className = 'x-date-active';
15703 setCellClass(this, cells[i]);
15706 for(; i < 42; i++) {
15707 textEls[i].innerHTML = (++extraDays);
15708 d.setDate(d.getDate()+1);
15709 cells[i].className = 'x-date-nextday';
15710 setCellClass(this, cells[i]);
15713 this.mbtn.setText(this.monthNames[date.getMonth()] + ' ' + date.getFullYear());
15715 if(!this.internalRender){
15716 var main = this.el.dom.firstChild,
15717 w = main.offsetWidth;
15718 this.el.setWidth(w + this.el.getBorderWidth('lr'));
15719 Ext.fly(main).setWidth(w);
15720 this.internalRender = true;
15724 if(Ext.isOpera && !this.secondPass){
15725 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + 'px';
15726 this.secondPass = true;
15727 this.update.defer(10, this, [date]);
15734 beforeDestroy : function() {
15746 delete this.textNodes;
15747 delete this.cells.elements;
15754 Ext.reg('datepicker', Ext.DatePicker);
15756 Ext.LoadMask = function(el, config){
15757 this.el = Ext.get(el);
15758 Ext.apply(this, config);
15762 beforeload: this.onBeforeLoad,
15764 exception: this.onLoad
15766 this.removeMask = Ext.value(this.removeMask, false);
15768 var um = this.el.getUpdater();
15769 um.showLoadIndicator = false;
15772 beforeupdate: this.onBeforeLoad,
15773 update: this.onLoad,
15774 failure: this.onLoad
15776 this.removeMask = Ext.value(this.removeMask, true);
15780 Ext.LoadMask.prototype = {
15784 msg : 'Loading...',
15786 msgCls : 'x-mask-loading',
15792 disable : function(){
15793 this.disabled = true;
15797 enable : function(){
15798 this.disabled = false;
15802 onLoad : function(){
15803 this.el.unmask(this.removeMask);
15807 onBeforeLoad : function(){
15808 if(!this.disabled){
15809 this.el.mask(this.msg, this.msgCls);
15815 this.onBeforeLoad();
15824 destroy : function(){
15826 this.store.un('beforeload', this.onBeforeLoad, this);
15827 this.store.un('load', this.onLoad, this);
15828 this.store.un('exception', this.onLoad, this);
15830 var um = this.el.getUpdater();
15831 um.un('beforeupdate', this.onBeforeLoad, this);
15832 um.un('update', this.onLoad, this);
15833 um.un('failure', this.onLoad, this);
15837 Ext.Slider = Ext.extend(Ext.BoxComponent, {
15846 decimalPrecision: 0,
15852 clickRange: [5,15],
15854 clickToChange : true,
15862 initComponent : function(){
15863 if(!Ext.isDefined(this.value)){
15864 this.value = this.minValue;
15866 Ext.Slider.superclass.initComponent.call(this);
15867 this.keyIncrement = Math.max(this.increment, this.keyIncrement);
15884 Ext.apply(this, Ext.Slider.Vertical);
15889 onRender : function(){
15891 cls: 'x-slider ' + (this.vertical ? 'x-slider-vert' : 'x-slider-horz'),
15892 cn:{cls:'x-slider-end',cn:{cls:'x-slider-inner',cn:[{cls:'x-slider-thumb'},{tag:'a', cls:'x-slider-focus', href:"#", tabIndex: '-1', hidefocus:'on'}]}}
15894 Ext.Slider.superclass.onRender.apply(this, arguments);
15895 this.endEl = this.el.first();
15896 this.innerEl = this.endEl.first();
15897 this.thumb = this.innerEl.first();
15898 this.halfThumb = (this.vertical ? this.thumb.getHeight() : this.thumb.getWidth())/2;
15899 this.focusEl = this.thumb.next();
15904 initEvents : function(){
15905 this.thumb.addClassOnOver('x-slider-thumb-over');
15906 this.mon(this.el, {
15908 mousedown: this.onMouseDown,
15909 keydown: this.onKeyDown
15912 this.focusEl.swallowEvent("click", true);
15914 this.tracker = new Ext.dd.DragTracker({
15915 onBeforeStart: this.onBeforeDragStart.createDelegate(this),
15916 onStart: this.onDragStart.createDelegate(this),
15917 onDrag: this.onDrag.createDelegate(this),
15918 onEnd: this.onDragEnd.createDelegate(this),
15922 this.tracker.initEl(this.thumb);
15926 onMouseDown : function(e){
15930 if(this.clickToChange && e.target != this.thumb.dom){
15931 var local = this.innerEl.translatePoints(e.getXY());
15932 this.onClickChange(local);
15938 onClickChange : function(local){
15939 if(local.top > this.clickRange[0] && local.top < this.clickRange[1]){
15940 this.setValue(Ext.util.Format.round(this.reverseValue(local.left), this.decimalPrecision), undefined, true);
15945 onKeyDown : function(e){
15946 if(this.disabled){e.preventDefault();return;}
15947 var k = e.getKey();
15953 this.setValue(this.maxValue, undefined, true);
15955 this.setValue(this.value+this.keyIncrement, undefined, true);
15962 this.setValue(this.minValue, undefined, true);
15964 this.setValue(this.value-this.keyIncrement, undefined, true);
15968 e.preventDefault();
15973 doSnap : function(value){
15974 if(!(this.increment && value)){
15977 var newValue = value,
15978 inc = this.increment,
15984 }else if(m * 2 < -inc){
15988 return newValue.constrain(this.minValue, this.maxValue);
15992 afterRender : function(){
15993 Ext.Slider.superclass.afterRender.apply(this, arguments);
15994 if(this.value !== undefined){
15995 var v = this.normalizeValue(this.value);
15996 if(v !== this.value){
15998 this.setValue(v, false);
16000 this.moveThumb(this.translateValue(v), false);
16006 getRatio : function(){
16007 var w = this.innerEl.getWidth(),
16008 v = this.maxValue - this.minValue;
16009 return v == 0 ? w : (w/v);
16013 normalizeValue : function(v){
16014 v = this.doSnap(v);
16015 v = Ext.util.Format.round(v, this.decimalPrecision);
16016 v = v.constrain(this.minValue, this.maxValue);
16021 setValue : function(v, animate, changeComplete){
16022 v = this.normalizeValue(v);
16023 if(v !== this.value && this.fireEvent('beforechange', this, v, this.value) !== false){
16025 this.moveThumb(this.translateValue(v), animate !== false);
16026 this.fireEvent('change', this, v);
16027 if(changeComplete){
16028 this.fireEvent('changecomplete', this, v);
16034 translateValue : function(v){
16035 var ratio = this.getRatio();
16036 return (v * ratio) - (this.minValue * ratio) - this.halfThumb;
16039 reverseValue : function(pos){
16040 var ratio = this.getRatio();
16041 return (pos + this.halfThumb + (this.minValue * ratio)) / ratio;
16045 moveThumb: function(v, animate){
16046 if(!animate || this.animate === false){
16047 this.thumb.setLeft(v);
16049 this.thumb.shift({left: v, stopFx: true, duration:.35});
16054 focus : function(){
16055 this.focusEl.focus(10);
16059 onBeforeDragStart : function(e){
16060 return !this.disabled;
16064 onDragStart: function(e){
16065 this.thumb.addClass('x-slider-thumb-drag');
16066 this.dragging = true;
16067 this.dragStartValue = this.value;
16068 this.fireEvent('dragstart', this, e);
16072 onDrag: function(e){
16073 var pos = this.innerEl.translatePoints(this.tracker.getXY());
16074 this.setValue(Ext.util.Format.round(this.reverseValue(pos.left), this.decimalPrecision), false);
16075 this.fireEvent('drag', this, e);
16079 onDragEnd: function(e){
16080 this.thumb.removeClass('x-slider-thumb-drag');
16081 this.dragging = false;
16082 this.fireEvent('dragend', this, e);
16083 if(this.dragStartValue != this.value){
16084 this.fireEvent('changecomplete', this, this.value);
16089 onResize : function(w, h){
16090 this.innerEl.setWidth(w - (this.el.getPadding('l') + this.endEl.getPadding('r')));
16095 onDisable: function(){
16096 Ext.Slider.superclass.onDisable.call(this);
16097 this.thumb.addClass(this.disabledClass);
16101 var xy = this.thumb.getXY();
16103 this.innerEl.addClass(this.disabledClass).dom.disabled = true;
16104 if (!this.thumbHolder){
16105 this.thumbHolder = this.endEl.createChild({cls: 'x-slider-thumb ' + this.disabledClass});
16107 this.thumbHolder.show().setXY(xy);
16112 onEnable: function(){
16113 Ext.Slider.superclass.onEnable.call(this);
16114 this.thumb.removeClass(this.disabledClass);
16116 this.innerEl.removeClass(this.disabledClass).dom.disabled = false;
16117 if(this.thumbHolder){
16118 this.thumbHolder.hide();
16126 syncThumb : function(){
16128 this.moveThumb(this.translateValue(this.value));
16133 getValue : function(){
16138 beforeDestroy : function(){
16139 Ext.destroyMembers(this, 'endEl', 'innerEl', 'thumb', 'halfThumb', 'focusEl', 'tracker', 'thumbHolder');
16140 Ext.Slider.superclass.beforeDestroy.call(this);
16143 Ext.reg('slider', Ext.Slider);
16146 Ext.Slider.Vertical = {
16147 onResize : function(w, h){
16148 this.innerEl.setHeight(h - (this.el.getPadding('t') + this.endEl.getPadding('b')));
16152 getRatio : function(){
16153 var h = this.innerEl.getHeight(),
16154 v = this.maxValue - this.minValue;
16158 moveThumb: function(v, animate){
16159 if(!animate || this.animate === false){
16160 this.thumb.setBottom(v);
16162 this.thumb.shift({bottom: v, stopFx: true, duration:.35});
16166 onDrag: function(e){
16167 var pos = this.innerEl.translatePoints(this.tracker.getXY()),
16168 bottom = this.innerEl.getHeight()-pos.top;
16169 this.setValue(this.minValue + Ext.util.Format.round(bottom/this.getRatio(), this.decimalPrecision), false);
16170 this.fireEvent('drag', this, e);
16173 onClickChange : function(local){
16174 if(local.left > this.clickRange[0] && local.left < this.clickRange[1]){
16175 var bottom = this.innerEl.getHeight() - local.top;
16176 this.setValue(this.minValue + Ext.util.Format.round(bottom/this.getRatio(), this.decimalPrecision), undefined, true);
16180 Ext.ProgressBar = Ext.extend(Ext.BoxComponent, {
16182 baseCls : 'x-progress',
16191 initComponent : function(){
16192 Ext.ProgressBar.superclass.initComponent.call(this);
16200 onRender : function(ct, position){
16201 var tpl = new Ext.Template(
16202 '<div class="{cls}-wrap">',
16203 '<div class="{cls}-inner">',
16204 '<div class="{cls}-bar">',
16205 '<div class="{cls}-text">',
16206 '<div> </div>',
16209 '<div class="{cls}-text {cls}-text-back">',
16210 '<div> </div>',
16216 this.el = position ? tpl.insertBefore(position, {cls: this.baseCls}, true)
16217 : tpl.append(ct, {cls: this.baseCls}, true);
16220 this.el.dom.id = this.id;
16222 var inner = this.el.dom.firstChild;
16223 this.progressBar = Ext.get(inner.firstChild);
16227 this.textEl = Ext.get(this.textEl);
16228 delete this.textTopEl;
16231 this.textTopEl = Ext.get(this.progressBar.dom.firstChild);
16232 var textBackEl = Ext.get(inner.childNodes[1]);
16233 this.textTopEl.setStyle("z-index", 99).addClass('x-hidden');
16234 this.textEl = new Ext.CompositeElement([this.textTopEl.dom.firstChild, textBackEl.dom.firstChild]);
16235 this.textEl.setWidth(inner.offsetWidth);
16237 this.progressBar.setHeight(inner.offsetHeight);
16241 afterRender : function(){
16242 Ext.ProgressBar.superclass.afterRender.call(this);
16244 this.updateProgress(this.value, this.text);
16246 this.updateText(this.text);
16251 updateProgress : function(value, text, animate){
16252 this.value = value || 0;
16254 this.updateText(text);
16257 var w = Math.floor(value*this.el.dom.firstChild.offsetWidth);
16258 this.progressBar.setWidth(w, animate === true || (animate !== false && this.animate));
16259 if(this.textTopEl){
16261 this.textTopEl.removeClass('x-hidden').setWidth(w);
16264 this.fireEvent('update', this, value, text);
16269 wait : function(o){
16270 if(!this.waitTimer){
16273 this.updateText(o.text);
16274 this.waitTimer = Ext.TaskMgr.start({
16276 var inc = o.increment || 10;
16278 this.updateProgress(((((i+inc)%inc)+1)*(100/inc))*0.01, null, o.animate);
16280 interval: o.interval || 1000,
16281 duration: o.duration,
16282 onStop: function(){
16284 o.fn.apply(o.scope || this);
16295 isWaiting : function(){
16296 return this.waitTimer !== null;
16300 updateText : function(text){
16301 this.text = text || ' ';
16303 this.textEl.update(this.text);
16309 syncProgressBar : function(){
16311 this.updateProgress(this.value, this.text);
16317 setSize : function(w, h){
16318 Ext.ProgressBar.superclass.setSize.call(this, w, h);
16319 if(this.textTopEl){
16320 var inner = this.el.dom.firstChild;
16321 this.textEl.setSize(inner.offsetWidth, inner.offsetHeight);
16323 this.syncProgressBar();
16328 reset : function(hide){
16329 this.updateProgress(0);
16330 if(this.textTopEl){
16331 this.textTopEl.addClass('x-hidden');
16333 if(this.waitTimer){
16334 this.waitTimer.onStop = null;
16335 Ext.TaskMgr.stop(this.waitTimer);
16336 this.waitTimer = null;
16344 onDestroy: function(){
16346 if(this.textEl.isComposite){
16347 this.textEl.clear();
16349 Ext.destroyMembers(this, 'textEl', 'progressBar', 'textTopEl');
16351 Ext.ProgressBar.superclass.onDestroy.call(this);
16354 Ext.reg('progress', Ext.ProgressBar);
16358 var Event=Ext.EventManager;
16359 var Dom=Ext.lib.Dom;
16362 Ext.dd.DragDrop = function(id, sGroup, config) {
16364 this.init(id, sGroup, config);
16368 Ext.dd.DragDrop.prototype = {
16385 invalidHandleTypes: null,
16388 invalidHandleIds: null,
16391 invalidHandleClasses: null,
16406 lock: function() { this.locked = true; },
16412 unlock: function() { this.locked = false; },
16424 __ygDragDrop: true,
16445 maintainOffset: false,
16454 primaryButtonOnly: true,
16460 hasOuterHandles: false,
16463 b4StartDrag: function(x, y) { },
16466 startDrag: function(x, y) { },
16469 b4Drag: function(e) { },
16472 onDrag: function(e) { },
16475 onDragEnter: function(e, id) { },
16478 b4DragOver: function(e) { },
16481 onDragOver: function(e, id) { },
16484 b4DragOut: function(e) { },
16487 onDragOut: function(e, id) { },
16490 b4DragDrop: function(e) { },
16493 onDragDrop: function(e, id) { },
16496 onInvalidDrop: function(e) { },
16499 b4EndDrag: function(e) { },
16502 endDrag: function(e) { },
16505 b4MouseDown: function(e) { },
16508 onMouseDown: function(e) { },
16511 onMouseUp: function(e) { },
16514 onAvailable: function () {
16518 defaultPadding : {left:0, right:0, top:0, bottom:0},
16521 constrainTo : function(constrainTo, pad, inContent){
16522 if(Ext.isNumber(pad)){
16523 pad = {left: pad, right:pad, top:pad, bottom:pad};
16525 pad = pad || this.defaultPadding;
16526 var b = Ext.get(this.getEl()).getBox(),
16527 ce = Ext.get(constrainTo),
16528 s = ce.getScroll(),
16531 if(cd == document.body){
16532 c = { x: s.left, y: s.top, width: Ext.lib.Dom.getViewWidth(), height: Ext.lib.Dom.getViewHeight()};
16534 var xy = ce.getXY();
16535 c = {x : xy[0], y: xy[1], width: cd.clientWidth, height: cd.clientHeight};
16539 var topSpace = b.y - c.y,
16540 leftSpace = b.x - c.x;
16542 this.resetConstraints();
16543 this.setXConstraint(leftSpace - (pad.left||0),
16544 c.width - leftSpace - b.width - (pad.right||0),
16547 this.setYConstraint(topSpace - (pad.top||0),
16548 c.height - topSpace - b.height - (pad.bottom||0),
16554 getEl: function() {
16555 if (!this._domRef) {
16556 this._domRef = Ext.getDom(this.id);
16559 return this._domRef;
16563 getDragEl: function() {
16564 return Ext.getDom(this.dragElId);
16568 init: function(id, sGroup, config) {
16569 this.initTarget(id, sGroup, config);
16570 Event.on(this.id, "mousedown", this.handleMouseDown, this);
16575 initTarget: function(id, sGroup, config) {
16578 this.config = config || {};
16581 this.DDM = Ext.dd.DDM;
16587 if (typeof id !== "string") {
16595 this.addToGroup((sGroup) ? sGroup : "default");
16599 this.handleElId = id;
16602 this.setDragElId(id);
16605 this.invalidHandleTypes = { A: "A" };
16606 this.invalidHandleIds = {};
16607 this.invalidHandleClasses = [];
16609 this.applyConfig();
16611 this.handleOnAvailable();
16615 applyConfig: function() {
16619 this.padding = this.config.padding || [0, 0, 0, 0];
16620 this.isTarget = (this.config.isTarget !== false);
16621 this.maintainOffset = (this.config.maintainOffset);
16622 this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);
16627 handleOnAvailable: function() {
16628 this.available = true;
16629 this.resetConstraints();
16630 this.onAvailable();
16634 setPadding: function(iTop, iRight, iBot, iLeft) {
16636 if (!iRight && 0 !== iRight) {
16637 this.padding = [iTop, iTop, iTop, iTop];
16638 } else if (!iBot && 0 !== iBot) {
16639 this.padding = [iTop, iRight, iTop, iRight];
16641 this.padding = [iTop, iRight, iBot, iLeft];
16646 setInitPosition: function(diffX, diffY) {
16647 var el = this.getEl();
16649 if (!this.DDM.verifyEl(el)) {
16653 var dx = diffX || 0;
16654 var dy = diffY || 0;
16656 var p = Dom.getXY( el );
16658 this.initPageX = p[0] - dx;
16659 this.initPageY = p[1] - dy;
16661 this.lastPageX = p[0];
16662 this.lastPageY = p[1];
16665 this.setStartPosition(p);
16669 setStartPosition: function(pos) {
16670 var p = pos || Dom.getXY( this.getEl() );
16671 this.deltaSetXY = null;
16673 this.startPageX = p[0];
16674 this.startPageY = p[1];
16678 addToGroup: function(sGroup) {
16679 this.groups[sGroup] = true;
16680 this.DDM.regDragDrop(this, sGroup);
16684 removeFromGroup: function(sGroup) {
16685 if (this.groups[sGroup]) {
16686 delete this.groups[sGroup];
16689 this.DDM.removeDDFromGroup(this, sGroup);
16693 setDragElId: function(id) {
16694 this.dragElId = id;
16698 setHandleElId: function(id) {
16699 if (typeof id !== "string") {
16702 this.handleElId = id;
16703 this.DDM.regHandle(this.id, id);
16707 setOuterHandleElId: function(id) {
16708 if (typeof id !== "string") {
16711 Event.on(id, "mousedown",
16712 this.handleMouseDown, this);
16713 this.setHandleElId(id);
16715 this.hasOuterHandles = true;
16719 unreg: function() {
16720 Event.un(this.id, "mousedown",
16721 this.handleMouseDown);
16722 this._domRef = null;
16723 this.DDM._remove(this);
16726 destroy : function(){
16731 isLocked: function() {
16732 return (this.DDM.isLocked() || this.locked);
16736 handleMouseDown: function(e, oDD){
16737 if (this.primaryButtonOnly && e.button != 0) {
16741 if (this.isLocked()) {
16745 this.DDM.refreshCache(this.groups);
16747 var pt = new Ext.lib.Point(Ext.lib.Event.getPageX(e), Ext.lib.Event.getPageY(e));
16748 if (!this.hasOuterHandles && !this.DDM.isOverTarget(pt, this) ) {
16750 if (this.clickValidator(e)) {
16753 this.setStartPosition();
16756 this.b4MouseDown(e);
16757 this.onMouseDown(e);
16759 this.DDM.handleMouseDown(e, this);
16761 this.DDM.stopEvent(e);
16769 clickValidator: function(e) {
16770 var target = e.getTarget();
16771 return ( this.isValidHandleChild(target) &&
16772 (this.id == this.handleElId ||
16773 this.DDM.handleWasClicked(target, this.id)) );
16777 addInvalidHandleType: function(tagName) {
16778 var type = tagName.toUpperCase();
16779 this.invalidHandleTypes[type] = type;
16783 addInvalidHandleId: function(id) {
16784 if (typeof id !== "string") {
16787 this.invalidHandleIds[id] = id;
16791 addInvalidHandleClass: function(cssClass) {
16792 this.invalidHandleClasses.push(cssClass);
16796 removeInvalidHandleType: function(tagName) {
16797 var type = tagName.toUpperCase();
16799 delete this.invalidHandleTypes[type];
16803 removeInvalidHandleId: function(id) {
16804 if (typeof id !== "string") {
16807 delete this.invalidHandleIds[id];
16811 removeInvalidHandleClass: function(cssClass) {
16812 for (var i=0, len=this.invalidHandleClasses.length; i<len; ++i) {
16813 if (this.invalidHandleClasses[i] == cssClass) {
16814 delete this.invalidHandleClasses[i];
16820 isValidHandleChild: function(node) {
16826 nodeName = node.nodeName.toUpperCase();
16828 nodeName = node.nodeName;
16830 valid = valid && !this.invalidHandleTypes[nodeName];
16831 valid = valid && !this.invalidHandleIds[node.id];
16833 for (var i=0, len=this.invalidHandleClasses.length; valid && i<len; ++i) {
16834 valid = !Ext.fly(node).hasClass(this.invalidHandleClasses[i]);
16843 setXTicks: function(iStartX, iTickSize) {
16845 this.xTickSize = iTickSize;
16849 for (var i = this.initPageX; i >= this.minX; i = i - iTickSize) {
16851 this.xTicks[this.xTicks.length] = i;
16856 for (i = this.initPageX; i <= this.maxX; i = i + iTickSize) {
16858 this.xTicks[this.xTicks.length] = i;
16863 this.xTicks.sort(this.DDM.numericSort) ;
16867 setYTicks: function(iStartY, iTickSize) {
16869 this.yTickSize = iTickSize;
16873 for (var i = this.initPageY; i >= this.minY; i = i - iTickSize) {
16875 this.yTicks[this.yTicks.length] = i;
16880 for (i = this.initPageY; i <= this.maxY; i = i + iTickSize) {
16882 this.yTicks[this.yTicks.length] = i;
16887 this.yTicks.sort(this.DDM.numericSort) ;
16891 setXConstraint: function(iLeft, iRight, iTickSize) {
16892 this.leftConstraint = iLeft;
16893 this.rightConstraint = iRight;
16895 this.minX = this.initPageX - iLeft;
16896 this.maxX = this.initPageX + iRight;
16897 if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); }
16899 this.constrainX = true;
16903 clearConstraints: function() {
16904 this.constrainX = false;
16905 this.constrainY = false;
16910 clearTicks: function() {
16911 this.xTicks = null;
16912 this.yTicks = null;
16913 this.xTickSize = 0;
16914 this.yTickSize = 0;
16918 setYConstraint: function(iUp, iDown, iTickSize) {
16919 this.topConstraint = iUp;
16920 this.bottomConstraint = iDown;
16922 this.minY = this.initPageY - iUp;
16923 this.maxY = this.initPageY + iDown;
16924 if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); }
16926 this.constrainY = true;
16931 resetConstraints: function() {
16935 if (this.initPageX || this.initPageX === 0) {
16937 var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0;
16938 var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0;
16940 this.setInitPosition(dx, dy);
16944 this.setInitPosition();
16947 if (this.constrainX) {
16948 this.setXConstraint( this.leftConstraint,
16949 this.rightConstraint,
16953 if (this.constrainY) {
16954 this.setYConstraint( this.topConstraint,
16955 this.bottomConstraint,
16961 getTick: function(val, tickArray) {
16967 } else if (tickArray[0] >= val) {
16970 return tickArray[0];
16972 for (var i=0, len=tickArray.length; i<len; ++i) {
16974 if (tickArray[next] && tickArray[next] >= val) {
16975 var diff1 = val - tickArray[i];
16976 var diff2 = tickArray[next] - val;
16977 return (diff2 > diff1) ? tickArray[i] : tickArray[next];
16983 return tickArray[tickArray.length - 1];
16988 toString: function() {
16989 return ("DragDrop " + this.id);
16999 if (!Ext.dd.DragDropMgr) {
17002 Ext.dd.DragDropMgr = function() {
17004 var Event = Ext.EventManager;
17027 preventDefault: true,
17030 stopPropagation: true,
17033 initialized: false,
17040 this.initialized = true;
17053 _execOnAll: function(sMethod, args) {
17054 for (var i in this.ids) {
17055 for (var j in this.ids[i]) {
17056 var oDD = this.ids[i][j];
17057 if (! this.isTypeOfDD(oDD)) {
17060 oDD[sMethod].apply(oDD, args);
17066 _onLoad: function() {
17071 Event.on(document, "mouseup", this.handleMouseUp, this, true);
17072 Event.on(document, "mousemove", this.handleMouseMove, this, true);
17073 Event.on(window, "unload", this._onUnload, this, true);
17074 Event.on(window, "resize", this._onResize, this, true);
17080 _onResize: function(e) {
17081 this._execOnAll("resetConstraints", []);
17085 lock: function() { this.locked = true; },
17088 unlock: function() { this.locked = false; },
17091 isLocked: function() { return this.locked; },
17100 clickPixelThresh: 3,
17103 clickTimeThresh: 350,
17106 dragThreshMet: false,
17109 clickTimeout: null,
17118 regDragDrop: function(oDD, sGroup) {
17119 if (!this.initialized) { this.init(); }
17121 if (!this.ids[sGroup]) {
17122 this.ids[sGroup] = {};
17124 this.ids[sGroup][oDD.id] = oDD;
17128 removeDDFromGroup: function(oDD, sGroup) {
17129 if (!this.ids[sGroup]) {
17130 this.ids[sGroup] = {};
17133 var obj = this.ids[sGroup];
17134 if (obj && obj[oDD.id]) {
17135 delete obj[oDD.id];
17140 _remove: function(oDD) {
17141 for (var g in oDD.groups) {
17142 if (g && this.ids[g] && this.ids[g][oDD.id]) {
17143 delete this.ids[g][oDD.id];
17146 delete this.handleIds[oDD.id];
17150 regHandle: function(sDDId, sHandleId) {
17151 if (!this.handleIds[sDDId]) {
17152 this.handleIds[sDDId] = {};
17154 this.handleIds[sDDId][sHandleId] = sHandleId;
17158 isDragDrop: function(id) {
17159 return ( this.getDDById(id) ) ? true : false;
17163 getRelated: function(p_oDD, bTargetsOnly) {
17165 for (var i in p_oDD.groups) {
17166 for (var j in this.ids[i]) {
17167 var dd = this.ids[i][j];
17168 if (! this.isTypeOfDD(dd)) {
17171 if (!bTargetsOnly || dd.isTarget) {
17172 oDDs[oDDs.length] = dd;
17181 isLegalTarget: function (oDD, oTargetDD) {
17182 var targets = this.getRelated(oDD, true);
17183 for (var i=0, len=targets.length;i<len;++i) {
17184 if (targets[i].id == oTargetDD.id) {
17193 isTypeOfDD: function (oDD) {
17194 return (oDD && oDD.__ygDragDrop);
17198 isHandle: function(sDDId, sHandleId) {
17199 return ( this.handleIds[sDDId] &&
17200 this.handleIds[sDDId][sHandleId] );
17204 getDDById: function(id) {
17205 for (var i in this.ids) {
17206 if (this.ids[i][id]) {
17207 return this.ids[i][id];
17214 handleMouseDown: function(e, oDD) {
17216 Ext.QuickTips.disable();
17218 if(this.dragCurrent){
17221 this.handleMouseUp(e);
17224 this.currentTarget = e.getTarget();
17225 this.dragCurrent = oDD;
17227 var el = oDD.getEl();
17230 this.startX = e.getPageX();
17231 this.startY = e.getPageY();
17233 this.deltaX = this.startX - el.offsetLeft;
17234 this.deltaY = this.startY - el.offsetTop;
17236 this.dragThreshMet = false;
17238 this.clickTimeout = setTimeout(
17240 var DDM = Ext.dd.DDM;
17241 DDM.startDrag(DDM.startX, DDM.startY);
17243 this.clickTimeThresh );
17247 startDrag: function(x, y) {
17248 clearTimeout(this.clickTimeout);
17249 if (this.dragCurrent) {
17250 this.dragCurrent.b4StartDrag(x, y);
17251 this.dragCurrent.startDrag(x, y);
17253 this.dragThreshMet = true;
17257 handleMouseUp: function(e) {
17260 Ext.QuickTips.enable();
17262 if (! this.dragCurrent) {
17266 clearTimeout(this.clickTimeout);
17268 if (this.dragThreshMet) {
17269 this.fireEvents(e, true);
17279 stopEvent: function(e){
17280 if(this.stopPropagation) {
17281 e.stopPropagation();
17284 if (this.preventDefault) {
17285 e.preventDefault();
17290 stopDrag: function(e) {
17292 if (this.dragCurrent) {
17293 if (this.dragThreshMet) {
17294 this.dragCurrent.b4EndDrag(e);
17295 this.dragCurrent.endDrag(e);
17298 this.dragCurrent.onMouseUp(e);
17301 this.dragCurrent = null;
17302 this.dragOvers = {};
17306 handleMouseMove: function(e) {
17307 if (! this.dragCurrent) {
17313 if (Ext.isIE && (e.button !== 0 && e.button !== 1 && e.button !== 2)) {
17315 return this.handleMouseUp(e);
17318 if (!this.dragThreshMet) {
17319 var diffX = Math.abs(this.startX - e.getPageX());
17320 var diffY = Math.abs(this.startY - e.getPageY());
17321 if (diffX > this.clickPixelThresh ||
17322 diffY > this.clickPixelThresh) {
17323 this.startDrag(this.startX, this.startY);
17327 if (this.dragThreshMet) {
17328 this.dragCurrent.b4Drag(e);
17329 this.dragCurrent.onDrag(e);
17330 if(!this.dragCurrent.moveOnly){
17331 this.fireEvents(e, false);
17341 fireEvents: function(e, isDrop) {
17342 var dc = this.dragCurrent;
17346 if (!dc || dc.isLocked()) {
17350 var pt = e.getPoint();
17358 var enterEvts = [];
17362 for (var i in this.dragOvers) {
17364 var ddo = this.dragOvers[i];
17366 if (! this.isTypeOfDD(ddo)) {
17370 if (! this.isOverTarget(pt, ddo, this.mode)) {
17371 outEvts.push( ddo );
17374 oldOvers[i] = true;
17375 delete this.dragOvers[i];
17378 for (var sGroup in dc.groups) {
17380 if ("string" != typeof sGroup) {
17384 for (i in this.ids[sGroup]) {
17385 var oDD = this.ids[sGroup][i];
17386 if (! this.isTypeOfDD(oDD)) {
17390 if (oDD.isTarget && !oDD.isLocked() && ((oDD != dc) || (dc.ignoreSelf === false))) {
17391 if (this.isOverTarget(pt, oDD, this.mode)) {
17394 dropEvts.push( oDD );
17399 if (!oldOvers[oDD.id]) {
17400 enterEvts.push( oDD );
17403 overEvts.push( oDD );
17406 this.dragOvers[oDD.id] = oDD;
17414 if (outEvts.length) {
17415 dc.b4DragOut(e, outEvts);
17416 dc.onDragOut(e, outEvts);
17419 if (enterEvts.length) {
17420 dc.onDragEnter(e, enterEvts);
17423 if (overEvts.length) {
17424 dc.b4DragOver(e, overEvts);
17425 dc.onDragOver(e, overEvts);
17428 if (dropEvts.length) {
17429 dc.b4DragDrop(e, dropEvts);
17430 dc.onDragDrop(e, dropEvts);
17436 for (i=0, len=outEvts.length; i<len; ++i) {
17437 dc.b4DragOut(e, outEvts[i].id);
17438 dc.onDragOut(e, outEvts[i].id);
17442 for (i=0,len=enterEvts.length; i<len; ++i) {
17444 dc.onDragEnter(e, enterEvts[i].id);
17448 for (i=0,len=overEvts.length; i<len; ++i) {
17449 dc.b4DragOver(e, overEvts[i].id);
17450 dc.onDragOver(e, overEvts[i].id);
17454 for (i=0, len=dropEvts.length; i<len; ++i) {
17455 dc.b4DragDrop(e, dropEvts[i].id);
17456 dc.onDragDrop(e, dropEvts[i].id);
17462 if (isDrop && !dropEvts.length) {
17463 dc.onInvalidDrop(e);
17469 getBestMatch: function(dds) {
17477 var len = dds.length;
17483 for (var i=0; i<len; ++i) {
17488 if (dd.cursorIsOver) {
17494 winner.overlap.getArea() < dd.overlap.getArea()) {
17505 refreshCache: function(groups) {
17506 for (var sGroup in groups) {
17507 if ("string" != typeof sGroup) {
17510 for (var i in this.ids[sGroup]) {
17511 var oDD = this.ids[sGroup][i];
17513 if (this.isTypeOfDD(oDD)) {
17515 var loc = this.getLocation(oDD);
17517 this.locationCache[oDD.id] = loc;
17519 delete this.locationCache[oDD.id];
17530 verifyEl: function(el) {
17535 parent = el.offsetParent;
17538 parent = el.offsetParent;
17549 getLocation: function(oDD) {
17550 if (! this.isTypeOfDD(oDD)) {
17554 var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l;
17557 pos= Ext.lib.Dom.getXY(el);
17565 x2 = x1 + el.offsetWidth;
17567 y2 = y1 + el.offsetHeight;
17569 t = y1 - oDD.padding[0];
17570 r = x2 + oDD.padding[1];
17571 b = y2 + oDD.padding[2];
17572 l = x1 - oDD.padding[3];
17574 return new Ext.lib.Region( t, r, b, l );
17578 isOverTarget: function(pt, oTarget, intersect) {
17580 var loc = this.locationCache[oTarget.id];
17581 if (!loc || !this.useCache) {
17582 loc = this.getLocation(oTarget);
17583 this.locationCache[oTarget.id] = loc;
17591 oTarget.cursorIsOver = loc.contains( pt );
17598 var dc = this.dragCurrent;
17599 if (!dc || !dc.getTargetCoord ||
17600 (!intersect && !dc.constrainX && !dc.constrainY)) {
17601 return oTarget.cursorIsOver;
17604 oTarget.overlap = null;
17610 var pos = dc.getTargetCoord(pt.x, pt.y);
17612 var el = dc.getDragEl();
17613 var curRegion = new Ext.lib.Region( pos.y,
17614 pos.x + el.offsetWidth,
17615 pos.y + el.offsetHeight,
17618 var overlap = curRegion.intersect(loc);
17621 oTarget.overlap = overlap;
17622 return (intersect) ? true : oTarget.cursorIsOver;
17629 _onUnload: function(e, me) {
17630 Ext.dd.DragDropMgr.unregAll();
17634 unregAll: function() {
17636 if (this.dragCurrent) {
17638 this.dragCurrent = null;
17641 this._execOnAll("unreg", []);
17643 for (var i in this.elementCache) {
17644 delete this.elementCache[i];
17647 this.elementCache = {};
17655 getElWrapper: function(id) {
17656 var oWrapper = this.elementCache[id];
17657 if (!oWrapper || !oWrapper.el) {
17658 oWrapper = this.elementCache[id] =
17659 new this.ElementWrapper(Ext.getDom(id));
17665 getElement: function(id) {
17666 return Ext.getDom(id);
17670 getCss: function(id) {
17671 var el = Ext.getDom(id);
17672 return (el) ? el.style : null;
17676 ElementWrapper: function(el) {
17678 this.el = el || null;
17680 this.id = this.el && el.id;
17682 this.css = this.el && el.style;
17686 getPosX: function(el) {
17687 return Ext.lib.Dom.getX(el);
17691 getPosY: function(el) {
17692 return Ext.lib.Dom.getY(el);
17696 swapNode: function(n1, n2) {
17700 var p = n2.parentNode;
17701 var s = n2.nextSibling;
17704 p.insertBefore(n1, n2);
17705 } else if (n2 == n1.nextSibling) {
17706 p.insertBefore(n2, n1);
17708 n1.parentNode.replaceChild(n2, n1);
17709 p.insertBefore(n1, s);
17715 getScroll: function () {
17716 var t, l, dde=document.documentElement, db=document.body;
17717 if (dde && (dde.scrollTop || dde.scrollLeft)) {
17719 l = dde.scrollLeft;
17726 return { top: t, left: l };
17730 getStyle: function(el, styleProp) {
17731 return Ext.fly(el).getStyle(styleProp);
17735 getScrollTop: function () { return this.getScroll().top; },
17738 getScrollLeft: function () { return this.getScroll().left; },
17741 moveToEl: function (moveEl, targetEl) {
17742 var aCoord = Ext.lib.Dom.getXY(targetEl);
17743 Ext.lib.Dom.setXY(moveEl, aCoord);
17747 numericSort: function(a, b) { return (a - b); },
17753 _addListeners: function() {
17754 var DDM = Ext.dd.DDM;
17755 if ( Ext.lib.Event && document ) {
17758 if (DDM._timeoutCount > 2000) {
17760 setTimeout(DDM._addListeners, 10);
17761 if (document && document.body) {
17762 DDM._timeoutCount += 1;
17769 handleWasClicked: function(node, id) {
17770 if (this.isHandle(id, node.id)) {
17774 var p = node.parentNode;
17777 if (this.isHandle(id, p.id)) {
17793 Ext.dd.DDM = Ext.dd.DragDropMgr;
17794 Ext.dd.DDM._addListeners();
17799 Ext.dd.DD = function(id, sGroup, config) {
17801 this.init(id, sGroup, config);
17805 Ext.extend(Ext.dd.DD, Ext.dd.DragDrop, {
17811 autoOffset: function(iPageX, iPageY) {
17812 var x = iPageX - this.startPageX;
17813 var y = iPageY - this.startPageY;
17814 this.setDelta(x, y);
17818 setDelta: function(iDeltaX, iDeltaY) {
17819 this.deltaX = iDeltaX;
17820 this.deltaY = iDeltaY;
17824 setDragElPos: function(iPageX, iPageY) {
17828 var el = this.getDragEl();
17829 this.alignElWithMouse(el, iPageX, iPageY);
17833 alignElWithMouse: function(el, iPageX, iPageY) {
17834 var oCoord = this.getTargetCoord(iPageX, iPageY);
17835 var fly = el.dom ? el : Ext.fly(el, '_dd');
17836 if (!this.deltaSetXY) {
17837 var aCoord = [oCoord.x, oCoord.y];
17839 var newLeft = fly.getLeft(true);
17840 var newTop = fly.getTop(true);
17841 this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ];
17843 fly.setLeftTop(oCoord.x + this.deltaSetXY[0], oCoord.y + this.deltaSetXY[1]);
17846 this.cachePosition(oCoord.x, oCoord.y);
17847 this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
17852 cachePosition: function(iPageX, iPageY) {
17854 this.lastPageX = iPageX;
17855 this.lastPageY = iPageY;
17857 var aCoord = Ext.lib.Dom.getXY(this.getEl());
17858 this.lastPageX = aCoord[0];
17859 this.lastPageY = aCoord[1];
17864 autoScroll: function(x, y, h, w) {
17868 var clientH = Ext.lib.Dom.getViewHeight();
17871 var clientW = Ext.lib.Dom.getViewWidth();
17874 var st = this.DDM.getScrollTop();
17877 var sl = this.DDM.getScrollLeft();
17888 var toBot = (clientH + st - y - this.deltaY);
17891 var toRight = (clientW + sl - x - this.deltaX);
17901 var scrAmt = (document.all) ? 80 : 30;
17905 if ( bot > clientH && toBot < thresh ) {
17906 window.scrollTo(sl, st + scrAmt);
17911 if ( y < st && st > 0 && y - st < thresh ) {
17912 window.scrollTo(sl, st - scrAmt);
17917 if ( right > clientW && toRight < thresh ) {
17918 window.scrollTo(sl + scrAmt, st);
17923 if ( x < sl && sl > 0 && x - sl < thresh ) {
17924 window.scrollTo(sl - scrAmt, st);
17930 getTargetCoord: function(iPageX, iPageY) {
17933 var x = iPageX - this.deltaX;
17934 var y = iPageY - this.deltaY;
17936 if (this.constrainX) {
17937 if (x < this.minX) { x = this.minX; }
17938 if (x > this.maxX) { x = this.maxX; }
17941 if (this.constrainY) {
17942 if (y < this.minY) { y = this.minY; }
17943 if (y > this.maxY) { y = this.maxY; }
17946 x = this.getTick(x, this.xTicks);
17947 y = this.getTick(y, this.yTicks);
17954 applyConfig: function() {
17955 Ext.dd.DD.superclass.applyConfig.call(this);
17956 this.scroll = (this.config.scroll !== false);
17960 b4MouseDown: function(e) {
17962 this.autoOffset(e.getPageX(),
17967 b4Drag: function(e) {
17968 this.setDragElPos(e.getPageX(),
17972 toString: function() {
17973 return ("DD " + this.id);
17983 Ext.dd.DDProxy = function(id, sGroup, config) {
17985 this.init(id, sGroup, config);
17991 Ext.dd.DDProxy.dragElId = "ygddfdiv";
17993 Ext.extend(Ext.dd.DDProxy, Ext.dd.DD, {
17999 centerFrame: false,
18002 createFrame: function() {
18004 var body = document.body;
18006 if (!body || !body.firstChild) {
18007 setTimeout( function() { self.createFrame(); }, 50 );
18011 var div = this.getDragEl();
18014 div = document.createElement("div");
18015 div.id = this.dragElId;
18018 s.position = "absolute";
18019 s.visibility = "hidden";
18021 s.border = "2px solid #aaa";
18027 body.insertBefore(div, body.firstChild);
18032 initFrame: function() {
18033 this.createFrame();
18036 applyConfig: function() {
18037 Ext.dd.DDProxy.superclass.applyConfig.call(this);
18039 this.resizeFrame = (this.config.resizeFrame !== false);
18040 this.centerFrame = (this.config.centerFrame);
18041 this.setDragElId(this.config.dragElId || Ext.dd.DDProxy.dragElId);
18045 showFrame: function(iPageX, iPageY) {
18046 var el = this.getEl();
18047 var dragEl = this.getDragEl();
18048 var s = dragEl.style;
18050 this._resizeProxy();
18052 if (this.centerFrame) {
18053 this.setDelta( Math.round(parseInt(s.width, 10)/2),
18054 Math.round(parseInt(s.height, 10)/2) );
18057 this.setDragElPos(iPageX, iPageY);
18059 Ext.fly(dragEl).show();
18063 _resizeProxy: function() {
18064 if (this.resizeFrame) {
18065 var el = this.getEl();
18066 Ext.fly(this.getDragEl()).setSize(el.offsetWidth, el.offsetHeight);
18071 b4MouseDown: function(e) {
18072 var x = e.getPageX();
18073 var y = e.getPageY();
18074 this.autoOffset(x, y);
18075 this.setDragElPos(x, y);
18079 b4StartDrag: function(x, y) {
18081 this.showFrame(x, y);
18085 b4EndDrag: function(e) {
18086 Ext.fly(this.getDragEl()).hide();
18092 endDrag: function(e) {
18094 var lel = this.getEl();
18095 var del = this.getDragEl();
18098 del.style.visibility = "";
18103 lel.style.visibility = "hidden";
18104 Ext.dd.DDM.moveToEl(lel, del);
18105 del.style.visibility = "hidden";
18106 lel.style.visibility = "";
18111 beforeMove : function(){
18115 afterDrag : function(){
18119 toString: function() {
18120 return ("DDProxy " + this.id);
18125 Ext.dd.DDTarget = function(id, sGroup, config) {
18127 this.initTarget(id, sGroup, config);
18132 Ext.extend(Ext.dd.DDTarget, Ext.dd.DragDrop, {
18134 getDragEl: Ext.emptyFn,
18136 isValidHandleChild: Ext.emptyFn,
18138 startDrag: Ext.emptyFn,
18140 endDrag: Ext.emptyFn,
18142 onDrag: Ext.emptyFn,
18144 onDragDrop: Ext.emptyFn,
18146 onDragEnter: Ext.emptyFn,
18148 onDragOut: Ext.emptyFn,
18150 onDragOver: Ext.emptyFn,
18152 onInvalidDrop: Ext.emptyFn,
18154 onMouseDown: Ext.emptyFn,
18156 onMouseUp: Ext.emptyFn,
18158 setXConstraint: Ext.emptyFn,
18160 setYConstraint: Ext.emptyFn,
18162 resetConstraints: Ext.emptyFn,
18164 clearConstraints: Ext.emptyFn,
18166 clearTicks: Ext.emptyFn,
18168 setInitPosition: Ext.emptyFn,
18170 setDragElId: Ext.emptyFn,
18172 setHandleElId: Ext.emptyFn,
18174 setOuterHandleElId: Ext.emptyFn,
18176 addInvalidHandleClass: Ext.emptyFn,
18178 addInvalidHandleId: Ext.emptyFn,
18180 addInvalidHandleType: Ext.emptyFn,
18182 removeInvalidHandleClass: Ext.emptyFn,
18184 removeInvalidHandleId: Ext.emptyFn,
18186 removeInvalidHandleType: Ext.emptyFn,
18188 toString: function() {
18189 return ("DDTarget " + this.id);
18192 Ext.dd.DragTracker = Ext.extend(Ext.util.Observable, {
18200 constructor : function(config){
18201 Ext.apply(this, config);
18217 this.dragRegion = new Ext.lib.Region(0,0,0,0);
18220 this.initEl(this.el);
18222 Ext.dd.DragTracker.superclass.constructor.call(this, config);
18225 initEl: function(el){
18226 this.el = Ext.get(el);
18227 el.on('mousedown', this.onMouseDown, this,
18228 this.delegate ? {delegate: this.delegate} : undefined);
18231 destroy : function(){
18232 this.el.un('mousedown', this.onMouseDown, this);
18235 onMouseDown: function(e, target){
18236 if(this.fireEvent('mousedown', this, e) !== false && this.onBeforeStart(e) !== false){
18237 this.startXY = this.lastXY = e.getXY();
18238 this.dragTarget = this.delegate ? target : this.el.dom;
18239 if(this.preventDefault !== false){
18240 e.preventDefault();
18242 var doc = Ext.getDoc();
18243 doc.on('mouseup', this.onMouseUp, this);
18244 doc.on('mousemove', this.onMouseMove, this);
18245 doc.on('selectstart', this.stopSelect, this);
18246 if(this.autoStart){
18247 this.timer = this.triggerStart.defer(this.autoStart === true ? 1000 : this.autoStart, this);
18252 onMouseMove: function(e, target){
18254 if(this.active && Ext.isIE && !e.browserEvent.button){
18255 e.preventDefault();
18260 e.preventDefault();
18261 var xy = e.getXY(), s = this.startXY;
18264 if(Math.abs(s[0]-xy[0]) > this.tolerance || Math.abs(s[1]-xy[1]) > this.tolerance){
18265 this.triggerStart();
18270 this.fireEvent('mousemove', this, e);
18272 this.fireEvent('drag', this, e);
18275 onMouseUp: function(e){
18276 var doc = Ext.getDoc();
18277 doc.un('mousemove', this.onMouseMove, this);
18278 doc.un('mouseup', this.onMouseUp, this);
18279 doc.un('selectstart', this.stopSelect, this);
18280 e.preventDefault();
18282 var wasActive = this.active;
18283 this.active = false;
18284 delete this.elRegion;
18285 this.fireEvent('mouseup', this, e);
18288 this.fireEvent('dragend', this, e);
18292 triggerStart: function(isTimer){
18294 this.active = true;
18295 this.onStart(this.startXY);
18296 this.fireEvent('dragstart', this, this.startXY);
18299 clearStart : function(){
18301 clearTimeout(this.timer);
18306 stopSelect : function(e){
18311 onBeforeStart : function(e){
18315 onStart : function(xy){
18319 onDrag : function(e){
18323 onEnd : function(e){
18327 getDragTarget : function(){
18328 return this.dragTarget;
18331 getDragCt : function(){
18335 getXY : function(constrain){
18337 this.constrainModes[constrain].call(this, this.lastXY) : this.lastXY;
18340 getOffset : function(constrain){
18341 var xy = this.getXY(constrain);
18342 var s = this.startXY;
18343 return [s[0]-xy[0], s[1]-xy[1]];
18347 'point' : function(xy){
18349 if(!this.elRegion){
18350 this.elRegion = this.getDragCt().getRegion();
18353 var dr = this.dragRegion;
18360 dr.constrainTo(this.elRegion);
18362 return [dr.left, dr.top];
18366 Ext.dd.ScrollManager = function(){
18367 var ddm = Ext.dd.DragDropMgr;
18372 var onStop = function(e){
18377 var triggerRefresh = function(){
18378 if(ddm.dragCurrent){
18379 ddm.refreshCache(ddm.dragCurrent.groups);
18383 var doScroll = function(){
18384 if(ddm.dragCurrent){
18385 var dds = Ext.dd.ScrollManager;
18386 var inc = proc.el.ddScrollConfig ?
18387 proc.el.ddScrollConfig.increment : dds.increment;
18389 if(proc.el.scroll(proc.dir, inc)){
18393 proc.el.scroll(proc.dir, inc, true, dds.animDuration, triggerRefresh);
18398 var clearProc = function(){
18400 clearInterval(proc.id);
18407 var startProc = function(el, dir){
18411 var freq = (el.ddScrollConfig && el.ddScrollConfig.frequency) ?
18412 el.ddScrollConfig.frequency : Ext.dd.ScrollManager.frequency;
18413 proc.id = setInterval(doScroll, freq);
18416 var onFire = function(e, isDrop){
18417 if(isDrop || !ddm.dragCurrent){ return; }
18418 var dds = Ext.dd.ScrollManager;
18419 if(!dragEl || dragEl != ddm.dragCurrent){
18420 dragEl = ddm.dragCurrent;
18422 dds.refreshCache();
18425 var xy = Ext.lib.Event.getXY(e);
18426 var pt = new Ext.lib.Point(xy[0], xy[1]);
18427 for(var id in els){
18428 var el = els[id], r = el._region;
18429 var c = el.ddScrollConfig ? el.ddScrollConfig : dds;
18430 if(r && r.contains(pt) && el.isScrollable()){
18431 if(r.bottom - pt.y <= c.vthresh){
18433 startProc(el, "down");
18436 }else if(r.right - pt.x <= c.hthresh){
18438 startProc(el, "left");
18441 }else if(pt.y - r.top <= c.vthresh){
18443 startProc(el, "up");
18446 }else if(pt.x - r.left <= c.hthresh){
18448 startProc(el, "right");
18457 ddm.fireEvents = ddm.fireEvents.createSequence(onFire, ddm);
18458 ddm.stopDrag = ddm.stopDrag.createSequence(onStop, ddm);
18462 register : function(el){
18463 if(Ext.isArray(el)){
18464 for(var i = 0, len = el.length; i < len; i++) {
18465 this.register(el[i]);
18474 unregister : function(el){
18475 if(Ext.isArray(el)){
18476 for(var i = 0, len = el.length; i < len; i++) {
18477 this.unregister(el[i]);
18503 refreshCache : function(){
18504 for(var id in els){
18505 if(typeof els[id] == 'object'){
18506 els[id]._region = els[id].getRegion();
18512 Ext.dd.Registry = function(){
18515 var autoIdSeed = 0;
18517 var getId = function(el, autogen){
18518 if(typeof el == "string"){
18522 if(!id && autogen !== false){
18523 id = "extdd-" + (++autoIdSeed);
18531 register : function(el, data){
18533 if(typeof el == "string"){
18534 el = document.getElementById(el);
18537 elements[getId(el)] = data;
18538 if(data.isHandle !== false){
18539 handles[data.ddel.id] = data;
18542 var hs = data.handles;
18543 for(var i = 0, len = hs.length; i < len; i++){
18544 handles[getId(hs[i])] = data;
18550 unregister : function(el){
18551 var id = getId(el, false);
18552 var data = elements[id];
18554 delete elements[id];
18556 var hs = data.handles;
18557 for(var i = 0, len = hs.length; i < len; i++){
18558 delete handles[getId(hs[i], false)];
18565 getHandle : function(id){
18566 if(typeof id != "string"){
18569 return handles[id];
18573 getHandleFromEvent : function(e){
18574 var t = Ext.lib.Event.getTarget(e);
18575 return t ? handles[t.id] : null;
18579 getTarget : function(id){
18580 if(typeof id != "string"){
18583 return elements[id];
18587 getTargetFromEvent : function(e){
18588 var t = Ext.lib.Event.getTarget(e);
18589 return t ? elements[t.id] || handles[t.id] : null;
18593 Ext.dd.StatusProxy = function(config){
18594 Ext.apply(this, config);
18595 this.id = this.id || Ext.id();
18596 this.el = new Ext.Layer({
18598 id: this.id, tag: "div", cls: "x-dd-drag-proxy "+this.dropNotAllowed, children: [
18599 {tag: "div", cls: "x-dd-drop-icon"},
18600 {tag: "div", cls: "x-dd-drag-ghost"}
18603 shadow: !config || config.shadow !== false
18605 this.ghost = Ext.get(this.el.dom.childNodes[1]);
18606 this.dropStatus = this.dropNotAllowed;
18609 Ext.dd.StatusProxy.prototype = {
18611 dropAllowed : "x-dd-drop-ok",
18613 dropNotAllowed : "x-dd-drop-nodrop",
18616 setStatus : function(cssClass){
18617 cssClass = cssClass || this.dropNotAllowed;
18618 if(this.dropStatus != cssClass){
18619 this.el.replaceClass(this.dropStatus, cssClass);
18620 this.dropStatus = cssClass;
18625 reset : function(clearGhost){
18626 this.el.dom.className = "x-dd-drag-proxy " + this.dropNotAllowed;
18627 this.dropStatus = this.dropNotAllowed;
18629 this.ghost.update("");
18634 update : function(html){
18635 if(typeof html == "string"){
18636 this.ghost.update(html);
18638 this.ghost.update("");
18639 html.style.margin = "0";
18640 this.ghost.dom.appendChild(html);
18642 var el = this.ghost.dom.firstChild;
18644 Ext.fly(el).setStyle('float', 'none');
18649 getEl : function(){
18654 getGhost : function(){
18659 hide : function(clear){
18668 if(this.anim && this.anim.isAnimated && this.anim.isAnimated()){
18684 repair : function(xy, callback, scope){
18685 this.callback = callback;
18686 this.scope = scope;
18687 if(xy && this.animRepair !== false){
18688 this.el.addClass("x-dd-drag-repair");
18689 this.el.hideUnders(true);
18690 this.anim = this.el.shift({
18691 duration: this.repairDuration || .5,
18695 callback: this.afterRepair,
18699 this.afterRepair();
18704 afterRepair : function(){
18706 if(typeof this.callback == "function"){
18707 this.callback.call(this.scope || this);
18709 this.callback = null;
18713 destroy: function(){
18714 Ext.destroy(this.ghost, this.el);
18717 Ext.dd.DragSource = function(el, config){
18718 this.el = Ext.get(el);
18719 if(!this.dragData){
18720 this.dragData = {};
18723 Ext.apply(this, config);
18726 this.proxy = new Ext.dd.StatusProxy();
18728 Ext.dd.DragSource.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group,
18729 {dragElId : this.proxy.id, resizeFrame: false, isTarget: false, scroll: this.scroll === true});
18731 this.dragging = false;
18734 Ext.extend(Ext.dd.DragSource, Ext.dd.DDProxy, {
18737 dropAllowed : "x-dd-drop-ok",
18739 dropNotAllowed : "x-dd-drop-nodrop",
18742 getDragData : function(e){
18743 return this.dragData;
18747 onDragEnter : function(e, id){
18748 var target = Ext.dd.DragDropMgr.getDDById(id);
18749 this.cachedTarget = target;
18750 if(this.beforeDragEnter(target, e, id) !== false){
18751 if(target.isNotifyTarget){
18752 var status = target.notifyEnter(this, e, this.dragData);
18753 this.proxy.setStatus(status);
18755 this.proxy.setStatus(this.dropAllowed);
18758 if(this.afterDragEnter){
18760 this.afterDragEnter(target, e, id);
18766 beforeDragEnter : function(target, e, id){
18771 alignElWithMouse: function() {
18772 Ext.dd.DragSource.superclass.alignElWithMouse.apply(this, arguments);
18777 onDragOver : function(e, id){
18778 var target = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(id);
18779 if(this.beforeDragOver(target, e, id) !== false){
18780 if(target.isNotifyTarget){
18781 var status = target.notifyOver(this, e, this.dragData);
18782 this.proxy.setStatus(status);
18785 if(this.afterDragOver){
18787 this.afterDragOver(target, e, id);
18793 beforeDragOver : function(target, e, id){
18798 onDragOut : function(e, id){
18799 var target = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(id);
18800 if(this.beforeDragOut(target, e, id) !== false){
18801 if(target.isNotifyTarget){
18802 target.notifyOut(this, e, this.dragData);
18804 this.proxy.reset();
18805 if(this.afterDragOut){
18807 this.afterDragOut(target, e, id);
18810 this.cachedTarget = null;
18814 beforeDragOut : function(target, e, id){
18819 onDragDrop : function(e, id){
18820 var target = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(id);
18821 if(this.beforeDragDrop(target, e, id) !== false){
18822 if(target.isNotifyTarget){
18823 if(target.notifyDrop(this, e, this.dragData)){
18824 this.onValidDrop(target, e, id);
18826 this.onInvalidDrop(target, e, id);
18829 this.onValidDrop(target, e, id);
18832 if(this.afterDragDrop){
18834 this.afterDragDrop(target, e, id);
18837 delete this.cachedTarget;
18841 beforeDragDrop : function(target, e, id){
18846 onValidDrop : function(target, e, id){
18848 if(this.afterValidDrop){
18850 this.afterValidDrop(target, e, id);
18855 getRepairXY : function(e, data){
18856 return this.el.getXY();
18860 onInvalidDrop : function(target, e, id){
18861 this.beforeInvalidDrop(target, e, id);
18862 if(this.cachedTarget){
18863 if(this.cachedTarget.isNotifyTarget){
18864 this.cachedTarget.notifyOut(this, e, this.dragData);
18866 this.cacheTarget = null;
18868 this.proxy.repair(this.getRepairXY(e, this.dragData), this.afterRepair, this);
18870 if(this.afterInvalidDrop){
18872 this.afterInvalidDrop(e, id);
18877 afterRepair : function(){
18879 this.el.highlight(this.hlColor || "c3daf9");
18881 this.dragging = false;
18885 beforeInvalidDrop : function(target, e, id){
18890 handleMouseDown : function(e){
18891 if(this.dragging) {
18894 var data = this.getDragData(e);
18895 if(data && this.onBeforeDrag(data, e) !== false){
18896 this.dragData = data;
18898 Ext.dd.DragSource.superclass.handleMouseDown.apply(this, arguments);
18903 onBeforeDrag : function(data, e){
18908 onStartDrag : Ext.emptyFn,
18911 startDrag : function(x, y){
18912 this.proxy.reset();
18913 this.dragging = true;
18914 this.proxy.update("");
18915 this.onInitDrag(x, y);
18920 onInitDrag : function(x, y){
18921 var clone = this.el.dom.cloneNode(true);
18922 clone.id = Ext.id();
18923 this.proxy.update(clone);
18924 this.onStartDrag(x, y);
18929 getProxy : function(){
18934 hideProxy : function(){
18936 this.proxy.reset(true);
18937 this.dragging = false;
18941 triggerCacheRefresh : function(){
18942 Ext.dd.DDM.refreshCache(this.groups);
18946 b4EndDrag: function(e) {
18950 endDrag : function(e){
18951 this.onEndDrag(this.dragData, e);
18955 onEndDrag : function(data, e){
18959 autoOffset : function(x, y) {
18960 this.setDelta(-12, -20);
18963 destroy: function(){
18964 Ext.dd.DragSource.superclass.destroy.call(this);
18965 Ext.destroy(this.proxy);
18968 Ext.dd.DropTarget = function(el, config){
18969 this.el = Ext.get(el);
18971 Ext.apply(this, config);
18973 if(this.containerScroll){
18974 Ext.dd.ScrollManager.register(this.el);
18977 Ext.dd.DropTarget.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group,
18982 Ext.extend(Ext.dd.DropTarget, Ext.dd.DDTarget, {
18986 dropAllowed : "x-dd-drop-ok",
18988 dropNotAllowed : "x-dd-drop-nodrop",
18994 isNotifyTarget : true,
18997 notifyEnter : function(dd, e, data){
18998 if(this.overClass){
18999 this.el.addClass(this.overClass);
19001 return this.dropAllowed;
19005 notifyOver : function(dd, e, data){
19006 return this.dropAllowed;
19010 notifyOut : function(dd, e, data){
19011 if(this.overClass){
19012 this.el.removeClass(this.overClass);
19017 notifyDrop : function(dd, e, data){
19021 Ext.dd.DragZone = function(el, config){
19022 Ext.dd.DragZone.superclass.constructor.call(this, el, config);
19023 if(this.containerScroll){
19024 Ext.dd.ScrollManager.register(this.el);
19028 Ext.extend(Ext.dd.DragZone, Ext.dd.DragSource, {
19034 getDragData : function(e){
19035 return Ext.dd.Registry.getHandleFromEvent(e);
19039 onInitDrag : function(x, y){
19040 this.proxy.update(this.dragData.ddel.cloneNode(true));
19041 this.onStartDrag(x, y);
19046 afterRepair : function(){
19048 Ext.Element.fly(this.dragData.ddel).highlight(this.hlColor || "c3daf9");
19050 this.dragging = false;
19054 getRepairXY : function(e){
19055 return Ext.Element.fly(this.dragData.ddel).getXY();
19058 Ext.dd.DropZone = function(el, config){
19059 Ext.dd.DropZone.superclass.constructor.call(this, el, config);
19062 Ext.extend(Ext.dd.DropZone, Ext.dd.DropTarget, {
19064 getTargetFromEvent : function(e){
19065 return Ext.dd.Registry.getTargetFromEvent(e);
19069 onNodeEnter : function(n, dd, e, data){
19074 onNodeOver : function(n, dd, e, data){
19075 return this.dropAllowed;
19079 onNodeOut : function(n, dd, e, data){
19084 onNodeDrop : function(n, dd, e, data){
19089 onContainerOver : function(dd, e, data){
19090 return this.dropNotAllowed;
19094 onContainerDrop : function(dd, e, data){
19099 notifyEnter : function(dd, e, data){
19100 return this.dropNotAllowed;
19104 notifyOver : function(dd, e, data){
19105 var n = this.getTargetFromEvent(e);
19107 if(this.lastOverNode){
19108 this.onNodeOut(this.lastOverNode, dd, e, data);
19109 this.lastOverNode = null;
19111 return this.onContainerOver(dd, e, data);
19113 if(this.lastOverNode != n){
19114 if(this.lastOverNode){
19115 this.onNodeOut(this.lastOverNode, dd, e, data);
19117 this.onNodeEnter(n, dd, e, data);
19118 this.lastOverNode = n;
19120 return this.onNodeOver(n, dd, e, data);
19124 notifyOut : function(dd, e, data){
19125 if(this.lastOverNode){
19126 this.onNodeOut(this.lastOverNode, dd, e, data);
19127 this.lastOverNode = null;
19132 notifyDrop : function(dd, e, data){
19133 if(this.lastOverNode){
19134 this.onNodeOut(this.lastOverNode, dd, e, data);
19135 this.lastOverNode = null;
19137 var n = this.getTargetFromEvent(e);
19139 this.onNodeDrop(n, dd, e, data) :
19140 this.onContainerDrop(dd, e, data);
19144 triggerCacheRefresh : function(){
19145 Ext.dd.DDM.refreshCache(this.groups);
19148 Ext.Element.addMethods({
19150 initDD : function(group, config, overrides){
19151 var dd = new Ext.dd.DD(Ext.id(this.dom), group, config);
19152 return Ext.apply(dd, overrides);
19156 initDDProxy : function(group, config, overrides){
19157 var dd = new Ext.dd.DDProxy(Ext.id(this.dom), group, config);
19158 return Ext.apply(dd, overrides);
19162 initDDTarget : function(group, config, overrides){
19163 var dd = new Ext.dd.DDTarget(Ext.id(this.dom), group, config);
19164 return Ext.apply(dd, overrides);
19168 Ext.data.Api = (function() {
19174 var validActions = {};
19182 destroy : 'destroy'
19194 isAction : function(action) {
19195 return (Ext.data.Api.actions[action]) ? true : false;
19199 getVerb : function(name) {
19200 if (validActions[name]) {
19201 return validActions[name];
19203 for (var verb in this.actions) {
19204 if (this.actions[verb] === name) {
19205 validActions[name] = verb;
19209 return (validActions[name] !== undefined) ? validActions[name] : null;
19213 isValid : function(api){
19215 var crud = this.actions;
19216 for (var action in api) {
19217 if (!(action in crud)) {
19218 invalid.push(action);
19221 return (!invalid.length) ? true : invalid;
19225 hasUniqueUrl : function(proxy, verb) {
19226 var url = (proxy.api[verb]) ? proxy.api[verb].url : null;
19228 for (var action in proxy.api) {
19229 if ((unique = (action === verb) ? true : (proxy.api[action].url != url) ? true : false) === false) {
19237 prepare : function(proxy) {
19241 for (var verb in this.actions) {
19242 var action = this.actions[verb];
19243 proxy.api[action] = proxy.api[action] || proxy.url || proxy.directFn;
19244 if (typeof(proxy.api[action]) == 'string') {
19245 proxy.api[action] = {
19246 url: proxy.api[action],
19247 method: (proxy.restful === true) ? Ext.data.Api.restActions[action] : undefined
19254 restify : function(proxy) {
19255 proxy.restful = true;
19256 for (var verb in this.restActions) {
19257 proxy.api[this.actions[verb]].method = this.restActions[verb];
19261 proxy.onWrite = proxy.onWrite.createInterceptor(function(action, o, response, rs) {
19262 var reader = o.reader;
19263 var res = new Ext.data.Response({
19268 switch (response.status) {
19273 res.success = true;
19276 res.success = true;
19283 if (res.success === true) {
19284 this.fireEvent("write", this, action, res.data, res, rs, o.request.arg);
19286 this.fireEvent('exception', this, 'remote', action, o, res, rs);
19288 o.request.callback.call(o.request.scope, res.data, res, res.success);
19297 Ext.data.Response = function(params, response) {
19298 Ext.apply(this, params, {
19302 Ext.data.Response.prototype = {
19309 getMessage : function() {
19310 return this.message;
19312 getSuccess : function() {
19313 return this.success;
19315 getStatus : function() {
19318 getRoot : function() {
19321 getRawResponse : function() {
19327 Ext.data.Api.Error = Ext.extend(Ext.Error, {
19328 constructor : function(message, arg) {
19330 Ext.Error.call(this, message);
19332 name: 'Ext.data.Api'
19334 Ext.apply(Ext.data.Api.Error.prototype, {
19336 'action-url-undefined': 'No fallback url defined for this action. When defining a DataProxy api, please be sure to define an url for each CRUD action in Ext.data.Api.actions or define a default url in addition to your api-configuration.',
19337 'invalid': 'received an invalid API-configuration. Please ensure your proxy API-configuration contains only the actions defined in Ext.data.Api.actions',
19338 'invalid-url': 'Invalid url. Please review your proxy configuration.',
19339 'execute': 'Attempted to execute an unknown action. Valid API actions are defined in Ext.data.Api.actions"'
19346 Ext.data.SortTypes = {
19348 none : function(s){
19353 stripTagsRE : /<\/?[^>]+>/gi,
19356 asText : function(s){
19357 return String(s).replace(this.stripTagsRE, "");
19361 asUCText : function(s){
19362 return String(s).toUpperCase().replace(this.stripTagsRE, "");
19366 asUCString : function(s) {
19367 return String(s).toUpperCase();
19371 asDate : function(s) {
19376 return s.getTime();
19378 return Date.parse(String(s));
19382 asFloat : function(s) {
19383 var val = parseFloat(String(s).replace(/,/g, ""));
19384 return isNaN(val) ? 0 : val;
19388 asInt : function(s) {
19389 var val = parseInt(String(s).replace(/,/g, ""), 10);
19390 return isNaN(val) ? 0 : val;
19393 Ext.data.Record = function(data, id){
19395 this.id = (id || id === 0) ? id : Ext.data.Record.id(this);
19396 this.data = data || {};
19400 Ext.data.Record.create = function(o){
19401 var f = Ext.extend(Ext.data.Record, {});
19402 var p = f.prototype;
19403 p.fields = new Ext.util.MixedCollection(false, function(field){
19406 for(var i = 0, len = o.length; i < len; i++){
19407 p.fields.add(new Ext.data.Field(o[i]));
19409 f.getField = function(name){
19410 return p.fields.get(name);
19415 Ext.data.Record.PREFIX = 'ext-record';
19416 Ext.data.Record.AUTO_ID = 1;
19417 Ext.data.Record.EDIT = 'edit';
19418 Ext.data.Record.REJECT = 'reject';
19419 Ext.data.Record.COMMIT = 'commit';
19423 Ext.data.Record.id = function(rec) {
19424 rec.phantom = true;
19425 return [Ext.data.Record.PREFIX, '-', Ext.data.Record.AUTO_ID++].join('');
19428 Ext.data.Record.prototype = {
19444 join : function(store){
19446 this.store = store;
19450 set : function(name, value){
19451 var encode = Ext.isPrimitive(value) ? String : Ext.encode;
19452 if(encode(this.data[name]) == encode(value)) {
19456 if(!this.modified){
19457 this.modified = {};
19459 if(this.modified[name] === undefined){
19460 this.modified[name] = this.data[name];
19462 this.data[name] = value;
19469 afterEdit : function(){
19471 this.store.afterEdit(this);
19476 afterReject : function(){
19478 this.store.afterReject(this);
19483 afterCommit : function(){
19485 this.store.afterCommit(this);
19490 get : function(name){
19491 return this.data[name];
19495 beginEdit : function(){
19496 this.editing = true;
19497 this.modified = this.modified || {};
19501 cancelEdit : function(){
19502 this.editing = false;
19503 delete this.modified;
19507 endEdit : function(){
19508 this.editing = false;
19515 reject : function(silent){
19516 var m = this.modified;
19518 if(typeof m[n] != "function"){
19519 this.data[n] = m[n];
19522 this.dirty = false;
19523 delete this.modified;
19524 this.editing = false;
19525 if(silent !== true){
19526 this.afterReject();
19531 commit : function(silent){
19532 this.dirty = false;
19533 delete this.modified;
19534 this.editing = false;
19535 if(silent !== true){
19536 this.afterCommit();
19541 getChanges : function(){
19542 var m = this.modified, cs = {};
19544 if(m.hasOwnProperty(n)){
19545 cs[n] = this.data[n];
19552 hasError : function(){
19553 return this.error !== null;
19557 clearError : function(){
19562 copy : function(newId) {
19563 return new this.constructor(Ext.apply({}, this.data), newId || this.id);
19567 isModified : function(fieldName){
19568 return !!(this.modified && this.modified.hasOwnProperty(fieldName));
19572 isValid : function() {
19573 return this.fields.find(function(f) {
19574 return (f.allowBlank === false && Ext.isEmpty(this.data[f.name])) ? true : false;
19575 },this) ? false : true;
19579 markDirty : function(){
19581 if(!this.modified){
19582 this.modified = {};
19584 this.fields.each(function(f) {
19585 this.modified[f.name] = this.data[f.name];
19590 Ext.StoreMgr = Ext.apply(new Ext.util.MixedCollection(), {
19594 register : function(){
19595 for(var i = 0, s; (s = arguments[i]); i++){
19601 unregister : function(){
19602 for(var i = 0, s; (s = arguments[i]); i++){
19603 this.remove(this.lookup(s));
19608 lookup : function(id){
19609 if(Ext.isArray(id)){
19610 var fields = ['field1'], expand = !Ext.isArray(id[0]);
19612 for(var i = 2, len = id[0].length; i <= len; ++i){
19613 fields.push('field' + i);
19616 return new Ext.data.ArrayStore({
19619 expandData: expand,
19625 return Ext.isObject(id) ? (id.events ? id : Ext.create(id, 'store')) : this.get(id);
19629 getKey : function(o){
19633 Ext.data.Store = Ext.extend(Ext.util.Observable, {
19641 writer : undefined,
19645 remoteSort : false,
19648 autoDestroy : false,
19651 pruneModifiedRecords : false,
19654 lastOptions : null,
19666 paramNames : undefined,
19669 defaultParamNames : {
19677 batchKey : '_ext_batch_',
19679 constructor : function(config){
19680 this.data = new Ext.util.MixedCollection(false);
19681 this.data.getKey = function(o){
19685 this.baseParams = {};
19690 if(config && config.data){
19691 this.inlineData = config.data;
19692 delete config.data;
19695 Ext.apply(this, config);
19697 this.paramNames = Ext.applyIf(this.paramNames || {}, this.defaultParamNames);
19699 if((this.url || this.api) && !this.proxy){
19700 this.proxy = new Ext.data.HttpProxy({url: this.url, api: this.api});
19703 if (this.restful === true && this.proxy) {
19706 this.batch = false;
19707 Ext.data.Api.restify(this.proxy);
19711 if(!this.recordType){
19712 this.recordType = this.reader.recordType;
19714 if(this.reader.onMetaChange){
19715 this.reader.onMetaChange = this.reader.onMetaChange.createSequence(this.onMetaChange, this);
19718 if (this.writer instanceof(Ext.data.DataWriter) === false) {
19719 this.writer = this.buildWriter(this.writer);
19721 this.writer.meta = this.reader.meta;
19722 this.pruneModifiedRecords = true;
19728 if(this.recordType){
19730 this.fields = this.recordType.prototype.fields;
19732 this.modified = [];
19768 this.relayEvents(this.proxy, ['loadexception', 'exception']);
19774 add: this.createRecords,
19775 remove: this.destroyRecord,
19776 update: this.updateRecord,
19777 clear: this.onClear
19781 this.sortToggle = {};
19782 if(this.sortField){
19783 this.setDefaultSort(this.sortField, this.sortDir);
19784 }else if(this.sortInfo){
19785 this.setDefaultSort(this.sortInfo.field, this.sortInfo.direction);
19788 Ext.data.Store.superclass.constructor.call(this);
19791 this.storeId = this.id;
19795 Ext.StoreMgr.register(this);
19797 if(this.inlineData){
19798 this.loadData(this.inlineData);
19799 delete this.inlineData;
19800 }else if(this.autoLoad){
19801 this.load.defer(10, this, [
19802 typeof this.autoLoad == 'object' ?
19803 this.autoLoad : undefined]);
19806 this.batchCounter = 0;
19811 buildWriter : function(config) {
19812 var klass = undefined;
19813 type = (config.format || 'json').toLowerCase();
19816 klass = Ext.data.JsonWriter;
19819 klass = Ext.data.XmlWriter;
19822 klass = Ext.data.JsonWriter;
19824 return new klass(config);
19828 destroy : function(){
19829 if(!this.isDestroyed){
19831 Ext.StoreMgr.unregister(this);
19835 Ext.destroy(this.proxy);
19836 this.reader = this.writer = null;
19837 this.purgeListeners();
19838 this.isDestroyed = true;
19843 add : function(records){
19844 records = [].concat(records);
19845 if(records.length < 1){
19848 for(var i = 0, len = records.length; i < len; i++){
19849 records[i].join(this);
19851 var index = this.data.length;
19852 this.data.addAll(records);
19854 this.snapshot.addAll(records);
19856 this.fireEvent('add', this, records, index);
19860 addSorted : function(record){
19861 var index = this.findInsertIndex(record);
19862 this.insert(index, record);
19866 remove : function(record){
19867 if(Ext.isArray(record)){
19868 Ext.each(record, function(r){
19872 var index = this.data.indexOf(record);
19875 this.data.removeAt(index);
19877 if(this.pruneModifiedRecords){
19878 this.modified.remove(record);
19881 this.snapshot.remove(record);
19884 this.fireEvent('remove', this, record, index);
19889 removeAt : function(index){
19890 this.remove(this.getAt(index));
19894 removeAll : function(silent){
19896 this.each(function(rec){
19901 this.snapshot.clear();
19903 if(this.pruneModifiedRecords){
19904 this.modified = [];
19906 if (silent !== true) {
19907 this.fireEvent('clear', this, items);
19912 onClear: function(store, records){
19913 Ext.each(records, function(rec, index){
19914 this.destroyRecord(this, rec, index);
19919 insert : function(index, records){
19920 records = [].concat(records);
19921 for(var i = 0, len = records.length; i < len; i++){
19922 this.data.insert(index, records[i]);
19923 records[i].join(this);
19926 this.snapshot.addAll(records);
19928 this.fireEvent('add', this, records, index);
19932 indexOf : function(record){
19933 return this.data.indexOf(record);
19937 indexOfId : function(id){
19938 return this.data.indexOfKey(id);
19942 getById : function(id){
19943 return (this.snapshot || this.data).key(id);
19947 getAt : function(index){
19948 return this.data.itemAt(index);
19952 getRange : function(start, end){
19953 return this.data.getRange(start, end);
19957 storeOptions : function(o){
19958 o = Ext.apply({}, o);
19961 this.lastOptions = o;
19965 clearData: function(){
19966 this.data.each(function(rec) {
19973 load : function(options) {
19974 options = options || {};
19975 this.storeOptions(options);
19976 if(this.sortInfo && this.remoteSort){
19977 var pn = this.paramNames;
19978 options.params = options.params || {};
19979 options.params[pn.sort] = this.sortInfo.field;
19980 options.params[pn.dir] = this.sortInfo.direction;
19983 return this.execute('read', null, options);
19985 this.handleException(e);
19991 updateRecord : function(store, record, action) {
19992 if (action == Ext.data.Record.EDIT && this.autoSave === true && (!record.phantom || (record.phantom && record.isValid()))) {
19998 createRecords : function(store, rs, index) {
19999 for (var i = 0, len = rs.length; i < len; i++) {
20000 if (rs[i].phantom && rs[i].isValid()) {
20002 this.modified.push(rs[i]);
20005 if (this.autoSave === true) {
20011 destroyRecord : function(store, record, index) {
20012 if (this.modified.indexOf(record) != -1) {
20013 this.modified.remove(record);
20015 if (!record.phantom) {
20016 this.removed.push(record);
20021 record.lastIndex = index;
20023 if (this.autoSave === true) {
20030 execute : function(action, rs, options, batch) {
20032 if (!Ext.data.Api.isAction(action)) {
20033 throw new Ext.data.Api.Error('execute', action);
20036 options = Ext.applyIf(options||{}, {
20039 if(batch !== undefined){
20040 this.addToBatch(batch);
20044 var doRequest = true;
20046 if (action === 'read') {
20047 Ext.applyIf(options.params, this.baseParams);
20048 doRequest = this.fireEvent('beforeload', this, options);
20053 if (this.writer.listful === true && this.restful !== true) {
20054 rs = (Ext.isArray(rs)) ? rs : [rs];
20057 else if (Ext.isArray(rs) && rs.length == 1) {
20061 if ((doRequest = this.fireEvent('beforewrite', this, action, rs, options)) !== false) {
20062 this.writer.apply(options.params, this.baseParams, action, rs);
20065 if (doRequest !== false) {
20067 if (this.writer && this.proxy.url && !this.proxy.restful && !Ext.data.Api.hasUniqueUrl(this.proxy, action)) {
20068 options.params.xaction = action;
20075 this.proxy.request(Ext.data.Api.actions[action], rs, options.params, this.reader, this.createCallback(action, rs, batch), this, options);
20081 save : function() {
20082 if (!this.writer) {
20083 throw new Ext.data.Store.Error('writer-undefined');
20092 if(this.removed.length){
20093 queue.push(['destroy', this.removed]);
20097 var rs = [].concat(this.getModifiedRecords());
20101 for(var i = rs.length-1; i >= 0; i--){
20102 if(rs[i].phantom === true){
20103 var rec = rs.splice(i, 1).shift();
20105 phantoms.push(rec);
20107 }else if(!rs[i].isValid()){
20112 if(phantoms.length){
20113 queue.push(['create', phantoms]);
20118 queue.push(['update', rs]);
20121 len = queue.length;
20123 batch = ++this.batchCounter;
20124 for(var i = 0; i < len; ++i){
20126 data[trans[0]] = trans[1];
20128 if(this.fireEvent('beforesave', this, data) !== false){
20129 for(var i = 0; i < len; ++i){
20131 this.doTransaction(trans[0], trans[1], batch);
20140 doTransaction : function(action, rs, batch) {
20141 function transaction(records) {
20143 this.execute(action, records, undefined, batch);
20145 this.handleException(e);
20148 if(this.batch === false){
20149 for(var i = 0, len = rs.length; i < len; i++){
20150 transaction.call(this, rs[i]);
20153 transaction.call(this, rs);
20158 addToBatch : function(batch){
20159 var b = this.batches,
20160 key = this.batchKey + batch,
20173 removeFromBatch : function(batch, action, data){
20174 var b = this.batches,
20175 key = this.batchKey + batch,
20182 arr = o.data[action] || [];
20183 o.data[action] = arr.concat(data);
20187 this.fireEvent('save', this, batch, data);
20196 createCallback : function(action, rs, batch) {
20197 var actions = Ext.data.Api.actions;
20198 return (action == 'read') ? this.loadRecords : function(data, response, success) {
20200 this['on' + Ext.util.Format.capitalize(action) + 'Records'](success, rs, [].concat(data));
20202 if (success === true) {
20203 this.fireEvent('write', this, action, data, response, rs);
20205 this.removeFromBatch(batch, action, data);
20212 clearModified : function(rs) {
20213 if (Ext.isArray(rs)) {
20214 for (var n=rs.length-1;n>=0;n--) {
20215 this.modified.splice(this.modified.indexOf(rs[n]), 1);
20218 this.modified.splice(this.modified.indexOf(rs), 1);
20223 reMap : function(record) {
20224 if (Ext.isArray(record)) {
20225 for (var i = 0, len = record.length; i < len; i++) {
20226 this.reMap(record[i]);
20229 delete this.data.map[record._phid];
20230 this.data.map[record.id] = record;
20231 var index = this.data.keys.indexOf(record._phid);
20232 this.data.keys.splice(index, 1, record.id);
20233 delete record._phid;
20238 onCreateRecords : function(success, rs, data) {
20239 if (success === true) {
20241 this.reader.realize(rs, data);
20245 this.handleException(e);
20246 if (Ext.isArray(rs)) {
20248 this.onCreateRecords(success, rs, data);
20255 onUpdateRecords : function(success, rs, data) {
20256 if (success === true) {
20258 this.reader.update(rs, data);
20260 this.handleException(e);
20261 if (Ext.isArray(rs)) {
20263 this.onUpdateRecords(success, rs, data);
20270 onDestroyRecords : function(success, rs, data) {
20272 rs = (rs instanceof Ext.data.Record) ? [rs] : [].concat(rs);
20273 for (var i=0,len=rs.length;i<len;i++) {
20274 this.removed.splice(this.removed.indexOf(rs[i]), 1);
20276 if (success === false) {
20279 for (i=rs.length-1;i>=0;i--) {
20280 this.insert(rs[i].lastIndex, rs[i]);
20286 handleException : function(e) {
20288 Ext.handleError(e);
20292 reload : function(options){
20293 this.load(Ext.applyIf(options||{}, this.lastOptions));
20298 loadRecords : function(o, options, success){
20299 if (this.isDestroyed === true) {
20302 if(!o || success === false){
20303 if(success !== false){
20304 this.fireEvent('load', this, [], options);
20306 if(options.callback){
20307 options.callback.call(options.scope || this, [], options, false, o);
20311 var r = o.records, t = o.totalRecords || r.length;
20312 if(!options || options.add !== true){
20313 if(this.pruneModifiedRecords){
20314 this.modified = [];
20316 for(var i = 0, len = r.length; i < len; i++){
20320 this.data = this.snapshot;
20321 delete this.snapshot;
20324 this.data.addAll(r);
20325 this.totalLength = t;
20327 this.fireEvent('datachanged', this);
20329 this.totalLength = Math.max(t, this.data.length+r.length);
20332 this.fireEvent('load', this, r, options);
20333 if(options.callback){
20334 options.callback.call(options.scope || this, r, options, true);
20339 loadData : function(o, append){
20340 var r = this.reader.readRecords(o);
20341 this.loadRecords(r, {add: append}, true);
20345 getCount : function(){
20346 return this.data.length || 0;
20350 getTotalCount : function(){
20351 return this.totalLength || 0;
20355 getSortState : function(){
20356 return this.sortInfo;
20360 applySort : function(){
20361 if(this.sortInfo && !this.remoteSort){
20362 var s = this.sortInfo, f = s.field;
20363 this.sortData(f, s.direction);
20368 sortData : function(f, direction){
20369 direction = direction || 'ASC';
20370 var st = this.fields.get(f).sortType;
20371 var fn = function(r1, r2){
20372 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
20373 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
20375 this.data.sort(direction, fn);
20376 if(this.snapshot && this.snapshot != this.data){
20377 this.snapshot.sort(direction, fn);
20382 setDefaultSort : function(field, dir){
20383 dir = dir ? dir.toUpperCase() : 'ASC';
20384 this.sortInfo = {field: field, direction: dir};
20385 this.sortToggle[field] = dir;
20389 sort : function(fieldName, dir){
20390 var f = this.fields.get(fieldName);
20395 if(this.sortInfo && this.sortInfo.field == f.name){
20396 dir = (this.sortToggle[f.name] || 'ASC').toggle('ASC', 'DESC');
20401 var st = (this.sortToggle) ? this.sortToggle[f.name] : null;
20402 var si = (this.sortInfo) ? this.sortInfo : null;
20404 this.sortToggle[f.name] = dir;
20405 this.sortInfo = {field: f.name, direction: dir};
20406 if(!this.remoteSort){
20408 this.fireEvent('datachanged', this);
20410 if (!this.load(this.lastOptions)) {
20412 this.sortToggle[f.name] = st;
20415 this.sortInfo = si;
20422 each : function(fn, scope){
20423 this.data.each(fn, scope);
20427 getModifiedRecords : function(){
20428 return this.modified;
20432 createFilterFn : function(property, value, anyMatch, caseSensitive){
20433 if(Ext.isEmpty(value, false)){
20436 value = this.data.createValueMatcher(value, anyMatch, caseSensitive);
20437 return function(r){
20438 return value.test(r.data[property]);
20443 sum : function(property, start, end){
20444 var rs = this.data.items, v = 0;
20445 start = start || 0;
20446 end = (end || end === 0) ? end : rs.length-1;
20448 for(var i = start; i <= end; i++){
20449 v += (rs[i].data[property] || 0);
20455 filter : function(property, value, anyMatch, caseSensitive){
20456 var fn = this.createFilterFn(property, value, anyMatch, caseSensitive);
20457 return fn ? this.filterBy(fn) : this.clearFilter();
20461 filterBy : function(fn, scope){
20462 this.snapshot = this.snapshot || this.data;
20463 this.data = this.queryBy(fn, scope||this);
20464 this.fireEvent('datachanged', this);
20468 query : function(property, value, anyMatch, caseSensitive){
20469 var fn = this.createFilterFn(property, value, anyMatch, caseSensitive);
20470 return fn ? this.queryBy(fn) : this.data.clone();
20474 queryBy : function(fn, scope){
20475 var data = this.snapshot || this.data;
20476 return data.filterBy(fn, scope||this);
20480 find : function(property, value, start, anyMatch, caseSensitive){
20481 var fn = this.createFilterFn(property, value, anyMatch, caseSensitive);
20482 return fn ? this.data.findIndexBy(fn, null, start) : -1;
20486 findExact: function(property, value, start){
20487 return this.data.findIndexBy(function(rec){
20488 return rec.get(property) === value;
20493 findBy : function(fn, scope, start){
20494 return this.data.findIndexBy(fn, scope, start);
20498 collect : function(dataIndex, allowNull, bypassFilter){
20499 var d = (bypassFilter === true && this.snapshot) ?
20500 this.snapshot.items : this.data.items;
20501 var v, sv, r = [], l = {};
20502 for(var i = 0, len = d.length; i < len; i++){
20503 v = d[i].data[dataIndex];
20505 if((allowNull || !Ext.isEmpty(v)) && !l[sv]){
20514 clearFilter : function(suppressEvent){
20515 if(this.isFiltered()){
20516 this.data = this.snapshot;
20517 delete this.snapshot;
20518 if(suppressEvent !== true){
20519 this.fireEvent('datachanged', this);
20525 isFiltered : function(){
20526 return this.snapshot && this.snapshot != this.data;
20530 afterEdit : function(record){
20531 if(this.modified.indexOf(record) == -1){
20532 this.modified.push(record);
20534 this.fireEvent('update', this, record, Ext.data.Record.EDIT);
20538 afterReject : function(record){
20539 this.modified.remove(record);
20540 this.fireEvent('update', this, record, Ext.data.Record.REJECT);
20544 afterCommit : function(record){
20545 this.modified.remove(record);
20546 this.fireEvent('update', this, record, Ext.data.Record.COMMIT);
20550 commitChanges : function(){
20551 var m = this.modified.slice(0);
20552 this.modified = [];
20553 for(var i = 0, len = m.length; i < len; i++){
20559 rejectChanges : function(){
20560 var m = this.modified.slice(0);
20561 this.modified = [];
20562 for(var i = 0, len = m.length; i < len; i++){
20565 var m = this.removed.slice(0).reverse();
20567 for(var i = 0, len = m.length; i < len; i++){
20568 this.insert(m[i].lastIndex||0, m[i]);
20574 onMetaChange : function(meta){
20575 this.recordType = this.reader.recordType;
20576 this.fields = this.recordType.prototype.fields;
20577 delete this.snapshot;
20578 if(this.reader.meta.sortInfo){
20579 this.sortInfo = this.reader.meta.sortInfo;
20580 }else if(this.sortInfo && !this.fields.get(this.sortInfo.field)){
20581 delete this.sortInfo;
20584 this.writer.meta = this.reader.meta;
20586 this.modified = [];
20587 this.fireEvent('metachange', this, this.reader.meta);
20591 findInsertIndex : function(record){
20592 this.suspendEvents();
20593 var data = this.data.clone();
20594 this.data.add(record);
20596 var index = this.data.indexOf(record);
20598 this.resumeEvents();
20603 setBaseParam : function (name, value){
20604 this.baseParams = this.baseParams || {};
20605 this.baseParams[name] = value;
20609 Ext.reg('store', Ext.data.Store);
20612 Ext.data.Store.Error = Ext.extend(Ext.Error, {
20613 name: 'Ext.data.Store'
20615 Ext.apply(Ext.data.Store.Error.prototype, {
20617 'writer-undefined' : 'Attempted to execute a write-action without a DataWriter installed.'
20621 Ext.data.Field = function(config){
20622 if(typeof config == "string"){
20623 config = {name: config};
20625 Ext.apply(this, config);
20628 this.type = "auto";
20631 var st = Ext.data.SortTypes;
20633 if(typeof this.sortType == "string"){
20634 this.sortType = st[this.sortType];
20638 if(!this.sortType){
20641 this.sortType = st.asUCString;
20644 this.sortType = st.asDate;
20647 this.sortType = st.none;
20652 var stripRe = /[\$,%]/g;
20657 var cv, dateFormat = this.dateFormat;
20662 cv = function(v){ return v; };
20665 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
20669 return v !== undefined && v !== null && v !== '' ?
20670 parseInt(String(v).replace(stripRe, ""), 10) : '';
20675 return v !== undefined && v !== null && v !== '' ?
20676 parseFloat(String(v).replace(stripRe, ""), 10) : '';
20680 cv = function(v){ return v === true || v === "true" || v == 1; };
20691 if(dateFormat == "timestamp"){
20692 return new Date(v*1000);
20694 if(dateFormat == "time"){
20695 return new Date(parseInt(v, 10));
20697 return Date.parseDate(v, dateFormat);
20699 var parsed = Date.parse(v);
20700 return parsed ? new Date(parsed) : null;
20704 cv = function(v){ return v; };
20712 Ext.data.Field.prototype = {
20729 Ext.data.DataReader = function(meta, recordType){
20733 this.recordType = Ext.isArray(recordType) ?
20734 Ext.data.Record.create(recordType) : recordType;
20737 if (this.recordType){
20738 this.buildExtractors();
20742 Ext.data.DataReader.prototype = {
20745 getTotal: Ext.emptyFn,
20747 getRoot: Ext.emptyFn,
20749 getMessage: Ext.emptyFn,
20751 getSuccess: Ext.emptyFn,
20753 getId: Ext.emptyFn,
20755 buildExtractors : Ext.emptyFn,
20757 extractData : Ext.emptyFn,
20759 extractValues : Ext.emptyFn,
20762 realize: function(rs, data){
20763 if (Ext.isArray(rs)) {
20764 for (var i = rs.length - 1; i >= 0; i--) {
20766 if (Ext.isArray(data)) {
20767 this.realize(rs.splice(i,1).shift(), data.splice(i,1).shift());
20772 this.realize(rs.splice(i,1).shift(), data);
20778 if (Ext.isArray(data) && data.length == 1) {
20779 data = data.shift();
20781 if (!this.isData(data)) {
20784 throw new Ext.data.DataReader.Error('realize', rs);
20786 rs.phantom = false;
20788 rs.id = this.getId(data);
20790 rs.fields.each(function(f) {
20791 if (data[f.name] !== f.defaultValue) {
20792 rs.data[f.name] = data[f.name];
20800 update : function(rs, data) {
20801 if (Ext.isArray(rs)) {
20802 for (var i=rs.length-1; i >= 0; i--) {
20803 if (Ext.isArray(data)) {
20804 this.update(rs.splice(i,1).shift(), data.splice(i,1).shift());
20809 this.update(rs.splice(i,1).shift(), data);
20815 if (Ext.isArray(data) && data.length == 1) {
20816 data = data.shift();
20818 if (this.isData(data)) {
20819 rs.fields.each(function(f) {
20820 if (data[f.name] !== f.defaultValue) {
20821 rs.data[f.name] = data[f.name];
20830 extractData : function(root, returnRecords) {
20832 var rawName = (this instanceof Ext.data.JsonReader) ? 'json' : 'node';
20838 if (this.isData(root) && !(this instanceof Ext.data.XmlReader)) {
20841 var f = this.recordType.prototype.fields,
20845 if (returnRecords === true) {
20846 var Record = this.recordType;
20847 for (var i = 0; i < root.length; i++) {
20849 var record = new Record(this.extractValues(n, fi, fl), this.getId(n));
20850 record[rawName] = n;
20855 for (var i = 0; i < root.length; i++) {
20856 var data = this.extractValues(root[i], fi, fl);
20857 data[this.meta.idProperty] = this.getId(root[i]);
20865 isData : function(data) {
20866 return (data && Ext.isObject(data) && !Ext.isEmpty(this.getId(data))) ? true : false;
20870 onMetaChange : function(meta){
20873 this.recordType = Ext.data.Record.create(meta.fields);
20874 this.buildExtractors();
20879 Ext.data.DataReader.Error = Ext.extend(Ext.Error, {
20880 constructor : function(message, arg) {
20882 Ext.Error.call(this, message);
20884 name: 'Ext.data.DataReader'
20886 Ext.apply(Ext.data.DataReader.Error.prototype, {
20888 'update': "#update received invalid data from server. Please see docs for DataReader#update and review your DataReader configuration.",
20889 'realize': "#realize was called with invalid remote-data. Please see the docs for DataReader#realize and review your DataReader configuration.",
20890 'invalid-response': "#readResponse received an invalid response from the server."
20894 Ext.data.DataWriter = function(config){
20895 Ext.apply(this, config);
20897 Ext.data.DataWriter.prototype = {
20900 writeAllFields : false,
20905 apply : function(params, baseParams, action, rs) {
20907 renderer = action + 'Record';
20909 if (Ext.isArray(rs)) {
20910 Ext.each(rs, function(rec){
20911 data.push(this[renderer](rec));
20914 else if (rs instanceof Ext.data.Record) {
20915 data = this[renderer](rs);
20917 this.render(params, baseParams, data);
20921 render : Ext.emptyFn,
20924 updateRecord : Ext.emptyFn,
20927 createRecord : Ext.emptyFn,
20930 destroyRecord : Ext.emptyFn,
20933 toHash : function(rec, config) {
20934 var map = rec.fields.map,
20936 raw = (this.writeAllFields === false && rec.phantom === false) ? rec.getChanges() : rec.data,
20938 Ext.iterate(raw, function(prop, value){
20939 if((m = map[prop])){
20940 data[m.mapping ? m.mapping : m.name] = value;
20947 if (rec.fields.containsKey(this.meta.idProperty) && Ext.isEmpty(rec.data[this.meta.idProperty])) {
20948 delete data[this.meta.idProperty];
20951 data[this.meta.idProperty] = rec.id
20957 toArray : function(data) {
20959 Ext.iterate(data, function(k, v) {fields.push({name: k, value: v});},this);
20963 Ext.data.DataProxy = function(conn){
20972 this.api = conn.api;
20973 this.url = conn.url;
20974 this.restful = conn.restful;
20975 this.listeners = conn.listeners;
20978 this.prettyUrls = conn.prettyUrls;
20996 Ext.data.DataProxy.superclass.constructor.call(this);
21000 Ext.data.Api.prepare(this);
21002 if (e instanceof Ext.data.Api.Error) {
21007 Ext.data.DataProxy.relayEvents(this, ['beforewrite', 'write', 'exception']);
21010 Ext.extend(Ext.data.DataProxy, Ext.util.Observable, {
21015 setApi : function() {
21016 if (arguments.length == 1) {
21017 var valid = Ext.data.Api.isValid(arguments[0]);
21018 if (valid === true) {
21019 this.api = arguments[0];
21022 throw new Ext.data.Api.Error('invalid', valid);
21025 else if (arguments.length == 2) {
21026 if (!Ext.data.Api.isAction(arguments[0])) {
21027 throw new Ext.data.Api.Error('invalid', arguments[0]);
21029 this.api[arguments[0]] = arguments[1];
21031 Ext.data.Api.prepare(this);
21035 isApiAction : function(action) {
21036 return (this.api[action]) ? true : false;
21040 request : function(action, rs, params, reader, callback, scope, options) {
21041 if (!this.api[action] && !this.load) {
21042 throw new Ext.data.DataProxy.Error('action-undefined', action);
21044 params = params || {};
21045 if ((action === Ext.data.Api.actions.read) ? this.fireEvent("beforeload", this, params) : this.fireEvent("beforewrite", this, action, rs, params) !== false) {
21046 this.doRequest.apply(this, arguments);
21049 callback.call(scope || this, null, options, false);
21058 doRequest : function(action, rs, params, reader, callback, scope, options) {
21062 this.load(params, reader, callback, scope, options);
21066 onRead : Ext.emptyFn,
21068 onWrite : Ext.emptyFn,
21070 buildUrl : function(action, record) {
21071 record = record || null;
21076 var url = (this.conn && this.conn.url) ? this.conn.url : (this.api[action]) ? this.api[action].url : this.url;
21078 throw new Ext.data.Api.Error('invalid-url', action);
21087 var provides = null;
21088 var m = url.match(/(.*)(\.json|\.xml|\.html)$/);
21094 if ((this.restful === true || this.prettyUrls === true) && record instanceof Ext.data.Record && !record.phantom) {
21095 url += '/' + record.id;
21097 return (provides === null) ? url : url + provides;
21101 destroy: function(){
21102 this.purgeListeners();
21108 Ext.apply(Ext.data.DataProxy, Ext.util.Observable.prototype);
21109 Ext.util.Observable.call(Ext.data.DataProxy);
21112 Ext.data.DataProxy.Error = Ext.extend(Ext.Error, {
21113 constructor : function(message, arg) {
21115 Ext.Error.call(this, message);
21117 name: 'Ext.data.DataProxy'
21119 Ext.apply(Ext.data.DataProxy.Error.prototype, {
21121 'action-undefined': "DataProxy attempted to execute an API-action but found an undefined url / function. Please review your Proxy url/api-configuration.",
21122 'api-invalid': 'Recieved an invalid API-configuration. Please ensure your proxy API-configuration contains only the actions from Ext.data.Api.actions.'
21128 Ext.data.Request = function(params) {
21129 Ext.apply(this, params);
21131 Ext.data.Request.prototype = {
21133 action : undefined,
21139 callback : Ext.emptyFn,
21146 Ext.data.Response = function(params) {
21147 Ext.apply(this, params);
21149 Ext.data.Response.prototype = {
21153 success : undefined,
21155 message : undefined,
21164 Ext.data.ScriptTagProxy = function(config){
21165 Ext.apply(this, config);
21167 Ext.data.ScriptTagProxy.superclass.constructor.call(this, config);
21169 this.head = document.getElementsByTagName("head")[0];
21174 Ext.data.ScriptTagProxy.TRANS_ID = 1000;
21176 Ext.extend(Ext.data.ScriptTagProxy, Ext.data.DataProxy, {
21181 callbackParam : "callback",
21186 doRequest : function(action, rs, params, reader, callback, scope, arg) {
21187 var p = Ext.urlEncode(Ext.apply(params, this.extraParams));
21189 var url = this.buildUrl(action, rs);
21191 throw new Ext.data.Api.Error('invalid-url', url);
21193 url = Ext.urlAppend(url, p);
21196 url = Ext.urlAppend(url, '_dc=' + (new Date().getTime()));
21198 var transId = ++Ext.data.ScriptTagProxy.TRANS_ID;
21202 cb : "stcCallback"+transId,
21203 scriptId : "stcScript"+transId,
21207 callback : callback,
21211 window[trans.cb] = this.createCallback(action, rs, trans);
21212 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
21213 if(this.autoAbort !== false){
21217 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
21219 var script = document.createElement("script");
21220 script.setAttribute("src", url);
21221 script.setAttribute("type", "text/javascript");
21222 script.setAttribute("id", trans.scriptId);
21223 this.head.appendChild(script);
21225 this.trans = trans;
21229 createCallback : function(action, rs, trans) {
21231 return function(res) {
21232 self.trans = false;
21233 self.destroyTrans(trans, true);
21234 if (action === Ext.data.Api.actions.read) {
21235 self.onRead.call(self, action, trans, res);
21237 self.onWrite.call(self, action, trans, res, rs);
21242 onRead : function(action, trans, res) {
21245 result = trans.reader.readRecords(res);
21248 this.fireEvent("loadexception", this, trans, res, e);
21250 this.fireEvent('exception', this, 'response', action, trans, res, e);
21251 trans.callback.call(trans.scope||window, null, trans.arg, false);
21254 if (result.success === false) {
21256 this.fireEvent('loadexception', this, trans, res);
21258 this.fireEvent('exception', this, 'remote', action, trans, res, null);
21260 this.fireEvent("load", this, res, trans.arg);
21262 trans.callback.call(trans.scope||window, result, trans.arg, result.success);
21265 onWrite : function(action, trans, response, rs) {
21266 var reader = trans.reader;
21269 var res = reader.readResponse(action, response);
21271 this.fireEvent('exception', this, 'response', action, trans, res, e);
21272 trans.callback.call(trans.scope||window, null, res, false);
21275 if(!res.success === true){
21276 this.fireEvent('exception', this, 'remote', action, trans, res, rs);
21277 trans.callback.call(trans.scope||window, null, res, false);
21280 this.fireEvent("write", this, action, res.data, res, rs, trans.arg );
21281 trans.callback.call(trans.scope||window, res.data, res, true);
21285 isLoading : function(){
21286 return this.trans ? true : false;
21290 abort : function(){
21291 if(this.isLoading()){
21292 this.destroyTrans(this.trans);
21297 destroyTrans : function(trans, isLoaded){
21298 this.head.removeChild(document.getElementById(trans.scriptId));
21299 clearTimeout(trans.timeoutId);
21301 window[trans.cb] = undefined;
21303 delete window[trans.cb];
21307 window[trans.cb] = function(){
21308 window[trans.cb] = undefined;
21310 delete window[trans.cb];
21317 handleFailure : function(trans){
21318 this.trans = false;
21319 this.destroyTrans(trans, false);
21320 if (trans.action === Ext.data.Api.actions.read) {
21322 this.fireEvent("loadexception", this, null, trans.arg);
21325 this.fireEvent('exception', this, 'response', trans.action, {
21329 trans.callback.call(trans.scope||window, null, trans.arg, false);
21333 destroy: function(){
21335 Ext.data.ScriptTagProxy.superclass.destroy.call(this);
21338 Ext.data.HttpProxy = function(conn){
21339 Ext.data.HttpProxy.superclass.constructor.call(this, conn);
21348 this.conn.url = null;
21350 this.useAjax = !conn || !conn.events;
21353 var actions = Ext.data.Api.actions;
21354 this.activeRequest = {};
21355 for (var verb in actions) {
21356 this.activeRequest[actions[verb]] = undefined;
21360 Ext.extend(Ext.data.HttpProxy, Ext.data.DataProxy, {
21362 getConnection : function() {
21363 return this.useAjax ? Ext.Ajax : this.conn;
21367 setUrl : function(url, makePermanent) {
21368 this.conn.url = url;
21369 if (makePermanent === true) {
21372 Ext.data.Api.prepare(this);
21377 doRequest : function(action, rs, params, reader, cb, scope, arg) {
21379 method: (this.api[action]) ? this.api[action]['method'] : undefined,
21386 callback : this.createCallback(action, rs),
21392 if (params.jsonData) {
21393 o.jsonData = params.jsonData;
21394 } else if (params.xmlData) {
21395 o.xmlData = params.xmlData;
21397 o.params = params || {};
21402 this.conn.url = this.buildUrl(action, rs);
21406 Ext.applyIf(o, this.conn);
21409 if (this.activeRequest[action]) {
21416 this.activeRequest[action] = Ext.Ajax.request(o);
21418 this.conn.request(o);
21421 this.conn.url = null;
21425 createCallback : function(action, rs) {
21426 return function(o, success, response) {
21427 this.activeRequest[action] = undefined;
21429 if (action === Ext.data.Api.actions.read) {
21432 this.fireEvent('loadexception', this, o, response);
21434 this.fireEvent('exception', this, 'response', action, o, response);
21435 o.request.callback.call(o.request.scope, null, o.request.arg, false);
21438 if (action === Ext.data.Api.actions.read) {
21439 this.onRead(action, o, response);
21441 this.onWrite(action, o, response, rs);
21447 onRead : function(action, o, response) {
21450 result = o.reader.read(response);
21454 this.fireEvent('loadexception', this, o, response, e);
21456 this.fireEvent('exception', this, 'response', action, o, response, e);
21457 o.request.callback.call(o.request.scope, null, o.request.arg, false);
21460 if (result.success === false) {
21463 this.fireEvent('loadexception', this, o, response);
21466 var res = o.reader.readResponse(action, response);
21467 this.fireEvent('exception', this, 'remote', action, o, res, null);
21470 this.fireEvent('load', this, o, o.request.arg);
21475 o.request.callback.call(o.request.scope, result, o.request.arg, result.success);
21478 onWrite : function(action, o, response, rs) {
21479 var reader = o.reader;
21482 res = reader.readResponse(action, response);
21484 this.fireEvent('exception', this, 'response', action, o, response, e);
21485 o.request.callback.call(o.request.scope, null, o.request.arg, false);
21488 if (res.success === false) {
21489 this.fireEvent('exception', this, 'remote', action, o, res, rs);
21491 this.fireEvent('write', this, action, res.data, res, rs, o.request.arg);
21496 o.request.callback.call(o.request.scope, res.data, res, res.success);
21500 destroy: function(){
21503 }else if(this.activeRequest){
21504 var actions = Ext.data.Api.actions;
21505 for (var verb in actions) {
21506 if(this.activeRequest[actions[verb]]){
21507 Ext.Ajax.abort(this.activeRequest[actions[verb]]);
21511 Ext.data.HttpProxy.superclass.destroy.call(this);
21514 Ext.data.MemoryProxy = function(data){
21517 api[Ext.data.Api.actions.read] = true;
21518 Ext.data.MemoryProxy.superclass.constructor.call(this, {
21524 Ext.extend(Ext.data.MemoryProxy, Ext.data.DataProxy, {
21528 doRequest : function(action, rs, params, reader, callback, scope, arg) {
21530 params = params || {};
21533 result = reader.readRecords(this.data);
21536 this.fireEvent("loadexception", this, null, arg, e);
21538 this.fireEvent('exception', this, 'response', action, arg, null, e);
21539 callback.call(scope, null, arg, false);
21542 callback.call(scope, result, arg, true);
21545 Ext.data.JsonWriter = function(config) {
21546 Ext.data.JsonWriter.superclass.constructor.call(this, config);
21550 if (this.returnJson != undefined) {
21551 this.encode = this.returnJson;
21554 Ext.extend(Ext.data.JsonWriter, Ext.data.DataWriter, {
21556 returnJson : undefined,
21561 render : function(params, baseParams, data) {
21562 if (this.encode === true) {
21564 Ext.apply(params, baseParams);
21565 params[this.meta.root] = Ext.encode(data);
21568 var jdata = Ext.apply({}, baseParams);
21569 jdata[this.meta.root] = data;
21570 params.jsonData = jdata;
21574 createRecord : function(rec) {
21575 return this.toHash(rec);
21578 updateRecord : function(rec) {
21579 return this.toHash(rec);
21583 destroyRecord : function(rec) {
21587 Ext.data.JsonReader = function(meta, recordType){
21593 Ext.applyIf(meta, {
21595 successProperty: 'success',
21596 totalProperty: 'total'
21599 Ext.data.JsonReader.superclass.constructor.call(this, meta, recordType || meta.fields);
21601 Ext.extend(Ext.data.JsonReader, Ext.data.DataReader, {
21604 read : function(response){
21605 var json = response.responseText;
21606 var o = Ext.decode(json);
21608 throw {message: 'JsonReader.read: Json object not found'};
21610 return this.readRecords(o);
21614 readResponse : function(action, response) {
21615 var o = (response.responseText !== undefined) ? Ext.decode(response.responseText) : response;
21617 throw new Ext.data.JsonReader.Error('response');
21620 var root = this.getRoot(o);
21621 if (action === Ext.data.Api.actions.create) {
21622 var def = Ext.isDefined(root);
21623 if (def && Ext.isEmpty(root)) {
21624 throw new Ext.data.JsonReader.Error('root-empty', this.meta.root);
21627 throw new Ext.data.JsonReader.Error('root-undefined-response', this.meta.root);
21632 var res = new Ext.data.Response({
21634 success: this.getSuccess(o),
21635 data: (root) ? this.extractData(root, false) : [],
21636 message: this.getMessage(o),
21641 if (Ext.isEmpty(res.success)) {
21642 throw new Ext.data.JsonReader.Error('successProperty-response', this.meta.successProperty);
21648 readRecords : function(o){
21652 this.onMetaChange(o.metaData);
21654 var s = this.meta, Record = this.recordType,
21655 f = Record.prototype.fields, fi = f.items, fl = f.length, v;
21657 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
21658 if(s.totalProperty){
21659 v = parseInt(this.getTotal(o), 10);
21664 if(s.successProperty){
21665 v = this.getSuccess(o);
21666 if(v === false || v === 'false'){
21674 records : this.extractData(root, true),
21675 totalRecords : totalRecords
21680 buildExtractors : function() {
21684 var s = this.meta, Record = this.recordType,
21685 f = Record.prototype.fields, fi = f.items, fl = f.length;
21687 if(s.totalProperty) {
21688 this.getTotal = this.createAccessor(s.totalProperty);
21690 if(s.successProperty) {
21691 this.getSuccess = this.createAccessor(s.successProperty);
21693 if (s.messageProperty) {
21694 this.getMessage = this.createAccessor(s.messageProperty);
21696 this.getRoot = s.root ? this.createAccessor(s.root) : function(p){return p;};
21697 if (s.id || s.idProperty) {
21698 var g = this.createAccessor(s.id || s.idProperty);
21699 this.getId = function(rec) {
21701 return (r === undefined || r === '') ? null : r;
21704 this.getId = function(){return null;};
21707 for(var i = 0; i < fl; i++){
21709 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
21710 ef.push(this.createAccessor(map));
21716 simpleAccess : function(obj, subsc) {
21721 createAccessor : function(){
21723 return function(expr) {
21725 return(re.test(expr)) ?
21726 new Function('obj', 'return obj.' + expr) :
21731 return Ext.emptyFn;
21736 extractValues : function(data, items, len) {
21737 var f, values = {};
21738 for(var j = 0; j < len; j++){
21740 var v = this.ef[j](data);
21741 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue, data);
21748 Ext.data.JsonReader.Error = Ext.extend(Ext.Error, {
21749 constructor : function(message, arg) {
21751 Ext.Error.call(this, message);
21753 name : 'Ext.data.JsonReader'
21755 Ext.apply(Ext.data.JsonReader.Error.prototype, {
21757 'response': 'An error occurred while json-decoding your server response',
21758 'successProperty-response': 'Could not locate your "successProperty" in your server response. Please review your JsonReader config to ensure the config-property "successProperty" matches the property in your server-response. See the JsonReader docs.',
21759 'root-undefined-config': 'Your JsonReader was configured without a "root" property. Please review your JsonReader config and make sure to define the root property. See the JsonReader docs.',
21760 'idProperty-undefined' : 'Your JsonReader was configured without an "idProperty" Please review your JsonReader configuration and ensure the "idProperty" is set (e.g.: "id"). See the JsonReader docs.',
21761 'root-empty': 'Data was expected to be returned by the server in the "root" property of the response. Please review your JsonReader configuration to ensure the "root" property matches that returned in the server-response. See JsonReader docs.'
21765 Ext.data.ArrayReader = Ext.extend(Ext.data.JsonReader, {
21770 readRecords : function(o){
21771 this.arrayData = o;
21773 sid = s ? Ext.num(s.idIndex, s.id) : null,
21774 recordType = this.recordType,
21775 fields = recordType.prototype.fields,
21779 var root = this.getRoot(o);
21781 for(var i = 0, len = root.length; i < len; i++) {
21784 id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
21785 for(var j = 0, jlen = fields.length; j < jlen; j++) {
21786 var f = fields.items[j],
21787 k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
21788 v = n[k] !== undefined ? n[k] : f.defaultValue;
21789 v = f.convert(v, n);
21790 values[f.name] = v;
21792 var record = new recordType(values, id);
21794 records[records.length] = record;
21797 var totalRecords = records.length;
21799 if(s.totalProperty) {
21800 v = parseInt(this.getTotal(o), 10);
21808 totalRecords : totalRecords
21812 Ext.data.ArrayStore = Ext.extend(Ext.data.Store, {
21814 constructor: function(config){
21815 Ext.data.ArrayStore.superclass.constructor.call(this, Ext.apply(config, {
21816 reader: new Ext.data.ArrayReader(config)
21820 loadData : function(data, append){
21821 if(this.expandData === true){
21823 for(var i = 0, len = data.length; i < len; i++){
21824 r[r.length] = [data[i]];
21828 Ext.data.ArrayStore.superclass.loadData.call(this, data, append);
21831 Ext.reg('arraystore', Ext.data.ArrayStore);
21834 Ext.data.SimpleStore = Ext.data.ArrayStore;
21835 Ext.reg('simplestore', Ext.data.SimpleStore);
21836 Ext.data.JsonStore = Ext.extend(Ext.data.Store, {
21838 constructor: function(config){
21839 Ext.data.JsonStore.superclass.constructor.call(this, Ext.apply(config, {
21840 reader: new Ext.data.JsonReader(config)
21844 Ext.reg('jsonstore', Ext.data.JsonStore);
21845 Ext.data.XmlWriter = function(params) {
21846 Ext.data.XmlWriter.superclass.constructor.apply(this, arguments);
21848 this.tpl = (typeof(this.tpl) === 'string') ? new Ext.XTemplate(this.tpl).compile() : this.tpl.compile();
21850 Ext.extend(Ext.data.XmlWriter, Ext.data.DataWriter, {
21852 documentRoot: 'xrequest',
21854 forceDocumentRoot: false,
21858 xmlVersion : '1.0',
21860 xmlEncoding: 'ISO-8859-15',
21863 tpl: '<tpl for="."><' + '?xml version="{version}" encoding="{encoding}"?' + '><tpl if="documentRoot"><{documentRoot}><tpl for="baseParams"><tpl for="."><{name}>{value}</{name}</tpl></tpl></tpl><tpl if="records.length>1"><{root}></tpl><tpl for="records"><{parent.record}><tpl for="."><{name}>{value}</{name}></tpl></{parent.record}></tpl><tpl if="records.length>1"></{root}></tpl><tpl if="documentRoot"></{documentRoot}></tpl></tpl>',
21866 render : function(params, baseParams, data) {
21867 baseParams = this.toArray(baseParams);
21868 params.xmlData = this.tpl.applyTemplate({
21869 version: this.xmlVersion,
21870 encoding: this.xmlEncoding,
21871 documentRoot: (baseParams.length > 0 || this.forceDocumentRoot === true) ? this.documentRoot : false,
21872 record: this.meta.record,
21874 baseParams: baseParams,
21875 records: (Ext.isArray(data[0])) ? data : [data]
21880 createRecord : function(rec) {
21881 return this.toArray(this.toHash(rec));
21885 updateRecord : function(rec) {
21886 return this.toArray(this.toHash(rec));
21890 destroyRecord : function(rec) {
21892 data[this.meta.idProperty] = rec.id;
21893 return this.toArray(data);
21898 Ext.data.XmlReader = function(meta, recordType){
21902 Ext.applyIf(meta, {
21903 idProperty: meta.idProperty || meta.idPath || meta.id,
21904 successProperty: meta.successProperty || meta.success
21907 Ext.data.XmlReader.superclass.constructor.call(this, meta, recordType || meta.fields);
21909 Ext.extend(Ext.data.XmlReader, Ext.data.DataReader, {
21911 read : function(response){
21912 var doc = response.responseXML;
21914 throw {message: "XmlReader.read: XML Document not available"};
21916 return this.readRecords(doc);
21920 readRecords : function(doc){
21922 this.xmlData = doc;
21924 var root = doc.documentElement || doc,
21929 if(this.meta.totalProperty){
21930 totalRecords = this.getTotal(root, 0);
21932 if(this.meta.successProperty){
21933 success = this.getSuccess(root);
21936 var records = this.extractData(q.select(this.meta.record, root), true);
21942 totalRecords : totalRecords || records.length
21947 readResponse : function(action, response) {
21948 var q = Ext.DomQuery,
21949 doc = response.responseXML;
21952 var res = new Ext.data.Response({
21954 success : this.getSuccess(doc),
21955 message: this.getMessage(doc),
21956 data: this.extractData(q.select(this.meta.record, doc) || q.select(this.meta.root, doc), false),
21960 if (Ext.isEmpty(res.success)) {
21961 throw new Ext.data.DataReader.Error('successProperty-response', this.meta.successProperty);
21965 if (action === Ext.data.Api.actions.create) {
21966 var def = Ext.isDefined(res.data);
21967 if (def && Ext.isEmpty(res.data)) {
21968 throw new Ext.data.JsonReader.Error('root-empty', this.meta.root);
21971 throw new Ext.data.JsonReader.Error('root-undefined-response', this.meta.root);
21977 getSuccess : function() {
21982 buildExtractors : function() {
21987 Record = this.recordType,
21988 f = Record.prototype.fields,
21992 if(s.totalProperty) {
21993 this.getTotal = this.createAccessor(s.totalProperty);
21995 if(s.successProperty) {
21996 this.getSuccess = this.createAccessor(s.successProperty);
21998 if (s.messageProperty) {
21999 this.getMessage = this.createAccessor(s.messageProperty);
22001 this.getRoot = function(res) {
22002 return (!Ext.isEmpty(res[this.meta.record])) ? res[this.meta.record] : res[this.meta.root];
22004 if (s.idPath || s.idProperty) {
22005 var g = this.createAccessor(s.idPath || s.idProperty);
22006 this.getId = function(rec) {
22007 var id = g(rec) || rec.id;
22008 return (id === undefined || id === '') ? null : id;
22011 this.getId = function(){return null;};
22014 for(var i = 0; i < fl; i++){
22016 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
22017 ef.push(this.createAccessor(map));
22023 createAccessor : function(){
22024 var q = Ext.DomQuery;
22025 return function(key) {
22027 case this.meta.totalProperty:
22028 return function(root, def){
22029 return q.selectNumber(key, root, def);
22032 case this.meta.successProperty:
22033 return function(root, def) {
22034 var sv = q.selectValue(key, root, true);
22035 var success = sv !== false && sv !== 'false';
22040 return function(root, def) {
22041 return q.selectValue(key, root, def);
22049 extractValues : function(data, items, len) {
22050 var f, values = {};
22051 for(var j = 0; j < len; j++){
22053 var v = this.ef[j](data);
22054 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue, data);
22059 Ext.data.XmlStore = Ext.extend(Ext.data.Store, {
22061 constructor: function(config){
22062 Ext.data.XmlStore.superclass.constructor.call(this, Ext.apply(config, {
22063 reader: new Ext.data.XmlReader(config)
22067 Ext.reg('xmlstore', Ext.data.XmlStore);
22068 Ext.data.GroupingStore = Ext.extend(Ext.data.Store, {
22071 constructor: function(config){
22072 Ext.data.GroupingStore.superclass.constructor.call(this, config);
22073 this.applyGroupField();
22078 remoteGroup : false,
22085 clearGrouping : function(){
22086 this.groupField = false;
22087 if(this.remoteGroup){
22088 if(this.baseParams){
22089 delete this.baseParams.groupBy;
22091 var lo = this.lastOptions;
22092 if(lo && lo.params){
22093 delete lo.params.groupBy;
22098 this.fireEvent('datachanged', this);
22103 groupBy : function(field, forceRegroup, direction){
22104 direction = direction ? (String(direction).toUpperCase() == 'DESC' ? 'DESC' : 'ASC') : this.groupDir;
22105 if(this.groupField == field && this.groupDir == direction && !forceRegroup){
22108 this.groupField = field;
22109 this.groupDir = direction;
22110 this.applyGroupField();
22111 if(this.groupOnSort){
22112 this.sort(field, direction);
22115 if(this.remoteGroup){
22118 var si = this.sortInfo || {};
22119 if(si.field != field || si.direction != direction){
22122 this.sortData(field, direction);
22124 this.fireEvent('datachanged', this);
22129 applyGroupField: function(){
22130 if(this.remoteGroup){
22131 if(!this.baseParams){
22132 this.baseParams = {};
22134 this.baseParams.groupBy = this.groupField;
22135 this.baseParams.groupDir = this.groupDir;
22140 applySort : function(){
22141 Ext.data.GroupingStore.superclass.applySort.call(this);
22142 if(!this.groupOnSort && !this.remoteGroup){
22143 var gs = this.getGroupState();
22144 if(gs && (gs != this.sortInfo.field || this.groupDir != this.sortInfo.direction)){
22145 this.sortData(this.groupField, this.groupDir);
22151 applyGrouping : function(alwaysFireChange){
22152 if(this.groupField !== false){
22153 this.groupBy(this.groupField, true, this.groupDir);
22156 if(alwaysFireChange === true){
22157 this.fireEvent('datachanged', this);
22164 getGroupState : function(){
22165 return this.groupOnSort && this.groupField !== false ?
22166 (this.sortInfo ? this.sortInfo.field : undefined) : this.groupField;
22169 Ext.reg('groupingstore', Ext.data.GroupingStore);
22170 Ext.data.DirectProxy = function(config){
22171 Ext.apply(this, config);
22172 if(typeof this.paramOrder == 'string'){
22173 this.paramOrder = this.paramOrder.split(/[\s,|]/);
22175 Ext.data.DirectProxy.superclass.constructor.call(this, config);
22178 Ext.extend(Ext.data.DirectProxy, Ext.data.DataProxy, {
22180 paramOrder: undefined,
22183 paramsAsHash: true,
22186 directFn : undefined,
22189 doRequest : function(action, rs, params, reader, callback, scope, options) {
22191 directFn = this.api[action] || this.directFn;
22194 case Ext.data.Api.actions.create:
22195 args.push(params.jsonData);
22197 case Ext.data.Api.actions.read:
22199 if(directFn.directCfg.method.len > 0){
22200 if(this.paramOrder){
22201 for(var i = 0, len = this.paramOrder.length; i < len; i++){
22202 args.push(params[this.paramOrder[i]]);
22204 }else if(this.paramsAsHash){
22209 case Ext.data.Api.actions.update:
22210 args.push(params.jsonData);
22212 case Ext.data.Api.actions.destroy:
22213 args.push(params.jsonData);
22218 params : params || {},
22220 callback : callback,
22227 args.push(this.createCallback(action, rs, trans), this);
22228 directFn.apply(window, args);
22232 createCallback : function(action, rs, trans) {
22233 return function(result, res) {
22236 if (action === Ext.data.Api.actions.read) {
22237 this.fireEvent("loadexception", this, trans, res, null);
22239 this.fireEvent('exception', this, 'remote', action, trans, res, null);
22240 trans.request.callback.call(trans.request.scope, null, trans.request.arg, false);
22243 if (action === Ext.data.Api.actions.read) {
22244 this.onRead(action, trans, result, res);
22246 this.onWrite(action, trans, result, res, rs);
22251 onRead : function(action, trans, result, res) {
22254 records = trans.reader.readRecords(result);
22258 this.fireEvent("loadexception", this, trans, res, ex);
22260 this.fireEvent('exception', this, 'response', action, trans, res, ex);
22261 trans.request.callback.call(trans.request.scope, null, trans.request.arg, false);
22264 this.fireEvent("load", this, res, trans.request.arg);
22265 trans.request.callback.call(trans.request.scope, records, trans.request.arg, true);
22268 onWrite : function(action, trans, result, res, rs) {
22269 var data = trans.reader.extractData(result, false);
22270 this.fireEvent("write", this, action, data, res, rs, trans.request.arg);
22271 trans.request.callback.call(trans.request.scope, data, res, true);
22276 Ext.data.DirectStore = function(c){
22278 c.batchTransactions = false;
22280 Ext.data.DirectStore.superclass.constructor.call(this, Ext.apply(c, {
22281 proxy: (typeof(c.proxy) == 'undefined') ? new Ext.data.DirectProxy(Ext.copyTo({}, c, 'paramOrder,paramsAsHash,directFn,api')) : c.proxy,
22282 reader: (typeof(c.reader) == 'undefined' && typeof(c.fields) == 'object') ? new Ext.data.JsonReader(Ext.copyTo({}, c, 'totalProperty,root,idProperty'), c.fields) : c.reader
22285 Ext.extend(Ext.data.DirectStore, Ext.data.Store, {});
22286 Ext.reg('directstore', Ext.data.DirectStore);
22288 Ext.Direct = Ext.extend(Ext.util.Observable, {
22296 SERVER: 'exception'
22300 constructor: function(){
22307 this.transactions = {};
22308 this.providers = {};
22312 addProvider : function(provider){
22315 for(var i = 0, len = a.length; i < len; i++){
22316 this.addProvider(a[i]);
22322 if(!provider.events){
22323 provider = new Ext.Direct.PROVIDERS[provider.type](provider);
22325 provider.id = provider.id || Ext.id();
22326 this.providers[provider.id] = provider;
22328 provider.on('data', this.onProviderData, this);
22329 provider.on('exception', this.onProviderException, this);
22332 if(!provider.isConnected()){
22333 provider.connect();
22340 getProvider : function(id){
22341 return this.providers[id];
22344 removeProvider : function(id){
22345 var provider = id.id ? id : this.providers[id.id];
22346 provider.un('data', this.onProviderData, this);
22347 provider.un('exception', this.onProviderException, this);
22348 delete this.providers[provider.id];
22352 addTransaction: function(t){
22353 this.transactions[t.tid] = t;
22357 removeTransaction: function(t){
22358 delete this.transactions[t.tid || t];
22362 getTransaction: function(tid){
22363 return this.transactions[tid.tid || tid];
22366 onProviderData : function(provider, e){
22367 if(Ext.isArray(e)){
22368 for(var i = 0, len = e.length; i < len; i++){
22369 this.onProviderData(provider, e[i]);
22373 if(e.name && e.name != 'event' && e.name != 'exception'){
22374 this.fireEvent(e.name, e);
22375 }else if(e.type == 'exception'){
22376 this.fireEvent('exception', e);
22378 this.fireEvent('event', e, provider);
22381 createEvent : function(response, extraProps){
22382 return new Ext.Direct.eventTypes[response.type](Ext.apply(response, extraProps));
22386 Ext.Direct = new Ext.Direct();
22388 Ext.Direct.TID = 1;
22389 Ext.Direct.PROVIDERS = {};
22390 Ext.Direct.Transaction = function(config){
22391 Ext.apply(this, config);
22392 this.tid = ++Ext.Direct.TID;
22393 this.retryCount = 0;
22395 Ext.Direct.Transaction.prototype = {
22397 this.provider.queueTransaction(this);
22405 getProvider: function(){
22406 return this.provider;
22408 };Ext.Direct.Event = function(config){
22409 Ext.apply(this, config);
22411 Ext.Direct.Event.prototype = {
22413 getData: function(){
22418 Ext.Direct.RemotingEvent = Ext.extend(Ext.Direct.Event, {
22420 getTransaction: function(){
22421 return this.transaction || Ext.Direct.getTransaction(this.tid);
22425 Ext.Direct.ExceptionEvent = Ext.extend(Ext.Direct.RemotingEvent, {
22430 Ext.Direct.eventTypes = {
22431 'rpc': Ext.Direct.RemotingEvent,
22432 'event': Ext.Direct.Event,
22433 'exception': Ext.Direct.ExceptionEvent
22437 Ext.direct.Provider = Ext.extend(Ext.util.Observable, {
22446 constructor : function(config){
22447 Ext.apply(this, config);
22458 Ext.direct.Provider.superclass.constructor.call(this, config);
22462 isConnected: function(){
22467 connect: Ext.emptyFn,
22470 disconnect: Ext.emptyFn
22473 Ext.direct.JsonProvider = Ext.extend(Ext.direct.Provider, {
22474 parseResponse: function(xhr){
22475 if(!Ext.isEmpty(xhr.responseText)){
22476 if(typeof xhr.responseText == 'object'){
22477 return xhr.responseText;
22479 return Ext.decode(xhr.responseText);
22484 getEvents: function(xhr){
22487 data = this.parseResponse(xhr);
22489 var event = new Ext.Direct.ExceptionEvent({
22492 code: Ext.Direct.exceptions.PARSE,
22493 message: 'Error parsing json response: \n\n ' + data
22498 if(Ext.isArray(data)){
22499 for(var i = 0, len = data.length; i < len; i++){
22500 events.push(Ext.Direct.createEvent(data[i]));
22503 events.push(Ext.Direct.createEvent(data));
22508 Ext.direct.PollingProvider = Ext.extend(Ext.direct.JsonProvider, {
22521 constructor : function(config){
22522 Ext.direct.PollingProvider.superclass.constructor.call(this, config);
22532 isConnected: function(){
22533 return !!this.pollTask;
22537 connect: function(){
22538 if(this.url && !this.pollTask){
22539 this.pollTask = Ext.TaskMgr.start({
22541 if(this.fireEvent('beforepoll', this) !== false){
22542 if(typeof this.url == 'function'){
22543 this.url(this.baseParams);
22547 callback: this.onData,
22549 params: this.baseParams
22554 interval: this.interval,
22557 this.fireEvent('connect', this);
22558 }else if(!this.url){
22559 throw 'Error initializing PollingProvider, no url configured.';
22564 disconnect: function(){
22566 Ext.TaskMgr.stop(this.pollTask);
22567 delete this.pollTask;
22568 this.fireEvent('disconnect', this);
22573 onData: function(opt, success, xhr){
22575 var events = this.getEvents(xhr);
22576 for(var i = 0, len = events.length; i < len; i++){
22578 this.fireEvent('data', this, e);
22581 var e = new Ext.Direct.ExceptionEvent({
22583 code: Ext.Direct.exceptions.TRANSPORT,
22584 message: 'Unable to connect to the server.',
22587 this.fireEvent('data', this, e);
22592 Ext.Direct.PROVIDERS['polling'] = Ext.direct.PollingProvider;
22593 Ext.direct.RemotingProvider = Ext.extend(Ext.direct.JsonProvider, {
22609 timeout: undefined,
22611 constructor : function(config){
22612 Ext.direct.RemotingProvider.superclass.constructor.call(this, config);
22619 this.namespace = (Ext.isString(this.namespace)) ? Ext.ns(this.namespace) : this.namespace || window;
22620 this.transactions = {};
22621 this.callBuffer = [];
22625 initAPI : function(){
22626 var o = this.actions;
22628 var cls = this.namespace[c] || (this.namespace[c] = {}),
22630 for(var i = 0, len = ms.length; i < len; i++){
22632 cls[m.name] = this.createMethod(c, m);
22638 isConnected: function(){
22639 return !!this.connected;
22642 connect: function(){
22645 this.connected = true;
22646 this.fireEvent('connect', this);
22647 }else if(!this.url){
22648 throw 'Error initializing RemotingProvider, no url configured.';
22652 disconnect: function(){
22653 if(this.connected){
22654 this.connected = false;
22655 this.fireEvent('disconnect', this);
22659 onData: function(opt, success, xhr){
22661 var events = this.getEvents(xhr);
22662 for(var i = 0, len = events.length; i < len; i++){
22664 t = this.getTransaction(e);
22665 this.fireEvent('data', this, e);
22667 this.doCallback(t, e, true);
22668 Ext.Direct.removeTransaction(t);
22672 var ts = [].concat(opt.ts);
22673 for(var i = 0, len = ts.length; i < len; i++){
22674 var t = this.getTransaction(ts[i]);
22675 if(t && t.retryCount < this.maxRetries){
22678 var e = new Ext.Direct.ExceptionEvent({
22681 code: Ext.Direct.exceptions.TRANSPORT,
22682 message: 'Unable to connect to the server.',
22685 this.fireEvent('data', this, e);
22687 this.doCallback(t, e, false);
22688 Ext.Direct.removeTransaction(t);
22695 getCallData: function(t){
22705 doSend : function(data){
22708 callback: this.onData,
22711 timeout: this.timeout
22714 if(Ext.isArray(data)){
22716 for(var i = 0, len = data.length; i < len; i++){
22717 callData.push(this.getCallData(data[i]));
22720 callData = this.getCallData(data);
22723 if(this.enableUrlEncode){
22725 params[Ext.isString(this.enableUrlEncode) ? this.enableUrlEncode : 'data'] = Ext.encode(callData);
22728 o.jsonData = callData;
22730 Ext.Ajax.request(o);
22733 combineAndSend : function(){
22734 var len = this.callBuffer.length;
22736 this.doSend(len == 1 ? this.callBuffer[0] : this.callBuffer);
22737 this.callBuffer = [];
22741 queueTransaction: function(t){
22743 this.processForm(t);
22746 this.callBuffer.push(t);
22747 if(this.enableBuffer){
22748 if(!this.callTask){
22749 this.callTask = new Ext.util.DelayedTask(this.combineAndSend, this);
22751 this.callTask.delay(Ext.isNumber(this.enableBuffer) ? this.enableBuffer : 10);
22753 this.combineAndSend();
22757 doCall : function(c, m, args){
22758 var data = null, hs = args[m.len], scope = args[m.len+1];
22761 data = args.slice(0, m.len);
22764 var t = new Ext.Direct.Transaction({
22770 cb: scope && Ext.isFunction(hs) ? hs.createDelegate(scope) : hs
22773 if(this.fireEvent('beforecall', this, t) !== false){
22774 Ext.Direct.addTransaction(t);
22775 this.queueTransaction(t);
22776 this.fireEvent('call', this, t);
22780 doForm : function(c, m, form, callback, scope){
22781 var t = new Ext.Direct.Transaction({
22785 args:[form, callback, scope],
22786 cb: scope && Ext.isFunction(callback) ? callback.createDelegate(scope) : callback,
22790 if(this.fireEvent('beforecall', this, t) !== false){
22791 Ext.Direct.addTransaction(t);
22792 var isUpload = String(form.getAttribute("enctype")).toLowerCase() == 'multipart/form-data',
22798 extUpload: String(isUpload)
22804 form: Ext.getDom(form),
22805 isUpload: isUpload,
22806 params: callback && Ext.isObject(callback.params) ? Ext.apply(params, callback.params) : params
22808 this.fireEvent('call', this, t);
22809 this.processForm(t);
22813 processForm: function(t){
22817 callback: this.onData,
22820 isUpload: t.isUpload,
22825 createMethod : function(c, m){
22827 if(!m.formHandler){
22829 this.doCall(c, m, Array.prototype.slice.call(arguments, 0));
22830 }.createDelegate(this);
22832 f = function(form, callback, scope){
22833 this.doForm(c, m, form, callback, scope);
22834 }.createDelegate(this);
22843 getTransaction: function(opt){
22844 return opt && opt.tid ? Ext.Direct.getTransaction(opt.tid) : null;
22847 doCallback: function(t, e){
22848 var fn = e.status ? 'success' : 'failure';
22851 result = Ext.isDefined(e.result) ? e.result : e.data;
22852 if(Ext.isFunction(hs)){
22855 Ext.callback(hs[fn], hs.scope, [result, e]);
22856 Ext.callback(hs.callback, hs.scope, [result, e]);
22861 Ext.Direct.PROVIDERS['remoting'] = Ext.direct.RemotingProvider;
22862 Ext.Resizable = function(el, config){
22863 this.el = Ext.get(el);
22865 if(config && config.wrap){
22866 config.resizeChild = this.el;
22867 this.el = this.el.wrap(typeof config.wrap == 'object' ? config.wrap : {cls:'xresizable-wrap'});
22868 this.el.id = this.el.dom.id = config.resizeChild.id + '-rzwrap';
22869 this.el.setStyle('overflow', 'hidden');
22870 this.el.setPositioning(config.resizeChild.getPositioning());
22871 config.resizeChild.clearPositioning();
22872 if(!config.width || !config.height){
22873 var csize = config.resizeChild.getSize();
22874 this.el.setSize(csize.width, csize.height);
22876 if(config.pinned && !config.adjustments){
22877 config.adjustments = 'auto';
22882 this.proxy = this.el.createProxy({tag: 'div', cls: 'x-resizable-proxy', id: this.el.id + '-rzproxy'}, Ext.getBody());
22883 this.proxy.unselectable();
22884 this.proxy.enableDisplayMode('block');
22886 Ext.apply(this, config);
22889 this.disableTrackOver = true;
22890 this.el.addClass('x-resizable-pinned');
22893 var position = this.el.getStyle('position');
22894 if(position != 'absolute' && position != 'fixed'){
22895 this.el.setStyle('position', 'relative');
22898 this.handles = 's,e,se';
22899 if(this.multiDirectional){
22900 this.handles += ',n,w';
22903 if(this.handles == 'all'){
22904 this.handles = 'n s e w ne nw se sw';
22906 var hs = this.handles.split(/\s*?[,;]\s*?| /);
22907 var ps = Ext.Resizable.positions;
22908 for(var i = 0, len = hs.length; i < len; i++){
22909 if(hs[i] && ps[hs[i]]){
22910 var pos = ps[hs[i]];
22911 this[pos] = new Ext.Resizable.Handle(this, pos, this.disableTrackOver, this.transparent);
22915 this.corner = this.southeast;
22917 if(this.handles.indexOf('n') != -1 || this.handles.indexOf('w') != -1){
22918 this.updateBox = true;
22921 this.activeHandle = null;
22923 if(this.resizeChild){
22924 if(typeof this.resizeChild == 'boolean'){
22925 this.resizeChild = Ext.get(this.el.dom.firstChild, true);
22927 this.resizeChild = Ext.get(this.resizeChild, true);
22931 if(this.adjustments == 'auto'){
22932 var rc = this.resizeChild;
22933 var hw = this.west, he = this.east, hn = this.north, hs = this.south;
22934 if(rc && (hw || hn)){
22935 rc.position('relative');
22936 rc.setLeft(hw ? hw.el.getWidth() : 0);
22937 rc.setTop(hn ? hn.el.getHeight() : 0);
22939 this.adjustments = [
22940 (he ? -he.el.getWidth() : 0) + (hw ? -hw.el.getWidth() : 0),
22941 (hn ? -hn.el.getHeight() : 0) + (hs ? -hs.el.getHeight() : 0) -1
22945 if(this.draggable){
22946 this.dd = this.dynamic ?
22947 this.el.initDD(null) : this.el.initDDProxy(null, {dragElId: this.proxy.id});
22948 this.dd.setHandleElId(this.resizeChild ? this.resizeChild.id : this.el.id);
22949 if(this.constrainTo){
22950 this.dd.constrainTo(this.constrainTo);
22961 if(this.width !== null && this.height !== null){
22962 this.resizeTo(this.width, this.height);
22964 this.updateChildSize();
22967 this.el.dom.style.zoom = 1;
22969 Ext.Resizable.superclass.constructor.call(this);
22972 Ext.extend(Ext.Resizable, Ext.util.Observable, {
22975 adjustments : [0, 0],
22980 disableTrackOver : false,
22988 easing : 'easeOutStrong',
22995 multiDirectional : false,
23001 heightIncrement : 0,
23003 widthIncrement : 0,
23019 preserveRatio : false,
23021 resizeChild : false,
23023 transparent: false,
23029 resizeTo : function(width, height){
23030 this.el.setSize(width, height);
23031 this.updateChildSize();
23032 this.fireEvent('resize', this, width, height, null);
23036 startSizing : function(e, handle){
23037 this.fireEvent('beforeresize', this, e);
23041 this.overlay = this.el.createProxy({tag: 'div', cls: 'x-resizable-overlay', html: ' '}, Ext.getBody());
23042 this.overlay.unselectable();
23043 this.overlay.enableDisplayMode('block');
23046 mousemove: this.onMouseMove,
23047 mouseup: this.onMouseUp
23050 this.overlay.setStyle('cursor', handle.el.getStyle('cursor'));
23052 this.resizing = true;
23053 this.startBox = this.el.getBox();
23054 this.startPoint = e.getXY();
23055 this.offsets = [(this.startBox.x + this.startBox.width) - this.startPoint[0],
23056 (this.startBox.y + this.startBox.height) - this.startPoint[1]];
23058 this.overlay.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
23059 this.overlay.show();
23061 if(this.constrainTo) {
23062 var ct = Ext.get(this.constrainTo);
23063 this.resizeRegion = ct.getRegion().adjust(
23064 ct.getFrameWidth('t'),
23065 ct.getFrameWidth('l'),
23066 -ct.getFrameWidth('b'),
23067 -ct.getFrameWidth('r')
23071 this.proxy.setStyle('visibility', 'hidden');
23073 this.proxy.setBox(this.startBox);
23075 this.proxy.setStyle('visibility', 'visible');
23081 onMouseDown : function(handle, e){
23084 this.activeHandle = handle;
23085 this.startSizing(e, handle);
23090 onMouseUp : function(e){
23091 this.activeHandle = null;
23092 var size = this.resizeElement();
23093 this.resizing = false;
23095 this.overlay.hide();
23097 this.fireEvent('resize', this, size.width, size.height, e);
23101 updateChildSize : function(){
23102 if(this.resizeChild){
23104 var child = this.resizeChild;
23105 var adj = this.adjustments;
23106 if(el.dom.offsetWidth){
23107 var b = el.getSize(true);
23108 child.setSize(b.width+adj[0], b.height+adj[1]);
23115 setTimeout(function(){
23116 if(el.dom.offsetWidth){
23117 var b = el.getSize(true);
23118 child.setSize(b.width+adj[0], b.height+adj[1]);
23126 snap : function(value, inc, min){
23127 if(!inc || !value){
23130 var newValue = value;
23131 var m = value % inc;
23134 newValue = value + (inc-m);
23136 newValue = value - m;
23139 return Math.max(min, newValue);
23143 resizeElement : function(){
23144 var box = this.proxy.getBox();
23145 if(this.updateBox){
23146 this.el.setBox(box, false, this.animate, this.duration, null, this.easing);
23148 this.el.setSize(box.width, box.height, this.animate, this.duration, null, this.easing);
23150 this.updateChildSize();
23154 if(this.draggable && this.constrainTo){
23155 this.dd.resetConstraints();
23156 this.dd.constrainTo(this.constrainTo);
23162 constrain : function(v, diff, m, mx){
23165 }else if(v - diff > mx){
23172 onMouseMove : function(e){
23173 if(this.enabled && this.activeHandle){
23176 if(this.resizeRegion && !this.resizeRegion.contains(e.getPoint())) {
23181 var curSize = this.curSize || this.startBox,
23182 x = this.startBox.x, y = this.startBox.y,
23186 h = curSize.height,
23189 mw = this.minWidth,
23190 mh = this.minHeight,
23191 mxw = this.maxWidth,
23192 mxh = this.maxHeight,
23193 wi = this.widthIncrement,
23194 hi = this.heightIncrement,
23195 eventXY = e.getXY(),
23196 diffX = -(this.startPoint[0] - Math.max(this.minX, eventXY[0])),
23197 diffY = -(this.startPoint[1] - Math.max(this.minY, eventXY[1])),
23198 pos = this.activeHandle.position,
23205 w = Math.min(Math.max(mw, w), mxw);
23209 h = Math.min(Math.max(mh, h), mxh);
23214 w = Math.min(Math.max(mw, w), mxw);
23215 h = Math.min(Math.max(mh, h), mxh);
23218 diffY = this.constrain(h, diffY, mh, mxh);
23223 diffX = this.constrain(w, diffX, mw, mxw);
23229 w = Math.min(Math.max(mw, w), mxw);
23230 diffY = this.constrain(h, diffY, mh, mxh);
23235 diffX = this.constrain(w, diffX, mw, mxw);
23236 diffY = this.constrain(h, diffY, mh, mxh);
23243 diffX = this.constrain(w, diffX, mw, mxw);
23245 h = Math.min(Math.max(mh, h), mxh);
23251 var sw = this.snap(w, wi, mw);
23252 var sh = this.snap(h, hi, mh);
23253 if(sw != w || sh != h){
23276 if(this.preserveRatio){
23281 h = Math.min(Math.max(mh, h), mxh);
23286 w = Math.min(Math.max(mw, w), mxw);
23291 w = Math.min(Math.max(mw, w), mxw);
23297 w = Math.min(Math.max(mw, w), mxw);
23303 h = Math.min(Math.max(mh, h), mxh);
23311 h = Math.min(Math.max(mh, h), mxh);
23321 h = Math.min(Math.max(mh, h), mxh);
23329 this.proxy.setBounds(x, y, w, h);
23331 this.resizeElement();
23338 handleOver : function(){
23340 this.el.addClass('x-resizable-over');
23345 handleOut : function(){
23346 if(!this.resizing){
23347 this.el.removeClass('x-resizable-over');
23352 getEl : function(){
23357 getResizeChild : function(){
23358 return this.resizeChild;
23362 destroy : function(removeEl){
23363 Ext.destroy(this.dd, this.overlay, this.proxy);
23364 this.overlay = null;
23367 var ps = Ext.Resizable.positions;
23369 if(typeof ps[k] != 'function' && this[ps[k]]){
23370 this[ps[k]].destroy();
23374 this.el.update('');
23375 Ext.destroy(this.el);
23378 this.purgeListeners();
23381 syncHandleHeight : function(){
23382 var h = this.el.getHeight(true);
23384 this.west.el.setHeight(h);
23387 this.east.el.setHeight(h);
23394 Ext.Resizable.positions = {
23395 n: 'north', s: 'south', e: 'east', w: 'west', se: 'southeast', sw: 'southwest', nw: 'northwest', ne: 'northeast'
23399 Ext.Resizable.Handle = function(rz, pos, disableTrackOver, transparent){
23402 var tpl = Ext.DomHelper.createTemplate(
23403 {tag: 'div', cls: 'x-resizable-handle x-resizable-handle-{0}'}
23406 Ext.Resizable.Handle.prototype.tpl = tpl;
23408 this.position = pos;
23410 this.el = this.tpl.append(rz.el.dom, [this.position], true);
23411 this.el.unselectable();
23413 this.el.setOpacity(0);
23415 this.el.on('mousedown', this.onMouseDown, this);
23416 if(!disableTrackOver){
23419 mouseover: this.onMouseOver,
23420 mouseout: this.onMouseOut
23426 Ext.Resizable.Handle.prototype = {
23428 afterResize : function(rz){
23432 onMouseDown : function(e){
23433 this.rz.onMouseDown(this, e);
23436 onMouseOver : function(e){
23437 this.rz.handleOver(this, e);
23440 onMouseOut : function(e){
23441 this.rz.handleOut(this, e);
23444 destroy : function(){
23445 Ext.destroy(this.el);
23450 Ext.Window = Ext.extend(Ext.Panel, {
23463 baseCls : 'x-window',
23471 closeAction : 'close',
23475 constrainHeader : false,
23479 minimizable : false,
23481 maximizable : false,
23487 expandOnShow : true,
23490 collapsible : false,
23493 initHidden : undefined,
23499 monitorResize : true,
23506 elements : 'header,body',
23513 initComponent : function(){
23515 Ext.Window.superclass.initComponent.call(this);
23529 if(Ext.isDefined(this.initHidden)){
23530 this.hidden = this.initHidden;
23532 if(this.hidden === false){
23533 this.hidden = true;
23539 getState : function(){
23540 return Ext.apply(Ext.Window.superclass.getState.call(this) || {}, this.getBox(true));
23544 onRender : function(ct, position){
23545 Ext.Window.superclass.onRender.call(this, ct, position);
23548 this.el.addClass('x-window-plain');
23552 this.focusEl = this.el.createChild({
23553 tag: 'a', href:'#', cls:'x-dlg-focus',
23554 tabIndex:'-1', html: ' '});
23555 this.focusEl.swallowEvent('click', true);
23557 this.proxy = this.el.createProxy('x-window-proxy');
23558 this.proxy.enableDisplayMode('block');
23561 this.mask = this.container.createChild({cls:'ext-el-mask'}, this.el.dom);
23562 this.mask.enableDisplayMode('block');
23564 this.mon(this.mask, 'click', this.focus, this);
23566 if(this.maximizable){
23567 this.mon(this.header, 'dblclick', this.toggleMaximize, this);
23572 initEvents : function(){
23573 Ext.Window.superclass.initEvents.call(this);
23574 if(this.animateTarget){
23575 this.setAnimateTarget(this.animateTarget);
23578 if(this.resizable){
23579 this.resizer = new Ext.Resizable(this.el, {
23580 minWidth: this.minWidth,
23581 minHeight:this.minHeight,
23582 handles: this.resizeHandles || 'all',
23584 resizeElement : this.resizerAction
23586 this.resizer.window = this;
23587 this.mon(this.resizer, 'beforeresize', this.beforeResize, this);
23590 if(this.draggable){
23591 this.header.addClass('x-window-draggable');
23593 this.mon(this.el, 'mousedown', this.toFront, this);
23594 this.manager = this.manager || Ext.WindowMgr;
23595 this.manager.register(this);
23596 if(this.maximized){
23597 this.maximized = false;
23601 var km = this.getKeyMap();
23602 km.on(27, this.onEsc, this);
23607 initDraggable : function(){
23609 this.dd = new Ext.Window.DD(this);
23613 onEsc : function(){
23614 this[this.closeAction]();
23618 beforeDestroy : function(){
23619 if (this.rendered){
23622 Ext.EventManager.removeResizeListener(this.doAnchor, this);
23623 Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
23633 Ext.Window.superclass.beforeDestroy.call(this);
23637 onDestroy : function(){
23639 this.manager.unregister(this);
23641 Ext.Window.superclass.onDestroy.call(this);
23645 initTools : function(){
23646 if(this.minimizable){
23649 handler: this.minimize.createDelegate(this, [])
23652 if(this.maximizable){
23655 handler: this.maximize.createDelegate(this, [])
23659 handler: this.restore.createDelegate(this, []),
23666 handler: this[this.closeAction].createDelegate(this, [])
23672 resizerAction : function(){
23673 var box = this.proxy.getBox();
23675 this.window.handleResize(box);
23680 beforeResize : function(){
23681 this.resizer.minHeight = Math.max(this.minHeight, this.getFrameHeight() + 40);
23682 this.resizer.minWidth = Math.max(this.minWidth, this.getFrameWidth() + 40);
23683 this.resizeBox = this.el.getBox();
23687 updateHandles : function(){
23688 if(Ext.isIE && this.resizer){
23689 this.resizer.syncHandleHeight();
23695 handleResize : function(box){
23696 var rz = this.resizeBox;
23697 if(rz.x != box.x || rz.y != box.y){
23698 this.updateBox(box);
23703 this.updateHandles();
23708 focus : function(){
23709 var f = this.focusEl, db = this.defaultButton, t = typeof db;
23710 if(Ext.isDefined(db)){
23711 if(Ext.isNumber(db) && this.fbar){
23712 f = this.fbar.items.get(db);
23713 }else if(Ext.isString(db)){
23714 f = Ext.getCmp(db);
23719 f = f || this.focusEl;
23720 f.focus.defer(10, f);
23724 setAnimateTarget : function(el){
23726 this.animateTarget = el;
23730 beforeShow : function(){
23731 delete this.el.lastXY;
23732 delete this.el.lastLT;
23733 if(this.x === undefined || this.y === undefined){
23734 var xy = this.el.getAlignToXY(this.container, 'c-c');
23735 var pos = this.el.translatePoints(xy[0], xy[1]);
23736 this.x = this.x === undefined? pos.left : this.x;
23737 this.y = this.y === undefined? pos.top : this.y;
23739 this.el.setLeftTop(this.x, this.y);
23741 if(this.expandOnShow){
23742 this.expand(false);
23746 Ext.getBody().addClass('x-body-masked');
23747 this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
23753 show : function(animateTarget, cb, scope){
23754 if(!this.rendered){
23755 this.render(Ext.getBody());
23757 if(this.hidden === false){
23761 if(this.fireEvent('beforeshow', this) === false){
23765 this.on('show', cb, scope, {single:true});
23767 this.hidden = false;
23768 if(Ext.isDefined(animateTarget)){
23769 this.setAnimateTarget(animateTarget);
23772 if(this.animateTarget){
23781 afterShow : function(isAnim){
23783 this.el.setStyle('display', 'block');
23785 if(this.maximized){
23786 this.fitContainer();
23788 if(Ext.isMac && Ext.isGecko2){
23789 this.cascade(this.setAutoScroll);
23792 if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
23793 Ext.EventManager.onWindowResize(this.onWindowResize, this);
23795 this.doConstrain();
23798 this.keyMap.enable();
23801 this.updateHandles();
23802 if(isAnim && (Ext.isIE || Ext.isWebKit)){
23803 var sz = this.getSize();
23804 this.onResize(sz.width, sz.height);
23807 this.fireEvent('show', this);
23811 animShow : function(){
23813 this.proxy.setBox(this.animateTarget.getBox());
23814 this.proxy.setOpacity(0);
23815 var b = this.getBox();
23816 this.el.setStyle('display', 'none');
23817 this.proxy.shift(Ext.apply(b, {
23818 callback: this.afterShow.createDelegate(this, [true], false),
23820 easing: 'easeNone',
23827 hide : function(animateTarget, cb, scope){
23828 if(this.hidden || this.fireEvent('beforehide', this) === false){
23832 this.on('hide', cb, scope, {single:true});
23834 this.hidden = true;
23835 if(animateTarget !== undefined){
23836 this.setAnimateTarget(animateTarget);
23840 Ext.getBody().removeClass('x-body-masked');
23842 if(this.animateTarget){
23852 afterHide : function(){
23854 if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
23855 Ext.EventManager.removeResizeListener(this.onWindowResize, this);
23858 this.keyMap.disable();
23861 this.fireEvent('hide', this);
23865 animHide : function(){
23866 this.proxy.setOpacity(0.5);
23868 var tb = this.getBox(false);
23869 this.proxy.setBox(tb);
23871 this.proxy.shift(Ext.apply(this.animateTarget.getBox(), {
23872 callback: this.afterHide,
23875 easing: 'easeNone',
23881 onShow : Ext.emptyFn,
23884 onHide : Ext.emptyFn,
23887 onWindowResize : function(){
23888 if(this.maximized){
23889 this.fitContainer();
23892 this.mask.setSize('100%', '100%');
23893 var force = this.mask.dom.offsetHeight;
23894 this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
23896 this.doConstrain();
23900 doConstrain : function(){
23901 if(this.constrain || this.constrainHeader){
23903 if(this.constrain){
23905 right:this.el.shadowOffset,
23906 left:this.el.shadowOffset,
23907 bottom:this.el.shadowOffset
23910 var s = this.getSize();
23912 right:-(s.width - 100),
23913 bottom:-(s.height - 25)
23917 var xy = this.el.getConstrainToXY(this.container, true, offsets);
23919 this.setPosition(xy[0], xy[1]);
23925 ghost : function(cls){
23926 var ghost = this.createGhost(cls);
23927 var box = this.getBox(true);
23928 ghost.setLeftTop(box.x, box.y);
23929 ghost.setWidth(box.width);
23931 this.activeGhost = ghost;
23936 unghost : function(show, matchPosition){
23937 if(!this.activeGhost) {
23940 if(show !== false){
23943 if(Ext.isMac && Ext.isGecko2){
23944 this.cascade(this.setAutoScroll);
23947 if(matchPosition !== false){
23948 this.setPosition(this.activeGhost.getLeft(true), this.activeGhost.getTop(true));
23950 this.activeGhost.hide();
23951 this.activeGhost.remove();
23952 delete this.activeGhost;
23956 minimize : function(){
23957 this.fireEvent('minimize', this);
23962 close : function(){
23963 if(this.fireEvent('beforeclose', this) !== false){
23967 this.hide(null, this.doClose, this);
23973 doClose : function(){
23974 this.fireEvent('close', this);
23979 maximize : function(){
23980 if(!this.maximized){
23981 this.expand(false);
23982 this.restoreSize = this.getSize();
23983 this.restorePos = this.getPosition(true);
23984 if (this.maximizable){
23985 this.tools.maximize.hide();
23986 this.tools.restore.show();
23988 this.maximized = true;
23989 this.el.disableShadow();
23994 if(this.collapsible){
23995 this.tools.toggle.hide();
23997 this.el.addClass('x-window-maximized');
23998 this.container.addClass('x-window-maximized-ct');
24000 this.setPosition(0, 0);
24001 this.fitContainer();
24002 this.fireEvent('maximize', this);
24008 restore : function(){
24009 if(this.maximized){
24010 var t = this.tools;
24011 this.el.removeClass('x-window-maximized');
24018 this.setPosition(this.restorePos[0], this.restorePos[1]);
24019 this.setSize(this.restoreSize.width, this.restoreSize.height);
24020 delete this.restorePos;
24021 delete this.restoreSize;
24022 this.maximized = false;
24023 this.el.enableShadow(true);
24028 if(this.collapsible && t.toggle){
24031 this.container.removeClass('x-window-maximized-ct');
24033 this.doConstrain();
24034 this.fireEvent('restore', this);
24040 toggleMaximize : function(){
24041 return this[this.maximized ? 'restore' : 'maximize']();
24045 fitContainer : function(){
24046 var vs = this.container.getViewSize(false);
24047 this.setSize(vs.width, vs.height);
24052 setZIndex : function(index){
24054 this.mask.setStyle('z-index', index);
24056 this.el.setZIndex(++index);
24060 this.resizer.proxy.setStyle('z-index', ++index);
24063 this.lastZIndex = index;
24067 alignTo : function(element, position, offsets){
24068 var xy = this.el.getAlignToXY(element, position, offsets);
24069 this.setPagePosition(xy[0], xy[1]);
24074 anchorTo : function(el, alignment, offsets, monitorScroll){
24076 Ext.EventManager.removeResizeListener(this.doAnchor, this);
24077 Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
24079 this.doAnchor = function(){
24080 this.alignTo(el, alignment, offsets);
24082 Ext.EventManager.onWindowResize(this.doAnchor, this);
24084 var tm = typeof monitorScroll;
24085 if(tm != 'undefined'){
24086 Ext.EventManager.on(window, 'scroll', this.doAnchor, this,
24087 {buffer: tm == 'number' ? monitorScroll : 50});
24094 toFront : function(e){
24095 if(this.manager.bringToFront(this)){
24096 if(!e || !e.getTarget().focus){
24104 setActive : function(active){
24106 if(!this.maximized){
24107 this.el.enableShadow(true);
24109 this.fireEvent('activate', this);
24111 this.el.disableShadow();
24112 this.fireEvent('deactivate', this);
24117 toBack : function(){
24118 this.manager.sendToBack(this);
24123 center : function(){
24124 var xy = this.el.getAlignToXY(this.container, 'c-c');
24125 this.setPagePosition(xy[0], xy[1]);
24131 Ext.reg('window', Ext.Window);
24134 Ext.Window.DD = function(win){
24136 Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id);
24137 this.setHandleElId(win.header.id);
24138 this.scroll = false;
24141 Ext.extend(Ext.Window.DD, Ext.dd.DD, {
24143 headerOffsets:[100, 25],
24144 startDrag : function(){
24146 this.proxy = w.ghost();
24147 if(w.constrain !== false){
24148 var so = w.el.shadowOffset;
24149 this.constrainTo(w.container, {right: so, left: so, bottom: so});
24150 }else if(w.constrainHeader !== false){
24151 var s = this.proxy.getSize();
24152 this.constrainTo(w.container, {right: -(s.width-this.headerOffsets[0]), bottom: -(s.height-this.headerOffsets[1])});
24155 b4Drag : Ext.emptyFn,
24157 onDrag : function(e){
24158 this.alignElWithMouse(this.proxy, e.getPageX(), e.getPageY());
24161 endDrag : function(e){
24162 this.win.unghost();
24163 this.win.saveState();
24167 Ext.WindowGroup = function(){
24169 var accessList = [];
24173 var sortWindows = function(d1, d2){
24174 return (!d1._lastAccess || d1._lastAccess < d2._lastAccess) ? -1 : 1;
24178 var orderWindows = function(){
24179 var a = accessList, len = a.length;
24181 a.sort(sortWindows);
24182 var seed = a[0].manager.zseed;
24183 for(var i = 0; i < len; i++){
24185 if(win && !win.hidden){
24186 win.setZIndex(seed + (i*10));
24194 var setActiveWin = function(win){
24197 front.setActive(false);
24201 win.setActive(true);
24207 var activateLast = function(){
24208 for(var i = accessList.length-1; i >=0; --i) {
24209 if(!accessList[i].hidden){
24210 setActiveWin(accessList[i]);
24215 setActiveWin(null);
24223 register : function(win){
24225 win.manager.unregister(win);
24227 win.manager = this;
24229 list[win.id] = win;
24230 accessList.push(win);
24231 win.on('hide', activateLast);
24235 unregister : function(win){
24236 delete win.manager;
24237 delete list[win.id];
24238 win.un('hide', activateLast);
24239 accessList.remove(win);
24243 get : function(id){
24244 return typeof id == "object" ? id : list[id];
24248 bringToFront : function(win){
24249 win = this.get(win);
24251 win._lastAccess = new Date().getTime();
24259 sendToBack : function(win){
24260 win = this.get(win);
24261 win._lastAccess = -(new Date().getTime());
24267 hideAll : function(){
24268 for(var id in list){
24269 if(list[id] && typeof list[id] != "function" && list[id].isVisible()){
24276 getActive : function(){
24281 getBy : function(fn, scope){
24283 for(var i = accessList.length-1; i >=0; --i) {
24284 var win = accessList[i];
24285 if(fn.call(scope||win, win) !== false){
24293 each : function(fn, scope){
24294 for(var id in list){
24295 if(list[id] && typeof list[id] != "function"){
24296 if(fn.call(scope || list[id], list[id]) === false){
24307 Ext.WindowMgr = new Ext.WindowGroup();
24308 Ext.MessageBox = function(){
24309 var dlg, opt, mask, waitTimer,
24310 bodyEl, msgEl, textboxEl, textareaEl, progressBar, pp, iconEl, spacerEl,
24311 buttons, activeTextEl, bwidth, bufferIcon = '', iconCls = '',
24312 buttonNames = ['ok', 'yes', 'no', 'cancel'];
24315 var handleButton = function(button){
24316 buttons[button].blur();
24317 if(dlg.isVisible()){
24320 Ext.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value, opt], 1);
24325 var handleHide = function(){
24326 if(opt && opt.cls){
24327 dlg.el.removeClass(opt.cls);
24329 progressBar.reset();
24333 var handleEsc = function(d, k, e){
24334 if(opt && opt.closable !== false){
24344 var updateButtons = function(b){
24348 Ext.each(buttonNames, function(name){
24349 buttons[name].hide();
24353 dlg.footer.dom.style.display = '';
24354 Ext.iterate(buttons, function(name, btn){
24358 btn.setText(Ext.isString(cfg) ? cfg : Ext.MessageBox.buttonText[name]);
24359 width += btn.getEl().getWidth() + 15;
24369 getDialog : function(titleText){
24374 Ext.each(buttonNames, function(name){
24375 btns.push(buttons[name] = new Ext.Button({
24376 text: this.buttonText[name],
24377 handler: handleButton.createCallback(name),
24378 hideMode: 'offsets'
24381 dlg = new Ext.Window({
24386 constrainHeader:true,
24387 minimizable : false,
24388 maximizable : false,
24392 buttonAlign:"center",
24399 close : function(){
24400 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
24401 handleButton("no");
24403 handleButton("cancel");
24406 fbar: new Ext.Toolbar({
24408 enableOverflow: false
24411 dlg.render(document.body);
24412 dlg.getEl().addClass('x-window-dlg');
24414 bodyEl = dlg.body.createChild({
24415 html:'<div class="ext-mb-icon"></div><div class="ext-mb-content"><span class="ext-mb-text"></span><br /><div class="ext-mb-fix-cursor"><input type="text" class="ext-mb-input" /><textarea class="ext-mb-textarea"></textarea></div></div>'
24417 iconEl = Ext.get(bodyEl.dom.firstChild);
24418 var contentEl = bodyEl.dom.childNodes[1];
24419 msgEl = Ext.get(contentEl.firstChild);
24420 textboxEl = Ext.get(contentEl.childNodes[2].firstChild);
24421 textboxEl.enableDisplayMode();
24422 textboxEl.addKeyListener([10,13], function(){
24423 if(dlg.isVisible() && opt && opt.buttons){
24424 if(opt.buttons.ok){
24425 handleButton("ok");
24426 }else if(opt.buttons.yes){
24427 handleButton("yes");
24431 textareaEl = Ext.get(contentEl.childNodes[2].childNodes[1]);
24432 textareaEl.enableDisplayMode();
24433 progressBar = new Ext.ProgressBar({
24436 bodyEl.createChild({cls:'x-clear'});
24442 updateText : function(text){
24443 if(!dlg.isVisible() && !opt.width){
24444 dlg.setSize(this.maxWidth, 100);
24446 msgEl.update(text || ' ');
24448 var iw = iconCls != '' ? (iconEl.getWidth() + iconEl.getMargins('lr')) : 0;
24449 var mw = msgEl.getWidth() + msgEl.getMargins('lr');
24450 var fw = dlg.getFrameWidth('lr');
24451 var bw = dlg.body.getFrameWidth('lr');
24452 if (Ext.isIE && iw > 0){
24457 var w = Math.max(Math.min(opt.width || iw+mw+fw+bw, this.maxWidth),
24458 Math.max(opt.minWidth || this.minWidth, bwidth || 0));
24460 if(opt.prompt === true){
24461 activeTextEl.setWidth(w-iw-fw-bw);
24463 if(opt.progress === true || opt.wait === true){
24464 progressBar.setSize(w-iw-fw-bw);
24466 if(Ext.isIE && w == bwidth){
24469 dlg.setSize(w, 'auto').center();
24474 updateProgress : function(value, progressText, msg){
24475 progressBar.updateProgress(value, progressText);
24477 this.updateText(msg);
24483 isVisible : function(){
24484 return dlg && dlg.isVisible();
24489 var proxy = dlg ? dlg.activeGhost : null;
24490 if(this.isVisible() || proxy){
24496 dlg.unghost(false, false);
24503 show : function(options){
24504 if(this.isVisible()){
24508 var d = this.getDialog(opt.title || " ");
24510 d.setTitle(opt.title || " ");
24511 var allowClose = (opt.closable !== false && opt.progress !== true && opt.wait !== true);
24512 d.tools.close.setDisplayed(allowClose);
24513 activeTextEl = textboxEl;
24514 opt.prompt = opt.prompt || (opt.multiline ? true : false);
24519 textareaEl.setHeight(Ext.isNumber(opt.multiline) ? opt.multiline : this.defaultTextHeight);
24520 activeTextEl = textareaEl;
24529 activeTextEl.dom.value = opt.value || "";
24531 d.focusEl = activeTextEl;
24533 var bs = opt.buttons;
24536 db = buttons["ok"];
24537 }else if(bs && bs.yes){
24538 db = buttons["yes"];
24545 d.setIconClass(opt.iconCls);
24547 this.setIcon(Ext.isDefined(opt.icon) ? opt.icon : bufferIcon);
24548 bwidth = updateButtons(opt.buttons);
24549 progressBar.setVisible(opt.progress === true || opt.wait === true);
24550 this.updateProgress(0, opt.progressText);
24551 this.updateText(opt.msg);
24553 d.el.addClass(opt.cls);
24555 d.proxyDrag = opt.proxyDrag === true;
24556 d.modal = opt.modal !== false;
24557 d.mask = opt.modal !== false ? mask : false;
24558 if(!d.isVisible()){
24560 document.body.appendChild(dlg.el.dom);
24561 d.setAnimateTarget(opt.animEl);
24563 d.on('show', function(){
24564 if(allowClose === true){
24567 d.keyMap.disable();
24569 }, this, {single:true});
24570 d.show(opt.animEl);
24572 if(opt.wait === true){
24573 progressBar.wait(opt.waitConfig);
24579 setIcon : function(icon){
24584 bufferIcon = undefined;
24585 if(icon && icon != ''){
24586 iconEl.removeClass('x-hidden');
24587 iconEl.replaceClass(iconCls, icon);
24588 bodyEl.addClass('x-dlg-icon');
24591 iconEl.replaceClass(iconCls, 'x-hidden');
24592 bodyEl.removeClass('x-dlg-icon');
24599 progress : function(title, msg, progressText){
24606 minWidth: this.minProgressWidth,
24607 progressText: progressText
24613 wait : function(msg, title, config){
24621 minWidth: this.minProgressWidth,
24628 alert : function(title, msg, fn, scope){
24640 confirm : function(title, msg, fn, scope){
24644 buttons: this.YESNO,
24647 icon: this.QUESTION
24653 prompt : function(title, msg, fn, scope, multiline, value){
24657 buttons: this.OKCANCEL,
24662 multiline: multiline,
24671 CANCEL : {cancel:true},
24673 OKCANCEL : {ok:true, cancel:true},
24675 YESNO : {yes:true, no:true},
24677 YESNOCANCEL : {yes:true, no:true, cancel:true},
24679 INFO : 'ext-mb-info',
24681 WARNING : 'ext-mb-warning',
24683 QUESTION : 'ext-mb-question',
24685 ERROR : 'ext-mb-error',
24688 defaultTextHeight : 75,
24694 minProgressWidth : 250,
24706 Ext.Msg = Ext.MessageBox;
24707 Ext.dd.PanelProxy = function(panel, config){
24708 this.panel = panel;
24709 this.id = this.panel.id +'-ddproxy';
24710 Ext.apply(this, config);
24713 Ext.dd.PanelProxy.prototype = {
24715 insertProxy : true,
24718 setStatus : Ext.emptyFn,
24719 reset : Ext.emptyFn,
24720 update : Ext.emptyFn,
24721 stop : Ext.emptyFn,
24725 getEl : function(){
24730 getGhost : function(){
24735 getProxy : function(){
24743 this.proxy.remove();
24746 this.panel.el.dom.style.display = '';
24747 this.ghost.remove();
24755 this.ghost = this.panel.createGhost(undefined, undefined, Ext.getBody());
24756 this.ghost.setXY(this.panel.el.getXY())
24757 if(this.insertProxy){
24758 this.proxy = this.panel.el.insertSibling({cls:'x-panel-dd-spacer'});
24759 this.proxy.setSize(this.panel.getSize());
24761 this.panel.el.dom.style.display = 'none';
24766 repair : function(xy, callback, scope){
24768 if(typeof callback == "function"){
24769 callback.call(scope || this);
24774 moveProxy : function(parentNode, before){
24776 parentNode.insertBefore(this.proxy.dom, before);
24782 Ext.Panel.DD = function(panel, cfg){
24783 this.panel = panel;
24784 this.dragData = {panel: panel};
24785 this.proxy = new Ext.dd.PanelProxy(panel, cfg);
24786 Ext.Panel.DD.superclass.constructor.call(this, panel.el, cfg);
24787 var h = panel.header;
24789 this.setHandleElId(h.id);
24791 (h ? h : this.panel.body).setStyle('cursor', 'move');
24792 this.scroll = false;
24795 Ext.extend(Ext.Panel.DD, Ext.dd.DragSource, {
24796 showFrame: Ext.emptyFn,
24797 startDrag: Ext.emptyFn,
24798 b4StartDrag: function(x, y) {
24801 b4MouseDown: function(e) {
24802 var x = e.getPageX();
24803 var y = e.getPageY();
24804 this.autoOffset(x, y);
24806 onInitDrag : function(x, y){
24807 this.onStartDrag(x, y);
24810 createFrame : Ext.emptyFn,
24811 getDragEl : function(e){
24812 return this.proxy.ghost.dom;
24814 endDrag : function(e){
24816 this.panel.saveState();
24819 autoOffset : function(x, y) {
24820 x -= this.startPageX;
24821 y -= this.startPageY;
24822 this.setDelta(x, y);
24825 Ext.state.Provider = function(){
24827 this.addEvents("statechange");
24829 Ext.state.Provider.superclass.constructor.call(this);
24831 Ext.extend(Ext.state.Provider, Ext.util.Observable, {
24833 get : function(name, defaultValue){
24834 return typeof this.state[name] == "undefined" ?
24835 defaultValue : this.state[name];
24839 clear : function(name){
24840 delete this.state[name];
24841 this.fireEvent("statechange", this, name, null);
24845 set : function(name, value){
24846 this.state[name] = value;
24847 this.fireEvent("statechange", this, name, value);
24851 decodeValue : function(cookie){
24852 var re = /^(a|n|d|b|s|o)\:(.*)$/;
24853 var matches = re.exec(unescape(cookie));
24854 if(!matches || !matches[1]) return;
24855 var type = matches[1];
24856 var v = matches[2];
24859 return parseFloat(v);
24861 return new Date(Date.parse(v));
24867 Ext.each(v.split('^'), function(val){
24868 all.push(this.decodeValue(val));
24875 Ext.each(v.split('^'), function(val){
24876 var kv = val.split('=');
24877 all[kv[0]] = this.decodeValue(kv[1]);
24887 encodeValue : function(v){
24889 if(typeof v == "number"){
24891 }else if(typeof v == "boolean"){
24892 enc = "b:" + (v ? "1" : "0");
24893 }else if(Ext.isDate(v)){
24894 enc = "d:" + v.toGMTString();
24895 }else if(Ext.isArray(v)){
24897 for(var i = 0, len = v.length; i < len; i++){
24898 flat += this.encodeValue(v[i]);
24899 if(i != len-1) flat += "^";
24902 }else if(typeof v == "object"){
24905 if(typeof v[key] != "function" && v[key] !== undefined){
24906 flat += key + "=" + this.encodeValue(v[key]) + "^";
24909 enc = "o:" + flat.substring(0, flat.length-1);
24913 return escape(enc);
24917 Ext.state.Manager = function(){
24918 var provider = new Ext.state.Provider();
24922 setProvider : function(stateProvider){
24923 provider = stateProvider;
24927 get : function(key, defaultValue){
24928 return provider.get(key, defaultValue);
24932 set : function(key, value){
24933 provider.set(key, value);
24937 clear : function(key){
24938 provider.clear(key);
24942 getProvider : function(){
24948 Ext.state.CookieProvider = function(config){
24949 Ext.state.CookieProvider.superclass.constructor.call(this);
24951 this.expires = new Date(new Date().getTime()+(1000*60*60*24*7));
24952 this.domain = null;
24953 this.secure = false;
24954 Ext.apply(this, config);
24955 this.state = this.readCookies();
24958 Ext.extend(Ext.state.CookieProvider, Ext.state.Provider, {
24960 set : function(name, value){
24961 if(typeof value == "undefined" || value === null){
24965 this.setCookie(name, value);
24966 Ext.state.CookieProvider.superclass.set.call(this, name, value);
24970 clear : function(name){
24971 this.clearCookie(name);
24972 Ext.state.CookieProvider.superclass.clear.call(this, name);
24976 readCookies : function(){
24978 var c = document.cookie + ";";
24979 var re = /\s?(.*?)=(.*?);/g;
24981 while((matches = re.exec(c)) != null){
24982 var name = matches[1];
24983 var value = matches[2];
24984 if(name && name.substring(0,3) == "ys-"){
24985 cookies[name.substr(3)] = this.decodeValue(value);
24992 setCookie : function(name, value){
24993 document.cookie = "ys-"+ name + "=" + this.encodeValue(value) +
24994 ((this.expires == null) ? "" : ("; expires=" + this.expires.toGMTString())) +
24995 ((this.path == null) ? "" : ("; path=" + this.path)) +
24996 ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
24997 ((this.secure == true) ? "; secure" : "");
25001 clearCookie : function(name){
25002 document.cookie = "ys-" + name + "=null; expires=Thu, 01-Jan-70 00:00:01 GMT" +
25003 ((this.path == null) ? "" : ("; path=" + this.path)) +
25004 ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
25005 ((this.secure == true) ? "; secure" : "");
25008 Ext.DataView = Ext.extend(Ext.BoxComponent, {
25018 selectedClass : "x-view-selected",
25023 deferEmptyText: true,
25031 initComponent : function(){
25032 Ext.DataView.superclass.initComponent.call(this);
25033 if(Ext.isString(this.tpl) || Ext.isArray(this.tpl)){
25034 this.tpl = new Ext.XTemplate(this.tpl);
25053 "containercontextmenu",
25061 this.store = Ext.StoreMgr.lookup(this.store);
25062 this.all = new Ext.CompositeElementLite();
25063 this.selected = new Ext.CompositeElementLite();
25067 afterRender : function(){
25068 Ext.DataView.superclass.afterRender.call(this);
25070 this.mon(this.getTemplateTarget(), {
25071 "click": this.onClick,
25072 "dblclick": this.onDblClick,
25073 "contextmenu": this.onContextMenu,
25077 if(this.overClass || this.trackOver){
25078 this.mon(this.getTemplateTarget(), {
25079 "mouseover": this.onMouseOver,
25080 "mouseout": this.onMouseOut,
25086 this.bindStore(this.store, true);
25091 refresh : function(){
25092 this.clearSelections(false, true);
25093 var el = this.getTemplateTarget();
25095 var records = this.store.getRange();
25096 if(records.length < 1){
25097 if(!this.deferEmptyText || this.hasSkippedEmptyText){
25098 el.update(this.emptyText);
25102 this.tpl.overwrite(el, this.collectData(records, 0));
25103 this.all.fill(Ext.query(this.itemSelector, el.dom));
25104 this.updateIndexes(0);
25106 this.hasSkippedEmptyText = true;
25109 getTemplateTarget: function(){
25114 prepareData : function(data){
25119 collectData : function(records, startIndex){
25121 for(var i = 0, len = records.length; i < len; i++){
25122 r[r.length] = this.prepareData(records[i].data, startIndex+i, records[i]);
25128 bufferRender : function(records){
25129 var div = document.createElement('div');
25130 this.tpl.overwrite(div, this.collectData(records));
25131 return Ext.query(this.itemSelector, div);
25135 onUpdate : function(ds, record){
25136 var index = this.store.indexOf(record);
25138 var sel = this.isSelected(index);
25139 var original = this.all.elements[index];
25140 var node = this.bufferRender([record], index)[0];
25142 this.all.replaceElement(index, node, true);
25144 this.selected.replaceElement(original, node);
25145 this.all.item(index).addClass(this.selectedClass);
25147 this.updateIndexes(index, index);
25152 onAdd : function(ds, records, index){
25153 if(this.all.getCount() === 0){
25157 var nodes = this.bufferRender(records, index), n, a = this.all.elements;
25158 if(index < this.all.getCount()){
25159 n = this.all.item(index).insertSibling(nodes, 'before', true);
25160 a.splice.apply(a, [index, 0].concat(nodes));
25162 n = this.all.last().insertSibling(nodes, 'after', true);
25163 a.push.apply(a, nodes);
25165 this.updateIndexes(index);
25169 onRemove : function(ds, record, index){
25170 this.deselect(index);
25171 this.all.removeElement(index, true);
25172 this.updateIndexes(index);
25173 if (this.store.getCount() === 0){
25179 refreshNode : function(index){
25180 this.onUpdate(this.store, this.store.getAt(index));
25184 updateIndexes : function(startIndex, endIndex){
25185 var ns = this.all.elements;
25186 startIndex = startIndex || 0;
25187 endIndex = endIndex || ((endIndex === 0) ? 0 : (ns.length - 1));
25188 for(var i = startIndex; i <= endIndex; i++){
25189 ns[i].viewIndex = i;
25194 getStore : function(){
25199 bindStore : function(store, initial){
25200 if(!initial && this.store){
25201 if(store !== this.store && this.store.autoDestroy){
25202 this.store.destroy();
25204 this.store.un("beforeload", this.onBeforeLoad, this);
25205 this.store.un("datachanged", this.refresh, this);
25206 this.store.un("add", this.onAdd, this);
25207 this.store.un("remove", this.onRemove, this);
25208 this.store.un("update", this.onUpdate, this);
25209 this.store.un("clear", this.refresh, this);
25216 store = Ext.StoreMgr.lookup(store);
25219 beforeload: this.onBeforeLoad,
25220 datachanged: this.refresh,
25222 remove: this.onRemove,
25223 update: this.onUpdate,
25224 clear: this.refresh
25227 this.store = store;
25234 findItemFromChild : function(node){
25235 return Ext.fly(node).findParent(this.itemSelector, this.getTemplateTarget());
25239 onClick : function(e){
25240 var item = e.getTarget(this.itemSelector, this.getTemplateTarget());
25242 var index = this.indexOf(item);
25243 if(this.onItemClick(item, index, e) !== false){
25244 this.fireEvent("click", this, index, item, e);
25247 if(this.fireEvent("containerclick", this, e) !== false){
25248 this.onContainerClick(e);
25253 onContainerClick : function(e){
25254 this.clearSelections();
25258 onContextMenu : function(e){
25259 var item = e.getTarget(this.itemSelector, this.getTemplateTarget());
25261 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
25263 this.fireEvent("containercontextmenu", this, e);
25268 onDblClick : function(e){
25269 var item = e.getTarget(this.itemSelector, this.getTemplateTarget());
25271 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
25276 onMouseOver : function(e){
25277 var item = e.getTarget(this.itemSelector, this.getTemplateTarget());
25278 if(item && item !== this.lastItem){
25279 this.lastItem = item;
25280 Ext.fly(item).addClass(this.overClass);
25281 this.fireEvent("mouseenter", this, this.indexOf(item), item, e);
25286 onMouseOut : function(e){
25288 if(!e.within(this.lastItem, true, true)){
25289 Ext.fly(this.lastItem).removeClass(this.overClass);
25290 this.fireEvent("mouseleave", this, this.indexOf(this.lastItem), this.lastItem, e);
25291 delete this.lastItem;
25297 onItemClick : function(item, index, e){
25298 if(this.fireEvent("beforeclick", this, index, item, e) === false){
25301 if(this.multiSelect){
25302 this.doMultiSelection(item, index, e);
25303 e.preventDefault();
25304 }else if(this.singleSelect){
25305 this.doSingleSelection(item, index, e);
25306 e.preventDefault();
25312 doSingleSelection : function(item, index, e){
25313 if(e.ctrlKey && this.isSelected(index)){
25314 this.deselect(index);
25316 this.select(index, false);
25321 doMultiSelection : function(item, index, e){
25322 if(e.shiftKey && this.last !== false){
25323 var last = this.last;
25324 this.selectRange(last, index, e.ctrlKey);
25327 if((e.ctrlKey||this.simpleSelect) && this.isSelected(index)){
25328 this.deselect(index);
25330 this.select(index, e.ctrlKey || e.shiftKey || this.simpleSelect);
25336 getSelectionCount : function(){
25337 return this.selected.getCount();
25341 getSelectedNodes : function(){
25342 return this.selected.elements;
25346 getSelectedIndexes : function(){
25347 var indexes = [], s = this.selected.elements;
25348 for(var i = 0, len = s.length; i < len; i++){
25349 indexes.push(s[i].viewIndex);
25355 getSelectedRecords : function(){
25356 var r = [], s = this.selected.elements;
25357 for(var i = 0, len = s.length; i < len; i++){
25358 r[r.length] = this.store.getAt(s[i].viewIndex);
25364 getRecords : function(nodes){
25365 var r = [], s = nodes;
25366 for(var i = 0, len = s.length; i < len; i++){
25367 r[r.length] = this.store.getAt(s[i].viewIndex);
25373 getRecord : function(node){
25374 return this.store.getAt(node.viewIndex);
25378 clearSelections : function(suppressEvent, skipUpdate){
25379 if((this.multiSelect || this.singleSelect) && this.selected.getCount() > 0){
25381 this.selected.removeClass(this.selectedClass);
25383 this.selected.clear();
25385 if(!suppressEvent){
25386 this.fireEvent("selectionchange", this, this.selected.elements);
25392 isSelected : function(node){
25393 return this.selected.contains(this.getNode(node));
25397 deselect : function(node){
25398 if(this.isSelected(node)){
25399 node = this.getNode(node);
25400 this.selected.removeElement(node);
25401 if(this.last == node.viewIndex){
25404 Ext.fly(node).removeClass(this.selectedClass);
25405 this.fireEvent("selectionchange", this, this.selected.elements);
25410 select : function(nodeInfo, keepExisting, suppressEvent){
25411 if(Ext.isArray(nodeInfo)){
25413 this.clearSelections(true);
25415 for(var i = 0, len = nodeInfo.length; i < len; i++){
25416 this.select(nodeInfo[i], true, true);
25418 if(!suppressEvent){
25419 this.fireEvent("selectionchange", this, this.selected.elements);
25422 var node = this.getNode(nodeInfo);
25424 this.clearSelections(true);
25426 if(node && !this.isSelected(node)){
25427 if(this.fireEvent("beforeselect", this, node, this.selected.elements) !== false){
25428 Ext.fly(node).addClass(this.selectedClass);
25429 this.selected.add(node);
25430 this.last = node.viewIndex;
25431 if(!suppressEvent){
25432 this.fireEvent("selectionchange", this, this.selected.elements);
25440 selectRange : function(start, end, keepExisting){
25442 this.clearSelections(true);
25444 this.select(this.getNodes(start, end), true);
25448 getNode : function(nodeInfo){
25449 if(Ext.isString(nodeInfo)){
25450 return document.getElementById(nodeInfo);
25451 }else if(Ext.isNumber(nodeInfo)){
25452 return this.all.elements[nodeInfo];
25458 getNodes : function(start, end){
25459 var ns = this.all.elements;
25460 start = start || 0;
25461 end = !Ext.isDefined(end) ? Math.max(ns.length - 1, 0) : end;
25464 for(i = start; i <= end && ns[i]; i++){
25468 for(i = start; i >= end && ns[i]; i--){
25476 indexOf : function(node){
25477 node = this.getNode(node);
25478 if(Ext.isNumber(node.viewIndex)){
25479 return node.viewIndex;
25481 return this.all.indexOf(node);
25485 onBeforeLoad : function(){
25486 if(this.loadingText){
25487 this.clearSelections(false, true);
25488 this.getTemplateTarget().update('<div class="loading-indicator">'+this.loadingText+'</div>');
25493 onDestroy : function(){
25495 this.selected.clear();
25496 Ext.DataView.superclass.onDestroy.call(this);
25497 this.bindStore(null);
25502 Ext.DataView.prototype.setStore = Ext.DataView.prototype.bindStore;
25504 Ext.reg('dataview', Ext.DataView);
25506 Ext.list.ListView = Ext.extend(Ext.DataView, {
25510 itemSelector: 'dl',
25512 selectedClass:'x-list-selected',
25514 overClass:'x-list-over',
25517 scrollOffset : undefined,
25519 columnResize: true,
25526 maxWidth: Ext.isIE ? 99 : 100,
25528 initComponent : function(){
25529 if(this.columnResize){
25530 this.colResizer = new Ext.list.ColumnResizer(this.colResizer);
25531 this.colResizer.init(this);
25533 if(this.columnSort){
25534 this.colSorter = new Ext.list.Sorter(this.columnSort);
25535 this.colSorter.init(this);
25537 if(!this.internalTpl){
25538 this.internalTpl = new Ext.XTemplate(
25539 '<div class="x-list-header"><div class="x-list-header-inner">',
25540 '<tpl for="columns">',
25541 '<div style="width:{[values.width*100]}%;text-align:{align};"><em unselectable="on" id="',this.id, '-xlhd-{#}">',
25545 '<div class="x-clear"></div>',
25547 '<div class="x-list-body"><div class="x-list-body-inner">',
25552 this.tpl = new Ext.XTemplate(
25553 '<tpl for="rows">',
25555 '<tpl for="parent.columns">',
25556 '<dt style="width:{[values.width*100]}%;text-align:{align};">',
25557 '<em unselectable="on"<tpl if="cls"> class="{cls}</tpl>">',
25558 '{[values.tpl.apply(parent)]}',
25561 '<div class="x-clear"></div>',
25567 var cs = this.columns,
25568 allocatedWidth = 0,
25573 for(var i = 0; i < len; i++){
25576 c.xtype = c.xtype ? (/^lv/.test(c.xtype) ? c.xtype : 'lv' + c.xtype) : 'lvcolumn';
25580 allocatedWidth += c.width*100;
25586 cs = this.columns = columns;
25589 if(colsWithWidth < len){
25590 var remaining = len - colsWithWidth;
25591 if(allocatedWidth < this.maxWidth){
25592 var perCol = ((this.maxWidth-allocatedWidth) / remaining)/100;
25593 for(var j = 0; j < len; j++){
25601 Ext.list.ListView.superclass.initComponent.call(this);
25604 onRender : function(){
25608 Ext.list.ListView.superclass.onRender.apply(this, arguments);
25610 this.internalTpl.overwrite(this.el, {columns: this.columns});
25612 this.innerBody = Ext.get(this.el.dom.childNodes[1].firstChild);
25613 this.innerHd = Ext.get(this.el.dom.firstChild.firstChild);
25615 if(this.hideHeaders){
25616 this.el.dom.firstChild.style.display = 'none';
25620 getTemplateTarget : function(){
25621 return this.innerBody;
25625 collectData : function(){
25626 var rs = Ext.list.ListView.superclass.collectData.apply(this, arguments);
25628 columns: this.columns,
25633 verifyInternalSize : function(){
25635 this.onResize(this.lastSize.width, this.lastSize.height);
25640 onResize : function(w, h){
25641 var bd = this.innerBody.dom;
25642 var hd = this.innerHd.dom
25646 var bdp = bd.parentNode;
25647 if(Ext.isNumber(w)){
25648 var sw = w - Ext.num(this.scrollOffset, Ext.getScrollBarWidth());
25649 if(this.reserveScrollOffset || ((bdp.offsetWidth - bdp.clientWidth) > 10)){
25650 bd.style.width = sw + 'px';
25651 hd.style.width = sw + 'px';
25653 bd.style.width = w + 'px';
25654 hd.style.width = w + 'px';
25655 setTimeout(function(){
25656 if((bdp.offsetWidth - bdp.clientWidth) > 10){
25657 bd.style.width = sw + 'px';
25658 hd.style.width = sw + 'px';
25663 if(Ext.isNumber(h)){
25664 bdp.style.height = (h - hd.parentNode.offsetHeight) + 'px';
25668 updateIndexes : function(){
25669 Ext.list.ListView.superclass.updateIndexes.apply(this, arguments);
25670 this.verifyInternalSize();
25673 findHeaderIndex : function(hd){
25675 var pn = hd.parentNode, cs = pn.parentNode.childNodes;
25676 for(var i = 0, c; c = cs[i]; i++){
25684 setHdWidths : function(){
25685 var els = this.innerHd.dom.getElementsByTagName('div');
25686 for(var i = 0, cs = this.columns, len = cs.length; i < len; i++){
25687 els[i].style.width = (cs[i].width*100) + '%';
25692 Ext.reg('listview', Ext.list.ListView);
25695 Ext.ListView = Ext.list.ListView;
25696 Ext.list.Column = Ext.extend(Object, {
25715 constructor : function(c){
25717 c.tpl = new Ext.XTemplate('{' + c.dataIndex + '}');
25719 else if(Ext.isString(c.tpl)){
25720 c.tpl = new Ext.XTemplate(c.tpl);
25723 Ext.apply(this, c);
25727 Ext.reg('lvcolumn', Ext.list.Column);
25730 Ext.list.NumberColumn = Ext.extend(Ext.list.Column, {
25732 format: '0,000.00',
25734 constructor : function(c) {
25735 c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':number("' + (c.format || this.format) + '")}');
25736 Ext.list.NumberColumn.superclass.constructor.call(this, c);
25740 Ext.reg('lvnumbercolumn', Ext.list.NumberColumn);
25743 Ext.list.DateColumn = Ext.extend(Ext.list.Column, {
25745 constructor : function(c) {
25746 c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':date("' + (c.format || this.format) + '")}');
25747 Ext.list.DateColumn.superclass.constructor.call(this, c);
25750 Ext.reg('lvdatecolumn', Ext.list.DateColumn);
25753 Ext.list.BooleanColumn = Ext.extend(Ext.list.Column, {
25757 falseText: 'false',
25759 undefinedText: ' ',
25761 constructor : function(c) {
25762 c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':this.format}');
25764 var t = this.trueText, f = this.falseText, u = this.undefinedText;
25765 c.tpl.format = function(v){
25766 if(v === undefined){
25769 if(!v || v === 'false'){
25775 Ext.list.DateColumn.superclass.constructor.call(this, c);
25779 Ext.reg('lvbooleancolumn', Ext.list.BooleanColumn);
25780 Ext.list.ColumnResizer = Ext.extend(Ext.util.Observable, {
25784 constructor: function(config){
25785 Ext.apply(this, config);
25786 Ext.list.ColumnResizer.superclass.constructor.call(this);
25788 init : function(listView){
25789 this.view = listView;
25790 listView.on('render', this.initEvents, this);
25793 initEvents : function(view){
25794 view.mon(view.innerHd, 'mousemove', this.handleHdMove, this);
25795 this.tracker = new Ext.dd.DragTracker({
25796 onBeforeStart: this.onBeforeStart.createDelegate(this),
25797 onStart: this.onStart.createDelegate(this),
25798 onDrag: this.onDrag.createDelegate(this),
25799 onEnd: this.onEnd.createDelegate(this),
25803 this.tracker.initEl(view.innerHd);
25804 view.on('beforedestroy', this.tracker.destroy, this.tracker);
25807 handleHdMove : function(e, t){
25810 hd = e.getTarget('em', 3, true);
25812 var r = hd.getRegion(),
25814 pn = hd.dom.parentNode;
25816 if(x - r.left <= hw && pn != pn.parentNode.firstChild){
25817 this.activeHd = Ext.get(pn.previousSibling.firstChild);
25818 ss.cursor = Ext.isWebKit ? 'e-resize' : 'col-resize';
25819 } else if(r.right - x <= hw && pn != pn.parentNode.lastChild.previousSibling){
25820 this.activeHd = hd;
25821 ss.cursor = Ext.isWebKit ? 'w-resize' : 'col-resize';
25823 delete this.activeHd;
25829 onBeforeStart : function(e){
25830 this.dragHd = this.activeHd;
25831 return !!this.dragHd;
25834 onStart: function(e){
25835 this.view.disableHeaders = true;
25836 this.proxy = this.view.el.createChild({cls:'x-list-resizer'});
25837 this.proxy.setHeight(this.view.el.getHeight());
25839 var x = this.tracker.getXY()[0],
25840 w = this.view.innerHd.getWidth();
25842 this.hdX = this.dragHd.getX();
25843 this.hdIndex = this.view.findHeaderIndex(this.dragHd);
25845 this.proxy.setX(this.hdX);
25846 this.proxy.setWidth(x-this.hdX);
25848 this.minWidth = w*this.minPct;
25849 this.maxWidth = w - (this.minWidth*(this.view.columns.length-1-this.hdIndex));
25852 onDrag: function(e){
25853 var cursorX = this.tracker.getXY()[0];
25854 this.proxy.setWidth((cursorX-this.hdX).constrain(this.minWidth, this.maxWidth));
25857 onEnd: function(e){
25859 var nw = this.proxy.getWidth();
25860 this.proxy.remove();
25862 var index = this.hdIndex,
25866 w = this.view.innerHd.getWidth(),
25867 minPct = this.minPct * 100,
25868 pct = Math.ceil((nw * vw.maxWidth) / w),
25869 diff = (cs[index].width * 100) - pct,
25870 each = Math.floor(diff / (len-1-index)),
25871 mod = diff - (each * (len-1-index));
25873 for(var i = index+1; i < len; i++){
25874 var cw = (cs[i].width * 100) + each,
25875 ncw = Math.max(minPct, cw);
25879 cs[i].width = ncw / 100;
25881 cs[index].width = pct / 100;
25882 cs[index+1].width += (mod / 100);
25883 delete this.dragHd;
25886 setTimeout(function(){
25887 vw.disableHeaders = false;
25893 Ext.ListView.ColumnResizer = Ext.list.ColumnResizer;
25894 Ext.list.Sorter = Ext.extend(Ext.util.Observable, {
25896 sortClasses : ["sort-asc", "sort-desc"],
25898 constructor: function(config){
25899 Ext.apply(this, config);
25900 Ext.list.Sorter.superclass.constructor.call(this);
25903 init : function(listView){
25904 this.view = listView;
25905 listView.on('render', this.initEvents, this);
25908 initEvents : function(view){
25909 view.mon(view.innerHd, 'click', this.onHdClick, this);
25910 view.innerHd.setStyle('cursor', 'pointer');
25911 view.mon(view.store, 'datachanged', this.updateSortState, this);
25912 this.updateSortState.defer(10, this, [view.store]);
25915 updateSortState : function(store){
25916 var state = store.getSortState();
25920 this.sortState = state;
25921 var cs = this.view.columns, sortColumn = -1;
25922 for(var i = 0, len = cs.length; i < len; i++){
25923 if(cs[i].dataIndex == state.field){
25928 if(sortColumn != -1){
25929 var sortDir = state.direction;
25930 this.updateSortIcon(sortColumn, sortDir);
25934 updateSortIcon : function(col, dir){
25935 var sc = this.sortClasses;
25936 var hds = this.view.innerHd.select('em').removeClass(sc);
25937 hds.item(col).addClass(sc[dir == "DESC" ? 1 : 0]);
25940 onHdClick : function(e){
25941 var hd = e.getTarget('em', 3);
25942 if(hd && !this.view.disableHeaders){
25943 var index = this.view.findHeaderIndex(hd);
25944 this.view.store.sort(this.view.columns[index].dataIndex);
25950 Ext.ListView.Sorter = Ext.list.Sorter;
25951 Ext.TabPanel = Ext.extend(Ext.Panel, {
25955 monitorResize : true,
25957 deferredRender : true,
25963 resizeTabs : false,
25965 enableTabScroll : false,
25967 scrollIncrement : 0,
25969 scrollRepeatInterval : 400,
25971 scrollDuration : 0.35,
25975 tabPosition : 'top',
25977 baseCls : 'x-tab-panel',
25981 autoTabSelector : 'div.x-tab',
25983 activeTab : undefined,
25989 wheelIncrement : 20,
25992 idDelimiter : '__',
25995 itemCls : 'x-tab-item',
25999 headerAsText : false,
26004 initComponent : function(){
26005 this.frame = false;
26006 Ext.TabPanel.superclass.initComponent.call(this);
26016 this.setLayout(new Ext.layout.CardLayout(Ext.apply({
26017 layoutOnCardChange: this.layoutOnTabChange,
26018 deferredRender: this.deferredRender
26019 }, this.layoutConfig)));
26021 if(this.tabPosition == 'top'){
26022 this.elements += ',header';
26023 this.stripTarget = 'header';
26025 this.elements += ',footer';
26026 this.stripTarget = 'footer';
26029 this.stack = Ext.TabPanel.AccessStack();
26035 onRender : function(ct, position){
26036 Ext.TabPanel.superclass.onRender.call(this, ct, position);
26039 var pos = this.tabPosition == 'top' ? 'header' : 'footer';
26040 this[pos].addClass('x-tab-panel-'+pos+'-plain');
26043 var st = this[this.stripTarget];
26045 this.stripWrap = st.createChild({cls:'x-tab-strip-wrap', cn:{
26046 tag:'ul', cls:'x-tab-strip x-tab-strip-'+this.tabPosition}});
26048 var beforeEl = (this.tabPosition=='bottom' ? this.stripWrap : null);
26049 st.createChild({cls:'x-tab-strip-spacer'}, beforeEl);
26050 this.strip = new Ext.Element(this.stripWrap.dom.firstChild);
26053 this.edge = this.strip.createChild({tag:'li', cls:'x-tab-edge', cn: [{tag: 'span', cls: 'x-tab-strip-text', cn: ' '}]});
26054 this.strip.createChild({cls:'x-clear'});
26056 this.body.addClass('x-tab-panel-body-'+this.tabPosition);
26060 var tt = new Ext.Template(
26061 '<li class="{cls}" id="{id}"><a class="x-tab-strip-close"></a>',
26062 '<a class="x-tab-right" href="#"><em class="x-tab-left">',
26063 '<span class="x-tab-strip-inner"><span class="x-tab-strip-text {iconCls}">{text}</span></span>',
26066 tt.disableFormats = true;
26068 Ext.TabPanel.prototype.itemTpl = tt;
26071 this.items.each(this.initTab, this);
26075 afterRender : function(){
26076 Ext.TabPanel.superclass.afterRender.call(this);
26078 this.readTabs(false);
26080 if(this.activeTab !== undefined){
26081 var item = Ext.isObject(this.activeTab) ? this.activeTab : this.items.get(this.activeTab);
26082 delete this.activeTab;
26083 this.setActiveTab(item);
26088 initEvents : function(){
26089 Ext.TabPanel.superclass.initEvents.call(this);
26090 this.mon(this.strip, {
26092 mousedown: this.onStripMouseDown,
26093 contextmenu: this.onStripContextMenu
26095 if(this.enableTabScroll){
26096 this.mon(this.strip, 'mousewheel', this.onWheel, this);
26101 findTargets : function(e){
26103 var itemEl = e.getTarget('li', this.strip);
26105 item = this.getComponent(itemEl.id.split(this.idDelimiter)[1]);
26115 close : e.getTarget('.x-tab-strip-close', this.strip),
26122 onStripMouseDown : function(e){
26123 if(e.button !== 0){
26126 e.preventDefault();
26127 var t = this.findTargets(e);
26129 if (t.item.fireEvent('beforeclose', t.item) !== false) {
26130 t.item.fireEvent('close', t.item);
26131 this.remove(t.item);
26135 if(t.item && t.item != this.activeTab){
26136 this.setActiveTab(t.item);
26141 onStripContextMenu : function(e){
26142 e.preventDefault();
26143 var t = this.findTargets(e);
26145 this.fireEvent('contextmenu', this, t.item, e);
26150 readTabs : function(removeExisting){
26151 if(removeExisting === true){
26152 this.items.each(function(item){
26156 var tabs = this.el.query(this.autoTabSelector);
26157 for(var i = 0, len = tabs.length; i < len; i++){
26159 title = tab.getAttribute('title');
26160 tab.removeAttribute('title');
26169 initTab : function(item, index){
26170 var before = this.strip.dom.childNodes[index],
26171 p = this.getTemplateArgs(item),
26173 this.itemTpl.insertBefore(before, p) :
26174 this.itemTpl.append(this.strip, p),
26175 cls = 'x-tab-strip-over',
26176 tabEl = Ext.get(el);
26178 tabEl.hover(function(){
26179 if(!item.disabled){
26180 tabEl.addClass(cls);
26183 tabEl.removeClass(cls);
26187 tabEl.child('span.x-tab-strip-text', true).qtip = item.tabTip;
26192 tabEl.select('a').on('click', function(e){
26194 this.onStripMouseDown(e);
26196 }, this, {preventDefault: true});
26200 disable: this.onItemDisabled,
26201 enable: this.onItemEnabled,
26202 titlechange: this.onItemTitleChanged,
26203 iconchange: this.onItemIconChanged,
26204 beforeshow: this.onBeforeShowItem
26211 getTemplateArgs : function(item) {
26212 var cls = item.closable ? 'x-tab-strip-closable' : '';
26214 cls += ' x-item-disabled';
26217 cls += ' x-tab-with-icon';
26220 cls += ' ' + item.tabCls;
26224 id: this.id + this.idDelimiter + item.getItemId(),
26227 iconCls: item.iconCls || ''
26232 onAdd : function(c){
26233 Ext.TabPanel.superclass.onAdd.call(this, c);
26235 var items = this.items;
26236 this.initTab(c, items.indexOf(c));
26237 if(items.getCount() == 1){
26240 this.delegateUpdates();
26245 onBeforeAdd : function(item){
26246 var existing = item.events ? (this.items.containsKey(item.getItemId()) ? item : null) : this.items.get(item);
26248 this.setActiveTab(item);
26251 Ext.TabPanel.superclass.onBeforeAdd.apply(this, arguments);
26252 var es = item.elements;
26253 item.elements = es ? es.replace(',header', '') : es;
26254 item.border = (item.border === true);
26258 onRemove : function(c){
26259 var te = Ext.get(c.tabEl);
26262 te.select('a').removeAllListeners();
26265 Ext.TabPanel.superclass.onRemove.call(this, c);
26266 this.stack.remove(c);
26268 c.un('disable', this.onItemDisabled, this);
26269 c.un('enable', this.onItemEnabled, this);
26270 c.un('titlechange', this.onItemTitleChanged, this);
26271 c.un('iconchange', this.onItemIconChanged, this);
26272 c.un('beforeshow', this.onBeforeShowItem, this);
26273 if(c == this.activeTab){
26274 var next = this.stack.next();
26276 this.setActiveTab(next);
26277 }else if(this.items.getCount() > 0){
26278 this.setActiveTab(0);
26280 this.setActiveTab(null);
26283 if(!this.destroying){
26284 this.delegateUpdates();
26289 onBeforeShowItem : function(item){
26290 if(item != this.activeTab){
26291 this.setActiveTab(item);
26297 onItemDisabled : function(item){
26298 var el = this.getTabEl(item);
26300 Ext.fly(el).addClass('x-item-disabled');
26302 this.stack.remove(item);
26306 onItemEnabled : function(item){
26307 var el = this.getTabEl(item);
26309 Ext.fly(el).removeClass('x-item-disabled');
26314 onItemTitleChanged : function(item){
26315 var el = this.getTabEl(item);
26317 Ext.fly(el).child('span.x-tab-strip-text', true).innerHTML = item.title;
26322 onItemIconChanged : function(item, iconCls, oldCls){
26323 var el = this.getTabEl(item);
26326 el.child('span.x-tab-strip-text').replaceClass(oldCls, iconCls);
26327 el[Ext.isEmpty(iconCls) ? 'removeClass' : 'addClass']('x-tab-with-icon');
26332 getTabEl : function(item){
26333 var c = this.getComponent(item);
26334 return c ? c.tabEl : null;
26338 onResize : function(){
26339 Ext.TabPanel.superclass.onResize.apply(this, arguments);
26340 this.delegateUpdates();
26344 beginUpdate : function(){
26345 this.suspendUpdates = true;
26349 endUpdate : function(){
26350 this.suspendUpdates = false;
26351 this.delegateUpdates();
26355 hideTabStripItem : function(item){
26356 item = this.getComponent(item);
26357 var el = this.getTabEl(item);
26359 el.style.display = 'none';
26360 this.delegateUpdates();
26362 this.stack.remove(item);
26366 unhideTabStripItem : function(item){
26367 item = this.getComponent(item);
26368 var el = this.getTabEl(item);
26370 el.style.display = '';
26371 this.delegateUpdates();
26376 delegateUpdates : function(){
26377 if(this.suspendUpdates){
26380 if(this.resizeTabs && this.rendered){
26381 this.autoSizeTabs();
26383 if(this.enableTabScroll && this.rendered){
26384 this.autoScrollTabs();
26389 autoSizeTabs : function(){
26390 var count = this.items.length,
26391 ce = this.tabPosition != 'bottom' ? 'header' : 'footer',
26392 ow = this[ce].dom.offsetWidth,
26393 aw = this[ce].dom.clientWidth;
26395 if(!this.resizeTabs || count < 1 || !aw){
26399 var each = Math.max(Math.min(Math.floor((aw-4) / count) - this.tabMargin, this.tabWidth), this.minTabWidth);
26400 this.lastTabWidth = each;
26401 var lis = this.strip.query("li:not([className^=x-tab-edge])");
26402 for(var i = 0, len = lis.length; i < len; i++) {
26404 inner = Ext.fly(li).child('.x-tab-strip-inner', true),
26405 tw = li.offsetWidth,
26406 iw = inner.offsetWidth;
26407 inner.style.width = (each - (tw-iw)) + 'px';
26412 adjustBodyWidth : function(w){
26414 this.header.setWidth(w);
26417 this.footer.setWidth(w);
26423 setActiveTab : function(item){
26424 item = this.getComponent(item);
26425 if(this.fireEvent('beforetabchange', this, item, this.activeTab) === false){
26428 if(!this.rendered){
26429 this.activeTab = item;
26432 if(this.activeTab != item){
26433 if(this.activeTab){
26434 var oldEl = this.getTabEl(this.activeTab);
26436 Ext.fly(oldEl).removeClass('x-tab-strip-active');
26440 var el = this.getTabEl(item);
26441 Ext.fly(el).addClass('x-tab-strip-active');
26442 this.activeTab = item;
26443 this.stack.add(item);
26445 this.layout.setActiveItem(item);
26446 if(this.scrolling){
26447 this.scrollToTab(item, this.animScroll);
26450 this.fireEvent('tabchange', this, item);
26455 getActiveTab : function(){
26456 return this.activeTab || null;
26460 getItem : function(item){
26461 return this.getComponent(item);
26465 autoScrollTabs : function(){
26466 this.pos = this.tabPosition=='bottom' ? this.footer : this.header;
26467 var count = this.items.length,
26468 ow = this.pos.dom.offsetWidth,
26469 tw = this.pos.dom.clientWidth,
26470 wrap = this.stripWrap,
26472 cw = wd.offsetWidth,
26473 pos = this.getScrollPos(),
26474 l = this.edge.getOffsetsTo(this.stripWrap)[0] + pos;
26476 if(!this.enableTabScroll || count < 1 || cw < 20){
26482 if(this.scrolling){
26483 this.scrolling = false;
26484 this.pos.removeClass('x-tab-scrolling');
26485 this.scrollLeft.hide();
26486 this.scrollRight.hide();
26488 if(Ext.isAir || Ext.isWebKit){
26489 wd.style.marginLeft = '';
26490 wd.style.marginRight = '';
26494 if(!this.scrolling){
26495 this.pos.addClass('x-tab-scrolling');
26497 if(Ext.isAir || Ext.isWebKit){
26498 wd.style.marginLeft = '18px';
26499 wd.style.marginRight = '18px';
26502 tw -= wrap.getMargins('lr');
26503 wrap.setWidth(tw > 20 ? tw : 20);
26504 if(!this.scrolling){
26505 if(!this.scrollLeft){
26506 this.createScrollers();
26508 this.scrollLeft.show();
26509 this.scrollRight.show();
26512 this.scrolling = true;
26514 wd.scrollLeft = l-tw;
26516 this.scrollToTab(this.activeTab, false);
26518 this.updateScrollButtons();
26523 createScrollers : function(){
26524 this.pos.addClass('x-tab-scrolling-' + this.tabPosition);
26525 var h = this.stripWrap.dom.offsetHeight;
26528 var sl = this.pos.insertFirst({
26529 cls:'x-tab-scroller-left'
26532 sl.addClassOnOver('x-tab-scroller-left-over');
26533 this.leftRepeater = new Ext.util.ClickRepeater(sl, {
26534 interval : this.scrollRepeatInterval,
26535 handler: this.onScrollLeft,
26538 this.scrollLeft = sl;
26541 var sr = this.pos.insertFirst({
26542 cls:'x-tab-scroller-right'
26545 sr.addClassOnOver('x-tab-scroller-right-over');
26546 this.rightRepeater = new Ext.util.ClickRepeater(sr, {
26547 interval : this.scrollRepeatInterval,
26548 handler: this.onScrollRight,
26551 this.scrollRight = sr;
26555 getScrollWidth : function(){
26556 return this.edge.getOffsetsTo(this.stripWrap)[0] + this.getScrollPos();
26560 getScrollPos : function(){
26561 return parseInt(this.stripWrap.dom.scrollLeft, 10) || 0;
26565 getScrollArea : function(){
26566 return parseInt(this.stripWrap.dom.clientWidth, 10) || 0;
26570 getScrollAnim : function(){
26571 return {duration:this.scrollDuration, callback: this.updateScrollButtons, scope: this};
26575 getScrollIncrement : function(){
26576 return this.scrollIncrement || (this.resizeTabs ? this.lastTabWidth+2 : 100);
26581 scrollToTab : function(item, animate){
26585 var el = this.getTabEl(item),
26586 pos = this.getScrollPos(),
26587 area = this.getScrollArea(),
26588 left = Ext.fly(el).getOffsetsTo(this.stripWrap)[0] + pos,
26589 right = left + el.offsetWidth;
26591 this.scrollTo(left, animate);
26592 }else if(right > (pos + area)){
26593 this.scrollTo(right - area, animate);
26598 scrollTo : function(pos, animate){
26599 this.stripWrap.scrollTo('left', pos, animate ? this.getScrollAnim() : false);
26601 this.updateScrollButtons();
26605 onWheel : function(e){
26606 var d = e.getWheelDelta()*this.wheelIncrement*-1;
26609 var pos = this.getScrollPos(),
26611 sw = this.getScrollWidth()-this.getScrollArea();
26613 var s = Math.max(0, Math.min(sw, newpos));
26615 this.scrollTo(s, false);
26620 onScrollRight : function(){
26621 var sw = this.getScrollWidth()-this.getScrollArea(),
26622 pos = this.getScrollPos(),
26623 s = Math.min(sw, pos + this.getScrollIncrement());
26625 this.scrollTo(s, this.animScroll);
26630 onScrollLeft : function(){
26631 var pos = this.getScrollPos(),
26632 s = Math.max(0, pos - this.getScrollIncrement());
26634 this.scrollTo(s, this.animScroll);
26639 updateScrollButtons : function(){
26640 var pos = this.getScrollPos();
26641 this.scrollLeft[pos === 0 ? 'addClass' : 'removeClass']('x-tab-scroller-left-disabled');
26642 this.scrollRight[pos >= (this.getScrollWidth()-this.getScrollArea()) ? 'addClass' : 'removeClass']('x-tab-scroller-right-disabled');
26646 beforeDestroy : function() {
26647 Ext.destroy(this.leftRepeater, this.rightRepeater);
26648 this.deleteMembers('strip', 'edge', 'scrollLeft', 'scrollRight', 'stripWrap');
26649 this.activeTab = null;
26650 Ext.TabPanel.superclass.beforeDestroy.apply(this);
26666 Ext.reg('tabpanel', Ext.TabPanel);
26669 Ext.TabPanel.prototype.activate = Ext.TabPanel.prototype.setActiveTab;
26672 Ext.TabPanel.AccessStack = function(){
26675 add : function(item){
26677 if(items.length > 10){
26682 remove : function(item){
26684 for(var i = 0, len = items.length; i < len; i++) {
26685 if(items[i] != item){
26693 return items.pop();
26698 Ext.Button = Ext.extend(Ext.BoxComponent, {
26711 enableToggle : false,
26715 menuAlign : 'tl-bl?',
26723 menuClassTarget : 'tr:nth(2)',
26726 clickEvent : 'click',
26729 handleMouseEvents : true,
26732 tooltipType : 'qtip',
26735 buttonSelector : 'button:first-child',
26743 iconAlign : 'left',
26746 arrowAlign : 'right',
26752 initComponent : function(){
26753 Ext.Button.superclass.initComponent.call(this);
26774 this.menu = Ext.menu.MenuMgr.get(this.menu);
26776 if(Ext.isString(this.toggleGroup)){
26777 this.enableToggle = true;
26782 getTemplateArgs : function(){
26783 return [this.type, 'x-btn-' + this.scale + ' x-btn-icon-' + this.scale + '-' + this.iconAlign, this.getMenuClass(), this.cls, this.id];
26787 setButtonClass : function(){
26788 if(this.useSetClass){
26789 if(!Ext.isEmpty(this.oldCls)){
26790 this.el.removeClass([this.oldCls, 'x-btn-pressed']);
26792 this.oldCls = (this.iconCls || this.icon) ? (this.text ? ' x-btn-text-icon' : ' x-btn-icon') : ' x-btn-noicon';
26793 this.el.addClass([this.oldCls, this.pressed ? 'x-btn-pressed' : null]);
26798 getMenuClass : function(){
26799 return this.menu ? (this.arrowAlign != 'bottom' ? 'x-btn-arrow' : 'x-btn-arrow-bottom') : '';
26803 onRender : function(ct, position){
26804 if(!this.template){
26805 if(!Ext.Button.buttonTemplate){
26807 Ext.Button.buttonTemplate = new Ext.Template(
26808 '<table id="{4}" cellspacing="0" class="x-btn {3}"><tbody class="{1}">',
26809 '<tr><td class="x-btn-tl"><i> </i></td><td class="x-btn-tc"></td><td class="x-btn-tr"><i> </i></td></tr>',
26810 '<tr><td class="x-btn-ml"><i> </i></td><td class="x-btn-mc"><em class="{2}" unselectable="on"><button type="{0}"></button></em></td><td class="x-btn-mr"><i> </i></td></tr>',
26811 '<tr><td class="x-btn-bl"><i> </i></td><td class="x-btn-bc"></td><td class="x-btn-br"><i> </i></td></tr>',
26812 '</tbody></table>');
26813 Ext.Button.buttonTemplate.compile();
26815 this.template = Ext.Button.buttonTemplate;
26818 var btn, targs = this.getTemplateArgs();
26821 btn = this.template.insertBefore(position, targs, true);
26823 btn = this.template.append(ct, targs, true);
26826 this.btnEl = btn.child(this.buttonSelector);
26827 this.mon(this.btnEl, {
26829 focus: this.onFocus,
26833 this.initButtonEl(btn, this.btnEl);
26835 Ext.ButtonToggleMgr.register(this);
26839 initButtonEl : function(btn, btnEl){
26841 this.setIcon(this.icon);
26842 this.setText(this.text);
26843 this.setIconClass(this.iconCls);
26844 if(Ext.isDefined(this.tabIndex)){
26845 btnEl.dom.tabIndex = this.tabIndex;
26848 this.setTooltip(this.tooltip, true);
26851 if(this.handleMouseEvents){
26854 mouseover: this.onMouseOver,
26855 mousedown: this.onMouseDown
26863 this.mon(this.menu, {
26865 show: this.onMenuShow,
26866 hide: this.onMenuHide
26871 var repeater = new Ext.util.ClickRepeater(btn, Ext.isObject(this.repeat) ? this.repeat : {});
26872 this.mon(repeater, 'click', this.onClick, this);
26874 this.mon(btn, this.clickEvent, this.onClick, this);
26878 afterRender : function(){
26879 Ext.Button.superclass.afterRender.call(this);
26880 this.useSetClass = true;
26881 this.setButtonClass();
26882 this.doc = Ext.getDoc();
26883 this.doAutoWidth();
26887 setIconClass : function(cls){
26888 this.iconCls = cls;
26890 this.btnEl.dom.className = '';
26891 this.btnEl.addClass(['x-btn-text', cls || '']);
26892 this.setButtonClass();
26898 setTooltip : function(tooltip, initial){
26903 if(Ext.isObject(tooltip)){
26904 Ext.QuickTips.register(Ext.apply({
26905 target: this.btnEl.id
26907 this.tooltip = tooltip;
26909 this.btnEl.dom[this.tooltipType] = tooltip;
26912 this.tooltip = tooltip;
26918 clearTip : function(){
26919 if(Ext.isObject(this.tooltip)){
26920 Ext.QuickTips.unregister(this.btnEl);
26925 beforeDestroy : function(){
26929 if(this.menu && this.menu.autoDestroy) {
26930 Ext.destroy(this.menu);
26932 Ext.destroy(this.repeater);
26936 onDestroy : function(){
26938 this.doc.un('mouseover', this.monitorMouseOver, this);
26939 this.doc.un('mouseup', this.onMouseUp, this);
26942 Ext.ButtonToggleMgr.unregister(this);
26947 doAutoWidth : function(){
26948 if(this.el && this.text && this.width === undefined){
26949 this.el.setWidth('auto');
26950 if(Ext.isIE7 && Ext.isStrict){
26951 var ib = this.btnEl;
26952 if(ib && ib.getWidth() > 20){
26954 ib.setWidth(Ext.util.TextMetrics.measure(ib, this.text).width+ib.getFrameWidth('lr'));
26958 if(this.el.getWidth() < this.minWidth){
26959 this.el.setWidth(this.minWidth);
26966 setHandler : function(handler, scope){
26967 this.handler = handler;
26968 this.scope = scope;
26973 setText : function(text){
26976 this.btnEl.update(text || ' ');
26977 this.setButtonClass();
26979 this.doAutoWidth();
26984 setIcon : function(icon){
26987 this.btnEl.setStyle('background-image', icon ? 'url(' + icon + ')' : '');
26988 this.setButtonClass();
26994 getText : function(){
26999 toggle : function(state, suppressEvent){
27000 state = state === undefined ? !this.pressed : !!state;
27001 if(state != this.pressed){
27003 this.el[state ? 'addClass' : 'removeClass']('x-btn-pressed');
27005 this.pressed = state;
27006 if(!suppressEvent){
27007 this.fireEvent('toggle', this, state);
27008 if(this.toggleHandler){
27009 this.toggleHandler.call(this.scope || this, this, state);
27017 focus : function(){
27018 this.btnEl.focus();
27022 onDisable : function(){
27023 this.onDisableChange(true);
27027 onEnable : function(){
27028 this.onDisableChange(false);
27031 onDisableChange : function(disabled){
27033 if(!Ext.isIE6 || !this.text){
27034 this.el[disabled ? 'addClass' : 'removeClass'](this.disabledClass);
27036 this.el.dom.disabled = disabled;
27038 this.disabled = disabled;
27042 showMenu : function(){
27043 if(this.rendered && this.menu){
27045 Ext.QuickTips.getQuickTip().cancelShow(this.btnEl);
27047 this.menu.show(this.el, this.menuAlign);
27053 hideMenu : function(){
27061 hasVisibleMenu : function(){
27062 return this.menu && this.menu.isVisible();
27066 onClick : function(e){
27068 e.preventDefault();
27070 if(e.button !== 0){
27073 if(!this.disabled){
27074 if(this.enableToggle && (this.allowDepress !== false || !this.pressed)){
27077 if(this.menu && !this.menu.isVisible() && !this.ignoreNextClick){
27080 this.fireEvent('click', this, e);
27083 this.handler.call(this.scope || this, this, e);
27089 isMenuTriggerOver : function(e, internal){
27090 return this.menu && !internal;
27094 isMenuTriggerOut : function(e, internal){
27095 return this.menu && !internal;
27099 onMouseOver : function(e){
27100 if(!this.disabled){
27101 var internal = e.within(this.el, true);
27103 this.el.addClass('x-btn-over');
27104 if(!this.monitoringMouseOver){
27105 this.doc.on('mouseover', this.monitorMouseOver, this);
27106 this.monitoringMouseOver = true;
27108 this.fireEvent('mouseover', this, e);
27110 if(this.isMenuTriggerOver(e, internal)){
27111 this.fireEvent('menutriggerover', this, this.menu, e);
27117 monitorMouseOver : function(e){
27118 if(e.target != this.el.dom && !e.within(this.el)){
27119 if(this.monitoringMouseOver){
27120 this.doc.un('mouseover', this.monitorMouseOver, this);
27121 this.monitoringMouseOver = false;
27123 this.onMouseOut(e);
27128 onMouseOut : function(e){
27129 var internal = e.within(this.el) && e.target != this.el.dom;
27130 this.el.removeClass('x-btn-over');
27131 this.fireEvent('mouseout', this, e);
27132 if(this.isMenuTriggerOut(e, internal)){
27133 this.fireEvent('menutriggerout', this, this.menu, e);
27137 focus : function() {
27138 this.btnEl.focus();
27141 blur : function() {
27146 onFocus : function(e){
27147 if(!this.disabled){
27148 this.el.addClass('x-btn-focus');
27152 onBlur : function(e){
27153 this.el.removeClass('x-btn-focus');
27157 getClickEl : function(e, isUp){
27162 onMouseDown : function(e){
27163 if(!this.disabled && e.button === 0){
27164 this.getClickEl(e).addClass('x-btn-click');
27165 this.doc.on('mouseup', this.onMouseUp, this);
27169 onMouseUp : function(e){
27170 if(e.button === 0){
27171 this.getClickEl(e, true).removeClass('x-btn-click');
27172 this.doc.un('mouseup', this.onMouseUp, this);
27176 onMenuShow : function(e){
27177 this.menu.ownerCt = this;
27178 this.ignoreNextClick = 0;
27179 this.el.addClass('x-btn-menu-active');
27180 this.fireEvent('menushow', this, this.menu);
27183 onMenuHide : function(e){
27184 this.el.removeClass('x-btn-menu-active');
27185 this.ignoreNextClick = this.restoreClick.defer(250, this);
27186 this.fireEvent('menuhide', this, this.menu);
27187 delete this.menu.ownerCt;
27191 restoreClick : function(){
27192 this.ignoreNextClick = 0;
27197 Ext.reg('button', Ext.Button);
27200 Ext.ButtonToggleMgr = function(){
27203 function toggleGroup(btn, state){
27205 var g = groups[btn.toggleGroup];
27206 for(var i = 0, l = g.length; i < l; i++){
27208 g[i].toggle(false);
27215 register : function(btn){
27216 if(!btn.toggleGroup){
27219 var g = groups[btn.toggleGroup];
27221 g = groups[btn.toggleGroup] = [];
27224 btn.on('toggle', toggleGroup);
27227 unregister : function(btn){
27228 if(!btn.toggleGroup){
27231 var g = groups[btn.toggleGroup];
27234 btn.un('toggle', toggleGroup);
27239 getPressed : function(group){
27240 var g = groups[group];
27242 for(var i = 0, len = g.length; i < len; i++){
27243 if(g[i].pressed === true){
27253 Ext.SplitButton = Ext.extend(Ext.Button, {
27255 arrowSelector : 'em',
27259 initComponent : function(){
27260 Ext.SplitButton.superclass.initComponent.call(this);
27262 this.addEvents("arrowclick");
27266 onRender : function(){
27267 Ext.SplitButton.superclass.onRender.apply(this, arguments);
27268 if(this.arrowTooltip){
27269 this.el.child(this.arrowSelector).dom[this.tooltipType] = this.arrowTooltip;
27274 setArrowHandler : function(handler, scope){
27275 this.arrowHandler = handler;
27276 this.scope = scope;
27279 getMenuClass : function(){
27280 return 'x-btn-split' + (this.arrowAlign == 'bottom' ? '-bottom' : '');
27283 isClickOnArrow : function(e){
27284 if (this.arrowAlign != 'bottom') {
27285 var visBtn = this.el.child('em.x-btn-split');
27286 var right = visBtn.getRegion().right - visBtn.getPadding('r');
27287 return e.getPageX() > right;
27289 return e.getPageY() > this.btnEl.getRegion().bottom;
27294 onClick : function(e, t){
27295 e.preventDefault();
27296 if(!this.disabled){
27297 if(this.isClickOnArrow(e)){
27298 if(this.menu && !this.menu.isVisible() && !this.ignoreNextClick){
27301 this.fireEvent("arrowclick", this, e);
27302 if(this.arrowHandler){
27303 this.arrowHandler.call(this.scope || this, this, e);
27306 if(this.enableToggle){
27309 this.fireEvent("click", this, e);
27311 this.handler.call(this.scope || this, this, e);
27318 isMenuTriggerOver : function(e){
27319 return this.menu && e.target.tagName == this.arrowSelector;
27323 isMenuTriggerOut : function(e, internal){
27324 return this.menu && e.target.tagName != this.arrowSelector;
27328 Ext.reg('splitbutton', Ext.SplitButton);
27329 Ext.CycleButton = Ext.extend(Ext.SplitButton, {
27338 getItemText : function(item){
27339 if(item && this.showText === true){
27341 if(this.prependText){
27342 text += this.prependText;
27351 setActiveItem : function(item, suppressEvent){
27352 if(!Ext.isObject(item)){
27353 item = this.menu.getComponent(item);
27356 if(!this.rendered){
27357 this.text = this.getItemText(item);
27358 this.iconCls = item.iconCls;
27360 var t = this.getItemText(item);
27364 this.setIconClass(item.iconCls);
27366 this.activeItem = item;
27368 item.setChecked(true, true);
27370 if(this.forceIcon){
27371 this.setIconClass(this.forceIcon);
27373 if(!suppressEvent){
27374 this.fireEvent('change', this, item);
27380 getActiveItem : function(){
27381 return this.activeItem;
27385 initComponent : function(){
27391 if(this.changeHandler){
27392 this.on('change', this.changeHandler, this.scope||this);
27393 delete this.changeHandler;
27396 this.itemCount = this.items.length;
27398 this.menu = {cls:'x-cycle-menu', items:[]};
27400 Ext.each(this.items, function(item, i){
27402 group: item.group || this.id,
27404 checkHandler: this.checkHandler,
27406 checked: item.checked || false
27408 this.menu.items.push(item);
27413 this.setActiveItem(checked, true);
27414 Ext.CycleButton.superclass.initComponent.call(this);
27416 this.on('click', this.toggleSelected, this);
27420 checkHandler : function(item, pressed){
27422 this.setActiveItem(item);
27427 toggleSelected : function(){
27435 var nextIdx, checkItem;
27436 for (var i = 1; i < this.itemCount; i++) {
27437 nextIdx = (this.activeItem.itemIndex + i) % this.itemCount;
27439 checkItem = m.items.itemAt(nextIdx);
27441 if (!checkItem.disabled) {
27442 checkItem.setChecked(true);
27448 Ext.reg('cycle', Ext.CycleButton);
27449 Ext.layout.ToolbarLayout = Ext.extend(Ext.layout.ContainerLayout, {
27450 monitorResize : true,
27452 lastOverflow : false,
27455 noItemsMenuText : '<div class="x-toolbar-no-items">(None)</div>',
27457 onLayout : function(ct, target){
27459 var align = ct.buttonAlign == 'center' ? 'center' : 'left';
27460 target.addClass('x-toolbar-layout-ct');
27461 target.insertHtml('beforeEnd',
27462 '<table cellspacing="0" class="x-toolbar-ct"><tbody><tr><td class="x-toolbar-left" align="' + align + '"><table cellspacing="0"><tbody><tr class="x-toolbar-left-row"></tr></tbody></table></td><td class="x-toolbar-right" align="right"><table cellspacing="0" class="x-toolbar-right-ct"><tbody><tr><td><table cellspacing="0"><tbody><tr class="x-toolbar-right-row"></tr></tbody></table></td><td><table cellspacing="0"><tbody><tr class="x-toolbar-extras-row"></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table>');
27463 this.leftTr = target.child('tr.x-toolbar-left-row', true);
27464 this.rightTr = target.child('tr.x-toolbar-right-row', true);
27465 this.extrasTr = target.child('tr.x-toolbar-extras-row', true);
27467 var side = ct.buttonAlign == 'right' ? this.rightTr : this.leftTr,
27469 items = ct.items.items;
27471 for(var i = 0, len = items.length, c; i < len; i++, pos++) {
27474 side = this.rightTr;
27476 }else if(!c.rendered){
27477 c.render(this.insertCell(c, side, pos));
27479 if(!c.xtbHidden && !this.isValidParent(c, side.childNodes[pos])){
27480 var td = this.insertCell(c, side, pos);
27481 td.appendChild(c.getPositionEl().dom);
27482 c.container = Ext.get(td);
27487 this.cleanup(this.leftTr);
27488 this.cleanup(this.rightTr);
27489 this.cleanup(this.extrasTr);
27490 this.fitToSize(target);
27493 cleanup : function(row){
27494 var cn = row.childNodes;
27495 for(var i = cn.length-1, c; i >= 0 && (c = cn[i]); i--){
27497 row.removeChild(c);
27502 insertCell : function(c, side, pos){
27503 var td = document.createElement('td');
27504 td.className='x-toolbar-cell';
27505 side.insertBefore(td, side.childNodes[pos]||null);
27509 hideItem : function(item){
27510 var h = (this.hiddens = this.hiddens || []);
27512 item.xtbHidden = true;
27513 item.xtbWidth = item.getPositionEl().dom.parentNode.offsetWidth;
27517 unhideItem : function(item){
27519 item.xtbHidden = false;
27520 this.hiddens.remove(item);
27521 if(this.hiddens.length < 1){
27522 delete this.hiddens;
27526 getItemWidth : function(c){
27527 return c.hidden ? (c.xtbWidth || 0) : c.getPositionEl().dom.parentNode.offsetWidth;
27530 fitToSize : function(t){
27531 if(this.container.enableOverflow === false){
27534 var w = t.dom.clientWidth,
27535 lw = this.lastWidth || 0,
27536 iw = t.dom.firstChild.offsetWidth,
27537 clipWidth = w - this.triggerWidth,
27540 this.lastWidth = w;
27542 if(iw > w || (this.hiddens && w >= lw)){
27543 var i, items = this.container.items.items,
27544 len = items.length, c,
27547 for(i = 0; i < len; i++) {
27550 loopWidth += this.getItemWidth(c);
27551 if(loopWidth > clipWidth){
27552 if(!(c.hidden || c.xtbHidden)){
27555 }else if(c.xtbHidden){
27556 this.unhideItem(c);
27563 if(!this.lastOverflow){
27564 this.container.fireEvent('overflowchange', this.container, true);
27565 this.lastOverflow = true;
27567 }else if(this.more){
27569 this.more.destroy();
27571 if(this.lastOverflow){
27572 this.container.fireEvent('overflowchange', this.container, false);
27573 this.lastOverflow = false;
27578 createMenuConfig : function(c, hideOnClick){
27579 var cfg = Ext.apply({}, c.initialConfig),
27580 group = c.toggleGroup;
27583 text: c.overflowText || c.text,
27584 iconCls: c.iconCls,
27587 disabled: c.disabled,
27588 handler: c.handler,
27591 hideOnClick: hideOnClick
27593 if(group || c.enableToggle){
27596 checked: c.pressed,
27598 checkchange: function(item, checked){
27604 delete cfg.ownerCt;
27611 addComponentToMenu : function(m, c){
27612 if(c instanceof Ext.Toolbar.Separator){
27614 }else if(Ext.isFunction(c.isXType)){
27615 if(c.isXType('splitbutton')){
27616 m.add(this.createMenuConfig(c, true));
27617 }else if(c.isXType('button')){
27618 m.add(this.createMenuConfig(c, !c.menu));
27619 }else if(c.isXType('buttongroup')){
27620 c.items.each(function(item){
27621 this.addComponentToMenu(m, item);
27627 clearMenu : function(){
27628 var m = this.moreMenu;
27630 m.items.each(function(item){
27637 beforeMoreShow : function(m){
27638 var h = this.container.items.items,
27642 needsSep = function(group, item){
27643 return group.isXType('buttongroup') && !(item instanceof Ext.Toolbar.Separator);
27648 for(var i = 0; i < len; i++){
27651 if(prev && (needsSep(c, prev) || needsSep(prev, c))){
27654 this.addComponentToMenu(m, c);
27660 if(m.items.length < 1){
27661 m.add(this.noItemsMenuText);
27665 initMore : function(){
27667 this.moreMenu = new Ext.menu.Menu({
27669 beforeshow: this.beforeMoreShow,
27673 this.moreMenu.ownerCt = this.container;
27674 this.more = new Ext.Button({
27675 iconCls: 'x-toolbar-more-icon',
27676 cls: 'x-toolbar-more',
27677 menu: this.moreMenu
27679 var td = this.insertCell(this.more, this.extrasTr, 100);
27680 this.more.render(td);
27684 onRemove : function(c){
27685 delete this.leftTr;
27686 delete this.rightTr;
27687 delete this.extrasTr;
27688 Ext.layout.ToolbarLayout.superclass.onRemove.call(this, c);
27691 destroy : function(){
27692 Ext.destroy(this.more, this.moreMenu);
27693 delete this.leftTr;
27694 delete this.rightTr;
27695 delete this.extrasTr;
27696 Ext.layout.ToolbarLayout.superclass.destroy.call(this);
27701 Ext.Container.LAYOUTS.toolbar = Ext.layout.ToolbarLayout;
27704 Ext.Toolbar = function(config){
27705 if(Ext.isArray(config)){
27706 config = {items: config, layout: 'toolbar'};
27708 config = Ext.apply({
27711 if(config.buttons) {
27712 config.items = config.buttons;
27715 Ext.Toolbar.superclass.constructor.call(this, config);
27720 var T = Ext.Toolbar;
27722 Ext.extend(T, Ext.Container, {
27724 defaultType: 'button',
27730 internalDefaults: {removeMode: 'container', hideParent: true},
27731 toolbarCls: 'x-toolbar',
27733 initComponent : function(){
27734 T.superclass.initComponent.call(this);
27737 this.addEvents('overflowchange');
27741 onRender : function(ct, position){
27743 if(!this.autoCreate){
27744 this.autoCreate = {
27745 cls: this.toolbarCls + ' x-small-editor'
27748 this.el = ct.createChild(Ext.apply({ id: this.id },this.autoCreate), position);
27749 Ext.Toolbar.superclass.onRender.apply(this, arguments);
27756 lookupComponent : function(c){
27757 if(Ext.isString(c)){
27759 c = new T.Separator();
27760 }else if(c == ' '){
27761 c = new T.Spacer();
27762 }else if(c == '->'){
27765 c = new T.TextItem(c);
27767 this.applyDefaults(c);
27769 if(c.isFormField || c.render){
27770 c = this.createComponent(c);
27772 c = new T.Item({autoEl: c});
27773 }else if(c.tagName){
27774 c = new T.Item({el:c});
27775 }else if(Ext.isObject(c)){
27776 c = c.xtype ? this.createComponent(c) : this.constructButton(c);
27783 applyDefaults : function(c){
27784 if(!Ext.isString(c)){
27785 c = Ext.Toolbar.superclass.applyDefaults.call(this, c);
27786 var d = this.internalDefaults;
27788 Ext.applyIf(c.initialConfig, d);
27798 addSeparator : function(){
27799 return this.add(new T.Separator());
27803 addSpacer : function(){
27804 return this.add(new T.Spacer());
27808 addFill : function(){
27809 this.add(new T.Fill());
27813 addElement : function(el){
27814 return this.addItem(new T.Item({el:el}));
27818 addItem : function(item){
27819 return this.add.apply(this, arguments);
27823 addButton : function(config){
27824 if(Ext.isArray(config)){
27826 for(var i = 0, len = config.length; i < len; i++) {
27827 buttons.push(this.addButton(config[i]));
27831 return this.add(this.constructButton(config));
27835 addText : function(text){
27836 return this.addItem(new T.TextItem(text));
27840 addDom : function(config){
27841 return this.add(new T.Item({autoEl: config}));
27845 addField : function(field){
27846 return this.add(field);
27850 insertButton : function(index, item){
27851 if(Ext.isArray(item)){
27853 for(var i = 0, len = item.length; i < len; i++) {
27854 buttons.push(this.insertButton(index + i, item[i]));
27858 return Ext.Toolbar.superclass.insert.call(this, index, item);
27862 trackMenu : function(item, remove){
27863 if(this.trackMenus && item.menu){
27864 var method = remove ? 'mun' : 'mon';
27865 this[method](item, 'menutriggerover', this.onButtonTriggerOver, this);
27866 this[method](item, 'menushow', this.onButtonMenuShow, this);
27867 this[method](item, 'menuhide', this.onButtonMenuHide, this);
27872 constructButton : function(item){
27873 var b = item.events ? item : this.createComponent(item, item.split ? 'splitbutton' : this.defaultType);
27878 onAdd : function(c){
27879 Ext.Toolbar.superclass.onAdd.call(this);
27884 onRemove : function(c){
27885 Ext.Toolbar.superclass.onRemove.call(this);
27886 this.trackMenu(c, true);
27890 onDisable : function(){
27891 this.items.each(function(item){
27899 onEnable : function(){
27900 this.items.each(function(item){
27908 onButtonTriggerOver : function(btn){
27909 if(this.activeMenuBtn && this.activeMenuBtn != btn){
27910 this.activeMenuBtn.hideMenu();
27912 this.activeMenuBtn = btn;
27917 onButtonMenuShow : function(btn){
27918 this.activeMenuBtn = btn;
27922 onButtonMenuHide : function(btn){
27923 delete this.activeMenuBtn;
27926 Ext.reg('toolbar', Ext.Toolbar);
27929 T.Item = Ext.extend(Ext.BoxComponent, {
27931 enable:Ext.emptyFn,
27932 disable:Ext.emptyFn,
27936 Ext.reg('tbitem', T.Item);
27939 T.Separator = Ext.extend(T.Item, {
27940 onRender : function(ct, position){
27941 this.el = ct.createChild({tag:'span', cls:'xtb-sep'}, position);
27944 Ext.reg('tbseparator', T.Separator);
27947 T.Spacer = Ext.extend(T.Item, {
27950 onRender : function(ct, position){
27951 this.el = ct.createChild({tag:'div', cls:'xtb-spacer', style: this.width?'width:'+this.width+'px':''}, position);
27954 Ext.reg('tbspacer', T.Spacer);
27957 T.Fill = Ext.extend(T.Item, {
27959 render : Ext.emptyFn,
27962 Ext.reg('tbfill', T.Fill);
27965 T.TextItem = Ext.extend(T.Item, {
27968 constructor: function(config){
27969 T.TextItem.superclass.constructor.call(this, Ext.isString(config) ? {text: config} : config);
27973 onRender : function(ct, position) {
27974 this.autoEl = {cls: 'xtb-text', html: this.text || ''};
27975 T.TextItem.superclass.onRender.call(this, ct, position);
27979 setText : function(t) {
27987 Ext.reg('tbtext', T.TextItem);
27990 T.Button = Ext.extend(Ext.Button, {});
27991 T.SplitButton = Ext.extend(Ext.SplitButton, {});
27992 Ext.reg('tbbutton', T.Button);
27993 Ext.reg('tbsplit', T.SplitButton);
27997 Ext.ButtonGroup = Ext.extend(Ext.Panel, {
28000 baseCls: 'x-btn-group',
28003 defaultType: 'button',
28006 internalDefaults: {removeMode: 'container', hideParent: true},
28008 initComponent : function(){
28009 this.layoutConfig = this.layoutConfig || {};
28010 Ext.applyIf(this.layoutConfig, {
28011 columns : this.columns
28014 this.addClass('x-btn-group-notitle');
28016 this.on('afterlayout', this.onAfterLayout, this);
28017 Ext.ButtonGroup.superclass.initComponent.call(this);
28020 applyDefaults : function(c){
28021 c = Ext.ButtonGroup.superclass.applyDefaults.call(this, c);
28022 var d = this.internalDefaults;
28024 Ext.applyIf(c.initialConfig, d);
28032 onAfterLayout : function(){
28033 var bodyWidth = this.body.getFrameWidth('lr') + this.body.dom.firstChild.offsetWidth;
28034 this.body.setWidth(bodyWidth);
28035 this.el.setWidth(bodyWidth + this.getFrameWidth());
28040 Ext.reg('buttongroup', Ext.ButtonGroup);
28044 var T = Ext.Toolbar;
28046 Ext.PagingToolbar = Ext.extend(Ext.Toolbar, {
28053 displayMsg : 'Displaying {0} - {1} of {2}',
28055 emptyMsg : 'No data to display',
28057 beforePageText : 'Page',
28059 afterPageText : 'of {0}',
28061 firstText : 'First Page',
28063 prevText : 'Previous Page',
28065 nextText : 'Next Page',
28067 lastText : 'Last Page',
28069 refreshText : 'Refresh',
28077 initComponent : function(){
28078 var pagingItems = [this.first = new T.Button({
28079 tooltip: this.firstText,
28080 overflowText: this.firstText,
28081 iconCls: 'x-tbar-page-first',
28083 handler: this.moveFirst,
28085 }), this.prev = new T.Button({
28086 tooltip: this.prevText,
28087 overflowText: this.prevText,
28088 iconCls: 'x-tbar-page-prev',
28090 handler: this.movePrevious,
28092 }), '-', this.beforePageText,
28093 this.inputItem = new Ext.form.NumberField({
28094 cls: 'x-tbar-page-number',
28095 allowDecimals: false,
28096 allowNegative: false,
28097 enableKeyEvents: true,
28098 selectOnFocus: true,
28099 submitValue: false,
28102 keydown: this.onPagingKeyDown,
28103 blur: this.onPagingBlur
28105 }), this.afterTextItem = new T.TextItem({
28106 text: String.format(this.afterPageText, 1)
28107 }), '-', this.next = new T.Button({
28108 tooltip: this.nextText,
28109 overflowText: this.nextText,
28110 iconCls: 'x-tbar-page-next',
28112 handler: this.moveNext,
28114 }), this.last = new T.Button({
28115 tooltip: this.lastText,
28116 overflowText: this.lastText,
28117 iconCls: 'x-tbar-page-last',
28119 handler: this.moveLast,
28121 }), '-', this.refresh = new T.Button({
28122 tooltip: this.refreshText,
28123 overflowText: this.refreshText,
28124 iconCls: 'x-tbar-loading',
28125 handler: this.doRefresh,
28130 var userItems = this.items || this.buttons || [];
28131 if (this.prependButtons) {
28132 this.items = userItems.concat(pagingItems);
28134 this.items = pagingItems.concat(userItems);
28136 delete this.buttons;
28137 if(this.displayInfo){
28138 this.items.push('->');
28139 this.items.push(this.displayItem = new T.TextItem({}));
28141 Ext.PagingToolbar.superclass.initComponent.call(this);
28148 this.on('afterlayout', this.onFirstLayout, this, {single: true});
28150 this.bindStore(this.store, true);
28154 onFirstLayout : function(){
28156 this.onLoad.apply(this, this.dsLoaded);
28161 updateInfo : function(){
28162 if(this.displayItem){
28163 var count = this.store.getCount();
28164 var msg = count == 0 ?
28168 this.cursor+1, this.cursor+count, this.store.getTotalCount()
28170 this.displayItem.setText(msg);
28175 onLoad : function(store, r, o){
28176 if(!this.rendered){
28177 this.dsLoaded = [store, r, o];
28180 var p = this.getParams();
28181 this.cursor = (o.params && o.params[p.start]) ? o.params[p.start] : 0;
28182 var d = this.getPageData(), ap = d.activePage, ps = d.pages;
28184 this.afterTextItem.setText(String.format(this.afterPageText, d.pages));
28185 this.inputItem.setValue(ap);
28186 this.first.setDisabled(ap == 1);
28187 this.prev.setDisabled(ap == 1);
28188 this.next.setDisabled(ap == ps);
28189 this.last.setDisabled(ap == ps);
28190 this.refresh.enable();
28192 this.fireEvent('change', this, d);
28196 getPageData : function(){
28197 var total = this.store.getTotalCount();
28200 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
28201 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
28206 changePage : function(page){
28207 this.doLoad(((page-1) * this.pageSize).constrain(0, this.store.getTotalCount()));
28211 onLoadError : function(){
28212 if(!this.rendered){
28215 this.refresh.enable();
28219 readPage : function(d){
28220 var v = this.inputItem.getValue(), pageNum;
28221 if (!v || isNaN(pageNum = parseInt(v, 10))) {
28222 this.inputItem.setValue(d.activePage);
28228 onPagingFocus : function(){
28229 this.inputItem.select();
28233 onPagingBlur : function(e){
28234 this.inputItem.setValue(this.getPageData().activePage);
28238 onPagingKeyDown : function(field, e){
28239 var k = e.getKey(), d = this.getPageData(), pageNum;
28240 if (k == e.RETURN) {
28242 pageNum = this.readPage(d);
28243 if(pageNum !== false){
28244 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
28245 this.doLoad(pageNum * this.pageSize);
28247 }else if (k == e.HOME || k == e.END){
28249 pageNum = k == e.HOME ? 1 : d.pages;
28250 field.setValue(pageNum);
28251 }else if (k == e.UP || k == e.PAGEUP || k == e.DOWN || k == e.PAGEDOWN){
28253 if((pageNum = this.readPage(d))){
28254 var increment = e.shiftKey ? 10 : 1;
28255 if(k == e.DOWN || k == e.PAGEDOWN){
28258 pageNum += increment;
28259 if(pageNum >= 1 & pageNum <= d.pages){
28260 field.setValue(pageNum);
28267 getParams : function(){
28269 return this.paramNames || this.store.paramNames;
28273 beforeLoad : function(){
28274 if(this.rendered && this.refresh){
28275 this.refresh.disable();
28280 doLoad : function(start){
28281 var o = {}, pn = this.getParams();
28282 o[pn.start] = start;
28283 o[pn.limit] = this.pageSize;
28284 if(this.fireEvent('beforechange', this, o) !== false){
28285 this.store.load({params:o});
28290 moveFirst : function(){
28295 movePrevious : function(){
28296 this.doLoad(Math.max(0, this.cursor-this.pageSize));
28300 moveNext : function(){
28301 this.doLoad(this.cursor+this.pageSize);
28305 moveLast : function(){
28306 var total = this.store.getTotalCount(),
28307 extra = total % this.pageSize;
28309 this.doLoad(extra ? (total - extra) : total - this.pageSize);
28313 doRefresh : function(){
28314 this.doLoad(this.cursor);
28318 bindStore : function(store, initial){
28320 if(!initial && this.store){
28321 if(store !== this.store && this.store.autoDestroy){
28322 this.store.destroy();
28324 this.store.un('beforeload', this.beforeLoad, this);
28325 this.store.un('load', this.onLoad, this);
28326 this.store.un('exception', this.onLoadError, this);
28333 store = Ext.StoreMgr.lookup(store);
28336 beforeload: this.beforeLoad,
28338 exception: this.onLoadError
28342 this.store = store;
28344 this.onLoad(store, null, {});
28349 unbind : function(store){
28350 this.bindStore(null);
28354 bind : function(store){
28355 this.bindStore(store);
28359 onDestroy : function(){
28360 this.bindStore(null);
28361 Ext.PagingToolbar.superclass.onDestroy.call(this);
28366 Ext.reg('paging', Ext.PagingToolbar);
28367 Ext.History = (function () {
28368 var iframe, hiddenField;
28372 function getHash() {
28373 var href = top.location.href, i = href.indexOf("#");
28374 return i >= 0 ? href.substr(i + 1) : null;
28377 function doSave() {
28378 hiddenField.value = currentToken;
28381 function handleStateChange(token) {
28382 currentToken = token;
28383 Ext.History.fireEvent('change', token);
28386 function updateIFrame (token) {
28387 var html = ['<html><body><div id="state">',Ext.util.Format.htmlEncode(token),'</div></body></html>'].join('');
28389 var doc = iframe.contentWindow.document;
28399 function checkIFrame() {
28400 if (!iframe.contentWindow || !iframe.contentWindow.document) {
28401 setTimeout(checkIFrame, 10);
28405 var doc = iframe.contentWindow.document;
28406 var elem = doc.getElementById("state");
28407 var token = elem ? elem.innerText : null;
28409 var hash = getHash();
28411 setInterval(function () {
28413 doc = iframe.contentWindow.document;
28414 elem = doc.getElementById("state");
28416 var newtoken = elem ? elem.innerText : null;
28418 var newHash = getHash();
28420 if (newtoken !== token) {
28422 handleStateChange(token);
28423 top.location.hash = token;
28426 } else if (newHash !== hash) {
28428 updateIFrame(newHash);
28435 Ext.History.fireEvent('ready', Ext.History);
28438 function startUp() {
28439 currentToken = hiddenField.value ? hiddenField.value : getHash();
28444 var hash = getHash();
28445 setInterval(function () {
28446 var newHash = getHash();
28447 if (newHash !== hash) {
28449 handleStateChange(hash);
28454 Ext.History.fireEvent('ready', Ext.History);
28460 fieldId: 'x-history-field',
28462 iframeId: 'x-history-frame',
28467 init: function (onReady, scope) {
28469 Ext.callback(onReady, scope, [this]);
28473 Ext.onReady(function(){
28474 Ext.History.init(onReady, scope);
28478 hiddenField = Ext.getDom(Ext.History.fieldId);
28480 iframe = Ext.getDom(Ext.History.iframeId);
28489 this.on('ready', onReady, scope, {single:true});
28495 add: function (token, preventDup) {
28496 if(preventDup !== false){
28497 if(this.getToken() == token){
28502 return updateIFrame(token);
28504 top.location.hash = token;
28515 forward: function(){
28520 getToken: function() {
28521 return ready ? currentToken : getHash();
28525 Ext.apply(Ext.History, new Ext.util.Observable());
28526 Ext.Tip = Ext.extend(Ext.Panel, {
28536 defaultAlign : "tl-bl?",
28538 quickShowInterval : 250,
28544 floating:{shadow:true,shim:true,useDisplay:true,constrain:false},
28547 closeAction: 'hide',
28550 initComponent : function(){
28551 Ext.Tip.superclass.initComponent.call(this);
28552 if(this.closable && !this.title){
28553 this.elements += ',header';
28558 afterRender : function(){
28559 Ext.Tip.superclass.afterRender.call(this);
28563 handler: this[this.closeAction],
28570 showAt : function(xy){
28571 Ext.Tip.superclass.show.call(this);
28572 if(this.measureWidth !== false && (!this.initialConfig || typeof this.initialConfig.width != 'number')){
28573 this.doAutoWidth();
28575 if(this.constrainPosition){
28576 xy = this.el.adjustForConstraints(xy);
28578 this.setPagePosition(xy[0], xy[1]);
28582 doAutoWidth : function(adjust){
28583 adjust = adjust || 0;
28584 var bw = this.body.getTextWidth();
28586 bw = Math.max(bw, this.header.child('span').getTextWidth(this.title));
28588 bw += this.getFrameWidth() + (this.closable ? 20 : 0) + this.body.getPadding("lr") + adjust;
28589 this.setWidth(bw.constrain(this.minWidth, this.maxWidth));
28592 if(Ext.isIE7 && !this.repainted){
28594 this.repainted = true;
28599 showBy : function(el, pos){
28600 if(!this.rendered){
28601 this.render(Ext.getBody());
28603 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign));
28606 initDraggable : function(){
28607 this.dd = new Ext.Tip.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);
28608 this.header.addClass('x-tip-draggable');
28612 Ext.reg('tip', Ext.Tip);
28615 Ext.Tip.DD = function(tip, config){
28616 Ext.apply(this, config);
28618 Ext.Tip.DD.superclass.constructor.call(this, tip.el.id, 'WindowDD-'+tip.id);
28619 this.setHandleElId(tip.header.id);
28620 this.scroll = false;
28623 Ext.extend(Ext.Tip.DD, Ext.dd.DD, {
28626 headerOffsets:[100, 25],
28627 startDrag : function(){
28628 this.tip.el.disableShadow();
28630 endDrag : function(e){
28631 this.tip.el.enableShadow(true);
28634 Ext.ToolTip = Ext.extend(Ext.Tip, {
28643 dismissDelay : 5000,
28646 trackMouse : false,
28648 anchorToTarget : true,
28656 constrainPosition : false,
28659 initComponent : function(){
28660 Ext.ToolTip.superclass.initComponent.call(this);
28661 this.lastActive = new Date();
28662 this.initTarget(this.target);
28663 this.origAnchor = this.anchor;
28667 onRender : function(ct, position){
28668 Ext.ToolTip.superclass.onRender.call(this, ct, position);
28669 this.anchorCls = 'x-tip-anchor-' + this.getAnchorPosition();
28670 this.anchorEl = this.el.createChild({
28671 cls: 'x-tip-anchor ' + this.anchorCls
28676 afterRender : function(){
28677 Ext.ToolTip.superclass.afterRender.call(this);
28678 this.anchorEl.setStyle('z-index', this.el.getZIndex() + 1);
28682 initTarget : function(target){
28684 if((t = Ext.get(target))){
28686 var tg = Ext.get(this.target);
28687 this.mun(tg, 'mouseover', this.onTargetOver, this);
28688 this.mun(tg, 'mouseout', this.onTargetOut, this);
28689 this.mun(tg, 'mousemove', this.onMouseMove, this);
28692 mouseover: this.onTargetOver,
28693 mouseout: this.onTargetOut,
28694 mousemove: this.onMouseMove,
28700 this.anchorTarget = this.target;
28705 onMouseMove : function(e){
28706 var t = this.delegate ? e.getTarget(this.delegate) : this.triggerElement = true;
28708 this.targetXY = e.getXY();
28709 if (t === this.triggerElement) {
28710 if(!this.hidden && this.trackMouse){
28711 this.setPagePosition(this.getTargetXY());
28715 this.lastActive = new Date(0);
28716 this.onTargetOver(e);
28718 } else if (!this.closable && this.isVisible()) {
28724 getTargetXY : function(){
28726 this.anchorTarget = this.triggerElement;
28729 this.targetCounter++;
28730 var offsets = this.getOffsets(),
28731 xy = (this.anchorToTarget && !this.trackMouse) ? this.el.getAlignToXY(this.anchorTarget, this.getAnchorAlign()) : this.targetXY,
28732 dw = Ext.lib.Dom.getViewWidth() - 5,
28733 dh = Ext.lib.Dom.getViewHeight() - 5,
28734 de = document.documentElement,
28735 bd = document.body,
28736 scrollX = (de.scrollLeft || bd.scrollLeft || 0) + 5,
28737 scrollY = (de.scrollTop || bd.scrollTop || 0) + 5,
28738 axy = [xy[0] + offsets[0], xy[1] + offsets[1]]
28739 sz = this.getSize();
28741 this.anchorEl.removeClass(this.anchorCls);
28743 if(this.targetCounter < 2){
28744 if(axy[0] < scrollX){
28745 if(this.anchorToTarget){
28746 this.defaultAlign = 'l-r';
28747 if(this.mouseOffset){this.mouseOffset[0] *= -1;}
28749 this.anchor = 'left';
28750 return this.getTargetXY();
28752 if(axy[0]+sz.width > dw){
28753 if(this.anchorToTarget){
28754 this.defaultAlign = 'r-l';
28755 if(this.mouseOffset){this.mouseOffset[0] *= -1;}
28757 this.anchor = 'right';
28758 return this.getTargetXY();
28760 if(axy[1] < scrollY){
28761 if(this.anchorToTarget){
28762 this.defaultAlign = 't-b';
28763 if(this.mouseOffset){this.mouseOffset[1] *= -1;}
28765 this.anchor = 'top';
28766 return this.getTargetXY();
28768 if(axy[1]+sz.height > dh){
28769 if(this.anchorToTarget){
28770 this.defaultAlign = 'b-t';
28771 if(this.mouseOffset){this.mouseOffset[1] *= -1;}
28773 this.anchor = 'bottom';
28774 return this.getTargetXY();
28778 this.anchorCls = 'x-tip-anchor-'+this.getAnchorPosition();
28779 this.anchorEl.addClass(this.anchorCls);
28780 this.targetCounter = 0;
28783 var mouseOffset = this.getMouseOffset();
28784 return [this.targetXY[0]+mouseOffset[0], this.targetXY[1]+mouseOffset[1]];
28788 getMouseOffset : function(){
28789 var offset = this.anchor ? [0,0] : [15,18];
28790 if(this.mouseOffset){
28791 offset[0] += this.mouseOffset[0];
28792 offset[1] += this.mouseOffset[1];
28798 getAnchorPosition : function(){
28800 this.tipAnchor = this.anchor.charAt(0);
28802 var m = this.defaultAlign.match(/^([a-z]+)-([a-z]+)(\?)?$/);
28804 throw 'AnchorTip.defaultAlign is invalid';
28806 this.tipAnchor = m[1].charAt(0);
28809 switch(this.tipAnchor){
28810 case 't': return 'top';
28811 case 'b': return 'bottom';
28812 case 'r': return 'right';
28818 getAnchorAlign : function(){
28819 switch(this.anchor){
28820 case 'top' : return 'tl-bl';
28821 case 'left' : return 'tl-tr';
28822 case 'right': return 'tr-tl';
28823 default : return 'bl-tl';
28828 getOffsets : function(){
28830 ap = this.getAnchorPosition().charAt(0);
28831 if(this.anchorToTarget && !this.trackMouse){
28837 offsets = [0, -13];
28840 offsets = [-13, 0];
28849 offsets = [-15-this.anchorOffset, 30];
28852 offsets = [-19-this.anchorOffset, -13-this.el.dom.offsetHeight];
28855 offsets = [-15-this.el.dom.offsetWidth, -13-this.anchorOffset];
28858 offsets = [25, -13-this.anchorOffset];
28862 var mouseOffset = this.getMouseOffset();
28863 offsets[0] += mouseOffset[0];
28864 offsets[1] += mouseOffset[1];
28870 onTargetOver : function(e){
28871 if(this.disabled || e.within(this.target.dom, true)){
28874 var t = e.getTarget(this.delegate);
28876 this.triggerElement = t;
28877 this.clearTimer('hide');
28878 this.targetXY = e.getXY();
28884 delayShow : function(){
28885 if(this.hidden && !this.showTimer){
28886 if(this.lastActive.getElapsed() < this.quickShowInterval){
28889 this.showTimer = this.show.defer(this.showDelay, this);
28891 }else if(!this.hidden && this.autoHide !== false){
28897 onTargetOut : function(e){
28898 if(this.disabled || e.within(this.target.dom, true)){
28901 this.clearTimer('show');
28902 if(this.autoHide !== false){
28908 delayHide : function(){
28909 if(!this.hidden && !this.hideTimer){
28910 this.hideTimer = this.hide.defer(this.hideDelay, this);
28916 this.clearTimer('dismiss');
28917 this.lastActive = new Date();
28919 this.anchorEl.hide();
28921 Ext.ToolTip.superclass.hide.call(this);
28922 delete this.triggerElement;
28930 this.showAt([-1000,-1000]);
28931 this.origConstrainPosition = this.constrainPosition;
28932 this.constrainPosition = false;
28933 this.anchor = this.origAnchor;
28935 this.showAt(this.getTargetXY());
28939 this.anchorEl.show();
28940 this.constrainPosition = this.origConstrainPosition;
28942 this.anchorEl.hide();
28947 showAt : function(xy){
28948 this.lastActive = new Date();
28949 this.clearTimers();
28950 Ext.ToolTip.superclass.showAt.call(this, xy);
28951 if(this.dismissDelay && this.autoHide !== false){
28952 this.dismissTimer = this.hide.defer(this.dismissDelay, this);
28954 if(this.anchor && !this.anchorEl.isVisible()){
28956 this.anchorEl.show();
28961 syncAnchor : function(){
28962 var anchorPos, targetPos, offset;
28963 switch(this.tipAnchor.charAt(0)){
28967 offset = [20+this.anchorOffset, 2];
28972 offset = [-2, 11+this.anchorOffset];
28977 offset = [20+this.anchorOffset, -2];
28982 offset = [2, 11+this.anchorOffset];
28985 this.anchorEl.alignTo(this.el, anchorPos+'-'+targetPos, offset);
28989 setPagePosition : function(x, y){
28990 Ext.ToolTip.superclass.setPagePosition.call(this, x, y);
28997 clearTimer : function(name){
28998 name = name + 'Timer';
28999 clearTimeout(this[name]);
29004 clearTimers : function(){
29005 this.clearTimer('show');
29006 this.clearTimer('dismiss');
29007 this.clearTimer('hide');
29011 onShow : function(){
29012 Ext.ToolTip.superclass.onShow.call(this);
29013 Ext.getDoc().on('mousedown', this.onDocMouseDown, this);
29017 onHide : function(){
29018 Ext.ToolTip.superclass.onHide.call(this);
29019 Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
29023 onDocMouseDown : function(e){
29024 if(this.autoHide !== true && !this.closable && !e.within(this.el.dom)){
29026 this.enable.defer(100, this);
29031 onDisable : function(){
29032 this.clearTimers();
29037 adjustPosition : function(x, y){
29038 if(this.contstrainPosition){
29039 var ay = this.targetXY[1], h = this.getSize().height;
29040 if(y <= ay && (y+h) >= ay){
29044 return {x : x, y: y};
29047 beforeDestroy : function(){
29048 this.clearTimers();
29049 Ext.destroy(this.anchorEl);
29050 delete this.anchorEl;
29051 delete this.target;
29052 delete this.anchorTarget;
29053 delete this.triggerElement;
29054 Ext.ToolTip.superclass.beforeDestroy.call(this);
29058 onDestroy : function(){
29059 Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
29060 Ext.ToolTip.superclass.onDestroy.call(this);
29064 Ext.reg('tooltip', Ext.ToolTip);
29065 Ext.QuickTip = Ext.extend(Ext.ToolTip, {
29068 interceptTitles : false,
29073 attribute : "qtip",
29084 initComponent : function(){
29085 this.target = this.target || Ext.getDoc();
29086 this.targets = this.targets || {};
29087 Ext.QuickTip.superclass.initComponent.call(this);
29091 register : function(config){
29092 var cs = Ext.isArray(config) ? config : arguments;
29093 for(var i = 0, len = cs.length; i < len; i++){
29095 var target = c.target;
29097 if(Ext.isArray(target)){
29098 for(var j = 0, jlen = target.length; j < jlen; j++){
29099 this.targets[Ext.id(target[j])] = c;
29102 this.targets[Ext.id(target)] = c;
29109 unregister : function(el){
29110 delete this.targets[Ext.id(el)];
29114 cancelShow: function(el){
29115 var at = this.activeTarget;
29116 el = Ext.get(el).dom;
29117 if(this.isVisible()){
29118 if(at && at.el == el){
29121 }else if(at && at.el == el){
29122 this.clearTimer('show');
29126 getTipCfg: function(e) {
29127 var t = e.getTarget(),
29130 if(this.interceptTitles && t.title && Ext.isString(t.title)){
29133 t.removeAttribute("title");
29134 e.preventDefault();
29136 cfg = this.tagConfig;
29137 ttp = t.qtip || Ext.fly(t).getAttribute(cfg.attribute, cfg.namespace);
29143 onTargetOver : function(e){
29147 this.targetXY = e.getXY();
29148 var t = e.getTarget();
29149 if(!t || t.nodeType !== 1 || t == document || t == document.body){
29152 if(this.activeTarget && ((t == this.activeTarget.el) || Ext.fly(this.activeTarget.el).contains(t))){
29153 this.clearTimer('hide');
29157 if(t && this.targets[t.id]){
29158 this.activeTarget = this.targets[t.id];
29159 this.activeTarget.el = t;
29160 this.anchor = this.activeTarget.anchor;
29162 this.anchorTarget = t;
29167 var ttp, et = Ext.fly(t), cfg = this.tagConfig, ns = cfg.namespace;
29168 if(ttp = this.getTipCfg(e)){
29169 var autoHide = et.getAttribute(cfg.hide, ns);
29170 this.activeTarget = {
29173 width: et.getAttribute(cfg.width, ns),
29174 autoHide: autoHide != "user" && autoHide !== 'false',
29175 title: et.getAttribute(cfg.title, ns),
29176 cls: et.getAttribute(cfg.cls, ns),
29177 align: et.getAttribute(cfg.align, ns)
29180 this.anchor = et.getAttribute(cfg.anchor, ns);
29182 this.anchorTarget = t;
29189 onTargetOut : function(e){
29192 if (this.activeTarget && e.within(this.activeTarget.el) && !this.getTipCfg(e)) {
29196 this.clearTimer('show');
29197 if(this.autoHide !== false){
29203 showAt : function(xy){
29204 var t = this.activeTarget;
29206 if(!this.rendered){
29207 this.render(Ext.getBody());
29208 this.activeTarget = t;
29211 this.setWidth(t.width);
29212 this.body.setWidth(this.adjustBodyWidth(t.width - this.getFrameWidth()));
29213 this.measureWidth = false;
29215 this.measureWidth = true;
29217 this.setTitle(t.title || '');
29218 this.body.update(t.text);
29219 this.autoHide = t.autoHide;
29220 this.dismissDelay = t.dismissDelay || this.dismissDelay;
29222 this.el.removeClass(this.lastCls);
29223 delete this.lastCls;
29226 this.el.addClass(t.cls);
29227 this.lastCls = t.cls;
29230 this.constrainPosition = false;
29232 xy = this.el.getAlignToXY(t.el, t.align);
29233 this.constrainPosition = false;
29235 this.constrainPosition = true;
29238 Ext.QuickTip.superclass.showAt.call(this, xy);
29243 delete this.activeTarget;
29244 Ext.QuickTip.superclass.hide.call(this);
29247 Ext.reg('quicktip', Ext.QuickTip);
29248 Ext.QuickTips = function(){
29249 var tip, locks = [];
29252 init : function(autoRender){
29255 Ext.onReady(function(){
29256 Ext.QuickTips.init(autoRender);
29260 tip = new Ext.QuickTip({elements:'header,body'});
29261 if(autoRender !== false){
29262 tip.render(Ext.getBody());
29268 enable : function(){
29271 if(locks.length < 1){
29278 disable : function(){
29286 isEnabled : function(){
29287 return tip !== undefined && !tip.disabled;
29291 getQuickTip : function(){
29296 register : function(){
29297 tip.register.apply(tip, arguments);
29301 unregister : function(){
29302 tip.unregister.apply(tip, arguments);
29307 tip.register.apply(tip, arguments);
29311 Ext.tree.TreePanel = Ext.extend(Ext.Panel, {
29312 rootVisible : true,
29313 animate : Ext.enableFx,
29316 hlDrop : Ext.enableFx,
29317 pathSeparator : '/',
29322 initComponent : function(){
29323 Ext.tree.TreePanel.superclass.initComponent.call(this);
29325 if(!this.eventModel){
29326 this.eventModel = new Ext.tree.TreeEventModel(this);
29330 var l = this.loader;
29332 l = new Ext.tree.TreeLoader({
29333 dataUrl: this.dataUrl,
29334 requestMethod: this.requestMethod
29336 }else if(Ext.isObject(l) && !l.load){
29337 l = new Ext.tree.TreeLoader(l);
29341 this.nodeHash = {};
29347 this.setRootNode(r);
29377 'beforeexpandnode',
29379 'beforecollapsenode',
29399 'containerdblclick',
29403 'containercontextmenu',
29405 'beforechildrenrendered',
29419 if(this.singleExpand){
29420 this.on('beforeexpandnode', this.restrictExpand, this);
29425 proxyNodeEvent : function(ename, a1, a2, a3, a4, a5, a6){
29426 if(ename == 'collapse' || ename == 'expand' || ename == 'beforecollapse' || ename == 'beforeexpand' || ename == 'move' || ename == 'beforemove'){
29427 ename = ename+'node';
29430 return this.fireEvent(ename, a1, a2, a3, a4, a5, a6);
29435 getRootNode : function(){
29440 setRootNode : function(node){
29441 Ext.destroy(this.root);
29443 node = this.loader.createNode(node);
29446 node.ownerTree = this;
29447 node.isRoot = true;
29448 this.registerNode(node);
29449 if(!this.rootVisible){
29450 var uiP = node.attributes.uiProvider;
29451 node.ui = uiP ? new uiP(node) : new Ext.tree.RootTreeNodeUI(node);
29453 if (this.innerCt) {
29454 this.innerCt.update('');
29455 this.afterRender();
29461 getNodeById : function(id){
29462 return this.nodeHash[id];
29466 registerNode : function(node){
29467 this.nodeHash[node.id] = node;
29471 unregisterNode : function(node){
29472 delete this.nodeHash[node.id];
29476 toString : function(){
29477 return '[Tree'+(this.id?' '+this.id:'')+']';
29481 restrictExpand : function(node){
29482 var p = node.parentNode;
29484 if(p.expandedChild && p.expandedChild.parentNode == p){
29485 p.expandedChild.collapse();
29487 p.expandedChild = node;
29492 getChecked : function(a, startNode){
29493 startNode = startNode || this.root;
29495 var f = function(){
29496 if(this.attributes.checked){
29497 r.push(!a ? this : (a == 'id' ? this.id : this.attributes[a]));
29500 startNode.cascade(f);
29505 getLoader : function(){
29506 return this.loader;
29510 expandAll : function(){
29511 this.root.expand(true);
29515 collapseAll : function(){
29516 this.root.collapse(true);
29520 getSelectionModel : function(){
29521 if(!this.selModel){
29522 this.selModel = new Ext.tree.DefaultSelectionModel();
29524 return this.selModel;
29528 expandPath : function(path, attr, callback){
29529 attr = attr || 'id';
29530 var keys = path.split(this.pathSeparator);
29531 var curNode = this.root;
29532 if(curNode.attributes[attr] != keys[1]){
29534 callback(false, null);
29539 var f = function(){
29540 if(++index == keys.length){
29542 callback(true, curNode);
29546 var c = curNode.findChild(attr, keys[index]);
29549 callback(false, curNode);
29554 c.expand(false, false, f);
29556 curNode.expand(false, false, f);
29560 selectPath : function(path, attr, callback){
29561 attr = attr || 'id';
29562 var keys = path.split(this.pathSeparator),
29564 if(keys.length > 1){
29565 var f = function(success, node){
29566 if(success && node){
29567 var n = node.findChild(attr, v);
29573 }else if(callback){
29574 callback(false, n);
29578 callback(false, n);
29582 this.expandPath(keys.join(this.pathSeparator), attr, f);
29584 this.root.select();
29586 callback(true, this.root);
29592 getTreeEl : function(){
29597 onRender : function(ct, position){
29598 Ext.tree.TreePanel.superclass.onRender.call(this, ct, position);
29599 this.el.addClass('x-tree');
29600 this.innerCt = this.body.createChild({tag:'ul',
29601 cls:'x-tree-root-ct ' +
29602 (this.useArrows ? 'x-tree-arrows' : this.lines ? 'x-tree-lines' : 'x-tree-no-lines')});
29606 initEvents : function(){
29607 Ext.tree.TreePanel.superclass.initEvents.call(this);
29609 if(this.containerScroll){
29610 Ext.dd.ScrollManager.register(this.body);
29612 if((this.enableDD || this.enableDrop) && !this.dropZone){
29614 this.dropZone = new Ext.tree.TreeDropZone(this, this.dropConfig || {
29615 ddGroup: this.ddGroup || 'TreeDD', appendOnly: this.ddAppendOnly === true
29618 if((this.enableDD || this.enableDrag) && !this.dragZone){
29620 this.dragZone = new Ext.tree.TreeDragZone(this, this.dragConfig || {
29621 ddGroup: this.ddGroup || 'TreeDD',
29622 scroll: this.ddScroll
29625 this.getSelectionModel().init(this);
29629 afterRender : function(){
29630 Ext.tree.TreePanel.superclass.afterRender.call(this);
29631 this.root.render();
29632 if(!this.rootVisible){
29633 this.root.renderChildren();
29637 beforeDestroy : function(){
29639 Ext.dd.ScrollManager.unregister(this.body);
29640 Ext.destroy(this.dropZone, this.dragZone);
29642 Ext.destroy(this.root, this.loader);
29643 this.nodeHash = this.root = this.loader = null;
29644 Ext.tree.TreePanel.superclass.beforeDestroy.call(this);
29696 Ext.tree.TreePanel.nodeTypes = {};
29698 Ext.reg('treepanel', Ext.tree.TreePanel);Ext.tree.TreeEventModel = function(tree){
29700 this.tree.on('render', this.initEvents, this);
29703 Ext.tree.TreeEventModel.prototype = {
29704 initEvents : function(){
29707 if(t.trackMouseOver !== false){
29710 mouseover: this.delegateOver,
29711 mouseout: this.delegateOut
29714 t.mon(t.getTreeEl(), {
29716 click: this.delegateClick,
29717 dblclick: this.delegateDblClick,
29718 contextmenu: this.delegateContextMenu
29722 getNode : function(e){
29724 if(t = e.getTarget('.x-tree-node-el', 10)){
29725 var id = Ext.fly(t, '_treeEvents').getAttribute('tree-node-id', 'ext');
29727 return this.tree.getNodeById(id);
29733 getNodeTarget : function(e){
29734 var t = e.getTarget('.x-tree-node-icon', 1);
29736 t = e.getTarget('.x-tree-node-el', 6);
29741 delegateOut : function(e, t){
29742 if(!this.beforeEvent(e)){
29745 if(e.getTarget('.x-tree-ec-icon', 1)){
29746 var n = this.getNode(e);
29747 this.onIconOut(e, n);
29748 if(n == this.lastEcOver){
29749 delete this.lastEcOver;
29752 if((t = this.getNodeTarget(e)) && !e.within(t, true)){
29753 this.onNodeOut(e, this.getNode(e));
29757 delegateOver : function(e, t){
29758 if(!this.beforeEvent(e)){
29761 if(Ext.isGecko && !this.trackingDoc){
29762 Ext.getBody().on('mouseover', this.trackExit, this);
29763 this.trackingDoc = true;
29765 if(this.lastEcOver){
29766 this.onIconOut(e, this.lastEcOver);
29767 delete this.lastEcOver;
29769 if(e.getTarget('.x-tree-ec-icon', 1)){
29770 this.lastEcOver = this.getNode(e);
29771 this.onIconOver(e, this.lastEcOver);
29773 if(t = this.getNodeTarget(e)){
29774 this.onNodeOver(e, this.getNode(e));
29778 trackExit : function(e){
29779 if(this.lastOverNode && !e.within(this.lastOverNode.ui.getEl())){
29780 this.onNodeOut(e, this.lastOverNode);
29781 delete this.lastOverNode;
29782 Ext.getBody().un('mouseover', this.trackExit, this);
29783 this.trackingDoc = false;
29787 delegateClick : function(e, t){
29788 if(this.beforeEvent(e)){
29789 if(e.getTarget('input[type=checkbox]', 1)){
29790 this.onCheckboxClick(e, this.getNode(e));
29791 }else if(e.getTarget('.x-tree-ec-icon', 1)){
29792 this.onIconClick(e, this.getNode(e));
29793 }else if(this.getNodeTarget(e)){
29794 this.onNodeClick(e, this.getNode(e));
29796 this.onContainerEvent(e, 'click');
29801 delegateDblClick : function(e, t){
29802 if(this.beforeEvent(e)){
29803 if(this.getNodeTarget(e)){
29804 this.onNodeDblClick(e, this.getNode(e));
29806 this.onContainerEvent(e, 'dblclick');
29811 delegateContextMenu : function(e, t){
29812 if(this.beforeEvent(e)){
29813 if(this.getNodeTarget(e)){
29814 this.onNodeContextMenu(e, this.getNode(e));
29816 this.onContainerEvent(e, 'contextmenu');
29821 onContainerEvent: function(e, type){
29822 this.tree.fireEvent('container' + type, this.tree, e);
29825 onNodeClick : function(e, node){
29826 node.ui.onClick(e);
29829 onNodeOver : function(e, node){
29830 this.lastOverNode = node;
29834 onNodeOut : function(e, node){
29838 onIconOver : function(e, node){
29839 node.ui.addClass('x-tree-ec-over');
29842 onIconOut : function(e, node){
29843 node.ui.removeClass('x-tree-ec-over');
29846 onIconClick : function(e, node){
29847 node.ui.ecClick(e);
29850 onCheckboxClick : function(e, node){
29851 node.ui.onCheckChange(e);
29854 onNodeDblClick : function(e, node){
29855 node.ui.onDblClick(e);
29858 onNodeContextMenu : function(e, node){
29859 node.ui.onContextMenu(e);
29862 beforeEvent : function(e){
29870 disable: function(){
29871 this.disabled = true;
29874 enable: function(){
29875 this.disabled = false;
29878 Ext.tree.DefaultSelectionModel = function(config){
29879 this.selNode = null;
29889 Ext.apply(this, config);
29890 Ext.tree.DefaultSelectionModel.superclass.constructor.call(this);
29893 Ext.extend(Ext.tree.DefaultSelectionModel, Ext.util.Observable, {
29894 init : function(tree){
29896 tree.mon(tree.getTreeEl(), 'keydown', this.onKeyDown, this);
29897 tree.on('click', this.onNodeClick, this);
29900 onNodeClick : function(node, e){
29905 select : function(node, selectNextNode){
29907 if (!Ext.fly(node.ui.wrap).isVisible() && selectNextNode) {
29908 return selectNextNode.call(this, node);
29910 var last = this.selNode;
29912 node.ui.onSelectedChange(true);
29913 }else if(this.fireEvent('beforeselect', this, node, last) !== false){
29914 if(last && last.ui){
29915 last.ui.onSelectedChange(false);
29917 this.selNode = node;
29918 node.ui.onSelectedChange(true);
29919 this.fireEvent('selectionchange', this, node, last);
29925 unselect : function(node, silent){
29926 if(this.selNode == node){
29927 this.clearSelections(silent);
29932 clearSelections : function(silent){
29933 var n = this.selNode;
29935 n.ui.onSelectedChange(false);
29936 this.selNode = null;
29937 if(silent !== true){
29938 this.fireEvent('selectionchange', this, null);
29945 getSelectedNode : function(){
29946 return this.selNode;
29950 isSelected : function(node){
29951 return this.selNode == node;
29955 selectPrevious : function( s){
29956 if(!(s = s || this.selNode || this.lastSelNode)){
29960 var ps = s.previousSibling;
29962 if(!ps.isExpanded() || ps.childNodes.length < 1){
29963 return this.select(ps, this.selectPrevious);
29965 var lc = ps.lastChild;
29966 while(lc && lc.isExpanded() && Ext.fly(lc.ui.wrap).isVisible() && lc.childNodes.length > 0){
29969 return this.select(lc, this.selectPrevious);
29971 } else if(s.parentNode && (this.tree.rootVisible || !s.parentNode.isRoot)){
29972 return this.select(s.parentNode, this.selectPrevious);
29978 selectNext : function( s){
29979 if(!(s = s || this.selNode || this.lastSelNode)){
29983 if(s.firstChild && s.isExpanded() && Ext.fly(s.ui.wrap).isVisible()){
29984 return this.select(s.firstChild, this.selectNext);
29985 }else if(s.nextSibling){
29986 return this.select(s.nextSibling, this.selectNext);
29987 }else if(s.parentNode){
29989 s.parentNode.bubble(function(){
29990 if(this.nextSibling){
29991 newS = this.getOwnerTree().selModel.select(this.nextSibling, this.selectNext);
30000 onKeyDown : function(e){
30001 var s = this.selNode || this.lastSelNode;
30007 var k = e.getKey();
30015 this.selectPrevious();
30018 e.preventDefault();
30019 if(s.hasChildNodes()){
30020 if(!s.isExpanded()){
30022 }else if(s.firstChild){
30023 this.select(s.firstChild, e);
30028 e.preventDefault();
30029 if(s.hasChildNodes() && s.isExpanded()){
30031 }else if(s.parentNode && (this.tree.rootVisible || s.parentNode != this.tree.getRootNode())){
30032 this.select(s.parentNode, e);
30040 Ext.tree.MultiSelectionModel = function(config){
30041 this.selNodes = [];
30047 Ext.apply(this, config);
30048 Ext.tree.MultiSelectionModel.superclass.constructor.call(this);
30051 Ext.extend(Ext.tree.MultiSelectionModel, Ext.util.Observable, {
30052 init : function(tree){
30054 tree.mon(tree.getTreeEl(), 'keydown', this.onKeyDown, this);
30055 tree.on('click', this.onNodeClick, this);
30058 onNodeClick : function(node, e){
30059 if(e.ctrlKey && this.isSelected(node)){
30060 this.unselect(node);
30062 this.select(node, e, e.ctrlKey);
30067 select : function(node, e, keepExisting){
30068 if(keepExisting !== true){
30069 this.clearSelections(true);
30071 if(this.isSelected(node)){
30072 this.lastSelNode = node;
30075 this.selNodes.push(node);
30076 this.selMap[node.id] = node;
30077 this.lastSelNode = node;
30078 node.ui.onSelectedChange(true);
30079 this.fireEvent('selectionchange', this, this.selNodes);
30084 unselect : function(node){
30085 if(this.selMap[node.id]){
30086 node.ui.onSelectedChange(false);
30087 var sn = this.selNodes;
30088 var index = sn.indexOf(node);
30090 this.selNodes.splice(index, 1);
30092 delete this.selMap[node.id];
30093 this.fireEvent('selectionchange', this, this.selNodes);
30098 clearSelections : function(suppressEvent){
30099 var sn = this.selNodes;
30101 for(var i = 0, len = sn.length; i < len; i++){
30102 sn[i].ui.onSelectedChange(false);
30104 this.selNodes = [];
30106 if(suppressEvent !== true){
30107 this.fireEvent('selectionchange', this, this.selNodes);
30113 isSelected : function(node){
30114 return this.selMap[node.id] ? true : false;
30118 getSelectedNodes : function(){
30119 return this.selNodes;
30122 onKeyDown : Ext.tree.DefaultSelectionModel.prototype.onKeyDown,
30124 selectNext : Ext.tree.DefaultSelectionModel.prototype.selectNext,
30126 selectPrevious : Ext.tree.DefaultSelectionModel.prototype.selectPrevious
30128 Ext.data.Tree = function(root){
30129 this.nodeHash = {};
30133 this.setRootNode(root);
30154 Ext.data.Tree.superclass.constructor.call(this);
30157 Ext.extend(Ext.data.Tree, Ext.util.Observable, {
30159 pathSeparator: "/",
30162 proxyNodeEvent : function(){
30163 return this.fireEvent.apply(this, arguments);
30167 getRootNode : function(){
30172 setRootNode : function(node){
30174 node.ownerTree = this;
30175 node.isRoot = true;
30176 this.registerNode(node);
30181 getNodeById : function(id){
30182 return this.nodeHash[id];
30186 registerNode : function(node){
30187 this.nodeHash[node.id] = node;
30191 unregisterNode : function(node){
30192 delete this.nodeHash[node.id];
30195 toString : function(){
30196 return "[Tree"+(this.id?" "+this.id:"")+"]";
30201 Ext.data.Node = function(attributes){
30203 this.attributes = attributes || {};
30204 this.leaf = this.attributes.leaf;
30206 this.id = this.attributes.id;
30208 this.id = Ext.id(null, "xnode-");
30209 this.attributes.id = this.id;
30212 this.childNodes = [];
30213 if(!this.childNodes.indexOf){
30214 this.childNodes.indexOf = function(o){
30215 for(var i = 0, len = this.length; i < len; i++){
30224 this.parentNode = null;
30226 this.firstChild = null;
30228 this.lastChild = null;
30230 this.previousSibling = null;
30232 this.nextSibling = null;
30244 "beforeappend" : true,
30246 "beforeremove" : true,
30248 "beforemove" : true,
30250 "beforeinsert" : true
30252 this.listeners = this.attributes.listeners;
30253 Ext.data.Node.superclass.constructor.call(this);
30256 Ext.extend(Ext.data.Node, Ext.util.Observable, {
30258 fireEvent : function(evtName){
30260 if(Ext.data.Node.superclass.fireEvent.apply(this, arguments) === false){
30264 var ot = this.getOwnerTree();
30266 if(ot.proxyNodeEvent.apply(ot, arguments) === false){
30274 isLeaf : function(){
30275 return this.leaf === true;
30279 setFirstChild : function(node){
30280 this.firstChild = node;
30284 setLastChild : function(node){
30285 this.lastChild = node;
30290 isLast : function(){
30291 return (!this.parentNode ? true : this.parentNode.lastChild == this);
30295 isFirst : function(){
30296 return (!this.parentNode ? true : this.parentNode.firstChild == this);
30300 hasChildNodes : function(){
30301 return !this.isLeaf() && this.childNodes.length > 0;
30305 isExpandable : function(){
30306 return this.attributes.expandable || this.hasChildNodes();
30310 appendChild : function(node){
30312 if(Ext.isArray(node)){
30314 }else if(arguments.length > 1){
30319 for(var i = 0, len = multi.length; i < len; i++) {
30320 this.appendChild(multi[i]);
30323 if(this.fireEvent("beforeappend", this.ownerTree, this, node) === false){
30326 var index = this.childNodes.length;
30327 var oldParent = node.parentNode;
30330 if(node.fireEvent("beforemove", node.getOwnerTree(), node, oldParent, this, index) === false){
30333 oldParent.removeChild(node);
30335 index = this.childNodes.length;
30337 this.setFirstChild(node);
30339 this.childNodes.push(node);
30340 node.parentNode = this;
30341 var ps = this.childNodes[index-1];
30343 node.previousSibling = ps;
30344 ps.nextSibling = node;
30346 node.previousSibling = null;
30348 node.nextSibling = null;
30349 this.setLastChild(node);
30350 node.setOwnerTree(this.getOwnerTree());
30351 this.fireEvent("append", this.ownerTree, this, node, index);
30353 node.fireEvent("move", this.ownerTree, node, oldParent, this, index);
30360 removeChild : function(node, destroy){
30361 var index = this.childNodes.indexOf(node);
30365 if(this.fireEvent("beforeremove", this.ownerTree, this, node) === false){
30370 this.childNodes.splice(index, 1);
30373 if(node.previousSibling){
30374 node.previousSibling.nextSibling = node.nextSibling;
30376 if(node.nextSibling){
30377 node.nextSibling.previousSibling = node.previousSibling;
30381 if(this.firstChild == node){
30382 this.setFirstChild(node.nextSibling);
30384 if(this.lastChild == node){
30385 this.setLastChild(node.previousSibling);
30389 this.fireEvent("remove", this.ownerTree, this, node);
30397 clear : function(destroy){
30399 this.setOwnerTree(null, destroy);
30400 this.parentNode = this.previousSibling = this.nextSibling = null
30402 this.firstChild = this.lastChild = null;
30407 destroy : function(){
30408 this.purgeListeners();
30410 Ext.each(this.childNodes, function(n){
30413 this.childNodes = null;
30417 insertBefore : function(node, refNode){
30419 return this.appendChild(node);
30422 if(node == refNode){
30426 if(this.fireEvent("beforeinsert", this.ownerTree, this, node, refNode) === false){
30429 var index = this.childNodes.indexOf(refNode);
30430 var oldParent = node.parentNode;
30431 var refIndex = index;
30434 if(oldParent == this && this.childNodes.indexOf(node) < index){
30440 if(node.fireEvent("beforemove", node.getOwnerTree(), node, oldParent, this, index, refNode) === false){
30443 oldParent.removeChild(node);
30445 if(refIndex === 0){
30446 this.setFirstChild(node);
30448 this.childNodes.splice(refIndex, 0, node);
30449 node.parentNode = this;
30450 var ps = this.childNodes[refIndex-1];
30452 node.previousSibling = ps;
30453 ps.nextSibling = node;
30455 node.previousSibling = null;
30457 node.nextSibling = refNode;
30458 refNode.previousSibling = node;
30459 node.setOwnerTree(this.getOwnerTree());
30460 this.fireEvent("insert", this.ownerTree, this, node, refNode);
30462 node.fireEvent("move", this.ownerTree, node, oldParent, this, refIndex, refNode);
30468 remove : function(destroy){
30469 this.parentNode.removeChild(this, destroy);
30474 item : function(index){
30475 return this.childNodes[index];
30479 replaceChild : function(newChild, oldChild){
30480 var s = oldChild ? oldChild.nextSibling : null;
30481 this.removeChild(oldChild);
30482 this.insertBefore(newChild, s);
30487 indexOf : function(child){
30488 return this.childNodes.indexOf(child);
30492 getOwnerTree : function(){
30494 if(!this.ownerTree){
30498 this.ownerTree = p.ownerTree;
30504 return this.ownerTree;
30508 getDepth : function(){
30511 while(p.parentNode){
30519 setOwnerTree : function(tree, destroy){
30521 if(tree != this.ownerTree){
30522 if(this.ownerTree){
30523 this.ownerTree.unregisterNode(this);
30525 this.ownerTree = tree;
30527 if(destroy !== true){
30528 Ext.each(this.childNodes, function(n){
30529 n.setOwnerTree(tree);
30533 tree.registerNode(this);
30539 setId: function(id){
30540 if(id !== this.id){
30541 var t = this.ownerTree;
30543 t.unregisterNode(this);
30545 this.id = this.attributes.id = id;
30547 t.registerNode(this);
30549 this.onIdChange(id);
30554 onIdChange: Ext.emptyFn,
30557 getPath : function(attr){
30558 attr = attr || "id";
30559 var p = this.parentNode;
30560 var b = [this.attributes[attr]];
30562 b.unshift(p.attributes[attr]);
30565 var sep = this.getOwnerTree().pathSeparator;
30566 return sep + b.join(sep);
30570 bubble : function(fn, scope, args){
30573 if(fn.apply(scope || p, args || [p]) === false){
30581 cascade : function(fn, scope, args){
30582 if(fn.apply(scope || this, args || [this]) !== false){
30583 var cs = this.childNodes;
30584 for(var i = 0, len = cs.length; i < len; i++) {
30585 cs[i].cascade(fn, scope, args);
30591 eachChild : function(fn, scope, args){
30592 var cs = this.childNodes;
30593 for(var i = 0, len = cs.length; i < len; i++) {
30594 if(fn.apply(scope || this, args || [cs[i]]) === false){
30601 findChild : function(attribute, value){
30602 var cs = this.childNodes;
30603 for(var i = 0, len = cs.length; i < len; i++) {
30604 if(cs[i].attributes[attribute] == value){
30612 findChildBy : function(fn, scope){
30613 var cs = this.childNodes;
30614 for(var i = 0, len = cs.length; i < len; i++) {
30615 if(fn.call(scope||cs[i], cs[i]) === true){
30623 sort : function(fn, scope){
30624 var cs = this.childNodes;
30625 var len = cs.length;
30627 var sortFn = scope ? function(){fn.apply(scope, arguments);} : fn;
30629 for(var i = 0; i < len; i++){
30631 n.previousSibling = cs[i-1];
30632 n.nextSibling = cs[i+1];
30634 this.setFirstChild(n);
30637 this.setLastChild(n);
30644 contains : function(node){
30645 return node.isAncestor(this);
30649 isAncestor : function(node){
30650 var p = this.parentNode;
30660 toString : function(){
30661 return "[Node"+(this.id?" "+this.id:"")+"]";
30664 Ext.tree.TreeNode = function(attributes){
30665 attributes = attributes || {};
30666 if(Ext.isString(attributes)){
30667 attributes = {text: attributes};
30669 this.childrenRendered = false;
30670 this.rendered = false;
30671 Ext.tree.TreeNode.superclass.constructor.call(this, attributes);
30672 this.expanded = attributes.expanded === true;
30673 this.isTarget = attributes.isTarget !== false;
30674 this.draggable = attributes.draggable !== false && attributes.allowDrag !== false;
30675 this.allowChildren = attributes.allowChildren !== false && attributes.allowDrop !== false;
30678 this.text = attributes.text;
30680 this.disabled = attributes.disabled === true;
30682 this.hidden = attributes.hidden === true;
30710 'beforechildrenrendered'
30713 var uiClass = this.attributes.uiProvider || this.defaultUI || Ext.tree.TreeNodeUI;
30716 this.ui = new uiClass(this);
30718 Ext.extend(Ext.tree.TreeNode, Ext.data.Node, {
30719 preventHScroll : true,
30721 isExpanded : function(){
30722 return this.expanded;
30726 getUI : function(){
30730 getLoader : function(){
30732 return this.loader || ((owner = this.getOwnerTree()) && owner.loader ? owner.loader : (this.loader = new Ext.tree.TreeLoader()));
30736 setFirstChild : function(node){
30737 var of = this.firstChild;
30738 Ext.tree.TreeNode.superclass.setFirstChild.call(this, node);
30739 if(this.childrenRendered && of && node != of){
30740 of.renderIndent(true, true);
30743 this.renderIndent(true, true);
30748 setLastChild : function(node){
30749 var ol = this.lastChild;
30750 Ext.tree.TreeNode.superclass.setLastChild.call(this, node);
30751 if(this.childrenRendered && ol && node != ol){
30752 ol.renderIndent(true, true);
30755 this.renderIndent(true, true);
30761 appendChild : function(n){
30762 if(!n.render && !Ext.isArray(n)){
30763 n = this.getLoader().createNode(n);
30765 var node = Ext.tree.TreeNode.superclass.appendChild.call(this, n);
30766 if(node && this.childrenRendered){
30769 this.ui.updateExpandIcon();
30774 removeChild : function(node, destroy){
30775 this.ownerTree.getSelectionModel().unselect(node);
30776 Ext.tree.TreeNode.superclass.removeChild.apply(this, arguments);
30778 if(node.ui.rendered){
30781 if(this.childNodes.length < 1){
30782 this.collapse(false, false);
30784 this.ui.updateExpandIcon();
30786 if(!this.firstChild && !this.isHiddenRoot()) {
30787 this.childrenRendered = false;
30793 insertBefore : function(node, refNode){
30795 node = this.getLoader().createNode(node);
30797 var newNode = Ext.tree.TreeNode.superclass.insertBefore.call(this, node, refNode);
30798 if(newNode && refNode && this.childrenRendered){
30801 this.ui.updateExpandIcon();
30806 setText : function(text){
30807 var oldText = this.text;
30808 this.text = this.attributes.text = text;
30810 this.ui.onTextChange(this, text, oldText);
30812 this.fireEvent('textchange', this, text, oldText);
30816 select : function(){
30817 var t = this.getOwnerTree();
30819 t.getSelectionModel().select(this);
30824 unselect : function(silent){
30825 var t = this.getOwnerTree();
30827 t.getSelectionModel().unselect(this, silent);
30832 isSelected : function(){
30833 var t = this.getOwnerTree();
30834 return t ? t.getSelectionModel().isSelected(this) : false;
30838 expand : function(deep, anim, callback, scope){
30839 if(!this.expanded){
30840 if(this.fireEvent('beforeexpand', this, deep, anim) === false){
30843 if(!this.childrenRendered){
30844 this.renderChildren();
30846 this.expanded = true;
30847 if(!this.isHiddenRoot() && (this.getOwnerTree().animate && anim !== false) || anim){
30848 this.ui.animExpand(function(){
30849 this.fireEvent('expand', this);
30850 this.runCallback(callback, scope || this, [this]);
30852 this.expandChildNodes(true);
30854 }.createDelegate(this));
30858 this.fireEvent('expand', this);
30859 this.runCallback(callback, scope || this, [this]);
30862 this.runCallback(callback, scope || this, [this]);
30865 this.expandChildNodes(true);
30869 runCallback : function(cb, scope, args){
30870 if(Ext.isFunction(cb)){
30871 cb.apply(scope, args);
30875 isHiddenRoot : function(){
30876 return this.isRoot && !this.getOwnerTree().rootVisible;
30880 collapse : function(deep, anim, callback, scope){
30881 if(this.expanded && !this.isHiddenRoot()){
30882 if(this.fireEvent('beforecollapse', this, deep, anim) === false){
30885 this.expanded = false;
30886 if((this.getOwnerTree().animate && anim !== false) || anim){
30887 this.ui.animCollapse(function(){
30888 this.fireEvent('collapse', this);
30889 this.runCallback(callback, scope || this, [this]);
30891 this.collapseChildNodes(true);
30893 }.createDelegate(this));
30896 this.ui.collapse();
30897 this.fireEvent('collapse', this);
30898 this.runCallback(callback, scope || this, [this]);
30900 }else if(!this.expanded){
30901 this.runCallback(callback, scope || this, [this]);
30904 var cs = this.childNodes;
30905 for(var i = 0, len = cs.length; i < len; i++) {
30906 cs[i].collapse(true, false);
30912 delayedExpand : function(delay){
30913 if(!this.expandProcId){
30914 this.expandProcId = this.expand.defer(delay, this);
30919 cancelExpand : function(){
30920 if(this.expandProcId){
30921 clearTimeout(this.expandProcId);
30923 this.expandProcId = false;
30927 toggle : function(){
30936 ensureVisible : function(callback, scope){
30937 var tree = this.getOwnerTree();
30938 tree.expandPath(this.parentNode ? this.parentNode.getPath() : this.getPath(), false, function(){
30939 var node = tree.getNodeById(this.id);
30940 tree.getTreeEl().scrollChildIntoView(node.ui.anchor);
30941 this.runCallback(callback, scope || this, [this]);
30942 }.createDelegate(this));
30946 expandChildNodes : function(deep){
30947 var cs = this.childNodes;
30948 for(var i = 0, len = cs.length; i < len; i++) {
30949 cs[i].expand(deep);
30954 collapseChildNodes : function(deep){
30955 var cs = this.childNodes;
30956 for(var i = 0, len = cs.length; i < len; i++) {
30957 cs[i].collapse(deep);
30962 disable : function(){
30963 this.disabled = true;
30965 if(this.rendered && this.ui.onDisableChange){
30966 this.ui.onDisableChange(this, true);
30968 this.fireEvent('disabledchange', this, true);
30972 enable : function(){
30973 this.disabled = false;
30974 if(this.rendered && this.ui.onDisableChange){
30975 this.ui.onDisableChange(this, false);
30977 this.fireEvent('disabledchange', this, false);
30981 renderChildren : function(suppressEvent){
30982 if(suppressEvent !== false){
30983 this.fireEvent('beforechildrenrendered', this);
30985 var cs = this.childNodes;
30986 for(var i = 0, len = cs.length; i < len; i++){
30987 cs[i].render(true);
30989 this.childrenRendered = true;
30993 sort : function(fn, scope){
30994 Ext.tree.TreeNode.superclass.sort.apply(this, arguments);
30995 if(this.childrenRendered){
30996 var cs = this.childNodes;
30997 for(var i = 0, len = cs.length; i < len; i++){
30998 cs[i].render(true);
31004 render : function(bulkRender){
31005 this.ui.render(bulkRender);
31006 if(!this.rendered){
31008 this.getOwnerTree().registerNode(this);
31009 this.rendered = true;
31011 this.expanded = false;
31012 this.expand(false, false);
31018 renderIndent : function(deep, refresh){
31020 this.ui.childIndent = null;
31022 this.ui.renderIndent();
31023 if(deep === true && this.childrenRendered){
31024 var cs = this.childNodes;
31025 for(var i = 0, len = cs.length; i < len; i++){
31026 cs[i].renderIndent(true, refresh);
31031 beginUpdate : function(){
31032 this.childrenRendered = false;
31035 endUpdate : function(){
31036 if(this.expanded && this.rendered){
31037 this.renderChildren();
31041 destroy : function(){
31042 this.unselect(true);
31043 Ext.tree.TreeNode.superclass.destroy.call(this);
31044 Ext.destroy(this.ui, this.loader);
31045 this.ui = this.loader = null;
31049 onIdChange : function(id){
31050 this.ui.onIdChange(id);
31054 Ext.tree.TreePanel.nodeTypes.node = Ext.tree.TreeNode;
31055 Ext.tree.AsyncTreeNode = function(config){
31056 this.loaded = config && config.loaded === true;
31057 this.loading = false;
31058 Ext.tree.AsyncTreeNode.superclass.constructor.apply(this, arguments);
31060 this.addEvents('beforeload', 'load');
31064 Ext.extend(Ext.tree.AsyncTreeNode, Ext.tree.TreeNode, {
31065 expand : function(deep, anim, callback, scope){
31068 var f = function(){
31070 clearInterval(timer);
31071 this.expand(deep, anim, callback, scope);
31073 }.createDelegate(this);
31074 timer = setInterval(f, 200);
31078 if(this.fireEvent("beforeload", this) === false){
31081 this.loading = true;
31082 this.ui.beforeLoad(this);
31083 var loader = this.loader || this.attributes.loader || this.getOwnerTree().getLoader();
31085 loader.load(this, this.loadComplete.createDelegate(this, [deep, anim, callback, scope]), this);
31089 Ext.tree.AsyncTreeNode.superclass.expand.call(this, deep, anim, callback, scope);
31093 isLoading : function(){
31094 return this.loading;
31097 loadComplete : function(deep, anim, callback, scope){
31098 this.loading = false;
31099 this.loaded = true;
31100 this.ui.afterLoad(this);
31101 this.fireEvent("load", this);
31102 this.expand(deep, anim, callback, scope);
31106 isLoaded : function(){
31107 return this.loaded;
31110 hasChildNodes : function(){
31111 if(!this.isLeaf() && !this.loaded){
31114 return Ext.tree.AsyncTreeNode.superclass.hasChildNodes.call(this);
31119 reload : function(callback, scope){
31120 this.collapse(false, false);
31121 while(this.firstChild){
31122 this.removeChild(this.firstChild).destroy();
31124 this.childrenRendered = false;
31125 this.loaded = false;
31126 if(this.isHiddenRoot()){
31127 this.expanded = false;
31129 this.expand(false, false, callback, scope);
31133 Ext.tree.TreePanel.nodeTypes.async = Ext.tree.AsyncTreeNode;
31134 Ext.tree.TreeNodeUI = function(node){
31136 this.rendered = false;
31137 this.animating = false;
31138 this.wasLeaf = true;
31139 this.ecc = 'x-tree-ec-icon x-tree-elbow';
31140 this.emptyIcon = Ext.BLANK_IMAGE_URL;
31143 Ext.tree.TreeNodeUI.prototype = {
31145 removeChild : function(node){
31147 this.ctNode.removeChild(node.ui.getEl());
31152 beforeLoad : function(){
31153 this.addClass("x-tree-node-loading");
31157 afterLoad : function(){
31158 this.removeClass("x-tree-node-loading");
31162 onTextChange : function(node, text, oldText){
31164 this.textNode.innerHTML = text;
31169 onDisableChange : function(node, state){
31170 this.disabled = state;
31171 if (this.checkbox) {
31172 this.checkbox.disabled = state;
31175 this.addClass("x-tree-node-disabled");
31177 this.removeClass("x-tree-node-disabled");
31182 onSelectedChange : function(state){
31185 this.addClass("x-tree-selected");
31188 this.removeClass("x-tree-selected");
31193 onMove : function(tree, node, oldParent, newParent, index, refNode){
31194 this.childIndent = null;
31196 var targetNode = newParent.ui.getContainer();
31198 this.holder = document.createElement("div");
31199 this.holder.appendChild(this.wrap);
31202 var insertBefore = refNode ? refNode.ui.getEl() : null;
31204 targetNode.insertBefore(this.wrap, insertBefore);
31206 targetNode.appendChild(this.wrap);
31208 this.node.renderIndent(true, oldParent != newParent);
31213 addClass : function(cls){
31215 Ext.fly(this.elNode).addClass(cls);
31220 removeClass : function(cls){
31222 Ext.fly(this.elNode).removeClass(cls);
31227 remove : function(){
31229 this.holder = document.createElement("div");
31230 this.holder.appendChild(this.wrap);
31235 fireEvent : function(){
31236 return this.node.fireEvent.apply(this.node, arguments);
31240 initEvents : function(){
31241 this.node.on("move", this.onMove, this);
31243 if(this.node.disabled){
31244 this.onDisableChange(this.node, true);
31246 if(this.node.hidden){
31249 var ot = this.node.getOwnerTree();
31250 var dd = ot.enableDD || ot.enableDrag || ot.enableDrop;
31251 if(dd && (!this.node.isRoot || ot.rootVisible)){
31252 Ext.dd.Registry.register(this.elNode, {
31254 handles: this.getDDHandles(),
31261 getDDHandles : function(){
31262 return [this.iconNode, this.textNode, this.elNode];
31267 this.node.hidden = true;
31269 this.wrap.style.display = "none";
31275 this.node.hidden = false;
31277 this.wrap.style.display = "";
31282 onContextMenu : function(e){
31283 if (this.node.hasListener("contextmenu") || this.node.getOwnerTree().hasListener("contextmenu")) {
31284 e.preventDefault();
31286 this.fireEvent("contextmenu", this.node, e);
31291 onClick : function(e){
31296 if(this.fireEvent("beforeclick", this.node, e) !== false){
31297 var a = e.getTarget('a');
31298 if(!this.disabled && this.node.attributes.href && a){
31299 this.fireEvent("click", this.node, e);
31301 }else if(a && e.ctrlKey){
31304 e.preventDefault();
31309 if(this.node.attributes.singleClickExpand && !this.animating && this.node.isExpandable()){
31310 this.node.toggle();
31313 this.fireEvent("click", this.node, e);
31320 onDblClick : function(e){
31321 e.preventDefault();
31325 if(this.fireEvent("beforedblclick", this.node, e) !== false){
31327 this.toggleCheck();
31329 if(!this.animating && this.node.isExpandable()){
31330 this.node.toggle();
31332 this.fireEvent("dblclick", this.node, e);
31336 onOver : function(e){
31337 this.addClass('x-tree-node-over');
31340 onOut : function(e){
31341 this.removeClass('x-tree-node-over');
31345 onCheckChange : function(){
31346 var checked = this.checkbox.checked;
31348 this.checkbox.defaultChecked = checked;
31349 this.node.attributes.checked = checked;
31350 this.fireEvent('checkchange', this.node, checked);
31354 ecClick : function(e){
31355 if(!this.animating && this.node.isExpandable()){
31356 this.node.toggle();
31361 startDrop : function(){
31362 this.dropping = true;
31366 endDrop : function(){
31367 setTimeout(function(){
31368 this.dropping = false;
31369 }.createDelegate(this), 50);
31373 expand : function(){
31374 this.updateExpandIcon();
31375 this.ctNode.style.display = "";
31379 focus : function(){
31380 if(!this.node.preventHScroll){
31381 try{this.anchor.focus();
31385 var noscroll = this.node.getOwnerTree().getTreeEl().dom;
31386 var l = noscroll.scrollLeft;
31387 this.anchor.focus();
31388 noscroll.scrollLeft = l;
31394 toggleCheck : function(value){
31395 var cb = this.checkbox;
31397 cb.checked = (value === undefined ? !cb.checked : value);
31398 this.onCheckChange();
31405 this.anchor.blur();
31410 animExpand : function(callback){
31411 var ct = Ext.get(this.ctNode);
31413 if(!this.node.isExpandable()){
31414 this.updateExpandIcon();
31415 this.ctNode.style.display = "";
31416 Ext.callback(callback);
31419 this.animating = true;
31420 this.updateExpandIcon();
31423 callback : function(){
31424 this.animating = false;
31425 Ext.callback(callback);
31428 duration: this.node.ownerTree.duration || .25
31433 highlight : function(){
31434 var tree = this.node.getOwnerTree();
31435 Ext.fly(this.wrap).highlight(
31436 tree.hlColor || "C3DAF9",
31437 {endColor: tree.hlBaseColor}
31442 collapse : function(){
31443 this.updateExpandIcon();
31444 this.ctNode.style.display = "none";
31448 animCollapse : function(callback){
31449 var ct = Ext.get(this.ctNode);
31450 ct.enableDisplayMode('block');
31453 this.animating = true;
31454 this.updateExpandIcon();
31457 callback : function(){
31458 this.animating = false;
31459 Ext.callback(callback);
31462 duration: this.node.ownerTree.duration || .25
31467 getContainer : function(){
31468 return this.ctNode;
31472 getEl : function(){
31477 appendDDGhost : function(ghostNode){
31478 ghostNode.appendChild(this.elNode.cloneNode(true));
31482 getDDRepairXY : function(){
31483 return Ext.lib.Dom.getXY(this.iconNode);
31487 onRender : function(){
31492 render : function(bulkRender){
31493 var n = this.node, a = n.attributes;
31494 var targetNode = n.parentNode ?
31495 n.parentNode.ui.getContainer() : n.ownerTree.innerCt.dom;
31497 if(!this.rendered){
31498 this.rendered = true;
31500 this.renderElements(n, a, targetNode, bulkRender);
31503 if(this.textNode.setAttributeNS){
31504 this.textNode.setAttributeNS("ext", "qtip", a.qtip);
31506 this.textNode.setAttributeNS("ext", "qtitle", a.qtipTitle);
31509 this.textNode.setAttribute("ext:qtip", a.qtip);
31511 this.textNode.setAttribute("ext:qtitle", a.qtipTitle);
31514 }else if(a.qtipCfg){
31515 a.qtipCfg.target = Ext.id(this.textNode);
31516 Ext.QuickTips.register(a.qtipCfg);
31519 if(!this.node.expanded){
31520 this.updateExpandIcon(true);
31523 if(bulkRender === true) {
31524 targetNode.appendChild(this.wrap);
31530 renderElements : function(n, a, targetNode, bulkRender){
31532 this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
31534 var cb = Ext.isBoolean(a.checked),
31536 href = a.href ? a.href : Ext.isGecko ? "" : "#",
31537 buf = ['<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf x-unselectable ', a.cls,'" unselectable="on">',
31538 '<span class="x-tree-node-indent">',this.indentMarkup,"</span>",
31539 '<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow" />',
31540 '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon',(a.icon ? " x-tree-node-inline-icon" : ""),(a.iconCls ? " "+a.iconCls : ""),'" unselectable="on" />',
31541 cb ? ('<input class="x-tree-node-cb" type="checkbox" ' + (a.checked ? 'checked="checked" />' : '/>')) : '',
31542 '<a hidefocus="on" class="x-tree-node-anchor" href="',href,'" tabIndex="1" ',
31543 a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "", '><span unselectable="on">',n.text,"</span></a></div>",
31544 '<ul class="x-tree-node-ct" style="display:none;"></ul>',
31547 if(bulkRender !== true && n.nextSibling && (nel = n.nextSibling.ui.getEl())){
31548 this.wrap = Ext.DomHelper.insertHtml("beforeBegin", nel, buf);
31550 this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf);
31553 this.elNode = this.wrap.childNodes[0];
31554 this.ctNode = this.wrap.childNodes[1];
31555 var cs = this.elNode.childNodes;
31556 this.indentNode = cs[0];
31557 this.ecNode = cs[1];
31558 this.iconNode = cs[2];
31561 this.checkbox = cs[3];
31563 this.checkbox.defaultChecked = this.checkbox.checked;
31566 this.anchor = cs[index];
31567 this.textNode = cs[index].firstChild;
31571 getAnchor : function(){
31572 return this.anchor;
31576 getTextEl : function(){
31577 return this.textNode;
31581 getIconEl : function(){
31582 return this.iconNode;
31586 isChecked : function(){
31587 return this.checkbox ? this.checkbox.checked : false;
31591 updateExpandIcon : function(){
31596 cls = n.isLast() ? "x-tree-elbow-end" : "x-tree-elbow",
31597 hasChild = n.hasChildNodes();
31598 if(hasChild || n.attributes.expandable){
31601 c1 = "x-tree-node-collapsed";
31602 c2 = "x-tree-node-expanded";
31605 c1 = "x-tree-node-expanded";
31606 c2 = "x-tree-node-collapsed";
31609 this.removeClass("x-tree-node-leaf");
31610 this.wasLeaf = false;
31612 if(this.c1 != c1 || this.c2 != c2){
31613 Ext.fly(this.elNode).replaceClass(c1, c2);
31614 this.c1 = c1; this.c2 = c2;
31618 Ext.fly(this.elNode).replaceClass("x-tree-node-expanded", "x-tree-node-leaf");
31621 this.wasLeaf = true;
31624 var ecc = "x-tree-ec-icon "+cls;
31625 if(this.ecc != ecc){
31626 this.ecNode.className = ecc;
31633 onIdChange: function(id){
31635 this.elNode.setAttribute('ext:tree-node-id', id);
31640 getChildIndent : function(){
31641 if(!this.childIndent){
31645 if(!p.isRoot || (p.isRoot && p.ownerTree.rootVisible)){
31647 buf.unshift('<img src="'+this.emptyIcon+'" class="x-tree-elbow-line" />');
31649 buf.unshift('<img src="'+this.emptyIcon+'" class="x-tree-icon" />');
31654 this.childIndent = buf.join("");
31656 return this.childIndent;
31660 renderIndent : function(){
31663 p = this.node.parentNode;
31665 indent = p.ui.getChildIndent();
31667 if(this.indentMarkup != indent){
31668 this.indentNode.innerHTML = indent;
31669 this.indentMarkup = indent;
31671 this.updateExpandIcon();
31675 destroy : function(){
31677 Ext.dd.Registry.unregister(this.elNode.id);
31680 Ext.each(['textnode', 'anchor', 'checkbox', 'indentNode', 'ecNode', 'iconNode', 'elNode', 'ctNode', 'wrap', 'holder'], function(el){
31682 Ext.fly(this[el]).remove();
31691 Ext.tree.RootTreeNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
31693 render : function(){
31694 if(!this.rendered){
31695 var targetNode = this.node.ownerTree.innerCt.dom;
31696 this.node.expanded = true;
31697 targetNode.innerHTML = '<div class="x-tree-root-node"></div>';
31698 this.wrap = this.ctNode = targetNode.firstChild;
31701 collapse : Ext.emptyFn,
31702 expand : Ext.emptyFn
31704 Ext.tree.TreeLoader = function(config){
31705 this.baseParams = {};
31706 Ext.apply(this, config);
31716 Ext.tree.TreeLoader.superclass.constructor.call(this);
31717 if(Ext.isString(this.paramOrder)){
31718 this.paramOrder = this.paramOrder.split(/[\s,|]/);
31722 Ext.extend(Ext.tree.TreeLoader, Ext.util.Observable, {
31733 clearOnLoad : true,
31736 paramOrder: undefined,
31739 paramsAsHash: false,
31742 nodeParameter: 'node',
31745 directFn : undefined,
31748 load : function(node, callback, scope){
31749 if(this.clearOnLoad){
31750 while(node.firstChild){
31751 node.removeChild(node.firstChild);
31754 if(this.doPreload(node)){
31755 this.runCallback(callback, scope || node, [node]);
31756 }else if(this.directFn || this.dataUrl || this.url){
31757 this.requestData(node, callback, scope || node);
31761 doPreload : function(node){
31762 if(node.attributes.children){
31763 if(node.childNodes.length < 1){
31764 var cs = node.attributes.children;
31765 node.beginUpdate();
31766 for(var i = 0, len = cs.length; i < len; i++){
31767 var cn = node.appendChild(this.createNode(cs[i]));
31768 if(this.preloadChildren){
31769 this.doPreload(cn);
31779 getParams: function(node){
31780 var buf = [], bp = this.baseParams;
31784 if(this.paramOrder){
31785 for(var i = 0, len = this.paramOrder.length; i < len; i++){
31786 buf.push(bp[this.paramOrder[i]]);
31788 }else if(this.paramsAsHash){
31794 var o = Ext.apply({}, bp);
31795 o[this.nodeParameter] = node.id;
31800 requestData : function(node, callback, scope){
31801 if(this.fireEvent("beforeload", this, node, callback) !== false){
31803 var args = this.getParams(node);
31804 args.push(this.processDirectResponse.createDelegate(this, [{callback: callback, node: node, scope: scope}], true));
31805 this.directFn.apply(window, args);
31807 this.transId = Ext.Ajax.request({
31808 method:this.requestMethod,
31809 url: this.dataUrl||this.url,
31810 success: this.handleResponse,
31811 failure: this.handleFailure,
31813 argument: {callback: callback, node: node, scope: scope},
31814 params: this.getParams(node)
31820 this.runCallback(callback, scope || node, []);
31824 processDirectResponse: function(result, response, args){
31825 if(response.status){
31826 this.handleResponse({
31827 responseData: Ext.isArray(result) ? result : null,
31828 responseText: result,
31832 this.handleFailure({
31839 runCallback: function(cb, scope, args){
31840 if(Ext.isFunction(cb)){
31841 cb.apply(scope, args);
31845 isLoading : function(){
31846 return !!this.transId;
31849 abort : function(){
31850 if(this.isLoading()){
31851 Ext.Ajax.abort(this.transId);
31856 createNode : function(attr){
31858 if(this.baseAttrs){
31859 Ext.applyIf(attr, this.baseAttrs);
31861 if(this.applyLoader !== false && !attr.loader){
31862 attr.loader = this;
31864 if(Ext.isString(attr.uiProvider)){
31865 attr.uiProvider = this.uiProviders[attr.uiProvider] || eval(attr.uiProvider);
31868 return new Ext.tree.TreePanel.nodeTypes[attr.nodeType](attr);
31871 new Ext.tree.TreeNode(attr) :
31872 new Ext.tree.AsyncTreeNode(attr);
31876 processResponse : function(response, node, callback, scope){
31877 var json = response.responseText;
31879 var o = response.responseData || Ext.decode(json);
31880 node.beginUpdate();
31881 for(var i = 0, len = o.length; i < len; i++){
31882 var n = this.createNode(o[i]);
31884 node.appendChild(n);
31888 this.runCallback(callback, scope || node, [node]);
31890 this.handleFailure(response);
31894 handleResponse : function(response){
31895 this.transId = false;
31896 var a = response.argument;
31897 this.processResponse(response, a.node, a.callback, a.scope);
31898 this.fireEvent("load", this, a.node, response);
31901 handleFailure : function(response){
31902 this.transId = false;
31903 var a = response.argument;
31904 this.fireEvent("loadexception", this, a.node, response);
31905 this.runCallback(a.callback, a.scope || a.node, [a.node]);
31908 destroy : function(){
31909 this.purgeListeners();
31912 Ext.tree.TreeFilter = function(tree, config){
31914 this.filtered = {};
31915 Ext.apply(this, config);
31918 Ext.tree.TreeFilter.prototype = {
31925 filter : function(value, attr, startNode){
31926 attr = attr || "text";
31928 if(typeof value == "string"){
31929 var vlen = value.length;
31931 if(vlen == 0 && this.clearBlank){
31935 value = value.toLowerCase();
31937 return n.attributes[attr].substr(0, vlen).toLowerCase() == value;
31939 }else if(value.exec){
31941 return value.test(n.attributes[attr]);
31944 throw 'Illegal filter type, must be string or regex';
31946 this.filterBy(f, null, startNode);
31950 filterBy : function(fn, scope, startNode){
31951 startNode = startNode || this.tree.root;
31952 if(this.autoClear){
31955 var af = this.filtered, rv = this.reverse;
31956 var f = function(n){
31957 if(n == startNode){
31963 var m = fn.call(scope || n, n);
31971 startNode.cascade(f);
31974 if(typeof id != "function"){
31976 if(n && n.parentNode){
31977 n.parentNode.removeChild(n);
31985 clear : function(){
31987 var af = this.filtered;
31989 if(typeof id != "function"){
31996 this.filtered = {};
32000 Ext.tree.TreeSorter = function(tree, config){
32008 Ext.apply(this, config);
32009 tree.on("beforechildrenrendered", this.doSort, this);
32010 tree.on("append", this.updateSort, this);
32011 tree.on("insert", this.updateSort, this);
32012 tree.on("textchange", this.updateSortParent, this);
32014 var dsc = this.dir && this.dir.toLowerCase() == "desc";
32015 var p = this.property || "text";
32016 var sortType = this.sortType;
32017 var fs = this.folderSort;
32018 var cs = this.caseSensitive === true;
32019 var leafAttr = this.leafAttr || 'leaf';
32021 this.sortFn = function(n1, n2){
32023 if(n1.attributes[leafAttr] && !n2.attributes[leafAttr]){
32026 if(!n1.attributes[leafAttr] && n2.attributes[leafAttr]){
32030 var v1 = sortType ? sortType(n1.attributes[p]) : (cs ? n1.attributes[p] : n1.attributes[p].toUpperCase());
32031 var v2 = sortType ? sortType(n2.attributes[p]) : (cs ? n2.attributes[p] : n2.attributes[p].toUpperCase());
32033 return dsc ? +1 : -1;
32035 return dsc ? -1 : +1;
32042 Ext.tree.TreeSorter.prototype = {
32043 doSort : function(node){
32044 node.sort(this.sortFn);
32047 compareNodes : function(n1, n2){
32048 return (n1.text.toUpperCase() > n2.text.toUpperCase() ? 1 : -1);
32051 updateSort : function(tree, node){
32052 if(node.childrenRendered){
32053 this.doSort.defer(1, this, [node]);
32057 updateSortParent : function(node){
32058 var p = node.parentNode;
32059 if(p && p.childrenRendered){
32060 this.doSort.defer(1, this, [p]);
32064 if(Ext.dd.DropZone){
32066 Ext.tree.TreeDropZone = function(tree, config){
32068 this.allowParentInsert = config.allowParentInsert || false;
32070 this.allowContainerDrop = config.allowContainerDrop || false;
32072 this.appendOnly = config.appendOnly || false;
32074 Ext.tree.TreeDropZone.superclass.constructor.call(this, tree.getTreeEl(), config);
32078 this.dragOverData = {};
32080 this.lastInsertClass = "x-tree-no-status";
32083 Ext.extend(Ext.tree.TreeDropZone, Ext.dd.DropZone, {
32085 ddGroup : "TreeDD",
32088 expandDelay : 1000,
32091 expandNode : function(node){
32092 if(node.hasChildNodes() && !node.isExpanded()){
32093 node.expand(false, null, this.triggerCacheRefresh.createDelegate(this));
32098 queueExpand : function(node){
32099 this.expandProcId = this.expandNode.defer(this.expandDelay, this, [node]);
32103 cancelExpand : function(){
32104 if(this.expandProcId){
32105 clearTimeout(this.expandProcId);
32106 this.expandProcId = false;
32111 isValidDropPoint : function(n, pt, dd, e, data){
32112 if(!n || !data){ return false; }
32113 var targetNode = n.node;
32114 var dropNode = data.node;
32116 if(!(targetNode && targetNode.isTarget && pt)){
32119 if(pt == "append" && targetNode.allowChildren === false){
32122 if((pt == "above" || pt == "below") && (targetNode.parentNode && targetNode.parentNode.allowChildren === false)){
32125 if(dropNode && (targetNode == dropNode || dropNode.contains(targetNode))){
32129 var overEvent = this.dragOverData;
32130 overEvent.tree = this.tree;
32131 overEvent.target = targetNode;
32132 overEvent.data = data;
32133 overEvent.point = pt;
32134 overEvent.source = dd;
32135 overEvent.rawEvent = e;
32136 overEvent.dropNode = dropNode;
32137 overEvent.cancel = false;
32138 var result = this.tree.fireEvent("nodedragover", overEvent);
32139 return overEvent.cancel === false && result !== false;
32143 getDropPoint : function(e, n, dd){
32146 return tn.allowChildren !== false ? "append" : false;
32148 var dragEl = n.ddel;
32149 var t = Ext.lib.Dom.getY(dragEl), b = t + dragEl.offsetHeight;
32150 var y = Ext.lib.Event.getPageY(e);
32151 var noAppend = tn.allowChildren === false || tn.isLeaf();
32152 if(this.appendOnly || tn.parentNode.allowChildren === false){
32153 return noAppend ? false : "append";
32155 var noBelow = false;
32156 if(!this.allowParentInsert){
32157 noBelow = tn.hasChildNodes() && tn.isExpanded();
32159 var q = (b - t) / (noAppend ? 2 : 3);
32160 if(y >= t && y < (t + q)){
32162 }else if(!noBelow && (noAppend || y >= b-q && y <= b)){
32170 onNodeEnter : function(n, dd, e, data){
32171 this.cancelExpand();
32174 onContainerOver : function(dd, e, data) {
32175 if (this.allowContainerDrop && this.isValidDropPoint({ ddel: this.tree.getRootNode().ui.elNode, node: this.tree.getRootNode() }, "append", dd, e, data)) {
32176 return this.dropAllowed;
32178 return this.dropNotAllowed;
32182 onNodeOver : function(n, dd, e, data){
32183 var pt = this.getDropPoint(e, n, dd);
32187 if(!this.expandProcId && pt == "append" && node.hasChildNodes() && !n.node.isExpanded()){
32188 this.queueExpand(node);
32189 }else if(pt != "append"){
32190 this.cancelExpand();
32194 var returnCls = this.dropNotAllowed;
32195 if(this.isValidDropPoint(n, pt, dd, e, data)){
32200 returnCls = n.node.isFirst() ? "x-tree-drop-ok-above" : "x-tree-drop-ok-between";
32201 cls = "x-tree-drag-insert-above";
32202 }else if(pt == "below"){
32203 returnCls = n.node.isLast() ? "x-tree-drop-ok-below" : "x-tree-drop-ok-between";
32204 cls = "x-tree-drag-insert-below";
32206 returnCls = "x-tree-drop-ok-append";
32207 cls = "x-tree-drag-append";
32209 if(this.lastInsertClass != cls){
32210 Ext.fly(el).replaceClass(this.lastInsertClass, cls);
32211 this.lastInsertClass = cls;
32219 onNodeOut : function(n, dd, e, data){
32220 this.cancelExpand();
32221 this.removeDropIndicators(n);
32225 onNodeDrop : function(n, dd, e, data){
32226 var point = this.getDropPoint(e, n, dd);
32227 var targetNode = n.node;
32228 targetNode.ui.startDrop();
32229 if(!this.isValidDropPoint(n, point, dd, e, data)){
32230 targetNode.ui.endDrop();
32234 var dropNode = data.node || (dd.getTreeNode ? dd.getTreeNode(data, targetNode, point, e) : null);
32235 return this.processDrop(targetNode, data, point, dd, e, dropNode);
32238 onContainerDrop : function(dd, e, data){
32239 if (this.allowContainerDrop && this.isValidDropPoint({ ddel: this.tree.getRootNode().ui.elNode, node: this.tree.getRootNode() }, "append", dd, e, data)) {
32240 var targetNode = this.tree.getRootNode();
32241 targetNode.ui.startDrop();
32242 var dropNode = data.node || (dd.getTreeNode ? dd.getTreeNode(data, targetNode, 'append', e) : null);
32243 return this.processDrop(targetNode, data, 'append', dd, e, dropNode);
32249 processDrop: function(target, data, point, dd, e, dropNode){
32257 dropNode: dropNode,
32261 var retval = this.tree.fireEvent("beforenodedrop", dropEvent);
32262 if(retval === false || dropEvent.cancel === true || !dropEvent.dropNode){
32263 target.ui.endDrop();
32264 return dropEvent.dropStatus;
32267 target = dropEvent.target;
32268 if(point == 'append' && !target.isExpanded()){
32269 target.expand(false, null, function(){
32270 this.completeDrop(dropEvent);
32271 }.createDelegate(this));
32273 this.completeDrop(dropEvent);
32279 completeDrop : function(de){
32280 var ns = de.dropNode, p = de.point, t = de.target;
32281 if(!Ext.isArray(ns)){
32285 for(var i = 0, len = ns.length; i < len; i++){
32288 t.parentNode.insertBefore(n, t);
32289 }else if(p == "below"){
32290 t.parentNode.insertBefore(n, t.nextSibling);
32296 if(Ext.enableFx && this.tree.hlDrop){
32300 this.tree.fireEvent("nodedrop", de);
32304 afterNodeMoved : function(dd, data, e, targetNode, dropNode){
32305 if(Ext.enableFx && this.tree.hlDrop){
32306 dropNode.ui.focus();
32307 dropNode.ui.highlight();
32309 this.tree.fireEvent("nodedrop", this.tree, targetNode, data, dd, e);
32313 getTree : function(){
32318 removeDropIndicators : function(n){
32321 Ext.fly(el).removeClass([
32322 "x-tree-drag-insert-above",
32323 "x-tree-drag-insert-below",
32324 "x-tree-drag-append"]);
32325 this.lastInsertClass = "_noclass";
32330 beforeDragDrop : function(target, e, id){
32331 this.cancelExpand();
32336 afterRepair : function(data){
32337 if(data && Ext.enableFx){
32338 data.node.ui.highlight();
32345 if(Ext.dd.DragZone){
32346 Ext.tree.TreeDragZone = function(tree, config){
32347 Ext.tree.TreeDragZone.superclass.constructor.call(this, tree.innerCt, config);
32352 Ext.extend(Ext.tree.TreeDragZone, Ext.dd.DragZone, {
32354 ddGroup : "TreeDD",
32357 onBeforeDrag : function(data, e){
32359 return n && n.draggable && !n.disabled;
32363 onInitDrag : function(e){
32364 var data = this.dragData;
32365 this.tree.getSelectionModel().select(data.node);
32366 this.tree.eventModel.disable();
32367 this.proxy.update("");
32368 data.node.ui.appendDDGhost(this.proxy.ghost.dom);
32369 this.tree.fireEvent("startdrag", this.tree, data.node, e);
32373 getRepairXY : function(e, data){
32374 return data.node.ui.getDDRepairXY();
32378 onEndDrag : function(data, e){
32379 this.tree.eventModel.enable.defer(100, this.tree.eventModel);
32380 this.tree.fireEvent("enddrag", this.tree, data.node, e);
32384 onValidDrop : function(dd, e, id){
32385 this.tree.fireEvent("dragdrop", this.tree, this.dragData.node, dd, e);
32390 beforeInvalidDrop : function(e, id){
32392 var sm = this.tree.getSelectionModel();
32393 sm.clearSelections();
32394 sm.select(this.dragData.node);
32398 afterRepair : function(){
32399 if (Ext.enableFx && this.tree.hlDrop) {
32400 Ext.Element.fly(this.dragData.ddel).highlight(this.hlColor || "c3daf9");
32402 this.dragging = false;
32406 Ext.tree.TreeEditor = function(tree, fc, config){
32408 var field = fc.events ? fc : new Ext.form.TextField(fc);
32409 Ext.tree.TreeEditor.superclass.constructor.call(this, field, config);
32413 if(!tree.rendered){
32414 tree.on('render', this.initEditor, this);
32416 this.initEditor(tree);
32420 Ext.extend(Ext.tree.TreeEditor, Ext.Editor, {
32428 cls: "x-small-editor x-tree-editor",
32438 initEditor : function(tree){
32441 beforeclick: this.beforeNodeClick,
32442 dblclick: this.onNodeDblClick
32446 complete: this.updateNode,
32447 beforestartedit: this.fitToTree,
32448 specialkey: this.onSpecialKey
32450 this.on('startedit', this.bindScroll, this, {delay:10});
32454 fitToTree : function(ed, el){
32455 var td = this.tree.getTreeEl().dom, nd = el.dom;
32456 if(td.scrollLeft > nd.offsetLeft){
32457 td.scrollLeft = nd.offsetLeft;
32461 (td.clientWidth > 20 ? td.clientWidth : td.offsetWidth) - Math.max(0, nd.offsetLeft-td.scrollLeft) - 5);
32462 this.setSize(w, '');
32466 triggerEdit : function(node, defer){
32467 this.completeEdit();
32468 if(node.attributes.editable !== false){
32470 this.editNode = node;
32471 if(this.tree.autoScroll){
32472 Ext.fly(node.ui.getEl()).scrollIntoView(this.tree.body);
32474 var value = node.text || '';
32475 if (!Ext.isGecko && Ext.isEmpty(node.text)){
32476 node.setText(' ');
32478 this.autoEditTimer = this.startEdit.defer(this.editDelay, this, [node.ui.textNode, value]);
32484 bindScroll : function(){
32485 this.tree.getTreeEl().on('scroll', this.cancelEdit, this);
32489 beforeNodeClick : function(node, e){
32490 clearTimeout(this.autoEditTimer);
32491 if(this.tree.getSelectionModel().isSelected(node)){
32493 return this.triggerEdit(node);
32497 onNodeDblClick : function(node, e){
32498 clearTimeout(this.autoEditTimer);
32502 updateNode : function(ed, value){
32503 this.tree.getTreeEl().un('scroll', this.cancelEdit, this);
32504 this.editNode.setText(value);
32508 onHide : function(){
32509 Ext.tree.TreeEditor.superclass.onHide.call(this);
32511 this.editNode.ui.focus.defer(50, this.editNode.ui);
32516 onSpecialKey : function(field, e){
32517 var k = e.getKey();
32521 }else if(k == e.ENTER && !e.hasModifier()){
32523 this.completeEdit();
32527 onDestroy : function(){
32528 clearTimeout(this.autoEditTimer);
32529 Ext.tree.TreeEditor.superclass.onDestroy.call(this);
32530 var tree = this.tree;
32531 tree.un('beforeclick', this.beforeNodeClick, this);
32532 tree.un('dblclick', this.onNodeDblClick, this);
32536 var swfobject = function() {
32538 var UNDEF = "undefined",
32540 SHOCKWAVE_FLASH = "Shockwave Flash",
32541 SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
32542 FLASH_MIME_TYPE = "application/x-shockwave-flash",
32543 EXPRESS_INSTALL_ID = "SWFObjectExprInst",
32544 ON_READY_STATE_CHANGE = "onreadystatechange",
32551 domLoadFnArr = [main],
32556 storedAltContentId,
32559 isDomLoaded = false,
32560 isExpressInstallActive = false,
32562 dynamicStylesheetMedia,
32563 autoHideShow = true,
32567 var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
32568 u = nav.userAgent.toLowerCase(),
32569 p = nav.platform.toLowerCase(),
32570 windows = p ? /win/.test(p) : /win/.test(u),
32571 mac = p ? /mac/.test(p) : /mac/.test(u),
32572 webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false,
32574 playerVersion = [0,0,0],
32576 if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
32577 d = nav.plugins[SHOCKWAVE_FLASH].description;
32578 if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) {
32581 d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
32582 playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
32583 playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
32584 playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0;
32587 else if (typeof win.ActiveXObject != UNDEF) {
32589 var a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
32591 d = a.GetVariable("$version");
32594 d = d.split(" ")[1].split(",");
32595 playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
32601 return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac };
32605 onDomLoad = function() {
32606 if (!ua.w3) { return; }
32607 if ((typeof doc.readyState != UNDEF && doc.readyState == "complete") || (typeof doc.readyState == UNDEF && (doc.getElementsByTagName("body")[0] || doc.body))) {
32608 callDomLoadFunctions();
32610 if (!isDomLoaded) {
32611 if (typeof doc.addEventListener != UNDEF) {
32612 doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, false);
32614 if (ua.ie && ua.win) {
32615 doc.attachEvent(ON_READY_STATE_CHANGE, function() {
32616 if (doc.readyState == "complete") {
32617 doc.detachEvent(ON_READY_STATE_CHANGE, arguments.callee);
32618 callDomLoadFunctions();
32623 if (isDomLoaded) { return; }
32625 doc.documentElement.doScroll("left");
32628 setTimeout(arguments.callee, 0);
32631 callDomLoadFunctions();
32637 if (isDomLoaded) { return; }
32638 if (!/loaded|complete/.test(doc.readyState)) {
32639 setTimeout(arguments.callee, 0);
32642 callDomLoadFunctions();
32645 addLoadEvent(callDomLoadFunctions);
32649 function callDomLoadFunctions() {
32650 if (isDomLoaded) { return; }
32652 var t = doc.getElementsByTagName("body")[0].appendChild(createElement("span"));
32653 t.parentNode.removeChild(t);
32655 catch (e) { return; }
32656 isDomLoaded = true;
32657 var dl = domLoadFnArr.length;
32658 for (var i = 0; i < dl; i++) {
32663 function addDomLoadEvent(fn) {
32668 domLoadFnArr[domLoadFnArr.length] = fn;
32673 function addLoadEvent(fn) {
32674 if (typeof win.addEventListener != UNDEF) {
32675 win.addEventListener("load", fn, false);
32677 else if (typeof doc.addEventListener != UNDEF) {
32678 doc.addEventListener("load", fn, false);
32680 else if (typeof win.attachEvent != UNDEF) {
32681 addListener(win, "onload", fn);
32683 else if (typeof win.onload == "function") {
32684 var fnOld = win.onload;
32685 win.onload = function() {
32698 testPlayerVersion();
32706 function testPlayerVersion() {
32707 var b = doc.getElementsByTagName("body")[0];
32708 var o = createElement(OBJECT);
32709 o.setAttribute("type", FLASH_MIME_TYPE);
32710 var t = b.appendChild(o);
32714 if (typeof t.GetVariable != UNDEF) {
32715 var d = t.GetVariable("$version");
32717 d = d.split(" ")[1].split(",");
32718 ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
32721 else if (counter < 10) {
32723 setTimeout(arguments.callee, 10);
32737 function matchVersions() {
32738 var rl = regObjArr.length;
32740 for (var i = 0; i < rl; i++) {
32741 var id = regObjArr[i].id;
32742 var cb = regObjArr[i].callbackFn;
32743 var cbObj = {success:false, id:id};
32744 if (ua.pv[0] > 0) {
32745 var obj = getElementById(id);
32747 if (hasPlayerVersion(regObjArr[i].swfVersion) && !(ua.wk && ua.wk < 312)) {
32748 setVisibility(id, true);
32750 cbObj.success = true;
32751 cbObj.ref = getObjectById(id);
32755 else if (regObjArr[i].expressInstall && canExpressInstall()) {
32757 att.data = regObjArr[i].expressInstall;
32758 att.width = obj.getAttribute("width") || "0";
32759 att.height = obj.getAttribute("height") || "0";
32760 if (obj.getAttribute("class")) { att.styleclass = obj.getAttribute("class"); }
32761 if (obj.getAttribute("align")) { att.align = obj.getAttribute("align"); }
32764 var p = obj.getElementsByTagName("param");
32766 for (var j = 0; j < pl; j++) {
32767 if (p[j].getAttribute("name").toLowerCase() != "movie") {
32768 par[p[j].getAttribute("name")] = p[j].getAttribute("value");
32771 showExpressInstall(att, par, id, cb);
32774 displayAltContent(obj);
32775 if (cb) { cb(cbObj); }
32780 setVisibility(id, true);
32782 var o = getObjectById(id);
32783 if (o && typeof o.SetVariable != UNDEF) {
32784 cbObj.success = true;
32794 function getObjectById(objectIdStr) {
32796 var o = getElementById(objectIdStr);
32797 if (o && o.nodeName == "OBJECT") {
32798 if (typeof o.SetVariable != UNDEF) {
32802 var n = o.getElementsByTagName(OBJECT)[0];
32812 function canExpressInstall() {
32813 return !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac) && !(ua.wk && ua.wk < 312);
32817 function showExpressInstall(att, par, replaceElemIdStr, callbackFn) {
32818 isExpressInstallActive = true;
32819 storedCallbackFn = callbackFn || null;
32820 storedCallbackObj = {success:false, id:replaceElemIdStr};
32821 var obj = getElementById(replaceElemIdStr);
32823 if (obj.nodeName == "OBJECT") {
32824 storedAltContent = abstractAltContent(obj);
32825 storedAltContentId = null;
32828 storedAltContent = obj;
32829 storedAltContentId = replaceElemIdStr;
32831 att.id = EXPRESS_INSTALL_ID;
32832 if (typeof att.width == UNDEF || (!/%$/.test(att.width) && parseInt(att.width, 10) < 310)) { att.width = "310"; }
32833 if (typeof att.height == UNDEF || (!/%$/.test(att.height) && parseInt(att.height, 10) < 137)) { att.height = "137"; }
32834 doc.title = doc.title.slice(0, 47) + " - Flash Player Installation";
32835 var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn",
32836 fv = "MMredirectURL=" + win.location.toString().replace(/&/g,"%26") + "&MMplayerType=" + pt + "&MMdoctitle=" + doc.title;
32837 if (typeof par.flashvars != UNDEF) {
32838 par.flashvars += "&" + fv;
32841 par.flashvars = fv;
32845 if (ua.ie && ua.win && obj.readyState != 4) {
32846 var newObj = createElement("div");
32847 replaceElemIdStr += "SWFObjectNew";
32848 newObj.setAttribute("id", replaceElemIdStr);
32849 obj.parentNode.insertBefore(newObj, obj);
32850 obj.style.display = "none";
32852 if (obj.readyState == 4) {
32853 obj.parentNode.removeChild(obj);
32856 setTimeout(arguments.callee, 10);
32860 createSWF(att, par, replaceElemIdStr);
32865 function displayAltContent(obj) {
32866 if (ua.ie && ua.win && obj.readyState != 4) {
32869 var el = createElement("div");
32870 obj.parentNode.insertBefore(el, obj);
32871 el.parentNode.replaceChild(abstractAltContent(obj), el);
32872 obj.style.display = "none";
32874 if (obj.readyState == 4) {
32875 obj.parentNode.removeChild(obj);
32878 setTimeout(arguments.callee, 10);
32883 obj.parentNode.replaceChild(abstractAltContent(obj), obj);
32887 function abstractAltContent(obj) {
32888 var ac = createElement("div");
32889 if (ua.win && ua.ie) {
32890 ac.innerHTML = obj.innerHTML;
32893 var nestedObj = obj.getElementsByTagName(OBJECT)[0];
32895 var c = nestedObj.childNodes;
32898 for (var i = 0; i < cl; i++) {
32899 if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) {
32900 ac.appendChild(c[i].cloneNode(true));
32910 function createSWF(attObj, parObj, id) {
32911 var r, el = getElementById(id);
32912 if (ua.wk && ua.wk < 312) { return r; }
32914 if (typeof attObj.id == UNDEF) {
32917 if (ua.ie && ua.win) {
32919 for (var i in attObj) {
32920 if (attObj[i] != Object.prototype[i]) {
32921 if (i.toLowerCase() == "data") {
32922 parObj.movie = attObj[i];
32924 else if (i.toLowerCase() == "styleclass") {
32925 att += ' class="' + attObj[i] + '"';
32927 else if (i.toLowerCase() != "classid") {
32928 att += ' ' + i + '="' + attObj[i] + '"';
32933 for (var j in parObj) {
32934 if (parObj[j] != Object.prototype[j]) {
32935 par += '<param name="' + j + '" value="' + parObj[j] + '" />';
32938 el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + '>' + par + '</object>';
32939 objIdArr[objIdArr.length] = attObj.id;
32940 r = getElementById(attObj.id);
32943 var o = createElement(OBJECT);
32944 o.setAttribute("type", FLASH_MIME_TYPE);
32945 for (var m in attObj) {
32946 if (attObj[m] != Object.prototype[m]) {
32947 if (m.toLowerCase() == "styleclass") {
32948 o.setAttribute("class", attObj[m]);
32950 else if (m.toLowerCase() != "classid") {
32951 o.setAttribute(m, attObj[m]);
32955 for (var n in parObj) {
32956 if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") {
32957 createObjParam(o, n, parObj[n]);
32960 el.parentNode.replaceChild(o, el);
32967 function createObjParam(el, pName, pValue) {
32968 var p = createElement("param");
32969 p.setAttribute("name", pName);
32970 p.setAttribute("value", pValue);
32975 function removeSWF(id) {
32976 var obj = getElementById(id);
32977 if (obj && obj.nodeName == "OBJECT") {
32978 if (ua.ie && ua.win) {
32979 obj.style.display = "none";
32981 if (obj.readyState == 4) {
32982 removeObjectInIE(id);
32985 setTimeout(arguments.callee, 10);
32990 obj.parentNode.removeChild(obj);
32995 function removeObjectInIE(id) {
32996 var obj = getElementById(id);
32998 for (var i in obj) {
32999 if (typeof obj[i] == "function") {
33003 obj.parentNode.removeChild(obj);
33008 function getElementById(id) {
33011 el = doc.getElementById(id);
33017 function createElement(el) {
33018 return doc.createElement(el);
33022 function addListener(target, eventType, fn) {
33023 target.attachEvent(eventType, fn);
33024 listenersArr[listenersArr.length] = [target, eventType, fn];
33028 function hasPlayerVersion(rv) {
33029 var pv = ua.pv, v = rv.split(".");
33030 v[0] = parseInt(v[0], 10);
33031 v[1] = parseInt(v[1], 10) || 0;
33032 v[2] = parseInt(v[2], 10) || 0;
33033 return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
33037 function createCSS(sel, decl, media, newStyle) {
33038 if (ua.ie && ua.mac) { return; }
33039 var h = doc.getElementsByTagName("head")[0];
33040 if (!h) { return; }
33041 var m = (media && typeof media == "string") ? media : "screen";
33043 dynamicStylesheet = null;
33044 dynamicStylesheetMedia = null;
33046 if (!dynamicStylesheet || dynamicStylesheetMedia != m) {
33048 var s = createElement("style");
33049 s.setAttribute("type", "text/css");
33050 s.setAttribute("media", m);
33051 dynamicStylesheet = h.appendChild(s);
33052 if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) {
33053 dynamicStylesheet = doc.styleSheets[doc.styleSheets.length - 1];
33055 dynamicStylesheetMedia = m;
33058 if (ua.ie && ua.win) {
33059 if (dynamicStylesheet && typeof dynamicStylesheet.addRule == OBJECT) {
33060 dynamicStylesheet.addRule(sel, decl);
33064 if (dynamicStylesheet && typeof doc.createTextNode != UNDEF) {
33065 dynamicStylesheet.appendChild(doc.createTextNode(sel + " {" + decl + "}"));
33070 function setVisibility(id, isVisible) {
33071 if (!autoHideShow) { return; }
33072 var v = isVisible ? "visible" : "hidden";
33073 if (isDomLoaded && getElementById(id)) {
33074 getElementById(id).style.visibility = v;
33077 createCSS("#" + id, "visibility:" + v);
33082 function urlEncodeIfNecessary(s) {
33083 var regex = /[\\\"<>\.;]/;
33084 var hasBadChars = regex.exec(s) != null;
33085 return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s;
33089 var cleanup = function() {
33090 if (ua.ie && ua.win) {
33091 window.attachEvent("onunload", function() {
33093 var ll = listenersArr.length;
33094 for (var i = 0; i < ll; i++) {
33095 listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]);
33098 var il = objIdArr.length;
33099 for (var j = 0; j < il; j++) {
33100 removeSWF(objIdArr[j]);
33103 for (var k in ua) {
33107 for (var l in swfobject) {
33108 swfobject[l] = null;
33117 registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr, callbackFn) {
33118 if (ua.w3 && objectIdStr && swfVersionStr) {
33120 regObj.id = objectIdStr;
33121 regObj.swfVersion = swfVersionStr;
33122 regObj.expressInstall = xiSwfUrlStr;
33123 regObj.callbackFn = callbackFn;
33124 regObjArr[regObjArr.length] = regObj;
33125 setVisibility(objectIdStr, false);
33127 else if (callbackFn) {
33128 callbackFn({success:false, id:objectIdStr});
33132 getObjectById: function(objectIdStr) {
33134 return getObjectById(objectIdStr);
33138 embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) {
33139 var callbackObj = {success:false, id:replaceElemIdStr};
33140 if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) {
33141 setVisibility(replaceElemIdStr, false);
33142 addDomLoadEvent(function() {
33146 if (attObj && typeof attObj === OBJECT) {
33147 for (var i in attObj) {
33148 att[i] = attObj[i];
33151 att.data = swfUrlStr;
33152 att.width = widthStr;
33153 att.height = heightStr;
33155 if (parObj && typeof parObj === OBJECT) {
33156 for (var j in parObj) {
33157 par[j] = parObj[j];
33160 if (flashvarsObj && typeof flashvarsObj === OBJECT) {
33161 for (var k in flashvarsObj) {
33162 if (typeof par.flashvars != UNDEF) {
33163 par.flashvars += "&" + k + "=" + flashvarsObj[k];
33166 par.flashvars = k + "=" + flashvarsObj[k];
33170 if (hasPlayerVersion(swfVersionStr)) {
33171 var obj = createSWF(att, par, replaceElemIdStr);
33172 if (att.id == replaceElemIdStr) {
33173 setVisibility(replaceElemIdStr, true);
33175 callbackObj.success = true;
33176 callbackObj.ref = obj;
33178 else if (xiSwfUrlStr && canExpressInstall()) {
33179 att.data = xiSwfUrlStr;
33180 showExpressInstall(att, par, replaceElemIdStr, callbackFn);
33184 setVisibility(replaceElemIdStr, true);
33186 if (callbackFn) { callbackFn(callbackObj); }
33189 else if (callbackFn) { callbackFn(callbackObj); }
33192 switchOffAutoHideShow: function() {
33193 autoHideShow = false;
33198 getFlashPlayerVersion: function() {
33199 return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] };
33202 hasFlashPlayerVersion: hasPlayerVersion,
33204 createSWF: function(attObj, parObj, replaceElemIdStr) {
33206 return createSWF(attObj, parObj, replaceElemIdStr);
33213 showExpressInstall: function(att, par, replaceElemIdStr, callbackFn) {
33214 if (ua.w3 && canExpressInstall()) {
33215 showExpressInstall(att, par, replaceElemIdStr, callbackFn);
33219 removeSWF: function(objElemIdStr) {
33221 removeSWF(objElemIdStr);
33225 createCSS: function(selStr, declStr, mediaStr, newStyleBoolean) {
33227 createCSS(selStr, declStr, mediaStr, newStyleBoolean);
33231 addDomLoadEvent: addDomLoadEvent,
33233 addLoadEvent: addLoadEvent,
33235 getQueryParamValue: function(param) {
33236 var q = doc.location.search || doc.location.hash;
33238 if (/\?/.test(q)) { q = q.split("?")[1]; }
33239 if (param == null) {
33240 return urlEncodeIfNecessary(q);
33242 var pairs = q.split("&");
33243 for (var i = 0; i < pairs.length; i++) {
33244 if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
33245 return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=") + 1)));
33253 expressInstallCallback: function() {
33254 if (isExpressInstallActive) {
33255 var obj = getElementById(EXPRESS_INSTALL_ID);
33256 if (obj && storedAltContent) {
33257 obj.parentNode.replaceChild(storedAltContent, obj);
33258 if (storedAltContentId) {
33259 setVisibility(storedAltContentId, true);
33260 if (ua.ie && ua.win) { storedAltContent.style.display = "block"; }
33262 if (storedCallbackFn) { storedCallbackFn(storedCallbackObj); }
33264 isExpressInstallActive = false;
33270 Ext.FlashComponent = Ext.extend(Ext.BoxComponent, {
33272 flashVersion : '9.0.115',
33275 backgroundColor: '#ffffff',
33281 flashVars: undefined,
33284 flashParams: undefined,
33293 expressInstall: false,
33295 initComponent : function(){
33296 Ext.FlashComponent.superclass.initComponent.call(this);
33304 onRender : function(){
33305 Ext.FlashComponent.superclass.onRender.apply(this, arguments);
33307 var params = Ext.apply({
33308 allowScriptAccess: 'always',
33309 bgcolor: this.backgroundColor,
33311 }, this.flashParams), vars = Ext.apply({
33312 allowedDomain: document.location.hostname,
33313 elementID: this.getId(),
33314 eventHandler: 'Ext.FlashEventProxy.onEvent'
33315 }, this.flashVars);
33317 new swfobject.embedSWF(this.url, this.id, this.swfWidth, this.swfHeight, this.flashVersion,
33318 this.expressInstall ? Ext.FlashComponent.EXPRESS_INSTALL_URL : undefined, vars, params);
33320 this.swf = Ext.getDom(this.id);
33321 this.el = Ext.get(this.swf);
33324 getSwfId : function(){
33325 return this.swfId || (this.swfId = "extswf" + (++Ext.Component.AUTO_ID));
33328 getId : function(){
33329 return this.id || (this.id = "extflashcmp" + (++Ext.Component.AUTO_ID));
33332 onFlashEvent : function(e){
33340 e.component = this;
33341 this.fireEvent(e.type.toLowerCase().replace(/event$/, ''), e);
33344 initSwf : function(){
33345 this.onSwfReady(!!this.isInitialized);
33346 this.isInitialized = true;
33347 this.fireEvent('initialize', this);
33350 beforeDestroy: function(){
33352 swfobject.removeSWF(this.swf.id);
33354 Ext.FlashComponent.superclass.beforeDestroy.call(this);
33357 onSwfReady : Ext.emptyFn
33361 Ext.FlashComponent.EXPRESS_INSTALL_URL = 'http:/' + '/swfobject.googlecode.com/svn/trunk/swfobject/expressInstall.swf';
33363 Ext.reg('flash', Ext.FlashComponent);
33364 Ext.FlashEventProxy = {
33365 onEvent : function(id, e){
33366 var fp = Ext.getCmp(id);
33368 fp.onFlashEvent(e);
33370 arguments.callee.defer(10, this, [id, e]);
33375 Ext.chart.Chart = Ext.extend(Ext.FlashComponent, {
33376 refreshBuffer: 100,
33383 animationEnabled: true,
33414 seriesStyles: null,
33417 disableCaching: Ext.isIE || Ext.isOpera,
33418 disableCacheParam: '_dc',
33420 initComponent : function(){
33421 Ext.chart.Chart.superclass.initComponent.call(this);
33423 this.url = Ext.chart.Chart.CHART_URL;
33425 if(this.disableCaching){
33426 this.url = Ext.urlAppend(this.url, String.format('{0}={1}', this.disableCacheParam, new Date().getTime()));
33441 this.store = Ext.StoreMgr.lookup(this.store);
33445 setStyle: function(name, value){
33446 this.swf.setStyle(name, Ext.encode(value));
33450 setStyles: function(styles){
33451 this.swf.setStyles(Ext.encode(styles));
33455 setSeriesStyles: function(styles){
33456 this.seriesStyles = styles;
33458 Ext.each(styles, function(style){
33459 s.push(Ext.encode(style));
33461 this.swf.setSeriesStyles(s);
33464 setCategoryNames : function(names){
33465 this.swf.setCategoryNames(names);
33468 setTipRenderer : function(fn){
33470 this.tipFnName = this.createFnProxy(function(item, index, series){
33471 var record = chart.store.getAt(index);
33472 return fn(chart, record, index, series);
33473 }, this.tipFnName);
33474 this.swf.setDataTipFunction(this.tipFnName);
33477 setSeries : function(series){
33478 this.series = series;
33483 bindStore : function(store, initial){
33484 if(!initial && this.store){
33485 if(store !== this.store && this.store.autoDestroy){
33486 this.store.destroy();
33488 this.store.un("datachanged", this.refresh, this);
33489 this.store.un("add", this.delayRefresh, this);
33490 this.store.un("remove", this.delayRefresh, this);
33491 this.store.un("update", this.delayRefresh, this);
33492 this.store.un("clear", this.refresh, this);
33496 store = Ext.StoreMgr.lookup(store);
33499 datachanged: this.refresh,
33500 add: this.delayRefresh,
33501 remove: this.delayRefresh,
33502 update: this.delayRefresh,
33503 clear: this.refresh
33506 this.store = store;
33507 if(store && !initial){
33512 onSwfReady : function(isReset){
33513 Ext.chart.Chart.superclass.onSwfReady.call(this, isReset);
33514 this.swf.setType(this.type);
33516 if(this.chartStyle){
33517 this.setStyles(Ext.apply({}, this.extraStyle, this.chartStyle));
33520 if(this.categoryNames){
33521 this.setCategoryNames(this.categoryNames);
33524 if(this.tipRenderer){
33525 this.setTipRenderer(this.tipRenderer);
33528 this.bindStore(this.store, true);
33530 this.refresh.defer(10, this);
33533 delayRefresh : function(){
33534 if(!this.refreshTask){
33535 this.refreshTask = new Ext.util.DelayedTask(this.refresh, this);
33537 this.refreshTask.delay(this.refreshBuffer);
33540 refresh : function(){
33541 if(this.fireEvent('beforerefresh', this) !== false){
33542 var styleChanged = false;
33544 var data = [], rs = this.store.data.items;
33545 for(var j = 0, len = rs.length; j < len; j++){
33546 data[j] = rs[j].data;
33550 var dataProvider = [];
33551 var seriesCount = 0;
33552 var currentSeries = null;
33555 seriesCount = this.series.length;
33556 for(i = 0; i < seriesCount; i++){
33557 currentSeries = this.series[i];
33558 var clonedSeries = {};
33559 for(var prop in currentSeries){
33560 if(prop == "style" && currentSeries.style !== null){
33561 clonedSeries.style = Ext.encode(currentSeries.style);
33562 styleChanged = true;
33568 clonedSeries[prop] = currentSeries[prop];
33571 dataProvider.push(clonedSeries);
33575 if(seriesCount > 0){
33576 for(i = 0; i < seriesCount; i++){
33577 currentSeries = dataProvider[i];
33578 if(!currentSeries.type){
33579 currentSeries.type = this.type;
33581 currentSeries.dataProvider = data;
33584 dataProvider.push({type: this.type, dataProvider: data});
33586 this.swf.setDataProvider(dataProvider);
33587 if(this.seriesStyles){
33588 this.setSeriesStyles(this.seriesStyles);
33590 this.fireEvent('refresh', this);
33594 createFnProxy : function(fn, old){
33596 delete window[old];
33598 var fnName = "extFnProxy" + (++Ext.chart.Chart.PROXY_FN_ID);
33599 window[fnName] = fn;
33603 onDestroy: function(){
33604 Ext.chart.Chart.superclass.onDestroy.call(this);
33605 this.bindStore(null);
33606 var tip = this.tipFnName;
33607 if(!Ext.isEmpty(tip)){
33608 delete window[tip];
33612 Ext.reg('chart', Ext.chart.Chart);
33613 Ext.chart.Chart.PROXY_FN_ID = 0;
33616 Ext.chart.Chart.CHART_URL = 'http:/' + '/yui.yahooapis.com/2.7.0/build/charts/assets/charts.swf';
33619 Ext.chart.PieChart = Ext.extend(Ext.chart.Chart, {
33622 onSwfReady : function(isReset){
33623 Ext.chart.PieChart.superclass.onSwfReady.call(this, isReset);
33625 this.setDataField(this.dataField);
33626 this.setCategoryField(this.categoryField);
33629 setDataField : function(field){
33630 this.dataField = field;
33631 this.swf.setDataField(field);
33634 setCategoryField : function(field){
33635 this.categoryField = field;
33636 this.swf.setCategoryField(field);
33639 Ext.reg('piechart', Ext.chart.PieChart);
33642 Ext.chart.CartesianChart = Ext.extend(Ext.chart.Chart, {
33643 onSwfReady : function(isReset){
33644 Ext.chart.CartesianChart.superclass.onSwfReady.call(this, isReset);
33647 this.setXField(this.xField);
33650 this.setYField(this.yField);
33653 this.setXAxis(this.xAxis);
33656 this.setYAxis(this.yAxis);
33660 setXField : function(value){
33661 this.xField = value;
33662 this.swf.setHorizontalField(value);
33665 setYField : function(value){
33666 this.yField = value;
33667 this.swf.setVerticalField(value);
33670 setXAxis : function(value){
33671 this.xAxis = this.createAxis('xAxis', value);
33672 this.swf.setHorizontalAxis(this.xAxis);
33675 setYAxis : function(value){
33676 this.yAxis = this.createAxis('yAxis', value);
33677 this.swf.setVerticalAxis(this.yAxis);
33680 createAxis : function(axis, value){
33681 var o = Ext.apply({}, value), oldFn = null;
33683 oldFn = this[axis].labelFunction;
33685 if(o.labelRenderer){
33686 var fn = o.labelRenderer;
33687 o.labelFunction = this.createFnProxy(function(v){
33690 delete o.labelRenderer;
33695 Ext.reg('cartesianchart', Ext.chart.CartesianChart);
33698 Ext.chart.LineChart = Ext.extend(Ext.chart.CartesianChart, {
33701 Ext.reg('linechart', Ext.chart.LineChart);
33704 Ext.chart.ColumnChart = Ext.extend(Ext.chart.CartesianChart, {
33707 Ext.reg('columnchart', Ext.chart.ColumnChart);
33710 Ext.chart.StackedColumnChart = Ext.extend(Ext.chart.CartesianChart, {
33711 type: 'stackcolumn'
33713 Ext.reg('stackedcolumnchart', Ext.chart.StackedColumnChart);
33716 Ext.chart.BarChart = Ext.extend(Ext.chart.CartesianChart, {
33719 Ext.reg('barchart', Ext.chart.BarChart);
33722 Ext.chart.StackedBarChart = Ext.extend(Ext.chart.CartesianChart, {
33725 Ext.reg('stackedbarchart', Ext.chart.StackedBarChart);
33730 Ext.chart.Axis = function(config){
33731 Ext.apply(this, config);
33734 Ext.chart.Axis.prototype =
33740 orientation: "horizontal",
33746 labelFunction: null,
33749 hideOverlappingLabels: true
33753 Ext.chart.NumericAxis = Ext.extend(Ext.chart.Axis, {
33772 alwaysShowZero: true,
33779 Ext.chart.TimeAxis = Ext.extend(Ext.chart.Axis, {
33792 majorTimeUnit: null,
33798 minorTimeUnit: null,
33805 Ext.chart.CategoryAxis = Ext.extend(Ext.chart.Axis, {
33809 categoryNames: null
33813 Ext.chart.Series = function(config) { Ext.apply(this, config); };
33815 Ext.chart.Series.prototype =
33825 Ext.chart.CartesianSeries = Ext.extend(Ext.chart.Series, {
33834 Ext.chart.ColumnSeries = Ext.extend(Ext.chart.CartesianSeries, {
33839 Ext.chart.LineSeries = Ext.extend(Ext.chart.CartesianSeries, {
33844 Ext.chart.BarSeries = Ext.extend(Ext.chart.CartesianSeries, {
33850 Ext.chart.PieSeries = Ext.extend(Ext.chart.Series, {
33853 categoryField: null
33855 Ext.layout.MenuLayout = Ext.extend(Ext.layout.ContainerLayout, {
33856 monitorResize : true,
33858 setContainer : function(ct){
33859 this.monitorResize = !ct.floating;
33862 ct.on('autosize', this.doAutoSize, this);
33863 Ext.layout.MenuLayout.superclass.setContainer.call(this, ct);
33866 renderItem : function(c, position, target){
33867 if (!this.itemTpl) {
33868 this.itemTpl = Ext.layout.MenuLayout.prototype.itemTpl = new Ext.XTemplate(
33869 '<li id="{itemId}" class="{itemCls}">',
33870 '<tpl if="needsIcon">',
33871 '<img src="{icon}" class="{iconCls}"/>',
33877 if(c && !c.rendered){
33878 if(Ext.isNumber(position)){
33879 position = target.dom.childNodes[position];
33881 var a = this.getItemArgs(c);
33884 c.render(c.positionEl = position ?
33885 this.itemTpl.insertBefore(position, a, true) :
33886 this.itemTpl.append(target, a, true));
33889 c.positionEl.menuItemId = c.getItemId();
33893 if (!a.isMenuItem && a.needsIcon) {
33894 c.positionEl.addClass('x-menu-list-item-indent');
33896 this.configureItem(c, position);
33897 }else if(c && !this.isValidParent(c, target)){
33898 if(Ext.isNumber(position)){
33899 position = target.dom.childNodes[position];
33901 target.dom.insertBefore(c.getActionEl().dom, position || null);
33905 getItemArgs : function(c) {
33906 var isMenuItem = c instanceof Ext.menu.Item;
33908 isMenuItem: isMenuItem,
33909 needsIcon: !isMenuItem && (c.icon || c.iconCls),
33910 icon: c.icon || Ext.BLANK_IMAGE_URL,
33911 iconCls: 'x-menu-item-icon ' + (c.iconCls || ''),
33912 itemId: 'x-menu-el-' + c.id,
33913 itemCls: 'x-menu-list-item '
33918 isValidParent : function(c, target) {
33919 return c.el.up('li.x-menu-list-item', 5).dom.parentNode === (target.dom || target);
33922 onLayout : function(ct, target){
33923 this.renderAll(ct, target);
33927 doAutoSize : function(){
33928 var ct = this.container, w = ct.width;
33932 }else if(Ext.isIE){
33933 ct.setWidth(Ext.isStrict && (Ext.isIE7 || Ext.isIE8) ? 'auto' : ct.minWidth);
33934 var el = ct.getEl(), t = el.dom.offsetWidth;
33935 ct.setWidth(ct.getLayoutTarget().getWidth() + el.getFrameWidth('lr'));
33940 Ext.Container.LAYOUTS['menu'] = Ext.layout.MenuLayout;
33943 Ext.menu.Menu = Ext.extend(Ext.Container, {
33951 subMenuAlign : 'tl-tr?',
33953 defaultAlign : 'tl-bl?',
33955 allowOtherMenus : false,
33957 ignoreParentClicks : false,
33959 enableScrolling : true,
33963 scrollIncrement : 24,
33965 showSeparator : true,
33967 defaultOffsets : [0, 0],
33980 hideMode : 'offsets',
33981 scrollerHeight : 8,
33983 defaultType : 'menuitem',
33984 bufferResize : false,
33986 initComponent : function(){
33987 if(Ext.isArray(this.initialConfig)){
33988 Ext.apply(this, {items:this.initialConfig});
34000 Ext.menu.MenuMgr.register(this);
34002 Ext.EventManager.onWindowResize(this.hide, this);
34004 if(this.initialConfig.hidden !== false){
34005 this.hidden = false;
34007 this.internalDefaults = {hideOnClick: false};
34009 Ext.menu.Menu.superclass.initComponent.call(this);
34010 if(this.autoLayout){
34012 add: this.doLayout,
34013 remove: this.doLayout,
34020 getLayoutTarget : function() {
34025 onRender : function(ct, position){
34027 ct = Ext.getBody();
34032 cls: 'x-menu ' + ((this.floating) ? 'x-menu-floating x-layer ' : '') + (this.cls || '') + (this.plain ? ' x-menu-plain' : '') + (this.showSeparator ? '' : ' x-menu-nosep'),
34035 {tag: 'a', cls: 'x-menu-focus', href: '#', onclick: 'return false;', tabIndex: '-1'},
34036 {tag: 'ul', cls: 'x-menu-list'}
34040 this.el = new Ext.Layer({
34041 shadow: this.shadow,
34048 this.el = ct.createChild(dh);
34050 Ext.menu.Menu.superclass.onRender.call(this, ct, position);
34053 this.keyNav = new Ext.menu.MenuNav(this);
34056 this.focusEl = this.el.child('a.x-menu-focus');
34057 this.ul = this.el.child('ul.x-menu-list');
34058 this.mon(this.ul, {
34060 click: this.onClick,
34061 mouseover: this.onMouseOver,
34062 mouseout: this.onMouseOut
34064 if(this.enableScrolling){
34065 this.mon(this.el, {
34067 delegate: '.x-menu-scroller',
34068 click: this.onScroll,
34069 mouseover: this.deactivateActive
34075 findTargetItem : function(e){
34076 var t = e.getTarget('.x-menu-list-item', this.ul, true);
34077 if(t && t.menuItemId){
34078 return this.items.get(t.menuItemId);
34083 onClick : function(e){
34084 var t = this.findTargetItem(e);
34087 this.setActiveItem(t);
34088 }else if(t instanceof Ext.menu.BaseItem){
34089 if(t.menu && this.ignoreParentClicks){
34091 e.preventDefault();
34092 }else if(t.onClick){
34094 this.fireEvent('click', this, t, e);
34101 setActiveItem : function(item, autoExpand){
34102 if(item != this.activeItem){
34103 this.deactivateActive();
34104 if((this.activeItem = item).isFormField){
34107 item.activate(autoExpand);
34109 }else if(autoExpand){
34114 deactivateActive : function(){
34115 var a = this.activeItem;
34125 delete this.activeItem;
34130 tryActivate : function(start, step){
34131 var items = this.items;
34132 for(var i = start, len = items.length; i >= 0 && i < len; i+= step){
34133 var item = items.get(i);
34134 if(!item.disabled && (item.canActivate || item.isFormField)){
34135 this.setActiveItem(item, false);
34143 onMouseOver : function(e){
34144 var t = this.findTargetItem(e);
34146 if(t.canActivate && !t.disabled){
34147 this.setActiveItem(t, true);
34151 this.fireEvent('mouseover', this, e, t);
34155 onMouseOut : function(e){
34156 var t = this.findTargetItem(e);
34158 if(t == this.activeItem && t.shouldDeactivate && t.shouldDeactivate(e)){
34159 this.activeItem.deactivate();
34160 delete this.activeItem;
34164 this.fireEvent('mouseout', this, e, t);
34168 onScroll : function(e, t){
34172 var ul = this.ul.dom, top = Ext.fly(t).is('.x-menu-scroller-top');
34173 ul.scrollTop += this.scrollIncrement * (top ? -1 : 1);
34174 if(top ? ul.scrollTop <= 0 : ul.scrollTop + this.activeMax >= ul.scrollHeight){
34175 this.onScrollerOut(null, t);
34180 onScrollerIn : function(e, t){
34181 var ul = this.ul.dom, top = Ext.fly(t).is('.x-menu-scroller-top');
34182 if(top ? ul.scrollTop > 0 : ul.scrollTop + this.activeMax < ul.scrollHeight){
34183 Ext.fly(t).addClass(['x-menu-item-active', 'x-menu-scroller-active']);
34188 onScrollerOut : function(e, t){
34189 Ext.fly(t).removeClass(['x-menu-item-active', 'x-menu-scroller-active']);
34193 show : function(el, pos, parentMenu){
34195 this.parentMenu = parentMenu;
34198 this.doLayout(false, true);
34200 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign, this.defaultOffsets), parentMenu);
34202 Ext.menu.Menu.superclass.show.call(this);
34207 showAt : function(xy, parentMenu){
34208 if(this.fireEvent('beforeshow', this) !== false){
34209 this.parentMenu = parentMenu;
34213 if(this.enableScrolling){
34217 this.constrainScroll(xy[1]);
34218 xy = [this.el.adjustForConstraints(xy)[0], xy[1]];
34221 xy = this.el.adjustForConstraints(xy);
34225 Ext.menu.Menu.superclass.onShow.call(this);
34228 this.fireEvent('autosize', this);
34233 this.hidden = false;
34235 this.fireEvent('show', this);
34239 constrainScroll : function(y){
34240 var max, full = this.ul.setHeight('auto').getHeight();
34242 max = this.maxHeight ? this.maxHeight : Ext.fly(this.el.dom.parentNode).getViewSize(false).height - y;
34244 max = this.getHeight();
34246 if(full > max && max > 0){
34247 this.activeMax = max - this.scrollerHeight * 2 - this.el.getFrameWidth('tb') - Ext.num(this.el.shadowOffset, 0);
34248 this.ul.setHeight(this.activeMax);
34249 this.createScrollers();
34250 this.el.select('.x-menu-scroller').setDisplayed('');
34252 this.ul.setHeight(full);
34253 this.el.select('.x-menu-scroller').setDisplayed('none');
34255 this.ul.dom.scrollTop = 0;
34258 createScrollers : function(){
34259 if(!this.scroller){
34262 top: this.el.insertFirst({
34264 cls: 'x-menu-scroller x-menu-scroller-top',
34267 bottom: this.el.createChild({
34269 cls: 'x-menu-scroller x-menu-scroller-bottom',
34273 this.scroller.top.hover(this.onScrollerIn, this.onScrollerOut, this);
34274 this.scroller.topRepeater = new Ext.util.ClickRepeater(this.scroller.top, {
34276 click: this.onScroll.createDelegate(this, [null, this.scroller.top], false)
34279 this.scroller.bottom.hover(this.onScrollerIn, this.onScrollerOut, this);
34280 this.scroller.bottomRepeater = new Ext.util.ClickRepeater(this.scroller.bottom, {
34282 click: this.onScroll.createDelegate(this, [null, this.scroller.bottom], false)
34288 onLayout : function(){
34289 if(this.isVisible()){
34290 if(this.enableScrolling){
34291 this.constrainScroll(this.el.getTop());
34299 focus : function(){
34301 this.doFocus.defer(50, this);
34305 doFocus : function(){
34307 this.focusEl.focus();
34312 hide : function(deep){
34313 this.deepHide = deep;
34314 Ext.menu.Menu.superclass.hide.call(this);
34315 delete this.deepHide;
34319 onHide : function(){
34320 Ext.menu.Menu.superclass.onHide.call(this);
34321 this.deactivateActive();
34322 if(this.el && this.floating){
34325 var pm = this.parentMenu;
34326 if(this.deepHide === true && pm){
34330 pm.deactivateActive();
34336 lookupComponent : function(c){
34337 if(Ext.isString(c)){
34338 c = (c == 'separator' || c == '-') ? new Ext.menu.Separator() : new Ext.menu.TextItem(c);
34339 this.applyDefaults(c);
34341 if(Ext.isObject(c)){
34342 c = this.getMenuItem(c);
34343 }else if(c.tagName || c.el){
34344 c = new Ext.BoxComponent({
34352 applyDefaults : function(c){
34353 if(!Ext.isString(c)){
34354 c = Ext.menu.Menu.superclass.applyDefaults.call(this, c);
34355 var d = this.internalDefaults;
34358 Ext.applyIf(c.initialConfig, d);
34369 getMenuItem : function(config){
34370 if(!config.isXType){
34371 if(!config.xtype && Ext.isBoolean(config.checked)){
34372 return new Ext.menu.CheckItem(config)
34374 return Ext.create(config, this.defaultType);
34380 addSeparator : function(){
34381 return this.add(new Ext.menu.Separator());
34385 addElement : function(el){
34386 return this.add(new Ext.menu.BaseItem(el));
34390 addItem : function(item){
34391 return this.add(item);
34395 addMenuItem : function(config){
34396 return this.add(this.getMenuItem(config));
34400 addText : function(text){
34401 return this.add(new Ext.menu.TextItem(text));
34405 onDestroy : function(){
34406 var pm = this.parentMenu;
34407 if(pm && pm.activeChild == this){
34408 delete pm.activeChild;
34410 delete this.parentMenu;
34411 Ext.menu.Menu.superclass.onDestroy.call(this);
34412 Ext.menu.MenuMgr.unregister(this);
34413 Ext.EventManager.removeResizeListener(this.hide, this);
34415 this.keyNav.disable();
34417 var s = this.scroller;
34419 Ext.destroy(s.topRepeater, s.bottomRepeater, s.top, s.bottom);
34429 Ext.reg('menu', Ext.menu.Menu);
34432 Ext.menu.MenuNav = Ext.extend(Ext.KeyNav, function(){
34434 if(!m.tryActivate(m.items.indexOf(m.activeItem)-1, -1)){
34435 m.tryActivate(m.items.length-1, -1);
34438 function down(e, m){
34439 if(!m.tryActivate(m.items.indexOf(m.activeItem)+1, 1)){
34440 m.tryActivate(0, 1);
34444 constructor : function(menu){
34445 Ext.menu.MenuNav.superclass.constructor.call(this, menu.el);
34446 this.scope = this.menu = menu;
34449 doRelay : function(e, h){
34450 var k = e.getKey();
34452 if (this.menu.activeItem && this.menu.activeItem.isFormField && k != e.TAB) {
34455 if(!this.menu.activeItem && e.isNavKeyPress() && k != e.SPACE && k != e.RETURN){
34456 this.menu.tryActivate(0, 1);
34459 return h.call(this.scope || this, e, this.menu);
34462 tab: function(e, m) {
34475 right : function(e, m){
34477 m.activeItem.expandMenu(true);
34481 left : function(e, m){
34483 if(m.parentMenu && m.parentMenu.activeItem){
34484 m.parentMenu.activeItem.activate();
34488 enter : function(e, m){
34490 e.stopPropagation();
34491 m.activeItem.onClick(e);
34492 m.fireEvent('click', this, m.activeItem);
34499 Ext.menu.MenuMgr = function(){
34500 var menus, active, groups = {}, attached = false, lastShow = new Date();
34505 active = new Ext.util.MixedCollection();
34506 Ext.getDoc().addKeyListener(27, function(){
34507 if(active.length > 0){
34514 function hideAll(){
34515 if(active && active.length > 0){
34516 var c = active.clone();
34517 c.each(function(m){
34526 function onHide(m){
34528 if(active.length < 1){
34529 Ext.getDoc().un("mousedown", onMouseDown);
34535 function onShow(m){
34536 var last = active.last();
34537 lastShow = new Date();
34540 Ext.getDoc().on("mousedown", onMouseDown);
34544 m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
34545 m.parentMenu.activeChild = m;
34546 }else if(last && last.isVisible()){
34547 m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
34552 function onBeforeHide(m){
34554 m.activeChild.hide();
34556 if(m.autoHideTimer){
34557 clearTimeout(m.autoHideTimer);
34558 delete m.autoHideTimer;
34563 function onBeforeShow(m){
34564 var pm = m.parentMenu;
34565 if(!pm && !m.allowOtherMenus){
34567 }else if(pm && pm.activeChild){
34568 pm.activeChild.hide();
34573 function onMouseDown(e){
34574 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".x-menu")){
34580 function onBeforeCheck(mi, state){
34582 var g = groups[mi.group];
34583 for(var i = 0, l = g.length; i < l; i++){
34585 g[i].setChecked(false);
34594 hideAll : function(){
34599 register : function(menu){
34603 menus[menu.id] = menu;
34605 beforehide: onBeforeHide,
34607 beforeshow: onBeforeShow,
34613 get : function(menu){
34614 if(typeof menu == "string"){
34618 return menus[menu];
34619 }else if(menu.events){
34621 }else if(typeof menu.length == 'number'){
34622 return new Ext.menu.Menu({items:menu});
34624 return Ext.create(menu, 'menu');
34629 unregister : function(menu){
34630 delete menus[menu.id];
34631 menu.un("beforehide", onBeforeHide);
34632 menu.un("hide", onHide);
34633 menu.un("beforeshow", onBeforeShow);
34634 menu.un("show", onShow);
34638 registerCheckable : function(menuItem){
34639 var g = menuItem.group;
34644 groups[g].push(menuItem);
34645 menuItem.on("beforecheckchange", onBeforeCheck);
34650 unregisterCheckable : function(menuItem){
34651 var g = menuItem.group;
34653 groups[g].remove(menuItem);
34654 menuItem.un("beforecheckchange", onBeforeCheck);
34658 getCheckedItem : function(groupId){
34659 var g = groups[groupId];
34661 for(var i = 0, l = g.length; i < l; i++){
34670 setCheckedItem : function(groupId, itemId){
34671 var g = groups[groupId];
34673 for(var i = 0, l = g.length; i < l; i++){
34674 if(g[i].id == itemId){
34675 g[i].setChecked(true);
34684 Ext.menu.BaseItem = Ext.extend(Ext.Component, {
34689 canActivate : false,
34691 activeClass : "x-menu-item-active",
34693 hideOnClick : true,
34695 clickHideDelay : 1,
34698 ctype : "Ext.menu.BaseItem",
34701 actionMode : "container",
34703 initComponent : function(){
34704 Ext.menu.BaseItem.superclass.initComponent.call(this);
34714 this.on("click", this.handler, this.scope);
34719 onRender : function(container, position){
34720 Ext.menu.BaseItem.superclass.onRender.apply(this, arguments);
34721 if(this.ownerCt && this.ownerCt instanceof Ext.menu.Menu){
34722 this.parentMenu = this.ownerCt;
34724 this.container.addClass('x-menu-list-item');
34725 this.mon(this.el, {
34727 click: this.onClick,
34728 mouseenter: this.activate,
34729 mouseleave: this.deactivate
34735 setHandler : function(handler, scope){
34737 this.un("click", this.handler, this.scope);
34739 this.on("click", this.handler = handler, this.scope = scope);
34743 onClick : function(e){
34744 if(!this.disabled && this.fireEvent("click", this, e) !== false
34745 && (this.parentMenu && this.parentMenu.fireEvent("itemclick", this, e) !== false)){
34746 this.handleClick(e);
34753 activate : function(){
34757 var li = this.container;
34758 li.addClass(this.activeClass);
34759 this.region = li.getRegion().adjust(2, 2, -2, -2);
34760 this.fireEvent("activate", this);
34765 deactivate : function(){
34766 this.container.removeClass(this.activeClass);
34767 this.fireEvent("deactivate", this);
34771 shouldDeactivate : function(e){
34772 return !this.region || !this.region.contains(e.getPoint());
34776 handleClick : function(e){
34777 var pm = this.parentMenu;
34778 if(this.hideOnClick){
34780 pm.hide.defer(this.clickHideDelay, pm, [true]);
34782 pm.deactivateActive();
34788 expandMenu : Ext.emptyFn,
34791 hideMenu : Ext.emptyFn
34793 Ext.reg('menubaseitem', Ext.menu.BaseItem);
34794 Ext.menu.TextItem = Ext.extend(Ext.menu.BaseItem, {
34797 hideOnClick : false,
34799 itemCls : "x-menu-text",
34801 constructor : function(config){
34802 if(typeof config == 'string'){
34803 config = {text: config}
34805 Ext.menu.TextItem.superclass.constructor.call(this, config);
34809 onRender : function(){
34810 var s = document.createElement("span");
34811 s.className = this.itemCls;
34812 s.innerHTML = this.text;
34814 Ext.menu.TextItem.superclass.onRender.apply(this, arguments);
34817 Ext.reg('menutextitem', Ext.menu.TextItem);
34818 Ext.menu.Separator = Ext.extend(Ext.menu.BaseItem, {
34820 itemCls : "x-menu-sep",
34822 hideOnClick : false,
34828 onRender : function(li){
34829 var s = document.createElement("span");
34830 s.className = this.itemCls;
34831 s.innerHTML = " ";
34833 li.addClass("x-menu-sep-li");
34834 Ext.menu.Separator.superclass.onRender.apply(this, arguments);
34837 Ext.reg('menuseparator', Ext.menu.Separator);
34838 Ext.menu.Item = Ext.extend(Ext.menu.BaseItem, {
34847 itemCls : 'x-menu-item',
34849 canActivate : true,
34856 ctype: 'Ext.menu.Item',
34858 initComponent : function(){
34859 Ext.menu.Item.superclass.initComponent.call(this);
34861 this.menu = Ext.menu.MenuMgr.get(this.menu);
34862 this.menu.ownerCt = this;
34867 onRender : function(container, position){
34868 if (!this.itemTpl) {
34869 this.itemTpl = Ext.menu.Item.prototype.itemTpl = new Ext.XTemplate(
34870 '<a id="{id}" class="{cls}" hidefocus="true" unselectable="on" href="{href}"',
34871 '<tpl if="hrefTarget">',
34872 ' target="{hrefTarget}"',
34875 '<img src="{icon}" class="x-menu-item-icon {iconCls}"/>',
34876 '<span class="x-menu-item-text">{text}</span>',
34880 var a = this.getTemplateArgs();
34881 this.el = position ? this.itemTpl.insertBefore(position, a, true) : this.itemTpl.append(container, a, true);
34882 this.iconEl = this.el.child('img.x-menu-item-icon');
34883 this.textEl = this.el.child('.x-menu-item-text');
34885 this.mon(this.el, 'click', Ext.emptyFn, null, { preventDefault: true });
34887 Ext.menu.Item.superclass.onRender.call(this, container, position);
34890 getTemplateArgs: function() {
34893 cls: this.itemCls + (this.menu ? ' x-menu-item-arrow' : '') + (this.cls ? ' ' + this.cls : ''),
34894 href: this.href || '#',
34895 hrefTarget: this.hrefTarget,
34896 icon: this.icon || Ext.BLANK_IMAGE_URL,
34897 iconCls: this.iconCls || '',
34898 text: this.itemText||this.text||' '
34903 setText : function(text){
34904 this.text = text||' ';
34906 this.textEl.update(this.text);
34907 this.parentMenu.layout.doAutoSize();
34912 setIconClass : function(cls){
34913 var oldCls = this.iconCls;
34914 this.iconCls = cls;
34916 this.iconEl.replaceClass(oldCls, this.iconCls);
34921 beforeDestroy: function(){
34923 delete this.menu.ownerCt;
34924 this.menu.destroy();
34926 Ext.menu.Item.superclass.beforeDestroy.call(this);
34930 handleClick : function(e){
34934 Ext.menu.Item.superclass.handleClick.apply(this, arguments);
34938 activate : function(autoExpand){
34939 if(Ext.menu.Item.superclass.activate.apply(this, arguments)){
34949 shouldDeactivate : function(e){
34950 if(Ext.menu.Item.superclass.shouldDeactivate.call(this, e)){
34951 if(this.menu && this.menu.isVisible()){
34952 return !this.menu.getEl().getRegion().contains(e.getPoint());
34960 deactivate : function(){
34961 Ext.menu.Item.superclass.deactivate.apply(this, arguments);
34966 expandMenu : function(autoActivate){
34967 if(!this.disabled && this.menu){
34968 clearTimeout(this.hideTimer);
34969 delete this.hideTimer;
34970 if(!this.menu.isVisible() && !this.showTimer){
34971 this.showTimer = this.deferExpand.defer(this.showDelay, this, [autoActivate]);
34972 }else if (this.menu.isVisible() && autoActivate){
34973 this.menu.tryActivate(0, 1);
34979 deferExpand : function(autoActivate){
34980 delete this.showTimer;
34981 this.menu.show(this.container, this.parentMenu.subMenuAlign || 'tl-tr?', this.parentMenu);
34983 this.menu.tryActivate(0, 1);
34988 hideMenu : function(){
34989 clearTimeout(this.showTimer);
34990 delete this.showTimer;
34991 if(!this.hideTimer && this.menu && this.menu.isVisible()){
34992 this.hideTimer = this.deferHide.defer(this.hideDelay, this);
34997 deferHide : function(){
34998 delete this.hideTimer;
34999 if(this.menu.over){
35000 this.parentMenu.setActiveItem(this, false);
35006 Ext.reg('menuitem', Ext.menu.Item);
35007 Ext.menu.CheckItem = Ext.extend(Ext.menu.Item, {
35010 itemCls : "x-menu-item x-menu-check-item",
35012 groupClass : "x-menu-group-item",
35018 ctype: "Ext.menu.CheckItem",
35020 initComponent : function(){
35021 Ext.menu.CheckItem.superclass.initComponent.call(this);
35024 "beforecheckchange" ,
35029 if(this.checkHandler){
35030 this.on('checkchange', this.checkHandler, this.scope);
35032 Ext.menu.MenuMgr.registerCheckable(this);
35036 onRender : function(c){
35037 Ext.menu.CheckItem.superclass.onRender.apply(this, arguments);
35039 this.el.addClass(this.groupClass);
35042 this.checked = false;
35043 this.setChecked(true, true);
35048 destroy : function(){
35049 Ext.menu.MenuMgr.unregisterCheckable(this);
35050 Ext.menu.CheckItem.superclass.destroy.apply(this, arguments);
35054 setChecked : function(state, suppressEvent){
35055 if(this.checked != state && this.fireEvent("beforecheckchange", this, state) !== false){
35056 if(this.container){
35057 this.container[state ? "addClass" : "removeClass"]("x-menu-item-checked");
35059 this.checked = state;
35060 if(suppressEvent !== true){
35061 this.fireEvent("checkchange", this, state);
35067 handleClick : function(e){
35068 if(!this.disabled && !(this.checked && this.group)){
35069 this.setChecked(!this.checked);
35071 Ext.menu.CheckItem.superclass.handleClick.apply(this, arguments);
35074 Ext.reg('menucheckitem', Ext.menu.CheckItem);
35075 Ext.menu.DateMenu = Ext.extend(Ext.menu.Menu, {
35077 enableScrolling : false,
35081 hideOnClick : true,
35089 cls : 'x-date-menu',
35095 initComponent : function(){
35096 this.on('beforeshow', this.onBeforeShow, this);
35097 if(this.strict = (Ext.isIE7 && Ext.isStrict)){
35098 this.on('show', this.onShow, this, {single: true, delay: 20});
35102 showSeparator: false,
35103 items: this.picker = new Ext.DatePicker(Ext.applyIf({
35104 internalRender: this.strict || !Ext.isIE,
35105 ctCls: 'x-menu-date-item',
35107 }, this.initialConfig))
35109 this.picker.purgeListeners();
35110 Ext.menu.DateMenu.superclass.initComponent.call(this);
35112 this.relayEvents(this.picker, ['select']);
35113 this.on('show', this.picker.focus, this.picker);
35114 this.on('select', this.menuHide, this);
35116 this.on('select', this.handler, this.scope || this);
35120 menuHide : function() {
35121 if(this.hideOnClick){
35126 onBeforeShow : function(){
35128 this.picker.hideMonthPicker(true);
35132 onShow : function(){
35133 var el = this.picker.getEl();
35134 el.setWidth(el.getWidth());
35137 Ext.reg('datemenu', Ext.menu.DateMenu);
35139 Ext.menu.ColorMenu = Ext.extend(Ext.menu.Menu, {
35141 enableScrolling : false,
35146 hideOnClick : true,
35148 cls : 'x-color-menu',
35162 initComponent : function(){
35165 showSeparator: false,
35166 items: this.palette = new Ext.ColorPalette(Ext.applyIf({
35168 }, this.initialConfig))
35170 this.palette.purgeListeners();
35171 Ext.menu.ColorMenu.superclass.initComponent.call(this);
35173 this.relayEvents(this.palette, ['select']);
35174 this.on('select', this.menuHide, this);
35176 this.on('select', this.handler, this.scope || this);
35180 menuHide : function(){
35181 if(this.hideOnClick){
35186 Ext.reg('colormenu', Ext.menu.ColorMenu);
35188 Ext.form.Field = Ext.extend(Ext.BoxComponent, {
35197 invalidClass : 'x-form-invalid',
35199 invalidText : 'The value in this field is invalid',
35201 focusClass : 'x-form-focus',
35204 validationEvent : 'keyup',
35206 validateOnBlur : true,
35208 validationDelay : 250,
35210 defaultAutoCreate : {tag: 'input', type: 'text', size: '20', autocomplete: 'off'},
35212 fieldClass : 'x-form-field',
35214 msgTarget : 'qtip',
35225 isFormField : true,
35234 initComponent : function(){
35235 Ext.form.Field.superclass.initComponent.call(this);
35253 getName : function(){
35254 return this.rendered && this.el.dom.name ? this.el.dom.name : this.name || this.id || '';
35258 onRender : function(ct, position){
35260 var cfg = this.getAutoCreate();
35263 cfg.name = this.name || this.id;
35265 if(this.inputType){
35266 cfg.type = this.inputType;
35270 Ext.form.Field.superclass.onRender.call(this, ct, position);
35271 if(this.submitValue === false){
35272 this.el.dom.removeAttribute('name');
35274 var type = this.el.dom.type;
35276 if(type == 'password'){
35279 this.el.addClass('x-form-'+type);
35282 this.setReadOnly(true);
35284 if(this.tabIndex !== undefined){
35285 this.el.dom.setAttribute('tabIndex', this.tabIndex);
35288 this.el.addClass([this.fieldClass, this.cls]);
35292 getItemCt : function(){
35293 return this.itemCt;
35297 initValue : function(){
35298 if(this.value !== undefined){
35299 this.setValue(this.value);
35300 }else if(!Ext.isEmpty(this.el.dom.value) && this.el.dom.value != this.emptyText){
35301 this.setValue(this.el.dom.value);
35304 this.originalValue = this.getValue();
35308 isDirty : function() {
35309 if(this.disabled || !this.rendered) {
35312 return String(this.getValue()) !== String(this.originalValue);
35316 setReadOnly : function(readOnly){
35318 this.el.dom.readOnly = readOnly;
35320 this.readOnly = readOnly;
35324 afterRender : function(){
35325 Ext.form.Field.superclass.afterRender.call(this);
35331 fireKey : function(e){
35332 if(e.isSpecialKey()){
35333 this.fireEvent('specialkey', this, e);
35338 reset : function(){
35339 this.setValue(this.originalValue);
35340 this.clearInvalid();
35344 initEvents : function(){
35345 this.mon(this.el, Ext.EventManager.useKeydown ? 'keydown' : 'keypress', this.fireKey, this);
35346 this.mon(this.el, 'focus', this.onFocus, this);
35350 this.mon(this.el, 'blur', this.onBlur, this, this.inEditor ? {buffer:10} : null);
35354 preFocus: Ext.emptyFn,
35357 onFocus : function(){
35359 if(this.focusClass){
35360 this.el.addClass(this.focusClass);
35362 if(!this.hasFocus){
35363 this.hasFocus = true;
35365 this.startValue = this.getValue();
35366 this.fireEvent('focus', this);
35371 beforeBlur : Ext.emptyFn,
35374 onBlur : function(){
35376 if(this.focusClass){
35377 this.el.removeClass(this.focusClass);
35379 this.hasFocus = false;
35380 if(this.validationEvent !== false && (this.validateOnBlur || this.validationEvent == 'blur')){
35383 var v = this.getValue();
35384 if(String(v) !== String(this.startValue)){
35385 this.fireEvent('change', this, v, this.startValue);
35387 this.fireEvent('blur', this);
35392 postBlur : Ext.emptyFn,
35395 isValid : function(preventMark){
35399 var restore = this.preventMark;
35400 this.preventMark = preventMark === true;
35401 var v = this.validateValue(this.processValue(this.getRawValue()));
35402 this.preventMark = restore;
35407 validate : function(){
35408 if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
35409 this.clearInvalid();
35416 processValue : function(value){
35421 validateValue : function(value){
35426 getActiveError : function(){
35427 return this.activeError || '';
35431 markInvalid : function(msg){
35432 if(!this.rendered || this.preventMark){
35435 msg = msg || this.invalidText;
35437 var mt = this.getMessageHandler();
35439 mt.mark(this, msg);
35440 }else if(this.msgTarget){
35441 this.el.addClass(this.invalidClass);
35442 var t = Ext.getDom(this.msgTarget);
35445 t.style.display = this.msgDisplay;
35448 this.activeError = msg;
35449 this.fireEvent('invalid', this, msg);
35453 clearInvalid : function(){
35454 if(!this.rendered || this.preventMark){
35457 this.el.removeClass(this.invalidClass);
35458 var mt = this.getMessageHandler();
35461 }else if(this.msgTarget){
35462 this.el.removeClass(this.invalidClass);
35463 var t = Ext.getDom(this.msgTarget);
35466 t.style.display = 'none';
35469 delete this.activeError;
35470 this.fireEvent('valid', this);
35474 getMessageHandler : function(){
35475 return Ext.form.MessageTargets[this.msgTarget];
35479 getErrorCt : function(){
35480 return this.el.findParent('.x-form-element', 5, true) ||
35481 this.el.findParent('.x-form-field-wrap', 5, true);
35485 alignErrorIcon : function(){
35486 this.errorIcon.alignTo(this.el, 'tl-tr', [2, 0]);
35490 getRawValue : function(){
35491 var v = this.rendered ? this.el.getValue() : Ext.value(this.value, '');
35492 if(v === this.emptyText){
35499 getValue : function(){
35500 if(!this.rendered) {
35503 var v = this.el.getValue();
35504 if(v === this.emptyText || v === undefined){
35511 setRawValue : function(v){
35512 return this.rendered ? (this.el.dom.value = (Ext.isEmpty(v) ? '' : v)) : '';
35516 setValue : function(v){
35519 this.el.dom.value = (Ext.isEmpty(v) ? '' : v);
35526 append : function(v){
35527 this.setValue([this.getValue(), v].join(''));
35537 Ext.form.MessageTargets = {
35539 mark: function(field, msg){
35540 field.el.addClass(field.invalidClass);
35541 field.el.dom.qtip = msg;
35542 field.el.dom.qclass = 'x-form-invalid-tip';
35544 Ext.QuickTips.enable();
35547 clear: function(field){
35548 field.el.removeClass(field.invalidClass);
35549 field.el.dom.qtip = '';
35553 mark: function(field, msg){
35554 field.el.addClass(field.invalidClass);
35555 field.el.dom.title = msg;
35557 clear: function(field){
35558 field.el.dom.title = '';
35562 mark: function(field, msg){
35563 field.el.addClass(field.invalidClass);
35564 if(!field.errorEl){
35565 var elp = field.getErrorCt();
35567 field.el.dom.title = msg;
35570 field.errorEl = elp.createChild({cls:'x-form-invalid-msg'});
35571 field.errorEl.setWidth(elp.getWidth(true)-20);
35573 field.errorEl.update(msg);
35574 Ext.form.Field.msgFx[field.msgFx].show(field.errorEl, field);
35576 clear: function(field){
35577 field.el.removeClass(field.invalidClass);
35579 Ext.form.Field.msgFx[field.msgFx].hide(field.errorEl, field);
35581 field.el.dom.title = '';
35586 mark: function(field, msg){
35587 field.el.addClass(field.invalidClass);
35588 if(!field.errorIcon){
35589 var elp = field.getErrorCt();
35591 field.el.dom.title = msg;
35594 field.errorIcon = elp.createChild({cls:'x-form-invalid-icon'});
35596 field.alignErrorIcon();
35597 field.errorIcon.dom.qtip = msg;
35598 field.errorIcon.dom.qclass = 'x-form-invalid-tip';
35599 field.errorIcon.show();
35600 field.on('resize', field.alignErrorIcon, field);
35602 clear: function(field){
35603 field.el.removeClass(field.invalidClass);
35604 if(field.errorIcon){
35605 field.errorIcon.dom.qtip = '';
35606 field.errorIcon.hide();
35607 field.un('resize', field.alignErrorIcon, field);
35609 field.el.dom.title = '';
35616 Ext.form.Field.msgFx = {
35618 show: function(msgEl, f){
35619 msgEl.setDisplayed('block');
35622 hide : function(msgEl, f){
35623 msgEl.setDisplayed(false).update('');
35628 show: function(msgEl, f){
35629 msgEl.slideIn('t', {stopFx:true});
35632 hide : function(msgEl, f){
35633 msgEl.slideOut('t', {stopFx:true,useDisplay:true});
35638 show: function(msgEl, f){
35639 msgEl.fixDisplay();
35640 msgEl.alignTo(f.el, 'tl-tr');
35641 msgEl.slideIn('l', {stopFx:true});
35644 hide : function(msgEl, f){
35645 msgEl.slideOut('l', {stopFx:true,useDisplay:true});
35649 Ext.reg('field', Ext.form.Field);
35651 Ext.form.TextField = Ext.extend(Ext.form.Field, {
35665 disableKeyFilter : false,
35671 maxLength : Number.MAX_VALUE,
35673 minLengthText : 'The minimum length for this field is {0}',
35675 maxLengthText : 'The maximum length for this field is {0}',
35677 selectOnFocus : false,
35679 blankText : 'This field is required',
35689 emptyClass : 'x-form-empty-field',
35693 initComponent : function(){
35694 Ext.form.TextField.superclass.initComponent.call(this);
35709 initEvents : function(){
35710 Ext.form.TextField.superclass.initEvents.call(this);
35711 if(this.validationEvent == 'keyup'){
35712 this.validationTask = new Ext.util.DelayedTask(this.validate, this);
35713 this.mon(this.el, 'keyup', this.filterValidation, this);
35715 else if(this.validationEvent !== false && this.validationEvent != 'blur'){
35716 this.mon(this.el, this.validationEvent, this.validate, this, {buffer: this.validationDelay});
35718 if(this.selectOnFocus || this.emptyText){
35719 this.mon(this.el, 'mousedown', this.onMouseDown, this);
35721 if(this.emptyText){
35722 this.applyEmptyText();
35725 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Ext.form.VTypes[this.vtype+'Mask']))){
35726 this.mon(this.el, 'keypress', this.filterKeys, this);
35729 this.mon(this.el, 'keyup', this.onKeyUpBuffered, this, {buffer: 50});
35730 this.mon(this.el, 'click', this.autoSize, this);
35732 if(this.enableKeyEvents){
35733 this.mon(this.el, {
35735 keyup: this.onKeyUp,
35736 keydown: this.onKeyDown,
35737 keypress: this.onKeyPress
35742 onMouseDown: function(e){
35743 if(!this.hasFocus){
35744 this.mon(this.el, 'mouseup', Ext.emptyFn, this, { single: true, preventDefault: true });
35748 processValue : function(value){
35749 if(this.stripCharsRe){
35750 var newValue = value.replace(this.stripCharsRe, '');
35751 if(newValue !== value){
35752 this.setRawValue(newValue);
35759 filterValidation : function(e){
35760 if(!e.isNavKeyPress()){
35761 this.validationTask.delay(this.validationDelay);
35766 onDisable: function(){
35767 Ext.form.TextField.superclass.onDisable.call(this);
35769 this.el.dom.unselectable = 'on';
35774 onEnable: function(){
35775 Ext.form.TextField.superclass.onEnable.call(this);
35777 this.el.dom.unselectable = '';
35782 onKeyUpBuffered : function(e){
35783 if(this.doAutoSize(e)){
35789 doAutoSize : function(e){
35790 return !e.isNavKeyPress();
35794 onKeyUp : function(e){
35795 this.fireEvent('keyup', this, e);
35799 onKeyDown : function(e){
35800 this.fireEvent('keydown', this, e);
35804 onKeyPress : function(e){
35805 this.fireEvent('keypress', this, e);
35809 reset : function(){
35810 Ext.form.TextField.superclass.reset.call(this);
35811 this.applyEmptyText();
35814 applyEmptyText : function(){
35815 if(this.rendered && this.emptyText && this.getRawValue().length < 1 && !this.hasFocus){
35816 this.setRawValue(this.emptyText);
35817 this.el.addClass(this.emptyClass);
35822 preFocus : function(){
35824 if(this.emptyText){
35825 if(el.dom.value == this.emptyText){
35826 this.setRawValue('');
35828 el.removeClass(this.emptyClass);
35830 if(this.selectOnFocus){
35836 postBlur : function(){
35837 this.applyEmptyText();
35841 filterKeys : function(e){
35845 var k = e.getKey();
35846 if(Ext.isGecko && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
35849 var cc = String.fromCharCode(e.getCharCode());
35850 if(!Ext.isGecko && e.isSpecialKey() && !cc){
35853 if(!this.maskRe.test(cc)){
35858 setValue : function(v){
35859 if(this.emptyText && this.el && !Ext.isEmpty(v)){
35860 this.el.removeClass(this.emptyClass);
35862 Ext.form.TextField.superclass.setValue.apply(this, arguments);
35863 this.applyEmptyText();
35869 validateValue : function(value){
35870 if(Ext.isFunction(this.validator)){
35871 var msg = this.validator(value);
35873 this.markInvalid(msg);
35877 if(value.length < 1 || value === this.emptyText){
35878 if(this.allowBlank){
35879 this.clearInvalid();
35882 this.markInvalid(this.blankText);
35886 if(value.length < this.minLength){
35887 this.markInvalid(String.format(this.minLengthText, this.minLength));
35890 if(value.length > this.maxLength){
35891 this.markInvalid(String.format(this.maxLengthText, this.maxLength));
35895 var vt = Ext.form.VTypes;
35896 if(!vt[this.vtype](value, this)){
35897 this.markInvalid(this.vtypeText || vt[this.vtype +'Text']);
35901 if(this.regex && !this.regex.test(value)){
35902 this.markInvalid(this.regexText);
35909 selectText : function(start, end){
35910 var v = this.getRawValue();
35911 var doFocus = false;
35913 start = start === undefined ? 0 : start;
35914 end = end === undefined ? v.length : end;
35915 var d = this.el.dom;
35916 if(d.setSelectionRange){
35917 d.setSelectionRange(start, end);
35918 }else if(d.createTextRange){
35919 var range = d.createTextRange();
35920 range.moveStart('character', start);
35921 range.moveEnd('character', end-v.length);
35924 doFocus = Ext.isGecko || Ext.isOpera;
35934 autoSize : function(){
35935 if(!this.grow || !this.rendered){
35939 this.metrics = Ext.util.TextMetrics.createInstance(this.el);
35942 var v = el.dom.value;
35943 var d = document.createElement('div');
35944 d.appendChild(document.createTextNode(v));
35949 var w = Math.min(this.growMax, Math.max(this.metrics.getWidth(v) + 10, this.growMin));
35950 this.el.setWidth(w);
35951 this.fireEvent('autosize', this, w);
35954 onDestroy: function(){
35955 if(this.validationTask){
35956 this.validationTask.cancel();
35957 this.validationTask = null;
35959 Ext.form.TextField.superclass.onDestroy.call(this);
35962 Ext.reg('textfield', Ext.form.TextField);
35964 Ext.form.TriggerField = Ext.extend(Ext.form.TextField, {
35968 defaultAutoCreate : {tag: "input", type: "text", size: "16", autocomplete: "off"},
35976 wrapFocusClass: 'x-trigger-wrap-focus',
35978 autoSize: Ext.emptyFn,
35982 deferHeight : true,
35986 actionMode: 'wrap',
35988 removeMode: 'container',
35990 defaultTriggerWidth: 17,
35993 onResize : function(w, h){
35994 Ext.form.TriggerField.superclass.onResize.call(this, w, h);
35995 var tw = this.getTriggerWidth();
35996 if(Ext.isNumber(w)){
35997 this.el.setWidth(w - tw);
35999 this.wrap.setWidth(this.el.getWidth() + tw);
36002 getTriggerWidth: function(){
36003 var tw = this.trigger.getWidth();
36004 if(!this.hideTrigger && tw === 0){
36005 tw = this.defaultTriggerWidth;
36011 alignErrorIcon : function(){
36013 this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);
36018 onRender : function(ct, position){
36019 this.doc = Ext.isIE ? Ext.getBody() : Ext.getDoc();
36020 Ext.form.TriggerField.superclass.onRender.call(this, ct, position);
36022 this.wrap = this.el.wrap({cls: 'x-form-field-wrap x-form-field-trigger-wrap'});
36023 this.trigger = this.wrap.createChild(this.triggerConfig ||
36024 {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.triggerClass});
36025 this.initTrigger();
36027 this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
36029 this.resizeEl = this.positionEl = this.wrap;
36030 this.updateEditState();
36033 updateEditState: function(){
36035 if (this.readOnly) {
36036 this.el.dom.readOnly = true;
36037 this.el.addClass('x-trigger-noedit');
36038 this.mun(this.el, 'click', this.onTriggerClick, this);
36039 this.trigger.setDisplayed(false);
36041 if (!this.editable) {
36042 this.el.dom.readOnly = true;
36043 this.el.addClass('x-trigger-noedit');
36044 this.mon(this.el, 'click', this.onTriggerClick, this);
36046 this.el.dom.readOnly = false;
36047 this.el.removeClass('x-trigger-noedit');
36048 this.mun(this.el, 'click', this.onTriggerClick, this);
36050 this.trigger.setDisplayed(!this.hideTrigger);
36052 this.onResize(this.width || this.wrap.getWidth());
36056 setHideTrigger: function(hideTrigger){
36057 if(hideTrigger != this.hideTrigger){
36058 this.hideTrigger = hideTrigger;
36059 this.updateEditState();
36064 setEditable: function(editable){
36065 if(editable != this.editable){
36066 this.editable = editable;
36067 this.updateEditState();
36072 setReadOnly: function(readOnly){
36073 if(readOnly != this.readOnly){
36074 this.readOnly = readOnly;
36075 this.updateEditState();
36079 afterRender : function(){
36080 Ext.form.TriggerField.superclass.afterRender.call(this);
36084 initTrigger : function(){
36085 this.mon(this.trigger, 'click', this.onTriggerClick, this, {preventDefault:true});
36086 this.trigger.addClassOnOver('x-form-trigger-over');
36087 this.trigger.addClassOnClick('x-form-trigger-click');
36091 onDestroy : function(){
36092 Ext.destroy(this.trigger, this.wrap);
36093 if (this.mimicing){
36094 this.doc.un('mousedown', this.mimicBlur, this);
36097 Ext.form.TriggerField.superclass.onDestroy.call(this);
36101 onFocus : function(){
36102 Ext.form.TriggerField.superclass.onFocus.call(this);
36103 if(!this.mimicing){
36104 this.wrap.addClass(this.wrapFocusClass);
36105 this.mimicing = true;
36106 this.doc.on('mousedown', this.mimicBlur, this, {delay: 10});
36107 if(this.monitorTab){
36108 this.on('specialkey', this.checkTab, this);
36114 checkTab : function(me, e){
36115 if(e.getKey() == e.TAB){
36116 this.triggerBlur();
36121 onBlur : Ext.emptyFn,
36124 mimicBlur : function(e){
36125 if(!this.isDestroyed && !this.wrap.contains(e.target) && this.validateBlur(e)){
36126 this.triggerBlur();
36131 triggerBlur : function(){
36132 this.mimicing = false;
36133 this.doc.un('mousedown', this.mimicBlur, this);
36134 if(this.monitorTab && this.el){
36135 this.un('specialkey', this.checkTab, this);
36137 Ext.form.TriggerField.superclass.onBlur.call(this);
36139 this.wrap.removeClass(this.wrapFocusClass);
36143 beforeBlur : Ext.emptyFn,
36147 validateBlur : function(e){
36152 onTriggerClick : Ext.emptyFn
36160 Ext.form.TwinTriggerField = Ext.extend(Ext.form.TriggerField, {
36165 initComponent : function(){
36166 Ext.form.TwinTriggerField.superclass.initComponent.call(this);
36168 this.triggerConfig = {
36169 tag:'span', cls:'x-form-twin-triggers', cn:[
36170 {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.trigger1Class},
36171 {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.trigger2Class}
36175 getTrigger : function(index){
36176 return this.triggers[index];
36179 initTrigger : function(){
36180 var ts = this.trigger.select('.x-form-trigger', true);
36181 var triggerField = this;
36182 ts.each(function(t, all, index){
36183 var triggerIndex = 'Trigger'+(index+1);
36184 t.hide = function(){
36185 var w = triggerField.wrap.getWidth();
36186 this.dom.style.display = 'none';
36187 triggerField.el.setWidth(w-triggerField.trigger.getWidth());
36188 this['hidden' + triggerIndex] = true;
36190 t.show = function(){
36191 var w = triggerField.wrap.getWidth();
36192 this.dom.style.display = '';
36193 triggerField.el.setWidth(w-triggerField.trigger.getWidth());
36194 this['hidden' + triggerIndex] = false;
36197 if(this['hide'+triggerIndex]){
36198 t.dom.style.display = 'none';
36199 this['hidden' + triggerIndex] = true;
36201 this.mon(t, 'click', this['on'+triggerIndex+'Click'], this, {preventDefault:true});
36202 t.addClassOnOver('x-form-trigger-over');
36203 t.addClassOnClick('x-form-trigger-click');
36205 this.triggers = ts.elements;
36208 getTriggerWidth: function(){
36210 Ext.each(this.triggers, function(t, index){
36211 var triggerIndex = 'Trigger' + (index + 1),
36213 if(w === 0 && !this['hidden' + triggerIndex]){
36214 tw += this.defaultTriggerWidth;
36223 onDestroy : function() {
36224 Ext.destroy(this.triggers);
36225 Ext.form.TwinTriggerField.superclass.onDestroy.call(this);
36229 onTrigger1Click : Ext.emptyFn,
36231 onTrigger2Click : Ext.emptyFn
36233 Ext.reg('trigger', Ext.form.TriggerField);
36235 Ext.form.TextArea = Ext.extend(Ext.form.TextField, {
36240 growAppend : ' \n ',
36242 enterIsSpecial : false,
36245 preventScrollbars: false,
36249 onRender : function(ct, position){
36251 this.defaultAutoCreate = {
36253 style:"width:100px;height:60px;",
36254 autocomplete: "off"
36257 Ext.form.TextArea.superclass.onRender.call(this, ct, position);
36259 this.textSizeEl = Ext.DomHelper.append(document.body, {
36260 tag: "pre", cls: "x-form-grow-sizer"
36262 if(this.preventScrollbars){
36263 this.el.setStyle("overflow", "hidden");
36265 this.el.setHeight(this.growMin);
36269 onDestroy : function(){
36270 Ext.removeNode(this.textSizeEl);
36271 Ext.form.TextArea.superclass.onDestroy.call(this);
36274 fireKey : function(e){
36275 if(e.isSpecialKey() && (this.enterIsSpecial || (e.getKey() != e.ENTER || e.hasModifier()))){
36276 this.fireEvent("specialkey", this, e);
36281 doAutoSize : function(e){
36282 return !e.isNavKeyPress() || e.getKey() == e.ENTER;
36286 autoSize: function(){
36287 if(!this.grow || !this.textSizeEl){
36291 v = Ext.util.Format.htmlEncode(el.dom.value),
36292 ts = this.textSizeEl,
36295 Ext.fly(ts).setWidth(this.el.getWidth());
36297 v = "  ";
36299 v += this.growAppend;
36301 v = v.replace(/\n/g, ' <br />');
36305 h = Math.min(this.growMax, Math.max(ts.offsetHeight, this.growMin));
36306 if(h != this.lastHeight){
36307 this.lastHeight = h;
36308 this.el.setHeight(h);
36309 this.fireEvent("autosize", this, h);
36313 Ext.reg('textarea', Ext.form.TextArea);
36314 Ext.form.NumberField = Ext.extend(Ext.form.TextField, {
36318 fieldClass: "x-form-field x-form-num-field",
36320 allowDecimals : true,
36322 decimalSeparator : ".",
36324 decimalPrecision : 2,
36326 allowNegative : true,
36328 minValue : Number.NEGATIVE_INFINITY,
36330 maxValue : Number.MAX_VALUE,
36332 minText : "The minimum value for this field is {0}",
36334 maxText : "The maximum value for this field is {0}",
36336 nanText : "{0} is not a valid number",
36338 baseChars : "0123456789",
36341 initEvents : function(){
36342 var allowed = this.baseChars + '';
36343 if (this.allowDecimals) {
36344 allowed += this.decimalSeparator;
36346 if (this.allowNegative) {
36349 this.maskRe = new RegExp('[' + Ext.escapeRe(allowed) + ']');
36350 Ext.form.NumberField.superclass.initEvents.call(this);
36354 validateValue : function(value){
36355 if(!Ext.form.NumberField.superclass.validateValue.call(this, value)){
36358 if(value.length < 1){
36361 value = String(value).replace(this.decimalSeparator, ".");
36363 this.markInvalid(String.format(this.nanText, value));
36366 var num = this.parseValue(value);
36367 if(num < this.minValue){
36368 this.markInvalid(String.format(this.minText, this.minValue));
36371 if(num > this.maxValue){
36372 this.markInvalid(String.format(this.maxText, this.maxValue));
36378 getValue : function(){
36379 return this.fixPrecision(this.parseValue(Ext.form.NumberField.superclass.getValue.call(this)));
36382 setValue : function(v){
36383 v = Ext.isNumber(v) ? v : parseFloat(String(v).replace(this.decimalSeparator, "."));
36384 v = isNaN(v) ? '' : String(v).replace(".", this.decimalSeparator);
36385 return Ext.form.NumberField.superclass.setValue.call(this, v);
36389 setMinValue : function(value){
36390 this.minValue = Ext.num(value, Number.NEGATIVE_INFINITY);
36394 setMaxValue : function(value){
36395 this.maxValue = Ext.num(value, Number.MAX_VALUE);
36399 parseValue : function(value){
36400 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
36401 return isNaN(value) ? '' : value;
36405 fixPrecision : function(value){
36406 var nan = isNaN(value);
36407 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
36408 return nan ? '' : value;
36410 return parseFloat(parseFloat(value).toFixed(this.decimalPrecision));
36413 beforeBlur : function(){
36414 var v = this.parseValue(this.getRawValue());
36415 if(!Ext.isEmpty(v)){
36416 this.setValue(this.fixPrecision(v));
36420 Ext.reg('numberfield', Ext.form.NumberField);
36421 Ext.form.DateField = Ext.extend(Ext.form.TriggerField, {
36425 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",
36427 disabledDaysText : "Disabled",
36429 disabledDatesText : "Disabled",
36431 minText : "The date in this field must be equal to or after {0}",
36433 maxText : "The date in this field must be equal to or before {0}",
36435 invalidText : "{0} is not a valid date - it must be in the format {1}",
36437 triggerClass : 'x-form-date-trigger',
36447 defaultAutoCreate : {tag: "input", type: "text", size: "10", autocomplete: "off"},
36449 initComponent : function(){
36450 Ext.form.DateField.superclass.initComponent.call(this);
36457 if(Ext.isString(this.minValue)){
36458 this.minValue = this.parseDate(this.minValue);
36460 if(Ext.isString(this.maxValue)){
36461 this.maxValue = this.parseDate(this.maxValue);
36463 this.disabledDatesRE = null;
36464 this.initDisabledDays();
36467 initEvents: function() {
36468 Ext.form.DateField.superclass.initEvents.call(this);
36469 this.keyNav = new Ext.KeyNav(this.el, {
36470 "down": function(e) {
36471 this.onTriggerClick();
36480 initDisabledDays : function(){
36481 if(this.disabledDates){
36482 var dd = this.disabledDates,
36483 len = dd.length - 1,
36486 Ext.each(dd, function(d, i){
36487 re += Ext.isDate(d) ? '^' + Ext.escapeRe(d.dateFormat(this.format)) + '$' : dd[i];
36492 this.disabledDatesRE = new RegExp(re + ')');
36497 setDisabledDates : function(dd){
36498 this.disabledDates = dd;
36499 this.initDisabledDays();
36501 this.menu.picker.setDisabledDates(this.disabledDatesRE);
36506 setDisabledDays : function(dd){
36507 this.disabledDays = dd;
36509 this.menu.picker.setDisabledDays(dd);
36514 setMinValue : function(dt){
36515 this.minValue = (Ext.isString(dt) ? this.parseDate(dt) : dt);
36517 this.menu.picker.setMinDate(this.minValue);
36522 setMaxValue : function(dt){
36523 this.maxValue = (Ext.isString(dt) ? this.parseDate(dt) : dt);
36525 this.menu.picker.setMaxDate(this.maxValue);
36530 validateValue : function(value){
36531 value = this.formatDate(value);
36532 if(!Ext.form.DateField.superclass.validateValue.call(this, value)){
36535 if(value.length < 1){
36538 var svalue = value;
36539 value = this.parseDate(value);
36541 this.markInvalid(String.format(this.invalidText, svalue, this.format));
36544 var time = value.getTime();
36545 if(this.minValue && time < this.minValue.getTime()){
36546 this.markInvalid(String.format(this.minText, this.formatDate(this.minValue)));
36549 if(this.maxValue && time > this.maxValue.getTime()){
36550 this.markInvalid(String.format(this.maxText, this.formatDate(this.maxValue)));
36553 if(this.disabledDays){
36554 var day = value.getDay();
36555 for(var i = 0; i < this.disabledDays.length; i++) {
36556 if(day === this.disabledDays[i]){
36557 this.markInvalid(this.disabledDaysText);
36562 var fvalue = this.formatDate(value);
36563 if(this.disabledDatesRE && this.disabledDatesRE.test(fvalue)){
36564 this.markInvalid(String.format(this.disabledDatesText, fvalue));
36572 validateBlur : function(){
36573 return !this.menu || !this.menu.isVisible();
36577 getValue : function(){
36578 return this.parseDate(Ext.form.DateField.superclass.getValue.call(this)) || "";
36582 setValue : function(date){
36583 return Ext.form.DateField.superclass.setValue.call(this, this.formatDate(this.parseDate(date)));
36587 parseDate : function(value){
36588 if(!value || Ext.isDate(value)){
36591 var v = Date.parseDate(value, this.format);
36592 if(!v && this.altFormats){
36593 if(!this.altFormatsArray){
36594 this.altFormatsArray = this.altFormats.split("|");
36596 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
36597 v = Date.parseDate(value, this.altFormatsArray[i]);
36604 onDestroy : function(){
36605 Ext.destroy(this.menu, this.keyNav);
36606 Ext.form.DateField.superclass.onDestroy.call(this);
36610 formatDate : function(date){
36611 return Ext.isDate(date) ? date.dateFormat(this.format) : date;
36617 onTriggerClick : function(){
36621 if(this.menu == null){
36622 this.menu = new Ext.menu.DateMenu({
36623 hideOnClick: false,
36624 focusOnSelect: false
36628 Ext.apply(this.menu.picker, {
36629 minDate : this.minValue,
36630 maxDate : this.maxValue,
36631 disabledDatesRE : this.disabledDatesRE,
36632 disabledDatesText : this.disabledDatesText,
36633 disabledDays : this.disabledDays,
36634 disabledDaysText : this.disabledDaysText,
36635 format : this.format,
36636 showToday : this.showToday,
36637 minText : String.format(this.minText, this.formatDate(this.minValue)),
36638 maxText : String.format(this.maxText, this.formatDate(this.maxValue))
36640 this.menu.picker.setValue(this.getValue() || new Date());
36641 this.menu.show(this.el, "tl-bl?");
36642 this.menuEvents('on');
36646 menuEvents: function(method){
36647 this.menu[method]('select', this.onSelect, this);
36648 this.menu[method]('hide', this.onMenuHide, this);
36649 this.menu[method]('show', this.onFocus, this);
36652 onSelect: function(m, d){
36654 this.fireEvent('select', this, d);
36658 onMenuHide: function(){
36659 this.focus(false, 60);
36660 this.menuEvents('un');
36664 beforeBlur : function(){
36665 var v = this.parseDate(this.getRawValue());
36676 Ext.reg('datefield', Ext.form.DateField);
36677 Ext.form.DisplayField = Ext.extend(Ext.form.Field, {
36678 validationEvent : false,
36679 validateOnBlur : false,
36680 defaultAutoCreate : {tag: "div"},
36682 fieldClass : "x-form-display-field",
36687 initEvents : Ext.emptyFn,
36689 isValid : function(){
36693 validate : function(){
36697 getRawValue : function(){
36698 var v = this.rendered ? this.el.dom.innerHTML : Ext.value(this.value, '');
36699 if(v === this.emptyText){
36702 if(this.htmlEncode){
36703 v = Ext.util.Format.htmlDecode(v);
36708 getValue : function(){
36709 return this.getRawValue();
36712 getName: function() {
36716 setRawValue : function(v){
36717 if(this.htmlEncode){
36718 v = Ext.util.Format.htmlEncode(v);
36720 return this.rendered ? (this.el.dom.innerHTML = (Ext.isEmpty(v) ? '' : v)) : (this.value = v);
36723 setValue : function(v){
36724 this.setRawValue(v);
36735 Ext.reg('displayfield', Ext.form.DisplayField);
36737 Ext.form.ComboBox = Ext.extend(Ext.form.TriggerField, {
36745 defaultAutoCreate : {tag: "input", type: "text", size: "24", autocomplete: "off"},
36755 selectedClass : 'x-combo-selected',
36759 triggerClass : 'x-form-arrow-trigger',
36763 listAlign : 'tl-bl?',
36769 triggerAction : 'query',
36779 selectOnFocus : false,
36781 queryParam : 'query',
36783 loadingText : 'Loading...',
36795 forceSelection : false,
36797 typeAheadDelay : 250,
36804 clearFilterOnReset : true,
36807 submitValue: undefined,
36812 initComponent : function(){
36813 Ext.form.ComboBox.superclass.initComponent.call(this);
36826 if(this.transform){
36827 var s = Ext.getDom(this.transform);
36828 if(!this.hiddenName){
36829 this.hiddenName = s.name;
36832 this.mode = 'local';
36833 var d = [], opts = s.options;
36834 for(var i = 0, len = opts.length;i < len; i++){
36836 value = (o.hasAttribute ? o.hasAttribute('value') : o.getAttributeNode('value').specified) ? o.value : o.text;
36837 if(o.selected && Ext.isEmpty(this.value, true)) {
36838 this.value = value;
36840 d.push([value, o.text]);
36842 this.store = new Ext.data.ArrayStore({
36844 fields: ['value', 'text'],
36848 this.valueField = 'value';
36849 this.displayField = 'text';
36852 if(!this.lazyRender){
36853 this.target = true;
36854 this.el = Ext.DomHelper.insertBefore(s, this.autoCreate || this.defaultAutoCreate);
36855 this.render(this.el.parentNode, s);
36860 else if(this.store){
36861 this.store = Ext.StoreMgr.lookup(this.store);
36862 if(this.store.autoCreated){
36863 this.displayField = this.valueField = 'field1';
36864 if(!this.store.expandData){
36865 this.displayField = 'field2';
36867 this.mode = 'local';
36871 this.selectedIndex = -1;
36872 if(this.mode == 'local'){
36873 if(!Ext.isDefined(this.initialConfig.queryDelay)){
36874 this.queryDelay = 10;
36876 if(!Ext.isDefined(this.initialConfig.minChars)){
36883 onRender : function(ct, position){
36884 if(this.hiddenName && !Ext.isDefined(this.submitValue)){
36885 this.submitValue = false;
36887 Ext.form.ComboBox.superclass.onRender.call(this, ct, position);
36888 if(this.hiddenName){
36889 this.hiddenField = this.el.insertSibling({tag:'input', type:'hidden', name: this.hiddenName,
36890 id: (this.hiddenId||this.hiddenName)}, 'before', true);
36894 this.el.dom.setAttribute('autocomplete', 'off');
36897 if(!this.lazyInit){
36900 this.on('focus', this.initList, this, {single: true});
36905 initValue : function(){
36906 Ext.form.ComboBox.superclass.initValue.call(this);
36907 if(this.hiddenField){
36908 this.hiddenField.value =
36909 Ext.isDefined(this.hiddenValue) ? this.hiddenValue :
36910 Ext.isDefined(this.value) ? this.value : '';
36915 initList : function(){
36917 var cls = 'x-combo-list';
36919 this.list = new Ext.Layer({
36920 parentEl: this.getListParent(),
36921 shadow: this.shadow,
36922 cls: [cls, this.listClass].join(' '),
36927 var lw = this.listWidth || Math.max(this.wrap.getWidth(), this.minListWidth);
36928 this.list.setSize(lw, 0);
36929 this.list.swallowEvent('mousewheel');
36930 this.assetHeight = 0;
36931 if(this.syncFont !== false){
36932 this.list.setStyle('font-size', this.el.getStyle('font-size'));
36935 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
36936 this.assetHeight += this.header.getHeight();
36939 this.innerList = this.list.createChild({cls:cls+'-inner'});
36940 this.mon(this.innerList, 'mouseover', this.onViewOver, this);
36941 this.mon(this.innerList, 'mousemove', this.onViewMove, this);
36942 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
36945 this.footer = this.list.createChild({cls:cls+'-ft'});
36946 this.pageTb = new Ext.PagingToolbar({
36948 pageSize: this.pageSize,
36949 renderTo:this.footer
36951 this.assetHeight += this.footer.getHeight();
36956 this.tpl = '<tpl for="."><div class="'+cls+'-item">{' + this.displayField + '}</div></tpl>';
36961 this.view = new Ext.DataView({
36962 applyTo: this.innerList,
36964 singleSelect: true,
36965 selectedClass: this.selectedClass,
36966 itemSelector: this.itemSelector || '.' + cls + '-item',
36967 emptyText: this.listEmptyText
36970 this.mon(this.view, 'click', this.onViewClick, this);
36972 this.bindStore(this.store, true);
36974 if(this.resizable){
36975 this.resizer = new Ext.Resizable(this.list, {
36976 pinned:true, handles:'se'
36978 this.mon(this.resizer, 'resize', function(r, w, h){
36979 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
36980 this.listWidth = w;
36981 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
36982 this.restrictHeight();
36985 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
36991 getListParent : function() {
36992 return document.body;
36996 getStore : function(){
37001 bindStore : function(store, initial){
37002 if(this.store && !initial){
37003 if(this.store !== store && this.store.autoDestroy){
37004 this.store.destroy();
37006 this.store.un('beforeload', this.onBeforeLoad, this);
37007 this.store.un('load', this.onLoad, this);
37008 this.store.un('exception', this.collapse, this);
37013 this.view.bindStore(null);
37016 this.pageTb.bindStore(null);
37022 this.lastQuery = null;
37024 this.pageTb.bindStore(store);
37028 this.store = Ext.StoreMgr.lookup(store);
37031 beforeload: this.onBeforeLoad,
37033 exception: this.collapse
37037 this.view.bindStore(store);
37042 reset : function(){
37043 Ext.form.ComboBox.superclass.reset.call(this);
37044 if(this.clearFilterOnReset && this.mode == 'local'){
37045 this.store.clearFilter();
37050 initEvents : function(){
37051 Ext.form.ComboBox.superclass.initEvents.call(this);
37053 this.keyNav = new Ext.KeyNav(this.el, {
37054 "up" : function(e){
37055 this.inKeyMode = true;
37059 "down" : function(e){
37060 if(!this.isExpanded()){
37061 this.onTriggerClick();
37063 this.inKeyMode = true;
37068 "enter" : function(e){
37069 this.onViewClick();
37072 "esc" : function(e){
37076 "tab" : function(e){
37077 this.onViewClick(false);
37083 doRelay : function(e, h, hname){
37084 if(hname == 'down' || this.scope.isExpanded()){
37086 var relay = Ext.KeyNav.prototype.doRelay.apply(this, arguments);
37087 if(!Ext.isIE && Ext.EventManager.useKeydown){
37089 this.scope.fireKey(e);
37096 forceKeyDown : true,
37097 defaultEventAction: 'stopEvent'
37099 this.queryDelay = Math.max(this.queryDelay || 10,
37100 this.mode == 'local' ? 10 : 250);
37101 this.dqTask = new Ext.util.DelayedTask(this.initQuery, this);
37102 if(this.typeAhead){
37103 this.taTask = new Ext.util.DelayedTask(this.onTypeAhead, this);
37105 if(!this.enableKeyEvents){
37106 this.mon(this.el, 'keyup', this.onKeyUp, this);
37111 onDestroy : function(){
37113 this.dqTask.cancel();
37114 this.dqTask = null;
37116 this.bindStore(null);
37123 Ext.destroyMembers(this, 'hiddenField');
37124 Ext.form.ComboBox.superclass.onDestroy.call(this);
37128 fireKey : function(e){
37129 if (!this.isExpanded()) {
37130 Ext.form.ComboBox.superclass.fireKey.call(this, e);
37135 onResize : function(w, h){
37136 Ext.form.ComboBox.superclass.onResize.apply(this, arguments);
37137 if(this.isVisible() && this.list){
37140 this.bufferSize = w;
37144 doResize: function(w){
37145 if(!Ext.isDefined(this.listWidth)){
37146 var lw = Math.max(w, this.minListWidth);
37147 this.list.setWidth(lw);
37148 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
37153 onEnable : function(){
37154 Ext.form.ComboBox.superclass.onEnable.apply(this, arguments);
37155 if(this.hiddenField){
37156 this.hiddenField.disabled = false;
37161 onDisable : function(){
37162 Ext.form.ComboBox.superclass.onDisable.apply(this, arguments);
37163 if(this.hiddenField){
37164 this.hiddenField.disabled = true;
37169 onBeforeLoad : function(){
37170 if(!this.hasFocus){
37173 this.innerList.update(this.loadingText ?
37174 '<div class="loading-indicator">'+this.loadingText+'</div>' : '');
37175 this.restrictHeight();
37176 this.selectedIndex = -1;
37180 onLoad : function(){
37181 if(!this.hasFocus){
37184 if(this.store.getCount() > 0 || this.listEmptyText){
37186 this.restrictHeight();
37187 if(this.lastQuery == this.allQuery){
37189 this.el.dom.select();
37191 if(!this.selectByValue(this.value, true)){
37192 this.select(0, true);
37196 if(this.typeAhead && this.lastKey != Ext.EventObject.BACKSPACE && this.lastKey != Ext.EventObject.DELETE){
37197 this.taTask.delay(this.typeAheadDelay);
37201 this.onEmptyResults();
37207 onTypeAhead : function(){
37208 if(this.store.getCount() > 0){
37209 var r = this.store.getAt(0);
37210 var newValue = r.data[this.displayField];
37211 var len = newValue.length;
37212 var selStart = this.getRawValue().length;
37213 if(selStart != len){
37214 this.setRawValue(newValue);
37215 this.selectText(selStart, newValue.length);
37221 onSelect : function(record, index){
37222 if(this.fireEvent('beforeselect', this, record, index) !== false){
37223 this.setValue(record.data[this.valueField || this.displayField]);
37225 this.fireEvent('select', this, record, index);
37230 getName: function(){
37231 var hf = this.hiddenField;
37232 return hf && hf.name ? hf.name : this.hiddenName || Ext.form.ComboBox.superclass.getName.call(this);
37236 getValue : function(){
37237 if(this.valueField){
37238 return Ext.isDefined(this.value) ? this.value : '';
37240 return Ext.form.ComboBox.superclass.getValue.call(this);
37245 clearValue : function(){
37246 if(this.hiddenField){
37247 this.hiddenField.value = '';
37249 this.setRawValue('');
37250 this.lastSelectionText = '';
37251 this.applyEmptyText();
37256 setValue : function(v){
37258 if(this.valueField){
37259 var r = this.findRecord(this.valueField, v);
37261 text = r.data[this.displayField];
37262 }else if(Ext.isDefined(this.valueNotFoundText)){
37263 text = this.valueNotFoundText;
37266 this.lastSelectionText = text;
37267 if(this.hiddenField){
37268 this.hiddenField.value = v;
37270 Ext.form.ComboBox.superclass.setValue.call(this, text);
37276 findRecord : function(prop, value){
37278 if(this.store.getCount() > 0){
37279 this.store.each(function(r){
37280 if(r.data[prop] == value){
37290 onViewMove : function(e, t){
37291 this.inKeyMode = false;
37295 onViewOver : function(e, t){
37296 if(this.inKeyMode){
37299 var item = this.view.findItemFromChild(t);
37301 var index = this.view.indexOf(item);
37302 this.select(index, false);
37307 onViewClick : function(doFocus){
37308 var index = this.view.getSelectedIndexes()[0],
37310 r = s.getAt(index);
37312 this.onSelect(r, index);
37313 }else if(s.getCount() === 0){
37314 this.onEmptyResults();
37316 if(doFocus !== false){
37322 restrictHeight : function(){
37323 this.innerList.dom.style.height = '';
37324 var inner = this.innerList.dom,
37325 pad = this.list.getFrameWidth('tb') + (this.resizable ? this.handleHeight : 0) + this.assetHeight,
37326 h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight),
37327 ha = this.getPosition()[1]-Ext.getBody().getScroll().top,
37328 hb = Ext.lib.Dom.getViewHeight()-ha-this.getSize().height,
37329 space = Math.max(ha, hb, this.minHeight || 0)-this.list.shadowOffset-pad-5;
37331 h = Math.min(h, space, this.maxHeight);
37333 this.innerList.setHeight(h);
37334 this.list.beginUpdate();
37335 this.list.setHeight(h+pad);
37336 this.list.alignTo(this.wrap, this.listAlign);
37337 this.list.endUpdate();
37341 onEmptyResults : function(){
37346 isExpanded : function(){
37347 return this.list && this.list.isVisible();
37351 selectByValue : function(v, scrollIntoView){
37352 if(!Ext.isEmpty(v, true)){
37353 var r = this.findRecord(this.valueField || this.displayField, v);
37355 this.select(this.store.indexOf(r), scrollIntoView);
37363 select : function(index, scrollIntoView){
37364 this.selectedIndex = index;
37365 this.view.select(index);
37366 if(scrollIntoView !== false){
37367 var el = this.view.getNode(index);
37369 this.innerList.scrollChildIntoView(el, false);
37375 selectNext : function(){
37376 var ct = this.store.getCount();
37378 if(this.selectedIndex == -1){
37380 }else if(this.selectedIndex < ct-1){
37381 this.select(this.selectedIndex+1);
37387 selectPrev : function(){
37388 var ct = this.store.getCount();
37390 if(this.selectedIndex == -1){
37392 }else if(this.selectedIndex !== 0){
37393 this.select(this.selectedIndex-1);
37399 onKeyUp : function(e){
37400 var k = e.getKey();
37401 if(this.editable !== false && this.readOnly !== true && (k == e.BACKSPACE || !e.isSpecialKey())){
37403 this.dqTask.delay(this.queryDelay);
37405 Ext.form.ComboBox.superclass.onKeyUp.call(this, e);
37409 validateBlur : function(){
37410 return !this.list || !this.list.isVisible();
37414 initQuery : function(){
37415 this.doQuery(this.getRawValue());
37419 beforeBlur : function(){
37420 var val = this.getRawValue(),
37421 rec = this.findRecord(this.displayField, val);
37422 if(!rec && this.forceSelection){
37423 if(val.length > 0 && val != this.emptyText){
37424 this.el.dom.value = Ext.isEmpty(this.lastSelectionText) ? '' : this.lastSelectionText;
37425 this.applyEmptyText();
37431 val = rec.get(this.valueField || this.displayField);
37433 this.setValue(val);
37438 doQuery : function(q, forceAll){
37439 q = Ext.isEmpty(q) ? '' : q;
37442 forceAll: forceAll,
37446 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
37450 forceAll = qe.forceAll;
37451 if(forceAll === true || (q.length >= this.minChars)){
37452 if(this.lastQuery !== q){
37453 this.lastQuery = q;
37454 if(this.mode == 'local'){
37455 this.selectedIndex = -1;
37457 this.store.clearFilter();
37459 this.store.filter(this.displayField, q);
37463 this.store.baseParams[this.queryParam] = q;
37465 params: this.getParams(q)
37470 this.selectedIndex = -1;
37477 getParams : function(q){
37482 p.limit = this.pageSize;
37488 collapse : function(){
37489 if(!this.isExpanded()){
37493 Ext.getDoc().un('mousewheel', this.collapseIf, this);
37494 Ext.getDoc().un('mousedown', this.collapseIf, this);
37495 this.fireEvent('collapse', this);
37499 collapseIf : function(e){
37500 if(!e.within(this.wrap) && !e.within(this.list)){
37506 expand : function(){
37507 if(this.isExpanded() || !this.hasFocus){
37510 if(this.bufferSize){
37511 this.doResize(this.bufferSize);
37512 delete this.bufferSize;
37514 this.list.alignTo(this.wrap, this.listAlign);
37517 this.innerList.setOverflow('auto');
37519 this.mon(Ext.getDoc(), {
37521 mousewheel: this.collapseIf,
37522 mousedown: this.collapseIf
37524 this.fireEvent('expand', this);
37530 onTriggerClick : function(){
37531 if(this.readOnly || this.disabled){
37534 if(this.isExpanded()){
37539 if(this.triggerAction == 'all') {
37540 this.doQuery(this.allQuery, true);
37542 this.doQuery(this.getRawValue());
37554 Ext.reg('combo', Ext.form.ComboBox);
37556 Ext.form.Checkbox = Ext.extend(Ext.form.Field, {
37558 focusClass : undefined,
37560 fieldClass : 'x-form-field',
37564 defaultAutoCreate : { tag: 'input', type: 'checkbox', autocomplete: 'off'},
37571 actionMode : 'wrap',
37574 initComponent : function(){
37575 Ext.form.Checkbox.superclass.initComponent.call(this);
37583 onResize : function(){
37584 Ext.form.Checkbox.superclass.onResize.apply(this, arguments);
37585 if(!this.boxLabel && !this.fieldLabel){
37586 this.el.alignTo(this.wrap, 'c-c');
37591 initEvents : function(){
37592 Ext.form.Checkbox.superclass.initEvents.call(this);
37593 this.mon(this.el, {
37595 click: this.onClick,
37596 change: this.onClick
37601 markInvalid : Ext.emptyFn,
37603 clearInvalid : Ext.emptyFn,
37606 onRender : function(ct, position){
37607 Ext.form.Checkbox.superclass.onRender.call(this, ct, position);
37608 if(this.inputValue !== undefined){
37609 this.el.dom.value = this.inputValue;
37611 this.wrap = this.el.wrap({cls: 'x-form-check-wrap'});
37613 this.wrap.createChild({tag: 'label', htmlFor: this.el.id, cls: 'x-form-cb-label', html: this.boxLabel});
37616 this.setValue(true);
37618 this.checked = this.el.dom.checked;
37622 this.wrap.repaint();
37624 this.resizeEl = this.positionEl = this.wrap;
37628 onDestroy : function(){
37629 Ext.destroy(this.wrap);
37630 Ext.form.Checkbox.superclass.onDestroy.call(this);
37634 initValue : function() {
37635 this.originalValue = this.getValue();
37639 getValue : function(){
37641 return this.el.dom.checked;
37643 return this.checked;
37647 onClick : function(){
37648 if(this.el.dom.checked != this.checked){
37649 this.setValue(this.el.dom.checked);
37654 setValue : function(v){
37655 var checked = this.checked ;
37656 this.checked = (v === true || v === 'true' || v == '1' || String(v).toLowerCase() == 'on');
37658 this.el.dom.checked = this.checked;
37659 this.el.dom.defaultChecked = this.checked;
37661 if(checked != this.checked){
37662 this.fireEvent('check', this, this.checked);
37664 this.handler.call(this.scope || this, this, this.checked);
37670 Ext.reg('checkbox', Ext.form.Checkbox);
37672 Ext.form.CheckboxGroup = Ext.extend(Ext.form.Field, {
37681 blankText : "You must select at least one item in this group",
37684 defaultType : 'checkbox',
37687 groupCls : 'x-form-check-group',
37690 initComponent: function(){
37695 this.on('change', this.validate, this);
37696 Ext.form.CheckboxGroup.superclass.initComponent.call(this);
37700 onRender : function(ct, position){
37706 cls: this.groupCls,
37709 bufferResize: false
37712 xtype: 'container',
37713 defaultType: this.defaultType,
37721 if(this.items[0].items){
37725 Ext.apply(panelCfg, {
37726 layoutConfig: {columns: this.items.length},
37727 defaults: this.defaults,
37730 for(var i=0, len=this.items.length; i<len; i++){
37731 Ext.applyIf(this.items[i], colCfg);
37739 var numCols, cols = [];
37741 if(typeof this.columns == 'string'){
37742 this.columns = this.items.length;
37744 if(!Ext.isArray(this.columns)){
37746 for(var i=0; i<this.columns; i++){
37747 cs.push((100/this.columns)*.01);
37752 numCols = this.columns.length;
37755 for(var i=0; i<numCols; i++){
37756 var cc = Ext.apply({items:[]}, colCfg);
37757 cc[this.columns[i] <= 1 ? 'columnWidth' : 'width'] = this.columns[i];
37759 cc.defaults = Ext.apply(cc.defaults || {}, this.defaults)
37766 var rows = Math.ceil(this.items.length / numCols), ri = 0;
37767 for(var i=0, len=this.items.length; i<len; i++){
37768 if(i>0 && i%rows==0){
37771 if(this.items[i].fieldLabel){
37772 this.items[i].hideLabel = false;
37774 cols[ri].items.push(this.items[i]);
37777 for(var i=0, len=this.items.length; i<len; i++){
37778 var ci = i % numCols;
37779 if(this.items[i].fieldLabel){
37780 this.items[i].hideLabel = false;
37782 cols[ci].items.push(this.items[i]);
37786 Ext.apply(panelCfg, {
37787 layoutConfig: {columns: numCols},
37792 this.panel = new Ext.Container(panelCfg);
37793 this.panel.ownerCt = this;
37794 this.el = this.panel.getEl();
37796 if(this.forId && this.itemCls){
37797 var l = this.el.up(this.itemCls).child('label', true);
37799 l.setAttribute('htmlFor', this.forId);
37803 var fields = this.panel.findBy(function(c){
37804 return c.isFormField;
37807 this.items = new Ext.util.MixedCollection();
37808 this.items.addAll(fields);
37810 Ext.form.CheckboxGroup.superclass.onRender.call(this, ct, position);
37813 initValue : function(){
37815 this.setValue.apply(this, this.buffered ? this.value : [this.value]);
37816 delete this.buffered;
37821 afterRender : function(){
37822 Ext.form.CheckboxGroup.superclass.afterRender.call(this);
37823 this.eachItem(function(item){
37824 item.on('check', this.fireChecked, this);
37825 item.inGroup = true;
37830 doLayout: function(){
37833 this.panel.forceLayout = this.ownerCt.forceLayout;
37834 this.panel.doLayout();
37839 fireChecked: function(){
37841 this.eachItem(function(item){
37846 this.fireEvent('change', this, arr);
37850 validateValue : function(value){
37851 if(!this.allowBlank){
37853 this.eachItem(function(f){
37855 return (blank = false);
37859 this.markInvalid(this.blankText);
37867 isDirty: function(){
37869 if (this.disabled || !this.rendered) {
37874 this.eachItem(function(item){
37875 if(item.isDirty()){
37884 onDisable : function(){
37885 this.eachItem(function(item){
37891 onEnable : function(){
37892 this.eachItem(function(item){
37898 doLayout: function(){
37900 this.panel.forceLayout = this.ownerCt.forceLayout;
37901 this.panel.doLayout();
37906 onResize : function(w, h){
37907 this.panel.setSize(w, h);
37908 this.panel.doLayout();
37912 reset : function(){
37913 this.eachItem(function(c){
37921 this.clearInvalid();
37922 }).defer(50, this);
37926 setValue: function(){
37928 this.onSetValue.apply(this, arguments);
37930 this.buffered = true;
37931 this.value = arguments;
37936 onSetValue: function(id, value){
37937 if(arguments.length == 1){
37938 if(Ext.isArray(id)){
37940 Ext.each(id, function(val, idx){
37941 var item = this.items.itemAt(idx);
37943 item.setValue(val);
37946 }else if(Ext.isObject(id)){
37949 var f = this.getBox(i);
37955 this.setValueForItem(id);
37958 var f = this.getBox(id);
37966 beforeDestroy: function(){
37967 Ext.destroy(this.panel);
37968 Ext.form.CheckboxGroup.superclass.beforeDestroy.call(this);
37972 setValueForItem : function(val){
37973 val = String(val).split(',');
37974 this.eachItem(function(item){
37975 if(val.indexOf(item.inputValue)> -1){
37976 item.setValue(true);
37982 getBox : function(id){
37984 this.eachItem(function(f){
37985 if(id == f || f.dataIndex == id || f.id == id || f.getName() == id){
37994 getValue : function(){
37996 this.eachItem(function(item){
38005 eachItem: function(fn){
38006 if(this.items && this.items.each){
38007 this.items.each(fn, this);
38014 getRawValue : Ext.emptyFn,
38017 setRawValue : Ext.emptyFn
38021 Ext.reg('checkboxgroup', Ext.form.CheckboxGroup);
38023 Ext.form.Radio = Ext.extend(Ext.form.Checkbox, {
38024 inputType: 'radio',
38027 markInvalid : Ext.emptyFn,
38029 clearInvalid : Ext.emptyFn,
38032 getGroupValue : function(){
38033 var p = this.el.up('form') || Ext.getBody();
38034 var c = p.child('input[name='+this.el.dom.name+']:checked', true);
38035 return c ? c.value : null;
38039 onClick : function(){
38040 if(this.el.dom.checked != this.checked){
38041 var els = this.getCheckEl().select('input[name=' + this.el.dom.name + ']');
38042 els.each(function(el){
38043 if(el.dom.id == this.id){
38044 this.setValue(true);
38046 Ext.getCmp(el.dom.id).setValue(false);
38053 setValue : function(v){
38054 if (typeof v == 'boolean') {
38055 Ext.form.Radio.superclass.setValue.call(this, v);
38057 var r = this.getCheckEl().child('input[name=' + this.el.dom.name + '][value=' + v + ']', true);
38059 Ext.getCmp(r.id).setValue(true);
38066 getCheckEl: function(){
38068 return this.el.up('.x-form-radio-group')
38070 return this.el.up('form') || Ext.getBody();
38073 Ext.reg('radio', Ext.form.Radio);
38075 Ext.form.RadioGroup = Ext.extend(Ext.form.CheckboxGroup, {
38080 blankText : 'You must select one item in this group',
38083 defaultType : 'radio',
38086 groupCls : 'x-form-radio-group',
38091 getValue : function(){
38093 this.eachItem(function(item){
38103 onSetValue : function(id, value){
38104 if(arguments.length > 1){
38105 var f = this.getBox(id);
38109 this.eachItem(function(item){
38111 item.setValue(false);
38117 this.setValueForItem(id);
38121 setValueForItem : function(val){
38122 val = String(val).split(',')[0];
38123 this.eachItem(function(item){
38124 item.setValue(val == item.inputValue);
38129 fireChecked : function(){
38130 if(!this.checkTask){
38131 this.checkTask = new Ext.util.DelayedTask(this.bufferChecked, this);
38133 this.checkTask.delay(10);
38137 bufferChecked : function(){
38139 this.eachItem(function(item){
38145 this.fireEvent('change', this, out);
38148 onDestroy : function(){
38149 if(this.checkTask){
38150 this.checkTask.cancel();
38151 this.checkTask = null;
38153 Ext.form.RadioGroup.superclass.onDestroy.call(this);
38158 Ext.reg('radiogroup', Ext.form.RadioGroup);
38160 Ext.form.Hidden = Ext.extend(Ext.form.Field, {
38162 inputType : 'hidden',
38165 onRender : function(){
38166 Ext.form.Hidden.superclass.onRender.apply(this, arguments);
38170 initEvents : function(){
38171 this.originalValue = this.getValue();
38175 setSize : Ext.emptyFn,
38176 setWidth : Ext.emptyFn,
38177 setHeight : Ext.emptyFn,
38178 setPosition : Ext.emptyFn,
38179 setPagePosition : Ext.emptyFn,
38180 markInvalid : Ext.emptyFn,
38181 clearInvalid : Ext.emptyFn
38183 Ext.reg('hidden', Ext.form.Hidden);
38184 Ext.form.BasicForm = function(el, config){
38185 Ext.apply(this, config);
38186 if(Ext.isString(this.paramOrder)){
38187 this.paramOrder = this.paramOrder.split(/[\s,|]/);
38190 this.items = new Ext.util.MixedCollection(false, function(o){
38191 return o.getItemId();
38205 Ext.form.BasicForm.superclass.constructor.call(this);
38208 Ext.extend(Ext.form.BasicForm, Ext.util.Observable, {
38221 paramOrder: undefined,
38224 paramsAsHash: false,
38227 waitTitle: 'Please Wait...',
38230 activeAction : null,
38233 trackResetOnLoad : false,
38239 initEl : function(el){
38240 this.el = Ext.get(el);
38241 this.id = this.el.id || Ext.id();
38242 if(!this.standardSubmit){
38243 this.el.on('submit', this.onSubmit, this);
38245 this.el.addClass('x-form');
38254 onSubmit : function(e){
38259 destroy: function() {
38260 this.items.each(function(f){
38264 this.el.removeAllListeners();
38267 this.purgeListeners();
38271 isValid : function(){
38273 this.items.each(function(f){
38282 isDirty : function(){
38284 this.items.each(function(f){
38294 doAction : function(action, options){
38295 if(Ext.isString(action)){
38296 action = new Ext.form.Action.ACTION_TYPES[action](this, options);
38298 if(this.fireEvent('beforeaction', this, action) !== false){
38299 this.beforeAction(action);
38300 action.run.defer(100, action);
38306 submit : function(options){
38307 if(this.standardSubmit){
38308 var v = this.isValid();
38310 var el = this.el.dom;
38311 if(this.url && Ext.isEmpty(el.action)){
38312 el.action = this.url;
38318 var submitAction = String.format('{0}submit', this.api ? 'direct' : '');
38319 this.doAction(submitAction, options);
38324 load : function(options){
38325 var loadAction = String.format('{0}load', this.api ? 'direct' : '');
38326 this.doAction(loadAction, options);
38331 updateRecord : function(record){
38332 record.beginEdit();
38333 var fs = record.fields;
38334 fs.each(function(f){
38335 var field = this.findField(f.name);
38337 record.set(f.name, field.getValue());
38345 loadRecord : function(record){
38346 this.setValues(record.data);
38351 beforeAction : function(action){
38352 var o = action.options;
38354 if(this.waitMsgTarget === true){
38355 this.el.mask(o.waitMsg, 'x-mask-loading');
38356 }else if(this.waitMsgTarget){
38357 this.waitMsgTarget = Ext.get(this.waitMsgTarget);
38358 this.waitMsgTarget.mask(o.waitMsg, 'x-mask-loading');
38360 Ext.MessageBox.wait(o.waitMsg, o.waitTitle || this.waitTitle);
38366 afterAction : function(action, success){
38367 this.activeAction = null;
38368 var o = action.options;
38370 if(this.waitMsgTarget === true){
38372 }else if(this.waitMsgTarget){
38373 this.waitMsgTarget.unmask();
38375 Ext.MessageBox.updateProgress(1);
38376 Ext.MessageBox.hide();
38383 Ext.callback(o.success, o.scope, [this, action]);
38384 this.fireEvent('actioncomplete', this, action);
38386 Ext.callback(o.failure, o.scope, [this, action]);
38387 this.fireEvent('actionfailed', this, action);
38392 findField : function(id){
38393 var field = this.items.get(id);
38394 if(!Ext.isObject(field)){
38395 this.items.each(function(f){
38396 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
38402 return field || null;
38407 markInvalid : function(errors){
38408 if(Ext.isArray(errors)){
38409 for(var i = 0, len = errors.length; i < len; i++){
38410 var fieldError = errors[i];
38411 var f = this.findField(fieldError.id);
38413 f.markInvalid(fieldError.msg);
38419 if(!Ext.isFunction(errors[id]) && (field = this.findField(id))){
38420 field.markInvalid(errors[id]);
38428 setValues : function(values){
38429 if(Ext.isArray(values)){
38430 for(var i = 0, len = values.length; i < len; i++){
38432 var f = this.findField(v.id);
38434 f.setValue(v.value);
38435 if(this.trackResetOnLoad){
38436 f.originalValue = f.getValue();
38443 if(!Ext.isFunction(values[id]) && (field = this.findField(id))){
38444 field.setValue(values[id]);
38445 if(this.trackResetOnLoad){
38446 field.originalValue = field.getValue();
38455 getValues : function(asString){
38456 var fs = Ext.lib.Ajax.serializeForm(this.el.dom);
38457 if(asString === true){
38460 return Ext.urlDecode(fs);
38464 getFieldValues : function(dirtyOnly){
38469 this.items.each(function(f){
38470 if(dirtyOnly !== true || f.isDirty()){
38473 val = f.getValue();
38475 if(Ext.isDefined(key)){
38476 if(Ext.isArray(key)){
38490 clearInvalid : function(){
38491 this.items.each(function(f){
38498 reset : function(){
38499 this.items.each(function(f){
38507 this.items.addAll(Array.prototype.slice.call(arguments, 0));
38513 remove : function(field){
38514 this.items.remove(field);
38519 render : function(){
38520 this.items.each(function(f){
38521 if(f.isFormField && !f.rendered && document.getElementById(f.id)){
38522 f.applyToMarkup(f.id);
38529 applyToFields : function(o){
38530 this.items.each(function(f){
38537 applyIfToFields : function(o){
38538 this.items.each(function(f){
38544 callFieldMethod : function(fnName, args){
38546 this.items.each(function(f){
38547 if(Ext.isFunction(f[fnName])){
38548 f[fnName].apply(f, args);
38556 Ext.BasicForm = Ext.form.BasicForm;
38557 Ext.FormPanel = Ext.extend(Ext.Panel, {
38568 minButtonWidth : 75,
38571 labelAlign : 'left',
38574 monitorValid : false,
38583 initComponent : function(){
38584 this.form = this.createForm();
38585 Ext.FormPanel.superclass.initComponent.call(this);
38589 cls: this.baseCls + '-body',
38590 method : this.method || 'POST',
38591 id : this.formId || Ext.id()
38593 if(this.fileUpload) {
38594 this.bodyCfg.enctype = 'multipart/form-data';
38603 this.relayEvents(this.form, ['beforeaction', 'actionfailed', 'actioncomplete']);
38607 createForm : function(){
38608 var config = Ext.applyIf({listeners: {}}, this.initialConfig);
38609 return new Ext.form.BasicForm(null, config);
38613 initFields : function(){
38615 var formPanel = this;
38616 var fn = function(c){
38617 if(formPanel.isField(c)){
38619 }else if(c.findBy && c != formPanel){
38620 formPanel.applySettings(c);
38622 if(c.items && c.items.each){
38623 c.items.each(fn, this);
38627 this.items.each(fn, this);
38631 applySettings: function(c){
38632 var ct = c.ownerCt;
38634 labelAlign: ct.labelAlign,
38635 labelWidth: ct.labelWidth,
38636 itemCls: ct.itemCls
38641 getLayoutTarget : function(){
38642 return this.form.el;
38646 getForm : function(){
38651 onRender : function(ct, position){
38653 Ext.FormPanel.superclass.onRender.call(this, ct, position);
38654 this.form.initEl(this.body);
38658 beforeDestroy : function(){
38659 this.stopMonitoring();
38661 Ext.destroy(this.form);
38662 this.form.items.clear();
38663 Ext.FormPanel.superclass.beforeDestroy.call(this);
38667 isField : function(c) {
38668 return !!c.setValue && !!c.getValue && !!c.markInvalid && !!c.clearInvalid;
38672 initEvents : function(){
38673 Ext.FormPanel.superclass.initEvents.call(this);
38677 add: this.onAddEvent,
38678 remove: this.onRemoveEvent
38680 if(this.monitorValid){
38681 this.startMonitoring();
38686 onAdd: function(c){
38687 Ext.FormPanel.superclass.onAdd.call(this, c);
38688 this.processAdd(c);
38692 onAddEvent: function(ct, c){
38694 this.processAdd(c);
38699 processAdd : function(c){
38701 if(this.isField(c)){
38704 }else if(c.findBy){
38705 this.applySettings(c);
38706 this.form.add.apply(this.form, c.findBy(this.isField));
38711 onRemove: function(c){
38712 Ext.FormPanel.superclass.onRemove.call(this, c);
38713 this.processRemove(c);
38716 onRemoveEvent: function(ct, c){
38718 this.processRemove(c);
38723 processRemove : function(c){
38725 if(this.isField(c)){
38726 this.form.remove(c);
38728 }else if(c.findBy){
38729 var isDestroyed = function(o) {
38730 return !!o.isDestroyed;
38732 this.form.items.filterBy(isDestroyed, this.form).each(this.form.remove, this.form);
38737 startMonitoring : function(){
38738 if(!this.validTask){
38739 this.validTask = new Ext.util.TaskRunner();
38740 this.validTask.start({
38741 run : this.bindHandler,
38742 interval : this.monitorPoll || 200,
38749 stopMonitoring : function(){
38750 if(this.validTask){
38751 this.validTask.stopAll();
38752 this.validTask = null;
38758 this.form.load.apply(this.form, arguments);
38762 onDisable : function(){
38763 Ext.FormPanel.superclass.onDisable.call(this);
38765 this.form.items.each(function(){
38772 onEnable : function(){
38773 Ext.FormPanel.superclass.onEnable.call(this);
38775 this.form.items.each(function(){
38782 bindHandler : function(){
38784 this.form.items.each(function(f){
38785 if(!f.isValid(true)){
38791 var fitems = this.fbar.items.items;
38792 for(var i = 0, len = fitems.length; i < len; i++){
38793 var btn = fitems[i];
38794 if(btn.formBind === true && btn.disabled === valid){
38795 btn.setDisabled(!valid);
38799 this.fireEvent('clientvalidation', this, valid);
38802 Ext.reg('form', Ext.FormPanel);
38804 Ext.form.FormPanel = Ext.FormPanel;
38806 Ext.form.FieldSet = Ext.extend(Ext.Panel, {
38813 baseCls : 'x-fieldset',
38817 animCollapse : false,
38820 onRender : function(ct, position){
38822 this.el = document.createElement('fieldset');
38823 this.el.id = this.id;
38824 if (this.title || this.header || this.checkboxToggle) {
38825 this.el.appendChild(document.createElement('legend')).className = 'x-fieldset-header';
38829 Ext.form.FieldSet.superclass.onRender.call(this, ct, position);
38831 if(this.checkboxToggle){
38832 var o = typeof this.checkboxToggle == 'object' ?
38833 this.checkboxToggle :
38834 {tag: 'input', type: 'checkbox', name: this.checkboxName || this.id+'-checkbox'};
38835 this.checkbox = this.header.insertFirst(o);
38836 this.checkbox.dom.checked = !this.collapsed;
38837 this.mon(this.checkbox, 'click', this.onCheckClick, this);
38842 onCollapse : function(doAnim, animArg){
38844 this.checkbox.dom.checked = false;
38846 Ext.form.FieldSet.superclass.onCollapse.call(this, doAnim, animArg);
38851 onExpand : function(doAnim, animArg){
38853 this.checkbox.dom.checked = true;
38855 Ext.form.FieldSet.superclass.onExpand.call(this, doAnim, animArg);
38859 onCheckClick : function(){
38860 this[this.checkbox.dom.checked ? 'expand' : 'collapse']();
38898 Ext.reg('fieldset', Ext.form.FieldSet);
38901 Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, {
38903 enableFormat : true,
38905 enableFontSize : true,
38907 enableColors : true,
38909 enableAlignments : true,
38911 enableLists : true,
38913 enableSourceEdit : true,
38915 enableLinks : true,
38919 createLinkText : 'Please enter the URL for the link:',
38921 defaultLinkValue : 'http:/'+'/',
38930 defaultFont: 'tahoma',
38932 defaultValue: (Ext.isOpera || Ext.isIE6) ? ' ' : '​',
38935 actionMode: 'wrap',
38936 validationEvent : false,
38938 initialized : false,
38940 sourceEditMode : false,
38941 onFocus : Ext.emptyFn,
38943 hideMode:'offsets',
38944 defaultAutoCreate : {
38946 style:"width:500px;height:300px;",
38947 autocomplete: "off"
38951 initComponent : function(){
38971 createFontOptions : function(){
38972 var buf = [], fs = this.fontFamilies, ff, lc;
38973 for(var i = 0, len = fs.length; i< len; i++){
38975 lc = ff.toLowerCase();
38977 '<option value="',lc,'" style="font-family:',ff,';"',
38978 (this.defaultFont == lc ? ' selected="true">' : '>'),
38983 return buf.join('');
38987 createToolbar : function(editor){
38989 var tipsEnabled = Ext.QuickTips && Ext.QuickTips.isEnabled();
38992 function btn(id, toggle, handler){
38995 cls : 'x-btn-icon',
38996 iconCls: 'x-edit-'+id,
38997 enableToggle:toggle !== false,
38999 handler:handler||editor.relayBtnCmd,
39000 clickEvent:'mousedown',
39001 tooltip: tipsEnabled ? editor.buttonTips[id] || undefined : undefined,
39002 overflowText: editor.buttonTips[id].title || undefined,
39008 if(this.enableFont && !Ext.isSafari2){
39009 var fontSelectItem = new Ext.Toolbar.Item({
39012 cls:'x-font-select',
39013 html: this.createFontOptions()
39023 if(this.enableFormat){
39031 if(this.enableFontSize){
39034 btn('increasefontsize', false, this.adjustFont),
39035 btn('decreasefontsize', false, this.adjustFont)
39039 if(this.enableColors){
39042 itemId:'forecolor',
39044 iconCls: 'x-edit-forecolor',
39045 clickEvent:'mousedown',
39046 tooltip: tipsEnabled ? editor.buttonTips.forecolor || undefined : undefined,
39048 menu : new Ext.menu.ColorMenu({
39049 allowReselect: true,
39050 focus: Ext.emptyFn,
39055 select: function(cp, color){
39056 this.execCmd('forecolor', Ext.isWebKit || Ext.isIE ? '#'+color : color);
39060 clickEvent:'mousedown'
39063 itemId:'backcolor',
39065 iconCls: 'x-edit-backcolor',
39066 clickEvent:'mousedown',
39067 tooltip: tipsEnabled ? editor.buttonTips.backcolor || undefined : undefined,
39069 menu : new Ext.menu.ColorMenu({
39070 focus: Ext.emptyFn,
39073 allowReselect: true,
39076 select: function(cp, color){
39078 this.execCmd('useCSS', false);
39079 this.execCmd('hilitecolor', color);
39080 this.execCmd('useCSS', true);
39083 this.execCmd(Ext.isOpera ? 'hilitecolor' : 'backcolor', Ext.isWebKit || Ext.isIE ? '#'+color : color);
39088 clickEvent:'mousedown'
39094 if(this.enableAlignments){
39097 btn('justifyleft'),
39098 btn('justifycenter'),
39099 btn('justifyright')
39103 if(!Ext.isSafari2){
39104 if(this.enableLinks){
39107 btn('createlink', false, this.createLink)
39111 if(this.enableLists){
39114 btn('insertorderedlist'),
39115 btn('insertunorderedlist')
39118 if(this.enableSourceEdit){
39121 btn('sourceedit', true, function(btn){
39122 this.toggleSourceEdit(!this.sourceEditMode);
39129 var tb = new Ext.Toolbar({
39130 renderTo: this.wrap.dom.firstChild,
39134 if (fontSelectItem) {
39135 this.fontSelect = fontSelectItem.el;
39137 this.mon(this.fontSelect, 'change', function(){
39138 var font = this.fontSelect.dom.value;
39139 this.relayCmd('fontname', font);
39146 this.mon(tb.el, 'click', function(e){
39147 e.preventDefault();
39155 onDisable: function(){
39157 Ext.form.HtmlEditor.superclass.onDisable.call(this);
39160 onEnable: function(){
39161 this.wrap.unmask();
39162 Ext.form.HtmlEditor.superclass.onEnable.call(this);
39165 setReadOnly: function(readOnly){
39166 if(this.initialized){
39167 var newDM = readOnly ? 'off' : 'on',
39168 doc = this.getDoc();
39169 if(String(doc.designMode).toLowerCase() != newDM){
39170 doc.designMode = newDM;
39172 this.disableItems(!readOnly);
39174 Ext.form.HtmlEditor.superclass.setReadOnly.call(this, readOnly);
39178 getDocMarkup : function(){
39179 return '<html><head><style type="text/css">body{border:0;margin:0;padding:3px;height:98%;cursor:text;}</style></head><body></body></html>';
39183 getEditorBody : function(){
39184 var doc = this.getDoc();
39185 return doc.body || doc.documentElement;
39189 getDoc : function(){
39190 return Ext.isIE ? this.getWin().document : (this.iframe.contentDocument || this.getWin().document);
39194 getWin : function(){
39195 return Ext.isIE ? this.iframe.contentWindow : window.frames[this.iframe.name];
39199 onRender : function(ct, position){
39200 Ext.form.HtmlEditor.superclass.onRender.call(this, ct, position);
39201 this.el.dom.style.border = '0 none';
39202 this.el.dom.setAttribute('tabIndex', -1);
39203 this.el.addClass('x-hidden');
39205 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
39207 this.wrap = this.el.wrap({
39208 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
39211 this.createToolbar(this);
39213 this.disableItems(true);
39217 this.createIFrame();
39220 var sz = this.el.getSize();
39221 this.setSize(sz.width, this.height || sz.height);
39223 this.resizeEl = this.positionEl = this.wrap;
39226 createIFrame: function(){
39227 var iframe = document.createElement('iframe');
39228 iframe.name = Ext.id();
39229 iframe.frameBorder = '0';
39230 iframe.src = Ext.SSL_SECURE_URL;
39231 this.wrap.dom.appendChild(iframe);
39233 this.iframe = iframe;
39235 this.monitorTask = Ext.TaskMgr.start({
39236 run: this.checkDesignMode,
39242 initFrame : function(){
39243 Ext.TaskMgr.stop(this.monitorTask);
39244 var doc = this.getDoc();
39245 this.win = this.getWin();
39248 doc.write(this.getDocMarkup());
39253 var doc = this.getDoc();
39254 if(doc.body || doc.readyState == 'complete'){
39255 Ext.TaskMgr.stop(task);
39256 doc.designMode="on";
39257 this.initEditor.defer(10, this);
39264 Ext.TaskMgr.start(task);
39268 checkDesignMode : function(){
39269 if(this.wrap && this.wrap.dom.offsetWidth){
39270 var doc = this.getDoc();
39274 if(!doc.editorInitialized || String(doc.designMode).toLowerCase() != 'on'){
39280 disableItems: function(disabled){
39281 if(this.fontSelect){
39282 this.fontSelect.dom.disabled = disabled;
39284 this.tb.items.each(function(item){
39285 if(item.getItemId() != 'sourceedit'){
39286 item.setDisabled(disabled);
39292 onResize : function(w, h){
39293 Ext.form.HtmlEditor.superclass.onResize.apply(this, arguments);
39294 if(this.el && this.iframe){
39295 if(Ext.isNumber(w)){
39296 var aw = w - this.wrap.getFrameWidth('lr');
39297 this.el.setWidth(aw);
39298 this.tb.setWidth(aw);
39299 this.iframe.style.width = Math.max(aw, 0) + 'px';
39301 if(Ext.isNumber(h)){
39302 var ah = h - this.wrap.getFrameWidth('tb') - this.tb.el.getHeight();
39303 this.el.setHeight(ah);
39304 this.iframe.style.height = Math.max(ah, 0) + 'px';
39305 var bd = this.getEditorBody();
39307 bd.style.height = Math.max((ah - (this.iframePad*2)), 0) + 'px';
39314 toggleSourceEdit : function(sourceEditMode){
39315 if(sourceEditMode === undefined){
39316 sourceEditMode = !this.sourceEditMode;
39318 this.sourceEditMode = sourceEditMode === true;
39319 var btn = this.tb.getComponent('sourceedit');
39321 if(btn.pressed !== this.sourceEditMode){
39322 btn.toggle(this.sourceEditMode);
39323 if(!btn.xtbHidden){
39327 if(this.sourceEditMode){
39328 this.disableItems(true);
39330 this.iframe.className = 'x-hidden';
39331 this.el.removeClass('x-hidden');
39332 this.el.dom.removeAttribute('tabIndex');
39335 if(this.initialized && !this.readOnly){
39336 this.disableItems(false);
39339 this.iframe.className = '';
39340 this.el.addClass('x-hidden');
39341 this.el.dom.setAttribute('tabIndex', -1);
39344 var lastSize = this.lastSize;
39346 delete this.lastSize;
39347 this.setSize(lastSize);
39349 this.fireEvent('editmodechange', this, this.sourceEditMode);
39353 createLink : function(){
39354 var url = prompt(this.createLinkText, this.defaultLinkValue);
39355 if(url && url != 'http:/'+'/'){
39356 this.relayCmd('createlink', url);
39361 initEvents : function(){
39362 this.originalValue = this.getValue();
39366 markInvalid : Ext.emptyFn,
39369 clearInvalid : Ext.emptyFn,
39372 setValue : function(v){
39373 Ext.form.HtmlEditor.superclass.setValue.call(this, v);
39379 cleanHtml: function(html) {
39380 html = String(html);
39382 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
39386 if(html.charCodeAt(0) == this.defaultValue.replace(/\D/g, '')){
39387 html = html.substring(1);
39393 syncValue : function(){
39394 if(this.initialized){
39395 var bd = this.getEditorBody();
39396 var html = bd.innerHTML;
39398 var bs = bd.getAttribute('style');
39399 var m = bs.match(/text-align:(.*?);/i);
39401 html = '<div style="'+m[0]+'">' + html + '</div>';
39404 html = this.cleanHtml(html);
39405 if(this.fireEvent('beforesync', this, html) !== false){
39406 this.el.dom.value = html;
39407 this.fireEvent('sync', this, html);
39413 getValue : function() {
39414 this[this.sourceEditMode ? 'pushValue' : 'syncValue']();
39415 return Ext.form.HtmlEditor.superclass.getValue.call(this);
39419 pushValue : function(){
39420 if(this.initialized){
39421 var v = this.el.dom.value;
39422 if(!this.activated && v.length < 1){
39423 v = this.defaultValue;
39425 if(this.fireEvent('beforepush', this, v) !== false){
39426 this.getEditorBody().innerHTML = v;
39429 var d = this.getDoc(),
39430 mode = d.designMode.toLowerCase();
39432 d.designMode = mode.toggle('on', 'off');
39433 d.designMode = mode;
39435 this.fireEvent('push', this, v);
39441 deferFocus : function(){
39442 this.focus.defer(10, this);
39446 focus : function(){
39447 if(this.win && !this.sourceEditMode){
39455 initEditor : function(){
39458 var dbody = this.getEditorBody(),
39459 ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat'),
39463 ss['background-attachment'] = 'fixed';
39464 dbody.bgProperties = 'fixed';
39466 Ext.DomHelper.applyStyles(dbody, ss);
39468 doc = this.getDoc();
39472 Ext.EventManager.removeAll(doc);
39477 fn = this.onEditorEvent.createDelegate(this);
39478 Ext.EventManager.on(doc, {
39487 Ext.EventManager.on(doc, 'keypress', this.applyCommand, this);
39489 if(Ext.isIE || Ext.isWebKit || Ext.isOpera){
39490 Ext.EventManager.on(doc, 'keydown', this.fixKeys, this);
39492 doc.editorInitialized = true;
39493 this.initialized = true;
39495 this.setReadOnly(this.readOnly);
39496 this.fireEvent('initialize', this);
39501 onDestroy : function(){
39502 if(this.monitorTask){
39503 Ext.TaskMgr.stop(this.monitorTask);
39506 Ext.destroy(this.tb);
39507 var doc = this.getDoc();
39510 Ext.EventManager.removeAll(doc);
39511 for (var prop in doc){
39517 this.wrap.dom.innerHTML = '';
39518 this.wrap.remove();
39523 this.el.removeAllListeners();
39526 this.purgeListeners();
39530 onFirstFocus : function(){
39531 this.activated = true;
39532 this.disableItems(false);
39535 var s = this.win.getSelection();
39536 if(!s.focusNode || s.focusNode.nodeType != 3){
39537 var r = s.getRangeAt(0);
39538 r.selectNodeContents(this.getEditorBody());
39543 this.execCmd('useCSS', true);
39544 this.execCmd('styleWithCSS', false);
39547 this.fireEvent('activate', this);
39551 adjustFont: function(btn){
39552 var adjust = btn.getItemId() == 'increasefontsize' ? 1 : -1,
39553 doc = this.getDoc(),
39554 v = parseInt(doc.queryCommandValue('FontSize') || 2, 10);
39555 if((Ext.isSafari && !Ext.isSafari2) || Ext.isChrome || Ext.isAir){
39571 v = v.constrain(1, 6);
39576 v = Math.max(1, v+adjust) + (Ext.isSafari ? 'px' : 0);
39578 this.execCmd('FontSize', v);
39582 onEditorEvent : function(e){
39583 this.updateToolbar();
39588 updateToolbar: function(){
39594 if(!this.activated){
39595 this.onFirstFocus();
39599 var btns = this.tb.items.map,
39600 doc = this.getDoc();
39602 if(this.enableFont && !Ext.isSafari2){
39603 var name = (doc.queryCommandValue('FontName')||this.defaultFont).toLowerCase();
39604 if(name != this.fontSelect.dom.value){
39605 this.fontSelect.dom.value = name;
39608 if(this.enableFormat){
39609 btns.bold.toggle(doc.queryCommandState('bold'));
39610 btns.italic.toggle(doc.queryCommandState('italic'));
39611 btns.underline.toggle(doc.queryCommandState('underline'));
39613 if(this.enableAlignments){
39614 btns.justifyleft.toggle(doc.queryCommandState('justifyleft'));
39615 btns.justifycenter.toggle(doc.queryCommandState('justifycenter'));
39616 btns.justifyright.toggle(doc.queryCommandState('justifyright'));
39618 if(!Ext.isSafari2 && this.enableLists){
39619 btns.insertorderedlist.toggle(doc.queryCommandState('insertorderedlist'));
39620 btns.insertunorderedlist.toggle(doc.queryCommandState('insertunorderedlist'));
39623 Ext.menu.MenuMgr.hideAll();
39629 relayBtnCmd : function(btn){
39630 this.relayCmd(btn.getItemId());
39634 relayCmd : function(cmd, value){
39637 this.execCmd(cmd, value);
39638 this.updateToolbar();
39639 }).defer(10, this);
39643 execCmd : function(cmd, value){
39644 var doc = this.getDoc();
39645 doc.execCommand(cmd, false, value === undefined ? null : value);
39650 applyCommand : function(e){
39652 var c = e.getCharCode(), cmd;
39654 c = String.fromCharCode(c);
39670 e.preventDefault();
39677 insertAtCursor : function(text){
39678 if(!this.activated){
39683 var doc = this.getDoc(),
39684 r = doc.selection.createRange();
39692 this.execCmd('InsertHTML', text);
39698 fixKeys : function(){
39700 return function(e){
39701 var k = e.getKey(),
39702 doc = this.getDoc(),
39706 r = doc.selection.createRange();
39709 r.pasteHTML(' ');
39712 }else if(k == e.ENTER){
39713 r = doc.selection.createRange();
39715 var target = r.parentElement();
39716 if(!target || target.tagName.toLowerCase() != 'li'){
39718 r.pasteHTML('<br />');
39725 }else if(Ext.isOpera){
39726 return function(e){
39727 var k = e.getKey();
39731 this.execCmd('InsertHTML',' ');
39735 }else if(Ext.isWebKit){
39736 return function(e){
39737 var k = e.getKey();
39740 this.execCmd('InsertText','\t');
39742 }else if(k == e.ENTER){
39744 this.execCmd('InsertHtml','<br /><br />');
39752 getToolbar : function(){
39759 title: 'Bold (Ctrl+B)',
39760 text: 'Make the selected text bold.',
39761 cls: 'x-html-editor-tip'
39764 title: 'Italic (Ctrl+I)',
39765 text: 'Make the selected text italic.',
39766 cls: 'x-html-editor-tip'
39769 title: 'Underline (Ctrl+U)',
39770 text: 'Underline the selected text.',
39771 cls: 'x-html-editor-tip'
39773 increasefontsize : {
39774 title: 'Grow Text',
39775 text: 'Increase the font size.',
39776 cls: 'x-html-editor-tip'
39778 decreasefontsize : {
39779 title: 'Shrink Text',
39780 text: 'Decrease the font size.',
39781 cls: 'x-html-editor-tip'
39784 title: 'Text Highlight Color',
39785 text: 'Change the background color of the selected text.',
39786 cls: 'x-html-editor-tip'
39789 title: 'Font Color',
39790 text: 'Change the color of the selected text.',
39791 cls: 'x-html-editor-tip'
39794 title: 'Align Text Left',
39795 text: 'Align text to the left.',
39796 cls: 'x-html-editor-tip'
39799 title: 'Center Text',
39800 text: 'Center text in the editor.',
39801 cls: 'x-html-editor-tip'
39804 title: 'Align Text Right',
39805 text: 'Align text to the right.',
39806 cls: 'x-html-editor-tip'
39808 insertunorderedlist : {
39809 title: 'Bullet List',
39810 text: 'Start a bulleted list.',
39811 cls: 'x-html-editor-tip'
39813 insertorderedlist : {
39814 title: 'Numbered List',
39815 text: 'Start a numbered list.',
39816 cls: 'x-html-editor-tip'
39819 title: 'Hyperlink',
39820 text: 'Make the selected text a hyperlink.',
39821 cls: 'x-html-editor-tip'
39824 title: 'Source Edit',
39825 text: 'Switch to source editing mode.',
39826 cls: 'x-html-editor-tip'
39865 Ext.reg('htmleditor', Ext.form.HtmlEditor);
39866 Ext.form.TimeField = Ext.extend(Ext.form.ComboBox, {
39868 minValue : undefined,
39870 maxValue : undefined,
39872 minText : "The time in this field must be equal to or after {0}",
39874 maxText : "The time in this field must be equal to or before {0}",
39876 invalidText : "{0} is not a valid time",
39880 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",
39887 triggerAction: 'all',
39894 initDate: '1/1/2008',
39897 initComponent : function(){
39898 if(Ext.isDefined(this.minValue)){
39899 this.setMinValue(this.minValue, true);
39901 if(Ext.isDefined(this.maxValue)){
39902 this.setMaxValue(this.maxValue, true);
39905 this.generateStore(true);
39907 Ext.form.TimeField.superclass.initComponent.call(this);
39911 setMinValue: function(value, initial){
39912 this.setLimit(value, true, initial);
39917 setMaxValue: function(value, initial){
39918 this.setLimit(value, false, initial);
39923 generateStore: function(initial){
39924 var min = this.minValue || new Date(this.initDate).clearTime(),
39925 max = this.maxValue || new Date(this.initDate).clearTime().add('mi', (24 * 60) - 1),
39929 times.push(min.dateFormat(this.format));
39930 min = min.add('mi', this.increment);
39932 this.bindStore(times, initial);
39936 setLimit: function(value, isMin, initial){
39938 if(Ext.isString(value)){
39939 d = this.parseDate(value);
39940 }else if(Ext.isDate(value)){
39944 var val = new Date(this.initDate).clearTime();
39945 val.setHours(d.getHours(), d.getMinutes(), isMin ? 0 : 59, 0);
39946 this[isMin ? 'minValue' : 'maxValue'] = val;
39948 this.generateStore();
39954 getValue : function(){
39955 var v = Ext.form.TimeField.superclass.getValue.call(this);
39956 return this.formatDate(this.parseDate(v)) || '';
39960 setValue : function(value){
39961 return Ext.form.TimeField.superclass.setValue.call(this, this.formatDate(this.parseDate(value)));
39965 validateValue : Ext.form.DateField.prototype.validateValue,
39966 parseDate : Ext.form.DateField.prototype.parseDate,
39967 formatDate : Ext.form.DateField.prototype.formatDate,
39970 beforeBlur : function(){
39971 var v = this.parseDate(this.getRawValue());
39973 this.setValue(v.dateFormat(this.format));
39975 Ext.form.TimeField.superclass.beforeBlur.call(this);
39983 Ext.reg('timefield', Ext.form.TimeField);
39984 Ext.form.Label = Ext.extend(Ext.BoxComponent, {
39990 onRender : function(ct, position){
39992 this.el = document.createElement('label');
39993 this.el.id = this.getId();
39994 this.el.innerHTML = this.text ? Ext.util.Format.htmlEncode(this.text) : (this.html || '');
39996 this.el.setAttribute('for', this.forId);
39999 Ext.form.Label.superclass.onRender.call(this, ct, position);
40003 setText : function(t, encode){
40004 var e = encode === false;
40005 this[!e ? 'text' : 'html'] = t;
40006 delete this[e ? 'text' : 'html'];
40008 this.el.dom.innerHTML = encode !== false ? Ext.util.Format.htmlEncode(t) : t;
40014 Ext.reg('label', Ext.form.Label);
40015 Ext.form.Action = function(form, options){
40017 this.options = options || {};
40021 Ext.form.Action.CLIENT_INVALID = 'client';
40023 Ext.form.Action.SERVER_INVALID = 'server';
40025 Ext.form.Action.CONNECT_FAILURE = 'connect';
40027 Ext.form.Action.LOAD_FAILURE = 'load';
40029 Ext.form.Action.prototype = {
40048 run : function(options){
40053 success : function(response){
40058 handleResponse : function(response){
40063 failure : function(response){
40064 this.response = response;
40065 this.failureType = Ext.form.Action.CONNECT_FAILURE;
40066 this.form.afterAction(this, false);
40072 processResponse : function(response){
40073 this.response = response;
40074 if(!response.responseText && !response.responseXML){
40077 this.result = this.handleResponse(response);
40078 return this.result;
40082 getUrl : function(appendParams){
40083 var url = this.options.url || this.form.url || this.form.el.dom.action;
40085 var p = this.getParams();
40087 url = Ext.urlAppend(url, p);
40094 getMethod : function(){
40095 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
40099 getParams : function(){
40100 var bp = this.form.baseParams;
40101 var p = this.options.params;
40103 if(typeof p == "object"){
40104 p = Ext.urlEncode(Ext.applyIf(p, bp));
40105 }else if(typeof p == 'string' && bp){
40106 p += '&' + Ext.urlEncode(bp);
40109 p = Ext.urlEncode(bp);
40115 createCallback : function(opts){
40116 var opts = opts || {};
40118 success: this.success,
40119 failure: this.failure,
40121 timeout: (opts.timeout*1000) || (this.form.timeout*1000),
40122 upload: this.form.fileUpload ? this.success : undefined
40128 Ext.form.Action.Submit = function(form, options){
40129 Ext.form.Action.Submit.superclass.constructor.call(this, form, options);
40132 Ext.extend(Ext.form.Action.Submit, Ext.form.Action, {
40139 var o = this.options;
40140 var method = this.getMethod();
40141 var isGet = method == 'GET';
40142 if(o.clientValidation === false || this.form.isValid()){
40143 Ext.Ajax.request(Ext.apply(this.createCallback(o), {
40144 form:this.form.el.dom,
40145 url:this.getUrl(isGet),
40147 headers: o.headers,
40148 params:!isGet ? this.getParams() : null,
40149 isUpload: this.form.fileUpload
40151 }else if (o.clientValidation !== false){
40152 this.failureType = Ext.form.Action.CLIENT_INVALID;
40153 this.form.afterAction(this, false);
40158 success : function(response){
40159 var result = this.processResponse(response);
40160 if(result === true || result.success){
40161 this.form.afterAction(this, true);
40165 this.form.markInvalid(result.errors);
40167 this.failureType = Ext.form.Action.SERVER_INVALID;
40168 this.form.afterAction(this, false);
40172 handleResponse : function(response){
40173 if(this.form.errorReader){
40174 var rs = this.form.errorReader.read(response);
40177 for(var i = 0, len = rs.records.length; i < len; i++) {
40178 var r = rs.records[i];
40179 errors[i] = r.data;
40182 if(errors.length < 1){
40186 success : rs.success,
40190 return Ext.decode(response.responseText);
40196 Ext.form.Action.Load = function(form, options){
40197 Ext.form.Action.Load.superclass.constructor.call(this, form, options);
40198 this.reader = this.form.reader;
40201 Ext.extend(Ext.form.Action.Load, Ext.form.Action, {
40207 Ext.Ajax.request(Ext.apply(
40208 this.createCallback(this.options), {
40209 method:this.getMethod(),
40210 url:this.getUrl(false),
40211 headers: this.options.headers,
40212 params:this.getParams()
40217 success : function(response){
40218 var result = this.processResponse(response);
40219 if(result === true || !result.success || !result.data){
40220 this.failureType = Ext.form.Action.LOAD_FAILURE;
40221 this.form.afterAction(this, false);
40224 this.form.clearInvalid();
40225 this.form.setValues(result.data);
40226 this.form.afterAction(this, true);
40230 handleResponse : function(response){
40231 if(this.form.reader){
40232 var rs = this.form.reader.read(response);
40233 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
40235 success : rs.success,
40239 return Ext.decode(response.responseText);
40246 Ext.form.Action.DirectLoad = Ext.extend(Ext.form.Action.Load, {
40247 constructor: function(form, opts) {
40248 Ext.form.Action.DirectLoad.superclass.constructor.call(this, form, opts);
40250 type : 'directload',
40253 var args = this.getParams();
40254 args.push(this.success, this);
40255 this.form.api.load.apply(window, args);
40258 getParams : function() {
40259 var buf = [], o = {};
40260 var bp = this.form.baseParams;
40261 var p = this.options.params;
40262 Ext.apply(o, p, bp);
40263 var paramOrder = this.form.paramOrder;
40265 for(var i = 0, len = paramOrder.length; i < len; i++){
40266 buf.push(o[paramOrder[i]]);
40268 }else if(this.form.paramsAsHash){
40276 processResponse : function(result) {
40277 this.result = result;
40281 success : function(response, trans){
40282 if(trans.type == Ext.Direct.exceptions.SERVER){
40285 Ext.form.Action.DirectLoad.superclass.success.call(this, response);
40290 Ext.form.Action.DirectSubmit = Ext.extend(Ext.form.Action.Submit, {
40291 constructor : function(form, opts) {
40292 Ext.form.Action.DirectSubmit.superclass.constructor.call(this, form, opts);
40294 type : 'directsubmit',
40297 var o = this.options;
40298 if(o.clientValidation === false || this.form.isValid()){
40301 this.success.params = this.getParams();
40302 this.form.api.submit(this.form.el.dom, this.success, this);
40303 }else if (o.clientValidation !== false){
40304 this.failureType = Ext.form.Action.CLIENT_INVALID;
40305 this.form.afterAction(this, false);
40309 getParams : function() {
40311 var bp = this.form.baseParams;
40312 var p = this.options.params;
40313 Ext.apply(o, p, bp);
40319 processResponse : function(result) {
40320 this.result = result;
40324 success : function(response, trans){
40325 if(trans.type == Ext.Direct.exceptions.SERVER){
40328 Ext.form.Action.DirectSubmit.superclass.success.call(this, response);
40332 Ext.form.Action.ACTION_TYPES = {
40333 'load' : Ext.form.Action.Load,
40334 'submit' : Ext.form.Action.Submit,
40335 'directload' : Ext.form.Action.DirectLoad,
40336 'directsubmit' : Ext.form.Action.DirectSubmit
40339 Ext.form.VTypes = function(){
40341 var alpha = /^[a-zA-Z_]+$/,
40342 alphanum = /^[a-zA-Z0-9_]+$/,
40343 email = /^(\w+)([\-+.][\w]+)*@(\w[\-\w]*\.){1,5}([A-Za-z]){2,6}$/,
40344 url = /(((^https?)|(^ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
40349 'email' : function(v){
40350 return email.test(v);
40353 'emailText' : 'This field should be an e-mail address in the format "user@example.com"',
40355 'emailMask' : /[a-z0-9_\.\-@]/i,
40358 'url' : function(v){
40359 return url.test(v);
40362 'urlText' : 'This field should be a URL in the format "http:/'+'/www.example.com"',
40365 'alpha' : function(v){
40366 return alpha.test(v);
40369 'alphaText' : 'This field should only contain letters and _',
40371 'alphaMask' : /[a-z_]/i,
40374 'alphanum' : function(v){
40375 return alphanum.test(v);
40378 'alphanumText' : 'This field should only contain letters, numbers and _',
40380 'alphanumMask' : /[a-z0-9_]/i
40383 Ext.grid.GridPanel = Ext.extend(Ext.Panel, {
40385 autoExpandColumn : false,
40387 autoExpandMax : 1000,
40389 autoExpandMin : 50,
40391 columnLines : false,
40397 ddText : '{0} selected row{1}',
40399 deferRowRender : true,
40403 enableColumnHide : true,
40405 enableColumnMove : true,
40407 enableDragDrop : false,
40409 enableHdMenu : true,
40415 minColumnWidth : 25,
40420 stripeRows : false,
40422 trackMouseOver : true,
40424 stateEvents : ['columnmove', 'columnresize', 'sortchange'],
40439 initComponent : function(){
40440 Ext.grid.GridPanel.superclass.initComponent.call(this);
40442 if(this.columnLines){
40443 this.cls = (this.cls || '') + ' x-grid-with-col-lines';
40447 this.autoScroll = false;
40448 this.autoWidth = false;
40450 if(Ext.isArray(this.columns)){
40451 this.colModel = new Ext.grid.ColumnModel(this.columns);
40452 delete this.columns;
40457 this.store = this.ds;
40461 this.colModel = this.cm;
40465 this.selModel = this.sm;
40468 this.store = Ext.StoreMgr.lookup(this.store);
40503 'rowbodymousedown',
40506 'containermousedown',
40527 'containerdblclick',
40539 'headercontextmenu',
40541 'groupcontextmenu',
40543 'containercontextmenu',
40545 'rowbodycontextmenu',
40562 onRender : function(ct, position){
40563 Ext.grid.GridPanel.superclass.onRender.apply(this, arguments);
40565 var c = this.getGridEl();
40567 this.el.addClass('x-grid-panel');
40571 mousedown: this.onMouseDown,
40572 click: this.onClick,
40573 dblclick: this.onDblClick,
40574 contextmenu: this.onContextMenu
40577 this.relayEvents(c, ['mousedown','mouseup','mouseover','mouseout','keypress', 'keydown']);
40579 var view = this.getView();
40582 this.getSelectionModel().init(this);
40586 initEvents : function(){
40587 Ext.grid.GridPanel.superclass.initEvents.call(this);
40590 this.loadMask = new Ext.LoadMask(this.bwrap,
40591 Ext.apply({store:this.store}, this.loadMask));
40595 initStateEvents : function(){
40596 Ext.grid.GridPanel.superclass.initStateEvents.call(this);
40597 this.mon(this.colModel, 'hiddenchange', this.saveState, this, {delay: 100});
40600 applyState : function(state){
40601 var cm = this.colModel,
40602 cs = state.columns;
40604 for(var i = 0, len = cs.length; i < len; i++){
40606 c = cm.getColumnById(s.id);
40608 c.hidden = s.hidden;
40610 var oldIndex = cm.getIndexById(s.id);
40612 cm.moveColumn(oldIndex, i);
40617 if(state.sort && this.store){
40618 this.store[this.store.remoteSort ? 'setDefaultSort' : 'sort'](state.sort.field, state.sort.direction);
40620 var o = Ext.apply({}, state);
40623 Ext.grid.GridPanel.superclass.applyState.call(this, o);
40626 getState : function(){
40627 var o = {columns: []};
40628 for(var i = 0, c; (c = this.colModel.config[i]); i++){
40634 o.columns[i].hidden = true;
40638 var ss = this.store.getSortState();
40647 afterRender : function(){
40648 Ext.grid.GridPanel.superclass.afterRender.call(this);
40650 this.on('bodyresize', v.layout, v);
40652 if(this.deferRowRender){
40653 v.afterRender.defer(10, this.view);
40657 this.viewReady = true;
40661 reconfigure : function(store, colModel){
40662 var rendered = this.rendered;
40665 this.loadMask.destroy();
40666 this.loadMask = new Ext.LoadMask(this.bwrap,
40667 Ext.apply({}, {store:store}, this.initialConfig.loadMask));
40671 this.view.initData(store, colModel);
40673 this.store = store;
40674 this.colModel = colModel;
40676 this.view.refresh(true);
40678 this.fireEvent('reconfigure', this, store, colModel);
40682 onDestroy : function(){
40684 Ext.destroy(this.view, this.loadMask);
40685 }else if(this.store && this.store.autoDestroy){
40686 this.store.destroy();
40688 Ext.destroy(this.colModel, this.selModel);
40689 this.store = this.selModel = this.colModel = this.view = this.loadMask = null;
40690 Ext.grid.GridPanel.superclass.onDestroy.call(this);
40694 processEvent : function(name, e){
40695 this.fireEvent(name, e);
40696 var t = e.getTarget(),
40698 header = v.findHeaderIndex(t);
40700 if(header !== false){
40701 this.fireEvent('header' + name, this, header, e);
40703 var row = v.findRowIndex(t),
40707 this.fireEvent('row' + name, this, row, e);
40708 cell = v.findCellIndex(t);
40709 body = v.findRowBody(t);
40710 if(cell !== false){
40711 this.fireEvent('cell' + name, this, row, cell, e);
40714 this.fireEvent('rowbody' + name, this, row, e);
40717 this.fireEvent('container' + name, this, e);
40720 this.view.processEvent(name, e);
40724 onClick : function(e){
40725 this.processEvent('click', e);
40729 onMouseDown : function(e){
40730 this.processEvent('mousedown', e);
40734 onContextMenu : function(e, t){
40735 this.processEvent('contextmenu', e);
40739 onDblClick : function(e){
40740 this.processEvent('dblclick', e);
40744 walkCells : function(row, col, step, fn, scope){
40745 var cm = this.colModel,
40746 clen = cm.getColumnCount(),
40748 rlen = ds.getCount(),
40761 if(fn.call(scope || this, row, col, cm) === true){
40779 if(fn.call(scope || this, row, col, cm) === true){
40791 onResize : function(){
40792 Ext.grid.GridPanel.superclass.onResize.apply(this, arguments);
40793 if(this.viewReady){
40794 this.view.layout();
40799 getGridEl : function(){
40804 stopEditing : Ext.emptyFn,
40807 getSelectionModel : function(){
40808 if(!this.selModel){
40809 this.selModel = new Ext.grid.RowSelectionModel(
40810 this.disableSelection ? {selectRow: Ext.emptyFn} : null);
40812 return this.selModel;
40816 getStore : function(){
40821 getColumnModel : function(){
40822 return this.colModel;
40826 getView : function(){
40828 this.view = new Ext.grid.GridView(this.viewConfig);
40833 getDragDropText : function(){
40834 var count = this.selModel.getCount();
40835 return String.format(this.ddText, count, count == 1 ? '' : 's');
40889 Ext.reg('grid', Ext.grid.GridPanel);
40890 Ext.grid.GridView = Ext.extend(Ext.util.Observable, {
40897 deferEmptyText : true,
40899 scrollOffset : undefined,
40905 sortClasses : ['sort-asc', 'sort-desc'],
40907 sortAscText : 'Sort Ascending',
40909 sortDescText : 'Sort Descending',
40911 columnsText : 'Columns',
40914 selectedRowClass : 'x-grid3-row-selected',
40918 tdClass : 'x-grid3-cell',
40919 hdCls : 'x-grid3-hd',
40923 cellSelectorDepth : 4,
40925 rowSelectorDepth : 10,
40928 rowBodySelectorDepth : 10,
40931 cellSelector : 'td.x-grid3-cell',
40933 rowSelector : 'div.x-grid3-row',
40936 rowBodySelector : 'div.x-grid3-row-body',
40939 firstRowCls: 'x-grid3-row-first',
40940 lastRowCls: 'x-grid3-row-last',
40941 rowClsRe: /(?:^|\s+)x-grid3-row-(first|last|alt)(?:\s+|$)/g,
40943 constructor : function(config){
40944 Ext.apply(this, config);
40948 'beforerowremoved',
40950 'beforerowsinserted',
40962 Ext.grid.GridView.superclass.constructor.call(this);
40968 initTemplates : function(){
40969 var ts = this.templates || {};
40971 ts.master = new Ext.Template(
40972 '<div class="x-grid3" hidefocus="true">',
40973 '<div class="x-grid3-viewport">',
40974 '<div class="x-grid3-header"><div class="x-grid3-header-inner"><div class="x-grid3-header-offset" style="{ostyle}">{header}</div></div><div class="x-clear"></div></div>',
40975 '<div class="x-grid3-scroller"><div class="x-grid3-body" style="{bstyle}">{body}</div><a href="#" class="x-grid3-focus" tabIndex="-1"></a></div>',
40977 '<div class="x-grid3-resize-marker"> </div>',
40978 '<div class="x-grid3-resize-proxy"> </div>',
40984 ts.header = new Ext.Template(
40985 '<table border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
40986 '<thead><tr class="x-grid3-hd-row">{cells}</tr></thead>',
40992 ts.hcell = new Ext.Template(
40993 '<td class="x-grid3-hd x-grid3-cell x-grid3-td-{id} {css}" style="{style}"><div {tooltip} {attr} class="x-grid3-hd-inner x-grid3-hd-{id}" unselectable="on" style="{istyle}">', this.grid.enableHdMenu ? '<a class="x-grid3-hd-btn" href="#"></a>' : '',
40994 '{value}<img class="x-grid3-sort-icon" src="', Ext.BLANK_IMAGE_URL, '" />',
41000 ts.body = new Ext.Template('{rows}');
41004 ts.row = new Ext.Template(
41005 '<div class="x-grid3-row {alt}" style="{tstyle}"><table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
41006 '<tbody><tr>{cells}</tr>',
41007 (this.enableRowBody ? '<tr class="x-grid3-row-body-tr" style="{bodyStyle}"><td colspan="{cols}" class="x-grid3-body-cell" tabIndex="0" hidefocus="on"><div class="x-grid3-row-body">{body}</div></td></tr>' : ''),
41008 '</tbody></table></div>'
41013 ts.cell = new Ext.Template(
41014 '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} {css}" style="{style}" tabIndex="0" {cellAttr}>',
41015 '<div class="x-grid3-cell-inner x-grid3-col-{id}" unselectable="on" {attr}>{value}</div>',
41022 if(t && Ext.isFunction(t.compile) && !t.compiled){
41023 t.disableFormats = true;
41028 this.templates = ts;
41029 this.colRe = new RegExp('x-grid3-td-([^\\s]+)', '');
41033 fly : function(el){
41034 if(!this._flyweight){
41035 this._flyweight = new Ext.Element.Flyweight(document.body);
41037 this._flyweight.dom = el;
41038 return this._flyweight;
41042 getEditorParent : function(){
41043 return this.scroller.dom;
41047 initElements : function(){
41048 var E = Ext.Element;
41050 var el = this.grid.getGridEl().dom.firstChild;
41051 var cs = el.childNodes;
41053 this.el = new E(el);
41055 this.mainWrap = new E(cs[0]);
41056 this.mainHd = new E(this.mainWrap.dom.firstChild);
41058 if(this.grid.hideHeaders){
41059 this.mainHd.setDisplayed(false);
41062 this.innerHd = this.mainHd.dom.firstChild;
41063 this.scroller = new E(this.mainWrap.dom.childNodes[1]);
41065 this.scroller.setStyle('overflow-x', 'hidden');
41068 this.mainBody = new E(this.scroller.dom.firstChild);
41070 this.focusEl = new E(this.scroller.dom.childNodes[1]);
41071 this.focusEl.swallowEvent('click', true);
41073 this.resizeMarker = new E(cs[1]);
41074 this.resizeProxy = new E(cs[2]);
41078 getRows : function(){
41079 return this.hasRows() ? this.mainBody.dom.childNodes : [];
41085 findCell : function(el){
41089 return this.fly(el).findParent(this.cellSelector, this.cellSelectorDepth);
41093 findCellIndex : function(el, requiredCls){
41094 var cell = this.findCell(el);
41095 if(cell && (!requiredCls || this.fly(cell).hasClass(requiredCls))){
41096 return this.getCellIndex(cell);
41102 getCellIndex : function(el){
41104 var m = el.className.match(this.colRe);
41106 return this.cm.getIndexById(m[1]);
41113 findHeaderCell : function(el){
41114 var cell = this.findCell(el);
41115 return cell && this.fly(cell).hasClass(this.hdCls) ? cell : null;
41119 findHeaderIndex : function(el){
41120 return this.findCellIndex(el, this.hdCls);
41124 findRow : function(el){
41128 return this.fly(el).findParent(this.rowSelector, this.rowSelectorDepth);
41132 findRowIndex : function(el){
41133 var r = this.findRow(el);
41134 return r ? r.rowIndex : false;
41138 findRowBody : function(el){
41142 return this.fly(el).findParent(this.rowBodySelector, this.rowBodySelectorDepth);
41148 getRow : function(row){
41149 return this.getRows()[row];
41153 getCell : function(row, col){
41154 return this.getRow(row).getElementsByTagName('td')[col];
41158 getHeaderCell : function(index){
41159 return this.mainHd.dom.getElementsByTagName('td')[index];
41165 addRowClass : function(row, cls){
41166 var r = this.getRow(row);
41168 this.fly(r).addClass(cls);
41173 removeRowClass : function(row, cls){
41174 var r = this.getRow(row);
41176 this.fly(r).removeClass(cls);
41181 removeRow : function(row){
41182 Ext.removeNode(this.getRow(row));
41183 this.syncFocusEl(row);
41187 removeRows : function(firstRow, lastRow){
41188 var bd = this.mainBody.dom;
41189 for(var rowIndex = firstRow; rowIndex <= lastRow; rowIndex++){
41190 Ext.removeNode(bd.childNodes[firstRow]);
41192 this.syncFocusEl(firstRow);
41198 getScrollState : function(){
41199 var sb = this.scroller.dom;
41200 return {left: sb.scrollLeft, top: sb.scrollTop};
41204 restoreScroll : function(state){
41205 var sb = this.scroller.dom;
41206 sb.scrollLeft = state.left;
41207 sb.scrollTop = state.top;
41211 scrollToTop : function(){
41212 this.scroller.dom.scrollTop = 0;
41213 this.scroller.dom.scrollLeft = 0;
41217 syncScroll : function(){
41218 this.syncHeaderScroll();
41219 var mb = this.scroller.dom;
41220 this.grid.fireEvent('bodyscroll', mb.scrollLeft, mb.scrollTop);
41224 syncHeaderScroll : function(){
41225 var mb = this.scroller.dom;
41226 this.innerHd.scrollLeft = mb.scrollLeft;
41227 this.innerHd.scrollLeft = mb.scrollLeft;
41231 updateSortIcon : function(col, dir){
41232 var sc = this.sortClasses;
41233 var hds = this.mainHd.select('td').removeClass(sc);
41234 hds.item(col).addClass(sc[dir == 'DESC' ? 1 : 0]);
41238 updateAllColumnWidths : function(){
41239 var tw = this.getTotalWidth(),
41240 clen = this.cm.getColumnCount(),
41244 for(i = 0; i < clen; i++){
41245 ws[i] = this.getColumnWidth(i);
41247 this.innerHd.firstChild.style.width = this.getOffsetWidth();
41248 this.innerHd.firstChild.firstChild.style.width = tw;
41249 this.mainBody.dom.style.width = tw;
41250 for(i = 0; i < clen; i++){
41251 var hd = this.getHeaderCell(i);
41252 hd.style.width = ws[i];
41255 var ns = this.getRows(), row, trow;
41256 for(i = 0, len = ns.length; i < len; i++){
41258 row.style.width = tw;
41259 if(row.firstChild){
41260 row.firstChild.style.width = tw;
41261 trow = row.firstChild.rows[0];
41262 for (var j = 0; j < clen; j++) {
41263 trow.childNodes[j].style.width = ws[j];
41268 this.onAllColumnWidthsUpdated(ws, tw);
41272 updateColumnWidth : function(col, width){
41273 var w = this.getColumnWidth(col);
41274 var tw = this.getTotalWidth();
41275 this.innerHd.firstChild.style.width = this.getOffsetWidth();
41276 this.innerHd.firstChild.firstChild.style.width = tw;
41277 this.mainBody.dom.style.width = tw;
41278 var hd = this.getHeaderCell(col);
41279 hd.style.width = w;
41281 var ns = this.getRows(), row;
41282 for(var i = 0, len = ns.length; i < len; i++){
41284 row.style.width = tw;
41285 if(row.firstChild){
41286 row.firstChild.style.width = tw;
41287 row.firstChild.rows[0].childNodes[col].style.width = w;
41291 this.onColumnWidthUpdated(col, w, tw);
41295 updateColumnHidden : function(col, hidden){
41296 var tw = this.getTotalWidth();
41297 this.innerHd.firstChild.style.width = this.getOffsetWidth();
41298 this.innerHd.firstChild.firstChild.style.width = tw;
41299 this.mainBody.dom.style.width = tw;
41300 var display = hidden ? 'none' : '';
41302 var hd = this.getHeaderCell(col);
41303 hd.style.display = display;
41305 var ns = this.getRows(), row;
41306 for(var i = 0, len = ns.length; i < len; i++){
41308 row.style.width = tw;
41309 if(row.firstChild){
41310 row.firstChild.style.width = tw;
41311 row.firstChild.rows[0].childNodes[col].style.display = display;
41315 this.onColumnHiddenUpdated(col, hidden, tw);
41316 delete this.lastViewWidth;
41321 doRender : function(cs, rs, ds, startRow, colCount, stripe){
41322 var ts = this.templates, ct = ts.cell, rt = ts.row, last = colCount-1;
41323 var tstyle = 'width:'+this.getTotalWidth()+';';
41325 var buf = [], cb, c, p = {}, rp = {tstyle: tstyle}, r;
41326 for(var j = 0, len = rs.length; j < len; j++){
41327 r = rs[j]; cb = [];
41328 var rowIndex = (j+startRow);
41329 for(var i = 0; i < colCount; i++){
41332 p.css = i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
41333 p.attr = p.cellAttr = '';
41334 p.value = c.renderer.call(c.scope, r.data[c.name], p, r, rowIndex, i, ds);
41336 if(Ext.isEmpty(p.value)){
41337 p.value = ' ';
41339 if(this.markDirty && r.dirty && Ext.isDefined(r.modified[c.name])){
41340 p.css += ' x-grid3-dirty-cell';
41342 cb[cb.length] = ct.apply(p);
41345 if(stripe && ((rowIndex+1) % 2 === 0)){
41346 alt[0] = 'x-grid3-row-alt';
41349 alt[1] = ' x-grid3-dirty-row';
41351 rp.cols = colCount;
41352 if(this.getRowClass){
41353 alt[2] = this.getRowClass(r, rowIndex, rp, ds);
41355 rp.alt = alt.join(' ');
41356 rp.cells = cb.join('');
41357 buf[buf.length] = rt.apply(rp);
41359 return buf.join('');
41363 processRows : function(startRow, skipStripe){
41364 if(!this.ds || this.ds.getCount() < 1){
41367 var rows = this.getRows(),
41371 skipStripe = skipStripe || !this.grid.stripeRows;
41372 startRow = startRow || 0;
41373 for(i = 0; i<len; i++) {
41378 r.className = r.className.replace(this.rowClsRe, ' ');
41379 if ((i + 1) % 2 === 0){
41380 r.className += ' x-grid3-row-alt';
41386 if(startRow === 0){
41387 Ext.fly(rows[0]).addClass(this.firstRowCls);
41389 Ext.fly(rows[rows.length - 1]).addClass(this.lastRowCls);
41392 afterRender : function(){
41393 if(!this.ds || !this.cm){
41396 this.mainBody.dom.innerHTML = this.renderRows() || ' ';
41397 this.processRows(0, true);
41399 if(this.deferEmptyText !== true){
41400 this.applyEmptyText();
41402 this.grid.fireEvent('viewready', this.grid);
41406 renderUI : function(){
41408 var header = this.renderHeaders();
41409 var body = this.templates.body.apply({rows:' '});
41412 var html = this.templates.master.apply({
41415 ostyle: 'width:'+this.getOffsetWidth()+';',
41416 bstyle: 'width:'+this.getTotalWidth()+';'
41421 g.getGridEl().dom.innerHTML = html;
41423 this.initElements();
41426 Ext.fly(this.innerHd).on('click', this.handleHdDown, this);
41429 mouseover: this.handleHdOver,
41430 mouseout: this.handleHdOut,
41431 mousemove: this.handleHdMove
41434 this.scroller.on('scroll', this.syncScroll, this);
41435 if(g.enableColumnResize !== false){
41436 this.splitZone = new Ext.grid.GridView.SplitDragZone(g, this.mainHd.dom);
41439 if(g.enableColumnMove){
41440 this.columnDrag = new Ext.grid.GridView.ColumnDragZone(g, this.innerHd);
41441 this.columnDrop = new Ext.grid.HeaderDropZone(g, this.mainHd.dom);
41444 if(g.enableHdMenu !== false){
41445 this.hmenu = new Ext.menu.Menu({id: g.id + '-hctx'});
41447 {itemId:'asc', text: this.sortAscText, cls: 'xg-hmenu-sort-asc'},
41448 {itemId:'desc', text: this.sortDescText, cls: 'xg-hmenu-sort-desc'}
41450 if(g.enableColumnHide !== false){
41451 this.colMenu = new Ext.menu.Menu({id:g.id + '-hcols-menu'});
41454 beforeshow: this.beforeColMenuShow,
41455 itemclick: this.handleHdMenuClick
41457 this.hmenu.add('-', {
41459 hideOnClick: false,
41460 text: this.columnsText,
41461 menu: this.colMenu,
41462 iconCls: 'x-cols-icon'
41465 this.hmenu.on('itemclick', this.handleHdMenuClick, this);
41468 if(g.trackMouseOver){
41471 mouseover: this.onRowOver,
41472 mouseout: this.onRowOut
41476 if(g.enableDragDrop || g.enableDrag){
41477 this.dragZone = new Ext.grid.GridDragZone(g, {
41478 ddGroup : g.ddGroup || 'GridDD'
41482 this.updateHeaderSortState();
41487 processEvent: Ext.emptyFn,
41490 layout : function(){
41491 if(!this.mainBody){
41495 var c = g.getGridEl();
41496 var csize = c.getSize(true);
41497 var vw = csize.width;
41499 if(!g.hideHeaders && (vw < 20 || csize.height < 20)){
41504 this.scroller.dom.style.overflow = 'visible';
41506 this.scroller.dom.style.position = 'static';
41509 this.el.setSize(csize.width, csize.height);
41511 var hdHeight = this.mainHd.getHeight();
41512 var vh = csize.height - (hdHeight);
41514 this.scroller.setSize(vw, vh);
41516 this.innerHd.style.width = (vw)+'px';
41520 if(this.lastViewWidth != vw){
41521 this.fitColumns(false, false);
41522 this.lastViewWidth = vw;
41526 this.syncHeaderScroll();
41528 this.onLayout(vw, vh);
41533 onLayout : function(vw, vh){
41537 onColumnWidthUpdated : function(col, w, tw){
41541 onAllColumnWidthsUpdated : function(ws, tw){
41545 onColumnHiddenUpdated : function(col, hidden, tw){
41549 updateColumnText : function(col, text){
41553 afterMove : function(colIndex){
41559 init : function(grid){
41562 this.initTemplates();
41563 this.initData(grid.store, grid.colModel);
41568 getColumnId : function(index){
41569 return this.cm.getColumnId(index);
41573 getOffsetWidth : function() {
41574 return (this.cm.getTotalWidth() + this.getScrollOffset()) + 'px';
41577 getScrollOffset: function(){
41578 return Ext.num(this.scrollOffset, Ext.getScrollBarWidth());
41582 renderHeaders : function(){
41584 ts = this.templates,
41588 len = cm.getColumnCount(),
41591 for(var i = 0; i < len; i++){
41592 p.id = cm.getColumnId(i);
41593 p.value = cm.getColumnHeader(i) || '';
41594 p.style = this.getColumnStyle(i, true);
41595 p.tooltip = this.getColumnTooltip(i);
41596 p.css = i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
41597 if(cm.config[i].align == 'right'){
41598 p.istyle = 'padding-right:16px';
41602 cb[cb.length] = ct.apply(p);
41604 return ts.header.apply({cells: cb.join(''), tstyle:'width:'+this.getTotalWidth()+';'});
41608 getColumnTooltip : function(i){
41609 var tt = this.cm.getColumnTooltip(i);
41611 if(Ext.QuickTips.isEnabled()){
41612 return 'ext:qtip="'+tt+'"';
41614 return 'title="'+tt+'"';
41621 beforeUpdate : function(){
41622 this.grid.stopEditing(true);
41626 updateHeaders : function(){
41627 this.innerHd.firstChild.innerHTML = this.renderHeaders();
41628 this.innerHd.firstChild.style.width = this.getOffsetWidth();
41629 this.innerHd.firstChild.firstChild.style.width = this.getTotalWidth();
41633 focusRow : function(row){
41634 this.focusCell(row, 0, false);
41638 focusCell : function(row, col, hscroll){
41639 this.syncFocusEl(this.ensureVisible(row, col, hscroll));
41641 this.focusEl.focus();
41643 this.focusEl.focus.defer(1, this.focusEl);
41647 resolveCell : function(row, col, hscroll){
41648 if(!Ext.isNumber(row)){
41649 row = row.rowIndex;
41654 if(row < 0 || row >= this.ds.getCount()){
41657 col = (col !== undefined ? col : 0);
41659 var rowEl = this.getRow(row),
41661 colCount = cm.getColumnCount(),
41663 if(!(hscroll === false && col === 0)){
41664 while(col < colCount && cm.isHidden(col)){
41667 cellEl = this.getCell(row, col);
41670 return {row: rowEl, cell: cellEl};
41673 getResolvedXY : function(resolved){
41677 var s = this.scroller.dom, c = resolved.cell, r = resolved.row;
41678 return c ? Ext.fly(c).getXY() : [this.el.getX(), Ext.fly(r).getY()];
41681 syncFocusEl : function(row, col, hscroll){
41683 if(!Ext.isArray(xy)){
41684 row = Math.min(row, Math.max(0, this.getRows().length-1));
41685 xy = this.getResolvedXY(this.resolveCell(row, col, hscroll));
41687 this.focusEl.setXY(xy||this.scroller.getXY());
41690 ensureVisible : function(row, col, hscroll){
41691 var resolved = this.resolveCell(row, col, hscroll);
41692 if(!resolved || !resolved.row){
41696 var rowEl = resolved.row,
41697 cellEl = resolved.cell,
41698 c = this.scroller.dom,
41701 stop = this.el.dom;
41703 while(p && p != stop){
41704 ctop += p.offsetTop;
41705 p = p.offsetParent;
41708 ctop -= this.mainHd.dom.offsetHeight;
41709 stop = parseInt(c.scrollTop, 10);
41711 var cbot = ctop + rowEl.offsetHeight,
41712 ch = c.clientHeight,
41717 c.scrollTop = ctop;
41718 }else if(cbot > sbot){
41719 c.scrollTop = cbot-ch;
41722 if(hscroll !== false){
41723 var cleft = parseInt(cellEl.offsetLeft, 10);
41724 var cright = cleft + cellEl.offsetWidth;
41726 var sleft = parseInt(c.scrollLeft, 10);
41727 var sright = sleft + c.clientWidth;
41729 c.scrollLeft = cleft;
41730 }else if(cright > sright){
41731 c.scrollLeft = cright-c.clientWidth;
41734 return this.getResolvedXY(resolved);
41738 insertRows : function(dm, firstRow, lastRow, isUpdate){
41739 var last = dm.getCount() - 1;
41740 if(!isUpdate && firstRow === 0 && lastRow >= last){
41741 this.fireEvent('beforerowsinserted', this, firstRow, lastRow);
41743 this.fireEvent('rowsinserted', this, firstRow, lastRow);
41746 this.fireEvent('beforerowsinserted', this, firstRow, lastRow);
41748 var html = this.renderRows(firstRow, lastRow),
41749 before = this.getRow(firstRow);
41751 if(firstRow === 0){
41752 Ext.fly(this.getRow(0)).removeClass(this.firstRowCls);
41754 Ext.DomHelper.insertHtml('beforeBegin', before, html);
41756 var r = this.getRow(last - 1);
41758 Ext.fly(r).removeClass(this.lastRowCls);
41760 Ext.DomHelper.insertHtml('beforeEnd', this.mainBody.dom, html);
41763 this.fireEvent('rowsinserted', this, firstRow, lastRow);
41764 this.processRows(firstRow);
41765 }else if(firstRow === 0 || firstRow >= last){
41767 Ext.fly(this.getRow(firstRow)).addClass(firstRow === 0 ? this.firstRowCls : this.lastRowCls);
41770 this.syncFocusEl(firstRow);
41774 deleteRows : function(dm, firstRow, lastRow){
41775 if(dm.getRowCount()<1){
41778 this.fireEvent('beforerowsdeleted', this, firstRow, lastRow);
41780 this.removeRows(firstRow, lastRow);
41782 this.processRows(firstRow);
41783 this.fireEvent('rowsdeleted', this, firstRow, lastRow);
41788 getColumnStyle : function(col, isHeader){
41789 var style = !isHeader ? (this.cm.config[col].css || '') : '';
41790 style += 'width:'+this.getColumnWidth(col)+';';
41791 if(this.cm.isHidden(col)){
41792 style += 'display:none;';
41794 var align = this.cm.config[col].align;
41796 style += 'text-align:'+align+';';
41802 getColumnWidth : function(col){
41803 var w = this.cm.getColumnWidth(col);
41804 if(Ext.isNumber(w)){
41805 return (Ext.isBorderBox || (Ext.isWebKit && !Ext.isSafari2) ? w : (w - this.borderWidth > 0 ? w - this.borderWidth : 0)) + 'px';
41811 getTotalWidth : function(){
41812 return this.cm.getTotalWidth()+'px';
41816 fitColumns : function(preventRefresh, onlyExpand, omitColumn){
41817 var cm = this.cm, i;
41818 var tw = cm.getTotalWidth(false);
41819 var aw = this.grid.getGridEl().getWidth(true)-this.getScrollOffset();
41824 var extra = aw - tw;
41830 var vc = cm.getColumnCount(true);
41831 var ac = vc-(Ext.isNumber(omitColumn) ? 1 : 0);
41834 omitColumn = undefined;
41836 var colCount = cm.getColumnCount();
41841 for (i = 0; i < colCount; i++){
41842 if(!cm.isHidden(i) && !cm.isFixed(i) && i !== omitColumn){
41843 w = cm.getColumnWidth(i);
41850 var frac = (aw - cm.getTotalWidth())/width;
41851 while (cols.length){
41854 cm.setColumnWidth(i, Math.max(this.grid.minColumnWidth, Math.floor(w + w*frac)), true);
41857 if((tw = cm.getTotalWidth(false)) > aw){
41858 var adjustCol = ac != vc ? omitColumn : extraCol;
41859 cm.setColumnWidth(adjustCol, Math.max(1,
41860 cm.getColumnWidth(adjustCol)- (tw-aw)), true);
41863 if(preventRefresh !== true){
41864 this.updateAllColumnWidths();
41872 autoExpand : function(preventUpdate){
41873 var g = this.grid, cm = this.cm;
41874 if(!this.userResized && g.autoExpandColumn){
41875 var tw = cm.getTotalWidth(false);
41876 var aw = this.grid.getGridEl().getWidth(true)-this.getScrollOffset();
41878 var ci = cm.getIndexById(g.autoExpandColumn);
41879 var currentWidth = cm.getColumnWidth(ci);
41880 var cw = Math.min(Math.max(((aw-tw)+currentWidth), g.autoExpandMin), g.autoExpandMax);
41881 if(cw != currentWidth){
41882 cm.setColumnWidth(ci, cw, true);
41883 if(preventUpdate !== true){
41884 this.updateColumnWidth(ci, cw);
41892 getColumnData : function(){
41894 var cs = [], cm = this.cm, colCount = cm.getColumnCount();
41895 for(var i = 0; i < colCount; i++){
41896 var name = cm.getDataIndex(i);
41898 name : (!Ext.isDefined(name) ? this.ds.fields.get(i).name : name),
41899 renderer : cm.getRenderer(i),
41900 scope: cm.getRendererScope(i),
41901 id : cm.getColumnId(i),
41902 style : this.getColumnStyle(i)
41909 renderRows : function(startRow, endRow){
41911 var g = this.grid, cm = g.colModel, ds = g.store, stripe = g.stripeRows;
41912 var colCount = cm.getColumnCount();
41914 if(ds.getCount() < 1){
41918 var cs = this.getColumnData();
41920 startRow = startRow || 0;
41921 endRow = !Ext.isDefined(endRow) ? ds.getCount()-1 : endRow;
41924 var rs = ds.getRange(startRow, endRow);
41926 return this.doRender(cs, rs, ds, startRow, colCount, stripe);
41930 renderBody : function(){
41931 var markup = this.renderRows() || ' ';
41932 return this.templates.body.apply({rows: markup});
41936 refreshRow : function(record){
41937 var ds = this.ds, index;
41938 if(Ext.isNumber(record)){
41940 record = ds.getAt(index);
41945 index = ds.indexOf(record);
41950 this.insertRows(ds, index, index, true);
41951 this.getRow(index).rowIndex = index;
41952 this.onRemove(ds, record, index+1, true);
41953 this.fireEvent('rowupdated', this, index, record);
41957 refresh : function(headersToo){
41958 this.fireEvent('beforerefresh', this);
41959 this.grid.stopEditing(true);
41961 var result = this.renderBody();
41962 this.mainBody.update(result).setWidth(this.getTotalWidth());
41963 if(headersToo === true){
41964 this.updateHeaders();
41965 this.updateHeaderSortState();
41967 this.processRows(0, true);
41969 this.applyEmptyText();
41970 this.fireEvent('refresh', this);
41974 applyEmptyText : function(){
41975 if(this.emptyText && !this.hasRows()){
41976 this.mainBody.update('<div class="x-grid-empty">' + this.emptyText + '</div>');
41981 updateHeaderSortState : function(){
41982 var state = this.ds.getSortState();
41986 if(!this.sortState || (this.sortState.field != state.field || this.sortState.direction != state.direction)){
41987 this.grid.fireEvent('sortchange', this.grid, state);
41989 this.sortState = state;
41990 var sortColumn = this.cm.findColumnIndex(state.field);
41991 if(sortColumn != -1){
41992 var sortDir = state.direction;
41993 this.updateSortIcon(sortColumn, sortDir);
41998 clearHeaderSortState : function(){
41999 if(!this.sortState){
42002 this.grid.fireEvent('sortchange', this.grid, null);
42003 this.mainHd.select('td').removeClass(this.sortClasses);
42004 delete this.sortState;
42008 destroy : function(){
42010 Ext.menu.MenuMgr.unregister(this.colMenu);
42011 this.colMenu.destroy();
42012 delete this.colMenu;
42015 Ext.menu.MenuMgr.unregister(this.hmenu);
42016 this.hmenu.destroy();
42020 this.initData(null, null);
42021 this.purgeListeners();
42022 Ext.fly(this.innerHd).un("click", this.handleHdDown, this);
42024 if(this.grid.enableColumnMove){
42026 this.columnDrag.el,
42027 this.columnDrag.proxy.ghost,
42028 this.columnDrag.proxy.el,
42029 this.columnDrop.el,
42030 this.columnDrop.proxyTop,
42031 this.columnDrop.proxyBottom,
42032 this.columnDrag.dragData.ddel,
42033 this.columnDrag.dragData.header
42035 if (this.columnDrag.proxy.anim) {
42036 Ext.destroy(this.columnDrag.proxy.anim);
42038 delete this.columnDrag.proxy.ghost;
42039 delete this.columnDrag.dragData.ddel;
42040 delete this.columnDrag.dragData.header;
42041 this.columnDrag.destroy();
42042 delete Ext.dd.DDM.locationCache[this.columnDrag.id];
42043 delete this.columnDrag._domRef;
42045 delete this.columnDrop.proxyTop;
42046 delete this.columnDrop.proxyBottom;
42047 this.columnDrop.destroy();
42048 delete Ext.dd.DDM.locationCache["gridHeader" + this.grid.getGridEl().id];
42049 delete this.columnDrop._domRef;
42050 delete Ext.dd.DDM.ids[this.columnDrop.ddGroup];
42053 if (this.splitZone){
42054 this.splitZone.destroy();
42055 delete this.splitZone._domRef;
42056 delete Ext.dd.DDM.ids["gridSplitters" + this.grid.getGridEl().id];
42059 Ext.fly(this.innerHd).removeAllListeners();
42060 Ext.removeNode(this.innerHd);
42061 delete this.innerHd;
42078 delete this.grid.container;
42081 this.dragZone.destroy();
42084 Ext.dd.DDM.currentTarget = null;
42085 delete Ext.dd.DDM.locationCache[this.grid.getGridEl().id];
42087 Ext.EventManager.removeResizeListener(this.onWindowResize, this);
42091 onDenyColumnHide : function(){
42096 render : function(){
42098 var ct = this.grid.ownerCt;
42099 if (ct && ct.getLayout()){
42100 ct.on('afterlayout', function(){
42101 this.fitColumns(true, true);
42102 this.updateHeaders();
42103 }, this, {single: true});
42105 this.fitColumns(true, true);
42107 }else if(this.forceFit){
42108 this.fitColumns(true, false);
42109 }else if(this.grid.autoExpandColumn){
42110 this.autoExpand(true);
42118 initData : function(ds, cm){
42120 this.ds.un('load', this.onLoad, this);
42121 this.ds.un('datachanged', this.onDataChange, this);
42122 this.ds.un('add', this.onAdd, this);
42123 this.ds.un('remove', this.onRemove, this);
42124 this.ds.un('update', this.onUpdate, this);
42125 this.ds.un('clear', this.onClear, this);
42126 if(this.ds !== ds && this.ds.autoDestroy){
42134 datachanged: this.onDataChange,
42136 remove: this.onRemove,
42137 update: this.onUpdate,
42138 clear: this.onClear
42144 this.cm.un('configchange', this.onColConfigChange, this);
42145 this.cm.un('widthchange', this.onColWidthChange, this);
42146 this.cm.un('headerchange', this.onHeaderChange, this);
42147 this.cm.un('hiddenchange', this.onHiddenChange, this);
42148 this.cm.un('columnmoved', this.onColumnMove, this);
42151 delete this.lastViewWidth;
42154 configchange: this.onColConfigChange,
42155 widthchange: this.onColWidthChange,
42156 headerchange: this.onHeaderChange,
42157 hiddenchange: this.onHiddenChange,
42158 columnmoved: this.onColumnMove
42165 onDataChange : function(){
42167 this.updateHeaderSortState();
42168 this.syncFocusEl(0);
42172 onClear : function(){
42174 this.syncFocusEl(0);
42178 onUpdate : function(ds, record){
42179 this.refreshRow(record);
42183 onAdd : function(ds, records, index){
42185 this.insertRows(ds, index, index + (records.length-1));
42189 onRemove : function(ds, record, index, isUpdate){
42190 if(isUpdate !== true){
42191 this.fireEvent('beforerowremoved', this, index, record);
42193 this.removeRow(index);
42194 if(isUpdate !== true){
42195 this.processRows(index);
42196 this.applyEmptyText();
42197 this.fireEvent('rowremoved', this, index, record);
42202 onLoad : function(){
42203 this.scrollToTop.defer(Ext.isGecko ? 1 : 0, this);
42207 onColWidthChange : function(cm, col, width){
42208 this.updateColumnWidth(col, width);
42212 onHeaderChange : function(cm, col, text){
42213 this.updateHeaders();
42217 onHiddenChange : function(cm, col, hidden){
42218 this.updateColumnHidden(col, hidden);
42222 onColumnMove : function(cm, oldIndex, newIndex){
42223 this.indexMap = null;
42224 var s = this.getScrollState();
42225 this.refresh(true);
42226 this.restoreScroll(s);
42227 this.afterMove(newIndex);
42228 this.grid.fireEvent('columnmove', oldIndex, newIndex);
42232 onColConfigChange : function(){
42233 delete this.lastViewWidth;
42234 this.indexMap = null;
42235 this.refresh(true);
42240 initUI : function(grid){
42241 grid.on('headerclick', this.onHeaderClick, this);
42245 initEvents : function(){
42249 onHeaderClick : function(g, index){
42250 if(this.headersDisabled || !this.cm.isSortable(index)){
42253 g.stopEditing(true);
42254 g.store.sort(this.cm.getDataIndex(index));
42258 onRowOver : function(e, t){
42260 if((row = this.findRowIndex(t)) !== false){
42261 this.addRowClass(row, 'x-grid3-row-over');
42266 onRowOut : function(e, t){
42268 if((row = this.findRowIndex(t)) !== false && !e.within(this.getRow(row), true)){
42269 this.removeRowClass(row, 'x-grid3-row-over');
42274 handleWheel : function(e){
42275 e.stopPropagation();
42279 onRowSelect : function(row){
42280 this.addRowClass(row, this.selectedRowClass);
42284 onRowDeselect : function(row){
42285 this.removeRowClass(row, this.selectedRowClass);
42289 onCellSelect : function(row, col){
42290 var cell = this.getCell(row, col);
42292 this.fly(cell).addClass('x-grid3-cell-selected');
42297 onCellDeselect : function(row, col){
42298 var cell = this.getCell(row, col);
42300 this.fly(cell).removeClass('x-grid3-cell-selected');
42305 onColumnSplitterMoved : function(i, w){
42306 this.userResized = true;
42307 var cm = this.grid.colModel;
42308 cm.setColumnWidth(i, w, true);
42311 this.fitColumns(true, false, i);
42312 this.updateAllColumnWidths();
42314 this.updateColumnWidth(i, w);
42315 this.syncHeaderScroll();
42318 this.grid.fireEvent('columnresize', i, w);
42322 handleHdMenuClick : function(item){
42323 var index = this.hdCtxIndex,
42326 id = item.getItemId();
42329 ds.sort(cm.getDataIndex(index), 'ASC');
42332 ds.sort(cm.getDataIndex(index), 'DESC');
42335 index = cm.getIndexById(id.substr(4));
42337 if(item.checked && cm.getColumnsBy(this.isHideableColumn, this).length <= 1){
42338 this.onDenyColumnHide();
42341 cm.setHidden(index, item.checked);
42348 isHideableColumn : function(c){
42349 return !c.hidden && !c.fixed;
42353 beforeColMenuShow : function(){
42354 var cm = this.cm, colCount = cm.getColumnCount();
42355 this.colMenu.removeAll();
42356 for(var i = 0; i < colCount; i++){
42357 if(cm.config[i].fixed !== true && cm.config[i].hideable !== false){
42358 this.colMenu.add(new Ext.menu.CheckItem({
42359 itemId: 'col-'+cm.getColumnId(i),
42360 text: cm.getColumnHeader(i),
42361 checked: !cm.isHidden(i),
42363 disabled: cm.config[i].hideable === false
42370 handleHdDown : function(e, t){
42371 if(Ext.fly(t).hasClass('x-grid3-hd-btn')){
42373 var hd = this.findHeaderCell(t);
42374 Ext.fly(hd).addClass('x-grid3-hd-menu-open');
42375 var index = this.getCellIndex(hd);
42376 this.hdCtxIndex = index;
42377 var ms = this.hmenu.items, cm = this.cm;
42378 ms.get('asc').setDisabled(!cm.isSortable(index));
42379 ms.get('desc').setDisabled(!cm.isSortable(index));
42380 this.hmenu.on('hide', function(){
42381 Ext.fly(hd).removeClass('x-grid3-hd-menu-open');
42382 }, this, {single:true});
42383 this.hmenu.show(t, 'tl-bl?');
42388 handleHdOver : function(e, t){
42389 var hd = this.findHeaderCell(t);
42390 if(hd && !this.headersDisabled){
42391 this.activeHdRef = t;
42392 this.activeHdIndex = this.getCellIndex(hd);
42393 var fly = this.fly(hd);
42394 this.activeHdRegion = fly.getRegion();
42395 if(!this.cm.isMenuDisabled(this.activeHdIndex)){
42396 fly.addClass('x-grid3-hd-over');
42397 this.activeHdBtn = fly.child('.x-grid3-hd-btn');
42398 if(this.activeHdBtn){
42399 this.activeHdBtn.dom.style.height = (hd.firstChild.offsetHeight-1)+'px';
42406 handleHdMove : function(e, t){
42407 var hd = this.findHeaderCell(this.activeHdRef);
42408 if(hd && !this.headersDisabled){
42409 var hw = this.splitHandleWidth || 5,
42410 r = this.activeHdRegion,
42414 if(this.grid.enableColumnResize !== false){
42415 if(x - r.left <= hw && this.cm.isResizable(this.activeHdIndex-1)){
42416 cur = Ext.isAir ? 'move' : Ext.isWebKit ? 'e-resize' : 'col-resize';
42417 }else if(r.right - x <= (!this.activeHdBtn ? hw : 2) && this.cm.isResizable(this.activeHdIndex)){
42418 cur = Ext.isAir ? 'move' : Ext.isWebKit ? 'w-resize' : 'col-resize';
42426 handleHdOut : function(e, t){
42427 var hd = this.findHeaderCell(t);
42428 if(hd && (!Ext.isIE || !e.within(hd, true))){
42429 this.activeHdRef = null;
42430 this.fly(hd).removeClass('x-grid3-hd-over');
42431 hd.style.cursor = '';
42436 hasRows : function(){
42437 var fc = this.mainBody.dom.firstChild;
42438 return fc && fc.nodeType == 1 && fc.className != 'x-grid-empty';
42442 bind : function(d, c){
42443 this.initData(d, c);
42450 Ext.grid.GridView.SplitDragZone = function(grid, hd){
42452 this.view = grid.getView();
42453 this.marker = this.view.resizeMarker;
42454 this.proxy = this.view.resizeProxy;
42455 Ext.grid.GridView.SplitDragZone.superclass.constructor.call(this, hd,
42456 'gridSplitters' + this.grid.getGridEl().id, {
42457 dragElId : Ext.id(this.proxy.dom), resizeFrame:false
42459 this.scroll = false;
42460 this.hw = this.view.splitHandleWidth || 5;
42462 Ext.extend(Ext.grid.GridView.SplitDragZone, Ext.dd.DDProxy, {
42464 b4StartDrag : function(x, y){
42465 this.view.headersDisabled = true;
42466 var h = this.view.mainWrap.getHeight();
42467 this.marker.setHeight(h);
42468 this.marker.show();
42469 this.marker.alignTo(this.view.getHeaderCell(this.cellIndex), 'tl-tl', [-2, 0]);
42470 this.proxy.setHeight(h);
42471 var w = this.cm.getColumnWidth(this.cellIndex);
42472 var minw = Math.max(w-this.grid.minColumnWidth, 0);
42473 this.resetConstraints();
42474 this.setXConstraint(minw, 1000);
42475 this.setYConstraint(0, 0);
42476 this.minX = x - minw;
42477 this.maxX = x + 1000;
42479 Ext.dd.DDProxy.prototype.b4StartDrag.call(this, x, y);
42482 allowHeaderDrag : function(e){
42487 handleMouseDown : function(e){
42488 var t = this.view.findHeaderCell(e.getTarget());
42489 if(t && this.allowHeaderDrag(e)){
42490 var xy = this.view.fly(t).getXY(), x = xy[0], y = xy[1];
42491 var exy = e.getXY(), ex = exy[0];
42492 var w = t.offsetWidth, adjust = false;
42493 if((ex - x) <= this.hw){
42495 }else if((x+w) - ex <= this.hw){
42498 if(adjust !== false){
42499 this.cm = this.grid.colModel;
42500 var ci = this.view.getCellIndex(t);
42502 if (ci + adjust < 0) {
42505 while(this.cm.isHidden(ci+adjust)){
42512 this.cellIndex = ci+adjust;
42513 this.split = t.dom;
42514 if(this.cm.isResizable(this.cellIndex) && !this.cm.isFixed(this.cellIndex)){
42515 Ext.grid.GridView.SplitDragZone.superclass.handleMouseDown.apply(this, arguments);
42517 }else if(this.view.columnDrag){
42518 this.view.columnDrag.callHandleMouseDown(e);
42523 endDrag : function(e){
42524 this.marker.hide();
42526 var endX = Math.max(this.minX, e.getPageX());
42527 var diff = endX - this.startPos;
42528 v.onColumnSplitterMoved(this.cellIndex, this.cm.getColumnWidth(this.cellIndex)+diff);
42529 setTimeout(function(){
42530 v.headersDisabled = false;
42534 autoOffset : function(){
42535 this.setDelta(0,0);
42540 Ext.grid.HeaderDragZone = Ext.extend(Ext.dd.DragZone, {
42543 constructor : function(grid, hd, hd2){
42545 this.view = grid.getView();
42546 this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
42547 Ext.grid.HeaderDragZone.superclass.constructor.call(this, hd);
42549 this.setHandleElId(Ext.id(hd));
42550 this.setOuterHandleElId(Ext.id(hd2));
42552 this.scroll = false;
42555 getDragData : function(e){
42556 var t = Ext.lib.Event.getTarget(e);
42557 var h = this.view.findHeaderCell(t);
42559 return {ddel: h.firstChild, header:h};
42564 onInitDrag : function(e){
42565 this.view.headersDisabled = true;
42566 var clone = this.dragData.ddel.cloneNode(true);
42567 clone.id = Ext.id();
42568 clone.style.width = Math.min(this.dragData.header.offsetWidth,this.maxDragWidth) + "px";
42569 this.proxy.update(clone);
42573 afterValidDrop : function(){
42575 setTimeout(function(){
42576 v.headersDisabled = false;
42580 afterInvalidDrop : function(){
42582 setTimeout(function(){
42583 v.headersDisabled = false;
42590 Ext.grid.HeaderDropZone = Ext.extend(Ext.dd.DropZone, {
42591 proxyOffsets : [-4, -9],
42592 fly: Ext.Element.fly,
42594 constructor : function(grid, hd, hd2){
42596 this.view = grid.getView();
42598 this.proxyTop = Ext.DomHelper.append(document.body, {
42599 cls:"col-move-top", html:" "
42601 this.proxyBottom = Ext.DomHelper.append(document.body, {
42602 cls:"col-move-bottom", html:" "
42604 this.proxyTop.hide = this.proxyBottom.hide = function(){
42605 this.setLeftTop(-100,-100);
42606 this.setStyle("visibility", "hidden");
42608 this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
42611 Ext.grid.HeaderDropZone.superclass.constructor.call(this, grid.getGridEl().dom);
42614 getTargetFromEvent : function(e){
42615 var t = Ext.lib.Event.getTarget(e);
42616 var cindex = this.view.findCellIndex(t);
42617 if(cindex !== false){
42618 return this.view.getHeaderCell(cindex);
42622 nextVisible : function(h){
42623 var v = this.view, cm = this.grid.colModel;
42626 if(!cm.isHidden(v.getCellIndex(h))){
42634 prevVisible : function(h){
42635 var v = this.view, cm = this.grid.colModel;
42638 if(!cm.isHidden(v.getCellIndex(h))){
42646 positionIndicator : function(h, n, e){
42647 var x = Ext.lib.Event.getPageX(e);
42648 var r = Ext.lib.Dom.getRegion(n.firstChild);
42649 var px, pt, py = r.top + this.proxyOffsets[1];
42650 if((r.right - x) <= (r.right-r.left)/2){
42651 px = r.right+this.view.borderWidth;
42658 if(this.grid.colModel.isFixed(this.view.getCellIndex(n))){
42662 px += this.proxyOffsets[0];
42663 this.proxyTop.setLeftTop(px, py);
42664 this.proxyTop.show();
42665 if(!this.bottomOffset){
42666 this.bottomOffset = this.view.mainHd.getHeight();
42668 this.proxyBottom.setLeftTop(px, py+this.proxyTop.dom.offsetHeight+this.bottomOffset);
42669 this.proxyBottom.show();
42673 onNodeEnter : function(n, dd, e, data){
42674 if(data.header != n){
42675 this.positionIndicator(data.header, n, e);
42679 onNodeOver : function(n, dd, e, data){
42680 var result = false;
42681 if(data.header != n){
42682 result = this.positionIndicator(data.header, n, e);
42685 this.proxyTop.hide();
42686 this.proxyBottom.hide();
42688 return result ? this.dropAllowed : this.dropNotAllowed;
42691 onNodeOut : function(n, dd, e, data){
42692 this.proxyTop.hide();
42693 this.proxyBottom.hide();
42696 onNodeDrop : function(n, dd, e, data){
42697 var h = data.header;
42699 var cm = this.grid.colModel;
42700 var x = Ext.lib.Event.getPageX(e);
42701 var r = Ext.lib.Dom.getRegion(n.firstChild);
42702 var pt = (r.right - x) <= ((r.right-r.left)/2) ? "after" : "before";
42703 var oldIndex = this.view.getCellIndex(h);
42704 var newIndex = this.view.getCellIndex(n);
42708 if(oldIndex < newIndex){
42711 cm.moveColumn(oldIndex, newIndex);
42718 Ext.grid.GridView.ColumnDragZone = Ext.extend(Ext.grid.HeaderDragZone, {
42720 constructor : function(grid, hd){
42721 Ext.grid.GridView.ColumnDragZone.superclass.constructor.call(this, grid, hd, null);
42722 this.proxy.el.addClass('x-grid3-col-dd');
42725 handleMouseDown : function(e){
42728 callHandleMouseDown : function(e){
42729 Ext.grid.GridView.ColumnDragZone.superclass.handleMouseDown.call(this, e);
42733 Ext.grid.SplitDragZone = Ext.extend(Ext.dd.DDProxy, {
42734 fly: Ext.Element.fly,
42736 constructor : function(grid, hd, hd2){
42738 this.view = grid.getView();
42739 this.proxy = this.view.resizeProxy;
42740 Ext.grid.SplitDragZone.superclass.constructor.call(this, hd,
42741 "gridSplitters" + this.grid.getGridEl().id, {
42742 dragElId : Ext.id(this.proxy.dom), resizeFrame:false
42744 this.setHandleElId(Ext.id(hd));
42745 this.setOuterHandleElId(Ext.id(hd2));
42746 this.scroll = false;
42749 b4StartDrag : function(x, y){
42750 this.view.headersDisabled = true;
42751 this.proxy.setHeight(this.view.mainWrap.getHeight());
42752 var w = this.cm.getColumnWidth(this.cellIndex);
42753 var minw = Math.max(w-this.grid.minColumnWidth, 0);
42754 this.resetConstraints();
42755 this.setXConstraint(minw, 1000);
42756 this.setYConstraint(0, 0);
42757 this.minX = x - minw;
42758 this.maxX = x + 1000;
42760 Ext.dd.DDProxy.prototype.b4StartDrag.call(this, x, y);
42764 handleMouseDown : function(e){
42765 var ev = Ext.EventObject.setEvent(e);
42766 var t = this.fly(ev.getTarget());
42767 if(t.hasClass("x-grid-split")){
42768 this.cellIndex = this.view.getCellIndex(t.dom);
42769 this.split = t.dom;
42770 this.cm = this.grid.colModel;
42771 if(this.cm.isResizable(this.cellIndex) && !this.cm.isFixed(this.cellIndex)){
42772 Ext.grid.SplitDragZone.superclass.handleMouseDown.apply(this, arguments);
42777 endDrag : function(e){
42778 this.view.headersDisabled = false;
42779 var endX = Math.max(this.minX, Ext.lib.Event.getPageX(e));
42780 var diff = endX - this.startPos;
42781 this.view.onColumnSplitterMoved(this.cellIndex, this.cm.getColumnWidth(this.cellIndex)+diff);
42784 autoOffset : function(){
42785 this.setDelta(0,0);
42788 Ext.grid.GridDragZone = function(grid, config){
42789 this.view = grid.getView();
42790 Ext.grid.GridDragZone.superclass.constructor.call(this, this.view.mainBody.dom, config);
42791 this.scroll = false;
42793 this.ddel = document.createElement('div');
42794 this.ddel.className = 'x-grid-dd-wrap';
42797 Ext.extend(Ext.grid.GridDragZone, Ext.dd.DragZone, {
42798 ddGroup : "GridDD",
42801 getDragData : function(e){
42802 var t = Ext.lib.Event.getTarget(e);
42803 var rowIndex = this.view.findRowIndex(t);
42804 if(rowIndex !== false){
42805 var sm = this.grid.selModel;
42806 if(!sm.isSelected(rowIndex) || e.hasModifier()){
42807 sm.handleMouseDown(this.grid, rowIndex, e);
42809 return {grid: this.grid, ddel: this.ddel, rowIndex: rowIndex, selections:sm.getSelections()};
42815 onInitDrag : function(e){
42816 var data = this.dragData;
42817 this.ddel.innerHTML = this.grid.getDragDropText();
42818 this.proxy.update(this.ddel);
42823 afterRepair : function(){
42824 this.dragging = false;
42828 getRepairXY : function(e, data){
42832 onEndDrag : function(data, e){
42836 onValidDrop : function(dd, e, id){
42841 beforeInvalidDrop : function(e, id){
42846 Ext.grid.ColumnModel = Ext.extend(Ext.util.Observable, {
42850 defaultSortable: false,
42854 constructor : function(config){
42856 if(config.columns){
42857 Ext.apply(this, config);
42858 this.setConfig(config.columns, true);
42860 this.setConfig(config, true);
42874 Ext.grid.ColumnModel.superclass.constructor.call(this);
42878 getColumnId : function(index){
42879 return this.config[index].id;
42882 getColumnAt : function(index){
42883 return this.config[index];
42887 setConfig : function(config, initial){
42890 delete this.totalWidth;
42891 for(i = 0, len = this.config.length; i < len; i++){
42892 c = this.config[i];
42894 c.editor.destroy();
42900 this.defaults = Ext.apply({
42901 width: this.defaultWidth,
42902 sortable: this.defaultSortable
42905 this.config = config;
42908 for(i = 0, len = config.length; i < len; i++){
42909 c = Ext.applyIf(config[i], this.defaults);
42911 if(typeof c.id == 'undefined'){
42915 var Cls = Ext.grid.Column.types[c.xtype || 'gridcolumn'];
42919 this.lookup[c.id] = c;
42922 this.fireEvent('configchange', this);
42927 getColumnById : function(id){
42928 return this.lookup[id];
42932 getIndexById : function(id){
42933 for(var i = 0, len = this.config.length; i < len; i++){
42934 if(this.config[i].id == id){
42942 moveColumn : function(oldIndex, newIndex){
42943 var c = this.config[oldIndex];
42944 this.config.splice(oldIndex, 1);
42945 this.config.splice(newIndex, 0, c);
42946 this.dataMap = null;
42947 this.fireEvent("columnmoved", this, oldIndex, newIndex);
42951 getColumnCount : function(visibleOnly){
42952 if(visibleOnly === true){
42954 for(var i = 0, len = this.config.length; i < len; i++){
42955 if(!this.isHidden(i)){
42961 return this.config.length;
42965 getColumnsBy : function(fn, scope){
42967 for(var i = 0, len = this.config.length; i < len; i++){
42968 var c = this.config[i];
42969 if(fn.call(scope||this, c, i) === true){
42977 isSortable : function(col){
42978 return !!this.config[col].sortable;
42982 isMenuDisabled : function(col){
42983 return !!this.config[col].menuDisabled;
42987 getRenderer : function(col){
42988 if(!this.config[col].renderer){
42989 return Ext.grid.ColumnModel.defaultRenderer;
42991 return this.config[col].renderer;
42994 getRendererScope : function(col){
42995 return this.config[col].scope;
42999 setRenderer : function(col, fn){
43000 this.config[col].renderer = fn;
43004 getColumnWidth : function(col){
43005 return this.config[col].width;
43009 setColumnWidth : function(col, width, suppressEvent){
43010 this.config[col].width = width;
43011 this.totalWidth = null;
43012 if(!suppressEvent){
43013 this.fireEvent("widthchange", this, col, width);
43018 getTotalWidth : function(includeHidden){
43019 if(!this.totalWidth){
43020 this.totalWidth = 0;
43021 for(var i = 0, len = this.config.length; i < len; i++){
43022 if(includeHidden || !this.isHidden(i)){
43023 this.totalWidth += this.getColumnWidth(i);
43027 return this.totalWidth;
43031 getColumnHeader : function(col){
43032 return this.config[col].header;
43036 setColumnHeader : function(col, header){
43037 this.config[col].header = header;
43038 this.fireEvent("headerchange", this, col, header);
43042 getColumnTooltip : function(col){
43043 return this.config[col].tooltip;
43046 setColumnTooltip : function(col, tooltip){
43047 this.config[col].tooltip = tooltip;
43051 getDataIndex : function(col){
43052 return this.config[col].dataIndex;
43056 setDataIndex : function(col, dataIndex){
43057 this.config[col].dataIndex = dataIndex;
43061 findColumnIndex : function(dataIndex){
43062 var c = this.config;
43063 for(var i = 0, len = c.length; i < len; i++){
43064 if(c[i].dataIndex == dataIndex){
43072 isCellEditable : function(colIndex, rowIndex){
43073 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
43077 getCellEditor : function(colIndex, rowIndex){
43078 return this.config[colIndex].getCellEditor(rowIndex);
43082 setEditable : function(col, editable){
43083 this.config[col].editable = editable;
43087 isHidden : function(colIndex){
43088 return !!this.config[colIndex].hidden;
43092 isFixed : function(colIndex){
43093 return !!this.config[colIndex].fixed;
43097 isResizable : function(colIndex){
43098 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
43101 setHidden : function(colIndex, hidden){
43102 var c = this.config[colIndex];
43103 if(c.hidden !== hidden){
43105 this.totalWidth = null;
43106 this.fireEvent("hiddenchange", this, colIndex, hidden);
43111 setEditor : function(col, editor){
43112 Ext.destroy(this.config[col].editor);
43113 this.config[col].editor = editor;
43117 destroy : function(){
43118 for(var i = 0, c = this.config, len = c.length; i < len; i++){
43119 Ext.destroy(c[i].editor);
43121 this.purgeListeners();
43126 Ext.grid.ColumnModel.defaultRenderer = function(value){
43127 if(typeof value == "string" && value.length < 1){
43132 Ext.grid.AbstractSelectionModel = Ext.extend(Ext.util.Observable, {
43135 constructor : function(){
43136 this.locked = false;
43137 Ext.grid.AbstractSelectionModel.superclass.constructor.call(this);
43141 init : function(grid){
43148 this.locked = true;
43152 unlock : function(){
43153 this.locked = false;
43157 isLocked : function(){
43158 return this.locked;
43161 destroy: function(){
43162 this.purgeListeners();
43165 Ext.grid.RowSelectionModel = Ext.extend(Ext.grid.AbstractSelectionModel, {
43167 singleSelect : false,
43169 constructor : function(config){
43170 Ext.apply(this, config);
43171 this.selections = new Ext.util.MixedCollection(false, function(o){
43176 this.lastActive = false;
43188 Ext.grid.RowSelectionModel.superclass.constructor.call(this);
43193 initEvents : function(){
43195 if(!this.grid.enableDragDrop && !this.grid.enableDrag){
43196 this.grid.on('rowmousedown', this.handleMouseDown, this);
43199 this.rowNav = new Ext.KeyNav(this.grid.getGridEl(), {
43200 'up' : function(e){
43201 if(!e.shiftKey || this.singleSelect){
43202 this.selectPrevious(false);
43203 }else if(this.last !== false && this.lastActive !== false){
43204 var last = this.last;
43205 this.selectRange(this.last, this.lastActive-1);
43206 this.grid.getView().focusRow(this.lastActive);
43207 if(last !== false){
43211 this.selectFirstRow();
43214 'down' : function(e){
43215 if(!e.shiftKey || this.singleSelect){
43216 this.selectNext(false);
43217 }else if(this.last !== false && this.lastActive !== false){
43218 var last = this.last;
43219 this.selectRange(this.last, this.lastActive+1);
43220 this.grid.getView().focusRow(this.lastActive);
43221 if(last !== false){
43225 this.selectFirstRow();
43231 this.grid.getView().on({
43233 refresh: this.onRefresh,
43234 rowupdated: this.onRowUpdated,
43235 rowremoved: this.onRemove
43240 onRefresh : function(){
43241 var ds = this.grid.store, index;
43242 var s = this.getSelections();
43243 this.clearSelections(true);
43244 for(var i = 0, len = s.length; i < len; i++){
43246 if((index = ds.indexOfId(r.id)) != -1){
43247 this.selectRow(index, true);
43250 if(s.length != this.selections.getCount()){
43251 this.fireEvent('selectionchange', this);
43256 onRemove : function(v, index, r){
43257 if(this.selections.remove(r) !== false){
43258 this.fireEvent('selectionchange', this);
43263 onRowUpdated : function(v, index, r){
43264 if(this.isSelected(r)){
43265 v.onRowSelect(index);
43270 selectRecords : function(records, keepExisting){
43272 this.clearSelections();
43274 var ds = this.grid.store;
43275 for(var i = 0, len = records.length; i < len; i++){
43276 this.selectRow(ds.indexOf(records[i]), true);
43281 getCount : function(){
43282 return this.selections.length;
43286 selectFirstRow : function(){
43291 selectLastRow : function(keepExisting){
43292 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
43296 selectNext : function(keepExisting){
43297 if(this.hasNext()){
43298 this.selectRow(this.last+1, keepExisting);
43299 this.grid.getView().focusRow(this.last);
43306 selectPrevious : function(keepExisting){
43307 if(this.hasPrevious()){
43308 this.selectRow(this.last-1, keepExisting);
43309 this.grid.getView().focusRow(this.last);
43316 hasNext : function(){
43317 return this.last !== false && (this.last+1) < this.grid.store.getCount();
43321 hasPrevious : function(){
43322 return !!this.last;
43327 getSelections : function(){
43328 return [].concat(this.selections.items);
43332 getSelected : function(){
43333 return this.selections.itemAt(0);
43337 each : function(fn, scope){
43338 var s = this.getSelections();
43339 for(var i = 0, len = s.length; i < len; i++){
43340 if(fn.call(scope || this, s[i], i) === false){
43348 clearSelections : function(fast){
43349 if(this.isLocked()){
43353 var ds = this.grid.store;
43354 var s = this.selections;
43355 s.each(function(r){
43356 this.deselectRow(ds.indexOfId(r.id));
43360 this.selections.clear();
43367 selectAll : function(){
43368 if(this.isLocked()){
43371 this.selections.clear();
43372 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
43373 this.selectRow(i, true);
43378 hasSelection : function(){
43379 return this.selections.length > 0;
43383 isSelected : function(index){
43384 var r = Ext.isNumber(index) ? this.grid.store.getAt(index) : index;
43385 return (r && this.selections.key(r.id) ? true : false);
43389 isIdSelected : function(id){
43390 return (this.selections.key(id) ? true : false);
43394 handleMouseDown : function(g, rowIndex, e){
43395 if(e.button !== 0 || this.isLocked()){
43398 var view = this.grid.getView();
43399 if(e.shiftKey && !this.singleSelect && this.last !== false){
43400 var last = this.last;
43401 this.selectRange(last, rowIndex, e.ctrlKey);
43403 view.focusRow(rowIndex);
43405 var isSelected = this.isSelected(rowIndex);
43406 if(e.ctrlKey && isSelected){
43407 this.deselectRow(rowIndex);
43408 }else if(!isSelected || this.getCount() > 1){
43409 this.selectRow(rowIndex, e.ctrlKey || e.shiftKey);
43410 view.focusRow(rowIndex);
43416 selectRows : function(rows, keepExisting){
43418 this.clearSelections();
43420 for(var i = 0, len = rows.length; i < len; i++){
43421 this.selectRow(rows[i], true);
43426 selectRange : function(startRow, endRow, keepExisting){
43428 if(this.isLocked()){
43432 this.clearSelections();
43434 if(startRow <= endRow){
43435 for(i = startRow; i <= endRow; i++){
43436 this.selectRow(i, true);
43439 for(i = startRow; i >= endRow; i--){
43440 this.selectRow(i, true);
43446 deselectRange : function(startRow, endRow, preventViewNotify){
43447 if(this.isLocked()){
43450 for(var i = startRow; i <= endRow; i++){
43451 this.deselectRow(i, preventViewNotify);
43456 selectRow : function(index, keepExisting, preventViewNotify){
43457 if(this.isLocked() || (index < 0 || index >= this.grid.store.getCount()) || (keepExisting && this.isSelected(index))){
43460 var r = this.grid.store.getAt(index);
43461 if(r && this.fireEvent('beforerowselect', this, index, keepExisting, r) !== false){
43462 if(!keepExisting || this.singleSelect){
43463 this.clearSelections();
43465 this.selections.add(r);
43466 this.last = this.lastActive = index;
43467 if(!preventViewNotify){
43468 this.grid.getView().onRowSelect(index);
43470 this.fireEvent('rowselect', this, index, r);
43471 this.fireEvent('selectionchange', this);
43476 deselectRow : function(index, preventViewNotify){
43477 if(this.isLocked()){
43480 if(this.last == index){
43483 if(this.lastActive == index){
43484 this.lastActive = false;
43486 var r = this.grid.store.getAt(index);
43488 this.selections.remove(r);
43489 if(!preventViewNotify){
43490 this.grid.getView().onRowDeselect(index);
43492 this.fireEvent('rowdeselect', this, index, r);
43493 this.fireEvent('selectionchange', this);
43498 restoreLast : function(){
43500 this.last = this._last;
43505 acceptsNav : function(row, col, cm){
43506 return !cm.isHidden(col) && cm.isCellEditable(col, row);
43510 onEditorKey : function(field, e){
43511 var k = e.getKey(),
43515 ed = g.activeEditor,
43517 var shift = e.shiftKey;
43522 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
43524 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
43526 }else if(k == e.ENTER){
43527 if(this.moveEditorOnEnter !== false){
43529 newCell = g.walkCells(last.row - 1, last.col, -1, this.acceptsNav, this);
43531 newCell = g.walkCells(last.row + 1, last.col, 1, this.acceptsNav, this);
43543 if(g.isEditor && g.editing){
43544 ae = g.activeEditor;
43545 if(ae && ae.field.triggerBlur){
43547 ae.field.triggerBlur();
43550 g.startEditing(r, c);
43554 destroy : function(){
43556 this.rowNav.disable();
43557 this.rowNav = null;
43559 Ext.grid.RowSelectionModel.superclass.destroy.call(this);
43562 Ext.grid.Column = Ext.extend(Object, {
43589 constructor : function(config){
43590 Ext.apply(this, config);
43592 if(Ext.isString(this.renderer)){
43593 this.renderer = Ext.util.Format[this.renderer];
43594 }else if(Ext.isObject(this.renderer)){
43595 this.scope = this.renderer.scope;
43596 this.renderer = this.renderer.fn;
43603 this.editor = Ext.create(this.editor, 'textfield');
43608 renderer : function(value){
43609 if(Ext.isString(value) && value.length < 1){
43616 getEditor: function(rowIndex){
43617 return this.editable !== false ? this.editor : null;
43621 getCellEditor: function(rowIndex){
43622 var editor = this.getEditor(rowIndex);
43624 if(!editor.startEdit){
43625 if(!editor.gridEditor){
43626 editor.gridEditor = new Ext.grid.GridEditor(editor);
43628 return editor.gridEditor;
43629 }else if(editor.startEdit){
43638 Ext.grid.BooleanColumn = Ext.extend(Ext.grid.Column, {
43642 falseText: 'false',
43644 undefinedText: ' ',
43646 constructor: function(cfg){
43647 Ext.grid.BooleanColumn.superclass.constructor.call(this, cfg);
43648 var t = this.trueText, f = this.falseText, u = this.undefinedText;
43649 this.renderer = function(v){
43650 if(v === undefined){
43653 if(!v || v === 'false'){
43662 Ext.grid.NumberColumn = Ext.extend(Ext.grid.Column, {
43664 format : '0,000.00',
43665 constructor: function(cfg){
43666 Ext.grid.NumberColumn.superclass.constructor.call(this, cfg);
43667 this.renderer = Ext.util.Format.numberRenderer(this.format);
43672 Ext.grid.DateColumn = Ext.extend(Ext.grid.Column, {
43675 constructor: function(cfg){
43676 Ext.grid.DateColumn.superclass.constructor.call(this, cfg);
43677 this.renderer = Ext.util.Format.dateRenderer(this.format);
43682 Ext.grid.TemplateColumn = Ext.extend(Ext.grid.Column, {
43684 constructor: function(cfg){
43685 Ext.grid.TemplateColumn.superclass.constructor.call(this, cfg);
43686 var tpl = (!Ext.isPrimitive(this.tpl) && this.tpl.compile) ? this.tpl : new Ext.XTemplate(this.tpl);
43687 this.renderer = function(value, p, r){
43688 return tpl.apply(r.data);
43695 Ext.grid.Column.types = {
43696 gridcolumn : Ext.grid.Column,
43697 booleancolumn: Ext.grid.BooleanColumn,
43698 numbercolumn: Ext.grid.NumberColumn,
43699 datecolumn: Ext.grid.DateColumn,
43700 templatecolumn: Ext.grid.TemplateColumn
43702 Ext.grid.RowNumberer = Ext.extend(Object, {
43710 constructor : function(config){
43711 Ext.apply(this, config);
43713 this.renderer = this.renderer.createDelegate(this);
43722 rowspan: undefined,
43725 renderer : function(v, p, record, rowIndex){
43727 p.cellAttr = 'rowspan="'+this.rowspan+'"';
43732 Ext.grid.CheckboxSelectionModel = Ext.extend(Ext.grid.RowSelectionModel, {
43736 header : '<div class="x-grid3-hd-checker"> </div>',
43743 menuDisabled : true,
43748 constructor : function(){
43749 Ext.grid.CheckboxSelectionModel.superclass.constructor.apply(this, arguments);
43751 if(this.checkOnly){
43752 this.handleMouseDown = Ext.emptyFn;
43757 initEvents : function(){
43758 Ext.grid.CheckboxSelectionModel.superclass.initEvents.call(this);
43759 this.grid.on('render', function(){
43760 var view = this.grid.getView();
43761 view.mainBody.on('mousedown', this.onMouseDown, this);
43762 Ext.fly(view.innerHd).on('mousedown', this.onHdMouseDown, this);
43768 onMouseDown : function(e, t){
43769 if(e.button === 0 && t.className == 'x-grid3-row-checker'){
43771 var row = e.getTarget('.x-grid3-row');
43773 var index = row.rowIndex;
43774 if(this.isSelected(index)){
43775 this.deselectRow(index);
43777 this.selectRow(index, true);
43784 onHdMouseDown : function(e, t){
43785 if(t.className == 'x-grid3-hd-checker'){
43787 var hd = Ext.fly(t.parentNode);
43788 var isChecked = hd.hasClass('x-grid3-hd-checker-on');
43790 hd.removeClass('x-grid3-hd-checker-on');
43791 this.clearSelections();
43793 hd.addClass('x-grid3-hd-checker-on');
43800 renderer : function(v, p, record){
43801 return '<div class="x-grid3-row-checker"> </div>';
43804 Ext.grid.CellSelectionModel = Ext.extend(Ext.grid.AbstractSelectionModel, {
43806 constructor : function(config){
43807 Ext.apply(this, config);
43809 this.selection = null;
43813 "beforecellselect",
43820 Ext.grid.CellSelectionModel.superclass.constructor.call(this);
43824 initEvents : function(){
43825 this.grid.on('cellmousedown', this.handleMouseDown, this);
43826 this.grid.on(Ext.EventManager.useKeydown ? 'keydown' : 'keypress', this.handleKeyDown, this);
43827 this.grid.getView().on({
43829 refresh: this.onViewChange,
43830 rowupdated: this.onRowUpdated,
43831 beforerowremoved: this.clearSelections,
43832 beforerowsinserted: this.clearSelections
43834 if(this.grid.isEditor){
43835 this.grid.on('beforeedit', this.beforeEdit, this);
43840 beforeEdit : function(e){
43841 this.select(e.row, e.column, false, true, e.record);
43845 onRowUpdated : function(v, index, r){
43846 if(this.selection && this.selection.record == r){
43847 v.onCellSelect(index, this.selection.cell[1]);
43852 onViewChange : function(){
43853 this.clearSelections(true);
43857 getSelectedCell : function(){
43858 return this.selection ? this.selection.cell : null;
43862 clearSelections : function(preventNotify){
43863 var s = this.selection;
43865 if(preventNotify !== true){
43866 this.grid.view.onCellDeselect(s.cell[0], s.cell[1]);
43868 this.selection = null;
43869 this.fireEvent("selectionchange", this, null);
43874 hasSelection : function(){
43875 return this.selection ? true : false;
43879 handleMouseDown : function(g, row, cell, e){
43880 if(e.button !== 0 || this.isLocked()){
43883 this.select(row, cell);
43887 select : function(rowIndex, colIndex, preventViewNotify, preventFocus, r){
43888 if(this.fireEvent("beforecellselect", this, rowIndex, colIndex) !== false){
43889 this.clearSelections();
43890 r = r || this.grid.store.getAt(rowIndex);
43893 cell : [rowIndex, colIndex]
43895 if(!preventViewNotify){
43896 var v = this.grid.getView();
43897 v.onCellSelect(rowIndex, colIndex);
43898 if(preventFocus !== true){
43899 v.focusCell(rowIndex, colIndex);
43902 this.fireEvent("cellselect", this, rowIndex, colIndex);
43903 this.fireEvent("selectionchange", this, this.selection);
43908 isSelectable : function(rowIndex, colIndex, cm){
43909 return !cm.isHidden(colIndex);
43913 onEditorKey: function(field, e){
43914 if(e.getKey() == e.TAB){
43915 this.handleKeyDown(e);
43920 handleKeyDown : function(e){
43921 if(!e.isNavKeyPress()){
43925 var k = e.getKey(),
43927 s = this.selection,
43929 walk = function(row, col, step){
43930 return g.walkCells(
43934 g.isEditor && g.editing ? sm.acceptsNav : sm.isSelectable,
43938 cell, newCell, r, c, ae;
43953 cell = walk(0, 0, 1);
43955 this.select(cell[0], cell[1]);
43967 newCell = walk(r, c - 1, -1);
43969 newCell = walk(r, c + 1, 1);
43973 newCell = walk(r + 1, c, 1);
43976 newCell = walk(r - 1, c, -1);
43979 newCell = walk(r, c + 1, 1);
43982 newCell = walk(r, c - 1, -1);
43985 if (g.isEditor && !g.editing) {
43986 g.startEditing(r, c);
43999 if(g.isEditor && g.editing){
44000 ae = g.activeEditor;
44001 if(ae && ae.field.triggerBlur){
44003 ae.field.triggerBlur();
44005 g.startEditing(r, c);
44010 acceptsNav : function(row, col, cm){
44011 return !cm.isHidden(col) && cm.isCellEditable(col, row);
44014 Ext.grid.EditorGridPanel = Ext.extend(Ext.grid.GridPanel, {
44019 forceValidation: false,
44027 autoEncode : false,
44031 trackMouseOver: false,
44034 initComponent : function(){
44035 Ext.grid.EditorGridPanel.superclass.initComponent.call(this);
44037 if(!this.selModel){
44039 this.selModel = new Ext.grid.CellSelectionModel();
44042 this.activeEditor = null;
44055 initEvents : function(){
44056 Ext.grid.EditorGridPanel.superclass.initEvents.call(this);
44058 this.getGridEl().on('mousewheel', this.stopEditing.createDelegate(this, [true]), this);
44059 this.on('columnresize', this.stopEditing, this, [true]);
44061 if(this.clicksToEdit == 1){
44062 this.on("cellclick", this.onCellDblClick, this);
44064 var view = this.getView();
44065 if(this.clicksToEdit == 'auto' && view.mainBody){
44066 view.mainBody.on('mousedown', this.onAutoEditClick, this);
44068 this.on('celldblclick', this.onCellDblClick, this);
44072 onResize : function(){
44073 Ext.grid.EditorGridPanel.superclass.onResize.apply(this, arguments);
44074 var ae = this.activeEditor;
44075 if(this.editing && ae){
44081 onCellDblClick : function(g, row, col){
44082 this.startEditing(row, col);
44086 onAutoEditClick : function(e, t){
44087 if(e.button !== 0){
44090 var row = this.view.findRowIndex(t),
44091 col = this.view.findCellIndex(t);
44092 if(row !== false && col !== false){
44093 this.stopEditing();
44094 if(this.selModel.getSelectedCell){
44095 var sc = this.selModel.getSelectedCell();
44096 if(sc && sc[0] === row && sc[1] === col){
44097 this.startEditing(row, col);
44100 if(this.selModel.isSelected(row)){
44101 this.startEditing(row, col);
44108 onEditComplete : function(ed, value, startValue){
44109 this.editing = false;
44110 this.activeEditor = null;
44113 field = this.colModel.getDataIndex(ed.col);
44114 value = this.postEditValue(value, startValue, r, field);
44115 if(this.forceValidation === true || String(value) !== String(startValue)){
44120 originalValue: startValue,
44126 if(this.fireEvent("validateedit", e) !== false && !e.cancel && String(value) !== String(startValue)){
44127 r.set(field, e.value);
44129 this.fireEvent("afteredit", e);
44132 this.view.focusCell(ed.row, ed.col);
44136 startEditing : function(row, col){
44137 this.stopEditing();
44138 if(this.colModel.isCellEditable(col, row)){
44139 this.view.ensureVisible(row, col, true);
44140 var r = this.store.getAt(row),
44141 field = this.colModel.getDataIndex(col),
44146 value: r.data[field],
44151 if(this.fireEvent("beforeedit", e) !== false && !e.cancel){
44152 this.editing = true;
44153 var ed = this.colModel.getCellEditor(col, row);
44158 ed.parentEl = this.view.getEditorParent(ed);
44163 c.field.focus(false, true);
44168 specialkey: function(field, e){
44169 this.getSelectionModel().onEditorKey(field, e);
44171 complete: this.onEditComplete,
44172 canceledit: this.stopEditing.createDelegate(this, [true])
44184 this.activeEditor = ed;
44185 var v = this.preEditValue(r, field);
44186 ed.startEdit(this.view.getCell(row, col).firstChild, Ext.isDefined(v) ? v : '');
44192 preEditValue : function(r, field){
44193 var value = r.data[field];
44194 return this.autoEncode && Ext.isString(value) ? Ext.util.Format.htmlDecode(value) : value;
44198 postEditValue : function(value, originalValue, r, field){
44199 return this.autoEncode && Ext.isString(value) ? Ext.util.Format.htmlEncode(value) : value;
44203 stopEditing : function(cancel){
44205 var ae = this.activeEditor;
44207 ae[cancel === true ? 'cancelEdit' : 'completeEdit']();
44208 this.view.focusCell(ae.row, ae.col);
44210 this.activeEditor = null;
44212 this.editing = false;
44215 Ext.reg('editorgrid', Ext.grid.EditorGridPanel);
44217 Ext.grid.GridEditor = function(field, config){
44218 Ext.grid.GridEditor.superclass.constructor.call(this, field, config);
44219 field.monitorTab = false;
44222 Ext.extend(Ext.grid.GridEditor, Ext.Editor, {
44223 alignment: "tl-tl",
44226 cls: "x-small-editor x-grid-editor",
44230 Ext.grid.PropertyRecord = Ext.data.Record.create([
44231 {name:'name',type:'string'}, 'value'
44235 Ext.grid.PropertyStore = Ext.extend(Ext.util.Observable, {
44237 constructor : function(grid, source){
44239 this.store = new Ext.data.Store({
44240 recordType : Ext.grid.PropertyRecord
44242 this.store.on('update', this.onUpdate, this);
44244 this.setSource(source);
44246 Ext.grid.PropertyStore.superclass.constructor.call(this);
44250 setSource : function(o){
44252 this.store.removeAll();
44255 if(this.isEditableValue(o[k])){
44256 data.push(new Ext.grid.PropertyRecord({name: k, value: o[k]}, k));
44259 this.store.loadRecords({records: data}, {}, true);
44263 onUpdate : function(ds, record, type){
44264 if(type == Ext.data.Record.EDIT){
44265 var v = record.data.value;
44266 var oldValue = record.modified.value;
44267 if(this.grid.fireEvent('beforepropertychange', this.source, record.id, v, oldValue) !== false){
44268 this.source[record.id] = v;
44270 this.grid.fireEvent('propertychange', this.source, record.id, v, oldValue);
44278 getProperty : function(row){
44279 return this.store.getAt(row);
44283 isEditableValue: function(val){
44284 return Ext.isPrimitive(val) || Ext.isDate(val);
44288 setValue : function(prop, value){
44289 this.source[prop] = value;
44290 this.store.getById(prop).set('value', value);
44294 getSource : function(){
44295 return this.source;
44300 Ext.grid.PropertyColumnModel = Ext.extend(Ext.grid.ColumnModel, {
44303 valueText : 'Value',
44304 dateFormat : 'm/j/Y',
44306 constructor : function(grid, store){
44311 g.PropertyColumnModel.superclass.constructor.call(this, [
44312 {header: this.nameText, width:50, sortable: true, dataIndex:'name', id: 'name', menuDisabled:true},
44313 {header: this.valueText, width:50, resizable:false, dataIndex: 'value', id: 'value', menuDisabled:true}
44315 this.store = store;
44317 var bfield = new f.Field({
44318 autoCreate: {tag: 'select', children: [
44319 {tag: 'option', value: 'true', html: 'true'},
44320 {tag: 'option', value: 'false', html: 'false'}
44322 getValue : function(){
44323 return this.el.dom.value == 'true';
44327 'date' : new g.GridEditor(new f.DateField({selectOnFocus:true})),
44328 'string' : new g.GridEditor(new f.TextField({selectOnFocus:true})),
44329 'number' : new g.GridEditor(new f.NumberField({selectOnFocus:true, style:'text-align:left;'})),
44330 'boolean' : new g.GridEditor(bfield, {
44334 this.renderCellDelegate = this.renderCell.createDelegate(this);
44335 this.renderPropDelegate = this.renderProp.createDelegate(this);
44339 renderDate : function(dateVal){
44340 return dateVal.dateFormat(this.dateFormat);
44344 renderBool : function(bVal){
44345 return bVal ? 'true' : 'false';
44349 isCellEditable : function(colIndex, rowIndex){
44350 return colIndex == 1;
44354 getRenderer : function(col){
44356 this.renderCellDelegate : this.renderPropDelegate;
44360 renderProp : function(v){
44361 return this.getPropertyName(v);
44365 renderCell : function(val){
44367 if(Ext.isDate(val)){
44368 rv = this.renderDate(val);
44369 }else if(typeof val == 'boolean'){
44370 rv = this.renderBool(val);
44372 return Ext.util.Format.htmlEncode(rv);
44376 getPropertyName : function(name){
44377 var pn = this.grid.propertyNames;
44378 return pn && pn[name] ? pn[name] : name;
44382 getCellEditor : function(colIndex, rowIndex){
44383 var p = this.store.getProperty(rowIndex),
44385 val = p.data.value;
44386 if(this.grid.customEditors[n]){
44387 return this.grid.customEditors[n];
44389 if(Ext.isDate(val)){
44390 return this.editors.date;
44391 }else if(typeof val == 'number'){
44392 return this.editors.number;
44393 }else if(typeof val == 'boolean'){
44394 return this.editors['boolean'];
44396 return this.editors.string;
44401 destroy : function(){
44402 Ext.grid.PropertyColumnModel.superclass.destroy.call(this);
44403 for(var ed in this.editors){
44404 Ext.destroy(this.editors[ed]);
44410 Ext.grid.PropertyGrid = Ext.extend(Ext.grid.EditorGridPanel, {
44416 enableColumnMove:false,
44418 trackMouseOver: false,
44420 enableHdMenu : false,
44426 initComponent : function(){
44427 this.customEditors = this.customEditors || {};
44428 this.lastEditRow = null;
44429 var store = new Ext.grid.PropertyStore(this);
44430 this.propStore = store;
44431 var cm = new Ext.grid.PropertyColumnModel(this, store);
44432 store.store.sort('name', 'ASC');
44435 'beforepropertychange',
44440 this.ds = store.store;
44441 Ext.grid.PropertyGrid.superclass.initComponent.call(this);
44443 this.mon(this.selModel, 'beforecellselect', function(sm, rowIndex, colIndex){
44444 if(colIndex === 0){
44445 this.startEditing.defer(200, this, [rowIndex, 1]);
44452 onRender : function(){
44453 Ext.grid.PropertyGrid.superclass.onRender.apply(this, arguments);
44455 this.getGridEl().addClass('x-props-grid');
44459 afterRender: function(){
44460 Ext.grid.PropertyGrid.superclass.afterRender.apply(this, arguments);
44462 this.setSource(this.source);
44467 setSource : function(source){
44468 this.propStore.setSource(source);
44472 getSource : function(){
44473 return this.propStore.getSource();
44481 Ext.reg("propertygrid", Ext.grid.PropertyGrid);
44483 Ext.grid.GroupingView = Ext.extend(Ext.grid.GridView, {
44486 groupByText : 'Group By This Field',
44488 showGroupsText : 'Show in Groups',
44490 hideGroupedColumn : false,
44492 showGroupName : true,
44494 startCollapsed : false,
44496 enableGrouping : true,
44498 enableGroupingMenu : true,
44500 enableNoGroups : true,
44502 emptyGroupText : '(None)',
44506 groupTextTpl : '{text}',
44509 groupMode: 'value',
44517 initTemplates : function(){
44518 Ext.grid.GroupingView.superclass.initTemplates.call(this);
44521 var sm = this.grid.getSelectionModel();
44522 sm.on(sm.selectRow ? 'beforerowselect' : 'beforecellselect',
44523 this.onBeforeRowSelect, this);
44525 if(!this.startGroup){
44526 this.startGroup = new Ext.XTemplate(
44527 '<div id="{groupId}" class="x-grid-group {cls}">',
44528 '<div id="{groupId}-hd" class="x-grid-group-hd" style="{style}"><div class="x-grid-group-title">', this.groupTextTpl ,'</div></div>',
44529 '<div id="{groupId}-bd" class="x-grid-group-body">'
44532 this.startGroup.compile();
44533 if(!this.endGroup){
44534 this.endGroup = '</div></div>';
44537 this.endGroup = '</div></div>';
44541 findGroup : function(el){
44542 return Ext.fly(el).up('.x-grid-group', this.mainBody.dom);
44546 getGroups : function(){
44547 return this.hasRows() ? this.mainBody.dom.childNodes : [];
44551 onAdd : function(){
44552 if(this.enableGrouping && !this.ignoreAdd){
44553 var ss = this.getScrollState();
44555 this.restoreScroll(ss);
44556 }else if(!this.enableGrouping){
44557 Ext.grid.GroupingView.superclass.onAdd.apply(this, arguments);
44562 onRemove : function(ds, record, index, isUpdate){
44563 Ext.grid.GroupingView.superclass.onRemove.apply(this, arguments);
44564 var g = document.getElementById(record._groupId);
44565 if(g && g.childNodes[1].childNodes.length < 1){
44568 this.applyEmptyText();
44572 refreshRow : function(record){
44573 if(this.ds.getCount()==1){
44576 this.isUpdating = true;
44577 Ext.grid.GroupingView.superclass.refreshRow.apply(this, arguments);
44578 this.isUpdating = false;
44583 beforeMenuShow : function(){
44584 var item, items = this.hmenu.items, disabled = this.cm.config[this.hdCtxIndex].groupable === false;
44585 if((item = items.get('groupBy'))){
44586 item.setDisabled(disabled);
44588 if((item = items.get('showGroups'))){
44589 item.setDisabled(disabled);
44590 item.setChecked(this.enableGrouping, true);
44595 renderUI : function(){
44596 Ext.grid.GroupingView.superclass.renderUI.call(this);
44597 this.mainBody.on('mousedown', this.interceptMouse, this);
44599 if(this.enableGroupingMenu && this.hmenu){
44600 this.hmenu.add('-',{
44602 text: this.groupByText,
44603 handler: this.onGroupByClick,
44605 iconCls:'x-group-by-icon'
44607 if(this.enableNoGroups){
44609 itemId:'showGroups',
44610 text: this.showGroupsText,
44612 checkHandler: this.onShowGroupsClick,
44616 this.hmenu.on('beforeshow', this.beforeMenuShow, this);
44620 processEvent: function(name, e){
44621 var hd = e.getTarget('.x-grid-group-hd', this.mainBody);
44624 var field = this.getGroupField(),
44625 prefix = this.getPrefix(field),
44626 groupValue = hd.id.substring(prefix.length);
44629 groupValue = groupValue.substr(0, groupValue.length - 3);
44631 this.grid.fireEvent('group' + name, this.grid, field, groupValue, e);
44638 onGroupByClick : function(){
44639 this.enableGrouping = true;
44640 this.grid.store.groupBy(this.cm.getDataIndex(this.hdCtxIndex));
44641 this.beforeMenuShow();
44646 onShowGroupsClick : function(mi, checked){
44647 this.enableGrouping = checked;
44649 this.onGroupByClick();
44651 this.grid.store.clearGrouping();
44656 toggleRowIndex : function(rowIndex, expanded){
44657 if(!this.enableGrouping){
44660 var row = this.getRow(rowIndex);
44662 this.toggleGroup(this.findGroup(row), expanded);
44667 toggleGroup : function(group, expanded){
44668 var gel = Ext.get(group);
44669 expanded = Ext.isDefined(expanded) ? expanded : gel.hasClass('x-grid-group-collapsed');
44670 if(this.state[gel.id] !== expanded){
44671 this.grid.stopEditing(true);
44672 this.state[gel.id] = expanded;
44673 gel[expanded ? 'removeClass' : 'addClass']('x-grid-group-collapsed');
44678 toggleAllGroups : function(expanded){
44679 var groups = this.getGroups();
44680 for(var i = 0, len = groups.length; i < len; i++){
44681 this.toggleGroup(groups[i], expanded);
44686 expandAllGroups : function(){
44687 this.toggleAllGroups(true);
44691 collapseAllGroups : function(){
44692 this.toggleAllGroups(false);
44696 interceptMouse : function(e){
44697 var hd = e.getTarget('.x-grid-group-hd', this.mainBody);
44700 this.toggleGroup(hd.parentNode);
44705 getGroup : function(v, r, groupRenderer, rowIndex, colIndex, ds){
44706 var g = groupRenderer ? groupRenderer(v, {}, r, rowIndex, colIndex, ds) : String(v);
44707 if(g === '' || g === ' '){
44708 g = this.cm.config[colIndex].emptyGroupText || this.emptyGroupText;
44714 getGroupField : function(){
44715 return this.grid.store.getGroupState();
44719 afterRender : function(){
44720 Ext.grid.GroupingView.superclass.afterRender.call(this);
44721 if(this.grid.deferRowRender){
44722 this.updateGroupWidths();
44727 renderRows : function(){
44728 var groupField = this.getGroupField();
44729 var eg = !!groupField;
44731 if(this.hideGroupedColumn) {
44732 var colIndex = this.cm.findColumnIndex(groupField),
44733 hasLastGroupField = Ext.isDefined(this.lastGroupField);
44734 if(!eg && hasLastGroupField){
44735 this.mainBody.update('');
44736 this.cm.setHidden(this.cm.findColumnIndex(this.lastGroupField), false);
44737 delete this.lastGroupField;
44738 }else if (eg && !hasLastGroupField){
44739 this.lastGroupField = groupField;
44740 this.cm.setHidden(colIndex, true);
44741 }else if (eg && hasLastGroupField && groupField !== this.lastGroupField) {
44742 this.mainBody.update('');
44743 var oldIndex = this.cm.findColumnIndex(this.lastGroupField);
44744 this.cm.setHidden(oldIndex, false);
44745 this.lastGroupField = groupField;
44746 this.cm.setHidden(colIndex, true);
44749 return Ext.grid.GroupingView.superclass.renderRows.apply(
44754 doRender : function(cs, rs, ds, startRow, colCount, stripe){
44758 var groupField = this.getGroupField(),
44759 colIndex = this.cm.findColumnIndex(groupField),
44762 this.enableGrouping = (this.enableGrouping === false) ? false : !!groupField;
44764 if(!this.enableGrouping || this.isUpdating){
44765 return Ext.grid.GroupingView.superclass.doRender.apply(
44768 var gstyle = 'width:' + this.getTotalWidth() + ';',
44769 cfg = this.cm.config[colIndex],
44770 groupRenderer = cfg.groupRenderer || cfg.renderer,
44771 prefix = this.showGroupName ? (cfg.groupName || cfg.header)+': ' : '',
44773 curGroup, i, len, gid;
44775 for(i = 0, len = rs.length; i < len; i++){
44776 var rowIndex = startRow + i,
44778 gvalue = r.data[groupField];
44780 g = this.getGroup(gvalue, r, groupRenderer, rowIndex, colIndex, ds);
44781 if(!curGroup || curGroup.group != g){
44782 gid = this.constructId(gvalue, groupField, colIndex);
44785 this.state[gid] = !(Ext.isDefined(this.state[gid]) ? !this.state[gid] : this.startCollapsed);
44791 startRow: rowIndex,
44793 cls: this.state[gid] ? '' : 'x-grid-group-collapsed',
44796 groups.push(curGroup);
44798 curGroup.rs.push(r);
44804 for(i = 0, len = groups.length; i < len; i++){
44806 this.doGroupStart(buf, g, cs, ds, colCount);
44807 buf[buf.length] = Ext.grid.GroupingView.superclass.doRender.call(
44808 this, cs, g.rs, ds, g.startRow, colCount, stripe);
44810 this.doGroupEnd(buf, g, cs, ds, colCount);
44812 return buf.join('');
44816 getGroupId : function(value){
44817 var field = this.getGroupField();
44818 return this.constructId(value, field, this.cm.findColumnIndex(field));
44822 constructId : function(value, field, idx){
44823 var cfg = this.cm.config[idx],
44824 groupRenderer = cfg.groupRenderer || cfg.renderer,
44825 val = (this.groupMode == 'value') ? value : this.getGroup(value, {data:{}}, groupRenderer, 0, idx, this.ds);
44827 return this.getPrefix(field) + Ext.util.Format.htmlEncode(val);
44831 getPrefix: function(field){
44832 return this.grid.getGridEl().id + '-gp-' + field + '-';
44836 doGroupStart : function(buf, g, cs, ds, colCount){
44837 buf[buf.length] = this.startGroup.apply(g);
44841 doGroupEnd : function(buf, g, cs, ds, colCount){
44842 buf[buf.length] = this.endGroup;
44846 getRows : function(){
44847 if(!this.enableGrouping){
44848 return Ext.grid.GroupingView.superclass.getRows.call(this);
44851 var g, gs = this.getGroups();
44852 for(var i = 0, len = gs.length; i < len; i++){
44853 g = gs[i].childNodes[1].childNodes;
44854 for(var j = 0, jlen = g.length; j < jlen; j++){
44855 r[r.length] = g[j];
44862 updateGroupWidths : function(){
44863 if(!this.enableGrouping || !this.hasRows()){
44866 var tw = Math.max(this.cm.getTotalWidth(), this.el.dom.offsetWidth-this.getScrollOffset()) +'px';
44867 var gs = this.getGroups();
44868 for(var i = 0, len = gs.length; i < len; i++){
44869 gs[i].firstChild.style.width = tw;
44874 onColumnWidthUpdated : function(col, w, tw){
44875 Ext.grid.GroupingView.superclass.onColumnWidthUpdated.call(this, col, w, tw);
44876 this.updateGroupWidths();
44880 onAllColumnWidthsUpdated : function(ws, tw){
44881 Ext.grid.GroupingView.superclass.onAllColumnWidthsUpdated.call(this, ws, tw);
44882 this.updateGroupWidths();
44886 onColumnHiddenUpdated : function(col, hidden, tw){
44887 Ext.grid.GroupingView.superclass.onColumnHiddenUpdated.call(this, col, hidden, tw);
44888 this.updateGroupWidths();
44892 onLayout : function(){
44893 this.updateGroupWidths();
44897 onBeforeRowSelect : function(sm, rowIndex){
44898 this.toggleRowIndex(rowIndex, true);
44902 Ext.grid.GroupingView.GROUP_ID = 1000;