upgraded yui to 2.2.2 and yui-ext to 1.0.1a
This commit is contained in:
parent
4d9af2c691
commit
547ced6500
1992 changed files with 645731 additions and 0 deletions
212
www/extras/yui-ext/source/core/CompositeElement.js
vendored
Normal file
212
www/extras/yui-ext/source/core/CompositeElement.js
vendored
Normal file
|
|
@ -0,0 +1,212 @@
|
|||
/*
|
||||
* Ext JS Library 1.0.1
|
||||
* Copyright(c) 2006-2007, Ext JS, LLC.
|
||||
* licensing@extjs.com
|
||||
*
|
||||
* http://www.extjs.com/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Ext.CompositeElement
|
||||
* Standard composite class. Creates a Ext.Element for every element in the collection.
|
||||
* <br><br>
|
||||
* <b>NOTE: Although they are not listed, this class supports all of the set/update methods of Ext.Element. All Ext.Element
|
||||
* actions will be performed on all the elements in this collection.</b>
|
||||
* <br><br>
|
||||
* All methods return <i>this</i> and can be chained.
|
||||
<pre><code>
|
||||
var els = getEls("#some-el div.some-class");
|
||||
// or
|
||||
var els = Ext.Element.select("#some-el div.some-class");
|
||||
els.setWidth(100); // all elements become 100 width
|
||||
els.hide(true); // all elements fade out and hide
|
||||
// or
|
||||
els.setWidth(100).hide(true);
|
||||
</code></pre>
|
||||
*/
|
||||
Ext.CompositeElement = function(els){
|
||||
this.elements = [];
|
||||
this.addElements(els);
|
||||
};
|
||||
Ext.CompositeElement.prototype = {
|
||||
isComposite: true,
|
||||
addElements : function(els){
|
||||
if(!els) return this;
|
||||
if(typeof els == "string"){
|
||||
els = Ext.Element.selectorFunction(els);
|
||||
}
|
||||
var yels = this.elements;
|
||||
var index = yels.length-1;
|
||||
for(var i = 0, len = els.length; i < len; i++) {
|
||||
yels[++index] = Ext.get(els[i], true);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
invoke : function(fn, args){
|
||||
var els = this.elements;
|
||||
for(var i = 0, len = els.length; i < len; i++) {
|
||||
Ext.Element.prototype[fn].apply(els[i], args);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
/**
|
||||
* Adds elements to this composite.
|
||||
* @param {String/Array} els A string CSS selector, an array of elements or an element
|
||||
* @return {CompositeElement} this
|
||||
*/
|
||||
add : function(els){
|
||||
if(typeof els == "string"){
|
||||
this.addElements(Ext.Element.selectorFunction(els));
|
||||
}else if(els.length !== undefined){
|
||||
this.addElements(els);
|
||||
}else{
|
||||
this.addElements([els]);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
/**
|
||||
* Calls the passed function passing (el, this, index) for each element in this composite.
|
||||
* @param {Function} fn The function to call
|
||||
* @param {Object} scope (optional) The <i>this</i> object (defaults to the element)
|
||||
* @return {CompositeElement} this
|
||||
*/
|
||||
each : function(fn, scope){
|
||||
var els = this.elements;
|
||||
for(var i = 0, len = els.length; i < len; i++){
|
||||
if(fn.call(scope || els[i], els[i], this, i) === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the Element object at the specified index
|
||||
* @param {Number} index
|
||||
* @return {Ext.Element}
|
||||
*/
|
||||
item : function(index){
|
||||
return this.elements[index];
|
||||
}
|
||||
};
|
||||
(function(){
|
||||
Ext.CompositeElement.createCall = function(proto, fnName){
|
||||
if(!proto[fnName]){
|
||||
proto[fnName] = function(){
|
||||
return this.invoke(fnName, arguments);
|
||||
};
|
||||
}
|
||||
};
|
||||
for(var fnName in Ext.Element.prototype){
|
||||
if(typeof Ext.Element.prototype[fnName] == "function"){
|
||||
Ext.CompositeElement.createCall(Ext.CompositeElement.prototype, fnName);
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
/**
|
||||
* @class Ext.CompositeElementLite
|
||||
* @extends Ext.CompositeElement
|
||||
* Flyweight composite class. Reuses the same Ext.Element for element operations.
|
||||
* <br><br>
|
||||
* <b>NOTE: Although they are not listed, this class supports all of the set/update methods of Ext.Element. All Ext.Element
|
||||
* actions will be performed on all the elements in this collection.</b>
|
||||
*/
|
||||
Ext.CompositeElementLite = function(els){
|
||||
Ext.CompositeElementLite.superclass.constructor.call(this, els);
|
||||
var flyEl = function(){};
|
||||
flyEl.prototype = Ext.Element.prototype;
|
||||
this.el = new Ext.Element.Flyweight();
|
||||
};
|
||||
Ext.extend(Ext.CompositeElementLite, Ext.CompositeElement, {
|
||||
addElements : function(els){
|
||||
if(els){
|
||||
if(els instanceof Array){
|
||||
this.elements = this.elements.concat(els);
|
||||
}else{
|
||||
var yels = this.elements;
|
||||
var index = yels.length-1;
|
||||
for(var i = 0, len = els.length; i < len; i++) {
|
||||
yels[++index] = els[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
},
|
||||
invoke : function(fn, args){
|
||||
var els = this.elements;
|
||||
var el = this.el;
|
||||
for(var i = 0, len = els.length; i < len; i++) {
|
||||
el.dom = els[i];
|
||||
Ext.Element.prototype[fn].apply(el, args);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
/**
|
||||
* Returns a flyweight Element of the dom element object at the specified index
|
||||
* @param {Number} index
|
||||
* @return {Ext.Element}
|
||||
*/
|
||||
item : function(index){
|
||||
this.el.dom = this.elements[index];
|
||||
return this.el;
|
||||
},
|
||||
|
||||
// fixes scope with flyweight
|
||||
addListener : function(eventName, handler, scope, opt){
|
||||
var els = this.elements;
|
||||
for(var i = 0, len = els.length; i < len; i++) {
|
||||
Ext.EventManager.on(els[i], eventName, handler, scope || els[i], opt);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Calls the passed function passing (el, this, index) for each element in this composite. <b>The element
|
||||
* passed is the flyweight (shared) Ext.Element instance, so if you require a
|
||||
* a reference to the dom node, use el.dom.</b>
|
||||
* @param {Function} fn The function to call
|
||||
* @param {Object} scope (optional) The <i>this</i> object (defaults to the element)
|
||||
* @return {CompositeElement} this
|
||||
*/
|
||||
each : function(fn, scope){
|
||||
var els = this.elements;
|
||||
var el = this.el;
|
||||
for(var i = 0, len = els.length; i < len; i++){
|
||||
el.dom = els[i];
|
||||
if(fn.call(scope || el, el, this, i) === false){
|
||||
break;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
});
|
||||
Ext.CompositeElementLite.prototype.on = Ext.CompositeElementLite.prototype.addListener;
|
||||
if(Ext.DomQuery){
|
||||
Ext.Element.selectorFunction = Ext.DomQuery.select;
|
||||
}
|
||||
|
||||
Ext.Element.select = function(selector, unique){
|
||||
var els;
|
||||
if(typeof selector == "string"){
|
||||
els = Ext.Element.selectorFunction(selector);
|
||||
}else if(selector.length !== undefined){
|
||||
els = selector;
|
||||
}else{
|
||||
throw "Invalid selector";
|
||||
}
|
||||
if(unique === true){
|
||||
return new Ext.CompositeElement(els);
|
||||
}else{
|
||||
return new Ext.CompositeElementLite(els);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Selects elements based on the passed CSS selector to enable working on them as 1.
|
||||
* @param {String/Array} selector The CSS selector or an array of elements
|
||||
* @param {Boolean} unique (optional) true to create a unique Ext.Element for each element (defaults to a shared flyweight object)
|
||||
* @return {CompositeElementLite/CompositeElement}
|
||||
* @member Ext
|
||||
* @method select
|
||||
*/
|
||||
Ext.select = Ext.Element.select;
|
||||
395
www/extras/yui-ext/source/core/DomHelper.js
vendored
Normal file
395
www/extras/yui-ext/source/core/DomHelper.js
vendored
Normal file
|
|
@ -0,0 +1,395 @@
|
|||
/*
|
||||
* Ext JS Library 1.0.1
|
||||
* Copyright(c) 2006-2007, Ext JS, LLC.
|
||||
* licensing@extjs.com
|
||||
*
|
||||
* http://www.extjs.com/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Ext.DomHelper
|
||||
* Utility class for working with DOM and/or Templates. It transparently supports using HTML fragments or DOM.
|
||||
* For more information see <a href="http://www.jackslocum.com/yui/2006/10/06/domhelper-create-elements-using-dom-html-fragments-or-templates/">this blog post with examples</a>.
|
||||
* @singleton
|
||||
*/
|
||||
Ext.DomHelper = function(){
|
||||
var tempTableEl = null;
|
||||
var emptyTags = /^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i;
|
||||
|
||||
// build as innerHTML where available
|
||||
/** @ignore */
|
||||
var createHtml = function(o){
|
||||
if(typeof o == 'string'){
|
||||
return o;
|
||||
}
|
||||
var b = "";
|
||||
if(!o.tag){
|
||||
o.tag = "div";
|
||||
}
|
||||
b += "<" + o.tag;
|
||||
for(var attr in o){
|
||||
if(attr == "tag" || attr == "children" || attr == "cn" || attr == "html" || typeof o[attr] == "function") continue;
|
||||
if(attr == "style"){
|
||||
var s = o["style"];
|
||||
if(typeof s == "function"){
|
||||
s = s.call();
|
||||
}
|
||||
if(typeof s == "string"){
|
||||
b += ' style="' + s + '"';
|
||||
}else if(typeof s == "object"){
|
||||
b += ' style="';
|
||||
for(var key in s){
|
||||
if(typeof s[key] != "function"){
|
||||
b += key + ":" + s[key] + ";";
|
||||
}
|
||||
}
|
||||
b += '"';
|
||||
}
|
||||
}else{
|
||||
if(attr == "cls"){
|
||||
b += ' class="' + o["cls"] + '"';
|
||||
}else if(attr == "htmlFor"){
|
||||
b += ' for="' + o["htmlFor"] + '"';
|
||||
}else{
|
||||
b += " " + attr + '="' + o[attr] + '"';
|
||||
}
|
||||
}
|
||||
}
|
||||
if(emptyTags.test(o.tag)){
|
||||
b += "/>";
|
||||
}else{
|
||||
b += ">";
|
||||
var cn = o.children || o.cn;
|
||||
if(cn){
|
||||
if(cn instanceof Array){
|
||||
for(var i = 0, len = cn.length; i < len; i++) {
|
||||
b += createHtml(cn[i], b);
|
||||
}
|
||||
}else{
|
||||
b += createHtml(cn, b);
|
||||
}
|
||||
}
|
||||
if(o.html){
|
||||
b += o.html;
|
||||
}
|
||||
b += "</" + o.tag + ">";
|
||||
}
|
||||
return b;
|
||||
};
|
||||
|
||||
// build as dom
|
||||
/** @ignore */
|
||||
var createDom = function(o, parentNode){
|
||||
var el = document.createElement(o.tag);
|
||||
var useSet = el.setAttribute ? true : false; // In IE some elements don't have setAttribute
|
||||
for(var attr in o){
|
||||
if(attr == "tag" || attr == "children" || attr == "cn" || attr == "html" || attr == "style" || typeof o[attr] == "function") continue;
|
||||
if(attr=="cls"){
|
||||
el.className = o["cls"];
|
||||
}else{
|
||||
if(useSet) el.setAttribute(attr, o[attr]);
|
||||
else el[attr] = o[attr];
|
||||
}
|
||||
}
|
||||
Ext.DomHelper.applyStyles(el, o.style);
|
||||
var cn = o.children || o.cn;
|
||||
if(cn){
|
||||
if(cn instanceof Array){
|
||||
for(var i = 0, len = cn.length; i < len; i++) {
|
||||
createDom(cn[i], el);
|
||||
}
|
||||
}else{
|
||||
createDom(cn, el);
|
||||
}
|
||||
}
|
||||
if(o.html){
|
||||
el.innerHTML = o.html;
|
||||
}
|
||||
if(parentNode){
|
||||
parentNode.appendChild(el);
|
||||
}
|
||||
return el;
|
||||
};
|
||||
|
||||
var ieTable = function(depth, s, h, e){
|
||||
tempTableEl.innerHTML = [s, h, e].join('');
|
||||
var i = -1, el = tempTableEl;
|
||||
while(++i < depth){
|
||||
el = el.firstChild;
|
||||
}
|
||||
return el;
|
||||
};
|
||||
|
||||
// kill repeat to save bytes
|
||||
var ts = '<table>',
|
||||
te = '</table>',
|
||||
tbs = ts+'<tbody>',
|
||||
tbe = '</tbody>'+te,
|
||||
trs = tbs + '<tr>',
|
||||
tre = '</tr>'+tbe;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
* Nasty code for IE's broken table implementation
|
||||
*/
|
||||
var insertIntoTable = function(tag, where, el, html){
|
||||
if(!tempTableEl){
|
||||
tempTableEl = document.createElement('div');
|
||||
}
|
||||
var node;
|
||||
var before = null;
|
||||
if(tag == 'td'){
|
||||
if(where == 'afterbegin' || where == 'beforeend'){ // INTO a TD
|
||||
return;
|
||||
}
|
||||
if(where == 'beforebegin'){
|
||||
before = el;
|
||||
el = el.parentNode;
|
||||
} else{
|
||||
before = el.nextSibling;
|
||||
el = el.parentNode;
|
||||
}
|
||||
node = ieTable(4, trs, html, tre);
|
||||
}
|
||||
else if(tag == 'tr'){
|
||||
if(where == 'beforebegin'){
|
||||
before = el;
|
||||
el = el.parentNode;
|
||||
node = ieTable(3, tbs, html, tbe);
|
||||
} else if(where == 'afterend'){
|
||||
before = el.nextSibling;
|
||||
el = el.parentNode;
|
||||
node = ieTable(3, tbs, html, tbe);
|
||||
} else{ // INTO a TR
|
||||
if(where == 'afterbegin'){
|
||||
before = el.firstChild;
|
||||
}
|
||||
node = ieTable(4, trs, html, tre);
|
||||
}
|
||||
} else if(tag == 'tbody'){
|
||||
if(where == 'beforebegin'){
|
||||
before = el;
|
||||
el = el.parentNode;
|
||||
node = ieTable(2, ts, html, te);
|
||||
} else if(where == 'afterend'){
|
||||
before = el.nextSibling;
|
||||
el = el.parentNode;
|
||||
node = ieTable(2, ts, html, te);
|
||||
} else{
|
||||
if(where == 'afterbegin'){
|
||||
before = el.firstChild;
|
||||
}
|
||||
node = ieTable(3, tbs, html, tbe);
|
||||
}
|
||||
} else{ // TABLE
|
||||
if(where == 'beforebegin' || where == 'afterend'){ // OUTSIDE the table
|
||||
return;
|
||||
}
|
||||
if(where == 'afterbegin'){
|
||||
before = el.firstChild;
|
||||
}
|
||||
node = ieTable(2, ts, html, te);
|
||||
}
|
||||
el.insertBefore(node, before);
|
||||
return node;
|
||||
};
|
||||
|
||||
return {
|
||||
/** True to force the use of DOM instead of html fragments @type Boolean */
|
||||
useDom : false,
|
||||
|
||||
/**
|
||||
* Returns the markup for the passed Element(s) config
|
||||
* @param {Object} o The Dom object spec (and children)
|
||||
* @return {String}
|
||||
*/
|
||||
markup : function(o){
|
||||
return createHtml(o);
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies a style specification to an element
|
||||
* @param {String/HTMLElement} el The element to apply styles to
|
||||
* @param {String/Object/Function} styles A style specification string eg "width:100px", or object in the form {width:"100px"}, or
|
||||
* a function which returns such a specification.
|
||||
*/
|
||||
applyStyles : function(el, styles){
|
||||
if(styles){
|
||||
el = Ext.fly(el);
|
||||
if(typeof styles == "string"){
|
||||
var re = /\s?([a-z\-]*)\:\s?([^;]*);?/gi;
|
||||
var matches;
|
||||
while ((matches = re.exec(styles)) != null){
|
||||
el.setStyle(matches[1], matches[2]);
|
||||
}
|
||||
}else if (typeof styles == "object"){
|
||||
for (var style in styles){
|
||||
el.setStyle(style, styles[style]);
|
||||
}
|
||||
}else if (typeof styles == "function"){
|
||||
Ext.DomHelper.applyStyles(el, styles.call());
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Inserts an HTML fragment into the Dom
|
||||
* @param {String} where Where to insert the html in relation to el - beforeBegin, afterBegin, beforeEnd, afterEnd.
|
||||
* @param {HTMLElement} el The context element
|
||||
* @param {String} html The HTML fragmenet
|
||||
* @return {HTMLElement} The new node
|
||||
*/
|
||||
insertHtml : function(where, el, html){
|
||||
where = where.toLowerCase();
|
||||
if(el.insertAdjacentHTML){
|
||||
var tag = el.tagName.toLowerCase();
|
||||
if(tag == "table" || tag == "tbody" || tag == "tr" || tag == 'td'){
|
||||
var rs;
|
||||
if(rs = insertIntoTable(tag, where, el, html)){
|
||||
return rs;
|
||||
}
|
||||
}
|
||||
switch(where){
|
||||
case "beforebegin":
|
||||
el.insertAdjacentHTML(where, html);
|
||||
return el.previousSibling;
|
||||
case "afterbegin":
|
||||
el.insertAdjacentHTML(where, html);
|
||||
return el.firstChild;
|
||||
case "beforeend":
|
||||
el.insertAdjacentHTML(where, html);
|
||||
return el.lastChild;
|
||||
case "afterend":
|
||||
el.insertAdjacentHTML(where, html);
|
||||
return el.nextSibling;
|
||||
}
|
||||
throw 'Illegal insertion point -> "' + where + '"';
|
||||
}
|
||||
var range = el.ownerDocument.createRange();
|
||||
var frag;
|
||||
switch(where){
|
||||
case "beforebegin":
|
||||
range.setStartBefore(el);
|
||||
frag = range.createContextualFragment(html);
|
||||
el.parentNode.insertBefore(frag, el);
|
||||
return el.previousSibling;
|
||||
case "afterbegin":
|
||||
if(el.firstChild){
|
||||
range.setStartBefore(el.firstChild);
|
||||
frag = range.createContextualFragment(html);
|
||||
el.insertBefore(frag, el.firstChild);
|
||||
return el.firstChild;
|
||||
}else{
|
||||
el.innerHTML = html;
|
||||
return el.firstChild;
|
||||
}
|
||||
case "beforeend":
|
||||
if(el.lastChild){
|
||||
range.setStartAfter(el.lastChild);
|
||||
frag = range.createContextualFragment(html);
|
||||
el.appendChild(frag);
|
||||
return el.lastChild;
|
||||
}else{
|
||||
el.innerHTML = html;
|
||||
return el.lastChild;
|
||||
}
|
||||
case "afterend":
|
||||
range.setStartAfter(el);
|
||||
frag = range.createContextualFragment(html);
|
||||
el.parentNode.insertBefore(frag, el.nextSibling);
|
||||
return el.nextSibling;
|
||||
}
|
||||
throw 'Illegal insertion point -> "' + where + '"';
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates new Dom element(s) and inserts them before el
|
||||
* @param {String/HTMLElement/Element} el The context element
|
||||
* @param {Object} o The Dom object spec (and children)
|
||||
* @param {Boolean} returnElement (optional) true to return a Ext.Element
|
||||
* @return {HTMLElement} The new node
|
||||
*/
|
||||
insertBefore : function(el, o, returnElement){
|
||||
return this.doInsert(el, o, returnElement, "beforeBegin");
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates new Dom element(s) and inserts them after el
|
||||
* @param {String/HTMLElement/Element} el The context element
|
||||
* @param {Object} o The Dom object spec (and children)
|
||||
* @param {Boolean} returnElement (optional) true to return a Ext.Element
|
||||
* @return {HTMLElement} The new node
|
||||
*/
|
||||
insertAfter : function(el, o, returnElement){
|
||||
return this.doInsert(el, o, returnElement, "afterEnd", "nextSibling");
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates new Dom element(s) and inserts them as the first child of el
|
||||
* @param {String/HTMLElement/Element} el The context element
|
||||
* @param {Object} o The Dom object spec (and children)
|
||||
* @param {Boolean} returnElement (optional) true to return a Ext.Element
|
||||
* @return {HTMLElement} The new node
|
||||
*/
|
||||
insertFirst : function(el, o, returnElement){
|
||||
return this.doInsert(el, o, returnElement, "afterBegin");
|
||||
},
|
||||
|
||||
// private
|
||||
doInsert : function(el, o, returnElement, pos, sibling){
|
||||
el = Ext.getDom(el);
|
||||
var newNode;
|
||||
if(this.useDom){
|
||||
newNode = createDom(o, null);
|
||||
el.parentNode.insertBefore(newNode, sibling ? el[sibling] : el);
|
||||
}else{
|
||||
var html = createHtml(o);
|
||||
newNode = this.insertHtml(pos, el, html);
|
||||
}
|
||||
return returnElement ? Ext.get(newNode, true) : newNode;
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates new Dom element(s) and appends them to el
|
||||
* @param {String/HTMLElement/Element} el The context element
|
||||
* @param {Object} o The Dom object spec (and children)
|
||||
* @param {Boolean} returnElement (optional) true to return a Ext.Element
|
||||
* @return {HTMLElement} The new node
|
||||
*/
|
||||
append : function(el, o, returnElement){
|
||||
el = Ext.getDom(el);
|
||||
var newNode;
|
||||
if(this.useDom){
|
||||
newNode = createDom(o, null);
|
||||
el.appendChild(newNode);
|
||||
}else{
|
||||
var html = createHtml(o);
|
||||
newNode = this.insertHtml("beforeEnd", el, html);
|
||||
}
|
||||
return returnElement ? Ext.get(newNode, true) : newNode;
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates new Dom element(s) and overwrites the contents of el with them
|
||||
* @param {String/HTMLElement/Element} el The context element
|
||||
* @param {Object} o The Dom object spec (and children)
|
||||
* @param {Boolean} returnElement (optional) true to return a Ext.Element
|
||||
* @return {HTMLElement} The new node
|
||||
*/
|
||||
overwrite : function(el, o, returnElement){
|
||||
el = Ext.getDom(el);
|
||||
el.innerHTML = createHtml(o);
|
||||
return returnElement ? Ext.get(el.firstChild, true) : el.firstChild;
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a new Ext.DomHelper.Template from the Dom object spec
|
||||
* @param {Object} o The Dom object spec (and children)
|
||||
* @return {Ext.DomHelper.Template} The new template
|
||||
*/
|
||||
createTemplate : function(o){
|
||||
var html = createHtml(o);
|
||||
return new Ext.Template(html);
|
||||
}
|
||||
};
|
||||
}();
|
||||
715
www/extras/yui-ext/source/core/DomQuery.js
vendored
Normal file
715
www/extras/yui-ext/source/core/DomQuery.js
vendored
Normal file
|
|
@ -0,0 +1,715 @@
|
|||
/*
|
||||
* Ext JS Library 1.0.1
|
||||
* Copyright(c) 2006-2007, Ext JS, LLC.
|
||||
* licensing@extjs.com
|
||||
*
|
||||
* http://www.extjs.com/license
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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).
|
||||
* @singleton
|
||||
*/
|
||||
Ext.DomQuery = function(){
|
||||
var cache = {}, simpleCache = {}, valueCache = {};
|
||||
var nonSpace = /\S/;
|
||||
var trimRe = /^\s+|\s+$/g;
|
||||
var tplRe = /\{(\d+)\}/g;
|
||||
var modeRe = /^(\s?[\/>]\s?|\s|$)/;
|
||||
var tagTokenRe = /^(#)?([\w-\*]+)/;
|
||||
|
||||
function child(p, index){
|
||||
var i = 0;
|
||||
var n = p.firstChild;
|
||||
while(n){
|
||||
if(n.nodeType == 1){
|
||||
if(++i == index){
|
||||
return n;
|
||||
}
|
||||
}
|
||||
n = n.nextSibling;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
function next(n){
|
||||
while((n = n.nextSibling) && n.nodeType != 1);
|
||||
return n;
|
||||
};
|
||||
|
||||
function prev(n){
|
||||
while((n = n.previousSibling) && n.nodeType != 1);
|
||||
return n;
|
||||
};
|
||||
|
||||
function clean(d){
|
||||
var n = d.firstChild, ni = -1;
|
||||
while(n){
|
||||
var nx = n.nextSibling;
|
||||
if(n.nodeType == 3 && !nonSpace.test(n.nodeValue)){
|
||||
d.removeChild(n);
|
||||
}else{
|
||||
n.nodeIndex = ++ni;
|
||||
}
|
||||
n = nx;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
function byClassName(c, a, v, re, cn){
|
||||
if(!v){
|
||||
return c;
|
||||
}
|
||||
var r = [];
|
||||
for(var i = 0, ci; ci = c[i]; i++){
|
||||
cn = ci.className;
|
||||
if(cn && (' '+cn+' ').indexOf(v) != -1){
|
||||
r[r.length] = ci;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
};
|
||||
|
||||
function attrValue(n, attr){
|
||||
if(!n.tagName && typeof n.length != "undefined"){
|
||||
n = n[0];
|
||||
}
|
||||
if(!n){
|
||||
return null;
|
||||
}
|
||||
if(attr == "for"){
|
||||
return n.htmlFor;
|
||||
}
|
||||
if(attr == "class" || attr == "className"){
|
||||
return n.className;
|
||||
}
|
||||
return n.getAttribute(attr) || n[attr];
|
||||
|
||||
};
|
||||
|
||||
function getNodes(ns, mode, tagName){
|
||||
var result = [], cs;
|
||||
if(!ns){
|
||||
return result;
|
||||
}
|
||||
mode = mode ? mode.replace(trimRe, "") : "";
|
||||
tagName = tagName || "*";
|
||||
if(typeof ns.getElementsByTagName != "undefined"){
|
||||
ns = [ns];
|
||||
}
|
||||
if(mode != "/" && mode != ">"){
|
||||
for(var i = 0, ni; ni = ns[i]; i++){
|
||||
cs = ni.getElementsByTagName(tagName);
|
||||
for(var j = 0, ci; ci = cs[j]; j++){
|
||||
result[result.length] = ci;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
for(var i = 0, ni; ni = ns[i]; i++){
|
||||
var cn = ni.getElementsByTagName(tagName);
|
||||
for(var j = 0, cj; cj = cn[j]; j++){
|
||||
if(cj.parentNode == ni){
|
||||
result[result.length] = cj;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
function concat(a, b){
|
||||
if(b.slice){
|
||||
return a.concat(b);
|
||||
}
|
||||
for(var i = 0, l = b.length; i < l; i++){
|
||||
a[a.length] = b[i];
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
function byTag(cs, tagName){
|
||||
if(cs.tagName || cs == document){
|
||||
cs = [cs];
|
||||
}
|
||||
if(!tagName){
|
||||
return cs;
|
||||
}
|
||||
var r = []; tagName = tagName.toLowerCase();
|
||||
for(var i = 0, ci; ci = cs[i]; i++){
|
||||
if(ci.nodeType == 1 && ci.tagName.toLowerCase()==tagName){
|
||||
r[r.length] = ci;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
};
|
||||
|
||||
function byId(cs, attr, id){
|
||||
if(cs.tagName || cs == document){
|
||||
cs = [cs];
|
||||
}
|
||||
if(!id){
|
||||
return cs;
|
||||
}
|
||||
var r = [];
|
||||
for(var i = 0,ci; ci = cs[i]; i++){
|
||||
if(ci && ci.id == id){
|
||||
r[r.length] = ci;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
};
|
||||
|
||||
function byAttribute(cs, attr, value, op, custom){
|
||||
var r = [], st = custom=="{";
|
||||
var f = Ext.DomQuery.operators[op];
|
||||
for(var i = 0; ci = cs[i]; i++){
|
||||
var a;
|
||||
if(st){
|
||||
a = Ext.DomQuery.getStyle(ci, attr);
|
||||
}
|
||||
else if(attr == "class" || attr == "className"){
|
||||
a = ci.className;
|
||||
}else if(attr == "for"){
|
||||
a = ci.htmlFor;
|
||||
}else if(attr == "href"){
|
||||
a = ci.getAttribute("href", 2);
|
||||
}else{
|
||||
a = ci.getAttribute(attr);
|
||||
}
|
||||
if((f && f(a, value)) || (!f && a)){
|
||||
r[r.length] = ci;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
};
|
||||
|
||||
function byPseudo(cs, name, value){
|
||||
return Ext.DomQuery.pseudos[name](cs, value);
|
||||
};
|
||||
|
||||
// This is for IE MSXML which does not support expandos.
|
||||
// IE runs the same speed using setAttribute, however FF slows way down
|
||||
// and Safari completely fails so they need to continue to use expandos.
|
||||
var isIE = window.ActiveXObject ? true : false;
|
||||
|
||||
var key = 30803;
|
||||
|
||||
function nodupIEXml(cs){
|
||||
var d = ++key;
|
||||
cs[0].setAttribute("_nodup", d);
|
||||
var r = [cs[0]];
|
||||
for(var i = 1, len = cs.length; i < len; i++){
|
||||
var c = cs[i];
|
||||
if(!c.getAttribute("_nodup") != d){
|
||||
c.setAttribute("_nodup", d);
|
||||
r[r.length] = c;
|
||||
}
|
||||
}
|
||||
for(var i = 0, len = cs.length; i < len; i++){
|
||||
cs[i].removeAttribute("_nodup");
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
function nodup(cs){
|
||||
if(!cs){
|
||||
return [];
|
||||
}
|
||||
var len = cs.length, c, i, r = cs, cj;
|
||||
if(!len || typeof cs.nodeType != "undefined" || len == 1){
|
||||
return cs;
|
||||
}
|
||||
if(isIE && typeof cs[0].selectSingleNode != "undefined"){
|
||||
return nodupIEXml(cs);
|
||||
}
|
||||
var d = ++key;
|
||||
cs[0]._nodup = d;
|
||||
for(i = 1; c = cs[i]; i++){
|
||||
if(c._nodup != d){
|
||||
c._nodup = d;
|
||||
}else{
|
||||
r = [];
|
||||
for(var j = 0; j < i; j++){
|
||||
r[r.length] = cs[j];
|
||||
}
|
||||
for(j = i+1; cj = cs[j]; j++){
|
||||
if(cj._nodup != d){
|
||||
cj._nodup = d;
|
||||
r[r.length] = cj;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
function quickDiffIEXml(c1, c2){
|
||||
var d = ++key;
|
||||
for(var i = 0, len = c1.length; i < len; i++){
|
||||
c1[i].setAttribute("_qdiff", d);
|
||||
}
|
||||
var r = [];
|
||||
for(var i = 0, len = c2.length; i < len; i++){
|
||||
if(c2[i].getAttribute("_qdiff") != d){
|
||||
r[r.length] = c2[i];
|
||||
}
|
||||
}
|
||||
for(var i = 0, len = c1.length; i < len; i++){
|
||||
c1[i].removeAttribute("_qdiff");
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
function quickDiff(c1, c2){
|
||||
var len1 = c1.length;
|
||||
if(!len1){
|
||||
return c2;
|
||||
}
|
||||
if(isIE && c1[0].selectSingleNode){
|
||||
return quickDiffIEXml(c1, c2);
|
||||
}
|
||||
var d = ++key;
|
||||
for(var i = 0; i < len1; i++){
|
||||
c1[i]._qdiff = d;
|
||||
}
|
||||
var r = [];
|
||||
for(var i = 0, len = c2.length; i < len; i++){
|
||||
if(c2[i]._qdiff != d){
|
||||
r[r.length] = c2[i];
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
function quickId(ns, mode, root, id){
|
||||
if(ns == root){
|
||||
var d = root.ownerDocument || root;
|
||||
return d.getElementById(id);
|
||||
}
|
||||
ns = getNodes(ns, mode, "*");
|
||||
return byId(ns, null, id);
|
||||
}
|
||||
|
||||
return {
|
||||
getStyle : function(el, name){
|
||||
return Ext.fly(el).getStyle(name);
|
||||
},
|
||||
/**
|
||||
* Compiles a selector/xpath query into a reusable function. The returned function
|
||||
* takes one parameter "root" (optional), which is the context node from where the query should start.
|
||||
* @param {String} selector The selector/xpath query
|
||||
* @param {String} type (optional) Either "select" (the default) or "simple" for a simple selector match
|
||||
* @return {Function}
|
||||
*/
|
||||
compile : function(path, type){
|
||||
// strip leading slashes
|
||||
while(path.substr(0, 1)=="/"){
|
||||
path = path.substr(1);
|
||||
}
|
||||
type = type || "select";
|
||||
|
||||
var fn = ["var f = function(root){\n var mode; var n = root || document;\n"];
|
||||
var q = path, mode, lq;
|
||||
var tk = Ext.DomQuery.matchers;
|
||||
var tklen = tk.length;
|
||||
var mm;
|
||||
while(q && lq != q){
|
||||
lq = q;
|
||||
var tm = q.match(tagTokenRe);
|
||||
if(type == "select"){
|
||||
if(tm){
|
||||
if(tm[1] == "#"){
|
||||
fn[fn.length] = 'n = quickId(n, mode, root, "'+tm[2]+'");';
|
||||
}else{
|
||||
fn[fn.length] = 'n = getNodes(n, mode, "'+tm[2]+'");';
|
||||
}
|
||||
q = q.replace(tm[0], "");
|
||||
}else if(q.substr(0, 1) != '@'){
|
||||
fn[fn.length] = 'n = getNodes(n, mode, "*");';
|
||||
}
|
||||
}else{
|
||||
if(tm){
|
||||
if(tm[1] == "#"){
|
||||
fn[fn.length] = 'n = byId(n, null, "'+tm[2]+'");';
|
||||
}else{
|
||||
fn[fn.length] = 'n = byTag(n, "'+tm[2]+'");';
|
||||
}
|
||||
q = q.replace(tm[0], "");
|
||||
}
|
||||
}
|
||||
while(!(mm = q.match(modeRe))){
|
||||
var matched = false;
|
||||
for(var j = 0; j < tklen; j++){
|
||||
var t = tk[j];
|
||||
var m = q.match(t.re);
|
||||
if(m){
|
||||
fn[fn.length] = t.select.replace(tplRe, function(x, i){
|
||||
return m[i];
|
||||
});
|
||||
q = q.replace(m[0], "");
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// prevent infinite loop on bad selector
|
||||
if(!matched){
|
||||
throw 'Error parsing selector, parsing failed at "' + q + '"';
|
||||
}
|
||||
}
|
||||
if(mm[1]){
|
||||
fn[fn.length] = 'mode="'+mm[1]+'";';
|
||||
q = q.replace(mm[1], "");
|
||||
}
|
||||
}
|
||||
fn[fn.length] = "return nodup(n);\n}";
|
||||
eval(fn.join(""));
|
||||
return f;
|
||||
},
|
||||
|
||||
/**
|
||||
* Selects a group of elements.
|
||||
* @param {String} selector The selector/xpath query
|
||||
* @param {Node} root (optional) The start of the query (defaults to document).
|
||||
* @return {Array}
|
||||
*/
|
||||
select : function(path, root, type){
|
||||
if(!root || root == document){
|
||||
root = document;
|
||||
}
|
||||
if(typeof root == "string"){
|
||||
root = document.getElementById(root);
|
||||
}
|
||||
var paths = path.split(",");
|
||||
var results = [];
|
||||
for(var i = 0, len = paths.length; i < len; i++){
|
||||
var p = paths[i].replace(trimRe, "");
|
||||
if(!cache[p]){
|
||||
cache[p] = Ext.DomQuery.compile(p);
|
||||
if(!cache[p]){
|
||||
throw p + " is not a valid selector";
|
||||
}
|
||||
}
|
||||
var result = cache[p](root);
|
||||
if(result && result != document){
|
||||
results = results.concat(result);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
},
|
||||
|
||||
/**
|
||||
* Selects a single element.
|
||||
* @param {String} selector The selector/xpath query
|
||||
* @param {Node} root (optional) The start of the query (defaults to document).
|
||||
* @return {Element}
|
||||
*/
|
||||
selectNode : function(path, root){
|
||||
return Ext.DomQuery.select(path, root)[0];
|
||||
},
|
||||
|
||||
/**
|
||||
* Selects the value of a node, optionally replacing null with the defaultValue.
|
||||
* @param {String} selector The selector/xpath query
|
||||
* @param {Node} root (optional) The start of the query (defaults to document).
|
||||
* @param {String} defaultValue
|
||||
*/
|
||||
selectValue : function(path, root, defaultValue){
|
||||
path = path.replace(trimRe, "");
|
||||
if(!valueCache[path]){
|
||||
valueCache[path] = Ext.DomQuery.compile(path, "select");
|
||||
}
|
||||
var n = valueCache[path](root);
|
||||
n = n[0] ? n[0] : n;
|
||||
var v = (n && n.firstChild ? n.firstChild.nodeValue : null);
|
||||
return (v === null ? defaultValue : v);
|
||||
},
|
||||
|
||||
/**
|
||||
* Selects the value of a node, parsing integers and floats.
|
||||
* @param {String} selector The selector/xpath query
|
||||
* @param {Node} root (optional) The start of the query (defaults to document).
|
||||
* @param {Number} defaultValue
|
||||
* @return {Number}
|
||||
*/
|
||||
selectNumber : function(path, root, defaultValue){
|
||||
var v = Ext.DomQuery.selectValue(path, root, defaultValue || 0);
|
||||
return parseFloat(v);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns true if the passed element(s) match the passed simple selector (e.g. div.some-class or span:first-child)
|
||||
* @param {String/HTMLElement/Array} el An element id, element or array of elements
|
||||
* @param {String} selector The simple selector to test
|
||||
* @return {Boolean}
|
||||
*/
|
||||
is : function(el, ss){
|
||||
if(typeof el == "string"){
|
||||
el = document.getElementById(el);
|
||||
}
|
||||
var isArray = (el instanceof Array);
|
||||
var result = Ext.DomQuery.filter(isArray ? el : [el], ss);
|
||||
return isArray ? (result.length == el.length) : (result.length > 0);
|
||||
},
|
||||
|
||||
/**
|
||||
* Filters an array of elements to only include matches of a simple selector (e.g. div.some-class or span:first-child)
|
||||
* @param {Array} el An array of elements to filter
|
||||
* @param {String} selector The simple selector to test
|
||||
* @param {Boolean} nonMatches If true, it returns the elements that DON'T match
|
||||
* the selector instead of the ones that match
|
||||
* @return {Array}
|
||||
*/
|
||||
filter : function(els, ss, nonMatches){
|
||||
ss = ss.replace(trimRe, "");
|
||||
if(!simpleCache[ss]){
|
||||
simpleCache[ss] = Ext.DomQuery.compile(ss, "simple");
|
||||
}
|
||||
var result = simpleCache[ss](els);
|
||||
return nonMatches ? quickDiff(result, els) : result;
|
||||
},
|
||||
|
||||
/**
|
||||
* Collection of matching regular expressions and code snippets.
|
||||
*/
|
||||
matchers : [{
|
||||
re: /^\.([\w-]+)/,
|
||||
select: 'n = byClassName(n, null, " {1} ");'
|
||||
}, {
|
||||
re: /^\:([\w-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/,
|
||||
select: 'n = byPseudo(n, "{1}", "{2}");'
|
||||
},{
|
||||
re: /^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,
|
||||
select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
|
||||
}, {
|
||||
re: /^#([\w-]+)/,
|
||||
select: 'n = byId(n, null, "{1}");'
|
||||
},{
|
||||
re: /^@([\w-]+)/,
|
||||
select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};'
|
||||
}
|
||||
],
|
||||
|
||||
/**
|
||||
* Collection of operator comparison functions. The default operators are =, !=, ^=, $=, *= and %=.
|
||||
* New operators can be added as long as the match the format <i>c</i>= where <i>c<i> is any character other than space, > <.
|
||||
*/
|
||||
operators : {
|
||||
"=" : function(a, v){
|
||||
return a == v;
|
||||
},
|
||||
"!=" : function(a, v){
|
||||
return a != v;
|
||||
},
|
||||
"^=" : function(a, v){
|
||||
return a && a.substr(0, v.length) == v;
|
||||
},
|
||||
"$=" : function(a, v){
|
||||
return a && a.substr(a.length-v.length) == v;
|
||||
},
|
||||
"*=" : function(a, v){
|
||||
return a && a.indexOf(v) !== -1;
|
||||
},
|
||||
"%=" : function(a, v){
|
||||
return (a % v) == 0;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Collection of "pseudo class" processors. Each processor is passed the current nodeset (array)
|
||||
* and the argument (if any) supplied in the selector.
|
||||
*/
|
||||
pseudos : {
|
||||
"first-child" : function(c){
|
||||
var r = [], n;
|
||||
for(var i = 0, ci; ci = n = c[i]; i++){
|
||||
while((n = n.previousSibling) && n.nodeType != 1);
|
||||
if(!n){
|
||||
r[r.length] = ci;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
},
|
||||
|
||||
"last-child" : function(c){
|
||||
var r = [];
|
||||
for(var i = 0, ci; ci = n = c[i]; i++){
|
||||
while((n = n.nextSibling) && n.nodeType != 1);
|
||||
if(!n){
|
||||
r[r.length] = ci;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
},
|
||||
|
||||
"nth-child" : function(c, a){
|
||||
var r = [];
|
||||
if(a != "odd" && a != "even"){
|
||||
for(var i = 0, ci; ci = c[i]; i++){
|
||||
var m = child(ci.parentNode, a);
|
||||
if(m == ci){
|
||||
r[r.length] = m;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
var p;
|
||||
// first let's clean up the parent nodes
|
||||
for(var i = 0, l = c.length; i < l; i++){
|
||||
var cp = c[i].parentNode;
|
||||
if(cp != p){
|
||||
clean(cp);
|
||||
p = cp;
|
||||
}
|
||||
}
|
||||
// then lets see if we match
|
||||
for(var i = 0, ci; ci = c[i]; i++){
|
||||
var m = false;
|
||||
if(a == "odd"){
|
||||
m = ((ci.nodeIndex+1) % 2 == 1);
|
||||
}else if(a == "even"){
|
||||
m = ((ci.nodeIndex+1) % 2 == 0);
|
||||
}
|
||||
if(m){
|
||||
r[r.length] = ci;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
},
|
||||
|
||||
"only-child" : function(c){
|
||||
var r = [];
|
||||
for(var i = 0, ci; ci = c[i]; i++){
|
||||
if(!prev(ci) && !next(ci)){
|
||||
r[r.length] = ci;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
},
|
||||
|
||||
"empty" : function(c){
|
||||
var r = [];
|
||||
for(var i = 0, ci; ci = c[i]; i++){
|
||||
var cns = ci.childNodes, j = 0, cn, empty = true;
|
||||
while(cn = cns[j]){
|
||||
++j;
|
||||
if(cn.nodeType == 1 || cn.nodeType == 3){
|
||||
empty = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(empty){
|
||||
r[r.length] = ci;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
},
|
||||
|
||||
"contains" : function(c, v){
|
||||
var r = [];
|
||||
for(var i = 0, ci; ci = c[i]; i++){
|
||||
if(ci.innerHTML.indexOf(v) !== -1){
|
||||
r[r.length] = ci;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
},
|
||||
|
||||
"nodeValue" : function(c, v){
|
||||
var r = [];
|
||||
for(var i = 0, ci; ci = c[i]; i++){
|
||||
if(ci.firstChild && ci.firstChild.nodeValue == v){
|
||||
r[r.length] = ci;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
},
|
||||
|
||||
"checked" : function(c){
|
||||
var r = [];
|
||||
for(var i = 0, ci; ci = c[i]; i++){
|
||||
if(ci.checked == true){
|
||||
r[r.length] = ci;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
},
|
||||
|
||||
"not" : function(c, ss){
|
||||
return Ext.DomQuery.filter(c, ss, true);
|
||||
},
|
||||
|
||||
"odd" : function(c){
|
||||
return this["nth-child"](c, "odd");
|
||||
},
|
||||
|
||||
"even" : function(c){
|
||||
return this["nth-child"](c, "even");
|
||||
},
|
||||
|
||||
"nth" : function(c, a){
|
||||
return c[a-1] || [];
|
||||
},
|
||||
|
||||
"first" : function(c){
|
||||
return c[0] || [];
|
||||
},
|
||||
|
||||
"last" : function(c){
|
||||
return c[c.length-1] || [];
|
||||
},
|
||||
|
||||
"has" : function(c, ss){
|
||||
var s = Ext.DomQuery.select;
|
||||
var r = [];
|
||||
for(var i = 0, ci; ci = c[i]; i++){
|
||||
if(s(ss, ci).length > 0){
|
||||
r[r.length] = ci;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
},
|
||||
|
||||
"next" : function(c, ss){
|
||||
var is = Ext.DomQuery.is;
|
||||
var r = [];
|
||||
for(var i = 0, ci; ci = c[i]; i++){
|
||||
var n = next(ci);
|
||||
if(n && is(n, ss)){
|
||||
r[r.length] = ci;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
},
|
||||
|
||||
"prev" : function(c, ss){
|
||||
var is = Ext.DomQuery.is;
|
||||
var r = [];
|
||||
for(var i = 0, ci; ci = c[i]; i++){
|
||||
var n = prev(ci);
|
||||
if(n && is(n, ss)){
|
||||
r[r.length] = ci;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
/**
|
||||
* Selects an array of DOM nodes by CSS/XPath selector. Shorthand of {@link Ext.DomQuery#select}
|
||||
* @param {String} path The selector/xpath query
|
||||
* @param {Node} root (optional) The start of the query (defaults to document).
|
||||
* @return {Array}
|
||||
* @member Ext
|
||||
* @method query
|
||||
*/
|
||||
Ext.query = Ext.DomQuery.select;
|
||||
2806
www/extras/yui-ext/source/core/Element.js
vendored
Normal file
2806
www/extras/yui-ext/source/core/Element.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
662
www/extras/yui-ext/source/core/EventManager.js
vendored
Normal file
662
www/extras/yui-ext/source/core/EventManager.js
vendored
Normal file
|
|
@ -0,0 +1,662 @@
|
|||
/*
|
||||
* Ext JS Library 1.0.1
|
||||
* Copyright(c) 2006-2007, Ext JS, LLC.
|
||||
* licensing@extjs.com
|
||||
*
|
||||
* http://www.extjs.com/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Ext.EventManager
|
||||
* Registers event handlers that want to receive a normalized EventObject instead of the standard browser event and provides
|
||||
* several useful events directly.
|
||||
* See {@link Ext.EventObject} for more details on normalized event objects.
|
||||
* @singleton
|
||||
*/
|
||||
Ext.EventManager = function(){
|
||||
var docReadyEvent, docReadyProcId, docReadyState = false;
|
||||
var resizeEvent, resizeTask, textEvent, textSize;
|
||||
var E = Ext.lib.Event;
|
||||
var D = Ext.lib.Dom;
|
||||
|
||||
|
||||
var fireDocReady = function(){
|
||||
if(!docReadyState){
|
||||
docReadyState = true;
|
||||
Ext.isReady = true;
|
||||
if(docReadyProcId){
|
||||
clearInterval(docReadyProcId);
|
||||
}
|
||||
if(Ext.isGecko || Ext.isOpera) {
|
||||
document.removeEventListener("DOMContentLoaded", fireDocReady, false);
|
||||
}
|
||||
if(docReadyEvent){
|
||||
docReadyEvent.fire();
|
||||
docReadyEvent.clearListeners();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var initDocReady = function(){
|
||||
docReadyEvent = new Ext.util.Event();
|
||||
if(Ext.isGecko || Ext.isOpera) {
|
||||
document.addEventListener("DOMContentLoaded", fireDocReady, false);
|
||||
}else if(Ext.isIE){
|
||||
// inspired by http://www.thefutureoftheweb.com/blog/2006/6/adddomloadevent
|
||||
document.write("<s"+'cript id="ie-deferred-loader" defer="defer" src="/'+'/:"></s'+"cript>");
|
||||
var defer = document.getElementById("ie-deferred-loader");
|
||||
defer.onreadystatechange = function(){
|
||||
if(this.readyState == "complete"){
|
||||
fireDocReady();
|
||||
defer.onreadystatechange = null;
|
||||
defer.parentNode.removeChild(defer);
|
||||
}
|
||||
};
|
||||
}else if(Ext.isSafari){
|
||||
docReadyProcId = setInterval(function(){
|
||||
var rs = document.readyState;
|
||||
if(rs == "complete") {
|
||||
fireDocReady();
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
// no matter what, make sure it fires on load
|
||||
E.on(window, "load", fireDocReady);
|
||||
};
|
||||
|
||||
var createBuffered = function(h, o){
|
||||
var task = new Ext.util.DelayedTask(h);
|
||||
return function(e){
|
||||
// create new event object impl so new events don't wipe out properties
|
||||
e = new Ext.EventObjectImpl(e);
|
||||
task.delay(o.buffer, h, null, [e]);
|
||||
};
|
||||
};
|
||||
|
||||
var createSingle = function(h, el, ename, fn){
|
||||
return function(e){
|
||||
Ext.EventManager.removeListener(el, ename, fn);
|
||||
h(e);
|
||||
};
|
||||
};
|
||||
|
||||
var createDelayed = function(h, o){
|
||||
return function(e){
|
||||
// create new event object impl so new events don't wipe out properties
|
||||
e = new Ext.EventObjectImpl(e);
|
||||
setTimeout(function(){
|
||||
h(e);
|
||||
}, o.delay || 10);
|
||||
};
|
||||
};
|
||||
|
||||
var listen = function(element, ename, opt, fn, scope){
|
||||
var o = (!opt || typeof opt == "boolean") ? {} : opt;
|
||||
fn = fn || o.fn; scope = scope || o.scope;
|
||||
var el = Ext.getDom(element);
|
||||
if(!el){
|
||||
throw "Error listening for \"" + ename + '\". Element "' + element + '" doesn\'t exist.';
|
||||
}
|
||||
var h = function(e){
|
||||
e = Ext.EventObject.setEvent(e);
|
||||
var t;
|
||||
if(o.delegate){
|
||||
t = e.getTarget(o.delegate, el);
|
||||
if(!t){
|
||||
return;
|
||||
}
|
||||
}else{
|
||||
t = e.target;
|
||||
}
|
||||
if(o.stopEvent === true){
|
||||
e.stopEvent();
|
||||
}
|
||||
if(o.preventDefault === true){
|
||||
e.preventDefault();
|
||||
}
|
||||
if(o.stopPropagation === true){
|
||||
e.stopPropagation();
|
||||
}
|
||||
|
||||
if(o.normalized === false){
|
||||
e = e.browserEvent;
|
||||
}
|
||||
|
||||
fn.call(scope || el, e, t, o);
|
||||
};
|
||||
if(o.delay){
|
||||
h = createDelayed(h, o);
|
||||
}
|
||||
if(o.single){
|
||||
h = createSingle(h, el, ename, fn);
|
||||
}
|
||||
if(o.buffer){
|
||||
h = createBuffered(h, o);
|
||||
}
|
||||
fn._handlers = fn._handlers || [];
|
||||
fn._handlers.push([Ext.id(el), ename, h]);
|
||||
|
||||
E.on(el, ename, h);
|
||||
if(ename == "mousewheel" && el.addEventListener){ // workaround for jQuery
|
||||
el.addEventListener("DOMMouseScroll", h, false);
|
||||
E.on(window, 'unload', function(){
|
||||
el.removeEventListener("DOMMouseScroll", h, false);
|
||||
});
|
||||
}
|
||||
if(ename == "mousedown" && el == document){ // fix stopped mousedowns on the document
|
||||
Ext.EventManager.stoppedMouseDownEvent.addListener(h);
|
||||
}
|
||||
return h;
|
||||
};
|
||||
|
||||
var stopListening = function(el, ename, fn){
|
||||
var id = Ext.id(el), hds = fn._handlers, hd = fn;
|
||||
if(hds){
|
||||
for(var i = 0, len = hds.length; i < len; i++){
|
||||
var h = hds[i];
|
||||
if(h[0] == id && h[1] == ename){
|
||||
hd = h[2];
|
||||
hds.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
E.un(el, ename, hd);
|
||||
el = Ext.getDom(el);
|
||||
if(ename == "mousewheel" && el.addEventListener){
|
||||
el.removeEventListener("DOMMouseScroll", hd, false);
|
||||
}
|
||||
if(ename == "mousedown" && el == document){ // fix stopped mousedowns on the document
|
||||
Ext.EventManager.stoppedMouseDownEvent.removeListener(hd);
|
||||
}
|
||||
};
|
||||
|
||||
var propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized)$/;
|
||||
var pub = {
|
||||
|
||||
/**
|
||||
* This is no longer needed and is deprecated. Places a simple wrapper around an event handler to override the browser event
|
||||
* object with a Ext.EventObject
|
||||
* @param {Function} fn The method the event invokes
|
||||
* @param {Object} scope An object that becomes the scope of the handler
|
||||
* @param {boolean} override If true, the obj passed in becomes
|
||||
* the execution scope of the listener
|
||||
* @return {Function} The wrapped function
|
||||
* @deprecated
|
||||
*/
|
||||
wrap : function(fn, scope, override){
|
||||
return function(e){
|
||||
Ext.EventObject.setEvent(e);
|
||||
fn.call(override ? scope || window : window, Ext.EventObject, scope);
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Appends an event handler
|
||||
*
|
||||
* @param {String/HTMLElement} element The html element or id to assign the
|
||||
* event to
|
||||
* @param {String} eventName The type of event to append
|
||||
* @param {Function} fn The method the event invokes
|
||||
* @param {Object} options An object with standard EventManager options
|
||||
*/
|
||||
addListener : function(element, eventName, fn, scope, options){
|
||||
if(typeof eventName == "object"){
|
||||
var o = eventName;
|
||||
for(var e in o){
|
||||
if(propRe.test(e)){
|
||||
continue;
|
||||
}
|
||||
if(typeof o[e] == "function"){
|
||||
// shared options
|
||||
listen(element, e, o, o[e], o.scope);
|
||||
}else{
|
||||
// individual options
|
||||
listen(element, e, o[e]);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
return listen(element, eventName, options, fn, scope);
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes an event handler
|
||||
*
|
||||
* @param {String/HTMLElement} element The id or html element to remove the
|
||||
* event from
|
||||
* @param {String} eventName The type of event
|
||||
* @param {Function} fn
|
||||
* @return {Boolean} True if a listener was actually removed
|
||||
*/
|
||||
removeListener : function(element, eventName, fn){
|
||||
return stopListening(element, eventName, fn);
|
||||
},
|
||||
|
||||
/**
|
||||
* Fires when the document is ready (before onload and before images are loaded). Can be
|
||||
* accessed shorthanded Ext.onReady().
|
||||
* @param {Function} fn The method the event invokes
|
||||
* @param {Object} scope An object that becomes the scope of the handler
|
||||
* @param {boolean} options
|
||||
*/
|
||||
onDocumentReady : function(fn, scope, options){
|
||||
if(docReadyState){ // if it already fired
|
||||
fn.call(scope || window, scope);
|
||||
return;
|
||||
}
|
||||
if(!docReadyEvent){
|
||||
initDocReady();
|
||||
}
|
||||
docReadyEvent.addListener(fn, scope, options);
|
||||
},
|
||||
|
||||
/**
|
||||
* Fires when the window is resized and provides resize event buffering (50 milliseconds), passes new viewport width and height to handlers.
|
||||
* @param {Function} fn The method the event invokes
|
||||
* @param {Object} scope An object that becomes the scope of the handler
|
||||
* @param {boolean} options
|
||||
*/
|
||||
onWindowResize : function(fn, scope, options){
|
||||
if(!resizeEvent){
|
||||
resizeEvent = new Ext.util.Event();
|
||||
resizeTask = new Ext.util.DelayedTask(function(){
|
||||
resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
|
||||
});
|
||||
E.on(window, "resize", function(){
|
||||
if(Ext.isIE){
|
||||
resizeTask.delay(50);
|
||||
}else{
|
||||
resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
|
||||
}
|
||||
});
|
||||
}
|
||||
resizeEvent.addListener(fn, scope, options);
|
||||
},
|
||||
|
||||
/**
|
||||
* Fires when the user changes the active text size. Handler gets called with 2 params, the old size and the new size.
|
||||
* @param {Function} fn The method the event invokes
|
||||
* @param {Object} scope An object that becomes the scope of the handler
|
||||
* @param {boolean} options
|
||||
*/
|
||||
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);
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the passed window resize listener.
|
||||
* @param {Function} fn The method the event invokes
|
||||
* @param {Object} scope The scope of handler
|
||||
*/
|
||||
removeResizeListener : function(fn, scope){
|
||||
if(resizeEvent){
|
||||
resizeEvent.removeListener(fn, scope);
|
||||
}
|
||||
},
|
||||
|
||||
fireResize : function(){
|
||||
if(resizeEvent){
|
||||
resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Url used for onDocumentReady with using SSL (defaults to Ext.SSL_SECURE_URL)
|
||||
*/
|
||||
ieDeferSrc : false,
|
||||
textResizeInterval : 50
|
||||
};
|
||||
/**
|
||||
* Appends an event handler (shorthand for addListener)
|
||||
*
|
||||
* @param {String/HTMLElement} element The html element or id to assign the
|
||||
* event to
|
||||
* @param {String} eventName The type of event to append
|
||||
* @param {Function} fn The method the event invokes
|
||||
* @param {Object} scope An arbitrary object that will be
|
||||
* passed as a parameter to the handler
|
||||
* @param {boolean} override If true, the obj passed in becomes
|
||||
* the execution scope of the listener
|
||||
* @return {Function} The wrapper function created (to be used to remove the listener if necessary)
|
||||
* @method
|
||||
*/
|
||||
pub.on = pub.addListener;
|
||||
pub.un = pub.removeListener;
|
||||
|
||||
pub.stoppedMouseDownEvent = new Ext.util.Event();
|
||||
return pub;
|
||||
}();
|
||||
/**
|
||||
* Fires when the document is ready (before onload and before images are loaded). Shorthand of {@link Ext.EventManager#onDocumentReady}.
|
||||
* @param {Function} fn The method the event invokes
|
||||
* @param {Object} scope An object that becomes the scope of the handler
|
||||
* @param {boolean} override If true, the obj passed in becomes
|
||||
* the execution scope of the listener
|
||||
* @member Ext
|
||||
* @method onReady
|
||||
*/
|
||||
Ext.onReady = Ext.EventManager.onDocumentReady;
|
||||
|
||||
Ext.onReady(function(){
|
||||
var bd = Ext.get(document.body);
|
||||
if(!bd){ return; }
|
||||
var cls = Ext.isIE ? "ext-ie"
|
||||
: Ext.isGecko ? "ext-gecko"
|
||||
: Ext.isOpera ? "ext-opera"
|
||||
: Ext.isSafari ? "ext-safari" : "";
|
||||
if(Ext.isBorderBox){
|
||||
cls += ' ext-border-box';
|
||||
}
|
||||
if(Ext.isStrict){
|
||||
cls += ' ext-strict';
|
||||
}
|
||||
bd.addClass(cls);
|
||||
});
|
||||
/**
|
||||
* @class Ext.EventObject
|
||||
* EventObject exposes the Yahoo! UI Event functionality directly on the object
|
||||
* passed to your event handler. It exists mostly for convenience. It also fixes the annoying null checks automatically to cleanup your code
|
||||
* Example:
|
||||
* <pre><code>
|
||||
function handleClick(e){ // e is not a standard event object, it is a Ext.EventObject
|
||||
e.preventDefault();
|
||||
var target = e.getTarget();
|
||||
...
|
||||
}
|
||||
var myDiv = Ext.get("myDiv");
|
||||
myDiv.on("click", handleClick);
|
||||
//or
|
||||
Ext.EventManager.on("myDiv", 'click', handleClick);
|
||||
Ext.EventManager.addListener("myDiv", 'click', handleClick);
|
||||
</code></pre>
|
||||
* @singleton
|
||||
*/
|
||||
Ext.EventObject = function(){
|
||||
|
||||
var E = Ext.lib.Event;
|
||||
|
||||
// safari keypress events for special keys return bad keycodes
|
||||
var safariKeys = {
|
||||
63234 : 37, // left
|
||||
63235 : 39, // right
|
||||
63232 : 38, // up
|
||||
63233 : 40, // down
|
||||
63276 : 33, // page up
|
||||
63277 : 34, // page down
|
||||
63272 : 46, // delete
|
||||
63273 : 36, // home
|
||||
63275 : 35 // end
|
||||
};
|
||||
|
||||
// normalize button clicks
|
||||
var btnMap = Ext.isIE ? {1:0,4:1,2:2} :
|
||||
(Ext.isSafari ? {1:0,2:1,3:2} : {0:0,1:1,2:2});
|
||||
|
||||
Ext.EventObjectImpl = function(e){
|
||||
if(e){
|
||||
this.setEvent(e.browserEvent || e);
|
||||
}
|
||||
};
|
||||
Ext.EventObjectImpl.prototype = {
|
||||
/** The normal browser event */
|
||||
browserEvent : null,
|
||||
/** The button pressed in a mouse event */
|
||||
button : -1,
|
||||
/** True if the shift key was down during the event */
|
||||
shiftKey : false,
|
||||
/** True if the control key was down during the event */
|
||||
ctrlKey : false,
|
||||
/** True if the alt key was down during the event */
|
||||
altKey : false,
|
||||
|
||||
/** Key constant @type Number */
|
||||
BACKSPACE : 8,
|
||||
/** Key constant @type Number */
|
||||
TAB : 9,
|
||||
/** Key constant @type Number */
|
||||
RETURN : 13,
|
||||
/** Key constant @type Number */
|
||||
ENTER : 13,
|
||||
/** Key constant @type Number */
|
||||
SHIFT : 16,
|
||||
/** Key constant @type Number */
|
||||
CONTROL : 17,
|
||||
/** Key constant @type Number */
|
||||
ESC : 27,
|
||||
/** Key constant @type Number */
|
||||
SPACE : 32,
|
||||
/** Key constant @type Number */
|
||||
PAGEUP : 33,
|
||||
/** Key constant @type Number */
|
||||
PAGEDOWN : 34,
|
||||
/** Key constant @type Number */
|
||||
END : 35,
|
||||
/** Key constant @type Number */
|
||||
HOME : 36,
|
||||
/** Key constant @type Number */
|
||||
LEFT : 37,
|
||||
/** Key constant @type Number */
|
||||
UP : 38,
|
||||
/** Key constant @type Number */
|
||||
RIGHT : 39,
|
||||
/** Key constant @type Number */
|
||||
DOWN : 40,
|
||||
/** Key constant @type Number */
|
||||
DELETE : 46,
|
||||
/** Key constant @type Number */
|
||||
F5 : 116,
|
||||
|
||||
/** @private */
|
||||
setEvent : function(e){
|
||||
if(e == this || (e && e.browserEvent)){ // already wrapped
|
||||
return e;
|
||||
}
|
||||
this.browserEvent = e;
|
||||
if(e){
|
||||
// normalize buttons
|
||||
this.button = e.button ? btnMap[e.button] : (e.which ? e.which-1 : -1);
|
||||
this.shiftKey = e.shiftKey;
|
||||
// mac metaKey behaves like ctrlKey
|
||||
this.ctrlKey = e.ctrlKey || e.metaKey;
|
||||
this.altKey = e.altKey;
|
||||
// in getKey these will be normalized for the mac
|
||||
this.keyCode = e.keyCode;
|
||||
this.charCode = e.charCode;
|
||||
// cache the target for the delayed and or buffered events
|
||||
this.target = E.getTarget(e);
|
||||
// same for XY
|
||||
this.xy = E.getXY(e);
|
||||
}else{
|
||||
this.button = -1;
|
||||
this.shiftKey = false;
|
||||
this.ctrlKey = false;
|
||||
this.altKey = false;
|
||||
this.keyCode = 0;
|
||||
this.charCode =0;
|
||||
this.target = null;
|
||||
this.xy = [0, 0];
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Stop the event (preventDefault and stopPropagation)
|
||||
*/
|
||||
stopEvent : function(){
|
||||
if(this.browserEvent){
|
||||
if(this.browserEvent.type == 'mousedown'){
|
||||
Ext.EventManager.stoppedMouseDownEvent.fire(this);
|
||||
}
|
||||
E.stopEvent(this.browserEvent);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Prevents the browsers default handling of the event.
|
||||
*/
|
||||
preventDefault : function(){
|
||||
if(this.browserEvent){
|
||||
E.preventDefault(this.browserEvent);
|
||||
}
|
||||
},
|
||||
|
||||
/** @private */
|
||||
isNavKeyPress : function(){
|
||||
var k = this.keyCode;
|
||||
k = Ext.isSafari ? (safariKeys[k] || k) : k;
|
||||
return (k >= 33 && k <= 40) || k == this.RETURN || k == this.TAB || k == this.ESC;
|
||||
},
|
||||
|
||||
isSpecialKey : function(){
|
||||
var k = this.keyCode;
|
||||
return k == 9 || k == 13 || k == 40 || k == 27 ||
|
||||
(k == 16) || (k == 17) ||
|
||||
(k >= 18 && k <= 20) ||
|
||||
(k >= 33 && k <= 35) ||
|
||||
(k >= 36 && k <= 39) ||
|
||||
(k >= 44 && k <= 45);
|
||||
},
|
||||
/**
|
||||
* Cancels bubbling of the event.
|
||||
*/
|
||||
stopPropagation : function(){
|
||||
if(this.browserEvent){
|
||||
if(this.browserEvent.type == 'mousedown'){
|
||||
Ext.EventManager.stoppedMouseDownEvent.fire(this);
|
||||
}
|
||||
E.stopPropagation(this.browserEvent);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the key code for the event.
|
||||
* @return {Number}
|
||||
*/
|
||||
getCharCode : function(){
|
||||
return this.charCode || this.keyCode;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a normalized keyCode for the event.
|
||||
* @return {Number} The key code
|
||||
*/
|
||||
getKey : function(){
|
||||
var k = this.keyCode || this.charCode;
|
||||
return Ext.isSafari ? (safariKeys[k] || k) : k;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the x coordinate of the event.
|
||||
* @return {Number}
|
||||
*/
|
||||
getPageX : function(){
|
||||
return this.xy[0];
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the y coordinate of the event.
|
||||
* @return {Number}
|
||||
*/
|
||||
getPageY : function(){
|
||||
return this.xy[1];
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the time of the event.
|
||||
* @return {Number}
|
||||
*/
|
||||
getTime : function(){
|
||||
if(this.browserEvent){
|
||||
return E.getTime(this.browserEvent);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the page coordinates of the event.
|
||||
* @return {Array} The xy values like [x, y]
|
||||
*/
|
||||
getXY : function(){
|
||||
return this.xy;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the target for the event.
|
||||
* @param {String} selector (optional) A simple selector to filter the target or look for an ancestor of the target
|
||||
* @param {Number/String/HTMLElement/Element} maxDepth (optional) The max depth to
|
||||
search as a number or element (defaults to 10 || document.body)
|
||||
* @param {Boolean} returnEl (optional) True to return a Ext.Element object instead of DOM node
|
||||
* @return {HTMLelement}
|
||||
*/
|
||||
getTarget : function(selector, maxDepth, returnEl){
|
||||
return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : this.target;
|
||||
},
|
||||
/**
|
||||
* Gets the related target.
|
||||
* @return {HTMLElement}
|
||||
*/
|
||||
getRelatedTarget : function(){
|
||||
if(this.browserEvent){
|
||||
return E.getRelatedTarget(this.browserEvent);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Normalizes mouse wheel delta across browsers
|
||||
* @return {Number} The delta
|
||||
*/
|
||||
getWheelDelta : function(){
|
||||
var e = this.browserEvent;
|
||||
var delta = 0;
|
||||
if(e.wheelDelta){ /* IE/Opera. */
|
||||
delta = e.wheelDelta/120;
|
||||
/* In Opera 9, delta differs in sign as compared to IE. */
|
||||
if(window.opera) delta = -delta;
|
||||
}else if(e.detail){ /* Mozilla case. */
|
||||
delta = -e.detail/3;
|
||||
}
|
||||
return delta;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns true if the control, meta, shift or alt key was pressed during this event.
|
||||
* @return {Boolean}
|
||||
*/
|
||||
hasModifier : function(){
|
||||
return ((this.ctrlKey || this.altKey) || this.shiftKey) ? true : false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns true if the target of this event equals el or is a child of el
|
||||
* @param {String/HTMLElement/Element} el
|
||||
* @param {Boolean} related (optional) true to test if the related target is within el instead of the target
|
||||
* @return {Boolean}
|
||||
*/
|
||||
within : function(el, related){
|
||||
var t = this[related ? "getRelatedTarget" : "getTarget"]();
|
||||
return t && Ext.fly(el).contains(t);
|
||||
},
|
||||
|
||||
getPoint : function(){
|
||||
return new Ext.lib.Point(this.xy[0], this.xy[1]);
|
||||
}
|
||||
};
|
||||
|
||||
return new Ext.EventObjectImpl();
|
||||
}();
|
||||
|
||||
|
||||
594
www/extras/yui-ext/source/core/Ext.js
vendored
Normal file
594
www/extras/yui-ext/source/core/Ext.js
vendored
Normal file
|
|
@ -0,0 +1,594 @@
|
|||
/*
|
||||
* Ext JS Library 1.0.1
|
||||
* Copyright(c) 2006-2007, Ext JS, LLC.
|
||||
* licensing@extjs.com
|
||||
*
|
||||
* http://www.extjs.com/license
|
||||
*/
|
||||
|
||||
|
||||
Ext = {};
|
||||
|
||||
// for old browsers
|
||||
window["undefined"] = window["undefined"];
|
||||
|
||||
/**
|
||||
* @class Ext
|
||||
* Ext core utilties and functions
|
||||
* @singleton
|
||||
*/
|
||||
|
||||
/**
|
||||
* Copies all the properties of config to obj.
|
||||
* @param {Object} obj The receiver of the properties
|
||||
* @param {Object} config The source of the properties
|
||||
* @param {Object} defaults A different object that will also be applied for default values
|
||||
* @return {Object} returns obj
|
||||
* @member Ext apply
|
||||
*/
|
||||
Ext.apply = function(o, c, defaults){
|
||||
if(defaults){
|
||||
// no "this" reference for friendly out of scope calls
|
||||
Ext.apply(o, defaults);
|
||||
}
|
||||
if(o && c && typeof c == 'object'){
|
||||
for(var p in c){
|
||||
o[p] = c[p];
|
||||
}
|
||||
}
|
||||
return o;
|
||||
};
|
||||
|
||||
(function(){
|
||||
var idSeed = 0;
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
|
||||
var isStrict = document.compatMode == "CSS1Compat",
|
||||
isOpera = ua.indexOf("opera") > -1,
|
||||
isSafari = (/webkit|khtml/).test(ua),
|
||||
isIE = ua.indexOf("msie") > -1,
|
||||
isIE7 = ua.indexOf("msie 7") > -1,
|
||||
isGecko = !isSafari && ua.indexOf("gecko") > -1,
|
||||
isBorderBox = isIE && !isStrict,
|
||||
isWindows = (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1),
|
||||
isMac = (ua.indexOf("macintosh") != -1 || ua.indexOf("mac os x") != -1),
|
||||
isSecure = window.location.href.toLowerCase().indexOf("https") === 0;
|
||||
|
||||
// remove css image flicker
|
||||
if(isIE && !isIE7){
|
||||
try{
|
||||
document.execCommand("BackgroundImageCache", false, true);
|
||||
}catch(e){}
|
||||
}
|
||||
|
||||
Ext.apply(Ext, {
|
||||
/**
|
||||
* True if the browser is in strict mode
|
||||
* @type Boolean
|
||||
*/
|
||||
isStrict : isStrict,
|
||||
/**
|
||||
* True if the page is running over SSL
|
||||
* @type Boolean
|
||||
*/
|
||||
isSecure : isSecure,
|
||||
/**
|
||||
* True when the document is fully initialized and ready for action
|
||||
* @type Boolean
|
||||
*/
|
||||
isReady : false,
|
||||
/**
|
||||
* URL to a blank file used by Ext when in secure mode for iframe src and onReady src to prevent
|
||||
* the IE insecure content warning (defaults to javascript:false).
|
||||
* @type String
|
||||
*/
|
||||
SSL_SECURE_URL : "javascript:false",
|
||||
|
||||
/**
|
||||
* URL to a 1x1 transparent gif image used by Ext to create inline icons with CSS background images. (Defaults to
|
||||
* "http://extjs.com/s.gif" and you should change this to a URL on your server).
|
||||
* @type String
|
||||
*/
|
||||
BLANK_IMAGE_URL : "http:/"+"/extjs.com/s.gif",
|
||||
|
||||
emptyFn : function(){},
|
||||
|
||||
/**
|
||||
* Copies all the properties of config to obj if they don't already exist.
|
||||
* @param {Object} obj The receiver of the properties
|
||||
* @param {Object} config The source of the properties
|
||||
* @return {Object} returns obj
|
||||
*/
|
||||
applyIf : function(o, c){
|
||||
if(o && c){
|
||||
for(var p in c){
|
||||
if(typeof o[p] == "undefined"){ o[p] = c[p]; }
|
||||
}
|
||||
}
|
||||
return o;
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies event listeners to elements by selectors when the document is ready.
|
||||
* The event name is specified with an @ suffix.
|
||||
<pre><code>
|
||||
Ext.addBehaviors({
|
||||
// add a listener for click on all anchors in element with id foo
|
||||
'#foo a@click' : function(e, t){
|
||||
// do something
|
||||
},
|
||||
|
||||
// add the same listener to multiple selectors (separated by comma BEFORE the @)
|
||||
'#foo a, #bar span.some-class@mouseover' : function(){
|
||||
// do something
|
||||
}
|
||||
});
|
||||
</code></pre>
|
||||
* @param {Object} obj The list of behaviors to apply
|
||||
*/
|
||||
addBehaviors : function(o){
|
||||
if(!Ext.isReady){
|
||||
Ext.onReady(function(){
|
||||
Ext.addBehaviors(o);
|
||||
});
|
||||
return;
|
||||
}
|
||||
var cache = {}; // simple cache for applying multiple behaviors to same selector does query multiple times
|
||||
for(var b in o){
|
||||
var parts = b.split('@');
|
||||
if(parts[1]){ // for Object prototype breakers
|
||||
var s = parts[0];
|
||||
if(!cache[s]){
|
||||
cache[s] = Ext.select(s);
|
||||
}
|
||||
cache[s].on(parts[1], o[b]);
|
||||
}
|
||||
}
|
||||
cache = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Generates unique ids. If the element already has an id, it is unchanged
|
||||
* @param {String/HTMLElement/Element} el (optional) The element to generate an id for
|
||||
* @param {String} prefix (optional) Id prefix (defaults "ext-gen")
|
||||
*/
|
||||
id : function(el, prefix){
|
||||
prefix = prefix || "ext-gen";
|
||||
el = Ext.getDom(el);
|
||||
var id = prefix + (++idSeed);
|
||||
return el ? (el.id ? el.id : (el.id = id)) : id;
|
||||
},
|
||||
|
||||
/**
|
||||
* Extends one class with another class and optionally overrides members with the passed literal. This class
|
||||
* also adds the function "override()" to the class that can be used to override
|
||||
* members on an instance.
|
||||
* @param {Object} subclass The class inheriting the functionality
|
||||
* @param {Object} superclass The class being extended
|
||||
* @param {Object} overrides (optional) A literal with members
|
||||
* @method extend
|
||||
*/
|
||||
extend : function(){
|
||||
// inline overrides
|
||||
var io = function(o){
|
||||
for(var m in o){
|
||||
this[m] = o[m];
|
||||
}
|
||||
};
|
||||
return function(sb, sp, overrides){
|
||||
if(typeof sp == 'object'){
|
||||
overrides = sp;
|
||||
sp = sb;
|
||||
sb = function(){sp.apply(this, arguments);};
|
||||
}
|
||||
var F = function(){}, sbp, spp = sp.prototype;
|
||||
F.prototype = spp;
|
||||
sbp = sb.prototype = new F();
|
||||
sbp.constructor=sb;
|
||||
sb.superclass=spp;
|
||||
if(spp.constructor == Object.prototype.constructor){
|
||||
spp.constructor=sp;
|
||||
}
|
||||
sb.override = function(o){
|
||||
Ext.override(sb, o);
|
||||
};
|
||||
sbp.override = io;
|
||||
sbp.__extcls = sb;
|
||||
Ext.override(sb, overrides);
|
||||
return sb;
|
||||
};
|
||||
}(),
|
||||
|
||||
override : function(origclass, overrides){
|
||||
if(overrides){
|
||||
var p = origclass.prototype;
|
||||
for(var method in overrides){
|
||||
p[method] = overrides[method];
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Creates namespaces but does not assume YAHOO is the root.
|
||||
* @param {String} namespace1
|
||||
* @param {String} namespace2
|
||||
* @param {String} etc
|
||||
* @method namespace
|
||||
*/
|
||||
namespace : function(){
|
||||
var a=arguments, o=null, i, j, d, rt;
|
||||
for (i=0; i<a.length; ++i) {
|
||||
d=a[i].split(".");
|
||||
rt = d[0];
|
||||
eval('if (typeof ' + rt + ' == "undefined"){' + rt + ' = {};} o = ' + rt + ';');
|
||||
for (j=1; j<d.length; ++j) {
|
||||
o[d[j]]=o[d[j]] || {};
|
||||
o=o[d[j]];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Takes an object and converts it to an encoded URL. e.g. Ext.urlEncode({foo: 1, bar: 2}); would return "foo=1&bar=2". Optionally, property values can be arrays, instead of keys and the resulting string that's returned will contain a name/value pair for each array value.
|
||||
* @param {Object} o
|
||||
* @return {String}
|
||||
*/
|
||||
urlEncode : function(o){
|
||||
if(!o){
|
||||
return "";
|
||||
}
|
||||
var buf = [];
|
||||
for(var key in o){
|
||||
var ov = o[key];
|
||||
var type = typeof ov;
|
||||
if(type == 'undefined'){
|
||||
buf.push(encodeURIComponent(key), "=&");
|
||||
}else if(type != "function" && type != "object"){
|
||||
buf.push(encodeURIComponent(key), "=", encodeURIComponent(ov), "&");
|
||||
}else if(ov instanceof Array){
|
||||
for(var i = 0, len = ov.length; i < len; i++) {
|
||||
buf.push(encodeURIComponent(key), "=", encodeURIComponent(ov[i] === undefined ? '' : ov[i]), "&");
|
||||
}
|
||||
}
|
||||
}
|
||||
buf.pop();
|
||||
return buf.join("");
|
||||
},
|
||||
|
||||
/**
|
||||
* Takes an encoded URL and and converts it to an object. e.g. Ext.urlDecode("foo=1&bar=2"); would return {foo: 1, bar: 2} or Ext.urlDecode("foo=1&bar=2&bar=3&bar=4", true); would return {foo: 1, bar: [2, 3, 4]}.
|
||||
* @param {String} string
|
||||
* @param {Boolean} overwrite (optional) Items of the same name will overwrite previous values instead of creating an an array (Defaults to false).
|
||||
* @return {Object} A literal with members
|
||||
*/
|
||||
urlDecode : function(string, overwrite){
|
||||
if(!string || !string.length){
|
||||
return {};
|
||||
}
|
||||
var obj = {};
|
||||
var pairs = string.split('&');
|
||||
var pair, name, value;
|
||||
for(var i = 0, len = pairs.length; i < len; i++){
|
||||
pair = pairs[i].split('=');
|
||||
name = decodeURIComponent(pair[0]);
|
||||
value = decodeURIComponent(pair[1]);
|
||||
if(overwrite !== true){
|
||||
if(typeof obj[name] == "undefined"){
|
||||
obj[name] = value;
|
||||
}else if(typeof obj[name] == "string"){
|
||||
obj[name] = [obj[name]];
|
||||
obj[name].push(value);
|
||||
}else{
|
||||
obj[name].push(value);
|
||||
}
|
||||
}else{
|
||||
obj[name] = value;
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
/**
|
||||
* Iterates an array calling the passed function with each item, stopping if your function returns false. If the
|
||||
* passed array is not really an array, your function is called once with it.
|
||||
* The supplied function is called with (Object item, Number index, Array allItems).
|
||||
* @param {Array/NodeList/Mixed} array
|
||||
* @param {Function} fn
|
||||
* @param {Object} scope
|
||||
*/
|
||||
each : function(array, fn, scope){
|
||||
if(typeof array.length == "undefined" || typeof array == "string"){
|
||||
array = [array];
|
||||
}
|
||||
for(var i = 0, len = array.length; i < len; i++){
|
||||
if(fn.call(scope || array[i], array[i], i, array) === false){ return i; };
|
||||
}
|
||||
},
|
||||
|
||||
// deprecated
|
||||
combine : function(){
|
||||
var as = arguments, l = as.length, r = [];
|
||||
for(var i = 0; i < l; i++){
|
||||
var a = as[i];
|
||||
if(a instanceof Array){
|
||||
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 r;
|
||||
},
|
||||
|
||||
/**
|
||||
* Escapes the passed string for use in a regular expression
|
||||
* @param {String} str
|
||||
* @return {String}
|
||||
*/
|
||||
escapeRe : function(s) {
|
||||
return s.replace(/([.*+?^${}()|[\]\/\\])/g, "\\$1");
|
||||
},
|
||||
|
||||
// internal
|
||||
callback : function(cb, scope, args, delay){
|
||||
if(typeof cb == "function"){
|
||||
if(delay){
|
||||
cb.defer(delay, scope, args || []);
|
||||
}else{
|
||||
cb.apply(scope, args || []);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Return the dom node for the passed string (id), dom node, or Ext.Element
|
||||
* @param {String/HTMLElement/Element) el
|
||||
* @return HTMLElement
|
||||
*/
|
||||
getDom : function(el){
|
||||
if(!el){
|
||||
return null;
|
||||
}
|
||||
return el.dom ? el.dom : (typeof el == 'string' ? document.getElementById(el) : el);
|
||||
},
|
||||
|
||||
/**
|
||||
* Shorthand for {@link Ext.ComponentMgr#get}
|
||||
* @param {String} id
|
||||
* @return Ext.Component
|
||||
*/
|
||||
getCmp : function(id){
|
||||
return Ext.ComponentMgr.get(id);
|
||||
},
|
||||
|
||||
num : function(v, defaultValue){
|
||||
if(typeof v != 'number'){
|
||||
return defaultValue;
|
||||
}
|
||||
return v;
|
||||
},
|
||||
|
||||
destroy : function(){
|
||||
for(var i = 0, a = arguments, len = a.length; i < len; i++) {
|
||||
var as = a[i];
|
||||
if(as){
|
||||
if(as.dom){
|
||||
as.removeAllListeners();
|
||||
as.remove();
|
||||
continue;
|
||||
}
|
||||
if(typeof as.purgeListeners == 'function'){
|
||||
as.purgeListeners();
|
||||
}
|
||||
if(typeof as.destroy == 'function'){
|
||||
as.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/* @type Boolean */
|
||||
isOpera : isOpera,
|
||||
/* @type Boolean */
|
||||
isSafari : isSafari,
|
||||
/* @type Boolean */
|
||||
isIE : isIE,
|
||||
/* @type Boolean */
|
||||
isIE7 : isIE7,
|
||||
/* @type Boolean */
|
||||
isGecko : isGecko,
|
||||
/* @type Boolean */
|
||||
isBorderBox : isBorderBox,
|
||||
/* @type Boolean */
|
||||
isWindows : isWindows,
|
||||
/* @type Boolean */
|
||||
isMac : isMac,
|
||||
|
||||
/**
|
||||
By default, Ext intelligently decides whether floating elements should be shimmed. If you are using flash,
|
||||
you may want to set this to true.
|
||||
@type Boolean
|
||||
*/
|
||||
useShims : ((isIE && !isIE7) || (isGecko && isMac))
|
||||
});
|
||||
|
||||
|
||||
})();
|
||||
|
||||
Ext.namespace("Ext", "Ext.util", "Ext.grid", "Ext.dd", "Ext.tree", "Ext.data",
|
||||
"Ext.form", "Ext.menu", "Ext.state", "Ext.lib", "Ext.layout");
|
||||
|
||||
|
||||
/**
|
||||
* @class Function
|
||||
* These functions are available on every Function object (any javascript function).
|
||||
*/
|
||||
Ext.apply(Function.prototype, {
|
||||
/**
|
||||
* Creates a callback that passes arguments[0], arguments[1], arguments[2], ...
|
||||
* Call directly on any function. Example: <code>myFunction.createCallback(myarg, myarg2)</code>
|
||||
* Will create a function that is bound to those 2 args.
|
||||
* @return {Function} The new function
|
||||
*/
|
||||
createCallback : function(/*args...*/){
|
||||
// make args available, in function below
|
||||
var args = arguments;
|
||||
var method = this;
|
||||
return function() {
|
||||
return method.apply(window, args);
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a delegate (callback) that sets the scope to obj.
|
||||
* Call directly on any function. Example: <code>this.myFunction.createDelegate(this)</code>
|
||||
* Will create a function that is automatically scoped to this.
|
||||
* @param {Object} obj (optional) The object for which the scope is set
|
||||
* @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(obj, args, appendArgs){
|
||||
var method = this;
|
||||
return function() {
|
||||
var callArgs = args || arguments;
|
||||
if(appendArgs === true){
|
||||
callArgs = Array.prototype.slice.call(arguments, 0);
|
||||
callArgs = callArgs.concat(args);
|
||||
}else if(typeof appendArgs == "number"){
|
||||
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 method.apply(obj || window, callArgs);
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Calls this function after the number of millseconds specified.
|
||||
* @param {Number} millis The number of milliseconds for the setTimeout call (if 0 the function is executed immediately)
|
||||
* @param {Object} obj (optional) The object for which the scope is set
|
||||
* @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(millis, obj, args, appendArgs){
|
||||
var fn = this.createDelegate(obj, args, appendArgs);
|
||||
if(millis){
|
||||
return setTimeout(fn, millis);
|
||||
}
|
||||
fn();
|
||||
return 0;
|
||||
},
|
||||
/**
|
||||
* 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
|
||||
* @param {Function} fcn The function to sequence
|
||||
* @param {Object} scope (optional) The scope of the passed fcn (Defaults to scope of original function or window)
|
||||
* @return {Function} The new function
|
||||
*/
|
||||
createSequence : function(fcn, scope){
|
||||
if(typeof fcn != "function"){
|
||||
return this;
|
||||
}
|
||||
var method = this;
|
||||
return function() {
|
||||
var retval = method.apply(this || window, arguments);
|
||||
fcn.apply(scope || this || window, arguments);
|
||||
return retval;
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates an interceptor function. The passed fcn 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 fcn is called with the parameters of the original function.
|
||||
* @addon
|
||||
* @param {Function} fcn The function to call before the original
|
||||
* @param {Object} scope (optional) The scope of the passed fcn (Defaults to scope of original function or window)
|
||||
* @return {Function} The new function
|
||||
*/
|
||||
createInterceptor : function(fcn, scope){
|
||||
if(typeof fcn != "function"){
|
||||
return this;
|
||||
}
|
||||
var method = this;
|
||||
return function() {
|
||||
fcn.target = this;
|
||||
fcn.method = method;
|
||||
if(fcn.apply(scope || this || window, arguments) === false){
|
||||
return;
|
||||
}
|
||||
return method.apply(this || window, arguments);
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
Ext.applyIf(String, {
|
||||
|
||||
/*
|
||||
* Escapes the passed string for ' and \
|
||||
* @param {String} str
|
||||
* @return {String}
|
||||
*/
|
||||
escape : function(string) {
|
||||
return string.replace(/('|\\)/g, "\\$1");
|
||||
},
|
||||
|
||||
leftPad : function (val, size, ch) {
|
||||
var result = new String(val);
|
||||
if (ch == null) {
|
||||
ch = " ";
|
||||
}
|
||||
while (result.length < size) {
|
||||
result = ch + result;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
format : function(format){
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
return format.replace(/\{(\d+)\}/g, function(m, i){
|
||||
return args[i];
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
String.prototype.toggle = function(value, other){
|
||||
return this == value ? other : value;
|
||||
};
|
||||
|
||||
Ext.applyIf(Number.prototype, {
|
||||
constrain : function(min, max){
|
||||
return Math.min(Math.max(this, min), max);
|
||||
}
|
||||
});
|
||||
|
||||
Ext.applyIf(Array.prototype, {
|
||||
indexOf : function(o){
|
||||
for (var i = 0, len = this.length; i < len; i++){
|
||||
if(this[i] == o) return i;
|
||||
}
|
||||
return -1;
|
||||
},
|
||||
|
||||
remove : function(o){
|
||||
var index = this.indexOf(o);
|
||||
if(index != -1){
|
||||
this.splice(index, 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
Returns the number of milliseconds between this date and date
|
||||
@param {Date} date (optional) Defaults to now
|
||||
@return {Number} The diff in milliseconds
|
||||
@member Date getElapsed
|
||||
*/
|
||||
Date.prototype.getElapsed = function(date) {
|
||||
return Math.abs((date || new Date()).getTime()-this.getTime());
|
||||
};
|
||||
1000
www/extras/yui-ext/source/core/Fx.js
vendored
Normal file
1000
www/extras/yui-ext/source/core/Fx.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
364
www/extras/yui-ext/source/core/Template.js
vendored
Normal file
364
www/extras/yui-ext/source/core/Template.js
vendored
Normal file
|
|
@ -0,0 +1,364 @@
|
|||
/*
|
||||
* Ext JS Library 1.0.1
|
||||
* Copyright(c) 2006-2007, Ext JS, LLC.
|
||||
* licensing@extjs.com
|
||||
*
|
||||
* http://www.extjs.com/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Ext.Template
|
||||
* Represents an HTML fragment template. Templates can be precompiled for greater performance.
|
||||
* For a list of available format functions, see {@link Ext.util.Format}.
|
||||
<pre><code>
|
||||
var t = new Ext.Template(
|
||||
'<div name="{id}">',
|
||||
'<span class="{cls}">{name:trim} {value:ellipsis(10)}</span>',
|
||||
'</div>'
|
||||
);
|
||||
t.append('some-element', {id: 'myid', name: 'foo', value: 'bar'});
|
||||
</code></pre>
|
||||
* For more information see <a href="http://www.jackslocum.com/yui/2006/10/06/domhelper-create-elements-using-dom-html-fragments-or-templates/">this blog post with examples</a>.
|
||||
* <br>
|
||||
* @constructor
|
||||
* @param {String/Array} html The HTML fragment or an array of fragments to join('') or multiple arguments to join('')
|
||||
*/
|
||||
Ext.Template = function(html){
|
||||
if(html instanceof Array){
|
||||
html = html.join("");
|
||||
}else if(arguments.length > 1){
|
||||
html = Array.prototype.join.call(arguments, "");
|
||||
}
|
||||
/**@private*/
|
||||
this.html = html;
|
||||
|
||||
};
|
||||
Ext.Template.prototype = {
|
||||
/**
|
||||
* Returns an HTML fragment of this template with the specified values applied
|
||||
* @param {Object} 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}
|
||||
*/
|
||||
applyTemplate : function(values){
|
||||
if(this.compiled){
|
||||
return this.compiled(values);
|
||||
}
|
||||
var useF = this.disableFormats !== true;
|
||||
var fm = Ext.util.Format, tpl = this;
|
||||
var fn = function(m, name, format, args){
|
||||
if(format && useF){
|
||||
if(format.substr(0, 5) == "this."){
|
||||
return tpl.call(format.substr(5), values[name]);
|
||||
}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 = /^\s*['"](.*)["']\s*$/;
|
||||
args = args.split(',');
|
||||
for(var i = 0, len = args.length; i < len; i++){
|
||||
args[i] = args[i].replace(re, "$1");
|
||||
}
|
||||
args = [values[name]].concat(args);
|
||||
}else{
|
||||
args = [values[name]];
|
||||
}
|
||||
return fm[format].apply(fm, args);
|
||||
}
|
||||
}else{
|
||||
return values[name] !== undefined ? values[name] : "";
|
||||
}
|
||||
};
|
||||
return this.html.replace(this.re, fn);
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the html used as the template and optionally compiles it
|
||||
* @param {String} html
|
||||
* @param {Boolean} compile (optional)
|
||||
* @return {Template} this
|
||||
*/
|
||||
set : function(html, compile){
|
||||
this.html = html;
|
||||
this.compiled = null;
|
||||
if(compile){
|
||||
this.compile();
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* True to disable format functions (default to false)
|
||||
* @type Boolean
|
||||
*/
|
||||
disableFormats : false,
|
||||
|
||||
/**
|
||||
* The regular expression used to match template variables
|
||||
* @type RegExp
|
||||
* @property
|
||||
*/
|
||||
re : /\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,
|
||||
|
||||
/**
|
||||
* Compiles the template into an internal function, eliminating the RegEx overhead
|
||||
*/
|
||||
compile : function(){
|
||||
var fm = Ext.util.Format;
|
||||
var useF = this.disableFormats !== true;
|
||||
var sep = Ext.isGecko ? "+" : ",";
|
||||
var fn = function(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 = "";
|
||||
}
|
||||
}else{
|
||||
args= '', format = "(values['" + name + "'] == undefined ? '' : ";
|
||||
}
|
||||
return "'"+ sep + format + "values['" + name + "']" + args + ")"+sep+"'";
|
||||
};
|
||||
var body;
|
||||
// branched to use + in gecko and [].join() in others
|
||||
if(Ext.isGecko){
|
||||
body = "this.compiled = function(values){ return '" +
|
||||
this.html.replace(/(\r\n|\n)/g, '\\n').replace("'", "\\'").replace(this.re, fn) +
|
||||
"';};";
|
||||
}else{
|
||||
body = ["this.compiled = function(values){ return ['"];
|
||||
body.push(this.html.replace(/(\r\n|\n)/g, '\\n').replace("'", "\\'").replace(this.re, fn));
|
||||
body.push("'].join('');};");
|
||||
body = body.join('');
|
||||
}
|
||||
eval(body);
|
||||
return this;
|
||||
},
|
||||
|
||||
// private function used to call members
|
||||
call : function(fnName, value){
|
||||
return this[fnName](value);
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies the supplied values to the template and inserts the new node(s) as the first child of el
|
||||
* @param {String/HTMLElement/Element} el The context element
|
||||
* @param {Object} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
|
||||
* @param {Boolean} returnElement (optional) true to return a Ext.Element
|
||||
* @return {HTMLElement} The new node
|
||||
*/
|
||||
insertFirst: function(el, values, returnElement){
|
||||
return this.doInsert('afterBegin', el, values, returnElement);
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies the supplied values to the template and inserts the new node(s) before el
|
||||
* @param {String/HTMLElement/Element} el The context element
|
||||
* @param {Object} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
|
||||
* @param {Boolean} returnElement (optional) true to return a Ext.Element
|
||||
* @return {HTMLElement} The new node
|
||||
*/
|
||||
insertBefore: function(el, values, returnElement){
|
||||
return this.doInsert('beforeBegin', el, values, returnElement);
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies the supplied values to the template and inserts the new node(s) after el
|
||||
* @param {String/HTMLElement/Element} el The context element
|
||||
* @param {Object} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
|
||||
* @param {Boolean} returnElement (optional) true to return a Ext.Element
|
||||
* @return {HTMLElement} The new node
|
||||
*/
|
||||
insertAfter : function(el, values, returnElement){
|
||||
return this.doInsert('afterEnd', el, values, returnElement);
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies the supplied values to the template and append the new node(s) to el
|
||||
* @param {String/HTMLElement/Element} el The context element
|
||||
* @param {Object} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
|
||||
* @param {Boolean} returnElement (optional) true to return a Ext.Element
|
||||
* @return {HTMLElement} The new node
|
||||
*/
|
||||
append : function(el, values, returnElement){
|
||||
return this.doInsert('beforeEnd', el, values, returnElement);
|
||||
},
|
||||
|
||||
doInsert : function(where, el, values, returnEl){
|
||||
el = Ext.getDom(el);
|
||||
var newNode = Ext.DomHelper.insertHtml(where, el, this.applyTemplate(values));
|
||||
return returnEl ? Ext.get(newNode, true) : newNode;
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies the supplied values to the template and overwrites the content of el with the new node(s)
|
||||
* @param {String/HTMLElement/Element} el The context element
|
||||
* @param {Object} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
|
||||
* @param {Boolean} returnElement (optional) true to return a Ext.Element
|
||||
* @return {HTMLElement} The new node
|
||||
*/
|
||||
overwrite : function(el, values, returnElement){
|
||||
el = Ext.getDom(el);
|
||||
el.innerHTML = this.applyTemplate(values);
|
||||
return returnElement ? Ext.get(el.firstChild, true) : el.firstChild;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Alias for applyTemplate
|
||||
* @method
|
||||
*/
|
||||
Ext.Template.prototype.apply = Ext.Template.prototype.applyTemplate;
|
||||
|
||||
// backwards compat
|
||||
Ext.DomHelper.Template = Ext.Template;
|
||||
|
||||
/**
|
||||
* Creates a template from the passed element's value (display:none textarea, preferred) or innerHTML
|
||||
* @param {String/HTMLElement} el
|
||||
* @static
|
||||
*/
|
||||
Ext.Template.from = function(el){
|
||||
el = Ext.getDom(el);
|
||||
return new Ext.Template(el.value || el.innerHTML);
|
||||
};
|
||||
|
||||
/**
|
||||
* @class Ext.MasterTemplate
|
||||
* @extends Ext.Template
|
||||
* Provides a template that can have child templates. The syntax is:
|
||||
<pre><code>
|
||||
var t = new Ext.MasterTemplate(
|
||||
'<select name="{name}">',
|
||||
'<tpl name="options"><option value="{value:trim}">{text:ellipsis(10)}</option></tpl>',
|
||||
'</select>'
|
||||
);
|
||||
t.add('options', {value: 'foo', text: 'bar'});
|
||||
// or you can add multiple child elements in one shot
|
||||
t.addAll('options', [
|
||||
{value: 'foo', text: 'bar'},
|
||||
{value: 'foo2', text: 'bar2'},
|
||||
{value: 'foo3', text: 'bar3'}
|
||||
]);
|
||||
// then append, applying the master template values
|
||||
t.append('my-form', {name: 'my-select'});
|
||||
</code></pre>
|
||||
* A name attribute for the child template is not required if you have only one child
|
||||
* template or you want to refer to them by index.
|
||||
*/
|
||||
Ext.MasterTemplate = function(){
|
||||
Ext.MasterTemplate.superclass.constructor.apply(this, arguments);
|
||||
this.originalHtml = this.html;
|
||||
var st = {};
|
||||
var m, re = this.subTemplateRe;
|
||||
re.lastIndex = 0;
|
||||
var subIndex = 0;
|
||||
while(m = re.exec(this.html)){
|
||||
var name = m[1], content = m[2];
|
||||
st[subIndex] = {
|
||||
name: name,
|
||||
index: subIndex,
|
||||
buffer: [],
|
||||
tpl : new Ext.Template(content)
|
||||
};
|
||||
if(name){
|
||||
st[name] = st[subIndex];
|
||||
}
|
||||
st[subIndex].tpl.compile();
|
||||
st[subIndex].tpl.call = this.call.createDelegate(this);
|
||||
subIndex++;
|
||||
}
|
||||
this.subCount = subIndex;
|
||||
this.subs = st;
|
||||
};
|
||||
Ext.extend(Ext.MasterTemplate, Ext.Template, {
|
||||
/**
|
||||
* The regular expression used to match sub templates
|
||||
* @type RegExp
|
||||
* @property
|
||||
*/
|
||||
subTemplateRe : /<tpl(?:\sname="([\w-]+)")?>((?:.|\n)*?)<\/tpl>/gi,
|
||||
|
||||
/**
|
||||
* Applies the passed values to a child template.
|
||||
* @param {String/Number} name (optional) The name or index of the child template
|
||||
* @param {Array/Object} values The values to be applied to the template
|
||||
* @return {MasterTemplate} this
|
||||
*/
|
||||
add : function(name, values){
|
||||
if(arguments.length == 1){
|
||||
values = arguments[0];
|
||||
name = 0;
|
||||
}
|
||||
var s = this.subs[name];
|
||||
s.buffer[s.buffer.length] = s.tpl.apply(values);
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies all the passed values to a child template.
|
||||
* @param {String/Number} name (optional) The name or index of the child template
|
||||
* @param {Array} values The values to be applied to the template, this should be an array of objects.
|
||||
* @param {Boolean} reset (optional) True to reset the template first
|
||||
* @return {MasterTemplate} this
|
||||
*/
|
||||
fill : function(name, values, reset){
|
||||
var a = arguments;
|
||||
if(a.length == 1 || (a.length == 2 && typeof a[1] == "boolean")){
|
||||
values = a[0];
|
||||
name = 0;
|
||||
reset = a[1];
|
||||
}
|
||||
if(reset){
|
||||
this.reset();
|
||||
}
|
||||
for(var i = 0, len = values.length; i < len; i++){
|
||||
this.add(name, values[i]);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets the template for reuse
|
||||
* @return {MasterTemplate} this
|
||||
*/
|
||||
reset : function(){
|
||||
var s = this.subs;
|
||||
for(var i = 0; i < this.subCount; i++){
|
||||
s[i].buffer = [];
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
applyTemplate : function(values){
|
||||
var s = this.subs;
|
||||
var replaceIndex = -1;
|
||||
this.html = this.originalHtml.replace(this.subTemplateRe, function(m, name){
|
||||
return s[++replaceIndex].buffer.join("");
|
||||
});
|
||||
return Ext.MasterTemplate.superclass.applyTemplate.call(this, values);
|
||||
},
|
||||
|
||||
apply : function(){
|
||||
return this.applyTemplate.apply(this, arguments);
|
||||
},
|
||||
|
||||
compile : function(){return this;}
|
||||
});
|
||||
|
||||
/**
|
||||
* Alias for fill().
|
||||
* @method
|
||||
*/
|
||||
Ext.MasterTemplate.prototype.addAll = Ext.MasterTemplate.prototype.fill;
|
||||
/**
|
||||
* Creates a template from the passed element's value (display:none textarea, preferred) or innerHTML. e.g.
|
||||
* var tpl = Ext.MasterTemplate.from('element-id');
|
||||
* @param {String/HTMLElement} el
|
||||
* @static
|
||||
*/
|
||||
Ext.MasterTemplate.from = function(el){
|
||||
el = Ext.getDom(el);
|
||||
return new Ext.MasterTemplate(el.value || el.innerHTML);
|
||||
};
|
||||
493
www/extras/yui-ext/source/core/UpdateManager.js
vendored
Normal file
493
www/extras/yui-ext/source/core/UpdateManager.js
vendored
Normal file
|
|
@ -0,0 +1,493 @@
|
|||
/*
|
||||
* Ext JS Library 1.0.1
|
||||
* Copyright(c) 2006-2007, Ext JS, LLC.
|
||||
* licensing@extjs.com
|
||||
*
|
||||
* http://www.extjs.com/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Ext.UpdateManager
|
||||
* @extends Ext.util.Observable
|
||||
* Provides AJAX-style update for Element object.<br><br>
|
||||
* Usage:<br>
|
||||
* <pre><code>
|
||||
* // Get it from a Ext.Element object
|
||||
* var el = Ext.get("foo");
|
||||
* var mgr = el.getUpdateManager();
|
||||
* mgr.update("http://myserver.com/index.php", "param1=1&param2=2");
|
||||
* ...
|
||||
* mgr.formUpdate("myFormId", "http://myserver.com/index.php");
|
||||
* <br>
|
||||
* // or directly (returns the same UpdateManager instance)
|
||||
* var mgr = new Ext.UpdateManager("myElementId");
|
||||
* mgr.startAutoRefresh(60, "http://myserver.com/index.php");
|
||||
* mgr.on("update", myFcnNeedsToKnow);
|
||||
* <br>
|
||||
// short handed call directly from the element object
|
||||
Ext.get("foo").load({
|
||||
url: "bar.php",
|
||||
scripts:true,
|
||||
params: "for=bar",
|
||||
text: "Loading Foo..."
|
||||
});
|
||||
* </code></pre>
|
||||
* @constructor
|
||||
* Create new UpdateManager directly.
|
||||
* @param {String/HTMLElement/Ext.Element} el The element to update
|
||||
* @param {Boolean} forceNew (optional) By default the constructor checks to see if the passed element already has an UpdateManager and if it does it returns the same instance. This will skip that check (useful for extending this class).
|
||||
*/
|
||||
Ext.UpdateManager = function(el, forceNew){
|
||||
el = Ext.get(el);
|
||||
if(!forceNew && el.updateManager){
|
||||
return el.updateManager;
|
||||
}
|
||||
/**
|
||||
* The Element object
|
||||
* @type Ext.Element
|
||||
*/
|
||||
this.el = el;
|
||||
/**
|
||||
* Cached url to use for refreshes. Overwritten every time update() is called unless "discardUrl" param is set to true.
|
||||
* @type String
|
||||
*/
|
||||
this.defaultUrl = null;
|
||||
|
||||
this.addEvents({
|
||||
/**
|
||||
* @event beforeupdate
|
||||
* Fired before an update is made, return false from your handler and the update is cancelled.
|
||||
* @param {Ext.Element} el
|
||||
* @param {String/Object/Function} url
|
||||
* @param {String/Object} params
|
||||
*/
|
||||
"beforeupdate": true,
|
||||
/**
|
||||
* @event update
|
||||
* Fired after successful update is made.
|
||||
* @param {Ext.Element} el
|
||||
* @param {Object} oResponseObject The response Object
|
||||
*/
|
||||
"update": true,
|
||||
/**
|
||||
* @event failure
|
||||
* Fired on update failure.
|
||||
* @param {Ext.Element} el
|
||||
* @param {Object} oResponseObject The response Object
|
||||
*/
|
||||
"failure": true
|
||||
});
|
||||
var d = Ext.UpdateManager.defaults;
|
||||
/**
|
||||
* Blank page URL to use with SSL file uploads (Defaults to Ext.UpdateManager.defaults.sslBlankUrl or "about:blank").
|
||||
* @type String
|
||||
*/
|
||||
this.sslBlankUrl = d.sslBlankUrl;
|
||||
/**
|
||||
* Whether to append unique parameter on get request to disable caching (Defaults to Ext.UpdateManager.defaults.disableCaching or false).
|
||||
* @type Boolean
|
||||
*/
|
||||
this.disableCaching = d.disableCaching;
|
||||
/**
|
||||
* Text for loading indicator (Defaults to Ext.UpdateManager.defaults.indicatorText or '<div class="loading-indicator">Loading...</div>').
|
||||
* @type String
|
||||
*/
|
||||
this.indicatorText = d.indicatorText;
|
||||
/**
|
||||
* Whether to show indicatorText when loading (Defaults to Ext.UpdateManager.defaults.showLoadIndicator or true).
|
||||
* @type String
|
||||
*/
|
||||
this.showLoadIndicator = d.showLoadIndicator;
|
||||
/**
|
||||
* Timeout for requests or form posts in seconds (Defaults to Ext.UpdateManager.defaults.timeout or 30 seconds).
|
||||
* @type Number
|
||||
*/
|
||||
this.timeout = d.timeout;
|
||||
|
||||
/**
|
||||
* True to process scripts in the output (Defaults to Ext.UpdateManager.defaults.loadScripts (false)).
|
||||
* @type Boolean
|
||||
*/
|
||||
this.loadScripts = d.loadScripts;
|
||||
|
||||
/**
|
||||
* Transaction object of current executing transaction
|
||||
*/
|
||||
this.transaction = null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
this.autoRefreshProcId = null;
|
||||
/**
|
||||
* Delegate for refresh() prebound to "this", use myUpdater.refreshDelegate.createCallback(arg1, arg2) to bind arguments
|
||||
* @type Function
|
||||
*/
|
||||
this.refreshDelegate = this.refresh.createDelegate(this);
|
||||
/**
|
||||
* Delegate for update() prebound to "this", use myUpdater.updateDelegate.createCallback(arg1, arg2) to bind arguments
|
||||
* @type Function
|
||||
*/
|
||||
this.updateDelegate = this.update.createDelegate(this);
|
||||
/**
|
||||
* Delegate for formUpdate() prebound to "this", use myUpdater.formUpdateDelegate.createCallback(arg1, arg2) to bind arguments
|
||||
* @type Function
|
||||
*/
|
||||
this.formUpdateDelegate = this.formUpdate.createDelegate(this);
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
this.successDelegate = this.processSuccess.createDelegate(this);
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
this.failureDelegate = this.processFailure.createDelegate(this);
|
||||
|
||||
/**
|
||||
* The renderer for this UpdateManager. Defaults to {@link Ext.UpdateManager.BasicRenderer}.
|
||||
*/
|
||||
this.renderer = new Ext.UpdateManager.BasicRenderer();
|
||||
|
||||
Ext.UpdateManager.superclass.constructor.call(this);
|
||||
};
|
||||
|
||||
Ext.extend(Ext.UpdateManager, Ext.util.Observable, {
|
||||
/**
|
||||
* Get the Element this UpdateManager is bound to
|
||||
* @return {Ext.Element} The element
|
||||
*/
|
||||
getEl : function(){
|
||||
return this.el;
|
||||
},
|
||||
/**
|
||||
* Performs an async request, updating this element with the response. If params are specified it uses POST, otherwise it uses GET.
|
||||
* @param {Object/String/Function} url The url for this request or a function to call to get the url or a config object containing any of the following options:
|
||||
<pre><code>
|
||||
um.update({<br/>
|
||||
url: "your-url.php",<br/>
|
||||
params: {param1: "foo", param2: "bar"}, // or a URL encoded string<br/>
|
||||
callback: yourFunction,<br/>
|
||||
scope: yourObject, //(optional scope) <br/>
|
||||
discardUrl: false, <br/>
|
||||
nocache: false,<br/>
|
||||
text: "Loading...",<br/>
|
||||
timeout: 30,<br/>
|
||||
scripts: false<br/>
|
||||
});
|
||||
</code></pre>
|
||||
* The only required property is url. The optional properties nocache, text and scripts
|
||||
* are shorthand for disableCaching, indicatorText and loadScripts and are used to set their associated property on this UpdateManager instance.
|
||||
* @param {String/Object} params (optional) The parameters to pass as either a url encoded string "param1=1&param2=2" or an object {param1: 1, param2: 2}
|
||||
* @param {Function} callback (optional) Callback when transaction is complete - called with signature (oElement, bSuccess, oResponse)
|
||||
* @param {Boolean} discardUrl (optional) By default when you execute an update the defaultUrl is changed to the last used url. If true, it will not store the url.
|
||||
*/
|
||||
update : function(url, params, callback, discardUrl){
|
||||
if(this.fireEvent("beforeupdate", this.el, url, params) !== false){
|
||||
var method = this.method;
|
||||
if(typeof url == "object"){ // must be config object
|
||||
var cfg = url;
|
||||
url = cfg.url;
|
||||
params = params || cfg.params;
|
||||
callback = callback || cfg.callback;
|
||||
discardUrl = discardUrl || cfg.discardUrl;
|
||||
if(callback && cfg.scope){
|
||||
callback = callback.createDelegate(cfg.scope);
|
||||
}
|
||||
if(typeof cfg.method != "undefined"){method = cfg.method;};
|
||||
if(typeof cfg.nocache != "undefined"){this.disableCaching = cfg.nocache;};
|
||||
if(typeof cfg.text != "undefined"){this.indicatorText = '<div class="loading-indicator">'+cfg.text+"</div>";};
|
||||
if(typeof cfg.scripts != "undefined"){this.loadScripts = cfg.scripts;};
|
||||
if(typeof cfg.timeout != "undefined"){this.timeout = cfg.timeout;};
|
||||
}
|
||||
this.showLoading();
|
||||
if(!discardUrl){
|
||||
this.defaultUrl = url;
|
||||
}
|
||||
if(typeof url == "function"){
|
||||
url = url.call(this);
|
||||
}
|
||||
if(typeof params == "function"){
|
||||
params = params();
|
||||
}
|
||||
if(params && typeof params != "string"){ // must be object
|
||||
var buf = [];
|
||||
for(var key in params){
|
||||
if(typeof params[key] != "function"){
|
||||
buf.push(encodeURIComponent(key), "=", encodeURIComponent(params[key]), "&");
|
||||
}
|
||||
}
|
||||
delete buf[buf.length-1];
|
||||
params = buf.join("");
|
||||
}
|
||||
var cb = {
|
||||
success: this.successDelegate,
|
||||
failure: this.failureDelegate,
|
||||
timeout: (this.timeout*1000),
|
||||
argument: {"url": url, "form": null, "callback": callback, "params": params}
|
||||
};
|
||||
method = method || (params ? "POST" : "GET");
|
||||
if(method == "GET"){
|
||||
url = this.prepareUrl(url);
|
||||
}
|
||||
this.transaction = Ext.lib.Ajax.request(method, url, cb, params);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Performs an async form post, updating this element with the response. If the form has the attribute enctype="multipart/form-data", it assumes it's a file upload.
|
||||
* Uses this.sslBlankUrl for SSL file uploads to prevent IE security warning. See YUI docs for more info.
|
||||
* @param {String/HTMLElement} form The form Id or form element
|
||||
* @param {String} url (optional) The url to pass the form to. If omitted the action attribute on the form will be used.
|
||||
* @param {Boolean} reset (optional) Whether to try to reset the form after the update
|
||||
* @param {Function} callback (optional) Callback when transaction is complete - called with signature (oElement, bSuccess, oResponse)
|
||||
*/
|
||||
formUpdate : function(form, url, reset, callback){
|
||||
if(this.fireEvent("beforeupdate", this.el, form, url) !== false){
|
||||
formEl = Ext.getDom(form);
|
||||
if(typeof url == "function"){
|
||||
url = url.call(this);
|
||||
}
|
||||
if(typeof params == "function"){
|
||||
params = params();
|
||||
}
|
||||
url = url || formEl.action;
|
||||
var cb = {
|
||||
success: this.successDelegate,
|
||||
failure: this.failureDelegate,
|
||||
timeout: (this.timeout*1000),
|
||||
argument: {"url": url, "form": formEl, "callback": callback, "reset": reset}
|
||||
};
|
||||
var isUpload = false;
|
||||
var enctype = formEl.getAttribute("enctype");
|
||||
if(enctype && enctype.toLowerCase() == "multipart/form-data"){
|
||||
isUpload = true;
|
||||
cb.upload = this.successDelegate;
|
||||
}
|
||||
this.transaction = Ext.lib.Ajax.formRequest(formEl, url, cb, null, isUpload, this.sslBlankUrl);
|
||||
this.showLoading.defer(1, this);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Refresh the element with the last used url or defaultUrl. If there is no url, it returns immediately
|
||||
* @param {Function} callback (optional) Callback when transaction is complete - called with signature (oElement, bSuccess)
|
||||
*/
|
||||
refresh : function(callback){
|
||||
if(this.defaultUrl == null){
|
||||
return;
|
||||
}
|
||||
this.update(this.defaultUrl, null, callback, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Set this element to auto refresh.
|
||||
* @param {Number} interval How often to update (in seconds).
|
||||
* @param {String/Function} url (optional) The url for this request or a function to call to get the url (Defaults to the last used url)
|
||||
* @param {String/Object} params (optional) The parameters to pass as either a url encoded string "¶m1=1¶m2=2" or as an object {param1: 1, param2: 2}
|
||||
* @param {Function} callback (optional) Callback when transaction is complete - called with signature (oElement, bSuccess)
|
||||
* @param {Boolean} refreshNow (optional) Whether to execute the refresh now, or wait the interval
|
||||
*/
|
||||
startAutoRefresh : function(interval, url, params, callback, refreshNow){
|
||||
if(refreshNow){
|
||||
this.update(url || this.defaultUrl, params, callback, true);
|
||||
}
|
||||
if(this.autoRefreshProcId){
|
||||
clearInterval(this.autoRefreshProcId);
|
||||
}
|
||||
this.autoRefreshProcId = setInterval(this.update.createDelegate(this, [url || this.defaultUrl, params, callback, true]), interval*1000);
|
||||
},
|
||||
|
||||
/**
|
||||
* Stop auto refresh on this element.
|
||||
*/
|
||||
stopAutoRefresh : function(){
|
||||
if(this.autoRefreshProcId){
|
||||
clearInterval(this.autoRefreshProcId);
|
||||
delete this.autoRefreshProcId;
|
||||
}
|
||||
},
|
||||
|
||||
isAutoRefreshing : function(){
|
||||
return this.autoRefreshProcId ? true : false;
|
||||
},
|
||||
/**
|
||||
* Called to update the element to "Loading" state. Override to perform custom action.
|
||||
*/
|
||||
showLoading : function(){
|
||||
if(this.showLoadIndicator){
|
||||
this.el.update(this.indicatorText);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds unique parameter to query string if disableCaching = true
|
||||
* @private
|
||||
*/
|
||||
prepareUrl : function(url){
|
||||
if(this.disableCaching){
|
||||
var append = "_dc=" + (new Date().getTime());
|
||||
if(url.indexOf("?") !== -1){
|
||||
url += "&" + append;
|
||||
}else{
|
||||
url += "?" + append;
|
||||
}
|
||||
}
|
||||
return url;
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
processSuccess : function(response){
|
||||
this.transaction = null;
|
||||
if(response.argument.form && response.argument.reset){
|
||||
try{ // put in try/catch since some older FF releases had problems with this
|
||||
response.argument.form.reset();
|
||||
}catch(e){}
|
||||
}
|
||||
if(this.loadScripts){
|
||||
this.renderer.render(this.el, response, this,
|
||||
this.updateComplete.createDelegate(this, [response]));
|
||||
}else{
|
||||
this.renderer.render(this.el, response, this);
|
||||
this.updateComplete(response);
|
||||
}
|
||||
},
|
||||
|
||||
updateComplete : function(response){
|
||||
this.fireEvent("update", this.el, response);
|
||||
if(typeof response.argument.callback == "function"){
|
||||
response.argument.callback(this.el, true, response);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
processFailure : function(response){
|
||||
this.transaction = null;
|
||||
this.fireEvent("failure", this.el, response);
|
||||
if(typeof response.argument.callback == "function"){
|
||||
response.argument.callback(this.el, false, response);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the content renderer for this UpdateManager. See {@link Ext.UpdateManager.BasicRenderer#render} for more details.
|
||||
* @param {Object} renderer The object implementing the render() method
|
||||
*/
|
||||
setRenderer : function(renderer){
|
||||
this.renderer = renderer;
|
||||
},
|
||||
|
||||
getRenderer : function(){
|
||||
return this.renderer;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the defaultUrl used for updates
|
||||
* @param {String/Function} defaultUrl The url or a function to call to get the url
|
||||
*/
|
||||
setDefaultUrl : function(defaultUrl){
|
||||
this.defaultUrl = defaultUrl;
|
||||
},
|
||||
|
||||
/**
|
||||
* Aborts the executing transaction
|
||||
*/
|
||||
abort : function(){
|
||||
if(this.transaction){
|
||||
Ext.lib.Ajax.abort(this.transaction);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns true if an update is in progress
|
||||
* @return {Boolean}
|
||||
*/
|
||||
isUpdating : function(){
|
||||
if(this.transaction){
|
||||
return Ext.lib.Ajax.isCallInProgress(this.transaction);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @class Ext.UpdateManager.defaults
|
||||
* The defaults collection enables customizing the default properties of UpdateManager
|
||||
*/
|
||||
Ext.UpdateManager.defaults = {
|
||||
/**
|
||||
* Timeout for requests or form posts in seconds (Defaults 30 seconds).
|
||||
* @type Number
|
||||
*/
|
||||
timeout : 30,
|
||||
|
||||
/**
|
||||
* True to process scripts by default (Defaults to false).
|
||||
* @type Boolean
|
||||
*/
|
||||
loadScripts : false,
|
||||
|
||||
/**
|
||||
* Blank page URL to use with SSL file uploads (Defaults to "javascript:false").
|
||||
* @type String
|
||||
*/
|
||||
sslBlankUrl : (Ext.SSL_SECURE_URL || "javascript:false"),
|
||||
/**
|
||||
* Whether to append unique parameter on get request to disable caching (Defaults to false).
|
||||
* @type Boolean
|
||||
*/
|
||||
disableCaching : false,
|
||||
/**
|
||||
* Whether to show indicatorText when loading (Defaults to true).
|
||||
* @type Boolean
|
||||
*/
|
||||
showLoadIndicator : true,
|
||||
/**
|
||||
* Text for loading indicator (Defaults to '<div class="loading-indicator">Loading...</div>').
|
||||
* @type String
|
||||
*/
|
||||
indicatorText : '<div class="loading-indicator">Loading...</div>'
|
||||
};
|
||||
|
||||
/**
|
||||
* Static convenience method. This method is deprecated in favor of el.load({url:'foo.php', ...}).
|
||||
*Usage:
|
||||
* <pre><code>Ext.UpdateManager.updateElement("my-div", "stuff.php");</code></pre>
|
||||
* @param {String/HTMLElement/Ext.Element} el The element to update
|
||||
* @param {String} url The url
|
||||
* @param {String/Object} params (optional) Url encoded param string or an object of name/value pairs
|
||||
* @param {Object} options (optional) A config object with any of the UpdateManager properties you want to set - for example: {disableCaching:true, indicatorText: "Loading data..."}
|
||||
* @static
|
||||
* @deprecated
|
||||
* @member Ext.UpdateManager
|
||||
*/
|
||||
Ext.UpdateManager.updateElement = function(el, url, params, options){
|
||||
var um = Ext.get(el, true).getUpdateManager();
|
||||
Ext.apply(um, options);
|
||||
um.update(url, params, options ? options.callback : null);
|
||||
};
|
||||
// alias for backwards compat
|
||||
Ext.UpdateManager.update = Ext.UpdateManager.updateElement;
|
||||
/**
|
||||
* @class Ext.UpdateManager.BasicRenderer
|
||||
* Default Content renderer. Updates the elements innerHTML with the responseText.
|
||||
*/
|
||||
Ext.UpdateManager.BasicRenderer = function(){};
|
||||
|
||||
Ext.UpdateManager.BasicRenderer.prototype = {
|
||||
/**
|
||||
* This is called when the transaction is completed and it's time to update the element - The BasicRenderer
|
||||
* updates the elements innerHTML with the responseText - To perform a custom render (i.e. XML or JSON processing),
|
||||
* create an object with a "render(el, response)" method and pass it to setRenderer on the UpdateManager.
|
||||
* @param {Ext.Element} el The element being rendered
|
||||
* @param {Object} response The YUI Connect response object
|
||||
* @param {UpdateManager} updateManager The calling update manager
|
||||
* @param {Function} callback A callback that will need to be called if loadScripts is true on the UpdateManager
|
||||
*/
|
||||
render : function(el, response, updateManager, callback){
|
||||
el.update(response.responseText, updateManager.loadScripts, callback);
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue