jQuery: JSDoc'd width + added width test suite

This commit is contained in:
johnnyreilly
2014-01-01 15:48:56 +00:00
parent f6e89c970d
commit 6baada500f
2 changed files with 64 additions and 1 deletions

View File

@@ -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
View File

@@ -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;