X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6e39d509471fe9b4e2660e0d1631b350d0c66f40..530ef4b6c5b943cfa68b779d11cf7de29aa878bf:/ext-all-debug.js diff --git a/ext-all-debug.js b/ext-all-debug.js index 1b11a0e9..3befa7e7 100644 --- a/ext-all-debug.js +++ b/ext-all-debug.js @@ -1,14 +1,13 @@ -/* - * Ext JS Library 3.1.0 - * Copyright(c) 2006-2009 Ext JS, LLC - * licensing@extjs.com - * http://www.extjs.com/license - */ + Ext.DomHelper = function(){ var tempTableEl = null, emptyTags = /^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i, tableRe = /^table|tbody|tr|td$/i, + confRe = /tag|children|cn|html$/i, + tableElRe = /td|tr|tbody/i, + cssRe = /([a-z0-9-]+)\s*:\s*([^;\s]+(?:\s*[^;\s]+)*);?/gi, + endRe = /end/i, pub, afterbegin = 'afterbegin', @@ -37,7 +36,7 @@ Ext.DomHelper = function(){ keyVal, cn; - if(Ext.isString(o)){ + if(typeof o == "string"){ b = o; } else if (Ext.isArray(o)) { for (var i=0; i < o.length; i++) { @@ -47,19 +46,20 @@ Ext.DomHelper = function(){ }; } else { b += '<' + (o.tag = o.tag || 'div'); - Ext.iterate(o, function(attr, val){ - if(!/tag|children|cn|html$/i.test(attr)){ - if (Ext.isObject(val)) { + for (attr in o) { + val = o[attr]; + if(!confRe.test(attr)){ + if (typeof val == "object") { b += ' ' + attr + '="'; - Ext.iterate(val, function(key, keyVal){ - b += key + ':' + keyVal + ';'; - }); + for (key in val) { + b += key + ':' + val[key] + ';'; + }; b += '"'; }else{ b += ' ' + ({cls : 'class', htmlFor : 'for'}[attr] || attr) + '="' + val + '"'; } } - }); + }; if (emptyTags.test(o.tag)) { b += '/>'; @@ -105,7 +105,7 @@ Ext.DomHelper = function(){ tempTableEl = tempTableEl || document.createElement('div'); if(tag == 'td' && (where == afterbegin || where == beforeend) || - !/td|tr|tbody/i.test(tag) && (where == beforebegin || where == afterend)) { + !tableElRe.test(tag) && (where == beforebegin || where == afterend)) { return; } before = where == beforebegin ? el : @@ -134,24 +134,24 @@ Ext.DomHelper = function(){ markup : function(o){ return createHtml(o); }, - + applyStyles : function(el, styles){ if(styles){ var i = 0, len, - style; + style, + matches; el = Ext.fly(el); - if(Ext.isFunction(styles)){ + if(typeof styles == "function"){ styles = styles.call(); } - if(Ext.isString(styles)){ - styles = styles.trim().split(/\s*(?::|;)\s*/); - for(len = styles.length; i < len;){ - el.setStyle(styles[i++], styles[i++]); + if(typeof styles == "string"){ + while((matches = cssRe.exec(styles))){ + el.setStyle(matches[1], matches[2]); } - }else if (Ext.isObject(styles)){ + }else if (typeof styles == "object"){ el.setStyle(styles); } } @@ -185,7 +185,7 @@ Ext.DomHelper = function(){ } } else { range = el.ownerDocument.createRange(); - setStart = 'setStart' + (/end/i.test(where) ? 'After' : 'Before'); + setStart = 'setStart' + (endRe.test(where) ? 'After' : 'Before'); if (hash[where]) { range[setStart](el); frag = range.createContextualFragment(html); @@ -241,24 +241,26 @@ Ext.DomHelper = function(){ }; return pub; }(); + Ext.apply(Ext.DomHelper, function(){ - var pub, - afterbegin = 'afterbegin', - afterend = 'afterend', - beforebegin = 'beforebegin', - beforeend = 'beforeend'; + var pub, + afterbegin = 'afterbegin', + afterend = 'afterend', + beforebegin = 'beforebegin', + beforeend = 'beforeend', + confRe = /tag|children|cn|html$/i; - + function doInsert(el, o, returnElement, pos, sibling, append){ el = Ext.getDom(el); var newNode; if (pub.useDom) { newNode = createDom(o, null); if (append) { - el.appendChild(newNode); + el.appendChild(newNode); } else { - (sibling == 'firstChild' ? el : el.parentNode).insertBefore(newNode, el[sibling] || el); + (sibling == 'firstChild' ? el : el.parentNode).insertBefore(newNode, el[sibling] || el); } } else { newNode = Ext.DomHelper.insertHtml(pos, el, Ext.DomHelper.createHtml(o)); @@ -266,39 +268,40 @@ function(){ return returnElement ? Ext.get(newNode, true) : newNode; } - + function createDom(o, parentNode){ var el, - doc = document, - useSet, - attr, - val, - cn; + doc = document, + useSet, + attr, + val, + cn; if (Ext.isArray(o)) { el = doc.createDocumentFragment(); - Ext.each(o, function(v) { - createDom(v, el); - }); - } else if (Ext.isString(o)) { + for (var i = 0, l = o.length; i < l; i++) { + createDom(o[i], el); + } + } else if (typeof o == 'string') { el = doc.createTextNode(o); } else { el = doc.createElement( o.tag || 'div' ); useSet = !!el.setAttribute; - Ext.iterate(o, function(attr, val){ - if(!/tag|children|cn|html|style/.test(attr)){ - if(attr == 'cls'){ - el.className = val; - }else{ + for (var attr in o) { + if(!confRe.test(attr)){ + val = o[attr]; + if(attr == 'cls'){ + el.className = val; + }else{ if(useSet){ el.setAttribute(attr, val); }else{ el[attr] = val; } - } + } } - }); + } Ext.DomHelper.applyStyles(el, o.style); if ((cn = o.children || o.cn)) { @@ -313,56 +316,59 @@ function(){ return el; } - pub = { - - createTemplate : function(o){ - var html = Ext.DomHelper.createHtml(o); - return new Ext.Template(html); - }, + pub = { + + createTemplate : function(o){ + var html = Ext.DomHelper.createHtml(o); + return new Ext.Template(html); + }, - - useDom : false, + + useDom : false, - - insertBefore : function(el, o, returnElement){ - return doInsert(el, o, returnElement, beforebegin); - }, + + insertBefore : function(el, o, returnElement){ + return doInsert(el, o, returnElement, beforebegin); + }, - - insertAfter : function(el, o, returnElement){ - return doInsert(el, o, returnElement, afterend, 'nextSibling'); - }, + + insertAfter : function(el, o, returnElement){ + return doInsert(el, o, returnElement, afterend, 'nextSibling'); + }, - - insertFirst : function(el, o, returnElement){ - return doInsert(el, o, returnElement, afterbegin, 'firstChild'); - }, + + insertFirst : function(el, o, returnElement){ + return doInsert(el, o, returnElement, afterbegin, 'firstChild'); + }, - - append: function(el, o, returnElement){ + + append: function(el, o, returnElement){ return doInsert(el, o, returnElement, beforeend, '', true); }, - + createDom: createDom - }; - return pub; + }; + return pub; }()); + Ext.Template = function(html){ var me = this, - a = arguments, - buf = []; + a = arguments, + buf = [], + v; if (Ext.isArray(html)) { html = html.join(""); } else if (a.length > 1) { - Ext.each(a, function(v) { - if (Ext.isObject(v)) { + for(var i = 0, len = a.length; i < len; i++){ + v = a[i]; + if(typeof v == 'object'){ Ext.apply(me, v); } else { buf.push(v); } - }); + }; html = buf.join(''); } @@ -380,18 +386,18 @@ Ext.Template.prototype = { applyTemplate : function(values){ - var me = this; + var me = this; return me.compiled ? - me.compiled(values) : - me.html.replace(me.re, function(m, name){ - return values[name] !== undefined ? values[name] : ""; - }); - }, + me.compiled(values) : + me.html.replace(me.re, function(m, name){ + return values[name] !== undefined ? values[name] : ""; + }); + }, set : function(html, compile){ - var me = this; + var me = this; me.html = html; me.compiled = null; return compile ? me.compile() : me; @@ -400,13 +406,13 @@ Ext.Template.prototype = { compile : function(){ var me = this, - sep = Ext.isGecko ? "+" : ","; + sep = Ext.isGecko ? "+" : ","; - function fn(m, name){ - name = "values['" + name + "']"; - return "'"+ sep + '(' + name + " == undefined ? '' : " + name + ')' + sep + "'"; + function fn(m, name){ + name = "values['" + name + "']"; + return "'"+ sep + '(' + name + " == undefined ? '' : " + name + ')' + sep + "'"; } - + eval("this.compiled = function(values){ return " + (Ext.isGecko ? "'" : "['") + me.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn) + (Ext.isGecko ? "';};" : "'].join('');};")); @@ -454,21 +460,31 @@ Ext.Template.from = function(el, config){ el = Ext.getDom(el); return new Ext.Template(el.value || el.innerHTML, config || ''); }; + Ext.apply(Ext.Template.prototype, { - disableFormats : false, + disableFormats : false, re : /\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g, - - + argsRe : /^\s*['"](.*)["']\s*$/, + compileARe : /\\/g, + compileBRe : /(\r\n|\n)/g, + compileCRe : /'/g, + + /** + * Returns an HTML fragment of this template with the specified values applied. + * @param {Object/Array} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'}) + * @return {String} The HTML fragment + * @hide repeat doc + */ applyTemplate : function(values){ - var me = this, - useF = me.disableFormats !== true, - fm = Ext.util.Format, - tpl = me; - + var me = this, + useF = me.disableFormats !== true, + fm = Ext.util.Format, + tpl = me; + if(me.compiled){ return me.compiled(values); } @@ -478,10 +494,10 @@ Ext.apply(Ext.Template.prototype, { return tpl.call(format.substr(5), values[name], values); } else { if (args) { - - - - var re = /^\s*['"](.*)["']\s*$/; + // quoted values are required for strings in compiled templates, + // but for non compiled we need to strip them + // quoted reversed for jsmin + var re = me.argsRe; args = args.split(','); for(var i = 0, len = args.length; i < len; i++){ args[i] = args[i].replace(re, "$1"); @@ -498,15 +514,19 @@ Ext.apply(Ext.Template.prototype, { } return me.html.replace(me.re, fn); }, - - + + /** + * Compiles the template into an internal function, eliminating the RegEx overhead. + * @return {Ext.Template} this + * @hide repeat doc + */ compile : function(){ var me = this, - fm = Ext.util.Format, - useF = me.disableFormats !== true, - sep = Ext.isGecko ? "+" : ",", - body; - + fm = Ext.util.Format, + useF = me.disableFormats !== true, + sep = Ext.isGecko ? "+" : ",", + body; + function fn(m, name, format, args){ if(format && useF){ args = args ? ',' + args : ""; @@ -521,29 +541,94 @@ Ext.apply(Ext.Template.prototype, { } return "'"+ sep + format + "values['" + name + "']" + args + ")"+sep+"'"; } - - + + // branched to use + in gecko and [].join() in others if(Ext.isGecko){ body = "this.compiled = function(values){ return '" + - me.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn) + + me.html.replace(me.compileARe, '\\\\').replace(me.compileBRe, '\\n').replace(me.compileCRe, "\\'").replace(me.re, fn) + "';};"; }else{ body = ["this.compiled = function(values){ return ['"]; - body.push(me.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn)); + body.push(me.html.replace(me.compileARe, '\\\\').replace(me.compileBRe, '\\n').replace(me.compileCRe, "\\'").replace(me.re, fn)); body.push("'].join('');};"); body = body.join(''); } eval(body); return me; }, - - + + // private function used to call members call : function(fnName, value, allValues){ return this[fnName](value, allValues); } }); -Ext.Template.prototype.apply = Ext.Template.prototype.applyTemplate; - +Ext.Template.prototype.apply = Ext.Template.prototype.applyTemplate; +/* + * This is code is also distributed under MIT license for use + * with jQuery and prototype JavaScript libraries. + */ +/** + * @class Ext.DomQuery +Provides high performance selector/xpath processing by compiling queries into reusable functions. New pseudo classes and matchers can be plugged. It works on HTML and XML documents (if a content node is passed in). +

+DomQuery supports most of the CSS3 selectors spec, along with some custom selectors and basic XPath.

+ +

+All selectors, attribute filters and pseudos below can be combined infinitely in any order. For example "div.foo:nth-child(odd)[@foo=bar].bar:first" would be a perfectly valid selector. Node filters are processed in the order in which they appear, which allows you to optimize your queries for your document structure. +

+

Element Selectors:

+ +

Attribute Selectors:

+

The use of @ and quotes are optional. For example, div[@foo='bar'] is also a valid attribute selector.

+ +

Pseudo Classes:

+ +

CSS Value Selectors:

+ + * @singleton + */ Ext.DomQuery = function(){ var cache = {}, simpleCache = {}, @@ -556,18 +641,20 @@ Ext.DomQuery = function(){ nthRe = /(\d*)n\+?(\d*)/, nthRe2 = /\D/, - - - isIE = window.ActiveXObject ? true : false, - key = 30803; - - - eval("var batch = 30803;"); + + isIE = window.ActiveXObject ? true : false, + key = 30803; + + + + eval("var batch = 30803;"); - function child(p, index){ + + + function child(parent, index){ var i = 0, - n = p.firstChild; + n = parent.firstChild; while(n){ if(n.nodeType == 1){ if(++i == index){ @@ -577,53 +664,65 @@ Ext.DomQuery = function(){ n = n.nextSibling; } return null; - }; + } - function next(n){ + + function next(n){ while((n = n.nextSibling) && n.nodeType != 1); return n; - }; + } + function prev(n){ while((n = n.previousSibling) && n.nodeType != 1); return n; - }; + } - function children(d){ - var n = d.firstChild, ni = -1, - nx; - while(n){ - nx = n.nextSibling; - if(n.nodeType == 3 && !nonSpace.test(n.nodeValue)){ - d.removeChild(n); - }else{ - n.nodeIndex = ++ni; - } - n = nx; - } - return this; - }; - - function byClassName(c, a, v){ - if(!v){ - return c; + + + function children(parent){ + var n = parent.firstChild, + nodeIndex = -1, + nextNode; + while(n){ + nextNode = n.nextSibling; + + if(n.nodeType == 3 && !nonSpace.test(n.nodeValue)){ + parent.removeChild(n); + }else{ + + n.nodeIndex = ++nodeIndex; + } + n = nextNode; + } + return this; + } + + + + + function byClassName(nodeSet, cls){ + if(!cls){ + return nodeSet; } - var r = [], ri = -1, cn; - for(var i = 0, ci; ci = c[i]; i++){ - if((' '+ci.className+' ').indexOf(v) != -1){ - r[++ri] = ci; + var result = [], ri = -1; + for(var i = 0, ci; ci = nodeSet[i]; i++){ + if((' '+ci.className+' ').indexOf(cls) != -1){ + result[++ri] = ci; } } - return r; + return result; }; function attrValue(n, attr){ + if(!n.tagName && typeof n.length != "undefined"){ n = n[0]; } if(!n){ return null; } + if(attr == "for"){ return n.htmlFor; } @@ -634,15 +733,23 @@ Ext.DomQuery = function(){ }; + + + + function getNodes(ns, mode, tagName){ var result = [], ri = -1, cs; if(!ns){ return result; } tagName = tagName || "*"; + if(typeof ns.getElementsByTagName != "undefined"){ ns = [ns]; } + + + if(!mode){ for(var i = 0, ni; ni = ns[i]; i++){ cs = ni.getElementsByTagName(tagName); @@ -650,7 +757,9 @@ Ext.DomQuery = function(){ result[++ri] = ci; } } - }else if(mode == "/" || mode == ">"){ + + + } else if(mode == "/" || mode == ">"){ var utag = tagName.toUpperCase(); for(var i = 0, ni, cn; ni = ns[i]; i++){ cn = ni.childNodes; @@ -660,6 +769,8 @@ Ext.DomQuery = function(){ } } } + + }else if(mode == "+"){ var utag = tagName.toUpperCase(); for(var i = 0, n; n = ns[i]; i++){ @@ -668,6 +779,8 @@ Ext.DomQuery = function(){ result[++ri] = n; } } + + }else if(mode == "~"){ var utag = tagName.toUpperCase(); for(var i = 0, n; n = ns[i]; i++){ @@ -679,7 +792,7 @@ Ext.DomQuery = function(){ } } return result; - }; + } function concat(a, b){ if(b.slice){ @@ -698,69 +811,81 @@ Ext.DomQuery = function(){ if(!tagName){ return cs; } - var r = [], ri = -1; + var result = [], ri = -1; tagName = tagName.toLowerCase(); for(var i = 0, ci; ci = cs[i]; i++){ - if(ci.nodeType == 1 && ci.tagName.toLowerCase()==tagName){ - r[++ri] = ci; + if(ci.nodeType == 1 && ci.tagName.toLowerCase() == tagName){ + result[++ri] = ci; } } - return r; - }; + return result; + } - function byId(cs, attr, id){ + function byId(cs, id){ if(cs.tagName || cs == document){ cs = [cs]; } if(!id){ return cs; } - var r = [], ri = -1; - for(var i = 0,ci; ci = cs[i]; i++){ + var result = [], ri = -1; + for(var i = 0, ci; ci = cs[i]; i++){ if(ci && ci.id == id){ - r[++ri] = ci; - return r; + result[++ri] = ci; + return result; } } - return r; - }; + return result; + } + + function byAttribute(cs, attr, value, op, custom){ - var r = [], - ri = -1, - st = custom=="{", - f = Ext.DomQuery.operators[op]; + var result = [], + ri = -1, + useGetStyle = custom == "{", + fn = Ext.DomQuery.operators[op], + a, + innerHTML; for(var i = 0, ci; ci = cs[i]; i++){ + if(ci.nodeType != 1){ continue; } - var a; - if(st){ - a = Ext.DomQuery.getStyle(ci, attr); - } - else if(attr == "class" || attr == "className"){ - a = ci.className; - }else if(attr == "for"){ - a = ci.htmlFor; - }else if(attr == "href"){ - a = ci.getAttribute("href", 2); + + innerHTML = ci.innerHTML; + + if(innerHTML !== null && innerHTML !== undefined){ + if(useGetStyle){ + a = Ext.DomQuery.getStyle(ci, attr); + } else if (attr == "class" || attr == "className"){ + a = ci.className; + } else if (attr == "for"){ + a = ci.htmlFor; + } else if (attr == "href"){ + + + a = ci.getAttribute("href", 2); + } else{ + a = ci.getAttribute(attr); + } }else{ a = ci.getAttribute(attr); } - if((f && f(a, value)) || (!f && a)){ - r[++ri] = ci; + if((fn && fn(a, value)) || (!fn && a)){ + result[++ri] = ci; } } - return r; - }; + return result; + } function byPseudo(cs, name, value){ return Ext.DomQuery.pseudos[name](cs, value); - }; + } function nodupIEXml(cs){ var d = ++key, - r; + r; cs[0].setAttribute("_nodup", d); r = [cs[0]]; for(var i = 1, len = cs.length; i < len; i++){ @@ -811,7 +936,7 @@ Ext.DomQuery = function(){ function quickDiffIEXml(c1, c2){ var d = ++key, - r = []; + r = []; for(var i = 0, len = c1.length; i < len; i++){ c1[i].setAttribute("_qdiff", d); } @@ -853,7 +978,7 @@ Ext.DomQuery = function(){ return d.getElementById(id); } ns = getNodes(ns, mode, "*"); - return byId(ns, null, id); + return byId(ns, id); } return { @@ -864,104 +989,135 @@ Ext.DomQuery = function(){ compile : function(path, type){ type = type || "select"; + var fn = ["var f = function(root){\n var mode; ++batch; var n = root || document;\n"], - q = path, mode, lq, - tk = Ext.DomQuery.matchers, - tklen = tk.length, - mm, + mode, + lastPath, + matchers = Ext.DomQuery.matchers, + matchersLn = matchers.length, + modeMatch, - lmode = q.match(modeRe); + lmode = path.match(modeRe); if(lmode && lmode[1]){ fn[fn.length] = 'mode="'+lmode[1].replace(trimRe, "")+'";'; - q = q.replace(lmode[1], ""); + path = path.replace(lmode[1], ""); } + while(path.substr(0, 1)=="/"){ path = path.substr(1); } - while(q && lq != q){ - lq = q; - var tm = q.match(tagTokenRe); + while(path && lastPath != path){ + lastPath = path; + var tokenMatch = path.match(tagTokenRe); if(type == "select"){ - if(tm){ - if(tm[1] == "#"){ - fn[fn.length] = 'n = quickId(n, mode, root, "'+tm[2]+'");'; + if(tokenMatch){ + + if(tokenMatch[1] == "#"){ + fn[fn.length] = 'n = quickId(n, mode, root, "'+tokenMatch[2]+'");'; }else{ - fn[fn.length] = 'n = getNodes(n, mode, "'+tm[2]+'");'; + fn[fn.length] = 'n = getNodes(n, mode, "'+tokenMatch[2]+'");'; } - q = q.replace(tm[0], ""); - }else if(q.substr(0, 1) != '@'){ + path = path.replace(tokenMatch[0], ""); + }else if(path.substr(0, 1) != '@'){ fn[fn.length] = 'n = getNodes(n, mode, "*");'; } + }else{ - if(tm){ - if(tm[1] == "#"){ - fn[fn.length] = 'n = byId(n, null, "'+tm[2]+'");'; + if(tokenMatch){ + if(tokenMatch[1] == "#"){ + fn[fn.length] = 'n = byId(n, "'+tokenMatch[2]+'");'; }else{ - fn[fn.length] = 'n = byTag(n, "'+tm[2]+'");'; + fn[fn.length] = 'n = byTag(n, "'+tokenMatch[2]+'");'; } - q = q.replace(tm[0], ""); + path = path.replace(tokenMatch[0], ""); } } - while(!(mm = q.match(modeRe))){ + while(!(modeMatch = path.match(modeRe))){ var matched = false; - for(var j = 0; j < tklen; j++){ - var t = tk[j]; - var m = q.match(t.re); + for(var j = 0; j < matchersLn; j++){ + var t = matchers[j]; + var m = path.match(t.re); if(m){ fn[fn.length] = t.select.replace(tplRe, function(x, i){ - return m[i]; - }); - q = q.replace(m[0], ""); + return m[i]; + }); + path = path.replace(m[0], ""); matched = true; break; } } if(!matched){ - throw 'Error parsing selector, parsing failed at "' + q + '"'; + throw 'Error parsing selector, parsing failed at "' + path + '"'; } } - if(mm[1]){ - fn[fn.length] = 'mode="'+mm[1].replace(trimRe, "")+'";'; - q = q.replace(mm[1], ""); + if(modeMatch[1]){ + fn[fn.length] = 'mode="'+modeMatch[1].replace(trimRe, "")+'";'; + path = path.replace(modeMatch[1], ""); } } + fn[fn.length] = "return nodup(n);\n}"; + + eval(fn.join("")); return f; }, - select : function(path, root, type){ - if(!root || root == document){ - root = document; - } + jsSelect: function(path, root, type){ + + root = root || document; + if(typeof root == "string"){ root = document.getElementById(root); } var paths = path.split(","), results = []; - for(var i = 0, len = paths.length; i < len; i++){ - var p = paths[i].replace(trimRe, ""); - if(!cache[p]){ - cache[p] = Ext.DomQuery.compile(p); - if(!cache[p]){ - throw p + " is not a valid selector"; + + + for(var i = 0, len = paths.length; i < len; i++){ + var subPath = paths[i].replace(trimRe, ""); + + if(!cache[subPath]){ + cache[subPath] = Ext.DomQuery.compile(subPath); + if(!cache[subPath]){ + throw subPath + " is not a valid selector"; } } - var result = cache[p](root); + var result = cache[subPath](root); if(result && result != document){ results = results.concat(result); } } + + + if(paths.length > 1){ return nodup(results); } return results; }, + isXml: function(el) { + var docEl = (el ? el.ownerDocument || el : 0).documentElement; + return docEl ? docEl.nodeName !== "HTML" : false; + }, + select : document.querySelectorAll ? function(path, root, type) { + root = root || document; + if (!Ext.DomQuery.isXml(root)) { + try { + var cs = root.querySelectorAll(path); + return Ext.toArray(cs); + } + catch (ex) {} + } + return Ext.DomQuery.jsSelect.call(this, path, root, type); + } : function(path, root, type) { + return Ext.DomQuery.jsSelect.call(this, path, root, type); + }, selectNode : function(path, root){ @@ -976,7 +1132,11 @@ Ext.DomQuery = function(){ } var n = valueCache[path](root), v; n = n[0] ? n[0] : n; - + + + + + if (typeof n.normalize == 'function') n.normalize(); v = (n && n.firstChild ? n.firstChild.nodeValue : null); @@ -1012,7 +1172,7 @@ Ext.DomQuery = function(){ matchers : [{ re: /^\.([\w-]+)/, - select: 'n = byClassName(n, null, " {1} ");' + select: 'n = byClassName(n, " {1} ");' }, { re: /^\:([\w-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/, select: 'n = byPseudo(n, "{1}", "{2}");' @@ -1021,7 +1181,7 @@ Ext.DomQuery = function(){ select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");' }, { re: /^#([\w-]+)/, - select: 'n = byId(n, null, "{1}");' + select: 'n = byId(n, "{1}");' },{ re: /^@([\w-]+)/, select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};' @@ -1272,9 +1432,7 @@ Ext.util.DelayedTask = function(fn, scope, args){ };(function(){ var EXTUTIL = Ext.util, - TOARRAY = Ext.toArray, EACH = Ext.each, - ISOBJECT = Ext.isObject, TRUE = true, FALSE = false; @@ -1294,11 +1452,12 @@ EXTUTIL.Observable.prototype = { fireEvent : function(){ - var a = TOARRAY(arguments), + var a = Array.prototype.slice.call(arguments, 0), ename = a[0].toLowerCase(), me = this, ret = TRUE, ce = me.events[ename], + cc, q, c; if (me.eventsSuspended === TRUE) { @@ -1306,20 +1465,21 @@ EXTUTIL.Observable.prototype = { q.push(a); } } - else if(ISOBJECT(ce) && ce.bubble){ - if(ce.fire.apply(ce, a.slice(1)) === FALSE) { - return FALSE; - } - c = me.getBubbleTarget && me.getBubbleTarget(); - if(c && c.enableBubble) { - if(!c.events[ename] || !Ext.isObject(c.events[ename]) || !c.events[ename].bubble) { - c.enableBubble(ename); + else if(typeof ce == 'object') { + if (ce.bubble){ + if(ce.fire.apply(ce, a.slice(1)) === FALSE) { + return FALSE; + } + c = me.getBubbleTarget && me.getBubbleTarget(); + if(c && c.enableBubble) { + cc = c.events[ename]; + if(!cc || typeof cc != 'object' || !cc.bubble) { + c.enableBubble(ename); + } + return c.fireEvent.apply(c, a); } - return c.fireEvent.apply(c, a); } - } - else { - if (ISOBJECT(ce)) { + else { a.shift(); ret = ce.fire.apply(ce, a); } @@ -1334,7 +1494,7 @@ EXTUTIL.Observable.prototype = { oe, isF, ce; - if (ISOBJECT(eventName)) { + if (typeof eventName == 'object') { o = eventName; for (e in o){ oe = o[e]; @@ -1345,17 +1505,17 @@ EXTUTIL.Observable.prototype = { } else { eventName = eventName.toLowerCase(); ce = me.events[eventName] || TRUE; - if (Ext.isBoolean(ce)) { + if (typeof ce == 'boolean') { me.events[eventName] = ce = new EXTUTIL.Event(me, eventName); } - ce.addListener(fn, scope, ISOBJECT(o) ? o : {}); + ce.addListener(fn, scope, typeof o == 'object' ? o : {}); } }, removeListener : function(eventName, fn, scope){ var ce = this.events[eventName.toLowerCase()]; - if (ISOBJECT(ce)) { + if (typeof ce == 'object') { ce.removeListener(fn, scope); } }, @@ -1367,7 +1527,7 @@ EXTUTIL.Observable.prototype = { key; for(key in events){ evt = events[key]; - if(ISOBJECT(evt)){ + if(typeof evt == 'object'){ evt.clearListeners(); } } @@ -1377,7 +1537,7 @@ EXTUTIL.Observable.prototype = { addEvents : function(o){ var me = this; me.events = me.events || {}; - if (Ext.isString(o)) { + if (typeof o == 'string') { var a = arguments, i = a.length; while(i--) { @@ -1390,8 +1550,8 @@ EXTUTIL.Observable.prototype = { hasListener : function(eventName){ - var e = this.events[eventName]; - return ISOBJECT(e) && e.listeners.length > 0; + var e = this.events[eventName.toLowerCase()]; + return typeof e == 'object' && e.listeners.length > 0; }, @@ -1428,33 +1588,33 @@ EXTUTIL.Observable.releaseCapture = function(o){ function createTargeted(h, o, scope){ return function(){ if(o.target == arguments[0]){ - h.apply(scope, TOARRAY(arguments)); + h.apply(scope, Array.prototype.slice.call(arguments, 0)); } }; }; -function createBuffered(h, o, fn, scope){ - fn.task = new EXTUTIL.DelayedTask(); +function createBuffered(h, o, l, scope){ + l.task = new EXTUTIL.DelayedTask(); return function(){ - fn.task.delay(o.buffer, h, scope, TOARRAY(arguments)); + l.task.delay(o.buffer, h, scope, Array.prototype.slice.call(arguments, 0)); }; -} +}; function createSingle(h, e, fn, scope){ return function(){ e.removeListener(fn, scope); return h.apply(scope, arguments); }; -} +}; -function createDelayed(h, o, fn, scope){ +function createDelayed(h, o, l, scope){ return function(){ var task = new EXTUTIL.DelayedTask(); - if(!fn.tasks) { - fn.tasks = []; + if(!l.tasks) { + l.tasks = []; } - fn.tasks.push(task); - task.delay(o.delay || 10, h, scope, TOARRAY(arguments)); + l.tasks.push(task); + task.delay(o.delay || 10, h, scope, Array.prototype.slice.call(arguments, 0)); }; }; @@ -1489,13 +1649,13 @@ EXTUTIL.Event.prototype = { h = createTargeted(h, o, scope); } if(o.delay){ - h = createDelayed(h, o, fn, scope); + h = createDelayed(h, o, l, scope); } if(o.single){ h = createSingle(h, this, fn, scope); } if(o.buffer){ - h = createBuffered(h, o, fn, scope); + h = createBuffered(h, o, l, scope); } l.fireFn = h; return l; @@ -1504,13 +1664,13 @@ EXTUTIL.Event.prototype = { findListener : function(fn, scope){ var list = this.listeners, i = list.length, - l, - s; - while(i--) { + l; + + scope = scope || this.obj; + while(i--){ l = list[i]; - if(l) { - s = l.scope; - if(l.fn == fn && (s == scope || s == this.obj)){ + if(l){ + if(l.fn == fn && l.scope == scope){ return i; } } @@ -1532,13 +1692,11 @@ EXTUTIL.Event.prototype = { if (me.firing) { me.listeners = me.listeners.slice(0); } - l = me.listeners[index].fn; - + l = me.listeners[index]; if(l.task) { l.task.cancel(); delete l.task; } - k = l.tasks && l.tasks.length; if(k) { while(k--) { @@ -1564,7 +1722,6 @@ EXTUTIL.Event.prototype = { fire : function(){ var me = this, - args = TOARRAY(arguments), listeners = me.listeners, len = listeners.length, i = 0, @@ -1572,6 +1729,7 @@ EXTUTIL.Event.prototype = { if(len > 0){ me.firing = TRUE; + var args = Array.prototype.slice.call(arguments, 0); for (; i < len; i++) { l = listeners[i]; if(l && l.fireFn.apply(l.scope || me.obj || window, args) === FALSE) { @@ -1582,8 +1740,10 @@ EXTUTIL.Event.prototype = { me.firing = FALSE; return TRUE; } + }; })(); + Ext.apply(Ext.util.Observable.prototype, function(){ @@ -1600,9 +1760,13 @@ Ext.apply(Ext.util.Observable.prototype, function(){ e.after = []; var makeCall = function(fn, scope, args){ - if (!Ext.isEmpty(v = fn.apply(scope || obj, args))) { - if (Ext.isObject(v)) { - returnValue = !Ext.isEmpty(v.returnValue) ? v.returnValue : v; + if((v = fn.apply(scope || obj, args)) !== undefined){ + if (typeof v == 'object') { + if(v.returnValue !== undefined){ + returnValue = v.returnValue; + }else{ + returnValue = v; + } cancel = !!v.cancel; } else @@ -1616,26 +1780,30 @@ Ext.apply(Ext.util.Observable.prototype, function(){ }; this[method] = function(){ - var args = Ext.toArray(arguments); + var args = Array.prototype.slice.call(arguments, 0), + b; returnValue = v = undefined; cancel = false; - Ext.each(e.before, function(b){ + for(var i = 0, len = e.before.length; i < len; i++){ + b = e.before[i]; makeCall(b.fn, b.scope, args); if (cancel) { return returnValue; } - }); + } - if (!Ext.isEmpty(v = e.originalFn.apply(obj, args))) { + if((v = e.originalFn.apply(obj, args)) !== undefined){ returnValue = v; } - Ext.each(e.after, function(a){ - makeCall(a.fn, a.scope, args); + + for(var i = 0, len = e.after.length; i < len; i++){ + b = e.after[i]; + makeCall(b.fn, b.scope, args); if (cancel) { return returnValue; } - }); + } return returnValue; }; } @@ -1662,21 +1830,18 @@ Ext.apply(Ext.util.Observable.prototype, function(){ }, removeMethodListener: function(method, fn, scope){ - var e = getMethodEvent.call(this, method), found = false; - Ext.each(e.before, function(b, i, arr){ - if (b.fn == fn && b.scope == scope) { - arr.splice(i, 1); - found = true; - return false; + var e = this.getMethodEvent(method); + for(var i = 0, len = e.before.length; i < len; i++){ + if(e.before[i].fn == fn && e.before[i].scope == scope){ + e.before.splice(i, 1); + return; + } + } + for(var i = 0, len = e.after.length; i < len; i++){ + if(e.after[i].fn == fn && e.after[i].scope == scope){ + e.after.splice(i, 1); + return; } - }); - if (!found) { - Ext.each(e.after, function(a, i, arr){ - if (a.fn == fn && a.scope == scope) { - arr.splice(i, 1); - return false; - } - }); } }, @@ -1685,29 +1850,31 @@ Ext.apply(Ext.util.Observable.prototype, function(){ var me = this; function createHandler(ename){ return function(){ - return me.fireEvent.apply(me, [ename].concat(Ext.toArray(arguments))); + return me.fireEvent.apply(me, [ename].concat(Array.prototype.slice.call(arguments, 0))); }; } - Ext.each(events, function(ename){ + for(var i = 0, len = events.length; i < len; i++){ + var ename = events[i]; me.events[ename] = me.events[ename] || true; o.on(ename, createHandler(ename), me); - }); + } }, enableBubble : function(events){ var me = this; if(!Ext.isEmpty(events)){ - events = Ext.isArray(events) ? events : Ext.toArray(arguments); - Ext.each(events, function(ename){ + events = Ext.isArray(events) ? events : Array.prototype.slice.call(arguments, 0); + for(var i = 0, len = events.length; i < len; i++){ + var ename = events[i]; ename = ename.toLowerCase(); var ce = me.events[ename] || true; - if (Ext.isBoolean(ce)) { + if (typeof ce == 'boolean') { ce = new Ext.util.Event(me, ename); me.events[ename] = ce; } ce.bubble = true; - }); + } } } }; @@ -1727,22 +1894,25 @@ Ext.util.Observable.observeClass = function(c, listeners){ Ext.apply(c, new Ext.util.Observable()); Ext.util.Observable.capture(c.prototype, c.fireEvent, c); } - if(Ext.isObject(listeners)){ + if(typeof listeners == 'object'){ c.on(listeners); } return c; } }; + + Ext.EventManager = function(){ var docReadyEvent, docReadyProcId, docReadyState = false, + DETECT_NATIVE = Ext.isGecko || Ext.isWebKit || Ext.isSafari, E = Ext.lib.Event, D = Ext.lib.Dom, DOC = document, WINDOW = window, - IEDEFERED = "ie-deferred-loader", DOMCONTENTLOADED = "DOMContentLoaded", + COMPLETE = 'complete', propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/, specialElCache = []; @@ -1787,7 +1957,7 @@ Ext.EventManager = function(){ }; - function addListener(el, ename, fn, wrap, scope){ + function addListener(el, ename, fn, task, wrap, scope){ el = Ext.getDom(el); var id = getId(el), es = Ext.elCache[id].events, @@ -1795,64 +1965,120 @@ Ext.EventManager = function(){ wfn = E.on(el, ename, wrap); es[ename] = es[ename] || []; - es[ename].push([fn, wrap, scope, wfn]); + es[ename].push([fn, wrap, scope, wfn, task]); + - if(ename == "mousewheel" && el.addEventListener){ + + + + if(el.addEventListener && ename == "mousewheel"){ var args = ["DOMMouseScroll", wrap, false]; el.addEventListener.apply(el, args); Ext.EventManager.addListener(WINDOW, 'unload', function(){ el.removeEventListener.apply(el, args); }); } - if(ename == "mousedown" && el == document){ + + + if(el == DOC && ename == "mousedown"){ Ext.EventManager.stoppedMouseDownEvent.addListener(wrap); } }; - function fireDocReady(){ + function doScrollChk(){ + + if(window != top){ + return false; + } + + try{ + DOC.documentElement.doScroll('left'); + }catch(e){ + return false; + } + + fireDocReady(); + return true; + } + + function checkReadyState(e){ + + if(Ext.isIE && doScrollChk()){ + return true; + } + if(DOC.readyState == COMPLETE){ + fireDocReady(); + return true; + } + docReadyState || (docReadyProcId = setTimeout(arguments.callee, 2)); + return false; + } + + var styles; + function checkStyleSheets(e){ + styles || (styles = Ext.query('style, link[rel=stylesheet]')); + if(styles.length == DOC.styleSheets.length){ + fireDocReady(); + return true; + } + docReadyState || (docReadyProcId = setTimeout(arguments.callee, 2)); + return false; + } + + function OperaDOMContentLoaded(e){ + DOC.removeEventListener(DOMCONTENTLOADED, arguments.callee, false); + checkStyleSheets(); + } + + function fireDocReady(e){ if(!docReadyState){ - Ext.isReady = docReadyState = true; + docReadyState = true; + if(docReadyProcId){ - clearInterval(docReadyProcId); + clearTimeout(docReadyProcId); } - if(Ext.isGecko || Ext.isOpera) { + if(DETECT_NATIVE) { DOC.removeEventListener(DOMCONTENTLOADED, fireDocReady, false); } - if(Ext.isIE){ - var defer = DOC.getElementById(IEDEFERED); - if(defer){ - defer.onreadystatechange = null; - defer.parentNode.removeChild(defer); - } - } - if(docReadyEvent){ - docReadyEvent.fire(); - docReadyEvent.listeners = []; + if(Ext.isIE && checkReadyState.bindIE){ + DOC.detachEvent('onreadystatechange', checkReadyState); } + E.un(WINDOW, "load", arguments.callee); + } + if(docReadyEvent && !Ext.isReady){ + Ext.isReady = true; + docReadyEvent.fire(); + docReadyEvent.listeners = []; } + }; function initDocReady(){ - var COMPLETE = "complete"; - - docReadyEvent = new Ext.util.Event(); - if (Ext.isGecko || Ext.isOpera) { + docReadyEvent || (docReadyEvent = new Ext.util.Event()); + if (DETECT_NATIVE) { DOC.addEventListener(DOMCONTENTLOADED, fireDocReady, false); - } else if (Ext.isIE){ - DOC.write(""); - DOC.getElementById(IEDEFERED).onreadystatechange = function(){ - if(this.readyState == COMPLETE){ - fireDocReady(); - } - }; - } else if (Ext.isWebKit){ - docReadyProcId = setInterval(function(){ - if(DOC.readyState == COMPLETE) { - fireDocReady(); - } - }, 10); + } + + if (Ext.isIE){ + + + if(!checkReadyState()){ + checkReadyState.bindIE = true; + DOC.attachEvent('onreadystatechange', checkReadyState); + } + + }else if(Ext.isOpera ){ + + + + (DOC.readyState == COMPLETE && checkStyleSheets()) || + DOC.addEventListener(DOMCONTENTLOADED, OperaDOMContentLoaded, false); + + }else if (Ext.isWebKit){ + + checkReadyState(); } E.on(WINDOW, "load", fireDocReady); @@ -1867,13 +2093,11 @@ Ext.EventManager = function(){ }; }; - function createBuffered(h, o, fn){ - fn.task = new Ext.util.DelayedTask(h); - var w = function(e){ + function createBuffered(h, o, task){ + return function(e){ - fn.task.delay(o.buffer, h, null, [new Ext.EventObjectImpl(e)]); + task.delay(o.buffer, h, null, [new Ext.EventObjectImpl(e)]); }; - return w; }; function createSingle(h, el, ename, fn, scope){ @@ -1895,8 +2119,8 @@ Ext.EventManager = function(){ }; function listen(element, ename, opt, fn, scope){ - var o = !Ext.isObject(opt) ? {} : opt, - el = Ext.getDom(element); + var o = (!opt || typeof opt == "boolean") ? {} : opt, + el = Ext.getDom(element), task; fn = fn || o.fn; scope = scope || o.scope; @@ -1943,17 +2167,18 @@ Ext.EventManager = function(){ h = createSingle(h, el, ename, fn, scope); } if(o.buffer){ - h = createBuffered(h, o, fn); + task = new Ext.util.DelayedTask(h); + h = createBuffered(h, o, task); } - addListener(el, ename, fn, h, scope); + addListener(el, ename, fn, task, h, scope); return h; }; var pub = { addListener : function(element, eventName, fn, scope, options){ - if(Ext.isObject(eventName)){ + if(typeof eventName == 'object'){ var o = eventName, e, val; for(e in o){ val = o[e]; @@ -1977,13 +2202,14 @@ Ext.EventManager = function(){ el = Ext.getDom(el); var id = getId(el), f = el && (Ext.elCache[id].events)[eventName] || [], - wrap, i, l, k, wf; + wrap, i, l, k, len, fnc; for (i = 0, len = f.length; i < len; i++) { - if (Ext.isArray(f[i]) && f[i][0] == fn && (!scope || f[i][2] == scope)) { - if(fn.task) { - fn.task.cancel(); - delete fn.task; + + + if (Ext.isArray(fnc = f[i]) && fnc[0] == fn && (!scope || fnc[2] == scope)) { + if(fnc[4]) { + fnc[4].cancel(); } k = fn.tasks && fn.tasks.length; if(k) { @@ -1992,12 +2218,20 @@ Ext.EventManager = function(){ } delete fn.tasks; } - wf = wrap = f[i][1]; - if (E.extAdapter) { - wf = f[i][3]; + wrap = fnc[1]; + E.un(el, eventName, E.extAdapter ? fnc[3] : wrap); + + + if(wrap && el.addEventListener && eventName == "mousewheel"){ + el.removeEventListener("DOMMouseScroll", wrap, false); } - E.un(el, eventName, wf); - f.splice(i,1); + + + if(wrap && el == DOC && eventName == "mousedown"){ + Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap); + } + + f.splice(i, 1); if (f.length === 0) { delete Ext.elCache[id].events[eventName]; } @@ -2008,15 +2242,6 @@ Ext.EventManager = function(){ return false; } } - - - if(eventName == "mousewheel" && el.addEventListener && wrap){ - el.removeEventListener("DOMMouseScroll", wrap, false); - } - - if(eventName == "mousedown" && el == DOC && wrap){ - Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap); - } }, @@ -2025,24 +2250,35 @@ Ext.EventManager = function(){ var id = getId(el), ec = Ext.elCache[id] || {}, es = ec.events || {}, - f, i, len, ename, fn, k; + f, i, len, ename, fn, k, wrap; for(ename in es){ if(es.hasOwnProperty(ename)){ f = es[ename]; + for (i = 0, len = f.length; i < len; i++) { - fn = f[i][0]; - if(fn.task) { - fn.task.cancel(); - delete fn.task; + fn = f[i]; + if(fn[4]) { + fn[4].cancel(); } - if(fn.tasks && (k = fn.tasks.length)) { + if(fn[0].tasks && (k = fn[0].tasks.length)) { while(k--) { - fn.tasks[k].cancel(); + fn[0].tasks[k].cancel(); } delete fn.tasks; } - E.un(el, ename, E.extAdapter ? f[i][3] : f[i][1]); + wrap = fn[1]; + E.un(el, ename, E.extAdapter ? fn[3] : wrap); + + + if(el.addEventListener && wrap && ename == "mousewheel"){ + el.removeEventListener("DOMMouseScroll", wrap, false); + } + + + if(wrap && el == DOC && ename == "mousedown"){ + Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap); + } } } } @@ -2092,20 +2328,41 @@ Ext.EventManager = function(){ for (el in Ext.elCache) { Ext.EventManager.removeAll(el); } + delete Ext.elCache; + delete Ext.Element._flyweights; + + + var c, + conn, + tid, + ajax = Ext.lib.Ajax; + (typeof ajax.conn == 'object') ? conn = ajax.conn : conn = {}; + for (tid in conn) { + c = conn[tid]; + if (c) { + ajax.abort({conn: c, tId: tid}); + } + } }, onDocumentReady : function(fn, scope, options){ - if(docReadyState){ + if(Ext.isReady){ + docReadyEvent || (docReadyEvent = new Ext.util.Event()); docReadyEvent.addListener(fn, scope, options); docReadyEvent.fire(); - docReadyEvent.listeners = []; - } else { - if(!docReadyEvent) initDocReady(); + docReadyEvent.listeners = []; + }else{ + if(!docReadyEvent){ + initDocReady(); + } options = options || {}; options.delay = options.delay || 1; docReadyEvent.addListener(fn, scope, options); } - } + }, + + + fireDocReady : fireDocReady }; pub.on = pub.addListener; @@ -2320,7 +2577,6 @@ Ext.EventObject = function(){ return new Ext.EventObjectImpl(); }(); - Ext.apply(Ext.EventManager, function(){ var resizeEvent, resizeTask, @@ -2343,10 +2599,10 @@ Ext.apply(Ext.EventManager, function(){ var h = D.getViewHeight(), w = D.getViewWidth(); - - if(curHeight != h || curWidth != w){ + + if(curHeight != h || curWidth != w){ resizeEvent.fire(curWidth = w, curHeight = h); - } + } }, @@ -2362,11 +2618,7 @@ Ext.apply(Ext.EventManager, function(){ fireWindowResize : function(){ if(resizeEvent){ - if((Ext.isIE||Ext.isAir) && resizeTask){ - resizeTask.delay(50); - }else{ - resizeEvent.fire(D.getViewWidth(), D.getViewHeight()); - } + resizeTask.delay(100); } }, @@ -2612,7 +2864,7 @@ Ext.apply(Ext.EventObjectImpl.prototype, { this.isNavKeyPress() || (k == this.BACKSPACE) || (k >= 16 && k <= 20) || - (k >= 44 && k <= 45); + (k >= 44 && k <= 46); }, getPoint : function(){ @@ -2916,8 +3168,15 @@ El.get = function(el){ return ex; } else if (el instanceof El) { if(el != docEl){ - el.dom = DOC.getElementById(el.id) || el.dom; - + + + + + if (Ext.isIE && (el.id == undefined || el.id == '')) { + el.dom = el.dom; + } else { + el.dom = DOC.getElementById(el.id) || el.dom; + } } return el; } else if(el.isComposite) { @@ -2938,7 +3197,7 @@ El.get = function(el){ }; El.addToCache = function(el, id){ - id = id || el.id; + id = id || el.id; EC[id] = { el: el, data: {}, @@ -3056,11 +3315,6 @@ if(Ext.isIE || Ext.isGecko){ noBoxAdjust['button'] = 1; } - -Ext.EventManager.on(window, 'unload', function(){ - delete EC; - delete El._flyweights; -}); })(); Ext.Element.addMethods({ @@ -3135,7 +3389,7 @@ Ext.Element.addMethods({ if(loadScripts !== true){ this.dom.innerHTML = html; - if(Ext.isFunction(callback)){ + if(typeof callback == 'function'){ callback(); } return this; @@ -3180,7 +3434,7 @@ Ext.Element.addMethods({ } el = DOC.getElementById(id); if(el){Ext.removeNode(el);} - if(Ext.isFunction(callback)){ + if(typeof callback == 'function'){ callback(); } }); @@ -3197,7 +3451,7 @@ Ext.Element.addMethods({ createProxy : function(config, renderTo, matchBox){ - config = Ext.isObject(config) ? config : {tag : "div", cls: config}; + config = (typeof config == 'object') ? config : {tag : "div", cls: config}; var me = this, proxy = renderTo ? Ext.DomHelper.append(renderTo, config, true) : @@ -3780,6 +4034,8 @@ Ext.Element.addMethods(function(){ propFloat = Ext.isIE ? 'styleFloat' : 'cssFloat', opacityRe = /alpha\(opacity=(.*)\)/i, trimRe = /^\s+|\s+$/g, + spacesRe = /\s+/, + wordsRe = /\w/g, EL = Ext.Element, PADDING = "padding", MARGIN = "margin", @@ -3816,7 +4072,7 @@ Ext.Element.addMethods(function(){ adjustWidth : function(width) { var me = this; - var isNum = Ext.isNumber(width); + var isNum = (typeof width == "number"); if(isNum && me.autoBoxAdjust && !me.isBorderBox()){ width -= (me.getBorderWidth("lr") + me.getPadding("lr")); } @@ -3826,7 +4082,7 @@ Ext.Element.addMethods(function(){ adjustHeight : function(height) { var me = this; - var isNum = Ext.isNumber(height); + var isNum = (typeof height == "number"); if(isNum && me.autoBoxAdjust && !me.isBorderBox()){ height -= (me.getBorderWidth("tb") + me.getPadding("tb")); } @@ -3836,24 +4092,69 @@ Ext.Element.addMethods(function(){ addClass : function(className){ - var me = this, i, len, v; - className = Ext.isArray(className) ? className : [className]; - for (i=0, len = className.length; i < len; i++) { - v = className[i]; - if (v) { - me.dom.className += (!me.hasClass(v) && v ? " " + v : ""); - }; - }; + var me = this, + i, + len, + v, + cls = []; + + if (!Ext.isArray(className)) { + if (typeof className == 'string' && !this.hasClass(className)) { + me.dom.className += " " + className; + } + } + else { + for (i = 0, len = className.length; i < len; i++) { + v = className[i]; + if (typeof v == 'string' && (' ' + me.dom.className + ' ').indexOf(' ' + v + ' ') == -1) { + cls.push(v); + } + } + if (cls.length) { + me.dom.className += " " + cls.join(" "); + } + } + return me; + }, + + + removeClass : function(className){ + var me = this, + i, + idx, + len, + cls, + elClasses; + if (!Ext.isArray(className)){ + className = [className]; + } + if (me.dom && me.dom.className) { + elClasses = me.dom.className.replace(trimRe, '').split(spacesRe); + for (i = 0, len = className.length; i < len; i++) { + cls = className[i]; + if (typeof cls == 'string') { + cls = cls.replace(trimRe, ''); + idx = elClasses.indexOf(cls); + if (idx != -1) { + elClasses.splice(idx, 1); + } + } + } + me.dom.className = elClasses.join(" "); + } return me; }, radioClass : function(className){ - var cn = this.dom.parentNode.childNodes, v; + var cn = this.dom.parentNode.childNodes, + v, + i, + len; className = Ext.isArray(className) ? className : [className]; - for (var i=0, len = cn.length; i < len; i++) { + for (i = 0, len = cn.length; i < len; i++) { v = cn[i]; - if(v && v.nodeType == 1) { + if (v && v.nodeType == 1) { Ext.fly(v, '_internal').removeClass(className); } }; @@ -3861,23 +4162,6 @@ Ext.Element.addMethods(function(){ }, - removeClass : function(className){ - var me = this, v; - className = Ext.isArray(className) ? className : [className]; - if (me.dom && me.dom.className) { - for (var i=0, len=className.length; i < len; i++) { - v = className[i]; - if(v) { - me.dom.className = me.dom.className.replace( - classReCache[v] = classReCache[v] || new RegExp('(?:^|\\s+)' + v + '(?:\\s+|$)', "g"), " " - ); - } - }; - } - return me; - }, - - toggleClass : function(className){ return this.hasClass(className) ? this.removeClass(className) : this.addClass(className); }, @@ -3907,7 +4191,7 @@ Ext.Element.addMethods(function(){ display, wk = Ext.isWebKit, display; - + if(el == document){ return null; } @@ -3955,7 +4239,7 @@ Ext.Element.addMethods(function(){ getColor : function(attr, defaultValue, prefix){ var v = this.getStyle(attr), - color = Ext.isDefined(prefix) ? prefix : '#', + color = (typeof prefix != 'undefined') ? prefix : '#', h; if(!v || /transparent|inherit/.test(v)){ @@ -3978,7 +4262,7 @@ Ext.Element.addMethods(function(){ var tmp, style, camel; - if (!Ext.isObject(prop)) { + if (typeof prop != 'object') { tmp = {}; tmp[prop] = value; prop = tmp; @@ -4119,16 +4403,20 @@ Ext.Element.addMethods(function(){ addStyles : function(sides, styles){ - var val = 0, - m = sides.match(/\w/g), - s; - for (var i=0, len=m.length; i