for (var i = 0; i < depends.length; i++) {
var istat = true,
- reverse = false;
+ reverse = depends[i]['!reverse'],
+ contains = depends[i]['!contains'];
for (var dep in depends[i]) {
- if (dep == '!reverse') {
- reverse = true;
+ if (dep == '!reverse' || dep == '!contains') {
+ continue;
}
else if (dep == '!default') {
def = true;
var res = this.lookupOption(dep, section_id, config_name),
val = (res && res[0].isActive(res[1])) ? res[0].formvalue(res[1]) : null;
- istat = (istat && isEqual(val, depends[i][dep]));
+ var equal = contains
+ ? isContained(val, depends[i][dep])
+ : isEqual(val, depends[i][dep]);
+
+ istat = (istat && equal);
}
}
return true;
};
+var isContained = function(x, y) {
+ if (Array.isArray(x)) {
+ for (var i = 0; i < x.length; i++)
+ if (x[i] == y)
+ return true;
+ }
+ else if (L.isObject(x)) {
+ if (x.hasOwnProperty(y) && x[y] != null)
+ return true;
+ }
+ else if (typeof(x) == 'string') {
+ return (x.indexOf(y) > -1);
+ }
+
+ return false;
+};
+
var CBIAbstractValue = CBINode.extend({
__init__: function(map, section, option /*, ... */) {
this.super('__init__', this.varargs(arguments, 3));