Skip to content

Commit ded8104

Browse files
committed
Added support for jQuery 3. Dropped <1.7. Fixes #103
1 parent 7549e35 commit ded8104

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2013 Izilla Partners Pty Ltd
3+
Copyright (c) 2016 Matt Stow
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of
66
this software and associated documentation files (the "Software"), to deal in

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ http://mattstow.com/experiment/responsive-image-maps/rwd-image-maps.html
2828

2929
---
3030

31-
Copyright (c) 2012 [Matt Stow](http://mattstow.com)
31+
Copyright (c) 2016 [Matt Stow](http://mattstow.com)
3232
Licensed under the MIT license *(see [LICENSE](https://github.com/stowball/jQuery-rwdImageMaps/blob/master/LICENSE) for details)*
3333
Minified version created with Online YUI Compressor: http://www.refresh-sf.com/yui/

jquery.rwdImageMaps.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
/*
2-
* rwdImageMaps jQuery plugin v1.5
2+
* rwdImageMaps jQuery plugin v1.6
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
55
*
6-
* Copyright (c) 2013 Matt Stow
6+
* Copyright (c) 2016 Matt Stow
77
* https://github.com/stowball/jQuery-rwdImageMaps
88
* http://mattstow.com
99
* Licensed under the MIT license
1010
*/
1111
;(function($) {
1212
$.fn.rwdImageMaps = function() {
1313
var $img = this;
14-
14+
1515
var rwdImageMap = function() {
1616
$img.each(function() {
1717
if (typeof($(this).attr('usemap')) == 'undefined')
1818
return;
19-
19+
2020
var that = this,
2121
$that = $(that);
22-
22+
2323
// Since WebKit doesn't know the height until after the image has loaded, perform everything in an onload copy
24-
$('<img />').load(function() {
24+
$('<img />').on('load', function() {
2525
var attrW = 'width',
2626
attrH = 'height',
2727
w = $that.attr(attrW),
2828
h = $that.attr(attrH);
29-
29+
3030
if (!w || !h) {
3131
var temp = new Image();
3232
temp.src = $that.attr('src');
@@ -35,20 +35,20 @@
3535
if (!h)
3636
h = temp.height;
3737
}
38-
38+
3939
var wPercent = $that.width()/100,
4040
hPercent = $that.height()/100,
4141
map = $that.attr('usemap').replace('#', ''),
4242
c = 'coords';
43-
43+
4444
$('map[name="' + map + '"]').find('area').each(function() {
4545
var $this = $(this);
4646
if (!$this.data(c))
4747
$this.data(c, $this.attr(c));
48-
48+
4949
var coords = $this.data(c).split(','),
5050
coordsPercent = new Array(coords.length);
51-
51+
5252
for (var i = 0; i < coordsPercent.length; ++i) {
5353
if (i % 2 === 0)
5454
coordsPercent[i] = parseInt(((coords[i]/w)*100)*wPercent);
@@ -61,7 +61,7 @@
6161
});
6262
};
6363
$(window).resize(rwdImageMap).trigger('resize');
64-
64+
6565
return this;
6666
};
67-
})(jQuery);
67+
})(jQuery);

jquery.rwdImageMaps.min.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* rwdImageMaps jQuery plugin v1.5
2+
* rwdImageMaps jQuery plugin v1.6
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
55
*
6-
* Copyright (c) 2013 Matt Stow
6+
* Copyright (c) 2016 Matt Stow
77
* https://github.com/stowball/jQuery-rwdImageMaps
88
* http://mattstow.com
99
* Licensed under the MIT license
1010
*/
11-
;(function(a){a.fn.rwdImageMaps=function(){var c=this;var b=function(){c.each(function(){if(typeof(a(this).attr("usemap"))=="undefined"){return}var e=this,d=a(e);a("<img />").load(function(){var g="width",m="height",n=d.attr(g),j=d.attr(m);if(!n||!j){var o=new Image();o.src=d.attr("src");if(!n){n=o.width}if(!j){j=o.height}}var f=d.width()/100,k=d.height()/100,i=d.attr("usemap").replace("#",""),l="coords";a('map[name="'+i+'"]').find("area").each(function(){var r=a(this);if(!r.data(l)){r.data(l,r.attr(l))}var q=r.data(l).split(","),p=new Array(q.length);for(var h=0;h<p.length;++h){if(h%2===0){p[h]=parseInt(((q[h]/n)*100)*f)}else{p[h]=parseInt(((q[h]/j)*100)*k)}}r.attr(l,p.toString())})}).attr("src",d.attr("src"))})};a(window).resize(b).trigger("resize");return this}})(jQuery);
11+
;(function(a){a.fn.rwdImageMaps=function(){var c=this;var b=function(){c.each(function(){if(typeof(a(this).attr("usemap"))=="undefined"){return}var e=this,d=a(e);a("<img />").on('load',function(){var g="width",m="height",n=d.attr(g),j=d.attr(m);if(!n||!j){var o=new Image();o.src=d.attr("src");if(!n){n=o.width}if(!j){j=o.height}}var f=d.width()/100,k=d.height()/100,i=d.attr("usemap").replace("#",""),l="coords";a('map[name="'+i+'"]').find("area").each(function(){var r=a(this);if(!r.data(l)){r.data(l,r.attr(l))}var q=r.data(l).split(","),p=new Array(q.length);for(var h=0;h<p.length;++h){if(h%2===0){p[h]=parseInt(((q[h]/n)*100)*f)}else{p[h]=parseInt(((q[h]/j)*100)*k)}}r.attr(l,p.toString())})}).attr("src",d.attr("src"))})};a(window).resize(b).trigger("resize");return this}})(jQuery);

0 commit comments

Comments
 (0)