/** * @namespace jvm Holds core methods and classes used by jVectorMap. */ var jvm = { /** * Inherits child's prototype from the parent's one. * @param {Function} child * @param {Function} parent */ inherits: function(child, parent) { function temp() {} temp.prototype = parent.prototype; child.prototype = new temp(); child.prototype.constructor = child; child.parentClass = parent; }, /** * Mixes in methods from the source constructor to the target one. * @param {Function} target * @param {Function} source */ mixin: function(target, source){ var prop; for (prop in source.prototype) { if (source.prototype.hasOwnProperty(prop)) { target.prototype[prop] = source.prototype[prop]; } } }, min: function(values){ var min = Number.MAX_VALUE, i; if (values instanceof Array) { for (i = 0; i < values.length; i++) { if (values[i] < min) { min = values[i]; } } } else { for (i in values) { if (values[i] < min) { min = values[i]; } } } return min; }, max: function(values){ var max = Number.MIN_VALUE, i; if (values instanceof Array) { for (i = 0; i < values.length; i++) { if (values[i] > max) { max = values[i]; } } } else { for (i in values) { if (values[i] > max) { max = values[i]; } } } return max; }, keys: function(object){ var keys = [], key; for (key in object) { keys.push(key); } return keys; }, values: function(object){ var values = [], key, i; for (i = 0; i < arguments.length; i++) { object = arguments[i]; for (key in object) { values.push(object[key]); } } return values; } }; jvm.$ = jQuery;