+(function(){
+
+var EXTUTIL = Ext.util,
+ EACH = Ext.each,
+ TRUE = true,
+ FALSE = false;
+
+EXTUTIL.Observable = function(){
+
+ var me = this, e = me.events;
+ if(me.listeners){
+ me.on(me.listeners);
+ delete me.listeners;
+ }
+ me.events = e || {};
+};
+
+EXTUTIL.Observable.prototype = {
+
+ filterOptRe : /^(?:scope|delay|buffer|single)$/,
+
+
+ fireEvent : function(){
+ var a = Array.prototype.slice.call(arguments, 0),
+ ename = a[0].toLowerCase(),
+ me = this,
+ ret = TRUE,
+ ce = me.events[ename],
+ cc,
+ q,
+ c;
+ if (me.eventsSuspended === TRUE) {
+ if (q = me.eventQueue) {
+ q.push(a);
+ }
+ }
+ else if(typeof ce == 'object') {
+ if (ce.bubble){
+ if(ce.fire.apply(ce, a.slice(1)) === FALSE) {
+ return FALSE;
+ }
+ c = me.getBubbleTarget && me.getBubbleTarget();
+ if(c && c.enableBubble) {
+ cc = c.events[ename];
+ if(!cc || typeof cc != 'object' || !cc.bubble) {
+ c.enableBubble(ename);
+ }
+ return c.fireEvent.apply(c, a);
+ }
+ }
+ else {
+ a.shift();
+ ret = ce.fire.apply(ce, a);
+ }
+ }
+ return ret;
+ },
+
+
+ addListener : function(eventName, fn, scope, o){
+ var me = this,
+ e,
+ oe,
+ ce;
+
+ if (typeof eventName == 'object') {
+ 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 (typeof ce == 'boolean') {
+ me.events[eventName] = ce = new EXTUTIL.Event(me, eventName);
+ }
+ ce.addListener(fn, scope, typeof o == 'object' ? o : {});
+ }
+ },
+
+
+ removeListener : function(eventName, fn, scope){
+ var ce = this.events[eventName.toLowerCase()];
+ if (typeof ce == 'object') {
+ ce.removeListener(fn, scope);
+ }
+ },
+
+
+ purgeListeners : function(){
+ var events = this.events,
+ evt,
+ key;
+ for(key in events){
+ evt = events[key];
+ if(typeof evt == 'object'){
+ evt.clearListeners();
+ }
+ }
+ },
+
+
+ addEvents : function(o){
+ var me = this;
+ me.events = me.events || {};
+ if (typeof o == 'string') {
+ var a = arguments,
+ i = a.length;
+ while(i--) {
+ me.events[a[i]] = me.events[a[i]] || TRUE;
+ }
+ } else {
+ Ext.applyIf(me.events, o);
+ }
+ },
+
+
+ hasListener : function(eventName){
+ var e = this.events[eventName.toLowerCase()];
+ return typeof e == 'object' && e.listeners.length > 0;
+ },
+
+
+ suspendEvents : function(queueSuspended){
+ this.eventsSuspended = TRUE;
+ if(queueSuspended && !this.eventQueue){
+ this.eventQueue = [];
+ }
+ },
+
+
+ resumeEvents : function(){
+ var me = this,
+ queued = me.eventQueue || [];
+ me.eventsSuspended = FALSE;
+ delete me.eventQueue;
+ EACH(queued, function(e) {
+ me.fireEvent.apply(me, e);
+ });
+ }
+};
+
+var OBSERVABLE = EXTUTIL.Observable.prototype;
+
+OBSERVABLE.on = OBSERVABLE.addListener;
+
+OBSERVABLE.un = OBSERVABLE.removeListener;
+
+
+EXTUTIL.Observable.releaseCapture = function(o){
+ o.fireEvent = OBSERVABLE.fireEvent;
+};
+
+function createTargeted(h, o, scope){
+ return function(){
+ if(o.target == arguments[0]){
+ h.apply(scope, Array.prototype.slice.call(arguments, 0));
+ }
+ };
+};
+
+function createBuffered(h, o, l, scope){
+ l.task = new EXTUTIL.DelayedTask();
+ return function(){
+ l.task.delay(o.buffer, h, scope, Array.prototype.slice.call(arguments, 0));
+ };
+};
+
+function createSingle(h, e, fn, scope){
+ return function(){
+ e.removeListener(fn, scope);
+ return h.apply(scope, arguments);
+ };
+};
+
+function createDelayed(h, o, l, scope){
+ return function(){
+ var task = new EXTUTIL.DelayedTask(),
+ args = Array.prototype.slice.call(arguments, 0);
+ if(!l.tasks) {
+ l.tasks = [];
+ }
+ l.tasks.push(task);
+ task.delay(o.delay || 10, function(){
+ l.tasks.remove(task);
+ h.apply(scope, args);
+ }, scope);
+ };
+};
+
+EXTUTIL.Event = function(obj, name){
+ this.name = name;
+ this.obj = obj;
+ this.listeners = [];
+};
+
+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);
+ }
+ },
+
+ 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, l, scope);
+ }
+ if(o.single){
+ h = createSingle(h, this, fn, scope);
+ }
+ if(o.buffer){
+ h = createBuffered(h, o, l, scope);
+ }
+ l.fireFn = h;
+ return l;
+ },
+
+ findListener : function(fn, scope){
+ var list = this.listeners,
+ i = list.length,
+ l;
+
+ scope = scope || this.obj;
+ while(i--){
+ l = list[i];
+ if(l){
+ if(l.fn == fn && l.scope == scope){
+ return i;
+ }
+ }
+ }
+ return -1;
+ },
+
+ isListening : function(fn, scope){
+ return this.findListener(fn, scope) != -1;
+ },
+
+ 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];
+ if(l.task) {
+ l.task.cancel();
+ delete l.task;
+ }
+ k = l.tasks && l.tasks.length;
+ if(k) {
+ while(k--) {
+ l.tasks[k].cancel();
+ }
+ delete l.tasks;
+ }
+ 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);
+ }
+ },
+
+ fire : function(){
+ var me = this,
+ listeners = me.listeners,
+ len = listeners.length,
+ i = 0,
+ l;
+
+ if(len > 0){
+ me.firing = TRUE;
+ var args = Array.prototype.slice.call(arguments, 0);
+ 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.DomHelper = function(){
var tempTableEl = null,
attr,
val,
key,
- keyVal,
cn;
if(typeof o == "string"){
applyStyles : function(el, styles){
- if(styles){
- var i = 0,
- len,
- style,
- matches;
+ if (styles) {
+ var matches;
el = Ext.fly(el);
- if(typeof styles == "function"){
+ if (typeof styles == "function") {
styles = styles.call();
}
- if(typeof styles == "string"){
- while((matches = cssRe.exec(styles))){
+ if (typeof styles == "string") {
+
+ cssRe.lastIndex = 0;
+ while ((matches = cssRe.exec(styles))) {
el.setStyle(matches[1], matches[2]);
}
- }else if (typeof styles == "object"){
+ } else if (typeof styles == "object") {
el.setStyle(styles);
}
}
return pub;
}();
-Ext.apply(Ext.DomHelper,
-function(){
- var pub,
- afterbegin = 'afterbegin',
- afterend = 'afterend',
- beforebegin = 'beforebegin',
- beforeend = 'beforeend',
- confRe = /tag|children|cn|html$/i;
-
-
- 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));
- }
- return returnElement ? Ext.get(newNode, true) : newNode;
- }
-
-
-
- function createDom(o, parentNode){
- var el,
- doc = document,
- useSet,
- attr,
- val,
- cn;
-
- if (Ext.isArray(o)) {
- el = doc.createDocumentFragment();
- for (var i = 0, l = o.length; i < l; i++) {
- createDom(o[i], el);
- }
- } else if (typeof o == 'string') {
- el = doc.createTextNode(o);
- } else {
- el = doc.createElement( o.tag || 'div' );
- useSet = !!el.setAttribute;
- for (var attr in o) {
- if(!confRe.test(attr)){
- val = o[attr];
- if(attr == 'cls'){
- el.className = val;
- }else{
- if(useSet){
- el.setAttribute(attr, val);
- }else{
- el[attr] = val;
- }
- }
- }
- }
- Ext.DomHelper.applyStyles(el, o.style);
-
- if ((cn = o.children || o.cn)) {
- createDom(cn, el);
- } else if (o.html) {
- el.innerHTML = o.html;
- }
- }
- if(parentNode){
- parentNode.appendChild(el);
- }
- return el;
- }
-
- pub = {
-
- createTemplate : function(o){
- var html = Ext.DomHelper.createHtml(o);
- return new Ext.Template(html);
- },
-
-
- useDom : false,
-
-
- insertBefore : function(el, o, returnElement){
- return doInsert(el, o, returnElement, beforebegin);
- },
-
-
- insertAfter : function(el, o, returnElement){
- return doInsert(el, o, returnElement, afterend, 'nextSibling');
- },
-
-
- insertFirst : function(el, o, returnElement){
- return doInsert(el, o, returnElement, afterbegin, 'firstChild');
- },
-
-
- append: function(el, o, returnElement){
- return doInsert(el, o, returnElement, beforeend, '', true);
- },
-
-
- createDom: createDom
- };
- return pub;
-}());
-
Ext.Template = function(html){
var me = this,
a = arguments,
return new Ext.Template(el.value || el.innerHTML, config || '');
};
-Ext.apply(Ext.Template.prototype, {
+
+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;
- disableFormats : false,
-
- re : /\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,
- argsRe : /^\s*['"](.*)["']\s*$/,
- compileARe : /\\/g,
- compileBRe : /(\r\n|\n)/g,
- compileCRe : /'/g,
-
- /**
- * Returns an HTML fragment of this template with the specified values applied.
- * @param {Object/Array} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
- * @return {String} The HTML fragment
- * @hide repeat doc
- */
- applyTemplate : function(values){
- var me = this,
- useF = me.disableFormats !== true,
- fm = Ext.util.Format,
- tpl = me;
+ eval("var batch = 30803;");
- if(me.compiled){
- return me.compiled(values);
- }
- 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) {
- // quoted values are required for strings in compiled templates,
- // but for non compiled we need to strip them
- // quoted reversed for jsmin
- var re = me.argsRe;
- 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] : "";
+
+
+ function child(parent, index){
+ var i = 0,
+ n = parent.firstChild;
+ while(n){
+ if(n.nodeType == 1){
+ if(++i == index){
+ return n;
+ }
}
+ n = n.nextSibling;
}
- return me.html.replace(me.re, fn);
- },
-
- /**
- * Compiles the template into an internal function, eliminating the RegEx overhead.
- * @return {Ext.Template} this
- * @hide repeat doc
- */
- 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+"'";
- }
-
- // branched to use + in gecko and [].join() in others
- if(Ext.isGecko){
- body = "this.compiled = function(values){ return '" +
- me.html.replace(me.compileARe, '\\\\').replace(me.compileBRe, '\\n').replace(me.compileCRe, "\\'").replace(me.re, fn) +
- "';};";
- }else{
- body = ["this.compiled = function(values){ return ['"];
- body.push(me.html.replace(me.compileARe, '\\\\').replace(me.compileBRe, '\\n').replace(me.compileCRe, "\\'").replace(me.re, fn));
- body.push("'].join('');};");
- body = body.join('');
- }
- eval(body);
- return me;
- },
-
- // private function used to call members
- call : function(fnName, value, allValues){
- return this[fnName](value, allValues);
- }
-});
-Ext.Template.prototype.apply = Ext.Template.prototype.applyTemplate;
-/*
- * This is code is also distributed under MIT license for use
- * with jQuery and prototype JavaScript libraries.
- */
-/**
- * @class Ext.DomQuery
-Provides high performance selector/xpath processing by compiling queries into reusable functions. New pseudo classes and matchers can be plugged. It works on HTML and XML documents (if a content node is passed in).
-<p>
-DomQuery supports most of the <a href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215/#selectors">CSS3 selectors spec</a>, along with some custom selectors and basic XPath.</p>
-
-<p>
-All selectors, attribute filters and pseudos below can be combined infinitely in any order. For example "div.foo:nth-child(odd)[@foo=bar].bar:first" would be a perfectly valid selector. Node filters are processed in the order in which they appear, which allows you to optimize your queries for your document structure.
-</p>
-<h4>Element Selectors:</h4>
-<ul class="list">
- <li> <b>*</b> any element</li>
- <li> <b>E</b> an element with the tag E</li>
- <li> <b>E F</b> All descendent elements of E that have the tag F</li>
- <li> <b>E > F</b> or <b>E/F</b> all direct children elements of E that have the tag F</li>
- <li> <b>E + F</b> all elements with the tag F that are immediately preceded by an element with the tag E</li>
- <li> <b>E ~ F</b> all elements with the tag F that are preceded by a sibling element with the tag E</li>
-</ul>
-<h4>Attribute Selectors:</h4>
-<p>The use of @ and quotes are optional. For example, div[@foo='bar'] is also a valid attribute selector.</p>
-<ul class="list">
- <li> <b>E[foo]</b> has an attribute "foo"</li>
- <li> <b>E[foo=bar]</b> has an attribute "foo" that equals "bar"</li>
- <li> <b>E[foo^=bar]</b> has an attribute "foo" that starts with "bar"</li>
- <li> <b>E[foo$=bar]</b> has an attribute "foo" that ends with "bar"</li>
- <li> <b>E[foo*=bar]</b> has an attribute "foo" that contains the substring "bar"</li>
- <li> <b>E[foo%=2]</b> has an attribute "foo" that is evenly divisible by 2</li>
- <li> <b>E[foo!=bar]</b> has an attribute "foo" that does not equal "bar"</li>
-</ul>
-<h4>Pseudo Classes:</h4>
-<ul class="list">
- <li> <b>E:first-child</b> E is the first child of its parent</li>
- <li> <b>E:last-child</b> E is the last child of its parent</li>
- <li> <b>E:nth-child(<i>n</i>)</b> E is the <i>n</i>th child of its parent (1 based as per the spec)</li>
- <li> <b>E:nth-child(odd)</b> E is an odd child of its parent</li>
- <li> <b>E:nth-child(even)</b> E is an even child of its parent</li>
- <li> <b>E:only-child</b> E is the only child of its parent</li>
- <li> <b>E:checked</b> E is an element that is has a checked attribute that is true (e.g. a radio or checkbox) </li>
- <li> <b>E:first</b> the first E in the resultset</li>
- <li> <b>E:last</b> the last E in the resultset</li>
- <li> <b>E:nth(<i>n</i>)</b> the <i>n</i>th E in the resultset (1 based)</li>
- <li> <b>E:odd</b> shortcut for :nth-child(odd)</li>
- <li> <b>E:even</b> shortcut for :nth-child(even)</li>
- <li> <b>E:contains(foo)</b> E's innerHTML contains the substring "foo"</li>
- <li> <b>E:nodeValue(foo)</b> E contains a textNode with a nodeValue that equals "foo"</li>
- <li> <b>E:not(S)</b> an E element that does not match simple selector S</li>
- <li> <b>E:has(S)</b> an E element that has a descendent that matches simple selector S</li>
- <li> <b>E:next(S)</b> an E element whose next sibling matches simple selector S</li>
- <li> <b>E:prev(S)</b> an E element whose previous sibling matches simple selector S</li>
- <li> <b>E:any(S1|S2|S2)</b> an E element which matches any of the simple selectors S1, S2 or S3
-</ul>
-<h4>CSS Value Selectors:</h4>
-<ul class="list">
- <li> <b>E{display=none}</b> css value "display" that equals "none"</li>
- <li> <b>E{display^=none}</b> css value "display" that starts with "none"</li>
- <li> <b>E{display$=none}</b> css value "display" that ends with "none"</li>
- <li> <b>E{display*=none}</b> css value "display" that contains the substring "none"</li>
- <li> <b>E{display%=2}</b> css value "display" that is evenly divisible by 2</li>
- <li> <b>E{display!=none}</b> css value "display" that does not equal "none"</li>
-</ul>
- * @singleton
- */
-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(parent, index){
- var i = 0,
- n = parent.firstChild;
- while(n){
- if(n.nodeType == 1){
- if(++i == index){
- return n;
- }
- }
- n = n.nextSibling;
- }
- return null;
- }
+ return null;
+ }
function next(n){
ri = -1,
useGetStyle = custom == "{",
fn = Ext.DomQuery.operators[op],
- a,
- innerHTML;
+ a,
+ xml,
+ hasXml;
+
for(var i = 0, ci; ci = cs[i]; i++){
if(ci.nodeType != 1){
continue;
}
+
+ if(!hasXml){
+ xml = Ext.DomQuery.isXml(ci);
+ hasXml = true;
+ }
- innerHTML = ci.innerHTML;
- if(innerHTML !== null && innerHTML !== undefined){
+ if(!xml){
if(useGetStyle){
a = Ext.DomQuery.getStyle(ci, attr);
} else if (attr == "class" || attr == "className"){
compile : function(path, type){
type = type || "select";
-
+
var fn = ["var f = function(root){\n var mode; ++batch; var n = root || document;\n"],
- mode,
- lastPath,
+ mode,
+ lastPath,
matchers = Ext.DomQuery.matchers,
matchersLn = matchers.length,
modeMatch,
id = null;
}
};
-};(function(){
+};
+(function(){
+var DOC = document;
-var EXTUTIL = Ext.util,
- EACH = Ext.each,
- TRUE = true,
- FALSE = false;
+Ext.Element = function(element, forceNew){
+ var dom = typeof element == "string" ?
+ DOC.getElementById(element) : element,
+ id;
-EXTUTIL.Observable = function(){
-
- var me = this, e = me.events;
- if(me.listeners){
- me.on(me.listeners);
- delete me.listeners;
+ if(!dom) return null;
+
+ id = dom.id;
+
+ if(!forceNew && id && Ext.elCache[id]){
+ return Ext.elCache[id].el;
}
- me.events = e || {};
-};
-EXTUTIL.Observable.prototype = {
- filterOptRe : /^(?:scope|delay|buffer|single)$/,
+ this.dom = dom;
- fireEvent : function(){
- var a = Array.prototype.slice.call(arguments, 0),
- ename = a[0].toLowerCase(),
- me = this,
- ret = TRUE,
- ce = me.events[ename],
- cc,
- q,
- c;
- if (me.eventsSuspended === TRUE) {
- if (q = me.eventQueue) {
- q.push(a);
- }
- }
- else if(typeof ce == 'object') {
- if (ce.bubble){
- if(ce.fire.apply(ce, a.slice(1)) === FALSE) {
- return FALSE;
- }
- c = me.getBubbleTarget && me.getBubbleTarget();
- if(c && c.enableBubble) {
- cc = c.events[ename];
- if(!cc || typeof cc != 'object' || !cc.bubble) {
- c.enableBubble(ename);
- }
- return c.fireEvent.apply(c, a);
+ this.id = id || Ext.id(dom);
+};
+
+var DH = Ext.DomHelper,
+ El = Ext.Element,
+ EC = Ext.elCache;
+
+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;
}
}
- else {
- a.shift();
- ret = ce.fire.apply(ce, a);
- }
}
- return ret;
+ return this;
},
+
- addListener : function(eventName, fn, scope, o){
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ defaultUnit : "px",
+
+
+ is : function(simpleSelector){
+ return Ext.DomQuery.is(this.dom, simpleSelector);
+ },
+
+
+ focus : function(defer, dom) {
var me = this,
- e,
- oe,
- isF,
- ce;
- if (typeof eventName == 'object') {
- 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 (typeof ce == 'boolean') {
- me.events[eventName] = ce = new EXTUTIL.Event(me, eventName);
+ dom = dom || me.dom;
+ try{
+ if(Number(defer)){
+ me.focus.defer(defer, null, [null, dom]);
+ }else{
+ dom.focus();
}
- ce.addListener(fn, scope, typeof o == 'object' ? o : {});
- }
+ }catch(e){}
+ return me;
+ },
+
+
+ blur : function() {
+ try{
+ this.dom.blur();
+ }catch(e){}
+ return this;
+ },
+
+
+ getValue : function(asNumber){
+ var val = this.dom.value;
+ return asNumber ? parseInt(val, 10) : val;
+ },
+
+
+ addListener : function(eventName, fn, scope, options){
+ Ext.EventManager.on(this.dom, eventName, fn, scope || this, options);
+ return this;
},
removeListener : function(eventName, fn, scope){
- var ce = this.events[eventName.toLowerCase()];
- if (typeof ce == 'object') {
- ce.removeListener(fn, scope);
+ Ext.EventManager.removeListener(this.dom, eventName, fn, scope || this);
+ return this;
+ },
+
+
+ removeAllListeners : function(){
+ Ext.EventManager.removeAll(this.dom);
+ return this;
+ },
+
+
+ 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;
},
- purgeListeners : function(){
- var events = this.events,
- evt,
- key;
- for(key in events){
- evt = events[key];
- if(typeof evt == 'object'){
- evt.clearListeners();
- }
+ 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;
+ },
+
+
+ isBorderBox : function(){
+ return Ext.isBorderBox || Ext.isForcedBorderBox || noBoxAdjust[(this.dom.tagName || "").toLowerCase()];
+ },
+
+
+ remove : function(){
+ var me = this,
+ dom = me.dom;
+
+ if (dom) {
+ delete me.dom;
+ Ext.removeNode(dom);
}
},
- addEvents : function(o){
+ hover : function(overFn, outFn, scope, options){
var me = this;
- me.events = me.events || {};
- if (typeof o == 'string') {
- var a = arguments,
- i = a.length;
- while(i--) {
- me.events[a[i]] = me.events[a[i]] || TRUE;
- }
- } else {
- Ext.applyIf(me.events, o);
- }
+ me.on('mouseenter', overFn, scope || me.dom, options);
+ me.on('mouseleave', outFn, scope || me.dom, options);
+ return me;
},
- hasListener : function(eventName){
- var e = this.events[eventName.toLowerCase()];
- return typeof e == 'object' && e.listeners.length > 0;
+ contains : function(el){
+ return !el ? false : Ext.lib.Dom.isAncestor(this.dom, el.dom ? el.dom : el);
},
- suspendEvents : function(queueSuspended){
- this.eventsSuspended = TRUE;
- if(queueSuspended && !this.eventQueue){
- this.eventQueue = [];
+ getAttributeNS : function(ns, name){
+ return this.getAttribute(name, ns);
+ },
+
+
+ getAttribute : Ext.isIE ? function(name, ns){
+ var d = this.dom,
+ type = typeof d[ns + ":" + name];
+
+ if(['undefined', 'unknown'].indexOf(type) == -1){
+ return d[ns + ":" + name];
}
+ return d[name];
+ } : function(name, ns){
+ var d = this.dom;
+ return d.getAttributeNS(ns, name) || d.getAttribute(ns + ":" + name) || d.getAttribute(name) || d[name];
},
- resumeEvents : function(){
- var me = this,
- queued = me.eventQueue || [];
- me.eventsSuspended = FALSE;
- delete me.eventQueue;
- EACH(queued, function(e) {
- me.fireEvent.apply(me, e);
- });
+ update : function(html) {
+ if (this.dom) {
+ this.dom.innerHTML = html;
+ }
+ return this;
}
};
-var OBSERVABLE = EXTUTIL.Observable.prototype;
+var ep = El.prototype;
-OBSERVABLE.on = OBSERVABLE.addListener;
+El.addMethods = function(o){
+ Ext.apply(ep, o);
+};
-OBSERVABLE.un = OBSERVABLE.removeListener;
+
+ep.on = ep.addListener;
-EXTUTIL.Observable.releaseCapture = function(o){
- o.fireEvent = OBSERVABLE.fireEvent;
-};
+ep.un = ep.removeListener;
-function createTargeted(h, o, scope){
- return function(){
- if(o.target == arguments[0]){
- h.apply(scope, Array.prototype.slice.call(arguments, 0));
- }
- };
-};
-function createBuffered(h, o, l, scope){
- l.task = new EXTUTIL.DelayedTask();
- return function(){
- l.task.delay(o.buffer, h, scope, Array.prototype.slice.call(arguments, 0));
- };
-};
+ep.autoBoxAdjust = true;
-function createSingle(h, e, fn, scope){
- return function(){
- e.removeListener(fn, scope);
- return h.apply(scope, arguments);
- };
-};
-function createDelayed(h, o, l, scope){
- return function(){
- var task = new EXTUTIL.DelayedTask();
- if(!l.tasks) {
- l.tasks = [];
- }
- l.tasks.push(task);
- task.delay(o.delay || 10, h, scope, Array.prototype.slice.call(arguments, 0));
- };
-};
+var unitPattern = /\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i,
+ docEl;
-EXTUTIL.Event = function(obj, name){
- this.name = name;
- this.obj = obj;
- this.listeners = [];
-};
-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);
- }
- },
- 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);
+
+El.get = function(el){
+ var ex,
+ elm,
+ id;
+ if(!el){ return null; }
+ if (typeof el == "string") {
+ if (!(elm = DOC.getElementById(el))) {
+ return null;
}
- if(o.delay){
- h = createDelayed(h, o, l, scope);
+ if (EC[el] && EC[el].el) {
+ ex = EC[el].el;
+ ex.dom = elm;
+ } else {
+ ex = El.addToCache(new El(elm));
}
- if(o.single){
- h = createSingle(h, this, fn, scope);
+ return ex;
+ } else if (el.tagName) {
+ if(!(id = el.id)){
+ id = Ext.id(el);
}
- if(o.buffer){
- h = createBuffered(h, o, l, scope);
+ if (EC[id] && EC[id].el) {
+ ex = EC[id].el;
+ ex.dom = el;
+ } else {
+ ex = El.addToCache(new El(el));
}
- l.fireFn = h;
- return l;
- },
-
- findListener : function(fn, scope){
- var list = this.listeners,
- i = list.length,
- l;
+ return ex;
+ } else if (el instanceof El) {
+ if(el != docEl){
+
+
- scope = scope || this.obj;
- while(i--){
- l = list[i];
- if(l){
- if(l.fn == fn && l.scope == scope){
- return i;
- }
+
+ if (Ext.isIE && (el.id == undefined || el.id == '')) {
+ el.dom = el.dom;
+ } else {
+ el.dom = DOC.getElementById(el.id) || el.dom;
}
}
- return -1;
- },
-
- isListening : function(fn, scope){
- return this.findListener(fn, scope) != -1;
- },
-
- 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];
- if(l.task) {
- l.task.cancel();
- delete l.task;
- }
- k = l.tasks && l.tasks.length;
- if(k) {
- while(k--) {
- l.tasks[k].cancel();
- }
- delete l.tasks;
- }
- 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);
- }
- },
-
- fire : function(){
- var me = this,
- listeners = me.listeners,
- len = listeners.length,
- i = 0,
- l;
-
- if(len > 0){
- me.firing = TRUE;
- var args = Array.prototype.slice.call(arguments, 0);
- for (; i < len; i++) {
- l = listeners[i];
- if(l && l.fireFn.apply(l.scope || me.obj || window, args) === FALSE) {
- return (me.firing = FALSE);
- }
- }
+ 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;
}
- me.firing = FALSE;
- return TRUE;
+ return docEl;
}
-
+ return null;
};
-})();
-
-Ext.apply(Ext.util.Observable.prototype, function(){
-
-
-
- function getMethodEvent(method){
- var e = (this.methodEvents = this.methodEvents ||
- {})[method], returnValue, v, cancel, obj = this;
-
- if (!e) {
- this.methodEvents[method] = e = {};
- e.originalFn = this[method];
- e.methodName = method;
- e.before = [];
- e.after = [];
-
- var makeCall = function(fn, scope, args){
- if((v = fn.apply(scope || obj, args)) !== undefined){
- if (typeof v == 'object') {
- if(v.returnValue !== undefined){
- returnValue = v.returnValue;
- }else{
- returnValue = v;
- }
- cancel = !!v.cancel;
- }
- else
- if (v === false) {
- cancel = true;
- }
- else {
- returnValue = v;
- }
- }
- };
-
- this[method] = function(){
- var args = Array.prototype.slice.call(arguments, 0),
- b;
- returnValue = v = undefined;
- cancel = false;
-
- for(var i = 0, len = e.before.length; i < len; i++){
- b = e.before[i];
- makeCall(b.fn, b.scope, args);
- if (cancel) {
- return returnValue;
- }
- }
-
- if((v = e.originalFn.apply(obj, args)) !== undefined){
- returnValue = v;
- }
-
- for(var i = 0, len = e.after.length; i < len; i++){
- b = e.after[i];
- makeCall(b.fn, b.scope, args);
- if (cancel) {
- return returnValue;
- }
- }
- return returnValue;
- };
- }
- return e;
- }
-
- 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
- });
- },
-
- removeMethodListener: function(method, fn, scope){
- var e = this.getMethodEvent(method);
- for(var i = 0, len = e.before.length; i < len; i++){
- if(e.before[i].fn == fn && e.before[i].scope == scope){
- e.before.splice(i, 1);
- return;
- }
- }
- for(var i = 0, len = e.after.length; i < len; i++){
- if(e.after[i].fn == fn && e.after[i].scope == scope){
- e.after.splice(i, 1);
- return;
- }
- }
- },
-
-
- relayEvents : function(o, events){
- var me = this;
- function createHandler(ename){
- return function(){
- return me.fireEvent.apply(me, [ename].concat(Array.prototype.slice.call(arguments, 0)));
- };
- }
- for(var i = 0, len = events.length; i < len; i++){
- var ename = events[i];
- 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 : Array.prototype.slice.call(arguments, 0);
- for(var i = 0, len = events.length; i < len; i++){
- var ename = events[i];
- ename = ename.toLowerCase();
- var ce = me.events[ename] || true;
- if (typeof ce == 'boolean') {
- ce = new Ext.util.Event(me, ename);
- me.events[ename] = ce;
- }
- ce.bubble = true;
- }
- }
- }
+El.addToCache = function(el, id){
+ id = id || el.id;
+ EC[id] = {
+ el: el,
+ data: {},
+ events: {}
};
-}());
-
-
-
-Ext.util.Observable.capture = function(o, fn, scope){
- o.fireEvent = o.fireEvent.createInterceptor(fn, scope);
+ return el;
};
-
-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(typeof listeners == 'object'){
- c.on(listeners);
- }
- return c;
- }
+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);
+ }
};
-Ext.EventManager = function(){
- var docReadyEvent,
- docReadyProcId,
- docReadyState = false,
- DETECT_NATIVE = Ext.isGecko || Ext.isWebKit || Ext.isSafari,
- E = Ext.lib.Event,
- D = Ext.lib.Dom,
- DOC = document,
- WINDOW = window,
- DOMCONTENTLOADED = "DOMContentLoaded",
- COMPLETE = 'complete',
- 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,
+
+function garbageCollect(){
+ if(!Ext.enableGarbageCollector){
+ clearInterval(El.collectorThreadId);
+ } else {
+ var eid,
+ el,
+ d,
o;
- if(el){
- if(el.getElementById || el.navigator){
-
- for(; i < len; ++i){
- o = specialElCache[i];
- if(o.el === el){
- id = o.id;
- break;
- }
- }
- if(!id){
-
- id = Ext.id(el);
- specialElCache.push({
- id: id,
- el: el
- });
- skip = true;
- }
- }else{
- id = Ext.id(el);
+
+ for(eid in EC){
+ o = EC[eid];
+ if(o.skipGC){
+ continue;
}
- if(!Ext.elCache[id]){
- Ext.Element.addToCache(new Ext.Element(el), id);
- if(skip){
- Ext.elCache[id].skipGC = true;
+ el = o.el;
+ d = el.dom;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ if(!d || !d.parentNode || (!d.offsetParent && !DOC.getElementById(eid))){
+ if(Ext.enableListenerCollection){
+ Ext.EventManager.removeAll(d);
}
+ delete EC[eid];
}
}
- return id;
- };
-
-
- function addListener(el, ename, fn, task, 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, task]);
-
-
-
-
- if(el.addEventListener && ename == "mousewheel"){
- var args = ["DOMMouseScroll", wrap, false];
- el.addEventListener.apply(el, args);
- Ext.EventManager.addListener(WINDOW, 'unload', function(){
- el.removeEventListener.apply(el, args);
- });
+ if (Ext.isIE) {
+ var t = {};
+ for (eid in EC) {
+ t[eid] = EC[eid];
+ }
+ EC = Ext.elCache = t;
}
+ }
+}
+El.collectorThreadId = setInterval(garbageCollect, 30000);
-
- if(el == DOC && ename == "mousedown"){
- Ext.EventManager.stoppedMouseDownEvent.addListener(wrap);
- }
- };
+var flyFn = function(){};
+flyFn.prototype = El.prototype;
- function doScrollChk(){
-
- if(window != top){
- return false;
- }
- try{
- DOC.documentElement.doScroll('left');
- }catch(e){
- return false;
- }
+El.Flyweight = function(dom){
+ this.dom = dom;
+};
- fireDocReady();
- return true;
- }
-
- function checkReadyState(e){
+El.Flyweight.prototype = new flyFn();
+El.Flyweight.prototype.isFlyweight = true;
+El._flyweights = {};
- if(Ext.isIE && doScrollChk()){
- return true;
- }
- if(DOC.readyState == COMPLETE){
- fireDocReady();
- return true;
- }
- docReadyState || (docReadyProcId = setTimeout(arguments.callee, 2));
- return false;
- }
- var styles;
- function checkStyleSheets(e){
- styles || (styles = Ext.query('style, link[rel=stylesheet]'));
- if(styles.length == DOC.styleSheets.length){
- fireDocReady();
- return true;
- }
- docReadyState || (docReadyProcId = setTimeout(arguments.callee, 2));
- return false;
- }
+El.fly = function(el, named){
+ var ret = null;
+ named = named || '_global';
- function OperaDOMContentLoaded(e){
- DOC.removeEventListener(DOMCONTENTLOADED, arguments.callee, false);
- checkStyleSheets();
+ if (el = Ext.getDom(el)) {
+ (El._flyweights[named] = El._flyweights[named] || new El.Flyweight()).dom = el;
+ ret = El._flyweights[named];
}
+ return ret;
+};
- function fireDocReady(e){
- if(!docReadyState){
- docReadyState = true;
-
- if(docReadyProcId){
- clearTimeout(docReadyProcId);
- }
- if(DETECT_NATIVE) {
- DOC.removeEventListener(DOMCONTENTLOADED, fireDocReady, false);
- }
- if(Ext.isIE && checkReadyState.bindIE){
- DOC.detachEvent('onreadystatechange', checkReadyState);
- }
- E.un(WINDOW, "load", arguments.callee);
- }
- if(docReadyEvent && !Ext.isReady){
- Ext.isReady = true;
- docReadyEvent.fire();
- docReadyEvent.listeners = [];
- }
-
- };
-
- function initDocReady(){
- docReadyEvent || (docReadyEvent = new Ext.util.Event());
- if (DETECT_NATIVE) {
- DOC.addEventListener(DOMCONTENTLOADED, fireDocReady, false);
- }
-
- if (Ext.isIE){
-
-
- if(!checkReadyState()){
- checkReadyState.bindIE = true;
- DOC.attachEvent('onreadystatechange', checkReadyState);
- }
- }else if(Ext.isOpera ){
-
+Ext.get = El.get;
-
- (DOC.readyState == COMPLETE && checkStyleSheets()) ||
- DOC.addEventListener(DOMCONTENTLOADED, OperaDOMContentLoaded, false);
- }else if (Ext.isWebKit){
-
- checkReadyState();
- }
-
- E.on(WINDOW, "load", fireDocReady);
- };
+Ext.fly = El.fly;
- function createTargeted(h, o){
- return function(){
- var args = Ext.toArray(arguments);
- if(o.target == Ext.EventObject.setEvent(args[0]).target){
- h.apply(this, args);
- }
- };
- };
- function createBuffered(h, o, task){
- return function(e){
-
- task.delay(o.buffer, h, null, [new Ext.EventObjectImpl(e)]);
- };
- };
+var noBoxAdjust = Ext.isStrict ? {
+ select:1
+} : {
+ input:1, select:1, textarea:1
+};
+if(Ext.isIE || Ext.isGecko){
+ noBoxAdjust['button'] = 1;
+}
- function createSingle(h, el, ename, fn, scope){
- return function(e){
- Ext.EventManager.removeListener(el, ename, fn, scope);
- h(e);
- };
- };
+})();
- function createDelayed(h, o, fn){
- return function(e){
- var task = new Ext.util.DelayedTask(h);
- if(!fn.tasks) {
- fn.tasks = [];
+Ext.Element.addMethods(function(){
+ var PARENTNODE = 'parentNode',
+ NEXTSIBLING = 'nextSibling',
+ PREVIOUSSIBLING = 'previousSibling',
+ DQ = Ext.DomQuery,
+ GET = Ext.get;
+
+ return {
+
+ findParent : function(simpleSelector, maxDepth, returnEl){
+ var p = this.dom,
+ b = document.body,
+ depth = 0,
+ stopEl;
+ if(Ext.isGecko && Object.prototype.toString.call(p) == '[object XULElement]') {
+ return null;
}
- fn.tasks.push(task);
- task.delay(o.delay || 10, h, null, [new Ext.EventObjectImpl(e)]);
- };
- };
-
- function listen(element, ename, opt, fn, scope){
- var o = (!opt || typeof opt == "boolean") ? {} : opt,
- el = Ext.getDom(element), task;
-
- fn = fn || o.fn;
- scope = scope || o.scope;
-
- 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;
- }
-
- 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){
- task = new Ext.util.DelayedTask(h);
- h = createBuffered(h, o, task);
- }
-
- addListener(el, ename, fn, task, h, scope);
- return h;
+ maxDepth = maxDepth || 50;
+ if (isNaN(maxDepth)) {
+ stopEl = Ext.getDom(maxDepth);
+ maxDepth = Number.MAX_VALUE;
+ }
+ while(p && p.nodeType == 1 && depth < maxDepth && p != b && p != stopEl){
+ if(DQ.is(p, simpleSelector)){
+ return returnEl ? GET(p) : p;
+ }
+ depth++;
+ p = p.parentNode;
+ }
+ return null;
+ },
+
+
+ findParentNode : function(simpleSelector, maxDepth, returnEl){
+ var p = Ext.fly(this.dom.parentNode, '_internal');
+ return p ? p.findParent(simpleSelector, maxDepth, returnEl) : null;
+ },
+
+
+ up : function(simpleSelector, maxDepth){
+ return this.findParentNode(simpleSelector, maxDepth, true);
+ },
+
+
+ select : function(selector){
+ return Ext.Element.select(selector, this.dom);
+ },
+
+
+ query : function(selector){
+ return DQ.select(selector, this.dom);
+ },
+
+
+ child : function(selector, returnDom){
+ var n = DQ.selectNode(selector, this.dom);
+ return returnDom ? n : GET(n);
+ },
+
+
+ down : function(selector, returnDom){
+ var n = DQ.selectNode(" > " + selector, this.dom);
+ return returnDom ? n : GET(n);
+ },
+
+
+ parent : function(selector, returnDom){
+ return this.matchNode(PARENTNODE, PARENTNODE, selector, returnDom);
+ },
+
+
+ next : function(selector, returnDom){
+ return this.matchNode(NEXTSIBLING, NEXTSIBLING, selector, returnDom);
+ },
+
+
+ prev : function(selector, returnDom){
+ return this.matchNode(PREVIOUSSIBLING, PREVIOUSSIBLING, selector, returnDom);
+ },
+
+
+
+ first : function(selector, returnDom){
+ return this.matchNode(NEXTSIBLING, 'firstChild', selector, returnDom);
+ },
+
+
+ last : function(selector, returnDom){
+ return this.matchNode(PREVIOUSSIBLING, 'lastChild', selector, returnDom);
+ },
+
+ matchNode : function(dir, start, selector, returnDom){
+ var n = this.dom[start];
+ while(n){
+ if(n.nodeType == 1 && (!selector || DQ.is(n, selector))){
+ return !returnDom ? GET(n) : n;
+ }
+ n = n[dir];
+ }
+ return null;
+ }
};
-
- var pub = {
-
- addListener : function(element, eventName, fn, scope, options){
- if(typeof eventName == 'object'){
- 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);
+}());
+Ext.Element.addMethods(
+function() {
+ var GETDOM = Ext.getDom,
+ GET = Ext.get,
+ DH = Ext.DomHelper;
+
+ return {
+
+ appendChild: function(el){
+ return GET(el).appendTo(this);
+ },
+
+
+ appendTo: function(el){
+ GETDOM(el).appendChild(this.dom);
+ return this;
+ },
+
+
+ insertBefore: function(el){
+ (el = GETDOM(el)).parentNode.insertBefore(this.dom, el);
+ return this;
+ },
+
+
+ insertAfter: function(el){
+ (el = GETDOM(el)).parentNode.insertBefore(this.dom, el.nextSibling);
+ return this;
+ },
+
+
+ insertFirst: function(el, returnDom){
+ el = el || {};
+ if(el.nodeType || el.dom || typeof el == 'string'){
+ el = GETDOM(el);
+ this.dom.insertBefore(el, this.dom.firstChild);
+ return !returnDom ? GET(el) : el;
+ }else{
+ return this.createChild(el, this.dom.firstChild, returnDom);
}
},
-
+
+
+ replace: function(el){
+ el = GET(el);
+ this.insertBefore(el);
+ el.remove();
+ return this;
+ },
+
+
+ replaceWith: function(el){
+ var me = this;
+
+ if(el.nodeType || el.dom || typeof el == 'string'){
+ el = GETDOM(el);
+ me.dom.parentNode.insertBefore(el, me.dom);
+ }else{
+ el = DH.insertBefore(me.dom, el);
+ }
+
+ delete Ext.elCache[me.id];
+ Ext.removeNode(me.dom);
+ me.id = Ext.id(me.dom = el);
+ Ext.Element.addToCache(me.isFlyweight ? new Ext.Element(me.dom) : me);
+ return me;
+ },
+
+
+ createChild: function(config, insertBefore, returnDom){
+ config = config || {tag:'div'};
+ return insertBefore ?
+ DH.insertBefore(insertBefore, config, returnDom !== true) :
+ DH[!this.dom.firstChild ? 'overwrite' : 'append'](this.dom, config, returnDom !== true);
+ },
+
+
+ wrap: function(config, returnDom){
+ var newEl = DH.insertBefore(this.dom, config || {tag: "div"}, !returnDom);
+ newEl.dom ? newEl.dom.appendChild(this.dom) : newEl.appendChild(this.dom);
+ return newEl;
+ },
+
+
+ insertHtml : function(where, html, returnEl){
+ var el = DH.insertHtml(where, this.dom, html);
+ return returnEl ? Ext.get(el) : el;
+ }
+ };
+}());
+Ext.Element.addMethods(function(){
+
+ var supports = Ext.supports,
+ propCache = {},
+ camelRe = /(-[a-z])/gi,
+ view = document.defaultView,
+ opacityRe = /alpha\(opacity=(.*)\)/i,
+ trimRe = /^\s+|\s+$/g,
+ EL = Ext.Element,
+ spacesRe = /\s+/,
+ wordsRe = /\w/g,
+ PADDING = "padding",
+ MARGIN = "margin",
+ BORDER = "border",
+ LEFT = "-left",
+ RIGHT = "-right",
+ TOP = "-top",
+ BOTTOM = "-bottom",
+ WIDTH = "-width",
+ MATH = Math,
+ HIDDEN = 'hidden',
+ ISCLIPPED = 'isClipped',
+ OVERFLOW = 'overflow',
+ OVERFLOWX = 'overflow-x',
+ OVERFLOWY = 'overflow-y',
+ ORIGINALCLIP = 'originalClip',
- 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, len, fnc;
-
- for (i = 0, len = f.length; i < len; i++) {
+ borders = {l: BORDER + LEFT + WIDTH, r: BORDER + RIGHT + WIDTH, t: BORDER + TOP + WIDTH, b: BORDER + BOTTOM + WIDTH},
+ paddings = {l: PADDING + LEFT, r: PADDING + RIGHT, t: PADDING + TOP, b: PADDING + BOTTOM},
+ margins = {l: MARGIN + LEFT, r: MARGIN + RIGHT, t: MARGIN + TOP, b: MARGIN + BOTTOM},
+ data = Ext.Element.data;
-
- if (Ext.isArray(fnc = f[i]) && fnc[0] == fn && (!scope || fnc[2] == scope)) {
- if(fnc[4]) {
- fnc[4].cancel();
- }
- k = fn.tasks && fn.tasks.length;
- if(k) {
- while(k--) {
- fn.tasks[k].cancel();
- }
- delete fn.tasks;
- }
- wrap = fnc[1];
- E.un(el, eventName, E.extAdapter ? fnc[3] : wrap);
-
- if(wrap && el.addEventListener && eventName == "mousewheel"){
- el.removeEventListener("DOMMouseScroll", wrap, false);
- }
+
+ function camelFn(m, a) {
+ return a.charAt(1).toUpperCase();
+ }
-
- if(wrap && el == DOC && eventName == "mousedown"){
- Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
- }
+ function chkCache(prop) {
+ return propCache[prop] || (propCache[prop] = prop == 'float' ? (supports.cssFloat ? 'cssFloat' : 'styleFloat') : prop.replace(camelRe, camelFn));
+ }
- 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;
- }
+ return {
+
+ adjustWidth : function(width) {
+ var me = this;
+ var isNum = (typeof width == "number");
+ if(isNum && me.autoBoxAdjust && !me.isBorderBox()){
+ width -= (me.getBorderWidth("lr") + me.getPadding("lr"));
}
+ return (isNum && width < 0) ? 0 : width;
},
- removeAll : function(el){
- el = Ext.getDom(el);
- var id = getId(el),
- ec = Ext.elCache[id] || {},
- es = ec.events || {},
- f, i, len, ename, fn, k, wrap;
-
- for(ename in es){
- if(es.hasOwnProperty(ename)){
- f = es[ename];
-
- for (i = 0, len = f.length; i < len; i++) {
- fn = f[i];
- if(fn[4]) {
- fn[4].cancel();
- }
- if(fn[0].tasks && (k = fn[0].tasks.length)) {
- while(k--) {
- fn[0].tasks[k].cancel();
- }
- delete fn.tasks;
- }
- wrap = fn[1];
- E.un(el, ename, E.extAdapter ? fn[3] : wrap);
-
-
- if(el.addEventListener && wrap && ename == "mousewheel"){
- el.removeEventListener("DOMMouseScroll", wrap, false);
- }
-
-
- if(wrap && el == DOC && ename == "mousedown"){
- Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
- }
- }
- }
- }
- if (Ext.elCache[id]) {
- Ext.elCache[id].events = {};
+ adjustHeight : function(height) {
+ var me = this;
+ var isNum = (typeof height == "number");
+ if(isNum && me.autoBoxAdjust && !me.isBorderBox()){
+ height -= (me.getBorderWidth("tb") + me.getPadding("tb"));
}
+ return (isNum && height < 0) ? 0 : height;
},
- 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]);
- }
+
+ addClass : function(className){
+ var me = this,
+ i,
+ len,
+ v,
+ cls = [];
+
+ if (!Ext.isArray(className)) {
+ if (typeof className == 'string' && !this.hasClass(className)) {
+ me.dom.className += " " + className;
}
- } 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);
+ else {
+ for (i = 0, len = className.length; i < len; i++) {
+ v = className[i];
+ if (typeof v == 'string' && (' ' + me.dom.className + ' ').indexOf(' ' + v + ' ') == -1) {
+ cls.push(v);
+ }
+ }
+ if (cls.length) {
+ me.dom.className += " " + cls.join(" ");
}
}
+ return me;
},
- _unload : function() {
- var el;
- for (el in Ext.elCache) {
- Ext.EventManager.removeAll(el);
+
+ removeClass : function(className){
+ var me = this,
+ i,
+ idx,
+ len,
+ cls,
+ elClasses;
+ if (!Ext.isArray(className)){
+ className = [className];
}
- delete Ext.elCache;
- delete Ext.Element._flyweights;
-
-
- var c,
- conn,
- tid,
- ajax = Ext.lib.Ajax;
- (typeof ajax.conn == 'object') ? conn = ajax.conn : conn = {};
- for (tid in conn) {
- c = conn[tid];
- if (c) {
- ajax.abort({conn: c, tId: tid});
+ if (me.dom && me.dom.className) {
+ elClasses = me.dom.className.replace(trimRe, '').split(spacesRe);
+ for (i = 0, len = className.length; i < len; i++) {
+ cls = className[i];
+ if (typeof cls == 'string') {
+ cls = cls.replace(trimRe, '');
+ idx = elClasses.indexOf(cls);
+ if (idx != -1) {
+ elClasses.splice(idx, 1);
+ }
+ }
}
+ me.dom.className = elClasses.join(" ");
}
+ return me;
},
+
- onDocumentReady : function(fn, scope, options){
- if(Ext.isReady){
- docReadyEvent || (docReadyEvent = new Ext.util.Event());
- docReadyEvent.addListener(fn, scope, options);
- docReadyEvent.fire();
- docReadyEvent.listeners = [];
- }else{
- if(!docReadyEvent){
- initDocReady();
+ radioClass : function(className){
+ var cn = this.dom.parentNode.childNodes,
+ v,
+ i,
+ len;
+ className = Ext.isArray(className) ? className : [className];
+ for (i = 0, len = cn.length; i < len; i++) {
+ v = cn[i];
+ if (v && v.nodeType == 1) {
+ Ext.fly(v, '_internal').removeClass(className);
}
- options = options || {};
- options.delay = options.delay || 1;
- docReadyEvent.addListener(fn, scope, options);
- }
+ };
+ return this.addClass(className);
},
- fireDocReady : fireDocReady
- };
-
- pub.on = pub.addListener;
-
- pub.un = pub.removeListener;
-
- pub.stoppedMouseDownEvent = new Ext.util.Event();
- return pub;
-}();
+ toggleClass : function(className){
+ return this.hasClass(className) ? this.removeClass(className) : this.addClass(className);
+ },
-Ext.onReady = Ext.EventManager.onDocumentReady;
+
+ hasClass : function(className){
+ return className && (' '+this.dom.className+' ').indexOf(' '+className+' ') != -1;
+ },
+
+ replaceClass : function(oldClassName, newClassName){
+ return this.removeClass(oldClassName).addClass(newClassName);
+ },
+ isStyle : function(style, val) {
+ return this.getStyle(style) == val;
+ },
-(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");
- }
-
- if(Ext.isStrict || Ext.isBorderBox){
- var p = bd.parentNode;
- if(p){
- p.className += Ext.isStrict ? ' ext-strict' : ' ext-border-box';
- }
- }
- bd.className += cls.join(' ');
- return true;
- }
-
- if(!initExtCss()){
- Ext.onReady(initExtCss);
- }
-})();
+ getStyle : function(){
+ return view && view.getComputedStyle ?
+ function(prop){
+ var el = this.dom,
+ v,
+ cs,
+ out,
+ display;
+ if(el == document){
+ return null;
+ }
+ prop = chkCache(prop);
+ out = (v = el.style[prop]) ? v :
+ (cs = view.getComputedStyle(el, "")) ? cs[prop] : null;
+
+
+
+ if(prop == 'marginRight' && out != '0px' && !supports.correctRightMargin){
+ display = el.style.display;
+ el.style.display = 'inline-block';
+ out = view.getComputedStyle(el, '').marginRight;
+ el.style.display = display;
+ }
+
+ if(prop == 'backgroundColor' && out == 'rgba(0, 0, 0, 0)' && !supports.correctTransparentColor){
+ out = 'transparent';
+ }
+ return out;
+ } :
+ function(prop){
+ var el = this.dom,
+ m,
+ cs;
+ if(el == document) return null;
+ if (prop == 'opacity') {
+ if (el.style.filter.match) {
+ if(m = el.style.filter.match(opacityRe)){
+ var fv = parseFloat(m[1]);
+ if(!isNaN(fv)){
+ return fv ? fv / 100 : 0;
+ }
+ }
+ }
+ return 1;
+ }
+ prop = chkCache(prop);
+ return el.style[prop] || ((cs = el.currentStyle) ? cs[prop] : null);
+ };
+ }(),
-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);
- }
- };
+ getColor : function(attr, defaultValue, prefix){
+ var v = this.getStyle(attr),
+ color = (typeof prefix != 'undefined') ? prefix : '#',
+ h;
- Ext.EventObjectImpl.prototype = {
-
- setEvent : function(e){
- var me = this;
- if(e == me || (e && e.browserEvent)){
- return e;
+ if(!v || (/transparent|inherit/.test(v))) {
+ return defaultValue;
}
- 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);
+ if(/^r/.test(v)){
+ Ext.each(v.slice(4, v.length -1).split(','), function(s){
+ h = parseInt(s, 10);
+ color += (h < 16 ? '0' : '') + h.toString(16);
+ });
}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];
+ v = v.replace('#', '');
+ color += v.length == 3 ? v.replace(/^(\w)(\w)(\w)$/, '$1$1$2$2$3$3') : v;
}
- return me;
+ return(color.length > 5 ? color.toLowerCase() : defaultValue);
},
- stopEvent : function(){
- var me = this;
- if(me.browserEvent){
- if(me.browserEvent.type == 'mousedown'){
- Ext.EventManager.stoppedMouseDownEvent.fire(me);
- }
- E.stopEvent(me.browserEvent);
+ setStyle : function(prop, value){
+ var tmp, style;
+
+ if (typeof prop != 'object') {
+ tmp = {};
+ tmp[prop] = value;
+ prop = tmp;
+ }
+ for (style in prop) {
+ value = prop[style];
+ style == 'opacity' ?
+ this.setOpacity(value) :
+ this.dom.style[chkCache(style)] = value;
}
+ return this;
},
- preventDefault : function(){
- if(this.browserEvent){
- E.preventDefault(this.browserEvent);
+ setOpacity : function(opacity, animate){
+ var me = this,
+ s = me.dom.style;
+
+ if(!animate || !me.anim){
+ if(Ext.isIE){
+ var opac = opacity < 1 ? 'alpha(opacity=' + opacity * 100 + ')' : '',
+ val = s.filter.replace(opacityRe, '').replace(trimRe, '');
+
+ s.zoom = 1;
+ s.filter = val + (val.length > 0 ? ' ' : '') + opac;
+ }else{
+ s.opacity = opacity;
+ }
+ }else{
+ me.anim({opacity: {to: opacity}}, me.preanim(arguments, 1), null, .35, 'easeIn');
}
+ return me;
},
- stopPropagation : function(){
- var me = this;
- if(me.browserEvent){
- if(me.browserEvent.type == 'mousedown'){
- Ext.EventManager.stoppedMouseDownEvent.fire(me);
+ clearOpacity : function(){
+ var style = this.dom.style;
+ if(Ext.isIE){
+ if(!Ext.isEmpty(style.filter)){
+ style.filter = style.filter.replace(opacityRe, '').replace(trimRe, '');
}
- E.stopPropagation(me.browserEvent);
+ }else{
+ style.opacity = style['-moz-opacity'] = style['-khtml-opacity'] = '';
}
+ return this;
},
- getCharCode : function(){
- return this.charCode || this.keyCode;
- },
+ getHeight : function(contentHeight){
+ var me = this,
+ dom = me.dom,
+ hidden = Ext.isIE && me.isStyle('display', 'none'),
+ h = MATH.max(dom.offsetHeight, hidden ? 0 : dom.clientHeight) || 0;
-
- getKey : function(){
- return this.normalizeKey(this.keyCode || this.charCode)
+ h = !contentHeight ? h : h - me.getBorderWidth("tb") - me.getPadding("tb");
+ return h < 0 ? 0 : h;
},
- normalizeKey: function(k){
- return Ext.isSafari ? (safariKeys[k] || k) : k;
+ getWidth : function(contentWidth){
+ var me = this,
+ dom = me.dom,
+ hidden = Ext.isIE && me.isStyle('display', 'none'),
+ w = MATH.max(dom.offsetWidth, hidden ? 0 : dom.clientWidth) || 0;
+ w = !contentWidth ? w : w - me.getBorderWidth("lr") - me.getPadding("lr");
+ return w < 0 ? 0 : w;
},
- getPageX : function(){
- return this.xy[0];
+ setWidth : function(width, animate){
+ var me = this;
+ width = me.adjustWidth(width);
+ !animate || !me.anim ?
+ me.dom.style.width = me.addUnits(width) :
+ me.anim({width : {to : width}}, me.preanim(arguments, 1));
+ return me;
},
- getPageY : function(){
- return this.xy[1];
+ setHeight : function(height, animate){
+ var me = this;
+ height = me.adjustHeight(height);
+ !animate || !me.anim ?
+ me.dom.style.height = me.addUnits(height) :
+ me.anim({height : {to : height}}, me.preanim(arguments, 1));
+ return me;
},
- getXY : function(){
- return this.xy;
+ getBorderWidth : function(side){
+ return this.addStyles(side, borders);
},
- getTarget : function(selector, maxDepth, returnEl){
- return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : (returnEl ? Ext.get(this.target) : this.target);
+ getPadding : function(side){
+ return this.addStyles(side, paddings);
},
- getRelatedTarget : function(){
- return this.browserEvent ? E.getRelatedTarget(this.browserEvent) : null;
+ clip : function(){
+ var me = this,
+ dom = me.dom;
+
+ if(!data(dom, ISCLIPPED)){
+ data(dom, ISCLIPPED, true);
+ data(dom, ORIGINALCLIP, {
+ o: me.getStyle(OVERFLOW),
+ x: me.getStyle(OVERFLOWX),
+ y: me.getStyle(OVERFLOWY)
+ });
+ me.setStyle(OVERFLOW, HIDDEN);
+ me.setStyle(OVERFLOWX, HIDDEN);
+ me.setStyle(OVERFLOWY, HIDDEN);
+ }
+ return me;
},
- getWheelDelta : function(){
- var e = this.browserEvent;
- var delta = 0;
- if(e.wheelDelta){
- delta = e.wheelDelta/120;
- }else if(e.detail){
- delta = -e.detail/3;
+ unclip : function(){
+ var me = this,
+ dom = me.dom;
+
+ if(data(dom, ISCLIPPED)){
+ data(dom, ISCLIPPED, false);
+ var o = data(dom, ORIGINALCLIP);
+ if(o.o){
+ me.setStyle(OVERFLOW, o.o);
+ }
+ if(o.x){
+ me.setStyle(OVERFLOWX, o.x);
+ }
+ if(o.y){
+ me.setStyle(OVERFLOWY, o.y);
+ }
}
- return delta;
+ return me;
},
- 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));
+ addStyles : function(sides, styles){
+ var ttlSize = 0,
+ sidesArr = sides.match(wordsRe),
+ side,
+ size,
+ i,
+ len = sidesArr.length;
+ for (i = 0; i < len; i++) {
+ side = sidesArr[i];
+ size = side && parseInt(this.getStyle(styles[side]), 10);
+ if (size) {
+ ttlSize += MATH.abs(size);
+ }
}
- return false;
- }
- };
+ return ttlSize;
+ },
- return new Ext.EventObjectImpl();
-}();
+ margins : margins
+ };
+}()
+);
-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);
+(function(){
+var D = Ext.lib.Dom,
+ LEFT = "left",
+ RIGHT = "right",
+ TOP = "top",
+ BOTTOM = "bottom",
+ POSITION = "position",
+ STATIC = "static",
+ RELATIVE = "relative",
+ AUTO = "auto",
+ ZINDEX = "z-index";
- return {
-
- doResizeEvent: function(){
- var h = D.getViewHeight(),
- w = D.getViewWidth();
+Ext.Element.addMethods({
+
+ getX : function(){
+ return D.getX(this.dom);
+ },
-
- if(curHeight != h || curWidth != w){
- resizeEvent.fire(curWidth = w, curHeight = h);
- }
- },
+
+ getY : function(){
+ return D.getY(this.dom);
+ },
-
- 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);
- },
+
+ getXY : function(){
+ return D.getXY(this.dom);
+ },
-
- fireWindowResize : function(){
- if(resizeEvent){
- resizeTask.delay(100);
- }
- },
+
+ getOffsetsTo : function(el){
+ var o = this.getXY(),
+ e = Ext.fly(el, '_internal').getXY();
+ return [o[0]-e[0],o[1]-e[1]];
+ },
-
- 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);
- },
+
+ setX : function(x, animate){
+ return this.setXY([x, this.getY()], this.animTest(arguments, animate, 1));
+ },
-
- removeResizeListener : function(fn, scope){
- if(resizeEvent){
- resizeEvent.removeListener(fn, scope);
- }
- },
+
+ setY : function(y, animate){
+ return this.setXY([this.getX(), y], this.animTest(arguments, animate, 1));
+ },
-
- fireResize : function(){
- if(resizeEvent){
- resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
- }
- },
+
+ setLeft : function(left){
+ this.setStyle(LEFT, this.addUnits(left));
+ return this;
+ },
-
- textResizeInterval : 50,
+
+ setTop : function(top){
+ this.setStyle(TOP, this.addUnits(top));
+ return this;
+ },
-
- ieDeferSrc : false,
+
+ setRight : function(right){
+ this.setStyle(RIGHT, this.addUnits(right));
+ return this;
+ },
-
-
- useKeydown: useKeydown
- };
-}());
+
+ setBottom : function(bottom){
+ this.setStyle(BOTTOM, this.addUnits(bottom));
+ return this;
+ },
-Ext.EventManager.on = Ext.EventManager.addListener;
+
+ setXY : function(pos, animate){
+ var me = this;
+ if(!animate || !me.anim){
+ D.setXY(me.dom, pos);
+ }else{
+ me.anim({points: {to: pos}}, me.preanim(arguments, 1), 'motion');
+ }
+ return me;
+ },
+
+ setLocation : function(x, y, animate){
+ return this.setXY([x, y], this.animTest(arguments, animate, 2));
+ },
-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 <= 46);
- },
-
- 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;
-
- id = dom.id;
-
- if(!forceNew && id && Ext.elCache[id]){
- return Ext.elCache[id].el;
- }
-
-
- this.dom = dom;
-
-
- 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;
-
-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;
- }
- }
- }
- return this;
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ moveTo : function(x, y, animate){
+ return this.setXY([x, y], this.animTest(arguments, animate, 2));
+ },
-
-
-
-
- defaultUnit : "px",
-
-
- is : function(simpleSelector){
- return Ext.DomQuery.is(this.dom, simpleSelector);
+ getLeft : function(local){
+ return !local ? this.getX() : parseInt(this.getStyle(LEFT), 10) || 0;
},
- 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;
+ getRight : function(local){
+ var me = this;
+ return !local ? me.getX() + me.getWidth() : (me.getLeft(true) + me.getWidth()) || 0;
},
- blur : function() {
- try{
- this.dom.blur();
- }catch(e){}
- return this;
+ getTop : function(local) {
+ return !local ? this.getY() : parseInt(this.getStyle(TOP), 10) || 0;
},
- getValue : function(asNumber){
- var val = this.dom.value;
- return asNumber ? parseInt(val, 10) : val;
+ getBottom : function(local){
+ var me = this;
+ return !local ? me.getY() + me.getHeight() : (me.getTop(true) + me.getHeight()) || 0;
},
- addListener : function(eventName, fn, scope, options){
- Ext.EventManager.on(this.dom, eventName, fn, scope || this, options);
- return this;
+ position : function(pos, zIndex, x, y){
+ var me = this;
+
+ if(!pos && me.isStyle(POSITION, STATIC)){
+ me.setStyle(POSITION, RELATIVE);
+ } else if(pos) {
+ me.setStyle(POSITION, pos);
+ }
+ if(zIndex){
+ me.setStyle(ZINDEX, zIndex);
+ }
+ if(x || y) me.setXY([x || false, y || false]);
},
- removeListener : function(eventName, fn, scope){
- Ext.EventManager.removeListener(this.dom, eventName, fn, scope || this);
+ clearPositioning : function(value){
+ value = value || '';
+ this.setStyle({
+ left : value,
+ right : value,
+ top : value,
+ bottom : value,
+ "z-index" : "",
+ position : STATIC
+ });
return this;
},
- removeAllListeners : function(){
- Ext.EventManager.removeAll(this.dom);
- return this;
+ getPositioning : function(){
+ var l = this.getStyle(LEFT);
+ var t = this.getStyle(TOP);
+ return {
+ "position" : this.getStyle(POSITION),
+ "left" : l,
+ "right" : l ? "" : this.getStyle(RIGHT),
+ "top" : t,
+ "bottom" : t ? "" : this.getStyle(BOTTOM),
+ "z-index" : this.getStyle(ZINDEX)
+ };
},
-
- 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');
+ setPositioning : function(pc){
+ var me = this,
+ style = me.dom.style;
+
+ me.setStyle(pc);
+
+ if(pc.right == AUTO){
+ style.right = "";
}
- return size;
- },
-
-
- 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;
- },
-
-
- isBorderBox : function(){
- return noBoxAdjust[(this.dom.tagName || "").toLowerCase()] || Ext.isBorderBox;
- },
-
+ if(pc.bottom == AUTO){
+ style.bottom = "";
+ }
+
+ return me;
+ },
+
- remove : function(){
+ translatePoints : function(x, y){
+ y = isNaN(x[1]) ? y : x[1];
+ x = isNaN(x[0]) ? x : x[0];
var me = this,
- dom = me.dom;
+ relative = me.isStyle(POSITION, RELATIVE),
+ o = me.getXY(),
+ l = parseInt(me.getStyle(LEFT), 10),
+ t = parseInt(me.getStyle(TOP), 10);
+
+ l = !isNaN(l) ? l : (relative ? 0 : me.dom.offsetLeft);
+ t = !isNaN(t) ? t : (relative ? 0 : me.dom.offsetTop);
- if (dom) {
- delete me.dom;
- Ext.removeNode(dom);
- }
+ return {left: (x - o[0] + l), top: (y - o[1] + t)};
},
-
- 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;
- },
-
+ animTest : function(args, animate, i) {
+ return !!animate && this.preanim ? this.preanim(args, i) : false;
+ }
+});
+})();
+Ext.Element.addMethods({
- contains : function(el){
- return !el ? false : Ext.lib.Dom.isAncestor(this.dom, el.dom ? el.dom : el);
+ isScrollable : function(){
+ var dom = this.dom;
+ return dom.scrollHeight > dom.clientHeight || dom.scrollWidth > dom.clientWidth;
},
- getAttributeNS : function(ns, name){
- return this.getAttribute(name, ns);
+ scrollTo : function(side, value){
+ this.dom["scroll" + (/top/i.test(side) ? "Top" : "Left")] = value;
+ return this;
},
- getAttribute : Ext.isIE ? function(name, ns){
- var d = this.dom,
- type = typeof d[ns + ":" + name];
-
- if(['undefined', 'unknown'].indexOf(type) == -1){
- return d[ns + ":" + name];
- }
- return d[name];
- } : function(name, ns){
- var d = this.dom;
- return d.getAttributeNS(ns, name) || d.getAttribute(ns + ":" + name) || d.getAttribute(name) || d[name];
- },
+ getScroll : function(){
+ var d = this.dom,
+ doc = document,
+ body = doc.body,
+ docElement = doc.documentElement,
+ l,
+ t,
+ ret;
-
- update : function(html) {
- if (this.dom) {
- this.dom.innerHTML = html;
+ if(d == doc || d == body){
+ if(Ext.isIE && Ext.isStrict){
+ l = docElement.scrollLeft;
+ t = docElement.scrollTop;
+ }else{
+ l = window.pageXOffset;
+ t = window.pageYOffset;
+ }
+ ret = {left: l || (body ? body.scrollLeft : 0), top: t || (body ? body.scrollTop : 0)};
+ }else{
+ ret = {left: d.scrollLeft, top: d.scrollTop};
}
- return this;
+ return ret;
}
-};
-
-var ep = El.prototype;
+});
-El.addMethods = function(o){
- Ext.apply(ep, o);
-};
+Ext.Element.VISIBILITY = 1;
+Ext.Element.DISPLAY = 2;
-ep.on = ep.addListener;
+Ext.Element.OFFSETS = 3;
-ep.un = ep.removeListener;
+Ext.Element.ASCLASS = 4;
-ep.autoBoxAdjust = true;
+Ext.Element.visibilityCls = 'x-hide-nosize';
-var unitPattern = /\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i,
- docEl;
+Ext.Element.addMethods(function(){
+ var El = Ext.Element,
+ OPACITY = "opacity",
+ VISIBILITY = "visibility",
+ DISPLAY = "display",
+ HIDDEN = "hidden",
+ OFFSETS = "offsets",
+ ASCLASS = "asclass",
+ NONE = "none",
+ NOSIZE = 'nosize',
+ ORIGINALDISPLAY = 'originalDisplay',
+ VISMODE = 'visibilityMode',
+ ISVISIBLE = 'isVisible',
+ data = El.data,
+ getDisplay = function(dom){
+ var d = data(dom, ORIGINALDISPLAY);
+ if(d === undefined){
+ data(dom, ORIGINALDISPLAY, d = '');
+ }
+ return d;
+ },
+ getVisMode = function(dom){
+ var m = data(dom, VISMODE);
+ if(m === undefined){
+ data(dom, VISMODE, m = 1);
+ }
+ return m;
+ };
+ return {
+
+ originalDisplay : "",
+ visibilityMode : 1,
+
+ setVisibilityMode : function(visMode){
+ data(this.dom, VISMODE, visMode);
+ return this;
+ },
+
+ animate : function(args, duration, onComplete, easing, animType){
+ this.anim(args, {duration: duration, callback: onComplete, easing: easing}, animType);
+ return this;
+ },
-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){
-
-
-
-
- if (Ext.isIE && (el.id == undefined || el.id == '')) {
- el.dom = el.dom;
- } else {
- 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;
-};
-
-El.addToCache = function(el, id){
- id = id || el.id;
- EC[id] = {
- el: el,
- data: {},
- events: {}
- };
- return el;
-};
+ anim : function(args, opt, animType, defaultDur, defaultEase, cb){
+ animType = animType || 'run';
+ opt = opt || {};
+ var me = this,
+ anim = Ext.lib.Anim[animType](
+ me.dom,
+ args,
+ (opt.duration || defaultDur) || .35,
+ (opt.easing || defaultEase) || 'easeOut',
+ function(){
+ if(cb) cb.call(me);
+ if(opt.callback) opt.callback.call(opt.scope || me, me, opt);
+ },
+ me
+ );
+ opt.anim = anim;
+ return anim;
+ },
+
+ preanim : function(a, i){
+ return !a[i] ? false : (typeof a[i] == 'object' ? a[i]: {duration: a[i+1], callback: a[i+2], easing: a[i+3]});
+ },
-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);
- }
-};
+
+ isVisible : function() {
+ var me = this,
+ dom = me.dom,
+ visible = data(dom, ISVISIBLE);
+ if(typeof visible == 'boolean'){
+ return visible;
+ }
+
+ visible = !me.isStyle(VISIBILITY, HIDDEN) &&
+ !me.isStyle(DISPLAY, NONE) &&
+ !((getVisMode(dom) == El.ASCLASS) && me.hasClass(me.visibilityCls || El.visibilityCls));
+ data(dom, ISVISIBLE, visible);
+ return visible;
+ },
+
+ setVisible : function(visible, animate){
+ var me = this, isDisplay, isVisibility, isOffsets, isNosize,
+ dom = me.dom,
+ visMode = getVisMode(dom);
-function garbageCollect(){
- if(!Ext.enableGarbageCollector){
- clearInterval(El.collectorThreadId);
- } else {
- var eid,
- el,
- d,
- o;
- 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);
+ if (typeof animate == 'string'){
+ switch (animate) {
+ case DISPLAY:
+ visMode = El.DISPLAY;
+ break;
+ case VISIBILITY:
+ visMode = El.VISIBILITY;
+ break;
+ case OFFSETS:
+ visMode = El.OFFSETS;
+ break;
+ case NOSIZE:
+ case ASCLASS:
+ visMode = El.ASCLASS;
+ break;
}
- delete EC[eid];
- }
- }
-
- if (Ext.isIE) {
- var t = {};
- for (eid in EC) {
- t[eid] = EC[eid];
+ me.setVisibilityMode(visMode);
+ animate = false;
}
- EC = Ext.elCache = t;
- }
- }
-}
-El.collectorThreadId = setInterval(garbageCollect, 30000);
-
-var flyFn = function(){};
-flyFn.prototype = El.prototype;
-
-
-El.Flyweight = function(dom){
- this.dom = dom;
-};
-
-El.Flyweight.prototype = new flyFn();
-El.Flyweight.prototype.isFlyweight = true;
-El._flyweights = {};
-
-
-El.fly = function(el, named){
- var ret = null;
- named = named || '_global';
-
- if (el = Ext.getDom(el)) {
- (El._flyweights[named] = El._flyweights[named] || new El.Flyweight()).dom = el;
- ret = El._flyweights[named];
- }
- return ret;
-};
+ if (!animate || !me.anim) {
+ if(visMode == El.ASCLASS ){
-Ext.get = El.get;
-
+ me[visible?'removeClass':'addClass'](me.visibilityCls || El.visibilityCls);
-Ext.fly = El.fly;
+ } else if (visMode == El.DISPLAY){
+ return me.setDisplayed(visible);
-var noBoxAdjust = Ext.isStrict ? {
- select:1
-} : {
- input:1, select:1, textarea:1
-};
-if(Ext.isIE || Ext.isGecko){
- noBoxAdjust['button'] = 1;
-}
+ } else if (visMode == El.OFFSETS){
-})();
+ if (!visible){
+ me.hideModeStyles = {
+ position: me.getStyle('position'),
+ top: me.getStyle('top'),
+ left: me.getStyle('left')
+ };
+ me.applyStyles({position: 'absolute', top: '-10000px', left: '-10000px'});
+ } else {
+ me.applyStyles(me.hideModeStyles || {position: '', top: '', left: ''});
+ delete me.hideModeStyles;
+ }
-Ext.Element.addMethods({
-
- swallowEvent : function(eventName, preventDefault){
- var me = this;
- function fn(e){
- e.stopPropagation();
- if(preventDefault){
- e.preventDefault();
+ }else{
+ me.fixDisplay();
+ dom.style.visibility = visible ? "visible" : HIDDEN;
+ }
+ }else{
+
+ if(visible){
+ me.setOpacity(.01);
+ me.setVisible(true);
+ }
+ me.anim({opacity: { to: (visible?1:0) }},
+ me.preanim(arguments, 1),
+ null,
+ .35,
+ 'easeIn',
+ function(){
+ visible || me.setVisible(false).setOpacity(1);
+ });
}
- }
- if(Ext.isArray(eventName)){
- Ext.each(eventName, function(e) {
- me.on(e, fn);
- });
+ data(dom, ISVISIBLE, visible);
return me;
- }
- me.on(eventName, fn);
- return me;
- },
+ },
-
- relayEvent : function(eventName, observable){
- this.on(eventName, function(e){
- observable.fireEvent(eventName, e);
- });
- },
-
- clean : function(forceReclean){
- var me = this,
- dom = me.dom,
- n = dom.firstChild,
- ni = -1;
+
+ hasMetrics : function(){
+ var dom = this.dom;
+ return this.isVisible() || (getVisMode(dom) == El.VISIBILITY);
+ },
- if(Ext.Element.data(dom, 'isCleaned') && forceReclean !== true){
+
+ toggle : function(animate){
+ var me = this;
+ me.setVisible(!me.isVisible(), me.preanim(arguments, 0));
return me;
- }
-
- while(n){
- var nx = n.nextSibling;
- if(n.nodeType == 3 && !/\S/.test(n.nodeValue)){
- dom.removeChild(n);
- }else{
- n.nodeIndex = ++ni;
- }
- n = nx;
- }
- Ext.Element.data(dom, 'isCleaned', true);
- return me;
- },
-
-
- load : function(){
- var um = this.getUpdater();
- um.update.apply(um, arguments);
- return this;
- },
-
-
- getUpdater : function(){
- return this.updateManager || (this.updateManager = new Ext.Updater(this));
- },
-
-
- update : function(html, loadScripts, callback){
- if (!this.dom) {
- return this;
- }
- html = html || "";
+ },
- if(loadScripts !== true){
- this.dom.innerHTML = html;
- if(typeof callback == 'function'){
- callback();
+
+ setDisplayed : function(value) {
+ if(typeof value == "boolean"){
+ value = value ? getDisplay(this.dom) : NONE;
}
+ this.setStyle(DISPLAY, value);
return this;
- }
-
- var id = Ext.id(),
- dom = this.dom;
-
- html += '<span id="' + id + '"></span>';
-
- Ext.lib.Event.onAvailable(id, function(){
- var DOC = document,
- hd = DOC.getElementsByTagName("head")[0],
- re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig,
- srcRe = /\ssrc=([\'\"])(.*?)\1/i,
- typeRe = /\stype=([\'\"])(.*?)\1/i,
- match,
- attrs,
- srcMatch,
- typeMatch,
- el,
- s;
+ },
- while((match = re.exec(html))){
- attrs = match[1];
- srcMatch = attrs ? attrs.match(srcRe) : false;
- if(srcMatch && srcMatch[2]){
- s = DOC.createElement("script");
- s.src = srcMatch[2];
- typeMatch = attrs.match(typeRe);
- if(typeMatch && typeMatch[2]){
- s.type = typeMatch[2];
- }
- hd.appendChild(s);
- }else if(match[2] && match[2].length > 0){
- if(window.execScript) {
- window.execScript(match[2]);
- } else {
- window.eval(match[2]);
- }
+
+ fixDisplay : function(){
+ var me = this;
+ if(me.isStyle(DISPLAY, NONE)){
+ me.setStyle(VISIBILITY, HIDDEN);
+ me.setStyle(DISPLAY, getDisplay(this.dom));
+ if(me.isStyle(DISPLAY, NONE)){
+ me.setStyle(DISPLAY, "block");
}
}
- el = DOC.getElementById(id);
- if(el){Ext.removeNode(el);}
- if(typeof callback == 'function'){
- callback();
- }
- });
- dom.innerHTML = html.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig, "");
- return this;
- },
-
-
- removeAllListeners : function(){
- this.removeAnchor();
- Ext.EventManager.removeAll(this.dom);
- return this;
- },
-
-
- createProxy : function(config, renderTo, matchBox){
- config = (typeof config == 'object') ? config : {tag : "div", cls: config};
+ },
- var me = this,
- proxy = renderTo ? Ext.DomHelper.append(renderTo, config, true) :
- Ext.DomHelper.insertBefore(me.dom, config, true);
+
+ hide : function(animate){
+
+ if (typeof animate == 'string'){
+ this.setVisible(false, animate);
+ return this;
+ }
+ this.setVisible(false, this.preanim(arguments, 0));
+ return this;
+ },
- if(matchBox && me.setBox && me.getBox){
- proxy.setBox(me.getBox());
+
+ show : function(animate){
+
+ if (typeof animate == 'string'){
+ this.setVisible(true, animate);
+ return this;
+ }
+ this.setVisible(true, this.preanim(arguments, 0));
+ return this;
}
- return proxy;
- }
-});
-
-Ext.Element.prototype.getUpdateManager = Ext.Element.prototype.getUpdater;
-
-Ext.Element.addMethods({
+ };
+}());(function(){
- getAnchorXY : function(anchor, local, s){
-
+ var NULL = null,
+ UNDEFINED = undefined,
+ TRUE = true,
+ FALSE = false,
+ SETX = "setX",
+ SETY = "setY",
+ SETXY = "setXY",
+ LEFT = "left",
+ BOTTOM = "bottom",
+ TOP = "top",
+ RIGHT = "right",
+ HEIGHT = "height",
+ WIDTH = "width",
+ POINTS = "points",
+ HIDDEN = "hidden",
+ ABSOLUTE = "absolute",
+ VISIBLE = "visible",
+ MOTION = "motion",
+ POSITION = "position",
+ EASEOUT = "easeOut",
- anchor = (anchor || "tl").toLowerCase();
- s = s || {};
+ flyEl = new Ext.Element.Flyweight(),
+ queues = {},
+ getObject = function(o){
+ return o || {};
+ },
+ fly = function(dom){
+ flyEl.dom = dom;
+ flyEl.id = Ext.id(dom);
+ return flyEl;
+ },
- var me = this,
- vp = me.dom == document.body || me.dom == document,
- w = s.width || vp ? Ext.lib.Dom.getViewWidth() : me.getWidth(),
- h = s.height || vp ? Ext.lib.Dom.getViewHeight() : me.getHeight(),
- xy,
- r = Math.round,
- o = me.getXY(),
- scroll = me.getScroll(),
- extraX = vp ? scroll.left : !local ? o[0] : 0,
- extraY = vp ? scroll.top : !local ? o[1] : 0,
- hash = {
- c : [r(w * 0.5), r(h * 0.5)],
- t : [r(w * 0.5), 0],
- l : [0, r(h * 0.5)],
- r : [w, r(h * 0.5)],
- b : [r(w * 0.5), h],
- tl : [0, 0],
- bl : [0, h],
- br : [w, h],
- tr : [w, 0]
- };
+ getQueue = function(id){
+ if(!queues[id]){
+ queues[id] = [];
+ }
+ return queues[id];
+ },
+ setQueue = function(id, value){
+ queues[id] = value;
+ };
- xy = hash[anchor];
- return [xy[0] + extraX, xy[1] + extraY];
- },
-
- anchorTo : function(el, alignment, offsets, animate, monitorScroll, callback){
- var me = this,
- dom = me.dom,
- scroll = !Ext.isEmpty(monitorScroll),
- action = function(){
- Ext.fly(dom).alignTo(el, alignment, offsets, animate);
- Ext.callback(callback, Ext.fly(dom));
- },
- anchor = this.getAnchor();
-
-
- this.removeAnchor();
- Ext.apply(anchor, {
- fn: action,
- scroll: scroll
- });
+Ext.enableFx = TRUE;
- Ext.EventManager.onWindowResize(action, null);
-
- if(scroll){
- Ext.EventManager.on(window, 'scroll', action, null,
- {buffer: !isNaN(monitorScroll) ? monitorScroll : 50});
- }
- action.call(me);
- return me;
- },
+
+Ext.Fx = {
- removeAnchor : function(){
- var me = this,
- anchor = this.getAnchor();
-
- if(anchor && anchor.fn){
- Ext.EventManager.removeResizeListener(anchor.fn);
- if(anchor.scroll){
- Ext.EventManager.un(window, 'scroll', anchor.fn);
- }
- delete anchor.fn;
- }
- return me;
+
+ switchStatements : function(key, fn, argHash){
+ return fn.apply(this, argHash[key]);
},
- getAnchor : function(){
- var data = Ext.Element.data,
- dom = this.dom;
- if (!dom) {
- return;
- }
- var anchor = data(dom, '_anchor');
+ slideIn : function(anchor, o){
+ o = getObject(o);
+ var me = this,
+ dom = me.dom,
+ st = dom.style,
+ xy,
+ r,
+ b,
+ wrap,
+ after,
+ st,
+ args,
+ pt,
+ bw,
+ bh;
- if(!anchor){
- anchor = data(dom, '_anchor', {});
- }
- return anchor;
- },
+ anchor = anchor || "t";
-
- getAlignToXY : function(el, p, o){
- el = Ext.get(el);
-
- if(!el || !el.dom){
- throw "Element.alignToXY with an element that doesn't exist";
- }
-
- o = o || [0,0];
- p = (!p || p == "?" ? "tl-bl?" : (!/-/.test(p) && p !== "" ? "tl-" + p : p || "tl-bl")).toLowerCase();
-
- var me = this,
- d = me.dom,
- a1,
- a2,
- x,
- y,
-
- w,
- h,
- r,
- dw = Ext.lib.Dom.getViewWidth() -10,
- dh = Ext.lib.Dom.getViewHeight()-10,
- p1y,
- p1x,
- p2y,
- p2x,
- swapY,
- swapX,
- doc = document,
- docElement = doc.documentElement,
- docBody = doc.body,
- scrollX = (docElement.scrollLeft || docBody.scrollLeft || 0)+5,
- scrollY = (docElement.scrollTop || docBody.scrollTop || 0)+5,
- c = false,
- p1 = "",
- p2 = "",
- m = p.match(/^([a-z]+)-([a-z]+)(\?)?$/);
+ me.queueFx(o, function(){
+ xy = fly(dom).getXY();
+
+ fly(dom).fixDisplay();
+
+
+ r = fly(dom).getFxRestore();
+ b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight};
+ b.right = b.x + b.width;
+ b.bottom = b.y + b.height;
+
+
+ fly(dom).setWidth(b.width).setHeight(b.height);
+
+
+ wrap = fly(dom).fxWrap(r.pos, o, HIDDEN);
+
+ st.visibility = VISIBLE;
+ st.position = ABSOLUTE;
+
+
+ function after(){
+ fly(dom).fxUnwrap(wrap, r.pos, o);
+ st.width = r.width;
+ st.height = r.height;
+ fly(dom).afterFx(o);
+ }
+
+
+ pt = {to: [b.x, b.y]};
+ bw = {to: b.width};
+ bh = {to: b.height};
+
+ function argCalc(wrap, style, ww, wh, sXY, sXYval, s1, s2, w, h, p){
+ var ret = {};
+ fly(wrap).setWidth(ww).setHeight(wh);
+ if(fly(wrap)[sXY]){
+ fly(wrap)[sXY](sXYval);
+ }
+ style[s1] = style[s2] = "0";
+ if(w){
+ ret.width = w;
+ }
+ if(h){
+ ret.height = h;
+ }
+ if(p){
+ ret.points = p;
+ }
+ return ret;
+ };
+
+ args = fly(dom).switchStatements(anchor.toLowerCase(), argCalc, {
+ t : [wrap, st, b.width, 0, NULL, NULL, LEFT, BOTTOM, NULL, bh, NULL],
+ l : [wrap, st, 0, b.height, NULL, NULL, RIGHT, TOP, bw, NULL, NULL],
+ r : [wrap, st, b.width, b.height, SETX, b.right, LEFT, TOP, NULL, NULL, pt],
+ b : [wrap, st, b.width, b.height, SETY, b.bottom, LEFT, TOP, NULL, bh, pt],
+ tl : [wrap, st, 0, 0, NULL, NULL, RIGHT, BOTTOM, bw, bh, pt],
+ bl : [wrap, st, 0, 0, SETY, b.y + b.height, RIGHT, TOP, bw, bh, pt],
+ br : [wrap, st, 0, 0, SETXY, [b.right, b.bottom], LEFT, TOP, bw, bh, pt],
+ tr : [wrap, st, 0, 0, SETX, b.x + b.width, LEFT, BOTTOM, bw, bh, pt]
+ });
+
+ st.visibility = VISIBLE;
+ fly(wrap).show();
+
+ arguments.callee.anim = fly(wrap).fxanim(args,
+ o,
+ MOTION,
+ .5,
+ EASEOUT,
+ after);
+ });
+ return me;
+ },
+
+
+ slideOut : function(anchor, o){
+ o = getObject(o);
+ var me = this,
+ dom = me.dom,
+ st = dom.style,
+ xy = me.getXY(),
+ wrap,
+ r,
+ b,
+ a,
+ zero = {to: 0};
+
+ anchor = anchor || "t";
+
+ me.queueFx(o, function(){
+
+
+ r = fly(dom).getFxRestore();
+ b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight};
+ b.right = b.x + b.width;
+ b.bottom = b.y + b.height;
+
+
+ fly(dom).setWidth(b.width).setHeight(b.height);
+
+
+ wrap = fly(dom).fxWrap(r.pos, o, VISIBLE);
+
+ st.visibility = VISIBLE;
+ st.position = ABSOLUTE;
+ fly(wrap).setWidth(b.width).setHeight(b.height);
+
+ function after(){
+ o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
+ fly(dom).fxUnwrap(wrap, r.pos, o);
+ st.width = r.width;
+ st.height = r.height;
+ fly(dom).afterFx(o);
+ }
+
+ function argCalc(style, s1, s2, p1, v1, p2, v2, p3, v3){
+ var ret = {};
+
+ style[s1] = style[s2] = "0";
+ ret[p1] = v1;
+ if(p2){
+ ret[p2] = v2;
+ }
+ if(p3){
+ ret[p3] = v3;
+ }
+
+ return ret;
+ };
+
+ a = fly(dom).switchStatements(anchor.toLowerCase(), argCalc, {
+ t : [st, LEFT, BOTTOM, HEIGHT, zero],
+ l : [st, RIGHT, TOP, WIDTH, zero],
+ r : [st, LEFT, TOP, WIDTH, zero, POINTS, {to : [b.right, b.y]}],
+ b : [st, LEFT, TOP, HEIGHT, zero, POINTS, {to : [b.x, b.bottom]}],
+ tl : [st, RIGHT, BOTTOM, WIDTH, zero, HEIGHT, zero],
+ bl : [st, RIGHT, TOP, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.x, b.bottom]}],
+ br : [st, LEFT, TOP, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.x + b.width, b.bottom]}],
+ tr : [st, LEFT, BOTTOM, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.right, b.y]}]
+ });
+
+ arguments.callee.anim = fly(wrap).fxanim(a,
+ o,
+ MOTION,
+ .5,
+ EASEOUT,
+ after);
+ });
+ return me;
+ },
+
+
+ puff : function(o){
+ o = getObject(o);
+ var me = this,
+ dom = me.dom,
+ st = dom.style,
+ width,
+ height,
+ r;
+
+ me.queueFx(o, function(){
+ width = fly(dom).getWidth();
+ height = fly(dom).getHeight();
+ fly(dom).clearOpacity();
+ fly(dom).show();
+
+
+ r = fly(dom).getFxRestore();
+
+ function after(){
+ o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
+ fly(dom).clearOpacity();
+ fly(dom).setPositioning(r.pos);
+ st.width = r.width;
+ st.height = r.height;
+ st.fontSize = '';
+ fly(dom).afterFx(o);
+ }
+
+ arguments.callee.anim = fly(dom).fxanim({
+ width : {to : fly(dom).adjustWidth(width * 2)},
+ height : {to : fly(dom).adjustHeight(height * 2)},
+ points : {by : [-width * .5, -height * .5]},
+ opacity : {to : 0},
+ fontSize: {to : 200, unit: "%"}
+ },
+ o,
+ MOTION,
+ .5,
+ EASEOUT,
+ after);
+ });
+ return me;
+ },
+
+
+ switchOff : function(o){
+ o = getObject(o);
+ var me = this,
+ dom = me.dom,
+ st = dom.style,
+ r;
+
+ me.queueFx(o, function(){
+ fly(dom).clearOpacity();
+ fly(dom).clip();
+
+
+ r = fly(dom).getFxRestore();
+
+ function after(){
+ o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
+ fly(dom).clearOpacity();
+ fly(dom).setPositioning(r.pos);
+ st.width = r.width;
+ st.height = r.height;
+ fly(dom).afterFx(o);
+ };
+
+ fly(dom).fxanim({opacity : {to : 0.3}},
+ NULL,
+ NULL,
+ .1,
+ NULL,
+ function(){
+ fly(dom).clearOpacity();
+ (function(){
+ fly(dom).fxanim({
+ height : {to : 1},
+ points : {by : [0, fly(dom).getHeight() * .5]}
+ },
+ o,
+ MOTION,
+ 0.3,
+ 'easeIn',
+ after);
+ }).defer(100);
+ });
+ });
+ return me;
+ },
+
+
+ highlight : function(color, o){
+ o = getObject(o);
+ var me = this,
+ dom = me.dom,
+ attr = o.attr || "backgroundColor",
+ a = {},
+ restore;
+
+ me.queueFx(o, function(){
+ fly(dom).clearOpacity();
+ fly(dom).show();
+
+ function after(){
+ dom.style[attr] = restore;
+ fly(dom).afterFx(o);
+ }
+ restore = dom.style[attr];
+ a[attr] = {from: color || "ffff9c", to: o.endColor || fly(dom).getColor(attr) || "ffffff"};
+ arguments.callee.anim = fly(dom).fxanim(a,
+ o,
+ 'color',
+ 1,
+ 'easeIn',
+ after);
+ });
+ return me;
+ },
+
+
+ frame : function(color, count, o){
+ o = getObject(o);
+ var me = this,
+ dom = me.dom,
+ proxy,
+ active;
+
+ me.queueFx(o, function(){
+ color = color || '#C3DAF9';
+ if(color.length == 6){
+ color = '#' + color;
+ }
+ count = count || 1;
+ fly(dom).show();
+
+ var xy = fly(dom).getXY(),
+ b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight},
+ queue = function(){
+ proxy = fly(document.body || document.documentElement).createChild({
+ style:{
+ position : ABSOLUTE,
+ 'z-index': 35000,
+ border : '0px solid ' + color
+ }
+ });
+ return proxy.queueFx({}, animFn);
+ };
+
+
+ arguments.callee.anim = {
+ isAnimated: true,
+ stop: function() {
+ count = 0;
+ proxy.stopFx();
+ }
+ };
+
+ function animFn(){
+ var scale = Ext.isBorderBox ? 2 : 1;
+ active = proxy.anim({
+ top : {from : b.y, to : b.y - 20},
+ left : {from : b.x, to : b.x - 20},
+ borderWidth : {from : 0, to : 10},
+ opacity : {from : 1, to : 0},
+ height : {from : b.height, to : b.height + 20 * scale},
+ width : {from : b.width, to : b.width + 20 * scale}
+ },{
+ duration: o.duration || 1,
+ callback: function() {
+ proxy.remove();
+ --count > 0 ? queue() : fly(dom).afterFx(o);
+ }
+ });
+ arguments.callee.anim = {
+ isAnimated: true,
+ stop: function(){
+ active.stop();
+ }
+ };
+ };
+ queue();
+ });
+ return me;
+ },
+
+
+ pause : function(seconds){
+ var dom = this.dom,
+ t;
+
+ this.queueFx({}, function(){
+ t = setTimeout(function(){
+ fly(dom).afterFx({});
+ }, seconds * 1000);
+ arguments.callee.anim = {
+ isAnimated: true,
+ stop: function(){
+ clearTimeout(t);
+ fly(dom).afterFx({});
+ }
+ };
+ });
+ return this;
+ },
+
+
+ fadeIn : function(o){
+ o = getObject(o);
+ var me = this,
+ dom = me.dom,
+ to = o.endOpacity || 1;
+
+ me.queueFx(o, function(){
+ fly(dom).setOpacity(0);
+ fly(dom).fixDisplay();
+ dom.style.visibility = VISIBLE;
+ arguments.callee.anim = fly(dom).fxanim({opacity:{to:to}},
+ o, NULL, .5, EASEOUT, function(){
+ if(to == 1){
+ fly(dom).clearOpacity();
+ }
+ fly(dom).afterFx(o);
+ });
+ });
+ return me;
+ },
+
+
+ fadeOut : function(o){
+ o = getObject(o);
+ var me = this,
+ dom = me.dom,
+ style = dom.style,
+ to = o.endOpacity || 0;
+
+ me.queueFx(o, function(){
+ arguments.callee.anim = fly(dom).fxanim({
+ opacity : {to : to}},
+ o,
+ NULL,
+ .5,
+ EASEOUT,
+ function(){
+ if(to == 0){
+ Ext.Element.data(dom, 'visibilityMode') == Ext.Element.DISPLAY || o.useDisplay ?
+ style.display = "none" :
+ style.visibility = HIDDEN;
+
+ fly(dom).clearOpacity();
+ }
+ fly(dom).afterFx(o);
+ });
+ });
+ return me;
+ },
+
+
+ scale : function(w, h, o){
+ this.shift(Ext.apply({}, o, {
+ width: w,
+ height: h
+ }));
+ return this;
+ },
+
+
+ shift : function(o){
+ o = getObject(o);
+ var dom = this.dom,
+ a = {};
+
+ this.queueFx(o, function(){
+ for (var prop in o) {
+ if (o[prop] != UNDEFINED) {
+ a[prop] = {to : o[prop]};
+ }
+ }
+
+ a.width ? a.width.to = fly(dom).adjustWidth(o.width) : a;
+ a.height ? a.height.to = fly(dom).adjustWidth(o.height) : a;
+
+ if (a.x || a.y || a.xy) {
+ a.points = a.xy ||
+ {to : [ a.x ? a.x.to : fly(dom).getX(),
+ a.y ? a.y.to : fly(dom).getY()]};
+ }
+
+ arguments.callee.anim = fly(dom).fxanim(a,
+ o,
+ MOTION,
+ .35,
+ EASEOUT,
+ function(){
+ fly(dom).afterFx(o);
+ });
+ });
+ return this;
+ },
+
+
+ ghost : function(anchor, o){
+ o = getObject(o);
+ var me = this,
+ dom = me.dom,
+ st = dom.style,
+ a = {opacity: {to: 0}, points: {}},
+ pt = a.points,
+ r,
+ w,
+ h;
+
+ anchor = anchor || "b";
+
+ me.queueFx(o, function(){
+
+ r = fly(dom).getFxRestore();
+ w = fly(dom).getWidth();
+ h = fly(dom).getHeight();
+
+ function after(){
+ o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
+ fly(dom).clearOpacity();
+ fly(dom).setPositioning(r.pos);
+ st.width = r.width;
+ st.height = r.height;
+ fly(dom).afterFx(o);
+ }
+
+ pt.by = fly(dom).switchStatements(anchor.toLowerCase(), function(v1,v2){ return [v1, v2];}, {
+ t : [0, -h],
+ l : [-w, 0],
+ r : [w, 0],
+ b : [0, h],
+ tl : [-w, -h],
+ bl : [-w, h],
+ br : [w, h],
+ tr : [w, -h]
+ });
+
+ arguments.callee.anim = fly(dom).fxanim(a,
+ o,
+ MOTION,
+ .5,
+ EASEOUT, after);
+ });
+ return me;
+ },
+
+
+ syncFx : function(){
+ var me = this;
+ me.fxDefaults = Ext.apply(me.fxDefaults || {}, {
+ block : FALSE,
+ concurrent : TRUE,
+ stopFx : FALSE
+ });
+ return me;
+ },
+
+
+ sequenceFx : function(){
+ var me = this;
+ me.fxDefaults = Ext.apply(me.fxDefaults || {}, {
+ block : FALSE,
+ concurrent : FALSE,
+ stopFx : FALSE
+ });
+ return me;
+ },
+
+
+ nextFx : function(){
+ var ef = getQueue(this.dom.id)[0];
+ if(ef){
+ ef.call(this);
+ }
+ },
+
+
+ hasActiveFx : function(){
+ return getQueue(this.dom.id)[0];
+ },
+
+
+ stopFx : function(finish){
+ var me = this,
+ id = me.dom.id;
+ if(me.hasActiveFx()){
+ var cur = getQueue(id)[0];
+ if(cur && cur.anim){
+ if(cur.anim.isAnimated){
+ setQueue(id, [cur]);
+ cur.anim.stop(finish !== undefined ? finish : TRUE);
+ }else{
+ setQueue(id, []);
+ }
+ }
+ }
+ return me;
+ },
+
+
+ beforeFx : function(o){
+ if(this.hasActiveFx() && !o.concurrent){
+ if(o.stopFx){
+ this.stopFx();
+ return TRUE;
+ }
+ return FALSE;
+ }
+ return TRUE;
+ },
+
+
+ hasFxBlock : function(){
+ var q = getQueue(this.dom.id);
+ return q && q[0] && q[0].block;
+ },
+
+
+ queueFx : function(o, fn){
+ var me = fly(this.dom);
+ if(!me.hasFxBlock()){
+ Ext.applyIf(o, me.fxDefaults);
+ if(!o.concurrent){
+ var run = me.beforeFx(o);
+ fn.block = o.block;
+ getQueue(me.dom.id).push(fn);
+ if(run){
+ me.nextFx();
+ }
+ }else{
+ fn.call(me);
+ }
+ }
+ return me;
+ },
+
+
+ fxWrap : function(pos, o, vis){
+ var dom = this.dom,
+ wrap,
+ wrapXY;
+ if(!o.wrap || !(wrap = Ext.getDom(o.wrap))){
+ if(o.fixPosition){
+ wrapXY = fly(dom).getXY();
+ }
+ var div = document.createElement("div");
+ div.style.visibility = vis;
+ wrap = dom.parentNode.insertBefore(div, dom);
+ fly(wrap).setPositioning(pos);
+ if(fly(wrap).isStyle(POSITION, "static")){
+ fly(wrap).position("relative");
+ }
+ fly(dom).clearPositioning('auto');
+ fly(wrap).clip();
+ wrap.appendChild(dom);
+ if(wrapXY){
+ fly(wrap).setXY(wrapXY);
+ }
+ }
+ return wrap;
+ },
+
+
+ fxUnwrap : function(wrap, pos, o){
+ var dom = this.dom;
+ fly(dom).clearPositioning();
+ fly(dom).setPositioning(pos);
+ if(!o.wrap){
+ var pn = fly(wrap).dom.parentNode;
+ pn.insertBefore(dom, wrap);
+ fly(wrap).remove();
+ }
+ },
+
+
+ getFxRestore : function(){
+ var st = this.dom.style;
+ return {pos: this.getPositioning(), width: st.width, height : st.height};
+ },
+
+
+ afterFx : function(o){
+ var dom = this.dom,
+ id = dom.id;
+ if(o.afterStyle){
+ fly(dom).setStyle(o.afterStyle);
+ }
+ if(o.afterCls){
+ fly(dom).addClass(o.afterCls);
+ }
+ if(o.remove == TRUE){
+ fly(dom).remove();
+ }
+ if(o.callback){
+ o.callback.call(o.scope, fly(dom));
+ }
+ if(!o.concurrent){
+ getQueue(id).shift();
+ fly(dom).nextFx();
+ }
+ },
+
+
+ fxanim : function(args, opt, animType, defaultDur, defaultEase, cb){
+ animType = animType || 'run';
+ opt = opt || {};
+ var anim = Ext.lib.Anim[animType](
+ this.dom,
+ args,
+ (opt.duration || defaultDur) || .35,
+ (opt.easing || defaultEase) || EASEOUT,
+ cb,
+ this
+ );
+ opt.anim = anim;
+ return anim;
+ }
+};
+
+
+Ext.Fx.resize = Ext.Fx.scale;
+
+
+
+Ext.Element.addMethods(Ext.Fx);
+})();
+
+Ext.CompositeElementLite = function(els, root){
+
+ this.elements = [];
+ this.add(els, root);
+ this.el = new Ext.Element.Flyweight();
+};
+
+Ext.CompositeElementLite.prototype = {
+ isComposite: true,
+
+
+ getElement : function(el){
- if(!m){
- throw "Element.alignTo with an invalid alignment " + p;
+ var e = this.el;
+ e.dom = el;
+ e.id = el.id;
+ return e;
+ },
+
+
+ transformElement : function(el){
+ return Ext.getDom(el);
+ },
+
+
+ getCount : function(){
+ return this.elements.length;
+ },
+
+ add : function(els, root){
+ var me = this,
+ elements = me.elements;
+ if(!els){
+ return this;
+ }
+ if(typeof els == "string"){
+ els = Ext.Element.selectorFunction(els, root);
+ }else if(els.isComposite){
+ els = els.elements;
+ }else if(!Ext.isIterable(els)){
+ els = [els];
+ }
+
+ for(var i = 0, len = els.length; i < len; ++i){
+ elements.push(me.transformElement(els[i]));
+ }
+ return me;
+ },
+
+ invoke : function(fn, args){
+ var me = this,
+ els = me.elements,
+ len = els.length,
+ e,
+ i;
+
+ for(i = 0; i < len; i++) {
+ e = els[i];
+ if(e){
+ Ext.Element.prototype[fn].apply(me.getElement(e), args);
+ }
+ }
+ return me;
+ },
+
+ item : function(index){
+ var me = this,
+ el = me.elements[index],
+ out = null;
+
+ if(el){
+ out = me.getElement(el);
+ }
+ return out;
+ },
+
+
+ addListener : function(eventName, handler, scope, opt){
+ var els = this.elements,
+ len = els.length,
+ i, e;
+
+ for(i = 0; i<len; i++) {
+ e = els[i];
+ if(e) {
+ Ext.EventManager.on(e, eventName, handler, scope || e, opt);
+ }
+ }
+ return this;
+ },
+
+ each : function(fn, scope){
+ var me = this,
+ els = me.elements,
+ len = els.length,
+ i, e;
+
+ for(i = 0; i<len; i++) {
+ e = els[i];
+ if(e){
+ e = this.getElement(e);
+ if(fn.call(scope || e, e, me, i) === false){
+ break;
+ }
+ }
}
+ return me;
+ },
+
+
+ fill : function(els){
+ var me = this;
+ me.elements = [];
+ me.add(els);
+ return me;
+ },
+
+
+ filter : function(selector){
+ var els = [],
+ me = this,
+ fn = Ext.isFunction(selector) ? selector
+ : function(el){
+ return el.is(selector);
+ };
+
+ me.each(function(el, self, i) {
+ if (fn(el, i) !== false) {
+ els[els.length] = me.transformElement(el);
+ }
+ });
- p1 = m[1];
- p2 = m[2];
- c = !!m[3];
+ me.elements = els;
+ return me;
+ },
+
+
+ indexOf : function(el){
+ return this.elements.indexOf(this.transformElement(el));
+ },
+
+
+ replaceElement : function(el, replacement, domReplace){
+ var index = !isNaN(el) ? el : this.indexOf(el),
+ d;
+ if(index > -1){
+ replacement = Ext.getDom(replacement);
+ if(domReplace){
+ d = this.elements[index];
+ d.parentNode.insertBefore(replacement, d);
+ Ext.removeNode(d);
+ }
+ this.elements.splice(index, 1, replacement);
+ }
+ return this;
+ },
+
+
+ clear : function(){
+ this.elements = [];
+ }
+};
+
+Ext.CompositeElementLite.prototype.on = Ext.CompositeElementLite.prototype.addListener;
+
+
+Ext.CompositeElementLite.importElementMethods = function() {
+ var fnName,
+ ElProto = Ext.Element.prototype,
+ CelProto = Ext.CompositeElementLite.prototype;
+
+ for (fnName in ElProto) {
+ if (typeof ElProto[fnName] == 'function'){
+ (function(fnName) {
+ CelProto[fnName] = CelProto[fnName] || function() {
+ return this.invoke(fnName, arguments);
+ };
+ }).call(CelProto, fnName);
+
+ }
+ }
+};
+
+Ext.CompositeElementLite.importElementMethods();
+
+if(Ext.DomQuery){
+ Ext.Element.selectorFunction = Ext.DomQuery.select;
+}
+
+
+Ext.Element.select = function(selector, root){
+ var els;
+ if(typeof selector == "string"){
+ els = Ext.Element.selectorFunction(selector, root);
+ }else if(selector.length !== undefined){
+ els = selector;
+ }else{
+ throw "Invalid selector";
+ }
+ return new Ext.CompositeElementLite(els);
+};
+
+Ext.select = Ext.Element.select;
+(function(){
+ var BEFOREREQUEST = "beforerequest",
+ REQUESTCOMPLETE = "requestcomplete",
+ REQUESTEXCEPTION = "requestexception",
+ UNDEFINED = undefined,
+ LOAD = 'load',
+ POST = 'POST',
+ GET = 'GET',
+ WINDOW = window;
+
+
+ Ext.data.Connection = function(config){
+ Ext.apply(this, config);
+ this.addEvents(
+
+ BEFOREREQUEST,
+
+ REQUESTCOMPLETE,
+
+ REQUESTEXCEPTION
+ );
+ Ext.data.Connection.superclass.constructor.call(this);
+ };
+
+ Ext.extend(Ext.data.Connection, Ext.util.Observable, {
+
+
+
+
+
+ timeout : 30000,
+
+ autoAbort:false,
+
+
+ disableCaching: true,
+
+
+ disableCachingParam: '_dc',
+
+
+ request : function(o){
+ var me = this;
+ if(me.fireEvent(BEFOREREQUEST, me, o)){
+ if (o.el) {
+ if(!Ext.isEmpty(o.indicatorText)){
+ me.indicatorText = '<div class="loading-indicator">'+o.indicatorText+"</div>";
+ }
+ if(me.indicatorText) {
+ Ext.getDom(o.el).innerHTML = me.indicatorText;
+ }
+ o.success = (Ext.isFunction(o.success) ? o.success : function(){}).createInterceptor(function(response) {
+ Ext.getDom(o.el).innerHTML = response.responseText;
+ });
+ }
+
+ var p = o.params,
+ url = o.url || me.url,
+ method,
+ cb = {success: me.handleResponse,
+ failure: me.handleFailure,
+ scope: me,
+ argument: {options: o},
+ timeout : Ext.num(o.timeout, me.timeout)
+ },
+ form,
+ serForm;
+
+
+ if (Ext.isFunction(p)) {
+ p = p.call(o.scope||WINDOW, o);
+ }
+
+ p = Ext.urlEncode(me.extraParams, Ext.isObject(p) ? Ext.urlEncode(p) : p);
+
+ if (Ext.isFunction(url)) {
+ url = url.call(o.scope || WINDOW, o);
+ }
+
+ if((form = Ext.getDom(o.form))){
+ url = url || form.action;
+ if(o.isUpload || (/multipart\/form-data/i.test(form.getAttribute("enctype")))) {
+ return me.doFormUpload.call(me, o, p, url);
+ }
+ serForm = Ext.lib.Ajax.serializeForm(form);
+ p = p ? (p + '&' + serForm) : serForm;
+ }
+
+ method = o.method || me.method || ((p || o.xmlData || o.jsonData) ? POST : GET);
+
+ if(method === GET && (me.disableCaching && o.disableCaching !== false) || o.disableCaching === true){
+ var dcp = o.disableCachingParam || me.disableCachingParam;
+ url = Ext.urlAppend(url, dcp + '=' + (new Date().getTime()));
+ }
+
+ o.headers = Ext.apply(o.headers || {}, me.defaultHeaders || {});
+
+ if(o.autoAbort === true || me.autoAbort) {
+ me.abort();
+ }
+
+ if((method == GET || o.xmlData || o.jsonData) && p){
+ url = Ext.urlAppend(url, p);
+ p = '';
+ }
+ return (me.transId = Ext.lib.Ajax.request(method, url, cb, p, o));
+ }else{
+ return o.callback ? o.callback.apply(o.scope, [o,UNDEFINED,UNDEFINED]) : null;
+ }
+ },
+
+
+ isLoading : function(transId){
+ return transId ? Ext.lib.Ajax.isCallInProgress(transId) : !! this.transId;
+ },
+
+
+ abort : function(transId){
+ if(transId || this.isLoading()){
+ Ext.lib.Ajax.abort(transId || this.transId);
+ }
+ },
+
+
+ handleResponse : function(response){
+ this.transId = false;
+ var options = response.argument.options;
+ response.argument = options ? options.argument : null;
+ this.fireEvent(REQUESTCOMPLETE, this, response, options);
+ if(options.success){
+ options.success.call(options.scope, response, options);
+ }
+ if(options.callback){
+ options.callback.call(options.scope, options, true, response);
+ }
+ },
+
+
+ handleFailure : function(response, e){
+ this.transId = false;
+ var options = response.argument.options;
+ response.argument = options ? options.argument : null;
+ this.fireEvent(REQUESTEXCEPTION, this, response, options, e);
+ if(options.failure){
+ options.failure.call(options.scope, response, options);
+ }
+ if(options.callback){
+ options.callback.call(options.scope, options, false, response);
+ }
+ },
+
+
+ doFormUpload : function(o, ps, url){
+ var id = Ext.id(),
+ doc = document,
+ frame = doc.createElement('iframe'),
+ form = Ext.getDom(o.form),
+ hiddens = [],
+ hd,
+ encoding = 'multipart/form-data',
+ buf = {
+ target: form.target,
+ method: form.method,
+ encoding: form.encoding,
+ enctype: form.enctype,
+ action: form.action
+ };
+
+
+ Ext.fly(frame).set({
+ id: id,
+ name: id,
+ cls: 'x-hidden',
+ src: Ext.SSL_SECURE_URL
+ });
+
+ doc.body.appendChild(frame);
+
+
+ if(Ext.isIE){
+ document.frames[id].name = id;
+ }
+
+
+ Ext.fly(form).set({
+ target: id,
+ method: POST,
+ enctype: encoding,
+ encoding: encoding,
+ action: url || buf.action
+ });
+
+
+ Ext.iterate(Ext.urlDecode(ps, false), function(k, v){
+ hd = doc.createElement('input');
+ Ext.fly(hd).set({
+ type: 'hidden',
+ value: v,
+ name: k
+ });
+ form.appendChild(hd);
+ hiddens.push(hd);
+ });
+
+ function cb(){
+ var me = this,
+
+ r = {responseText : '',
+ responseXML : null,
+ argument : o.argument},
+ doc,
+ firstChild;
+
+ try{
+ doc = frame.contentWindow.document || frame.contentDocument || WINDOW.frames[id].document;
+ if(doc){
+ if(doc.body){
+ if(/textarea/i.test((firstChild = doc.body.firstChild || {}).tagName)){
+ r.responseText = firstChild.value;
+ }else{
+ r.responseText = doc.body.innerHTML;
+ }
+ }
+
+ r.responseXML = doc.XMLDocument || doc;
+ }
+ }
+ catch(e) {}
-
-
- a1 = me.getAnchorXY(p1, true);
- a2 = el.getAnchorXY(p2, false);
+ Ext.EventManager.removeListener(frame, LOAD, cb, me);
- x = a2[0] - a1[0] + o[0];
- y = a2[1] - a1[1] + o[1];
+ me.fireEvent(REQUESTCOMPLETE, me, r, o);
- if(c){
- w = me.getWidth();
- h = me.getHeight();
- r = el.getRegion();
-
-
-
- p1y = p1.charAt(0);
- p1x = p1.charAt(p1.length-1);
- p2y = p2.charAt(0);
- p2x = p2.charAt(p2.length-1);
- swapY = ((p1y=="t" && p2y=="b") || (p1y=="b" && p2y=="t"));
- swapX = ((p1x=="r" && p2x=="l") || (p1x=="l" && p2x=="r"));
-
+ function runCallback(fn, scope, args){
+ if(Ext.isFunction(fn)){
+ fn.apply(scope, args);
+ }
+ }
- if (x + w > dw + scrollX) {
- x = swapX ? r.left-w : dw+scrollX-w;
- }
- if (x < scrollX) {
- x = swapX ? r.right : scrollX;
- }
- if (y + h > dh + scrollY) {
- y = swapY ? r.top-h : dh+scrollY-h;
+ runCallback(o.success, o.scope, [r, o]);
+ runCallback(o.callback, o.scope, [o, true, r]);
+
+ if(!me.debugUploads){
+ setTimeout(function(){Ext.removeNode(frame);}, 100);
+ }
}
- if (y < scrollY){
- y = swapY ? r.bottom : scrollY;
- }
+
+ Ext.EventManager.on(frame, LOAD, cb, this);
+ form.submit();
+
+ Ext.fly(form).set(buf);
+ Ext.each(hiddens, function(h) {
+ Ext.removeNode(h);
+ });
}
- return [x,y];
- },
+ });
+})();
+
+
+Ext.Ajax = new Ext.data.Connection({
+
+
+
+
+
+
- alignTo : function(element, position, offsets, animate){
- var me = this;
- return me.setXY(me.getAlignToXY(element, position, offsets),
- me.preanim && !!animate ? me.preanim(arguments, 3) : false);
- },
+
+
+
+
+
- adjustForConstraints : function(xy, parent, offsets){
- return this.getConstrainToXY(parent || document, false, offsets, xy) || xy;
- },
- getConstrainToXY : function(el, local, offsets, proposedXY){
- var os = {top:0, left:0, bottom:0, right: 0};
+ autoAbort : false,
- return function(el, local, offsets, proposedXY){
- el = Ext.get(el);
- offsets = offsets ? Ext.applyIf(offsets, os) : os;
+
+ serializeForm : function(form){
+ return Ext.lib.Ajax.serializeForm(form);
+ }
+});
- var vw, vh, vx = 0, vy = 0;
- if(el.dom == document.body || el.dom == document){
- vw =Ext.lib.Dom.getViewWidth();
- vh = Ext.lib.Dom.getViewHeight();
- }else{
- vw = el.dom.clientWidth;
- vh = el.dom.clientHeight;
- if(!local){
- var vxy = el.getXY();
- vx = vxy[0];
- vy = vxy[1];
+Ext.util.JSON = new (function(){
+ var useHasOwn = !!{}.hasOwnProperty,
+ isNative = function() {
+ var useNative = null;
+
+ return function() {
+ if (useNative === null) {
+ useNative = Ext.USE_NATIVE_JSON && window.JSON && JSON.toString() == '[object JSON]';
+ }
+
+ return useNative;
+ };
+ }(),
+ pad = function(n) {
+ return n < 10 ? "0" + n : n;
+ },
+ doDecode = function(json){
+ return eval("(" + json + ")");
+ },
+ doEncode = function(o){
+ if(!Ext.isDefined(o) || o === null){
+ return "null";
+ }else if(Ext.isArray(o)){
+ return encodeArray(o);
+ }else if(Ext.isDate(o)){
+ return Ext.util.JSON.encodeDate(o);
+ }else if(Ext.isString(o)){
+ return encodeString(o);
+ }else if(typeof o == "number"){
+
+ return isFinite(o) ? String(o) : "null";
+ }else if(Ext.isBoolean(o)){
+ return String(o);
+ }else {
+ var a = ["{"], b, i, v;
+ for (i in o) {
+
+ if(!o.getElementsByTagName){
+ if(!useHasOwn || o.hasOwnProperty(i)) {
+ v = o[i];
+ switch (typeof v) {
+ case "undefined":
+ case "function":
+ case "unknown":
+ break;
+ default:
+ if(b){
+ a.push(',');
+ }
+ a.push(doEncode(i), ":",
+ v === null ? "null" : doEncode(v));
+ b = true;
+ }
+ }
+ }
+ }
+ a.push("}");
+ return a.join("");
+ }
+ },
+ m = {
+ "\b": '\\b',
+ "\t": '\\t',
+ "\n": '\\n',
+ "\f": '\\f',
+ "\r": '\\r',
+ '"' : '\\"',
+ "\\": '\\\\'
+ },
+ encodeString = function(s){
+ if (/["\\\x00-\x1f]/.test(s)) {
+ return '"' + s.replace(/([\x00-\x1f\\"])/g, function(a, b) {
+ var c = m[b];
+ if(c){
+ return c;
+ }
+ c = b.charCodeAt();
+ return "\\u00" +
+ Math.floor(c / 16).toString(16) +
+ (c % 16).toString(16);
+ }) + '"';
+ }
+ return '"' + s + '"';
+ },
+ encodeArray = function(o){
+ var a = ["["], b, i, l = o.length, v;
+ for (i = 0; i < l; i += 1) {
+ v = o[i];
+ switch (typeof v) {
+ case "undefined":
+ case "function":
+ case "unknown":
+ break;
+ default:
+ if (b) {
+ a.push(',');
+ }
+ a.push(v === null ? "null" : Ext.util.JSON.encode(v));
+ b = true;
+ }
}
+ a.push("]");
+ return a.join("");
+ };
+
+
+ this.encodeDate = function(o){
+ return '"' + o.getFullYear() + "-" +
+ pad(o.getMonth() + 1) + "-" +
+ pad(o.getDate()) + "T" +
+ pad(o.getHours()) + ":" +
+ pad(o.getMinutes()) + ":" +
+ pad(o.getSeconds()) + '"';
+ };
+
+
+ this.encode = function() {
+ var ec;
+ return function(o) {
+ if (!ec) {
+
+ ec = isNative() ? JSON.stringify : doEncode;
}
+ return ec(o);
+ };
+ }();
- var s = el.getScroll();
- vx += offsets.left + s.left;
- vy += offsets.top + s.top;
+
+ this.decode = function() {
+ var dc;
+ return function(json) {
+ if (!dc) {
+
+ dc = isNative() ? JSON.parse : doDecode;
+ }
+ return dc(json);
+ };
+ }();
- vw -= offsets.right;
- vh -= offsets.bottom;
+})();
- var vr = vx+vw;
- var vb = vy+vh;
+Ext.encode = Ext.util.JSON.encode;
- var xy = proposedXY || (!local ? this.getXY() : [this.getLeft(true), this.getTop(true)]);
- var x = xy[0], y = xy[1];
- var w = this.dom.offsetWidth, h = this.dom.offsetHeight;
+Ext.decode = Ext.util.JSON.decode;
-
- var moved = false;
+Ext.EventManager = function(){
+ var docReadyEvent,
+ docReadyProcId,
+ docReadyState = false,
+ DETECT_NATIVE = Ext.isGecko || Ext.isWebKit || Ext.isSafari,
+ E = Ext.lib.Event,
+ D = Ext.lib.Dom,
+ DOC = document,
+ WINDOW = window,
+ DOMCONTENTLOADED = "DOMContentLoaded",
+ COMPLETE = 'complete',
+ propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,
+
+ specialElCache = [];
+ function getId(el){
+ var id = false,
+ i = 0,
+ len = specialElCache.length,
+ skip = false,
+ o;
- if((x + w) > vr){
- x = vr - w;
- moved = true;
+ if (el) {
+ if (el.getElementById || el.navigator) {
+
+ for(; i < len; ++i){
+ o = specialElCache[i];
+ if(o.el === el){
+ id = o.id;
+ break;
+ }
+ }
+ if(!id){
+
+ id = Ext.id(el);
+ specialElCache.push({
+ id: id,
+ el: el
+ });
+ skip = true;
+ }
+ }else{
+ id = Ext.id(el);
}
- if((y + h) > vb){
- y = vb - h;
- moved = true;
+ if(!Ext.elCache[id]){
+ Ext.Element.addToCache(new Ext.Element(el), id);
+ if(skip){
+ Ext.elCache[id].skipGC = true;
+ }
}
-
- if(x < vx){
- x = vx;
- moved = true;
+ }
+ return id;
+ }
+
+
+ function addListener(el, ename, fn, task, 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, task]);
+
+
+
+
+
+ if(el.addEventListener && ename == "mousewheel"){
+ var args = ["DOMMouseScroll", wrap, false];
+ el.addEventListener.apply(el, args);
+ Ext.EventManager.addListener(WINDOW, 'unload', function(){
+ el.removeEventListener.apply(el, args);
+ });
+ }
+
+
+ if(el == DOC && ename == "mousedown"){
+ Ext.EventManager.stoppedMouseDownEvent.addListener(wrap);
+ }
+ }
+
+ function doScrollChk(){
+
+ if(window != top){
+ return false;
+ }
+
+ try{
+ DOC.documentElement.doScroll('left');
+ }catch(e){
+ return false;
+ }
+
+ fireDocReady();
+ return true;
+ }
+
+ function checkReadyState(e){
+
+ if(Ext.isIE && doScrollChk()){
+ return true;
+ }
+ if(DOC.readyState == COMPLETE){
+ fireDocReady();
+ return true;
+ }
+ docReadyState || (docReadyProcId = setTimeout(arguments.callee, 2));
+ return false;
+ }
+
+ var styles;
+ function checkStyleSheets(e){
+ styles || (styles = Ext.query('style, link[rel=stylesheet]'));
+ if(styles.length == DOC.styleSheets.length){
+ fireDocReady();
+ return true;
+ }
+ docReadyState || (docReadyProcId = setTimeout(arguments.callee, 2));
+ return false;
+ }
+
+ function OperaDOMContentLoaded(e){
+ DOC.removeEventListener(DOMCONTENTLOADED, arguments.callee, false);
+ checkStyleSheets();
+ }
+
+ function fireDocReady(e){
+ if(!docReadyState){
+ docReadyState = true;
+
+ if(docReadyProcId){
+ clearTimeout(docReadyProcId);
}
- if(y < vy){
- y = vy;
- moved = true;
+ if(DETECT_NATIVE) {
+ DOC.removeEventListener(DOMCONTENTLOADED, fireDocReady, false);
+ }
+ if(Ext.isIE && checkReadyState.bindIE){
+ DOC.detachEvent('onreadystatechange', checkReadyState);
+ }
+ E.un(WINDOW, "load", arguments.callee);
+ }
+ if(docReadyEvent && !Ext.isReady){
+ Ext.isReady = true;
+ docReadyEvent.fire();
+ docReadyEvent.listeners = [];
+ }
+
+ }
+
+ function initDocReady(){
+ docReadyEvent || (docReadyEvent = new Ext.util.Event());
+ if (DETECT_NATIVE) {
+ DOC.addEventListener(DOMCONTENTLOADED, fireDocReady, false);
+ }
+
+ if (Ext.isIE){
+
+
+ if(!checkReadyState()){
+ checkReadyState.bindIE = true;
+ DOC.attachEvent('onreadystatechange', checkReadyState);
}
- return moved ? [x, y] : false;
- };
- }(),
-
-
-
+ }else if(Ext.isOpera ){
+
+
+ (DOC.readyState == COMPLETE && checkStyleSheets()) ||
+ DOC.addEventListener(DOMCONTENTLOADED, OperaDOMContentLoaded, false);
+ }else if (Ext.isWebKit){
+
+ checkReadyState();
+ }
+
+ 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);
+ }
+ };
+ }
+ function createBuffered(h, o, task){
+ return function(e){
+
+ task.delay(o.buffer, h, null, [new Ext.EventObjectImpl(e)]);
+ };
+ }
+ function createSingle(h, el, ename, fn, scope){
+ return function(e){
+ Ext.EventManager.removeListener(el, ename, fn, scope);
+ h(e);
+ };
+ }
+ function createDelayed(h, o, fn){
+ return function(e){
+ var task = new Ext.util.DelayedTask(h);
+ if(!fn.tasks) {
+ fn.tasks = [];
+ }
+ fn.tasks.push(task);
+ task.delay(o.delay || 10, h, null, [new Ext.EventObjectImpl(e)]);
+ };
+ }
+ function listen(element, ename, opt, fn, scope){
+ var o = (!opt || typeof opt == "boolean") ? {} : opt,
+ el = Ext.getDom(element), task;
+ fn = fn || o.fn;
+ scope = scope || o.scope;
+ 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 === false) {
+ e = e.browserEvent;
+ }
+ 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){
+ task = new Ext.util.DelayedTask(h);
+ h = createBuffered(h, o, task);
+ }
+ addListener(el, ename, fn, task, h, scope);
+ return h;
+ }
+ var pub = {
+
+ addListener : function(element, eventName, fn, scope, options){
+ if(typeof eventName == 'object'){
+ 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, len, fnc;
+ for (i = 0, len = f.length; i < len; i++) {
+
+ if (Ext.isArray(fnc = f[i]) && fnc[0] == fn && (!scope || fnc[2] == scope)) {
+ if(fnc[4]) {
+ fnc[4].cancel();
+ }
+ k = fn.tasks && fn.tasks.length;
+ if(k) {
+ while(k--) {
+ fn.tasks[k].cancel();
+ }
+ delete fn.tasks;
+ }
+ wrap = fnc[1];
+ E.un(el, eventName, E.extAdapter ? fnc[3] : wrap);
+
+ if(wrap && el.addEventListener && eventName == "mousewheel"){
+ el.removeEventListener("DOMMouseScroll", wrap, false);
+ }
+
+ if(wrap && el == DOC && eventName == "mousedown"){
+ Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
+ }
+ 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;
+ }
+ }
+ },
+
+ removeAll : function(el){
+ el = Ext.getDom(el);
+ var id = getId(el),
+ ec = Ext.elCache[id] || {},
+ es = ec.events || {},
+ f, i, len, ename, fn, k, wrap;
+ for(ename in es){
+ if(es.hasOwnProperty(ename)){
+ f = es[ename];
+
+ for (i = 0, len = f.length; i < len; i++) {
+ fn = f[i];
+ if(fn[4]) {
+ fn[4].cancel();
+ }
+ if(fn[0].tasks && (k = fn[0].tasks.length)) {
+ while(k--) {
+ fn[0].tasks[k].cancel();
+ }
+ delete fn.tasks;
+ }
+ wrap = fn[1];
+ E.un(el, ename, E.extAdapter ? fn[3] : wrap);
+
+ if(el.addEventListener && wrap && ename == "mousewheel"){
+ el.removeEventListener("DOMMouseScroll", wrap, false);
+ }
+
+ if(wrap && el == DOC && ename == "mousedown"){
+ Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
+ }
+ }
+ }
+ }
+ 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);
+ }
+ delete Ext.elCache;
+ delete Ext.Element._flyweights;
+
+ var c,
+ conn,
+ tid,
+ ajax = Ext.lib.Ajax;
+ (typeof ajax.conn == 'object') ? conn = ajax.conn : conn = {};
+ for (tid in conn) {
+ c = conn[tid];
+ if (c) {
+ ajax.abort({conn: c, tId: tid});
+ }
+ }
+ },
+
+ onDocumentReady : function(fn, scope, options){
+ if (Ext.isReady) {
+ docReadyEvent || (docReadyEvent = new Ext.util.Event());
+ 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);
+ }
+ },
+
+ fireDocReady : fireDocReady
+ };
+
+ 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");
+ }
+
+ if (Ext.isStrict || Ext.isBorderBox) {
+ var p = bd.parentNode;
+ if (p) {
+ Ext.fly(p, '_internal').addClass(((Ext.isStrict && Ext.isIE ) || (!Ext.enableForcedBoxModel && !Ext.isIE)) ? ' ext-strict' : ' ext-border-box');
+ }
+ }
+
+
+ if (Ext.enableForcedBoxModel && !Ext.isIE) {
+ Ext.isForcedBorderBox = true;
+ cls.push("ext-forced-border-box");
+ }
+
+ Ext.fly(bd, '_internal').addClass(cls);
+ return true;
+ };
+
+ if (!initExtCss()) {
+ Ext.onReady(initExtCss);
+ }
+})();
+(function(){
+ var supports = Ext.apply(Ext.supports, {
+
+ correctRightMargin: true,
+
+
+ correctTransparentColor: true,
+
+
+ cssFloat: true
+ });
+
+ var supportTests = function(){
+ var div = document.createElement('div'),
+ doc = document,
+ view,
+ last;
+
+ div.innerHTML = '<div style="height:30px;width:50px;"><div style="height:20px;width:20px;"></div></div><div style="float:left;background-color:transparent;">';
+ doc.body.appendChild(div);
+ last = div.lastChild;
+
+ if((view = doc.defaultView)){
+ if(view.getComputedStyle(div.firstChild.firstChild, null).marginRight != '0px'){
+ supports.correctRightMargin = false;
+ }
+ if(view.getComputedStyle(last, null).backgroundColor != 'transparent'){
+ supports.correctTransparentColor = false;
+ }
+ }
+ supports.cssFloat = !!last.style.cssFloat;
+ doc.body.removeChild(div);
+ };
+
+ if (Ext.isReady) {
+ supportTests();
+ } else {
+ Ext.onReady(supportTests);
+ }
+})();
+Ext.EventObject = function(){
+ var E = Ext.lib.Event,
+ clickRe = /(dbl)?click/,
+
+ 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} : {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(clickRe.test(e.type) && 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);
+ }
+ },
+
+ 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;
+ },
+
+ getKey : function(){
+ return this.normalizeKey(this.keyCode || this.charCode);
+ },
+
+ normalizeKey: function(k){
+ return Ext.isSafari ? (safariKeys[k] || k) : k;
+ },
+
+ getPageX : function(){
+ return this.xy[0];
+ },
+
+ getPageY : function(){
+ return this.xy[1];
+ },
-
-
- getCenterXY : function(){
- return this.getAlignToXY(document, 'c-c');
- },
+
+ getXY : function(){
+ return this.xy;
+ },
-
- center : function(centerIn){
- return this.alignTo(centerIn || document, 'c-c');
- }
-});
+
+ getTarget : function(selector, maxDepth, returnEl){
+ return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : (returnEl ? Ext.get(this.target) : this.target);
+ },
-Ext.Element.addMethods(function(){
- var PARENTNODE = 'parentNode',
- NEXTSIBLING = 'nextSibling',
- PREVIOUSSIBLING = 'previousSibling',
- DQ = Ext.DomQuery,
- GET = Ext.get;
-
- return {
-
- findParent : function(simpleSelector, maxDepth, returnEl){
- var p = this.dom,
- b = document.body,
- depth = 0,
- stopEl;
- if(Ext.isGecko && Object.prototype.toString.call(p) == '[object XULElement]') {
- return null;
- }
- maxDepth = maxDepth || 50;
- if (isNaN(maxDepth)) {
- stopEl = Ext.getDom(maxDepth);
- maxDepth = Number.MAX_VALUE;
- }
- while(p && p.nodeType == 1 && depth < maxDepth && p != b && p != stopEl){
- if(DQ.is(p, simpleSelector)){
- return returnEl ? GET(p) : p;
- }
- depth++;
- p = p.parentNode;
- }
- return null;
- },
-
-
- findParentNode : function(simpleSelector, maxDepth, returnEl){
- var p = Ext.fly(this.dom.parentNode, '_internal');
- return p ? p.findParent(simpleSelector, maxDepth, returnEl) : null;
- },
-
-
- up : function(simpleSelector, maxDepth){
- return this.findParentNode(simpleSelector, maxDepth, true);
- },
-
-
- select : function(selector){
- return Ext.Element.select(selector, this.dom);
- },
-
-
- query : function(selector){
- return DQ.select(selector, this.dom);
- },
-
-
- child : function(selector, returnDom){
- var n = DQ.selectNode(selector, this.dom);
- return returnDom ? n : GET(n);
- },
-
-
- down : function(selector, returnDom){
- var n = DQ.selectNode(" > " + selector, this.dom);
- return returnDom ? n : GET(n);
- },
-
-
- parent : function(selector, returnDom){
- return this.matchNode(PARENTNODE, PARENTNODE, selector, returnDom);
- },
-
-
- next : function(selector, returnDom){
- return this.matchNode(NEXTSIBLING, NEXTSIBLING, selector, returnDom);
- },
-
-
- prev : function(selector, returnDom){
- return this.matchNode(PREVIOUSSIBLING, PREVIOUSSIBLING, selector, returnDom);
- },
-
-
-
- first : function(selector, returnDom){
- return this.matchNode(NEXTSIBLING, 'firstChild', selector, returnDom);
- },
-
-
- last : function(selector, returnDom){
- return this.matchNode(PREVIOUSSIBLING, 'lastChild', selector, returnDom);
- },
-
- matchNode : function(dir, start, selector, returnDom){
- var n = this.dom[start];
- while(n){
- if(n.nodeType == 1 && (!selector || DQ.is(n, selector))){
- return !returnDom ? GET(n) : n;
- }
- n = n[dir];
- }
- return null;
- }
- }
-}());
-Ext.Element.addMethods({
-
- select : function(selector, unique){
- return Ext.Element.select(selector, unique, this.dom);
- }
-});
-Ext.Element.addMethods(
-function() {
- var GETDOM = Ext.getDom,
- GET = Ext.get,
- DH = Ext.DomHelper;
-
- return {
-
- appendChild: function(el){
- return GET(el).appendTo(this);
- },
-
-
- appendTo: function(el){
- GETDOM(el).appendChild(this.dom);
- return this;
- },
-
-
- insertBefore: function(el){
- (el = GETDOM(el)).parentNode.insertBefore(this.dom, el);
- return this;
- },
-
-
- insertAfter: function(el){
- (el = GETDOM(el)).parentNode.insertBefore(this.dom, el.nextSibling);
- return this;
- },
-
-
- insertFirst: function(el, returnDom){
- el = el || {};
- if(el.nodeType || el.dom || typeof el == 'string'){
- el = GETDOM(el);
- this.dom.insertBefore(el, this.dom.firstChild);
- return !returnDom ? GET(el) : el;
- }else{
- return this.createChild(el, this.dom.firstChild, returnDom);
+
+ 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;
},
-
-
- replace: function(el){
- el = GET(el);
- this.insertBefore(el);
- el.remove();
- return this;
- },
-
-
- replaceWith: function(el){
- var me = this;
-
- if(el.nodeType || el.dom || typeof el == 'string'){
- el = GETDOM(el);
- me.dom.parentNode.insertBefore(el, me.dom);
- }else{
- el = DH.insertBefore(me.dom, el);
+
+
+ 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));
}
-
- delete Ext.elCache[me.id];
- Ext.removeNode(me.dom);
- me.id = Ext.id(me.dom = el);
- Ext.Element.addToCache(me.isFlyweight ? new Ext.Element(me.dom) : me);
- return me;
- },
-
-
- createChild: function(config, insertBefore, returnDom){
- config = config || {tag:'div'};
- return insertBefore ?
- DH.insertBefore(insertBefore, config, returnDom !== true) :
- DH[!this.dom.firstChild ? 'overwrite' : 'append'](this.dom, config, returnDom !== true);
- },
-
-
- wrap: function(config, returnDom){
- var newEl = DH.insertBefore(this.dom, config || {tag: "div"}, !returnDom);
- newEl.dom ? newEl.dom.appendChild(this.dom) : newEl.appendChild(this.dom);
- return newEl;
- },
-
-
- insertHtml : function(where, html, returnEl){
- var el = DH.insertHtml(where, this.dom, html);
- return returnEl ? Ext.get(el) : el;
- }
- }
-}());
-Ext.apply(Ext.Element.prototype, function() {
- var GETDOM = Ext.getDom,
- GET = Ext.get,
- DH = Ext.DomHelper;
-
- return {
-
- insertSibling: function(el, where, returnDom){
- var me = this,
- rt,
- isAfter = (where || 'before').toLowerCase() == 'after',
- insertEl;
-
- if(Ext.isArray(el)){
- insertEl = me;
- Ext.each(el, function(e) {
- rt = Ext.fly(insertEl, '_internal').insertSibling(e, where, returnDom);
- if(isAfter){
- insertEl = rt;
- }
- });
- return rt;
- }
-
- el = el || {};
-
- if(el.nodeType || el.dom){
- rt = me.dom.parentNode.insertBefore(GETDOM(el), isAfter ? me.dom.nextSibling : me.dom);
- if (!returnDom) {
- rt = GET(rt);
- }
- }else{
- if (isAfter && !me.dom.nextSibling) {
- rt = DH.append(me.dom.parentNode, el, !returnDom);
- } else {
- rt = DH[isAfter ? 'insertAfter' : 'insertBefore'](me.dom, el, !returnDom);
+ return false;
+ }
+ };
+
+ return new Ext.EventObjectImpl();
+}();
+
+Ext.Loader = Ext.apply({}, {
+
+ load: function(fileList, callback, scope, preserveOrder) {
+ var scope = scope || this,
+ head = document.getElementsByTagName("head")[0],
+ fragment = document.createDocumentFragment(),
+ numFiles = fileList.length,
+ loadedFiles = 0,
+ me = this;
+
+
+ var loadFileIndex = function(index) {
+ head.appendChild(
+ me.buildScriptTag(fileList[index], onFileLoaded)
+ );
+ };
+
+
+ var onFileLoaded = function() {
+ loadedFiles ++;
+
+
+ if (numFiles == loadedFiles && typeof callback == 'function') {
+ callback.call(scope);
+ } else {
+ if (preserveOrder === true) {
+ loadFileIndex(loadedFiles);
}
}
- return rt;
- }
- };
-}());
-Ext.Element.addMethods(function(){
+ };
+
+ if (preserveOrder === true) {
+ loadFileIndex.call(this, 0);
+ } else {
+
+ Ext.each(fileList, function(file, index) {
+ fragment.appendChild(
+ this.buildScriptTag(file, onFileLoaded)
+ );
+ }, this);
+
+ head.appendChild(fragment);
+ }
+ },
- var propCache = {},
- camelRe = /(-[a-z])/gi,
- classReCache = {},
- view = document.defaultView,
- propFloat = Ext.isIE ? 'styleFloat' : 'cssFloat',
- opacityRe = /alpha\(opacity=(.*)\)/i,
- trimRe = /^\s+|\s+$/g,
- spacesRe = /\s+/,
- wordsRe = /\w/g,
- EL = Ext.Element,
- PADDING = "padding",
- MARGIN = "margin",
- BORDER = "border",
- LEFT = "-left",
- RIGHT = "-right",
- TOP = "-top",
- BOTTOM = "-bottom",
- WIDTH = "-width",
- MATH = Math,
- HIDDEN = 'hidden',
- ISCLIPPED = 'isClipped',
- OVERFLOW = 'overflow',
- OVERFLOWX = 'overflow-x',
- OVERFLOWY = 'overflow-y',
- ORIGINALCLIP = 'originalClip',
+
+ buildScriptTag: function(filename, callback) {
+ var script = document.createElement('script');
+ script.type = "text/javascript";
+ script.src = filename;
- borders = {l: BORDER + LEFT + WIDTH, r: BORDER + RIGHT + WIDTH, t: BORDER + TOP + WIDTH, b: BORDER + BOTTOM + WIDTH},
- paddings = {l: PADDING + LEFT, r: PADDING + RIGHT, t: PADDING + TOP, b: PADDING + BOTTOM},
- margins = {l: MARGIN + LEFT, r: MARGIN + RIGHT, t: MARGIN + TOP, b: MARGIN + BOTTOM},
- data = Ext.Element.data;
+
+ if (script.readyState) {
+ script.onreadystatechange = function() {
+ if (script.readyState == "loaded" || script.readyState == "complete") {
+ script.onreadystatechange = null;
+ callback();
+ }
+ };
+ } else {
+ script.onload = callback;
+ }
+
+ return script;
+ }
+});
+Ext.ns("Ext.grid", "Ext.list", "Ext.dd", "Ext.tree", "Ext.form", "Ext.menu",
+ "Ext.state", "Ext.layout", "Ext.app", "Ext.ux", "Ext.chart", "Ext.direct");
- function camelFn(m, a) {
- return a.charAt(1).toUpperCase();
- }
- function chkCache(prop) {
- return propCache[prop] || (propCache[prop] = prop == 'float' ? propFloat : prop.replace(camelRe, camelFn));
- }
+Ext.apply(Ext, function(){
+ var E = Ext,
+ idSeed = 0,
+ scrollWidth = null;
return {
- adjustWidth : function(width) {
- var me = this;
- var isNum = (typeof width == "number");
- if(isNum && me.autoBoxAdjust && !me.isBorderBox()){
- width -= (me.getBorderWidth("lr") + me.getPadding("lr"));
- }
- return (isNum && width < 0) ? 0 : width;
+ emptyFn : function(){},
+
+
+ BLANK_IMAGE_URL : Ext.isIE6 || Ext.isIE7 || Ext.isAir ?
+ 'http:/' + '/www.extjs.com/s.gif' :
+ 'data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==',
+
+ extendX : function(supr, fn){
+ return Ext.extend(supr, fn(supr.prototype));
},
- adjustHeight : function(height) {
- var me = this;
- var isNum = (typeof height == "number");
- if(isNum && me.autoBoxAdjust && !me.isBorderBox()){
- height -= (me.getBorderWidth("tb") + me.getPadding("tb"));
- }
- return (isNum && height < 0) ? 0 : height;
+ getDoc : function(){
+ return Ext.get(document);
},
+
+ num : function(v, defaultValue){
+ v = Number(Ext.isEmpty(v) || Ext.isArray(v) || typeof v == 'boolean' || (typeof v == 'string' && v.trim().length == 0) ? NaN : v);
+ return isNaN(v) ? defaultValue : v;
+ },
- addClass : function(className){
- var me = this,
- i,
- len,
- v,
- cls = [];
-
- if (!Ext.isArray(className)) {
- if (typeof className == 'string' && !this.hasClass(className)) {
- me.dom.className += " " + className;
- }
- }
- else {
- for (i = 0, len = className.length; i < len; i++) {
- v = className[i];
- if (typeof v == 'string' && (' ' + me.dom.className + ' ').indexOf(' ' + v + ' ') == -1) {
- cls.push(v);
+ value : function(v, defaultValue, allowBlank){
+ return Ext.isEmpty(v, allowBlank) ? defaultValue : v;
+ },
+
+
+ escapeRe : function(s) {
+ return s.replace(/([-.*+?^${}()|[\]\/\\])/g, "\\$1");
+ },
+
+ sequence : function(o, name, fn, scope){
+ o[name] = o[name].createSequence(fn, scope);
+ },
+
+
+ addBehaviors : function(o){
+ if(!Ext.isReady){
+ Ext.onReady(function(){
+ Ext.addBehaviors(o);
+ });
+ } else {
+ var cache = {},
+ parts,
+ b,
+ s;
+ for (b in o) {
+ if ((parts = b.split('@'))[1]) {
+ s = parts[0];
+ if(!cache[s]){
+ cache[s] = Ext.select(s);
+ }
+ cache[s].on(parts[1], o[b]);
}
}
- if (cls.length) {
- me.dom.className += " " + cls.join(" ");
+ cache = null;
+ }
+ },
+
+
+ getScrollBarWidth: function(force){
+ if(!Ext.isReady){
+ return 0;
+ }
+
+ if(force === true || scrollWidth === null){
+
+ var div = Ext.getBody().createChild('<div class="x-hide-offsets" style="width:100px;height:50px;overflow:hidden;"><div style="height:200px;"></div></div>'),
+ child = div.child('div', true);
+ var w1 = child.offsetWidth;
+ div.setStyle('overflow', (Ext.isWebKit || Ext.isGecko) ? 'auto' : 'scroll');
+ var w2 = child.offsetWidth;
+ div.remove();
+
+ scrollWidth = w1 - w2 + 2;
+ }
+ return scrollWidth;
+ },
+
+
+
+ combine : function(){
+ var as = arguments, l = as.length, r = [];
+ for(var i = 0; i < l; i++){
+ var a = as[i];
+ if(Ext.isArray(a)){
+ r = r.concat(a);
+ }else if(a.length !== undefined && !a.substr){
+ r = r.concat(Array.prototype.slice.call(a, 0));
+ }else{
+ r.push(a);
}
}
- return me;
+ return r;
},
- removeClass : function(className){
- var me = this,
- i,
- idx,
- len,
- cls,
- elClasses;
- if (!Ext.isArray(className)){
- className = [className];
+ copyTo : function(dest, source, names){
+ if(typeof names == 'string'){
+ names = names.split(/[,;\s]/);
}
- if (me.dom && me.dom.className) {
- elClasses = me.dom.className.replace(trimRe, '').split(spacesRe);
- for (i = 0, len = className.length; i < len; i++) {
- cls = className[i];
- if (typeof cls == 'string') {
- cls = cls.replace(trimRe, '');
- idx = elClasses.indexOf(cls);
- if (idx != -1) {
- elClasses.splice(idx, 1);
- }
+ Ext.each(names, function(name){
+ if(source.hasOwnProperty(name)){
+ dest[name] = source[name];
+ }
+ }, this);
+ return dest;
+ },
+
+
+ destroy : function(){
+ Ext.each(arguments, function(arg){
+ if(arg){
+ if(Ext.isArray(arg)){
+ this.destroy.apply(this, arg);
+ }else if(typeof arg.destroy == 'function'){
+ arg.destroy();
+ }else if(arg.dom){
+ arg.remove();
}
}
- me.dom.className = elClasses.join(" ");
+ }, this);
+ },
+
+
+ destroyMembers : function(o, arg1, arg2, etc){
+ for(var i = 1, a = arguments, len = a.length; i < len; i++) {
+ Ext.destroy(o[a[i]]);
+ delete o[a[i]];
}
- return me;
},
- radioClass : function(className){
- var cn = this.dom.parentNode.childNodes,
- v,
- i,
- len;
- className = Ext.isArray(className) ? className : [className];
- for (i = 0, len = cn.length; i < len; i++) {
- v = cn[i];
- if (v && v.nodeType == 1) {
- Ext.fly(v, '_internal').removeClass(className);
+ clean : function(arr){
+ var ret = [];
+ Ext.each(arr, function(v){
+ if(!!v){
+ ret.push(v);
}
- };
- return this.addClass(className);
+ });
+ return ret;
},
- toggleClass : function(className){
- return this.hasClass(className) ? this.removeClass(className) : this.addClass(className);
+ unique : function(arr){
+ var ret = [],
+ collect = {};
+
+ Ext.each(arr, function(v) {
+ if(!collect[v]){
+ ret.push(v);
+ }
+ collect[v] = true;
+ });
+ return ret;
},
- hasClass : function(className){
- return className && (' '+this.dom.className+' ').indexOf(' '+className+' ') != -1;
+ flatten : function(arr){
+ var worker = [];
+ function rFlatten(a) {
+ Ext.each(a, function(v) {
+ if(Ext.isArray(v)){
+ rFlatten(v);
+ }else{
+ worker.push(v);
+ }
+ });
+ return worker;
+ }
+ return rFlatten(arr);
},
- replaceClass : function(oldClassName, newClassName){
- return this.removeClass(oldClassName).addClass(newClassName);
+ min : function(arr, comp){
+ var ret = arr[0];
+ comp = comp || function(a,b){ return a < b ? -1 : 1; };
+ Ext.each(arr, function(v) {
+ ret = comp(ret, v) == -1 ? ret : v;
+ });
+ return ret;
},
- isStyle : function(style, val) {
- return this.getStyle(style) == val;
+
+ max : function(arr, comp){
+ var ret = arr[0];
+ comp = comp || function(a,b){ return a > b ? 1 : -1; };
+ Ext.each(arr, function(v) {
+ ret = comp(ret, v) == 1 ? ret : v;
+ });
+ return ret;
},
- getStyle : function(){
- return view && view.getComputedStyle ?
- function(prop){
- var el = this.dom,
- v,
- cs,
- out,
- display,
- wk = Ext.isWebKit,
- display;
+ mean : function(arr){
+ return arr.length > 0 ? Ext.sum(arr) / arr.length : undefined;
+ },
- if(el == document){
- return null;
- }
- prop = chkCache(prop);
-
- if(wk && /marginRight/.test(prop)){
- display = this.getStyle('display');
- el.style.display = 'inline-block';
- }
- out = (v = el.style[prop]) ? v :
- (cs = view.getComputedStyle(el, "")) ? cs[prop] : null;
+
+ sum : function(arr){
+ var ret = 0;
+ Ext.each(arr, function(v) {
+ ret += v;
+ });
+ return ret;
+ },
-
- if(wk){
- if(out == 'rgba(0, 0, 0, 0)'){
- out = 'transparent';
- }else if(display){
- el.style.display = display;
- }
- }
- return out;
- } :
- function(prop){
- var el = this.dom,
- m,
- cs;
+
+ partition : function(arr, truth){
+ var ret = [[],[]];
+ Ext.each(arr, function(v, i, a) {
+ ret[ (truth && truth(v, i, a)) || (!truth && v) ? 0 : 1].push(v);
+ });
+ return ret;
+ },
- if(el == document) return null;
- if (prop == 'opacity') {
- if (el.style.filter.match) {
- if(m = el.style.filter.match(opacityRe)){
- var fv = parseFloat(m[1]);
- if(!isNaN(fv)){
- return fv ? fv / 100 : 0;
- }
- }
- }
- return 1;
- }
- prop = chkCache(prop);
- return el.style[prop] || ((cs = el.currentStyle) ? cs[prop] : null);
- };
- }(),
+
+ invoke : function(arr, methodName){
+ var ret = [],
+ args = Array.prototype.slice.call(arguments, 2);
+ Ext.each(arr, function(v,i) {
+ if (v && typeof v[methodName] == 'function') {
+ ret.push(v[methodName].apply(v, args));
+ } else {
+ ret.push(undefined);
+ }
+ });
+ return ret;
+ },
- getColor : function(attr, defaultValue, prefix){
- var v = this.getStyle(attr),
- color = (typeof prefix != 'undefined') ? prefix : '#',
- h;
+ pluck : function(arr, prop){
+ var ret = [];
+ Ext.each(arr, function(v) {
+ ret.push( v[prop] );
+ });
+ return ret;
+ },
- if(!v || /transparent|inherit/.test(v)){
- return defaultValue;
- }
- if(/^r/.test(v)){
- Ext.each(v.slice(4, v.length -1).split(','), function(s){
- h = parseInt(s, 10);
- color += (h < 16 ? '0' : '') + h.toString(16);
- });
- }else{
- v = v.replace('#', '');
- color += v.length == 3 ? v.replace(/^(\w)(\w)(\w)$/, '$1$1$2$2$3$3') : v;
+
+ zip : function(){
+ var parts = Ext.partition(arguments, function( val ){ return typeof val != 'function'; }),
+ arrs = parts[0],
+ fn = parts[1][0],
+ len = Ext.max(Ext.pluck(arrs, "length")),
+ ret = [];
+
+ for (var i = 0; i < len; i++) {
+ ret[i] = [];
+ if(fn){
+ ret[i] = fn.apply(fn, Ext.pluck(arrs, i));
+ }else{
+ for (var j = 0, aLen = arrs.length; j < aLen; j++){
+ ret[i].push( arrs[j][i] );
+ }
+ }
}
- return(color.length > 5 ? color.toLowerCase() : defaultValue);
+ return ret;
},
- setStyle : function(prop, value){
- var tmp,
- style,
- camel;
- if (typeof prop != 'object') {
- tmp = {};
- tmp[prop] = value;
- prop = tmp;
+ getCmp : function(id){
+ return Ext.ComponentMgr.get(id);
+ },
+
+
+ useShims: E.isIE6 || (E.isMac && E.isGecko2),
+
+
+
+ type : function(o){
+ if(o === undefined || o === null){
+ return false;
}
- for (style in prop) {
- value = prop[style];
- style == 'opacity' ?
- this.setOpacity(value) :
- this.dom.style[chkCache(style)] = value;
+ if(o.htmlElement){
+ return 'element';
}
- return this;
+ var t = typeof o;
+ if(t == 'object' && o.nodeName) {
+ switch(o.nodeType) {
+ case 1: return 'element';
+ case 3: return (/\S/).test(o.nodeValue) ? 'textnode' : 'whitespace';
+ }
+ }
+ if(t == 'object' || t == 'function') {
+ switch(o.constructor) {
+ case Array: return 'array';
+ case RegExp: return 'regexp';
+ case Date: return 'date';
+ }
+ if(typeof o.length == 'number' && typeof o.item == 'function') {
+ return 'nodelist';
+ }
+ }
+ return t;
+ },
+
+ intercept : function(o, name, fn, scope){
+ o[name] = o[name].createInterceptor(fn, scope);
},
- setOpacity : function(opacity, animate){
+ callback : function(cb, scope, args, delay){
+ if(typeof cb == 'function'){
+ if(delay){
+ cb.defer(delay, scope, args || []);
+ }else{
+ cb.apply(scope, args || []);
+ }
+ }
+ }
+ };
+}());
+
+
+Ext.apply(Function.prototype, {
+
+ createSequence : function(fcn, scope){
+ var method = this;
+ return (typeof fcn != 'function') ?
+ this :
+ function(){
+ var retval = method.apply(this || window, arguments);
+ fcn.apply(scope || this || window, arguments);
+ return retval;
+ };
+ }
+});
+
+
+
+Ext.applyIf(String, {
+
+
+ escape : function(string) {
+ return string.replace(/('|\\)/g, "\\$1");
+ },
+
+
+ leftPad : function (val, size, ch) {
+ var result = String(val);
+ if(!ch) {
+ ch = " ";
+ }
+ while (result.length < size) {
+ result = ch + result;
+ }
+ return result;
+ }
+});
+
+
+String.prototype.toggle = function(value, other){
+ return this == value ? other : value;
+};
+
+
+String.prototype.trim = function(){
+ var re = /^\s+|\s+$/g;
+ return function(){ return this.replace(re, ""); };
+}();
+
+
+
+Date.prototype.getElapsed = function(date) {
+ return Math.abs((date || new Date()).getTime()-this.getTime());
+};
+
+
+
+Ext.applyIf(Number.prototype, {
+
+ constrain : function(min, max){
+ return Math.min(Math.max(this, min), max);
+ }
+});
+Ext.lib.Dom.getRegion = function(el) {
+ return Ext.lib.Region.getRegion(el);
+}; Ext.lib.Region = function(t, r, b, l) {
+ var me = this;
+ me.top = t;
+ me[1] = t;
+ me.right = r;
+ me.bottom = b;
+ me.left = l;
+ me[0] = l;
+ };
+
+ Ext.lib.Region.prototype = {
+ contains : function(region) {
+ var me = this;
+ return ( region.left >= me.left &&
+ region.right <= me.right &&
+ region.top >= me.top &&
+ region.bottom <= me.bottom );
+
+ },
+
+ getArea : function() {
+ var me = this;
+ return ( (me.bottom - me.top) * (me.right - me.left) );
+ },
+
+ intersect : function(region) {
var me = this,
- s = me.dom.style;
+ t = Math.max(me.top, region.top),
+ r = Math.min(me.right, region.right),
+ b = Math.min(me.bottom, region.bottom),
+ l = Math.max(me.left, region.left);
- if(!animate || !me.anim){
- if(Ext.isIE){
- var opac = opacity < 1 ? 'alpha(opacity=' + opacity * 100 + ')' : '',
- val = s.filter.replace(opacityRe, '').replace(trimRe, '');
+ if (b >= t && r >= l) {
+ return new Ext.lib.Region(t, r, b, l);
+ }
+ },
+
+ union : function(region) {
+ var me = this,
+ t = Math.min(me.top, region.top),
+ r = Math.max(me.right, region.right),
+ b = Math.max(me.bottom, region.bottom),
+ l = Math.min(me.left, region.left);
+
+ return new Ext.lib.Region(t, r, b, l);
+ },
+
+ constrainTo : function(r) {
+ var me = this;
+ me.top = me.top.constrain(r.top, r.bottom);
+ me.bottom = me.bottom.constrain(r.top, r.bottom);
+ me.left = me.left.constrain(r.left, r.right);
+ me.right = me.right.constrain(r.left, r.right);
+ return me;
+ },
+
+ adjust : function(t, l, b, r) {
+ var me = this;
+ me.top += t;
+ me.left += l;
+ me.right += r;
+ me.bottom += b;
+ return me;
+ }
+ };
+
+ Ext.lib.Region.getRegion = function(el) {
+ var p = Ext.lib.Dom.getXY(el),
+ t = p[1],
+ r = p[0] + el.offsetWidth,
+ b = p[1] + el.offsetHeight,
+ l = p[0];
+
+ return new Ext.lib.Region(t, r, b, l);
+ }; Ext.lib.Point = function(x, y) {
+ if (Ext.isArray(x)) {
+ y = x[1];
+ x = x[0];
+ }
+ var me = this;
+ me.x = me.right = me.left = me[0] = x;
+ me.y = me.top = me.bottom = me[1] = y;
+ };
+
+ Ext.lib.Point.prototype = new Ext.lib.Region();
+
+Ext.apply(Ext.DomHelper,
+function(){
+ var pub,
+ afterbegin = 'afterbegin',
+ afterend = 'afterend',
+ beforebegin = 'beforebegin',
+ beforeend = 'beforeend',
+ confRe = /tag|children|cn|html$/i;
+
+
+ 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));
+ }
+ return returnElement ? Ext.get(newNode, true) : newNode;
+ }
- s.zoom = 1;
- s.filter = val + (val.length > 0 ? ' ' : '') + opac;
- }else{
- s.opacity = opacity;
+
+
+ function createDom(o, parentNode){
+ var el,
+ doc = document,
+ useSet,
+ attr,
+ val,
+ cn;
+
+ if (Ext.isArray(o)) {
+ el = doc.createDocumentFragment();
+ for (var i = 0, l = o.length; i < l; i++) {
+ createDom(o[i], el);
+ }
+ } else if (typeof o == 'string') {
+ el = doc.createTextNode(o);
+ } else {
+ el = doc.createElement( o.tag || 'div' );
+ useSet = !!el.setAttribute;
+ for (var attr in o) {
+ if(!confRe.test(attr)){
+ val = o[attr];
+ if(attr == 'cls'){
+ el.className = val;
+ }else{
+ if(useSet){
+ el.setAttribute(attr, val);
+ }else{
+ el[attr] = val;
+ }
+ }
}
- }else{
- me.anim({opacity: {to: opacity}}, me.preanim(arguments, 1), null, .35, 'easeIn');
}
- return me;
- },
+ Ext.DomHelper.applyStyles(el, o.style);
-
- clearOpacity : function(){
- var style = this.dom.style;
- if(Ext.isIE){
- if(!Ext.isEmpty(style.filter)){
- style.filter = style.filter.replace(opacityRe, '').replace(trimRe, '');
- }
- }else{
- style.opacity = style['-moz-opacity'] = style['-khtml-opacity'] = '';
+ if ((cn = o.children || o.cn)) {
+ createDom(cn, el);
+ } else if (o.html) {
+ el.innerHTML = o.html;
}
- return this;
- },
+ }
+ if(parentNode){
+ parentNode.appendChild(el);
+ }
+ return el;
+ }
+ pub = {
- getHeight : function(contentHeight){
- var me = this,
- dom = me.dom,
- hidden = Ext.isIE && me.isStyle('display', 'none'),
- h = MATH.max(dom.offsetHeight, hidden ? 0 : dom.clientHeight) || 0;
-
- h = !contentHeight ? h : h - me.getBorderWidth("tb") - me.getPadding("tb");
- return h < 0 ? 0 : h;
+ createTemplate : function(o){
+ var html = Ext.DomHelper.createHtml(o);
+ return new Ext.Template(html);
},
- getWidth : function(contentWidth){
- var me = this,
- dom = me.dom,
- hidden = Ext.isIE && me.isStyle('display', 'none'),
- w = MATH.max(dom.offsetWidth, hidden ? 0 : dom.clientWidth) || 0;
- w = !contentWidth ? w : w - me.getBorderWidth("lr") - me.getPadding("lr");
- return w < 0 ? 0 : w;
- },
+ useDom : false,
- setWidth : function(width, animate){
- var me = this;
- width = me.adjustWidth(width);
- !animate || !me.anim ?
- me.dom.style.width = me.addUnits(width) :
- me.anim({width : {to : width}}, me.preanim(arguments, 1));
- return me;
+ insertBefore : function(el, o, returnElement){
+ return doInsert(el, o, returnElement, beforebegin);
},
- setHeight : function(height, animate){
- var me = this;
- height = me.adjustHeight(height);
- !animate || !me.anim ?
- me.dom.style.height = me.addUnits(height) :
- me.anim({height : {to : height}}, me.preanim(arguments, 1));
- return me;
+ insertAfter : function(el, o, returnElement){
+ return doInsert(el, o, returnElement, afterend, 'nextSibling');
},
- getBorderWidth : function(side){
- return this.addStyles(side, borders);
+ insertFirst : function(el, o, returnElement){
+ return doInsert(el, o, returnElement, afterbegin, 'firstChild');
},
- getPadding : function(side){
- return this.addStyles(side, paddings);
+ append: function(el, o, returnElement){
+ return doInsert(el, o, returnElement, beforeend, '', true);
},
- clip : function(){
- var me = this,
- dom = me.dom;
+ createDom: createDom
+ };
+ return pub;
+}());
- if(!data(dom, ISCLIPPED)){
- data(dom, ISCLIPPED, true);
- data(dom, ORIGINALCLIP, {
- o: me.getStyle(OVERFLOW),
- x: me.getStyle(OVERFLOWX),
- y: me.getStyle(OVERFLOWY)
- });
- me.setStyle(OVERFLOW, HIDDEN);
- me.setStyle(OVERFLOWX, HIDDEN);
- me.setStyle(OVERFLOWY, HIDDEN);
- }
- return me;
- },
+Ext.apply(Ext.Template.prototype, {
+
+ disableFormats : false,
+
-
- unclip : function(){
- var me = this,
- dom = me.dom;
+
+ re : /\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,
+ argsRe : /^\s*['"](.*)["']\s*$/,
+ compileARe : /\\/g,
+ compileBRe : /(\r\n|\n)/g,
+ compileCRe : /'/g,
- if(data(dom, ISCLIPPED)){
- data(dom, ISCLIPPED, false);
- var o = data(dom, ORIGINALCLIP);
- if(o.o){
- me.setStyle(OVERFLOW, o.o);
- }
- if(o.x){
- me.setStyle(OVERFLOWX, o.x);
- }
- if(o.y){
- me.setStyle(OVERFLOWY, o.y);
+ /**
+ * Returns an HTML fragment of this template with the specified values applied.
+ * @param {Object/Array} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
+ * @return {String} The HTML fragment
+ * @hide repeat doc
+ */
+ applyTemplate : function(values){
+ var me = this,
+ useF = me.disableFormats !== true,
+ fm = Ext.util.Format,
+ tpl = me;
+
+ if(me.compiled){
+ return me.compiled(values);
+ }
+ 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) {
+ // quoted values are required for strings in compiled templates,
+ // but for non compiled we need to strip them
+ // quoted reversed for jsmin
+ var re = me.argsRe;
+ 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] : "";
}
- return me;
- },
+ }
+ return me.html.replace(me.re, fn);
+ },
-
- addStyles : function(sides, styles){
- var ttlSize = 0,
- sidesArr = sides.match(wordsRe),
- side,
- size,
- i,
- len = sidesArr.length;
- for (i = 0; i < len; i++) {
- side = sidesArr[i];
- size = side && parseInt(this.getStyle(styles[side]), 10);
- if (size) {
- ttlSize += MATH.abs(size);
+ /**
+ * Compiles the template into an internal function, eliminating the RegEx overhead.
+ * @return {Ext.Template} this
+ * @hide repeat doc
+ */
+ 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 ttlSize;
- },
+ return "'"+ sep + format + "values['" + name + "']" + args + ")"+sep+"'";
+ }
- margins : margins
+ // branched to use + in gecko and [].join() in others
+ if(Ext.isGecko){
+ body = "this.compiled = function(values){ return '" +
+ me.html.replace(me.compileARe, '\\\\').replace(me.compileBRe, '\\n').replace(me.compileCRe, "\\'").replace(me.re, fn) +
+ "';};";
+ }else{
+ body = ["this.compiled = function(values){ return ['"];
+ body.push(me.html.replace(me.compileARe, '\\\\').replace(me.compileBRe, '\\n').replace(me.compileCRe, "\\'").replace(me.re, fn));
+ body.push("'].join('');};");
+ body = body.join('');
+ }
+ eval(body);
+ return me;
+ },
+
+ // private function used to call members
+ call : function(fnName, value, allValues){
+ return this[fnName](value, allValues);
}
-}()
-);
+});
+Ext.Template.prototype.apply = Ext.Template.prototype.applyTemplate;
+/**
+ * @class Ext.util.Functions
+ * @singleton
+ */
+Ext.util.Functions = {
+ /**
+ * Creates an interceptor function. The passed function is called before the original one. If it returns false,
+ * the original one is not called. The resulting function returns the results of the original function.
+ * The passed function is called with the parameters of the original function. Example usage:
+ * <pre><code>
+var sayHi = function(name){
+ alert('Hi, ' + name);
+}
+sayHi('Fred'); // alerts "Hi, Fred"
+// create a new function that validates input without
+// directly modifying the original function:
+var sayHiToFriend = Ext.createInterceptor(sayHi, function(name){
+ return name == 'Brian';
+});
-Ext.Element.boxMarkup = '<div class="{0}-tl"><div class="{0}-tr"><div class="{0}-tc"></div></div></div><div class="{0}-ml"><div class="{0}-mr"><div class="{0}-mc"></div></div></div><div class="{0}-bl"><div class="{0}-br"><div class="{0}-bc"></div></div></div>';
+sayHiToFriend('Fred'); // no alert
+sayHiToFriend('Brian'); // alerts "Hi, Brian"
+ </code></pre>
+ * @param {Function} origFn The original function.
+ * @param {Function} newFn The function to call before the original
+ * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the passed function is executed.
+ * <b>If omitted, defaults to the scope in which the original function is called or the browser window.</b>
+ * @return {Function} The new function
+ */
+ createInterceptor: function(origFn, newFn, scope) {
+ 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) :
+ null;
+ };
+ }
+ },
-Ext.Element.addMethods(function(){
- var INTERNAL = "_internal",
- pxMatch = /(\d+\.?\d+)px/;
- return {
-
- applyStyles : function(style){
- Ext.DomHelper.applyStyles(this.dom, style);
- return this;
- },
+ /**
+ * Creates a delegate (callback) that sets the scope to obj.
+ * Call directly on any function. Example: <code>Ext.createDelegate(this.myFunction, this, [arg1, arg2])</code>
+ * Will create a function that is automatically scoped to obj so that the <tt>this</tt> variable inside the
+ * callback points to obj. Example usage:
+ * <pre><code>
+var sayHi = function(name){
+ // Note this use of "this.text" here. This function expects to
+ // execute within a scope that contains a text property. In this
+ // example, the "this" variable is pointing to the btn object that
+ // was passed in createDelegate below.
+ alert('Hi, ' + name + '. You clicked the "' + this.text + '" button.');
+}
-
- getStyles : function(){
- var ret = {};
- Ext.each(arguments, function(v) {
- ret[v] = this.getStyle(v);
- },
- this);
- return ret;
- },
+var btn = new Ext.Button({
+ text: 'Say Hi',
+ renderTo: Ext.getBody()
+});
-
- setOverflow : function(v){
- var dom = this.dom;
- if(v=='auto' && Ext.isMac && Ext.isGecko2){
- dom.style.overflow = 'hidden';
- (function(){dom.style.overflow = 'auto';}).defer(1);
- }else{
- dom.style.overflow = v;
- }
- },
+// This callback will execute in the scope of the
+// button instance. Clicking the button alerts
+// "Hi, Fred. You clicked the "Say Hi" button."
+btn.on('click', Ext.createDelegate(sayHi, btn, ['Fred']));
+ </code></pre>
+ * @param {Function} fn The function to delegate.
+ * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
+ * <b>If omitted, defaults to the browser window.</b>
+ * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
+ * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
+ * if a number the args are inserted at the specified position
+ * @return {Function} The new function
+ */
+ createDelegate: function(fn, obj, args, appendArgs) {
+ if (!Ext.isFunction(fn)) {
+ return fn;
+ }
+ return function() {
+ var callArgs = args || arguments;
+ if (appendArgs === true) {
+ callArgs = Array.prototype.slice.call(arguments, 0);
+ callArgs = callArgs.concat(args);
+ }
+ else if (Ext.isNumber(appendArgs)) {
+ callArgs = Array.prototype.slice.call(arguments, 0);
+ // copy arguments first
+ var applyArgs = [appendArgs, 0].concat(args);
+ // create method call params
+ Array.prototype.splice.apply(callArgs, applyArgs);
+ // splice them in
+ }
+ return fn.apply(obj || window, callArgs);
+ };
+ },
-
- boxWrap : function(cls){
- cls = cls || 'x-box';
- var el = Ext.get(this.insertHtml("beforeBegin", "<div class='" + cls + "'>" + String.format(Ext.Element.boxMarkup, cls) + "</div>"));
- Ext.DomQuery.selectNode('.' + cls + '-mc', el.dom).appendChild(this.dom);
- return el;
- },
+ /**
+ * Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
+ * <pre><code>
+var sayHi = function(name){
+ alert('Hi, ' + name);
+}
-
- setSize : function(width, height, animate){
- var me = this;
- if(typeof width == 'object'){
- height = width.height;
- width = width.width;
- }
- width = me.adjustWidth(width);
- height = me.adjustHeight(height);
- if(!animate || !me.anim){
- me.dom.style.width = me.addUnits(width);
- me.dom.style.height = me.addUnits(height);
- }else{
- me.anim({width: {to: width}, height: {to: height}}, me.preanim(arguments, 2));
- }
- return me;
- },
+// executes immediately:
+sayHi('Fred');
+
+// executes after 2 seconds:
+Ext.defer(sayHi, 2000, this, ['Fred']);
+
+// this syntax is sometimes useful for deferring
+// execution of an anonymous function:
+Ext.defer(function(){
+ alert('Anonymous');
+}, 100);
+ </code></pre>
+ * @param {Function} fn The function to defer.
+ * @param {Number} millis The number of milliseconds for the setTimeout call (if less than or equal to 0 the function is executed immediately)
+ * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
+ * <b>If omitted, defaults to the browser window.</b>
+ * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
+ * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
+ * if a number the args are inserted at the specified position
+ * @return {Number} The timeout id that can be used with clearTimeout
+ */
+ defer: function(fn, millis, obj, args, appendArgs) {
+ fn = Ext.util.Functions.createDelegate(fn, obj, args, appendArgs);
+ if (millis > 0) {
+ return setTimeout(fn, millis);
+ }
+ fn();
+ return 0;
+ },
-
- getComputedHeight : function(){
- var me = this,
- h = Math.max(me.dom.offsetHeight, me.dom.clientHeight);
- if(!h){
- h = parseFloat(me.getStyle('height')) || 0;
- if(!me.isBorderBox()){
- h += me.getFrameWidth('tb');
- }
- }
- return h;
- },
-
- getComputedWidth : function(){
- var w = Math.max(this.dom.offsetWidth, this.dom.clientWidth);
- if(!w){
- w = parseFloat(this.getStyle('width')) || 0;
- if(!this.isBorderBox()){
- w += this.getFrameWidth('lr');
- }
- }
- return w;
- },
+ /**
+ * Create a combined function call sequence of the original function + the passed function.
+ * The resulting function returns the results of the original function.
+ * The passed fcn is called with the parameters of the original function. Example usage:
+ *
-
- getFrameWidth : function(sides, onlyContentBox){
- return onlyContentBox && this.isBorderBox() ? 0 : (this.getPadding(sides) + this.getBorderWidth(sides));
- },
+var sayHi = function(name){
+ alert('Hi, ' + name);
+}
-
- addClassOnOver : function(className){
- this.hover(
- function(){
- Ext.fly(this, INTERNAL).addClass(className);
- },
- function(){
- Ext.fly(this, INTERNAL).removeClass(className);
- }
- );
- return this;
- },
+sayHi('Fred'); // alerts "Hi, Fred"
-
- addClassOnFocus : function(className){
- this.on("focus", function(){
- Ext.fly(this, INTERNAL).addClass(className);
- }, this.dom);
- this.on("blur", function(){
- Ext.fly(this, INTERNAL).removeClass(className);
- }, this.dom);
- return this;
- },
+var sayGoodbye = Ext.createSequence(sayHi, function(name){
+ alert('Bye, ' + name);
+});
-
- addClassOnClick : function(className){
- var dom = this.dom;
- this.on("mousedown", function(){
- Ext.fly(dom, INTERNAL).addClass(className);
- var d = Ext.getDoc(),
- fn = function(){
- Ext.fly(dom, INTERNAL).removeClass(className);
- d.removeListener("mouseup", fn);
- };
- d.on("mouseup", fn);
- });
- return this;
- },
+sayGoodbye('Fred'); // both alerts show
-
+ * @param {Function} origFn The original function.
+ * @param {Function} newFn The function to sequence
+ * @param {Object} scope (optional) The scope (this reference) in which the passed function is executed.
+ * If omitted, defaults to the scope in which the original function is called or the browser window.
+ * @return {Function} The new function
+ */
+ 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;
+ };
+ }
+ }
+};
- getViewSize : function(){
- var doc = document,
- d = this.dom,
- isDoc = (d == doc || d == doc.body);
+/**
+ * Shorthand for {@link Ext.util.Functions#defer}
+ * @param {Function} fn The function to defer.
+ * @param {Number} millis The number of milliseconds for the setTimeout call (if less than or equal to 0 the function is executed immediately)
+ * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
+ * <b>If omitted, defaults to the browser window.</b>
+ * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
+ * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
+ * if a number the args are inserted at the specified position
+ * @return {Number} The timeout id that can be used with clearTimeout
+ * @member Ext
+ * @method defer
+ */
-
- if (isDoc) {
- var extdom = Ext.lib.Dom;
- return {
- width : extdom.getViewWidth(),
- height : extdom.getViewHeight()
- };
+Ext.defer = Ext.util.Functions.defer;
-
- } else {
- return {
- width : d.clientWidth,
- height : d.clientHeight
+/**
+ * Shorthand for {@link Ext.util.Functions#createInterceptor}
+ * @param {Function} origFn The original function.
+ * @param {Function} newFn The function to call before the original
+ * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the passed function is executed.
+ * <b>If omitted, defaults to the scope in which the original function is called or the browser window.</b>
+ * @return {Function} The new function
+ * @member Ext
+ * @method defer
+ */
+
+Ext.createInterceptor = Ext.util.Functions.createInterceptor;
+
+/**
+ * Shorthand for {@link Ext.util.Functions#createSequence}
+ * @param {Function} origFn The original function.
+ * @param {Function} newFn The function to sequence
+ * @param {Object} scope (optional) The scope (this reference) in which the passed function is executed.
+ * If omitted, defaults to the scope in which the original function is called or the browser window.
+ * @return {Function} The new function
+ * @member Ext
+ * @method defer
+ */
+
+Ext.createSequence = Ext.util.Functions.createSequence;
+
+/**
+ * Shorthand for {@link Ext.util.Functions#createDelegate}
+ * @param {Function} fn The function to delegate.
+ * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
+ * <b>If omitted, defaults to the browser window.</b>
+ * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
+ * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
+ * if a number the args are inserted at the specified position
+ * @return {Function} The new function
+ * @member Ext
+ * @method defer
+ */
+Ext.createDelegate = Ext.util.Functions.createDelegate;
+/**
+ * @class Ext.util.Observable
+ */
+Ext.apply(Ext.util.Observable.prototype, function(){
+ // this is considered experimental (along with beforeMethod, afterMethod, removeMethodListener?)
+ // allows for easier interceptor and sequences, including cancelling and overwriting the return value of the call
+ // private
+ function getMethodEvent(method){
+ var e = (this.methodEvents = this.methodEvents ||
+ {})[method], returnValue, v, cancel, obj = this;
+
+ if (!e) {
+ this.methodEvents[method] = e = {};
+ e.originalFn = this[method];
+ e.methodName = method;
+ e.before = [];
+ e.after = [];
+
+ var makeCall = function(fn, scope, args){
+ if((v = fn.apply(scope || obj, args)) !== undefined){
+ if (typeof v == 'object') {
+ if(v.returnValue !== undefined){
+ returnValue = v.returnValue;
+ }else{
+ returnValue = v;
+ }
+ cancel = !!v.cancel;
+ }
+ else
+ if (v === false) {
+ cancel = true;
+ }
+ else {
+ returnValue = v;
+ }
}
- }
- },
+ };
-
+ this[method] = function(){
+ var args = Array.prototype.slice.call(arguments, 0),
+ b;
+ returnValue = v = undefined;
+ cancel = false;
+
+ for(var i = 0, len = e.before.length; i < len; i++){
+ b = e.before[i];
+ makeCall(b.fn, b.scope, args);
+ if (cancel) {
+ return returnValue;
+ }
+ }
+
+ if((v = e.originalFn.apply(obj, args)) !== undefined){
+ returnValue = v;
+ }
+
+ for(var i = 0, len = e.after.length; i < len; i++){
+ b = e.after[i];
+ makeCall(b.fn, b.scope, args);
+ if (cancel) {
+ return returnValue;
+ }
+ }
+ return returnValue;
+ };
+ }
+ return e;
+ }
+
+ return {
+ // these are considered experimental
+ // allows for easier interceptor and sequences, including cancelling and overwriting the return value of the call
+ // adds an 'interceptor' called before the original method
+ beforeMethod : function(method, fn, scope){
+ getMethodEvent.call(this, method).before.push({
+ fn: fn,
+ scope: scope
+ });
+ },
- getStyleSize : function(){
- var me = this,
- w, h,
- doc = document,
- d = this.dom,
- isDoc = (d == doc || d == doc.body),
- s = d.style;
+ // adds a 'sequence' called after the original method
+ afterMethod : function(method, fn, scope){
+ getMethodEvent.call(this, method).after.push({
+ fn: fn,
+ scope: scope
+ });
+ },
-
- if (isDoc) {
- var extdom = Ext.lib.Dom;
- return {
- width : extdom.getViewWidth(),
- height : extdom.getViewHeight()
- }
- }
-
- if(s.width && s.width != 'auto'){
- w = parseFloat(s.width);
- if(me.isBorderBox()){
- w -= me.getFrameWidth('lr');
+ removeMethodListener: function(method, fn, scope){
+ var e = this.getMethodEvent(method);
+ for(var i = 0, len = e.before.length; i < len; i++){
+ if(e.before[i].fn == fn && e.before[i].scope == scope){
+ e.before.splice(i, 1);
+ return;
}
}
-
- if(s.height && s.height != 'auto'){
- h = parseFloat(s.height);
- if(me.isBorderBox()){
- h -= me.getFrameWidth('tb');
+ for(var i = 0, len = e.after.length; i < len; i++){
+ if(e.after[i].fn == fn && e.after[i].scope == scope){
+ e.after.splice(i, 1);
+ return;
}
}
-
- return {width: w || me.getWidth(true), height: h || me.getHeight(true)};
- },
-
-
- getSize : function(contentSize){
- return {width: this.getWidth(contentSize), height: this.getHeight(contentSize)};
},
-
- repaint : function(){
- var dom = this.dom;
- this.addClass("x-repaint");
- setTimeout(function(){
- Ext.fly(dom).removeClass("x-repaint");
- }, 1);
- return this;
+ /**
+ * Relays selected events from the specified Observable as if the events were fired by <tt><b>this</b></tt>.
+ * @param {Object} o The Observable whose events this object is to relay.
+ * @param {Array} events Array of event names to relay.
+ */
+ relayEvents : function(o, events){
+ var me = this;
+ function createHandler(ename){
+ return function(){
+ return me.fireEvent.apply(me, [ename].concat(Array.prototype.slice.call(arguments, 0)));
+ };
+ }
+ for(var i = 0, len = events.length; i < len; i++){
+ var ename = events[i];
+ me.events[ename] = me.events[ename] || true;
+ o.on(ename, createHandler(ename), me);
+ }
},
-
- unselectable : function(){
- this.dom.unselectable = "on";
- return this.swallowEvent("selectstart", true).
- applyStyles("-moz-user-select:none;-khtml-user-select:none;").
- addClass("x-unselectable");
- },
+ /**
+ * <p>Enables events fired by this Observable to bubble up an owner hierarchy by calling
+ * <code>this.getBubbleTarget()</code> if present. There is no implementation in the Observable base class.</p>
+ * <p>This is commonly used by Ext.Components to bubble events to owner Containers. See {@link Ext.Component.getBubbleTarget}. The default
+ * implementation in Ext.Component returns the Component's immediate owner. But if a known target is required, this can be overridden to
+ * access the required target more quickly.</p>
+ * <p>Example:</p><pre><code>
+Ext.override(Ext.form.Field, {
+
+ initComponent : Ext.form.Field.prototype.initComponent.createSequence(function() {
+ this.enableBubble('change');
+ }),
-
- getMargins : function(side){
- var me = this,
- key,
- hash = {t:"top", l:"left", r:"right", b: "bottom"},
- o = {};
+
+ getBubbleTarget : function() {
+ if (!this.formPanel) {
+ this.formPanel = this.findParentByType('form');
+ }
+ return this.formPanel;
+ }
+});
- if (!side) {
- for (key in me.margins){
- o[hash[key]] = parseFloat(me.getStyle(me.margins[key])) || 0;
+var myForm = new Ext.formPanel({
+ title: 'User Details',
+ items: [{
+ ...
+ }],
+ listeners: {
+ change: function() {
+
+ myForm.header.setStyle('color', 'red');
+ }
+ }
+});
+</code></pre>
+ * @param {String/Array} events The event name to bubble, or an Array of event names.
+ */
+ enableBubble : function(events){
+ var me = this;
+ if(!Ext.isEmpty(events)){
+ events = Ext.isArray(events) ? events : Array.prototype.slice.call(arguments, 0);
+ for(var i = 0, len = events.length; i < len; i++){
+ var ename = events[i];
+ ename = ename.toLowerCase();
+ var ce = me.events[ename] || true;
+ if (typeof ce == 'boolean') {
+ ce = new Ext.util.Event(me, ename);
+ me.events[ename] = ce;
+ }
+ ce.bubble = true;
}
- return o;
- } else {
- return me.addStyles.call(me, side, me.margins);
}
}
};
}());
-(function(){
-var D = Ext.lib.Dom,
- LEFT = "left",
- RIGHT = "right",
- TOP = "top",
- BOTTOM = "bottom",
- POSITION = "position",
- STATIC = "static",
- RELATIVE = "relative",
- AUTO = "auto",
- ZINDEX = "z-index";
-Ext.Element.addMethods({
-
- getX : function(){
- return D.getX(this.dom);
- },
-
- getY : function(){
- return D.getY(this.dom);
- },
+Ext.util.Observable.capture = function(o, fn, scope){
+ o.fireEvent = o.fireEvent.createInterceptor(fn, scope);
+};
-
- getXY : function(){
- return D.getXY(this.dom);
- },
-
- getOffsetsTo : function(el){
- var o = this.getXY(),
- e = Ext.fly(el, '_internal').getXY();
- return [o[0]-e[0],o[1]-e[1]];
- },
-
- setX : function(x, animate){
- return this.setXY([x, this.getY()], this.animTest(arguments, animate, 1));
- },
+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(typeof listeners == 'object'){
+ c.on(listeners);
+ }
+ return c;
+ }
+};
-
- setY : function(y, animate){
- return this.setXY([this.getX(), y], this.animTest(arguments, animate, 1));
- },
+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);
-
- setLeft : function(left){
- this.setStyle(LEFT, this.addUnits(left));
- return this;
- },
+ return {
+
+ doResizeEvent: function(){
+ var h = D.getViewHeight(),
+ w = D.getViewWidth();
-
- setTop : function(top){
- this.setStyle(TOP, this.addUnits(top));
- return this;
- },
+
+ if(curHeight != h || curWidth != w){
+ resizeEvent.fire(curWidth = w, curHeight = h);
+ }
+ },
-
- setRight : function(right){
- this.setStyle(RIGHT, this.addUnits(right));
- return this;
- },
+
+ 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);
+ },
-
- setBottom : function(bottom){
- this.setStyle(BOTTOM, this.addUnits(bottom));
- return this;
- },
+
+ fireWindowResize : function(){
+ if(resizeEvent){
+ resizeTask.delay(100);
+ }
+ },
+
+
+ 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);
+ },
+
+
+ removeResizeListener : function(fn, scope){
+ if(resizeEvent){
+ resizeEvent.removeListener(fn, scope);
+ }
+ },
+
+
+ fireResize : function(){
+ if(resizeEvent){
+ resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
+ }
+ },
+
+
+ textResizeInterval : 50,
+
+
+ ieDeferSrc : false,
+
+
+ getKeyEvent : function(){
+ return useKeydown ? 'keydown' : 'keypress';
+ },
+
+
+
+ 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 <= 46);
+ },
+
+ getPoint : function(){
+ return new Ext.lib.Point(this.xy[0], this.xy[1]);
+ },
+
+ hasModifier : function(){
+ return ((this.ctrlKey || this.altKey) || this.shiftKey);
+ }
+});
+Ext.Element.addMethods({
- setXY : function(pos, animate){
- var me = this;
- if(!animate || !me.anim){
- D.setXY(me.dom, pos);
- }else{
- me.anim({points: {to: pos}}, me.preanim(arguments, 1), 'motion');
+ 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;
},
- setLocation : function(x, y, animate){
- return this.setXY([x, y], this.animTest(arguments, animate, 2));
- },
-
-
- moveTo : function(x, y, animate){
- return this.setXY([x, y], this.animTest(arguments, animate, 2));
- },
-
-
- getLeft : function(local){
- return !local ? this.getX() : parseInt(this.getStyle(LEFT), 10) || 0;
+ relayEvent : function(eventName, observable) {
+ this.on(eventName, function(e) {
+ observable.fireEvent(eventName, e);
+ });
},
- getRight : function(local){
- var me = this;
- return !local ? me.getX() + me.getWidth() : (me.getLeft(true) + me.getWidth()) || 0;
+ clean : function(forceReclean) {
+ var me = this,
+ dom = me.dom,
+ n = dom.firstChild,
+ ni = -1;
+
+ if (Ext.Element.data(dom, 'isCleaned') && forceReclean !== true) {
+ return me;
+ }
+
+ while (n) {
+ var nx = n.nextSibling;
+ if (n.nodeType == 3 && !(/\S/.test(n.nodeValue))) {
+ dom.removeChild(n);
+ } else {
+ n.nodeIndex = ++ni;
+ }
+ n = nx;
+ }
+
+ Ext.Element.data(dom, 'isCleaned', true);
+ return me;
},
- getTop : function(local) {
- return !local ? this.getY() : parseInt(this.getStyle(TOP), 10) || 0;
+ load : function() {
+ var updateManager = this.getUpdater();
+ updateManager.update.apply(updateManager, arguments);
+
+ return this;
},
- getBottom : function(local){
- var me = this;
- return !local ? me.getY() + me.getHeight() : (me.getTop(true) + me.getHeight()) || 0;
+ getUpdater : function() {
+ return this.updateManager || (this.updateManager = new Ext.Updater(this));
},
- position : function(pos, zIndex, x, y){
- var me = this;
-
- if(!pos && me.isStyle(POSITION, STATIC)){
- me.setStyle(POSITION, RELATIVE);
- } else if(pos) {
- me.setStyle(POSITION, pos);
+ update : function(html, loadScripts, callback) {
+ if (!this.dom) {
+ return this;
}
- if(zIndex){
- me.setStyle(ZINDEX, zIndex);
+ html = html || "";
+
+ if (loadScripts !== true) {
+ this.dom.innerHTML = html;
+ if (typeof callback == 'function') {
+ callback();
+ }
+ return this;
}
- if(x || y) me.setXY([x || false, y || false]);
- },
-
- clearPositioning : function(value){
- value = value || '';
- this.setStyle({
- left : value,
- right : value,
- top : value,
- bottom : value,
- "z-index" : "",
- position : STATIC
+ var id = Ext.id(),
+ dom = this.dom;
+
+ html += '<span id="' + id + '"></span>';
+
+ Ext.lib.Event.onAvailable(id, function() {
+ var DOC = document,
+ hd = DOC.getElementsByTagName("head")[0],
+ re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig,
+ srcRe = /\ssrc=([\'\"])(.*?)\1/i,
+ typeRe = /\stype=([\'\"])(.*?)\1/i,
+ match,
+ attrs,
+ srcMatch,
+ typeMatch,
+ el,
+ s;
+
+ while ((match = re.exec(html))) {
+ attrs = match[1];
+ srcMatch = attrs ? attrs.match(srcRe) : false;
+ if (srcMatch && srcMatch[2]) {
+ s = DOC.createElement("script");
+ s.src = srcMatch[2];
+ typeMatch = attrs.match(typeRe);
+ if (typeMatch && typeMatch[2]) {
+ s.type = typeMatch[2];
+ }
+ hd.appendChild(s);
+ } else if (match[2] && match[2].length > 0) {
+ if (window.execScript) {
+ window.execScript(match[2]);
+ } else {
+ window.eval(match[2]);
+ }
+ }
+ }
+
+ el = DOC.getElementById(id);
+ if (el) {
+ Ext.removeNode(el);
+ }
+
+ if (typeof callback == 'function') {
+ callback();
+ }
});
+ dom.innerHTML = html.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig, "");
return this;
},
- getPositioning : function(){
- var l = this.getStyle(LEFT);
- var t = this.getStyle(TOP);
- return {
- "position" : this.getStyle(POSITION),
- "left" : l,
- "right" : l ? "" : this.getStyle(RIGHT),
- "top" : t,
- "bottom" : t ? "" : this.getStyle(BOTTOM),
- "z-index" : this.getStyle(ZINDEX)
- };
+ removeAllListeners : function() {
+ this.removeAnchor();
+ Ext.EventManager.removeAll(this.dom);
+ return this;
},
+
-
- setPositioning : function(pc){
- var me = this,
- style = me.dom.style;
-
- me.setStyle(pc);
-
- if(pc.right == AUTO){
- style.right = "";
- }
- if(pc.bottom == AUTO){
- style.bottom = "";
- }
-
- return me;
- },
-
-
- translatePoints : function(x, y){
- y = isNaN(x[1]) ? y : x[1];
- x = isNaN(x[0]) ? x : x[0];
+ createProxy : function(config, renderTo, matchBox) {
+ config = (typeof config == 'object') ? config : {tag : "div", cls: config};
+
var me = this,
- relative = me.isStyle(POSITION, RELATIVE),
- o = me.getXY(),
- l = parseInt(me.getStyle(LEFT), 10),
- t = parseInt(me.getStyle(TOP), 10);
-
- l = !isNaN(l) ? l : (relative ? 0 : me.dom.offsetLeft);
- t = !isNaN(t) ? t : (relative ? 0 : me.dom.offsetTop);
+ proxy = renderTo ? Ext.DomHelper.append(renderTo, config, true) :
+ Ext.DomHelper.insertBefore(me.dom, config, true);
- return {left: (x - o[0] + l), top: (y - o[1] + t)};
- },
-
- animTest : function(args, animate, i) {
- return !!animate && this.preanim ? this.preanim(args, i) : false;
+ if (matchBox && me.setBox && me.getBox) {
+ proxy.setBox(me.getBox());
+ }
+ return proxy;
}
});
-})();
+
+Ext.Element.prototype.getUpdateManager = Ext.Element.prototype.getUpdater;
+
Ext.Element.addMethods({
- setBox : function(box, adjust, animate){
- var me = this,
- w = box.width,
- h = box.height;
- if((adjust && !me.autoBoxAdjust) && !me.isBorderBox()){
- w -= (me.getBorderWidth("lr") + me.getPadding("lr"));
- h -= (me.getBorderWidth("tb") + me.getPadding("tb"));
- }
- me.setBounds(box.x, box.y, w, h, me.animTest.call(me, arguments, animate, 2));
- return me;
+ getAnchorXY : function(anchor, local, s){
+
+
+ anchor = (anchor || "tl").toLowerCase();
+ s = s || {};
+
+ var me = this,
+ vp = me.dom == document.body || me.dom == document,
+ w = s.width || vp ? Ext.lib.Dom.getViewWidth() : me.getWidth(),
+ h = s.height || vp ? Ext.lib.Dom.getViewHeight() : me.getHeight(),
+ xy,
+ r = Math.round,
+ o = me.getXY(),
+ scroll = me.getScroll(),
+ extraX = vp ? scroll.left : !local ? o[0] : 0,
+ extraY = vp ? scroll.top : !local ? o[1] : 0,
+ hash = {
+ c : [r(w * 0.5), r(h * 0.5)],
+ t : [r(w * 0.5), 0],
+ l : [0, r(h * 0.5)],
+ r : [w, r(h * 0.5)],
+ b : [r(w * 0.5), h],
+ tl : [0, 0],
+ bl : [0, h],
+ br : [w, h],
+ tr : [w, 0]
+ };
+
+ xy = hash[anchor];
+ return [xy[0] + extraX, xy[1] + extraY];
},
- getBox : function(contentBox, local) {
+ anchorTo : function(el, alignment, offsets, animate, monitorScroll, callback){
var me = this,
- xy,
- left,
- top,
- getBorderWidth = me.getBorderWidth,
- getPadding = me.getPadding,
- l,
- r,
- t,
- b;
- if(!local){
- xy = me.getXY();
- }else{
- left = parseInt(me.getStyle("left"), 10) || 0;
- top = parseInt(me.getStyle("top"), 10) || 0;
- xy = [left, top];
- }
- var el = me.dom, w = el.offsetWidth, h = el.offsetHeight, bx;
- if(!contentBox){
- bx = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: w, height: h};
- }else{
- l = getBorderWidth.call(me, "l") + getPadding.call(me, "l");
- r = getBorderWidth.call(me, "r") + getPadding.call(me, "r");
- t = getBorderWidth.call(me, "t") + getPadding.call(me, "t");
- b = getBorderWidth.call(me, "b") + getPadding.call(me, "b");
- bx = {x: xy[0]+l, y: xy[1]+t, 0: xy[0]+l, 1: xy[1]+t, width: w-(l+r), height: h-(t+b)};
- }
- bx.right = bx.x + bx.width;
- bx.bottom = bx.y + bx.height;
- return bx;
- },
-
-
- move : function(direction, distance, animate){
- var me = this,
- xy = me.getXY(),
- x = xy[0],
- y = xy[1],
- left = [x - distance, y],
- right = [x + distance, y],
- top = [x, y - distance],
- bottom = [x, y + distance],
- hash = {
- l : left,
- left : left,
- r : right,
- right : right,
- t : top,
- top : top,
- up : top,
- b : bottom,
- bottom : bottom,
- down : bottom
- };
+ dom = me.dom,
+ scroll = !Ext.isEmpty(monitorScroll),
+ action = function(){
+ Ext.fly(dom).alignTo(el, alignment, offsets, animate);
+ Ext.callback(callback, Ext.fly(dom));
+ },
+ anchor = this.getAnchor();
+
- direction = direction.toLowerCase();
- me.moveTo(hash[direction][0], hash[direction][1], me.animTest.call(me, arguments, animate, 2));
- },
-
-
- setLeftTop : function(left, top){
- var me = this,
- style = me.dom.style;
- style.left = me.addUnits(left);
- style.top = me.addUnits(top);
+ this.removeAnchor();
+ Ext.apply(anchor, {
+ fn: action,
+ scroll: scroll
+ });
+
+ Ext.EventManager.onWindowResize(action, null);
+
+ if(scroll){
+ Ext.EventManager.on(window, 'scroll', action, null,
+ {buffer: !isNaN(monitorScroll) ? monitorScroll : 50});
+ }
+ action.call(me);
return me;
},
- getRegion : function(){
- return Ext.lib.Dom.getRegion(this.dom);
- },
-
-
- setBounds : function(x, y, width, height, animate){
- var me = this;
- if (!animate || !me.anim) {
- me.setSize(width, height);
- me.setLocation(x, y);
- } else {
- me.anim({points: {to: [x, y]},
- width: {to: me.adjustWidth(width)},
- height: {to: me.adjustHeight(height)}},
- me.preanim(arguments, 4),
- 'motion');
+ removeAnchor : function(){
+ var me = this,
+ anchor = this.getAnchor();
+
+ if(anchor && anchor.fn){
+ Ext.EventManager.removeResizeListener(anchor.fn);
+ if(anchor.scroll){
+ Ext.EventManager.un(window, 'scroll', anchor.fn);
+ }
+ delete anchor.fn;
}
return me;
},
-
-
- setRegion : function(region, animate) {
- return this.setBounds(region.left, region.top, region.right-region.left, region.bottom-region.top, this.animTest.call(this, arguments, animate, 1));
- }
-});
-Ext.Element.addMethods({
- isScrollable : function(){
- var dom = this.dom;
- return dom.scrollHeight > dom.clientHeight || dom.scrollWidth > dom.clientWidth;
- },
-
- scrollTo : function(side, value){
- this.dom["scroll" + (/top/i.test(side) ? "Top" : "Left")] = value;
- return this;
+ getAnchor : function(){
+ var data = Ext.Element.data,
+ dom = this.dom;
+ if (!dom) {
+ return;
+ }
+ var anchor = data(dom, '_anchor');
+
+ if(!anchor){
+ anchor = data(dom, '_anchor', {});
+ }
+ return anchor;
},
- getScroll : function(){
- var d = this.dom,
- doc = document,
- body = doc.body,
- docElement = doc.documentElement,
- l,
- t,
- ret;
-
- if(d == doc || d == body){
- if(Ext.isIE && Ext.isStrict){
- l = docElement.scrollLeft;
- t = docElement.scrollTop;
- }else{
- l = window.pageXOffset;
- t = window.pageYOffset;
- }
- ret = {left: l || (body ? body.scrollLeft : 0), top: t || (body ? body.scrollTop : 0)};
- }else{
- ret = {left: d.scrollLeft, top: d.scrollTop};
+ getAlignToXY : function(el, p, o){
+ el = Ext.get(el);
+
+ if(!el || !el.dom){
+ throw "Element.alignToXY with an element that doesn't exist";
}
- return ret;
- }
-});
-Ext.Element.addMethods({
-
- scrollTo : function(side, value, animate){
- var top = /top/i.test(side),
- me = this,
- dom = me.dom,
- prop;
- if (!animate || !me.anim) {
- prop = 'scroll' + (top ? 'Top' : 'Left'),
- dom[prop] = value;
- }else{
- prop = 'scroll' + (top ? 'Left' : 'Top'),
- me.anim({scroll: {to: top ? [dom[prop], value] : [value, dom[prop]]}},
- me.preanim(arguments, 2), 'scroll');
+
+ o = o || [0,0];
+ p = (!p || p == "?" ? "tl-bl?" : (!(/-/).test(p) && p !== "" ? "tl-" + p : p || "tl-bl")).toLowerCase();
+
+ var me = this,
+ d = me.dom,
+ a1,
+ a2,
+ x,
+ y,
+
+ w,
+ h,
+ r,
+ dw = Ext.lib.Dom.getViewWidth() -10,
+ dh = Ext.lib.Dom.getViewHeight()-10,
+ p1y,
+ p1x,
+ p2y,
+ p2x,
+ swapY,
+ swapX,
+ doc = document,
+ docElement = doc.documentElement,
+ docBody = doc.body,
+ scrollX = (docElement.scrollLeft || docBody.scrollLeft || 0)+5,
+ scrollY = (docElement.scrollTop || docBody.scrollTop || 0)+5,
+ c = false,
+ p1 = "",
+ p2 = "",
+ m = p.match(/^([a-z]+)-([a-z]+)(\?)?$/);
+
+ if(!m){
+ throw "Element.alignTo with an invalid alignment " + p;
}
- return me;
- },
-
-
- scrollIntoView : function(container, hscroll){
- var c = Ext.getDom(container) || Ext.getBody().dom,
- el = this.dom,
- o = this.getOffsetsTo(c),
- l = o[0] + c.scrollLeft,
- t = o[1] + c.scrollTop,
- b = t + el.offsetHeight,
- r = l + el.offsetWidth,
- ch = c.clientHeight,
- ct = parseInt(c.scrollTop, 10),
- cl = parseInt(c.scrollLeft, 10),
- cb = ct + ch,
- cr = cl + c.clientWidth;
+
+ p1 = m[1];
+ p2 = m[2];
+ c = !!m[3];
- if (el.offsetHeight > ch || t < ct) {
- c.scrollTop = t;
- } else if (b > cb){
- c.scrollTop = b-ch;
- }
- c.scrollTop = c.scrollTop;
+
+
+ a1 = me.getAnchorXY(p1, true);
+ a2 = el.getAnchorXY(p2, false);
- if(hscroll !== false){
- if(el.offsetWidth > c.clientWidth || l < cl){
- c.scrollLeft = l;
- }else if(r > cr){
- c.scrollLeft = r - c.clientWidth;
+ x = a2[0] - a1[0] + o[0];
+ y = a2[1] - a1[1] + o[1];
+
+ if(c){
+ w = me.getWidth();
+ h = me.getHeight();
+ r = el.getRegion();
+
+
+
+ p1y = p1.charAt(0);
+ p1x = p1.charAt(p1.length-1);
+ p2y = p2.charAt(0);
+ p2x = p2.charAt(p2.length-1);
+ swapY = ((p1y=="t" && p2y=="b") || (p1y=="b" && p2y=="t"));
+ swapX = ((p1x=="r" && p2x=="l") || (p1x=="l" && p2x=="r"));
+
+
+ if (x + w > dw + scrollX) {
+ x = swapX ? r.left-w : dw+scrollX-w;
+ }
+ if (x < scrollX) {
+ x = swapX ? r.right : scrollX;
+ }
+ if (y + h > dh + scrollY) {
+ y = swapY ? r.top-h : dh+scrollY-h;
}
- c.scrollLeft = c.scrollLeft;
+ if (y < scrollY){
+ y = swapY ? r.bottom : scrollY;
+ }
}
- return this;
+ return [x,y];
},
- scrollChildIntoView : function(child, hscroll){
- Ext.fly(child, '_scrollChildIntoView').scrollIntoView(this, hscroll);
+ alignTo : function(element, position, offsets, animate){
+ var me = this;
+ return me.setXY(me.getAlignToXY(element, position, offsets),
+ me.preanim && !!animate ? me.preanim(arguments, 3) : false);
},
- scroll : function(direction, distance, animate){
- if(!this.isScrollable()){
- return;
- }
- var el = this.dom,
- l = el.scrollLeft, t = el.scrollTop,
- w = el.scrollWidth, h = el.scrollHeight,
- cw = el.clientWidth, ch = el.clientHeight,
- scrolled = false, v,
- hash = {
- l: Math.min(l + distance, w-cw),
- r: v = Math.max(l - distance, 0),
- t: Math.max(t - distance, 0),
- b: Math.min(t + distance, h-ch)
- };
- hash.d = hash.b;
- hash.u = hash.t;
-
- direction = direction.substr(0, 1);
- if((v = hash[direction]) > -1){
- scrolled = true;
- this.scrollTo(direction == 'l' || direction == 'r' ? 'left' : 'top', v, this.preanim(arguments, 2));
- }
- return scrolled;
- }
-});
+ adjustForConstraints : function(xy, parent, offsets){
+ return this.getConstrainToXY(parent || document, false, offsets, xy) || xy;
+ },
-Ext.Element.VISIBILITY = 1;
+
+ getConstrainToXY : function(el, local, offsets, proposedXY){
+ var os = {top:0, left:0, bottom:0, right: 0};
-Ext.Element.DISPLAY = 2;
+ return function(el, local, offsets, proposedXY){
+ el = Ext.get(el);
+ offsets = offsets ? Ext.applyIf(offsets, os) : os;
-Ext.Element.addMethods(function(){
- var VISIBILITY = "visibility",
- DISPLAY = "display",
- HIDDEN = "hidden",
- OFFSETS = "offsets",
- NONE = "none",
- ORIGINALDISPLAY = 'originalDisplay',
- VISMODE = 'visibilityMode',
- ELDISPLAY = Ext.Element.DISPLAY,
- data = Ext.Element.data,
- getDisplay = function(dom){
- var d = data(dom, ORIGINALDISPLAY);
- if(d === undefined){
- data(dom, ORIGINALDISPLAY, d = '');
+ var vw, vh, vx = 0, vy = 0;
+ if(el.dom == document.body || el.dom == document){
+ vw =Ext.lib.Dom.getViewWidth();
+ vh = Ext.lib.Dom.getViewHeight();
+ }else{
+ vw = el.dom.clientWidth;
+ vh = el.dom.clientHeight;
+ if(!local){
+ var vxy = el.getXY();
+ vx = vxy[0];
+ vy = vxy[1];
+ }
+ }
+
+ var s = el.getScroll();
+
+ vx += offsets.left + s.left;
+ vy += offsets.top + s.top;
+
+ vw -= offsets.right;
+ vh -= offsets.bottom;
+
+ var vr = vx + vw,
+ vb = vy + vh,
+ xy = proposedXY || (!local ? this.getXY() : [this.getLeft(true), this.getTop(true)]),
+ x = xy[0], y = xy[1],
+ offset = this.getConstrainOffset(),
+ w = this.dom.offsetWidth + offset,
+ h = this.dom.offsetHeight + offset;
+
+
+ var moved = false;
+
+
+ if((x + w) > vr){
+ x = vr - w;
+ moved = true;
}
- return d;
- },
- getVisMode = function(dom){
- var m = data(dom, VISMODE);
- if(m === undefined){
- data(dom, VISMODE, m = 1);
+ if((y + h) > vb){
+ y = vb - h;
+ moved = true;
}
- return m;
+
+ if(x < vx){
+ x = vx;
+ moved = true;
+ }
+ if(y < vy){
+ y = vy;
+ moved = true;
+ }
+ return moved ? [x, y] : false;
};
+ }(),
+
+
+
+
+
+
+
+
+
+
+
- return {
-
- originalDisplay : "",
- visibilityMode : 1,
-
- setVisibilityMode : function(visMode){
- data(this.dom, VISMODE, visMode);
- return this;
- },
-
- animate : function(args, duration, onComplete, easing, animType){
- this.anim(args, {duration: duration, callback: onComplete, easing: easing}, animType);
- return this;
- },
-
- anim : function(args, opt, animType, defaultDur, defaultEase, cb){
- animType = animType || 'run';
- opt = opt || {};
- var me = this,
- anim = Ext.lib.Anim[animType](
- me.dom,
- args,
- (opt.duration || defaultDur) || .35,
- (opt.easing || defaultEase) || 'easeOut',
- function(){
- if(cb) cb.call(me);
- if(opt.callback) opt.callback.call(opt.scope || me, me, opt);
- },
- me
- );
- opt.anim = anim;
- return anim;
- },
-
- preanim : function(a, i){
- return !a[i] ? false : (typeof a[i] == 'object' ? a[i]: {duration: a[i+1], callback: a[i+2], easing: a[i+3]});
- },
-
- isVisible : function() {
- return !this.isStyle(VISIBILITY, HIDDEN) && !this.isStyle(DISPLAY, NONE);
- },
-
- setVisible : function(visible, animate){
- var me = this, isDisplay, isVisible, isOffsets,
- dom = me.dom;
-
- if (typeof animate == 'string'){
- isDisplay = animate == DISPLAY;
- isVisible = animate == VISIBILITY;
- isOffsets = animate == OFFSETS;
- animate = false;
- } else {
- isDisplay = getVisMode(this.dom) == ELDISPLAY;
- isVisible = !isDisplay;
- }
- if (!animate || !me.anim) {
- if (isDisplay){
- me.setDisplayed(visible);
- } else if (isOffsets){
- if (!visible){
- me.hideModeStyles = {
- position: me.getStyle('position'),
- top: me.getStyle('top'),
- left: me.getStyle('left')
- };
- me.applyStyles({position: 'absolute', top: '-10000px', left: '-10000px'});
- } else {
- me.applyStyles(me.hideModeStyles || {position: '', top: '', left: ''});
- }
- }else{
- me.fixDisplay();
- dom.style.visibility = visible ? "visible" : HIDDEN;
- }
- }else{
-
- if (visible){
- me.setOpacity(.01);
- me.setVisible(true);
- }
- me.anim({opacity: { to: (visible?1:0) }},
- me.preanim(arguments, 1),
- null,
- .35,
- 'easeIn',
- function(){
- if(!visible){
- dom.style[isDisplay ? DISPLAY : VISIBILITY] = (isDisplay) ? NONE : HIDDEN;
- Ext.fly(dom).setOpacity(1);
- }
- });
- }
- return me;
- },
-
- toggle : function(animate){
- var me = this;
- me.setVisible(!me.isVisible(), me.preanim(arguments, 0));
- return me;
- },
-
- setDisplayed : function(value) {
- if(typeof value == "boolean"){
- value = value ? getDisplay(this.dom) : NONE;
- }
- this.setStyle(DISPLAY, value);
- return this;
- },
-
- fixDisplay : function(){
- var me = this;
- if(me.isStyle(DISPLAY, NONE)){
- me.setStyle(VISIBILITY, HIDDEN);
- me.setStyle(DISPLAY, getDisplay(this.dom));
- if(me.isStyle(DISPLAY, NONE)){
- me.setStyle(DISPLAY, "block");
- }
- }
- },
-
- hide : function(animate){
-
- if (typeof animate == 'string'){
- this.setVisible(false, animate);
- return this;
- }
- this.setVisible(false, this.preanim(arguments, 0));
- return this;
- },
-
- show : function(animate){
-
- if (typeof animate == 'string'){
- this.setVisible(true, animate);
- return this;
- }
- this.setVisible(true, this.preanim(arguments, 0));
- return this;
- }
- };
-}());
-Ext.Element.addMethods(
-function(){
- var VISIBILITY = "visibility",
- DISPLAY = "display",
- HIDDEN = "hidden",
- NONE = "none",
- XMASKED = "x-masked",
- XMASKEDRELATIVE = "x-masked-relative",
- data = Ext.Element.data;
- return {
-
- isVisible : function(deep) {
- var vis = !this.isStyle(VISIBILITY,HIDDEN) && !this.isStyle(DISPLAY,NONE),
- p = this.dom.parentNode;
- if(deep !== true || !vis){
- return vis;
- }
- while(p && !/^body/i.test(p.tagName)){
- if(!Ext.fly(p, '_isVisible').isVisible()){
- return false;
- }
- p = p.parentNode;
- }
- return true;
- },
-
- isDisplayed : function() {
- return !this.isStyle(DISPLAY, NONE);
- },
-
- enableDisplayMode : function(display){
- this.setVisibilityMode(Ext.Element.DISPLAY);
- if(!Ext.isEmpty(display)){
- data(this.dom, 'originalDisplay', display);
- }
- return this;
- },
-
- mask : function(msg, msgCls){
- var me = this,
- dom = me.dom,
- dh = Ext.DomHelper,
- EXTELMASKMSG = "ext-el-mask-msg",
- el,
- mask;
- if(!/^body/i.test(dom.tagName) && me.getStyle('position') == 'static'){
- me.addClass(XMASKEDRELATIVE);
- }
- if((el = data(dom, 'maskMsg'))){
- el.remove();
- }
- if((el = data(dom, 'mask'))){
- el.remove();
- }
- mask = dh.append(dom, {cls : "ext-el-mask"}, true);
- data(dom, 'mask', mask);
-
- me.addClass(XMASKED);
- mask.setDisplayed(true);
- if(typeof msg == 'string'){
- var mm = dh.append(dom, {cls : EXTELMASKMSG, cn:{tag:'div'}}, true);
- data(dom, 'maskMsg', mm);
- mm.dom.className = msgCls ? EXTELMASKMSG + " " + msgCls : EXTELMASKMSG;
- mm.dom.firstChild.innerHTML = msg;
- mm.setDisplayed(true);
- mm.center(me);
- }
- if(Ext.isIE && !(Ext.isIE7 && Ext.isStrict) && me.getStyle('height') == 'auto'){
- mask.setSize(undefined, me.getHeight());
- }
- return mask;
- },
-
- unmask : function(){
- var me = this,
- dom = me.dom,
- mask = data(dom, 'mask'),
- maskMsg = data(dom, 'maskMsg');
- if(mask){
- if(maskMsg){
- maskMsg.remove();
- data(dom, 'maskMsg', undefined);
- }
- mask.remove();
- data(dom, 'mask', undefined);
- }
- me.removeClass([XMASKED, XMASKEDRELATIVE]);
- },
-
- isMasked : function(){
- var m = data(this.dom, 'mask');
- return m && m.isVisible();
- },
-
- createShim : function(){
- var el = document.createElement('iframe'),
- shim;
- el.frameBorder = '0';
- el.className = 'ext-shim';
- el.src = Ext.SSL_SECURE_URL;
- shim = Ext.get(this.dom.parentNode.insertBefore(el, this.dom));
- shim.autoBoxAdjust = false;
- return shim;
- }
- };
-}());
-Ext.Element.addMethods({
-
- addKeyListener : function(key, fn, scope){
- var config;
- if(typeof key != 'object' || Ext.isArray(key)){
- config = {
- key: key,
- fn: fn,
- scope: scope
- };
- }else{
- config = {
- key : key.key,
- shift : key.shift,
- ctrl : key.ctrl,
- alt : key.alt,
- fn: fn,
- scope: scope
- };
- }
- return new Ext.KeyMap(this, config);
- },
-
- addKeyMap : function(config){
- return new Ext.KeyMap(this, config);
- }
-});
-(function(){
-
- var NULL = null,
- UNDEFINED = undefined,
- TRUE = true,
- FALSE = false,
- SETX = "setX",
- SETY = "setY",
- SETXY = "setXY",
- LEFT = "left",
- BOTTOM = "bottom",
- TOP = "top",
- RIGHT = "right",
- HEIGHT = "height",
- WIDTH = "width",
- POINTS = "points",
- HIDDEN = "hidden",
- ABSOLUTE = "absolute",
- VISIBLE = "visible",
- MOTION = "motion",
- POSITION = "position",
- EASEOUT = "easeOut",
-
- flyEl = new Ext.Element.Flyweight(),
- queues = {},
- getObject = function(o){
- return o || {};
- },
- fly = function(dom){
- flyEl.dom = dom;
- flyEl.id = Ext.id(dom);
- return flyEl;
- },
-
- getQueue = function(id){
- if(!queues[id]){
- queues[id] = [];
- }
- return queues[id];
- },
- setQueue = function(id, value){
- queues[id] = value;
- };
-
-Ext.enableFx = TRUE;
-Ext.Fx = {
-
-
-
- switchStatements : function(key, fn, argHash){
- return fn.apply(this, argHash[key]);
- },
-
-
- slideIn : function(anchor, o){
- o = getObject(o);
- var me = this,
- dom = me.dom,
- st = dom.style,
- xy,
- r,
- b,
- wrap,
- after,
- st,
- args,
- pt,
- bw,
- bh;
-
- anchor = anchor || "t";
- me.queueFx(o, function(){
- xy = fly(dom).getXY();
-
- fly(dom).fixDisplay();
-
-
- r = fly(dom).getFxRestore();
- b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight};
- b.right = b.x + b.width;
- b.bottom = b.y + b.height;
-
-
- fly(dom).setWidth(b.width).setHeight(b.height);
-
-
- wrap = fly(dom).fxWrap(r.pos, o, HIDDEN);
-
- st.visibility = VISIBLE;
- st.position = ABSOLUTE;
-
-
- function after(){
- fly(dom).fxUnwrap(wrap, r.pos, o);
- st.width = r.width;
- st.height = r.height;
- fly(dom).afterFx(o);
- }
-
-
- pt = {to: [b.x, b.y]};
- bw = {to: b.width};
- bh = {to: b.height};
-
- function argCalc(wrap, style, ww, wh, sXY, sXYval, s1, s2, w, h, p){
- var ret = {};
- fly(wrap).setWidth(ww).setHeight(wh);
- if(fly(wrap)[sXY]){
- fly(wrap)[sXY](sXYval);
- }
- style[s1] = style[s2] = "0";
- if(w){
- ret.width = w
- };
- if(h){
- ret.height = h;
- }
- if(p){
- ret.points = p;
- }
- return ret;
- };
- args = fly(dom).switchStatements(anchor.toLowerCase(), argCalc, {
- t : [wrap, st, b.width, 0, NULL, NULL, LEFT, BOTTOM, NULL, bh, NULL],
- l : [wrap, st, 0, b.height, NULL, NULL, RIGHT, TOP, bw, NULL, NULL],
- r : [wrap, st, b.width, b.height, SETX, b.right, LEFT, TOP, NULL, NULL, pt],
- b : [wrap, st, b.width, b.height, SETY, b.bottom, LEFT, TOP, NULL, bh, pt],
- tl : [wrap, st, 0, 0, NULL, NULL, RIGHT, BOTTOM, bw, bh, pt],
- bl : [wrap, st, 0, 0, SETY, b.y + b.height, RIGHT, TOP, bw, bh, pt],
- br : [wrap, st, 0, 0, SETXY, [b.right, b.bottom], LEFT, TOP, bw, bh, pt],
- tr : [wrap, st, 0, 0, SETX, b.x + b.width, LEFT, BOTTOM, bw, bh, pt]
- });
-
- st.visibility = VISIBLE;
- fly(wrap).show();
- arguments.callee.anim = fly(wrap).fxanim(args,
- o,
- MOTION,
- .5,
- EASEOUT,
- after);
- });
- return me;
- },
-
-
- slideOut : function(anchor, o){
- o = getObject(o);
- var me = this,
- dom = me.dom,
- st = dom.style,
- xy = me.getXY(),
- wrap,
- r,
- b,
- a,
- zero = {to: 0};
-
- anchor = anchor || "t";
- me.queueFx(o, function(){
-
-
- r = fly(dom).getFxRestore();
- b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight};
- b.right = b.x + b.width;
- b.bottom = b.y + b.height;
-
-
- fly(dom).setWidth(b.width).setHeight(b.height);
-
- wrap = fly(dom).fxWrap(r.pos, o, VISIBLE);
-
- st.visibility = VISIBLE;
- st.position = ABSOLUTE;
- fly(wrap).setWidth(b.width).setHeight(b.height);
- function after(){
- o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
- fly(dom).fxUnwrap(wrap, r.pos, o);
- st.width = r.width;
- st.height = r.height;
- fly(dom).afterFx(o);
- }
-
- function argCalc(style, s1, s2, p1, v1, p2, v2, p3, v3){
- var ret = {};
-
- style[s1] = style[s2] = "0";
- ret[p1] = v1;
- if(p2){
- ret[p2] = v2;
- }
- if(p3){
- ret[p3] = v3;
- }
-
- return ret;
- };
-
- a = fly(dom).switchStatements(anchor.toLowerCase(), argCalc, {
- t : [st, LEFT, BOTTOM, HEIGHT, zero],
- l : [st, RIGHT, TOP, WIDTH, zero],
- r : [st, LEFT, TOP, WIDTH, zero, POINTS, {to : [b.right, b.y]}],
- b : [st, LEFT, TOP, HEIGHT, zero, POINTS, {to : [b.x, b.bottom]}],
- tl : [st, RIGHT, BOTTOM, WIDTH, zero, HEIGHT, zero],
- bl : [st, RIGHT, TOP, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.x, b.bottom]}],
- br : [st, LEFT, TOP, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.x + b.width, b.bottom]}],
- tr : [st, LEFT, BOTTOM, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.right, b.y]}]
- });
-
- arguments.callee.anim = fly(wrap).fxanim(a,
- o,
- MOTION,
- .5,
- EASEOUT,
- after);
- });
- return me;
- },
-
- puff : function(o){
- o = getObject(o);
- var me = this,
- dom = me.dom,
- st = dom.style,
- width,
- height,
- r;
- me.queueFx(o, function(){
- width = fly(dom).getWidth();
- height = fly(dom).getHeight();
- fly(dom).clearOpacity();
- fly(dom).show();
-
- r = fly(dom).getFxRestore();
-
- function after(){
- o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
- fly(dom).clearOpacity();
- fly(dom).setPositioning(r.pos);
- st.width = r.width;
- st.height = r.height;
- st.fontSize = '';
- fly(dom).afterFx(o);
- }
- arguments.callee.anim = fly(dom).fxanim({
- width : {to : fly(dom).adjustWidth(width * 2)},
- height : {to : fly(dom).adjustHeight(height * 2)},
- points : {by : [-width * .5, -height * .5]},
- opacity : {to : 0},
- fontSize: {to : 200, unit: "%"}
- },
- o,
- MOTION,
- .5,
- EASEOUT,
- after);
- });
- return me;
- },
-
- switchOff : function(o){
- o = getObject(o);
- var me = this,
- dom = me.dom,
- st = dom.style,
- r;
- me.queueFx(o, function(){
- fly(dom).clearOpacity();
- fly(dom).clip();
-
- r = fly(dom).getFxRestore();
-
- function after(){
- o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
- fly(dom).clearOpacity();
- fly(dom).setPositioning(r.pos);
- st.width = r.width;
- st.height = r.height;
- fly(dom).afterFx(o);
- };
- fly(dom).fxanim({opacity : {to : 0.3}},
- NULL,
- NULL,
- .1,
- NULL,
- function(){
- fly(dom).clearOpacity();
- (function(){
- fly(dom).fxanim({
- height : {to : 1},
- points : {by : [0, fly(dom).getHeight() * .5]}
- },
- o,
- MOTION,
- 0.3,
- 'easeIn',
- after);
- }).defer(100);
- });
- });
- return me;
+
+
+
+ getConstrainOffset : function(){
+ return 0;
+ },
+
+
+ getCenterXY : function(){
+ return this.getAlignToXY(document, 'c-c');
},
-
- highlight : function(color, o){
- o = getObject(o);
- var me = this,
- dom = me.dom,
- attr = o.attr || "backgroundColor",
- a = {},
- restore;
+
+ center : function(centerIn){
+ return this.alignTo(centerIn || document, 'c-c');
+ }
+});
- me.queueFx(o, function(){
- fly(dom).clearOpacity();
- fly(dom).show();
+Ext.Element.addMethods({
+
+ select : function(selector, unique){
+ return Ext.Element.select(selector, unique, this.dom);
+ }
+});
+Ext.apply(Ext.Element.prototype, function() {
+ var GETDOM = Ext.getDom,
+ GET = Ext.get,
+ DH = Ext.DomHelper;
+
+ return {
+
+ insertSibling: function(el, where, returnDom){
+ var me = this,
+ rt,
+ isAfter = (where || 'before').toLowerCase() == 'after',
+ insertEl;
+
+ if(Ext.isArray(el)){
+ insertEl = me;
+ Ext.each(el, function(e) {
+ rt = Ext.fly(insertEl, '_internal').insertSibling(e, where, returnDom);
+ if(isAfter){
+ insertEl = rt;
+ }
+ });
+ return rt;
+ }
+
+ el = el || {};
+
+ if(el.nodeType || el.dom){
+ rt = me.dom.parentNode.insertBefore(GETDOM(el), isAfter ? me.dom.nextSibling : me.dom);
+ if (!returnDom) {
+ rt = GET(rt);
+ }
+ }else{
+ if (isAfter && !me.dom.nextSibling) {
+ rt = DH.append(me.dom.parentNode, el, !returnDom);
+ } else {
+ rt = DH[isAfter ? 'insertAfter' : 'insertBefore'](me.dom, el, !returnDom);
+ }
+ }
+ return rt;
+ }
+ };
+}());
- function after(){
- dom.style[attr] = restore;
- fly(dom).afterFx(o);
- }
- restore = dom.style[attr];
- a[attr] = {from: color || "ffff9c", to: o.endColor || fly(dom).getColor(attr) || "ffffff"};
- arguments.callee.anim = fly(dom).fxanim(a,
- o,
- 'color',
- 1,
- 'easeIn',
- after);
- });
- return me;
- },
-
- frame : function(color, count, o){
- o = getObject(o);
- var me = this,
- dom = me.dom,
- proxy,
- active;
+Ext.Element.boxMarkup = '<div class="{0}-tl"><div class="{0}-tr"><div class="{0}-tc"></div></div></div><div class="{0}-ml"><div class="{0}-mr"><div class="{0}-mc"></div></div></div><div class="{0}-bl"><div class="{0}-br"><div class="{0}-bc"></div></div></div>';
- me.queueFx(o, function(){
- color = color || '#C3DAF9';
- if(color.length == 6){
- color = '#' + color;
- }
- count = count || 1;
- fly(dom).show();
+Ext.Element.addMethods(function(){
+ var INTERNAL = "_internal",
+ pxMatch = /(\d+\.?\d+)px/;
+ return {
+
+ applyStyles : function(style){
+ Ext.DomHelper.applyStyles(this.dom, style);
+ return this;
+ },
- var xy = fly(dom).getXY(),
- b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight},
- queue = function(){
- proxy = fly(document.body || document.documentElement).createChild({
- style:{
- position : ABSOLUTE,
- 'z-index': 35000,
- border : '0px solid ' + color
- }
- });
- return proxy.queueFx({}, animFn);
- };
-
-
- arguments.callee.anim = {
- isAnimated: true,
- stop: function() {
- count = 0;
- proxy.stopFx();
- }
- };
-
- function animFn(){
- var scale = Ext.isBorderBox ? 2 : 1;
- active = proxy.anim({
- top : {from : b.y, to : b.y - 20},
- left : {from : b.x, to : b.x - 20},
- borderWidth : {from : 0, to : 10},
- opacity : {from : 1, to : 0},
- height : {from : b.height, to : b.height + 20 * scale},
- width : {from : b.width, to : b.width + 20 * scale}
- },{
- duration: o.duration || 1,
- callback: function() {
- proxy.remove();
- --count > 0 ? queue() : fly(dom).afterFx(o);
- }
- });
- arguments.callee.anim = {
- isAnimated: true,
- stop: function(){
- active.stop();
- }
- };
- };
- queue();
- });
- return me;
- },
+
+ getStyles : function(){
+ var ret = {};
+ Ext.each(arguments, function(v) {
+ ret[v] = this.getStyle(v);
+ },
+ this);
+ return ret;
+ },
-
- pause : function(seconds){
- var dom = this.dom,
- t;
+
+ setOverflow : function(v){
+ var dom = this.dom;
+ if(v=='auto' && Ext.isMac && Ext.isGecko2){
+ dom.style.overflow = 'hidden';
+ (function(){dom.style.overflow = 'auto';}).defer(1);
+ }else{
+ dom.style.overflow = v;
+ }
+ },
- this.queueFx({}, function(){
- t = setTimeout(function(){
- fly(dom).afterFx({});
- }, seconds * 1000);
- arguments.callee.anim = {
- isAnimated: true,
- stop: function(){
- clearTimeout(t);
- fly(dom).afterFx({});
+
+ boxWrap : function(cls){
+ cls = cls || 'x-box';
+ var el = Ext.get(this.insertHtml("beforeBegin", "<div class='" + cls + "'>" + String.format(Ext.Element.boxMarkup, cls) + "</div>"));
+ Ext.DomQuery.selectNode('.' + cls + '-mc', el.dom).appendChild(this.dom);
+ return el;
+ },
+
+
+ setSize : function(width, height, animate){
+ var me = this;
+ if(typeof width == 'object'){
+ height = width.height;
+ width = width.width;
+ }
+ width = me.adjustWidth(width);
+ height = me.adjustHeight(height);
+ if(!animate || !me.anim){
+ me.dom.style.width = me.addUnits(width);
+ me.dom.style.height = me.addUnits(height);
+ }else{
+ me.anim({width: {to: width}, height: {to: height}}, me.preanim(arguments, 2));
+ }
+ return me;
+ },
+
+
+ getComputedHeight : function(){
+ var me = this,
+ h = Math.max(me.dom.offsetHeight, me.dom.clientHeight);
+ if(!h){
+ h = parseFloat(me.getStyle('height')) || 0;
+ if(!me.isBorderBox()){
+ h += me.getFrameWidth('tb');
}
- };
- });
- return this;
- },
+ }
+ return h;
+ },
-
- fadeIn : function(o){
- o = getObject(o);
- var me = this,
- dom = me.dom,
- to = o.endOpacity || 1;
- me.queueFx(o, function(){
- fly(dom).setOpacity(0);
- fly(dom).fixDisplay();
- dom.style.visibility = VISIBLE;
- arguments.callee.anim = fly(dom).fxanim({opacity:{to:to}},
- o, NULL, .5, EASEOUT, function(){
- if(to == 1){
- fly(dom).clearOpacity();
+ getComputedWidth : function(){
+ var w = Math.max(this.dom.offsetWidth, this.dom.clientWidth);
+ if(!w){
+ w = parseFloat(this.getStyle('width')) || 0;
+ if(!this.isBorderBox()){
+ w += this.getFrameWidth('lr');
}
- fly(dom).afterFx(o);
- });
- });
- return me;
- },
+ }
+ return w;
+ },
-
- fadeOut : function(o){
- o = getObject(o);
- var me = this,
- dom = me.dom,
- style = dom.style,
- to = o.endOpacity || 0;
- me.queueFx(o, function(){
- arguments.callee.anim = fly(dom).fxanim({
- opacity : {to : to}},
- o,
- NULL,
- .5,
- EASEOUT,
+ getFrameWidth : function(sides, onlyContentBox){
+ return onlyContentBox && this.isBorderBox() ? 0 : (this.getPadding(sides) + this.getBorderWidth(sides));
+ },
+
+
+ addClassOnOver : function(className){
+ this.hover(
function(){
- if(to == 0){
- Ext.Element.data(dom, 'visibilityMode') == Ext.Element.DISPLAY || o.useDisplay ?
- style.display = "none" :
- style.visibility = HIDDEN;
-
- fly(dom).clearOpacity();
- }
- fly(dom).afterFx(o);
+ Ext.fly(this, INTERNAL).addClass(className);
+ },
+ function(){
+ Ext.fly(this, INTERNAL).removeClass(className);
+ }
+ );
+ return this;
+ },
+
+
+ addClassOnFocus : function(className){
+ this.on("focus", function(){
+ Ext.fly(this, INTERNAL).addClass(className);
+ }, this.dom);
+ this.on("blur", function(){
+ Ext.fly(this, INTERNAL).removeClass(className);
+ }, this.dom);
+ return this;
+ },
+
+
+ addClassOnClick : function(className){
+ var dom = this.dom;
+ this.on("mousedown", function(){
+ Ext.fly(dom, INTERNAL).addClass(className);
+ var d = Ext.getDoc(),
+ fn = function(){
+ Ext.fly(dom, INTERNAL).removeClass(className);
+ d.removeListener("mouseup", fn);
+ };
+ d.on("mouseup", fn);
});
- });
- return me;
- },
+ return this;
+ },
-
- scale : function(w, h, o){
- this.shift(Ext.apply({}, o, {
- width: w,
- height: h
- }));
- return this;
- },
+
+
+ getViewSize : function(){
+ var doc = document,
+ d = this.dom,
+ isDoc = (d == doc || d == doc.body);
-
- shift : function(o){
- o = getObject(o);
- var dom = this.dom,
- a = {};
-
- this.queueFx(o, function(){
- for (var prop in o) {
- if (o[prop] != UNDEFINED) {
- a[prop] = {to : o[prop]};
- }
- }
- a.width ? a.width.to = fly(dom).adjustWidth(o.width) : a;
- a.height ? a.height.to = fly(dom).adjustWidth(o.height) : a;
+ if (isDoc) {
+ var extdom = Ext.lib.Dom;
+ return {
+ width : extdom.getViewWidth(),
+ height : extdom.getViewHeight()
+ };
+
- if (a.x || a.y || a.xy) {
- a.points = a.xy ||
- {to : [ a.x ? a.x.to : fly(dom).getX(),
- a.y ? a.y.to : fly(dom).getY()]};
+ } else {
+ return {
+ width : d.clientWidth,
+ height : d.clientHeight
+ };
}
+ },
- arguments.callee.anim = fly(dom).fxanim(a,
- o,
- MOTION,
- .35,
- EASEOUT,
- function(){
- fly(dom).afterFx(o);
- });
- });
- return this;
- },
+
-
- ghost : function(anchor, o){
- o = getObject(o);
- var me = this,
- dom = me.dom,
- st = dom.style,
- a = {opacity: {to: 0}, points: {}},
- pt = a.points,
- r,
- w,
- h;
-
- anchor = anchor || "b";
+ getStyleSize : function(){
+ var me = this,
+ w, h,
+ doc = document,
+ d = this.dom,
+ isDoc = (d == doc || d == doc.body),
+ s = d.style;
- me.queueFx(o, function(){
- r = fly(dom).getFxRestore();
- w = fly(dom).getWidth();
- h = fly(dom).getHeight();
+ if (isDoc) {
+ var extdom = Ext.lib.Dom;
+ return {
+ width : extdom.getViewWidth(),
+ height : extdom.getViewHeight()
+ };
+ }
- function after(){
- o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
- fly(dom).clearOpacity();
- fly(dom).setPositioning(r.pos);
- st.width = r.width;
- st.height = r.height;
- fly(dom).afterFx(o);
+ if(s.width && s.width != 'auto'){
+ w = parseFloat(s.width);
+ if(me.isBorderBox()){
+ w -= me.getFrameWidth('lr');
+ }
}
-
- pt.by = fly(dom).switchStatements(anchor.toLowerCase(), function(v1,v2){ return [v1, v2];}, {
- t : [0, -h],
- l : [-w, 0],
- r : [w, 0],
- b : [0, h],
- tl : [-w, -h],
- bl : [-w, h],
- br : [w, h],
- tr : [w, -h]
- });
-
- arguments.callee.anim = fly(dom).fxanim(a,
- o,
- MOTION,
- .5,
- EASEOUT, after);
- });
- return me;
- },
+
+ if(s.height && s.height != 'auto'){
+ h = parseFloat(s.height);
+ if(me.isBorderBox()){
+ h -= me.getFrameWidth('tb');
+ }
+ }
+
+ return {width: w || me.getWidth(true), height: h || me.getHeight(true)};
+ },
-
- syncFx : function(){
- var me = this;
- me.fxDefaults = Ext.apply(me.fxDefaults || {}, {
- block : FALSE,
- concurrent : TRUE,
- stopFx : FALSE
- });
- return me;
- },
+
+ getSize : function(contentSize){
+ return {width: this.getWidth(contentSize), height: this.getHeight(contentSize)};
+ },
-
- sequenceFx : function(){
- var me = this;
- me.fxDefaults = Ext.apply(me.fxDefaults || {}, {
- block : FALSE,
- concurrent : FALSE,
- stopFx : FALSE
- });
- return me;
- },
+
+ repaint : function(){
+ var dom = this.dom;
+ this.addClass("x-repaint");
+ setTimeout(function(){
+ Ext.fly(dom).removeClass("x-repaint");
+ }, 1);
+ return this;
+ },
+
+
+ unselectable : function(){
+ this.dom.unselectable = "on";
+ return this.swallowEvent("selectstart", true).
+ applyStyles("-moz-user-select:none;-khtml-user-select:none;").
+ addClass("x-unselectable");
+ },
-
- nextFx : function(){
- var ef = getQueue(this.dom.id)[0];
- if(ef){
- ef.call(this);
- }
- },
+
+ getMargins : function(side){
+ var me = this,
+ key,
+ hash = {t:"top", l:"left", r:"right", b: "bottom"},
+ o = {};
-
- hasActiveFx : function(){
- return getQueue(this.dom.id)[0];
- },
+ if (!side) {
+ for (key in me.margins){
+ o[hash[key]] = parseFloat(me.getStyle(me.margins[key])) || 0;
+ }
+ return o;
+ } else {
+ return me.addStyles.call(me, side, me.margins);
+ }
+ }
+ };
+}());
+Ext.Element.addMethods({
- stopFx : function(finish){
+ setBox : function(box, adjust, animate){
var me = this,
- id = me.dom.id;
- if(me.hasActiveFx()){
- var cur = getQueue(id)[0];
- if(cur && cur.anim){
- if(cur.anim.isAnimated){
- setQueue(id, [cur]);
- cur.anim.stop(finish !== undefined ? finish : TRUE);
- }else{
- setQueue(id, []);
- }
- }
+ w = box.width,
+ h = box.height;
+ if((adjust && !me.autoBoxAdjust) && !me.isBorderBox()){
+ w -= (me.getBorderWidth("lr") + me.getPadding("lr"));
+ h -= (me.getBorderWidth("tb") + me.getPadding("tb"));
}
+ me.setBounds(box.x, box.y, w, h, me.animTest.call(me, arguments, animate, 2));
return me;
},
- beforeFx : function(o){
- if(this.hasActiveFx() && !o.concurrent){
- if(o.stopFx){
- this.stopFx();
- return TRUE;
- }
- return FALSE;
+ getBox : function(contentBox, local) {
+ var me = this,
+ xy,
+ left,
+ top,
+ getBorderWidth = me.getBorderWidth,
+ getPadding = me.getPadding,
+ l,
+ r,
+ t,
+ b;
+ if(!local){
+ xy = me.getXY();
+ }else{
+ left = parseInt(me.getStyle("left"), 10) || 0;
+ top = parseInt(me.getStyle("top"), 10) || 0;
+ xy = [left, top];
}
- return TRUE;
- },
-
+ var el = me.dom, w = el.offsetWidth, h = el.offsetHeight, bx;
+ if(!contentBox){
+ bx = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: w, height: h};
+ }else{
+ l = getBorderWidth.call(me, "l") + getPadding.call(me, "l");
+ r = getBorderWidth.call(me, "r") + getPadding.call(me, "r");
+ t = getBorderWidth.call(me, "t") + getPadding.call(me, "t");
+ b = getBorderWidth.call(me, "b") + getPadding.call(me, "b");
+ bx = {x: xy[0]+l, y: xy[1]+t, 0: xy[0]+l, 1: xy[1]+t, width: w-(l+r), height: h-(t+b)};
+ }
+ bx.right = bx.x + bx.width;
+ bx.bottom = bx.y + bx.height;
+ return bx;
+ },
+
- hasFxBlock : function(){
- var q = getQueue(this.dom.id);
- return q && q[0] && q[0].block;
+ move : function(direction, distance, animate){
+ var me = this,
+ xy = me.getXY(),
+ x = xy[0],
+ y = xy[1],
+ left = [x - distance, y],
+ right = [x + distance, y],
+ top = [x, y - distance],
+ bottom = [x, y + distance],
+ hash = {
+ l : left,
+ left : left,
+ r : right,
+ right : right,
+ t : top,
+ top : top,
+ up : top,
+ b : bottom,
+ bottom : bottom,
+ down : bottom
+ };
+
+ direction = direction.toLowerCase();
+ me.moveTo(hash[direction][0], hash[direction][1], me.animTest.call(me, arguments, animate, 2));
},
-
- queueFx : function(o, fn){
- var me = fly(this.dom);
- if(!me.hasFxBlock()){
- Ext.applyIf(o, me.fxDefaults);
- if(!o.concurrent){
- var run = me.beforeFx(o);
- fn.block = o.block;
- getQueue(me.dom.id).push(fn);
- if(run){
- me.nextFx();
- }
- }else{
- fn.call(me);
- }
- }
+
+ setLeftTop : function(left, top){
+ var me = this,
+ style = me.dom.style;
+ style.left = me.addUnits(left);
+ style.top = me.addUnits(top);
return me;
},
-
- fxWrap : function(pos, o, vis){
- var dom = this.dom,
- wrap,
- wrapXY;
- if(!o.wrap || !(wrap = Ext.getDom(o.wrap))){
- if(o.fixPosition){
- wrapXY = fly(dom).getXY();
- }
- var div = document.createElement("div");
- div.style.visibility = vis;
- wrap = dom.parentNode.insertBefore(div, dom);
- fly(wrap).setPositioning(pos);
- if(fly(wrap).isStyle(POSITION, "static")){
- fly(wrap).position("relative");
- }
- fly(dom).clearPositioning('auto');
- fly(wrap).clip();
- wrap.appendChild(dom);
- if(wrapXY){
- fly(wrap).setXY(wrapXY);
- }
- }
- return wrap;
+
+ getRegion : function(){
+ return Ext.lib.Dom.getRegion(this.dom);
},
-
- fxUnwrap : function(wrap, pos, o){
- var dom = this.dom;
- fly(dom).clearPositioning();
- fly(dom).setPositioning(pos);
- if(!o.wrap){
- var pn = fly(wrap).dom.parentNode;
- pn.insertBefore(dom, wrap);
- fly(wrap).remove();
+
+ setBounds : function(x, y, width, height, animate){
+ var me = this;
+ if (!animate || !me.anim) {
+ me.setSize(width, height);
+ me.setLocation(x, y);
+ } else {
+ me.anim({points: {to: [x, y]},
+ width: {to: me.adjustWidth(width)},
+ height: {to: me.adjustHeight(height)}},
+ me.preanim(arguments, 4),
+ 'motion');
}
+ return me;
},
- getFxRestore : function(){
- var st = this.dom.style;
- return {pos: this.getPositioning(), width: st.width, height : st.height};
- },
-
+ setRegion : function(region, animate) {
+ return this.setBounds(region.left, region.top, region.right-region.left, region.bottom-region.top, this.animTest.call(this, arguments, animate, 1));
+ }
+});
+Ext.Element.addMethods({
- afterFx : function(o){
- var dom = this.dom,
- id = dom.id;
- if(o.afterStyle){
- fly(dom).setStyle(o.afterStyle);
- }
- if(o.afterCls){
- fly(dom).addClass(o.afterCls);
- }
- if(o.remove == TRUE){
- fly(dom).remove();
- }
- if(o.callback){
- o.callback.call(o.scope, fly(dom));
+ scrollTo : function(side, value, animate) {
+
+ var top = /top/i.test(side),
+ me = this,
+ dom = me.dom,
+ prop;
+ if (!animate || !me.anim) {
+
+ prop = 'scroll' + (top ? 'Top' : 'Left');
+ dom[prop] = value;
}
- if(!o.concurrent){
- getQueue(id).shift();
- fly(dom).nextFx();
+ else {
+
+ prop = 'scroll' + (top ? 'Left' : 'Top');
+ me.anim({scroll: {to: top ? [dom[prop], value] : [value, dom[prop]]}}, me.preanim(arguments, 2), 'scroll');
}
+ return me;
},
-
- fxanim : function(args, opt, animType, defaultDur, defaultEase, cb){
- animType = animType || 'run';
- opt = opt || {};
- var anim = Ext.lib.Anim[animType](
- this.dom,
- args,
- (opt.duration || defaultDur) || .35,
- (opt.easing || defaultEase) || EASEOUT,
- cb,
- this
- );
- opt.anim = anim;
- return anim;
- }
-};
-
-
-Ext.Fx.resize = Ext.Fx.scale;
-
-
-
-Ext.Element.addMethods(Ext.Fx);
-})();
-
-Ext.CompositeElementLite = function(els, root){
- this.elements = [];
- this.add(els, root);
- this.el = new Ext.Element.Flyweight();
-};
-
-Ext.CompositeElementLite.prototype = {
- isComposite: true,
+ scrollIntoView : function(container, hscroll) {
+ var c = Ext.getDom(container) || Ext.getBody().dom,
+ el = this.dom,
+ o = this.getOffsetsTo(c),
+ l = o[0] + c.scrollLeft,
+ t = o[1] + c.scrollTop,
+ b = t + el.offsetHeight,
+ r = l + el.offsetWidth,
+ ch = c.clientHeight,
+ ct = parseInt(c.scrollTop, 10),
+ cl = parseInt(c.scrollLeft, 10),
+ cb = ct + ch,
+ cr = cl + c.clientWidth;
-
- getElement : function(el){
+ if (el.offsetHeight > ch || t < ct) {
+ c.scrollTop = t;
+ }
+ else if (b > cb) {
+ c.scrollTop = b-ch;
+ }
- var e = this.el;
- e.dom = el;
- e.id = el.id;
- return e;
- },
+ c.scrollTop = c.scrollTop;
-
- transformElement : function(el){
- return Ext.getDom(el);
+ if (hscroll !== false) {
+ if (el.offsetWidth > c.clientWidth || l < cl) {
+ c.scrollLeft = l;
+ }
+ else if (r > cr) {
+ c.scrollLeft = r - c.clientWidth;
+ }
+ c.scrollLeft = c.scrollLeft;
+ }
+ return this;
},
- getCount : function(){
- return this.elements.length;
+ scrollChildIntoView : function(child, hscroll) {
+ Ext.fly(child, '_scrollChildIntoView').scrollIntoView(this, hscroll);
},
- add : function(els, root){
- var me = this,
- elements = me.elements;
- if(!els){
- return this;
+
+ scroll : function(direction, distance, animate) {
+ if (!this.isScrollable()) {
+ return false;
}
- if(typeof els == "string"){
- els = Ext.Element.selectorFunction(els, root);
- }else if(els.isComposite){
- els = els.elements;
- }else if(!Ext.isIterable(els)){
- els = [els];
+ var el = this.dom,
+ l = el.scrollLeft, t = el.scrollTop,
+ w = el.scrollWidth, h = el.scrollHeight,
+ cw = el.clientWidth, ch = el.clientHeight,
+ scrolled = false, v,
+ hash = {
+ l: Math.min(l + distance, w-cw),
+ r: v = Math.max(l - distance, 0),
+ t: Math.max(t - distance, 0),
+ b: Math.min(t + distance, h-ch)
+ };
+ hash.d = hash.b;
+ hash.u = hash.t;
+
+ direction = direction.substr(0, 1);
+ if ((v = hash[direction]) > -1) {
+ scrolled = true;
+ this.scrollTo(direction == 'l' || direction == 'r' ? 'left' : 'top', v, this.preanim(arguments, 2));
}
+ return scrolled;
+ }
+});
+Ext.Element.addMethods(
+ function() {
+ var VISIBILITY = "visibility",
+ DISPLAY = "display",
+ HIDDEN = "hidden",
+ NONE = "none",
+ XMASKED = "x-masked",
+ XMASKEDRELATIVE = "x-masked-relative",
+ data = Ext.Element.data;
- for(var i = 0, len = els.length; i < len; ++i){
- elements.push(me.transformElement(els[i]));
- }
- return me;
- },
+ return {
+
+ isVisible : function(deep) {
+ var vis = !this.isStyle(VISIBILITY, HIDDEN) && !this.isStyle(DISPLAY, NONE),
+ p = this.dom.parentNode;
+
+ if (deep !== true || !vis) {
+ return vis;
+ }
+
+ while (p && !(/^body/i.test(p.tagName))) {
+ if (!Ext.fly(p, '_isVisible').isVisible()) {
+ return false;
+ }
+ p = p.parentNode;
+ }
+ return true;
+ },
- invoke : function(fn, args){
- var me = this,
- els = me.elements,
- len = els.length,
- e,
- i;
+
+ isDisplayed : function() {
+ return !this.isStyle(DISPLAY, NONE);
+ },
- for(i = 0; i < len; i++) {
- e = els[i];
- if(e){
- Ext.Element.prototype[fn].apply(me.getElement(e), args);
- }
- }
- return me;
- },
-
- item : function(index){
- var me = this,
- el = me.elements[index],
- out = null;
+
+ enableDisplayMode : function(display) {
+ this.setVisibilityMode(Ext.Element.DISPLAY);
+
+ if (!Ext.isEmpty(display)) {
+ data(this.dom, 'originalDisplay', display);
+ }
+
+ return this;
+ },
- if(el){
- out = me.getElement(el);
- }
- return out;
- },
+
+ mask : function(msg, msgCls) {
+ var me = this,
+ dom = me.dom,
+ dh = Ext.DomHelper,
+ EXTELMASKMSG = "ext-el-mask-msg",
+ el,
+ mask;
-
- addListener : function(eventName, handler, scope, opt){
- var els = this.elements,
- len = els.length,
- i, e;
+ if (!(/^body/i.test(dom.tagName) && me.getStyle('position') == 'static')) {
+ me.addClass(XMASKEDRELATIVE);
+ }
+ if (el = data(dom, 'maskMsg')) {
+ el.remove();
+ }
+ if (el = data(dom, 'mask')) {
+ el.remove();
+ }
- for(i = 0; i<len; i++) {
- e = els[i];
- if(e) {
- Ext.EventManager.on(e, eventName, handler, scope || e, opt);
- }
- }
- return this;
- },
-
- each : function(fn, scope){
- var me = this,
- els = me.elements,
- len = els.length,
- i, e;
+ mask = dh.append(dom, {cls : "ext-el-mask"}, true);
+ data(dom, 'mask', mask);
- for(i = 0; i<len; i++) {
- e = els[i];
- if(e){
- e = this.getElement(e);
- if(fn.call(scope || e, e, me, i) === false){
- break;
+ me.addClass(XMASKED);
+ mask.setDisplayed(true);
+
+ if (typeof msg == 'string') {
+ var mm = dh.append(dom, {cls : EXTELMASKMSG, cn:{tag:'div'}}, true);
+ data(dom, 'maskMsg', mm);
+ mm.dom.className = msgCls ? EXTELMASKMSG + " " + msgCls : EXTELMASKMSG;
+ mm.dom.firstChild.innerHTML = msg;
+ mm.setDisplayed(true);
+ mm.center(me);
}
- }
- }
- return me;
- },
+
+
+ if (Ext.isIE && !(Ext.isIE7 && Ext.isStrict) && me.getStyle('height') == 'auto') {
+ mask.setSize(undefined, me.getHeight());
+ }
+
+ return mask;
+ },
-
- fill : function(els){
- var me = this;
- me.elements = [];
- me.add(els);
- return me;
- },
+
+ unmask : function() {
+ var me = this,
+ dom = me.dom,
+ mask = data(dom, 'mask'),
+ maskMsg = data(dom, 'maskMsg');
-
- filter : function(selector){
- var els = [],
- me = this,
- elements = me.elements,
- fn = Ext.isFunction(selector) ? selector
- : function(el){
- return el.is(selector);
- };
+ if (mask) {
+ if (maskMsg) {
+ maskMsg.remove();
+ data(dom, 'maskMsg', undefined);
+ }
+
+ mask.remove();
+ data(dom, 'mask', undefined);
+ me.removeClass([XMASKED, XMASKEDRELATIVE]);
+ }
+ },
+
+ isMasked : function() {
+ var m = data(this.dom, 'mask');
+ return m && m.isVisible();
+ },
- me.each(function(el, self, i){
- if(fn(el, i) !== false){
- els[els.length] = me.transformElement(el);
+
+ createShim : function() {
+ var el = document.createElement('iframe'),
+ shim;
+
+ el.frameBorder = '0';
+ el.className = 'ext-shim';
+ el.src = Ext.SSL_SECURE_URL;
+ shim = Ext.get(this.dom.parentNode.insertBefore(el, this.dom));
+ shim.autoBoxAdjust = false;
+ return shim;
}
- });
- me.elements = els;
- return me;
- },
-
-
- indexOf : function(el){
- return this.elements.indexOf(this.transformElement(el));
- },
-
+ };
+ }()
+);
+Ext.Element.addMethods({
- replaceElement : function(el, replacement, domReplace){
- var index = !isNaN(el) ? el : this.indexOf(el),
- d;
- if(index > -1){
- replacement = Ext.getDom(replacement);
- if(domReplace){
- d = this.elements[index];
- d.parentNode.insertBefore(replacement, d);
- Ext.removeNode(d);
- }
- this.elements.splice(index, 1, replacement);
+ addKeyListener : function(key, fn, scope){
+ var config;
+ if(typeof key != 'object' || Ext.isArray(key)){
+ config = {
+ key: key,
+ fn: fn,
+ scope: scope
+ };
+ }else{
+ config = {
+ key : key.key,
+ shift : key.shift,
+ ctrl : key.ctrl,
+ alt : key.alt,
+ fn: fn,
+ scope: scope
+ };
}
- return this;
+ return new Ext.KeyMap(this, config);
},
- clear : function(){
- this.elements = [];
- }
-};
-
-Ext.CompositeElementLite.prototype.on = Ext.CompositeElementLite.prototype.addListener;
-
-(function(){
-var fnName,
- ElProto = Ext.Element.prototype,
- CelProto = Ext.CompositeElementLite.prototype;
-
-for(fnName in ElProto){
- if(Ext.isFunction(ElProto[fnName])){
- (function(fnName){
- CelProto[fnName] = CelProto[fnName] || function(){
- return this.invoke(fnName, arguments);
- };
- }).call(CelProto, fnName);
-
+ addKeyMap : function(config){
+ return new Ext.KeyMap(this, config);
}
-}
-})();
-
-if(Ext.DomQuery){
- Ext.Element.selectorFunction = Ext.DomQuery.select;
-}
-
+});
-Ext.Element.select = function(selector, root){
- var els;
- if(typeof selector == "string"){
- els = Ext.Element.selectorFunction(selector, root);
- }else if(selector.length !== undefined){
- els = selector;
- }else{
- throw "Invalid selector";
- }
- return new Ext.CompositeElementLite(els);
-};
-Ext.select = Ext.Element.select;
+Ext.CompositeElementLite.importElementMethods();
Ext.apply(Ext.CompositeElementLite.prototype, {
addElements : function(els, root){
if(!els){
};
-Ext.select = Ext.Element.select;(function(){
- var BEFOREREQUEST = "beforerequest",
- REQUESTCOMPLETE = "requestcomplete",
- REQUESTEXCEPTION = "requestexception",
- UNDEFINED = undefined,
- LOAD = 'load',
- POST = 'POST',
- GET = 'GET',
- WINDOW = window;
-
-
- Ext.data.Connection = function(config){
- Ext.apply(this, config);
- this.addEvents(
-
- BEFOREREQUEST,
-
- REQUESTCOMPLETE,
-
- REQUESTEXCEPTION
- );
- Ext.data.Connection.superclass.constructor.call(this);
- };
-
- Ext.extend(Ext.data.Connection, Ext.util.Observable, {
-
-
-
-
-
- timeout : 30000,
-
- autoAbort:false,
-
-
- disableCaching: true,
-
-
- disableCachingParam: '_dc',
-
-
- request : function(o){
- var me = this;
- if(me.fireEvent(BEFOREREQUEST, me, o)){
- if (o.el) {
- if(!Ext.isEmpty(o.indicatorText)){
- me.indicatorText = '<div class="loading-indicator">'+o.indicatorText+"</div>";
- }
- if(me.indicatorText) {
- Ext.getDom(o.el).innerHTML = me.indicatorText;
- }
- o.success = (Ext.isFunction(o.success) ? o.success : function(){}).createInterceptor(function(response) {
- Ext.getDom(o.el).innerHTML = response.responseText;
- });
- }
-
- var p = o.params,
- url = o.url || me.url,
- method,
- cb = {success: me.handleResponse,
- failure: me.handleFailure,
- scope: me,
- argument: {options: o},
- timeout : o.timeout || me.timeout
- },
- form,
- serForm;
-
-
- if (Ext.isFunction(p)) {
- p = p.call(o.scope||WINDOW, o);
- }
-
- p = Ext.urlEncode(me.extraParams, Ext.isObject(p) ? Ext.urlEncode(p) : p);
-
- if (Ext.isFunction(url)) {
- url = url.call(o.scope || WINDOW, o);
- }
-
- if((form = Ext.getDom(o.form))){
- url = url || form.action;
- if(o.isUpload || /multipart\/form-data/i.test(form.getAttribute("enctype"))) {
- return me.doFormUpload.call(me, o, p, url);
- }
- serForm = Ext.lib.Ajax.serializeForm(form);
- p = p ? (p + '&' + serForm) : serForm;
- }
-
- method = o.method || me.method || ((p || o.xmlData || o.jsonData) ? POST : GET);
-
- if(method === GET && (me.disableCaching && o.disableCaching !== false) || o.disableCaching === true){
- var dcp = o.disableCachingParam || me.disableCachingParam;
- url = Ext.urlAppend(url, dcp + '=' + (new Date().getTime()));
- }
-
- o.headers = Ext.apply(o.headers || {}, me.defaultHeaders || {});
-
- if(o.autoAbort === true || me.autoAbort) {
- me.abort();
- }
-
- if((method == GET || o.xmlData || o.jsonData) && p){
- url = Ext.urlAppend(url, p);
- p = '';
- }
- return (me.transId = Ext.lib.Ajax.request(method, url, cb, p, o));
- }else{
- return o.callback ? o.callback.apply(o.scope, [o,UNDEFINED,UNDEFINED]) : null;
- }
- },
-
-
- isLoading : function(transId){
- return transId ? Ext.lib.Ajax.isCallInProgress(transId) : !! this.transId;
- },
-
-
- abort : function(transId){
- if(transId || this.isLoading()){
- Ext.lib.Ajax.abort(transId || this.transId);
- }
- },
-
-
- handleResponse : function(response){
- this.transId = false;
- var options = response.argument.options;
- response.argument = options ? options.argument : null;
- this.fireEvent(REQUESTCOMPLETE, this, response, options);
- if(options.success){
- options.success.call(options.scope, response, options);
- }
- if(options.callback){
- options.callback.call(options.scope, options, true, response);
- }
- },
-
-
- handleFailure : function(response, e){
- this.transId = false;
- var options = response.argument.options;
- response.argument = options ? options.argument : null;
- this.fireEvent(REQUESTEXCEPTION, this, response, options, e);
- if(options.failure){
- options.failure.call(options.scope, response, options);
- }
- if(options.callback){
- options.callback.call(options.scope, options, false, response);
- }
- },
-
-
- doFormUpload : function(o, ps, url){
- var id = Ext.id(),
- doc = document,
- frame = doc.createElement('iframe'),
- form = Ext.getDom(o.form),
- hiddens = [],
- hd,
- encoding = 'multipart/form-data',
- buf = {
- target: form.target,
- method: form.method,
- encoding: form.encoding,
- enctype: form.enctype,
- action: form.action
- };
-
-
- Ext.fly(frame).set({
- id: id,
- name: id,
- cls: 'x-hidden',
- src: Ext.SSL_SECURE_URL
- });
-
- doc.body.appendChild(frame);
-
-
- if(Ext.isIE){
- document.frames[id].name = id;
- }
-
-
- Ext.fly(form).set({
- target: id,
- method: POST,
- enctype: encoding,
- encoding: encoding,
- action: url || buf.action
- });
-
-
- Ext.iterate(Ext.urlDecode(ps, false), function(k, v){
- hd = doc.createElement('input');
- Ext.fly(hd).set({
- type: 'hidden',
- value: v,
- name: k
- });
- form.appendChild(hd);
- hiddens.push(hd);
- });
-
- function cb(){
- var me = this,
-
- r = {responseText : '',
- responseXML : null,
- argument : o.argument},
- doc,
- firstChild;
-
- try{
- doc = frame.contentWindow.document || frame.contentDocument || WINDOW.frames[id].document;
- if(doc){
- if(doc.body){
- if(/textarea/i.test((firstChild = doc.body.firstChild || {}).tagName)){
- r.responseText = firstChild.value;
- }else{
- r.responseText = doc.body.innerHTML;
- }
- }
-
- r.responseXML = doc.XMLDocument || doc;
- }
- }
- catch(e) {}
-
- Ext.EventManager.removeListener(frame, LOAD, cb, me);
-
- me.fireEvent(REQUESTCOMPLETE, me, r, o);
-
- function runCallback(fn, scope, args){
- if(Ext.isFunction(fn)){
- fn.apply(scope, args);
- }
- }
-
- runCallback(o.success, o.scope, [r, o]);
- runCallback(o.callback, o.scope, [o, true, r]);
-
- if(!me.debugUploads){
- setTimeout(function(){Ext.removeNode(frame);}, 100);
- }
- }
-
- Ext.EventManager.on(frame, LOAD, cb, this);
- form.submit();
-
- Ext.fly(form).set(buf);
- Ext.each(hiddens, function(h) {
- Ext.removeNode(h);
- });
- }
- });
-})();
-
-
-Ext.Ajax = new Ext.data.Connection({
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- autoAbort : false,
-
-
- serializeForm : function(form){
- return Ext.lib.Ajax.serializeForm(form);
- }
-});
-
+Ext.select = Ext.Element.select;
Ext.UpdateManager = Ext.Updater = Ext.extend(Ext.util.Observable,
function() {
var BEFOREUPDATE = "beforeupdate",
this.update(this.defaultUrl, null, callback, true);
}
}
- }
+ };
}());
g:0,
c:null,
s:Ext.escapeRe(character)
- }
+ };
};
t: "this.getDaysInMonth()",
L: "(this.isLeapYear() ? 1 : 0)",
o: "(this.getFullYear() + (this.getWeekOfYear() == 1 && this.getMonth() > 0 ? +1 : (this.getWeekOfYear() >= 52 && this.getMonth() < 11 ? -1 : 0)))",
- Y: "this.getFullYear()",
+ Y: "String.leftPad(this.getFullYear(), 4, '0')",
y: "('' + this.getFullYear()).substring(2, 4)",
a: "(this.getHours() < 12 ? 'am' : 'pm')",
A: "(this.getHours() < 12 ? 'AM' : 'PM')",
s = s || 0;
ms = ms || 0;
- var dt = new Date(y, m - 1, d, h, i, s, ms);
+
+ var dt = new Date(y < 100 ? 100 : y, m - 1, d, h, i, s, ms).add(Date.YEAR, y < 100 ? y - 100 : 0);
return y == dt.getFullYear() &&
m == dt.getMonth() + 1 &&
special = false;
code.push("'" + String.escape(ch) + "'");
} else {
- code.push(Date.getFormatCode(ch))
+ code.push(Date.getFormatCode(ch));
}
}
Date.formatFunctions[format] = new Function("return " + code.join('+'));
- "v = new Date(y, 0, 1, h, i, s, ms);",
+
+ "v = new Date(y < 100 ? 100 : y, 0, 1, h, i, s, ms).add(Date.YEAR, y < 100 ? y - 100 : 0);",
"v = !strict? v : (strict === true && (z <= 364 || (v.isLeapYear() && z <= 365))? v.add(Date.DAY, z) : null);",
"v = null;",
"}else{",
- "v = new Date(y, m, d, h, i, s, ms);",
+
+ "v = new Date(y < 100 ? 100 : y, m, d, h, i, s, ms).add(Date.YEAR, y < 100 ? y - 100 : 0);",
"}",
"}",
"}",
calc = [],
regex = [],
special = false,
- ch = "";
+ ch = "",
+ i = 0,
+ obj,
+ last;
- for (var i = 0; i < format.length; ++i) {
+ for (; i < format.length; ++i) {
ch = format.charAt(i);
if (!special && ch == "\\") {
special = true;
special = false;
regex.push(String.escape(ch));
} else {
- var obj = $f(ch, currentGroup);
+ obj = $f(ch, currentGroup);
currentGroup += obj.g;
regex.push(obj.s);
if (obj.g && obj.c) {
- calc.push(obj.c);
+ if (obj.calcLast) {
+ last = obj.c;
+ } else {
+ calc.push(obj.c);
+ }
}
}
}
+
+ if (last) {
+ calc.push(last);
+ }
- Date.parseRegexes[regexNum] = new RegExp("^" + regex.join('') + "$");
+ Date.parseRegexes[regexNum] = new RegExp("^" + regex.join('') + "$", 'i');
Date.parseFunctions[format] = new Function("input", "strict", xf(code, regexNum, calc.join('')));
- }
+ };
}(),
g:0,
c:null,
s:"(?:" + a.join("|") +")"
- }
+ };
},
l: function() {
return {
g:0,
c:null,
s:"(?:" + Date.dayNames.join("|") + ")"
- }
+ };
},
N: {
g:0,
g:1,
c:"m = parseInt(Date.getMonthNumber(results[{0}]), 10);\n",
s:"(" + Date.monthNames.join("|") + ")"
- }
+ };
},
M: function() {
for (var a = [], i = 0; i < 12; a.push(Date.getShortMonthName(i)), ++i);
+ "y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",
s:"(\\d{1,2})"
},
- a: {
- g:1,
- c:"if (results[{0}] == 'am') {\n"
- + "if (!h || h == 12) { h = 0; }\n"
- + "} else { if (!h || h < 12) { h = (h || 0) + 12; }}",
- s:"(am|pm)"
+
+ a: function(){
+ return $f("A");
},
A: {
+
+ calcLast: true,
g:1,
- c:"if (results[{0}] == 'AM') {\n"
+ 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)"
+ s:"(AM|PM|am|pm)"
},
g: function() {
return $f("G");
")?",
")?"
].join("")
- }
+ };
},
U: {
g:1,
Wyr = new Date(AWN * ms7d).getUTCFullYear();
return AWN - Math.floor(Date.UTC(Wyr, 0, 7) / ms7d) + 1;
- }
+ };
}(),
var m = this.getMonth();
return m == 1 && this.isLeapYear() ? 29 : daysInMonth[m];
- }
+ };
}(),
reorder: function(mapping) {
this.suspendEvents();
- var items = this.items,
- index = 0,
- length = items.length,
- order = [],
- remaining = [];
+ var items = this.items,
+ index = 0,
+ length = items.length,
+ order = [],
+ remaining = [],
+ oldIndex;
for (oldIndex in mapping) {
Ext.util.MixedCollection.prototype.get = Ext.util.MixedCollection.prototype.item;
-Ext.util.JSON = new (function(){
- var useHasOwn = !!{}.hasOwnProperty,
- isNative = function() {
- var useNative = null;
-
- return function() {
- if (useNative === null) {
- useNative = Ext.USE_NATIVE_JSON && window.JSON && JSON.toString() == '[object JSON]';
- }
+Ext.AbstractManager = Ext.extend(Object, {
+ typeName: 'type',
+
+ constructor: function(config) {
+ Ext.apply(this, config || {});
- return useNative;
- };
- }(),
- pad = function(n) {
- return n < 10 ? "0" + n : n;
- },
- doDecode = function(json){
- return eval("(" + json + ')');
- },
- doEncode = function(o){
- if(!Ext.isDefined(o) || o === null){
- return "null";
- }else if(Ext.isArray(o)){
- return encodeArray(o);
- }else if(Ext.isDate(o)){
- return Ext.util.JSON.encodeDate(o);
- }else if(Ext.isString(o)){
- return encodeString(o);
- }else if(typeof o == "number"){
-
- return isFinite(o) ? String(o) : "null";
- }else if(Ext.isBoolean(o)){
- return String(o);
- }else {
- var a = ["{"], b, i, v;
- for (i in o) {
-
- if(!o.getElementsByTagName){
- if(!useHasOwn || o.hasOwnProperty(i)) {
- v = o[i];
- switch (typeof v) {
- case "undefined":
- case "function":
- case "unknown":
- break;
- default:
- if(b){
- a.push(',');
- }
- a.push(doEncode(i), ":",
- v === null ? "null" : doEncode(v));
- b = true;
- }
- }
- }
- }
- a.push("}");
- return a.join("");
- }
- },
- m = {
- "\b": '\\b',
- "\t": '\\t',
- "\n": '\\n',
- "\f": '\\f',
- "\r": '\\r',
- '"' : '\\"',
- "\\": '\\\\'
- },
- encodeString = function(s){
- if (/["\\\x00-\x1f]/.test(s)) {
- return '"' + s.replace(/([\x00-\x1f\\"])/g, function(a, b) {
- var c = m[b];
- if(c){
- return c;
- }
- c = b.charCodeAt();
- return "\\u00" +
- Math.floor(c / 16).toString(16) +
- (c % 16).toString(16);
- }) + '"';
- }
- return '"' + s + '"';
- },
- encodeArray = function(o){
- var a = ["["], b, i, l = o.length, v;
- for (i = 0; i < l; i += 1) {
- v = o[i];
- switch (typeof v) {
- case "undefined":
- case "function":
- case "unknown":
- break;
- default:
- if (b) {
- a.push(',');
- }
- a.push(v === null ? "null" : Ext.util.JSON.encode(v));
- b = true;
- }
- }
- a.push("]");
- return a.join("");
- };
-
+
+ this.all = new Ext.util.MixedCollection();
+
+ this.types = {};
+ },
- this.encodeDate = function(o){
- return '"' + o.getFullYear() + "-" +
- pad(o.getMonth() + 1) + "-" +
- pad(o.getDate()) + "T" +
- pad(o.getHours()) + ":" +
- pad(o.getMinutes()) + ":" +
- pad(o.getSeconds()) + '"';
- };
-
- this.encode = function() {
- var ec;
- return function(o) {
- if (!ec) {
-
- ec = isNative() ? JSON.stringify : doEncode;
- }
- return ec(o);
- };
- }();
-
-
+ get : function(id){
+ return this.all.get(id);
+ },
- this.decode = function() {
- var dc;
- return function(json) {
- if (!dc) {
-
- dc = isNative() ? JSON.parse : doDecode;
+
+ register: function(item) {
+ this.all.add(item);
+ },
+
+
+ unregister: function(item) {
+ this.all.remove(item);
+ },
+
+
+ registerType : function(type, cls){
+ this.types[type] = cls;
+ cls[this.typeName] = type;
+ },
+
+
+ isRegistered : function(type){
+ return this.types[type] !== undefined;
+ },
+
+
+ create: function(config, defaultType) {
+ var type = config[this.typeName] || config.type || defaultType,
+ Constructor = this.types[type];
+
+ if (Constructor == undefined) {
+ throw new Error(String.format("The '{0}' type has not been registered with this manager", type));
+ }
+
+ return new Constructor(config);
+ },
+
+
+ onAvailable : function(id, fn, scope){
+ var all = this.all;
+
+ all.on("add", function(index, o){
+ if (o.id == id) {
+ fn.call(scope || o, o);
+ all.un("add", fn, scope);
}
- return dc(json);
- };
- }();
-
-})();
-
-Ext.encode = Ext.util.JSON.encode;
-
-Ext.decode = Ext.util.JSON.decode;
-
-Ext.util.Format = function(){
- var trimRe = /^\s+|\s+$/g,
- stripTagsRE = /<\/?[^>]+>/gi,
+ });
+ }
+});
+Ext.util.Format = function() {
+ var trimRe = /^\s+|\s+$/g,
+ stripTagsRE = /<\/?[^>]+>/gi,
stripScriptsRe = /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig,
- nl2brRe = /\r?\n/g;
+ nl2brRe = /\r?\n/g;
return {
- ellipsis : function(value, len, word){
- if(value && value.length > len){
- if(word){
- var vs = value.substr(0, len - 2),
+ 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)){
+ if (index == -1 || index < (len - 15)) {
return value.substr(0, len - 3) + "...";
- }else{
+ } else {
return vs.substr(0, index) + "...";
}
- } else{
+ } else {
return value.substr(0, len - 3) + "...";
}
}
},
- undef : function(value){
+ undef : function(value) {
return value !== undefined ? value : "";
},
- defaultValue : function(value, defaultValue){
+ defaultValue : function(value, defaultValue) {
return value !== undefined && value !== '' ? value : defaultValue;
},
- htmlEncode : function(value){
+ htmlEncode : function(value) {
return !value ? value : String(value).replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, """);
},
- htmlDecode : function(value){
+ htmlDecode : function(value) {
return !value ? value : String(value).replace(/>/g, ">").replace(/</g, "<").replace(/"/g, '"').replace(/&/g, "&");
},
- trim : function(value){
+ trim : function(value) {
return String(value).replace(trimRe, "");
},
- substr : function(value, start, length){
+ substr : function(value, start, length) {
return String(value).substr(start, length);
},
- lowercase : function(value){
+ lowercase : function(value) {
return String(value).toLowerCase();
},
- uppercase : function(value){
+ uppercase : function(value) {
return String(value).toUpperCase();
},
- capitalize : function(value){
+ capitalize : function(value) {
return !value ? value : value.charAt(0).toUpperCase() + value.substr(1).toLowerCase();
},
- call : function(value, fn){
- if(arguments.length > 2){
+ call : function(value, fn) {
+ if (arguments.length > 2) {
var args = Array.prototype.slice.call(arguments, 2);
args.unshift(value);
return eval(fn).apply(window, args);
- }else{
+ } else {
return eval(fn).call(window, value);
}
},
- usMoney : function(v){
+ usMoney : function(v) {
v = (Math.round((v-0)*100))/100;
v = (v == Math.floor(v)) ? v + ".00" : ((v*10 == Math.floor(v*10)) ? v + "0" : v);
v = String(v);
whole = whole.replace(r, '$1' + ',' + '$2');
}
v = whole + sub;
- if(v.charAt(0) == '-'){
+ if (v.charAt(0) == '-') {
return '-$' + v.substr(1);
}
return "$" + v;
},
- date : function(v, format){
- if(!v){
+ date : function(v, format) {
+ if (!v) {
return "";
}
- if(!Ext.isDate(v)){
+ if (!Ext.isDate(v)) {
v = new Date(Date.parse(v));
}
return v.dateFormat(format || "m/d/Y");
},
- dateRenderer : function(format){
- return function(v){
+ dateRenderer : function(format) {
+ return function(v) {
return Ext.util.Format.date(v, format);
};
},
- stripTags : function(v){
+ stripTags : function(v) {
return !v ? v : String(v).replace(stripTagsRE, "");
},
- stripScripts : function(v){
+ stripScripts : function(v) {
return !v ? v : String(v).replace(stripScriptsRe, "");
},
- fileSize : function(size){
- if(size < 1024) {
+ fileSize : function(size) {
+ if (size < 1024) {
return size + " bytes";
- } else if(size < 1048576) {
+ } else if (size < 1048576) {
return (Math.round(((size*10) / 1024))/10) + " KB";
} else {
return (Math.round(((size*10) / 1048576))/10) + " MB";
math : function(){
var fns = {};
+
return function(v, a){
- if(!fns[a]){
+ if (!fns[a]) {
fns[a] = new Function('v', 'return v ' + a + ';');
}
return fns[a](v);
- }
+ };
}(),
number: function(v, format) {
- if(!format){
+ if (!format) {
return v;
}
v = Ext.num(v, NaN);
- if (isNaN(v)){
+ if (isNaN(v)) {
return '';
}
var comma = ',',
- dec = '.',
- i18n = false,
- neg = v < 0;
+ dec = '.',
+ i18n = false,
+ neg = v < 0;
v = Math.abs(v);
- if(format.substr(format.length - 2) == '/i'){
+ if (format.substr(format.length - 2) == '/i') {
format = format.substr(0, format.length - 2);
- i18n = true;
- comma = '.';
- dec = ',';
+ i18n = true;
+ comma = '.';
+ dec = ',';
}
var hasComma = format.indexOf(comma) != -1,
- psplit = (i18n ? format.replace(/[^\d\,]/g, '') : format.replace(/[^\d\.]/g, '')).split(dec);
+ psplit = (i18n ? format.replace(/[^\d\,]/g, '') : format.replace(/[^\d\.]/g, '')).split(dec);
- if(1 < psplit.length){
+ if (1 < psplit.length) {
v = v.toFixed(psplit[1].length);
- }else if(2 < psplit.length){
+ } else if(2 < psplit.length) {
throw ('NumberFormatException: invalid format, formats should have no more than 1 period: ' + format);
- }else{
+ } else {
v = v.toFixed(0);
}
psplit = fnum.split('.');
if (hasComma) {
- var cnum = psplit[0], parr = [], j = cnum.length, m = Math.floor(j / 3), n = cnum.length % 3 || 3;
-
- for (var i = 0; i < j; i += n) {
+ var cnum = psplit[0],
+ parr = [],
+ j = cnum.length,
+ m = Math.floor(j / 3),
+ n = cnum.length % 3 || 3,
+ i;
+
+ for (i = 0; i < j; i += n) {
if (i != 0) {
n = 3;
}
+
parr[parr.length] = cnum.substr(i, n);
m -= 1;
}
},
- numberRenderer : function(format){
- return function(v){
+ numberRenderer : function(format) {
+ return function(v) {
return Ext.util.Format.number(v, format);
};
},
- plural : function(v, s, p){
+ plural : function(v, s, p) {
return v +' ' + (v == 1 ? s : (p ? p : s+'s'));
},
- nl2br : function(v){
+ nl2br : function(v) {
return Ext.isEmpty(v) ? '' : v.replace(nl2brRe, '<br/>');
}
- }
+ };
}();
Ext.XTemplate = function(){
}
};
}();
-Ext.util.ClickRepeater = function(el, config)
-{
- this.el = Ext.get(el);
- this.el.unselectable();
+Ext.util.ClickRepeater = Ext.extend(Ext.util.Observable, {
+
+ constructor : function(el, config){
+ this.el = Ext.get(el);
+ this.el.unselectable();
- Ext.apply(this, config);
+ Ext.apply(this, config);
- this.addEvents(
-
+ this.addEvents(
+
"mousedown",
-
+
"click",
-
+
"mouseup"
- );
-
- if(!this.disabled){
- this.disabled = true;
- this.enable();
- }
+ );
-
- if(this.handler){
- this.on("click", this.handler, this.scope || this);
- }
+ if(!this.disabled){
+ this.disabled = true;
+ this.enable();
+ }
- Ext.util.ClickRepeater.superclass.constructor.call(this);
-};
+
+ if(this.handler){
+ this.on("click", this.handler, this.scope || this);
+ }
-Ext.extend(Ext.util.ClickRepeater, Ext.util.Observable, {
+ Ext.util.ClickRepeater.superclass.constructor.call(this);
+ },
+
interval : 20,
delay: 250,
preventDefault : true,
this.purgeListeners();
},
- handleDblClick : function(){
+ handleDblClick : function(e){
clearTimeout(this.timer);
this.el.blur();
- this.fireEvent("mousedown", this);
- this.fireEvent("click", this);
+ this.fireEvent("mousedown", this, e);
+ this.fireEvent("click", this, e);
},
- handleMouseDown : function(){
+ handleMouseDown : function(e){
clearTimeout(this.timer);
this.el.blur();
if(this.pressClass){
Ext.getDoc().on("mouseup", this.handleMouseUp, this);
this.el.on("mouseout", this.handleMouseOut, this);
- this.fireEvent("mousedown", this);
- this.fireEvent("click", this);
+ this.fireEvent("mousedown", this, e);
+ this.fireEvent("click", this, e);
if (this.accelerate) {
this.delay = 400;
}
- this.timer = this.click.defer(this.delay || this.interval, this);
+ this.timer = this.click.defer(this.delay || this.interval, this, [e]);
},
- click : function(){
- this.fireEvent("click", this);
+ click : function(e){
+ this.fireEvent("click", this, e);
this.timer = this.click.defer(this.accelerate ?
this.easeOutExpo(this.mousedownTime.getElapsed(),
400,
-390,
12000) :
- this.interval, this);
+ this.interval, this, [e]);
},
easeOutExpo : function (t, b, c, d) {
},
- handleMouseUp : function(){
+ handleMouseUp : function(e){
clearTimeout(this.timer);
this.el.un("mouseover", this.handleMouseReturn, this);
this.el.un("mouseout", this.handleMouseOut, this);
Ext.getDoc().un("mouseup", this.handleMouseUp, this);
this.el.removeClass(this.pressClass);
- this.fireEvent("mouseup", this);
+ this.fireEvent("mouseup", this, e);
}
});
Ext.KeyNav = function(el, config){
relay : function(e){
- var k = e.getKey();
- var h = this.keyToHandler[k];
+ var k = e.getKey(),
+ h = this.keyToHandler[k];
if(h && this[h]){
if(this.doRelay(e, this[h], h) !== true){
e[this.defaultEventAction]();
doRelay : function(e, h, hname){
- return h.call(this.scope || this, e);
+ return h.call(this.scope || this, e, hname);
},
if(delay){
this.focusTask = new Ext.util.DelayedTask(this.focus, this, [selectText, false]);
this.focusTask.delay(Ext.isNumber(delay) ? delay : 10);
- return;
+ return this;
}
if(this.rendered && !this.isDestroyed){
this.el.focus();
},
- findParentByType : function(xtype) {
- return Ext.isFunction(xtype) ?
- this.findParentBy(function(p){
- return p.constructor === xtype;
- }) :
- this.findParentBy(function(p){
- return p.constructor.xtype === xtype;
- });
+ findParentByType : function(xtype, shallow){
+ return this.findParentBy(function(c){
+ return c.isXType(xtype, shallow);
+ });
+ },
+
+
+ bubble : function(fn, scope, args){
+ var p = this;
+ while(p){
+ if(fn.apply(scope || p, args || [p]) === false){
+ break;
+ }
+ p = p.ownerCt;
+ }
+ return this;
},
});
Ext.reg('component', Ext.Component);
+
Ext.Action = Ext.extend(Object, {
(function(){
Ext.Layer = function(config, existingEl){
config = config || {};
- var dh = Ext.DomHelper;
- var cp = config.parentEl, pel = cp ? Ext.getDom(cp) : document.body;
- if(existingEl){
+ var dh = Ext.DomHelper,
+ cp = config.parentEl, pel = cp ? Ext.getDom(cp) : document.body;
+
+ if (existingEl) {
this.dom = Ext.getDom(existingEl);
}
if(!this.dom){
}
return this;
},
+
+ getConstrainOffset : function(){
+ return this.shadowOffset;
+ },
isVisible : function(){
return this.visible;
});
})();
-Ext.Shadow = function(config){
+Ext.Shadow = function(config) {
Ext.apply(this, config);
- if(typeof this.mode != "string"){
+ if (typeof this.mode != "string") {
this.mode = this.defaultMode;
}
- var o = this.offset, a = {h: 0};
- var rad = Math.floor(this.offset/2);
- switch(this.mode.toLowerCase()){
+ var o = this.offset,
+ a = {
+ h: 0
+ },
+ rad = Math.floor(this.offset / 2);
+ switch (this.mode.toLowerCase()) {
+
case "drop":
a.w = 0;
a.l = a.t = o;
a.t -= 1;
- if(Ext.isIE){
+ if (Ext.isIE) {
a.l -= this.offset + rad;
a.t -= this.offset + rad;
a.w -= rad;
}
break;
case "sides":
- a.w = (o*2);
+ a.w = (o * 2);
a.l = -o;
- a.t = o-1;
- if(Ext.isIE){
+ a.t = o - 1;
+ if (Ext.isIE) {
a.l -= (this.offset - rad);
a.t -= this.offset + rad;
a.l += 1;
- a.w -= (this.offset - rad)*2;
+ a.w -= (this.offset - rad) * 2;
a.w -= rad + 1;
a.h -= 1;
}
break;
case "frame":
- a.w = a.h = (o*2);
+ a.w = a.h = (o * 2);
a.l = a.t = -o;
a.t += 1;
a.h -= 2;
- if(Ext.isIE){
+ if (Ext.isIE) {
a.l -= (this.offset - rad);
a.t -= (this.offset - rad);
a.l += 1;
defaultMode: "drop",
- show : function(target){
+ show: function(target) {
target = Ext.get(target);
- if(!this.el){
+ if (!this.el) {
this.el = Ext.Shadow.Pool.pull();
- if(this.el.dom.nextSibling != target.dom){
+ if (this.el.dom.nextSibling != target.dom) {
this.el.insertBefore(target);
}
}
- this.el.setStyle("z-index", this.zIndex || parseInt(target.getStyle("z-index"), 10)-1);
- if(Ext.isIE){
- this.el.dom.style.filter="progid:DXImageTransform.Microsoft.alpha(opacity=50) progid:DXImageTransform.Microsoft.Blur(pixelradius="+(this.offset)+")";
+ this.el.setStyle("z-index", this.zIndex || parseInt(target.getStyle("z-index"), 10) - 1);
+ if (Ext.isIE) {
+ this.el.dom.style.filter = "progid:DXImageTransform.Microsoft.alpha(opacity=50) progid:DXImageTransform.Microsoft.Blur(pixelradius=" + (this.offset) + ")";
}
this.realign(
- target.getLeft(true),
- target.getTop(true),
- target.getWidth(),
- target.getHeight()
+ target.getLeft(true),
+ target.getTop(true),
+ target.getWidth(),
+ target.getHeight()
);
this.el.dom.style.display = "block";
},
- isVisible : function(){
- return this.el ? true : false;
+ isVisible: function() {
+ return this.el ? true: false;
},
- realign : function(l, t, w, h){
- if(!this.el){
+ realign: function(l, t, w, h) {
+ if (!this.el) {
return;
}
- var a = this.adjusts, d = this.el.dom, s = d.style;
- var iea = 0;
- s.left = (l+a.l)+"px";
- s.top = (t+a.t)+"px";
- var sw = (w+a.w), sh = (h+a.h), sws = sw +"px", shs = sh + "px";
- if(s.width != sws || s.height != shs){
+ var a = this.adjusts,
+ d = this.el.dom,
+ s = d.style,
+ iea = 0,
+ sw = (w + a.w),
+ sh = (h + a.h),
+ sws = sw + "px",
+ shs = sh + "px",
+ cn,
+ sww;
+ s.left = (l + a.l) + "px";
+ s.top = (t + a.t) + "px";
+ if (s.width != sws || s.height != shs) {
s.width = sws;
s.height = shs;
- if(!Ext.isIE){
- var cn = d.childNodes;
- var sww = Math.max(0, (sw-12))+"px";
+ if (!Ext.isIE) {
+ cn = d.childNodes;
+ sww = Math.max(0, (sw - 12)) + "px";
cn[0].childNodes[1].style.width = sww;
cn[1].childNodes[1].style.width = sww;
cn[2].childNodes[1].style.width = sww;
- cn[1].style.height = Math.max(0, (sh-12))+"px";
+ cn[1].style.height = Math.max(0, (sh - 12)) + "px";
}
}
},
- hide : function(){
- if(this.el){
+ hide: function() {
+ if (this.el) {
this.el.dom.style.display = "none";
Ext.Shadow.Pool.push(this.el);
delete this.el;
},
- setZIndex : function(z){
+ setZIndex: function(z) {
this.zIndex = z;
- if(this.el){
+ if (this.el) {
this.el.setStyle("z-index", z);
}
}
};
-Ext.Shadow.Pool = function(){
- var p = [];
- var markup = Ext.isIE ?
- '<div class="x-ie-shadow"></div>' :
- '<div class="x-shadow"><div class="xst"><div class="xstl"></div><div class="xstc"></div><div class="xstr"></div></div><div class="xsc"><div class="xsml"></div><div class="xsmc"></div><div class="xsmr"></div></div><div class="xsb"><div class="xsbl"></div><div class="xsbc"></div><div class="xsbr"></div></div></div>';
+Ext.Shadow.Pool = function() {
+ var p = [],
+ markup = Ext.isIE ?
+ '<div class="x-ie-shadow"></div>':
+ '<div class="x-shadow"><div class="xst"><div class="xstl"></div><div class="xstc"></div><div class="xstr"></div></div><div class="xsc"><div class="xsml"></div><div class="xsmc"></div><div class="xsmr"></div></div><div class="xsb"><div class="xsbl"></div><div class="xsbc"></div><div class="xsbr"></div></div></div>';
return {
- pull : function(){
+ pull: function() {
var sh = p.shift();
- if(!sh){
+ if (!sh) {
sh = Ext.get(Ext.DomHelper.insertHtml("beforeBegin", document.body.firstChild, markup));
sh.autoBoxAdjust = false;
}
return sh;
},
- push : function(sh){
+ push: function(sh) {
p.push(sh);
}
};
this.setLayout(this.layout);
- if(this.activeItem !== undefined){
+ if(this.activeItem !== undefined && this.layout.setActiveItem){
var item = this.activeItem;
delete this.activeItem;
this.layout.setActiveItem(item);
},
- insert : function(index, comp){
+ insert : function(index, comp) {
+ var args = arguments,
+ length = args.length,
+ result = [],
+ i, c;
+
this.initItems();
- var a = arguments, len = a.length;
- if(len > 2){
- var result = [];
- for(var i = len-1; i >= 1; --i) {
- result.push(this.insert(index, a[i]));
+
+ if (length > 2) {
+ for (i = length - 1; i >= 1; --i) {
+ result.push(this.insert(index, args[i]));
}
return result;
}
- var c = this.lookupComponent(this.applyDefaults(comp));
+
+ c = this.lookupComponent(this.applyDefaults(comp));
index = Math.min(index, this.items.length);
- if(this.fireEvent('beforeadd', this, c, index) !== false && this.onBeforeAdd(c) !== false){
- if(c.ownerCt == this){
+
+ if (this.fireEvent('beforeadd', this, c, index) !== false && this.onBeforeAdd(c) !== false) {
+ if (c.ownerCt == this) {
this.items.remove(c);
}
this.items.insert(index, c);
this.onAdd(c);
this.fireEvent('add', this, c, index);
}
+
return c;
},
c = Ext.ComponentMgr.get(c);
Ext.apply(c, d);
}else if(!c.events){
- Ext.applyIf(c, d);
+ Ext.applyIf(c.isAction ? c.initialConfig : c, d);
}else{
Ext.apply(c, d);
}
},
- bubble : function(fn, scope, args){
- var p = this;
- while(p){
- if(fn.apply(scope || p, args || [p]) === false){
- break;
- }
- p = p.ownerCt;
- }
- return this;
- },
-
-
cascade : function(fn, scope, args){
if(fn.apply(scope || this, args || [this]) !== false){
if(this.items){
findById : function(id){
- var m, ct = this;
+ var m = null,
+ ct = this;
this.cascade(function(c){
if(ct != c && c.id === id){
m = c;
return false;
}
});
- return m || null;
+ return m;
},
get : function(key){
- return this.items.get(key);
+ return this.getComponent(key);
}
});
if (c) {
if (!c.rendered) {
c.render(target, position);
- this.configureItem(c, position);
+ this.configureItem(c);
} else if (!this.isValidParent(c, target)) {
if (Ext.isNumber(position)) {
position = target.dom.childNodes[position];
target.dom.insertBefore(c.getPositionEl().dom, position || null);
c.container = target;
- this.configureItem(c, position);
+ this.configureItem(c);
}
}
},
getRenderedItems: function(ct){
var t = ct.getLayoutTarget(), cti = ct.items.items, len = cti.length, i, c, items = [];
for (i = 0; i < len; i++) {
- if((c = cti[i]).rendered && this.isValidParent(c, t)){
+ if((c = cti[i]).rendered && this.isValidParent(c, t) && c.shouldLayout !== false){
items.push(c);
}
};
},
- configureItem: function(c, position){
+ configureItem: function(c){
if (this.extraCls) {
var t = c.getPositionEl ? c.getPositionEl() : c;
t.addClass(this.extraCls);
if(this.resizeTask && this.resizeTask.cancel){
this.resizeTask.cancel();
}
+ if(this.container) {
+ this.container.un(this.container.resizeEvent, this.onResize, this);
+ }
if(!Ext.isEmpty(this.targetCls)){
var target = this.container.getLayoutTarget();
if(target){
parseAnchorRE : /^(r|right|b|bottom)$/i,
+
getLayoutTargetSize : function() {
- var target = this.container.getLayoutTarget();
- if (!target) {
- return {};
+ var target = this.container.getLayoutTarget(), ret = {};
+ if (target) {
+ ret = target.getViewSize();
+
+
+
+
+ if (Ext.isIE && Ext.isStrict && ret.width == 0){
+ ret = target.getStyleSize();
+ }
+ ret.width -= target.getPadding('lr');
+ ret.height -= target.getPadding('tb');
}
-
- return target.getStyleSize();
+ return ret;
},
- onLayout : function(ct, target){
- Ext.layout.AnchorLayout.superclass.onLayout.call(this, ct, target);
- var size = this.getLayoutTargetSize();
-
- var w = size.width, h = size.height;
+ onLayout : function(container, target) {
+ Ext.layout.AnchorLayout.superclass.onLayout.call(this, container, target);
+
+ var size = this.getLayoutTargetSize(),
+ containerWidth = size.width,
+ containerHeight = size.height,
+ overflow = target.getStyle('overflow'),
+ components = this.getRenderedItems(container),
+ len = components.length,
+ boxes = [],
+ box,
+ anchorWidth,
+ anchorHeight,
+ component,
+ anchorSpec,
+ calcWidth,
+ calcHeight,
+ anchorsArray,
+ totalHeight = 0,
+ i,
+ el;
- if(w < 20 && h < 20){
+ if(containerWidth < 20 && containerHeight < 20){
return;
}
- var aw, ah;
- if(ct.anchorSize){
- if(typeof ct.anchorSize == 'number'){
- aw = ct.anchorSize;
- }else{
- aw = ct.anchorSize.width;
- ah = ct.anchorSize.height;
+ if(container.anchorSize) {
+ if(typeof container.anchorSize == 'number') {
+ anchorWidth = container.anchorSize;
+ } else {
+ anchorWidth = container.anchorSize.width;
+ anchorHeight = container.anchorSize.height;
}
- }else{
- aw = ct.initialConfig.width;
- ah = ct.initialConfig.height;
+ } else {
+ anchorWidth = container.initialConfig.width;
+ anchorHeight = container.initialConfig.height;
}
- var cs = this.getRenderedItems(ct), len = cs.length, i, c, a, cw, ch, el, vs, boxes = [];
- for(i = 0; i < len; i++){
- c = cs[i];
- el = c.getPositionEl();
+ for(i = 0; i < len; i++) {
+ component = components[i];
+ el = component.getPositionEl();
- if (!c.anchor && c.items && !Ext.isNumber(c.width) && !(Ext.isIE6 && Ext.isStrict)){
- c.anchor = this.defaultAnchor;
+ if (!component.anchor && component.items && !Ext.isNumber(component.width) && !(Ext.isIE6 && Ext.isStrict)){
+ component.anchor = this.defaultAnchor;
}
- if(c.anchor){
- a = c.anchorSpec;
- if(!a){
- vs = c.anchor.split(' ');
- c.anchorSpec = a = {
- right: this.parseAnchor(vs[0], c.initialConfig.width, aw),
- bottom: this.parseAnchor(vs[1], c.initialConfig.height, ah)
+ if(component.anchor) {
+ anchorSpec = component.anchorSpec;
+
+ if(!anchorSpec){
+ anchorsArray = component.anchor.split(' ');
+ component.anchorSpec = anchorSpec = {
+ right: this.parseAnchor(anchorsArray[0], component.initialConfig.width, anchorWidth),
+ bottom: this.parseAnchor(anchorsArray[1], component.initialConfig.height, anchorHeight)
};
}
- cw = a.right ? this.adjustWidthAnchor(a.right(w) - el.getMargins('lr'), c) : undefined;
- ch = a.bottom ? this.adjustHeightAnchor(a.bottom(h) - el.getMargins('tb'), c) : undefined;
+ calcWidth = anchorSpec.right ? this.adjustWidthAnchor(anchorSpec.right(containerWidth) - el.getMargins('lr'), component) : undefined;
+ calcHeight = anchorSpec.bottom ? this.adjustHeightAnchor(anchorSpec.bottom(containerHeight) - el.getMargins('tb'), component) : undefined;
- if(cw || ch){
+ if(calcWidth || calcHeight) {
boxes.push({
- comp: c,
- width: cw || undefined,
- height: ch || undefined
+ component: component,
+ width: calcWidth || undefined,
+ height: calcHeight || undefined
});
}
}
}
for (i = 0, len = boxes.length; i < len; i++) {
- c = boxes[i];
- c.comp.setSize(c.width, c.height);
+ box = boxes[i];
+ box.component.setSize(box.width, box.height);
+ }
+
+ if (overflow && overflow != 'hidden' && !this.adjustmentPass) {
+ var newTargetSize = this.getLayoutTargetSize();
+ if (newTargetSize.width != size.width || newTargetSize.height != size.height){
+ this.adjustmentPass = true;
+ this.onLayout(container, target);
+ }
}
+
+ delete this.adjustmentPass;
},
- parseAnchor : function(a, start, cstart){
- if(a && a != 'none'){
+ parseAnchor : function(a, start, cstart) {
+ if (a && a != 'none') {
var last;
- if(this.parseAnchorRE.test(a)){
+ if (this.parseAnchorRE.test(a)) {
var diff = cstart - start;
return function(v){
if(v !== last){
last = v;
return v - diff;
}
- }
+ };
- }else if(a.indexOf('%') != -1){
+ } else if(a.indexOf('%') != -1) {
var ratio = parseFloat(a.replace('%', ''))*.01;
return function(v){
if(v !== last){
last = v;
return Math.floor(v*ratio);
}
- }
+ };
- }else{
+ } else {
a = parseInt(a, 10);
- if(!isNaN(a)){
- return function(v){
- if(v !== last){
+ if (!isNaN(a)) {
+ return function(v) {
+ if (v !== last) {
last = v;
return v + a;
}
- }
+ };
}
}
}
if(this.collapseMode == 'mini' && !this.cmargins){
this.cmargins = {left:0,top:0,right:0,bottom:0};
}else{
- this.cmargins = Ext.applyIf(this.cmargins || {},
- pos == 'north' || pos == 'south' ? this.defaultNSCMargins : this.defaultEWCMargins);
+ this.cmargins = Ext.applyIf(this.cmargins || {},
+ pos == 'north' || pos == 'south' ? this.defaultNSCMargins : this.defaultEWCMargins);
+ }
+ }
+};
+
+Ext.layout.BorderLayout.Region.prototype = {
+
+
+
+
+
+
+ collapsible : false,
+
+ split:false,
+
+ floatable: true,
+
+ minWidth:50,
+
+ minHeight:50,
+
+
+ defaultMargins : {left:0,top:0,right:0,bottom:0},
+
+ defaultNSCMargins : {left:5,top:5,right:5,bottom:5},
+
+ defaultEWCMargins : {left:5,top:0,right:5,bottom:0},
+ floatingZIndex: 100,
+
+
+ isCollapsed : false,
+
+
+
+
+
+
+ render : function(ct, p){
+ this.panel = p;
+ p.el.enableDisplayMode();
+ this.targetEl = ct;
+ this.el = p.el;
+
+ var gs = p.getState, ps = this.position;
+ p.getState = function(){
+ return Ext.apply(gs.call(p) || {}, this.state);
+ }.createDelegate(this);
+
+ if(ps != 'center'){
+ p.allowQueuedExpand = false;
+ p.on({
+ beforecollapse: this.beforeCollapse,
+ collapse: this.onCollapse,
+ beforeexpand: this.beforeExpand,
+ expand: this.onExpand,
+ hide: this.onHide,
+ show: this.onShow,
+ scope: this
+ });
+ if(this.collapsible || this.floatable){
+ p.collapseEl = 'el';
+ p.slideAnchor = this.getSlideAnchor();
+ }
+ if(p.tools && p.tools.toggle){
+ p.tools.toggle.addClass('x-tool-collapse-'+ps);
+ p.tools.toggle.addClassOnOver('x-tool-collapse-'+ps+'-over');
+ }
+ }
+ },
+
+
+ getCollapsedEl : function(){
+ if(!this.collapsedEl){
+ if(!this.toolTemplate){
+ var tt = new Ext.Template(
+ '<div class="x-tool x-tool-{id}"> </div>'
+ );
+ tt.disableFormats = true;
+ tt.compile();
+ Ext.layout.BorderLayout.Region.prototype.toolTemplate = tt;
+ }
+ this.collapsedEl = this.targetEl.createChild({
+ cls: "x-layout-collapsed x-layout-collapsed-"+this.position,
+ id: this.panel.id + '-xcollapsed'
+ });
+ this.collapsedEl.enableDisplayMode('block');
+
+ if(this.collapseMode == 'mini'){
+ this.collapsedEl.addClass('x-layout-cmini-'+this.position);
+ this.miniCollapsedEl = this.collapsedEl.createChild({
+ cls: "x-layout-mini x-layout-mini-"+this.position, html: " "
+ });
+ this.miniCollapsedEl.addClassOnOver('x-layout-mini-over');
+ this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
+ this.collapsedEl.on('click', this.onExpandClick, this, {stopEvent:true});
+ }else {
+ if(this.collapsible !== false && !this.hideCollapseTool) {
+ var t = this.expandToolEl = this.toolTemplate.append(
+ this.collapsedEl.dom,
+ {id:'expand-'+this.position}, true);
+ t.addClassOnOver('x-tool-expand-'+this.position+'-over');
+ t.on('click', this.onExpandClick, this, {stopEvent:true});
+ }
+ if(this.floatable !== false || this.titleCollapse){
+ this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
+ this.collapsedEl.on("click", this[this.floatable ? 'collapseClick' : 'onExpandClick'], this);
+ }
+ }
+ }
+ return this.collapsedEl;
+ },
+
+
+ onExpandClick : function(e){
+ if(this.isSlid){
+ this.panel.expand(false);
+ }else{
+ this.panel.expand();
+ }
+ },
+
+
+ onCollapseClick : function(e){
+ this.panel.collapse();
+ },
+
+
+ beforeCollapse : function(p, animate){
+ this.lastAnim = animate;
+ if(this.splitEl){
+ this.splitEl.hide();
+ }
+ this.getCollapsedEl().show();
+ var el = this.panel.getEl();
+ this.originalZIndex = el.getStyle('z-index');
+ el.setStyle('z-index', 100);
+ this.isCollapsed = true;
+ this.layout.layout();
+ },
+
+
+ onCollapse : function(animate){
+ this.panel.el.setStyle('z-index', 1);
+ if(this.lastAnim === false || this.panel.animCollapse === false){
+ this.getCollapsedEl().dom.style.visibility = 'visible';
+ }else{
+ this.getCollapsedEl().slideIn(this.panel.slideAnchor, {duration:.2});
+ }
+ this.state.collapsed = true;
+ this.panel.saveState();
+ },
+
+
+ beforeExpand : function(animate){
+ if(this.isSlid){
+ this.afterSlideIn();
+ }
+ var c = this.getCollapsedEl();
+ this.el.show();
+ if(this.position == 'east' || this.position == 'west'){
+ this.panel.setSize(undefined, c.getHeight());
+ }else{
+ this.panel.setSize(c.getWidth(), undefined);
+ }
+ c.hide();
+ c.dom.style.visibility = 'hidden';
+ this.panel.el.setStyle('z-index', this.floatingZIndex);
+ },
+
+
+ onExpand : function(){
+ this.isCollapsed = false;
+ if(this.splitEl){
+ this.splitEl.show();
+ }
+ this.layout.layout();
+ this.panel.el.setStyle('z-index', this.originalZIndex);
+ this.state.collapsed = false;
+ this.panel.saveState();
+ },
+
+
+ collapseClick : function(e){
+ if(this.isSlid){
+ e.stopPropagation();
+ this.slideIn();
+ }else{
+ e.stopPropagation();
+ this.slideOut();
+ }
+ },
+
+
+ onHide : function(){
+ if(this.isCollapsed){
+ this.getCollapsedEl().hide();
+ }else if(this.splitEl){
+ this.splitEl.hide();
+ }
+ },
+
+
+ onShow : function(){
+ if(this.isCollapsed){
+ this.getCollapsedEl().show();
+ }else if(this.splitEl){
+ this.splitEl.show();
+ }
+ },
+
+
+ isVisible : function(){
+ return !this.panel.hidden;
+ },
+
+
+ getMargins : function(){
+ return this.isCollapsed && this.cmargins ? this.cmargins : this.margins;
+ },
+
+
+ getSize : function(){
+ return this.isCollapsed ? this.getCollapsedEl().getSize() : this.panel.getSize();
+ },
+
+
+ setPanel : function(panel){
+ this.panel = panel;
+ },
+
+
+ getMinWidth: function(){
+ return this.minWidth;
+ },
+
+
+ getMinHeight: function(){
+ return this.minHeight;
+ },
+
+
+ applyLayoutCollapsed : function(box){
+ var ce = this.getCollapsedEl();
+ ce.setLeftTop(box.x, box.y);
+ ce.setSize(box.width, box.height);
+ },
+
+
+ applyLayout : function(box){
+ if(this.isCollapsed){
+ this.applyLayoutCollapsed(box);
+ }else{
+ this.panel.setPosition(box.x, box.y);
+ this.panel.setSize(box.width, box.height);
+ }
+ },
+
+
+ beforeSlide: function(){
+ this.panel.beforeEffect();
+ },
+
+
+ afterSlide : function(){
+ this.panel.afterEffect();
+ },
+
+
+ initAutoHide : function(){
+ if(this.autoHide !== false){
+ if(!this.autoHideHd){
+ this.autoHideSlideTask = new Ext.util.DelayedTask(this.slideIn, this);
+ this.autoHideHd = {
+ "mouseout": function(e){
+ if(!e.within(this.el, true)){
+ this.autoHideSlideTask.delay(500);
+ }
+ },
+ "mouseover" : function(e){
+ this.autoHideSlideTask.cancel();
+ },
+ scope : this
+ };
+ }
+ this.el.on(this.autoHideHd);
+ this.collapsedEl.on(this.autoHideHd);
+ }
+ },
+
+
+ clearAutoHide : function(){
+ if(this.autoHide !== false){
+ this.el.un("mouseout", this.autoHideHd.mouseout);
+ this.el.un("mouseover", this.autoHideHd.mouseover);
+ this.collapsedEl.un("mouseout", this.autoHideHd.mouseout);
+ this.collapsedEl.un("mouseover", this.autoHideHd.mouseover);
+ }
+ },
+
+
+ clearMonitor : function(){
+ Ext.getDoc().un("click", this.slideInIf, this);
+ },
+
+
+ slideOut : function(){
+ if(this.isSlid || this.el.hasActiveFx()){
+ return;
+ }
+ this.isSlid = true;
+ var ts = this.panel.tools, dh, pc;
+ if(ts && ts.toggle){
+ ts.toggle.hide();
+ }
+ this.el.show();
+
+
+ pc = this.panel.collapsed;
+ this.panel.collapsed = false;
+
+ if(this.position == 'east' || this.position == 'west'){
+
+ dh = this.panel.deferHeight;
+ this.panel.deferHeight = false;
+
+ this.panel.setSize(undefined, this.collapsedEl.getHeight());
+
+
+ this.panel.deferHeight = dh;
+ }else{
+ this.panel.setSize(this.collapsedEl.getWidth(), undefined);
+ }
+
+
+ this.panel.collapsed = pc;
+
+ this.restoreLT = [this.el.dom.style.left, this.el.dom.style.top];
+ this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
+ this.el.setStyle("z-index", this.floatingZIndex+2);
+ this.panel.el.replaceClass('x-panel-collapsed', 'x-panel-floating');
+ if(this.animFloat !== false){
+ this.beforeSlide();
+ this.el.slideIn(this.getSlideAnchor(), {
+ callback: function(){
+ this.afterSlide();
+ this.initAutoHide();
+ Ext.getDoc().on("click", this.slideInIf, this);
+ },
+ scope: this,
+ block: true
+ });
+ }else{
+ this.initAutoHide();
+ Ext.getDoc().on("click", this.slideInIf, this);
+ }
+ },
+
+
+ afterSlideIn : function(){
+ this.clearAutoHide();
+ this.isSlid = false;
+ this.clearMonitor();
+ this.el.setStyle("z-index", "");
+ this.panel.el.replaceClass('x-panel-floating', 'x-panel-collapsed');
+ this.el.dom.style.left = this.restoreLT[0];
+ this.el.dom.style.top = this.restoreLT[1];
+
+ var ts = this.panel.tools;
+ if(ts && ts.toggle){
+ ts.toggle.show();
+ }
+ },
+
+
+ slideIn : function(cb){
+ if(!this.isSlid || this.el.hasActiveFx()){
+ Ext.callback(cb);
+ return;
+ }
+ this.isSlid = false;
+ if(this.animFloat !== false){
+ this.beforeSlide();
+ this.el.slideOut(this.getSlideAnchor(), {
+ callback: function(){
+ this.el.hide();
+ this.afterSlide();
+ this.afterSlideIn();
+ Ext.callback(cb);
+ },
+ scope: this,
+ block: true
+ });
+ }else{
+ this.el.hide();
+ this.afterSlideIn();
}
- }
-};
+ },
-Ext.layout.BorderLayout.Region.prototype = {
-
-
-
-
+ slideInIf : function(e){
+ if(!e.within(this.el)){
+ this.slideIn();
+ }
+ },
+
- collapsible : false,
+ anchors : {
+ "west" : "left",
+ "east" : "right",
+ "north" : "top",
+ "south" : "bottom"
+ },
+
- split:false,
+ sanchors : {
+ "west" : "l",
+ "east" : "r",
+ "north" : "t",
+ "south" : "b"
+ },
+
- floatable: true,
+ canchors : {
+ "west" : "tl-tr",
+ "east" : "tr-tl",
+ "north" : "tl-bl",
+ "south" : "bl-tl"
+ },
+
- minWidth:50,
+ getAnchor : function(){
+ return this.anchors[this.position];
+ },
+
- minHeight:50,
+ getCollapseAnchor : function(){
+ return this.canchors[this.position];
+ },
- defaultMargins : {left:0,top:0,right:0,bottom:0},
+ getSlideAnchor : function(){
+ return this.sanchors[this.position];
+ },
+
- defaultNSCMargins : {left:5,top:5,right:5,bottom:5},
+ getAlignAdj : function(){
+ var cm = this.cmargins;
+ switch(this.position){
+ case "west":
+ return [0, 0];
+ break;
+ case "east":
+ return [0, 0];
+ break;
+ case "north":
+ return [0, 0];
+ break;
+ case "south":
+ return [0, 0];
+ break;
+ }
+ },
+
- defaultEWCMargins : {left:5,top:0,right:5,bottom:0},
- floatingZIndex: 100,
+ getExpandAdj : function(){
+ var c = this.collapsedEl, cm = this.cmargins;
+ switch(this.position){
+ case "west":
+ return [-(cm.right+c.getWidth()+cm.left), 0];
+ break;
+ case "east":
+ return [cm.right+c.getWidth()+cm.left, 0];
+ break;
+ case "north":
+ return [0, -(cm.top+cm.bottom+c.getHeight())];
+ break;
+ case "south":
+ return [0, cm.top+cm.bottom+c.getHeight()];
+ break;
+ }
+ },
+
+ destroy : function(){
+ if (this.autoHideSlideTask && this.autoHideSlideTask.cancel){
+ this.autoHideSlideTask.cancel();
+ }
+ Ext.destroyMembers(this, 'miniCollapsedEl', 'collapsedEl', 'expandToolEl');
+ }
+};
+
+Ext.layout.BorderLayout.SplitRegion = function(layout, config, pos){
+ Ext.layout.BorderLayout.SplitRegion.superclass.constructor.call(this, layout, config, pos);
- isCollapsed : false,
+ this.applyLayout = this.applyFns[pos];
+};
+Ext.extend(Ext.layout.BorderLayout.SplitRegion, Ext.layout.BorderLayout.Region, {
+ splitTip : "Drag to resize.",
-
+ collapsibleSplitTip : "Drag to resize. Double click to hide.",
- render : function(ct, p){
- this.panel = p;
- p.el.enableDisplayMode();
- this.targetEl = ct;
- this.el = p.el;
+ useSplitTips : false,
- var gs = p.getState, ps = this.position;
- p.getState = function(){
- return Ext.apply(gs.call(p) || {}, this.state);
- }.createDelegate(this);
+
+ splitSettings : {
+ north : {
+ orientation: Ext.SplitBar.VERTICAL,
+ placement: Ext.SplitBar.TOP,
+ maxFn : 'getVMaxSize',
+ minProp: 'minHeight',
+ maxProp: 'maxHeight'
+ },
+ south : {
+ orientation: Ext.SplitBar.VERTICAL,
+ placement: Ext.SplitBar.BOTTOM,
+ maxFn : 'getVMaxSize',
+ minProp: 'minHeight',
+ maxProp: 'maxHeight'
+ },
+ east : {
+ orientation: Ext.SplitBar.HORIZONTAL,
+ placement: Ext.SplitBar.RIGHT,
+ maxFn : 'getHMaxSize',
+ minProp: 'minWidth',
+ maxProp: 'maxWidth'
+ },
+ west : {
+ orientation: Ext.SplitBar.HORIZONTAL,
+ placement: Ext.SplitBar.LEFT,
+ maxFn : 'getHMaxSize',
+ minProp: 'minWidth',
+ maxProp: 'maxWidth'
+ }
+ },
- if(ps != 'center'){
- p.allowQueuedExpand = false;
- p.on({
- beforecollapse: this.beforeCollapse,
- collapse: this.onCollapse,
- beforeexpand: this.beforeExpand,
- expand: this.onExpand,
- hide: this.onHide,
- show: this.onShow,
- scope: this
- });
- if(this.collapsible || this.floatable){
- p.collapseEl = 'el';
- p.slideAnchor = this.getSlideAnchor();
+
+ applyFns : {
+ west : function(box){
+ if(this.isCollapsed){
+ return this.applyLayoutCollapsed(box);
}
- if(p.tools && p.tools.toggle){
- p.tools.toggle.addClass('x-tool-collapse-'+ps);
- p.tools.toggle.addClassOnOver('x-tool-collapse-'+ps+'-over');
+ var sd = this.splitEl.dom, s = sd.style;
+ this.panel.setPosition(box.x, box.y);
+ var sw = sd.offsetWidth;
+ s.left = (box.x+box.width-sw)+'px';
+ s.top = (box.y)+'px';
+ s.height = Math.max(0, box.height)+'px';
+ this.panel.setSize(box.width-sw, box.height);
+ },
+ east : function(box){
+ if(this.isCollapsed){
+ return this.applyLayoutCollapsed(box);
+ }
+ var sd = this.splitEl.dom, s = sd.style;
+ var sw = sd.offsetWidth;
+ this.panel.setPosition(box.x+sw, box.y);
+ s.left = (box.x)+'px';
+ s.top = (box.y)+'px';
+ s.height = Math.max(0, box.height)+'px';
+ this.panel.setSize(box.width-sw, box.height);
+ },
+ north : function(box){
+ if(this.isCollapsed){
+ return this.applyLayoutCollapsed(box);
+ }
+ var sd = this.splitEl.dom, s = sd.style;
+ var sh = sd.offsetHeight;
+ this.panel.setPosition(box.x, box.y);
+ s.left = (box.x)+'px';
+ s.top = (box.y+box.height-sh)+'px';
+ s.width = Math.max(0, box.width)+'px';
+ this.panel.setSize(box.width, box.height-sh);
+ },
+ south : function(box){
+ if(this.isCollapsed){
+ return this.applyLayoutCollapsed(box);
}
+ var sd = this.splitEl.dom, s = sd.style;
+ var sh = sd.offsetHeight;
+ this.panel.setPosition(box.x, box.y+sh);
+ s.left = (box.x)+'px';
+ s.top = (box.y)+'px';
+ s.width = Math.max(0, box.width)+'px';
+ this.panel.setSize(box.width, box.height-sh);
}
},
- getCollapsedEl : function(){
- if(!this.collapsedEl){
- if(!this.toolTemplate){
- var tt = new Ext.Template(
- '<div class="x-tool x-tool-{id}"> </div>'
- );
- tt.disableFormats = true;
- tt.compile();
- Ext.layout.BorderLayout.Region.prototype.toolTemplate = tt;
- }
- this.collapsedEl = this.targetEl.createChild({
- cls: "x-layout-collapsed x-layout-collapsed-"+this.position,
- id: this.panel.id + '-xcollapsed'
+ render : function(ct, p){
+ Ext.layout.BorderLayout.SplitRegion.superclass.render.call(this, ct, p);
+
+ var ps = this.position;
+
+ this.splitEl = ct.createChild({
+ cls: "x-layout-split x-layout-split-"+ps, html: " ",
+ id: this.panel.id + '-xsplit'
+ });
+
+ if(this.collapseMode == 'mini'){
+ this.miniSplitEl = this.splitEl.createChild({
+ cls: "x-layout-mini x-layout-mini-"+ps, html: " "
});
- this.collapsedEl.enableDisplayMode('block');
+ this.miniSplitEl.addClassOnOver('x-layout-mini-over');
+ this.miniSplitEl.on('click', this.onCollapseClick, this, {stopEvent:true});
+ }
- if(this.collapseMode == 'mini'){
- this.collapsedEl.addClass('x-layout-cmini-'+this.position);
- this.miniCollapsedEl = this.collapsedEl.createChild({
- cls: "x-layout-mini x-layout-mini-"+this.position, html: " "
- });
- this.miniCollapsedEl.addClassOnOver('x-layout-mini-over');
- this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
- this.collapsedEl.on('click', this.onExpandClick, this, {stopEvent:true});
- }else {
- if(this.collapsible !== false && !this.hideCollapseTool) {
- var t = this.toolTemplate.append(
- this.collapsedEl.dom,
- {id:'expand-'+this.position}, true);
- t.addClassOnOver('x-tool-expand-'+this.position+'-over');
- t.on('click', this.onExpandClick, this, {stopEvent:true});
- }
- if(this.floatable !== false || this.titleCollapse){
- this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
- this.collapsedEl.on("click", this[this.floatable ? 'collapseClick' : 'onExpandClick'], this);
- }
- }
+ var s = this.splitSettings[ps];
+
+ this.split = new Ext.SplitBar(this.splitEl.dom, p.el, s.orientation);
+ this.split.tickSize = this.tickSize;
+ this.split.placement = s.placement;
+ this.split.getMaximumSize = this[s.maxFn].createDelegate(this);
+ this.split.minSize = this.minSize || this[s.minProp];
+ this.split.on("beforeapply", this.onSplitMove, this);
+ this.split.useShim = this.useShim === true;
+ this.maxSize = this.maxSize || this[s.maxProp];
+
+ if(p.hidden){
+ this.splitEl.hide();
+ }
+
+ if(this.useSplitTips){
+ this.splitEl.dom.title = this.collapsible ? this.collapsibleSplitTip : this.splitTip;
+ }
+ if(this.collapsible){
+ this.splitEl.on("dblclick", this.onCollapseClick, this);
}
- return this.collapsedEl;
},
- onExpandClick : function(e){
- if(this.isSlid){
- this.panel.expand(false);
+ getSize : function(){
+ if(this.isCollapsed){
+ return this.collapsedEl.getSize();
+ }
+ var s = this.panel.getSize();
+ if(this.position == 'north' || this.position == 'south'){
+ s.height += this.splitEl.dom.offsetHeight;
}else{
- this.panel.expand();
+ s.width += this.splitEl.dom.offsetWidth;
}
+ return s;
},
- onCollapseClick : function(e){
- this.panel.collapse();
+ getHMaxSize : function(){
+ var cmax = this.maxSize || 10000;
+ var center = this.layout.center;
+ return Math.min(cmax, (this.el.getWidth()+center.el.getWidth())-center.getMinWidth());
},
- beforeCollapse : function(p, animate){
- this.lastAnim = animate;
- if(this.splitEl){
- this.splitEl.hide();
- }
- this.getCollapsedEl().show();
- var el = this.panel.getEl();
- this.originalZIndex = el.getStyle('z-index');
- el.setStyle('z-index', 100);
- this.isCollapsed = true;
- this.layout.layout();
+ getVMaxSize : function(){
+ var cmax = this.maxSize || 10000;
+ var center = this.layout.center;
+ return Math.min(cmax, (this.el.getHeight()+center.el.getHeight())-center.getMinHeight());
},
- onCollapse : function(animate){
- this.panel.el.setStyle('z-index', 1);
- if(this.lastAnim === false || this.panel.animCollapse === false){
- this.getCollapsedEl().dom.style.visibility = 'visible';
+ onSplitMove : function(split, newSize){
+ var s = this.panel.getSize();
+ this.lastSplitSize = newSize;
+ if(this.position == 'north' || this.position == 'south'){
+ this.panel.setSize(s.width, newSize);
+ this.state.height = newSize;
}else{
- this.getCollapsedEl().slideIn(this.panel.slideAnchor, {duration:.2});
+ this.panel.setSize(newSize, s.height);
+ this.state.width = newSize;
}
- this.state.collapsed = true;
+ this.layout.layout();
this.panel.saveState();
+ return false;
},
- beforeExpand : function(animate){
- if(this.isSlid){
- this.afterSlideIn();
+ getSplitBar : function(){
+ return this.split;
+ },
+
+
+ destroy : function() {
+ Ext.destroy(this.miniSplitEl, this.split, this.splitEl);
+ Ext.layout.BorderLayout.SplitRegion.superclass.destroy.call(this);
+ }
+});
+
+Ext.Container.LAYOUTS['border'] = Ext.layout.BorderLayout;
+
+Ext.layout.FormLayout = Ext.extend(Ext.layout.AnchorLayout, {
+
+
+ labelSeparator : ':',
+
+
+
+
+ trackLabels: true,
+
+ type: 'form',
+
+ onRemove: function(c){
+ Ext.layout.FormLayout.superclass.onRemove.call(this, c);
+ if(this.trackLabels){
+ c.un('show', this.onFieldShow, this);
+ c.un('hide', this.onFieldHide, this);
}
- var c = this.getCollapsedEl();
- this.el.show();
- if(this.position == 'east' || this.position == 'west'){
- this.panel.setSize(undefined, c.getHeight());
+
+ var el = c.getPositionEl(),
+ ct = c.getItemCt && c.getItemCt();
+ if (c.rendered && ct) {
+ if (el && el.dom) {
+ el.insertAfter(ct);
+ }
+ Ext.destroy(ct);
+ Ext.destroyMembers(c, 'label', 'itemCt');
+ if (c.customItemCt) {
+ Ext.destroyMembers(c, 'getItemCt', 'customItemCt');
+ }
+ }
+ },
+
+
+ setContainer : function(ct){
+ Ext.layout.FormLayout.superclass.setContainer.call(this, ct);
+ if(ct.labelAlign){
+ ct.addClass('x-form-label-'+ct.labelAlign);
+ }
+
+ if(ct.hideLabels){
+ Ext.apply(this, {
+ labelStyle: 'display:none',
+ elementStyle: 'padding-left:0;',
+ labelAdjust: 0
+ });
}else{
- this.panel.setSize(c.getWidth(), undefined);
+ this.labelSeparator = Ext.isDefined(ct.labelSeparator) ? ct.labelSeparator : this.labelSeparator;
+ ct.labelWidth = ct.labelWidth || 100;
+ if(Ext.isNumber(ct.labelWidth)){
+ var pad = Ext.isNumber(ct.labelPad) ? ct.labelPad : 5;
+ Ext.apply(this, {
+ labelAdjust: ct.labelWidth + pad,
+ labelStyle: 'width:' + ct.labelWidth + 'px;',
+ elementStyle: 'padding-left:' + (ct.labelWidth + pad) + 'px'
+ });
+ }
+ if(ct.labelAlign == 'top'){
+ Ext.apply(this, {
+ labelStyle: 'width:auto;',
+ labelAdjust: 0,
+ elementStyle: 'padding-left:0;'
+ });
+ }
}
- c.hide();
- c.dom.style.visibility = 'hidden';
- this.panel.el.setStyle('z-index', this.floatingZIndex);
},
- onExpand : function(){
- this.isCollapsed = false;
- if(this.splitEl){
- this.splitEl.show();
+ isHide: function(c){
+ return c.hideLabel || this.container.hideLabels;
+ },
+
+ onFieldShow: function(c){
+ c.getItemCt().removeClass('x-hide-' + c.hideMode);
+
+
+ if (c.isComposite) {
+ c.doLayout();
}
- this.layout.layout();
- this.panel.el.setStyle('z-index', this.originalZIndex);
- this.state.collapsed = false;
- this.panel.saveState();
+ },
+
+ onFieldHide: function(c){
+ c.getItemCt().addClass('x-hide-' + c.hideMode);
},
- collapseClick : function(e){
- if(this.isSlid){
- e.stopPropagation();
- this.slideIn();
- }else{
- e.stopPropagation();
- this.slideOut();
+ getLabelStyle: function(s){
+ var ls = '', items = [this.labelStyle, s];
+ for (var i = 0, len = items.length; i < len; ++i){
+ if (items[i]){
+ ls += items[i];
+ if (ls.substr(-1, 1) != ';'){
+ ls += ';';
+ }
+ }
}
+ return ls;
},
- onHide : function(){
- if(this.isCollapsed){
- this.getCollapsedEl().hide();
- }else if(this.splitEl){
- this.splitEl.hide();
+
+
+ renderItem : function(c, position, target){
+ if(c && (c.isFormField || c.fieldLabel) && c.inputType != 'hidden'){
+ var args = this.getTemplateArgs(c);
+ if(Ext.isNumber(position)){
+ position = target.dom.childNodes[position] || null;
+ }
+ if(position){
+ c.itemCt = this.fieldTpl.insertBefore(position, args, true);
+ }else{
+ c.itemCt = this.fieldTpl.append(target, args, true);
+ }
+ if(!c.getItemCt){
+
+
+ Ext.apply(c, {
+ getItemCt: function(){
+ return c.itemCt;
+ },
+ customItemCt: true
+ });
+ }
+ c.label = c.getItemCt().child('label.x-form-item-label');
+ if(!c.rendered){
+ c.render('x-form-el-' + c.id);
+ }else if(!this.isValidParent(c, target)){
+ Ext.fly('x-form-el-' + c.id).appendChild(c.getPositionEl());
+ }
+ if(this.trackLabels){
+ if(c.hidden){
+ this.onFieldHide(c);
+ }
+ c.on({
+ scope: this,
+ show: this.onFieldShow,
+ hide: this.onFieldHide
+ });
+ }
+ this.configureItem(c);
+ }else {
+ Ext.layout.FormLayout.superclass.renderItem.apply(this, arguments);
}
},
- onShow : function(){
- if(this.isCollapsed){
- this.getCollapsedEl().show();
- }else if(this.splitEl){
- this.splitEl.show();
- }
- },
+ getTemplateArgs: function(field) {
+ var noLabelSep = !field.fieldLabel || field.hideLabel;
-
- isVisible : function(){
- return !this.panel.hidden;
+ return {
+ id : field.id,
+ label : field.fieldLabel,
+ itemCls : (field.itemCls || this.container.itemCls || '') + (field.hideLabel ? ' x-hide-label' : ''),
+ clearCls : field.clearCls || 'x-form-clear-left',
+ labelStyle : this.getLabelStyle(field.labelStyle),
+ elementStyle : this.elementStyle || '',
+ labelSeparator: noLabelSep ? '' : (Ext.isDefined(field.labelSeparator) ? field.labelSeparator : this.labelSeparator)
+ };
},
- getMargins : function(){
- return this.isCollapsed && this.cmargins ? this.cmargins : this.margins;
+ adjustWidthAnchor: function(value, c){
+ if(c.label && !this.isHide(c) && (this.container.labelAlign != 'top')){
+ var adjust = Ext.isIE6 || (Ext.isIE && !Ext.isStrict);
+ return value - this.labelAdjust + (adjust ? -3 : 0);
+ }
+ return value;
},
-
- getSize : function(){
- return this.isCollapsed ? this.getCollapsedEl().getSize() : this.panel.getSize();
+ adjustHeightAnchor : function(value, c){
+ if(c.label && !this.isHide(c) && (this.container.labelAlign == 'top')){
+ return value - c.label.getHeight();
+ }
+ return value;
},
- setPanel : function(panel){
- this.panel = panel;
- },
+ isValidParent : function(c, target){
+ return target && this.container.getEl().contains(c.getPositionEl());
+ }
- getMinWidth: function(){
- return this.minWidth;
- },
+});
+
+Ext.Container.LAYOUTS['form'] = Ext.layout.FormLayout;
+Ext.layout.AccordionLayout = Ext.extend(Ext.layout.FitLayout, {
- getMinHeight: function(){
- return this.minHeight;
+ fill : true,
+
+ autoWidth : true,
+
+ titleCollapse : true,
+
+ hideCollapseTool : false,
+
+ collapseFirst : false,
+
+ animate : false,
+
+ sequence : false,
+
+ activeOnTop : false,
+
+ type: 'accordion',
+
+ renderItem : function(c){
+ if(this.animate === false){
+ c.animCollapse = false;
+ }
+ c.collapsible = true;
+ if(this.autoWidth){
+ c.autoWidth = true;
+ }
+ if(this.titleCollapse){
+ c.titleCollapse = true;
+ }
+ if(this.hideCollapseTool){
+ c.hideCollapseTool = true;
+ }
+ if(this.collapseFirst !== undefined){
+ c.collapseFirst = this.collapseFirst;
+ }
+ if(!this.activeItem && !c.collapsed){
+ this.setActiveItem(c, true);
+ }else if(this.activeItem && this.activeItem != c){
+ c.collapsed = true;
+ }
+ Ext.layout.AccordionLayout.superclass.renderItem.apply(this, arguments);
+ c.header.addClass('x-accordion-hd');
+ c.on('beforeexpand', this.beforeExpand, this);
},
-
- applyLayoutCollapsed : function(box){
- var ce = this.getCollapsedEl();
- ce.setLeftTop(box.x, box.y);
- ce.setSize(box.width, box.height);
+ onRemove: function(c){
+ Ext.layout.AccordionLayout.superclass.onRemove.call(this, c);
+ if(c.rendered){
+ c.header.removeClass('x-accordion-hd');
+ }
+ c.un('beforeexpand', this.beforeExpand, this);
},
- applyLayout : function(box){
- if(this.isCollapsed){
- this.applyLayoutCollapsed(box);
- }else{
- this.panel.setPosition(box.x, box.y);
- this.panel.setSize(box.width, box.height);
+ beforeExpand : function(p, anim){
+ var ai = this.activeItem;
+ if(ai){
+ if(this.sequence){
+ delete this.activeItem;
+ if (!ai.collapsed){
+ ai.collapse({callback:function(){
+ p.expand(anim || true);
+ }, scope: this});
+ return false;
+ }
+ }else{
+ ai.collapse(this.animate);
+ }
+ }
+ this.setActive(p);
+ if(this.activeOnTop){
+ p.el.dom.parentNode.insertBefore(p.el.dom, p.el.dom.parentNode.firstChild);
}
+
+ this.layout();
},
- beforeSlide: function(){
- this.panel.beforeEffect();
+ setItemSize : function(item, size){
+ if(this.fill && item){
+ var hh = 0, i, ct = this.getRenderedItems(this.container), len = ct.length, p;
+
+ for (i = 0; i < len; i++) {
+ if((p = ct[i]) != item && !p.hidden){
+ hh += p.header.getHeight();
+ }
+ };
+
+ size.height -= hh;
+
+
+ item.setSize(size);
+ }
},
- afterSlide : function(){
- this.panel.afterEffect();
+ setActiveItem : function(item){
+ this.setActive(item, true);
},
- initAutoHide : function(){
- if(this.autoHide !== false){
- if(!this.autoHideHd){
- this.autoHideSlideTask = new Ext.util.DelayedTask(this.slideIn, this);
- this.autoHideHd = {
- "mouseout": function(e){
- if(!e.within(this.el, true)){
- this.autoHideSlideTask.delay(500);
- }
- },
- "mouseover" : function(e){
- this.autoHideSlideTask.cancel();
- },
- scope : this
- };
+ setActive : function(item, expand){
+ var ai = this.activeItem;
+ item = this.container.getComponent(item);
+ if(ai != item){
+ if(item.rendered && item.collapsed && expand){
+ item.expand();
+ }else{
+ if(ai){
+ ai.fireEvent('deactivate', ai);
+ }
+ this.activeItem = item;
+ item.fireEvent('activate', item);
}
- this.el.on(this.autoHideHd);
- this.collapsedEl.on(this.autoHideHd);
}
- },
+ }
+});
+Ext.Container.LAYOUTS.accordion = Ext.layout.AccordionLayout;
-
- clearAutoHide : function(){
- if(this.autoHide !== false){
- this.el.un("mouseout", this.autoHideHd.mouseout);
- this.el.un("mouseover", this.autoHideHd.mouseover);
- this.collapsedEl.un("mouseout", this.autoHideHd.mouseout);
- this.collapsedEl.un("mouseover", this.autoHideHd.mouseover);
- }
- },
+Ext.layout.Accordion = Ext.layout.AccordionLayout;
+Ext.layout.TableLayout = Ext.extend(Ext.layout.ContainerLayout, {
- clearMonitor : function(){
- Ext.getDoc().un("click", this.slideInIf, this);
- },
- slideOut : function(){
- if(this.isSlid || this.el.hasActiveFx()){
- return;
- }
- this.isSlid = true;
- var ts = this.panel.tools, dh, pc;
- if(ts && ts.toggle){
- ts.toggle.hide();
- }
- this.el.show();
+ monitorResize:false,
-
- pc = this.panel.collapsed;
- this.panel.collapsed = false;
+ type: 'table',
- if(this.position == 'east' || this.position == 'west'){
-
- dh = this.panel.deferHeight;
- this.panel.deferHeight = false;
+ targetCls: 'x-table-layout-ct',
- this.panel.setSize(undefined, this.collapsedEl.getHeight());
+
+ tableAttrs:null,
-
- this.panel.deferHeight = dh;
- }else{
- this.panel.setSize(this.collapsedEl.getWidth(), undefined);
- }
+
+ setContainer : function(ct){
+ Ext.layout.TableLayout.superclass.setContainer.call(this, ct);
-
- this.panel.collapsed = pc;
+ this.currentRow = 0;
+ this.currentColumn = 0;
+ this.cells = [];
+ },
+
+
+ onLayout : function(ct, target){
+ var cs = ct.items.items, len = cs.length, c, i;
- this.restoreLT = [this.el.dom.style.left, this.el.dom.style.top];
- this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
- this.el.setStyle("z-index", this.floatingZIndex+2);
- this.panel.el.replaceClass('x-panel-collapsed', 'x-panel-floating');
- if(this.animFloat !== false){
- this.beforeSlide();
- this.el.slideIn(this.getSlideAnchor(), {
- callback: function(){
- this.afterSlide();
- this.initAutoHide();
- Ext.getDoc().on("click", this.slideInIf, this);
- },
- scope: this,
- block: true
- });
- }else{
- this.initAutoHide();
- Ext.getDoc().on("click", this.slideInIf, this);
+ if(!this.table){
+ target.addClass('x-table-layout-ct');
+
+ this.table = target.createChild(
+ Ext.apply({tag:'table', cls:'x-table-layout', cellspacing: 0, cn: {tag: 'tbody'}}, this.tableAttrs), null, true);
}
+ this.renderAll(ct, target);
},
- afterSlideIn : function(){
- this.clearAutoHide();
- this.isSlid = false;
- this.clearMonitor();
- this.el.setStyle("z-index", "");
- this.panel.el.replaceClass('x-panel-floating', 'x-panel-collapsed');
- this.el.dom.style.left = this.restoreLT[0];
- this.el.dom.style.top = this.restoreLT[1];
-
- var ts = this.panel.tools;
- if(ts && ts.toggle){
- ts.toggle.show();
+ getRow : function(index){
+ var row = this.table.tBodies[0].childNodes[index];
+ if(!row){
+ row = document.createElement('tr');
+ this.table.tBodies[0].appendChild(row);
}
+ return row;
},
- slideIn : function(cb){
- if(!this.isSlid || this.el.hasActiveFx()){
- Ext.callback(cb);
- return;
+ getNextCell : function(c){
+ var cell = this.getNextNonSpan(this.currentColumn, this.currentRow);
+ var curCol = this.currentColumn = cell[0], curRow = this.currentRow = cell[1];
+ for(var rowIndex = curRow; rowIndex < curRow + (c.rowspan || 1); rowIndex++){
+ if(!this.cells[rowIndex]){
+ this.cells[rowIndex] = [];
+ }
+ for(var colIndex = curCol; colIndex < curCol + (c.colspan || 1); colIndex++){
+ this.cells[rowIndex][colIndex] = true;
+ }
}
- this.isSlid = false;
- if(this.animFloat !== false){
- this.beforeSlide();
- this.el.slideOut(this.getSlideAnchor(), {
- callback: function(){
- this.el.hide();
- this.afterSlide();
- this.afterSlideIn();
- Ext.callback(cb);
- },
- scope: this,
- block: true
- });
- }else{
- this.el.hide();
- this.afterSlideIn();
+ var td = document.createElement('td');
+ if(c.cellId){
+ td.id = c.cellId;
+ }
+ var cls = 'x-table-layout-cell';
+ if(c.cellCls){
+ cls += ' ' + c.cellCls;
}
+ td.className = cls;
+ if(c.colspan){
+ td.colSpan = c.colspan;
+ }
+ if(c.rowspan){
+ td.rowSpan = c.rowspan;
+ }
+ this.getRow(curRow).appendChild(td);
+ return td;
},
- slideInIf : function(e){
- if(!e.within(this.el)){
- this.slideIn();
+ getNextNonSpan: function(colIndex, rowIndex){
+ var cols = this.columns;
+ while((cols && colIndex >= cols) || (this.cells[rowIndex] && this.cells[rowIndex][colIndex])) {
+ if(cols && colIndex >= cols){
+ rowIndex++;
+ colIndex = 0;
+ }else{
+ colIndex++;
+ }
}
+ return [colIndex, rowIndex];
},
- anchors : {
- "west" : "left",
- "east" : "right",
- "north" : "top",
- "south" : "bottom"
+ renderItem : function(c, position, target){
+
+ if(!this.table){
+ this.table = target.createChild(
+ Ext.apply({tag:'table', cls:'x-table-layout', cellspacing: 0, cn: {tag: 'tbody'}}, this.tableAttrs), null, true);
+ }
+ if(c && !c.rendered){
+ c.render(this.getNextCell(c));
+ this.configureItem(c);
+ }else if(c && !this.isValidParent(c, target)){
+ var container = this.getNextCell(c);
+ container.insertBefore(c.getPositionEl().dom, null);
+ c.container = Ext.get(container);
+ this.configureItem(c);
+ }
},
- sanchors : {
- "west" : "l",
- "east" : "r",
- "north" : "t",
- "south" : "b"
+ isValidParent : function(c, target){
+ return c.getPositionEl().up('table', 5).dom.parentNode === (target.dom || target);
},
-
- canchors : {
- "west" : "tl-tr",
- "east" : "tr-tl",
- "north" : "tl-bl",
- "south" : "bl-tl"
- },
+ destroy: function(){
+ delete this.table;
+ Ext.layout.TableLayout.superclass.destroy.call(this);
+ }
- getAnchor : function(){
- return this.anchors[this.position];
- },
+});
-
- getCollapseAnchor : function(){
- return this.canchors[this.position];
- },
+Ext.Container.LAYOUTS['table'] = Ext.layout.TableLayout;
+Ext.layout.AbsoluteLayout = Ext.extend(Ext.layout.AnchorLayout, {
-
- getSlideAnchor : function(){
- return this.sanchors[this.position];
- },
+ extraCls: 'x-abs-layout-item',
-
- getAlignAdj : function(){
- var cm = this.cmargins;
- switch(this.position){
- case "west":
- return [0, 0];
- break;
- case "east":
- return [0, 0];
- break;
- case "north":
- return [0, 0];
- break;
- case "south":
- return [0, 0];
- break;
- }
+ type: 'absolute',
+
+ onLayout : function(ct, target){
+ target.position();
+ this.paddingLeft = target.getPadding('l');
+ this.paddingTop = target.getPadding('t');
+ Ext.layout.AbsoluteLayout.superclass.onLayout.call(this, ct, target);
},
- getExpandAdj : function(){
- var c = this.collapsedEl, cm = this.cmargins;
- switch(this.position){
- case "west":
- return [-(cm.right+c.getWidth()+cm.left), 0];
- break;
- case "east":
- return [cm.right+c.getWidth()+cm.left, 0];
- break;
- case "north":
- return [0, -(cm.top+cm.bottom+c.getHeight())];
- break;
- case "south":
- return [0, cm.top+cm.bottom+c.getHeight()];
- break;
- }
+ adjustWidthAnchor : function(value, comp){
+ return value ? value - comp.getPosition(true)[0] + this.paddingLeft : value;
},
- destroy : function(){
- if (this.autoHideSlideTask && this.autoHideSlideTask.cancel){
- this.autoHideSlideTask.cancel();
- }
- Ext.destroy(this.miniCollapsedEl, this.collapsedEl);
+
+ adjustHeightAnchor : function(value, comp){
+ return value ? value - comp.getPosition(true)[1] + this.paddingTop : value;
}
-};
-
-
-Ext.layout.BorderLayout.SplitRegion = function(layout, config, pos){
- Ext.layout.BorderLayout.SplitRegion.superclass.constructor.call(this, layout, config, pos);
- this.applyLayout = this.applyFns[pos];
-};
+});
+Ext.Container.LAYOUTS['absolute'] = Ext.layout.AbsoluteLayout;
-Ext.extend(Ext.layout.BorderLayout.SplitRegion, Ext.layout.BorderLayout.Region, {
+Ext.layout.BoxLayout = Ext.extend(Ext.layout.ContainerLayout, {
+ defaultMargins : {left:0,top:0,right:0,bottom:0},
- splitTip : "Drag to resize.",
+ padding : '0',
- collapsibleSplitTip : "Drag to resize. Double click to hide.",
+ pack : 'start',
+
- useSplitTips : false,
+ monitorResize : true,
+ type: 'box',
+ scrollOffset : 0,
+ extraCls : 'x-box-item',
+ targetCls : 'x-box-layout-ct',
+ innerCls : 'x-box-inner',
+
+ constructor : function(config){
+ Ext.layout.BoxLayout.superclass.constructor.call(this, config);
+
+ if (Ext.isString(this.defaultMargins)) {
+ this.defaultMargins = this.parseMargins(this.defaultMargins);
+ }
+
+ var handler = this.overflowHandler;
+
+ if (typeof handler == 'string') {
+ handler = {
+ type: handler
+ };
+ }
+
+ var handlerType = 'none';
+ if (handler && handler.type != undefined) {
+ handlerType = handler.type;
+ }
+
+ var constructor = Ext.layout.boxOverflow[handlerType];
+ if (constructor[this.type]) {
+ constructor = constructor[this.type];
+ }
+
+ this.overflowHandler = new constructor(this, handler);
+ },
- splitSettings : {
- north : {
- orientation: Ext.SplitBar.VERTICAL,
- placement: Ext.SplitBar.TOP,
- maxFn : 'getVMaxSize',
- minProp: 'minHeight',
- maxProp: 'maxHeight'
- },
- south : {
- orientation: Ext.SplitBar.VERTICAL,
- placement: Ext.SplitBar.BOTTOM,
- maxFn : 'getVMaxSize',
- minProp: 'minHeight',
- maxProp: 'maxHeight'
- },
- east : {
- orientation: Ext.SplitBar.HORIZONTAL,
- placement: Ext.SplitBar.RIGHT,
- maxFn : 'getHMaxSize',
- minProp: 'minWidth',
- maxProp: 'maxWidth'
- },
- west : {
- orientation: Ext.SplitBar.HORIZONTAL,
- placement: Ext.SplitBar.LEFT,
- maxFn : 'getHMaxSize',
- minProp: 'minWidth',
- maxProp: 'maxWidth'
+ onLayout: function(container, target) {
+ Ext.layout.BoxLayout.superclass.onLayout.call(this, container, target);
+
+ var tSize = this.getLayoutTargetSize(),
+ items = this.getVisibleItems(container),
+ calcs = this.calculateChildBoxes(items, tSize),
+ boxes = calcs.boxes,
+ meta = calcs.meta;
+
+
+ if (tSize.width > 0) {
+ var handler = this.overflowHandler,
+ method = meta.tooNarrow ? 'handleOverflow' : 'clearOverflow';
+
+ var results = handler[method](calcs, tSize);
+
+ if (results) {
+ if (results.targetSize) {
+ tSize = results.targetSize;
+ }
+
+ if (results.recalculate) {
+ items = this.getVisibleItems(container);
+ calcs = this.calculateChildBoxes(items, tSize);
+ boxes = calcs.boxes;
+ }
+ }
}
+
+
+ this.layoutTargetLastSize = tSize;
+
+
+ this.childBoxCache = calcs;
+
+ this.updateInnerCtSize(tSize, calcs);
+ this.updateChildBoxes(boxes);
+
+
+ this.handleTargetOverflow(tSize, container, target);
},
- applyFns : {
- west : function(box){
- if(this.isCollapsed){
- return this.applyLayoutCollapsed(box);
- }
- var sd = this.splitEl.dom, s = sd.style;
- this.panel.setPosition(box.x, box.y);
- var sw = sd.offsetWidth;
- s.left = (box.x+box.width-sw)+'px';
- s.top = (box.y)+'px';
- s.height = Math.max(0, box.height)+'px';
- this.panel.setSize(box.width-sw, box.height);
- },
- east : function(box){
- if(this.isCollapsed){
- return this.applyLayoutCollapsed(box);
- }
- var sd = this.splitEl.dom, s = sd.style;
- var sw = sd.offsetWidth;
- this.panel.setPosition(box.x+sw, box.y);
- s.left = (box.x)+'px';
- s.top = (box.y)+'px';
- s.height = Math.max(0, box.height)+'px';
- this.panel.setSize(box.width-sw, box.height);
- },
- north : function(box){
- if(this.isCollapsed){
- return this.applyLayoutCollapsed(box);
+ updateChildBoxes: function(boxes) {
+ for (var i = 0, length = boxes.length; i < length; i++) {
+ var box = boxes[i],
+ comp = box.component;
+
+ if (box.dirtySize) {
+ comp.setSize(box.width, box.height);
}
- var sd = this.splitEl.dom, s = sd.style;
- var sh = sd.offsetHeight;
- this.panel.setPosition(box.x, box.y);
- s.left = (box.x)+'px';
- s.top = (box.y+box.height-sh)+'px';
- s.width = Math.max(0, box.width)+'px';
- this.panel.setSize(box.width, box.height-sh);
- },
- south : function(box){
- if(this.isCollapsed){
- return this.applyLayoutCollapsed(box);
+
+ if (isNaN(box.left) || isNaN(box.top)) {
+ continue;
}
- var sd = this.splitEl.dom, s = sd.style;
- var sh = sd.offsetHeight;
- this.panel.setPosition(box.x, box.y+sh);
- s.left = (box.x)+'px';
- s.top = (box.y)+'px';
- s.width = Math.max(0, box.width)+'px';
- this.panel.setSize(box.width, box.height-sh);
+
+ comp.setPosition(box.left, box.top);
}
},
- render : function(ct, p){
- Ext.layout.BorderLayout.SplitRegion.superclass.render.call(this, ct, p);
-
- var ps = this.position;
+ updateInnerCtSize: function(tSize, calcs) {
+ var align = this.align,
+ padding = this.padding,
+ width = tSize.width,
+ height = tSize.height;
+
+ if (this.type == 'hbox') {
+ var innerCtWidth = width,
+ innerCtHeight = calcs.meta.maxHeight + padding.top + padding.bottom;
- this.splitEl = ct.createChild({
- cls: "x-layout-split x-layout-split-"+ps, html: " ",
- id: this.panel.id + '-xsplit'
- });
+ if (align == 'stretch') {
+ innerCtHeight = height;
+ } else if (align == 'middle') {
+ innerCtHeight = Math.max(height, innerCtHeight);
+ }
+ } else {
+ var innerCtHeight = height,
+ innerCtWidth = calcs.meta.maxWidth + padding.left + padding.right;
- if(this.collapseMode == 'mini'){
- this.miniSplitEl = this.splitEl.createChild({
- cls: "x-layout-mini x-layout-mini-"+ps, html: " "
- });
- this.miniSplitEl.addClassOnOver('x-layout-mini-over');
- this.miniSplitEl.on('click', this.onCollapseClick, this, {stopEvent:true});
+ if (align == 'stretch') {
+ innerCtWidth = width;
+ } else if (align == 'center') {
+ innerCtWidth = Math.max(width, innerCtWidth);
+ }
}
- var s = this.splitSettings[ps];
+ this.innerCt.setSize(innerCtWidth || undefined, innerCtHeight || undefined);
+ },
- this.split = new Ext.SplitBar(this.splitEl.dom, p.el, s.orientation);
- this.split.tickSize = this.tickSize;
- this.split.placement = s.placement;
- this.split.getMaximumSize = this[s.maxFn].createDelegate(this);
- this.split.minSize = this.minSize || this[s.minProp];
- this.split.on("beforeapply", this.onSplitMove, this);
- this.split.useShim = this.useShim === true;
- this.maxSize = this.maxSize || this[s.maxProp];
+
+ handleTargetOverflow: function(previousTargetSize, container, target) {
+ var overflow = target.getStyle('overflow');
- if(p.hidden){
- this.splitEl.hide();
+ if (overflow && overflow != 'hidden' &&!this.adjustmentPass) {
+ var newTargetSize = this.getLayoutTargetSize();
+ if (newTargetSize.width != previousTargetSize.width || newTargetSize.height != previousTargetSize.height){
+ this.adjustmentPass = true;
+ this.onLayout(container, target);
+ }
}
- if(this.useSplitTips){
- this.splitEl.dom.title = this.collapsible ? this.collapsibleSplitTip : this.splitTip;
- }
- if(this.collapsible){
- this.splitEl.on("dblclick", this.onCollapseClick, this);
- }
+ delete this.adjustmentPass;
},
- getSize : function(){
- if(this.isCollapsed){
- return this.collapsedEl.getSize();
- }
- var s = this.panel.getSize();
- if(this.position == 'north' || this.position == 'south'){
- s.height += this.splitEl.dom.offsetHeight;
- }else{
- s.width += this.splitEl.dom.offsetWidth;
- }
- return s;
+ isValidParent : function(c, target) {
+ return this.innerCt && c.getPositionEl().dom.parentNode == this.innerCt.dom;
},
- getHMaxSize : function(){
- var cmax = this.maxSize || 10000;
- var center = this.layout.center;
- return Math.min(cmax, (this.el.getWidth()+center.el.getWidth())-center.getMinWidth());
+ getVisibleItems: function(ct) {
+ var ct = ct || this.container,
+ t = ct.getLayoutTarget(),
+ cti = ct.items.items,
+ len = cti.length,
+
+ i, c, items = [];
+
+ for (i = 0; i < len; i++) {
+ if((c = cti[i]).rendered && this.isValidParent(c, t) && c.hidden !== true && c.collapsed !== true && c.shouldLayout !== false){
+ items.push(c);
+ }
+ }
+
+ return items;
},
- getVMaxSize : function(){
- var cmax = this.maxSize || 10000;
- var center = this.layout.center;
- return Math.min(cmax, (this.el.getHeight()+center.el.getHeight())-center.getMinHeight());
+ renderAll : function(ct, target) {
+ if (!this.innerCt) {
+
+ this.innerCt = target.createChild({cls:this.innerCls});
+ this.padding = this.parseMargins(this.padding);
+ }
+ Ext.layout.BoxLayout.superclass.renderAll.call(this, ct, this.innerCt);
},
-
- onSplitMove : function(split, newSize){
- var s = this.panel.getSize();
- this.lastSplitSize = newSize;
- if(this.position == 'north' || this.position == 'south'){
- this.panel.setSize(s.width, newSize);
- this.state.height = newSize;
- }else{
- this.panel.setSize(newSize, s.height);
- this.state.width = newSize;
+ getLayoutTargetSize : function() {
+ var target = this.container.getLayoutTarget(), ret;
+
+ if (target) {
+ ret = target.getViewSize();
+
+
+
+
+ if (Ext.isIE && Ext.isStrict && ret.width == 0){
+ ret = target.getStyleSize();
+ }
+
+ ret.width -= target.getPadding('lr');
+ ret.height -= target.getPadding('tb');
}
- this.layout.layout();
- this.panel.saveState();
- return false;
+
+ return ret;
},
- getSplitBar : function(){
- return this.split;
+ renderItem : function(c) {
+ if(Ext.isString(c.margins)){
+ c.margins = this.parseMargins(c.margins);
+ }else if(!c.margins){
+ c.margins = this.defaultMargins;
+ }
+ Ext.layout.BoxLayout.superclass.renderItem.apply(this, arguments);
},
-
- destroy : function() {
- Ext.destroy(this.miniSplitEl, this.split, this.splitEl);
- Ext.layout.BorderLayout.SplitRegion.superclass.destroy.call(this);
+
+ destroy: function() {
+ Ext.destroy(this.overflowHandler);
+
+ Ext.layout.BoxLayout.superclass.destroy.apply(this, arguments);
}
});
-Ext.Container.LAYOUTS['border'] = Ext.layout.BorderLayout;
-Ext.layout.FormLayout = Ext.extend(Ext.layout.AnchorLayout, {
-
- labelSeparator : ':',
-
+Ext.ns('Ext.layout.boxOverflow');
+
+
+Ext.layout.boxOverflow.None = Ext.extend(Object, {
+ constructor: function(layout, config) {
+ this.layout = layout;
+
+ Ext.apply(this, config || {});
+ },
- trackLabels: false,
+ handleOverflow: Ext.emptyFn,
+
+ clearOverflow: Ext.emptyFn
+});
- type: 'form',
- onRemove: function(c){
- Ext.layout.FormLayout.superclass.onRemove.call(this, c);
- if(this.trackLabels){
- c.un('show', this.onFieldShow, this);
- c.un('hide', this.onFieldHide, this);
- }
+Ext.layout.boxOverflow.none = Ext.layout.boxOverflow.None;
+
+Ext.layout.boxOverflow.Menu = Ext.extend(Ext.layout.boxOverflow.None, {
+
+ afterCls: 'x-strip-right',
+
+
+ noItemsMenuText : '<div class="x-toolbar-no-items">(None)</div>',
+
+ constructor: function(layout) {
+ Ext.layout.boxOverflow.Menu.superclass.constructor.apply(this, arguments);
- var el = c.getPositionEl(),
- ct = c.getItemCt && c.getItemCt();
- if (c.rendered && ct) {
- if (el && el.dom) {
- el.insertAfter(ct);
- }
- Ext.destroy(ct);
- Ext.destroyMembers(c, 'label', 'itemCt');
- if (c.customItemCt) {
- Ext.destroyMembers(c, 'getItemCt', 'customItemCt');
- }
+
+ this.menuItems = [];
+ },
+
+
+ createInnerElements: function() {
+ if (!this.afterCt) {
+ this.afterCt = this.layout.innerCt.insertSibling({cls: this.afterCls}, 'before');
}
},
-
- setContainer : function(ct){
- Ext.layout.FormLayout.superclass.setContainer.call(this, ct);
- if(ct.labelAlign){
- ct.addClass('x-form-label-'+ct.labelAlign);
+
+ clearOverflow: function(calculations, targetSize) {
+ var newWidth = targetSize.width + (this.afterCt ? this.afterCt.getWidth() : 0),
+ items = this.menuItems;
+
+ this.hideTrigger();
+
+ for (var index = 0, length = items.length; index < length; index++) {
+ items.pop().component.show();
}
-
- if(ct.hideLabels){
- Ext.apply(this, {
- labelStyle: 'display:none',
- elementStyle: 'padding-left:0;',
- labelAdjust: 0
- });
- }else{
- this.labelSeparator = ct.labelSeparator || this.labelSeparator;
- ct.labelWidth = ct.labelWidth || 100;
- if(Ext.isNumber(ct.labelWidth)){
- var pad = Ext.isNumber(ct.labelPad) ? ct.labelPad : 5;
- Ext.apply(this, {
- labelAdjust: ct.labelWidth + pad,
- labelStyle: 'width:' + ct.labelWidth + 'px;',
- elementStyle: 'padding-left:' + (ct.labelWidth + pad) + 'px'
- });
- }
- if(ct.labelAlign == 'top'){
- Ext.apply(this, {
- labelStyle: 'width:auto;',
- labelAdjust: 0,
- elementStyle: 'padding-left:0;'
- });
+
+ return {
+ targetSize: {
+ height: targetSize.height,
+ width : newWidth
}
- }
+ };
},
-
- isHide: function(c){
- return c.hideLabel || this.container.hideLabels;
+
+ showTrigger: function() {
+ this.createMenu();
+ this.menuTrigger.show();
+ },
+
+
+ hideTrigger: function() {
+ if (this.menuTrigger != undefined) {
+ this.menuTrigger.hide();
+ }
},
+
+
+ beforeMenuShow: function(menu) {
+ var items = this.menuItems,
+ len = items.length,
+ item,
+ prev;
- onFieldShow: function(c){
- c.getItemCt().removeClass('x-hide-' + c.hideMode);
+ var needsSep = function(group, item){
+ return group.isXType('buttongroup') && !(item instanceof Ext.Toolbar.Separator);
+ };
+
+ this.clearMenu();
+ menu.removeAll();
+
+ for (var i = 0; i < len; i++) {
+ item = items[i].component;
+
+ if (prev && (needsSep(item, prev) || needsSep(prev, item))) {
+ menu.add('-');
+ }
+
+ this.addComponentToMenu(menu, item);
+ prev = item;
+ }
- if (c.isComposite) {
- c.doLayout();
+ if (menu.items.length < 1) {
+ menu.add(this.noItemsMenuText);
}
},
+
+
+ createMenuConfig : function(component, hideOnClick){
+ var config = Ext.apply({}, component.initialConfig),
+ group = component.toggleGroup;
- onFieldHide: function(c){
- c.getItemCt().addClass('x-hide-' + c.hideMode);
- },
+ Ext.copyTo(config, component, [
+ 'iconCls', 'icon', 'itemId', 'disabled', 'handler', 'scope', 'menu'
+ ]);
-
- getLabelStyle: function(s){
- var ls = '', items = [this.labelStyle, s];
- for (var i = 0, len = items.length; i < len; ++i){
- if (items[i]){
- ls += items[i];
- if (ls.substr(-1, 1) != ';'){
- ls += ';';
+ Ext.apply(config, {
+ text : component.overflowText || component.text,
+ hideOnClick: hideOnClick
+ });
+
+ if (group || component.enableToggle) {
+ Ext.apply(config, {
+ group : group,
+ checked: component.pressed,
+ listeners: {
+ checkchange: function(item, checked){
+ component.toggle(checked);
+ }
}
- }
+ });
}
- return ls;
+
+ delete config.ownerCt;
+ delete config.xtype;
+ delete config.id;
+
+ return config;
},
+ addComponentToMenu : function(menu, component) {
+ if (component instanceof Ext.Toolbar.Separator) {
+ menu.add('-');
-
- renderItem : function(c, position, target){
- if(c && (c.isFormField || c.fieldLabel) && c.inputType != 'hidden'){
- var args = this.getTemplateArgs(c);
- if(Ext.isNumber(position)){
- position = target.dom.childNodes[position] || null;
- }
- if(position){
- c.itemCt = this.fieldTpl.insertBefore(position, args, true);
- }else{
- c.itemCt = this.fieldTpl.append(target, args, true);
- }
- if(!c.getItemCt){
-
-
- Ext.apply(c, {
- getItemCt: function(){
- return c.itemCt;
- },
- customItemCt: true
- });
- }
- c.label = c.getItemCt().child('label.x-form-item-label');
- if(!c.rendered){
- c.render('x-form-el-' + c.id);
- }else if(!this.isValidParent(c, target)){
- Ext.fly('x-form-el-' + c.id).appendChild(c.getPositionEl());
- }
- if(this.trackLabels){
- if(c.hidden){
- this.onFieldHide(c);
- }
- c.on({
- scope: this,
- show: this.onFieldShow,
- hide: this.onFieldHide
- });
+ } else if (Ext.isFunction(component.isXType)) {
+ if (component.isXType('splitbutton')) {
+ menu.add(this.createMenuConfig(component, true));
+
+ } else if (component.isXType('button')) {
+ menu.add(this.createMenuConfig(component, !component.menu));
+
+ } else if (component.isXType('buttongroup')) {
+ component.items.each(function(item){
+ this.addComponentToMenu(menu, item);
+ }, this);
}
- this.configureItem(c);
- }else {
- Ext.layout.FormLayout.superclass.renderItem.apply(this, arguments);
}
},
-
- getTemplateArgs: function(field) {
- var noLabelSep = !field.fieldLabel || field.hideLabel;
-
- return {
- id : field.id,
- label : field.fieldLabel,
- itemCls : (field.itemCls || this.container.itemCls || '') + (field.hideLabel ? ' x-hide-label' : ''),
- clearCls : field.clearCls || 'x-form-clear-left',
- labelStyle : this.getLabelStyle(field.labelStyle),
- elementStyle : this.elementStyle || '',
- labelSeparator: noLabelSep ? '' : (Ext.isDefined(field.labelSeparator) ? field.labelSeparator : this.labelSeparator)
- };
- },
-
- adjustWidthAnchor: function(value, c){
- if(c.label && !this.isHide(c) && (this.container.labelAlign != 'top')){
- var adjust = Ext.isIE6 || (Ext.isIE && !Ext.isStrict);
- return value - this.labelAdjust + (adjust ? -3 : 0);
+ clearMenu : function(){
+ var menu = this.moreMenu;
+ if (menu && menu.items) {
+ menu.items.each(function(item){
+ delete item.menu;
+ });
}
- return value;
},
+
+
+ createMenu: function() {
+ if (!this.menuTrigger) {
+ this.createInnerElements();
+
+
+ this.menu = new Ext.menu.Menu({
+ ownerCt : this.layout.container,
+ listeners: {
+ scope: this,
+ beforeshow: this.beforeMenuShow
+ }
+ });
- adjustHeightAnchor : function(value, c){
- if(c.label && !this.isHide(c) && (this.container.labelAlign == 'top')){
- return value - c.label.getHeight();
+
+ this.menuTrigger = new Ext.Button({
+ iconCls : 'x-toolbar-more-icon',
+ cls : 'x-toolbar-more',
+ menu : this.menu,
+ renderTo: this.afterCt
+ });
}
- return value;
},
+
+
+ destroy: function() {
+ Ext.destroy(this.menu, this.menuTrigger);
+ }
+});
+Ext.layout.boxOverflow.menu = Ext.layout.boxOverflow.Menu;
+
+
+
+Ext.layout.boxOverflow.HorizontalMenu = Ext.extend(Ext.layout.boxOverflow.Menu, {
- isValidParent : function(c, target){
- return target && this.container.getEl().contains(c.getPositionEl());
+ constructor: function() {
+ Ext.layout.boxOverflow.HorizontalMenu.superclass.constructor.apply(this, arguments);
+
+ var me = this,
+ layout = me.layout,
+ origFunction = layout.calculateChildBoxes;
+
+ layout.calculateChildBoxes = function(visibleItems, targetSize) {
+ var calcs = origFunction.apply(layout, arguments),
+ meta = calcs.meta,
+ items = me.menuItems;
+
+
+
+ var hiddenWidth = 0;
+ for (var index = 0, length = items.length; index < length; index++) {
+ hiddenWidth += items[index].width;
+ }
+
+ meta.minimumWidth += hiddenWidth;
+ meta.tooNarrow = meta.minimumWidth > targetSize.width;
+
+ return calcs;
+ };
+ },
+
+ handleOverflow: function(calculations, targetSize) {
+ this.showTrigger();
+
+ var newWidth = targetSize.width - this.afterCt.getWidth(),
+ boxes = calculations.boxes,
+ usedWidth = 0,
+ recalculate = false;
+
+
+ for (var index = 0, length = boxes.length; index < length; index++) {
+ usedWidth += boxes[index].width;
+ }
+
+ var spareWidth = newWidth - usedWidth,
+ showCount = 0;
+
+
+ for (var index = 0, length = this.menuItems.length; index < length; index++) {
+ var hidden = this.menuItems[index],
+ comp = hidden.component,
+ width = hidden.width;
+
+ if (width < spareWidth) {
+ comp.show();
+
+ spareWidth -= width;
+ showCount ++;
+ recalculate = true;
+ } else {
+ break;
+ }
+ }
+
+ if (recalculate) {
+ this.menuItems = this.menuItems.slice(showCount);
+ } else {
+ for (var i = boxes.length - 1; i >= 0; i--) {
+ var item = boxes[i].component,
+ right = boxes[i].left + boxes[i].width;
+
+ if (right >= newWidth) {
+ this.menuItems.unshift({
+ component: item,
+ width : boxes[i].width
+ });
+
+ item.hide();
+ } else {
+ break;
+ }
+ }
+ }
+
+ if (this.menuItems.length == 0) {
+ this.hideTrigger();
+ }
+
+ return {
+ targetSize: {
+ height: targetSize.height,
+ width : newWidth
+ },
+ recalculate: recalculate
+ };
}
+});
+Ext.layout.boxOverflow.menu.hbox = Ext.layout.boxOverflow.HorizontalMenu;
+Ext.layout.boxOverflow.Scroller = Ext.extend(Ext.layout.boxOverflow.None, {
+
+ animateScroll: true,
+
+
+ scrollIncrement: 100,
+
+
+ wheelIncrement: 3,
+
+
+ scrollRepeatInterval: 400,
+
+
+ scrollDuration: 0.4,
+
+
+ beforeCls: 'x-strip-left',
-});
-
-Ext.Container.LAYOUTS['form'] = Ext.layout.FormLayout;
-
-Ext.layout.AccordionLayout = Ext.extend(Ext.layout.FitLayout, {
- fill : true,
+ afterCls: 'x-strip-right',
- autoWidth : true,
- titleCollapse : true,
+ scrollerCls: 'x-strip-scroller',
- hideCollapseTool : false,
- collapseFirst : false,
+ beforeScrollerCls: 'x-strip-scroller-left',
- animate : false,
- sequence : false,
+ afterScrollerCls: 'x-strip-scroller-right',
- activeOnTop : false,
-
- type: 'accordion',
+
+ createWheelListener: function() {
+ this.layout.innerCt.on({
+ scope : this,
+ mousewheel: function(e) {
+ e.stopEvent();
- renderItem : function(c){
- if(this.animate === false){
- c.animCollapse = false;
- }
- c.collapsible = true;
- if(this.autoWidth){
- c.autoWidth = true;
- }
- if(this.titleCollapse){
- c.titleCollapse = true;
- }
- if(this.hideCollapseTool){
- c.hideCollapseTool = true;
- }
- if(this.collapseFirst !== undefined){
- c.collapseFirst = this.collapseFirst;
- }
- if(!this.activeItem && !c.collapsed){
- this.setActiveItem(c, true);
- }else if(this.activeItem && this.activeItem != c){
- c.collapsed = true;
- }
- Ext.layout.AccordionLayout.superclass.renderItem.apply(this, arguments);
- c.header.addClass('x-accordion-hd');
- c.on('beforeexpand', this.beforeExpand, this);
+ this.scrollBy(e.getWheelDelta() * this.wheelIncrement * -1, false);
+ }
+ });
},
-
- onRemove: function(c){
- Ext.layout.AccordionLayout.superclass.onRemove.call(this, c);
- if(c.rendered){
- c.header.removeClass('x-accordion-hd');
- }
- c.un('beforeexpand', this.beforeExpand, this);
+
+
+ handleOverflow: function(calculations, targetSize) {
+ this.createInnerElements();
+ this.showScrollers();
},
-
- beforeExpand : function(p, anim){
- var ai = this.activeItem;
- if(ai){
- if(this.sequence){
- delete this.activeItem;
- if (!ai.collapsed){
- ai.collapse({callback:function(){
- p.expand(anim || true);
- }, scope: this});
- return false;
- }
- }else{
- ai.collapse(this.animate);
- }
- }
- this.setActive(p);
- if(this.activeOnTop){
- p.el.dom.parentNode.insertBefore(p.el.dom, p.el.dom.parentNode.firstChild);
- }
+
+ clearOverflow: function() {
+ this.hideScrollers();
+ },
+
+
+ showScrollers: function() {
+ this.createScrollers();
- this.layout();
+ this.beforeScroller.show();
+ this.afterScroller.show();
+
+ this.updateScrollButtons();
},
-
- setItemSize : function(item, size){
- if(this.fill && item){
- var hh = 0, i, ct = this.getRenderedItems(this.container), len = ct.length, p;
+
+ hideScrollers: function() {
+ if (this.beforeScroller != undefined) {
+ this.beforeScroller.hide();
+ this.afterScroller.hide();
+ }
+ },
+
+
+ createScrollers: function() {
+ if (!this.beforeScroller && !this.afterScroller) {
+ var before = this.beforeCt.createChild({
+ cls: String.format("{0} {1} ", this.scrollerCls, this.beforeScrollerCls)
+ });
- for (i = 0; i < len; i++) {
- if((p = ct[i]) != item && !p.hidden){
- hh += p.header.getHeight();
- }
- };
+ var after = this.afterCt.createChild({
+ cls: String.format("{0} {1}", this.scrollerCls, this.afterScrollerCls)
+ });
- size.height -= hh;
+ before.addClassOnOver(this.beforeScrollerCls + '-hover');
+ after.addClassOnOver(this.afterScrollerCls + '-hover');
+ before.setVisibilityMode(Ext.Element.DISPLAY);
+ after.setVisibilityMode(Ext.Element.DISPLAY);
- item.setSize(size);
+ this.beforeRepeater = new Ext.util.ClickRepeater(before, {
+ interval: this.scrollRepeatInterval,
+ handler : this.scrollLeft,
+ scope : this
+ });
+
+ this.afterRepeater = new Ext.util.ClickRepeater(after, {
+ interval: this.scrollRepeatInterval,
+ handler : this.scrollRight,
+ scope : this
+ });
+
+
+ this.beforeScroller = before;
+
+
+ this.afterScroller = after;
}
},
-
- setActiveItem : function(item){
- this.setActive(item, true);
+
+ destroy: function() {
+ Ext.destroy(this.beforeScroller, this.afterScroller, this.beforeRepeater, this.afterRepeater, this.beforeCt, this.afterCt);
},
-
- setActive : function(item, expand){
- var ai = this.activeItem;
- item = this.container.getComponent(item);
- if(ai != item){
- if(item.rendered && item.collapsed && expand){
- item.expand();
- }else{
- if(ai){
- ai.fireEvent('deactivate', ai);
+
+ scrollBy: function(delta, animate) {
+ this.scrollTo(this.getScrollPosition() + delta, animate);
+ },
+
+
+ getItem: function(item) {
+ if (Ext.isString(item)) {
+ item = Ext.getCmp(item);
+ } else if (Ext.isNumber(item)) {
+ item = this.items[item];
+ }
+
+ return item;
+ },
+
+
+ getScrollAnim: function() {
+ return {
+ duration: this.scrollDuration,
+ callback: this.updateScrollButtons,
+ scope : this
+ };
+ },
+
+
+ updateScrollButtons: function() {
+ if (this.beforeScroller == undefined || this.afterScroller == undefined) {
+ return;
+ }
+
+ var beforeMeth = this.atExtremeBefore() ? 'addClass' : 'removeClass',
+ afterMeth = this.atExtremeAfter() ? 'addClass' : 'removeClass',
+ beforeCls = this.beforeScrollerCls + '-disabled',
+ afterCls = this.afterScrollerCls + '-disabled';
+
+ this.beforeScroller[beforeMeth](beforeCls);
+ this.afterScroller[afterMeth](afterCls);
+ this.scrolling = false;
+ },
+
+
+ atExtremeBefore: function() {
+ return this.getScrollPosition() === 0;
+ },
+
+
+ scrollLeft: function(animate) {
+ this.scrollBy(-this.scrollIncrement, animate);
+ },
+
+
+ scrollRight: function(animate) {
+ this.scrollBy(this.scrollIncrement, animate);
+ },
+
+
+ scrollToItem: function(item, animate) {
+ item = this.getItem(item);
+
+ if (item != undefined) {
+ var visibility = this.getItemVisibility(item);
+
+ if (!visibility.fullyVisible) {
+ var box = item.getBox(true, true),
+ newX = box.x;
+
+ if (visibility.hiddenRight) {
+ newX -= (this.layout.innerCt.getWidth() - box.width);
}
- this.activeItem = item;
- item.fireEvent('activate', item);
+
+ this.scrollTo(newX, animate);
}
}
- }
-});
-Ext.Container.LAYOUTS.accordion = Ext.layout.AccordionLayout;
-
-
-Ext.layout.Accordion = Ext.layout.AccordionLayout;
-Ext.layout.TableLayout = Ext.extend(Ext.layout.ContainerLayout, {
+ },
-
- monitorResize:false,
-
- type: 'table',
+ getItemVisibility: function(item) {
+ var box = this.getItem(item).getBox(true, true),
+ itemLeft = box.x,
+ itemRight = box.x + box.width,
+ scrollLeft = this.getScrollPosition(),
+ scrollRight = this.layout.innerCt.getWidth() + scrollLeft;
+
+ return {
+ hiddenLeft : itemLeft < scrollLeft,
+ hiddenRight : itemRight > scrollRight,
+ fullyVisible: itemLeft > scrollLeft && itemRight < scrollRight
+ };
+ }
+});
- targetCls: 'x-table-layout-ct',
+Ext.layout.boxOverflow.scroller = Ext.layout.boxOverflow.Scroller;
-
- tableAttrs:null,
+\r
+Ext.layout.boxOverflow.VerticalScroller = Ext.extend(Ext.layout.boxOverflow.Scroller, {
+ scrollIncrement: 75,
+ wheelIncrement : 2,
- setContainer : function(ct){
- Ext.layout.TableLayout.superclass.setContainer.call(this, ct);
-
- this.currentRow = 0;
- this.currentColumn = 0;
- this.cells = [];
+ handleOverflow: function(calculations, targetSize) {
+ Ext.layout.boxOverflow.VerticalScroller.superclass.handleOverflow.apply(this, arguments);
+
+ return {
+ targetSize: {
+ height: targetSize.height - (this.beforeCt.getHeight() + this.afterCt.getHeight()),
+ width : targetSize.width
+ }
+ };
},
- onLayout : function(ct, target){
- var cs = ct.items.items, len = cs.length, c, i;
-
- if(!this.table){
- target.addClass('x-table-layout-ct');
+ createInnerElements: function() {
+ var target = this.layout.innerCt;
+
+
+
+ if (!this.beforeCt) {
+ this.beforeCt = target.insertSibling({cls: this.beforeCls}, 'before');
+ this.afterCt = target.insertSibling({cls: this.afterCls}, 'after');
- this.table = target.createChild(
- Ext.apply({tag:'table', cls:'x-table-layout', cellspacing: 0, cn: {tag: 'tbody'}}, this.tableAttrs), null, true);
+ this.createWheelListener();
}
- this.renderAll(ct, target);
},
-
- getRow : function(index){
- var row = this.table.tBodies[0].childNodes[index];
- if(!row){
- row = document.createElement('tr');
- this.table.tBodies[0].appendChild(row);
- }
- return row;
- },
-
- getNextCell : function(c){
- var cell = this.getNextNonSpan(this.currentColumn, this.currentRow);
- var curCol = this.currentColumn = cell[0], curRow = this.currentRow = cell[1];
- for(var rowIndex = curRow; rowIndex < curRow + (c.rowspan || 1); rowIndex++){
- if(!this.cells[rowIndex]){
- this.cells[rowIndex] = [];
+ scrollTo: function(position, animate) {
+ var oldPosition = this.getScrollPosition(),
+ newPosition = position.constrain(0, this.getMaxScrollBottom());
+
+ if (newPosition != oldPosition && !this.scrolling) {
+ if (animate == undefined) {
+ animate = this.animateScroll;
}
- for(var colIndex = curCol; colIndex < curCol + (c.colspan || 1); colIndex++){
- this.cells[rowIndex][colIndex] = true;
+
+ this.layout.innerCt.scrollTo('top', newPosition, animate ? this.getScrollAnim() : false);
+
+ if (animate) {
+ this.scrolling = true;
+ } else {
+ this.scrolling = false;
+ this.updateScrollButtons();
}
}
- var td = document.createElement('td');
- if(c.cellId){
- td.id = c.cellId;
- }
- var cls = 'x-table-layout-cell';
- if(c.cellCls){
- cls += ' ' + c.cellCls;
- }
- td.className = cls;
- if(c.colspan){
- td.colSpan = c.colspan;
- }
- if(c.rowspan){
- td.rowSpan = c.rowspan;
- }
- this.getRow(curRow).appendChild(td);
- return td;
},
-
- getNextNonSpan: function(colIndex, rowIndex){
- var cols = this.columns;
- while((cols && colIndex >= cols) || (this.cells[rowIndex] && this.cells[rowIndex][colIndex])) {
- if(cols && colIndex >= cols){
- rowIndex++;
- colIndex = 0;
- }else{
- colIndex++;
- }
- }
- return [colIndex, rowIndex];
+
+ getScrollPosition: function(){
+ return parseInt(this.layout.innerCt.dom.scrollTop, 10) || 0;
},
-
- renderItem : function(c, position, target){
-
- if(!this.table){
- this.table = target.createChild(
- Ext.apply({tag:'table', cls:'x-table-layout', cellspacing: 0, cn: {tag: 'tbody'}}, this.tableAttrs), null, true);
- }
- if(c && !c.rendered){
- c.render(this.getNextCell(c));
- this.configureItem(c, position);
- }else if(c && !this.isValidParent(c, target)){
- var container = this.getNextCell(c);
- container.insertBefore(c.getPositionEl().dom, null);
- c.container = Ext.get(container);
- this.configureItem(c, position);
- }
+
+ getMaxScrollBottom: function() {
+ return this.layout.innerCt.dom.scrollHeight - this.layout.innerCt.getHeight();
},
-
- isValidParent : function(c, target){
- return c.getPositionEl().up('table', 5).dom.parentNode === (target.dom || target);
- }
-
+ atExtremeAfter: function() {
+ return this.getScrollPosition() >= this.getMaxScrollBottom();
+ }
});
-Ext.Container.LAYOUTS['table'] = Ext.layout.TableLayout;
-Ext.layout.AbsoluteLayout = Ext.extend(Ext.layout.AnchorLayout, {
+Ext.layout.boxOverflow.scroller.vbox = Ext.layout.boxOverflow.VerticalScroller;
- extraCls: 'x-abs-layout-item',
- type: 'absolute',
- onLayout : function(ct, target){
- target.position();
- this.paddingLeft = target.getPadding('l');
- this.paddingTop = target.getPadding('t');
- Ext.layout.AbsoluteLayout.superclass.onLayout.call(this, ct, target);
+Ext.layout.boxOverflow.HorizontalScroller = Ext.extend(Ext.layout.boxOverflow.Scroller, {
+ handleOverflow: function(calculations, targetSize) {
+ Ext.layout.boxOverflow.HorizontalScroller.superclass.handleOverflow.apply(this, arguments);
+
+ return {
+ targetSize: {
+ height: targetSize.height,
+ width : targetSize.width - (this.beforeCt.getWidth() + this.afterCt.getWidth())
+ }
+ };
},
-
- adjustWidthAnchor : function(value, comp){
- return value ? value - comp.getPosition(true)[0] + this.paddingLeft : value;
+
+ createInnerElements: function() {
+ var target = this.layout.innerCt;
+
+
+
+ if (!this.beforeCt) {
+ this.afterCt = target.insertSibling({cls: this.afterCls}, 'before');
+ this.beforeCt = target.insertSibling({cls: this.beforeCls}, 'before');
+
+ this.createWheelListener();
+ }
},
-
- adjustHeightAnchor : function(value, comp){
- return value ? value - comp.getPosition(true)[1] + this.paddingTop : value;
- }
+ scrollTo: function(position, animate) {
+ var oldPosition = this.getScrollPosition(),
+ newPosition = position.constrain(0, this.getMaxScrollRight());
+
+ if (newPosition != oldPosition && !this.scrolling) {
+ if (animate == undefined) {
+ animate = this.animateScroll;
+ }
+
+ this.layout.innerCt.scrollTo('left', newPosition, animate ? this.getScrollAnim() : false);
+
+ if (animate) {
+ this.scrolling = true;
+ } else {
+ this.scrolling = false;
+ this.updateScrollButtons();
+ }
+ }
+ },
+
+
+ getScrollPosition: function(){
+ return parseInt(this.layout.innerCt.dom.scrollLeft, 10) || 0;
+ },
+
+
+ getMaxScrollRight: function() {
+ return this.layout.innerCt.dom.scrollWidth - this.layout.innerCt.getWidth();
+ },
+
+
+ atExtremeAfter: function() {
+ return this.getScrollPosition() >= this.getMaxScrollRight();
+ }
});
-Ext.Container.LAYOUTS['absolute'] = Ext.layout.AbsoluteLayout;
-Ext.layout.BoxLayout = Ext.extend(Ext.layout.ContainerLayout, {
+Ext.layout.boxOverflow.scroller.hbox = Ext.layout.boxOverflow.HorizontalScroller;
+Ext.layout.HBoxLayout = Ext.extend(Ext.layout.BoxLayout, {
- defaultMargins : {left:0,top:0,right:0,bottom:0},
+ align: 'top',
+
+ type : 'hbox',
+
- padding : '0',
- pack : 'start',
- monitorResize : true,
- type: 'box',
- scrollOffset : 0,
- extraCls : 'x-box-item',
- targetCls : 'x-box-layout-ct',
- innerCls : 'x-box-inner',
+ calculateChildBoxes: function(visibleItems, targetSize) {
+ var visibleCount = visibleItems.length,
- constructor : function(config){
- Ext.layout.BoxLayout.superclass.constructor.call(this, config);
+ padding = this.padding,
+ topOffset = padding.top,
+ leftOffset = padding.left,
+ paddingVert = topOffset + padding.bottom,
+ paddingHoriz = leftOffset + padding.right,
- if (Ext.isString(this.defaultMargins)) {
- this.defaultMargins = this.parseMargins(this.defaultMargins);
- }
- },
+ width = targetSize.width - this.scrollOffset,
+ height = targetSize.height,
+ availHeight = Math.max(0, height - paddingVert),
-
- onLayout: function(container, target) {
- Ext.layout.BoxLayout.superclass.onLayout.call(this, container, target);
+ isStart = this.pack == 'start',
+ isCenter = this.pack == 'center',
+ isEnd = this.pack == 'end',
- var items = this.getVisibleItems(container),
- tSize = this.getLayoutTargetSize();
+ nonFlexWidth = 0,
+ maxHeight = 0,
+ totalFlex = 0,
+ desiredWidth = 0,
+ minimumWidth = 0,
-
- this.layoutTargetLastSize = tSize;
+
+ boxes = [],
+
+
+ child, childWidth, childHeight, childSize, childMargins, canLayout, i, calcs, flexedWidth,
+ horizMargins, vertMargins, stretchHeight;
- this.childBoxCache = this.calculateChildBoxes(items, tSize);
+ for (i = 0; i < visibleCount; i++) {
+ child = visibleItems[i];
+ childHeight = child.height;
+ childWidth = child.width;
+ canLayout = !child.hasLayout && typeof child.doLayout == 'function';
- this.updateInnerCtSize(tSize, this.childBoxCache);
- this.updateChildBoxes(this.childBoxCache.boxes);
+
+ if (typeof childWidth != 'number') {
-
- this.handleTargetOverflow(tSize, container, target);
- },
+
+ if (child.flex && !childWidth) {
+ totalFlex += child.flex;
-
- updateChildBoxes: function(boxes) {
- for (var i = 0, length = boxes.length; i < length; i++) {
- var box = boxes[i],
- comp = box.component;
+
+ } else {
+
+
+ if (!childWidth && canLayout) {
+ child.doLayout();
+ }
- if (box.dirtySize) {
- comp.setSize(box.width, box.height);
- }
-
- if (isNaN(box.left) || isNaN(box.top)) {
- continue;
+ childSize = child.getSize();
+ childWidth = childSize.width;
+ childHeight = childSize.height;
+ }
}
- comp.setPosition(box.left, box.top);
- }
- },
-
- updateInnerCtSize: Ext.emptyFn,
+ childMargins = child.margins;
+ horizMargins = childMargins.left + childMargins.right;
-
- handleTargetOverflow: function(previousTargetSize, container, target) {
- var overflow = target.getStyle('overflow');
+ nonFlexWidth += horizMargins + (childWidth || 0);
+ desiredWidth += horizMargins + (child.flex ? child.minWidth || 0 : childWidth);
+ minimumWidth += horizMargins + (child.minWidth || childWidth || 0);
- if (overflow && overflow != 'hidden' &&!this.adjustmentPass) {
- var newTargetSize = this.getLayoutTargetSize();
- if (newTargetSize.width != previousTargetSize.width || newTargetSize.height != previousTargetSize.height){
- this.adjustmentPass = true;
- this.onLayout(container, target);
+
+ if (typeof childHeight != 'number') {
+ if (canLayout) {
+ child.doLayout();
+ }
+ childHeight = child.getHeight();
}
+
+ maxHeight = Math.max(maxHeight, childHeight + childMargins.top + childMargins.bottom);
+
+
+ boxes.push({
+ component: child,
+ height : childHeight || undefined,
+ width : childWidth || undefined
+ });
}
+
+ var shortfall = desiredWidth - width,
+ tooNarrow = minimumWidth > width;
+
+
+ var availableWidth = Math.max(0, width - nonFlexWidth - paddingHoriz);
+
+ if (tooNarrow) {
+ for (i = 0; i < visibleCount; i++) {
+ boxes[i].width = visibleItems[i].minWidth || visibleItems[i].width || boxes[i].width;
+ }
+ } else {
+
+
+ if (shortfall > 0) {
+ var minWidths = [];
+
+
+ for (var index = 0, length = visibleCount; index < length; index++) {
+ var item = visibleItems[index],
+ minWidth = item.minWidth || 0;
- delete this.adjustmentPass;
- },
+
+
+ if (item.flex) {
+ boxes[index].width = minWidth;
+ } else {
+ minWidths.push({
+ minWidth : minWidth,
+ available: boxes[index].width - minWidth,
+ index : index
+ });
+ }
+ }
+
+
+ minWidths.sort(function(a, b) {
+ return a.available > b.available ? 1 : -1;
+ });
+
+
+ for (var i = 0, length = minWidths.length; i < length; i++) {
+ var itemIndex = minWidths[i].index;
+
+ if (itemIndex == undefined) {
+ continue;
+ }
+
+ var item = visibleItems[itemIndex],
+ box = boxes[itemIndex],
+ oldWidth = box.width,
+ minWidth = item.minWidth,
+ newWidth = Math.max(minWidth, oldWidth - Math.ceil(shortfall / (length - i))),
+ reduction = oldWidth - newWidth;
+
+ boxes[itemIndex].width = newWidth;
+ shortfall -= reduction;
+ }
+ } else {
+
+ var remainingWidth = availableWidth,
+ remainingFlex = totalFlex;
-
- isValidParent : function(c, target){
- return this.innerCt && c.getPositionEl().dom.parentNode == this.innerCt.dom;
- },
+
+ for (i = 0; i < visibleCount; i++) {
+ child = visibleItems[i];
+ calcs = boxes[i];
-
- getVisibleItems: function(ct) {
- var ct = ct || this.container,
- t = ct.getLayoutTarget(),
- cti = ct.items.items,
- len = cti.length,
+ childMargins = child.margins;
+ vertMargins = childMargins.top + childMargins.bottom;
- i, c, items = [];
+ if (isStart && child.flex && !child.width) {
+ flexedWidth = Math.ceil((child.flex / remainingFlex) * remainingWidth);
+ remainingWidth -= flexedWidth;
+ remainingFlex -= child.flex;
- for (i = 0; i < len; i++) {
- if((c = cti[i]).rendered && this.isValidParent(c, t) && c.hidden !== true && c.collapsed !== true){
- items.push(c);
+ calcs.width = flexedWidth;
+ calcs.dirtySize = true;
+ }
+ }
}
}
-
- return items;
- },
-
-
- renderAll : function(ct, target){
- if(!this.innerCt){
-
-
- this.innerCt = target.createChild({cls:this.innerCls});
- this.padding = this.parseMargins(this.padding);
+
+ if (isCenter) {
+ leftOffset += availableWidth / 2;
+ } else if (isEnd) {
+ leftOffset += availableWidth;
}
- Ext.layout.BoxLayout.superclass.renderAll.call(this, ct, this.innerCt);
- },
-
- getLayoutTargetSize : function(){
- var target = this.container.getLayoutTarget(), ret;
- if (target) {
- ret = target.getViewSize();
-
-
+
+
+ for (i = 0; i < visibleCount; i++) {
+ child = visibleItems[i];
+ calcs = boxes[i];
+ childMargins = child.margins;
+ leftOffset += childMargins.left;
+ vertMargins = childMargins.top + childMargins.bottom;
- if (Ext.isIE && Ext.isStrict && ret.width == 0){
- ret = target.getStyleSize();
- }
+ calcs.left = leftOffset;
+ calcs.top = topOffset + childMargins.top;
- ret.width -= target.getPadding('lr');
- ret.height -= target.getPadding('tb');
+ switch (this.align) {
+ case 'stretch':
+ stretchHeight = availHeight - vertMargins;
+ calcs.height = stretchHeight.constrain(child.minHeight || 0, child.maxHeight || 1000000);
+ calcs.dirtySize = true;
+ break;
+ case 'stretchmax':
+ stretchHeight = maxHeight - vertMargins;
+ calcs.height = stretchHeight.constrain(child.minHeight || 0, child.maxHeight || 1000000);
+ calcs.dirtySize = true;
+ break;
+ case 'middle':
+ var diff = availHeight - calcs.height - vertMargins;
+ if (diff > 0) {
+ calcs.top = topOffset + vertMargins + (diff / 2);
+ }
+ }
+
+ leftOffset += calcs.width + childMargins.right;
}
- return ret;
- },
-
- renderItem : function(c){
- if(Ext.isString(c.margins)){
- c.margins = this.parseMargins(c.margins);
- }else if(!c.margins){
- c.margins = this.defaultMargins;
- }
- Ext.layout.BoxLayout.superclass.renderItem.apply(this, arguments);
+ return {
+ boxes: boxes,
+ meta : {
+ maxHeight : maxHeight,
+ nonFlexWidth: nonFlexWidth,
+ desiredWidth: desiredWidth,
+ minimumWidth: minimumWidth,
+ shortfall : desiredWidth - width,
+ tooNarrow : tooNarrow
+ }
+ };
}
});
-
+Ext.Container.LAYOUTS.hbox = Ext.layout.HBoxLayout;
Ext.layout.VBoxLayout = Ext.extend(Ext.layout.BoxLayout, {
align : 'left',
- updateInnerCtSize: function(tSize, calcs) {
- var innerCtHeight = tSize.height,
- innerCtWidth = calcs.meta.maxWidth + this.padding.left + this.padding.right;
-
- if (this.align == 'stretch') {
- innerCtWidth = tSize.width;
- } else if (this.align == 'center') {
- innerCtWidth = Math.max(tSize.width, innerCtWidth);
- }
-
-
-
- this.innerCt.setSize(innerCtWidth || undefined, innerCtHeight || undefined);
- },
-
-
calculateChildBoxes: function(visibleItems, targetSize) {
var visibleCount = visibleItems.length,
nonFlexHeight= 0,
maxWidth = 0,
totalFlex = 0,
+ desiredHeight= 0,
+ minimumHeight= 0,
boxes = [],
-
- child, childWidth, childHeight, childSize, childMargins, canLayout, i, calcs, flexedHeight, horizMargins, stretchWidth;
-
- for (i = 0; i < visibleCount; i++) {
- child = visibleItems[i];
- childHeight = child.height;
- childWidth = child.width;
- canLayout = !child.hasLayout && Ext.isFunction(child.doLayout);
+ child, childWidth, childHeight, childSize, childMargins, canLayout, i, calcs, flexedWidth,
+ horizMargins, vertMargins, stretchWidth;
+
+ for (i = 0; i < visibleCount; i++) {
+ child = visibleItems[i];
+ childHeight = child.height;
+ childWidth = child.width;
+ canLayout = !child.hasLayout && typeof child.doLayout == 'function';
+
+
+ if (typeof childHeight != 'number') {
- if (!Ext.isNumber(childHeight)) {
+ if (child.flex && !childHeight) {
+ totalFlex += child.flex;
+
+ } else {
- if (child.flex && !childHeight) {
- totalFlex += child.flex;
-
- } else {
-
-
- if (!childHeight && canLayout) {
- child.doLayout();
- }
-
- childSize = child.getSize();
- childWidth = childSize.width;
- childHeight = childSize.height;
- }
- }
-
- childMargins = child.margins;
-
- nonFlexHeight += (childHeight || 0) + childMargins.top + childMargins.bottom;
-
-
- if (!Ext.isNumber(childWidth)) {
- if (canLayout) {
+ if (!childHeight && canLayout) {
child.doLayout();
}
- childWidth = child.getWidth();
- }
-
- maxWidth = Math.max(maxWidth, childWidth + childMargins.left + childMargins.right);
-
- boxes.push({
- component: child,
- height : childHeight || undefined,
- width : childWidth || undefined
- });
+ childSize = child.getSize();
+ childWidth = childSize.width;
+ childHeight = childSize.height;
+ }
}
-
- var availableHeight = Math.max(0, (height - nonFlexHeight - paddingVert));
+ childMargins = child.margins;
+ vertMargins = childMargins.top + childMargins.bottom;
- if (isCenter) {
- topOffset += availableHeight / 2;
- } else if (isEnd) {
- topOffset += availableHeight;
- }
+ nonFlexHeight += vertMargins + (childHeight || 0);
+ desiredHeight += vertMargins + (child.flex ? child.minHeight || 0 : childHeight);
+ minimumHeight += vertMargins + (child.minHeight || childHeight || 0);
- var remainingHeight = availableHeight,
- remainingFlex = totalFlex;
-
-
- for (i = 0; i < visibleCount; i++) {
- child = visibleItems[i];
- calcs = boxes[i];
-
- childMargins = child.margins;
- horizMargins = childMargins.left + childMargins.right;
-
- topOffset += childMargins.top;
-
- if (isStart && child.flex && !child.height) {
- flexedHeight = Math.ceil((child.flex / remainingFlex) * remainingHeight);
- remainingHeight -= flexedHeight;
- remainingFlex -= child.flex;
-
- calcs.height = flexedHeight;
- calcs.dirtySize = true;
+ if (typeof childWidth != 'number') {
+ if (canLayout) {
+ child.doLayout();
}
-
- calcs.left = leftOffset + childMargins.left;
- calcs.top = topOffset;
-
- switch (this.align) {
- case 'stretch':
- stretchWidth = availWidth - horizMargins;
- calcs.width = stretchWidth.constrain(child.minWidth || 0, child.maxWidth || 1000000);
- calcs.dirtySize = true;
- break;
- case 'stretchmax':
- stretchWidth = maxWidth - horizMargins;
- calcs.width = stretchWidth.constrain(child.minWidth || 0, child.maxWidth || 1000000);
- calcs.dirtySize = true;
- break;
- case 'center':
- var diff = availWidth - calcs.width - horizMargins;
- if (diff > 0) {
- calcs.left = leftOffset + horizMargins + (diff / 2);
- }
- }
-
- topOffset += calcs.height + childMargins.bottom;
+ childWidth = child.getWidth();
}
- return {
- boxes: boxes,
- meta : {
- maxWidth: maxWidth
- }
- };
- }
-});
-
-Ext.Container.LAYOUTS.vbox = Ext.layout.VBoxLayout;
-
-
-Ext.layout.HBoxLayout = Ext.extend(Ext.layout.BoxLayout, {
-
- align: 'top',
-
- type : 'hbox',
-
-
- updateInnerCtSize: function(tSize, calcs) {
- var innerCtWidth = tSize.width,
- innerCtHeight = calcs.meta.maxHeight + this.padding.top + this.padding.bottom;
-
- if (this.align == 'stretch') {
- innerCtHeight = tSize.height;
- } else if (this.align == 'middle') {
- innerCtHeight = Math.max(tSize.height, innerCtHeight);
- }
-
- this.innerCt.setSize(innerCtWidth || undefined, innerCtHeight || undefined);
- },
-
-
-
-
-
- calculateChildBoxes: function(visibleItems, targetSize) {
- var visibleCount = visibleItems.length,
-
- padding = this.padding,
- topOffset = padding.top,
- leftOffset = padding.left,
- paddingVert = topOffset + padding.bottom,
- paddingHoriz = leftOffset + padding.right,
-
- width = targetSize.width - this.scrollOffset,
- height = targetSize.height,
- availHeight = Math.max(0, height - paddingVert),
-
- isStart = this.pack == 'start',
- isCenter = this.pack == 'center',
- isEnd = this.pack == 'end',
-
-
- nonFlexWidth = 0,
- maxHeight = 0,
- totalFlex = 0,
+ maxWidth = Math.max(maxWidth, childWidth + childMargins.left + childMargins.right);
- boxes = [],
+ boxes.push({
+ component: child,
+ height : childHeight || undefined,
+ width : childWidth || undefined
+ });
+ }
+
+ var shortfall = desiredHeight - height,
+ tooNarrow = minimumHeight > height;
+
+ var availableHeight = Math.max(0, (height - nonFlexHeight - paddingVert));
+
+ if (tooNarrow) {
+ for (i = 0, length = visibleCount; i < length; i++) {
+ boxes[i].height = visibleItems[i].minHeight || visibleItems[i].height || boxes[i].height;
+ }
+ } else {
- child, childWidth, childHeight, childSize, childMargins, canLayout, i, calcs, flexedWidth, vertMargins, stretchHeight;
-
- for (i = 0; i < visibleCount; i++) {
- child = visibleItems[i];
- childHeight = child.height;
- childWidth = child.width;
- canLayout = !child.hasLayout && Ext.isFunction(child.doLayout);
+ if (shortfall > 0) {
+ var minHeights = [];
- if (!Ext.isNumber(childWidth)) {
+ for (var index = 0, length = visibleCount; index < length; index++) {
+ var item = visibleItems[index],
+ minHeight = item.minHeight || 0;
- if (child.flex && !childWidth) {
- totalFlex += child.flex;
-
+ if (item.flex) {
+ boxes[index].height = minHeight;
} else {
-
-
- if (!childWidth && canLayout) {
- child.doLayout();
- }
-
- childSize = child.getSize();
- childWidth = childSize.width;
- childHeight = childSize.height;
+ minHeights.push({
+ minHeight: minHeight,
+ available: boxes[index].height - minHeight,
+ index : index
+ });
}
}
- childMargins = child.margins;
-
- nonFlexWidth += (childWidth || 0) + childMargins.left + childMargins.right;
+
+ minHeights.sort(function(a, b) {
+ return a.available > b.available ? 1 : -1;
+ });
- if (!Ext.isNumber(childHeight)) {
- if (canLayout) {
- child.doLayout();
+ for (var i = 0, length = minHeights.length; i < length; i++) {
+ var itemIndex = minHeights[i].index;
+
+ if (itemIndex == undefined) {
+ continue;
}
- childHeight = child.getHeight();
- }
- maxHeight = Math.max(maxHeight, childHeight + childMargins.top + childMargins.bottom);
+ var item = visibleItems[itemIndex],
+ box = boxes[itemIndex],
+ oldHeight = box.height,
+ minHeight = item.minHeight,
+ newHeight = Math.max(minHeight, oldHeight - Math.ceil(shortfall / (length - i))),
+ reduction = oldHeight - newHeight;
+ boxes[itemIndex].height = newHeight;
+ shortfall -= reduction;
+ }
+ } else {
- boxes.push({
- component: child,
- height : childHeight || undefined,
- width : childWidth || undefined
- });
- }
+ var remainingHeight = availableHeight,
+ remainingFlex = totalFlex;
+
+
+ for (i = 0; i < visibleCount; i++) {
+ child = visibleItems[i];
+ calcs = boxes[i];
-
- var availableWidth = Math.max(0, (width - nonFlexWidth - paddingHoriz));
+ childMargins = child.margins;
+ horizMargins = childMargins.left + childMargins.right;
- if (isCenter) {
- leftOffset += availableWidth / 2;
- } else if (isEnd) {
- leftOffset += availableWidth;
- }
+ if (isStart && child.flex && !child.height) {
+ flexedHeight = Math.ceil((child.flex / remainingFlex) * remainingHeight);
+ remainingHeight -= flexedHeight;
+ remainingFlex -= child.flex;
-
- var remainingWidth = availableWidth,
- remainingFlex = totalFlex;
-
-
- for (i = 0; i < visibleCount; i++) {
- child = visibleItems[i];
- calcs = boxes[i];
+ calcs.height = flexedHeight;
+ calcs.dirtySize = true;
+ }
+ }
+ }
+ }
- childMargins = child.margins;
- vertMargins = childMargins.top + childMargins.bottom;
+ if (isCenter) {
+ topOffset += availableHeight / 2;
+ } else if (isEnd) {
+ topOffset += availableHeight;
+ }
- leftOffset += childMargins.left;
+
+ for (i = 0; i < visibleCount; i++) {
+ child = visibleItems[i];
+ calcs = boxes[i];
- if (isStart && child.flex && !child.width) {
- flexedWidth = Math.ceil((child.flex / remainingFlex) * remainingWidth);
- remainingWidth -= flexedWidth;
- remainingFlex -= child.flex;
+ childMargins = child.margins;
+ topOffset += childMargins.top;
+ horizMargins = childMargins.left + childMargins.right;
+
- calcs.width = flexedWidth;
+ calcs.left = leftOffset + childMargins.left;
+ calcs.top = topOffset;
+
+ switch (this.align) {
+ case 'stretch':
+ stretchWidth = availWidth - horizMargins;
+ calcs.width = stretchWidth.constrain(child.minWidth || 0, child.maxWidth || 1000000);
calcs.dirtySize = true;
- }
-
- calcs.left = leftOffset;
- calcs.top = topOffset + childMargins.top;
-
- switch (this.align) {
- case 'stretch':
- stretchHeight = availHeight - vertMargins;
- calcs.height = stretchHeight.constrain(child.minHeight || 0, child.maxHeight || 1000000);
- calcs.dirtySize = true;
- break;
- case 'stretchmax':
- stretchHeight = maxHeight - vertMargins;
- calcs.height = stretchHeight.constrain(child.minHeight || 0, child.maxHeight || 1000000);
- calcs.dirtySize = true;
- break;
- case 'middle':
- var diff = availHeight - calcs.height - vertMargins;
- if (diff > 0) {
- calcs.top = topOffset + vertMargins + (diff / 2);
- }
- }
- leftOffset += calcs.width + childMargins.right;
+ break;
+ case 'stretchmax':
+ stretchWidth = maxWidth - horizMargins;
+ calcs.width = stretchWidth.constrain(child.minWidth || 0, child.maxWidth || 1000000);
+ calcs.dirtySize = true;
+ break;
+ case 'center':
+ var diff = availWidth - calcs.width - horizMargins;
+ if (diff > 0) {
+ calcs.left = leftOffset + horizMargins + (diff / 2);
+ }
}
+ topOffset += calcs.height + childMargins.bottom;
+ }
+
return {
boxes: boxes,
meta : {
- maxHeight: maxHeight
+ maxWidth : maxWidth,
+ nonFlexHeight: nonFlexHeight,
+ desiredHeight: desiredHeight,
+ minimumHeight: minimumHeight,
+ shortfall : desiredHeight - height,
+ tooNarrow : tooNarrow
}
};
}
});
-Ext.Container.LAYOUTS.hbox = Ext.layout.HBoxLayout;
+Ext.Container.LAYOUTS.vbox = Ext.layout.VBoxLayout;
Ext.layout.ToolbarLayout = Ext.extend(Ext.layout.ContainerLayout, {
monitorResize : true,
position = -1;
} else if (!c.rendered) {
c.render(this.insertCell(c, side, position));
+ this.configureItem(c);
} else {
if (!c.xtbHidden && !this.isValidParent(c, side.childNodes[position])) {
var td = this.insertCell(c, side, position);
this.itemTpl = Ext.layout.MenuLayout.prototype.itemTpl = new Ext.XTemplate(
'<li id="{itemId}" class="{itemCls}">',
'<tpl if="needsIcon">',
- '<img src="{icon}" class="{iconCls}"/>',
+ '<img alt="{altText}" src="{icon}" class="{iconCls}"/>',
'</tpl>',
'</li>'
);
if (!a.isMenuItem && a.needsIcon) {
c.positionEl.addClass('x-menu-list-item-indent');
}
- this.configureItem(c, position);
+ this.configureItem(c);
}else if(c && !this.isValidParent(c, target)){
if(Ext.isNumber(position)){
position = target.dom.childNodes[position];
},
getItemArgs : function(c) {
- var isMenuItem = c instanceof Ext.menu.Item;
+ var isMenuItem = c instanceof Ext.menu.Item,
+ canHaveIcon = !(isMenuItem || c instanceof Ext.menu.Separator);
+
return {
isMenuItem: isMenuItem,
- needsIcon: !isMenuItem && (c.icon || c.iconCls),
+ needsIcon: canHaveIcon && (c.icon || c.iconCls),
icon: c.icon || Ext.BLANK_IMAGE_URL,
iconCls: 'x-menu-item-icon ' + (c.iconCls || ''),
itemId: 'x-menu-el-' + c.id,
- itemCls: 'x-menu-list-item '
+ itemCls: 'x-menu-list-item ',
+ altText: c.altText || ''
};
},
var hdspan = hd.child('span.' + this.headerTextCls);
if (hdspan) {
Ext.DomHelper.insertBefore(hdspan.dom, {
- tag:'img', src: Ext.BLANK_IMAGE_URL, cls:'x-panel-inline-icon '+this.iconCls
+ tag:'img', alt: '', src: Ext.BLANK_IMAGE_URL, cls:'x-panel-inline-icon '+this.iconCls
});
}
}
getFrameHeight : function() {
- var h = Math.max(0, this.getHeight() - this.body.getHeight());
+ var h = this.el.getFrameWidth('tb') + this.bwrap.getFrameWidth('tb');
+ h += (this.tbar ? this.tbar.getHeight() : 0) +
+ (this.bbar ? this.bbar.getHeight() : 0);
- if (isNaN(h)) {
- h = 0;
+ if(this.frame){
+ h += this.el.dom.firstChild.offsetHeight + this.ft.dom.offsetHeight + this.mc.getFrameWidth('tb');
+ }else{
+ h += (this.header ? this.header.getHeight() : 0) +
+ (this.footer ? this.footer.getHeight() : 0);
}
return h;
-
-
},
delete this.field.lastSize;
this.field.setSize(w, h);
if(this.el){
- if(Ext.isGecko2 || Ext.isOpera){
+
+ if(Ext.isGecko2 || Ext.isOpera || (Ext.isIE7 && Ext.isStrict)){
this.el.setSize(w, h);
}
Ext.slider.Thumb = Ext.extend(Object, {
+
+
+ dragging: false,
constructor: function(config) {
if (this.dragStartValue != value) {
slider.fireEvent('changecomplete', slider, value, this);
}
+ },
+
+
+ destroy: function(){
+ Ext.destroyMembers(this, 'tracker', 'el');
}
});
clickToChange : true,
animate: true,
-
-
- dragging: false,
-
constrainThumbs: true,
for(; i < len; ++i){
thumbs[i].el.stopFx();
}
- this.innerEl.setWidth(w - (this.el.getPadding('l') + this.endEl.getPadding('r')));
+
+ if(Ext.isNumber(w)){
+ this.innerEl.setWidth(w - (this.el.getPadding('l') + this.endEl.getPadding('r')));
+ }
this.syncThumb();
Ext.slider.MultiSlider.superclass.onResize.apply(this, arguments);
},
beforeDestroy : function(){
- Ext.destroyMembers(this, 'endEl', 'innerEl', 'thumb', 'halfThumb', 'focusEl', 'tracker', 'thumbHolder');
+ var thumbs = this.thumbs;
+ for(var i = 0, len = thumbs.length; i < len; ++i){
+ thumbs[i].destroy();
+ thumbs[i] = null;
+ }
+ Ext.destroyMembers(this, 'endEl', 'innerEl', 'focusEl', 'thumbHolder');
Ext.slider.MultiSlider.superclass.beforeDestroy.call(this);
}
});
handleMouseDown: function(e, oDD) {
if(Ext.QuickTips){
- Ext.QuickTips.disable();
+ Ext.QuickTips.ddDisable();
}
if(this.dragCurrent){
handleMouseUp: function(e) {
if(Ext.QuickTips){
- Ext.QuickTips.enable();
+ Ext.QuickTips.ddEnable();
}
if (! this.dragCurrent) {
return;
destroy : function(){
this.el.un('mousedown', this.onMouseDown, this);
+ delete this.el;
},
onMouseDown: function(e, target){
if(this.preventDefault !== false){
e.preventDefault();
}
- var doc = Ext.getDoc();
- doc.on('mouseup', this.onMouseUp, this);
- doc.on('mousemove', this.onMouseMove, this);
- doc.on('selectstart', this.stopSelect, this);
+ Ext.getDoc().on({
+ scope: this,
+ mouseup: this.onMouseUp,
+ mousemove: this.onMouseMove,
+ selectstart: this.stopSelect
+ });
if(this.autoStart){
- this.timer = this.triggerStart.defer(this.autoStart === true ? 1000 : this.autoStart, this);
+ this.timer = this.triggerStart.defer(this.autoStart === true ? 1000 : this.autoStart, this, [e]);
}
}
},
this.lastXY = xy;
if(!this.active){
if(Math.abs(s[0]-xy[0]) > this.tolerance || Math.abs(s[1]-xy[1]) > this.tolerance){
- this.triggerStart();
+ this.triggerStart(e);
}else{
return;
}
},
onMouseUp: function(e) {
- var doc = Ext.getDoc();
+ var doc = Ext.getDoc(),
+ wasActive = this.active;
+
doc.un('mousemove', this.onMouseMove, this);
doc.un('mouseup', this.onMouseUp, this);
doc.un('selectstart', this.stopSelect, this);
e.preventDefault();
this.clearStart();
- var wasActive = this.active;
this.active = false;
delete this.elRegion;
this.fireEvent('mouseup', this, e);
}
},
- triggerStart: function(isTimer) {
+ triggerStart: function(e) {
this.clearStart();
this.active = true;
- this.onStart(this.startXY);
- this.fireEvent('dragstart', this, this.startXY);
+ this.onStart(e);
+ this.fireEvent('dragstart', this, e);
},
clearStart : function() {
},
getOffset : function(constrain){
- var xy = this.getXY(constrain);
- var s = this.startXY;
+ var xy = this.getXY(constrain),
+ s = this.startXY;
return [s[0]-xy[0], s[1]-xy[1]];
},
proc.el = null;
proc.dir = "";
};
-
+
var startProc = function(el, dir){
clearProc();
proc.el = el;
proc.dir = dir;
- var freq = (el.ddScrollConfig && el.ddScrollConfig.frequency) ?
- el.ddScrollConfig.frequency : Ext.dd.ScrollManager.frequency;
- proc.id = setInterval(doScroll, freq);
+ var group = el.ddScrollConfig ? el.ddScrollConfig.ddGroup : undefined,
+ freq = (el.ddScrollConfig && el.ddScrollConfig.frequency)
+ ? el.ddScrollConfig.frequency
+ : Ext.dd.ScrollManager.frequency;
+
+ if (group === undefined || ddm.dragCurrent.ddGroup == group) {
+ proc.id = setInterval(doScroll, freq);
+ }
};
var onFire = function(e, isDrop){
animDuration: .4,
+ ddGroup: undefined,
+
+
refreshCache : function(){
for(var id in els){
if(typeof els[id] == 'object'){
Ext.destroy(this.proxy);
}
});
-Ext.dd.DropTarget = function(el, config){
- this.el = Ext.get(el);
+Ext.dd.DropTarget = Ext.extend(Ext.dd.DDTarget, {
- Ext.apply(this, config);
+ constructor : function(el, config){
+ this.el = Ext.get(el);
- if(this.containerScroll){
- Ext.dd.ScrollManager.register(this.el);
- }
+ Ext.apply(this, config);
+
+ if(this.containerScroll){
+ Ext.dd.ScrollManager.register(this.el);
+ }
+
+ Ext.dd.DropTarget.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group,
+ {isTarget: true});
+ },
- Ext.dd.DropTarget.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group,
- {isTarget: true});
-
-};
-
-Ext.extend(Ext.dd.DropTarget, Ext.dd.DDTarget, {
notifyDrop : function(dd, e, data){
return false;
+ },
+
+ destroy : function(){
+ Ext.dd.DropTarget.superclass.destroy.call(this);
+ if(this.containerScroll){
+ Ext.dd.ScrollManager.unregister(this.el);
+ }
}
});
-Ext.dd.DragZone = function(el, config){
- Ext.dd.DragZone.superclass.constructor.call(this, el, config);
- if(this.containerScroll){
- Ext.dd.ScrollManager.register(this.el);
- }
-};
-
-Ext.extend(Ext.dd.DragZone, Ext.dd.DragSource, {
+Ext.dd.DragZone = Ext.extend(Ext.dd.DragSource, {
+
+ constructor : function(el, config){
+ Ext.dd.DragZone.superclass.constructor.call(this, el, config);
+ if(this.containerScroll){
+ Ext.dd.ScrollManager.register(this.el);
+ }
+ },
+
getRepairXY : function(e){
return Ext.Element.fly(this.dragData.ddel).getXY();
+ },
+
+ destroy : function(){
+ Ext.dd.DragZone.superclass.destroy.call(this);
+ if(this.containerScroll){
+ Ext.dd.ScrollManager.unregister(this.el);
+ }
}
});
Ext.dd.DropZone = function(el, config){
dir : 'dir'
},
-
- isDestroyed: false,
-
-
+ isDestroyed: false,
hasMultiSort: false,
batchKey : '_ext_batch_',
constructor : function(config){
+
+
+
+
this.data = new Ext.util.MixedCollection(false);
this.data.getKey = function(o){
return o.id;
};
-
+
this.removed = [];
},
- add : function(records){
+ add : function(records) {
+ var i, len, record, index;
+
records = [].concat(records);
- if(records.length < 1){
+ if (records.length < 1) {
return;
}
- for(var i = 0, len = records.length; i < len; i++){
- records[i].join(this);
+
+ for (i = 0, len = records.length; i < len; i++) {
+ record = records[i];
+
+ record.join(this);
+
+ if (record.dirty || record.phantom) {
+ this.modified.push(record);
+ }
}
- var index = this.data.length;
+
+ index = this.data.length;
this.data.addAll(records);
- if(this.snapshot){
+
+ if (this.snapshot) {
this.snapshot.addAll(records);
}
+
this.fireEvent('add', this, records, index);
},
var index = this.findInsertIndex(record);
this.insert(index, record);
},
+
+
+ doUpdate : function(rec){
+ this.data.replace(rec.id, rec);
+ if(this.snapshot){
+ this.snapshot.replace(rec.id, rec);
+ }
+ this.fireEvent('update', this, rec, Ext.data.Record.COMMIT);
+ },
remove : function(record){
},
- insert : function(index, records){
+ insert : function(index, records) {
+ var i, len, record;
+
records = [].concat(records);
- for(var i = 0, len = records.length; i < len; i++){
- this.data.insert(index, records[i]);
- records[i].join(this);
+ for (i = 0, len = records.length; i < len; i++) {
+ record = records[i];
+
+ this.data.insert(index + i, record);
+ record.join(this);
+
+ if (record.dirty || record.phantom) {
+ this.modified.push(record);
+ }
}
- if(this.snapshot){
+
+ if (this.snapshot) {
this.snapshot.addAll(records);
}
+
this.fireEvent('add', this, records, index);
},
},
- createRecords : function(store, rs, index) {
- for (var i = 0, len = rs.length; i < len; i++) {
- if (rs[i].phantom && rs[i].isValid()) {
- rs[i].markDirty();
- this.modified.push(rs[i]);
+ createRecords : function(store, records, index) {
+ var modified = this.modified,
+ length = records.length,
+ record, i;
+
+ for (i = 0; i < length; i++) {
+ record = records[i];
+
+ if (record.phantom && record.isValid()) {
+ record.markDirty();
+
+ if (modified.indexOf(record) == -1) {
+ modified.push(record);
+ }
}
}
if (this.autoSave === true) {
len,
trans,
batch,
- data = {};
+ data = {},
+ i;
if(this.removed.length){
queue.push(['destroy', this.removed]);
if(rs.length){
var phantoms = [];
- for(var i = rs.length-1; i >= 0; i--){
+ for(i = rs.length-1; i >= 0; i--){
if(rs[i].phantom === true){
var rec = rs.splice(i, 1).shift();
if(rec.isValid()){
len = queue.length;
if(len){
batch = ++this.batchCounter;
- for(var i = 0; i < len; ++i){
+ for(i = 0; i < len; ++i){
trans = queue[i];
data[trans[0]] = trans[1];
}
if(this.fireEvent('beforesave', this, data) !== false){
- for(var i = 0; i < len; ++i){
+ for(i = 0; i < len; ++i){
trans = queue[i];
this.doTransaction(trans[0], trans[1], batch);
}
var b = this.batches,
key = this.batchKey + batch,
o = b[key],
- data,
arr;
loadRecords : function(o, options, success){
+ var i, len;
+
if (this.isDestroyed === true) {
return;
}
if(this.pruneModifiedRecords){
this.modified = [];
}
- for(var i = 0, len = r.length; i < len; i++){
+ for(i = 0, len = r.length; i < len; i++){
r[i].join(this);
}
if(this.snapshot){
this.applySort();
this.fireEvent('datachanged', this);
}else{
- this.totalLength = Math.max(t, this.data.length+r.length);
- this.add(r);
+ var toAdd = [],
+ rec,
+ cnt = 0;
+ for(i = 0, len = r.length; i < len; ++i){
+ rec = r[i];
+ if(this.indexOfId(rec.id) > -1){
+ this.doUpdate(rec);
+ }else{
+ toAdd.push(rec);
+ ++cnt;
+ }
+ }
+ this.totalLength = Math.max(t, this.data.length + cnt);
+ this.add(toAdd);
}
this.fireEvent('load', this, r, options);
if(options.callback){
singleSort: function(fieldName, dir) {
var field = this.fields.get(fieldName);
- if (!field) return false;
+ if (!field) {
+ return false;
+ }
var name = field.name,
sortInfo = this.sortInfo || null,
this.applySort();
this.fireEvent('datachanged', this);
}
+ return true;
},
filter : function(property, value, anyMatch, caseSensitive, exactMatch){
+ var fn;
if (Ext.isObject(property)) {
property = [property];
filters.push({fn: func, scope: scope});
}
- var fn = this.createMultipleFilterFn(filters);
+ fn = this.createMultipleFilterFn(filters);
} else {
- var fn = this.createFilterFn(property, value, anyMatch, caseSensitive, exactMatch);
+ fn = this.createFilterFn(property, value, anyMatch, caseSensitive, exactMatch);
}
return fn ? this.filterBy(fn) : this.clearFilter();
filterBy : function(fn, scope){
this.snapshot = this.snapshot || this.data;
- this.data = this.queryBy(fn, scope||this);
+ this.data = this.queryBy(fn, scope || this);
this.fireEvent('datachanged', this);
},
commitChanges : function(){
- var m = this.modified.slice(0);
- this.modified = [];
- for(var i = 0, len = m.length; i < len; i++){
- m[i].commit();
+ var modified = this.modified.slice(0),
+ length = modified.length,
+ i;
+
+ for (i = 0; i < length; i++){
+ modified[i].commit();
}
+
+ this.modified = [];
+ this.removed = [];
},
- rejectChanges : function(){
- var m = this.modified.slice(0);
- this.modified = [];
- for(var i = 0, len = m.length; i < len; i++){
- m[i].reject();
+ rejectChanges : function() {
+ var modified = this.modified.slice(0),
+ removed = this.removed.slice(0).reverse(),
+ mLength = modified.length,
+ rLength = removed.length,
+ i;
+
+ for (i = 0; i < mLength; i++) {
+ modified[i].reject();
}
- var m = this.removed.slice(0).reverse();
- this.removed = [];
- for(var i = 0, len = m.length; i < len; i++){
- this.insert(m[i].lastIndex||0, m[i]);
- m[i].reject();
+
+ for (i = 0; i < rLength; i++) {
+ this.insert(removed[i].lastIndex || 0, removed[i]);
+ removed[i].reject();
}
+
+ this.modified = [];
+ this.removed = [];
},
dateFormat: null,
+
+ useNull: false,
+
+
defaultValue: "",
mapping: null,
delete data[this.meta.idProperty];
}
} else {
- data[this.meta.idProperty] = rec.id
+ data[this.meta.idProperty] = rec.id;
}
return data;
},
INT: {
convert: function(v){
return v !== undefined && v !== null && v !== '' ?
- parseInt(String(v).replace(Ext.data.Types.stripRe, ''), 10) : 0;
+ parseInt(String(v).replace(Ext.data.Types.stripRe, ''), 10) : (this.useNull ? null : 0);
},
sortType: st.none,
type: 'int'
FLOAT: {
convert: function(v){
return v !== undefined && v !== null && v !== '' ?
- parseFloat(String(v).replace(Ext.data.Types.stripRe, ''), 10) : 0;
+ parseFloat(String(v).replace(Ext.data.Types.stripRe, ''), 10) : (this.useNull ? null : 0);
},
sortType: st.none,
type: 'float'
xmlEncoding: 'ISO-8859-15',
- tpl: '<tpl for="."><\u003fxml version="{version}" encoding="{encoding}"\u003f><tpl if="documentRoot"><{documentRoot}><tpl for="baseParams"><tpl for="."><{name}>{value}</{name}</tpl></tpl></tpl><tpl if="records.length>1"><{root}></tpl><tpl for="records"><{parent.record}><tpl for="."><{name}>{value}</{name}></tpl></{parent.record}></tpl><tpl if="records.length>1"></{root}></tpl><tpl if="documentRoot"></{documentRoot}></tpl></tpl>',
+ tpl: '<tpl for="."><\u003fxml version="{version}" encoding="{encoding}"\u003f><tpl if="documentRoot"><{documentRoot}><tpl for="baseParams"><tpl for="."><{name}>{value}</{name}></tpl></tpl></tpl><tpl if="records.length>1"><{root}></tpl><tpl for="records"><{parent.record}><tpl for="."><{name}>{value}</{name}></tpl></{parent.record}></tpl><tpl if="records.length>1"></{root}></tpl><tpl if="documentRoot"></{documentRoot}></tpl></tpl>',
readResponse : function(action, response) {
- var q = Ext.DomQuery,
- doc = response.responseXML;
+ var q = Ext.DomQuery,
+ doc = response.responseXML,
+ root = doc.documentElement || doc;
var res = new Ext.data.Response({
action: action,
- success : this.getSuccess(doc),
- message: this.getMessage(doc),
- data: this.extractData(q.select(this.meta.record, doc) || q.select(this.meta.root, doc), false),
+ success : this.getSuccess(root),
+ message: this.getMessage(root),
+ data: this.extractData(q.select(this.meta.record, root) || q.select(this.meta.root, root), false),
raw: doc
});
createAccessor : function(){
var q = Ext.DomQuery;
return function(key) {
+ if (Ext.isFunction(key)) {
+ return key;
+ }
switch(key) {
case this.meta.totalProperty:
return function(root, def){
groupOnSort:false,
+
groupDir : 'ASC',
- sorters = this.multiSortInfo.sorters;
+ var sorters = this.multiSortInfo.sorters;
if (sorters.length > 0 && sorters[0].field == this.groupField) {
sorters.shift();
}
cb: scope && Ext.isFunction(hs) ? hs.createDelegate(scope) : hs
});
- if(this.fireEvent('beforecall', this, t) !== false){
+ if(this.fireEvent('beforecall', this, t, m) !== false){
Ext.Direct.addTransaction(t);
this.queueTransaction(t);
- this.fireEvent('call', this, t);
+ this.fireEvent('call', this, t, m);
}
},
isForm: true
});
- if(this.fireEvent('beforecall', this, t) !== false){
+ if(this.fireEvent('beforecall', this, t, m) !== false){
Ext.Direct.addTransaction(t);
var isUpload = String(form.getAttribute("enctype")).toLowerCase() == 'multipart/form-data',
params = {
isUpload: isUpload,
params: callback && Ext.isObject(callback.params) ? Ext.apply(params, callback.params) : params
});
- this.fireEvent('call', this, t);
+ this.fireEvent('call', this, t, m);
this.processForm(t);
}
},
minWidth : 200,
expandOnShow : true,
+
+
+ showAnimDuration: 0.25,
+
+
+ hideAnimDuration: 0.25,
collapsible : false,
el = f.getEl();
ct = Ext.getDom(this.container);
if (el && ct) {
- if (!Ext.lib.Region.getRegion(ct).contains(Ext.lib.Region.getRegion(el.dom))){
+ if (ct != document.body && !Ext.lib.Region.getRegion(ct).contains(Ext.lib.Region.getRegion(el.dom))){
return;
}
}
callback: this.afterShow.createDelegate(this, [true], false),
scope: this,
easing: 'easeNone',
- duration: 0.25,
+ duration: this.showAnimDuration,
opacity: 0.5
}));
},
this.proxy.shift(Ext.apply(this.animateTarget.getBox(), {
callback: this.afterHide,
scope: this,
- duration: 0.25,
+ duration: this.hideAnimDuration,
easing: 'easeNone',
opacity: 0
}));
Ext.reg('window', Ext.Window);
-Ext.Window.DD = function(win){
- this.win = win;
- Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id);
- this.setHandleElId(win.header.id);
- this.scroll = false;
-};
-
-Ext.extend(Ext.Window.DD, Ext.dd.DD, {
+Ext.Window.DD = Ext.extend(Ext.dd.DD, {
+
+ constructor : function(win){
+ this.win = win;
+ Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id);
+ this.setHandleElId(win.header.id);
+ this.scroll = false;
+ },
+
moveOnly:true,
headerOffsets:[100, 25],
startDrag : function(){
var w = this.win;
- this.proxy = w.ghost();
+ this.proxy = w.ghost(w.initialConfig.cls);
if(w.constrain !== false){
var so = w.el.shadowOffset;
this.constrainTo(w.container, {right: so, left: so, bottom: so});
if(!dlg.isVisible() && !opt.width){
dlg.setSize(this.maxWidth, 100);
}
- msgEl.update(text || ' ');
+
+ msgEl.update(text ? text + ' ' : ' ');
var iw = iconCls != '' ? (iconEl.getWidth() + iconEl.getMargins('lr')) : 0,
mw = msgEl.getWidth() + msgEl.getMargins('lr'),
bw = dlg.body.getFrameWidth('lr'),
w;
- if (Ext.isIE && iw > 0){
-
-
- iw += 3;
- }
w = Math.max(Math.min(opt.width || iw+mw+fw+bw, opt.maxWidth || this.maxWidth),
Math.max(opt.minWidth || this.minWidth, bwidth || 0));
if(Ext.isIE && w == bwidth){
w += 4;
}
+ msgEl.update(text || ' ');
dlg.setSize(w, 'auto').center();
return this;
},
d.focusEl = db;
}
}
- if(opt.iconCls){
+ if(Ext.isDefined(opt.iconCls)){
d.setIconClass(opt.iconCls);
}
this.setIcon(Ext.isDefined(opt.icon) ? opt.icon : bufferIcon);
Ext.Msg = Ext.MessageBox;
-Ext.dd.PanelProxy = function(panel, config){
- this.panel = panel;
- this.id = this.panel.id +'-ddproxy';
- Ext.apply(this, config);
-};
-
-Ext.dd.PanelProxy.prototype = {
+Ext.dd.PanelProxy = Ext.extend(Object, {
+
+ constructor : function(panel, config){
+ this.panel = panel;
+ this.id = this.panel.id +'-ddproxy';
+ Ext.apply(this, config);
+ },
+
insertProxy : true,
show : function(){
if(!this.ghost){
- this.ghost = this.panel.createGhost(undefined, undefined, Ext.getBody());
+ this.ghost = this.panel.createGhost(this.panel.initialConfig.cls, undefined, Ext.getBody());
this.ghost.setXY(this.panel.el.getXY());
if(this.insertProxy){
this.proxy = this.panel.el.insertSibling({cls:'x-panel-dd-spacer'});
parentNode.insertBefore(this.proxy.dom, before);
}
}
-};
-
+});
-Ext.Panel.DD = function(panel, cfg){
- this.panel = panel;
- this.dragData = {panel: panel};
- this.proxy = new Ext.dd.PanelProxy(panel, cfg);
- Ext.Panel.DD.superclass.constructor.call(this, panel.el, cfg);
- var h = panel.header;
- if(h){
- this.setHandleElId(h.id);
- }
- (h ? h : this.panel.body).setStyle('cursor', 'move');
- this.scroll = false;
-};
-Ext.extend(Ext.Panel.DD, Ext.dd.DragSource, {
+Ext.Panel.DD = Ext.extend(Ext.dd.DragSource, {
+
+ constructor : function(panel, cfg){
+ this.panel = panel;
+ this.dragData = {panel: panel};
+ this.proxy = new Ext.dd.PanelProxy(panel, cfg);
+ Ext.Panel.DD.superclass.constructor.call(this, panel.el, cfg);
+ var h = panel.header,
+ el = panel.body;
+ if(h){
+ this.setHandleElId(h.id);
+ el = panel.header;
+ }
+ el.setStyle('cursor', 'move');
+ this.scroll = false;
+ },
+
showFrame: Ext.emptyFn,
startDrag: Ext.emptyFn,
b4StartDrag: function(x, y) {
this.proxy.show();
},
b4MouseDown: function(e) {
- var x = e.getPageX();
- var y = e.getPageY();
+ var x = e.getPageX(),
+ y = e.getPageY();
this.autoOffset(x, y);
},
onInitDrag : function(x, y){
this.setDelta(x, y);
}
});
-Ext.state.Provider = function(){
+Ext.state.Provider = Ext.extend(Ext.util.Observable, {
+
+ constructor : function(){
+
+ this.addEvents("statechange");
+ this.state = {};
+ Ext.state.Provider.superclass.constructor.call(this);
+ },
- this.addEvents("statechange");
- this.state = {};
- Ext.state.Provider.superclass.constructor.call(this);
-};
-Ext.extend(Ext.state.Provider, Ext.util.Observable, {
get : function(name, defaultValue){
return typeof this.state[name] == "undefined" ?
decodeValue : function(cookie){
- var re = /^(a|n|d|b|s|o)\:(.*)$/;
- var matches = re.exec(unescape(cookie));
- if(!matches || !matches[1]) return;
- var type = matches[1];
- var v = matches[2];
+
+ var re = /^(a|n|d|b|s|o|e)\:(.*)$/,
+ matches = re.exec(unescape(cookie)),
+ all,
+ type,
+ v,
+ kv;
+ if(!matches || !matches[1]){
+ return;
+ }
+ type = matches[1];
+ v = matches[2];
switch(type){
- case "n":
+ case 'e':
+ return null;
+ case 'n':
return parseFloat(v);
- case "d":
+ case 'd':
return new Date(Date.parse(v));
- case "b":
- return (v == "1");
- case "a":
- var all = [];
+ case 'b':
+ return (v == '1');
+ case 'a':
+ all = [];
if(v != ''){
Ext.each(v.split('^'), function(val){
all.push(this.decodeValue(val));
}, this);
}
return all;
- case "o":
- var all = {};
+ case 'o':
+ all = {};
if(v != ''){
Ext.each(v.split('^'), function(val){
- var kv = val.split('=');
+ kv = val.split('=');
all[kv[0]] = this.decodeValue(kv[1]);
}, this);
}
encodeValue : function(v){
- var enc;
- if(typeof v == "number"){
- enc = "n:" + v;
- }else if(typeof v == "boolean"){
- enc = "b:" + (v ? "1" : "0");
+ var enc,
+ flat = '',
+ i = 0,
+ len,
+ key;
+ if(v == null){
+ return 'e:1';
+ }else if(typeof v == 'number'){
+ enc = 'n:' + v;
+ }else if(typeof v == 'boolean'){
+ enc = 'b:' + (v ? '1' : '0');
}else if(Ext.isDate(v)){
- enc = "d:" + v.toGMTString();
+ enc = 'd:' + v.toGMTString();
}else if(Ext.isArray(v)){
- var flat = "";
- for(var i = 0, len = v.length; i < len; i++){
+ for(len = v.length; i < len; i++){
flat += this.encodeValue(v[i]);
- if(i != len-1) flat += "^";
+ if(i != len - 1){
+ flat += '^';
+ }
}
- enc = "a:" + flat;
- }else if(typeof v == "object"){
- var flat = "";
- for(var key in v){
- if(typeof v[key] != "function" && v[key] !== undefined){
- flat += key + "=" + this.encodeValue(v[key]) + "^";
+ enc = 'a:' + flat;
+ }else if(typeof v == 'object'){
+ for(key in v){
+ if(typeof v[key] != 'function' && v[key] !== undefined){
+ flat += key + '=' + this.encodeValue(v[key]) + '^';
}
}
- enc = "o:" + flat.substring(0, flat.length-1);
+ enc = 'o:' + flat.substring(0, flat.length-1);
}else{
- enc = "s:" + v;
+ enc = 's:' + v;
}
return escape(enc);
}
};
}();
-Ext.state.CookieProvider = function(config){
- Ext.state.CookieProvider.superclass.constructor.call(this);
- this.path = "/";
- this.expires = new Date(new Date().getTime()+(1000*60*60*24*7));
- this.domain = null;
- this.secure = false;
- Ext.apply(this, config);
- this.state = this.readCookies();
-};
-
-Ext.extend(Ext.state.CookieProvider, Ext.state.Provider, {
+Ext.state.CookieProvider = Ext.extend(Ext.state.Provider, {
+
+ constructor : function(config){
+ Ext.state.CookieProvider.superclass.constructor.call(this);
+ this.path = "/";
+ this.expires = new Date(new Date().getTime()+(1000*60*60*24*7));
+ this.domain = null;
+ this.secure = false;
+ Ext.apply(this, config);
+ this.state = this.readCookies();
+ },
+
set : function(name, value){
if(typeof value == "undefined" || value === null){
readCookies : function(){
- var cookies = {};
- var c = document.cookie + ";";
- var re = /\s?(.*?)=(.*?);/g;
- var matches;
+ var cookies = {},
+ c = document.cookie + ";",
+ re = /\s?(.*?)=(.*?);/g,
+ matches,
+ name,
+ value;
while((matches = re.exec(c)) != null){
- var name = matches[1];
- var value = matches[2];
+ name = matches[1];
+ value = matches[2];
if(name && name.substring(0,3) == "ys-"){
cookies[name.substr(3)] = this.decodeValue(value);
}
refresh : function() {
this.clearSelections(false, true);
- var el = this.getTemplateTarget();
- el.update("");
- var records = this.store.getRange();
+ var el = this.getTemplateTarget(),
+ records = this.store.getRange();
+
+ el.update('');
if(records.length < 1){
if(!this.deferEmptyText || this.hasSkippedEmptyText){
el.update(this.emptyText);
collectData : function(records, startIndex){
- var r = [];
- for(var i = 0, len = records.length; i < len; i++){
- r[r.length] = this.prepareData(records[i].data, startIndex+i, records[i]);
+ var r = [],
+ i = 0,
+ len = records.length;
+ for(; i < len; i++){
+ r[r.length] = this.prepareData(records[i].data, startIndex + i, records[i]);
}
return r;
},
- bufferRender : function(records){
+ bufferRender : function(records, index){
var div = document.createElement('div');
- this.tpl.overwrite(div, this.collectData(records));
+ this.tpl.overwrite(div, this.collectData(records, index));
return Ext.query(this.itemSelector, div);
},
onUpdate : function(ds, record){
var index = this.store.indexOf(record);
if(index > -1){
- var sel = this.isSelected(index);
- var original = this.all.elements[index];
- var node = this.bufferRender([record], index)[0];
+ var sel = this.isSelected(index),
+ original = this.all.elements[index],
+ node = this.bufferRender([record], index)[0];
this.all.replaceElement(index, node, true);
if(sel){
onClick : function(e){
- var item = e.getTarget(this.itemSelector, this.getTemplateTarget());
+ var item = e.getTarget(this.itemSelector, this.getTemplateTarget()),
+ index;
if(item){
- var index = this.indexOf(item);
+ index = this.indexOf(item);
if(this.onItemClick(item, index, e) !== false){
this.fireEvent("click", this, index, item, e);
}
getSelectedIndexes : function(){
- var indexes = [], s = this.selected.elements;
- for(var i = 0, len = s.length; i < len; i++){
- indexes.push(s[i].viewIndex);
+ var indexes = [],
+ selected = this.selected.elements,
+ i = 0,
+ len = selected.length;
+
+ for(; i < len; i++){
+ indexes.push(selected[i].viewIndex);
}
return indexes;
},
getSelectedRecords : function(){
- var r = [], s = this.selected.elements;
- for(var i = 0, len = s.length; i < len; i++){
- r[r.length] = this.store.getAt(s[i].viewIndex);
- }
- return r;
+ return this.getRecords(this.selected.elements);
},
getRecords : function(nodes){
- var r = [], s = nodes;
- for(var i = 0, len = s.length; i < len; i++){
- r[r.length] = this.store.getAt(s[i].viewIndex);
+ var records = [],
+ i = 0,
+ len = nodes.length;
+
+ for(; i < len; i++){
+ records[records.length] = this.store.getAt(nodes[i].viewIndex);
}
- return r;
+ return records;
},
getNodes : function(start, end){
- var ns = this.all.elements;
+ var ns = this.all.elements,
+ nodes = [],
+ i;
+
start = start || 0;
end = !Ext.isDefined(end) ? Math.max(ns.length - 1, 0) : end;
- var nodes = [], i;
if(start <= end){
for(i = start; i <= end && ns[i]; i++){
nodes.push(ns[i]);
- maxWidth: Ext.isIE ? 99 : 100,
+ maxColumnWidth: Ext.isIE ? 99 : 100,
initComponent : function(){
if(this.columnResize){
}
if(c.width) {
allocatedWidth += c.width*100;
+ if(allocatedWidth > this.maxColumnWidth){
+ c.width -= (allocatedWidth - this.maxColumnWidth) / 100;
+ }
colsWithWidth++;
}
columns.push(c);
if(colsWithWidth < len){
var remaining = len - colsWithWidth;
- if(allocatedWidth < this.maxWidth){
- var perCol = ((this.maxWidth-allocatedWidth) / remaining)/100;
+ if(allocatedWidth < this.maxColumnWidth){
+ var perCol = ((this.maxColumnWidth-allocatedWidth) / remaining)/100;
for(var j = 0; j < len; j++){
var c = cs[j];
if(!c.width){
return {
columns: this.columns,
rows: rs
- }
+ };
},
verifyInternalSize : function(){
onResize : function(w, h){
- var bd = this.innerBody.dom;
- var hd = this.innerHd.dom;
- if(!bd){
+ var body = this.innerBody.dom,
+ header = this.innerHd.dom,
+ scrollWidth = w - Ext.num(this.scrollOffset, Ext.getScrollBarWidth()) + 'px',
+ parentNode;
+
+ if(!body){
return;
}
- var bdp = bd.parentNode;
+ parentNode = body.parentNode;
if(Ext.isNumber(w)){
- var sw = w - Ext.num(this.scrollOffset, Ext.getScrollBarWidth());
- if(this.reserveScrollOffset || ((bdp.offsetWidth - bdp.clientWidth) > 10)){
- bd.style.width = sw + 'px';
- hd.style.width = sw + 'px';
+ if(this.reserveScrollOffset || ((parentNode.offsetWidth - parentNode.clientWidth) > 10)){
+ body.style.width = scrollWidth;
+ header.style.width = scrollWidth;
}else{
- bd.style.width = w + 'px';
- hd.style.width = w + 'px';
+ body.style.width = w + 'px';
+ header.style.width = w + 'px';
setTimeout(function(){
- if((bdp.offsetWidth - bdp.clientWidth) > 10){
- bd.style.width = sw + 'px';
- hd.style.width = sw + 'px';
+ if((parentNode.offsetWidth - parentNode.clientWidth) > 10){
+ body.style.width = scrollWidth;
+ header.style.width = scrollWidth;
}
}, 10);
}
}
if(Ext.isNumber(h)){
- bdp.style.height = (h - hd.parentNode.offsetHeight) + 'px';
+ parentNode.style.height = Math.max(0, h - header.parentNode.offsetHeight) + 'px';
}
},
this.verifyInternalSize();
},
- findHeaderIndex : function(hd){
- hd = hd.dom || hd;
- var pn = hd.parentNode, cs = pn.parentNode.childNodes;
- for(var i = 0, c; c = cs[i]; i++){
- if(c == pn){
+ findHeaderIndex : function(header){
+ header = header.dom || header;
+ var parentNode = header.parentNode,
+ children = parentNode.parentNode.childNodes,
+ i = 0,
+ c;
+ for(; c = children[i]; i++){
+ if(c == parentNode){
return i;
}
}
},
setHdWidths : function(){
- var els = this.innerHd.dom.getElementsByTagName('div');
- for(var i = 0, cs = this.columns, len = cs.length; i < len; i++){
- els[i].style.width = (cs[i].width*100) + '%';
+ var els = this.innerHd.dom.getElementsByTagName('div'),
+ i = 0,
+ columns = this.columns,
+ len = columns.length;
+
+ for(; i < len; i++){
+ els[i].style.width = (columns[i].width*100) + '%';
}
}
});
},
handleHdMove : function(e, t){
- var hw = 5,
+ var handleWidth = 5,
x = e.getPageX(),
- hd = e.getTarget('em', 3, true);
- if(hd){
- var r = hd.getRegion(),
- ss = hd.dom.style,
- pn = hd.dom.parentNode;
-
- if(x - r.left <= hw && pn != pn.parentNode.firstChild){
- this.activeHd = Ext.get(pn.previousSibling.firstChild);
- ss.cursor = Ext.isWebKit ? 'e-resize' : 'col-resize';
- } else if(r.right - x <= hw && pn != pn.parentNode.lastChild.previousSibling){
- this.activeHd = hd;
- ss.cursor = Ext.isWebKit ? 'w-resize' : 'col-resize';
+ header = e.getTarget('em', 3, true);
+ if(header){
+ var region = header.getRegion(),
+ style = header.dom.style,
+ parentNode = header.dom.parentNode;
+
+ if(x - region.left <= handleWidth && parentNode != parentNode.parentNode.firstChild){
+ this.activeHd = Ext.get(parentNode.previousSibling.firstChild);
+ style.cursor = Ext.isWebKit ? 'e-resize' : 'col-resize';
+ } else if(region.right - x <= handleWidth && parentNode != parentNode.parentNode.lastChild.previousSibling){
+ this.activeHd = header;
+ style.cursor = Ext.isWebKit ? 'w-resize' : 'col-resize';
} else{
delete this.activeHd;
- ss.cursor = '';
+ style.cursor = '';
}
}
},
},
onStart: function(e){
- this.view.disableHeaders = true;
- this.proxy = this.view.el.createChild({cls:'x-list-resizer'});
- this.proxy.setHeight(this.view.el.getHeight());
-
- var x = this.tracker.getXY()[0],
- w = this.view.innerHd.getWidth();
-
- this.hdX = this.dragHd.getX();
- this.hdIndex = this.view.findHeaderIndex(this.dragHd);
-
- this.proxy.setX(this.hdX);
- this.proxy.setWidth(x-this.hdX);
-
- this.minWidth = w*this.minPct;
- this.maxWidth = w - (this.minWidth*(this.view.columns.length-1-this.hdIndex));
+
+ var me = this,
+ view = me.view,
+ dragHeader = me.dragHd,
+ x = me.tracker.getXY()[0];
+
+ me.proxy = view.el.createChild({cls:'x-list-resizer'});
+ me.dragX = dragHeader.getX();
+ me.headerIndex = view.findHeaderIndex(dragHeader);
+
+ me.headersDisabled = view.disableHeaders;
+ view.disableHeaders = true;
+
+ me.proxy.setHeight(view.el.getHeight());
+ me.proxy.setX(me.dragX);
+ me.proxy.setWidth(x - me.dragX);
+
+ this.setBoundaries();
+
+ },
+
+
+ setBoundaries: function(relativeX){
+ var view = this.view,
+ headerIndex = this.headerIndex,
+ width = view.innerHd.getWidth(),
+ relativeX = view.innerHd.getX(),
+ minWidth = Math.ceil(width * this.minPct),
+ maxWidth = width - minWidth,
+ numColumns = view.columns.length,
+ headers = view.innerHd.select('em', true),
+ minX = minWidth + relativeX,
+ maxX = maxWidth + relativeX,
+ header;
+
+ if (numColumns == 2) {
+ this.minX = minX;
+ this.maxX = maxX;
+ }else{
+ header = headers.item(headerIndex + 2);
+ this.minX = headers.item(headerIndex).getX() + minWidth;
+ this.maxX = header ? header.getX() - minWidth : maxX;
+ if (headerIndex == 0) {
+
+ this.minX = minX;
+ } else if (headerIndex == numColumns - 2) {
+
+ this.maxX = maxX;
+ }
+ }
},
onDrag: function(e){
- var cursorX = this.tracker.getXY()[0];
- this.proxy.setWidth((cursorX-this.hdX).constrain(this.minWidth, this.maxWidth));
+ var me = this,
+ cursorX = me.tracker.getXY()[0].constrain(me.minX, me.maxX);
+
+ me.proxy.setWidth(cursorX - this.dragX);
},
onEnd: function(e){
- var nw = this.proxy.getWidth();
+ var newWidth = this.proxy.getWidth(),
+ index = this.headerIndex,
+ view = this.view,
+ columns = view.columns,
+ width = view.innerHd.getWidth(),
+ newPercent = Math.ceil(newWidth * view.maxColumnWidth / width) / 100,
+ disabled = this.headersDisabled,
+ headerCol = columns[index],
+ otherCol = columns[index + 1],
+ totalPercent = headerCol.width + otherCol.width;
+
this.proxy.remove();
- var index = this.hdIndex,
- vw = this.view,
- cs = vw.columns,
- len = cs.length,
- w = this.view.innerHd.getWidth(),
- minPct = this.minPct * 100,
- pct = Math.ceil((nw * vw.maxWidth) / w),
- diff = (cs[index].width * 100) - pct,
- eachItem = Math.floor(diff / (len-1-index)),
- mod = diff - (eachItem * (len-1-index));
-
- for(var i = index+1; i < len; i++){
- var cw = (cs[i].width * 100) + eachItem,
- ncw = Math.max(minPct, cw);
- if(cw != ncw){
- mod += cw - ncw;
- }
- cs[i].width = ncw / 100;
- }
- cs[index].width = pct / 100;
- cs[index+1].width += (mod / 100);
+ headerCol.width = newPercent;
+ otherCol.width = totalPercent - newPercent;
+
delete this.dragHd;
- vw.setHdWidths();
- vw.refresh();
+ view.setHdWidths();
+ view.refresh();
+
setTimeout(function(){
- vw.disableHeaders = false;
+ view.disableHeaders = disabled;
}, 100);
}
});
delegateUpdates : function(){
+ var rendered = this.rendered;
if(this.suspendUpdates){
return;
}
- if(this.resizeTabs && this.rendered){
+ if(this.resizeTabs && rendered){
this.autoSizeTabs();
}
- if(this.enableTabScroll && this.rendered){
+ if(this.enableTabScroll && rendered){
this.autoScrollTabs();
}
},
this.stack.add(item);
this.layout.setActiveItem(item);
+
+ this.delegateUpdates();
if(this.scrolling){
this.scrollToTab(item, this.animScroll);
}
pos = this.getScrollPos(),
l = this.edge.getOffsetsTo(this.stripWrap)[0] + pos;
- if(!this.enableTabScroll || count < 1 || cw < 20){
+ if(!this.enableTabScroll || cw < 20){
return;
}
- if(l <= tw){
+ if(count == 0 || l <= tw){
+
wd.scrollLeft = 0;
wrap.setWidth(tw);
if(this.scrolling){
initComponent : function(){
+ if(this.menu){
+ this.menu = Ext.menu.MenuMgr.get(this.menu);
+ this.menu.ownerCt = this;
+ }
+
Ext.Button.superclass.initComponent.call(this);
this.addEvents(
'menutriggerout'
);
- if(this.menu){
- this.menu = Ext.menu.MenuMgr.get(this.menu);
+
+ if (this.menu){
+ this.menu.ownerCt = undefined;
}
if(Ext.isString(this.toggleGroup)){
this.enableToggle = true;
if(this.repeat){
var repeater = new Ext.util.ClickRepeater(btn, Ext.isObject(this.repeat) ? this.repeat : {});
- this.mon(repeater, 'click', this.onClick, this);
+ this.mon(repeater, 'click', this.onRepeatClick, this);
+ }else{
+ this.mon(btn, this.clickEvent, this.onClick, this);
}
- this.mon(btn, this.clickEvent, this.onClick, this);
},
this.clearTip();
}
if(this.menu && this.destroyMenu !== false) {
- Ext.destroy(this.menu);
+ Ext.destroy(this.btnEl, this.menu);
}
Ext.destroy(this.repeater);
},
hasVisibleMenu : function(){
return this.menu && this.menu.ownerCt == this && this.menu.isVisible();
},
+
+
+ onRepeatClick : function(repeat, e){
+ this.onClick(e);
+ },
onClick : function(e){
return;
}
if(!this.disabled){
- if(this.enableToggle && (this.allowDepress !== false || !this.pressed)){
- this.toggle();
- }
+ this.doToggle();
if(this.menu && !this.hasVisibleMenu() && !this.ignoreNextClick){
this.showMenu();
}
}
}
},
+
+
+ doToggle: function(){
+ if (this.enableToggle && (this.allowDepress !== false || !this.pressed)) {
+ this.toggle();
+ }
+ },
isMenuTriggerOver : function(e, internal){
this.arrowHandler.call(this.scope || this, this, e);
}
}else{
- if(this.enableToggle){
- this.toggle();
- }
+ this.doToggle();
this.fireEvent("click", this, e);
if(this.handler){
this.handler.call(this.scope || this, this, e);
onRemove : function(c){
Ext.Toolbar.superclass.onRemove.call(this);
+ if (c == this.activeMenuBtn) {
+ delete this.activeMenuBtn;
+ }
this.trackMenu(c, true);
},
var currentToken;
function getHash() {
- var href = top.location.href, i = href.indexOf("#");
+ var href = location.href, i = href.indexOf("#");
return i >= 0 ? href.substr(i + 1) : null;
}
afterRender : function(){
Ext.ToolTip.superclass.afterRender.call(this);
- this.anchorEl.setStyle('z-index', this.el.getZIndex() + 1);
+ this.anchorEl.setStyle('z-index', this.el.getZIndex() + 1).setVisibilityMode(Ext.Element.DISPLAY);
},
this.showAt(this.getTargetXY());
if(this.anchor){
- this.syncAnchor();
this.anchorEl.show();
+ this.syncAnchor();
this.constrainPosition = this.origConstrainPosition;
}else{
this.anchorEl.hide();
if(this.anchor && !this.anchorEl.isVisible()){
this.syncAnchor();
this.anchorEl.show();
+ }else{
+ this.anchorEl.hide();
}
},
});
Ext.reg('quicktip', Ext.QuickTip);
Ext.QuickTips = function(){
- var tip, locks = [];
+ var tip,
+ disabled = false;
+
return {
init : function(autoRender){
});
return;
}
- tip = new Ext.QuickTip({elements:'header,body'});
+ tip = new Ext.QuickTip({
+ elements:'header,body',
+ disabled: disabled
+ });
if(autoRender !== false){
tip.render(Ext.getBody());
}
}
},
+
+
+ ddDisable : function(){
+
+ if(tip && !disabled){
+ tip.disable();
+ }
+ },
+
+
+ ddEnable : function(){
+
+ if(tip && !disabled){
+ tip.enable();
+ }
+ },
enable : function(){
if(tip){
- locks.pop();
- if(locks.length < 1){
- tip.enable();
- }
+ tip.enable();
}
+ disabled = false;
},
if(tip){
tip.disable();
}
- locks.push(1);
+ disabled = true;
},
},
- tips :function(){
+ tips : function(){
tip.register.apply(tip, arguments);
}
- }
+ };
}();
Ext.slider.Tip = Ext.extend(Ext.Tip, {
minWidth: 10,
expandPath : function(path, attr, callback){
+ if(Ext.isEmpty(path)){
+ if(callback){
+ callback(false, undefined);
+ }
+ return;
+ }
attr = attr || 'id';
var keys = path.split(this.pathSeparator);
var curNode = this.root;
selectPath : function(path, attr, callback){
+ if(Ext.isEmpty(path)){
+ if(callback){
+ callback(false, undefined);
+ }
+ return;
+ }
attr = attr || 'id';
var keys = path.split(this.pathSeparator),
v = keys.pop();
selectPrevious : Ext.tree.DefaultSelectionModel.prototype.selectPrevious
});
-Ext.data.Tree = function(root){
- this.nodeHash = {};
-
- this.root = null;
- if(root){
- this.setRootNode(root);
- }
- this.addEvents(
-
- "append",
-
- "remove",
-
- "move",
-
- "insert",
-
- "beforeappend",
-
- "beforeremove",
-
- "beforemove",
-
- "beforeinsert"
- );
-
- Ext.data.Tree.superclass.constructor.call(this);
-};
-
-Ext.extend(Ext.data.Tree, Ext.util.Observable, {
+Ext.data.Tree = Ext.extend(Ext.util.Observable, {
+
+ constructor: function(root){
+ this.nodeHash = {};
+
+ this.root = null;
+ if(root){
+ this.setRootNode(root);
+ }
+ this.addEvents(
+
+ "append",
+
+ "remove",
+
+ "move",
+
+ "insert",
+
+ "beforeappend",
+
+ "beforeremove",
+
+ "beforemove",
+
+ "beforeinsert"
+ );
+ Ext.data.Tree.superclass.constructor.call(this);
+ },
+
pathSeparator: "/",
});
-Ext.data.Node = function(attributes){
-
- this.attributes = attributes || {};
- this.leaf = this.attributes.leaf;
-
- this.id = this.attributes.id;
- if(!this.id){
- this.id = Ext.id(null, "xnode-");
- this.attributes.id = this.id;
- }
+Ext.data.Node = Ext.extend(Ext.util.Observable, {
- this.childNodes = [];
- if(!this.childNodes.indexOf){
- this.childNodes.indexOf = function(o){
- for(var i = 0, len = this.length; i < len; i++){
- if(this[i] == o){
- return i;
- }
- }
- return -1;
- };
- }
-
- this.parentNode = null;
-
- this.firstChild = null;
-
- this.lastChild = null;
-
- this.previousSibling = null;
-
- this.nextSibling = null;
-
- this.addEvents({
-
- "append" : true,
-
- "remove" : true,
-
- "move" : true,
-
- "insert" : true,
-
- "beforeappend" : true,
-
- "beforeremove" : true,
-
- "beforemove" : true,
-
- "beforeinsert" : true
- });
- this.listeners = this.attributes.listeners;
- Ext.data.Node.superclass.constructor.call(this);
-};
+ constructor: function(attributes){
+
+ this.attributes = attributes || {};
+ this.leaf = this.attributes.leaf;
+
+ this.id = this.attributes.id;
+ if(!this.id){
+ this.id = Ext.id(null, "xnode-");
+ this.attributes.id = this.id;
+ }
+
+ this.childNodes = [];
+
+ this.parentNode = null;
+
+ this.firstChild = null;
+
+ this.lastChild = null;
+
+ this.previousSibling = null;
+
+ this.nextSibling = null;
-Ext.extend(Ext.data.Node, Ext.util.Observable, {
+ this.addEvents({
+
+ "append" : true,
+
+ "remove" : true,
+
+ "move" : true,
+
+ "insert" : true,
+
+ "beforeappend" : true,
+
+ "beforeremove" : true,
+
+ "beforemove" : true,
+
+ "beforeinsert" : true
+ });
+ this.listeners = this.attributes.listeners;
+ Ext.data.Node.superclass.constructor.call(this);
+ },
+
fireEvent : function(evtName){
eachChild : function(fn, scope, args){
var cs = this.childNodes;
for(var i = 0, len = cs.length; i < len; i++) {
- if(fn.apply(scope || this, args || [cs[i]]) === false){
+ if(fn.apply(scope || cs[i], args || [cs[i]]) === false){
break;
}
}
return "[Node"+(this.id?" "+this.id:"")+"]";
}
});
-Ext.tree.TreeNode = function(attributes){
- attributes = attributes || {};
- if(Ext.isString(attributes)){
- attributes = {text: attributes};
- }
- this.childrenRendered = false;
- this.rendered = false;
- Ext.tree.TreeNode.superclass.constructor.call(this, attributes);
- this.expanded = attributes.expanded === true;
- this.isTarget = attributes.isTarget !== false;
- this.draggable = attributes.draggable !== false && attributes.allowDrag !== false;
- this.allowChildren = attributes.allowChildren !== false && attributes.allowDrop !== false;
-
-
- this.text = attributes.text;
-
- this.disabled = attributes.disabled === true;
+Ext.tree.TreeNode = Ext.extend(Ext.data.Node, {
- this.hidden = attributes.hidden === true;
+ constructor : function(attributes){
+ attributes = attributes || {};
+ if(Ext.isString(attributes)){
+ attributes = {text: attributes};
+ }
+ this.childrenRendered = false;
+ this.rendered = false;
+ Ext.tree.TreeNode.superclass.constructor.call(this, attributes);
+ this.expanded = attributes.expanded === true;
+ this.isTarget = attributes.isTarget !== false;
+ this.draggable = attributes.draggable !== false && attributes.allowDrag !== false;
+ this.allowChildren = attributes.allowChildren !== false && attributes.allowDrop !== false;
- this.addEvents(
-
- 'textchange',
- 'beforeexpand',
+ this.text = attributes.text;
- 'beforecollapse',
+ this.disabled = attributes.disabled === true;
- 'expand',
-
- 'disabledchange',
-
- 'collapse',
-
- 'beforeclick',
-
- 'click',
-
- 'checkchange',
-
- 'beforedblclick',
-
- 'dblclick',
-
- 'contextmenu',
+ this.hidden = attributes.hidden === true;
+
+ this.addEvents(
+
+ 'textchange',
+
+ 'beforeexpand',
+
+ 'beforecollapse',
+
+ 'expand',
+
+ 'disabledchange',
+
+ 'collapse',
+
+ 'beforeclick',
+
+ 'click',
+
+ 'checkchange',
+
+ 'beforedblclick',
+
+ 'dblclick',
+
+ 'contextmenu',
+
+ 'beforechildrenrendered'
+ );
+
+ var uiClass = this.attributes.uiProvider || this.defaultUI || Ext.tree.TreeNodeUI;
+
- 'beforechildrenrendered'
- );
-
- var uiClass = this.attributes.uiProvider || this.defaultUI || Ext.tree.TreeNodeUI;
-
+ this.ui = new uiClass(this);
+ },
- this.ui = new uiClass(this);
-};
-Ext.extend(Ext.tree.TreeNode, Ext.data.Node, {
preventHScroll : true,
isExpanded : function(){
Ext.tree.TreeNode.superclass.removeChild.apply(this, arguments);
if(!destroy){
+ var rendered = node.ui.rendered;
- if(node.ui.rendered){
+ if(rendered){
node.ui.remove();
}
- if(this.childNodes.length < 1){
+ if(rendered && this.childNodes.length < 1){
this.collapse(false, false);
}else{
this.ui.updateExpandIcon();
}
this.fireEvent('textchange', this, text, oldText);
},
+
+
+ setIconCls : function(cls){
+ var old = this.attributes.iconCls;
+ this.attributes.iconCls = cls;
+ if(this.rendered){
+ this.ui.onIconClsChange(this, cls, old);
+ }
+ },
+
+
+ setTooltip : function(tip, title){
+ this.attributes.qtip = tip;
+ this.attributes.qtipTitle = title;
+ if(this.rendered){
+ this.ui.onTipChange(this, tip, title);
+ }
+ },
+
+
+ setIcon : function(icon){
+ this.attributes.icon = icon;
+ if(this.rendered){
+ this.ui.onIconChange(this, icon);
+ }
+ },
+
+
+ setHref : function(href, target){
+ this.attributes.href = href;
+ this.attributes.hrefTarget = target;
+ if(this.rendered){
+ this.ui.onHrefChange(this, href, target);
+ }
+ },
+
+
+ setCls : function(cls){
+ var old = this.attributes.cls;
+ this.attributes.cls = cls;
+ if(this.rendered){
+ this.ui.onClsChange(this, cls, old);
+ }
+ },
select : function(){
this.fireEvent('expand', this);
this.runCallback(callback, scope || this, [this]);
if(deep === true){
- this.expandChildNodes(true);
+ this.expandChildNodes(true, true);
}
}.createDelegate(this));
return;
},
- expandChildNodes : function(deep){
- var cs = this.childNodes;
- for(var i = 0, len = cs.length; i < len; i++) {
- cs[i].expand(deep);
+ expandChildNodes : function(deep, anim) {
+ var cs = this.childNodes,
+ i,
+ len = cs.length;
+ for (i = 0; i < len; i++) {
+ cs[i].expand(deep, anim);
}
},
});
Ext.tree.TreePanel.nodeTypes.async = Ext.tree.AsyncTreeNode;
-Ext.tree.TreeNodeUI = function(node){
- this.node = node;
- this.rendered = false;
- this.animating = false;
- this.wasLeaf = true;
- this.ecc = 'x-tree-ec-icon x-tree-elbow';
- this.emptyIcon = Ext.BLANK_IMAGE_URL;
-};
-
-Ext.tree.TreeNodeUI.prototype = {
+Ext.tree.TreeNodeUI = Ext.extend(Object, {
+
+ constructor : function(node){
+ Ext.apply(this, {
+ node: node,
+ rendered: false,
+ animating: false,
+ wasLeaf: true,
+ ecc: 'x-tree-ec-icon x-tree-elbow',
+ emptyIcon: Ext.BLANK_IMAGE_URL
+ });
+ },
+
removeChild : function(node){
if(this.rendered){
this.textNode.innerHTML = text;
}
},
+
+
+ onIconClsChange : function(node, cls, oldCls){
+ if(this.rendered){
+ Ext.fly(this.iconNode).replaceClass(oldCls, cls);
+ }
+ },
+
+
+ onIconChange : function(node, icon){
+ if(this.rendered){
+
+ var empty = Ext.isEmpty(icon);
+ this.iconNode.src = empty ? this.emptyIcon : icon;
+ Ext.fly(this.iconNode)[empty ? 'removeClass' : 'addClass']('x-tree-node-inline-icon');
+ }
+ },
+
+
+ onTipChange : function(node, tip, title){
+ if(this.rendered){
+ var hasTitle = Ext.isDefined(title);
+ if(this.textNode.setAttributeNS){
+ this.textNode.setAttributeNS("ext", "qtip", tip);
+ if(hasTitle){
+ this.textNode.setAttributeNS("ext", "qtitle", title);
+ }
+ }else{
+ this.textNode.setAttribute("ext:qtip", tip);
+ if(hasTitle){
+ this.textNode.setAttribute("ext:qtitle", title);
+ }
+ }
+ }
+ },
+
+
+ onHrefChange : function(node, href, target){
+ if(this.rendered){
+ this.anchor.href = this.getHref(href);
+ if(Ext.isDefined(target)){
+ this.anchor.target = target;
+ }
+ }
+ },
+
+
+ onClsChange : function(node, cls, oldCls){
+ if(this.rendered){
+ Ext.fly(this.elNode).replaceClass(oldCls, cls);
+ }
+ },
onDisableChange : function(node, state){
if (this.checkbox) {
this.checkbox.disabled = state;
}
- if(state){
- this.addClass("x-tree-node-disabled");
- }else{
- this.removeClass("x-tree-node-disabled");
- }
+ this[state ? 'addClass' : 'removeClass']('x-tree-node-disabled');
},
this.renderElements(n, a, targetNode, bulkRender);
if(a.qtip){
- if(this.textNode.setAttributeNS){
- this.textNode.setAttributeNS("ext", "qtip", a.qtip);
- if(a.qtipTitle){
- this.textNode.setAttributeNS("ext", "qtitle", a.qtipTitle);
- }
- }else{
- this.textNode.setAttribute("ext:qtip", a.qtip);
- if(a.qtipTitle){
- this.textNode.setAttribute("ext:qtitle", a.qtipTitle);
- }
- }
+ this.onTipChange(n, a.qtip, a.qtipTitle);
}else if(a.qtipCfg){
a.qtipCfg.target = Ext.id(this.textNode);
Ext.QuickTips.register(a.qtipCfg);
var cb = Ext.isBoolean(a.checked),
nel,
- href = a.href ? a.href : Ext.isGecko ? "" : "#",
+ href = this.getHref(a.href),
buf = ['<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf x-unselectable ', a.cls,'" unselectable="on">',
'<span class="x-tree-node-indent">',this.indentMarkup,"</span>",
- '<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow" />',
- '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon',(a.icon ? " x-tree-node-inline-icon" : ""),(a.iconCls ? " "+a.iconCls : ""),'" unselectable="on" />',
+ '<img alt="" src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow" />',
+ '<img alt="" src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon',(a.icon ? " x-tree-node-inline-icon" : ""),(a.iconCls ? " "+a.iconCls : ""),'" unselectable="on" />',
cb ? ('<input class="x-tree-node-cb" type="checkbox" ' + (a.checked ? 'checked="checked" />' : '/>')) : '',
'<a hidefocus="on" class="x-tree-node-anchor" href="',href,'" tabIndex="1" ',
a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "", '><span unselectable="on">',n.text,"</span></a></div>",
this.anchor = cs[index];
this.textNode = cs[index].firstChild;
},
+
+
+ getHref : function(href){
+ return Ext.isEmpty(href) ? (Ext.isGecko ? '' : '#') : href;
+ },
getAnchor : function(){
while(p){
if(!p.isRoot || (p.isRoot && p.ownerTree.rootVisible)){
if(!p.isLast()) {
- buf.unshift('<img src="'+this.emptyIcon+'" class="x-tree-elbow-line" />');
+ buf.unshift('<img alt="" src="'+this.emptyIcon+'" class="x-tree-elbow-line" />');
} else {
- buf.unshift('<img src="'+this.emptyIcon+'" class="x-tree-icon" />');
+ buf.unshift('<img alt="" src="'+this.emptyIcon+'" class="x-tree-icon" />');
}
}
p = p.parentNode;
}, this);
delete this.node;
}
-};
+});
Ext.tree.RootTreeNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
}
};
-Ext.tree.TreeSorter = function(tree, config){
+Ext.tree.TreeSorter = Ext.extend(Object, {
+ constructor: function(tree, config){
+
Ext.apply(this, config);
- tree.on("beforechildrenrendered", this.doSort, this);
- tree.on("append", this.updateSort, this);
- tree.on("insert", this.updateSort, this);
- tree.on("textchange", this.updateSortParent, this);
-
- var dsc = this.dir && this.dir.toLowerCase() == "desc";
- var p = this.property || "text";
- var sortType = this.sortType;
- var fs = this.folderSort;
- var cs = this.caseSensitive === true;
- var leafAttr = this.leafAttr || 'leaf';
+ tree.on({
+ scope: this,
+ beforechildrenrendered: this.doSort,
+ append: this.updateSort,
+ insert: this.updateSort,
+ textchange: this.updateSortParent
+ });
+ var desc = this.dir && this.dir.toLowerCase() == 'desc',
+ prop = this.property || 'text';
+ sortType = this.sortType;
+ folderSort = this.folderSort;
+ caseSensitive = this.caseSensitive === true;
+ leafAttr = this.leafAttr || 'leaf';
+
+ if(Ext.isString(sortType)){
+ sortType = Ext.data.SortTypes[sortType];
+ }
this.sortFn = function(n1, n2){
- if(fs){
- if(n1.attributes[leafAttr] && !n2.attributes[leafAttr]){
+ var attr1 = n1.attributes,
+ attr2 = n2.attributes;
+
+ if(folderSort){
+ if(attr1[leafAttr] && !attr2[leafAttr]){
return 1;
}
- if(!n1.attributes[leafAttr] && n2.attributes[leafAttr]){
+ if(!attr1[leafAttr] && attr2[leafAttr]){
return -1;
}
}
- var v1 = sortType ? sortType(n1) : (cs ? n1.attributes[p] : n1.attributes[p].toUpperCase());
- var v2 = sortType ? sortType(n2) : (cs ? n2.attributes[p] : n2.attributes[p].toUpperCase());
+ var prop1 = attr1[prop],
+ prop2 = attr2[prop],
+ v1 = sortType ? sortType(prop1) : (caseSensitive ? prop1 : prop1.toUpperCase());
+ v2 = sortType ? sortType(prop2) : (caseSensitive ? prop2 : prop2.toUpperCase());
+
if(v1 < v2){
- return dsc ? +1 : -1;
+ return desc ? 1 : -1;
}else if(v1 > v2){
- return dsc ? -1 : +1;
- }else{
- return 0;
+ return desc ? -1 : 1;
}
+ return 0;
};
-};
-
-Ext.tree.TreeSorter.prototype = {
+ },
+
doSort : function(node){
node.sort(this.sortFn);
},
- compareNodes : function(n1, n2){
- return (n1.text.toUpperCase() > n2.text.toUpperCase() ? 1 : -1);
- },
-
updateSort : function(tree, node){
if(node.childrenRendered){
this.doSort.defer(1, this, [node]);
if(p && p.childrenRendered){
this.doSort.defer(1, this, [p]);
}
- }
-};
+ }
+});
if(Ext.dd.DropZone){
Ext.tree.TreeDropZone = function(tree, config){
var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
u = nav.userAgent.toLowerCase(),
p = nav.platform.toLowerCase(),
- windows = p ? /win/.test(p) : /win/.test(u),
- mac = p ? /mac/.test(p) : /mac/.test(u),
+ windows = p ? (/win/).test(p) : /win/.test(u),
+ mac = p ? (/mac/).test(p) : /mac/.test(u),
webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false,
ie = !+"\v1",
playerVersion = [0,0,0],
if (ua.wk) {
(function(){
if (isDomLoaded) { return; }
- if (!/loaded|complete/.test(doc.readyState)) {
+ if (!(/loaded|complete/).test(doc.readyState)) {
setTimeout(arguments.callee, 0);
return;
}
storedAltContentId = replaceElemIdStr;
}
att.id = EXPRESS_INSTALL_ID;
- if (typeof att.width == UNDEF || (!/%$/.test(att.width) && parseInt(att.width, 10) < 310)) { att.width = "310"; }
- if (typeof att.height == UNDEF || (!/%$/.test(att.height) && parseInt(att.height, 10) < 137)) { att.height = "137"; }
+ if (typeof att.width == UNDEF || (!(/%$/).test(att.width) && parseInt(att.width, 10) < 310)) {
+ att.width = "310";
+ }
+
+ if (typeof att.height == UNDEF || (!(/%$/).test(att.height) && parseInt(att.height, 10) < 137)) {
+ att.height = "137";
+ }
doc.title = doc.title.slice(0, 47) + " - Flash Player Installation";
var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn",
fv = "MMredirectURL=" + win.location.toString().replace(/&/g,"%26") + "&MMplayerType=" + pt + "&MMdoctitle=" + doc.title;
return {
fn: val.fn,
scope: val.scope || this
- }
+ };
}
},
Ext.chart.Chart.proxyFunction = {};
-Ext.chart.Chart.CHART_URL = 'http:/' + '/yui.yahooapis.com/2.8.0/build/charts/assets/charts.swf';
+Ext.chart.Chart.CHART_URL = 'http:/' + '/yui.yahooapis.com/2.8.2/build/charts/assets/charts.swf';
Ext.chart.PieChart = Ext.extend(Ext.chart.Chart, {
var items = this.items;
for(var i = start, len = items.length; i >= 0 && i < len; i+= step){
var item = items.get(i);
- if(!item.disabled && (item.canActivate || item.isFormField)){
+ if(item.isVisible() && !item.disabled && (item.canActivate || item.isFormField)){
this.setActiveItem(item, false);
return item;
}
return c;
},
- applyDefaults : function(c){
- if(!Ext.isString(c)){
+ applyDefaults : function(c) {
+ if (!Ext.isString(c)) {
c = Ext.menu.Menu.superclass.applyDefaults.call(this, c);
var d = this.internalDefaults;
if(d){
},
- getMenuItem : function(config){
- if(!config.isXType){
- if(!config.xtype && Ext.isBoolean(config.checked)){
- return new Ext.menu.CheckItem(config)
+ getMenuItem : function(config) {
+ if (!config.isXType) {
+ if (!config.xtype && Ext.isBoolean(config.checked)) {
+ return new Ext.menu.CheckItem(config);
}
return Ext.create(config, this.defaultType);
}
},
- addSeparator : function(){
+ addSeparator : function() {
return this.add(new Ext.menu.Separator());
},
- addElement : function(el){
+ addElement : function(el) {
return this.add(new Ext.menu.BaseItem({
el: el
}));
},
- addItem : function(item){
+ addItem : function(item) {
return this.add(item);
},
- addMenuItem : function(config){
+ addMenuItem : function(config) {
return this.add(this.getMenuItem(config));
},
}
}
-
- function onBeforeCheck(mi, state){
- if(state){
- var g = groups[mi.group];
- for(var i = 0, l = g.length; i < l; i++){
- if(g[i] != mi){
- g[i].setChecked(false);
- }
- }
- }
- }
-
return {
groups[g] = [];
}
groups[g].push(menuItem);
- menuItem.on("beforecheckchange", onBeforeCheck);
}
},
var g = menuItem.group;
if(g){
groups[g].remove(menuItem);
- menuItem.un("beforecheckchange", onBeforeCheck);
+ }
+ },
+
+
+ onCheckChange: function(item, state){
+ if(item.group && state){
+ var group = groups[item.group],
+ i = 0,
+ len = group.length,
+ current;
+
+ for(; i < len; i++){
+ current = group[i];
+ if(current != item){
+ current.setChecked(false);
+ }
+ }
}
},
itemCls : "x-menu-text",
- constructor : function(config){
- if(typeof config == 'string'){
- config = {text: config}
+ constructor : function(config) {
+ if (typeof config == 'string') {
+ config = {
+ text: config
+ };
}
Ext.menu.TextItem.superclass.constructor.call(this, config);
},
- onRender : function(){
+ onRender : function() {
var s = document.createElement("span");
s.className = this.itemCls;
s.innerHTML = this.text;
showDelay: 200,
+
+ altText: '',
+
+
hideDelay: 200,
' target="{hrefTarget}"',
'</tpl>',
'>',
- '<img src="{icon}" class="x-menu-item-icon {iconCls}"/>',
+ '<img alt="{altText}" src="{icon}" class="x-menu-item-icon {iconCls}"/>',
'<span class="x-menu-item-text">{text}</span>',
'</a>'
);
hrefTarget: this.hrefTarget,
icon: this.icon || Ext.BLANK_IMAGE_URL,
iconCls: this.iconCls || '',
- text: this.itemText||this.text||' '
+ text: this.itemText||this.text||' ',
+ altText: this.altText || ''
};
},
setChecked : function(state, suppressEvent){
var suppress = suppressEvent === true;
if(this.checked != state && (suppress || this.fireEvent("beforecheckchange", this, state) !== false)){
+ Ext.menu.MenuMgr.onCheckChange(this, state);
if(this.container){
this.container[state ? "addClass" : "removeClass"]("x-menu-item-checked");
}
initEvents : function(){
- this.mon(this.el, Ext.EventManager.useKeydown ? 'keydown' : 'keypress', this.fireKey, this);
+ this.mon(this.el, Ext.EventManager.getKeyEvent(), this.fireKey, this);
this.mon(this.el, 'focus', this.onFocus, this);
preFocus : function(){
- var el = this.el;
+ var el = this.el,
+ isEmpty;
if(this.emptyText){
if(el.dom.value == this.emptyText){
this.setRawValue('');
+ isEmpty = true;
}
el.removeClass(this.emptyClass);
}
- if(this.selectOnFocus){
+ if(this.selectOnFocus || isEmpty){
el.dom.select();
}
},
getErrors: function(value) {
var errors = Ext.form.TextField.superclass.getErrors.apply(this, arguments);
- value = value || this.processValue(this.getRawValue());
+ value = Ext.isDefined(value) ? value : this.processValue(this.getRawValue());
if (Ext.isFunction(this.validator)) {
var msg = this.validator(value);
this.wrap = this.el.wrap({cls: 'x-form-field-wrap x-form-field-trigger-wrap'});
this.trigger = this.wrap.createChild(this.triggerConfig ||
- {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.triggerClass});
+ {tag: "img", src: Ext.BLANK_IMAGE_URL, alt: "", cls: "x-form-trigger " + this.triggerClass});
this.initTrigger();
if(!this.width){
this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
}
},
+
setHideTrigger: function(hideTrigger){
if(hideTrigger != this.hideTrigger){
this.hideTrigger = hideTrigger;
this.triggerConfig = {
tag:'span', cls:'x-form-twin-triggers', cn:[
- {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.trigger1Class},
- {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.trigger2Class}
+ {tag: "img", src: Ext.BLANK_IMAGE_URL, alt: "", cls: "x-form-trigger " + this.trigger1Class},
+ {tag: "img", src: Ext.BLANK_IMAGE_URL, alt: "", cls: "x-form-trigger " + this.trigger2Class}
]};
},
getTrigger : function(index){
return this.triggers[index];
},
+
+ afterRender: function(){
+ Ext.form.TwinTriggerField.superclass.afterRender.call(this);
+ var triggers = this.triggers,
+ i = 0,
+ len = triggers.length;
+
+ for(; i < len; ++i){
+ if(this['hideTrigger' + (i + 1)]){
+ triggers[i].hide();
+ }
+
+ }
+ },
initTrigger : function(){
- var ts = this.trigger.select('.x-form-trigger', true);
- var triggerField = this;
+ var ts = this.trigger.select('.x-form-trigger', true),
+ triggerField = this;
+
ts.each(function(t, all, index){
var triggerIndex = 'Trigger'+(index+1);
t.hide = function(){
var w = triggerField.wrap.getWidth();
this.dom.style.display = 'none';
triggerField.el.setWidth(w-triggerField.trigger.getWidth());
- this['hidden' + triggerIndex] = true;
+ triggerField['hidden' + triggerIndex] = true;
};
t.show = function(){
var w = triggerField.wrap.getWidth();
this.dom.style.display = '';
triggerField.el.setWidth(w-triggerField.trigger.getWidth());
- this['hidden' + triggerIndex] = false;
+ triggerField['hidden' + triggerIndex] = false;
};
-
- if(this['hide'+triggerIndex]){
- t.dom.style.display = 'none';
- this['hidden' + triggerIndex] = true;
- }
this.mon(t, 'click', this['on'+triggerIndex+'Click'], this, {preventDefault:true});
t.addClassOnOver('x-form-trigger-over');
t.addClassOnClick('x-form-trigger-click');
doAutoSize : function(e){
return !e.isNavKeyPress() || e.getKey() == e.ENTER;
},
+
+
+ filterValidation: function(e) {
+ if(!e.isNavKeyPress() || (!this.enterIsSpecial && e.keyCode == e.ENTER)){
+ this.validationTask.delay(this.validationDelay);
+ }
+ },
autoSize: function(){
fieldClass: "x-form-field x-form-num-field",
+
allowDecimals : true,
+
decimalSeparator : ".",
+
decimalPrecision : 2,
+
allowNegative : true,
+
minValue : Number.NEGATIVE_INFINITY,
+
maxValue : Number.MAX_VALUE,
+
minText : "The minimum value for this field is {0}",
+
maxText : "The maximum value for this field is {0}",
+
nanText : "{0} is not a valid number",
+
baseChars : "0123456789",
+
+
+ autoStripChars: false,
- initEvents : function(){
+ initEvents : function() {
var allowed = this.baseChars + '';
if (this.allowDecimals) {
allowed += this.decimalSeparator;
if (this.allowNegative) {
allowed += '-';
}
- this.maskRe = new RegExp('[' + Ext.escapeRe(allowed) + ']');
+ allowed = Ext.escapeRe(allowed);
+ this.maskRe = new RegExp('[' + allowed + ']');
+ if (this.autoStripChars) {
+ this.stripCharsRe = new RegExp('[^' + allowed + ']', 'gi');
+ }
+
Ext.form.NumberField.superclass.initEvents.call(this);
},
getErrors: function(value) {
var errors = Ext.form.NumberField.superclass.getErrors.apply(this, arguments);
- value = value || this.processValue(this.getRawValue());
+ value = Ext.isDefined(value) ? value : this.processValue(this.getRawValue());
if (value.length < 1) {
return errors;
var num = this.parseValue(value);
- if(num < this.minValue){
+ if (num < this.minValue) {
errors.push(String.format(this.minText, this.minValue));
}
- if(num > this.maxValue){
+ if (num > this.maxValue) {
errors.push(String.format(this.maxText, this.maxValue));
}
return errors;
},
- getValue : function(){
+ getValue : function() {
return this.fixPrecision(this.parseValue(Ext.form.NumberField.superclass.getValue.call(this)));
},
- setValue : function(v){
+ setValue : function(v) {
+ v = this.fixPrecision(v);
v = Ext.isNumber(v) ? v : parseFloat(String(v).replace(this.decimalSeparator, "."));
v = isNaN(v) ? '' : String(v).replace(".", this.decimalSeparator);
return Ext.form.NumberField.superclass.setValue.call(this, v);
},
- setMinValue : function(value){
+ setMinValue : function(value) {
this.minValue = Ext.num(value, Number.NEGATIVE_INFINITY);
},
- setMaxValue : function(value){
+ setMaxValue : function(value) {
this.maxValue = Ext.num(value, Number.MAX_VALUE);
},
- parseValue : function(value){
+ parseValue : function(value) {
value = parseFloat(String(value).replace(this.decimalSeparator, "."));
return isNaN(value) ? '' : value;
},
- fixPrecision : function(value){
+ fixPrecision : function(value) {
var nan = isNaN(value);
- if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
- return nan ? '' : value;
+
+ if (!this.allowDecimals || this.decimalPrecision == -1 || nan || !value) {
+ return nan ? '' : value;
}
+
return parseFloat(parseFloat(value).toFixed(this.decimalPrecision));
},
- beforeBlur : function(){
+ beforeBlur : function() {
var v = this.parseValue(this.getRawValue());
- if(!Ext.isEmpty(v)){
- this.setValue(this.fixPrecision(v));
+
+ if (!Ext.isEmpty(v)) {
+ this.setValue(v);
}
}
});
+
Ext.reg('numberfield', Ext.form.NumberField);
+
Ext.form.DateField = Ext.extend(Ext.form.TriggerField, {
format : "m/d/Y",
- altFormats : "m/d/Y|n/j/Y|n/j/y|m/j/y|n/d/y|m/j/Y|n/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d|Y-m-d",
+ altFormats : "m/d/Y|n/j/Y|n/j/y|m/j/y|n/d/y|m/j/Y|n/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d|Y-m-d|n-j|n/j",
disabledDaysText : "Disabled",
showToday : true,
+ startDay : 0,
+
+
+
} else {
var parsedDate = Date.parseDate(value + ' ' + this.initTime, format + ' ' + this.initTimeFormat);
-
- if (parsedDate) return parsedDate.clearTime();
+
+ if (parsedDate) {
+ return parsedDate.clearTime();
+ }
}
},
this.menu.picker.setMaxDate(this.maxValue);
}
},
-
+
getErrors: function(value) {
var errors = Ext.form.DateField.superclass.getErrors.apply(this, arguments);
-
+
value = this.formatDate(value || this.processValue(this.getRawValue()));
-
+
if (value.length < 1) {
return errors;
}
-
+
var svalue = value;
value = this.parseDate(value);
if (!value) {
errors.push(String.format(this.invalidText, svalue, this.format));
return errors;
}
-
+
var time = value.getTime();
- if (this.minValue && time < this.minValue.getTime()) {
+ if (this.minValue && time < this.minValue.clearTime().getTime()) {
errors.push(String.format(this.minText, this.formatDate(this.minValue)));
}
-
- if (this.maxValue && time > this.maxValue.getTime()) {
+
+ if (this.maxValue && time > this.maxValue.clearTime().getTime()) {
errors.push(String.format(this.maxText, this.formatDate(this.maxValue)));
}
-
+
if (this.disabledDays) {
var day = value.getDay();
-
+
for(var i = 0; i < this.disabledDays.length; i++) {
if (day === this.disabledDays[i]) {
errors.push(this.disabledDaysText);
}
}
}
-
+
var fvalue = this.formatDate(value);
if (this.disabledDatesRE && this.disabledDatesRE.test(fvalue)) {
errors.push(String.format(this.disabledDatesText, fvalue));
}
-
+
return errors;
},
disabledDaysText : this.disabledDaysText,
format : this.format,
showToday : this.showToday,
+ startDay: this.startDay,
minText : String.format(this.minText, this.formatDate(this.minValue)),
maxText : String.format(this.maxText, this.formatDate(this.maxValue))
});
});
Ext.reg('datefield', Ext.form.DateField);
+
Ext.form.DisplayField = Ext.extend(Ext.form.Field, {
validationEvent : false,
validateOnBlur : false,
d.push([value, o.text]);
}
this.store = new Ext.data.ArrayStore({
- 'id': 0,
+ idIndex: 0,
fields: ['value', 'text'],
data : d,
autoDestroy: true
Ext.form.ComboBox.superclass.onRender.call(this, ct, position);
if(this.hiddenName){
this.hiddenField = this.el.insertSibling({tag:'input', type:'hidden', name: this.hiddenName,
- id: (this.hiddenId||this.hiddenName)}, 'before', true);
+ id: (this.hiddenId || Ext.id())}, 'before', true);
}
if(Ext.isGecko){
}
return zindex;
},
+
+ getZIndex : function(listParent){
+ listParent = listParent || Ext.getDom(this.getListParent() || Ext.getBody());
+ var zindex = parseInt(Ext.fly(listParent).getStyle('z-index'), 10);
+ if(!zindex){
+ zindex = this.getParentZIndex();
+ }
+ return (zindex || 12000) + 5;
+ },
initList : function(){
if(!this.list){
var cls = 'x-combo-list',
- listParent = Ext.getDom(this.getListParent() || Ext.getBody()),
- zindex = parseInt(Ext.fly(listParent).getStyle('z-index'), 10);
-
- if (!zindex) {
- zindex = this.getParentZIndex();
- }
+ listParent = Ext.getDom(this.getListParent() || Ext.getBody());
this.list = new Ext.Layer({
parentEl: listParent,
shadow: this.shadow,
cls: [cls, this.listClass].join(' '),
constrain:false,
- zindex: (zindex || 12000) + 5
+ zindex: this.getZIndex(listParent)
});
var lw = this.listWidth || Math.max(this.wrap.getWidth(), this.minListWidth);
},
reset : function(){
- Ext.form.ComboBox.superclass.reset.call(this);
if(this.clearFilterOnReset && this.mode == 'local'){
this.store.clearFilter();
}
+ Ext.form.ComboBox.superclass.reset.call(this);
},
},
- assertValue : function(){
+ assertValue : function(){
var val = this.getRawValue(),
- rec = this.findRecord(this.displayField, val);
+ rec;
+ if(this.valueField && Ext.isDefined(this.value)){
+ rec = this.findRecord(this.valueField, this.value);
+ }
+ if(!rec || rec.get(this.displayField) != val){
+ rec = this.findRecord(this.displayField, val);
+ }
if(!rec && this.forceSelection){
if(val.length > 0 && val != this.emptyText){
this.el.dom.value = Ext.value(this.lastSelectionText, '');
this.clearValue();
}
}else{
- if(rec){
+ if(rec && this.valueField){
- if (val == rec.get(this.displayField) && this.value == rec.get(this.valueField)){
+ if (this.value == val){
return;
}
val = rec.get(this.valueField || this.displayField);
getParams : function(q){
- var p = {};
-
+ var params = {},
+ paramNames = this.store.paramNames;
if(this.pageSize){
- p.start = 0;
- p.limit = this.pageSize;
+ params[paramNames.start] = 0;
+ params[paramNames.limit] = this.pageSize;
}
- return p;
+ return params;
},
this.list.alignTo.apply(this.list, [this.el].concat(this.listAlign));
- var listParent = Ext.getDom(this.getListParent() || Ext.getBody()),
- zindex = parseInt(Ext.fly(listParent).getStyle('z-index') ,10);
- if (!zindex){
- zindex = this.getParentZIndex();
- }
- if (zindex) {
- this.list.setZIndex(zindex + 5);
- }
+ this.list.setZIndex(this.getZIndex());
this.list.show();
if(Ext.isGecko2){
this.innerList.setOverflow('auto');
-
actionMode : 'wrap',
this.checked = this.el.dom.checked;
}
- if(Ext.isIE){
+ if (Ext.isIE && !Ext.isStrict) {
this.wrap.repaint();
}
this.resizeEl = this.positionEl = this.wrap;
setValue : function(v){
- var checked = this.checked ;
- this.checked = (v === true || v === 'true' || v == '1' || String(v).toLowerCase() == 'on');
+ var checked = this.checked,
+ inputVal = this.inputValue;
+
+ this.checked = (v === true || v === 'true' || v == '1' || (inputVal ? v == inputVal : String(v).toLowerCase() == 'on'));
if(this.rendered){
this.el.dom.checked = this.checked;
this.el.dom.defaultChecked = this.checked;
beforeDestroy: function(){
Ext.destroy(this.panel);
+ if (!this.rendered) {
+ Ext.destroy(this.items);
+ }
Ext.form.CheckboxGroup.superclass.beforeDestroy.call(this);
},
combineErrors: true,
+
+
+ labelConnector: ', ',
+
+
for (var i=0, j = items.length; i < j; i++) {
item = items[i];
+
+ if (!Ext.isEmpty(item.ref)){
+ item.ref = '../' + item.ref;
+ }
labels.push(item.fieldLabel);
- Ext.apply(item, this.defaults);
+ Ext.applyIf(item, this.defaults);
if (!(i == j - 1 && this.skipLastItemMargin)) {
});
Ext.form.CompositeField.superclass.initComponent.apply(this, arguments);
+
+ this.innerCt = new Ext.Container({
+ layout : 'hbox',
+ items : this.items,
+ cls : 'x-form-composite',
+ defaultMargins: '0 3 0 0',
+ ownerCt: this
+ });
+ this.innerCt.ownerCt = undefined;
+
+ var fields = this.innerCt.findBy(function(c) {
+ return c.isFormField;
+ }, this);
+
+
+ this.items = new Ext.util.MixedCollection();
+ this.items.addAll(fields);
+
},
onRender: function(ct, position) {
if (!this.el) {
- var innerCt = this.innerCt = new Ext.Container({
- layout : 'hbox',
- renderTo: ct,
- items : this.items,
- cls : 'x-form-composite',
- defaultMargins: '0 3 0 0'
- });
+ var innerCt = this.innerCt;
+ innerCt.render(ct);
this.el = innerCt.getEl();
- var fields = innerCt.findBy(function(c) {
- return c.isFormField;
- }, this);
-
-
- this.items = new Ext.util.MixedCollection();
- this.items.addAll(fields);
-
if (this.combineErrors) {
onFieldMarkInvalid: function(field, message) {
var name = field.getName(),
- error = {field: name, error: message};
+ error = {
+ field: name,
+ errorName: field.fieldLabel || name,
+ error: message
+ };
this.fieldErrors.replace(name, error);
for (var i = 0, j = errors.length; i < j; i++) {
error = errors[i];
- combined.push(String.format("{0}: {1}", error.field, error.error));
+ combined.push(String.format("{0}: {1}", error.errorName, error.error));
}
return combined.join("<br />");
buildLabel: function(segments) {
- return segments.join(", ");
+ return Ext.clean(segments).join(this.labelConnector);
},
setReadOnly : function(readOnly) {
- readOnly = readOnly || true;
+ if (readOnly == undefined) {
+ readOnly = true;
+ }
+ readOnly = !!readOnly;
if(this.rendered){
this.eachItem(function(item){
});
Ext.reg('compositefield', Ext.form.CompositeField);
-
Ext.form.Radio = Ext.extend(Ext.form.Checkbox, {
inputType: 'radio',
},
- onClick : function(){
- if(this.el.dom.checked != this.checked){
- var els = this.getCheckEl().select('input[name=' + this.el.dom.name + ']');
- els.each(function(el){
- if(el.dom.id == this.id){
- this.setValue(true);
- }else{
- Ext.getCmp(el.dom.id).setValue(false);
- }
- }, this);
- }
- },
-
-
setValue : function(v){
+ var checkEl,
+ els,
+ radio;
if (typeof v == 'boolean') {
Ext.form.Radio.superclass.setValue.call(this, v);
} else if (this.rendered) {
- var r = this.getCheckEl().child('input[name=' + this.el.dom.name + '][value=' + v + ']', true);
- if(r){
- Ext.getCmp(r.id).setValue(true);
+ checkEl = this.getCheckEl();
+ radio = checkEl.child('input[name=' + this.el.dom.name + '][value=' + v + ']', true);
+ if(radio){
+ Ext.getCmp(radio.id).setValue(true);
}
}
+ if(this.rendered && this.checked){
+ checkEl = checkEl || this.getCheckEl();
+ els = this.getCheckEl().select('input[name=' + this.el.dom.name + ']');
+ els.each(function(el){
+ if(el.dom.id != this.id){
+ Ext.getCmp(el.dom.id).setValue(false);
+ }
+ }, this);
+ }
return this;
},
getCheckEl: function(){
if(this.inGroup){
- return this.el.up('.x-form-radio-group')
+ return this.el.up('.x-form-radio-group');
}
return this.el.up('form') || Ext.getBody();
}
Ext.form.Hidden = Ext.extend(Ext.form.Field, {
inputType : 'hidden',
+
+ shouldLayout: false,
onRender : function(){
updateRecord : function(record){
record.beginEdit();
- var fs = record.fields;
+ var fs = record.fields,
+ field,
+ value;
fs.each(function(f){
- var field = this.findField(f.name);
+ field = this.findField(f.name);
if(field){
- record.set(f.name, field.getValue());
+ value = field.getValue();
+ if (typeof value != undefined && value.getGroupValue) {
+ value = value.getGroupValue();
+ } else if ( field.eachItem ) {
+ value = [];
+ field.eachItem(function(item){
+ value.push(item.getValue());
+ });
+ }
+ record.set(f.name, value);
}
}, this);
record.endEdit();
if (f.dataIndex == id || f.id == id || f.getName() == id) {
field = f;
return false;
- } else if (f.isComposite && f.rendered) {
+ } else if (f.isComposite) {
return f.items.each(findMatchingField);
+ } else if (f instanceof Ext.form.CheckboxGroup && f.rendered) {
+ return f.eachItem(findMatchingField);
}
}
};
key,
val;
this.items.each(function(f) {
- if (dirtyOnly !== true || f.isDirty()) {
+ if (!f.disabled && (dirtyOnly !== true || f.isDirty())) {
n = f.getName();
key = o[n];
val = f.getValue();
}else if (c.findBy){
Ext.each(c.findBy(this.isField), this.form.remove, this.form);
- if (c.isDestroyed) {
- this.form.cleanDestroyed();
- }
+
+ this.form.cleanDestroyed();
}
}
},
'editmodechange'
);
+ Ext.form.HtmlEditor.superclass.initComponent.call(this);
},
iframe.name = Ext.id();
iframe.frameBorder = '0';
iframe.style.overflow = 'auto';
+ iframe.src = Ext.SSL_SECURE_URL;
this.wrap.dom.appendChild(iframe);
this.iframe = iframe;
setDesignMode : function(mode){
- var doc ;
- if(doc = this.getDoc()){
+ var doc = this.getDoc();
+ if (doc) {
if(this.readOnly){
mode = false;
}
toggleSourceEdit : function(sourceEditMode){
var iframeHeight,
- elHeight,
- ls;
+ elHeight;
if (sourceEditMode === undefined) {
sourceEditMode = !this.sourceEditMode;
}
if (this.sourceEditMode) {
- ls = this.getSize();
+ this.previousSize = this.getSize();
iframeHeight = Ext.get(this.iframe).getHeight();
this.el.dom.setAttribute('tabIndex', -1);
this.deferFocus();
- this.setSize(ls);
+ this.setSize(this.previousSize);
+ delete this.previousSize;
this.iframe.style.height = elHeight + 'px';
}
this.fireEvent('editmodechange', this, this.sourceEditMode);
},
- onDestroy : function(){
+ beforeDestroy : function(){
if(this.monitorTask){
Ext.TaskMgr.stop(this.monitorTask);
}
this.wrap.remove();
}
}
-
- if(this.el){
- this.el.removeAllListeners();
- this.el.remove();
- }
- this.purgeListeners();
+ Ext.form.HtmlEditor.superclass.beforeDestroy.call(this);
},
if(o.clientValidation === false || this.form.isValid()){
if (o.submitEmptyText === false) {
var fields = this.form.items,
- emptyFields = [];
- fields.each(function(f) {
- if (f.el.getValue() == f.emptyText) {
- emptyFields.push(f);
- f.el.dom.value = "";
- }
- });
+ emptyFields = [],
+ setupEmptyFields = function(f){
+ if (f.el.getValue() == f.emptyText) {
+ emptyFields.push(f);
+ f.el.dom.value = "";
+ }
+ if(f.isComposite && f.rendered){
+ f.items.each(setupEmptyFields);
+ }
+ };
+
+ fields.each(setupEmptyFields);
}
Ext.Ajax.request(Ext.apply(this.createCallback(o), {
form:this.form.el.dom,
autoExpandColumn : false,
+
autoExpandMax : 1000,
+
autoExpandMin : 50,
+
columnLines : false,
+
ddText : '{0} selected row{1}',
+
deferRowRender : true,
+
enableColumnHide : true,
+
enableColumnMove : true,
+
enableDragDrop : false,
+
enableHdMenu : true,
+
loadMask : false,
+
minColumnWidth : 25,
+
stripeRows : false,
+
trackMouseOver : true,
+
stateEvents : ['columnmove', 'columnresize', 'sortchange', 'groupchange'],
+
view : null,
rendered : false,
+
viewReady : false,
- initComponent : function(){
+ initComponent : function() {
Ext.grid.GridPanel.superclass.initComponent.call(this);
- if(this.columnLines){
+ if (this.columnLines) {
this.cls = (this.cls || '') + ' x-grid-with-col-lines';
}
store = this.store,
s,
c,
- oldIndex;
+ colIndex;
if(cs){
for(var i = 0, len = cs.length; i < len; i++){
s = cs[i];
c = cm.getColumnById(s.id);
if(c){
- c.hidden = s.hidden;
- c.width = s.width;
- oldIndex = cm.getIndexById(s.id);
- if(oldIndex != i){
- cm.moveColumn(oldIndex, i);
+ colIndex = cm.getIndexById(s.id);
+ cm.setState(colIndex, {
+ hidden: s.hidden,
+ width: s.width,
+ sortable: s.sortable
+ });
+ if(colIndex != i){
+ cm.moveColumn(colIndex, i);
}
}
}
if(c.hidden){
o.columns[i].hidden = true;
}
+ if(c.sortable){
+ o.columns[i].sortable = true;
+ }
}
if(store){
ss = store.getSortState();
Ext.grid.GridPanel.superclass.afterRender.call(this);
var v = this.view;
this.on('bodyresize', v.layout, v);
- v.layout();
+ v.layout(true);
if(this.deferRowRender){
if (!this.deferRowRenderTask){
this.deferRowRenderTask = new Ext.util.DelayedTask(v.afterRender, this.view);
},
- getView : function(){
- if(!this.view){
+ getView : function() {
+ if (!this.view) {
this.view = new Ext.grid.GridView(this.viewConfig);
}
+
return this.view;
},
});
Ext.reg('grid', Ext.grid.GridPanel);
+Ext.grid.PivotGrid = Ext.extend(Ext.grid.GridPanel, {
+
+
+ aggregator: 'sum',
+
+
+ renderer: undefined,
+
+
+
+
+
+
+
+
+ initComponent: function() {
+ Ext.grid.PivotGrid.superclass.initComponent.apply(this, arguments);
+
+ this.initAxes();
+
+
+ this.enableColumnResize = false;
+
+ this.viewConfig = Ext.apply(this.viewConfig || {}, {
+ forceFit: true
+ });
+
+
+
+ this.colModel = new Ext.grid.ColumnModel({});
+ },
+
+
+ getAggregator: function() {
+ if (typeof this.aggregator == 'string') {
+ return Ext.grid.PivotAggregatorMgr.types[this.aggregator];
+ } else {
+ return this.aggregator;
+ }
+ },
+
+
+ setAggregator: function(aggregator) {
+ this.aggregator = aggregator;
+ },
+
+
+ setMeasure: function(measure) {
+ this.measure = measure;
+ },
+
+
+ setLeftAxis: function(axis, refresh) {
+
+ this.leftAxis = axis;
+
+ if (refresh) {
+ this.view.refresh();
+ }
+ },
+
+
+ setTopAxis: function(axis, refresh) {
+
+ this.topAxis = axis;
+
+ if (refresh) {
+ this.view.refresh();
+ }
+ },
+
+
+ initAxes: function() {
+ var PivotAxis = Ext.grid.PivotAxis;
+
+ if (!(this.leftAxis instanceof PivotAxis)) {
+ this.setLeftAxis(new PivotAxis({
+ orientation: 'vertical',
+ dimensions : this.leftAxis || [],
+ store : this.store
+ }));
+ };
+
+ if (!(this.topAxis instanceof PivotAxis)) {
+ this.setTopAxis(new PivotAxis({
+ orientation: 'horizontal',
+ dimensions : this.topAxis || [],
+ store : this.store
+ }));
+ };
+ },
+
+
+ extractData: function() {
+ var records = this.store.data.items,
+ recCount = records.length,
+ cells = [],
+ record, i, j, k;
+
+ if (recCount == 0) {
+ return [];
+ }
+
+ var leftTuples = this.leftAxis.getTuples(),
+ leftCount = leftTuples.length,
+ topTuples = this.topAxis.getTuples(),
+ topCount = topTuples.length,
+ aggregator = this.getAggregator();
+
+ for (i = 0; i < recCount; i++) {
+ record = records[i];
+
+ for (j = 0; j < leftCount; j++) {
+ cells[j] = cells[j] || [];
+
+ if (leftTuples[j].matcher(record) === true) {
+ for (k = 0; k < topCount; k++) {
+ cells[j][k] = cells[j][k] || [];
+
+ if (topTuples[k].matcher(record)) {
+ cells[j][k].push(record);
+ }
+ }
+ }
+ }
+ }
+
+ var rowCount = cells.length,
+ colCount, row;
+
+ for (i = 0; i < rowCount; i++) {
+ row = cells[i];
+ colCount = row.length;
+
+ for (j = 0; j < colCount; j++) {
+ cells[i][j] = aggregator(cells[i][j], this.measure);
+ }
+ }
+
+ return cells;
+ },
+
+
+ getView: function() {
+ if (!this.view) {
+ this.view = new Ext.grid.PivotGridView(this.viewConfig);
+ }
+
+ return this.view;
+ }
+});
+
+Ext.reg('pivotgrid', Ext.grid.PivotGrid);
+
+
+Ext.grid.PivotAggregatorMgr = new Ext.AbstractManager();
+
+Ext.grid.PivotAggregatorMgr.registerType('sum', function(records, measure) {
+ var length = records.length,
+ total = 0,
+ i;
+
+ for (i = 0; i < length; i++) {
+ total += records[i].get(measure);
+ }
+
+ return total;
+});
+
+Ext.grid.PivotAggregatorMgr.registerType('avg', function(records, measure) {
+ var length = records.length,
+ total = 0,
+ i;
+
+ for (i = 0; i < length; i++) {
+ total += records[i].get(measure);
+ }
+
+ return (total / length) || 'n/a';
+});
+
+Ext.grid.PivotAggregatorMgr.registerType('min', function(records, measure) {
+ var data = [],
+ length = records.length,
+ i;
+
+ for (i = 0; i < length; i++) {
+ data.push(records[i].get(measure));
+ }
+
+ return Math.min.apply(this, data) || 'n/a';
+});
+
+Ext.grid.PivotAggregatorMgr.registerType('max', function(records, measure) {
+ var data = [],
+ length = records.length,
+ i;
+
+ for (i = 0; i < length; i++) {
+ data.push(records[i].get(measure));
+ }
+
+ return Math.max.apply(this, data) || 'n/a';
+});
+
+Ext.grid.PivotAggregatorMgr.registerType('count', function(records, measure) {
+ return records.length;
+});
Ext.grid.GridView = Ext.extend(Ext.util.Observable, {
borderWidth : 2,
tdClass : 'x-grid3-cell',
hdCls : 'x-grid3-hd',
+
+
+
markDirty : true,
cellSelectorDepth : 4,
+
rowSelectorDepth : 10,
cellSelector : 'td.x-grid3-cell',
+
rowSelector : 'div.x-grid3-row',
firstRowCls: 'x-grid3-row-first',
lastRowCls: 'x-grid3-row-last',
rowClsRe: /(?:^|\s+)x-grid3-row-(first|last|alt)(?:\s+|$)/g,
+
+
+ headerMenuOpenCls: 'x-grid3-hd-menu-open',
+
+
+ rowOverCls: 'x-grid3-row-over',
- constructor : function(config){
+ constructor : function(config) {
Ext.apply(this, config);
+
this.addEvents(
'beforerowremoved',
+
'beforerowsinserted',
+
'beforerefresh',
+
'rowremoved',
+
'rowsinserted',
+
'rowupdated',
+
'refresh'
);
+
Ext.grid.GridView.superclass.constructor.call(this);
},
-
- initTemplates : function(){
- var ts = this.templates || {};
- if(!ts.master){
- ts.master = new Ext.Template(
- '<div class="x-grid3" hidefocus="true">',
- '<div class="x-grid3-viewport">',
- '<div class="x-grid3-header"><div class="x-grid3-header-inner"><div class="x-grid3-header-offset" style="{ostyle}">{header}</div></div><div class="x-clear"></div></div>',
- '<div class="x-grid3-scroller"><div class="x-grid3-body" style="{bstyle}">{body}</div><a href="#" class="x-grid3-focus" tabIndex="-1"></a></div>',
+
+ masterTpl: new Ext.Template(
+ '<div class="x-grid3" hidefocus="true">',
+ '<div class="x-grid3-viewport">',
+ '<div class="x-grid3-header">',
+ '<div class="x-grid3-header-inner">',
+ '<div class="x-grid3-header-offset" style="{ostyle}">{header}</div>',
'</div>',
- '<div class="x-grid3-resize-marker"> </div>',
- '<div class="x-grid3-resize-proxy"> </div>',
- '</div>'
- );
- }
-
- if(!ts.header){
- ts.header = new Ext.Template(
- '<table border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
- '<thead><tr class="x-grid3-hd-row">{cells}</tr></thead>',
+ '<div class="x-clear"></div>',
+ '</div>',
+ '<div class="x-grid3-scroller">',
+ '<div class="x-grid3-body" style="{bstyle}">{body}</div>',
+ '<a href="#" class="x-grid3-focus" tabIndex="-1"></a>',
+ '</div>',
+ '</div>',
+ '<div class="x-grid3-resize-marker"> </div>',
+ '<div class="x-grid3-resize-proxy"> </div>',
+ '</div>'
+ ),
+
+
+ headerTpl: new Ext.Template(
+ '<table border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
+ '<thead>',
+ '<tr class="x-grid3-hd-row">{cells}</tr>',
+ '</thead>',
+ '</table>'
+ ),
+
+
+ bodyTpl: new Ext.Template('{rows}'),
+
+
+ cellTpl: new Ext.Template(
+ '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} {css}" style="{style}" tabIndex="0" {cellAttr}>',
+ '<div class="x-grid3-cell-inner x-grid3-col-{id}" unselectable="on" {attr}>{value}</div>',
+ '</td>'
+ ),
+
+
+ initTemplates : function() {
+ var templates = this.templates || {},
+ template, name,
+
+ headerCellTpl = new Ext.Template(
+ '<td class="x-grid3-hd x-grid3-cell x-grid3-td-{id} {css}" style="{style}">',
+ '<div {tooltip} {attr} class="x-grid3-hd-inner x-grid3-hd-{id}" unselectable="on" style="{istyle}">',
+ this.grid.enableHdMenu ? '<a class="x-grid3-hd-btn" href="#"></a>' : '',
+ '{value}',
+ '<img alt="" class="x-grid3-sort-icon" src="', Ext.BLANK_IMAGE_URL, '" />',
+ '</div>',
+ '</td>'
+ ),
+
+ rowBodyText = [
+ '<tr class="x-grid3-row-body-tr" style="{bodyStyle}">',
+ '<td colspan="{cols}" class="x-grid3-body-cell" tabIndex="0" hidefocus="on">',
+ '<div class="x-grid3-row-body">{body}</div>',
+ '</td>',
+ '</tr>'
+ ].join(""),
+
+ innerText = [
+ '<table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
+ '<tbody>',
+ '<tr>{cells}</tr>',
+ this.enableRowBody ? rowBodyText : '',
+ '</tbody>',
'</table>'
- );
- }
-
- if(!ts.hcell){
- ts.hcell = new Ext.Template(
- '<td class="x-grid3-hd x-grid3-cell x-grid3-td-{id} {css}" style="{style}"><div {tooltip} {attr} class="x-grid3-hd-inner x-grid3-hd-{id}" unselectable="on" style="{istyle}">', this.grid.enableHdMenu ? '<a class="x-grid3-hd-btn" href="#"></a>' : '',
- '{value}<img class="x-grid3-sort-icon" src="', Ext.BLANK_IMAGE_URL, '" />',
- '</div></td>'
- );
- }
-
- if(!ts.body){
- ts.body = new Ext.Template('{rows}');
- }
-
- if(!ts.row){
- ts.row = new Ext.Template(
- '<div class="x-grid3-row {alt}" style="{tstyle}"><table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
- '<tbody><tr>{cells}</tr>',
- (this.enableRowBody ? '<tr class="x-grid3-row-body-tr" style="{bodyStyle}"><td colspan="{cols}" class="x-grid3-body-cell" tabIndex="0" hidefocus="on"><div class="x-grid3-row-body">{body}</div></td></tr>' : ''),
- '</tbody></table></div>'
- );
- }
-
- if(!ts.cell){
- ts.cell = new Ext.Template(
- '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} {css}" style="{style}" tabIndex="0" {cellAttr}>',
- '<div class="x-grid3-cell-inner x-grid3-col-{id}" unselectable="on" {attr}>{value}</div>',
- '</td>'
- );
- }
+ ].join("");
+
+ Ext.applyIf(templates, {
+ hcell : headerCellTpl,
+ cell : this.cellTpl,
+ body : this.bodyTpl,
+ header : this.headerTpl,
+ master : this.masterTpl,
+ row : new Ext.Template('<div class="x-grid3-row {alt}" style="{tstyle}">' + innerText + '</div>'),
+ rowInner: new Ext.Template(innerText)
+ });
- for(var k in ts){
- var t = ts[k];
- if(t && Ext.isFunction(t.compile) && !t.compiled){
- t.disableFormats = true;
- t.compile();
+ for (name in templates) {
+ template = templates[name];
+
+ if (template && Ext.isFunction(template.compile) && !template.compiled) {
+ template.disableFormats = true;
+ template.compile();
}
}
- this.templates = ts;
+ this.templates = templates;
this.colRe = new RegExp('x-grid3-td-([^\\s]+)', '');
},
- fly : function(el){
- if(!this._flyweight){
+ fly : function(el) {
+ if (!this._flyweight) {
this._flyweight = new Ext.Element.Flyweight(document.body);
}
this._flyweight.dom = el;
},
- getEditorParent : function(){
+ getEditorParent : function() {
return this.scroller.dom;
},
- initElements : function(){
- var E = Ext.Element;
-
- var el = this.grid.getGridEl().dom.firstChild;
- var cs = el.childNodes;
-
- this.el = new E(el);
-
- this.mainWrap = new E(cs[0]);
- this.mainHd = new E(this.mainWrap.dom.firstChild);
-
- if(this.grid.hideHeaders){
- this.mainHd.setDisplayed(false);
+ initElements : function() {
+ var Element = Ext.Element,
+ el = Ext.get(this.grid.getGridEl().dom.firstChild),
+ mainWrap = new Element(el.child('div.x-grid3-viewport')),
+ mainHd = new Element(mainWrap.child('div.x-grid3-header')),
+ scroller = new Element(mainWrap.child('div.x-grid3-scroller'));
+
+ if (this.grid.hideHeaders) {
+ mainHd.setDisplayed(false);
}
-
- this.innerHd = this.mainHd.dom.firstChild;
- this.scroller = new E(this.mainWrap.dom.childNodes[1]);
- if(this.forceFit){
- this.scroller.setStyle('overflow-x', 'hidden');
+
+ if (this.forceFit) {
+ scroller.setStyle('overflow-x', 'hidden');
}
- this.mainBody = new E(this.scroller.dom.firstChild);
-
- this.focusEl = new E(this.scroller.dom.childNodes[1]);
+
+
+ Ext.apply(this, {
+ el : el,
+ mainWrap: mainWrap,
+ scroller: scroller,
+ mainHd : mainHd,
+ innerHd : mainHd.child('div.x-grid3-header-inner').dom,
+ mainBody: new Element(Element.fly(scroller).child('div.x-grid3-body')),
+ focusEl : new Element(Element.fly(scroller).child('a')),
+
+ resizeMarker: new Element(el.child('div.x-grid3-resize-marker')),
+ resizeProxy : new Element(el.child('div.x-grid3-resize-proxy'))
+ });
+
this.focusEl.swallowEvent('click', true);
-
- this.resizeMarker = new E(cs[1]);
- this.resizeProxy = new E(cs[2]);
},
- getRows : function(){
+ getRows : function() {
return this.hasRows() ? this.mainBody.dom.childNodes : [];
},
- findCell : function(el){
- if(!el){
+ findCell : function(el) {
+ if (!el) {
return false;
}
return this.fly(el).findParent(this.cellSelector, this.cellSelectorDepth);
},
- findCellIndex : function(el, requiredCls){
- var cell = this.findCell(el);
- if(cell && (!requiredCls || this.fly(cell).hasClass(requiredCls))){
- return this.getCellIndex(cell);
+ findCellIndex : function(el, requiredCls) {
+ var cell = this.findCell(el),
+ hasCls;
+
+ if (cell) {
+ hasCls = this.fly(cell).hasClass(requiredCls);
+ if (!requiredCls || hasCls) {
+ return this.getCellIndex(cell);
+ }
}
return false;
},
- getCellIndex : function(el){
- if(el){
- var m = el.className.match(this.colRe);
- if(m && m[1]){
- return this.cm.getIndexById(m[1]);
+ getCellIndex : function(el) {
+ if (el) {
+ var match = el.className.match(this.colRe);
+
+ if (match && match[1]) {
+ return this.cm.getIndexById(match[1]);
}
}
return false;
},
- findHeaderCell : function(el){
+ findHeaderCell : function(el) {
var cell = this.findCell(el);
return cell && this.fly(cell).hasClass(this.hdCls) ? cell : null;
},
},
- findRow : function(el){
- if(!el){
+ findRow : function(el) {
+ if (!el) {
return false;
}
return this.fly(el).findParent(this.rowSelector, this.rowSelectorDepth);
},
- findRowIndex : function(el){
- var r = this.findRow(el);
- return r ? r.rowIndex : false;
+ findRowIndex : function(el) {
+ var row = this.findRow(el);
+ return row ? row.rowIndex : false;
},
- findRowBody : function(el){
- if(!el){
+ findRowBody : function(el) {
+ if (!el) {
return false;
}
+
return this.fly(el).findParent(this.rowBodySelector, this.rowBodySelectorDepth);
},
- getRow : function(row){
+ getRow : function(row) {
return this.getRows()[row];
},
- getCell : function(row, col){
- return this.getRow(row).getElementsByTagName('td')[col];
+ getCell : function(row, col) {
+ return Ext.fly(this.getRow(row)).query(this.cellSelector)[col];
},
- getHeaderCell : function(index){
+ getHeaderCell : function(index) {
return this.mainHd.dom.getElementsByTagName('td')[index];
},
- addRowClass : function(row, cls){
- var r = this.getRow(row);
- if(r){
- this.fly(r).addClass(cls);
+ addRowClass : function(rowId, cls) {
+ var row = this.getRow(rowId);
+ if (row) {
+ this.fly(row).addClass(cls);
}
},
- removeRowClass : function(row, cls){
+ removeRowClass : function(row, cls) {
var r = this.getRow(row);
if(r){
this.fly(r).removeClass(cls);
},
- removeRow : function(row){
+ removeRow : function(row) {
Ext.removeNode(this.getRow(row));
this.syncFocusEl(row);
},
- removeRows : function(firstRow, lastRow){
- var bd = this.mainBody.dom;
- for(var rowIndex = firstRow; rowIndex <= lastRow; rowIndex++){
+ removeRows : function(firstRow, lastRow) {
+ var bd = this.mainBody.dom,
+ rowIndex;
+
+ for (rowIndex = firstRow; rowIndex <= lastRow; rowIndex++){
Ext.removeNode(bd.childNodes[firstRow]);
}
+
this.syncFocusEl(firstRow);
},
-
- getScrollState : function(){
+
+ getScrollState : function() {
var sb = this.scroller.dom;
- return {left: sb.scrollLeft, top: sb.scrollTop};
+
+ return {
+ left: sb.scrollLeft,
+ top : sb.scrollTop
+ };
},
- restoreScroll : function(state){
+ restoreScroll : function(state) {
var sb = this.scroller.dom;
sb.scrollLeft = state.left;
- sb.scrollTop = state.top;
+ sb.scrollTop = state.top;
},
- scrollToTop : function(){
- this.scroller.dom.scrollTop = 0;
- this.scroller.dom.scrollLeft = 0;
+ scrollToTop : function() {
+ var dom = this.scroller.dom;
+
+ dom.scrollTop = 0;
+ dom.scrollLeft = 0;
},
- syncScroll : function(){
+ syncScroll : function() {
this.syncHeaderScroll();
var mb = this.scroller.dom;
this.grid.fireEvent('bodyscroll', mb.scrollLeft, mb.scrollTop);
},
- syncHeaderScroll : function(){
- var mb = this.scroller.dom;
- this.innerHd.scrollLeft = mb.scrollLeft;
- this.innerHd.scrollLeft = mb.scrollLeft;
+ syncHeaderScroll : function() {
+ var innerHd = this.innerHd,
+ scrollLeft = this.scroller.dom.scrollLeft;
+
+ innerHd.scrollLeft = scrollLeft;
+ innerHd.scrollLeft = scrollLeft;
},
-
- updateSortIcon : function(col, dir){
- var sc = this.sortClasses;
- var hds = this.mainHd.select('td').removeClass(sc);
- hds.item(col).addClass(sc[dir == 'DESC' ? 1 : 0]);
+
+ updateSortIcon : function(col, dir) {
+ var sortClasses = this.sortClasses,
+ sortClass = sortClasses[dir == "DESC" ? 1 : 0],
+ headers = this.mainHd.select('td').removeClass(sortClasses);
+
+ headers.item(col).addClass(sortClass);
},
- updateAllColumnWidths : function(){
- var tw = this.getTotalWidth(),
- clen = this.cm.getColumnCount(),
- ws = [],
- len,
- i;
-
- for(i = 0; i < clen; i++){
- ws[i] = this.getColumnWidth(i);
- }
-
- this.innerHd.firstChild.style.width = this.getOffsetWidth();
- this.innerHd.firstChild.firstChild.style.width = tw;
- this.mainBody.dom.style.width = tw;
-
- for(i = 0; i < clen; i++){
- var hd = this.getHeaderCell(i);
- hd.style.width = ws[i];
+ updateAllColumnWidths : function() {
+ var totalWidth = this.getTotalWidth(),
+ colCount = this.cm.getColumnCount(),
+ rows = this.getRows(),
+ rowCount = rows.length,
+ widths = [],
+ row, rowFirstChild, trow, i, j;
+
+ for (i = 0; i < colCount; i++) {
+ widths[i] = this.getColumnWidth(i);
+ this.getHeaderCell(i).style.width = widths[i];
}
-
- var ns = this.getRows(), row, trow;
- for(i = 0, len = ns.length; i < len; i++){
- row = ns[i];
- row.style.width = tw;
- if(row.firstChild){
- row.firstChild.style.width = tw;
- trow = row.firstChild.rows[0];
- for (var j = 0; j < clen; j++) {
- trow.childNodes[j].style.width = ws[j];
+
+ this.updateHeaderWidth();
+
+ for (i = 0; i < rowCount; i++) {
+ row = rows[i];
+ row.style.width = totalWidth;
+ rowFirstChild = row.firstChild;
+
+ if (rowFirstChild) {
+ rowFirstChild.style.width = totalWidth;
+ trow = rowFirstChild.rows[0];
+
+ for (j = 0; j < colCount; j++) {
+ trow.childNodes[j].style.width = widths[j];
}
}
}
-
- this.onAllColumnWidthsUpdated(ws, tw);
+
+ this.onAllColumnWidthsUpdated(widths, totalWidth);
},
- updateColumnWidth : function(col, width){
- var w = this.getColumnWidth(col);
- var tw = this.getTotalWidth();
- this.innerHd.firstChild.style.width = this.getOffsetWidth();
- this.innerHd.firstChild.firstChild.style.width = tw;
- this.mainBody.dom.style.width = tw;
- var hd = this.getHeaderCell(col);
- hd.style.width = w;
-
- var ns = this.getRows(), row;
- for(var i = 0, len = ns.length; i < len; i++){
- row = ns[i];
- row.style.width = tw;
- if(row.firstChild){
- row.firstChild.style.width = tw;
- row.firstChild.rows[0].childNodes[col].style.width = w;
+ updateColumnWidth : function(column, width) {
+ var columnWidth = this.getColumnWidth(column),
+ totalWidth = this.getTotalWidth(),
+ headerCell = this.getHeaderCell(column),
+ nodes = this.getRows(),
+ nodeCount = nodes.length,
+ row, i, firstChild;
+
+ this.updateHeaderWidth();
+ headerCell.style.width = columnWidth;
+
+ for (i = 0; i < nodeCount; i++) {
+ row = nodes[i];
+ firstChild = row.firstChild;
+
+ row.style.width = totalWidth;
+ if (firstChild) {
+ firstChild.style.width = totalWidth;
+ firstChild.rows[0].childNodes[column].style.width = columnWidth;
}
}
-
- this.onColumnWidthUpdated(col, w, tw);
+
+ this.onColumnWidthUpdated(column, columnWidth, totalWidth);
},
-
- updateColumnHidden : function(col, hidden){
- var tw = this.getTotalWidth();
- this.innerHd.firstChild.style.width = this.getOffsetWidth();
- this.innerHd.firstChild.firstChild.style.width = tw;
- this.mainBody.dom.style.width = tw;
- var display = hidden ? 'none' : '';
-
- var hd = this.getHeaderCell(col);
- hd.style.display = display;
-
- var ns = this.getRows(), row;
- for(var i = 0, len = ns.length; i < len; i++){
- row = ns[i];
- row.style.width = tw;
- if(row.firstChild){
- row.firstChild.style.width = tw;
- row.firstChild.rows[0].childNodes[col].style.display = display;
+
+ updateColumnHidden : function(col, hidden) {
+ var totalWidth = this.getTotalWidth(),
+ display = hidden ? 'none' : '',
+ headerCell = this.getHeaderCell(col),
+ nodes = this.getRows(),
+ nodeCount = nodes.length,
+ row, rowFirstChild, i;
+
+ this.updateHeaderWidth();
+ headerCell.style.display = display;
+
+ for (i = 0; i < nodeCount; i++) {
+ row = nodes[i];
+ row.style.width = totalWidth;
+ rowFirstChild = row.firstChild;
+
+ if (rowFirstChild) {
+ rowFirstChild.style.width = totalWidth;
+ rowFirstChild.rows[0].childNodes[col].style.display = display;
}
}
-
- this.onColumnHiddenUpdated(col, hidden, tw);
+
+ this.onColumnHiddenUpdated(col, hidden, totalWidth);
delete this.lastViewWidth;
this.layout();
},
doRender : function(columns, records, store, startRow, colCount, stripe) {
- var templates = this.templates,
+ var templates = this.templates,
cellTemplate = templates.cell,
- rowTemplate = templates.row,
- last = colCount - 1;
-
- var tstyle = 'width:' + this.getTotalWidth() + ';';
-
-
- var rowBuffer = [],
+ rowTemplate = templates.row,
+ last = colCount - 1,
+ tstyle = 'width:' + this.getTotalWidth() + ';',
+
+ rowBuffer = [],
colBuffer = [],
rowParams = {tstyle: tstyle},
- meta = {},
+ meta = {},
+ len = records.length,
+ alt,
column,
- record;
+ record, i, j, rowIndex;
- for (var j = 0, len = records.length; j < len; j++) {
+ for (j = 0; j < len; j++) {
record = records[j];
colBuffer = [];
- var rowIndex = j + startRow;
+ rowIndex = j + startRow;
- for (var i = 0; i < colCount; i++) {
+ for (i = 0; i < colCount; i++) {
column = columns[i];
-
+
meta.id = column.id;
meta.css = i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
meta.attr = meta.cellAttr = '';
meta.value = ' ';
}
- if (this.markDirty && record.dirty && Ext.isDefined(record.modified[column.name])) {
+ if (this.markDirty && record.dirty && typeof record.modified[column.name] != 'undefined') {
meta.css += ' x-grid3-dirty-cell';
}
colBuffer[colBuffer.length] = cellTemplate.apply(meta);
}
+ alt = [];
- var alt = [];
-
if (stripe && ((rowIndex + 1) % 2 === 0)) {
alt[0] = 'x-grid3-row-alt';
}
return;
}
- var rows = this.getRows(),
- len = rows.length,
- i, r;
+ var rows = this.getRows(),
+ length = rows.length,
+ row, i;
skipStripe = skipStripe || !this.grid.stripeRows;
startRow = startRow || 0;
- for (i = 0; i<len; i++) {
- r = rows[i];
- if (r) {
- r.rowIndex = i;
+ for (i = 0; i < length; i++) {
+ row = rows[i];
+ if (row) {
+ row.rowIndex = i;
if (!skipStripe) {
- r.className = r.className.replace(this.rowClsRe, ' ');
+ row.className = row.className.replace(this.rowClsRe, ' ');
if ((i + 1) % 2 === 0){
- r.className += ' x-grid3-row-alt';
+ row.className += ' x-grid3-row-alt';
}
}
}
Ext.fly(rows[0]).addClass(this.firstRowCls);
}
- Ext.fly(rows[rows.length - 1]).addClass(this.lastRowCls);
+ Ext.fly(rows[length - 1]).addClass(this.lastRowCls);
},
-
- afterRender : function(){
- if(!this.ds || !this.cm){
+
+
+ afterRender : function() {
+ if (!this.ds || !this.cm) {
return;
}
- this.mainBody.dom.innerHTML = this.renderRows() || ' ';
+
+ this.mainBody.dom.innerHTML = this.renderBody() || ' ';
this.processRows(0, true);
- if(this.deferEmptyText !== true){
+ if (this.deferEmptyText !== true) {
this.applyEmptyText();
}
+
this.grid.fireEvent('viewready', this.grid);
},
-
- renderUI : function() {
- var templates = this.templates,
- header = this.renderHeaders(),
- body = templates.body.apply({rows:' '});
-
- var html = templates.master.apply({
- body : body,
- header: header,
- ostyle: 'width:' + this.getOffsetWidth() + ';',
- bstyle: 'width:' + this.getTotalWidth() + ';'
- });
-
- var g = this.grid;
-
- g.getGridEl().dom.innerHTML = html;
-
+
+ afterRenderUI: function() {
+ var grid = this.grid;
+
this.initElements();
});
this.scroller.on('scroll', this.syncScroll, this);
- if (g.enableColumnResize !== false) {
- this.splitZone = new Ext.grid.GridView.SplitDragZone(g, this.mainHd.dom);
+
+ if (grid.enableColumnResize !== false) {
+ this.splitZone = new Ext.grid.GridView.SplitDragZone(grid, this.mainHd.dom);
}
- if (g.enableColumnMove) {
- this.columnDrag = new Ext.grid.GridView.ColumnDragZone(g, this.innerHd);
- this.columnDrop = new Ext.grid.HeaderDropZone(g, this.mainHd.dom);
+ if (grid.enableColumnMove) {
+ this.columnDrag = new Ext.grid.GridView.ColumnDragZone(grid, this.innerHd);
+ this.columnDrop = new Ext.grid.HeaderDropZone(grid, this.mainHd.dom);
}
- if (g.enableHdMenu !== false) {
- this.hmenu = new Ext.menu.Menu({id: g.id + '-hctx'});
+ if (grid.enableHdMenu !== false) {
+ this.hmenu = new Ext.menu.Menu({id: grid.id + '-hctx'});
this.hmenu.add(
{itemId:'asc', text: this.sortAscText, cls: 'xg-hmenu-sort-asc'},
{itemId:'desc', text: this.sortDescText, cls: 'xg-hmenu-sort-desc'}
);
- if (g.enableColumnHide !== false) {
- this.colMenu = new Ext.menu.Menu({id:g.id + '-hcols-menu'});
+ if (grid.enableColumnHide !== false) {
+ this.colMenu = new Ext.menu.Menu({id:grid.id + '-hcols-menu'});
this.colMenu.on({
scope : this,
beforeshow: this.beforeColMenuShow,
this.hmenu.on('itemclick', this.handleHdMenuClick, this);
}
- if (g.trackMouseOver) {
+ if (grid.trackMouseOver) {
this.mainBody.on({
scope : this,
mouseover: this.onRowOver,
});
}
- if (g.enableDragDrop || g.enableDrag) {
- this.dragZone = new Ext.grid.GridDragZone(g, {
- ddGroup : g.ddGroup || 'GridDD'
+ if (grid.enableDragDrop || grid.enableDrag) {
+ this.dragZone = new Ext.grid.GridDragZone(grid, {
+ ddGroup : grid.ddGroup || 'GridDD'
});
}
},
+ renderUI : function() {
+ var templates = this.templates;
+
+ return templates.master.apply({
+ body : templates.body.apply({rows:' '}),
+ header: this.renderHeaders(),
+ ostyle: 'width:' + this.getOffsetWidth() + ';',
+ bstyle: 'width:' + this.getTotalWidth() + ';'
+ });
+ },
+
+
processEvent : function(name, e) {
- var t = e.getTarget(),
- g = this.grid,
- header = this.findHeaderIndex(t);
- g.fireEvent(name, e);
+ var target = e.getTarget(),
+ grid = this.grid,
+ header = this.findHeaderIndex(target),
+ row, cell, col, body;
+
+ grid.fireEvent(name, e);
+
if (header !== false) {
- g.fireEvent('header' + name, g, header, e);
+ grid.fireEvent('header' + name, grid, header, e);
} else {
- var row = this.findRowIndex(t),
- cell,
- body;
+ row = this.findRowIndex(target);
+
+
+
+
if (row !== false) {
- g.fireEvent('row' + name, g, row, e);
- cell = this.findCellIndex(t);
+ cell = this.findCellIndex(target);
if (cell !== false) {
- g.fireEvent('cell' + name, g, row, cell, e);
+ col = grid.colModel.getColumnAt(cell);
+ if (grid.fireEvent('cell' + name, grid, row, cell, e) !== false) {
+ if (!col || (col.processEvent && (col.processEvent(name, e, grid, row, cell) !== false))) {
+ grid.fireEvent('row' + name, grid, row, e);
+ }
+ }
} else {
- body = this.findRowBody(t);
- if (body) {
- g.fireEvent('rowbody' + name, g, row, e);
+ if (grid.fireEvent('row' + name, grid, row, e) !== false) {
+ (body = this.findRowBody(target)) && grid.fireEvent('rowbody' + name, grid, row, e);
}
}
} else {
- g.fireEvent('container' + name, g, e);
+ grid.fireEvent('container' + name, grid, e);
}
}
},
- layout : function() {
- if(!this.mainBody){
+ layout : function(initial) {
+ if (!this.mainBody) {
return;
}
- var g = this.grid;
- var c = g.getGridEl();
- var csize = c.getSize(true);
- var vw = csize.width;
- if(!g.hideHeaders && (vw < 20 || csize.height < 20)){
+ var grid = this.grid,
+ gridEl = grid.getGridEl(),
+ gridSize = gridEl.getSize(true),
+ gridWidth = gridSize.width,
+ gridHeight = gridSize.height,
+ scroller = this.scroller,
+ scrollStyle, headerHeight, scrollHeight;
+
+ if (gridWidth < 20 || gridHeight < 20) {
return;
}
-
- if(g.autoHeight){
- this.scroller.dom.style.overflow = 'visible';
- if(Ext.isWebKit){
- this.scroller.dom.style.position = 'static';
+
+ if (grid.autoHeight) {
+ scrollStyle = scroller.dom.style;
+ scrollStyle.overflow = 'visible';
+
+ if (Ext.isWebKit) {
+ scrollStyle.position = 'static';
}
- }else{
- this.el.setSize(csize.width, csize.height);
-
- var hdHeight = this.mainHd.getHeight();
- var vh = csize.height - (hdHeight);
-
- this.scroller.setSize(vw, vh);
- if(this.innerHd){
- this.innerHd.style.width = (vw)+'px';
+ } else {
+ this.el.setSize(gridWidth, gridHeight);
+
+ headerHeight = this.mainHd.getHeight();
+ scrollHeight = gridHeight - headerHeight;
+
+ scroller.setSize(gridWidth, scrollHeight);
+
+ if (this.innerHd) {
+ this.innerHd.style.width = (gridWidth) + "px";
}
}
- if(this.forceFit){
- if(this.lastViewWidth != vw){
+
+ if (this.forceFit || (initial === true && this.autoFill)) {
+ if (this.lastViewWidth != gridWidth) {
this.fitColumns(false, false);
- this.lastViewWidth = vw;
+ this.lastViewWidth = gridWidth;
}
- }else {
+ } else {
this.autoExpand();
this.syncHeaderScroll();
}
- this.onLayout(vw, vh);
+
+ this.onLayout(gridWidth, scrollHeight);
},
- onLayout : function(vw, vh){
+ onLayout : function(vw, vh) {
},
- onColumnWidthUpdated : function(col, w, tw){
+ onColumnWidthUpdated : function(col, w, tw) {
},
- onAllColumnWidthsUpdated : function(ws, tw){
+ onAllColumnWidthsUpdated : function(ws, tw) {
},
- onColumnHiddenUpdated : function(col, hidden, tw){
+ onColumnHiddenUpdated : function(col, hidden, tw) {
},
- updateColumnText : function(col, text){
+ updateColumnText : function(col, text) {
},
- afterMove : function(colIndex){
+ afterMove : function(colIndex) {
},
- init : function(grid){
+ init : function(grid) {
this.grid = grid;
this.initTemplates();
getColumnId : function(index){
- return this.cm.getColumnId(index);
+ return this.cm.getColumnId(index);
},
return (this.cm.getTotalWidth() + this.getScrollOffset()) + 'px';
},
- getScrollOffset: function(){
+
+ getScrollOffset: function() {
return Ext.num(this.scrollOffset, Ext.getScrollBarWidth());
},
renderHeaders : function() {
- var cm = this.cm,
- ts = this.templates,
- ct = ts.hcell,
- cb = [],
- p = {},
- len = cm.getColumnCount(),
- last = len - 1;
-
- for (var i = 0; i < len; i++) {
- p.id = cm.getColumnId(i);
- p.value = cm.getColumnHeader(i) || '';
- p.style = this.getColumnStyle(i, true);
- p.tooltip = this.getColumnTooltip(i);
- p.css = i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
-
- if (cm.config[i].align == 'right') {
- p.istyle = 'padding-right:16px';
+ var colModel = this.cm,
+ templates = this.templates,
+ headerTpl = templates.hcell,
+ properties = {},
+ colCount = colModel.getColumnCount(),
+ last = colCount - 1,
+ cells = [],
+ i, cssCls;
+
+ for (i = 0; i < colCount; i++) {
+ if (i == 0) {
+ cssCls = 'x-grid3-cell-first ';
+ } else {
+ cssCls = i == last ? 'x-grid3-cell-last ' : '';
+ }
+
+ properties = {
+ id : colModel.getColumnId(i),
+ value : colModel.getColumnHeader(i) || '',
+ style : this.getColumnStyle(i, true),
+ css : cssCls,
+ tooltip: this.getColumnTooltip(i)
+ };
+
+ if (colModel.config[i].align == 'right') {
+ properties.istyle = 'padding-right: 16px;';
} else {
- delete p.istyle;
+ delete properties.istyle;
}
- cb[cb.length] = ct.apply(p);
+
+ cells[i] = headerTpl.apply(properties);
}
- return ts.header.apply({cells: cb.join(''), tstyle:'width:'+this.getTotalWidth()+';'});
+
+ return templates.header.apply({
+ cells : cells.join(""),
+ tstyle: String.format("width: {0};", this.getTotalWidth())
+ });
},
- getColumnTooltip : function(i){
- var tt = this.cm.getColumnTooltip(i);
- if(tt){
- if(Ext.QuickTips.isEnabled()){
- return 'ext:qtip="'+tt+'"';
- }else{
- return 'title="'+tt+'"';
+ getColumnTooltip : function(i) {
+ var tooltip = this.cm.getColumnTooltip(i);
+ if (tooltip) {
+ if (Ext.QuickTips.isEnabled()) {
+ return 'ext:qtip="' + tooltip + '"';
+ } else {
+ return 'title="' + tooltip + '"';
}
}
+
return '';
},
- beforeUpdate : function(){
+ beforeUpdate : function() {
this.grid.stopEditing(true);
},
- updateHeaders : function(){
+ updateHeaders : function() {
this.innerHd.firstChild.innerHTML = this.renderHeaders();
- this.innerHd.firstChild.style.width = this.getOffsetWidth();
- this.innerHd.firstChild.firstChild.style.width = this.getTotalWidth();
+
+ this.updateHeaderWidth(false);
+ },
+
+
+ updateHeaderWidth: function(updateMain) {
+ var innerHdChild = this.innerHd.firstChild,
+ totalWidth = this.getTotalWidth();
+
+ innerHdChild.style.width = this.getOffsetWidth();
+ innerHdChild.firstChild.style.width = totalWidth;
+
+ if (updateMain !== false) {
+ this.mainBody.dom.style.width = totalWidth;
+ }
},
- focusRow : function(row){
+ focusRow : function(row) {
this.focusCell(row, 0, false);
},
- focusCell : function(row, col, hscroll){
+ focusCell : function(row, col, hscroll) {
this.syncFocusEl(this.ensureVisible(row, col, hscroll));
- if(Ext.isGecko){
- this.focusEl.focus();
- }else{
- this.focusEl.focus.defer(1, this.focusEl);
+
+ var focusEl = this.focusEl;
+
+ if (Ext.isGecko) {
+ focusEl.focus();
+ } else {
+ focusEl.focus.defer(1, focusEl);
}
},
- resolveCell : function(row, col, hscroll){
- if(!Ext.isNumber(row)){
+
+ resolveCell : function(row, col, hscroll) {
+ if (!Ext.isNumber(row)) {
row = row.rowIndex;
}
- if(!this.ds){
+
+ if (!this.ds) {
return null;
}
- if(row < 0 || row >= this.ds.getCount()){
+
+ if (row < 0 || row >= this.ds.getCount()) {
return null;
}
col = (col !== undefined ? col : 0);
- var rowEl = this.getRow(row),
- cm = this.cm,
- colCount = cm.getColumnCount(),
+ var rowEl = this.getRow(row),
+ colModel = this.cm,
+ colCount = colModel.getColumnCount(),
cellEl;
- if(!(hscroll === false && col === 0)){
- while(col < colCount && cm.isHidden(col)){
+
+ if (!(hscroll === false && col === 0)) {
+ while (col < colCount && colModel.isHidden(col)) {
col++;
}
+
cellEl = this.getCell(row, col);
}
return {row: rowEl, cell: cellEl};
},
- getResolvedXY : function(resolved){
- if(!resolved){
+
+ getResolvedXY : function(resolved) {
+ if (!resolved) {
return null;
}
- var s = this.scroller.dom, c = resolved.cell, r = resolved.row;
- return c ? Ext.fly(c).getXY() : [this.el.getX(), Ext.fly(r).getY()];
+
+ var cell = resolved.cell,
+ row = resolved.row;
+
+ if (cell) {
+ return Ext.fly(cell).getXY();
+ } else {
+ return [this.el.getX(), Ext.fly(row).getY()];
+ }
},
- syncFocusEl : function(row, col, hscroll){
+
+ syncFocusEl : function(row, col, hscroll) {
var xy = row;
- if(!Ext.isArray(xy)){
+
+ if (!Ext.isArray(xy)) {
row = Math.min(row, Math.max(0, this.getRows().length-1));
+
if (isNaN(row)) {
return;
}
+
xy = this.getResolvedXY(this.resolveCell(row, col, hscroll));
}
- this.focusEl.setXY(xy||this.scroller.getXY());
+
+ this.focusEl.setXY(xy || this.scroller.getXY());
},
- ensureVisible : function(row, col, hscroll){
+
+ ensureVisible : function(row, col, hscroll) {
var resolved = this.resolveCell(row, col, hscroll);
- if(!resolved || !resolved.row){
- return;
+
+ if (!resolved || !resolved.row) {
+ return null;
}
- var rowEl = resolved.row,
+ var rowEl = resolved.row,
cellEl = resolved.cell,
c = this.scroller.dom,
- ctop = 0,
p = rowEl,
+ ctop = 0,
stop = this.el.dom;
- while(p && p != stop){
+ while (p && p != stop) {
ctop += p.offsetTop;
p = p.offsetParent;
}
sbot = stop + ch;
- if(ctop < stop){
+ if (ctop < stop) {
c.scrollTop = ctop;
- }else if(cbot > sbot){
+ } else if(cbot > sbot) {
c.scrollTop = cbot-ch;
}
- if(hscroll !== false){
- var cleft = parseInt(cellEl.offsetLeft, 10);
- var cright = cleft + cellEl.offsetWidth;
-
- var sleft = parseInt(c.scrollLeft, 10);
- var sright = sleft + c.clientWidth;
- if(cleft < sleft){
+ if (hscroll !== false) {
+ var cleft = parseInt(cellEl.offsetLeft, 10),
+ cright = cleft + cellEl.offsetWidth,
+ sleft = parseInt(c.scrollLeft, 10),
+ sright = sleft + c.clientWidth;
+
+ if (cleft < sleft) {
c.scrollLeft = cleft;
- }else if(cright > sright){
+ } else if(cright > sright) {
c.scrollLeft = cright-c.clientWidth;
}
}
+
return this.getResolvedXY(resolved);
},
Ext.DomHelper.insertHtml('beforeEnd', this.mainBody.dom, html);
}
if (!isUpdate) {
- this.fireEvent('rowsinserted', this, firstRow, lastRow);
this.processRows(firstRow);
+ this.fireEvent('rowsinserted', this, firstRow, lastRow);
} else if (firstRow === 0 || firstRow >= last) {
Ext.fly(this.getRow(firstRow)).addClass(firstRow === 0 ? this.firstRowCls : this.lastRowCls);
},
- deleteRows : function(dm, firstRow, lastRow){
- if(dm.getRowCount()<1){
+ deleteRows : function(dm, firstRow, lastRow) {
+ if (dm.getRowCount() < 1) {
this.refresh();
- }else{
+ } else {
this.fireEvent('beforerowsdeleted', this, firstRow, lastRow);
this.removeRows(firstRow, lastRow);
},
- getColumnStyle : function(col, isHeader){
- var style = !isHeader ? (this.cm.config[col].css || '') : '';
- style += 'width:'+this.getColumnWidth(col)+';';
- if(this.cm.isHidden(col)){
- style += 'display:none;';
+ getColumnStyle : function(colIndex, isHeader) {
+ var colModel = this.cm,
+ colConfig = colModel.config,
+ style = isHeader ? '' : colConfig[colIndex].css || '',
+ align = colConfig[colIndex].align;
+
+ style += String.format("width: {0};", this.getColumnWidth(colIndex));
+
+ if (colModel.isHidden(colIndex)) {
+ style += 'display: none; ';
}
- var align = this.cm.config[col].align;
- if(align){
- style += 'text-align:'+align+';';
+
+ if (align) {
+ style += String.format("text-align: {0};", align);
}
+
return style;
},
- getColumnWidth : function(col){
- var w = this.cm.getColumnWidth(col);
- if(Ext.isNumber(w)){
- return (Ext.isBorderBox || (Ext.isWebKit && !Ext.isSafari2) ? w : (w - this.borderWidth > 0 ? w - this.borderWidth : 0)) + 'px';
+ getColumnWidth : function(column) {
+ var columnWidth = this.cm.getColumnWidth(column),
+ borderWidth = this.borderWidth;
+
+ if (Ext.isNumber(columnWidth)) {
+ if (Ext.isBorderBox || (Ext.isWebKit && !Ext.isSafari2)) {
+ return columnWidth + "px";
+ } else {
+ return Math.max(columnWidth - borderWidth, 0) + "px";
+ }
+ } else {
+ return columnWidth;
}
- return w;
},
- getTotalWidth : function(){
- return this.cm.getTotalWidth()+'px';
+ getTotalWidth : function() {
+ return this.cm.getTotalWidth() + 'px';
},
- fitColumns : function(preventRefresh, onlyExpand, omitColumn){
- var cm = this.cm, i;
- var tw = cm.getTotalWidth(false);
- var aw = this.grid.getGridEl().getWidth(true)-this.getScrollOffset();
-
- if(aw < 20){
- return;
- }
- var extra = aw - tw;
-
- if(extra === 0){
+ fitColumns : function(preventRefresh, onlyExpand, omitColumn) {
+ var grid = this.grid,
+ colModel = this.cm,
+ totalColWidth = colModel.getTotalWidth(false),
+ gridWidth = this.getGridInnerWidth(),
+ extraWidth = gridWidth - totalColWidth,
+ columns = [],
+ extraCol = 0,
+ width = 0,
+ colWidth, fraction, i;
+
+
+ if (gridWidth < 20 || extraWidth === 0) {
return false;
}
-
- var vc = cm.getColumnCount(true);
- var ac = vc-(Ext.isNumber(omitColumn) ? 1 : 0);
- if(ac === 0){
- ac = 1;
+
+ var visibleColCount = colModel.getColumnCount(true),
+ totalColCount = colModel.getColumnCount(false),
+ adjCount = visibleColCount - (Ext.isNumber(omitColumn) ? 1 : 0);
+
+ if (adjCount === 0) {
+ adjCount = 1;
omitColumn = undefined;
}
- var colCount = cm.getColumnCount();
- var cols = [];
- var extraCol = 0;
- var width = 0;
- var w;
- for (i = 0; i < colCount; i++){
- if(!cm.isHidden(i) && !cm.isFixed(i) && i !== omitColumn){
- w = cm.getColumnWidth(i);
- cols.push(i);
- extraCol = i;
- cols.push(w);
- width += w;
+
+
+ for (i = 0; i < totalColCount; i++) {
+ if (!colModel.isFixed(i) && i !== omitColumn) {
+ colWidth = colModel.getColumnWidth(i);
+ columns.push(i, colWidth);
+
+ if (!colModel.isHidden(i)) {
+ extraCol = i;
+ width += colWidth;
+ }
}
}
- var frac = (aw - cm.getTotalWidth())/width;
- while (cols.length){
- w = cols.pop();
- i = cols.pop();
- cm.setColumnWidth(i, Math.max(this.grid.minColumnWidth, Math.floor(w + w*frac)), true);
+
+ fraction = (gridWidth - colModel.getTotalWidth()) / width;
+
+ while (columns.length) {
+ colWidth = columns.pop();
+ i = columns.pop();
+
+ colModel.setColumnWidth(i, Math.max(grid.minColumnWidth, Math.floor(colWidth + colWidth * fraction)), true);
}
-
- if((tw = cm.getTotalWidth(false)) > aw){
- var adjustCol = ac != vc ? omitColumn : extraCol;
- cm.setColumnWidth(adjustCol, Math.max(1,
- cm.getColumnWidth(adjustCol)- (tw-aw)), true);
+
+
+ totalColWidth = colModel.getTotalWidth(false);
+
+ if (totalColWidth > gridWidth) {
+ var adjustCol = (adjCount == visibleColCount) ? extraCol : omitColumn,
+ newWidth = Math.max(1, colModel.getColumnWidth(adjustCol) - (totalColWidth - gridWidth));
+
+ colModel.setColumnWidth(adjustCol, newWidth, true);
}
-
- if(preventRefresh !== true){
+
+ if (preventRefresh !== true) {
this.updateAllColumnWidths();
}
-
-
+
return true;
},
- autoExpand : function(preventUpdate){
- var g = this.grid, cm = this.cm;
- if(!this.userResized && g.autoExpandColumn){
- var tw = cm.getTotalWidth(false);
- var aw = this.grid.getGridEl().getWidth(true)-this.getScrollOffset();
- if(tw != aw){
- var ci = cm.getIndexById(g.autoExpandColumn);
- var currentWidth = cm.getColumnWidth(ci);
- var cw = Math.min(Math.max(((aw-tw)+currentWidth), g.autoExpandMin), g.autoExpandMax);
- if(cw != currentWidth){
- cm.setColumnWidth(ci, cw, true);
- if(preventUpdate !== true){
- this.updateColumnWidth(ci, cw);
+ autoExpand : function(preventUpdate) {
+ var grid = this.grid,
+ colModel = this.cm,
+ gridWidth = this.getGridInnerWidth(),
+ totalColumnWidth = colModel.getTotalWidth(false),
+ autoExpandColumn = grid.autoExpandColumn;
+
+ if (!this.userResized && autoExpandColumn) {
+ if (gridWidth != totalColumnWidth) {
+
+ var colIndex = colModel.getIndexById(autoExpandColumn),
+ currentWidth = colModel.getColumnWidth(colIndex),
+ desiredWidth = gridWidth - totalColumnWidth + currentWidth,
+ newWidth = Math.min(Math.max(desiredWidth, grid.autoExpandMin), grid.autoExpandMax);
+
+ if (currentWidth != newWidth) {
+ colModel.setColumnWidth(colIndex, newWidth, true);
+
+ if (preventUpdate !== true) {
+ this.updateColumnWidth(colIndex, newWidth);
}
}
}
}
},
+
+
+ getGridInnerWidth: function() {
+ return this.grid.getGridEl().getWidth(true) - this.getScrollOffset();
+ },
- getColumnData : function(){
+ getColumnData : function() {
+ var columns = [],
+ colModel = this.cm,
+ colCount = colModel.getColumnCount(),
+ fields = this.ds.fields,
+ i, name;
- var cs = [],
- cm = this.cm,
- colCount = cm.getColumnCount();
-
- for (var i = 0; i < colCount; i++) {
- var name = cm.getDataIndex(i);
-
- cs[i] = {
- name : (!Ext.isDefined(name) ? this.ds.fields.get(i).name : name),
- renderer: cm.getRenderer(i),
- scope : cm.getRendererScope(i),
- id : cm.getColumnId(i),
+ for (i = 0; i < colCount; i++) {
+ name = colModel.getDataIndex(i);
+
+ columns[i] = {
+ name : Ext.isDefined(name) ? name : (fields.get(i) ? fields.get(i).name : undefined),
+ renderer: colModel.getRenderer(i),
+ scope : colModel.getRendererScope(i),
+ id : colModel.getColumnId(i),
style : this.getColumnStyle(i)
};
}
-
- return cs;
+
+ return columns;
},
- renderRows : function(startRow, endRow){
+ renderRows : function(startRow, endRow) {
+ var grid = this.grid,
+ store = grid.store,
+ stripe = grid.stripeRows,
+ colModel = grid.colModel,
+ colCount = colModel.getColumnCount(),
+ rowCount = store.getCount(),
+ records;
- var g = this.grid, cm = g.colModel, ds = g.store, stripe = g.stripeRows;
- var colCount = cm.getColumnCount();
-
- if(ds.getCount() < 1){
+ if (rowCount < 1) {
return '';
}
-
- var cs = this.getColumnData();
-
+
startRow = startRow || 0;
- endRow = !Ext.isDefined(endRow) ? ds.getCount()-1 : endRow;
-
+ endRow = Ext.isDefined(endRow) ? endRow : rowCount - 1;
+ records = store.getRange(startRow, endRow);
- var rs = ds.getRange(startRow, endRow);
-
- return this.doRender(cs, rs, ds, startRow, colCount, stripe);
+ return this.doRender(this.getColumnData(), records, store, startRow, colCount, stripe);
},
},
- refreshRow : function(record){
- var ds = this.ds, index;
- if(Ext.isNumber(record)){
- index = record;
- record = ds.getAt(index);
- if(!record){
- return;
+ refreshRow: function(record) {
+ var store = this.ds,
+ colCount = this.cm.getColumnCount(),
+ columns = this.getColumnData(),
+ last = colCount - 1,
+ cls = ['x-grid3-row'],
+ rowParams = {
+ tstyle: String.format("width: {0};", this.getTotalWidth())
+ },
+ colBuffer = [],
+ cellTpl = this.templates.cell,
+ rowIndex, row, column, meta, css, i;
+
+ if (Ext.isNumber(record)) {
+ rowIndex = record;
+ record = store.getAt(rowIndex);
+ } else {
+ rowIndex = store.indexOf(record);
+ }
+
+
+ if (!record || rowIndex < 0) {
+ return;
+ }
+
+
+ for (i = 0; i < colCount; i++) {
+ column = columns[i];
+
+ if (i == 0) {
+ css = 'x-grid3-cell-first';
+ } else {
+ css = (i == last) ? 'x-grid3-cell-last ' : '';
}
- }else{
- index = ds.indexOf(record);
- if(index < 0){
- return;
+
+ meta = {
+ id : column.id,
+ style : column.style,
+ css : css,
+ attr : "",
+ cellAttr: ""
+ };
+
+ meta.value = column.renderer.call(column.scope, record.data[column.name], meta, record, rowIndex, i, store);
+
+ if (Ext.isEmpty(meta.value)) {
+ meta.value = ' ';
}
+
+ if (this.markDirty && record.dirty && typeof record.modified[column.name] != 'undefined') {
+ meta.css += ' x-grid3-dirty-cell';
+ }
+
+ colBuffer[i] = cellTpl.apply(meta);
}
- this.insertRows(ds, index, index, true);
- this.getRow(index).rowIndex = index;
- this.onRemove(ds, record, index+1, true);
- this.fireEvent('rowupdated', this, index, record);
+
+ row = this.getRow(rowIndex);
+ row.className = '';
+
+ if (this.grid.stripeRows && ((rowIndex + 1) % 2 === 0)) {
+ cls.push('x-grid3-row-alt');
+ }
+
+ if (this.getRowClass) {
+ rowParams.cols = colCount;
+ cls.push(this.getRowClass(record, rowIndex, rowParams, store));
+ }
+
+ this.fly(row).addClass(cls).setStyle(rowParams.tstyle);
+ rowParams.cells = colBuffer.join("");
+ row.innerHTML = this.templates.rowInner.apply(rowParams);
+
+ this.fireEvent('rowupdated', this, rowIndex, record);
},
- refresh : function(headersToo){
+ refresh : function(headersToo) {
this.fireEvent('beforerefresh', this);
this.grid.stopEditing(true);
var result = this.renderBody();
this.mainBody.update(result).setWidth(this.getTotalWidth());
- if(headersToo === true){
+ if (headersToo === true) {
this.updateHeaders();
this.updateHeaderSortState();
}
},
- applyEmptyText : function(){
- if(this.emptyText && !this.hasRows()){
+ applyEmptyText : function() {
+ if (this.emptyText && !this.hasRows()) {
this.mainBody.update('<div class="x-grid-empty">' + this.emptyText + '</div>');
}
},
- updateHeaderSortState : function(){
+ updateHeaderSortState : function() {
var state = this.ds.getSortState();
if (!state) {
return;
this.sortState = state;
var sortColumn = this.cm.findColumnIndex(state.field);
- if (sortColumn != -1){
+ if (sortColumn != -1) {
var sortDir = state.direction;
this.updateSortIcon(sortColumn, sortDir);
}
},
- clearHeaderSortState : function(){
+ clearHeaderSortState : function() {
if (!this.sortState) {
return;
}
},
- destroy : function(){
- if (this.scrollToTopTask && this.scrollToTopTask.cancel){
- this.scrollToTopTask.cancel();
- }
- if(this.colMenu){
- Ext.menu.MenuMgr.unregister(this.colMenu);
- this.colMenu.destroy();
- delete this.colMenu;
- }
- if(this.hmenu){
- Ext.menu.MenuMgr.unregister(this.hmenu);
- this.hmenu.destroy();
- delete this.hmenu;
+ destroy : function() {
+ var me = this,
+ grid = me.grid,
+ gridEl = grid.getGridEl(),
+ dragZone = me.dragZone,
+ splitZone = me.splitZone,
+ columnDrag = me.columnDrag,
+ columnDrop = me.columnDrop,
+ scrollToTopTask = me.scrollToTopTask,
+ columnDragData,
+ columnDragProxy;
+
+ if (scrollToTopTask && scrollToTopTask.cancel) {
+ scrollToTopTask.cancel();
}
+
+ Ext.destroyMembers(me, 'colMenu', 'hmenu');
- this.initData(null, null);
- this.purgeListeners();
- Ext.fly(this.innerHd).un("click", this.handleHdDown, this);
+ me.initData(null, null);
+ me.purgeListeners();
+
+ Ext.fly(me.innerHd).un("click", me.handleHdDown, me);
- if(this.grid.enableColumnMove){
+ if (grid.enableColumnMove) {
+ columnDragData = columnDrag.dragData;
+ columnDragProxy = columnDrag.proxy;
Ext.destroy(
- this.columnDrag.el,
- this.columnDrag.proxy.ghost,
- this.columnDrag.proxy.el,
- this.columnDrop.el,
- this.columnDrop.proxyTop,
- this.columnDrop.proxyBottom,
- this.columnDrag.dragData.ddel,
- this.columnDrag.dragData.header
+ columnDrag.el,
+ columnDragProxy.ghost,
+ columnDragProxy.el,
+ columnDrop.el,
+ columnDrop.proxyTop,
+ columnDrop.proxyBottom,
+ columnDragData.ddel,
+ columnDragData.header
);
- if (this.columnDrag.proxy.anim) {
- Ext.destroy(this.columnDrag.proxy.anim);
+
+ if (columnDragProxy.anim) {
+ Ext.destroy(columnDragProxy.anim);
}
- delete this.columnDrag.proxy.ghost;
- delete this.columnDrag.dragData.ddel;
- delete this.columnDrag.dragData.header;
- this.columnDrag.destroy();
- delete Ext.dd.DDM.locationCache[this.columnDrag.id];
- delete this.columnDrag._domRef;
+
+ delete columnDragProxy.ghost;
+ delete columnDragData.ddel;
+ delete columnDragData.header;
+ columnDrag.destroy();
+
+ delete Ext.dd.DDM.locationCache[columnDrag.id];
+ delete columnDrag._domRef;
- delete this.columnDrop.proxyTop;
- delete this.columnDrop.proxyBottom;
- this.columnDrop.destroy();
- delete Ext.dd.DDM.locationCache["gridHeader" + this.grid.getGridEl().id];
- delete this.columnDrop._domRef;
- delete Ext.dd.DDM.ids[this.columnDrop.ddGroup];
+ delete columnDrop.proxyTop;
+ delete columnDrop.proxyBottom;
+ columnDrop.destroy();
+ delete Ext.dd.DDM.locationCache["gridHeader" + gridEl.id];
+ delete columnDrop._domRef;
+ delete Ext.dd.DDM.ids[columnDrop.ddGroup];
}
- if (this.splitZone){
- this.splitZone.destroy();
- delete this.splitZone._domRef;
- delete Ext.dd.DDM.ids["gridSplitters" + this.grid.getGridEl().id];
+ if (splitZone) {
+ splitZone.destroy();
+ delete splitZone._domRef;
+ delete Ext.dd.DDM.ids["gridSplitters" + gridEl.id];
}
- Ext.fly(this.innerHd).removeAllListeners();
- Ext.removeNode(this.innerHd);
- delete this.innerHd;
+ Ext.fly(me.innerHd).removeAllListeners();
+ Ext.removeNode(me.innerHd);
+ delete me.innerHd;
Ext.destroy(
- this.el,
- this.mainWrap,
- this.mainHd,
- this.scroller,
- this.mainBody,
- this.focusEl,
- this.resizeMarker,
- this.resizeProxy,
- this.activeHdBtn,
- this.dragZone,
- this.splitZone,
- this._flyweight
+ me.el,
+ me.mainWrap,
+ me.mainHd,
+ me.scroller,
+ me.mainBody,
+ me.focusEl,
+ me.resizeMarker,
+ me.resizeProxy,
+ me.activeHdBtn,
+ me._flyweight,
+ dragZone,
+ splitZone
);
- delete this.grid.container;
+ delete grid.container;
- if(this.dragZone){
- this.dragZone.destroy();
+ if (dragZone) {
+ dragZone.destroy();
}
Ext.dd.DDM.currentTarget = null;
- delete Ext.dd.DDM.locationCache[this.grid.getGridEl().id];
+ delete Ext.dd.DDM.locationCache[gridEl.id];
- Ext.EventManager.removeResizeListener(this.onWindowResize, this);
+ Ext.EventManager.removeResizeListener(me.onWindowResize, me);
},
- onDenyColumnHide : function(){
+ onDenyColumnHide : function() {
},
- render : function(){
- if(this.autoFill){
+ render : function() {
+ if (this.autoFill) {
var ct = this.grid.ownerCt;
- if (ct && ct.getLayout()){
- ct.on('afterlayout', function(){
+
+ if (ct && ct.getLayout()) {
+ ct.on('afterlayout', function() {
this.fitColumns(true, true);
this.updateHeaders();
+ this.updateHeaderSortState();
}, this, {single: true});
- }else{
- this.fitColumns(true, true);
}
- }else if(this.forceFit){
+ } else if (this.forceFit) {
this.fitColumns(true, false);
- }else if(this.grid.autoExpandColumn){
+ } else if (this.grid.autoExpandColumn) {
this.autoExpand(true);
}
-
- this.renderUI();
+
+ this.grid.getGridEl().dom.innerHTML = this.renderUI();
+
+ this.afterRenderUI();
},
- initData : function(ds, cm){
- if(this.ds){
- this.ds.un('load', this.onLoad, this);
- this.ds.un('datachanged', this.onDataChange, this);
- this.ds.un('add', this.onAdd, this);
- this.ds.un('remove', this.onRemove, this);
- this.ds.un('update', this.onUpdate, this);
- this.ds.un('clear', this.onClear, this);
- if(this.ds !== ds && this.ds.autoDestroy){
- this.ds.destroy();
- }
- }
- if(ds){
- ds.on({
- scope: this,
- load: this.onLoad,
- datachanged: this.onDataChange,
- add: this.onAdd,
- remove: this.onRemove,
- update: this.onUpdate,
- clear: this.onClear
+
+ initData : function(newStore, newColModel) {
+ var me = this;
+
+ if (me.ds) {
+ var oldStore = me.ds;
+
+ oldStore.un('add', me.onAdd, me);
+ oldStore.un('load', me.onLoad, me);
+ oldStore.un('clear', me.onClear, me);
+ oldStore.un('remove', me.onRemove, me);
+ oldStore.un('update', me.onUpdate, me);
+ oldStore.un('datachanged', me.onDataChange, me);
+
+ if (oldStore !== newStore && oldStore.autoDestroy) {
+ oldStore.destroy();
+ }
+ }
+
+ if (newStore) {
+ newStore.on({
+ scope : me,
+ load : me.onLoad,
+ add : me.onAdd,
+ remove : me.onRemove,
+ update : me.onUpdate,
+ clear : me.onClear,
+ datachanged: me.onDataChange
});
}
- this.ds = ds;
-
- if(this.cm){
- this.cm.un('configchange', this.onColConfigChange, this);
- this.cm.un('widthchange', this.onColWidthChange, this);
- this.cm.un('headerchange', this.onHeaderChange, this);
- this.cm.un('hiddenchange', this.onHiddenChange, this);
- this.cm.un('columnmoved', this.onColumnMove, this);
- }
- if(cm){
- delete this.lastViewWidth;
- cm.on({
- scope: this,
- configchange: this.onColConfigChange,
- widthchange: this.onColWidthChange,
- headerchange: this.onHeaderChange,
- hiddenchange: this.onHiddenChange,
- columnmoved: this.onColumnMove
+
+ if (me.cm) {
+ var oldColModel = me.cm;
+
+ oldColModel.un('configchange', me.onColConfigChange, me);
+ oldColModel.un('widthchange', me.onColWidthChange, me);
+ oldColModel.un('headerchange', me.onHeaderChange, me);
+ oldColModel.un('hiddenchange', me.onHiddenChange, me);
+ oldColModel.un('columnmoved', me.onColumnMove, me);
+ }
+
+ if (newColModel) {
+ delete me.lastViewWidth;
+
+ newColModel.on({
+ scope : me,
+ configchange: me.onColConfigChange,
+ widthchange : me.onColWidthChange,
+ headerchange: me.onHeaderChange,
+ hiddenchange: me.onHiddenChange,
+ columnmoved : me.onColumnMove
});
}
- this.cm = cm;
+
+ me.ds = newStore;
+ me.cm = newColModel;
},
onDataChange : function(){
- this.refresh();
+ this.refresh(true);
this.updateHeaderSortState();
this.syncFocusEl(0);
},
- onClear : function(){
+ onClear : function() {
this.refresh();
this.syncFocusEl(0);
},
- onUpdate : function(ds, record){
+ onUpdate : function(store, record) {
this.refreshRow(record);
},
- onAdd : function(ds, records, index){
- this.insertRows(ds, index, index + (records.length-1));
+ onAdd : function(store, records, index) {
+ this.insertRows(store, index, index + (records.length-1));
},
- onRemove : function(ds, record, index, isUpdate){
- if(isUpdate !== true){
+ onRemove : function(store, record, index, isUpdate) {
+ if (isUpdate !== true) {
this.fireEvent('beforerowremoved', this, index, record);
}
+
this.removeRow(index);
- if(isUpdate !== true){
+
+ if (isUpdate !== true) {
this.processRows(index);
this.applyEmptyText();
this.fireEvent('rowremoved', this, index, record);
},
- onLoad : function(){
- if (Ext.isGecko){
+ onLoad : function() {
+ if (Ext.isGecko) {
if (!this.scrollToTopTask) {
this.scrollToTopTask = new Ext.util.DelayedTask(this.scrollToTop, this);
}
this.scrollToTopTask.delay(1);
- }else{
+ } else {
this.scrollToTop();
}
},
- onColWidthChange : function(cm, col, width){
+ onColWidthChange : function(cm, col, width) {
this.updateColumnWidth(col, width);
},
- onHeaderChange : function(cm, col, text){
+ onHeaderChange : function(cm, col, text) {
this.updateHeaders();
},
- onHiddenChange : function(cm, col, hidden){
+ onHiddenChange : function(cm, col, hidden) {
this.updateColumnHidden(col, hidden);
},
- onColumnMove : function(cm, oldIndex, newIndex){
+ onColumnMove : function(cm, oldIndex, newIndex) {
this.indexMap = null;
- var s = this.getScrollState();
this.refresh(true);
- this.restoreScroll(s);
+ this.restoreScroll(this.getScrollState());
+
this.afterMove(newIndex);
this.grid.fireEvent('columnmove', oldIndex, newIndex);
},
- onColConfigChange : function(){
+ onColConfigChange : function() {
delete this.lastViewWidth;
this.indexMap = null;
this.refresh(true);
- initUI : function(grid){
+ initUI : function(grid) {
grid.on('headerclick', this.onHeaderClick, this);
},
- initEvents : function(){
- },
+ initEvents : Ext.emptyFn,
- onHeaderClick : function(g, index){
- if(this.headersDisabled || !this.cm.isSortable(index)){
+ onHeaderClick : function(g, index) {
+ if (this.headersDisabled || !this.cm.isSortable(index)) {
return;
}
g.stopEditing(true);
},
- onRowOver : function(e, t){
- var row;
- if((row = this.findRowIndex(t)) !== false){
- this.addRowClass(row, 'x-grid3-row-over');
+ onRowOver : function(e, target) {
+ var row = this.findRowIndex(target);
+
+ if (row !== false) {
+ this.addRowClass(row, this.rowOverCls);
}
},
- onRowOut : function(e, t){
- var row;
- if((row = this.findRowIndex(t)) !== false && !e.within(this.getRow(row), true)){
- this.removeRowClass(row, 'x-grid3-row-over');
+ onRowOut : function(e, target) {
+ var row = this.findRowIndex(target);
+
+ if (row !== false && !e.within(this.getRow(row), true)) {
+ this.removeRowClass(row, this.rowOverCls);
}
},
- handleWheel : function(e){
- e.stopPropagation();
- },
-
-
- onRowSelect : function(row){
+ onRowSelect : function(row) {
this.addRowClass(row, this.selectedRowClass);
},
- onRowDeselect : function(row){
+ onRowDeselect : function(row) {
this.removeRowClass(row, this.selectedRowClass);
},
- onCellSelect : function(row, col){
+ onCellSelect : function(row, col) {
var cell = this.getCell(row, col);
- if(cell){
+ if (cell) {
this.fly(cell).addClass('x-grid3-cell-selected');
}
},
- onCellDeselect : function(row, col){
+ onCellDeselect : function(row, col) {
var cell = this.getCell(row, col);
- if(cell){
+ if (cell) {
this.fly(cell).removeClass('x-grid3-cell-selected');
}
},
- onColumnSplitterMoved : function(i, w){
+ handleWheel : function(e) {
+ e.stopPropagation();
+ },
+
+
+ onColumnSplitterMoved : function(cellIndex, width) {
this.userResized = true;
- var cm = this.grid.colModel;
- cm.setColumnWidth(i, w, true);
+ this.grid.colModel.setColumnWidth(cellIndex, width, true);
- if(this.forceFit){
- this.fitColumns(true, false, i);
+ if (this.forceFit) {
+ this.fitColumns(true, false, cellIndex);
this.updateAllColumnWidths();
- }else{
- this.updateColumnWidth(i, w);
+ } else {
+ this.updateColumnWidth(cellIndex, width);
this.syncHeaderScroll();
}
- this.grid.fireEvent('columnresize', i, w);
+ this.grid.fireEvent('columnresize', cellIndex, width);
},
- handleHdMenuClick : function(item){
- var index = this.hdCtxIndex,
- cm = this.cm,
- ds = this.ds,
- id = item.getItemId();
- switch(id){
+ beforeColMenuShow : function() {
+ var colModel = this.cm,
+ colCount = colModel.getColumnCount(),
+ colMenu = this.colMenu,
+ i;
+
+ colMenu.removeAll();
+
+ for (i = 0; i < colCount; i++) {
+ if (colModel.config[i].hideable !== false) {
+ colMenu.add(new Ext.menu.CheckItem({
+ text : colModel.getColumnHeader(i),
+ itemId : 'col-' + colModel.getColumnId(i),
+ checked : !colModel.isHidden(i),
+ disabled : colModel.config[i].hideable === false,
+ hideOnClick: false
+ }));
+ }
+ }
+ },
+
+
+ handleHdMenuClick : function(item) {
+ var store = this.ds,
+ dataIndex = this.cm.getDataIndex(this.hdCtxIndex);
+
+ switch (item.getItemId()) {
case 'asc':
- ds.sort(cm.getDataIndex(index), 'ASC');
+ store.sort(dataIndex, 'ASC');
break;
case 'desc':
- ds.sort(cm.getDataIndex(index), 'DESC');
+ store.sort(dataIndex, 'DESC');
break;
default:
- index = cm.getIndexById(id.substr(4));
- if(index != -1){
- if(item.checked && cm.getColumnsBy(this.isHideableColumn, this).length <= 1){
- this.onDenyColumnHide();
- return false;
- }
- cm.setHidden(index, item.checked);
- }
+ this.handleHdMenuClickDefault(item);
}
return true;
},
-
- isHideableColumn : function(c){
- return !c.hidden;
- },
-
- beforeColMenuShow : function(){
- var cm = this.cm, colCount = cm.getColumnCount();
- this.colMenu.removeAll();
- for(var i = 0; i < colCount; i++){
- if(cm.config[i].hideable !== false){
- this.colMenu.add(new Ext.menu.CheckItem({
- itemId: 'col-'+cm.getColumnId(i),
- text: cm.getColumnHeader(i),
- checked: !cm.isHidden(i),
- hideOnClick:false,
- disabled: cm.config[i].hideable === false
- }));
+ handleHdMenuClickDefault: function(item) {
+ var colModel = this.cm,
+ itemId = item.getItemId(),
+ index = colModel.getIndexById(itemId.substr(4));
+
+ if (index != -1) {
+ if (item.checked && colModel.getColumnsBy(this.isHideableColumn, this).length <= 1) {
+ this.onDenyColumnHide();
+ return;
}
+ colModel.setHidden(index, item.checked);
}
},
- handleHdDown : function(e, t){
- if(Ext.fly(t).hasClass('x-grid3-hd-btn')){
+ handleHdDown : function(e, target) {
+ if (Ext.fly(target).hasClass('x-grid3-hd-btn')) {
e.stopEvent();
- var hd = this.findHeaderCell(t);
- Ext.fly(hd).addClass('x-grid3-hd-menu-open');
- var index = this.getCellIndex(hd);
+
+ var colModel = this.cm,
+ header = this.findHeaderCell(target),
+ index = this.getCellIndex(header),
+ sortable = colModel.isSortable(index),
+ menu = this.hmenu,
+ menuItems = menu.items,
+ menuCls = this.headerMenuOpenCls;
+
this.hdCtxIndex = index;
- var ms = this.hmenu.items, cm = this.cm;
- ms.get('asc').setDisabled(!cm.isSortable(index));
- ms.get('desc').setDisabled(!cm.isSortable(index));
- this.hmenu.on('hide', function(){
- Ext.fly(hd).removeClass('x-grid3-hd-menu-open');
+
+ Ext.fly(header).addClass(menuCls);
+ menuItems.get('asc').setDisabled(!sortable);
+ menuItems.get('desc').setDisabled(!sortable);
+
+ menu.on('hide', function() {
+ Ext.fly(header).removeClass(menuCls);
}, this, {single:true});
- this.hmenu.show(t, 'tl-bl?');
+
+ menu.show(target, 'tl-bl?');
}
},
- handleHdOver : function(e, t){
- var hd = this.findHeaderCell(t);
- if(hd && !this.headersDisabled){
- this.activeHdRef = t;
- this.activeHdIndex = this.getCellIndex(hd);
- var fly = this.fly(hd);
- this.activeHdRegion = fly.getRegion();
- if(!this.cm.isMenuDisabled(this.activeHdIndex)){
- fly.addClass('x-grid3-hd-over');
- this.activeHdBtn = fly.child('.x-grid3-hd-btn');
- if(this.activeHdBtn){
- this.activeHdBtn.dom.style.height = (hd.firstChild.offsetHeight-1)+'px';
+ handleHdMove : function(e) {
+ var header = this.findHeaderCell(this.activeHdRef);
+
+ if (header && !this.headersDisabled) {
+ var handleWidth = this.splitHandleWidth || 5,
+ activeRegion = this.activeHdRegion,
+ headerStyle = header.style,
+ colModel = this.cm,
+ cursor = '',
+ pageX = e.getPageX();
+
+ if (this.grid.enableColumnResize !== false) {
+ var activeHeaderIndex = this.activeHdIndex,
+ previousVisible = this.getPreviousVisible(activeHeaderIndex),
+ currentResizable = colModel.isResizable(activeHeaderIndex),
+ previousResizable = previousVisible && colModel.isResizable(previousVisible),
+ inLeftResizer = pageX - activeRegion.left <= handleWidth,
+ inRightResizer = activeRegion.right - pageX <= (!this.activeHdBtn ? handleWidth : 2);
+
+ if (inLeftResizer && previousResizable) {
+ cursor = Ext.isAir ? 'move' : Ext.isWebKit ? 'e-resize' : 'col-resize';
+ } else if (inRightResizer && currentResizable) {
+ cursor = Ext.isAir ? 'move' : Ext.isWebKit ? 'w-resize' : 'col-resize';
}
}
+
+ headerStyle.cursor = cursor;
+ }
+ },
+
+
+ getPreviousVisible: function(index) {
+ while (index > 0) {
+ if (!this.cm.isHidden(index - 1)) {
+ return index;
+ }
+ index--;
}
+ return undefined;
},
- handleHdMove : function(e, t){
- var hd = this.findHeaderCell(this.activeHdRef);
- if(hd && !this.headersDisabled){
- var hw = this.splitHandleWidth || 5,
- r = this.activeHdRegion,
- x = e.getPageX(),
- ss = hd.style,
- cur = '';
- if(this.grid.enableColumnResize !== false){
- if(x - r.left <= hw && this.cm.isResizable(this.activeHdIndex-1)){
- cur = Ext.isAir ? 'move' : Ext.isWebKit ? 'e-resize' : 'col-resize';
- }else if(r.right - x <= (!this.activeHdBtn ? hw : 2) && this.cm.isResizable(this.activeHdIndex)){
- cur = Ext.isAir ? 'move' : Ext.isWebKit ? 'w-resize' : 'col-resize';
+ handleHdOver : function(e, target) {
+ var header = this.findHeaderCell(target);
+
+ if (header && !this.headersDisabled) {
+ var fly = this.fly(header);
+
+ this.activeHdRef = target;
+ this.activeHdIndex = this.getCellIndex(header);
+ this.activeHdRegion = fly.getRegion();
+
+ if (!this.isMenuDisabled(this.activeHdIndex, fly)) {
+ fly.addClass('x-grid3-hd-over');
+ this.activeHdBtn = fly.child('.x-grid3-hd-btn');
+
+ if (this.activeHdBtn) {
+ this.activeHdBtn.dom.style.height = (header.firstChild.offsetHeight - 1) + 'px';
}
}
- ss.cursor = cur;
}
},
- handleHdOut : function(e, t){
- var hd = this.findHeaderCell(t);
- if(hd && (!Ext.isIE || !e.within(hd, true))){
+ handleHdOut : function(e, target) {
+ var header = this.findHeaderCell(target);
+
+ if (header && (!Ext.isIE || !e.within(header, true))) {
this.activeHdRef = null;
- this.fly(hd).removeClass('x-grid3-hd-over');
- hd.style.cursor = '';
+ this.fly(header).removeClass('x-grid3-hd-over');
+ header.style.cursor = '';
}
},
+
+
+ isMenuDisabled: function(cellIndex, el) {
+ return this.cm.isMenuDisabled(cellIndex);
+ },
- hasRows : function(){
+ hasRows : function() {
var fc = this.mainBody.dom.firstChild;
return fc && fc.nodeType == 1 && fc.className != 'x-grid-empty';
},
+
+
+ isHideableColumn : function(c) {
+ return !c.hidden;
+ },
- bind : function(d, c){
+ bind : function(d, c) {
this.initData(d, c);
}
});
Ext.grid.GridView.SplitDragZone = Ext.extend(Ext.dd.DDProxy, {
-
+
constructor: function(grid, hd){
this.grid = grid;
this.view = grid.getView();
var t = this.view.findHeaderCell(e.getTarget());
if(t && this.allowHeaderDrag(e)){
var xy = this.view.fly(t).getXY(),
- x = xy[0],
- y = xy[1],
- exy = e.getXY(), ex = exy[0],
- w = t.offsetWidth, adjust = false;
+ x = xy[0],
+ exy = e.getXY(),
+ ex = exy[0],
+ w = t.offsetWidth,
+ adjust = false;
if((ex - x) <= this.hw){
adjust = -1;
}
});
+Ext.grid.PivotGridView = Ext.extend(Ext.grid.GridView, {
+
+
+ colHeaderCellCls: 'grid-hd-group-cell',
+
+
+ title: '',
+
+
+
+
+ getColumnHeaders: function() {
+ return this.grid.topAxis.buildHeaders();;
+ },
+
+
+ getRowHeaders: function() {
+ return this.grid.leftAxis.buildHeaders();
+ },
+
+
+ renderRows : function(startRow, endRow) {
+ var grid = this.grid,
+ rows = grid.extractData(),
+ rowCount = rows.length,
+ templates = this.templates,
+ renderer = grid.renderer,
+ hasRenderer = typeof renderer == 'function',
+ getCellCls = this.getCellCls,
+ hasGetCellCls = typeof getCellCls == 'function',
+ cellTemplate = templates.cell,
+ rowTemplate = templates.row,
+ rowBuffer = [],
+ meta = {},
+ tstyle = 'width:' + this.getGridInnerWidth() + 'px;',
+ colBuffer, column, i;
+
+ startRow = startRow || 0;
+ endRow = Ext.isDefined(endRow) ? endRow : rowCount - 1;
+
+ for (i = 0; i < rowCount; i++) {
+ row = rows[i];
+ colCount = row.length;
+ colBuffer = [];
+
+ rowIndex = startRow + i;
+
+
+ for (j = 0; j < colCount; j++) {
+ cell = row[j];
+
+ meta.css = j === 0 ? 'x-grid3-cell-first ' : (j == (colCount - 1) ? 'x-grid3-cell-last ' : '');
+ meta.attr = meta.cellAttr = '';
+ meta.value = cell;
+
+ if (Ext.isEmpty(meta.value)) {
+ meta.value = ' ';
+ }
+
+ if (hasRenderer) {
+ meta.value = renderer(meta.value);
+ }
+
+ if (hasGetCellCls) {
+ meta.css += getCellCls(meta.value) + ' ';
+ }
+
+ colBuffer[colBuffer.length] = cellTemplate.apply(meta);
+ }
+
+ rowBuffer[rowBuffer.length] = rowTemplate.apply({
+ tstyle: tstyle,
+ cols : colCount,
+ cells : colBuffer.join(""),
+ alt : ''
+ });
+ }
+
+ return rowBuffer.join("");
+ },
+
+
+ masterTpl: new Ext.Template(
+ '<div class="x-grid3 x-pivotgrid" hidefocus="true">',
+ '<div class="x-grid3-viewport">',
+ '<div class="x-grid3-header">',
+ '<div class="x-grid3-header-title"><span>{title}</span></div>',
+ '<div class="x-grid3-header-inner">',
+ '<div class="x-grid3-header-offset" style="{ostyle}"></div>',
+ '</div>',
+ '<div class="x-clear"></div>',
+ '</div>',
+ '<div class="x-grid3-scroller">',
+ '<div class="x-grid3-row-headers"></div>',
+ '<div class="x-grid3-body" style="{bstyle}">{body}</div>',
+ '<a href="#" class="x-grid3-focus" tabIndex="-1"></a>',
+ '</div>',
+ '</div>',
+ '<div class="x-grid3-resize-marker"> </div>',
+ '<div class="x-grid3-resize-proxy"> </div>',
+ '</div>'
+ ),
+
+
+ initTemplates: function() {
+ Ext.grid.PivotGridView.superclass.initTemplates.apply(this, arguments);
+
+ var templates = this.templates || {};
+ if (!templates.gcell) {
+ templates.gcell = new Ext.XTemplate(
+ '<td class="x-grid3-hd x-grid3-gcell x-grid3-td-{id} ux-grid-hd-group-row-{row} ' + this.colHeaderCellCls + '" style="{style}">',
+ '<div {tooltip} class="x-grid3-hd-inner x-grid3-hd-{id}" unselectable="on" style="{istyle}">',
+ this.grid.enableHdMenu ? '<a class="x-grid3-hd-btn" href="#"></a>' : '', '{value}',
+ '</div>',
+ '</td>'
+ );
+ }
+
+ this.templates = templates;
+ this.hrowRe = new RegExp("ux-grid-hd-group-row-(\\d+)", "");
+ },
+
+
+ initElements: function() {
+ Ext.grid.PivotGridView.superclass.initElements.apply(this, arguments);
+
+
+ this.rowHeadersEl = new Ext.Element(this.scroller.child('div.x-grid3-row-headers'));
+
+
+ this.headerTitleEl = new Ext.Element(this.mainHd.child('div.x-grid3-header-title'));
+ },
+
+
+ getGridInnerWidth: function() {
+ var previousWidth = Ext.grid.PivotGridView.superclass.getGridInnerWidth.apply(this, arguments);
+
+ return previousWidth - this.getTotalRowHeaderWidth();
+ },
+
+
+ getTotalRowHeaderWidth: function() {
+ var headers = this.getRowHeaders(),
+ length = headers.length,
+ total = 0,
+ i;
+
+ for (i = 0; i< length; i++) {
+ total += headers[i].width;
+ }
+
+ return total;
+ },
+
+
+ getTotalColumnHeaderHeight: function() {
+ return this.getColumnHeaders().length * 21;
+ },
+
+
+ renderUI : function() {
+ var templates = this.templates,
+ innerWidth = this.getGridInnerWidth();
+
+ return templates.master.apply({
+ body : templates.body.apply({rows:' '}),
+ ostyle: 'width:' + innerWidth + 'px',
+ bstyle: 'width:' + innerWidth + 'px'
+ });
+ },
+
+
+ onLayout: function(width, height) {
+ Ext.grid.PivotGridView.superclass.onLayout.apply(this, arguments);
+
+ var width = this.getGridInnerWidth();
+
+ this.resizeColumnHeaders(width);
+ this.resizeAllRows(width);
+ },
+
+
+ refresh : function(headersToo) {
+ this.fireEvent('beforerefresh', this);
+ this.grid.stopEditing(true);
+
+ var result = this.renderBody();
+ this.mainBody.update(result).setWidth(this.getGridInnerWidth());
+ if (headersToo === true) {
+ this.updateHeaders();
+ this.updateHeaderSortState();
+ }
+ this.processRows(0, true);
+ this.layout();
+ this.applyEmptyText();
+ this.fireEvent('refresh', this);
+ },
+
+
+ renderHeaders: Ext.emptyFn,
+
+
+ fitColumns: Ext.emptyFn,
+
+
+ resizeColumnHeaders: function(width) {
+ var topAxis = this.grid.topAxis;
+
+ if (topAxis.rendered) {
+ topAxis.el.setWidth(width);
+ }
+ },
+
+
+ resizeRowHeaders: function() {
+ var rowHeaderWidth = this.getTotalRowHeaderWidth(),
+ marginStyle = String.format("margin-left: {0}px;", rowHeaderWidth);
+
+ this.rowHeadersEl.setWidth(rowHeaderWidth);
+ this.mainBody.applyStyles(marginStyle);
+ Ext.fly(this.innerHd).applyStyles(marginStyle);
+
+ this.headerTitleEl.setWidth(rowHeaderWidth);
+ this.headerTitleEl.setHeight(this.getTotalColumnHeaderHeight());
+ },
+
+
+ resizeAllRows: function(width) {
+ var rows = this.getRows(),
+ length = rows.length,
+ i;
+
+ for (i = 0; i < length; i++) {
+ Ext.fly(rows[i]).setWidth(width);
+ Ext.fly(rows[i]).child('table').setWidth(width);
+ }
+ },
+
+
+ updateHeaders: function() {
+ this.renderGroupRowHeaders();
+ this.renderGroupColumnHeaders();
+ },
+
+
+ renderGroupRowHeaders: function() {
+ var leftAxis = this.grid.leftAxis;
+
+ this.resizeRowHeaders();
+ leftAxis.rendered = false;
+ leftAxis.render(this.rowHeadersEl);
+
+ this.setTitle(this.title);
+ },
+
+
+ setTitle: function(title) {
+ this.headerTitleEl.child('span').dom.innerHTML = title;
+ },
+
+
+ renderGroupColumnHeaders: function() {
+ var topAxis = this.grid.topAxis;
+
+ topAxis.rendered = false;
+ topAxis.render(this.innerHd.firstChild);
+ },
+
+
+ isMenuDisabled: function(cellIndex, el) {
+ return true;
+ }
+});
+Ext.grid.PivotAxis = Ext.extend(Ext.Component, {
+
+ orientation: 'horizontal',
+
+
+ defaultHeaderWidth: 80,
+
+
+ paddingWidth: 7,
+
+
+ setDimensions: function(dimensions) {
+ this.dimensions = dimensions;
+ },
+
+
+ onRender: function(ct, position) {
+ var rows = this.orientation == 'horizontal'
+ ? this.renderHorizontalRows()
+ : this.renderVerticalRows();
+
+ this.el = Ext.DomHelper.overwrite(ct.dom, {tag: 'table', cn: rows}, true);
+ },
+
+
+ renderHorizontalRows: function() {
+ var headers = this.buildHeaders(),
+ rowCount = headers.length,
+ rows = [],
+ cells, cols, colCount, i, j;
+
+ for (i = 0; i < rowCount; i++) {
+ cells = [];
+ cols = headers[i].items;
+ colCount = cols.length;
+
+ for (j = 0; j < colCount; j++) {
+ cells.push({
+ tag: 'td',
+ html: cols[j].header,
+ colspan: cols[j].span
+ });
+ }
+
+ rows[i] = {
+ tag: 'tr',
+ cn: cells
+ };
+ }
+
+ return rows;
+ },
+
+
+ renderVerticalRows: function() {
+ var headers = this.buildHeaders(),
+ colCount = headers.length,
+ rowCells = [],
+ rows = [],
+ rowCount, col, row, colWidth, i, j;
+
+ for (i = 0; i < colCount; i++) {
+ col = headers[i];
+ colWidth = col.width || 80;
+ rowCount = col.items.length;
+
+ for (j = 0; j < rowCount; j++) {
+ row = col.items[j];
+
+ rowCells[row.start] = rowCells[row.start] || [];
+ rowCells[row.start].push({
+ tag : 'td',
+ html : row.header,
+ rowspan: row.span,
+ width : Ext.isBorderBox ? colWidth : colWidth - this.paddingWidth
+ });
+ }
+ }
+
+ rowCount = rowCells.length;
+ for (i = 0; i < rowCount; i++) {
+ rows[i] = {
+ tag: 'tr',
+ cn : rowCells[i]
+ };
+ }
+
+ return rows;
+ },
+
+
+ getTuples: function() {
+ var newStore = new Ext.data.Store({});
+
+ newStore.data = this.store.data.clone();
+ newStore.fields = this.store.fields;
+
+ var sorters = [],
+ dimensions = this.dimensions,
+ length = dimensions.length,
+ i;
+
+ for (i = 0; i < length; i++) {
+ sorters.push({
+ field : dimensions[i].dataIndex,
+ direction: dimensions[i].direction || 'ASC'
+ });
+ }
+
+ newStore.sort(sorters);
+
+ var records = newStore.data.items,
+ hashes = [],
+ tuples = [],
+ recData, hash, info, data, key;
+
+ length = records.length;
+
+ for (i = 0; i < length; i++) {
+ info = this.getRecordInfo(records[i]);
+ data = info.data;
+ hash = "";
+
+ for (key in data) {
+ hash += data[key] + '---';
+ }
+
+ if (hashes.indexOf(hash) == -1) {
+ hashes.push(hash);
+ tuples.push(info);
+ }
+ }
+
+ newStore.destroy();
+
+ return tuples;
+ },
+
+
+ getRecordInfo: function(record) {
+ var dimensions = this.dimensions,
+ length = dimensions.length,
+ data = {},
+ dimension, dataIndex, i;
+
+
+ for (i = 0; i < length; i++) {
+ dimension = dimensions[i];
+ dataIndex = dimension.dataIndex;
+
+ data[dataIndex] = record.get(dataIndex);
+ }
+
+
+
+ var createMatcherFunction = function(data) {
+ return function(record) {
+ for (var dataIndex in data) {
+ if (record.get(dataIndex) != data[dataIndex]) {
+ return false;
+ }
+ }
+
+ return true;
+ };
+ };
+
+ return {
+ data: data,
+ matcher: createMatcherFunction(data)
+ };
+ },
+
+
+ buildHeaders: function() {
+ var tuples = this.getTuples(),
+ rowCount = tuples.length,
+ dimensions = this.dimensions,
+ colCount = dimensions.length,
+ headers = [],
+ tuple, rows, currentHeader, previousHeader, span, start, isLast, changed, i, j;
+
+ for (i = 0; i < colCount; i++) {
+ dimension = dimensions[i];
+ rows = [];
+ span = 0;
+ start = 0;
+
+ for (j = 0; j < rowCount; j++) {
+ tuple = tuples[j];
+ isLast = j == (rowCount - 1);
+ currentHeader = tuple.data[dimension.dataIndex];
+
+
+ changed = previousHeader != undefined && previousHeader != currentHeader;
+ if (i > 0 && j > 0) {
+ changed = changed || tuple.data[dimensions[i-1].dataIndex] != tuples[j-1].data[dimensions[i-1].dataIndex];
+ }
+
+ if (changed) {
+ rows.push({
+ header: previousHeader,
+ span : span,
+ start : start
+ });
+
+ start += span;
+ span = 0;
+ }
+
+ if (isLast) {
+ rows.push({
+ header: currentHeader,
+ span : span + 1,
+ start : start
+ });
+
+ start += span;
+ span = 0;
+ }
+
+ previousHeader = currentHeader;
+ span++;
+ }
+
+ headers.push({
+ items: rows,
+ width: dimension.width || this.defaultHeaderWidth
+ });
+
+ previousHeader = undefined;
+ }
+
+ return headers;
+ }
+});
+
Ext.grid.HeaderDragZone = Ext.extend(Ext.dd.DragZone, {
maxDragWidth: 120,
Ext.grid.ColumnModel = Ext.extend(Ext.util.Observable, {
defaultWidth: 100,
+
defaultSortable: false,
+
+
- constructor : function(config){
+ constructor : function(config) {
- if(config.columns){
+ if (config.columns) {
Ext.apply(this, config);
this.setConfig(config.columns, true);
- }else{
+ } else {
this.setConfig(config, true);
}
+
this.addEvents(
"widthchange",
+
"headerchange",
+
"hiddenchange",
+
"columnmoved",
+
"configchange"
);
+
Ext.grid.ColumnModel.superclass.constructor.call(this);
},
- getColumnId : function(index){
+ getColumnId : function(index) {
return this.config[index].id;
},
- getColumnAt : function(index){
+ getColumnAt : function(index) {
return this.config[index];
},
- setConfig : function(config, initial){
+ setConfig : function(config, initial) {
var i, c, len;
- if(!initial){
+
+ if (!initial) {
delete this.totalWidth;
- for(i = 0, len = this.config.length; i < len; i++){
+
+ for (i = 0, len = this.config.length; i < len; i++) {
c = this.config[i];
- if(c.setEditor){
+
+ if (c.setEditor) {
c.setEditor(null);
}
this.config = config;
this.lookup = {};
- for(i = 0, len = config.length; i < len; i++){
+ for (i = 0, len = config.length; i < len; i++) {
c = Ext.applyIf(config[i], this.defaults);
- if(Ext.isEmpty(c.id)){
+
+ if (Ext.isEmpty(c.id)) {
c.id = i;
}
- if(!c.isColumn){
+
+ if (!c.isColumn) {
var Cls = Ext.grid.Column.types[c.xtype || 'gridcolumn'];
c = new Cls(c);
config[i] = c;
}
+
this.lookup[c.id] = c;
}
- if(!initial){
+
+ if (!initial) {
this.fireEvent('configchange', this);
}
},
- getColumnById : function(id){
+ getColumnById : function(id) {
return this.lookup[id];
},
- getIndexById : function(id){
- for(var i = 0, len = this.config.length; i < len; i++){
- if(this.config[i].id == id){
+ getIndexById : function(id) {
+ for (var i = 0, len = this.config.length; i < len; i++) {
+ if (this.config[i].id == id) {
return i;
}
}
},
- moveColumn : function(oldIndex, newIndex){
- var c = this.config[oldIndex];
- this.config.splice(oldIndex, 1);
- this.config.splice(newIndex, 0, c);
+ moveColumn : function(oldIndex, newIndex) {
+ var config = this.config,
+ c = config[oldIndex];
+
+ config.splice(oldIndex, 1);
+ config.splice(newIndex, 0, c);
this.dataMap = null;
this.fireEvent("columnmoved", this, oldIndex, newIndex);
},
- getColumnCount : function(visibleOnly){
- if(visibleOnly === true){
- var c = 0;
- for(var i = 0, len = this.config.length; i < len; i++){
- if(!this.isHidden(i)){
+ getColumnCount : function(visibleOnly) {
+ var length = this.config.length,
+ c = 0,
+ i;
+
+ if (visibleOnly === true) {
+ for (i = 0; i < length; i++) {
+ if (!this.isHidden(i)) {
c++;
}
}
+
return c;
}
- return this.config.length;
+
+ return length;
},
- getColumnsBy : function(fn, scope){
- var r = [];
- for(var i = 0, len = this.config.length; i < len; i++){
- var c = this.config[i];
- if(fn.call(scope||this, c, i) === true){
- r[r.length] = c;
+ getColumnsBy : function(fn, scope) {
+ var config = this.config,
+ length = config.length,
+ result = [],
+ i, c;
+
+ for (i = 0; i < length; i++){
+ c = config[i];
+
+ if (fn.call(scope || this, c, i) === true) {
+ result[result.length] = c;
}
}
- return r;
+
+ return result;
},
- isSortable : function(col){
+ isSortable : function(col) {
return !!this.config[col].sortable;
},
- isMenuDisabled : function(col){
+ isMenuDisabled : function(col) {
return !!this.config[col].menuDisabled;
},
- getRenderer : function(col){
- if(!this.config[col].renderer){
- return Ext.grid.ColumnModel.defaultRenderer;
- }
- return this.config[col].renderer;
+ getRenderer : function(col) {
+ return this.config[col].renderer || Ext.grid.ColumnModel.defaultRenderer;
},
- getRendererScope : function(col){
+ getRendererScope : function(col) {
return this.config[col].scope;
},
- setRenderer : function(col, fn){
+ setRenderer : function(col, fn) {
this.config[col].renderer = fn;
},
- getColumnWidth : function(col){
- return this.config[col].width;
+ getColumnWidth : function(col) {
+ var width = this.config[col].width;
+ if(typeof width != 'number'){
+ width = this.defaultWidth;
+ }
+ return width;
},
- setColumnWidth : function(col, width, suppressEvent){
+ setColumnWidth : function(col, width, suppressEvent) {
this.config[col].width = width;
this.totalWidth = null;
- if(!suppressEvent){
+
+ if (!suppressEvent) {
this.fireEvent("widthchange", this, col, width);
}
},
- getTotalWidth : function(includeHidden){
- if(!this.totalWidth){
+ getTotalWidth : function(includeHidden) {
+ if (!this.totalWidth) {
this.totalWidth = 0;
- for(var i = 0, len = this.config.length; i < len; i++){
- if(includeHidden || !this.isHidden(i)){
+ for (var i = 0, len = this.config.length; i < len; i++) {
+ if (includeHidden || !this.isHidden(i)) {
this.totalWidth += this.getColumnWidth(i);
}
}
},
- getColumnHeader : function(col){
+ getColumnHeader : function(col) {
return this.config[col].header;
},
- setColumnHeader : function(col, header){
+ setColumnHeader : function(col, header) {
this.config[col].header = header;
this.fireEvent("headerchange", this, col, header);
},
- getColumnTooltip : function(col){
+ getColumnTooltip : function(col) {
return this.config[col].tooltip;
},
- setColumnTooltip : function(col, tooltip){
+ setColumnTooltip : function(col, tooltip) {
this.config[col].tooltip = tooltip;
},
- getDataIndex : function(col){
+ getDataIndex : function(col) {
return this.config[col].dataIndex;
},
- setDataIndex : function(col, dataIndex){
+ setDataIndex : function(col, dataIndex) {
this.config[col].dataIndex = dataIndex;
},
- findColumnIndex : function(dataIndex){
+ findColumnIndex : function(dataIndex) {
var c = this.config;
for(var i = 0, len = c.length; i < len; i++){
if(c[i].dataIndex == dataIndex){
},
- isCellEditable : function(colIndex, rowIndex){
+ isCellEditable : function(colIndex, rowIndex) {
var c = this.config[colIndex],
ed = c.editable;
},
- getCellEditor : function(colIndex, rowIndex){
+ getCellEditor : function(colIndex, rowIndex) {
return this.config[colIndex].getCellEditor(rowIndex);
},
- setEditable : function(col, editable){
+ setEditable : function(col, editable) {
this.config[col].editable = editable;
},
- isHidden : function(colIndex){
+ isHidden : function(colIndex) {
return !!this.config[colIndex].hidden;
},
- isFixed : function(colIndex){
+ isFixed : function(colIndex) {
return !!this.config[colIndex].fixed;
},
- isResizable : function(colIndex){
+ isResizable : function(colIndex) {
return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
},
- setHidden : function(colIndex, hidden){
+
+ setHidden : function(colIndex, hidden) {
var c = this.config[colIndex];
if(c.hidden !== hidden){
c.hidden = hidden;
},
- setEditor : function(col, editor){
+ setEditor : function(col, editor) {
this.config[col].setEditor(editor);
},
- destroy : function(){
- var c;
- for(var i = 0, len = this.config.length; i < len; i++){
- c = this.config[i];
- if(c.setEditor){
- c.setEditor(null);
- }
+ destroy : function() {
+ var length = this.config.length,
+ i = 0;
+
+ for (; i < length; i++){
+ this.config[i].destroy();
}
+ delete this.config;
+ delete this.lookup;
this.purgeListeners();
+ },
+
+
+ setState : function(col, state) {
+ state = Ext.applyIf(state, this.defaults);
+ Ext.apply(this.config[col], state);
}
});
-Ext.grid.ColumnModel.defaultRenderer = function(value){
- if(typeof value == "string" && value.length < 1){
+Ext.grid.ColumnModel.defaultRenderer = function(value) {
+ if (typeof value == "string" && value.length < 1) {
return " ";
}
return value;
}
this.rowNav = new Ext.KeyNav(this.grid.getGridEl(), {
- 'up' : function(e){
- if(!e.shiftKey || this.singleSelect){
- this.selectPrevious(false);
- }else if(this.last !== false && this.lastActive !== false){
- var last = this.last;
- this.selectRange(this.last, this.lastActive-1);
- this.grid.getView().focusRow(this.lastActive);
- if(last !== false){
- this.last = last;
- }
- }else{
- this.selectFirstRow();
- }
- },
- 'down' : function(e){
- if(!e.shiftKey || this.singleSelect){
- this.selectNext(false);
- }else if(this.last !== false && this.lastActive !== false){
- var last = this.last;
- this.selectRange(this.last, this.lastActive+1);
- this.grid.getView().focusRow(this.lastActive);
- if(last !== false){
- this.last = last;
- }
- }else{
- this.selectFirstRow();
- }
- },
+ up: this.onKeyPress,
+ down: this.onKeyPress,
scope: this
});
rowremoved: this.onRemove
});
},
+
+ onKeyPress : function(e, name){
+ var up = name == 'up',
+ method = up ? 'selectPrevious' : 'selectNext',
+ add = up ? -1 : 1,
+ last;
+ if(!e.shiftKey || this.singleSelect){
+ this[method](false);
+ }else if(this.last !== false && this.lastActive !== false){
+ last = this.last;
+ this.selectRange(this.last, this.lastActive + add);
+ this.grid.getView().focusRow(this.lastActive);
+ if(last !== false){
+ this.last = last;
+ }
+ }else{
+ this.selectFirstRow();
+ }
+ },
onRefresh : function(){
- var ds = this.grid.store, index;
- var s = this.getSelections();
+ var ds = this.grid.store,
+ s = this.getSelections(),
+ i = 0,
+ len = s.length,
+ index, r;
+
+ this.silent = true;
this.clearSelections(true);
- for(var i = 0, len = s.length; i < len; i++){
- var r = s[i];
+ for(; i < len; i++){
+ r = s[i];
if((index = ds.indexOfId(r.id)) != -1){
this.selectRow(index, true);
}
if(s.length != this.selections.getCount()){
this.fireEvent('selectionchange', this);
}
+ this.silent = false;
},
if(!keepExisting){
this.clearSelections();
}
- var ds = this.grid.store;
- for(var i = 0, len = records.length; i < len; i++){
+ var ds = this.grid.store,
+ i = 0,
+ len = records.length;
+ for(; i < len; i++){
this.selectRow(ds.indexOf(records[i]), true);
}
},
each : function(fn, scope){
- var s = this.getSelections();
- for(var i = 0, len = s.length; i < len; i++){
+ var s = this.getSelections(),
+ i = 0,
+ len = s.length;
+
+ for(; i < len; i++){
if(fn.call(scope || this, s[i], i) === false){
return false;
}
return;
}
if(fast !== true){
- var ds = this.grid.store;
- var s = this.selections;
+ var ds = this.grid.store,
+ s = this.selections;
s.each(function(r){
this.deselectRow(ds.indexOfId(r.id));
}, this);
if(!preventViewNotify){
this.grid.getView().onRowSelect(index);
}
- this.fireEvent('rowselect', this, index, r);
- this.fireEvent('selectionchange', this);
+ if(!this.silent){
+ this.fireEvent('rowselect', this, index, r);
+ this.fireEvent('selectionchange', this);
+ }
}
},
},
- restoreLast : function(){
- if(this._last){
- this.last = this._last;
- }
- },
-
-
acceptsNav : function(row, col, cm){
return !cm.isHidden(col) && cm.isCellEditable(col, row);
},
g = this.grid,
last = g.lastEdit,
ed = g.activeEditor,
+ shift = e.shiftKey,
ae, last, r, c;
- var shift = e.shiftKey;
+
if(k == e.TAB){
e.stopEvent();
ed.completeEdit();
r = newCell[0];
c = newCell[1];
- if(last.row != r){
- this.selectRow(r);
- }
+ this.onEditorSelect(r, last.row);
if(g.isEditor && g.editing){
ae = g.activeEditor;
}
},
- destroy : function(){
- if(this.rowNav){
- this.rowNav.disable();
- this.rowNav = null;
+ onEditorSelect: function(row, lastRow){
+ if(lastRow != row){
+ this.selectRow(row);
}
+ },
+
+ destroy : function(){
+ Ext.destroy(this.rowNav);
+ this.rowNav = null;
Ext.grid.RowSelectionModel.superclass.destroy.call(this);
}
});
-Ext.grid.Column = Ext.extend(Object, {
+
+Ext.grid.Column = Ext.extend(Ext.util.Observable, {
var ed = this.editor;
delete this.editor;
this.setEditor(ed);
+ this.addEvents(
+
+ 'click',
+
+ 'contextmenu',
+
+ 'dblclick',
+
+ 'mousedown'
+ );
+ Ext.grid.Column.superclass.constructor.call(this);
},
- renderer : function(value){
- if(Ext.isString(value) && value.length < 1){
- return ' ';
+ processEvent : function(name, e, grid, rowIndex, colIndex){
+ return this.fireEvent(name, this, grid, rowIndex, e);
+ },
+
+
+ destroy: function() {
+ if(this.setEditor){
+ this.setEditor(null);
}
+ this.purgeListeners();
+ },
+
+
+ renderer : function(value){
return value;
},
});
+Ext.grid.ActionColumn = Ext.extend(Ext.grid.Column, {
+
+
+
+
+
+
+
+
+ header: ' ',
+
+ actionIdRe: /x-action-col-(\d+)/,
+
+
+ altText: '',
+
+ constructor: function(cfg) {
+ var me = this,
+ items = cfg.items || (me.items = [me]),
+ l = items.length,
+ i,
+ item;
+
+ Ext.grid.ActionColumn.superclass.constructor.call(me, cfg);
+
+
+
+ me.renderer = function(v, meta) {
+
+ v = Ext.isFunction(cfg.renderer) ? cfg.renderer.apply(this, arguments)||'' : '';
+
+ meta.css += ' x-action-col-cell';
+ for (i = 0; i < l; i++) {
+ item = items[i];
+ v += '<img alt="' + me.altText + '" src="' + (item.icon || Ext.BLANK_IMAGE_URL) +
+ '" class="x-action-col-icon x-action-col-' + String(i) + ' ' + (item.iconCls || '') +
+ ' ' + (Ext.isFunction(item.getClass) ? item.getClass.apply(item.scope||this.scope||this, arguments) : '') + '"' +
+ ((item.tooltip) ? ' ext:qtip="' + item.tooltip + '"' : '') + ' />';
+ }
+ return v;
+ };
+ },
+
+ destroy: function() {
+ delete this.items;
+ delete this.renderer;
+ return Ext.grid.ActionColumn.superclass.destroy.apply(this, arguments);
+ },
+
+
+ processEvent : function(name, e, grid, rowIndex, colIndex){
+ var m = e.getTarget().className.match(this.actionIdRe),
+ item, fn;
+ if (m && (item = this.items[parseInt(m[1], 10)])) {
+ if (name == 'click') {
+ (fn = item.handler || this.handler) && fn.call(item.scope||this.scope||this, grid, rowIndex, colIndex, item, e);
+ } else if ((name == 'mousedown') && (item.stopSelection !== false)) {
+ return false;
+ }
+ }
+ return Ext.grid.ActionColumn.superclass.processEvent.apply(this, arguments);
+ }
+});
+
+
Ext.grid.Column.types = {
gridcolumn : Ext.grid.Column,
booleancolumn: Ext.grid.BooleanColumn,
numbercolumn: Ext.grid.NumberColumn,
datecolumn: Ext.grid.DateColumn,
- templatecolumn: Ext.grid.TemplateColumn
+ templatecolumn: Ext.grid.TemplateColumn,
+ actioncolumn: Ext.grid.ActionColumn
};
Ext.grid.RowNumberer = Ext.extend(Object, {
hideable: false,
dataIndex : '',
id : 'checker',
+ isColumn: true,
constructor : function(){
Ext.grid.CheckboxSelectionModel.superclass.constructor.apply(this, arguments);
-
if(this.checkOnly){
this.handleMouseDown = Ext.emptyFn;
}
initEvents : function(){
Ext.grid.CheckboxSelectionModel.superclass.initEvents.call(this);
this.grid.on('render', function(){
- var view = this.grid.getView();
- view.mainBody.on('mousedown', this.onMouseDown, this);
- Ext.fly(view.innerHd).on('mousedown', this.onHdMouseDown, this);
-
+ Ext.fly(this.grid.getView().innerHd).on('mousedown', this.onHdMouseDown, this);
}, this);
},
-
- handleMouseDown : function() {
- Ext.grid.CheckboxSelectionModel.superclass.handleMouseDown.apply(this, arguments);
- this.mouseHandled = true;
+ processEvent : function(name, e, grid, rowIndex, colIndex){
+ if (name == 'mousedown') {
+ this.onMouseDown(e, e.getTarget());
+ return false;
+ } else {
+ return Ext.grid.Column.prototype.processEvent.apply(this, arguments);
+ }
},
if(e.button === 0 && t.className == 'x-grid3-row-checker'){
e.stopEvent();
var row = e.getTarget('.x-grid3-row');
-
-
- if(!this.mouseHandled && row){
+ if(row){
var index = row.rowIndex;
if(this.isSelected(index)){
this.deselectRow(index);
}
}
}
- this.mouseHandled = false;
},
- onHdMouseDown : function(e, t){
+ onHdMouseDown : function(e, t) {
if(t.className == 'x-grid3-hd-checker'){
e.stopEvent();
var hd = Ext.fly(t.parentNode);
renderer : function(v, p, record){
return '<div class="x-grid3-row-checker"> </div>';
+ },
+
+ onEditorSelect: function(row, lastRow){
+ if(lastRow != row && !this.checkOnly){
+ this.selectRow(row);
+ }
}
});
Ext.grid.CellSelectionModel = Ext.extend(Ext.grid.AbstractSelectionModel, {
initEvents : function(){
this.grid.on('cellmousedown', this.handleMouseDown, this);
- this.grid.on(Ext.EventManager.useKeydown ? 'keydown' : 'keypress', this.handleKeyDown, this);
+ this.grid.on(Ext.EventManager.getKeyEvent(), this.handleKeyDown, this);
this.grid.getView().on({
scope: this,
refresh: this.onViewChange,
destroy : function(){
Ext.grid.PropertyColumnModel.superclass.destroy.call(this);
- for(var ed in this.editors){
- Ext.destroy(this.editors[ed]);
+ this.destroyEditors(this.editors);
+ this.destroyEditors(this.grid.customEditors);
+ },
+
+ destroyEditors: function(editors){
+ for(var ed in editors){
+ Ext.destroy(editors[ed]);
}
}
});
groupMode: 'value',
+
+
+ cancelEditOnToggle: true,
initTemplates : function(){
}
if((item = items.get('showGroups'))){
item.setDisabled(disabled);
- item.setChecked(this.enableGrouping, true);
+ item.setChecked(this.canGroup(), true);
}
},
renderUI : function(){
- Ext.grid.GroupingView.superclass.renderUI.call(this);
- this.mainBody.on('mousedown', this.interceptMouse, this);
+ var markup = Ext.grid.GroupingView.superclass.renderUI.call(this);
if(this.enableGroupingMenu && this.hmenu){
this.hmenu.add('-',{
}
this.hmenu.on('beforeshow', this.beforeMenuShow, this);
}
+ return markup;
},
processEvent: function(name, e){
var field = this.getGroupField(),
prefix = this.getPrefix(field),
- groupValue = hd.id.substring(prefix.length);
+ groupValue = hd.id.substring(prefix.length),
+ emptyRe = new RegExp('gp-' + Ext.escapeRe(field) + '--hd');
groupValue = groupValue.substr(0, groupValue.length - 3);
- if(groupValue){
+
+
+ if(groupValue || emptyRe.test(hd.id)){
this.grid.fireEvent('group' + name, this.grid, field, groupValue, e);
}
+ if(name == 'mousedown' && e.button == 0){
+ this.toggleGroup(hd.parentNode);
+ }
}
},
onGroupByClick : function(){
+ var grid = this.grid;
this.enableGrouping = true;
- this.grid.store.groupBy(this.cm.getDataIndex(this.hdCtxIndex));
- this.grid.fireEvent('groupchange', this, this.grid.store.getGroupState());
+ grid.store.groupBy(this.cm.getDataIndex(this.hdCtxIndex));
+ grid.fireEvent('groupchange', grid, grid.store.getGroupState());
this.beforeMenuShow();
this.refresh();
},
var gel = Ext.get(group);
expanded = Ext.isDefined(expanded) ? expanded : gel.hasClass('x-grid-group-collapsed');
if(this.state[gel.id] !== expanded){
- this.grid.stopEditing(true);
+ if (this.cancelEditOnToggle !== false) {
+ this.grid.stopEditing(true);
+ }
this.state[gel.id] = expanded;
gel[expanded ? 'removeClass' : 'addClass']('x-grid-group-collapsed');
}
},
- interceptMouse : function(e){
- var hd = e.getTarget('.x-grid-group-hd', this.mainBody);
- if(hd){
- e.stopEvent();
- this.toggleGroup(hd.parentNode);
- }
- },
-
-
getGroup : function(v, r, groupRenderer, rowIndex, colIndex, ds){
- var g = groupRenderer ? groupRenderer(v, {}, r, rowIndex, colIndex, ds) : String(v);
+ var column = this.cm.config[colIndex],
+ g = groupRenderer ? groupRenderer.call(column.scope, v, {}, r, rowIndex, colIndex, ds) : String(v);
if(g === '' || g === ' '){
- g = this.cm.config[colIndex].emptyGroupText || this.emptyGroupText;
+ g = column.emptyGroupText || this.emptyGroupText;
}
return g;
},
this.updateGroupWidths();
}
},
+
+ afterRenderUI: function () {
+ Ext.grid.GroupingView.superclass.afterRenderUI.call(this);
+
+ if (this.enableGroupingMenu && this.hmenu) {
+ this.hmenu.add('-',{
+ itemId:'groupBy',
+ text: this.groupByText,
+ handler: this.onGroupByClick,
+ scope: this,
+ iconCls:'x-group-by-icon'
+ });
+
+ if (this.enableNoGroups) {
+ this.hmenu.add({
+ itemId:'showGroups',
+ text: this.showGroupsText,
+ checked: true,
+ checkHandler: this.onShowGroupsClick,
+ scope: this
+ });
+ }
+
+ this.hmenu.on('beforeshow', this.beforeMenuShow, this);
+ }
+ },
renderRows : function(){