X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/7a654f8d43fdb43d78b63d90528bed6e86b608cc..f562e4c6e5fac7bcb445985b99acbea4d706e6f0:/src/core/src/Ext-more.js
diff --git a/src/core/src/Ext-more.js b/src/core/src/Ext-more.js
index 5e5a030f..5e8a7012 100644
--- a/src/core/src/Ext-more.js
+++ b/src/core/src/Ext-more.js
@@ -1,3 +1,17 @@
+/*
+
+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
@@ -20,9 +34,9 @@
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
@@ -31,8 +45,6 @@ Ext.apply(Ext, {
userAgent: navigator.userAgent.toLowerCase(),
cache: {},
idSeed: 1000,
- BLANK_IMAGE_URL : 'data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==',
- isStrict: document.compatMode == "CSS1Compat",
windowId: 'ext-window',
documentId: 'ext-document',
@@ -43,48 +55,57 @@ Ext.apply(Ext, {
isReady: false,
/**
- * True to automatically uncache orphaned Ext.core.Elements periodically (defaults to true)
+ * True to automatically uncache orphaned Ext.Elements periodically
* @type Boolean
*/
enableGarbageCollector: true,
/**
- * True to automatically purge event listeners during garbageCollection (defaults to true).
+ * True to automatically purge event listeners during garbageCollection.
* @type Boolean
*/
enableListenerCollection: true,
/**
* Generates unique ids. If the element already has an id, it is unchanged
- * @param {Mixed} el (optional) The element to generate an id for
+ * @param {HTMLElement/Ext.Element} el (optional) The element to generate an id for
* @param {String} prefix (optional) Id prefix (defaults "ext-gen")
* @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;
},
/**
- * Returns the current document body as an {@link Ext.core.Element}.
- * @return Ext.core.Element The document body
+ * Returns the current document body as an {@link Ext.Element}.
+ * @return Ext.Element The document body
*/
getBody: function() {
return Ext.get(document.body || false);
},
/**
- * Returns the current document head as an {@link Ext.core.Element}.
- * @return Ext.core.Element The document head
+ * Returns the current document head as an {@link Ext.Element}.
+ * @return Ext.Element The document head
+ * @method
*/
getHead: function() {
var head;
@@ -99,8 +120,8 @@ Ext.apply(Ext, {
}(),
/**
- * Returns the current HTML document object as an {@link Ext.core.Element}.
- * @return Ext.core.Element The document
+ * Returns the current HTML document object as an {@link Ext.Element}.
+ * @return Ext.Element The document
*/
getDoc: function() {
return Ext.get(document);
@@ -128,12 +149,11 @@ Ext.apply(Ext, {
/**
* Attempts to destroy any objects passed to it by removing all event listeners, removing them from the
* DOM (if applicable) and calling their destroy functions (if available). This method is primarily
- * intended for arguments of type {@link Ext.core.Element} and {@link Ext.Component}, but any subclass of
+ * intended for arguments of type {@link Ext.Element} and {@link Ext.Component}, but any subclass of
* {@link Ext.util.Observable} can be passed in. Any number of elements and/or components can be
* passed into this function in a single call as separate arguments.
- * @param {Mixed} arg1 An {@link Ext.core.Element}, {@link Ext.Component}, or an Array of either of these to destroy
- * @param {Mixed} arg2 (optional)
- * @param {Mixed} etc... (optional)
+ * @param {Ext.Element/Ext.Component/Ext.Element[]/Ext.Component[]...} arg1
+ * An {@link Ext.Element}, {@link Ext.Component}, or an Array of either of these to destroy
*/
destroy: function() {
var ln = arguments.length,
@@ -157,6 +177,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
@@ -212,15 +238,37 @@ Ext.ns = Ext.namespace;
// for old browsers
window.undefined = window.undefined;
+
/**
* @class Ext
* Ext core utilities and functions.
* @singleton
*/
(function(){
+/*
+FF 3.6 - Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17
+FF 4.0.1 - Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
+FF 5.0 - Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0
+
+IE6 - Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;)
+IE7 - Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1;)
+IE8 - Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)
+IE9 - Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
+
+Chrome 11 - Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.60 Safari/534.24
+
+Safari 5 - Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1
+
+Opera 11.11 - Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11
+*/
var check = function(regex){
return regex.test(Ext.userAgent);
},
+ isStrict = document.compatMode == "CSS1Compat",
+ version = function (is, regex) {
+ var m;
+ return (is && (m = regex.exec(Ext.userAgent))) ? parseFloat(m[1]) : 0;
+ },
docMode = document.documentMode,
isOpera = check(/opera/),
isOpera10_5 = isOpera && check(/version\/10\.5/),
@@ -230,6 +278,7 @@ window.undefined = window.undefined;
isSafari2 = isSafari && check(/applewebkit\/4/), // unique to Safari 2
isSafari3 = isSafari && check(/version\/3/),
isSafari4 = isSafari && check(/version\/4/),
+ isSafari5 = isSafari && check(/version\/5/),
isIE = !isOpera && check(/msie/),
isIE7 = isIE && (check(/msie 7/) || docMode == 7),
isIE8 = isIE && (check(/msie 8/) && docMode != 7 && docMode != 9 || docMode == 8),
@@ -238,27 +287,170 @@ window.undefined = window.undefined;
isGecko = !isWebKit && check(/gecko/),
isGecko3 = isGecko && check(/rv:1\.9/),
isGecko4 = isGecko && check(/rv:2\.0/),
+ isGecko5 = isGecko && check(/rv:5\./),
isFF3_0 = isGecko3 && check(/rv:1\.9\.0/),
isFF3_5 = isGecko3 && check(/rv:1\.9\.1/),
isFF3_6 = isGecko3 && check(/rv:1\.9\.2/),
isWindows = check(/windows|win32/),
isMac = check(/macintosh|mac os x/),
isLinux = check(/linux/),
- scrollWidth = null;
+ scrollbarSize = null,
+ chromeVersion = version(true, /\bchrome\/(\d+\.\d+)/),
+ firefoxVersion = version(true, /\bfirefox\/(\d+\.\d+)/),
+ ieVersion = version(isIE, /msie (\d+\.\d+)/),
+ operaVersion = version(isOpera, /version\/(\d+\.\d+)/),
+ safariVersion = version(isSafari, /version\/(\d+\.\d+)/),
+ webKitVersion = version(isWebKit, /webkit\/(\d+\.\d+)/),
+ isSecure = /^https/i.test(window.location.protocol);
// remove css image flicker
try {
document.execCommand("BackgroundImageCache", false, true);
} catch(e) {}
- Ext.setVersion('extjs', '4.0.0');
+ //true
, then DOM event listeners are also removed from all child nodes. The body node
* will be ignored if passed in.
Utility method for returning a default value if the passed value is empty.
@@ -513,11 +782,11 @@ function(el){ *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
+ * @param {String/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]/);
@@ -637,16 +929,56 @@ ImageComponent = Ext.extend(Ext.Component, {
/**
* Attempts to destroy and then remove a set of named properties of the passed object.
* @param {Object} o The object (most likely a Component) who's properties you wish to destroy.
- * @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.
+ * @param {String...} args One or more names of the properties to destroy and remove from the object.
*/
- 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 250).
+ * The `Ext.log.out` array can also be written to a popup window by entering the
+ * following in the URL bar (a "bookmarklet"):
+ *
+ * javascript:void(Ext.log.show());
+ *
+ * If additional parameters are passed, they are joined and appended to the message.
+ * A technique for tracing entry and exit of a function is this:
+ *
+ * function foo () {
+ * Ext.log({ indent: 1 }, '>> foo');
+ *
+ * // log statements in here or methods called from here will be indented
+ * // by one step
+ *
+ * Ext.log({ outdent: 1 }, '<< foo');
+ * }
+ *
+ * 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.
+ * - `indent`: Cause subsequent log statements to be indented one step.
+ * - `outdent`: Cause this and following statements to be one step less indented.
+ * @markdown
+ */
+ log :
+ //