From cfd36d55eaa8089d61a6362ec68b2f390d91a33e Mon Sep 17 00:00:00 2001 From: Roy Goode Date: Tue, 27 Nov 2012 20:50:33 +0000 Subject: [PATCH] Added jQuery.Cookie definitions and tests --- README.md | 129 ++++++++++++++------------- jquery.cookie/jquery.cookie-tests.ts | 37 ++++++++ jquery.cookie/jquery.cookie.d.ts | 31 +++++++ 3 files changed, 133 insertions(+), 64 deletions(-) create mode 100644 jquery.cookie/jquery.cookie-tests.ts create mode 100644 jquery.cookie/jquery.cookie.d.ts diff --git a/README.md b/README.md index 9a3e540502..faaaa06c7b 100644 --- a/README.md +++ b/README.md @@ -1,65 +1,66 @@ -DefinitelyTyped -=============== - -TypeScript type definitions repository for popular JavaScript libraries. - -The project aims to provide *high quality* definitions for the most popular libraries out there. - -Complete --------- -* [AngularJS](http://angularjs.org) (by [Diego Vilar](https://github.com/diegovilar)) ([wiki](https://github.com/borisyankov/DefinitelyTyped/wiki/AngularJS-Definitions-Usage-Notes)) -* [async](https://github.com/caolan/async) (by [Boris Yankov](https://github.com/borisyankov)) -* [Backbone.js](http://backbonejs.org/) (by [Boris Yankov](https://github.com/borisyankov)) -* [Bootstrap](http://twitter.github.com/bootstrap/) (by [Boris Yankov](https://github.com/borisyankov)) -* [bootstrap.datepicker](https://github.com/eternicode/bootstrap-datepicker) (by [Boris Yankov](https://github.com/borisyankov)) -* [Breeze](http://www.breezejs.com/) (by [Boris Yankov](https://github.com/borisyankov)) -* [CodeMirror](http://codemirror.net) (by [François de Campredon](https://github.com/fdecampredon)) -* [Chosen](http://harvesthq.github.com/chosen/) (by [Boris Yankov](https://github.com/borisyankov)) -* [dynatree](http://code.google.com/p/dynatree/) (by [François de Campredon](https://github.com/fdecampredon)) -* [d3.js](http://d3js.org/) (from TypeScript samples) -* [EaselJS](http://www.createjs.com/#!/EaselJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) -* [ember.js](http://emberjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) -* [Express](http://expressjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) -* [Fancybox](http://fancybox.net/) (by [Boris Yankov](https://github.com/borisyankov)) -* [Foundation](http://foundation.zurb.com/) (by [Boris Yankov](https://github.com/borisyankov)) -* [GoogleMaps](https://developers.google.com/maps/) (by [Esben Nepper](https://github.com/eNepper)) -* [Handlebars](http://handlebarsjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) -* [Highcharts]http://www.highcharts.com/) (by [damianog](https://github.com/damianog)) -* [History.js](https://github.com/balupton/History.js/) (by [Boris Yankov](https://github.com/borisyankov)) -* [Humane.js](http://wavded.github.com/humane-js/) (by [John Vrbanac](https://github.com/jmvrbanac)) -* [Impress.js](https://github.com/bartaz/impress.js) (by [Boris Yankov](https://github.com/borisyankov)) -* [Jasmine](http://pivotal.github.com/jasmine/) (by [Boris Yankov](https://github.com/borisyankov)) -* [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.BBQ](http://benalman.com/projects/jquery-bbq-plugin/) (by [Adam R. Smith](https://github.com/sunetos)) -* [jQuery.Globalize](https://github.com/jquery/globalize) (by [Boris Yankov](https://github.com/borisyankov)) -* [jQuery.Validation](http://bassistance.de/jquery-plugins/jquery-plugin-validation/) (by [Boris Yankov](https://github.com/borisyankov)) -* [Knockback](http://kmalakoff.github.com/knockback/) (by [Marcel Binot](https://github.com/docgit)) -* [Knockout.js](http://knockoutjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) -* [Knockout.Mapping](https://github.com/SteveSanderson/knockout.mapping) (by [Boris Yankov](https://github.com/borisyankov)) -* [linq.js](http://linqjs.codeplex.com/) (by [Marcin Najder](https://github.com/marcinnajder)) -* [Modernizr](http://modernizr.com/) (by [Boris Yankov](https://github.com/borisyankov)) -* [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield)) -* [Mustache.js](https://github.com/janl/mustache.js) (by [Boris Yankov](https://github.com/borisyankov)) -* [Node.js](http://nodejs.org/) (from TypeScript samples) -* [node_redis](https://github.com/mranney/node_redis) (by [Boris Yankov](https://github.com/borisyankov)) -* [node-sqlserver](https://github.com/WindowsAzure/node-sqlserver) (by [Boris Yankov](https://github.com/borisyankov)) -* [PhoneGap](http://phonegap.com) (by [Boris Yankov](https://github.com/borisyankov)) -* [PreloadJS](http://www.createjs.com/#!/PreloadJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) -* [QUnit](http://qunitjs.com/) (by [Diullei Gomes](https://github.com/Diullei)) -* [Raphael](http://raphaeljs.com/) (by [CheCoxshall](https://github.com/CheCoxshall)) -* [require.js](http://requirejs.org/) (by [Josh Baldwin](https://github.com/jbaldwin/)) -* [Sammy.js](http://sammyjs.org/) (by [Boris Yankov](https://github.com/borisyankov)) -* [Select2](http://ivaynberg.github.com/select2/) (by [Boris Yankov](https://github.com/borisyankov)) -* [SignalR](http://www.asp.net/signalr) (by [Boris Yankov](https://github.com/borisyankov)) -* [SoundJS](http://www.createjs.com/#!/SoundJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) -* [Spin](http://fgnass.github.com/spin.js/) (by [Boris Yankov](https://github.com/borisyankov)) -* [Sugar](http://sugarjs.com/) (by [Josh Baldwin](https://github.com/jbaldwin/)) -* [Teechart](http://www.steema.com) (by [Steema](http://www.steema.com)) -* [Toastr](https://github.com/CodeSeven/toastr) (by [Boris Yankov](https://github.com/borisyankov)) -* [TweenJS](http://www.createjs.com/#!/TweenJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) -* [tween.js](https://github.com/sole/tween.js/) (by [Adam R. Smith](https://github.com/sunetos)) -* [Ubuntu Unity Web API](https://launchpad.net/libunity-webapps) (by [John Vrbanac](https://github.com/jmvrbanac)) -* [Underscore.js](http://underscorejs.org/) (by [Boris Yankov](https://github.com/borisyankov)) +DefinitelyTyped +=============== + +TypeScript type definitions repository for popular JavaScript libraries. + +The project aims to provide *high quality* definitions for the most popular libraries out there. + +Complete +-------- +* [AngularJS](http://angularjs.org) (by [Diego Vilar](https://github.com/diegovilar)) ([wiki](https://github.com/borisyankov/DefinitelyTyped/wiki/AngularJS-Definitions-Usage-Notes)) +* [async](https://github.com/caolan/async) (by [Boris Yankov](https://github.com/borisyankov)) +* [Backbone.js](http://backbonejs.org/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Bootstrap](http://twitter.github.com/bootstrap/) (by [Boris Yankov](https://github.com/borisyankov)) +* [bootstrap.datepicker](https://github.com/eternicode/bootstrap-datepicker) (by [Boris Yankov](https://github.com/borisyankov)) +* [Breeze](http://www.breezejs.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [CodeMirror](http://codemirror.net) (by [François de Campredon](https://github.com/fdecampredon)) +* [Chosen](http://harvesthq.github.com/chosen/) (by [Boris Yankov](https://github.com/borisyankov)) +* [dynatree](http://code.google.com/p/dynatree/) (by [François de Campredon](https://github.com/fdecampredon)) +* [d3.js](http://d3js.org/) (from TypeScript samples) +* [EaselJS](http://www.createjs.com/#!/EaselJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) +* [ember.js](http://emberjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Express](http://expressjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Fancybox](http://fancybox.net/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Foundation](http://foundation.zurb.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [GoogleMaps](https://developers.google.com/maps/) (by [Esben Nepper](https://github.com/eNepper)) +* [Handlebars](http://handlebarsjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Highcharts]http://www.highcharts.com/) (by [damianog](https://github.com/damianog)) +* [History.js](https://github.com/balupton/History.js/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Humane.js](http://wavded.github.com/humane-js/) (by [John Vrbanac](https://github.com/jmvrbanac)) +* [Impress.js](https://github.com/bartaz/impress.js) (by [Boris Yankov](https://github.com/borisyankov)) +* [Jasmine](http://pivotal.github.com/jasmine/) (by [Boris Yankov](https://github.com/borisyankov)) +* [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.BBQ](http://benalman.com/projects/jquery-bbq-plugin/) (by [Adam R. Smith](https://github.com/sunetos)) +* [jQuery.Cookie](https://github.com/carhartl/jquery-cookie) (by [Roy Goode](https://github.com/RoyGoode)) +* [jQuery.Globalize](https://github.com/jquery/globalize) (by [Boris Yankov](https://github.com/borisyankov)) +* [jQuery.Validation](http://bassistance.de/jquery-plugins/jquery-plugin-validation/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Knockback](http://kmalakoff.github.com/knockback/) (by [Marcel Binot](https://github.com/docgit)) +* [Knockout.js](http://knockoutjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Knockout.Mapping](https://github.com/SteveSanderson/knockout.mapping) (by [Boris Yankov](https://github.com/borisyankov)) +* [linq.js](http://linqjs.codeplex.com/) (by [Marcin Najder](https://github.com/marcinnajder)) +* [Modernizr](http://modernizr.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield)) +* [Mustache.js](https://github.com/janl/mustache.js) (by [Boris Yankov](https://github.com/borisyankov)) +* [Node.js](http://nodejs.org/) (from TypeScript samples) +* [node_redis](https://github.com/mranney/node_redis) (by [Boris Yankov](https://github.com/borisyankov)) +* [node-sqlserver](https://github.com/WindowsAzure/node-sqlserver) (by [Boris Yankov](https://github.com/borisyankov)) +* [PhoneGap](http://phonegap.com) (by [Boris Yankov](https://github.com/borisyankov)) +* [PreloadJS](http://www.createjs.com/#!/PreloadJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) +* [QUnit](http://qunitjs.com/) (by [Diullei Gomes](https://github.com/Diullei)) +* [Raphael](http://raphaeljs.com/) (by [CheCoxshall](https://github.com/CheCoxshall)) +* [require.js](http://requirejs.org/) (by [Josh Baldwin](https://github.com/jbaldwin/)) +* [Sammy.js](http://sammyjs.org/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Select2](http://ivaynberg.github.com/select2/) (by [Boris Yankov](https://github.com/borisyankov)) +* [SignalR](http://www.asp.net/signalr) (by [Boris Yankov](https://github.com/borisyankov)) +* [SoundJS](http://www.createjs.com/#!/SoundJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) +* [Spin](http://fgnass.github.com/spin.js/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Sugar](http://sugarjs.com/) (by [Josh Baldwin](https://github.com/jbaldwin/)) +* [Teechart](http://www.steema.com) (by [Steema](http://www.steema.com)) +* [Toastr](https://github.com/CodeSeven/toastr) (by [Boris Yankov](https://github.com/borisyankov)) +* [TweenJS](http://www.createjs.com/#!/TweenJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) +* [tween.js](https://github.com/sole/tween.js/) (by [Adam R. Smith](https://github.com/sunetos)) +* [Ubuntu Unity Web API](https://launchpad.net/libunity-webapps) (by [John Vrbanac](https://github.com/jmvrbanac)) +* [Underscore.js](http://underscorejs.org/) (by [Boris Yankov](https://github.com/borisyankov)) * [Underscore.js (Typed)](http://underscorejs.org/) (by [Josh Baldwin](https://github.com/jbaldwin/)) \ No newline at end of file diff --git a/jquery.cookie/jquery.cookie-tests.ts b/jquery.cookie/jquery.cookie-tests.ts new file mode 100644 index 0000000000..cf7f4e63f8 --- /dev/null +++ b/jquery.cookie/jquery.cookie-tests.ts @@ -0,0 +1,37 @@ +/// +/// + +class TestObject { + text: string; + value: number; + + constructor (text: string, value: number) { + this.text = text; + this.value = value; + } +} + +class CookieOptions implements JQueryCookieOptions { + expires: number; + path: string; + domain: string; + secure: bool; +} + +$.cookie("the_cookie", "the_value"); + +console.log($.cookie("the_cookie")); + +var testObject = new TestObject("Hello World", 5); + +var cookieOptions = new CookieOptions(); +cookieOptions.path = "/"; +cookieOptions.domain = "jquery.com"; + +$.cookie.json = true; + +$.cookie("test", testObject, cookieOptions); + +var result = $.cookie("test"); + +console.log(result.text); diff --git a/jquery.cookie/jquery.cookie.d.ts b/jquery.cookie/jquery.cookie.d.ts new file mode 100644 index 0000000000..820a217c32 --- /dev/null +++ b/jquery.cookie/jquery.cookie.d.ts @@ -0,0 +1,31 @@ +// Type definitions for jQuery Cookie Plugin 1.3 +// Project: https://github.com/carhartl/jquery-cookie +// Definitions by: Roy Goode +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface JQueryCookieOptions { + expires?: number; + path?: string; + domain?: string; + secure?: bool; +} + +interface JQueryCookieStatic { + raw?: bool; + json?: bool; + + (name: string): any; + (name: string, value: string): void; + (name: string, value: string, options: JQueryCookieOptions): void; + (name: string, value: any): void; + (name: string, value: any, options: JQueryCookieOptions): void; +} + +interface JQueryStatic { + cookie?: JQueryCookieStatic; + + removeCookie(name: string): bool; + removeCookie(name: string, options: JQueryCookieOptions): bool; +} \ No newline at end of file