-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
76 lines (70 loc) · 2.17 KB
/
script.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
// Generated by CoffeeScript 1.3.1
(function() {
var addLinkListeners, cacheImage, handleZoom, init;
init = function() {
if (window.verbose) {
console.log("loaded");
}
window.zoom = new Zoom("z");
return addLinkListeners();
};
addLinkListeners = function() {
var a, fileTypes, type, _i, _len, _ref, _results;
fileTypes = [".jpg", ".png", ".gif", ".jpeg", ".bmp", ".tiff", ".webp"];
_ref = document.getElementsByTagName("a");
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
a = _ref[_i];
_results.push((function() {
var _j, _len1, _results1;
_results1 = [];
for (_j = 0, _len1 = fileTypes.length; _j < _len1; _j++) {
type = fileTypes[_j];
if (a.getAttribute("href").match(type)) {
if (a.childNodes.length !== 0 && a.firstChild === a.getElementsByTagName("img")[0]) {
a.addEventListener("mouseover", cacheImage, false);
_results1.push(a.addEventListener("click", handleZoom, false));
} else {
_results1.push(void 0);
}
} else {
_results1.push(void 0);
}
}
return _results1;
})());
}
return _results;
};
handleZoom = function(e) {
var image,
_this = this;
e.preventDefault();
if (this.loaded) {
return window.zoom.zoom(this);
} else {
window.zoom.showLoadingIndicator();
image = document.createElement("img");
image.onload = function() {
window.zoom.cache[image.src] = image;
window.zoom.hideLoadingIndicator();
_this.loaded = true;
return window.zoom.zoom(_this);
};
return image.src = this.getAttribute("href");
}
};
cacheImage = function(e) {
var image, url,
_this = this;
image = document.createElement("img");
url = this.getAttribute("href");
image.onload = function() {
_this.loaded = true;
window.zoom.cache[url] = image;
return _this.removeEventListener("mouseover", cacheImage, false);
};
return image.src = url;
};
window.addEventListener("DOMContentLoaded", init, false);
}).call(this);