X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6e39d509471fe9b4e2660e0d1631b350d0c66f40..HEAD:/ext-all-debug.js
diff --git a/ext-all-debug.js b/ext-all-debug.js
index 1b11a0e9..8fc6dc00 100644
--- a/ext-all-debug.js
+++ b/ext-all-debug.js
@@ -1,44902 +1,93093 @@
/*
- * Ext JS Library 3.1.0
- * Copyright(c) 2006-2009 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-Ext.DomHelper = function(){
- var tempTableEl = null,
- emptyTags = /^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i,
- tableRe = /^table|tbody|tr|td$/i,
- pub,
-
- afterbegin = 'afterbegin',
- afterend = 'afterend',
- beforebegin = 'beforebegin',
- beforeend = 'beforeend',
- ts = '
',
- tbs = ts+'',
- tbe = ''+te,
- trs = tbs + '',
- tre = '
'+tbe;
+This file is part of Ext JS 4
-
- function doInsert(el, o, returnElement, pos, sibling, append){
- var newNode = pub.insertHtml(pos, Ext.getDom(el), createHtml(o));
- return returnElement ? Ext.get(newNode, true) : newNode;
+Copyright (c) 2011 Sencha Inc
+
+Contact: http://www.sencha.com/contact
+
+GNU General Public License Usage
+This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
+
+If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
+
+*/
+
+
+(function() {
+ var global = this,
+ objectPrototype = Object.prototype,
+ toString = objectPrototype.toString,
+ enumerables = true,
+ enumerablesTest = { toString: 1 },
+ i;
+
+ if (typeof Ext === 'undefined') {
+ global.Ext = {};
+ }
+
+ Ext.global = global;
+
+ for (i in enumerablesTest) {
+ enumerables = null;
+ }
+
+ if (enumerables) {
+ enumerables = ['hasOwnProperty', 'valueOf', 'isPrototypeOf', 'propertyIsEnumerable',
+ 'toLocaleString', 'toString', 'constructor'];
}
- function createHtml(o){
- var b = '',
- attr,
- val,
- key,
- keyVal,
- cn;
+ Ext.enumerables = enumerables;
- if(Ext.isString(o)){
- b = o;
- } else if (Ext.isArray(o)) {
- for (var i=0; i < o.length; i++) {
- if(o[i]) {
- b += createHtml(o[i]);
- }
- };
- } else {
- b += '<' + (o.tag = o.tag || 'div');
- Ext.iterate(o, function(attr, val){
- if(!/tag|children|cn|html$/i.test(attr)){
- if (Ext.isObject(val)) {
- b += ' ' + attr + '="';
- Ext.iterate(val, function(key, keyVal){
- b += key + ':' + keyVal + ';';
- });
- b += '"';
- }else{
- b += ' ' + ({cls : 'class', htmlFor : 'for'}[attr] || attr) + '="' + val + '"';
+
+ Ext.apply = function(object, config, defaults) {
+ if (defaults) {
+ Ext.apply(object, defaults);
+ }
+
+ if (object && config && typeof config === 'object') {
+ var i, j, k;
+
+ for (i in config) {
+ object[i] = config[i];
+ }
+
+ if (enumerables) {
+ for (j = enumerables.length; j--;) {
+ k = enumerables[j];
+ if (config.hasOwnProperty(k)) {
+ object[k] = config[k];
}
}
- });
-
- if (emptyTags.test(o.tag)) {
- b += '/>';
- } else {
- b += '>';
- if ((cn = o.children || o.cn)) {
- b += createHtml(cn);
- } else if(o.html){
- b += o.html;
- }
- b += '' + o.tag + '>';
}
}
- return b;
- }
- function ieTable(depth, s, h, e){
- tempTableEl.innerHTML = [s, h, e].join('');
- var i = -1,
- el = tempTableEl,
- ns;
- while(++i < depth){
- el = el.firstChild;
- }
+ return object;
+ };
- if(ns = el.nextSibling){
- var df = document.createDocumentFragment();
- while(el){
- ns = el.nextSibling;
- df.appendChild(el);
- el = ns;
+ Ext.buildSettings = Ext.apply({
+ baseCSSPrefix: 'x-',
+ scopeResetCSS: false
+ }, Ext.buildSettings || {});
+
+ Ext.apply(Ext, {
+
+ emptyFn: function() {},
+
+ baseCSSPrefix: Ext.buildSettings.baseCSSPrefix,
+
+
+ applyIf: function(object, config) {
+ var property;
+
+ if (object) {
+ for (property in config) {
+ if (object[property] === undefined) {
+ object[property] = config[property];
+ }
+ }
}
- el = df;
- }
- return el;
- }
-
- function insertIntoTable(tag, where, el, html) {
- var node,
- before;
+ return object;
+ },
- tempTableEl = tempTableEl || document.createElement('div');
+
+ iterate: function(object, fn, scope) {
+ if (Ext.isEmpty(object)) {
+ return;
+ }
- if(tag == 'td' && (where == afterbegin || where == beforeend) ||
- !/td|tr|tbody/i.test(tag) && (where == beforebegin || where == afterend)) {
- return;
- }
- before = where == beforebegin ? el :
- where == afterend ? el.nextSibling :
- where == afterbegin ? el.firstChild : null;
+ if (scope === undefined) {
+ scope = object;
+ }
- if (where == beforebegin || where == afterend) {
- el = el.parentNode;
+ if (Ext.isIterable(object)) {
+ Ext.Array.each.call(Ext.Array, object, fn, scope);
+ }
+ else {
+ Ext.Object.each.call(Ext.Object, object, fn, scope);
+ }
}
+ });
- if (tag == 'td' || (tag == 'tr' && (where == beforeend || where == afterbegin))) {
- node = ieTable(4, trs, html, tre);
- } else if ((tag == 'tbody' && (where == beforeend || where == afterbegin)) ||
- (tag == 'tr' && (where == beforebegin || where == afterend))) {
- node = ieTable(3, tbs, html, tbe);
- } else {
- node = ieTable(2, ts, html, te);
+ Ext.apply(Ext, {
+
+
+ extend: function() {
+
+ var objectConstructor = objectPrototype.constructor,
+ inlineOverrides = function(o) {
+ for (var m in o) {
+ if (!o.hasOwnProperty(m)) {
+ continue;
+ }
+ this[m] = o[m];
+ }
+ };
+
+ return function(subclass, superclass, overrides) {
+
+ if (Ext.isObject(superclass)) {
+ overrides = superclass;
+ superclass = subclass;
+ subclass = overrides.constructor !== objectConstructor ? overrides.constructor : function() {
+ superclass.apply(this, arguments);
+ };
+ }
+
+
+
+ var F = function() {},
+ subclassProto, superclassProto = superclass.prototype;
+
+ F.prototype = superclassProto;
+ subclassProto = subclass.prototype = new F();
+ subclassProto.constructor = subclass;
+ subclass.superclass = superclassProto;
+
+ if (superclassProto.constructor === objectConstructor) {
+ superclassProto.constructor = superclass;
+ }
+
+ subclass.override = function(overrides) {
+ Ext.override(subclass, overrides);
+ };
+
+ subclassProto.override = inlineOverrides;
+ subclassProto.proto = subclassProto;
+
+ subclass.override(overrides);
+ subclass.extend = function(o) {
+ return Ext.extend(subclass, o);
+ };
+
+ return subclass;
+ };
+ }(),
+
+
+ override: function(cls, overrides) {
+ if (cls.prototype.$className) {
+ return cls.override(overrides);
+ }
+ else {
+ Ext.apply(cls.prototype, overrides);
+ }
}
- el.insertBefore(node, before);
- return node;
- }
+ });
+
+ Ext.apply(Ext, {
- pub = {
- markup : function(o){
- return createHtml(o);
+ valueFrom: function(value, defaultValue, allowBlank){
+ return Ext.isEmpty(value, allowBlank) ? defaultValue : value;
},
+
-
- applyStyles : function(el, styles){
- if(styles){
- var i = 0,
- len,
- style;
+ typeOf: function(value) {
+ if (value === null) {
+ return 'null';
+ }
- el = Ext.fly(el);
- if(Ext.isFunction(styles)){
- styles = styles.call();
- }
- if(Ext.isString(styles)){
- styles = styles.trim().split(/\s*(?::|;)\s*/);
- for(len = styles.length; i < len;){
- el.setStyle(styles[i++], styles[i++]);
+ var type = typeof value;
+
+ if (type === 'undefined' || type === 'string' || type === 'number' || type === 'boolean') {
+ return type;
+ }
+
+ var typeToString = toString.call(value);
+
+ switch(typeToString) {
+ case '[object Array]':
+ return 'array';
+ case '[object Date]':
+ return 'date';
+ case '[object Boolean]':
+ return 'boolean';
+ case '[object Number]':
+ return 'number';
+ case '[object RegExp]':
+ return 'regexp';
+ }
+
+ if (type === 'function') {
+ return 'function';
+ }
+
+ if (type === 'object') {
+ if (value.nodeType !== undefined) {
+ if (value.nodeType === 3) {
+ return (/\S/).test(value.nodeValue) ? 'textnode' : 'whitespace';
+ }
+ else {
+ return 'element';
}
- }else if (Ext.isObject(styles)){
- el.setStyle(styles);
}
+
+ return 'object';
}
+
},
- insertHtml : function(where, el, html){
- var hash = {},
- hashVal,
- setStart,
- range,
- frag,
- rangeEl,
- rs;
+ isEmpty: function(value, allowEmptyString) {
+ return (value === null) || (value === undefined) || (!allowEmptyString ? value === '' : false) || (Ext.isArray(value) && value.length === 0);
+ },
- where = where.toLowerCase();
+
+ isArray: ('isArray' in Array) ? Array.isArray : function(value) {
+ return toString.call(value) === '[object Array]';
+ },
+
+
+ isDate: function(value) {
+ return toString.call(value) === '[object Date]';
+ },
+
+
+ isObject: (toString.call(null) === '[object Object]') ?
+ function(value) {
- hash[beforebegin] = ['BeforeBegin', 'previousSibling'];
- hash[afterend] = ['AfterEnd', 'nextSibling'];
+ return value !== null && value !== undefined && toString.call(value) === '[object Object]' && value.ownerDocument === undefined;
+ } :
+ function(value) {
+ return toString.call(value) === '[object Object]';
+ },
- if (el.insertAdjacentHTML) {
- if(tableRe.test(el.tagName) && (rs = insertIntoTable(el.tagName.toLowerCase(), where, el, html))){
- return rs;
+
+ isPrimitive: function(value) {
+ var type = typeof value;
+
+ return type === 'string' || type === 'number' || type === 'boolean';
+ },
+
+
+ isFunction:
+
+
+ (typeof document !== 'undefined' && typeof document.getElementsByTagName('body') === 'function') ? function(value) {
+ return toString.call(value) === '[object Function]';
+ } : function(value) {
+ return typeof value === 'function';
+ },
+
+
+ isNumber: function(value) {
+ return typeof value === 'number' && isFinite(value);
+ },
+
+
+ isNumeric: function(value) {
+ return !isNaN(parseFloat(value)) && isFinite(value);
+ },
+
+
+ isString: function(value) {
+ return typeof value === 'string';
+ },
+
+
+ isBoolean: function(value) {
+ return typeof value === 'boolean';
+ },
+
+
+ isElement: function(value) {
+ return value ? value.nodeType === 1 : false;
+ },
+
+
+ isTextNode: function(value) {
+ return value ? value.nodeName === "#text" : false;
+ },
+
+
+ isDefined: function(value) {
+ return typeof value !== 'undefined';
+ },
+
+
+ isIterable: function(value) {
+ return (value && typeof value !== 'string') ? value.length !== undefined : false;
+ }
+ });
+
+ Ext.apply(Ext, {
+
+
+ clone: function(item) {
+ if (item === null || item === undefined) {
+ return item;
+ }
+
+
+
+
+ if (item.nodeType && item.cloneNode) {
+ return item.cloneNode(true);
+ }
+
+ var type = toString.call(item);
+
+
+ if (type === '[object Date]') {
+ return new Date(item.getTime());
+ }
+
+ var i, j, k, clone, key;
+
+
+ if (type === '[object Array]') {
+ i = item.length;
+
+ clone = [];
+
+ while (i--) {
+ clone[i] = Ext.clone(item[i]);
}
-
- hash[afterbegin] = ['AfterBegin', 'firstChild'];
- hash[beforeend] = ['BeforeEnd', 'lastChild'];
- if ((hashVal = hash[where])) {
- el.insertAdjacentHTML(hashVal[0], html);
- return el[hashVal[1]];
+ }
+
+ else if (type === '[object Object]' && item.constructor === Object) {
+ clone = {};
+
+ for (key in item) {
+ clone[key] = Ext.clone(item[key]);
}
- } else {
- range = el.ownerDocument.createRange();
- setStart = 'setStart' + (/end/i.test(where) ? 'After' : 'Before');
- if (hash[where]) {
- range[setStart](el);
- frag = range.createContextualFragment(html);
- el.parentNode.insertBefore(frag, where == beforebegin ? el : el.nextSibling);
- return el[(where == beforebegin ? 'previous' : 'next') + 'Sibling'];
- } else {
- rangeEl = (where == afterbegin ? 'first' : 'last') + 'Child';
- if (el.firstChild) {
- range[setStart](el[rangeEl]);
- frag = range.createContextualFragment(html);
- if(where == afterbegin){
- el.insertBefore(frag, el.firstChild);
- }else{
- el.appendChild(frag);
- }
- } else {
- el.innerHTML = html;
+
+ if (enumerables) {
+ for (j = enumerables.length; j--;) {
+ k = enumerables[j];
+ clone[k] = item[k];
}
- return el[rangeEl];
}
}
- throw 'Illegal insertion point -> "' + where + '"';
+
+ return clone || item;
},
- insertBefore : function(el, o, returnElement){
- return doInsert(el, o, returnElement, beforebegin);
+ getUniqueGlobalNamespace: function() {
+ var uniqueGlobalNamespace = this.uniqueGlobalNamespace;
+
+ if (uniqueGlobalNamespace === undefined) {
+ var i = 0;
+
+ do {
+ uniqueGlobalNamespace = 'ExtBox' + (++i);
+ } while (Ext.global[uniqueGlobalNamespace] !== undefined);
+
+ Ext.global[uniqueGlobalNamespace] = Ext;
+ this.uniqueGlobalNamespace = uniqueGlobalNamespace;
+ }
+
+ return uniqueGlobalNamespace;
},
- insertAfter : function(el, o, returnElement){
- return doInsert(el, o, returnElement, afterend, 'nextSibling');
+ functionFactory: function() {
+ var args = Array.prototype.slice.call(arguments);
+
+ if (args.length > 0) {
+ args[args.length - 1] = 'var Ext=window.' + this.getUniqueGlobalNamespace() + ';' +
+ args[args.length - 1];
+ }
+
+ return Function.prototype.constructor.apply(Function.prototype, args);
+ }
+ });
+
+
+ Ext.type = Ext.typeOf;
+
+})();
+
+
+(function() {
+
+
+var version = '4.0.7', Version;
+ Ext.Version = Version = Ext.extend(Object, {
+
+
+ constructor: function(version) {
+ var parts, releaseStartIndex;
+
+ if (version instanceof Version) {
+ return version;
+ }
+
+ this.version = this.shortVersion = String(version).toLowerCase().replace(/_/g, '.').replace(/[\-+]/g, '');
+
+ releaseStartIndex = this.version.search(/([^\d\.])/);
+
+ if (releaseStartIndex !== -1) {
+ this.release = this.version.substr(releaseStartIndex, version.length);
+ this.shortVersion = this.version.substr(0, releaseStartIndex);
+ }
+
+ this.shortVersion = this.shortVersion.replace(/[^\d]/g, '');
+
+ parts = this.version.split('.');
+
+ this.major = parseInt(parts.shift() || 0, 10);
+ this.minor = parseInt(parts.shift() || 0, 10);
+ this.patch = parseInt(parts.shift() || 0, 10);
+ this.build = parseInt(parts.shift() || 0, 10);
+
+ return this;
},
- insertFirst : function(el, o, returnElement){
- return doInsert(el, o, returnElement, afterbegin, 'firstChild');
+ toString: function() {
+ return this.version;
},
- append : function(el, o, returnElement){
- return doInsert(el, o, returnElement, beforeend, '', true);
+ valueOf: function() {
+ return this.version;
},
- overwrite : function(el, o, returnElement){
- el = Ext.getDom(el);
- el.innerHTML = createHtml(o);
- return returnElement ? Ext.get(el.firstChild) : el.firstChild;
+ getMajor: function() {
+ return this.major || 0;
},
- createHtml : createHtml
- };
- return pub;
-}();
-Ext.apply(Ext.DomHelper,
-function(){
- var pub,
- afterbegin = 'afterbegin',
- afterend = 'afterend',
- beforebegin = 'beforebegin',
- beforeend = 'beforeend';
-
-
- function doInsert(el, o, returnElement, pos, sibling, append){
- el = Ext.getDom(el);
- var newNode;
- if (pub.useDom) {
- newNode = createDom(o, null);
- if (append) {
- el.appendChild(newNode);
- } else {
- (sibling == 'firstChild' ? el : el.parentNode).insertBefore(newNode, el[sibling] || el);
- }
- } else {
- newNode = Ext.DomHelper.insertHtml(pos, el, Ext.DomHelper.createHtml(o));
+
+ getMinor: function() {
+ return this.minor || 0;
+ },
+
+
+ getPatch: function() {
+ return this.patch || 0;
+ },
+
+
+ getBuild: function() {
+ return this.build || 0;
+ },
+
+
+ getRelease: function() {
+ return this.release || '';
+ },
+
+
+ isGreaterThan: function(target) {
+ return Version.compare(this.version, target) === 1;
+ },
+
+
+ isLessThan: function(target) {
+ return Version.compare(this.version, target) === -1;
+ },
+
+
+ equals: function(target) {
+ return Version.compare(this.version, target) === 0;
+ },
+
+
+ match: function(target) {
+ target = String(target);
+ return this.version.substr(0, target.length) === target;
+ },
+
+
+ toArray: function() {
+ return [this.getMajor(), this.getMinor(), this.getPatch(), this.getBuild(), this.getRelease()];
+ },
+
+
+ getShortVersion: function() {
+ return this.shortVersion;
}
- return returnElement ? Ext.get(newNode, true) : newNode;
- }
+ });
-
-
- function createDom(o, parentNode){
- var el,
- doc = document,
- useSet,
- attr,
- val,
- cn;
+ Ext.apply(Version, {
+
+ releaseValueMap: {
+ 'dev': -6,
+ 'alpha': -5,
+ 'a': -5,
+ 'beta': -4,
+ 'b': -4,
+ 'rc': -3,
+ '#': -2,
+ 'p': -1,
+ 'pl': -1
+ },
- if (Ext.isArray(o)) {
- el = doc.createDocumentFragment();
- Ext.each(o, function(v) {
- createDom(v, el);
- });
- } else if (Ext.isString(o)) {
- el = doc.createTextNode(o);
- } else {
- el = doc.createElement( o.tag || 'div' );
- useSet = !!el.setAttribute;
- Ext.iterate(o, function(attr, val){
- if(!/tag|children|cn|html|style/.test(attr)){
- if(attr == 'cls'){
- el.className = val;
- }else{
- if(useSet){
- el.setAttribute(attr, val);
- }else{
- el[attr] = val;
- }
- }
- }
- });
- Ext.DomHelper.applyStyles(el, o.style);
+
+ getComponentValue: function(value) {
+ return !value ? 0 : (isNaN(value) ? this.releaseValueMap[value] || value : parseInt(value, 10));
+ },
- if ((cn = o.children || o.cn)) {
- createDom(cn, el);
- } else if (o.html) {
- el.innerHTML = o.html;
+
+ compare: function(current, target) {
+ var currentValue, targetValue, i;
+
+ current = new Version(current).toArray();
+ target = new Version(target).toArray();
+
+ for (i = 0; i < Math.max(current.length, target.length); i++) {
+ currentValue = this.getComponentValue(current[i]);
+ targetValue = this.getComponentValue(target[i]);
+
+ if (currentValue < targetValue) {
+ return -1;
+ } else if (currentValue > targetValue) {
+ return 1;
+ }
}
+
+ return 0;
}
- if(parentNode){
- parentNode.appendChild(el);
- }
- return el;
- }
+ });
- pub = {
-
- createTemplate : function(o){
- var html = Ext.DomHelper.createHtml(o);
- return new Ext.Template(html);
- },
+ Ext.apply(Ext, {
+
+ versions: {},
-
- useDom : false,
+
+ lastRegisteredVersion: null,
-
- insertBefore : function(el, o, returnElement){
- return doInsert(el, o, returnElement, beforebegin);
- },
+
+ setVersion: function(packageName, version) {
+ Ext.versions[packageName] = new Version(version);
+ Ext.lastRegisteredVersion = Ext.versions[packageName];
-
- insertAfter : function(el, o, returnElement){
- return doInsert(el, o, returnElement, afterend, 'nextSibling');
- },
+ return this;
+ },
-
- insertFirst : function(el, o, returnElement){
- return doInsert(el, o, returnElement, afterbegin, 'firstChild');
- },
+
+ getVersion: function(packageName) {
+ if (packageName === undefined) {
+ return Ext.lastRegisteredVersion;
+ }
-
- append: function(el, o, returnElement){
- return doInsert(el, o, returnElement, beforeend, '', true);
+ return Ext.versions[packageName];
},
-
- createDom: createDom
- };
- return pub;
-}());
-Ext.Template = function(html){
- var me = this,
- a = arguments,
- buf = [];
-
- if (Ext.isArray(html)) {
- html = html.join("");
- } else if (a.length > 1) {
- Ext.each(a, function(v) {
- if (Ext.isObject(v)) {
- Ext.apply(me, v);
- } else {
- buf.push(v);
+
+ deprecate: function(packageName, since, closure, scope) {
+ if (Version.compare(Ext.getVersion(packageName), since) < 1) {
+ closure.call(scope);
}
- });
- html = buf.join('');
- }
+ }
+ });
-
- me.html = html;
-
- if (me.compiled) {
- me.compile();
- }
-};
-Ext.Template.prototype = {
-
- re : /\{([\w-]+)\}/g,
-
+ Ext.setVersion('core', version);
+
+})();
+
+
+
+Ext.String = {
+ trimRegex: /^[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000]+|[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000]+$/g,
+ escapeRe: /('|\\)/g,
+ formatRe: /\{(\d+)\}/g,
+ escapeRegexRe: /([-.*+?^${}()|[\]\/\\])/g,
+
+ /**
+ * Convert certain characters (&, <, >, and ") to their HTML character equivalents for literal display in web pages.
+ * @param {String} value The string to encode
+ * @return {String} The encoded text
+ * @method
+ */
+ htmlEncode: (function() {
+ var entities = {
+ '&': '&',
+ '>': '>',
+ '<': '<',
+ '"': '"'
+ }, keys = [], p, regex;
+
+ for (p in entities) {
+ keys.push(p);
+ }
+
+ regex = new RegExp('(' + keys.join('|') + ')', 'g');
+
+ return function(value) {
+ return (!value) ? value : String(value).replace(regex, function(match, capture) {
+ return entities[capture];
+ });
+ };
+ })(),
+
+ /**
+ * Convert certain characters (&, <, >, and ") from their HTML character equivalents.
+ * @param {String} value The string to decode
+ * @return {String} The decoded text
+ * @method
+ */
+ htmlDecode: (function() {
+ var entities = {
+ '&': '&',
+ '>': '>',
+ '<': '<',
+ '"': '"'
+ }, keys = [], p, regex;
+
+ for (p in entities) {
+ keys.push(p);
+ }
+
+ regex = new RegExp('(' + keys.join('|') + '|[0-9]{1,5};' + ')', 'g');
+
+ return function(value) {
+ return (!value) ? value : String(value).replace(regex, function(match, capture) {
+ if (capture in entities) {
+ return entities[capture];
+ } else {
+ return String.fromCharCode(parseInt(capture.substr(2), 10));
+ }
+ });
+ };
+ })(),
- applyTemplate : function(values){
- var me = this;
+ urlAppend : function(url, string) {
+ if (!Ext.isEmpty(string)) {
+ return url + (url.indexOf('?') === -1 ? '?' : '&') + string;
+ }
- return me.compiled ?
- me.compiled(values) :
- me.html.replace(me.re, function(m, name){
- return values[name] !== undefined ? values[name] : "";
- });
- },
+ return url;
+ },
- set : function(html, compile){
- var me = this;
- me.html = html;
- me.compiled = null;
- return compile ? me.compile() : me;
+ trim: function(string) {
+ return string.replace(Ext.String.trimRegex, "");
},
- compile : function(){
- var me = this,
- sep = Ext.isGecko ? "+" : ",";
+ capitalize: function(string) {
+ return string.charAt(0).toUpperCase() + string.substr(1);
+ },
- function fn(m, name){
- name = "values['" + name + "']";
- return "'"+ sep + '(' + name + " == undefined ? '' : " + name + ')' + sep + "'";
+
+ ellipsis: function(value, len, word) {
+ if (value && value.length > len) {
+ if (word) {
+ var vs = value.substr(0, len - 2),
+ index = Math.max(vs.lastIndexOf(' '), vs.lastIndexOf('.'), vs.lastIndexOf('!'), vs.lastIndexOf('?'));
+ if (index !== -1 && index >= (len - 15)) {
+ return vs.substr(0, index) + "...";
+ }
+ }
+ return value.substr(0, len - 3) + "...";
}
-
- eval("this.compiled = function(values){ return " + (Ext.isGecko ? "'" : "['") +
- me.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn) +
- (Ext.isGecko ? "';};" : "'].join('');};"));
- return me;
+ return value;
},
- insertFirst: function(el, values, returnElement){
- return this.doInsert('afterBegin', el, values, returnElement);
+ escapeRegex: function(string) {
+ return string.replace(Ext.String.escapeRegexRe, "\\$1");
},
- insertBefore: function(el, values, returnElement){
- return this.doInsert('beforeBegin', el, values, returnElement);
+ escape: function(string) {
+ return string.replace(Ext.String.escapeRe, "\\$1");
},
- insertAfter : function(el, values, returnElement){
- return this.doInsert('afterEnd', el, values, returnElement);
+ toggle: function(string, value, other) {
+ return string === value ? other : value;
},
- append : function(el, values, returnElement){
- return this.doInsert('beforeEnd', el, values, returnElement);
+ leftPad: function(string, size, character) {
+ var result = String(string);
+ character = character || " ";
+ while (result.length < size) {
+ result = character + result;
+ }
+ return result;
},
- doInsert : function(where, el, values, returnEl){
- el = Ext.getDom(el);
- var newNode = Ext.DomHelper.insertHtml(where, el, this.applyTemplate(values));
- return returnEl ? Ext.get(newNode, true) : newNode;
+
+ format: function(format) {
+ var args = Ext.Array.toArray(arguments, 1);
+ return format.replace(Ext.String.formatRe, function(m, i) {
+ return args[i];
+ });
},
- overwrite : function(el, values, returnElement){
- el = Ext.getDom(el);
- el.innerHTML = this.applyTemplate(values);
- return returnElement ? Ext.get(el.firstChild, true) : el.firstChild;
+ repeat: function(pattern, count, sep) {
+ for (var buf = [], i = count; i--; ) {
+ buf.push(pattern);
+ }
+ return buf.join(sep || '');
}
};
-Ext.Template.prototype.apply = Ext.Template.prototype.applyTemplate;
-Ext.Template.from = function(el, config){
- el = Ext.getDom(el);
- return new Ext.Template(el.value || el.innerHTML, config || '');
-};
-Ext.apply(Ext.Template.prototype, {
-
- disableFormats : false,
-
+(function() {
+var isToFixedBroken = (0.9).toFixed() !== '1';
+
+Ext.Number = {
- re : /\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,
+ constrain: function(number, min, max) {
+ number = parseFloat(number);
+
+ if (!isNaN(min)) {
+ number = Math.max(number, min);
+ }
+ if (!isNaN(max)) {
+ number = Math.min(number, max);
+ }
+ return number;
+ },
- applyTemplate : function(values){
- var me = this,
- useF = me.disableFormats !== true,
- fm = Ext.util.Format,
- tpl = me;
-
- if(me.compiled){
- return me.compiled(values);
+ snap : function(value, increment, minValue, maxValue) {
+ var newValue = value,
+ m;
+
+ if (!(increment && value)) {
+ return value;
}
- function fn(m, name, format, args){
- if (format && useF) {
- if (format.substr(0, 5) == "this.") {
- return tpl.call(format.substr(5), values[name], values);
- } else {
- if (args) {
-
-
-
- var re = /^\s*['"](.*)["']\s*$/;
- args = args.split(',');
- for(var i = 0, len = args.length; i < len; i++){
- args[i] = args[i].replace(re, "$1");
- }
- args = [values[name]].concat(args);
- } else {
- args = [values[name]];
- }
- return fm[format].apply(fm, args);
- }
- } else {
- return values[name] !== undefined ? values[name] : "";
+ m = value % increment;
+ if (m !== 0) {
+ newValue -= m;
+ if (m * 2 >= increment) {
+ newValue += increment;
+ } else if (m * 2 < -increment) {
+ newValue -= increment;
}
}
- return me.html.replace(me.re, fn);
+ return Ext.Number.constrain(newValue, minValue, maxValue);
},
-
+
- compile : function(){
- var me = this,
- fm = Ext.util.Format,
- useF = me.disableFormats !== true,
- sep = Ext.isGecko ? "+" : ",",
- body;
-
- function fn(m, name, format, args){
- if(format && useF){
- args = args ? ',' + args : "";
- if(format.substr(0, 5) != "this."){
- format = "fm." + format + '(';
- }else{
- format = 'this.call("'+ format.substr(5) + '", ';
- args = ", values";
- }
- }else{
- args= ''; format = "(values['" + name + "'] == undefined ? '' : ";
- }
- return "'"+ sep + format + "values['" + name + "']" + args + ")"+sep+"'";
- }
-
-
- if(Ext.isGecko){
- body = "this.compiled = function(values){ return '" +
- me.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn) +
- "';};";
- }else{
- body = ["this.compiled = function(values){ return ['"];
- body.push(me.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn));
- body.push("'].join('');};");
- body = body.join('');
+ toFixed: function(value, precision) {
+ if (isToFixedBroken) {
+ precision = precision || 0;
+ var pow = Math.pow(10, precision);
+ return (Math.round(value * pow) / pow).toFixed(precision);
}
- eval(body);
- return me;
+
+ return value.toFixed(precision);
},
+
-
- call : function(fnName, value, allValues){
- return this[fnName](value, allValues);
+ from: function(value, defaultValue) {
+ if (isFinite(value)) {
+ value = parseFloat(value);
+ }
+
+ return !isNaN(value) ? value : defaultValue;
}
-});
-Ext.Template.prototype.apply = Ext.Template.prototype.applyTemplate;
+};
-Ext.DomQuery = function(){
- var cache = {},
- simpleCache = {},
- valueCache = {},
- nonSpace = /\S/,
- trimRe = /^\s+|\s+$/g,
- tplRe = /\{(\d+)\}/g,
- modeRe = /^(\s?[\/>+~]\s?|\s|$)/,
- tagTokenRe = /^(#)?([\w-\*]+)/,
- nthRe = /(\d*)n\+?(\d*)/,
- nthRe2 = /\D/,
-
-
-
- isIE = window.ActiveXObject ? true : false,
- key = 30803;
-
-
-
- eval("var batch = 30803;");
+})();
- function child(p, index){
- var i = 0,
- n = p.firstChild;
- while(n){
- if(n.nodeType == 1){
- if(++i == index){
- return n;
- }
+
+Ext.num = function() {
+ return Ext.Number.from.apply(this, arguments);
+};
+
+(function() {
+
+ var arrayPrototype = Array.prototype,
+ slice = arrayPrototype.slice,
+ supportsSplice = function () {
+ var array = [],
+ lengthBefore,
+ j = 20;
+
+ if (!array.splice) {
+ return false;
}
- n = n.nextSibling;
- }
- return null;
- };
- function next(n){
- while((n = n.nextSibling) && n.nodeType != 1);
- return n;
- };
+
+
- function prev(n){
- while((n = n.previousSibling) && n.nodeType != 1);
- return n;
- };
+ while (j--) {
+ array.push("A");
+ }
+
+ array.splice(15, 0, "F", "F", "F", "F", "F","F","F","F","F","F","F","F","F","F","F","F","F","F","F","F","F");
+
+ lengthBefore = array.length;
+ array.splice(13, 0, "XXX");
- function children(d){
- var n = d.firstChild, ni = -1,
- nx;
- while(n){
- nx = n.nextSibling;
- if(n.nodeType == 3 && !nonSpace.test(n.nodeValue)){
- d.removeChild(n);
- }else{
- n.nodeIndex = ++ni;
- }
- n = nx;
- }
- return this;
- };
-
- function byClassName(c, a, v){
- if(!v){
- return c;
- }
- var r = [], ri = -1, cn;
- for(var i = 0, ci; ci = c[i]; i++){
- if((' '+ci.className+' ').indexOf(v) != -1){
- r[++ri] = ci;
+ if (lengthBefore+1 != array.length) {
+ return false;
}
- }
- return r;
- };
+
- function attrValue(n, attr){
- if(!n.tagName && typeof n.length != "undefined"){
- n = n[0];
- }
- if(!n){
- return null;
- }
- if(attr == "for"){
- return n.htmlFor;
- }
- if(attr == "class" || attr == "className"){
- return n.className;
+ return true;
+ }(),
+ supportsForEach = 'forEach' in arrayPrototype,
+ supportsMap = 'map' in arrayPrototype,
+ supportsIndexOf = 'indexOf' in arrayPrototype,
+ supportsEvery = 'every' in arrayPrototype,
+ supportsSome = 'some' in arrayPrototype,
+ supportsFilter = 'filter' in arrayPrototype,
+ supportsSort = function() {
+ var a = [1,2,3,4,5].sort(function(){ return 0; });
+ return a[0] === 1 && a[1] === 2 && a[2] === 3 && a[3] === 4 && a[4] === 5;
+ }(),
+ supportsSliceOnNodeList = true,
+ ExtArray;
+
+ try {
+
+ if (typeof document !== 'undefined') {
+ slice.call(document.getElementsByTagName('body'));
}
- return n.getAttribute(attr) || n[attr];
+ } catch (e) {
+ supportsSliceOnNodeList = false;
+ }
- };
+ function fixArrayIndex (array, index) {
+ return (index < 0) ? Math.max(0, array.length + index)
+ : Math.min(array.length, index);
+ }
- function getNodes(ns, mode, tagName){
- var result = [], ri = -1, cs;
- if(!ns){
- return result;
- }
- tagName = tagName || "*";
- if(typeof ns.getElementsByTagName != "undefined"){
- ns = [ns];
- }
- if(!mode){
- for(var i = 0, ni; ni = ns[i]; i++){
- cs = ni.getElementsByTagName(tagName);
- for(var j = 0, ci; ci = cs[j]; j++){
- result[++ri] = ci;
- }
+
+ function replaceSim (array, index, removeCount, insert) {
+ var add = insert ? insert.length : 0,
+ length = array.length,
+ pos = fixArrayIndex(array, index);
+
+
+ if (pos === length) {
+ if (add) {
+ array.push.apply(array, insert);
}
- }else if(mode == "/" || mode == ">"){
- var utag = tagName.toUpperCase();
- for(var i = 0, ni, cn; ni = ns[i]; i++){
- cn = ni.childNodes;
- for(var j = 0, cj; cj = cn[j]; j++){
- if(cj.nodeName == utag || cj.nodeName == tagName || tagName == '*'){
- result[++ri] = cj;
- }
+ } else {
+ var remove = Math.min(removeCount, length - pos),
+ tailOldPos = pos + remove,
+ tailNewPos = tailOldPos + add - remove,
+ tailCount = length - tailOldPos,
+ lengthAfterRemove = length - remove,
+ i;
+
+ if (tailNewPos < tailOldPos) {
+ for (i = 0; i < tailCount; ++i) {
+ array[tailNewPos+i] = array[tailOldPos+i];
}
- }
- }else if(mode == "+"){
- var utag = tagName.toUpperCase();
- for(var i = 0, n; n = ns[i]; i++){
- while((n = n.nextSibling) && n.nodeType != 1);
- if(n && (n.nodeName == utag || n.nodeName == tagName || tagName == '*')){
- result[++ri] = n;
+ } else if (tailNewPos > tailOldPos) {
+ for (i = tailCount; i--; ) {
+ array[tailNewPos+i] = array[tailOldPos+i];
}
- }
- }else if(mode == "~"){
- var utag = tagName.toUpperCase();
- for(var i = 0, n; n = ns[i]; i++){
- while((n = n.nextSibling)){
- if (n.nodeName == utag || n.nodeName == tagName || tagName == '*'){
- result[++ri] = n;
- }
+ }
+
+ if (add && pos === lengthAfterRemove) {
+ array.length = lengthAfterRemove;
+ array.push.apply(array, insert);
+ } else {
+ array.length = lengthAfterRemove + add;
+ for (i = 0; i < add; ++i) {
+ array[pos+i] = insert[i];
}
}
}
- return result;
- };
- function concat(a, b){
- if(b.slice){
- return a.concat(b);
- }
- for(var i = 0, l = b.length; i < l; i++){
- a[a.length] = b[i];
- }
- return a;
+ return array;
}
- function byTag(cs, tagName){
- if(cs.tagName || cs == document){
- cs = [cs];
- }
- if(!tagName){
- return cs;
- }
- var r = [], ri = -1;
- tagName = tagName.toLowerCase();
- for(var i = 0, ci; ci = cs[i]; i++){
- if(ci.nodeType == 1 && ci.tagName.toLowerCase()==tagName){
- r[++ri] = ci;
+ function replaceNative (array, index, removeCount, insert) {
+ if (insert && insert.length) {
+ if (index < array.length) {
+ array.splice.apply(array, [index, removeCount].concat(insert));
+ } else {
+ array.push.apply(array, insert);
}
+ } else {
+ array.splice(index, removeCount);
}
- return r;
- };
+ return array;
+ }
- function byId(cs, attr, id){
- if(cs.tagName || cs == document){
- cs = [cs];
- }
- if(!id){
- return cs;
+ function eraseSim (array, index, removeCount) {
+ return replaceSim(array, index, removeCount);
+ }
+
+ function eraseNative (array, index, removeCount) {
+ array.splice(index, removeCount);
+ return array;
+ }
+
+ function spliceSim (array, index, removeCount) {
+ var pos = fixArrayIndex(array, index),
+ removed = array.slice(index, fixArrayIndex(array, pos+removeCount));
+
+ if (arguments.length < 4) {
+ replaceSim(array, pos, removeCount);
+ } else {
+ replaceSim(array, pos, removeCount, slice.call(arguments, 3));
}
- var r = [], ri = -1;
- for(var i = 0,ci; ci = cs[i]; i++){
- if(ci && ci.id == id){
- r[++ri] = ci;
- return r;
+
+ return removed;
+ }
+
+ function spliceNative (array) {
+ return array.splice.apply(array, slice.call(arguments, 1));
+ }
+
+ var erase = supportsSplice ? eraseNative : eraseSim,
+ replace = supportsSplice ? replaceNative : replaceSim,
+ splice = supportsSplice ? spliceNative : spliceSim;
+
+
+
+ ExtArray = Ext.Array = {
+
+ each: function(array, fn, scope, reverse) {
+ array = ExtArray.from(array);
+
+ var i,
+ ln = array.length;
+
+ if (reverse !== true) {
+ for (i = 0; i < ln; i++) {
+ if (fn.call(scope || array[i], array[i], i, array) === false) {
+ return i;
+ }
+ }
+ }
+ else {
+ for (i = ln - 1; i > -1; i--) {
+ if (fn.call(scope || array[i], array[i], i, array) === false) {
+ return i;
+ }
+ }
}
- }
- return r;
- };
- function byAttribute(cs, attr, value, op, custom){
- var r = [],
- ri = -1,
- st = custom=="{",
- f = Ext.DomQuery.operators[op];
- for(var i = 0, ci; ci = cs[i]; i++){
- if(ci.nodeType != 1){
- continue;
+ return true;
+ },
+
+
+ forEach: function(array, fn, scope) {
+ if (supportsForEach) {
+ return array.forEach(fn, scope);
}
- var a;
- if(st){
- a = Ext.DomQuery.getStyle(ci, attr);
+
+ var i = 0,
+ ln = array.length;
+
+ for (; i < ln; i++) {
+ fn.call(scope, array[i], i, array);
}
- else if(attr == "class" || attr == "className"){
- a = ci.className;
- }else if(attr == "for"){
- a = ci.htmlFor;
- }else if(attr == "href"){
- a = ci.getAttribute("href", 2);
- }else{
- a = ci.getAttribute(attr);
+ },
+
+
+ indexOf: function(array, item, from) {
+ if (supportsIndexOf) {
+ return array.indexOf(item, from);
}
- if((f && f(a, value)) || (!f && a)){
- r[++ri] = ci;
+
+ var i, length = array.length;
+
+ for (i = (from < 0) ? Math.max(0, length + from) : from || 0; i < length; i++) {
+ if (array[i] === item) {
+ return i;
+ }
}
- }
- return r;
- };
- function byPseudo(cs, name, value){
- return Ext.DomQuery.pseudos[name](cs, value);
- };
+ return -1;
+ },
- function nodupIEXml(cs){
- var d = ++key,
- r;
- cs[0].setAttribute("_nodup", d);
- r = [cs[0]];
- for(var i = 1, len = cs.length; i < len; i++){
- var c = cs[i];
- if(!c.getAttribute("_nodup") != d){
- c.setAttribute("_nodup", d);
- r[r.length] = c;
+
+ contains: function(array, item) {
+ if (supportsIndexOf) {
+ return array.indexOf(item) !== -1;
}
- }
- for(var i = 0, len = cs.length; i < len; i++){
- cs[i].removeAttribute("_nodup");
- }
- return r;
- }
- function nodup(cs){
- if(!cs){
- return [];
- }
- var len = cs.length, c, i, r = cs, cj, ri = -1;
- if(!len || typeof cs.nodeType != "undefined" || len == 1){
- return cs;
- }
- if(isIE && typeof cs[0].selectSingleNode != "undefined"){
- return nodupIEXml(cs);
- }
- var d = ++key;
- cs[0]._nodup = d;
- for(i = 1; c = cs[i]; i++){
- if(c._nodup != d){
- c._nodup = d;
- }else{
- r = [];
- for(var j = 0; j < i; j++){
- r[++ri] = cs[j];
- }
- for(j = i+1; cj = cs[j]; j++){
- if(cj._nodup != d){
- cj._nodup = d;
- r[++ri] = cj;
- }
+ var i, ln;
+
+ for (i = 0, ln = array.length; i < ln; i++) {
+ if (array[i] === item) {
+ return true;
}
- return r;
}
- }
- return r;
- }
- function quickDiffIEXml(c1, c2){
- var d = ++key,
- r = [];
- for(var i = 0, len = c1.length; i < len; i++){
- c1[i].setAttribute("_qdiff", d);
- }
- for(var i = 0, len = c2.length; i < len; i++){
- if(c2[i].getAttribute("_qdiff") != d){
- r[r.length] = c2[i];
+ return false;
+ },
+
+
+ toArray: function(iterable, start, end){
+ if (!iterable || !iterable.length) {
+ return [];
}
- }
- for(var i = 0, len = c1.length; i < len; i++){
- c1[i].removeAttribute("_qdiff");
- }
- return r;
- }
- function quickDiff(c1, c2){
- var len1 = c1.length,
- d = ++key,
- r = [];
- if(!len1){
- return c2;
- }
- if(isIE && typeof c1[0].selectSingleNode != "undefined"){
- return quickDiffIEXml(c1, c2);
- }
- for(var i = 0; i < len1; i++){
- c1[i]._qdiff = d;
- }
- for(var i = 0, len = c2.length; i < len; i++){
- if(c2[i]._qdiff != d){
- r[r.length] = c2[i];
+ if (typeof iterable === 'string') {
+ iterable = iterable.split('');
}
- }
- return r;
- }
- function quickId(ns, mode, root, id){
- if(ns == root){
- var d = root.ownerDocument || root;
- return d.getElementById(id);
- }
- ns = getNodes(ns, mode, "*");
- return byId(ns, null, id);
- }
+ if (supportsSliceOnNodeList) {
+ return slice.call(iterable, start || 0, end || iterable.length);
+ }
- return {
- getStyle : function(el, name){
- return Ext.fly(el).getStyle(name);
+ var array = [],
+ i;
+
+ start = start || 0;
+ end = end ? ((end < 0) ? iterable.length + end : end) : iterable.length;
+
+ for (i = start; i < end; i++) {
+ array.push(iterable[i]);
+ }
+
+ return array;
},
+
- compile : function(path, type){
- type = type || "select";
+ pluck: function(array, propertyName) {
+ var ret = [],
+ i, ln, item;
- var fn = ["var f = function(root){\n var mode; ++batch; var n = root || document;\n"],
- q = path, mode, lq,
- tk = Ext.DomQuery.matchers,
- tklen = tk.length,
- mm,
-
- lmode = q.match(modeRe);
-
- if(lmode && lmode[1]){
- fn[fn.length] = 'mode="'+lmode[1].replace(trimRe, "")+'";';
- q = q.replace(lmode[1], "");
+ for (i = 0, ln = array.length; i < ln; i++) {
+ item = array[i];
+
+ ret.push(item[propertyName]);
}
-
- while(path.substr(0, 1)=="/"){
- path = path.substr(1);
+
+ return ret;
+ },
+
+
+ map: function(array, fn, scope) {
+ if (supportsMap) {
+ return array.map(fn, scope);
}
- while(q && lq != q){
- lq = q;
- var tm = q.match(tagTokenRe);
- if(type == "select"){
- if(tm){
- if(tm[1] == "#"){
- fn[fn.length] = 'n = quickId(n, mode, root, "'+tm[2]+'");';
- }else{
- fn[fn.length] = 'n = getNodes(n, mode, "'+tm[2]+'");';
- }
- q = q.replace(tm[0], "");
- }else if(q.substr(0, 1) != '@'){
- fn[fn.length] = 'n = getNodes(n, mode, "*");';
- }
- }else{
- if(tm){
- if(tm[1] == "#"){
- fn[fn.length] = 'n = byId(n, null, "'+tm[2]+'");';
- }else{
- fn[fn.length] = 'n = byTag(n, "'+tm[2]+'");';
- }
- q = q.replace(tm[0], "");
- }
- }
- while(!(mm = q.match(modeRe))){
- var matched = false;
- for(var j = 0; j < tklen; j++){
- var t = tk[j];
- var m = q.match(t.re);
- if(m){
- fn[fn.length] = t.select.replace(tplRe, function(x, i){
- return m[i];
- });
- q = q.replace(m[0], "");
- matched = true;
- break;
- }
- }
-
- if(!matched){
- throw 'Error parsing selector, parsing failed at "' + q + '"';
- }
- }
- if(mm[1]){
- fn[fn.length] = 'mode="'+mm[1].replace(trimRe, "")+'";';
- q = q.replace(mm[1], "");
- }
+ var results = [],
+ i = 0,
+ len = array.length;
+
+ for (; i < len; i++) {
+ results[i] = fn.call(scope, array[i], i, array);
}
- fn[fn.length] = "return nodup(n);\n}";
- eval(fn.join(""));
- return f;
+
+ return results;
},
- select : function(path, root, type){
- if(!root || root == document){
- root = document;
- }
- if(typeof root == "string"){
- root = document.getElementById(root);
+ every: function(array, fn, scope) {
+ if (supportsEvery) {
+ return array.every(fn, scope);
}
- var paths = path.split(","),
- results = [];
- for(var i = 0, len = paths.length; i < len; i++){
- var p = paths[i].replace(trimRe, "");
- if(!cache[p]){
- cache[p] = Ext.DomQuery.compile(p);
- if(!cache[p]){
- throw p + " is not a valid selector";
- }
+
+ var i = 0,
+ ln = array.length;
+
+ for (; i < ln; ++i) {
+ if (!fn.call(scope, array[i], i, array)) {
+ return false;
}
- var result = cache[p](root);
- if(result && result != document){
- results = results.concat(result);
+ }
+
+ return true;
+ },
+
+
+ some: function(array, fn, scope) {
+ if (supportsSome) {
+ return array.some(fn, scope);
+ }
+
+ var i = 0,
+ ln = array.length;
+
+ for (; i < ln; ++i) {
+ if (fn.call(scope, array[i], i, array)) {
+ return true;
}
}
- if(paths.length > 1){
- return nodup(results);
+
+ return false;
+ },
+
+
+ clean: function(array) {
+ var results = [],
+ i = 0,
+ ln = array.length,
+ item;
+
+ for (; i < ln; i++) {
+ item = array[i];
+
+ if (!Ext.isEmpty(item)) {
+ results.push(item);
+ }
}
+
return results;
},
- selectNode : function(path, root){
- return Ext.DomQuery.select(path, root)[0];
+ unique: function(array) {
+ var clone = [],
+ i = 0,
+ ln = array.length,
+ item;
+
+ for (; i < ln; i++) {
+ item = array[i];
+
+ if (ExtArray.indexOf(clone, item) === -1) {
+ clone.push(item);
+ }
+ }
+
+ return clone;
},
- selectValue : function(path, root, defaultValue){
- path = path.replace(trimRe, "");
- if(!valueCache[path]){
- valueCache[path] = Ext.DomQuery.compile(path, "select");
+ filter: function(array, fn, scope) {
+ if (supportsFilter) {
+ return array.filter(fn, scope);
}
- var n = valueCache[path](root), v;
- n = n[0] ? n[0] : n;
-
- if (typeof n.normalize == 'function') n.normalize();
-
- v = (n && n.firstChild ? n.firstChild.nodeValue : null);
- return ((v === null||v === undefined||v==='') ? defaultValue : v);
+
+ var results = [],
+ i = 0,
+ ln = array.length;
+
+ for (; i < ln; i++) {
+ if (fn.call(scope, array[i], i, array)) {
+ results.push(array[i]);
+ }
+ }
+
+ return results;
},
- selectNumber : function(path, root, defaultValue){
- var v = Ext.DomQuery.selectValue(path, root, defaultValue || 0);
- return parseFloat(v);
+ from: function(value, newReference) {
+ if (value === undefined || value === null) {
+ return [];
+ }
+
+ if (Ext.isArray(value)) {
+ return (newReference) ? slice.call(value) : value;
+ }
+
+ if (value && value.length !== undefined && typeof value !== 'string') {
+ return Ext.toArray(value);
+ }
+
+ return [value];
},
- is : function(el, ss){
- if(typeof el == "string"){
- el = document.getElementById(el);
+ remove: function(array, item) {
+ var index = ExtArray.indexOf(array, item);
+
+ if (index !== -1) {
+ erase(array, index, 1);
}
- var isArray = Ext.isArray(el),
- result = Ext.DomQuery.filter(isArray ? el : [el], ss);
- return isArray ? (result.length == el.length) : (result.length > 0);
+
+ return array;
},
- filter : function(els, ss, nonMatches){
- ss = ss.replace(trimRe, "");
- if(!simpleCache[ss]){
- simpleCache[ss] = Ext.DomQuery.compile(ss, "simple");
+ include: function(array, item) {
+ if (!ExtArray.contains(array, item)) {
+ array.push(item);
}
- var result = simpleCache[ss](els);
- return nonMatches ? quickDiff(result, els) : result;
},
- matchers : [{
- re: /^\.([\w-]+)/,
- select: 'n = byClassName(n, null, " {1} ");'
- }, {
- re: /^\:([\w-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/,
- select: 'n = byPseudo(n, "{1}", "{2}");'
- },{
- re: /^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,
- select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
- }, {
- re: /^#([\w-]+)/,
- select: 'n = byId(n, null, "{1}");'
- },{
- re: /^@([\w-]+)/,
- select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};'
- }
- ],
+ clone: function(array) {
+ return slice.call(array);
+ },
- operators : {
- "=" : function(a, v){
- return a == v;
- },
- "!=" : function(a, v){
- return a != v;
- },
- "^=" : function(a, v){
- return a && a.substr(0, v.length) == v;
- },
- "$=" : function(a, v){
- return a && a.substr(a.length-v.length) == v;
- },
- "*=" : function(a, v){
- return a && a.indexOf(v) !== -1;
- },
- "%=" : function(a, v){
- return (a % v) == 0;
- },
- "|=" : function(a, v){
- return a && (a == v || a.substr(0, v.length+1) == v+'-');
- },
- "~=" : function(a, v){
- return a && (' '+a+' ').indexOf(' '+v+' ') != -1;
+ merge: function() {
+ var args = slice.call(arguments),
+ array = [],
+ i, ln;
+
+ for (i = 0, ln = args.length; i < ln; i++) {
+ array = array.concat(args[i]);
}
+
+ return ExtArray.unique(array);
},
- pseudos : {
- "first-child" : function(c){
- var r = [], ri = -1, n;
- for(var i = 0, ci; ci = n = c[i]; i++){
- while((n = n.previousSibling) && n.nodeType != 1);
- if(!n){
- r[++ri] = ci;
- }
+ intersect: function() {
+ var intersect = [],
+ arrays = slice.call(arguments),
+ i, j, k, minArray, array, x, y, ln, arraysLn, arrayLn;
+
+ if (!arrays.length) {
+ return intersect;
+ }
+
+
+ for (i = x = 0,ln = arrays.length; i < ln,array = arrays[i]; i++) {
+ if (!minArray || array.length < minArray.length) {
+ minArray = array;
+ x = i;
}
- return r;
- },
+ }
- "last-child" : function(c){
- var r = [], ri = -1, n;
- for(var i = 0, ci; ci = n = c[i]; i++){
- while((n = n.nextSibling) && n.nodeType != 1);
- if(!n){
- r[++ri] = ci;
+ minArray = ExtArray.unique(minArray);
+ erase(arrays, x, 1);
+
+
+
+
+ for (i = 0,ln = minArray.length; i < ln,x = minArray[i]; i++) {
+ var count = 0;
+
+ for (j = 0,arraysLn = arrays.length; j < arraysLn,array = arrays[j]; j++) {
+ for (k = 0,arrayLn = array.length; k < arrayLn,y = array[k]; k++) {
+ if (x === y) {
+ count++;
+ break;
+ }
}
}
- return r;
- },
- "nth-child" : function(c, a) {
- var r = [], ri = -1,
- m = nthRe.exec(a == "even" && "2n" || a == "odd" && "2n+1" || !nthRe2.test(a) && "n+" + a || a),
- f = (m[1] || 1) - 0, l = m[2] - 0;
- for(var i = 0, n; n = c[i]; i++){
- var pn = n.parentNode;
- if (batch != pn._batch) {
- var j = 0;
- for(var cn = pn.firstChild; cn; cn = cn.nextSibling){
- if(cn.nodeType == 1){
- cn.nodeIndex = ++j;
- }
- }
- pn._batch = batch;
- }
- if (f == 1) {
- if (l == 0 || n.nodeIndex == l){
- r[++ri] = n;
- }
- } else if ((n.nodeIndex + l) % f == 0){
- r[++ri] = n;
- }
+ if (count === arraysLn) {
+ intersect.push(x);
}
+ }
- return r;
- },
+ return intersect;
+ },
- "only-child" : function(c){
- var r = [], ri = -1;;
- for(var i = 0, ci; ci = c[i]; i++){
- if(!prev(ci) && !next(ci)){
- r[++ri] = ci;
- }
- }
- return r;
- },
+
+ difference: function(arrayA, arrayB) {
+ var clone = slice.call(arrayA),
+ ln = clone.length,
+ i, j, lnB;
- "empty" : function(c){
- var r = [], ri = -1;
- for(var i = 0, ci; ci = c[i]; i++){
- var cns = ci.childNodes, j = 0, cn, empty = true;
- while(cn = cns[j]){
- ++j;
- if(cn.nodeType == 1 || cn.nodeType == 3){
- empty = false;
- break;
- }
- }
- if(empty){
- r[++ri] = ci;
+ for (i = 0,lnB = arrayB.length; i < lnB; i++) {
+ for (j = 0; j < ln; j++) {
+ if (clone[j] === arrayB[i]) {
+ erase(clone, j, 1);
+ j--;
+ ln--;
}
}
- return r;
- },
+ }
- "contains" : function(c, v){
- var r = [], ri = -1;
- for(var i = 0, ci; ci = c[i]; i++){
- if((ci.textContent||ci.innerText||'').indexOf(v) != -1){
- r[++ri] = ci;
- }
+ return clone;
+ },
+
+
+
+ slice: ([1,2].slice(1, undefined).length ?
+ function (array, begin, end) {
+ return slice.call(array, begin, end);
+ } :
+
+ function (array, begin, end) {
+
+
+ if (typeof begin === 'undefined') {
+ return slice.call(array);
}
- return r;
- },
+ if (typeof end === 'undefined') {
+ return slice.call(array, begin);
+ }
+ return slice.call(array, begin, end);
+ }
+ ),
- "nodeValue" : function(c, v){
- var r = [], ri = -1;
- for(var i = 0, ci; ci = c[i]; i++){
- if(ci.firstChild && ci.firstChild.nodeValue == v){
- r[++ri] = ci;
- }
+
+ sort: function(array, sortFn) {
+ if (supportsSort) {
+ if (sortFn) {
+ return array.sort(sortFn);
+ } else {
+ return array.sort();
}
- return r;
- },
+ }
- "checked" : function(c){
- var r = [], ri = -1;
- for(var i = 0, ci; ci = c[i]; i++){
- if(ci.checked == true){
- r[++ri] = ci;
+ var length = array.length,
+ i = 0,
+ comparison,
+ j, min, tmp;
+
+ for (; i < length; i++) {
+ min = i;
+ for (j = i + 1; j < length; j++) {
+ if (sortFn) {
+ comparison = sortFn(array[j], array[min]);
+ if (comparison < 0) {
+ min = j;
+ }
+ } else if (array[j] < array[min]) {
+ min = j;
}
}
- return r;
- },
+ if (min !== i) {
+ tmp = array[i];
+ array[i] = array[min];
+ array[min] = tmp;
+ }
+ }
- "not" : function(c, ss){
- return Ext.DomQuery.filter(c, ss, true);
- },
+ return array;
+ },
- "any" : function(c, selectors){
- var ss = selectors.split('|'),
- r = [], ri = -1, s;
- for(var i = 0, ci; ci = c[i]; i++){
- for(var j = 0; s = ss[j]; j++){
- if(Ext.DomQuery.is(ci, s)){
- r[++ri] = ci;
- break;
- }
+
+ flatten: function(array) {
+ var worker = [];
+
+ function rFlatten(a) {
+ var i, ln, v;
+
+ for (i = 0, ln = a.length; i < ln; i++) {
+ v = a[i];
+
+ if (Ext.isArray(v)) {
+ rFlatten(v);
+ } else {
+ worker.push(v);
}
}
- return r;
- },
-
- "odd" : function(c){
- return this["nth-child"](c, "odd");
- },
- "even" : function(c){
- return this["nth-child"](c, "even");
- },
+ return worker;
+ }
- "nth" : function(c, a){
- return c[a-1] || [];
- },
+ return rFlatten(array);
+ },
- "first" : function(c){
- return c[0] || [];
- },
+
+ min: function(array, comparisonFn) {
+ var min = array[0],
+ i, ln, item;
- "last" : function(c){
- return c[c.length-1] || [];
- },
+ for (i = 0, ln = array.length; i < ln; i++) {
+ item = array[i];
- "has" : function(c, ss){
- var s = Ext.DomQuery.select,
- r = [], ri = -1;
- for(var i = 0, ci; ci = c[i]; i++){
- if(s(ss, ci).length > 0){
- r[++ri] = ci;
+ if (comparisonFn) {
+ if (comparisonFn(min, item) === 1) {
+ min = item;
}
}
- return r;
- },
-
- "next" : function(c, ss){
- var is = Ext.DomQuery.is,
- r = [], ri = -1;
- for(var i = 0, ci; ci = c[i]; i++){
- var n = next(ci);
- if(n && is(n, ss)){
- r[++ri] = ci;
+ else {
+ if (item < min) {
+ min = item;
}
}
- return r;
- },
+ }
- "prev" : function(c, ss){
- var is = Ext.DomQuery.is,
- r = [], ri = -1;
- for(var i = 0, ci; ci = c[i]; i++){
- var n = prev(ci);
- if(n && is(n, ss)){
- r[++ri] = ci;
+ return min;
+ },
+
+
+ max: function(array, comparisonFn) {
+ var max = array[0],
+ i, ln, item;
+
+ for (i = 0, ln = array.length; i < ln; i++) {
+ item = array[i];
+
+ if (comparisonFn) {
+ if (comparisonFn(max, item) === -1) {
+ max = item;
+ }
+ }
+ else {
+ if (item > max) {
+ max = item;
}
}
- return r;
}
- }
- };
-}();
+ return max;
+ },
-Ext.query = Ext.DomQuery.select;
+
+ mean: function(array) {
+ return array.length > 0 ? ExtArray.sum(array) / array.length : undefined;
+ },
-Ext.util.DelayedTask = function(fn, scope, args){
- var me = this,
- id,
- call = function(){
- clearInterval(id);
- id = null;
- fn.apply(scope, args || []);
- };
-
-
- me.delay = function(delay, newFn, newScope, newArgs){
- me.cancel();
- fn = newFn || fn;
- scope = newScope || scope;
- args = newArgs || args;
- id = setInterval(call, delay);
+
+ sum: function(array) {
+ var sum = 0,
+ i, ln, item;
+
+ for (i = 0,ln = array.length; i < ln; i++) {
+ item = array[i];
+
+ sum += item;
+ }
+
+ return sum;
+ },
+
+
+
+ erase: erase,
+
+
+ insert: function (array, index, items) {
+ return replace(array, index, 0, items);
+ },
+
+
+ replace: replace,
+
+
+ splice: splice
};
- me.cancel = function(){
- if(id){
- clearInterval(id);
- id = null;
- }
- };
-};(function(){
+ Ext.each = ExtArray.each;
-var EXTUTIL = Ext.util,
- TOARRAY = Ext.toArray,
- EACH = Ext.each,
- ISOBJECT = Ext.isObject,
- TRUE = true,
- FALSE = false;
+
+ ExtArray.union = ExtArray.merge;
-EXTUTIL.Observable = function(){
- var me = this, e = me.events;
- if(me.listeners){
- me.on(me.listeners);
- delete me.listeners;
- }
- me.events = e || {};
-};
+ Ext.min = ExtArray.min;
-EXTUTIL.Observable.prototype = {
- filterOptRe : /^(?:scope|delay|buffer|single)$/,
+ Ext.max = ExtArray.max;
- fireEvent : function(){
- var a = TOARRAY(arguments),
- ename = a[0].toLowerCase(),
- me = this,
- ret = TRUE,
- ce = me.events[ename],
- q,
- c;
- if (me.eventsSuspended === TRUE) {
- if (q = me.eventQueue) {
- q.push(a);
- }
- }
- else if(ISOBJECT(ce) && ce.bubble){
- if(ce.fire.apply(ce, a.slice(1)) === FALSE) {
- return FALSE;
+ Ext.sum = ExtArray.sum;
+
+
+ Ext.mean = ExtArray.mean;
+
+
+ Ext.flatten = ExtArray.flatten;
+
+
+ Ext.clean = ExtArray.clean;
+
+
+ Ext.unique = ExtArray.unique;
+
+
+ Ext.pluck = ExtArray.pluck;
+
+
+ Ext.toArray = function() {
+ return ExtArray.toArray.apply(ExtArray, arguments);
+ };
+})();
+
+
+Ext.Function = {
+
+
+ flexSetter: function(fn) {
+ return function(a, b) {
+ var k, i;
+
+ if (a === null) {
+ return this;
}
- c = me.getBubbleTarget && me.getBubbleTarget();
- if(c && c.enableBubble) {
- if(!c.events[ename] || !Ext.isObject(c.events[ename]) || !c.events[ename].bubble) {
- c.enableBubble(ename);
+
+ if (typeof a !== 'string') {
+ for (k in a) {
+ if (a.hasOwnProperty(k)) {
+ fn.call(this, k, a[k]);
+ }
+ }
+
+ if (Ext.enumerables) {
+ for (i = Ext.enumerables.length; i--;) {
+ k = Ext.enumerables[i];
+ if (a.hasOwnProperty(k)) {
+ fn.call(this, k, a[k]);
+ }
+ }
}
- return c.fireEvent.apply(c, a);
+ } else {
+ fn.call(this, a, b);
+ }
+
+ return this;
+ };
+ },
+
+
+ bind: function(fn, scope, args, appendArgs) {
+ if (arguments.length === 2) {
+ return function() {
+ return fn.apply(scope, arguments);
}
}
- else {
- if (ISOBJECT(ce)) {
- a.shift();
- ret = ce.fire.apply(ce, a);
+
+ var method = fn,
+ slice = Array.prototype.slice;
+
+ return function() {
+ var callArgs = args || arguments;
+
+ if (appendArgs === true) {
+ callArgs = slice.call(arguments, 0);
+ callArgs = callArgs.concat(args);
}
+ else if (typeof appendArgs == 'number') {
+ callArgs = slice.call(arguments, 0);
+ Ext.Array.insert(callArgs, appendArgs, args);
+ }
+
+ return method.apply(scope || window, callArgs);
+ };
+ },
+
+
+ pass: function(fn, args, scope) {
+ if (args) {
+ args = Ext.Array.from(args);
}
- return ret;
+
+ return function() {
+ return fn.apply(scope, args.concat(Ext.Array.toArray(arguments)));
+ };
},
- addListener : function(eventName, fn, scope, o){
- var me = this,
- e,
- oe,
- isF,
- ce;
- if (ISOBJECT(eventName)) {
- o = eventName;
- for (e in o){
- oe = o[e];
- if (!me.filterOptRe.test(e)) {
- me.addListener(e, oe.fn || oe, oe.scope || o.scope, oe.fn ? oe : o);
- }
- }
- } else {
- eventName = eventName.toLowerCase();
- ce = me.events[eventName] || TRUE;
- if (Ext.isBoolean(ce)) {
- me.events[eventName] = ce = new EXTUTIL.Event(me, eventName);
- }
- ce.addListener(fn, scope, ISOBJECT(o) ? o : {});
+ alias: function(object, methodName) {
+ return function() {
+ return object[methodName].apply(object, arguments);
+ };
+ },
+
+
+ createInterceptor: function(origFn, newFn, scope, returnValue) {
+ var method = origFn;
+ if (!Ext.isFunction(newFn)) {
+ return origFn;
+ }
+ else {
+ return function() {
+ var me = this,
+ args = arguments;
+ newFn.target = me;
+ newFn.method = origFn;
+ return (newFn.apply(scope || me || window, args) !== false) ? origFn.apply(me || window, args) : returnValue || null;
+ };
}
},
- removeListener : function(eventName, fn, scope){
- var ce = this.events[eventName.toLowerCase()];
- if (ISOBJECT(ce)) {
- ce.removeListener(fn, scope);
+ createDelayed: function(fn, delay, scope, args, appendArgs) {
+ if (scope || args) {
+ fn = Ext.Function.bind(fn, scope, args, appendArgs);
}
+ return function() {
+ var me = this;
+ setTimeout(function() {
+ fn.apply(me, arguments);
+ }, delay);
+ };
},
- purgeListeners : function(){
- var events = this.events,
- evt,
- key;
- for(key in events){
- evt = events[key];
- if(ISOBJECT(evt)){
- evt.clearListeners();
- }
+ defer: function(fn, millis, obj, args, appendArgs) {
+ fn = Ext.Function.bind(fn, obj, args, appendArgs);
+ if (millis > 0) {
+ return setTimeout(fn, millis);
}
+ fn();
+ return 0;
},
- addEvents : function(o){
- var me = this;
- me.events = me.events || {};
- if (Ext.isString(o)) {
- var a = arguments,
- i = a.length;
- while(i--) {
- me.events[a[i]] = me.events[a[i]] || TRUE;
- }
- } else {
- Ext.applyIf(me.events, o);
+ createSequence: function(origFn, newFn, scope) {
+ if (!Ext.isFunction(newFn)) {
+ return origFn;
+ }
+ else {
+ return function() {
+ var retval = origFn.apply(this || window, arguments);
+ newFn.apply(scope || this || window, arguments);
+ return retval;
+ };
}
},
- hasListener : function(eventName){
- var e = this.events[eventName];
- return ISOBJECT(e) && e.listeners.length > 0;
+ createBuffered: function(fn, buffer, scope, args) {
+ return function(){
+ var timerId;
+ return function() {
+ var me = this;
+ if (timerId) {
+ clearTimeout(timerId);
+ timerId = null;
+ }
+ timerId = setTimeout(function(){
+ fn.apply(scope || me, args || arguments);
+ }, buffer);
+ };
+ }();
},
- suspendEvents : function(queueSuspended){
- this.eventsSuspended = TRUE;
- if(queueSuspended && !this.eventQueue){
- this.eventQueue = [];
- }
+ createThrottled: function(fn, interval, scope) {
+ var lastCallTime, elapsed, lastArgs, timer, execute = function() {
+ fn.apply(scope || this, lastArgs);
+ lastCallTime = new Date().getTime();
+ };
+
+ return function() {
+ elapsed = new Date().getTime() - lastCallTime;
+ lastArgs = arguments;
+
+ clearTimeout(timer);
+ if (!lastCallTime || (elapsed >= interval)) {
+ execute();
+ } else {
+ timer = setTimeout(execute, interval - elapsed);
+ }
+ };
},
- resumeEvents : function(){
- var me = this,
- queued = me.eventQueue || [];
- me.eventsSuspended = FALSE;
- delete me.eventQueue;
- EACH(queued, function(e) {
- me.fireEvent.apply(me, e);
- });
+ interceptBefore: function(object, methodName, fn) {
+ var method = object[methodName] || Ext.emptyFn;
+
+ return object[methodName] = function() {
+ var ret = fn.apply(this, arguments);
+ method.apply(this, arguments);
+
+ return ret;
+ };
+ },
+
+
+ interceptAfter: function(object, methodName, fn) {
+ var method = object[methodName] || Ext.emptyFn;
+
+ return object[methodName] = function() {
+ method.apply(this, arguments);
+ return fn.apply(this, arguments);
+ };
}
};
-var OBSERVABLE = EXTUTIL.Observable.prototype;
-OBSERVABLE.on = OBSERVABLE.addListener;
+Ext.defer = Ext.Function.alias(Ext.Function, 'defer');
-OBSERVABLE.un = OBSERVABLE.removeListener;
+Ext.pass = Ext.Function.alias(Ext.Function, 'pass');
-EXTUTIL.Observable.releaseCapture = function(o){
- o.fireEvent = OBSERVABLE.fireEvent;
-};
-function createTargeted(h, o, scope){
- return function(){
- if(o.target == arguments[0]){
- h.apply(scope, TOARRAY(arguments));
- }
- };
-};
+Ext.bind = Ext.Function.alias(Ext.Function, 'bind');
-function createBuffered(h, o, fn, scope){
- fn.task = new EXTUTIL.DelayedTask();
- return function(){
- fn.task.delay(o.buffer, h, scope, TOARRAY(arguments));
- };
-}
-function createSingle(h, e, fn, scope){
- return function(){
- e.removeListener(fn, scope);
- return h.apply(scope, arguments);
- };
-}
-function createDelayed(h, o, fn, scope){
- return function(){
- var task = new EXTUTIL.DelayedTask();
- if(!fn.tasks) {
- fn.tasks = [];
- }
- fn.tasks.push(task);
- task.delay(o.delay || 10, h, scope, TOARRAY(arguments));
- };
-};
+(function() {
-EXTUTIL.Event = function(obj, name){
- this.name = name;
- this.obj = obj;
- this.listeners = [];
-};
+var ExtObject = Ext.Object = {
-EXTUTIL.Event.prototype = {
- addListener : function(fn, scope, options){
- var me = this,
- l;
- scope = scope || me.obj;
- if(!me.isListening(fn, scope)){
- l = me.createListener(fn, scope, options);
- if(me.firing){
- me.listeners = me.listeners.slice(0);
- }
- me.listeners.push(l);
- }
- },
+
+ toQueryObjects: function(name, value, recursive) {
+ var self = ExtObject.toQueryObjects,
+ objects = [],
+ i, ln;
- createListener: function(fn, scope, o){
- o = o || {}, scope = scope || this.obj;
- var l = {
- fn: fn,
- scope: scope,
- options: o
- }, h = fn;
- if(o.target){
- h = createTargeted(h, o, scope);
- }
- if(o.delay){
- h = createDelayed(h, o, fn, scope);
+ if (Ext.isArray(value)) {
+ for (i = 0, ln = value.length; i < ln; i++) {
+ if (recursive) {
+ objects = objects.concat(self(name + '[' + i + ']', value[i], true));
+ }
+ else {
+ objects.push({
+ name: name,
+ value: value[i]
+ });
+ }
+ }
}
- if(o.single){
- h = createSingle(h, this, fn, scope);
+ else if (Ext.isObject(value)) {
+ for (i in value) {
+ if (value.hasOwnProperty(i)) {
+ if (recursive) {
+ objects = objects.concat(self(name + '[' + i + ']', value[i], true));
+ }
+ else {
+ objects.push({
+ name: name,
+ value: value[i]
+ });
+ }
+ }
+ }
}
- if(o.buffer){
- h = createBuffered(h, o, fn, scope);
+ else {
+ objects.push({
+ name: name,
+ value: value
+ });
}
- l.fireFn = h;
- return l;
+
+ return objects;
},
- findListener : function(fn, scope){
- var list = this.listeners,
- i = list.length,
- l,
- s;
- while(i--) {
- l = list[i];
- if(l) {
- s = l.scope;
- if(l.fn == fn && (s == scope || s == this.obj)){
- return i;
- }
+
+ toQueryString: function(object, recursive) {
+ var paramObjects = [],
+ params = [],
+ i, j, ln, paramObject, value;
+
+ for (i in object) {
+ if (object.hasOwnProperty(i)) {
+ paramObjects = paramObjects.concat(ExtObject.toQueryObjects(i, object[i], recursive));
}
}
- return -1;
- },
- isListening : function(fn, scope){
- return this.findListener(fn, scope) != -1;
- },
+ for (j = 0, ln = paramObjects.length; j < ln; j++) {
+ paramObject = paramObjects[j];
+ value = paramObject.value;
- removeListener : function(fn, scope){
- var index,
- l,
- k,
- me = this,
- ret = FALSE;
- if((index = me.findListener(fn, scope)) != -1){
- if (me.firing) {
- me.listeners = me.listeners.slice(0);
- }
- l = me.listeners[index].fn;
-
- if(l.task) {
- l.task.cancel();
- delete l.task;
+ if (Ext.isEmpty(value)) {
+ value = '';
}
-
- k = l.tasks && l.tasks.length;
- if(k) {
- while(k--) {
- l.tasks[k].cancel();
- }
- delete l.tasks;
+ else if (Ext.isDate(value)) {
+ value = Ext.Date.toString(value);
}
- me.listeners.splice(index, 1);
- ret = TRUE;
- }
- return ret;
- },
-
- clearListeners : function(){
- var me = this,
- l = me.listeners,
- i = l.length;
- while(i--) {
- me.removeListener(l[i].fn, l[i].scope);
+ params.push(encodeURIComponent(paramObject.name) + '=' + encodeURIComponent(String(value)));
}
- },
- fire : function(){
- var me = this,
- args = TOARRAY(arguments),
- listeners = me.listeners,
- len = listeners.length,
- i = 0,
- l;
+ return params.join('&');
+ },
- if(len > 0){
- me.firing = TRUE;
- for (; i < len; i++) {
- l = listeners[i];
- if(l && l.fireFn.apply(l.scope || me.obj || window, args) === FALSE) {
- return (me.firing = FALSE);
- }
- }
- }
- me.firing = FALSE;
- return TRUE;
- }
-};
-})();
-Ext.apply(Ext.util.Observable.prototype, function(){
-
-
- function getMethodEvent(method){
- var e = (this.methodEvents = this.methodEvents ||
- {})[method], returnValue, v, cancel, obj = this;
+ fromQueryString: function(queryString, recursive) {
+ var parts = queryString.replace(/^\?/, '').split('&'),
+ object = {},
+ temp, components, name, value, i, ln,
+ part, j, subLn, matchedKeys, matchedName,
+ keys, key, nextKey;
- if (!e) {
- this.methodEvents[method] = e = {};
- e.originalFn = this[method];
- e.methodName = method;
- e.before = [];
- e.after = [];
+ for (i = 0, ln = parts.length; i < ln; i++) {
+ part = parts[i];
- var makeCall = function(fn, scope, args){
- if (!Ext.isEmpty(v = fn.apply(scope || obj, args))) {
- if (Ext.isObject(v)) {
- returnValue = !Ext.isEmpty(v.returnValue) ? v.returnValue : v;
- cancel = !!v.cancel;
- }
- else
- if (v === false) {
- cancel = true;
- }
- else {
- returnValue = v;
- }
- }
- };
+ if (part.length > 0) {
+ components = part.split('=');
+ name = decodeURIComponent(components[0]);
+ value = (components[1] !== undefined) ? decodeURIComponent(components[1]) : '';
- this[method] = function(){
- var args = Ext.toArray(arguments);
- returnValue = v = undefined;
- cancel = false;
+ if (!recursive) {
+ if (object.hasOwnProperty(name)) {
+ if (!Ext.isArray(object[name])) {
+ object[name] = [object[name]];
+ }
- Ext.each(e.before, function(b){
- makeCall(b.fn, b.scope, args);
- if (cancel) {
- return returnValue;
+ object[name].push(value);
}
- });
-
- if (!Ext.isEmpty(v = e.originalFn.apply(obj, args))) {
- returnValue = v;
- }
- Ext.each(e.after, function(a){
- makeCall(a.fn, a.scope, args);
- if (cancel) {
- return returnValue;
+ else {
+ object[name] = value;
}
- });
- return returnValue;
- };
- }
- return e;
- }
+ }
+ else {
+ matchedKeys = name.match(/(\[):?([^\]]*)\]/g);
+ matchedName = name.match(/^([^\[]+)/);
- return {
-
-
-
- beforeMethod : function(method, fn, scope){
- getMethodEvent.call(this, method).before.push({
- fn: fn,
- scope: scope
- });
- },
-
- afterMethod : function(method, fn, scope){
- getMethodEvent.call(this, method).after.push({
- fn: fn,
- scope: scope
- });
- },
+ name = matchedName[0];
+ keys = [];
- removeMethodListener: function(method, fn, scope){
- var e = getMethodEvent.call(this, method), found = false;
- Ext.each(e.before, function(b, i, arr){
- if (b.fn == fn && b.scope == scope) {
- arr.splice(i, 1);
- found = true;
- return false;
- }
- });
- if (!found) {
- Ext.each(e.after, function(a, i, arr){
- if (a.fn == fn && a.scope == scope) {
- arr.splice(i, 1);
- return false;
+ if (matchedKeys === null) {
+ object[name] = value;
+ continue;
}
- });
- }
- },
-
-
- relayEvents : function(o, events){
- var me = this;
- function createHandler(ename){
- return function(){
- return me.fireEvent.apply(me, [ename].concat(Ext.toArray(arguments)));
- };
- }
- Ext.each(events, function(ename){
- me.events[ename] = me.events[ename] || true;
- o.on(ename, createHandler(ename), me);
- });
- },
-
- enableBubble : function(events){
- var me = this;
- if(!Ext.isEmpty(events)){
- events = Ext.isArray(events) ? events : Ext.toArray(arguments);
- Ext.each(events, function(ename){
- ename = ename.toLowerCase();
- var ce = me.events[ename] || true;
- if (Ext.isBoolean(ce)) {
- ce = new Ext.util.Event(me, ename);
- me.events[ename] = ce;
- }
- ce.bubble = true;
- });
- }
- }
- };
-}());
+ for (j = 0, subLn = matchedKeys.length; j < subLn; j++) {
+ key = matchedKeys[j];
+ key = (key.length === 2) ? '' : key.substring(1, key.length - 1);
+ keys.push(key);
+ }
+ keys.unshift(name);
+ temp = object;
-Ext.util.Observable.capture = function(o, fn, scope){
- o.fireEvent = o.fireEvent.createInterceptor(fn, scope);
-};
+ for (j = 0, subLn = keys.length; j < subLn; j++) {
+ key = keys[j];
+ if (j === subLn - 1) {
+ if (Ext.isArray(temp) && key === '') {
+ temp.push(value);
+ }
+ else {
+ temp[key] = value;
+ }
+ }
+ else {
+ if (temp[key] === undefined || typeof temp[key] === 'string') {
+ nextKey = keys[j+1];
+ temp[key] = (Ext.isNumeric(nextKey) || nextKey === '') ? [] : {};
+ }
-Ext.util.Observable.observeClass = function(c, listeners){
- if(c){
- if(!c.fireEvent){
- Ext.apply(c, new Ext.util.Observable());
- Ext.util.Observable.capture(c.prototype, c.fireEvent, c);
- }
- if(Ext.isObject(listeners)){
- c.on(listeners);
- }
- return c;
- }
-};
-Ext.EventManager = function(){
- var docReadyEvent,
- docReadyProcId,
- docReadyState = false,
- E = Ext.lib.Event,
- D = Ext.lib.Dom,
- DOC = document,
- WINDOW = window,
- IEDEFERED = "ie-deferred-loader",
- DOMCONTENTLOADED = "DOMContentLoaded",
- propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,
-
- specialElCache = [];
-
- function getId(el){
- var id = false,
- i = 0,
- len = specialElCache.length,
- id = false,
- skip = false,
- o;
- if(el){
- if(el.getElementById || el.navigator){
-
- for(; i < len; ++i){
- o = specialElCache[i];
- if(o.el === el){
- id = o.id;
- break;
+ temp = temp[key];
+ }
}
}
- if(!id){
-
- id = Ext.id(el);
- specialElCache.push({
- id: id,
- el: el
- });
- skip = true;
- }
- }else{
- id = Ext.id(el);
- }
- if(!Ext.elCache[id]){
- Ext.Element.addToCache(new Ext.Element(el), id);
- if(skip){
- Ext.elCache[id].skipGC = true;
- }
}
}
- return id;
- };
-
-
- function addListener(el, ename, fn, wrap, scope){
- el = Ext.getDom(el);
- var id = getId(el),
- es = Ext.elCache[id].events,
- wfn;
- wfn = E.on(el, ename, wrap);
- es[ename] = es[ename] || [];
- es[ename].push([fn, wrap, scope, wfn]);
+ return object;
+ },
-
-
- if(ename == "mousewheel" && el.addEventListener){
- var args = ["DOMMouseScroll", wrap, false];
- el.addEventListener.apply(el, args);
- Ext.EventManager.addListener(WINDOW, 'unload', function(){
- el.removeEventListener.apply(el, args);
- });
- }
- if(ename == "mousedown" && el == document){
- Ext.EventManager.stoppedMouseDownEvent.addListener(wrap);
+
+ each: function(object, fn, scope) {
+ for (var property in object) {
+ if (object.hasOwnProperty(property)) {
+ if (fn.call(scope || object, property, object[property], object) === false) {
+ return;
+ }
+ }
}
- };
+ },
- function fireDocReady(){
- if(!docReadyState){
- Ext.isReady = docReadyState = true;
- if(docReadyProcId){
- clearInterval(docReadyProcId);
- }
- if(Ext.isGecko || Ext.isOpera) {
- DOC.removeEventListener(DOMCONTENTLOADED, fireDocReady, false);
- }
- if(Ext.isIE){
- var defer = DOC.getElementById(IEDEFERED);
- if(defer){
- defer.onreadystatechange = null;
- defer.parentNode.removeChild(defer);
+
+ merge: function(source, key, value) {
+ if (typeof key === 'string') {
+ if (value && value.constructor === Object) {
+ if (source[key] && source[key].constructor === Object) {
+ ExtObject.merge(source[key], value);
+ }
+ else {
+ source[key] = Ext.clone(value);
}
}
- if(docReadyEvent){
- docReadyEvent.fire();
- docReadyEvent.listeners = [];
+ else {
+ source[key] = value;
}
+
+ return source;
}
- };
- function initDocReady(){
- var COMPLETE = "complete";
+ var i = 1,
+ ln = arguments.length,
+ object, property;
- docReadyEvent = new Ext.util.Event();
- if (Ext.isGecko || Ext.isOpera) {
- DOC.addEventListener(DOMCONTENTLOADED, fireDocReady, false);
- } else if (Ext.isIE){
- DOC.write("");
- DOC.getElementById(IEDEFERED).onreadystatechange = function(){
- if(this.readyState == COMPLETE){
- fireDocReady();
+ for (; i < ln; i++) {
+ object = arguments[i];
+
+ for (property in object) {
+ if (object.hasOwnProperty(property)) {
+ ExtObject.merge(source, property, object[property]);
}
- };
- } else if (Ext.isWebKit){
- docReadyProcId = setInterval(function(){
- if(DOC.readyState == COMPLETE) {
- fireDocReady();
- }
- }, 10);
+ }
}
-
- E.on(WINDOW, "load", fireDocReady);
- };
- function createTargeted(h, o){
- return function(){
- var args = Ext.toArray(arguments);
- if(o.target == Ext.EventObject.setEvent(args[0]).target){
- h.apply(this, args);
+ return source;
+ },
+
+
+ getKey: function(object, value) {
+ for (var property in object) {
+ if (object.hasOwnProperty(property) && object[property] === value) {
+ return property;
}
- };
- };
+ }
- function createBuffered(h, o, fn){
- fn.task = new Ext.util.DelayedTask(h);
- var w = function(e){
-
- fn.task.delay(o.buffer, h, null, [new Ext.EventObjectImpl(e)]);
- };
- return w;
- };
+ return null;
+ },
- function createSingle(h, el, ename, fn, scope){
- return function(e){
- Ext.EventManager.removeListener(el, ename, fn, scope);
- h(e);
- };
- };
+
+ getValues: function(object) {
+ var values = [],
+ property;
- function createDelayed(h, o, fn){
- return function(e){
- var task = new Ext.util.DelayedTask(h);
- if(!fn.tasks) {
- fn.tasks = [];
+ for (property in object) {
+ if (object.hasOwnProperty(property)) {
+ values.push(object[property]);
}
- fn.tasks.push(task);
- task.delay(o.delay || 10, h, null, [new Ext.EventObjectImpl(e)]);
- };
- };
+ }
- function listen(element, ename, opt, fn, scope){
- var o = !Ext.isObject(opt) ? {} : opt,
- el = Ext.getDom(element);
+ return values;
+ },
- fn = fn || o.fn;
- scope = scope || o.scope;
+
+ getKeys: ('keys' in Object.prototype) ? Object.keys : function(object) {
+ var keys = [],
+ property;
- if(!el){
- throw "Error listening for \"" + ename + '\". Element "' + element + '" doesn\'t exist.';
- }
- function h(e){
-
- if(!Ext){
- return;
- }
- e = Ext.EventObject.setEvent(e);
- var t;
- if (o.delegate) {
- if(!(t = e.getTarget(o.delegate, el))){
- return;
- }
- } else {
- t = e.target;
- }
- if (o.stopEvent) {
- e.stopEvent();
- }
- if (o.preventDefault) {
- e.preventDefault();
- }
- if (o.stopPropagation) {
- e.stopPropagation();
- }
- if (o.normalized) {
- e = e.browserEvent;
+ for (property in object) {
+ if (object.hasOwnProperty(property)) {
+ keys.push(property);
}
-
- fn.call(scope || el, e, t, o);
- };
- if(o.target){
- h = createTargeted(h, o);
- }
- if(o.delay){
- h = createDelayed(h, o, fn);
- }
- if(o.single){
- h = createSingle(h, el, ename, fn, scope);
- }
- if(o.buffer){
- h = createBuffered(h, o, fn);
}
- addListener(el, ename, fn, h, scope);
- return h;
- };
+ return keys;
+ },
- var pub = {
-
- addListener : function(element, eventName, fn, scope, options){
- if(Ext.isObject(eventName)){
- var o = eventName, e, val;
- for(e in o){
- val = o[e];
- if(!propRe.test(e)){
- if(Ext.isFunction(val)){
-
- listen(element, e, o, val, o.scope);
- }else{
-
- listen(element, e, val);
- }
- }
- }
- } else {
- listen(element, eventName, options, fn, scope);
- }
- },
-
-
- removeListener : function(el, eventName, fn, scope){
- el = Ext.getDom(el);
- var id = getId(el),
- f = el && (Ext.elCache[id].events)[eventName] || [],
- wrap, i, l, k, wf;
-
- for (i = 0, len = f.length; i < len; i++) {
- if (Ext.isArray(f[i]) && f[i][0] == fn && (!scope || f[i][2] == scope)) {
- if(fn.task) {
- fn.task.cancel();
- delete fn.task;
- }
- k = fn.tasks && fn.tasks.length;
- if(k) {
- while(k--) {
- fn.tasks[k].cancel();
- }
- delete fn.tasks;
- }
- wf = wrap = f[i][1];
- if (E.extAdapter) {
- wf = f[i][3];
- }
- E.un(el, eventName, wf);
- f.splice(i,1);
- if (f.length === 0) {
- delete Ext.elCache[id].events[eventName];
- }
- for (k in Ext.elCache[id].events) {
- return false;
- }
- Ext.elCache[id].events = {};
- return false;
- }
- }
-
-
- if(eventName == "mousewheel" && el.addEventListener && wrap){
- el.removeEventListener("DOMMouseScroll", wrap, false);
- }
-
- if(eventName == "mousedown" && el == DOC && wrap){
- Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
- }
- },
-
-
- removeAll : function(el){
- el = Ext.getDom(el);
- var id = getId(el),
- ec = Ext.elCache[id] || {},
- es = ec.events || {},
- f, i, len, ename, fn, k;
-
- for(ename in es){
- if(es.hasOwnProperty(ename)){
- f = es[ename];
- for (i = 0, len = f.length; i < len; i++) {
- fn = f[i][0];
- if(fn.task) {
- fn.task.cancel();
- delete fn.task;
- }
- if(fn.tasks && (k = fn.tasks.length)) {
- while(k--) {
- fn.tasks[k].cancel();
- }
- delete fn.tasks;
- }
- E.un(el, ename, E.extAdapter ? f[i][3] : f[i][1]);
- }
- }
- }
- if (Ext.elCache[id]) {
- Ext.elCache[id].events = {};
- }
- },
-
- getListeners : function(el, eventName) {
- el = Ext.getDom(el);
- var id = getId(el),
- ec = Ext.elCache[id] || {},
- es = ec.events || {},
- results = [];
- if (es && es[eventName]) {
- return es[eventName];
- } else {
- return null;
- }
- },
-
- purgeElement : function(el, recurse, eventName) {
- el = Ext.getDom(el);
- var id = getId(el),
- ec = Ext.elCache[id] || {},
- es = ec.events || {},
- i, f, len;
- if (eventName) {
- if (es && es.hasOwnProperty(eventName)) {
- f = es[eventName];
- for (i = 0, len = f.length; i < len; i++) {
- Ext.EventManager.removeListener(el, eventName, f[i][0]);
- }
- }
- } else {
- Ext.EventManager.removeAll(el);
- }
- if (recurse && el && el.childNodes) {
- for (i = 0, len = el.childNodes.length; i < len; i++) {
- Ext.EventManager.purgeElement(el.childNodes[i], recurse, eventName);
- }
- }
- },
-
- _unload : function() {
- var el;
- for (el in Ext.elCache) {
- Ext.EventManager.removeAll(el);
- }
- },
-
- onDocumentReady : function(fn, scope, options){
- if(docReadyState){
- docReadyEvent.addListener(fn, scope, options);
- docReadyEvent.fire();
- docReadyEvent.listeners = [];
- } else {
- if(!docReadyEvent) initDocReady();
- options = options || {};
- options.delay = options.delay || 1;
- docReadyEvent.addListener(fn, scope, options);
- }
- }
- };
-
- pub.on = pub.addListener;
- pub.un = pub.removeListener;
-
- pub.stoppedMouseDownEvent = new Ext.util.Event();
- return pub;
-}();
-
-Ext.onReady = Ext.EventManager.onDocumentReady;
-
-
-
-(function(){
-
- var initExtCss = function(){
-
- var bd = document.body || document.getElementsByTagName('body')[0];
- if(!bd){ return false; }
- var cls = [' ',
- Ext.isIE ? "ext-ie " + (Ext.isIE6 ? 'ext-ie6' : (Ext.isIE7 ? 'ext-ie7' : 'ext-ie8'))
- : Ext.isGecko ? "ext-gecko " + (Ext.isGecko2 ? 'ext-gecko2' : 'ext-gecko3')
- : Ext.isOpera ? "ext-opera"
- : Ext.isWebKit ? "ext-webkit" : ""];
-
- if(Ext.isSafari){
- cls.push("ext-safari " + (Ext.isSafari2 ? 'ext-safari2' : (Ext.isSafari3 ? 'ext-safari3' : 'ext-safari4')));
- }else if(Ext.isChrome){
- cls.push("ext-chrome");
- }
-
- if(Ext.isMac){
- cls.push("ext-mac");
- }
- if(Ext.isLinux){
- cls.push("ext-linux");
- }
+ getSize: function(object) {
+ var size = 0,
+ property;
- if(Ext.isStrict || Ext.isBorderBox){
- var p = bd.parentNode;
- if(p){
- p.className += Ext.isStrict ? ' ext-strict' : ' ext-border-box';
+ for (property in object) {
+ if (object.hasOwnProperty(property)) {
+ size++;
}
}
- bd.className += cls.join(' ');
- return true;
- }
- if(!initExtCss()){
- Ext.onReady(initExtCss);
+ return size;
}
-})();
-
-
-
-Ext.EventObject = function(){
- var E = Ext.lib.Event,
-
- safariKeys = {
- 3 : 13,
- 63234 : 37,
- 63235 : 39,
- 63232 : 38,
- 63233 : 40,
- 63276 : 33,
- 63277 : 34,
- 63272 : 46,
- 63273 : 36,
- 63275 : 35
- },
-
- btnMap = Ext.isIE ? {1:0,4:1,2:2} :
- (Ext.isWebKit ? {1:0,2:1,3:2} : {0:0,1:1,2:2});
-
- Ext.EventObjectImpl = function(e){
- if(e){
- this.setEvent(e.browserEvent || e);
- }
- };
+};
- Ext.EventObjectImpl.prototype = {
-
- setEvent : function(e){
- var me = this;
- if(e == me || (e && e.browserEvent)){
- return e;
- }
- me.browserEvent = e;
- if(e){
-
- me.button = e.button ? btnMap[e.button] : (e.which ? e.which - 1 : -1);
- if(e.type == 'click' && me.button == -1){
- me.button = 0;
- }
- me.type = e.type;
- me.shiftKey = e.shiftKey;
-
- me.ctrlKey = e.ctrlKey || e.metaKey || false;
- me.altKey = e.altKey;
-
- me.keyCode = e.keyCode;
- me.charCode = e.charCode;
-
- me.target = E.getTarget(e);
-
- me.xy = E.getXY(e);
- }else{
- me.button = -1;
- me.shiftKey = false;
- me.ctrlKey = false;
- me.altKey = false;
- me.keyCode = 0;
- me.charCode = 0;
- me.target = null;
- me.xy = [0, 0];
- }
- return me;
- },
-
- stopEvent : function(){
- var me = this;
- if(me.browserEvent){
- if(me.browserEvent.type == 'mousedown'){
- Ext.EventManager.stoppedMouseDownEvent.fire(me);
- }
- E.stopEvent(me.browserEvent);
- }
- },
-
- preventDefault : function(){
- if(this.browserEvent){
- E.preventDefault(this.browserEvent);
- }
- },
+Ext.merge = Ext.Object.merge;
-
- stopPropagation : function(){
- var me = this;
- if(me.browserEvent){
- if(me.browserEvent.type == 'mousedown'){
- Ext.EventManager.stoppedMouseDownEvent.fire(me);
- }
- E.stopPropagation(me.browserEvent);
- }
- },
-
- getCharCode : function(){
- return this.charCode || this.keyCode;
- },
+Ext.urlEncode = function() {
+ var args = Ext.Array.from(arguments),
+ prefix = '';
-
- getKey : function(){
- return this.normalizeKey(this.keyCode || this.charCode)
- },
+
+ if ((typeof args[1] === 'string')) {
+ prefix = args[1] + '&';
+ args[1] = false;
+ }
-
- normalizeKey: function(k){
- return Ext.isSafari ? (safariKeys[k] || k) : k;
- },
+ return prefix + Ext.Object.toQueryString.apply(Ext.Object, args);
+};
-
- getPageX : function(){
- return this.xy[0];
- },
-
- getPageY : function(){
- return this.xy[1];
- },
+Ext.urlDecode = function() {
+ return Ext.Object.fromQueryString.apply(Ext.Object, arguments);
+};
-
- getXY : function(){
- return this.xy;
- },
+})();
-
- getTarget : function(selector, maxDepth, returnEl){
- return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : (returnEl ? Ext.get(this.target) : this.target);
- },
-
- getRelatedTarget : function(){
- return this.browserEvent ? E.getRelatedTarget(this.browserEvent) : null;
- },
-
- getWheelDelta : function(){
- var e = this.browserEvent;
- var delta = 0;
- if(e.wheelDelta){
- delta = e.wheelDelta/120;
- }else if(e.detail){
- delta = -e.detail/3;
- }
- return delta;
- },
-
- within : function(el, related, allowEl){
- if(el){
- var t = this[related ? "getRelatedTarget" : "getTarget"]();
- return t && ((allowEl ? (t == Ext.getDom(el)) : false) || Ext.fly(el).contains(t));
- }
- return false;
- }
- };
- return new Ext.EventObjectImpl();
-}();
+(function() {
-Ext.apply(Ext.EventManager, function(){
- var resizeEvent,
- resizeTask,
- textEvent,
- textSize,
- D = Ext.lib.Dom,
- propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,
- curWidth = 0,
- curHeight = 0,
-
-
-
- useKeydown = Ext.isWebKit ?
- Ext.num(navigator.userAgent.match(/AppleWebKit\/(\d+)/)[1]) >= 525 :
- !((Ext.isGecko && !Ext.isWindows) || Ext.isOpera);
- return {
-
- doResizeEvent: function(){
- var h = D.getViewHeight(),
- w = D.getViewWidth();
-
- if(curHeight != h || curWidth != w){
- resizeEvent.fire(curWidth = w, curHeight = h);
- }
- },
+function xf(format) {
+ var args = Array.prototype.slice.call(arguments, 1);
+ return format.replace(/\{(\d+)\}/g, function(m, i) {
+ return args[i];
+ });
+}
-
- onWindowResize : function(fn, scope, options){
- if(!resizeEvent){
- resizeEvent = new Ext.util.Event();
- resizeTask = new Ext.util.DelayedTask(this.doResizeEvent);
- Ext.EventManager.on(window, "resize", this.fireWindowResize, this);
- }
- resizeEvent.addListener(fn, scope, options);
- },
+Ext.Date = {
+
+ now: Date.now || function() {
+ return +new Date();
+ },
-
- fireWindowResize : function(){
- if(resizeEvent){
- if((Ext.isIE||Ext.isAir) && resizeTask){
- resizeTask.delay(50);
- }else{
- resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
- }
- }
- },
+
+ toString: function(date) {
+ var pad = Ext.String.leftPad;
-
- onTextResize : function(fn, scope, options){
- if(!textEvent){
- textEvent = new Ext.util.Event();
- var textEl = new Ext.Element(document.createElement('div'));
- textEl.dom.className = 'x-text-resize';
- textEl.dom.innerHTML = 'X';
- textEl.appendTo(document.body);
- textSize = textEl.dom.offsetHeight;
- setInterval(function(){
- if(textEl.dom.offsetHeight != textSize){
- textEvent.fire(textSize, textSize = textEl.dom.offsetHeight);
- }
- }, this.textResizeInterval);
- }
- textEvent.addListener(fn, scope, options);
- },
+ return date.getFullYear() + "-"
+ + pad(date.getMonth() + 1, 2, '0') + "-"
+ + pad(date.getDate(), 2, '0') + "T"
+ + pad(date.getHours(), 2, '0') + ":"
+ + pad(date.getMinutes(), 2, '0') + ":"
+ + pad(date.getSeconds(), 2, '0');
+ },
-
- removeResizeListener : function(fn, scope){
- if(resizeEvent){
- resizeEvent.removeListener(fn, scope);
- }
- },
+
+ getElapsed: function(dateA, dateB) {
+ return Math.abs(dateA - (dateB || new Date()));
+ },
-
- fireResize : function(){
- if(resizeEvent){
- resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
- }
- },
+
+ useStrict: false,
+
+ formatCodeToRegex: function(character, currentGroup) {
- textResizeInterval : 50,
-
-
- ieDeferSrc : false,
-
-
-
- useKeydown: useKeydown
- };
-}());
-
-Ext.EventManager.on = Ext.EventManager.addListener;
-
-
-Ext.apply(Ext.EventObjectImpl.prototype, {
-
- BACKSPACE: 8,
-
- TAB: 9,
-
- NUM_CENTER: 12,
-
- ENTER: 13,
-
- RETURN: 13,
-
- SHIFT: 16,
-
- CTRL: 17,
- CONTROL : 17,
-
- ALT: 18,
-
- PAUSE: 19,
-
- CAPS_LOCK: 20,
-
- ESC: 27,
-
- SPACE: 32,
-
- PAGE_UP: 33,
- PAGEUP : 33,
-
- PAGE_DOWN: 34,
- PAGEDOWN : 34,
-
- END: 35,
-
- HOME: 36,
-
- LEFT: 37,
-
- UP: 38,
-
- RIGHT: 39,
-
- DOWN: 40,
-
- PRINT_SCREEN: 44,
-
- INSERT: 45,
-
- DELETE: 46,
-
- ZERO: 48,
-
- ONE: 49,
-
- TWO: 50,
-
- THREE: 51,
-
- FOUR: 52,
-
- FIVE: 53,
-
- SIX: 54,
-
- SEVEN: 55,
-
- EIGHT: 56,
-
- NINE: 57,
-
- A: 65,
-
- B: 66,
-
- C: 67,
-
- D: 68,
-
- E: 69,
-
- F: 70,
-
- G: 71,
-
- H: 72,
-
- I: 73,
-
- J: 74,
-
- K: 75,
-
- L: 76,
-
- M: 77,
-
- N: 78,
-
- O: 79,
-
- P: 80,
-
- Q: 81,
-
- R: 82,
-
- S: 83,
-
- T: 84,
-
- U: 85,
-
- V: 86,
-
- W: 87,
-
- X: 88,
-
- Y: 89,
-
- Z: 90,
-
- CONTEXT_MENU: 93,
-
- NUM_ZERO: 96,
-
- NUM_ONE: 97,
-
- NUM_TWO: 98,
-
- NUM_THREE: 99,
-
- NUM_FOUR: 100,
-
- NUM_FIVE: 101,
-
- NUM_SIX: 102,
-
- NUM_SEVEN: 103,
-
- NUM_EIGHT: 104,
-
- NUM_NINE: 105,
-
- NUM_MULTIPLY: 106,
-
- NUM_PLUS: 107,
-
- NUM_MINUS: 109,
-
- NUM_PERIOD: 110,
-
- NUM_DIVISION: 111,
-
- F1: 112,
-
- F2: 113,
-
- F3: 114,
-
- F4: 115,
-
- F5: 116,
-
- F6: 117,
-
- F7: 118,
-
- F8: 119,
-
- F9: 120,
-
- F10: 121,
-
- F11: 122,
-
- F12: 123,
-
-
- isNavKeyPress : function(){
- var me = this,
- k = this.normalizeKey(me.keyCode);
- return (k >= 33 && k <= 40) ||
- k == me.RETURN ||
- k == me.TAB ||
- k == me.ESC;
- },
-
- isSpecialKey : function(){
- var k = this.normalizeKey(this.keyCode);
- return (this.type == 'keypress' && this.ctrlKey) ||
- this.isNavKeyPress() ||
- (k == this.BACKSPACE) ||
- (k >= 16 && k <= 20) ||
- (k >= 44 && k <= 45);
- },
-
- getPoint : function(){
- return new Ext.lib.Point(this.xy[0], this.xy[1]);
- },
-
-
- hasModifier : function(){
- return ((this.ctrlKey || this.altKey) || this.shiftKey);
- }
-});
-(function(){
-var DOC = document;
-
-Ext.Element = function(element, forceNew){
- var dom = typeof element == "string" ?
- DOC.getElementById(element) : element,
- id;
-
- if(!dom) return null;
+ var p = utilDate.parseCodes[character];
- id = dom.id;
-
- if(!forceNew && id && Ext.elCache[id]){
- return Ext.elCache[id].el;
- }
+ if (p) {
+ p = typeof p == 'function'? p() : p;
+ utilDate.parseCodes[character] = p;
+ }
-
- this.dom = dom;
+ return p ? Ext.applyIf({
+ c: p.c ? xf(p.c, currentGroup || "{0}") : p.c
+ }, p) : {
+ g: 0,
+ c: null,
+ s: Ext.String.escapeRegex(character)
+ };
+ },
- this.id = id || Ext.id(dom);
-};
-
-var D = Ext.lib.Dom,
- DH = Ext.DomHelper,
- E = Ext.lib.Event,
- A = Ext.lib.Anim,
- El = Ext.Element,
- EC = Ext.elCache;
+ parseFunctions: {
+ "MS": function(input, strict) {
+
+
+ var re = new RegExp('\\/Date\\(([-+])?(\\d+)(?:[+-]\\d{4})?\\)\\/');
+ var r = (input || '').match(re);
+ return r? new Date(((r[1] || '') + r[2]) * 1) : null;
+ }
+ },
+ parseRegexes: [],
-El.prototype = {
- set : function(o, useSet){
- var el = this.dom,
- attr,
- val,
- useSet = (useSet !== false) && !!el.setAttribute;
-
- for(attr in o){
- if (o.hasOwnProperty(attr)) {
- val = o[attr];
- if (attr == 'style') {
- DH.applyStyles(el, val);
- } else if (attr == 'cls') {
- el.className = val;
- } else if (useSet) {
- el.setAttribute(attr, val);
- } else {
- el[attr] = val;
- }
- }
+ formatFunctions: {
+ "MS": function() {
+
+ return '\\/Date(' + this.getTime() + ')\\/';
}
- return this;
},
+ y2kYear : 50,
-
-
-
-
-
-
-
-
-
-
+ MILLI : "ms",
-
-
-
-
+ SECOND : "s",
-
-
-
-
-
-
+ MINUTE : "mi",
-
-
-
-
-
-
+ HOUR : "h",
-
-
-
+ DAY : "d",
-
-
-
-
-
-
+ MONTH : "mo",
- defaultUnit : "px",
+ YEAR : "y",
- is : function(simpleSelector){
- return Ext.DomQuery.is(this.dom, simpleSelector);
- },
+ defaults: {},
- focus : function(defer, dom) {
- var me = this,
- dom = dom || me.dom;
- try{
- if(Number(defer)){
- me.focus.defer(defer, null, [null, dom]);
- }else{
- dom.focus();
- }
- }catch(e){}
- return me;
- },
+ dayNames : [
+ "Sunday",
+ "Monday",
+ "Tuesday",
+ "Wednesday",
+ "Thursday",
+ "Friday",
+ "Saturday"
+ ],
- blur : function() {
- try{
- this.dom.blur();
- }catch(e){}
- return this;
- },
+ monthNames : [
+ "January",
+ "February",
+ "March",
+ "April",
+ "May",
+ "June",
+ "July",
+ "August",
+ "September",
+ "October",
+ "November",
+ "December"
+ ],
- getValue : function(asNumber){
- var val = this.dom.value;
- return asNumber ? parseInt(val, 10) : val;
+ monthNumbers : {
+ Jan:0,
+ Feb:1,
+ Mar:2,
+ Apr:3,
+ May:4,
+ Jun:5,
+ Jul:6,
+ Aug:7,
+ Sep:8,
+ Oct:9,
+ Nov:10,
+ Dec:11
},
-
- addListener : function(eventName, fn, scope, options){
- Ext.EventManager.on(this.dom, eventName, fn, scope || this, options);
- return this;
- },
-
+ defaultFormat : "m/d/Y",
- removeListener : function(eventName, fn, scope){
- Ext.EventManager.removeListener(this.dom, eventName, fn, scope || this);
- return this;
+ getShortMonthName : function(month) {
+ return utilDate.monthNames[month].substring(0, 3);
},
- removeAllListeners : function(){
- Ext.EventManager.removeAll(this.dom);
- return this;
+ getShortDayName : function(day) {
+ return utilDate.dayNames[day].substring(0, 3);
},
- purgeAllListeners : function() {
- Ext.EventManager.purgeElement(this, true);
- return this;
- },
-
- addUnits : function(size){
- if(size === "" || size == "auto" || size === undefined){
- size = size || '';
- } else if(!isNaN(size) || !unitPattern.test(size)){
- size = size + (this.defaultUnit || 'px');
- }
- return size;
+ getMonthNumber : function(name) {
+
+ return utilDate.monthNumbers[name.substring(0, 1).toUpperCase() + name.substring(1, 3).toLowerCase()];
},
- load : function(url, params, cb){
- Ext.Ajax.request(Ext.apply({
- params: params,
- url: url.url || url,
- callback: cb,
- el: this.dom,
- indicatorText: url.indicatorText || ''
- }, Ext.isObject(url) ? url : {}));
- return this;
- },
+ formatContainsHourInfo : (function(){
+ var stripEscapeRe = /(\\.)/g,
+ hourInfoRe = /([gGhHisucUOPZ]|MS)/;
+ return function(format){
+ return hourInfoRe.test(format.replace(stripEscapeRe, ''));
+ };
+ })(),
- isBorderBox : function(){
- return noBoxAdjust[(this.dom.tagName || "").toLowerCase()] || Ext.isBorderBox;
- },
+ formatContainsDateInfo : (function(){
+ var stripEscapeRe = /(\\.)/g,
+ dateInfoRe = /([djzmnYycU]|MS)/;
+
+ return function(format){
+ return dateInfoRe.test(format.replace(stripEscapeRe, ''));
+ };
+ })(),
- remove : function(){
- var me = this,
- dom = me.dom;
+ formatCodes : {
+ d: "Ext.String.leftPad(this.getDate(), 2, '0')",
+ D: "Ext.Date.getShortDayName(this.getDay())",
+ j: "this.getDate()",
+ l: "Ext.Date.dayNames[this.getDay()]",
+ N: "(this.getDay() ? this.getDay() : 7)",
+ S: "Ext.Date.getSuffix(this)",
+ w: "this.getDay()",
+ z: "Ext.Date.getDayOfYear(this)",
+ W: "Ext.String.leftPad(Ext.Date.getWeekOfYear(this), 2, '0')",
+ F: "Ext.Date.monthNames[this.getMonth()]",
+ m: "Ext.String.leftPad(this.getMonth() + 1, 2, '0')",
+ M: "Ext.Date.getShortMonthName(this.getMonth())",
+ n: "(this.getMonth() + 1)",
+ t: "Ext.Date.getDaysInMonth(this)",
+ L: "(Ext.Date.isLeapYear(this) ? 1 : 0)",
+ o: "(this.getFullYear() + (Ext.Date.getWeekOfYear(this) == 1 && this.getMonth() > 0 ? +1 : (Ext.Date.getWeekOfYear(this) >= 52 && this.getMonth() < 11 ? -1 : 0)))",
+ Y: "Ext.String.leftPad(this.getFullYear(), 4, '0')",
+ y: "('' + this.getFullYear()).substring(2, 4)",
+ a: "(this.getHours() < 12 ? 'am' : 'pm')",
+ A: "(this.getHours() < 12 ? 'AM' : 'PM')",
+ g: "((this.getHours() % 12) ? this.getHours() % 12 : 12)",
+ G: "this.getHours()",
+ h: "Ext.String.leftPad((this.getHours() % 12) ? this.getHours() % 12 : 12, 2, '0')",
+ H: "Ext.String.leftPad(this.getHours(), 2, '0')",
+ i: "Ext.String.leftPad(this.getMinutes(), 2, '0')",
+ s: "Ext.String.leftPad(this.getSeconds(), 2, '0')",
+ u: "Ext.String.leftPad(this.getMilliseconds(), 3, '0')",
+ O: "Ext.Date.getGMTOffset(this)",
+ P: "Ext.Date.getGMTOffset(this, true)",
+ T: "Ext.Date.getTimezone(this)",
+ Z: "(this.getTimezoneOffset() * -60)",
- if (dom) {
- delete me.dom;
- Ext.removeNode(dom);
- }
+ c: function() {
+ for (var c = "Y-m-dTH:i:sP", code = [], i = 0, l = c.length; i < l; ++i) {
+ var e = c.charAt(i);
+ code.push(e == "T" ? "'T'" : utilDate.getFormatCode(e));
+ }
+ return code.join(" + ");
+ },
+
+
+ U: "Math.round(this.getTime() / 1000)"
},
- hover : function(overFn, outFn, scope, options){
- var me = this;
- me.on('mouseenter', overFn, scope || me.dom, options);
- me.on('mouseleave', outFn, scope || me.dom, options);
- return me;
+ isValid : function(y, m, d, h, i, s, ms) {
+
+ h = h || 0;
+ i = i || 0;
+ s = s || 0;
+ ms = ms || 0;
+
+
+ var dt = utilDate.add(new Date(y < 100 ? 100 : y, m - 1, d, h, i, s, ms), utilDate.YEAR, y < 100 ? y - 100 : 0);
+
+ return y == dt.getFullYear() &&
+ m == dt.getMonth() + 1 &&
+ d == dt.getDate() &&
+ h == dt.getHours() &&
+ i == dt.getMinutes() &&
+ s == dt.getSeconds() &&
+ ms == dt.getMilliseconds();
},
- contains : function(el){
- return !el ? false : Ext.lib.Dom.isAncestor(this.dom, el.dom ? el.dom : el);
+ parse : function(input, format, strict) {
+ var p = utilDate.parseFunctions;
+ if (p[format] == null) {
+ utilDate.createParser(format);
+ }
+ return p[format](input, Ext.isDefined(strict) ? strict : utilDate.useStrict);
},
- getAttributeNS : function(ns, name){
- return this.getAttribute(name, ns);
+ parseDate: function(input, format, strict){
+ return utilDate.parse(input, format, strict);
},
+
- getAttribute : Ext.isIE ? function(name, ns){
- var d = this.dom,
- type = typeof d[ns + ":" + name];
+ getFormatCode : function(character) {
+ var f = utilDate.formatCodes[character];
- if(['undefined', 'unknown'].indexOf(type) == -1){
- return d[ns + ":" + name];
+ if (f) {
+ f = typeof f == 'function'? f() : f;
+ utilDate.formatCodes[character] = f;
}
- return d[name];
- } : function(name, ns){
- var d = this.dom;
- return d.getAttributeNS(ns, name) || d.getAttribute(ns + ":" + name) || d.getAttribute(name) || d[name];
+
+
+ return f || ("'" + Ext.String.escape(character) + "'");
},
- update : function(html) {
- if (this.dom) {
- this.dom.innerHTML = html;
- }
- return this;
- }
-};
+ createFormat : function(format) {
+ var code = [],
+ special = false,
+ ch = '';
-var ep = El.prototype;
-
-El.addMethods = function(o){
- Ext.apply(ep, o);
-};
-
-
-ep.on = ep.addListener;
-
-
-ep.un = ep.removeListener;
-
-
-ep.autoBoxAdjust = true;
-
-
-var unitPattern = /\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i,
- docEl;
+ for (var i = 0; i < format.length; ++i) {
+ ch = format.charAt(i);
+ if (!special && ch == "\\") {
+ special = true;
+ } else if (special) {
+ special = false;
+ code.push("'" + Ext.String.escape(ch) + "'");
+ } else {
+ code.push(utilDate.getFormatCode(ch));
+ }
+ }
+ utilDate.formatFunctions[format] = Ext.functionFactory("return " + code.join('+'));
+ },
+
+ createParser : (function() {
+ var code = [
+ "var dt, y, m, d, h, i, s, ms, o, z, zz, u, v,",
+ "def = Ext.Date.defaults,",
+ "results = String(input).match(Ext.Date.parseRegexes[{0}]);",
+ "if(results){",
+ "{1}",
+ "if(u != null){",
+ "v = new Date(u * 1000);",
+ "}else{",
+
+
+
+ "dt = Ext.Date.clearTime(new Date);",
-El.get = function(el){
- var ex,
- elm,
- id;
- if(!el){ return null; }
- if (typeof el == "string") {
- if (!(elm = DOC.getElementById(el))) {
- return null;
- }
- if (EC[el] && EC[el].el) {
- ex = EC[el].el;
- ex.dom = elm;
- } else {
- ex = El.addToCache(new El(elm));
- }
- return ex;
- } else if (el.tagName) {
- if(!(id = el.id)){
- id = Ext.id(el);
- }
- if (EC[id] && EC[id].el) {
- ex = EC[id].el;
- ex.dom = el;
- } else {
- ex = El.addToCache(new El(el));
- }
- return ex;
- } else if (el instanceof El) {
- if(el != docEl){
- el.dom = DOC.getElementById(el.id) || el.dom;
-
- }
- return el;
- } else if(el.isComposite) {
- return el;
- } else if(Ext.isArray(el)) {
- return El.select(el);
- } else if(el == DOC) {
-
- if(!docEl){
- var f = function(){};
- f.prototype = El.prototype;
- docEl = new f();
- docEl.dom = DOC;
- }
- return docEl;
- }
- return null;
-};
+
+ "y = Ext.Number.from(y, Ext.Number.from(def.y, dt.getFullYear()));",
+ "m = Ext.Number.from(m, Ext.Number.from(def.m - 1, dt.getMonth()));",
+ "d = Ext.Number.from(d, Ext.Number.from(def.d, dt.getDate()));",
-El.addToCache = function(el, id){
- id = id || el.id;
- EC[id] = {
- el: el,
- data: {},
- events: {}
- };
- return el;
-};
+
+ "h = Ext.Number.from(h, Ext.Number.from(def.h, dt.getHours()));",
+ "i = Ext.Number.from(i, Ext.Number.from(def.i, dt.getMinutes()));",
+ "s = Ext.Number.from(s, Ext.Number.from(def.s, dt.getSeconds()));",
+ "ms = Ext.Number.from(ms, Ext.Number.from(def.ms, dt.getMilliseconds()));",
+ "if(z >= 0 && y >= 0){",
+
+
-El.data = function(el, key, value){
- el = El.get(el);
- if (!el) {
- return null;
- }
- var c = EC[el.id].data;
- if(arguments.length == 2){
- return c[key];
- }else{
- return (c[key] = value);
- }
-};
+
+
+ "v = Ext.Date.add(new Date(y < 100 ? 100 : y, 0, 1, h, i, s, ms), Ext.Date.YEAR, y < 100 ? y - 100 : 0);",
+
+ "v = !strict? v : (strict === true && (z <= 364 || (Ext.Date.isLeapYear(v) && z <= 365))? Ext.Date.add(v, Ext.Date.DAY, z) : null);",
+ "}else if(strict === true && !Ext.Date.isValid(y, m + 1, d, h, i, s, ms)){",
+ "v = null;",
+ "}else{",
+
+
+ "v = Ext.Date.add(new Date(y < 100 ? 100 : y, m, d, h, i, s, ms), Ext.Date.YEAR, y < 100 ? y - 100 : 0);",
+ "}",
+ "}",
+ "}",
+ "if(v){",
+
+ "if(zz != null){",
+
+ "v = Ext.Date.add(v, Ext.Date.SECOND, -v.getTimezoneOffset() * 60 - zz);",
+ "}else if(o){",
+
+ "v = Ext.Date.add(v, Ext.Date.MINUTE, -v.getTimezoneOffset() + (sn == '+'? -1 : 1) * (hr * 60 + mn));",
+ "}",
+ "}",
+ "return v;"
+ ].join('\n');
-function garbageCollect(){
- if(!Ext.enableGarbageCollector){
- clearInterval(El.collectorThreadId);
- } else {
- var eid,
- el,
- d,
- o;
+ return function(format) {
+ var regexNum = utilDate.parseRegexes.length,
+ currentGroup = 1,
+ calc = [],
+ regex = [],
+ special = false,
+ ch = "";
- for(eid in EC){
- o = EC[eid];
- if(o.skipGC){
- continue;
- }
- el = o.el;
- d = el.dom;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if(!d || !d.parentNode || (!d.offsetParent && !DOC.getElementById(eid))){
- if(Ext.enableListenerCollection){
- Ext.EventManager.removeAll(d);
+ for (var i = 0; i < format.length; ++i) {
+ ch = format.charAt(i);
+ if (!special && ch == "\\") {
+ special = true;
+ } else if (special) {
+ special = false;
+ regex.push(Ext.String.escape(ch));
+ } else {
+ var obj = utilDate.formatCodeToRegex(ch, currentGroup);
+ currentGroup += obj.g;
+ regex.push(obj.s);
+ if (obj.g && obj.c) {
+ calc.push(obj.c);
+ }
}
- delete EC[eid];
}
- }
+
+ utilDate.parseRegexes[regexNum] = new RegExp("^" + regex.join('') + "$", 'i');
+ utilDate.parseFunctions[format] = Ext.functionFactory("input", "strict", xf(code, regexNum, calc.join('')));
+ };
+ })(),
+
+
+ parseCodes : {
- if (Ext.isIE) {
- var t = {};
- for (eid in EC) {
- t[eid] = EC[eid];
- }
- EC = Ext.elCache = t;
- }
- }
-}
-El.collectorThreadId = setInterval(garbageCollect, 30000);
+ d: {
+ g:1,
+ c:"d = parseInt(results[{0}], 10);\n",
+ s:"(\\d{2})"
+ },
+ j: {
+ g:1,
+ c:"d = parseInt(results[{0}], 10);\n",
+ s:"(\\d{1,2})"
+ },
+ D: function() {
+ for (var a = [], i = 0; i < 7; a.push(utilDate.getShortDayName(i)), ++i);
+ return {
+ g:0,
+ c:null,
+ s:"(?:" + a.join("|") +")"
+ };
+ },
+ l: function() {
+ return {
+ g:0,
+ c:null,
+ s:"(?:" + utilDate.dayNames.join("|") + ")"
+ };
+ },
+ N: {
+ g:0,
+ c:null,
+ s:"[1-7]"
+ },
+ S: {
+ g:0,
+ c:null,
+ s:"(?:st|nd|rd|th)"
+ },
+ w: {
+ g:0,
+ c:null,
+ s:"[0-6]"
+ },
+ z: {
+ g:1,
+ c:"z = parseInt(results[{0}], 10);\n",
+ s:"(\\d{1,3})"
+ },
+ W: {
+ g:0,
+ c:null,
+ s:"(?:\\d{2})"
+ },
+ F: function() {
+ return {
+ g:1,
+ c:"m = parseInt(Ext.Date.getMonthNumber(results[{0}]), 10);\n",
+ s:"(" + utilDate.monthNames.join("|") + ")"
+ };
+ },
+ M: function() {
+ for (var a = [], i = 0; i < 12; a.push(utilDate.getShortMonthName(i)), ++i);
+ return Ext.applyIf({
+ s:"(" + a.join("|") + ")"
+ }, utilDate.formatCodeToRegex("F"));
+ },
+ m: {
+ g:1,
+ c:"m = parseInt(results[{0}], 10) - 1;\n",
+ s:"(\\d{2})"
+ },
+ n: {
+ g:1,
+ c:"m = parseInt(results[{0}], 10) - 1;\n",
+ s:"(\\d{1,2})"
+ },
+ t: {
+ g:0,
+ c:null,
+ s:"(?:\\d{2})"
+ },
+ L: {
+ g:0,
+ c:null,
+ s:"(?:1|0)"
+ },
+ o: function() {
+ return utilDate.formatCodeToRegex("Y");
+ },
+ Y: {
+ g:1,
+ c:"y = parseInt(results[{0}], 10);\n",
+ s:"(\\d{4})"
+ },
+ y: {
+ g:1,
+ c:"var ty = parseInt(results[{0}], 10);\n"
+ + "y = ty > Ext.Date.y2kYear ? 1900 + ty : 2000 + ty;\n",
+ s:"(\\d{1,2})"
+ },
+
+ a: {
+ g:1,
+ c:"if (/(am)/i.test(results[{0}])) {\n"
+ + "if (!h || h == 12) { h = 0; }\n"
+ + "} else { if (!h || h < 12) { h = (h || 0) + 12; }}",
+ s:"(am|pm|AM|PM)"
+ },
+ A: {
+ g:1,
+ c:"if (/(am)/i.test(results[{0}])) {\n"
+ + "if (!h || h == 12) { h = 0; }\n"
+ + "} else { if (!h || h < 12) { h = (h || 0) + 12; }}",
+ s:"(AM|PM|am|pm)"
+ },
+ g: function() {
+ return utilDate.formatCodeToRegex("G");
+ },
+ G: {
+ g:1,
+ c:"h = parseInt(results[{0}], 10);\n",
+ s:"(\\d{1,2})"
+ },
+ h: function() {
+ return utilDate.formatCodeToRegex("H");
+ },
+ H: {
+ g:1,
+ c:"h = parseInt(results[{0}], 10);\n",
+ s:"(\\d{2})"
+ },
+ i: {
+ g:1,
+ c:"i = parseInt(results[{0}], 10);\n",
+ s:"(\\d{2})"
+ },
+ s: {
+ g:1,
+ c:"s = parseInt(results[{0}], 10);\n",
+ s:"(\\d{2})"
+ },
+ u: {
+ g:1,
+ c:"ms = results[{0}]; ms = parseInt(ms, 10)/Math.pow(10, ms.length - 3);\n",
+ s:"(\\d+)"
+ },
+ O: {
+ g:1,
+ c:[
+ "o = results[{0}];",
+ "var sn = o.substring(0,1),",
+ "hr = o.substring(1,3)*1 + Math.floor(o.substring(3,5) / 60),",
+ "mn = o.substring(3,5) % 60;",
+ "o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))? (sn + Ext.String.leftPad(hr, 2, '0') + Ext.String.leftPad(mn, 2, '0')) : null;\n"
+ ].join("\n"),
+ s: "([+\-]\\d{4})"
+ },
+ P: {
+ g:1,
+ c:[
+ "o = results[{0}];",
+ "var sn = o.substring(0,1),",
+ "hr = o.substring(1,3)*1 + Math.floor(o.substring(4,6) / 60),",
+ "mn = o.substring(4,6) % 60;",
+ "o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))? (sn + Ext.String.leftPad(hr, 2, '0') + Ext.String.leftPad(mn, 2, '0')) : null;\n"
+ ].join("\n"),
+ s: "([+\-]\\d{2}:\\d{2})"
+ },
+ T: {
+ g:0,
+ c:null,
+ s:"[A-Z]{1,4}"
+ },
+ Z: {
+ g:1,
+ c:"zz = results[{0}] * 1;\n"
+ + "zz = (-43200 <= zz && zz <= 50400)? zz : null;\n",
+ s:"([+\-]?\\d{1,5})"
+ },
+ c: function() {
+ var calc = [],
+ arr = [
+ utilDate.formatCodeToRegex("Y", 1),
+ utilDate.formatCodeToRegex("m", 2),
+ utilDate.formatCodeToRegex("d", 3),
+ utilDate.formatCodeToRegex("h", 4),
+ utilDate.formatCodeToRegex("i", 5),
+ utilDate.formatCodeToRegex("s", 6),
+ {c:"ms = results[7] || '0'; ms = parseInt(ms, 10)/Math.pow(10, ms.length - 3);\n"},
+ {c:[
+ "if(results[8]) {",
+ "if(results[8] == 'Z'){",
+ "zz = 0;",
+ "}else if (results[8].indexOf(':') > -1){",
+ utilDate.formatCodeToRegex("P", 8).c,
+ "}else{",
+ utilDate.formatCodeToRegex("O", 8).c,
+ "}",
+ "}"
+ ].join('\n')}
+ ];
-var flyFn = function(){};
-flyFn.prototype = El.prototype;
+ for (var i = 0, l = arr.length; i < l; ++i) {
+ calc.push(arr[i].c);
+ }
+ return {
+ g:1,
+ c:calc.join(""),
+ s:[
+ arr[0].s,
+ "(?:", "-", arr[1].s,
+ "(?:", "-", arr[2].s,
+ "(?:",
+ "(?:T| )?",
+ arr[3].s, ":", arr[4].s,
+ "(?::", arr[5].s, ")?",
+ "(?:(?:\\.|,)(\\d+))?",
+ "(Z|(?:[-+]\\d{2}(?::)?\\d{2}))?",
+ ")?",
+ ")?",
+ ")?"
+ ].join("")
+ };
+ },
+ U: {
+ g:1,
+ c:"u = parseInt(results[{0}], 10);\n",
+ s:"(-?\\d+)"
+ }
+ },
-El.Flyweight = function(dom){
- this.dom = dom;
-};
+
+
+ dateFormat: function(date, format) {
+ return utilDate.format(date, format);
+ },
-El.Flyweight.prototype = new flyFn();
-El.Flyweight.prototype.isFlyweight = true;
-El._flyweights = {};
+
+ format: function(date, format) {
+ if (utilDate.formatFunctions[format] == null) {
+ utilDate.createFormat(format);
+ }
+ var result = utilDate.formatFunctions[format].call(date);
+ return result + '';
+ },
+
+ getTimezone : function(date) {
+
+
+
+
+
+
+
+
+
+
+
+
+ return date.toString().replace(/^.* (?:\((.*)\)|([A-Z]{1,4})(?:[\-+][0-9]{4})?(?: -?\d+)?)$/, "$1$2").replace(/[^A-Z]/g, "");
+ },
-El.fly = function(el, named){
- var ret = null;
- named = named || '_global';
+
+ getGMTOffset : function(date, colon) {
+ var offset = date.getTimezoneOffset();
+ return (offset > 0 ? "-" : "+")
+ + Ext.String.leftPad(Math.floor(Math.abs(offset) / 60), 2, "0")
+ + (colon ? ":" : "")
+ + Ext.String.leftPad(Math.abs(offset % 60), 2, "0");
+ },
- if (el = Ext.getDom(el)) {
- (El._flyweights[named] = El._flyweights[named] || new El.Flyweight()).dom = el;
- ret = El._flyweights[named];
- }
- return ret;
-};
+
+ getDayOfYear: function(date) {
+ var num = 0,
+ d = Ext.Date.clone(date),
+ m = date.getMonth(),
+ i;
+ for (i = 0, d.setDate(1), d.setMonth(0); i < m; d.setMonth(++i)) {
+ num += utilDate.getDaysInMonth(d);
+ }
+ return num + date.getDate() - 1;
+ },
-Ext.get = El.get;
+
+ getWeekOfYear : (function() {
+
+ var ms1d = 864e5,
+ ms7d = 7 * ms1d;
+ return function(date) {
+ var DC3 = Date.UTC(date.getFullYear(), date.getMonth(), date.getDate() + 3) / ms1d,
+ AWN = Math.floor(DC3 / 7),
+ Wyr = new Date(AWN * ms7d).getUTCFullYear();
-Ext.fly = El.fly;
+ return AWN - Math.floor(Date.UTC(Wyr, 0, 7) / ms7d) + 1;
+ };
+ })(),
+
+ isLeapYear : function(date) {
+ var year = date.getFullYear();
+ return !!((year & 3) == 0 && (year % 100 || (year % 400 == 0 && year)));
+ },
-var noBoxAdjust = Ext.isStrict ? {
- select:1
-} : {
- input:1, select:1, textarea:1
-};
-if(Ext.isIE || Ext.isGecko){
- noBoxAdjust['button'] = 1;
-}
+
+ getFirstDayOfMonth : function(date) {
+ var day = (date.getDay() - (date.getDate() - 1)) % 7;
+ return (day < 0) ? (day + 7) : day;
+ },
+
+ getLastDayOfMonth : function(date) {
+ return utilDate.getLastDateOfMonth(date).getDay();
+ },
-Ext.EventManager.on(window, 'unload', function(){
- delete EC;
- delete El._flyweights;
-});
-})();
-Ext.Element.addMethods({
- swallowEvent : function(eventName, preventDefault){
- var me = this;
- function fn(e){
- e.stopPropagation();
- if(preventDefault){
- e.preventDefault();
- }
- }
- if(Ext.isArray(eventName)){
- Ext.each(eventName, function(e) {
- me.on(e, fn);
- });
- return me;
- }
- me.on(eventName, fn);
- return me;
+ getFirstDateOfMonth : function(date) {
+ return new Date(date.getFullYear(), date.getMonth(), 1);
},
- relayEvent : function(eventName, observable){
- this.on(eventName, function(e){
- observable.fireEvent(eventName, e);
- });
+ getLastDateOfMonth : function(date) {
+ return new Date(date.getFullYear(), date.getMonth(), utilDate.getDaysInMonth(date));
},
- clean : function(forceReclean){
- var me = this,
- dom = me.dom,
- n = dom.firstChild,
- ni = -1;
+ getDaysInMonth: (function() {
+ var daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
- if(Ext.Element.data(dom, 'isCleaned') && forceReclean !== true){
- return me;
- }
+ return function(date) {
+ var m = date.getMonth();
- while(n){
- var nx = n.nextSibling;
- if(n.nodeType == 3 && !/\S/.test(n.nodeValue)){
- dom.removeChild(n);
- }else{
- n.nodeIndex = ++ni;
- }
- n = nx;
+ return m == 1 && utilDate.isLeapYear(date) ? 29 : daysInMonth[m];
+ };
+ })(),
+
+
+ getSuffix : function(date) {
+ switch (date.getDate()) {
+ case 1:
+ case 21:
+ case 31:
+ return "st";
+ case 2:
+ case 22:
+ return "nd";
+ case 3:
+ case 23:
+ return "rd";
+ default:
+ return "th";
}
- Ext.Element.data(dom, 'isCleaned', true);
- return me;
},
- load : function(){
- var um = this.getUpdater();
- um.update.apply(um, arguments);
- return this;
+ clone : function(date) {
+ return new Date(date.getTime());
},
- getUpdater : function(){
- return this.updateManager || (this.updateManager = new Ext.Updater(this));
+ isDST : function(date) {
+
+
+ return new Date(date.getFullYear(), 0, 1).getTimezoneOffset() != date.getTimezoneOffset();
},
- update : function(html, loadScripts, callback){
- if (!this.dom) {
- return this;
+ clearTime : function(date, clone) {
+ if (clone) {
+ return Ext.Date.clearTime(Ext.Date.clone(date));
}
- html = html || "";
- if(loadScripts !== true){
- this.dom.innerHTML = html;
- if(Ext.isFunction(callback)){
- callback();
- }
- return this;
+
+ var d = date.getDate();
+
+
+ date.setHours(0);
+ date.setMinutes(0);
+ date.setSeconds(0);
+ date.setMilliseconds(0);
+
+ if (date.getDate() != d) {
+
+
+
+
+ for (var hr = 1, c = utilDate.add(date, Ext.Date.HOUR, hr); c.getDate() != d; hr++, c = utilDate.add(date, Ext.Date.HOUR, hr));
+
+ date.setDate(d);
+ date.setHours(c.getHours());
}
- var id = Ext.id(),
- dom = this.dom;
+ return date;
+ },
- html += '';
-
- Ext.lib.Event.onAvailable(id, function(){
- var DOC = document,
- hd = DOC.getElementsByTagName("head")[0],
- re = /(?: