X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6746dc89c47ed01b165cc1152533605f97eb8e8d..f562e4c6e5fac7bcb445985b99acbea4d706e6f0:/pkgs/extras.js diff --git a/pkgs/extras.js b/pkgs/extras.js index 77728fd4..f4c99d79 100644 --- a/pkgs/extras.js +++ b/pkgs/extras.js @@ -14,7 +14,7 @@ If you are unsure which license is appropriate for your use, please contact the */ /** * @class Ext.JSON - * Modified version of Douglas Crockford"s json.js that doesn"t + * Modified version of Douglas Crockford's JSON.js that doesn't * mess with the Object prototype * http://www.json.org/js.html * @singleton @@ -107,15 +107,15 @@ Ext.JSON = new(function() { * The returned value includes enclosing double quotation marks.
*The default return format is "yyyy-mm-ddThh:mm:ss".
*To override this:
- Ext.JSON.encodeDate = function(d) {
- return d.format('"Y-m-d"');
- };
+Ext.JSON.encodeDate = function(d) {
+ return Ext.Date.format(d, '"Y-m-d"');
+};
* @param {Date} d The Date to encode
* @return {String} The string literal to use in a JSON string.
*/
this.encodeDate = function(o) {
- return '"' + o.getFullYear() + "-"
+ return '"' + o.getFullYear() + "-"
+ pad(o.getMonth() + 1) + "-"
+ pad(o.getDate()) + "T"
+ pad(o.getHours()) + ":"
@@ -125,7 +125,7 @@ Ext.JSON = new(function() {
/**
* Encodes an Object, Array or other value
- * @param {Mixed} o The variable to encode
+ * @param {Object} o The variable to encode
* @return {String} The JSON string
*/
this.encode = function() {
@@ -171,19 +171,16 @@ Ext.JSON = new(function() {
})();
/**
* Shorthand for {@link Ext.JSON#encode}
- * @param {Mixed} o The variable to encode
- * @return {String} The JSON string
* @member Ext
* @method encode
+ * @alias Ext.JSON#encode
*/
Ext.encode = Ext.JSON.encode;
/**
* Shorthand for {@link Ext.JSON#decode}
- * @param {String} json The JSON string
- * @param {Boolean} safe (optional) Whether to return null or throw an exception if the JSON is invalid.
- * @return {Object} The resulting object
* @member Ext
* @method decode
+ * @alias Ext.JSON#decode
*/
Ext.decode = Ext.JSON.decode;
@@ -221,8 +218,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',
@@ -233,20 +228,20 @@ 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.
*/
@@ -273,16 +268,16 @@ Ext.apply(Ext, {
},
/**
- * 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() {
@@ -298,8 +293,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);
@@ -327,12 +322,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,
@@ -356,12 +350,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
@@ -424,9 +418,30 @@ window.undefined = window.undefined;
* @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/),
@@ -436,6 +451,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),
@@ -444,6 +460,7 @@ window.undefined = window.undefined;
isGecko = !isWebKit && check(/gecko/),
isGecko3 = isGecko && check(/rv:1\.9/),
isGecko4 = isGecko && check(/rv:2\.0/),
+ isGecko5 = isGecko && check(/rv:5\./),
isFF3_0 = isGecko3 && check(/rv:1\.9\.0/),
isFF3_5 = isGecko3 && check(/rv:1\.9\.1/),
isFF3_6 = isGecko3 && check(/rv:1\.9\.2/),
@@ -451,21 +468,162 @@ window.undefined = window.undefined;
isMac = check(/macintosh|mac os x/),
isLinux = check(/linux/),
scrollbarSize = null,
- webKitVersion = isWebKit && (/webkit\/(\d+\.\d+)/.exec(Ext.userAgent));
+ chromeVersion = version(true, /\bchrome\/(\d+\.\d+)/),
+ firefoxVersion = version(true, /\bfirefox\/(\d+\.\d+)/),
+ ieVersion = version(isIE, /msie (\d+\.\d+)/),
+ operaVersion = version(isOpera, /version\/(\d+\.\d+)/),
+ safariVersion = version(isSafari, /version\/(\d+\.\d+)/),
+ webKitVersion = version(isWebKit, /webkit\/(\d+\.\d+)/),
+ isSecure = /^https/i.test(window.location.protocol);
// remove css image flicker
try {
document.execCommand("BackgroundImageCache", false, true);
} catch(e) {}
- Ext.setVersion('extjs', '4.0.2');
+ //Utility method for returning a default value if the passed value is empty.
@@ -727,10 +955,10 @@ function(el){ *The character that the {@link #number} function uses as a thousand separator.
- *This defaults to ,
, but may be overridden in a locale file.
This may be overridden in a locale file.
*/ thousandSeparator: ',', /** - * @type String - * @property decimalSeparator + * @property {String} decimalSeparator *The character that the {@link #number} function uses as a decimal point.
- *This defaults to .
, but may be overridden in a locale file.
This may be overridden in a locale file.
*/ decimalSeparator: '.', /** - * @type Number - * @property currencyPrecision + * @property {Number} currencyPrecision *The number of decimal places that the {@link #currency} function displays.
- *This defaults to 2
, but may be overridden in a locale file.
This may be overridden in a locale file.
*/ currencyPrecision: 2, /** - * @type String - * @property currencySign + * @property {String} currencySign *The currency sign that the {@link #currency} function displays.
- *This defaults to $
, but may be overridden in a locale file.
This may be overridden in a locale file.
*/ currencySign: '$', /** - * @type Boolean - * @property currencyAtEnd + * @property {Boolean} currencyAtEnd *This may be set to true
to make the {@link #currency} function
* append the currency sign to the formatted value.
This defaults to false
, but may be overridden in a locale file.
This may be overridden in a locale file.
*/ currencyAtEnd: false, /** * Checks a reference and converts it to empty string if it is undefined - * @param {Mixed} value Reference to check - * @return {Mixed} Empty string if converted, otherwise the original value + * @param {Object} value Reference to check + * @return {Object} Empty string if converted, otherwise the original value */ undef : function(value) { return value !== undefined ? value : ""; @@ -1268,7 +1409,7 @@ XTemplates can also directly use Ext.util.Format functions: /** * Checks a reference and converts it to the default value if it's empty - * @param {Mixed} value Reference to check + * @param {Object} value Reference to check * @param {String} defaultValue The value to insert of it's undefined (defaults to "") * @return {String} */ @@ -1336,7 +1477,7 @@ XTemplates can also directly use Ext.util.Format functions: for (; i < decimals; i++) { format += '0'; } - v = UtilFormat.number(v, format); + v = UtilFormat.number(v, format); if ((end || UtilFormat.currencyAtEnd) === true) { return Ext.String.format("{0}{1}{2}", negativeSign, v, currencySign || UtilFormat.currencySign); } else { @@ -1374,7 +1515,7 @@ XTemplates can also directly use Ext.util.Format functions: /** * Strips all HTML tags - * @param {Mixed} value The text from which to strip tags + * @param {Object} value The text from which to strip tags * @return {String} The stripped text */ stripTags : function(v) { @@ -1383,7 +1524,7 @@ XTemplates can also directly use Ext.util.Format functions: /** * Strips all script tags - * @param {Mixed} value The text from which to strip script tags + * @param {Object} value The text from which to strip script tags * @return {String} The stripped text */ stripScripts : function(v) { @@ -1445,7 +1586,7 @@ XTemplates can also directly use Ext.util.Format functions: *The presence of a thousand separator character in the format string specifies that * the locale-specific thousand separator (if any) is inserted separating thousand groups.
*By default, "," is expected as the thousand separator, and "." is expected as the decimal separator.
- *New to Ext4
+ *New to Ext JS 4
*Locale-specific characters are always used in the formatted output when inserting * thousand and decimal separators.
*The format string must specify separator characters according to US/UK conventions ("," as the @@ -1546,7 +1687,7 @@ XTemplates can also directly use Ext.util.Format functions: fnum = psplit[0] + dec + psplit[1]; } } - + if (neg) { /* * Edge case. If we have a very small negative number it will get rounded to 0, @@ -1592,54 +1733,58 @@ XTemplates can also directly use Ext.util.Format functions: }, /** - * Capitalize the given string. See {@link Ext.String#capitalize}. + * Alias for {@link Ext.String#capitalize}. * @method + * @alias Ext.String#capitalize */ capitalize: Ext.String.capitalize, /** - * Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length. - * See {@link Ext.String#ellipsis}. + * Alias for {@link Ext.String#ellipsis}. * @method + * @alias Ext.String#ellipsis */ ellipsis: Ext.String.ellipsis, /** - * Formats to a string. See {@link Ext.String#format} + * Alias for {@link Ext.String#format}. * @method + * @alias Ext.String#format */ format: Ext.String.format, /** - * Convert certain characters (&, <, >, and ') from their HTML character equivalents. - * See {@link Ext.String#htmlDecode}. + * Alias for {@link Ext.String#htmlDecode}. * @method + * @alias Ext.String#htmlDecode */ htmlDecode: Ext.String.htmlDecode, /** - * Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages. - * See {@link Ext.String#htmlEncode}. + * Alias for {@link Ext.String#htmlEncode}. * @method + * @alias Ext.String#htmlEncode */ htmlEncode: Ext.String.htmlEncode, /** - * Adds left padding to a string. See {@link Ext.String#leftPad} + * Alias for {@link Ext.String#leftPad}. * @method + * @alias Ext.String#leftPad */ leftPad: Ext.String.leftPad, /** - * Trims any whitespace from either side of a string. See {@link Ext.String#trim}. + * Alias for {@link Ext.String#trim}. * @method + * @alias Ext.String#trim */ trim : Ext.String.trim, /** * Parses a number or string representing margin sizes into an object. Supports CSS-style margin declarations * (e.g. 10, "10", "10 10", "10 10 10" and "10 10 10 10" are all valid options and would return the same result) - * @param {Number|String} v The encoded margins + * @param {Number/String} v The encoded margins * @return {Object} An object with margin sizes for top, right, bottom and left */ parseBox : function(box) { @@ -1709,8 +1854,7 @@ Ext.TaskManager.start({ * Also see {@link Ext.util.DelayedTask}. * * @constructor - * @param {Number} interval (optional) The minimum precision in milliseconds supported by this TaskRunner instance - * (defaults to 10) + * @param {Number} [interval=10] The minimum precision in milliseconds supported by this TaskRunner instance */ Ext.ns('Ext.util');