X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6746dc89c47ed01b165cc1152533605f97eb8e8d..HEAD:/ext-all-debug.js diff --git a/ext-all-debug.js b/ext-all-debug.js index ba428b54..8fc6dc00 100644 --- a/ext-all-debug.js +++ b/ext-all-debug.js @@ -407,7 +407,7 @@ If you are unsure which license is appropriate for your use, please contact the (function() { -var version = '4.0.2', Version; +var version = '4.0.7', Version; Ext.Version = Version = Ext.extend(Object, { @@ -592,7 +592,7 @@ Ext.String = { escapeRegexRe: /([-.*+?^${}()|[\]\/\\])/g, /** - * Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages. + * Convert certain characters (&, <, >, and ") to their HTML character equivalents for literal display in web pages. * @param {String} value The string to encode * @return {String} The encoded text * @method @@ -618,7 +618,12 @@ Ext.String = { }; })(), - + /** + * Convert certain characters (&, <, >, and ") from their HTML character equivalents. + * @param {String} value The string to decode + * @return {String} The decoded text + * @method + */ htmlDecode: (function() { var entities = { '&': '&', @@ -709,6 +714,14 @@ Ext.String = { return format.replace(Ext.String.formatRe, function(m, i) { return args[i]; }); + }, + + + repeat: function(pattern, count, sep) { + for (var buf = [], i = count; i--; ) { + buf.push(pattern); + } + return buf.join(sep || ''); } }; @@ -1267,9 +1280,24 @@ Ext.num = function() { }, - slice: function(array, begin, end) { - return slice.call(array, begin, end); - }, + + slice: ([1,2].slice(1, undefined).length ? + function (array, begin, end) { + return slice.call(array, begin, end); + } : + + function (array, begin, end) { + + + if (typeof begin === 'undefined') { + return slice.call(array); + } + if (typeof end === 'undefined') { + return slice.call(array, begin); + } + return slice.call(array, begin, end); + } + ), sort: function(array, sortFn) { @@ -1485,6 +1513,12 @@ Ext.Function = { bind: function(fn, scope, args, appendArgs) { + if (arguments.length === 2) { + return function() { + return fn.apply(scope, arguments); + } + } + var method = fn, slice = Array.prototype.slice; @@ -1495,7 +1529,7 @@ Ext.Function = { callArgs = slice.call(arguments, 0); callArgs = callArgs.concat(args); } - else if (Ext.isNumber(appendArgs)) { + else if (typeof appendArgs == 'number') { callArgs = slice.call(arguments, 0); Ext.Array.insert(callArgs, appendArgs, args); } @@ -1583,7 +1617,7 @@ Ext.Function = { return function() { var me = this; if (timerId) { - clearInterval(timerId); + clearTimeout(timerId); timerId = null; } timerId = setTimeout(function(){ @@ -1611,6 +1645,28 @@ Ext.Function = { timer = setTimeout(execute, interval - elapsed); } }; + }, + + + interceptBefore: function(object, methodName, fn) { + var method = object[methodName] || Ext.emptyFn; + + return object[methodName] = function() { + var ret = fn.apply(this, arguments); + method.apply(this, arguments); + + return ret; + }; + }, + + + interceptAfter: function(object, methodName, fn) { + var method = object[methodName] || Ext.emptyFn; + + return object[methodName] = function() { + method.apply(this, arguments); + return fn.apply(this, arguments); + }; } }; @@ -2786,6 +2842,7 @@ var Base = Ext.Base = function() {}; }, + initConfig: function(config) { if (!this.$configInited) { this.config = Ext.Object.merge({}, this.config || {}, config || {}); @@ -2815,6 +2872,7 @@ var Base = Ext.Base = function() {}; return this; }), + callParent: function(args) { @@ -2865,20 +2923,20 @@ var Base = Ext.Base = function() {}; }, - own: flexSetter(function(name, value) { - if (typeof value === 'function') { + own: function(name, value) { + if (typeof value == 'function') { this.ownMethod(name, value); } else { this.prototype[name] = value; } - }), + }, ownMethod: function(name, fn) { var originalFn; - if (fn.$owner !== undefined && fn !== Ext.emptyFn) { + if (typeof fn.$owner !== 'undefined' && fn !== Ext.emptyFn) { originalFn = fn; fn = function() { @@ -2904,9 +2962,41 @@ var Base = Ext.Base = function() {}; }, + addInheritableStatics: function(members) { + var inheritableStatics, + hasInheritableStatics, + prototype = this.prototype, + name, member; + + inheritableStatics = prototype.$inheritableStatics; + hasInheritableStatics = prototype.$hasInheritableStatics; + + if (!inheritableStatics) { + inheritableStatics = prototype.$inheritableStatics = []; + hasInheritableStatics = prototype.$hasInheritableStatics = {}; + } + + + for (name in members) { + if (members.hasOwnProperty(name)) { + member = members[name]; + this[name] = member; + + if (!hasInheritableStatics[name]) { + hasInheritableStatics[name] = true; + inheritableStatics.push(name); + } + } + } + + return this; + }, + + implement: function(members) { var prototype = this.prototype, - name, i, member, previous; + enumerables = Ext.enumerables, + name, i, member; for (name in members) { if (members.hasOwnProperty(name)) { member = members[name]; @@ -2920,9 +3010,7 @@ var Base = Ext.Base = function() {}; } } - if (Ext.enumerables) { - var enumerables = Ext.enumerables; - + if (enumerables) { for (i = enumerables.length; i--;) { name = enumerables[i]; @@ -2955,8 +3043,28 @@ var Base = Ext.Base = function() {}; override: function(members) { var prototype = this.prototype, + enumerables = Ext.enumerables, name, i, member, previous; + if (arguments.length === 2) { + name = members; + member = arguments[1]; + + if (typeof member == 'function') { + if (typeof prototype[name] == 'function') { + previous = prototype[name]; + member.$previous = previous; + } + + this.ownMethod(name, member); + } + else { + prototype[name] = member; + } + + return this; + } + for (name in members) { if (members.hasOwnProperty(name)) { member = members[name]; @@ -2975,14 +3083,12 @@ var Base = Ext.Base = function() {}; } } - if (Ext.enumerables) { - var enumerables = Ext.enumerables; - + if (enumerables) { for (i = enumerables.length; i--;) { name = enumerables[i]; if (members.hasOwnProperty(name)) { - if (prototype[name] !== undefined) { + if (typeof prototype[name] !== 'undefined') { previous = prototype[name]; members[name].$previous = previous; } @@ -2996,40 +3102,53 @@ var Base = Ext.Base = function() {}; }, - mixin: flexSetter(function(name, cls) { + + mixin: function(name, cls) { var mixin = cls.prototype, my = this.prototype, - i, fn; + key, fn; - for (i in mixin) { - if (mixin.hasOwnProperty(i)) { - if (my[i] === undefined) { - if (typeof mixin[i] === 'function') { - fn = mixin[i]; + for (key in mixin) { + if (mixin.hasOwnProperty(key)) { + if (typeof my[key] === 'undefined' && key !== 'mixins' && key !== 'mixinId') { + if (typeof mixin[key] === 'function') { + fn = mixin[key]; - if (fn.$owner === undefined) { - this.ownMethod(i, fn); + if (typeof fn.$owner === 'undefined') { + this.ownMethod(key, fn); } else { - my[i] = fn; + my[key] = fn; } } else { - my[i] = mixin[i]; + my[key] = mixin[key]; } } - else if (i === 'config' && my.config && mixin.config) { + + else if (key === 'config' && my.config && mixin.config) { Ext.Object.merge(my.config, mixin.config); } + } } - if (my.mixins === undefined) { - my.mixins = {}; + if (typeof mixin.onClassMixedIn !== 'undefined') { + mixin.onClassMixedIn.call(cls, this); + } + + if (!my.hasOwnProperty('mixins')) { + if ('mixins' in my) { + my.mixins = Ext.Object.merge({}, my.mixins); + } + else { + my.mixins = {}; + } } my.mixins[name] = mixin; - }), + }, + getName: function() { @@ -3038,7 +3157,9 @@ var Base = Ext.Base = function() {}; createAlias: flexSetter(function(alias, origin) { - this.prototype[alias] = this.prototype[origin]; + this.prototype[alias] = function() { + return this[origin].apply(this, arguments); + } }) }); @@ -3060,7 +3181,7 @@ var Base = Ext.Base = function() {}; Ext.Class = Class = function(newClass, classData, onClassCreated) { - if (typeof newClass !== 'function') { + if (typeof newClass != 'function') { onClassCreated = classData; classData = newClass; newClass = function() { @@ -3076,7 +3197,7 @@ var Base = Ext.Base = function() {}; registeredPreprocessors = Class.getPreprocessors(), index = 0, preprocessors = [], - preprocessor, preprocessors, staticPropertyName, process, i, j, ln; + preprocessor, staticPropertyName, process, i, j, ln; for (i = 0, ln = baseStaticProperties.length; i < ln; i++) { staticPropertyName = baseStaticProperties[i]; @@ -3088,7 +3209,7 @@ var Base = Ext.Base = function() {}; for (j = 0, ln = preprocessorStack.length; j < ln; j++) { preprocessor = preprocessorStack[j]; - if (typeof preprocessor === 'string') { + if (typeof preprocessor == 'string') { preprocessor = registeredPreprocessors[preprocessor]; if (!preprocessor.always) { @@ -3105,7 +3226,7 @@ var Base = Ext.Base = function() {}; } } - classData.onClassCreated = onClassCreated; + classData.onClassCreated = onClassCreated || Ext.emptyFn; classData.onBeforeClassCreated = function(cls, data) { onClassCreated = data.onClassCreated; @@ -3115,9 +3236,7 @@ var Base = Ext.Base = function() {}; cls.implement(data); - if (onClassCreated) { - onClassCreated.call(cls, cls); - } + onClassCreated.call(cls, cls); }; process = function(cls, data) { @@ -3180,7 +3299,7 @@ var Base = Ext.Base = function() {}; var defaultPreprocessors = this.defaultPreprocessors, index; - if (typeof offset === 'string') { + if (typeof offset == 'string') { if (offset === 'first') { defaultPreprocessors.unshift(name); @@ -3241,6 +3360,7 @@ var Base = Ext.Base = function() {}; delete data.extend; + parentStatics = parentPrototype.$inheritableStatics; if (parentStatics) { @@ -3252,15 +3372,19 @@ var Base = Ext.Base = function() {}; } } } + + if (parentPrototype.config) { clsPrototype.config = Ext.Object.merge({}, parentPrototype.config); } else { clsPrototype.config = {}; } + + if (clsPrototype.$onExtended) { clsPrototype.$onExtended.call(cls, cls, data); } @@ -3269,54 +3393,30 @@ var Base = Ext.Base = function() {}; clsPrototype.$onExtended = data.onClassExtended; delete data.onClassExtended; } + }, true); + Class.registerPreprocessor('statics', function(cls, data) { - var statics = data.statics, - name; - - for (name in statics) { - if (statics.hasOwnProperty(name)) { - cls[name] = statics[name]; - } - } + cls.addStatics(data.statics); delete data.statics; }); + + Class.registerPreprocessor('inheritableStatics', function(cls, data) { - var statics = data.inheritableStatics, - inheritableStatics, - prototype = cls.prototype, - name; - - inheritableStatics = prototype.$inheritableStatics; - - if (!inheritableStatics) { - inheritableStatics = prototype.$inheritableStatics = []; - } - - for (name in statics) { - if (statics.hasOwnProperty(name)) { - cls[name] = statics[name]; - inheritableStatics.push(name); - } - } + cls.addInheritableStatics(data.inheritableStatics); delete data.inheritableStatics; }); - - Class.registerPreprocessor('mixins', function(cls, data) { - cls.mixin(data.mixins); - - delete data.mixins; - }); + Class.registerPreprocessor('config', function(cls, data) { var prototype = cls.prototype; @@ -3337,7 +3437,7 @@ var Base = Ext.Base = function() {}; data[setter] = function(val) { var ret = this[apply].call(this, val, this[pName]); - if (ret !== undefined) { + if (typeof ret != 'undefined') { this[pName] = ret; } @@ -3355,10 +3455,55 @@ var Base = Ext.Base = function() {}; Ext.Object.merge(prototype.config, data.config); delete data.config; }); + + + + + Class.registerPreprocessor('mixins', function(cls, data) { + var mixins = data.mixins, + name, mixin, i, ln; + + delete data.mixins; - Class.setDefaultPreprocessors(['extend', 'statics', 'inheritableStatics', 'mixins', 'config']); + Ext.Function.interceptBefore(data, 'onClassCreated', function(cls) { + if (mixins instanceof Array) { + for (i = 0,ln = mixins.length; i < ln; i++) { + mixin = mixins[i]; + name = mixin.prototype.mixinId || mixin.$className; + + cls.mixin(name, mixin); + } + } + else { + for (name in mixins) { + if (mixins.hasOwnProperty(name)) { + cls.mixin(name, mixins[name]); + } + } + } + }); + }); + + Class.setDefaultPreprocessors([ + 'extend' + + ,'statics' + + + ,'inheritableStatics' + + + ,'config' + + + ,'mixins' + + ]); + + + Ext.extend = function(subclass, superclass, members) { if (arguments.length === 2 && Ext.isObject(superclass)) { members = superclass; @@ -3373,7 +3518,21 @@ var Base = Ext.Base = function() {}; } members.extend = superclass; - members.preprocessors = ['extend', 'mixins', 'config', 'statics']; + members.preprocessors = [ + 'extend' + + ,'statics' + + + ,'inheritableStatics' + + + ,'mixins' + + + ,'config' + + ]; if (subclass) { cls = new Class(subclass, members); @@ -3392,6 +3551,7 @@ var Base = Ext.Base = function() {}; return cls; }; + })(); @@ -3512,10 +3672,11 @@ var Base = Ext.Base = function() {}; setNamespace: function(name, value) { var root = Ext.global, parts = this.parseNamespace(name), - leaf = parts.pop(), - i, ln, part; + ln = parts.length - 1, + leaf = parts[ln], + i, part; - for (i = 0, ln = parts.length; i < ln; i++) { + for (i = 0; i < ln; i++) { part = parts[i]; if (typeof part !== 'string') { @@ -3670,7 +3831,7 @@ var Base = Ext.Base = function() {}; registeredPostprocessors = manager.postprocessors, index = 0, postprocessors = [], - postprocessor, postprocessors, process, i, ln; + postprocessor, process, i, ln; delete data.postprocessors; @@ -3915,33 +4076,21 @@ var Base = Ext.Base = function() {}; } }; + var defaultPostprocessors = Manager.defaultPostprocessors; + + Manager.registerPostprocessor('alias', function(name, cls, data) { var aliases = data.alias, - widgetPrefix = 'widget.', - i, ln, alias; + i, ln; - if (!(aliases instanceof Array)) { - aliases = [aliases]; - } + delete data.alias; for (i = 0, ln = aliases.length; i < ln; i++) { alias = aliases[i]; - this.setAlias(cls, alias); } - - - for (i = 0, ln = aliases.length; i < ln; i++) { - alias = aliases[i]; - - if (alias.substring(0, widgetPrefix.length) === widgetPrefix) { - - cls.xtype = cls.$xtype = alias.substring(widgetPrefix.length); - break; - } - } }); @@ -4025,7 +4174,71 @@ var Base = Ext.Base = function() {}; createByAlias: alias(Manager, 'instantiateByAlias'), - define: alias(Manager, 'create'), + + + define: function (className, data, createdFn) { + if (!data.override) { + return Manager.create.apply(Manager, arguments); + } + + var requires = data.requires, + uses = data.uses, + overrideName = className; + + className = data.override; + + + data = Ext.apply({}, data); + delete data.requires; + delete data.uses; + delete data.override; + + + if (typeof requires == 'string') { + requires = [ className, requires ]; + } else if (requires) { + requires = requires.slice(0); + requires.unshift(className); + } else { + requires = [ className ]; + } + + + + + + + + + + + + + + + + return Manager.create(overrideName, { + requires: requires, + uses: uses, + isPartial: true, + constructor: function () { + } + }, function () { + var cls = Manager.get(className); + if (cls.override) { + cls.override(data); + } else { + cls.self.override(data); + } + + if (createdFn) { + + + + createdFn.call(cls); + } + }); + }, getClassName: alias(Manager, 'getName'), @@ -4068,6 +4281,56 @@ var Base = Ext.Base = function() {}; Class.setDefaultPreprocessorPosition('className', 'first'); + Class.registerPreprocessor('xtype', function(cls, data) { + var xtypes = Ext.Array.from(data.xtype), + widgetPrefix = 'widget.', + aliases = Ext.Array.from(data.alias), + i, ln, xtype; + + data.xtype = xtypes[0]; + data.xtypes = xtypes; + + aliases = data.alias = Ext.Array.from(data.alias); + + for (i = 0,ln = xtypes.length; i < ln; i++) { + xtype = xtypes[i]; + + + aliases.push(widgetPrefix + xtype); + } + + data.alias = aliases; + }); + + Class.setDefaultPreprocessorPosition('xtype', 'last'); + + Class.registerPreprocessor('alias', function(cls, data) { + var aliases = Ext.Array.from(data.alias), + xtypes = Ext.Array.from(data.xtypes), + widgetPrefix = 'widget.', + widgetPrefixLength = widgetPrefix.length, + i, ln, alias, xtype; + + for (i = 0, ln = aliases.length; i < ln; i++) { + alias = aliases[i]; + + + if (alias.substring(0, widgetPrefixLength) === widgetPrefix) { + xtype = alias.substring(widgetPrefixLength); + Ext.Array.include(xtypes, xtype); + + if (!cls.xtype) { + cls.xtype = data.xtype = xtype; + } + } + } + + data.alias = aliases; + data.xtypes = xtypes; + }); + + Class.setDefaultPreprocessorPosition('alias', 'last'); + })(Ext.Class, Ext.Function.alias); @@ -4616,7 +4879,7 @@ var Base = Ext.Base = function() {}; } } } - else { + else if (typeof propertyValue != 'function') { for (j in propertyValue) { if (propertyValue.hasOwnProperty(j)) { value = propertyValue[j]; @@ -4655,7 +4918,7 @@ var Base = Ext.Base = function() {}; } } } - else { + else if (typeof propertyValue != 'function') { for (var k in propertyValue) { if (propertyValue.hasOwnProperty(k)) { value = propertyValue[k]; @@ -4864,7 +5127,7 @@ Ext.JSON = new(function() { this.encodeDate = function(o) { - return '"' + o.getFullYear() + "-" + return '"' + o.getFullYear() + "-" + pad(o.getMonth() + 1) + "-" + pad(o.getDate()) + "T" + pad(o.getHours()) + ":" @@ -4920,8 +5183,6 @@ Ext.apply(Ext, { userAgent: navigator.userAgent.toLowerCase(), cache: {}, idSeed: 1000, - BLANK_IMAGE_URL : 'data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==', - isStrict: document.compatMode == "CSS1Compat", windowId: 'ext-window', documentId: 'ext-document', @@ -5051,9 +5312,15 @@ window.undefined = window.undefined; (function(){ + var check = function(regex){ return regex.test(Ext.userAgent); }, + isStrict = document.compatMode == "CSS1Compat", + version = function (is, regex) { + var m; + return (is && (m = regex.exec(Ext.userAgent))) ? parseFloat(m[1]) : 0; + }, docMode = document.documentMode, isOpera = check(/opera/), isOpera10_5 = isOpera && check(/version\/10\.5/), @@ -5063,6 +5330,7 @@ window.undefined = window.undefined; isSafari2 = isSafari && check(/applewebkit\/4/), isSafari3 = isSafari && check(/version\/3/), isSafari4 = isSafari && check(/version\/4/), + isSafari5 = isSafari && check(/version\/5/), isIE = !isOpera && check(/msie/), isIE7 = isIE && (check(/msie 7/) || docMode == 7), isIE8 = isIE && (check(/msie 8/) && docMode != 7 && docMode != 9 || docMode == 8), @@ -5071,6 +5339,7 @@ window.undefined = window.undefined; isGecko = !isWebKit && check(/gecko/), isGecko3 = isGecko && check(/rv:1\.9/), isGecko4 = isGecko && check(/rv:2\.0/), + isGecko5 = isGecko && check(/rv:5\./), isFF3_0 = isGecko3 && check(/rv:1\.9\.0/), isFF3_5 = isGecko3 && check(/rv:1\.9\.1/), isFF3_6 = isGecko3 && check(/rv:1\.9\.2/), @@ -5078,17 +5347,24 @@ window.undefined = window.undefined; isMac = check(/macintosh|mac os x/), isLinux = check(/linux/), scrollbarSize = null, - webKitVersion = isWebKit && (/webkit\/(\d+\.\d+)/.exec(Ext.userAgent)); + chromeVersion = version(true, /\bchrome\/(\d+\.\d+)/), + firefoxVersion = version(true, /\bfirefox\/(\d+\.\d+)/), + ieVersion = version(isIE, /msie (\d+\.\d+)/), + operaVersion = version(isOpera, /version\/(\d+\.\d+)/), + safariVersion = version(isSafari, /version\/(\d+\.\d+)/), + webKitVersion = version(isWebKit, /webkit\/(\d+\.\d+)/), + isSecure = /^https/i.test(window.location.protocol); try { document.execCommand("BackgroundImageCache", false, true); } catch(e) {} - Ext.setVersion('extjs', '4.0.2'); + + Ext.setVersion('extjs', '4.0.7'); Ext.apply(Ext, { - SSL_SECURE_URL : Ext.isSecure && isIE ? 'javascript:""' : 'about:blank', + SSL_SECURE_URL : isSecure && isIE ? 'javascript:""' : 'about:blank', @@ -5147,6 +5423,10 @@ window.undefined = window.undefined; } }, + isStrict: isStrict, + + isIEQuirks: isIE && !isStrict, + isOpera : isOpera, @@ -5169,6 +5449,9 @@ window.undefined = window.undefined; isSafari4 : isSafari4, + isSafari5 : isSafari5, + + isSafari2 : isSafari2, @@ -5196,15 +5479,24 @@ window.undefined = window.undefined; isGecko4 : isGecko4, + isGecko5 : isGecko5, - isFF3_0 : isFF3_0, + isFF3_0 : isFF3_0, + isFF3_5 : isFF3_5, + isFF3_6 : isFF3_6, + isFF4 : 4 <= firefoxVersion && firefoxVersion < 5, + + + isFF5 : 5 <= firefoxVersion && firefoxVersion < 6, + + isLinux : isLinux, @@ -5214,10 +5506,28 @@ window.undefined = window.undefined; isMac : isMac, - webKitVersion: webKitVersion ? parseFloat(webKitVersion[1]) : -1, + chromeVersion: chromeVersion, + + + firefoxVersion: firefoxVersion, + + + ieVersion: ieVersion, + + + operaVersion: operaVersion, + + + safariVersion: safariVersion, + + + webKitVersion: webKitVersion, + + + isSecure: isSecure, - BLANK_IMAGE_URL : (isIE6 || isIE7) ? 'http:/' + '/www.sencha.com/s.gif' : 'data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==', + BLANK_IMAGE_URL : (isIE6 || isIE7) ? '/' + '/www.sencha.com/s.gif' : 'data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==', value : function(v, defaultValue, allowBlank){ @@ -5309,8 +5619,8 @@ window.undefined = window.undefined; }, - log : function (message) { - }, + log : + Ext.emptyFn, partition : function(arr, truth){ @@ -5462,7 +5772,7 @@ Ext.application = function(config) { for (; i < decimals; i++) { format += '0'; } - v = UtilFormat.number(v, format); + v = UtilFormat.number(v, format); if ((end || UtilFormat.currencyAtEnd) === true) { return Ext.String.format("{0}{1}{2}", negativeSign, v, currencySign || UtilFormat.currencySign); } else { @@ -5602,7 +5912,7 @@ Ext.application = function(config) { fnum = psplit[0] + dec + psplit[1]; } } - + if (neg) { neg = fnum.replace(/[^1-9]/g, '') !== ''; @@ -6202,7 +6512,7 @@ Ext.supports = { Ext.ns('Ext.core'); -Ext.core.DomHelper = function(){ +Ext.core.DomHelper = 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, @@ -6234,11 +6544,11 @@ Ext.core.DomHelper = function(){ (sibling == 'firstChild' ? el : el.parentNode).insertBefore(newNode, el[sibling] || el); } } else { - newNode = Ext.core.DomHelper.insertHtml(pos, el, Ext.core.DomHelper.createHtml(o)); + newNode = Ext.DomHelper.insertHtml(pos, el, Ext.DomHelper.createHtml(o)); } return returnElement ? Ext.get(newNode, true) : newNode; } - + function createDom(o, parentNode){ var el, doc = document, @@ -6271,7 +6581,7 @@ Ext.core.DomHelper = function(){ } } } - Ext.core.DomHelper.applyStyles(el, o.style); + Ext.DomHelper.applyStyles(el, o.style); if ((cn = o.children || o.cn)) { createDom(cn, el); @@ -6386,14 +6696,14 @@ Ext.core.DomHelper = function(){ el.insertBefore(node, before); return node; } + - function createContextualFragment(html){ var div = document.createElement("div"), fragment = document.createDocumentFragment(), i = 0, length, childNodes; - + div.innerHTML = html; childNodes = div.childNodes; length = childNodes.length; @@ -6404,7 +6714,7 @@ Ext.core.DomHelper = function(){ return fragment; } - + pub = { markup : function(o){ @@ -6419,7 +6729,7 @@ Ext.core.DomHelper = function(){ styles = styles.call(); } if (typeof styles == "string") { - styles = Ext.core.Element.parseStyles(styles); + styles = Ext.Element.parseStyles(styles); } if (typeof styles == "object") { el.setStyle(styles); @@ -6441,13 +6751,13 @@ Ext.core.DomHelper = function(){ hash[beforebegin] = ['BeforeBegin', 'previousSibling']; hash[afterend] = ['AfterEnd', 'nextSibling']; - + if (el.insertAdjacentHTML) { if(tableRe.test(el.tagName) && (rs = insertIntoTable(el.tagName.toLowerCase(), where, el, html))){ return rs; } - + hash[afterbegin] = ['AfterBegin', 'firstChild']; hash[beforeend] = ['BeforeEnd', 'lastChild']; @@ -6459,7 +6769,7 @@ Ext.core.DomHelper = function(){ } else { if (Ext.isTextNode(el)) { - where = where === 'afterbegin' ? 'beforebegin' : where; + where = where === 'afterbegin' ? 'beforebegin' : where; where = where === 'beforeend' ? 'afterend' : where; } range = Ext.supports.CreateContextualFragment ? el.ownerDocument.createRange() : undefined; @@ -6482,7 +6792,7 @@ Ext.core.DomHelper = function(){ } else { frag = createContextualFragment(html); } - + if(where == afterbegin){ el.insertBefore(frag, el.firstChild); }else{ @@ -6524,16 +6834,16 @@ Ext.core.DomHelper = function(){ }, createHtml : createHtml, - + createDom: createDom, - + useDom : false, - + createTemplate : function(o){ - var html = Ext.core.DomHelper.createHtml(o); + var html = Ext.DomHelper.createHtml(o); return Ext.create('Ext.Template', html); } }; @@ -6555,6 +6865,7 @@ Ext.core.DomQuery = Ext.DomQuery = function(){ tagTokenRe = /^(#)?([\w-\*]+)/, nthRe = /(\d*)n\+?(\d*)/, nthRe2 = /\D/, + startIdRe = /^\s*\#/, @@ -7029,12 +7340,22 @@ Ext.core.DomQuery = Ext.DomQuery = function(){ select : document.querySelectorAll ? function(path, root, type) { root = root || document; - if (!Ext.DomQuery.isXml(root)) { - try { - var cs = root.querySelectorAll(path); - return Ext.Array.toArray(cs); - } - catch (ex) {} + + if (!Ext.DomQuery.isXml(root) && !(Ext.isSafari3 && !Ext.isStrict)) { + try { + + var isDocumentRoot = root.nodeType === 9, + _path = path, + _root = root; + + if (!isDocumentRoot && path.indexOf(',') === -1 && !startIdRe.test(path)) { + _path = '#' + Ext.id(root) + ' ' + path; + _root = root.parentNode; + } + return Ext.Array.toArray(_root.querySelectorAll(_path)); + } + catch (e) { + } } return Ext.DomQuery.jsSelect.call(this, path, root, type); } : function(path, root, type) { @@ -7353,8 +7674,8 @@ Ext.query = Ext.DomQuery.select; this.id = id || Ext.id(dom); }; - var DH = Ext.core.DomHelper, - El = Ext.core.Element; + var DH = Ext.DomHelper, + El = Ext.Element; El.prototype = { @@ -7501,7 +7822,7 @@ Ext.query = Ext.DomQuery.select; } - if (size === "" || size == "auto" || size === undefined || size === null) { + if (size === "" || size == "auto" || size == null) { return size || ''; } @@ -7538,7 +7859,7 @@ Ext.query = Ext.DomQuery.select; contains: function(el) { - return ! el ? false: Ext.core.Element.isAncestor(this.dom, el.dom ? el.dom: el); + return ! el ? false: Ext.Element.isAncestor(this.dom, el.dom ? el.dom: el); }, @@ -7665,6 +7986,31 @@ Ext.query = Ext.DomQuery.select; return null; }; + + ep.getById = (!Ext.isIE6 && !Ext.isIE7 && !Ext.isIE8) ? El.get : + function (id) { + var dom = this.dom, + cached, el, ret; + + if (dom) { + el = dom.all[id]; + if (el) { + + + cached = EC[id]; + if (cached && cached.el) { + ret = cached.el; + ret.dom = el; + } else { + ret = El.addToCache(new El(el)); + } + return ret; + } + } + + return El.get(id); + }; + El.addToCache = function(el, id) { if (el) { id = id || el.id; @@ -7796,7 +8142,7 @@ Ext.query = Ext.DomQuery.select; })(); -Ext.core.Element.addMethods({ +Ext.Element.addMethods({ findParent : function(simpleSelector, maxDepth, returnEl) { var p = this.dom, @@ -7818,7 +8164,7 @@ Ext.core.Element.addMethods({ } return null; }, - + findParentNode : function(simpleSelector, maxDepth, returnEl) { var p = Ext.fly(this.dom.parentNode, '_internal'); @@ -7832,7 +8178,7 @@ Ext.core.Element.addMethods({ select : function(selector) { - return Ext.core.Element.select(selector, false, this.dom); + return Ext.Element.select(selector, false, this.dom); }, @@ -7888,7 +8234,7 @@ Ext.core.Element.addMethods({ if (!this.dom) { return null; } - + var n = this.dom[start]; while (n) { if (n.nodeType == 1 && (!selector || Ext.DomQuery.is(n, selector))) { @@ -7901,7 +8247,7 @@ Ext.core.Element.addMethods({ }); -Ext.core.Element.addMethods({ +Ext.Element.addMethods({ appendChild : function(el) { return Ext.get(el).appendTo(this); @@ -7966,9 +8312,9 @@ Ext.core.Element.addMethods({ } }else{ if (isAfter && !me.dom.nextSibling) { - rt = Ext.core.DomHelper.append(me.dom.parentNode, el, !returnDom); + rt = Ext.DomHelper.append(me.dom.parentNode, el, !returnDom); } else { - rt = Ext.core.DomHelper[isAfter ? 'insertAfter' : 'insertBefore'](me.dom, el, !returnDom); + rt = Ext.DomHelper[isAfter ? 'insertAfter' : 'insertBefore'](me.dom, el, !returnDom); } } return rt; @@ -7990,13 +8336,13 @@ Ext.core.Element.addMethods({ el = Ext.get(el); me.dom.parentNode.insertBefore(el, me.dom); }else{ - el = Ext.core.DomHelper.insertBefore(me.dom, el); + el = Ext.DomHelper.insertBefore(me.dom, el); } delete Ext.cache[me.id]; Ext.removeNode(me.dom); me.id = Ext.id(me.dom = el); - Ext.core.Element.addToCache(me.isFlyweight ? new Ext.core.Element(me.dom) : me); + Ext.Element.addToCache(me.isFlyweight ? new Ext.Element(me.dom) : me); return me; }, @@ -8004,16 +8350,16 @@ Ext.core.Element.addMethods({ createChild : function(config, insertBefore, returnDom) { config = config || {tag:'div'}; if (insertBefore) { - return Ext.core.DomHelper.insertBefore(insertBefore, config, returnDom !== true); + return Ext.DomHelper.insertBefore(insertBefore, config, returnDom !== true); } else { - return Ext.core.DomHelper[!this.dom.firstChild ? 'insertFirst' : 'append'](this.dom, config, returnDom !== true); + return Ext.DomHelper[!this.dom.firstChild ? 'insertFirst' : 'append'](this.dom, config, returnDom !== true); } }, wrap : function(config, returnDom) { - var newEl = Ext.core.DomHelper.insertBefore(this.dom, config || {tag: "div"}, !returnDom), + var newEl = Ext.DomHelper.insertBefore(this.dom, config || {tag: "div"}, !returnDom), d = newEl.dom || newEl; d.appendChild(this.dom); @@ -8022,16 +8368,16 @@ Ext.core.Element.addMethods({ insertHtml : function(where, html, returnEl) { - var el = Ext.core.DomHelper.insertHtml(where, this.dom, html); + var el = Ext.DomHelper.insertHtml(where, this.dom, html); return returnEl ? Ext.get(el) : el; } }); (function(){ - Ext.core.Element.boxMarkup = '