-
Notifications
You must be signed in to change notification settings - Fork 0
/
imageMapResizer.min.js
114 lines (112 loc) · 3.8 KB
/
imageMapResizer.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* ! Image Map Resizer (imageMapResizer.min.js ) - v1.0.10 - 2019-04-10 Desc:
* Resize HTML imageMap to scaled image. Copyright: (c) 2019 David J. Bradshaw
* - dave@bradshaw.net License: MIT
*/
!function () {
"use strict";
function r() {
function e() {
var r = {
width: u.width / u.naturalWidth,
height: u.height / u.naturalHeight
},
a = {
width: parseInt(
window.getComputedStyle(u, null).getPropertyValue("padding-left"),
10
),
height: parseInt(
window.getComputedStyle(u, null).getPropertyValue("padding-top"),
10
)
};
i.forEach(function (e, t) {
var n = 0;
o[t].coords = e
.split(",")
.map(function (e) {
var t = 1 == (n = 1 - n)
? "width"
: "height";
return a[t] + Math.floor(Number(e) * r[t])
})
.join(",")
})
}
function t(e) {
return e
.coords
.replace(/ *, */g, ",")
.replace(/ +/g, ",")
}
function n() {
clearTimeout(d),
d = setTimeout(e, 250)
}
function r(e) {
return document.querySelector('img[usemap="' + e + '"]')
}
var a = this,
o = null,
i = null,
u = null,
d = null;
"function" != typeof a._resize
? (
o = a.getElementsByTagName("area"),
i = Array.prototype.map.call(o, t),
u = r(
"#" + a.name
) || r(a.name),
a._resize = e,
u.addEventListener("load", e, !1),
window.addEventListener("focus", e, !1),
window.addEventListener("resize", n, !1),
window.addEventListener("readystatechange", e, !1),
document.addEventListener("fullscreenchange", e, !1),
u.width === u.naturalWidth && u.height === u.naturalHeight || e()
)
: a._resize()
}
function e() {
function t(e) {
e && (!function (e) {
if (!e.tagName)
throw new TypeError("Object is not a valid DOM element");
if ("MAP" !== e.tagName.toUpperCase())
throw new TypeError("Expected <MAP> tag, found <" + e.tagName + ">.")
}(e), r.call(e), n.push(e))
}
var n;
return function (e) {
switch (n = [], typeof e) {
case "undefined":
case "string":
Array
.prototype
.forEach
.call(document.querySelectorAll(e || "map"), t);
break;
case "object":
t(e);
break;
default:
throw new TypeError("Unexpected data type (" + typeof e + ").")
}
return n
}
}
"function" == typeof define && define.amd
? define([], e)
: "object" == typeof module && "object" == typeof module.exports
? module.exports = e()
: window.imageMapResize = e(),
"jQuery" in window && (window.jQuery.fn.imageMapResize = function () {
return this
.filter("map")
.each(r)
.end()
})
}();
//# sourceMappingURL=imageMapResizer.map
//# sourceMappingURL=imageMapResizer.map