Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
1ebced17
Commit
1ebced17
authored
Sep 30, 2011
by
timmywil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for calling outer/inner Width/Height on the window and document. Fixes #9434.
parent
96a44a86
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
18 deletions
+35
-18
dimensions.js
src/dimensions.js
+6
-2
dimensions.js
test/unit/dimensions.js
+29
-16
No files found.
src/dimensions.js
View file @
1ebced17
...
@@ -8,16 +8,20 @@ jQuery.each([ "Height", "Width" ], function( i, name ) {
...
@@ -8,16 +8,20 @@ jQuery.each([ "Height", "Width" ], function( i, name ) {
// innerHeight and innerWidth
// innerHeight and innerWidth
jQuery
.
fn
[
"inner"
+
name
]
=
function
()
{
jQuery
.
fn
[
"inner"
+
name
]
=
function
()
{
var
elem
=
this
[
0
];
var
elem
=
this
[
0
];
return
elem
&&
elem
.
style
?
return
elem
?
elem
.
style
?
parseFloat
(
jQuery
.
css
(
elem
,
type
,
"padding"
)
)
:
parseFloat
(
jQuery
.
css
(
elem
,
type
,
"padding"
)
)
:
this
[
type
]()
:
null
;
null
;
};
};
// outerHeight and outerWidth
// outerHeight and outerWidth
jQuery
.
fn
[
"outer"
+
name
]
=
function
(
margin
)
{
jQuery
.
fn
[
"outer"
+
name
]
=
function
(
margin
)
{
var
elem
=
this
[
0
];
var
elem
=
this
[
0
];
return
elem
&&
elem
.
style
?
return
elem
?
elem
.
style
?
parseFloat
(
jQuery
.
css
(
elem
,
type
,
margin
?
"margin"
:
"border"
)
)
:
parseFloat
(
jQuery
.
css
(
elem
,
type
,
margin
?
"margin"
:
"border"
)
)
:
this
[
type
]()
:
null
;
null
;
};
};
...
...
test/unit/dimensions.js
View file @
1ebced17
...
@@ -109,11 +109,14 @@ test("height() with function args", function() {
...
@@ -109,11 +109,14 @@ test("height() with function args", function() {
test
(
"innerWidth()"
,
function
()
{
test
(
"innerWidth()"
,
function
()
{
expect
(
8
);
expect
(
8
);
equals
(
jQuery
(
window
).
innerWidth
(),
null
,
"Test on window without margin option"
);
var
winWidth
=
jQuery
(
window
).
width
(),
equals
(
jQuery
(
window
).
innerWidth
(
true
),
null
,
"Test on window with margin option"
);
docWidth
=
jQuery
(
document
).
width
(
);
equals
(
jQuery
(
document
).
innerWidth
(),
null
,
"Test on document without margin option"
);
equals
(
jQuery
(
window
).
innerWidth
(),
winWidth
,
"Test on window without margin option"
);
equals
(
jQuery
(
document
).
innerWidth
(
true
),
null
,
"Test on document with margin option"
);
equals
(
jQuery
(
window
).
innerWidth
(
true
),
winWidth
,
"Test on window with margin option"
);
equals
(
jQuery
(
document
).
innerWidth
(),
docWidth
,
"Test on document without margin option"
);
equals
(
jQuery
(
document
).
innerWidth
(
true
),
docWidth
,
"Test on document with margin option"
);
var
$div
=
jQuery
(
"#nothiddendiv"
);
var
$div
=
jQuery
(
"#nothiddendiv"
);
// set styles
// set styles
...
@@ -144,11 +147,14 @@ test("innerWidth()", function() {
...
@@ -144,11 +147,14 @@ test("innerWidth()", function() {
test
(
"innerHeight()"
,
function
()
{
test
(
"innerHeight()"
,
function
()
{
expect
(
8
);
expect
(
8
);
equals
(
jQuery
(
window
).
innerHeight
(),
null
,
"Test on window without margin option"
);
var
winHeight
=
jQuery
(
window
).
height
(),
equals
(
jQuery
(
window
).
innerHeight
(
true
),
null
,
"Test on window with margin option"
);
docHeight
=
jQuery
(
document
).
height
();
equals
(
jQuery
(
window
).
innerHeight
(),
winHeight
,
"Test on window without margin option"
);
equals
(
jQuery
(
window
).
innerHeight
(
true
),
winHeight
,
"Test on window with margin option"
);
equals
(
jQuery
(
document
).
innerHeight
(),
null
,
"Test on document without margin option"
);
equals
(
jQuery
(
document
).
innerHeight
(),
docHeight
,
"Test on document without margin option"
);
equals
(
jQuery
(
document
).
innerHeight
(
true
),
null
,
"Test on document with margin option"
);
equals
(
jQuery
(
document
).
innerHeight
(
true
),
docHeight
,
"Test on document with margin option"
);
var
$div
=
jQuery
(
"#nothiddendiv"
);
var
$div
=
jQuery
(
"#nothiddendiv"
);
// set styles
// set styles
...
@@ -179,10 +185,13 @@ test("innerHeight()", function() {
...
@@ -179,10 +185,13 @@ test("innerHeight()", function() {
test
(
"outerWidth()"
,
function
()
{
test
(
"outerWidth()"
,
function
()
{
expect
(
11
);
expect
(
11
);
equal
(
jQuery
(
window
).
outerWidth
(),
null
,
"Test on window without margin option"
);
var
winWidth
=
jQuery
(
window
).
width
(),
equal
(
jQuery
(
window
).
outerWidth
(
true
),
null
,
"Test on window with margin option"
);
docWidth
=
jQuery
(
document
).
width
();
equal
(
jQuery
(
document
).
outerWidth
(),
null
,
"Test on document without margin option"
);
equal
(
jQuery
(
document
).
outerWidth
(
true
),
null
,
"Test on document with margin option"
);
equal
(
jQuery
(
window
).
outerWidth
(),
winWidth
,
"Test on window without margin option"
);
equal
(
jQuery
(
window
).
outerWidth
(
true
),
winWidth
,
"Test on window with margin option"
);
equal
(
jQuery
(
document
).
outerWidth
(),
docWidth
,
"Test on document without margin option"
);
equal
(
jQuery
(
document
).
outerWidth
(
true
),
docWidth
,
"Test on document with margin option"
);
var
$div
=
jQuery
(
"#nothiddendiv"
);
var
$div
=
jQuery
(
"#nothiddendiv"
);
$div
.
css
(
"width"
,
30
);
$div
.
css
(
"width"
,
30
);
...
@@ -239,10 +248,14 @@ test("child of a hidden elem has accurate inner/outer/Width()/Height() see #944
...
@@ -239,10 +248,14 @@ test("child of a hidden elem has accurate inner/outer/Width()/Height() see #944
test
(
"outerHeight()"
,
function
()
{
test
(
"outerHeight()"
,
function
()
{
expect
(
11
);
expect
(
11
);
equal
(
jQuery
(
window
).
outerHeight
(),
null
,
"Test on window without margin option"
);
var
winHeight
=
jQuery
(
window
).
height
(),
equal
(
jQuery
(
window
).
outerHeight
(
true
),
null
,
"Test on window with margin option"
);
docHeight
=
jQuery
(
document
).
height
();
equal
(
jQuery
(
document
).
outerHeight
(),
null
,
"Test on document without margin option"
);
equal
(
jQuery
(
document
).
outerHeight
(
true
),
null
,
"Test on document with margin option"
);
equal
(
jQuery
(
window
).
outerHeight
(),
winHeight
,
"Test on window without margin option"
);
equal
(
jQuery
(
window
).
outerHeight
(
true
),
winHeight
,
"Test on window with margin option"
);
equal
(
jQuery
(
document
).
outerHeight
(),
docHeight
,
"Test on document without margin option"
);
equal
(
jQuery
(
document
).
outerHeight
(
true
),
docHeight
,
"Test on document with margin option"
);
var
$div
=
jQuery
(
"#nothiddendiv"
);
var
$div
=
jQuery
(
"#nothiddendiv"
);
$div
.
css
(
"height"
,
30
);
$div
.
css
(
"height"
,
30
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment