From 2223fcfd2b27cc5f39d76c0388c39d46bc73d758 Mon Sep 17 00:00:00 2001 From: rolux Date: Fri, 26 Oct 2012 17:27:15 +0200 Subject: [PATCH] In Ox.api, add support for values that are arrays --- source/Ox/js/Array.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/source/Ox/js/Array.js b/source/Ox/js/Array.js index 5e520fed..5d4dd14a 100644 --- a/source/Ox/js/Array.js +++ b/source/Ox/js/Array.js @@ -363,10 +363,18 @@ Ox.api = function(items, options) { test = { '=': function(a, b) { return Ox.isArray(b) ? a >= b[0] && a < b[1] + : Ox.isArray(a) ? a.some(function(value) { + return value.indexOf(b) > -1; + }) : Ox.isString(a) ? a.indexOf(b) > -1 : a === b; }, - '==': function(a, b) { return a === b; }, + '==': function(a, b) { + return Ox.isArray(a) ? a.some(function(value) { + return value === b; + }) + : a === b; + }, '<': function(a, b) { return a < b; }, '<=': function(a, b) { return a <= b; }, '>': function(a, b) { return a > b; }, @@ -376,6 +384,10 @@ Ox.api = function(items, options) { }; if (Ox.isString(itemValue)) { itemValue = itemValue.toLowerCase(); + } else if (Ox.isArray(itemValue) && Ox.isString(itemValue[0])) { + itemValue = itemValue.map(function(value) { + return value.toLowerCase(); + }); } if (api.enums[key] && ( operator.indexOf('<') > -1