From b50af00be53d4b886638218ee703164088206d32 Mon Sep 17 00:00:00 2001 From: zaneli Date: Mon, 23 Jun 2014 11:07:10 +0900 Subject: [PATCH 1/7] Add definitions for jQuery Notify bar --- CONTRIBUTORS.md | 1 + jquery.notifyBar/jquery.notifyBar-test.ts | 66 +++++++++++++++ jquery.notifyBar/jquery.notifyBar.d.ts | 99 +++++++++++++++++++++++ 3 files changed, 166 insertions(+) create mode 100644 jquery.notifyBar/jquery.notifyBar-test.ts create mode 100644 jquery.notifyBar/jquery.notifyBar.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 1d32f8c2f..c69f938bb 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -156,6 +156,7 @@ All definitions files include a header with the author and editors, so at some p * [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.notifyBar](http://www.whoop.ee/posts/2013-04-05-the-resurrection-of-jquery-notify-bar/) (by [Shunsuke Ohtani](https://github.com/zaneli)) * [jQuery.noty](http://needim.github.io/noty/) (by [Aaron King](https://github.com/kingdango/)) * [jQuery.payment](http://needim.github.io/noty/) (by [Eric J. Smith](https://github.com/ejsmith/)) * [jQuery.pickadate](https://github.com/amsul/pickadate.js) (by [Theodore Brown](https://github.com/theodorejb)) diff --git a/jquery.notifyBar/jquery.notifyBar-test.ts b/jquery.notifyBar/jquery.notifyBar-test.ts new file mode 100644 index 000000000..8338fc830 --- /dev/null +++ b/jquery.notifyBar/jquery.notifyBar-test.ts @@ -0,0 +1,66 @@ +/// + +$(function() { + $.notifyBar({ + html: "Autostart" + }); + + $("#common").click(function () { + $.notifyBar(); + }); + $("#error").click(function () { + $.notifyBar({ cssClass: "error", html: "Error occurred!" }); + }); + $("#success").click(function () { + $.notifyBar({ cssClass: "success", html: "Your data has been changed!" }); + }); + $("#warning").click(function() { + $.notifyBar({ cssClass: "warning", html: "Settings aren't changed!" }); + }) + $("#custom").click(function () { + $.notifyBar({ cssClass: "custom", html: "Your data has been changed!" }); + }); + $("#close").click(function () { + $.notifyBar({ html: "Click 'close' to hide notify bar", close: true, closeOnClick: false }); + }); + $("#position").click(function () { + $.notifyBar({ html: "At bottom", position: "bottom" }); + }); + + $("#events").click(function () { + $.notifyBar({ + html: "Test events", + onBeforeShow: function () { + $("#onBeforeShow").html("onBeforeShow - ok"); + }, + onShow: function () { + $("#onShow").html("onShow - ok"); + }, + onBeforeHide: function () { + $("#onBeforeHide").html("onBeforeHide - ok"); + }, + onHide: function () { + $("#onHide").html("onHide - ok"); + } + }); + }); + + $("#delay").click(function () { + $.notifyBar({ html: "delay 1000000", delay: 1000000 }); + }); + $("#speed-string").click(function () { + $.notifyBar({ html: "speed normal", animationSpeed: "normal" }); + }); + $("#speed-number").click(function () { + $.notifyBar({ html: "speed normal", animationSpeed: 500 }); + }); + $("#jqObject").click(function () { + $.notifyBar({ html: "set jqObject", jqObject: $("#jqObject") }); + }); + $("#closeText").click(function () { + $.notifyBar({ html: "set close text", closeText: "close" }); + }); + $("#closeOnOver").click(function () { + $.notifyBar({ html: "enable close on over", close: false, closeOnClick: false, closeOnOver: true }); + }); +}); diff --git a/jquery.notifyBar/jquery.notifyBar.d.ts b/jquery.notifyBar/jquery.notifyBar.d.ts new file mode 100644 index 000000000..b33c54337 --- /dev/null +++ b/jquery.notifyBar/jquery.notifyBar.d.ts @@ -0,0 +1,99 @@ +// Type definitions for jQuery Notify Bar 1.4 +// Project: http://www.whoop.ee/posts/2013-04-05-the-resurrection-of-jquery-notify-bar/ +// Definitions by: Shunsuke Ohtani +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module JQueryNotifyBar { + + interface NotifyBarOptions { + /** + * What text will be inside bar. Can be HTML or just text. + */ + html?: string; + + /** + * How long bar will be delayed, doesn't count animation time. + */ + delay?: number; + + /** + * Custom jQuery object for notify bar. + */ + jqObject?: JQuery; + + /** + * You can define own CSS class for Notify bar. There are too premade classes "error", "warning" and "success". + */ + cssClass?: string; + + /** + * If set to true close button will be displayed. + */ + close?: boolean; + + /** + * Sets the text to close button. + */ + closeText?: string; + + /** + * If enabled, user can hide notify bar just by click on it. + */ + closeOnClick?: boolean; + + /** + * If enabled, user can hide notify bar just by moving mouse cursor on it. + */ + closeOnOver?: boolean; + + /** + * Callback on before show. + */ + onBeforeShow?: () => any; + + /** + * Callback on show. + */ + onShow?: () => any; + + /** + * Callback on before hide. + */ + onBeforeHide?: () => any; + + /** + * Callback on hide. + */ + onHide?: () => any; + + /** + * Set the position of notify bar. Possible values are "top", "bottom". + */ + position?: string; + } + + interface NotifyBarOptionsForAnimationSpeedString extends NotifyBarOptions { + /** + * How long this bar will be slided up and down. Possible values are "slow", "default", "normal", "fast". + */ + animationSpeed?: string; + } + + interface NotifyBarOptionsForAnimationSpeedNumber extends NotifyBarOptions { + /** + * How long this bar will be slided up and down. + */ + animationSpeed?: number; + } +} + +interface JQueryStatic { + /** + * Show notify bar. + * + * @param notify bar options + */ + notifyBar(options?: JQueryNotifyBar.NotifyBarOptions): void; +} \ No newline at end of file From 6bf9011af7808aa2a6a74c0bf773f7565033d6a0 Mon Sep 17 00:00:00 2001 From: zaneli Date: Mon, 23 Jun 2014 11:31:49 +0900 Subject: [PATCH 2/7] fix param name in comment. --- jquery.notifyBar/jquery.notifyBar.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jquery.notifyBar/jquery.notifyBar.d.ts b/jquery.notifyBar/jquery.notifyBar.d.ts index b33c54337..22e012673 100644 --- a/jquery.notifyBar/jquery.notifyBar.d.ts +++ b/jquery.notifyBar/jquery.notifyBar.d.ts @@ -93,7 +93,7 @@ interface JQueryStatic { /** * Show notify bar. * - * @param notify bar options + * @param options notify bar options */ notifyBar(options?: JQueryNotifyBar.NotifyBarOptions): void; -} \ No newline at end of file +} From 1dd12f188e112d62d47e6ffb8c648a23d2a55a95 Mon Sep 17 00:00:00 2001 From: bolkhovsky Date: Mon, 23 Jun 2014 17:17:08 +0400 Subject: [PATCH 3/7] add KnockoutBindingAccessor interface to extend custom bindings API definition --- knockout/knockout.d.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index 9c4e02bd8..512a6a305 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -123,9 +123,14 @@ interface KnockoutBindingContext { createChildContext(dataItemOrAccessor: any, dataItemAlias?: any, extendCallback?: Function): any; } +interface KnockoutBindingAccessor { + get(name: string): any; + has(name: string): boolean; +} + interface KnockoutBindingHandler { - init?(element: any, valueAccessor: () => any, allBindingsAccessor: () => any, viewModel: any, bindingContext: KnockoutBindingContext): void; - update?(element: any, valueAccessor: () => any, allBindingsAccessor: () => any, viewModel: any, bindingContext: KnockoutBindingContext): void; + init? (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutBindingAccessor, viewModel: any, bindingContext: KnockoutBindingContext): void; + update? (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutBindingAccessor, viewModel: any, bindingContext: KnockoutBindingContext): void; options?: any; } From e7a6ee50c2b6a622841f6708ab9c36357159f44d Mon Sep 17 00:00:00 2001 From: bolkhovsky Date: Mon, 23 Jun 2014 17:47:43 +0400 Subject: [PATCH 4/7] fix definition to support dynamic binding property access --- knockout/knockout.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index 512a6a305..006b83361 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -124,6 +124,7 @@ interface KnockoutBindingContext { } interface KnockoutBindingAccessor { + (): any; get(name: string): any; has(name: string): boolean; } From 361ce9e2f34e4ea805553a41ec80b2d5d545d679 Mon Sep 17 00:00:00 2001 From: bolkhovsky Date: Tue, 24 Jun 2014 00:28:16 +0400 Subject: [PATCH 5/7] change interface name to historical (4 days earlier) version --- knockout/knockout.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index 006b83361..0c57d2ad9 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -123,15 +123,15 @@ interface KnockoutBindingContext { createChildContext(dataItemOrAccessor: any, dataItemAlias?: any, extendCallback?: Function): any; } -interface KnockoutBindingAccessor { +interface KnockoutAllBindingsAccessor { (): any; get(name: string): any; has(name: string): boolean; } interface KnockoutBindingHandler { - init? (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutBindingAccessor, viewModel: any, bindingContext: KnockoutBindingContext): void; - update? (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutBindingAccessor, viewModel: any, bindingContext: KnockoutBindingContext): void; + init? (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext): void; + update? (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext): void; options?: any; } From d1db936207c9b28d1bdff5a081d1f0ac1b94975b Mon Sep 17 00:00:00 2001 From: bolkhovsky Date: Tue, 24 Jun 2014 00:32:47 +0400 Subject: [PATCH 6/7] extend tests for KnockoutAllBindingsAccessor --- knockout/tests/knockout-tests.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/knockout/tests/knockout-tests.ts b/knockout/tests/knockout-tests.ts index da5d1e65a..6d4c9e25d 100644 --- a/knockout/tests/knockout-tests.ts +++ b/knockout/tests/knockout-tests.ts @@ -591,11 +591,15 @@ function test_allBindingsAccessor() { ko.bindingHandlers.allBindingsAccessorTest = { init: (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext) => { var allBindings = allBindingsAccessor(); + var hasBinding = allBindingsAccessor.has("myBindingName"); var myBinding = allBindingsAccessor.get("myBindingName"); + var fnAccessorBinding = allBindingsAccessor().myBindingName; }, update: (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext) => { var allBindings = allBindingsAccessor(); + var hasBinding = allBindingsAccessor.has("myBindingName"); var myBinding = allBindingsAccessor.get("myBindingName"); + var fnAccessorBinding = allBindingsAccessor().myBindingName; } }; } \ No newline at end of file From 2b55cf57dcccfc4952fb4aabea59954f193fea97 Mon Sep 17 00:00:00 2001 From: David Sichau Date: Thu, 26 Jun 2014 17:04:44 +0200 Subject: [PATCH 7/7] added a definition for knockout-amd-helpers --- CONTRIBUTORS.md | 1 + .../knockout-amd-helpers-tests.ts | 23 +++++++++++++ .../knockout-amd-helpers.d.ts | 34 +++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 knockout.amd.helpers/knockout-amd-helpers-tests.ts create mode 100644 knockout.amd.helpers/knockout-amd-helpers.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index ae430f57d..f34a8b244 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -193,6 +193,7 @@ All definitions files include a header with the author and editors, so at some p * [KineticJS](http://kineticjs.com/) (by [Basarat Ali Syed](https://github.com/basarat)) * [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.Amd.Helpers](https://github.com/rniemeyer/knockout-amd-helpers) (by [David Sichau](https://github.com/DavidSichau/)) * [Knockout.DeferredUpdates](https://github.com/mbest/knockout-deferred-updates) (by [Sebastián Galiano](https://github.com/sgaliano)) * [Knockout.ES5](https://github.com/SteveSanderson/knockout-es5) (by [Sebastián Galiano](https://github.com/sgaliano)) * [Knockout.Mapper](https://github.com/LucasLorentz/knockout.mapper) (by [Brandon Meyer](https://github.com/BMeyerKC)) diff --git a/knockout.amd.helpers/knockout-amd-helpers-tests.ts b/knockout.amd.helpers/knockout-amd-helpers-tests.ts new file mode 100644 index 000000000..c5d1b62e0 --- /dev/null +++ b/knockout.amd.helpers/knockout-amd-helpers-tests.ts @@ -0,0 +1,23 @@ +// Tests for knockout.projections.d.ts + +/// +/// + +//The baseDir is used in building the path to use in the require statement. If your modules live in the modules directory, then you can specify it globally here. +ko.bindingHandlers.module.baseDir = "blub"; + +//This allows the ability to globally override the function that the module binding calls after loading an AMD module that does not return a constructor. +ko.bindingHandlers.module.initializer= "initialize"; + +//The dispose method name can be globally overriden. This function is optionally called when a module is being removed/swapped. +ko.bindingHandlers.module.disposeMethod ="dispose"; + +//The templateProperty option can be globally set. If defined, when a module is loaded - if it has a property with the key specified here +// (where the value is a string or function), the value of that property will be used as the template for the module. The result is a fully +// self-contained module (i.e. it has its own template, not an external one). +ko.bindingHandlers.module.templateProperty ="test"; + + +ko.amdTemplateEngine.defaultPath = "your/path/to/templates"; +ko.amdTemplateEngine.defaultSuffix = ".template.html"; +ko.amdTemplateEngine.defaultRequireTextPluginName = "text"; \ No newline at end of file diff --git a/knockout.amd.helpers/knockout-amd-helpers.d.ts b/knockout.amd.helpers/knockout-amd-helpers.d.ts new file mode 100644 index 000000000..34d4eb027 --- /dev/null +++ b/knockout.amd.helpers/knockout-amd-helpers.d.ts @@ -0,0 +1,34 @@ +// Type definitions for knockout-amd-helpers +// Project: https://github.com/rniemeyer/knockout-amd-helpers +// Definitions by: David Sichau +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + + +interface KnockoutAMDModule { + baseDir: string; + initializer: string; + disposeMethod: string; + templateProperty: string; +} + +interface KnockoutAMDTemplate { + defaultPath: string; + defaultSuffix: string; + defaultRequireTextPluginName: string; +} + +interface KnockoutBindingHandlers { + module: KnockoutAMDModule; +} +interface KnockoutStatic { + + amdTemplateEngine: KnockoutAMDTemplate +} + +declare module "knockout-amd-helpers" { + export = ko; +} + +declare var ko: KnockoutStatic;