-
Notifications
You must be signed in to change notification settings - Fork 6
/
demo.html
71 lines (60 loc) · 2.78 KB
/
demo.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
<!DOCTYPE html>
<html>
<head>
<title>Signature demo</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Just to make this demo look nicer -->
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" />
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<style type="text/css">
form p{margin-top:1em}#mySignature .radio{margin-left:20px}.clear-canvas{display:block}
.sign-field canvas {
border: 1px silver solid;
width: 350px; height: 200px /* Size of signature image */
}
</style>
</head>
<body>
<div class="container">
<h1>Form with signature field</h1>
<form method="POST" action="#dump">
<div>
<button class="btn btn-default" id="reload">Reload</button>
a previously drawn signature (saved as <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/data_URIs" rel="external friend" onclick="window.open(this.href);return false">data URI</a>).
</div>
<div id="mySignature" data-name="mySignature" data-max-size="2048"
data-pen-tickness="3" data-pen-color="green"
class="sign-field"></div>
<p>
<a href="#inspect">Open request inspector</a>
before submitting, to see what is sent.
</p>
<button class="btn btn-primary" disabled="disabled">Submit</button>
</form>
</div>
<script src="//codeorigin.jquery.com/jquery-1.10.2.min.js"></script>
<script src="//intridea.github.com/sketch.js/lib/sketch.min.js"></script>
<script src="lang/jquery.signfield-en.min.js"></script>
<script src="js/jquery.signfield.min.js"></script>
<script src="demo.js"></script>
<script type="text/javascript">
var s = $('#mySignature').signField(). // Setup
on('change', function(){
var signature = $(this); // div
if (signature.signField('errors').length == 0) {
$('.btn-primary').removeAttr("disabled")
} else $('.btn-primary').attr("disabled", "disabled")
});
$('#reload').click(function(){
s.signField('imagedata', _sample);
return false
})
</script>
<!-- Request inspector for demo -->
<script type="text/javascript">$.ajax({"type":"POST","url": "http://requestb.in/api/v1/bins","data":{"private":"false"}}).done(function(d){ var ru="http://requestb.in/"+d.name; $('a[href="#inspect"]').click(function(){ window.open(ru + "?inspect"); return false }); $('form').attr("action", ru) })</script>
<!-- Just to make this demo look nicer -->
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script type="text/javascript">$('.clear-canvas').prepend('<i class="fa fa-eraser"></i>')</script>
</body>
</html>