jvectormap-rails4 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +3 -0
  3. data/History.txt +3 -0
  4. data/README.md +60 -0
  5. data/Rakefile +38 -0
  6. data/jvectormap-rails4.gemspec +20 -0
  7. data/lib/jvectormap/rails4/engine.rb +8 -0
  8. data/lib/jvectormap/rails4/railtie.rb +17 -0
  9. data/lib/jvectormap/rails4/version.rb +8 -0
  10. data/lib/jvectormap/rails4.rb +7 -0
  11. data/lib/jvectormap-rails4.rb +26 -0
  12. data/tasks/jvectormap.rake +6 -0
  13. data/vendor/assets/javascripts/jvectormap/jquery-jvectormap.js +45 -0
  14. data/vendor/assets/javascripts/jvectormap/jquery-mousewheel.js +84 -0
  15. data/vendor/assets/javascripts/jvectormap/lib/abstract-canvas-element.js +67 -0
  16. data/vendor/assets/javascripts/jvectormap/lib/abstract-element.js +73 -0
  17. data/vendor/assets/javascripts/jvectormap/lib/abstract-shape-element.js +85 -0
  18. data/vendor/assets/javascripts/jvectormap/lib/color-scale.js +44 -0
  19. data/vendor/assets/javascripts/jvectormap/lib/data-series.js +139 -0
  20. data/vendor/assets/javascripts/jvectormap/lib/jvectormap.js +99 -0
  21. data/vendor/assets/javascripts/jvectormap/lib/numeric-scale.js +147 -0
  22. data/vendor/assets/javascripts/jvectormap/lib/ordinal-scale.js +7 -0
  23. data/vendor/assets/javascripts/jvectormap/lib/proj.js +181 -0
  24. data/vendor/assets/javascripts/jvectormap/lib/simple-scale.js +7 -0
  25. data/vendor/assets/javascripts/jvectormap/lib/svg-canvas-element.js +22 -0
  26. data/vendor/assets/javascripts/jvectormap/lib/svg-circle-element.js +5 -0
  27. data/vendor/assets/javascripts/jvectormap/lib/svg-element.js +48 -0
  28. data/vendor/assets/javascripts/jvectormap/lib/svg-group-element.js +9 -0
  29. data/vendor/assets/javascripts/jvectormap/lib/svg-path-element.js +6 -0
  30. data/vendor/assets/javascripts/jvectormap/lib/svg-shape-element.js +7 -0
  31. data/vendor/assets/javascripts/jvectormap/lib/vector-canvas.js +16 -0
  32. data/vendor/assets/javascripts/jvectormap/lib/vml-canvas-element.js +45 -0
  33. data/vendor/assets/javascripts/jvectormap/lib/vml-circle-element.js +26 -0
  34. data/vendor/assets/javascripts/jvectormap/lib/vml-element.js +106 -0
  35. data/vendor/assets/javascripts/jvectormap/lib/vml-group-element.js +13 -0
  36. data/vendor/assets/javascripts/jvectormap/lib/vml-path-element.js +111 -0
  37. data/vendor/assets/javascripts/jvectormap/lib/vml-shape-element.js +49 -0
  38. data/vendor/assets/javascripts/jvectormap/lib/world-map.js +977 -0
  39. data/vendor/assets/javascripts/jvectormap/maps/ar_merc_en.js +1 -0
  40. data/vendor/assets/javascripts/jvectormap/maps/ar_mill_en.js +1 -0
  41. data/vendor/assets/javascripts/jvectormap/maps/at_merc_en.js +1 -0
  42. data/vendor/assets/javascripts/jvectormap/maps/at_mill_en.js +1 -0
  43. data/vendor/assets/javascripts/jvectormap/maps/au_merc_en.js +1 -0
  44. data/vendor/assets/javascripts/jvectormap/maps/au_mill_en.js +1 -0
  45. data/vendor/assets/javascripts/jvectormap/maps/be_merc_en.js +1 -0
  46. data/vendor/assets/javascripts/jvectormap/maps/be_mill_en.js +1 -0
  47. data/vendor/assets/javascripts/jvectormap/maps/ca_lcc_en.js +1 -0
  48. data/vendor/assets/javascripts/jvectormap/maps/ca_merc_en.js +1 -0
  49. data/vendor/assets/javascripts/jvectormap/maps/ca_mill_en.js +1 -0
  50. data/vendor/assets/javascripts/jvectormap/maps/ch_merc_en.js +1 -0
  51. data/vendor/assets/javascripts/jvectormap/maps/ch_mill_en.js +1 -0
  52. data/vendor/assets/javascripts/jvectormap/maps/cn_merc_en.js +1 -0
  53. data/vendor/assets/javascripts/jvectormap/maps/cn_mill_en.js +1 -0
  54. data/vendor/assets/javascripts/jvectormap/maps/co_merc_en.js +1 -0
  55. data/vendor/assets/javascripts/jvectormap/maps/co_mill_en.js +1 -0
  56. data/vendor/assets/javascripts/jvectormap/maps/de_merc_en.js +1 -0
  57. data/vendor/assets/javascripts/jvectormap/maps/de_mill_en.js +1 -0
  58. data/vendor/assets/javascripts/jvectormap/maps/dk_merc_en.js +1 -0
  59. data/vendor/assets/javascripts/jvectormap/maps/dk_mill_en.js +1 -0
  60. data/vendor/assets/javascripts/jvectormap/maps/es_merc_en.js +1 -0
  61. data/vendor/assets/javascripts/jvectormap/maps/es_mill_en.js +1 -0
  62. data/vendor/assets/javascripts/jvectormap/maps/europe_merc_en.js +1 -0
  63. data/vendor/assets/javascripts/jvectormap/maps/europe_mill_en.js +1 -0
  64. data/vendor/assets/javascripts/jvectormap/maps/fr_merc_en.js +1 -0
  65. data/vendor/assets/javascripts/jvectormap/maps/fr_mill_en.js +1 -0
  66. data/vendor/assets/javascripts/jvectormap/maps/in_merc_en.js +1 -0
  67. data/vendor/assets/javascripts/jvectormap/maps/in_mill_en.js +1 -0
  68. data/vendor/assets/javascripts/jvectormap/maps/it_merc_en.js +1 -0
  69. data/vendor/assets/javascripts/jvectormap/maps/it_mill_en.js +1 -0
  70. data/vendor/assets/javascripts/jvectormap/maps/nl_merc_en.js +1 -0
  71. data/vendor/assets/javascripts/jvectormap/maps/nl_mill_en.js +1 -0
  72. data/vendor/assets/javascripts/jvectormap/maps/no_merc_en.js +1 -0
  73. data/vendor/assets/javascripts/jvectormap/maps/no_mill_en.js +1 -0
  74. data/vendor/assets/javascripts/jvectormap/maps/nz_merc_en.js +1 -0
  75. data/vendor/assets/javascripts/jvectormap/maps/nz_mill_en.js +1 -0
  76. data/vendor/assets/javascripts/jvectormap/maps/ph_regions_merc_en.js +1 -0
  77. data/vendor/assets/javascripts/jvectormap/maps/ph_regions_mill_en.js +1 -0
  78. data/vendor/assets/javascripts/jvectormap/maps/pl_merc_en.js +1 -0
  79. data/vendor/assets/javascripts/jvectormap/maps/pl_mill_en.js +1 -0
  80. data/vendor/assets/javascripts/jvectormap/maps/pt_merc_en.js +1 -0
  81. data/vendor/assets/javascripts/jvectormap/maps/pt_mill_en.js +1 -0
  82. data/vendor/assets/javascripts/jvectormap/maps/se_merc_en.js +1 -0
  83. data/vendor/assets/javascripts/jvectormap/maps/se_mill_en.js +1 -0
  84. data/vendor/assets/javascripts/jvectormap/maps/th_merc_en.js +1 -0
  85. data/vendor/assets/javascripts/jvectormap/maps/th_mill_en.js +1 -0
  86. data/vendor/assets/javascripts/jvectormap/maps/th_regions_merc_en.js +1 -0
  87. data/vendor/assets/javascripts/jvectormap/maps/th_regions_mill_en.js +1 -0
  88. data/vendor/assets/javascripts/jvectormap/maps/uk_merc_en.js +1 -0
  89. data/vendor/assets/javascripts/jvectormap/maps/uk_mill_en.js +1 -0
  90. data/vendor/assets/javascripts/jvectormap/maps/us-il-chicago_mill_en.js +1 -0
  91. data/vendor/assets/javascripts/jvectormap/maps/us-ny-newyork_mill_en.js +1 -0
  92. data/vendor/assets/javascripts/jvectormap/maps/us_aea_en.js +1 -0
  93. data/vendor/assets/javascripts/jvectormap/maps/us_lcc_en.js +1 -0
  94. data/vendor/assets/javascripts/jvectormap/maps/us_merc_en.js +1 -0
  95. data/vendor/assets/javascripts/jvectormap/maps/us_mill_en.js +1 -0
  96. data/vendor/assets/javascripts/jvectormap/maps/ve_merc_en.js +1 -0
  97. data/vendor/assets/javascripts/jvectormap/maps/ve_mill_en.js +1 -0
  98. data/vendor/assets/javascripts/jvectormap/maps/world_merc_en.js +1 -0
  99. data/vendor/assets/javascripts/jvectormap/maps/world_mill_en.js +1 -0
  100. data/vendor/assets/javascripts/jvectormap/maps/za_merc_en.js +1 -0
  101. data/vendor/assets/javascripts/jvectormap/maps/za_mill_en.js +1 -0
  102. data/vendor/assets/javascripts/jvectormap.js +26 -0
  103. data/vendor/assets/stylesheets/jvectormap.css +37 -0
  104. metadata +159 -0
