forked from brinley/jSignature
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
94 lines (80 loc) · 2.04 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
91
92
93
94
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
html,
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#wrapper {
display: flex;
height: 100%;
overflow: hidden;
justify-content: center;
align-items: center;
}
#signatureparent {
display: flex;
flex: 1;
overflow: hidden;
justify-content: center;
align-items: center;
padding:16px
}
#signature {
padding: 0;
margin: 0;
flex: 1;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="signatureparent" style="touch-action:none;">
<div id="signature" style="touch-action:none;"></div>
</div>
</div>
<script src="https://github.com/jsp3536/jSignature/blob/master/jquery.js"></script>
<script src="https://github.com/jsp3536/jSignature/blob/master/jSignature.min.js"></script>
<script src="https://github.com/jsp3536/jSignature/blob/master/Signature.CompressorBase30.js"></script>
<script>
$(document).ready(function () {
document.addEventListener('message', function (message) {
if (message.data === 'clearSignature') {
clear();
}
else if (message.data === 'getSignature') {
submit();
}
});
document.body.style.overflow = "hidden";
var $sigdiv = $("#signature").jSignature({
'width': 'ratio',
'height': 'ratio',
'sizeRatio': '3'
});
$("#signature").bind('change',
function (e) {
var datapair = $("#signature").jSignature("getData", "base30");
console.log('change')
if (datapair[1].length > 0) {
window.postMessage(btoa(datapair[1]));
}
});
})
function clear() {
$("#signature").jSignature("reset");
}
function submit() {
var datapair = $("#signature").jSignature("getData", "base30");
console.log('submit')
alert(datapair[1])
window.postMessage(datapair[1]);
}
</script>
</body>
</html>