kisukedeath

Jqvmap prevent default

Feb 5th, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 18.24 KB | None | 0 0
  1. var highlighted_states = {
  2.                ae:'#a8a8a8',af:'#a8a8a8',ag:'#a8a8a8',al:'#a8a8a8',am:'#a8a8a8',ao:'#a8a8a8',at:'#a8a8a8',au:'#a8a8a8',az:'#a8a8a8',bb :'#a8a8a8',bd:'#a8a8a8',bf:'#a8a8a8',bg :'#a8a8a8',bi :'#a8a8a8',bj :'#a8a8a8',bn :'#a8a8a8',bo:'#a8a8a8',bs :'#a8a8a8',bt :'#a8a8a8',bw :'#a8a8a8',by:'#a8a8a8',bz :'#a8a8a8',ca:'#a8a8a8',cd :'#a8a8a8',cf :'#a8a8a8',cg :'#a8a8a8',ch :'#a8a8a8',cn:'#a8a8a8',cr :'#a8a8a8',cu :'#a8a8a8',cv :'#a8a8a8',cy:'#a8a8a8',dj :'#a8a8a8',dk :'#a8a8a8',dm :'#a8a8a8',do :'#a8a8a8',dz :'#a8a8a8',ee:'#a8a8a8',eg :'#a8a8a8',er:'#a8a8a8',et :'#a8a8a8',fi :'#a8a8a8',fj:'#a8a8a8',fk:'#a8a8a8',ga:'#a8a8a8',gd :'#a8a8a8',ge :'#a8a8a8',gf :'#a8a8a8',gh :'#a8a8a8',gl :'#a8a8a8',gm :'#a8a8a8',gn :'#a8a8a8',gq :'#a8a8a8',gr :'#a8a8a8',gt :'#a8a8a8',gw :'#a8a8a8',gy :'#a8a8a8',hn :'#a8a8a8',ht :'#a8a8a8',hu :'#a8a8a8',id :'#a8a8a8',il :'#a8a8a8',in :'#a8a8a8',iq :'#a8a8a8',ir :'#a8a8a8',is:'#a8a8a8',jm :'#a8a8a8',jo:'#a8a8a8',ke :'#a8a8a8',kg :'#a8a8a8',kh :'#a8a8a8',km :'#a8a8a8',kn :'#a8a8a8',kp :'#a8a8a8',kr :'#a8a8a8',kw :'#a8a8a8',kz :'#a8a8a8',la :'#a8a8a8',lb :'#a8a8a8', lk :'#a8a8a8',lr :'#a8a8a8',ls :'#a8a8a8',lt :'#a8a8a8',lv :'#a8a8a8',ly :'#a8a8a8',ma :'#a8a8a8',md :'#a8a8a8',mg :'#a8a8a8',mk :'#a8a8a8',ml :'#a8a8a8',mm :'#a8a8a8',mn:'#a8a8a8',mr :'#a8a8a8',mt :'#a8a8a8',mu :'#a8a8a8',mv :'#a8a8a8',mw :'#a8a8a8',mx :'#a8a8a8',my :'#a8a8a8',mz :'#a8a8a8',na :'#a8a8a8',nc :'#a8a8a8',ne :'#a8a8a8',ng :'#a8a8a8',ni:'#a8a8a8',no :'#a8a8a8',np :'#a8a8a8',nz:'#a8a8a8',om :'#a8a8a8',pa:'#a8a8a8',pe :'#a8a8a8',pf :'#a8a8a8',pg :'#a8a8a8',ph :'#a8a8a8',pk:'#a8a8a8',py:'#a8a8a8',qa:'#a8a8a8',re :'#a8a8a8',ro:'#a8a8a8',rw :'#a8a8a8',sa :'#a8a8a8',sb :'#a8a8a8',sc :'#a8a8a8',sd:'#a8a8a8', sl :'#a8a8a8',sn:'#a8a8a8',so :'#a8a8a8',sr :'#a8a8a8',st :'#a8a8a8',sv :'#a8a8a8',sy :'#a8a8a8',sz :'#a8a8a8',td :'#a8a8a8',tg :'#a8a8a8',th :'#a8a8a8',tj :'#a8a8a8',tl :'#a8a8a8',tm :'#a8a8a8',tn:'#a8a8a8',tt :'#a8a8a8',tw :'#a8a8a8',tz :'#a8a8a8',ua :'#a8a8a8',ug :'#a8a8a8',us:'#a8a8a8',uz :'#a8a8a8',ve :'#a8a8a8',vn :'#a8a8a8',vu :'#a8a8a8',ye:'#a8a8a8',za :'#a8a8a8',zm :'#a8a8a8',zw :'#a8a8a8',ak :'#a8a8a8',al :'#a8a8a8',az:'#a8a8a8',ca :'#a8a8a8',ct :'#a8a8a8',dc:'#a8a8a8',fl :'#a8a8a8',ga :'#a8a8a8',hi :'#a8a8a8',ia:'#a8a8a8',id :'#a8a8a8',il:'#a8a8a8',in :'#a8a8a8',ks :'#a8a8a8',ky :'#a8a8a8',la :'#a8a8a8',ma :'#a8a8a8',md :'#a8a8a8',mi :'#a8a8a8',mn :'#a8a8a8',mo :'#a8a8a8',ms :'#a8a8a8',mt :'#a8a8a8',nc :'#a8a8a8',nd :'#a8a8a8',ne :'#a8a8a8',nh :'#a8a8a8',nj :'#a8a8a8',nm :'#a8a8a8',nv:'#a8a8a8',ny:'#a8a8a8',oh :'#a8a8a8',ok :'#a8a8a8',or :'#a8a8a8',pa :'#a8a8a8',ri :'#a8a8a8',sc:'#a8a8a8',sd :'#a8a8a8',tn :'#a8a8a8',tx :'#a8a8a8',ut :'#a8a8a8',va :'#a8a8a8',vt :'#a8a8a8',wa :'#a8a8a8',wi :'#a8a8a8',wv :'#a8a8a8',wy:'#a8a8a8',ad :'#a8a8a8',al :'#a8a8a8',am :'#a8a8a8',at :'#a8a8a8',az:'#a8a8a8',bg :'#a8a8a8',by :'#a8a8a8',ch :'#a8a8a8',cy:'#a8a8a8',dk :'#a8a8a8',dz :'#a8a8a8',ee:'#a8a8a8',fi:'#a8a8a8',ge :'#a8a8a8',gl :'#a8a8a8',gr :'#a8a8a8',hu :'#a8a8a8',il :'#a8a8a8',iq :'#a8a8a8',ir :'#a8a8a8',is :'#a8a8a8',jo :'#a8a8a8',kz :'#a8a8a8',lb :'#a8a8a8',li :'#a8a8a8',lt :'#a8a8a8',lu :'#a8a8a8',lv :'#a8a8a8',ma :'#a8a8a8',mc :'#a8a8a8',md:'#a8a8a8',mk :'#a8a8a8',mt :'#a8a8a8',no:'#a8a8a8',ro :'#a8a8a8',sa :'#a8a8a8',sm:'#a8a8a8',sr :'#a8a8a8',sy:'#a8a8a8',tm :'#a8a8a8',tn :'#a8a8a8',ua:'#a8a8a8',bb :'#a8a8a8',bw :'#a8a8a8',by :'#a8a8a8',hb :'#a8a8a8',he :'#a8a8a8',hh :'#a8a8a8',mv :'#a8a8a8',ni :'#a8a8a8',nw :'#a8a8a8',rp :'#a8a8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,UA,BB ,BW ,BY ,HB ,HE ,HH ,MV ,NI ,NW ,RP ,SH ,SL ,SN ,ST ,TH ';
  7.  
  8.            
  9.  
  10.                jQuery('#vmap').vectorMap({
  11.                     map: 'world_en',
  12.                     backgroundColor: '#ffffff',
  13.                     color: '#666666',
  14.                     colors: highlighted_states,
  15.                     //hoverOpacity: 0.7,
  16.                     hoverColor: '#1f8b8d',
  17.                     enableZoom: false,
  18.                     selectedColor: '#1f8b8d',
  19.                     showTooltip: true,
  20.                     //values: sample_data,
  21.                     scaleColors: ['#C8EEFF', '#006491'],
  22.                     normalizeFunction: 'polynomial',
  23.                     onLabelShow: function(event, label, code) {
  24.                     if (states.toLowerCase().indexOf(code) <= -1) {
  25.                         event.preventDefault();
  26.                     } else {
  27.                         label[0].innerHTML = "No players from this region";
  28.                     }
  29.                     },
  30.                     onRegionClick: function(event, code, region)
  31.                     {
  32.                         /*fill: #666666;*/
  33.                         /*var message = 'You clicked "'
  34.                             + region;
  35.                         alert(message);*/
  36.                         //alert(states.toLowerCase().indexOf(code));
  37.                         if (states.toLowerCase().indexOf(code) != -1) {
  38.                             $('.jqvmap-region').css('cursor','default');
  39.                             event.preventDefault();
  40.                             $('.jqvmap-region').click(function(){return false;});
  41.                         }
  42.                     },
  43.                     onRegionOver: function(event, code, region)
  44.                     {
  45.                         /*var message = 'You hover "'
  46.                             + region
  47.                             + '" which has the code: '
  48.                             + code.toUpperCase();
  49.                         alert(message);*/
  50.                        if (states.toLowerCase().indexOf(code) != -1) {
  51.                             $('.jqvmap-region').css('cursor','default');
  52.                             $('.jqvmap-region').on('click',function(){return false;});
  53.                             event.preventDefault();
  54.                        }else{
  55.  
  56.                             $('.jqvmap-region').off('click');
  57.                        }
  58.  
  59.                        switch(code){
  60.                             case ('ar'):
  61.                                 $('.argentina').stop( true, true ).fadeIn();
  62.                                 $('#jqvmap1_ar').mouseout(function(e){
  63.                                     e.preventDefault();
  64.                                     $('.argentina').stop( true, true ).fadeOut();
  65.                                 });
  66.                             break;
  67.                             case ('fr'):
  68.                                 $('.france').stop( true, true ).fadeIn();
  69.                                 $('#jqvmap1_fr').mouseout(function(e){
  70.                                     e.preventDefault();
  71.                                     $('.france').stop( true, true ).fadeOut();
  72.                                 });
  73.                             break;
  74.                             case ('es'):
  75.                                 $('.spain').stop( true, true ).fadeIn();
  76.                                 $('#jqvmap1_es').mouseout(function(e){
  77.                                     e.preventDefault();
  78.                                     $('.spain').stop( true, true ).fadeOut();
  79.                                 });
  80.                             break;
  81.                             case ('pt'):
  82.                                 $('.portugal').stop( true, true ).fadeIn();
  83.                                 $('#jqvmap1_pt').mouseout(function(e){
  84.                                     e.preventDefault();
  85.                                     $('.portugal').stop( true, true ).fadeOut();
  86.                                 });
  87.                             break;
  88.                             case ('co'):
  89.                                 $('.columbia').stop( true, true ).fadeIn();
  90.                                 $('#jqvmap1_co').mouseout(function(e){
  91.                                     e.preventDefault();
  92.                                     $('.columbia').stop( true, true ).fadeOut();
  93.                                 });
  94.                             break;
  95.                             case ('de'):
  96.                                 $('.germany').stop( true, true ).fadeIn();
  97.                                 $('#jqvmap1_de').mouseout(function(e){
  98.                                     e.preventDefault();
  99.                                     $('.germany').stop( true, true ).fadeOut();
  100.                                 });
  101.                             break;
  102.                             case ('nl'):
  103.                                 $('.netherlands').stop( true, true ).fadeIn();
  104.                                 $('#jqvmap1_nl').mouseout(function(e){
  105.                                     e.preventDefault();
  106.                                     $('.netherlands').stop( true, true ).fadeOut();
  107.                                 });
  108.                             break;
  109.                             case ('ie'):
  110.                                 $('.wales').stop( true, true ).fadeIn();
  111.                                 $('#jqvmap1_ie').mouseout(function(e){
  112.                                     e.preventDefault();
  113.                                     $('.wales').stop( true, true ).fadeOut();
  114.                                 });
  115.                             break;
  116.                             case ('br'):
  117.                                 $('.brazil').stop( true, true ).fadeIn();
  118.                                 $('#jqvmap1_br').mouseout(function(e){
  119.                                     e.preventDefault();
  120.                                     $('.brazil').stop( true, true ).fadeOut();
  121.                                 });
  122.                             break;
  123.                             case ('uy'):
  124.                                 $('.uruguay').stop( true, true ).fadeIn();
  125.                                 $('#jqvmap1_uy').mouseout(function(e){
  126.                                     e.preventDefault();
  127.                                     $('.uruguay').stop( true, true ).fadeOut();
  128.                                 });
  129.                             break;
  130.                             case ('gb'):
  131.                                 $('.england').stop( true, true ).fadeIn();
  132.                                 $('#jqvmap1_gb').mouseout(function(e){
  133.                                     e.preventDefault();
  134.                                     $('.england').stop( true, true ).fadeOut();
  135.                                 });
  136.                             break;
  137.                             case ('be'):
  138.                                 $('.belgium').stop( true, true ).fadeIn();
  139.                                 $('#jqvmap1_be').mouseout(function(e){
  140.                                     e.preventDefault();
  141.                                     $('.belgium').stop( true, true ).fadeOut();
  142.                                 });
  143.                             break;
  144.                             case ('rs'):
  145.                                 $('.serbia').stop( true, true ).fadeIn();
  146.                                 $('#jqvmap1_rs').mouseout(function(e){
  147.                                     e.preventDefault();
  148.                                     $('.serbia').stop( true, true ).fadeOut();
  149.                                 });
  150.                             break;
  151.                             case ('pl'):
  152.                                 $('.poland').stop( true, true ).fadeIn();
  153.                                 $('#jqvmap1_pl').mouseout(function(e){
  154.                                     e.preventDefault();
  155.                                     $('.poland').stop( true, true ).fadeOut();
  156.                                 });
  157.                             break;
  158.                             case ('ci'):
  159.                                 $('.ivory').stop( true, true ).fadeIn();
  160.                                 $('#jqvmap1_ci').mouseout(function(e){
  161.                                     e.preventDefault();
  162.                                     $('.ivory').stop( true, true ).fadeOut();
  163.                                 });
  164.                             break;
  165.                             case ('hr'):
  166.                                 $('.croatia').stop( true, true ).fadeIn();
  167.                                 $('#jqvmap1_hr').mouseout(function(e){
  168.                                     e.preventDefault();
  169.                                     $('.croatia').stop( true, true ).fadeOut();
  170.                                 });
  171.                             break;
  172.                             case ('me'):
  173.                                 $('.montenegro').stop( true, true ).fadeIn();
  174.                                 $('#jqvmap1_me').mouseout(function(e){
  175.                                     e.preventDefault();
  176.                                     $('.montenegro').stop( true, true ).fadeOut();
  177.                                 });
  178.                             break;
  179.                             case ('cl'):
  180.                                 $('.chile').stop( true, true ).fadeIn();
  181.                                 $('#jqvmap1_cl').mouseout(function(e){
  182.                                     e.preventDefault();
  183.                                     $('.chile').stop( true, true ).fadeOut();
  184.                                 });
  185.                             break;
  186.                             case ('si'):
  187.                                 $('.slovenia').stop( true, true ).fadeIn();
  188.                                 $('#jqvmap1_si').mouseout(function(e){
  189.                                     e.preventDefault();
  190.                                     $('.slovenia').stop( true, true ).fadeOut();
  191.                                 });
  192.                             break;
  193.                             case ('ru'):
  194.                                 $('.russia').stop( true, true ).fadeIn();
  195.                                 $('#jqvmap1_ru').mouseout(function(e){
  196.                                     e.preventDefault();
  197.                                     $('.russia').stop( true, true ).fadeOut();
  198.                                 });
  199.                             break;
  200.                             case ('tr'):
  201.                                 $('.turkey').stop( true, true ).fadeIn();
  202.                                 $('#jqvmap1_tr').mouseout(function(e){
  203.                                     e.preventDefault();
  204.                                     $('.turkey').stop( true, true ).fadeOut();
  205.                                 });
  206.                             break;
  207.                             case ('cm'):
  208.                                 $('.cameroon').stop( true, true ).fadeIn();
  209.                                 $('#jqvmap1_cm').mouseout(function(e){
  210.                                     e.preventDefault();
  211.                                     $('.cameroon').stop( true, true ).fadeOut();
  212.                                 });
  213.                             break;
  214.                             case ('sk'):
  215.                                 $('.slovakia').stop( true, true ).fadeIn();
  216.                                 $('#jqvmap1_sk').mouseout(function(e){
  217.                                     e.preventDefault();
  218.                                     $('.slovakia').stop( true, true ).fadeOut();
  219.                                 });
  220.                             break;
  221.                             case ('ec'):
  222.                                 $('.ecuador').stop( true, true ).fadeIn();
  223.                                 $('#jqvmap1_ec').mouseout(function(e){
  224.                                     e.preventDefault();
  225.                                     $('.ecuador').stop( true, true ).fadeOut();
  226.                                 });
  227.                             break;
  228.                             case ('ba'):
  229.                                 $('.bosnia').stop( true, true ).fadeIn();
  230.                                 $('#jqvmap1_ba').mouseout(function(e){
  231.                                     e.preventDefault();
  232.                                     $('.bosnia').stop( true, true ).fadeOut();
  233.                                 });
  234.                             break;
  235.                             case ('jp'):
  236.                                 $('.japan').stop( true, true ).fadeIn();
  237.                                 $('#jqvmap1_jp').mouseout(function(e){
  238.                                     e.preventDefault();
  239.                                     $('.japan').stop( true, true ).fadeOut();
  240.                                 });
  241.                             break;
  242.                             case ('se'):
  243.                                 $('.sweden').stop( true, true ).fadeIn();
  244.                                 $('#jqvmap1_se').mouseout(function(e){
  245.                                     e.preventDefault();
  246.                                     $('.sweden').stop( true, true ).fadeOut();
  247.                                 });
  248.                             break;
  249.                             case ('it'):
  250.                                 $('.italy').stop( true, true ).fadeIn();
  251.                                 $('#jqvmap1_it').mouseout(function(e){
  252.                                     e.preventDefault();
  253.                                     $('.italy').stop( true, true ).fadeOut();
  254.                                 });
  255.                             break;
  256.                             case ('cz'):
  257.                                 $('.czech').stop( true, true ).fadeIn();
  258.                                 $('#jqvmap1_cz').mouseout(function(e){
  259.                                     e.preventDefault();
  260.                                     $('.czech').stop( true, true ).fadeOut();
  261.                                 });
  262.                             break;
  263.  
  264.                        }
  265.                     }
Advertisement
Add Comment
Please, Sign In to add comment