-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
90 lines (89 loc) · 2.17 KB
/
index.html
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
89
90
<!doctype html>
<html>
<head>
<title>Crop Demo</title>
<script src="crop.js"></script>
<link href='http://fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
<style>
body{
background: #777;
font-family: 'Lato', sans-serif;
color: #fff;
user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
}
#container{
width: 760px;
margin: 0 auto;
text-align: center;
font-size: 150%;
}
img{
max-width: 100%;
box-shadow: 0 0 8px #333;
border: 4px solid #fff;
margin-left: -4px;
border-radius: 4px;
background: #eee;
}
#image-container{
}
button{
display: none;
margin: 20px 5px;
}
#info{
display: none;
}
#btn-crop{
display: inline;
}
</style>
</head>
<body>
<div id="container">
<h1>canvas_crop</h1>
<div>Lightweight plugin for client side image cropping using HTML5 canvas</div>
<h3>Try it</h3>
<div id="image-container">
<img id="crop-img" src="1.jpg"><br>
<button id="btn-crop">Crop</button>
<button id="btn-ok">OK</button>
<button id="btn-cancel">Cancel</button>
<div id="info">Drag rectangle to move, drag at border and edges to resize</div>
</div>
<script>
cropimg = document.getElementById('crop-img');
cropbtn = document.getElementById('btn-crop');
okbtn = document.getElementById('btn-ok');
cancelbtn = document.getElementById('btn-cancel')
showbuttons = function(){
cropbtn.style.display == 'inline';
}
cropbtn.onclick = function(){
window.cropInstance = canvas_crop(cropimg);
this.style.display = 'none';
okbtn.style.display = 'inline';
cancelbtn.style.display = 'inline';
document.getElementById('info').style.display = 'block';
}
cancelCrop = function(){
cropbtn.style.display = 'inline';
okbtn.style.display = 'none';
cancelbtn.style.display = 'none';
cropInstance.destroy();
document.getElementById('info').style.display = 'none';
}
okbtn.onclick = function(){
cropInstance.cropToCanvas();
cropimg.src = cropInstance.canvasEl.toDataURL("image/jpeg");
cancelCrop();
}
cancelbtn.onclick = function(){
cancelCrop();
}
</script>
</div>
</body>
</html>