From 6fcfb7c04d32e1c8b26a312295bf7ac3ec2d2ad7 Mon Sep 17 00:00:00 2001
From: Marvin Borner
Date: Fri, 13 Jul 2018 19:06:45 +0200
Subject: Fixed many permissions and began admin interface
---
.../jvectormap/src/abstract-canvas-element.js | 93 ++
.../jvectormap/src/abstract-element.js | 73 ++
.../jvectormap/src/abstract-shape-element.js | 62 +
.../bower_components/jvectormap/src/color-scale.js | 44 +
.../bower_components/jvectormap/src/data-series.js | 158 +++
.../bower_components/jvectormap/src/jvectormap.js | 185 +++
public/bower_components/jvectormap/src/legend.js | 83 ++
.../bower_components/jvectormap/src/map-object.js | 73 ++
public/bower_components/jvectormap/src/map.js | 1186 ++++++++++++++++++++
public/bower_components/jvectormap/src/marker.js | 76 ++
public/bower_components/jvectormap/src/multimap.js | 139 +++
.../jvectormap/src/numeric-scale.js | 185 +++
.../jvectormap/src/ordinal-scale.js | 21 +
public/bower_components/jvectormap/src/proj.js | 181 +++
public/bower_components/jvectormap/src/region.js | 45 +
.../jvectormap/src/simple-scale.js | 7 +
.../jvectormap/src/svg-canvas-element.js | 26 +
.../jvectormap/src/svg-circle-element.js | 5 +
.../bower_components/jvectormap/src/svg-element.js | 48 +
.../jvectormap/src/svg-group-element.js | 9 +
.../jvectormap/src/svg-image-element.js | 36 +
.../jvectormap/src/svg-path-element.js | 6 +
.../jvectormap/src/svg-shape-element.js | 49 +
.../jvectormap/src/svg-text-element.js | 13 +
.../jvectormap/src/vector-canvas.js | 18 +
.../jvectormap/src/vml-canvas-element.js | 45 +
.../jvectormap/src/vml-circle-element.js | 26 +
.../bower_components/jvectormap/src/vml-element.js | 107 ++
.../jvectormap/src/vml-group-element.js | 13 +
.../jvectormap/src/vml-image-element.js | 47 +
.../jvectormap/src/vml-path-element.js | 98 ++
.../jvectormap/src/vml-shape-element.js | 49 +
32 files changed, 3206 insertions(+)
create mode 100644 public/bower_components/jvectormap/src/abstract-canvas-element.js
create mode 100644 public/bower_components/jvectormap/src/abstract-element.js
create mode 100644 public/bower_components/jvectormap/src/abstract-shape-element.js
create mode 100644 public/bower_components/jvectormap/src/color-scale.js
create mode 100644 public/bower_components/jvectormap/src/data-series.js
create mode 100644 public/bower_components/jvectormap/src/jvectormap.js
create mode 100644 public/bower_components/jvectormap/src/legend.js
create mode 100644 public/bower_components/jvectormap/src/map-object.js
create mode 100644 public/bower_components/jvectormap/src/map.js
create mode 100644 public/bower_components/jvectormap/src/marker.js
create mode 100644 public/bower_components/jvectormap/src/multimap.js
create mode 100644 public/bower_components/jvectormap/src/numeric-scale.js
create mode 100644 public/bower_components/jvectormap/src/ordinal-scale.js
create mode 100644 public/bower_components/jvectormap/src/proj.js
create mode 100644 public/bower_components/jvectormap/src/region.js
create mode 100644 public/bower_components/jvectormap/src/simple-scale.js
create mode 100644 public/bower_components/jvectormap/src/svg-canvas-element.js
create mode 100644 public/bower_components/jvectormap/src/svg-circle-element.js
create mode 100644 public/bower_components/jvectormap/src/svg-element.js
create mode 100644 public/bower_components/jvectormap/src/svg-group-element.js
create mode 100644 public/bower_components/jvectormap/src/svg-image-element.js
create mode 100644 public/bower_components/jvectormap/src/svg-path-element.js
create mode 100644 public/bower_components/jvectormap/src/svg-shape-element.js
create mode 100644 public/bower_components/jvectormap/src/svg-text-element.js
create mode 100644 public/bower_components/jvectormap/src/vector-canvas.js
create mode 100644 public/bower_components/jvectormap/src/vml-canvas-element.js
create mode 100644 public/bower_components/jvectormap/src/vml-circle-element.js
create mode 100644 public/bower_components/jvectormap/src/vml-element.js
create mode 100644 public/bower_components/jvectormap/src/vml-group-element.js
create mode 100644 public/bower_components/jvectormap/src/vml-image-element.js
create mode 100644 public/bower_components/jvectormap/src/vml-path-element.js
create mode 100644 public/bower_components/jvectormap/src/vml-shape-element.js
(limited to 'public/bower_components/jvectormap/src')
diff --git a/public/bower_components/jvectormap/src/abstract-canvas-element.js b/public/bower_components/jvectormap/src/abstract-canvas-element.js
new file mode 100644
index 0000000..de8d30d
--- /dev/null
+++ b/public/bower_components/jvectormap/src/abstract-canvas-element.js
@@ -0,0 +1,93 @@
+/**
+ * Implements abstract vector canvas.
+ * @constructor
+ * @param {HTMLElement} container Container to put element to.
+ * @param {Number} width Width of canvas.
+ * @param {Number} height Height of canvas.
+ */
+jvm.AbstractCanvasElement = function(container, width, height){
+ this.container = container;
+ this.setSize(width, height);
+ this.rootElement = new jvm[this.classPrefix+'GroupElement']();
+ this.node.appendChild( this.rootElement.node );
+ this.container.appendChild(this.node);
+}
+
+/**
+ * Add element to the certain group inside of the canvas.
+ * @param {HTMLElement} element Element to add to canvas.
+ * @param {HTMLElement} group Group to add element into or into root group if not provided.
+ */
+jvm.AbstractCanvasElement.prototype.add = function(element, group){
+ group = group || this.rootElement;
+ group.add(element);
+ element.canvas = this;
+}
+
+/**
+ * Create path and add it to the canvas.
+ * @param {Object} config Parameters of path to create.
+ * @param {Object} style Styles of the path to create.
+ * @param {HTMLElement} group Group to add path into.
+ */
+jvm.AbstractCanvasElement.prototype.addPath = function(config, style, group){
+ var el = new jvm[this.classPrefix+'PathElement'](config, style);
+
+ this.add(el, group);
+ return el;
+};
+
+/**
+ * Create circle and add it to the canvas.
+ * @param {Object} config Parameters of path to create.
+ * @param {Object} style Styles of the path to create.
+ * @param {HTMLElement} group Group to add circle into.
+ */
+jvm.AbstractCanvasElement.prototype.addCircle = function(config, style, group){
+ var el = new jvm[this.classPrefix+'CircleElement'](config, style);
+
+ this.add(el, group);
+ return el;
+};
+
+/**
+ * Create circle and add it to the canvas.
+ * @param {Object} config Parameters of path to create.
+ * @param {Object} style Styles of the path to create.
+ * @param {HTMLElement} group Group to add circle into.
+ */
+jvm.AbstractCanvasElement.prototype.addImage = function(config, style, group){
+ var el = new jvm[this.classPrefix+'ImageElement'](config, style);
+
+ this.add(el, group);
+ return el;
+};
+
+/**
+ * Create text and add it to the canvas.
+ * @param {Object} config Parameters of path to create.
+ * @param {Object} style Styles of the path to create.
+ * @param {HTMLElement} group Group to add circle into.
+ */
+jvm.AbstractCanvasElement.prototype.addText = function(config, style, group){
+ var el = new jvm[this.classPrefix+'TextElement'](config, style);
+
+ this.add(el, group);
+ return el;
+};
+
+/**
+ * Add group to the another group inside of the canvas.
+ * @param {HTMLElement} group Group to add circle into or root group if not provided.
+ */
+jvm.AbstractCanvasElement.prototype.addGroup = function(parentGroup){
+ var el = new jvm[this.classPrefix+'GroupElement']();
+
+ if (parentGroup) {
+ parentGroup.node.appendChild(el.node);
+ } else {
+ this.node.appendChild(el.node);
+ }
+ el.canvas = this;
+ return el;
+};
\ No newline at end of file
diff --git a/public/bower_components/jvectormap/src/abstract-element.js b/public/bower_components/jvectormap/src/abstract-element.js
new file mode 100644
index 0000000..e393491
--- /dev/null
+++ b/public/bower_components/jvectormap/src/abstract-element.js
@@ -0,0 +1,73 @@
+/**
+ * Basic wrapper for DOM element.
+ * @constructor
+ * @param {String} name Tag name of the element
+ * @param {Object} config Set of parameters to initialize element with
+ */
+jvm.AbstractElement = function(name, config){
+ /**
+ * Underlying DOM element
+ * @type {DOMElement}
+ * @private
+ */
+ this.node = this.createElement(name);
+
+ /**
+ * Name of underlying element
+ * @type {String}
+ * @private
+ */
+ this.name = name;
+
+ /**
+ * Internal store of attributes
+ * @type {Object}
+ * @private
+ */
+ this.properties = {};
+
+ if (config) {
+ this.set(config);
+ }
+};
+
+/**
+ * Set attribute of the underlying DOM element.
+ * @param {String} name Name of attribute
+ * @param {Number|String} config Set of parameters to initialize element with
+ */
+jvm.AbstractElement.prototype.set = function(property, value){
+ var key;
+
+ if (typeof property === 'object') {
+ for (key in property) {
+ this.properties[key] = property[key];
+ this.applyAttr(key, property[key]);
+ }
+ } else {
+ this.properties[property] = value;
+ this.applyAttr(property, value);
+ }
+};
+
+/**
+ * Returns value of attribute.
+ * @param {String} name Name of attribute
+ */
+jvm.AbstractElement.prototype.get = function(property){
+ return this.properties[property];
+};
+
+/**
+ * Applies attribute value to the underlying DOM element.
+ * @param {String} name Name of attribute
+ * @param {Number|String} config Value of attribute to apply
+ * @private
+ */
+jvm.AbstractElement.prototype.applyAttr = function(property, value){
+ this.node.setAttribute(property, value);
+};
+
+jvm.AbstractElement.prototype.remove = function(){
+ jvm.$(this.node).remove();
+};
\ No newline at end of file
diff --git a/public/bower_components/jvectormap/src/abstract-shape-element.js b/public/bower_components/jvectormap/src/abstract-shape-element.js
new file mode 100644
index 0000000..9a2419a
--- /dev/null
+++ b/public/bower_components/jvectormap/src/abstract-shape-element.js
@@ -0,0 +1,62 @@
+/**
+ * Abstract shape element. Shape element represents some visual vector or raster object.
+ * @constructor
+ * @param {String} name Tag name of the element.
+ * @param {Object} config Set of parameters to initialize element with.
+ * @param {Object} style Object with styles to set on element initialization.
+ */
+jvm.AbstractShapeElement = function(name, config, style){
+ this.style = style || {};
+ this.style.current = this.style.current || {};
+ this.isHovered = false;
+ this.isSelected = false;
+ this.updateStyle();
+};
+
+/**
+ * Set element's style.
+ * @param {Object|String} property Could be string to set only one property or object to set several style properties at once.
+ * @param {String} value Value to set in case only one property should be set.
+ */
+jvm.AbstractShapeElement.prototype.setStyle = function(property, value){
+ var styles = {};
+
+ if (typeof property === 'object') {
+ styles = property;
+ } else {
+ styles[property] = value;
+ }
+ jvm.$.extend(this.style.current, styles);
+ this.updateStyle();
+};
+
+
+jvm.AbstractShapeElement.prototype.updateStyle = function(){
+ var attrs = {};
+
+ jvm.AbstractShapeElement.mergeStyles(attrs, this.style.initial);
+ jvm.AbstractShapeElement.mergeStyles(attrs, this.style.current);
+ if (this.isHovered) {
+ jvm.AbstractShapeElement.mergeStyles(attrs, this.style.hover);
+ }
+ if (this.isSelected) {
+ jvm.AbstractShapeElement.mergeStyles(attrs, this.style.selected);
+ if (this.isHovered) {
+ jvm.AbstractShapeElement.mergeStyles(attrs, this.style.selectedHover);
+ }
+ }
+ this.set(attrs);
+};
+
+jvm.AbstractShapeElement.mergeStyles = function(styles, newStyles){
+ var key;
+
+ newStyles = newStyles || {};
+ for (key in newStyles) {
+ if (newStyles[key] === null) {
+ delete styles[key];
+ } else {
+ styles[key] = newStyles[key];
+ }
+ }
+}
\ No newline at end of file
diff --git a/public/bower_components/jvectormap/src/color-scale.js b/public/bower_components/jvectormap/src/color-scale.js
new file mode 100644
index 0000000..899a09b
--- /dev/null
+++ b/public/bower_components/jvectormap/src/color-scale.js
@@ -0,0 +1,44 @@
+jvm.ColorScale = function(colors, normalizeFunction, minValue, maxValue) {
+ jvm.ColorScale.parentClass.apply(this, arguments);
+}
+
+jvm.inherits(jvm.ColorScale, jvm.NumericScale);
+
+jvm.ColorScale.prototype.setScale = function(scale) {
+ var i;
+
+ for (i = 0; i < scale.length; i++) {
+ this.scale[i] = jvm.ColorScale.rgbToArray(scale[i]);
+ }
+};
+
+jvm.ColorScale.prototype.getValue = function(value) {
+ return jvm.ColorScale.numToRgb(jvm.ColorScale.parentClass.prototype.getValue.call(this, value));
+};
+
+jvm.ColorScale.arrayToRgb = function(ar) {
+ var rgb = '#',
+ d,
+ i;
+
+ for (i = 0; i < ar.length; i++) {
+ d = ar[i].toString(16);
+ rgb += d.length == 1 ? '0'+d : d;
+ }
+ return rgb;
+};
+
+jvm.ColorScale.numToRgb = function(num) {
+ num = num.toString(16);
+
+ while (num.length < 6) {
+ num = '0' + num;
+ }
+
+ return '#'+num;
+};
+
+jvm.ColorScale.rgbToArray = function(rgb) {
+ rgb = rgb.substr(1);
+ return [parseInt(rgb.substr(0, 2), 16), parseInt(rgb.substr(2, 2), 16), parseInt(rgb.substr(4, 2), 16)];
+};
\ No newline at end of file
diff --git a/public/bower_components/jvectormap/src/data-series.js b/public/bower_components/jvectormap/src/data-series.js
new file mode 100644
index 0000000..2cb0be0
--- /dev/null
+++ b/public/bower_components/jvectormap/src/data-series.js
@@ -0,0 +1,158 @@
+/**
+ * Creates data series.
+ * @constructor
+ * @param {Object} params Parameters to initialize series with.
+ * @param {Array} params.values The data set to visualize.
+ * @param {String} params.attribute Numberic or color attribute to use for data visualization. This could be: fill
, stroke
, fill-opacity
, stroke-opacity
for markers and regions and r
(radius) for markers only.
+ * @param {Array} params.scale Values used to map a dimension of data to a visual representation. The first value sets visualization for minimum value from the data set and the last value sets visualization for the maximum value. There also could be intermidiate values. Default value is ['#C8EEFF', '#0071A4']
+ * @param {Function|String} params.normalizeFunction The function used to map input values to the provided scale. This parameter could be provided as function or one of the strings: 'linear'
or 'polynomial'
, while 'linear'
is used by default. The function provided takes value from the data set as an input and returns corresponding value from the scale.
+ * @param {Number} params.min Minimum value of the data set. Could be calculated automatically if not provided.
+ * @param {Number} params.min Maximum value of the data set. Could be calculated automatically if not provided.
+ */
+jvm.DataSeries = function(params, elements, map) {
+ var scaleConstructor;
+
+ params = params || {};
+ params.attribute = params.attribute || 'fill';
+
+ this.elements = elements;
+ this.params = params;
+ this.map = map;
+
+ if (params.attributes) {
+ this.setAttributes(params.attributes);
+ }
+
+ if (jvm.$.isArray(params.scale)) {
+ scaleConstructor = (params.attribute === 'fill' || params.attribute === 'stroke') ? jvm.ColorScale : jvm.NumericScale;
+ this.scale = new scaleConstructor(params.scale, params.normalizeFunction, params.min, params.max);
+ } else if (params.scale) {
+ this.scale = new jvm.OrdinalScale(params.scale);
+ } else {
+ this.scale = new jvm.SimpleScale(params.scale);
+ }
+
+ this.values = params.values || {};
+ this.setValues(this.values);
+
+ if (this.params.legend) {
+ this.legend = new jvm.Legend($.extend({
+ map: this.map,
+ series: this
+ }, this.params.legend))
+ }
+};
+
+jvm.DataSeries.prototype = {
+ setAttributes: function(key, attr){
+ var attrs = key,
+ code;
+
+ if (typeof key == 'string') {
+ if (this.elements[key]) {
+ this.elements[key].setStyle(this.params.attribute, attr);
+ }
+ } else {
+ for (code in attrs) {
+ if (this.elements[code]) {
+ this.elements[code].element.setStyle(this.params.attribute, attrs[code]);
+ }
+ }
+ }
+ },
+
+ /**
+ * Set values for the data set.
+ * @param {Object} values Object which maps codes of regions or markers to values.
+ */
+ setValues: function(values) {
+ var max = -Number.MAX_VALUE,
+ min = Number.MAX_VALUE,
+ val,
+ cc,
+ attrs = {};
+
+ if (!(this.scale instanceof jvm.OrdinalScale) && !(this.scale instanceof jvm.SimpleScale)) {
+ // we have a color scale as an array
+ if (typeof this.params.min === 'undefined' || typeof this.params.max === 'undefined') {
+ // min and/or max are not defined, so calculate them
+ for (cc in values) {
+ val = parseFloat(values[cc]);
+ if (val > max) max = val;
+ if (val < min) min = val;
+ }
+ }
+
+ if (typeof this.params.min === 'undefined') {
+ this.scale.setMin(min);
+ this.params.min = min;
+ } else {
+ this.scale.setMin(this.params.min);
+ }
+
+ if (typeof this.params.max === 'undefined') {
+ this.scale.setMax(max);
+ this.params.max = max;
+ } else {
+ this.scale.setMax(this.params.max);
+ }
+
+ for (cc in values) {
+ if (cc != 'indexOf') {
+ val = parseFloat(values[cc]);
+ if (!isNaN(val)) {
+ attrs[cc] = this.scale.getValue(val);
+ } else {
+ attrs[cc] = this.elements[cc].element.style.initial[this.params.attribute];
+ }
+ }
+ }
+ } else {
+ for (cc in values) {
+ if (values[cc]) {
+ attrs[cc] = this.scale.getValue(values[cc]);
+ } else {
+ attrs[cc] = this.elements[cc].element.style.initial[this.params.attribute];
+ }
+ }
+ }
+
+ this.setAttributes(attrs);
+ jvm.$.extend(this.values, values);
+ },
+
+ clear: function(){
+ var key,
+ attrs = {};
+
+ for (key in this.values) {
+ if (this.elements[key]) {
+ attrs[key] = this.elements[key].element.shape.style.initial[this.params.attribute];
+ }
+ }
+ this.setAttributes(attrs);
+ this.values = {};
+ },
+
+ /**
+ * Set scale of the data series.
+ * @param {Array} scale Values representing scale.
+ */
+ setScale: function(scale) {
+ this.scale.setScale(scale);
+ if (this.values) {
+ this.setValues(this.values);
+ }
+ },
+
+ /**
+ * Set normalize function of the data series.
+ * @param {Function|String} normilizeFunction.
+ */
+ setNormalizeFunction: function(f) {
+ this.scale.setNormalizeFunction(f);
+ if (this.values) {
+ this.setValues(this.values);
+ }
+ }
+};
diff --git a/public/bower_components/jvectormap/src/jvectormap.js b/public/bower_components/jvectormap/src/jvectormap.js
new file mode 100644
index 0000000..b44897c
--- /dev/null
+++ b/public/bower_components/jvectormap/src/jvectormap.js
@@ -0,0 +1,185 @@
+/**
+ * @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;
+ },
+
+ whenImageLoaded: function(url){
+ var deferred = new jvm.$.Deferred(),
+ img = jvm.$('');
+
+ img.error(function(){
+ deferred.reject();
+ }).load(function(){
+ deferred.resolve(img);
+ });
+ img.attr('src', url);
+
+ return deferred;
+ },
+
+ isImageUrl: function(s){
+ return /\.\w{3,4}$/.test(s);
+ }
+};
+
+jvm.$ = jQuery;
+
+/**
+ * indexOf polyfill for IE < 9
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
+ */
+if (!Array.prototype.indexOf) {
+ Array.prototype.indexOf = function (searchElement, fromIndex) {
+
+ var k;
+
+ // 1. Let O be the result of calling ToObject passing
+ // the this value as the argument.
+ if (this == null) {
+ throw new TypeError('"this" is null or not defined');
+ }
+
+ var O = Object(this);
+
+ // 2. Let lenValue be the result of calling the Get
+ // internal method of O with the argument "length".
+ // 3. Let len be ToUint32(lenValue).
+ var len = O.length >>> 0;
+
+ // 4. If len is 0, return -1.
+ if (len === 0) {
+ return -1;
+ }
+
+ // 5. If argument fromIndex was passed let n be
+ // ToInteger(fromIndex); else let n be 0.
+ var n = +fromIndex || 0;
+
+ if (Math.abs(n) === Infinity) {
+ n = 0;
+ }
+
+ // 6. If n >= len, return -1.
+ if (n >= len) {
+ return -1;
+ }
+
+ // 7. If n >= 0, then Let k be n.
+ // 8. Else, n<0, Let k be len - abs(n).
+ // If k is less than 0, then let k be 0.
+ k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
+
+ // 9. Repeat, while k < len
+ while (k < len) {
+ // a. Let Pk be ToString(k).
+ // This is implicit for LHS operands of the in operator
+ // b. Let kPresent be the result of calling the
+ // HasProperty internal method of O with argument Pk.
+ // This step can be combined with c
+ // c. If kPresent is true, then
+ // i. Let elementK be the result of calling the Get
+ // internal method of O with the argument ToString(k).
+ // ii. Let same be the result of applying the
+ // Strict Equality Comparison Algorithm to
+ // searchElement and elementK.
+ // iii. If same is true, return k.
+ if (k in O && O[k] === searchElement) {
+ return k;
+ }
+ k++;
+ }
+ return -1;
+ };
+}
\ No newline at end of file
diff --git a/public/bower_components/jvectormap/src/legend.js b/public/bower_components/jvectormap/src/legend.js
new file mode 100644
index 0000000..fdc3177
--- /dev/null
+++ b/public/bower_components/jvectormap/src/legend.js
@@ -0,0 +1,83 @@
+/**
+ * Represents map legend.
+ * @constructor
+ * @param {Object} params Configuration parameters.
+ * @param {String} params.cssClass Additional CSS class to apply to legend element.
+ * @param {Boolean} params.vertical If
true
legend will be rendered as vertical.
+ * @param {String} params.title Legend title.
+ * @param {Function} params.labelRender Method to convert series values to legend labels.
+ */
+jvm.Legend = function(params) {
+ this.params = params || {};
+ this.map = this.params.map;
+ this.series = this.params.series;
+ this.body = jvm.$('
true
to make element hovered, false
otherwise.
+ */
+jvm.MapObject.prototype.setHovered = function(isHovered){
+ if (this.isHovered !== isHovered) {
+ this.isHovered = isHovered;
+ this.shape.isHovered = isHovered;
+ this.shape.updateStyle();
+ if (this.label) {
+ this.label.isHovered = isHovered;
+ this.label.updateStyle();
+ }
+ }
+};
+
+/**
+ * Set selected state to the element. Styles will be updates respectively.
+ * @param {Boolean} isSelected true
to make element selected, false
otherwise.
+ */
+jvm.MapObject.prototype.setSelected = function(isSelected){
+ if (this.isSelected !== isSelected) {
+ this.isSelected = isSelected;
+ this.shape.isSelected = isSelected;
+ this.shape.updateStyle();
+ if (this.label) {
+ this.label.isSelected = isSelected;
+ this.label.updateStyle();
+ }
+ jvm.$(this.shape).trigger('selected', [isSelected]);
+ }
+};
+
+jvm.MapObject.prototype.setStyle = function(){
+ this.shape.setStyle.apply(this.shape, arguments);
+};
+
+jvm.MapObject.prototype.remove = function(){
+ this.shape.remove();
+ if (this.label) {
+ this.label.remove();
+ }
+};
\ No newline at end of file
diff --git a/public/bower_components/jvectormap/src/map.js b/public/bower_components/jvectormap/src/map.js
new file mode 100644
index 0000000..a9f26eb
--- /dev/null
+++ b/public/bower_components/jvectormap/src/map.js
@@ -0,0 +1,1186 @@
+/**
+ * Creates map, draws paths, binds events.
+ * @constructor
+ * @param {Object} params Parameters to initialize map with.
+ * @param {String} params.map Name of the map in the format territory_proj_lang
where territory
is a unique code or name of the territory which the map represents (ISO 3166 standard is used where possible), proj
is a name of projection used to generate representation of the map on the plane (projections are named according to the conventions of proj4 utility) and lang
is a code of the language, used for the names of regions.
+ * @param {String} params.backgroundColor Background color of the map in CSS format.
+ * @param {Boolean} params.zoomOnScroll When set to true map could be zoomed using mouse scroll. Default value is true
.
+ * @param {Boolean} params.zoomOnScrollSpeed Mouse scroll speed. Number from 1 to 10. Default value is 3
.
+ * @param {Boolean} params.panOnDrag When set to true, the map pans when being dragged. Default value is true
.
+ * @param {Number} params.zoomMax Indicates the maximum zoom ratio which could be reached zooming the map. Default value is 8
.
+ * @param {Number} params.zoomMin Indicates the minimum zoom ratio which could be reached zooming the map. Default value is 1
.
+ * @param {Number} params.zoomStep Indicates the multiplier used to zoom map with +/- buttons. Default value is 1.6
.
+ * @param {Boolean} params.zoomAnimate Indicates whether or not to animate changing of map zoom with zoom buttons.
+ * @param {Boolean} params.regionsSelectable When set to true regions of the map could be selected. Default value is false
.
+ * @param {Boolean} params.regionsSelectableOne Allow only one region to be selected at the moment. Default value is false
.
+ * @param {Boolean} params.markersSelectable When set to true markers on the map could be selected. Default value is false
.
+ * @param {Boolean} params.markersSelectableOne Allow only one marker to be selected at the moment. Default value is false
.
+ * @param {Object} params.regionStyle Set the styles for the map's regions. Each region or marker has four states: initial
(default state), hover
(when the mouse cursor is over the region or marker), selected
(when region or marker is selected), selectedHover
(when the mouse cursor is over the region or marker and it's selected simultaneously). Styles could be set for each of this states. Default value for that parameter is:
+{ + initial: { + fill: 'white', + "fill-opacity": 1, + stroke: 'none', + "stroke-width": 0, + "stroke-opacity": 1 + }, + hover: { + "fill-opacity": 0.8, + cursor: 'pointer' + }, + selected: { + fill: 'yellow' + }, + selectedHover: { + } +}+* @param {Object} params.regionLabelStyle Set the styles for the regions' labels. Each region or marker has four states:
initial
(default state), hover
(when the mouse cursor is over the region or marker), selected
(when region or marker is selected), selectedHover
(when the mouse cursor is over the region or marker and it's selected simultaneously). Styles could be set for each of this states. Default value for that parameter is:
+{ + initial: { + 'font-family': 'Verdana', + 'font-size': '12', + 'font-weight': 'bold', + cursor: 'default', + fill: 'black' + }, + hover: { + cursor: 'pointer' + } +}+ * @param {Object} params.markerStyle Set the styles for the map's markers. Any parameter suitable for
regionStyle
could be used as well as numeric parameter r
to set the marker's radius. Default value for that parameter is:
+{ + initial: { + fill: 'grey', + stroke: '#505050', + "fill-opacity": 1, + "stroke-width": 1, + "stroke-opacity": 1, + r: 5 + }, + hover: { + stroke: 'black', + "stroke-width": 2, + cursor: 'pointer' + }, + selected: { + fill: 'blue' + }, + selectedHover: { + } +}+ * @param {Object} params.markerLabelStyle Set the styles for the markers' labels. Default value for that parameter is: +
{ + initial: { + 'font-family': 'Verdana', + 'font-size': '12', + 'font-weight': 'bold', + cursor: 'default', + fill: 'black' + }, + hover: { + cursor: 'pointer' + } +}+ * @param {Object|Array} params.markers Set of markers to add to the map during initialization. In case of array is provided, codes of markers will be set as string representations of array indexes. Each marker is represented by
latLng
(array of two numeric values), name
(string which will be show on marker's tip) and any marker styles.
+ * @param {Object} params.series Object with two keys: markers
and regions
. Each of which is an array of series configs to be applied to the respective map elements. See DataSeries description for a list of parameters available.
+ * @param {Object|String} params.focusOn This parameter sets the initial position and scale of the map viewport. See setFocus
docuemntation for possible parameters.
+ * @param {Object} params.labels Defines parameters for rendering static labels. Object could contain two keys: regions
and markers
. Each key value defines configuration object with the following possible options:
+render {Function}
- defines method for converting region code or marker index to actual label value.offsets {Object|Function}
- provides method or object which could be used to define label offset by region code or marker index.(Event e, Object tip, String code)
Will be called right before the region tip is going to be shown.
+ * @param {Function} params.onRegionOver (Event e, String code)
Will be called on region mouse over event.
+ * @param {Function} params.onRegionOut (Event e, String code)
Will be called on region mouse out event.
+ * @param {Function} params.onRegionClick (Event e, String code)
Will be called on region click event.
+ * @param {Function} params.onRegionSelected (Event e, String code, Boolean isSelected, Array selectedRegions)
Will be called when region is (de)selected. isSelected
parameter of the callback indicates whether region is selected or not. selectedRegions
contains codes of all currently selected regions.
+ * @param {Function} params.onMarkerTipShow (Event e, Object tip, String code)
Will be called right before the marker tip is going to be shown.
+ * @param {Function} params.onMarkerOver (Event e, String code)
Will be called on marker mouse over event.
+ * @param {Function} params.onMarkerOut (Event e, String code)
Will be called on marker mouse out event.
+ * @param {Function} params.onMarkerClick (Event e, String code)
Will be called on marker click event.
+ * @param {Function} params.onMarkerSelected (Event e, String code, Boolean isSelected, Array selectedMarkers)
Will be called when marker is (de)selected. isSelected
parameter of the callback indicates whether marker is selected or not. selectedMarkers
contains codes of all currently selected markers.
+ * @param {Function} params.onViewportChange (Event e, Number scale)
Triggered when the map's viewport is changed (map was panned or zoomed).
+ */
+jvm.Map = function(params) {
+ var map = this,
+ e;
+
+ this.params = jvm.$.extend(true, {}, jvm.Map.defaultParams, params);
+
+ if (!jvm.Map.maps[this.params.map]) {
+ throw new Error('Attempt to use map which was not loaded: '+this.params.map);
+ }
+
+ this.mapData = jvm.Map.maps[this.params.map];
+ this.markers = {};
+ this.regions = {};
+ this.regionsColors = {};
+ this.regionsData = {};
+
+ this.container = jvm.$('String
or Array
the region(s) with the corresponding code(s) will be selected. If Object
was provided its keys are codes of regions, state of which should be changed. Selected state will be set if value is true, removed otherwise.
+ */
+ setSelectedRegions: function(keys){
+ this.setSelected('regions', keys);
+ },
+
+ /**
+ * Set or remove selected state for the markers.
+ * @param {String|Array|Object} keys If String
or Array
the marker(s) with the corresponding code(s) will be selected. If Object
was provided its keys are codes of markers, state of which should be changed. Selected state will be set if value is true, removed otherwise.
+ */
+ setSelectedMarkers: function(keys){
+ this.setSelected('markers', keys);
+ },
+
+ clearSelected: function(type){
+ var select = {},
+ selected = this.getSelected(type),
+ i;
+
+ for (i = 0; i < selected.length; i++) {
+ select[selected[i]] = false;
+ };
+
+ this.setSelected(type, select);
+ },
+
+ /**
+ * Remove the selected state from all the currently selected regions.
+ */
+ clearSelectedRegions: function(){
+ this.clearSelected('regions');
+ },
+
+ /**
+ * Remove the selected state from all the currently selected markers.
+ */
+ clearSelectedMarkers: function(){
+ this.clearSelected('markers');
+ },
+
+ /**
+ * Return the instance of Map. Useful when instantiated as a jQuery plug-in.
+ * @returns {Map}
+ */
+ getMapObject: function(){
+ return this;
+ },
+
+ /**
+ * Return the name of the region by region code.
+ * @returns {String}
+ */
+ getRegionName: function(code){
+ return this.mapData.paths[code].name;
+ },
+
+ createRegions: function(){
+ var key,
+ region,
+ map = this;
+
+ this.regionLabelsGroup = this.regionLabelsGroup || this.canvas.addGroup();
+
+ for (key in this.mapData.paths) {
+ region = new jvm.Region({
+ map: this,
+ path: this.mapData.paths[key].path,
+ code: key,
+ style: jvm.$.extend(true, {}, this.params.regionStyle),
+ labelStyle: jvm.$.extend(true, {}, this.params.regionLabelStyle),
+ canvas: this.canvas,
+ labelsGroup: this.regionLabelsGroup,
+ label: this.canvas.mode != 'vml' ? (this.params.labels && this.params.labels.regions) : null
+ });
+
+ jvm.$(region.shape).bind('selected', function(e, isSelected){
+ map.container.trigger('regionSelected.jvectormap', [jvm.$(this.node).attr('data-code'), isSelected, map.getSelectedRegions()]);
+ });
+ this.regions[key] = {
+ element: region,
+ config: this.mapData.paths[key]
+ };
+ }
+ },
+
+ createMarkers: function(markers) {
+ var i,
+ marker,
+ point,
+ markerConfig,
+ markersArray,
+ map = this;
+
+ this.markersGroup = this.markersGroup || this.canvas.addGroup();
+ this.markerLabelsGroup = this.markerLabelsGroup || this.canvas.addGroup();
+
+ if (jvm.$.isArray(markers)) {
+ markersArray = markers.slice();
+ markers = {};
+ for (i = 0; i < markersArray.length; i++) {
+ markers[i] = markersArray[i];
+ }
+ }
+
+ for (i in markers) {
+ markerConfig = markers[i] instanceof Array ? {latLng: markers[i]} : markers[i];
+ point = this.getMarkerPosition( markerConfig );
+
+ if (point !== false) {
+ marker = new jvm.Marker({
+ map: this,
+ style: jvm.$.extend(true, {}, this.params.markerStyle, {initial: markerConfig.style || {}}),
+ labelStyle: jvm.$.extend(true, {}, this.params.markerLabelStyle),
+ index: i,
+ cx: point.x,
+ cy: point.y,
+ group: this.markersGroup,
+ canvas: this.canvas,
+ labelsGroup: this.markerLabelsGroup,
+ label: this.canvas.mode != 'vml' ? (this.params.labels && this.params.labels.markers) : null
+ });
+
+ jvm.$(marker.shape).bind('selected', function(e, isSelected){
+ map.container.trigger('markerSelected.jvectormap', [jvm.$(this.node).attr('data-index'), isSelected, map.getSelectedMarkers()]);
+ });
+ if (this.markers[i]) {
+ this.removeMarkers([i]);
+ }
+ this.markers[i] = {element: marker, config: markerConfig};
+ }
+ }
+ },
+
+ repositionMarkers: function() {
+ var i,
+ point;
+
+ for (i in this.markers) {
+ point = this.getMarkerPosition( this.markers[i].config );
+ if (point !== false) {
+ this.markers[i].element.setStyle({cx: point.x, cy: point.y});
+ }
+ }
+ },
+
+ repositionLabels: function() {
+ var key;
+
+ for (key in this.regions) {
+ this.regions[key].element.updateLabelPosition();
+ }
+
+ for (key in this.markers) {
+ this.markers[key].element.updateLabelPosition();
+ }
+ },
+
+ getMarkerPosition: function(markerConfig) {
+ if (jvm.Map.maps[this.params.map].projection) {
+ return this.latLngToPoint.apply(this, markerConfig.latLng || [0, 0]);
+ } else {
+ return {
+ x: markerConfig.coords[0]*this.scale + this.transX*this.scale,
+ y: markerConfig.coords[1]*this.scale + this.transY*this.scale
+ };
+ }
+ },
+
+ /**
+ * Add one marker to the map.
+ * @param {String} key Marker unique code.
+ * @param {Object} marker Marker configuration parameters.
+ * @param {Array} seriesData Values to add to the data series.
+ */
+ addMarker: function(key, marker, seriesData){
+ var markers = {},
+ data = [],
+ values,
+ i,
+ seriesData = seriesData || [];
+
+ markers[key] = marker;
+
+ for (i = 0; i < seriesData.length; i++) {
+ values = {};
+ if (typeof seriesData[i] !== 'undefined') {
+ values[key] = seriesData[i];
+ }
+ data.push(values);
+ }
+ this.addMarkers(markers, data);
+ },
+
+ /**
+ * Add set of marker to the map.
+ * @param {Object|Array} markers Markers to add to the map. In case of array is provided, codes of markers will be set as string representations of array indexes.
+ * @param {Array} seriesData Values to add to the data series.
+ */
+ addMarkers: function(markers, seriesData){
+ var i;
+
+ seriesData = seriesData || [];
+
+ this.createMarkers(markers);
+ for (i = 0; i < seriesData.length; i++) {
+ this.series.markers[i].setValues(seriesData[i] || {});
+ };
+ },
+
+ /**
+ * Remove some markers from the map.
+ * @param {Array} markers Array of marker codes to be removed.
+ */
+ removeMarkers: function(markers){
+ var i;
+
+ for (i = 0; i < markers.length; i++) {
+ this.markers[ markers[i] ].element.remove();
+ delete this.markers[ markers[i] ];
+ };
+ },
+
+ /**
+ * Remove all markers from the map.
+ */
+ removeAllMarkers: function(){
+ var i,
+ markers = [];
+
+ for (i in this.markers) {
+ markers.push(i);
+ }
+ this.removeMarkers(markers)
+ },
+
+ /**
+ * Converts coordinates expressed as latitude and longitude to the coordinates in pixels on the map.
+ * @param {Number} lat Latitide of point in degrees.
+ * @param {Number} lng Longitude of point in degrees.
+ */
+ latLngToPoint: function(lat, lng) {
+ var point,
+ proj = jvm.Map.maps[this.params.map].projection,
+ centralMeridian = proj.centralMeridian,
+ inset,
+ bbox;
+
+ if (lng < (-180 + centralMeridian)) {
+ lng += 360;
+ }
+
+ point = jvm.Proj[proj.type](lat, lng, centralMeridian);
+
+ inset = this.getInsetForPoint(point.x, point.y);
+ if (inset) {
+ bbox = inset.bbox;
+
+ point.x = (point.x - bbox[0].x) / (bbox[1].x - bbox[0].x) * inset.width * this.scale;
+ point.y = (point.y - bbox[0].y) / (bbox[1].y - bbox[0].y) * inset.height * this.scale;
+
+ return {
+ x: point.x + this.transX*this.scale + inset.left*this.scale,
+ y: point.y + this.transY*this.scale + inset.top*this.scale
+ };
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Converts cartesian coordinates into coordinates expressed as latitude and longitude.
+ * @param {Number} x X-axis of point on map in pixels.
+ * @param {Number} y Y-axis of point on map in pixels.
+ */
+ pointToLatLng: function(x, y) {
+ var proj = jvm.Map.maps[this.params.map].projection,
+ centralMeridian = proj.centralMeridian,
+ insets = jvm.Map.maps[this.params.map].insets,
+ i,
+ inset,
+ bbox,
+ nx,
+ ny;
+
+ for (i = 0; i < insets.length; i++) {
+ inset = insets[i];
+ bbox = inset.bbox;
+
+ nx = x - (this.transX*this.scale + inset.left*this.scale);
+ ny = y - (this.transY*this.scale + inset.top*this.scale);
+
+ nx = (nx / (inset.width * this.scale)) * (bbox[1].x - bbox[0].x) + bbox[0].x;
+ ny = (ny / (inset.height * this.scale)) * (bbox[1].y - bbox[0].y) + bbox[0].y;
+
+ if (nx > bbox[0].x && nx < bbox[1].x && ny > bbox[0].y && ny < bbox[1].y) {
+ return jvm.Proj[proj.type + '_inv'](nx, -ny, centralMeridian);
+ }
+ }
+
+ return false;
+ },
+
+ getInsetForPoint: function(x, y){
+ var insets = jvm.Map.maps[this.params.map].insets,
+ i,
+ bbox;
+
+ for (i = 0; i < insets.length; i++) {
+ bbox = insets[i].bbox;
+ if (x > bbox[0].x && x < bbox[1].x && y > bbox[0].y && y < bbox[1].y) {
+ return insets[i];
+ }
+ }
+ },
+
+ createSeries: function(){
+ var i,
+ key;
+
+ this.series = {
+ markers: [],
+ regions: []
+ };
+
+ for (key in this.params.series) {
+ for (i = 0; i < this.params.series[key].length; i++) {
+ this.series[key][i] = new jvm.DataSeries(
+ this.params.series[key][i],
+ this[key],
+ this
+ );
+ }
+ }
+ },
+
+ /**
+ * Gracefully remove the map and and all its accessories, unbind event handlers.
+ */
+ remove: function(){
+ this.tip.remove();
+ this.container.remove();
+ jvm.$(window).unbind('resize', this.onResize);
+ jvm.$('body').unbind('mouseup', this.onContainerMouseUp);
+ }
+};
+
+jvm.Map.maps = {};
+jvm.Map.defaultParams = {
+ map: 'world_mill_en',
+ backgroundColor: '#505050',
+ zoomButtons: true,
+ zoomOnScroll: true,
+ zoomOnScrollSpeed: 3,
+ panOnDrag: true,
+ zoomMax: 8,
+ zoomMin: 1,
+ zoomStep: 1.6,
+ zoomAnimate: true,
+ regionsSelectable: false,
+ markersSelectable: false,
+ bindTouchEvents: true,
+ regionStyle: {
+ initial: {
+ fill: 'white',
+ "fill-opacity": 1,
+ stroke: 'none',
+ "stroke-width": 0,
+ "stroke-opacity": 1
+ },
+ hover: {
+ "fill-opacity": 0.8,
+ cursor: 'pointer'
+ },
+ selected: {
+ fill: 'yellow'
+ },
+ selectedHover: {
+ }
+ },
+ regionLabelStyle: {
+ initial: {
+ 'font-family': 'Verdana',
+ 'font-size': '12',
+ 'font-weight': 'bold',
+ cursor: 'default',
+ fill: 'black'
+ },
+ hover: {
+ cursor: 'pointer'
+ }
+ },
+ markerStyle: {
+ initial: {
+ fill: 'grey',
+ stroke: '#505050',
+ "fill-opacity": 1,
+ "stroke-width": 1,
+ "stroke-opacity": 1,
+ r: 5
+ },
+ hover: {
+ stroke: 'black',
+ "stroke-width": 2,
+ cursor: 'pointer'
+ },
+ selected: {
+ fill: 'blue'
+ },
+ selectedHover: {
+ }
+ },
+ markerLabelStyle: {
+ initial: {
+ 'font-family': 'Verdana',
+ 'font-size': '12',
+ 'font-weight': 'bold',
+ cursor: 'default',
+ fill: 'black'
+ },
+ hover: {
+ cursor: 'pointer'
+ }
+ }
+};
+jvm.Map.apiEvents = {
+ onRegionTipShow: 'regionTipShow',
+ onRegionOver: 'regionOver',
+ onRegionOut: 'regionOut',
+ onRegionClick: 'regionClick',
+ onRegionSelected: 'regionSelected',
+ onMarkerTipShow: 'markerTipShow',
+ onMarkerOver: 'markerOver',
+ onMarkerOut: 'markerOut',
+ onMarkerClick: 'markerClick',
+ onMarkerSelected: 'markerSelected',
+ onViewportChange: 'viewportChange'
+};
\ No newline at end of file
diff --git a/public/bower_components/jvectormap/src/marker.js b/public/bower_components/jvectormap/src/marker.js
new file mode 100644
index 0000000..8277500
--- /dev/null
+++ b/public/bower_components/jvectormap/src/marker.js
@@ -0,0 +1,76 @@
+jvm.Marker = function(config){
+ var text,
+ offsets;
+
+ this.config = config;
+ this.map = this.config.map;
+
+ this.isImage = !!this.config.style.initial.image;
+ this.createShape();
+
+ text = this.getLabelText(config.index);
+ if (this.config.label && text) {
+ this.offsets = this.getLabelOffsets(config.index);
+ this.labelX = config.cx / this.map.scale - this.map.transX;
+ this.labelY = config.cy / this.map.scale - this.map.transY;
+ this.label = config.canvas.addText({
+ text: text,
+ 'data-index': config.index,
+ dy: "0.6ex",
+ x: this.labelX,
+ y: this.labelY
+ }, config.labelStyle, config.labelsGroup);
+
+ this.label.addClass('jvectormap-marker jvectormap-element');
+ }
+};
+
+jvm.inherits(jvm.Marker, jvm.MapObject);
+
+jvm.Marker.prototype.createShape = function(){
+ var that = this;
+
+ if (this.shape) {
+ this.shape.remove();
+ }
+ this.shape = this.config.canvas[this.isImage ? 'addImage' : 'addCircle']({
+ "data-index": this.config.index,
+ cx: this.config.cx,
+ cy: this.config.cy
+ }, this.config.style, this.config.group);
+
+ this.shape.addClass('jvectormap-marker jvectormap-element');
+
+ if (this.isImage) {
+ jvm.$(this.shape.node).on('imageloaded', function(){
+ that.updateLabelPosition();
+ });
+ }
+};
+
+jvm.Marker.prototype.updateLabelPosition = function(){
+ if (this.label) {
+ this.label.set({
+ x: this.labelX * this.map.scale + this.offsets[0] +
+ this.map.transX * this.map.scale + 5 + (this.isImage ? (this.shape.width || 0) / 2 : this.shape.properties.r),
+ y: this.labelY * this.map.scale + this.map.transY * this.map.scale + this.offsets[1]
+ });
+ }
+};
+
+jvm.Marker.prototype.setStyle = function(property, value){
+ var isImage;
+
+ jvm.Marker.parentClass.prototype.setStyle.apply(this, arguments);
+
+ if (property === 'r') {
+ this.updateLabelPosition();
+ }
+
+ isImage = !!this.shape.get('image');
+ if (isImage != this.isImage) {
+ this.isImage = isImage;
+ this.config.style = jvm.$.extend(true, {}, this.shape.style);
+ this.createShape();
+ }
+};
\ No newline at end of file
diff --git a/public/bower_components/jvectormap/src/multimap.js b/public/bower_components/jvectormap/src/multimap.js
new file mode 100644
index 0000000..fb91201
--- /dev/null
+++ b/public/bower_components/jvectormap/src/multimap.js
@@ -0,0 +1,139 @@
+/**
+ * Creates map with drill-down functionality.
+ * @constructor
+ * @param {Object} params Parameters to initialize map with.
+ * @param {Number} params.maxLevel Maximum number of levels user can go through
+ * @param {Object} params.main Config of the main map. See jvm.Map for more information.
+ * @param {Function} params.mapNameByCode Function go generate map name by region code. Default value is:
++function(code, multiMap) { + return code.toLowerCase()+'_'+ + multiMap.defaultProjection+'_en'; +} ++ * @param {Function} params.mapUrlByCode Function to generate map url by region code. Default value is: +
+function(code, multiMap){ + return 'jquery-jvectormap-data-'+ + code.toLowerCase()+'-'+ + multiMap.defaultProjection+'-en.js'; +} ++ */ +jvm.MultiMap = function(params) { + var that = this; + + this.maps = {}; + this.params = jvm.$.extend(true, {}, jvm.MultiMap.defaultParams, params); + this.params.maxLevel = this.params.maxLevel || Number.MAX_VALUE; + this.params.main = this.params.main || {}; + this.params.main.multiMapLevel = 0; + this.history = [ this.addMap(this.params.main.map, this.params.main) ]; + this.defaultProjection = this.history[0].mapData.projection.type; + this.mapsLoaded = {}; + + this.params.container.css({position: 'relative'}); + this.backButton = jvm.$('').addClass('jvectormap-goback').text('Back').appendTo(this.params.container); + this.backButton.hide(); + this.backButton.click(function(){ + that.goBack(); + }); + + this.spinner = jvm.$('').addClass('jvectormap-spinner').appendTo(this.params.container); + this.spinner.hide(); +}; + +jvm.MultiMap.prototype = { + addMap: function(name, config){ + var cnt = jvm.$('').css({ + width: '100%', + height: '100%' + }); + + this.params.container.append(cnt); + + this.maps[name] = new jvm.Map(jvm.$.extend(config, {container: cnt})); + if (this.params.maxLevel > config.multiMapLevel) { + this.maps[name].container.on('regionClick.jvectormap', {scope: this}, function(e, code){ + var multimap = e.data.scope, + mapName = multimap.params.mapNameByCode(code, multimap); + + if (!multimap.drillDownPromise || multimap.drillDownPromise.state() !== 'pending') { + multimap.drillDown(mapName, code); + } + }); + } + + + return this.maps[name]; + }, + + downloadMap: function(code){ + var that = this, + deferred = jvm.$.Deferred(); + + if (!this.mapsLoaded[code]) { + jvm.$.get(this.params.mapUrlByCode(code, this)).then(function(){ + that.mapsLoaded[code] = true; + deferred.resolve(); + }, function(){ + deferred.reject(); + }); + } else { + deferred.resolve(); + } + return deferred; + }, + + drillDown: function(name, code){ + var currentMap = this.history[this.history.length - 1], + that = this, + focusPromise = currentMap.setFocus({region: code, animate: true}), + downloadPromise = this.downloadMap(code); + + focusPromise.then(function(){ + if (downloadPromise.state() === 'pending') { + that.spinner.show(); + } + }); + downloadPromise.always(function(){ + that.spinner.hide(); + }); + this.drillDownPromise = jvm.$.when(downloadPromise, focusPromise); + this.drillDownPromise.then(function(){ + currentMap.params.container.hide(); + if (!that.maps[name]) { + that.addMap(name, {map: name, multiMapLevel: currentMap.params.multiMapLevel + 1}); + } else { + that.maps[name].params.container.show(); + } + that.history.push( that.maps[name] ); + that.backButton.show(); + }); + }, + + goBack: function(){ + var currentMap = this.history.pop(), + prevMap = this.history[this.history.length - 1], + that = this; + + currentMap.setFocus({scale: 1, x: 0.5, y: 0.5, animate: true}).then(function(){ + currentMap.params.container.hide(); + prevMap.params.container.show(); + prevMap.updateSize(); + if (that.history.length === 1) { + that.backButton.hide(); + } + prevMap.setFocus({scale: 1, x: 0.5, y: 0.5, animate: true}); + }); + } +}; + +jvm.MultiMap.defaultParams = { + mapNameByCode: function(code, multiMap){ + return code.toLowerCase()+'_'+multiMap.defaultProjection+'_en'; + }, + mapUrlByCode: function(code, multiMap){ + return 'jquery-jvectormap-data-'+code.toLowerCase()+'-'+multiMap.defaultProjection+'-en.js'; + } +} diff --git a/public/bower_components/jvectormap/src/numeric-scale.js b/public/bower_components/jvectormap/src/numeric-scale.js new file mode 100644 index 0000000..510151a --- /dev/null +++ b/public/bower_components/jvectormap/src/numeric-scale.js @@ -0,0 +1,185 @@ +jvm.NumericScale = function(scale, normalizeFunction, minValue, maxValue) { + this.scale = []; + + normalizeFunction = normalizeFunction || 'linear'; + + if (scale) this.setScale(scale); + if (normalizeFunction) this.setNormalizeFunction(normalizeFunction); + if (typeof minValue !== 'undefined' ) this.setMin(minValue); + if (typeof maxValue !== 'undefined' ) this.setMax(maxValue); +}; + +jvm.NumericScale.prototype = { + setMin: function(min) { + this.clearMinValue = min; + if (typeof this.normalize === 'function') { + this.minValue = this.normalize(min); + } else { + this.minValue = min; + } + }, + + setMax: function(max) { + this.clearMaxValue = max; + if (typeof this.normalize === 'function') { + this.maxValue = this.normalize(max); + } else { + this.maxValue = max; + } + }, + + setScale: function(scale) { + var i; + + this.scale = []; + for (i = 0; i < scale.length; i++) { + this.scale[i] = [scale[i]]; + } + }, + + setNormalizeFunction: function(f) { + if (f === 'polynomial') { + this.normalize = function(value) { + return Math.pow(value, 0.2); + } + } else if (f === 'linear') { + delete this.normalize; + } else { + this.normalize = f; + } + this.setMin(this.clearMinValue); + this.setMax(this.clearMaxValue); + }, + + getValue: function(value) { + var lengthes = [], + fullLength = 0, + l, + i = 0, + c; + + if (typeof this.normalize === 'function') { + value = this.normalize(value); + } + for (i = 0; i < this.scale.length-1; i++) { + l = this.vectorLength(this.vectorSubtract(this.scale[i+1], this.scale[i])); + lengthes.push(l); + fullLength += l; + } + + c = (this.maxValue - this.minValue) / fullLength; + for (i=0; i