| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 | <!DOCTYPE html><html><head>  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  <title>The source code</title>  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>  <style type="text/css">    .highlight { display: block; background-color: #ddd; }  </style>  <script type="text/javascript">    function highlight() {      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";    }  </script></head><body onload="prettyPrint(); highlight();">  <pre class="prettyprint lang-js"><span id='Ext-dom-AbstractElement'>/**</span> * @class Ext.dom.AbstractElement */Ext.dom.AbstractElement.override({<span id='Ext-dom-AbstractElement-method-findParent'>    /**</span>     * Looks at this node and then at parent nodes for a match of the passed simple selector (e.g. div.some-class or span:first-child)     * @param {String} selector The simple selector to test     * @param {Number/String/HTMLElement/Ext.Element} [limit]     * The max depth to search as a number or an element which causes the upward traversal to stop     * and is <b>not</b> considered for inclusion as the result. (defaults to 50 || document.documentElement)     * @param {Boolean} [returnEl=false] True to return a Ext.Element object instead of DOM node     * @return {HTMLElement} The matching DOM node (or null if no match was found)     */    findParent: function(simpleSelector, limit, returnEl) {        var target = this.dom,            topmost = document.documentElement,            depth = 0,            stopEl;        limit = limit || 50;        if (isNaN(limit)) {            stopEl = Ext.getDom(limit);            limit = Number.MAX_VALUE;        }        while (target && target.nodeType == 1 && depth < limit && target != topmost && target != stopEl) {            if (Ext.DomQuery.is(target, simpleSelector)) {                return returnEl ? Ext.get(target) : target;            }            depth++;            target = target.parentNode;        }        return null;    },<span id='Ext-dom-AbstractElement-method-findParentNode'>    /**</span>     * Looks at parent nodes for a match of the passed simple selector (e.g. div.some-class or span:first-child)     * @param {String} selector The simple selector to test     * @param {Number/String/HTMLElement/Ext.Element} [limit]     * The max depth to search as a number or an element which causes the upward traversal to stop     * and is <b>not</b> considered for inclusion as the result. (defaults to 50 || document.documentElement)     * @param {Boolean} [returnEl=false] True to return a Ext.Element object instead of DOM node     * @return {HTMLElement} The matching DOM node (or null if no match was found)     */    findParentNode: function(simpleSelector, limit, returnEl) {        var p = Ext.fly(this.dom.parentNode, '_internal');        return p ? p.findParent(simpleSelector, limit, returnEl) : null;    },<span id='Ext-dom-AbstractElement-method-up'>    /**</span>     * Walks up the dom looking for a parent node that matches the passed simple selector (e.g. div.some-class or span:first-child).     * This is a shortcut for findParentNode() that always returns an Ext.dom.Element.     * @param {String} selector The simple selector to test     * @param {Number/String/HTMLElement/Ext.Element} [limit]     * The max depth to search as a number or an element which causes the upward traversal to stop     * and is <b>not</b> considered for inclusion as the result. (defaults to 50 || document.documentElement)     * @return {Ext.Element} The matching DOM node (or null if no match was found)     */    up: function(simpleSelector, limit) {        return this.findParentNode(simpleSelector, limit, true);    },<span id='Ext-dom-AbstractElement-method-select'>    /**</span>     * Creates a {@link Ext.CompositeElement} for child nodes based on the passed CSS selector (the selector should not contain an id).     * @param {String} selector The CSS selector     * @param {Boolean} [unique] True to create a unique Ext.Element for each element. Defaults to a shared flyweight object.     * @return {Ext.CompositeElement} The composite element     */    select: function(selector, composite) {        return Ext.dom.Element.select(selector, this.dom, composite);    },<span id='Ext-dom-AbstractElement-method-query'>    /**</span>     * Selects child nodes based on the passed CSS selector (the selector should not contain an id).     * @param {String} selector The CSS selector     * @return {HTMLElement[]} An array of the matched nodes     */    query: function(selector) {        return Ext.DomQuery.select(selector, this.dom);    },<span id='Ext-dom-AbstractElement-method-down'>    /**</span>     * Selects a single child at any depth below this element based on the passed CSS selector (the selector should not contain an id).     * @param {String} selector The CSS selector     * @param {Boolean} [returnDom=false] True to return the DOM node instead of Ext.dom.Element     * @return {HTMLElement/Ext.dom.Element} The child Ext.dom.Element (or DOM node if returnDom = true)     */    down: function(selector, returnDom) {        var n = Ext.DomQuery.selectNode(selector, this.dom);        return returnDom ? n : Ext.get(n);    },<span id='Ext-dom-AbstractElement-method-child'>    /**</span>     * Selects a single *direct* child based on the passed CSS selector (the selector should not contain an id).     * @param {String} selector The CSS selector     * @param {Boolean} [returnDom=false] True to return the DOM node instead of Ext.dom.Element.     * @return {HTMLElement/Ext.dom.Element} The child Ext.dom.Element (or DOM node if returnDom = true)     */    child: function(selector, returnDom) {        var node,            me = this,            id;        // Pull the ID from the DOM (Ext.id also ensures that there *is* an ID).        // If this object is a Flyweight, it will not have an ID        id = Ext.id(me.dom);        // Escape "invalid" chars        id = Ext.escapeId(id);        node = Ext.DomQuery.selectNode('#' + id + " > " + selector, me.dom);        return returnDom ? node : Ext.get(node);    },<span id='Ext-dom-AbstractElement-method-parent'>     /**</span>     * Gets the parent node for this element, optionally chaining up trying to match a selector     * @param {String} [selector] Find a parent node that matches the passed simple selector     * @param {Boolean} [returnDom=false] True to return a raw dom node instead of an Ext.dom.Element     * @return {Ext.dom.Element/HTMLElement} The parent node or null     */    parent: function(selector, returnDom) {        return this.matchNode('parentNode', 'parentNode', selector, returnDom);    },<span id='Ext-dom-AbstractElement-method-next'>     /**</span>     * Gets the next sibling, skipping text nodes     * @param {String} [selector] Find the next sibling that matches the passed simple selector     * @param {Boolean} [returnDom=false] True to return a raw dom node instead of an Ext.dom.Element     * @return {Ext.dom.Element/HTMLElement} The next sibling or null     */    next: function(selector, returnDom) {        return this.matchNode('nextSibling', 'nextSibling', selector, returnDom);    },<span id='Ext-dom-AbstractElement-method-prev'>    /**</span>     * Gets the previous sibling, skipping text nodes     * @param {String} [selector] Find the previous sibling that matches the passed simple selector     * @param {Boolean} [returnDom=false] True to return a raw dom node instead of an Ext.dom.Element     * @return {Ext.dom.Element/HTMLElement} The previous sibling or null     */    prev: function(selector, returnDom) {        return this.matchNode('previousSibling', 'previousSibling', selector, returnDom);    },<span id='Ext-dom-AbstractElement-method-first'>    /**</span>     * Gets the first child, skipping text nodes     * @param {String} [selector] Find the next sibling that matches the passed simple selector     * @param {Boolean} [returnDom=false] True to return a raw dom node instead of an Ext.dom.Element     * @return {Ext.dom.Element/HTMLElement} The first child or null     */    first: function(selector, returnDom) {        return this.matchNode('nextSibling', 'firstChild', selector, returnDom);    },<span id='Ext-dom-AbstractElement-method-last'>    /**</span>     * Gets the last child, skipping text nodes     * @param {String} [selector] Find the previous sibling that matches the passed simple selector     * @param {Boolean} [returnDom=false] True to return a raw dom node instead of an Ext.dom.Element     * @return {Ext.dom.Element/HTMLElement} The last child or null     */    last: function(selector, returnDom) {        return this.matchNode('previousSibling', 'lastChild', selector, returnDom);    },    matchNode: function(dir, start, selector, returnDom) {        if (!this.dom) {            return null;        }        var n = this.dom[start];        while (n) {            if (n.nodeType == 1 && (!selector || Ext.DomQuery.is(n, selector))) {                return !returnDom ? Ext.get(n) : n;            }            n = n[dir];        }        return null;    },    isAncestor: function(element) {        return this.self.isAncestor.call(this.self, this.dom, element);    }});</pre></body></html>
 |