From ae18b734523516fa84cc12e2d8913fb4ac4e12ff Mon Sep 17 00:00:00 2001 From: johnnyreilly Date: Tue, 24 Dec 2013 10:59:23 +0000 Subject: [PATCH 1/8] jQuery: Added addClass JSDoc --- jquery/jquery.d.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index e8a050194..31b9b782f 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -657,9 +657,9 @@ interface JQueryStatic { easing: JQueryEasing; } -/* - The jQuery instance members -*/ +/** + * The jQuery instance members + */ interface JQuery { // AJAX ajaxComplete(handler: any): JQuery; @@ -674,9 +674,18 @@ interface JQuery { serialize(): string; serializeArray(): any[]; - // Attributes - addClass(classNames: string): JQuery; - addClass(func: (index: any, currentClass: any) => string): JQuery; + /** + * Adds the specified class(es) to each of the set of matched elements. + * + * @param className One or more space-separated classes to be added to the class attribute of each matched element. + */ + addClass(className: string): JQuery; + /** + * Adds the specified class(es) to each of the set of matched elements. + * + * @param function A function returning one or more space-separated class names to be added to the existing class name(s). Receives the index position of the element in the set and the existing class name(s) as arguments. Within the function, this refers to the current element in the set. + */ + addClass(func: (index: number, currentClass: string) => string): JQuery; // http://api.jquery.com/addBack/ addBack(selector?: string): JQuery; From db67a18e04dfb73df6604a0b806c301f4e980cfa Mon Sep 17 00:00:00 2001 From: johnnyreilly Date: Tue, 24 Dec 2013 11:06:23 +0000 Subject: [PATCH 2/8] jQuery: Add serialize / serializeArray JSDoc --- jquery/jquery.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 31b9b782f..c7af21827 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -671,8 +671,14 @@ interface JQuery { load(url: string, data?: any, complete?: any): JQuery; + /** + * Encode a set of form elements as a string for submission. + */ serialize(): string; - serializeArray(): any[]; + /** + * Encode a set of form elements as an array of names and values. + */ + serializeArray(): Object[]; /** * Adds the specified class(es) to each of the set of matched elements. From 97787b7e3e480e0a5eb306b88e4d0115fb133054 Mon Sep 17 00:00:00 2001 From: johnnyreilly Date: Tue, 24 Dec 2013 11:20:42 +0000 Subject: [PATCH 3/8] jQuery: toggleClass / removeClass --- jquery/jquery.d.ts | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index c7af21827..63ce53a96 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -691,9 +691,11 @@ interface JQuery { * * @param function A function returning one or more space-separated class names to be added to the existing class name(s). Receives the index position of the element in the set and the existing class name(s) as arguments. Within the function, this refers to the current element in the set. */ - addClass(func: (index: number, currentClass: string) => string): JQuery; + addClass(func: (index: number, className: string) => string): JQuery; - // http://api.jquery.com/addBack/ + /** + * Add the previous set of elements on the stack to the current set, optionally filtered by a selector. + */ addBack(selector?: string): JQuery; @@ -702,6 +704,11 @@ interface JQuery { attr(attributeName: string, func: (index: any, attr: any) => any): JQuery; attr(map: any): JQuery; + /** + * Determine whether any of the matched elements are assigned the given class. + * + * @param className The class name to search for. + */ hasClass(className: string): boolean; html(): string; @@ -716,14 +723,41 @@ interface JQuery { removeAttr(attributeName: string): JQuery; + /** + * Remove a single class, multiple classes, or all classes from each element in the set of matched elements. + * + * @param className One or more space-separated classes to be removed from the class attribute of each matched element. + */ removeClass(className?: string): JQuery; - removeClass(func: (index: any, cls: any) => any): JQuery; + /** + * Remove a single class, multiple classes, or all classes from each element in the set of matched elements. + * + * @param function A function returning one or more space-separated class names to be removed. Receives the index position of the element in the set and the old class value as arguments. + */ + removeClass(func: (index: number, className: string) => string): JQuery; removeProp(propertyName: string): JQuery; + /** + * Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. + * + * @param className One or more class names (separated by spaces) to be toggled for each element in the matched set. + * @param swtch A Boolean (not just truthy/falsy) value to determine whether the class should be added or removed. + */ toggleClass(className: string, swtch?: boolean): JQuery; + /** + * Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. + * + * @param swtch A boolean value to determine whether the class should be added or removed. + */ toggleClass(swtch?: boolean): JQuery; - toggleClass(func: (index: any, cls: any, swtch: any) => any): JQuery; + /** + * Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. + * + * @param func A function that returns class names to be toggled in the class attribute of each element in the matched set. Receives the index position of the element in the set, the old class value, and the switch as arguments. + * @param swtch A boolean value to determine whether the class should be added or removed. + */ + toggleClass(func: (index: number, className: string, swtch: boolean) => string, swtch?: boolean): JQuery; val(): any; val(value: string[]): JQuery; From 3649e3320bf389e516c5707b18302a4e5cbc68c5 Mon Sep 17 00:00:00 2001 From: johnnyreilly Date: Tue, 24 Dec 2013 11:31:23 +0000 Subject: [PATCH 4/8] jQuery: attr JSDoc --- jquery/jquery.d.ts | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 63ce53a96..3ddd0fefa 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -698,12 +698,40 @@ interface JQuery { */ addBack(selector?: string): JQuery; - + /** + * Get the value of an attribute for the first element in the set of matched elements. + * + * @param attributeName The name of the attribute to get. + */ attr(attributeName: string): string; - attr(attributeName: string, value: any): JQuery; - attr(attributeName: string, func: (index: any, attr: any) => any): JQuery; - attr(map: any): JQuery; - + /** + * Set one or more attributes for the set of matched elements. + * + * @param attributeName The name of the attribute to set. + * @param value A value to set for the attribute. + */ + attr(attributeName: string, value: string): JQuery; + /** + * Set one or more attributes for the set of matched elements. + * + * @param attributeName The name of the attribute to set. + * @param value A value to set for the attribute. + */ + attr(attributeName: string, value: number): JQuery; + /** + * Set one or more attributes for the set of matched elements. + * + * @param attributeName The name of the attribute to set. + * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old attribute value as arguments. + */ + attr(attributeName: string, func: (index: number, attr: any) => any): JQuery; + /** + * Set one or more attributes for the set of matched elements. + * + * @param attributes An object of attribute-value pairs to set. + */ + attr(attributes: Object): JQuery; + /** * Determine whether any of the matched elements are assigned the given class. * From ac4275f1687e5dffc5fae05ecf3a00ddec4fff4e Mon Sep 17 00:00:00 2001 From: johnnyreilly Date: Tue, 24 Dec 2013 11:39:34 +0000 Subject: [PATCH 5/8] jQuery: load JSDoc --- jquery/jquery.d.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 3ddd0fefa..fcd8fda3e 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -669,7 +669,22 @@ interface JQuery { ajaxStop(handler: () => any): JQuery; ajaxSuccess(handler: (event: any, jqXHR: any, settings: any, exception: any) => any): JQuery; - load(url: string, data?: any, complete?: any): JQuery; + /** + * Load data from the server and place the returned HTML into the matched element. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param complete A callback function that is executed when the request completes. + */ + load(url: string, data?: string, complete?: (responseText: string, textStatus: string, XMLHttpRequest: JQueryXHR) => any): JQuery; + /** + * Load data from the server and place the returned HTML into the matched element. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param complete A callback function that is executed when the request completes. + */ + load(url: string, data?: Object, complete?: (responseText: string, textStatus: string, XMLHttpRequest: JQueryXHR) => any): JQuery; /** * Encode a set of form elements as a string for submission. @@ -749,6 +764,11 @@ interface JQuery { prop(map: any): JQuery; prop(propertyName: string, func: (index: any, oldPropertyValue: any) => any): JQuery; + /** + * Remove an attribute from each element in the set of matched elements. + * + * @param attributeName An attribute to remove; as of version 1.7, it can be a space-separated list of attributes. + */ removeAttr(attributeName: string): JQuery; /** From 3416f6e88a0bfee29dc15701316df11db188b16e Mon Sep 17 00:00:00 2001 From: johnnyreilly Date: Tue, 24 Dec 2013 11:48:46 +0000 Subject: [PATCH 6/8] jQuery: ajaxComplete --- jquery/jquery.d.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index fcd8fda3e..abcbd11e7 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -661,8 +661,12 @@ interface JQueryStatic { * The jQuery instance members */ interface JQuery { - // AJAX - ajaxComplete(handler: any): JQuery; + /** + * Register a handler to be called when Ajax requests complete. This is an AjaxEvent. + * + * @param handler The function to be invoked. + */ + ajaxComplete(handler: (event: any, XMLHttpRequest: XMLHttpRequest, ajaxOptions: any) => any): JQuery; ajaxError(handler: (event: any, jqXHR: any, settings: any, exception: any) => any): JQuery; ajaxSend(handler: (event: any, jqXHR: any, settings: any, exception: any) => any): JQuery; ajaxStart(handler: () => any): JQuery; @@ -676,7 +680,7 @@ interface JQuery { * @param data A plain object or string that is sent to the server with the request. * @param complete A callback function that is executed when the request completes. */ - load(url: string, data?: string, complete?: (responseText: string, textStatus: string, XMLHttpRequest: JQueryXHR) => any): JQuery; + load(url: string, data?: string, complete?: (responseText: string, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any): JQuery; /** * Load data from the server and place the returned HTML into the matched element. * @@ -684,7 +688,7 @@ interface JQuery { * @param data A plain object or string that is sent to the server with the request. * @param complete A callback function that is executed when the request completes. */ - load(url: string, data?: Object, complete?: (responseText: string, textStatus: string, XMLHttpRequest: JQueryXHR) => any): JQuery; + load(url: string, data?: Object, complete?: (responseText: string, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any): JQuery; /** * Encode a set of form elements as a string for submission. From 427d2e05760ddc8c3e4fdbb24ee6c25c1444037e Mon Sep 17 00:00:00 2001 From: johnnyreilly Date: Wed, 25 Dec 2013 19:07:30 +0000 Subject: [PATCH 7/8] jQuery: Fix to typings --- jquery/jquery.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index abcbd11e7..196acb179 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -666,7 +666,7 @@ interface JQuery { * * @param handler The function to be invoked. */ - ajaxComplete(handler: (event: any, XMLHttpRequest: XMLHttpRequest, ajaxOptions: any) => any): JQuery; + ajaxComplete(handler: (event: any, XMLHttpRequest: any, ajaxOptions: any) => any): JQuery; ajaxError(handler: (event: any, jqXHR: any, settings: any, exception: any) => any): JQuery; ajaxSend(handler: (event: any, jqXHR: any, settings: any, exception: any) => any): JQuery; ajaxStart(handler: () => any): JQuery; From 3b581e015208e939a8fddf14c9ad430d96abf491 Mon Sep 17 00:00:00 2001 From: johnnyreilly Date: Thu, 26 Dec 2013 21:15:05 +0000 Subject: [PATCH 8/8] jQuery: now with valid ajaxComplete test Also with corrected jquerymobile attr test --- jquery/jquery-tests.ts | 2 +- jquery/jquery.d.ts | 2 +- jquerymobile/jquerymobile-tests.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 728d9d06f..e56893d3b 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -161,7 +161,7 @@ function test_ajaxComplete() { }); $('.log').ajaxComplete(function (e, xhr, settings) { if (settings.url == 'ajax/test.html') { - $(this).text('Triggered ajaxComplete handler. The result is ' + xhr.responseHTML); + $(this).text('Triggered ajaxComplete handler. The result is ' + xhr.responseText); } }); $("#msg").ajaxComplete(function (event, request, settings) { diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 196acb179..abcbd11e7 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -666,7 +666,7 @@ interface JQuery { * * @param handler The function to be invoked. */ - ajaxComplete(handler: (event: any, XMLHttpRequest: any, ajaxOptions: any) => any): JQuery; + ajaxComplete(handler: (event: any, XMLHttpRequest: XMLHttpRequest, ajaxOptions: any) => any): JQuery; ajaxError(handler: (event: any, jqXHR: any, settings: any, exception: any) => any): JQuery; ajaxSend(handler: (event: any, jqXHR: any, settings: any, exception: any) => any): JQuery; ajaxStart(handler: () => any): JQuery; diff --git a/jquerymobile/jquerymobile-tests.ts b/jquerymobile/jquerymobile-tests.ts index a3d20194a..a21340932 100644 --- a/jquerymobile/jquerymobile-tests.ts +++ b/jquerymobile/jquerymobile-tests.ts @@ -216,7 +216,7 @@ function test_form() { $("input[type='radio']").checkboxradio({ mini: true }); $("input[type='radio']").checkboxradio({ theme: "a" }); $("input[type='radio']").checkboxradio('enable'); - $("input[type='radio']:first").attr("checked", true).checkboxradio("refresh"); + $("input[type='radio']:first").prop("checked", true).checkboxradio("refresh"); $("input[type='radio']").checkboxradio({ create: function (event, ui) { } });