12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
- Remove this if you use the .htaccess -->
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="initial-scale=1.0, target-densitydpi=device-dpi" /><!-- this is for mobile (Android) Chrome -->
- <meta name="viewport" content="initial-scale=1.0, width=device-height"><!-- mobile Safari, FireFox, Opera Mobile -->
- <script src="libs/modernizr.js"></script>
- <!--[if lt IE 9]>
- <script type="text/javascript" src="libs/flashcanvas.js"></script>
- <![endif]-->
- <script src="libs/jquery.js"></script>
- <script src="libs/jSignature.min.noconflict.js"></script>
- </head>
- <body>
- <div id="content">
- <div id="signatureparent">
- <div id="signature" style="border: 2px dotted black;"></div>
- </div>
- <div id="tools"></div>
- <div>
- <img id="myImg" />
- </div>
- </div>
- <script type="text/javascript">
- (function($) {
- var topics = {};
- $.publish = function(topic, args) {
- if (topics[topic]) {
- var currentTopic = topics[topic],
- args = args || {};
-
- for (var i = 0, j = currentTopic.length; i < j; i++) {
- currentTopic[i].call($, args);
- }
- }
- };
- $.subscribe = function(topic, callback) {
- if (!topics[topic]) {
- topics[topic] = [];
- }
- topics[topic].push(callback);
- return {
- "topic": topic,
- "callback": callback
- };
- };
- $.unsubscribe = function(handle) {
- var topic = handle.topic;
- if (topics[topic]) {
- var currentTopic = topics[topic];
-
- for (var i = 0, j = currentTopic.length; i < j; i++) {
- if (currentTopic[i] === handle.callback) {
- currentTopic.splice(i, 1);
- }
- }
- }
- };
-
- // This is the part where jSignature is initialized.
- var $sigdiv = $("#signature").jSignature({'UndoButton':true})
-
- // All the code below is just code driving the demo.
- , $tools = $('#tools')
- , pubsubprefix = 'jSignature.demo.'
-
- $('<input type="button" value="生成">').bind('click', function(e){
- var data = $sigdiv.jSignature('getData', 'default')
- $("#myImg").attr("src",data);
- console.log(data)
- }).appendTo($tools)
-
- $('<input type="button" value="Reset">').bind('click', function(e){
- $sigdiv.jSignature('reset')
- }).appendTo($tools)
-
- })(jQuery);
- </script>
- </body>
- </html>
|