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.

129 lines
5.9 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-CompositeElement'>/**
  19. </span> * @class Ext.CompositeElement
  20. * @extends Ext.CompositeElementLite
  21. * &lt;p&gt;This class encapsulates a &lt;i&gt;collection&lt;/i&gt; of DOM elements, providing methods to filter
  22. * members, or to perform collective actions upon the whole set.&lt;/p&gt;
  23. * &lt;p&gt;Although they are not listed, this class supports all of the methods of {@link Ext.Element} and
  24. * {@link Ext.Fx}. The methods from these classes will be performed on all the elements in this collection.&lt;/p&gt;
  25. * &lt;p&gt;All methods return &lt;i&gt;this&lt;/i&gt; and can be chained.&lt;/p&gt;
  26. * Usage:
  27. &lt;pre&gt;&lt;code&gt;
  28. var els = Ext.select(&quot;#some-el div.some-class&quot;, true);
  29. // or select directly from an existing element
  30. var el = Ext.get('some-el');
  31. el.select('div.some-class', true);
  32. els.setWidth(100); // all elements become 100 width
  33. els.hide(true); // all elements fade out and hide
  34. // or
  35. els.setWidth(100).hide(true);
  36. &lt;/code&gt;&lt;/pre&gt;
  37. */
  38. Ext.CompositeElement = Ext.extend(Ext.CompositeElementLite, {
  39. <span id='Ext-CompositeElement-method-constructor'> constructor : function(els, root){
  40. </span> this.elements = [];
  41. this.add(els, root);
  42. },
  43. <span id='Ext-CompositeElement-method-getElement'> // private
  44. </span> getElement : function(el){
  45. // In this case just return it, since we already have a reference to it
  46. return el;
  47. },
  48. <span id='Ext-CompositeElement-method-transformElement'> // private
  49. </span> transformElement : function(el){
  50. return Ext.get(el);
  51. }
  52. <span id='global-method-'> /**
  53. </span> * Adds elements to this composite.
  54. * @param {String/Array} els A string CSS selector, an array of elements or an element
  55. * @return {CompositeElement} this
  56. * @ignore
  57. */
  58. <span id='global-method-'> /**
  59. </span> * Returns the Element object at the specified index
  60. * @param {Number} index
  61. * @return {Ext.Element}
  62. * @ignore
  63. */
  64. <span id='global-method-'> /**
  65. </span> * Iterates each &lt;code&gt;element&lt;/code&gt; in this &lt;code&gt;composite&lt;/code&gt;
  66. * calling the supplied function using {@link Ext#each}.
  67. * @param {Function} fn The function to be called with each
  68. * &lt;code&gt;element&lt;/code&gt;. If the supplied function returns &lt;tt&gt;false&lt;/tt&gt;,
  69. * iteration stops. This function is called with the following arguments:
  70. * &lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
  71. * &lt;li&gt;&lt;code&gt;element&lt;/code&gt; : &lt;i&gt;Ext.Element&lt;/i&gt;&lt;div class=&quot;sub-desc&quot;&gt;The element at the current &lt;code&gt;index&lt;/code&gt;
  72. * in the &lt;code&gt;composite&lt;/code&gt;&lt;/div&gt;&lt;/li&gt;
  73. * &lt;li&gt;&lt;code&gt;composite&lt;/code&gt; : &lt;i&gt;Object&lt;/i&gt; &lt;div class=&quot;sub-desc&quot;&gt;This composite.&lt;/div&gt;&lt;/li&gt;
  74. * &lt;li&gt;&lt;code&gt;index&lt;/code&gt; : &lt;i&gt;Number&lt;/i&gt; &lt;div class=&quot;sub-desc&quot;&gt;The current index within the &lt;code&gt;composite&lt;/code&gt; &lt;/div&gt;&lt;/li&gt;
  75. * &lt;/ul&gt;&lt;/div&gt;
  76. * @param {Object} scope (optional) The scope (&lt;code&gt;&lt;this&lt;/code&gt; reference) in which the specified function is executed.
  77. * Defaults to the &lt;code&gt;element&lt;/code&gt; at the current &lt;code&gt;index&lt;/code&gt;
  78. * within the composite.
  79. * @return {CompositeElement} this
  80. * @ignore
  81. */
  82. });
  83. <span id='Ext-Element-static-method-select'>/**
  84. </span> * Selects elements based on the passed CSS selector to enable {@link Ext.Element Element} methods
  85. * to be applied to many related elements in one statement through the returned {@link Ext.CompositeElement CompositeElement} or
  86. * {@link Ext.CompositeElementLite CompositeElementLite} object.
  87. * @param {String/Array} selector The CSS selector or an array of elements
  88. * @param {Boolean} unique (optional) true to create a unique Ext.Element for each element (defaults to a shared flyweight object)
  89. * @param {HTMLElement/String} root (optional) The root element of the query or id of the root
  90. * @return {CompositeElementLite/CompositeElement}
  91. * @member Ext.Element
  92. * @method select
  93. * @static
  94. */
  95. Ext.Element.select = function(selector, unique, root){
  96. var els;
  97. if(typeof selector == &quot;string&quot;){
  98. els = Ext.Element.selectorFunction(selector, root);
  99. }else if(selector.length !== undefined){
  100. els = selector;
  101. }else{
  102. throw &quot;Invalid selector&quot;;
  103. }
  104. return (unique === true) ? new Ext.CompositeElement(els) : new Ext.CompositeElementLite(els);
  105. };
  106. <span id='Ext-method-select'>/**
  107. </span> * Selects elements based on the passed CSS selector to enable {@link Ext.Element Element} methods
  108. * to be applied to many related elements in one statement through the returned {@link Ext.CompositeElement CompositeElement} or
  109. * {@link Ext.CompositeElementLite CompositeElementLite} object.
  110. * @param {String/Array} selector The CSS selector or an array of elements
  111. * @param {Boolean} unique (optional) true to create a unique Ext.Element for each element (defaults to a shared flyweight object)
  112. * @param {HTMLElement/String} root (optional) The root element of the query or id of the root
  113. * @return {CompositeElementLite/CompositeElement}
  114. * @member Ext
  115. * @method select
  116. */
  117. Ext.select = Ext.Element.select;</pre>
  118. </body>
  119. </html>