9 window["undefined"] = window["undefined"];
18 Roo.apply = function(o, c, A){
23 if(o && c && typeof c == 'object'){
34 var ua = navigator.userAgent.toLowerCase();
36 var C = document.compatMode == "CSS1Compat",
37 D = ua.indexOf("opera") > -1,
38 E = (/webkit|khtml/).test(ua),
39 F = ua.indexOf("msie") > -1,
40 G = ua.indexOf("msie 7") > -1,
41 H = !E && ua.indexOf("gecko") > -1,
43 J = (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1),
44 K = (ua.indexOf("macintosh") != -1 || ua.indexOf("mac os x") != -1),
45 L = (ua.indexOf("linux") != -1),
46 M = window.location.href.toLowerCase().indexOf("https") === 0;
51 document.execCommand("BackgroundImageCache", false, true);
73 enableGarbageCollector : true,
77 enableListenerCollection:false,
81 SSL_SECURE_URL : "javascript:false",
85 BLANK_IMAGE_URL : "http:/"+"/localhost/s.gif",
87 emptyFn : function(){},
91 applyIf : function(o, c){
94 if(typeof o[p] == "undefined"){ o[p] = c[p]; }
102 addBehaviors : function(o){
104 Roo.onReady(function(){
111 var parts = b.split('@');
115 N[s] = Roo.select(s);
118 N[s].on(parts[1], o[b]);
127 id : function(el, O){
131 return el ? (el.id ? el.id : (el.id = id)) : id;
139 var io = function(o){
144 return function(sb, sp, P){
145 if(typeof sp == 'object'){
148 sb = function(){sp.apply(this, arguments);};
150 var F = function(){}, sbp, spp = sp.prototype;
152 sbp = sb.prototype = new F();
156 if(spp.constructor == Object.prototype.constructor){
162 sb.override = function(o){
173 override : function(P, Q){
176 for(var method in Q){
177 p[method] = Q[method];
183 namespace : function(){
184 var a=arguments, o=null, i, j, d, rt;
185 for (i=0; i<a.length; ++i) {
190 eval('if (typeof ' + rt + ' == "undefined"){' + rt + ' = {};} o = ' + rt + ';');
191 for (j=1; j<d.length; ++j) {
192 o[d[j]]=o[d[j]] || {};
200 factory : function(c, ns)
203 if (!c.xtype || (!ns && !c.xns) || (c.xns === false)) {
207 ns = c.xns ? c.xns : ns;
208 if (c.constructor == ns[c.xtype]) {
212 if (Roo.debug) Roo.log("Roo.Factory(" + c.xtype + ")");
213 var ret = new ns[c.xtype](c);
225 if ((typeof(console) == 'undefined') || (typeof(console.log) == 'undefined')) {
234 urlEncode : function(o){
240 var ov = o[key], k = encodeURIComponent(key);
241 var type = typeof ov;
242 if(type == 'undefined'){
244 }else if(type != "function" && type != "object"){
245 R.push(k, "=", encodeURIComponent(ov), "&");
246 }else if(ov instanceof Array){
248 for(var i = 0, len = ov.length; i < len; i++) {
249 R.push(k, "=", encodeURIComponent(ov[i] === undefined ? '' : ov[i]), "&");
263 urlDecode : function(S, T){
268 var V = S.split('&');
270 for(var i = 0, len = V.length; i < len; i++){
272 X = decodeURIComponent(W[0]);
273 Y = decodeURIComponent(W[1]);
275 if(typeof U[X] == "undefined"){
277 }else if(typeof U[X] == "string"){
292 each : function(Z, fn, f){
293 if(typeof Z.length == "undefined" || typeof Z == "string"){
296 for(var i = 0, len = Z.length; i < len; i++){
297 if(fn.call(f || Z[i], Z[i], i, Z) === false){ return i; };
302 combine : function(){
303 var as = arguments, l = as.length, r = [];
304 for(var i = 0; i < l; i++){
306 if(a instanceof Array){
308 }else if(a.length !== undefined && !a.substr){
309 r = r.concat(Array.prototype.slice.call(a, 0));
319 escapeRe : function(s) {
320 return s.replace(/([.*+?^${}()|[\]\/\\])/g, "\\$1");
324 callback : function(cb, g, h, n){
325 if(typeof cb == "function"){
327 cb.defer(n, g, h || []);
329 cb.apply(g, h || []);
336 getDom : function(el){
340 return el.dom ? el.dom : (typeof el == 'string' ? document.getElementById(el) : el);
345 getCmp : function(id){
346 return Roo.ComponentMgr.get(id);
349 num : function(v, q){
350 if(typeof v != 'number'){
356 destroy : function(){
357 for(var i = 0, a = arguments, len = a.length; i < len; i++) {
361 as.removeAllListeners();
365 if(typeof as.purgeListeners == 'function'){
368 if(typeof as.destroy == 'function'){
379 if(o === undefined || o === null){
386 if(t == 'object' && o.nodeName) {
388 case 1: return 'element';
389 case 3: return (/\S/).test(o.nodeValue) ? 'textnode' : 'whitespace';
392 if(t == 'object' || t == 'function') {
393 switch(o.constructor) {
394 case Array: return 'array';
395 case RegExp: return 'regexp';
397 if(typeof o.length == 'number' && typeof o.item == 'function') {
406 isEmpty : function(v, u){
407 return v === null || v === undefined || (!u ? v === '' : false);
440 useShims : ((F && !G) || (H && K))
446 Roo.namespace("Roo", "Roo.util", "Roo.grid", "Roo.dd", "Roo.tree", "Roo.data",
447 "Roo.form", "Roo.menu", "Roo.state", "Roo.lib", "Roo.layout", "Roo.app", "Roo.ux");
456 var p = Function.prototype;
457 delete p.createSequence;
459 delete p.createDelegate;
460 delete p.createCallback;
461 delete p.createInterceptor;
463 window.detachEvent("onunload", A);
466 window.attachEvent("onunload", A);
473 Roo.apply(Function.prototype, {
476 createCallback : function(
482 return C.apply(window, B);
488 createDelegate : function(D, E, F){
491 var H = E || arguments;
493 H = Array.prototype.slice.call(arguments, 0);
495 }else if(typeof F == "number"){
496 H = Array.prototype.slice.call(arguments, 0);
497 var applyArgs = [F, 0].concat(E);
498 Array.prototype.splice.apply(H, applyArgs);
500 return G.apply(D || window, H);
506 defer : function(H, I, J, K){
507 var fn = this.createDelegate(I, J, K);
509 return setTimeout(fn, H);
517 createSequence : function(L, M){
518 if(typeof L != "function"){
523 var O = N.apply(this || window, arguments);
524 L.apply(M || this || window, arguments);
531 createInterceptor : function(O, P){
532 if(typeof O != "function"){
539 if(O.apply(P || this || window, arguments) === false){
542 return Q.apply(this || window, arguments);
550 Roo.applyIf(String, {
557 escape : function(A) {
558 return A.replace(/('|\\)/g, "\\$1");
563 leftPad : function (B, C, ch) {
564 var D = new String(B);
565 if(ch === null || ch === undefined || ch === '') {
568 while (D.length < C) {
576 format : function(E){
577 var F = Array.prototype.slice.call(arguments, 1);
578 return E.replace(/\{(\d+)\}/g, function(m, i){
579 return Roo.util.Format.htmlEncode(F[i]);
587 String.prototype.toggle = function(G, H){
588 return this == G ? H : G;
595 Roo.applyIf(Number.prototype, {
598 constrain : function(A, B){
599 return Math.min(Math.max(this, A), B);
606 Roo.applyIf(Array.prototype, {
609 indexOf : function(o){
610 for (var i = 0, len = this.length; i < len; i++){
611 if(this[i] == o) return i;
618 remove : function(o){
619 var A = this.indexOf(o);
628 var C = this.length >>> 0;
629 if (typeof B != "function")
630 throw new TypeError();
632 var D = new Array(C);
633 var E = arguments[1];
634 for (var i = 0; i < C; i++)
637 D[i] = B.call(E, this[i], i, this);
660 Date.prototype.getElapsed = function(A) {
661 return Math.abs((A || new Date()).getTime()-this.getTime());
667 Date.parseFunctions = {count:0};
669 Date.parseRegexes = [];
671 Date.formatFunctions = {count:0};
674 Date.prototype.dateFormat = function(B) {
675 if (Date.formatFunctions[B] == null) {
676 Date.createNewFormat(B);
678 var C = Date.formatFunctions[B];
685 Date.prototype.format = Date.prototype.dateFormat;
688 Date.createNewFormat = function(D) {
689 var E = "format" + Date.formatFunctions.count++;
690 Date.formatFunctions[D] = E;
691 var F = "Date.prototype." + E + " = function(){return ";
694 for (var i = 0; i < D.length; ++i) {
696 if (!G && ch == "\\") {
701 F += "'" + String.escape(ch) + "' + ";
704 F += Date.getFormatCode(ch);
709 eval(F.substring(0, F.length - 3) + ";}");
713 Date.getFormatCode = function(H) {
716 return "String.leftPad(this.getDate(), 2, '0') + ";
718 return "Date.dayNames[this.getDay()].substring(0, 3) + ";
720 return "this.getDate() + ";
722 return "Date.dayNames[this.getDay()] + ";
724 return "this.getSuffix() + ";
726 return "this.getDay() + ";
728 return "this.getDayOfYear() + ";
730 return "this.getWeekOfYear() + ";
732 return "Date.monthNames[this.getMonth()] + ";
734 return "String.leftPad(this.getMonth() + 1, 2, '0') + ";
736 return "Date.monthNames[this.getMonth()].substring(0, 3) + ";
738 return "(this.getMonth() + 1) + ";
740 return "this.getDaysInMonth() + ";
742 return "(this.isLeapYear() ? 1 : 0) + ";
744 return "this.getFullYear() + ";
746 return "('' + this.getFullYear()).substring(2, 4) + ";
748 return "(this.getHours() < 12 ? 'am' : 'pm') + ";
750 return "(this.getHours() < 12 ? 'AM' : 'PM') + ";
752 return "((this.getHours() % 12) ? this.getHours() % 12 : 12) + ";
754 return "this.getHours() + ";
756 return "String.leftPad((this.getHours() % 12) ? this.getHours() % 12 : 12, 2, '0') + ";
758 return "String.leftPad(this.getHours(), 2, '0') + ";
760 return "String.leftPad(this.getMinutes(), 2, '0') + ";
762 return "String.leftPad(this.getSeconds(), 2, '0') + ";
764 return "this.getGMTOffset() + ";
766 return "this.getTimezone() + ";
768 return "(this.getTimezoneOffset() * -60) + ";
770 return "'" + String.escape(H) + "' + ";
776 Date.parseDate = function(I, J) {
777 if (Date.parseFunctions[J] == null) {
778 Date.createParser(J);
780 var K = Date.parseFunctions[J];
785 Date.createParser = function(L) {
786 var M = "parse" + Date.parseFunctions.count++;
787 var N = Date.parseRegexes.length;
789 Date.parseFunctions[L] = M;
791 var P = "Date." + M + " = function(input){\n"
792 + "var y = -1, m = -1, d = -1, h = -1, i = -1, s = -1, o, z, v;\n"
793 + "var d = new Date();\n"
794 + "y = d.getFullYear();\n"
795 + "m = d.getMonth();\n"
796 + "d = d.getDate();\n"
797 + "var results = input.match(Date.parseRegexes[" + N + "]);\n"
798 + "if (results && results.length > 0) {";
803 for (var i = 0; i < L.length; ++i) {
805 if (!R && ch == "\\") {
810 Q += String.escape(ch);
813 var obj = Date.formatCodeToRegex(ch, O);
816 if (obj.g && obj.c) {
823 P += "if (y >= 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n"
824 + "{v = new Date(y, m, d, h, i, s);}\n"
825 + "else if (y >= 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n"
826 + "{v = new Date(y, m, d, h, i);}\n"
827 + "else if (y >= 0 && m >= 0 && d > 0 && h >= 0)\n"
828 + "{v = new Date(y, m, d, h);}\n"
829 + "else if (y >= 0 && m >= 0 && d > 0)\n"
830 + "{v = new Date(y, m, d);}\n"
831 + "else if (y >= 0 && m >= 0)\n"
832 + "{v = new Date(y, m);}\n"
833 + "else if (y >= 0)\n"
834 + "{v = new Date(y);}\n"
835 + "}return (v && (z || o))?\n"
836 + " ((z)? v.add(Date.SECOND, (v.getTimezoneOffset() * 60) + (z*1)) :\n"
837 + " v.add(Date.HOUR, (v.getGMTOffset() / 100) + (o / -100))) : v\n"
840 Date.parseRegexes[N] = new RegExp("^" + Q + "$");
847 Date.formatCodeToRegex = function(S, T) {
852 s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};
855 c:"d = parseInt(results[" + T + "], 10);\n",
859 c:"d = parseInt(results[" + T + "], 10);\n",
864 s:"(?:" + Date.dayNames.join("|") + ")"};
868 s:"(?:st|nd|rd|th)"};
883 c:"m = parseInt(Date.monthNumbers[results[" + T + "].substring(0, 3)], 10);\n",
884 s:"(" + Date.monthNames.join("|") + ")"};
887 c:"m = parseInt(Date.monthNumbers[results[" + T + "]], 10);\n",
888 s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};
891 c:"m = parseInt(results[" + T + "], 10) - 1;\n",
895 c:"m = parseInt(results[" + T + "], 10) - 1;\n",
907 c:"y = parseInt(results[" + T + "], 10);\n",
911 c:"var ty = parseInt(results[" + T + "], 10);\n"
912 + "y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",
916 c:"if (results[" + T + "] == 'am') {\n"
917 + "if (h == 12) { h = 0; }\n"
918 + "} else { if (h < 12) { h += 12; }}",
922 c:"if (results[" + T + "] == 'AM') {\n"
923 + "if (h == 12) { h = 0; }\n"
924 + "} else { if (h < 12) { h += 12; }}",
929 c:"h = parseInt(results[" + T + "], 10);\n",
934 c:"h = parseInt(results[" + T + "], 10);\n",
938 c:"i = parseInt(results[" + T + "], 10);\n",
942 c:"s = parseInt(results[" + T + "], 10);\n",
947 "o = results[", T, "];\n",
948 "var sn = o.substring(0,1);\n",
949 "var hr = o.substring(1,3)*1 + Math.floor(o.substring(3,5) / 60);\n",
950 "var mn = o.substring(3,5) % 60;\n",
951 "o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))?\n",
952 " (sn + String.leftPad(hr, 2, 0) + String.leftPad(mn, 2, 0)) : null;\n"
961 c:"z = results[" + T + "];\n"
962 + "z = (-43200 <= z*1 && z*1 <= 50400)? z : null;\n",
963 s:"([+\-]?\\d{1,5})"};
973 Date.prototype.getTimezone = function() {
974 return this.toString().replace(/^.*? ([A-Z]{1,4})[\-+][0-9]{4} .*$/, "$1");
979 Date.prototype.getGMTOffset = function() {
980 return (this.getTimezoneOffset() > 0 ? "-" : "+")
981 + String.leftPad(Math.abs(Math.floor(this.getTimezoneOffset() / 60)), 2, "0")
982 + String.leftPad(this.getTimezoneOffset() % 60, 2, "0");
987 Date.prototype.getDayOfYear = function() {
989 Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
990 for (var i = 0; i < this.getMonth(); ++i) {
991 U += Date.daysInMonth[i];
993 return U + this.getDate() - 1;
998 Date.prototype.getWeekOfYear = function() {
1000 var V = this.getDayOfYear() + (4 - this.getDay());
1002 var W = new Date(this.getFullYear(), 0, 1);
1003 var X = (7 - W.getDay() + 4);
1004 return String.leftPad(((V - X) / 7) + 1, 2, "0");
1009 Date.prototype.isLeapYear = function() {
1010 var Y = this.getFullYear();
1011 return ((Y & 3) == 0 && (Y % 100 || (Y % 400 == 0 && Y)));
1016 Date.prototype.getFirstDayOfMonth = function() {
1017 var Z = (this.getDay() - (this.getDate() - 1)) % 7;
1018 return (Z < 0) ? (Z + 7) : Z;
1023 Date.prototype.getLastDayOfMonth = function() {
1024 var a = (this.getDay() + (Date.daysInMonth[this.getMonth()] - this.getDate())) % 7;
1025 return (a < 0) ? (a + 7) : a;
1031 Date.prototype.getFirstDateOfMonth = function() {
1032 return new Date(this.getFullYear(), this.getMonth(), 1);
1037 Date.prototype.getLastDateOfMonth = function() {
1038 return new Date(this.getFullYear(), this.getMonth(), this.getDaysInMonth());
1042 Date.prototype.getDaysInMonth = function() {
1043 Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
1044 return Date.daysInMonth[this.getMonth()];
1049 Date.prototype.getSuffix = function() {
1050 switch (this.getDate()) {
1067 Date.daysInMonth = [31,28,31,30,31,30,31,31,30,31,30,31];
1099 Date.monthNumbers = {
1115 Date.prototype.clone = function() {
1116 return new Date(this.getTime());
1121 Date.prototype.clearTime = function(b){
1123 return this.clone().clearTime();
1129 this.setMilliseconds(0);
1136 Date.brokenSetMonth = Date.prototype.setMonth;
1137 Date.prototype.setMonth = function(c){
1139 var n = Math.ceil(-c);
1140 var back_year = Math.ceil(n/12);
1141 var month = (n % 12) ? 12 - n % 12 : 0 ;
1142 this.setFullYear(this.getFullYear() - back_year);
1143 return Date.brokenSetMonth.call(this, month);
1145 return Date.brokenSetMonth.apply(this, arguments);
1175 Date.prototype.add = function(e, f){
1176 var d = this.clone();
1177 if (!e || f === 0) return d;
1178 switch(e.toLowerCase()){
1180 d.setMilliseconds(this.getMilliseconds() + f);
1183 d.setSeconds(this.getSeconds() + f);
1186 d.setMinutes(this.getMinutes() + f);
1189 d.setHours(this.getHours() + f);
1192 d.setDate(this.getDate() + f);
1195 var a = this.getDate();
1197 a = Math.min(a, this.getFirstDateOfMonth().add('mo', f).getLastDateOfMonth().getDate());
1201 d.setMonth(this.getMonth() + f);
1204 d.setFullYear(this.getFullYear() + f);
1213 getViewWidth : function(A) {
1214 return A ? this.getDocumentWidth() : this.getViewportWidth();
1217 getViewHeight : function(B) {
1218 return B ? this.getDocumentHeight() : this.getViewportHeight();
1221 getDocumentHeight: function() {
1222 var C = (document.compatMode != "CSS1Compat") ? document.body.scrollHeight : document.documentElement.scrollHeight;
1223 return Math.max(C, this.getViewportHeight());
1226 getDocumentWidth: function() {
1227 var D = (document.compatMode != "CSS1Compat") ? document.body.scrollWidth : document.documentElement.scrollWidth;
1228 return Math.max(D, this.getViewportWidth());
1231 getViewportHeight: function() {
1232 var E = self.innerHeight;
1233 var F = document.compatMode;
1235 if ((F || Roo.isIE) && !Roo.isOpera) {
1236 E = (F == "CSS1Compat") ?
1237 document.documentElement.clientHeight :
1238 document.body.clientHeight;
1244 getViewportWidth: function() {
1245 var G = self.innerWidth;
1246 var H = document.compatMode;
1248 if (H || Roo.isIE) {
1249 G = (H == "CSS1Compat") ?
1250 document.documentElement.clientWidth :
1251 document.body.clientWidth;
1256 isAncestor : function(p, c) {
1263 if (p.contains && !Roo.isSafari) {
1264 return p.contains(c);
1265 } else if (p.compareDocumentPosition) {
1266 return !!(p.compareDocumentPosition(c) & 16);
1268 var parent = c.parentNode;
1273 else if (!parent.tagName || parent.tagName.toUpperCase() == "HTML") {
1277 parent = parent.parentNode;
1283 getRegion : function(el) {
1284 return Roo.lib.Region.getRegion(el);
1287 getY : function(el) {
1288 return this.getXY(el)[1];
1291 getX : function(el) {
1292 return this.getXY(el)[0];
1295 getXY : function(el) {
1296 var p, pe, b, I, bd = document.body;
1297 el = Roo.getDom(el);
1298 var J = Roo.lib.AnimBase.fly;
1299 if (el.getBoundingClientRect) {
1300 b = el.getBoundingClientRect();
1301 I = J(document).getScroll();
1302 return [b.left + I.left, b.top + I.top];
1308 var K = J(el).getStyle("position") == "absolute";
1315 if (!K && J(p).getStyle("position") == "absolute") {
1322 var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
1323 var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
1330 if (p != el && pe.getStyle('overflow') != 'visible') {
1339 if (Roo.isSafari && K) {
1344 if (Roo.isGecko && !K) {
1346 x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
1347 y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
1352 while (p && p != bd) {
1353 if (!Roo.isOpera || (p.tagName != 'TR' && J(p).getStyle("display") != "inline")) {
1366 setXY : function(el, xy) {
1367 el = Roo.fly(el, '_setXY');
1369 var L = el.translatePoints(xy);
1370 if (xy[0] !== false) {
1371 el.dom.style.left = L.left + "px";
1373 if (xy[1] !== false) {
1374 el.dom.style.top = L.top + "px";
1378 setX : function(el, x) {
1379 this.setXY(el, [x, false]);
1382 setY : function(el, y) {
1383 this.setXY(el, [false, y]);
1390 Roo.lib.Event = function() {
1410 startInterval: function() {
1411 if (!this._interval) {
1413 var callback = function() {
1414 self._tryPreloadAttach();
1416 this._interval = setInterval(callback, this.POLL_INTERVAL);
1421 onAvailable: function(h, k, m, n) {
1426 checkReady: false });
1428 D = this.POLL_RETRYS;
1429 this.startInterval();
1433 addListener: function(el, o, fn) {
1434 el = Roo.getDom(el);
1439 if ("unload" == o) {
1445 var p = function(e) {
1446 return fn(Roo.lib.Event.getEvent(e));
1449 var li = [el, o, fn, p];
1454 this.doAdd(el, o, p, false);
1460 removeListener: function(el, r, fn) {
1463 el = Roo.getDom(el);
1466 return this.purgeElement(el, false, r);
1470 if ("unload" == r) {
1472 for (i = 0,s = C.length; i < s; i++) {
1489 var v = arguments[3];
1491 if ("undefined" == typeof v) {
1492 v = this._getCacheIndex(el, r, fn);
1504 this.doRemove(el, r, u[this.WFN], false);
1506 delete B[v][this.WFN];
1507 delete B[v][this.FN];
1515 getTarget: function(ev, w) {
1516 ev = ev.browserEvent || ev;
1517 var t = ev.target || ev.srcElement;
1518 return this.resolveTextNode(t);
1522 resolveTextNode: function(z) {
1523 if (Roo.isSafari && z && 3 == z.nodeType) {
1524 return z.parentNode;
1531 getPageX: function(ev) {
1532 ev = ev.browserEvent || ev;
1534 if (!x && 0 !== x) {
1535 x = ev.clientX || 0;
1538 x += this.getScroll()[1];
1546 getPageY: function(ev) {
1547 ev = ev.browserEvent || ev;
1549 if (!y && 0 !== y) {
1550 y = ev.clientY || 0;
1553 y += this.getScroll()[0];
1562 getXY: function(ev) {
1563 ev = ev.browserEvent || ev;
1564 return [this.getPageX(ev), this.getPageY(ev)];
1568 getRelatedTarget: function(ev) {
1569 ev = ev.browserEvent || ev;
1570 var t = ev.relatedTarget;
1572 if (ev.type == "mouseout") {
1574 } else if (ev.type == "mouseover") {
1579 return this.resolveTextNode(t);
1583 getTime: function(ev) {
1584 ev = ev.browserEvent || ev;
1586 var t = new Date().getTime();
1590 this.lastError = ex;
1599 stopEvent: function(ev) {
1600 this.stopPropagation(ev);
1601 this.preventDefault(ev);
1605 stopPropagation: function(ev) {
1606 ev = ev.browserEvent || ev;
1607 if (ev.stopPropagation) {
1608 ev.stopPropagation();
1610 ev.cancelBubble = true;
1615 preventDefault: function(ev) {
1616 ev = ev.browserEvent || ev;
1617 if(ev.preventDefault) {
1618 ev.preventDefault();
1620 ev.returnValue = false;
1625 getEvent: function(e) {
1626 var ev = e || window.event;
1628 var c = this.getEvent.caller;
1630 ev = c.arguments[0];
1631 if (ev && Event == ev.constructor) {
1642 getCharCode: function(ev) {
1643 ev = ev.browserEvent || ev;
1644 return ev.charCode || ev.keyCode || 0;
1648 _getCacheIndex: function(el, AA, fn) {
1649 for (var i = 0,s = B.length; i < s; ++i) {
1652 li[this.FN] == fn &&
1653 li[this.EL] == el &&
1654 li[this.TYPE] == AA) {
1666 getEl: function(id) {
1667 return document.getElementById(id);
1671 clearCache: function() {
1675 _load: function(e) {
1677 var EU = Roo.lib.Event;
1681 EU.doRemove(window, "load", EU._load);
1686 _tryPreloadAttach: function() {
1703 for (var i = 0,s = E.length; i < s; ++i) {
1706 var el = this.getEl(item.id);
1709 if (!item.checkReady ||
1712 (document && document.body)) {
1715 if (item.override) {
1716 if (item.override === true) {
1719 scope = item.override;
1723 item.fn.call(scope, item.obj);
1733 D = (AC.length === 0) ? 0 : D - 1;
1737 this.startInterval();
1739 clearInterval(this._interval);
1740 this._interval = null;
1744 this.locked = false;
1751 purgeElement: function(el, AD, AE) {
1752 var AF = this.getListeners(el, AE);
1754 for (var i = 0,s = AF.length; i < s; ++i) {
1756 this.removeListener(el, l.type, l.fn);
1760 if (AD && el && el.childNodes) {
1761 for (i = 0,s = el.childNodes.length; i < s; ++i) {
1762 this.purgeElement(el.childNodes[i], AD, AE);
1768 getListeners: function(el, AG) {
1772 } else if (AG == "unload") {
1778 for (var j = 0; j < AI.length; ++j) {
1779 var searchList = AI[j];
1780 if (searchList && searchList.length > 0) {
1781 for (var i = 0,s = searchList.length; i < s; ++i) {
1782 var l = searchList[i];
1783 if (l && l[this.EL] === el &&
1784 (!AG || AG === l[this.TYPE])) {
1789 adjust: l[this.ADJ_SCOPE],
1797 return (AH.length) ? AH : null;
1801 _unload: function(e) {
1803 var EU = Roo.lib.Event, i, j, l, AJ, AK;
1805 for (i = 0,AJ = C.length; i < AJ; ++i) {
1809 if (l[EU.ADJ_SCOPE]) {
1810 if (l[EU.ADJ_SCOPE] === true) {
1813 scope = l[EU.ADJ_SCOPE];
1817 l[EU.FN].call(scope, EU.getEvent(e), l[EU.OBJ]);
1827 if (B && B.length > 0) {
1833 EU.removeListener(l[EU.EL], l[EU.TYPE],
1846 EU.doRemove(window, "unload", EU._unload);
1851 getScroll: function() {
1852 var dd = document.documentElement, db = document.body;
1853 if (dd && (dd.scrollTop || dd.scrollLeft)) {
1854 return [dd.scrollTop, dd.scrollLeft];
1856 return [db.scrollTop, db.scrollLeft];
1863 doAdd: function () {
1864 if (window.addEventListener) {
1865 return function(el, AL, fn, AM) {
1866 el.addEventListener(AL, fn, (AM));
1868 } else if (window.attachEvent) {
1869 return function(el, AL, fn, AM) {
1870 el.attachEvent("on" + AL, fn);
1879 doRemove: function() {
1880 if (window.removeEventListener) {
1881 return function (el, AL, fn, AM) {
1882 el.removeEventListener(AL, fn, (AM));
1884 } else if (window.detachEvent) {
1885 return function (el, AL, fn) {
1886 el.detachEvent("on" + AL, fn);
1898 var E = Roo.lib.Event;
1899 E.on = E.addListener;
1900 E.un = E.removeListener;
1902 if (document && document.body) {
1905 E.doAdd(window, "load", E._load);
1908 E.doAdd(window, "unload", E._unload);
1909 E._tryPreloadAttach();
1919 request : function(A, B, cb, C, D) {
1924 if(hs.hasOwnProperty(h)){
1925 this.initHeader(h, hs[h], false);
1930 this.initHeader('Content-Type', 'text/xml', false);
1936 return this.asyncRequest(A, B, cb, C);
1939 serializeForm : function(E) {
1940 if(typeof E == 'string') {
1941 E = (document.getElementById(E) || document.forms[E]);
1944 var el, F, G, H, I = '', J = false;
1945 for (var i = 0; i < E.elements.length; i++) {
1947 H = E.elements[i].disabled;
1948 F = E.elements[i].name;
1949 G = E.elements[i].value;
1955 case 'select-multiple':
1956 for (var j = 0; j < el.options.length; j++) {
1957 if (el.options[j].selected) {
1959 I += encodeURIComponent(F) + '=' + encodeURIComponent(el.options[j].attributes['value'].specified ? el.options[j].value : el.options[j].text) + '&';
1962 I += encodeURIComponent(F) + '=' + encodeURIComponent(el.options[j].hasAttribute('value') ? el.options[j].value : el.options[j].text) + '&';
1970 I += encodeURIComponent(F) + '=' + encodeURIComponent(G) + '&';
1984 I += encodeURIComponent(F) + '=' + encodeURIComponent(G) + '&';
1989 I += encodeURIComponent(F) + '=' + encodeURIComponent(G) + '&';
1995 I = I.substr(0, I.length - 1);
2003 useDefaultHeader:true,
2005 defaultPostHeader:'application/x-www-form-urlencoded',
2007 useDefaultXhrHeader:true,
2009 defaultXhrHeader:'XMLHttpRequest',
2011 hasDefaultHeaders:true,
2023 setProgId:function(id)
2025 this.activeX.unshift(id);
2028 setDefaultPostHeader:function(b)
2030 this.useDefaultHeader = b;
2033 setDefaultXhrHeader:function(b)
2035 this.useDefaultXhrHeader = b;
2038 setPollingInterval:function(i)
2040 if (typeof i == 'number' && isFinite(i)) {
2041 this.pollInterval = i;
2045 createXhrObject:function(K)
2051 M = new XMLHttpRequest();
2053 L = { conn:M, tId:K };
2057 for (var i = 0; i < this.activeX.length; ++i) {
2061 http = new ActiveXObject(this.activeX[i]);
2063 obj = { conn:http, tId:transactionId };
2076 getConnectionObject:function()
2079 var N = this.transactionId;
2083 o = this.createXhrObject(N);
2085 this.transactionId++;
2096 asyncRequest:function(O, P, Q, R)
2098 var o = this.getConnectionObject();
2104 o.conn.open(O, P, true);
2106 if (this.useDefaultXhrHeader) {
2107 if (!this.defaultHeaders['X-Requested-With']) {
2108 this.initHeader('X-Requested-With', this.defaultXhrHeader, true);
2112 if(R && this.useDefaultHeader){
2113 this.initHeader('Content-Type', this.defaultPostHeader);
2116 if (this.hasDefaultHeaders || this.hasHeaders) {
2121 this.handleReadyState(o, Q);
2122 o.conn.send(R || null);
2128 handleReadyState:function(o, S)
2132 if (S && S.timeout) {
2133 this.timeout[o.tId] = window.setTimeout(function() {
2134 T.abort(o, S, true);
2139 this.poll[o.tId] = window.setInterval(
2141 if (o.conn && o.conn.readyState == 4) {
2142 window.clearInterval(T.poll[o.tId]);
2143 delete T.poll[o.tId];
2145 if(S && S.timeout) {
2146 window.clearTimeout(T.timeout[o.tId]);
2147 delete T.timeout[o.tId];
2151 T.handleTransactionResponse(o, S);
2154 , this.pollInterval);
2157 handleTransactionResponse:function(o, U, V)
2161 this.releaseObject(o);
2169 if (o.conn.status !== undefined && o.conn.status != 0) {
2182 if (W >= 200 && W < 300) {
2183 X = this.createResponseObject(o, U.argument);
2191 U.success.apply(U.scope, [X]);
2204 X = this.createExceptionObject(o.tId, U.argument, (V ? V : false));
2210 U.failure.apply(U.scope, [X]);
2215 X = this.createResponseObject(o, U.argument);
2221 U.failure.apply(U.scope, [X]);
2228 this.releaseObject(o);
2232 createResponseObject:function(o, Y)
2239 var headerStr = o.conn.getAllResponseHeaders();
2240 var header = headerStr.split('\n');
2241 for (var i = 0; i < header.length; i++) {
2242 var delimitPos = header[i].indexOf(':');
2243 if (delimitPos != -1) {
2244 a[header[i].substring(0, delimitPos)] = header[i].substring(delimitPos + 2);
2253 Z.status = o.conn.status;
2254 Z.statusText = o.conn.statusText;
2255 Z.getResponseHeader = a;
2256 Z.getAllResponseHeaders = headerStr;
2257 Z.responseText = o.conn.responseText;
2258 Z.responseXML = o.conn.responseXML;
2260 if (typeof Y !== undefined) {
2267 createExceptionObject:function(c, d, f)
2270 var k = 'communication failure';
2272 var m = 'transaction aborted';
2293 initHeader:function(p, q, r)
2295 var s = (r) ? this.defaultHeaders : this.headers;
2297 if (s[p] === undefined) {
2303 s[p] = q + "," + s[p];
2307 this.hasDefaultHeaders = true;
2310 this.hasHeaders = true;
2315 setHeader:function(o)
2317 if (this.hasDefaultHeaders) {
2318 for (var prop in this.defaultHeaders) {
2319 if (this.defaultHeaders.hasOwnProperty(prop)) {
2320 o.conn.setRequestHeader(prop, this.defaultHeaders[prop]);
2325 if (this.hasHeaders) {
2326 for (var prop in this.headers) {
2327 if (this.headers.hasOwnProperty(prop)) {
2328 o.conn.setRequestHeader(prop, this.headers[prop]);
2333 this.hasHeaders = false;
2337 resetDefaultHeaders:function() {
2338 delete this.defaultHeaders;
2339 this.defaultHeaders = {};
2340 this.hasDefaultHeaders = false;
2343 abort:function(o, t, u)
2345 if(this.isCallInProgress(o)) {
2347 window.clearInterval(this.poll[o.tId]);
2348 delete this.poll[o.tId];
2350 delete this.timeout[o.tId];
2354 this.handleTransactionResponse(o, t, true);
2364 isCallInProgress:function(o)
2367 return o.conn.readyState != 4 && o.conn.readyState != 0;
2376 releaseObject:function(o)
2385 'MSXML2.XMLHTTP.3.0',
2396 Roo.lib.Region = function(t, r, b, l) {
2406 Roo.lib.Region.prototype = {
2407 contains : function(A) {
2408 return ( A.left >= this.left &&
2409 A.right <= this.right &&
2410 A.top >= this.top &&
2411 A.bottom <= this.bottom );
2415 getArea : function() {
2416 return ( (this.bottom - this.top) * (this.right - this.left) );
2419 intersect : function(B) {
2420 var t = Math.max(this.top, B.top);
2421 var r = Math.min(this.right, B.right);
2422 var b = Math.min(this.bottom, B.bottom);
2423 var l = Math.max(this.left, B.left);
2425 if (b >= t && r >= l) {
2426 return new Roo.lib.Region(t, r, b, l);
2431 union : function(C) {
2432 var t = Math.min(this.top, C.top);
2433 var r = Math.max(this.right, C.right);
2434 var b = Math.max(this.bottom, C.bottom);
2435 var l = Math.min(this.left, C.left);
2437 return new Roo.lib.Region(t, r, b, l);
2440 adjust : function(t, l, b, r) {
2449 Roo.lib.Region.getRegion = function(el) {
2450 var p = Roo.lib.Dom.getXY(el);
2453 var r = p[0] + el.offsetWidth;
2454 var b = p[1] + el.offsetHeight;
2457 return new Roo.lib.Region(t, r, b, l);
2465 Roo.lib.Point = function(x, y) {
2466 if (x instanceof Array) {
2471 this.x = this.right = this.left = this[0] = x;
2472 this.y = this.top = this.bottom = this[1] = y;
2475 Roo.lib.Point.prototype = new Roo.lib.Region();
2483 scroll : function(el, A, B, C, cb, D) {
2484 this.run(el, A, B, C, cb, D, Roo.lib.Scroll);
2487 motion : function(el, E, F, G, cb, H) {
2488 this.run(el, E, F, G, cb, H, Roo.lib.Motion);
2491 color : function(el, I, J, K, cb, L) {
2492 this.run(el, I, J, K, cb, L, Roo.lib.ColorAnim);
2495 run : function(el, M, N, O, cb, P, Q) {
2496 Q = Q || Roo.lib.AnimBase;
2497 if (typeof O == "string") {
2498 O = Roo.lib.Easing[O];
2500 var R = new Q(el, M, N, O);
2501 R.animateX(function() {
2502 Roo.callback(cb, P);
2516 A = new Roo.Element.Flyweight();
2528 Roo.lib.AnimBase = function(el, C, D, E) {
2530 this.init(el, C, D, E);
2534 Roo.lib.AnimBase.fly = B;
2538 Roo.lib.AnimBase.prototype = {
2540 toString: function() {
2541 var el = this.getEl();
2542 var id = el.id || el.tagName;
2543 return ("Anim " + id);
2547 noNegatives: /width|height|opacity|padding/i,
2548 offsetAttribute: /^((width|height)|(top|left))$/,
2549 defaultUnit: /width|height|top$|bottom$|left$|right$/i,
2550 offsetUnit: /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i
2554 doMethod: function(C, D, E) {
2555 return this.method(this.currentFrame, D, E - D, this.totalFrames);
2559 setAttribute: function(F, G, H) {
2560 if (this.patterns.noNegatives.test(F)) {
2561 G = (G > 0) ? G : 0;
2565 Roo.fly(this.getEl(), '_anim').setStyle(F, G + H);
2569 getAttribute: function(I) {
2570 var el = this.getEl();
2571 var J = B(el).getStyle(I);
2573 if (J !== 'auto' && !this.patterns.offsetUnit.test(J)) {
2574 return parseFloat(J);
2577 var a = this.patterns.offsetAttribute.exec(I) || [];
2582 if (L || (B(el).getStyle('position') == 'absolute' && K)) {
2583 J = el['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)];
2592 getDefaultUnit: function(M) {
2593 if (this.patterns.defaultUnit.test(M)) {
2600 animateX : function(N, O) {
2601 var f = function() {
2602 this.onComplete.removeListener(f);
2603 if (typeof N == "function") {
2604 N.call(O || this, this);
2607 this.onComplete.addListener(f, this);
2612 setRuntimeAttribute: function(P) {
2615 var S = this.attributes;
2617 this.runtimeAttributes[P] = {};
2619 var T = function(U) {
2620 return (typeof U !== 'undefined');
2623 if (!T(S[P]['to']) && !T(S[P]['by'])) {
2628 Q = ( T(S[P]['from']) ) ? S[P]['from'] : this.getAttribute(P);
2631 if (T(S[P]['to'])) {
2633 } else if (T(S[P]['by'])) {
2634 if (Q.constructor == Array) {
2636 for (var i = 0, len = Q.length; i < len; ++i) {
2637 R[i] = Q[i] + S[P]['by'][i];
2645 this.runtimeAttributes[P].start = Q;
2646 this.runtimeAttributes[P].end = R;
2649 this.runtimeAttributes[P].unit = ( T(S[P].unit) ) ? S[P]['unit'] : this.getDefaultUnit(P);
2653 init: function(el, U, V, W) {
2664 el = Roo.getDom(el);
2667 this.attributes = U || {};
2670 this.duration = V || 1;
2673 this.method = W || Roo.lib.Easing.easeNone;
2676 this.useSeconds = true;
2679 this.currentFrame = 0;
2682 this.totalFrames = Roo.lib.AnimMgr.fps;
2685 this.getEl = function() {
2690 this.isAnimated = function() {
2695 this.getStartTime = function() {
2699 this.runtimeAttributes = {};
2702 this.animate = function() {
2703 if (this.isAnimated()) {
2708 this.currentFrame = 0;
2710 this.totalFrames = ( this.useSeconds ) ? Math.ceil(Roo.lib.AnimMgr.fps * this.duration) : this.duration;
2712 Roo.lib.AnimMgr.registerElement(this);
2716 this.stop = function(e) {
2718 this.currentFrame = this.totalFrames;
2719 this._onTween.fire();
2722 Roo.lib.AnimMgr.stop(this);
2725 var b = function() {
2726 this.onStart.fire();
2728 this.runtimeAttributes = {};
2729 for (var P in this.attributes) {
2730 this.setRuntimeAttribute(P);
2740 var c = function() {
2742 duration: new Date() - this.getStartTime(),
2743 currentFrame: this.currentFrame
2746 e.toString = function() {
2748 'duration: ' + e.duration +
2749 ', currentFrame: ' + e.currentFrame
2753 this.onTween.fire(e);
2755 var g = this.runtimeAttributes;
2758 this.setAttribute(P, this.doMethod(P, g[P].start, g[P].end), g[P].unit);
2765 var d = function() {
2766 var e = (new Date() - Y) / 1000 ;
2774 g.toString = function() {
2776 'duration: ' + g.duration +
2777 ', frames: ' + g.frames +
2784 this.onComplete.fire(g);
2788 this._onStart = new Roo.util.Event(this);
2789 this.onStart = new Roo.util.Event(this);
2790 this.onTween = new Roo.util.Event(this);
2791 this._onTween = new Roo.util.Event(this);
2792 this.onComplete = new Roo.util.Event(this);
2793 this._onComplete = new Roo.util.Event(this);
2794 this._onStart.addListener(b);
2795 this._onTween.addListener(c);
2796 this._onComplete.addListener(d);
2804 Roo.lib.AnimMgr = new function() {
2821 this.registerElement = function(F) {
2829 this.unRegister = function(F, G) {
2830 F._onComplete.fire();
2844 this.start = function() {
2846 A = setInterval(this.run, this.delay);
2851 this.stop = function(F) {
2855 for (var i = 0, len = B.length; i < len; ++i) {
2856 if (B[0].isAnimated()) {
2857 this.unRegister(B[0], 0);
2872 this.run = function() {
2873 for (var i = 0, len = B.length; i < len; ++i) {
2875 if (!tween || !tween.isAnimated()) {
2879 if (tween.currentFrame < tween.totalFrames || tween.totalFrames === null)
2881 tween.currentFrame += 1;
2883 if (tween.useSeconds) {
2887 tween._onTween.fire();
2890 Roo.lib.AnimMgr.stop(tween, i);
2895 var D = function(F) {
2896 for (var i = 0, len = B.length; i < len; ++i) {
2905 var E = function(F) {
2906 var G = F.totalFrames;
2907 var H = F.currentFrame;
2908 var I = (F.currentFrame * F.duration * 1000 / F.totalFrames);
2909 var J = (new Date() - F.getStartTime());
2912 if (J < F.duration * 1000) {
2913 K = Math.round((J / I - 1) * F.currentFrame);
2917 if (K > 0 && isFinite(K)) {
2918 if (F.currentFrame + K >= G) {
2923 F.currentFrame += K;
2929 Roo.lib.Bezier = new function() {
2931 this.getPosition = function(A, t) {
2935 for (var i = 0; i < n; ++i) {
2936 B[i] = [A[i][0], A[i][1]];
2939 for (var j = 1; j < n; ++j) {
2940 for (i = 0; i < n - j; ++i) {
2941 B[i][0] = (1 - t) * B[i][0] + t * B[parseInt(i + 1, 10)][0];
2942 B[i][1] = (1 - t) * B[i][1] + t * B[parseInt(i + 1, 10)][1];
2946 return [ B[0][0], B[0][1] ];
2954 Roo.lib.ColorAnim = function(el, D, E, F) {
2955 Roo.lib.ColorAnim.superclass.constructor.call(this, el, D, E, F);
2958 Roo.extend(Roo.lib.ColorAnim, Roo.lib.AnimBase);
2960 var A = Roo.lib.AnimBase.fly;
2962 var B = Y.ColorAnim.superclass;
2963 var C = Y.ColorAnim.prototype;
2965 C.toString = function() {
2966 var el = this.getEl();
2967 var id = el.id || el.tagName;
2968 return ("ColorAnim " + id);
2971 C.patterns.color = /color$/i;
2972 C.patterns.rgb = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i;
2973 C.patterns.hex = /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i;
2974 C.patterns.hex3 = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i;
2975 C.patterns.transparent = /^transparent|rgba\(0, 0, 0, 0\)$/;
2978 C.parseColor = function(s) {
2979 if (s.length == 3) {
2983 var c = this.patterns.hex.exec(s);
2984 if (c && c.length == 4) {
2985 return [ parseInt(c[1], 16), parseInt(c[2], 16), parseInt(c[3], 16) ];
2989 c = this.patterns.rgb.exec(s);
2990 if (c && c.length == 4) {
2991 return [ parseInt(c[1], 10), parseInt(c[2], 10), parseInt(c[3], 10) ];
2995 c = this.patterns.hex3.exec(s);
2996 if (c && c.length == 4) {
2997 return [ parseInt(c[1] + c[1], 16), parseInt(c[2] + c[2], 16), parseInt(c[3] + c[3], 16) ];
3003 C.getAttribute = function(D) {
3004 var el = this.getEl();
3005 if (this.patterns.color.test(D)) {
3006 var val = A(el).getStyle(D);
3008 if (this.patterns.transparent.test(val)) {
3009 var parent = el.parentNode;
3010 val = A(parent).getStyle(D);
3012 while (parent && this.patterns.transparent.test(val)) {
3013 parent = parent.parentNode;
3014 val = A(parent).getStyle(D);
3015 if (parent.tagName.toUpperCase() == 'HTML') {
3021 val = B.getAttribute.call(this, D);
3026 C.getAttribute = function(D) {
3027 var el = this.getEl();
3028 if (this.patterns.color.test(D)) {
3029 var val = A(el).getStyle(D);
3031 if (this.patterns.transparent.test(val)) {
3032 var parent = el.parentNode;
3033 val = A(parent).getStyle(D);
3035 while (parent && this.patterns.transparent.test(val)) {
3036 parent = parent.parentNode;
3037 val = A(parent).getStyle(D);
3038 if (parent.tagName.toUpperCase() == 'HTML') {
3044 val = B.getAttribute.call(this, D);
3050 C.doMethod = function(D, E, F) {
3053 if (this.patterns.color.test(D)) {
3055 for (var i = 0, len = E.length; i < len; ++i) {
3056 G[i] = B.doMethod.call(this, D, E[i], F[i]);
3060 G = 'rgb(' + Math.floor(G[0]) + ',' + Math.floor(G[1]) + ',' + Math.floor(G[2]) + ')';
3063 G = B.doMethod.call(this, D, E, F);
3069 C.setRuntimeAttribute = function(D) {
3070 B.setRuntimeAttribute.call(this, D);
3072 if (this.patterns.color.test(D)) {
3073 var attributes = this.attributes;
3074 var start = this.parseColor(this.runtimeAttributes[D].start);
3075 var end = this.parseColor(this.runtimeAttributes[D].end);
3077 if (typeof attributes[D]['to'] === 'undefined' && typeof attributes[D]['by'] !== 'undefined') {
3078 end = this.parseColor(attributes[D].by);
3080 for (var i = 0, len = start.length; i < len; ++i) {
3081 end[i] = start[i] + end[i];
3086 this.runtimeAttributes[D].start = start;
3087 this.runtimeAttributes[D].end = end;
3098 easeNone: function (t, b, c, d) {
3099 return c * t / d + b;
3103 easeIn: function (t, b, c, d) {
3104 return c * (t /= d) * t + b;
3108 easeOut: function (t, b, c, d) {
3109 return -c * (t /= d) * (t - 2) + b;
3113 easeBoth: function (t, b, c, d) {
3114 if ((t /= d / 2) < 1) {
3115 return c / 2 * t * t + b;
3118 return -c / 2 * ((--t) * (t - 2) - 1) + b;
3122 easeInStrong: function (t, b, c, d) {
3123 return c * (t /= d) * t * t * t + b;
3127 easeOutStrong: function (t, b, c, d) {
3128 return -c * ((t = t / d - 1) * t * t * t - 1) + b;
3132 easeBothStrong: function (t, b, c, d) {
3133 if ((t /= d / 2) < 1) {
3134 return c / 2 * t * t * t * t + b;
3137 return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
3142 elasticIn: function (t, b, c, d, a, p) {
3146 if ((t /= d) == 1) {
3153 if (!a || a < Math.abs(c)) {
3158 var s = p / (2 * Math.PI) * Math.asin(c / a);
3161 return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
3165 elasticOut: function (t, b, c, d, a, p) {
3169 if ((t /= d) == 1) {
3176 if (!a || a < Math.abs(c)) {
3181 var s = p / (2 * Math.PI) * Math.asin(c / a);
3184 return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
3188 elasticBoth: function (t, b, c, d, a, p) {
3193 if ((t /= d / 2) == 2) {
3201 if (!a || a < Math.abs(c)) {
3206 var s = p / (2 * Math.PI) * Math.asin(c / a);
3210 return -.5 * (a * Math.pow(2, 10 * (t -= 1)) *
3211 Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
3213 return a * Math.pow(2, -10 * (t -= 1)) *
3214 Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
3219 backIn: function (t, b, c, d, s) {
3220 if (typeof s == 'undefined') {
3223 return c * (t /= d) * t * ((s + 1) * t - s) + b;
3227 backOut: function (t, b, c, d, s) {
3228 if (typeof s == 'undefined') {
3231 return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
3235 backBoth: function (t, b, c, d, s) {
3236 if (typeof s == 'undefined') {
3240 if ((t /= d / 2 ) < 1) {
3241 return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
3243 return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
3247 bounceIn: function (t, b, c, d) {
3248 return c - Roo.lib.Easing.bounceOut(d - t, 0, c, d) + b;
3252 bounceOut: function (t, b, c, d) {
3253 if ((t /= d) < (1 / 2.75)) {
3254 return c * (7.5625 * t * t) + b;
3255 } else if (t < (2 / 2.75)) {
3256 return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
3257 } else if (t < (2.5 / 2.75)) {
3258 return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
3260 return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
3264 bounceBoth: function (t, b, c, d) {
3266 return Roo.lib.Easing.bounceIn(t * 2, 0, c, d) * .5 + b;
3268 return Roo.lib.Easing.bounceOut(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
3274 Roo.lib.Motion = function(el, E, F, G) {
3276 Roo.lib.Motion.superclass.constructor.call(this, el, E, F, G);
3280 Roo.extend(Roo.lib.Motion, Roo.lib.ColorAnim);
3284 var A = Y.Motion.superclass;
3285 var B = Y.Motion.prototype;
3287 B.toString = function() {
3288 var el = this.getEl();
3289 var id = el.id || el.tagName;
3290 return ("Motion " + id);
3293 B.patterns.points = /^points$/i;
3295 B.setAttribute = function(E, F, G) {
3296 if (this.patterns.points.test(E)) {
3298 A.setAttribute.call(this, 'left', F[0], G);
3299 A.setAttribute.call(this, 'top', F[1], G);
3301 A.setAttribute.call(this, E, F, G);
3305 B.getAttribute = function(E) {
3306 if (this.patterns.points.test(E)) {
3308 A.getAttribute.call(this, 'left'),
3309 A.getAttribute.call(this, 'top')
3312 val = A.getAttribute.call(this, E);
3318 B.doMethod = function(E, F, G) {
3321 if (this.patterns.points.test(E)) {
3322 var t = this.method(this.currentFrame, 0, 100, this.totalFrames) / 100;
3323 H = Y.Bezier.getPosition(this.runtimeAttributes[E], t);
3325 H = A.doMethod.call(this, E, F, G);
3330 B.setRuntimeAttribute = function(E) {
3331 if (this.patterns.points.test(E)) {
3332 var el = this.getEl();
3333 var attributes = this.attributes;
3335 var control = attributes['points']['control'] || [];
3339 if (control.length > 0 && !(control[0] instanceof Array)) {
3340 control = [control];
3343 for (i = 0,len = control.length; i < len; ++i) {
3344 tmp[i] = control[i];
3351 Roo.fly(el).position();
3353 if (D(attributes['points']['from'])) {
3354 Roo.lib.Dom.setXY(el, attributes['points']['from']);
3357 Roo.lib.Dom.setXY(el, Roo.lib.Dom.getXY(el));
3361 start = this.getAttribute('points');
3364 if (D(attributes['points']['to'])) {
3365 end = C.call(this, attributes['points']['to'], start);
3367 var pageXY = Roo.lib.Dom.getXY(this.getEl());
3368 for (i = 0,len = control.length; i < len; ++i) {
3369 control[i] = C.call(this, control[i], start);
3373 } else if (D(attributes['points']['by'])) {
3374 end = [ start[0] + attributes['points']['by'][0], start[1] + attributes['points']['by'][1] ];
3376 for (i = 0,len = control.length; i < len; ++i) {
3377 control[i] = [ start[0] + control[i][0], start[1] + control[i][1] ];
3382 this.runtimeAttributes[E] = [start];
3384 if (control.length > 0) {
3385 this.runtimeAttributes[E] = this.runtimeAttributes[E].concat(control);
3389 this.runtimeAttributes[E][this.runtimeAttributes[E].length] = end;
3392 A.setRuntimeAttribute.call(this, E);
3396 var C = function(E, F) {
3397 var G = Roo.lib.Dom.getXY(this.getEl());
3398 E = [ E[0] - G[0] + F[0], E[1] - G[1] + F[1] ];
3403 var D = function(E) {
3404 return (typeof E !== 'undefined');
3411 Roo.lib.Scroll = function(el, C, D, E) {
3413 Roo.lib.Scroll.superclass.constructor.call(this, el, C, D, E);
3417 Roo.extend(Roo.lib.Scroll, Roo.lib.ColorAnim);
3421 var A = Y.Scroll.superclass;
3422 var B = Y.Scroll.prototype;
3424 B.toString = function() {
3425 var el = this.getEl();
3426 var id = el.id || el.tagName;
3427 return ("Scroll " + id);
3430 B.doMethod = function(C, D, E) {
3433 if (C == 'scroll') {
3435 this.method(this.currentFrame, D[0], E[0] - D[0], this.totalFrames),
3436 this.method(this.currentFrame, D[1], E[1] - D[1], this.totalFrames)
3440 F = A.doMethod.call(this, C, D, E);
3445 B.getAttribute = function(C) {
3447 var el = this.getEl();
3449 if (C == 'scroll') {
3450 D = [ el.scrollLeft, el.scrollTop ];
3452 D = A.getAttribute.call(this, C);
3458 B.setAttribute = function(C, D, E) {
3459 var el = this.getEl();
3461 if (C == 'scroll') {
3462 el.scrollLeft = D[0];
3463 el.scrollTop = D[1];
3465 A.setAttribute.call(this, C, D, E);
3476 Roo.DomHelper = function(){
3478 var B = /^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i;
3479 var C = /^table|tbody|tr|td$/i;
3484 var E = function(o){
3485 if(typeof o == 'string'){
3495 if(attr == "tag" || attr == "children" || attr == "cn" || attr == "html" || typeof o[attr] == "function") continue;
3496 if(attr == "style"){
3498 if(typeof s == "function"){
3501 if(typeof s == "string"){
3502 b += ' style="' + s + '"';
3503 }else if(typeof s == "object"){
3506 if(typeof s[key] != "function"){
3507 b += key + ":" + s[key] + ";";
3515 b += ' class="' + o["cls"] + '"';
3516 }else if(attr == "htmlFor"){
3517 b += ' for="' + o["htmlFor"] + '"';
3519 b += " " + attr + '="' + o[attr] + '"';
3527 var cn = o.children || o.cn;
3530 if((cn instanceof Array) || (Roo.isSafari && typeof(cn.join) == "function")){
3531 for(var i = 0, len = cn.length; i < len; i++) {
3542 b += "</" + o.tag + ">";
3550 var F = function(o, M){
3554 if (o.ns && o.ns != 'html') {
3556 if (o.xmlns && typeof(D[o.ns]) == 'undefined') {
3560 if (typeof(D[o.ns]) == 'undefined') {
3561 console.log("Trying to create namespace element " + o.ns + ", however no xmlns was sent to builder previously");
3568 if (typeof(o) == 'string') {
3569 return M.appendChild(document.createTextNode(o));
3572 o.tag = o.tag || div;
3573 if (o.ns && Roo.isIE) {
3575 o.tag = o.ns + ':' + o.tag;
3578 var el = ns ? document.createElementNS( ns, o.tag||'div') : document.createElement(o.tag||'div');
3579 var N = el.setAttribute ? true : false;
3582 if(attr == "tag" || attr == "ns" ||attr == "xmlns" ||attr == "children" || attr == "cn" || attr == "html" ||
3583 attr == "style" || typeof o[attr] == "function") continue;
3585 if(attr=="cls" && Roo.isIE){
3586 el.className = o["cls"];
3588 if(N) el.setAttribute(attr=="cls" ? 'class' : attr, o[attr]);
3589 else el[attr] = o[attr];
3593 Roo.DomHelper.applyStyles(el, o.style);
3594 var cn = o.children || o.cn;
3597 if((cn instanceof Array) || (Roo.isSafari && typeof(cn.join) == "function")){
3598 for(var i = 0, len = cn.length; i < len; i++) {
3606 el.innerHTML = o.html;
3614 var G = function(M, s, h, e){
3615 A.innerHTML = [s, h, e].join('');
3633 var L = function(M, N, el, O){
3635 A = document.createElement('div');
3640 if(N == 'afterbegin' || N == 'beforeend'){
3643 if(N == 'beforebegin'){
3654 if(N == 'beforebegin'){
3658 } else if(N == 'afterend'){
3663 if(N == 'afterbegin'){
3669 } else if(M == 'tbody'){
3670 if(N == 'beforebegin'){
3673 P = G(2, ts, O, te);
3674 } else if(N == 'afterend'){
3677 P = G(2, ts, O, te);
3679 if(N == 'afterbegin'){
3686 if(N == 'beforebegin' || N == 'afterend'){
3689 if(N == 'afterbegin'){
3693 P = G(2, ts, O, te);
3696 el.insertBefore(P, Q);
3707 markup : function(o){
3713 applyStyles : function(el, c){
3716 if(typeof c == "string"){
3717 var re = /\s?([a-z\-]*)\:\s?([^;]*);?/gi;
3719 while ((matches = re.exec(c)) != null){
3720 el.setStyle(matches[1], matches[2]);
3722 }else if (typeof c == "object"){
3723 for (var style in c){
3724 el.setStyle(style, c[style]);
3726 }else if (typeof c == "function"){
3727 Roo.DomHelper.applyStyles(el, c.call());
3734 insertHtml : function(d, el, e){
3735 d = d.toLowerCase();
3736 if(el.insertAdjacentHTML){
3737 if(C.test(el.tagName)){
3739 if(rs = L(el.tagName.toLowerCase(), d, el, e)){
3745 el.insertAdjacentHTML('BeforeBegin', e);
3746 return el.previousSibling;
3748 el.insertAdjacentHTML('AfterBegin', e);
3749 return el.firstChild;
3751 el.insertAdjacentHTML('BeforeEnd', e);
3752 return el.lastChild;
3754 el.insertAdjacentHTML('AfterEnd', e);
3755 return el.nextSibling;
3757 throw 'Illegal insertion point -> "' + d + '"';
3759 var f = el.ownerDocument.createRange();
3763 f.setStartBefore(el);
3764 g = f.createContextualFragment(e);
3765 el.parentNode.insertBefore(g, el);
3766 return el.previousSibling;
3769 f.setStartBefore(el.firstChild);
3770 g = f.createContextualFragment(e);
3771 el.insertBefore(g, el.firstChild);
3772 return el.firstChild;
3775 return el.firstChild;
3779 f.setStartAfter(el.lastChild);
3780 g = f.createContextualFragment(e);
3782 return el.lastChild;
3785 return el.lastChild;
3788 f.setStartAfter(el);
3789 g = f.createContextualFragment(e);
3790 el.parentNode.insertBefore(g, el.nextSibling);
3791 return el.nextSibling;
3793 throw 'Illegal insertion point -> "' + d + '"';
3798 insertBefore : function(el, o, h){
3799 return this.doInsert(el, o, h, "beforeBegin");
3804 insertAfter : function(el, o, j){
3805 return this.doInsert(el, o, j, "afterEnd", "nextSibling");
3810 insertFirst : function(el, o, k){
3811 return this.doInsert(el, o, k, "afterBegin");
3815 doInsert : function(el, o, l, m, n){
3816 el = Roo.getDom(el);
3818 if(this.useDom || o.ns){
3820 el.parentNode.insertBefore(p, n ? el[n] : el);
3823 p = this.insertHtml(m, el, e);
3825 return l ? Roo.get(p, true) : p;
3830 append : function(el, o, q){
3831 el = Roo.getDom(el);
3833 if(this.useDom || o.ns){
3838 r = this.insertHtml("beforeEnd", el, e);
3840 return q ? Roo.get(r, true) : r;
3845 overwrite : function(el, o, t){
3846 el = Roo.getDom(el);
3849 while (el.childNodes.length) {
3850 el.removeChild(el.firstChild);
3855 el.innerHTML = E(o);
3858 return t ? Roo.get(el.firstChild, true) : el.firstChild;
3863 createTemplate : function(o){
3865 return new Roo.Template(u);
3875 Roo.Template = function(A){
3877 if(A instanceof Array){
3879 }else if(arguments.length > 1){
3880 A = Array.prototype.join.call(arguments, "");
3884 if (typeof(A) == 'object') {
3893 Roo.Template.prototype = {
3900 applyTemplate : function(values){
3904 return this.compiled(values);
3906 var useF = this.disableFormats !== true;
3907 var fm = Roo.util.Format, tpl = this;
3908 var fn = function(m, E, F, G){
3910 if(F.substr(0, 5) == "this."){
3911 return tpl.call(F.substr(5), values[E], values);
3917 var re = /^\s*['"](.*)["']\s*$/;
3919 for(var i = 0, len = G.length; i < len; i++){
3920 G[i] = G[i].replace(re, "$1");
3923 G = [values[E]].concat(G);
3927 return fm[F].apply(fm, G);
3930 return values[E] !== undefined ? values[E] : "";
3933 return this.html.replace(this.re, fn);
3943 set : function(B, C){
3945 this.compiled = null;
3954 disableFormats : false,
3958 re : /\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,
3962 compile : function(){
3963 var fm = Roo.util.Format;
3964 var D = this.disableFormats !== true;
3965 var E = Roo.isGecko ? "+" : ",";
3966 var fn = function(m, G, H, I){
3968 I = I ? ',' + I : "";
3969 if(H.substr(0, 5) != "this."){
3970 H = "fm." + H + '(';
3972 H = 'this.call("'+ H.substr(5) + '", ';
3976 I= ''; H = "(values['" + G + "'] == undefined ? '' : ";
3978 return "'"+ E + H + "values['" + G + "']" + I + ")"+E+"'";
3983 F = "this.compiled = function(values){ return '" +
3984 this.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn) +
3987 F = ["this.compiled = function(values){ return ['"];
3988 F.push(this.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn));
3989 F.push("'].join('');};");
3999 call : function(G, H, I){
4000 return this[G](H, I);
4005 insertFirst: function(el, J, K){
4006 return this.doInsert('afterBegin', el, J, K);
4011 insertBefore: function(el, L, M){
4012 return this.doInsert('beforeBegin', el, L, M);
4017 insertAfter : function(el, N, O){
4018 return this.doInsert('afterEnd', el, N, O);
4023 append : function(el, P, Q){
4024 return this.doInsert('beforeEnd', el, P, Q);
4027 doInsert : function(R, el, S, T){
4028 el = Roo.getDom(el);
4029 var U = Roo.DomHelper.insertHtml(R, el, this.applyTemplate(S));
4030 return T ? Roo.get(U, true) : U;
4035 overwrite : function(el, V, W){
4036 el = Roo.getDom(el);
4037 el.innerHTML = this.applyTemplate(V);
4038 return W ? Roo.get(el.firstChild, true) : el.firstChild;
4043 Roo.Template.prototype.apply = Roo.Template.prototype.applyTemplate;
4046 Roo.DomHelper.Template = Roo.Template;
4050 Roo.Template.from = function(el){
4051 el = Roo.getDom(el);
4052 return new Roo.Template(el.value || el.innerHTML);
4062 Roo.DomQuery = function(){
4063 var A = {}, simpleCache = {}, valueCache = {};
4065 var C = /^\s+|\s+$/g;
4066 var D = /\{(\d+)\}/g;
4067 var E = /^(\s?[\/>+~]\s?|\s|$)/;
4068 var F = /^(#)?([\w-\*]+)/;
4069 var G = /(\d*)n\+?(\d*)/, H = /\D/;
4073 var n = p.firstChild;
4075 if(n.nodeType == 1){
4087 while((n = n.nextSibling) && n.nodeType != 1);
4092 while((n = n.previousSibling) && n.nodeType != 1);
4097 var n = d.firstChild, ni = -1;
4099 var nx = n.nextSibling;
4100 if(n.nodeType == 3 && !B.test(n.nodeValue)){
4111 function byClassName(c, a, v){
4115 var r = [], ri = -1, cn;
4116 for(var i = 0, ci; ci = c[i]; i++){
4117 if((' '+ci.className+' ').indexOf(v) != -1){
4124 function attrValue(n, T){
4125 if(!n.tagName && typeof n.length != "undefined"){
4134 if(T == "class" || T == "className"){
4137 return n.getAttribute(T) || n[T];
4141 function getNodes(ns, T, U){
4142 var V = [], ri = -1, cs;
4148 if(typeof ns.getElementsByTagName != "undefined"){
4152 for(var i = 0, ni; ni = ns[i]; i++){
4153 cs = ni.getElementsByTagName(U);
4154 for(var j = 0, ci; ci = cs[j]; j++){
4158 }else if(T == "/" || T == ">"){
4159 var utag = U.toUpperCase();
4160 for(var i = 0, ni, cn; ni = ns[i]; i++){
4161 cn = ni.children || ni.childNodes;
4162 for(var j = 0, cj; cj = cn[j]; j++){
4163 if(cj.nodeName == utag || cj.nodeName == U || U == '*'){
4169 var utag = U.toUpperCase();
4170 for(var i = 0, n; n = ns[i]; i++){
4171 while((n = n.nextSibling) && n.nodeType != 1);
4172 if(n && (n.nodeName == utag || n.nodeName == U || U == '*')){
4177 for(var i = 0, n; n = ns[i]; i++){
4178 while((n = n.nextSibling) && (n.nodeType != 1 || (U == '*' || n.tagName.toLowerCase()!=U)));
4191 for(var i = 0, l = b.length; i < l; i++){
4197 function byTag(cs, T){
4198 if(cs.tagName || cs == document){
4204 var r = [], ri = -1;
4205 T = T.toLowerCase();
4206 for(var i = 0, ci; ci = cs[i]; i++){
4207 if(ci.nodeType == 1 && ci.tagName.toLowerCase()==T){
4214 function N(cs, T, id){
4215 if(cs.tagName || cs == document){
4221 var r = [], ri = -1;
4222 for(var i = 0,ci; ci = cs[i]; i++){
4223 if(ci && ci.id == id){
4231 function byAttribute(cs, T, U, op, V){
4232 var r = [], ri = -1, st = V=="{";
4233 var f = Roo.DomQuery.operators[op];
4234 for(var i = 0, ci; ci = cs[i]; i++){
4237 a = Roo.DomQuery.getStyle(ci, T);
4239 else if(T == "class" || T == "className"){
4241 }else if(T == "for"){
4243 }else if(T == "href"){
4244 a = ci.getAttribute("href", 2);
4246 a = ci.getAttribute(T);
4248 if((f && f(a, U)) || (!f && a)){
4255 function byPseudo(cs, T, U){
4256 return Roo.DomQuery.pseudos[T](cs, U);
4262 var O = window.ActiveXObject ? true : false;
4275 cs[0].setAttribute("_nodup", d);
4277 for(var i = 1, len = cs.length; i < len; i++){
4279 if(!c.getAttribute("_nodup") != d){
4280 c.setAttribute("_nodup", d);
4284 for(var i = 0, len = cs.length; i < len; i++){
4285 cs[i].removeAttribute("_nodup");
4294 var T = cs.length, c, i, r = cs, cj, ri = -1;
4295 if(!T || typeof cs.nodeType != "undefined" || T == 1){
4298 if(O && typeof cs[0].selectSingleNode != "undefined"){
4303 for(i = 1; c = cs[i]; i++){
4308 for(var j = 0; j < i; j++){
4311 for(j = i+1; cj = cs[j]; j++){
4325 for(var i = 0, len = c1.length; i < len; i++){
4326 c1[i].setAttribute("_qdiff", d);
4329 for(var i = 0, len = c2.length; i < len; i++){
4330 if(c2[i].getAttribute("_qdiff") != d){
4331 r[r.length] = c2[i];
4334 for(var i = 0, len = c1.length; i < len; i++){
4335 c1[i].removeAttribute("_qdiff");
4345 if(O && c1[0].selectSingleNode){
4349 for(var i = 0; i < T; i++){
4353 for(var i = 0, len = c2.length; i < len; i++){
4354 if(c2[i]._qdiff != d){
4355 r[r.length] = c2[i];
4361 function quickId(ns, T, U, id){
4363 var d = U.ownerDocument || U;
4364 return d.getElementById(id);
4367 ns = getNodes(ns, T, "*");
4368 return N(ns, null, id);
4372 getStyle : function(el, AA){
4373 return Roo.fly(el).getStyle(AA);
4377 compile : function(AB, AC){
4378 AC = AC || "select";
4380 var fn = ["var f = function(root){\n var mode; ++batch; var n = root || document;\n"];
4381 var q = AB, mode, lq;
4382 var tk = Roo.DomQuery.matchers;
4387 var AE = q.match(E);
4389 fn[fn.length] = 'mode="'+AE[1].replace(C, "")+'";';
4390 q = q.replace(AE[1], "");
4393 while(AB.substr(0, 1)=="/"){
4397 while(q && lq != q){
4399 var tm = q.match(F);
4403 fn[fn.length] = 'n = quickId(n, mode, root, "'+tm[2]+'");';
4405 fn[fn.length] = 'n = getNodes(n, mode, "'+tm[2]+'");';
4408 q = q.replace(tm[0], "");
4409 }else if(q.substr(0, 1) != '@'){
4410 fn[fn.length] = 'n = getNodes(n, mode, "*");';
4415 fn[fn.length] = 'n = byId(n, null, "'+tm[2]+'");';
4417 fn[fn.length] = 'n = byTag(n, "'+tm[2]+'");';
4420 q = q.replace(tm[0], "");
4423 while(!(mm = q.match(E))){
4424 var matched = false;
4425 for(var j = 0; j < AD; j++){
4427 var m = q.match(t.re);
4429 fn[fn.length] = t.select.replace(D, function(x, i){
4432 q = q.replace(m[0], "");
4439 throw 'Error parsing selector, parsing failed at "' + q + '"';
4443 fn[fn.length] = 'mode="'+mm[1].replace(C, "")+'";';
4444 q = q.replace(mm[1], "");
4448 fn[fn.length] = "return nodup(n);\n}";
4458 select : function(AF, AG, AH){
4459 if(!AG || AG == document){
4462 if(typeof AG == "string"){
4463 AG = document.getElementById(AG);
4465 var AI = AF.split(",");
4467 for(var i = 0, len = AI.length; i < len; i++){
4468 var p = AI[i].replace(C, "");
4470 A[p] = Roo.DomQuery.compile(p);
4472 throw p + " is not a valid selector";
4476 if(z && z != document){
4488 selectNode : function(AK, AL){
4489 return Roo.DomQuery.select(AK, AL)[0];
4494 selectValue : function(AM, AN, AO){
4495 AM = AM.replace(C, "");
4496 if(!valueCache[AM]){
4497 valueCache[AM] = Roo.DomQuery.compile(AM, "select");
4499 var n = valueCache[AM](AN);
4500 n = n[0] ? n[0] : n;
4501 var v = (n && n.firstChild ? n.firstChild.nodeValue : null);
4502 return ((v === null||v === undefined||v==='') ? AO : v);
4507 selectNumber : function(AP, AQ, AR){
4508 var v = Roo.DomQuery.selectValue(AP, AQ, AR || 0);
4509 return parseFloat(v);
4514 is : function(el, ss){
4515 if(typeof el == "string"){
4516 el = document.getElementById(el);
4518 var AS = (el instanceof Array);
4519 var AT = Roo.DomQuery.filter(AS ? el : [el], ss);
4520 return AS ? (AT.length == el.length) : (AT.length > 0);
4525 filter : function(AU, ss, AV){
4526 ss = ss.replace(C, "");
4527 if(!simpleCache[ss]){
4528 simpleCache[ss] = Roo.DomQuery.compile(ss, "simple");
4530 var AW = simpleCache[ss](AU);
4531 return AV ? S(AW, AU) : AW;
4538 select: 'n = byClassName(n, null, " {1} ");'
4540 re: /^\:([\w-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/,
4541 select: 'n = byPseudo(n, "{1}", "{2}");'
4543 re: /^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,
4544 select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
4547 select: 'n = byId(n, null, "{1}");'
4550 select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};'
4557 "=" : function(a, v){
4560 "!=" : function(a, v){
4563 "^=" : function(a, v){
4564 return a && a.substr(0, v.length) == v;
4566 "$=" : function(a, v){
4567 return a && a.substr(a.length-v.length) == v;
4569 "*=" : function(a, v){
4570 return a && a.indexOf(v) !== -1;
4572 "%=" : function(a, v){
4573 return (a % v) == 0;
4575 "|=" : function(a, v){
4576 return a && (a == v || a.substr(0, v.length+1) == v+'-');
4578 "~=" : function(a, v){
4579 return a && (' '+a+' ').indexOf(' '+v+' ') != -1;
4586 "first-child" : function(c){
4587 var r = [], ri = -1, n;
4588 for(var i = 0, ci; ci = n = c[i]; i++){
4589 while((n = n.previousSibling) && n.nodeType != 1);
4597 "last-child" : function(c){
4598 var r = [], ri = -1, n;
4599 for(var i = 0, ci; ci = n = c[i]; i++){
4600 while((n = n.nextSibling) && n.nodeType != 1);
4608 "nth-child" : function(c, a) {
4609 var r = [], ri = -1;
4610 var m = G.exec(a == "even" && "2n" || a == "odd" && "2n+1" || !H.test(a) && "n+" + a || a);
4611 var f = (m[1] || 1) - 0, l = m[2] - 0;
4612 for(var i = 0, n; n = c[i]; i++){
4613 var pn = n.parentNode;
4614 if (batch != pn._batch) {
4616 for(var cn = pn.firstChild; cn; cn = cn.nextSibling){
4617 if(cn.nodeType == 1){
4625 if (l == 0 || n.nodeIndex == l){
4628 } else if ((n.nodeIndex + l) % f == 0){
4636 "only-child" : function(c){
4637 var r = [], ri = -1;;
4638 for(var i = 0, ci; ci = c[i]; i++){
4639 if(!K(ci) && !J(ci)){
4646 "empty" : function(c){
4647 var r = [], ri = -1;
4648 for(var i = 0, ci; ci = c[i]; i++){
4649 var cns = ci.childNodes, j = 0, cn, empty = true;
4652 if(cn.nodeType == 1 || cn.nodeType == 3){
4664 "contains" : function(c, v){
4665 var r = [], ri = -1;
4666 for(var i = 0, ci; ci = c[i]; i++){
4667 if((ci.textContent||ci.innerText||'').indexOf(v) != -1){
4674 "nodeValue" : function(c, v){
4675 var r = [], ri = -1;
4676 for(var i = 0, ci; ci = c[i]; i++){
4677 if(ci.firstChild && ci.firstChild.nodeValue == v){
4684 "checked" : function(c){
4685 var r = [], ri = -1;
4686 for(var i = 0, ci; ci = c[i]; i++){
4687 if(ci.checked == true){
4694 "not" : function(c, ss){
4695 return Roo.DomQuery.filter(c, ss, true);
4698 "odd" : function(c){
4699 return this["nth-child"](c, "odd");
4702 "even" : function(c){
4703 return this["nth-child"](c, "even");
4706 "nth" : function(c, a){
4707 return c[a-1] || [];
4710 "first" : function(c){
4714 "last" : function(c){
4715 return c[c.length-1] || [];
4718 "has" : function(c, ss){
4719 var s = Roo.DomQuery.select;
4720 var r = [], ri = -1;
4721 for(var i = 0, ci; ci = c[i]; i++){
4722 if(s(ss, ci).length > 0){
4729 "next" : function(c, ss){
4730 var is = Roo.DomQuery.is;
4731 var r = [], ri = -1;
4732 for(var i = 0, ci; ci = c[i]; i++){
4741 "prev" : function(c, ss){
4742 var is = Roo.DomQuery.is;
4743 var r = [], ri = -1;
4744 for(var i = 0, ci; ci = c[i]; i++){
4758 Roo.query = Roo.DomQuery.select;
4766 Roo.util.Observable = function(A){
4769 this.addEvents(A.events || {});
4778 this.on(this.listeners);
4779 delete this.listeners;
4782 Roo.util.Observable.prototype = {
4789 fireEvent : function(){
4790 var ce = this.events[arguments[0].toLowerCase()];
4791 if(typeof ce == "object"){
4792 return ce.fire.apply(ce, Array.prototype.slice.call(arguments, 1));
4799 filterOptRe : /^(?:scope|delay|buffer|single)$/,
4803 addListener : function(B, fn, C, o){
4804 if(typeof B == "object"){
4807 if(this.filterOptRe.test(e)){
4810 if(typeof o[e] == "function"){
4812 this.addListener(e, o[e], o.scope, o);
4815 this.addListener(e, o[e].fn, o[e].scope, o[e]);
4821 o = (!o || typeof o == "boolean") ? {} : o;
4822 B = B.toLowerCase();
4823 var ce = this.events[B] || true;
4824 if(typeof ce == "boolean"){
4825 ce = new Roo.util.Event(this, B);
4826 this.events[B] = ce;
4829 ce.addListener(fn, C, o);
4834 removeListener : function(D, fn, E){
4835 var ce = this.events[D.toLowerCase()];
4836 if(typeof ce == "object"){
4837 ce.removeListener(fn, E);
4843 purgeListeners : function(){
4844 for(var evt in this.events){
4845 if(typeof this.events[evt] == "object"){
4846 this.events[evt].clearListeners();
4851 relayEvents : function(o, F){
4852 var G = function(H){
4854 return this.fireEvent.apply(this, Roo.combine(H, Array.prototype.slice.call(arguments, 0)));
4857 for(var i = 0, len = F.length; i < len; i++){
4859 if(!this.events[ename]){ this.events[ename] = true; };
4860 o.on(ename, G(ename), this);
4866 addEvents : function(o){
4871 Roo.applyIf(this.events, o);
4876 hasListener : function(H){
4877 var e = this.events[H];
4878 return typeof e == "object" && e.listeners.length > 0;
4883 Roo.util.Observable.prototype.on = Roo.util.Observable.prototype.addListener;
4886 Roo.util.Observable.prototype.un = Roo.util.Observable.prototype.removeListener;
4890 Roo.util.Observable.capture = function(o, fn, I){
4891 o.fireEvent = o.fireEvent.createInterceptor(fn, I);
4896 Roo.util.Observable.releaseCapture = function(o){
4897 o.fireEvent = Roo.util.Observable.prototype.fireEvent;
4902 var J = function(h, o, M){
4903 var N = new Roo.util.DelayedTask();
4905 N.delay(o.buffer, h, M, Array.prototype.slice.call(arguments, 0));
4909 var K = function(h, e, fn, M){
4911 e.removeListener(fn, M);
4912 return h.apply(M, arguments);
4916 var L = function(h, o, M){
4918 var N = Array.prototype.slice.call(arguments, 0);
4919 setTimeout(function(){
4925 Roo.util.Event = function(M, N){
4928 this.listeners = [];
4931 Roo.util.Event.prototype = {
4932 addListener : function(fn, M, N){
4935 if(!this.isListening(fn, M)){
4936 var l = {fn: fn, scope: M, options: o};
4942 h = K(h, this, fn, M);
4950 this.listeners.push(l);
4952 this.listeners = this.listeners.slice(0);
4953 this.listeners.push(l);
4958 findListener : function(fn, O){
4960 var ls = this.listeners;
4961 for(var i = 0, len = ls.length; i < len; i++){
4963 if(l.fn == fn && l.scope == O){
4970 isListening : function(fn, P){
4971 return this.findListener(fn, P) != -1;
4974 removeListener : function(fn, Q){
4976 if((R = this.findListener(fn, Q)) != -1){
4978 this.listeners.splice(R, 1);
4980 this.listeners = this.listeners.slice(0);
4981 this.listeners.splice(R, 1);
4988 clearListeners : function(){
4989 this.listeners = [];
4993 var ls = this.listeners, S, T = ls.length;
4996 var args = Array.prototype.slice.call(arguments, 0);
4997 for(var i = 0; i < T; i++){
4999 if(l.fireFn.apply(l.scope||this.obj||window, arguments) === false){
5000 this.firing = false;
5005 this.firing = false;
5016 Roo.EventManager = function(){
5017 var A, B, C = false;
5019 var E = Roo.lib.Event;
5020 var D = Roo.lib.Dom;
5030 if(Roo.isGecko || Roo.isOpera) {
5031 document.removeEventListener("DOMContentLoaded", J, false);
5034 var defer = document.getElementById("ie-deferred-loader");
5036 defer.onreadystatechange = null;
5037 defer.parentNode.removeChild(defer);
5048 A = new Roo.util.Event();
5049 if(Roo.isGecko || Roo.isOpera) {
5050 document.addEventListener("DOMContentLoaded", J, false);
5052 document.write("<s"+'cript id="ie-deferred-loader" defer="defer" src="/'+'/:"></s'+"cript>");
5053 var defer = document.getElementById("ie-deferred-loader");
5054 defer.onreadystatechange = function(){
5055 if(this.readyState == "complete"){
5059 }else if(Roo.isSafari){
5060 B = setInterval(function(){
5061 var rs = document.readyState;
5062 if(rs == "complete") {
5069 E.on(window, "load", J);
5072 var L = function(h, o){
5073 var S = new Roo.util.DelayedTask(h);
5076 e = new Roo.EventObjectImpl(e);
5077 S.delay(o.buffer, h, null, [e]);
5081 var M = function(h, el, S, fn){
5083 Roo.EventManager.removeListener(el, S, fn);
5088 var N = function(h, o){
5091 e = new Roo.EventObjectImpl(e);
5092 setTimeout(function(){
5098 var O = function(S, T, U, fn, V){
5099 var o = (!U || typeof U == "boolean") ? {} : U;
5100 fn = fn || o.fn; V = V || o.scope;
5101 var el = Roo.getDom(S);
5103 throw "Error listening for \"" + T + '\". Element "' + S + '" doesn\'t exist.';
5105 var h = function(e){
5106 e = Roo.EventObject.setEvent(e);
5109 t = e.getTarget(o.delegate, el);
5116 if(o.stopEvent === true){
5119 if(o.preventDefault === true){
5122 if(o.stopPropagation === true){
5123 e.stopPropagation();
5126 if(o.normalized === false){
5131 fn.call(V || el, e, t, o);
5137 h = M(h, el, T, fn);
5143 fn._handlers = fn._handlers || [];
5144 fn._handlers.push([Roo.id(el), T, h]);
5147 if(T == "mousewheel" && el.addEventListener){
5148 el.addEventListener("DOMMouseScroll", h, false);
5149 E.on(window, 'unload', function(){
5150 el.removeEventListener("DOMMouseScroll", h, false);
5153 if(T == "mousedown" && el == document){
5154 Roo.EventManager.stoppedMouseDownEvent.addListener(h);
5159 var P = function(el, S, fn){
5160 var id = Roo.id(el), T = fn._handlers, hd = fn;
5162 for(var i = 0, len = T.length; i < len; i++){
5164 if(h[0] == id && h[1] == S){
5173 el = Roo.getDom(el);
5174 if(S == "mousewheel" && el.addEventListener){
5175 el.removeEventListener("DOMMouseScroll", hd, false);
5177 if(S == "mousedown" && el == document){
5178 Roo.EventManager.stoppedMouseDownEvent.removeListener(hd);
5182 var Q = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/;
5193 wrap : function(fn, S, T){
5195 Roo.EventObject.setEvent(e);
5196 fn.call(T ? S || window : window, Roo.EventObject, S);
5202 addListener : function(U, V, fn, W, X){
5203 if(typeof V == "object"){
5209 if(typeof o[e] == "function"){
5211 O(U, e, o, o[e], o.scope);
5219 return O(U, V, X, fn, W);
5224 removeListener : function(Y, Z, fn){
5230 onDocumentReady : function(fn, a, b){
5232 A.addListener(fn, a, b);
5241 A.addListener(fn, a, b);
5246 onWindowResize : function(fn, c, d){
5248 F = new Roo.util.Event();
5249 G = new Roo.util.DelayedTask(function(){
5250 F.fire(D.getViewWidth(), D.getViewHeight());
5252 E.on(window, "resize", function(){
5256 F.fire(D.getViewWidth(), D.getViewHeight());
5261 F.addListener(fn, c, d);
5266 onTextResize : function(fn, f, g){
5268 H = new Roo.util.Event();
5269 var textEl = new Roo.Element(document.createElement('div'));
5270 textEl.dom.className = 'x-text-resize';
5271 textEl.dom.innerHTML = 'X';
5272 textEl.appendTo(document.body);
5273 I = textEl.dom.offsetHeight;
5274 setInterval(function(){
5275 if(textEl.dom.offsetHeight != I){
5276 H.fire(I, I = textEl.dom.offsetHeight);
5278 }, this.textResizeInterval);
5281 H.addListener(fn, f, g);
5286 removeResizeListener : function(fn, j){
5288 F.removeListener(fn, j);
5293 fireResize : function(){
5295 F.fire(D.getViewWidth(), D.getViewHeight());
5303 textResizeInterval : 50
5311 R.on = R.addListener;
5312 R.un = R.removeListener;
5314 R.stoppedMouseDownEvent = new Roo.util.Event();
5319 Roo.onReady = Roo.EventManager.onDocumentReady;
5321 Roo.onReady(function(){
5322 var bd = Roo.get(document.body);
5327 : Roo.isGecko ? "roo-gecko"
5328 : Roo.isOpera ? "roo-opera"
5329 : Roo.isSafari ? "roo-safari" : ""];
5335 S.push("roo-linux");
5337 if(Roo.isBorderBox){
5338 S.push('roo-border-box');
5341 var p = bd.dom.parentNode;
5343 p.className += ' roo-strict';
5347 bd.addClass(S.join(' '));
5352 Roo.EventObject = function(){
5354 var E = Roo.lib.Event;
5370 var U = Roo.isIE ? {1:0,4:1,2:2} :
5371 (Roo.isSafari ? {1:0,2:1,3:2} : {0:0,1:1,2:2});
5373 Roo.EventObjectImpl = function(e){
5375 this.setEvent(e.browserEvent || e);
5378 Roo.EventObjectImpl.prototype = {
5387 browserEvent : null,
5458 setEvent : function(e){
5459 if(e == this || (e && e.browserEvent)){
5463 this.browserEvent = e;
5466 this.button = e.button ? U[e.button] : (e.which ? e.which-1 : -1);
5467 if(e.type == 'click' && this.button == -1){
5472 this.shiftKey = e.shiftKey;
5474 this.ctrlKey = e.ctrlKey || e.metaKey;
5475 this.altKey = e.altKey;
5477 this.keyCode = e.keyCode;
5479 this.charCode = (e.type == 'keyup' || e.type == 'keydown') ? 0 : e.charCode;
5481 this.target = E.getTarget(e);
5483 this.xy = E.getXY(e);
5486 this.shiftKey = false;
5487 this.ctrlKey = false;
5488 this.altKey = false;
5499 stopEvent : function(){
5500 if(this.browserEvent){
5501 if(this.browserEvent.type == 'mousedown'){
5502 Roo.EventManager.stoppedMouseDownEvent.fire(this);
5505 E.stopEvent(this.browserEvent);
5511 preventDefault : function(){
5512 if(this.browserEvent){
5513 E.preventDefault(this.browserEvent);
5519 isNavKeyPress : function(){
5520 var k = this.keyCode;
5521 k = Roo.isSafari ? (T[k] || k) : k;
5522 return (k >= 33 && k <= 40) || k == this.RETURN || k == this.TAB || k == this.ESC;
5525 isSpecialKey : function(){
5526 var k = this.keyCode;
5527 return (this.type == 'keypress' && this.ctrlKey) || k == 9 || k == 13 || k == 40 || k == 27 ||
5528 (k == 16) || (k == 17) ||
5529 (k >= 18 && k <= 20) ||
5530 (k >= 33 && k <= 35) ||
5531 (k >= 36 && k <= 39) ||
5532 (k >= 44 && k <= 45);
5536 stopPropagation : function(){
5537 if(this.browserEvent){
5538 if(this.type == 'mousedown'){
5539 Roo.EventManager.stoppedMouseDownEvent.fire(this);
5542 E.stopPropagation(this.browserEvent);
5548 getCharCode : function(){
5549 return this.charCode || this.keyCode;
5554 getKey : function(){
5555 var k = this.keyCode || this.charCode;
5556 return Roo.isSafari ? (T[k] || k) : k;
5561 getPageX : function(){
5567 getPageY : function(){
5573 getTime : function(){
5574 if(this.browserEvent){
5575 return E.getTime(this.browserEvent);
5588 getTarget : function(V, W, X){
5589 return V ? Roo.fly(this.target).findParent(V, W, X) : this.target;
5593 getRelatedTarget : function(){
5594 if(this.browserEvent){
5595 return E.getRelatedTarget(this.browserEvent);
5602 getWheelDelta : function(){
5603 var e = this.browserEvent;
5607 Y = e.wheelDelta/120;
5617 hasModifier : function(){
5618 return !!((this.ctrlKey || this.altKey) || this.shiftKey);
5623 within : function(el, Z){
5624 var t = this[Z ? "getRelatedTarget" : "getTarget"]();
5625 return t && Roo.fly(el).contains(t);
5628 getPoint : function(){
5629 return new Roo.lib.Point(this.xy[0], this.xy[1]);
5633 return new Roo.EventObjectImpl();
5644 var D = Roo.lib.Dom;
5645 var E = Roo.lib.Event;
5646 var A = Roo.lib.Anim;
5650 var C = /(-[a-z])/gi;
5651 var F = function(m, a){ return a.charAt(1).toUpperCase(); };
5652 var G = document.defaultView;
5656 Roo.Element = function(J, K){
5657 var L = typeof J == "string" ?
5658 document.getElementById(J) : J;
5663 if(K !== true && id && Roo.Element.cache[id]){
5664 return Roo.Element.cache[id];
5674 this.id = id || Roo.id(L);
5677 var El = Roo.Element;
5682 originalDisplay : "",
5690 setVisibilityMode : function(J){
5691 this.visibilityMode = J;
5696 enableDisplayMode : function(K){
5697 this.setVisibilityMode(El.DISPLAY);
5698 if(typeof K != "undefined") this.originalDisplay = K;
5704 findParent : function(L, M, N){
5705 var p = this.dom, b = document.body, O = 0, dq = Roo.DomQuery, P;
5707 if(typeof M != "number"){
5711 while(p && p.nodeType == 1 && O < M && p != b && p != P){
5713 return N ? Roo.get(p) : p;
5725 findParentNode : function(Q, R, S){
5726 var p = Roo.fly(this.dom.parentNode, '_internal');
5727 return p ? p.findParent(Q, R, S) : null;
5732 up : function(T, U){
5733 return this.findParentNode(T, U, true);
5741 return Roo.DomQuery.is(this.dom, V);
5746 animate : function(W, X, Y, Z, c){
5747 this.anim(W, {duration: X, callback: Y, easing: Z}, c);
5753 anim : function(e, g, h, j, k, cb){
5756 var l = Roo.lib.Anim[h](
5758 (g.duration || j) || .35,
5759 (g.easing || k) || 'easeOut',
5761 Roo.callback(cb, this);
5762 Roo.callback(g.callback, g.scope || this, [this, g]);
5771 preanim : function(a, i){
5772 return !a[i] ? false : (typeof a[i] == "object" ? a[i]: {duration: a[i+1], callback: a[i+2], easing: a[i+3]});
5777 clean : function(o){
5778 if(this.isCleaned && o !== true){
5782 var d = this.dom, n = d.firstChild, ni = -1;
5784 var nx = n.nextSibling;
5785 if(n.nodeType == 3 && !ns.test(n.nodeValue)){
5794 this.isCleaned = true;
5799 calcOffsetsTo : function(el){
5803 if(el.getStyle('position') == 'static'){
5804 el.position('relative');
5809 while(op && op != d && op.tagName != 'HTML'){
5812 op = op.offsetParent;
5815 el.position('static');
5822 scrollIntoView : function(u, v){
5823 var c = Roo.getDom(u) || document.body;
5826 var o = this.calcOffsetsTo(c),
5829 b = t+el.offsetHeight,
5830 r = l+el.offsetWidth;
5832 var ch = c.clientHeight;
5833 var ct = parseInt(c.scrollTop, 10);
5834 var cl = parseInt(c.scrollLeft, 10);
5836 var cr = cl + c.clientWidth;
5848 c.scrollLeft = r-c.clientWidth;
5855 scrollChildIntoView : function(w, z){
5856 Roo.fly(w, '_scrollChildIntoView').scrollIntoView(this, z);
5861 autoHeight : function(AA, AB, AC, AD){
5862 var AE = this.getHeight();
5865 setTimeout(function(){
5866 var AG = parseInt(this.dom.scrollHeight, 10);
5870 if(typeof AC == "function"){
5875 this.setHeight(AG, AA, AB, function(){
5877 if(typeof AC == "function") AC();
5878 }.createDelegate(this), AD);
5880 }.createDelegate(this), 0);
5886 contains : function(el){
5887 if(!el){return false;}
5888 return D.isAncestor(this.dom, el.dom ? el.dom : el);
5893 isVisible : function(AF) {
5894 var AG = !(this.getStyle("visibility") == "hidden" || this.getStyle("display") == "none");
5895 if(AF !== true || !AG){
5898 var p = this.dom.parentNode;
5899 while(p && p.tagName.toLowerCase() != "body"){
5900 if(!Roo.fly(p, '_isVisible').isVisible()){
5911 select : function(AH, AI){
5912 return El.select(AH, AI, this.dom);
5917 query : function(AJ, AK){
5918 return Roo.DomQuery.select(AJ, this.dom);
5923 child : function(AL, AM){
5924 var n = Roo.DomQuery.selectNode(AL, this.dom);
5925 return AM ? n : Roo.get(n);
5930 down : function(AN, AO){
5931 var n = Roo.DomQuery.selectNode(" > " + AN, this.dom);
5932 return AO ? n : Roo.get(n);
5937 initDD : function(AP, AQ, AR){
5938 var dd = new Roo.dd.DD(Roo.id(this.dom), AP, AQ);
5939 return Roo.apply(dd, AR);
5944 initDDProxy : function(AS, AT, AU){
5945 var dd = new Roo.dd.DDProxy(Roo.id(this.dom), AS, AT);
5946 return Roo.apply(dd, AU);
5951 initDDTarget : function(AV, AW, AX){
5952 var dd = new Roo.dd.DDTarget(Roo.id(this.dom), AV, AW);
5953 return Roo.apply(dd, AX);
5958 setVisible : function(AY, AZ){
5960 if(this.visibilityMode == El.DISPLAY){
5961 this.setDisplayed(AY);
5964 this.dom.style.visibility = AY ? "visible" : "hidden";
5969 var J = this.visibilityMode;
5971 this.setOpacity(.01);
5972 this.setVisible(true);
5975 this.anim({opacity: { to: (AY?1:0) }},
5976 this.preanim(arguments, 1),
5977 null, .35, 'easeIn', function(){
5979 if(J == El.DISPLAY){
5980 dom.style.display = "none";
5982 dom.style.visibility = "hidden";
5985 Roo.get(dom).setOpacity(1);
5994 isDisplayed : function() {
5995 return this.getStyle("display") != "none";
6000 toggle : function(Aa){
6001 this.setVisible(!this.isVisible(), this.preanim(arguments, 0));
6007 setDisplayed : function(Ab) {
6008 if(typeof Ab == "boolean"){
6009 Ab = Ab ? this.originalDisplay : "none";
6012 this.setStyle("display", Ab);
6018 focus : function() {
6036 addClass : function(Ac){
6037 if(Ac instanceof Array){
6038 for(var i = 0, len = Ac.length; i < len; i++) {
6039 this.addClass(Ac[i]);
6042 if(Ac && !this.hasClass(Ac)){
6043 this.dom.className = this.dom.className + " " + Ac;
6051 radioClass : function(Ad){
6052 var Ae = this.dom.parentNode.childNodes;
6053 for(var i = 0; i < Ae.length; i++) {
6055 if(s.nodeType == 1){
6056 Roo.get(s).removeClass(Ad);
6066 removeClass : function(Af){
6067 if(!Af || !this.dom.className){
6070 if(Af instanceof Array){
6071 for(var i = 0, len = Af.length; i < len; i++) {
6072 this.removeClass(Af[i]);
6075 if(this.hasClass(Af)){
6076 var re = this.classReCache[Af];
6078 re = new RegExp('(?:^|\\s+)' + Af + '(?:\\s+|$)', "g");
6079 this.classReCache[Af] = re;
6082 this.dom.className =
6083 this.dom.className.replace(re, " ");
6094 toggleClass : function(Ag){
6095 if(this.hasClass(Ag)){
6096 this.removeClass(Ag);
6105 hasClass : function(Ah){
6106 return Ah && (' '+this.dom.className+' ').indexOf(' '+Ah+' ') != -1;
6111 replaceClass : function(Ai, Aj){
6112 this.removeClass(Ai);
6119 getStyles : function(){
6120 var a = arguments, Ak = a.length, r = {};
6121 for(var i = 0; i < Ak; i++){
6122 r[a[i]] = this.getStyle(a[i]);
6129 getStyle : function(){
6130 return G && G.getComputedStyle ?
6132 var el = this.dom, v, cs, Am;
6136 if(el.style && (v = el.style[Al])){
6139 if(cs = G.getComputedStyle(el, "")){
6141 Am = B[Al] = Al.replace(C, F);
6148 var el = this.dom, v, cs, Am;
6149 if(Al == 'opacity'){
6150 if(typeof el.style.filter == 'string'){
6151 var m = el.style.filter.match(/alpha\(opacity=(.*)\)/i);
6153 var fv = parseFloat(m[1]);
6155 return fv ? fv / 100 : 0;
6160 }else if(Al == 'float'){
6164 Am = B[Al] = Al.replace(C, F);
6166 if(v = el.style[Am]){
6169 if(cs = el.currentStyle){
6178 setStyle : function(Al, Am){
6179 if(typeof Al == "string"){
6181 if (Al == 'float') {
6182 this.setStyle(Roo.isIE ? 'styleFloat' : 'cssFloat', Am);
6187 if(!(camel = B[Al])){
6188 camel = B[Al] = Al.replace(C, F);
6191 if(camel == 'opacity') {
6192 this.setOpacity(Am);
6194 this.dom.style[camel] = Am;
6197 for(var style in Al){
6198 if(typeof Al[style] != "function"){
6199 this.setStyle(style, Al[style]);
6208 applyStyles : function(An){
6209 Roo.DomHelper.applyStyles(this.dom, An);
6216 return D.getX(this.dom);
6222 return D.getY(this.dom);
6228 return D.getXY(this.dom);
6233 setX : function(x, Ao){
6235 D.setX(this.dom, x);
6237 this.setXY([x, this.getY()], this.preanim(arguments, 1));
6244 setY : function(y, Ap){
6246 D.setY(this.dom, y);
6248 this.setXY([this.getX(), y], this.preanim(arguments, 1));
6255 setLeft : function(Aq){
6256 this.setStyle("left", this.addUnits(Aq));
6262 setTop : function(Ar){
6263 this.setStyle("top", this.addUnits(Ar));
6269 setRight : function(As){
6270 this.setStyle("right", this.addUnits(As));
6276 setBottom : function(At){
6277 this.setStyle("bottom", this.addUnits(At));
6283 setXY : function(Au, Av){
6285 D.setXY(this.dom, Au);
6287 this.anim({points: {to: Au}}, this.preanim(arguments, 1), 'motion');
6294 setLocation : function(x, y, Aw){
6295 this.setXY([x, y], this.preanim(arguments, 2));
6301 moveTo : function(x, y, Ax){
6302 this.setXY([x, y], this.preanim(arguments, 2));
6308 getRegion : function(){
6309 return D.getRegion(this.dom);
6314 getHeight : function(Ay){
6315 var h = this.dom.offsetHeight || 0;
6316 return Ay !== true ? h : h-this.getBorderWidth("tb")-this.getPadding("tb");
6321 getWidth : function(Az){
6322 var w = this.dom.offsetWidth || 0;
6323 return Az !== true ? w : w-this.getBorderWidth("lr")-this.getPadding("lr");
6328 getComputedHeight : function(){
6329 var h = Math.max(this.dom.offsetHeight, this.dom.clientHeight);
6331 h = parseInt(this.getStyle('height'), 10) || 0;
6332 if(!this.isBorderBox()){
6333 h += this.getFrameWidth('tb');
6341 getComputedWidth : function(){
6342 var w = Math.max(this.dom.offsetWidth, this.dom.clientWidth);
6344 w = parseInt(this.getStyle('width'), 10) || 0;
6345 if(!this.isBorderBox()){
6346 w += this.getFrameWidth('lr');
6354 getSize : function(A0){
6355 return {width: this.getWidth(A0), height: this.getHeight(A0)};
6360 getViewSize : function(){
6361 var d = this.dom, A1 = document, aw = 0, ah = 0;
6362 if(d == A1 || d == A1.body){
6363 return {width : D.getViewWidth(), height: D.getViewHeight()};
6366 width : d.clientWidth,
6367 height: d.clientHeight
6374 getValue : function(A2){
6375 return A2 ? parseInt(this.dom.value, 10) : this.dom.value;
6379 adjustWidth : function(A3){
6380 if(typeof A3 == "number"){
6381 if(this.autoBoxAdjust && !this.isBorderBox()){
6382 A3 -= (this.getBorderWidth("lr") + this.getPadding("lr"));
6392 adjustHeight : function(A4){
6393 if(typeof A4 == "number"){
6394 if(this.autoBoxAdjust && !this.isBorderBox()){
6395 A4 -= (this.getBorderWidth("tb") + this.getPadding("tb"));
6406 setWidth : function(A5, A6){
6407 A5 = this.adjustWidth(A5);
6409 this.dom.style.width = this.addUnits(A5);
6411 this.anim({width: {to: A5}}, this.preanim(arguments, 1));
6418 setHeight : function(A7, A8){
6419 A7 = this.adjustHeight(A7);
6421 this.dom.style.height = this.addUnits(A7);
6423 this.anim({height: {to: A7}}, this.preanim(arguments, 1));
6430 setSize : function(A9, BA, BB){
6431 if(typeof A9 == "object"){
6432 BA = A9.height; A9 = A9.width;
6435 A9 = this.adjustWidth(A9); BA = this.adjustHeight(BA);
6437 this.dom.style.width = this.addUnits(A9);
6438 this.dom.style.height = this.addUnits(BA);
6440 this.anim({width: {to: A9}, height: {to: BA}}, this.preanim(arguments, 2));
6447 setBounds : function(x, y, BC, BD, BE){
6449 this.setSize(BC, BD);
6450 this.setLocation(x, y);
6452 BC = this.adjustWidth(BC); BD = this.adjustHeight(BD);
6453 this.anim({points: {to: [x, y]}, width: {to: BC}, height: {to: BD}},
6454 this.preanim(arguments, 4), 'motion');
6461 setRegion : function(BF, BG){
6462 this.setBounds(BF.left, BF.top, BF.right-BF.left, BF.bottom-BF.top, this.preanim(arguments, 1));
6468 addListener : function(BH, fn, BI, BJ){
6469 Roo.EventManager.on(this.dom, BH, fn, BI || this, BJ);
6474 removeListener : function(BK, fn){
6475 Roo.EventManager.removeListener(this.dom, BK, fn);
6481 removeAllListeners : function(){
6482 E.purgeElement(this.dom);
6486 relayEvent : function(BL, BM){
6487 this.on(BL, function(e){
6488 BM.fireEvent(BL, e);
6494 setOpacity : function(BN, BO){
6496 var s = this.dom.style;
6499 s.filter = (s.filter || '').replace(/alpha\([^\)]*\)/gi,"") +
6500 (BN == 1 ? "" : "alpha(opacity=" + BN * 100 + ")");
6505 this.anim({opacity: {to: BN}}, this.preanim(arguments, 1), null, .35, 'easeIn');
6512 getLeft : function(BP){
6516 return parseInt(this.getStyle("left"), 10) || 0;
6522 getRight : function(BQ){
6524 return this.getX() + this.getWidth();
6526 return (this.getLeft(true) + this.getWidth()) || 0;
6532 getTop : function(BR) {
6536 return parseInt(this.getStyle("top"), 10) || 0;
6542 getBottom : function(BS){
6544 return this.getY() + this.getHeight();
6546 return (this.getTop(true) + this.getHeight()) || 0;
6552 position : function(BT, BU, x, y){
6554 if(this.getStyle('position') == 'static'){
6555 this.setStyle('position', 'relative');
6558 this.setStyle("position", BT);
6561 this.setStyle("z-index", BU);
6563 if(x !== undefined && y !== undefined){
6565 }else if(x !== undefined){
6567 }else if(y !== undefined){
6574 clearPositioning : function(BV){
6582 "position" : "static"
6589 getPositioning : function(){
6590 var l = this.getStyle("left");
6591 var t = this.getStyle("top");
6593 "position" : this.getStyle("position"),
6595 "right" : l ? "" : this.getStyle("right"),
6597 "bottom" : t ? "" : this.getStyle("bottom"),
6598 "z-index" : this.getStyle("z-index")
6604 getBorderWidth : function(BW){
6605 return this.addStyles(BW, El.borders);
6610 getPadding : function(BX){
6611 return this.addStyles(BX, El.paddings);
6616 setPositioning : function(pc){
6617 this.applyStyles(pc);
6618 if(pc.right == "auto"){
6619 this.dom.style.right = "";
6621 if(pc.bottom == "auto"){
6622 this.dom.style.bottom = "";
6628 fixDisplay : function(){
6629 if(this.getStyle("display") == "none"){
6630 this.setStyle("visibility", "hidden");
6631 this.setStyle("display", this.originalDisplay);
6632 if(this.getStyle("display") == "none"){
6633 this.setStyle("display", "block");
6640 setLeftTop : function(BY, BZ){
6641 this.dom.style.left = this.addUnits(BY);
6642 this.dom.style.top = this.addUnits(BZ);
6648 move : function(Ba, Bb, Bc){
6649 var xy = this.getXY();
6650 Ba = Ba.toLowerCase();
6654 this.moveTo(xy[0]-Bb, xy[1], this.preanim(arguments, 2));
6658 this.moveTo(xy[0]+Bb, xy[1], this.preanim(arguments, 2));
6663 this.moveTo(xy[0], xy[1]-Bb, this.preanim(arguments, 2));
6668 this.moveTo(xy[0], xy[1]+Bb, this.preanim(arguments, 2));
6677 if(!this.isClipped){
6678 this.isClipped = true;
6679 this.originalClip = {
6680 "o": this.getStyle("overflow"),
6681 "x": this.getStyle("overflow-x"),
6682 "y": this.getStyle("overflow-y")
6684 this.setStyle("overflow", "hidden");
6685 this.setStyle("overflow-x", "hidden");
6686 this.setStyle("overflow-y", "hidden");
6693 unclip : function(){
6695 this.isClipped = false;
6696 var o = this.originalClip;
6697 if(o.o){this.setStyle("overflow", o.o);}
6698 if(o.x){this.setStyle("overflow-x", o.x);}
6699 if(o.y){this.setStyle("overflow-y", o.y);}
6707 getAnchorXY : function(Bd, Be, s){
6711 var w, h, vp = false;
6714 if(d == document.body || d == document){
6716 w = D.getViewWidth(); h = D.getViewHeight();
6718 w = this.getWidth(); h = this.getHeight();
6721 w = s.width; h = s.height;
6723 var x = 0, y = 0, r = Math.round;
6724 switch((Bd || "tl").toLowerCase()){
6766 var sc = this.getScroll();
6767 return [x + sc.left, y + sc.top];
6770 var o = this.getXY();
6771 return [x+o[0], y+o[1]];
6776 getAlignToXY : function(el, p, o){
6780 throw "Element.alignTo with an element that doesn't exist";
6783 var p1 = "", p2 = "";
6790 }else if(p.indexOf("-") == -1){
6794 p = p.toLowerCase();
6795 var m = p.match(/^([a-z]+)-([a-z]+)(\?)?$/);
6797 throw "Element.alignTo with an invalid alignment " + p;
6800 p1 = m[1]; p2 = m[2]; c = !!m[3];
6804 var a1 = this.getAnchorXY(p1, true);
6805 var a2 = el.getAnchorXY(p2, false);
6806 var x = a2[0] - a1[0] + o[0];
6807 var y = a2[1] - a1[1] + o[1];
6810 var w = this.getWidth(), h = this.getHeight(), r = el.getRegion();
6812 var dw = D.getViewWidth()-5, dh = D.getViewHeight()-5;
6817 var p1y = p1.charAt(0), p1x = p1.charAt(p1.length-1);
6818 var p2y = p2.charAt(0), p2x = p2.charAt(p2.length-1);
6819 var swapY = ((p1y=="t" && p2y=="b") || (p1y=="b" && p2y=="t"));
6820 var swapX = ((p1x=="r" && p2x=="l") || (p1x=="l" && p2x=="r"));
6823 var scrollX = (A1.documentElement.scrollLeft || A1.body.scrollLeft || 0)+5;
6824 var scrollY = (A1.documentElement.scrollTop || A1.body.scrollTop || 0)+5;
6826 if((x+w) > dw + scrollX){
6827 x = swapX ? r.left-w : dw+scrollX-w;
6830 x = swapX ? r.right : scrollX;
6832 if((y+h) > dh + scrollY){
6833 y = swapY ? r.top-h : dh+scrollY-h;
6836 y = swapY ? r.bottom : scrollY;
6843 getConstrainToXY : function(){
6844 var os = {top:0, left:0, bottom:0, right: 0};
6846 return function(el, Bf, Bg, Bh){
6848 Bg = Bg ? Roo.applyIf(Bg, os) : os;
6850 var vw, vh, vx = 0, vy = 0;
6851 if(el.dom == document.body || el.dom == document){
6852 vw = Roo.lib.Dom.getViewWidth();
6853 vh = Roo.lib.Dom.getViewHeight();
6855 vw = el.dom.clientWidth;
6856 vh = el.dom.clientHeight;
6858 var vxy = el.getXY();
6864 var s = el.getScroll();
6866 vx += Bg.left + s.left;
6867 vy += Bg.top + s.top;
6875 var xy = Bh || (!Bf ? this.getXY() : [this.getLeft(true), this.getTop(true)]);
6876 var x = xy[0], y = xy[1];
6877 var w = this.dom.offsetWidth, h = this.dom.offsetHeight;
6900 return Bi ? [x, y] : false;
6905 adjustForConstraints : function(xy, Bf, Bg){
6906 return this.getConstrainToXY(Bf || document, false, Bg, xy) || xy;
6911 alignTo : function(Bh, Bi, Bj, Bk){
6912 var xy = this.getAlignToXY(Bh, Bi, Bj);
6913 this.setXY(xy, this.preanim(arguments, 3));
6919 anchorTo : function(el, Bl, Bm, Bn, Bo, Bp){
6920 var Bq = function(){
6921 this.alignTo(el, Bl, Bm, Bn);
6922 Roo.callback(Bp, this);
6924 Roo.EventManager.onWindowResize(Bq, this);
6926 if(tm != 'undefined'){
6927 Roo.EventManager.on(window, 'scroll', Bq, this,
6928 {buffer: tm == 'number' ? Bo : 50});
6936 clearOpacity : function(){
6937 if (window.ActiveXObject) {
6938 if(typeof this.dom.style.filter == 'string' && (/alpha/i).test(this.dom.style.filter)){
6939 this.dom.style.filter = "";
6942 this.dom.style.opacity = "";
6943 this.dom.style["-moz-opacity"] = "";
6944 this.dom.style["-khtml-opacity"] = "";
6951 hide : function(Br){
6952 this.setVisible(false, this.preanim(arguments, 0));
6958 show : function(Bs){
6959 this.setVisible(true, this.preanim(arguments, 0));
6965 addUnits : function(Bt){
6966 return Roo.Element.addUnits(Bt, this.defaultUnit);
6971 beginMeasure : function(){
6973 if(el.offsetWidth || el.offsetHeight){
6977 var p = this.dom, b = document.body;
6978 while((!el.offsetWidth && !el.offsetHeight) && p && p.tagName && p != b){
6979 var pe = Roo.get(p);
6980 if(pe.getStyle('display') == 'none'){
6981 Bu.push({el: p, visibility: pe.getStyle("visibility")});
6982 p.style.visibility = "hidden";
6983 p.style.display = "block";
6989 this._measureChanged = Bu;
6996 endMeasure : function(){
6997 var Bv = this._measureChanged;
6999 for(var i = 0, Ak = Bv.length; i < Ak; i++) {
7001 r.el.style.visibility = r.visibility;
7002 r.el.style.display = "none";
7005 this._measureChanged = null;
7012 update : function(Bw, Bx, By){
7013 if(typeof Bw == "undefined"){
7017 this.dom.innerHTML = Bw;
7018 if(typeof By == "function"){
7026 Bw += '<span id="' + id + '"></span>';
7028 E.onAvailable(id, function(){
7029 var hd = document.getElementsByTagName("head")[0];
7030 var re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig;
7031 var B0 = /\ssrc=([\'\"])(.*?)\1/i;
7032 var B1 = /\stype=([\'\"])(.*?)\1/i;
7035 while(B2 = re.exec(Bw)){
7037 var srcMatch = attrs ? attrs.match(B0) : false;
7038 if(srcMatch && srcMatch[2]){
7039 var s = document.createElement("script");
7040 s.src = srcMatch[2];
7041 var typeMatch = attrs.match(B1);
7042 if(typeMatch && typeMatch[2]){
7043 s.type = typeMatch[2];
7047 }else if(B2[2] && B2[2].length > 0){
7048 if(window.execScript) {
7049 window.execScript(B2[2]);
7057 var el = document.getElementById(id);
7058 if(el){el.parentNode.removeChild(el);}
7059 if(typeof By == "function"){
7063 Bz.innerHTML = Bw.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig, "");
7070 var um = this.getUpdateManager();
7071 um.update.apply(um, arguments);
7077 getUpdateManager : function(){
7078 if(!this.updateManager){
7079 this.updateManager = new Roo.UpdateManager(this);
7081 return this.updateManager;
7086 unselectable : function(){
7087 this.dom.unselectable = "on";
7088 this.swallowEvent("selectstart", true);
7089 this.applyStyles("-moz-user-select:none;-khtml-user-select:none;");
7090 this.addClass("x-unselectable");
7096 getCenterXY : function(){
7097 return this.getAlignToXY(document, 'c-c');
7102 center : function(B0){
7103 this.alignTo(B0 || document, 'c-c');
7109 isBorderBox : function(){
7110 return I[this.dom.tagName.toLowerCase()] || Roo.isBorderBox;
7115 getBox : function(B1, B2){
7120 var BY = parseInt(this.getStyle("left"), 10) || 0;
7121 var BZ = parseInt(this.getStyle("top"), 10) || 0;
7124 var el = this.dom, w = el.offsetWidth, h = el.offsetHeight, bx;
7126 bx = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: w, height: h};
7128 var l = this.getBorderWidth("l")+this.getPadding("l");
7129 var r = this.getBorderWidth("r")+this.getPadding("r");
7130 var t = this.getBorderWidth("t")+this.getPadding("t");
7131 var b = this.getBorderWidth("b")+this.getPadding("b");
7132 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)};
7135 bx.right = bx.x + bx.width;
7136 bx.bottom = bx.y + bx.height;
7142 getFrameWidth : function(B3, B4){
7143 return B4 && Roo.isBorderBox ? 0 : (this.getPadding(B3) + this.getBorderWidth(B3));
7148 setBox : function(B5, B6, B7){
7149 var w = B5.width, h = B5.height;
7150 if((B6 && !this.autoBoxAdjust) && !this.isBorderBox()){
7151 w -= (this.getBorderWidth("lr") + this.getPadding("lr"));
7152 h -= (this.getBorderWidth("tb") + this.getPadding("tb"));
7155 this.setBounds(B5.x, B5.y, w, h, this.preanim(arguments, 2));
7161 repaint : function(){
7163 this.addClass("x-repaint");
7164 setTimeout(function(){
7165 Roo.get(B8).removeClass("x-repaint");
7172 getMargins : function(B9){
7175 top: parseInt(this.getStyle("margin-top"), 10) || 0,
7176 left: parseInt(this.getStyle("margin-left"), 10) || 0,
7177 bottom: parseInt(this.getStyle("margin-bottom"), 10) || 0,
7178 right: parseInt(this.getStyle("margin-right"), 10) || 0
7181 return this.addStyles(B9, El.margins);
7186 addStyles : function(CA, CB){
7188 for(var i = 0, Ak = CA.length; i < Ak; i++){
7189 v = this.getStyle(CB[CA.charAt(i)]);
7191 w = parseInt(v, 10);
7200 createProxy : function(CD, CE, CF){
7202 CE = Roo.getDom(CE);
7207 CD = typeof CD == "object" ?
7208 CD : {tag : "div", cls: CD};
7209 var CG = Roo.DomHelper.append(CE, CD, true);
7211 CG.setBox(this.getBox());
7218 mask : function(CH, CI){
7219 if(this.getStyle("position") == "static"){
7220 this.setStyle("position", "relative");
7223 this._mask = Roo.DomHelper.append(this.dom, {cls:"roo-el-mask"}, true);
7226 this.addClass("x-masked");
7227 this._mask.setDisplayed(true);
7228 if(typeof CH == 'string'){
7230 this._maskMsg = Roo.DomHelper.append(this.dom, {cls:"roo-el-mask-msg", cn:{tag:'div'}}, true);
7232 var mm = this._maskMsg;
7233 mm.dom.className = CI ? "roo-el-mask-msg " + CI : "roo-el-mask-msg";
7234 mm.dom.firstChild.innerHTML = CH;
7235 mm.setDisplayed(true);
7238 if(Roo.isIE && !(Roo.isIE7 && Roo.isStrict) && this.getStyle('height') == 'auto'){
7239 this._mask.setHeight(this.getHeight());
7246 unmask : function(CJ){
7249 this._mask.remove();
7252 this._maskMsg.remove();
7253 delete this._maskMsg;
7256 this._mask.setDisplayed(false);
7258 this._maskMsg.setDisplayed(false);
7263 this.removeClass("x-masked");
7268 isMasked : function(){
7269 return this._mask && this._mask.isVisible();
7274 createShim : function(){
7275 var el = document.createElement('iframe');
7276 el.frameBorder = 'no';
7277 el.className = 'roo-shim';
7278 if(Roo.isIE && Roo.isSecure){
7279 el.src = Roo.SSL_SECURE_URL;
7281 var CK = Roo.get(this.dom.parentNode.insertBefore(el, this.dom));
7282 CK.autoBoxAdjust = false;
7288 remove : function(){
7289 if(this.dom.parentNode){
7290 this.dom.parentNode.removeChild(this.dom);
7292 delete El.cache[this.dom.id];
7297 addClassOnOver : function(CL, CM){
7298 this.on("mouseover", function(){
7299 Roo.fly(this, '_internal').addClass(CL);
7301 var CN = function(e){
7302 if(CM !== true || !e.within(this, true)){
7303 Roo.fly(this, '_internal').removeClass(CL);
7306 this.on("mouseout", CN, this.dom);
7312 addClassOnFocus : function(CO){
7313 this.on("focus", function(){
7314 Roo.fly(this, '_internal').addClass(CO);
7316 this.on("blur", function(){
7317 Roo.fly(this, '_internal').removeClass(CO);
7323 addClassOnClick : function(CP){
7325 this.on("mousedown", function(){
7326 Roo.fly(CQ, '_internal').addClass(CP);
7327 var d = Roo.get(document);
7328 var fn = function(){
7329 Roo.fly(CQ, '_internal').removeClass(CP);
7330 d.removeListener("mouseup", fn);
7332 d.on("mouseup", fn);
7339 swallowEvent : function(CR, CS){
7340 var fn = function(e){
7341 e.stopPropagation();
7346 if(CR instanceof Array){
7347 for(var i = 0, Ak = CR.length; i < Ak; i++){
7359 fitToParentDelegate : Roo.emptyFn,
7363 fitToParent : function(CT, CU) {
7364 Roo.EventManager.removeResizeListener(this.fitToParentDelegate);
7365 this.fitToParentDelegate = Roo.emptyFn;
7366 if (CT === true && !this.dom.parentNode) {
7369 var p = Roo.get(CU || this.dom.parentNode);
7370 this.setSize(p.getComputedWidth() - p.getFrameWidth('lr'), p.getComputedHeight() - p.getFrameWidth('tb'));
7372 this.fitToParentDelegate = this.fitToParent.createDelegate(this, [true, CU]);
7373 Roo.EventManager.onWindowResize(this.fitToParentDelegate);
7380 getNextSibling : function(){
7381 var n = this.dom.nextSibling;
7382 while(n && n.nodeType != 1){
7390 getPrevSibling : function(){
7391 var n = this.dom.previousSibling;
7392 while(n && n.nodeType != 1){
7393 n = n.previousSibling;
7401 appendChild: function(el){
7409 createChild: function(CV, CW, CX){
7410 CV = CV || {tag:'div'};
7412 return Roo.DomHelper.insertBefore(CW, CV, CX !== true);
7414 return Roo.DomHelper[!this.dom.firstChild ? 'overwrite' : 'append'](this.dom, CV, CX !== true);
7419 appendTo: function(el){
7420 el = Roo.getDom(el);
7421 el.appendChild(this.dom);
7427 insertBefore: function(el){
7428 el = Roo.getDom(el);
7429 el.parentNode.insertBefore(this.dom, el);
7435 insertAfter: function(el){
7436 el = Roo.getDom(el);
7437 el.parentNode.insertBefore(this.dom, el.nextSibling);
7443 insertFirst: function(el, CY){
7445 if(typeof el == 'object' && !el.nodeType){
7446 return this.createChild(el, this.dom.firstChild, CY);
7448 el = Roo.getDom(el);
7449 this.dom.insertBefore(el, this.dom.firstChild);
7450 return !CY ? Roo.get(el) : el;
7456 insertSibling: function(el, CZ, Ca){
7457 CZ = CZ ? CZ.toLowerCase() : 'before';
7459 var rt, Cb = CZ == 'before' ? this.dom : this.dom.nextSibling;
7461 if(typeof el == 'object' && !el.nodeType){
7462 if(CZ == 'after' && !this.dom.nextSibling){
7463 rt = Roo.DomHelper.append(this.dom.parentNode, el, !Ca);
7465 rt = Roo.DomHelper[CZ == 'after' ? 'insertAfter' : 'insertBefore'](this.dom, el, !Ca);
7469 rt = this.dom.parentNode.insertBefore(Roo.getDom(el),
7470 CZ == 'before' ? this.dom : this.dom.nextSibling);
7480 wrap: function(Cc, Cd){
7484 var Ce = Roo.DomHelper.insertBefore(this.dom, Cc, !Cd);
7485 Ce.dom ? Ce.dom.appendChild(this.dom) : Ce.appendChild(this.dom);
7491 replace: function(el){
7493 this.insertBefore(el);
7500 insertHtml : function(Cf, Cg, Ch){
7501 var el = Roo.DomHelper.insertHtml(Cf, this.dom, Cg);
7502 return Ch ? Roo.get(el) : el;
7507 set : function(o, Ci){
7509 Ci = typeof Ci == 'undefined' ? (el.setAttribute ? true : false) : Ci;
7511 if(attr == "style" || typeof o[attr] == "function") continue;
7513 el.className = o["cls"];
7515 if(Ci) el.setAttribute(attr, o[attr]);
7516 else el[attr] = o[attr];
7520 Roo.DomHelper.applyStyles(el, o.style);
7527 addKeyListener : function(Cj, fn, Ck){
7529 if(typeof Cj != "object" || Cj instanceof Array){
7545 return new Roo.KeyMap(this, Cl);
7550 addKeyMap : function(Cm){
7551 return new Roo.KeyMap(this, Cm);
7556 isScrollable : function(){
7558 return Cn.scrollHeight > Cn.clientHeight || Cn.scrollWidth > Cn.clientWidth;
7564 scrollTo : function(Co, Cp, Cq){
7565 var Cr = Co.toLowerCase() == "left" ? "scrollLeft" : "scrollTop";
7569 var to = Cr == "scrollLeft" ? [Cp, this.dom.scrollTop] : [this.dom.scrollLeft, Cp];
7570 this.anim({scroll: {"to": to}}, this.preanim(arguments, 2), 'scroll');
7577 scroll : function(Cs, Ct, Cu){
7578 if(!this.isScrollable()){
7582 var l = el.scrollLeft, t = el.scrollTop;
7583 var w = el.scrollWidth, h = el.scrollHeight;
7584 var cw = el.clientWidth, ch = el.clientHeight;
7585 Cs = Cs.toLowerCase();
7587 var a = this.preanim(arguments, 2);
7592 var v = Math.min(l + Ct, w-cw);
7593 this.scrollTo("left", v, a);
7600 var v = Math.max(l - Ct, 0);
7601 this.scrollTo("left", v, a);
7609 var v = Math.max(t - Ct, 0);
7610 this.scrollTo("top", v, a);
7618 var v = Math.min(t + Ct, h-ch);
7619 this.scrollTo("top", v, a);
7629 translatePoints : function(x, y){
7630 if(typeof x == 'object' || x instanceof Array){
7633 var p = this.getStyle('position');
7634 var o = this.getXY();
7636 var l = parseInt(this.getStyle('left'), 10);
7637 var t = parseInt(this.getStyle('top'), 10);
7640 l = (p == "relative") ? 0 : this.dom.offsetLeft;
7643 t = (p == "relative") ? 0 : this.dom.offsetTop;
7646 return {left: (x - o[0] + l), top: (y - o[1] + t)};
7651 getScroll : function(){
7652 var d = this.dom, Cw = document;
7653 if(d == Cw || d == Cw.body){
7654 var l = window.pageXOffset || Cw.documentElement.scrollLeft || Cw.body.scrollLeft || 0;
7655 var t = window.pageYOffset || Cw.documentElement.scrollTop || Cw.body.scrollTop || 0;
7656 return {left: l, top: t};
7658 return {left: d.scrollLeft, top: d.scrollTop};
7664 getColor : function(Cx, Cy, Cz){
7665 var v = this.getStyle(Cx);
7666 if(!v || v == "transparent" || v == "inherit") {
7669 var C0 = typeof Cz == "undefined" ? "#" : Cz;
7670 if(v.substr(0, 4) == "rgb("){
7671 var rvs = v.slice(4, v.length -1).split(",");
7672 for(var i = 0; i < 3; i++){
7673 var h = parseInt(rvs[i]).toString(16);
7681 if(v.substr(0, 1) == "#"){
7683 for(var i = 1; i < 4; i++){
7684 var c = v.charAt(i);
7687 }else if(v.length == 7){
7692 return (C0.length > 5 ? C0.toLowerCase() : Cy);
7697 boxWrap : function(C1){
7699 var el = Roo.get(this.insertHtml('beforeBegin', String.format('<div class="{0}">'+El.boxMarkup+'</div>', C1)));
7700 el.child('.'+C1+'-mc').dom.appendChild(this.dom);
7706 getAttributeNS : Roo.isIE ? function(ns, C2){
7708 var C3 = typeof d[ns+":"+C2];
7709 if(C3 != 'undefined' && C3 != 'unknown'){
7710 return d[ns+":"+C2];
7713 } : function(ns, C4){
7715 return d.getAttributeNS(ns, C4) || d.getAttribute(ns+":"+C4) || d.getAttribute(C4) || d[C4];
7719 var ep = El.prototype;
7723 ep.on = ep.addListener;
7725 ep.mon = ep.addListener;
7729 ep.un = ep.removeListener;
7733 ep.autoBoxAdjust = true;
7736 El.unitPattern = /\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i;
7739 El.addUnits = function(v, J){
7740 if(v === "" || v == "auto"){
7743 if(v === undefined){
7746 if(typeof v == "number" || !El.unitPattern.test(v)){
7747 return v + (J || 'px');
7753 El.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>';
7761 El.borders = {l: "border-left-width", r: "border-right-width", t: "border-top-width", b: "border-bottom-width"};
7762 El.paddings = {l: "padding-left", r: "padding-right", t: "padding-top", b: "padding-bottom"};
7763 El.margins = {l: "margin-left", r: "margin-right", t: "margin-top", b: "margin-bottom"};
7775 El.get = function(el){
7777 if(!el){ return null; }
7778 if(typeof el == "string"){
7779 if(!(J = document.getElementById(el))){
7782 if(ex = El.cache[el]){
7785 ex = El.cache[el] = new El(J);
7788 }else if(el.tagName){
7792 if(ex = El.cache[id]){
7795 ex = El.cache[id] = new El(el);
7798 }else if(el instanceof El){
7800 el.dom = document.getElementById(el.id) || el.dom;
7802 El.cache[el.id] = el;
7805 }else if(el.isComposite){
7807 }else if(el instanceof Array){
7808 return El.select(el);
7809 }else if(el == document){
7812 var f = function(){};
7813 f.prototype = El.prototype;
7823 El.uncache = function(el){
7824 for(var i = 0, a = arguments, len = a.length; i < len; i++) {
7826 delete El.cache[a[i].id || a[i]];
7834 El.garbageCollect = function(){
7835 if(!Roo.enableGarbageCollector){
7836 clearInterval(El.collectorThread);
7839 for(var eid in El.cache){
7840 var el = El.cache[eid], d = el.dom;
7858 if(!d || !d.parentNode || (!d.offsetParent && !document.getElementById(eid))){
7859 delete El.cache[eid];
7860 if(d && Roo.enableListenerCollection){
7867 El.collectorThreadId = setInterval(El.garbageCollect, 30000);
7871 El.Flyweight = function(J){
7874 El.Flyweight.prototype = El.prototype;
7876 El._flyweights = {};
7879 El.fly = function(el, J){
7881 el = Roo.getDom(el);
7885 if(!El._flyweights[J]){
7886 El._flyweights[J] = new El.Flyweight();
7889 El._flyweights[J].dom = el;
7890 return El._flyweights[J];
7901 var I = Roo.isStrict ? {
7904 input:1, select:1, textarea:1
7906 if(Roo.isIE || Roo.isGecko){
7912 Roo.EventManager.on(window, 'unload', function(){
7914 delete El._flyweights;
7922 Roo.Element.selectorFunction = Roo.DomQuery.select;
7926 Roo.Element.select = function(J, K, L){
7928 if(typeof J == "string"){
7929 M = Roo.Element.selectorFunction(J, L);
7930 }else if(J.length !== undefined){
7933 throw "Invalid selector";
7936 return new Roo.CompositeElement(M);
7938 return new Roo.CompositeElementLite(M);
7943 Roo.select = Roo.Element.select;
7965 Roo.enableFx = true;
7972 slideIn : function(A, o){
7973 var el = this.getFxEl();
7976 el.queueFx(o, function(){
7984 var r = this.getFxRestore();
7985 var b = this.getBox();
7990 var B = this.fxWrap(r.pos, o, "hidden");
7992 var st = this.dom.style;
7993 st.visibility = "visible";
7994 st.position = "absolute";
7998 el.fxUnwrap(B, r.pos, o);
8000 st.height = r.height;
8004 var a, pt = {to: [b.x, b.y]}, bw = {to: b.width}, bh = {to: b.height};
8006 switch(A.toLowerCase()){
8008 B.setSize(b.width, 0);
8009 st.left = st.bottom = "0";
8013 B.setSize(0, b.height);
8014 st.right = st.top = "0";
8018 B.setSize(0, b.height);
8020 st.left = st.top = "0";
8021 a = {width: bw, points: pt};
8024 B.setSize(b.width, 0);
8026 st.left = st.top = "0";
8027 a = {height: bh, points: pt};
8031 st.right = st.bottom = "0";
8032 a = {width: bw, height: bh};
8036 B.setY(b.y+b.height);
8037 st.right = st.top = "0";
8038 a = {width: bw, height: bh, points: pt};
8042 B.setXY([b.right, b.bottom]);
8043 st.left = st.top = "0";
8044 a = {width: bw, height: bh, points: pt};
8048 B.setX(b.x+b.width);
8049 st.left = st.bottom = "0";
8050 a = {width: bw, height: bh, points: pt};
8054 this.dom.style.visibility = "visible";
8057 arguments.callee.anim = B.fxanim(a,
8068 slideOut : function(B, o){
8069 var el = this.getFxEl();
8072 el.queueFx(o, function(){
8077 var r = this.getFxRestore();
8079 var b = this.getBox();
8084 var C = this.fxWrap(r.pos, o, "visible");
8086 var st = this.dom.style;
8087 st.visibility = "visible";
8088 st.position = "absolute";
8094 el.setDisplayed(false);
8100 el.fxUnwrap(C, r.pos, o);
8103 st.height = r.height;
8109 switch(B.toLowerCase()){
8111 st.left = st.bottom = "0";
8115 st.right = st.top = "0";
8119 st.left = st.top = "0";
8120 a = {width: E, points: {to:[b.right, b.y]}};
8123 st.left = st.top = "0";
8124 a = {height: E, points: {to:[b.x, b.bottom]}};
8127 st.right = st.bottom = "0";
8128 a = {width: E, height: E};
8131 st.right = st.top = "0";
8132 a = {width: E, height: E, points: {to:[b.x, b.bottom]}};
8135 st.left = st.top = "0";
8136 a = {width: E, height: E, points: {to:[b.x+b.width, b.bottom]}};
8139 st.left = st.bottom = "0";
8140 a = {width: E, height: E, points: {to:[b.right, b.y]}};
8145 arguments.callee.anim = C.fxanim(a,
8157 var el = this.getFxEl();
8160 el.queueFx(o, function(){
8161 this.clearOpacity();
8165 var r = this.getFxRestore();
8166 var st = this.dom.style;
8170 el.setDisplayed(false);
8178 el.setPositioning(r.pos);
8180 st.height = r.height;
8185 var D = this.getWidth();
8186 var E = this.getHeight();
8188 arguments.callee.anim = this.fxanim({
8189 width : {to: this.adjustWidth(D * 2)},
8190 height : {to: this.adjustHeight(E * 2)},
8191 points : {by: [-(D * .5), -(E * .5)]},
8193 fontSize: {to:200, unit: "%"}
8205 switchOff : function(o){
8206 var el = this.getFxEl();
8209 el.queueFx(o, function(){
8210 this.clearOpacity();
8214 var r = this.getFxRestore();
8215 var st = this.dom.style;
8219 el.setDisplayed(false);
8226 el.setPositioning(r.pos);
8228 st.height = r.height;
8233 this.fxanim({opacity:{to:0.3}}, null, null, .1, null, function(){
8234 this.clearOpacity();
8238 points:{by:[0, this.getHeight() * .5]}
8239 }, o, 'motion', 0.3, 'easeIn', C);
8240 }).defer(100, this);
8248 highlight : function(C, o){
8249 var el = this.getFxEl();
8252 el.queueFx(o, function(){
8254 attr = o.attr || "backgroundColor";
8256 this.clearOpacity();
8259 var D = this.getColor(attr);
8260 var E = this.dom.style[attr];
8261 endColor = (o.endColor || D) || "ffffff";
8264 el.dom.style[attr] = E;
8269 a[attr] = {from: C, to: endColor};
8270 arguments.callee.anim = this.fxanim(a,
8281 frame : function(D, E, o){
8282 var el = this.getFxEl();
8285 el.queueFx(o, function(){
8292 duration = o.duration || 1;
8295 var b = this.getBox();
8297 var G = this.createProxy({
8301 position:"absolute",
8303 border:"0px solid " + D
8306 var H = Roo.isBorderBox ? 2 : 1;
8308 top:{from:b.y, to:b.y - 20},
8309 left:{from:b.x, to:b.x - 20},
8310 borderWidth:{from:0, to:10},
8311 opacity:{from:1, to:0},
8312 height:{from:b.height, to:(b.height + (20*H))},
8313 width:{from:b.width, to:(b.width + (20*H))}
8314 }, duration, function(){
8318 F.defer((duration/2)*1000, this);
8330 pause : function(F){
8331 var el = this.getFxEl();
8334 el.queueFx(o, function(){
8335 setTimeout(function(){
8344 fadeIn : function(o){
8345 var el = this.getFxEl();
8347 el.queueFx(o, function(){
8350 this.dom.style.visibility = 'visible';
8351 var to = o.endOpacity || 1;
8352 arguments.callee.anim = this.fxanim({opacity:{to:to}},
8353 o, null, .5, "easeOut", function(){
8355 this.clearOpacity();
8366 fadeOut : function(o){
8367 var el = this.getFxEl();
8369 el.queueFx(o, function(){
8370 arguments.callee.anim = this.fxanim({opacity:{to:o.endOpacity || 0}},
8371 o, null, .5, "easeOut", function(){
8372 if(this.visibilityMode == Roo.Element.DISPLAY || o.useDisplay){
8373 this.dom.style.display = "none";
8375 this.dom.style.visibility = "hidden";
8378 this.clearOpacity();
8387 scale : function(w, h, o){
8388 this.shift(Roo.apply({}, o, {
8397 shift : function(o){
8398 var el = this.getFxEl();
8400 el.queueFx(o, function(){
8401 var a = {}, w = o.width, h = o.height, x = o.x, y = o.y, op = o.opacity;
8402 if(w !== undefined){
8403 a.width = {to: this.adjustWidth(w)};
8405 if(h !== undefined){
8406 a.height = {to: this.adjustHeight(h)};
8408 if(x !== undefined || y !== undefined){
8410 x !== undefined ? x : this.getX(),
8411 y !== undefined ? y : this.getY()
8414 if(op !== undefined){
8415 a.opacity = {to: op};
8417 if(o.xy !== undefined){
8418 a.points = {to: o.xy};
8421 arguments.callee.anim = this.fxanim(a,
8422 o, 'motion', .35, "easeOut", function(){
8431 ghost : function(G, o){
8432 var el = this.getFxEl();
8435 el.queueFx(o, function(){
8439 var r = this.getFxRestore();
8440 var w = this.getWidth(),
8441 h = this.getHeight();
8443 var st = this.dom.style;
8447 el.setDisplayed(false);
8454 el.setPositioning(r.pos);
8456 st.height = r.height;
8461 var a = {opacity: {to: 0}, points: {}}, pt = a.points;
8462 switch(G.toLowerCase()){
8490 arguments.callee.anim = this.fxanim(a,
8501 syncFx : function(){
8502 this.fxDefaults = Roo.apply(this.fxDefaults || {}, {
8512 sequenceFx : function(){
8513 this.fxDefaults = Roo.apply(this.fxDefaults || {}, {
8523 nextFx : function(){
8524 var ef = this.fxQueue[0];
8532 hasActiveFx : function(){
8533 return this.fxQueue && this.fxQueue[0];
8538 stopFx : function(){
8539 if(this.hasActiveFx()){
8540 var cur = this.fxQueue[0];
8541 if(cur && cur.anim && cur.anim.isAnimated()){
8542 this.fxQueue = [cur];
8543 cur.anim.stop(true);
8551 beforeFx : function(o){
8552 if(this.hasActiveFx() && !o.concurrent){
8564 hasFxBlock : function(){
8565 var q = this.fxQueue;
8566 return q && q[0] && q[0].block;
8571 queueFx : function(o, fn){
8575 if(!this.hasFxBlock()){
8576 Roo.applyIf(o, this.fxDefaults);
8578 var run = this.beforeFx(o);
8580 this.fxQueue.push(fn);
8593 fxWrap : function(H, o, I){
8595 if(!o.wrap || !(J = Roo.get(o.wrap))){
8598 wrapXY = this.getXY();
8600 var div = document.createElement("div");
8601 div.style.visibility = I;
8602 J = Roo.get(this.dom.parentNode.insertBefore(div, this.dom));
8603 J.setPositioning(H);
8604 if(J.getStyle("position") == "static"){
8605 J.position("relative");
8608 this.clearPositioning('auto');
8610 J.dom.appendChild(this.dom);
8620 fxUnwrap : function(K, L, o){
8621 this.clearPositioning();
8622 this.setPositioning(L);
8624 K.dom.parentNode.insertBefore(this.dom, K.dom);
8631 getFxRestore : function(){
8632 var st = this.dom.style;
8633 return {pos: this.getPositioning(), width: st.width, height : st.height};
8638 afterFx : function(o){
8640 this.applyStyles(o.afterStyle);
8643 this.addClass(o.afterCls);
8645 if(o.remove === true){
8649 Roo.callback(o.callback, o.scope, [this]);
8651 this.fxQueue.shift();
8658 getFxEl : function(){
8659 return Roo.get(this.dom);
8664 fxanim : function(M, N, O, P, Q, cb){
8667 var R = Roo.lib.Anim[O](
8669 (N.duration || P) || .35,
8670 (N.easing || Q) || 'easeOut',
8672 Roo.callback(cb, this);
8682 Roo.Fx.resize = Roo.Fx.scale;
8686 Roo.apply(Roo.Element.prototype, Roo.Fx);
8693 Roo.CompositeElement = function(A){
8695 this.addElements(A);
8697 Roo.CompositeElement.prototype = {
8699 addElements : function(B){
8701 if(typeof B == "string"){
8702 B = Roo.Element.selectorFunction(B);
8704 var C = this.elements;
8706 for(var i = 0, len = B.length; i < len; i++) {
8707 C[++D] = Roo.get(B[i]);
8722 filter : function(F){
8724 this.each(function(el){
8726 G[G.length] = el.dom;
8733 invoke : function(fn, H){
8734 var I = this.elements;
8735 for(var i = 0, len = I.length; i < len; i++) {
8736 Roo.Element.prototype[fn].apply(I[i], H);
8743 if(typeof J == "string"){
8744 this.addElements(Roo.Element.selectorFunction(J));
8745 }else if(J.length !== undefined){
8746 this.addElements(J);
8748 this.addElements([J]);
8754 each : function(fn, K){
8755 var L = this.elements;
8756 for(var i = 0, len = L.length; i < len; i++){
8757 if(fn.call(K || L[i], L[i], this, i) === false) {
8767 return this.elements[M] || null;
8773 return this.item(0);
8779 return this.item(this.elements.length-1);
8784 getCount : function(){
8785 return this.elements.length;
8790 contains : function(el){
8791 return this.indexOf(el) !== -1;
8796 indexOf : function(el){
8797 return this.elements.indexOf(Roo.get(el));
8803 removeElement : function(el, N){
8804 if(el instanceof Array){
8805 for(var i = 0, len = el.length; i < len; i++){
8806 this.removeElement(el[i]);
8810 var O = typeof el == 'number' ? el : this.indexOf(el);
8813 var d = this.elements[O];
8817 d.parentNode.removeChild(d);
8821 this.elements.splice(O, 1);
8828 replaceElement : function(el, P, Q){
8829 var R = typeof el == 'number' ? el : this.indexOf(el);
8832 this.elements[R].replaceWith(P);
8834 this.elements.splice(R, 1, Roo.get(P))
8847 Roo.CompositeElement.createCall = function(S, T){
8850 return this.invoke(T, arguments);
8854 for(var fnName in Roo.Element.prototype){
8855 if(typeof Roo.Element.prototype[fnName] == "function"){
8856 Roo.CompositeElement.createCall(Roo.CompositeElement.prototype, fnName);
8866 Roo.CompositeElementLite = function(A){
8867 Roo.CompositeElementLite.superclass.constructor.call(this, A);
8868 this.el = new Roo.Element.Flyweight();
8870 Roo.extend(Roo.CompositeElementLite, Roo.CompositeElement, {
8871 addElements : function(B){
8873 if(B instanceof Array){
8874 this.elements = this.elements.concat(B);
8876 var yels = this.elements;
8877 var index = yels.length-1;
8878 for(var i = 0, len = B.length; i < len; i++) {
8879 yels[++index] = B[i];
8885 invoke : function(fn, C){
8886 var D = this.elements;
8888 for(var i = 0, len = D.length; i < len; i++) {
8890 Roo.Element.prototype[fn].apply(el, C);
8897 if(!this.elements[E]){
8901 this.el.dom = this.elements[E];
8906 addListener : function(F, G, H, I){
8907 var J = this.elements;
8908 for(var i = 0, len = J.length; i < len; i++) {
8909 Roo.EventManager.on(J[i], F, G, H || J[i], I);
8916 each : function(fn, K){
8917 var L = this.elements;
8919 for(var i = 0, len = L.length; i < len; i++){
8921 if(fn.call(K || el, el, this, i) === false){
8928 indexOf : function(el){
8929 return this.elements.indexOf(Roo.getDom(el));
8932 replaceElement : function(el, M, N){
8933 var O = typeof el == 'number' ? el : this.indexOf(el);
8937 var d = this.elements[O];
8938 d.parentNode.insertBefore(M, d);
8939 d.parentNode.removeChild(d);
8942 this.elements.splice(O, 1, M);
8947 Roo.CompositeElementLite.prototype.on = Roo.CompositeElementLite.prototype.addListener;
8957 Roo.data.Connection = function(A){
8962 "beforerequest" : true,
8965 "requestcomplete" : true,
8968 "requestexception" : true
8970 Roo.data.Connection.superclass.constructor.call(this);
8973 Roo.extend(Roo.data.Connection, Roo.util.Observable, {
8991 disableCaching: true,
8995 request : function(o){
8996 if(this.fireEvent("beforerequest", this, o) !== false){
8999 if(typeof p == "function"){
9000 p = p.call(o.scope||window, o);
9002 if(typeof p == "object"){
9003 p = Roo.urlEncode(o.params);
9005 if(this.extraParams){
9006 var extras = Roo.urlEncode(this.extraParams);
9007 p = p ? (p + '&' + extras) : extras;
9010 var url = o.url || this.url;
9011 if(typeof url == 'function'){
9012 url = url.call(o.scope||window, o);
9016 var form = Roo.getDom(o.form);
9017 url = url || form.action;
9019 var enctype = form.getAttribute("enctype");
9020 if(o.isUpload || (enctype && enctype.toLowerCase() == 'multipart/form-data')){
9021 return this.doFormUpload(o, p, url);
9023 var f = Roo.lib.Ajax.serializeForm(form);
9024 p = p ? (p + '&' + f) : f;
9028 if(this.defaultHeaders){
9029 hs = Roo.apply(hs || {}, this.defaultHeaders);
9036 success: this.handleResponse,
9037 failure: this.handleFailure,
9039 argument: {options: o},
9040 timeout : this.timeout
9043 var method = o.method||this.method||(p ? "POST" : "GET");
9045 if(method == 'GET' && (this.disableCaching && o.disableCaching !== false) || o.disableCaching === true){
9046 url += (url.indexOf('?') != -1 ? '&' : '?') + '_dc=' + (new Date().getTime());
9049 if(typeof o.autoAbort == 'boolean'){
9053 }else if(this.autoAbort !== false){
9057 if((method == 'GET' && p) || o.xmlData){
9058 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
9062 this.transId = Roo.lib.Ajax.request(method, url, cb, p, o);
9063 return this.transId;
9065 Roo.callback(o.callback, o.scope, [o, null, null]);
9072 isLoading : function(B){
9074 return Roo.lib.Ajax.isCallInProgress(B);
9076 return this.transId ? true : false;
9082 abort : function(C){
9083 if(C || this.isLoading()){
9084 Roo.lib.Ajax.abort(C || this.transId);
9089 handleResponse : function(D){
9090 this.transId = false;
9091 var E = D.argument.options;
9092 D.argument = E ? E.argument : null;
9093 this.fireEvent("requestcomplete", this, D, E);
9094 Roo.callback(E.success, E.scope, [D, E]);
9095 Roo.callback(E.callback, E.scope, [E, true, D]);
9099 handleFailure : function(F, e){
9100 this.transId = false;
9101 var G = F.argument.options;
9102 F.argument = G ? G.argument : null;
9103 this.fireEvent("requestexception", this, F, G, e);
9104 Roo.callback(G.failure, G.scope, [F, G]);
9105 Roo.callback(G.callback, G.scope, [G, false, F]);
9109 doFormUpload : function(o, ps, H){
9111 var I = document.createElement('iframe');
9114 I.className = 'x-hidden';
9116 I.src = Roo.SSL_SECURE_URL;
9119 document.body.appendChild(I);
9122 document.frames[id].name = id;
9125 var J = Roo.getDom(o.form);
9128 J.enctype = J.encoding = 'multipart/form-data';
9136 ps = Roo.urlDecode(ps, false);
9138 if(ps.hasOwnProperty(k)){
9139 hd = document.createElement('input');
9155 r.argument = o ? o.argument : null;
9160 doc = I.contentWindow.document;
9162 doc = (I.contentDocument || window.frames[id].document);
9164 if(doc && doc.body){
9165 r.responseText = doc.body.innerHTML;
9167 if(doc && doc.XMLDocument){
9168 r.responseXML = doc.XMLDocument;
9170 r.responseXML = doc;
9178 Roo.EventManager.removeListener(I, 'load', cb, this);
9180 this.fireEvent("requestcomplete", this, r, o);
9181 Roo.callback(o.success, o.scope, [r, o]);
9182 Roo.callback(o.callback, o.scope, [o, true, r]);
9184 setTimeout(function(){document.body.removeChild(I);}, 100);
9188 Roo.EventManager.on(I, 'load', cb, this);
9192 for(var i = 0, len = K.length; i < len; i++){
9193 J.removeChild(K[i]);
9201 Roo.Ajax = new Roo.data.Connection({
9238 serializeForm : function(L){
9239 return Roo.lib.Ajax.serializeForm(L);
9247 Roo.Ajax = new Roo.data.Connection({
9288 serializeForm : function(A){
9289 return Roo.lib.Ajax.serializeForm(A);
9298 Roo.UpdateManager = function(el, A){
9300 if(!A && el.updateManager){
9301 return el.updateManager;
9309 this.defaultUrl = null;
9314 "beforeupdate": true,
9322 var d = Roo.UpdateManager.defaults;
9325 this.sslBlankUrl = d.sslBlankUrl;
9328 this.disableCaching = d.disableCaching;
9331 this.indicatorText = d.indicatorText;
9334 this.showLoadIndicator = d.showLoadIndicator;
9337 this.timeout = d.timeout;
9341 this.loadScripts = d.loadScripts;
9345 this.transaction = null;
9349 this.autoRefreshProcId = null;
9352 this.refreshDelegate = this.refresh.createDelegate(this);
9355 this.updateDelegate = this.update.createDelegate(this);
9358 this.formUpdateDelegate = this.formUpdate.createDelegate(this);
9361 this.successDelegate = this.processSuccess.createDelegate(this);
9364 this.failureDelegate = this.processFailure.createDelegate(this);
9369 this.renderer = new Roo.UpdateManager.BasicRenderer();
9373 Roo.UpdateManager.superclass.constructor.call(this);
9376 Roo.extend(Roo.UpdateManager, Roo.util.Observable, {
9384 update : function(B, C, D, E){
9385 if(this.fireEvent("beforeupdate", this.el, B, C) !== false){
9386 var method = this.method, cfg;
9387 if(typeof B == "object"){
9390 C = C || cfg.params;
9391 D = D || cfg.callback;
9392 E = E || cfg.discardUrl;
9394 D = D.createDelegate(cfg.scope);
9396 if(typeof cfg.method != "undefined"){method = cfg.method;};
9397 if(typeof cfg.nocache != "undefined"){this.disableCaching = cfg.nocache;};
9398 if(typeof cfg.text != "undefined"){this.indicatorText = '<div class="loading-indicator">'+cfg.text+"</div>";};
9399 if(typeof cfg.scripts != "undefined"){this.loadScripts = cfg.scripts;};
9400 if(typeof cfg.timeout != "undefined"){this.timeout = cfg.timeout;};
9405 this.defaultUrl = B;
9407 if(typeof B == "function"){
9412 method = method || (C ? "POST" : "GET");
9413 if(method == "GET"){
9414 B = this.prepareUrl(B);
9417 var o = Roo.apply(cfg ||{}, {
9420 success: this.successDelegate,
9421 failure: this.failureDelegate,
9422 callback: undefined,
9423 timeout: (this.timeout*1000),
9424 argument: {"url": B, "form": null, "callback": D, "params": C}
9427 this.transaction = Roo.Ajax.request(o);
9433 formUpdate : function(F, G, H, I){
9434 if(this.fireEvent("beforeupdate", this.el, F, G) !== false){
9435 if(typeof G == "function"){
9440 this.transaction = Roo.Ajax.request({
9443 success: this.successDelegate,
9444 failure: this.failureDelegate,
9445 timeout: (this.timeout*1000),
9446 argument: {"url": G, "form": F, "callback": I, "reset": H}
9448 this.showLoading.defer(1, this);
9454 refresh : function(J){
9455 if(this.defaultUrl == null){
9459 this.update(this.defaultUrl, null, J, true);
9464 startAutoRefresh : function(K, L, M, N, O){
9466 this.update(L || this.defaultUrl, M, N, true);
9468 if(this.autoRefreshProcId){
9469 clearInterval(this.autoRefreshProcId);
9472 this.autoRefreshProcId = setInterval(this.update.createDelegate(this, [L || this.defaultUrl, M, N, true]), K*1000);
9477 stopAutoRefresh : function(){
9478 if(this.autoRefreshProcId){
9479 clearInterval(this.autoRefreshProcId);
9480 delete this.autoRefreshProcId;
9484 isAutoRefreshing : function(){
9485 return this.autoRefreshProcId ? true : false;
9489 showLoading : function(){
9490 if(this.showLoadIndicator){
9491 this.el.update(this.indicatorText);
9497 prepareUrl : function(P){
9498 if(this.disableCaching){
9499 var append = "_dc=" + (new Date().getTime());
9500 if(P.indexOf("?") !== -1){
9511 processSuccess : function(Q){
9512 this.transaction = null;
9513 if(Q.argument.form && Q.argument.reset){
9515 Q.argument.form.reset();
9518 if(this.loadScripts){
9519 this.renderer.render(this.el, Q, this,
9520 this.updateComplete.createDelegate(this, [Q]));
9522 this.renderer.render(this.el, Q, this);
9523 this.updateComplete(Q);
9527 updateComplete : function(R){
9528 this.fireEvent("update", this.el, R);
9529 if(typeof R.argument.callback == "function"){
9530 R.argument.callback(this.el, true, R);
9536 processFailure : function(S){
9537 this.transaction = null;
9538 this.fireEvent("failure", this.el, S);
9539 if(typeof S.argument.callback == "function"){
9540 S.argument.callback(this.el, false, S);
9546 setRenderer : function(T){
9550 getRenderer : function(){
9551 return this.renderer;
9556 setDefaultUrl : function(U){
9557 this.defaultUrl = U;
9563 if(this.transaction){
9564 Roo.Ajax.abort(this.transaction);
9570 isUpdating : function(){
9571 if(this.transaction){
9572 return Roo.Ajax.isLoading(this.transaction);
9580 Roo.UpdateManager.defaults = {
9587 loadScripts : false,
9591 sslBlankUrl : (Roo.SSL_SECURE_URL || "javascript:false"),
9594 disableCaching : false,
9597 showLoadIndicator : true,
9600 indicatorText : '<div class="loading-indicator">Loading...</div>'
9605 Roo.UpdateManager.updateElement = function(el, V, W, X){
9606 var um = Roo.get(el, true).getUpdateManager();
9608 um.update(V, W, X ? X.callback : null);
9611 Roo.UpdateManager.update = Roo.UpdateManager.updateElement;
9614 Roo.UpdateManager.BasicRenderer = function(){};
9616 Roo.UpdateManager.BasicRenderer.prototype = {
9619 render : function(el, Y, Z, a){
9620 el.update(Y.responseText, Z.loadScripts, a);
9629 Roo.util.DelayedTask = function(fn, A, B){
9630 var id = null, d, t;
9633 var D = new Date().getTime();
9637 fn.apply(A, B || []);
9642 this.delay = function(D, E, F, G){
9648 t = new Date().getTime();
9653 id = setInterval(C, d);
9659 this.cancel = function(){
9670 Roo.util.TaskRunner = function(A){
9685 id = setInterval(H, A);
9689 var G = function(I){
9698 for(var i = 0, len = C.length; i < len; i++){
9708 var I = new Date().getTime();
9709 for(var i = 0, len = B.length; i < len; ++i){
9711 var itime = I - t.taskRunTime;
9712 if(t.interval <= itime){
9713 var rt = t.run.apply(t.scope || t, t.args || [++t.taskRunCount]);
9715 if(rt === false || t.taskRunCount === t.repeat){
9720 if(t.duration && t.duration <= (I - t.taskStartTime)){
9728 this.start = function(I){
9730 I.taskStartTime = new Date().getTime();
9737 this.stop = function(I){
9742 this.stopAll = function(){
9744 for(var i = 0, len = B.length; i < len; i++){
9755 Roo.TaskMgr = new Roo.util.TaskRunner();
9762 Roo.util.MixedCollection = function(A, B){
9782 this.allowFunctions = A === true;
9787 Roo.util.MixedCollection.superclass.constructor.call(this);
9790 Roo.extend(Roo.util.MixedCollection, Roo.util.Observable, {
9791 allowFunctions : false,
9795 add : function(C, o){
9796 if(arguments.length == 1){
9800 if(typeof C == "undefined" || C === null){
9803 this.keys.push(null);
9805 var old = this.map[C];
9807 return this.replace(C, o);
9816 this.fireEvent("add", this.length-1, o, C);
9822 getKey : function(o){
9828 replace : function(D, o){
9829 if(arguments.length == 1){
9833 var E = this.item(D);
9834 if(typeof D == "undefined" || D === null || typeof E == "undefined"){
9835 return this.add(D, o);
9837 var F = this.indexOfKey(D);
9840 this.fireEvent("replace", D, E, o);
9846 addAll : function(G){
9847 if(arguments.length > 1 || G instanceof Array){
9848 var args = arguments.length > 1 ? arguments : G;
9849 for(var i = 0, len = args.length; i < len; i++){
9854 if(this.allowFunctions || typeof G[D] != "function"){
9863 each : function(fn, H){
9864 var I = [].concat(this.items);
9865 for(var i = 0, len = I.length; i < len; i++){
9866 if(fn.call(H || I[i], I[i], i, len) === false){
9874 eachKey : function(fn, J){
9875 for(var i = 0, len = this.keys.length; i < len; i++){
9876 fn.call(J || window, this.keys[i], this.items[i], i, len);
9882 find : function(fn, K){
9883 for(var i = 0, len = this.items.length; i < len; i++){
9884 if(fn.call(K || window, this.items[i], this.keys[i])){
9885 return this.items[i];
9893 insert : function(L, M, o){
9894 if(arguments.length == 2){
9898 if(L >= this.length){
9899 return this.add(M, o);
9903 this.items.splice(L, 0, o);
9904 if(typeof M != "undefined" && M != null){
9908 this.keys.splice(L, 0, M);
9909 this.fireEvent("add", L, o, M);
9915 remove : function(o){
9916 return this.removeAt(this.indexOf(o));
9921 removeAt : function(N){
9922 if(N < this.length && N >= 0){
9924 var o = this.items[N];
9925 this.items.splice(N, 1);
9926 var M = this.keys[N];
9927 if(typeof M != "undefined"){
9931 this.keys.splice(N, 1);
9932 this.fireEvent("remove", o, M);
9938 removeKey : function(O){
9939 return this.removeAt(this.indexOfKey(O));
9944 getCount : function(){
9950 indexOf : function(o){
9951 if(!this.items.indexOf){
9952 for(var i = 0, len = this.items.length; i < len; i++){
9953 if(this.items[i] == o) return i;
9957 return this.items.indexOf(o);
9963 indexOfKey : function(P){
9964 if(!this.keys.indexOf){
9965 for(var i = 0, len = this.keys.length; i < len; i++){
9966 if(this.keys[i] == P) return i;
9970 return this.keys.indexOf(P);
9977 var R = typeof this.map[Q] != "undefined" ? this.map[Q] : this.items[Q];
9978 return typeof R != 'function' || this.allowFunctions ? R : null;
9983 itemAt : function(S){
9984 return this.items[S];
9995 contains : function(o){
9996 return this.indexOf(o) != -1;
10001 containsKey : function(U){
10002 return typeof this.map[U] != "undefined";
10007 clear : function(){
10012 this.fireEvent("clear");
10017 first : function(){
10018 return this.items[0];
10024 return this.items[this.length-1];
10027 _sort : function(V, W, fn){
10028 var X = String(W).toUpperCase() == "DESC" ? -1 : 1;
10029 fn = fn || function(a, b){
10032 var c = [], k = this.keys, Y = this.items;
10033 for(var i = 0, len = Y.length; i < len; i++){
10034 c[c.length] = {key: k[i], value: Y[i], index: i};
10037 c.sort(function(a, b){
10038 var v = fn(a[V], b[V]) * X;
10040 v = (a.index < b.index ? -1 : 1);
10044 for(var i = 0, len = c.length; i < len; i++){
10049 this.fireEvent("sort", this);
10054 sort : function(Z, fn){
10055 this._sort("value", Z, fn);
10060 keySort : function(a, fn){
10061 this._sort("key", a, fn || function(a, b){
10062 return String(a).toUpperCase()-String(b).toUpperCase();
10068 getRange : function(b, d){
10069 var e = this.items;
10075 d = Math.min(typeof d == "undefined" ? this.length-1 : d, this.length-1);
10078 for(var i = b; i <= d; i++) {
10079 r[r.length] = e[i];
10082 for(var i = b; i >= d; i--) {
10083 r[r.length] = e[i];
10091 filter : function(f, g){
10095 return this.clone();
10098 g = new RegExp("^" + Roo.escapeRe(g), "i");
10100 return this.filterBy(function(o){
10101 return o && g.test(o[f]);
10107 filterBy : function(fn, h){
10108 var r = new Roo.util.MixedCollection();
10109 r.getKey = this.getKey;
10110 var k = this.keys, it = this.items;
10111 for(var i = 0, len = it.length; i < len; i++){
10112 if(fn.call(h||this, it[i], k[i])){
10113 r.add(k[i], it[i]);
10121 clone : function(){
10122 var r = new Roo.util.MixedCollection();
10123 var k = this.keys, it = this.items;
10124 for(var i = 0, len = it.length; i < len; i++){
10125 r.add(k[i], it[i]);
10128 r.getKey = this.getKey;
10134 Roo.util.MixedCollection.prototype.get = Roo.util.MixedCollection.prototype.item;
10139 Roo.util.JSON = new (function(){
10140 var useHasOwn = {}.hasOwnProperty ? true : false;
10145 var pad = function(n) {
10146 return n < 10 ? "0" + n : n;
10159 var encodeString = function(s){
10160 if (/["\\\x00-\x1f]/.test(s)) {
10161 return '"' + s.replace(/([\x00-\x1f\\"])/g, function(a, b) {
10167 c = b.charCodeAt();
10169 Math.floor(c / 16).toString(16) +
10170 (c % 16).toString(16);
10173 return '"' + s + '"';
10176 var encodeArray = function(o){
10177 var a = ["["], b, i, l = o.length, v;
10178 for (i = 0; i < l; i += 1) {
10180 switch (typeof v) {
10190 a.push(v === null ? "null" : Roo.util.JSON.encode(v));
10199 var encodeDate = function(o){
10200 return '"' + o.getFullYear() + "-" +
10201 pad(o.getMonth() + 1) + "-" +
10202 pad(o.getDate()) + "T" +
10203 pad(o.getHours()) + ":" +
10204 pad(o.getMinutes()) + ":" +
10205 pad(o.getSeconds()) + '"';
10210 this.encode = function(o){
10211 if(typeof o == "undefined" || o === null){
10213 }else if(o instanceof Array){
10214 return encodeArray(o);
10215 }else if(o instanceof Date){
10216 return encodeDate(o);
10217 }else if(typeof o == "string"){
10218 return encodeString(o);
10219 }else if(typeof o == "number"){
10220 return isFinite(o) ? String(o) : "null";
10221 }else if(typeof o == "boolean"){
10224 var a = ["{"], b, i, v;
10226 if(!useHasOwn || o.hasOwnProperty(i)) {
10228 switch (typeof v) {
10238 a.push(this.encode(i), ":",
10239 v === null ? "null" : this.encode(v));
10252 this.decode = function(json){
10255 return eval("(" + json + ')');
10260 Roo.encode = Roo.util.JSON.encode;
10263 Roo.decode = Roo.util.JSON.decode;
10270 Roo.util.Format = function(){
10271 var A = /^\s+|\s+$/g;
10275 ellipsis : function(R, S){
10276 if(R && R.length > S){
10277 return R.substr(0, S-3)+"...";
10284 undef : function(T){
10285 return typeof T != "undefined" ? T : "";
10290 htmlEncode : function(U){
10291 return !U ? U : String(U).replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, """);
10296 htmlDecode : function(V){
10297 return !V ? V : String(V).replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, '"');
10302 trim : function(W){
10303 return String(W).replace(A, "");
10308 substr : function(X, Y, Z){
10309 return String(X).substr(Y, Z);
10314 lowercase : function(a){
10315 return String(a).toLowerCase();
10320 uppercase : function(b){
10321 return String(b).toUpperCase();
10326 capitalize : function(c){
10327 return !c ? c : c.charAt(0).toUpperCase() + c.substr(1).toLowerCase();
10331 call : function(value, fn){
10332 if(arguments.length > 2){
10333 var args = Array.prototype.slice.call(arguments, 2);
10334 args.unshift(value);
10337 eval(fn).apply(window, args);
10342 eval(fn).call(window, value);
10348 usMoney : function(v){
10349 v = (Math.round((v-0)*100))/100;
10350 v = (v == Math.floor(v)) ? v + ".00" : ((v*10 == Math.floor(v*10)) ? v + "0" : v);
10352 var ps = v.split('.');
10354 var e = ps[1] ? '.'+ ps[1] : '.00';
10355 var r = /(\d+)(\d{3})/;
10356 while (r.test(d)) {
10357 d = d.replace(r, '$1' + ',' + '$2');
10359 return "$" + d + e ;
10364 date : function(v, f){
10368 if(!(v instanceof Date)){
10369 v = new Date(Date.parse(v));
10371 return v.dateFormat(f || "m/d/Y");
10376 dateRenderer : function(g){
10377 return function(v){
10378 return Roo.util.Format.date(v, g);
10383 stripTagsRE : /<\/?[^>]+>/gi,
10387 stripTags : function(v){
10388 return !v ? v : String(v).replace(this.stripTagsRE, "");
10400 Roo.MasterTemplate = function(){
10401 Roo.MasterTemplate.superclass.constructor.apply(this, arguments);
10402 this.originalHtml = this.html;
10404 var m, re = this.subTemplateRe;
10407 while(m = re.exec(this.html)){
10408 var name = m[1], content = m[2];
10413 tpl : new Roo.Template(content)
10419 st[A].tpl.compile();
10420 st[A].tpl.call = this.call.createDelegate(this);
10427 Roo.extend(Roo.MasterTemplate, Roo.Template, {
10430 subTemplateRe : /<tpl(?:\sname="([\w-]+)")?>((?:.|\n)*?)<\/tpl>/gi,
10434 add : function(B, C){
10435 if(arguments.length == 1){
10439 var s = this.subs[B];
10440 s.buffer[s.buffer.length] = s.tpl.apply(C);
10446 fill : function(D, E, F){
10448 if(a.length == 1 || (a.length == 2 && typeof a[1] == "boolean")){
10456 for(var i = 0, len = E.length; i < len; i++){
10464 reset : function(){
10466 for(var i = 0; i < this.subCount; i++){
10472 applyTemplate : function(G){
10475 this.html = this.originalHtml.replace(this.subTemplateRe, function(m, I){
10476 return s[++H].buffer.join("");
10478 return Roo.MasterTemplate.superclass.applyTemplate.call(this, G);
10481 apply : function(){
10482 return this.applyTemplate.apply(this, arguments);
10485 compile : function(){return this;}
10490 Roo.MasterTemplate.prototype.addAll = Roo.MasterTemplate.prototype.fill;
10493 Roo.MasterTemplate.from = function(el, I){
10494 el = Roo.getDom(el);
10495 return new Roo.MasterTemplate(el.value || el.innerHTML, I || '');
10503 Roo.util.CSS = function(){
10507 var C = /(-[a-z])/gi;
10508 var D = function(m, a){ return a.charAt(1).toUpperCase(); };
10513 createStyleSheet : function(Q, id){
10515 var R = B.getElementsByTagName("head")[0];
10516 var S = B.createElement("style");
10517 S.setAttribute("type", "text/css");
10519 S.setAttribute("id", id);
10521 if (typeof(Q) != 'string') {
10526 var cssTextNew = [];
10529 for(var k in Q[n]) {
10530 citems.push( k + ' : ' +Q[n][k] + ';' );
10533 cssTextNew.push( n + ' { ' + citems.join(' ') + '} ');
10537 Q = cssTextNew.join("\n");
10548 S.appendChild(B.createTextNode(Q));
10554 ss = S.styleSheet ? S.styleSheet : (S.sheet || B.styleSheets[B.styleSheets.length-1]);
10557 this.cacheStyleSheet(ss);
10563 removeStyleSheet : function(id){
10564 var T = B.getElementById(id);
10566 T.parentNode.removeChild(T);
10572 swapStyleSheet : function(id, U){
10573 this.removeStyleSheet(id);
10574 var ss = B.createElement("link");
10575 ss.setAttribute("rel", "stylesheet");
10576 ss.setAttribute("type", "text/css");
10577 ss.setAttribute("id", id);
10578 ss.setAttribute("href", U);
10579 B.getElementsByTagName("head")[0].appendChild(ss);
10584 refreshCache : function(){
10585 return this.getRules(true);
10589 cacheStyleSheet : function(V){
10594 var ssRules = V.cssRules || V.rules;
10595 for(var j = ssRules.length-1; j >= 0; --j){
10596 A[ssRules[j].selectorText] = ssRules[j];
10603 getRules : function(W){
10604 if(A == null || W){
10606 var ds = B.styleSheets;
10607 for(var i =0, len = ds.length; i < len; i++){
10609 this.cacheStyleSheet(ds[i]);
10618 getRule : function(X, Y){
10619 var rs = this.getRules(Y);
10620 if(!(X instanceof Array)){
10623 for(var i = 0; i < X.length; i++){
10634 updateRule : function(Z, a, b){
10635 if(!(Z instanceof Array)){
10636 var rule = this.getRule(Z);
10638 rule.style[a.replace(C, D)] = b;
10642 for(var i = 0; i < Z.length; i++){
10643 if(this.updateRule(Z[i], a, b)){
10659 Roo.util.ClickRepeater = function(el, A)
10661 this.el = Roo.get(el);
10662 this.el.unselectable();
10664 Roo.apply(this, A);
10669 "mousedown" : true,
10678 this.el.on("mousedown", this.handleMouseDown, this);
10679 if(this.preventDefault || this.stopDefault){
10680 this.el.on("click", function(e){
10681 if(this.preventDefault){
10682 e.preventDefault();
10684 if(this.stopDefault){
10692 this.on("click", this.handler, this.scope || this);
10696 Roo.util.ClickRepeater.superclass.constructor.call(this);
10699 Roo.extend(Roo.util.ClickRepeater, Roo.util.Observable, {
10702 preventDefault : true,
10703 stopDefault : false,
10707 handleMouseDown : function(){
10708 clearTimeout(this.timer);
10710 if(this.pressClass){
10711 this.el.addClass(this.pressClass);
10714 this.mousedownTime = new Date();
10716 Roo.get(document).on("mouseup", this.handleMouseUp, this);
10717 this.el.on("mouseout", this.handleMouseOut, this);
10719 this.fireEvent("mousedown", this);
10720 this.fireEvent("click", this);
10722 this.timer = this.click.defer(this.delay || this.interval, this);
10726 click : function(){
10727 this.fireEvent("click", this);
10728 this.timer = this.click.defer(this.getInterval(), this);
10732 getInterval: function(){
10733 if(!this.accelerate){
10734 return this.interval;
10736 var B = this.mousedownTime.getElapsed();
10739 }else if(B < 1700){
10741 }else if(B < 2600){
10743 }else if(B < 3500){
10745 }else if(B < 4400){
10747 }else if(B < 5300){
10749 }else if(B < 6200){
10757 handleMouseOut : function(){
10758 clearTimeout(this.timer);
10759 if(this.pressClass){
10760 this.el.removeClass(this.pressClass);
10763 this.el.on("mouseover", this.handleMouseReturn, this);
10767 handleMouseReturn : function(){
10768 this.el.un("mouseover", this.handleMouseReturn);
10769 if(this.pressClass){
10770 this.el.addClass(this.pressClass);
10777 handleMouseUp : function(){
10778 clearTimeout(this.timer);
10779 this.el.un("mouseover", this.handleMouseReturn);
10780 this.el.un("mouseout", this.handleMouseOut);
10781 Roo.get(document).un("mouseup", this.handleMouseUp);
10782 this.el.removeClass(this.pressClass);
10783 this.fireEvent("mouseup", this);
10792 Roo.KeyNav = function(el, A){
10793 this.el = Roo.get(el);
10794 Roo.apply(this, A);
10795 if(!this.disabled){
10796 this.disabled = true;
10801 Roo.KeyNav.prototype = {
10807 defaultEventAction: "stopEvent",
10810 forceKeyDown : false,
10813 prepareEvent : function(e){
10814 var k = e.getKey();
10815 var h = this.keyToHandler[k];
10819 if(Roo.isSafari && h && k >= 37 && k <= 40){
10825 relay : function(e){
10826 var k = e.getKey();
10827 var h = this.keyToHandler[k];
10829 if(this.doRelay(e, this[h], h) !== true){
10830 e[this.defaultEventAction]();
10836 doRelay : function(e, h, B){
10837 return h.call(this.scope || this, e);
10872 enable: function(){
10876 if(this.forceKeyDown || Roo.isIE || Roo.isAir){
10877 this.el.on("keydown", this.relay, this);
10879 this.el.on("keydown", this.prepareEvent, this);
10880 this.el.on("keypress", this.relay, this);
10883 this.disabled = false;
10889 disable: function(){
10890 if(!this.disabled){
10891 if(this.forceKeyDown || Roo.isIE || Roo.isAir){
10892 this.el.un("keydown", this.relay);
10894 this.el.un("keydown", this.prepareEvent);
10895 this.el.un("keypress", this.relay);
10898 this.disabled = true;
10908 Roo.KeyMap = function(el, A, B){
10909 this.el = Roo.get(el);
10910 this.eventName = B || "keydown";
10911 this.bindings = [];
10913 this.addBinding(A);
10919 Roo.KeyMap.prototype = {
10926 addBinding : function(C){
10927 if(C instanceof Array){
10928 for(var i = 0, len = C.length; i < len; i++){
10929 this.addBinding(C[i]);
10939 if(typeof D == "string"){
10941 var keyString = D.toUpperCase();
10942 for(var j = 0, len = keyString.length; j < len; j++){
10943 ks.push(keyString.charCodeAt(j));
10948 var I = D instanceof Array;
10949 var J = function(e){
10950 if((!E || e.shiftKey) && (!F || e.ctrlKey) && (!G || e.altKey)){
10951 var k = e.getKey();
10953 for(var i = 0, len = D.length; i < len; i++){
10955 if(this.stopEvent){
10959 fn.call(H || window, k, e);
10965 if(this.stopEvent){
10969 fn.call(H || window, k, e);
10974 this.bindings.push(J);
10979 on : function(K, fn, L){
10981 if(typeof K == "object" && !(K instanceof Array)){
11001 handleKeyDown : function(e){
11003 var b = this.bindings;
11004 for(var i = 0, len = b.length; i < len; i++){
11005 b[i].call(this, e);
11012 isEnabled : function(){
11013 return this.enabled;
11018 enable: function(){
11020 this.el.on(this.eventName, this.handleKeyDown, this);
11021 this.enabled = true;
11027 disable: function(){
11029 this.el.removeListener(this.eventName, this.handleKeyDown, this);
11030 this.enabled = false;
11040 Roo.util.TextMetrics = function(){
11045 measure : function(el, E, F){
11047 A = Roo.util.TextMetrics.Instance(el, F);
11051 A.setFixedWidth(F || 'auto');
11052 return A.getSize(E);
11057 createInstance : function(el, G){
11058 return Roo.util.TextMetrics.Instance(el, G);
11065 Roo.util.TextMetrics.Instance = function(B, C){
11066 var ml = new Roo.Element(document.createElement('div'));
11067 document.body.appendChild(ml.dom);
11068 ml.position('absolute');
11069 ml.setLeftTop(-1000, -1000);
11079 getSize : function(E){
11081 var s = ml.getSize();
11088 bind : function(el){
11090 Roo.fly(el).getStyles('font-size','font-style', 'font-weight', 'font-family','line-height')
11096 setFixedWidth : function(F){
11102 getWidth : function(G){
11103 ml.dom.style.width = 'auto';
11104 return this.getSize(G).width;
11109 getHeight : function(H){
11110 return this.getSize(H).height;
11120 Roo.Element.measureText = Roo.util.TextMetrics.measure;
11126 Roo.state.Provider = function(){
11130 "statechange": true
11133 Roo.state.Provider.superclass.constructor.call(this);
11135 Roo.extend(Roo.state.Provider, Roo.util.Observable, {
11138 get : function(A, B){
11139 return typeof this.state[A] == "undefined" ?
11145 clear : function(C){
11146 delete this.state[C];
11147 this.fireEvent("statechange", this, C, null);
11152 set : function(D, E){
11154 this.fireEvent("statechange", this, D, E);
11159 decodeValue : function(F){
11160 var re = /^(a|n|d|b|s|o)\:(.*)$/;
11161 var G = re.exec(unescape(F));
11162 if(!G || !G[1]) return;
11167 return parseFloat(v);
11169 return new Date(Date.parse(v));
11174 var values = v.split("^");
11175 for(var i = 0, len = values.length; i < len; i++){
11176 all.push(this.decodeValue(values[i]));
11181 var values = v.split("^");
11182 for(var i = 0, len = values.length; i < len; i++){
11183 var kv = values[i].split("=");
11184 all[kv[0]] = this.decodeValue(kv[1]);
11194 encodeValue : function(v){
11196 if(typeof v == "number"){
11198 }else if(typeof v == "boolean"){
11199 I = "b:" + (v ? "1" : "0");
11200 }else if(v instanceof Date){
11201 I = "d:" + v.toGMTString();
11202 }else if(v instanceof Array){
11204 for(var i = 0, len = v.length; i < len; i++){
11205 flat += this.encodeValue(v[i]);
11206 if(i != len-1) flat += "^";
11210 }else if(typeof v == "object"){
11213 if(typeof v[key] != "function"){
11214 flat += key + "=" + this.encodeValue(v[key]) + "^";
11218 I = "o:" + flat.substring(0, flat.length-1);
11231 Roo.state.Manager = function(){
11232 var A = new Roo.state.Provider();
11237 setProvider : function(H){
11243 get : function(I, J){
11244 return A.get(I, J);
11249 set : function(K, L){
11255 clear : function(M){
11261 getProvider : function(){
11271 Roo.state.CookieProvider = function(A){
11272 Roo.state.CookieProvider.superclass.constructor.call(this);
11274 this.expires = new Date(new Date().getTime()+(1000*60*60*24*7));
11275 this.domain = null;
11276 this.secure = false;
11277 Roo.apply(this, A);
11278 this.state = this.readCookies();
11281 Roo.extend(Roo.state.CookieProvider, Roo.state.Provider, {
11283 set : function(B, C){
11284 if(typeof C == "undefined" || C === null){
11289 this.setCookie(B, C);
11290 Roo.state.CookieProvider.superclass.set.call(this, B, C);
11294 clear : function(D){
11295 this.clearCookie(D);
11296 Roo.state.CookieProvider.superclass.clear.call(this, D);
11300 readCookies : function(){
11302 var c = document.cookie + ";";
11303 var re = /\s?(.*?)=(.*?);/g;
11305 while((F = re.exec(c)) != null){
11308 if(D && D.substring(0,3) == "ys-"){
11309 E[D.substr(3)] = this.decodeValue(C);
11316 setCookie : function(G, H){
11317 document.cookie = "ys-"+ G + "=" + this.encodeValue(H) +
11318 ((this.expires == null) ? "" : ("; expires=" + this.expires.toGMTString())) +
11319 ((this.path == null) ? "" : ("; path=" + this.path)) +
11320 ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
11321 ((this.secure == true) ? "; secure" : "");
11325 clearCookie : function(I){
11326 document.cookie = "ys-" + I + "=null; expires=Thu, 01-Jan-70 00:00:01 GMT" +
11327 ((this.path == null) ? "" : ("; path=" + this.path)) +
11328 ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
11329 ((this.secure == true) ? "; secure" : "");
11342 var A=Roo.EventManager;
11347 Roo.dd.DragDrop = function(id, C, D) {
11349 this.init(id, C, D);
11353 Roo.dd.DragDrop.prototype = {
11373 invalidHandleTypes: null,
11377 invalidHandleIds: null,
11381 invalidHandleClasses: null,
11401 lock: function() { this.locked = true; },
11405 unlock: function() { this.locked = false; },
11421 __ygDragDrop: true,
11449 maintainOffset: false,
11461 primaryButtonOnly: true,
11469 hasOuterHandles: false,
11473 b4StartDrag: function(x, y) { },
11477 startDrag: function(x, y) {
11482 b4Drag: function(e) { },
11486 onDrag: function(e) {
11491 onDragEnter: function(e, id) {
11496 b4DragOver: function(e) { },
11500 onDragOver: function(e, id) {
11505 b4DragOut: function(e) { },
11509 onDragOut: function(e, id) {
11514 b4DragDrop: function(e) { },
11518 onDragDrop: function(e, id) {
11523 onInvalidDrop: function(e) {
11528 b4EndDrag: function(e) { },
11532 endDrag: function(e) {
11537 b4MouseDown: function(e) { },
11541 onMouseDown: function(e) {
11546 onMouseUp: function(e) {
11551 onAvailable: function () {
11556 defaultPadding : {left:0, right:0, top:0, bottom:0},
11560 constrainTo : function(C, D, E){
11561 if(typeof D == "number"){
11562 D = {left: D, right:D, top:D, bottom:D};
11565 D = D || this.defaultPadding;
11566 var b = Roo.get(this.getEl()).getBox();
11567 var ce = Roo.get(C);
11568 var s = ce.getScroll();
11569 var c, cd = ce.dom;
11570 if(cd == document.body){
11571 c = { x: s.left, y: s.top, width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
11574 c = {x : xy[0]+s.left, y: xy[1]+s.top, width: cd.clientWidth, height: cd.clientHeight};
11581 this.resetConstraints();
11582 this.setXConstraint(G - (D.left||0),
11583 c.width - G - b.width - (D.right||0)
11585 this.setYConstraint(F - (D.top||0),
11586 c.height - F - b.height - (D.bottom||0)
11592 getEl: function() {
11593 if (!this._domRef) {
11594 this._domRef = Roo.getDom(this.id);
11597 return this._domRef;
11602 getDragEl: function() {
11603 return Roo.getDom(this.dragElId);
11608 init: function(id, H, I) {
11609 this.initTarget(id, H, I);
11610 A.on(this.id, "mousedown", this.handleMouseDown, this);
11616 initTarget: function(id, J, K) {
11619 this.config = K || {};
11622 this.DDM = Roo.dd.DDM;
11628 if (typeof id !== "string") {
11637 this.addToGroup((J) ? J : "default");
11641 this.handleElId = id;
11644 this.setDragElId(id);
11647 this.invalidHandleTypes = { A: "A" };
11648 this.invalidHandleIds = {};
11649 this.invalidHandleClasses = [];
11651 this.applyConfig();
11653 this.handleOnAvailable();
11658 applyConfig: function() {
11662 this.padding = this.config.padding || [0, 0, 0, 0];
11663 this.isTarget = (this.config.isTarget !== false);
11664 this.maintainOffset = (this.config.maintainOffset);
11665 this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);
11671 handleOnAvailable: function() {
11672 this.available = true;
11673 this.resetConstraints();
11674 this.onAvailable();
11679 setPadding: function(L, M, N, O) {
11681 if (!M && 0 !== M) {
11682 this.padding = [L, L, L, L];
11683 } else if (!N && 0 !== N) {
11684 this.padding = [L, M, L, M];
11686 this.padding = [L, M, N, O];
11692 setInitPosition: function(P, Q) {
11693 var el = this.getEl();
11695 if (!this.DDM.verifyEl(el)) {
11702 var p = B.getXY( el );
11704 this.initPageX = p[0] - dx;
11705 this.initPageY = p[1] - dy;
11707 this.lastPageX = p[0];
11708 this.lastPageY = p[1];
11711 this.setStartPosition(p);
11716 setStartPosition: function(R) {
11717 var p = R || B.getXY( this.getEl() );
11718 this.deltaSetXY = null;
11720 this.startPageX = p[0];
11721 this.startPageY = p[1];
11726 addToGroup: function(S) {
11727 this.groups[S] = true;
11728 this.DDM.regDragDrop(this, S);
11733 removeFromGroup: function(T) {
11734 if (this.groups[T]) {
11735 delete this.groups[T];
11739 this.DDM.removeDDFromGroup(this, T);
11744 setDragElId: function(id) {
11745 this.dragElId = id;
11750 setHandleElId: function(id) {
11751 if (typeof id !== "string") {
11755 this.handleElId = id;
11756 this.DDM.regHandle(this.id, id);
11761 setOuterHandleElId: function(id) {
11762 if (typeof id !== "string") {
11766 A.on(id, "mousedown",
11767 this.handleMouseDown, this);
11768 this.setHandleElId(id);
11770 this.hasOuterHandles = true;
11775 unreg: function() {
11776 A.un(this.id, "mousedown",
11777 this.handleMouseDown);
11778 this._domRef = null;
11779 this.DDM._remove(this);
11782 destroy : function(){
11788 isLocked: function() {
11789 return (this.DDM.isLocked() || this.locked);
11794 handleMouseDown: function(e, U){
11795 if (this.primaryButtonOnly && e.button != 0) {
11799 if (this.isLocked()) {
11804 this.DDM.refreshCache(this.groups);
11806 var pt = new Roo.lib.Point(Roo.lib.Event.getPageX(e), Roo.lib.Event.getPageY(e));
11807 if (!this.hasOuterHandles && !this.DDM.isOverTarget(pt, this) ) {
11809 if (this.clickValidator(e)) {
11812 this.setStartPosition();
11815 this.b4MouseDown(e);
11816 this.onMouseDown(e);
11818 this.DDM.handleMouseDown(e, this);
11820 this.DDM.stopEvent(e);
11828 clickValidator: function(e) {
11829 var V = e.getTarget();
11830 return ( this.isValidHandleChild(V) &&
11831 (this.id == this.handleElId ||
11832 this.DDM.handleWasClicked(V, this.id)) );
11837 addInvalidHandleType: function(W) {
11838 var X = W.toUpperCase();
11839 this.invalidHandleTypes[X] = X;
11844 addInvalidHandleId: function(id) {
11845 if (typeof id !== "string") {
11849 this.invalidHandleIds[id] = id;
11854 addInvalidHandleClass: function(Y) {
11855 this.invalidHandleClasses.push(Y);
11860 removeInvalidHandleType: function(Z) {
11861 var a = Z.toUpperCase();
11863 delete this.invalidHandleTypes[a];
11868 removeInvalidHandleId: function(id) {
11869 if (typeof id !== "string") {
11872 delete this.invalidHandleIds[id];
11877 removeInvalidHandleClass: function(d) {
11878 for (var i=0, len=this.invalidHandleClasses.length; i<len; ++i) {
11879 if (this.invalidHandleClasses[i] == d) {
11880 delete this.invalidHandleClasses[i];
11887 isValidHandleChild: function(f) {
11893 h = f.nodeName.toUpperCase();
11895 nodeName = node.nodeName;
11898 g = g && !this.invalidHandleTypes[h];
11899 g = g && !this.invalidHandleIds[f.id];
11901 for (var i=0, len=this.invalidHandleClasses.length; g && i<len; ++i) {
11902 g = !B.hasClass(f, this.invalidHandleClasses[i]);
11912 setXTicks: function(j, k) {
11914 this.xTickSize = k;
11918 for (var i = this.initPageX; i >= this.minX; i = i - k) {
11920 this.xTicks[this.xTicks.length] = i;
11925 for (i = this.initPageX; i <= this.maxX; i = i + k) {
11927 this.xTicks[this.xTicks.length] = i;
11933 this.xTicks.sort(this.DDM.numericSort) ;
11938 setYTicks: function(m, n) {
11940 this.yTickSize = n;
11944 for (var i = this.initPageY; i >= this.minY; i = i - n) {
11946 this.yTicks[this.yTicks.length] = i;
11951 for (i = this.initPageY; i <= this.maxY; i = i + n) {
11953 this.yTicks[this.yTicks.length] = i;
11959 this.yTicks.sort(this.DDM.numericSort) ;
11964 setXConstraint: function(q, r, t) {
11965 this.leftConstraint = q;
11966 this.rightConstraint = r;
11968 this.minX = this.initPageX - q;
11969 this.maxX = this.initPageX + r;
11970 if (t) { this.setXTicks(this.initPageX, t); }
11973 this.constrainX = true;
11978 clearConstraints: function() {
11979 this.constrainX = false;
11980 this.constrainY = false;
11986 clearTicks: function() {
11987 this.xTicks = null;
11988 this.yTicks = null;
11989 this.xTickSize = 0;
11990 this.yTickSize = 0;
11995 setYConstraint: function(u, v, w) {
11996 this.topConstraint = u;
11997 this.bottomConstraint = v;
11999 this.minY = this.initPageY - u;
12000 this.maxY = this.initPageY + v;
12001 if (w) { this.setYTicks(this.initPageY, w); }
12004 this.constrainY = true;
12010 resetConstraints: function() {
12014 if (this.initPageX || this.initPageX === 0) {
12016 var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0;
12017 var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0;
12019 this.setInitPosition(dx, dy);
12023 this.setInitPosition();
12026 if (this.constrainX) {
12027 this.setXConstraint( this.leftConstraint,
12028 this.rightConstraint,
12032 if (this.constrainY) {
12033 this.setYConstraint( this.topConstraint,
12034 this.bottomConstraint,
12041 getTick: function(z, AA) {
12047 } else if (AA[0] >= z) {
12052 for (var i=0, len=AA.length; i<len; ++i) {
12054 if (AA[next] && AA[next] >= z) {
12055 var diff1 = z - AA[i];
12056 var diff2 = AA[next] - z;
12057 return (diff2 > diff1) ? AA[i] : AA[next];
12063 return AA[AA.length - 1];
12069 toString: function() {
12070 return ("DragDrop " + this.id);
12086 if (!Roo.dd.DragDropMgr) {
12090 Roo.dd.DragDropMgr = function() {
12092 var A = Roo.EventManager;
12122 preventDefault: true,
12126 stopPropagation: true,
12139 this.initialized = true;
12156 _execOnAll: function(AG, AH) {
12157 for (var i in this.ids) {
12158 for (var j in this.ids[i]) {
12159 var h = this.ids[i][j];
12160 if (! this.isTypeOfDD(h)) {
12164 h[AG].apply(h, AH);
12171 _onLoad: function() {
12176 A.on(document, "mouseup", this.handleMouseUp, this, true);
12177 A.on(document, "mousemove", this.handleMouseMove, this, true);
12178 A.on(window, "unload", this._onUnload, this, true);
12179 A.on(window, "resize", this._onResize, this, true);
12186 _onResize: function(e) {
12187 this._execOnAll("resetConstraints", []);
12192 lock: function() { this.locked = true; },
12196 unlock: function() { this.locked = false; },
12200 isLocked: function() { return this.locked; },
12212 clickPixelThresh: 3,
12216 clickTimeThresh: 350,
12220 dragThreshMet: false,
12224 clickTimeout: null,
12236 regDragDrop: function(AI, AJ) {
12237 if (!this.initialized) { this.init(); }
12239 if (!this.ids[AJ]) {
12243 this.ids[AJ][AI.id] = AI;
12248 removeDDFromGroup: function(AK, AL) {
12249 if (!this.ids[AL]) {
12253 var AM = this.ids[AL];
12254 if (AM && AM[AK.id]) {
12261 _remove: function(AN) {
12262 for (var g in AN.groups) {
12263 if (g && this.ids[g][AN.id]) {
12264 delete this.ids[g][AN.id];
12267 delete this.handleIds[AN.id];
12272 regHandle: function(AO, AP) {
12273 if (!this.handleIds[AO]) {
12274 this.handleIds[AO] = {};
12277 this.handleIds[AO][AP] = AP;
12282 isDragDrop: function(id) {
12283 return ( this.getDDById(id) ) ? true : false;
12288 getRelated: function(AQ, AR) {
12290 for (var i in AQ.groups) {
12291 for (j in this.ids[i]) {
12292 var dd = this.ids[i][j];
12293 if (! this.isTypeOfDD(dd)) {
12296 if (!AR || dd.isTarget) {
12297 AS[AS.length] = dd;
12307 isLegalTarget: function (AT, AU) {
12308 var AV = this.getRelated(AT, true);
12309 for (var i=0, d=AV.length;i<d;++i) {
12310 if (AV[i].id == AU.id) {
12320 isTypeOfDD: function (AW) {
12321 return (AW && AW.__ygDragDrop);
12326 isHandle: function(AX, AY) {
12327 return ( this.handleIds[AX] &&
12328 this.handleIds[AX][AY] );
12333 getDDById: function(id) {
12334 for (var i in this.ids) {
12335 if (this.ids[i][id]) {
12336 return this.ids[i][id];
12344 handleMouseDown: function(e, AZ) {
12346 Roo.QuickTips.disable();
12349 this.currentTarget = e.getTarget();
12351 this.dragCurrent = AZ;
12353 var el = AZ.getEl();
12356 this.startX = e.getPageX();
12357 this.startY = e.getPageY();
12359 this.deltaX = this.startX - el.offsetLeft;
12360 this.deltaY = this.startY - el.offsetTop;
12362 this.dragThreshMet = false;
12364 this.clickTimeout = setTimeout(
12366 var Aa = Roo.dd.DDM;
12367 Aa.startDrag(Aa.startX, Aa.startY);
12369 this.clickTimeThresh );
12374 startDrag: function(x, y) {
12375 clearTimeout(this.clickTimeout);
12376 if (this.dragCurrent) {
12377 this.dragCurrent.b4StartDrag(x, y);
12378 this.dragCurrent.startDrag(x, y);
12381 this.dragThreshMet = true;
12386 handleMouseUp: function(e) {
12389 Roo.QuickTips.enable();
12391 if (! this.dragCurrent) {
12396 clearTimeout(this.clickTimeout);
12398 if (this.dragThreshMet) {
12399 this.fireEvents(e, true);
12411 stopEvent: function(e){
12412 if(this.stopPropagation) {
12413 e.stopPropagation();
12416 if (this.preventDefault) {
12417 e.preventDefault();
12423 stopDrag: function(e) {
12425 if (this.dragCurrent) {
12426 if (this.dragThreshMet) {
12427 this.dragCurrent.b4EndDrag(e);
12428 this.dragCurrent.endDrag(e);
12432 this.dragCurrent.onMouseUp(e);
12436 this.dragCurrent = null;
12437 this.dragOvers = {};
12442 handleMouseMove: function(e) {
12443 if (! this.dragCurrent) {
12450 if (Roo.isIE && (e.button !== 0 && e.button !== 1 && e.button !== 2)) {
12452 return this.handleMouseUp(e);
12455 if (!this.dragThreshMet) {
12456 var diffX = Math.abs(this.startX - e.getPageX());
12457 var diffY = Math.abs(this.startY - e.getPageY());
12458 if (diffX > this.clickPixelThresh ||
12459 diffY > this.clickPixelThresh) {
12460 this.startDrag(this.startX, this.startY);
12464 if (this.dragThreshMet) {
12465 this.dragCurrent.b4Drag(e);
12466 this.dragCurrent.onDrag(e);
12467 if(!this.dragCurrent.moveOnly){
12468 this.fireEvents(e, false);
12480 fireEvents: function(e, Aa) {
12481 var dc = this.dragCurrent;
12485 if (!dc || dc.isLocked()) {
12489 var pt = e.getPoint();
12501 for (var i in this.dragOvers) {
12503 var ddo = this.dragOvers[i];
12505 if (! this.isTypeOfDD(ddo)) {
12509 if (! this.isOverTarget(pt, ddo, this.mode)) {
12515 delete this.dragOvers[i];
12518 for (var AL in dc.groups) {
12520 if ("string" != typeof AL) {
12524 for (i in this.ids[AL]) {
12525 var AZ = this.ids[AL][i];
12526 if (! this.isTypeOfDD(AZ)) {
12530 if (AZ.isTarget && !AZ.isLocked() && AZ != dc) {
12531 if (this.isOverTarget(pt, AZ, this.mode)) {
12547 this.dragOvers[AZ.id] = AZ;
12556 dc.b4DragOut(e, Ac);
12557 dc.onDragOut(e, Ac);
12561 dc.onDragEnter(e, Af);
12565 dc.b4DragOver(e, Ad);
12566 dc.onDragOver(e, Ad);
12570 dc.b4DragDrop(e, Ae);
12571 dc.onDragDrop(e, Ae);
12577 for (i=0, d=Ac.length; i<d; ++i) {
12578 dc.b4DragOut(e, Ac[i].id);
12579 dc.onDragOut(e, Ac[i].id);
12583 for (i=0,d=Af.length; i<d; ++i) {
12585 dc.onDragEnter(e, Af[i].id);
12589 for (i=0,d=Ad.length; i<d; ++i) {
12590 dc.b4DragOver(e, Ad[i].id);
12591 dc.onDragOver(e, Ad[i].id);
12595 for (i=0, d=Ae.length; i<d; ++i) {
12596 dc.b4DragDrop(e, Ae[i].id);
12597 dc.onDragDrop(e, Ae[i].id);
12603 if (Aa && !Ae.length) {
12604 dc.onInvalidDrop(e);
12611 getBestMatch: function(Ag) {
12619 var Ai = Ag.length;
12625 for (var i=0; i<Ai; ++i) {
12630 if (dd.cursorIsOver) {
12636 Ah.overlap.getArea() < dd.overlap.getArea()) {
12648 refreshCache: function(Aj) {
12649 for (var AL in Aj) {
12650 if ("string" != typeof AL) {
12653 for (var i in this.ids[AL]) {
12654 var AZ = this.ids[AL][i];
12656 if (this.isTypeOfDD(AZ)) {
12658 var o = this.getLocation(AZ);
12660 this.locationCache[AZ.id] = o;
12662 delete this.locationCache[AZ.id];
12674 verifyEl: function(el) {
12679 parent = el.offsetParent;
12682 parent = el.offsetParent;
12694 getLocation: function(Ak) {
12695 if (! this.isTypeOfDD(Ak)) {
12699 var el = Ak.getEl(), Al, x1, x2, y1, y2, t, r, b, l;
12702 Al= Roo.lib.Dom.getXY(el);
12711 x2 = x1 + el.offsetWidth;
12713 y2 = y1 + el.offsetHeight;
12715 t = y1 - Ak.padding[0];
12716 r = x2 + Ak.padding[1];
12717 b = y2 + Ak.padding[2];
12718 l = x1 - Ak.padding[3];
12720 return new Roo.lib.Region( t, r, b, l );
12725 isOverTarget: function(pt, Am, An) {
12727 var Ao = this.locationCache[Am.id];
12728 if (!Ao || !this.useCache) {
12729 Ao = this.getLocation(Am);
12730 this.locationCache[Am.id] = Ao;
12739 Am.cursorIsOver = Ao.contains( pt );
12746 var dc = this.dragCurrent;
12747 if (!dc || !dc.getTargetCoord ||
12748 (!An && !dc.constrainX && !dc.constrainY)) {
12749 return Am.cursorIsOver;
12759 var Ap = dc.getTargetCoord(pt.x, pt.y);
12761 var el = dc.getDragEl();
12762 var Aq = new Roo.lib.Region( Ap.y,
12763 Ap.x + el.offsetWidth,
12764 Ap.y + el.offsetHeight,
12767 var Ar = Aq.intersect(Ao);
12771 return (An) ? true : Am.cursorIsOver;
12779 _onUnload: function(e, me) {
12780 Roo.dd.DragDropMgr.unregAll();
12785 unregAll: function() {
12787 if (this.dragCurrent) {
12789 this.dragCurrent = null;
12793 this._execOnAll("unreg", []);
12795 for (i in this.elementCache) {
12796 delete this.elementCache[i];
12800 this.elementCache = {};
12810 getElWrapper: function(id) {
12811 var As = this.elementCache[id];
12812 if (!As || !As.el) {
12813 As = this.elementCache[id] =
12814 new this.ElementWrapper(Roo.getDom(id));
12821 getElement: function(id) {
12822 return Roo.getDom(id);
12827 getCss: function(id) {
12828 var el = Roo.getDom(id);
12829 return (el) ? el.style : null;
12834 ElementWrapper: function(el) {
12837 this.el = el || null;
12840 this.id = this.el && el.id;
12843 this.css = this.el && el.style;
12848 getPosX: function(el) {
12849 return Roo.lib.Dom.getX(el);
12854 getPosY: function(el) {
12855 return Roo.lib.Dom.getY(el);
12860 swapNode: function(n1, n2) {
12864 var p = n2.parentNode;
12865 var s = n2.nextSibling;
12868 p.insertBefore(n1, n2);
12869 } else if (n2 == n1.nextSibling) {
12870 p.insertBefore(n2, n1);
12872 n1.parentNode.replaceChild(n2, n1);
12873 p.insertBefore(n1, s);
12880 getScroll: function () {
12881 var t, l, At=document.documentElement, db=document.body;
12882 if (At && (At.scrollTop || At.scrollLeft)) {
12891 return { top: t, left: l };
12896 getStyle: function(el, Au) {
12897 return Roo.fly(el).getStyle(Au);
12902 getScrollTop: function () { return this.getScroll().top; },
12906 getScrollLeft: function () { return this.getScroll().left; },
12910 moveToEl: function (Av, Aw) {
12911 var Ax = Roo.lib.Dom.getXY(Aw);
12912 Roo.lib.Dom.setXY(Av, Ax);
12917 numericSort: function(a, b) { return (a - b); },
12925 _addListeners: function() {
12926 var Ay = Roo.dd.DDM;
12927 if ( Roo.lib.Event && document ) {
12930 if (Ay._timeoutCount > 2000) {
12932 setTimeout(Ay._addListeners, 10);
12933 if (document && document.body) {
12934 Ay._timeoutCount += 1;
12942 handleWasClicked: function(Az, id) {
12943 if (this.isHandle(id, Az.id)) {
12947 var p = Az.parentNode;
12950 if (this.isHandle(id, p.id)) {
12966 Roo.dd.DDM = Roo.dd.DragDropMgr;
12967 Roo.dd.DDM._addListeners();
12975 Roo.dd.DD = function(id, A, B) {
12977 this.init(id, A, B);
12981 Roo.extend(Roo.dd.DD, Roo.dd.DragDrop, {
12989 autoOffset: function(C, D) {
12990 var x = C - this.startPageX;
12991 var y = D - this.startPageY;
12992 this.setDelta(x, y);
12997 setDelta: function(E, F) {
13004 setDragElPos: function(G, H) {
13008 var el = this.getDragEl();
13009 this.alignElWithMouse(el, G, H);
13014 alignElWithMouse: function(el, I, J) {
13015 var K = this.getTargetCoord(I, J);
13016 var L = el.dom ? el : Roo.fly(el);
13017 if (!this.deltaSetXY) {
13018 var aCoord = [K.x, K.y];
13020 var newLeft = L.getLeft(true);
13021 var newTop = L.getTop(true);
13022 this.deltaSetXY = [ newLeft - K.x, newTop - K.y ];
13024 L.setLeftTop(K.x + this.deltaSetXY[0], K.y + this.deltaSetXY[1]);
13028 this.cachePosition(K.x, K.y);
13029 this.autoScroll(K.x, K.y, el.offsetHeight, el.offsetWidth);
13035 cachePosition: function(M, N) {
13037 this.lastPageX = M;
13038 this.lastPageY = N;
13040 var aCoord = Roo.lib.Dom.getXY(this.getEl());
13041 this.lastPageX = aCoord[0];
13042 this.lastPageY = aCoord[1];
13048 autoScroll: function(x, y, h, w) {
13052 var clientH = Roo.lib.Dom.getViewWidth();
13055 var clientW = Roo.lib.Dom.getViewHeight();
13058 var st = this.DDM.getScrollTop();
13061 var sl = this.DDM.getScrollLeft();
13072 var toBot = (clientH + st - y - this.deltaY);
13075 var toRight = (clientW + sl - x - this.deltaX);
13085 var scrAmt = (document.all) ? 80 : 30;
13089 if ( bot > clientH && toBot < thresh ) {
13090 window.scrollTo(sl, st + scrAmt);
13095 if ( y < st && st > 0 && y - st < thresh ) {
13096 window.scrollTo(sl, st - scrAmt);
13101 if ( right > clientW && toRight < thresh ) {
13102 window.scrollTo(sl + scrAmt, st);
13107 if ( x < sl && sl > 0 && x - sl < thresh ) {
13108 window.scrollTo(sl - scrAmt, st);
13115 getTargetCoord: function(O, P) {
13118 var x = O - this.deltaX;
13119 var y = P - this.deltaY;
13121 if (this.constrainX) {
13122 if (x < this.minX) { x = this.minX; }
13123 if (x > this.maxX) { x = this.maxX; }
13126 if (this.constrainY) {
13127 if (y < this.minY) { y = this.minY; }
13128 if (y > this.maxY) { y = this.maxY; }
13132 x = this.getTick(x, this.xTicks);
13133 y = this.getTick(y, this.yTicks);
13141 applyConfig: function() {
13142 Roo.dd.DD.superclass.applyConfig.call(this);
13143 this.scroll = (this.config.scroll !== false);
13148 b4MouseDown: function(e) {
13150 this.autoOffset(e.getPageX(),
13156 b4Drag: function(e) {
13157 this.setDragElPos(e.getPageX(),
13161 toString: function() {
13162 return ("DD " + this.id);
13177 Roo.dd.DDProxy = function(id, A, B) {
13179 this.init(id, A, B);
13186 Roo.dd.DDProxy.dragElId = "ygddfdiv";
13188 Roo.extend(Roo.dd.DDProxy, Roo.dd.DD, {
13196 centerFrame: false,
13200 createFrame: function() {
13202 var D = document.body;
13204 if (!D || !D.firstChild) {
13205 setTimeout( function() { C.createFrame(); }, 50 );
13209 var E = this.getDragEl();
13212 E = document.createElement("div");
13213 E.id = this.dragElId;
13216 s.position = "absolute";
13217 s.visibility = "hidden";
13219 s.border = "2px solid #aaa";
13225 D.insertBefore(E, D.firstChild);
13231 initFrame: function() {
13232 this.createFrame();
13235 applyConfig: function() {
13236 Roo.dd.DDProxy.superclass.applyConfig.call(this);
13238 this.resizeFrame = (this.config.resizeFrame !== false);
13239 this.centerFrame = (this.config.centerFrame);
13240 this.setDragElId(this.config.dragElId || Roo.dd.DDProxy.dragElId);
13245 showFrame: function(F, G) {
13246 var el = this.getEl();
13247 var H = this.getDragEl();
13250 this._resizeProxy();
13252 if (this.centerFrame) {
13253 this.setDelta( Math.round(parseInt(s.width, 10)/2),
13254 Math.round(parseInt(s.height, 10)/2) );
13258 this.setDragElPos(F, G);
13265 _resizeProxy: function() {
13266 if (this.resizeFrame) {
13267 var el = this.getEl();
13268 Roo.fly(this.getDragEl()).setSize(el.offsetWidth, el.offsetHeight);
13273 b4MouseDown: function(e) {
13274 var x = e.getPageX();
13275 var y = e.getPageY();
13276 this.autoOffset(x, y);
13277 this.setDragElPos(x, y);
13281 b4StartDrag: function(x, y) {
13283 this.showFrame(x, y);
13287 b4EndDrag: function(e) {
13288 Roo.fly(this.getDragEl()).hide();
13294 endDrag: function(e) {
13296 var I = this.getEl();
13297 var J = this.getDragEl();
13300 J.style.visibility = "";
13305 I.style.visibility = "hidden";
13306 Roo.dd.DDM.moveToEl(I, J);
13307 J.style.visibility = "hidden";
13308 I.style.visibility = "";
13313 beforeMove : function(){
13317 afterDrag : function(){
13321 toString: function() {
13322 return ("DDProxy " + this.id);
13332 Roo.dd.DDTarget = function(id, A, B) {
13334 this.initTarget(id, A, B);
13339 Roo.extend(Roo.dd.DDTarget, Roo.dd.DragDrop, {
13340 toString: function() {
13341 return ("DDTarget " + this.id);
13351 Roo.dd.ScrollManager = function(){
13352 var A = Roo.dd.DragDropMgr;
13357 var E = function(e){
13362 var F = function(){
13364 A.refreshCache(A.dragCurrent.groups);
13368 var G = function(){
13370 var dds = Roo.dd.ScrollManager;
13372 if(D.el.scroll(D.dir, dds.increment)){
13376 D.el.scroll(D.dir, dds.increment, true, dds.animDuration, F);
13381 var H = function(){
13383 clearInterval(D.id);
13391 var I = function(el, K){
13395 D.id = setInterval(G, Roo.dd.ScrollManager.frequency);
13398 var J = function(e, K){
13399 if(K || !A.dragCurrent){ return; }
13400 var L = Roo.dd.ScrollManager;
13401 if(!C || C != A.dragCurrent){
13407 var xy = Roo.lib.Event.getXY(e);
13408 var pt = new Roo.lib.Point(xy[0], xy[1]);
13410 var el = B[id], r = el._region;
13411 if(r && r.contains(pt) && el.isScrollable()){
13412 if(r.bottom - pt.y <= L.thresh){
13417 }else if(r.right - pt.x <= L.thresh){
13422 }else if(pt.y - r.top <= L.thresh){
13427 }else if(pt.x - r.left <= L.thresh){
13439 A.fireEvents = A.fireEvents.createSequence(J, A);
13440 A.stopDrag = A.stopDrag.createSequence(E, A);
13445 register : function(el){
13446 if(el instanceof Array){
13447 for(var i = 0, len = el.length; i < len; i++) {
13448 this.register(el[i]);
13458 unregister : function(el){
13459 if(el instanceof Array){
13460 for(var i = 0, len = el.length; i < len; i++) {
13461 this.unregister(el[i]);
13491 refreshCache : function(){
13493 if(typeof B[id] == 'object'){
13494 B[id]._region = B[id].getRegion();
13506 Roo.dd.Registry = function(){
13511 var D = function(el, E){
13512 if(typeof el == "string"){
13516 if(!id && E !== false){
13517 id = "roodd-" + (++C);
13526 register : function(el, G){
13528 if(typeof el == "string"){
13529 el = document.getElementById(el);
13534 if(G.isHandle !== false){
13538 var hs = G.handles;
13539 for(var i = 0, len = hs.length; i < len; i++){
13547 unregister : function(el){
13548 var id = D(el, false);
13553 var hs = H.handles;
13554 for(var i = 0, len = hs.length; i < len; i++){
13555 delete B[D(hs[i], false)];
13563 getHandle : function(id){
13564 if(typeof id != "string"){
13572 getHandleFromEvent : function(e){
13573 var t = Roo.lib.Event.getTarget(e);
13574 return t ? B[t.id] : null;
13579 getTarget : function(id){
13580 if(typeof id != "string"){
13588 getTargetFromEvent : function(e){
13589 var t = Roo.lib.Event.getTarget(e);
13590 return t ? A[t.id] || B[t.id] : null;
13600 Roo.dd.StatusProxy = function(A){
13601 Roo.apply(this, A);
13602 this.id = this.id || Roo.id();
13603 this.el = new Roo.Layer({
13605 id: this.id, tag: "div", cls: "x-dd-drag-proxy "+this.dropNotAllowed, children: [
13606 {tag: "div", cls: "x-dd-drop-icon"},
13607 {tag: "div", cls: "x-dd-drag-ghost"}
13610 shadow: !A || A.shadow !== false
13612 this.ghost = Roo.get(this.el.dom.childNodes[1]);
13613 this.dropStatus = this.dropNotAllowed;
13616 Roo.dd.StatusProxy.prototype = {
13619 dropAllowed : "x-dd-drop-ok",
13622 dropNotAllowed : "x-dd-drop-nodrop",
13626 setStatus : function(B){
13627 B = B || this.dropNotAllowed;
13628 if(this.dropStatus != B){
13629 this.el.replaceClass(this.dropStatus, B);
13630 this.dropStatus = B;
13636 reset : function(C){
13637 this.el.dom.className = "x-dd-drag-proxy " + this.dropNotAllowed;
13638 this.dropStatus = this.dropNotAllowed;
13640 this.ghost.update("");
13646 update : function(D){
13647 if(typeof D == "string"){
13648 this.ghost.update(D);
13650 this.ghost.update("");
13651 D.style.margin = "0";
13652 this.ghost.dom.appendChild(D);
13655 var el = this.ghost.dom.firstChild;
13657 Roo.fly(el).setStyle('float', 'none');
13663 getEl : function(){
13669 getGhost : function(){
13675 hide : function(E){
13685 if(this.anim && this.anim.isAnimated && this.anim.isAnimated()){
13704 repair : function(xy, F, G){
13707 if(xy && this.animRepair !== false){
13708 this.el.addClass("x-dd-drag-repair");
13709 this.el.hideUnders(true);
13710 this.anim = this.el.shift({
13711 duration: this.repairDuration || .5,
13715 callback: this.afterRepair,
13719 this.afterRepair();
13724 afterRepair : function(){
13726 if(typeof this.callback == "function"){
13727 this.callback.call(this.scope || this);
13730 this.callback = null;
13739 Roo.dd.DragSource = function(el, A){
13740 this.el = Roo.get(el);
13741 this.dragData = {};
13743 Roo.apply(this, A);
13746 this.proxy = new Roo.dd.StatusProxy();
13750 Roo.dd.DragSource.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group,
13751 {dragElId : this.proxy.id, resizeFrame: false, isTarget: false, scroll: this.scroll === true});
13753 this.dragging = false;
13756 Roo.extend(Roo.dd.DragSource, Roo.dd.DDProxy, {
13759 dropAllowed : "x-dd-drop-ok",
13762 dropNotAllowed : "x-dd-drop-nodrop",
13766 getDragData : function(e){
13767 return this.dragData;
13771 onDragEnter : function(e, id){
13772 var B = Roo.dd.DragDropMgr.getDDById(id);
13773 this.cachedTarget = B;
13774 if(this.beforeDragEnter(B, e, id) !== false){
13775 if(B.isNotifyTarget){
13776 var status = B.notifyEnter(this, e, this.dragData);
13777 this.proxy.setStatus(status);
13779 this.proxy.setStatus(this.dropAllowed);
13782 if(this.afterDragEnter){
13785 this.afterDragEnter(B, e, id);
13792 beforeDragEnter : function(C, e, id){
13797 alignElWithMouse: function() {
13798 Roo.dd.DragSource.superclass.alignElWithMouse.apply(this, arguments);
13803 onDragOver : function(e, id){
13804 var D = this.cachedTarget || Roo.dd.DragDropMgr.getDDById(id);
13805 if(this.beforeDragOver(D, e, id) !== false){
13806 if(D.isNotifyTarget){
13807 var status = D.notifyOver(this, e, this.dragData);
13808 this.proxy.setStatus(status);
13811 if(this.afterDragOver){
13814 this.afterDragOver(D, e, id);
13821 beforeDragOver : function(E, e, id){
13826 onDragOut : function(e, id){
13827 var F = this.cachedTarget || Roo.dd.DragDropMgr.getDDById(id);
13828 if(this.beforeDragOut(F, e, id) !== false){
13829 if(F.isNotifyTarget){
13830 F.notifyOut(this, e, this.dragData);
13833 this.proxy.reset();
13834 if(this.afterDragOut){
13837 this.afterDragOut(F, e, id);
13841 this.cachedTarget = null;
13846 beforeDragOut : function(G, e, id){
13851 onDragDrop : function(e, id){
13852 var H = this.cachedTarget || Roo.dd.DragDropMgr.getDDById(id);
13853 if(this.beforeDragDrop(H, e, id) !== false){
13854 if(H.isNotifyTarget){
13855 if(H.notifyDrop(this, e, this.dragData)){
13856 this.onValidDrop(H, e, id);
13858 this.onInvalidDrop(H, e, id);
13861 this.onValidDrop(H, e, id);
13864 if(this.afterDragDrop){
13867 this.afterDragDrop(H, e, id);
13870 delete this.cachedTarget;
13875 beforeDragDrop : function(I, e, id){
13880 onValidDrop : function(J, e, id){
13882 if(this.afterValidDrop){
13885 this.afterValidDrop(J, e, id);
13890 getRepairXY : function(e, K){
13891 return this.el.getXY();
13895 onInvalidDrop : function(L, e, id){
13896 this.beforeInvalidDrop(L, e, id);
13897 if(this.cachedTarget){
13898 if(this.cachedTarget.isNotifyTarget){
13899 this.cachedTarget.notifyOut(this, e, this.dragData);
13902 this.cacheTarget = null;
13905 this.proxy.repair(this.getRepairXY(e, this.dragData), this.afterRepair, this);
13907 if(this.afterInvalidDrop){
13910 this.afterInvalidDrop(e, id);
13915 afterRepair : function(){
13917 this.el.highlight(this.hlColor || "c3daf9");
13920 this.dragging = false;
13925 beforeInvalidDrop : function(M, e, id){
13930 handleMouseDown : function(e){
13931 if(this.dragging) {
13934 var N = this.getDragData(e);
13935 if(N && this.onBeforeDrag(N, e) !== false){
13938 Roo.dd.DragSource.superclass.handleMouseDown.apply(this, arguments);
13944 onBeforeDrag : function(O, e){
13950 onStartDrag : Roo.emptyFn,
13953 startDrag : function(x, y){
13954 this.proxy.reset();
13955 this.dragging = true;
13956 this.proxy.update("");
13957 this.onInitDrag(x, y);
13962 onInitDrag : function(x, y){
13963 var P = this.el.dom.cloneNode(true);
13965 this.proxy.update(P);
13966 this.onStartDrag(x, y);
13972 getProxy : function(){
13978 hideProxy : function(){
13980 this.proxy.reset(true);
13981 this.dragging = false;
13985 triggerCacheRefresh : function(){
13986 Roo.dd.DDM.refreshCache(this.groups);
13990 b4EndDrag: function(e) {
13994 endDrag : function(e){
13995 this.onEndDrag(this.dragData, e);
13999 onEndDrag : function(Q, e){
14003 autoOffset : function(x, y) {
14004 this.setDelta(-12, -20);
14013 Roo.dd.DropTarget = function(el, A){
14014 this.el = Roo.get(el);
14016 Roo.apply(this, A);
14018 if(this.containerScroll){
14019 Roo.dd.ScrollManager.register(this.el);
14023 Roo.dd.DropTarget.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group,
14028 Roo.extend(Roo.dd.DropTarget, Roo.dd.DDTarget, {
14033 dropAllowed : "x-dd-drop-ok",
14036 dropNotAllowed : "x-dd-drop-nodrop",
14042 isNotifyTarget : true,
14046 notifyEnter : function(dd, e, B){
14047 if(this.overClass){
14048 this.el.addClass(this.overClass);
14050 return this.dropAllowed;
14055 notifyOver : function(dd, e, C){
14056 return this.dropAllowed;
14061 notifyOut : function(dd, e, D){
14062 if(this.overClass){
14063 this.el.removeClass(this.overClass);
14069 notifyDrop : function(dd, e, E){
14079 Roo.dd.DragZone = function(el, A){
14080 Roo.dd.DragZone.superclass.constructor.call(this, el, A);
14081 if(this.containerScroll){
14082 Roo.dd.ScrollManager.register(this.el);
14086 Roo.extend(Roo.dd.DragZone, Roo.dd.DragSource, {
14094 getDragData : function(e){
14095 return Roo.dd.Registry.getHandleFromEvent(e);
14100 onInitDrag : function(x, y){
14101 this.proxy.update(this.dragData.ddel.cloneNode(true));
14102 this.onStartDrag(x, y);
14108 afterRepair : function(){
14110 Roo.Element.fly(this.dragData.ddel).highlight(this.hlColor || "c3daf9");
14113 this.dragging = false;
14118 getRepairXY : function(e){
14119 return Roo.Element.fly(this.dragData.ddel).getXY();
14126 Roo.dd.DropZone = function(el, A){
14127 Roo.dd.DropZone.superclass.constructor.call(this, el, A);
14130 Roo.extend(Roo.dd.DropZone, Roo.dd.DropTarget, {
14133 getTargetFromEvent : function(e){
14134 return Roo.dd.Registry.getTargetFromEvent(e);
14139 onNodeEnter : function(n, dd, e, B){
14145 onNodeOver : function(n, dd, e, C){
14146 return this.dropAllowed;
14151 onNodeOut : function(n, dd, e, D){
14157 onNodeDrop : function(n, dd, e, E){
14163 onContainerOver : function(dd, e, F){
14164 return this.dropNotAllowed;
14169 onContainerDrop : function(dd, e, G){
14175 notifyEnter : function(dd, e, H){
14176 return this.dropNotAllowed;
14181 notifyOver : function(dd, e, I){
14182 var n = this.getTargetFromEvent(e);
14184 if(this.lastOverNode){
14185 this.onNodeOut(this.lastOverNode, dd, e, I);
14186 this.lastOverNode = null;
14188 return this.onContainerOver(dd, e, I);
14190 if(this.lastOverNode != n){
14191 if(this.lastOverNode){
14192 this.onNodeOut(this.lastOverNode, dd, e, I);
14195 this.onNodeEnter(n, dd, e, I);
14196 this.lastOverNode = n;
14198 return this.onNodeOver(n, dd, e, I);
14203 notifyOut : function(dd, e, J){
14204 if(this.lastOverNode){
14205 this.onNodeOut(this.lastOverNode, dd, e, J);
14206 this.lastOverNode = null;
14212 notifyDrop : function(dd, e, K){
14213 if(this.lastOverNode){
14214 this.onNodeOut(this.lastOverNode, dd, e, K);
14215 this.lastOverNode = null;
14217 var n = this.getTargetFromEvent(e);
14219 this.onNodeDrop(n, dd, e, K) :
14220 this.onContainerDrop(dd, e, K);
14224 triggerCacheRefresh : function(){
14225 Roo.dd.DDM.refreshCache(this.groups);
14234 Roo.data.SortTypes = {
14237 none : function(s){
14243 stripTagsRE : /<\/?[^>]+>/gi,
14247 asText : function(s){
14248 return String(s).replace(this.stripTagsRE, "");
14253 asUCText : function(s){
14254 return String(s).toUpperCase().replace(this.stripTagsRE, "");
14259 asUCString : function(s) {
14260 return String(s).toUpperCase();
14265 asDate : function(s) {
14269 if(s instanceof Date){
14270 return s.getTime();
14272 return Date.parse(String(s));
14277 asFloat : function(s) {
14278 var A = parseFloat(String(s).replace(/,/g, ""));
14279 if(isNaN(A)) A = 0;
14285 asInt : function(s) {
14286 var B = parseInt(String(s).replace(/,/g, ""));
14287 if(isNaN(B)) B = 0;
14296 Roo.data.Record = function(A, id){
14297 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
14303 Roo.data.Record.create = function(o){
14304 var f = function(){
14305 f.superclass.constructor.apply(this, arguments);
14307 Roo.extend(f, Roo.data.Record);
14308 var p = f.prototype;
14309 p.fields = new Roo.util.MixedCollection(false, function(B){
14312 for(var i = 0, len = o.length; i < len; i++){
14313 p.fields.add(new Roo.data.Field(o[i]));
14316 f.getField = function(B){
14317 return p.fields.get(B);
14322 Roo.data.Record.AUTO_ID = 1000;
14323 Roo.data.Record.EDIT = 'edit';
14324 Roo.data.Record.REJECT = 'reject';
14325 Roo.data.Record.COMMIT = 'commit';
14327 Roo.data.Record.prototype = {
14336 join : function(B){
14342 set : function(C, D){
14343 if(this.data[C] == D){
14348 if(!this.modified){
14349 this.modified = {};
14351 if(typeof this.modified[C] == 'undefined'){
14352 this.modified[C] = this.data[C];
14357 this.store.afterEdit(this);
14364 return this.data[E];
14368 beginEdit : function(){
14369 this.editing = true;
14370 this.modified = {};
14374 cancelEdit : function(){
14375 this.editing = false;
14376 delete this.modified;
14380 endEdit : function(){
14381 this.editing = false;
14382 if(this.dirty && this.store){
14383 this.store.afterEdit(this);
14389 reject : function(){
14390 var m = this.modified;
14392 if(typeof m[n] != "function"){
14393 this.data[n] = m[n];
14397 this.dirty = false;
14398 delete this.modified;
14399 this.editing = false;
14401 this.store.afterReject(this);
14407 commit : function(){
14408 this.dirty = false;
14409 delete this.modified;
14410 this.editing = false;
14412 this.store.afterCommit(this);
14417 hasError : function(){
14418 return this.error != null;
14422 clearError : function(){
14428 copy : function(F) {
14429 return new this.constructor(Roo.apply({}, this.data), F || this.id);
14439 Roo.data.Store = function(A){
14440 this.data = new Roo.util.MixedCollection(false);
14441 this.data.getKey = function(o){
14444 this.baseParams = {};
14446 this.paramNames = {
14454 this.inlineData = A.data;
14459 Roo.apply(this, A);
14462 this.reader = Roo.factory(this.reader, Roo.data);
14463 this.reader.xmodule = this.xmodule || false;
14464 if(!this.recordType){
14465 this.recordType = this.reader.recordType;
14467 if(this.reader.onMetaChange){
14468 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
14472 if(this.recordType){
14473 this.fields = this.recordType.prototype.fields;
14476 this.modified = [];
14481 datachanged : true,
14505 loadexception : true
14509 this.proxy = Roo.factory(this.proxy, Roo.data);
14510 this.proxy.xmodule = this.xmodule || false;
14511 this.relayEvents(this.proxy, ["loadexception"]);
14514 this.sortToggle = {};
14516 Roo.data.Store.superclass.constructor.call(this);
14518 if(this.inlineData){
14519 this.loadData(this.inlineData);
14520 delete this.inlineData;
14523 Roo.extend(Roo.data.Store, Roo.util.Observable, {
14539 remoteSort : false,
14543 pruneModifiedRecords : false,
14546 lastOptions : null,
14552 for(var i = 0, len = B.length; i < len; i++){
14555 var C = this.data.length;
14556 this.data.addAll(B);
14557 this.fireEvent("add", this, B, C);
14562 remove : function(D){
14563 var E = this.data.indexOf(D);
14564 this.data.removeAt(E);
14565 if(this.pruneModifiedRecords){
14566 this.modified.remove(D);
14569 this.fireEvent("remove", this, D, E);
14574 removeAll : function(){
14576 if(this.pruneModifiedRecords){
14577 this.modified = [];
14580 this.fireEvent("clear", this);
14585 insert : function(F, G){
14587 for(var i = 0, len = G.length; i < len; i++){
14588 this.data.insert(F, G[i]);
14592 this.fireEvent("add", this, G, F);
14597 indexOf : function(H){
14598 return this.data.indexOf(H);
14603 indexOfId : function(id){
14604 return this.data.indexOfKey(id);
14609 getById : function(id){
14610 return this.data.key(id);
14615 getAt : function(I){
14616 return this.data.itemAt(I);
14621 getRange : function(J, K){
14622 return this.data.getRange(J, K);
14626 storeOptions : function(o){
14627 o = Roo.apply({}, o);
14630 this.lastOptions = o;
14635 load : function(L){
14637 if(this.fireEvent("beforeload", this, L) !== false){
14638 this.storeOptions(L);
14639 var p = Roo.apply(L.params || {}, this.baseParams);
14640 if(this.sortInfo && this.remoteSort){
14641 var pn = this.paramNames;
14642 p[pn["sort"]] = this.sortInfo.field;
14643 p[pn["dir"]] = this.sortInfo.direction;
14646 this.proxy.load(p, this.reader, this.loadRecords, this, L);
14652 reload : function(M){
14653 this.load(Roo.applyIf(M||{}, this.lastOptions));
14658 loadRecords : function(o, N, O){
14659 if(!o || O === false){
14661 this.fireEvent("load", this, [], N);
14664 N.callback.call(N.scope || this, [], N, false);
14669 if (o.success === false) {
14670 this.fireEvent("loadexception", this, o, N, this.reader.jsonData);
14673 var r = o.records, t = o.totalRecords || r.length;
14674 if(!N || N.add !== true){
14675 if(this.pruneModifiedRecords){
14676 this.modified = [];
14678 for(var i = 0, len = r.length; i < len; i++){
14682 this.data = this.snapshot;
14683 delete this.snapshot;
14687 this.data.addAll(r);
14688 this.totalLength = t;
14690 this.fireEvent("datachanged", this);
14692 this.totalLength = Math.max(t, this.data.length+r.length);
14696 this.fireEvent("load", this, r, N);
14698 N.callback.call(N.scope || this, r, N, true);
14704 loadData : function(o, P){
14705 var r = this.reader.readRecords(o);
14706 this.loadRecords(r, {add: P}, true);
14711 getCount : function(){
14712 return this.data.length || 0;
14717 getTotalCount : function(){
14718 return this.totalLength || 0;
14723 getSortState : function(){
14724 return this.sortInfo;
14728 applySort : function(){
14729 if(this.sortInfo && !this.remoteSort){
14730 var s = this.sortInfo, f = s.field;
14731 var st = this.fields.get(f).sortType;
14732 var fn = function(r1, r2){
14733 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
14734 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
14736 this.data.sort(s.direction, fn);
14737 if(this.snapshot && this.snapshot != this.data){
14738 this.snapshot.sort(s.direction, fn);
14745 setDefaultSort : function(Q, R){
14746 this.sortInfo = {field: Q, direction: R ? R.toUpperCase() : "ASC"};
14751 sort : function(S, T){
14752 var f = this.fields.get(S);
14754 if(this.sortInfo && this.sortInfo.field == f.name){
14755 T = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
14761 this.sortToggle[f.name] = T;
14762 this.sortInfo = {field: f.name, direction: T};
14763 if(!this.remoteSort){
14765 this.fireEvent("datachanged", this);
14767 this.load(this.lastOptions);
14773 each : function(fn, U){
14774 this.data.each(fn, U);
14779 getModifiedRecords : function(){
14780 return this.modified;
14784 createFilterFn : function(V, W, X){
14791 W = new RegExp((X === true ? '' : '^') + Roo.escapeRe(W), "i");
14793 return function(r){
14794 return W.test(r.data[V]);
14800 sum : function(Y, Z, a){
14801 var rs = this.data.items, v = 0;
14803 a = (a || a === 0) ? a : rs.length-1;
14805 for(var i = Z; i <= a; i++){
14806 v += (rs[i].data[Y] || 0);
14813 filter : function(b, c, d){
14814 var fn = this.createFilterFn(b, c, d);
14815 return fn ? this.filterBy(fn) : this.clearFilter();
14820 filterBy : function(fn, e){
14821 this.snapshot = this.snapshot || this.data;
14822 this.data = this.queryBy(fn, e||this);
14823 this.fireEvent("datachanged", this);
14828 query : function(g, h, j){
14829 var fn = this.createFilterFn(g, h, j);
14830 return fn ? this.queryBy(fn) : this.data.clone();
14835 queryBy : function(fn, k){
14836 var l = this.snapshot || this.data;
14837 return l.filterBy(fn, k||this);
14842 collect : function(m, n, q){
14843 var d = (q === true && this.snapshot) ?
14844 this.snapshot.items : this.data.items;
14845 var v, sv, r = [], l = {};
14846 for(var i = 0, len = d.length; i < len; i++){
14849 if((n || !Roo.isEmpty(v)) && !l[sv]){
14859 clearFilter : function(u){
14860 if(this.snapshot && this.snapshot != this.data){
14861 this.data = this.snapshot;
14862 delete this.snapshot;
14864 this.fireEvent("datachanged", this);
14870 afterEdit : function(w){
14871 if(this.modified.indexOf(w) == -1){
14872 this.modified.push(w);
14875 this.fireEvent("update", this, w, Roo.data.Record.EDIT);
14879 afterReject : function(x){
14880 this.modified.remove(x);
14881 this.fireEvent("update", this, x, Roo.data.Record.REJECT);
14885 afterCommit : function(y){
14886 this.modified.remove(y);
14887 this.fireEvent("update", this, y, Roo.data.Record.COMMIT);
14892 commitChanges : function(){
14893 var m = this.modified.slice(0);
14894 this.modified = [];
14895 for(var i = 0, len = m.length; i < len; i++){
14902 rejectChanges : function(){
14903 var m = this.modified.slice(0);
14904 this.modified = [];
14905 for(var i = 0, len = m.length; i < len; i++){
14910 onMetaChange : function(z, AA, o){
14911 this.recordType = AA;
14912 this.fields = AA.prototype.fields;
14913 delete this.snapshot;
14914 this.sortInfo = z.sortInfo;
14915 this.modified = [];
14916 this.fireEvent('metachange', this, this.reader.meta);
14924 Roo.data.SimpleStore = function(A){
14925 Roo.data.SimpleStore.superclass.constructor.call(this, {
14927 reader: new Roo.data.ArrayReader({
14930 Roo.data.Record.create(A.fields)
14932 proxy : new Roo.data.MemoryProxy(A.data)
14936 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);
14942 Roo.data.JsonStore = function(c){
14943 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
14944 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
14945 reader: new Roo.data.JsonReader(c, c.fields)
14948 Roo.extend(Roo.data.JsonStore, Roo.data.Store);
14953 Roo.data.Field = function(A){
14954 if(typeof A == "string"){
14958 Roo.apply(this, A);
14961 this.type = "auto";
14964 var st = Roo.data.SortTypes;
14966 if(typeof this.sortType == "string"){
14967 this.sortType = st[this.sortType];
14971 if(!this.sortType){
14974 this.sortType = st.asUCString;
14977 this.sortType = st.asDate;
14980 this.sortType = st.none;
14990 var cv, dateFormat = this.dateFormat;
14995 cv = function(v){ return v; };
14998 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
15002 return v !== undefined && v !== null && v !== '' ?
15003 parseInt(String(v).replace(B, ""), 10) : '';
15008 return v !== undefined && v !== null && v !== '' ?
15009 parseFloat(String(v).replace(B, ""), 10) : '';
15014 cv = function(v){ return v === true || v === "true" || v == 1; };
15021 if(v instanceof Date){
15025 if(dateFormat == "timestamp"){
15026 return new Date(v*1000);
15028 return Date.parseDate(v, dateFormat);
15030 var C = Date.parse(v);
15031 return C ? new Date(C) : null;
15041 Roo.data.Field.prototype = {
15057 Roo.data.DataReader = function(A, B){
15061 this.recordType = B instanceof Array ?
15062 Roo.data.Record.create(B) : B;
15065 Roo.data.DataReader.prototype = {
15068 newRow : function(d) {
15070 this.recordType.prototype.fields.each(function(c) {
15072 case 'int' : da[c.name] = 0; break;
15073 case 'date' : da[c.name] = new Date(); break;
15074 case 'float' : da[c.name] = 0.0; break;
15075 case 'boolean' : da[c.name] = false; break;
15076 default : da[c.name] = ""; break;
15080 return new this.recordType(Roo.apply(da, d));
15089 Roo.data.DataProxy = function(){
15099 loadexception : true
15101 Roo.data.DataProxy.superclass.constructor.call(this);
15104 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
15113 Roo.data.MemoryProxy = function(A){
15118 Roo.data.MemoryProxy.superclass.constructor.call(this);
15122 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
15125 load : function(B, C, D, E, F){
15129 G = C.readRecords(this.data);
15131 this.fireEvent("loadexception", this, arg, null, e);
15132 callback.call(scope, null, arg, false);
15136 D.call(E, G, F, true);
15140 update : function(H, I){
15148 Roo.data.HttpProxy = function(A){
15149 Roo.data.HttpProxy.superclass.constructor.call(this);
15152 this.useAjax = !A || !A.events;
15156 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
15177 getConnection : function(){
15178 return this.useAjax ? Roo.Ajax : this.conn;
15183 load : function(B, C, D, E, F){
15184 if(this.fireEvent("beforeload", this, B) !== false){
15193 callback : this.loadResponse,
15197 Roo.applyIf(o, this.conn);
15198 if(this.activeRequest){
15199 Roo.Ajax.abort(this.activeRequest);
15202 this.activeRequest = Roo.Ajax.request(o);
15204 this.conn.request(o);
15207 D.call(E||this, null, F, false);
15212 loadResponse : function(o, G, H){
15213 delete this.activeRequest;
15215 this.fireEvent("loadexception", this, o, H);
15216 o.request.callback.call(o.request.scope, null, o.request.arg, false);
15221 I = o.reader.read(H);
15223 this.fireEvent("loadexception", this, o, response, e);
15224 o.request.callback.call(o.request.scope, null, o.request.arg, false);
15229 this.fireEvent("load", this, o, o.request.arg);
15230 o.request.callback.call(o.request.scope, I, o.request.arg, true);
15234 update : function(J){
15239 updateResponse : function(K){
15248 Roo.data.ScriptTagProxy = function(A){
15249 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
15250 Roo.apply(this, A);
15251 this.head = document.getElementsByTagName("head")[0];
15254 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
15256 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
15264 callbackParam : "callback",
15271 load : function(B, C, D, E, F){
15272 if(this.fireEvent("beforeload", this, B) !== false){
15274 var p = Roo.urlEncode(Roo.apply(B, this.extraParams));
15276 var url = this.url;
15277 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
15279 url += "&_dc=" + (new Date().getTime());
15281 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
15284 cb : "stcCallback"+transId,
15285 scriptId : "stcScript"+transId,
15295 window[trans.cb] = function(o){
15296 conn.handleResponse(o, trans);
15299 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
15301 if(this.autoAbort !== false){
15306 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
15308 var script = document.createElement("script");
15309 script.setAttribute("src", url);
15310 script.setAttribute("type", "text/javascript");
15311 script.setAttribute("id", trans.scriptId);
15312 this.head.appendChild(script);
15314 this.trans = trans;
15316 D.call(E||this, null, F, false);
15321 isLoading : function(){
15322 return this.trans ? true : false;
15327 abort : function(){
15328 if(this.isLoading()){
15329 this.destroyTrans(this.trans);
15334 destroyTrans : function(G, H){
15335 this.head.removeChild(document.getElementById(G.scriptId));
15336 clearTimeout(G.timeoutId);
15338 window[G.cb] = undefined;
15340 delete window[G.cb];
15344 window[G.cb] = function(){
15345 window[G.cb] = undefined;
15347 delete window[G.cb];
15354 handleResponse : function(o, I){
15355 this.trans = false;
15356 this.destroyTrans(I, true);
15359 J = I.reader.readRecords(o);
15361 this.fireEvent("loadexception", this, o, trans.arg, e);
15362 trans.callback.call(trans.scope||window, null, trans.arg, false);
15366 this.fireEvent("load", this, o, I.arg);
15367 I.callback.call(I.scope||window, J, I.arg, true);
15371 handleFailure : function(K){
15372 this.trans = false;
15373 this.destroyTrans(K, false);
15374 this.fireEvent("loadexception", this, null, K.arg);
15375 K.callback.call(K.scope||window, null, K.arg, false);
15383 Roo.data.JsonReader = function(meta, recordType){
15387 Roo.applyIf(meta, {
15388 totalProperty: 'total',
15389 successProperty : 'success',
15394 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
15396 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
15399 read : function(response){
15400 var json = response.responseText;
15403 var o = eval("("+json+")");
15405 throw {message: "JsonReader.read: Json object not found"};
15410 this.meta = o.metaData;
15411 this.recordType = Roo.data.Record.create(o.metaData.fields);
15412 this.onMetaChange(this.meta, this.recordType, o);
15414 return this.readRecords(o);
15418 onMetaChange : function(meta, recordType, o){
15424 simpleAccess: function(obj, subsc) {
15430 getJsonAccessor: function(){
15432 return function(expr) {
15434 return (re.test(expr))
15435 ? new Function("obj", "return obj." + expr)
15440 return Roo.emptyFn;
15446 readRecords : function(o){
15450 var s = this.meta, Record = this.recordType,
15451 f = Record.prototype.fields, fi = f.items, fl = f.length;
15455 if(s.totalProperty) {
15456 this.getTotal = this.getJsonAccessor(s.totalProperty);
15458 if(s.successProperty) {
15459 this.getSuccess = this.getJsonAccessor(s.successProperty);
15462 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
15464 var g = this.getJsonAccessor(s.id);
15465 this.getId = function(rec) {
15467 return (r === undefined || r === "") ? null : r;
15470 this.getId = function(){return null;};
15474 for(var i = 0; i < fl; i++){
15476 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
15477 this.ef[i] = this.getJsonAccessor(map);
15481 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
15482 if(s.totalProperty){
15483 var v = parseInt(this.getTotal(o), 10);
15488 if(s.successProperty){
15489 var v = this.getSuccess(o);
15490 if(v === false || v === 'false'){
15495 for(var i = 0; i < c; i++){
15498 var id = this.getId(n);
15499 for(var j = 0; j < fl; j++){
15501 var v = this.ef[j](n);
15502 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
15504 var record = new Record(values, id);
15506 records[i] = record;
15511 totalRecords : totalRecords
15520 Roo.data.XmlReader = function(A, B){
15522 Roo.data.XmlReader.superclass.constructor.call(this, A, B||A.fields);
15524 Roo.extend(Roo.data.XmlReader, Roo.data.DataReader, {
15527 read : function(C){
15528 var D = C.responseXML;
15530 throw {message: "XmlReader.read: XML Document not available"};
15532 return this.readRecords(D);
15537 readRecords : function(E){
15541 var F = E.documentElement || E;
15542 var q = Roo.DomQuery;
15543 var G = this.recordType, H = G.prototype.fields;
15544 var I = this.meta.id;
15545 var J = 0, K = true;
15546 if(this.meta.totalRecords){
15547 J = q.selectNumber(this.meta.totalRecords, F, 0);
15550 if(this.meta.success){
15551 var sv = q.selectValue(this.meta.success, F, true);
15552 K = sv !== false && sv !== 'false';
15555 var ns = q.select(this.meta.record, F);
15556 for(var i = 0, len = ns.length; i < len; i++) {
15559 var id = I ? q.selectValue(I, n) : undefined;
15560 for(var j = 0, jlen = H.length; j < jlen; j++){
15561 var f = H.items[j];
15562 var v = q.selectValue(f.mapping || f.name, n, f.defaultValue);
15564 values[f.name] = v;
15566 var record = new G(values, id);
15568 L[L.length] = record;
15574 totalRecords : J || L.length
15583 Roo.data.ArrayReader = function(A, B){
15584 Roo.data.ArrayReader.superclass.constructor.call(this, A, B);
15587 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
15590 readRecords : function(o){
15591 var C = this.meta ? this.meta.id : null;
15592 var D = this.recordType, E = D.prototype.fields;
15595 for(var i = 0; i < G.length; i++){
15598 var id = ((C || C === 0) && n[C] !== undefined && n[C] !== "" ? n[C] : null);
15599 for(var j = 0, jlen = E.length; j < jlen; j++){
15600 var f = E.items[j];
15601 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
15602 var v = n[k] !== undefined ? n[k] : f.defaultValue;
15604 values[f.name] = v;
15606 var record = new D(values, id);
15608 F[F.length] = record;
15612 totalRecords : F.length
15622 Roo.data.Tree = function(A){
15623 this.nodeHash = {};
15628 this.setRootNode(A);
15646 "beforeappend" : true,
15649 "beforeremove" : true,
15652 "beforemove" : true,
15655 "beforeinsert" : true
15658 Roo.data.Tree.superclass.constructor.call(this);
15661 Roo.extend(Roo.data.Tree, Roo.util.Observable, {
15662 pathSeparator: "/",
15664 proxyNodeEvent : function(){
15665 return this.fireEvent.apply(this, arguments);
15670 getRootNode : function(){
15676 setRootNode : function(B){
15678 B.ownerTree = this;
15680 this.registerNode(B);
15686 getNodeById : function(id){
15687 return this.nodeHash[id];
15690 registerNode : function(C){
15691 this.nodeHash[C.id] = C;
15694 unregisterNode : function(D){
15695 delete this.nodeHash[D.id];
15698 toString : function(){
15699 return "[Tree"+(this.id?" "+this.id:"")+"]";
15705 Roo.data.Node = function(E){
15708 this.attributes = E || {};
15709 this.leaf = this.attributes.leaf;
15712 this.id = this.attributes.id;
15714 this.id = Roo.id(null, "ynode-");
15715 this.attributes.id = this.id;
15720 this.childNodes = [];
15721 if(!this.childNodes.indexOf){
15722 this.childNodes.indexOf = function(o){
15723 for(var i = 0, len = this.length; i < len; i++){
15724 if(this[i] == o) return i;
15732 this.parentNode = null;
15735 this.firstChild = null;
15738 this.lastChild = null;
15741 this.previousSibling = null;
15744 this.nextSibling = null;
15761 "beforeappend" : true,
15764 "beforeremove" : true,
15767 "beforemove" : true,
15770 "beforeinsert" : true
15772 this.listeners = this.attributes.listeners;
15773 Roo.data.Node.superclass.constructor.call(this);
15776 Roo.extend(Roo.data.Node, Roo.util.Observable, {
15777 fireEvent : function(F){
15779 if(Roo.data.Node.superclass.fireEvent.apply(this, arguments) === false){
15783 var ot = this.getOwnerTree();
15785 if(ot.proxyNodeEvent.apply(ot, arguments) === false){
15794 isLeaf : function(){
15795 return this.leaf === true;
15799 setFirstChild : function(G){
15800 this.firstChild = G;
15804 setLastChild : function(H){
15805 this.lastChild = H;
15811 isLast : function(){
15812 return (!this.parentNode ? true : this.parentNode.lastChild == this);
15817 isFirst : function(){
15818 return (!this.parentNode ? true : this.parentNode.firstChild == this);
15821 hasChildNodes : function(){
15822 return !this.isLeaf() && this.childNodes.length > 0;
15827 appendChild : function(I){
15829 if(I instanceof Array){
15831 }else if(arguments.length > 1){
15836 for(var i = 0, len = J.length; i < len; i++) {
15837 this.appendChild(J[i]);
15840 if(this.fireEvent("beforeappend", this.ownerTree, this, I) === false){
15843 var index = this.childNodes.length;
15844 var oldParent = I.parentNode;
15847 if(I.fireEvent("beforemove", I.getOwnerTree(), I, oldParent, this, index) === false){
15851 oldParent.removeChild(I);
15854 index = this.childNodes.length;
15856 this.setFirstChild(I);
15859 this.childNodes.push(I);
15860 I.parentNode = this;
15861 var ps = this.childNodes[index-1];
15863 I.previousSibling = ps;
15864 ps.nextSibling = I;
15866 I.previousSibling = null;
15869 I.nextSibling = null;
15870 this.setLastChild(I);
15871 I.setOwnerTree(this.getOwnerTree());
15872 this.fireEvent("append", this.ownerTree, this, I, index);
15874 I.fireEvent("move", this.ownerTree, I, oldParent, this, index);
15882 removeChild : function(K){
15883 var L = this.childNodes.indexOf(K);
15887 if(this.fireEvent("beforeremove", this.ownerTree, this, K) === false){
15893 this.childNodes.splice(L, 1);
15896 if(K.previousSibling){
15897 K.previousSibling.nextSibling = K.nextSibling;
15900 K.nextSibling.previousSibling = K.previousSibling;
15904 if(this.firstChild == K){
15905 this.setFirstChild(K.nextSibling);
15907 if(this.lastChild == K){
15908 this.setLastChild(K.previousSibling);
15912 K.setOwnerTree(null);
15914 K.parentNode = null;
15915 K.previousSibling = null;
15916 K.nextSibling = null;
15917 this.fireEvent("remove", this.ownerTree, this, K);
15923 insertBefore : function(M, N){
15925 return this.appendChild(M);
15932 if(this.fireEvent("beforeinsert", this.ownerTree, this, M, N) === false){
15935 var O = this.childNodes.indexOf(N);
15936 var P = M.parentNode;
15940 if(P == this && this.childNodes.indexOf(M) < O){
15946 if(M.fireEvent("beforemove", M.getOwnerTree(), M, P, this, O, N) === false){
15953 this.setFirstChild(M);
15956 this.childNodes.splice(Q, 0, M);
15957 M.parentNode = this;
15958 var ps = this.childNodes[Q-1];
15960 M.previousSibling = ps;
15961 ps.nextSibling = M;
15963 M.previousSibling = null;
15967 N.previousSibling = M;
15968 M.setOwnerTree(this.getOwnerTree());
15969 this.fireEvent("insert", this.ownerTree, this, M, N);
15971 M.fireEvent("move", this.ownerTree, M, P, this, Q, N);
15978 item : function(R){
15979 return this.childNodes[R];
15984 replaceChild : function(S, T){
15985 this.insertBefore(S, T);
15986 this.removeChild(T);
15992 indexOf : function(U){
15993 return this.childNodes.indexOf(U);
15998 getOwnerTree : function(){
16000 if(!this.ownerTree){
16004 this.ownerTree = p.ownerTree;
16011 return this.ownerTree;
16016 getDepth : function(){
16019 while(p.parentNode){
16027 setOwnerTree : function(W){
16029 if(W != this.ownerTree){
16030 if(this.ownerTree){
16031 this.ownerTree.unregisterNode(this);
16034 this.ownerTree = W;
16035 var cs = this.childNodes;
16036 for(var i = 0, len = cs.length; i < len; i++) {
16037 cs[i].setOwnerTree(W);
16040 W.registerNode(this);
16047 getPath : function(X){
16049 var p = this.parentNode;
16050 var b = [this.attributes[X]];
16052 b.unshift(p.attributes[X]);
16055 var Y = this.getOwnerTree().pathSeparator;
16056 return Y + b.join(Y);
16061 bubble : function(fn, Z, a){
16064 if(fn.call(Z || p, a || p) === false){
16074 cascade : function(fn, c, d){
16075 if(fn.call(c || this, d || this) !== false){
16076 var cs = this.childNodes;
16077 for(var i = 0, len = cs.length; i < len; i++) {
16078 cs[i].cascade(fn, c, d);
16085 eachChild : function(fn, e, f){
16086 var cs = this.childNodes;
16087 for(var i = 0, len = cs.length; i < len; i++) {
16088 if(fn.call(e || this, f || cs[i]) === false){
16096 findChild : function(g, h){
16097 var cs = this.childNodes;
16098 for(var i = 0, len = cs.length; i < len; i++) {
16099 if(cs[i].attributes[g] == h){
16108 findChildBy : function(fn, j){
16109 var cs = this.childNodes;
16110 for(var i = 0, len = cs.length; i < len; i++) {
16111 if(fn.call(j||cs[i], cs[i]) === true){
16120 sort : function(fn, k){
16121 var cs = this.childNodes;
16124 var sortFn = k ? function(){fn.apply(k, arguments);} : fn;
16126 for(var i = 0; i < l; i++){
16128 n.previousSibling = cs[i-1];
16129 n.nextSibling = cs[i+1];
16131 this.setFirstChild(n);
16134 this.setLastChild(n);
16142 contains : function(m){
16143 return m.isAncestor(this);
16148 isAncestor : function(o){
16149 var p = this.parentNode;
16160 toString : function(){
16161 return "[Node"+(this.id?" "+this.id:"")+"]";
16170 Roo.ComponentMgr = function(){
16171 var A = new Roo.util.MixedCollection();
16176 register : function(c){
16182 unregister : function(c){
16188 get : function(id){
16194 onAvailable : function(id, fn, C){
16195 A.on("add", function(D, o){
16197 fn.call(C || o, o);
16198 A.un("add", fn, C);
16209 Roo.Component = function(A){
16211 if(A.tagName || A.dom || typeof A == "string"){
16212 A = {el: A, id: A.id || A};
16215 this.initialConfig = A;
16217 Roo.apply(this, A);
16239 beforerender : true,
16245 beforedestroy : true,
16251 this.id = "ext-comp-" + (++Roo.Component.AUTO_ID);
16254 Roo.ComponentMgr.register(this);
16255 Roo.Component.superclass.constructor.call(this);
16256 this.initComponent();
16258 this.render(this.renderTo);
16259 delete this.renderTo;
16264 Roo.Component.AUTO_ID = 1000;
16266 Roo.extend(Roo.Component, Roo.util.Observable, {
16279 disabledClass : "x-item-disabled",
16282 allowDomMove : true,
16285 hideMode: 'display',
16288 ctype : "Roo.Component",
16295 getActionEl : function(){
16296 return this[this.actionMode];
16299 initComponent : Roo.emptyFn,
16302 render : function(B, C){
16303 if(!this.rendered && this.fireEvent("beforerender", this) !== false){
16305 this.el = Roo.get(this.el);
16306 B = this.el.dom.parentNode;
16307 this.allowDomMove = false;
16310 this.container = Roo.get(B);
16311 this.rendered = true;
16312 if(C !== undefined){
16313 if(typeof C == 'number'){
16314 C = this.container.dom.childNodes[C];
16320 this.onRender(this.container, C || null);
16322 this.el.addClass(this.cls);
16326 this.el.applyStyles(this.style);
16330 this.fireEvent("render", this);
16331 this.afterRender(this.container);
16344 onRender : function(ct, D){
16346 this.el = Roo.get(this.el);
16347 if(this.allowDomMove !== false){
16348 ct.dom.insertBefore(this.el.dom, D);
16354 getAutoCreate : function(){
16355 var E = typeof this.autoCreate == "object" ?
16356 this.autoCreate : Roo.apply({}, this.defaultAutoCreate);
16357 if(this.id && !E.id){
16364 afterRender : Roo.emptyFn,
16368 destroy : function(){
16369 if(this.fireEvent("beforedestroy", this) !== false){
16370 this.purgeListeners();
16371 this.beforeDestroy();
16373 this.el.removeAllListeners();
16375 if(this.actionMode == "container"){
16376 this.container.remove();
16381 Roo.ComponentMgr.unregister(this);
16382 this.fireEvent("destroy", this);
16387 beforeDestroy : function(){
16392 onDestroy : function(){
16398 getEl : function(){
16404 getId : function(){
16410 focus : function(F){
16414 this.el.dom.select();
16430 disable : function(){
16435 this.disabled = true;
16436 this.fireEvent("disable", this);
16441 onDisable : function(){
16442 this.getActionEl().addClass(this.disabledClass);
16443 this.el.dom.disabled = true;
16448 enable : function(){
16453 this.disabled = false;
16454 this.fireEvent("enable", this);
16459 onEnable : function(){
16460 this.getActionEl().removeClass(this.disabledClass);
16461 this.el.dom.disabled = false;
16466 setDisabled : function(G){
16467 this[G ? "disable" : "enable"]();
16473 if(this.fireEvent("beforeshow", this) !== false){
16474 this.hidden = false;
16479 this.fireEvent("show", this);
16485 onShow : function(){
16486 var ae = this.getActionEl();
16487 if(this.hideMode == 'visibility'){
16488 ae.dom.style.visibility = "visible";
16489 }else if(this.hideMode == 'offsets'){
16490 ae.removeClass('x-hidden');
16492 ae.dom.style.display = "";
16499 if(this.fireEvent("beforehide", this) !== false){
16500 this.hidden = true;
16505 this.fireEvent("hide", this);
16511 onHide : function(){
16512 var ae = this.getActionEl();
16513 if(this.hideMode == 'visibility'){
16514 ae.dom.style.visibility = "hidden";
16515 }else if(this.hideMode == 'offsets'){
16516 ae.addClass('x-hidden');
16518 ae.dom.style.display = "none";
16524 setVisible: function(H){
16535 isVisible : function(){
16536 return this.getActionEl().isVisible();
16539 cloneConfig : function(I){
16541 var id = I.id || Roo.id();
16542 var J = Roo.applyIf(I, this.initialConfig);
16544 return new this.constructor(J);
16553 Roo.Layer = function(C, D){
16555 var dh = Roo.DomHelper;
16556 var cp = C.parentEl, E = cp ? Roo.getDom(cp) : document.body;
16558 this.dom = Roo.getDom(D);
16561 var o = C.dh || {tag: "div", cls: "x-layer"};
16562 this.dom = dh.append(E, o);
16565 this.addClass(C.cls);
16568 this.constrain = C.constrain !== false;
16569 this.visibilityMode = Roo.Element.VISIBILITY;
16571 this.id = this.dom.id = C.id;
16573 this.id = Roo.id(this.dom);
16576 this.zindex = C.zindex || this.getZIndex();
16577 this.position("absolute", this.zindex);
16579 this.shadowOffset = C.shadowOffset || 4;
16580 this.shadow = new Roo.Shadow({
16581 offset : this.shadowOffset,
16585 this.shadowOffset = 0;
16588 this.useShim = C.shim !== false && Roo.useShims;
16589 this.useDisplay = C.useDisplay;
16593 var A = Roo.Element.prototype;
16598 Roo.extend(Roo.Layer, Roo.Element, {
16600 getZIndex : function(){
16601 return this.zindex || parseInt(this.getStyle("z-index"), 10) || 11000;
16604 getShim : function(){
16613 C = this.createShim();
16614 C.enableDisplayMode('block');
16615 C.dom.style.display = 'none';
16616 C.dom.style.visibility = 'visible';
16618 var pn = this.dom.parentNode;
16619 if(C.dom.parentNode != pn){
16620 pn.insertBefore(C.dom, this.dom);
16623 C.setStyle('z-index', this.getZIndex()-2);
16628 hideShim : function(){
16630 this.shim.setDisplayed(false);
16636 disableShadow : function(){
16638 this.shadowDisabled = true;
16639 this.shadow.hide();
16640 this.lastShadowOffset = this.shadowOffset;
16641 this.shadowOffset = 0;
16645 enableShadow : function(D){
16647 this.shadowDisabled = false;
16648 this.shadowOffset = this.lastShadowOffset;
16649 delete this.lastShadowOffset;
16659 sync : function(E){
16660 var sw = this.shadow;
16661 if(!this.updating && this.isVisible() && (sw || this.useShim)){
16662 var sh = this.getShim();
16664 var w = this.getWidth(),
16665 h = this.getHeight();
16667 var l = this.getLeft(true),
16668 t = this.getTop(true);
16670 if(sw && !this.shadowDisabled){
16671 if(E && !sw.isVisible()){
16674 sw.realign(l, t, w, h);
16681 var a = sw.adjusts, s = sh.dom.style;
16682 s.left = (Math.min(l, l+a.l))+"px";
16683 s.top = (Math.min(t, t+a.t))+"px";
16684 s.width = (w+a.w)+"px";
16685 s.height = (h+a.h)+"px";
16693 sh.setLeftTop(l, t);
16700 destroy : function(){
16703 this.shadow.hide();
16706 this.removeAllListeners();
16707 var pn = this.dom.parentNode;
16709 pn.removeChild(this.dom);
16712 Roo.Element.uncache(this.id);
16715 remove : function(){
16720 beginUpdate : function(){
16721 this.updating = true;
16725 endUpdate : function(){
16726 this.updating = false;
16731 hideUnders : function(F){
16733 this.shadow.hide();
16740 constrainXY : function(){
16741 if(this.constrain){
16742 var vw = Roo.lib.Dom.getViewWidth(),
16743 vh = Roo.lib.Dom.getViewHeight();
16744 var s = Roo.get(document).getScroll();
16746 var xy = this.getXY();
16747 var x = xy[0], y = xy[1];
16748 var w = this.dom.offsetWidth+this.shadowOffset, h = this.dom.offsetHeight+this.shadowOffset;
16752 if((x + w) > vw+s.left){
16753 x = vw - w - this.shadowOffset;
16756 if((y + h) > vh+s.top){
16757 y = vh - h - this.shadowOffset;
16771 var ay = this.avoidY;
16772 if(y <= ay && (y+h) >= ay){
16779 A.setXY.call(this, xy);
16785 isVisible : function(){
16786 return this.visible;
16790 showAction : function(){
16791 this.visible = true;
16792 if(this.useDisplay === true){
16793 this.setDisplayed("");
16794 }else if(this.lastXY){
16795 A.setXY.call(this, this.lastXY);
16796 }else if(this.lastLT){
16797 A.setLeftTop.call(this, this.lastLT[0], this.lastLT[1]);
16802 hideAction : function(){
16803 this.visible = false;
16804 if(this.useDisplay === true){
16805 this.setDisplayed(false);
16807 this.setLeftTop(-10000,-10000);
16812 setVisible : function(v, a, d, c, e){
16817 var cb = function(){
16822 }.createDelegate(this);
16823 A.setVisible.call(this, true, true, d, cb, e);
16826 this.hideUnders(true);
16835 }.createDelegate(this);
16838 A.setVisible.call(this, v, a, d, cb, e);
16847 storeXY : function(xy){
16848 delete this.lastLT;
16852 storeLeftTop : function(G, H){
16853 delete this.lastXY;
16854 this.lastLT = [G, H];
16858 beforeFx : function(){
16859 this.beforeAction();
16860 return Roo.Layer.superclass.beforeFx.apply(this, arguments);
16864 afterFx : function(){
16865 Roo.Layer.superclass.afterFx.apply(this, arguments);
16866 this.sync(this.isVisible());
16870 beforeAction : function(){
16871 if(!this.updating && this.shadow){
16872 this.shadow.hide();
16877 setLeft : function(I){
16878 this.storeLeftTop(I, this.getTop(true));
16879 A.setLeft.apply(this, arguments);
16883 setTop : function(J){
16884 this.storeLeftTop(this.getLeft(true), J);
16885 A.setTop.apply(this, arguments);
16889 setLeftTop : function(K, L){
16890 this.storeLeftTop(K, L);
16891 A.setLeftTop.apply(this, arguments);
16895 setXY : function(xy, a, d, c, e){
16897 this.beforeAction();
16899 var cb = this.createCB(c);
16900 A.setXY.call(this, xy, a, d, cb, e);
16907 createCB : function(c){
16919 setX : function(x, a, d, c, e){
16920 this.setXY([x, this.getY()], a, d, c, e);
16924 setY : function(y, a, d, c, e){
16925 this.setXY([this.getX(), y], a, d, c, e);
16929 setSize : function(w, h, a, d, c, e){
16930 this.beforeAction();
16931 var cb = this.createCB(c);
16932 A.setSize.call(this, w, h, a, d, cb, e);
16939 setWidth : function(w, a, d, c, e){
16940 this.beforeAction();
16941 var cb = this.createCB(c);
16942 A.setWidth.call(this, w, a, d, cb, e);
16949 setHeight : function(h, a, d, c, e){
16950 this.beforeAction();
16951 var cb = this.createCB(c);
16952 A.setHeight.call(this, h, a, d, cb, e);
16959 setBounds : function(x, y, w, h, a, d, c, e){
16960 this.beforeAction();
16961 var cb = this.createCB(c);
16963 this.storeXY([x, y]);
16964 A.setXY.call(this, [x, y]);
16965 A.setSize.call(this, w, h, a, d, cb, e);
16968 A.setBounds.call(this, x, y, w, h, a, d, cb, e);
16975 setZIndex : function(M){
16977 this.setStyle("z-index", M + 2);
16979 this.shadow.setZIndex(M + 1);
16982 this.shim.setStyle("z-index", M);
16993 Roo.Shadow = function(A){
16994 Roo.apply(this, A);
16995 if(typeof this.mode != "string"){
16996 this.mode = this.defaultMode;
16998 var o = this.offset, a = {h: 0};
16999 var B = Math.floor(this.offset/2);
17000 switch(this.mode.toLowerCase()){
17006 a.l -= this.offset + B;
17007 a.t -= this.offset + B;
17018 a.l -= (this.offset - B);
17019 a.t -= this.offset + B;
17021 a.w -= (this.offset - B)*2;
17032 a.l -= (this.offset - B);
17033 a.t -= (this.offset - B);
17035 a.w -= (this.offset + B + 1);
17036 a.h -= (this.offset + B);
17045 Roo.Shadow.prototype = {
17053 defaultMode: "drop",
17057 show : function(C){
17060 this.el = Roo.Shadow.Pool.pull();
17061 if(this.el.dom.nextSibling != C.dom){
17062 this.el.insertBefore(C);
17066 this.el.setStyle("z-index", this.zIndex || parseInt(C.getStyle("z-index"), 10)-1);
17068 this.el.dom.style.filter="progid:DXImageTransform.Microsoft.alpha(opacity=50) progid:DXImageTransform.Microsoft.Blur(pixelradius="+(this.offset)+")";
17077 this.el.dom.style.display = "block";
17082 isVisible : function(){
17083 return this.el ? true : false;
17088 realign : function(l, t, w, h){
17092 var a = this.adjusts, d = this.el.dom, s = d.style;
17094 s.left = (l+a.l)+"px";
17095 s.top = (t+a.t)+"px";
17096 var sw = (w+a.w), sh = (h+a.h), E = sw +"px", F = sh + "px";
17097 if(s.width != E || s.height != F){
17101 var cn = d.childNodes;
17102 var sww = Math.max(0, (sw-12))+"px";
17103 cn[0].childNodes[1].style.width = sww;
17104 cn[1].childNodes[1].style.width = sww;
17105 cn[2].childNodes[1].style.width = sww;
17106 cn[1].style.height = Math.max(0, (sh-12))+"px";
17115 this.el.dom.style.display = "none";
17116 Roo.Shadow.Pool.push(this.el);
17123 setZIndex : function(z){
17126 this.el.setStyle("z-index", z);
17132 Roo.Shadow.Pool = function(){
17135 '<div class="x-ie-shadow"></div>' :
17136 '<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>';
17139 var sh = p.shift();
17141 sh = Roo.get(Roo.DomHelper.insertHtml("beforeBegin", document.body.firstChild, G));
17142 sh.autoBoxAdjust = false;
17147 push : function(sh){
17157 Roo.BoxComponent = function(A){
17158 Roo.Component.call(this, A);
17169 Roo.extend(Roo.BoxComponent, Roo.Component, {
17173 deferHeight: false,
17181 setSize : function(w, h){
17183 if(typeof w == 'object'){
17188 if(!this.boxReady){
17195 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
17199 this.lastSize = {width: w, height: h};
17201 var B = this.adjustSize(w, h);
17202 var aw = B.width, ah = B.height;
17203 if(aw !== undefined || ah !== undefined){
17204 var rz = this.getResizeEl();
17205 if(!this.deferHeight && aw !== undefined && ah !== undefined){
17206 rz.setSize(aw, ah);
17207 }else if(!this.deferHeight && ah !== undefined){
17209 }else if(aw !== undefined){
17213 this.onResize(aw, ah, w, h);
17214 this.fireEvent('resize', this, aw, ah, w, h);
17221 getSize : function(){
17222 return this.el.getSize();
17227 getPosition : function(C){
17229 return [this.el.getLeft(true), this.el.getTop(true)];
17231 return this.xy || this.el.getXY();
17236 getBox : function(D){
17237 var s = this.el.getSize();
17239 s.x = this.el.getLeft(true);
17240 s.y = this.el.getTop(true);
17242 var xy = this.xy || this.el.getXY();
17251 updateBox : function(E){
17252 this.setSize(E.width, E.height);
17253 this.setPagePosition(E.x, E.y);
17258 getResizeEl : function(){
17259 return this.resizeEl || this.el;
17263 getPositionEl : function(){
17264 return this.positionEl || this.el;
17269 setPosition : function(x, y){
17272 if(!this.boxReady){
17275 var F = this.adjustPosition(x, y);
17276 var ax = F.x, ay = F.y;
17278 var el = this.getPositionEl();
17279 if(ax !== undefined || ay !== undefined){
17280 if(ax !== undefined && ay !== undefined){
17281 el.setLeftTop(ax, ay);
17282 }else if(ax !== undefined){
17284 }else if(ay !== undefined){
17288 this.onPosition(ax, ay);
17289 this.fireEvent('move', this, ax, ay);
17296 setPagePosition : function(x, y){
17299 if(!this.boxReady){
17302 if(x === undefined || y === undefined){
17305 var p = this.el.translatePoints(x, y);
17306 this.setPosition(p.left, p.top);
17311 onRender : function(ct, G){
17312 Roo.BoxComponent.superclass.onRender.call(this, ct, G);
17314 this.resizeEl = Roo.get(this.resizeEl);
17316 if(this.positionEl){
17317 this.positionEl = Roo.get(this.positionEl);
17322 afterRender : function(){
17323 Roo.BoxComponent.superclass.afterRender.call(this);
17324 this.boxReady = true;
17325 this.setSize(this.width, this.height);
17326 if(this.x || this.y){
17327 this.setPosition(this.x, this.y);
17329 if(this.pageX || this.pageY){
17330 this.setPagePosition(this.pageX, this.pageY);
17336 syncSize : function(){
17337 delete this.lastSize;
17338 this.setSize(this.el.getWidth(), this.el.getHeight());
17344 onResize : function(H, I, J, K){
17350 onPosition : function(x, y){
17355 adjustSize : function(w, h){
17356 if(this.autoWidth){
17359 if(this.autoHeight){
17362 return {width : w, height: h};
17366 adjustPosition : function(x, y){
17367 return {x : x, y: y};
17376 Roo.SplitBar = function(A, B, C, D, E){
17380 this.el = Roo.get(A, true);
17381 this.el.dom.unselectable = "on";
17384 this.resizingEl = Roo.get(B, true);
17388 this.orientation = C || Roo.SplitBar.HORIZONTAL;
17396 this.maxSize = 2000;
17400 this.animate = false;
17404 this.useShim = false;
17413 this.proxy = Roo.SplitBar.createProxy(this.orientation);
17415 this.proxy = Roo.get(E).dom;
17420 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
17424 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
17428 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
17432 this.dragSpecs = {};
17436 this.adapter = new Roo.SplitBar.BasicLayoutAdapter();
17437 this.adapter.init(this);
17439 if(this.orientation == Roo.SplitBar.HORIZONTAL){
17442 this.placement = D || (this.el.getX() > this.resizingEl.getX() ? Roo.SplitBar.LEFT : Roo.SplitBar.RIGHT);
17443 this.el.addClass("x-splitbar-h");
17447 this.placement = D || (this.el.getY() > this.resizingEl.getY() ? Roo.SplitBar.TOP : Roo.SplitBar.BOTTOM);
17448 this.el.addClass("x-splitbar-v");
17461 "beforeresize" : true,
17463 "beforeapply" : true
17466 Roo.util.Observable.call(this);
17469 Roo.extend(Roo.SplitBar, Roo.util.Observable, {
17470 onStartProxyDrag : function(x, y){
17471 this.fireEvent("beforeresize", this);
17473 var o = Roo.DomHelper.insertFirst(document.body, {cls: "x-drag-overlay", html: " "}, true);
17475 o.enableDisplayMode("block");
17477 Roo.SplitBar.prototype.overlay = o;
17480 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
17481 this.overlay.show();
17482 Roo.get(this.proxy).setDisplayed("block");
17483 var F = this.adapter.getElementSize(this);
17484 this.activeMinSize = this.getMinimumSize();;
17485 this.activeMaxSize = this.getMaximumSize();;
17486 var c1 = F - this.activeMinSize;
17487 var c2 = Math.max(this.activeMaxSize - F, 0);
17488 if(this.orientation == Roo.SplitBar.HORIZONTAL){
17489 this.dd.resetConstraints();
17490 this.dd.setXConstraint(
17491 this.placement == Roo.SplitBar.LEFT ? c1 : c2,
17492 this.placement == Roo.SplitBar.LEFT ? c2 : c1
17494 this.dd.setYConstraint(0, 0);
17496 this.dd.resetConstraints();
17497 this.dd.setXConstraint(0, 0);
17498 this.dd.setYConstraint(
17499 this.placement == Roo.SplitBar.TOP ? c1 : c2,
17500 this.placement == Roo.SplitBar.TOP ? c2 : c1
17504 this.dragSpecs.startSize = F;
17505 this.dragSpecs.startPoint = [x, y];
17506 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
17511 onEndProxyDrag : function(e){
17512 Roo.get(this.proxy).setDisplayed(false);
17513 var G = Roo.lib.Event.getXY(e);
17515 this.overlay.hide();
17518 if(this.orientation == Roo.SplitBar.HORIZONTAL){
17519 H = this.dragSpecs.startSize +
17520 (this.placement == Roo.SplitBar.LEFT ?
17521 G[0] - this.dragSpecs.startPoint[0] :
17522 this.dragSpecs.startPoint[0] - G[0]
17525 H = this.dragSpecs.startSize +
17526 (this.placement == Roo.SplitBar.TOP ?
17527 G[1] - this.dragSpecs.startPoint[1] :
17528 this.dragSpecs.startPoint[1] - G[1]
17532 H = Math.min(Math.max(H, this.activeMinSize), this.activeMaxSize);
17533 if(H != this.dragSpecs.startSize){
17534 if(this.fireEvent('beforeapply', this, H) !== false){
17535 this.adapter.setElementSize(this, H);
17536 this.fireEvent("moved", this, H);
17537 this.fireEvent("resize", this, H);
17544 getAdapter : function(){
17545 return this.adapter;
17550 setAdapter : function(I){
17552 this.adapter.init(this);
17557 getMinimumSize : function(){
17558 return this.minSize;
17563 setMinimumSize : function(J){
17569 getMaximumSize : function(){
17570 return this.maxSize;
17575 setMaximumSize : function(K){
17581 setCurrentSize : function(L){
17582 var M = this.animate;
17583 this.animate = false;
17584 this.adapter.setElementSize(this, L);
17590 destroy : function(N){
17592 this.shim.remove();
17596 this.proxy.parentNode.removeChild(this.proxy);
17605 Roo.SplitBar.createProxy = function(O){
17606 var P = new Roo.Element(document.createElement("div"));
17608 var Q = 'x-splitbar-proxy';
17609 P.addClass(Q + ' ' + (O == Roo.SplitBar.HORIZONTAL ? Q +'-h' : Q + '-v'));
17610 document.body.appendChild(P.dom);
17616 Roo.SplitBar.BasicLayoutAdapter = function(){
17619 Roo.SplitBar.BasicLayoutAdapter.prototype = {
17621 init : function(s){
17626 getElementSize : function(s){
17627 if(s.orientation == Roo.SplitBar.HORIZONTAL){
17628 return s.resizingEl.getWidth();
17630 return s.resizingEl.getHeight();
17636 setElementSize : function(s, R, S){
17637 if(s.orientation == Roo.SplitBar.HORIZONTAL){
17639 s.resizingEl.setWidth(R);
17644 s.resizingEl.setWidth(R, true, .1, S, 'easeOut');
17649 s.resizingEl.setHeight(R);
17654 s.resizingEl.setHeight(R, true, .1, S, 'easeOut');
17662 Roo.SplitBar.AbsoluteLayoutAdapter = function(T){
17663 this.basic = new Roo.SplitBar.BasicLayoutAdapter();
17664 this.container = Roo.get(T);
17667 Roo.SplitBar.AbsoluteLayoutAdapter.prototype = {
17668 init : function(s){
17669 this.basic.init(s);
17672 getElementSize : function(s){
17673 return this.basic.getElementSize(s);
17676 setElementSize : function(s, U, V){
17677 this.basic.setElementSize(s, U, this.moveSplitter.createDelegate(this, [s]));
17680 moveSplitter : function(s){
17681 var W = Roo.SplitBar;
17682 switch(s.placement){
17684 s.el.setX(s.resizingEl.getRight());
17687 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
17690 s.el.setY(s.resizingEl.getBottom());
17693 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
17701 Roo.SplitBar.VERTICAL = 1;
17705 Roo.SplitBar.HORIZONTAL = 2;
17709 Roo.SplitBar.LEFT = 1;
17713 Roo.SplitBar.RIGHT = 2;
17717 Roo.SplitBar.TOP = 3;
17721 Roo.SplitBar.BOTTOM = 4;
17728 Roo.View = function(A, B, C){
17730 if (typeof(B) == 'undefined') {
17732 Roo.apply(this, A);
17733 this.el = Roo.get(this.el);
17736 this.el = Roo.get(A);
17738 Roo.apply(this, C);
17742 if(typeof(this.tpl) == "string"){
17743 this.tpl = new Roo.Template(this.tpl);
17746 this.tpl = new Roo.factory(this.tpl, Roo);
17751 this.tpl.compile();
17760 "beforeclick" : true,
17769 "contextmenu" : true,
17772 "selectionchange" : true,
17776 "beforeselect" : true
17780 "click": this.onClick,
17781 "dblclick": this.onDblClick,
17782 "contextmenu": this.onContextMenu,
17786 this.selections = [];
17788 this.cmp = new Roo.CompositeElementLite([]);
17790 this.store = Roo.factory(this.store, Roo.data);
17791 this.setStore(this.store, true);
17794 Roo.View.superclass.constructor.call(this);
17797 Roo.extend(Roo.View, Roo.util.Observable, {
17813 selectedClass : "x-view-selected",
17819 getEl : function(){
17825 refresh : function(){
17827 this.clearSelections();
17828 this.el.update("");
17830 var E = this.store.getRange();
17832 this.el.update(this.emptyText);
17835 for(var i = 0, len = E.length; i < len; i++){
17836 var data = this.prepareData(E[i].data, i, E[i]);
17837 D[D.length] = t.apply(data);
17840 this.el.update(D.join(""));
17841 this.nodes = this.el.dom.childNodes;
17842 this.updateIndexes(0);
17847 prepareData : function(F){
17851 onUpdate : function(ds, G){
17852 this.clearSelections();
17853 var H = this.store.indexOf(G);
17854 var n = this.nodes[H];
17855 this.tpl.insertBefore(n, this.prepareData(G.data));
17856 n.parentNode.removeChild(n);
17857 this.updateIndexes(H, H);
17860 onAdd : function(ds, I, J){
17861 this.clearSelections();
17862 if(this.nodes.length == 0){
17866 var n = this.nodes[J];
17867 for(var i = 0, len = I.length; i < len; i++){
17868 var d = this.prepareData(I[i].data);
17870 this.tpl.insertBefore(n, d);
17872 this.tpl.append(this.el, d);
17876 this.updateIndexes(J);
17879 onRemove : function(ds, K, L){
17880 this.clearSelections();
17881 this.el.dom.removeChild(this.nodes[L]);
17882 this.updateIndexes(L);
17887 refreshNode : function(M){
17888 this.onUpdate(this.store, this.store.getAt(M));
17891 updateIndexes : function(N, O){
17892 var ns = this.nodes;
17894 O = O || ns.length - 1;
17895 for(var i = N; i <= O; i++){
17896 ns[i].nodeIndex = i;
17902 setStore : function(P, Q){
17903 if(!Q && this.store){
17904 this.store.un("datachanged", this.refresh);
17905 this.store.un("add", this.onAdd);
17906 this.store.un("remove", this.onRemove);
17907 this.store.un("update", this.onUpdate);
17908 this.store.un("clear", this.refresh);
17912 P.on("datachanged", this.refresh, this);
17913 P.on("add", this.onAdd, this);
17914 P.on("remove", this.onRemove, this);
17915 P.on("update", this.onUpdate, this);
17916 P.on("clear", this.refresh, this);
17926 findItemFromChild : function(R){
17927 var el = this.el.dom;
17928 if(!R || R.parentNode == el){
17931 var p = R.parentNode;
17932 while(p && p != el){
17933 if(p.parentNode == el){
17944 onClick : function(e){
17945 var S = this.findItemFromChild(e.getTarget());
17947 var M = this.indexOf(S);
17948 if(this.onItemClick(S, M, e) !== false){
17949 this.fireEvent("click", this, M, S, e);
17952 this.clearSelections();
17958 onContextMenu : function(e){
17959 var T = this.findItemFromChild(e.getTarget());
17961 this.fireEvent("contextmenu", this, this.indexOf(T), T, e);
17967 onDblClick : function(e){
17968 var U = this.findItemFromChild(e.getTarget());
17970 this.fireEvent("dblclick", this, this.indexOf(U), U, e);
17974 onItemClick : function(V, W, e){
17975 if(this.fireEvent("beforeclick", this, W, V, e) === false){
17978 if(this.multiSelect || this.singleSelect){
17979 if(this.multiSelect && e.shiftKey && this.lastSelection){
17980 this.select(this.getNodes(this.indexOf(this.lastSelection), W), false);
17982 this.select(V, this.multiSelect && e.ctrlKey);
17983 this.lastSelection = V;
17986 e.preventDefault();
17993 getSelectionCount : function(){
17994 return this.selections.length;
17999 getSelectedNodes : function(){
18000 return this.selections;
18005 getSelectedIndexes : function(){
18006 var X = [], s = this.selections;
18007 for(var i = 0, len = s.length; i < len; i++){
18008 X.push(s[i].nodeIndex);
18015 clearSelections : function(Y){
18016 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
18017 this.cmp.elements = this.selections;
18018 this.cmp.removeClass(this.selectedClass);
18019 this.selections = [];
18021 this.fireEvent("selectionchange", this, this.selections);
18028 isSelected : function(Z){
18029 var s = this.selections;
18034 Z = this.getNode(Z);
18035 return s.indexOf(Z) !== -1;
18040 select : function(a, b, c){
18041 if(a instanceof Array){
18043 this.clearSelections(true);
18045 for(var i = 0, len = a.length; i < len; i++){
18046 this.select(a[i], true, true);
18049 var Z = this.getNode(a);
18050 if(Z && !this.isSelected(Z)){
18052 this.clearSelections(true);
18054 if(this.fireEvent("beforeselect", this, Z, this.selections) !== false){
18055 Roo.fly(Z).addClass(this.selectedClass);
18056 this.selections.push(Z);
18058 this.fireEvent("selectionchange", this, this.selections);
18067 getNode : function(f){
18068 if(typeof f == "string"){
18069 return document.getElementById(f);
18070 }else if(typeof f == "number"){
18071 return this.nodes[f];
18078 getNodes : function(g, h){
18079 var ns = this.nodes;
18081 h = typeof h == "undefined" ? ns.length - 1 : h;
18084 for(var i = g; i <= h; i++){
18088 for(var i = g; i >= h; i--){
18097 indexOf : function(k){
18098 k = this.getNode(k);
18099 if(typeof k.nodeIndex == "number"){
18100 return k.nodeIndex;
18102 var ns = this.nodes;
18103 for(var i = 0, len = ns.length; i < len; i++){
18117 Roo.JsonView = function(A, B, C){
18120 Roo.JsonView.superclass.constructor.call(this, A, B, C);
18122 var um = this.el.getUpdateManager();
18123 um.setRenderer(this);
18124 um.on("update", this.onLoad, this);
18125 um.on("failure", this.onLoadException, this);
18134 'beforerender' : true,
18136 'loadexception' : true
18139 Roo.extend(Roo.JsonView, Roo.View, {
18146 refresh : function(){
18147 this.clearSelections();
18148 this.el.update("");
18150 var o = this.jsonData;
18151 if(o && o.length > 0){
18152 for(var i = 0, len = o.length; i < len; i++){
18153 var data = this.prepareData(o[i], i, o);
18154 D[D.length] = this.tpl.apply(data);
18157 D.push(this.emptyText);
18160 this.el.update(D.join(""));
18161 this.nodes = this.el.dom.childNodes;
18162 this.updateIndexes(0);
18168 var um = this.el.getUpdateManager();
18169 um.update.apply(um, arguments);
18172 render : function(el, E){
18173 this.clearSelections();
18174 this.el.update("");
18177 o = Roo.util.JSON.decode(E.responseText);
18181 eval("o." + this.jsonRoot);
18189 this.beforeRender();
18195 getCount : function(){
18196 return this.jsonData ? this.jsonData.length : 0;
18201 getNodeData : function(F){
18202 if(F instanceof Array){
18204 for(var i = 0, len = F.length; i < len; i++){
18205 data.push(this.getNodeData(F[i]));
18209 return this.jsonData[this.indexOf(F)] || null;
18212 beforeRender : function(){
18213 this.snapshot = this.jsonData;
18215 this.sort.apply(this, this.sortInfo);
18218 this.fireEvent("beforerender", this, this.jsonData);
18221 onLoad : function(el, o){
18222 this.fireEvent("load", this, this.jsonData, o);
18225 onLoadException : function(el, o){
18226 this.fireEvent("loadexception", this, o);
18231 filter : function(G, H){
18234 var ss = this.snapshot;
18235 if(typeof H == "string"){
18236 var vlen = H.length;
18238 this.clearFilter();
18242 H = H.toLowerCase();
18243 for(var i = 0, len = ss.length; i < len; i++){
18245 if(o[G].substr(0, vlen).toLowerCase() == H){
18250 for(var i = 0, len = ss.length; i < len; i++){
18260 this.jsonData = data;
18267 filterBy : function(fn, I){
18270 var ss = this.snapshot;
18271 for(var i = 0, len = ss.length; i < len; i++){
18273 if(fn.call(I || this, o)){
18278 this.jsonData = data;
18285 clearFilter : function(){
18286 if(this.snapshot && this.jsonData != this.snapshot){
18287 this.jsonData = this.snapshot;
18295 sort : function(J, K, L){
18296 this.sortInfo = Array.prototype.slice.call(arguments, 0);
18299 var dsc = K && K.toLowerCase() == "desc";
18300 var f = function(o1, o2){
18301 var v1 = L ? L(o1[p]) : o1[p];
18302 var v2 = L ? L(o2[p]) : o2[p];
18305 return dsc ? +1 : -1;
18306 } else if(v1 > v2){
18307 return dsc ? -1 : +1;
18312 this.jsonData.sort(f);
18314 if(this.jsonData != this.snapshot){
18315 this.snapshot.sort(f);
18326 Roo.ColorPalette = function(A){
18327 Roo.ColorPalette.superclass.constructor.call(this, A);
18335 this.on("select", this.handler, this.scope, true);
18338 Roo.extend(Roo.ColorPalette, Roo.Component, {
18341 itemCls : "x-color-palette",
18345 clickEvent:'click',
18347 ctype: "Roo.ColorPalette",
18351 allowReselect : false,
18356 "000000", "993300", "333300", "003300", "003366", "000080", "333399", "333333",
18357 "800000", "FF6600", "808000", "008000", "008080", "0000FF", "666699", "808080",
18358 "FF0000", "FF9900", "99CC00", "339966", "33CCCC", "3366FF", "800080", "969696",
18359 "FF00FF", "FFCC00", "FFFF00", "00FF00", "00FFFF", "00CCFF", "993366", "C0C0C0",
18360 "FF99CC", "FFCC99", "FFFF99", "CCFFCC", "CCFFFF", "99CCFF", "CC99FF", "FFFFFF"
18364 onRender : function(B, C){
18365 var t = new Roo.MasterTemplate(
18366 '<tpl><a href="#" class="color-{0}" hidefocus="on"><em><span style="background:#{0}" unselectable="on"> </span></em></a></tpl>'
18368 var c = this.colors;
18369 for(var i = 0, len = c.length; i < len; i++){
18372 var el = document.createElement("div");
18373 el.className = this.itemCls;
18375 B.dom.insertBefore(el, C);
18376 this.el = Roo.get(el);
18377 this.el.on(this.clickEvent, this.handleClick, this, {delegate: "a"});
18378 if(this.clickEvent != 'click'){
18379 this.el.on('click', Roo.emptyFn, this, {delegate: "a", preventDefault:true});
18384 afterRender : function(){
18385 Roo.ColorPalette.superclass.afterRender.call(this);
18387 var s = this.value;
18394 handleClick : function(e, t){
18395 e.preventDefault();
18396 if(!this.disabled){
18397 var c = t.className.match(/(?:^|\s)color-(.{6})(?:\s|$)/)[1];
18398 this.select(c.toUpperCase());
18404 select : function(D){
18405 D = D.replace("#", "");
18406 if(D != this.value || this.allowReselect){
18409 el.child("a.color-"+this.value).removeClass("x-color-palette-sel");
18412 el.child("a.color-"+D).addClass("x-color-palette-sel");
18414 this.fireEvent("select", this, D);
18423 Roo.DatePicker = function(A){
18424 Roo.DatePicker.superclass.constructor.call(this, A);
18426 this.value = A && A.value ?
18427 A.value.clearTime() : new Date().clearTime();
18436 this.on("select", this.handler, this.scope || this);
18439 if(!this.disabledDatesRE && this.disabledDates){
18440 var dd = this.disabledDates;
18442 for(var i = 0; i < dd.length; i++){
18444 if(i != dd.length-1) re += "|";
18447 this.disabledDatesRE = new RegExp(re + ")");
18451 Roo.extend(Roo.DatePicker, Roo.Component, {
18454 todayText : "Today",
18457 okText : " OK ",
18460 cancelText : "Cancel",
18463 todayTip : "{0} (Spacebar)",
18472 minText : "This date is before the minimum date",
18475 maxText : "This date is after the maximum date",
18481 disabledDays : null,
18484 disabledDaysText : "",
18487 disabledDatesRE : null,
18490 disabledDatesText : "",
18493 constrainToViewport : true,
18496 monthNames : Date.monthNames,
18499 dayNames : Date.dayNames,
18502 nextText: 'Next Month (Control+Right)',
18505 prevText: 'Previous Month (Control+Left)',
18508 monthYearText: 'Choose a month (Control+Up/Down to move years)',
18519 setValue : function(B){
18520 var C = this.value;
18521 this.value = B.clearTime(true);
18523 this.update(this.value);
18529 getValue : function(){
18534 focus : function(){
18536 this.update(this.activeDate);
18541 onRender : function(D, E){
18543 '<table cellspacing="0">',
18544 '<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>',
18545 '<tr><td colspan="3"><table class="x-date-inner" cellspacing="0"><thead><tr>'];
18546 var dn = this.dayNames;
18547 for(var i = 0; i < 7; i++){
18548 var d = this.startDay+i;
18553 m.push("<th><span>", dn[d].substr(0,1), "</span></th>");
18556 m[m.length] = "</tr></thead><tbody><tr>";
18557 for(var i = 0; i < 42; i++) {
18558 if(i % 7 == 0 && i != 0){
18559 m[m.length] = "</tr><tr>";
18562 m[m.length] = '<td><a href="#" hidefocus="on" class="x-date-date" tabIndex="1"><em><span></span></em></a></td>';
18565 m[m.length] = '</tr></tbody></table></td></tr><tr>'+
18566 '<td colspan="3" class="x-date-bottom" align="center"></td></tr></table><div class="x-date-mp"></div>';
18568 var el = document.createElement("div");
18569 el.className = "x-date-picker";
18570 el.innerHTML = m.join("");
18572 D.dom.insertBefore(el, E);
18574 this.el = Roo.get(el);
18575 this.eventEl = Roo.get(el.firstChild);
18577 new Roo.util.ClickRepeater(this.el.child("td.x-date-left a"), {
18578 handler: this.showPrevMonth,
18580 preventDefault:true,
18584 new Roo.util.ClickRepeater(this.el.child("td.x-date-right a"), {
18585 handler: this.showNextMonth,
18587 preventDefault:true,
18591 this.eventEl.on("mousewheel", this.handleMouseWheel, this);
18593 this.monthPicker = this.el.down('div.x-date-mp');
18594 this.monthPicker.enableDisplayMode('block');
18596 var kn = new Roo.KeyNav(this.eventEl, {
18597 "left" : function(e){
18599 this.showPrevMonth() :
18600 this.update(this.activeDate.add("d", -1));
18603 "right" : function(e){
18605 this.showNextMonth() :
18606 this.update(this.activeDate.add("d", 1));
18609 "up" : function(e){
18611 this.showNextYear() :
18612 this.update(this.activeDate.add("d", -7));
18615 "down" : function(e){
18617 this.showPrevYear() :
18618 this.update(this.activeDate.add("d", 7));
18621 "pageUp" : function(e){
18622 this.showNextMonth();
18625 "pageDown" : function(e){
18626 this.showPrevMonth();
18629 "enter" : function(e){
18630 e.stopPropagation();
18637 this.eventEl.on("click", this.handleDateClick, this, {delegate: "a.x-date-date"});
18639 this.eventEl.addKeyListener(Roo.EventObject.SPACE, this.selectToday, this);
18641 this.el.unselectable();
18643 this.cells = this.el.select("table.x-date-inner tbody td");
18644 this.textNodes = this.el.query("table.x-date-inner tbody span");
18646 this.mbtn = new Roo.Button(this.el.child("td.x-date-middle", true), {
18648 tooltip: this.monthYearText
18651 this.mbtn.on('click', this.showMonthPicker, this);
18652 this.mbtn.el.child(this.mbtn.menuClassTarget).addClass("x-btn-with-menu");
18655 var F = (new Date()).dateFormat(this.format);
18657 var G = new Roo.Toolbar(this.el.child("td.x-date-bottom", true));
18659 text: String.format(this.todayText, F),
18660 tooltip: String.format(this.todayTip, F),
18661 handler: this.selectToday,
18668 if (this.showClear) {
18670 G.add( new Roo.Toolbar.Fill());
18673 cls: 'x-btn-icon x-btn-clear',
18674 handler: function() {
18676 this.fireEvent("select", this, '');
18687 this.update(this.value);
18690 createMonthPicker : function(){
18691 if(!this.monthPicker.dom.firstChild){
18692 var buf = ['<table border="0" cellspacing="0">'];
18693 for(var i = 0; i < 6; i++){
18695 '<tr><td class="x-date-mp-month"><a href="#">', this.monthNames[i].substr(0, 3), '</a></td>',
18696 '<td class="x-date-mp-month x-date-mp-sep"><a href="#">', this.monthNames[i+6].substr(0, 3), '</a></td>',
18698 '<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>' :
18699 '<td class="x-date-mp-year"><a href="#"></a></td><td class="x-date-mp-year"><a href="#"></a></td></tr>'
18704 '<tr class="x-date-mp-btns"><td colspan="4"><button type="button" class="x-date-mp-ok">',
18706 '</button><button type="button" class="x-date-mp-cancel">',
18708 '</button></td></tr>',
18711 this.monthPicker.update(buf.join(''));
18712 this.monthPicker.on('click', this.onMonthClick, this);
18713 this.monthPicker.on('dblclick', this.onMonthDblClick, this);
18715 this.mpMonths = this.monthPicker.select('td.x-date-mp-month');
18716 this.mpYears = this.monthPicker.select('td.x-date-mp-year');
18718 this.mpMonths.each(function(m, a, i){
18721 m.dom.xmonth = 5 + Math.round(i * .5);
18723 m.dom.xmonth = Math.round((i-1) * .5);
18729 showMonthPicker : function(){
18730 this.createMonthPicker();
18731 var H = this.el.getSize();
18732 this.monthPicker.setSize(H);
18733 this.monthPicker.child('table').setSize(H);
18735 this.mpSelMonth = (this.activeDate || this.value).getMonth();
18736 this.updateMPMonth(this.mpSelMonth);
18737 this.mpSelYear = (this.activeDate || this.value).getFullYear();
18738 this.updateMPYear(this.mpSelYear);
18740 this.monthPicker.slideIn('t', {duration:.2});
18743 updateMPYear : function(y){
18745 var ys = this.mpYears.elements;
18746 for(var i = 1; i <= 10; i++){
18747 var td = ys[i-1], y2;
18749 y2 = y + Math.round(i * .5);
18750 td.firstChild.innerHTML = y2;
18753 y2 = y - (5-Math.round(i * .5));
18754 td.firstChild.innerHTML = y2;
18758 this.mpYears.item(i-1)[y2 == this.mpSelYear ? 'addClass' : 'removeClass']('x-date-mp-sel');
18762 updateMPMonth : function(sm){
18763 this.mpMonths.each(function(m, a, i){
18764 m[m.dom.xmonth == sm ? 'addClass' : 'removeClass']('x-date-mp-sel');
18768 selectMPMonth: function(m){
18772 onMonthClick : function(e, t){
18774 var el = new Roo.Element(t), pn;
18775 if(el.is('button.x-date-mp-cancel')){
18776 this.hideMonthPicker();
18778 else if(el.is('button.x-date-mp-ok')){
18779 this.update(new Date(this.mpSelYear, this.mpSelMonth, (this.activeDate || this.value).getDate()));
18780 this.hideMonthPicker();
18782 else if(pn = el.up('td.x-date-mp-month', 2)){
18783 this.mpMonths.removeClass('x-date-mp-sel');
18784 pn.addClass('x-date-mp-sel');
18785 this.mpSelMonth = pn.dom.xmonth;
18787 else if(pn = el.up('td.x-date-mp-year', 2)){
18788 this.mpYears.removeClass('x-date-mp-sel');
18789 pn.addClass('x-date-mp-sel');
18790 this.mpSelYear = pn.dom.xyear;
18792 else if(el.is('a.x-date-mp-prev')){
18793 this.updateMPYear(this.mpyear-10);
18795 else if(el.is('a.x-date-mp-next')){
18796 this.updateMPYear(this.mpyear+10);
18800 onMonthDblClick : function(e, t){
18802 var el = new Roo.Element(t), pn;
18803 if(pn = el.up('td.x-date-mp-month', 2)){
18804 this.update(new Date(this.mpSelYear, pn.dom.xmonth, (this.activeDate || this.value).getDate()));
18805 this.hideMonthPicker();
18807 else if(pn = el.up('td.x-date-mp-year', 2)){
18808 this.update(new Date(pn.dom.xyear, this.mpSelMonth, (this.activeDate || this.value).getDate()));
18809 this.hideMonthPicker();
18813 hideMonthPicker : function(I){
18814 if(this.monthPicker){
18816 this.monthPicker.hide();
18818 this.monthPicker.slideOut('t', {duration:.2});
18824 showPrevMonth : function(e){
18825 this.update(this.activeDate.add("mo", -1));
18829 showNextMonth : function(e){
18830 this.update(this.activeDate.add("mo", 1));
18834 showPrevYear : function(){
18835 this.update(this.activeDate.add("y", -1));
18839 showNextYear : function(){
18840 this.update(this.activeDate.add("y", 1));
18844 handleMouseWheel : function(e){
18845 var J = e.getWheelDelta();
18847 this.showPrevMonth();
18850 this.showNextMonth();
18856 handleDateClick : function(e, t){
18858 if(t.dateValue && !Roo.fly(t.parentNode).hasClass("x-date-disabled")){
18859 this.setValue(new Date(t.dateValue));
18860 this.fireEvent("select", this, this.value);
18865 selectToday : function(){
18866 this.setValue(new Date().clearTime());
18867 this.fireEvent("select", this, this.value);
18871 update : function(K){
18872 var vd = this.activeDate;
18873 this.activeDate = K;
18875 var t = K.getTime();
18876 if(vd.getMonth() == K.getMonth() && vd.getFullYear() == K.getFullYear()){
18877 this.cells.removeClass("x-date-selected");
18878 this.cells.each(function(c){
18879 if(c.dom.firstChild.dateValue == t){
18880 c.addClass("x-date-selected");
18881 setTimeout(function(){
18882 try{c.dom.firstChild.focus();}catch(e){}
18890 var L = K.getDaysInMonth();
18891 var M = K.getFirstDateOfMonth();
18892 var N = M.getDay()-this.startDay;
18894 if(N <= this.startDay){
18898 var pm = K.add("mo", -1);
18899 var O = pm.getDaysInMonth()-N;
18901 var P = this.cells.elements;
18902 var Q = this.textNodes;
18907 var d = (new Date(pm.getFullYear(), pm.getMonth(), O)).clearTime();
18908 var S = new Date().clearTime().getTime();
18909 var T = K.clearTime().getTime();
18910 var U = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
18911 var V = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
18912 var W = this.disabledDatesRE;
18913 var X = this.disabledDatesText;
18914 var Y = this.disabledDays ? this.disabledDays.join("") : false;
18915 var Z = this.disabledDaysText;
18916 var a = this.format;
18918 var b = function(f, g){
18920 var t = d.getTime();
18921 g.firstChild.dateValue = t;
18923 g.className += " x-date-today";
18924 g.title = f.todayText;
18927 g.className += " x-date-selected";
18928 setTimeout(function(){
18929 try{g.firstChild.focus();}catch(e){}
18934 g.className = " x-date-disabled";
18935 g.title = f.minText;
18939 g.className = " x-date-disabled";
18940 g.title = f.maxText;
18944 if(Y.indexOf(d.getDay()) != -1){
18946 g.className = " x-date-disabled";
18950 var fvalue = d.dateFormat(a);
18951 if(W.test(fvalue)){
18952 g.title = X.replace("%0", fvalue);
18953 g.className = " x-date-disabled";
18959 for(; i < N; i++) {
18960 Q[i].innerHTML = (++O);
18961 d.setDate(d.getDate()+1);
18962 P[i].className = "x-date-prevday";
18966 intDay = i - N + 1;
18967 Q[i].innerHTML = (intDay);
18968 d.setDate(d.getDate()+1);
18969 P[i].className = "x-date-active";
18973 for(; i < 42; i++) {
18974 Q[i].innerHTML = (++c);
18975 d.setDate(d.getDate()+1);
18976 P[i].className = "x-date-nextday";
18981 this.mbtn.setText(this.monthNames[K.getMonth()] + " " + K.getFullYear());
18983 if(!this.internalRender){
18984 var main = this.el.dom.firstChild;
18985 var w = main.offsetWidth;
18986 this.el.setWidth(w + this.el.getBorderWidth("lr"));
18987 Roo.fly(main).setWidth(w);
18988 this.internalRender = true;
18992 if(Roo.isOpera && !this.secondPass){
18993 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
18994 this.secondPass = true;
18995 this.update.defer(10, this, [K]);
19004 Roo.TabPanel = function(A, B){
19007 this.el = Roo.get(A, true);
19009 if(typeof B == "boolean"){
19010 this.tabPosition = B ? "bottom" : "top";
19012 Roo.apply(this, B);
19015 if(this.tabPosition == "bottom"){
19016 this.bodyEl = Roo.get(this.createBody(this.el.dom));
19017 this.el.addClass("x-tabs-bottom");
19020 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
19021 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
19022 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
19024 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
19026 if(this.tabPosition != "bottom"){
19029 this.bodyEl = Roo.get(this.createBody(this.el.dom));
19030 this.el.addClass("x-tabs-top");
19035 this.bodyEl.setStyle("position", "relative");
19037 this.active = null;
19038 this.activateDelegate = this.activate.createDelegate(this);
19046 "beforetabchange" : true
19049 Roo.EventManager.onWindowResize(this.onResize, this);
19050 this.cpad = this.el.getPadding("lr");
19051 this.hiddenCount = 0;
19053 Roo.TabPanel.superclass.constructor.call(this);
19056 Roo.extend(Roo.TabPanel, Roo.util.Observable, {
19059 tabPosition : "top",
19062 currentTabWidth : 0,
19071 preferredTabWidth : 175,
19074 resizeTabs : false,
19077 monitorResize : true,
19081 addTab : function(id, C, D, E){
19082 var F = new Roo.TabPanelItem(this, id, C, E);
19083 this.addTabItem(F);
19092 getTab : function(id){
19093 return this.items[id];
19098 hideTab : function(id){
19099 var t = this.items[id];
19102 this.hiddenCount++;
19103 this.autoSizeTabs();
19109 unhideTab : function(id){
19110 var t = this.items[id];
19112 t.setHidden(false);
19113 this.hiddenCount--;
19114 this.autoSizeTabs();
19120 addTabItem : function(G){
19121 this.items[G.id] = G;
19122 this.items.push(G);
19123 if(this.resizeTabs){
19124 G.setWidth(this.currentTabWidth || this.preferredTabWidth);
19125 this.autoSizeTabs();
19133 removeTab : function(id){
19134 var H = this.items;
19137 var J = H.indexOf(I);
19138 if(this.active == I && H.length > 1){
19139 var newTab = this.getNextAvailable(J);
19140 if(newTab)newTab.activate();
19143 this.stripEl.dom.removeChild(I.pnode.dom);
19144 if(I.bodyEl.dom.parentNode == this.bodyEl.dom){
19145 this.bodyEl.dom.removeChild(I.bodyEl.dom);
19149 delete this.items[I.id];
19150 I.fireEvent("close", I);
19151 I.purgeListeners();
19152 this.autoSizeTabs();
19155 getNextAvailable : function(K){
19156 var L = this.items;
19160 while(M < L.length){
19162 if(G && !G.isHidden()){
19171 if(G && !G.isHidden()){
19180 disableTab : function(id){
19181 var N = this.items[id];
19182 if(N && this.active != N){
19189 enableTab : function(id){
19190 var O = this.items[id];
19196 activate : function(id){
19197 var P = this.items[id];
19201 if(P == this.active || P.disabled){
19205 this.fireEvent("beforetabchange", this, e, P);
19206 if(e.cancel !== true && !P.disabled){
19208 this.active.hide();
19211 this.active = this.items[id];
19212 this.active.show();
19213 this.fireEvent("tabchange", this, this.active);
19220 getActiveTab : function(){
19221 return this.active;
19226 syncHeight : function(Q){
19227 var R = (Q || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
19228 var bm = this.bodyEl.getMargins();
19229 var S = R-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
19230 this.bodyEl.setHeight(S);
19234 onResize : function(){
19235 if(this.monitorResize){
19236 this.autoSizeTabs();
19242 beginUpdate : function(){
19243 this.updating = true;
19248 endUpdate : function(){
19249 this.updating = false;
19250 this.autoSizeTabs();
19255 autoSizeTabs : function(){
19256 var T = this.items.length;
19257 var U = T - this.hiddenCount;
19258 if(!this.resizeTabs || T < 1 || U < 1 || this.updating) return;
19259 var w = Math.max(this.el.getWidth() - this.cpad, 10);
19260 var V = Math.floor(w / U);
19261 var b = this.stripBody;
19262 if(b.getWidth() > w){
19263 var tabs = this.items;
19264 this.setTabWidth(Math.max(V, this.minTabWidth)-2);
19265 if(V < this.minTabWidth){
19270 if(this.currentTabWidth < this.preferredTabWidth){
19271 this.setTabWidth(Math.min(V, this.preferredTabWidth)-2);
19278 getCount : function(){
19279 return this.items.length;
19284 setTabWidth : function(W){
19285 this.currentTabWidth = W;
19286 for(var i = 0, len = this.items.length; i < len; i++) {
19287 if(!this.items[i].isHidden())this.items[i].setWidth(W);
19293 destroy : function(X){
19294 Roo.EventManager.removeResizeListener(this.onResize, this);
19295 for(var i = 0, len = this.items.length; i < len; i++){
19296 this.items[i].purgeListeners();
19299 this.el.update("");
19307 Roo.TabPanelItem = function(Y, id, Z, a){
19316 this.disabled = false;
19322 this.loaded = false;
19327 this.bodyEl = Roo.get(Y.createItemBody(Y.bodyEl.dom, id));
19328 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
19329 this.bodyEl.setStyle("display", "block");
19330 this.bodyEl.setStyle("zoom", "1");
19333 var d = Y.createStripElements(Y.stripEl.dom, Z, a);
19336 this.el = Roo.get(d.el, true);
19337 this.inner = Roo.get(d.inner, true);
19338 this.textEl = Roo.get(this.el.dom.firstChild.firstChild.firstChild, true);
19339 this.pnode = Roo.get(d.el.parentNode, true);
19340 this.el.on("mousedown", this.onTabMouseDown, this);
19341 this.el.on("click", this.onTabClick, this);
19345 var c = Roo.get(d.close, true);
19346 c.dom.title = this.closeText;
19347 c.addClassOnOver("close-over");
19348 c.on("click", this.closeClick, this);
19358 "beforeclose": true,
19364 "deactivate" : true
19366 this.hidden = false;
19368 Roo.TabPanelItem.superclass.constructor.call(this);
19371 Roo.extend(Roo.TabPanelItem, Roo.util.Observable, {
19372 purgeListeners : function(){
19373 Roo.util.Observable.prototype.purgeListeners.call(this);
19374 this.el.removeAllListeners();
19379 this.pnode.addClass("on");
19382 this.tabPanel.stripWrap.repaint();
19385 this.fireEvent("activate", this.tabPanel, this);
19390 isActive : function(){
19391 return this.tabPanel.getActiveTab() == this;
19397 this.pnode.removeClass("on");
19399 this.fireEvent("deactivate", this.tabPanel, this);
19402 hideAction : function(){
19403 this.bodyEl.hide();
19404 this.bodyEl.setStyle("position", "absolute");
19405 this.bodyEl.setLeft("-20000px");
19406 this.bodyEl.setTop("-20000px");
19409 showAction : function(){
19410 this.bodyEl.setStyle("position", "relative");
19411 this.bodyEl.setTop("");
19412 this.bodyEl.setLeft("");
19413 this.bodyEl.show();
19418 setTooltip : function(f){
19419 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
19420 this.textEl.dom.qtip = f;
19421 this.textEl.dom.removeAttribute('title');
19423 this.textEl.dom.title = f;
19427 onTabClick : function(e){
19428 e.preventDefault();
19429 this.tabPanel.activate(this.id);
19432 onTabMouseDown : function(e){
19433 e.preventDefault();
19434 this.tabPanel.activate(this.id);
19437 getWidth : function(){
19438 return this.inner.getWidth();
19441 setWidth : function(g){
19442 var h = g - this.pnode.getPadding("lr");
19443 this.inner.setWidth(h);
19444 this.textEl.setWidth(h-this.inner.getPadding("lr"));
19445 this.pnode.setWidth(g);
19450 setHidden : function(j){
19452 this.pnode.setStyle("display", j ? "none" : "");
19457 isHidden : function(){
19458 return this.hidden;
19463 getText : function(){
19467 autoSize : function(){
19469 this.textEl.setWidth(1);
19470 this.setWidth(this.textEl.dom.scrollWidth+this.pnode.getPadding("lr")+this.inner.getPadding("lr"));
19476 setText : function(k){
19478 this.textEl.update(k);
19479 this.setTooltip(k);
19480 if(!this.tabPanel.resizeTabs){
19486 activate : function(){
19487 this.tabPanel.activate(this.id);
19492 disable : function(){
19493 if(this.tabPanel.active != this){
19494 this.disabled = true;
19495 this.pnode.addClass("disabled");
19501 enable : function(){
19502 this.disabled = false;
19503 this.pnode.removeClass("disabled");
19508 setContent : function(l, m){
19509 this.bodyEl.update(l, m);
19514 getUpdateManager : function(){
19515 return this.bodyEl.getUpdateManager();
19520 setUrl : function(n, o, p){
19521 if(this.refreshDelegate){
19522 this.un('activate', this.refreshDelegate);
19525 this.refreshDelegate = this._handleRefresh.createDelegate(this, [n, o, p]);
19526 this.on("activate", this.refreshDelegate);
19527 return this.bodyEl.getUpdateManager();
19532 _handleRefresh : function(q, r, s){
19533 if(!s || !this.loaded){
19534 var updater = this.bodyEl.getUpdateManager();
19535 updater.update(q, r, this._setLoaded.createDelegate(this));
19541 refresh : function(){
19542 if(this.refreshDelegate){
19543 this.loaded = false;
19544 this.refreshDelegate();
19550 _setLoaded : function(){
19551 this.loaded = true;
19556 closeClick : function(e){
19559 this.fireEvent("beforeclose", this, o);
19560 if(o.cancel !== true){
19561 this.tabPanel.removeTab(this.id);
19566 closeText : "Close this tab"
19571 Roo.TabPanel.prototype.createStrip = function(u){
19572 var v = document.createElement("div");
19573 v.className = "x-tabs-wrap";
19579 Roo.TabPanel.prototype.createStripList = function(x){
19581 x.innerHTML = '<div class="x-tabs-strip-wrap"><table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr></tr></tbody></table></div>';
19582 return x.firstChild.firstChild.firstChild.firstChild;
19586 Roo.TabPanel.prototype.createBody = function(y){
19587 var z = document.createElement("div");
19588 Roo.id(z, "tab-body");
19589 Roo.fly(z).addClass("x-tabs-body");
19595 Roo.TabPanel.prototype.createItemBody = function(AA, id){
19596 var AB = Roo.getDom(id);
19598 AB = document.createElement("div");
19602 Roo.fly(AB).addClass("x-tabs-item-body");
19603 AA.insertBefore(AB, AA.firstChild);
19608 Roo.TabPanel.prototype.createStripElements = function(AC, AD, AE){
19609 var td = document.createElement("td");
19610 AC.appendChild(td);
19612 td.className = "x-tabs-closable";
19613 if(!this.closeTpl){
19614 this.closeTpl = new Roo.Template(
19615 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
19616 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
19617 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
19620 var el = this.closeTpl.overwrite(td, {"text": AD});
19621 var close = el.getElementsByTagName("div")[0];
19622 var inner = el.getElementsByTagName("em")[0];
19623 return {"el": el, "close": close, "inner": inner};
19626 this.tabTpl = new Roo.Template(
19627 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
19628 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
19631 var el = this.tabTpl.overwrite(td, {"text": AD});
19632 var inner = el.getElementsByTagName("em")[0];
19633 return {"el": el, "inner": inner};
19641 Roo.Button = function(A, B)
19645 A = B.renderTo || false;
19649 Roo.apply(this, B);
19659 'mouseover' : true,
19668 this.menu = Roo.menu.MenuMgr.get(this.menu);
19675 Roo.util.Observable.call(this);
19678 Roo.extend(Roo.Button, Roo.util.Observable, {
19694 tabIndex : undefined,
19698 enableToggle: false,
19704 menuAlign : "tl-bl?",
19708 iconCls : undefined,
19714 menuClassTarget: 'tr',
19718 clickEvent : 'click',
19722 handleMouseEvents : true,
19726 tooltipType : 'qtip',
19735 render : function(C){
19737 if(this.hideParent){
19738 this.parentEl = Roo.get(C);
19740 if(!this.dhconfig){
19741 if(!this.template){
19742 if(!Roo.Button.buttonTemplate){
19744 Roo.Button.buttonTemplate = new Roo.Template(
19745 '<table border="0" cellpadding="0" cellspacing="0" class="x-btn-wrap"><tbody><tr>',
19746 '<td class="x-btn-left"><i> </i></td><td class="x-btn-center"><em unselectable="on"><button class="x-btn-text" type="{1}">{0}</button></em></td><td class="x-btn-right"><i> </i></td>',
19747 "</tr></tbody></table>");
19750 this.template = Roo.Button.buttonTemplate;
19753 D = this.template.append(C, [this.text || ' ', this.type], true);
19754 var btnEl = D.child("button:first");
19755 btnEl.on('focus', this.onFocus, this);
19756 btnEl.on('blur', this.onBlur, this);
19758 D.addClass(this.cls);
19761 btnEl.setStyle('background-image', 'url(' +this.icon +')');
19764 btnEl.addClass(this.iconCls);
19766 D.addClass(this.text ? 'x-btn-text-icon' : 'x-btn-icon');
19769 if(this.tabIndex !== undefined){
19770 btnEl.dom.tabIndex = this.tabIndex;
19773 if(typeof this.tooltip == 'object'){
19774 Roo.QuickTips.tips(Roo.apply({
19778 btnEl.dom[this.tooltipType] = this.tooltip;
19782 D = Roo.DomHelper.append(Roo.get(C).dom, this.dhconfig, true);
19787 this.el.dom.id = this.el.id = this.id;
19790 this.el.child(this.menuClassTarget).addClass("x-btn-with-menu");
19791 this.menu.on("show", this.onMenuShow, this);
19792 this.menu.on("hide", this.onMenuHide, this);
19795 D.addClass("x-btn");
19796 if(Roo.isIE && !Roo.isIE7){
19797 this.autoWidth.defer(1, this);
19801 if(this.handleMouseEvents){
19802 D.on("mouseover", this.onMouseOver, this);
19803 D.on("mouseout", this.onMouseOut, this);
19804 D.on("mousedown", this.onMouseDown, this);
19807 D.on(this.clickEvent, this.onClick, this);
19816 Roo.ButtonToggleMgr.register(this);
19818 this.el.addClass("x-btn-pressed");
19821 var repeater = new Roo.util.ClickRepeater(D,
19822 typeof this.repeat == "object" ? this.repeat : {}
19824 repeater.on("click", this.onClick, this);
19827 this.fireEvent('render', this);
19832 getEl : function(){
19838 destroy : function(){
19839 Roo.ButtonToggleMgr.unregister(this);
19840 this.el.removeAllListeners();
19841 this.purgeListeners();
19846 autoWidth : function(){
19848 this.el.setWidth("auto");
19849 if(Roo.isIE7 && Roo.isStrict){
19850 var ib = this.el.child('button');
19851 if(ib && ib.getWidth() > 20){
19853 ib.setWidth(Roo.util.TextMetrics.measure(ib, this.text).width+ib.getFrameWidth('lr'));
19858 this.el.beginMeasure();
19860 if(this.el.getWidth() < this.minWidth){
19861 this.el.setWidth(this.minWidth);
19864 this.el.endMeasure();
19872 setHandler : function(E, F){
19879 setText : function(G){
19882 this.el.child("td.x-btn-center button.x-btn-text").update(G);
19890 getText : function(){
19897 this.hidden = false;
19899 this[this.hideParent? 'parentEl' : 'el'].setStyle("display", "");
19906 this.hidden = true;
19908 this[this.hideParent? 'parentEl' : 'el'].setStyle("display", "none");
19914 setVisible: function(H){
19924 toggle : function(I){
19925 I = I === undefined ? !this.pressed : I;
19926 if(I != this.pressed){
19928 this.el.addClass("x-btn-pressed");
19929 this.pressed = true;
19930 this.fireEvent("toggle", this, true);
19932 this.el.removeClass("x-btn-pressed");
19933 this.pressed = false;
19934 this.fireEvent("toggle", this, false);
19936 if(this.toggleHandler){
19937 this.toggleHandler.call(this.scope || this, this, I);
19944 focus : function(){
19945 this.el.child('button:first').focus();
19950 disable : function(){
19952 this.el.addClass("x-btn-disabled");
19955 this.disabled = true;
19960 enable : function(){
19962 this.el.removeClass("x-btn-disabled");
19965 this.disabled = false;
19970 setDisabled : function(v){
19971 this[v !== true ? "enable" : "disable"]();
19975 onClick : function(e){
19977 e.preventDefault();
19982 if(!this.disabled){
19983 if(this.enableToggle){
19986 if(this.menu && !this.menu.isVisible()){
19987 this.menu.show(this.el, this.menuAlign);
19990 this.fireEvent("click", this, e);
19992 this.el.removeClass("x-btn-over");
19993 this.handler.call(this.scope || this, this, e);
19998 onMouseOver : function(e){
19999 if(!this.disabled){
20000 this.el.addClass("x-btn-over");
20001 this.fireEvent('mouseover', this, e);
20005 onMouseOut : function(e){
20006 if(!e.within(this.el, true)){
20007 this.el.removeClass("x-btn-over");
20008 this.fireEvent('mouseout', this, e);
20012 onFocus : function(e){
20013 if(!this.disabled){
20014 this.el.addClass("x-btn-focus");
20018 onBlur : function(e){
20019 this.el.removeClass("x-btn-focus");
20022 onMouseDown : function(e){
20023 if(!this.disabled && e.button == 0){
20024 this.el.addClass("x-btn-click");
20025 Roo.get(document).on('mouseup', this.onMouseUp, this);
20029 onMouseUp : function(e){
20031 this.el.removeClass("x-btn-click");
20032 Roo.get(document).un('mouseup', this.onMouseUp, this);
20036 onMenuShow : function(e){
20037 this.el.addClass("x-btn-menu-active");
20040 onMenuHide : function(e){
20041 this.el.removeClass("x-btn-menu-active");
20046 Roo.ButtonToggleMgr = function(){
20051 var g = J[L.toggleGroup];
20052 for(var i = 0, l = g.length; i < l; i++){
20054 g[i].toggle(false);
20061 register : function(N){
20062 if(!N.toggleGroup){
20065 var g = J[N.toggleGroup];
20067 g = J[N.toggleGroup] = [];
20074 unregister : function(O){
20075 if(!O.toggleGroup){
20078 var g = J[O.toggleGroup];
20091 Roo.SplitButton = function(A, B){
20092 Roo.SplitButton.superclass.constructor.call(this, A, B);
20095 this.addEvents({"arrowclick":true});
20098 Roo.extend(Roo.SplitButton, Roo.Button, {
20099 render : function(C){
20101 var D = new Roo.Template(
20102 '<table cellspacing="0" class="x-btn-menu-wrap x-btn"><tr><td>',
20103 '<table cellspacing="0" class="x-btn-wrap x-btn-menu-text-wrap"><tbody>',
20104 '<tr><td class="x-btn-left"><i> </i></td><td class="x-btn-center"><button class="x-btn-text" type="{1}">{0}</button></td></tr>',
20105 "</tbody></table></td><td>",
20106 '<table cellspacing="0" class="x-btn-wrap x-btn-menu-arrow-wrap"><tbody>',
20107 '<tr><td class="x-btn-center"><button class="x-btn-menu-arrow-el" type="button"> </button></td><td class="x-btn-right"><i> </i></td></tr>',
20108 "</tbody></table></td></tr></table>"
20110 var E = D.append(C, [this.text, this.type], true);
20111 var F = E.child("button");
20113 E.addClass(this.cls);
20116 F.setStyle('background-image', 'url(' +this.icon +')');
20119 F.addClass(this.iconCls);
20121 E.addClass(this.text ? 'x-btn-text-icon' : 'x-btn-icon');
20126 if(this.handleMouseEvents){
20127 E.on("mouseover", this.onMouseOver, this);
20128 E.on("mouseout", this.onMouseOut, this);
20129 E.on("mousedown", this.onMouseDown, this);
20130 E.on("mouseup", this.onMouseUp, this);
20133 E.on(this.clickEvent, this.onClick, this);
20135 if(typeof this.tooltip == 'object'){
20136 Roo.QuickTips.tips(Roo.apply({
20140 F.dom[this.tooltipType] = this.tooltip;
20143 if(this.arrowTooltip){
20144 E.child("button:nth(2)").dom[this.tooltipType] = this.arrowTooltip;
20153 this.el.addClass("x-btn-pressed");
20155 if(Roo.isIE && !Roo.isIE7){
20156 this.autoWidth.defer(1, this);
20161 this.menu.on("show", this.onMenuShow, this);
20162 this.menu.on("hide", this.onMenuHide, this);
20165 this.fireEvent('render', this);
20169 autoWidth : function(){
20171 var tbl = this.el.child("table:first");
20172 var tbl2 = this.el.child("table:last");
20173 this.el.setWidth("auto");
20174 tbl.setWidth("auto");
20175 if(Roo.isIE7 && Roo.isStrict){
20176 var ib = this.el.child('button:first');
20177 if(ib && ib.getWidth() > 20){
20179 ib.setWidth(Roo.util.TextMetrics.measure(ib, this.text).width+ib.getFrameWidth('lr'));
20184 this.el.beginMeasure();
20186 if((tbl.getWidth()+tbl2.getWidth()) < this.minWidth){
20187 tbl.setWidth(this.minWidth-tbl2.getWidth());
20190 this.el.endMeasure();
20194 this.el.setWidth(tbl.getWidth()+tbl2.getWidth());
20199 setHandler : function(G, H){
20206 setArrowHandler : function(I, J){
20207 this.arrowHandler = I;
20213 focus : function(){
20215 this.el.child("button:first").focus();
20220 onClick : function(e){
20221 e.preventDefault();
20222 if(!this.disabled){
20223 if(e.getTarget(".x-btn-menu-arrow-wrap")){
20224 if(this.menu && !this.menu.isVisible()){
20225 this.menu.show(this.el, this.menuAlign);
20228 this.fireEvent("arrowclick", this, e);
20229 if(this.arrowHandler){
20230 this.arrowHandler.call(this.scope || this, this, e);
20233 this.fireEvent("click", this, e);
20235 this.handler.call(this.scope || this, this, e);
20241 onMouseDown : function(e){
20242 if(!this.disabled){
20243 Roo.fly(e.getTarget("table")).addClass("x-btn-click");
20247 onMouseUp : function(e){
20248 Roo.fly(e.getTarget("table")).removeClass("x-btn-click");
20254 Roo.MenuButton = Roo.SplitButton;
20260 Roo.Toolbar = function(A, B, C)
20263 if(A instanceof Array){
20268 if (typeof(A) == 'object' && A.xtype) {
20274 if (C && C.items) {
20279 Roo.apply(this, C);
20286 Roo.each(D, function(b) {
20292 Roo.Toolbar.prototype = {
20299 render : function(ct){
20300 this.el = Roo.get(ct);
20302 this.el.addClass(this.cls);
20307 this.el.update('<div class="x-toolbar x-small-editor"><table cellspacing="0"><tr></tr></table></div>');
20308 this.tr = this.el.child("tr", true);
20310 this.items = new Roo.util.MixedCollection(false, function(o){
20311 return o.id || ("item" + (++E));
20314 this.add.apply(this, this.buttons);
20315 delete this.buttons;
20322 var a = arguments, l = a.length;
20323 for(var i = 0; i < l; i++){
20328 _add : function(el) {
20331 el = Roo.factory(el, typeof(Roo.Toolbar[el.xtype]) == 'undefined' ? Roo.form : Roo.Toolbar);
20335 return this.addField(el);
20338 return this.addItem(el);
20340 if (typeof el == "string"){
20341 if(el == "separator" || el == "-"){
20342 return this.addSeparator();
20345 return this.addSpacer();
20348 return this.addFill();
20350 return this.addText(el);
20354 return this.addElement(el);
20356 if(typeof el == "object"){
20357 return this.addButton(el);
20366 addxtype : function(e){
20367 return this.add(e);
20372 getEl : function(){
20378 addSeparator : function(){
20379 return this.addItem(new Roo.Toolbar.Separator());
20384 addSpacer : function(){
20385 return this.addItem(new Roo.Toolbar.Spacer());
20390 addFill : function(){
20391 return this.addItem(new Roo.Toolbar.Fill());
20396 addElement : function(el){
20397 return this.addItem(new Roo.Toolbar.Item(el));
20405 addItem : function(F){
20406 var td = this.nextBlock();
20414 addButton : function(G){
20415 if(G instanceof Array){
20417 for(var i = 0, len = G.length; i < len; i++) {
20418 B.push(this.addButton(G[i]));
20423 if(!(G instanceof Roo.Toolbar.Button)){
20425 new Roo.Toolbar.SplitButton(G) :
20426 new Roo.Toolbar.Button(G);
20428 var td = this.nextBlock();
20436 addText : function(H){
20437 return this.addItem(new Roo.Toolbar.TextItem(H));
20442 insertButton : function(I, J){
20443 if(J instanceof Array){
20445 for(var i = 0, len = J.length; i < len; i++) {
20446 B.push(this.insertButton(I + i, J[i]));
20450 if (!(J instanceof Roo.Toolbar.Button)){
20451 J = new Roo.Toolbar.Button(J);
20453 var td = document.createElement("td");
20454 this.tr.insertBefore(td, this.tr.childNodes[I]);
20456 this.items.insert(I, J);
20462 addDom : function(K, L){
20463 var td = this.nextBlock();
20464 Roo.DomHelper.overwrite(td, K);
20465 var ti = new Roo.Toolbar.Item(td.firstChild);
20467 this.items.add(ti);
20479 addField : function(M) {
20480 if (!this.fields) {
20482 this.fields = new Roo.util.MixedCollection(false, function(o){
20483 return o.id || ("item" + (++E));
20488 var td = this.nextBlock();
20490 var ti = new Roo.Toolbar.Item(td.firstChild);
20492 this.items.add(ti);
20493 this.fields.add(M);
20502 this.el.child('div').setVisibilityMode(Roo.Element.DISPLAY);
20503 this.el.child('div').hide();
20509 this.el.child('div').show();
20513 nextBlock : function(){
20514 var td = document.createElement("td");
20515 this.tr.appendChild(td);
20520 destroy : function(){
20522 Roo.destroy.apply(Roo, this.items.items);
20525 Roo.destroy.apply(Roo, this.fields.items);
20528 Roo.Element.uncache(this.el, this.tr);
20534 Roo.Toolbar.Item = function(el){
20535 this.el = Roo.getDom(el);
20536 this.id = Roo.id(this.el);
20537 this.hidden = false;
20540 Roo.Toolbar.Item.prototype = {
20544 getEl : function(){
20549 render : function(td){
20551 td.appendChild(this.el);
20556 destroy : function(){
20557 this.td.parentNode.removeChild(this.td);
20563 this.hidden = false;
20564 this.td.style.display = "";
20570 this.hidden = true;
20571 this.td.style.display = "none";
20576 setVisible: function(N){
20586 focus : function(){
20587 Roo.fly(this.el).focus();
20592 disable : function(){
20593 Roo.fly(this.td).addClass("x-item-disabled");
20594 this.disabled = true;
20595 this.el.disabled = true;
20600 enable : function(){
20601 Roo.fly(this.td).removeClass("x-item-disabled");
20602 this.disabled = false;
20603 this.el.disabled = false;
20610 Roo.Toolbar.Separator = function(){
20611 var s = document.createElement("span");
20612 s.className = "ytb-sep";
20613 Roo.Toolbar.Separator.superclass.constructor.call(this, s);
20615 Roo.extend(Roo.Toolbar.Separator, Roo.Toolbar.Item, {
20616 enable:Roo.emptyFn,
20617 disable:Roo.emptyFn,
20623 Roo.Toolbar.Spacer = function(){
20624 var s = document.createElement("div");
20625 s.className = "ytb-spacer";
20626 Roo.Toolbar.Spacer.superclass.constructor.call(this, s);
20628 Roo.extend(Roo.Toolbar.Spacer, Roo.Toolbar.Item, {
20629 enable:Roo.emptyFn,
20630 disable:Roo.emptyFn,
20636 Roo.Toolbar.Fill = Roo.extend(Roo.Toolbar.Spacer, {
20638 render : function(td){
20639 td.style.width = '100%';
20640 Roo.Toolbar.Fill.superclass.render.call(this, td);
20646 Roo.Toolbar.TextItem = function(O){
20647 if (typeof(O) == 'object') {
20650 var s = document.createElement("span");
20651 s.className = "ytb-text";
20653 Roo.Toolbar.TextItem.superclass.constructor.call(this, s);
20655 Roo.extend(Roo.Toolbar.TextItem, Roo.Toolbar.Item, {
20656 enable:Roo.emptyFn,
20657 disable:Roo.emptyFn,
20663 Roo.Toolbar.Button = function(P){
20664 Roo.Toolbar.Button.superclass.constructor.call(this, null, P);
20666 Roo.extend(Roo.Toolbar.Button, Roo.Button, {
20667 render : function(td){
20669 Roo.Toolbar.Button.superclass.render.call(this, td);
20674 destroy : function(){
20675 Roo.Toolbar.Button.superclass.destroy.call(this);
20676 this.td.parentNode.removeChild(this.td);
20682 this.hidden = false;
20683 this.td.style.display = "";
20689 this.hidden = true;
20690 this.td.style.display = "none";
20695 disable : function(){
20696 Roo.fly(this.td).addClass("x-item-disabled");
20697 this.disabled = true;
20702 enable : function(){
20703 Roo.fly(this.td).removeClass("x-item-disabled");
20704 this.disabled = false;
20708 Roo.ToolbarButton = Roo.Toolbar.Button;
20712 Roo.Toolbar.SplitButton = function(Q){
20713 Roo.Toolbar.SplitButton.superclass.constructor.call(this, null, Q);
20715 Roo.extend(Roo.Toolbar.SplitButton, Roo.SplitButton, {
20716 render : function(td){
20718 Roo.Toolbar.SplitButton.superclass.render.call(this, td);
20723 destroy : function(){
20724 Roo.Toolbar.SplitButton.superclass.destroy.call(this);
20725 this.td.parentNode.removeChild(this.td);
20731 this.hidden = false;
20732 this.td.style.display = "";
20738 this.hidden = true;
20739 this.td.style.display = "none";
20744 Roo.Toolbar.MenuButton = Roo.Toolbar.SplitButton;
20750 Roo.PagingToolbar = function(el, ds, A)
20753 if (typeof(el) == 'object' && el.xtype) {
20756 ds = el.dataSource;
20762 Roo.PagingToolbar.superclass.constructor.call(this, el, null, A);
20765 this.renderButtons(this.el);
20769 Roo.extend(Roo.PagingToolbar, Roo.Toolbar, {
20781 displayMsg : 'Displaying {0} - {1} of {2}',
20784 emptyMsg : 'No data to display',
20787 beforePageText : "Page",
20790 afterPageText : "of {0}",
20793 firstText : "First Page",
20796 prevText : "Previous Page",
20799 nextText : "Next Page",
20802 lastText : "Last Page",
20805 refreshText : "Refresh",
20808 renderButtons : function(el){
20809 Roo.PagingToolbar.superclass.render.call(this, el);
20810 this.first = this.addButton({
20811 tooltip: this.firstText,
20812 cls: "x-btn-icon x-grid-page-first",
20814 handler: this.onClick.createDelegate(this, ["first"])
20816 this.prev = this.addButton({
20817 tooltip: this.prevText,
20818 cls: "x-btn-icon x-grid-page-prev",
20820 handler: this.onClick.createDelegate(this, ["prev"])
20822 this.addSeparator();
20823 this.add(this.beforePageText);
20824 this.field = Roo.get(this.addDom({
20829 cls: "x-grid-page-number"
20831 this.field.on("keydown", this.onPagingKeydown, this);
20832 this.field.on("focus", function(){this.dom.select();});
20833 this.afterTextEl = this.addText(String.format(this.afterPageText, 1));
20834 this.field.setHeight(18);
20835 this.addSeparator();
20836 this.next = this.addButton({
20837 tooltip: this.nextText,
20838 cls: "x-btn-icon x-grid-page-next",
20840 handler: this.onClick.createDelegate(this, ["next"])
20842 this.last = this.addButton({
20843 tooltip: this.lastText,
20844 cls: "x-btn-icon x-grid-page-last",
20846 handler: this.onClick.createDelegate(this, ["last"])
20848 this.addSeparator();
20849 this.loading = this.addButton({
20850 tooltip: this.refreshText,
20851 cls: "x-btn-icon x-grid-loading",
20852 handler: this.onClick.createDelegate(this, ["refresh"])
20855 if(this.displayInfo){
20856 this.displayEl = Roo.fly(this.el.dom.firstChild).createChild({cls:'x-paging-info'});
20861 updateInfo : function(){
20862 if(this.displayEl){
20863 var count = this.ds.getCount();
20864 var msg = count == 0 ?
20868 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
20870 this.displayEl.update(msg);
20875 onLoad : function(ds, r, o){
20876 this.cursor = o.params ? o.params.start : 0;
20877 var d = this.getPageData(), ap = d.activePage, ps = d.pages;
20879 this.afterTextEl.el.innerHTML = String.format(this.afterPageText, d.pages);
20880 this.field.dom.value = ap;
20881 this.first.setDisabled(ap == 1);
20882 this.prev.setDisabled(ap == 1);
20883 this.next.setDisabled(ap == ps);
20884 this.last.setDisabled(ap == ps);
20885 this.loading.enable();
20890 getPageData : function(){
20891 var B = this.ds.getTotalCount();
20894 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
20895 pages : B < this.pageSize ? 1 : Math.ceil(B/this.pageSize)
20900 onLoadError : function(){
20901 this.loading.enable();
20905 onPagingKeydown : function(e){
20906 var k = e.getKey();
20907 var d = this.getPageData();
20908 if(k == e.RETURN ){
20909 var v = this.field.dom.value, pageNum;
20910 if(!v || isNaN(pageNum = parseInt(v, 10))){
20911 this.field.dom.value = d.activePage;
20915 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
20916 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
20919 else if(k == e.HOME || (k == e.UP && e.ctrlKey) || (k == e.PAGEUP && e.ctrlKey) || (k == e.RIGHT && e.ctrlKey) || k == e.END || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey))
20921 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
20922 this.field.dom.value = pageNum;
20923 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
20926 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
20928 var v = this.field.dom.value, pageNum;
20929 var increment = (e.shiftKey) ? 10 : 1;
20930 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
20932 if(!v || isNaN(pageNum = parseInt(v, 10))) {
20933 this.field.dom.value = d.activePage;
20936 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
20938 this.field.dom.value = parseInt(v, 10) + increment;
20939 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
20940 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
20948 beforeLoad : function(){
20950 this.loading.disable();
20955 onClick : function(C){
20959 ds.load({params:{start: 0, limit: this.pageSize}});
20962 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
20965 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
20968 var B = ds.getTotalCount();
20969 var extra = B % this.pageSize;
20970 var lastStart = extra ? (B - extra) : B-this.pageSize;
20971 ds.load({params:{start: lastStart, limit: this.pageSize}});
20974 ds.load({params:{start: this.cursor, limit: this.pageSize}});
20981 unbind : function(ds){
20982 ds.un("beforeload", this.beforeLoad, this);
20983 ds.un("load", this.onLoad, this);
20984 ds.un("loadexception", this.onLoadError, this);
20985 ds.un("remove", this.updateInfo, this);
20986 ds.un("add", this.updateInfo, this);
20987 this.ds = undefined;
20992 bind : function(ds){
20993 ds.on("beforeload", this.beforeLoad, this);
20994 ds.on("load", this.onLoad, this);
20995 ds.on("loadexception", this.onLoadError, this);
20996 ds.on("remove", this.updateInfo, this);
20997 ds.on("add", this.updateInfo, this);
21006 Roo.Resizable = function(el, A){
21007 this.el = Roo.get(el);
21010 A.resizeChild = this.el;
21011 this.el = this.el.wrap(typeof A.wrap == "object" ? A.wrap : {cls:"xresizable-wrap"});
21012 this.el.id = this.el.dom.id = A.resizeChild.id + "-rzwrap";
21013 this.el.setStyle("overflow", "hidden");
21014 this.el.setPositioning(A.resizeChild.getPositioning());
21015 A.resizeChild.clearPositioning();
21016 if(!A.width || !A.height){
21017 var csize = A.resizeChild.getSize();
21018 this.el.setSize(csize.width, csize.height);
21020 if(A.pinned && !A.adjustments){
21021 A.adjustments = "auto";
21026 this.proxy = this.el.createProxy({tag: "div", cls: "x-resizable-proxy", id: this.el.id + "-rzproxy"});
21027 this.proxy.unselectable();
21028 this.proxy.enableDisplayMode('block');
21030 Roo.apply(this, A);
21033 this.disableTrackOver = true;
21034 this.el.addClass("x-resizable-pinned");
21037 var B = this.el.getStyle("position");
21038 if(B != "absolute" && B != "fixed"){
21039 this.el.setStyle("position", "relative");
21042 this.handles = 's,e,se';
21043 if(this.multiDirectional){
21044 this.handles += ',n,w';
21047 if(this.handles == "all"){
21048 this.handles = "n s e w ne nw se sw";
21050 var hs = this.handles.split(/\s*?[,;]\s*?| /);
21051 var ps = Roo.Resizable.positions;
21052 for(var i = 0, len = hs.length; i < len; i++){
21053 if(hs[i] && ps[hs[i]]){
21054 var pos = ps[hs[i]];
21055 this[pos] = new Roo.Resizable.Handle(this, pos, this.disableTrackOver, this.transparent);
21060 this.corner = this.southeast;
21062 if(this.handles.indexOf("n") != -1 || this.handles.indexOf("w") != -1){
21063 this.updateBox = true;
21067 this.activeHandle = null;
21069 if(this.resizeChild){
21070 if(typeof this.resizeChild == "boolean"){
21071 this.resizeChild = Roo.get(this.el.dom.firstChild, true);
21073 this.resizeChild = Roo.get(this.resizeChild, true);
21077 if(this.adjustments == "auto"){
21078 var rc = this.resizeChild;
21079 var hw = this.west, he = this.east, hn = this.north, hs = this.south;
21080 if(rc && (hw || hn)){
21081 rc.position("relative");
21082 rc.setLeft(hw ? hw.el.getWidth() : 0);
21083 rc.setTop(hn ? hn.el.getHeight() : 0);
21086 this.adjustments = [
21087 (he ? -he.el.getWidth() : 0) + (hw ? -hw.el.getWidth() : 0),
21088 (hn ? -hn.el.getHeight() : 0) + (hs ? -hs.el.getHeight() : 0) -1
21092 if(this.draggable){
21093 this.dd = this.dynamic ?
21094 this.el.initDD(null) : this.el.initDDProxy(null, {dragElId: this.proxy.id});
21095 this.dd.setHandleElId(this.resizeChild ? this.resizeChild.id : this.el.id);
21103 "beforeresize" : true,
21109 if(this.width !== null && this.height !== null){
21110 this.resizeTo(this.width, this.height);
21112 this.updateChildSize();
21115 this.el.dom.style.zoom = 1;
21118 Roo.Resizable.superclass.constructor.call(this);
21121 Roo.extend(Roo.Resizable, Roo.util.Observable, {
21122 resizeChild : false,
21123 adjustments : [0, 0],
21133 multiDirectional : false,
21134 disableTrackOver : false,
21135 easing : 'easeOutStrong',
21136 widthIncrement : 0,
21137 heightIncrement : 0,
21141 preserveRatio : false,
21142 transparent: false,
21149 constrainTo: undefined,
21152 resizeRegion: undefined,
21157 resizeTo : function(C, D){
21158 this.el.setSize(C, D);
21159 this.updateChildSize();
21160 this.fireEvent("resize", this, C, D, null);
21164 startSizing : function(e, E){
21165 this.fireEvent("beforeresize", this, e);
21169 this.overlay = this.el.createProxy({tag: "div", cls: "x-resizable-overlay", html: " "});
21170 this.overlay.unselectable();
21171 this.overlay.enableDisplayMode("block");
21172 this.overlay.on("mousemove", this.onMouseMove, this);
21173 this.overlay.on("mouseup", this.onMouseUp, this);
21176 this.overlay.setStyle("cursor", E.el.getStyle("cursor"));
21178 this.resizing = true;
21179 this.startBox = this.el.getBox();
21180 this.startPoint = e.getXY();
21181 this.offsets = [(this.startBox.x + this.startBox.width) - this.startPoint[0],
21182 (this.startBox.y + this.startBox.height) - this.startPoint[1]];
21184 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
21185 this.overlay.show();
21187 if(this.constrainTo) {
21188 var ct = Roo.get(this.constrainTo);
21189 this.resizeRegion = ct.getRegion().adjust(
21190 ct.getFrameWidth('t'),
21191 ct.getFrameWidth('l'),
21192 -ct.getFrameWidth('b'),
21193 -ct.getFrameWidth('r')
21198 this.proxy.setStyle('visibility', 'hidden');
21200 this.proxy.setBox(this.startBox);
21202 this.proxy.setStyle('visibility', 'visible');
21208 onMouseDown : function(F, e){
21211 this.activeHandle = F;
21212 this.startSizing(e, F);
21217 onMouseUp : function(e){
21218 var G = this.resizeElement();
21219 this.resizing = false;
21221 this.overlay.hide();
21223 this.fireEvent("resize", this, G.width, G.height, e);
21227 updateChildSize : function(){
21228 if(this.resizeChild){
21230 var child = this.resizeChild;
21231 var adj = this.adjustments;
21232 if(el.dom.offsetWidth){
21233 var b = el.getSize(true);
21234 child.setSize(b.width+adj[0], b.height+adj[1]);
21241 setTimeout(function(){
21242 if(el.dom.offsetWidth){
21243 var b = el.getSize(true);
21244 child.setSize(b.width+adj[0], b.height+adj[1]);
21252 snap : function(H, I, J){
21253 if(!I || !H) return H;
21263 return Math.max(J, K);
21267 resizeElement : function(){
21268 var L = this.proxy.getBox();
21269 if(this.updateBox){
21270 this.el.setBox(L, false, this.animate, this.duration, null, this.easing);
21272 this.el.setSize(L.width, L.height, this.animate, this.duration, null, this.easing);
21275 this.updateChildSize();
21283 constrain : function(v, M, m, mx){
21286 }else if(v - M > mx){
21293 onMouseMove : function(e){
21297 if(this.resizeRegion && !this.resizeRegion.contains(e.getPoint())) {
21302 var curSize = this.curSize || this.startBox;
21303 var x = this.startBox.x, y = this.startBox.y;
21304 var ox = x, oy = y;
21305 var w = curSize.width, h = curSize.height;
21306 var ow = w, oh = h;
21307 var mw = this.minWidth, mh = this.minHeight;
21308 var mxw = this.maxWidth, mxh = this.maxHeight;
21309 var wi = this.widthIncrement;
21310 var hi = this.heightIncrement;
21312 var eventXY = e.getXY();
21313 var diffX = -(this.startPoint[0] - Math.max(this.minX, eventXY[0]));
21314 var diffY = -(this.startPoint[1] - Math.max(this.minY, eventXY[1]));
21316 var pos = this.activeHandle.position;
21321 w = Math.min(Math.max(mw, w), mxw);
21325 h = Math.min(Math.max(mh, h), mxh);
21330 w = Math.min(Math.max(mw, w), mxw);
21331 h = Math.min(Math.max(mh, h), mxh);
21334 diffY = this.constrain(h, diffY, mh, mxh);
21339 diffX = this.constrain(w, diffX, mw, mxw);
21345 w = Math.min(Math.max(mw, w), mxw);
21346 diffY = this.constrain(h, diffY, mh, mxh);
21351 diffX = this.constrain(w, diffX, mw, mxw);
21352 diffY = this.constrain(h, diffY, mh, mxh);
21359 diffX = this.constrain(w, diffX, mw, mxw);
21361 h = Math.min(Math.max(mh, h), mxh);
21367 var sw = this.snap(w, wi, mw);
21368 var sh = this.snap(h, hi, mh);
21369 if(sw != w || sh != h){
21393 if(this.preserveRatio){
21398 h = Math.min(Math.max(mh, h), mxh);
21403 w = Math.min(Math.max(mw, w), mxw);
21408 w = Math.min(Math.max(mw, w), mxw);
21414 w = Math.min(Math.max(mw, w), mxw);
21420 h = Math.min(Math.max(mh, h), mxh);
21428 h = Math.min(Math.max(mh, h), mxh);
21438 h = Math.min(Math.max(mh, h), mxh);
21447 this.proxy.setBounds(x, y, w, h);
21449 this.resizeElement();
21456 handleOver : function(){
21458 this.el.addClass("x-resizable-over");
21463 handleOut : function(){
21464 if(!this.resizing){
21465 this.el.removeClass("x-resizable-over");
21471 getEl : function(){
21477 getResizeChild : function(){
21478 return this.resizeChild;
21483 destroy : function(N){
21484 this.proxy.remove();
21486 this.overlay.removeAllListeners();
21487 this.overlay.remove();
21489 var ps = Roo.Resizable.positions;
21491 if(typeof ps[k] != "function" && this[ps[k]]){
21492 var h = this[ps[k]];
21493 h.el.removeAllListeners();
21498 this.el.update("");
21506 Roo.Resizable.positions = {
21507 n: "north", s: "south", e: "east", w: "west", se: "southeast", sw: "southwest", nw: "northwest", ne: "northeast"
21511 Roo.Resizable.Handle = function(rz, O, P, Q){
21514 var tpl = Roo.DomHelper.createTemplate(
21515 {tag: "div", cls: "x-resizable-handle x-resizable-handle-{0}"}
21518 Roo.Resizable.Handle.prototype.tpl = tpl;
21523 this.el = this.tpl.append(rz.el.dom, [this.position], true);
21524 this.el.unselectable();
21526 this.el.setOpacity(0);
21529 this.el.on("mousedown", this.onMouseDown, this);
21531 this.el.on("mouseover", this.onMouseOver, this);
21532 this.el.on("mouseout", this.onMouseOut, this);
21537 Roo.Resizable.Handle.prototype = {
21538 afterResize : function(rz){
21542 onMouseDown : function(e){
21543 this.rz.onMouseDown(this, e);
21546 onMouseOver : function(e){
21547 this.rz.handleOver(this, e);
21550 onMouseOut : function(e){
21551 this.rz.handleOut(this, e);
21559 Roo.Editor = function(A, B){
21560 Roo.Editor.superclass.constructor.call(this, B);
21565 "beforestartedit" : true,
21568 "startedit" : true,
21571 "beforecomplete" : true,
21577 "specialkey" : true
21581 Roo.extend(Roo.Editor, Roo.Component, {
21604 completeOnEnter : false,
21607 cancelOnEsc : false,
21613 onRender : function(ct, C){
21614 this.el = new Roo.Layer({
21615 shadow: this.shadow,
21621 constrain: this.constrain
21623 this.el.setStyle("overflow", Roo.isGecko ? "auto" : "hidden");
21624 if(this.field.msgTarget != 'title'){
21625 this.field.msgTarget = 'qtip';
21628 this.field.render(this.el);
21630 this.field.el.dom.setAttribute('autocomplete', 'off');
21633 this.field.on("specialkey", this.onSpecialKey, this);
21634 if(this.swallowKeys){
21635 this.field.el.swallowEvent(['keydown','keypress']);
21639 this.field.on("blur", this.onBlur, this);
21640 if(this.field.grow){
21641 this.field.on("autosize", this.el.sync, this.el, {delay:1});
21645 onSpecialKey : function(D, e){
21646 if(this.completeOnEnter && e.getKey() == e.ENTER){
21648 this.completeEdit();
21649 }else if(this.cancelOnEsc && e.getKey() == e.ESC){
21652 this.fireEvent('specialkey', D, e);
21658 startEdit : function(el, E){
21660 this.completeEdit();
21663 this.boundEl = Roo.get(el);
21664 var v = E !== undefined ? E : this.boundEl.dom.innerHTML;
21665 if(!this.rendered){
21666 this.render(this.parentEl || document.body);
21668 if(this.fireEvent("beforestartedit", this, this.boundEl, v) === false){
21672 this.startValue = v;
21673 this.field.setValue(v);
21675 var sz = this.boundEl.getSize();
21676 switch(this.autoSize){
21678 this.setSize(sz.width, "");
21681 this.setSize("", sz.height);
21684 this.setSize(sz.width, sz.height);
21688 this.el.alignTo(this.boundEl, this.alignment);
21689 this.editing = true;
21691 Roo.QuickTips.disable();
21699 setSize : function(w, h){
21700 this.field.setSize(w, h);
21708 realign : function(){
21709 this.el.alignTo(this.boundEl, this.alignment);
21714 completeEdit : function(F){
21718 var v = this.getValue();
21719 if(this.revertInvalid !== false && !this.field.isValid()){
21720 v = this.startValue;
21721 this.cancelEdit(true);
21723 if(String(v) === String(this.startValue) && this.ignoreNoChange){
21724 this.editing = false;
21728 if(this.fireEvent("beforecomplete", this, v, this.startValue) !== false){
21729 this.editing = false;
21730 if(this.updateEl && this.boundEl){
21731 this.boundEl.update(v);
21737 this.fireEvent("complete", this, v, this.startValue);
21742 onShow : function(){
21744 if(this.hideEl !== false){
21745 this.boundEl.hide();
21749 if(Roo.isIE && !this.fixIEFocus){
21750 this.fixIEFocus = true;
21751 this.deferredFocus.defer(50, this);
21753 this.field.focus();
21756 this.fireEvent("startedit", this.boundEl, this.startValue);
21759 deferredFocus : function(){
21761 this.field.focus();
21767 cancelEdit : function(G){
21769 this.setValue(this.startValue);
21777 onBlur : function(){
21778 if(this.allowBlur !== true && this.editing){
21779 this.completeEdit();
21784 onHide : function(){
21786 this.completeEdit();
21791 if(this.field.collapse){
21792 this.field.collapse();
21796 if(this.hideEl !== false){
21797 this.boundEl.show();
21800 Roo.QuickTips.enable();
21806 setValue : function(v){
21807 this.field.setValue(v);
21812 getValue : function(){
21813 return this.field.getValue();
21821 Roo.BasicDialog = function(el, A){
21822 this.el = Roo.get(el);
21823 var dh = Roo.DomHelper;
21824 if(!this.el && A && A.autoCreate){
21825 if(typeof A.autoCreate == "object"){
21826 if(!A.autoCreate.id){
21827 A.autoCreate.id = el;
21830 this.el = dh.append(document.body,
21831 A.autoCreate, true);
21833 this.el = dh.append(document.body,
21834 {tag: "div", id: el, style:'visibility:hidden;'}, true);
21839 el.setDisplayed(true);
21840 el.hide = this.hideAction;
21842 el.addClass("x-dlg");
21844 Roo.apply(this, A);
21846 this.proxy = el.createProxy("x-dlg-proxy");
21847 this.proxy.hide = this.hideAction;
21848 this.proxy.setOpacity(.5);
21852 el.setWidth(A.width);
21855 el.setHeight(A.height);
21858 this.size = el.getSize();
21859 if(typeof A.x != "undefined" && typeof A.y != "undefined"){
21860 this.xy = [A.x,A.y];
21862 this.xy = el.getCenterXY(true);
21867 this.header = el.child("> .x-dlg-hd");
21870 this.body = el.child("> .x-dlg-bd");
21873 this.footer = el.child("> .x-dlg-ft");
21876 this.header = el.createChild({tag: "div", cls:"x-dlg-hd", html: " "}, this.body ? this.body.dom : null);
21879 this.body = el.createChild({tag: "div", cls:"x-dlg-bd"});
21883 this.header.unselectable();
21885 this.header.update(this.title);
21889 this.focusEl = el.createChild({tag: "a", href:"#", cls:"x-dlg-focus", tabIndex:"-1"});
21890 this.focusEl.swallowEvent("click", true);
21892 this.header.wrap({cls:"x-dlg-hd-right"}).wrap({cls:"x-dlg-hd-left"}, true);
21895 this.bwrap = this.body.wrap({tag: "div", cls:"x-dlg-dlg-body"});
21897 this.bwrap.dom.appendChild(this.footer.dom);
21901 this.bg = this.el.createChild({
21902 tag: "div", cls:"x-dlg-bg",
21903 html: '<div class="x-dlg-bg-left"><div class="x-dlg-bg-right"><div class="x-dlg-bg-center"> </div></div></div>'
21905 this.centerBg = this.bg.child("div.x-dlg-bg-center");
21908 if(this.autoScroll !== false && !this.autoTabs){
21909 this.body.setStyle("overflow", "auto");
21913 this.toolbox = this.el.createChild({cls: "x-dlg-toolbox"});
21915 if(this.closable !== false){
21916 this.el.addClass("x-dlg-closable");
21917 this.close = this.toolbox.createChild({cls:"x-dlg-close"});
21918 this.close.on("click", this.closeClick, this);
21919 this.close.addClassOnOver("x-dlg-close-over");
21921 if(this.collapsible !== false){
21922 this.collapseBtn = this.toolbox.createChild({cls:"x-dlg-collapse"});
21923 this.collapseBtn.on("click", this.collapseClick, this);
21924 this.collapseBtn.addClassOnOver("x-dlg-collapse-over");
21925 this.header.on("dblclick", this.collapseClick, this);
21927 if(this.resizable !== false){
21928 this.el.addClass("x-dlg-resizable");
21929 this.resizer = new Roo.Resizable(el, {
21930 minWidth: this.minWidth || 80,
21931 minHeight:this.minHeight || 80,
21932 handles: this.resizeHandles || "all",
21935 this.resizer.on("beforeresize", this.beforeResize, this);
21936 this.resizer.on("resize", this.onResize, this);
21938 if(this.draggable !== false){
21939 el.addClass("x-dlg-draggable");
21940 if (!this.proxyDrag) {
21941 var dd = new Roo.dd.DD(el.dom.id, "WindowDrag");
21944 var dd = new Roo.dd.DDProxy(el.dom.id, "WindowDrag", {dragElId: this.proxy.id});
21947 dd.setHandleElId(this.header.id);
21948 dd.endDrag = this.endMove.createDelegate(this);
21949 dd.startDrag = this.startMove.createDelegate(this);
21950 dd.onDrag = this.onDrag.createDelegate(this);
21955 this.mask = dh.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
21956 this.mask.enableDisplayMode("block");
21958 this.el.addClass("x-dlg-modal");
21961 this.shadow = new Roo.Shadow({
21962 mode : typeof this.shadow == "string" ? this.shadow : "sides",
21963 offset : this.shadowOffset
21966 this.shadowOffset = 0;
21968 if(Roo.useShims && this.shim !== false){
21969 this.shim = this.el.createShim();
21970 this.shim.hide = this.hideAction;
21978 if (this.buttons) {
21979 var bts= this.buttons;
21981 Roo.each(bts, function(b) {
22000 "beforehide" : true,
22006 "beforeshow" : true,
22011 el.on("keydown", this.onKeyDown, this);
22012 el.on("mousedown", this.toFront, this);
22013 Roo.EventManager.onWindowResize(this.adjustViewport, this, true);
22015 Roo.DialogManager.register(this);
22016 Roo.BasicDialog.superclass.constructor.call(this);
22019 Roo.extend(Roo.BasicDialog, Roo.util.Observable, {
22020 shadowOffset: Roo.isIE ? 6 : 5,
22023 minButtonWidth: 75,
22024 defaultButton: null,
22025 buttonAlign: "right",
22031 setTitle : function(B){
22032 this.header.update(B);
22037 closeClick : function(){
22042 collapseClick : function(){
22043 this[this.collapsed ? "expand" : "collapse"]();
22048 collapse : function(){
22049 if(!this.collapsed){
22050 this.collapsed = true;
22051 this.el.addClass("x-dlg-collapsed");
22052 this.restoreHeight = this.el.getHeight();
22053 this.resizeTo(this.el.getWidth(), this.header.getHeight());
22059 expand : function(){
22060 if(this.collapsed){
22061 this.collapsed = false;
22062 this.el.removeClass("x-dlg-collapsed");
22063 this.resizeTo(this.el.getWidth(), this.restoreHeight);
22069 initTabs : function(){
22070 var C = this.getTabs();
22071 while(C.getTab(0)){
22075 this.el.select(this.tabTag+'.x-dlg-tab').each(function(el){
22077 C.addTab(Roo.id(D), D.title);
22085 beforeResize : function(){
22086 this.resizer.minHeight = Math.max(this.minHeight, this.getHeaderFooterHeight(true)+40);
22090 onResize : function(){
22091 this.refreshSize();
22092 this.syncBodyHeight();
22093 this.adjustAssets();
22095 this.fireEvent("resize", this, this.size.width, this.size.height);
22099 onKeyDown : function(e){
22100 if(this.isVisible()){
22101 this.fireEvent("keydown", this, e);
22107 resizeTo : function(D, E){
22108 this.el.setSize(D, E);
22109 this.size = {width: D, height: E};
22110 this.syncBodyHeight();
22111 if(this.fixedcenter){
22114 if(this.isVisible()){
22115 this.constrainXY();
22116 this.adjustAssets();
22119 this.fireEvent("resize", this, D, E);
22126 setContentSize : function(w, h){
22127 h += this.getHeaderFooterHeight() + this.body.getMargins("tb");
22128 w += this.body.getMargins("lr") + this.bwrap.getMargins("lr") + this.centerBg.getPadding("lr");
22130 h += this.body.getPadding("tb") + this.bwrap.getBorderWidth("tb") + this.body.getBorderWidth("tb") + this.el.getBorderWidth("tb");
22131 w += this.body.getPadding("lr") + this.bwrap.getBorderWidth("lr") + this.body.getBorderWidth("lr") + this.bwrap.getPadding("lr") + this.el.getBorderWidth("lr");
22134 h += this.tabs.stripWrap.getHeight() + this.tabs.bodyEl.getMargins("tb") + this.tabs.bodyEl.getPadding("tb");
22135 w += this.tabs.bodyEl.getMargins("lr") + this.tabs.bodyEl.getPadding("lr");
22138 this.resizeTo(w, h);
22144 addKeyListener : function(F, fn, G){
22146 if(typeof F == "object" && !(F instanceof Array)){
22154 var L = function(M, e){
22155 if((!I || e.shiftKey) && (!J || e.ctrlKey) && (!K || e.altKey)){
22156 var k = e.getKey();
22157 if(H instanceof Array){
22158 for(var i = 0, len = H.length; i < len; i++){
22160 fn.call(G || window, M, k, e);
22166 fn.call(G || window, M, k, e);
22171 this.on("keydown", L);
22177 getTabs : function(){
22179 this.el.addClass("x-dlg-auto-tabs");
22180 this.body.addClass(this.tabPosition == "bottom" ? "x-tabs-bottom" : "x-tabs-top");
22181 this.tabs = new Roo.TabPanel(this.body.dom, this.tabPosition == "bottom");
22188 addButton : function(M, N, O){
22189 var dh = Roo.DomHelper;
22191 this.footer = dh.append(this.bwrap, {tag: "div", cls:"x-dlg-ft"}, true);
22193 if(!this.btnContainer){
22194 var tb = this.footer.createChild({
22196 cls:"x-dlg-btns x-dlg-btns-"+this.buttonAlign,
22197 html:'<table cellspacing="0"><tbody><tr></tr></tbody></table><div class="x-clear"></div>'
22199 this.btnContainer = tb.firstChild.firstChild.firstChild;
22204 minWidth: this.minButtonWidth,
22207 if(typeof M == "string"){
22217 if ((typeof(P.position) != 'undefined') && P.position < this.btnContainer.childNodes.length-1) {
22218 P.position = Math.max(0, P.position);
22219 fc = this.btnContainer.childNodes[P.position];
22222 var Q = new Roo.Button(
22224 this.btnContainer.insertBefore(document.createElement("td"),fc)
22225 : this.btnContainer.appendChild(document.createElement("td")),
22229 this.syncBodyHeight();
22236 this.buttons.push(Q);
22242 setDefaultButton : function(R){
22243 this.defaultButton = R;
22248 getHeaderFooterHeight : function(S){
22251 T += this.header.getHeight();
22254 var fm = this.footer.getMargins();
22255 T += (this.footer.getHeight()+fm.top+fm.bottom);
22258 T += this.bwrap.getPadding("tb")+this.bwrap.getBorderWidth("tb");
22259 T += this.centerBg.getPadding("tb");
22264 syncBodyHeight : function(){
22265 var bd = this.body, cb = this.centerBg, bw = this.bwrap;
22266 var U = this.size.height - this.getHeaderFooterHeight(false);
22267 bd.setHeight(U-bd.getMargins("tb"));
22268 var hh = this.header.getHeight();
22269 var h = this.size.height-hh;
22271 bw.setLeftTop(cb.getPadding("l"), hh+cb.getPadding("t"));
22272 bw.setHeight(h-cb.getPadding("tb"));
22273 bw.setWidth(this.el.getWidth(true)-cb.getPadding("lr"));
22274 bd.setWidth(bw.getWidth(true));
22276 this.tabs.syncHeight();
22278 this.tabs.el.repaint();
22285 restoreState : function(){
22286 var V = Roo.state.Manager.get(this.stateId || (this.el.id + "-state"));
22288 this.xy = [V.x, V.y];
22289 this.resizeTo(V.width, V.height);
22295 beforeShow : function(){
22297 if(this.fixedcenter){
22298 this.xy = this.el.getCenterXY(true);
22301 Roo.get(document.body).addClass("x-body-masked");
22302 this.mask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
22306 this.constrainXY();
22310 animShow : function(){
22311 var b = Roo.get(this.animateTarget, true).getBox();
22312 this.proxy.setSize(b.width, b.height);
22313 this.proxy.setLocation(b.x, b.y);
22315 this.proxy.setBounds(this.xy[0], this.xy[1], this.size.width, this.size.height,
22316 true, .35, this.showEl.createDelegate(this));
22321 show : function(W){
22322 if (this.fireEvent("beforeshow", this) === false){
22325 if(this.syncHeightBeforeShow){
22326 this.syncBodyHeight();
22327 }else if(this.firstShow){
22328 this.firstShow = false;
22329 this.syncBodyHeight();
22332 this.animateTarget = W || this.animateTarget;
22333 if(!this.el.isVisible()){
22335 if(this.animateTarget){
22345 showEl : function(){
22347 this.el.setXY(this.xy);
22349 this.adjustAssets(true);
22357 this.fireEvent("show", this);
22362 focus : function(){
22363 if(this.defaultButton){
22364 this.defaultButton.focus();
22366 this.focusEl.focus();
22371 constrainXY : function(){
22372 if(this.constraintoviewport !== false){
22373 if(!this.viewSize){
22374 if(this.container){
22375 var s = this.container.getSize();
22376 this.viewSize = [s.width, s.height];
22378 this.viewSize = [Roo.lib.Dom.getViewWidth(),Roo.lib.Dom.getViewHeight()];
22381 var s = Roo.get(this.container||document).getScroll();
22383 var x = this.xy[0], y = this.xy[1];
22384 var w = this.size.width, h = this.size.height;
22385 var vw = this.viewSize[0], vh = this.viewSize[1];
22389 if(x + w > vw+s.left){
22393 if(y + h > vh+s.top){
22409 if(this.isVisible()){
22410 this.el.setLocation(x, y);
22411 this.adjustAssets();
22418 onDrag : function(){
22419 if(!this.proxyDrag){
22420 this.xy = this.el.getXY();
22421 this.adjustAssets();
22426 adjustAssets : function(X){
22427 var x = this.xy[0], y = this.xy[1];
22428 var w = this.size.width, h = this.size.height;
22431 this.shadow.show(this.el);
22437 if(this.shadow && this.shadow.isVisible()){
22438 this.shadow.show(this.el);
22440 if(this.shim && this.shim.isVisible()){
22441 this.shim.setBounds(x, y, w, h);
22446 adjustViewport : function(w, h){
22448 w = Roo.lib.Dom.getViewWidth();
22449 h = Roo.lib.Dom.getViewHeight();
22453 this.viewSize = [w, h];
22454 if(this.modal && this.mask.isVisible()){
22455 this.mask.setSize(w, h);
22456 this.mask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
22458 if(this.isVisible()){
22459 this.constrainXY();
22465 destroy : function(Y){
22466 if(this.isVisible()){
22467 this.animateTarget = null;
22471 Roo.EventManager.removeResizeListener(this.adjustViewport, this);
22473 this.tabs.destroy(Y);
22487 for(var i = 0, len = this.buttons.length; i < len; i++){
22488 this.buttons[i].destroy();
22492 this.el.removeAllListeners();
22494 this.el.update("");
22498 Roo.DialogManager.unregister(this);
22502 startMove : function(){
22503 if(this.proxyDrag){
22506 if(this.constraintoviewport !== false){
22507 this.dd.constrainTo(document.body, {right: this.shadowOffset, bottom: this.shadowOffset});
22512 endMove : function(){
22513 if(!this.proxyDrag){
22514 Roo.dd.DD.prototype.endDrag.apply(this.dd, arguments);
22516 Roo.dd.DDProxy.prototype.endDrag.apply(this.dd, arguments);
22520 this.refreshSize();
22521 this.adjustAssets();
22523 this.fireEvent("move", this, this.xy[0], this.xy[1]);
22528 toFront : function(){
22529 Roo.DialogManager.bringToFront(this);
22535 toBack : function(){
22536 Roo.DialogManager.sendToBack(this);
22542 center : function(){
22543 var xy = this.el.getCenterXY(true);
22544 this.moveTo(xy[0], xy[1]);
22550 moveTo : function(x, y){
22552 if(this.isVisible()){
22553 this.el.setXY(this.xy);
22554 this.adjustAssets();
22561 alignTo : function(Z, a, c){
22562 this.xy = this.el.getAlignToXY(Z, a, c);
22563 if(this.isVisible()){
22564 this.el.setXY(this.xy);
22565 this.adjustAssets();
22572 anchorTo : function(el, d, f, g){
22573 var j = function(){
22574 this.alignTo(el, d, f);
22576 Roo.EventManager.onWindowResize(j, this);
22578 if(tm != 'undefined'){
22579 Roo.EventManager.on(window, 'scroll', j, this,
22580 {buffer: tm == 'number' ? g : 50});
22589 isVisible : function(){
22590 return this.el.isVisible();
22594 animHide : function(l){
22595 var b = Roo.get(this.animateTarget).getBox();
22597 this.proxy.setBounds(this.xy[0], this.xy[1], this.size.width, this.size.height);
22599 this.proxy.setBounds(b.x, b.y, b.width, b.height, true, .35,
22600 this.hideEl.createDelegate(this, [l]));
22605 hide : function(m){
22606 if (this.fireEvent("beforehide", this) === false){
22610 this.shadow.hide();
22615 if(this.animateTarget){
22625 hideEl : function(n){
22629 Roo.get(document.body).removeClass("x-body-masked");
22632 this.fireEvent("hide", this);
22633 if(typeof n == "function"){
22639 hideAction : function(){
22640 this.setLeft("-10000px");
22641 this.setTop("-10000px");
22642 this.setStyle("visibility", "hidden");
22646 refreshSize : function(){
22647 this.size = this.el.getSize();
22648 this.xy = this.el.getXY();
22649 Roo.state.Manager.set(this.stateId || this.el.id + "-state", this.el.getBox());
22654 setZIndex : function(o){
22656 this.mask.setStyle("z-index", o);
22659 this.shim.setStyle("z-index", ++o);
22662 this.shadow.setZIndex(++o);
22665 this.el.setStyle("z-index", ++o);
22667 this.proxy.setStyle("z-index", ++o);
22670 this.resizer.proxy.setStyle("z-index", ++o);
22674 this.lastZIndex = o;
22679 getEl : function(){
22686 Roo.DialogManager = function(){
22692 var t = function(d1, d2){
22693 return (!d1._lastAccess || d1._lastAccess < d2._lastAccess) ? -1 : 1;
22697 var u = function(){
22699 var v = Roo.DialogManager.zseed;
22700 for(var i = 0, len = q.length; i < len; i++){
22703 dlg.setZIndex(v + (i*10));
22714 register : function(AD){
22720 unregister : function(AE){
22725 for( i = 0, AF = q.length; i < AF; i++){
22741 get : function(id){
22742 return typeof id == "object" ? id : p[id];
22747 bringToFront : function(AG){
22751 AG._lastAccess = new Date().getTime();
22759 sendToBack : function(AH){
22761 AH._lastAccess = -(new Date().getTime());
22768 hideAll : function(){
22770 if(p[id] && typeof p[id] != "function" && p[id].isVisible()){
22780 Roo.LayoutDialog = function(el, v){
22783 if (typeof(v) == 'undefined') {
22784 z = Roo.apply({}, el);
22785 el = Roo.get( document.documentElement || document.body).createChild();
22791 z.autoTabs = false;
22792 Roo.LayoutDialog.superclass.constructor.call(this, el, z);
22793 this.body.setStyle({overflow:"hidden", position:"relative"});
22794 this.layout = new Roo.BorderLayout(this.body.dom, z);
22795 this.layout.monitorWindowResize = false;
22796 this.el.addClass("x-dlg-auto-layout");
22798 this.center = Roo.BasicDialog.prototype.center;
22799 this.on("show", this.layout.layout, this.layout, true);
22801 var xitems = z.items;
22803 Roo.each(xitems, this.addxtype, this);
22808 Roo.extend(Roo.LayoutDialog, Roo.BasicDialog, {
22811 endUpdate : function(){
22812 this.layout.endUpdate();
22817 beginUpdate : function(){
22818 this.layout.beginUpdate();
22823 getLayout : function(){
22824 return this.layout;
22827 showEl : function(){
22828 Roo.LayoutDialog.superclass.showEl.apply(this, arguments);
22830 this.layout.layout();
22836 syncBodyHeight : function(){
22837 Roo.LayoutDialog.superclass.syncBodyHeight.call(this);
22838 if(this.layout){this.layout.layout();}
22844 addxtype : function(c) {
22845 return this.layout.addxtype(c);
22853 Roo.MessageBox = function(){
22855 var E, F, G, H, I, pp;
22859 var M = function(Q){
22861 Roo.callback(B.fn, B.scope||window, [Q, K.dom.value], 1);
22865 var N = function(){
22867 A.el.removeClass(B.cls);
22870 Roo.TaskMgr.stop(D);
22876 var O = function(b){
22880 J["cancel"].hide();
22883 A.footer.dom.style.display = 'none';
22887 A.footer.dom.style.display = '';
22889 if(typeof J[k] != "function"){
22892 J[k].setText(typeof b[k] == "string" ? b[k] : Roo.MessageBox.buttonText[k]);
22893 Q += J[k].el.getWidth()+15;
22903 var P = function(d, k, e){
22904 if(B && B.closable !== false){
22915 getDialog : function(){
22917 A = new Roo.BasicDialog("x-msg-box", {
22922 constraintoviewport:false,
22924 collapsible : false,
22927 width:400, height:100,
22928 buttonAlign:"center",
22929 closeClick : function(){
22930 if(B && B.buttons && B.buttons.no && !B.buttons.cancel){
22939 A.addKeyListener(27, P);
22941 var bt = this.buttonText;
22942 J["ok"] = A.addButton(bt["ok"], M.createCallback("ok"));
22943 J["yes"] = A.addButton(bt["yes"], M.createCallback("yes"));
22944 J["no"] = A.addButton(bt["no"], M.createCallback("no"));
22945 J["cancel"] = A.addButton(bt["cancel"], M.createCallback("cancel"));
22946 E = A.body.createChild({
22948 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" /><textarea class="roo-mb-textarea"></textarea><div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
22950 F = E.dom.firstChild;
22951 G = Roo.get(E.dom.childNodes[2]);
22952 G.enableDisplayMode();
22953 G.addKeyListener([10,13], function(){
22954 if(A.isVisible() && B && B.buttons){
22957 }else if(B.buttons.yes){
22962 H = Roo.get(E.dom.childNodes[3]);
22963 H.enableDisplayMode();
22964 I = Roo.get(E.dom.childNodes[4]);
22965 I.enableDisplayMode();
22966 var pf = I.dom.firstChild;
22968 pp = Roo.get(pf.firstChild);
22969 pp.setHeight(pf.offsetHeight);
22978 updateText : function(j){
22979 if(!A.isVisible() && !B.width){
22980 A.resizeTo(this.maxWidth, 100);
22983 F.innerHTML = j || ' ';
22984 var w = Math.max(Math.min(B.width || F.offsetWidth, this.maxWidth),
22985 Math.max(B.minWidth || this.minWidth, L));
22990 A.fixedcenter = false;
22993 A.setContentSize(w, E.getHeight());
22995 A.fixedcenter = true;
23002 updateProgress : function(l, m){
23004 this.updateText(m);
23007 pp.setWidth(Math.floor(l*I.dom.firstChild.offsetWidth));
23014 isVisible : function(){
23015 return A && A.isVisible();
23021 if(this.isVisible()){
23028 show : function(n){
23029 if(this.isVisible()){
23032 var d = this.getDialog();
23034 d.setTitle(B.title || " ");
23035 d.close.setDisplayed(B.closable !== false);
23037 B.prompt = B.prompt || (B.multiline ? true : false);
23042 H.setHeight(typeof B.multiline == "number" ?
23043 B.multiline : this.defaultTextHeight);
23054 I.setDisplayed(B.progress === true);
23055 this.updateProgress(0);
23056 K.dom.value = B.value || "";
23058 A.setDefaultButton(K);
23060 var bs = B.buttons;
23064 }else if(bs && bs.yes){
23068 A.setDefaultButton(db);
23072 this.updateText(B.msg);
23074 d.el.addClass(B.cls);
23077 d.proxyDrag = B.proxyDrag === true;
23078 d.modal = B.modal !== false;
23079 d.mask = B.modal !== false ? C : false;
23080 if(!d.isVisible()){
23082 document.body.appendChild(A.el.dom);
23083 d.animateTarget = null;
23091 progress : function(o, p){
23098 minWidth: this.minProgressWidth,
23106 alert : function(q, r, fn, s){
23120 wait : function(t, u){
23131 D = Roo.TaskMgr.start({
23133 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
23142 confirm : function(v, x, fn, y){
23146 buttons: this.YESNO,
23156 prompt : function(z, AA, fn, AB, AC){
23160 buttons: this.OKCANCEL,
23176 YESNO : {yes:true, no:true},
23179 OKCANCEL : {ok:true, cancel:true},
23182 YESNOCANCEL : {yes:true, no:true, cancel:true},
23186 defaultTextHeight : 75,
23195 minProgressWidth : 250,
23209 Roo.Msg = Roo.MessageBox;
23214 Roo.QuickTips = function(){
23215 var el, A, B, C, tm, D, E, F = {}, esc, removeCls = null, bdLeft, bdRight;
23216 var ce, bd, xy, dd;
23217 var G = false, H = true, I = false;
23218 var J = 1, K = 1, L = 1, M = [];
23220 var N = function(e){
23224 var t = e.getTarget();
23225 if(!t || t.nodeType !== 1 || t == document || t == document.body){
23228 if(ce && t == ce.el){
23234 J = S.defer(tm.showDelay, tm, [F[t.id]]);
23237 var W, et = Roo.fly(t);
23238 var ns = D.namespace;
23239 if(tm.interceptTitles && t.title){
23242 t.removeAttribute("title");
23243 e.preventDefault();
23245 W = t.qtip || et.getAttributeNS(ns, D.attribute);
23248 J = S.defer(tm.showDelay, tm, [{
23251 width: et.getAttributeNS(ns, D.width),
23252 autoHide: et.getAttributeNS(ns, D.hide) != "user",
23253 title: et.getAttributeNS(ns, D.title),
23254 cls: et.getAttributeNS(ns, D.cls)
23259 var O = function(e){
23261 var t = e.getTarget();
23262 if(t && ce && ce.el == t && (tm.autoHide && ce.autoHide !== false)){
23263 K = setTimeout(U, tm.hideDelay);
23267 var P = function(e){
23274 if(tm.trackMouse && ce){
23279 var Q = function(e){
23283 if(tm.hideOnClick){
23286 tm.enable.defer(100, tm);
23291 var R = function(){
23295 var S = function(o){
23303 el.removeClass(removeCls);
23307 el.addClass(ce.cls);
23308 removeCls = ce.cls;
23311 C.update(ce.title);
23318 el.dom.style.width = tm.maxWidth+'px';
23321 var p = R(), w = ce.width;
23324 var aw = Math.max(td.offsetWidth, td.clientWidth, td.scrollWidth);
23325 if(aw > tm.maxWidth){
23327 }else if(aw < tm.minWidth){
23335 el.setWidth(parseInt(w, 10) + p);
23336 if(ce.autoHide === false){
23337 E.setDisplayed(true);
23342 E.setDisplayed(false);
23348 el.avoidY = xy[1]-18;
23353 el.setStyle("visibility", "visible");
23354 el.fadeIn({callback: T});
23360 var T = function(){
23364 if(tm.autoDismiss && ce.autoHide !== false){
23365 L = setTimeout(U, tm.autoDismissDelay);
23370 var U = function(W){
23374 if(el.isVisible()){
23376 if(W !== true && tm.animate){
23377 el.fadeOut({callback: V});
23384 var V = function(){
23387 el.removeClass(removeCls);
23401 interceptTitles : false,
23404 trackMouse : false,
23407 hideOnClick : true,
23419 autoDismiss : true,
23422 autoDismissDelay : 5000,
23443 tm = Roo.QuickTips;
23447 Roo.onReady(Roo.QuickTips.init, Roo.QuickTips);
23451 el = new Roo.Layer({cls:"x-tip", shadow:"drop", shim: true, constrain:true, shadowOffset:4});
23452 el.fxDefaults = {stopFx: true};
23455 el.update('<div class="x-tip-bd"><div class="x-tip-close"></div><h3></h3><div class="x-tip-bd-inner"></div><div class="x-clear"></div></div>');
23456 C = el.child('h3');
23457 C.enableDisplayMode("block");
23458 A = el.child('div.x-tip-bd');
23459 B = el.child('div.x-tip-bd-inner');
23462 E = el.child('div.x-tip-close');
23463 E.enableDisplayMode("block");
23465 var d = Roo.get(document);
23466 d.on("mousedown", Q);
23467 d.on("mouseover", N);
23468 d.on("mouseout", O);
23469 d.on("mousemove", P);
23470 esc = d.addKeyListener(27, U);
23473 dd = el.initDD("default", null, {
23474 onDrag : function(){
23478 dd.setHandleElId(C.id);
23490 register : function(X){
23491 var cs = X instanceof Array ? X : arguments;
23492 for(var i = 0, len = cs.length; i < len; i++) {
23494 var target = c.target;
23496 if(target instanceof Array){
23497 for(var j = 0, jlen = target.length; j < jlen; j++){
23501 F[typeof target == 'string' ? target : Roo.id(target)] = c;
23509 unregister : function(el){
23510 delete F[Roo.id(el)];
23515 enable : function(){
23526 disable : function(){
23540 isEnabled : function(){
23547 attribute : "qtip",
23558 Roo.QuickTips.tips = Roo.QuickTips.register;
23565 Roo.tree.TreePanel = function(el, A){
23578 Roo.apply(this, A);
23579 Roo.tree.TreePanel.superclass.constructor.call(this);
23580 this.el = Roo.get(el);
23581 this.el.addClass('x-tree');
23584 this.setRootNode( Roo.factory(B, Roo.tree));
23587 this.loader = Roo.factory(C, Roo.tree);
23592 this.id = this.el.id;
23596 "beforeload" : true,
23602 "textchange" : true,
23605 "beforeexpand" : true,
23608 "beforecollapse" : true,
23614 "disabledchange" : true,
23620 "beforeclick":true,
23623 "checkchange":true,
23632 "contextmenu":true,
23635 "beforechildrenrendered":true,
23638 "startdrag" : true,
23647 "beforenodedrop" : true,
23653 "nodedragover" : true
23656 if(this.singleExpand){
23657 this.on("beforeexpand", this.restrictExpand, this);
23660 Roo.extend(Roo.tree.TreePanel, Roo.data.Tree, {
23661 rootVisible : true,
23662 animate: Roo.enableFx,
23665 hlDrop : Roo.enableFx,
23669 rendererTip: false,
23671 restrictExpand : function(D){
23672 var p = D.parentNode;
23674 if(p.expandedChild && p.expandedChild.parentNode == p){
23675 p.expandedChild.collapse();
23678 p.expandedChild = D;
23683 setRootNode : function(E){
23684 Roo.tree.TreePanel.superclass.setRootNode.call(this, E);
23685 if(!this.rootVisible){
23686 E.ui = new Roo.tree.RootTreeNodeUI(E);
23693 getEl : function(){
23699 getLoader : function(){
23700 return this.loader;
23705 expandAll : function(){
23706 this.root.expand(true);
23711 collapseAll : function(){
23712 this.root.collapse(true);
23717 getSelectionModel : function(){
23718 if(!this.selModel){
23719 this.selModel = new Roo.tree.DefaultSelectionModel();
23721 return this.selModel;
23726 getChecked : function(a, F){
23727 F = F || this.root;
23729 var f = function(){
23730 if(this.attributes.checked){
23731 r.push(!a ? this : (a == 'id' ? this.id : this.attributes[a]));
23741 expandPath : function(G, H, I){
23743 var J = G.split(this.pathSeparator);
23745 if(K.attributes[H] != J[1]){
23752 var f = function(){
23753 if(++L == J.length){
23759 var c = K.findChild(H, J[L]);
23768 c.expand(false, false, f);
23770 K.expand(false, false, f);
23775 selectPath : function(M, N, O){
23777 var P = M.split(this.pathSeparator);
23780 var f = function(Q, R){
23782 var n = R.findChild(N, v);
23797 this.expandPath(P.join(this.pathSeparator), N, f);
23799 this.root.select();
23801 O(true, this.root);
23806 getTreeEl : function(){
23812 render : function(){
23813 if (this.innerCt) {
23818 this.innerCt = this.el.createChild({tag:"ul",
23819 cls:"x-tree-root-ct " +
23820 (this.lines ? "x-tree-lines" : "x-tree-no-lines")});
23822 if(this.containerScroll){
23823 Roo.dd.ScrollManager.register(this.el);
23825 if((this.enableDD || this.enableDrop) && !this.dropZone){
23828 this.dropZone = new Roo.tree.TreeDropZone(this, this.dropConfig || {
23829 ddGroup: this.ddGroup || "TreeDD", appendOnly: this.ddAppendOnly === true
23832 if((this.enableDD || this.enableDrag) && !this.dragZone){
23835 this.dragZone = new Roo.tree.TreeDragZone(this, this.dragConfig || {
23836 ddGroup: this.ddGroup || "TreeDD",
23837 scroll: this.ddScroll
23841 this.getSelectionModel().init(this);
23843 console.log("ROOT not set in tree");
23847 this.root.render();
23848 if(!this.rootVisible){
23849 this.root.renderChildren();
23860 Roo.tree.DefaultSelectionModel = function(){
23861 this.selNode = null;
23866 "selectionchange" : true,
23870 "beforeselect" : true
23874 Roo.extend(Roo.tree.DefaultSelectionModel, Roo.util.Observable, {
23875 init : function(A){
23877 A.getTreeEl().on("keydown", this.onKeyDown, this);
23878 A.on("click", this.onNodeClick, this);
23881 onNodeClick : function(B, e){
23882 if (e.ctrlKey && this.selNode == B) {
23892 select : function(C){
23893 var D = this.selNode;
23894 if(D != C && this.fireEvent('beforeselect', this, C, D) !== false){
23896 D.ui.onSelectedChange(false);
23900 C.ui.onSelectedChange(true);
23901 this.fireEvent("selectionchange", this, C, D);
23908 unselect : function(E){
23909 if(this.selNode == E){
23910 this.clearSelections();
23916 clearSelections : function(){
23917 var n = this.selNode;
23919 n.ui.onSelectedChange(false);
23920 this.selNode = null;
23921 this.fireEvent("selectionchange", this, null);
23928 getSelectedNode : function(){
23929 return this.selNode;
23934 isSelected : function(F){
23935 return this.selNode == F;
23940 selectPrevious : function(){
23941 var s = this.selNode || this.lastSelNode;
23945 var ps = s.previousSibling;
23947 if(!ps.isExpanded() || ps.childNodes.length < 1){
23948 return this.select(ps);
23950 var lc = ps.lastChild;
23951 while(lc && lc.isExpanded() && lc.childNodes.length > 0){
23954 return this.select(lc);
23956 } else if(s.parentNode && (this.tree.rootVisible || !s.parentNode.isRoot)){
23957 return this.select(s.parentNode);
23964 selectNext : function(){
23965 var s = this.selNode || this.lastSelNode;
23969 if(s.firstChild && s.isExpanded()){
23970 return this.select(s.firstChild);
23971 }else if(s.nextSibling){
23972 return this.select(s.nextSibling);
23973 }else if(s.parentNode){
23975 s.parentNode.bubble(function(){
23976 if(this.nextSibling){
23977 newS = this.getOwnerTree().selModel.select(this.nextSibling);
23986 onKeyDown : function(e){
23987 var s = this.selNode || this.lastSelNode;
23993 var k = e.getKey();
24001 this.selectPrevious();
24004 e.preventDefault();
24005 if(s.hasChildNodes()){
24006 if(!s.isExpanded()){
24008 }else if(s.firstChild){
24009 this.select(s.firstChild, e);
24014 e.preventDefault();
24015 if(s.hasChildNodes() && s.isExpanded()){
24017 }else if(s.parentNode && (this.tree.rootVisible || s.parentNode != this.tree.getRootNode())){
24018 this.select(s.parentNode, e);
24027 Roo.tree.MultiSelectionModel = function(){
24028 this.selNodes = [];
24033 "selectionchange" : true
24037 Roo.extend(Roo.tree.MultiSelectionModel, Roo.util.Observable, {
24038 init : function(G){
24040 G.getTreeEl().on("keydown", this.onKeyDown, this);
24041 G.on("click", this.onNodeClick, this);
24044 onNodeClick : function(H, e){
24045 this.select(H, e, e.ctrlKey);
24050 select : function(I, e, J){
24052 this.clearSelections(true);
24054 if(this.isSelected(I)){
24055 this.lastSelNode = I;
24059 this.selNodes.push(I);
24060 this.selMap[I.id] = I;
24061 this.lastSelNode = I;
24062 I.ui.onSelectedChange(true);
24063 this.fireEvent("selectionchange", this, this.selNodes);
24069 unselect : function(K){
24070 if(this.selMap[K.id]){
24071 K.ui.onSelectedChange(false);
24072 var sn = this.selNodes;
24075 index = sn.indexOf(K);
24077 for(var i = 0, len = sn.length; i < len; i++){
24085 this.selNodes.splice(index, 1);
24087 delete this.selMap[K.id];
24088 this.fireEvent("selectionchange", this, this.selNodes);
24094 clearSelections : function(L){
24095 var sn = this.selNodes;
24097 for(var i = 0, len = sn.length; i < len; i++){
24098 sn[i].ui.onSelectedChange(false);
24101 this.selNodes = [];
24104 this.fireEvent("selectionchange", this, this.selNodes);
24111 isSelected : function(M){
24112 return this.selMap[M.id] ? true : false;
24117 getSelectedNodes : function(){
24118 return this.selNodes;
24121 onKeyDown : Roo.tree.DefaultSelectionModel.prototype.onKeyDown,
24123 selectNext : Roo.tree.DefaultSelectionModel.prototype.selectNext,
24125 selectPrevious : Roo.tree.DefaultSelectionModel.prototype.selectPrevious
24132 Roo.tree.TreeNode = function(A){
24134 if(typeof A == "string"){
24138 this.childrenRendered = false;
24139 this.rendered = false;
24140 Roo.tree.TreeNode.superclass.constructor.call(this, A);
24141 this.expanded = A.expanded === true;
24142 this.isTarget = A.isTarget !== false;
24143 this.draggable = A.draggable !== false && A.allowDrag !== false;
24144 this.allowChildren = A.allowChildren !== false && A.allowDrop !== false;
24148 this.text = A.text;
24151 this.disabled = A.disabled === true;
24156 "textchange" : true,
24159 "beforeexpand" : true,
24162 "beforecollapse" : true,
24168 "disabledchange" : true,
24174 "beforeclick":true,
24177 "checkchange":true,
24186 "contextmenu":true,
24189 "beforechildrenrendered":true
24192 var B = this.attributes.uiProvider || Roo.tree.TreeNodeUI;
24196 this.ui = new B(this);
24198 Roo.extend(Roo.tree.TreeNode, Roo.data.Node, {
24199 preventHScroll: true,
24202 isExpanded : function(){
24203 return this.expanded;
24208 getUI : function(){
24213 setFirstChild : function(C){
24214 var of = this.firstChild;
24215 Roo.tree.TreeNode.superclass.setFirstChild.call(this, C);
24216 if(this.childrenRendered && of && C != of){
24217 of.renderIndent(true, true);
24220 this.renderIndent(true, true);
24225 setLastChild : function(D){
24226 var ol = this.lastChild;
24227 Roo.tree.TreeNode.superclass.setLastChild.call(this, D);
24228 if(this.childrenRendered && ol && D != ol){
24229 ol.renderIndent(true, true);
24232 this.renderIndent(true, true);
24238 appendChild : function(){
24239 var E = Roo.tree.TreeNode.superclass.appendChild.apply(this, arguments);
24240 if(E && this.childrenRendered){
24244 this.ui.updateExpandIcon();
24249 removeChild : function(F){
24250 this.ownerTree.getSelectionModel().unselect(F);
24251 Roo.tree.TreeNode.superclass.removeChild.apply(this, arguments);
24253 if(this.childrenRendered){
24256 if(this.childNodes.length < 1){
24257 this.collapse(false, false);
24259 this.ui.updateExpandIcon();
24261 if(!this.firstChild) {
24262 this.childrenRendered = false;
24268 insertBefore : function(G, H){
24269 var I = Roo.tree.TreeNode.superclass.insertBefore.apply(this, arguments);
24270 if(I && H && this.childrenRendered){
24274 this.ui.updateExpandIcon();
24280 setText : function(J){
24283 this.attributes.text = J;
24285 this.ui.onTextChange(this, J, K);
24288 this.fireEvent("textchange", this, J, K);
24293 select : function(){
24294 this.getOwnerTree().getSelectionModel().select(this);
24299 unselect : function(){
24300 this.getOwnerTree().getSelectionModel().unselect(this);
24305 isSelected : function(){
24306 return this.getOwnerTree().getSelectionModel().isSelected(this);
24311 expand : function(L, M, N){
24312 if(!this.expanded){
24313 if(this.fireEvent("beforeexpand", this, L, M) === false){
24316 if(!this.childrenRendered){
24317 this.renderChildren();
24320 this.expanded = true;
24321 if(!this.isHiddenRoot() && (this.getOwnerTree().animate && M !== false) || M){
24322 this.ui.animExpand(function(){
24323 this.fireEvent("expand", this);
24324 if(typeof N == "function"){
24328 this.expandChildNodes(true);
24330 }.createDelegate(this));
24334 this.fireEvent("expand", this);
24335 if(typeof N == "function"){
24340 if(typeof N == "function"){
24345 this.expandChildNodes(true);
24349 isHiddenRoot : function(){
24350 return this.isRoot && !this.getOwnerTree().rootVisible;
24355 collapse : function(O, P){
24356 if(this.expanded && !this.isHiddenRoot()){
24357 if(this.fireEvent("beforecollapse", this, O, P) === false){
24361 this.expanded = false;
24362 if((this.getOwnerTree().animate && P !== false) || P){
24363 this.ui.animCollapse(function(){
24364 this.fireEvent("collapse", this);
24366 this.collapseChildNodes(true);
24368 }.createDelegate(this));
24371 this.ui.collapse();
24372 this.fireEvent("collapse", this);
24376 var cs = this.childNodes;
24377 for(var i = 0, len = cs.length; i < len; i++) {
24378 cs[i].collapse(true, false);
24384 delayedExpand : function(Q){
24385 if(!this.expandProcId){
24386 this.expandProcId = this.expand.defer(Q, this);
24391 cancelExpand : function(){
24392 if(this.expandProcId){
24393 clearTimeout(this.expandProcId);
24396 this.expandProcId = false;
24401 toggle : function(){
24411 ensureVisible : function(R){
24412 var S = this.getOwnerTree();
24413 S.expandPath(this.parentNode.getPath(), false, function(){
24414 S.getTreeEl().scrollChildIntoView(this.ui.anchor);
24416 }.createDelegate(this));
24421 expandChildNodes : function(T){
24422 var cs = this.childNodes;
24423 for(var i = 0, len = cs.length; i < len; i++) {
24430 collapseChildNodes : function(U){
24431 var cs = this.childNodes;
24432 for(var i = 0, len = cs.length; i < len; i++) {
24439 disable : function(){
24440 this.disabled = true;
24442 if(this.rendered && this.ui.onDisableChange){
24443 this.ui.onDisableChange(this, true);
24446 this.fireEvent("disabledchange", this, true);
24451 enable : function(){
24452 this.disabled = false;
24453 if(this.rendered && this.ui.onDisableChange){
24454 this.ui.onDisableChange(this, false);
24457 this.fireEvent("disabledchange", this, false);
24461 renderChildren : function(V){
24463 this.fireEvent("beforechildrenrendered", this);
24465 var cs = this.childNodes;
24466 for(var i = 0, len = cs.length; i < len; i++){
24467 cs[i].render(true);
24470 this.childrenRendered = true;
24474 sort : function(fn, W){
24475 Roo.tree.TreeNode.superclass.sort.apply(this, arguments);
24476 if(this.childrenRendered){
24477 var cs = this.childNodes;
24478 for(var i = 0, len = cs.length; i < len; i++){
24479 cs[i].render(true);
24485 render : function(X){
24487 if(!this.rendered){
24488 this.rendered = true;
24490 this.expanded = false;
24491 this.expand(false, false);
24497 renderIndent : function(Y, Z){
24499 this.ui.childIndent = null;
24502 this.ui.renderIndent();
24503 if(Y === true && this.childrenRendered){
24504 var cs = this.childNodes;
24505 for(var i = 0, len = cs.length; i < len; i++){
24506 cs[i].renderIndent(true, Z);
24516 Roo.tree.AsyncTreeNode = function(A){
24517 this.loaded = false;
24518 this.loading = false;
24519 Roo.tree.AsyncTreeNode.superclass.constructor.apply(this, arguments);
24522 this.addEvents({'beforeload':true, 'load': true});
24528 Roo.extend(Roo.tree.AsyncTreeNode, Roo.tree.TreeNode, {
24529 expand : function(B, C, D){
24532 var f = function(){
24534 clearInterval(timer);
24535 this.expand(B, C, D);
24537 }.createDelegate(this);
24538 timer = setInterval(f, 200);
24542 if(this.fireEvent("beforeload", this) === false){
24546 this.loading = true;
24547 this.ui.beforeLoad(this);
24548 var loader = this.loader || this.attributes.loader || this.getOwnerTree().getLoader();
24550 loader.load(this, this.loadComplete.createDelegate(this, [B, C, D]));
24555 Roo.tree.AsyncTreeNode.superclass.expand.call(this, B, C, D);
24560 isLoading : function(){
24561 return this.loading;
24564 loadComplete : function(E, F, G){
24565 this.loading = false;
24566 this.loaded = true;
24567 this.ui.afterLoad(this);
24568 this.fireEvent("load", this);
24569 this.expand(E, F, G);
24574 isLoaded : function(){
24575 return this.loaded;
24578 hasChildNodes : function(){
24579 if(!this.isLeaf() && !this.loaded){
24582 return Roo.tree.AsyncTreeNode.superclass.hasChildNodes.call(this);
24588 reload : function(H){
24589 this.collapse(false, false);
24590 while(this.firstChild){
24591 this.removeChild(this.firstChild);
24594 this.childrenRendered = false;
24595 this.loaded = false;
24596 if(this.isHiddenRoot()){
24597 this.expanded = false;
24600 this.expand(false, false, H);
24608 Roo.tree.TreeNodeUI = function(A){
24610 this.rendered = false;
24611 this.animating = false;
24612 this.emptyIcon = Roo.BLANK_IMAGE_URL;
24615 Roo.tree.TreeNodeUI.prototype = {
24616 removeChild : function(B){
24618 this.ctNode.removeChild(B.ui.getEl());
24622 beforeLoad : function(){
24623 this.addClass("x-tree-node-loading");
24626 afterLoad : function(){
24627 this.removeClass("x-tree-node-loading");
24630 onTextChange : function(C, D, E){
24632 this.textNode.innerHTML = D;
24636 onDisableChange : function(F, G){
24639 this.addClass("x-tree-node-disabled");
24641 this.removeClass("x-tree-node-disabled");
24645 onSelectedChange : function(H){
24648 this.addClass("x-tree-selected");
24651 this.removeClass("x-tree-selected");
24655 onMove : function(I, J, K, L, M, N){
24656 this.childIndent = null;
24658 var targetNode = L.ui.getContainer();
24660 this.holder = document.createElement("div");
24661 this.holder.appendChild(this.wrap);
24664 var insertBefore = N ? N.ui.getEl() : null;
24666 targetNode.insertBefore(this.wrap, insertBefore);
24668 targetNode.appendChild(this.wrap);
24671 this.node.renderIndent(true);
24675 addClass : function(O){
24677 Roo.fly(this.elNode).addClass(O);
24681 removeClass : function(P){
24683 Roo.fly(this.elNode).removeClass(P);
24687 remove : function(){
24689 this.holder = document.createElement("div");
24690 this.holder.appendChild(this.wrap);
24694 fireEvent : function(){
24695 return this.node.fireEvent.apply(this.node, arguments);
24698 initEvents : function(){
24699 this.node.on("move", this.onMove, this);
24700 var E = Roo.EventManager;
24701 var a = this.anchor;
24703 var el = Roo.fly(a, '_treeui');
24706 el.setStyle("text-decoration", "none");
24710 el.on("click", this.onClick, this);
24711 el.on("dblclick", this.onDblClick, this);
24714 Roo.EventManager.on(this.checkbox,
24715 Roo.isIE ? 'click' : 'change', this.onCheckChange, this);
24719 el.on("contextmenu", this.onContextMenu, this);
24721 var Q = Roo.fly(this.iconNode);
24722 Q.on("click", this.onClick, this);
24723 Q.on("dblclick", this.onDblClick, this);
24724 Q.on("contextmenu", this.onContextMenu, this);
24725 E.on(this.ecNode, "click", this.ecClick, this, true);
24727 if(this.node.disabled){
24728 this.addClass("x-tree-node-disabled");
24730 if(this.node.hidden){
24731 this.addClass("x-tree-node-disabled");
24733 var ot = this.node.getOwnerTree();
24734 var dd = ot.enableDD || ot.enableDrag || ot.enableDrop;
24735 if(dd && (!this.node.isRoot || ot.rootVisible)){
24736 Roo.dd.Registry.register(this.elNode, {
24738 handles: this.getDDHandles(),
24744 getDDHandles : function(){
24745 return [this.iconNode, this.textNode];
24750 this.wrap.style.display = "none";
24756 this.wrap.style.display = "";
24760 onContextMenu : function(e){
24761 if (this.node.hasListener("contextmenu") || this.node.getOwnerTree().hasListener("contextmenu")) {
24762 e.preventDefault();
24764 this.fireEvent("contextmenu", this.node, e);
24768 onClick : function(e){
24773 if(this.fireEvent("beforeclick", this.node, e) !== false){
24774 if(!this.disabled && this.node.attributes.href){
24775 this.fireEvent("click", this.node, e);
24779 e.preventDefault();
24784 if(this.node.attributes.singleClickExpand && !this.animating && this.node.hasChildNodes()){
24785 this.node.toggle();
24789 this.fireEvent("click", this.node, e);
24795 onDblClick : function(e){
24796 e.preventDefault();
24801 this.toggleCheck();
24803 if(!this.animating && this.node.hasChildNodes()){
24804 this.node.toggle();
24807 this.fireEvent("dblclick", this.node, e);
24810 onCheckChange : function(){
24811 var R = this.checkbox.checked;
24812 this.node.attributes.checked = R;
24813 this.fireEvent('checkchange', this.node, R);
24816 ecClick : function(e){
24817 if(!this.animating && this.node.hasChildNodes()){
24818 this.node.toggle();
24822 startDrop : function(){
24823 this.dropping = true;
24827 endDrop : function(){
24828 setTimeout(function(){
24829 this.dropping = false;
24830 }.createDelegate(this), 50);
24833 expand : function(){
24834 this.updateExpandIcon();
24835 this.ctNode.style.display = "";
24838 focus : function(){
24839 if(!this.node.preventHScroll){
24840 try{this.anchor.focus();
24842 }else if(!Roo.isIE){
24844 var noscroll = this.node.getOwnerTree().getTreeEl().dom;
24845 var l = noscroll.scrollLeft;
24846 this.anchor.focus();
24847 noscroll.scrollLeft = l;
24852 toggleCheck : function(S){
24853 var cb = this.checkbox;
24855 cb.checked = (S === undefined ? !cb.checked : S);
24861 this.anchor.blur();
24865 animExpand : function(T){
24866 var ct = Roo.get(this.ctNode);
24868 if(!this.node.hasChildNodes()){
24869 this.updateExpandIcon();
24870 this.ctNode.style.display = "";
24875 this.animating = true;
24876 this.updateExpandIcon();
24879 callback : function(){
24880 this.animating = false;
24884 duration: this.node.ownerTree.duration || .25
24888 highlight : function(){
24889 var U = this.node.getOwnerTree();
24890 Roo.fly(this.wrap).highlight(
24891 U.hlColor || "C3DAF9",
24892 {endColor: U.hlBaseColor}
24896 collapse : function(){
24897 this.updateExpandIcon();
24898 this.ctNode.style.display = "none";
24901 animCollapse : function(V){
24902 var ct = Roo.get(this.ctNode);
24903 ct.enableDisplayMode('block');
24906 this.animating = true;
24907 this.updateExpandIcon();
24910 callback : function(){
24911 this.animating = false;
24915 duration: this.node.ownerTree.duration || .25
24919 getContainer : function(){
24920 return this.ctNode;
24923 getEl : function(){
24927 appendDDGhost : function(W){
24928 W.appendChild(this.elNode.cloneNode(true));
24931 getDDRepairXY : function(){
24932 return Roo.lib.Dom.getXY(this.iconNode);
24935 onRender : function(){
24939 render : function(X){
24940 var n = this.node, a = n.attributes;
24941 var Y = n.parentNode ?
24942 n.parentNode.ui.getContainer() : n.ownerTree.innerCt.dom;
24944 if(!this.rendered){
24945 this.rendered = true;
24947 this.renderElements(n, a, Y, X);
24950 if(this.textNode.setAttributeNS){
24951 this.textNode.setAttributeNS("ext", "qtip", a.qtip);
24953 this.textNode.setAttributeNS("ext", "qtitle", a.qtipTitle);
24956 this.textNode.setAttribute("ext:qtip", a.qtip);
24958 this.textNode.setAttribute("ext:qtitle", a.qtipTitle);
24961 }else if(a.qtipCfg){
24962 a.qtipCfg.target = Roo.id(this.textNode);
24963 Roo.QuickTips.register(a.qtipCfg);
24967 if(!this.node.expanded){
24968 this.updateExpandIcon();
24972 Y.appendChild(this.wrap);
24977 renderElements : function(n, a, Z, b){
24979 this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
24980 var t = n.getOwnerTree();
24981 var c = t.renderer ? t.renderer(n.attributes) : Roo.util.Format.htmlEncode(n.text);
24982 var d = t.rendererTip ? t.rendererTip(n.attributes) : c;
24983 var cb = typeof a.checked == 'boolean';
24984 var f = a.href ? a.href : Roo.isGecko ? "" : "#";
24985 var g = ['<li class="x-tree-node"><div class="x-tree-node-el ', a.cls,'">',
24986 '<span class="x-tree-node-indent">',this.indentMarkup,"</span>",
24987 '<img src="', this.emptyIcon, '" class="x-tree-ec-icon" />',
24988 '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon',(a.icon ? " x-tree-node-inline-icon" : ""),(a.iconCls ? " "+a.iconCls : ""),'" unselectable="on" />',
24989 cb ? ('<input class="x-tree-node-cb" type="checkbox" ' + (a.checked ? 'checked="checked" />' : ' />')) : '',
24990 '<a hidefocus="on" href="',f,'" tabIndex="1" ',
24991 a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "",
24992 '><span unselectable="on" qtip="' , d ,'">',c,"</span></a></div>",
24993 '<ul class="x-tree-node-ct" style="display:none;"></ul>',
24996 if(b !== true && n.nextSibling && n.nextSibling.ui.getEl()){
24997 this.wrap = Roo.DomHelper.insertHtml("beforeBegin",
24998 n.nextSibling.ui.getEl(), g.join(""));
25000 this.wrap = Roo.DomHelper.insertHtml("beforeEnd", Z, g.join(""));
25004 this.elNode = this.wrap.childNodes[0];
25005 this.ctNode = this.wrap.childNodes[1];
25006 var cs = this.elNode.childNodes;
25007 this.indentNode = cs[0];
25008 this.ecNode = cs[1];
25009 this.iconNode = cs[2];
25012 this.checkbox = cs[3];
25016 this.anchor = cs[h];
25017 this.textNode = cs[h].firstChild;
25020 getAnchor : function(){
25021 return this.anchor;
25024 getTextEl : function(){
25025 return this.textNode;
25028 getIconEl : function(){
25029 return this.iconNode;
25032 isChecked : function(){
25033 return this.checkbox ? this.checkbox.checked : false;
25036 updateExpandIcon : function(){
25038 var n = this.node, c1, c2;
25039 var P = n.isLast() ? "x-tree-elbow-end" : "x-tree-elbow";
25040 var hasChild = n.hasChildNodes();
25044 c1 = "x-tree-node-collapsed";
25045 c2 = "x-tree-node-expanded";
25048 c1 = "x-tree-node-expanded";
25049 c2 = "x-tree-node-collapsed";
25052 this.removeClass("x-tree-node-leaf");
25053 this.wasLeaf = false;
25055 if(this.c1 != c1 || this.c2 != c2){
25056 Roo.fly(this.elNode).replaceClass(c1, c2);
25057 this.c1 = c1; this.c2 = c2;
25061 Roo.fly(this.elNode).replaceClass("x-tree-node-expanded", "x-tree-node-leaf");
25064 this.wasLeaf = true;
25067 var ecc = "x-tree-ec-icon "+P;
25068 if(this.ecc != ecc){
25069 this.ecNode.className = ecc;
25075 getChildIndent : function(){
25076 if(!this.childIndent){
25080 if(!p.isRoot || (p.isRoot && p.ownerTree.rootVisible)){
25082 g.unshift('<img src="'+this.emptyIcon+'" class="x-tree-elbow-line" />');
25084 g.unshift('<img src="'+this.emptyIcon+'" class="x-tree-icon" />');
25091 this.childIndent = g.join("");
25093 return this.childIndent;
25096 renderIndent : function(){
25099 var p = this.node.parentNode;
25101 indent = p.ui.getChildIndent();
25103 if(this.indentMarkup != indent){
25104 this.indentNode.innerHTML = indent;
25105 this.indentMarkup = indent;
25108 this.updateExpandIcon();
25113 Roo.tree.RootTreeNodeUI = function(){
25114 Roo.tree.RootTreeNodeUI.superclass.constructor.apply(this, arguments);
25116 Roo.extend(Roo.tree.RootTreeNodeUI, Roo.tree.TreeNodeUI, {
25117 render : function(){
25118 if(!this.rendered){
25119 var Z = this.node.ownerTree.innerCt.dom;
25120 this.node.expanded = true;
25121 Z.innerHTML = '<div class="x-tree-root-node"></div>';
25122 this.wrap = this.ctNode = Z.firstChild;
25125 collapse : function(){
25127 expand : function(){
25134 Roo.tree.TreeLoader = function(A){
25135 this.baseParams = {};
25136 this.requestMethod = "POST";
25137 Roo.apply(this, A);
25149 loadexception : true,
25155 Roo.tree.TreeLoader.superclass.constructor.call(this);
25158 Roo.extend(Roo.tree.TreeLoader, Roo.util.Observable, {
25171 clearOnLoad : true,
25185 load : function(B, C){
25186 if(this.clearOnLoad){
25187 while(B.firstChild){
25188 B.removeChild(B.firstChild);
25191 if(B.attributes.children){
25192 var cs = B.attributes.children;
25193 for(var i = 0, len = cs.length; i < len; i++){
25194 B.appendChild(this.createNode(cs[i]));
25196 if(typeof C == "function"){
25199 }else if(this.dataUrl){
25200 this.requestData(B, C);
25204 getParams: function(D){
25205 var E = [], bp = this.baseParams;
25206 for(var key in bp){
25207 if(typeof bp[key] != "function"){
25208 E.push(encodeURIComponent(key), "=", encodeURIComponent(bp[key]), "&");
25211 var n = this.queryParam === false ? 'node' : this.queryParam;
25212 E.push(n + "=", encodeURIComponent(D.id));
25216 requestData : function(F, G){
25217 if(this.fireEvent("beforeload", this, F, G) !== false){
25218 this.transId = Roo.Ajax.request({
25219 method:this.requestMethod,
25220 url: this.dataUrl||this.url,
25221 success: this.handleResponse,
25222 failure: this.handleFailure,
25224 argument: {callback: G, node: F},
25225 params: this.getParams(F)
25230 if(typeof G == "function"){
25236 isLoading : function(){
25237 return this.transId ? true : false;
25240 abort : function(){
25241 if(this.isLoading()){
25242 Roo.Ajax.abort(this.transId);
25247 createNode : function(attr){
25249 if(this.baseAttrs){
25250 Roo.applyIf(attr, this.baseAttrs);
25252 if(this.applyLoader !== false){
25253 attr.loader = this;
25257 if(typeof(attr.uiProvider) == 'string'){
25258 attr.uiProvider = this.uiProviders[attr.uiProvider] ||
25260 eval(attr.uiProvider);
25262 if(typeof(this.uiProviders['default']) != 'undefined') {
25263 attr.uiProvider = this.uiProviders['default'];
25267 this.fireEvent('create', this, attr);
25269 attr.leaf = typeof(attr.leaf) == 'string' ? attr.leaf * 1 : attr.leaf;
25270 return (attr.leaf ?
25271 new Roo.tree.TreeNode(attr) :
25272 new Roo.tree.AsyncTreeNode(attr));
25275 processResponse : function(H, I, J){
25276 var K = H.responseText;
25281 if (this.root !== false) {
25285 for(var i = 0, len = o.length; i < len; i++){
25286 var n = this.createNode(o[i]);
25291 if(typeof J == "function"){
25295 this.handleFailure(response);
25299 handleResponse : function(L){
25300 this.transId = false;
25301 var a = L.argument;
25302 this.processResponse(L, a.node, a.callback);
25303 this.fireEvent("load", this, a.node, L);
25306 handleFailure : function(M){
25307 this.transId = false;
25308 var a = M.argument;
25309 this.fireEvent("loadexception", this, a.node, M);
25310 if(typeof a.callback == "function"){
25311 a.callback(this, a.node);
25320 Roo.tree.TreeFilter = function(A, B){
25322 this.filtered = {};
25323 Roo.apply(this, B);
25326 Roo.tree.TreeFilter.prototype = {
25334 filter : function(C, D, E){
25337 if(typeof C == "string"){
25338 var vlen = C.length;
25340 if(vlen == 0 && this.clearBlank){
25345 C = C.toLowerCase();
25347 return n.attributes[D].substr(0, vlen).toLowerCase() == C;
25351 return C.test(n.attributes[D]);
25354 throw 'Illegal filter type, must be string or regex';
25357 this.filterBy(f, null, E);
25362 filterBy : function(fn, F, G){
25363 G = G || this.tree.root;
25364 if(this.autoClear){
25367 var af = this.filtered, rv = this.reverse;
25368 var f = function(n){
25375 var m = fn.call(F || n, n);
25386 if(typeof id != "function"){
25388 if(n && n.parentNode){
25389 n.parentNode.removeChild(n);
25398 clear : function(){
25400 var af = this.filtered;
25402 if(typeof id != "function"){
25410 this.filtered = {};
25420 Roo.tree.TreeSorter = function(A, B){
25421 Roo.apply(this, B);
25422 A.on("beforechildrenrendered", this.doSort, this);
25423 A.on("append", this.updateSort, this);
25424 A.on("insert", this.updateSort, this);
25426 var C = this.dir && this.dir.toLowerCase() == "desc";
25427 var p = this.property || "text";
25428 var D = this.sortType;
25429 var fs = this.folderSort;
25430 var cs = this.caseSensitive === true;
25431 var E = this.leafAttr || 'leaf';
25433 this.sortFn = function(n1, n2){
25435 if(n1.attributes[E] && !n2.attributes[E]){
25438 if(!n1.attributes[E] && n2.attributes[E]){
25442 var v1 = D ? D(n1) : (cs ? n1.attributes[p] : n1.attributes[p].toUpperCase());
25443 var v2 = D ? D(n2) : (cs ? n2.attributes[p] : n2.attributes[p].toUpperCase());
25445 return C ? +1 : -1;
25447 return C ? -1 : +1;
25454 Roo.tree.TreeSorter.prototype = {
25455 doSort : function(F){
25456 F.sort(this.sortFn);
25459 compareNodes : function(n1, n2){
25460 return (n1.text.toUpperCase() > n2.text.toUpperCase() ? 1 : -1);
25463 updateSort : function(G, H){
25464 if(H.childrenRendered){
25465 this.doSort.defer(1, this, [H]);
25472 if(Roo.dd.DropZone){
25474 Roo.tree.TreeDropZone = function(A, B){
25475 this.allowParentInsert = false;
25476 this.allowContainerDrop = false;
25477 this.appendOnly = false;
25478 Roo.tree.TreeDropZone.superclass.constructor.call(this, A.innerCt, B);
25480 this.lastInsertClass = "x-tree-no-status";
25481 this.dragOverData = {};
25484 Roo.extend(Roo.tree.TreeDropZone, Roo.dd.DropZone, {
25485 ddGroup : "TreeDD",
25487 expandDelay : 1000,
25489 expandNode : function(C){
25490 if(C.hasChildNodes() && !C.isExpanded()){
25491 C.expand(false, null, this.triggerCacheRefresh.createDelegate(this));
25495 queueExpand : function(D){
25496 this.expandProcId = this.expandNode.defer(this.expandDelay, this, [D]);
25499 cancelExpand : function(){
25500 if(this.expandProcId){
25501 clearTimeout(this.expandProcId);
25502 this.expandProcId = false;
25506 isValidDropPoint : function(n, pt, dd, e, E){
25507 if(!n || !E){ return false; }
25511 if(!(F && F.isTarget && pt)){
25514 if(pt == "append" && F.allowChildren === false){
25517 if((pt == "above" || pt == "below") && (F.parentNode && F.parentNode.allowChildren === false)){
25520 if(G && (F == G || G.contains(F))){
25524 var H = this.dragOverData;
25525 H.tree = this.tree;
25533 var I = this.tree.fireEvent("nodedragover", H);
25534 return H.cancel === false && I !== false;
25537 getDropPoint : function(e, n, dd){
25540 return tn.allowChildren !== false ? "append" : false;
25543 var t = Roo.lib.Dom.getY(J), b = t + J.offsetHeight;
25544 var y = Roo.lib.Event.getPageY(e);
25545 var K = tn.allowChildren === false || tn.isLeaf();
25546 if(this.appendOnly || tn.parentNode.allowChildren === false){
25547 return K ? false : "append";
25550 if(!this.allowParentInsert){
25551 L = tn.hasChildNodes() && tn.isExpanded();
25553 var q = (b - t) / (K ? 2 : 3);
25554 if(y >= t && y < (t + q)){
25556 }else if(!L && (K || y >= b-q && y <= b)){
25563 onNodeEnter : function(n, dd, e, M){
25564 this.cancelExpand();
25567 onNodeOver : function(n, dd, e, N){
25568 var pt = this.getDropPoint(e, n, dd);
25572 if(!this.expandProcId && pt == "append" && O.hasChildNodes() && !n.node.isExpanded()){
25573 this.queueExpand(O);
25574 }else if(pt != "append"){
25575 this.cancelExpand();
25579 var P = this.dropNotAllowed;
25580 if(this.isValidDropPoint(n, pt, dd, e, N)){
25585 P = n.node.isFirst() ? "x-tree-drop-ok-above" : "x-tree-drop-ok-between";
25586 cls = "x-tree-drag-insert-above";
25587 }else if(pt == "below"){
25588 P = n.node.isLast() ? "x-tree-drop-ok-below" : "x-tree-drop-ok-between";
25589 cls = "x-tree-drag-insert-below";
25591 P = "x-tree-drop-ok-append";
25592 cls = "x-tree-drag-append";
25594 if(this.lastInsertClass != cls){
25595 Roo.fly(el).replaceClass(this.lastInsertClass, cls);
25596 this.lastInsertClass = cls;
25603 onNodeOut : function(n, dd, e, Q){
25604 this.cancelExpand();
25605 this.removeDropIndicators(n);
25608 onNodeDrop : function(n, dd, e, R){
25609 var S = this.getDropPoint(e, n, dd);
25612 if(!this.isValidDropPoint(n, S, dd, e, R)){
25617 var U = R.node || (dd.getTreeNode ? dd.getTreeNode(R, T, S, e) : null);
25628 var W = this.tree.fireEvent("beforenodedrop", V);
25629 if(W === false || V.cancel === true || !V.dropNode){
25636 if(S == "append" && !T.isExpanded()){
25637 T.expand(false, null, function(){
25638 this.completeDrop(V);
25639 }.createDelegate(this));
25641 this.completeDrop(V);
25646 completeDrop : function(de){
25647 var ns = de.dropNode, p = de.point, t = de.target;
25648 if(!(ns instanceof Array)){
25652 for(var i = 0, len = ns.length; i < len; i++){
25655 t.parentNode.insertBefore(n, t);
25656 }else if(p == "below"){
25657 t.parentNode.insertBefore(n, t.nextSibling);
25664 if(this.tree.hlDrop){
25669 this.tree.fireEvent("nodedrop", de);
25672 afterNodeMoved : function(dd, X, e, Y, Z){
25673 if(this.tree.hlDrop){
25678 this.tree.fireEvent("nodedrop", this.tree, Y, X, dd, e);
25681 getTree : function(){
25685 removeDropIndicators : function(n){
25688 Roo.fly(el).removeClass([
25689 "x-tree-drag-insert-above",
25690 "x-tree-drag-insert-below",
25691 "x-tree-drag-append"]);
25692 this.lastInsertClass = "_noclass";
25696 beforeDragDrop : function(a, e, id){
25697 this.cancelExpand();
25701 afterRepair : function(c){
25702 if(c && Roo.enableFx){
25703 c.node.ui.highlight();
25715 if(Roo.dd.DragZone){
25716 Roo.tree.TreeDragZone = function(A, B){
25717 Roo.tree.TreeDragZone.superclass.constructor.call(this, A.getTreeEl(), B);
25721 Roo.extend(Roo.tree.TreeDragZone, Roo.dd.DragZone, {
25722 ddGroup : "TreeDD",
25724 onBeforeDrag : function(C, e){
25726 return n && n.draggable && !n.disabled;
25729 onInitDrag : function(e){
25730 var D = this.dragData;
25731 this.tree.getSelectionModel().select(D.node);
25732 this.proxy.update("");
25733 D.node.ui.appendDDGhost(this.proxy.ghost.dom);
25734 this.tree.fireEvent("startdrag", this.tree, D.node, e);
25737 getRepairXY : function(e, E){
25738 return E.node.ui.getDDRepairXY();
25741 onEndDrag : function(F, e){
25742 this.tree.fireEvent("enddrag", this.tree, F.node, e);
25745 onValidDrop : function(dd, e, id){
25746 this.tree.fireEvent("dragdrop", this.tree, this.dragData.node, dd, e);
25750 beforeInvalidDrop : function(e, id){
25752 var sm = this.tree.getSelectionModel();
25753 sm.clearSelections();
25754 sm.select(this.dragData.node);
25762 Roo.tree.TreeEditor = function(A, B){
25764 var C = B.events ? B : new Roo.form.TextField(B);
25765 Roo.tree.TreeEditor.superclass.constructor.call(this, C);
25769 A.on('beforeclick', this.beforeNodeClick, this);
25770 A.getTreeEl().on('mousedown', this.hide, this);
25771 this.on('complete', this.updateNode, this);
25772 this.on('beforestartedit', this.fitToTree, this);
25773 this.on('startedit', this.bindScroll, this, {delay:10});
25774 this.on('specialkey', this.onSpecialKey, this);
25777 Roo.extend(Roo.tree.TreeEditor, Roo.Editor, {
25788 cls: "x-small-editor x-tree-editor",
25801 fitToTree : function(ed, el){
25802 var td = this.tree.getTreeEl().dom, nd = el.dom;
25803 if(td.scrollLeft > nd.offsetLeft){
25804 td.scrollLeft = nd.offsetLeft;
25808 (td.clientWidth > 20 ? td.clientWidth : td.offsetWidth) - Math.max(0, nd.offsetLeft-td.scrollLeft) -
25810 this.setSize(w, '');
25814 triggerEdit : function(D){
25815 this.completeEdit();
25817 this.startEdit(D.ui.textNode, D.text);
25821 bindScroll : function(){
25822 this.tree.getTreeEl().on('scroll', this.cancelEdit, this);
25826 beforeNodeClick : function(E, e){
25827 var F = (this.lastClick ? this.lastClick.getElapsed() : 0);
25828 this.lastClick = new Date();
25829 if(F > this.editDelay && this.tree.getSelectionModel().isSelected(E)){
25831 this.triggerEdit(E);
25837 updateNode : function(ed, G){
25838 this.tree.getTreeEl().un('scroll', this.cancelEdit, this);
25839 this.editNode.setText(G);
25843 onHide : function(){
25844 Roo.tree.TreeEditor.superclass.onHide.call(this);
25846 this.editNode.ui.focus();
25851 onSpecialKey : function(H, e){
25852 var k = e.getKey();
25856 }else if(k == e.ENTER && !e.hasModifier()){
25858 this.completeEdit();
25869 Roo.tree.ColumnNodeUI = Roo.extend(Roo.tree.TreeNodeUI, {
25872 renderElements : function(n, a, A, B){
25874 this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
25876 var t = n.getOwnerTree();
25877 var C = Pman.Tab.Document_TypesTree.tree.el.id;
25880 var bw = t.borderWidth;
25882 var E = a.href ? a.href : Roo.isGecko ? "" : "#";
25883 var cb = typeof a.checked == "boolean";
25884 var tx = String.format('{0}',n.text || (c.renderer ? c.renderer(a[c.dataIndex], n, a) : a[c.dataIndex]));
25885 var F = 'x-t-' + C + '-c0';
25887 '<li class="x-tree-node">',
25890 '<div class="x-tree-node-el ', a.cls,'">',
25892 '<div class="x-tree-col ', F, '" style="width:', c.width-bw, 'px;">',
25895 '<span class="x-tree-node-indent">',this.indentMarkup,'</span>',
25896 '<img src="', this.emptyIcon, '" class="x-tree-ec-icon " />',
25897 '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon',
25898 (a.icon ? ' x-tree-node-inline-icon' : ''),
25899 (a.iconCls ? ' '+a.iconCls : ''),
25900 '" unselectable="on" />',
25901 (cb ? ('<input class="x-tree-node-cb" type="checkbox" ' +
25902 (a.checked ? 'checked="checked" />' : ' />')) : ''),
25904 '<a class="x-tree-node-anchor" hidefocus="on" href="',E,'" tabIndex="1" ',
25905 (a.hrefTarget ? ' target="' +a.hrefTarget + '"' : ''), '>',
25906 '<span unselectable="on" qtip="' + tx + '">',
25910 '<a class="x-tree-node-anchor" hidefocus="on" href="',E,'" tabIndex="1" ',
25911 (a.hrefTarget ? ' target="' +a.hrefTarget + '"' : ''), '>',
25914 for(var i = 1, len = D.length; i < len; i++){
25916 F = 'x-t-' + C + '-c' +i;
25917 tx = String.format('{0}', (c.renderer ? c.renderer(a[c.dataIndex], n, a) : a[c.dataIndex]));
25918 G.push('<div class="x-tree-col ', F, ' ' ,(c.cls?c.cls:''),'" style="width:',c.width-bw,'px;">',
25919 '<div class="x-tree-col-text" qtip="' + tx +'">',tx,"</div>",
25926 '<div class="x-clear"></div></div>',
25927 '<ul class="x-tree-node-ct" style="display:none;"></ul>',
25930 if(B !== true && n.nextSibling && n.nextSibling.ui.getEl()){
25931 this.wrap = Roo.DomHelper.insertHtml("beforeBegin",
25932 n.nextSibling.ui.getEl(), G.join(""));
25934 this.wrap = Roo.DomHelper.insertHtml("beforeEnd", A, G.join(""));
25936 var el = this.wrap.firstChild;
25938 this.elNode = el.firstChild;
25939 this.ranchor = el.childNodes[1];
25940 this.ctNode = this.wrap.childNodes[1];
25941 var cs = el.firstChild.childNodes;
25942 this.indentNode = cs[0];
25943 this.ecNode = cs[1];
25944 this.iconNode = cs[2];
25947 this.checkbox = cs[3];
25951 this.anchor = cs[H];
25953 this.textNode = cs[H].firstChild;
25961 initEvents : function(){
25962 Roo.tree.ColumnNodeUI.superclass.initEvents.call(this);
25965 var a = this.ranchor;
25967 var el = Roo.get(a);
25970 el.setStyle("text-decoration", "none");
25974 el.on("click", this.onClick, this);
25975 el.on("dblclick", this.onDblClick, this);
25976 el.on("contextmenu", this.onContextMenu, this);
25982 addClass : function(I){
25984 Roo.fly(this.elRow).addClass(I);
25990 removeClass : function(J){
25992 Roo.fly(this.elRow).removeClass(J);
26007 Roo.tree.ColumnTree = function(el, A)
26009 Roo.tree.ColumnTree.superclass.constructor.call(this, el , A);
26015 this.on('resize', this.onResize, this);
26018 Roo.extend(Roo.tree.ColumnTree, Roo.tree.TreePanel, {
26022 borderWidth: Roo.isBorderBox ? 0 : 2,
26025 render : function(){
26028 Roo.tree.ColumnTree.superclass.render.apply(this);
26030 this.el.addClass('x-column-tree');
26032 this.headers = this.el.createChild(
26033 {cls:'x-tree-headers'},this.innerCt.dom);
26035 var B = this.columns, c;
26039 for(var i = 0; i < D; i++){
26042 this.headEls.push(this.headers.createChild({
26043 cls:'x-tree-hd ' + (c.cls?c.cls+'-hd':''),
26045 cls:'x-tree-hd-text',
26048 style:'width:'+(c.width-this.borderWidth)+'px;'
26052 this.headers.createChild({cls:'x-clear'});
26054 this.headers.setWidth(C);
26056 this.innerCt.setStyle({ overflow: 'auto' });
26057 this.onResize(this.width, this.height);
26061 onResize : function(w,h)
26066 this.innerCt.setWidth(this.width);
26067 this.innerCt.setHeight(this.height-20);
26070 var E = this.columns, c;
26074 for(var i = 0; i < H; i++){
26076 if (this.autoExpandColumn !== false && c.dataIndex == this.autoExpandColumn) {
26078 G = this.headEls[i];
26086 G.setWidth( ((w - F)-this.borderWidth - 20));
26089 this.headers.setWidth(w-20);
26102 Roo.menu.Menu = function(A){
26103 Roo.apply(this, A);
26104 this.id = this.id || Roo.id();
26131 if (this.registerMenu) {
26132 Roo.menu.MenuMgr.register(this);
26135 var B = this.items;
26136 this.items = new Roo.util.MixedCollection();
26138 this.add.apply(this, B);
26142 Roo.extend(Roo.menu.Menu, Roo.util.Observable, {
26151 subMenuAlign : "tl-tr?",
26154 defaultAlign : "tl-bl?",
26157 allowOtherMenus : false,
26160 registerMenu : true,
26165 render : function(){
26169 var el = this.el = new Roo.Layer({
26171 shadow:this.shadow,
26173 parentEl: this.parentEl || document.body,
26177 this.keyNav = new Roo.menu.MenuNav(this);
26180 el.addClass("x-menu-plain");
26183 el.addClass(this.cls);
26187 this.focusEl = el.createChild({
26188 tag: "a", cls: "x-menu-focus", href: "#", onclick: "return false;", tabIndex:"-1"
26190 var ul = el.createChild({tag: "ul", cls: "x-menu-list"});
26191 ul.on("click", this.onClick, this);
26192 ul.on("mouseover", this.onMouseOver, this);
26193 ul.on("mouseout", this.onMouseOut, this);
26194 this.items.each(function(C){
26195 var li = document.createElement("li");
26196 li.className = "x-menu-list-item";
26197 ul.dom.appendChild(li);
26198 C.render(li, this);
26205 autoWidth : function(){
26206 var el = this.el, ul = this.ul;
26210 var w = this.width;
26213 }else if(Roo.isIE){
26214 el.setWidth(this.minWidth);
26215 var t = el.dom.offsetWidth;
26216 el.setWidth(ul.getWidth()+el.getFrameWidth("lr"));
26221 delayAutoWidth : function(){
26224 this.awTask = new Roo.util.DelayedTask(this.autoWidth, this);
26227 this.awTask.delay(20);
26232 findTargetItem : function(e){
26233 var t = e.getTarget(".x-menu-list-item", this.ul, true);
26234 if(t && t.menuItemId){
26235 return this.items.get(t.menuItemId);
26240 onClick : function(e){
26242 if(t = this.findTargetItem(e)){
26244 this.fireEvent("click", this, t, e);
26249 setActiveItem : function(C, D){
26250 if(C != this.activeItem){
26251 if(this.activeItem){
26252 this.activeItem.deactivate();
26255 this.activeItem = C;
26263 tryActivate : function(E, F){
26264 var G = this.items;
26265 for(var i = E, len = G.length; i >= 0 && i < len; i+= F){
26267 if(!C.disabled && C.canActivate){
26268 this.setActiveItem(C, false);
26276 onMouseOver : function(e){
26278 if(t = this.findTargetItem(e)){
26279 if(t.canActivate && !t.disabled){
26280 this.setActiveItem(t, true);
26284 this.fireEvent("mouseover", this, e, t);
26288 onMouseOut : function(e){
26290 if(t = this.findTargetItem(e)){
26291 if(t == this.activeItem && t.shouldDeactivate(e)){
26292 this.activeItem.deactivate();
26293 delete this.activeItem;
26297 this.fireEvent("mouseout", this, e, t);
26302 isVisible : function(){
26303 return this.el && !this.hidden;
26308 show : function(el, H, I){
26309 this.parentMenu = I;
26314 this.fireEvent("beforeshow", this);
26315 this.showAt(this.el.getAlignToXY(el, H || this.defaultAlign), I, false);
26320 showAt : function(xy, J,
26322 this.parentMenu = J;
26327 this.fireEvent("beforeshow", this);
26328 xy = this.el.adjustForConstraints(xy);
26333 this.hidden = false;
26335 this.fireEvent("show", this);
26338 focus : function(){
26340 this.doFocus.defer(50, this);
26344 doFocus : function(){
26346 this.focusEl.focus();
26352 hide : function(K){
26353 if(this.el && this.isVisible()){
26354 this.fireEvent("beforehide", this);
26355 if(this.activeItem){
26356 this.activeItem.deactivate();
26357 this.activeItem = null;
26361 this.hidden = true;
26362 this.fireEvent("hide", this);
26364 if(K === true && this.parentMenu){
26365 this.parentMenu.hide(true);
26372 var a = arguments, l = a.length, L;
26373 for(var i = 0; i < l; i++){
26376 L = this.addItem(el);
26377 }else if(typeof el == "string"){
26378 if(el == "separator" || el == "-"){
26379 L = this.addSeparator();
26381 L = this.addText(el);
26383 }else if(el.tagName || el.el){
26384 L = this.addElement(el);
26385 }else if(typeof el == "object"){
26386 L = this.addMenuItem(el);
26394 getEl : function(){
26403 addSeparator : function(){
26404 return this.addItem(new Roo.menu.Separator());
26409 addElement : function(el){
26410 return this.addItem(new Roo.menu.BaseItem(el));
26415 addItem : function(M){
26418 var li = document.createElement("li");
26419 li.className = "x-menu-list-item";
26420 this.ul.dom.appendChild(li);
26421 M.render(li, this);
26422 this.delayAutoWidth();
26429 addMenuItem : function(N){
26430 if(!(N instanceof Roo.menu.Item)){
26431 if(typeof N.checked == "boolean"){
26432 N = new Roo.menu.CheckItem(N);
26434 N = new Roo.menu.Item(N);
26437 return this.addItem(N);
26442 addText : function(O){
26443 return this.addItem(new Roo.menu.TextItem(O));
26448 insert : function(P, Q){
26449 this.items.insert(P, Q);
26451 var li = document.createElement("li");
26452 li.className = "x-menu-list-item";
26453 this.ul.dom.insertBefore(li, this.ul.dom.childNodes[P]);
26454 Q.render(li, this);
26455 this.delayAutoWidth();
26462 remove : function(R){
26463 this.items.removeKey(R.id);
26469 removeAll : function(){
26471 while(f = this.items.first()){
26478 Roo.menu.MenuNav = function(S){
26479 Roo.menu.MenuNav.superclass.constructor.call(this, S.el);
26480 this.scope = this.menu = S;
26483 Roo.extend(Roo.menu.MenuNav, Roo.KeyNav, {
26484 doRelay : function(e, h){
26485 var k = e.getKey();
26486 if(!this.menu.activeItem && e.isNavKeyPress() && k != e.SPACE && k != e.RETURN ){
26487 this.menu.tryActivate(0, 1);
26490 return h.call(this.scope || this, e, this.menu);
26493 up : function(e, m){
26494 if(!m.tryActivate(m.items.indexOf(m.activeItem)-1, -1)){
26495 m.tryActivate(m.items.length-1, -1);
26499 down : function(e, m){
26500 if(!m.tryActivate(m.items.indexOf(m.activeItem)+1, 1)){
26501 m.tryActivate(0, 1);
26505 right : function(e, m){
26507 m.activeItem.expandMenu(true);
26511 left : function(e, m){
26513 if(m.parentMenu && m.parentMenu.activeItem){
26514 m.parentMenu.activeItem.activate();
26518 enter : function(e, m){
26520 e.stopPropagation();
26521 m.activeItem.onClick(e);
26522 m.fireEvent("click", this, m.activeItem);
26532 Roo.menu.MenuMgr = function(){
26533 var A, B, C = {}, attached = false, lastShow = new Date();
26538 B = new Roo.util.MixedCollection();
26539 Roo.get(document).addKeyListener(27, function(){
26548 if(B && B.length > 0){
26550 c.each(function(m){
26560 Roo.get(document).un("mousedown", J);
26568 lastShow = new Date();
26571 Roo.get(document).on("mousedown", J);
26575 m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
26576 m.parentMenu.activeChild = m;
26577 }else if(L && L.isVisible()){
26578 m.getEl().setZIndex(parseInt(L.getEl().getStyle("z-index"), 10) + 3);
26585 m.activeChild.hide();
26587 if(m.autoHideTimer){
26588 clearTimeout(m.autoHideTimer);
26589 delete m.autoHideTimer;
26595 var pm = m.parentMenu;
26596 if(!pm && !m.allowOtherMenus){
26598 }else if(pm && pm.activeChild && B != m){
26599 pm.activeChild.hide();
26605 if(lastShow.getElapsed() > 50 && B.length > 0 && !e.getTarget(".x-menu")){
26613 var g = C[mi.group];
26614 for(var i = 0, l = g.length; i < l; i++){
26616 g[i].setChecked(false);
26626 hideAll : function(){
26631 register : function(Q){
26637 Q.on("beforehide", H);
26639 Q.on("beforeshow", I);
26642 if(g && Q.events["checkchange"]){
26648 Q.on("checkchange", onCheck);
26655 if(typeof R == "string"){
26657 }else if(R.events){
26659 }else if(typeof R.length == 'number'){
26660 return new Roo.menu.Menu({items:R});
26662 return new Roo.menu.Menu(R);
26667 unregister : function(S){
26669 S.un("beforehide", H);
26671 S.un("beforeshow", I);
26674 if(g && S.events["checkchange"]){
26676 S.un("checkchange", onCheck);
26681 registerCheckable : function(T){
26689 T.on("beforecheckchange", K);
26694 unregisterCheckable : function(U){
26698 U.un("beforecheckchange", K);
26709 Roo.menu.BaseItem = function(A){
26710 Roo.menu.BaseItem.superclass.constructor.call(this, A);
26725 this.on("click", this.handler, this.scope, true);
26729 Roo.extend(Roo.menu.BaseItem, Roo.Component, {
26734 canActivate : false,
26737 activeClass : "x-menu-item-active",
26740 hideOnClick : true,
26746 ctype: "Roo.menu.BaseItem",
26749 actionMode : "container",
26752 render : function(B, C){
26753 this.parentMenu = C;
26754 Roo.menu.BaseItem.superclass.render.call(this, B);
26755 this.container.menuItemId = this.id;
26759 onRender : function(D, E){
26760 this.el = Roo.get(this.el);
26761 D.dom.appendChild(this.el.dom);
26765 onClick : function(e){
26766 if(!this.disabled && this.fireEvent("click", this, e) !== false
26767 && this.parentMenu.fireEvent("itemclick", this, e) !== false){
26768 this.handleClick(e);
26775 activate : function(){
26779 var li = this.container;
26780 li.addClass(this.activeClass);
26781 this.region = li.getRegion().adjust(2, 2, -2, -2);
26782 this.fireEvent("activate", this);
26787 deactivate : function(){
26788 this.container.removeClass(this.activeClass);
26789 this.fireEvent("deactivate", this);
26793 shouldDeactivate : function(e){
26794 return !this.region || !this.region.contains(e.getPoint());
26798 handleClick : function(e){
26799 if(this.hideOnClick){
26800 this.parentMenu.hide.defer(this.hideDelay, this.parentMenu, [true]);
26805 expandMenu : function(F){
26810 hideMenu : function(){
26819 Roo.menu.Adapter = function(A, B){
26820 Roo.menu.Adapter.superclass.constructor.call(this, B);
26821 this.component = A;
26823 Roo.extend(Roo.menu.Adapter, Roo.menu.BaseItem, {
26825 canActivate : true,
26828 onRender : function(C, D){
26829 this.component.render(C);
26830 this.el = this.component.getEl();
26834 activate : function(){
26839 this.component.focus();
26840 this.fireEvent("activate", this);
26845 deactivate : function(){
26846 this.fireEvent("deactivate", this);
26850 disable : function(){
26851 this.component.disable();
26852 Roo.menu.Adapter.superclass.disable.call(this);
26856 enable : function(){
26857 this.component.enable();
26858 Roo.menu.Adapter.superclass.enable.call(this);
26866 Roo.menu.TextItem = function(A){
26868 Roo.menu.TextItem.superclass.constructor.call(this);
26871 Roo.extend(Roo.menu.TextItem, Roo.menu.BaseItem, {
26874 hideOnClick : false,
26877 itemCls : "x-menu-text",
26880 onRender : function(){
26881 var s = document.createElement("span");
26882 s.className = this.itemCls;
26883 s.innerHTML = this.text;
26885 Roo.menu.TextItem.superclass.onRender.apply(this, arguments);
26893 Roo.menu.Separator = function(A){
26894 Roo.menu.Separator.superclass.constructor.call(this, A);
26897 Roo.extend(Roo.menu.Separator, Roo.menu.BaseItem, {
26900 itemCls : "x-menu-sep",
26903 hideOnClick : false,
26906 onRender : function(li){
26907 var s = document.createElement("span");
26908 s.className = this.itemCls;
26909 s.innerHTML = " ";
26911 li.addClass("x-menu-sep-li");
26912 Roo.menu.Separator.superclass.onRender.apply(this, arguments);
26919 Roo.menu.Item = function(A){
26920 Roo.menu.Item.superclass.constructor.call(this, A);
26922 this.menu = Roo.menu.MenuMgr.get(this.menu);
26925 Roo.extend(Roo.menu.Item, Roo.menu.BaseItem, {
26930 itemCls : "x-menu-item",
26933 canActivate : true,
26941 ctype: "Roo.menu.Item",
26944 onRender : function(B, C){
26945 var el = document.createElement("a");
26946 el.hideFocus = true;
26947 el.unselectable = "on";
26948 el.href = this.href || "#";
26949 if(this.hrefTarget){
26950 el.target = this.hrefTarget;
26953 el.className = this.itemCls + (this.menu ? " x-menu-item-arrow" : "") + (this.cls ? " " + this.cls : "");
26954 el.innerHTML = String.format(
26955 '<img src="{0}" class="x-menu-item-icon {2}" />{1}',
26956 this.icon || Roo.BLANK_IMAGE_URL, this.text, this.iconCls || '');
26958 Roo.menu.Item.superclass.onRender.call(this, B, C);
26963 setText : function(D){
26966 this.el.update(String.format(
26967 '<img src="{0}" class="x-menu-item-icon {2}">{1}',
26968 this.icon || Roo.BLANK_IMAGE_URL, this.text, this.iconCls || ''));
26969 this.parentMenu.autoWidth();
26974 handleClick : function(e){
26979 Roo.menu.Item.superclass.handleClick.apply(this, arguments);
26983 activate : function(E){
26984 if(Roo.menu.Item.superclass.activate.apply(this, arguments)){
26994 shouldDeactivate : function(e){
26995 if(Roo.menu.Item.superclass.shouldDeactivate.call(this, e)){
26996 if(this.menu && this.menu.isVisible()){
26997 return !this.menu.getEl().getRegion().contains(e.getPoint());
27005 deactivate : function(){
27006 Roo.menu.Item.superclass.deactivate.apply(this, arguments);
27011 expandMenu : function(F){
27012 if(!this.disabled && this.menu){
27013 clearTimeout(this.hideTimer);
27014 delete this.hideTimer;
27015 if(!this.menu.isVisible() && !this.showTimer){
27016 this.showTimer = this.deferExpand.defer(this.showDelay, this, [F]);
27017 }else if (this.menu.isVisible() && F){
27018 this.menu.tryActivate(0, 1);
27024 deferExpand : function(G){
27025 delete this.showTimer;
27026 this.menu.show(this.container, this.parentMenu.subMenuAlign || "tl-tr?", this.parentMenu);
27028 this.menu.tryActivate(0, 1);
27033 hideMenu : function(){
27034 clearTimeout(this.showTimer);
27035 delete this.showTimer;
27036 if(!this.hideTimer && this.menu && this.menu.isVisible()){
27037 this.hideTimer = this.deferHide.defer(this.hideDelay, this);
27042 deferHide : function(){
27043 delete this.hideTimer;
27052 Roo.menu.CheckItem = function(A){
27053 Roo.menu.CheckItem.superclass.constructor.call(this, A);
27057 "beforecheckchange" : true,
27060 "checkchange" : true
27062 if(this.checkHandler){
27063 this.on('checkchange', this.checkHandler, this.scope);
27066 Roo.extend(Roo.menu.CheckItem, Roo.menu.Item, {
27071 itemCls : "x-menu-item x-menu-check-item",
27074 groupClass : "x-menu-group-item",
27081 ctype: "Roo.menu.CheckItem",
27084 onRender : function(c){
27085 Roo.menu.CheckItem.superclass.onRender.apply(this, arguments);
27087 this.el.addClass(this.groupClass);
27090 Roo.menu.MenuMgr.registerCheckable(this);
27092 this.checked = false;
27093 this.setChecked(true, true);
27098 destroy : function(){
27100 Roo.menu.MenuMgr.unregisterCheckable(this);
27103 Roo.menu.CheckItem.superclass.destroy.apply(this, arguments);
27108 setChecked : function(B, C){
27109 if(this.checked != B && this.fireEvent("beforecheckchange", this, B) !== false){
27110 if(this.container){
27111 this.container[B ? "addClass" : "removeClass"]("x-menu-item-checked");
27116 this.fireEvent("checkchange", this, B);
27122 handleClick : function(e){
27123 if(!this.disabled && !(this.checked && this.group)){
27124 this.setChecked(!this.checked);
27127 Roo.menu.CheckItem.superclass.handleClick.apply(this, arguments);
27135 Roo.menu.DateItem = function(A){
27136 Roo.menu.DateItem.superclass.constructor.call(this, new Roo.DatePicker(A), A);
27139 this.picker = this.component;
27140 this.addEvents({select: true});
27142 this.picker.on("render", function(B){
27143 B.getEl().swallowEvent("click");
27144 B.container.addClass("x-menu-date-item");
27147 this.picker.on("select", this.onSelect, this);
27150 Roo.extend(Roo.menu.DateItem, Roo.menu.Adapter, {
27152 onSelect : function(B, C){
27153 this.fireEvent("select", this, C, B);
27154 Roo.menu.DateItem.superclass.handleClick.call(this);
27162 Roo.menu.ColorItem = function(A){
27163 Roo.menu.ColorItem.superclass.constructor.call(this, new Roo.ColorPalette(A), A);
27166 this.palette = this.component;
27167 this.relayEvents(this.palette, ["select"]);
27168 if(this.selectHandler){
27169 this.on('select', this.selectHandler, this.scope);
27172 Roo.extend(Roo.menu.ColorItem, Roo.menu.Adapter);
27179 Roo.menu.DateMenu = function(A){
27180 Roo.menu.DateMenu.superclass.constructor.call(this, A);
27182 var di = new Roo.menu.DateItem(A);
27186 this.picker = di.picker;
27189 this.relayEvents(di, ["select"]);
27191 this.on('beforeshow', function(){
27193 this.picker.hideMonthPicker(true);
27197 Roo.extend(Roo.menu.DateMenu, Roo.menu.Menu, {
27206 Roo.menu.ColorMenu = function(A){
27207 Roo.menu.ColorMenu.superclass.constructor.call(this, A);
27209 var ci = new Roo.menu.ColorItem(A);
27213 this.palette = ci.palette;
27216 this.relayEvents(ci, ["select"]);
27218 Roo.extend(Roo.menu.ColorMenu, Roo.menu.Menu);
27224 Roo.form.Field = function(A){
27225 Roo.form.Field.superclass.constructor.call(this, A);
27228 Roo.extend(Roo.form.Field, Roo.BoxComponent, {
27236 invalidClass : "x-form-invalid",
27239 invalidText : "The value in this field is invalid",
27242 focusClass : "x-form-focus",
27245 validationEvent : "keyup",
27248 validateOnBlur : true,
27251 validationDelay : 250,
27254 defaultAutoCreate : {tag: "input", type: "text", size: "20", autocomplete: "off"},
27257 fieldClass : "x-form-field",
27260 msgTarget : 'qtip',
27275 inputType : undefined,
27279 tabIndex : undefined,
27282 isFormField : true,
27298 initComponent : function(){
27299 Roo.form.Field.superclass.initComponent.call(this);
27324 getName: function(){
27325 return this.rendered && this.el.dom.name ? this.el.dom.name : (this.hiddenName || '');
27329 onRender : function(ct, B){
27330 Roo.form.Field.superclass.onRender.call(this, ct, B);
27332 var cfg = this.getAutoCreate();
27334 cfg.name = this.name || this.id;
27336 if(this.inputType){
27337 cfg.type = this.inputType;
27340 this.el = ct.createChild(cfg, B);
27342 var C = this.el.dom.type;
27344 if(C == 'password'){
27348 this.el.addClass('x-form-'+C);
27351 this.el.dom.readOnly = true;
27353 if(this.tabIndex !== undefined){
27354 this.el.dom.setAttribute('tabIndex', this.tabIndex);
27358 this.el.addClass([this.fieldClass, this.cls]);
27364 applyTo : function(D){
27365 this.allowDomMove = false;
27366 this.el = Roo.get(D);
27367 this.render(this.el.dom.parentNode);
27372 initValue : function(){
27373 if(this.value !== undefined){
27374 this.setValue(this.value);
27375 }else if(this.el.dom.value.length > 0){
27376 this.setValue(this.el.dom.value);
27382 isDirty : function() {
27383 if(this.disabled) {
27386 return String(this.getValue()) !== String(this.originalValue);
27390 afterRender : function(){
27391 Roo.form.Field.superclass.afterRender.call(this);
27396 fireKey : function(e){
27397 if(e.isNavKeyPress()){
27398 this.fireEvent("specialkey", this, e);
27404 reset : function(){
27405 this.setValue(this.originalValue);
27406 this.clearInvalid();
27410 initEvents : function(){
27411 this.el.on(Roo.isIE ? "keydown" : "keypress", this.fireKey, this);
27412 this.el.on("focus", this.onFocus, this);
27413 this.el.on("blur", this.onBlur, this);
27416 this.originalValue = this.getValue();
27420 onFocus : function(){
27421 if(!Roo.isOpera && this.focusClass){
27422 this.el.addClass(this.focusClass);
27424 if(!this.hasFocus){
27425 this.hasFocus = true;
27426 this.startValue = this.getValue();
27427 this.fireEvent("focus", this);
27431 beforeBlur : Roo.emptyFn,
27434 onBlur : function(){
27436 if(!Roo.isOpera && this.focusClass){
27437 this.el.removeClass(this.focusClass);
27440 this.hasFocus = false;
27441 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
27444 var v = this.getValue();
27445 if(String(v) !== String(this.startValue)){
27446 this.fireEvent('change', this, v, this.startValue);
27449 this.fireEvent("blur", this);
27454 isValid : function(E){
27458 var F = this.preventMark;
27459 this.preventMark = E === true;
27460 var v = this.validateValue(this.processValue(this.getRawValue()));
27461 this.preventMark = F;
27467 validate : function(){
27468 if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
27469 this.clearInvalid();
27475 processValue : function(G){
27481 validateValue : function(H){
27487 markInvalid : function(I){
27488 if(!this.rendered || this.preventMark){
27492 this.el.addClass(this.invalidClass);
27493 I = I || this.invalidText;
27494 switch(this.msgTarget){
27496 this.el.dom.qtip = I;
27497 this.el.dom.qclass = 'x-form-invalid-tip';
27499 Roo.QuickTips.enable();
27503 this.el.dom.title = I;
27507 var elp = this.el.findParent('.x-form-element', 5, true);
27508 this.errorEl = elp.createChild({cls:'x-form-invalid-msg'});
27509 this.errorEl.setWidth(elp.getWidth(true)-20);
27512 this.errorEl.update(I);
27513 Roo.form.Field.msgFx[this.msgFx].show(this.errorEl, this);
27516 if(!this.errorIcon){
27517 var elp = this.el.findParent('.x-form-element', 5, true);
27518 this.errorIcon = elp.createChild({cls:'x-form-invalid-icon'});
27521 this.alignErrorIcon();
27522 this.errorIcon.dom.qtip = I;
27523 this.errorIcon.dom.qclass = 'x-form-invalid-tip';
27524 this.errorIcon.show();
27525 this.on('resize', this.alignErrorIcon, this);
27528 var t = Roo.getDom(this.msgTarget);
27530 t.style.display = this.msgDisplay;
27534 this.fireEvent('invalid', this, I);
27538 alignErrorIcon : function(){
27539 this.errorIcon.alignTo(this.el, 'tl-tr', [2, 0]);
27544 clearInvalid : function(){
27545 if(!this.rendered || this.preventMark){
27549 this.el.removeClass(this.invalidClass);
27550 switch(this.msgTarget){
27552 this.el.dom.qtip = '';
27555 this.el.dom.title = '';
27559 Roo.form.Field.msgFx[this.msgFx].hide(this.errorEl, this);
27563 if(this.errorIcon){
27564 this.errorIcon.dom.qtip = '';
27565 this.errorIcon.hide();
27566 this.un('resize', this.alignErrorIcon, this);
27570 var t = Roo.getDom(this.msgTarget);
27572 t.style.display = 'none';
27576 this.fireEvent('valid', this);
27581 getRawValue : function(){
27582 var v = this.el.getValue();
27583 if(v === this.emptyText){
27591 getValue : function(){
27592 var v = this.el.getValue();
27593 if(v === this.emptyText || v === undefined){
27601 setRawValue : function(v){
27602 return this.el.dom.value = (v === null || v === undefined ? '' : v);
27607 setValue : function(v){
27610 this.el.dom.value = (v === null || v === undefined ? '' : v);
27615 adjustSize : function(w, h){
27616 var s = Roo.form.Field.superclass.adjustSize.call(this, w, h);
27617 s.width = this.adjustWidth(this.el.dom.tagName, s.width);
27621 adjustWidth : function(J, w){
27622 J = J.toLowerCase();
27623 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
27624 if(Roo.isIE && (J == 'input' || J == 'textarea')){
27628 if(J = 'textarea'){
27631 }else if(Roo.isOpera){
27635 if(J = 'textarea'){
27646 Roo.form.Field.msgFx = {
27648 show: function(K, f){
27649 K.setDisplayed('block');
27652 hide : function(L, f){
27653 L.setDisplayed(false).update('');
27658 show: function(M, f){
27659 M.slideIn('t', {stopFx:true});
27662 hide : function(N, f){
27663 N.slideOut('t', {stopFx:true,useDisplay:true});
27668 show: function(O, f){
27670 O.alignTo(f.el, 'tl-tr');
27671 O.slideIn('l', {stopFx:true});
27674 hide : function(P, f){
27675 P.slideOut('l', {stopFx:true,useDisplay:true});
27685 Roo.form.TextField = function(A){
27686 Roo.form.TextField.superclass.constructor.call(this, A);
27694 Roo.extend(Roo.form.TextField, Roo.form.Field, {
27712 disableKeyFilter : false,
27721 maxLength : Number.MAX_VALUE,
27724 minLengthText : "The minimum length for this field is {0}",
27727 maxLengthText : "The maximum length for this field is {0}",
27730 selectOnFocus : false,
27733 blankText : "This field is required",
27748 emptyClass : 'x-form-empty-field',
27751 initEvents : function(){
27752 Roo.form.TextField.superclass.initEvents.call(this);
27753 if(this.validationEvent == 'keyup'){
27754 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
27755 this.el.on('keyup', this.filterValidation, this);
27757 else if(this.validationEvent !== false){
27758 this.el.on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
27760 if(this.selectOnFocus || this.emptyText){
27761 this.on("focus", this.preFocus, this);
27762 if(this.emptyText){
27763 this.on('blur', this.postBlur, this);
27764 this.applyEmptyText();
27767 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
27768 this.el.on("keypress", this.filterKeys, this);
27771 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
27772 this.el.on("click", this.autoSize, this);
27776 processValue : function(B){
27777 if(this.stripCharsRe){
27778 var newValue = B.replace(this.stripCharsRe, '');
27779 if(newValue !== B){
27780 this.setRawValue(newValue);
27787 filterValidation : function(e){
27788 if(!e.isNavKeyPress()){
27789 this.validationTask.delay(this.validationDelay);
27794 onKeyUp : function(e){
27795 if(!e.isNavKeyPress()){
27802 reset : function(){
27803 Roo.form.TextField.superclass.reset.call(this);
27804 this.applyEmptyText();
27807 applyEmptyText : function(){
27808 if(this.rendered && this.emptyText && this.getRawValue().length < 1){
27809 this.setRawValue(this.emptyText);
27810 this.el.addClass(this.emptyClass);
27815 preFocus : function(){
27816 if(this.emptyText){
27817 if(this.el.dom.value == this.emptyText){
27818 this.setRawValue('');
27821 this.el.removeClass(this.emptyClass);
27823 if(this.selectOnFocus){
27824 this.el.dom.select();
27829 postBlur : function(){
27830 this.applyEmptyText();
27834 filterKeys : function(e){
27835 var k = e.getKey();
27836 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
27839 var c = e.getCharCode(), cc = String.fromCharCode(c);
27840 if(Roo.isIE && (e.isSpecialKey() || !cc)){
27843 if(!this.maskRe.test(cc)){
27848 setValue : function(v){
27849 if(this.emptyText && this.el && v !== undefined && v !== null && v !== ''){
27850 this.el.removeClass(this.emptyClass);
27853 Roo.form.TextField.superclass.setValue.apply(this, arguments);
27854 this.applyEmptyText();
27860 validateValue : function(C){
27861 if(C.length < 1 || C === this.emptyText){
27862 if(this.allowBlank){
27863 this.clearInvalid();
27866 this.markInvalid(this.blankText);
27870 if(C.length < this.minLength){
27871 this.markInvalid(String.format(this.minLengthText, this.minLength));
27874 if(C.length > this.maxLength){
27875 this.markInvalid(String.format(this.maxLengthText, this.maxLength));
27879 var vt = Roo.form.VTypes;
27880 if(!vt[this.vtype](C, this)){
27881 this.markInvalid(this.vtypeText || vt[this.vtype +'Text']);
27885 if(typeof this.validator == "function"){
27886 var msg = this.validator(C);
27888 this.markInvalid(msg);
27892 if(this.regex && !this.regex.test(C)){
27893 this.markInvalid(this.regexText);
27901 selectText : function(D, E){
27902 var v = this.getRawValue();
27904 D = D === undefined ? 0 : D;
27905 E = E === undefined ? v.length : E;
27906 var d = this.el.dom;
27907 if(d.setSelectionRange){
27908 d.setSelectionRange(D, E);
27909 }else if(d.createTextRange){
27910 var range = d.createTextRange();
27911 range.moveStart("character", D);
27912 range.moveEnd("character", v.length-E);
27920 autoSize : function(){
27921 if(!this.grow || !this.rendered){
27925 this.metrics = Roo.util.TextMetrics.createInstance(this.el);
27928 var v = el.dom.value;
27929 var d = document.createElement('div');
27930 d.appendChild(document.createTextNode(v));
27934 var w = Math.min(this.growMax, Math.max(this.metrics.getWidth(v) +
27935 10, this.growMin));
27936 this.el.setWidth(w);
27937 this.fireEvent("autosize", this, w);
27949 Roo.form.Hidden = function(A){
27950 Roo.form.Hidden.superclass.constructor.call(this, A);
27953 Roo.extend(Roo.form.Hidden, Roo.form.TextField, {
27955 inputType: 'hidden',
27958 labelSeparator: '',
27960 itemCls : 'x-form-item-display-none'
27972 Roo.form.TriggerField = function(A){
27973 this.mimicing = false;
27974 Roo.form.TriggerField.superclass.constructor.call(this, A);
27977 Roo.extend(Roo.form.TriggerField, Roo.form.TextField, {
27982 defaultAutoCreate : {tag: "input", type: "text", size: "16", autocomplete: "off"},
27996 autoSize: Roo.emptyFn,
28000 deferHeight : true,
28003 actionMode : 'wrap',
28005 onResize : function(w, h){
28006 Roo.form.TriggerField.superclass.onResize.apply(this, arguments);
28007 if(typeof w == 'number'){
28008 this.el.setWidth(this.adjustWidth('input', w - this.trigger.getWidth()));
28013 adjustSize : Roo.BoxComponent.prototype.adjustSize,
28016 getResizeEl : function(){
28021 getPositionEl : function(){
28026 alignErrorIcon : function(){
28027 this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);
28031 onRender : function(ct, B){
28032 Roo.form.TriggerField.superclass.onRender.call(this, ct, B);
28033 this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
28034 this.trigger = this.wrap.createChild(this.triggerConfig ||
28035 {tag: "img", src: Roo.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.triggerClass});
28036 if(this.hideTrigger){
28037 this.trigger.setDisplayed(false);
28040 this.initTrigger();
28042 this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
28047 initTrigger : function(){
28048 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
28049 this.trigger.addClassOnOver('x-form-trigger-over');
28050 this.trigger.addClassOnClick('x-form-trigger-click');
28054 onDestroy : function(){
28056 this.trigger.removeAllListeners();
28057 this.trigger.remove();
28060 this.wrap.remove();
28063 Roo.form.TriggerField.superclass.onDestroy.call(this);
28067 onFocus : function(){
28068 Roo.form.TriggerField.superclass.onFocus.call(this);
28069 if(!this.mimicing){
28070 this.wrap.addClass('x-trigger-wrap-focus');
28071 this.mimicing = true;
28072 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
28073 if(this.monitorTab){
28074 this.el.on("keydown", this.checkTab, this);
28080 checkTab : function(e){
28081 if(e.getKey() == e.TAB){
28082 this.triggerBlur();
28087 onBlur : function(){
28092 mimicBlur : function(e, t){
28093 if(!this.wrap.contains(t) && this.validateBlur()){
28094 this.triggerBlur();
28099 triggerBlur : function(){
28100 this.mimicing = false;
28101 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
28102 if(this.monitorTab){
28103 this.el.un("keydown", this.checkTab, this);
28106 this.wrap.removeClass('x-trigger-wrap-focus');
28107 Roo.form.TriggerField.superclass.onBlur.call(this);
28112 validateBlur : function(e, t){
28117 onDisable : function(){
28118 Roo.form.TriggerField.superclass.onDisable.call(this);
28120 this.wrap.addClass('x-item-disabled');
28125 onEnable : function(){
28126 Roo.form.TriggerField.superclass.onEnable.call(this);
28128 this.wrap.removeClass('x-item-disabled');
28133 onShow : function(){
28134 var ae = this.getActionEl();
28137 ae.dom.style.display = '';
28138 ae.dom.style.visibility = 'visible';
28144 onHide : function(){
28145 var ae = this.getActionEl();
28146 ae.dom.style.display = 'none';
28151 onTriggerClick : Roo.emptyFn
28157 Roo.form.TwinTriggerField = Roo.extend(Roo.form.TriggerField, {
28158 initComponent : function(){
28159 Roo.form.TwinTriggerField.superclass.initComponent.call(this);
28161 this.triggerConfig = {
28162 tag:'span', cls:'x-form-twin-triggers', cn:[
28163 {tag: "img", src: Roo.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.trigger1Class},
28164 {tag: "img", src: Roo.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.trigger2Class}
28168 getTrigger : function(C){
28169 return this.triggers[C];
28172 initTrigger : function(){
28173 var ts = this.trigger.select('.x-form-trigger', true);
28174 this.wrap.setStyle('overflow', 'hidden');
28176 ts.each(function(t, E, F){
28177 t.hide = function(){
28178 var w = D.wrap.getWidth();
28179 this.dom.style.display = 'none';
28180 D.el.setWidth(w-D.trigger.getWidth());
28182 t.show = function(){
28183 var w = D.wrap.getWidth();
28184 this.dom.style.display = '';
28185 D.el.setWidth(w-D.trigger.getWidth());
28187 var G = 'Trigger'+(F+1);
28189 if(this['hide'+G]){
28190 t.dom.style.display = 'none';
28193 t.on("click", this['on'+G+'Click'], this, {preventDefault:true});
28194 t.addClassOnOver('x-form-trigger-over');
28195 t.addClassOnClick('x-form-trigger-click');
28197 this.triggers = ts.elements;
28200 onTrigger1Click : Roo.emptyFn,
28201 onTrigger2Click : Roo.emptyFn
28208 Roo.form.TextArea = function(A){
28209 Roo.form.TextArea.superclass.constructor.call(this, A);
28213 if(this.minHeight !== undefined){
28214 this.growMin = this.minHeight;
28216 if(this.maxHeight !== undefined){
28217 this.growMax = this.maxHeight;
28221 Roo.extend(Roo.form.TextArea, Roo.form.TextField, {
28230 preventScrollbars: false,
28235 onRender : function(ct, B){
28237 this.defaultAutoCreate = {
28239 style:"width:300px;height:60px;",
28240 autocomplete: "off"
28244 Roo.form.TextArea.superclass.onRender.call(this, ct, B);
28246 this.textSizeEl = Roo.DomHelper.append(document.body, {
28247 tag: "pre", cls: "x-form-grow-sizer"
28249 if(this.preventScrollbars){
28250 this.el.setStyle("overflow", "hidden");
28253 this.el.setHeight(this.growMin);
28257 onDestroy : function(){
28258 if(this.textSizeEl){
28259 this.textSizeEl.parentNode.removeChild(this.textSizeEl);
28262 Roo.form.TextArea.superclass.onDestroy.call(this);
28266 onKeyUp : function(e){
28267 if(!e.isNavKeyPress() || e.getKey() == e.ENTER){
28274 autoSize : function(){
28275 if(!this.grow || !this.textSizeEl){
28279 var v = el.dom.value;
28280 var ts = this.textSizeEl;
28283 ts.appendChild(document.createTextNode(v));
28286 Roo.fly(ts).setWidth(this.el.getWidth());
28288 v = "  ";
28291 v = v.replace(/\n/g, '<p> </p>');
28294 v += " \n ";
28298 var h = Math.min(this.growMax, Math.max(ts.offsetHeight, this.growMin));
28299 if(h != this.lastHeight){
28300 this.lastHeight = h;
28301 this.el.setHeight(h);
28302 this.fireEvent("autosize", this, h);
28312 Roo.form.NumberField = function(A){
28313 Roo.form.NumberField.superclass.constructor.call(this, A);
28316 Roo.extend(Roo.form.NumberField, Roo.form.TextField, {
28319 fieldClass: "x-form-field x-form-num-field",
28322 allowDecimals : true,
28325 decimalSeparator : ".",
28328 decimalPrecision : 2,
28331 allowNegative : true,
28334 minValue : Number.NEGATIVE_INFINITY,
28337 maxValue : Number.MAX_VALUE,
28340 minText : "The minimum value for this field is {0}",
28343 maxText : "The maximum value for this field is {0}",
28346 nanText : "{0} is not a valid number",
28349 initEvents : function(){
28350 Roo.form.NumberField.superclass.initEvents.call(this);
28351 var B = "0123456789";
28352 if(this.allowDecimals){
28353 B += this.decimalSeparator;
28355 if(this.allowNegative){
28359 this.stripCharsRe = new RegExp('[^'+B+']', 'gi');
28360 var C = function(e){
28361 var k = e.getKey();
28362 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE )){
28365 var c = e.getCharCode();
28366 if(B.indexOf(String.fromCharCode(c)) === -1){
28370 this.el.on("keypress", C, this);
28374 validateValue : function(D){
28375 if(!Roo.form.NumberField.superclass.validateValue.call(this, D)){
28381 var E = this.parseValue(D);
28383 this.markInvalid(String.format(this.nanText, D));
28386 if(E < this.minValue){
28387 this.markInvalid(String.format(this.minText, this.minValue));
28390 if(E > this.maxValue){
28391 this.markInvalid(String.format(this.maxText, this.maxValue));
28397 getValue : function(){
28398 return this.fixPrecision(this.parseValue(Roo.form.NumberField.superclass.getValue.call(this)));
28402 parseValue : function(F){
28403 F = parseFloat(String(F).replace(this.decimalSeparator, "."));
28404 return isNaN(F) ? '' : F;
28408 fixPrecision : function(G){
28410 if(!this.allowDecimals || this.decimalPrecision == -1 || H || !G){
28413 return parseFloat(G).toFixed(this.decimalPrecision);
28416 setValue : function(v){
28417 Roo.form.NumberField.superclass.setValue.call(this, String(v).replace(".", this.decimalSeparator));
28421 decimalPrecisionFcn : function(v){
28422 return Math.floor(v);
28425 beforeBlur : function(){
28426 var v = this.parseValue(this.getRawValue());
28428 this.setValue(this.fixPrecision(v));
28437 Roo.form.DateField = function(A){
28438 Roo.form.DateField.superclass.constructor.call(this, A);
28449 if(typeof this.minValue == "string") this.minValue = this.parseDate(this.minValue);
28450 if(typeof this.maxValue == "string") this.maxValue = this.parseDate(this.maxValue);
28451 this.ddMatch = null;
28452 if(this.disabledDates){
28453 var dd = this.disabledDates;
28455 for(var i = 0; i < dd.length; i++){
28457 if(i != dd.length-1) re += "|";
28460 this.ddMatch = new RegExp(re + ")");
28464 Roo.extend(Roo.form.DateField, Roo.form.TriggerField, {
28470 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
28473 disabledDays : null,
28476 disabledDaysText : "Disabled",
28479 disabledDates : null,
28482 disabledDatesText : "Disabled",
28491 minText : "The date in this field must be equal to or after {0}",
28494 maxText : "The date in this field must be equal to or before {0}",
28497 invalidText : "{0} is not a valid date - it must be in the format {1}",
28500 triggerClass : 'x-form-date-trigger',
28509 defaultAutoCreate : {tag: "input", type: "text", size: "10", autocomplete: "off"},
28512 hiddenField: false,
28514 onRender : function(ct, B)
28516 Roo.form.DateField.superclass.onRender.call(this, ct, B);
28518 this.el.dom.removeAttribute('name');
28519 this.hiddenField = this.el.insertSibling({ tag:'input', type:'hidden', name: this.name },
28521 this.hiddenField.value = this.formatDate(this.value, 'Y-m-d');
28523 this.hiddenName = this.name;
28530 validateValue : function(C)
28532 C = this.formatDate(C);
28533 if(!Roo.form.DateField.superclass.validateValue.call(this, C)){
28540 C = this.parseDate(C);
28542 this.markInvalid(String.format(this.invalidText, D, this.format));
28545 var E = C.getTime();
28546 if(this.minValue && E < this.minValue.getTime()){
28547 this.markInvalid(String.format(this.minText, this.formatDate(this.minValue)));
28550 if(this.maxValue && E > this.maxValue.getTime()){
28551 this.markInvalid(String.format(this.maxText, this.formatDate(this.maxValue)));
28554 if(this.disabledDays){
28555 var day = C.getDay();
28556 for(var i = 0; i < this.disabledDays.length; i++) {
28557 if(day === this.disabledDays[i]){
28558 this.markInvalid(this.disabledDaysText);
28563 var F = this.formatDate(C);
28564 if(this.ddMatch && this.ddMatch.test(F)){
28565 this.markInvalid(String.format(this.disabledDatesText, F));
28573 validateBlur : function(){
28574 return !this.menu || !this.menu.isVisible();
28579 getValue : function(){
28581 return this.hiddenField ? this.hiddenField.value : this.parseDate(Roo.form.DateField.superclass.getValue.call(this)) || "";
28586 setValue : function(G){
28587 if (this.hiddenField) {
28588 this.hiddenField.value = this.formatDate(this.parseDate(G), 'Y-m-d');
28591 Roo.form.DateField.superclass.setValue.call(this, this.formatDate(this.parseDate(G)));
28595 parseDate : function(H){
28596 if(!H || H instanceof Date){
28599 var v = Date.parseDate(H, this.format);
28600 if(!v && this.altFormats){
28601 if(!this.altFormatsArray){
28602 this.altFormatsArray = this.altFormats.split("|");
28604 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
28605 v = Date.parseDate(H, this.altFormatsArray[i]);
28612 formatDate : function(I, J){
28613 return (!I || !(I instanceof Date)) ?
28614 I : I.dateFormat(J || this.format);
28619 select: function(m, d){
28621 this.fireEvent('select', this, d);
28627 this.focus.defer(10, this);
28628 var ml = this.menuListeners;
28629 this.menu.un("select", ml.select, this);
28630 this.menu.un("show", ml.show, this);
28631 this.menu.un("hide", ml.hide, this);
28637 onTriggerClick : function(){
28641 if(this.menu == null){
28642 this.menu = new Roo.menu.DateMenu();
28645 Roo.apply(this.menu.picker, {
28646 showClear: this.allowBlank,
28647 minDate : this.minValue,
28648 maxDate : this.maxValue,
28649 disabledDatesRE : this.ddMatch,
28650 disabledDatesText : this.disabledDatesText,
28651 disabledDays : this.disabledDays,
28652 disabledDaysText : this.disabledDaysText,
28653 format : this.format,
28654 minText : String.format(this.minText, this.formatDate(this.minValue)),
28655 maxText : String.format(this.maxText, this.formatDate(this.maxValue))
28657 this.menu.on(Roo.apply({}, this.menuListeners, {
28660 this.menu.picker.setValue(this.getValue() || new Date());
28661 this.menu.show(this.el, "tl-bl?");
28664 beforeBlur : function(){
28665 var v = this.parseDate(this.getRawValue());
28686 Roo.form.ComboBox = function(A){
28687 Roo.form.ComboBox.superclass.constructor.call(this, A);
28697 'beforeselect' : true,
28703 'beforequery': true
28705 if(this.transform){
28706 this.allowDomMove = false;
28707 var s = Roo.getDom(this.transform);
28708 if(!this.hiddenName){
28709 this.hiddenName = s.name;
28712 this.mode = 'local';
28713 var d = [], opts = s.options;
28714 for(var i = 0, len = opts.length;i < len; i++){
28716 var value = (Roo.isIE ? o.getAttributeNode('value').specified : o.hasAttribute('value')) ? o.value : o.text;
28718 this.value = value;
28721 d.push([value, o.text]);
28724 this.store = new Roo.data.SimpleStore({
28726 fields: ['value', 'text'],
28729 this.valueField = 'value';
28730 this.displayField = 'text';
28734 if(!this.lazyRender){
28735 this.target = true;
28736 this.el = Roo.DomHelper.insertBefore(s, this.autoCreate || this.defaultAutoCreate);
28737 s.parentNode.removeChild(s);
28738 this.render(this.el.parentNode);
28740 s.parentNode.removeChild(s);
28745 this.store = Roo.factory(this.store, Roo.data);
28749 this.selectedIndex = -1;
28750 if(this.mode == 'local'){
28751 if(A.queryDelay === undefined){
28752 this.queryDelay = 10;
28754 if(A.minChars === undefined){
28760 Roo.extend(Roo.form.ComboBox, Roo.form.TriggerField, {
28776 defaultAutoCreate : {tag: "input", type: "text", size: "24", autocomplete: "off"},
28779 listWidth: undefined,
28782 displayField: undefined,
28785 valueField: undefined,
28788 hiddenName: undefined,
28794 selectedClass: 'x-combo-selected',
28797 triggerClass : 'x-form-arrow-trigger',
28803 listAlign: 'tl-bl?',
28809 triggerAction: 'query',
28824 selectOnFocus:false,
28827 queryParam: 'query',
28830 loadingText: 'Loading...',
28851 forceSelection:false,
28854 typeAheadDelay : 250,
28857 valueNotFoundText : undefined,
28860 blockFocus : false,
28864 disableClear : false,
28867 onRender : function(ct, B){
28868 Roo.form.ComboBox.superclass.onRender.call(this, ct, B);
28869 if(this.hiddenName){
28870 this.hiddenField = this.el.insertSibling({tag:'input', type:'hidden', name: this.hiddenName, id: (this.hiddenId||this.hiddenName)},
28872 this.hiddenField.value =
28873 this.hiddenValue !== undefined ? this.hiddenValue :
28874 this.value !== undefined ? this.value : '';
28877 this.el.dom.removeAttribute('name');
28880 this.el.dom.setAttribute('autocomplete', 'off');
28883 var C = 'x-combo-list';
28885 this.list = new Roo.Layer({
28886 shadow: this.shadow, cls: [C, this.listClass].join(' '), constrain:false
28889 var lw = this.listWidth || Math.max(this.wrap.getWidth(), this.minListWidth);
28890 this.list.setWidth(lw);
28891 this.list.swallowEvent('mousewheel');
28892 this.assetHeight = 0;
28895 this.header = this.list.createChild({cls:C+'-hd', html: this.title});
28896 this.assetHeight += this.header.getHeight();
28900 this.innerList = this.list.createChild({cls:C+'-inner'});
28901 this.innerList.on('mouseover', this.onViewOver, this);
28902 this.innerList.on('mousemove', this.onViewMove, this);
28903 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
28905 if(this.allowBlank && !this.pageSize && !this.disableClear){
28906 this.footer = this.list.createChild({cls:C+'-ft'});
28907 this.pageTb = new Roo.Toolbar(this.footer);
28911 this.footer = this.list.createChild({cls:C+'-ft'});
28912 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
28913 {pageSize: this.pageSize});
28917 if (this.pageTb && this.allowBlank && !this.disableClear) {
28919 this.pageTb.add(new Roo.Toolbar.Fill(), {
28920 cls: 'x-btn-icon x-btn-clear',
28922 handler: function()
28925 _this.clearValue();
28926 _this.onSelect(false, -1);
28931 this.assetHeight += this.footer.getHeight();
28936 this.tpl = '<div class="'+C+'-item">{' + this.displayField + '}</div>';
28940 this.view = new Roo.View(this.innerList, this.tpl, {
28941 singleSelect:true, store: this.store, selectedClass: this.selectedClass
28944 this.view.on('click', this.onViewClick, this);
28946 this.store.on('beforeload', this.onBeforeLoad, this);
28947 this.store.on('load', this.onLoad, this);
28948 this.store.on('loadexception', this.collapse, this);
28950 if(this.resizable){
28951 this.resizer = new Roo.Resizable(this.list, {
28952 pinned:true, handles:'se'
28954 this.resizer.on('resize', function(r, w, h){
28955 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
28956 this.listWidth = w;
28957 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
28958 this.restrictHeight();
28960 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
28962 if(!this.editable){
28963 this.editable = true;
28964 this.setEditable(false);
28969 initEvents : function(){
28970 Roo.form.ComboBox.superclass.initEvents.call(this);
28972 this.keyNav = new Roo.KeyNav(this.el, {
28973 "up" : function(e){
28974 this.inKeyMode = true;
28978 "down" : function(e){
28979 if(!this.isExpanded()){
28980 this.onTriggerClick();
28982 this.inKeyMode = true;
28987 "enter" : function(e){
28988 this.onViewClick();
28992 "esc" : function(e){
28996 "tab" : function(e){
28997 this.onViewClick(false);
29003 doRelay : function(D, E, F){
29004 if(F == 'down' || this.scope.isExpanded()){
29005 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
29012 this.queryDelay = Math.max(this.queryDelay || 10,
29013 this.mode == 'local' ? 10 : 250);
29014 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
29015 if(this.typeAhead){
29016 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
29018 if(this.editable !== false){
29019 this.el.on("keyup", this.onKeyUp, this);
29021 if(this.forceSelection){
29022 this.on('blur', this.doForce, this);
29026 onDestroy : function(){
29028 this.view.setStore(null);
29029 this.view.el.removeAllListeners();
29030 this.view.el.remove();
29031 this.view.purgeListeners();
29034 this.list.destroy();
29037 this.store.un('beforeload', this.onBeforeLoad, this);
29038 this.store.un('load', this.onLoad, this);
29039 this.store.un('loadexception', this.collapse, this);
29042 Roo.form.ComboBox.superclass.onDestroy.call(this);
29046 fireKey : function(e){
29047 if(e.isNavKeyPress() && !this.list.isVisible()){
29048 this.fireEvent("specialkey", this, e);
29053 onResize: function(w, h){
29054 Roo.form.ComboBox.superclass.onResize.apply(this, arguments);
29055 if(this.list && this.listWidth === undefined){
29056 var lw = Math.max(w, this.minListWidth);
29057 this.list.setWidth(lw);
29058 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
29064 setEditable : function(D){
29065 if(D == this.editable){
29071 this.el.dom.setAttribute('readOnly', true);
29072 this.el.on('mousedown', this.onTriggerClick, this);
29073 this.el.addClass('x-combo-noedit');
29075 this.el.dom.setAttribute('readOnly', false);
29076 this.el.un('mousedown', this.onTriggerClick, this);
29077 this.el.removeClass('x-combo-noedit');
29082 onBeforeLoad : function(){
29083 if(!this.hasFocus){
29087 this.innerList.update(this.loadingText ?
29088 '<div class="loading-indicator">'+this.loadingText+'</div>' : '');
29089 this.restrictHeight();
29090 this.selectedIndex = -1;
29094 onLoad : function(){
29095 if(!this.hasFocus){
29098 if(this.store.getCount() > 0){
29100 this.restrictHeight();
29101 if(this.lastQuery == this.allQuery){
29103 this.el.dom.select();
29105 if(!this.selectByValue(this.value, true)){
29106 this.select(0, true);
29110 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE ){
29111 this.taTask.delay(this.typeAheadDelay);
29115 this.onEmptyResults();
29121 onTypeAhead : function(){
29122 if(this.store.getCount() > 0){
29123 var r = this.store.getAt(0);
29124 var newValue = r.data[this.displayField];
29125 var len = newValue.length;
29126 var selStart = this.getRawValue().length;
29127 if(selStart != len){
29128 this.setRawValue(newValue);
29129 this.selectText(selStart, newValue.length);
29135 onSelect : function(E, F){
29136 if(this.fireEvent('beforeselect', this, E, F) !== false){
29137 this.setFromData(F > -1 ? E.data : false);
29139 this.fireEvent('select', this, E, F);
29145 getValue : function(){
29146 if(this.valueField){
29147 return typeof this.value != 'undefined' ? this.value : '';
29149 return Roo.form.ComboBox.superclass.getValue.call(this);
29155 clearValue : function(){
29156 if(this.hiddenField){
29157 this.hiddenField.value = '';
29161 this.setRawValue('');
29162 this.lastSelectionText = '';
29163 this.applyEmptyText();
29168 setValue : function(v){
29170 if(this.valueField){
29171 var r = this.findRecord(this.valueField, v);
29173 G = r.data[this.displayField];
29174 }else if(this.valueNotFoundText !== undefined){
29175 G = this.valueNotFoundText;
29179 this.lastSelectionText = G;
29180 if(this.hiddenField){
29181 this.hiddenField.value = v;
29184 Roo.form.ComboBox.superclass.setValue.call(this, G);
29193 setFromData : function(o){
29197 if (this.displayField) {
29198 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
29201 console.log('no value field set for '+ this.name);
29204 if(this.valueField){
29205 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
29207 if(this.hiddenField){
29208 this.hiddenField.value = vv;
29210 this.lastSelectionText = dv;
29211 Roo.form.ComboBox.superclass.setValue.call(this, dv);
29218 this.lastSelectionText = dv;
29219 Roo.form.ComboBox.superclass.setValue.call(this, dv);
29225 reset : function(){
29227 this.setValue(this.originalValue);
29228 this.clearInvalid();
29229 this.lastData = false;
29232 findRecord : function(H, I){
29234 if(this.store.getCount() > 0){
29235 this.store.each(function(r){
29236 if(r.data[H] == I){
29246 onViewMove : function(e, t){
29247 this.inKeyMode = false;
29251 onViewOver : function(e, t){
29252 if(this.inKeyMode){
29255 var K = this.view.findItemFromChild(t);
29257 var F = this.view.indexOf(K);
29258 this.select(F, false);
29263 onViewClick : function(L){
29264 var M = this.view.getSelectedIndexes()[0];
29265 var r = this.store.getAt(M);
29267 this.onSelect(r, M);
29269 if(L !== false && !this.blockFocus){
29275 restrictHeight : function(){
29276 this.innerList.dom.style.height = '';
29277 var N = this.innerList.dom;
29278 var h = Math.max(N.clientHeight, N.offsetHeight, N.scrollHeight);
29279 this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
29280 this.list.beginUpdate();
29281 this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
29282 this.list.alignTo(this.el, this.listAlign);
29283 this.list.endUpdate();
29287 onEmptyResults : function(){
29293 isExpanded : function(){
29294 return this.list.isVisible();
29299 selectByValue : function(v, O){
29300 if(v !== undefined && v !== null){
29301 var r = this.findRecord(this.valueField || this.displayField, v);
29303 this.select(this.store.indexOf(r), O);
29312 select : function(P, Q){
29313 this.selectedIndex = P;
29314 this.view.select(P);
29316 var el = this.view.getNode(P);
29318 this.innerList.scrollChildIntoView(el, false);
29324 selectNext : function(){
29325 var ct = this.store.getCount();
29327 if(this.selectedIndex == -1){
29329 }else if(this.selectedIndex < ct-1){
29330 this.select(this.selectedIndex+1);
29336 selectPrev : function(){
29337 var ct = this.store.getCount();
29339 if(this.selectedIndex == -1){
29341 }else if(this.selectedIndex != 0){
29342 this.select(this.selectedIndex-1);
29348 onKeyUp : function(e){
29349 if(this.editable !== false && !e.isSpecialKey()){
29350 this.lastKey = e.getKey();
29351 this.dqTask.delay(this.queryDelay);
29356 validateBlur : function(){
29357 return !this.list || !this.list.isVisible();
29361 initQuery : function(){
29362 this.doQuery(this.getRawValue());
29366 doForce : function(){
29367 if(this.el.dom.value.length > 0){
29368 this.el.dom.value =
29369 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
29370 this.applyEmptyText();
29376 doQuery : function(q, R){
29377 if(q === undefined || q === null){
29386 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
29392 if(R === true || (q.length >= this.minChars)){
29393 if(this.lastQuery != q){
29394 this.lastQuery = q;
29395 if(this.mode == 'local'){
29396 this.selectedIndex = -1;
29398 this.store.clearFilter();
29400 this.store.filter(this.displayField, q);
29405 this.store.baseParams[this.queryParam] = q;
29407 params: this.getParams(q)
29412 this.selectedIndex = -1;
29419 getParams : function(q){
29424 p.limit = this.pageSize;
29431 collapse : function(){
29432 if(!this.isExpanded()){
29437 Roo.get(document).un('mousedown', this.collapseIf, this);
29438 Roo.get(document).un('mousewheel', this.collapseIf, this);
29439 this.fireEvent('collapse', this);
29443 collapseIf : function(e){
29444 if(!e.within(this.wrap) && !e.within(this.list)){
29451 expand : function(){
29452 if(this.isExpanded() || !this.hasFocus){
29456 this.list.alignTo(this.el, this.listAlign);
29458 Roo.get(document).on('mousedown', this.collapseIf, this);
29459 Roo.get(document).on('mousewheel', this.collapseIf, this);
29460 this.fireEvent('expand', this);
29465 onTriggerClick : function(){
29469 if(this.isExpanded()){
29471 if (!this.blockFocus) {
29476 this.hasFocus = true;
29477 if(this.triggerAction == 'all') {
29478 this.doQuery(this.allQuery, true);
29480 this.doQuery(this.getRawValue());
29482 if (!this.blockFocus) {
29501 Roo.form.Checkbox = function(A){
29502 Roo.form.Checkbox.superclass.constructor.call(this, A);
29510 Roo.extend(Roo.form.Checkbox, Roo.form.Field, {
29513 focusClass : undefined,
29516 fieldClass: "x-form-field",
29522 defaultAutoCreate : { tag: "input", type: 'hidden', autocomplete: "off"},
29533 actionMode : 'viewEl',
29536 itemCls : 'x-menu-check-item x-form-item',
29537 groupClass : 'x-menu-group-item',
29538 inputType : 'hidden',
29541 inSetChecked: false,
29543 inputElement: false,
29548 onResize : function(){
29549 Roo.form.Checkbox.superclass.onResize.apply(this, arguments);
29550 if(!this.boxLabel){
29551 this.el.alignTo(this.wrap, 'c-c');
29555 initEvents : function(){
29556 Roo.form.Checkbox.superclass.initEvents.call(this);
29557 this.el.on("click", this.onClick, this);
29558 this.el.on("change", this.onClick, this);
29562 getResizeEl : function(){
29566 getPositionEl : function(){
29571 onRender : function(ct, B){
29572 Roo.form.Checkbox.superclass.onRender.call(this, ct, B);
29576 this.wrap = this.el.wrap({cls: 'x-menu-check-item '});
29577 var C = this.wrap.createChild({
29578 tag: 'img', cls: 'x-menu-item-icon', style: 'margin: 0px;' ,src : Roo.BLANK_IMAGE_URL });
29580 this.wrap.on('click', this.onClick, this);
29582 this.el.on('DOMAttrModified', this.setFromHidden, this);
29583 this.el.on('propertychange', this.setFromHidden, this);
29588 this.wrap.createChild({tag: 'label', htmlFor: this.el.id, cls: 'x-form-cb-label', html: this.boxLabel});
29593 this.setChecked(this.checked);
29601 initValue : Roo.emptyFn,
29605 getValue : function(){
29607 return String(this.el.dom.value) == String(this.inputValue ) ? this.inputValue : this.valueOff;
29609 return this.valueOff;
29614 onClick : function(){
29615 this.setChecked(!this.checked);
29624 setValue : function(v,D){
29630 this.setChecked(v === this.inputValue);
29634 setChecked : function(E,F)
29636 if (this.inSetChecked) {
29643 this.wrap[E ? 'addClass' : 'removeClass']('x-menu-item-checked');
29648 this.fireEvent('checkchange', this, E);
29651 this.inSetChecked = true;
29652 this.el.dom.value = E ? this.inputValue : this.valueOff;
29653 this.inSetChecked = false;
29657 setFromHidden: function()
29665 this.setValue(this.el.dom.value);
29668 onDestroy : function()
29671 Roo.get(this.viewEl).remove();
29675 Roo.form.Checkbox.superclass.onDestroy.call(this);
29684 Roo.form.Radio = function(){
29685 Roo.form.Radio.superclass.constructor.apply(this, arguments);
29687 Roo.extend(Roo.form.Radio, Roo.form.Checkbox, {
29688 inputType: 'radio',
29692 getGroupValue : function(){
29693 return this.el.up('form').child('input[name='+this.el.dom.name+']:checked', true).value;
29707 Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
29713 createLinkText : 'Please enter the URL for the link:',
29716 defaultLinkValue : 'http:/'+'/',
29723 validationEvent : false,
29725 initialized : false,
29727 sourceEditMode : false,
29728 onFocus : Roo.emptyFn,
29730 hideMode:'offsets',
29731 defaultAutoCreate : {
29733 style:"width:500px;height:300px;",
29734 autocomplete: "off"
29738 initComponent : function(){
29760 editmodechange: true,
29769 createToolbar : function(A){
29770 if (!A.toolbars || !A.toolbars.length) {
29771 A.toolbars = [ new Roo.form.HtmlEditor.ToolbarStandard() ];
29774 for (var i =0 ; i < A.toolbars.length;i++) {
29775 A.toolbars[i].init(A);
29783 getDocMarkup : function(){
29784 return '<html><head><style type="text/css">body{border:0;margin:0;padding:3px;height:98%;cursor:text;}</style></head><body></body></html>';
29788 onRender : function(ct, B){
29789 Roo.form.HtmlEditor.superclass.onRender.call(this, ct, B);
29790 this.el.dom.style.border = '0 none';
29791 this.el.dom.setAttribute('tabIndex', -1);
29792 this.el.addClass('x-hidden');
29794 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
29797 this.wrap = this.el.wrap({
29798 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
29801 this.frameId = Roo.id();
29802 this.createToolbar(this);
29809 var C = this.wrap.createChild({
29812 name: this.frameId,
29813 frameBorder : 'no',
29814 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
29820 this.iframe = C.dom;
29822 this.assignDocWin();
29824 this.doc.designMode = 'on';
29827 this.doc.write(this.getDocMarkup());
29834 this.assignDocWin();
29835 if(this.doc.body || this.doc.readyState == 'complete'){
29839 this.doc.designMode="on";
29844 Roo.TaskMgr.stop(D);
29845 this.initEditor.defer(10, this);
29852 Roo.TaskMgr.start(D);
29855 this.setSize(this.el.getSize());
29860 onResize : function(w, h){
29861 Roo.form.HtmlEditor.superclass.onResize.apply(this, arguments);
29862 if(this.el && this.iframe){
29863 if(typeof w == 'number'){
29864 var aw = w - this.wrap.getFrameWidth('lr');
29865 this.el.setWidth(this.adjustWidth('textarea', aw));
29866 this.iframe.style.width = aw + 'px';
29868 if(typeof h == 'number'){
29870 for (var i =0; i < this.toolbars.length;i++) {
29872 tbh += this.toolbars[i].tb.el.getHeight();
29878 var ah = h - this.wrap.getFrameWidth('tb') - tbh;
29879 this.el.setHeight(this.adjustWidth('textarea', ah));
29880 this.iframe.style.height = ah + 'px';
29882 (this.doc.body || this.doc.documentElement).style.height = (ah - (this.iframePad*2)) + 'px';
29890 toggleSourceEdit : function(E){
29892 this.sourceEditMode = E === true;
29894 if(this.sourceEditMode){
29897 this.iframe.className = 'x-hidden';
29898 this.el.removeClass('x-hidden');
29899 this.el.dom.removeAttribute('tabIndex');
29904 this.iframe.className = '';
29905 this.el.addClass('x-hidden');
29906 this.el.dom.setAttribute('tabIndex', -1);
29910 this.setSize(this.wrap.getSize());
29911 this.fireEvent('editmodechange', this, this.sourceEditMode);
29915 createLink : function(){
29916 var F = prompt(this.createLinkText, this.defaultLinkValue);
29917 if(F && F != 'http:/'+'/'){
29918 this.relayCmd('createlink', F);
29923 adjustSize : Roo.BoxComponent.prototype.adjustSize,
29926 getResizeEl : function(){
29931 getPositionEl : function(){
29936 initEvents : function(){
29937 this.originalValue = this.getValue();
29942 markInvalid : Roo.emptyFn,
29945 clearInvalid : Roo.emptyFn,
29947 setValue : function(v){
29948 Roo.form.HtmlEditor.superclass.setValue.call(this, v);
29954 cleanHtml : function(G){
29958 G = G.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
29969 syncValue : function(){
29970 if(this.initialized){
29971 var bd = (this.doc.body || this.doc.documentElement);
29972 var G = bd.innerHTML;
29974 var bs = bd.getAttribute('style');
29975 var m = bs.match(/text-align:(.*?);/i);
29977 G = '<div style="'+m[0]+'">' + G + '</div>';
29981 G = this.cleanHtml(G);
29982 if(this.fireEvent('beforesync', this, G) !== false){
29983 this.el.dom.value = G;
29984 this.fireEvent('sync', this, G);
29991 pushValue : function(){
29992 if(this.initialized){
29993 var v = this.el.dom.value;
29997 if(this.fireEvent('beforepush', this, v) !== false){
29998 (this.doc.body || this.doc.documentElement).innerHTML = v;
29999 this.fireEvent('push', this, v);
30005 deferFocus : function(){
30006 this.focus.defer(10, this);
30010 focus : function(){
30011 if(this.win && !this.sourceEditMode){
30018 assignDocWin: function()
30020 var H = this.iframe;
30023 this.doc = H.contentWindow.document;
30024 this.win = H.contentWindow;
30026 this.doc = (H.contentDocument || Roo.get(this.frameId).dom.document);
30027 this.win = Roo.get(this.frameId).dom.contentWindow;
30032 initEditor : function(){
30034 this.assignDocWin();
30038 this.doc.designMode="on";
30040 this.doc.write(this.getDocMarkup());
30043 var I = (this.doc.body || this.doc.documentElement);
30047 var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
30048 ss['background-attachment'] = 'fixed';
30049 I.bgProperties = 'fixed';
30050 Roo.DomHelper.applyStyles(I, ss);
30051 Roo.EventManager.on(this.doc, {
30052 'mousedown': this.onEditorEvent,
30053 'dblclick': this.onEditorEvent,
30054 'click': this.onEditorEvent,
30055 'keyup': this.onEditorEvent,
30060 Roo.EventManager.on(this.doc, 'keypress', this.applyCommand, this);
30062 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
30063 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
30066 this.initialized = true;
30068 this.fireEvent('initialize', this);
30073 onDestroy : function(){
30079 for (var i =0; i < this.toolbars.length;i++) {
30081 this.toolbars[i].onDestroy();
30085 this.wrap.dom.innerHTML = '';
30086 this.wrap.remove();
30091 onFirstFocus : function(){
30093 this.assignDocWin();
30096 this.activated = true;
30097 for (var i =0; i < this.toolbars.length;i++) {
30098 this.toolbars[i].onFirstFocus();
30103 var s = this.win.getSelection();
30104 if(!s.focusNode || s.focusNode.nodeType != 3){
30105 var r = s.getRangeAt(0);
30106 r.selectNodeContents((this.doc.body || this.doc.documentElement));
30111 this.execCmd('useCSS', true);
30112 this.execCmd('styleWithCSS', false);
30116 this.fireEvent('activate', this);
30120 adjustFont: function(J){
30121 var K = J.cmd == 'increasefontsize' ? 1 : -1;
30125 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
30127 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
30128 v = (v < 10) ? 10 : v;
30129 v = (v > 48) ? 48 : v;
30130 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
30136 v = Math.max(1, v+K);
30138 this.execCmd('FontSize', v );
30141 onEditorEvent : function(e){
30142 this.fireEvent('editorevent', this, e);
30147 insertTag : function(tg)
30151 this.execCmd("formatblock", tg);
30155 insertText : function(L)
30159 range = this.createRange();
30160 range.deleteContents();
30163 range.insertNode(this.doc.createTextNode(L));
30167 relayBtnCmd : function(M){
30168 this.relayCmd(M.cmd);
30173 relayCmd : function(N, O){
30175 this.execCmd(N, O);
30176 this.fireEvent('editorevent', this);
30183 execCmd : function(P, Q){
30184 this.doc.execCommand(P, false, Q === undefined ? null : Q);
30189 applyCommand : function(e){
30191 var c = e.getCharCode(), P;
30193 c = String.fromCharCode(c);
30209 e.preventDefault();
30217 insertAtCursor : function(R){
30218 if(!this.activated){
30223 var r = this.doc.selection.createRange();
30230 }else if(Roo.isGecko || Roo.isOpera){
30232 this.execCmd('InsertHTML', R);
30234 }else if(Roo.isSafari){
30235 this.execCmd('InsertText', R);
30241 fixKeys : function(){
30243 return function(e){
30244 var k = e.getKey(), r;
30247 r = this.doc.selection.createRange();
30250 r.pasteHTML('    ');
30253 }else if(k == e.ENTER){
30254 r = this.doc.selection.createRange();
30256 var target = r.parentElement();
30257 if(!target || target.tagName.toLowerCase() != 'li'){
30259 r.pasteHTML('<br />');
30266 }else if(Roo.isOpera){
30267 return function(e){
30268 var k = e.getKey();
30272 this.execCmd('InsertHTML','    ');
30276 }else if(Roo.isSafari){
30277 return function(e){
30278 var k = e.getKey();
30281 this.execCmd('InsertText','\t');
30288 getAllAncestors: function()
30290 var p = this.getSelectedNode();
30294 p = this.getParentElement();
30298 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
30303 a.push(this.doc.body);
30307 lastSelNode : false,
30310 getSelection : function()
30312 this.assignDocWin();
30313 return Roo.isIE ? this.doc.selection : this.win.getSelection();
30316 getSelectedNode: function()
30325 var S = this.createRange(this.getSelection());
30328 var parent = S.parentElement();
30330 var testRange = S.duplicate();
30331 testRange.moveToElementText(parent);
30332 if (testRange.inRange(S)) {
30335 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
30339 parent = parent.parentElement;
30345 var ar = S.endContainer.childNodes;
30347 ar = S.commonAncestorContainer.childNodes;
30353 for (var i=0;i<ar.length;i++) {
30354 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) {
30359 if (this.rangeIntersectsNode(S,ar[i]) && this.rangeCompareNode(S,ar[i]) == 3) {
30365 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(S,ar[i]) && (this.rangeCompareNode(S,ar[i]) > 0)) {
30369 if (!this.rangeIntersectsNode(S,ar[i])|| (this.rangeCompareNode(S,ar[i]) == 0)) {
30377 if (!T.length && U.length) {
30380 if (V || !T.length || (T.length > 1)) {
30386 createRange: function(W)
30391 if (typeof W != "undefined") {
30393 return W.getRangeAt ? W.getRangeAt(0) : W.createRange();
30395 return this.doc.createRange();
30398 return this.doc.createRange();
30401 getParentElement: function()
30404 this.assignDocWin();
30405 var X = Roo.isIE ? this.doc.selection : this.win.getSelection();
30407 var Y = this.createRange(X);
30410 var p = Y.commonAncestorContainer;
30411 while (p.nodeType == 3) {
30424 rangeIntersectsNode : function(Z, b)
30426 var d = b.ownerDocument.createRange();
30431 nodeRange.selectNodeContents(node);
30434 return Z.compareBoundaryPoints(Range.END_TO_START, d) == -1 &&
30435 Z.compareBoundaryPoints(Range.START_TO_END, d) == 1;
30437 rangeCompareNode : function(f, g) {
30438 var j = g.ownerDocument.createRange();
30442 nodeRange.selectNodeContents(node);
30444 var k = f.compareBoundaryPoints(Range.START_TO_START, j) == 1;
30445 var l = f.compareBoundaryPoints(Range.END_TO_END, j) == -1;
30492 Roo.form.HtmlEditor.ToolbarStandard = function(A)
30495 Roo.apply(this, A);
30501 Roo.apply(Roo.form.HtmlEditor.ToolbarStandard.prototype, {
30540 "form", "input:text", "input:hidden", "input:checkbox", "input:radio", "input:password",
30541 "input:submit", "input:button", "select", "textarea", "label" ],
30544 ["h1"],["h2"],["h3"],["h4"],["h5"],["h6"],
30546 ["abbr"],[ "acronym"],[ "address"],[ "cite"],[ "samp"],[ "var"]
30550 defaultFont: 'tahoma',
30552 fontSelect : false,
30555 formatCombo : false,
30564 function E(id, G, H){
30565 var I = C + '-'+ id ;
30569 cls : 'x-btn-icon x-edit-'+id,
30570 enableToggle:G !== false,
30572 handler:H||B.relayBtnCmd,
30573 clickEvent:'mousedown',
30574 tooltip: D.buttonTips[id] || undefined,
30581 var tb = new Roo.Toolbar(B.wrap.dom.firstChild);
30584 tb.el.on('click', function(e){
30585 e.preventDefault();
30588 if(!this.disable.font && !Roo.isSafari){
30592 if(!this.disable.formats){
30593 this.formatCombo = new Roo.form.ComboBox({
30594 store: new Roo.data.SimpleStore({
30597 data : this.formats
30601 displayField:'tag',
30605 triggerAction: 'all',
30606 emptyText:'Add tag',
30607 selectOnFocus:true,
30610 'select': function(c, r, i) {
30611 B.insertTag(r.get('tag'));
30617 tb.addField(this.formatCombo);
30621 if(!this.disable.format){
30628 if(!this.disable.fontSize){
30633 E('increasefontsize', false, B.adjustFont),
30634 E('decreasefontsize', false, B.adjustFont)
30639 if(this.disable.colors){
30642 id:B.frameId +'-forecolor',
30643 cls:'x-btn-icon x-edit-forecolor',
30644 clickEvent:'mousedown',
30645 tooltip: this.buttonTips['forecolor'] || undefined,
30647 menu : new Roo.menu.ColorMenu({
30648 allowReselect: true,
30649 focus: Roo.emptyFn,
30652 selectHandler: function(cp, G){
30653 B.execCmd('forecolor', Roo.isSafari || Roo.isIE ? '#'+G : G);
30657 clickEvent:'mousedown'
30660 id:B.frameId +'backcolor',
30661 cls:'x-btn-icon x-edit-backcolor',
30662 clickEvent:'mousedown',
30663 tooltip: this.buttonTips['backcolor'] || undefined,
30665 menu : new Roo.menu.ColorMenu({
30666 focus: Roo.emptyFn,
30669 allowReselect: true,
30670 selectHandler: function(cp, H){
30672 B.execCmd('useCSS', false);
30673 B.execCmd('hilitecolor', H);
30674 B.execCmd('useCSS', true);
30677 B.execCmd(Roo.isOpera ? 'hilitecolor' : 'backcolor',
30678 Roo.isSafari || Roo.isIE ? '#'+H : H);
30683 clickEvent:'mousedown'
30691 if(!this.disable.alignments){
30695 E('justifycenter'),
30701 if(!this.disable.links){
30704 E('createlink', false, B.createLink)
30708 if(!this.disable.lists){
30711 E('insertorderedlist'),
30712 E('insertunorderedlist')
30715 if(!this.disable.sourceEdit){
30718 E('sourceedit', true, function(G){
30719 this.toggleSourceEdit(G.pressed);
30727 if (!this.disable.special) {
30730 cls: 'x-edit-none',
30735 for (var i =0; i < this.specialChars.length; i++) {
30736 F.menu.items.push({
30738 text: this.specialChars[i],
30739 handler: function(a,b) {
30740 B.insertAtCursor(String.fromCharCode(a.text.replace('&#','').replace(';', '')));
30753 for(var i =0; i< this.btns.length;i++) {
30754 var b = this.btns[i];
30755 b.cls = 'x-edit-none';
30767 this.tb.items.each(function(G){
30768 if(G.id != B.frameId+ '-sourceedit'){
30772 this.rendered = true;
30775 B.on('editorevent', this.updateToolbar, this);
30784 updateToolbar: function(){
30786 if(!this.editor.activated){
30787 this.editor.onFirstFocus();
30791 var G = this.tb.items.map,
30792 H = this.editor.doc,
30793 I = this.editor.frameId;
30795 if(!this.disable.font && !Roo.isSafari){
30799 if(!this.disable.format){
30800 G[I + '-bold'].toggle(H.queryCommandState('bold'));
30801 G[I + '-italic'].toggle(H.queryCommandState('italic'));
30802 G[I + '-underline'].toggle(H.queryCommandState('underline'));
30804 if(!this.disable.alignments){
30805 G[I + '-justifyleft'].toggle(H.queryCommandState('justifyleft'));
30806 G[I + '-justifycenter'].toggle(H.queryCommandState('justifycenter'));
30807 G[I + '-justifyright'].toggle(H.queryCommandState('justifyright'));
30809 if(!Roo.isSafari && !this.disable.lists){
30810 G[I + '-insertorderedlist'].toggle(H.queryCommandState('insertorderedlist'));
30811 G[I + '-insertunorderedlist'].toggle(H.queryCommandState('insertunorderedlist'));
30814 var J = this.editor.getAllAncestors();
30815 if (this.formatCombo) {
30818 var store = this.formatCombo.store;
30819 this.formatCombo.setValue("");
30820 for (var i =0; i < J.length;i++) {
30821 if (J[i] && store.query('tag',J[i].tagName.toLowerCase(), true).length) {
30823 this.formatCombo.setValue(J[i].tagName.toLowerCase());
30833 Roo.menu.MenuMgr.hideAll();
30839 createFontOptions : function(){
30840 var K = [], fs = this.fontFamilies, ff, lc;
30841 for(var i = 0, len = fs.length; i< len; i++){
30843 lc = ff.toLowerCase();
30845 '<option value="',lc,'" style="font-family:',ff,';"',
30846 (this.defaultFont == lc ? ' selected="true">' : '>'),
30854 toggleSourceEdit : function(L){
30855 if(L === undefined){
30856 L = !this.sourceEditMode;
30859 this.sourceEditMode = L === true;
30860 var M = this.tb.items.get(this.editor.frameId +'-sourceedit');
30862 if(M.pressed !== this.editor.sourceEditMode){
30863 M.toggle(this.editor.sourceEditMode);
30867 if(this.sourceEditMode){
30868 this.tb.items.each(function(N){
30869 if(N.cmd != 'sourceedit'){
30875 if(this.initialized){
30876 this.tb.items.each(function(O){
30884 this.editor.toggleSourceEdit(L);
30891 title: 'Bold (Ctrl+B)',
30892 text: 'Make the selected text bold.',
30893 cls: 'x-html-editor-tip'
30896 title: 'Italic (Ctrl+I)',
30897 text: 'Make the selected text italic.',
30898 cls: 'x-html-editor-tip'
30901 title: 'Underline (Ctrl+U)',
30902 text: 'Underline the selected text.',
30903 cls: 'x-html-editor-tip'
30905 increasefontsize : {
30906 title: 'Grow Text',
30907 text: 'Increase the font size.',
30908 cls: 'x-html-editor-tip'
30910 decreasefontsize : {
30911 title: 'Shrink Text',
30912 text: 'Decrease the font size.',
30913 cls: 'x-html-editor-tip'
30916 title: 'Text Highlight Color',
30917 text: 'Change the background color of the selected text.',
30918 cls: 'x-html-editor-tip'
30921 title: 'Font Color',
30922 text: 'Change the color of the selected text.',
30923 cls: 'x-html-editor-tip'
30926 title: 'Align Text Left',
30927 text: 'Align text to the left.',
30928 cls: 'x-html-editor-tip'
30931 title: 'Center Text',
30932 text: 'Center text in the editor.',
30933 cls: 'x-html-editor-tip'
30936 title: 'Align Text Right',
30937 text: 'Align text to the right.',
30938 cls: 'x-html-editor-tip'
30940 insertunorderedlist : {
30941 title: 'Bullet List',
30942 text: 'Start a bulleted list.',
30943 cls: 'x-html-editor-tip'
30945 insertorderedlist : {
30946 title: 'Numbered List',
30947 text: 'Start a numbered list.',
30948 cls: 'x-html-editor-tip'
30951 title: 'Hyperlink',
30952 text: 'Make the selected text a hyperlink.',
30953 cls: 'x-html-editor-tip'
30956 title: 'Source Edit',
30957 text: 'Switch to source editing mode.',
30958 cls: 'x-html-editor-tip'
30962 onDestroy : function(){
30965 this.tb.items.each(function(N){
30967 N.menu.removeAll();
30969 N.menu.el.destroy();
30978 onFirstFocus: function() {
30979 this.tb.items.each(function(N){
30997 Roo.form.HtmlEditor.ToolbarContext = function(A)
31000 Roo.apply(this, A);
31005 Roo.form.HtmlEditor.ToolbarContext.types = {
31017 opts : [ [""],[ "left"],[ "right"],[ "center"],[ "top"]],
31079 opts : [[""],[ "left"],[ "center"],[ "right"],[ "justify"],[ "char"]],
31084 opts : [[""],[ "top"],[ "middle"],[ "bottom"],[ "baseline"]],
31148 Roo.apply(Roo.form.HtmlEditor.ToolbarContext.prototype, {
31170 function E(id, G, H){
31171 var I = C + '-'+ id ;
31175 cls : 'x-btn-icon x-edit-'+id,
31176 enableToggle:G !== false,
31178 handler:H||B.relayBtnCmd,
31179 clickEvent:'mousedown',
31180 tooltip: D.buttonTips[id] || undefined,
31185 var F = B.wrap.createChild({
31187 }, B.wrap.dom.firstChild.nextSibling, true);
31195 var ty= Roo.form.HtmlEditor.ToolbarContext.types;
31196 this.toolbars = {};
31198 for (var i in ty) {
31199 this.toolbars[i] = this.buildToolbar(ty[i],i);
31202 this.tb = this.toolbars.BODY;
31206 this.rendered = true;
31209 B.on('editorevent', this.updateToolbar, this);
31218 updateToolbar: function(){
31220 if(!this.editor.activated){
31221 this.editor.onFirstFocus();
31226 var G = this.editor.getAllAncestors();
31229 var ty= Roo.form.HtmlEditor.ToolbarContext.types;
31230 var H = G.length ? (G[0] ? G[0] : G[1]) : this.editor.doc.body;
31231 H = H ? H : this.editor.doc.body;
31232 H = H.tagName.length ? H : this.editor.doc.body;
31233 var tn = H.tagName.toUpperCase();
31234 H = typeof(ty[tn]) != 'undefined' ? H : this.editor.doc.body;
31235 tn = H.tagName.toUpperCase();
31236 if (this.tb.name == tn) {
31242 this.tb = this.toolbars[tn];
31244 this.tb.fields.each(function(e) {
31245 e.setValue(H.getAttribute(e.name));
31247 this.tb.selectedNode = H;
31250 Roo.menu.MenuMgr.hideAll();
31257 onDestroy : function(){
31260 this.tb.items.each(function(I){
31262 I.menu.removeAll();
31264 I.menu.el.destroy();
31273 onFirstFocus: function() {
31275 this.tb.items.each(function(I){
31279 buildToolbar: function(I, nm)
31281 var J = this.editor;
31283 var K = J.wrap.createChild({
31285 }, J.wrap.dom.firstChild.nextSibling, true);
31288 var tb = new Roo.Toolbar(K);
31289 tb.add(nm+ ": ");
31292 tb.add(item.title + ": ");
31297 tb.addField( new Roo.form.ComboBox({
31298 store: new Roo.data.SimpleStore({
31304 displayField:'val',
31308 triggerAction: 'all',
31309 emptyText:'Select',
31310 selectOnFocus:true,
31311 width: item.width ? item.width : 130,
31313 'select': function(c, r, i) {
31314 tb.selectedNode.setAttribute(c.name, r.get('val'));
31325 tb.addField( new Roo.form.TextField({
31334 tb.addField( new Roo.form.TextField({
31340 'change' : function(f, nv, ov) {
31341 tb.selectedNode.setAttribute(f.name, nv);
31348 tb.el.on('click', function(e){
31349 e.preventDefault();
31351 tb.el.setVisibilityMode( Roo.Element.DISPLAY);
31375 Roo.form.BasicForm = function(el, A){
31376 this.allItems = [];
31377 this.childForms = [];
31378 Roo.apply(this, A);
31383 this.items = new Roo.util.MixedCollection(false, function(o){
31384 return o.id || (o.id = Roo.id());
31389 beforeaction: true,
31392 actionfailed : true,
31395 actioncomplete : true
31401 Roo.form.BasicForm.superclass.constructor.call(this);
31404 Roo.extend(Roo.form.BasicForm, Roo.util.Observable, {
31422 activeAction : null,
31426 trackResetOnLoad : false,
31431 childForms : false,
31439 waitMsgTarget : undefined,
31442 initEl : function(el){
31443 this.el = Roo.get(el);
31444 this.id = this.el.id || Roo.id();
31445 this.el.on('submit', this.onSubmit, this);
31446 this.el.addClass('x-form');
31450 onSubmit : function(e){
31456 isValid : function(){
31458 this.items.each(function(f){
31468 isDirty : function(){
31470 this.items.each(function(f){
31481 doAction : function(D, E){
31482 if(typeof D == 'string'){
31483 D = new Roo.form.Action.ACTION_TYPES[D](this, E);
31485 if(this.fireEvent('beforeaction', this, D) !== false){
31486 this.beforeAction(D);
31487 D.run.defer(100, D);
31494 submit : function(F){
31495 this.doAction('submit', F);
31501 load : function(G){
31502 this.doAction('load', G);
31508 updateRecord : function(H){
31511 fs.each(function(f){
31512 var I = this.findField(f.name);
31514 H.set(f.name, I.getValue());
31523 loadRecord : function(I){
31524 this.setValues(I.data);
31529 beforeAction : function(J){
31532 if(this.waitMsgTarget === true){
31533 this.el.mask(o.waitMsg, 'x-mask-loading');
31534 }else if(this.waitMsgTarget){
31535 this.waitMsgTarget = Roo.get(this.waitMsgTarget);
31536 this.waitMsgTarget.mask(o.waitMsg, 'x-mask-loading');
31538 Roo.MessageBox.wait(o.waitMsg, o.waitTitle || this.waitTitle || 'Please Wait...');
31544 afterAction : function(K, L){
31545 this.activeAction = null;
31548 if(this.waitMsgTarget === true){
31550 }else if(this.waitMsgTarget){
31551 this.waitMsgTarget.unmask();
31553 Roo.MessageBox.updateProgress(1);
31554 Roo.MessageBox.hide();
31562 Roo.callback(o.success, o.scope, [this, K]);
31563 this.fireEvent('actioncomplete', this, K);
31565 Roo.callback(o.failure, o.scope, [this, K]);
31566 this.fireEvent('actionfailed', this, K);
31572 findField : function(id){
31573 var M = this.items.get(id);
31575 this.items.each(function(f){
31576 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
31587 addForm : function(N){
31589 this.childForms.push(N);
31590 Roo.each(N.allItems, function (fe) {
31592 if (this.findField(fe.name)) {
31596 this.add( new Roo.form.Hidden({
31604 markInvalid : function(O){
31605 if(O instanceof Array){
31606 for(var i = 0, len = O.length; i < len; i++){
31607 var fieldError = O[i];
31608 var f = this.findField(fieldError.id);
31610 f.markInvalid(fieldError.msg);
31616 if(typeof O[id] != 'function' && (M = this.findField(id))){
31617 M.markInvalid(O[id]);
31622 Roo.each(this.childForms || [], function (f) {
31631 setValues : function(P){
31632 if(P instanceof Array){
31633 for(var i = 0, len = P.length; i < len; i++){
31635 var f = this.findField(v.id);
31637 f.setValue(v.value);
31638 if(this.trackResetOnLoad){
31639 f.originalValue = f.getValue();
31646 if(typeof P[id] != 'function' && (M = this.findField(id))){
31648 if (M.setFromData &&
31654 (M.store && !M.store.isLocal)
31658 sd[M.valueField] = typeof(P[M.hiddenName]) == 'undefined' ? '' : P[M.hiddenName];
31659 sd[M.displayField] = typeof(P[M.name]) == 'undefined' ? '' : P[M.name];
31667 if(this.trackResetOnLoad){
31668 M.originalValue = M.getValue();
31675 Roo.each(this.childForms || [], function (f) {
31684 getValues : function(Q){
31685 if (this.childForms) {
31687 Roo.each(this.childForms, function (f) {
31689 Roo.each(f.allFields, function (e) {
31690 if (e.name && e.getValue && this.findField(e.name)) {
31691 this.findField(e.name).setValue(e.getValue());
31700 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
31704 return Roo.urlDecode(fs);
31709 clearInvalid : function(){
31710 this.items.each(function(f){
31714 Roo.each(this.childForms || [], function (f) {
31724 reset : function(){
31725 this.items.each(function(f){
31729 Roo.each(this.childForms || [], function (f) {
31740 this.items.addAll(Array.prototype.slice.call(arguments, 0));
31747 remove : function(R){
31748 this.items.remove(R);
31754 render : function(){
31755 this.items.each(function(f){
31756 if(f.isFormField && !f.rendered && document.getElementById(f.id)){
31765 applyToFields : function(o){
31766 this.items.each(function(f){
31774 applyIfToFields : function(o){
31775 this.items.each(function(f){
31783 Roo.BasicForm = Roo.form.BasicForm;
31789 Roo.form.Form = function(A){
31798 Roo.form.Form.superclass.constructor.call(this, null, A);
31799 this.url = this.url || this.action;
31801 this.root = new Roo.form.Layout(Roo.applyIf({
31806 this.active = this.root;
31810 this.allItems = [];
31814 clientvalidation: true,
31820 Roo.each(B, this.addxtype, this);
31826 Roo.extend(Roo.form.Form, Roo.form.BasicForm, {
31833 buttonAlign:'center',
31845 monitorValid : false,
31854 column : function(c){
31855 var C = new Roo.form.Column(c);
31857 if(arguments.length > 1){
31858 this.add.apply(this, Array.prototype.slice.call(arguments, 1));
31866 fieldset : function(c){
31867 var fs = new Roo.form.FieldSet(c);
31869 if(arguments.length > 1){
31870 this.add.apply(this, Array.prototype.slice.call(arguments, 1));
31878 container : function(c){
31879 var l = new Roo.form.Layout(c);
31881 if(arguments.length > 1){
31882 this.add.apply(this, Array.prototype.slice.call(arguments, 1));
31890 start : function(c){
31892 Roo.applyIf(c, {'labelAlign': this.active.labelAlign, 'labelWidth': this.active.labelWidth, 'itemCls': this.active.itemCls});
31893 this.active.stack.push(c);
31894 c.ownerCt = this.active;
31902 if(this.active == this.root){
31906 this.active = this.active.ownerCt;
31913 this.active.stack.push.apply(this.active.stack, arguments);
31914 this.allItems.push.apply(this.allItems,arguments);
31916 for(var i = 0, a = arguments, len = a.length; i < len; i++) {
31917 if(a[i].isFormField){
31922 Roo.form.Form.superclass.add.apply(this, r);
31933 findbyId : function(id)
31940 Ext.each(this.allItems, function(f){
31941 if (f.id == id || f.name == id ){
31953 render : function(ct){
31955 var o = this.autoCreate || {
31957 method : this.method || 'POST',
31958 id : this.id || Roo.id()
31960 this.initEl(ct.createChild(o));
31962 this.root.render(this.el);
31964 this.items.each(function(f){
31965 f.render('x-form-el-'+f.id);
31968 if(this.buttons.length > 0){
31970 var tb = this.el.createChild({cls:'x-form-btns-ct', cn: {
31971 cls:"x-form-btns x-form-btns-"+this.buttonAlign,
31972 html:'<table cellspacing="0"><tbody><tr></tr></tbody></table><div class="x-clear"></div>'
31974 var tr = tb.getElementsByTagName('tr')[0];
31975 for(var i = 0, len = this.buttons.length; i < len; i++) {
31976 var b = this.buttons[i];
31977 var td = document.createElement('td');
31978 td.className = 'x-form-btn-td';
31979 b.render(tr.appendChild(td));
31982 if(this.monitorValid){
31983 this.startMonitoring();
31986 this.fireEvent('rendered', this);
31992 addButton : function(E, F, G){
31996 minWidth: this.minButtonWidth,
31999 if(typeof E == "string"){
32004 var H = new Roo.Button(null, bc);
32005 this.buttons.push(H);
32012 addxtype : function()
32014 var ar = Array.prototype.slice.call(arguments, 0);
32016 for(var i = 0; i < ar.length; i++) {
32023 if (Roo.form[ar[i].xtype]) {
32025 var fe = Roo.factory(ar[i], Roo.form);
32032 fe.store.form = this;
32037 this.allItems.push(fe);
32038 if (fe.items && fe.addxtype) {
32039 fe.addxtype.apply(fe, fe.items);
32053 if (ar[i].xtype == 'Button') {
32056 this.addButton(ar[i]);
32057 this.allItems.push(fe);
32061 if (ar[i].xtype == 'end') {
32062 alert('end is not supported on xtype any more, use items');
32073 startMonitoring : function(){
32076 Roo.TaskMgr.start({
32077 run : this.bindHandler,
32078 interval : this.monitorPoll || 200,
32086 stopMonitoring : function(){
32087 this.bound = false;
32091 bindHandler : function(){
32096 this.items.each(function(f){
32097 if(!f.isValid(true)){
32102 for(var i = 0, len = this.buttons.length; i < len; i++){
32103 var H = this.buttons[i];
32104 if(H.formBind === true && H.disabled === J){
32109 this.fireEvent('clientvalidation', this, J);
32123 Roo.Form = Roo.form.Form;
32133 Roo.form.Action = function(A, B){
32135 this.options = B || {};
32139 Roo.form.Action.CLIENT_INVALID = 'client';
32142 Roo.form.Action.SERVER_INVALID = 'server';
32145 Roo.form.Action.CONNECT_FAILURE = 'connect';
32148 Roo.form.Action.LOAD_FAILURE = 'load';
32150 Roo.form.Action.prototype = {
32152 failureType : undefined,
32153 response : undefined,
32154 result : undefined,
32162 success : function(D){
32167 handleResponse : function(E){
32172 failure : function(F){
32174 this.failureType = Roo.form.Action.CONNECT_FAILURE;
32175 this.form.afterAction(this, false);
32178 processResponse : function(G){
32180 if(!G.responseText){
32184 this.result = this.handleResponse(G);
32185 return this.result;
32189 getUrl : function(H){
32190 var I = this.options.url || this.form.url || this.form.el.dom.action;
32192 var p = this.getParams();
32194 I += (I.indexOf('?') != -1 ? '&' : '?') + p;
32200 getMethod : function(){
32201 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
32204 getParams : function(){
32205 var bp = this.form.baseParams;
32206 var p = this.options.params;
32208 if(typeof p == "object"){
32209 p = Roo.urlEncode(Roo.applyIf(p, bp));
32210 }else if(typeof p == 'string' && bp){
32211 p += '&' + Roo.urlEncode(bp);
32214 p = Roo.urlEncode(bp);
32219 createCallback : function(){
32221 success: this.success,
32222 failure: this.failure,
32224 timeout: (this.form.timeout*1000),
32225 upload: this.form.fileUpload ? this.success : undefined
32230 Roo.form.Action.Submit = function(J, K){
32231 Roo.form.Action.Submit.superclass.constructor.call(this, J, K);
32234 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
32238 var o = this.options;
32239 var L = this.getMethod();
32240 var M = L == 'POST';
32241 if(o.clientValidation === false || this.form.isValid()){
32242 Roo.Ajax.request(Roo.apply(this.createCallback(), {
32243 form:this.form.el.dom,
32244 url:this.getUrl(!M),
32246 params:M ? this.getParams() : null,
32247 isUpload: this.form.fileUpload
32250 }else if (o.clientValidation !== false){
32251 this.failureType = Roo.form.Action.CLIENT_INVALID;
32252 this.form.afterAction(this, false);
32256 success : function(N){
32257 var O = this.processResponse(N);
32258 if(O === true || O.success){
32259 this.form.afterAction(this, true);
32263 this.form.markInvalid(O.errors);
32264 this.failureType = Roo.form.Action.SERVER_INVALID;
32267 this.form.afterAction(this, false);
32270 handleResponse : function(P){
32271 if(this.form.errorReader){
32272 var rs = this.form.errorReader.read(P);
32275 for(var i = 0, len = rs.records.length; i < len; i++) {
32276 var r = rs.records[i];
32277 errors[i] = r.data;
32280 if(errors.length < 1){
32284 success : rs.success,
32290 Q = Roo.decode(P.responseText);
32294 errorMsg: "Failed to read server message: " + response.responseText,
32304 Roo.form.Action.Load = function(R, S){
32305 Roo.form.Action.Load.superclass.constructor.call(this, R, S);
32306 this.reader = this.form.reader;
32309 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
32313 Roo.Ajax.request(Roo.apply(
32314 this.createCallback(), {
32315 method:this.getMethod(),
32316 url:this.getUrl(false),
32317 params:this.getParams()
32321 success : function(T){
32322 var U = this.processResponse(T);
32323 if(U === true || !U.success || !U.data){
32324 this.failureType = Roo.form.Action.LOAD_FAILURE;
32325 this.form.afterAction(this, false);
32329 this.form.clearInvalid();
32330 this.form.setValues(U.data);
32331 this.form.afterAction(this, true);
32334 handleResponse : function(V){
32335 if(this.form.reader){
32336 var rs = this.form.reader.read(V);
32337 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
32339 success : rs.success,
32343 return Roo.decode(V.responseText);
32347 Roo.form.Action.ACTION_TYPES = {
32348 'load' : Roo.form.Action.Load,
32349 'submit' : Roo.form.Action.Submit
32356 Roo.form.Layout = function(A){
32363 Roo.form.Layout.superclass.constructor.call(this, A);
32365 Roo.each(B, this.addxtype, this);
32369 Roo.extend(Roo.form.Layout, Roo.Component, {
32383 labelSeparator : ':',
32386 hideLabels : false,
32389 defaultAutoCreate : {tag: 'div', cls: 'x-form-ct'},
32394 onRender : function(ct, C){
32396 this.el = Roo.get(this.el);
32398 var cfg = this.getAutoCreate();
32399 this.el = ct.createChild(cfg, C);
32402 this.el.applyStyles(this.style);
32404 if(this.labelAlign){
32405 this.el.addClass('x-form-label-'+this.labelAlign);
32407 if(this.hideLabels){
32408 this.labelStyle = "display:none";
32409 this.elementStyle = "padding-left:0;";
32411 if(typeof this.labelWidth == 'number'){
32412 this.labelStyle = "width:"+this.labelWidth+"px;";
32413 this.elementStyle = "padding-left:"+((this.labelWidth+(typeof this.labelPad == 'number' ? this.labelPad : 5))+'px')+";";
32415 if(this.labelAlign == 'top'){
32416 this.labelStyle = "width:auto;";
32417 this.elementStyle = "padding-left:0;";
32420 var D = this.stack;
32423 if(!this.fieldTpl){
32424 var t = new Roo.Template(
32425 '<div class="x-form-item {5}">',
32426 '<label for="{0}" style="{2}">{1}{4}</label>',
32427 '<div class="x-form-element" id="x-form-el-{0}" style="{3}">',
32429 '</div><div class="x-form-clear-left"></div>'
32431 t.disableFormats = true;
32433 Roo.form.Layout.prototype.fieldTpl = t;
32435 for(var i = 0; i < E; i++) {
32436 if(D[i].isFormField){
32437 this.renderField(D[i]);
32439 this.renderComponent(D[i]);
32444 this.el.createChild({cls:'x-form-clear'});
32449 renderField : function(f){
32450 f.fieldEl = Roo.get(this.fieldTpl.append(this.el, [
32453 f.labelStyle||this.labelStyle||'',
32454 this.elementStyle||'',
32455 typeof f.labelSeparator == 'undefined' ? this.labelSeparator : f.labelSeparator,
32456 f.itemCls||this.itemCls||''
32457 ], true).getPrevSibling());
32461 renderComponent : function(c){
32462 c.render(c.isLayout ? this.el : this.el.createChild());
32466 addxtype : function(o)
32469 o.form = this.form;
32470 var fe = Roo.factory(o, Roo.form);
32471 this.form.allItems.push(fe);
32472 this.stack.push(fe);
32474 if (fe.isFormField) {
32475 this.form.items.add(fe);
32484 Roo.form.Column = function(F){
32485 Roo.form.Column.superclass.constructor.call(this, F);
32488 Roo.extend(Roo.form.Column, Roo.form.Layout, {
32495 defaultAutoCreate : {tag: 'div', cls: 'x-form-ct x-form-column'},
32498 onRender : function(ct, G){
32499 Roo.form.Column.superclass.onRender.call(this, ct, G);
32501 this.el.setWidth(this.width);
32511 Roo.form.Row = function(H){
32512 Roo.form.Row.superclass.constructor.call(this, H);
32515 Roo.extend(Roo.form.Row, Roo.form.Layout, {
32520 defaultAutoCreate : {tag: 'div', cls: 'x-form-ct x-form-row'},
32524 onRender : function(ct, I){
32527 var t = new Roo.Template(
32528 '<div class="x-form-item {5}" style="float:left;width:{6}px">',
32529 '<label for="{0}" style="{2}">{1}{4}</label>',
32530 '<div class="x-form-element" id="x-form-el-{0}" style="{3}">',
32534 t.disableFormats = true;
32536 Roo.form.Layout.prototype.rowTpl = t;
32539 this.fieldTpl = this.rowTpl;
32544 if ((this.labelAlign != 'top')) {
32545 if (typeof this.labelWidth == 'number') {
32546 J = this.labelWidth
32549 this.padWidth = 20 + J;
32554 Roo.form.Column.superclass.onRender.call(this, ct, I);
32556 this.el.setWidth(this.width);
32559 this.el.setHeight(this.height);
32564 renderField : function(f){
32565 f.fieldEl = this.fieldTpl.append(this.el, [
32566 f.id, f.fieldLabel,
32567 f.labelStyle||this.labelStyle||'',
32568 this.elementStyle||'',
32569 typeof f.labelSeparator == 'undefined' ? this.labelSeparator : f.labelSeparator,
32570 f.itemCls||this.itemCls||'',
32571 f.width ? f.width + this.padWidth : 160 + this.padWidth
32579 Roo.form.FieldSet = function(K){
32580 Roo.form.FieldSet.superclass.constructor.call(this, K);
32583 Roo.extend(Roo.form.FieldSet, Roo.form.Layout, {
32590 defaultAutoCreate : {tag: 'fieldset', cn: {tag:'legend'}},
32593 onRender : function(ct, L){
32594 Roo.form.FieldSet.superclass.onRender.call(this, ct, L);
32596 this.setLegend(this.legend);
32601 setLegend : function(M){
32603 this.el.child('legend').update(M);
32611 Roo.form.VTypes = function(){
32613 var A = /^[a-zA-Z_]+$/;
32614 var B = /^[a-zA-Z0-9_]+$/;
32615 var C = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,4}$/;
32616 var D = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
32622 'email' : function(v){
32627 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
32630 'emailMask' : /[a-z0-9_\.\-@]/i,
32634 'url' : function(v){
32639 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
32643 'alpha' : function(v){
32648 'alphaText' : 'This field should only contain letters and _',
32651 'alphaMask' : /[a-z_]/i,
32655 'alphanum' : function(v){
32660 'alphanumText' : 'This field should only contain letters, numbers and _',
32663 'alphanumMask' : /[a-z0-9_]/i
32670 Roo.form.FCKeditor = function(A){
32671 Roo.form.FCKeditor.superclass.constructor.call(this, A);
32680 Roo.form.FCKeditor.editors = { };
32681 Roo.extend(Roo.form.FCKeditor, Roo.form.TextArea,
32693 toolbarSet : 'Basic',
32696 basePath : '/fckeditor/',
32704 onRender : function(ct, B)
32707 this.defaultAutoCreate = {
32709 style:"width:300px;height:60px;",
32710 autocomplete: "off"
32714 Roo.form.FCKeditor.superclass.onRender.call(this, ct, B);
32718 Roo.form.FCKeditor.editors[this.getId()] = this;
32721 this.replaceTextarea() ;
32725 getEditor : function() {
32726 return this.fckEditor;
32732 setValue : function(C)
32736 if(typeof(C) == 'undefined') {
32740 Roo.form.FCKeditor.superclass.setValue.apply(this,[C]);
32748 if(!this.getEditor()) {
32753 this.getEditor().SetData(C);
32761 getValue : function()
32764 if (this.frame && this.frame.dom.style.display == 'none') {
32765 return Roo.form.FCKeditor.superclass.getValue.call(this);
32768 if(!this.el || !this.getEditor()) {
32775 var D=this.getEditor().GetData();
32776 Roo.form.FCKeditor.superclass.setValue.apply(this,[D]);
32777 return Roo.form.FCKeditor.superclass.getValue.call(this);
32784 getRawValue : function()
32786 if (this.frame && this.frame.dom.style.display == 'none') {
32787 return Roo.form.FCKeditor.superclass.getRawValue.call(this);
32790 if(!this.el || !this.getEditor()) {
32798 var E=this.getEditor().GetData();
32799 Roo.form.FCKeditor.superclass.setRawValue.apply(this,[E]);
32800 return Roo.form.FCKeditor.superclass.getRawValue.call(this);
32804 setSize : function(w,h) {
32819 Roo.form.FCKeditor.superclass.setSize.apply(this, [w, h]);
32821 this.frame.dom.setAttribute('width', w);
32822 this.frame.dom.setAttribute('height', h);
32823 this.frame.setSize(w,h);
32827 toggleSourceEdit : function(F) {
32831 this.el.dom.style.display = F ? '' : 'none';
32832 this.frame.dom.style.display = F ? 'none' : '';
32839 if (this.frame.dom.style.display == 'none') {
32840 return Roo.form.FCKeditor.superclass.focus.call(this);
32842 if(!this.el || !this.getEditor()) {
32843 this.focus.defer(100,this, [G]);
32850 var H = this.getEditor().EditorDocument.getElementsByTagName(G);
32851 this.getEditor().Focus();
32853 if (!this.getEditor().Selection.GetSelection()) {
32854 this.focus.defer(100,this, [G]);
32859 var r = this.getEditor().EditorDocument.createRange();
32860 r.setStart(H[0],0);
32862 this.getEditor().Selection.GetSelection().removeAllRanges();
32863 this.getEditor().Selection.GetSelection().addRange(r);
32864 this.getEditor().Focus();
32871 replaceTextarea : function()
32873 if ( document.getElementById( this.getId() + '___Frame' ) )
32878 var I = document.getElementById( this.getId() );
32880 var J = document.getElementsByName( this.getId() ) ;
32882 I.style.display = 'none' ;
32884 if ( I.tabIndex ) {
32885 this.TabIndex = I.tabIndex ;
32889 this._insertHtmlBefore( this._getConfigHtml(), I ) ;
32890 this._insertHtmlBefore( this._getIFrameHtml(), I ) ;
32891 this.frame = Roo.get(this.getId() + '___Frame')
32894 _getConfigHtml : function()
32898 for ( var o in this.fckconfig ) {
32899 K += K.length > 0 ? '&' : '';
32900 K += encodeURIComponent( o ) + '=' + encodeURIComponent( this.fckconfig[o] ) ;
32903 return '<input type="hidden" id="' + this.getId() + '___Config" value="' + K + '" style="display:none" />' ;
32907 _getIFrameHtml : function()
32909 var L = 'fckeditor.html' ;
32913 var M = this.basePath + 'editor/' + L + '?InstanceName=' + encodeURIComponent( this.getId() ) ;
32914 M += this.toolbarSet ? ( '&Toolbar=' + this.toolbarSet) : '';
32917 var N = '<iframe id="' + this.getId() +
32918 '___Frame" src="' + M +
32919 '" width="' + this.width +
32920 '" height="' + this.height + '"' +
32921 (this.tabIndex ? ' tabindex="' + this.tabIndex + '"' :'' ) +
32922 ' frameborder="0" scrolling="no"></iframe>' ;
32927 _insertHtmlBefore : function( O, P )
32929 if ( P.insertAdjacentHTML ) {
32931 P.insertAdjacentHTML( 'beforeBegin', O ) ;
32933 var oRange = document.createRange() ;
32934 oRange.setStartBefore( P ) ;
32935 var oFragment = oRange.createContextualFragment( O );
32936 P.parentNode.insertBefore( oFragment, P ) ;
32952 var f = Roo.form.FCKeditor.editors[R.Name];
32955 f.fireEvent('editorinit', f, R);
32979 Roo.form.GridField = function(A){
32980 Roo.form.GridField.superclass.constructor.call(this, A);
32984 Roo.extend(Roo.form.GridField, Roo.form.Field, {
32997 defaultAutoCreate : { tag: 'input', type: 'hidden', autocomplete: 'off'},
33002 onResize : function(){
33003 Roo.form.Field.superclass.onResize.apply(this, arguments);
33006 initEvents : function(){
33013 getResizeEl : function(){
33017 getPositionEl : function(){
33022 onRender : function(ct, B){
33024 this.style = this.style || 'overflow: hidden; border:1px solid #c3daf9;';
33025 var C = this.style;
33028 Roo.form.DisplayImage.superclass.onRender.call(this, ct, B);
33029 this.wrap = this.el.wrap({cls: ''});
33030 this.viewEl = this.wrap.createChild({ tag: 'div' });
33032 this.viewEl.applyStyles(C);
33035 this.viewEl.setWidth(this.width);
33038 this.viewEl.setHeight(this.height);
33045 this.grid = new Roo.grid[this.xgrid.xtype](this.viewEl, this.xgrid);
33048 this.grid.render();
33049 this.grid.getDataSource().on('remove', this.refreshValue, this);
33050 this.grid.getDataSource().on('update', this.refreshValue, this);
33051 this.grid.on('afteredit', this.refreshValue, this);
33058 setValue : function(v){
33062 if (this.grid && this.grid.getDataSource() && typeof(v) != 'undefined') {
33063 var ds = this.grid.getDataSource();
33067 data[ds.reader.meta.root ] = typeof(v) == 'string' ? Roo.decode(v) : v;
33068 ds.loadData( data);
33071 Roo.form.GridField.superclass.setValue.call(this, v);
33072 this.refreshValue();
33077 refreshValue: function() {
33079 this.grid.getDataSource().each(function(r) {
33082 this.el.dom.value = Roo.encode(D);
33095 Roo.DDView = function(A, B, C) {
33096 Roo.DDView.superclass.constructor.apply(this, arguments);
33097 this.getEl().setStyle("outline", "0px none");
33098 this.getEl().unselectable();
33099 if (this.dragGroup) {
33100 this.setDraggable(this.dragGroup.split(","));
33102 if (this.dropGroup) {
33103 this.setDroppable(this.dropGroup.split(","));
33105 if (this.deletable) {
33106 this.setDeletable();
33109 this.isDirtyFlag = false;
33115 Roo.extend(Roo.DDView, Roo.View, {
33127 reset: Roo.emptyFn,
33129 clearInvalid: Roo.form.Field.prototype.clearInvalid,
33131 validate: function() {
33135 destroy: function() {
33136 this.purgeListeners();
33137 this.getEl.removeAllListeners();
33138 this.getEl().remove();
33139 if (this.dragZone) {
33140 if (this.dragZone.destroy) {
33141 this.dragZone.destroy();
33144 if (this.dropZone) {
33145 if (this.dropZone.destroy) {
33146 this.dropZone.destroy();
33153 getName: function() {
33159 setValue: function(v) {
33161 throw "DDView.setValue(). DDView must be constructed with a valid Store";
33164 D[this.store.reader.meta.root] = v ? [].concat(v) : [];
33165 this.store.proxy = new Roo.data.MemoryProxy(D);
33171 getValue: function() {
33173 this.store.each(function(F) {
33176 return E.substr(0, E.length - 1) + ')';
33179 getIds: function() {
33180 var i = 0, F = new Array(this.store.getCount());
33181 this.store.each(function(G) {
33187 isDirty: function() {
33188 return this.isDirtyFlag;
33193 getTargetFromEvent : function(e) {
33194 var G = e.getTarget();
33195 while ((G !== null) && (G.parentNode != this.el.dom)) {
33199 G = this.el.dom.lastChild || this.el.dom;
33206 getDragData : function(e) {
33207 var H = this.findItemFromChild(e.getTarget());
33209 this.handleSelection(e);
33210 var selNodes = this.getSelectedNodes();
33213 copy: this.copy || (this.allowCopy && e.ctrlKey),
33217 var selectedIndices = this.getSelectedIndexes();
33218 for (var i = 0; i < selectedIndices.length; i++) {
33219 dragData.records.push(this.store.getAt(selectedIndices[i]));
33221 if (selNodes.length == 1) {
33222 dragData.ddel = H.cloneNode(true);
33224 var div = document.createElement('div');
33225 div.className = 'multi-proxy';
33226 for (var i = 0, len = selNodes.length; i < len; i++) {
33227 div.appendChild(selNodes[i].cloneNode(true));
33230 dragData.ddel = div;
33242 setDraggable: function(I) {
33243 if (I instanceof Array) {
33244 Roo.each(I, this.setDraggable, this);
33247 if (this.dragZone) {
33248 this.dragZone.addToGroup(I);
33250 this.dragZone = new Roo.dd.DragZone(this.getEl(), {
33251 containerScroll: true,
33256 if (!this.multiSelect) { this.singleSelect = true; }
33260 this.dragZone.getDragData = this.getDragData.createDelegate(this);
33266 setDroppable: function(J) {
33267 if (J instanceof Array) {
33268 Roo.each(J, this.setDroppable, this);
33271 if (this.dropZone) {
33272 this.dropZone.addToGroup(J);
33274 this.dropZone = new Roo.dd.DropZone(this.getEl(), {
33275 containerScroll: true,
33280 this.dropZone.getTargetFromEvent = this.getTargetFromEvent.createDelegate(this);
33281 this.dropZone.onNodeEnter = this.onNodeEnter.createDelegate(this);
33282 this.dropZone.onNodeOver = this.onNodeOver.createDelegate(this);
33283 this.dropZone.onNodeOut = this.onNodeOut.createDelegate(this);
33284 this.dropZone.onNodeDrop = this.onNodeDrop.createDelegate(this);
33290 getDropPoint : function(e, n, dd){
33291 if (n == this.el.dom) { return "above"; }
33292 var t = Roo.lib.Dom.getY(n), b = t + n.offsetHeight;
33293 var c = t + (b - t) / 2;
33294 var y = Roo.lib.Event.getPageY(e);
33302 onNodeEnter : function(n, dd, e, K){
33306 onNodeOver : function(n, dd, e, L){
33307 var pt = this.getDropPoint(e, n, dd);
33309 var M = this.dropNotAllowed;
33312 if (pt == "above"){
33313 M = n.previousSibling ? "x-tree-drop-ok-between" : "x-tree-drop-ok-above";
33314 targetElClass = "x-view-drag-insert-above";
33316 M = n.nextSibling ? "x-tree-drop-ok-between" : "x-tree-drop-ok-below";
33317 targetElClass = "x-view-drag-insert-below";
33319 if (this.lastInsertClass != targetElClass){
33320 Roo.fly(n).replaceClass(this.lastInsertClass, targetElClass);
33321 this.lastInsertClass = targetElClass;
33327 onNodeOut : function(n, dd, e, N){
33328 this.removeDropIndicators(n);
33331 onNodeDrop : function(n, dd, e, O){
33332 if (this.fireEvent("drop", this, n, dd, e, O) === false) {
33335 var pt = this.getDropPoint(e, n, dd);
33336 var P = (n == this.el.dom) ? this.nodes.length : n.nodeIndex;
33337 if (pt == "below") { P++; }
33338 for (var i = 0; i < O.records.length; i++) {
33339 var r = O.records[i];
33340 var dup = this.store.getById(r.id);
33341 if (dup && (dd != this.dragZone)) {
33342 Roo.fly(this.getNode(this.store.indexOf(dup))).frame("red", 1);
33345 this.store.insert(P++, r.copy());
33347 O.source.isDirtyFlag = true;
33349 this.store.insert(P++, r);
33352 this.isDirtyFlag = true;
33356 this.dragZone.cachedTarget = null;
33360 removeDropIndicators : function(n){
33362 Roo.fly(n).removeClass([
33363 "x-view-drag-insert-above",
33364 "x-view-drag-insert-below"]);
33365 this.lastInsertClass = "_noclass";
33371 setDeletable: function(Q) {
33372 if (!this.singleSelect && !this.multiSelect) {
33373 this.singleSelect = true;
33375 var c = this.getContextMenu();
33376 this.contextMenu.on("itemclick", function(R) {
33379 this.remove(this.getSelectedIndexes());
33383 this.contextMenu.add({
33392 getContextMenu: function() {
33393 if (!this.contextMenu) {
33395 this.contextMenu = new Roo.menu.Menu({
33396 id: this.id + "-contextmenu"
33398 this.el.on("contextmenu", this.showContextMenu, this);
33400 return this.contextMenu;
33403 disableContextMenu: function() {
33404 if (this.contextMenu) {
33405 this.el.un("contextmenu", this.showContextMenu, this);
33409 showContextMenu: function(e, R) {
33410 R = this.findItemFromChild(e.getTarget());
33413 this.select(this.getNode(R), this.multiSelect && e.ctrlKey, true);
33414 this.contextMenu.showAt(e.getXY());
33420 remove: function(S) {
33422 for (var i = 0; i < S.length; i++) {
33423 var rec = this.store.getAt(S[i]);
33424 this.store.remove(rec);
33430 onDblClick : function(e){
33431 var T = this.findItemFromChild(e.getTarget());
33433 if (this.fireEvent("dblclick", this, this.indexOf(T), T, e) === false) {
33436 if (this.dragGroup) {
33437 var targets = Roo.dd.DragDropMgr.getRelated(this.dragZone, true);
33438 while (targets.indexOf(this.dropZone) > -1) {
33439 targets.remove(this.dropZone);
33441 if (targets.length == 1) {
33442 this.dragZone.cachedTarget = null;
33443 var el = Roo.get(targets[0].getEl());
33444 var box = el.getBox(true);
33445 targets[0].onNodeDrop(el.dom, {
33447 xy: [box.x, box.y + box.height - 1]
33448 }, null, this.getDragData(e));
33454 handleSelection: function(e) {
33455 this.dragZone.cachedTarget = null;
33456 var U = this.findItemFromChild(e.getTarget());
33458 this.clearSelections(true);
33461 if (U && (this.multiSelect || this.singleSelect)){
33462 if(this.multiSelect && e.shiftKey && (!e.ctrlKey) && this.lastSelection){
33463 this.select(this.getNodes(this.indexOf(this.lastSelection), U.nodeIndex), false);
33464 }else if (this.isSelected(this.getNode(U)) && e.ctrlKey){
33467 this.select(U, this.multiSelect && e.ctrlKey);
33468 this.lastSelection = U;
33473 onItemClick : function(V, W, e){
33474 if(this.fireEvent("beforeclick", this, W, V, e) === false){
33480 unselect : function(X, Y){
33481 var Z = this.getNode(X);
33482 if(Z && this.isSelected(Z)){
33483 if(this.fireEvent("beforeselect", this, Z, this.selections) !== false){
33484 Roo.fly(Z).removeClass(this.selectedClass);
33485 this.selections.remove(Z);
33487 this.fireEvent("selectionchange", this, this.selections);
33499 Roo.LayoutManager = function(A, B){
33500 Roo.LayoutManager.superclass.constructor.call(this);
33501 this.el = Roo.get(A);
33503 if(this.el.dom == document.body && Roo.isIE && !B.allowScroll){
33504 document.body.scroll = "no";
33505 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
33506 this.el.position('relative');
33509 this.id = this.el.id;
33510 this.el.addClass("x-layout-container");
33513 this.monitorWindowResize = true;
33521 "regionresized" : true,
33524 "regioncollapsed" : true,
33527 "regionexpanded" : true
33529 this.updating = false;
33530 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
33533 Roo.extend(Roo.LayoutManager, Roo.util.Observable, {
33536 isUpdating : function(){
33537 return this.updating;
33542 beginUpdate : function(){
33543 this.updating = true;
33548 endUpdate : function(C){
33549 this.updating = false;
33555 layout: function(){
33559 onRegionResized : function(D, E){
33560 this.fireEvent("regionresized", D, E);
33564 onRegionCollapsed : function(F){
33565 this.fireEvent("regioncollapsed", F);
33568 onRegionExpanded : function(G){
33569 this.fireEvent("regionexpanded", G);
33574 getViewSize : function(){
33576 if(this.el.dom != document.body){
33577 H = this.el.getSize();
33579 H = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
33582 H.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
33583 H.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
33589 getEl : function(){
33595 getRegion : function(I){
33596 return this.regions[I.toLowerCase()];
33599 onWindowResize : function(){
33600 if(this.monitorWindowResize){
33609 Roo.BorderLayout = function(A, B){
33611 Roo.BorderLayout.superclass.constructor.call(this, A, B);
33612 this.factory = B.factory || Roo.BorderLayout.RegionFactory;
33613 for(var i = 0, len = this.factory.validRegions.length; i < len; i++) {
33614 var target = this.factory.validRegions[i];
33616 this.addRegion(target, B[target]);
33621 Roo.extend(Roo.BorderLayout, Roo.LayoutManager, {
33624 addRegion : function(C, D){
33625 if(!this.regions[C]){
33626 var r = this.factory.create(C, this, D);
33627 this.bindRegion(C, r);
33629 return this.regions[C];
33633 bindRegion : function(E, r){
33634 this.regions[E] = r;
33635 r.on("visibilitychange", this.layout, this);
33636 r.on("paneladded", this.layout, this);
33637 r.on("panelremoved", this.layout, this);
33638 r.on("invalidated", this.layout, this);
33639 r.on("resized", this.onRegionResized, this);
33640 r.on("collapsed", this.onRegionCollapsed, this);
33641 r.on("expanded", this.onRegionExpanded, this);
33646 layout : function(){
33647 if(this.updating) return;
33648 var F = this.getViewSize();
33657 var rs = this.regions;
33658 var K = rs["north"];
33659 var L = rs["south"];
33660 var M = rs["west"];
33661 var N = rs["east"];
33662 var O = rs["center"];
33666 if(K && K.isVisible()){
33667 var b = K.getBox();
33668 var m = K.getMargins();
33669 b.width = w - (m.left+m.right);
33672 I = b.height + b.y + m.bottom;
33674 K.updateBox(this.safeBox(b));
33676 if(L && L.isVisible()){
33677 var b = L.getBox();
33678 var m = L.getMargins();
33679 b.width = w - (m.left+m.right);
33681 var totalHeight = (b.height + m.top + m.bottom);
33682 b.y = h - totalHeight + m.top;
33684 L.updateBox(this.safeBox(b));
33686 if(M && M.isVisible()){
33687 var b = M.getBox();
33688 var m = M.getMargins();
33689 b.height = H - (m.top+m.bottom);
33692 var totalWidth = (b.width + m.left + m.right);
33695 M.updateBox(this.safeBox(b));
33697 if(N && N.isVisible()){
33698 var b = N.getBox();
33699 var m = N.getMargins();
33700 b.height = H - (m.top+m.bottom);
33701 var totalWidth = (b.width + m.left + m.right);
33702 b.x = w - totalWidth + m.left;
33705 N.updateBox(this.safeBox(b));
33708 var m = O.getMargins();
33712 width: G - (m.left+m.right),
33713 height: H - (m.top+m.bottom)
33718 O.updateBox(this.safeBox(centerBox));
33722 this.fireEvent("layout", this);
33726 safeBox : function(P){
33727 P.width = Math.max(0, P.width);
33728 P.height = Math.max(0, P.height);
33734 add : function(Q, R){
33736 Q = Q.toLowerCase();
33737 return this.regions[Q].add(R);
33742 remove : function(S, T){
33743 S = S.toLowerCase();
33744 return this.regions[S].remove(T);
33749 findPanel : function(U){
33750 var rs = this.regions;
33752 if(typeof rs[S] != "function"){
33753 var p = rs[S].getPanel(U);
33764 showPanel : function(V) {
33765 var rs = this.regions;
33768 if(typeof r != "function"){
33770 return r.showPanel(V);
33779 restoreState : function(W){
33781 W = Roo.state.Manager;
33783 var sm = new Roo.LayoutStateManager();
33789 batchAdd : function(X){
33790 this.beginUpdate();
33791 for(var rname in X){
33792 var lr = this.regions[rname];
33794 this.addTypedPanels(lr, X[rname]);
33802 addTypedPanels : function(lr, ps){
33803 if(typeof ps == 'string'){
33804 lr.add(new Roo.ContentPanel(ps));
33806 else if(ps instanceof Array){
33807 for(var i =0, len = ps.length; i < len; i++){
33808 this.addTypedPanels(lr, ps[i]);
33811 else if(!ps.events){
33814 lr.add(new Roo.ContentPanel(el || Roo.id(), ps));
33822 addxtype : function(Y)
33828 if (!Y.xtype.match(/Panel$/)) {
33845 case 'ContentPanel':
33847 Z = new Roo[Y.xtype](Y);
33849 var el = this.el.createChild();
33850 Z = new Roo[Y.xtype](el, Y);
33859 Y.el = this.el.createChild();
33860 Z = new Roo[Y.xtype](Y);
33864 case 'NestedLayoutPanel':
33866 var el = this.el.createChild();
33867 var clayout = Y.layout;
33869 clayout.items = clayout.items || [];
33874 if (a == 'center' && this.active && this.getRegion('center').panels.length < 1) {
33875 Y.background = false;
33877 var layout = new Roo.BorderLayout(el, clayout);
33879 Z = new Roo[Y.xtype](layout, Y);
33890 var el = this.el.createChild();
33893 var grid = new Roo.grid[Y.grid.xtype](el, Y.grid);
33895 if (a == 'center' && this.active ) {
33896 Y.background = false;
33899 Z = new Roo[Y.xtype](grid, Y);
33902 if (Y.background) {
33903 Z.on('activate', function(gp) {
33904 if (!gp.grid.rendered) {
33917 alert("Can not add '" + Y.xtype + "' to BorderLayout");
33923 this.beginUpdate();
33925 Roo.each(c, function(i) {
33936 Roo.BorderLayout.create = function(d, e){
33937 var f = new Roo.BorderLayout(e || document.body, d);
33939 var g = Roo.BorderLayout.RegionFactory.validRegions;
33940 for(var j = 0, jlen = g.length; j < jlen; j++){
33942 if(f.regions[lr] && d[lr].panels){
33943 var r = f.regions[lr];
33944 var ps = d[lr].panels;
33945 f.addTypedPanels(r, ps);
33954 Roo.BorderLayout.RegionFactory = {
33956 validRegions : ["north","south","east","west","center"],
33959 create : function(k, l, n){
33960 k = k.toLowerCase();
33961 if(n.lightweight || n.basic){
33962 return new Roo.BasicLayoutRegion(l, n, k);
33966 return new Roo.NorthLayoutRegion(l, n);
33968 return new Roo.SouthLayoutRegion(l, n);
33970 return new Roo.EastLayoutRegion(l, n);
33972 return new Roo.WestLayoutRegion(l, n);
33974 return new Roo.CenterLayoutRegion(l, n);
33976 throw 'Layout region "'+k+'" not supported.';
33984 Roo.BasicLayoutRegion = function(A, B, C, D){
33993 "beforeremove" : true,
33996 "invalidated" : true,
33999 "visibilitychange" : true,
34002 "paneladded" : true,
34005 "panelremoved" : true,
34008 "collapsed" : true,
34014 "slideshow" : true,
34017 "slidehide" : true,
34020 "panelactivated" : true,
34027 this.panels = new Roo.util.MixedCollection();
34028 this.panels.getKey = this.getPanelId.createDelegate(this);
34030 this.activePanel = null;
34033 if (B.listeners || B.events) {
34034 Roo.BasicLayoutRegion.superclass.constructor.call(this, {
34035 listeners : B.listeners || {},
34036 events : B.events || {}
34041 this.applyConfig(B);
34045 Roo.extend(Roo.BasicLayoutRegion, Roo.util.Observable, {
34046 getPanelId : function(p){
34050 applyConfig : function(E){
34051 this.margins = E.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
34058 resizeTo : function(F){
34059 var el = this.el ? this.el :
34060 (this.activePanel ? this.activePanel.getEl() : null);
34062 switch(this.position){
34066 this.fireEvent("resized", this, F);
34071 this.fireEvent("resized", this, F);
34077 getBox : function(){
34078 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
34081 getMargins : function(){
34082 return this.margins;
34085 updateBox : function(G){
34087 var el = this.activePanel.getEl();
34088 el.dom.style.left = G.x + "px";
34089 el.dom.style.top = G.y + "px";
34090 this.activePanel.setSize(G.width, G.height);
34095 getEl : function(){
34096 return this.activePanel;
34101 isVisible : function(){
34102 return this.activePanel ? true : false;
34105 setActivePanel : function(H){
34106 H = this.getPanel(H);
34107 if(this.activePanel && this.activePanel != H){
34108 this.activePanel.setActiveState(false);
34109 this.activePanel.getEl().setLeftTop(-10000,-10000);
34112 this.activePanel = H;
34113 H.setActiveState(true);
34115 H.setSize(this.box.width, this.box.height);
34118 this.fireEvent("panelactivated", this, H);
34119 this.fireEvent("invalidated");
34124 showPanel : function(I){
34125 if(I = this.getPanel(I)){
34126 this.setActivePanel(I);
34133 getActivePanel : function(){
34134 return this.activePanel;
34140 if(arguments.length > 1){
34141 for(var i = 0, len = arguments.length; i < len; i++) {
34142 this.add(arguments[i]);
34146 if(this.hasPanel(J)){
34150 var el = J.getEl();
34151 if(el.dom.parentNode != this.mgr.el.dom){
34152 this.mgr.el.dom.appendChild(el.dom);
34158 this.panels.add(J);
34159 el.setStyle("position", "absolute");
34161 this.setActivePanel(J);
34162 if(this.config.initialSize && this.panels.getCount()==1){
34163 this.resizeTo(this.config.initialSize);
34167 this.fireEvent("paneladded", this, J);
34173 hasPanel : function(K){
34174 if(typeof K == "object"){
34177 return this.getPanel(K) ? true : false;
34182 remove : function(L, M){
34183 L = this.getPanel(L);
34188 this.fireEvent("beforeremove", this, L, e);
34189 if(e.cancel === true){
34193 this.panels.removeKey(N);
34199 getPanel : function(id){
34200 if(typeof id == "object"){
34203 return this.panels.get(id);
34208 getPosition: function(){
34209 return this.position;
34217 Roo.LayoutRegion = function(A, B, C){
34218 Roo.LayoutRegion.superclass.constructor.call(this, A, B, C, true);
34219 var dh = Roo.DomHelper;
34222 this.el = dh.append(A.el.dom, {tag: "div", cls: "x-layout-panel x-layout-panel-" + this.position}, true);
34226 this.titleEl = dh.append(this.el.dom, {tag: "div", unselectable: "on", cls: "x-unselectable x-layout-panel-hd x-layout-title-"+this.position, children:[
34227 {tag: "span", cls: "x-unselectable x-layout-panel-hd-text", unselectable: "on", html: " "},
34228 {tag: "div", cls: "x-unselectable x-layout-panel-hd-tools", unselectable: "on"}
34230 this.titleEl.enableDisplayMode();
34233 this.titleTextEl = this.titleEl.dom.firstChild;
34234 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
34235 this.closeBtn = this.createTool(this.tools.dom, "x-layout-close");
34236 this.closeBtn.enableDisplayMode();
34237 this.closeBtn.on("click", this.closeClicked, this);
34238 this.closeBtn.hide();
34240 this.createBody(B);
34241 this.visible = true;
34242 this.collapsed = false;
34244 if(B.hideWhenEmpty){
34246 this.on("paneladded", this.validateVisibility, this);
34247 this.on("panelremoved", this.validateVisibility, this);
34250 this.applyConfig(B);
34253 Roo.extend(Roo.LayoutRegion, Roo.BasicLayoutRegion, {
34255 createBody : function(){
34258 this.bodyEl = this.el.createChild({tag: "div", cls: "x-layout-panel-body"});
34261 applyConfig : function(c){
34262 if(c.collapsible && this.position != "center" && !this.collapsedEl){
34263 var dh = Roo.DomHelper;
34264 if(c.titlebar !== false){
34265 this.collapseBtn = this.createTool(this.tools.dom, "x-layout-collapse-"+this.position);
34266 this.collapseBtn.on("click", this.collapse, this);
34267 this.collapseBtn.enableDisplayMode();
34269 if(c.showPin === true || this.showPin){
34270 this.stickBtn = this.createTool(this.tools.dom, "x-layout-stick");
34271 this.stickBtn.enableDisplayMode();
34272 this.stickBtn.on("click", this.expand, this);
34273 this.stickBtn.hide();
34279 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
34280 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
34282 if(c.floatable !== false){
34283 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
34284 this.collapsedEl.on("click", this.collapseClick, this);
34287 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
34288 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
34289 id: "message", unselectable: "on", style:{"float":"left"}});
34290 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
34293 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
34294 this.expandBtn.on("click", this.expand, this);
34296 if(this.collapseBtn){
34297 this.collapseBtn.setVisible(c.collapsible == true);
34300 this.cmargins = c.cmargins || this.cmargins ||
34301 (this.position == "west" || this.position == "east" ?
34302 {top: 0, left: 2, right:2, bottom: 0} :
34303 {top: 2, left: 0, right:0, bottom: 2});
34304 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
34305 this.bottomTabs = c.tabPosition != "top";
34306 this.autoScroll = c.autoScroll || false;
34307 if(this.autoScroll){
34308 this.bodyEl.setStyle("overflow", "auto");
34310 this.bodyEl.setStyle("overflow", "hidden");
34313 if((!c.titlebar && !c.title) || c.titlebar === false){
34314 this.titleEl.hide();
34316 this.titleEl.show();
34318 this.titleTextEl.innerHTML = c.title;
34323 this.duration = c.duration || .30;
34324 this.slideDuration = c.slideDuration || .45;
34327 this.collapse(true);
34335 isVisible : function(){
34336 return this.visible;
34341 setCollapsedTitle : function(D){
34343 if(this.collapsedTitleTextEl){
34344 this.collapsedTitleTextEl.innerHTML = D;
34348 getBox : function(){
34350 if(!this.collapsed){
34351 b = this.el.getBox(false, true);
34353 b = this.collapsedEl.getBox(false, true);
34358 getMargins : function(){
34359 return this.collapsed ? this.cmargins : this.margins;
34362 highlight : function(){
34363 this.el.addClass("x-layout-panel-dragover");
34366 unhighlight : function(){
34367 this.el.removeClass("x-layout-panel-dragover");
34370 updateBox : function(E){
34372 if(!this.collapsed){
34373 this.el.dom.style.left = E.x + "px";
34374 this.el.dom.style.top = E.y + "px";
34375 this.updateBody(E.width, E.height);
34377 this.collapsedEl.dom.style.left = E.x + "px";
34378 this.collapsedEl.dom.style.top = E.y + "px";
34379 this.collapsedEl.setSize(E.width, E.height);
34382 this.tabs.autoSizeTabs();
34386 updateBody : function(w, h){
34388 this.el.setWidth(w);
34389 w -= this.el.getBorderWidth("rl");
34390 if(this.config.adjustments){
34391 w += this.config.adjustments[0];
34395 this.el.setHeight(h);
34396 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
34397 h -= this.el.getBorderWidth("tb");
34398 if(this.config.adjustments){
34399 h += this.config.adjustments[1];
34402 this.bodyEl.setHeight(h);
34404 h = this.tabs.syncHeight(h);
34407 if(this.panelSize){
34408 w = w !== null ? w : this.panelSize.width;
34409 h = h !== null ? h : this.panelSize.height;
34411 if(this.activePanel){
34412 var el = this.activePanel.getEl();
34413 w = w !== null ? w : el.getWidth();
34414 h = h !== null ? h : el.getHeight();
34415 this.panelSize = {width: w, height: h};
34416 this.activePanel.setSize(w, h);
34418 if(Roo.isIE && this.tabs){
34419 this.tabs.el.repaint();
34425 getEl : function(){
34432 if(!this.collapsed){
34433 this.el.dom.style.left = "-2000px";
34436 this.collapsedEl.dom.style.left = "-2000px";
34437 this.collapsedEl.hide();
34440 this.visible = false;
34441 this.fireEvent("visibilitychange", this, false);
34447 if(!this.collapsed){
34450 this.collapsedEl.show();
34453 this.visible = true;
34454 this.fireEvent("visibilitychange", this, true);
34457 closeClicked : function(){
34458 if(this.activePanel){
34459 this.remove(this.activePanel);
34463 collapseClick : function(e){
34465 e.stopPropagation();
34468 e.stopPropagation();
34475 collapse : function(F){
34476 if(this.collapsed) return;
34477 this.collapsed = true;
34479 this.split.el.hide();
34481 if(this.config.animate && F !== true){
34482 this.fireEvent("invalidated", this);
34483 this.animateCollapse();
34485 this.el.setLocation(-20000,-20000);
34487 this.collapsedEl.show();
34488 this.fireEvent("collapsed", this);
34489 this.fireEvent("invalidated", this);
34493 animateCollapse : function(){
34499 expand : function(e, G){
34500 if(e) e.stopPropagation();
34501 if(!this.collapsed || this.el.hasActiveFx()) return;
34503 this.afterSlideIn();
34507 this.collapsed = false;
34508 if(this.config.animate && G !== true){
34509 this.animateExpand();
34513 this.split.el.show();
34516 this.collapsedEl.setLocation(-2000,-2000);
34517 this.collapsedEl.hide();
34518 this.fireEvent("invalidated", this);
34519 this.fireEvent("expanded", this);
34523 animateExpand : function(){
34527 initTabs : function(){
34528 this.bodyEl.setStyle("overflow", "hidden");
34529 var ts = new Roo.TabPanel(this.bodyEl.dom, {
34530 tabPosition: this.bottomTabs ? 'bottom' : 'top',
34531 disableTooltips: this.config.disableTabTips
34533 if(this.config.hideTabs){
34534 ts.stripWrap.setDisplayed(false);
34538 ts.resizeTabs = this.config.resizeTabs === true;
34539 ts.minTabWidth = this.config.minTabWidth || 40;
34540 ts.maxTabWidth = this.config.maxTabWidth || 250;
34541 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
34542 ts.monitorResize = false;
34543 ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
34544 ts.bodyEl.addClass('x-layout-tabs-body');
34545 this.panels.each(this.initPanelAsTab, this);
34548 initPanelAsTab : function(H){
34549 var ti = this.tabs.addTab(H.getEl().id, H.getTitle(), null,
34550 this.config.closeOnTab && H.isClosable());
34551 if(H.tabTip !== undefined){
34552 ti.setTooltip(H.tabTip);
34555 ti.on("activate", function(){
34556 this.setActivePanel(H);
34558 if(this.config.closeOnTab){
34559 ti.on("beforeclose", function(t, e){
34567 updatePanelTitle : function(I, J){
34568 if(this.activePanel == I){
34569 this.updateTitle(J);
34572 var ti = this.tabs.getTab(I.getEl().id);
34574 if(I.tabTip !== undefined){
34575 ti.setTooltip(I.tabTip);
34580 updateTitle : function(K){
34581 if(this.titleTextEl && !this.config.title){
34582 this.titleTextEl.innerHTML = (typeof K != "undefined" && K.length > 0 ? K : " ");
34586 setActivePanel : function(L){
34587 L = this.getPanel(L);
34588 if(this.activePanel && this.activePanel != L){
34589 this.activePanel.setActiveState(false);
34592 this.activePanel = L;
34593 L.setActiveState(true);
34594 if(this.panelSize){
34595 L.setSize(this.panelSize.width, this.panelSize.height);
34598 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && L.isClosable());
34601 this.updateTitle(L.getTitle());
34603 this.fireEvent("invalidated", this);
34606 this.fireEvent("panelactivated", this, L);
34611 showPanel : function(M){
34612 if(M = this.getPanel(M)){
34614 var tab = this.tabs.getTab(M.getEl().id);
34615 if(tab.isHidden()){
34616 this.tabs.unhideTab(tab.id);
34621 this.setActivePanel(M);
34629 getActivePanel : function(){
34630 return this.activePanel;
34633 validateVisibility : function(){
34634 if(this.panels.getCount() < 1){
34635 this.updateTitle(" ");
34636 this.closeBtn.hide();
34639 if(!this.isVisible()){
34648 if(arguments.length > 1){
34649 for(var i = 0, len = arguments.length; i < len; i++) {
34650 this.add(arguments[i]);
34654 if(this.hasPanel(N)){
34660 this.panels.add(N);
34661 if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
34662 this.bodyEl.dom.appendChild(N.getEl().dom);
34663 if(N.background !== true){
34664 this.setActivePanel(N);
34667 this.fireEvent("paneladded", this, N);
34673 this.initPanelAsTab(N);
34675 if(N.background !== true){
34676 this.tabs.activate(N.getEl().id);
34679 this.fireEvent("paneladded", this, N);
34685 hidePanel : function(O){
34686 if(this.tabs && (O = this.getPanel(O))){
34687 this.tabs.hideTab(O.getEl().id);
34693 unhidePanel : function(P){
34694 if(this.tabs && (P = this.getPanel(P))){
34695 this.tabs.unhideTab(P.getEl().id);
34699 clearPanels : function(){
34700 while(this.panels.getCount() > 0){
34701 this.remove(this.panels.first());
34707 remove : function(Q, R){
34708 Q = this.getPanel(Q);
34713 this.fireEvent("beforeremove", this, Q, e);
34714 if(e.cancel === true){
34718 R = (typeof R != "undefined" ? R : (this.config.preservePanels === true || Q.preserve === true));
34720 this.panels.removeKey(S);
34722 document.body.appendChild(Q.getEl().dom);
34725 this.tabs.removeTab(Q.getEl().id);
34727 this.bodyEl.dom.removeChild(Q.getEl().dom);
34729 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
34730 var p = this.panels.first();
34731 var tempEl = document.createElement("div");
34732 tempEl.appendChild(p.getEl().dom);
34733 this.bodyEl.update("");
34734 this.bodyEl.dom.appendChild(p.getEl().dom);
34736 this.updateTitle(p.getTitle());
34738 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
34739 this.setActivePanel(p);
34743 if(this.activePanel == Q){
34744 this.activePanel = null;
34746 if(this.config.autoDestroy !== false && R !== true){
34747 try{Q.destroy();}catch(e){}
34750 this.fireEvent("panelremoved", this, Q);
34756 getTabs : function(){
34760 createTool : function(T, U){
34761 var V = Roo.DomHelper.append(T, {tag: "div", cls: "x-layout-tools-button",
34762 children: [{tag: "div", cls: "x-layout-tools-button-inner " + U, html: " "}]}, true);
34763 V.addClassOnOver("x-layout-tools-button-over");
34774 Roo.SplitLayoutRegion = function(A, B, C, D){
34776 Roo.SplitLayoutRegion.superclass.constructor.call(this, A, B, C);
34779 Roo.extend(Roo.SplitLayoutRegion, Roo.LayoutRegion, {
34780 splitTip : "Drag to resize.",
34781 collapsibleSplitTip : "Drag to resize. Double click to hide.",
34782 useSplitTips : false,
34784 applyConfig : function(E){
34785 Roo.SplitLayoutRegion.superclass.applyConfig.call(this, E);
34788 var splitEl = Roo.DomHelper.append(this.mgr.el.dom,
34789 {tag: "div", id: this.el.id + "-split", cls: "x-layout-split x-layout-split-"+this.position, html: " "});
34792 this.split = new Roo.SplitBar(splitEl, this.el, this.orientation);
34793 this.split.on("moved", this.onSplitMove, this);
34794 this.split.useShim = E.useShim === true;
34795 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
34796 if(this.useSplitTips){
34797 this.split.el.dom.title = E.collapsible ? this.collapsibleSplitTip : this.splitTip;
34800 this.split.el.on("dblclick", this.collapse, this);
34803 if(typeof E.minSize != "undefined"){
34804 this.split.minSize = E.minSize;
34806 if(typeof E.maxSize != "undefined"){
34807 this.split.maxSize = E.maxSize;
34809 if(E.hideWhenEmpty || E.hidden || E.collapsed){
34810 this.hideSplitter();
34815 getHMaxSize : function(){
34816 var F = this.config.maxSize || 10000;
34817 var G = this.mgr.getRegion("center");
34818 return Math.min(F, (this.el.getWidth()+G.getEl().getWidth())-G.getMinWidth());
34821 getVMaxSize : function(){
34822 var H = this.config.maxSize || 10000;
34823 var I = this.mgr.getRegion("center");
34824 return Math.min(H, (this.el.getHeight()+I.getEl().getHeight())-I.getMinHeight());
34827 onSplitMove : function(J, K){
34828 this.fireEvent("resized", this, K);
34833 getSplitBar : function(){
34838 this.hideSplitter();
34839 Roo.SplitLayoutRegion.superclass.hide.call(this);
34842 hideSplitter : function(){
34844 this.split.el.setLocation(-2000,-2000);
34845 this.split.el.hide();
34851 this.split.el.show();
34854 Roo.SplitLayoutRegion.superclass.show.call(this);
34857 beforeSlide: function(){
34859 this.bodyEl.clip();
34860 if(this.tabs) this.tabs.bodyEl.clip();
34861 if(this.activePanel){
34862 this.activePanel.getEl().clip();
34864 if(this.activePanel.beforeSlide){
34865 this.activePanel.beforeSlide();
34871 afterSlide : function(){
34873 this.bodyEl.unclip();
34874 if(this.tabs) this.tabs.bodyEl.unclip();
34875 if(this.activePanel){
34876 this.activePanel.getEl().unclip();
34877 if(this.activePanel.afterSlide){
34878 this.activePanel.afterSlide();
34884 initAutoHide : function(){
34885 if(this.autoHide !== false){
34886 if(!this.autoHideHd){
34887 var st = new Roo.util.DelayedTask(this.slideIn, this);
34888 this.autoHideHd = {
34889 "mouseout": function(e){
34890 if(!e.within(this.el, true)){
34894 "mouseover" : function(e){
34901 this.el.on(this.autoHideHd);
34905 clearAutoHide : function(){
34906 if(this.autoHide !== false){
34907 this.el.un("mouseout", this.autoHideHd.mouseout);
34908 this.el.un("mouseover", this.autoHideHd.mouseover);
34912 clearMonitor : function(){
34913 Roo.get(document).un("click", this.slideInIf, this);
34917 slideOut : function(){
34918 if(this.isSlid || this.el.hasActiveFx()){
34922 this.isSlid = true;
34923 if(this.collapseBtn){
34924 this.collapseBtn.hide();
34927 this.closeBtnState = this.closeBtn.getStyle('display');
34928 this.closeBtn.hide();
34930 this.stickBtn.show();
34934 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
34935 this.beforeSlide();
34936 this.el.setStyle("z-index", 10001);
34937 this.el.slideIn(this.getSlideAnchor(), {
34938 callback: function(){
34940 this.initAutoHide();
34941 Roo.get(document).on("click", this.slideInIf, this);
34942 this.fireEvent("slideshow", this);
34949 afterSlideIn : function(){
34950 this.clearAutoHide();
34951 this.isSlid = false;
34952 this.clearMonitor();
34953 this.el.setStyle("z-index", "");
34954 if(this.collapseBtn){
34955 this.collapseBtn.show();
34958 this.closeBtn.setStyle('display', this.closeBtnState);
34960 this.stickBtn.hide();
34963 this.fireEvent("slidehide", this);
34966 slideIn : function(cb){
34967 if(!this.isSlid || this.el.hasActiveFx()){
34972 this.isSlid = false;
34973 this.beforeSlide();
34974 this.el.slideOut(this.getSlideAnchor(), {
34975 callback: function(){
34976 this.el.setLeftTop(-10000, -10000);
34978 this.afterSlideIn();
34986 slideInIf : function(e){
34987 if(!e.within(this.el)){
34992 animateCollapse : function(){
34993 this.beforeSlide();
34994 this.el.setStyle("z-index", 20000);
34995 var L = this.getSlideAnchor();
34996 this.el.slideOut(L, {
34997 callback : function(){
34998 this.el.setStyle("z-index", "");
34999 this.collapsedEl.slideIn(L, {duration:.3});
35001 this.el.setLocation(-10000,-10000);
35003 this.fireEvent("collapsed", this);
35010 animateExpand : function(){
35011 this.beforeSlide();
35012 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
35013 this.el.setStyle("z-index", 20000);
35014 this.collapsedEl.hide({
35017 this.el.slideIn(this.getSlideAnchor(), {
35018 callback : function(){
35019 this.el.setStyle("z-index", "");
35022 this.split.el.show();
35025 this.fireEvent("invalidated", this);
35026 this.fireEvent("expanded", this);
35054 getAnchor : function(){
35055 return this.anchors[this.position];
35058 getCollapseAnchor : function(){
35059 return this.canchors[this.position];
35062 getSlideAnchor : function(){
35063 return this.sanchors[this.position];
35066 getAlignAdj : function(){
35067 var cm = this.cmargins;
35068 switch(this.position){
35084 getExpandAdj : function(){
35085 var c = this.collapsedEl, cm = this.cmargins;
35086 switch(this.position){
35088 return [-(cm.right+c.getWidth()+cm.left), 0];
35091 return [cm.right+c.getWidth()+cm.left, 0];
35094 return [0, -(cm.top+cm.bottom+c.getHeight())];
35097 return [0, cm.top+cm.bottom+c.getHeight()];
35106 Roo.CenterLayoutRegion = function(A, B){
35107 Roo.LayoutRegion.call(this, A, B, "center");
35108 this.visible = true;
35109 this.minWidth = B.minWidth || 20;
35110 this.minHeight = B.minHeight || 20;
35113 Roo.extend(Roo.CenterLayoutRegion, Roo.LayoutRegion, {
35122 getMinWidth: function(){
35123 return this.minWidth;
35126 getMinHeight: function(){
35127 return this.minHeight;
35132 Roo.NorthLayoutRegion = function(C, D){
35133 Roo.LayoutRegion.call(this, C, D, "north", "n-resize");
35135 this.split.placement = Roo.SplitBar.TOP;
35136 this.split.orientation = Roo.SplitBar.VERTICAL;
35137 this.split.el.addClass("x-layout-split-v");
35139 var E = D.initialSize || D.height;
35140 if(typeof E != "undefined"){
35141 this.el.setHeight(E);
35144 Roo.extend(Roo.NorthLayoutRegion, Roo.SplitLayoutRegion, {
35145 orientation: Roo.SplitBar.VERTICAL,
35146 getBox : function(){
35147 if(this.collapsed){
35148 return this.collapsedEl.getBox();
35150 var F = this.el.getBox();
35152 F.height += this.split.el.getHeight();
35157 updateBox : function(G){
35158 if(this.split && !this.collapsed){
35159 G.height -= this.split.el.getHeight();
35160 this.split.el.setLeft(G.x);
35161 this.split.el.setTop(G.y+G.height);
35162 this.split.el.setWidth(G.width);
35164 if(this.collapsed){
35165 this.updateBody(G.width, null);
35168 Roo.LayoutRegion.prototype.updateBox.call(this, G);
35172 Roo.SouthLayoutRegion = function(H, I){
35173 Roo.SplitLayoutRegion.call(this, H, I, "south", "s-resize");
35175 this.split.placement = Roo.SplitBar.BOTTOM;
35176 this.split.orientation = Roo.SplitBar.VERTICAL;
35177 this.split.el.addClass("x-layout-split-v");
35179 var J = I.initialSize || I.height;
35180 if(typeof J != "undefined"){
35181 this.el.setHeight(J);
35184 Roo.extend(Roo.SouthLayoutRegion, Roo.SplitLayoutRegion, {
35185 orientation: Roo.SplitBar.VERTICAL,
35186 getBox : function(){
35187 if(this.collapsed){
35188 return this.collapsedEl.getBox();
35190 var K = this.el.getBox();
35192 var sh = this.split.el.getHeight();
35199 updateBox : function(L){
35200 if(this.split && !this.collapsed){
35201 var sh = this.split.el.getHeight();
35204 this.split.el.setLeft(L.x);
35205 this.split.el.setTop(L.y-sh);
35206 this.split.el.setWidth(L.width);
35208 if(this.collapsed){
35209 this.updateBody(L.width, null);
35212 Roo.LayoutRegion.prototype.updateBox.call(this, L);
35216 Roo.EastLayoutRegion = function(M, N){
35217 Roo.SplitLayoutRegion.call(this, M, N, "east", "e-resize");
35219 this.split.placement = Roo.SplitBar.RIGHT;
35220 this.split.orientation = Roo.SplitBar.HORIZONTAL;
35221 this.split.el.addClass("x-layout-split-h");
35223 var O = N.initialSize || N.width;
35224 if(typeof O != "undefined"){
35225 this.el.setWidth(O);
35228 Roo.extend(Roo.EastLayoutRegion, Roo.SplitLayoutRegion, {
35229 orientation: Roo.SplitBar.HORIZONTAL,
35230 getBox : function(){
35231 if(this.collapsed){
35232 return this.collapsedEl.getBox();
35234 var P = this.el.getBox();
35236 var sw = this.split.el.getWidth();
35243 updateBox : function(Q){
35244 if(this.split && !this.collapsed){
35245 var sw = this.split.el.getWidth();
35247 this.split.el.setLeft(Q.x);
35248 this.split.el.setTop(Q.y);
35249 this.split.el.setHeight(Q.height);
35252 if(this.collapsed){
35253 this.updateBody(null, Q.height);
35256 Roo.LayoutRegion.prototype.updateBox.call(this, Q);
35260 Roo.WestLayoutRegion = function(R, S){
35261 Roo.SplitLayoutRegion.call(this, R, S, "west", "w-resize");
35263 this.split.placement = Roo.SplitBar.LEFT;
35264 this.split.orientation = Roo.SplitBar.HORIZONTAL;
35265 this.split.el.addClass("x-layout-split-h");
35267 var T = S.initialSize || S.width;
35268 if(typeof T != "undefined"){
35269 this.el.setWidth(T);
35272 Roo.extend(Roo.WestLayoutRegion, Roo.SplitLayoutRegion, {
35273 orientation: Roo.SplitBar.HORIZONTAL,
35274 getBox : function(){
35275 if(this.collapsed){
35276 return this.collapsedEl.getBox();
35278 var U = this.el.getBox();
35280 U.width += this.split.el.getWidth();
35285 updateBox : function(V){
35286 if(this.split && !this.collapsed){
35287 var sw = this.split.el.getWidth();
35289 this.split.el.setLeft(V.x+V.width);
35290 this.split.el.setTop(V.y);
35291 this.split.el.setHeight(V.height);
35293 if(this.collapsed){
35294 this.updateBody(null, V.height);
35297 Roo.LayoutRegion.prototype.updateBox.call(this, V);
35307 Roo.LayoutStateManager = function(A){
35317 Roo.LayoutStateManager.prototype = {
35318 init : function(B, C){
35320 var D = C.get(B.id+"-layout-state");
35322 var wasUpdating = B.isUpdating();
35327 if(typeof D[key] != "function"){
35328 var rstate = D[key];
35329 var r = B.getRegion(key);
35332 r.resizeTo(rstate.size);
35334 if(rstate.collapsed == true){
35337 r.expand(null, true);
35350 B.on("regionresized", this.onRegionResized, this);
35351 B.on("regioncollapsed", this.onRegionCollapsed, this);
35352 B.on("regionexpanded", this.onRegionExpanded, this);
35355 storeState : function(){
35356 this.provider.set(this.layout.id+"-layout-state", this.state);
35359 onRegionResized : function(E, F){
35360 this.state[E.getPosition()].size = F;
35364 onRegionCollapsed : function(G){
35365 this.state[G.getPosition()].collapsed = true;
35369 onRegionExpanded : function(H){
35370 this.state[H.getPosition()].collapsed = false;
35378 Roo.ContentPanel = function(el, A, B){
35388 this.el = Roo.get(el);
35389 if(!this.el && A && A.autoCreate){
35390 if(typeof A.autoCreate == "object"){
35391 if(!A.autoCreate.id){
35392 A.autoCreate.id = A.id||el;
35395 this.el = Roo.DomHelper.append(document.body,
35396 A.autoCreate, true);
35398 this.el = Roo.DomHelper.append(document.body,
35399 {tag: "div", cls: "x-layout-inactive-content", id: A.id||el}, true);
35403 this.closable = false;
35404 this.loaded = false;
35405 this.active = false;
35406 if(typeof A == "string"){
35409 Roo.apply(this, A);
35412 if (this.toolbar && !this.toolbar.el && this.toolbar.xtype) {
35413 this.wrapEl = this.el.wrap();
35414 this.toolbar = new Roo.Toolbar(this.el.insertSibling(false, 'before'), [] , this.toolbar);
35421 this.resizeEl = Roo.get(this.resizeEl, true);
35423 this.resizeEl = this.el;
35432 "deactivate" : true,
35438 if(this.autoScroll){
35439 this.resizeEl.setStyle("overflow", "auto");
35442 B = B || this.content;
35444 this.setContent(B);
35447 this.setUrl(this.url, this.params, this.loadOnce);
35453 Roo.ContentPanel.superclass.constructor.call(this);
35456 Roo.extend(Roo.ContentPanel, Roo.util.Observable, {
35458 setRegion : function(C){
35461 this.el.replaceClass("x-layout-inactive-content", "x-layout-active-content");
35463 this.el.replaceClass("x-layout-active-content", "x-layout-inactive-content");
35469 getToolbar : function(){
35470 return this.toolbar;
35473 setActiveState : function(D){
35476 this.fireEvent("deactivate", this);
35478 this.fireEvent("activate", this);
35483 setContent : function(E, F){
35484 this.el.update(E, F);
35487 ignoreResize : function(w, h){
35488 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
35491 this.lastSize = {width: w, height: h};
35497 getUpdateManager : function(){
35498 return this.el.getUpdateManager();
35503 var um = this.el.getUpdateManager();
35504 um.update.apply(um, arguments);
35511 setUrl : function(G, H, I){
35512 if(this.refreshDelegate){
35513 this.removeListener("activate", this.refreshDelegate);
35516 this.refreshDelegate = this._handleRefresh.createDelegate(this, [G, H, I]);
35517 this.on("activate", this.refreshDelegate);
35518 return this.el.getUpdateManager();
35521 _handleRefresh : function(J, K, L){
35522 if(!L || !this.loaded){
35523 var updater = this.el.getUpdateManager();
35524 updater.update(J, K, this._setLoaded.createDelegate(this));
35528 _setLoaded : function(){
35529 this.loaded = true;
35534 getId : function(){
35540 getEl : function(){
35541 return this.wrapEl || this.el;
35544 adjustForComponents : function(M, N){
35545 if(this.resizeEl != this.el){
35546 M -= this.el.getFrameWidth('lr');
35547 N -= this.el.getFrameWidth('tb');
35550 var te = this.toolbar.getEl();
35551 N -= te.getHeight();
35554 if(this.adjustments){
35555 M += this.adjustments[0];
35556 N += this.adjustments[1];
35558 return {"width": M, "height": N};
35561 setSize : function(O, P){
35562 if(this.fitToFrame && !this.ignoreResize(O, P)){
35563 if(this.fitContainer && this.resizeEl != this.el){
35564 this.el.setSize(O, P);
35566 var size = this.adjustForComponents(O, P);
35567 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
35568 this.fireEvent('resize', this, size.width, size.height);
35574 getTitle : function(){
35580 setTitle : function(Q){
35583 this.region.updatePanelTitle(this, Q);
35589 isClosable : function(){
35590 return this.closable;
35593 beforeSlide : function(){
35595 this.resizeEl.clip();
35598 afterSlide : function(){
35600 this.resizeEl.unclip();
35605 refresh : function(){
35606 if(this.refreshDelegate){
35607 this.loaded = false;
35608 this.refreshDelegate();
35614 destroy : function(){
35615 this.el.removeAllListeners();
35616 var R = document.createElement("span");
35617 R.appendChild(this.el.dom);
35626 addxtype : function(S) {
35628 if (S.xtype.match(/^Form$/)) {
35629 var el = this.el.createChild();
35631 this.form = new Roo.form.Form(S);
35634 if ( this.form.allItems.length) this.form.render(el.dom);
35637 if (['View', 'JsonView'].indexOf(S.xtype) > -1) {
35639 S.el = this.el.appendChild(document.createElement("div"));
35641 var ret = new Roo[S.xtype](S);
35642 ret.render(false, '');
35653 Roo.GridPanel = function(T, U){
35656 this.wrapper = Roo.DomHelper.append(document.body,
35657 {tag: "div", cls: "x-layout-grid-wrapper x-layout-inactive-content"}, true);
35659 this.wrapper.dom.appendChild(T.getGridEl().dom);
35661 Roo.GridPanel.superclass.constructor.call(this, this.wrapper, U);
35664 this.toolbar.el.insertBefore(this.wrapper.dom.firstChild);
35667 if (this.footer && !this.footer.el && this.footer.xtype) {
35669 this.footer.container = this.grid.getView().getFooterPanel(true);
35670 this.footer.dataSource = this.grid.dataSource;
35671 this.footer = Roo.factory(this.footer, Roo);
35676 T.monitorWindowResize = false;
35677 T.autoHeight = false;
35678 T.autoWidth = false;
35680 this.grid.getGridEl().replaceClass("x-layout-inactive-content", "x-layout-component-panel");
35683 Roo.extend(Roo.GridPanel, Roo.ContentPanel, {
35684 getId : function(){
35685 return this.grid.id;
35690 getGrid : function(){
35694 setSize : function(V, W){
35695 if(!this.ignoreResize(V, W)){
35697 var size = this.adjustForComponents(V, W);
35698 T.getGridEl().setSize(size.width, size.height);
35703 beforeSlide : function(){
35704 this.grid.getView().scroller.clip();
35707 afterSlide : function(){
35708 this.grid.getView().scroller.unclip();
35711 destroy : function(){
35712 this.grid.destroy();
35714 Roo.GridPanel.superclass.destroy.call(this);
35721 Roo.NestedLayoutPanel = function(X, Y)
35727 Roo.NestedLayoutPanel.superclass.constructor.call(this, X.getEl(), Y);
35729 X.monitorWindowResize = false;
35731 this.layout.getEl().addClass("x-layout-nested-layout");
35737 Roo.extend(Roo.NestedLayoutPanel, Roo.ContentPanel, {
35739 setSize : function(Z, a){
35740 if(!this.ignoreResize(Z, a)){
35741 var size = this.adjustForComponents(Z, a);
35742 var el = this.layout.getEl();
35743 el.setSize(size.width, size.height);
35744 var touch = el.dom.offsetWidth;
35745 this.layout.layout();
35747 if(Roo.isIE && !this.initialized){
35748 this.initialized = true;
35749 this.layout.layout();
35756 setActiveState : function(b){
35759 this.fireEvent("deactivate", this);
35764 this.fireEvent("activate", this);
35766 if (!this.layout) {
35770 for (var r in this.layout.regions) {
35771 c = this.layout.getRegion(r);
35772 if (c.getActivePanel()) {
35774 c.setActivePanel(c.getActivePanel());
35777 if (!c.panels.length) {
35781 c.showPanel(c.getPanel(0));
35791 getLayout : function(){
35792 return this.layout;
35797 addxtype : function(d) {
35798 return this.layout.addxtype(d);
35803 Roo.ScrollPanel = function(el, e, f){
35805 e.fitToFrame = true;
35806 Roo.ScrollPanel.superclass.constructor.call(this, el, e, f);
35808 this.el.dom.style.overflow = "hidden";
35809 var g = this.el.wrap({cls: "x-scroller x-layout-inactive-content"});
35810 this.el.removeClass("x-layout-inactive-content");
35811 this.el.on("mousewheel", this.onWheel, this);
35813 var up = g.createChild({cls: "x-scroller-up", html: " "}, this.el.dom);
35814 var i = g.createChild({cls: "x-scroller-down", html: " "});
35815 up.unselectable(); i.unselectable();
35816 up.on("click", this.scrollUp, this);
35817 i.on("click", this.scrollDown, this);
35818 up.addClassOnOver("x-scroller-btn-over");
35819 i.addClassOnOver("x-scroller-btn-over");
35820 up.addClassOnClick("x-scroller-btn-click");
35821 i.addClassOnClick("x-scroller-btn-click");
35822 this.adjustments = [0, -(up.getHeight() + i.getHeight())];
35824 this.resizeEl = this.el;
35825 this.el = g; this.up = up; this.down = i;
35828 Roo.extend(Roo.ScrollPanel, Roo.ContentPanel, {
35830 wheelIncrement : 5,
35831 scrollUp : function(){
35832 this.resizeEl.scroll("up", this.increment, {callback: this.afterScroll, scope: this});
35835 scrollDown : function(){
35836 this.resizeEl.scroll("down", this.increment, {callback: this.afterScroll, scope: this});
35839 afterScroll : function(){
35840 var el = this.resizeEl;
35841 var t = el.dom.scrollTop, h = el.dom.scrollHeight, ch = el.dom.clientHeight;
35842 this.up[t == 0 ? "addClass" : "removeClass"]("x-scroller-btn-disabled");
35843 this.down[h - t <= ch ? "addClass" : "removeClass"]("x-scroller-btn-disabled");
35846 setSize : function(){
35847 Roo.ScrollPanel.superclass.setSize.apply(this, arguments);
35848 this.afterScroll();
35851 onWheel : function(e){
35852 var d = e.getWheelDelta();
35853 this.resizeEl.dom.scrollTop -= (d*this.wheelIncrement);
35854 this.afterScroll();
35858 setContent : function(j, k){
35859 this.resizeEl.update(j, k);
35874 Roo.TreePanel = function(l){
35879 Roo.TreePanel.superclass.constructor.call(this, el, l);
35880 var n = el.createChild();
35881 this.tree = new Roo.tree.TreePanel(n , m);
35883 this.on('activate', function()
35885 if (this.tree.rendered) {
35890 this.tree.render();
35893 this.on('resize', function (cp, w, h) {
35894 this.tree.innerCt.setWidth(w);
35895 this.tree.innerCt.setHeight(h);
35896 this.tree.innerCt.setStyle('overflow-y', 'auto');
35903 Roo.extend(Roo.TreePanel, Roo.ContentPanel);
35922 Roo.ReaderLayout = function(A, B){
35923 var c = A || {size:{}};
35924 Roo.ReaderLayout.superclass.constructor.call(this, B || document.body, {
35925 north: c.north !== false ? Roo.apply({
35929 }, c.north) : false,
35930 west: c.west !== false ? Roo.apply({
35938 margins:{left:5,right:0,bottom:5,top:5},
35939 cmargins:{left:5,right:5,bottom:5,top:5}
35940 }, c.west) : false,
35941 east: c.east !== false ? Roo.apply({
35949 margins:{left:0,right:5,bottom:5,top:5},
35950 cmargins:{left:5,right:5,bottom:5,top:5}
35951 }, c.east) : false,
35952 center: Roo.apply({
35953 tabPosition: 'top',
35957 margins:{left:c.west!==false ? 0 : 5,right:c.east!==false ? 0 : 5,bottom:5,top:2}
35961 this.el.addClass('x-reader');
35963 this.beginUpdate();
35965 var C = new Roo.BorderLayout(Roo.get(document.body).createChild(), {
35966 south: c.preview !== false ? Roo.apply({
35973 cmargins:{top:5,left:0, right:0, bottom:0}
35974 }, c.preview) : false,
35975 center: Roo.apply({
35981 this.add('center', new Roo.NestedLayoutPanel(C,
35982 Roo.apply({title: c.mainTitle || '',tabTip:''},c.innerPanelCfg)));
35986 this.regions.preview = C.getRegion('south');
35987 this.regions.listView = C.getRegion('center');
35990 Roo.extend(Roo.ReaderLayout, Roo.BorderLayout);
35996 Roo.grid.Grid = function(A, B){
35998 this.container = Roo.get(A);
35999 this.container.update("");
36000 this.container.setStyle("overflow", "hidden");
36001 this.container.addClass('x-grid-container');
36003 this.id = this.container.id;
36005 Roo.apply(this, B);
36008 this.dataSource = this.ds;
36012 this.colModel = this.cm;
36016 this.selModel = this.sm;
36020 if (this.selModel) {
36021 this.selModel = Roo.factory(this.selModel, Roo.grid);
36022 this.sm = this.selModel;
36023 this.sm.xmodule = this.xmodule || false;
36025 if (typeof(this.colModel.config) == 'undefined') {
36026 this.colModel = new Roo.grid.ColumnModel(this.colModel);
36027 this.cm = this.colModel;
36028 this.cm.xmodule = this.xmodule || false;
36030 if (this.dataSource) {
36031 this.dataSource= Roo.factory(this.dataSource, Roo.data);
36032 this.ds = this.dataSource;
36033 this.ds.xmodule = this.xmodule || false;
36040 this.container.setWidth(this.width);
36044 this.container.setHeight(this.height);
36059 "contextmenu" : true,
36062 "mousedown" : true,
36068 "mouseover" : true,
36083 "cellclick" : true,
36086 "celldblclick" : true,
36092 "rowdblclick" : true,
36095 "headerclick" : true,
36098 "headerdblclick" : true,
36101 "rowcontextmenu" : true,
36104 "cellcontextmenu" : true,
36107 "headercontextmenu" : true,
36110 "bodyscroll" : true,
36113 "columnresize" : true,
36116 "columnmove" : true,
36119 "startdrag" : true,
36131 "dragenter" : true,
36140 Roo.grid.Grid.superclass.constructor.call(this);
36142 Roo.extend(Roo.grid.Grid, Roo.util.Observable, {
36145 minColumnWidth : 25,
36149 autoSizeColumns : false,
36153 autoSizeHeaders : true,
36157 monitorWindowResize : true,
36161 maxRowsToMeasure : 0,
36165 trackMouseOver : true,
36169 enableDragDrop : false,
36173 enableColumnMove : true,
36177 enableColumnHide : true,
36181 enableRowHeightSync : false,
36189 autoHeight : false,
36193 autoExpandColumn : false,
36197 autoExpandMin : 50,
36201 autoExpandMax : 1000,
36220 render : function(){
36221 var c = this.container;
36223 if((!c.dom.offsetHeight || c.dom.offsetHeight < 20) || c.getStyle("height") == "auto"){
36224 this.autoHeight = true;
36226 var C = this.getView();
36229 c.on("click", this.onClick, this);
36230 c.on("dblclick", this.onDblClick, this);
36231 c.on("contextmenu", this.onContextMenu, this);
36232 c.on("keydown", this.onKeyDown, this);
36234 this.relayEvents(c, ["mousedown","mouseup","mouseover","mouseout","keypress"]);
36236 this.getSelectionModel().init(this);
36241 this.loadMask = new Roo.LoadMask(this.container,
36242 Roo.apply({store:this.dataSource}, this.loadMask));
36246 if (this.toolbar && this.toolbar.xtype) {
36247 this.toolbar.container = this.getView().getHeaderPanel(true);
36248 this.toolbar = new Ext.Toolbar(this.toolbar);
36250 if (this.footer && this.footer.xtype) {
36251 this.footer.dataSource = this.getDataSource();
36252 this.footer.container = this.getView().getFooterPanel(true);
36253 this.footer = Roo.factory(this.footer, Roo);
36256 this.rendered = true;
36257 this.fireEvent('render', this);
36263 reconfigure : function(D, E){
36265 this.loadMask.destroy();
36266 this.loadMask = new Roo.LoadMask(this.container,
36267 Roo.apply({store:D}, this.loadMask));
36270 this.view.bind(D, E);
36271 this.dataSource = D;
36273 this.view.refresh(true);
36277 onKeyDown : function(e){
36278 this.fireEvent("keydown", e);
36283 destroy : function(F, G){
36285 this.loadMask.destroy();
36287 var c = this.container;
36288 c.removeAllListeners();
36289 this.view.destroy();
36290 this.colModel.purgeListeners();
36292 this.purgeListeners();
36302 processEvent : function(H, e){
36303 this.fireEvent(H, e);
36304 var t = e.getTarget();
36306 var I = v.findHeaderIndex(t);
36308 this.fireEvent("header" + H, this, I, e);
36310 var row = v.findRowIndex(t);
36311 var cell = v.findCellIndex(t);
36313 this.fireEvent("row" + H, this, row, e);
36314 if(cell !== false){
36315 this.fireEvent("cell" + H, this, row, cell, e);
36322 onClick : function(e){
36323 this.processEvent("click", e);
36327 onContextMenu : function(e, t){
36328 this.processEvent("contextmenu", e);
36332 onDblClick : function(e){
36333 this.processEvent("dblclick", e);
36337 walkCells : function(J, K, L, fn, M){
36338 var cm = this.colModel, N = cm.getColumnCount();
36339 var ds = this.dataSource, O = ds.getCount(), P = true;
36352 if(fn.call(M || this, J, K, cm) === true){
36373 if(fn.call(M || this, J, K, cm) === true){
36387 getSelections : function(){
36388 return this.selModel.getSelections();
36393 autoSize : function(){
36395 this.view.layout();
36396 if(this.view.adjustForScroll){
36397 this.view.adjustForScroll();
36404 getGridEl : function(){
36405 return this.container;
36409 stopEditing : function(){},
36413 getSelectionModel : function(){
36414 if(!this.selModel){
36415 this.selModel = new Roo.grid.RowSelectionModel();
36417 return this.selModel;
36422 getDataSource : function(){
36423 return this.dataSource;
36428 getColumnModel : function(){
36429 return this.colModel;
36434 getView : function(){
36436 this.view = new Roo.grid.GridView(this.viewConfig);
36442 getDragDropText : function(){
36443 var Q = this.selModel.getCount();
36444 return String.format(this.ddText, Q, Q == 1 ? '' : 's');
36449 Roo.grid.Grid.prototype.ddText = "{0} selected row{1}";
36453 Roo.grid.AbstractGridView = function(){
36457 "beforerowremoved" : true,
36458 "beforerowsinserted" : true,
36459 "beforerefresh" : true,
36460 "rowremoved" : true,
36461 "rowsinserted" : true,
36462 "rowupdated" : true,
36465 Roo.grid.AbstractGridView.superclass.constructor.call(this);
36468 Roo.extend(Roo.grid.AbstractGridView, Roo.util.Observable, {
36469 rowClass : "x-grid-row",
36470 cellClass : "x-grid-cell",
36471 tdClass : "x-grid-td",
36472 hdClass : "x-grid-hd",
36473 splitClass : "x-grid-hd-split",
36477 var B = this.grid.getGridEl().id;
36478 this.colSelector = "#" + B + " ." + this.cellClass + "-";
36479 this.tdSelector = "#" + B + " ." + this.tdClass + "-";
36480 this.hdSelector = "#" + B + " ." + this.hdClass + "-";
36481 this.splitSelector = "#" + B + " ." + this.splitClass + "-";
36484 getColumnRenderers : function(){
36486 var cm = this.grid.colModel;
36487 var D = cm.getColumnCount();
36488 for(var i = 0; i < D; i++){
36489 C[i] = cm.getRenderer(i);
36494 getColumnIds : function(){
36496 var cm = this.grid.colModel;
36497 var F = cm.getColumnCount();
36498 for(var i = 0; i < F; i++){
36499 E[i] = cm.getColumnId(i);
36504 getDataIndexes : function(){
36505 if(!this.indexMap){
36506 this.indexMap = this.buildIndexMap();
36508 return this.indexMap.colToData;
36511 getColumnIndexByDataIndex : function(G){
36512 if(!this.indexMap){
36513 this.indexMap = this.buildIndexMap();
36515 return this.indexMap.dataToCol[G];
36520 setCSSStyle : function(H, I, J){
36521 var K = "#" + this.grid.id + " .x-grid-col-" + H;
36522 Roo.util.CSS.updateRule(K, I, J);
36525 generateRules : function(cm){
36526 var L = [], M = this.grid.id + '-cssrules';
36527 Roo.util.CSS.removeStyleSheet(M);
36528 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
36529 var B = cm.getColumnId(i);
36530 L.push(this.colSelector, B, " {\n", cm.config[i].css, "}\n",
36531 this.tdSelector, B, " {\n}\n",
36532 this.hdSelector, B, " {\n}\n",
36533 this.splitSelector, B, " {\n}\n");
36535 return Roo.util.CSS.createStyleSheet(L.join(""), M);
36543 Roo.grid.HeaderDragZone = function(A, hd, B){
36545 this.view = A.getView();
36546 this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
36547 Roo.grid.HeaderDragZone.superclass.constructor.call(this, hd);
36549 this.setHandleElId(Roo.id(hd));
36550 this.setOuterHandleElId(Roo.id(B));
36553 this.scroll = false;
36555 Roo.extend(Roo.grid.HeaderDragZone, Roo.dd.DragZone, {
36557 getDragData : function(e){
36558 var t = Roo.lib.Event.getTarget(e);
36559 var h = this.view.findHeaderCell(t);
36561 return {ddel: h.firstChild, header:h};
36566 onInitDrag : function(e){
36567 this.view.headersDisabled = true;
36568 var C = this.dragData.ddel.cloneNode(true);
36570 C.style.width = Math.min(this.dragData.header.offsetWidth,this.maxDragWidth) + "px";
36571 this.proxy.update(C);
36575 afterValidDrop : function(){
36577 setTimeout(function(){
36578 v.headersDisabled = false;
36582 afterInvalidDrop : function(){
36584 setTimeout(function(){
36585 v.headersDisabled = false;
36594 Roo.grid.HeaderDropZone = function(A, hd, B){
36596 this.view = A.getView();
36598 this.proxyTop = Roo.DomHelper.append(document.body, {
36599 cls:"col-move-top", html:" "
36601 this.proxyBottom = Roo.DomHelper.append(document.body, {
36602 cls:"col-move-bottom", html:" "
36604 this.proxyTop.hide = this.proxyBottom.hide = function(){
36605 this.setLeftTop(-100,-100);
36606 this.setStyle("visibility", "hidden");
36608 this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
36611 Roo.grid.HeaderDropZone.superclass.constructor.call(this, A.getGridEl().dom);
36613 Roo.extend(Roo.grid.HeaderDropZone, Roo.dd.DropZone, {
36614 proxyOffsets : [-4, -9],
36615 fly: Roo.Element.fly,
36617 getTargetFromEvent : function(e){
36618 var t = Roo.lib.Event.getTarget(e);
36619 var C = this.view.findCellIndex(t);
36621 return this.view.getHeaderCell(C);
36625 nextVisible : function(h){
36626 var v = this.view, cm = this.grid.colModel;
36629 if(!cm.isHidden(v.getCellIndex(h))){
36638 prevVisible : function(h){
36639 var v = this.view, cm = this.grid.colModel;
36642 if(!cm.isHidden(v.getCellIndex(h))){
36651 positionIndicator : function(h, n, e){
36652 var x = Roo.lib.Event.getPageX(e);
36653 var r = Roo.lib.Dom.getRegion(n.firstChild);
36654 var px, pt, py = r.top + this.proxyOffsets[1];
36655 if((r.right - x) <= (r.right-r.left)/2){
36656 px = r.right+this.view.borderWidth;
36662 var D = this.view.getCellIndex(h);
36663 var E = this.view.getCellIndex(n);
36665 if(this.grid.colModel.isFixed(E)){
36669 var F = this.grid.colModel.isLocked(E);
36677 if(D == E && (F == this.grid.colModel.isLocked(D))){
36681 px += this.proxyOffsets[0];
36682 this.proxyTop.setLeftTop(px, py);
36683 this.proxyTop.show();
36684 if(!this.bottomOffset){
36685 this.bottomOffset = this.view.mainHd.getHeight();
36688 this.proxyBottom.setLeftTop(px, py+this.proxyTop.dom.offsetHeight+this.bottomOffset);
36689 this.proxyBottom.show();
36693 onNodeEnter : function(n, dd, e, G){
36695 this.positionIndicator(G.header, n, e);
36699 onNodeOver : function(n, dd, e, H){
36702 I = this.positionIndicator(H.header, n, e);
36705 this.proxyTop.hide();
36706 this.proxyBottom.hide();
36708 return I ? this.dropAllowed : this.dropNotAllowed;
36711 onNodeOut : function(n, dd, e, J){
36712 this.proxyTop.hide();
36713 this.proxyBottom.hide();
36716 onNodeDrop : function(n, dd, e, K){
36719 var cm = this.grid.colModel;
36720 var x = Roo.lib.Event.getPageX(e);
36721 var r = Roo.lib.Dom.getRegion(n.firstChild);
36722 var pt = (r.right - x) <= ((r.right-r.left)/2) ? "after" : "before";
36723 var D = this.view.getCellIndex(h);
36724 var E = this.view.getCellIndex(n);
36725 var F = cm.isLocked(E);
36732 if(D == E && (F == cm.isLocked(D))){
36736 cm.setLocked(D, F, true);
36737 cm.moveColumn(D, E);
36738 this.grid.fireEvent("columnmove", D, E);
36750 Roo.grid.GridView = function(A){
36751 Roo.grid.GridView.superclass.constructor.call(this);
36754 Roo.apply(this, A);
36757 Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, {
36761 rowClass : "x-grid-row",
36763 cellClass : "x-grid-col",
36765 tdClass : "x-grid-td",
36767 hdClass : "x-grid-hd",
36769 splitClass : "x-grid-split",
36771 sortClasses : ["sort-asc", "sort-desc"],
36773 enableMoveAnim : false,
36777 dh : Roo.DomHelper,
36779 fly : Roo.Element.fly,
36781 css : Roo.util.CSS,
36787 scrollIncrement : 22,
36789 cellRE: /(?:.*?)x-grid-(?:hd|cell|csplit)-(?:[\d]+)-([\d]+)(?:.*?)/,
36791 findRE: /\s?(?:x-grid-hd|x-grid-col|x-grid-csplit)\s/,
36793 bind : function(ds, cm){
36795 this.ds.un("load", this.onLoad, this);
36796 this.ds.un("datachanged", this.onDataChange, this);
36797 this.ds.un("add", this.onAdd, this);
36798 this.ds.un("remove", this.onRemove, this);
36799 this.ds.un("update", this.onUpdate, this);
36800 this.ds.un("clear", this.onClear, this);
36803 ds.on("load", this.onLoad, this);
36804 ds.on("datachanged", this.onDataChange, this);
36805 ds.on("add", this.onAdd, this);
36806 ds.on("remove", this.onRemove, this);
36807 ds.on("update", this.onUpdate, this);
36808 ds.on("clear", this.onClear, this);
36814 this.cm.un("widthchange", this.onColWidthChange, this);
36815 this.cm.un("headerchange", this.onHeaderChange, this);
36816 this.cm.un("hiddenchange", this.onHiddenChange, this);
36817 this.cm.un("columnmoved", this.onColumnMove, this);
36818 this.cm.un("columnlockchange", this.onColumnLock, this);
36821 this.generateRules(cm);
36822 cm.on("widthchange", this.onColWidthChange, this);
36823 cm.on("headerchange", this.onHeaderChange, this);
36824 cm.on("hiddenchange", this.onHiddenChange, this);
36825 cm.on("columnmoved", this.onColumnMove, this);
36826 cm.on("columnlockchange", this.onColumnLock, this);
36833 Roo.grid.GridView.superclass.init.call(this, B);
36835 this.bind(B.dataSource, B.colModel);
36837 B.on("headerclick", this.handleHeaderClick, this);
36839 if(B.trackMouseOver){
36840 B.on("mouseover", this.onRowOver, this);
36841 B.on("mouseout", this.onRowOut, this);
36844 B.cancelTextSelection = function(){};
36845 this.gridId = B.id;
36847 var C = this.templates || {};
36850 C.master = new Roo.Template(
36851 '<div class="x-grid" hidefocus="true">',
36852 '<div class="x-grid-topbar"></div>',
36853 '<div class="x-grid-scroller"><div></div></div>',
36854 '<div class="x-grid-locked">',
36855 '<div class="x-grid-header">{lockedHeader}</div>',
36856 '<div class="x-grid-body">{lockedBody}</div>',
36858 '<div class="x-grid-viewport">',
36859 '<div class="x-grid-header">{header}</div>',
36860 '<div class="x-grid-body">{body}</div>',
36862 '<div class="x-grid-bottombar"></div>',
36863 '<a href="#" class="x-grid-focus" tabIndex="-1"></a>',
36864 '<div class="x-grid-resize-proxy"> </div>',
36867 C.master.disableformats = true;
36871 C.header = new Roo.Template(
36872 '<table border="0" cellspacing="0" cellpadding="0">',
36873 '<tbody><tr class="x-grid-hd-row">{cells}</tr></tbody>',
36876 C.header.disableformats = true;
36879 C.header.compile();
36882 C.hcell = new Roo.Template(
36883 '<td class="x-grid-hd x-grid-td-{id} {cellId}"><div title="{title}" class="x-grid-hd-inner x-grid-hd-{id}">',
36884 '<div class="x-grid-hd-text" unselectable="on">{value}<img class="x-grid-sort-icon" src="', Roo.BLANK_IMAGE_URL, '" /></div>',
36887 C.hcell.disableFormats = true;
36893 C.hsplit = new Roo.Template('<div class="x-grid-split {splitId} x-grid-split-{id}" style="{style}" unselectable="on"> </div>');
36894 C.hsplit.disableFormats = true;
36897 C.hsplit.compile();
36900 C.body = new Roo.Template(
36901 '<table border="0" cellspacing="0" cellpadding="0">',
36902 "<tbody>{rows}</tbody>",
36905 C.body.disableFormats = true;
36911 C.row = new Roo.Template('<tr class="x-grid-row {alt}">{cells}</tr>');
36912 C.row.disableFormats = true;
36918 C.cell = new Roo.Template(
36919 '<td class="x-grid-col x-grid-td-{id} {cellId} {css}" tabIndex="0">',
36920 '<div class="x-grid-col-{id} x-grid-cell-inner"><div class="x-grid-cell-text" unselectable="on" {attr}>{value}</div></div>',
36923 C.cell.disableFormats = true;
36928 this.templates = C;
36932 onColWidthChange : function(){
36933 this.updateColumns.apply(this, arguments);
36935 onHeaderChange : function(){
36936 this.updateHeaders.apply(this, arguments);
36938 onHiddenChange : function(){
36939 this.handleHiddenChange.apply(this, arguments);
36941 onColumnMove : function(){
36942 this.handleColumnMove.apply(this, arguments);
36944 onColumnLock : function(){
36945 this.handleLockChange.apply(this, arguments);
36948 onDataChange : function(){
36950 this.updateHeaderSortState();
36953 onClear : function(){
36957 onUpdate : function(ds, D){
36958 this.refreshRow(D);
36961 refreshRow : function(E){
36962 var ds = this.ds, F;
36963 if(typeof E == 'number'){
36970 this.insertRows(ds, F, F, true);
36971 this.onRemove(ds, E, F+1, true);
36972 this.syncRowHeights(F, F);
36974 this.fireEvent("rowupdated", this, F, E);
36977 onAdd : function(ds, G, H){
36978 this.insertRows(ds, H, H + (G.length-1));
36981 onRemove : function(ds, I, J, K){
36983 this.fireEvent("beforerowremoved", this, J, I);
36985 var bt = this.getBodyTable(), lt = this.getLockedTable();
36987 bt.firstChild.removeChild(bt.rows[J]);
36990 lt.firstChild.removeChild(lt.rows[J]);
36993 this.stripeRows(J);
36994 this.syncRowHeights(J, J);
36996 this.fireEvent("rowremoved", this, J, I);
37000 onLoad : function(){
37001 this.scrollToTop();
37006 scrollToTop : function(){
37008 this.scroller.dom.scrollTop = 0;
37015 getHeaderPanel : function(L){
37017 this.headerPanel.show();
37019 return this.headerPanel;
37024 getFooterPanel : function(M){
37026 this.footerPanel.show();
37028 return this.footerPanel;
37031 initElements : function(){
37032 var E = Roo.Element;
37033 var el = this.grid.getGridEl().dom.firstChild;
37034 var cs = el.childNodes;
37036 this.el = new E(el);
37037 this.headerPanel = new E(el.firstChild);
37038 this.headerPanel.enableDisplayMode("block");
37040 this.scroller = new E(cs[1]);
37041 this.scrollSizer = new E(this.scroller.dom.firstChild);
37043 this.lockedWrap = new E(cs[2]);
37044 this.lockedHd = new E(this.lockedWrap.dom.firstChild);
37045 this.lockedBody = new E(this.lockedWrap.dom.childNodes[1]);
37047 this.mainWrap = new E(cs[3]);
37048 this.mainHd = new E(this.mainWrap.dom.firstChild);
37049 this.mainBody = new E(this.mainWrap.dom.childNodes[1]);
37051 this.footerPanel = new E(cs[4]);
37052 this.footerPanel.enableDisplayMode("block");
37054 this.focusEl = new E(cs[5]);
37055 this.focusEl.swallowEvent("click", true);
37056 this.resizeProxy = new E(cs[6]);
37058 this.headerSelector = String.format(
37059 '#{0} td.x-grid-hd, #{1} td.x-grid-hd',
37060 this.lockedHd.id, this.mainHd.id
37063 this.splitterSelector = String.format(
37064 '#{0} div.x-grid-split, #{1} div.x-grid-split',
37065 this.idToCssName(this.lockedHd.id), this.idToCssName(this.mainHd.id)
37068 idToCssName : function(s)
37070 return s.replace(/[^a-z0-9]+/ig, '-');
37073 getHeaderCell : function(N){
37074 return Roo.DomQuery.select(this.headerSelector)[N];
37077 getHeaderCellMeasure : function(O){
37078 return this.getHeaderCell(O).firstChild;
37081 getHeaderCellText : function(P){
37082 return this.getHeaderCell(P).firstChild.firstChild;
37085 getLockedTable : function(){
37086 return this.lockedBody.dom.firstChild;
37089 getBodyTable : function(){
37090 return this.mainBody.dom.firstChild;
37093 getLockedRow : function(Q){
37094 return this.getLockedTable().rows[Q];
37097 getRow : function(R){
37098 return this.getBodyTable().rows[R];
37101 getRowComposite : function(S){
37103 this.rowEl = new Roo.CompositeElementLite();
37106 if(U = this.getLockedRow(S)){
37109 if(V = this.getRow(S)){
37113 this.rowEl.elements = T;
37117 getCell : function(W, X){
37118 var Y = this.cm.getLockedCount();
37121 Z = this.lockedBody.dom.firstChild;
37123 Z = this.mainBody.dom.firstChild;
37126 return Z.rows[W].childNodes[X];
37129 getCellText : function(a, b){
37130 return this.getCell(a, b).firstChild.firstChild;
37133 getCellBox : function(c){
37134 var b = this.fly(c).getBox();
37136 b.y = c.offsetTop + this.mainBody.getY();
37141 getCellIndex : function(d){
37142 var id = String(d.className).match(this.cellRE);
37144 return parseInt(id[1], 10);
37149 findHeaderIndex : function(n){
37150 var r = Roo.fly(n).findParent("td." + this.hdClass, 6);
37151 return r ? this.getCellIndex(r) : false;
37154 findHeaderCell : function(n){
37155 var r = Roo.fly(n).findParent("td." + this.hdClass, 6);
37156 return r ? r : false;
37159 findRowIndex : function(n){
37163 var r = Roo.fly(n).findParent("tr." + this.rowClass, 6);
37164 return r ? r.rowIndex : false;
37167 findCellIndex : function(e){
37168 var f = this.el.dom;
37169 while(e && e != f){
37170 if(this.findRE.test(e.className)){
37171 return this.getCellIndex(e);
37179 getColumnId : function(g){
37180 return this.cm.getColumnId(g);
37183 getSplitters : function(){
37184 if(this.splitterSelector){
37185 return Roo.DomQuery.select(this.splitterSelector);
37191 getSplitter : function(k){
37192 return this.getSplitters()[k];
37195 onRowOver : function(e, t){
37197 if((o = this.findRowIndex(t)) !== false){
37198 this.getRowComposite(o).addClass("x-grid-row-over");
37202 onRowOut : function(e, t){
37204 if((p = this.findRowIndex(t)) !== false && p !== this.findRowIndex(e.getRelatedTarget())){
37205 this.getRowComposite(p).removeClass("x-grid-row-over");
37209 renderHeaders : function(){
37211 var ct = this.templates.hcell, ht = this.templates.header, st = this.templates.hsplit;
37212 var cb = [], lb = [], sb = [], q = [], p = {};
37213 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
37214 p.cellId = "x-grid-hd-0-" + i;
37215 p.splitId = "x-grid-csplit-0-" + i;
37216 p.id = cm.getColumnId(i);
37217 p.title = cm.getColumnTooltip(i) || "";
37218 p.value = cm.getColumnHeader(i) || "";
37219 p.style = (this.grid.enableColumnResize === false || !cm.isResizable(i) || cm.isFixed(i)) ? 'cursor:default' : '';
37220 if(!cm.isLocked(i)){
37221 cb[cb.length] = ct.apply(p);
37222 sb[sb.length] = st.apply(p);
37224 lb[lb.length] = ct.apply(p);
37225 q[q.length] = st.apply(p);
37228 return [ht.apply({cells: lb.join(""), splits:q.join("")}),
37229 ht.apply({cells: cb.join(""), splits:sb.join("")})];
37232 updateHeaders : function(){
37233 var u = this.renderHeaders();
37234 this.lockedHd.update(u[0]);
37235 this.mainHd.update(u[1]);
37240 focusRow : function(v){
37241 var x = this.scroller.dom.scrollLeft;
37242 this.focusCell(v, 0, false);
37243 this.scroller.dom.scrollLeft = x;
37248 focusCell : function(y, z, AA){
37249 var el = this.ensureVisible(y, z, AA);
37250 this.focusEl.alignTo(el, "tl-tl");
37252 this.focusEl.focus();
37254 this.focusEl.focus.defer(1, this.focusEl);
37260 ensureVisible : function(AB, AC, AD){
37261 if(typeof AB != "number"){
37264 if(AB < 0 && AB >= this.ds.getCount()){
37268 AC = (AC !== undefined ? AC : 0);
37269 var cm = this.grid.colModel;
37270 while(cm.isHidden(AC)){
37274 var el = this.getCell(AB, AC);
37278 var c = this.scroller.dom;
37280 var AE = parseInt(el.offsetTop, 10);
37281 var AF = parseInt(el.offsetLeft, 10);
37282 var AG = AE + el.offsetHeight;
37283 var AH = AF + el.offsetWidth;
37285 var ch = c.clientHeight - this.mainHd.dom.offsetHeight;
37286 var AI = parseInt(c.scrollTop, 10);
37287 var AJ = parseInt(c.scrollLeft, 10);
37289 var AL = AJ + c.clientWidth;
37294 c.scrollTop = AG-ch;
37301 c.scrollLeft = AH-c.clientWidth;
37307 updateColumns : function(){
37308 this.grid.stopEditing();
37309 var cm = this.grid.colModel, AM = this.getColumnIds();
37312 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
37314 var w = cm.getColumnWidth(i);
37315 this.css.updateRule(this.colSelector+this.idToCssName(AM[i]), "width", (w - this.borderWidth) + "px");
37316 this.css.updateRule(this.hdSelector+this.idToCssName(AM[i]), "width", (w - this.borderWidth) + "px");
37319 this.updateSplitters();
37322 generateRules : function(cm){
37323 var AO = [], AP = this.idToCssName(this.grid.id)+ '-cssrules';
37324 Roo.util.CSS.removeStyleSheet(AP);
37325 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
37326 var cid = cm.getColumnId(i);
37328 if(cm.config[i].align){
37329 align = 'text-align:'+cm.config[i].align+';';
37332 if(cm.isHidden(i)){
37333 hidden = 'display:none;';
37335 var width = "width:" + (cm.getColumnWidth(i) - this.borderWidth) + "px;";
37337 this.colSelector, cid, " {\n", cm.config[i].css, align, width, "\n}\n",
37338 this.hdSelector, cid, " {\n", align, width, "}\n",
37339 this.tdSelector, cid, " {\n",hidden,"\n}\n",
37340 this.splitSelector, cid, " {\n", hidden , "\n}\n");
37342 return Roo.util.CSS.createStyleSheet(AO.join(""), AP);
37345 updateSplitters : function(){
37346 var cm = this.cm, s = this.getSplitters();
37348 var AN = 0, Y = true;
37349 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
37350 if(cm.isHidden(i)) continue;
37351 var w = cm.getColumnWidth(i);
37352 if(!cm.isLocked(i) && Y){
37358 s[i].style.left = (AN-this.splitOffset) + "px";
37363 handleHiddenChange : function(AQ, AR, AS){
37365 this.hideColumn(AR);
37367 this.unhideColumn(AR);
37371 hideColumn : function(AT){
37372 var AU = this.getColumnId(AT);
37373 this.css.updateRule(this.tdSelector+this.idToCssName(AU), "display", "none");
37374 this.css.updateRule(this.splitSelector+this.idToCssName(AU), "display", "none");
37376 this.updateHeaders();
37379 this.updateSplitters();
37383 unhideColumn : function(AV){
37384 var AW = this.getColumnId(AV);
37385 this.css.updateRule(this.tdSelector+this.idToCssName(AW), "display", "");
37386 this.css.updateRule(this.splitSelector+this.idToCssName(AW), "display", "");
37389 this.updateHeaders();
37392 this.updateSplitters();
37396 insertRows : function(dm, AX, AY, AZ){
37397 if(AX == 0 && AY == dm.getCount()-1){
37401 this.fireEvent("beforerowsinserted", this, AX, AY);
37403 var s = this.getScrollState();
37404 var markup = this.renderRows(AX, AY);
37405 this.bufferRows(markup[0], this.getLockedTable(), AX);
37406 this.bufferRows(markup[1], this.getBodyTable(), AX);
37407 this.restoreScroll(s);
37409 this.fireEvent("rowsinserted", this, AX, AY);
37410 this.syncRowHeights(AX, AY);
37411 this.stripeRows(AX);
37417 bufferRows : function(Aa, Ab, Ac){
37418 var Ad = null, Ae = Ab.rows, Af = Ab.tBodies[0];
37419 if(Ac < Ae.length){
37422 var b = document.createElement("div");
37423 b.innerHTML = "<table><tbody>"+Aa+"</tbody></table>";
37424 var Ag = b.firstChild.rows;
37425 for(var i = 0, len = Ag.length; i < len; i++){
37427 Af.insertBefore(Ag[0], Ad);
37429 Af.appendChild(Ag[0]);
37437 deleteRows : function(dm, Ah, Ai){
37438 if(dm.getRowCount()<1){
37439 this.fireEvent("beforerefresh", this);
37440 this.mainBody.update("");
37441 this.lockedBody.update("");
37442 this.fireEvent("refresh", this);
37444 this.fireEvent("beforerowsdeleted", this, Ah, Ai);
37445 var bt = this.getBodyTable();
37446 var Af = bt.firstChild;
37448 for(var a = Ah; a <= Ai; a++){
37449 Af.removeChild(Ag[Ah]);
37452 this.stripeRows(Ah);
37453 this.fireEvent("rowsdeleted", this, Ah, Ai);
37457 updateRows : function(Aj, Ak, Al){
37458 var s = this.getScrollState();
37460 this.restoreScroll(s);
37463 handleSort : function(Am, An, Ao, Ap){
37468 this.updateHeaderSortState();
37471 getScrollState : function(){
37472 var sb = this.scroller.dom;
37473 return {left: sb.scrollLeft, top: sb.scrollTop};
37476 stripeRows : function(Aq){
37477 if(!this.grid.stripeRows || this.ds.getCount() < 1){
37482 var Ar = this.getBodyTable().rows;
37483 var As = this.getLockedTable().rows;
37484 var At = ' x-grid-row-alt ';
37485 for(var i = Aq, len = Ar.length; i < len; i++){
37486 var AB = Ar[i], U = As[i];
37487 var isAlt = ((i+1) % 2 == 0);
37488 var hasAlt = (' '+AB.className + ' ').indexOf(At) != -1;
37489 if(isAlt == hasAlt){
37493 AB.className += " x-grid-row-alt";
37495 AB.className = AB.className.replace("x-grid-row-alt", "");
37498 U.className = AB.className;
37503 restoreScroll : function(Au){
37504 var sb = this.scroller.dom;
37505 sb.scrollLeft = Au.left;
37506 sb.scrollTop = Au.top;
37510 syncScroll : function(){
37511 var sb = this.scroller.dom;
37512 var sh = this.mainHd.dom;
37513 var bs = this.mainBody.dom;
37514 var lv = this.lockedBody.dom;
37515 sh.scrollLeft = bs.scrollLeft = sb.scrollLeft;
37516 lv.scrollTop = bs.scrollTop = sb.scrollTop;
37519 handleScroll : function(e){
37521 var sb = this.scroller.dom;
37522 this.grid.fireEvent("bodyscroll", sb.scrollLeft, sb.scrollTop);
37526 handleWheel : function(e){
37527 var d = e.getWheelDelta();
37528 this.scroller.dom.scrollTop -= d*22;
37530 this.lockedBody.dom.scrollTop = this.mainBody.dom.scrollTop = this.scroller.dom.scrollTop;
37534 renderRows : function(Av, Aw){
37536 var g = this.grid, cm = g.colModel, ds = g.dataSource, Ax = g.stripeRows;
37537 var Ay = cm.getColumnCount();
37539 if(ds.getCount() < 1){
37545 for(var i = 0; i < Ay; i++){
37546 var name = cm.getDataIndex(i);
37548 name : typeof name == 'undefined' ? ds.fields.get(i).name : name,
37549 renderer : cm.getRenderer(i),
37550 id : cm.getColumnId(i),
37551 locked : cm.isLocked(i)
37557 Aw = typeof Aw == "undefined"? ds.getCount()-1 : Aw;
37560 var rs = ds.getRange(Av, Aw);
37562 return this.doRender(cs, rs, ds, Av, Ay, Ax);
37568 doRender : Roo.isGecko ?
37569 function(cs, rs, ds, Az, A0, A1){
37570 var ts = this.templates, ct = ts.cell, rt = ts.row;
37572 var A2 = "", A3 = "", cb, A4, c, p = {}, rp = {}, r, a;
37573 for(var j = 0, len = rs.length; j < len; j++){
37574 r = rs[j]; cb = ""; A4 = ""; a = (j+Az);
37575 for(var i = 0; i < A0; i++){
37577 p.cellId = "x-grid-cell-" + a + "-" + i;
37579 p.css = p.attr = "";
37580 p.value = c.renderer(r.data[c.name], p, r, a, i, ds);
37581 if(p.value == undefined || p.value === "") p.value = " ";
37582 if(r.dirty && typeof r.modified[c.name] !== 'undefined'){
37583 p.css += p.css ? ' x-grid-dirty-cell' : 'x-grid-dirty-cell';
37585 var Aa = ct.apply(p);
37593 if(A1 && ((a+1) % 2 == 0)){
37594 alt[0] = "x-grid-row-alt";
37597 alt[1] = " x-grid-dirty-row";
37601 if(this.getRowClass){
37602 alt[2] = this.getRowClass(r, a);
37605 rp.alt = alt.join(" ");
37612 function(cs, rs, ds, A5, A6, A7){
37613 var ts = this.templates, ct = ts.cell, rt = ts.row;
37615 var A8 = [], A9 = [], cb, BA, c, p = {}, rp = {}, r, a;
37616 for(var j = 0, len = rs.length; j < len; j++){
37617 r = rs[j]; cb = []; BA = []; a = (j+A5);
37618 for(var i = 0; i < A6; i++){
37620 p.cellId = "x-grid-cell-" + a + "-" + i;
37622 p.css = p.attr = "";
37623 p.value = c.renderer(r.data[c.name], p, r, a, i, ds);
37624 if(p.value == undefined || p.value === "") p.value = " ";
37625 if(r.dirty && typeof r.modified[c.name] !== 'undefined'){
37626 p.css += p.css ? ' x-grid-dirty-cell' : 'x-grid-dirty-cell';
37628 var Aa = ct.apply(p);
37630 cb[cb.length] = Aa;
37632 BA[BA.length] = Aa;
37636 if(A7 && ((a+1) % 2 == 0)){
37637 alt[0] = "x-grid-row-alt";
37640 alt[1] = " x-grid-dirty-row";
37644 if(this.getRowClass){
37645 alt[2] = this.getRowClass(r, a);
37648 rp.alt = alt.join(" ");
37649 rp.cells = BA.join("");
37650 A9[A9.length] = rt.apply(rp);
37651 rp.cells = cb.join("");
37652 A8[A8.length] = rt.apply(rp);
37654 return [A9.join(""), A8.join("")];
37657 renderBody : function(){
37658 var BB = this.renderRows();
37659 var bt = this.templates.body;
37660 return [bt.apply({rows: BB[0]}), bt.apply({rows: BB[1]})];
37665 refresh : function(BC){
37666 this.fireEvent("beforerefresh", this);
37667 this.grid.stopEditing();
37668 var BD = this.renderBody();
37669 this.lockedBody.update(BD[0]);
37670 this.mainBody.update(BD[1]);
37672 this.updateHeaders();
37673 this.updateColumns();
37674 this.updateSplitters();
37675 this.updateHeaderSortState();
37678 this.syncRowHeights();
37680 this.fireEvent("refresh", this);
37683 handleColumnMove : function(cm, BE, BF){
37684 this.indexMap = null;
37685 var s = this.getScrollState();
37686 this.refresh(true);
37687 this.restoreScroll(s);
37688 this.afterMove(BF);
37691 afterMove : function(BG){
37692 if(this.enableMoveAnim && Roo.enableFx){
37693 this.fly(this.getHeaderCell(BG).firstChild).highlight(this.hlColor);
37697 updateCell : function(dm, BH, BI){
37698 var BJ = this.getColumnIndexByDataIndex(BI);
37699 if(typeof BJ == "undefined"){
37702 var cm = this.grid.colModel;
37703 var BK = this.getCell(BH, BJ);
37704 var BL = this.getCellText(BH, BJ);
37707 cellId : "x-grid-cell-" + BH + "-" + BJ,
37708 id : cm.getColumnId(BJ),
37709 css: BJ == cm.getColumnCount()-1 ? "x-grid-col-last" : ""
37711 var BM = cm.getRenderer(BJ);
37712 var BN = BM(dm.getValueAt(BH, BI), p, BH, BJ, dm);
37713 if(typeof BN == "undefined" || BN === "") BN = " ";
37715 BK.className = this.cellClass + " " + this.idToCssName(p.cellId) + " " + p.css;
37716 this.syncRowHeights(BH, BH);
37719 calcColumnWidth : function(BO, BP){
37721 if(this.grid.autoSizeHeaders){
37722 var h = this.getHeaderCellMeasure(BO);
37723 BQ = Math.max(BQ, h.scrollWidth);
37726 if(this.cm.isLocked(BO)){
37727 tb = this.getLockedTable();
37730 tb = this.getBodyTable();
37731 BR = BO - this.cm.getLockedCount();
37735 var stopIndex = Math.min(BP || Ar.length, Ar.length);
37736 for(var i = 0; i < stopIndex; i++){
37737 var BK = Ar[i].childNodes[BR].firstChild;
37738 BQ = Math.max(BQ, BK.scrollWidth);
37746 autoSizeColumn : function(BS, BT, BU){
37747 if(this.cm.isHidden(BS)){
37751 var AW = this.cm.getColumnId(BS);
37752 this.css.updateRule(this.colSelector +this.idToCssName( AW), "width", this.grid.minColumnWidth + "px");
37753 if(this.grid.autoSizeHeaders){
37754 this.css.updateRule(this.hdSelector + this.idToCssName(AW), "width", this.grid.minColumnWidth + "px");
37757 var BV = this.calcColumnWidth(BS);
37758 this.cm.setColumnWidth(BS,
37759 Math.max(this.grid.minColumnWidth, BV), BU);
37761 this.grid.fireEvent("columnresize", BS, BV);
37767 autoSizeColumns : function(){
37768 var cm = this.grid.colModel;
37769 var BW = cm.getColumnCount();
37770 for(var i = 0; i < BW; i++){
37771 this.autoSizeColumn(i, true, true);
37773 if(cm.getTotalWidth() < this.scroller.dom.clientWidth){
37776 this.updateColumns();
37783 fitColumns : function(BX){
37784 var cm = this.grid.colModel;
37785 var BY = cm.getColumnCount();
37789 for (i = 0; i < BY; i++){
37790 if(!cm.isHidden(i) && !cm.isFixed(i)){
37791 w = cm.getColumnWidth(i);
37797 var Bb = Math.min(this.scroller.dom.clientWidth, this.el.getWidth());
37801 var Bc = (Bb - cm.getTotalWidth())/Ba;
37805 cm.setColumnWidth(i, Math.floor(w + w*Bc), true);
37808 this.updateColumns();
37812 onRowSelect : function(Bd){
37813 var Be = this.getRowComposite(Bd);
37814 Be.addClass("x-grid-row-selected");
37817 onRowDeselect : function(Bf){
37818 var Bg = this.getRowComposite(Bf);
37819 Bg.removeClass("x-grid-row-selected");
37822 onCellSelect : function(Bh, Bi){
37823 var Bj = this.getCell(Bh, Bi);
37825 Roo.fly(Bj).addClass("x-grid-cell-selected");
37829 onCellDeselect : function(Bk, Bl){
37830 var Bm = this.getCell(Bk, Bl);
37832 Roo.fly(Bm).removeClass("x-grid-cell-selected");
37836 updateHeaderSortState : function(){
37837 var Bn = this.ds.getSortState();
37842 this.sortState = Bn;
37843 var Bo = this.cm.findColumnIndex(Bn.field);
37845 var Ao = Bn.direction;
37846 var sc = this.sortClasses;
37847 var hds = this.el.select(this.headerSelector).removeClass(sc);
37848 hds.item(Bo).addClass(sc[Ao == "DESC" ? 1 : 0]);
37852 handleHeaderClick : function(g, Bp){
37853 if(this.headersDisabled){
37856 var dm = g.dataSource, cm = g.colModel;
37857 if(!cm.isSortable(Bp)){
37862 dm.sort(cm.getDataIndex(Bp));
37866 destroy : function(){
37868 this.colMenu.removeAll();
37869 Roo.menu.MenuMgr.unregister(this.colMenu);
37870 this.colMenu.getEl().remove();
37871 delete this.colMenu;
37874 this.hmenu.removeAll();
37875 Roo.menu.MenuMgr.unregister(this.hmenu);
37876 this.hmenu.getEl().remove();
37879 if(this.grid.enableColumnMove){
37880 var dds = Roo.dd.DDM.ids['gridHeader' + this.grid.getGridEl().id];
37882 for(var dd in dds){
37883 if(!dds[dd].config.isTarget && dds[dd].dragElId){
37884 var elid = dds[dd].dragElId;
37886 Roo.get(elid).remove();
37887 } else if(dds[dd].config.isTarget){
37888 dds[dd].proxyTop.remove();
37889 dds[dd].proxyBottom.remove();
37892 if(Roo.dd.DDM.locationCache[dd]){
37893 delete Roo.dd.DDM.locationCache[dd];
37896 delete Roo.dd.DDM.ids['gridHeader' + this.grid.getGridEl().id];
37900 Roo.util.CSS.removeStyleSheet(this.idToCssName(this.grid.id) + '-cssrules');
37901 this.bind(null, null);
37902 Roo.EventManager.removeResizeListener(this.onWindowResize, this);
37905 handleLockChange : function(){
37906 this.refresh(true);
37909 onDenyColumnLock : function(){
37913 onDenyColumnHide : function(){
37917 handleHdMenuClick : function(Bq){
37918 var Br = this.hdCtxIndex;
37919 var cm = this.cm, ds = this.ds;
37922 ds.sort(cm.getDataIndex(Br), "ASC");
37925 ds.sort(cm.getDataIndex(Br), "DESC");
37928 var lc = cm.getLockedCount();
37929 if(cm.getColumnCount(true) <= lc+1){
37930 this.onDenyColumnLock();
37934 cm.setLocked(Br, true, true);
37935 cm.moveColumn(Br, lc);
37936 this.grid.fireEvent("columnmove", Br, lc);
37938 cm.setLocked(Br, true);
37942 var lc = cm.getLockedCount();
37944 cm.setLocked(Br, false, true);
37945 cm.moveColumn(Br, lc-1);
37946 this.grid.fireEvent("columnmove", Br, lc-1);
37948 cm.setLocked(Br, false);
37952 Br = cm.getIndexById(Bq.id.substr(4));
37954 if(Bq.checked && cm.getColumnCount(true) <= 1){
37955 this.onDenyColumnHide();
37959 cm.setHidden(Br, Bq.checked);
37965 beforeColMenuShow : function(){
37966 var cm = this.cm, Bs = cm.getColumnCount();
37967 this.colMenu.removeAll();
37968 for(var i = 0; i < Bs; i++){
37969 this.colMenu.add(new Roo.menu.CheckItem({
37970 id: "col-"+cm.getColumnId(i),
37971 text: cm.getColumnHeader(i),
37972 checked: !cm.isHidden(i),
37978 handleHdCtx : function(g, Bt, e){
37980 var hd = this.getHeaderCell(Bt);
37981 this.hdCtxIndex = Bt;
37982 var ms = this.hmenu.items, cm = this.cm;
37983 ms.get("asc").setDisabled(!cm.isSortable(Bt));
37984 ms.get("desc").setDisabled(!cm.isSortable(Bt));
37985 if(this.grid.enableColLock !== false){
37986 ms.get("lock").setDisabled(cm.isLocked(Bt));
37987 ms.get("unlock").setDisabled(!cm.isLocked(Bt));
37990 this.hmenu.show(hd, "tl-bl");
37993 handleHdOver : function(e){
37994 var hd = this.findHeaderCell(e.getTarget());
37995 if(hd && !this.headersDisabled){
37996 if(this.grid.colModel.isSortable(this.getCellIndex(hd))){
37997 this.fly(hd).addClass("x-grid-hd-over");
38002 handleHdOut : function(e){
38003 var hd = this.findHeaderCell(e.getTarget());
38005 this.fly(hd).removeClass("x-grid-hd-over");
38009 handleSplitDblClick : function(e, t){
38010 var i = this.getCellIndex(t);
38011 if(this.grid.enableColumnResize !== false && this.cm.isResizable(i) && !this.cm.isFixed(i)){
38012 this.autoSizeColumn(i, true);
38017 render : function(){
38020 var Bu = cm.getColumnCount();
38022 if(this.grid.monitorWindowResize === true){
38023 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
38025 var Bv = this.renderHeaders();
38026 var Bw = this.templates.body.apply({rows:""});
38027 var Bx = this.templates.master.apply({
38030 lockedHeader: Bv[0],
38036 this.grid.getGridEl().dom.innerHTML = Bx;
38038 this.initElements();
38040 this.scroller.on("scroll", this.handleScroll, this);
38041 this.lockedBody.on("mousewheel", this.handleWheel, this);
38042 this.mainBody.on("mousewheel", this.handleWheel, this);
38044 this.mainHd.on("mouseover", this.handleHdOver, this);
38045 this.mainHd.on("mouseout", this.handleHdOut, this);
38046 this.mainHd.on("dblclick", this.handleSplitDblClick, this,
38047 {delegate: "."+this.splitClass});
38049 this.lockedHd.on("mouseover", this.handleHdOver, this);
38050 this.lockedHd.on("mouseout", this.handleHdOut, this);
38051 this.lockedHd.on("dblclick", this.handleSplitDblClick, this,
38052 {delegate: "."+this.splitClass});
38054 if(this.grid.enableColumnResize !== false && Roo.grid.SplitDragZone){
38055 new Roo.grid.SplitDragZone(this.grid, this.lockedHd.dom, this.mainHd.dom);
38059 this.updateSplitters();
38061 if(this.grid.enableColumnMove && Roo.grid.HeaderDragZone){
38062 new Roo.grid.HeaderDragZone(this.grid, this.lockedHd.dom, this.mainHd.dom);
38063 new Roo.grid.HeaderDropZone(this.grid, this.lockedHd.dom, this.mainHd.dom);
38066 if(this.grid.enableCtxMenu !== false && Roo.menu.Menu){
38067 this.hmenu = new Roo.menu.Menu({id: this.grid.id + "-hctx"});
38069 {id:"asc", text: this.sortAscText, cls: "xg-hmenu-sort-asc"},
38070 {id:"desc", text: this.sortDescText, cls: "xg-hmenu-sort-desc"}
38072 if(this.grid.enableColLock !== false){
38073 this.hmenu.add('-',
38074 {id:"lock", text: this.lockText, cls: "xg-hmenu-lock"},
38075 {id:"unlock", text: this.unlockText, cls: "xg-hmenu-unlock"}
38078 if(this.grid.enableColumnHide !== false){
38080 this.colMenu = new Roo.menu.Menu({id:this.grid.id + "-hcols-menu"});
38081 this.colMenu.on("beforeshow", this.beforeColMenuShow, this);
38082 this.colMenu.on("itemclick", this.handleHdMenuClick, this);
38084 this.hmenu.add('-',
38085 {id:"columns", text: this.columnsText, menu: this.colMenu}
38089 this.hmenu.on("itemclick", this.handleHdMenuClick, this);
38091 this.grid.on("headercontextmenu", this.handleHdCtx, this);
38094 if((this.grid.enableDragDrop || this.grid.enableDrag) && Roo.grid.GridDragZone){
38095 this.dd = new Roo.grid.GridDragZone(this.grid, {
38096 ddGroup : this.grid.ddGroup || 'GridDD'
38104 this.updateHeaderSortState();
38106 this.beforeInitialResize();
38110 this.renderPhase2.defer(1, this);
38113 renderPhase2 : function(){
38116 if(this.grid.autoSizeColumns){
38117 this.autoSizeColumns();
38121 beforeInitialResize : function(){
38125 onColumnSplitterMoved : function(i, w){
38126 this.userResized = true;
38127 var cm = this.grid.colModel;
38128 cm.setColumnWidth(i, w, true);
38129 var By = cm.getColumnId(i);
38130 this.css.updateRule(this.colSelector + this.idToCssName(By), "width", (w-this.borderWidth) + "px");
38131 this.css.updateRule(this.hdSelector + this.idToCssName(By), "width", (w-this.borderWidth) + "px");
38132 this.updateSplitters();
38134 this.grid.fireEvent("columnresize", i, w);
38137 syncRowHeights : function(Bz, B0){
38138 if(this.grid.enableRowHeightSync === true && this.cm.getLockedCount() > 0){
38140 var mrows = this.getBodyTable().rows;
38141 var As = this.getLockedTable().rows;
38142 var len = mrows.length-1;
38143 B0 = Math.min(B0 || len, len);
38144 for(var i = Bz; i <= B0; i++){
38145 var m = mrows[i], l = As[i];
38146 var h = Math.max(m.offsetHeight, l.offsetHeight);
38147 m.style.height = l.style.height = h + "px";
38152 layout : function(B1, B2){
38154 var B3 = g.autoHeight;
38156 var c = g.getGridEl(), cm = this.cm,
38157 B5 = g.autoExpandColumn,
38161 if(!c.dom.offsetWidth){
38163 this.lockedWrap.show();
38164 this.mainWrap.show();
38169 var B6 = this.cm.isLocked(0);
38171 var B7 = this.headerPanel.getHeight();
38172 var B8 = this.footerPanel.getHeight();
38175 var ch = this.getBodyTable().offsetHeight + B7 + B8 + this.mainHd.getHeight();
38176 var newHeight = ch + c.getBorderWidth("tb");
38178 newHeight = Math.min(g.maxHeight, newHeight);
38181 c.setHeight(newHeight);
38185 c.setWidth(cm.getTotalWidth()+c.getBorderWidth('lr'));
38188 var s = this.scroller;
38190 var B9 = c.getSize(true);
38192 this.el.setSize(B9.width, B9.height);
38194 this.headerPanel.setWidth(B9.width);
38195 this.footerPanel.setWidth(B9.width);
38197 var CA = this.mainHd.getHeight();
38199 var vh = B9.height - (B7 + B8);
38203 var bt = this.getBodyTable();
38205 Math.max(this.getLockedTable().offsetWidth, this.lockedHd.dom.firstChild.offsetWidth) : 0;
38207 var CC = bt.offsetHeight;
38208 var CD = CB + bt.offsetWidth;
38209 var CE = false, CF = false;
38211 this.scrollSizer.setSize(CD, CC+CA);
38213 var lw = this.lockedWrap, mw = this.mainWrap;
38214 var lb = this.lockedBody, mb = this.mainBody;
38216 setTimeout(function(){
38217 var t = s.dom.offsetTop;
38218 var w = s.dom.clientWidth,
38219 h = s.dom.clientHeight;
38224 mw.setLeftTop(CB, t);
38225 mw.setSize(w-CB, h);
38227 lb.setHeight(h-CA);
38228 mb.setHeight(h-CA);
38230 if(B2 !== true && !gv.userResized && B5){
38233 var ci = cm.getIndexById(B5);
38235 ci = cm.findColumnIndex(B5);
38238 ci = Math.max(0, ci);
38239 var expandId = cm.getColumnId(ci);
38240 var tw = cm.getTotalWidth(false);
38241 var currentWidth = cm.getColumnWidth(ci);
38242 var cw = Math.min(Math.max(((w-tw)+currentWidth-2)-
38243 (w <= s.dom.offsetWidth ? 0 : 18), g.autoExpandMin), g.autoExpandMax);
38244 if(currentWidth != cw){
38245 cm.setColumnWidth(ci, cw, true);
38246 gv.css.updateRule(gv.colSelector+gv.idToCssName(expandId), "width", (cw - gv.borderWidth) + "px");
38247 gv.css.updateRule(gv.hdSelector+gv.idToCssName(expandId), "width", (cw - gv.borderWidth) + "px");
38248 gv.updateSplitters();
38249 gv.layout(false, true);
38261 onWindowResize : function(){
38262 if(!this.grid.monitorWindowResize || this.grid.autoHeight){
38269 appendFooter : function(CG){
38273 sortAscText : "Sort Ascending",
38274 sortDescText : "Sort Descending",
38275 lockText : "Lock Column",
38276 unlockText : "Unlock Column",
38277 columnsText : "Columns"
38281 Roo.grid.GridView.ColumnDragZone = function(CH, hd){
38282 Roo.grid.GridView.ColumnDragZone.superclass.constructor.call(this, CH, hd, null);
38283 this.proxy.el.addClass('x-grid3-col-dd');
38286 Roo.extend(Roo.grid.GridView.ColumnDragZone, Roo.grid.HeaderDragZone, {
38287 handleMouseDown : function(e){
38291 callHandleMouseDown : function(e){
38292 Roo.grid.GridView.ColumnDragZone.superclass.handleMouseDown.call(this, e);
38301 Roo.grid.SplitDragZone = function(A, hd, B){
38303 this.view = A.getView();
38304 this.proxy = this.view.resizeProxy;
38305 Roo.grid.SplitDragZone.superclass.constructor.call(this, hd,
38306 "gridSplitters" + this.grid.getGridEl().id, {
38307 dragElId : Roo.id(this.proxy.dom), resizeFrame:false
38309 this.setHandleElId(Roo.id(hd));
38310 this.setOuterHandleElId(Roo.id(B));
38311 this.scroll = false;
38313 Roo.extend(Roo.grid.SplitDragZone, Roo.dd.DDProxy, {
38314 fly: Roo.Element.fly,
38316 b4StartDrag : function(x, y){
38317 this.view.headersDisabled = true;
38318 this.proxy.setHeight(this.view.mainWrap.getHeight());
38319 var w = this.cm.getColumnWidth(this.cellIndex);
38320 var C = Math.max(w-this.grid.minColumnWidth, 0);
38321 this.resetConstraints();
38322 this.setXConstraint(C, 1000);
38323 this.setYConstraint(0, 0);
38325 this.maxX = x + 1000;
38327 Roo.dd.DDProxy.prototype.b4StartDrag.call(this, x, y);
38331 handleMouseDown : function(e){
38332 ev = Roo.EventObject.setEvent(e);
38333 var t = this.fly(ev.getTarget());
38334 if(t.hasClass("x-grid-split")){
38335 this.cellIndex = this.view.getCellIndex(t.dom);
38336 this.split = t.dom;
38337 this.cm = this.grid.colModel;
38338 if(this.cm.isResizable(this.cellIndex) && !this.cm.isFixed(this.cellIndex)){
38339 Roo.grid.SplitDragZone.superclass.handleMouseDown.apply(this, arguments);
38344 endDrag : function(e){
38345 this.view.headersDisabled = false;
38346 var D = Math.max(this.minX, Roo.lib.Event.getPageX(e));
38347 var E = D - this.startPos;
38348 this.view.onColumnSplitterMoved(this.cellIndex, this.cm.getColumnWidth(this.cellIndex)+E);
38351 autoOffset : function(){
38352 this.setDelta(0,0);
38360 Roo.grid.GridDragZone = function(A, B){
38361 this.view = A.getView();
38362 Roo.grid.GridDragZone.superclass.constructor.call(this, this.view.mainBody.dom, B);
38363 if(this.view.lockedBody){
38364 this.setHandleElId(Roo.id(this.view.mainBody.dom));
38365 this.setOuterHandleElId(Roo.id(this.view.lockedBody.dom));
38368 this.scroll = false;
38370 this.ddel = document.createElement('div');
38371 this.ddel.className = 'x-grid-dd-wrap';
38374 Roo.extend(Roo.grid.GridDragZone, Roo.dd.DragZone, {
38375 ddGroup : "GridDD",
38377 getDragData : function(e){
38378 var t = Roo.lib.Event.getTarget(e);
38379 var C = this.view.findRowIndex(t);
38381 var sm = this.grid.selModel;
38385 if (e.hasModifier()){
38386 sm.handleMouseDown(e, t);
38388 return {grid: this.grid, ddel: this.ddel, rowIndex: C, selections:sm.getSelections()};
38393 onInitDrag : function(e){
38394 var D = this.dragData;
38395 this.ddel.innerHTML = this.grid.getDragDropText();
38396 this.proxy.update(this.ddel);
38400 afterRepair : function(){
38401 this.dragging = false;
38404 getRepairXY : function(e, E){
38408 onEndDrag : function(F, e){
38412 onValidDrop : function(dd, e, id){
38417 beforeInvalidDrop : function(e, id){
38427 Roo.grid.ColumnModel = function(A){
38436 for(var i = 0, len = A.length; i < len; i++){
38438 if(typeof c.dataIndex == "undefined"){
38441 if(typeof c.renderer == "string"){
38442 c.renderer = Roo.util.Format[c.renderer];
38444 if(typeof c.id == "undefined"){
38447 if(c.editor && c.editor.xtype){
38448 c.editor = Roo.factory(c.editor, Roo.grid);
38450 if(c.editor && c.editor.isFormField){
38451 c.editor = new Roo.grid.GridEditor(c.editor);
38454 this.lookup[c.id] = c;
38460 this.defaultWidth = 100;
38464 this.defaultSortable = false;
38469 "widthchange": true,
38472 "headerchange": true,
38475 "hiddenchange": true,
38478 "columnmoved" : true,
38481 "columnlockchange" : true
38483 Roo.grid.ColumnModel.superclass.constructor.call(this);
38485 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
38511 getColumnId : function(B){
38512 return this.config[B].id;
38517 getColumnById : function(id){
38518 return this.lookup[id];
38523 getIndexById : function(id){
38524 for(var i = 0, len = this.config.length; i < len; i++){
38525 if(this.config[i].id == id){
38534 findColumnIndex : function(C){
38535 for(var i = 0, len = this.config.length; i < len; i++){
38536 if(this.config[i].dataIndex == C){
38544 moveColumn : function(D, E){
38545 var c = this.config[D];
38546 this.config.splice(D, 1);
38547 this.config.splice(E, 0, c);
38548 this.dataMap = null;
38549 this.fireEvent("columnmoved", this, D, E);
38552 isLocked : function(F){
38553 return this.config[F].locked === true;
38556 setLocked : function(G, H, I){
38557 if(this.isLocked(G) == H){
38561 this.config[G].locked = H;
38563 this.fireEvent("columnlockchange", this, G, H);
38567 getTotalLockedWidth : function(){
38569 for(var i = 0; i < this.config.length; i++){
38570 if(this.isLocked(i) && !this.isHidden(i)){
38571 this.totalWidth += this.getColumnWidth(i);
38577 getLockedCount : function(){
38578 for(var i = 0, len = this.config.length; i < len; i++){
38579 if(!this.isLocked(i)){
38587 getColumnCount : function(K){
38590 for(var i = 0, len = this.config.length; i < len; i++){
38591 if(!this.isHidden(i)){
38597 return this.config.length;
38602 getColumnsBy : function(fn, L){
38604 for(var i = 0, len = this.config.length; i < len; i++){
38605 var c = this.config[i];
38606 if(fn.call(L||this, c, i) === true){
38615 isSortable : function(M){
38616 if(typeof this.config[M].sortable == "undefined"){
38617 return this.defaultSortable;
38619 return this.config[M].sortable;
38624 getRenderer : function(N){
38625 if(!this.config[N].renderer){
38626 return Roo.grid.ColumnModel.defaultRenderer;
38628 return this.config[N].renderer;
38633 setRenderer : function(O, fn){
38634 this.config[O].renderer = fn;
38639 getColumnWidth : function(P){
38640 return this.config[P].width || this.defaultWidth;
38645 setColumnWidth : function(Q, R, S){
38646 this.config[Q].width = R;
38647 this.totalWidth = null;
38649 this.fireEvent("widthchange", this, Q, R);
38655 getTotalWidth : function(T){
38656 if(!this.totalWidth){
38657 this.totalWidth = 0;
38658 for(var i = 0, len = this.config.length; i < len; i++){
38659 if(T || !this.isHidden(i)){
38660 this.totalWidth += this.getColumnWidth(i);
38664 return this.totalWidth;
38669 getColumnHeader : function(U){
38670 return this.config[U].header;
38675 setColumnHeader : function(V, W){
38676 this.config[V].header = W;
38677 this.fireEvent("headerchange", this, V, W);
38682 getColumnTooltip : function(X){
38683 return this.config[X].tooltip;
38687 setColumnTooltip : function(Y, Z){
38688 this.config[Y].tooltip = Z;
38693 getDataIndex : function(a){
38694 return this.config[a].dataIndex;
38699 setDataIndex : function(b, d){
38700 this.config[b].dataIndex = d;
38707 isCellEditable : function(e, f){
38708 return (this.config[e].editable || (typeof this.config[e].editable == "undefined" && this.config[e].editor)) ? true : false;
38713 getCellEditor : function(g, h){
38714 return this.config[g].editor;
38719 setEditable : function(j, k){
38720 this.config[j].editable = k;
38726 isHidden : function(l){
38727 return this.config[l].hidden;
38733 isFixed : function(m){
38734 return this.config[m].fixed;
38739 isResizable : function(n){
38740 return n >= 0 && this.config[n].resizable !== false && this.config[n].fixed !== true;
38744 setHidden : function(o, p){
38745 this.config[o].hidden = p;
38746 this.totalWidth = null;
38747 this.fireEvent("hiddenchange", this, o, p);
38752 setEditor : function(q, s){
38753 this.config[q].editor = s;
38757 Roo.grid.ColumnModel.defaultRenderer = function(t){
38758 if(typeof t == "string" && t.length < 1){
38765 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
38772 Roo.grid.AbstractSelectionModel = function(){
38773 this.locked = false;
38774 Roo.grid.AbstractSelectionModel.superclass.constructor.call(this);
38777 Roo.extend(Roo.grid.AbstractSelectionModel, Roo.util.Observable, {
38780 init : function(A){
38788 this.locked = true;
38793 unlock : function(){
38794 this.locked = false;
38799 isLocked : function(){
38800 return this.locked;
38807 Roo.grid.RowSelectionModel = function(A){
38808 Roo.apply(this, A);
38809 this.selections = new Roo.util.MixedCollection(false, function(o){
38814 this.lastActive = false;
38819 "selectionchange" : true,
38822 "afterselectionchange" : true,
38825 "beforerowselect" : true,
38828 "rowselect" : true,
38831 "rowdeselect" : true
38833 Roo.grid.RowSelectionModel.superclass.constructor.call(this);
38834 this.locked = false;
38837 Roo.extend(Roo.grid.RowSelectionModel, Roo.grid.AbstractSelectionModel, {
38840 singleSelect : false,
38843 initEvents : function(){
38845 if(!this.grid.enableDragDrop && !this.grid.enableDrag){
38846 this.grid.on("mousedown", this.handleMouseDown, this);
38848 this.grid.on("rowclick", this.handleDragableRowClick, this);
38852 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
38853 "up" : function(e){
38855 this.selectPrevious(e.shiftKey);
38856 }else if(this.last !== false && this.lastActive !== false){
38857 var last = this.last;
38858 this.selectRange(this.last, this.lastActive-1);
38859 this.grid.getView().focusRow(this.lastActive);
38860 if(last !== false){
38864 this.selectFirstRow();
38867 this.fireEvent("afterselectionchange", this);
38869 "down" : function(e){
38871 this.selectNext(e.shiftKey);
38872 }else if(this.last !== false && this.lastActive !== false){
38873 var last = this.last;
38874 this.selectRange(this.last, this.lastActive+1);
38875 this.grid.getView().focusRow(this.lastActive);
38876 if(last !== false){
38880 this.selectFirstRow();
38883 this.fireEvent("afterselectionchange", this);
38888 var B = this.grid.view;
38889 B.on("refresh", this.onRefresh, this);
38890 B.on("rowupdated", this.onRowUpdated, this);
38891 B.on("rowremoved", this.onRemove, this);
38895 onRefresh : function(){
38896 var ds = this.grid.dataSource, i, v = this.grid.view;
38897 var s = this.selections;
38898 s.each(function(r){
38899 if((i = ds.indexOfId(r.id)) != -1){
38908 onRemove : function(v, C, r){
38909 this.selections.remove(r);
38913 onRowUpdated : function(v, D, r){
38914 if(this.isSelected(r)){
38921 selectRecords : function(E, F){
38923 this.clearSelections();
38925 var ds = this.grid.dataSource;
38926 for(var i = 0, len = E.length; i < len; i++){
38927 this.selectRow(ds.indexOf(E[i]), true);
38933 getCount : function(){
38934 return this.selections.length;
38939 selectFirstRow : function(){
38945 selectLastRow : function(G){
38946 this.selectRow(this.grid.dataSource.getCount() - 1, G);
38951 selectNext : function(H){
38952 if(this.last !== false && (this.last+1) < this.grid.dataSource.getCount()){
38953 this.selectRow(this.last+1, H);
38954 this.grid.getView().focusRow(this.last);
38960 selectPrevious : function(I){
38962 this.selectRow(this.last-1, I);
38963 this.grid.getView().focusRow(this.last);
38969 getSelections : function(){
38970 return [].concat(this.selections.items);
38975 getSelected : function(){
38976 return this.selections.itemAt(0);
38982 clearSelections : function(J){
38983 if(this.locked) return;
38985 var ds = this.grid.dataSource;
38986 var s = this.selections;
38987 s.each(function(r){
38988 this.deselectRow(ds.indexOfId(r.id));
38992 this.selections.clear();
39001 selectAll : function(){
39002 if(this.locked) return;
39003 this.selections.clear();
39004 for(var i = 0, len = this.grid.dataSource.getCount(); i < len; i++){
39005 this.selectRow(i, true);
39011 hasSelection : function(){
39012 return this.selections.length > 0;
39017 isSelected : function(K){
39018 var r = typeof K == "number" ? this.grid.dataSource.getAt(K) : K;
39019 return (r && this.selections.key(r.id) ? true : false);
39024 isIdSelected : function(id){
39025 return (this.selections.key(id) ? true : false);
39029 handleMouseDown : function(e, t){
39030 var L = this.grid.getView(), M;
39031 if(this.isLocked() || (M = L.findRowIndex(t)) === false){
39034 if(e.shiftKey && this.last !== false){
39035 var last = this.last;
39036 this.selectRange(last, M, e.ctrlKey);
39040 var isSelected = this.isSelected(M);
39041 if(e.button !== 0 && isSelected){
39043 }else if(e.ctrlKey && isSelected){
39044 this.deselectRow(M);
39045 }else if(!isSelected){
39046 this.selectRow(M, e.button === 0 && (e.ctrlKey || e.shiftKey));
39051 this.fireEvent("afterselectionchange", this);
39054 handleDragableRowClick : function(N, O, e)
39056 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
39057 this.selectRow(O, false);
39058 N.view.focusRow(O);
39059 this.fireEvent("afterselectionchange", this);
39065 selectRows : function(P, Q){
39067 this.clearSelections();
39069 for(var i = 0, len = P.length; i < len; i++){
39070 this.selectRow(P[i], true);
39076 selectRange : function(R, S, T){
39077 if(this.locked) return;
39079 this.clearSelections();
39082 for(var i = R; i <= S; i++){
39083 this.selectRow(i, true);
39086 for(var i = R; i >= S; i--){
39087 this.selectRow(i, true);
39094 deselectRange : function(U, V, W){
39095 if(this.locked) return;
39096 for(var i = U; i <= V; i++){
39097 this.deselectRow(i, W);
39103 selectRow : function(X, Y, Z){
39104 if(this.locked || (X < 0 || X >= this.grid.dataSource.getCount())) return;
39105 if(this.fireEvent("beforerowselect", this, X, Y) !== false){
39106 if(!Y || this.singleSelect){
39107 this.clearSelections();
39109 var r = this.grid.dataSource.getAt(X);
39110 this.selections.add(r);
39111 this.last = this.lastActive = X;
39113 this.grid.getView().onRowSelect(X);
39116 this.fireEvent("rowselect", this, X, r);
39117 this.fireEvent("selectionchange", this);
39123 deselectRow : function(a, b){
39124 if(this.locked) return;
39125 if(this.last == a){
39128 if(this.lastActive == a){
39129 this.lastActive = false;
39131 var r = this.grid.dataSource.getAt(a);
39132 this.selections.remove(r);
39134 this.grid.getView().onRowDeselect(a);
39137 this.fireEvent("rowdeselect", this, a);
39138 this.fireEvent("selectionchange", this);
39142 restoreLast : function(){
39144 this.last = this._last;
39149 acceptsNav : function(c, d, cm){
39150 return !cm.isHidden(d) && cm.isCellEditable(d, c);
39154 onEditorKey : function(f, e){
39155 var k = e.getKey(), h, g = this.grid, ed = g.activeEditor;
39160 h = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
39162 h = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
39164 }else if(k == e.ENTER && !e.ctrlKey){
39168 h = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
39170 h = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
39172 }else if(k == e.ESC){
39176 g.startEditing(h[0], h[1]);
39184 Roo.grid.CellSelectionModel = function(A){
39185 Roo.apply(this, A);
39187 this.selection = null;
39192 "beforecellselect" : true,
39195 "cellselect" : true,
39198 "selectionchange" : true
39200 Roo.grid.CellSelectionModel.superclass.constructor.call(this);
39203 Roo.extend(Roo.grid.CellSelectionModel, Roo.grid.AbstractSelectionModel, {
39207 initEvents : function(){
39208 this.grid.on("mousedown", this.handleMouseDown, this);
39209 this.grid.getGridEl().on(Roo.isIE ? "keydown" : "keypress", this.handleKeyDown, this);
39210 var B = this.grid.view;
39211 B.on("refresh", this.onViewChange, this);
39212 B.on("rowupdated", this.onRowUpdated, this);
39213 B.on("beforerowremoved", this.clearSelections, this);
39214 B.on("beforerowsinserted", this.clearSelections, this);
39215 if(this.grid.isEditor){
39216 this.grid.on("beforeedit", this.beforeEdit, this);
39221 beforeEdit : function(e){
39222 this.select(e.row, e.column, false, true, e.record);
39226 onRowUpdated : function(v, C, r){
39227 if(this.selection && this.selection.record == r){
39228 v.onCellSelect(C, this.selection.cell[1]);
39233 onViewChange : function(){
39234 this.clearSelections(true);
39239 getSelectedCell : function(){
39240 return this.selection ? this.selection.cell : null;
39245 clearSelections : function(D){
39246 var s = this.selection;
39249 this.grid.view.onCellDeselect(s.cell[0], s.cell[1]);
39252 this.selection = null;
39253 this.fireEvent("selectionchange", this, null);
39259 hasSelection : function(){
39260 return this.selection ? true : false;
39265 handleMouseDown : function(e, t){
39266 var v = this.grid.getView();
39267 if(this.isLocked()){
39270 var E = v.findRowIndex(t);
39271 var F = v.findCellIndex(t);
39272 if(E !== false && F !== false){
39279 select : function(G, H, I, J,
39281 if(this.fireEvent("beforecellselect", this, G, H) !== false){
39282 this.clearSelections();
39283 r = r || this.grid.dataSource.getAt(G);
39289 var v = this.grid.getView();
39290 v.onCellSelect(G, H);
39296 this.fireEvent("cellselect", this, G, H);
39297 this.fireEvent("selectionchange", this, this.selection);
39302 isSelectable : function(K, L, cm){
39303 return !cm.isHidden(L);
39308 handleKeyDown : function(e){
39309 if(!e.isNavKeyPress()){
39312 var g = this.grid, s = this.selection;
39315 var F = g.walkCells(0, 0, 1, this.isSelectable, this);
39317 this.select(F[0], F[1]);
39322 var M = function(O, P, Q){
39323 return g.walkCells(O, P, Q, sm.isSelectable, sm);
39325 var k = e.getKey(), r = s.cell[0], c = s.cell[1];
39349 if(g.isEditor && !g.editing){
39350 g.startEditing(r, c);
39357 this.select(N[0], N[1]);
39362 acceptsNav : function(O, P, cm){
39363 return !cm.isHidden(P) && cm.isCellEditable(P, O);
39366 onEditorKey : function(Q, e){
39367 var k = e.getKey(), R, g = this.grid, ed = g.activeEditor;
39370 R = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
39372 R = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
39376 }else if(k == e.ENTER && !e.ctrlKey){
39379 }else if(k == e.ESC){
39383 g.startEditing(R[0], R[1]);
39392 Roo.grid.EditorGrid = function(A, B){
39393 Roo.grid.EditorGrid.superclass.constructor.call(this, A, B);
39394 this.getGridEl().addClass("xedit-grid");
39396 if(!this.selModel){
39397 this.selModel = new Roo.grid.CellSelectionModel();
39401 this.activeEditor = null;
39406 "beforeedit" : true,
39409 "afteredit" : true,
39412 "validateedit" : true
39414 this.on("bodyscroll", this.stopEditing, this);
39415 this.on(this.clicksToEdit == 1 ? "cellclick" : "celldblclick", this.onCellDblClick, this);
39418 Roo.extend(Roo.grid.EditorGrid, Roo.grid.Grid, {
39426 trackMouseOver: false,
39428 onCellDblClick : function(g, C, D){
39429 this.startEditing(C, D);
39432 onEditComplete : function(ed, E, F){
39433 this.editing = false;
39434 this.activeEditor = null;
39435 ed.un("specialkey", this.selModel.onEditorKey, this.selModel);
39437 var G = this.colModel.getDataIndex(ed.col);
39449 if(String(E) !== String(F)){
39451 if(this.fireEvent("validateedit", e) !== false && !e.cancel){
39454 this.fireEvent("afteredit", e);
39457 this.fireEvent("afteredit", e);
39460 this.view.focusCell(ed.row, ed.col);
39465 startEditing : function(H, I){
39466 this.stopEditing();
39467 if(this.colModel.isCellEditable(I, H)){
39468 this.view.ensureVisible(H, I, true);
39469 var r = this.dataSource.getAt(H);
39470 var G = this.colModel.getDataIndex(I);
39480 if(this.fireEvent("beforeedit", e) !== false && !e.cancel){
39481 this.editing = true;
39482 var ed = this.colModel.getCellEditor(I, H);
39488 ed.render(ed.parentEl || document.body);
39496 ed.on("complete", this.onEditComplete, this, {single: true});
39497 ed.on("specialkey", this.selModel.onEditorKey, this.selModel);
39498 this.activeEditor = ed;
39500 ed.startEdit(this.view.getCell(H, I), v);
39501 }).defer(50, this);
39508 stopEditing : function(){
39509 if(this.activeEditor){
39510 this.activeEditor.completeEdit();
39513 this.activeEditor = null;
39524 Roo.grid.GridEditor = function(A, B){
39525 if (!B && A.field) {
39527 A = Roo.factory(B.field, Roo.form);
39530 Roo.grid.GridEditor.superclass.constructor.call(this, A, B);
39531 A.monitorTab = false;
39534 Roo.extend(Roo.grid.GridEditor, Roo.Editor, {
39539 alignment: "tl-tl",
39542 cls: "x-small-editor x-grid-editor",
39551 Roo.grid.PropertyRecord = Roo.data.Record.create([
39552 {name:'name',type:'string'}, 'value'
39556 Roo.grid.PropertyStore = function(A, B){
39558 this.store = new Roo.data.Store({
39559 recordType : Roo.grid.PropertyRecord
39561 this.store.on('update', this.onUpdate, this);
39566 Roo.grid.PropertyStore.superclass.constructor.call(this);
39571 Roo.extend(Roo.grid.PropertyStore, Roo.util.Observable, {
39572 setSource : function(o){
39574 this.store.removeAll();
39577 if(this.isEditableValue(o[k])){
39578 C.push(new Roo.grid.PropertyRecord({name: k, value: o[k]}, k));
39582 this.store.loadRecords({records: C}, {}, true);
39585 onUpdate : function(ds, D, E){
39586 if(E == Roo.data.Record.EDIT){
39587 var v = D.data['value'];
39588 var oldValue = D.modified['value'];
39589 if(this.grid.fireEvent('beforepropertychange', this.source, D.id, v, oldValue) !== false){
39590 this.source[D.id] = v;
39592 this.grid.fireEvent('propertychange', this.source, D.id, v, oldValue);
39599 getProperty : function(F){
39600 return this.store.getAt(F);
39603 isEditableValue: function(G){
39604 if(G && G instanceof Date){
39606 }else if(typeof G == 'object' || typeof G == 'function'){
39612 setValue : function(H, I){
39613 this.source[H] = I;
39614 this.store.getById(H).set('value', I);
39617 getSource : function(){
39618 return this.source;
39622 Roo.grid.PropertyColumnModel = function(J, K){
39625 g.PropertyColumnModel.superclass.constructor.call(this, [
39626 {header: this.nameText, sortable: true, dataIndex:'name', id: 'name'},
39627 {header: this.valueText, resizable:false, dataIndex: 'value', id: 'value'}
39630 this.bselect = Roo.DomHelper.append(document.body, {
39631 tag: 'select', style:'display:none', cls: 'x-grid-editor', children: [
39632 {tag: 'option', value: 'true', html: 'true'},
39633 {tag: 'option', value: 'false', html: 'false'}
39636 Roo.id(this.bselect);
39639 'date' : new g.GridEditor(new f.DateField({selectOnFocus:true})),
39640 'string' : new g.GridEditor(new f.TextField({selectOnFocus:true})),
39641 'number' : new g.GridEditor(new f.NumberField({selectOnFocus:true, style:'text-align:left;'})),
39642 'int' : new g.GridEditor(new f.NumberField({selectOnFocus:true, allowDecimals:false, style:'text-align:left;'})),
39643 'boolean' : new g.GridEditor(new f.Field({el:this.bselect,selectOnFocus:true}))
39645 this.renderCellDelegate = this.renderCell.createDelegate(this);
39646 this.renderPropDelegate = this.renderProp.createDelegate(this);
39649 Roo.extend(Roo.grid.PropertyColumnModel, Roo.grid.ColumnModel, {
39653 valueText : 'Value',
39655 dateFormat : 'm/j/Y',
39658 renderDate : function(L){
39659 return L.dateFormat(this.dateFormat);
39662 renderBool : function(M){
39663 return M ? 'true' : 'false';
39666 isCellEditable : function(N, O){
39670 getRenderer : function(P){
39672 this.renderCellDelegate : this.renderPropDelegate;
39675 renderProp : function(v){
39676 return this.getPropertyName(v);
39679 renderCell : function(Q){
39681 if(Q instanceof Date){
39682 rv = this.renderDate(Q);
39683 }else if(typeof Q == 'boolean'){
39684 rv = this.renderBool(Q);
39686 return Roo.util.Format.htmlEncode(rv);
39689 getPropertyName : function(R){
39690 var pn = this.grid.propertyNames;
39691 return pn && pn[R] ? pn[R] : R;
39694 getCellEditor : function(S, T){
39695 var p = this.store.getProperty(T);
39696 var n = p.data['name'], U = p.data['value'];
39698 if(typeof(this.grid.customEditors[n]) == 'string'){
39699 return this.editors[this.grid.customEditors[n]];
39701 if(typeof(this.grid.customEditors[n]) != 'undefined'){
39702 return this.grid.customEditors[n];
39704 if(U instanceof Date){
39705 return this.editors['date'];
39706 }else if(typeof U == 'number'){
39707 return this.editors['number'];
39708 }else if(typeof U == 'boolean'){
39709 return this.editors['boolean'];
39711 return this.editors['string'];
39718 Roo.grid.PropertyGrid = function(V, W){
39720 var X = new Roo.grid.PropertyStore(this);
39722 var cm = new Roo.grid.PropertyColumnModel(this, X);
39723 X.store.sort('name', 'ASC');
39724 Roo.grid.PropertyGrid.superclass.constructor.call(this, V, Roo.apply({
39727 enableColLock:false,
39728 enableColumnMove:false,
39730 trackMouseOver: false,
39733 this.getGridEl().addClass('x-props-grid');
39734 this.lastEditRow = null;
39735 this.on('columnresize', this.onColumnResize, this);
39739 "beforepropertychange": true,
39742 "propertychange": true
39744 this.customEditors = this.customEditors || {};
39746 Roo.extend(Roo.grid.PropertyGrid, Roo.grid.EditorGrid, {
39754 render : function(){
39755 Roo.grid.PropertyGrid.superclass.render.call(this);
39756 this.autoSize.defer(100, this);
39759 autoSize : function(){
39760 Roo.grid.PropertyGrid.superclass.autoSize.call(this);
39762 this.view.fitColumns();
39766 onColumnResize : function(){
39767 this.colModel.setColumnWidth(1, this.container.getWidth(true)-this.colModel.getColumnWidth(0));
39772 setSource : function(Y){
39773 this.store.setSource(Y);
39778 getSource : function(){
39779 return this.store.getSource();
39787 Roo.LoadMask = function(el, A){
39788 this.el = Roo.get(el);
39789 Roo.apply(this, A);
39791 this.store.on('beforeload', this.onBeforeLoad, this);
39792 this.store.on('load', this.onLoad, this);
39793 this.store.on('loadexception', this.onLoad, this);
39794 this.removeMask = false;
39796 var um = this.el.getUpdateManager();
39797 um.showLoadIndicator = false;
39798 um.on('beforeupdate', this.onBeforeLoad, this);
39799 um.on('update', this.onLoad, this);
39800 um.on('failure', this.onLoad, this);
39801 this.removeMask = true;
39805 Roo.LoadMask.prototype = {
39810 msg : 'Loading...',
39813 msgCls : 'x-mask-loading',
39821 disable : function(){
39822 this.disabled = true;
39827 enable : function(){
39828 this.disabled = false;
39832 onLoad : function(){
39833 this.el.unmask(this.removeMask);
39837 onBeforeLoad : function(){
39838 if(!this.disabled){
39839 this.el.mask(this.msg, this.msgCls);
39844 destroy : function(){
39846 this.store.un('beforeload', this.onBeforeLoad, this);
39847 this.store.un('load', this.onLoad, this);
39848 this.store.un('loadexception', this.onLoad, this);
39850 var um = this.el.getUpdateManager();
39851 um.un('beforeupdate', this.onBeforeLoad, this);
39852 um.un('update', this.onLoad, this);
39853 um.un('failure', this.onLoad, this);
39859 Roo.XTemplate = function(){
39860 Roo.XTemplate.superclass.constructor.apply(this, arguments);
39863 s = ['<tpl>', s, '</tpl>'].join('');
39865 var re = /<tpl\b[^>]*>((?:(?=([^<]+))\2|<(?!tpl\b[^>]*>))*?)<\/tpl>/;
39867 var A = /^<tpl\b[^>]*?for="(.*?)"/;
39868 var B = /^<tpl\b[^>]*?if="(.*?)"/;
39869 var C = /^<tpl\b[^>]*?exec="(.*?)"/;
39873 while(m = s.match(re)){
39874 var m2 = m[0].match(A);
39875 var m3 = m[0].match(B);
39876 var m4 = m[0].match(C);
39877 var exp = null, fn = null, exec = null;
39878 var name = m2 && m2[1] ? m2[1] : '';
39880 exp = m3 && m3[1] ? m3[1] : null;
39882 fn = new Function('values', 'parent', 'with(values){ return '+(Roo.util.Format.htmlDecode(exp))+'; }');
39886 exp = m4 && m4[1] ? m4[1] : null;
39888 exec = new Function('values', 'parent', 'with(values){ '+(Roo.util.Format.htmlDecode(exp))+'; }');
39893 case '.': name = new Function('values', 'parent', 'with(values){ return values; }'); break;
39894 case '..': name = new Function('values', 'parent', 'with(values){ return parent; }'); break;
39895 default: name = new Function('values', 'parent', 'with(values){ return '+name+'; }');
39906 s = s.replace(m[0], '{xtpl'+ id + '}');
39909 for(var i = D.length-1; i >= 0; --i){
39910 this.compileTpl(D[i]);
39913 this.master = D[D.length-1];
39916 Roo.extend(Roo.XTemplate, Roo.Template, {
39918 re : /\{([\w-\.]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,
39920 applySubTemplate : function(id, E, F){
39921 var t = this.tpls[id];
39922 if(t.test && !t.test.call(this, E, F)){
39925 if(t.exec && t.exec.call(this, E, F)){
39928 var vs = t.target ? t.target.call(this, E, F) : E;
39929 F = t.target ? E : F;
39930 if(t.target && vs instanceof Array){
39932 for(var i = 0, len = vs.length; i < len; i++){
39933 buf[buf.length] = t.compiled.call(this, vs[i], F);
39935 return buf.join('');
39937 return t.compiled.call(this, vs, F);
39940 compileTpl : function(G){
39941 var fm = Roo.util.Format;
39942 var H = this.disableFormats !== true;
39943 var I = Roo.isGecko ? "+" : ",";
39944 var fn = function(m, K, L, M){
39945 if(K.substr(0, 4) == 'xtpl'){
39946 return "'"+ I +'this.applySubTemplate('+K.substr(4)+', values, parent)'+I+"'";
39949 if(K.indexOf('.') != -1){
39952 v = "values['" + K + "']";
39955 M = M ? ',' + M : "";
39956 if(L.substr(0, 5) != "this."){
39957 L = "fm." + L + '(';
39959 L = 'this.call("'+ L.substr(5) + '", ';
39963 M= ''; L = "("+v+" === undefined ? '' : ";
39965 return "'"+ I + L + v + M + ")"+I+"'";
39970 J = "tpl.compiled = function(values, parent){ return '" +
39971 G.body.replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn) +
39974 J = ["tpl.compiled = function(values, parent){ return ['"];
39975 J.push(G.body.replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn));
39976 J.push("'].join('');};");
39985 applyTemplate : function(K){
39986 return this.master.compiled.call(this, K, {});
39990 apply : function(){
39991 return this.applyTemplate.apply(this, arguments);
39994 compile : function(){return this;}
39997 Roo.XTemplate.from = function(el){
39998 el = Roo.getDom(el);
39999 return new Roo.XTemplate(el.value || el.innerHTML);
40006 Roo.XComponent = function(A) {
40007 Roo.apply(this, A);
40014 'buildcomplete' : true,
40018 Roo.XComponent.register(this);
40019 this.modules = false;
40025 Roo.extend(Roo.XComponent, Roo.util.Observable, {
40061 Roo.apply(Roo.XComponent, {
40065 buildCompleted : false,
40080 register : function(B) {
40081 this.modules.push(B);
40087 toObject : function(C)
40089 if (!C || typeof(C) == 'object') {
40092 var ar = C.split('.');
40097 eval('if (typeof ' + rt + ' == "undefined"){ o = false;} o = ' + rt + ';');
40099 throw "Module not found : " + C;
40102 Roo.each(ar, function(e) {
40103 if (typeof(o[e]) == 'undefined') {
40104 throw "Module not found : " + C;
40116 preBuild : function ()
40119 Roo.each(this.modules , function (D)
40121 D.parent = this.toObject(D.parent);
40124 this.topModule = D;
40128 if (!D.parent.modules) {
40129 D.parent.modules = new Roo.util.MixedCollection(false,
40130 function(o) { return o.order + '' }
40135 D.parent.modules.add(D);
40142 buildOrder : function()
40145 var E = function(a,b) {
40146 return String(a).toUpperCase() > String(b).toUpperCase() ? 1 : -1;
40149 if (!this.topModule || !this.topModule.modules) {
40150 throw "No top level modules to build";
40154 var F = [ this.topModule ];
40158 var G = function(m) {
40163 m.modules.keySort('ASC', E );
40168 m.finalize.name = m.name + " (clean up) ";
40169 F.push(m.finalize);
40174 this.topModule.modules.keySort('ASC', E );
40175 this.topModule.modules.each(G);
40186 var H = this.buildOrder();
40192 throw "NO modules!!!";
40199 Roo.MessageBox.show({ title: 'loading' });
40200 Roo.MessageBox.show({
40201 title: "Please wait...",
40202 msg: "Building Interface...",
40212 var K = function() {
40214 console.log('hide?');
40215 Roo.MessageBox.hide();
40216 J.topModule.fireEvent('buildcomplete', J.topModule);
40222 if (typeof(m) == 'function') {
40224 return K.defer(10, J);
40227 Roo.MessageBox.updateProgress(
40228 (I - H.length)/I, "Building Interface " + (I - H.length) +
40230 (m.name ? (' - ' + m.name) : '')
40235 var L = (typeof(m.disabled) == 'function') ?
40236 m.disabled.call(m.module.disabled) : m.disabled;
40245 var layoutbase = new Ext.BorderLayout(document.body, {
40251 tabPosition: 'top',
40253 alwaysShowTabs: true,
40258 M.region = 'center';
40259 m.el = layoutbase.addxtype(M);
40261 m.layout = m.panel.layout;
40262 return K.defer(10, J);
40266 M.region = M.region || m.region;
40267 m.el = m.parent.el.addxtype(M);
40268 m.fireEvent('built', m);
40270 m.layout = m.panel.layout;
40292 Roo.Login = function(A)
40295 'refreshed' : true,
40300 Roo.onReady(function() {
40306 Roo.Login.superclass.constructor.call(this, this);
40314 Roo.extend(Roo.Login, Roo.LayoutDialog, {
40335 onLoad : function()
40339 if (Roo.get('loading')) {
40340 Roo.get('loading').remove();
40347 success: function(B, C) {
40349 var D = this.processResponse(B);
40350 this.checkFails =0;
40352 this.checkFails = 5;
40354 return this.failure(B,C);
40358 return this.show();
40364 this.fillAuth(D.data);
40365 this.checkFails =0;
40366 Roo.XComponent.build();
40368 failure : this.show
40379 this.checkFails = 0;
40382 if (this.sending) {
40383 if ( this.checkFails > 4) {
40384 Roo.MessageBox.alert("Error",
40385 "Error getting authentication status. - try reloading, or wait a while", function() {
40392 C.check.defer(10000, C, [ B ]);
40396 this.sending = true;
40403 method: this.method,
40404 success: B.success || this.success,
40405 failure : B.failure || this.failure,
40415 window.onbeforeunload = function() { };
40425 failure : function() {
40426 Roo.MessageBox.alert("Error", "Error logging out. - continuing anyway.", function() {
40427 document.location = document.location.toString() + '?ts=' + Math.random();
40431 success : function() {
40433 this.checkFails =0;
40435 document.location = document.location.toString() + '?ts=' + Math.random();
40442 processResponse : function (E)
40446 F = Roo.decode(E.responseText);
40448 if (typeof(F) != 'object') {
40449 F = { success : false, errorMsg : F, errors : true };
40451 if (typeof(F.success) == 'undefined') {
40456 res = { success : false, errorMsg : response.responseText, errors : true };
40461 success : function(G, H)
40463 this.sending = false;
40464 var I = this.processResponse(G);
40466 return this.failure(G, H);
40468 if (!I.data || !I.data.id) {
40469 return this.failure(G,H);
40473 this.fillAuth(I.data);
40475 this.checkFails =0;
40480 failure : function (J, K)
40482 this.authUser = -1;
40483 this.sending = false;
40484 var L = this.processResponse(J);
40486 if ( this.checkFails > 2) {
40488 Roo.MessageBox.alert("Error", L.errorMsg ? L.errorMsg :
40489 "Error getting authentication status. - try reloading");
40493 K.callCfg.again = true;
40494 this.check.defer(1000, this, [ K.callCfg ]);
40500 fillAuth: function(au) {
40501 this.startAuthCheck();
40502 this.authUserId = au.id;
40503 this.authUser = au;
40504 this.lastChecked = new Date();
40505 this.fireEvent('refreshed', au);
40508 au.lang = au.lang || 'en';
40510 Roo.state.Manager.set( this.realm + 'lang' , au.lang);
40511 this.switchLang(au.lang );
40515 if (this.authUserId < 0) {
40516 Roo.MessageBox.alert("Warning",
40517 "This is an open system - please set up a admin user with a password.");
40525 startAuthCheck : function()
40527 if (this.intervalID) {
40531 this.intervalID = window.setInterval(function() {
40539 switchLang : function (N)
40541 _T = typeof(_T) == 'undefined' ? false : _T;
40542 if (!_T || !N.length) {
40546 if (!_T && N != 'en') {
40547 Roo.MessageBox.alert("Sorry", "Language not available yet (" + N +')');
40551 if (typeof(_T.en) == 'undefined') {
40553 Roo.apply(_T.en, _T);
40556 if (typeof(_T[N]) == 'undefined') {
40557 Roo.MessageBox.alert("Sorry", "Language not available yet (" + N +')');
40563 Roo.apply(_T, _T[N]);
40584 collapsible: false,
40592 alwaysShowTabs: false
40599 this.form = this.layout.getRegion('center').activePanel.form;
40600 this.form.dialog = P;
40601 this.buttons[0].form = this.form;
40602 this.buttons[0].dialog = P
40603 this.buttons[1].form = this.form;
40604 this.buttons[1].dialog = P;
40617 if (this.disabled) {
40622 if (this.user.id < 0) {
40626 if (this.intervalID) {
40628 window.clearInterval(this.intervalID);
40629 this.intervalID = false;
40633 if (Roo.get('loading')) {
40634 Roo.get('loading').remove();
40636 if (Roo.get('loading-mask')) {
40637 Roo.get('loading-mask').hide();
40648 this.form.setValues({
40649 'username' : Roo.state.Manager.get(this.realm + '.username', ''),
40650 'lang' : Roo.state.Manager.get(this.realm + '.lang', 'en')
40653 this.switchLang(Roo.state.Manager.get(this.realm + '.lang', 'en'));
40654 if (this.form.findField('username').getValue().length > 0 ){
40655 this.form.findField('password').focus();
40657 this.form.findField('username').focus();
40665 xtype : 'ContentPanel',
40677 style : 'margin: 10px;',
40680 actionfailed : function(f, Q) {
40686 this.dialog.el.unmask();
40687 Roo.MessageBox.alert("Error", Q.result.errorMsg ? Q.result.errorMsg :
40688 "Login failed - communication error - try again.");
40691 actioncomplete: function(re, R) {
40693 Roo.state.Manager.set(
40694 this.dialog.realm + '.username',
40695 this.findField('username').getValue()
40697 Roo.state.Manager.set(
40698 this.dialog.realm + '.lang',
40699 this.findField('lang').getValue()
40702 this.dialog.fillAuth(R.result.data);
40704 this.dialog.hide();
40706 if (Roo.get('loading-mask')) {
40707 Roo.get('loading-mask').show();
40710 Roo.XComponent.build();
40718 xtype : 'TextField',
40720 fieldLabel: "Email Address",
40723 autoCreate : {tag: "input", type: "text", size: "20"}
40726 xtype : 'TextField',
40728 fieldLabel: "Password",
40729 inputType: 'password',
40732 autoCreate : {tag: "input", type: "text", size: "20"},
40734 specialkey : function(e,ev) {
40735 if (ev.keyCode == 13) {
40736 this.form.dialog.el.mask("Logging in");
40737 this.form.doAction('submit', {
40738 url: this.form.dialog.url,
40739 method: this.form.dialog.method,
40746 xtype : 'ComboBox',
40748 fieldLabel: "Language",
40751 xtype : 'SimpleStore',
40752 fields: ['lang', 'ldisp'],
40754 [ 'en', 'English' ],
40755 [ 'zh_HK' , '\u7E41\u4E2D' ],
40756 [ 'zh_CN', '\u7C21\u4E2D' ]
40760 valueField : 'lang',
40761 hiddenName: 'lang',
40763 displayField:'ldisp',
40767 triggerAction: 'all',
40768 emptyText:'Select a Language...',
40769 selectOnFocus:true,
40771 select : function(cb, S, ix) {
40772 this.form.switchLang(S.data.lang);
40788 text : "Forgot Password",
40790 click : function() {
40792 var n = this.form.findField('username').getValue();
40794 Roo.MessageBox.alert("Error", "Fill in your email address");
40799 url: this.dialog.url,
40803 method: this.dialog.method,
40804 success: function(T, U) {
40806 var V = this.dialog.processResponse(T);
40808 Roo.MessageBox.alert("Error" ,
40809 V.errorMsg ? V.errorMsg : "Problem Requesting Password Reset");
40813 Roo.MessageBox.alert("Notice" ,
40814 "Please check you email for the Password Reset message");
40816 failure : function() {
40817 Roo.MessageBox.alert("Error" , "Problem Requesting Password Reset");
40830 click : function () {
40832 this.dialog.el.mask("Logging in");
40833 this.form.doAction('submit', {
40834 url: this.dialog.url,
40835 method: this.dialog.method