Adding OpenLayers.Array.filter to mimic Array.prototype.filter. Adding panel.getControlsBy and related methods that use filter. Reworking map.getBy to use filter as well. r=elemoine (closes #1203)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@5532 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-12-20 08:12:19 +00:00
parent c44b028a30
commit 36e04a689f
5 changed files with 214 additions and 12 deletions
+3 -12
View File
@@ -475,19 +475,10 @@ OpenLayers.Map = OpenLayers.Class({
* criteria.
*/
getBy: function(array, property, match) {
var found = [];
var item;
var list = this[array];
var test = (typeof match.test == "function");
if(list instanceof Array) {
for(var i=0; i<list.length; ++i) {
item = list[i];
if(item[property] == match ||
(test && match.test(item[property]))) {
found.push(item);
}
}
}
var found = OpenLayers.Array.filter(this[array], function(item) {
return item[property] == match || (test && match.test(item[property]));
});
return found;
},