Plugin Directory

Changeset 609515


Ignore:
Timestamp:
10/08/2012 11:04:49 AM (13 years ago)
Author:
philip.newcomer
Message:

Updating the jQuery RWD Image Maps plugin to version 1.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • responsive-image-maps/trunk/jquery.rwdImageMaps.min.js

    r586021 r609515  
    11/*
    2 * rwdImageMaps jQuery plugin v1.2
     2* rwdImageMaps jQuery plugin v1.3
    33*
    44* Allows image maps to be used in a responsive design by recalculating the area coordinates to match the actual image size on load and window.resize
     
    99* Licensed under the MIT license
    1010*/
    11 (function(a){a.fn.rwdImageMaps=function(){var d=this,c=parseFloat(a.fn.jquery);var b=function(){d.each(function(){if(typeof(a(this).attr("usemap"))=="undefined"){return}var e=this;a("<img />").attr("src",a(e).attr("src")).load(function(){var f,i;if(c<1.6){f=a(e)[0].getAttribute("width"),i=a(e)[0].getAttribute("height")}else{f=a(e).attr("width"),i=a(e).attr("height")}var g=a(e).width()/100,k=a(e).height()/100,j=a(e).attr("usemap").replace("#",""),l="coords";a('map[name="'+j+'"]').find("area").each(function(){if(!a(this).data(l)){a(this).data(l,a(this).attr(l))}var n=a(this).data(l).split(","),m=new Array(n.length);for(var h=0;h<m.length;++h){if(h%2===0){m[h]=parseInt(((n[h]/f)*100)*g)}else{m[h]=parseInt(((n[h]/i)*100)*k)}}a(this).attr(l,m.toString())})})})};b();a(window).resize(function(){b()})}})(jQuery);
     11;(function(a){a.fn.rwdImageMaps=function(){var d=this,c=parseFloat(a.fn.jquery);var b=function(){d.each(function(){if(typeof(a(this).attr("usemap"))=="undefined"){return}var f=this,e=a(f);a("<img />").load(function(){var i,k,l="width",g="height";if(c<1.6){i=f.getAttribute(l),k=f.getAttribute(g)}else{i=e.attr(l),k=e.attr(g)}var j=e.width()/100,n=e.height()/100,m=e.attr("usemap").replace("#",""),o="coords";a('map[name="'+m+'"]').find("area").each(function(){var r=a(this);if(!r.data(o)){r.data(o,r.attr(o))}var q=r.data(o).split(","),p=new Array(q.length);for(var h=0;h<p.length;++h){if(h%2===0){p[h]=parseInt(((q[h]/i)*100)*j)}else{p[h]=parseInt(((q[h]/k)*100)*n)}}r.attr(o,p.toString())})}).attr("src",e.attr("src"))})};a(window).resize(b).trigger("resize");return this}})(jQuery);
Note: See TracChangeset for help on using the changeset viewer.