mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 04:49:15 +08:00
jQuery: JSDoc completeness within reach
well nearly
This commit is contained in:
@@ -1857,6 +1857,26 @@ function test_getScript() {
|
||||
});
|
||||
}
|
||||
|
||||
function test_jQueryget() {
|
||||
console.log($("li").get(0));
|
||||
console.log($("li")[0]);
|
||||
console.log($("li").get(-1));
|
||||
$("*", document.body).click(function (event) {
|
||||
event.stopPropagation();
|
||||
var domElement = $(this).get(0);
|
||||
$("span:first").text("Clicked on - " + domElement.nodeName);
|
||||
});
|
||||
|
||||
function display(divs) {
|
||||
var a = [];
|
||||
for (var i = 0; i < divs.length; i++) {
|
||||
a.push(divs[i].innerHTML);
|
||||
}
|
||||
$("span").text(a.join(" "));
|
||||
}
|
||||
display($("div").get().reverse());
|
||||
}
|
||||
|
||||
function test_globalEval() {
|
||||
jQuery.globalEval("var newVar = true;");
|
||||
}
|
||||
@@ -2021,6 +2041,38 @@ function test_height() {
|
||||
});
|
||||
}
|
||||
|
||||
function test_wrap() {
|
||||
$(".inner").wrap("<div class='new'></div>");
|
||||
$(".inner").wrap(function () {
|
||||
return "<div class='" + $(this).text() + "'></div>";
|
||||
});
|
||||
$("span").wrap("<div><div><p><em><b></b></em></p></div></div>");
|
||||
$("p").wrap(document.createElement("div"));
|
||||
$("p").wrap($(".doublediv"));
|
||||
}
|
||||
|
||||
function test_wrapAll() {
|
||||
$(".inner").wrapAll("<div class='new' />");
|
||||
$("p").wrapAll("<div></div>");
|
||||
$("span").wrapAll("<div><div><p><em><b></b></em></p></div></div>");
|
||||
$("p").wrapAll(document.createElement("div"));
|
||||
$("p").wrapAll($(".doublediv"));
|
||||
}
|
||||
|
||||
function test_wrapInner() {
|
||||
$(".inner").wrapInner("<div class='new'></div>");
|
||||
$(".inner").wrapInner(function () {
|
||||
return "<div class='" + this.nodeValue + "'></div>";
|
||||
});
|
||||
var elem: Element;
|
||||
$(elem).wrapInner("<div class='test'></div>");
|
||||
$(elem).wrapInner("<div class=\"test\"></div>");
|
||||
$("p").wrapInner("<b></b>");
|
||||
$("body").wrapInner("<div><div><p><em><b></b></em></p></div></div>");
|
||||
$("p").wrapInner(document.createElement("b"));
|
||||
$("p").wrapInner($("<span class='red'></span>"));
|
||||
}
|
||||
|
||||
function test_width() {
|
||||
// Returns width of browser viewport
|
||||
$(window).width();
|
||||
@@ -2172,17 +2224,11 @@ function test_index() {
|
||||
function test_innerHeight() {
|
||||
var p = $("p:first");
|
||||
$("p:last").text("innerHeight:" + p.innerHeight());
|
||||
|
||||
p.innerHeight(123);
|
||||
p.innerHeight('123px');
|
||||
}
|
||||
|
||||
function test_innerWidth() {
|
||||
var p = $("p:first");
|
||||
$("p:last").text("innerWidth:" + p.innerWidth());
|
||||
|
||||
p.innerWidth(123);
|
||||
p.innerWidth('123px');
|
||||
}
|
||||
|
||||
function test_outerHeight() {
|
||||
@@ -2190,9 +2236,6 @@ function test_outerHeight() {
|
||||
$("p:last").text(
|
||||
"outerHeight:" + p.outerHeight() +
|
||||
" , outerHeight( true ):" + p.outerHeight(true));
|
||||
|
||||
p.outerHeight(123);
|
||||
p.outerHeight('123px');
|
||||
}
|
||||
|
||||
function test_outerWidth() {
|
||||
@@ -2200,9 +2243,6 @@ function test_outerWidth() {
|
||||
$("p:last").text(
|
||||
"outerWidth:" + p.outerWidth() +
|
||||
" , outerWidth( true ):" + p.outerWidth(true));
|
||||
|
||||
p.outerWidth(123);
|
||||
p.outerWidth('123px');
|
||||
}
|
||||
|
||||
function test_scrollLeft() {
|
||||
@@ -2920,16 +2960,25 @@ function test_map() {
|
||||
return $(this).val();
|
||||
}).get().join(", "));
|
||||
var mappedItems = $("li").map(function (index) {
|
||||
var replacement = $("<li>").text($(this).text()).get(0);
|
||||
if (index == 0) {
|
||||
var replacement:any = $("<li>").text($(this).text()).get(0);
|
||||
if (index === 0) {
|
||||
|
||||
// Make the first item all caps
|
||||
$(replacement).text($(replacement).text().toUpperCase());
|
||||
} else if (index == 1 || index == 3) {
|
||||
} else if (index === 1 || index === 3) {
|
||||
|
||||
// Delete the second and fourth items
|
||||
replacement = null;
|
||||
} else if (index == 2) {
|
||||
} else if (index === 2) {
|
||||
|
||||
// Make two of the third item and add some text
|
||||
replacement = [replacement, $("<li>").get(0)];
|
||||
$(replacement[0]).append("<b> - A</b>");
|
||||
$(replacement[1]).append("Extra <b> - B</b>");
|
||||
}
|
||||
|
||||
// Replacement will be a dom element, null,
|
||||
// or an array of dom elements
|
||||
return replacement;
|
||||
});
|
||||
$("#results").append(mappedItems);
|
||||
|
||||
207
jquery/jquery.d.ts
vendored
207
jquery/jquery.d.ts
vendored
@@ -1418,39 +1418,11 @@ interface JQuery {
|
||||
*/
|
||||
innerHeight(): number;
|
||||
|
||||
/**
|
||||
* Sets the inner height on elements in the set of matched elements, including padding but not border.
|
||||
*
|
||||
* @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
|
||||
*/
|
||||
innerHeight(height: number): JQuery;
|
||||
|
||||
/**
|
||||
* Sets the inner height on elements in the set of matched elements, including padding but not border.
|
||||
*
|
||||
* @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
|
||||
*/
|
||||
innerHeight(height: string): JQuery;
|
||||
|
||||
/**
|
||||
* Get the current computed width for the first element in the set of matched elements, including padding but not border.
|
||||
*/
|
||||
innerWidth(): number;
|
||||
|
||||
/**
|
||||
* Sets the inner width on elements in the set of matched elements, including padding but not border.
|
||||
*
|
||||
* @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
|
||||
*/
|
||||
innerWidth(width: number): JQuery;
|
||||
|
||||
/**
|
||||
* Sets the inner width on elements in the set of matched elements, including padding but not border.
|
||||
*
|
||||
* @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
|
||||
*/
|
||||
innerWidth(width: string): JQuery;
|
||||
|
||||
/**
|
||||
* Get the current coordinates of the first element in the set of matched elements, relative to the document.
|
||||
*/
|
||||
@@ -1475,20 +1447,6 @@ interface JQuery {
|
||||
*/
|
||||
outerHeight(includeMargin?: boolean): number;
|
||||
|
||||
/**
|
||||
* Sets the outer height on elements in the set of matched elements, including padding and border.
|
||||
*
|
||||
* @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
|
||||
*/
|
||||
outerHeight(height: number): JQuery;
|
||||
|
||||
/**
|
||||
* Sets the outer height on elements in the set of matched elements, including padding and border.
|
||||
*
|
||||
* @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
|
||||
*/
|
||||
outerHeight(height: string): JQuery;
|
||||
|
||||
/**
|
||||
* Get the current computed width for the first element in the set of matched elements, including padding and border.
|
||||
*
|
||||
@@ -1496,20 +1454,6 @@ interface JQuery {
|
||||
*/
|
||||
outerWidth(includeMargin?: boolean): number;
|
||||
|
||||
/**
|
||||
* Sets the outer width on elements in the set of matched elements, including padding and border.
|
||||
*
|
||||
* @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
|
||||
*/
|
||||
outerWidth(width: number): JQuery;
|
||||
|
||||
/**
|
||||
* Sets the outer width on elements in the set of matched elements, including padding and border.
|
||||
*
|
||||
* @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
|
||||
*/
|
||||
outerWidth(width: string): JQuery;
|
||||
|
||||
/**
|
||||
* Get the current coordinates of the first element in the set of matched elements, relative to the offset parent.
|
||||
*/
|
||||
@@ -3169,15 +3113,79 @@ interface JQuery {
|
||||
*/
|
||||
toArray(): any[];
|
||||
|
||||
/**
|
||||
* Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place.
|
||||
*/
|
||||
unwrap(): JQuery;
|
||||
|
||||
wrap(wrappingElement: any): JQuery;
|
||||
wrap(func: (index: any) => any): JQuery;
|
||||
/**
|
||||
* Wrap an HTML structure around each element in the set of matched elements.
|
||||
*
|
||||
* @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements.
|
||||
*/
|
||||
wrap(wrappingElement: JQuery): JQuery;
|
||||
/**
|
||||
* Wrap an HTML structure around each element in the set of matched elements.
|
||||
*
|
||||
* @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements.
|
||||
*/
|
||||
wrap(wrappingElement: Element): JQuery;
|
||||
/**
|
||||
* Wrap an HTML structure around each element in the set of matched elements.
|
||||
*
|
||||
* @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements.
|
||||
*/
|
||||
wrap(wrappingElement: string): JQuery;
|
||||
/**
|
||||
* Wrap an HTML structure around each element in the set of matched elements.
|
||||
*
|
||||
* @param func A callback function returning the HTML content or jQuery object to wrap around the matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set.
|
||||
*/
|
||||
wrap(func: (index: number) => any): JQuery;
|
||||
|
||||
wrapAll(wrappingElement: any): JQuery;
|
||||
/**
|
||||
* Wrap an HTML structure around all elements in the set of matched elements.
|
||||
*
|
||||
* @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements.
|
||||
*/
|
||||
wrapAll(wrappingElement: JQuery): JQuery;
|
||||
/**
|
||||
* Wrap an HTML structure around all elements in the set of matched elements.
|
||||
*
|
||||
* @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements.
|
||||
*/
|
||||
wrapAll(wrappingElement: Element): JQuery;
|
||||
/**
|
||||
* Wrap an HTML structure around all elements in the set of matched elements.
|
||||
*
|
||||
* @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements.
|
||||
*/
|
||||
wrapAll(wrappingElement: string): JQuery;
|
||||
|
||||
wrapInner(wrappingElement: any): JQuery;
|
||||
wrapInner(func: (index: any) => any): JQuery;
|
||||
/**
|
||||
* Wrap an HTML structure around the content of each element in the set of matched elements.
|
||||
*
|
||||
* @param wrappingElement An HTML snippet, selector expression, jQuery object, or DOM element specifying the structure to wrap around the content of the matched elements.
|
||||
*/
|
||||
wrapInner(wrappingElement: JQuery): JQuery;
|
||||
/**
|
||||
* Wrap an HTML structure around the content of each element in the set of matched elements.
|
||||
*
|
||||
* @param wrappingElement An HTML snippet, selector expression, jQuery object, or DOM element specifying the structure to wrap around the content of the matched elements.
|
||||
*/
|
||||
wrapInner(wrappingElement: Element): JQuery;
|
||||
/**
|
||||
* Wrap an HTML structure around the content of each element in the set of matched elements.
|
||||
*
|
||||
* @param wrappingElement An HTML snippet, selector expression, jQuery object, or DOM element specifying the structure to wrap around the content of the matched elements.
|
||||
*/
|
||||
wrapInner(wrappingElement: string): JQuery;
|
||||
/**
|
||||
* Wrap an HTML structure around the content of each element in the set of matched elements.
|
||||
*
|
||||
* @param func A callback function which generates a structure to wrap around the content of the matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set.
|
||||
*/
|
||||
wrapInner(func: (index: number) => any): JQuery;
|
||||
|
||||
/**
|
||||
* Iterate over a jQuery object, executing a function for each matched element.
|
||||
@@ -3186,25 +3194,84 @@ interface JQuery {
|
||||
*/
|
||||
each(func: (index: number, elem: Element) => any): JQuery;
|
||||
|
||||
get(index?: number): any;
|
||||
/**
|
||||
* Retrieve one of the elements matched by the jQuery object.
|
||||
*
|
||||
* @param index A zero-based integer indicating which element to retrieve.
|
||||
*/
|
||||
get(index: number): HTMLElement;
|
||||
/**
|
||||
* Retrieve the elements matched by the jQuery object.
|
||||
*/
|
||||
get(): any[];
|
||||
|
||||
/**
|
||||
* Search for a given element from among the matched elements.
|
||||
*/
|
||||
index(): number;
|
||||
/**
|
||||
* Search for a given element from among the matched elements.
|
||||
*
|
||||
* @param selector A selector representing a jQuery collection in which to look for an element.
|
||||
*/
|
||||
index(selector: string): number;
|
||||
index(element: any): number;
|
||||
/**
|
||||
* Search for a given element from among the matched elements.
|
||||
*
|
||||
* @param element The DOM element or first element within the jQuery object to look for.
|
||||
*/
|
||||
index(element: JQuery): number;
|
||||
/**
|
||||
* Search for a given element from among the matched elements.
|
||||
*
|
||||
* @param element The DOM element or first element within the jQuery object to look for.
|
||||
*/
|
||||
index(element: Element): number;
|
||||
|
||||
// Properties
|
||||
/**
|
||||
* The number of elements in the jQuery object.
|
||||
*/
|
||||
length: number;
|
||||
/**
|
||||
* A selector representing selector passed to jQuery(), if any, when creating the original set.
|
||||
* version deprecated: 1.7, removed: 1.9
|
||||
*/
|
||||
selector: string;
|
||||
[x: string]: any;
|
||||
[x: number]: HTMLElement;
|
||||
[index: string]: any;
|
||||
[index: number]: HTMLElement;
|
||||
|
||||
// Traversing
|
||||
add(selector: string, context?: any): JQuery;
|
||||
add(...elements: any[]): JQuery;
|
||||
/**
|
||||
* Add elements to the set of matched elements.
|
||||
*
|
||||
* @param selector A string representing a selector expression to find additional elements to add to the set of matched elements.
|
||||
* @param context The point in the document at which the selector should begin matching; similar to the context argument of the $(selector, context) method.
|
||||
*/
|
||||
add(selector: string, context?: Element): JQuery;
|
||||
/**
|
||||
* Add elements to the set of matched elements.
|
||||
*
|
||||
* @param elements One or more elements to add to the set of matched elements.
|
||||
*/
|
||||
add(...elements: Element[]): JQuery;
|
||||
/**
|
||||
* Add elements to the set of matched elements.
|
||||
*
|
||||
* @param html An HTML fragment to add to the set of matched elements.
|
||||
*/
|
||||
add(html: string): JQuery;
|
||||
/**
|
||||
* Add elements to the set of matched elements.
|
||||
*
|
||||
* @param obj An existing jQuery object to add to the set of matched elements.
|
||||
*/
|
||||
add(obj: JQuery): JQuery;
|
||||
|
||||
children(selector?: any): JQuery;
|
||||
/**
|
||||
* Get the children of each element in the set of matched elements, optionally filtered by a selector.
|
||||
*
|
||||
* @param selector A string containing a selector expression to match elements against.
|
||||
*/
|
||||
children(selector?: string): JQuery;
|
||||
|
||||
closest(selector: string): JQuery;
|
||||
closest(selector: string, context?: Element): JQuery;
|
||||
|
||||
8
svgjs/svgjs.d.ts
vendored
8
svgjs/svgjs.d.ts
vendored
@@ -270,3 +270,11 @@ declare module svgjs {
|
||||
f?: number;
|
||||
}
|
||||
}
|
||||
interface JQuery {
|
||||
/**
|
||||
* Retrieve one of the elements matched by the jQuery object.
|
||||
*
|
||||
* @param index A zero-based integer indicating which element to retrieve.
|
||||
*/
|
||||
get(index: number): svgjs.LinkedHTMLElement;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user