From 586de634a88bf01828fc36fcf5d4c7a445701de9 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 18 Feb 2014 16:52:02 +0000 Subject: [PATCH 1/4] jQuery: JSDoc'd bind --- jquery/jquery-tests.ts | 2 +- jquery/jquery.d.ts | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 57ba838ee..7177b1333 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -568,7 +568,7 @@ function test_bind() { $("form").bind("submit", function (event) { event.stopPropagation(); }); - $("p").bind("myCustomEvent", function (e, myName, myValue) { + $("p").bind("myCustomEvent", function (e, myName?, myValue?) { $(this).text(myName + ", hi there!"); $("span").stop().css("opacity", 1) .text("myName = " + myName) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 235022bf9..87f3a9afd 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -2028,12 +2028,42 @@ interface JQuery { */ toggle(showOrHide: boolean): JQuery; - // Events + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ bind(eventType: string, eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param handler A function to execute each time the event is triggered. + */ bind(eventType: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param eventData An object containing data that will be passed to the event handler. + * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true. + */ bind(eventType: string, eventData: any, preventBubble: boolean): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true. + */ bind(eventType: string, preventBubble: boolean): JQuery; - bind(...events: any[]): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param events An object containing one or more DOM event types and functions to execute for them. + */ + bind(events: any): JQuery; blur(handler: (eventObject: JQueryEventObject) => any): JQuery; blur(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; From b4ce3c8e6eb6eadd9ba167c580b3afb1bb241bca Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 18 Feb 2014 16:56:14 +0000 Subject: [PATCH 2/4] jQuery: JSDoc'd blur --- jquery/jquery.d.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 87f3a9afd..83f2288d0 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -2065,7 +2065,22 @@ interface JQuery { */ bind(events: any): JQuery; + /** + * Trigger the "blur" event on an element + */ + blur(): JQuery; + /** + * Bind an event handler to the "blur" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ blur(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "blur" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ blur(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; /** From 6fccc6e510f8b4cf40246f205df906e1dac8d6a0 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Thu, 20 Feb 2014 11:52:31 +0000 Subject: [PATCH 3/4] jQuery: fix to jquerymobile tests --- jquerymobile/jquerymobile-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquerymobile/jquerymobile-tests.ts b/jquerymobile/jquerymobile-tests.ts index 19231849f..b28d308a0 100644 --- a/jquerymobile/jquerymobile-tests.ts +++ b/jquerymobile/jquerymobile-tests.ts @@ -71,7 +71,7 @@ function test_pagesDialogs() { } }); - $(document).bind("pagebeforechange", function (e, data) { + $(document).bind("pagebeforechange", function (e, data?) { if (typeof data.toPage === "string") { var u = $.mobile.path.parseUrl(data.toPage), re = /^#category-item/; From f4e9a367db89730a1b2acaf57dd7085815566e6b Mon Sep 17 00:00:00 2001 From: John Reilly Date: Thu, 20 Feb 2014 16:58:11 +0000 Subject: [PATCH 4/4] jQuery: and fixed Sammy too --- sammyjs/sammyjs-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sammyjs/sammyjs-tests.ts b/sammyjs/sammyjs-tests.ts index da0da616e..1aa151d6e 100644 --- a/sammyjs/sammyjs-tests.ts +++ b/sammyjs/sammyjs-tests.ts @@ -422,7 +422,7 @@ function test_misc() { }); store = new Sammy.Store({ name: 'kvo' }); - $('body').bind('set-kvo-foo', function (e, data) { + $('body').bind('set-kvo-foo', function (e, data?) { Sammy.log(data.key + ' changed to ' + data.value); }); store.set('foo', 'bar');