@@ -0,0 +1,977 @@
1
+ /**
2
+ * Creates map, draws paths, binds events.
3
+ * @constructor
4
+ * @param {Object} params Parameters to initialize map with.
5
+ * @param {String} params.map Name of the map in the format <code>territory_proj_lang</code> where <code>territory</code> is a unique code or name of the territory which the map represents (ISO 3166 alpha 2 standard is used where possible), <code>proj</code> 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 <code>lang</code> is a code of the language, used for the names of regions.
6
+ * @param {String} params.backgroundColor Background color of the map in CSS format.
7
+ * @param {Boolean} params.zoomOnScroll When set to true map could be zoomed using mouse scroll. Default value is <code>true</code>.
8
+ * @param {Number} params.zoomMax Indicates the maximum zoom ratio which could be reached zooming the map. Default value is <code>8</code>.
9
+ * @param {Number} params.zoomMin Indicates the minimum zoom ratio which could be reached zooming the map. Default value is <code>1</code>.
10
+ * @param {Number} params.zoomStep Indicates the multiplier used to zoom map with +/- buttons. Default value is <code>1.6</code>.
11
+ * @param {Boolean} params.regionsSelectable When set to true regions of the map could be selected. Default value is <code>false</code>.
12
+ * @param {Boolean} params.regionsSelectableOne Allow only one region to be selected at the moment. Default value is <code>false</code>.
13
+ * @param {Boolean} params.markersSelectable When set to true markers on the map could be selected. Default value is <code>false</code>.
14
+ * @param {Boolean} params.markersSelectableOne Allow only one marker to be selected at the moment. Default value is <code>false</code>.
15
+ * @param {Object} params.regionStyle Set the styles for the map's regions. Each region or marker has four states: <code>initial</code> (default state), <code>hover</code> (when the mouse cursor is over the region or marker), <code>selected</code> (when region or marker is selected), <code>selectedHover</code> (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:
16
+ <pre>{
17
+ initial: {
18
+ fill: 'white',
19
+ "fill-opacity": 1,
20
+ stroke: 'none',
21
+ "stroke-width": 0,
22
+ "stroke-opacity": 1
23
+ },
24
+ hover: {
25
+ "fill-opacity": 0.8
26
+ },
27
+ selected: {
28
+ fill: 'yellow'
29
+ },
30
+ selectedHover: {
31
+ }
32
+ }</pre>
33
+ * @param {Object} params.markerStyle Set the styles for the map's markers. Any parameter suitable for <code>regionStyle</code> could be used as well as numeric parameter <code>r</code> to set the marker's radius. Default value for that parameter is:
34
+ <pre>{
35
+ initial: {
36
+ fill: 'grey',
37
+ stroke: '#505050',
38
+ "fill-opacity": 1,
39
+ "stroke-width": 1,
40
+ "stroke-opacity": 1,
41
+ r: 5
42
+ },
43
+ hover: {
44
+ stroke: 'black',
45
+ "stroke-width": 2
46
+ },
47
+ selected: {
48
+ fill: 'blue'
49
+ },
50
+ selectedHover: {
51
+ }
52
+ }</pre>
53
+ * @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 <code>latLng</code> (array of two numeric values), <code>name</code> (string which will be show on marker's label) and any marker styles.
54
+ * @param {Object} params.series Object with two keys: <code>markers</code> and <code>regions</code>. Each of which is an array of series configs to be applied to the respective map elements. See <a href="jvm.DataSeries.html">DataSeries</a> description for a list of parameters available.
55
+ * @param {Object|String} params.focusOn This parameter sets the initial position and scale of the map viewport. It could be expressed as a string representing region which should be in focus or an object representing coordinates and scale to set. For example to focus on the center of the map at the double scale you can provide the following value:
56
+ <pre>{
57
+ x: 0.5,
58
+ y: 0.5,
59
+ scale: 2
60
+ }</pre>
61
+ * @param {Array|Object|String} params.selectedRegions Set initially selected regions.
62
+ * @param {Array|Object|String} params.selectedMarkers Set initially selected markers.
63
+ * @param {Function} params.onRegionLabelShow <code>(Event e, Object label, String code)</code> Will be called right before the region label is going to be shown.
64
+ * @param {Function} params.onRegionOver <code>(Event e, String code)</code> Will be called on region mouse over event.
65
+ * @param {Function} params.onRegionOut <code>(Event e, String code)</code> Will be called on region mouse out event.
66
+ * @param {Function} params.onRegionClick <code>(Event e, String code)</code> Will be called on region click event.
67
+ * @param {Function} params.onRegionSelected <code>(Event e, String code, Boolean isSelected, Array selectedRegions)</code> Will be called when region is (de)selected. <code>isSelected</code> parameter of the callback indicates whether region is selected or not. <code>selectedRegions</code> contains codes of all currently selected regions.
68
+ * @param {Function} params.onMarkerLabelShow <code>(Event e, Object label, String code)</code> Will be called right before the marker label is going to be shown.
69
+ * @param {Function} params.onMarkerOver <code>(Event e, String code)</code> Will be called on marker mouse over event.
70
+ * @param {Function} params.onMarkerOut <code>(Event e, String code)</code> Will be called on marker mouse out event.
71
+ * @param {Function} params.onMarkerClick <code>(Event e, String code)</code> Will be called on marker click event.
72
+ * @param {Function} params.onMarkerSelected <code>(Event e, String code, Boolean isSelected, Array selectedMarkers)</code> Will be called when marker is (de)selected. <code>isSelected</code> parameter of the callback indicates whether marker is selected or not. <code>selectedMarkers</code> contains codes of all currently selected markers.
73
+ * @param {Function} params.onViewportChange <code>(Event e, Number scale)</code> Triggered when the map's viewport is changed (map was panned or zoomed).
74
+ */
75
+ jvm.WorldMap = function(params) {
76
+ var map = this,
77
+ e;
78
+
79
+ this.params = jvm.$.extend(true, {}, jvm.WorldMap.defaultParams, params);
80
+
81
+ if (!jvm.WorldMap.maps[this.params.map]) {
82
+ throw new Error('Attempt to use map which was not loaded: '+this.params.map);
83
+ }
84
+
85
+ this.mapData = jvm.WorldMap.maps[this.params.map];
86
+ this.markers = {};
87
+ this.regions = {};
88
+ this.regionsColors = {};
89
+ this.regionsData = {};
90
+
91
+ this.container = jvm.$('<div>').css({width: '100%', height: '100%'}).addClass('jvectormap-container');
92
+ this.params.container.append( this.container );
93
+ this.container.data('mapObject', this);
94
+ this.container.css({
95
+ position: 'relative',
96
+ overflow: 'hidden'
97
+ });
98
+
99
+ this.defaultWidth = this.mapData.width;
100
+ this.defaultHeight = this.mapData.height;
101
+
102
+ this.setBackgroundColor(this.params.backgroundColor);
103
+
104
+ this.onResize = function(){
105
+ map.setSize();
106
+ }
107
+ jvm.$(window).resize(this.onResize);
108
+
109
+ for (e in jvm.WorldMap.apiEvents) {
110
+ if (this.params[e]) {
111
+ this.container.bind(jvm.WorldMap.apiEvents[e]+'.jvectormap', this.params[e]);
112
+ }
113
+ }
114
+
115
+ this.canvas = new jvm.VectorCanvas(this.container[0], this.width, this.height);
116
+
117
+ if ( ('ontouchstart' in window) || (window.DocumentTouch && document instanceof DocumentTouch) ) {
118
+ if (this.params.bindTouchEvents) {
119
+ this.bindContainerTouchEvents();
120
+ }
121
+ } else {
122
+ this.bindContainerEvents();
123
+ }
124
+ this.bindElementEvents();
125
+ this.createLabel();
126
+ if (this.params.zoomButtons) {
127
+ this.bindZoomButtons();
128
+ }
129
+ this.createRegions();
130
+ this.createMarkers(this.params.markers || {});
131
+
132
+ this.setSize();
133
+
134
+ if (this.params.focusOn) {
135
+ if (typeof this.params.focusOn === 'object') {
136
+ this.setFocus.call(this, this.params.focusOn.scale, this.params.focusOn.x, this.params.focusOn.y);
137
+ } else {
138
+ this.setFocus.call(this, this.params.focusOn);
139
+ }
140
+ }
141
+
142
+ if (this.params.selectedRegions) {
143
+ this.setSelectedRegions(this.params.selectedRegions);
144
+ }
145
+ if (this.params.selectedMarkers) {
146
+ this.setSelectedMarkers(this.params.selectedMarkers);
147
+ }
148
+
149
+ if (this.params.series) {
150
+ this.createSeries();
151
+ }
152
+ };
153
+
154
+ jvm.WorldMap.prototype = {
155
+ transX: 0,
156
+ transY: 0,
157
+ scale: 1,
158
+ baseTransX: 0,
159
+ baseTransY: 0,
160
+ baseScale: 1,
161
+
162
+ width: 0,
163
+ height: 0,
164
+
165
+ /**
166
+ * Set background color of the map.
167
+ * @param {String} backgroundColor Background color in CSS format.
168
+ */
169
+ setBackgroundColor: function(backgroundColor) {
170
+ this.container.css('background-color', backgroundColor);
171
+ },
172
+
173
+ resize: function() {
174
+ var curBaseScale = this.baseScale;
175
+ if (this.width / this.height > this.defaultWidth / this.defaultHeight) {
176
+ this.baseScale = this.height / this.defaultHeight;
177
+ this.baseTransX = Math.abs(this.width - this.defaultWidth * this.baseScale) / (2 * this.baseScale);
178
+ } else {
179
+ this.baseScale = this.width / this.defaultWidth;
180
+ this.baseTransY = Math.abs(this.height - this.defaultHeight * this.baseScale) / (2 * this.baseScale);
181
+ }
182
+ this.scale *= this.baseScale / curBaseScale;
183
+ this.transX *= this.baseScale / curBaseScale;
184
+ this.transY *= this.baseScale / curBaseScale;
185
+ },
186
+
187
+ /**
188
+ * Synchronize the size of the map with the size of the container. Suitable in situations where the size of the container is changed programmatically or container is shown after it became visible.
189
+ */
190
+ setSize: function(){
191
+ this.width = this.container.width();
192
+ this.height = this.container.height();
193
+ this.resize();
194
+ this.canvas.setSize(this.width, this.height);
195
+ this.applyTransform();
196
+ },
197
+
198
+ /**
199
+ * Reset all the series and show the map with the initial zoom.
200
+ */
201
+ reset: function() {
202
+ var key,
203
+ i;
204
+
205
+ for (key in this.series) {
206
+ for (i = 0; i < this.series[key].length; i++) {
207
+ this.series[key][i].clear();
208
+ }
209
+ }
210
+ this.scale = this.baseScale;
211
+ this.transX = this.baseTransX;
212
+ this.transY = this.baseTransY;
213
+ this.applyTransform();
214
+ },
215
+
216
+ applyTransform: function() {
217
+ var maxTransX,
218
+ maxTransY,
219
+ minTransX,
220
+ minTransY;
221
+
222
+ if (this.defaultWidth * this.scale <= this.width) {
223
+ maxTransX = (this.width - this.defaultWidth * this.scale) / (2 * this.scale);
224
+ minTransX = (this.width - this.defaultWidth * this.scale) / (2 * this.scale);
225
+ } else {
226
+ maxTransX = 0;
227
+ minTransX = (this.width - this.defaultWidth * this.scale) / this.scale;
228
+ }
229
+
230
+ if (this.defaultHeight * this.scale <= this.height) {
231
+ maxTransY = (this.height - this.defaultHeight * this.scale) / (2 * this.scale);
232
+ minTransY = (this.height - this.defaultHeight * this.scale) / (2 * this.scale);
233
+ } else {
234
+ maxTransY = 0;
235
+ minTransY = (this.height - this.defaultHeight * this.scale) / this.scale;
236
+ }
237
+
238
+ if (this.transY > maxTransY) {
239
+ this.transY = maxTransY;
240
+ } else if (this.transY < minTransY) {
241
+ this.transY = minTransY;
242
+ }
243
+ if (this.transX > maxTransX) {
244
+ this.transX = maxTransX;
245
+ } else if (this.transX < minTransX) {
246
+ this.transX = minTransX;
247
+ }
248
+
249
+ this.canvas.applyTransformParams(this.scale, this.transX, this.transY);
250
+
251
+ if (this.markers) {
252
+ this.repositionMarkers();
253
+ }
254
+
255
+ this.container.trigger('viewportChange', [this.scale/this.baseScale, this.transX, this.transY]);
256
+ },
257
+
258
+ bindContainerEvents: function(){
259
+ var mouseDown = false,
260
+ oldPageX,
261
+ oldPageY,
262
+ map = this;
263
+
264
+ this.container.mousemove(function(e){
265
+ if (mouseDown) {
266
+ map.transX -= (oldPageX - e.pageX) / map.scale;
267
+ map.transY -= (oldPageY - e.pageY) / map.scale;
268
+
269
+ map.applyTransform();
270
+
271
+ oldPageX = e.pageX;
272
+ oldPageY = e.pageY;
273
+ }
274
+ return false;
275
+ }).mousedown(function(e){
276
+ mouseDown = true;
277
+ oldPageX = e.pageX;
278
+ oldPageY = e.pageY;
279
+ return false;
280
+ });
281
+
282
+ jvm.$('body').mouseup(function(){
283
+ mouseDown = false;
284
+ });
285
+
286
+ if (this.params.zoomOnScroll) {
287
+ this.container.mousewheel(function(event, delta, deltaX, deltaY) {
288
+ var offset = jvm.$(map.container).offset(),
289
+ centerX = event.pageX - offset.left,
290
+ centerY = event.pageY - offset.top,
291
+ zoomStep = Math.pow(1.3, deltaY);
292
+
293
+ map.label.hide();
294
+
295
+ map.setScale(map.scale * zoomStep, centerX, centerY);
296
+ event.preventDefault();
297
+ });
298
+ }
299
+ },
300
+
301
+ bindContainerTouchEvents: function(){
302
+ var touchStartScale,
303
+ touchStartDistance,
304
+ map = this,
305
+ touchX,
306
+ touchY,
307
+ centerTouchX,
308
+ centerTouchY,
309
+ lastTouchesLength,
310
+ handleTouchEvent = function(e){
311
+ var touches = e.originalEvent.touches,
312
+ scale;
313
+
314
+ if (e.type == 'touchstart') {
315
+ lastTouchesLength = 0;
316
+ }
317
+
318
+ if (touches.length == 1) {
319
+ if (lastTouchesLength == 1) {
320
+ map.transX -= (touchX - touches[0].pageX) / map.scale;
321
+ map.transY -= (touchY - touches[0].pageY) / map.scale;
322
+ map.applyTransform();
323
+ map.label.hide();
324
+ e.preventDefault();
325
+ }
326
+ touchX = touches[0].pageX;
327
+ touchY = touches[0].pageY;
328
+ } else if (touches.length == 2) {
329
+ if (lastTouchesLength == 2) {
330
+ scale = Math.sqrt(
331
+ Math.pow(touches[0].pageX - touches[1].pageX, 2) +
332
+ Math.pow(touches[0].pageY - touches[1].pageY, 2)
333
+ ) / touchStartDistance;
334
+ map.setScale(
335
+ touchStartScale * scale,
336
+ centerTouchX,
337
+ centerTouchY
338
+ )
339
+ map.label.hide();
340
+ e.preventDefault();
341
+ } else {
342
+ if (touches[0].pageX > touches[1].pageX) {
343
+ centerTouchX = touches[1].pageX + (touches[0].pageX - touches[1].pageX) / 2;
344
+ } else {
345
+ centerTouchX = touches[0].pageX + (touches[1].pageX - touches[0].pageX) / 2;
346
+ }
347
+ if (touches[0].pageY > touches[1].pageY) {
348
+ centerTouchY = touches[1].pageY + (touches[0].pageY - touches[1].pageY) / 2;
349
+ } else {
350
+ centerTouchY = touches[0].pageY + (touches[1].pageY - touches[0].pageY) / 2;
351
+ }
352
+ touchStartScale = map.scale;
353
+ touchStartDistance = Math.sqrt(
354
+ Math.pow(touches[0].pageX - touches[1].pageX, 2) +
355
+ Math.pow(touches[0].pageY - touches[1].pageY, 2)
356
+ );
357
+ }
358
+ }
359
+
360
+ lastTouchesLength = touches.length;
361
+ };
362
+
363
+ jvm.$(this.container).bind('touchstart', handleTouchEvent);
364
+ jvm.$(this.container).bind('touchmove', handleTouchEvent);
365
+ },
366
+
367
+ bindElementEvents: function(){
368
+ var map = this,
369
+ mouseMoved;
370
+
371
+ this.container.mousemove(function(){
372
+ mouseMoved = true;
373
+ });
374
+
375
+ /* Can not use common class selectors here because of the bug in jQuery
376
+ SVG handling, use with caution. */
377
+ this.container.delegate("[class~='jvectormap-element']", 'mouseover mouseout', function(e){
378
+ var path = this,
379
+ baseVal = jvm.$(this).attr('class').baseVal ? jvm.$(this).attr('class').baseVal : jvm.$(this).attr('class'),
380
+ type = baseVal.indexOf('jvectormap-region') === -1 ? 'marker' : 'region',
381
+ code = type == 'region' ? jvm.$(this).attr('data-code') : jvm.$(this).attr('data-index'),
382
+ element = type == 'region' ? map.regions[code].element : map.markers[code].element,
383
+ labelText = type == 'region' ? map.mapData.paths[code].name : (map.markers[code].config.name || ''),
384
+ labelShowEvent = jvm.$.Event(type+'LabelShow.jvectormap'),
385
+ overEvent = jvm.$.Event(type+'Over.jvectormap');
386
+
387
+ if (e.type == 'mouseover') {
388
+ map.container.trigger(overEvent, [code]);
389
+ if (!overEvent.isDefaultPrevented()) {
390
+ element.setHovered(true);
391
+ }
392
+
393
+ map.label.text(labelText);
394
+ map.container.trigger(labelShowEvent, [map.label, code]);
395
+ if (!labelShowEvent.isDefaultPrevented()) {
396
+ map.label.show();
397
+ map.labelWidth = map.label.width();
398
+ map.labelHeight = map.label.height();
399
+ }
400
+ } else {
401
+ element.setHovered(false);
402
+ map.label.hide();
403
+ map.container.trigger(type+'Out.jvectormap', [code]);
404
+ }
405
+ });
406
+
407
+ /* Can not use common class selectors here because of the bug in jQuery
408
+ SVG handling, use with caution. */
409
+ this.container.delegate("[class~='jvectormap-element']", 'mousedown', function(e){
410
+ mouseMoved = false;
411
+ });
412
+
413
+ /* Can not use common class selectors here because of the bug in jQuery
414
+ SVG handling, use with caution. */
415
+ this.container.delegate("[class~='jvectormap-element']", 'mouseup', function(e){
416
+ var path = this,
417
+ baseVal = jvm.$(this).attr('class').baseVal ? jvm.$(this).attr('class').baseVal : jvm.$(this).attr('class'),
418
+ type = baseVal.indexOf('jvectormap-region') === -1 ? 'marker' : 'region',
419
+ code = type == 'region' ? jvm.$(this).attr('data-code') : jvm.$(this).attr('data-index'),
420
+ clickEvent = jvm.$.Event(type+'Click.jvectormap'),
421
+ element = type == 'region' ? map.regions[code].element : map.markers[code].element;
422
+
423
+ if (!mouseMoved) {
424
+ map.container.trigger(clickEvent, [code]);
425
+ if ((type === 'region' && map.params.regionsSelectable) || (type === 'marker' && map.params.markersSelectable)) {
426
+ if (!clickEvent.isDefaultPrevented()) {
427
+ if (map.params[type+'sSelectableOne']) {
428
+ map.clearSelected(type+'s');
429
+ }
430
+ element.setSelected(!element.isSelected);
431
+ }
432
+ }
433
+ }
434
+ });
435
+ },
436
+
437
+ bindZoomButtons: function() {
438
+ var map = this;
439
+
440
+ jvm.$('<div/>').addClass('jvectormap-zoomin').text('+').appendTo(this.container);
441
+ jvm.$('<div/>').addClass('jvectormap-zoomout').html('&#x2212;').appendTo(this.container);
442
+
443
+ this.container.find('.jvectormap-zoomin').click(function(){
444
+ map.setScale(map.scale * map.params.zoomStep, map.width / 2, map.height / 2);
445
+ });
446
+ this.container.find('.jvectormap-zoomout').click(function(){
447
+ map.setScale(map.scale / map.params.zoomStep, map.width / 2, map.height / 2);
448
+ });
449
+ },
450
+
451
+ createLabel: function(){
452
+ var map = this;
453
+
454
+ this.label = jvm.$('<div/>').addClass('jvectormap-label').appendTo(jvm.$('body'));
455
+
456
+ this.container.mousemove(function(e){
457
+ var left = e.pageX-15-map.labelWidth,
458
+ top = e.pageY-15-map.labelHeight;
459
+
460
+ if (left < 5) {
461
+ left = e.pageX + 15;
462
+ }
463
+ if (top < 5) {
464
+ top = e.pageY + 15;
465
+ }
466
+
467
+ if (map.label.is(':visible')) {
468
+ map.label.css({
469
+ left: left,
470
+ top: top
471
+ })
472
+ }
473
+ });
474
+ },
475
+
476
+ setScale: function(scale, anchorX, anchorY, isCentered) {
477
+ var zoomStep,
478
+ viewportChangeEvent = jvm.$.Event('zoom.jvectormap');
479
+
480
+ if (scale > this.params.zoomMax * this.baseScale) {
481
+ scale = this.params.zoomMax * this.baseScale;
482
+ } else if (scale < this.params.zoomMin * this.baseScale) {
483
+ scale = this.params.zoomMin * this.baseScale;
484
+ }
485
+
486
+ if (typeof anchorX != 'undefined' && typeof anchorY != 'undefined') {
487
+ zoomStep = scale / this.scale;
488
+ if (isCentered) {
489
+ this.transX = anchorX + this.defaultWidth * (this.width / (this.defaultWidth * scale)) / 2;
490
+ this.transY = anchorY + this.defaultHeight * (this.height / (this.defaultHeight * scale)) / 2;
491
+ } else {
492
+ this.transX -= (zoomStep - 1) / scale * anchorX;
493
+ this.transY -= (zoomStep - 1) / scale * anchorY;
494
+ }
495
+ }
496
+
497
+ this.scale = scale;
498
+ this.applyTransform();
499
+ this.container.trigger(viewportChangeEvent, [scale/this.baseScale]);
500
+ },
501
+
502
+ /**
503
+ * Set the map's viewport to the specific point and set zoom of the map to the specific level. Point and zoom level could be defined in two ways: using the code of some region to focus on or a central point and zoom level as numbers.
504
+ * @param {Number|String|Array} scale|regionCode|regionCodes If the first parameter of this method is a string or array of strings and there are regions with the these codes, the viewport will be set to show all these regions. Otherwise if the first parameter is a number, the viewport will be set to show the map with provided scale.
505
+ * @param {Number} centerX Number from 0 to 1 specifying the horizontal coordinate of the central point of the viewport.
506
+ * @param {Number} centerY Number from 0 to 1 specifying the vertical coordinate of the central point of the viewport.
507
+ */
508
+ setFocus: function(scale, centerX, centerY){
509
+ var bbox,
510
+ itemBbox,
511
+ newBbox,
512
+ codes,
513
+ i;
514
+
515
+ if (jvm.$.isArray(scale) || this.regions[scale]) {
516
+ if (jvm.$.isArray(scale)) {
517
+ codes = scale;
518
+ } else {
519
+ codes = [scale]
520
+ }
521
+ for (i = 0; i < codes.length; i++) {
522
+ if (this.regions[codes[i]]) {
523
+ itemBbox = this.regions[codes[i]].element.getBBox();
524
+ if (itemBbox) {
525
+ if (typeof bbox == 'undefined') {
526
+ bbox = itemBbox;
527
+ } else {
528
+ newBbox = {
529
+ x: Math.min(bbox.x, itemBbox.x),
530
+ y: Math.min(bbox.y, itemBbox.y),
531
+ width: Math.max(bbox.x + bbox.width, itemBbox.x + itemBbox.width) - Math.min(bbox.x, itemBbox.x),
532
+ height: Math.max(bbox.y + bbox.height, itemBbox.y + itemBbox.height) - Math.min(bbox.y, itemBbox.y)
533
+ }
534
+ bbox = newBbox;
535
+ }
536
+ }
537
+ }
538
+ }
539
+ this.setScale(
540
+ Math.min(this.width / bbox.width, this.height / bbox.height),
541
+ - (bbox.x + bbox.width / 2),
542
+ - (bbox.y + bbox.height / 2),
543
+ true
544
+ );
545
+ } else {
546
+ scale = scale * this.baseScale;
547
+ this.setScale(scale, - centerX * this.defaultWidth, - centerY * this.defaultHeight, true);
548
+ }
549
+ },
550
+
551
+ getSelected: function(type){
552
+ var key,
553
+ selected = [];
554
+
555
+ for (key in this[type]) {
556
+ if (this[type][key].element.isSelected) {
557
+ selected.push(key);
558
+ }
559
+ }
560
+ return selected;
561
+ },
562
+
563
+ /**
564
+ * Return the codes of currently selected regions.
565
+ * @returns {Array}
566
+ */
567
+ getSelectedRegions: function(){
568
+ return this.getSelected('regions');
569
+ },
570
+
571
+ /**
572
+ * Return the codes of currently selected markers.
573
+ * @returns {Array}
574
+ */
575
+ getSelectedMarkers: function(){
576
+ return this.getSelected('markers');
577
+ },
578
+
579
+ setSelected: function(type, keys){
580
+ var i;
581
+
582
+ if (typeof keys != 'object') {
583
+ keys = [keys];
584
+ }
585
+
586
+ if (jvm.$.isArray(keys)) {
587
+ for (i = 0; i < keys.length; i++) {
588
+ this[type][keys[i]].element.setSelected(true);
589
+ }
590
+ } else {
591
+ for (i in keys) {
592
+ this[type][i].element.setSelected(!!keys[i]);
593
+ }
594
+ }
595
+ },
596
+
597
+ /**
598
+ * Set or remove selected state for the regions.
599
+ * @param {String|Array|Object} keys If <code>String</code> or <code>Array</code> the region(s) with the corresponding code(s) will be selected. If <code>Object</code> 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.
600
+ */
601
+ setSelectedRegions: function(keys){
602
+ this.setSelected('regions', keys);
603
+ },
604
+
605
+ /**
606
+ * Set or remove selected state for the markers.
607
+ * @param {String|Array|Object} keys If <code>String</code> or <code>Array</code> the marker(s) with the corresponding code(s) will be selected. If <code>Object</code> 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.
608
+ */
609
+ setSelectedMarkers: function(keys){
610
+ this.setSelected('markers', keys);
611
+ },
612
+
613
+ clearSelected: function(type){
614
+ var select = {},
615
+ selected = this.getSelected(type),
616
+ i;
617
+
618
+ for (i = 0; i < selected.length; i++) {
619
+ select[selected[i]] = false;
620
+ };
621
+
622
+ this.setSelected(type, select);
623
+ },
624
+
625
+ /**
626
+ * Remove the selected state from all the currently selected regions.
627
+ */
628
+ clearSelectedRegions: function(){
629
+ this.clearSelected('regions');
630
+ },
631
+
632
+ /**
633
+ * Remove the selected state from all the currently selected markers.
634
+ */
635
+ clearSelectedMarkers: function(){
636
+ this.clearSelected('markers');
637
+ },
638
+
639
+ /**
640
+ * Return the instance of WorldMap. Useful when instantiated as a jQuery plug-in.
641
+ * @returns {WorldMap}
642
+ */
643
+ getMapObject: function(){
644
+ return this;
645
+ },
646
+
647
+ /**
648
+ * Return the name of the region by region code.
649
+ * @returns {String}
650
+ */
651
+ getRegionName: function(code){
652
+ return this.mapData.paths[code].name;
653
+ },
654
+
655
+ createRegions: function(){
656
+ var key,
657
+ region,
658
+ map = this;
659
+
660
+ for (key in this.mapData.paths) {
661
+ region = this.canvas.addPath({
662
+ d: this.mapData.paths[key].path,
663
+ "data-code": key
664
+ }, jvm.$.extend(true, {}, this.params.regionStyle));
665
+ jvm.$(region.node).bind('selected', function(e, isSelected){
666
+ map.container.trigger('regionSelected.jvectormap', [jvm.$(this).attr('data-code'), isSelected, map.getSelectedRegions()]);
667
+ });
668
+ region.addClass('jvectormap-region jvectormap-element');
669
+ this.regions[key] = {
670
+ element: region,
671
+ config: this.mapData.paths[key]
672
+ };
673
+ }
674
+ },
675
+
676
+ createMarkers: function(markers) {
677
+ var i,
678
+ marker,
679
+ point,
680
+ markerConfig,
681
+ markersArray,
682
+ map = this;
683
+
684
+ this.markersGroup = this.markersGroup || this.canvas.addGroup();
685
+
686
+ if (jvm.$.isArray(markers)) {
687
+ markersArray = markers.slice();
688
+ markers = {};
689
+ for (i = 0; i < markersArray.length; i++) {
690
+ markers[i] = markersArray[i];
691
+ }
692
+ }
693
+
694
+ for (i in markers) {
695
+ markerConfig = markers[i] instanceof Array ? {latLng: markers[i]} : markers[i];
696
+ point = this.getMarkerPosition( markerConfig );
697
+
698
+ if (point !== false) {
699
+ marker = this.canvas.addCircle({
700
+ "data-index": i,
701
+ cx: point.x,
702
+ cy: point.y
703
+ }, jvm.$.extend(true, {}, this.params.markerStyle, {initial: markerConfig.style || {}}), this.markersGroup);
704
+ marker.addClass('jvectormap-marker jvectormap-element');
705
+ jvm.$(marker.node).bind('selected', function(e, isSelected){
706
+ map.container.trigger('markerSelected.jvectormap', [jvm.$(this).attr('data-index'), isSelected, map.getSelectedMarkers()]);
707
+ });
708
+ if (this.markers[i]) {
709
+ this.removeMarkers([i]);
710
+ }
711
+ this.markers[i] = {element: marker, config: markerConfig};
712
+ }
713
+ }
714
+ },
715
+
716
+ repositionMarkers: function() {
717
+ var i,
718
+ point;
719
+
720
+ for (i in this.markers) {
721
+ point = this.getMarkerPosition( this.markers[i].config );
722
+ if (point !== false) {
723
+ this.markers[i].element.setStyle({cx: point.x, cy: point.y});
724
+ }
725
+ }
726
+ },
727
+
728
+ getMarkerPosition: function(markerConfig) {
729
+ if (jvm.WorldMap.maps[this.params.map].projection) {
730
+ return this.latLngToPoint.apply(this, markerConfig.latLng || [0, 0]);
731
+ } else {
732
+ return {
733
+ x: markerConfig.coords[0]*this.scale + this.transX*this.scale,
734
+ y: markerConfig.coords[1]*this.scale + this.transY*this.scale
735
+ };
736
+ }
737
+ },
738
+
739
+ /**
740
+ * Add one marker to the map.
741
+ * @param {String} key Marker unique code.
742
+ * @param {Object} marker Marker configuration parameters.
743
+ * @param {Array} seriesData Values to add to the data series.
744
+ */
745
+ addMarker: function(key, marker, seriesData){
746
+ var markers = {},
747
+ data = [],
748
+ values,
749
+ i,
750
+ seriesData = seriesData || [];
751
+
752
+ markers[key] = marker;
753
+
754
+ for (i = 0; i < seriesData.length; i++) {
755
+ values = {};
756
+ values[key] = seriesData[i];
757
+ data.push(values);
758
+ }
759
+ this.addMarkers(markers, data);
760
+ },
761
+
762
+ /**
763
+ * Add set of marker to the map.
764
+ * @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.
765
+ * @param {Array} seriesData Values to add to the data series.
766
+ */
767
+ addMarkers: function(markers, seriesData){
768
+ var i;
769
+
770
+ seriesData = seriesData || [];
771
+
772
+ this.createMarkers(markers);
773
+ for (i = 0; i < seriesData.length; i++) {
774
+ this.series.markers[i].setValues(seriesData[i] || {});
775
+ };
776
+ },
777
+
778
+ /**
779
+ * Remove some markers from the map.
780
+ * @param {Array} markers Array of marker codes to be removed.
781
+ */
782
+ removeMarkers: function(markers){
783
+ var i;
784
+
785
+ for (i = 0; i < markers.length; i++) {
786
+ this.markers[ markers[i] ].element.remove();
787
+ delete this.markers[ markers[i] ];
788
+ };
789
+ },
790
+
791
+ /**
792
+ * Remove all markers from the map.
793
+ */
794
+ removeAllMarkers: function(){
795
+ var i,
796
+ markers = [];
797
+
798
+ for (i in this.markers) {
799
+ markers.push(i);
800
+ }
801
+ this.removeMarkers(markers)
802
+ },
803
+
804
+ /**
805
+ * Converts coordinates expressed as latitude and longitude to the coordinates in pixels on the map.
806
+ * @param {Number} lat Latitide of point in degrees.
807
+ * @param {Number} lng Longitude of point in degrees.
808
+ */
809
+ latLngToPoint: function(lat, lng) {
810
+ var point,
811
+ proj = jvm.WorldMap.maps[this.params.map].projection,
812
+ centralMeridian = proj.centralMeridian,
813
+ width = this.width - this.baseTransX * 2 * this.baseScale,
814
+ height = this.height - this.baseTransY * 2 * this.baseScale,
815
+ inset,
816
+ bbox,
817
+ scaleFactor = this.scale / this.baseScale;
818
+
819
+ if (lng < (-180 + centralMeridian)) {
820
+ lng += 360;
821
+ }
822
+
823
+ point = jvm.Proj[proj.type](lat, lng, centralMeridian);
824
+
825
+ inset = this.getInsetForPoint(point.x, point.y);
826
+ if (inset) {
827
+ bbox = inset.bbox;
828
+
829
+ point.x = (point.x - bbox[0].x) / (bbox[1].x - bbox[0].x) * inset.width * this.scale;
830
+ point.y = (point.y - bbox[0].y) / (bbox[1].y - bbox[0].y) * inset.height * this.scale;
831
+
832
+ return {
833
+ x: point.x + this.transX*this.scale + inset.left*this.scale,
834
+ y: point.y + this.transY*this.scale + inset.top*this.scale
835
+ };
836
+ } else {
837
+ return false;
838
+ }
839
+ },
840
+
841
+ /**
842
+ * Converts cartesian coordinates into coordinates expressed as latitude and longitude.
843
+ * @param {Number} x X-axis of point on map in pixels.
844
+ * @param {Number} y Y-axis of point on map in pixels.
845
+ */
846
+ pointToLatLng: function(x, y) {
847
+ var proj = jvm.WorldMap.maps[this.params.map].projection,
848
+ centralMeridian = proj.centralMeridian,
849
+ insets = jvm.WorldMap.maps[this.params.map].insets,
850
+ i,
851
+ inset,
852
+ bbox,
853
+ nx,
854
+ ny;
855
+
856
+ for (i = 0; i < insets.length; i++) {
857
+ inset = insets[i];
858
+ bbox = inset.bbox;
859
+
860
+ nx = x - (this.transX*this.scale + inset.left*this.scale);
861
+ ny = y - (this.transY*this.scale + inset.top*this.scale);
862
+
863
+ nx = (nx / (inset.width * this.scale)) * (bbox[1].x - bbox[0].x) + bbox[0].x;
864
+ ny = (ny / (inset.height * this.scale)) * (bbox[1].y - bbox[0].y) + bbox[0].y;
865
+
866
+ if (nx > bbox[0].x && nx < bbox[1].x && ny > bbox[0].y && ny < bbox[1].y) {
867
+ return jvm.Proj[proj.type + '_inv'](nx, -ny, centralMeridian);
868
+ }
869
+ }
870
+
871
+ return false;
872
+ },
873
+
874
+ getInsetForPoint: function(x, y){
875
+ var insets = jvm.WorldMap.maps[this.params.map].insets,
876
+ i,
877
+ bbox;
878
+
879
+ for (i = 0; i < insets.length; i++) {
880
+ bbox = insets[i].bbox;
881
+ if (x > bbox[0].x && x < bbox[1].x && y > bbox[0].y && y < bbox[1].y) {
882
+ return insets[i];
883
+ }
884
+ }
885
+ },
886
+
887
+ createSeries: function(){
888
+ var i,
889
+ key;
890
+
891
+ this.series = {
892
+ markers: [],
893
+ regions: []
894
+ };
895
+
896
+ for (key in this.params.series) {
897
+ for (i = 0; i < this.params.series[key].length; i++) {
898
+ this.series[key][i] = new jvm.DataSeries(
899
+ this.params.series[key][i],
900
+ this[key]
901
+ );
902
+ }
903
+ }
904
+ },
905
+
906
+ /**
907
+ * Gracefully remove the map and and all its accessories, unbind event handlers.
908
+ */
909
+ remove: function(){
910
+ this.label.remove();
911
+ this.container.remove();
912
+ jvm.$(window).unbind('resize', this.onResize);
913
+ }
914
+ };
915
+
916
+ jvm.WorldMap.maps = {};
917
+ jvm.WorldMap.defaultParams = {
918
+ map: 'world_mill_en',
919
+ backgroundColor: '#505050',
920
+ zoomButtons: true,
921
+ zoomOnScroll: true,
922
+ zoomMax: 8,
923
+ zoomMin: 1,
924
+ zoomStep: 1.6,
925
+ regionsSelectable: false,
926
+ markersSelectable: false,
927
+ bindTouchEvents: true,
928
+ regionStyle: {
929
+ initial: {
930
+ fill: 'white',
931
+ "fill-opacity": 1,
932
+ stroke: 'none',
933
+ "stroke-width": 0,
934
+ "stroke-opacity": 1
935
+ },
936
+ hover: {
937
+ "fill-opacity": 0.8
938
+ },
939
+ selected: {
940
+ fill: 'yellow'
941
+ },
942
+ selectedHover: {
943
+ }
944
+ },
945
+ markerStyle: {
946
+ initial: {
947
+ fill: 'grey',
948
+ stroke: '#505050',
949
+ "fill-opacity": 1,
950
+ "stroke-width": 1,
951
+ "stroke-opacity": 1,
952
+ r: 5
953
+ },
954
+ hover: {
955
+ stroke: 'black',
956
+ "stroke-width": 2
957
+ },
958
+ selected: {
959
+ fill: 'blue'
960
+ },
961
+ selectedHover: {
962
+ }
963
+ }
964
+ };
965
+ jvm.WorldMap.apiEvents = {
966
+ onRegionLabelShow: 'regionLabelShow',
967
+ onRegionOver: 'regionOver',
968
+ onRegionOut: 'regionOut',
969
+ onRegionClick: 'regionClick',
970
+ onRegionSelected: 'regionSelected',
971
+ onMarkerLabelShow: 'markerLabelShow',
972
+ onMarkerOver: 'markerOver',
973
+ onMarkerOut: 'markerOut',
974
+ onMarkerClick: 'markerClick',
975
+ onMarkerSelected: 'markerSelected',
976
+ onViewportChange: 'viewportChange'
977
+ };