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(P, id){
10515 var Q = B.getElementsByTagName("head")[0];
10516 var R = B.createElement("style");
10517 R.setAttribute("type", "text/css");
10519 R.setAttribute("id", id);
10521 if (typeof(P) != 'string') {
10526 var cssTextNew = [];
10529 for(var k in P[n]) {
10530 citems.push( k + ' : ' +P[n][k] + ';' );
10533 cssTextNew.push( n + ' { ' + citems.join(' ') + '} ');
10537 P = cssTextNew.join("\n");
10548 R.appendChild(B.createTextNode(P));
10554 ss = R.styleSheet ? R.styleSheet : (R.sheet || B.styleSheets[B.styleSheets.length-1]);
10557 this.cacheStyleSheet(ss);
10563 removeStyleSheet : function(id){
10564 var S = B.getElementById(id);
10566 S.parentNode.removeChild(S);
10572 swapStyleSheet : function(id, T){
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", T);
10579 B.getElementsByTagName("head")[0].appendChild(ss);
10584 refreshCache : function(){
10585 return this.getRules(true);
10589 cacheStyleSheet : function(ss){
10594 var ssRules = ss.cssRules || ss.rules;
10595 for(var j = ssRules.length-1; j >= 0; --j){
10596 R[ssRules[j].selectorText] = ssRules[j];
10603 getRules : function(U){
10604 if(R == null || U){
10606 var ds = B.styleSheets;
10607 for(var i =0, len = ds.length; i < len; i++){
10609 this.cacheStyleSheet(ds[i]);
10618 getRule : function(V, W){
10619 var rs = this.getRules(W);
10620 if(!(V instanceof Array)){
10623 for(var i = 0; i < V.length; i++){
10634 updateRule : function(X, Y, Z){
10635 if(!(X instanceof Array)){
10636 var rule = this.getRule(X);
10638 rule.style[Y.replace(C, D)] = Z;
10642 for(var i = 0; i < X.length; i++){
10643 if(this.updateRule(X[i], Y, Z)){
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" : "");