Code: Select all
.imgFullOpen{
position:fixed;
top:0px;
right:0px;
bottom:0px;
left:0px;
margin:auto;
z-index:99999;
width:auto;
height:auto;
overflow:scroll;
text-align:center;
/*border:3px solid #333*/
}
.postImageViewFull{
position:relative;
top:0px;
right:0px;
bottom:0px;
left:0px;
margin:auto;
z-index:99999;
width:auto;
height:auto;
overflow:scroll;
text-align:center;
}
Code: Select all
<div id="imgFullOpen" class="imgFullOpen" style="display:none"><img class="postImageViewFull" src="" /></div>
<script>
$(".postimage").on("click", function(event) {
$(".postImageViewFull").attr("src",this.src);
if( $(window).height() > this.naturalHeight || $(window).width() > this.naturalWidth ){
$(".imgFullOpen").css({"overflow":"hidden","display":"block","width":this.naturalWidth,"height":this.naturalHeight});//display":"block","height":"100%"
$(".postImageViewFull").css({"display":"block","width":this.naturalWidth,"height":this.naturalHeight});//display":"block","height":"100%"
var remListenerRecCont = $(document).mouseup(function (e) {
if ($(e.target).closest(".postImageViewFull").length === 0 && (e.target != $('html').get(0))) {
$(".imgFullOpen").css({ "display":"none" });
remListenerRecCont.unbind('mouseup');
}
});
} else {
$(".imgFullOpen").css({"overflow":"auto","display":"block","width":"100%","height":"100%"});
$(".postImageViewFull").css({"display":"block","width":this.naturalWidth,"height":this.naturalHeight});
}
$(".postImageViewFull").on("mouseup", function(event) {
$(".imgFullOpen").css({"display":"none"});
});
});
</script>
Code: Select all
$(".postimage").on("click", function(event) {
window.open(this.src);
}