From a6ecbeddaedafd148ac470c6954b0831ecbe601c Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Thu, 6 Mar 2014 15:21:53 +0000 Subject: [PATCH] Added definitions for JQuery plugin jSignature Definitions for jSignature jQuery plugin including tests for definitionss. Included are some documentation on the typed definition functions making use of JDocs TypeScript support. Updated the readme to include the new Typed Definition. Included empty tscparams files to be consistent with other definitions in the project. --- README.md | 1 + jquery.jsignature/jquery.jsignature-tests.ts | 19 ++++++++ .../jquery.jsignature-tests.ts.tscparams | 1 + jquery.jsignature/jquery.jsignature.d.ts | 46 +++++++++++++++++++ .../jquery.jsignature.d.ts.tscparams | 1 + 5 files changed, 68 insertions(+) create mode 100644 jquery.jsignature/jquery.jsignature-tests.ts create mode 100644 jquery.jsignature/jquery.jsignature-tests.ts.tscparams create mode 100644 jquery.jsignature/jquery.jsignature.d.ts create mode 100644 jquery.jsignature/jquery.jsignature.d.ts.tscparams diff --git a/README.md b/README.md index 29c94b8042..a58b651861 100755 --- a/README.md +++ b/README.md @@ -144,6 +144,7 @@ List of Definitions * [jQuery.gridster](http://gridster.net) (by [Josh Baldwin](https://github.com/jbaldwin/gridster.d.ts)) * [jQuery.jNotify](http://jnotify.codeplex.com) (by [James Curran](https://github.com/jamescurran/)) * [jQuery.joyride](http://zurb.com/playground/jquery-joyride-feature-tour-plugin) (by [Vincent Bortone](https://github.com/vbortone)) +* [jQuery.jSignature] (https://github.com/willowsystems/jSignature) (by [Patrick Magee](https://github.com/pjmagee)) * [jQuery.noty](http://needim.github.io/noty/) (by [Aaron King](https://github.com/kingdango/)) * [jQuery.pickadate](https://github.com/amsul/pickadate.js) (by [Theodore Brown](https://github.com/theodorejb)) * [jQuery.payment](http://needim.github.io/noty/) (by [Eric J. Smith](https://github.com/ejsmith/)) diff --git a/jquery.jsignature/jquery.jsignature-tests.ts b/jquery.jsignature/jquery.jsignature-tests.ts new file mode 100644 index 0000000000..b7e9631a50 --- /dev/null +++ b/jquery.jsignature/jquery.jsignature-tests.ts @@ -0,0 +1,19 @@ +/// +/// + +/* + * Taken from the tests section on jSignature + */ +$(document).ready(function () { + + var $sigdiv = $('#signature'); + + $sigdiv.jSignature(); + + $sigdiv.jSignature("reset"); + + var data = $sigdiv.jSignature("getData", "svgbase64"); + + $sigdiv.jSignature("setData", "data:" + data); + +}); \ No newline at end of file diff --git a/jquery.jsignature/jquery.jsignature-tests.ts.tscparams b/jquery.jsignature/jquery.jsignature-tests.ts.tscparams new file mode 100644 index 0000000000..e16c76dff8 --- /dev/null +++ b/jquery.jsignature/jquery.jsignature-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.jsignature/jquery.jsignature.d.ts b/jquery.jsignature/jquery.jsignature.d.ts new file mode 100644 index 0000000000..f4ffa498b9 --- /dev/null +++ b/jquery.jsignature/jquery.jsignature.d.ts @@ -0,0 +1,46 @@ +// Type definitions for jQuery.jsignature v2 +// Project: https://github.com/willowsystems/jSignature +// Definitions by: Patrick Magee +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Project by: Willow Systems Corp + +/// + +interface JQuery { + + /** + * inits the jSignature widget + */ + jSignature(): JQuery; + + /** + * Arguments vary per command. When provided, command is expected to be a string with a command for jSignature. Commands supported at this time: init, reset, getData, setData, listPlugins + * @summary + * init is the default, assumed action. init takes one argument - a settings Object. You can omit the command and just pass the settings object in upon init. Returns (in a traditional jQuery chainable way) jQuery object ref to the element onto which the plugin was applied. + * clear (also aliased as reset) clears the signature pad, data store (and puts back signature line and other decor). Returns (in a traditional jQuery chainable way) jQuery object ref to the element onto which the plugin was applied. + * getData takes an argument - the name of the data format. Returns a data object appropriate for the data format. + * setData (also aliased as importData) takes two arguments - data object, (optional) data format name. When data object is a string formatted in data-url pattern you don't need to specify the data dormat name. The data format name (mime) will be implied from the data-url prefix. Returns (in a traditional jQuery chainable way) jQuery object ref to the element onto which the plugin was applied. + * listPlugins takes an argument - a string denoting the category (Only export, import supported at this time) of plugins to list. Returns an array of strings. + * + * @param command the command used to perform an action on the jSignature canvas + * @see http://willowsystems.github.io/jSignature/#/about/ + * + */ + jSignature(command: string): any; + + /** + * Arguments vary per command. When provided, command is expected to be a string with a command for jSignature. Commands supported at this time: init, reset, getData, setData, listPlugins + * @summary + * init is the default, assumed action. init takes one argument - a settings Object. You can omit the command and just pass the settings object in upon init. Returns (in a traditional jQuery chainable way) jQuery object ref to the element onto which the plugin was applied. + * clear (also aliased as reset) clears the signature pad, data store (and puts back signature line and other decor). Returns (in a traditional jQuery chainable way) jQuery object ref to the element onto which the plugin was applied. + * getData takes an argument - the name of the data format. Returns a data object appropriate for the data format. + * setData (also aliased as importData) takes two arguments - data object, (optional) data format name. When data object is a string formatted in data-url pattern you don't need to specify the data dormat name. The data format name (mime) will be implied from the data-url prefix. Returns (in a traditional jQuery chainable way) jQuery object ref to the element onto which the plugin was applied. + * listPlugins takes an argument - a string denoting the category (Only export, import supported at this time) of plugins to list. Returns an array of strings. + * + * @param command the command used to perform an action on the jSignature canvas + * @param arg the argument used with the specified command + * @see http://willowsystems.github.io/jSignature/#/about/ + * + */ + jSignature(command: string, ...arg: string[]): any; +} diff --git a/jquery.jsignature/jquery.jsignature.d.ts.tscparams b/jquery.jsignature/jquery.jsignature.d.ts.tscparams new file mode 100644 index 0000000000..e16c76dff8 --- /dev/null +++ b/jquery.jsignature/jquery.jsignature.d.ts.tscparams @@ -0,0 +1 @@ +""