-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
34 lines (29 loc) · 1018 Bytes
/
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
$(document).ready(function () {
function openFullscreenImage(imageUrl) {
var container = $("<div>").addClass("fullscreen-image");
var img = $("<img>").attr("src", imageUrl);
container.click(function (event) {
if (event.target === this) {
$(this).remove();
}
});
var closeButton = $("<span>").html("×").addClass("close-button");
closeButton.click(function () {
container.remove();
});
closeButton.css("cursor", "pointer");
container.append(img, closeButton);
$("body").append(container);
}
function isMobile() {
return $(window).width() <= 768;
}
var images = $(".section-img, .img-fluid");
images.click(function () {
var imageUrl = $(this).attr("src");
openFullscreenImage(imageUrl);
if (isMobile()) {
$("img[src='" + imageUrl + "']").css({ "max-width": "90%", "max-height": "90vh" });
}
});
});