X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/7a654f8d43fdb43d78b63d90528bed6e86b608cc..6746dc89c47ed01b165cc1152533605f97eb8e8d:/ext-all-debug.js diff --git a/ext-all-debug.js b/ext-all-debug.js index 674494ad..ba428b54 100644 --- a/ext-all-debug.js +++ b/ext-all-debug.js @@ -1,9 +1,23 @@ +/* + +This file is part of Ext JS 4 + +Copyright (c) 2011 Sencha Inc + +Contact: http://www.sencha.com/contact + +GNU General Public License Usage +This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. + +If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact. + +*/ (function() { var global = this, objectPrototype = Object.prototype, - toString = Object.prototype.toString, + toString = objectPrototype.toString, enumerables = true, enumerablesTest = { toString: 1 }, i; @@ -122,13 +136,6 @@ }; } - if (!superclass) { - Ext.Error.raise({ - sourceClass: 'Ext', - sourceMethod: 'extend', - msg: 'Attempting to extend from a class which has not been loaded on the page.' - }); - } var F = function() {}, @@ -222,11 +229,6 @@ return 'object'; } - Ext.Error.raise({ - sourceClass: 'Ext', - sourceMethod: 'typeOf', - msg: 'Failed to determine the type of the specified value "' + value + '". This is most likely a bug.' - }); }, @@ -247,7 +249,8 @@ isObject: (toString.call(null) === '[object Object]') ? function(value) { - return value !== null && value !== undefined && toString.call(value) === '[object Object]' && value.nodeType === undefined; + + return value !== null && value !== undefined && toString.call(value) === '[object Object]' && value.ownerDocument === undefined; } : function(value) { return toString.call(value) === '[object Object]'; @@ -292,7 +295,7 @@ isElement: function(value) { - return value ? value.nodeType !== undefined : false; + return value ? value.nodeType === 1 : false; }, @@ -372,7 +375,7 @@ var i = 0; do { - uniqueGlobalNamespace = 'ExtSandbox' + (++i); + uniqueGlobalNamespace = 'ExtBox' + (++i); } while (Ext.global[uniqueGlobalNamespace] !== undefined); Ext.global[uniqueGlobalNamespace] = Ext; @@ -404,7 +407,7 @@ (function() { -var version = '4.0.0', Version; +var version = '4.0.2', Version; Ext.Version = Version = Ext.extend(Object, { @@ -592,6 +595,7 @@ Ext.String = { * 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 */ htmlEncode: (function() { var entities = { @@ -729,6 +733,26 @@ Ext.Number = { }, + snap : function(value, increment, minValue, maxValue) { + var newValue = value, + m; + + if (!(increment && value)) { + return value; + } + m = value % increment; + if (m !== 0) { + newValue -= m; + if (m * 2 >= increment) { + newValue += increment; + } else if (m * 2 < -increment) { + newValue -= increment; + } + } + return Ext.Number.constrain(newValue, minValue, maxValue); + }, + + toFixed: function(value, precision) { if (isToFixedBroken) { precision = precision || 0; @@ -760,6 +784,34 @@ Ext.num = function() { var arrayPrototype = Array.prototype, slice = arrayPrototype.slice, + supportsSplice = function () { + var array = [], + lengthBefore, + j = 20; + + if (!array.splice) { + return false; + } + + + + + while (j--) { + array.push("A"); + } + + array.splice(15, 0, "F", "F", "F", "F", "F","F","F","F","F","F","F","F","F","F","F","F","F","F","F","F","F"); + + lengthBefore = array.length; + array.splice(13, 0, "XXX"); + + if (lengthBefore+1 != array.length) { + return false; + } + + + return true; + }(), supportsForEach = 'forEach' in arrayPrototype, supportsMap = 'map' in arrayPrototype, supportsIndexOf = 'indexOf' in arrayPrototype, @@ -772,6 +824,7 @@ Ext.num = function() { }(), supportsSliceOnNodeList = true, ExtArray; + try { if (typeof document !== 'undefined') { @@ -781,6 +834,99 @@ Ext.num = function() { supportsSliceOnNodeList = false; } + function fixArrayIndex (array, index) { + return (index < 0) ? Math.max(0, array.length + index) + : Math.min(array.length, index); + } + + + function replaceSim (array, index, removeCount, insert) { + var add = insert ? insert.length : 0, + length = array.length, + pos = fixArrayIndex(array, index); + + + if (pos === length) { + if (add) { + array.push.apply(array, insert); + } + } else { + var remove = Math.min(removeCount, length - pos), + tailOldPos = pos + remove, + tailNewPos = tailOldPos + add - remove, + tailCount = length - tailOldPos, + lengthAfterRemove = length - remove, + i; + + if (tailNewPos < tailOldPos) { + for (i = 0; i < tailCount; ++i) { + array[tailNewPos+i] = array[tailOldPos+i]; + } + } else if (tailNewPos > tailOldPos) { + for (i = tailCount; i--; ) { + array[tailNewPos+i] = array[tailOldPos+i]; + } + } + + if (add && pos === lengthAfterRemove) { + array.length = lengthAfterRemove; + array.push.apply(array, insert); + } else { + array.length = lengthAfterRemove + add; + for (i = 0; i < add; ++i) { + array[pos+i] = insert[i]; + } + } + } + + return array; + } + + function replaceNative (array, index, removeCount, insert) { + if (insert && insert.length) { + if (index < array.length) { + array.splice.apply(array, [index, removeCount].concat(insert)); + } else { + array.push.apply(array, insert); + } + } else { + array.splice(index, removeCount); + } + return array; + } + + function eraseSim (array, index, removeCount) { + return replaceSim(array, index, removeCount); + } + + function eraseNative (array, index, removeCount) { + array.splice(index, removeCount); + return array; + } + + function spliceSim (array, index, removeCount) { + var pos = fixArrayIndex(array, index), + removed = array.slice(index, fixArrayIndex(array, pos+removeCount)); + + if (arguments.length < 4) { + replaceSim(array, pos, removeCount); + } else { + replaceSim(array, pos, removeCount, slice.call(arguments, 3)); + } + + return removed; + } + + function spliceNative (array) { + return array.splice.apply(array, slice.call(arguments, 1)); + } + + var erase = supportsSplice ? eraseNative : eraseSim, + replace = supportsSplice ? replaceNative : replaceSim, + splice = supportsSplice ? spliceNative : spliceSim; + + + ExtArray = Ext.Array = { each: function(array, fn, scope, reverse) { @@ -915,9 +1061,6 @@ Ext.num = function() { every: function(array, fn, scope) { - if (!fn) { - Ext.Error.raise('Ext.Array.every must have a callback function passed as second argument.'); - } if (supportsEvery) { return array.every(fn, scope); } @@ -936,9 +1079,6 @@ Ext.num = function() { some: function(array, fn, scope) { - if (!fn) { - Ext.Error.raise('Ext.Array.some must have a callback function passed as second argument.'); - } if (supportsSome) { return array.some(fn, scope); } @@ -1032,7 +1172,7 @@ Ext.num = function() { var index = ExtArray.indexOf(array, item); if (index !== -1) { - array.splice(index, 1); + erase(array, index, 1); } return array; @@ -1081,8 +1221,8 @@ Ext.num = function() { } } - minArray = Ext.Array.unique(minArray); - arrays.splice(x, 1); + minArray = ExtArray.unique(minArray); + erase(arrays, x, 1); @@ -1116,7 +1256,7 @@ Ext.num = function() { for (i = 0,lnB = arrayB.length; i < lnB; i++) { for (j = 0; j < ln; j++) { if (clone[j] === arrayB[i]) { - clone.splice(j, 1); + erase(clone, j, 1); j--; ln--; } @@ -1127,6 +1267,11 @@ Ext.num = function() { }, + slice: function(array, begin, end) { + return slice.call(array, begin, end); + }, + + sort: function(array, sortFn) { if (supportsSort) { if (sortFn) { @@ -1249,48 +1394,61 @@ Ext.num = function() { } return sum; - } + }, + + + + erase: erase, + + + insert: function (array, index, items) { + return replace(array, index, 0, items); + }, + + replace: replace, + + + splice: splice }; - Ext.each = Ext.Array.each; + Ext.each = ExtArray.each; - Ext.Array.union = Ext.Array.merge; + ExtArray.union = ExtArray.merge; - Ext.min = Ext.Array.min; + Ext.min = ExtArray.min; - Ext.max = Ext.Array.max; + Ext.max = ExtArray.max; - Ext.sum = Ext.Array.sum; + Ext.sum = ExtArray.sum; - Ext.mean = Ext.Array.mean; + Ext.mean = ExtArray.mean; - Ext.flatten = Ext.Array.flatten; + Ext.flatten = ExtArray.flatten; - Ext.clean = Ext.Array.clean; + Ext.clean = ExtArray.clean; - Ext.unique = Ext.Array.unique; + Ext.unique = ExtArray.unique; - Ext.pluck = Ext.Array.pluck; + Ext.pluck = ExtArray.pluck; Ext.toArray = function() { return ExtArray.toArray.apply(ExtArray, arguments); - } + }; })(); - Ext.Function = { @@ -1325,22 +1483,21 @@ Ext.Function = { }; }, - + bind: function(fn, scope, args, appendArgs) { var method = fn, - applyArgs; + slice = Array.prototype.slice; return function() { var callArgs = args || arguments; if (appendArgs === true) { - callArgs = Array.prototype.slice.call(arguments, 0); + callArgs = slice.call(arguments, 0); callArgs = callArgs.concat(args); } else if (Ext.isNumber(appendArgs)) { - callArgs = Array.prototype.slice.call(arguments, 0); - applyArgs = [appendArgs, 0].concat(args); - Array.prototype.splice.apply(callArgs, applyArgs); + callArgs = slice.call(arguments, 0); + Ext.Array.insert(callArgs, appendArgs, args); } return method.apply(scope || window, callArgs); @@ -1577,15 +1734,6 @@ var ExtObject = Ext.Object = { matchedKeys = name.match(/(\[):?([^\]]*)\]/g); matchedName = name.match(/^([^\[]+)/); - if (!matchedName) { - Ext.Error.raise({ - sourceClass: "Ext.Object", - sourceMethod: "fromQueryString", - queryString: queryString, - recursive: recursive, - msg: 'Malformed query string given, failed parsing name from "' + part + '"' - }); - } name = matchedName[0]; keys = []; @@ -2674,13 +2822,6 @@ var Base = Ext.Base = function() {}; parentClass, methodName; if (!method.$owner) { - if (!method.caller) { - Ext.Error.raise({ - sourceClass: Ext.getClassName(this), - sourceMethod: "callParent", - msg: "Attempting to call a protected method from the public scope, which is not allowed" - }); - } method = method.caller; } @@ -2688,14 +2829,6 @@ var Base = Ext.Base = function() {}; parentClass = method.$owner.superclass; methodName = method.$name; - if (!(methodName in parentClass)) { - Ext.Error.raise({ - sourceClass: Ext.getClassName(this), - sourceMethod: methodName, - msg: "this.callParent() was called but there's no such method (" + methodName + - ") found in the parent class (" + (Ext.getClassName(parentClass) || 'Object') + ")" - }); - } return parentClass[methodName].apply(this, args || []); }, @@ -2717,22 +2850,6 @@ var Base = Ext.Base = function() {}; callOverridden: function(args) { var method = this.callOverridden.caller; - if (!method.$owner) { - Ext.Error.raise({ - sourceClass: Ext.getClassName(this), - sourceMethod: "callOverridden", - msg: "Attempting to call a protected method from the public scope, which is not allowed" - }); - } - - if (!method.$previous) { - Ext.Error.raise({ - sourceClass: Ext.getClassName(this), - sourceMethod: "callOverridden", - msg: "this.callOverridden was called in '" + method.$name + - "' but this method has never been overridden" - }); - } return method.$previous.apply(this, args || []); }, @@ -2769,11 +2886,6 @@ var Base = Ext.Base = function() {}; }; } - var className; - className = Ext.getClassName(this); - if (className) { - fn.displayName = className + '#' + name; - } fn.$owner = this; fn.$name = name; @@ -2795,7 +2907,6 @@ var Base = Ext.Base = function() {}; implement: function(members) { var prototype = this.prototype, name, i, member, previous; - var className = Ext.getClassName(this); for (name in members) { if (members.hasOwnProperty(name)) { member = members[name]; @@ -2803,9 +2914,6 @@ var Base = Ext.Base = function() {}; if (typeof member === 'function') { member.$owner = this; member.$name = name; - if (className) { - member.displayName = className + '#' + name; - } } prototype[name] = member; @@ -3090,13 +3198,14 @@ var Base = Ext.Base = function() {}; index = Ext.Array.indexOf(defaultPreprocessors, relativeName); if (index !== -1) { - defaultPreprocessors.splice(Math.max(0, index + offset), 0, name); + Ext.Array.splice(defaultPreprocessors, Math.max(0, index + offset), 0, name); } return this; } }); + Class.registerPreprocessor('extend', function(cls, data) { var extend = data.extend, base = Ext.Base, @@ -3163,6 +3272,7 @@ var Base = Ext.Base = function() {}; }, true); + Class.registerPreprocessor('statics', function(cls, data) { var statics = data.statics, name; @@ -3176,6 +3286,7 @@ var Base = Ext.Base = function() {}; delete data.statics; }); + Class.registerPreprocessor('inheritableStatics', function(cls, data) { var statics = data.inheritableStatics, inheritableStatics, @@ -3198,12 +3309,14 @@ var Base = Ext.Base = function() {}; 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; @@ -3317,20 +3430,11 @@ var Base = Ext.Base = function() {}; instantiators: [], - - instantiationCounts: {}, isCreated: function(className) { var i, ln, part, root, parts; - if (typeof className !== 'string' || className.length < 1) { - Ext.Error.raise({ - sourceClass: "Ext.ClassManager", - sourceMethod: "exist", - msg: "Invalid classname, must be a string and must not be empty" - }); - } if (this.classes.hasOwnProperty(className) || this.existCache.hasOwnProperty(className)) { return true; @@ -3362,13 +3466,6 @@ var Base = Ext.Base = function() {}; parseNamespace: function(namespace) { - if (typeof namespace !== 'string') { - Ext.Error.raise({ - sourceClass: "Ext.ClassManager", - sourceMethod: "parseNamespace", - msg: "Invalid namespace, must be a string" - }); - } var cache = this.namespaceParseCache; @@ -3516,10 +3613,6 @@ var Base = Ext.Base = function() {}; } if (alias && aliasToNameMap[alias] !== className) { - if (aliasToNameMap.hasOwnProperty(alias) && Ext.isDefined(Ext.global.console)) { - Ext.global.console.log("[Ext.ClassManager] Overriding existing alias: '" + alias + "' " + - "of: '" + aliasToNameMap[alias] + "' with: '" + className + "'. Be sure it's intentional."); - } aliasToNameMap[alias] = className; } @@ -3569,13 +3662,6 @@ var Base = Ext.Base = function() {}; create: function(className, data, createdFn) { var manager = this; - if (typeof className !== 'string') { - Ext.Error.raise({ - sourceClass: "Ext", - sourceMethod: "define", - msg: "Invalid class name '" + className + "' specified, must be a non-empty string" - }); - } data.$className = className; @@ -3641,18 +3727,7 @@ var Base = Ext.Base = function() {}; if (!className) { className = this.maps.aliasToName[alias]; - if (!className) { - Ext.Error.raise({ - sourceClass: "Ext", - sourceMethod: "createByAlias", - msg: "Cannot create an instance of unrecognized alias: " + alias - }); - } - if (Ext.global.console) { - Ext.global.console.warn("[Ext.Loader] Synchronously loading '" + className + "'; consider adding " + - "Ext.require('" + alias + "') above Ext.onReady"); - } Ext.syncRequire(className); } @@ -3670,13 +3745,6 @@ var Base = Ext.Base = function() {}; possibleName, cls; if (typeof name !== 'function') { - if ((typeof name !== 'string' || name.length < 1)) { - Ext.Error.raise({ - sourceClass: "Ext", - sourceMethod: "create", - msg: "Invalid class name or alias '" + name + "' specified, must be a non-empty string" - }); - } cls = this.get(name); } @@ -3708,37 +3776,13 @@ var Base = Ext.Base = function() {}; if (!cls) { - if (Ext.global.console) { - Ext.global.console.warn("[Ext.Loader] Synchronously loading '" + name + "'; consider adding " + - "Ext.require('" + ((possibleName) ? alias : name) + "') above Ext.onReady"); - } Ext.syncRequire(name); cls = this.get(name); } - if (!cls) { - Ext.Error.raise({ - sourceClass: "Ext", - sourceMethod: "create", - msg: "Cannot create an instance of unrecognized class name / alias: " + alias - }); - } - - if (typeof cls !== 'function') { - Ext.Error.raise({ - sourceClass: "Ext", - sourceMethod: "create", - msg: "'" + name + "' is a singleton and cannot be instantiated" - }); - } - - if (!this.instantiationCounts[name]) { - this.instantiationCounts[name] = 0; - } - this.instantiationCounts[name]++; return this.getInstantiator(args.length)(cls, args); }, @@ -3814,7 +3858,7 @@ var Base = Ext.Base = function() {}; index = Ext.Array.indexOf(defaultPostprocessors, relativeName); if (index !== -1) { - defaultPostprocessors.splice(Math.max(0, index + offset), 0, name); + Ext.Array.splice(defaultPostprocessors, Math.max(0, index + offset), 0, name); } return this; @@ -3826,13 +3870,6 @@ var Base = Ext.Base = function() {}; names = [], name, alias, aliases, possibleName, regex, i, ln; - if (typeof expression !== 'string' || expression.length < 1) { - Ext.Error.raise({ - sourceClass: "Ext.ClassManager", - sourceMethod: "getNamesByExpression", - msg: "Expression " + expression + " is invalid, must be a non-empty string" - }); - } if (expression.indexOf('*') !== -1) { expression = expression.replace(/\*/g, '(.*?)'); @@ -3878,6 +3915,7 @@ var Base = Ext.Base = function() {}; } }; + Manager.registerPostprocessor('alias', function(name, cls, data) { var aliases = data.alias, widgetPrefix = 'widget.', @@ -3890,13 +3928,6 @@ var Base = Ext.Base = function() {}; for (i = 0, ln = aliases.length; i < ln; i++) { alias = aliases[i]; - if (typeof alias !== 'string') { - Ext.Error.raise({ - sourceClass: "Ext", - sourceMethod: "define", - msg: "Invalid alias of: '" + alias + "' for class: '" + name + "'; must be a valid string" - }); - } this.setAlias(cls, alias); } @@ -3913,11 +3944,13 @@ var Base = Ext.Base = function() {}; } }); + Manager.registerPostprocessor('singleton', function(name, cls, data, fn) { fn.call(this, name, new cls(), data); return false; }); + Manager.registerPostprocessor('alternateClassName', function(name, cls, data) { var alternates = data.alternateClassName, i, ln, alternate; @@ -3929,13 +3962,6 @@ var Base = Ext.Base = function() {}; for (i = 0, ln = alternates.length; i < ln; i++) { alternate = alternates[i]; - if (typeof alternate !== 'string') { - Ext.Error.raise({ - sourceClass: "Ext", - sourceMethod: "define", - msg: "Invalid alternate of: '" + alternate + "' for class: '" + name + "'; must be a valid string" - }); - } this.set(alternate, cls); } @@ -4028,6 +4054,7 @@ var Base = Ext.Base = function() {}; namespace: alias(Manager, 'createNamespaces') }); + Ext.createWidget = Ext.widget; @@ -4036,7 +4063,6 @@ var Base = Ext.Base = function() {}; Class.registerPreprocessor('className', function(cls, data) { if (data.$className) { cls.$className = data.$className; - cls.displayName = cls.$className; } }, true); @@ -4045,7 +4071,6 @@ var Base = Ext.Base = function() {}; })(Ext.Class, Ext.Function.alias); - (function(Manager, Class, flexSetter, alias) { var @@ -4203,7 +4228,7 @@ var Base = Ext.Base = function() {}; do { if (Manager.isCreated(requires[j])) { - requires.splice(j, 1); + Ext.Array.erase(requires, j, 1); } else { j++; @@ -4211,7 +4236,7 @@ var Base = Ext.Base = function() {}; } while (j < requires.length); if (item.requires.length === 0) { - this.queue.splice(i, 1); + Ext.Array.erase(this.queue, i, 1); item.callback.call(item.scope); this.refreshQueue(); break; @@ -4459,48 +4484,7 @@ var Base = Ext.Base = function() {}; this.refreshQueue(); } - if (this.numPendingFiles <= 1) { - window.status = "Finished loading all dependencies, onReady fired!"; - } - else { - window.status = "Loading dependencies, " + this.numPendingFiles + " files left..."; - } - - if (!this.syncModeEnabled && this.numPendingFiles === 0 && this.isLoading && !this.hasFileLoadError) { - var queue = this.queue, - requires, - i, ln, j, subLn, missingClasses = [], missingPaths = []; - - for (i = 0, ln = queue.length; i < ln; i++) { - requires = queue[i].requires; - for (j = 0, subLn = requires.length; j < ln; j++) { - if (this.isFileLoaded[requires[j]]) { - missingClasses.push(requires[j]); - } - } - } - - if (missingClasses.length < 1) { - return; - } - - missingClasses = Ext.Array.filter(missingClasses, function(item) { - return !this.requiresMap.hasOwnProperty(item); - }, this); - - for (i = 0,ln = missingClasses.length; i < ln; i++) { - missingPaths.push(this.classNameToFilePathMap[missingClasses[i]]); - } - - Ext.Error.raise({ - sourceClass: "Ext.Loader", - sourceMethod: "onFileLoaded", - msg: "The following classes are not declared even if their files have been " + - "loaded: '" + missingClasses.join("', '") + "'. Please check the source code of their " + - "corresponding files for possible typos: '" + missingPaths.join("', '") + "'" - }); - } }, @@ -4508,13 +4492,6 @@ var Base = Ext.Base = function() {}; this.numPendingFiles--; this.hasFileLoadError = true; - Ext.Error.raise({ - sourceClass: "Ext.Loader", - classToLoad: className, - loadPath: filePath, - loadingType: isSynchronous ? 'synchronous' : 'async', - msg: errorMessage - }); }, @@ -4612,6 +4589,7 @@ var Base = Ext.Base = function() {}; Loader.onReady(fn, scope, true, options); }; + Class.registerPreprocessor('loader', function(cls, data, continueFn) { var me = this, dependencies = [], @@ -4657,37 +4635,6 @@ var Base = Ext.Base = function() {}; return; } - var deadlockPath = [], - requiresMap = Loader.requiresMap, - detectDeadlock; - - - - if (className) { - requiresMap[className] = dependencies; - - detectDeadlock = function(cls) { - deadlockPath.push(cls); - - if (requiresMap[cls]) { - if (Ext.Array.contains(requiresMap[cls], className)) { - Ext.Error.raise({ - sourceClass: "Ext.Loader", - msg: "Deadlock detected while loading dependencies! '" + className + "' and '" + - deadlockPath[1] + "' " + "mutually require each other. Path: " + - deadlockPath.join(' -> ') + " -> " + deadlockPath[0] - }); - } - - for (i = 0, ln = requiresMap[cls].length; i < ln; i++) { - detectDeadlock(requiresMap[cls][i]); - } - } - }; - - detectDeadlock(className); - } - Loader.require(dependencies, function() { for (i = 0, ln = dependencyProperties.length; i < ln; i++) { @@ -4730,6 +4677,7 @@ var Base = Ext.Base = function() {}; Class.setDefaultPreprocessorPosition('loader', 'after', 'className'); + Manager.registerPostprocessor('uses', function(name, cls, data) { var uses = Ext.Array.from(data.uses), items = [], @@ -4757,6 +4705,9 @@ Ext.Error = Ext.extend(Error, { ignore: false, + + + raise: function(err){ err = err || {}; if (Ext.isString(err)) { @@ -4775,28 +4726,15 @@ Ext.Error = Ext.extend(Error, { } if (Ext.Error.handle(err) !== true) { - var global = Ext.global, - con = global.console, - msg = Ext.Error.prototype.toString.call(err), - noConsoleMsg = 'An uncaught error was raised: "' + msg + - '". Use Firebug or Webkit console for additional details.'; - - if (con) { - if (con.dir) { - con.warn('An uncaught error was raised with the following data:'); - con.dir(err); - } - else { - con.warn(noConsoleMsg); - } - if (con.error) { - con.error(msg); - } - } - else if (global.alert){ - global.alert(noConsoleMsg); - } - + var msg = Ext.Error.prototype.toString.call(err); + + Ext.log({ + msg: msg, + level: 'error', + dump: err, + stack: true + }); + throw new Ext.Error(err); } }, @@ -4808,11 +4746,20 @@ Ext.Error = Ext.extend(Error, { }, + name: 'Ext.Error', + + constructor: function(config){ if (Ext.isString(config)) { config = { msg: config }; } - Ext.apply(this, config); + + var me = this; + + Ext.apply(me, config); + + me.message = me.message || me.msg; + }, @@ -4829,6 +4776,9 @@ Ext.Error = Ext.extend(Error, { + + + Ext.JSON = new(function() { var useHasOwn = !! {}.hasOwnProperty, isNative = function() { @@ -4952,7 +4902,7 @@ Ext.JSON = new(function() { Ext.Error.raise({ sourceClass: "Ext.JSON", sourceMethod: "decode", - msg: "You're trying to decode and invalid JSON String: " + json + msg: "You're trying to decode an invalid JSON String: " + json }); } }; @@ -4986,15 +4936,23 @@ Ext.apply(Ext, { id: function(el, prefix) { + var me = this, + sandboxPrefix = ''; el = Ext.getDom(el, true) || {}; if (el === document) { - el.id = this.documentId; + el.id = me.documentId; } else if (el === window) { - el.id = this.windowId; + el.id = me.windowId; } if (!el.id) { - el.id = (prefix || "ext-gen") + (++Ext.idSeed); + if (me.isSandboxed) { + if (!me.uniqueGlobalNamespace) { + me.getUniqueGlobalNamespace(); + } + sandboxPrefix = me.uniqueGlobalNamespace + '-'; + } + el.id = sandboxPrefix + (prefix || "ext-gen") + (++Ext.idSeed); } return el.id; }, @@ -5091,6 +5049,7 @@ Ext.ns = Ext.namespace; window.undefined = window.undefined; + (function(){ var check = function(regex){ return regex.test(Ext.userAgent); @@ -5118,14 +5077,15 @@ window.undefined = window.undefined; isWindows = check(/windows|win32/), isMac = check(/macintosh|mac os x/), isLinux = check(/linux/), - scrollWidth = null; + scrollbarSize = null, + webKitVersion = isWebKit && (/webkit\/(\d+\.\d+)/.exec(Ext.userAgent)); try { document.execCommand("BackgroundImageCache", false, true); } catch(e) {} - Ext.setVersion('extjs', '4.0.0'); + Ext.setVersion('extjs', '4.0.2'); Ext.apply(Ext, { SSL_SECURE_URL : Ext.isSecure && isIE ? 'javascript:""' : 'about:blank', @@ -5254,6 +5214,9 @@ window.undefined = window.undefined; isMac : isMac, + webKitVersion: webKitVersion ? parseFloat(webKitVersion[1]) : -1, + + BLANK_IMAGE_URL : (isIE6 || isIE7) ? 'http:/' + '/www.sencha.com/s.gif' : 'data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==', @@ -5291,27 +5254,37 @@ window.undefined = window.undefined; }, - getScrollBarWidth: function(force){ + getScrollbarSize: function (force) { if(!Ext.isReady){ return 0; } - if(force === true || scrollWidth === null){ + if(force === true || scrollbarSize === null){ - var cssClass = Ext.isIE9 ? '' : Ext.baseCSSPrefix + 'hide-offsets'; + var cssClass = Ext.isIE9 ? '' : Ext.baseCSSPrefix + 'hide-offsets', - var div = Ext.getBody().createChild('
'), - child = div.child('div', true); - var w1 = child.offsetWidth; + div = Ext.getBody().createChild(' '), + child = div.child('div', true), + w1 = child.offsetWidth; + div.setStyle('overflow', (Ext.isWebKit || Ext.isGecko) ? 'auto' : 'scroll'); - var w2 = child.offsetWidth; + + var w2 = child.offsetWidth, width = w1 - w2; div.remove(); + - scrollWidth = w1 - w2 + 2; + scrollbarSize = { width: width, height: width }; } - return scrollWidth; + + return scrollbarSize; + }, + + + getScrollBarWidth: function(force){ + var size = Ext.getScrollbarSize(force); + return size.width + 2; }, @@ -5328,7 +5301,7 @@ window.undefined = window.undefined; }, - destroyMembers : function(o, arg1, arg2, etc){ + destroyMembers : function(o){ for (var i = 1, a = arguments, len = a.length; i < len; i++) { Ext.destroy(o[a[i]]); delete o[a[i]]; @@ -5336,6 +5309,10 @@ window.undefined = window.undefined; }, + log : function (message) { + }, + + partition : function(arr, truth){ var ret = [[],[]]; Ext.each(arr, function(v, i, a) { @@ -5555,8 +5532,7 @@ Ext.application = function(config) { }, - number: - function(v, formatString) { + number: function(v, formatString) { if (!formatString) { return v; } @@ -5593,13 +5569,6 @@ Ext.application = function(config) { if (1 < psplit.length) { v = v.toFixed(psplit[1].length); } else if(2 < psplit.length) { - Ext.Error.raise({ - sourceClass: "Ext.util.Format", - sourceMethod: "number", - value: v, - formatString: formatString, - msg: "Invalid number format, should have no more than 1 decimal" - }); } else { v = v.toFixed(0); } @@ -5633,6 +5602,11 @@ Ext.application = function(config) { fnum = psplit[0] + dec + psplit[1]; } } + + if (neg) { + + neg = fnum.replace(/[^1-9]/g, '') !== ''; + } return (neg ? '-' : '') + formatString.replace(/[\d,?\.?]+/, fnum); }, @@ -5982,12 +5956,33 @@ Ext.supports = { { identity: 'RightMargin', - fn: function(doc, div, view) { - view = doc.defaultView; + fn: function(doc, div) { + var view = doc.defaultView; return !(view && view.getComputedStyle(div.firstChild.firstChild, null).marginRight != '0px'); } }, + + + { + identity: 'DisplayChangeInputSelectionBug', + fn: function() { + var webKitVersion = Ext.webKitVersion; + + return 0 < webKitVersion && webKitVersion < 533; + } + }, + + { + identity: 'DisplayChangeTextAreaSelectionBug', + fn: function() { + var webKitVersion = Ext.webKitVersion; + + + return 0 < webKitVersion && webKitVersion < 534.24; + } + }, + { identity: 'TransparentColor', @@ -6189,8 +6184,16 @@ Ext.supports = { return range && !!range.createContextualFragment; } - } + }, + + { + identity: 'WindowOnError', + fn: function () { + + return Ext.isIE || Ext.isGecko || Ext.webKitVersion >= 534.16; + } + } ] }; @@ -6491,13 +6494,6 @@ Ext.core.DomHelper = function(){ return el[rangeEl]; } } - Ext.Error.raise({ - sourceClass: 'Ext.core.DomHelper', - sourceMethod: 'insertHtml', - htmlToInsert: html, - targetElement: el, - msg: 'Illegal insertion point reached: "' + where + '"' - }); }, @@ -6976,11 +6972,6 @@ Ext.core.DomQuery = Ext.DomQuery = function(){ } if(!matched){ - Ext.Error.raise({ - sourceClass: 'Ext.DomQuery', - sourceMethod: 'compile', - msg: 'Error parsing selector. Parsing failed at "' + path + '"' - }); } } if(modeMatch[1]){ @@ -7014,11 +7005,6 @@ Ext.core.DomQuery = Ext.DomQuery = function(){ if(!cache[subPath]){ cache[subPath] = Ext.DomQuery.compile(subPath); if(!cache[subPath]){ - Ext.Error.raise({ - sourceClass: 'Ext.DomQuery', - sourceMethod: 'jsSelect', - msg: subPath + ' is not a valid selector' - }); } } var result = cache[subPath](root); @@ -7039,6 +7025,7 @@ Ext.core.DomQuery = Ext.DomQuery = function(){ var docEl = (el ? el.ownerDocument || el : 0).documentElement; return docEl ? docEl.nodeName !== "HTML" : false; }, + select : document.querySelectorAll ? function(path, root, type) { root = root || document; @@ -7520,9 +7507,6 @@ Ext.query = Ext.DomQuery.select; if (!unitPattern.test(size)) { - if (Ext.isDefined(Ext.global.console)) { - Ext.global.console.warn("Warning, size detected as NaN on Element.addUnits."); - } return size || ''; } return size; @@ -8108,11 +8092,11 @@ Ext.core.Element.addMethods({ cls = [], space = ((me.dom.className.replace(trimRe, '') == '') ? "" : " "), i, len, v; - if (!Ext.isDefined(className)) { + if (className === undefined) { return me; } - if (!Ext.isArray(className)) { + if (Object.prototype.toString.call(className) !== '[object Array]') { if (typeof className === 'string') { className = className.replace(trimRe, '').split(spacesRe); if (className.length === 1) { @@ -8142,10 +8126,10 @@ Ext.core.Element.addMethods({ removeCls : function(className){ var me = this, i, idx, len, cls, elClasses; - if (!Ext.isDefined(className)) { + if (className === undefined) { return me; } - if (!Ext.isArray(className)){ + if (Object.prototype.toString.call(className) !== '[object Array]') { className = className.replace(trimRe, '').split(spacesRe); } if (me.dom && me.dom.className) { @@ -8156,7 +8140,7 @@ Ext.core.Element.addMethods({ cls = cls.replace(trimRe, ''); idx = Ext.Array.indexOf(elClasses, cls); if (idx != -1) { - elClasses.splice(idx, 1); + Ext.Array.erase(elClasses, idx, 1); } } } @@ -8223,7 +8207,7 @@ Ext.core.Element.addMethods({ return view && view.getComputedStyle ? function(prop){ var el = this.dom, - v, cs, out, display; + v, cs, out, display, cleaner; if(el == document){ return null; @@ -8235,10 +8219,12 @@ Ext.core.Element.addMethods({ if(prop == 'marginRight' && out != '0px' && !supports.RightMargin){ + cleaner = Ext.core.Element.getRightMarginFixCleaner(el); display = this.getStyle('display'); el.style.display = 'inline-block'; out = view.getComputedStyle(el, '').marginRight; el.style.display = display; + cleaner(); } if(prop == 'backgroundColor' && out == 'rgba(0, 0, 0, 0)' && !supports.TransparentColor){ @@ -8300,8 +8286,7 @@ Ext.core.Element.addMethods({ if (!me.dom) { return me; } - - if (!Ext.isObject(prop)) { + if (typeof prop === 'string') { tmp = {}; tmp[prop] = value; prop = tmp; @@ -8654,7 +8639,8 @@ Ext.core.Element.addMethods({ setSize : function(width, height, animate){ var me = this; - if (Ext.isObject(width)){ + if (Ext.isObject(width)) { + animate = height; height = width.height; width = width.width; } @@ -8665,7 +8651,7 @@ Ext.core.Element.addMethods({ me.dom.style.height = me.addUnits(height); } else { - if (!Ext.isObject(animate)) { + if (animate === true) { animate = {}; } me.animate(Ext.applyIf({ @@ -10026,7 +10012,7 @@ Ext.CompositeElementLite.prototype = { d.parentNode.insertBefore(replacement, d); Ext.removeNode(d); } - this.elements.splice(index, 1, replacement); + Ext.Array.splice(this.elements, index, 1, replacement); } return this; }, @@ -10071,13 +10057,6 @@ Ext.core.Element.select = function(selector, root){ }else if(selector.length !== undefined){ els = selector; }else{ - Ext.Error.raise({ - sourceClass: "Ext.core.Element", - sourceMethod: "select", - selector: selector, - root: root, - msg: "Invalid selector specified: " + selector - }); } return new Ext.CompositeElementLite(els); }; @@ -10153,13 +10132,6 @@ Ext.require('Ext.util.DelayedTask', function() { listener; scope = scope || me.observable; - if (!fn) { - Ext.Error.raise({ - sourceClass: Ext.getClassName(this.observable), - sourceMethod: "addListener", - msg: "The specified callback function is undefined" - }); - } if (!me.isListening(fn, scope)) { listener = me.createListener(fn, scope, options); @@ -10251,7 +10223,7 @@ Ext.require('Ext.util.DelayedTask', function() { } - me.listeners.splice(index, 1); + Ext.Array.erase(me.listeners, index, 1); return true; } @@ -10519,7 +10491,7 @@ Ext.EventManager = { addListener: function(element, eventName, fn, scope, options){ - if (Ext.isObject(eventName)) { + if (typeof eventName !== 'string') { this.prepareListenerConfig(element, eventName); return; } @@ -10528,24 +10500,6 @@ Ext.EventManager = { bind, wrap; - if (!dom){ - Ext.Error.raise({ - sourceClass: 'Ext.EventManager', - sourceMethod: 'addListener', - targetElement: element, - eventName: eventName, - msg: 'Error adding "' + eventName + '\" listener for nonexistent element "' + element + '"' - }); - } - if (!fn) { - Ext.Error.raise({ - sourceClass: 'Ext.EventManager', - sourceMethod: 'addListener', - targetElement: element, - eventName: eventName, - msg: 'Error adding "' + eventName + '\" listener. The handler function is undefined.' - }); - } options = options || {}; @@ -10575,7 +10529,7 @@ Ext.EventManager = { removeListener : function(element, eventName, fn, scope) { - if (Ext.isObject(eventName)) { + if (typeof eventName !== 'string') { this.prepareListenerConfig(element, eventName, true); return; } @@ -10619,7 +10573,7 @@ Ext.EventManager = { } - cache.splice(i, 1); + Ext.Array.erase(cache, i, 1); } } }, @@ -10662,83 +10616,94 @@ Ext.EventManager = { createListenerWrap : function(dom, ename, fn, scope, options) { - options = !Ext.isObject(options) ? {} : options; + options = options || {}; - var f = ['if(!Ext) {return;}'], - gen; + var f, gen; - if(options.buffer || options.delay || options.freezeEvent) { - f.push('e = new Ext.EventObjectImpl(e, ' + (options.freezeEvent ? 'true' : 'false' ) + ');'); - } else { - f.push('e = Ext.EventObject.setEvent(e);'); - } + return function wrap(e, args) { + + if (!gen) { + f = ['if(!Ext) {return;}']; - if (options.delegate) { - f.push('var t = e.getTarget("' + options.delegate + '", this);'); - f.push('if(!t) {return;}'); - } else { - f.push('var t = e.target;'); - } + if(options.buffer || options.delay || options.freezeEvent) { + f.push('e = new Ext.EventObjectImpl(e, ' + (options.freezeEvent ? 'true' : 'false' ) + ');'); + } else { + f.push('e = Ext.EventObject.setEvent(e);'); + } - if (options.target) { - f.push('if(e.target !== options.target) {return;}'); - } + if (options.delegate) { + f.push('var t = e.getTarget("' + options.delegate + '", this);'); + f.push('if(!t) {return;}'); + } else { + f.push('var t = e.target;'); + } - if(options.stopEvent) { - f.push('e.stopEvent();'); - } else { - if(options.preventDefault) { - f.push('e.preventDefault();'); - } - if(options.stopPropagation) { - f.push('e.stopPropagation();'); - } - } + if (options.target) { + f.push('if(e.target !== options.target) {return;}'); + } - if(options.normalized === false) { - f.push('e = e.browserEvent;'); - } + if(options.stopEvent) { + f.push('e.stopEvent();'); + } else { + if(options.preventDefault) { + f.push('e.preventDefault();'); + } + if(options.stopPropagation) { + f.push('e.stopPropagation();'); + } + } - if(options.buffer) { - f.push('(wrap.task && clearTimeout(wrap.task));'); - f.push('wrap.task = setTimeout(function(){'); - } + if(options.normalized === false) { + f.push('e = e.browserEvent;'); + } - if(options.delay) { - f.push('wrap.tasks = wrap.tasks || [];'); - f.push('wrap.tasks.push(setTimeout(function(){'); - } + if(options.buffer) { + f.push('(wrap.task && clearTimeout(wrap.task));'); + f.push('wrap.task = setTimeout(function(){'); + } - - f.push('fn.call(scope || dom, e, t, options);'); + if(options.delay) { + f.push('wrap.tasks = wrap.tasks || [];'); + f.push('wrap.tasks.push(setTimeout(function(){'); + } - if(options.single) { - f.push('Ext.EventManager.removeListener(dom, ename, fn, scope);'); - } + + f.push('fn.call(scope || dom, e, t, options);'); - if(options.delay) { - f.push('}, ' + options.delay + '));'); - } + if(options.single) { + f.push('Ext.EventManager.removeListener(dom, ename, fn, scope);'); + } - if(options.buffer) { - f.push('}, ' + options.buffer + ');'); - } + if(options.delay) { + f.push('}, ' + options.delay + '));'); + } + + if(options.buffer) { + f.push('}, ' + options.buffer + ');'); + } - gen = Ext.functionFactory('e', 'options', 'fn', 'scope', 'ename', 'dom', 'wrap', 'args', f.join('\n')); + gen = Ext.functionFactory('e', 'options', 'fn', 'scope', 'ename', 'dom', 'wrap', 'args', f.join('\n')); + } - return function wrap(e, args) { gen.call(dom, e, options, fn, scope, ename, dom, wrap, args); }; }, getEventListenerCache : function(element, eventName) { + if (!element) { + return []; + } + var eventCache = this.getElementEventCache(element); return eventCache[eventName] || (eventCache[eventName] = []); }, getElementEventCache : function(element) { + if (!element) { + return {}; + } var elementCache = Ext.cache[this.getId(element)]; return elementCache.events || (elementCache.events = {}); }, @@ -10953,7 +10918,7 @@ Ext.EventManager.un = Ext.EventManager.removeListener; var bd = document.body || document.getElementsByTagName('body')[0], baseCSSPrefix = Ext.baseCSSPrefix, - cls = [], + cls = [baseCSSPrefix + 'body'], htmlCls = [], html; @@ -11229,6 +11194,44 @@ Ext.define('Ext.EventObjectImpl', { F11: 122, F12: 123, + + WHEEL_SCALE: (function () { + var scale; + + if (Ext.isGecko) { + + scale = 3; + } else if (Ext.isMac) { + + + + + if (Ext.isSafari && Ext.webKitVersion >= 532.0) { + + + + + + + scale = 120; + } else { + + + scale = 12; + } + + + + + + scale *= 3; + } else { + + scale = 120; + } + + return scale; + })(), clickRe: /(dbl)?click/, @@ -11394,16 +11397,58 @@ Ext.define('Ext.EventObjectImpl', { }, - getWheelDelta : function(){ - var event = this.browserEvent, - delta = 0; + correctWheelDelta : function (delta) { + var scale = this.WHEEL_SCALE, + ret = Math.round(delta / scale + 0.5); + + if (!ret && delta) { + ret = (delta < 0) ? -1 : 1; + } + + return ret; + }, + + + getWheelDeltas : function () { + var me = this, + event = me.browserEvent, + dx = 0, dy = 0; + + if (Ext.isDefined(event.wheelDeltaX)) { + dx = event.wheelDeltaX; + dy = event.wheelDeltaY; + } else if (event.wheelDelta) { + dy = event.wheelDelta; + } else if (event.detail) { + dy = -event.detail; - if (event.wheelDelta) { - delta = event.wheelDelta / 120; - } else if (event.detail){ - delta = -event.detail / 3; + + + if (dy > 100) { + dy = 3; + } else if (dy < -100) { + dy = -3; + } + + + + if (Ext.isDefined(event.axis) && event.axis === event.HORIZONTAL_AXIS) { + dx = dy; + dy = 0; + } } - return delta; + + return { + x: me.correctWheelDelta(dx), + y: me.correctWheelDelta(dy) + }; + }, + + + getWheelDelta : function(){ + var deltas = this.getWheelDeltas(); + + return deltas.y; }, @@ -11524,7 +11569,7 @@ Ext.define('Ext.EventObjectImpl', { return target; } - } + }; } else if (document.createEventObject) { var crazyIEButtons = { 0: 1, 1: 4, 2: 2 }; @@ -11652,7 +11697,6 @@ Ext.define('Ext.EventObjectImpl', { } function cannotInject (target, srcEvent) { - } return function (target) { @@ -11675,6 +11719,7 @@ Ext.EventObject = new Ext.EventObjectImpl(); (function(){ var doc = document, + activeElement = null, isCSS1 = doc.compatMode == "CSS1Compat", ELEMENT = Ext.core.Element, fly = function(el){ @@ -11685,6 +11730,26 @@ Ext.EventObject = new Ext.EventObjectImpl(); return _fly; }, _fly; + + + + if (!('activeElement' in doc) && doc.addEventListener) { + doc.addEventListener('focus', + function (ev) { + if (ev && ev.target) { + activeElement = (ev.target == doc) ? null : ev.target; + } + }, true); + } + + + function makeSelectionRestoreFn (activeEl, start, end) { + return function () { + activeEl.selectionStart = start; + activeEl.selectionEnd = end; + }; + } + Ext.apply(ELEMENT, { isAncestor : function(p, c) { var ret = false; @@ -11705,6 +11770,43 @@ Ext.EventObject = new Ext.EventObjectImpl(); return ret; }, + + getActiveElement: function () { + return doc.activeElement || activeElement; + }, + + + getRightMarginFixCleaner: function (target) { + var supports = Ext.supports, + hasInputBug = supports.DisplayChangeInputSelectionBug, + hasTextAreaBug = supports.DisplayChangeTextAreaSelectionBug; + + if (hasInputBug || hasTextAreaBug) { + var activeEl = doc.activeElement || activeElement, + tag = activeEl && activeEl.tagName, + start, + end; + + if ((hasTextAreaBug && tag == 'TEXTAREA') || + (hasInputBug && tag == 'INPUT' && activeEl.type == 'text')) { + if (ELEMENT.isAncestor(target, activeEl)) { + start = activeEl.selectionStart; + end = activeEl.selectionEnd; + + if (Ext.isNumber(start) && Ext.isNumber(end)) { + + + + + return makeSelectionRestoreFn(activeEl, start, end); + } + } + } + } + + return Ext.emptyFn; + }, + getViewWidth : function(full) { return full ? ELEMENT.getDocumentWidth() : ELEMENT.getViewportWidth(); }, @@ -11851,7 +11953,7 @@ Ext.EventObject = new Ext.EventObjectImpl(); Ext.each(element.options, function(opt){ if (opt.selected) { hasValue = opt.hasAttribute ? opt.hasAttribute('value') : opt.getAttributeNode('value').specified; - data += String.format("{0}={1}&", encoder(name), encoder(hasValue ? opt.value : opt.text)); + data += Ext.String.format("{0}={1}&", encoder(name), encoder(hasValue ? opt.value : opt.text)); } }); } else if (!(/file|undefined|reset|button/i.test(type))) { @@ -12169,11 +12271,6 @@ Ext.core.Element.addMethods({ el = Ext.get(el); if(!el || !el.dom){ - Ext.Error.raise({ - sourceClass: 'Ext.core.Element', - sourceMethod: 'getAlignVector', - msg: 'Attempted to align an element that doesn\'t exist' - }); } elRegion = el.getRegion(); @@ -12184,11 +12281,6 @@ Ext.core.Element.addMethods({ el = Ext.get(el); if(!el || !el.dom){ - Ext.Error.raise({ - sourceClass: 'Ext.core.Element', - sourceMethod: 'getAlignToXY', - msg: 'Attempted to align an element that doesn\'t exist' - }); } o = o || [0,0]; @@ -12223,14 +12315,6 @@ Ext.core.Element.addMethods({ m = p.match(/^([a-z]+)-([a-z]+)(\?)?$/); if(!m){ - Ext.Error.raise({ - sourceClass: 'Ext.core.Element', - sourceMethod: 'getAlignToXY', - el: el, - position: p, - offset: o, - msg: 'Attemmpted to align an element with an invalid position: "' + p + '"' - }); } p1 = m[1]; @@ -13104,7 +13188,7 @@ Ext.apply(Ext.CompositeElementLite.prototype, { Ext.removeNode(el); } } - els.splice(val, 1); + Ext.Array.erase(els, val, 1); } }); return this; @@ -13145,14 +13229,6 @@ Ext.core.Element.select = function(selector, unique, root){ }else if(selector.length !== undefined){ els = selector; }else{ - Ext.Error.raise({ - sourceClass: "Ext.core.Element", - sourceMethod: "select", - selector: selector, - unique: unique, - root: root, - msg: "Invalid selector specified: " + selector - }); } return (unique === true) ? new Ext.CompositeElement(els) : new Ext.CompositeElementLite(els); }; @@ -13163,7 +13239,6 @@ Ext.select = Ext.core.Element.select; - Ext.define('Ext.util.Observable', { @@ -13226,7 +13301,7 @@ Ext.define('Ext.util.Observable', { managedListeners = me.managedListeners = me.managedListeners || [], config; - if (Ext.isObject(ename)) { + if (typeof ename !== 'string') { options = ename; for (ename in options) { if (options.hasOwnProperty(ename)) { @@ -13251,16 +13326,15 @@ Ext.define('Ext.util.Observable', { }, - removeManagedListener : function(item, ename, fn, scope) { + removeManagedListener : function(item, ename, fn, scope) { var me = this, options, config, managedListeners, - managedListener, length, i; - if (Ext.isObject(ename)) { + if (typeof ename !== 'string') { options = ename; for (ename in options) { if (options.hasOwnProperty(ename)) { @@ -13273,14 +13347,9 @@ Ext.define('Ext.util.Observable', { } managedListeners = me.managedListeners ? me.managedListeners.slice() : []; - length = managedListeners.length; - for (i = 0; i < length; i++) { - managedListener = managedListeners[i]; - if (managedListener.item === item && managedListener.ename === ename && (!fn || managedListener.fn === fn) && (!scope || managedListener.scope === scope)) { - Ext.Array.remove(me.managedListeners, managedListener); - item.un(managedListener.ename, managedListener.fn, managedListener.scope); - } + for (i = 0, length = managedListeners.length; i < length; i++) { + me.removeManagedListenerItem(false, managedListeners[i], item, ename, fn, scope); } }, @@ -13298,20 +13367,23 @@ Ext.define('Ext.util.Observable', { if (queue) { queue.push(args); } - } else if (event && Ext.isObject(event) && event.bubble) { - if (event.fire.apply(event, args.slice(1)) === false) { - return false; - } - parent = me.getBubbleTarget && me.getBubbleTarget(); - if (parent && parent.isObservable) { - if (!parent.events[ename] || !Ext.isObject(parent.events[ename]) || !parent.events[ename].bubble) { - parent.enableBubble(ename); + } else if (event && event !== true) { + if (event.bubble) { + if (event.fire.apply(event, args.slice(1)) === false) { + return false; } - return parent.fireEvent.apply(parent, args); + parent = me.getBubbleTarget && me.getBubbleTarget(); + if (parent && parent.isObservable) { + if (!parent.events[ename] || parent.events[ename] === true || !parent.events[ename].bubble) { + parent.enableBubble(ename); + } + return parent.fireEvent.apply(parent, args); + } + } + else { + args.shift(); + ret = event.fire.apply(event, args); } - } else if (event && Ext.isObject(event)) { - args.shift(); - ret = event.fire.apply(event, args); } return ret; }, @@ -13322,7 +13394,7 @@ Ext.define('Ext.util.Observable', { config, event; - if (Ext.isObject(ename)) { + if (typeof ename !== 'string') { options = ename; for (ename in options) { if (options.hasOwnProperty(ename)) { @@ -13351,7 +13423,7 @@ Ext.define('Ext.util.Observable', { event, options; - if (Ext.isObject(ename)) { + if (typeof ename !== 'string') { options = ename; for (ename in options) { if (options.hasOwnProperty(ename)) { @@ -13364,7 +13436,7 @@ Ext.define('Ext.util.Observable', { } else { ename = ename.toLowerCase(); event = me.events[ename]; - if (event.isEvent) { + if (event && event.isEvent) { event.removeListener(fn, scope); } } @@ -13388,31 +13460,31 @@ Ext.define('Ext.util.Observable', { this.clearManagedListeners(); }, - purgeListeners : function() { - console.warn('Observable: purgeListeners has been deprecated. Please use clearListeners.'); - return this.clearListeners.apply(this, arguments); - }, clearManagedListeners : function() { var managedListeners = this.managedListeners || [], i = 0, - len = managedListeners.length, - managedListener; + len = managedListeners.length; for (; i < len; i++) { - managedListener = managedListeners[i]; - managedListener.item.un(managedListener.ename, managedListener.fn, managedListener.scope); + this.removeManagedListenerItem(true, managedListeners[i]); } this.managedListeners = []; }, - - purgeManagedListeners : function() { - console.warn('Observable: purgeManagedListeners has been deprecated. Please use clearManagedListeners.'); - return this.clearManagedListeners.apply(this, arguments); + + + removeManagedListenerItem: function(isClear, managedListener, item, ename, fn, scope){ + if (isClear || (managedListener.item === item && managedListener.ename === ename && (!fn || managedListener.fn === fn) && (!scope || managedListener.scope === scope))) { + managedListener.item.un(managedListener.ename, managedListener.fn, managedListener.scope); + if (!isClear) { + Ext.Array.remove(this.managedListeners, managedListener); + } + } }, + addEvents: function(o) { var me = this, @@ -13504,14 +13576,15 @@ Ext.define('Ext.util.Observable', { } } }, function() { - - - this.createAlias({ + on: 'addListener', + un: 'removeListener', + mon: 'addManagedListener', + mun: 'removeManagedListener' }); @@ -13611,13 +13684,13 @@ Ext.define('Ext.util.Observable', { i, len; for(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); + Ext.Array.erase(e.before, i, 1); return; } } for(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); + Ext.Array.erase(e.after, i, 1); return; } } @@ -13675,6 +13748,7 @@ Ext.define('Ext.util.Animate', { stopAnimation: function() { Ext.fx.Manager.stopAnimation(this.id); + return this; }, @@ -13682,6 +13756,7 @@ Ext.define('Ext.util.Animate', { Ext.fx.Manager.setFxDefaults(this.id, { concurrent: true }); + return this; }, @@ -13689,6 +13764,7 @@ Ext.define('Ext.util.Animate', { Ext.fx.Manager.setFxDefaults(this.id, { concurrent: false }); + return this; }, @@ -13698,11 +13774,13 @@ Ext.define('Ext.util.Animate', { getActiveAnimation: function() { return Ext.fx.Manager.getActiveAnimation(this.id); } +}, function(){ + + Ext.applyIf(Ext.core.Element.prototype, this.prototype); + + Ext.CompositeElementLite.importElementMethods(); }); - -Ext.applyIf(Ext.core.Element.prototype, Ext.util.Animate.prototype); - Ext.define('Ext.state.Provider', { mixins: { observable: 'Ext.util.Observable' @@ -13843,8 +13921,12 @@ Ext.define('Ext.util.HashMap', { observable: 'Ext.util.Observable' }, + constructor: function(config) { - var me = this; + config = config || {}; + + var me = this, + keyFn = config.keyFn; me.addEvents( @@ -13859,6 +13941,10 @@ Ext.define('Ext.util.HashMap', { me.mixins.observable.constructor.call(me, config); me.clear(true); + + if (keyFn) { + me.getKey = keyFn; + } }, @@ -14145,7 +14231,6 @@ Ext.define('Ext.Template', { /** * Compiles the template into an internal function, eliminating the RegEx overhead. * @return {Ext.Template} this - * @hide repeat doc */ compile: function() { var me = this, @@ -14260,78 +14345,73 @@ Ext.define('Ext.Template', { /** * @class Ext.ComponentQuery * @extends Object + * @singleton * * Provides searching of Components within Ext.ComponentManager (globally) or a specific * Ext.container.Container on the document with a similar syntax to a CSS selector. * * Components can be retrieved by using their {@link Ext.Component xtype} with an optional . prefix -
-var disabledFields = myFormPanel.query("{isDisabled()}");
-
+ * - `component[autoScroll]`
+ * - `panel[title="Test"]`
+ *
+ * Member expressions from candidate Components may be tested. If the expression returns a *truthy* value,
+ * the candidate Component will be included in the query:
+ *
+ * var disabledFields = myFormPanel.query("{isDisabled()}");
+ *
+ * Pseudo classes may be used to filter results in the same way as in {@link Ext.DomQuery DomQuery}:
+ *
+ * // Function receives array and returns a filtered array.
+ * Ext.ComponentQuery.pseudos.invalid = function(items) {
+ * var i = 0, l = items.length, c, result = [];
+ * for (; i < l; i++) {
+ * if (!(c = items[i]).isValid()) {
+ * result.push(c);
+ * }
+ * }
+ * return result;
+ * };
+ *
+ * var invalidFields = myFormPanel.query('field:invalid');
+ * if (invalidFields.length) {
+ * invalidFields[0].getEl().scrollIntoView(myFormPanel.body);
+ * for (var i = 0, l = invalidFields.length; i < l; i++) {
+ * invalidFields[i].getEl().frame("red");
+ * }
+ * }
+ *
+ * Default pseudos include:
*
- * Pseudo classes may be used to filter results in the same way as in {@link Ext.DomQuery DomQuery}:
-// Function receives array and returns a filtered array.
-Ext.ComponentQuery.pseudos.invalid = function(items) {
- var i = 0, l = items.length, c, result = [];
- for (; i < l; i++) {
- if (!(c = items[i]).isValid()) {
- result.push(c);
- }
- }
- return result;
-};
-
-var invalidFields = myFormPanel.query('field:invalid');
-if (invalidFields.length) {
- invalidFields[0].getEl().scrollIntoView(myFormPanel.body);
- for (var i = 0, l = invalidFields.length; i < l; i++) {
- invalidFields[i].getEl().frame("red");
- }
-}
-
- *
- * Default pseudos include:
* - not
- *
- // retrieve all Ext.Panels in the document by xtype
- var panelsArray = Ext.ComponentQuery.query('panel');
-
- // retrieve all Ext.Panels within the container with an id myCt
- var panelsWithinmyCt = Ext.ComponentQuery.query('#myCt panel');
-
- // retrieve all direct children which are Ext.Panels within myCt
- var directChildPanel = Ext.ComponentQuery.query('#myCt > panel');
-
- // retrieve all gridpanels and listviews
- var gridsAndLists = Ext.ComponentQuery.query('gridpanel, listview');
-
-
-For easy access to queries based from a particular Container see the {@link Ext.container.Container#query},
-{@link Ext.container.Container#down} and {@link Ext.container.Container#child} methods. Also see
-{@link Ext.Component#up}.
- * @singleton
+ *
+ * // retrieve all Ext.Panels in the document by xtype
+ * var panelsArray = Ext.ComponentQuery.query('panel');
+ *
+ * // retrieve all Ext.Panels within the container with an id myCt
+ * var panelsWithinmyCt = Ext.ComponentQuery.query('#myCt panel');
+ *
+ * // retrieve all direct children which are Ext.Panels within myCt
+ * var directChildPanel = Ext.ComponentQuery.query('#myCt > panel');
+ *
+ * // retrieve all grids and trees
+ * var gridsAndTrees = Ext.ComponentQuery.query('gridpanel, treepanel');
+ *
+ * For easy access to queries based from a particular Container see the {@link Ext.container.Container#query},
+ * {@link Ext.container.Container#down} and {@link Ext.container.Container#child} methods. Also see
+ * {@link Ext.Component#up}.
*/
Ext.define('Ext.ComponentQuery', {
singleton: true,
@@ -14610,17 +14690,21 @@ Ext.define('Ext.ComponentQuery', {
},
/**
- * Returns an array of matched Components from within the passed root object.
- *This method filters returned Components in a similar way to how CSS selector based DOM - * queries work using a textual selector string.
- *See class summary for details.
- * @param selector The selector string to filter returned Components - * @param rootThe Container within which to perform the query. If omitted, all Components - * within the document are included in the search.
- *This parameter may also be an array of Components to filter according to the selector.
- * @returns {Array} The matched Components. + * Returns an array of matched Components from within the passed root object. + * + * This method filters returned Components in a similar way to how CSS selector based DOM + * queries work using a textual selector string. + * + * See class summary for details. + * + * @param {String} selector The selector string to filter returned Components + * @param {Ext.container.Container} root The Container within which to perform the query. + * If omitted, all Components within the document are included in the search. + * + * This parameter may also be an array of Components to filter according to the selector. + * @returns {[Ext.Component]} The matched Components. + * * @member Ext.ComponentQuery - * @method query */ query: function(selector, root) { var selectors = selector.split(','), @@ -14658,11 +14742,10 @@ Ext.define('Ext.ComponentQuery', { /** * Tests whether the passed Component matches the selector string. - * @param component The Component to test - * @param selector The selector string to test against. + * @param {Ext.Component} component The Component to test + * @param {String} selector The selector string to test against. * @return {Boolean} True if the Component matches the selector. * @member Ext.ComponentQuery - * @method query */ is: function(component, selector) { if (!selector) { @@ -14752,10 +14835,6 @@ Ext.define('Ext.ComponentQuery', { selector = selector.replace(selectorMatch[0], ''); break; // Break on match } - // Exhausted all matches: It's an error - if (i === (length - 1)) { - Ext.Error.raise('Invalid ComponentQuery selector: "' + arguments[0] + '"'); - } } } @@ -14814,8 +14893,6 @@ var longNames = allNames.filter(longNameFilter); //a new MixedCollection with the 2 people of age 24: var youngFolk = allNames.filter(ageFilter); - * @constructor - * @param {Object} config Config object */ Ext.define('Ext.util.Filter', { @@ -14823,7 +14900,7 @@ Ext.define('Ext.util.Filter', { /* End Definitions */ /** - * @cfg {String} property The property to filter on. Required unless a {@link #filter} is passed + * @cfg {String} property The property to filter on. Required unless a {@link #filterFn} is passed */ /** @@ -14851,7 +14928,11 @@ Ext.define('Ext.util.Filter', { * @cfg {String} root Optional root property. This is mostly useful when filtering a Store, in which case we set the * root to 'data' to make the filter pull the {@link #property} out of the data object of each item */ - + + /** + * Creates new Filter. + * @param {Object} config (optional) Config object + */ constructor: function(config) { Ext.apply(this, config); @@ -14929,16 +15010,76 @@ Ext.define('Ext.util.Filter', { /** * @class Ext.util.Sorter * @extends Object - * Represents a single sorter that can be applied to a Store + +Represents a single sorter that can be applied to a Store. The sorter is used +to compare two values against each other for the purpose of ordering them. Ordering +is achieved by specifying either: +- {@link #property A sorting property} +- {@link #sorterFn A sorting function} + +As a contrived example, we can specify a custom sorter that sorts by rank: + + Ext.define('Person', { + extend: 'Ext.data.Model', + fields: ['name', 'rank'] + }); + + Ext.create('Ext.data.Store', { + model: 'Person', + proxy: 'memory', + sorters: [{ + sorterFn: function(o1, o2){ + var getRank = function(o){ + var name = o.get('rank'); + if (name === 'first') { + return 1; + } else if (name === 'second') { + return 2; + } else { + return 3; + } + }, + rank1 = getRank(o1), + rank2 = getRank(o2); + + if (rank1 === rank2) { + return 0; + } + + return rank1 < rank2 ? -1 : 1; + } + }], + data: [{ + name: 'Person1', + rank: 'second' + }, { + name: 'Person2', + rank: 'third' + }, { + name: 'Person3', + rank: 'first' + }] + }); + + * @markdown */ Ext.define('Ext.util.Sorter', { /** - * @cfg {String} property The property to sort by. Required unless {@link #sorter} is provided + * @cfg {String} property The property to sort by. Required unless {@link #sorterFn} is provided. + * The property is extracted from the object directly and compared for sorting using the built in + * comparison operators. */ /** - * @cfg {Function} sorterFn A specific sorter function to execute. Can be passed instead of {@link #property} + * @cfg {Function} sorterFn A specific sorter function to execute. Can be passed instead of {@link #property}. + * This sorter function allows for any kind of custom/complex comparisons. + * The sorterFn receives two arguments, the objects being compared. The function should return: + *A flag which causes the object to attempt to restore the state of
* internal properties from a saved state on startup. The object must have
- * a {@link #stateId}
for state to be managed.
- * Auto-generated ids are not guaranteed to be stable across page loads and
+ * a {@link #stateId}
for state to be managed.
+ * Auto-generated ids are not guaranteed to be stable across page loads and
* cannot be relied upon to save and restore the same state for a object.
*
For state saving to work, the state manager's provider must have been * set to an implementation of {@link Ext.state.Provider} which overrides the @@ -15981,7 +16144,7 @@ Ext.state.Manager.setProvider(new Ext.state.CookieProvider({ * object hash which represents the restorable state of the object.
*The value yielded by getState is passed to {@link Ext.state.Manager#set}
* which uses the configured {@link Ext.state.Provider} to save the object
- * keyed by the {@link stateId}
{@link #stateId}
.
* During construction, a stateful object attempts to restore
* its state by calling {@link Ext.state.Manager#get} passing the
* {@link #stateId}
See {@link #stateful} for an explanation of saving and restoring state.
*/ - + /** * @cfg {Array} stateEvents *An array of events that, when fired, should trigger this object to @@ -16010,18 +16173,18 @@ Ext.state.Manager.setProvider(new Ext.state.CookieProvider({ *
See {@link #stateful}
for an explanation of saving and
* restoring object state.
', ' |
---|