todo/public/vendor/jvectormap/lib/jvectormap.js
Supan Adit Pratama 35d8715ab4 first commit
2020-06-23 11:40:37 +07:00

99 lines
1.9 KiB
JavaScript
Executable File
Vendored

/**
* @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;