(function($){ qmul.map = function(el, hHeight, map){ this.map = map; this.el = el; this.headerHeight = hHeight; this.mapHeight = this.map.outerHeight(); if (Modernizr.opacity === true){ this.overlay = $("
").addClass("overlay").css({width:$("body").width(),height:$("body").height(),opacity:0}); } else { this.overlay = $("").addClass("overlay").css({width:$("body").width(),height:$("body").height()}); } return this; }; qmul.map.prototype = { showHideMap: function(){ var that = this; that.el.data("shown",false).bind("click",function(e){ $(this).toggleClass("shown") if ($(this).data("shown") === false){ $(this).data("shown",true); that.map.animate({top:that.headerHeight},1000,'easeOutBounce'); if (Modernizr.opacity === true){ that.overlay.prependTo("body").animate({opacity:1},350); } else { that.overlay.prependTo("body"); } } else if ($(this).data("shown") === true) { $(this).data("shown",false); that.map.animate({top:(-(that.mapHeight - that.headerHeight)+5)},500,'easeOutCubic'); if (Modernizr.opacity === true){ that.overlay.animate({opacity:0},250,function(){ $(this).remove(); }); } else { that.overlay.remove(); } } e.preventDefault(); }); return this; }, drawWorldMap: function(){ $.post('/world/mapdata/format/json',function(data){ $('#worldMap').vectorMap( { values: data, scaleColors: ['#6f83a4', '#82acef'], normalizeFunction: 'polynomial', backgroundColor: 'transparent', color:'#5d7191', hoverColor:'#fff', preserveAspectRatio: "none", stroke: "none", onLabelShow: function(event, label, code){ var numReports = parseInt(data[code],10); var reportText; if (numReports > 1 ){ reportText = numReports + " reports"; } else if (numReports === 1 ) { reportText = numReports + " report"; } else { reportText = "0 reports"; } label.append(''+reportText+''); }, onRegionClick: function(event, code){ if ( typeof data[code] !== 'undefined' && data[code] > 0) { window.location.href = "/country-details?iso="+code } } } ); }); return this; } }; })(jQuery);