(function () {
var MAX_WIDTH = 900; // Masaüstünde görsel en fazla 900px
var VIEWPORT_WIDTH = 80; // Ekran genişliğinin en fazla %80'i
var VIEWPORT_HEIGHT = 80; // Ekran yüksekliğinin en fazla %80'i
function addGlunoImageStyle() {
if (document.getElementById("glunoImageModalStyle")) return;
var style = document.createElement("style");
style.id = "glunoImageModalStyle";
style.innerHTML = `
#glunoImageModal {
display: none;
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 999999;
background: rgba(0,0,0,.68);
align-items: center;
justify-content: center;
padding: 30px;
box-sizing: border-box;
}
#glunoImageModal.gluno-open {
display: flex;
}
#glunoImageModalBox {
position: relative;
display: flex;
align-items: center;
justify-content: center;
max-width: ${VIEWPORT_WIDTH}vw;
max-height: ${VIEWPORT_HEIGHT}vh;
background: #fff;
padding: 12px;
border-radius: 8px;
box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
#glunoImageModalImg {
display: block;
width: auto;
height: auto;
max-width: min(${MAX_WIDTH}px, ${VIEWPORT_WIDTH}vw);
max-height: ${VIEWPORT_HEIGHT}vh;
object-fit: contain;
cursor: default !important;
}
#glunoImageModalClose {
position: absolute;
right: -14px;
top: -14px;
width: 34px;
height: 34px;
border: 0;
border-radius: 50%;
background: #fff;
color: #222;
font-size: 24px;
line-height: 34px;
text-align: center;
cursor: pointer;
box-shadow: 0 3px 12px rgba(0,0,0,.25);
padding: 0;
}
#ProductDetailMain #imgUrunResim {
cursor: pointer !important;
}
@media(max-width:768px) {
#glunoImageModal {
padding: 18px;
}
#glunoImageModalBox {
max-width: 92vw;
max-height: 82vh;
padding: 8px;
}
#glunoImageModalImg {
max-width: 88vw;
max-height: 78vh;
}
}
`;
document.head.appendChild(style);
}
function createGlunoImageModal() {
if (document.getElementById("glunoImageModal")) return;
var modal = document.createElement("div");
modal.id = "glunoImageModal";
modal.innerHTML = `
`;
document.body.appendChild(modal);
modal.addEventListener("click", function (e) {
if (e.target === modal) {
closeGlunoImageModal();
}
});
document
.getElementById("glunoImageModalClose")
.addEventListener("click", function () {
closeGlunoImageModal();
});
document.addEventListener("keydown", function (e) {
if (e.key === "Escape") {
closeGlunoImageModal();
}
});
}
function openGlunoImageModal(image) {
var modal = document.getElementById("glunoImageModal");
var modalImage = document.getElementById("glunoImageModalImg");
modalImage.src = image.currentSrc || image.src;
modalImage.alt = image.alt || "";
modal.classList.add("gluno-open");
}
function closeGlunoImageModal() {
var modal = document.getElementById("glunoImageModal");
if (modal) {
modal.classList.remove("gluno-open");
}
}
function blockTicimaxZoom(e) {
var image = e.target.closest(
"#ProductDetailMain #imgUrunResim"
);
if (!image) return;
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
openGlunoImageModal(image);
return false;
}
function initGlunoProductImage() {
addGlunoImageStyle();
createGlunoImageModal();
/*
* Capture=true:
* Ticimax Fancybox click olayından önce yakalar.
*/
document.addEventListener(
"click",
blockTicimaxZoom,
true
);
}
if (document.readyState === "loading") {
document.addEventListener(
"DOMContentLoaded",
initGlunoProductImage
);
} else {
initGlunoProductImage();
}
})();