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:
+3
-12
@@ -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;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user