You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

69 lines
3.5 KiB

<script type="text/javascript" src="style/js/jquery.js"></script>
<script type="text/javascript" src="style/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="style/lib/layer/2.1/layer.js"></script>
<script type="text/javascript" src="style/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="style/lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="style/lib/ueditor/1.4.3/ueditor.all.min.js"></script>
<script type="text/javascript" src="style/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<!-- 新增编辑器引入文件 -->
<link rel="stylesheet" href="style/kindeditor/themes/default/default.css"/>
<script src="style/kindeditor/kindeditor-min.js"></script>
<script src="style/kindeditor/lang/zh_CN.js"></script>
<script language="javascript" src="style/js/check.js"> </script>
<script type="text/javascript" src="style/js/laydate/laydate.js"></script>
<div id="outerdiv" style="position:fixed;top:0;left:0;background:rgba(0,0,0,0.7);z-index:2;width:100%;height:100%;display:none;"><div id="innerdiv" style="position:absolute;"><img id="bigimg" src="" /></div></div>
<script type="text/javascript">
$(function(){
$(".pimg").click(function(){
var _this = $(this);//pimg元素作为_this传入函数
imgShow("#outerdiv", "#innerdiv", "#bigimg", _this);
});
});
function imgShow(outerdiv, innerdiv, bigimg, _this){
var src = _this.attr("src");//pimg元素中的src属性
$(bigimg).attr("src", src);//#bigimg元素的src属性
/**/
$("<img/>").attr("src", src).load(function(){
var windowW = $(window).width();//
var windowH = $(window).height();//
var realWidth = this.width;//
var realHeight = this.height;//
var imgWidth, imgHeight;
var scale = 0.8;//
if(realHeight>windowH*scale) {//
imgHeight = windowH*scale;//
imgWidth = imgHeight/realHeight*realWidth;//
if(imgWidth>windowW*scale) {//
imgWidth = windowW*scale;//
}
} else if(realWidth>windowW*scale) {//
imgWidth = windowW*scale;//
imgHeight = imgWidth/realWidth*realHeight;//
} else {//
imgWidth = realWidth;
imgHeight = realHeight;
}
$(bigimg).css("width",imgWidth);//
var w = (windowW-imgWidth)/2;//
var h = (windowH-imgHeight)/2;//
$(innerdiv).css({"top":h, "left":w});//#innerdiv的top和left属性
$(outerdiv).fadeIn("fast");//#outerdiv及.pimg
});
$(outerdiv).click(function(){//
$(this).fadeOut("fast");
});
}
</script>