cropzoom.js
2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
* 处理头像
*/
var sourceImage = '';
var cropzoomSend = 'http://sso.upload.yohobuy.com/crop';
function init()
{
$("#crop").click(function(){
if($('#image_source').val() == '')
{
alert('请上传头像图片');
return false;
}
var parameters = cropzoom.getSendData(cropzoomSend, {} ,'userIframe' );
$('#cropForm').submit();
$(".loading").attr('style', 'display:block');
return false;
});
$("#restore").click(function(){
cropzoom.restore();
});
$("#cropUpdate").click(function(){
if($("#headico").val() == '')
{
return false;
}
return true;
});
$('#choosepic').qupload({
upload_url: 'http://sso.upload.yohobuy.com',
uploadKey: 'f21ebQj7oPAzeleYfLjI5Zf87pXxl1V2-R6wkaICPbRgiMtd4AqnRtKWnXYUPQ20rb697a2gEV7IzOfc08rNasn8H-RRcGBhVeSgkLpSEgJ57yjgM8iJactjicvSGeXhKvY3XFgQsimA1wWwoWcycmk-43HEWnTJw2aY4F8-E-PIdAD6dIDCZSRFcq6xY1W19vKGKTmr1NfZu4UK6q1B4458ZkUJapslzmBK2-6n4RifhXsIke_GF1TDNFpgIKdESweCsXML_nbwKWFWiDDo07QUs9l9F0d90cqkWRV7iqGnm08-zOzC4RzPvRYUqJROEoNiFjBrZdI',
button_image_url: 'http://static.yohobuy.com/images/btn_upload_xzzp.png',
file_types: "*.jpg;*.gif;*.jpeg;*.png",
uploadSuccessed:function(serverData){
var data = eval('(' + serverData + ')');
if(data.code != 12)
{
alert(data.message);
return false;
}
$('#image_source').val(data.data.hit.Filedata.return_file_path);
$('#headico').val(data.data.hit.Filedata.return_file_path);
var imgPath = QGlobal.Common.QGetImagesMongo(data.data.hit.Filedata.return_file_path, 'source', myProject);
crop(imgPath);
}
});
}
function crop(imgPath)
{
if(typeof imgPath == 'undfined' || imgPath == '')
{
return false;
}
$("#" + previewImgId).attr("src", imgPath);
var img = new Image();
img.src = imgPath;
img.onload = function(){
var iWidth = img.width;
var iHeight = img.height;
cropzoom = $('#' + cropzoomId).cropzoom({
width: 300,
height: 300,
bgColor: '#ccc',
enableRotation: true,
enableZoom: true,
selector: {
w:100,
h:100,
showPositionsOnDrag:true,
showDimetionsOnDrag:false,
centered: true,
bgInfoLayer:'#fff',
borderColor: 'blue',
borderColorHover: 'yellow'
},
image: {
source: img.src,
width: iWidth,
height: iHeight,
minZoom: 30,
maxZoom: 150
}
});
};
}