diff --git a/misc/states.js b/misc/states.js index b01bc2b..1d2fdae 100644 --- a/misc/states.js +++ b/misc/states.js @@ -63,7 +63,23 @@ states.Dependent.comparisons = { 'Function': function (reference, value) { // The "reference" variable is a comparison function. return reference(value); - } + }, + 'Array': function (reference, value) { + //Make sure that value is an array, other wise we end up always evaling to true + if (!(typeof(value) == 'object' && (value instanceof Array))) { + return false; + } + //We iterate through each of the values provided in the reference + //and check that they all exist in the value array. + //If even one doesn't then we return false. Otherwise return true. + var arrayComplies = true; + $.each(reference, function(key, val) { + if ($.inArray(val, value) < 0) { + arrayComplies = false; + } + }); + return arrayComplies; + }, }; states.Dependent.prototype = {