jvectormap.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * @namespace jvm Holds core methods and classes used by jVectorMap.
  3. */
  4. var jvm = {
  5. /**
  6. * Inherits child's prototype from the parent's one.
  7. * @param {Function} child
  8. * @param {Function} parent
  9. */
  10. inherits: function(child, parent) {
  11. function temp() {}
  12. temp.prototype = parent.prototype;
  13. child.prototype = new temp();
  14. child.prototype.constructor = child;
  15. child.parentClass = parent;
  16. },
  17. /**
  18. * Mixes in methods from the source constructor to the target one.
  19. * @param {Function} target
  20. * @param {Function} source
  21. */
  22. mixin: function(target, source){
  23. var prop;
  24. for (prop in source.prototype) {
  25. if (source.prototype.hasOwnProperty(prop)) {
  26. target.prototype[prop] = source.prototype[prop];
  27. }
  28. }
  29. },
  30. min: function(values){
  31. var min = Number.MAX_VALUE,
  32. i;
  33. if (values instanceof Array) {
  34. for (i = 0; i < values.length; i++) {
  35. if (values[i] < min) {
  36. min = values[i];
  37. }
  38. }
  39. } else {
  40. for (i in values) {
  41. if (values[i] < min) {
  42. min = values[i];
  43. }
  44. }
  45. }
  46. return min;
  47. },
  48. max: function(values){
  49. var max = Number.MIN_VALUE,
  50. i;
  51. if (values instanceof Array) {
  52. for (i = 0; i < values.length; i++) {
  53. if (values[i] > max) {
  54. max = values[i];
  55. }
  56. }
  57. } else {
  58. for (i in values) {
  59. if (values[i] > max) {
  60. max = values[i];
  61. }
  62. }
  63. }
  64. return max;
  65. },
  66. keys: function(object){
  67. var keys = [],
  68. key;
  69. for (key in object) {
  70. keys.push(key);
  71. }
  72. return keys;
  73. },
  74. values: function(object){
  75. var values = [],
  76. key,
  77. i;
  78. for (i = 0; i < arguments.length; i++) {
  79. object = arguments[i];
  80. for (key in object) {
  81. values.push(object[key]);
  82. }
  83. }
  84. return values;
  85. }
  86. };
  87. jvm.$ = jQuery;