From 2bc074c287a62e746e3e5b6f4e9da13b02c8f460 Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Wed, 9 Jan 2013 11:30:35 +0200 Subject: [PATCH 1/9] Update jQuery.Watermark, add tests --- ...termark.d.ts => jquery.watermark-3.1.d.ts} | 17 +++++++++-- jquery.watermark/jquery.watermark-tests.ts | 28 +++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) rename jquery.watermark/{jquery.watermark.d.ts => jquery.watermark-3.1.d.ts} (62%) create mode 100644 jquery.watermark/jquery.watermark-tests.ts diff --git a/jquery.watermark/jquery.watermark.d.ts b/jquery.watermark/jquery.watermark-3.1.d.ts similarity index 62% rename from jquery.watermark/jquery.watermark.d.ts rename to jquery.watermark/jquery.watermark-3.1.d.ts index 25b4e646a..f5b1dce6c 100644 --- a/jquery.watermark/jquery.watermark.d.ts +++ b/jquery.watermark/jquery.watermark-3.1.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Watermark plugin for jQuery 3.1.4 +// Type definitions for Watermark plugin for jQuery 3.1 // Project: http://jquery-watermark.googlecode.com // Definitions by: https://github.com/anwarjaved // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -6,14 +6,25 @@ /// - interface WatermarkOptions { className?: string; // Default class name for all watermarks useNative?: bool; // If true, plugin will detect and use native browser support for watermarks, if available. (e.g., WebKit's placeholder attribute.) hideBeforeUnload?: bool; // If true, all watermarks will be hidden during the window beforeunload event. } +interface Watermark { + options: WatermarkOptions; + + show(element: string): void; + hide(element: string): void; + showAll(): void; + hideAll(): void; +} interface JQuery { - watermark(text : string, options?: WatermarkOptions): JQuery; + watermark(text: string, options?: WatermarkOptions): JQuery; } + +interface JQueryStatic { + watermark: Watermark; +} \ No newline at end of file diff --git a/jquery.watermark/jquery.watermark-tests.ts b/jquery.watermark/jquery.watermark-tests.ts new file mode 100644 index 000000000..5ce787598 --- /dev/null +++ b/jquery.watermark/jquery.watermark-tests.ts @@ -0,0 +1,28 @@ +/// +/// + + +$('#inputId').watermark('Required information'); +$('#inputId').watermark('Required information', { className: 'myClassName' }); +$('#inputId').watermark('Search', { useNative: false }); + +$.watermark.options.className = 'myClass'; + +$.watermark.options.useNative = false; + +var myFunction; +$.watermark.options.useNative = myFunction; + +$.watermark.options.hideBeforeUnload = false; + +$.watermark.options = { + className: 'myClass', + useNative: false, + hideBeforeUnload: false +}; + +$.watermark.options.hideBeforeUnload = true; +$.watermark.show('input.optional'); +$.watermark.hide('#myInput'); +$.watermark.showAll(); +$.watermark.hideAll(); \ No newline at end of file From 06bbfd9a24057f51879869825545a13340c5c096 Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Wed, 9 Jan 2013 11:31:35 +0200 Subject: [PATCH 2/9] Update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b48c5939d..69cda3193 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ Complete * [jQuery.Globalize](https://github.com/jquery/globalize) (by [Boris Yankov](https://github.com/borisyankov)) * [jQuery.Transit](http://ricostacruz.com/jquery.transit/) (by [MrBigDog2U](https://github.com/MrBigDog2U)) * [jQuery.Validation](http://bassistance.de/jquery-plugins/jquery-plugin-validation/) (by [Boris Yankov](https://github.com/borisyankov)) +* [jQuery.Watermark](http://jquery-watermark.googlecode.com) (by [Anwar Javed](https://github.com/anwarjaved)) * [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)) From b91ddee3107bc25d9a11551c8edda707e3ffab8a Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Wed, 9 Jan 2013 12:11:44 +0200 Subject: [PATCH 3/9] Update jquery.timepicker definitions, add tests --- ...picker.d.ts => jquery.timepicker-0.3.d.ts} | 4 +- jquery.timepicker/jquery.timepicker-tests.ts | 45 +++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) rename jquery.timepicker/{jquery.timepicker.d.ts => jquery.timepicker-0.3.d.ts} (95%) create mode 100644 jquery.timepicker/jquery.timepicker-tests.ts diff --git a/jquery.timepicker/jquery.timepicker.d.ts b/jquery.timepicker/jquery.timepicker-0.3.d.ts similarity index 95% rename from jquery.timepicker/jquery.timepicker.d.ts rename to jquery.timepicker/jquery.timepicker-0.3.d.ts index 2c8e0bcde..26b837bb5 100644 --- a/jquery.timepicker/jquery.timepicker.d.ts +++ b/jquery.timepicker/jquery.timepicker-0.3.d.ts @@ -1,4 +1,4 @@ -// Type definitions for jQuery UI Timepicker 0.3.1 +// Type definitions for jQuery UI Timepicker 0.3 // Project: http://fgelinas.com/code/timepicker/ // Definitions by: https://github.com/anwarjaved // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -22,7 +22,7 @@ interface TimePickerOptions { // 'button' for trigger button, or 'both' for either (not yet implemented) button?: string; // 'button' element that will trigger the timepicker showAnim?: string; // Name of jQuery animation for popup - showOptions: any; // Options for enhanced animations + showOptions?: any; // Options for enhanced animations appendText?: string; // Display text following the input box, e.g. showing the format beforeShow: () => any; // Define a callback function executed before the timepicker is shown diff --git a/jquery.timepicker/jquery.timepicker-tests.ts b/jquery.timepicker/jquery.timepicker-tests.ts new file mode 100644 index 000000000..5a979fc26 --- /dev/null +++ b/jquery.timepicker/jquery.timepicker-tests.ts @@ -0,0 +1,45 @@ +/// +/// + +var beforeShowCallback, onSelectCallback, onCloseCallback, onHourShow, onMinuteShow; +$('#timepicker').timepicker({ + timeSeparator: ':', + showLeadingZero: true, + showMinutesLeadingZero: true, + showPeriod: false, + showPeriodLabels: true, + periodSeparator: ' ', + altField: '#alternate_input', + defaultTime: '12:34', + showOn: 'focus', + button: null, + hourText: 'Hour', + minuteText: 'Minute', + amPmText: ['AM', 'PM'], + + myPosition: 'left top', + atPosition: 'left bottom', + beforeShow: beforeShowCallback, + onSelect: onSelectCallback, + onClose: onCloseCallback, + onHourShow: onHourShow, + onMinuteShow: onMinuteShow, + hours: { + starts: 0, + ends: 23 + }, + minutes: { + starts: 0, + ends: 55, + interval: 5 + }, + rows: 4, + showHours: true, + showMinutes: true, + showCloseButton: false, + closeButtonText: 'Done', + showNowButton: false, + nowButtonText: 'Now', + showDeselectButton: false, + deselectButtonText: 'Deselect' +}); \ No newline at end of file From 0ce8660fecf48920defd04644a4634dd237c9717 Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Wed, 9 Jan 2013 12:12:38 +0200 Subject: [PATCH 4/9] Update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 69cda3193..235d5cc00 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ Complete * [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.Timepicker](http://fgelinas.com/code/timepicker/) (by [Anwar Javed](https://github.com/anwarjaved)) * [jQuery.Transit](http://ricostacruz.com/jquery.transit/) (by [MrBigDog2U](https://github.com/MrBigDog2U)) * [jQuery.Validation](http://bassistance.de/jquery-plugins/jquery-plugin-validation/) (by [Boris Yankov](https://github.com/borisyankov)) * [jQuery.Watermark](http://jquery-watermark.googlecode.com) (by [Anwar Javed](https://github.com/anwarjaved)) From ecec763914b5bb6714e502776bbe0c2bc3434092 Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Wed, 9 Jan 2013 13:29:39 +0200 Subject: [PATCH 5/9] Add State Machine definitions and tests --- README.md | 1 + state-machine/state-machine-2.2.d.ts | 49 ++++++++++++++++++++++++++++ state-machine/state-machine-tests.ts | 18 ++++++++++ 3 files changed, 68 insertions(+) create mode 100644 state-machine/state-machine-2.2.d.ts create mode 100644 state-machine/state-machine-tests.ts diff --git a/README.md b/README.md index 235d5cc00..d7beb91ea 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Complete * [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)) +* [Finite State Machine](https://github.com/jakesgordon/javascript-state-machine) (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)) diff --git a/state-machine/state-machine-2.2.d.ts b/state-machine/state-machine-2.2.d.ts new file mode 100644 index 000000000..a8682cdd5 --- /dev/null +++ b/state-machine/state-machine-2.2.d.ts @@ -0,0 +1,49 @@ +// Type definitions for Finite State Machine 2.2 +// Project: https://github.com/jakesgordon/javascript-state-machine +// Definitions by: Boris Yankov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +interface ErrorCallback { + (name: string, from: string, to: string, args: any[]): void; +} + +interface EventCallback { + event: string; + from: string; + to: string; + msg?: string; +} + +interface StateMachineEvent { + name: string; + from: string; + to: string; +} + +interface StateMachineConfig { + initial?: any; // string or { state: 'foo', event: 'setup', defer: true|false } + events?: StateMachineEvent[]; + callbacks?: any; + target?: any; + error?: ErrorCallback; +} + +interface StateMachineStatic { + create(config: StateMachineConfig, target?: any): StateMachine; +} + +interface StateMachine { + current: string; + is(sstate: string): bool; + can(event: StateMachineEvent): bool; + cannot(event: StateMachineEvent): bool; + error: ErrorCallback; + + onbeforeevent: EventCallback; + onleaveevent: EventCallback; + onenterevent: EventCallback; + onafterevent: EventCallback; +} + +declare var StateMachine: StateMachineStatic; \ No newline at end of file diff --git a/state-machine/state-machine-tests.ts b/state-machine/state-machine-tests.ts new file mode 100644 index 000000000..4ff9bdf93 --- /dev/null +++ b/state-machine/state-machine-tests.ts @@ -0,0 +1,18 @@ +/// + +var fsm = StateMachine.create({ + initial: 'green', + events: [ + { name: 'warn', from: 'green', to: 'yellow' }, + { name: 'panic', from: 'yellow', to: 'red' }, + { name: 'calm', from: 'red', to: 'yellow' }, + { name: 'clear', from: 'yellow', to: 'green' } + ], + callbacks: { + onpanic: function (event, from, to, msg) { alert('panic! ' + msg); }, + onclear: function (event, from, to, msg) { alert('thanks to ' + msg); }, + ongreen: function (event, from, to) { document.body.className = 'green'; }, + onyellow: function (event, from, to) { document.body.className = 'yellow'; }, + onred: function (event, from, to) { document.body.className = 'red'; }, + } +}); \ No newline at end of file From 343bbd832cb86335f7fe8aa14fc6ca078721f6e3 Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Thu, 10 Jan 2013 12:50:07 +0200 Subject: [PATCH 6/9] Add missing reference to knockout.mapping definitions --- knockout.mapping/knockout.mapping-2.0.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/knockout.mapping/knockout.mapping-2.0.d.ts b/knockout.mapping/knockout.mapping-2.0.d.ts index 0667b9cf0..6ff398e37 100644 --- a/knockout.mapping/knockout.mapping-2.0.d.ts +++ b/knockout.mapping/knockout.mapping-2.0.d.ts @@ -3,6 +3,8 @@ // Definitions by: Boris Yankov // Definitions https://github.com/borisyankov/DefinitelyTyped +/// + interface KnockoutMappingCreateOptions { data: any; parent: any; From 9d34e3867d4b9ad24e9a3c2bab10279a0072da57 Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Thu, 10 Jan 2013 12:51:40 +0200 Subject: [PATCH 7/9] Fix jquery.timepicker, some options to optional --- jquery.timepicker/jquery.timepicker-0.3.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/jquery.timepicker/jquery.timepicker-0.3.d.ts b/jquery.timepicker/jquery.timepicker-0.3.d.ts index 26b837bb5..a939c9425 100644 --- a/jquery.timepicker/jquery.timepicker-0.3.d.ts +++ b/jquery.timepicker/jquery.timepicker-0.3.d.ts @@ -25,9 +25,9 @@ interface TimePickerOptions { showOptions?: any; // Options for enhanced animations appendText?: string; // Display text following the input box, e.g. showing the format - beforeShow: () => any; // Define a callback function executed before the timepicker is shown - onSelect: () => any; // Define a callback function when a hour / minutes is selected - onClose: () => any; // Define a callback function when the timepicker is closed + beforeShow?: () => any; // Define a callback function executed before the timepicker is shown + onSelect?: () => any; // Define a callback function when a hour / minutes is selected + onClose?: () => any; // Define a callback function when the timepicker is closed timeSeparator?: string; // The character to use to separate hours and minutes. periodSeparator?: string; // The character to use to separate the time from the time period. @@ -43,8 +43,8 @@ interface TimePickerOptions { atPosition?: string; // Position of the input element to match // Note : if the position utility is not loaded, the timepicker will attach left top to left bottom //NEW: 2011-02-03 - onHourShow: () => any; // callback for enabling / disabling on selectable hours ex : function(hour) { return true; } - onMinuteShow: () => any; // callback for enabling / disabling on time selection ex : function(hour,minute) { return true; } + onHourShow?: () => any; // callback for enabling / disabling on selectable hours ex : function(hour) { return true; } + onMinuteShow?: () => any; // callback for enabling / disabling on time selection ex : function(hour,minute) { return true; } hours?: TimePickerHour; minutes?: TimePickerMinutes; From 12b31edb576c0d6d9cf19b54b747a84bf829c783 Mon Sep 17 00:00:00 2001 From: Oisin Grehan Date: Thu, 10 Jan 2013 11:04:03 -0500 Subject: [PATCH 8/9] definitions for knockout.editables 1.1.3 and knockout.viewmodel 0.9 --- knockout.editables/ko.editables-0.9.d.ts | 30 +++++++++++++++++++ .../knockout.viewmodel-1.1.d.ts | 19 ++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 knockout.editables/ko.editables-0.9.d.ts create mode 100644 knockout.viewmodel/knockout.viewmodel-1.1.d.ts diff --git a/knockout.editables/ko.editables-0.9.d.ts b/knockout.editables/ko.editables-0.9.d.ts new file mode 100644 index 000000000..0579ee146 --- /dev/null +++ b/knockout.editables/ko.editables-0.9.d.ts @@ -0,0 +1,30 @@ +/// + +// build: ko.editables 0.9 +// http://romanych.github.com/ko.editables/ + +// bestowed by ko.editable(target) +interface KnockoutEditable { + addEditable(target: any): any; + beginEdit(): void; + commit(): void; + rollback(): void; + hasChanges(): bool; +} + +interface KnockoutEditableStatic { + (viewModel: any, autoInit?: bool): void; + beginEdit(scope: string): void; + commit(scope: string): void; + rollback(scope: string): void; + hasChanges(scope: string): bool; + + // INTERNAL + //getHasChangesFlag(scope: string): any; + //enable(object: any, scope: string); void; +} + +// extend ko global +interface KnockoutStatic { + editable: KnockoutEditableStatic; +} \ No newline at end of file diff --git a/knockout.viewmodel/knockout.viewmodel-1.1.d.ts b/knockout.viewmodel/knockout.viewmodel-1.1.d.ts new file mode 100644 index 000000000..eece83f90 --- /dev/null +++ b/knockout.viewmodel/knockout.viewmodel-1.1.d.ts @@ -0,0 +1,19 @@ +/// + +// build: knockout.viewmodel 1.1.3 +// http://coderenaissance.github.com/knockout.viewmodel/ + +interface KnockoutViewModelStatic { + toModel(viewmodel: any): any; + fromModel(model: any, options?: any): any; + updateFromModel(viewmodel: any, model: any); + + // INTERNAL flag: enable logging of conversions + // logs will be written to console + logging: bool; +} + +// Extend ko global +interface KnockoutStatic { + viewmodel: KnockoutViewModelStatic; +} \ No newline at end of file From 16018df9030c672a01fc91207abf8b7d5727fbcb Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Jan 2013 10:40:33 -0800 Subject: [PATCH 9/9] New API calls and fixes to parameter types --- pouchDB/pouch-0.1.d.ts | 21 ++++++++++++++------- pouchDB/pouch-tests.ts | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/pouchDB/pouch-0.1.d.ts b/pouchDB/pouch-0.1.d.ts index da380db7a..0fa6a1eb2 100644 --- a/pouchDB/pouch-0.1.d.ts +++ b/pouchDB/pouch-0.1.d.ts @@ -10,7 +10,9 @@ interface PouchError { } interface PouchApi { + type(): string; id(): string; + close(callback: () => void): void; } interface PouchInfoResponse { @@ -49,6 +51,7 @@ interface PouchAllDocsItem { id: string; key: string; value: any; + doc: any; } interface PouchAllDocsResponse { @@ -66,8 +69,12 @@ interface PouchApi { allDocs(callback: (err: PouchError, res: PouchAllDocsResponse) => void): void; } +interface PouchBulkDocsRequest { + docs: any[]; +} + interface PouchUpdateOptions { - new_edits: bool; + new_edits?: bool; } interface PouchUpdateResponse { @@ -77,8 +84,8 @@ interface PouchUpdateResponse { } interface PouchApi { - bulkDocs(req, opts: PouchUpdateOptions, callback: (err: PouchError, res: PouchUpdateResponse[]) => void): void; - bulkDocs(req, callback: (err: PouchError, res: PouchUpdateResponse[]) => void): void; + bulkDocs(req: PouchBulkDocsRequest, opts: PouchUpdateOptions, callback: (err: PouchError, res: PouchUpdateResponse[]) => void): void; + bulkDocs(req: PouchBulkDocsRequest, callback: (err: PouchError, res: PouchUpdateResponse[]) => void): void; // // post == insert (doc does not contain an _id) // @@ -87,13 +94,13 @@ interface PouchApi { // // put == update (doc DOES contain an _id) // - put(doc, opts: PouchUpdateOptions, callback: (err: PouchError, res: PouchUpdateResponse) => void): void; - put(doc, callback: (err: PouchError, res: PouchUpdateResponse) => void): void; + put(doc: any, opts: PouchUpdateOptions, callback: (err: PouchError, res: PouchUpdateResponse) => void): void; + put(doc: any, callback: (err: PouchError, res: PouchUpdateResponse) => void): void; // // remove == delete // - remove(doc, opts: PouchUpdateOptions, callback: (err: PouchError, res: PouchUpdateResponse) => void): void; - remove(doc, callback: (err: PouchError, res: PouchUpdateResponse) => void): void; + remove(doc: any, opts: PouchUpdateOptions, callback: (err: PouchError, res: PouchUpdateResponse) => void): void; + remove(doc: any, callback: (err: PouchError, res: PouchUpdateResponse) => void): void; } interface PouchFilter { diff --git a/pouchDB/pouch-tests.ts b/pouchDB/pouch-tests.ts index e5dc7bbe6..4d67520de 100644 --- a/pouchDB/pouch-tests.ts +++ b/pouchDB/pouch-tests.ts @@ -1,4 +1,4 @@ -/// +/// declare var $: any;