You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

8 lines
47 KiB
JavaScript

3 years ago
/**
* jVectorMap version 2.0.4
*
* Copyright 2011-2014, Kirill Lebedev
*
*/
!function(t){var e={set:{colors:1,values:1,backgroundColor:1,scaleColors:1,normalizeFunction:1,focus:1},get:{selectedRegions:1,selectedMarkers:1,mapObject:1,regionName:1}};t.fn.vectorMap=function(t){var a,s,a=this.children(".jvectormap-container").data("mapObject");if("addMap"===t)jvm.Map.maps[arguments[1]]=arguments[2];else{if(("set"===t||"get"===t)&&e[t][arguments[1]])return s=arguments[1].charAt(0).toUpperCase()+arguments[1].substr(1),a[t+s].apply(a,Array.prototype.slice.call(arguments,2));t=t||{},t.container=this,a=new jvm.Map(t)}return this}}(jQuery),function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof exports?module.exports=t:t(jQuery)}(function(t){function e(e){var r=e||window.event,o=h.call(arguments,1),l=0,m=0,c=0,p=0;if(e=t.event.fix(r),e.type="mousewheel","detail"in r&&(c=-1*r.detail),"wheelDelta"in r&&(c=r.wheelDelta),"wheelDeltaY"in r&&(c=r.wheelDeltaY),"wheelDeltaX"in r&&(m=-1*r.wheelDeltaX),"axis"in r&&r.axis===r.HORIZONTAL_AXIS&&(m=-1*c,c=0),l=0===c?m:c,"deltaY"in r&&(c=-1*r.deltaY,l=c),"deltaX"in r&&(m=r.deltaX,0===c&&(l=-1*m)),0!==c||0!==m){if(1===r.deltaMode){var d=t.data(this,"mousewheel-line-height");l*=d,c*=d,m*=d}else if(2===r.deltaMode){var u=t.data(this,"mousewheel-page-height");l*=u,c*=u,m*=u}return p=Math.max(Math.abs(c),Math.abs(m)),(!n||n>p)&&(n=p,s(r,p)&&(n/=40)),s(r,p)&&(l/=40,m/=40,c/=40),l=Math[l>=1?"floor":"ceil"](l/n),m=Math[m>=1?"floor":"ceil"](m/n),c=Math[c>=1?"floor":"ceil"](c/n),e.deltaX=m,e.deltaY=c,e.deltaFactor=n,e.deltaMode=0,o.unshift(e,l,m,c),i&&clearTimeout(i),i=setTimeout(a,200),(t.event.dispatch||t.event.handle).apply(this,o)}}function a(){n=null}function s(t,e){return m.settings.adjustOldDeltas&&"mousewheel"===t.type&&e%120===0}var i,n,r=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],o="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],h=Array.prototype.slice;if(t.event.fixHooks)for(var l=r.length;l;)t.event.fixHooks[r[--l]]=t.event.mouseHooks;var m=t.event.special.mousewheel={version:"3.1.9",setup:function(){if(this.addEventListener)for(var a=o.length;a;)this.addEventListener(o[--a],e,!1);else this.onmousewheel=e;t.data(this,"mousewheel-line-height",m.getLineHeight(this)),t.data(this,"mousewheel-page-height",m.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var t=o.length;t;)this.removeEventListener(o[--t],e,!1);else this.onmousewheel=null},getLineHeight:function(e){return parseInt(t(e)["offsetParent"in t.fn?"offsetParent":"parent"]().css("fontSize"),10)},getPageHeight:function(e){return t(e).height()},settings:{adjustOldDeltas:!0}};t.fn.extend({mousewheel:function(t){return t?this.bind("mousewheel",t):this.trigger("mousewheel")},unmousewheel:function(t){return this.unbind("mousewheel",t)}})});var jvm={inherits:function(t,e){function a(){}a.prototype=e.prototype,t.prototype=new a,t.prototype.constructor=t,t.parentClass=e},mixin:function(t,e){var a;for(a in e.prototype)e.prototype.hasOwnProperty(a)&&(t.prototype[a]=e.prototype[a])},min:function(t){var e,a=Number.MAX_VALUE;if(t instanceof Array)for(e=0;e<t.length;e++)t[e]<a&&(a=t[e]);else for(e in t)t[e]<a&&(a=t[e]);return a},max:function(t){var e,a=Number.MIN_VALUE;if(t instanceof Array)for(e=0;e<t.length;e++)t[e]>a&&(a=t[e]);else for(e in t)t[e]>a&&(a=t[e]);return a},keys:function(t){var e,a=[];for(e in t)a.push(e);return a},values:function(t){var e,a,s=[];for(a=0;a<arguments.length;a++){t=arguments[a];for(e in t)s.push(t[e])}return s},whenImageLoaded:function(t){var e=new jvm.$.Deferred,a=jvm.$("<img/>");return a.error(function(){e.reject()}).load(function(){e.resolve(a)}),a.attr("src",t),e},isImageUrl:function(t){return/\.\w{3,4}$/.test(t)}};jvm.$=jQuery,Array.prototype.indexOf||(Array.prototype.indexOf=function(t,e){var a;if(null==this)throw new TypeError('"this" is null or not defined');var s=Object(this),i=s.length>>>0;if(0===i)return-1;var n=+e||0;if(1/0===Math.abs(n)&&(n=0),n>=i)return-1;for(a=Math.max(n>=0?n:i-Math.abs(n),0);i>a;){if(a in s&&s[a]===t)return a;a++}return-1}),jvm.A
},applyTransform:function(){var t,e,a,s;this.defaultWidth*this.scale<=this.width?(t=(this.width-this.defaultWidth*this.scale)/(2*this.scale),a=(this.width-this.defaultWidth*this.scale)/(2*this.scale)):(t=0,a=(this.width-this.defaultWidth*this.scale)/this.scale),this.defaultHeight*this.scale<=this.height?(e=(this.height-this.defaultHeight*this.scale)/(2*this.scale),s=(this.height-this.defaultHeight*this.scale)/(2*this.scale)):(e=0,s=(this.height-this.defaultHeight*this.scale)/this.scale),this.transY>e?this.transY=e:this.transY<s&&(this.transY=s),this.transX>t?this.transX=t:this.transX<a&&(this.transX=a),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])},bindContainerEvents:function(){var t,e,a=!1,s=this;this.params.panOnDrag&&(this.container.mousemove(function(i){return a&&(s.transX-=(t-i.pageX)/s.scale,s.transY-=(e-i.pageY)/s.scale,s.applyTransform(),t=i.pageX,e=i.pageY),!1}).mousedown(function(s){return a=!0,t=s.pageX,e=s.pageY,!1}),this.onContainerMouseUp=function(){a=!1},jvm.$("body").mouseup(this.onContainerMouseUp)),this.params.zoomOnScroll&&this.container.mousewheel(function(t){var e=jvm.$(s.container).offset(),a=t.pageX-e.left,i=t.pageY-e.top,n=Math.pow(1+s.params.zoomOnScrollSpeed/1e3,t.deltaFactor*t.deltaY);s.tip.hide(),s.setScale(s.scale*n,a,i),t.preventDefault()})},bindContainerTouchEvents:function(){var t,e,a,s,i,n,r,o=this,h=function(h){var l,m,c,p,d=h.originalEvent.touches;"touchstart"==h.type&&(r=0),1==d.length?(1==r&&(c=o.transX,p=o.transY,o.transX-=(a-d[0].pageX)/o.scale,o.transY-=(s-d[0].pageY)/o.scale,o.applyTransform(),o.tip.hide(),(c!=o.transX||p!=o.transY)&&h.preventDefault()),a=d[0].pageX,s=d[0].pageY):2==d.length&&(2==r?(m=Math.sqrt(Math.pow(d[0].pageX-d[1].pageX,2)+Math.pow(d[0].pageY-d[1].pageY,2))/e,o.setScale(t*m,i,n),o.tip.hide(),h.preventDefault()):(l=jvm.$(o.container).offset(),i=d[0].pageX>d[1].pageX?d[1].pageX+(d[0].pageX-d[1].pageX)/2:d[0].pageX+(d[1].pageX-d[0].pageX)/2,n=d[0].pageY>d[1].pageY?d[1].pageY+(d[0].pageY-d[1].pageY)/2:d[0].pageY+(d[1].pageY-d[0].pageY)/2,i-=l.left,n-=l.top,t=o.scale,e=Math.sqrt(Math.pow(d[0].pageX-d[1].pageX,2)+Math.pow(d[0].pageY-d[1].pageY,2)))),r=d.length};jvm.$(this.container).bind("touchstart",h),jvm.$(this.container).bind("touchmove",h)},bindContainerPointerEvents:function(){var t=this,e=new MSGesture,a=this.container[0],s=function(t){e.addPointer(t.pointerId)},i=function(e){var a,s;(0!=e.translationX||0!=e.translationY)&&(a=t.transX,s=t.transY,t.transX+=e.translationX/t.scale,t.transY+=e.translationY/t.scale,t.applyTransform(),t.tip.hide(),(a!=t.transX||s!=t.transY)&&e.preventDefault()),1!=e.scale&&(t.setScale(t.scale*e.scale,e.offsetX,e.offsetY),t.tip.hide(),e.preventDefault())};e.target=a,a.addEventListener("MSGestureChange",i,!1),a.addEventListener("pointerdown",s,!1)},bindElementEvents:function(){var t,e,a,s=this;this.container.mousemove(function(s){Math.abs(t-s.pageX)+Math.abs(e-s.pageY)>2&&(a=!0)}),this.container.delegate("[class~='jvectormap-element']","mouseover mouseout",function(t){var e=jvm.$(this).attr("class").baseVal||jvm.$(this).attr("class"),a=-1===e.indexOf("jvectormap-region")?"marker":"region",i=jvm.$(this).attr("region"==a?"data-code":"data-index"),n="region"==a?s.regions[i].element:s.markers[i].element,r="region"==a?s.mapData.paths[i].name:s.markers[i].config.name||"",o=jvm.$.Event(a+"TipShow.jvectormap"),h=jvm.$.Event(a+"Over.jvectormap");"mouseover"==t.type?(s.container.trigger(h,[i]),h.isDefaultPrevented()||n.setHovered(!0),s.tip.text(r),s.container.trigger(o,[s.tip,i]),o.isDefaultPrevented()||(s.tip.show(),s.tipWidth=s.tip.width(),s.tipHeight=s.tip.height())):(n.setHovered(!1),s.tip.hide(),s.container.trigger(a+"Out.jvectormap",[i]))}),this.container.delegate("[class~='jvectormap-element']","mousedown",function(s){t=s.pageX,e=s.pageY,a=!1}),this.container.delegate("[class~='jvectormap-element']","mouseup",function(){var t=jvm.$(this).attr("class").baseVa