mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 11:57:33 +08:00
jQuery: JSDoc'd width + added width test suite
This commit is contained in:
@@ -1642,6 +1642,33 @@ function test_height() {
|
||||
});
|
||||
}
|
||||
|
||||
function test_width() {
|
||||
// Returns width of browser viewport
|
||||
$(window).width();
|
||||
|
||||
// Returns width of HTML document
|
||||
$(document).width();
|
||||
|
||||
function showWidth(ele, w) {
|
||||
$("div").text("The width for the " + ele + " is " + w + "px.");
|
||||
}
|
||||
$("#getp").click(function () {
|
||||
showWidth("paragraph", $("p").width());
|
||||
});
|
||||
$("#getd").click(function () {
|
||||
showWidth("document", $(document).width());
|
||||
});
|
||||
$("#getw").click(function () {
|
||||
showWidth("window", $(window).width());
|
||||
});
|
||||
|
||||
var modWidth = 50;
|
||||
$("div").one("click", function () {
|
||||
$(this).width(modWidth).addClass("mod");
|
||||
modWidth -= 8;
|
||||
});
|
||||
}
|
||||
|
||||
function test_hide() {
|
||||
$('.target').hide();
|
||||
$('#clickme').click(function () {
|
||||
|
||||
38
jquery/jquery.d.ts
vendored
38
jquery/jquery.d.ts
vendored
@@ -1041,10 +1041,46 @@ interface JQuery {
|
||||
scrollTop(): number;
|
||||
scrollTop(value: number): JQuery;
|
||||
|
||||
/**
|
||||
* Get the current computed width for the first element in the set of matched elements.
|
||||
*/
|
||||
width(): number;
|
||||
/**
|
||||
* Set the CSS width of each element in the set of matched elements.
|
||||
*
|
||||
* @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
|
||||
*/
|
||||
width(value: number): JQuery;
|
||||
/**
|
||||
* Set the CSS width of each element in the set of matched elements.
|
||||
*
|
||||
* @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
|
||||
*/
|
||||
width(value: string): JQuery;
|
||||
width(func: (index: any, height: any) => any): JQuery;
|
||||
/**
|
||||
* Set the CSS width of each element in the set of matched elements.
|
||||
*
|
||||
* @param func A function returning the width to set. Receives the index position of the element in the set and the old width as arguments. Within the function, this refers to the current element in the set.
|
||||
*/
|
||||
width(func: (index: number, width: number) => number): JQuery;
|
||||
/**
|
||||
* Set the CSS width of each element in the set of matched elements.
|
||||
*
|
||||
* @param func A function returning the width to set. Receives the index position of the element in the set and the old width as arguments. Within the function, this refers to the current element in the set.
|
||||
*/
|
||||
width(func: (index: number, width: string) => string): JQuery;
|
||||
/**
|
||||
* Set the CSS width of each element in the set of matched elements.
|
||||
*
|
||||
* @param func A function returning the width to set. Receives the index position of the element in the set and the old width as arguments. Within the function, this refers to the current element in the set.
|
||||
*/
|
||||
width(func: (index: number, width: string) => number): JQuery;
|
||||
/**
|
||||
* Set the CSS width of each element in the set of matched elements.
|
||||
*
|
||||
* @param func A function returning the width to set. Receives the index position of the element in the set and the old width as arguments. Within the function, this refers to the current element in the set.
|
||||
*/
|
||||
width(func: (index: number, width: number) => string): JQuery;
|
||||
|
||||
// Data
|
||||
clearQueue(queueName?: string): JQuery;
|
||||
|
||||
Reference in New Issue
Block a user