gushidianzibao-h5/public/static/js/jquery.rwdImageMaps.min.js

1 line
785 B
JavaScript
Raw Normal View History

2024-12-26 14:18:10 +08:00
(function($){$.fn.rwdImageMaps=function(){var $img=this;var rwdImageMap=function(){$img.each(function(){if(typeof($(this).attr("usemap"))=="undefined"){return}var that=this,$that=$(that);$("<img />").load(function(){var temp=new Image();temp.src=$that.attr("src");var w1=temp.width;var w2=$that.width();var map=$that.attr("usemap").replace("#",""),c="coords";$('map[name="'+map+'"]').find("area").each(function(){var $this=$(this);if(!$this.data(c)){$this.data(c,$this.attr(c))}var coords=$this.data(c).split(","),coordsPercent=new Array(coords.length);for(var i=0;i<coordsPercent.length;++i){coordsPercent[i]=parseInt((coords[i]/w1)*w2)}$this.attr(c,coordsPercent.toString())})}).attr("src",$that.attr("src"))})};$(window).resize(rwdImageMap).trigger("resize");return this}})(jQuery);