rlm@46: /*
rlm@46: * Ext JS Library 2.1
rlm@46: * Copyright(c) 2006-2008, Ext JS, LLC.
rlm@46: * licensing@extjs.com
rlm@46: *
rlm@46: * http://extjs.com/license
rlm@46: */
rlm@46:
rlm@46:
rlm@46: Ext.DomHelper = function(){
rlm@46: var tempTableEl = null;
rlm@46: var emptyTags = /^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i;
rlm@46: var tableRe = /^table|tbody|tr|td$/i;
rlm@46:
rlm@46: var createHtml = function(o){
rlm@46: if(typeof o == 'string'){
rlm@46: return o;
rlm@46: }
rlm@46: var b = "";
rlm@46: if (Ext.isArray(o)) {
rlm@46: for (var i = 0, l = o.length; i < l; i++) {
rlm@46: b += createHtml(o[i]);
rlm@46: }
rlm@46: return b;
rlm@46: }
rlm@46: if(!o.tag){
rlm@46: o.tag = "div";
rlm@46: }
rlm@46: b += "<" + o.tag;
rlm@46: for(var attr in o){
rlm@46: if(attr == "tag" || attr == "children" || attr == "cn" || attr == "html" || typeof o[attr] == "function") continue;
rlm@46: if(attr == "style"){
rlm@46: var s = o["style"];
rlm@46: if(typeof s == "function"){
rlm@46: s = s.call();
rlm@46: }
rlm@46: if(typeof s == "string"){
rlm@46: b += ' style="' + s + '"';
rlm@46: }else if(typeof s == "object"){
rlm@46: b += ' style="';
rlm@46: for(var key in s){
rlm@46: if(typeof s[key] != "function"){
rlm@46: b += key + ":" + s[key] + ";";
rlm@46: }
rlm@46: }
rlm@46: b += '"';
rlm@46: }
rlm@46: }else{
rlm@46: if(attr == "cls"){
rlm@46: b += ' class="' + o["cls"] + '"';
rlm@46: }else if(attr == "htmlFor"){
rlm@46: b += ' for="' + o["htmlFor"] + '"';
rlm@46: }else{
rlm@46: b += " " + attr + '="' + o[attr] + '"';
rlm@46: }
rlm@46: }
rlm@46: }
rlm@46: if(emptyTags.test(o.tag)){
rlm@46: b += "/>";
rlm@46: }else{
rlm@46: b += ">";
rlm@46: var cn = o.children || o.cn;
rlm@46: if(cn){
rlm@46: b += createHtml(cn);
rlm@46: } else if(o.html){
rlm@46: b += o.html;
rlm@46: }
rlm@46: b += "" + o.tag + ">";
rlm@46: }
rlm@46: return b;
rlm@46: };
rlm@46:
rlm@46:
rlm@46: var createDom = function(o, parentNode){
rlm@46: var el;
rlm@46: if (Ext.isArray(o)) { el = document.createDocumentFragment(); for(var i = 0, l = o.length; i < l; i++) {
rlm@46: createDom(o[i], el);
rlm@46: }
rlm@46: } else if (typeof o == "string") { el = document.createTextNode(o);
rlm@46: } else {
rlm@46: el = document.createElement(o.tag||'div');
rlm@46: var useSet = !!el.setAttribute; for(var attr in o){
rlm@46: if(attr == "tag" || attr == "children" || attr == "cn" || attr == "html" || attr == "style" || typeof o[attr] == "function") continue;
rlm@46: if(attr=="cls"){
rlm@46: el.className = o["cls"];
rlm@46: }else{
rlm@46: if(useSet) el.setAttribute(attr, o[attr]);
rlm@46: else el[attr] = o[attr];
rlm@46: }
rlm@46: }
rlm@46: Ext.DomHelper.applyStyles(el, o.style);
rlm@46: var cn = o.children || o.cn;
rlm@46: if(cn){
rlm@46: createDom(cn, el);
rlm@46: } else if(o.html){
rlm@46: el.innerHTML = o.html;
rlm@46: }
rlm@46: }
rlm@46: if(parentNode){
rlm@46: parentNode.appendChild(el);
rlm@46: }
rlm@46: return el;
rlm@46: };
rlm@46:
rlm@46: var ieTable = function(depth, s, h, e){
rlm@46: tempTableEl.innerHTML = [s, h, e].join('');
rlm@46: var i = -1, el = tempTableEl;
rlm@46: while(++i < depth){
rlm@46: el = el.firstChild;
rlm@46: }
rlm@46: return el;
rlm@46: };
rlm@46:
rlm@46: var ts = '
',
rlm@46: tbs = ts+'',
rlm@46: tbe = ''+te,
rlm@46: trs = tbs + '',
rlm@46: tre = '
'+tbe;
rlm@46:
rlm@46:
rlm@46: var insertIntoTable = function(tag, where, el, html){
rlm@46: if(!tempTableEl){
rlm@46: tempTableEl = document.createElement('div');
rlm@46: }
rlm@46: var node;
rlm@46: var before = null;
rlm@46: if(tag == 'td'){
rlm@46: if(where == 'afterbegin' || where == 'beforeend'){ return;
rlm@46: }
rlm@46: if(where == 'beforebegin'){
rlm@46: before = el;
rlm@46: el = el.parentNode;
rlm@46: } else{
rlm@46: before = el.nextSibling;
rlm@46: el = el.parentNode;
rlm@46: }
rlm@46: node = ieTable(4, trs, html, tre);
rlm@46: }
rlm@46: else if(tag == 'tr'){
rlm@46: if(where == 'beforebegin'){
rlm@46: before = el;
rlm@46: el = el.parentNode;
rlm@46: node = ieTable(3, tbs, html, tbe);
rlm@46: } else if(where == 'afterend'){
rlm@46: before = el.nextSibling;
rlm@46: el = el.parentNode;
rlm@46: node = ieTable(3, tbs, html, tbe);
rlm@46: } else{ if(where == 'afterbegin'){
rlm@46: before = el.firstChild;
rlm@46: }
rlm@46: node = ieTable(4, trs, html, tre);
rlm@46: }
rlm@46: } else if(tag == 'tbody'){
rlm@46: if(where == 'beforebegin'){
rlm@46: before = el;
rlm@46: el = el.parentNode;
rlm@46: node = ieTable(2, ts, html, te);
rlm@46: } else if(where == 'afterend'){
rlm@46: before = el.nextSibling;
rlm@46: el = el.parentNode;
rlm@46: node = ieTable(2, ts, html, te);
rlm@46: } else{
rlm@46: if(where == 'afterbegin'){
rlm@46: before = el.firstChild;
rlm@46: }
rlm@46: node = ieTable(3, tbs, html, tbe);
rlm@46: }
rlm@46: } else{ if(where == 'beforebegin' || where == 'afterend'){ return;
rlm@46: }
rlm@46: if(where == 'afterbegin'){
rlm@46: before = el.firstChild;
rlm@46: }
rlm@46: node = ieTable(2, ts, html, te);
rlm@46: }
rlm@46: el.insertBefore(node, before);
rlm@46: return node;
rlm@46: };
rlm@46:
rlm@46:
rlm@46: return {
rlm@46:
rlm@46: useDom : false,
rlm@46:
rlm@46:
rlm@46: markup : function(o){
rlm@46: return createHtml(o);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: applyStyles : function(el, styles){
rlm@46: if(styles){
rlm@46: el = Ext.fly(el);
rlm@46: if(typeof styles == "string"){
rlm@46: var re = /\s?([a-z\-]*)\:\s?([^;]*);?/gi;
rlm@46: var matches;
rlm@46: while ((matches = re.exec(styles)) != null){
rlm@46: el.setStyle(matches[1], matches[2]);
rlm@46: }
rlm@46: }else if (typeof styles == "object"){
rlm@46: for (var style in styles){
rlm@46: el.setStyle(style, styles[style]);
rlm@46: }
rlm@46: }else if (typeof styles == "function"){
rlm@46: Ext.DomHelper.applyStyles(el, styles.call());
rlm@46: }
rlm@46: }
rlm@46: },
rlm@46:
rlm@46:
rlm@46: insertHtml : function(where, el, html){
rlm@46: where = where.toLowerCase();
rlm@46: if(el.insertAdjacentHTML){
rlm@46: if(tableRe.test(el.tagName)){
rlm@46: var rs;
rlm@46: if(rs = insertIntoTable(el.tagName.toLowerCase(), where, el, html)){
rlm@46: return rs;
rlm@46: }
rlm@46: }
rlm@46: switch(where){
rlm@46: case "beforebegin":
rlm@46: el.insertAdjacentHTML('BeforeBegin', html);
rlm@46: return el.previousSibling;
rlm@46: case "afterbegin":
rlm@46: el.insertAdjacentHTML('AfterBegin', html);
rlm@46: return el.firstChild;
rlm@46: case "beforeend":
rlm@46: el.insertAdjacentHTML('BeforeEnd', html);
rlm@46: return el.lastChild;
rlm@46: case "afterend":
rlm@46: el.insertAdjacentHTML('AfterEnd', html);
rlm@46: return el.nextSibling;
rlm@46: }
rlm@46: throw 'Illegal insertion point -> "' + where + '"';
rlm@46: }
rlm@46: var range = el.ownerDocument.createRange();
rlm@46: var frag;
rlm@46: switch(where){
rlm@46: case "beforebegin":
rlm@46: range.setStartBefore(el);
rlm@46: frag = range.createContextualFragment(html);
rlm@46: el.parentNode.insertBefore(frag, el);
rlm@46: return el.previousSibling;
rlm@46: case "afterbegin":
rlm@46: if(el.firstChild){
rlm@46: range.setStartBefore(el.firstChild);
rlm@46: frag = range.createContextualFragment(html);
rlm@46: el.insertBefore(frag, el.firstChild);
rlm@46: return el.firstChild;
rlm@46: }else{
rlm@46: el.innerHTML = html;
rlm@46: return el.firstChild;
rlm@46: }
rlm@46: case "beforeend":
rlm@46: if(el.lastChild){
rlm@46: range.setStartAfter(el.lastChild);
rlm@46: frag = range.createContextualFragment(html);
rlm@46: el.appendChild(frag);
rlm@46: return el.lastChild;
rlm@46: }else{
rlm@46: el.innerHTML = html;
rlm@46: return el.lastChild;
rlm@46: }
rlm@46: case "afterend":
rlm@46: range.setStartAfter(el);
rlm@46: frag = range.createContextualFragment(html);
rlm@46: el.parentNode.insertBefore(frag, el.nextSibling);
rlm@46: return el.nextSibling;
rlm@46: }
rlm@46: throw 'Illegal insertion point -> "' + where + '"';
rlm@46: },
rlm@46:
rlm@46:
rlm@46: insertBefore : function(el, o, returnElement){
rlm@46: return this.doInsert(el, o, returnElement, "beforeBegin");
rlm@46: },
rlm@46:
rlm@46:
rlm@46: insertAfter : function(el, o, returnElement){
rlm@46: return this.doInsert(el, o, returnElement, "afterEnd", "nextSibling");
rlm@46: },
rlm@46:
rlm@46:
rlm@46: insertFirst : function(el, o, returnElement){
rlm@46: return this.doInsert(el, o, returnElement, "afterBegin", "firstChild");
rlm@46: },
rlm@46:
rlm@46: doInsert : function(el, o, returnElement, pos, sibling){
rlm@46: el = Ext.getDom(el);
rlm@46: var newNode;
rlm@46: if(this.useDom){
rlm@46: newNode = createDom(o, null);
rlm@46: (sibling === "firstChild" ? el : el.parentNode).insertBefore(newNode, sibling ? el[sibling] : el);
rlm@46: }else{
rlm@46: var html = createHtml(o);
rlm@46: newNode = this.insertHtml(pos, el, html);
rlm@46: }
rlm@46: return returnElement ? Ext.get(newNode, true) : newNode;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: append : function(el, o, returnElement){
rlm@46: el = Ext.getDom(el);
rlm@46: var newNode;
rlm@46: if(this.useDom){
rlm@46: newNode = createDom(o, null);
rlm@46: el.appendChild(newNode);
rlm@46: }else{
rlm@46: var html = createHtml(o);
rlm@46: newNode = this.insertHtml("beforeEnd", el, html);
rlm@46: }
rlm@46: return returnElement ? Ext.get(newNode, true) : newNode;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: overwrite : function(el, o, returnElement){
rlm@46: el = Ext.getDom(el);
rlm@46: el.innerHTML = createHtml(o);
rlm@46: return returnElement ? Ext.get(el.firstChild, true) : el.firstChild;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: createTemplate : function(o){
rlm@46: var html = createHtml(o);
rlm@46: return new Ext.Template(html);
rlm@46: }
rlm@46: };
rlm@46: }();
rlm@46:
rlm@46:
rlm@46: Ext.Template = function(html){
rlm@46: var a = arguments;
rlm@46: if(Ext.isArray(html)){
rlm@46: html = html.join("");
rlm@46: }else if(a.length > 1){
rlm@46: var buf = [];
rlm@46: for(var i = 0, len = a.length; i < len; i++){
rlm@46: if(typeof a[i] == 'object'){
rlm@46: Ext.apply(this, a[i]);
rlm@46: }else{
rlm@46: buf[buf.length] = a[i];
rlm@46: }
rlm@46: }
rlm@46: html = buf.join('');
rlm@46: }
rlm@46:
rlm@46: this.html = html;
rlm@46: if(this.compiled){
rlm@46: this.compile();
rlm@46: }
rlm@46: };
rlm@46: Ext.Template.prototype = {
rlm@46:
rlm@46: applyTemplate : function(values){
rlm@46: if(this.compiled){
rlm@46: return this.compiled(values);
rlm@46: }
rlm@46: var useF = this.disableFormats !== true;
rlm@46: var fm = Ext.util.Format, tpl = this;
rlm@46: var fn = function(m, name, format, args){
rlm@46: if(format && useF){
rlm@46: if(format.substr(0, 5) == "this."){
rlm@46: return tpl.call(format.substr(5), values[name], values);
rlm@46: }else{
rlm@46: if(args){
rlm@46: var re = /^\s*['"](.*)["']\s*$/;
rlm@46: args = args.split(',');
rlm@46: for(var i = 0, len = args.length; i < len; i++){
rlm@46: args[i] = args[i].replace(re, "$1");
rlm@46: }
rlm@46: args = [values[name]].concat(args);
rlm@46: }else{
rlm@46: args = [values[name]];
rlm@46: }
rlm@46: return fm[format].apply(fm, args);
rlm@46: }
rlm@46: }else{
rlm@46: return values[name] !== undefined ? values[name] : "";
rlm@46: }
rlm@46: };
rlm@46: return this.html.replace(this.re, fn);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: set : function(html, compile){
rlm@46: this.html = html;
rlm@46: this.compiled = null;
rlm@46: if(compile){
rlm@46: this.compile();
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: disableFormats : false,
rlm@46:
rlm@46:
rlm@46: re : /\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,
rlm@46:
rlm@46:
rlm@46: compile : function(){
rlm@46: var fm = Ext.util.Format;
rlm@46: var useF = this.disableFormats !== true;
rlm@46: var sep = Ext.isGecko ? "+" : ",";
rlm@46: var fn = function(m, name, format, args){
rlm@46: if(format && useF){
rlm@46: args = args ? ',' + args : "";
rlm@46: if(format.substr(0, 5) != "this."){
rlm@46: format = "fm." + format + '(';
rlm@46: }else{
rlm@46: format = 'this.call("'+ format.substr(5) + '", ';
rlm@46: args = ", values";
rlm@46: }
rlm@46: }else{
rlm@46: args= ''; format = "(values['" + name + "'] == undefined ? '' : ";
rlm@46: }
rlm@46: return "'"+ sep + format + "values['" + name + "']" + args + ")"+sep+"'";
rlm@46: };
rlm@46: var body;
rlm@46: if(Ext.isGecko){
rlm@46: body = "this.compiled = function(values){ return '" +
rlm@46: this.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn) +
rlm@46: "';};";
rlm@46: }else{
rlm@46: body = ["this.compiled = function(values){ return ['"];
rlm@46: body.push(this.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn));
rlm@46: body.push("'].join('');};");
rlm@46: body = body.join('');
rlm@46: }
rlm@46: eval(body);
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46: call : function(fnName, value, allValues){
rlm@46: return this[fnName](value, allValues);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: insertFirst: function(el, values, returnElement){
rlm@46: return this.doInsert('afterBegin', el, values, returnElement);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: insertBefore: function(el, values, returnElement){
rlm@46: return this.doInsert('beforeBegin', el, values, returnElement);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: insertAfter : function(el, values, returnElement){
rlm@46: return this.doInsert('afterEnd', el, values, returnElement);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: append : function(el, values, returnElement){
rlm@46: return this.doInsert('beforeEnd', el, values, returnElement);
rlm@46: },
rlm@46:
rlm@46: doInsert : function(where, el, values, returnEl){
rlm@46: el = Ext.getDom(el);
rlm@46: var newNode = Ext.DomHelper.insertHtml(where, el, this.applyTemplate(values));
rlm@46: return returnEl ? Ext.get(newNode, true) : newNode;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: overwrite : function(el, values, returnElement){
rlm@46: el = Ext.getDom(el);
rlm@46: el.innerHTML = this.applyTemplate(values);
rlm@46: return returnElement ? Ext.get(el.firstChild, true) : el.firstChild;
rlm@46: }
rlm@46: };
rlm@46:
rlm@46: Ext.Template.prototype.apply = Ext.Template.prototype.applyTemplate;
rlm@46:
rlm@46: Ext.DomHelper.Template = Ext.Template;
rlm@46:
rlm@46:
rlm@46: Ext.Template.from = function(el, config){
rlm@46: el = Ext.getDom(el);
rlm@46: return new Ext.Template(el.value || el.innerHTML, config || '');
rlm@46: };
rlm@46:
rlm@46:
rlm@46: Ext.DomQuery = function(){
rlm@46: var cache = {}, simpleCache = {}, valueCache = {};
rlm@46: var nonSpace = /\S/;
rlm@46: var trimRe = /^\s+|\s+$/g;
rlm@46: var tplRe = /\{(\d+)\}/g;
rlm@46: var modeRe = /^(\s?[\/>+~]\s?|\s|$)/;
rlm@46: var tagTokenRe = /^(#)?([\w-\*]+)/;
rlm@46: var nthRe = /(\d*)n\+?(\d*)/, nthRe2 = /\D/;
rlm@46:
rlm@46: function child(p, index){
rlm@46: var i = 0;
rlm@46: var n = p.firstChild;
rlm@46: while(n){
rlm@46: if(n.nodeType == 1){
rlm@46: if(++i == index){
rlm@46: return n;
rlm@46: }
rlm@46: }
rlm@46: n = n.nextSibling;
rlm@46: }
rlm@46: return null;
rlm@46: };
rlm@46:
rlm@46: function next(n){
rlm@46: while((n = n.nextSibling) && n.nodeType != 1);
rlm@46: return n;
rlm@46: };
rlm@46:
rlm@46: function prev(n){
rlm@46: while((n = n.previousSibling) && n.nodeType != 1);
rlm@46: return n;
rlm@46: };
rlm@46:
rlm@46: function children(d){
rlm@46: var n = d.firstChild, ni = -1;
rlm@46: while(n){
rlm@46: var nx = n.nextSibling;
rlm@46: if(n.nodeType == 3 && !nonSpace.test(n.nodeValue)){
rlm@46: d.removeChild(n);
rlm@46: }else{
rlm@46: n.nodeIndex = ++ni;
rlm@46: }
rlm@46: n = nx;
rlm@46: }
rlm@46: return this;
rlm@46: };
rlm@46:
rlm@46: function byClassName(c, a, v){
rlm@46: if(!v){
rlm@46: return c;
rlm@46: }
rlm@46: var r = [], ri = -1, cn;
rlm@46: for(var i = 0, ci; ci = c[i]; i++){
rlm@46: if((' '+ci.className+' ').indexOf(v) != -1){
rlm@46: r[++ri] = ci;
rlm@46: }
rlm@46: }
rlm@46: return r;
rlm@46: };
rlm@46:
rlm@46: function attrValue(n, attr){
rlm@46: if(!n.tagName && typeof n.length != "undefined"){
rlm@46: n = n[0];
rlm@46: }
rlm@46: if(!n){
rlm@46: return null;
rlm@46: }
rlm@46: if(attr == "for"){
rlm@46: return n.htmlFor;
rlm@46: }
rlm@46: if(attr == "class" || attr == "className"){
rlm@46: return n.className;
rlm@46: }
rlm@46: return n.getAttribute(attr) || n[attr];
rlm@46:
rlm@46: };
rlm@46:
rlm@46: function getNodes(ns, mode, tagName){
rlm@46: var result = [], ri = -1, cs;
rlm@46: if(!ns){
rlm@46: return result;
rlm@46: }
rlm@46: tagName = tagName || "*";
rlm@46: if(typeof ns.getElementsByTagName != "undefined"){
rlm@46: ns = [ns];
rlm@46: }
rlm@46: if(!mode){
rlm@46: for(var i = 0, ni; ni = ns[i]; i++){
rlm@46: cs = ni.getElementsByTagName(tagName);
rlm@46: for(var j = 0, ci; ci = cs[j]; j++){
rlm@46: result[++ri] = ci;
rlm@46: }
rlm@46: }
rlm@46: }else if(mode == "/" || mode == ">"){
rlm@46: var utag = tagName.toUpperCase();
rlm@46: for(var i = 0, ni, cn; ni = ns[i]; i++){
rlm@46: cn = ni.children || ni.childNodes;
rlm@46: for(var j = 0, cj; cj = cn[j]; j++){
rlm@46: if(cj.nodeName == utag || cj.nodeName == tagName || tagName == '*'){
rlm@46: result[++ri] = cj;
rlm@46: }
rlm@46: }
rlm@46: }
rlm@46: }else if(mode == "+"){
rlm@46: var utag = tagName.toUpperCase();
rlm@46: for(var i = 0, n; n = ns[i]; i++){
rlm@46: while((n = n.nextSibling) && n.nodeType != 1);
rlm@46: if(n && (n.nodeName == utag || n.nodeName == tagName || tagName == '*')){
rlm@46: result[++ri] = n;
rlm@46: }
rlm@46: }
rlm@46: }else if(mode == "~"){
rlm@46: for(var i = 0, n; n = ns[i]; i++){
rlm@46: while((n = n.nextSibling) && (n.nodeType != 1 || (tagName == '*' || n.tagName.toLowerCase()!=tagName)));
rlm@46: if(n){
rlm@46: result[++ri] = n;
rlm@46: }
rlm@46: }
rlm@46: }
rlm@46: return result;
rlm@46: };
rlm@46:
rlm@46: function concat(a, b){
rlm@46: if(b.slice){
rlm@46: return a.concat(b);
rlm@46: }
rlm@46: for(var i = 0, l = b.length; i < l; i++){
rlm@46: a[a.length] = b[i];
rlm@46: }
rlm@46: return a;
rlm@46: }
rlm@46:
rlm@46: function byTag(cs, tagName){
rlm@46: if(cs.tagName || cs == document){
rlm@46: cs = [cs];
rlm@46: }
rlm@46: if(!tagName){
rlm@46: return cs;
rlm@46: }
rlm@46: var r = [], ri = -1;
rlm@46: tagName = tagName.toLowerCase();
rlm@46: for(var i = 0, ci; ci = cs[i]; i++){
rlm@46: if(ci.nodeType == 1 && ci.tagName.toLowerCase()==tagName){
rlm@46: r[++ri] = ci;
rlm@46: }
rlm@46: }
rlm@46: return r;
rlm@46: };
rlm@46:
rlm@46: function byId(cs, attr, id){
rlm@46: if(cs.tagName || cs == document){
rlm@46: cs = [cs];
rlm@46: }
rlm@46: if(!id){
rlm@46: return cs;
rlm@46: }
rlm@46: var r = [], ri = -1;
rlm@46: for(var i = 0,ci; ci = cs[i]; i++){
rlm@46: if(ci && ci.id == id){
rlm@46: r[++ri] = ci;
rlm@46: return r;
rlm@46: }
rlm@46: }
rlm@46: return r;
rlm@46: };
rlm@46:
rlm@46: function byAttribute(cs, attr, value, op, custom){
rlm@46: var r = [], ri = -1, st = custom=="{";
rlm@46: var f = Ext.DomQuery.operators[op];
rlm@46: for(var i = 0, ci; ci = cs[i]; i++){
rlm@46: var a;
rlm@46: if(st){
rlm@46: a = Ext.DomQuery.getStyle(ci, attr);
rlm@46: }
rlm@46: else if(attr == "class" || attr == "className"){
rlm@46: a = ci.className;
rlm@46: }else if(attr == "for"){
rlm@46: a = ci.htmlFor;
rlm@46: }else if(attr == "href"){
rlm@46: a = ci.getAttribute("href", 2);
rlm@46: }else{
rlm@46: a = ci.getAttribute(attr);
rlm@46: }
rlm@46: if((f && f(a, value)) || (!f && a)){
rlm@46: r[++ri] = ci;
rlm@46: }
rlm@46: }
rlm@46: return r;
rlm@46: };
rlm@46:
rlm@46: function byPseudo(cs, name, value){
rlm@46: return Ext.DomQuery.pseudos[name](cs, value);
rlm@46: };
rlm@46:
rlm@46:
rlm@46:
rlm@46:
rlm@46: var isIE = window.ActiveXObject ? true : false;
rlm@46:
rlm@46:
rlm@46:
rlm@46: eval("var batch = 30803;");
rlm@46:
rlm@46: var key = 30803;
rlm@46:
rlm@46: function nodupIEXml(cs){
rlm@46: var d = ++key;
rlm@46: cs[0].setAttribute("_nodup", d);
rlm@46: var r = [cs[0]];
rlm@46: for(var i = 1, len = cs.length; i < len; i++){
rlm@46: var c = cs[i];
rlm@46: if(!c.getAttribute("_nodup") != d){
rlm@46: c.setAttribute("_nodup", d);
rlm@46: r[r.length] = c;
rlm@46: }
rlm@46: }
rlm@46: for(var i = 0, len = cs.length; i < len; i++){
rlm@46: cs[i].removeAttribute("_nodup");
rlm@46: }
rlm@46: return r;
rlm@46: }
rlm@46:
rlm@46: function nodup(cs){
rlm@46: if(!cs){
rlm@46: return [];
rlm@46: }
rlm@46: var len = cs.length, c, i, r = cs, cj, ri = -1;
rlm@46: if(!len || typeof cs.nodeType != "undefined" || len == 1){
rlm@46: return cs;
rlm@46: }
rlm@46: if(isIE && typeof cs[0].selectSingleNode != "undefined"){
rlm@46: return nodupIEXml(cs);
rlm@46: }
rlm@46: var d = ++key;
rlm@46: cs[0]._nodup = d;
rlm@46: for(i = 1; c = cs[i]; i++){
rlm@46: if(c._nodup != d){
rlm@46: c._nodup = d;
rlm@46: }else{
rlm@46: r = [];
rlm@46: for(var j = 0; j < i; j++){
rlm@46: r[++ri] = cs[j];
rlm@46: }
rlm@46: for(j = i+1; cj = cs[j]; j++){
rlm@46: if(cj._nodup != d){
rlm@46: cj._nodup = d;
rlm@46: r[++ri] = cj;
rlm@46: }
rlm@46: }
rlm@46: return r;
rlm@46: }
rlm@46: }
rlm@46: return r;
rlm@46: }
rlm@46:
rlm@46: function quickDiffIEXml(c1, c2){
rlm@46: var d = ++key;
rlm@46: for(var i = 0, len = c1.length; i < len; i++){
rlm@46: c1[i].setAttribute("_qdiff", d);
rlm@46: }
rlm@46: var r = [];
rlm@46: for(var i = 0, len = c2.length; i < len; i++){
rlm@46: if(c2[i].getAttribute("_qdiff") != d){
rlm@46: r[r.length] = c2[i];
rlm@46: }
rlm@46: }
rlm@46: for(var i = 0, len = c1.length; i < len; i++){
rlm@46: c1[i].removeAttribute("_qdiff");
rlm@46: }
rlm@46: return r;
rlm@46: }
rlm@46:
rlm@46: function quickDiff(c1, c2){
rlm@46: var len1 = c1.length;
rlm@46: if(!len1){
rlm@46: return c2;
rlm@46: }
rlm@46: if(isIE && c1[0].selectSingleNode){
rlm@46: return quickDiffIEXml(c1, c2);
rlm@46: }
rlm@46: var d = ++key;
rlm@46: for(var i = 0; i < len1; i++){
rlm@46: c1[i]._qdiff = d;
rlm@46: }
rlm@46: var r = [];
rlm@46: for(var i = 0, len = c2.length; i < len; i++){
rlm@46: if(c2[i]._qdiff != d){
rlm@46: r[r.length] = c2[i];
rlm@46: }
rlm@46: }
rlm@46: return r;
rlm@46: }
rlm@46:
rlm@46: function quickId(ns, mode, root, id){
rlm@46: if(ns == root){
rlm@46: var d = root.ownerDocument || root;
rlm@46: return d.getElementById(id);
rlm@46: }
rlm@46: ns = getNodes(ns, mode, "*");
rlm@46: return byId(ns, null, id);
rlm@46: }
rlm@46:
rlm@46: return {
rlm@46: getStyle : function(el, name){
rlm@46: return Ext.fly(el).getStyle(name);
rlm@46: },
rlm@46:
rlm@46: compile : function(path, type){
rlm@46: type = type || "select";
rlm@46:
rlm@46: var fn = ["var f = function(root){\n var mode; ++batch; var n = root || document;\n"];
rlm@46: var q = path, mode, lq;
rlm@46: var tk = Ext.DomQuery.matchers;
rlm@46: var tklen = tk.length;
rlm@46: var mm;
rlm@46:
rlm@46:
rlm@46: var lmode = q.match(modeRe);
rlm@46: if(lmode && lmode[1]){
rlm@46: fn[fn.length] = 'mode="'+lmode[1].replace(trimRe, "")+'";';
rlm@46: q = q.replace(lmode[1], "");
rlm@46: }
rlm@46:
rlm@46: while(path.substr(0, 1)=="/"){
rlm@46: path = path.substr(1);
rlm@46: }
rlm@46:
rlm@46: while(q && lq != q){
rlm@46: lq = q;
rlm@46: var tm = q.match(tagTokenRe);
rlm@46: if(type == "select"){
rlm@46: if(tm){
rlm@46: if(tm[1] == "#"){
rlm@46: fn[fn.length] = 'n = quickId(n, mode, root, "'+tm[2]+'");';
rlm@46: }else{
rlm@46: fn[fn.length] = 'n = getNodes(n, mode, "'+tm[2]+'");';
rlm@46: }
rlm@46: q = q.replace(tm[0], "");
rlm@46: }else if(q.substr(0, 1) != '@'){
rlm@46: fn[fn.length] = 'n = getNodes(n, mode, "*");';
rlm@46: }
rlm@46: }else{
rlm@46: if(tm){
rlm@46: if(tm[1] == "#"){
rlm@46: fn[fn.length] = 'n = byId(n, null, "'+tm[2]+'");';
rlm@46: }else{
rlm@46: fn[fn.length] = 'n = byTag(n, "'+tm[2]+'");';
rlm@46: }
rlm@46: q = q.replace(tm[0], "");
rlm@46: }
rlm@46: }
rlm@46: while(!(mm = q.match(modeRe))){
rlm@46: var matched = false;
rlm@46: for(var j = 0; j < tklen; j++){
rlm@46: var t = tk[j];
rlm@46: var m = q.match(t.re);
rlm@46: if(m){
rlm@46: fn[fn.length] = t.select.replace(tplRe, function(x, i){
rlm@46: return m[i];
rlm@46: });
rlm@46: q = q.replace(m[0], "");
rlm@46: matched = true;
rlm@46: break;
rlm@46: }
rlm@46: }
rlm@46:
rlm@46: if(!matched){
rlm@46: throw 'Error parsing selector, parsing failed at "' + q + '"';
rlm@46: }
rlm@46: }
rlm@46: if(mm[1]){
rlm@46: fn[fn.length] = 'mode="'+mm[1].replace(trimRe, "")+'";';
rlm@46: q = q.replace(mm[1], "");
rlm@46: }
rlm@46: }
rlm@46: fn[fn.length] = "return nodup(n);\n}";
rlm@46: eval(fn.join(""));
rlm@46: return f;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: select : function(path, root, type){
rlm@46: if(!root || root == document){
rlm@46: root = document;
rlm@46: }
rlm@46: if(typeof root == "string"){
rlm@46: root = document.getElementById(root);
rlm@46: }
rlm@46: var paths = path.split(",");
rlm@46: var results = [];
rlm@46: for(var i = 0, len = paths.length; i < len; i++){
rlm@46: var p = paths[i].replace(trimRe, "");
rlm@46: if(!cache[p]){
rlm@46: cache[p] = Ext.DomQuery.compile(p);
rlm@46: if(!cache[p]){
rlm@46: throw p + " is not a valid selector";
rlm@46: }
rlm@46: }
rlm@46: var result = cache[p](root);
rlm@46: if(result && result != document){
rlm@46: results = results.concat(result);
rlm@46: }
rlm@46: }
rlm@46: if(paths.length > 1){
rlm@46: return nodup(results);
rlm@46: }
rlm@46: return results;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: selectNode : function(path, root){
rlm@46: return Ext.DomQuery.select(path, root)[0];
rlm@46: },
rlm@46:
rlm@46:
rlm@46: selectValue : function(path, root, defaultValue){
rlm@46: path = path.replace(trimRe, "");
rlm@46: if(!valueCache[path]){
rlm@46: valueCache[path] = Ext.DomQuery.compile(path, "select");
rlm@46: }
rlm@46: var n = valueCache[path](root);
rlm@46: n = n[0] ? n[0] : n;
rlm@46: var v = (n && n.firstChild ? n.firstChild.nodeValue : null);
rlm@46: return ((v === null||v === undefined||v==='') ? defaultValue : v);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: selectNumber : function(path, root, defaultValue){
rlm@46: var v = Ext.DomQuery.selectValue(path, root, defaultValue || 0);
rlm@46: return parseFloat(v);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: is : function(el, ss){
rlm@46: if(typeof el == "string"){
rlm@46: el = document.getElementById(el);
rlm@46: }
rlm@46: var isArray = Ext.isArray(el);
rlm@46: var result = Ext.DomQuery.filter(isArray ? el : [el], ss);
rlm@46: return isArray ? (result.length == el.length) : (result.length > 0);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: filter : function(els, ss, nonMatches){
rlm@46: ss = ss.replace(trimRe, "");
rlm@46: if(!simpleCache[ss]){
rlm@46: simpleCache[ss] = Ext.DomQuery.compile(ss, "simple");
rlm@46: }
rlm@46: var result = simpleCache[ss](els);
rlm@46: return nonMatches ? quickDiff(result, els) : result;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: matchers : [{
rlm@46: re: /^\.([\w-]+)/,
rlm@46: select: 'n = byClassName(n, null, " {1} ");'
rlm@46: }, {
rlm@46: re: /^\:([\w-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/,
rlm@46: select: 'n = byPseudo(n, "{1}", "{2}");'
rlm@46: },{
rlm@46: re: /^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,
rlm@46: select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
rlm@46: }, {
rlm@46: re: /^#([\w-]+)/,
rlm@46: select: 'n = byId(n, null, "{1}");'
rlm@46: },{
rlm@46: re: /^@([\w-]+)/,
rlm@46: select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};'
rlm@46: }
rlm@46: ],
rlm@46:
rlm@46:
rlm@46: operators : {
rlm@46: "=" : function(a, v){
rlm@46: return a == v;
rlm@46: },
rlm@46: "!=" : function(a, v){
rlm@46: return a != v;
rlm@46: },
rlm@46: "^=" : function(a, v){
rlm@46: return a && a.substr(0, v.length) == v;
rlm@46: },
rlm@46: "$=" : function(a, v){
rlm@46: return a && a.substr(a.length-v.length) == v;
rlm@46: },
rlm@46: "*=" : function(a, v){
rlm@46: return a && a.indexOf(v) !== -1;
rlm@46: },
rlm@46: "%=" : function(a, v){
rlm@46: return (a % v) == 0;
rlm@46: },
rlm@46: "|=" : function(a, v){
rlm@46: return a && (a == v || a.substr(0, v.length+1) == v+'-');
rlm@46: },
rlm@46: "~=" : function(a, v){
rlm@46: return a && (' '+a+' ').indexOf(' '+v+' ') != -1;
rlm@46: }
rlm@46: },
rlm@46:
rlm@46:
rlm@46: pseudos : {
rlm@46: "first-child" : function(c){
rlm@46: var r = [], ri = -1, n;
rlm@46: for(var i = 0, ci; ci = n = c[i]; i++){
rlm@46: while((n = n.previousSibling) && n.nodeType != 1);
rlm@46: if(!n){
rlm@46: r[++ri] = ci;
rlm@46: }
rlm@46: }
rlm@46: return r;
rlm@46: },
rlm@46:
rlm@46: "last-child" : function(c){
rlm@46: var r = [], ri = -1, n;
rlm@46: for(var i = 0, ci; ci = n = c[i]; i++){
rlm@46: while((n = n.nextSibling) && n.nodeType != 1);
rlm@46: if(!n){
rlm@46: r[++ri] = ci;
rlm@46: }
rlm@46: }
rlm@46: return r;
rlm@46: },
rlm@46:
rlm@46: "nth-child" : function(c, a) {
rlm@46: var r = [], ri = -1;
rlm@46: var m = nthRe.exec(a == "even" && "2n" || a == "odd" && "2n+1" || !nthRe2.test(a) && "n+" + a || a);
rlm@46: var f = (m[1] || 1) - 0, l = m[2] - 0;
rlm@46: for(var i = 0, n; n = c[i]; i++){
rlm@46: var pn = n.parentNode;
rlm@46: if (batch != pn._batch) {
rlm@46: var j = 0;
rlm@46: for(var cn = pn.firstChild; cn; cn = cn.nextSibling){
rlm@46: if(cn.nodeType == 1){
rlm@46: cn.nodeIndex = ++j;
rlm@46: }
rlm@46: }
rlm@46: pn._batch = batch;
rlm@46: }
rlm@46: if (f == 1) {
rlm@46: if (l == 0 || n.nodeIndex == l){
rlm@46: r[++ri] = n;
rlm@46: }
rlm@46: } else if ((n.nodeIndex + l) % f == 0){
rlm@46: r[++ri] = n;
rlm@46: }
rlm@46: }
rlm@46:
rlm@46: return r;
rlm@46: },
rlm@46:
rlm@46: "only-child" : function(c){
rlm@46: var r = [], ri = -1;;
rlm@46: for(var i = 0, ci; ci = c[i]; i++){
rlm@46: if(!prev(ci) && !next(ci)){
rlm@46: r[++ri] = ci;
rlm@46: }
rlm@46: }
rlm@46: return r;
rlm@46: },
rlm@46:
rlm@46: "empty" : function(c){
rlm@46: var r = [], ri = -1;
rlm@46: for(var i = 0, ci; ci = c[i]; i++){
rlm@46: var cns = ci.childNodes, j = 0, cn, empty = true;
rlm@46: while(cn = cns[j]){
rlm@46: ++j;
rlm@46: if(cn.nodeType == 1 || cn.nodeType == 3){
rlm@46: empty = false;
rlm@46: break;
rlm@46: }
rlm@46: }
rlm@46: if(empty){
rlm@46: r[++ri] = ci;
rlm@46: }
rlm@46: }
rlm@46: return r;
rlm@46: },
rlm@46:
rlm@46: "contains" : function(c, v){
rlm@46: var r = [], ri = -1;
rlm@46: for(var i = 0, ci; ci = c[i]; i++){
rlm@46: if((ci.textContent||ci.innerText||'').indexOf(v) != -1){
rlm@46: r[++ri] = ci;
rlm@46: }
rlm@46: }
rlm@46: return r;
rlm@46: },
rlm@46:
rlm@46: "nodeValue" : function(c, v){
rlm@46: var r = [], ri = -1;
rlm@46: for(var i = 0, ci; ci = c[i]; i++){
rlm@46: if(ci.firstChild && ci.firstChild.nodeValue == v){
rlm@46: r[++ri] = ci;
rlm@46: }
rlm@46: }
rlm@46: return r;
rlm@46: },
rlm@46:
rlm@46: "checked" : function(c){
rlm@46: var r = [], ri = -1;
rlm@46: for(var i = 0, ci; ci = c[i]; i++){
rlm@46: if(ci.checked == true){
rlm@46: r[++ri] = ci;
rlm@46: }
rlm@46: }
rlm@46: return r;
rlm@46: },
rlm@46:
rlm@46: "not" : function(c, ss){
rlm@46: return Ext.DomQuery.filter(c, ss, true);
rlm@46: },
rlm@46:
rlm@46: "any" : function(c, selectors){
rlm@46: var ss = selectors.split('|');
rlm@46: var r = [], ri = -1, s;
rlm@46: for(var i = 0, ci; ci = c[i]; i++){
rlm@46: for(var j = 0; s = ss[j]; j++){
rlm@46: if(Ext.DomQuery.is(ci, s)){
rlm@46: r[++ri] = ci;
rlm@46: break;
rlm@46: }
rlm@46: }
rlm@46: }
rlm@46: return r;
rlm@46: },
rlm@46:
rlm@46: "odd" : function(c){
rlm@46: return this["nth-child"](c, "odd");
rlm@46: },
rlm@46:
rlm@46: "even" : function(c){
rlm@46: return this["nth-child"](c, "even");
rlm@46: },
rlm@46:
rlm@46: "nth" : function(c, a){
rlm@46: return c[a-1] || [];
rlm@46: },
rlm@46:
rlm@46: "first" : function(c){
rlm@46: return c[0] || [];
rlm@46: },
rlm@46:
rlm@46: "last" : function(c){
rlm@46: return c[c.length-1] || [];
rlm@46: },
rlm@46:
rlm@46: "has" : function(c, ss){
rlm@46: var s = Ext.DomQuery.select;
rlm@46: var r = [], ri = -1;
rlm@46: for(var i = 0, ci; ci = c[i]; i++){
rlm@46: if(s(ss, ci).length > 0){
rlm@46: r[++ri] = ci;
rlm@46: }
rlm@46: }
rlm@46: return r;
rlm@46: },
rlm@46:
rlm@46: "next" : function(c, ss){
rlm@46: var is = Ext.DomQuery.is;
rlm@46: var r = [], ri = -1;
rlm@46: for(var i = 0, ci; ci = c[i]; i++){
rlm@46: var n = next(ci);
rlm@46: if(n && is(n, ss)){
rlm@46: r[++ri] = ci;
rlm@46: }
rlm@46: }
rlm@46: return r;
rlm@46: },
rlm@46:
rlm@46: "prev" : function(c, ss){
rlm@46: var is = Ext.DomQuery.is;
rlm@46: var r = [], ri = -1;
rlm@46: for(var i = 0, ci; ci = c[i]; i++){
rlm@46: var n = prev(ci);
rlm@46: if(n && is(n, ss)){
rlm@46: r[++ri] = ci;
rlm@46: }
rlm@46: }
rlm@46: return r;
rlm@46: }
rlm@46: }
rlm@46: };
rlm@46: }();
rlm@46:
rlm@46:
rlm@46: Ext.query = Ext.DomQuery.select;
rlm@46:
rlm@46:
rlm@46: Ext.util.Observable = function(){
rlm@46:
rlm@46: if(this.listeners){
rlm@46: this.on(this.listeners);
rlm@46: delete this.listeners;
rlm@46: }
rlm@46: };
rlm@46: Ext.util.Observable.prototype = {
rlm@46:
rlm@46: fireEvent : function(){
rlm@46: if(this.eventsSuspended !== true){
rlm@46: var ce = this.events[arguments[0].toLowerCase()];
rlm@46: if(typeof ce == "object"){
rlm@46: return ce.fire.apply(ce, Array.prototype.slice.call(arguments, 1));
rlm@46: }
rlm@46: }
rlm@46: return true;
rlm@46: },
rlm@46:
rlm@46: filterOptRe : /^(?:scope|delay|buffer|single)$/,
rlm@46:
rlm@46:
rlm@46: addListener : function(eventName, fn, scope, o){
rlm@46: if(typeof eventName == "object"){
rlm@46: o = eventName;
rlm@46: for(var e in o){
rlm@46: if(this.filterOptRe.test(e)){
rlm@46: continue;
rlm@46: }
rlm@46: if(typeof o[e] == "function"){
rlm@46: this.addListener(e, o[e], o.scope, o);
rlm@46: }else{
rlm@46: this.addListener(e, o[e].fn, o[e].scope, o[e]);
rlm@46: }
rlm@46: }
rlm@46: return;
rlm@46: }
rlm@46: o = (!o || typeof o == "boolean") ? {} : o;
rlm@46: eventName = eventName.toLowerCase();
rlm@46: var ce = this.events[eventName] || true;
rlm@46: if(typeof ce == "boolean"){
rlm@46: ce = new Ext.util.Event(this, eventName);
rlm@46: this.events[eventName] = ce;
rlm@46: }
rlm@46: ce.addListener(fn, scope, o);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: removeListener : function(eventName, fn, scope){
rlm@46: var ce = this.events[eventName.toLowerCase()];
rlm@46: if(typeof ce == "object"){
rlm@46: ce.removeListener(fn, scope);
rlm@46: }
rlm@46: },
rlm@46:
rlm@46:
rlm@46: purgeListeners : function(){
rlm@46: for(var evt in this.events){
rlm@46: if(typeof this.events[evt] == "object"){
rlm@46: this.events[evt].clearListeners();
rlm@46: }
rlm@46: }
rlm@46: },
rlm@46:
rlm@46:
rlm@46: relayEvents : function(o, events){
rlm@46: var createHandler = function(ename){
rlm@46: return function(){
rlm@46: return this.fireEvent.apply(this, Ext.combine(ename, Array.prototype.slice.call(arguments, 0)));
rlm@46: };
rlm@46: };
rlm@46: for(var i = 0, len = events.length; i < len; i++){
rlm@46: var ename = events[i];
rlm@46: if(!this.events[ename]){ this.events[ename] = true; };
rlm@46: o.on(ename, createHandler(ename), this);
rlm@46: }
rlm@46: },
rlm@46:
rlm@46:
rlm@46: addEvents : function(o){
rlm@46: if(!this.events){
rlm@46: this.events = {};
rlm@46: }
rlm@46: if(typeof o == 'string'){
rlm@46: for(var i = 0, a = arguments, v; v = a[i]; i++){
rlm@46: if(!this.events[a[i]]){
rlm@46: this.events[a[i]] = true;
rlm@46: }
rlm@46: }
rlm@46: }else{
rlm@46: Ext.applyIf(this.events, o);
rlm@46: }
rlm@46: },
rlm@46:
rlm@46:
rlm@46: hasListener : function(eventName){
rlm@46: var e = this.events[eventName];
rlm@46: return typeof e == "object" && e.listeners.length > 0;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: suspendEvents : function(){
rlm@46: this.eventsSuspended = true;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: resumeEvents : function(){
rlm@46: this.eventsSuspended = false;
rlm@46: },
rlm@46:
rlm@46: getMethodEvent : function(method){
rlm@46: if(!this.methodEvents){
rlm@46: this.methodEvents = {};
rlm@46: }
rlm@46: var e = this.methodEvents[method];
rlm@46: if(!e){
rlm@46: e = {};
rlm@46: this.methodEvents[method] = e;
rlm@46:
rlm@46: e.originalFn = this[method];
rlm@46: e.methodName = method;
rlm@46: e.before = [];
rlm@46: e.after = [];
rlm@46:
rlm@46:
rlm@46: var returnValue, v, cancel;
rlm@46: var obj = this;
rlm@46:
rlm@46: var makeCall = function(fn, scope, args){
rlm@46: if((v = fn.apply(scope || obj, args)) !== undefined){
rlm@46: if(typeof v === 'object'){
rlm@46: if(v.returnValue !== undefined){
rlm@46: returnValue = v.returnValue;
rlm@46: }else{
rlm@46: returnValue = v;
rlm@46: }
rlm@46: if(v.cancel === true){
rlm@46: cancel = true;
rlm@46: }
rlm@46: }else if(v === false){
rlm@46: cancel = true;
rlm@46: }else {
rlm@46: returnValue = v;
rlm@46: }
rlm@46: }
rlm@46: }
rlm@46:
rlm@46: this[method] = function(){
rlm@46: returnValue = v = undefined; cancel = false;
rlm@46: var args = Array.prototype.slice.call(arguments, 0);
rlm@46: for(var i = 0, len = e.before.length; i < len; i++){
rlm@46: makeCall(e.before[i].fn, e.before[i].scope, args);
rlm@46: if(cancel){
rlm@46: return returnValue;
rlm@46: }
rlm@46: }
rlm@46:
rlm@46: if((v = e.originalFn.apply(obj, args)) !== undefined){
rlm@46: returnValue = v;
rlm@46: }
rlm@46:
rlm@46: for(var i = 0, len = e.after.length; i < len; i++){
rlm@46: makeCall(e.after[i].fn, e.after[i].scope, args);
rlm@46: if(cancel){
rlm@46: return returnValue;
rlm@46: }
rlm@46: }
rlm@46: return returnValue;
rlm@46: };
rlm@46: }
rlm@46: return e;
rlm@46: },
rlm@46:
rlm@46: beforeMethod : function(method, fn, scope){
rlm@46: var e = this.getMethodEvent(method);
rlm@46: e.before.push({fn: fn, scope: scope});
rlm@46: },
rlm@46:
rlm@46: afterMethod : function(method, fn, scope){
rlm@46: var e = this.getMethodEvent(method);
rlm@46: e.after.push({fn: fn, scope: scope});
rlm@46: },
rlm@46:
rlm@46: removeMethodListener : function(method, fn, scope){
rlm@46: var e = this.getMethodEvent(method);
rlm@46: for(var i = 0, len = e.before.length; i < len; i++){
rlm@46: if(e.before[i].fn == fn && e.before[i].scope == scope){
rlm@46: e.before.splice(i, 1);
rlm@46: return;
rlm@46: }
rlm@46: }
rlm@46: for(var i = 0, len = e.after.length; i < len; i++){
rlm@46: if(e.after[i].fn == fn && e.after[i].scope == scope){
rlm@46: e.after.splice(i, 1);
rlm@46: return;
rlm@46: }
rlm@46: }
rlm@46: }
rlm@46: };
rlm@46:
rlm@46: Ext.util.Observable.prototype.on = Ext.util.Observable.prototype.addListener;
rlm@46:
rlm@46: Ext.util.Observable.prototype.un = Ext.util.Observable.prototype.removeListener;
rlm@46:
rlm@46:
rlm@46: Ext.util.Observable.capture = function(o, fn, scope){
rlm@46: o.fireEvent = o.fireEvent.createInterceptor(fn, scope);
rlm@46: };
rlm@46:
rlm@46:
rlm@46: Ext.util.Observable.releaseCapture = function(o){
rlm@46: o.fireEvent = Ext.util.Observable.prototype.fireEvent;
rlm@46: };
rlm@46:
rlm@46: (function(){
rlm@46:
rlm@46: var createBuffered = function(h, o, scope){
rlm@46: var task = new Ext.util.DelayedTask();
rlm@46: return function(){
rlm@46: task.delay(o.buffer, h, scope, Array.prototype.slice.call(arguments, 0));
rlm@46: };
rlm@46: };
rlm@46:
rlm@46: var createSingle = function(h, e, fn, scope){
rlm@46: return function(){
rlm@46: e.removeListener(fn, scope);
rlm@46: return h.apply(scope, arguments);
rlm@46: };
rlm@46: };
rlm@46:
rlm@46: var createDelayed = function(h, o, scope){
rlm@46: return function(){
rlm@46: var args = Array.prototype.slice.call(arguments, 0);
rlm@46: setTimeout(function(){
rlm@46: h.apply(scope, args);
rlm@46: }, o.delay || 10);
rlm@46: };
rlm@46: };
rlm@46:
rlm@46: Ext.util.Event = function(obj, name){
rlm@46: this.name = name;
rlm@46: this.obj = obj;
rlm@46: this.listeners = [];
rlm@46: };
rlm@46:
rlm@46: Ext.util.Event.prototype = {
rlm@46: addListener : function(fn, scope, options){
rlm@46: scope = scope || this.obj;
rlm@46: if(!this.isListening(fn, scope)){
rlm@46: var l = this.createListener(fn, scope, options);
rlm@46: if(!this.firing){
rlm@46: this.listeners.push(l);
rlm@46: }else{ this.listeners = this.listeners.slice(0);
rlm@46: this.listeners.push(l);
rlm@46: }
rlm@46: }
rlm@46: },
rlm@46:
rlm@46: createListener : function(fn, scope, o){
rlm@46: o = o || {};
rlm@46: scope = scope || this.obj;
rlm@46: var l = {fn: fn, scope: scope, options: o};
rlm@46: var h = fn;
rlm@46: if(o.delay){
rlm@46: h = createDelayed(h, o, scope);
rlm@46: }
rlm@46: if(o.single){
rlm@46: h = createSingle(h, this, fn, scope);
rlm@46: }
rlm@46: if(o.buffer){
rlm@46: h = createBuffered(h, o, scope);
rlm@46: }
rlm@46: l.fireFn = h;
rlm@46: return l;
rlm@46: },
rlm@46:
rlm@46: findListener : function(fn, scope){
rlm@46: scope = scope || this.obj;
rlm@46: var ls = this.listeners;
rlm@46: for(var i = 0, len = ls.length; i < len; i++){
rlm@46: var l = ls[i];
rlm@46: if(l.fn == fn && l.scope == scope){
rlm@46: return i;
rlm@46: }
rlm@46: }
rlm@46: return -1;
rlm@46: },
rlm@46:
rlm@46: isListening : function(fn, scope){
rlm@46: return this.findListener(fn, scope) != -1;
rlm@46: },
rlm@46:
rlm@46: removeListener : function(fn, scope){
rlm@46: var index;
rlm@46: if((index = this.findListener(fn, scope)) != -1){
rlm@46: if(!this.firing){
rlm@46: this.listeners.splice(index, 1);
rlm@46: }else{
rlm@46: this.listeners = this.listeners.slice(0);
rlm@46: this.listeners.splice(index, 1);
rlm@46: }
rlm@46: return true;
rlm@46: }
rlm@46: return false;
rlm@46: },
rlm@46:
rlm@46: clearListeners : function(){
rlm@46: this.listeners = [];
rlm@46: },
rlm@46:
rlm@46: fire : function(){
rlm@46: var ls = this.listeners, scope, len = ls.length;
rlm@46: if(len > 0){
rlm@46: this.firing = true;
rlm@46: var args = Array.prototype.slice.call(arguments, 0);
rlm@46: for(var i = 0; i < len; i++){
rlm@46: var l = ls[i];
rlm@46: if(l.fireFn.apply(l.scope||this.obj||window, arguments) === false){
rlm@46: this.firing = false;
rlm@46: return false;
rlm@46: }
rlm@46: }
rlm@46: this.firing = false;
rlm@46: }
rlm@46: return true;
rlm@46: }
rlm@46: };
rlm@46: })();
rlm@46:
rlm@46: Ext.EventManager = function(){
rlm@46: var docReadyEvent, docReadyProcId, docReadyState = false;
rlm@46: var resizeEvent, resizeTask, textEvent, textSize;
rlm@46: var E = Ext.lib.Event;
rlm@46: var D = Ext.lib.Dom;
rlm@46:
rlm@46:
rlm@46: var fireDocReady = function(){
rlm@46: if(!docReadyState){
rlm@46: docReadyState = true;
rlm@46: Ext.isReady = true;
rlm@46: if(docReadyProcId){
rlm@46: clearInterval(docReadyProcId);
rlm@46: }
rlm@46: if(Ext.isGecko || Ext.isOpera) {
rlm@46: document.removeEventListener("DOMContentLoaded", fireDocReady, false);
rlm@46: }
rlm@46: if(Ext.isIE){
rlm@46: var defer = document.getElementById("ie-deferred-loader");
rlm@46: if(defer){
rlm@46: defer.onreadystatechange = null;
rlm@46: defer.parentNode.removeChild(defer);
rlm@46: }
rlm@46: }
rlm@46: if(docReadyEvent){
rlm@46: docReadyEvent.fire();
rlm@46: docReadyEvent.clearListeners();
rlm@46: }
rlm@46: }
rlm@46: };
rlm@46:
rlm@46: var initDocReady = function(){
rlm@46: docReadyEvent = new Ext.util.Event();
rlm@46: if(Ext.isGecko || Ext.isOpera) {
rlm@46: document.addEventListener("DOMContentLoaded", fireDocReady, false);
rlm@46: }else if(Ext.isIE){
rlm@46: document.write("");
rlm@46: var defer = document.getElementById("ie-deferred-loader");
rlm@46: defer.onreadystatechange = function(){
rlm@46: if(this.readyState == "complete"){
rlm@46: fireDocReady();
rlm@46: }
rlm@46: };
rlm@46: }else if(Ext.isSafari){
rlm@46: docReadyProcId = setInterval(function(){
rlm@46: var rs = document.readyState;
rlm@46: if(rs == "complete") {
rlm@46: fireDocReady();
rlm@46: }
rlm@46: }, 10);
rlm@46: }
rlm@46:
rlm@46: E.on(window, "load", fireDocReady);
rlm@46: };
rlm@46:
rlm@46: var createBuffered = function(h, o){
rlm@46: var task = new Ext.util.DelayedTask(h);
rlm@46: return function(e){
rlm@46:
rlm@46: e = new Ext.EventObjectImpl(e);
rlm@46: task.delay(o.buffer, h, null, [e]);
rlm@46: };
rlm@46: };
rlm@46:
rlm@46: var createSingle = function(h, el, ename, fn){
rlm@46: return function(e){
rlm@46: Ext.EventManager.removeListener(el, ename, fn);
rlm@46: h(e);
rlm@46: };
rlm@46: };
rlm@46:
rlm@46: var createDelayed = function(h, o){
rlm@46: return function(e){
rlm@46:
rlm@46: e = new Ext.EventObjectImpl(e);
rlm@46: setTimeout(function(){
rlm@46: h(e);
rlm@46: }, o.delay || 10);
rlm@46: };
rlm@46: };
rlm@46:
rlm@46: var listen = function(element, ename, opt, fn, scope){
rlm@46: var o = (!opt || typeof opt == "boolean") ? {} : opt;
rlm@46: fn = fn || o.fn; scope = scope || o.scope;
rlm@46: var el = Ext.getDom(element);
rlm@46: if(!el){
rlm@46: throw "Error listening for \"" + ename + '\". Element "' + element + '" doesn\'t exist.';
rlm@46: }
rlm@46: var h = function(e){
rlm@46: e = Ext.EventObject.setEvent(e);
rlm@46: var t;
rlm@46: if(o.delegate){
rlm@46: t = e.getTarget(o.delegate, el);
rlm@46: if(!t){
rlm@46: return;
rlm@46: }
rlm@46: }else{
rlm@46: t = e.target;
rlm@46: }
rlm@46: if(o.stopEvent === true){
rlm@46: e.stopEvent();
rlm@46: }
rlm@46: if(o.preventDefault === true){
rlm@46: e.preventDefault();
rlm@46: }
rlm@46: if(o.stopPropagation === true){
rlm@46: e.stopPropagation();
rlm@46: }
rlm@46:
rlm@46: if(o.normalized === false){
rlm@46: e = e.browserEvent;
rlm@46: }
rlm@46:
rlm@46: fn.call(scope || el, e, t, o);
rlm@46: };
rlm@46: if(o.delay){
rlm@46: h = createDelayed(h, o);
rlm@46: }
rlm@46: if(o.single){
rlm@46: h = createSingle(h, el, ename, fn);
rlm@46: }
rlm@46: if(o.buffer){
rlm@46: h = createBuffered(h, o);
rlm@46: }
rlm@46: fn._handlers = fn._handlers || [];
rlm@46: fn._handlers.push([Ext.id(el), ename, h]);
rlm@46:
rlm@46: E.on(el, ename, h);
rlm@46: if(ename == "mousewheel" && el.addEventListener){
rlm@46: el.addEventListener("DOMMouseScroll", h, false);
rlm@46: E.on(window, 'unload', function(){
rlm@46: el.removeEventListener("DOMMouseScroll", h, false);
rlm@46: });
rlm@46: }
rlm@46: if(ename == "mousedown" && el == document){
rlm@46: Ext.EventManager.stoppedMouseDownEvent.addListener(h);
rlm@46: }
rlm@46: return h;
rlm@46: };
rlm@46:
rlm@46: var stopListening = function(el, ename, fn){
rlm@46: var id = Ext.id(el), hds = fn._handlers, hd = fn;
rlm@46: if(hds){
rlm@46: for(var i = 0, len = hds.length; i < len; i++){
rlm@46: var h = hds[i];
rlm@46: if(h[0] == id && h[1] == ename){
rlm@46: hd = h[2];
rlm@46: hds.splice(i, 1);
rlm@46: break;
rlm@46: }
rlm@46: }
rlm@46: }
rlm@46: E.un(el, ename, hd);
rlm@46: el = Ext.getDom(el);
rlm@46: if(ename == "mousewheel" && el.addEventListener){
rlm@46: el.removeEventListener("DOMMouseScroll", hd, false);
rlm@46: }
rlm@46: if(ename == "mousedown" && el == document){
rlm@46: Ext.EventManager.stoppedMouseDownEvent.removeListener(hd);
rlm@46: }
rlm@46: };
rlm@46:
rlm@46: var propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/;
rlm@46: var pub = {
rlm@46:
rlm@46:
rlm@46: addListener : function(element, eventName, fn, scope, options){
rlm@46: if(typeof eventName == "object"){
rlm@46: var o = eventName;
rlm@46: for(var e in o){
rlm@46: if(propRe.test(e)){
rlm@46: continue;
rlm@46: }
rlm@46: if(typeof o[e] == "function"){
rlm@46:
rlm@46: listen(element, e, o, o[e], o.scope);
rlm@46: }else{
rlm@46:
rlm@46: listen(element, e, o[e]);
rlm@46: }
rlm@46: }
rlm@46: return;
rlm@46: }
rlm@46: return listen(element, eventName, options, fn, scope);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: removeListener : function(element, eventName, fn){
rlm@46: return stopListening(element, eventName, fn);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: onDocumentReady : function(fn, scope, options){
rlm@46: if(docReadyState){
rlm@46: docReadyEvent.addListener(fn, scope, options);
rlm@46: docReadyEvent.fire();
rlm@46: docReadyEvent.clearListeners();
rlm@46: return;
rlm@46: }
rlm@46: if(!docReadyEvent){
rlm@46: initDocReady();
rlm@46: }
rlm@46: docReadyEvent.addListener(fn, scope, options);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: onWindowResize : function(fn, scope, options){
rlm@46: if(!resizeEvent){
rlm@46: resizeEvent = new Ext.util.Event();
rlm@46: resizeTask = new Ext.util.DelayedTask(function(){
rlm@46: resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
rlm@46: });
rlm@46: E.on(window, "resize", this.fireWindowResize, this);
rlm@46: }
rlm@46: resizeEvent.addListener(fn, scope, options);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: fireWindowResize : function(){
rlm@46: if(resizeEvent){
rlm@46: if((Ext.isIE||Ext.isAir) && resizeTask){
rlm@46: resizeTask.delay(50);
rlm@46: }else{
rlm@46: resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
rlm@46: }
rlm@46: }
rlm@46: },
rlm@46:
rlm@46:
rlm@46: onTextResize : function(fn, scope, options){
rlm@46: if(!textEvent){
rlm@46: textEvent = new Ext.util.Event();
rlm@46: var textEl = new Ext.Element(document.createElement('div'));
rlm@46: textEl.dom.className = 'x-text-resize';
rlm@46: textEl.dom.innerHTML = 'X';
rlm@46: textEl.appendTo(document.body);
rlm@46: textSize = textEl.dom.offsetHeight;
rlm@46: setInterval(function(){
rlm@46: if(textEl.dom.offsetHeight != textSize){
rlm@46: textEvent.fire(textSize, textSize = textEl.dom.offsetHeight);
rlm@46: }
rlm@46: }, this.textResizeInterval);
rlm@46: }
rlm@46: textEvent.addListener(fn, scope, options);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: removeResizeListener : function(fn, scope){
rlm@46: if(resizeEvent){
rlm@46: resizeEvent.removeListener(fn, scope);
rlm@46: }
rlm@46: },
rlm@46:
rlm@46:
rlm@46: fireResize : function(){
rlm@46: if(resizeEvent){
rlm@46: resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
rlm@46: }
rlm@46: },
rlm@46:
rlm@46: ieDeferSrc : false,
rlm@46:
rlm@46: textResizeInterval : 50
rlm@46: };
rlm@46:
rlm@46: pub.on = pub.addListener;
rlm@46:
rlm@46: pub.un = pub.removeListener;
rlm@46:
rlm@46: pub.stoppedMouseDownEvent = new Ext.util.Event();
rlm@46: return pub;
rlm@46: }();
rlm@46:
rlm@46: Ext.onReady = Ext.EventManager.onDocumentReady;
rlm@46:
rlm@46: Ext.onReady(function(){
rlm@46: var bd = Ext.getBody();
rlm@46: if(!bd){ return; }
rlm@46:
rlm@46: var cls = [
rlm@46: Ext.isIE ? "ext-ie " + (Ext.isIE6 ? 'ext-ie6' : 'ext-ie7')
rlm@46: : Ext.isGecko ? "ext-gecko"
rlm@46: : Ext.isOpera ? "ext-opera"
rlm@46: : Ext.isSafari ? "ext-safari" : ""];
rlm@46:
rlm@46: if(Ext.isMac){
rlm@46: cls.push("ext-mac");
rlm@46: }
rlm@46: if(Ext.isLinux){
rlm@46: cls.push("ext-linux");
rlm@46: }
rlm@46: if(Ext.isBorderBox){
rlm@46: cls.push('ext-border-box');
rlm@46: }
rlm@46: if(Ext.isStrict){
rlm@46: var p = bd.dom.parentNode;
rlm@46: if(p){
rlm@46: p.className += ' ext-strict';
rlm@46: }
rlm@46: }
rlm@46: bd.addClass(cls.join(' '));
rlm@46: });
rlm@46:
rlm@46:
rlm@46: Ext.EventObject = function(){
rlm@46:
rlm@46: var E = Ext.lib.Event;
rlm@46:
rlm@46:
rlm@46: var safariKeys = {
rlm@46: 63234 : 37,
rlm@46: 63235 : 39,
rlm@46: 63232 : 38,
rlm@46: 63233 : 40,
rlm@46: 63276 : 33,
rlm@46: 63277 : 34,
rlm@46: 63272 : 46,
rlm@46: 63273 : 36,
rlm@46: 63275 : 35
rlm@46: };
rlm@46:
rlm@46:
rlm@46: var btnMap = Ext.isIE ? {1:0,4:1,2:2} :
rlm@46: (Ext.isSafari ? {1:0,2:1,3:2} : {0:0,1:1,2:2});
rlm@46:
rlm@46: Ext.EventObjectImpl = function(e){
rlm@46: if(e){
rlm@46: this.setEvent(e.browserEvent || e);
rlm@46: }
rlm@46: };
rlm@46: Ext.EventObjectImpl.prototype = {
rlm@46:
rlm@46: browserEvent : null,
rlm@46:
rlm@46: button : -1,
rlm@46:
rlm@46: shiftKey : false,
rlm@46:
rlm@46: ctrlKey : false,
rlm@46:
rlm@46: altKey : false,
rlm@46:
rlm@46:
rlm@46: BACKSPACE : 8,
rlm@46:
rlm@46: TAB : 9,
rlm@46:
rlm@46: RETURN : 13,
rlm@46:
rlm@46: ENTER : 13,
rlm@46:
rlm@46: SHIFT : 16,
rlm@46:
rlm@46: CONTROL : 17,
rlm@46:
rlm@46: ESC : 27,
rlm@46:
rlm@46: SPACE : 32,
rlm@46:
rlm@46: PAGEUP : 33,
rlm@46:
rlm@46: PAGEDOWN : 34,
rlm@46:
rlm@46: END : 35,
rlm@46:
rlm@46: HOME : 36,
rlm@46:
rlm@46: LEFT : 37,
rlm@46:
rlm@46: UP : 38,
rlm@46:
rlm@46: RIGHT : 39,
rlm@46:
rlm@46: DOWN : 40,
rlm@46:
rlm@46: DELETE : 46,
rlm@46:
rlm@46: F5 : 116,
rlm@46:
rlm@46:
rlm@46: setEvent : function(e){
rlm@46: if(e == this || (e && e.browserEvent)){
rlm@46: return e;
rlm@46: }
rlm@46: this.browserEvent = e;
rlm@46: if(e){
rlm@46:
rlm@46: this.button = e.button ? btnMap[e.button] : (e.which ? e.which-1 : -1);
rlm@46: if(e.type == 'click' && this.button == -1){
rlm@46: this.button = 0;
rlm@46: }
rlm@46: this.type = e.type;
rlm@46: this.shiftKey = e.shiftKey;
rlm@46:
rlm@46: this.ctrlKey = e.ctrlKey || e.metaKey;
rlm@46: this.altKey = e.altKey;
rlm@46:
rlm@46: this.keyCode = e.keyCode;
rlm@46: this.charCode = e.charCode;
rlm@46:
rlm@46: this.target = E.getTarget(e);
rlm@46:
rlm@46: this.xy = E.getXY(e);
rlm@46: }else{
rlm@46: this.button = -1;
rlm@46: this.shiftKey = false;
rlm@46: this.ctrlKey = false;
rlm@46: this.altKey = false;
rlm@46: this.keyCode = 0;
rlm@46: this.charCode =0;
rlm@46: this.target = null;
rlm@46: this.xy = [0, 0];
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: stopEvent : function(){
rlm@46: if(this.browserEvent){
rlm@46: if(this.browserEvent.type == 'mousedown'){
rlm@46: Ext.EventManager.stoppedMouseDownEvent.fire(this);
rlm@46: }
rlm@46: E.stopEvent(this.browserEvent);
rlm@46: }
rlm@46: },
rlm@46:
rlm@46:
rlm@46: preventDefault : function(){
rlm@46: if(this.browserEvent){
rlm@46: E.preventDefault(this.browserEvent);
rlm@46: }
rlm@46: },
rlm@46:
rlm@46:
rlm@46: isNavKeyPress : function(){
rlm@46: var k = this.keyCode;
rlm@46: k = Ext.isSafari ? (safariKeys[k] || k) : k;
rlm@46: return (k >= 33 && k <= 40) || k == this.RETURN || k == this.TAB || k == this.ESC;
rlm@46: },
rlm@46:
rlm@46: isSpecialKey : function(){
rlm@46: var k = this.keyCode;
rlm@46: return (this.type == 'keypress' && this.ctrlKey) || k == 9 || k == 13 || k == 40 || k == 27 ||
rlm@46: (k == 16) || (k == 17) ||
rlm@46: (k >= 18 && k <= 20) ||
rlm@46: (k >= 33 && k <= 35) ||
rlm@46: (k >= 36 && k <= 39) ||
rlm@46: (k >= 44 && k <= 45);
rlm@46: },
rlm@46:
rlm@46: stopPropagation : function(){
rlm@46: if(this.browserEvent){
rlm@46: if(this.browserEvent.type == 'mousedown'){
rlm@46: Ext.EventManager.stoppedMouseDownEvent.fire(this);
rlm@46: }
rlm@46: E.stopPropagation(this.browserEvent);
rlm@46: }
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getCharCode : function(){
rlm@46: return this.charCode || this.keyCode;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getKey : function(){
rlm@46: var k = this.keyCode || this.charCode;
rlm@46: return Ext.isSafari ? (safariKeys[k] || k) : k;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getPageX : function(){
rlm@46: return this.xy[0];
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getPageY : function(){
rlm@46: return this.xy[1];
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getTime : function(){
rlm@46: if(this.browserEvent){
rlm@46: return E.getTime(this.browserEvent);
rlm@46: }
rlm@46: return null;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getXY : function(){
rlm@46: return this.xy;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getTarget : function(selector, maxDepth, returnEl){
rlm@46: return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : (returnEl ? Ext.get(this.target) : this.target);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getRelatedTarget : function(){
rlm@46: if(this.browserEvent){
rlm@46: return E.getRelatedTarget(this.browserEvent);
rlm@46: }
rlm@46: return null;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getWheelDelta : function(){
rlm@46: var e = this.browserEvent;
rlm@46: var delta = 0;
rlm@46: if(e.wheelDelta){
rlm@46: delta = e.wheelDelta/120;
rlm@46: }else if(e.detail){
rlm@46: delta = -e.detail/3;
rlm@46: }
rlm@46: return delta;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: hasModifier : function(){
rlm@46: return ((this.ctrlKey || this.altKey) || this.shiftKey) ? true : false;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: within : function(el, related){
rlm@46: var t = this[related ? "getRelatedTarget" : "getTarget"]();
rlm@46: return t && Ext.fly(el).contains(t);
rlm@46: },
rlm@46:
rlm@46: getPoint : function(){
rlm@46: return new Ext.lib.Point(this.xy[0], this.xy[1]);
rlm@46: }
rlm@46: };
rlm@46:
rlm@46: return new Ext.EventObjectImpl();
rlm@46: }();
rlm@46:
rlm@46: (function(){
rlm@46: var D = Ext.lib.Dom;
rlm@46: var E = Ext.lib.Event;
rlm@46: var A = Ext.lib.Anim;
rlm@46:
rlm@46: var propCache = {};
rlm@46: var camelRe = /(-[a-z])/gi;
rlm@46: var camelFn = function(m, a){ return a.charAt(1).toUpperCase(); };
rlm@46: var view = document.defaultView;
rlm@46:
rlm@46: Ext.Element = function(element, forceNew){
rlm@46: var dom = typeof element == "string" ?
rlm@46: document.getElementById(element) : element;
rlm@46: if(!dom){ return null;
rlm@46: }
rlm@46: var id = dom.id;
rlm@46: if(forceNew !== true && id && Ext.Element.cache[id]){ return Ext.Element.cache[id];
rlm@46: }
rlm@46:
rlm@46:
rlm@46: this.dom = dom;
rlm@46:
rlm@46:
rlm@46: this.id = id || Ext.id(dom);
rlm@46: };
rlm@46:
rlm@46: var El = Ext.Element;
rlm@46:
rlm@46: El.prototype = {
rlm@46:
rlm@46: originalDisplay : "",
rlm@46:
rlm@46: visibilityMode : 1,
rlm@46:
rlm@46: defaultUnit : "px",
rlm@46:
rlm@46: setVisibilityMode : function(visMode){
rlm@46: this.visibilityMode = visMode;
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46: enableDisplayMode : function(display){
rlm@46: this.setVisibilityMode(El.DISPLAY);
rlm@46: if(typeof display != "undefined") this.originalDisplay = display;
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: findParent : function(simpleSelector, maxDepth, returnEl){
rlm@46: var p = this.dom, b = document.body, depth = 0, dq = Ext.DomQuery, stopEl;
rlm@46: maxDepth = maxDepth || 50;
rlm@46: if(typeof maxDepth != "number"){
rlm@46: stopEl = Ext.getDom(maxDepth);
rlm@46: maxDepth = 10;
rlm@46: }
rlm@46: while(p && p.nodeType == 1 && depth < maxDepth && p != b && p != stopEl){
rlm@46: if(dq.is(p, simpleSelector)){
rlm@46: return returnEl ? Ext.get(p) : p;
rlm@46: }
rlm@46: depth++;
rlm@46: p = p.parentNode;
rlm@46: }
rlm@46: return null;
rlm@46: },
rlm@46:
rlm@46:
rlm@46:
rlm@46: findParentNode : function(simpleSelector, maxDepth, returnEl){
rlm@46: var p = Ext.fly(this.dom.parentNode, '_internal');
rlm@46: return p ? p.findParent(simpleSelector, maxDepth, returnEl) : null;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: up : function(simpleSelector, maxDepth){
rlm@46: return this.findParentNode(simpleSelector, maxDepth, true);
rlm@46: },
rlm@46:
rlm@46:
rlm@46:
rlm@46:
rlm@46: is : function(simpleSelector){
rlm@46: return Ext.DomQuery.is(this.dom, simpleSelector);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: animate : function(args, duration, onComplete, easing, animType){
rlm@46: this.anim(args, {duration: duration, callback: onComplete, easing: easing}, animType);
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: anim : function(args, opt, animType, defaultDur, defaultEase, cb){
rlm@46: animType = animType || 'run';
rlm@46: opt = opt || {};
rlm@46: var anim = Ext.lib.Anim[animType](
rlm@46: this.dom, args,
rlm@46: (opt.duration || defaultDur) || .35,
rlm@46: (opt.easing || defaultEase) || 'easeOut',
rlm@46: function(){
rlm@46: Ext.callback(cb, this);
rlm@46: Ext.callback(opt.callback, opt.scope || this, [this, opt]);
rlm@46: },
rlm@46: this
rlm@46: );
rlm@46: opt.anim = anim;
rlm@46: return anim;
rlm@46: },
rlm@46:
rlm@46: preanim : function(a, i){
rlm@46: return !a[i] ? false : (typeof a[i] == "object" ? a[i]: {duration: a[i+1], callback: a[i+2], easing: a[i+3]});
rlm@46: },
rlm@46:
rlm@46:
rlm@46: clean : function(forceReclean){
rlm@46: if(this.isCleaned && forceReclean !== true){
rlm@46: return this;
rlm@46: }
rlm@46: var ns = /\S/;
rlm@46: var d = this.dom, n = d.firstChild, ni = -1;
rlm@46: while(n){
rlm@46: var nx = n.nextSibling;
rlm@46: if(n.nodeType == 3 && !ns.test(n.nodeValue)){
rlm@46: d.removeChild(n);
rlm@46: }else{
rlm@46: n.nodeIndex = ++ni;
rlm@46: }
rlm@46: n = nx;
rlm@46: }
rlm@46: this.isCleaned = true;
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: scrollIntoView : function(container, hscroll){
rlm@46: var c = Ext.getDom(container) || Ext.getBody().dom;
rlm@46: var el = this.dom;
rlm@46:
rlm@46: var o = this.getOffsetsTo(c),
rlm@46: l = o[0] + c.scrollLeft,
rlm@46: t = o[1] + c.scrollTop,
rlm@46: b = t+el.offsetHeight,
rlm@46: r = l+el.offsetWidth;
rlm@46:
rlm@46: var ch = c.clientHeight;
rlm@46: var ct = parseInt(c.scrollTop, 10);
rlm@46: var cl = parseInt(c.scrollLeft, 10);
rlm@46: var cb = ct + ch;
rlm@46: var cr = cl + c.clientWidth;
rlm@46:
rlm@46: if(el.offsetHeight > ch || t < ct){
rlm@46: c.scrollTop = t;
rlm@46: }else if(b > cb){
rlm@46: c.scrollTop = b-ch;
rlm@46: }
rlm@46: c.scrollTop = c.scrollTop;
rlm@46: if(hscroll !== false){
rlm@46: if(el.offsetWidth > c.clientWidth || l < cl){
rlm@46: c.scrollLeft = l;
rlm@46: }else if(r > cr){
rlm@46: c.scrollLeft = r-c.clientWidth;
rlm@46: }
rlm@46: c.scrollLeft = c.scrollLeft;
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46: scrollChildIntoView : function(child, hscroll){
rlm@46: Ext.fly(child, '_scrollChildIntoView').scrollIntoView(this, hscroll);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: autoHeight : function(animate, duration, onComplete, easing){
rlm@46: var oldHeight = this.getHeight();
rlm@46: this.clip();
rlm@46: this.setHeight(1); setTimeout(function(){
rlm@46: var height = parseInt(this.dom.scrollHeight, 10); if(!animate){
rlm@46: this.setHeight(height);
rlm@46: this.unclip();
rlm@46: if(typeof onComplete == "function"){
rlm@46: onComplete();
rlm@46: }
rlm@46: }else{
rlm@46: this.setHeight(oldHeight); this.setHeight(height, animate, duration, function(){
rlm@46: this.unclip();
rlm@46: if(typeof onComplete == "function") onComplete();
rlm@46: }.createDelegate(this), easing);
rlm@46: }
rlm@46: }.createDelegate(this), 0);
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: contains : function(el){
rlm@46: if(!el){return false;}
rlm@46: return D.isAncestor(this.dom, el.dom ? el.dom : el);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: isVisible : function(deep) {
rlm@46: var vis = !(this.getStyle("visibility") == "hidden" || this.getStyle("display") == "none");
rlm@46: if(deep !== true || !vis){
rlm@46: return vis;
rlm@46: }
rlm@46: var p = this.dom.parentNode;
rlm@46: while(p && p.tagName.toLowerCase() != "body"){
rlm@46: if(!Ext.fly(p, '_isVisible').isVisible()){
rlm@46: return false;
rlm@46: }
rlm@46: p = p.parentNode;
rlm@46: }
rlm@46: return true;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: select : function(selector, unique){
rlm@46: return El.select(selector, unique, this.dom);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: query : function(selector, unique){
rlm@46: return Ext.DomQuery.select(selector, this.dom);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: child : function(selector, returnDom){
rlm@46: var n = Ext.DomQuery.selectNode(selector, this.dom);
rlm@46: return returnDom ? n : Ext.get(n);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: down : function(selector, returnDom){
rlm@46: var n = Ext.DomQuery.selectNode(" > " + selector, this.dom);
rlm@46: return returnDom ? n : Ext.get(n);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: initDD : function(group, config, overrides){
rlm@46: var dd = new Ext.dd.DD(Ext.id(this.dom), group, config);
rlm@46: return Ext.apply(dd, overrides);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: initDDProxy : function(group, config, overrides){
rlm@46: var dd = new Ext.dd.DDProxy(Ext.id(this.dom), group, config);
rlm@46: return Ext.apply(dd, overrides);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: initDDTarget : function(group, config, overrides){
rlm@46: var dd = new Ext.dd.DDTarget(Ext.id(this.dom), group, config);
rlm@46: return Ext.apply(dd, overrides);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: setVisible : function(visible, animate){
rlm@46: if(!animate || !A){
rlm@46: if(this.visibilityMode == El.DISPLAY){
rlm@46: this.setDisplayed(visible);
rlm@46: }else{
rlm@46: this.fixDisplay();
rlm@46: this.dom.style.visibility = visible ? "visible" : "hidden";
rlm@46: }
rlm@46: }else{
rlm@46: var dom = this.dom;
rlm@46: var visMode = this.visibilityMode;
rlm@46: if(visible){
rlm@46: this.setOpacity(.01);
rlm@46: this.setVisible(true);
rlm@46: }
rlm@46: this.anim({opacity: { to: (visible?1:0) }},
rlm@46: this.preanim(arguments, 1),
rlm@46: null, .35, 'easeIn', function(){
rlm@46: if(!visible){
rlm@46: if(visMode == El.DISPLAY){
rlm@46: dom.style.display = "none";
rlm@46: }else{
rlm@46: dom.style.visibility = "hidden";
rlm@46: }
rlm@46: Ext.get(dom).setOpacity(1);
rlm@46: }
rlm@46: });
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: isDisplayed : function() {
rlm@46: return this.getStyle("display") != "none";
rlm@46: },
rlm@46:
rlm@46:
rlm@46: toggle : function(animate){
rlm@46: this.setVisible(!this.isVisible(), this.preanim(arguments, 0));
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: setDisplayed : function(value) {
rlm@46: if(typeof value == "boolean"){
rlm@46: value = value ? this.originalDisplay : "none";
rlm@46: }
rlm@46: this.setStyle("display", value);
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: focus : function() {
rlm@46: try{
rlm@46: this.dom.focus();
rlm@46: }catch(e){}
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: blur : function() {
rlm@46: try{
rlm@46: this.dom.blur();
rlm@46: }catch(e){}
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: addClass : function(className){
rlm@46: if(Ext.isArray(className)){
rlm@46: for(var i = 0, len = className.length; i < len; i++) {
rlm@46: this.addClass(className[i]);
rlm@46: }
rlm@46: }else{
rlm@46: if(className && !this.hasClass(className)){
rlm@46: this.dom.className = this.dom.className + " " + className;
rlm@46: }
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: radioClass : function(className){
rlm@46: var siblings = this.dom.parentNode.childNodes;
rlm@46: for(var i = 0; i < siblings.length; i++) {
rlm@46: var s = siblings[i];
rlm@46: if(s.nodeType == 1){
rlm@46: Ext.get(s).removeClass(className);
rlm@46: }
rlm@46: }
rlm@46: this.addClass(className);
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: removeClass : function(className){
rlm@46: if(!className || !this.dom.className){
rlm@46: return this;
rlm@46: }
rlm@46: if(Ext.isArray(className)){
rlm@46: for(var i = 0, len = className.length; i < len; i++) {
rlm@46: this.removeClass(className[i]);
rlm@46: }
rlm@46: }else{
rlm@46: if(this.hasClass(className)){
rlm@46: var re = this.classReCache[className];
rlm@46: if (!re) {
rlm@46: re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', "g");
rlm@46: this.classReCache[className] = re;
rlm@46: }
rlm@46: this.dom.className =
rlm@46: this.dom.className.replace(re, " ");
rlm@46: }
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46: classReCache: {},
rlm@46:
rlm@46:
rlm@46: toggleClass : function(className){
rlm@46: if(this.hasClass(className)){
rlm@46: this.removeClass(className);
rlm@46: }else{
rlm@46: this.addClass(className);
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: hasClass : function(className){
rlm@46: return className && (' '+this.dom.className+' ').indexOf(' '+className+' ') != -1;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: replaceClass : function(oldClassName, newClassName){
rlm@46: this.removeClass(oldClassName);
rlm@46: this.addClass(newClassName);
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getStyles : function(){
rlm@46: var a = arguments, len = a.length, r = {};
rlm@46: for(var i = 0; i < len; i++){
rlm@46: r[a[i]] = this.getStyle(a[i]);
rlm@46: }
rlm@46: return r;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getStyle : function(){
rlm@46: return view && view.getComputedStyle ?
rlm@46: function(prop){
rlm@46: var el = this.dom, v, cs, camel;
rlm@46: if(prop == 'float'){
rlm@46: prop = "cssFloat";
rlm@46: }
rlm@46: if(v = el.style[prop]){
rlm@46: return v;
rlm@46: }
rlm@46: if(cs = view.getComputedStyle(el, "")){
rlm@46: if(!(camel = propCache[prop])){
rlm@46: camel = propCache[prop] = prop.replace(camelRe, camelFn);
rlm@46: }
rlm@46: return cs[camel];
rlm@46: }
rlm@46: return null;
rlm@46: } :
rlm@46: function(prop){
rlm@46: var el = this.dom, v, cs, camel;
rlm@46: if(prop == 'opacity'){
rlm@46: if(typeof el.style.filter == 'string'){
rlm@46: var m = el.style.filter.match(/alpha\(opacity=(.*)\)/i);
rlm@46: if(m){
rlm@46: var fv = parseFloat(m[1]);
rlm@46: if(!isNaN(fv)){
rlm@46: return fv ? fv / 100 : 0;
rlm@46: }
rlm@46: }
rlm@46: }
rlm@46: return 1;
rlm@46: }else if(prop == 'float'){
rlm@46: prop = "styleFloat";
rlm@46: }
rlm@46: if(!(camel = propCache[prop])){
rlm@46: camel = propCache[prop] = prop.replace(camelRe, camelFn);
rlm@46: }
rlm@46: if(v = el.style[camel]){
rlm@46: return v;
rlm@46: }
rlm@46: if(cs = el.currentStyle){
rlm@46: return cs[camel];
rlm@46: }
rlm@46: return null;
rlm@46: };
rlm@46: }(),
rlm@46:
rlm@46:
rlm@46: setStyle : function(prop, value){
rlm@46: if(typeof prop == "string"){
rlm@46: var camel;
rlm@46: if(!(camel = propCache[prop])){
rlm@46: camel = propCache[prop] = prop.replace(camelRe, camelFn);
rlm@46: }
rlm@46: if(camel == 'opacity') {
rlm@46: this.setOpacity(value);
rlm@46: }else{
rlm@46: this.dom.style[camel] = value;
rlm@46: }
rlm@46: }else{
rlm@46: for(var style in prop){
rlm@46: if(typeof prop[style] != "function"){
rlm@46: this.setStyle(style, prop[style]);
rlm@46: }
rlm@46: }
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: applyStyles : function(style){
rlm@46: Ext.DomHelper.applyStyles(this.dom, style);
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getX : function(){
rlm@46: return D.getX(this.dom);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getY : function(){
rlm@46: return D.getY(this.dom);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getXY : function(){
rlm@46: return D.getXY(this.dom);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getOffsetsTo : function(el){
rlm@46: var o = this.getXY();
rlm@46: var e = Ext.fly(el, '_internal').getXY();
rlm@46: return [o[0]-e[0],o[1]-e[1]];
rlm@46: },
rlm@46:
rlm@46:
rlm@46: setX : function(x, animate){
rlm@46: if(!animate || !A){
rlm@46: D.setX(this.dom, x);
rlm@46: }else{
rlm@46: this.setXY([x, this.getY()], this.preanim(arguments, 1));
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: setY : function(y, animate){
rlm@46: if(!animate || !A){
rlm@46: D.setY(this.dom, y);
rlm@46: }else{
rlm@46: this.setXY([this.getX(), y], this.preanim(arguments, 1));
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: setLeft : function(left){
rlm@46: this.setStyle("left", this.addUnits(left));
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: setTop : function(top){
rlm@46: this.setStyle("top", this.addUnits(top));
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: setRight : function(right){
rlm@46: this.setStyle("right", this.addUnits(right));
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: setBottom : function(bottom){
rlm@46: this.setStyle("bottom", this.addUnits(bottom));
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: setXY : function(pos, animate){
rlm@46: if(!animate || !A){
rlm@46: D.setXY(this.dom, pos);
rlm@46: }else{
rlm@46: this.anim({points: {to: pos}}, this.preanim(arguments, 1), 'motion');
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: setLocation : function(x, y, animate){
rlm@46: this.setXY([x, y], this.preanim(arguments, 2));
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: moveTo : function(x, y, animate){
rlm@46: this.setXY([x, y], this.preanim(arguments, 2));
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getRegion : function(){
rlm@46: return D.getRegion(this.dom);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getHeight : function(contentHeight){
rlm@46: var h = this.dom.offsetHeight || 0;
rlm@46: h = contentHeight !== true ? h : h-this.getBorderWidth("tb")-this.getPadding("tb");
rlm@46: return h < 0 ? 0 : h;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getWidth : function(contentWidth){
rlm@46: var w = this.dom.offsetWidth || 0;
rlm@46: w = contentWidth !== true ? w : w-this.getBorderWidth("lr")-this.getPadding("lr");
rlm@46: return w < 0 ? 0 : w;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getComputedHeight : function(){
rlm@46: var h = Math.max(this.dom.offsetHeight, this.dom.clientHeight);
rlm@46: if(!h){
rlm@46: h = parseInt(this.getStyle('height'), 10) || 0;
rlm@46: if(!this.isBorderBox()){
rlm@46: h += this.getFrameWidth('tb');
rlm@46: }
rlm@46: }
rlm@46: return h;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getComputedWidth : function(){
rlm@46: var w = Math.max(this.dom.offsetWidth, this.dom.clientWidth);
rlm@46: if(!w){
rlm@46: w = parseInt(this.getStyle('width'), 10) || 0;
rlm@46: if(!this.isBorderBox()){
rlm@46: w += this.getFrameWidth('lr');
rlm@46: }
rlm@46: }
rlm@46: return w;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getSize : function(contentSize){
rlm@46: return {width: this.getWidth(contentSize), height: this.getHeight(contentSize)};
rlm@46: },
rlm@46:
rlm@46: getStyleSize : function(){
rlm@46: var w, h, d = this.dom, s = d.style;
rlm@46: if(s.width && s.width != 'auto'){
rlm@46: w = parseInt(s.width, 10);
rlm@46: if(Ext.isBorderBox){
rlm@46: w -= this.getFrameWidth('lr');
rlm@46: }
rlm@46: }
rlm@46: if(s.height && s.height != 'auto'){
rlm@46: h = parseInt(s.height, 10);
rlm@46: if(Ext.isBorderBox){
rlm@46: h -= this.getFrameWidth('tb');
rlm@46: }
rlm@46: }
rlm@46: return {width: w || this.getWidth(true), height: h || this.getHeight(true)};
rlm@46:
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getViewSize : function(){
rlm@46: var d = this.dom, doc = document, aw = 0, ah = 0;
rlm@46: if(d == doc || d == doc.body){
rlm@46: return {width : D.getViewWidth(), height: D.getViewHeight()};
rlm@46: }else{
rlm@46: return {
rlm@46: width : d.clientWidth,
rlm@46: height: d.clientHeight
rlm@46: };
rlm@46: }
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getValue : function(asNumber){
rlm@46: return asNumber ? parseInt(this.dom.value, 10) : this.dom.value;
rlm@46: },
rlm@46:
rlm@46: adjustWidth : function(width){
rlm@46: if(typeof width == "number"){
rlm@46: if(this.autoBoxAdjust && !this.isBorderBox()){
rlm@46: width -= (this.getBorderWidth("lr") + this.getPadding("lr"));
rlm@46: }
rlm@46: if(width < 0){
rlm@46: width = 0;
rlm@46: }
rlm@46: }
rlm@46: return width;
rlm@46: },
rlm@46:
rlm@46: adjustHeight : function(height){
rlm@46: if(typeof height == "number"){
rlm@46: if(this.autoBoxAdjust && !this.isBorderBox()){
rlm@46: height -= (this.getBorderWidth("tb") + this.getPadding("tb"));
rlm@46: }
rlm@46: if(height < 0){
rlm@46: height = 0;
rlm@46: }
rlm@46: }
rlm@46: return height;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: setWidth : function(width, animate){
rlm@46: width = this.adjustWidth(width);
rlm@46: if(!animate || !A){
rlm@46: this.dom.style.width = this.addUnits(width);
rlm@46: }else{
rlm@46: this.anim({width: {to: width}}, this.preanim(arguments, 1));
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: setHeight : function(height, animate){
rlm@46: height = this.adjustHeight(height);
rlm@46: if(!animate || !A){
rlm@46: this.dom.style.height = this.addUnits(height);
rlm@46: }else{
rlm@46: this.anim({height: {to: height}}, this.preanim(arguments, 1));
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: setSize : function(width, height, animate){
rlm@46: if(typeof width == "object"){ height = width.height; width = width.width;
rlm@46: }
rlm@46: width = this.adjustWidth(width); height = this.adjustHeight(height);
rlm@46: if(!animate || !A){
rlm@46: this.dom.style.width = this.addUnits(width);
rlm@46: this.dom.style.height = this.addUnits(height);
rlm@46: }else{
rlm@46: this.anim({width: {to: width}, height: {to: height}}, this.preanim(arguments, 2));
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: setBounds : function(x, y, width, height, animate){
rlm@46: if(!animate || !A){
rlm@46: this.setSize(width, height);
rlm@46: this.setLocation(x, y);
rlm@46: }else{
rlm@46: width = this.adjustWidth(width); height = this.adjustHeight(height);
rlm@46: this.anim({points: {to: [x, y]}, width: {to: width}, height: {to: height}},
rlm@46: this.preanim(arguments, 4), 'motion');
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: setRegion : function(region, animate){
rlm@46: this.setBounds(region.left, region.top, region.right-region.left, region.bottom-region.top, this.preanim(arguments, 1));
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: addListener : function(eventName, fn, scope, options){
rlm@46: Ext.EventManager.on(this.dom, eventName, fn, scope || this, options);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: removeListener : function(eventName, fn){
rlm@46: Ext.EventManager.removeListener(this.dom, eventName, fn);
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: removeAllListeners : function(){
rlm@46: E.purgeElement(this.dom);
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: relayEvent : function(eventName, observable){
rlm@46: this.on(eventName, function(e){
rlm@46: observable.fireEvent(eventName, e);
rlm@46: });
rlm@46: },
rlm@46:
rlm@46:
rlm@46: setOpacity : function(opacity, animate){
rlm@46: if(!animate || !A){
rlm@46: var s = this.dom.style;
rlm@46: if(Ext.isIE){
rlm@46: s.zoom = 1;
rlm@46: s.filter = (s.filter || '').replace(/alpha\([^\)]*\)/gi,"") +
rlm@46: (opacity == 1 ? "" : " alpha(opacity=" + opacity * 100 + ")");
rlm@46: }else{
rlm@46: s.opacity = opacity;
rlm@46: }
rlm@46: }else{
rlm@46: this.anim({opacity: {to: opacity}}, this.preanim(arguments, 1), null, .35, 'easeIn');
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getLeft : function(local){
rlm@46: if(!local){
rlm@46: return this.getX();
rlm@46: }else{
rlm@46: return parseInt(this.getStyle("left"), 10) || 0;
rlm@46: }
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getRight : function(local){
rlm@46: if(!local){
rlm@46: return this.getX() + this.getWidth();
rlm@46: }else{
rlm@46: return (this.getLeft(true) + this.getWidth()) || 0;
rlm@46: }
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getTop : function(local) {
rlm@46: if(!local){
rlm@46: return this.getY();
rlm@46: }else{
rlm@46: return parseInt(this.getStyle("top"), 10) || 0;
rlm@46: }
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getBottom : function(local){
rlm@46: if(!local){
rlm@46: return this.getY() + this.getHeight();
rlm@46: }else{
rlm@46: return (this.getTop(true) + this.getHeight()) || 0;
rlm@46: }
rlm@46: },
rlm@46:
rlm@46:
rlm@46: position : function(pos, zIndex, x, y){
rlm@46: if(!pos){
rlm@46: if(this.getStyle('position') == 'static'){
rlm@46: this.setStyle('position', 'relative');
rlm@46: }
rlm@46: }else{
rlm@46: this.setStyle("position", pos);
rlm@46: }
rlm@46: if(zIndex){
rlm@46: this.setStyle("z-index", zIndex);
rlm@46: }
rlm@46: if(x !== undefined && y !== undefined){
rlm@46: this.setXY([x, y]);
rlm@46: }else if(x !== undefined){
rlm@46: this.setX(x);
rlm@46: }else if(y !== undefined){
rlm@46: this.setY(y);
rlm@46: }
rlm@46: },
rlm@46:
rlm@46:
rlm@46: clearPositioning : function(value){
rlm@46: value = value ||'';
rlm@46: this.setStyle({
rlm@46: "left": value,
rlm@46: "right": value,
rlm@46: "top": value,
rlm@46: "bottom": value,
rlm@46: "z-index": "",
rlm@46: "position" : "static"
rlm@46: });
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getPositioning : function(){
rlm@46: var l = this.getStyle("left");
rlm@46: var t = this.getStyle("top");
rlm@46: return {
rlm@46: "position" : this.getStyle("position"),
rlm@46: "left" : l,
rlm@46: "right" : l ? "" : this.getStyle("right"),
rlm@46: "top" : t,
rlm@46: "bottom" : t ? "" : this.getStyle("bottom"),
rlm@46: "z-index" : this.getStyle("z-index")
rlm@46: };
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getBorderWidth : function(side){
rlm@46: return this.addStyles(side, El.borders);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getPadding : function(side){
rlm@46: return this.addStyles(side, El.paddings);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: setPositioning : function(pc){
rlm@46: this.applyStyles(pc);
rlm@46: if(pc.right == "auto"){
rlm@46: this.dom.style.right = "";
rlm@46: }
rlm@46: if(pc.bottom == "auto"){
rlm@46: this.dom.style.bottom = "";
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46: fixDisplay : function(){
rlm@46: if(this.getStyle("display") == "none"){
rlm@46: this.setStyle("visibility", "hidden");
rlm@46: this.setStyle("display", this.originalDisplay); if(this.getStyle("display") == "none"){ this.setStyle("display", "block");
rlm@46: }
rlm@46: }
rlm@46: },
rlm@46:
rlm@46: setOverflow : function(v){
rlm@46: if(v=='auto' && Ext.isMac && Ext.isGecko){ this.dom.style.overflow = 'hidden';
rlm@46: (function(){this.dom.style.overflow = 'auto';}).defer(1, this);
rlm@46: }else{
rlm@46: this.dom.style.overflow = v;
rlm@46: }
rlm@46: },
rlm@46:
rlm@46:
rlm@46: setLeftTop : function(left, top){
rlm@46: this.dom.style.left = this.addUnits(left);
rlm@46: this.dom.style.top = this.addUnits(top);
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: move : function(direction, distance, animate){
rlm@46: var xy = this.getXY();
rlm@46: direction = direction.toLowerCase();
rlm@46: switch(direction){
rlm@46: case "l":
rlm@46: case "left":
rlm@46: this.moveTo(xy[0]-distance, xy[1], this.preanim(arguments, 2));
rlm@46: break;
rlm@46: case "r":
rlm@46: case "right":
rlm@46: this.moveTo(xy[0]+distance, xy[1], this.preanim(arguments, 2));
rlm@46: break;
rlm@46: case "t":
rlm@46: case "top":
rlm@46: case "up":
rlm@46: this.moveTo(xy[0], xy[1]-distance, this.preanim(arguments, 2));
rlm@46: break;
rlm@46: case "b":
rlm@46: case "bottom":
rlm@46: case "down":
rlm@46: this.moveTo(xy[0], xy[1]+distance, this.preanim(arguments, 2));
rlm@46: break;
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: clip : function(){
rlm@46: if(!this.isClipped){
rlm@46: this.isClipped = true;
rlm@46: this.originalClip = {
rlm@46: "o": this.getStyle("overflow"),
rlm@46: "x": this.getStyle("overflow-x"),
rlm@46: "y": this.getStyle("overflow-y")
rlm@46: };
rlm@46: this.setStyle("overflow", "hidden");
rlm@46: this.setStyle("overflow-x", "hidden");
rlm@46: this.setStyle("overflow-y", "hidden");
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: unclip : function(){
rlm@46: if(this.isClipped){
rlm@46: this.isClipped = false;
rlm@46: var o = this.originalClip;
rlm@46: if(o.o){this.setStyle("overflow", o.o);}
rlm@46: if(o.x){this.setStyle("overflow-x", o.x);}
rlm@46: if(o.y){this.setStyle("overflow-y", o.y);}
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46:
rlm@46: getAnchorXY : function(anchor, local, s){
rlm@46:
rlm@46: var w, h, vp = false;
rlm@46: if(!s){
rlm@46: var d = this.dom;
rlm@46: if(d == document.body || d == document){
rlm@46: vp = true;
rlm@46: w = D.getViewWidth(); h = D.getViewHeight();
rlm@46: }else{
rlm@46: w = this.getWidth(); h = this.getHeight();
rlm@46: }
rlm@46: }else{
rlm@46: w = s.width; h = s.height;
rlm@46: }
rlm@46: var x = 0, y = 0, r = Math.round;
rlm@46: switch((anchor || "tl").toLowerCase()){
rlm@46: case "c":
rlm@46: x = r(w*.5);
rlm@46: y = r(h*.5);
rlm@46: break;
rlm@46: case "t":
rlm@46: x = r(w*.5);
rlm@46: y = 0;
rlm@46: break;
rlm@46: case "l":
rlm@46: x = 0;
rlm@46: y = r(h*.5);
rlm@46: break;
rlm@46: case "r":
rlm@46: x = w;
rlm@46: y = r(h*.5);
rlm@46: break;
rlm@46: case "b":
rlm@46: x = r(w*.5);
rlm@46: y = h;
rlm@46: break;
rlm@46: case "tl":
rlm@46: x = 0;
rlm@46: y = 0;
rlm@46: break;
rlm@46: case "bl":
rlm@46: x = 0;
rlm@46: y = h;
rlm@46: break;
rlm@46: case "br":
rlm@46: x = w;
rlm@46: y = h;
rlm@46: break;
rlm@46: case "tr":
rlm@46: x = w;
rlm@46: y = 0;
rlm@46: break;
rlm@46: }
rlm@46: if(local === true){
rlm@46: return [x, y];
rlm@46: }
rlm@46: if(vp){
rlm@46: var sc = this.getScroll();
rlm@46: return [x + sc.left, y + sc.top];
rlm@46: }
rlm@46: var o = this.getXY();
rlm@46: return [x+o[0], y+o[1]];
rlm@46: },
rlm@46:
rlm@46:
rlm@46: getAlignToXY : function(el, p, o){
rlm@46: el = Ext.get(el);
rlm@46: if(!el || !el.dom){
rlm@46: throw "Element.alignToXY with an element that doesn't exist";
rlm@46: }
rlm@46: var d = this.dom;
rlm@46: var c = false; var p1 = "", p2 = "";
rlm@46: o = o || [0,0];
rlm@46:
rlm@46: if(!p){
rlm@46: p = "tl-bl";
rlm@46: }else if(p == "?"){
rlm@46: p = "tl-bl?";
rlm@46: }else if(p.indexOf("-") == -1){
rlm@46: p = "tl-" + p;
rlm@46: }
rlm@46: p = p.toLowerCase();
rlm@46: var m = p.match(/^([a-z]+)-([a-z]+)(\?)?$/);
rlm@46: if(!m){
rlm@46: throw "Element.alignTo with an invalid alignment " + p;
rlm@46: }
rlm@46: p1 = m[1]; p2 = m[2]; c = !!m[3];
rlm@46:
rlm@46: var a1 = this.getAnchorXY(p1, true);
rlm@46: var a2 = el.getAnchorXY(p2, false);
rlm@46:
rlm@46: var x = a2[0] - a1[0] + o[0];
rlm@46: var y = a2[1] - a1[1] + o[1];
rlm@46:
rlm@46: if(c){
rlm@46: var w = this.getWidth(), h = this.getHeight(), r = el.getRegion();
rlm@46: var dw = D.getViewWidth()-5, dh = D.getViewHeight()-5;
rlm@46:
rlm@46: var p1y = p1.charAt(0), p1x = p1.charAt(p1.length-1);
rlm@46: var p2y = p2.charAt(0), p2x = p2.charAt(p2.length-1);
rlm@46: var swapY = ((p1y=="t" && p2y=="b") || (p1y=="b" && p2y=="t"));
rlm@46: var swapX = ((p1x=="r" && p2x=="l") || (p1x=="l" && p2x=="r"));
rlm@46:
rlm@46: var doc = document;
rlm@46: var scrollX = (doc.documentElement.scrollLeft || doc.body.scrollLeft || 0)+5;
rlm@46: var scrollY = (doc.documentElement.scrollTop || doc.body.scrollTop || 0)+5;
rlm@46:
rlm@46: if((x+w) > dw + scrollX){
rlm@46: x = swapX ? r.left-w : dw+scrollX-w;
rlm@46: }
rlm@46: if(x < scrollX){
rlm@46: x = swapX ? r.right : scrollX;
rlm@46: }
rlm@46: if((y+h) > dh + scrollY){
rlm@46: y = swapY ? r.top-h : dh+scrollY-h;
rlm@46: }
rlm@46: if (y < scrollY){
rlm@46: y = swapY ? r.bottom : scrollY;
rlm@46: }
rlm@46: }
rlm@46: return [x,y];
rlm@46: },
rlm@46:
rlm@46: getConstrainToXY : function(){
rlm@46: var os = {top:0, left:0, bottom:0, right: 0};
rlm@46:
rlm@46: return function(el, local, offsets, proposedXY){
rlm@46: el = Ext.get(el);
rlm@46: offsets = offsets ? Ext.applyIf(offsets, os) : os;
rlm@46:
rlm@46: var vw, vh, vx = 0, vy = 0;
rlm@46: if(el.dom == document.body || el.dom == document){
rlm@46: vw = Ext.lib.Dom.getViewWidth();
rlm@46: vh = Ext.lib.Dom.getViewHeight();
rlm@46: }else{
rlm@46: vw = el.dom.clientWidth;
rlm@46: vh = el.dom.clientHeight;
rlm@46: if(!local){
rlm@46: var vxy = el.getXY();
rlm@46: vx = vxy[0];
rlm@46: vy = vxy[1];
rlm@46: }
rlm@46: }
rlm@46:
rlm@46: var s = el.getScroll();
rlm@46:
rlm@46: vx += offsets.left + s.left;
rlm@46: vy += offsets.top + s.top;
rlm@46:
rlm@46: vw -= offsets.right;
rlm@46: vh -= offsets.bottom;
rlm@46:
rlm@46: var vr = vx+vw;
rlm@46: var vb = vy+vh;
rlm@46:
rlm@46: var xy = proposedXY || (!local ? this.getXY() : [this.getLeft(true), this.getTop(true)]);
rlm@46: var x = xy[0], y = xy[1];
rlm@46: var w = this.dom.offsetWidth, h = this.dom.offsetHeight;
rlm@46:
rlm@46: var moved = false;
rlm@46:
rlm@46: if((x + w) > vr){
rlm@46: x = vr - w;
rlm@46: moved = true;
rlm@46: }
rlm@46: if((y + h) > vb){
rlm@46: y = vb - h;
rlm@46: moved = true;
rlm@46: }
rlm@46: if(x < vx){
rlm@46: x = vx;
rlm@46: moved = true;
rlm@46: }
rlm@46: if(y < vy){
rlm@46: y = vy;
rlm@46: moved = true;
rlm@46: }
rlm@46: return moved ? [x, y] : false;
rlm@46: };
rlm@46: }(),
rlm@46:
rlm@46: adjustForConstraints : function(xy, parent, offsets){
rlm@46: return this.getConstrainToXY(parent || document, false, offsets, xy) || xy;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: alignTo : function(element, position, offsets, animate){
rlm@46: var xy = this.getAlignToXY(element, position, offsets);
rlm@46: this.setXY(xy, this.preanim(arguments, 3));
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: anchorTo : function(el, alignment, offsets, animate, monitorScroll, callback){
rlm@46: var action = function(){
rlm@46: this.alignTo(el, alignment, offsets, animate);
rlm@46: Ext.callback(callback, this);
rlm@46: };
rlm@46: Ext.EventManager.onWindowResize(action, this);
rlm@46: var tm = typeof monitorScroll;
rlm@46: if(tm != 'undefined'){
rlm@46: Ext.EventManager.on(window, 'scroll', action, this,
rlm@46: {buffer: tm == 'number' ? monitorScroll : 50});
rlm@46: }
rlm@46: action.call(this); return this;
rlm@46: },
rlm@46:
rlm@46: clearOpacity : function(){
rlm@46: if (window.ActiveXObject) {
rlm@46: if(typeof this.dom.style.filter == 'string' && (/alpha/i).test(this.dom.style.filter)){
rlm@46: this.dom.style.filter = "";
rlm@46: }
rlm@46: } else {
rlm@46: this.dom.style.opacity = "";
rlm@46: this.dom.style["-moz-opacity"] = "";
rlm@46: this.dom.style["-khtml-opacity"] = "";
rlm@46: }
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: hide : function(animate){
rlm@46: this.setVisible(false, this.preanim(arguments, 0));
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: show : function(animate){
rlm@46: this.setVisible(true, this.preanim(arguments, 0));
rlm@46: return this;
rlm@46: },
rlm@46:
rlm@46:
rlm@46: addUnits : function(size){
rlm@46: return Ext.Element.addUnits(size, this.defaultUnit);
rlm@46: },
rlm@46:
rlm@46:
rlm@46: update : function(html, loadScripts, callback){
rlm@46: if(typeof html == "undefined"){
rlm@46: html = "";
rlm@46: }
rlm@46: if(loadScripts !== true){
rlm@46: this.dom.innerHTML = html;
rlm@46: if(typeof callback == "function"){
rlm@46: callback();
rlm@46: }
rlm@46: return this;
rlm@46: }
rlm@46: var id = Ext.id();
rlm@46: var dom = this.dom;
rlm@46:
rlm@46: html += '';
rlm@46:
rlm@46: E.onAvailable(id, function(){
rlm@46: var hd = document.getElementsByTagName("head")[0];
rlm@46: var re = /(?: