mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
jQuery: queue, dequeue, hasdata
added queue test suite
This commit is contained in:
@@ -1095,6 +1095,68 @@ function test_dequeue() {
|
||||
});
|
||||
}
|
||||
|
||||
function test_queue() {
|
||||
|
||||
$("#show").click(function () {
|
||||
var n = jQuery.queue($("div")[0], "fx");
|
||||
$("span").text("Queue length is: " + n.length);
|
||||
});
|
||||
|
||||
function runIt() {
|
||||
$("div")
|
||||
.show("slow")
|
||||
.animate({
|
||||
left: "+=200"
|
||||
}, 2000)
|
||||
.slideToggle(1000)
|
||||
.slideToggle("fast")
|
||||
.animate({
|
||||
left: "-=200"
|
||||
}, 1500)
|
||||
.hide("slow")
|
||||
.show(1200)
|
||||
.slideUp("normal", runIt);
|
||||
}
|
||||
|
||||
runIt();
|
||||
|
||||
$(document.body).click(function () {
|
||||
var divs = $("div")
|
||||
.show("slow")
|
||||
.animate({ left: "+=200" }, 2000);
|
||||
jQuery.queue(divs[0], "fx", function () {
|
||||
$(this).addClass("newcolor");
|
||||
jQuery.dequeue(this);
|
||||
});
|
||||
divs.animate({ left: "-=200" }, 500);
|
||||
jQuery.queue(divs[0], "fx", function () {
|
||||
$(this).removeClass("newcolor");
|
||||
jQuery.dequeue(this);
|
||||
});
|
||||
divs.slideUp();
|
||||
});
|
||||
|
||||
$("#start").click(function () {
|
||||
var divs = $("div")
|
||||
.show("slow")
|
||||
.animate({ left: "+=200" }, 5000);
|
||||
jQuery.queue(divs[0], "fx", function () {
|
||||
$(this).addClass("newcolor");
|
||||
jQuery.dequeue(this);
|
||||
});
|
||||
divs.animate({ left: "-=200" }, 1500);
|
||||
jQuery.queue(divs[0], "fx", function () {
|
||||
$(this).removeClass("newcolor");
|
||||
jQuery.dequeue(this);
|
||||
});
|
||||
divs.slideUp();
|
||||
});
|
||||
$("#stop").click(function () {
|
||||
jQuery.queue($("div")[0], "fx", []);
|
||||
$("div").stop();
|
||||
});
|
||||
}
|
||||
|
||||
function test_detach() {
|
||||
$("p").click(function () {
|
||||
$(this).toggleClass("off");
|
||||
|
||||
Vendored
+40
-5
@@ -423,9 +423,9 @@ interface JQueryEasing {
|
||||
swing(p: number): number;
|
||||
}
|
||||
|
||||
/*
|
||||
Static members of jQuery (those on $ and jQuery themselves)
|
||||
*/
|
||||
/**
|
||||
* Static members of jQuery (those on $ and jQuery themselves)
|
||||
*/
|
||||
interface JQueryStatic {
|
||||
|
||||
/**
|
||||
@@ -659,6 +659,9 @@ interface JQueryStatic {
|
||||
*/
|
||||
when<T>(...deferreds: any[]): JQueryPromise<T>;
|
||||
|
||||
/**
|
||||
* Hook directly into jQuery to override how particular CSS properties are retrieved or set, normalize CSS property naming, or create custom properties.
|
||||
*/
|
||||
cssHooks: { [key: string]: any; };
|
||||
cssNumber: any;
|
||||
|
||||
@@ -684,12 +687,44 @@ interface JQueryStatic {
|
||||
*/
|
||||
data(element: Element): any;
|
||||
|
||||
dequeue(element: Element, queueName?: string): any;
|
||||
/**
|
||||
* Execute the next function on the queue for the matched element.
|
||||
*
|
||||
* @param element A DOM element from which to remove and execute a queued function.
|
||||
* @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
|
||||
*/
|
||||
dequeue(element: Element, queueName?: string): void;
|
||||
|
||||
/**
|
||||
* Determine whether an element has any jQuery data associated with it.
|
||||
*
|
||||
* @param element A DOM element to be checked for data.
|
||||
*/
|
||||
hasData(element: Element): boolean;
|
||||
|
||||
/**
|
||||
* Show the queue of functions to be executed on the matched element.
|
||||
*
|
||||
* @param element A DOM element to inspect for an attached queue.
|
||||
* @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
|
||||
*/
|
||||
queue(element: Element, queueName?: string): any[];
|
||||
queue(element: Element, queueName: string, newQueueOrCallback: any): JQuery;
|
||||
/**
|
||||
* Manipulate the queue of functions to be executed on the matched element.
|
||||
*
|
||||
* @param element A DOM element where the array of queued functions is attached.
|
||||
* @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
|
||||
* @param newQueue An array of functions to replace the current queue contents.
|
||||
*/
|
||||
queue(element: Element, queueName: string, newQueue: Function[]): JQuery;
|
||||
/**
|
||||
* Manipulate the queue of functions to be executed on the matched element.
|
||||
*
|
||||
* @param element A DOM element on which to add a queued function.
|
||||
* @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
|
||||
* @param callback The new function to add to the queue.
|
||||
*/
|
||||
queue(element: Element, queueName: string, callback: Function): JQuery;
|
||||
|
||||
removeData(element: Element, name?: string): JQuery;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user