From 49444066cb93b944b5f60b18e8920285baadf622 Mon Sep 17 00:00:00 2001 From: Jon Egerton Date: Wed, 21 Aug 2013 23:40:47 +0100 Subject: [PATCH] Add typings for jQuery.areYouSure Add typings for jQuery.areYouSure dirty form monitoring plugin --- README.md | 3 +- .../jquery.are-you-sure-tests.ts | 18 +++++++++++ jquery.are-you-sure/jquery.are-you-sure.d.ts | 31 +++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 jquery.are-you-sure/jquery.are-you-sure-tests.ts create mode 100644 jquery.are-you-sure/jquery.are-you-sure.d.ts diff --git a/README.md b/README.md index 1127d0cec6..2b31248e48 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -DefinitelyTyped [![Build Status](https://travis-ci.org/borisyankov/DefinitelyTyped.png?branch=master)](https://travis-ci.org/borisyankov/DefinitelyTyped) +DefinitelyTyped [![Build Status](https://travis-ci.org/borisyankov/DefinitelyTyped.png?branch=master)](https://travis-ci.org/borisyankov/DefinitelyTyped) =============== The repository for *high quality* TypeScript type definitions. @@ -93,6 +93,7 @@ List of Definitions * [jQuery](http://jquery.com/) (from TypeScript samples) * [jQuery Mobile](http://jquerymobile.com) (by [Boris Yankov](https://github.com/borisyankov)) * [jQuery UI](http://jqueryui.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [jQuery.areYouSure](https://github.com/codedance/jquery.AreYouSure) (by [Jon Egerton](https://github.com/jonegerton)) * [jQuery.autosize](http://www.jacklmoore.com/autosize/) (by [Jack Moore](http://www.jacklmoore.com/)) * [jQuery.BBQ](http://benalman.com/projects/jquery-bbq-plugin/) (by [Adam R. Smith](https://github.com/sunetos)) * [jQuery.contextMenu](http://medialize.github.com/jQuery-contextMenu/) (by [Natan Vivo](https://github.com/nvivo/)) diff --git a/jquery.are-you-sure/jquery.are-you-sure-tests.ts b/jquery.are-you-sure/jquery.are-you-sure-tests.ts new file mode 100644 index 0000000000..6f8691e05d --- /dev/null +++ b/jquery.are-you-sure/jquery.are-you-sure-tests.ts @@ -0,0 +1,18 @@ +// Type definitions for jquery.are-you-sure.js +// Project: https://github.com/codedance/jquery.AreYouSure +// Definitions by: Jon Egerton +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +//Use defaults +$("test").areYouSure(); + +//Use all settings +$("test").areYouSure({ + message: "Oops - sure you wanna leave?", + dirtyClass: "soiled", + fieldSelector: "input[type='text']", + change: function () { alert("changed");} +}) \ No newline at end of file diff --git a/jquery.are-you-sure/jquery.are-you-sure.d.ts b/jquery.are-you-sure/jquery.are-you-sure.d.ts new file mode 100644 index 0000000000..62cc39c2c8 --- /dev/null +++ b/jquery.are-you-sure/jquery.are-you-sure.d.ts @@ -0,0 +1,31 @@ +// Type definitions for jquery.are-you-sure.js +// Project: https://github.com/codedance/jquery.AreYouSure +// Definitions by: Jon Egerton +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +/**Options available to control dirty form checking*/ +interface AreYouSureOptions { + + /**Message to show when attempting to quit a dirty form without saving*/ + message?: string; + + /**Class to assign to the form when dirty*/ + dirtyClass?: string; + + /**Callback when form is found to be dirty - allows control of submit/reset buttons etc*/ + change?: Function; + + /**Jquery selector to use to find input elements*/ + fieldSelector?: string; +} + +interface AreYouSure { + (): JQuery; + (options: AreYouSureOptions): JQuery; +} + +interface JQuery { + areYouSure: AreYouSure; +} \ No newline at end of file