PageSourceSearch

https://www.argentum.org/wp-content/themes/hello-elementor-child/a…?ver=6.9.6-b-modified-1752221902

js argentum.org collected 2026-09-24 21:40:56 UTC 34,068 bytes, 1,281 lines download raw bytes

1/*!
2 * JQVMap: jQuery Vector Map Library
3 * @author JQVMap <[email protected]>
4 * @version 1.5.0
5 * @link http://jqvmap.com
6 * @license https://github.com/manifestinteractive/jqvmap/blob/master/LICENSE
7 * @builddate 2016/03/15
8 */
9
10var VectorCanvas = function (width, height, params) {
11  this.mode = window.SVGAngle ? 'svg' : 'vml';
12  this.params = params;
13
14  if (this.mode === 'svg') {
15    this.createSvgNode = function (nodeName) {
16      return document.createElementNS(this.svgns, nodeName);
17    };
18  } else {
19    try {
20      if (!document.namespaces.rvml) {
21        document.namespaces.add('rvml', 'urn:schemas-microsoft-com:vml');
22      }
23      this.createVmlNode = function (tagName) {
24        return document.createElement('<rvml:' + tagName + ' class="rvml">');
25      };
26    } catch (e) {
27      this.createVmlNode = function (tagName) {
28        return document.createElement('<' + tagName + ' xmlns="urn:schemas-microsoft.com:vml" class="rvml">');
29      };
30    }
31
32    document.createStyleSheet().addRule('.rvml', 'behavior:url(#default#VML)');
33  }
34
35  if (this.mode === 'svg') {
36    this.canvas = this.createSvgNode('svg');
37  } else {
38    this.canvas = this.createVmlNode('group');
39    this.canvas.style.position = 'absolute';
40  }
41
42  this.setSize(width, height);
43};
44
45VectorCanvas.prototype = {
46  svgns: 'http://www.w3.org/2000/svg',
47  mode: 'svg',
48  width: 0,
49  height: 0,
50  canvas: null
51};
52
53var ColorScale = function (colors, normalizeFunction, minValue, maxValue) {
54  if (colors) {
55    this.setColors(colors);
56  }
57  if (normalizeFunction) {
58    this.setNormalizeFunction(normalizeFunction);
59  }
60  if (minValue) {
61    this.setMin(minValue);
62  }
63  if (minValue) {
64    this.setMax(maxValue);
65  }
66};
67
68ColorScale.prototype = {
69  colors: []
70};
71
72var JQVMap = function (params) {
73  params = params || {};
74  var map = this;
75  var mapData = JQVMap.maps[params.map];
76  var mapPins;
77
78  if( !mapData){
79    throw new Error('Invalid "' + params.map + '" map parameter. Please make sure you have loaded this map file in your HTML.');
80  }
81
82  this.selectedRegions = [];
83  this.multiSelectRegion = params.multiSelectRegion;
84
85  this.container = params.container;
86
87  this.defaultWidth = mapData.width;
88  this.defaultHeight = mapData.height;
89
90  this.color = params.color;
91  this.selectedColor = params.selectedColor;
92  this.hoverColor = params.hoverColor;
93  this.hoverColors = params.hoverColors;
94  this.hoverOpacity = params.hoverOpacity;
95  this.setBackgroundColor(params.backgroundColor);
96
97  this.width = params.container.width();
98  this.height = params.container.height();
99
100  this.resize();
101
102  jQuery(window).resize(function () {
103    var newWidth = params.container.width();
104    var newHeight = params.container.height();
105
106    if(newWidth && newHeight){
107      map.width = newWidth;
108      map.height = newHeight;
109      map.resize();
110      map.canvas.setSize(map.width, map.height);
111      map.applyTransform();
112
113      var resizeEvent = jQuery.Event('resize.jqvmap');
114      jQuery(params.container).trigger(resizeEvent, [newWidth, newHeight]);
115
116      if(mapPins){
117        jQuery('.jqvmap-pin').remove();
118        map.pinHandlers = false;
119        map.placePins(mapPins.pins, mapPins.mode);
120      }
121    }
122  });
123
124  this.canvas = new VectorCanvas(this.width, this.height, params);
125  params.container.append(this.canvas.canvas);
126
127  this.makeDraggable();
128
129  this.rootGroup = this.canvas.createGroup(true);
130
131  this.index = JQVMap.mapIndex;
132  this.label = jQuery('<div/>').addClass('jqvmap-label').appendTo(jQuery('body')).hide();
133
134  if (params.enableZoom) {
135    jQuery('<div/>').addClass('jqvmap-zoomin').text('+').appendTo(params.container);
136    jQuery('<div/>').addClass('jqvmap-zoomout').html('&#x2212;').appendTo(params.container);
137  }
138
139  map.countries = [];
140
141  for (var key in mapData.paths) {
142    var path = this.canvas.createPath({
143      path: mapData.paths[key].path
144    });
145
146    path.setFill(this.color);
147    path.id = map.getCountryId(key);
148    map.countries[key] = path;
149
150    if (this.canvas.mode === 'svg') {
151      path.setAttribute('class', 'jqvmap-region');
152    } else {
153      jQuery(path).addClass('jqvmap-region');
154    }
155
156    jQuery(this.rootGroup).append(path);
157  }
158
159  jQuery(params.container).delegate(this.canvas.mode === 'svg' ? 'path' : 'shape', 'mouseover mouseout', function (e) {
160    var containerPath = e.target,
161      code = e.target.id.split('_').pop(),
162      labelShowEvent = jQuery.Event('labelShow.jqvmap'),
163      regionMouseOverEvent = jQuery.Event('regionMouseOver.jqvmap');
164
165    code = code.toLowerCase();
166
167    if (e.type === 'mouseover') {
168      jQuery(params.container).trigger(regionMouseOverEvent, [code, mapData.paths[code].name]);
169      if (!regionMouseOverEvent.isDefaultPrevented()) {
170        map.highlight(code, containerPath);
171      }
172      if (params.showTooltip) {
173        map.label.text(mapData.paths[code].name);
174        jQuery(params.container).trigger(labelShowEvent, [map.label, code]);
175
176        if (!labelShowEvent.isDefaultPrevented()) {
177          map.label.show();
178          map.labelWidth = map.label.width();
179          map.labelHeight = map.label.height();
180        }
181      }
182    } else {
183      map.unhighlight(code, containerPath);
184
185      map.label.hide();
186      jQuery(params.container).trigger('regionMouseOut.jqvmap', [code, mapData.paths[code].name]);
187    }
188  });
189
190  jQuery(params.container).delegate(this.canvas.mode === 'svg' ? 'path' : 'shape', 'click', function (regionClickEvent) {
191
192    var targetPath = regionClickEvent.target;
193    var code = regionClickEvent.target.id.split('_').pop();
194    var mapClickEvent = jQuery.Event('regionClick.jqvmap');
195
196    code = code.toLowerCase();
197
198    jQuery(params.container).trigger(mapClickEvent, [code, mapData.paths[code].name]);
199
200    if ( !params.multiSelectRegion && !mapClickEvent.isDefaultPrevented()) {
201      for (var keyPath in mapData.paths) {
202        map.countries[keyPath].currentFillColor = map.countries[keyPath].getOriginalFill
202();
203        map.countries[keyPath].setFill(map.countries[keyPath].getOriginalFill());
204      }
205    }
206
207    if ( !mapClickEvent.isDefaultPrevented()) {
208      if (map.isSelected(code)) {
209        map.deselect(code, targetPath);
210      } else {
211        map.select(code, targetPath);
212      }
213    }
214  });
215
216  if (params.showTooltip) {
217    params.container.mousemove(function (e) {
218      if (map.label.is(':visible')) {
219        var left = e.pageX - 15 - map.labelWidth;
220        var top = e.pageY - 15 - map.labelHeight;
221
222        if(left < 0) {
223          left = e.pageX + 15;
224        }
225        if(top < 0) {
226          top = e.pageY + 15;
227        }
228
229        map.label.css({
230          left: left,
231          top: top
232        });
233      }
234    });
235  }
236
237  this.setColors(params.colors);
238
239  this.canvas.canvas.appendChild(this.rootGroup);
240
241  this.applyTransform();
242
243  this.colorScale = new ColorScale(params.scaleColors, params.normalizeFunction, params.valueMin, params.valueMax);
244
245  if (params.values) {
246    this.values = params.values;
247    this.setValues(params.values);
248  }
249
250  if (params.selectedRegions) {
251    if (params.selectedRegions instanceof Array) {
252      for(var k in params.selectedRegions) {
253        this.select(params.selectedRegions[k].toLowerCase());
254      }
255    } else {
256      this.select(params.selectedRegions.toLowerCase());
257    }
258  }
259
260  this.bindZoomButtons();
261
262  if(params.pins) {
263    mapPins = {
264      pins: params.pins,
265      mode: params.pinMode
266    };
267
268    this.pinHandlers = false;
269    this.placePins(params.pins, params.pinMode);
270  }
271
272  if(params.showLabels){
273    this.pinHandlers = false;
274
275    var pins = {};
276    for (key in map.countries){
277      if (typeof map.countries[key] !== 'function') {
278        if( !params.pins || !params.pins[key] ){
279          pins[key] = key.toUpperCase();
280        }
281      }
282    }
283
284    mapPins = {
285      pins: pins,
286      mode: 'content'
287    };
288
289    this.placePins(pins, 'content');
290  }
291
292  JQVMap.mapIndex++;
293};
294
295JQVMap.prototype = {
296  transX: 0,
297  transY: 0,
298  scale: 1,
299  baseTransX: 0,
300  baseTransY: 0,
301  baseScale: 1,
302  width: 0,
303  height: 0,
304  countries: {},
305  countriesColors: {},
306  countriesData: {},
307  zoomStep: 1.4,
308  zoomMaxStep: 4,
309  zoomCurStep: 1
310};
311
312JQVMap.xlink = 'http://www.w3.org/1999/xlink';
313JQVMap.mapIndex = 1;
314JQVMap.maps = {};
315
316(function(){
317
318  var apiParams = {
319    colors: 1,
320    values: 1,
321    backgroundColor: 1,
322    scaleColors: 1,
323    normalizeFunction: 1,
324    enableZoom: 1,
325    showTooltip: 1,
326    borderColor: 1,
327    borderWidth: 1,
328    borderOpacity: 1,
329    selectedRegions: 1,
330    multiSelectRegion: 1
331  };
332
333  var apiEvents = {
334    onLabelShow: 'labelShow',
335    onLoad: 'load',
336    onRegionOver: 'regionMouseOver',
337    onRegionOut: 'regionMouseOut',
338    onRegionClick: 'regionClick',
339    onRegionSelect: 'regionSelect',
340    onRegionDeselect: 'regionDeselect',
341    onResize: 'resize'
342  };
343
344  jQuery.fn.vectorMap = function (options) {
345
346    var defaultParams = {
347      map: 'world_en',
348      backgroundColor: '#a5bfdd',
349      color: '#f4f3f0',
350      hoverColor: '#c9dfaf',
351      hoverColors: {},
352      selectedColor: '#c9dfaf',
353      scaleColors: ['#b6d6ff', '#005ace'],
354      normalizeFunction: 'linear',
355      enableZoom: true,
356      showTooltip: true,
357      borderColor: '#818181',
358      borderWidth: 1,
359      borderOpacity: 0.25,
360      selectedRegions: null,
361      multiSelectRegion: false
362    }, map = this.data('mapObject');
363
364    if (options === 'addMap') {
365      JQVMap.maps[arguments[1]] = arguments[2];
366    } else if (options === 'set' && apiParams[arguments[1]]) {
367      map['set' + arguments[1].charAt(0).toUpperCase() + arguments[1].substr(1)].apply(map, Array.prototype.slice.call(arguments, 2));
368    } else if (typeof options === 'string' &&
369      typeof map[options] === 'function') {
370      return map[options].apply(map, Array.prototype.slice.call(arguments, 1));
371    } else {
372      jQuery.extend(defaultParams, options);
373      defaultParams.container = this;
374      this.css({ position: 'relative', overflow: 'hidden' });
375
376      map = new JQVMap(defaultParams);
377
378      this.data('mapObject', map);
379
380      this.unbind('.jqvmap');
381
382      for (var e in apiEvents) {
383        if (defaultParams[e]) {
384          this.bind(apiEvents[e] + '.jqvmap', defaultParams[e]);
385        }
386      }
387
388      var loadEvent = jQuery.Event('load.jqvmap');
389      jQuery(defaultParams.container).trigger(loadEvent, map);
390
391      return map;
392    }
393  };
394
395})(jQuery);
396
397ColorScale.arrayToRgb = function (ar) {
398  var rgb = '#';
399  var d;
400  for (var i = 0; i < ar.length; i++) {
401    d = ar[i].toString(16);
402    rgb += d.length === 1 ? '0' + d : d;
403  }
404  return rgb;
405};
406
407ColorScale.prototype.getColor = function (value) {
408  if (typeof this.normalize === 'function') {
409    value = this.normalize(value);
410  }
411
412  var lengthes = [];
413  var fullLength = 0;
414  var l;
415
416  for (var i = 0; i < this.colors.length - 1; i++) {
417    l = this.vectorLength(this.vectorSubtract(this.colors[i + 1], this.colors[i]));
418    lengthes.push(l);
419    fullLength += l;
420  }
421
422  var c = (this.maxValue - this.minValue) / fullLength;
423
424  for (i = 0; i < lengthes.length; i++) {
425    lengthes[i] *= c;
426  }
427
428  i = 0;
429  value -= this.minValue;
430
431  while (value - lengthes[i] >= 0) {
432    value -= lengthes[i];
433    i++;
434  }
435
436  var color;
437  if (i === this.colors.length - 1) {
438    color = this.vectorToNum(this.colors[i]).toString(16);
439  } else {
440    color = (this.vectorToNum(this.vectorAdd(this.colors[i], this.vectorMult(this.vectorSubtract(this.colors[i + 1], this.colors[i]), (value) / (lengthes[i]))))).toString(16);
441  }
442
443  while (color.length < 6) {
444    color = '0' + color;
445  }
446  return '#' + color;
447};
448
449ColorScale.rgbToArray = function (rgb) {
450  rgb = rgb.substr(1);
451  return [parseInt(rgb.substr(0, 2), 16), parseInt(rgb.substr(2, 2), 16), parseInt(rgb.substr(4, 2), 16)];
452};
453
454ColorScale.prototype.setColors = function (colors) {
455  for (var i = 0; i < colors.length; i++) {
456    colors[i] = ColorScale.rgbToArray(colors[i]);
457  }
458  this.colors = colors;
459};
460
461ColorScale.prototype.setMax = function (max) {
462  this.clearMaxValue = max;
463  if (typeof this.normalize === 'function') {
464    this.maxValue = this.normalize(max);
465  } else {
466    this.maxValue = max;
467  }
468};
469
470ColorScale.prototype.setMin = function (min) {
471  this.clearMinValue = min;
472
473  if (typeof this.normalize === 'function') {
474    this.minValue = this.normalize(min);
475  } else {
476    this.minValue = min;
477  }
478};
479
480ColorScale.prototype.setNormalizeFunction = function (f) {
481  if (f === 'polynomial') {
482    this.normalize = function (value) {
483      return Math.pow(value, 0.2);
484    };
485  } else if (f === 'linear') {
486    delete this.normalize;
487  } else {
488    this.normalize = f;
489  }
490  this.setMin(this.clearMinValue);
491  this.setMax(this.clearMaxValue);
492};
493
494ColorScale.prototype.vectorAdd = function (vector1, vector2) {
495  var vector = [];
496  for (var i = 0; i < vector1.length; i++) {
497    vector[i] = vector1[i] + vector2[i];
498  }
499  return vector;
500};
501
502ColorScale.prototype.vectorLength = function (vector) {
503  var result = 0;
504  for (var i = 0; i < vector.length; i++) {
505    result += vector[i] * vector[i];
506  }
507  return Math.sqrt(result);
508};
509
510ColorScale.prototype.vectorMult = function (vector, num) {
511  var result = [];
512  for (var i = 0; i < vector.length; i++) {
513    result[i] = vector[i] * num;
514  }
515  return result;
516};
517
518ColorScale.prototype.vectorSubtract = function (vector1, vector2) {
519  var vector = [];
520  for (var i = 0; i < vector1.length; i++) {
521    vector[i] = vector1[i] - vector2[i];
522  }
523  return vector;
524};
525
526ColorScale.prototype.vectorToNum = function (vector) {
527  var num = 0;
528  for (var i = 0; i < vector.length; i++) {
529    num += Math.round(vector[i]) * Math.pow(256, vector.length - i - 1);
530  }
531  return num;
532};
533
534JQVMap.prototype.applyTransform = function () {
535  var maxTransX, maxTransY, minTransX, minTransY;
536  if (this.defaultWidth * this.scale <= this.width) {
537    maxTransX = (this.width - this.defaultWidth * this.scale) / (2 * this.scale);
538    minTransX = (this.width - this.defaultWidth * this.scale) / (2 * this.scale);
539  } else {
540    maxTransX = 0;
541    minTransX = (this.width - this.defaultWidth * this.scale) / this.scale;
542  }
543
544  if (this.defaultHeight * this.scale <= this.height) {
545    maxTransY = (this.height - this.defaultHeight * this.scale) / (2 * this.scale);
546    minTransY = (this.height - this.defaultHeight * this.scale) / (2 * this.scale);
547  } else {
548    maxTransY = 0;
549    minTransY = (this.height - this.defaultHeight * this.scale) / this.scale;
550  }
551
552  if (this.transY > maxTransY) {
553    this.transY = maxTransY;
554  } else if (this.transY < minTransY) {
555    this.transY = minTransY;
556  }
557  if (this.transX > maxTransX) {
558    this.transX = maxTransX;
559  } else if (this.transX < minTransX) {
560    this.transX = minTransX;
561  }
562
563  this.canvas.applyTransformParams(this.scale, this.transX, this.transY);
564};
565
566JQVMap.prototype.bindZoomButtons = function () {
567  var map = this;
568  this.container.find('.jqvmap-zoomin').click(function(){
569    map.zoomIn();
570  });
571  this.container.find('.jqvmap-zoomout').click(function(){
572    map.zoomOut();
573  });
574};
575
576JQVMap.prototype.deselect = function (cc, path) {
577  cc = cc.toLowerCase();
578  path = path || jQuery('#' + this.getCountryId(cc))[0];
579
580  if (this.isSelected(cc)) {
581    this.selectedRegions.splice(this.selectIndex(cc), 1);
582
583    jQuery(this.container).trigger('regionDeselect.jqvmap', [cc]);
584    path.currentFillColor = path.getOriginalFill();
585    path.setFill(path.getOriginalFill());
586  } else {
587    for (var key in this.countries) {
588      this.selectedRegions.splice(this.selectedRegions.indexOf(key), 1);
589      this.countries[key].currentFillColor = this.color;
590      this.countries[key].setFill(this.color);
591    }
592  }
593};
594
595JQVMap.prototype.getCountryId = function (cc) {
596  return 'jqvmap' + this.index + '_' + cc;
597};
598
599JQVMap.prototype.getPin = function(cc){
600  var pinObj = jQuery('#' + this.getPinId(cc));
601  return pinObj.html();
602};
603
604JQVMap.prototype.getPinId = function (cc) {
605  return this.getCountryId(cc) + '_pin';
606};
607
608JQVMap.prototype.getPins = function(){
609  var pins = this.container.find('.jqvmap-pin');
610  var ret = {};
611  jQuery.each(pins, function(index, pinObj){
612    pinObj = jQuery(pinObj);
613    var cc = pinObj.attr('for').toLowerCase();
614    var pinContent = pinObj.html();
615    ret[cc] = pinContent;
616  });
617  return JSON.stringify(ret);
618};
619
620JQVMap.prototype.highlight = function (cc, path) {
621  path = path || jQuery('#' + this.getCountryId(cc))[0];
622  if (this.hoverOpacity) {
623    path.setOpacity(this.hoverOpacity);
624  } else if (this.hoverColors && (cc in this.hoverColors)) {
625    path.currentFillColor = path.getFill() + '';
626    path.setFill(this.hoverColors[cc]);
627  } else if (this.hoverColor) {
628    path.currentFillColor = path.getFill() + '';
629    path.setFill(this.hoverColor);
630  }
631};
632
633JQVMap.prototype.isSelected = function(cc) {
634  return this.selectIndex(cc) >= 0;
635};
636
637JQVMap.prototype.makeDraggable = function () {
638  var mouseDown = false;
639  var oldPageX, oldPageY;
640  var self = this;
641
642  self.isMoving = false;
643  self.isMovingTimeout = false;
644
645  var lastTouchCount;
646  var touchCenterX;
647  var touchCenterY;
648  var touchStartDistance;
649  var touchStartScale;
650  var touchX;
651  var touchY;
652
653  this.container.mousemove(function (e) {
654
655    if (mouseDown) {
656      self.transX -= (oldPageX - e.pageX) / self.scale;
657      self.transY -= (oldPageY - e.pageY) / self.scale;
658
659      self.applyTransform();
660
661      oldPageX = e.pageX;
662      oldPageY = e.pageY;
663
664      self.isMoving = true;
665      if (self.isMovingTimeout) {
666        clearTimeout(self.isMovingTimeout);
667      }
668
669      self.container.trigger('drag');
670    }
671
672    return false;
673
674  }).mousedown(function (e) {
675
676    mouseDown = true;
677    oldPageX = e.pageX;
678    oldPageY = e.pageY;
679
680    return false;
681
682  }).mouseup(function () {
683
684    mouseDown = false;
685
686    clearTimeout(self.isMovingTimeout);
687    self.isMovingTimeout = setTimeout(function () {
688      self.isMoving = false;
689    }, 100);
690
691    return false;
692
693  }).mouseout(function () {
694
695    if(mouseDown && self.isMoving){
696
697      clearTimeout(self.isMovingTimeout);
698      self.isMovingTimeout = setTimeout(function () {
699        mouseDown = false;
700        self.isMoving = false;
701      }, 100);
702
703      return false;
704    }
705  });
706
707  jQuery(this.container).bind('touchmove', function (e) {
708
709    var offset;
710    var scale;
711    var touches = e.originalEvent.touches;
712    var transformXOld;
713    var transformYOld;
714
715    if (touches.length === 1) {
716      if (lastTouchCount === 1) {
717
718        if(touchX === touches[0].pageX && touchY === touches[0].pageY){
719          return;
720        }
721
722        transformXOld = self.transX;
723        transformYOld = self.transY;
724
725        self.transX -= (touchX - touches[0].pageX) / self.scale;
726        self.transY -= (touchY - touches[0].pageY) / self.scale;
727
728        self.applyTransform();
729
730        if (transformXOld !== self.transX || transformYOld !== self.transY) {
731          e.preventDefault();
732        }
733
734        self.isMoving = true;
735        if (self.isMovingTimeout) {
736          clearTimeout(self.isMovingTimeout);
737        }
738      }
739
740      touchX = touches[0].pageX;
741      touchY = touches[0].pageY;
742
743    } else if (touches.length === 2) {
744
745      if (lastTouchCount === 2) {
746        scale = Math.sqrt(
747            Math.pow(touches[0].pageX - touches[1].pageX, 2) +
748            Math.pow(touches[0].pageY - touches[1].pageY, 2)
749          ) / touchStartDistance;
750
751        self.setScale(
752          touchStartScale * scale,
753          touchCenterX,
754          touchCenterY
755        );
756
757        e.preventDefault();
758
759      } else {
760
761        offset = jQuery(self.container).offset();
762        if (touches[0].pageX > touches[1].pageX) {
763          touchCenterX = touches[1].pageX + (touches[0].pageX - touches[1].pageX) / 2;
764        } else {
765          touchCenterX = touches[0].pageX + (touches[1].pageX - touches[0].pageX) / 2;
766        }
767
768        if (touches[0].pageY > touches[1].pageY) {
769          touchCenterY = touches[1].pageY + (touches[0].pageY - touches[1].pageY) / 2;
770        } else {
771          touchCenterY = touches[0].pageY + (touches[1].pageY - touches[0].pageY) / 2;
772        }
773
774        touchCenterX -= offset.left;
775        touchCenterY -= offset.top;
776        touchStartScale = self.scale;
777
778        touchStartDistance = Math.sqrt(
779          Math.pow(touches[0].pageX - touches[1].pageX, 2) +
780          Math.pow(touches[0].pageY - touches[1].pageY, 2)
781        );
782      }
783    }
784
785    lastTouchCount = touches.length;
786  });
787
788  jQuery(this.container).bind('touchstart', function () {
789    lastTouchCount = 0;
790  });
791
792  jQuery(this.container).bind('touchend', function () {
793    lastTouchCount = 0;
794  });
795};
796
797JQVMap.prototype.placePins = function(pins, pinMode){
798  var map = this;
799
800  if(!pinMode || (pinMode !== 'content' && pinMode !== 'id')) {
801    pinMode = 'content';
802  }
803
804  if(pinMode === 'content') {//treat pin as content
805    jQuery.each(pins, function(index, pin){
806      if(jQuery('#' + map.getCountryId(index)).length === 0){
807        return;
808      }
809
810      var pinIndex = map.getPinId(index);
811      var $pin = jQuery('#' + pinIndex);
812      if($pin.length > 0){
813        $pin.remove();
814      }
815      map.container.append('<div id="' + pinIndex + '" for="' + index + '" class="jqvmap-pin" style="position:absolute">' + pin + '</div>');
816    });
817  } else { //treat pin as id of an html content
818    jQuery.each(pins, function(index, pin){
819      if(jQuery('#' + map.getCountryId(index)).length === 0){
820        return;
821      }
822      var pinIndex = map.getPinId(index);
823      var $pin = jQuery('#' + pinIndex);
824      if($pin.length > 0){
825        $pin.remove();
826      }
827      map.container.append('<div id="' + pinIndex + '" for="' + index + '" class="jqvmap-pin" style="position:absolute"></div>');
828      $pin.append(jQuery('#' + pin));
829    });
830  }
831
832  this.positionPins();
833  if(!this.pinHandlers){
834    this.pinHandlers = true;
835    var positionFix = function(){
836      map.positionPins();
837    };
838    this.container.bind('zoomIn', positionFix)
839      .bind('zoomOut', positionFix)
840      .bind('drag', positionFix);
841  }
842};
843
844JQVMap.prototype.positionPins = function(){
845  var map = this;
846  var pins = this.container.find('.jqvmap-pin');
847  jQuery.each(pins, function(index, pinObj){
848    pinObj = jQuery(pinObj);
849    var countryId = map.getCountryId(pinObj.attr('for').toLowerCase());
850    var countryObj = jQuery('#' + countryId);
851
852    var bbox = document.getElementById(countryId).getBBox();
853    var position = countryObj.position();
854
855    var scale = map.scale;
856
857    var left = position.left + (bbox.width / 2) * scale - pinObj.width() / 2,
858      top = position.top + (bbox.height / 2) * scale - pinObj.height() / 2;
859
860    pinObj.css('left', left).css('top', top);
861  });
862};
863
864JQVMap.prototype.removePin = function(cc) {
865  cc = cc.toLowerCase();
866  jQuery('#' + this.getPinId(cc)).remove();
867};
868
869JQVMap.prototype.removePins = function(){
870  this.container.find('.jqvmap-pin').remove();
871};
872
873JQVMap.prototype.reset = function () {
874  for (var key in this.countries) {
875    this.countries[key].setFill(this.color);
876  }
877  this.scale = this.baseScale;
878  this.transX = this.baseTransX;
879  this.transY = this.baseTransY;
880  this.applyTransform();
881};
882
883JQVMap.prototype.resize = function () {
884  var curBaseScale = this.baseScale;
885  if (this.width / this.height > this.defaultWidth / this.defaultHeight) {
886    this.baseScale = this.height / this.defaultHeight;
887    this.baseTransX = Math.abs(this.width - this.defaultWidth * this.baseScale) / (2 * this.baseScale);
888  } else {
889    this.baseScale = this.width / this.defaultWidth;
890    this.baseTransY = Math.abs(this.height - this.defaultHeight * this.baseScale) / (2 * this.baseScale);
891  }
892  this.scale *= this.baseScale / curBaseScale;
893  this.transX *= this.baseScale / curBaseScale;
894  this.transY *= this.baseScale / curBaseScale;
895};
896
897JQVMap.prototype.select = function (cc, path) {
898  cc = cc.toLowerCase();
899  path = path || jQuery('#' + this.getCountryId(cc))[0];
900
901  if (!this.isSelected(cc)) {
902    if (this.multiSelectRegion) {
903      this.selectedRegions.push(cc);
904    } else {
905      this.selectedRegions = [cc];
906    }
907
908    jQuery(this.container).trigger('regionSelect.jqvmap', [cc]);
909    if (this.selectedColor && path) {
910      path.currentFillColor = this.selectedColor;
911      path.setFill(this.selectedColor);
912    }
913  }
914};
915
916JQVMap.prototype.selectIndex = function (cc) {
917  cc = cc.toLowerCase();
918  for (var i = 0; i < this.selectedRegions.length; i++) {
919    if (cc === this.selectedRegions[i]) {
920      return i;
921    }
922  }
923  return -1;
924};
925
926JQVMap.prototype.setBackgroundColor = function (backgroundColor) {
927  this.container.css('background-color', backgroundColor);
928};
929
930JQVMap.prototype.setColors = function (key, color) {
931  if (typeof key === 'string') {
932    this.countries[key].setFill(color);
933    this.countries[key].setAttribute('original', color);
934  } else {
935    var colors = key;
936
937    for (var code in colors) {
938      if (this.countries[code]) {
939        this.countries[code].setFill(colors[code]);
940        this.countries[code].setAttribute('original', colors[code]);
941      }
942    }
943  }
944};
945
946JQVMap.prototype.setNormalizeFunction = function (f) {
947  this.colorScale.setNormalizeFunction(f);
948
949  if (this.values) {
950    this.setValues(this.values);
951  }
952};
953
954JQVMap.prototype.setScale = function (scale) {
955  this.scale = scale;
956  this.applyTransform();
957};
958
959JQVMap.prototype.setScaleColors = function (colors) {
960  this.colorScale.setColors(colors);
961
962  if (this.values) {
963    this.setValues(this.values);
964  }
965};
966
967JQVMap.prototype.setValues = function (values) {
968  var max = 0,
969    min = Number.MAX_VALUE,
970    val;
971
972  for (var cc in values) {
973    cc = cc.toLowerCase();
974    val = parseFloat(values[cc]);
975
976    if (isNaN(val)) {
977      continue;
978    }
979    if (val > max) {
980      max = values[cc];
981    }
982    if (val < min) {
983      min = val;
984    }
985  }
986
987  if (min === max) {
988    max++;
989  }
990
991  this.colorScale.setMin(min);
992  this.colorScale.setMax(max);
993
994  var colors = {};
995  for (cc in values) {
996    cc = cc.toLowerCase();
997    val = parseFloat(values[cc]);
998    colors[cc] = isNaN(val) ? this.color : this.colorScale.getColor(val);
999  }
1000  this.setColors(colors);
1001  this.values = values;
1002};
1003
1004JQVMap.prototype.unhighlight = function (cc, path) {
1005  cc = cc.toLowerCase();
1006  path = path || jQuery('#' + this.getCountryId(cc))[0];
1007  path.setOpacity(1);
1008  if (path.currentFillColor) {
1009    path.setFill(path.currentFillColor);
1010  }
1011};
1012
1013JQVMap.prototype.zoomIn = function () {
1014  var map = this;
1015  var sliderDelta = (jQuery('#zoom').innerHeight() - 6 * 2 - 15 * 2 - 3 * 2 - 7 - 6) / (this.zoomMaxStep - this.zoomCurStep);
1016
1017  if (map.zoomCurStep < map.zoomMaxStep) {
1018    map.transX -= (map.width / map.scale - map.width / (map.scale * map.zoomStep)) / 2;
1019    map.transY -= (map.height / map.scale - map.height / (map.scale * map.zoomStep)) / 2;
1020    map.setScale(map.scale * map.zoomStep);
1021    map.zoomCurStep++;
1022
1023    var $slider = jQuery('#zoomSlider');
1024
1025    $slider.css('top', parseInt($slider.css('top'), 10) - sliderDelta);
1026
1027    map.container.trigger('zoomIn');
1028  }
1029};
1030
1031JQVMap.prototype.zoomOut = function () {
1032  var map = this;
1033  var sliderDelta = (jQuery('#zoom').innerHeight() - 6 * 2 - 15 * 2 - 3 * 2 - 7 - 6) / (this.zoomMaxStep - this.zoomCurStep);
1034
1035  if (map.zoomCurStep > 1) {
1036    map.transX += (map.width / (map.scale / map.zoomStep) - map.width / map.scale) / 2;
1037    map.transY += (map.height / (map.scale / map.zoomStep) - map.height / map.scale) / 2;
1038    map.setScale(map.scale / map.zoomStep);
1039    map.zoomCurStep--;
1040
1041    var $slider = jQuery('#zoomSlider');
1042
1043    $slider.css('top', parseInt($slider.css('top'), 10) + sliderDelta);
1044
1045    map.container.trigger('zoomOut');
1046  }
1047};
1048
1049VectorCanvas.prototype.applyTransformParams = function (scale, transX, transY) {
1050  if (this.mode === 'svg') {
1051    this.rootGroup.setAttribute('transform', 'scale(' + scale + ') translate(' + transX + ', ' + transY + ')');
1052  } else {
1053    this.rootGroup.coordorigin = (this.width - transX) + ',' + (this.height - transY);
1054    this.rootGroup.coordsize = this.width / scale + ',' + this.height / scale;
1055  }
1056};
1057
1058VectorCanvas.prototype.createGroup = function (isRoot) {
1059  var node;
1060  if (this.mode === 'svg') {
1061    node = this.createSvgNode('g');
1062  } else {
1063    node = this.createVmlNode('group');
1064    node.style.width = this.width + 'px';
1065    node.style.height = this.height + 'px';
1066    node.style.left = '0px';
1067    node.style.top = '0px';
1068    node.coordorigin = '0 0';
1069    node.coordsize = this.width + ' ' + this.height;
1070  }
1071
1072  if (isRoot) {
1073    this.rootGroup = node;
1074  }
1075  return node;
1076};
1077
1078VectorCanvas.prototype.createPath = function (config) {
1079  var node;
1080  if (this.mode === 'svg') {
1081    node = this.createSvgNode('path');
1082    node.setAttribute('d', config.path);
1083
1084    if (this.params.borderColor !== null) {
1085      node.setAttribute('stroke', this.params.borderColor);
1086    }
1087    if (this.params.borderWidth > 0) {
1088      node.setAttribute('stroke-width', this.params.borderWidth);
1089      node.setAttribute('stroke-linecap', 'round');
1090      node.setAttribute('stroke-linejoin', 'round');
1091    }
1092    if (this.params.borderOpacity > 0) {
1093      node.setAttribute('stroke-opacity', this.params.borderOpacity);
1094    }
1095
1096    node.setFill = function (color) {
1097      this.setAttribute('fill', color);
1098      if (this.getAttribute('original') === null) {
1099        this.setAttribute('original', color);
1100      }
1101    };
1102
1103    node.getFill = function () {
1104      return this.getAttribute('fill');
1105    };
1106
1107    node.getOriginalFill = function () {
1108      return this.getAttribute('original');
1109    };
1110
1111    node.setOpacity = function (opacity) {
1112      this.setAttribute('fill-opacity', opacity);
1113    };
1114  } else {
1115    node = this.createVmlNode('shape');
1116    node.coordorigin = '0 0';
1117    node.coordsize = this.width + ' ' + this.height;
1118    node.style.width = this.width + 'px';
1119    node.style.height = this.height + 'px';
1120    node.fillcolor = JQVMap.defaultFillColor;
1121    node.stroked = false;
1122    node.path = VectorCanvas.pathSvgToVml(config.path);
1123
1124    var scale = this.createVmlNode('skew');
1125    scale.on = true;
1126    scale.matrix = '0.01,0,0,0.01,0,0';
1127    scale.offset = '0,0';
1128
1129    node.appendChild(scale);
1130
1131    var fill = this.createVmlNode('fill');
1132    node.appendChild(fill);
1133
1134    node.setFill = function (color) {
1135      this.getElementsByTagName('fill')[0].color = color;
1136      if (this.getAttribute('original') === null) {
1137        this.setAttribute('original', color);
1138      }
1139    };
1140
1141    node.getFill = function () {
1142      return this.getElementsByTagName('fill')[0].color;
1143    };
1144    node.getOriginalFill = function () {
1145      return this.getAttribute('original');
1146    };
1147    node.setOpacity = function (opacity) {
1148      this.getElementsByTagName('fill')[0].opacity = parseInt(opacity * 100, 10) + '%';
1149    };
1150  }
1151  return node;
1152};
1153
1154VectorCanvas.prototype.pathSvgToVml = function (path) {
1155  var result = '';
1156  var cx = 0, cy = 0, ctrlx, ctrly;
1157
1158  return path.replace(/([MmLlHhVvCcSs])((?:-?(?:\d+)?(?:\.\d+)?,?\s?)+)/g, function (segment, letter, coords) {
1159    coords = coords.replace(/(\d)-/g, '$1,-').replace(/\s+/g, ',').split(',');
1160    if (!coords[0]) {
1161      coords.shift();
1162    }
1163
1164    for (var i = 0, l = coords.length; i < l; i++) {
1165      coords[i] = Math.round(100 * coords[i]);
1166    }
1167
1168    switch (letter) {
1169      case 'm':
1170        cx += coords[0];
1171        cy += coords[1];
1172        result = 't' + coords.join(',');
1173        break;
1174
1175      case 'M':
1176        cx = coords[0];
1177        cy = coords[1];
1178        result = 'm' + coords.join(',');
1179        break;
1180
1181      case 'l':
1182        cx += coords[0];
1183        cy += coords[1];
1184        result = 'r' + coords.join(',');
1185        break;
1186
1187      case 'L':
1188        cx = coords[0];
1189        cy = coords[1];
1190        result = 'l' + coords.join(',');
1191        break;
1192
1193      case 'h':
1194        cx += coords[0];
1195        result = 'r' + coords[0] + ',0';
1196        break;
1197
1198      case 'H':
1199        cx = coords[0];
1200        result = 'l' + cx + ',' + cy;
1201        break;
1202
1203      case 'v':
1204        cy += coords[0];
1205        result = 'r0,' + coords[0];
1206        break;
1207
1208      case 'V':
1209        cy = coords[0];
1210        result = 'l' + cx + ',' + cy;
1211        break;
1212
1213      case 'c':
1214        ctrlx = cx + coords[coords.length - 4];
1215        ctrly = cy + coords[coords.length - 3];
1216        cx += coords[coords.length - 2];
1217        cy += coords[coords.length - 1];
1218        result = 'v' + coords.join(',');
1219        break;
1220
1221      case 'C':
1222        ctrlx = coords[coords.length - 4];
1223        ctrly = coords[coords.length - 3];
1224        cx = coords[coords.length - 2];
1225        cy = coords[coords.length - 1];
1226        result = 'c' + coords.join(',');
1227        break;
1228
1229      case 's':
1230        coords.unshift(cy - ctrly);
1231        coords.unshift(cx - ctrlx);
1232        ctrlx = cx + coords[coords.length - 4];
1233        ctrly = cy + coords[coords.length - 3];
1234        cx += coords[coords.length - 2];
1235        cy += coords[coords.length - 1];
1236        result = 'v' + coords.join(',');
1237        break;
1238
1239      case 'S':
1240        coords.unshift(cy + cy - ctrly);
1241        coords.unshift(cx + cx - ctrlx);
1242        ctrlx = coords[coords.length - 4];
1243        ctrly = coords[coords.length - 3];
1244        cx = coords[coords.length - 2];
1245        cy = coords[coords.length - 1];
1246        result = 'c' + coords.join(',');
1247        break;
1248
1249      default:
1250        break;
1251    }
1252
1253    return result;
1254
1255  }).replace(/z/g, '');
1256};
1257
1258VectorCanvas.prototype.setSize = function (width, height) {
1259  if (this.mode === 'svg') {
1260    this.canvas.setAttribute('width', width);
1261    this.canvas.setAttribute('height', height);
1262  } else {
1263    this.canvas.style.width = width + 'px';
1264    this.canvas.style.height = height + 'px';
1265    this.canvas.coordsize = width + ' ' + height;
1266    this.canvas.coordorigin = '0 0';
1267    if (this.rootGroup) {
1268      var paths = this.rootGroup.getElementsByTagName('shape');
1269      for (var i = 0, l = paths.length; i < l; i++) {
1270        paths[i].coordsize = width + ' ' + height;
1271        paths[i].style.width = width + 'px';
1272        paths[i].style.height = height + 'px';
1273      }
1274      this.rootGroup.coordsize = width + ' ' + height;
1275      this.rootGroup.style.width = width + 'px';
1276      this.rootGroup.style.height = height + 'px';
1277    }
1278  }
1279  this.width = width;
1280  this.height = height;
1281};

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.