X-Git-Url: https://dev.renevier.net/gitweb.cgi?p=syp.git;a=blobdiff_plain;f=js%2Fsyp.js;h=d8a54b5d5a59611d44cb4663e5dbec309161abb7;hp=fdd69ed7253b293e1d6dd9b0c1044925ee8fa4e8;hb=e57c166b46cf9c5961bca1b2241783944277cef5;hpb=2e4b166add373d0a2edcbd8b81babfec7a1b3892 diff --git a/js/syp.js b/js/syp.js index fdd69ed..d8a54b5 100644 --- a/js/syp.js +++ b/js/syp.js @@ -198,6 +198,50 @@ var SYP = { }; map.addPopup(popup); feature.popup = popup; + var anchor = popup.div.getElementsByTagName("a")[0]; + if (anchor) { + anchor.onclick = function() { + SYP.showBigImage(this.href); + return false; + } + } + }, + + showBigImage: function (href) { + try { + document.getElementById('bigimg_container').style.display = "table"; + } catch(e) { + document.getElementById('bigimg_container').style.display = "block"; + } + var maxHeight = document.body.clientHeight * 0.9; + var maxWidth = document.body.clientWidth * 0.9; + document.getElementById('bigimg').style.height = ""; + document.getElementById('bigimg').style.width = ""; + document.getElementById('bigimg').style.maxHeight = maxHeight + "px"; + document.getElementById('bigimg').style.maxWidth = maxWidth + "px"; + document.getElementById('bigimg').onload = function () { + var icon = document.getElementById('bigimg_close'); + icon.style.top = this.offsetTop; + icon.style.left = this.offsetLeft + this.clientWidth - icon.clientWidth; + + var heightRatio = this.clientHeight / parseInt(this.style.maxHeight); + var widthRatio = this.clientWidth / parseInt(this.style.maxWidth); + if (heightRatio > 1 || widthRatio > 1) { + if (heightRatio > widthRatio) { + this.style.height = this.style.maxHeight; + } else { + this.style.width = this.style.maxWidth; + } + } + + }; + document.getElementById('bigimg').src = href; + }, + + closeBigImage: function() { + document.getElementById('bigimg').src = ""; + document.getElementById('bigimg').parentNode.innerHTML = document.getElementById('bigimg').parentNode.innerHTML; + document.getElementById('bigimg_container').style.display = "none"; }, Utils: {