blob: fc95e1640fcd578dd03a68aa01556e93d9945ea5 (
plain)
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
|
// Callback to close the embedded image (openembeddedimage.js)
HashOverConstructor.prototype.closeEmbeddedImage = function (image)
{
// Reset source
image.src = image.dataset.placeholder;
// Reset title
image.title = this.locale['external-image-tip'];
// Remove loading class from wrapper
this.classes.remove (image.parentNode, 'hashover-loading');
};
// Onclick callback function for embedded images (openembeddedimage.js)
HashOverConstructor.prototype.openEmbeddedImage = function (image)
{
// Reference to this object
var hashover = this;
// If embedded image is open, close it and return false
if (image.src === image.dataset.url) {
this.closeEmbeddedImage (image);
return false;
}
// Set title
image.title = this.locale['loading'];
// Add loading class to wrapper
this.classes.add (image.parentNode, 'hashover-loading');
// Change title and remove load event handler once image is loaded
image.onload = function ()
{
image.title = hashover.locale['click-to-close'];
image.onload = null;
// Remove loading class from wrapper
hashover.classes.remove (image.parentNode, 'hashover-loading');
};
// Close embedded image if any error occurs
image.onerror = function ()
{
hashover.closeEmbeddedImage (this);
};
// Set placeholder image to embedded source
image.src = image.dataset.url;
};
|