1Sys.ComponentSet = function ComponentSet(elementSet, query, index) { 2 this._elementSet = elementSet || (elementSet = new Sys.ElementSet()); 3 this._components = this._execute(elementSet, query, index); 4} 5 6Sys.ComponentSet.prototype = { 7 __class: true, 8 setProperties: function ComponentSet$setProperties(properties) { 9 // Sets properties on the matched components. 10 // "properties" - object with the names and values of the properties to set. 11 return this.each(function() { 12 Sys._set(this, properties); 13 }); 14 }, 15 16 get: function ComponentSet$get(index) { 17 // Returns the component at the specified index, or an array of all matches if not specified. 18 var components = this._components; 19 20 return (typeof (index) === "undefined") ? (Array.apply(null, components)) : (components[index || 0] || null); 21 }, 22 23 each: function ComponentSet$each(callback) { 24 // Enumerate all the found components. The index of the component are passed as parameters to a callback. You may return 'false' to cancel the enumeration. 25 // "callback" - function called for each component. 26 foreach(this._components, function(c, i) { 27 if(callback.call(c, i) === false) 28 return true; 29 }); 30 31 return this; 32 }, 33 34 elements: function ComponentSet$elements() { 35 // Returns the underlying set of elements this component collection came from. 36 return this._elementSet; 37 }, 38 39 _execute: function ComponentSet$_execute(elementSet, query, index) { 40 var components = []; 41 function match(c) { 42 var ctor; 43 return (c instanceof query) || 44 ((ctor = c.constructor) && ( 45 (ctor === query) || 46 (ctor.inheritsFrom && ctor.inheritsFrom(query)) || 47 (ctor.implementsInterface && ctor.implementsInterface(query)))); 48 } 49 50 if(query instanceof Array) 51 components.push.apply(components, query); 52 else 53 // query is a type or not set 54 elementSet.each(function() { 55 var c = this.control; 56 57 if(c && (!query || match(c))) 58 components.push(c); 59 60 foreach(this._behaviors, function(b) { 61 if(!query || match(b)) 62 components.push(b); 63 }); 64 }); 65 66 if((typeof (index) !== "undefined")) { 67 if(components[index]) 68 components = [components[index]]; 69 else 70 components = []; 71 } 72 73 return components; 74 } 75}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.