/** * TO BE CLEANED UP. A HUGE MESS IN HERE * @class Ext * Ext core utilities and functions. * @singleton */ 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',
/** * True when the document is fully initialized and ready for action * @type Boolean */ isReady: false,
/** * True to automatically uncache orphaned Ext.core.Elements periodically (defaults to true) * @type Boolean */ enableGarbageCollector: true,
/** * True to automatically purge event listeners during garbageCollection (defaults to true). * @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 {String} prefix (optional) Id prefix (defaults "ext-gen") * @return {String} The generated Id. */ id: function(el, prefix) { el = Ext.getDom(el) || {}; if (el === document) { el.id = this.documentId; } else if (el === window) { el.id = this.windowId; } el.id = el.id || ((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 */ 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 */ getHead: function() { var head; return function() { if (head == undefined) { head = Ext.get(document.getElementsByTagName("head")[0]); } return head; }; }(),
/** * Returns the current HTML document object as an {@link Ext.core.Element}. * @return Ext.core.Element The document */ getDoc: function() { return Ext.get(document); },
/** * This is shorthand reference to {@link Ext.ComponentMgr#get}. * Looks up an existing {@link Ext.Component Component} by {@link Ext.Component#id id} * @param {String} id The component {@link Ext.Component#id id} * @return Ext.Component The Component, undefined if not found, or null if a * Class was found. */ getCmp: function(id) { return Ext.ComponentMgr.get(id); },
/** * Returns the current orientation of the mobile device * @return {String} Either 'portrait' or 'landscape' */ getOrientation: function() { return window.innerHeight > window.innerWidth ? 'portrait' : 'landscape'; },
/** * 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 * {@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) */ destroy: function() { var ln = arguments.length, i, arg; for (i = 0; i < ln; i++) { arg = arguments[i]; if (arg) { if (Ext.isArray(arg)) { this.destroy.apply(this, arg); } else if (Ext.isFunction(arg.destroy)) { arg.destroy(); } else if (arg.dom) { arg.remove(); } } } },
/** * Execute a callback function in a particular scope. If no function is passed the call is ignored. * @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 * @param {Number} delay (optional) Pass a number to delay the call by a number of milliseconds. */ callback: function(callback, scope, args, delay){ if(Ext.isFunction(callback)){ args = args || []; scope = scope || window; if (delay) { Ext.defer(callback, delay, scope, args); } else { callback.apply(scope, args); } } },
/** * Takes an object and converts it to an encoded URL. e.g. Ext.urlEncode({foo: 1, bar: 2}); would return "foo=1&bar=2". Optionally, * property values can be arrays, instead of keys and the resulting string that's returned will contain a name/value pair for each array value. * @param {Object} o The object to encode * @param {String} pre (optional) A prefix to add to the url encoded string * @return {String} */ urlEncode : function(o, pre) { var empty, buf = [], e = encodeURIComponent; Ext.iterate(o, function(key, item){ empty = Ext.isEmpty(item); Ext.each(empty ? key : item, function(val){ buf.push('&', e(key), '=', (!Ext.isEmpty(val) && (val != key || !empty)) ? (Ext.isDate(val) ? Ext.encode(val).replace(/"/g, '') : e(val)) : ''); }); }); if(!pre){ buf.shift(); pre = ''; } return pre + buf.join(''); },
/** * Takes an encoded URL and and converts it to an object. Example: *

Ext.urlDecode("foo=1&bar=2"); // returns {foo: "1", bar: "2"}
Ext.urlDecode("foo=1&bar=2&bar=3&bar=4", false); // returns {foo: "1", bar: ["2", "3", "4"]}
       
* @param {String} string * @param {Boolean} overwrite (optional) Items of the same name will overwrite previous values instead of creating an an array (Defaults to false). * @return {Object} A literal with members */ urlDecode : function(string, overwrite) { if (Ext.isEmpty(string)) { return {}; } var obj = {}, pairs = string.split('&'), d = decodeURIComponent, name, value; Ext.each(pairs, function(pair) { pair = pair.split('='); name = d(pair[0]); value = d(pair[1]); obj[name] = overwrite || !obj[name] ? value : [].concat(obj[name]).concat(value); }); return obj; },
/** * Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages. * @param {String} value The string to encode * @return {String} The encoded text */ htmlEncode : function(value) { return Ext.String.htmlEncode(value); },
/** * Convert certain characters (&, <, >, and ') from their HTML character equivalents. * @param {String} value The string to decode * @return {String} The decoded text */ htmlDecode : function(value) { return Ext.String.htmlDecode(value); },
/** * Appends content to the query string of a URL, handling logic for whether to place * a question mark or ampersand. * @param {String} url The URL to append to. * @param {String} s The content to append to the URL. * @return (String) The resulting URL */ urlAppend : function(url, s) { if (!Ext.isEmpty(s)) { return url + (url.indexOf('?') === -1 ? '?' : '&') + s; } return url; },
/** * Iterates an array calling the supplied function. * @param {Array/NodeList/Mixed} array The array to be iterated. If this * argument is not really an array, the supplied function is called once. * @param {Function} fn The function to be called with each item. If the * supplied function returns false, iteration stops and this method returns * the current index. This function is called with * the following arguments: *
* @param {Object} scope The scope (this reference) in which the specified function is executed. * Defaults to the item at the current indexutil * within the passed array. * @return See description for the fn parameter. */ each : function(array, fn, scope) { if (Ext.isEmpty(array, true)) { return 0; } if (!Ext.isIterable(array) || Ext.isPrimitive(array)) { array = [array]; } for (var i = 0, len = array.length; i < len; i++) { if (fn.call(scope || array[i], array[i], i, array) === false) { return i; } } return true; },
/** * Iterates either the elements in an array, or each of the properties in an object. * Note: If you are only iterating arrays, it is better to call {@link #each}. * @param {Object/Array} object The object or array to be iterated * @param {Function} fn The function to be called for each iteration. * The iteration will stop if the supplied function returns false, or * all array elements / object properties have been covered. The signature * varies depending on the type of object being interated: *
* @param {Object} scope The scope (this reference) in which the specified function is executed. Defaults to * the object being iterated. */ iterate : function(obj, fn, scope) { if (Ext.isEmpty(obj)) { return; } if (Ext.isIterable(obj)) { Ext.each(obj, fn, scope); return; } else if (Ext.isObject(obj)) { for (var prop in obj) { if (obj.hasOwnProperty(prop)) { if (fn.call(scope || obj, prop, obj[prop], obj) === false) { return; } } } } } }); Ext.ns = Ext.namespace; Ext.ns( 'Ext.util', 'Ext.data', 'Ext.list', 'Ext.form', 'Ext.menu', 'Ext.state', 'Ext.layout', 'Ext.app', 'Ext.ux', 'Ext.plugins', 'Ext.direct', 'Ext.lib', 'Ext.gesture', 'Ext.core' ); // for old browsers window.undefined = window.undefined; Ext.ns("Ext.grid", "Ext.list", "Ext.dd", "Ext.tree", "Ext.form", "Ext.menu", "Ext.state", "Ext.layout", "Ext.app", "Ext.ux", "Ext.chart", "Ext.direct"); /** * @class Ext * Ext core utilities and functions. * @singleton */ (function(){ var check = function(regex){ return regex.test(Ext.userAgent); }, docMode = document.documentMode, isOpera = check(/opera/), isChrome = check(/\bchrome\b/), isWebKit = check(/webkit/), isSafari = !isChrome && check(/safari/), isSafari2 = isSafari && check(/applewebkit\/4/), // unique to Safari 2 isSafari3 = isSafari && check(/version\/3/), isSafari4 = isSafari && check(/version\/4/), isIE = !isOpera && check(/msie/), isIE7 = isIE && (check(/msie 7/) || docMode == 7), isIE8 = isIE && (check(/msie 8/) && docMode != 7 && docMode != 9 || docMode == 8), isIE9 = isIE && (check(/msie 9/) && docMode != 7 && docMode != 8 || docMode == 9), isIE6 = isIE && !isIE7 && !isIE8 && !isIE9, isGecko = !isWebKit && check(/gecko/), isGecko3 = isGecko && check(/rv:1\.9/), isGecko4 = isGecko && check(/rv:2\.0/), isBorderBox = isIE && !Ext.isStrict, isWindows = check(/windows|win32/), isMac = check(/macintosh|mac os x/), isAir = check(/adobeair/), isLinux = check(/linux/), scrollWidth = null; // remove css image flicker try { document.execCommand("BackgroundImageCache", false, true); } catch(e) {} Ext.setVersion('extjs', '4.0.0dev'); Ext.apply(Ext, {
/** * URL to a blank file used by Ext when in secure mode for iframe src and onReady src to prevent * the IE insecure content warning ('about:blank', except for IE in secure mode, which is 'javascript:""'). * @type String */ SSL_SECURE_URL : Ext.isSecure && isIE ? 'javascript:""' : 'about:blank',
/** * True if the {@link Ext.Fx} Class is available * @type Boolean * @property enableFx */
/** * HIGHLY EXPERIMENTAL * True to force css based border-box model override and turning off javascript based adjustments. This is a * runtime configuration and must be set before onReady. * @type Boolean */ enableForcedBoxModel : true,
/** * EXPERIMENTAL - True to cascade listener removal to child elements when an element is removed. * Currently not optimized for performance. * @type Boolean */ enableNestedListenerRemoval : false,
/** * Indicates whether to use native browser parsing for JSON methods. * This option is ignored if the browser does not support native JSON methods. * Note: Native JSON methods will not work with objects that have functions. * Also, property names must be quoted, otherwise the data will not parse. (Defaults to false) * @type Boolean */ USE_NATIVE_JSON : false,
/** * Converts any iterable (numeric indices and a length property) into a true array * Don't use this on strings. IE doesn't support "abc"[0] which this implementation depends on. * For strings, use this instead: "abc".match(/./g) => [a,b,c]; * @param {Iterable} the iterable object to be turned into a true Array. * @return (Array) array */ toArray : function() { return isIE ? function(a, i, j, res) { res = []; for (var x = 0, len = a.length; x < len; x++) { res.push(a[x]); } return res.slice(i || 0, j || res.length); } : function(a, i, j) { return Array.prototype.slice.call(a, i || 0, j || a.length); }; }(),
/** * Return the dom node for the passed String (id), dom node, or Ext.core.Element. * Optional 'strict' flag is needed for IE since it can return 'name' and * 'id' elements by using getElementById. * Here are some examples: *

// gets dom node based on id
var elDom = Ext.getDom('elId');
// gets dom node based on the dom node
var elDom1 = Ext.getDom(elDom);

// If we don't know if we are working with an
// Ext.core.Element or a dom node use Ext.getDom
function(el){
    var dom = Ext.getDom(el);
    // do something with the dom node
}
         * 
* Note: the dom node to be found actually needs to exist (be rendered, etc) * when this method is called to be successful. * @param {Mixed} el * @return HTMLElement */ getDom : function(el, strict) { if (!el || !document) { return null; } if (el.dom) { return el.dom; } else { if (typeof el == 'string') { var e = document.getElementById(el); // IE returns elements with the 'name' and 'id' attribute. // we do a strict check to return the element with only the id attribute if (e && strict) { return; if (el == e.getAttribute('id')) { return e; } else { return null; } } return e; } else { return el; } } },
/** * Removes a DOM node from the document. */
/** *

Removes this element from the document, removes all DOM event listeners, and deletes the cache reference. * All DOM event listeners are removed from this element. If {@link Ext#enableNestedListenerRemoval} is * true, then DOM event listeners are also removed from all child nodes. The body node * will be ignored if passed in.

* @param {HTMLElement} node The node to remove */ removeNode : isIE && !isIE8 ? function() { var d; return function(n){ if(n && n.tagName != 'BODY'){ (Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n) : Ext.EventManager.removeAll(n); d = d || document.createElement('div'); d.appendChild(n); d.innerHTML = ''; delete Ext.cache[n.id]; } }; }() : function(n) { if (n && n.parentNode && n.tagName != 'BODY') { (Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n) : Ext.EventManager.removeAll(n); n.parentNode.removeChild(n); delete Ext.cache[n.id]; } },
/** * True if the detected browser is Opera. * @type Boolean */ isOpera : isOpera,
/** * True if the detected browser uses WebKit. * @type Boolean */ isWebKit : isWebKit,
/** * True if the detected browser is Chrome. * @type Boolean */ isChrome : isChrome,
/** * True if the detected browser is Safari. * @type Boolean */ isSafari : isSafari,
/** * True if the detected browser is Safari 3.x. * @type Boolean */ isSafari3 : isSafari3,
/** * True if the detected browser is Safari 4.x. * @type Boolean */ isSafari4 : isSafari4,
/** * True if the detected browser is Safari 2.x. * @type Boolean */ isSafari2 : isSafari2,
/** * True if the detected browser is Internet Explorer. * @type Boolean */ isIE : isIE,
/** * True if the detected browser is Internet Explorer 6.x. * @type Boolean */ isIE6 : isIE6,
/** * True if the detected browser is Internet Explorer 7.x. * @type Boolean */ isIE7 : isIE7,
/** * True if the detected browser is Internet Explorer 8.x. * @type Boolean */ isIE8 : isIE8,
/** * True if the detected browser is Internet Explorer 9.x. * @type Boolean */ isIE9 : isIE9,
/** * True if the detected browser uses the Gecko layout engine (e.g. Mozilla, Firefox). * @type Boolean */ isGecko : isGecko,
/** * True if the detected browser uses a Gecko 1.9+ layout engine (e.g. Firefox 3.x). * @type Boolean */ isGecko3 : isGecko3,
/** * True if the detected browser uses a Gecko 2.0+ layout engine (e.g. Firefox 4.x). * @type Boolean */ isGecko4 : isGecko4,
/** * True if the detected browser is Internet Explorer running in non-strict mode. * @type Boolean */ isBorderBox : isBorderBox,
/** * True if the detected platform is Linux. * @type Boolean */ isLinux : isLinux,
/** * True if the detected platform is Windows. * @type Boolean */ isWindows : isWindows,
/** * True if the detected platform is Mac OS. * @type Boolean */ isMac : isMac,
/** * True if the detected platform is Adobe Air. * @type Boolean */ isAir : isAir,
/** * URL to a 1x1 transparent gif image used by Ext to create inline icons with CSS background images. * In older versions of IE, this defaults to "http://extjs.com/s.gif" and you should change this to a URL on your server. * For other browsers it uses an inline data URL. * @type String */ BLANK_IMAGE_URL : (isIE6 || isIE7 || isAir) ? 'http:/' + '/www.extjs.com/s.gif' : 'data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==',
/** *

Utility method for returning a default value if the passed value is empty.

*

The value is deemed to be empty if it is

    *
  • null
  • *
  • undefined
  • *
  • an empty array
  • *
  • a zero length string (Unless the allowBlank parameter is true)
  • *
* @param {Mixed} value The value to test * @param {Mixed} defaultValue The value to return if the original value is empty * @param {Boolean} allowBlank (optional) true to allow zero length strings to qualify as non-empty (defaults to false) * @return {Mixed} value, if non-empty, else defaultValue */ value : function(v, defaultValue, allowBlank){ return Ext.isEmpty(v, allowBlank) ? defaultValue : v; },
/** * Escapes the passed string for use in a regular expression * @param {String} str * @return {String} */ escapeRe : function(s) { return s.replace(/([-.*+?^${}()|[\]\/\\])/g, "\\$1"); },
/** * Applies event listeners to elements by selectors when the document is ready. * The event name is specified with an @ suffix. *

Ext.addBehaviors({
    // add a listener for click on all anchors in element with id foo
    '#foo a@click' : function(e, t){
        // do something
    },

    // add the same listener to multiple selectors (separated by comma BEFORE the @)
    '#foo a, #bar span.some-class@mouseover' : function(){
        // do something
    }
});
         * 
* @param {Object} obj The list of behaviors to apply */ addBehaviors : function(o){ if(!Ext.isReady){ Ext.onReady(function(){ Ext.addBehaviors(o); }); } else { var cache = {}, // simple cache for applying multiple behaviors to same selector does query multiple times parts, b, s; for (b in o) { if ((parts = b.split('@'))[1]) { // for Object prototype breakers s = parts[0]; if(!cache[s]){ cache[s] = Ext.select(s); } cache[s].on(parts[1], o[b]); } } cache = null; } },
/** * Utility method for getting the width of the browser scrollbar. This can differ depending on * operating system settings, such as the theme or font size. * @param {Boolean} force (optional) true to force a recalculation of the value. * @return {Number} The width of the scrollbar. */ getScrollBarWidth: function(force){ if(!Ext.isReady){ return 0; } if(force === true || scrollWidth === null){ // Append our div, do our calculation and then remove it var div = Ext.getBody().createChild('
'), child = div.child('div', true); var w1 = child.offsetWidth; div.setStyle('overflow', (Ext.isWebKit || Ext.isGecko) ? 'auto' : 'scroll'); var w2 = child.offsetWidth; div.remove(); // Need to add 2 to ensure we leave enough space scrollWidth = w1 - w2 + 2; } return scrollWidth; },
/** * Copies a set of named properties fom the source object to the destination object. *

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');
    }
});
         * 
* @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]/); } Ext.each(names, function(name){ if(usePrototypeKeys || source.hasOwnProperty(name)){ dest[name] = source[name]; } }, this); return dest; },
/** * 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. */ destroyMembers : function(o, arg1, arg2, etc){ for (var i = 1, a = arguments, len = a.length; i < len; i++) { Ext.destroy(o[a[i]]); delete o[a[i]]; } },
/** * Creates a copy of the passed Array with falsy values removed. * @param {Array/NodeList} arr The Array from which to remove falsy values. * @return {Array} The new, compressed Array. */ clean : function(arr){ var ret = []; Ext.each(arr, function(v){ if(!!v){ ret.push(v); } }); return ret; },
/** * Creates a copy of the passed Array, filtered to contain only unique values. * @param {Array} arr The Array to filter * @return {Array} The new Array containing unique values. */ unique : function(arr){ var ret = [], collect = {}; Ext.each(arr, function(v) { if(!collect[v]){ ret.push(v); } collect[v] = true; }); return ret; },
/** * Recursively flattens into 1-d Array. Injects Arrays inline. * @param {Array} arr The array to flatten * @return {Array} The new, flattened array. */ flatten : function(arr){ var worker = []; function rFlatten(a) { Ext.each(a, function(v) { if(Ext.isArray(v)){ rFlatten(v); }else{ worker.push(v); } }); return worker; } return rFlatten(arr); },
/** * Returns the minimum value in the Array. * @param {Array|NodeList} arr The Array from which to select the minimum value. * @param {Function} comp (optional) a function to perform the comparision which determines minimization. * If omitted the "<" operator will be used. Note: gt = 1; eq = 0; lt = -1 * @return {Object} The minimum value in the Array. */ min : function(arr, comp){ var ret = arr[0]; comp = comp || function(a,b){ return a < b ? -1 : 1; }; Ext.each(arr, function(v) { ret = comp(ret, v) == -1 ? ret : v; }); return ret; },
/** * Returns the maximum value in the Array * @param {Array|NodeList} arr The Array from which to select the maximum value. * @param {Function} comp (optional) a function to perform the comparision which determines maximization. * If omitted the ">" operator will be used. Note: gt = 1; eq = 0; lt = -1 * @return {Object} The maximum value in the Array. */ max : function(arr, comp){ var ret = arr[0]; comp = comp || function(a,b){ return a > b ? 1 : -1; }; Ext.each(arr, function(v) { ret = comp(ret, v) == 1 ? ret : v; }); return ret; },
/** * Calculates the mean of the Array * @param {Array} arr The Array to calculate the mean value of. * @return {Number} The mean. */ mean : function(arr){ return arr.length > 0 ? Ext.sum(arr) / arr.length : undefined; },
/** * Calculates the sum of the Array * @param {Array} arr The Array to calculate the sum value of. * @return {Number} The sum. */ sum : function(arr){ var ret = 0; Ext.each(arr, function(v) { ret += v; }); return ret; },
/** * Partitions the set into two sets: a true set and a false set. * Example: * Example2: *

// Example 1:
Ext.partition([true, false, true, true, false]); // [[true, true, true], [false, false]]

// Example 2:
Ext.partition(
    Ext.query("p"),
    function(val){
        return val.className == "class1"
    }
);
// true are those paragraph elements with a className of "class1",
// false set are those that do not have that className.
         * 
* @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} [true,false] */ partition : function(arr, truth){ var ret = [[],[]]; Ext.each(arr, function(v, i, a) { ret[ (truth && truth(v, i, a)) || (!truth && v) ? 0 : 1].push(v); }); return ret; },
/** * Invokes a method on each item in an Array. *

// Example:
Ext.invoke(Ext.query("p"), "getAttribute", "id");
// [el1.getAttribute("id"), el2.getAttribute("id"), ..., elN.getAttribute("id")]
         * 
* @param {Array|NodeList} arr The Array of items to invoke the method on. * @param {String} methodName The method name to invoke. * @param {...*} args Arguments to send into the method invocation. * @return {Array} The results of invoking the method on each item in the array. */ invoke : function(arr, methodName){ var ret = [], args = Array.prototype.slice.call(arguments, 2); Ext.each(arr, function(v,i) { if (v && typeof v[methodName] == 'function') { ret.push(v[methodName].apply(v, args)); } else { ret.push(undefined); } }); return ret; },
/** * Plucks the value of a property from each item in the Array *

// Example:
Ext.pluck(Ext.query("p"), "className"); // [el1.className, el2.className, ..., elN.className]
         * 
* @param {Array|NodeList} arr The Array of items to pluck the value from. * @param {String} prop The property name to pluck from each element. * @return {Array} The value from each item in the Array. */ pluck : function(arr, prop){ var ret = []; Ext.each(arr, function(v) { ret.push( v[prop] ); }); return ret; },
/** *

Zips N sets together.

*

// Example 1:
Ext.zip([1,2,3],[4,5,6]); // [[1,4],[2,5],[3,6]]
// Example 2:
Ext.zip(
    [ "+", "-", "+"],
    [  12,  10,  22],
    [  43,  15,  96],
    function(a, b, c){
        return "$" + a + "" + b + "." + c
    }
); // ["$+12.43", "$-10.15", "$+22.96"]
         * 
* @param {Arrays|NodeLists} arr This argument may be repeated. Array(s) to contribute values. * @param {Function} zipper (optional) The last item in the argument list. This will drive how the items are zipped together. * @return {Array} The zipped set. */ zip : function(){ var parts = Ext.partition(arguments, function( val ){ return typeof val != 'function'; }), arrs = parts[0], fn = parts[1][0], len = Ext.max(Ext.pluck(arrs, "length")), ret = []; for (var i = 0; i < len; i++) { ret[i] = []; if(fn){ ret[i] = fn.apply(fn, Ext.pluck(arrs, i)); }else{ for (var j = 0, aLen = arrs.length; j < aLen; j++){ ret[i].push( arrs[j][i] ); } } } return ret; },
/** * Turns an array into a sentence, joined by a specified connector - e.g.: * Ext.toSentence(['Adama', 'Tigh', 'Roslin']); //'Adama, Tigh and Roslin' * Ext.toSentence(['Adama', 'Tigh', 'Roslin'], 'or'); //'Adama, Tigh or Roslin' * @param {Array} items The array to create a sentence from * @param {String} connector The string to use to connect the last two words. Usually 'and' or 'or' - defaults to 'and'. * @return {String} The sentence string */ toSentence: function(items, connector) { var length = items.length; if (length <= 1) { return items[0]; } else { var head = items.slice(0, length - 1), tail = items[length - 1]; return Ext.util.Format.format("{0} {1} {2}", head.join(", "), connector || 'and', tail); } },
/** * By default, Ext intelligently decides whether floating elements should be shimmed. If you are using flash, * you may want to set this to true. * @type Boolean */ useShims: Ext.isIE6, // inspired by a similar function in mootools library
/** * Returns the type of object that is passed in. If the object passed in is null or undefined it * return false otherwise it returns one of the following values:
    *
  • string: If the object passed is a string
  • *
  • number: If the object passed is a number
  • *
  • boolean: If the object passed is a boolean value
  • *
  • date: If the object passed is a Date object
  • *
  • function: If the object passed is a function reference
  • *
  • object: If the object passed is an object
  • *
  • array: If the object passed is an array
  • *
  • regexp: If the object passed is a regular expression
  • *
  • element: If the object passed is a DOM Element
  • *
  • nodelist: If the object passed is a DOM NodeList
  • *
  • textnode: If the object passed is a DOM text node and contains something other than whitespace
  • *
  • whitespace: If the object passed is a DOM text node and contains only whitespace
  • *
* @param {Mixed} object * @return {String} */ type : function(o){ if(o === undefined || o === null){ return false; } if(o.htmlElement){ return 'element'; } var t = typeof o; if(t == 'object' && o.nodeName) { switch(o.nodeType) { case 1: return 'element'; case 3: return (/\S/).test(o.nodeValue) ? 'textnode' : 'whitespace'; } } if(t == 'object' || t == 'function') { switch(o.constructor) { case Array: return 'array'; case RegExp: return 'regexp'; case Date: return 'date'; } if(typeof o.length == 'number' && typeof o.item == 'function') { return 'nodelist'; } } return t; } }); })();