X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/7a654f8d43fdb43d78b63d90528bed6e86b608cc..6746dc89c47ed01b165cc1152533605f97eb8e8d:/builds/ext-core-debug.js
diff --git a/builds/ext-core-debug.js b/builds/ext-core-debug.js
index 23074c86..46a086c4 100644
--- a/builds/ext-core-debug.js
+++ b/builds/ext-core-debug.js
@@ -1,8 +1,16 @@
/*
-Ext JS - JavaScript Library
-Copyright (c) 2006-2011, Sencha Inc.
-All rights reserved.
-licensing@sencha.com
+
+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.
+
*/
/**
* @class Ext
@@ -11,7 +19,7 @@ licensing@sencha.com
(function() {
var global = this,
objectPrototype = Object.prototype,
- toString = Object.prototype.toString,
+ toString = objectPrototype.toString,
enumerables = true,
enumerablesTest = { toString: 1 },
i;
@@ -86,7 +94,6 @@ licensing@sencha.com
/**
* Copies all the properties of config to object if they don't already exist.
- * @function
* @param {Object} object The receiver of the properties
* @param {Object} config The source of the properties
* @return {Object} returns obj
@@ -139,7 +146,7 @@ licensing@sencha.com
/**
* This method deprecated. Use {@link Ext#define Ext.define} instead.
- * @function
+ * @method
* @param {Function} superclass
* @param {Object} overrides
* @return {Function} The subclass constructor from the overrides parameter, or a generated one if not provided.
@@ -167,13 +174,6 @@ licensing@sencha.com
};
}
- if (!superclass) {
- Ext.Error.raise({
- sourceClass: 'Ext',
- sourceMethod: 'extend',
- msg: 'Attempting to extend from a class which has not been loaded on the page.'
- });
- }
// We create a new temporary class
var F = function() {},
@@ -324,11 +324,6 @@ licensing@sencha.com
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.'
- });
},
/**
@@ -353,6 +348,7 @@ licensing@sencha.com
*
* @param {Mixed} target The target to test
* @return {Boolean}
+ * @method
*/
isArray: ('isArray' in Array) ? Array.isArray : function(value) {
return toString.call(value) === '[object Array]';
@@ -371,10 +367,12 @@ licensing@sencha.com
* Returns true if the passed value is a JavaScript Object, false otherwise.
* @param {Mixed} value The value to test
* @return {Boolean}
+ * @method
*/
isObject: (toString.call(null) === '[object Object]') ?
function(value) {
- return value !== null && value !== undefined && toString.call(value) === '[object Object]' && value.nodeType === undefined;
+ // check ownerDocument here as well to exclude DOM nodes
+ return value !== null && value !== undefined && toString.call(value) === '[object Object]' && value.ownerDocument === undefined;
} :
function(value) {
return toString.call(value) === '[object Object]';
@@ -395,6 +393,7 @@ licensing@sencha.com
* Returns true if the passed value is a JavaScript Function, false otherwise.
* @param {Mixed} value The value to test
* @return {Boolean}
+ * @method
*/
isFunction:
// Safari 3.x and 4.x returns 'function' for typeof Creates a delegate function, optionally with a bound scope which, when called, buffers
+ * Creates a delegate function, optionally with a bound scope which, when called, buffers
* the execution of the passed function for the configured number of milliseconds.
* If called again within that period, the impending invocation will be canceled, and the
- * timeout period will begin again. Creates a throttled version of the passed function which, when called repeatedly and
+ * Creates a throttled version of the passed function which, when called repeatedly and
* rapidly, invokes the passed function only after a certain interval has elapsed since the
- * previous invocation. This is useful for wrapping functions which may be called repeatedly, such as
- * a handler of a mouse move event when the processing is expensive. The date format string that the {@link #dateRenderer} and {@link #date} functions use.
- * see {@link #Date} for details. The date format string that the {@link Ext.util.Format#dateRenderer}
+ * and {@link Ext.util.Format#date} functions use. See {@link Ext.Date} for details. This defaults to name
and value
.
+ * which originally accepts 2 arguments for `name` and `value`.
* The wrapped function then allows "flexible" value setting of either:
*
- *
- *
+ * - `name` and `value` as 2 arguments
+ * - one single object argument with multiple key - value pairs
*
* For example:
- * name
and value
as 2 arguments
+ *
+ * var setValue = Ext.Function.flexSetter(function(name, value) {
+ * this[name] = value;
+ * });
+ *
+ * // Afterwards
+ * // Setting a single name - value
+ * setValue('name1', 'value1');
+ *
+ * // Settings multiple name - value pairs
+ * setValue({
+ * name1: 'value1',
+ * name2: 'value2',
+ * name3: 'value3'
+ * });
+ *
* @param {Function} setter
* @returns {Function} flexSetter
*/
@@ -2077,13 +2334,15 @@ setValue({
};
},
- /**
- * Create a new function from the provided
-var setValue = Ext.Function.flexSetter(function(name, value) {
- this[name] = value;
-});
-
-// Afterwards
-// Setting a single name - value
-setValue('name1', 'value1');
-
-// Settings multiple name - value pairs
-setValue({
- name1: 'value1',
- name2: 'value2',
- name3: 'value3'
-});
- *
fn
, change this
to the provided scope, optionally
+ /**
+ * Create a new function from the provided `fn`, change `this` to the provided scope, optionally
* overrides arguments for the call. (Defaults to the arguments passed by the caller)
*
+ * {@link Ext#bind Ext.bind} is alias for {@link Ext.Function#bind Ext.Function.bind}
+ *
* @param {Function} fn The function to delegate.
- * @param {Object} scope (optional) The scope (this
reference) in which the function is executed.
- * If omitted, defaults to the browser window.
+ * @param {Object} scope (optional) The scope (`this` reference) in which the function is executed.
+ * **If omitted, defaults to the browser window.**
* @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
* @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
* if a number the args are inserted at the specified position
@@ -2091,19 +2350,18 @@ setValue({
*/
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); // copy arguments first
- applyArgs = [appendArgs, 0].concat(args); // create method call params
- Array.prototype.splice.apply(callArgs, applyArgs); // splice them in
+ callArgs = slice.call(arguments, 0); // copy arguments first
+ Ext.Array.insert(callArgs, appendArgs, args);
}
return method.apply(scope || window, callArgs);
@@ -2111,23 +2369,26 @@ setValue({
},
/**
- * Create a new function from the provided fn
, the arguments of which are pre-set to `args`.
+ * Create a new function from the provided `fn`, the arguments of which are pre-set to `args`.
* New arguments passed to the newly created callback when it's invoked are appended after the pre-set ones.
* This is especially useful when creating callbacks.
+ *
* For example:
*
- var originalFunction = function(){
- alert(Ext.Array.from(arguments).join(' '));
- };
-
- var callback = Ext.Function.pass(originalFunction, ['Hello', 'World']);
-
- callback(); // alerts 'Hello World'
- callback('by Me'); // alerts 'Hello World by Me'
-
+ * var originalFunction = function(){
+ * alert(Ext.Array.from(arguments).join(' '));
+ * };
+ *
+ * var callback = Ext.Function.pass(originalFunction, ['Hello', 'World']);
+ *
+ * callback(); // alerts 'Hello World'
+ * callback('by Me'); // alerts 'Hello World by Me'
+ *
+ * {@link Ext#pass Ext.pass} is alias for {@link Ext.Function#pass Ext.Function.pass}
+ *
* @param {Function} fn The original function
* @param {Array} args The arguments to pass to new callback
- * @param {Object} scope (optional) The scope (this
reference) in which the function is executed.
+ * @param {Object} scope (optional) The scope (`this` reference) in which the function is executed.
* @return {Function} The new callback function
*/
pass: function(fn, args, scope) {
@@ -2141,8 +2402,8 @@ setValue({
},
/**
- * Create an alias to the provided method property with name methodName
of object
.
- * Note that the execution scope will still be bound to the provided object
itself.
+ * Create an alias to the provided method property with name `methodName` of `object`.
+ * Note that the execution scope will still be bound to the provided `object` itself.
*
* @param {Object/Function} object
* @param {String} methodName
@@ -2158,26 +2419,26 @@ setValue({
* Creates an interceptor function. The passed function is called before the original one. If it returns false,
* the original one is not called. The resulting function returns the results of the original function.
* The passed function is called with the parameters of the original function. Example usage:
- *
+ *
+ * var sayHi = function(name){
+ * alert('Hi, ' + name);
+ * }
+ *
+ * sayHi('Fred'); // alerts "Hi, Fred"
+ *
+ * // create a new function that validates input without
+ * // directly modifying the original function:
+ * var sayHiToFriend = Ext.Function.createInterceptor(sayHi, function(name){
+ * return name == 'Brian';
+ * });
+ *
+ * sayHiToFriend('Fred'); // no alert
+ * sayHiToFriend('Brian'); // alerts "Hi, Brian"
+ *
* @param {Function} origFn The original function.
* @param {Function} newFn The function to call before the original
- * @param {Object} scope (optional) The scope (
-var sayHi = function(name){
- alert('Hi, ' + name);
-}
-
-sayHi('Fred'); // alerts "Hi, Fred"
-
-// create a new function that validates input without
-// directly modifying the original function:
-var sayHiToFriend = Ext.Function.createInterceptor(sayHi, function(name){
- return name == 'Brian';
-});
-
-sayHiToFriend('Fred'); // no alert
-sayHiToFriend('Brian'); // alerts "Hi, Brian"
-
this
reference) in which the passed function is executed.
- * If omitted, defaults to the scope in which the original function is called or the browser window.
+ * @param {Object} scope (optional) The scope (`this` reference) in which the passed function is executed.
+ * **If omitted, defaults to the scope in which the original function is called or the browser window.**
* @param {Mixed} returnValue (optional) The value to return if the passed function return false (defaults to null).
* @return {Function} The new function
*/
@@ -2198,16 +2459,17 @@ sayHiToFriend('Brian'); // alerts "Hi, Brian"
},
/**
- * Creates a delegate (callback) which, when called, executes after a specific delay.
- * @param {Function} fn The function which will be called on a delay when the returned function is called.
- * Optionally, a replacement (or additional) argument list may be specified.
- * @param {Number} delay The number of milliseconds to defer execution by whenever called.
- * @param {Object} scope (optional) The scope (this
reference) used by the function at execution time.
- * @param {Array} args (optional) Override arguments for the call. (Defaults to the arguments passed by the caller)
- * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
- * if a number the args are inserted at the specified position.
- * @return {Function} A function which, when called, executes the original function after the specified delay.
- */
+ * Creates a delegate (callback) which, when called, executes after a specific delay.
+ *
+ * @param {Function} fn The function which will be called on a delay when the returned function is called.
+ * Optionally, a replacement (or additional) argument list may be specified.
+ * @param {Number} delay The number of milliseconds to defer execution by whenever called.
+ * @param {Object} scope (optional) The scope (`this` reference) used by the function at execution time.
+ * @param {Array} args (optional) Override arguments for the call. (Defaults to the arguments passed by the caller)
+ * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
+ * if a number the args are inserted at the specified position.
+ * @return {Function} A function which, when called, executes the original function after the specified delay.
+ */
createDelayed: function(fn, delay, scope, args, appendArgs) {
if (scope || args) {
fn = Ext.Function.bind(fn, scope, args, appendArgs);
@@ -2222,27 +2484,30 @@ sayHiToFriend('Brian'); // alerts "Hi, Brian"
/**
* Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
- *
+ *
+ * var sayHi = function(name){
+ * alert('Hi, ' + name);
+ * }
+ *
+ * // executes immediately:
+ * sayHi('Fred');
+ *
+ * // executes after 2 seconds:
+ * Ext.Function.defer(sayHi, 2000, this, ['Fred']);
+ *
+ * // this syntax is sometimes useful for deferring
+ * // execution of an anonymous function:
+ * Ext.Function.defer(function(){
+ * alert('Anonymous');
+ * }, 100);
+ *
+ * {@link Ext#defer Ext.defer} is alias for {@link Ext.Function#defer Ext.Function.defer}
+ *
* @param {Function} fn The function to defer.
- * @param {Number} millis The number of milliseconds for the setTimeout call (if less than or equal to 0 the function is executed immediately)
- * @param {Object} scope (optional) The scope (
-var sayHi = function(name){
- alert('Hi, ' + name);
-}
-
-// executes immediately:
-sayHi('Fred');
-
-// executes after 2 seconds:
-Ext.Function.defer(sayHi, 2000, this, ['Fred']);
-
-// this syntax is sometimes useful for deferring
-// execution of an anonymous function:
-Ext.Function.defer(function(){
- alert('Anonymous');
-}, 100);
-
this
reference) in which the function is executed.
- * If omitted, defaults to the browser window.
+ * @param {Number} millis The number of milliseconds for the setTimeout call
+ * (if less than or equal to 0 the function is executed immediately)
+ * @param {Object} scope (optional) The scope (`this` reference) in which the function is executed.
+ * **If omitted, defaults to the browser window.**
* @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
* @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
* if a number the args are inserted at the specified position
@@ -2262,23 +2527,21 @@ Ext.Function.defer(function(){
* The resulting function returns the results of the original function.
* The passed function is called with the parameters of the original function. Example usage:
*
- *
+ * var sayHi = function(name){
+ * alert('Hi, ' + name);
+ * }
+ *
+ * sayHi('Fred'); // alerts "Hi, Fred"
+ *
+ * var sayGoodbye = Ext.Function.createSequence(sayHi, function(name){
+ * alert('Bye, ' + name);
+ * });
+ *
+ * sayGoodbye('Fred'); // both alerts show
*
* @param {Function} origFn The original function.
* @param {Function} newFn The function to sequence
- * @param {Object} scope (optional) The scope (this reference) in which the passed function is executed.
+ * @param {Object} scope (optional) The scope (`this` reference) in which the passed function is executed.
* If omitted, defaults to the scope in which the original function is called or the browser window.
* @return {Function} The new function
*/
@@ -2296,15 +2559,15 @@ sayGoodbye('Fred'); // both alerts show
},
/**
- *
-var sayHi = function(name){
- alert('Hi, ' + name);
-}
-
-sayHi('Fred'); // alerts "Hi, Fred"
-
-var sayGoodbye = Ext.Function.createSequence(sayHi, function(name){
- alert('Bye, ' + name);
-});
-
-sayGoodbye('Fred'); // both alerts show
- *
this
reference) in which
+ * @param {Object} scope (optional) The scope (`this` reference) in which
* the passed function is executed. If omitted, defaults to the scope specified by the caller.
* @param {Array} args (optional) Override arguments for the call. Defaults to the arguments
* passed by the caller.
@@ -2327,16 +2590,16 @@ sayGoodbye('Fred'); // both alerts show
},
/**
- * this
reference) in which
+ * @param {Function} fn The function to execute at a regular time interval.
+ * @param {Number} interval The interval **in milliseconds** on which the passed function is executed.
+ * @param {Object} scope (optional) The scope (`this` reference) in which
* the passed function is executed. If omitted, defaults to the scope specified by the caller.
* @returns {Function} A function which invokes the passed function at the specified interval.
*/
@@ -2361,23 +2624,23 @@ sayGoodbye('Fred'); // both alerts show
};
/**
- * Shorthand for {@link Ext.Function#defer}
+ * @method
* @member Ext
- * @method defer
+ * @alias Ext.Function#defer
*/
Ext.defer = Ext.Function.alias(Ext.Function, 'defer');
/**
- * Shorthand for {@link Ext.Function#pass}
+ * @method
* @member Ext
- * @method pass
+ * @alias Ext.Function#pass
*/
Ext.pass = Ext.Function.alias(Ext.Function, 'pass');
/**
- * Shorthand for {@link Ext.Function#bind}
+ * @method
* @member Ext
- * @method bind
+ * @alias Ext.Function#bind
*/
Ext.bind = Ext.Function.alias(Ext.Function, 'bind');
@@ -2597,15 +2860,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 = [];
@@ -2826,6 +3080,7 @@ var ExtObject = Ext.Object = {
* @param {Object} object
* @return {Array} An array of keys from the object
+ * @method
*/
getKeys: ('keys' in Object.prototype) ? Object.keys : function(object) {
var keys = [],
@@ -3041,6 +3296,7 @@ Ext.Date = {
/**
* Returns the current timestamp
* @return {Date} The current timestamp
+ * @method
*/
now: Date.now || function() {
return +new Date();
@@ -3322,8 +3578,8 @@ Ext.Date.monthNumbers = {
Dec:11
},
/**
- * m/d/Y
, but may be overridden in a locale file.Other.awesome.Class
- * will simply be loaded from ./Other/awesome/Class.js
+ * If not being specified, for example, `Other.awesome.Class`
+ * will simply be loaded from `./Other/awesome/Class.js`
*/
paths: {
'Ext': '.'
@@ -6888,30 +7133,30 @@ This process will be automated with Sencha Command, to be released and documente
/**
* Set the configuration for the loader. This should be called right after ext-core.js
- * (or ext-core-debug.js) is included in the page, i.e:
-
-
-
-
- * Refer to {@link Ext.Loader#configs} for the list of possible properties
+ * (or ext-core-debug.js) is included in the page, e.g.:
+ *
+ *
+ *
*
- * @param {Object} config The config object to override the default values in {@link Ext.Loader#config}
+ * Refer to config options of {@link Ext.Loader} for the list of possible properties.
+ *
+ * @param {String/Object} name Name of the value to override, or a config object to override multiple values.
+ * @param {Object} value (optional) The new value to set, needed if first parameter is String.
* @return {Ext.Loader} this
- * @markdown
*/
setConfig: function(name, value) {
if (Ext.isObject(name) && arguments.length === 1) {
@@ -6925,7 +7170,8 @@ This process will be automated with Sencha Command, to be released and documente
},
/**
- * Get the config value corresponding to the specified name. If no name is given, will return the config object
+ * Get the config value corresponding to the specified name.
+ * If no name is given, will return the config object.
* @param {String} name The config property name
* @return {Object/Mixed}
*/
@@ -6938,15 +7184,14 @@ This process will be automated with Sencha Command, to be released and documente
},
/**
- * Sets the path of a namespace.
- * For Example:
-
- Ext.Loader.setPath('Ext', '.');
-
+ * Sets the path of a namespace. For Example:
+ *
+ * Ext.Loader.setPath('Ext', '.');
+ *
* @param {String/Object} name See {@link Ext.Function#flexSetter flexSetter}
* @param {String} path See {@link Ext.Function#flexSetter flexSetter}
* @return {Ext.Loader} this
- * @markdown
+ * @method
*/
setPath: flexSetter(function(name, path) {
this.config.paths[name] = path;
@@ -6955,32 +7200,31 @@ This process will be automated with Sencha Command, to be released and documente
}),
/**
- * Translates a className to a file path by adding the
- * the proper prefix and converting the .'s to /'s. For example:
-
- Ext.Loader.setPath('My', '/path/to/My');
-
- alert(Ext.Loader.getPath('My.awesome.Class')); // alerts '/path/to/My/awesome/Class.js'
-
+ * Translates a className to a file path by adding the the proper prefix and converting the .'s to /'s.
+ * For example:
+ *
+ * Ext.Loader.setPath('My', '/path/to/My');
+ *
+ * alert(Ext.Loader.getPath('My.awesome.Class')); // alerts '/path/to/My/awesome/Class.js'
+ *
* Note that the deeper namespace levels, if explicitly set, are always resolved first. For example:
-
- Ext.Loader.setPath({
- 'My': '/path/to/lib',
- 'My.awesome': '/other/path/for/awesome/stuff',
- 'My.awesome.more': '/more/awesome/path'
- });
-
- alert(Ext.Loader.getPath('My.awesome.Class')); // alerts '/other/path/for/awesome/stuff/Class.js'
-
- alert(Ext.Loader.getPath('My.awesome.more.Class')); // alerts '/more/awesome/path/Class.js'
-
- alert(Ext.Loader.getPath('My.cool.Class')); // alerts '/path/to/lib/cool/Class.js'
-
- alert(Ext.Loader.getPath('Unknown.strange.Stuff')); // alerts 'Unknown/strange/Stuff.js'
-
+ *
+ * Ext.Loader.setPath({
+ * 'My': '/path/to/lib',
+ * 'My.awesome': '/other/path/for/awesome/stuff',
+ * 'My.awesome.more': '/more/awesome/path'
+ * });
+ *
+ * alert(Ext.Loader.getPath('My.awesome.Class')); // alerts '/other/path/for/awesome/stuff/Class.js'
+ *
+ * alert(Ext.Loader.getPath('My.awesome.more.Class')); // alerts '/more/awesome/path/Class.js'
+ *
+ * alert(Ext.Loader.getPath('My.cool.Class')); // alerts '/path/to/lib/cool/Class.js'
+ *
+ * alert(Ext.Loader.getPath('Unknown.strange.Stuff')); // alerts 'Unknown/strange/Stuff.js'
+ *
* @param {String} className
* @return {String} path
- * @markdown
*/
getPath: function(className) {
var path = '',
@@ -7058,7 +7302,7 @@ This process will be automated with Sencha Command, to be released and documente
do {
if (Manager.isCreated(requires[j])) {
// Take out from the queue
- requires.splice(j, 1);
+ Ext.Array.erase(requires, j, 1);
}
else {
j++;
@@ -7066,7 +7310,7 @@ This process will be automated with Sencha Command, to be released and documente
} 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;
@@ -7200,15 +7444,16 @@ This process will be automated with Sencha Command, to be released and documente
/**
* Explicitly exclude files from being loaded. Useful when used in conjunction with a broad include expression.
- * Can be chained with more `require` and `exclude` methods, eg:
-
- Ext.exclude('Ext.data.*').require('*');
-
- Ext.exclude('widget.button*').require('widget.*');
-
- * @param {Array} excludes
+ * Can be chained with more `require` and `exclude` methods, e.g.:
+ *
+ * Ext.exclude('Ext.data.*').require('*');
+ *
+ * Ext.exclude('widget.button*').require('widget.*');
+ *
+ * {@link Ext#exclude Ext.exclude} is alias for {@link Ext.Loader#exclude Ext.Loader.exclude} for convenience.
+ *
+ * @param {String/[String]} excludes
* @return {Object} object contains `require` method for chaining
- * @markdown
*/
exclude: function(excludes) {
var me = this;
@@ -7225,12 +7470,15 @@ This process will be automated with Sencha Command, to be released and documente
},
/**
- * Synchronously loads all classes by the given names and all their direct dependencies; optionally executes the given callback function when finishes, within the optional scope. This method is aliased by {@link Ext#syncRequire} for convenience
- * @param {String/Array} expressions Can either be a string or an array of string
+ * Synchronously loads all classes by the given names and all their direct dependencies;
+ * optionally executes the given callback function when finishes, within the optional scope.
+ *
+ * {@link Ext#syncRequire Ext.syncRequire} is alias for {@link Ext.Loader#syncRequire Ext.Loader.syncRequire} for convenience.
+ *
+ * @param {String/[String]} expressions Can either be a string or an array of string
* @param {Function} fn (Optional) The callback function
* @param {Object} scope (Optional) The execution scope (`this`) of the callback function
- * @param {String/Array} excludes (Optional) Classes to be excluded, useful when being used with expressions
- * @markdown
+ * @param {String/[String]} excludes (Optional) Classes to be excluded, useful when being used with expressions
*/
syncRequire: function() {
this.syncModeEnabled = true;
@@ -7240,13 +7488,15 @@ This process will be automated with Sencha Command, to be released and documente
},
/**
- * Loads all classes by the given names and all their direct dependencies; optionally executes the given callback function when
- * finishes, within the optional scope. This method is aliased by {@link Ext#require Ext.require} for convenience
- * @param {String/Array} expressions Can either be a string or an array of string
+ * Loads all classes by the given names and all their direct dependencies;
+ * optionally executes the given callback function when finishes, within the optional scope.
+ *
+ * {@link Ext#require Ext.require} is alias for {@link Ext.Loader#require Ext.Loader.require} for convenience.
+ *
+ * @param {String/[String]} expressions Can either be a string or an array of string
* @param {Function} fn (Optional) The callback function
* @param {Object} scope (Optional) The execution scope (`this`) of the callback function
- * @param {String/Array} excludes (Optional) Classes to be excluded, useful when being used with expressions
- * @markdown
+ * @param {String/[String]} excludes (Optional) Classes to be excluded, useful when being used with expressions
*/
require: function(expressions, fn, scope, excludes) {
var filePath, expression, exclude, className, excluded = {},
@@ -7357,48 +7607,7 @@ This process will be automated with Sencha Command, to be released and documente
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("', '") + "'"
- });
- }
},
/**
@@ -7408,13 +7617,6 @@ This process will be automated with Sencha Command, to be released and documente
this.numPendingFiles--;
this.hasFileLoadError = true;
- Ext.Error.raise({
- sourceClass: "Ext.Loader",
- classToLoad: className,
- loadPath: filePath,
- loadingType: isSynchronous ? 'synchronous' : 'async',
- msg: errorMessage
- });
},
/**
@@ -7470,10 +7672,10 @@ This process will be automated with Sencha Command, to be released and documente
},
/**
- * Add a new listener to be executed when all required scripts are fully loaded
+ * Adds new listener to be executed when all required scripts are fully loaded.
*
* @param {Function} fn The function callback to be executed
- * @param {Object} scope The execution scope (this
) of the callback function
+ * @param {Object} scope The execution scope (`this`) of the callback function
* @param {Boolean} withDomReady Whether or not to wait for document dom ready as well
*/
onReady: function(fn, scope, withDomReady, options) {
@@ -7512,36 +7714,49 @@ This process will be automated with Sencha Command, to be released and documente
};
/**
- * Convenient alias of {@link Ext.Loader#require}. Please see the introduction documentation of
- * {@link Ext.Loader} for examples.
* @member Ext
* @method require
+ * @alias Ext.Loader#require
*/
Ext.require = alias(Loader, 'require');
/**
- * Synchronous version of {@link Ext#require}, convenient alias of {@link Ext.Loader#syncRequire}.
- *
* @member Ext
* @method syncRequire
+ * @alias Ext.Loader#syncRequire
*/
Ext.syncRequire = alias(Loader, 'syncRequire');
/**
- * Convenient shortcut to {@link Ext.Loader#exclude}
* @member Ext
* @method exclude
+ * @alias Ext.Loader#exclude
*/
Ext.exclude = alias(Loader, 'exclude');
/**
* @member Ext
* @method onReady
+ * @alias Ext.Loader#onReady
*/
Ext.onReady = function(fn, scope, options) {
Loader.onReady(fn, scope, true, options);
};
+ /**
+ * @cfg {[String]} requires
+ * @member Ext.Class
+ * List of classes that have to be loaded before instanciating this class.
+ * For example:
+ *
+ * Ext.define('Mother', {
+ * requires: ['Child'],
+ * giveBirth: function() {
+ * // we can be sure that child class is available.
+ * return new Child();
+ * }
+ * });
+ */
Class.registerPreprocessor('loader', function(cls, data, continueFn) {
var me = this,
dependencies = [],
@@ -7601,48 +7816,8 @@ This process will be automated with Sencha Command, to be released and documente
}
if (dependencies.length === 0) {
-// Loader.historyPush(className);
- return;
- }
-
- var deadlockPath = [],
- requiresMap = Loader.requiresMap,
- detectDeadlock;
-
- /*
- Automatically detect deadlocks before-hand,
- will throw an error with detailed path for ease of debugging. Examples of deadlock cases:
-
- - A extends B, then B extends A
- - A requires B, B requires C, then C requires A
-
- The detectDeadlock function will recursively transverse till the leaf, hence it can detect deadlocks
- no matter how deep the path is.
- */
-
- 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.historyPush(className);
+ return;
}
@@ -7687,6 +7862,23 @@ This process will be automated with Sencha Command, to be released and documente
Class.setDefaultPreprocessorPosition('loader', 'after', 'className');
+ /**
+ * @cfg {[String]} uses
+ * @member Ext.Class
+ * List of classes to load together with this class. These aren't neccessarily loaded before
+ * this class is instanciated. For example:
+ *
+ * Ext.define('Mother', {
+ * uses: ['Child'],
+ * giveBirth: function() {
+ * // This code might, or might not work:
+ * // return new Child();
+ *
+ * // Instead use Ext.create() to load the class at the spot if not loaded already:
+ * return Ext.create('Child');
+ * }
+ * });
+ */
Manager.registerPostprocessor('uses', function(name, cls, data) {
var uses = Ext.Array.from(data.uses),
items = [],
@@ -7715,11 +7907,11 @@ This process will be automated with Sencha Command, to be released and documente
A wrapper class for the native JavaScript Error object that adds a few useful capabilities for handling
errors in an Ext application. When you use Ext.Error to {@link #raise} an error from within any class that
uses the Ext 4 class system, the Error class can automatically add the source class and method from which
-the error was raised. It also includes logic to automatically log the eroor to the console, if available,
+the error was raised. It also includes logic to automatically log the eroor to the console, if available,
with additional metadata about the error. In all cases, the error will always be thrown at the end so that
execution will halt.
-Ext.Error also offers a global error {@link #handle handling} method that can be overridden in order to
+Ext.Error also offers a global error {@link #handle handling} method that can be overridden in order to
handle application-wide errors in a single spot. You can optionally {@link #ignore} errors altogether,
although in a real application it's usually a better idea to override the handling function and perform
logging or some other method of reporting the errors in a way that is meaningful to the application.
@@ -7729,7 +7921,7 @@ At its simplest you can simply raise an error as a simple string from within any
#Example usage:#
Ext.Error.raise('Something bad happened!');
-
+
If raised from plain JavaScript code, the error will be logged to the console (if available) and the message
displayed. In most cases however you'll be raising errors from within a class, and it may often be useful to add
additional metadata about the error being raised. The {@link #raise} method can also take a config object.
@@ -7737,7 +7929,7 @@ In this form the `msg` attribute becomes the error description, and any other da
added to the error object and, if the console is available, logged to the console for inspection.
#Example usage:#
-
+
Ext.define('Ext.Foo', {
doSomething: function(option){
if (someCondition === false) {
@@ -7759,13 +7951,13 @@ If a console is available (that supports the `console.dir` function) you'll see
msg: "You cannot do that!"
sourceClass: "Ext.Foo"
sourceMethod: "doSomething"
-
+
uncaught exception: You cannot do that!
-As you can see, the error will report exactly where it was raised and will include as much information as the
+As you can see, the error will report exactly where it was raised and will include as much information as the
raising code can usefully provide.
-If you want to handle all application errors globally you can simply override the static {@link handle} method
+If you want to handle all application errors globally you can simply override the static {@link #handle} method
and provide whatever handling logic you need. If the method returns true then the error is considered handled
and will not be thrown to the browser. If anything but true is returned then the error will be thrown normally.
@@ -7804,12 +7996,32 @@ be preferable to supply a custom error {@link #handle handling} function instead
ignore: false,
/**
-Raise an error that can include additional data and supports automatic console logging if available.
-You can pass a string error message or an object with the `msg` attribute which will be used as the
-error message. The object can contain any other name-value attributes (or objects) to be logged
+ * @property notify
+Static flag that can be used to globally control error notification to the user. Unlike
+Ex.Error.ignore, this does not effect exceptions. They are still thrown. This value can be
+set to false to disable the alert notification (default is true for IE6 and IE7).
+
+Only the first error will generate an alert. Internally this flag is set to false when the
+first error occurs prior to displaying the alert.
+
+This flag is not used in a release build.
+
+#Example usage:#
+
+ Ext.Error.notify = false;
+
+ * @markdown
+ * @static
+ */
+ //notify: Ext.isIE6 || Ext.isIE7,
+
+ /**
+Raise an error that can include additional data and supports automatic console logging if available.
+You can pass a string error message or an object with the `msg` attribute which will be used as the
+error message. The object can contain any other name-value attributes (or objects) to be logged
along with the error.
-Note that after displaying the error message a JavaScript error will ultimately be thrown so that
+Note that after displaying the error message a JavaScript error will ultimately be thrown so that
execution will halt.
#Example usage:#
@@ -7829,7 +8041,7 @@ execution will halt.
}
}
});
- * @param {String/Object} err The error message string, or an object containing the
+ * @param {String/Object} err The error message string, or an object containing the
* attribute "msg" that will be used as the error message. Any other data included in
* the object will also be logged to the browser console, if available.
* @static
@@ -7853,28 +8065,15 @@ execution will halt.
}
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);
}
},
@@ -7905,9 +8104,11 @@ error to the browser, otherwise the error will be thrown and execution will halt
}
},
+ // This is the standard property that is the name of the constructor.
+ name: 'Ext.Error',
+
/**
- * @constructor
- * @param {String/Object} config The error message string, or an object containing the
+ * @param {String/Object} config The error message string, or an object containing the
* attribute "msg" that will be used as the error message. Any other data included in
* the object will be applied to the error instance and logged to the browser console, if available.
*/
@@ -7915,12 +8116,18 @@ error to the browser, otherwise the error will be thrown and execution will halt
if (Ext.isString(config)) {
config = { msg: config };
}
- Ext.apply(this, config);
+
+ var me = this;
+
+ Ext.apply(me, config);
+
+ me.message = me.message || me.msg; // 'message' is standard ('msg' is non-standard)
+ // note: the above does not work in old WebKit (me.message is readonly) (Safari 4)
},
/**
-Provides a custom string representation of the error object. This is an override of the base JavaScript
-`Object.toString` method, which is useful so that when logged to the browser console, an error object will
+Provides a custom string representation of the error object. This is an override of the base JavaScript
+`Object.toString` method, which is useful so that when logged to the browser console, an error object will
be displayed with a useful message instead of `[object Object]`, the default `toString` result.
The default implementation will include the error message along with the raising class and method, if available,
@@ -7940,12 +8147,28 @@ a particular error instance, if you want to provide a custom description that wi
}
});
+/*
+ * This mechanism is used to notify the user of the first error encountered on the page. This
+ * was previously internal to Ext.Error.raise and is a desirable feature since errors often
+ * slip silently under the radar. It cannot live in Ext.Error.raise since there are times
+ * where exceptions are handled in a try/catch.
+ */
+
+
/*
-Ext JS - JavaScript Library
-Copyright (c) 2006-2011, Sencha Inc.
-All rights reserved.
-licensing@sencha.com
+
+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.
+
*/
/**
* @class Ext.JSON
@@ -8097,7 +8320,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
});
}
};
@@ -8145,9 +8368,9 @@ Ext.decode = Ext.JSON.decode;
For more information about how to use the Ext classes, see
-* The Learning Center
-* The FAQ
-* The forums
+- The Learning Center
+- The FAQ
+- The forums
* @singleton
* @markdown
@@ -8186,15 +8409,23 @@ Ext.apply(Ext, {
* @return {String} The generated Id.
*/
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;
},
@@ -8210,6 +8441,7 @@ Ext.apply(Ext, {
/**
* Returns the current document head as an {@link Ext.core.Element}.
* @return Ext.core.Element The document head
+ * @method
*/
getHead: function() {
var head;
@@ -8282,6 +8514,12 @@ Ext.apply(Ext, {
/**
* Execute a callback function in a particular scope. If no function is passed the call is ignored.
+ *
+ * For example, these lines are equivalent:
+ *
+ * Ext.callback(myFunc, this, [arg1, arg2]);
+ * Ext.isFunction(myFunc) && myFunc.apply(this, [arg1, arg2]);
+ *
* @param {Function} callback The callback to execute
* @param {Object} scope (optional) The scope to execute in
* @param {Array} args (optional) The arguments to pass to the function
@@ -8337,6 +8575,7 @@ Ext.ns = Ext.namespace;
// for old browsers
window.undefined = window.undefined;
+
/**
* @class Ext
* Ext core utilities and functions.
@@ -8369,14 +8608,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));
// remove css image flicker
try {
document.execCommand("BackgroundImageCache", false, true);
} catch(e) {}
- Ext.setVersion('extjs', '4.0.0');
+ Ext.setVersion('extjs', '4.0.2');
Ext.apply(Ext, {
/**
* URL to a blank file used by Ext when in secure mode for iframe src and onReady src to prevent
@@ -8470,6 +8710,7 @@ function(el){
* true
, then DOM event listeners are also removed from all child nodes. The body node
* will be ignored if passed in.
example:
-ImageComponent = Ext.extend(Ext.Component, {
- initComponent: function() {
- this.autoEl = { tag: 'img' };
- MyComponent.superclass.initComponent.apply(this, arguments);
- this.initialBox = Ext.copyTo({}, this.initialConfig, 'x,y,width,height');
- }
-});
- *
+ *
+ * Example:
+ *
+ * ImageComponent = Ext.extend(Ext.Component, {
+ * initComponent: function() {
+ * this.autoEl = { tag: 'img' };
+ * MyComponent.superclass.initComponent.apply(this, arguments);
+ * this.initialBox = Ext.copyTo({}, this.initialConfig, 'x,y,width,height');
+ * }
+ * });
+ *
* Important note: To borrow class prototype methods, use {@link Ext.Base#borrow} instead.
+ *
* @param {Object} dest The destination object.
* @param {Object} source The source object.
* @param {Array/String} names Either an Array of property names, or a comma-delimited list
* of property names to copy.
* @param {Boolean} usePrototypeKeys (Optional) Defaults to false. Pass true to copy keys off of the prototype as well as the instance.
* @return {Object} The modified object.
- */
+ */
copyTo : function(dest, source, names, usePrototypeKeys){
if(typeof names == 'string'){
names = names.split(/[,;\s]/);
@@ -8765,13 +9035,35 @@ ImageComponent = Ext.extend(Ext.Component, {
* @param {Mixed} arg1 The name of the property to destroy and remove from the object.
* @param {Mixed} etc... More property names to destroy and remove.
*/
- 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]];
}
},
+ /**
+ * Logs a message. If a console is present it will be used. On Opera, the method
+ * "opera.postError" is called. In other cases, the message is logged to an array
+ * "Ext.log.out". An attached debugger can watch this array and view the log. The
+ * log buffer is limited to a maximum of "Ext.log.max" entries (defaults to 100).
+ *
+ * If additional parameters are passed, they are joined and appended to the message.
+ *
+ * This method does nothing in a release build.
+ *
+ * @param {String|Object} message The message to log or an options object with any
+ * of the following properties:
+ *
+ * - `msg`: The message to log (required).
+ * - `level`: One of: "error", "warn", "info" or "log" (the default is "log").
+ * - `dump`: An object to dump to the log as part of the message.
+ * - `stack`: True to include a stack trace in the log.
+ * @markdown
+ */
+ log : function (message) {
+ },
+
/**
* Partitions the set into two sets: a true set and a false set.
* Example:
@@ -8792,8 +9084,8 @@ Ext.partition(
*
* @param {Array|NodeList} arr The array to partition
* @param {Function} truth (optional) a function to determine truth. If this is omitted the element
- * itself must be able to be evaluated for its truthfulness.
- * @return {Array} [trueNOTE: For other arbitrary attributes, the value will currently not be automatically + * HTML-escaped prior to building the element's HTML string. This means that if your attribute value + * contains special characters that would not normally be allowed in a double-quoted attribute value, + * you must manually HTML-encode it beforehand (see {@link Ext.String#htmlEncode}) or risk + * malformed HTML being created. This behavior may change in a future release.
* *Insertion methods
*Commonly used insertion methods: @@ -10576,13 +10956,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 + '"' - }); }, /** @@ -10648,6 +11021,7 @@ Ext.core.DomHelper = function(){ * Creates new DOM element(s) without inserting them to the document. * @param {Object/String} o The DOM object spec (and children) or raw HTML blob * @return {HTMLElement} The new uninserted node + * @method */ createDom: createDom, @@ -11169,11 +11543,6 @@ Ext.core.DomQuery = Ext.DomQuery = function(){ } // prevent infinite loop on bad selector if(!matched){ - Ext.Error.raise({ - sourceClass: 'Ext.DomQuery', - sourceMethod: 'compile', - msg: 'Error parsing selector. Parsing failed at "' + path + '"' - }); } } if(modeMatch[1]){ @@ -11190,7 +11559,10 @@ Ext.core.DomQuery = Ext.DomQuery = function(){ }, /** - * Selects a group of elements. + * Selects an array of DOM nodes using JavaScript-only implementation. + * + * Use {@link #select} to take advantage of browsers built-in support for CSS selectors. + * * @param {String} selector The selector/xpath query (can be a comma separated list of selectors) * @param {Node/String} root (optional) The start of the query (defaults to document). * @return {Array} An Array of DOM elements which match the selector. If there are @@ -11213,11 +11585,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); @@ -11238,7 +11605,23 @@ Ext.core.DomQuery = Ext.DomQuery = function(){ var docEl = (el ? el.ownerDocument || el : 0).documentElement; return docEl ? docEl.nodeName !== "HTML" : false; }, - + + /** + * Selects an array of DOM nodes by CSS/XPath selector. + * + * Uses [document.querySelectorAll][0] if browser supports that, otherwise falls back to + * {@link #jsSelect} to do the work. + * + * Aliased as {@link Ext#query}. + * + * [0]: https://developer.mozilla.org/en/DOM/document.querySelectorAll + * + * @param {String} path The selector/xpath query + * @param {Node} root (optional) The start of the query (defaults to document). + * @return {Array} An array of DOM elements (not a NodeList as returned by `querySelectorAll`). + * Empty array when no matches. + * @method + */ select : document.querySelectorAll ? function(path, root, type) { root = root || document; if (!Ext.DomQuery.isXml(root)) { @@ -12231,9 +12614,6 @@ el.un('click', this.handlerFn); // Otherwise, warn if it's not a valid CSS measurement 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; @@ -12300,6 +12680,7 @@ el.un('click', this.handlerFn); * @param {String} name The attribute name * @param {String} namespace (optional) The namespace in which to look for the attribute * @return {String} The attribute value + * @method */ getAttribute: (Ext.isIE && !(Ext.isIE9 && document.documentMode === 9)) ? function(name, ns) { @@ -13054,11 +13435,11 @@ Ext.core.Element.addMethods({ cls = [], space = ((me.dom.className.replace(trimRe, '') == '') ? "" : " "), i, len, v; - if (!Ext.isDefined(className)) { + if (className === undefined) { return me; } // Separate case is for speed - 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) { @@ -13092,10 +13473,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) { @@ -13106,7 +13487,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); } } } @@ -13137,6 +13518,7 @@ Ext.core.Element.addMethods({ * Toggles the specified CSS class on this element (removes it if it already exists, otherwise adds it). * @param {String} className The CSS class to toggle * @return {Ext.core.Element} this + * @method */ toggleCls : Ext.supports.ClassList ? function(className) { @@ -13151,6 +13533,7 @@ Ext.core.Element.addMethods({ * Checks if the specified CSS class exists on this element's DOM node. * @param {String} className The CSS class to check for * @return {Boolean} True if the class exists, else false + * @method */ hasCls : Ext.supports.ClassList ? function(className) { @@ -13189,12 +13572,13 @@ Ext.core.Element.addMethods({ * Normalizes currentStyle and computedStyle. * @param {String} property The style property whose value is returned. * @return {String} The current value of the style property for this element. + * @method */ getStyle : function(){ return view && view.getComputedStyle ? function(prop){ var el = this.dom, - v, cs, out, display; + v, cs, out, display, cleaner; if(el == document){ return null; @@ -13206,10 +13590,12 @@ Ext.core.Element.addMethods({ // Ignore cases when the margin is correctly reported as 0, the bug only shows // numbers larger. 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){ @@ -13283,8 +13669,7 @@ Ext.core.Element.addMethods({ if (!me.dom) { return me; } - - if (!Ext.isObject(prop)) { + if (typeof prop === 'string') { tmp = {}; tmp[prop] = value; prop = tmp; @@ -13754,7 +14139,8 @@ Ext.fly('elId').setHeight(150, { */ setSize : function(width, height, animate){ var me = this; - if (Ext.isObject(width)){ // in case of object from getSize() + if (Ext.isObject(width)) { // in case of object from getSize() + animate = height; height = width.height; width = width.width; } @@ -13765,7 +14151,7 @@ Ext.fly('elId').setHeight(150, { me.dom.style.height = me.addUnits(height); } else { - if (!Ext.isObject(animate)) { + if (animate === true) { animate = {}; } me.animate(Ext.applyIf({ @@ -15144,7 +15530,7 @@ el.fadeOut({ /** * @deprecated 4.0 * Animates the transition of an element's dimensions from a starting height/width - * to an ending height/width. This method is a convenience implementation of {@link shift}. + * to an ending height/width. This method is a convenience implementation of {@link #shift}. * Usage:
// change height and width to 100x100 pixels
@@ -15651,7 +16037,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;
},
@@ -15712,13 +16098,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);
};
@@ -15766,7 +16145,7 @@ Ext.select = Ext.core.Element.select;
*
* @constructor The parameters to this constructor serve as defaults and are not required.
* @param {Function} fn (optional) The default function to call.
- * @param {Object} scope The default scope (The this
reference) in which the
+ * @param {Object} scope (optional) The default scope (The this
reference) in which the
* function is called. If not specified, this
will refer to the browser window.
* @param {Array} args (optional) The default Array of arguments.
*/
@@ -15847,13 +16226,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);
@@ -15945,7 +16317,7 @@ Ext.require('Ext.util.DelayedTask', function() {
}
// remove this listener from the listeners array
- me.listeners.splice(index, 1);
+ Ext.Array.erase(me.listeners, index, 1);
return true;
}
@@ -16305,7 +16677,7 @@ Ext.EventManager = {
*/
addListener: function(element, eventName, fn, scope, options){
// Check if we've been passed a "config style" event.
- if (Ext.isObject(eventName)) {
+ if (typeof eventName !== 'string') {
this.prepareListenerConfig(element, eventName);
return;
}
@@ -16314,24 +16686,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.'
- });
- }
// create the wrapper function
options = options || {};
@@ -16369,7 +16723,7 @@ Ext.EventManager = {
*/
removeListener : function(element, eventName, fn, scope) {
// handle our listener config object syntax
- if (Ext.isObject(eventName)) {
+ if (typeof eventName !== 'string') {
this.prepareListenerConfig(element, eventName, true);
return;
}
@@ -16413,7 +16767,7 @@ Ext.EventManager = {
}
// remove listener from cache
- cache.splice(i, 1);
+ Ext.Array.erase(cache, i, 1);
}
}
},
@@ -16470,74 +16824,79 @@ Ext.EventManager = {
* @param {String} ename The event name
* @param {Function} fn The function to execute
* @param {Object} scope The scope to execute callback in
- * @param {Object} o The options
+ * @param {Object} options The options
+ * @return {Function} the wrapper function
*/
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) {
+ // Compile the implementation upon first firing
+ 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(){');
+ }
- // finally call the actual handler fn
- 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);');
- }
+ // finally call the actual handler fn
+ 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 + '));');
+ }
- gen = Ext.functionFactory('e', 'options', 'fn', 'scope', 'ename', 'dom', 'wrap', 'args', f.join('\n'));
+ if(options.buffer) {
+ f.push('}, ' + options.buffer + ');');
+ }
+
+ 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);
};
},
@@ -16550,6 +16909,10 @@ Ext.EventManager = {
* @return {Array} The events for the element
*/
getEventListenerCache : function(element, eventName) {
+ if (!element) {
+ return [];
+ }
+
var eventCache = this.getElementEventCache(element);
return eventCache[eventName] || (eventCache[eventName] = []);
},
@@ -16561,6 +16924,9 @@ Ext.EventManager = {
* @return {Object} The event cache for the object
*/
getElementEventCache : function(element) {
+ if (!element) {
+ return {};
+ }
var elementCache = Ext.cache[this.getId(element)];
return elementCache.events || (elementCache.events = {});
},
@@ -16853,7 +17219,7 @@ Ext.EventManager.un = Ext.EventManager.removeListener;
// find the body element
var bd = document.body || document.getElementsByTagName('body')[0],
baseCSSPrefix = Ext.baseCSSPrefix,
- cls = [],
+ cls = [baseCSSPrefix + 'body'],
htmlCls = [],
html;
@@ -17157,6 +17523,54 @@ Ext.define('Ext.EventObjectImpl', {
F11: 122,
/** Key constant @type Number */
F12: 123,
+ /**
+ * The mouse wheel delta scaling factor. This value depends on browser version and OS and
+ * attempts to produce a similar scrolling experience across all platforms and browsers.
+ *
+ * To change this value:
+ *
+ * Ext.EventObjectImpl.prototype.WHEEL_SCALE = 72;
+ *
+ * @type Number
+ * @markdown
+ */
+ WHEEL_SCALE: (function () {
+ var scale;
+
+ if (Ext.isGecko) {
+ // Firefox uses 3 on all platforms
+ scale = 3;
+ } else if (Ext.isMac) {
+ // Continuous scrolling devices have momentum and produce much more scroll than
+ // discrete devices on the same OS and browser. To make things exciting, Safari
+ // (and not Chrome) changed from small values to 120 (like IE).
+
+ if (Ext.isSafari && Ext.webKitVersion >= 532.0) {
+ // Safari changed the scrolling factor to match IE (for details see
+ // https://bugs.webkit.org/show_bug.cgi?id=24368). The WebKit version where this
+ // change was introduced was 532.0
+ // Detailed discussion:
+ // https://bugs.webkit.org/show_bug.cgi?id=29601
+ // http://trac.webkit.org/browser/trunk/WebKit/chromium/src/mac/WebInputEventFactory.mm#L1063
+ scale = 120;
+ } else {
+ // MS optical wheel mouse produces multiples of 12 which is close enough
+ // to help tame the speed of the continuous mice...
+ scale = 12;
+ }
+
+ // Momentum scrolling produces very fast scrolling, so increase the scale factor
+ // to help produce similar results cross platform. This could be even larger and
+ // it would help those mice, but other mice would become almost unusable as a
+ // result (since we cannot tell which device type is in use).
+ scale *= 3;
+ } else {
+ // IE, Opera and other Windows browsers use 120.
+ scale = 120;
+ }
+
+ return scale;
+ })(),
/**
* Simple click regex
@@ -17371,19 +17785,68 @@ Ext.define('Ext.EventObjectImpl', {
},
/**
- * Normalizes mouse wheel delta across browsers
- * @return {Number} The delta
+ * Correctly scales a given wheel delta.
+ * @param {Number} delta The delta value.
*/
- 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; // don't allow non-zero deltas to go to zero!
+ }
+
+ return ret;
+ },
+
+ /**
+ * Returns the mouse wheel deltas for this event.
+ * @return {Object} An object with "x" and "y" properties holding the mouse wheel deltas.
+ */
+ getWheelDeltas : function () {
+ var me = this,
+ event = me.browserEvent,
+ dx = 0, dy = 0; // the deltas
+
+ if (Ext.isDefined(event.wheelDeltaX)) { // WebKit has both dimensions
+ dx = event.wheelDeltaX;
+ dy = event.wheelDeltaY;
+ } else if (event.wheelDelta) { // old WebKit and IE
+ dy = event.wheelDelta;
+ } else if (event.detail) { // Gecko
+ dy = -event.detail; // gecko is backwards
+
+ // Gecko sometimes returns really big values if the user changes settings to
+ // scroll a whole page per scroll
+ if (dy > 100) {
+ dy = 3;
+ } else if (dy < -100) {
+ dy = -3;
+ }
- if (event.wheelDelta) { /* IE/Opera. */
- delta = event.wheelDelta / 120;
- } else if (event.detail){ /* Mozilla case. */
- delta = -event.detail / 3;
+ // Firefox 3.1 adds an axis field to the event to indicate direction of
+ // scroll. See https://developer.mozilla.org/en/Gecko-Specific_DOM_Events
+ 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)
+ };
+ },
+
+ /**
+ * Normalizes mouse wheel y-delta across browsers. To get x-delta information, use
+ * {@link #getWheelDeltas} instead.
+ * @return {Number} The mouse wheel y-delta
+ */
+ getWheelDelta : function(){
+ var deltas = this.getWheelDeltas();
+
+ return deltas.y;
},
/**
@@ -17573,7 +18036,7 @@ Ext.getBody().on('click', function(e,t){
return target;
}
- }
+ };
} else if (document.createEventObject) { // else if (IE)
var crazyIEButtons = { 0: 1, 1: 4, 2: 2 };
@@ -17701,7 +18164,6 @@ Ext.getBody().on('click', function(e,t){
}
function cannotInject (target, srcEvent) {
- // TODO log something
}
return function (target) {
@@ -17726,6 +18188,7 @@ Ext.EventObject = new Ext.EventObjectImpl();
*/
(function(){
var doc = document,
+ activeElement = null,
isCSS1 = doc.compatMode == "CSS1Compat",
ELEMENT = Ext.core.Element,
fly = function(el){
@@ -17736,6 +18199,28 @@ Ext.EventObject = new Ext.EventObjectImpl();
return _fly;
}, _fly;
+ // If the browser does not support document.activeElement we need some assistance.
+ // This covers old Safari 3.2 (4.0 added activeElement along with just about all
+ // other browsers). We need this support to handle issues with old Safari.
+ if (!('activeElement' in doc) && doc.addEventListener) {
+ doc.addEventListener('focus',
+ function (ev) {
+ if (ev && ev.target) {
+ activeElement = (ev.target == doc) ? null : ev.target;
+ }
+ }, true);
+ }
+
+ /*
+ * Helper function to create the function that will restore the selection.
+ */
+ function makeSelectionRestoreFn (activeEl, start, end) {
+ return function () {
+ activeEl.selectionStart = start;
+ activeEl.selectionEnd = end;
+ };
+ }
+
Ext.apply(ELEMENT, {
isAncestor : function(p, c) {
var ret = false;
@@ -17756,6 +18241,59 @@ Ext.EventObject = new Ext.EventObjectImpl();
return ret;
},
+ /**
+ * Returns the active element in the DOM. If the browser supports activeElement
+ * on the document, this is returned. If not, the focus is tracked and the active
+ * element is maintained internally.
+ * @return {HTMLElement} The active (focused) element in the document.
+ */
+ getActiveElement: function () {
+ return doc.activeElement || activeElement;
+ },
+
+ /**
+ * Creates a function to call to clean up problems with the work-around for the
+ * WebKit RightMargin bug. The work-around is to add "display: 'inline-block'" to
+ * the element before calling getComputedStyle and then to restore its original
+ * display value. The problem with this is that it corrupts the selection of an
+ * INPUT or TEXTAREA element (as in the "I-beam" goes away but ths focus remains).
+ * To cleanup after this, we need to capture the selection of any such element and
+ * then restore it after we have restored the display style.
+ *
+ * @param target {Element} The top-most element being adjusted.
+ * @private
+ */
+ getRightMarginFixCleaner: function (target) {
+ var supports = Ext.supports,
+ hasInputBug = supports.DisplayChangeInputSelectionBug,
+ hasTextAreaBug = supports.DisplayChangeTextAreaSelectionBug;
+
+ if (hasInputBug || hasTextAreaBug) {
+ var activeEl = doc.activeElement || activeElement, // save a call
+ 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)) { // to be safe...
+ // We don't create the raw closure here inline because that
+ // will be costly even if we don't want to return it (nested
+ // function decls and exprs are often instantiated on entry
+ // regardless of whether execution ever reaches them):
+ return makeSelectionRestoreFn(activeEl, start, end);
+ }
+ }
+ }
+ }
+
+ return Ext.emptyFn; // avoid special cases, just return a nop
+ },
+
getViewWidth : function(full) {
return full ? ELEMENT.getDocumentWidth() : ELEMENT.getViewportWidth();
},
@@ -17906,7 +18444,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))) {
@@ -18301,11 +18839,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();
@@ -18323,11 +18856,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];
@@ -18362,14 +18890,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];
@@ -19574,7 +20094,7 @@ Ext.apply(Ext.CompositeElementLite.prototype, {
Ext.removeNode(el);
}
}
- els.splice(val, 1);
+ Ext.Array.erase(els, val, 1);
}
});
return this;
@@ -19675,14 +20195,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);
};