CompositeElement.html 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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-dom-CompositeElement'>/**
  19. </span> * @class Ext.dom.CompositeElement
  20. * &lt;p&gt;This class encapsulates a &lt;i&gt;collection&lt;/i&gt; of DOM elements, providing methods to filter
  21. * members, or to perform collective actions upon the whole set.&lt;/p&gt;
  22. * &lt;p&gt;Although they are not listed, this class supports all of the methods of {@link Ext.dom.Element} and
  23. * {@link Ext.fx.Anim}. The methods from these classes will be performed on all the elements in this collection.&lt;/p&gt;
  24. * &lt;p&gt;All methods return &lt;i&gt;this&lt;/i&gt; and can be chained.&lt;/p&gt;
  25. * Usage:
  26. &lt;pre&gt;&lt;code&gt;
  27. var els = Ext.select(&quot;#some-el div.some-class&quot;, true);
  28. // or select directly from an existing element
  29. var el = Ext.get('some-el');
  30. el.select('div.some-class', true);
  31. els.setWidth(100); // all elements become 100 width
  32. els.hide(true); // all elements fade out and hide
  33. // or
  34. els.setWidth(100).hide(true);
  35. &lt;/code&gt;&lt;/pre&gt;
  36. */
  37. Ext.define('Ext.dom.CompositeElement', {
  38. alternateClassName: 'Ext.CompositeElement',
  39. extend: 'Ext.dom.CompositeElementLite',
  40. // private
  41. getElement: function(el) {
  42. // In this case just return it, since we already have a reference to it
  43. return el;
  44. },
  45. // private
  46. transformElement: function(el) {
  47. return Ext.get(el);
  48. }
  49. }, function() {
  50. <span id='Ext-dom-Element-static-method-select'> /**
  51. </span> * Selects elements based on the passed CSS selector to enable {@link Ext.Element Element} methods
  52. * to be applied to many related elements in one statement through the returned {@link Ext.CompositeElement CompositeElement} or
  53. * {@link Ext.CompositeElementLite CompositeElementLite} object.
  54. * @param {String/HTMLElement[]} selector The CSS selector or an array of elements
  55. * @param {Boolean} [unique] true to create a unique Ext.Element for each element (defaults to a shared flyweight object)
  56. * @param {HTMLElement/String} [root] The root element of the query or id of the root
  57. * @return {Ext.CompositeElementLite/Ext.CompositeElement}
  58. * @member Ext.dom.Element
  59. * @method select
  60. * @static
  61. */
  62. Ext.dom.Element.select = function(selector, unique, root) {
  63. var elements;
  64. if (typeof selector == &quot;string&quot;) {
  65. elements = Ext.dom.Element.selectorFunction(selector, root);
  66. }
  67. else if (selector.length !== undefined) {
  68. elements = selector;
  69. }
  70. else {
  71. //&lt;debug&gt;
  72. throw new Error(&quot;[Ext.select] Invalid selector specified: &quot; + selector);
  73. //&lt;/debug&gt;
  74. }
  75. return (unique === true) ? new Ext.CompositeElement(elements) : new Ext.CompositeElementLite(elements);
  76. };
  77. });
  78. <span id='Ext-method-select'>/**
  79. </span> * Shorthand of {@link Ext.Element#method-select}.
  80. * @member Ext
  81. * @method select
  82. * @inheritdoc Ext.Element#select
  83. */
  84. Ext.select = Ext.Element.select;
  85. </pre>
  86. </body>
  87. </html>