Book Image

Mastering jQuery

By : Alex Libby
Book Image

Mastering jQuery

By: Alex Libby

Overview of this book

<p>Mastering jQuery has been written not only to help maximize your skills with core functionality in the library, but also to explore some of the more intriguing ways of using the library to achieve real-world solutions that could feature on any website or online environment.</p> <p>You'll start with a look at some of the more advanced ways to incorporate the library into your pages, followed by working with forms and advanced form validation using regular expressions. Next you'll move on to animating in jQuery, advanced event handling, and using jQuery effects.</p> <p>Finally, you will develop practical examples of using jQuery with external functionality such as node-webkit, before finishing with a session on optimizing your version of the library for maximum efficiency and exploring best practices for using QUnit.</p>
Table of Contents (21 chapters)
Mastering jQuery
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a signature pad and exporting the image


Now that we've seen how we can manipulate images, let's turn our attention to something more fundamental; capturing images drawn on canvas elements.

As we move more and more into a digital world, there will be occasions when we are asked to "sign" a document electronically, using our computer. It does mean that we shouldn't consider signing anything the morning after a heavy night out, but worse things can happen…! That in mind, let's take a look at how we can capture the image, once the document has been signed.

For this demo, we're going to use the Signature Pad plugin for jQuery, by Thomas Bradley. The plugin is available from http://thomasjbradley.ca/lab/signature-pad. We're going to take it a step further – instead of just signing our name, we will provide an option to save the output as a PNG file, using the canvas.toDataURL() method.

Note

Remember – if you use Chrome, please run this demo from within a local web server, as suggested in...