Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

184 lines
8.3 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>The source code</title>
  5. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  6. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  7. </head>
  8. <body onload="prettyPrint();">
  9. <pre class="prettyprint lang-js">/*!
  10. * Ext JS Library 3.3.1
  11. * Copyright(c) 2006-2010 Sencha Inc.
  12. * licensing@sencha.com
  13. * http://www.sencha.com/license
  14. */
  15. <div id="cls-Ext.Element"></div>/**
  16. * @class Ext.Element
  17. */
  18. Ext.Element.addMethods(function(){
  19. var PARENTNODE = 'parentNode',
  20. NEXTSIBLING = 'nextSibling',
  21. PREVIOUSSIBLING = 'previousSibling',
  22. DQ = Ext.DomQuery,
  23. GET = Ext.get;
  24. return {
  25. <div id="method-Ext.Element-findParent"></div>/**
  26. * 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)
  27. * @param {String} selector The simple selector to test
  28. * @param {Number/Mixed} maxDepth (optional) The max depth to search as a number or element (defaults to 50 || document.body)
  29. * @param {Boolean} returnEl (optional) True to return a Ext.Element object instead of DOM node
  30. * @return {HTMLElement} The matching DOM node (or null if no match was found)
  31. */
  32. findParent : function(simpleSelector, maxDepth, returnEl){
  33. var p = this.dom,
  34. b = document.body,
  35. depth = 0,
  36. stopEl;
  37. if(Ext.isGecko && Object.prototype.toString.call(p) == '[object XULElement]') {
  38. return null;
  39. }
  40. maxDepth = maxDepth || 50;
  41. if (isNaN(maxDepth)) {
  42. stopEl = Ext.getDom(maxDepth);
  43. maxDepth = Number.MAX_VALUE;
  44. }
  45. while(p && p.nodeType == 1 && depth < maxDepth && p != b && p != stopEl){
  46. if(DQ.is(p, simpleSelector)){
  47. return returnEl ? GET(p) : p;
  48. }
  49. depth++;
  50. p = p.parentNode;
  51. }
  52. return null;
  53. },
  54. <div id="method-Ext.Element-findParentNode"></div>/**
  55. * Looks at parent nodes for a match of the passed simple selector (e.g. div.some-class or span:first-child)
  56. * @param {String} selector The simple selector to test
  57. * @param {Number/Mixed} maxDepth (optional) The max depth to
  58. search as a number or element (defaults to 10 || document.body)
  59. * @param {Boolean} returnEl (optional) True to return a Ext.Element object instead of DOM node
  60. * @return {HTMLElement} The matching DOM node (or null if no match was found)
  61. */
  62. findParentNode : function(simpleSelector, maxDepth, returnEl){
  63. var p = Ext.fly(this.dom.parentNode, '_internal');
  64. return p ? p.findParent(simpleSelector, maxDepth, returnEl) : null;
  65. },
  66. <div id="method-Ext.Element-up"></div>/**
  67. * Walks up the dom looking for a parent node that matches the passed simple selector (e.g. div.some-class or span:first-child).
  68. * This is a shortcut for findParentNode() that always returns an Ext.Element.
  69. * @param {String} selector The simple selector to test
  70. * @param {Number/Mixed} maxDepth (optional) The max depth to
  71. search as a number or element (defaults to 10 || document.body)
  72. * @return {Ext.Element} The matching DOM node (or null if no match was found)
  73. */
  74. up : function(simpleSelector, maxDepth){
  75. return this.findParentNode(simpleSelector, maxDepth, true);
  76. },
  77. <div id="method-Ext.Element-select"></div>/**
  78. * Creates a {@link Ext.CompositeElement} for child nodes based on the passed CSS selector (the selector should not contain an id).
  79. * @param {String} selector The CSS selector
  80. * @return {CompositeElement/CompositeElementLite} The composite element
  81. */
  82. select : function(selector){
  83. return Ext.Element.select(selector, this.dom);
  84. },
  85. <div id="method-Ext.Element-query"></div>/**
  86. * Selects child nodes based on the passed CSS selector (the selector should not contain an id).
  87. * @param {String} selector The CSS selector
  88. * @return {Array} An array of the matched nodes
  89. */
  90. query : function(selector){
  91. return DQ.select(selector, this.dom);
  92. },
  93. <div id="method-Ext.Element-child"></div>/**
  94. * Selects a single child at any depth below this element based on the passed CSS selector (the selector should not contain an id).
  95. * @param {String} selector The CSS selector
  96. * @param {Boolean} returnDom (optional) True to return the DOM node instead of Ext.Element (defaults to false)
  97. * @return {HTMLElement/Ext.Element} The child Ext.Element (or DOM node if returnDom = true)
  98. */
  99. child : function(selector, returnDom){
  100. var n = DQ.selectNode(selector, this.dom);
  101. return returnDom ? n : GET(n);
  102. },
  103. <div id="method-Ext.Element-down"></div>/**
  104. * Selects a single *direct* child based on the passed CSS selector (the selector should not contain an id).
  105. * @param {String} selector The CSS selector
  106. * @param {Boolean} returnDom (optional) True to return the DOM node instead of Ext.Element (defaults to false)
  107. * @return {HTMLElement/Ext.Element} The child Ext.Element (or DOM node if returnDom = true)
  108. */
  109. down : function(selector, returnDom){
  110. var n = DQ.selectNode(" > " + selector, this.dom);
  111. return returnDom ? n : GET(n);
  112. },
  113. <div id="method-Ext.Element-parent"></div>/**
  114. * Gets the parent node for this element, optionally chaining up trying to match a selector
  115. * @param {String} selector (optional) Find a parent node that matches the passed simple selector
  116. * @param {Boolean} returnDom (optional) True to return a raw dom node instead of an Ext.Element
  117. * @return {Ext.Element/HTMLElement} The parent node or null
  118. */
  119. parent : function(selector, returnDom){
  120. return this.matchNode(PARENTNODE, PARENTNODE, selector, returnDom);
  121. },
  122. <div id="method-Ext.Element-next"></div>/**
  123. * Gets the next sibling, skipping text nodes
  124. * @param {String} selector (optional) Find the next sibling that matches the passed simple selector
  125. * @param {Boolean} returnDom (optional) True to return a raw dom node instead of an Ext.Element
  126. * @return {Ext.Element/HTMLElement} The next sibling or null
  127. */
  128. next : function(selector, returnDom){
  129. return this.matchNode(NEXTSIBLING, NEXTSIBLING, selector, returnDom);
  130. },
  131. <div id="method-Ext.Element-prev"></div>/**
  132. * Gets the previous sibling, skipping text nodes
  133. * @param {String} selector (optional) Find the previous sibling that matches the passed simple selector
  134. * @param {Boolean} returnDom (optional) True to return a raw dom node instead of an Ext.Element
  135. * @return {Ext.Element/HTMLElement} The previous sibling or null
  136. */
  137. prev : function(selector, returnDom){
  138. return this.matchNode(PREVIOUSSIBLING, PREVIOUSSIBLING, selector, returnDom);
  139. },
  140. <div id="method-Ext.Element-first"></div>/**
  141. * Gets the first child, skipping text nodes
  142. * @param {String} selector (optional) Find the next sibling that matches the passed simple selector
  143. * @param {Boolean} returnDom (optional) True to return a raw dom node instead of an Ext.Element
  144. * @return {Ext.Element/HTMLElement} The first child or null
  145. */
  146. first : function(selector, returnDom){
  147. return this.matchNode(NEXTSIBLING, 'firstChild', selector, returnDom);
  148. },
  149. <div id="method-Ext.Element-last"></div>/**
  150. * Gets the last child, skipping text nodes
  151. * @param {String} selector (optional) Find the previous sibling that matches the passed simple selector
  152. * @param {Boolean} returnDom (optional) True to return a raw dom node instead of an Ext.Element
  153. * @return {Ext.Element/HTMLElement} The last child or null
  154. */
  155. last : function(selector, returnDom){
  156. return this.matchNode(PREVIOUSSIBLING, 'lastChild', selector, returnDom);
  157. },
  158. matchNode : function(dir, start, selector, returnDom){
  159. var n = this.dom[start];
  160. while(n){
  161. if(n.nodeType == 1 && (!selector || DQ.is(n, selector))){
  162. return !returnDom ? GET(n) : n;
  163. }
  164. n = n[dir];
  165. }
  166. return null;
  167. }
  168. };
  169. }());</pre>
  170. </body>
  171. </html>