<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('上传Banner图片')" />
	<th:block th:include="include :: cropbox-css" />
    <style>

        .thumbBox_L{
            position: absolute;
            top: 50%;
            left: 50%;
            width: 730px;
            height: 390px;
            margin-left: -365px;
            margin-top: -195px;
            box-sizing: border-box;
            border: 1px solid rgb(102, 102, 102);
            box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.5);
            background: none repeat scroll 0% 0% transparent;
        }
        .imageBox_L{
            margin: 0 auto;
            width: 800px;
            height: 450px;
        }
    </style>
</head>
<body class="white-bg">
    <div class="container" style="width: 100%;">
        <div class="imageBox imageBox_L" style="margin: 0 auto;">
	        <div class="thumbBox_L" ></div>
	        <div class="spinner" style="display: none">Loading...</div> 
	   </div> 
	   <div class="action" style="margin: 10px auto;">
	       <div class="new-contentarea tc">
	           <a href="javascript:void(0)" class="upload-img"> <label for="avatar">上传图像</label> </a> 
	           <input type="file" class="" name="avatar" id="avatar" accept="image/*"/>
	       </div>
           <input type="button" id="btnZoomIn" class="Btnsty_peyton" value="+" />
           <input type="button" id="btnZoomOut" class="Btnsty_peyton"  value="-" />
	   </div> 

    </div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: cropbox-js" />
<script type="text/javascript">
var cropper;
$(window).load(function() {
	var imgUrl = '[[${imgUrl}]]';
    var options = {
        thumbBox: '.thumbBox_L',
        spinner: '.spinner',
        imgSrc: $.common.isEmpty(imgUrl) ? ctx + 'img/profile.jpg' : ctx +imgUrl
    }
    cropper = $('.imageBox').cropbox(options);
    $('#avatar').on('change', function() {
        var reader = new FileReader();
        reader.onload = function(e) {
            options.imgSrc = e.target.result;
            //根据MIME判断上传的文件是不是图片类型
            if((options.imgSrc).indexOf("image/")==-1){
                $.modal.alertWarning("文件格式错误，请上传图片类型,如：JPG，PNG后缀的文件。");
            } else {
                cropper = $('.imageBox').cropbox(options);
            }
        }
        reader.readAsDataURL(this.files[0]);
    })
    

	$('#btnZoomIn').on('click', function(){
		cropper.zoomIn();
	})
	
	$('#btnZoomOut').on('click', function(){
		cropper.zoomOut();
	})
});



</script>
</body>
</html>
