1! function($) { 2 var apiParams = { 3 set: { 4 colors: 1, 5 values: 1, 6 backgroundColor: 1, 7 scaleColors: 1, 8 normalizeFunction: 1, 9 focus: 1 10 }, 11 get: { 12 selectedRegions: 1, 13 selectedMarkers: 1, 14 mapObject: 1, 15 regionName: 1 16 } 17 }; 18 $.fn.vectorMap = function(options) { 19 var map = this.children(".jvectormap-container").data("mapObject"); 20 if ("addMap" === options) jvm.Map.maps[arguments[1]] = arguments[2]; 21 else { 22 if (("set" === options || "get" === options) && apiParams[options][arguments[1]]) return map[options + (arguments[1].charAt(0).toUpperCase() + arguments[1].substr(1))].apply(map, Array.prototype.slice.call(arguments, 2)); 23 (options = options || {}).container = this, map = new jvm.Map(options) 24 } 25 return this 26 } 27}(jQuery), 28function(factory) { 29 "function" == typeof define && define.amd ? define(["jquery"], factory) : "object" == typeof exports ? module.exports = factory : factory(jQuery) 30}(function($) { 31 var nullLowestDeltaTimeout, lowestDelta, toFix = ["wheel", "mousewheel", "DOMMouseScroll", "MozMousePixelScroll"], 32 toBind = "onwheel" in document || 9 <= document.documentMode ? ["wheel"] : ["mousewheel", "DomMouseScroll", "MozMousePixelScroll"], 33 slice = Array.prototype.slice; 34 if ($.event.fixHooks) 35 for (var i = toFix.length; i;) $.event.fixHooks[toFix[--i]] = $.event.mouseHooks; 36 var special = $.event.special.mousewheel = { 37 version: "3.1.9", 38 setup: function() { 39 if (this.addEventListener) 40 for (var i = toBind.length; i;) this.addEventListener(toBind[--i], handler, !1); 41 else this.onmousewheel = handler; 42 $.data(this, "mousewheel-line-height", special.getLineHeight(this)), $.data(this, "mousewheel-page-height", special.getPageHeight(this)) 43 }, 44 teardown: function() { 45 if (this.removeEventListener) 46 for (var i = toBind.length; i;) this.removeEventListener(toBind[--i], handler, !1); 47 else this.onmousewheel = null 48 }, 49 getLineHeight: function(elem) { 50 return parseInt($(elem)["offsetParent" in $.fn ? "offsetParent" : "parent"]().css("fontSize"), 10) 51 }, 52 getPageHeight: function(elem) { 53 return $(elem).height() 54 }, 55 settings: { 56 adjustOldDeltas: !0 57 } 58 }; 59 60 function handler(event) { 61 var absDelta, orgEvent = event || window.event, 62 args = slice.call(arguments, 1), 63 delta = 0, 64 deltaX = 0, 65 deltaY = 0; 66 if ((event = $.event.fix(orgEvent)).type = "mousewheel", "detail" in orgEvent && (deltaY = -1 * orgEvent.detail), "wheelDelta" in orgEvent && (deltaY = orgEvent.wheelDelta), "wheelDeltaY" in orgEvent && (deltaY = orgEvent.wheelDeltaY), "wheelDeltaX" in orgEvent && (deltaX = -1 * orgEvent.wheelDeltaX), "axis" in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS && (deltaX = -1 * deltaY, deltaY = 0), delta = 0 === deltaY ? deltaX : deltaY, "deltaY" in orgEvent && (delta = deltaY = -1 * orgEvent.deltaY), "deltaX" in orgEvent && (deltaX = orgEvent.deltaX, 0 === deltaY && (delta = -1 * deltaX)), 0 !== deltaY || 0 !== deltaX) { 67 if (1 === orgEvent.deltaMode) { 68 var lineHeight = $.data(this, "mousewheel-line-height"); 69 delta *= lineHeight, deltaY *= lineHeight, deltaX *= lineHeight 70 } else if (2 === orgEvent.deltaMode) { 71 var pageHeight = $.data(this, "mousewheel-page-height"); 72 delta *= pageHeight, deltaY *= pageHeight, deltaX *= pageHeight 73 } 74 return absDelta = Math.max(Math.abs(deltaY), Math.abs(deltaX)), (!lowestDelta || absDelta < lowestDelta) && shouldAdjustOldDeltas(orgEvent, lowestDelta = absDelta) && (lowestDelta /= 40), shouldAdjustOldDeltas(orgEvent, absDelta) && (delta /= 40, deltaX /= 40, deltaY /= 40), delta = Math[1 <= delta ? "floor" : "ceil"](delta / lowestDelta), deltaX = Math[1 <= deltaX ? "floor" : "ceil"](deltaX / lowestDelta), deltaY = Math[1 <= deltaY ? "floor" : "ceil"](deltaY / lowestDelta), event.deltaX = deltaX, event.deltaY = deltaY, event.deltaFactor = lowestDelta, event.deltaMode = 0, args.unshift(event, delta, deltaX, deltaY), nullLowestDeltaT
vendor: 39,536 bytes, lines 74-680
74imeout && clearTimeout(nullLowestDeltaTimeout), nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200), ($.event.dispatch || $.event.handle).apply(this, args) 75 } 76 } 77 78 function nullLowestDelta() { 79 lowestDelta = null 80 } 81 82 function shouldAdjustOldDeltas(orgEvent, absDelta) { 83 return special.settings.adjustOldDeltas && "mousewheel" === orgEvent.type && absDelta % 120 == 0 84 } 85 $.fn.extend({ 86 mousewheel: function(fn) { 87 return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel") 88 }, 89 unmousewheel: function(fn) { 90 return this.unbind("mousewheel", fn) 91 } 92 }) 93}); 94var jvm = { 95 inherits: function(child, parent) { 96 function temp() {} 97 temp.prototype = parent.prototype, child.prototype = new temp, (child.prototype.constructor = child).parentClass = parent 98 }, 99 mixin: function(target, source) { 100 var prop; 101 for (prop in source.prototype) source.prototype.hasOwnProperty(prop) && (target.prototype[prop] = source.prototype[prop]) 102 }, 103 min: function(values) { 104 var i, min = Number.MAX_VALUE; 105 if (values instanceof Array) 106 for (i = 0; i < values.length; i++) values[i] < min && (min = values[i]); 107 else 108 for (i in values) values[i] < min && (min = values[i]); 109 return min 110 }, 111 max: function(values) { 112 var i, max = Number.MIN_VALUE; 113 if (values instanceof Array) 114 for (i = 0; i < values.length; i++) values[i] > max && (max = values[i]); 115 else 116 for (i in values) values[i] > max && (max = values[i]); 117 return max 118 }, 119 keys: function(object) { 120 var key, keys = []; 121 for (key in object) keys.push(key); 122 return keys 123 }, 124 values: function(object) { 125 var key, i, values = []; 126 for (i = 0; i < arguments.length; i++) 127 for (key in object = arguments[i]) values.push(object[key]); 128 return values 129 }, 130 whenImageLoaded: function(url) { 131 var deferred = new jvm.$.Deferred, 132 img = jvm.$("<img/>"); 133 return img.on("error", function() { 134 deferred.reject() 135 }).on("load", function() { 136 deferred.resolve(img) 137 }), img.attr("src", url), deferred 138 }, 139 isImageUrl: function(s) { 140 return /\.\w{3,4}$/.test(s) 141 } 142}; 143jvm.$ = jQuery, Array.prototype.indexOf || (Array.prototype.indexOf = function(searchElement, fromIndex) { 144 var k; 145 if (null == this) throw new TypeError('"this" is null or not defined'); 146 var O = Object(this), 147 len = O.length >>> 0; 148 if (0 == len) return -1; 149 var n = +fromIndex || 0; 150 if (Math.abs(n) === 1 / 0 && (n = 0), len <= n) return -1; 151 for (k = Math.max(0 <= n ? n : len - Math.abs(n), 0); k < len;) { 152 if (k in O && O[k] === searchElement) return k; 153 k++ 154 } 155 return -1 156}), jvm.AbstractElement = function(name, config) { 157 this.node = this.createElement(name), this.name = name, this.properties = {}, config && this.set(config) 158}, jvm.AbstractElement.prototype.set = function(property, value) { 159 var key; 160 if ("object" == typeof property) 161 for (key in property) this.properties[key] = property[key], this.applyAttr(key, property[key]); 162 else this.properties[property] = value, this.applyAttr(property, value) 163}, jvm.AbstractElement.prototype.get = function(property) { 164 return this.properties[property] 165}, jvm.AbstractElement.prototype.applyAttr = function(property, value) { 166 this.node.setAttribute(property, value) 167}, jvm.AbstractElement.prototype.remove = function() { 168 jvm.$(this.node).remove() 169}, jvm.AbstractCanvasElement = function(container, width, height) { 170 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) 171}, jvm.AbstractCanvasElement.prototype.add = function(element, group) { 172 (group = group || this.rootElement).add(element), element.canvas = this 173}, jvm.AbstractCanvasElement.prototype.addPath = function(config, style, group) { 174 var el = new jvm[this.classPrefix + "PathElement"](config, style); 175 return this.add(el, group), el 176}, jvm.AbstractCanvasElement.prototype.addCircle = function(config, style, group) { 177 var el = new jvm[this.classPrefix + "CircleElement"](config, style); 178 return this.add(el, group), el 179}, jvm.AbstractCanvasElement.prototype.addImage = function(config, style, group) { 180 var el = new jvm[this.classPrefix + "ImageElement"](config, style); 181 return this.add(el, group), el 182}, jvm.AbstractCanvasElement.prototype.addText = function(config, style, group) { 183 var el = new jvm[this.classPrefix + "TextElement"](config, style); 184 return this.add(el, group), el 185}, jvm.AbstractCanvasElement.prototype.addGroup = function(parentGroup) { 186 var el = new jvm[this.classPrefix + "GroupElement"]; 187 return parentGroup ? parentGroup.node.appendChild(el.node) : this.node.appendChild(el.node), el.canvas = this, el 188}, jvm.AbstractShapeElement = function(name, config, style) { 189 this.style = style || {}, this.style.current = this.style.current || {}, this.isHovered = !1, this.isSelected = !1, this.updateStyle() 190}, jvm.AbstractShapeElement.prototype.setStyle = function(property, value) { 191 var styles = {}; 192 "object" == typeof property ? styles = property : styles[property] = value, jvm.$.extend(this.style.current, styles), this.updateStyle() 193}, jvm.AbstractShapeElement.prototype.updateStyle = function() { 194 var attrs = {}; 195 jvm.AbstractShapeElement.mergeStyles(attrs, this.style.initial), jvm.AbstractShapeElement.mergeStyles(attrs, this.style.current), this.isHovered && jvm.AbstractShapeElement.mergeStyles(attrs, this.style.hover), this.isSelected && (jvm.AbstractShapeElement.mergeStyles(attrs, this.style.selected), this.isHovered && jvm.AbstractShapeElement.mergeStyles(attrs, this.style.selectedHover)), this.set(attrs) 196}, jvm.AbstractShapeElement.mergeStyles = function(styles, newStyles) { 197 var key; 198 for (key in newStyles = newStyles || {}) null === newStyles[key] ? delete styles[key] : styles[key] = newStyles[key] 199}, jvm.SVGElement = function(name, config) { 200 jvm.SVGElement.parentClass.apply(this, arguments) 201}, jvm.inherits(jvm.SVGElement, jvm.AbstractElement), jvm.SVGElement.svgns = "http://www.w3.org/2000/svg", jvm.SVGElement.prototype.createElement = function(tagName) { 202 return document.createElementNS(jvm.SVGElement.svgns, tagName) 203}, jvm.SVGElement.prototype.addClass = function(className) { 204 this.node.setAttribute("class", className) 205}, jvm.SVGElement.prototype.getElementCtr = function(ctr) { 206 return jvm["SVG" + ctr] 207}, jvm.SVGElement.prototype.getBBox = function() { 208 return this.node.getBBox() 209}, jvm.SVGGroupElement = function() { 210 jvm.SVGGroupElement.parentClass.call(this, "g") 211}, jvm.inherits(jvm.SVGGroupElement, jvm.SVGElement), jvm.SVGGroupElement.prototype.add = function(element) { 212 this.node.appendChild(element.node) 213}, jvm.SVGCanvasElement = function(container, width, height) { 214 this.classPrefix = "SVG", jvm.SVGCanvasElement.parentClass.call(this, "svg"), this.defsElement = new jvm.SVGElement("defs"), this.node.appendChild(this.defsElement.node), jvm.AbstractCanvasElement.apply(this, arguments) 215}, jvm.inherits(jvm.SVGCanvasElement, jvm.SVGElement), jvm.mixin(jvm.SVGCanvasElement, jvm.AbstractCanvasElement), jvm.SVGCanvasElement.prototype.setSize = function(width, height) { 216 this.width = width, this.height = height, this.node.setAttribute("width", width), this.node.setAttribute("height", height) 217}, jvm.SVGCanvasElement.prototype.applyTransformParams = function(scale, transX, transY) { 218 this.scale = scale, this.transX = transX, this.transY = transY, this.rootElement.node.setAttribute("transform", "scale(" + scale + ") translate(" + transX + ", " + transY + ")") 219}, jvm.SVGShapeElement = function(name, config, style) { 220 jvm.SVGShapeElement.parentClass.call(this, name, config), jvm.AbstractShapeElement.apply(this, arguments) 221}, jvm.inherits(jvm.SVGShapeElement, jvm.SVGElement), jvm.mixin(jvm.SVGShapeElement, jvm.AbstractShapeElement), jvm.SVGShapeElement.prototype.applyAttr = function(attr, value) { 222 var patternEl, imageEl, that = this; 223 "fill" === attr && jvm.isImageUrl(value) ? jvm.SVGShapeElement.images[value] ? this.applyAttr("fill", "url(#image" + jvm.SVGShapeElement.images[value] + ")") : jvm.whenImageLoaded(value).then(function(img) { 224 (imageEl = new jvm.SVGElement("image")).node.setAttributeNS("http://www.w3.org/1999/xlink", "href", value), imageEl.applyAttr("x", "0"), imageEl.applyAttr("y", "0"), imageEl.applyAttr("width", img[0].width), imageEl.applyAttr("height", img[0].height), (patternEl = new jvm.SVGElement("pattern")).applyAttr("id", "image" + jvm.SVGShapeElement.imageCounter), patternEl.applyAttr("x", 0), patternEl.applyAttr("y", 0), patternEl.applyAttr("width", img[0].width / 2), patternEl.applyAttr("height", img[0].height / 2), patternEl.applyAttr("viewBox", "0 0 " + img[0].width + " " + img[0].height), patternEl.applyAttr("patternUnits", "userSpaceOnUse"), patternEl.node.appendChild(imageEl.node), that.canvas.defsElement.node.appendChild(patternEl.node), jvm.SVGShapeElement.images[value] = jvm.SVGShapeElement.imageCounter++, that.applyAttr("fill", "url(#image" + jvm.SVGShapeElement.images[value] + ")") 225 }) : jvm.SVGShapeElement.parentClass.prototype.applyAttr.apply(this, arguments) 226}, jvm.SVGShapeElement.imageCounter = 1, jvm.SVGShapeElement.images = {}, jvm.SVGPathElement = function(config, style) { 227 jvm.SVGPathElement.parentClass.call(this, "path", config, style), this.node.setAttribute("fill-rule", "evenodd") 228}, jvm.inherits(jvm.SVGPathElement, jvm.SVGShapeElement), jvm.SVGCircleElement = function(config, style) { 229 jvm.SVGCircleElement.parentClass.call(this, "circle", config, style) 230}, jvm.inherits(jvm.SVGCircleElement, jvm.SVGShapeElement), jvm.SVGImageElement = function(config, style) { 231 jvm.SVGImageElement.parentClass.call(this, "image", config, style) 232}, jvm.inherits(jvm.SVGImageElement, jvm.SVGShapeElement), jvm.SVGImageElement.prototype.applyAttr = function(attr, value) { 233 var imageUrl, that = this; 234 "image" == attr ? ("object" == typeof value ? (imageUrl = value.url, this.offset = value.offset) : (imageUrl = value, this.offset = [0, 0]), jvm.whenImageLoaded(imageUrl).then(function(img) { 235 that.node.setAttributeNS("http://www.w3.org/1999/xlink", "href", imageUrl), that.width = img[0].width, that.height = img[0].height, that.applyAttr("width", that.width), that.applyAttr("height", that.height), that.applyAttr("x", that.cx - that.width / 2 + that.offset[0]), that.applyAttr("y", that.cy - that.height / 2 + that.offset[1]), jvm.$(that.node).trigger("imageloaded", [img]) 236 })) : "cx" == attr ? (this.cx = value, this.width && this.applyAttr("x", value - this.width / 2 + this.offset[0])) : "cy" == attr ? (this.cy = value, this.height && this.applyAttr("y", value - this.height / 2 + this.offset[1])) : jvm.SVGImageElement.parentClass.prototype.applyAttr.apply(this, arguments) 237}, jvm.SVGTextElement = function(config, style) { 238 jvm.SVGTextElement.parentClass.call(this, "text", config, style) 239}, jvm.inherits(jvm.SVGTextElement, jvm.SVGShapeElement), jvm.SVGTextElement.prototype.applyAttr = function(attr, value) { 240 "text" === attr ? this.node.textContent = value : jvm.SVGTextElement.parentClass.prototype.applyAttr.apply(this, arguments) 241}, jvm.VMLElement = function(name, config) { 242 jvm.VMLElement.VMLInitialized || jvm.VMLElement.initializeVML(), jvm.VMLElement.parentClass.apply(this, arguments) 243}, jvm.inherits(jvm.VMLElement, jvm.AbstractElement), jvm.VMLElement.VMLInitialized = !1, jvm.VMLElement.initializeVML = function() { 244 try { 245 document.namespaces.rvml || document.namespaces.add("rvml", "urn:schemas-microsoft-com:vml"), jvm.VMLElement.prototype.createElement = function(tagName) { 246 return document.createElement("<rvml:" + tagName + ' class="rvml">') 247 } 248 } catch (e) { 249 jvm.VMLElement.prototype.createElement = function(tagName) { 250 return document.createElement("<" + tagName + ' xmlns="urn:schemas-microsoft.com:vml" class="rvml">') 251 } 252 } 253 document.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)"), jvm.VMLElement.VMLInitialized = !0 254}, jvm.VMLElement.prototype.getElementCtr = function(ctr) { 255 return jvm["VML" + ctr] 256}, jvm.VMLElement.prototype.addClass = function(className) { 257 jvm.$(this.node).addClass(className) 258}, jvm.VMLElement.prototype.applyAttr = function(attr, value) { 259 this.node[attr] = value 260}, jvm.VMLElement.prototype.getBBox = function() { 261 var node = jvm.$(this.node); 262 return { 263 x: node.position().left / this.canvas.scale, 264 y: node.position().top / this.canvas.scale, 265 width: node.width() / this.canvas.scale, 266 height: node.height() / this.canvas.scale 267 } 268}, jvm.VMLGroupElement = function() { 269 jvm.VMLGroupElement.parentClass.call(this, "group"), this.node.style.left = "0px", this.node.style.top = "0px", this.node.coordorigin = "0 0" 270}, jvm.inherits(jvm.VMLGroupElement, jvm.VMLElement), jvm.VMLGroupElement.prototype.add = function(element) { 271 this.node.appendChild(element.node) 272}, jvm.VMLCanvasElement = function(container, width, height) { 273 this.classPrefix = "VML", jvm.VMLCanvasElement.parentClass.call(this, "group"), jvm.AbstractCanvasElement.apply(this, arguments), this.node.style.position = "absolute" 274}, jvm.inherits(jvm.VMLCanvasElement, jvm.VMLElement), jvm.mixin(jvm.VMLCanvasElement, jvm.AbstractCanvasElement), jvm.VMLCanvasElement.prototype.setSize = function(width, height) { 275 var paths, groups, i, l; 276 if (this.width = width, this.height = height, this.node.style.width = width + "px", this.node.style.height = height + "px", this.node.coordsize = width + " " + height, this.node.coordorigin = "0 0", this.rootElement) { 277 for (i = 0, l = (paths = this.rootElement.node.getElementsByTagName("shape")).length; i < l; i++) paths[i].coordsize = width + " " + height, paths[i].style.width = width + "px", paths[i].style.height = height + "px"; 278 for (i = 0, l = (groups = this.node.getElementsByTagName("group")).length; i < l; i++) groups[i].coordsize = width + " " + height, groups[i].style.width = width + "px", groups[i].style.height = height + "px" 279 } 280}, jvm.VMLCanvasElement.prototype.applyTransformParams = function(scale, transX, transY) { 281 this.scale = scale, this.transX = transX, this.transY = transY, this.rootElement.node.coordorigin = this.width - transX - this.width / 100 + "," + (this.height - transY - this.height / 100), this.rootElement.node.coordsize = this.width / scale + "," + this.height / scale 282}, jvm.VMLShapeElement = function(name, config) { 283 jvm.VMLShapeElement.parentClass.call(this, name, config), this.fillElement = new jvm.VMLElement("fill"), this.strokeElement = new jvm.VMLElement("stroke"), this.node.appendChild(this.fillElement.node), this.node.appendChild(this.strokeElement.node), this.node.stroked = !1, jvm.AbstractShapeElement.apply(this, arguments) 284}, jvm.inherits(jvm.VMLShapeElement, jvm.VMLElement), jvm.mixin(jvm.VMLShapeElement, jvm.AbstractShapeElement), jvm.VMLShapeElement.prototype.applyAttr = function(attr, value) { 285 switch (attr) { 286 case "fill": 287 this.node.fillcolor = value; 288 break; 289 case "fill-opacity": 290 this.fillElement.node.opacity = Math.round(100 * value) + "%"; 291 break; 292 case "stroke": 293 this.node.stroked = "none" !== value, this.node.strokecolor = value; 294 break; 295 case "stroke-opacity": 296 this.strokeElement.node.opacity = Math.round(100 * value) + "%"; 297 break; 298 case "stroke-width": 299 0 === parseInt(value, 10) ? this.node.stroked = !1 : this.node.stroked = !0, this.node.strokeweight = value; 300 break; 301 case "d": 302 this.node.path = jvm.VMLPathElement.pathSvgToVml(value); 303 break; 304 default: 305 jvm.VMLShapeElement.parentClass.prototype.applyAttr.apply(this, arguments) 306 } 307}, jvm.VMLPathElement = function(config, style) { 308 var scale = new jvm.VMLElement("skew"); 309 jvm.VMLPathElement.parentClass.call(this, "shape", config, style), this.node.coordorigin = "0 0", scale.node.on = !0, scale.node.matrix = "0.01,0,0,0.01,0,0", scale.node.offset = "0,0", this.node.appendChild(scale.node) 310}, jvm.inherits(jvm.VMLPathElement, jvm.VMLShapeElement), jvm.VMLPathElement.prototype.applyAttr = function(attr, value) { 311 "d" === attr ? this.node.path = jvm.VMLPathElement.pathSvgToVml(value) : jvm.VMLShapeElement.prototype.applyAttr.call(this, attr, value) 312}, jvm.VMLPathElement.pathSvgToVml = function(path) { 313 var ctrlx, ctrly, cx = 0, 314 cy = 0; 315 return (path = path.replace(/(-?\d+)e(-?\d+)/g, "0")).replace(/([MmLlHhVvCcSs])\s*((?:-?\d*(?:\.\d+)?\s*,?\s*)+)/g, function(segment, letter, coords, index) { 316 (coords = coords.replace(/(\d)-/g, "$1,-").replace(/^\s+/g, "").replace(/\s+$/g, "").replace(/\s+/g, ",").split(","))[0] || coords.shift(); 317 for (var i = 0, l = coords.length; i < l; i++) coords[i] = Math.round(100 * coords[i]); 318 switch (letter) { 319 case "m": 320 return cx += coords[0], cy += coords[1], "t" + coords.join(","); 321 case "M": 322 return cx = coords[0], cy = coords[1], "m" + coords.join(","); 323 case "l": 324 return cx += coords[0], cy += coords[1], "r" + coords.join(","); 325 case "L": 326 return cx = coords[0], cy = coords[1], "l" + coords.join(","); 327 case "h": 328 return cx += coords[0], "r" + coords[0] + ",0"; 329 case "H": 330 return "l" + (cx = coords[0]) + "," + cy; 331 case "v": 332 return cy += coords[0], "r0," + coords[0]; 333 case "V": 334 return cy = coords[0], "l" + cx + "," + cy; 335 case "c": 336 return ctrlx = cx + coords[coords.length - 4], ctrly = cy + coords[coords.length - 3], cx += coords[coords.length - 2], cy += coords[coords.length - 1], "v" + coords.join(","); 337 case "C": 338 return ctrlx = coords[coords.length - 4], ctrly = coords[coords.length - 3], cx = coords[coords.length - 2], cy = coords[coords.length - 1], "c" + coords.join(","); 339 case "s": 340 return coords.unshift(cy - ctrly), coords.unshift(cx - ctrlx), ctrlx = cx + coords[coords.length - 4], ctrly = cy + coords[coords.length - 3], cx += coords[coords.length - 2], cy += coords[coords.length - 1], "v" + coords.join(","); 341 case "S": 342 return coords.unshift(cy + cy - ctrly), coords.unshift(cx + cx - ctrlx), ctrlx = coords[coords.length - 4], ctrly = coords[coords.length - 3], cx = coords[coords.length - 2], cy = coords[coords.length - 1], "c" + coords.join(",") 343 } 344 return "" 345 }).replace(/z/g, "e") 346}, jvm.VMLCircleElement = function(config, style) { 347 jvm.VMLCircleElement.parentClass.call(this, "oval", config, style) 348}, jvm.inherits(jvm.VMLCircleElement, jvm.VMLShapeElement), jvm.VMLCircleElement.prototype.applyAttr = function(attr, value) { 349 switch (attr) { 350 case "r": 351 this.node.style.width = 2 * value + "px", this.node.style.height = 2 * value + "px", this.applyAttr("cx", this.get("cx") || 0), this.applyAttr("cy", this.get("cy") || 0); 352 break; 353 case "cx": 354 if (!value) return; 355 this.node.style.left = value - (this.get("r") || 0) + "px"; 356 break; 357 case "cy": 358 if (!value) return; 359 this.node.style.top = value - (this.get("r") || 0) + "px"; 360 break; 361 default: 362 jvm.VMLCircleElement.parentClass.prototype.applyAttr.call(this, attr, value) 363 } 364}, jvm.VectorCanvas = function(container, width, height) { 365 return this.mode = window.SVGAngle ? "svg" : "vml", "svg" == this.mode ? this.impl = new jvm.SVGCanvasElement(container, width, height) : this.impl = new jvm.VMLCanvasElement(container, width, height), this.impl.mode = this.mode, this.impl 366}, jvm.SimpleScale = function(scale) { 367 this.scale = scale 368}, jvm.SimpleScale.prototype.getValue = function(value) { 369 return value 370}, jvm.OrdinalScale = function(scale) { 371 this.scale = scale 372}, jvm.OrdinalScale.prototype.getValue = function(value) { 373 return this.scale[value] 374}, jvm.OrdinalScale.prototype.getTicks = function() { 375 var key, ticks = []; 376 for (key in this.scale) ticks.push({ 377 label: key, 378 value: this.scale[key] 379 }); 380 return ticks 381}, jvm.NumericScale = function(scale, normalizeFunction, minValue, maxValue) { 382 this.scale = [], normalizeFunction = normalizeFunction || "linear", scale && this.setScale(scale), normalizeFunction && this.setNormalizeFunction(normalizeFunction), void 0 !== minValue && this.setMin(minValue), void 0 !== maxValue && this.setMax(maxValue) 383}, jvm.NumericScale.prototype = { 384 setMin: function(min) { 385 this.clearMinValue = min, "function" == typeof this.normalize ? this.minValue = this.normalize(min) : this.minValue = min 386 }, 387 setMax: function(max) { 388 this.clearMaxValue = max, "function" == typeof this.normalize ? this.maxValue = this.normalize(max) : this.maxValue = max 389 }, 390 setScale: function(scale) { 391 var i; 392 for (this.scale = [], i = 0; i < scale.length; i++) this.scale[i] = [scale[i]] 393 }, 394 setNormalizeFunction: function(f) { 395 "polynomial" === f ? this.normalize = function(value) { 396 return Math.pow(value, .2) 397 } : "linear" === f ? delete this.normalize : this.normalize = f, this.setMin(this.clearMinValue), this.setMax(this.clearMaxValue) 398 }, 399 getValue: function(value) { 400 var l, c, lengthes = [], 401 fullLength = 0, 402 i = 0; 403 for ("function" == typeof this.normalize && (value = this.normalize(value)), 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; 404 for (c = (this.maxValue - this.minValue) / fullLength, i = 0; i < lengthes.length; i++) lengthes[i] *= c; 405 for (i = 0, value -= this.minValue; 0 <= value - lengthes[i];) value -= lengthes[i], i++; 406 return value = i == this.scale.length - 1 ? this.vectorToNum(this.scale[i]) : this.vectorToNum(this.vectorAdd(this.scale[i], this.vectorMult(this.vectorSubtract(this.scale[i + 1], this.scale[i]), value / lengthes[i]))) 407 }, 408 vectorToNum: function(vector) { 409 var i, num = 0; 410 for (i = 0; i < vector.length; i++) num += Math.round(vector[i]) * Math.pow(256, vector.length - i - 1); 411 return num 412 }, 413 vectorSubtract: function(vector1, vector2) { 414 var i, vector = []; 415 for (i = 0; i < vector1.length; i++) vector[i] = vector1[i] - vector2[i]; 416 return vector 417 }, 418 vectorAdd: function(vector1, vector2) { 419 var i, vector = []; 420 for (i = 0; i < vector1.length; i++) vector[i] = vector1[i] + vector2[i]; 421 return vector 422 }, 423 vectorMult: function(vector, num) { 424 var i, result = []; 425 for (i = 0; i < vector.length; i++) result[i] = vector[i] * num; 426 return result 427 }, 428 vectorLength: function(vector) { 429 var i, result = 0; 430 for (i = 0; i < vector.length; i++) result += vector[i] * vector[i]; 431 return Math.sqrt(result) 432 }, 433 getTicks: function() { 434 var tick, v, extent = [this.clearMinValue, this.clearMaxValue], 435 span = extent[1] - extent[0], 436 step = Math.pow(10, Math.floor(Math.log(span / 5) / Math.LN10)), 437 err = 5 / span * step, 438 ticks = []; 439 for (err <= .15 ? step *= 10 : err <= .35 ? step *= 5 : err <= .75 && (step *= 2), extent[0] = Math.floor(extent[0] / step) * step, extent[1] = Math.ceil(extent[1] / step) * step, tick = extent[0]; tick <= extent[1];) v = tick == extent[0] ? this.clearMinValue : tick == extent[1] ? this.clearMaxValue : tick, ticks.push({ 440 label: tick, 441 value: this.getValue(v) 442 }), tick += step; 443 return ticks 444 } 445}, jvm.ColorScale = function(colors, normalizeFunction, minValue, maxValue) { 446 jvm.ColorScale.parentClass.apply(this, arguments) 447}, jvm.inherits(jvm.ColorScale, jvm.NumericScale), jvm.ColorScale.prototype.setScale = function(scale) { 448 var i; 449 for (i = 0; i < scale.length; i++) this.scale[i] = jvm.ColorScale.rgbToArray(scale[i]) 450}, jvm.ColorScale.prototype.getValue = function(value) { 451 return jvm.ColorScale.numToRgb(jvm.ColorScale.parentClass.prototype.getValue.call(this, value)) 452}, jvm.ColorScale.arrayToRgb = function(ar) { 453 var d, i, rgb = "#"; 454 for (i = 0; i < ar.length; i++) rgb += 1 == (d = ar[i].toString(16)).length ? "0" + d : d; 455 return rgb 456}, jvm.ColorScale.numToRgb = function(num) { 457 for (num = num.toString(16); num.length < 6;) num = "0" + num; 458 return "#" + num 459}, jvm.ColorScale.rgbToArray = function(rgb) { 460 return rgb = rgb.substr(1), [parseInt(rgb.substr(0, 2), 16), parseInt(rgb.substr(2, 2), 16), parseInt(rgb.substr(4, 2), 16)] 461}, jvm.Legend = function(params) { 462 this.params = params || {}, this.map = this.params.map, this.series = this.params.series, this.body = jvm.$("<div/>"), this.body.addClass("jvectormap-legend"), this.params.cssClass && this.body.addClass(this.params.cssClass), params.vertical ? this.map.legendCntVertical.append(this.body) : this.map.legendCntHorizontal.append(this.body), this.render() 463}, jvm.Legend.prototype.render = function() { 464 var i, tick, sample, label, ticks = this.series.scale.getTicks(), 465 inner = jvm.$("<div/>").addClass("jvectormap-legend-inner"); 466 for (this.body.html(""), this.params.title && this.body.append(jvm.$("<div/>").addClass("jvectormap-legend-title").html(this.params.title)), this.body.append(inner), i = 0; i < ticks.length; i++) { 467 switch (tick = jvm.$("<div/>").addClass("jvectormap-legend-tick"), sample = jvm.$("<div/>").addClass("jvectormap-legend-tick-sample"), this.series.params.attribute) { 468 case "fill": 469 jvm.isImageUrl(ticks[i].value) ? sample.css("background", "url(" + ticks[i].value + ")") : sample.css("background", ticks[i].value); 470 break; 471 case "stroke": 472 sample.css("background", ticks[i].value); 473 break; 474 case "image": 475 sample.css("background", "url(" + ("object" == typeof ticks[i].value ? ticks[i].value.url : ticks[i].value) + ") no-repeat center center"); 476 break; 477 case "r": 478 jvm.$("<div/>").css({ 479 "border-radius": ticks[i].value, 480 border: this.map.params.markerStyle.initial["stroke-width"] + "px " + this.map.params.markerStyle.initial.stroke + " solid", 481 width: 2 * ticks[i].value + "px", 482 height: 2 * ticks[i].value + "px", 483 background: this.map.params.markerStyle.initial.fill 484 }).appendTo(sample) 485 } 486 tick.append(sample), label = ticks[i].label, this.params.labelRender && (label = this.params.labelRender(label)), tick.append(jvm.$("<div>" + label + " </div>").addClass("jvectormap-legend-tick-text")), inner.append(tick) 487 } 488 inner.append(jvm.$("<div/>").css("clear", "both")) 489}, jvm.DataSeries = function(params, elements, map) { 490 var scaleConstructor; 491 (params = params || {}).attribute = params.attribute || "fill", this.elements = elements, this.params = params, this.map = map, params.attributes && this.setAttributes(params.attributes), jvm.$.isArray(params.scale) ? (scaleConstructor = "fill" === params.attribute || "stroke" === params.attribute ? jvm.ColorScale : jvm.NumericScale, this.scale = new scaleConstructor(params.scale, params.normalizeFunction, params.min, params.max)) : params.scale ? this.scale = new jvm.OrdinalScale(params.scale) : this.scale = new jvm.SimpleScale(params.scale), this.values = params.values || {}, this.setValues(this.values), this.params.legend && (this.legend = new jvm.Legend(jvm.$.extend({ 492 map: this.map, 493 series: this 494 }, this.params.legend))) 495}, jvm.DataSeries.prototype = { 496 setAttributes: function(key, attr) { 497 var code, attrs = key; 498 if ("string" == typeof key) this.elements[key] && this.elements[key].setStyle(this.params.attribute, attr); 499 else 500 for (code in attrs) this.elements[code] && this.elements[code].element.setStyle(this.params.attribute, attrs[code]) 501 }, 502 setValues: function(values) { 503 var val, cc, max = -Number.MAX_VALUE, 504 min = Number.MAX_VALUE, 505 attrs = {}; 506 if (this.scale instanceof jvm.OrdinalScale || this.scale instanceof jvm.SimpleScale) 507 for (cc in values) values[cc] ? attrs[cc] = this.scale.getValue(values[cc]) : attrs[cc] = this.elements[cc].element.style.initial[this.params.attribute]; 508 else { 509 if (void 0 === this.params.min || void 0 === this.params.max) 510 for (cc in values) max < (val = parseFloat(values[cc])) && (max = val), val < min && (min = val); 511 for (cc in void 0 === this.params.min ? (this.scale.setMin(min), this.params.min = min) : this.scale.setMin(this.params.min), void 0 === this.params.max ? (this.scale.setMax(max), this.params.max = max) : this.scale.setMax(this.params.max), values) "indexOf" != cc && (val = parseFloat(values[cc]), isNaN(val) ? attrs[cc] = this.elements[cc].element.style.initial[this.params.attribute] : attrs[cc] = this.scale.getValue(val)) 512 } 513 this.setAttributes(attrs), jvm.$.extend(this.values, values) 514 }, 515 clear: function() { 516 var key, attrs = {}; 517 for (key in this.values) this.elements[key] && (attrs[key] = this.elements[key].element.shape.style.initial[this.params.attribute]); 518 this.setAttributes(attrs), this.values = {} 519 }, 520 setScale: function(scale) { 521 this.scale.setScale(scale), this.values && this.setValues(this.values) 522 }, 523 setNormalizeFunction: function(f) { 524 this.scale.setNormalizeFunction(f), this.values && this.setValues(this.values) 525 } 526}, jvm.Proj = { 527 degRad: 180 / Math.PI, 528 radDeg: Math.PI / 180, 529 radius: 6381372, 530 sgn: function(n) { 531 return 0 < n ? 1 : n < 0 ? -1 : n 532 }, 533 mill: function(lat, lng, c) { 534 return { 535 x: this.radius * (lng - c) * this.radDeg, 536 y: -this.radius * Math.log(Math.tan((45 + .4 * lat) * this.radDeg)) / .8 537 } 538 }, 539 mill_inv: function(x, y, c) { 540 return { 541 lat: (2.5 * Math.atan(Math.exp(.8 * y / this.radius)) - 5 * Math.PI / 8) * this.degRad, 542 lng: (c * this.radDeg + x / this.radius) * this.degRad 543 } 544 }, 545 merc: function(lat, lng, c) { 546 return { 547 x: this.radius * (lng - c) * this.radDeg, 548 y: -this.radius * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360)) 549 } 550 }, 551 merc_inv: function(x, y, c) { 552 return { 553 lat: (2 * Math.atan(Math.exp(y / this.radius)) - Math.PI / 2) * this.degRad, 554 lng: (c * this.radDeg + x / this.radius) * this.degRad 555 } 556 }, 557 aea: function(lat, lng, c) { 558 var lambda0 = c * this.radDeg, 559 fi1 = 29.5 * this.radDeg, 560 fi2 = 45.5 * this.radDeg, 561 fi = lat * this.radDeg, 562 lambda = lng * this.radDeg, 563 n = (Math.sin(fi1) + Math.sin(fi2)) / 2, 564 C = Math.cos(fi1) * Math.cos(fi1) + 2 * n * Math.sin(fi1), 565 theta = n * (lambda - lambda0), 566 ro = Math.sqrt(C - 2 * n * Math.sin(fi)) / n, 567 ro0 = Math.sqrt(C - 2 * n * Math.sin(0)) / n; 568 return { 569 x: ro * Math.sin(theta) * this.radius, 570 y: -(ro0 - ro * Math.cos(theta)) * this.radius 571 } 572 }, 573 aea_inv: function(xCoord, yCoord, c) { 574 var x = xCoord / this.radius, 575 y = yCoord / this.radius, 576 lambda0 = c * this.radDeg, 577 fi1 = 29.5 * this.radDeg, 578 fi2 = 45.5 * this.radDeg, 579 n = (Math.sin(fi1) + Math.sin(fi2)) / 2, 580 C = Math.cos(fi1) * Math.cos(fi1) + 2 * n * Math.sin(fi1), 581 ro0 = Math.sqrt(C - 2 * n * Math.sin(0)) / n, 582 ro = Math.sqrt(x * x + (ro0 - y) * (ro0 - y)), 583 theta = Math.atan(x / (ro0 - y)); 584 return { 585 lat: Math.asin((C - ro * ro * n * n) / (2 * n)) * this.degRad, 586 lng: (lambda0 + theta / n) * this.degRad 587 } 588 }, 589 lcc: function(lat, lng, c) { 590 var lambda0 = c * this.radDeg, 591 lambda = lng * this.radDeg, 592 fi1 = 33 * this.radDeg, 593 fi2 = 45 * this.radDeg, 594 fi = lat * this.radDeg, 595 n = Math.log(Math.cos(fi1) * (1 / Math.cos(fi2))) / Math.log(Math.tan(Math.PI / 4 + fi2 / 2) * (1 / Math.tan(Math.PI / 4 + fi1 / 2))), 596 F = Math.cos(fi1) * Math.pow(Math.tan(Math.PI / 4 + fi1 / 2), n) / n, 597 ro = F * Math.pow(1 / Math.tan(Math.PI / 4 + fi / 2), n), 598 ro0 = F * Math.pow(1 / Math.tan(Math.PI / 4 + 0), n); 599 return { 600 x: ro * Math.sin(n * (lambda - lambda0)) * this.radius, 601 y: -(ro0 - ro * Math.cos(n * (lambda - lambda0))) * this.radius 602 } 603 }, 604 lcc_inv: function(xCoord, yCoord, c) { 605 var x = xCoord / this.radius, 606 y = yCoord / this.radius, 607 lambda0 = c * this.radDeg, 608 fi1 = 33 * this.radDeg, 609 fi2 = 45 * this.radDeg, 610 n = Math.log(Math.cos(fi1) * (1 / Math.cos(fi2))) / Math.log(Math.tan(Math.PI / 4 + fi2 / 2) * (1 / Math.tan(Math.PI / 4 + fi1 / 2))), 611 F = Math.cos(fi1) * Math.pow(Math.tan(Math.PI / 4 + fi1 / 2), n) / n, 612 ro0 = F * Math.pow(1 / Math.tan(Math.PI / 4 + 0), n), 613 ro = this.sgn(n) * Math.sqrt(x * x + (ro0 - y) * (ro0 - y)), 614 theta = Math.atan(x / (ro0 - y)); 615 return { 616 lat: (2 * Math.atan(Math.pow(F / ro, 1 / n)) - Math.PI / 2) * this.degRad, 617 lng: (lambda0 + theta / n) * this.degRad 618 } 619 } 620}, jvm.MapObject = function(config) {}, jvm.MapObject.prototype.getLabelText = function(key) { 621 return this.config.label ? "function" == typeof this.config.label.render ? this.config.label.render(key) : key : null 622}, jvm.MapObject.prototype.getLabelOffsets = function(key) { 623 var offsets; 624 return this.config.label && ("function" == typeof this.config.label.offsets ? offsets = this.config.label.offsets(key) : "object" == typeof this.config.label.offsets && (offsets = this.config.label.offsets[key])), offsets || [0, 0] 625}, jvm.MapObject.prototype.setHovered = function(isHovered) { 626 this.isHovered !== isHovered && (this.isHovered = isHovered, this.shape.isHovered = isHovered, this.shape.updateStyle(), this.label && (this.label.isHovered = isHovered, this.label.updateStyle())) 627}, jvm.MapObject.prototype.setSelected = function(isSelected) { 628 this.isSelected !== isSelected && (this.isSelected = isSelected, this.shape.isSelected = isSelected, this.shape.updateStyle(), this.label && (this.label.isSelected = isSelected, this.label.updateStyle()), jvm.$(this.shape).trigger("selected", [isSelected])) 629}, jvm.MapObject.prototype.setStyle = function() { 630 this.shape.setStyle.apply(this.shape, arguments) 631}, jvm.MapObject.prototype.remove = function() { 632 this.shape.remove(), this.label && this.label.remove() 633}, jvm.Region = function(config) { 634 var bbox, text, offsets; 635 this.config = config, this.map = this.config.map, this.shape = config.canvas.addPath({ 636 d: config.path, 637 "data-code": config.code 638 }, config.style, config.canvas.rootElement), this.shape.addClass("jvectormap-region jvectormap-element"), bbox = this.shape.getBBox(), text = this.getLabelText(config.code), this.config.label && text && (offsets = this.getLabelOffsets(config.code), this.labelX = bbox.x + bbox.width / 2 + offsets[0], this.labelY = bbox.y + bbox.height / 2 + offsets[1], this.label = config.canvas.addText({ 639 text: text, 640 "text-anchor": "middle", 641 "alignment-baseline": "central", 642 x: this.labelX, 643 y: this.labelY, 644 "data-code": config.code 645 }, config.labelStyle, config.labelsGroup), this.label.addClass("jvectormap-region jvectormap-element")) 646}, jvm.inherits(jvm.Region, jvm.MapObject), jvm.Region.prototype.updateLabelPosition = function() { 647 this.label && this.label.set({ 648 x: this.labelX * this.map.scale + this.map.transX * this.map.scale, 649 y: this.labelY * this.map.scale + this.map.transY * this.map.scale 650 }) 651}, jvm.Marker = function(config) { 652 var text; 653 this.config = config, this.map = this.config.map, this.isImage = !!this.config.style.initial.image, this.createShape(), text = this.getLabelText(config.index), 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({ 654 text: text, 655 "data-index": config.index, 656 dy: "0.6ex", 657 x: this.labelX, 658 y: this.labelY 659 }, config.labelStyle, config.labelsGroup), this.label.addClass("jvectormap-marker jvectormap-element")) 660}, jvm.inherits(jvm.Marker, jvm.MapObject), jvm.Marker.prototype.createShape = function() { 661 var that = this; 662 this.shape && this.shape.remove(), this.shape = this.config.canvas[this.isImage ? "addImage" : "addCircle"]({ 663 "data-index": this.config.index, 664 cx: this.config.cx, 665 cy: this.config.cy 666 }, this.config.style, this.config.group), this.shape.addClass("jvectormap-marker jvectormap-element"), this.isImage && jvm.$(this.shape.node).on("imageloaded", function() { 667 that.updateLabelPosition() 668 }) 669}, jvm.Marker.prototype.updateLabelPosition = function() { 670 this.label && this.label.set({ 671 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), 672 y: this.labelY * this.map.scale + this.map.transY * this.map.scale + this.offsets[1] 673 }) 674}, jvm.Marker.prototype.setStyle = function(property, value) { 675 var isImage; 676 jvm.Marker.parentClass.prototype.setStyle.apply(this, arguments), "r" === property && this.updateLabelPosition(), (isImage = !!this.shape.get("image")) != this.isImage && (this.isImage = isImage, this.config.style = jvm.$.extend(!0, {}, this.shape.style), this.createShape()) 677}, jvm.Map = function(params) { 678 var e, map = this; 679 if (this.params = jvm.$.extend(!0, {}, jvm.Map.defaultParams, params), !jvm.Map.maps[this.params.map]) throw new Error("Attempt to use map which was not loaded: " + this.params.map); 680 for (e in this.mapData = jvm.Map.maps[this.params.map], this.markers = {}, this.regions = {}, this.regionsColors = {}, this.regionsData = {}, this.container = jvm.$("<div>").addClass("jvectormap-container"), this.params.container && this.params.container.append(this.container), this.container.data("mapObject", this), this.defaultWidth = this.mapData.width, this.defaultHeight = this.mapData.height, this.setBackgroun
vendor: 4,926 bytes, lines 680-729
680dColor(this.params.backgroundColor), this.onResize = function() { 681 map.updateSize() 682 }, jvm.$(window).resize(this.onResize), jvm.Map.apiEvents) this.params[e] && this.container.bind(jvm.Map.apiEvents[e] + ".jvectormap", this.params[e]); 683 this.canvas = new jvm.VectorCanvas(this.container[0], this.width, this.height), this.params.bindTouchEvents && ("ontouchstart" in window || window.DocumentTouch && document instanceof DocumentTouch ? this.bindContainerTouchEvents() : window.MSGesture && this.bindContainerPointerEvents()), this.bindContainerEvents(), this.bindElementEvents(), this.createTip(), this.params.zoomButtons && this.bindZoomButtons(), this.createRegions(), this.createMarkers(this.params.markers || {}), this.updateSize(), this.params.focusOn && ("string" == typeof this.params.focusOn ? this.params.focusOn = { 684 region: this.params.focusOn 685 } : jvm.$.isArray(this.params.focusOn) && (this.params.focusOn = { 686 regions: this.params.focusOn 687 }), this.setFocus(this.params.focusOn)), this.params.selectedRegions && this.setSelectedRegions(this.params.selectedRegions), this.params.selectedMarkers && this.setSelectedMarkers(this.params.selectedMarkers), this.legendCntHorizontal = jvm.$("<div/>").addClass("jvectormap-legend-cnt jvectormap-legend-cnt-h"), this.legendCntVertical = jvm.$("<div/>").addClass("jvectormap-legend-cnt jvectormap-legend-cnt-v"), this.container.append(this.legendCntHorizontal), this.container.append(this.legendCntVertical), this.params.series && this.createSeries() 688}, jvm.Map.prototype = { 689 transX: 0, 690 transY: 0, 691 scale: 1, 692 baseTransX: 0, 693 baseTransY: 0, 694 baseScale: 1, 695 width: 0, 696 height: 0, 697 setBackgroundColor: function(backgroundColor) { 698 this.container.css("background-color", backgroundColor) 699 }, 700 resize: function() { 701 var curBaseScale = this.baseScale; 702 this.width / this.height > this.defaultWidth / this.defaultHeight ? (this.baseScale = this.height / this.defaultHeight, this.baseTransX = Math.abs(this.width - this.defaultWidth * this.baseScale) / (2 * this.baseScale)) : (this.baseScale = this.width / this.defaultWidth, this.baseTransY = Math.abs(this.height - this.defaultHeight * this.baseScale) / (2 * this.baseScale)), this.scale *= this.baseScale / curBaseScale, this.transX *= this.baseScale / curBaseScale, this.transY *= this.baseScale / curBaseScale 703 }, 704 updateSize: function() { 705 this.width = this.container.width(), this.height = this.container.height(), this.resize(), this.canvas.setSize(this.width, this.height), this.applyTransform() 706 }, 707 reset: function() { 708 var key, i; 709 for (key in this.series) 710 for (i = 0; i < this.series[key].length; i++) this.series[key][i].clear(); 711 this.scale = this.baseScale, this.transX = this.baseTransX, this.transY = this.baseTransY, this.applyTransform() 712 }, 713 applyTransform: function() { 714 var maxTransX, maxTransY, minTransX, minTransY; 715 minTransX = this.defaultWidth * this.scale <= this.width ? (maxTransX = (this.width - this.defaultWidth * this.scale) / (2 * this.scale), (this.width - this.defaultWidth * this.scale) / (2 * this.scale)) : (maxTransX = 0, (this.width - this.defaultWidth * this.scale) / this.scale), minTransY = this.defaultHeight * this.scale <= this.height ? (maxTransY = (this.height - this.defaultHeight * this.scale) / (2 * this.scale), (this.height - this.defaultHeight * this.scale) / (2 * this.scale)) : (maxTransY = 0, (this.height - this.defaultHeight * this.scale) / this.scale), this.transY > maxTransY ? this.transY = maxTransY : this.transY < minTransY && (this.transY = minTransY), this.transX > maxTransX ? this.transX = maxTransX : this.transX < minTransX && (this.transX = minTransX), this.canvas.applyTransformParams(this.scale, this.transX, this.transY), this.markers && this.repositionMarkers(), this.repositionLabels(), this.container.trigger("viewportChange", [this.scale / this.baseScale, this.transX, this.transY]) 716 }, 717 bindContainerEvents: function() { 718 var oldPageX, oldPageY, mouseDown = !1, 719 map = this; 720 this.params.panOnDrag && (this.container.mousemove(function(e) { 721 return mouseDown && (map.transX -= (oldPageX - e.pageX) / map.scale, map.transY -= (oldPageY - e.pageY) / map.scale, map.applyTransform(), oldPageX = e.pageX, oldPageY = e.pageY), !1 722 }).mousedown(function(e) { 723 return mouseDown = !0, oldPageX = e.pageX, oldPageY = e.pageY, !1 724 }), this.onContainerMouseUp = function() { 725 mouseDown = !1 726 }, jvm.$("body").mouseup(this.onContainerMouseUp)), this.params.zoomOnScroll && this.container.mousewheel(function(event, delta, deltaX, deltaY) { 727 var offset = jvm.$(map.container).offset(), 728 centerX = event.pageX - offset.left, 729 centerY = event.pageY - offset.top,
vendor: 4,677 bytes, lines 730-768
730 zoomStep = Math.pow(1 + map.params.zoomOnScrollSpeed / 1e3, event.deltaFactor * event.deltaY); 731 map.tip.hide(), map.setScale(map.scale * zoomStep, centerX, centerY), event.preventDefault() 732 }) 733 }, 734 bindContainerTouchEvents: function() { 735 function handleTouchEvent(e) { 736 var offset, scale, transXOld, transYOld, touches = e.originalEvent.touches; 737 "touchstart" == e.type && (lastTouchesLength = 0), 1 == touches.length ? (1 == lastTouchesLength && (transXOld = map.transX, transYOld = map.transY, map.transX -= (touchX - touches[0].pageX) / map.scale, map.transY -= (touchY - touches[0].pageY) / map.scale, map.applyTransform(), map.tip.hide(), transXOld == map.transX && transYOld == map.transY || e.preventDefault()), touchX = touches[0].pageX, touchY = touches[0].pageY) : 2 == touches.length && (2 == lastTouchesLength ? (scale = Math.sqrt(Math.pow(touches[0].pageX - touches[1].pageX, 2) + Math.pow(touches[0].pageY - touches[1].pageY, 2)) / touchStartDistance, map.setScale(touchStartScale * scale, centerTouchX, centerTouchY), map.tip.hide(), e.preventDefault()) : (offset = jvm.$(map.container).offset(), centerTouchX = touches[0].pageX > touches[1].pageX ? touches[1].pageX + (touches[0].pageX - touches[1].pageX) / 2 : touches[0].pageX + (touches[1].pageX - touches[0].pageX) / 2, centerTouchY = touches[0].pageY > touches[1].pageY ? touches[1].pageY + (touches[0].pageY - touches[1].pageY) / 2 : touches[0].pageY + (touches[1].pageY - touches[0].pageY) / 2, centerTouchX -= offset.left, centerTouchY -= offset.top, touchStartScale = map.scale, touchStartDistance = Math.sqrt(Math.pow(touches[0].pageX - touches[1].pageX, 2) + Math.pow(touches[0].pageY - touches[1].pageY, 2)))), lastTouchesLength = touches.length 738 } 739 var touchStartScale, touchStartDistance, touchX, touchY, centerTouchX, centerTouchY, lastTouchesLength, map = this; 740 jvm.$(this.container).bind("touchstart", handleTouchEvent), jvm.$(this.container).bind("touchmove", handleTouchEvent) 741 }, 742 bindContainerPointerEvents: function() { 743 var map = this, 744 gesture = new MSGesture, 745 element = this.container[0]; 746 (gesture.target = element).addEventListener("MSGestureChange", function(e) { 747 var transXOld, transYOld; 748 0 == e.translationX && 0 == e.translationY || (transXOld = map.transX, transYOld = map.transY, map.transX += e.translationX / map.scale, map.transY += e.translationY / map.scale, map.applyTransform(), map.tip.hide(), transXOld == map.transX && transYOld == map.transY || e.preventDefault()), 1 != e.scale && (map.setScale(map.scale * e.scale, e.offsetX, e.offsetY), map.tip.hide(), e.preventDefault()) 749 }, !1), element.addEventListener("pointerdown", function(e) { 750 gesture.addPointer(e.pointerId) 751 }, !1) 752 }, 753 bindElementEvents: function() { 754 var pageX, pageY, mouseMoved, map = this; 755 this.container.mousemove(function(e) { 756 2 < Math.abs(pageX - e.pageX) + Math.abs(pageY - e.pageY) && (mouseMoved = !0) 757 }), this.container.delegate("[class~='jvectormap-element']", "mouseover mouseout", function(e) { 758 var type = -1 === (jvm.$(this).attr("class").baseVal || jvm.$(this).attr("class")).indexOf("jvectormap-region") ? "marker" : "region", 759 code = "region" == type ? jvm.$(this).attr("data-code") : jvm.$(this).attr("data-index"), 760 element = "region" == type ? map.regions[code].element : map.markers[code].element, 761 tipText = "region" == type ? map.mapData.paths[code].name : map.markers[code].config.name || "", 762 tipShowEvent = jvm.$.Event(type + "TipShow.jvectormap"), 763 overEvent = jvm.$.Event(type + "Over.jvectormap"); 764 "mouseover" == e.type ? (map.container.trigger(overEvent, [code]), overEvent.isDefaultPrevented() || element.setHovered(!0), map.tip.text(tipText), map.container.trigger(tipShowEvent, [map.tip, code]), tipShowEvent.isDefaultPrevented() || (map.tip.show(), map.tipWidth = map.tip.width(), map.tipHeight = map.tip.height())) : (element.setHovered(!1), map.tip.hide(), map.container.trigger(type + "Out.jvectormap", [code])) 765 }), this.container.delegate("[class~='jvectormap-element']", "mousedown", function(e) { 766 pageX = e.pageX, pageY = e.pageY, mouseMoved = !1 767 }), this.container.delegate("[class~='jvectormap-element']", "mouseup", function() { 768 var type = -1 === (jvm.$(this).attr("class").baseVal ? jvm.$(this).attr("class").baseVal : jvm.$(this).attr("class")).indexOf("jvectormap-region") ? "marker" : "regi
768on", 769 code = "region" == type ? jvm.$(this).attr("data-code") : jvm.$(this).attr("data-index"), 770 clickEvent = jvm.$.Event(type + "Click.jvectormap"), 771 element = "region" == type ? map.regions[code].element : map.markers[code].element; 772 mouseMoved || (map.container.trigger(clickEvent, [code]), ("region" == type && map.params.regionsSelectable || "marker" == type && map.params.markersSelectable) && (clickEvent.isDefaultPrevented() || (map.params[type + "sSelectableOne"] && map.clearSelected(type + "s"), element.setSelected(!element.isSelected)))) 773 }) 774 }, 775 bindZoomButtons: function() { 776 var map = this; 777 jvm.$("<div/>").addClass("jvectormap-zoomin").text("+").appendTo(this.container), jvm.$("<div/>").addClass("jvectormap-zoomout").html("−").appendTo(this.container), this.container.find(".jvectormap-zoomin").click(function() { 778 map.setScale(map.scale * map.params.zoomStep, map.width / 2, map.height / 2, !1, map.params.zoomAnimate) 779 }), this.container.find(".jvectormap-zoomout").click(function() { 780 map.setScale(map.scale / map.params.zoomStep, map.width / 2, map.height / 2, !1, map.params.zoomAnimate) 781 }) 782 }, 783 createTip: function() { 784 var map = this; 785 this.tip = jvm.$("<div/>").addClass("jvectormap-tip").appendTo(jvm.$("body")), this.container.mousemove(function(e) { 786 var left = e.pageX - 15 - map.tipWidth, 787 top = e.pageY - 15 - map.tipHeight; 788 left < 5 && (left = e.pageX + 15), top < 5 && (top = e.pageY + 15), map.tip.css({ 789 left: left, 790 top: top 791 }) 792 }) 793 }, 794 setScale: function(scale, anchorX, anchorY, isCentered, animate) { 795 var interval, scaleStart, scaleDiff, transXStart, transXDiff, transYStart, transYDiff, transX, transY, viewportChangeEvent = jvm.$.Event("zoom.jvectormap"), 796 that = this, 797 i = 0, 798 count = Math.abs(Math.round(60 * (scale - this.scale) / Math.max(scale, this.scale))), 799 deferred = new jvm.$.Deferred; 800 return scale > this.params.zoomMax * this.baseScale ? scale = this.params.zoomMax * this.baseScale : scale < this.params.zoomMin * this.baseScale && (scale = this.params.zoomMin * this.baseScale), void 0 !== anchorX && void 0 !== anchorY && (zoomStep
vendor: 13,806 bytes, lines 800-1076
800= scale / this.scale, transY = isCentered ? (transX = anchorX + this.defaultWidth * (this.width / (this.defaultWidth * scale)) / 2, anchorY + this.defaultHeight * (this.height / (this.defaultHeight * scale)) / 2) : (transX = this.transX - (zoomStep - 1) / scale * anchorX, this.transY - (zoomStep - 1) / scale * anchorY)), animate && 0 < count ? (scaleStart = this.scale, scaleDiff = (scale - scaleStart) / count, transXStart = this.transX * this.scale, transYStart = this.transY * this.scale, transXDiff = (transX * scale - transXStart) / count, transYDiff = (transY * scale - transYStart) / count, interval = setInterval(function() { 801 i += 1, that.scale = scaleStart + scaleDiff * i, that.transX = (transXStart + transXDiff * i) / that.scale, that.transY = (transYStart + transYDiff * i) / that.scale, that.applyTransform(), i == count && (clearInterval(interval), that.container.trigger(viewportChangeEvent, [scale / that.baseScale]), deferred.resolve()) 802 }, 10)) : (this.transX = transX, this.transY = transY, this.scale = scale, this.applyTransform(), this.container.trigger(viewportChangeEvent, [scale / this.baseScale]), deferred.resolve()), deferred 803 }, 804 setFocus: function(config) { 805 var bbox, itemBbox, codes, i, point; 806 if ((config = config || {}).region ? codes = [config.region] : config.regions && (codes = config.regions), codes) { 807 for (i = 0; i < codes.length; i++) this.regions[codes[i]] && (itemBbox = this.regions[codes[i]].element.shape.getBBox()) && (bbox = void 0 === bbox ? itemBbox : { 808 x: Math.min(bbox.x, itemBbox.x), 809 y: Math.min(bbox.y, itemBbox.y), 810 width: Math.max(bbox.x + bbox.width, itemBbox.x + itemBbox.width) - Math.min(bbox.x, itemBbox.x), 811 height: Math.max(bbox.y + bbox.height, itemBbox.y + itemBbox.height) - Math.min(bbox.y, itemBbox.y) 812 }); 813 return this.setScale(Math.min(this.width / bbox.width, this.height / bbox.height), -(bbox.x + bbox.width / 2), -(bbox.y + bbox.height / 2), !0, config.animate) 814 } 815 return void 0 !== config.lat && void 0 !== config.lng ? (point = this.latLngToPoint(config.lat, config.lng), config.x = this.transX - point.x / this.scale, config.y = this.transY - point.y / this.scale) : config.x && config.y && (config.x *= -this.defaultWidth, config.y *= -this.defaultHeight), this.setScale(config.scale * this.baseScale, config.x, config.y, !0, config.animate) 816 }, 817 getSelected: function(type) { 818 var key, selected = []; 819 for (key in this[type]) this[type][key].element.isSelected && selected.push(key); 820 return selected 821 }, 822 getSelectedRegions: function() { 823 return this.getSelected("regions") 824 }, 825 getSelectedMarkers: function() { 826 return this.getSelected("markers") 827 }, 828 setSelected: function(type, keys) { 829 var i; 830 if ("object" != typeof keys && (keys = [keys]), jvm.$.isArray(keys)) 831 for (i = 0; i < keys.length; i++) this[type][keys[i]].element.setSelected(!0); 832 else 833 for (i in keys) this[type][i].element.setSelected(!!keys[i]) 834 }, 835 setSelectedRegions: function(keys) { 836 this.setSelected("regions", keys) 837 }, 838 setSelectedMarkers: function(keys) { 839 this.setSelected("markers", keys) 840 }, 841 clearSelected: function(type) { 842 var i, select = {}, 843 selected = this.getSelected(type); 844 for (i = 0; i < selected.length; i++) select[selected[i]] = !1; 845 this.setSelected(type, select) 846 }, 847 clearSelectedRegions: function() { 848 this.clearSelected("regions") 849 }, 850 clearSelectedMarkers: function() { 851 this.clearSelected("markers") 852 }, 853 getMapObject: function() { 854 return this 855 }, 856 getRegionName: function(code) { 857 return this.mapData.paths[code].name 858 }, 859 createRegions: function() { 860 var key, region, map = this; 861 for (key in this.regionLabelsGroup = this.regionLabelsGroup || this.canvas.addGroup(), this.mapData.paths) region = new jvm.Region({ 862 map: this, 863 path: this.mapData.paths[key].path, 864 code: key, 865 style: jvm.$.extend(!0, {}, this.params.regionStyle), 866 labelStyle: jvm.$.extend(!0, {}, this.params.regionLabelStyle), 867 canvas: this.canvas, 868 labelsGroup: this.regionLabelsGroup, 869 label: "vml" != this.canvas.mode ? this.params.labels && this.params.labels.regions : null 870 }), jvm.$(region.shape).bind("selected", function(e, isSelected) { 871 map.container.trigger("regionSelected.jvectormap", [jvm.$(this.node).attr("data-code"), isSelected, map.getSelectedRegions()]) 872 }), this.regions[key] = { 873 element: region, 874 config: this.mapData.paths[key] 875 } 876 }, 877 createMarkers: function(markers) { 878 var i, marker, point, markerConfig, markersArray, map = this; 879 if (this.markersGroup = this.markersGroup || this.canvas.addGroup(), this.markerLabelsGroup = this.markerLabelsGroup || this.canvas.addGroup(), jvm.$.isArray(markers)) 880 for (markersArray = markers.slice(), markers = {}, i = 0; i < markersArray.length; i++) markers[i] = markersArray[i]; 881 for (i in markers) markerConfig = markers[i] instanceof Array ? { 882 latLng: markers[i] 883 } : markers[i], !1 !== (point = this.getMarkerPosition(markerConfig)) && (marker = new jvm.Marker({ 884 map: this, 885 style: jvm.$.extend(!0, {}, this.params.markerStyle, { 886 initial: markerConfig.style || {} 887 }), 888 labelStyle: jvm.$.extend(!0, {}, this.params.markerLabelStyle), 889 index: i, 890 cx: point.x, 891 cy: point.y, 892 group: this.markersGroup, 893 canvas: this.canvas, 894 labelsGroup: this.markerLabelsGroup, 895 label: "vml" != this.canvas.mode ? this.params.labels && this.params.labels.markers : null 896 }), jvm.$(marker.shape).bind("selected", function(e, isSelected) { 897 map.container.trigger("markerSelected.jvectormap", [jvm.$(this.node).attr("data-index"), isSelected, map.getSelectedMarkers()]) 898 }), this.markers[i] && this.removeMarkers([i]), this.markers[i] = { 899 element: marker, 900 config: markerConfig 901 }) 902 }, 903 repositionMarkers: function() { 904 var i, point; 905 for (i in this.markers) !1 !== (point = this.getMarkerPosition(this.markers[i].config)) && this.markers[i].element.setStyle({ 906 cx: point.x, 907 cy: point.y 908 }) 909 }, 910 repositionLabels: function() { 911 var key; 912 for (key in this.regions) this.regions[key].element.updateLabelPosition(); 913 for (key in this.markers) this.markers[key].element.updateLabelPosition() 914 }, 915 getMarkerPosition: function(markerConfig) { 916 return jvm.Map.maps[this.params.map].projection ? this.latLngToPoint.apply(this, markerConfig.latLng || [0, 0]) : { 917 x: markerConfig.coords[0] * this.scale + this.transX * this.scale, 918 y: markerConfig.coords[1] * this.scale + this.transY * this.scale 919 } 920 }, 921 addMarker: function(key, marker, seriesData) { 922 var values, i, markers = {}, 923 data = []; 924 seriesData = seriesData || []; 925 for (markers[key] = marker, i = 0; i < seriesData.length; i++) values = {}, void 0 !== seriesData[i] && (values[key] = seriesData[i]), data.push(values); 926 this.addMarkers(markers, data) 927 }, 928 addMarkers: function(markers, seriesData) { 929 var i; 930 for (seriesData = seriesData || [], this.createMarkers(markers), i = 0; i < seriesData.length; i++) this.series.markers[i].setValues(seriesData[i] || {}) 931 }, 932 removeMarkers: function(markers) { 933 var i; 934 for (i = 0; i < markers.length; i++) this.markers[markers[i]].element.remove(), delete this.markers[markers[i]] 935 }, 936 removeAllMarkers: function() { 937 var i, markers = []; 938 for (i in this.markers) markers.push(i); 939 this.removeMarkers(markers) 940 }, 941 latLngToPoint: function(lat, lng) { 942 var point, inset, bbox, proj = jvm.Map.maps[this.params.map].projection, 943 centralMeridian = proj.centralMeridian; 944 return lng < -180 + centralMeridian && (lng += 360), point = jvm.Proj[proj.type](lat, lng, centralMeridian), !!(inset = this.getInsetForPoint(point.x, point.y)) && (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, { 945 x: point.x + this.transX * this.scale + inset.left * this.scale, 946 y: point.y + this.transY * this.scale + inset.top * this.scale 947 }) 948 }, 949 pointToLatLng: function(x, y) { 950 var i, inset, bbox, nx, ny, proj = jvm.Map.maps[this.params.map].projection, 951 centralMeridian = proj.centralMeridian, 952 insets = jvm.Map.maps[this.params.map].insets; 953 for (i = 0; i < insets.length; i++) 954 if (bbox = (inset = insets[i]).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, 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); 955 return !1 956 }, 957 getInsetForPoint: function(x, y) { 958 var i, bbox, insets = jvm.Map.maps[this.params.map].insets; 959 for (i = 0; i < insets.length; i++) 960 if (x > (bbox = insets[i].bbox)[0].x && x < bbox[1].x && y > bbox[0].y && y < bbox[1].y) return insets[i] 961 }, 962 createSeries: function() { 963 var i, key; 964 for (key in this.series = { 965 markers: [], 966 regions: [] 967 }, this.params.series) 968 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) 969 }, 970 remove: function() { 971 this.tip.remove(), this.container.remove(), jvm.$(window).unbind("resize", this.onResize), jvm.$("body").unbind("mouseup", this.onContainerMouseUp) 972 } 973}, jvm.Map.maps = {}, jvm.Map.defaultParams = { 974 map: "world_mill_en", 975 backgroundColor: "#505050", 976 zoomButtons: !0, 977 zoomOnScroll: !0, 978 zoomOnScrollSpeed: 3, 979 panOnDrag: !0, 980 zoomMax: 8, 981 zoomMin: 1, 982 zoomStep: 1.6, 983 zoomAnimate: !0, 984 regionsSelectable: !1, 985 markersSelectable: !1, 986 bindTouchEvents: !0, 987 regionStyle: { 988 initial: { 989 fill: "white", 990 "fill-opacity": 1, 991 stroke: "none", 992 "stroke-width": 0, 993 "stroke-opacity": 1 994 }, 995 hover: { 996 "fill-opacity": .8, 997 cursor: "pointer" 998 }, 999 selected: { 1000 fill: "yellow" 1001 }, 1002 selectedHover: {} 1003 }, 1004 regionLabelStyle: { 1005 initial: { 1006 "font-family": "Verdana", 1007 "font-size": "12", 1008 "font-weight": "bold", 1009 cursor: "default", 1010 fill: "black" 1011 }, 1012 hover: { 1013 cursor: "pointer" 1014 } 1015 }, 1016 markerStyle: { 1017 initial: { 1018 fill: "grey", 1019 stroke: "#505050", 1020 "fill-opacity": 1, 1021 "stroke-width": 1, 1022 "stroke-opacity": 1, 1023 r: 5 1024 }, 1025 hover: { 1026 stroke: "black", 1027 "stroke-width": 2, 1028 cursor: "pointer" 1029 }, 1030 selected: { 1031 fill: "blue" 1032 }, 1033 selectedHover: {} 1034 }, 1035 markerLabelStyle: { 1036 initial: { 1037 "font-family": "Verdana", 1038 "font-size": "12", 1039 "font-weight": "bold", 1040 cursor: "default", 1041 fill: "black" 1042 }, 1043 hover: { 1044 cursor: "pointer" 1045 } 1046 } 1047}, jvm.Map.apiEvents = { 1048 onRegionTipShow: "regionTipShow", 1049 onRegionOver: "regionOver", 1050 onRegionOut: "regionOut", 1051 onRegionClick: "regionClick", 1052 onRegionSelected: "regionSelected", 1053 onMarkerTipShow: "markerTipShow", 1054 onMarkerOver: "markerOver", 1055 onMarkerOut: "markerOut", 1056 onMarkerClick: "markerClick", 1057 onMarkerSelected: "markerSelected", 1058 onViewportChange: "viewportChange" 1059}, jvm.MultiMap = function(params) { 1060 var that = this; 1061 this.maps = {}, this.params = jvm.$.extend(!0, {}, 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({ 1062 position: "relative" 1063 }), this.backButton = jvm.$("<div/>").addClass("jvectormap-goback").text("Back").appendTo(this.params.container), this.backButton.hide(), this.backButton.click(function() { 1064 that.goBack() 1065 }), this.spinner = jvm.$("<div/>").addClass("jvectormap-spinner").appendTo(this.params.container), this.spinner.hide() 1066}, jvm.MultiMap.prototype = { 1067 addMap: function(name, config) { 1068 var cnt = jvm.$("<div/>").css({ 1069 width: "100%", 1070 height: "100%" 1071 }); 1072 return this.params.container.append(cnt), this.maps[name] = new jvm.Map(jvm.$.extend(config, { 1073 container: cnt 1074 })), this.params.maxLevel > config.multiMapLevel && this.maps[name].container.on("regionClick.jvectormap", { 1075 scope: this 1076 }
vendor: 2,525 bytes, lines 1076-1135
1076, function(e, code) { 1077 var multimap = e.data.scope, 1078 mapName = multimap.params.mapNameByCode(code, multimap); 1079 multimap.drillDownPromise && "pending" === multimap.drillDownPromise.state() || multimap.drillDown(mapName, code) 1080 }), this.maps[name] 1081 }, 1082 downloadMap: function(code) { 1083 var that = this, 1084 deferred = jvm.$.Deferred(); 1085 return this.mapsLoaded[code] ? deferred.resolve() : jvm.$.get(this.params.mapUrlByCode(code, this)).then(function() { 1086 that.mapsLoaded[code] = !0, deferred.resolve() 1087 }, function() { 1088 deferred.reject() 1089 }), deferred 1090 }, 1091 drillDown: function(name, code) { 1092 var currentMap = this.history[this.history.length - 1], 1093 that = this, 1094 focusPromise = currentMap.setFocus({ 1095 region: code, 1096 animate: !0 1097 }), 1098 downloadPromise = this.downloadMap(code); 1099 focusPromise.then(function() { 1100 "pending" === downloadPromise.state() && that.spinner.show() 1101 }), downloadPromise.always(function() { 1102 that.spinner.hide() 1103 }), this.drillDownPromise = jvm.$.when(downloadPromise, focusPromise), this.drillDownPromise.then(function() { 1104 currentMap.params.container.hide(), that.maps[name] ? that.maps[name].params.container.show() : that.addMap(name, { 1105 map: name, 1106 multiMapLevel: currentMap.params.multiMapLevel + 1 1107 }), that.history.push(that.maps[name]), that.backButton.show() 1108 }) 1109 }, 1110 goBack: function() { 1111 var currentMap = this.history.pop(), 1112 prevMap = this.history[this.history.length - 1], 1113 that = this; 1114 currentMap.setFocus({ 1115 scale: 1, 1116 x: .5, 1117 y: .5, 1118 animate: !0 1119 }).then(function() { 1120 currentMap.params.container.hide(), prevMap.params.container.show(), prevMap.updateSize(), 1 === that.history.length && that.backButton.hide(), prevMap.setFocus({ 1121 scale: 1, 1122 x: .5, 1123 y: .5, 1124 animate: !0 1125 }) 1126 }) 1127 } 1128}, jvm.MultiMap.defaultParams = { 1129 mapNameByCode: function(code, multiMap) { 1130 return code.toLowerCase() + "_" + multiMap.defaultProjection + "_en" 1131 }, 1132 mapUrlByCode: function(code, multiMap) { 1133 return "jquery-jvectormap-data-" + code.toLowerCase() + "-" + multiMap.defaultProjection + "-en.js" 1134 } 1135};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.