From e97d59b953c303920a660360c6931155286aad45 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Fri, 10 Jan 2014 13:35:23 +0000 Subject: [PATCH 1/4] jQuery: scrollLeft / scrollTop JSDoc'd --- jquery/jquery.d.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 01e75e118a..9bc102ca01 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -1067,10 +1067,26 @@ interface JQuery { */ position(): JQueryCoordinates; + /** + * Get the current horizontal position of the scroll bar for the first element in the set of matched elements or set the horizontal position of the scroll bar for every matched element. + */ scrollLeft(): number; + /** + * Set the current horizontal position of the scroll bar for each of the set of matched elements. + * + * @param value An integer indicating the new position to set the scroll bar to. + */ scrollLeft(value: number): JQuery; + /** + * Get the current vertical position of the scroll bar for the first element in the set of matched elements or set the vertical position of the scroll bar for every matched element. + */ scrollTop(): number; + /** + * Set the current vertical position of the scroll bar for each of the set of matched elements. + * + * @param value An integer indicating the new position to set the scroll bar to. + */ scrollTop(value: number): JQuery; /** From c733d256516bde678fc0f6c92ff75f35caa9d564 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Fri, 10 Jan 2014 13:38:25 +0000 Subject: [PATCH 2/4] jQuery: scrollLeft /scrollTop test suites --- jquery/jquery-tests.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 35a954e958..0fed71bf4c 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -1814,6 +1814,20 @@ function test_outerWidth() { " , outerWidth( true ):" + p.outerWidth(true)); } +function test_scrollLeft() { + var p = $("p:first"); + $("p:last").text("scrollLeft:" + p.scrollLeft()); + + $("div.demo").scrollLeft(300); +} + +function test_scrollTop() { + var p = $("p:first"); + $("p:last").text("scrollTop:" + p.scrollTop()); + + $("div.demo").scrollTop(300); +} + function test_position() { var p = $("p:first"); var position = p.position(); From 9d4f888a30651c9fc4ed4eb05c8dd4823df69a19 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Fri, 10 Jan 2014 13:51:27 +0000 Subject: [PATCH 3/4] jQuery: data JSDoc and removeData test suite --- jquery/jquery-tests.ts | 10 +++++++++ jquery/jquery.d.ts | 46 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 0fed71bf4c..440a567073 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -898,6 +898,16 @@ function test_data() { $.data(document.getElementById("id"), "", "8").toUpperCase(); } +function test_removeData() { + $("span:eq(0)").text("" + $("div").data("test1")); + $("div").data("test1", "VALUE-1"); + $("div").data("test2", "VALUE-2"); + $("span:eq(1)").text("" + $("div").data("test1")); + $("div").removeData("test1"); + $("span:eq(2)").text("" + $("div").data("test1")); + $("span:eq(3)").text("" + $("div").data("test2")); +} + function test_dblclick() { $('#target').dblclick(function () { alert('Handler for .dblclick() called.'); diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 9bc102ca01..f21670ba72 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -1130,16 +1130,56 @@ interface JQuery { */ width(func: (index: number, width: number) => string): JQuery; - // Data + /** + * Remove from the queue all items that have not yet been run. + * + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + */ clearQueue(queueName?: string): JQuery; + /** + * Store arbitrary data associated with the matched elements. + * + * @param key A string naming the piece of data to set. + * @param value The new data value; it can be any Javascript type including Array or Object. + */ data(key: string, value: any): JQuery; + /** + * Store arbitrary data associated with the matched elements. + * + * @param obj An object of key-value pairs of data to update. + */ data(obj: { [key: string]: any; }): JQuery; - data(key?: string): any; + /** + * Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute. + * + * @param key Name of the data stored. + */ + data(key: string): any; + /** + * Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute. + */ + data(): any; + /** + * Execute the next function on the queue for the matched elements. + * + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + */ dequeue(queueName?: string): JQuery; - removeData(nameOrList?: any): JQuery; + /** + * Remove a previously-stored piece of data. + * + * @param name A string naming the piece of data to delete or space-separated string naming the pieces of data to delete. + */ + removeData(name: string): JQuery; + /** + * Remove a previously-stored piece of data. + * + * @param list An array of strings naming the pieces of data to delete. + */ + removeData(list: string[]): JQuery; // Deferred promise(type?: any, target?: any): JQueryPromise; From 0931add1c36308f3a4e2b1ea1d256ba96b54687f Mon Sep 17 00:00:00 2001 From: John Reilly Date: Fri, 10 Jan 2014 13:55:55 +0000 Subject: [PATCH 4/4] jQuery: promise JSDoc'd and added test suite --- jquery/jquery-tests.ts | 33 +++++++++++++++++++++++++++++++++ jquery/jquery.d.ts | 9 +++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 440a567073..6508e81a74 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -1856,6 +1856,39 @@ function test_insertBefore() { $("p").insertBefore("#foo"); } +function test_promise() { + var div = $("
"); + + div.promise().done(function (arg1) { + // Will fire right away and alert "true" + alert(this === div && arg1 === div); + }); + + $("button").on("click", function () { + $("p").append("Started..."); + + $("div").each(function (i) { + $(this).fadeIn().fadeOut(1000 * (i + 1)); + }); + + $("div").promise().done(function () { + $("p").append(" Finished! "); + }); + }); + + var effect = function () { + return $("div").fadeIn(800).delay(1200).fadeOut(); + }; + + $("button").on("click", function () { + $("p").append(" Started... "); + + $.when(effect()).done(function () { + $("p").append(" Finished! "); + }); + }); +} + function test_is() { $("ul").click(function (event) { var $target = $(event.target); diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index f21670ba72..992213c390 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -1181,8 +1181,13 @@ interface JQuery { */ removeData(list: string[]): JQuery; - // Deferred - promise(type?: any, target?: any): JQueryPromise; + /** + * Return a Promise object to observe when all actions of a certain type bound to the collection, queued or not, have finished. + * + * @param type The type of queue that needs to be observed. (default: fx) + * @param target Object onto which the promise methods have to be attached + */ + promise(type?: string, target?: Object): JQueryPromise; // Effects animate(properties: any, duration?: any, complete?: Function): JQuery;