From e57c166b46cf9c5961bca1b2241783944277cef5 Mon Sep 17 00:00:00 2001 From: arno Date: Fri, 7 Aug 2009 00:31:45 +0200 Subject: [PATCH] when clicking image in popup, show it full screen --- inc/templates_index.php | 10 +++++++++ js/syp.js | 44 ++++++++++++++++++++++++++++++++++++++++ media/syp.css | 45 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) diff --git a/inc/templates_index.php b/inc/templates_index.php index 6fd516b..a84a9c6 100644 --- a/inc/templates_index.php +++ b/inc/templates_index.php @@ -73,5 +73,15 @@ if (defined ("THUMBSMAXSIZE") && (THUMBSMAXSIZE > 0)) {
+
+
+
+ + <?php ptrans('close')?> +
+
+ 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: { diff --git a/media/syp.css b/media/syp.css index 25be854..1a9fa05 100644 --- a/media/syp.css +++ b/media/syp.css @@ -40,3 +40,48 @@ font-weight: bold; background-color: white; } + +#bigimg_container { + z-index: 2001; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + display: none; + text-align: center; + overflow: hidden; +} +#bigimg_transparency { + z-index: -1; + position: absolute; + top: 0px; + left: 0px; + right: 0px; + bottom; 0px; + width: 100%; + height: 100%; + background-color: #000; + opacity: 0.6; + filter: alpha(opacity = 60); +} +#bigimg_content { + display: table-cell; + vertical-align: middle; + _position: absolute; + _top: 50%; + _left: 50%; +} +#bigimg { + -moz-user-select: none; + -webkit-user-select: none; + _position: relative; + _left: -50%; + _top: -50%; +} +#bigimg_close { + position: absolute; + top: 0; + left: 0; + cursor: pointer; +} -- 2.39.2