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
8ea634fd
Commit
8ea634fd
authored
Jan 23, 2010
by
jeresig
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:jquery/jquery
parents
f6ec9d54
2c28f229
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
15 deletions
+40
-15
effects.js
src/effects.js
+2
-2
offset.js
src/offset.js
+8
-8
effects.js
test/unit/effects.js
+23
-5
offset.js
test/unit/offset.js
+7
-0
No files found.
src/effects.js
View file @
8ea634fd
...
@@ -13,7 +13,7 @@ var elemdisplay = {},
...
@@ -13,7 +13,7 @@ var elemdisplay = {},
jQuery
.
fn
.
extend
({
jQuery
.
fn
.
extend
({
show
:
function
(
speed
,
callback
)
{
show
:
function
(
speed
,
callback
)
{
if
(
speed
!=
null
)
{
if
(
speed
||
speed
===
0
)
{
return
this
.
animate
(
genFx
(
"show"
,
3
),
speed
,
callback
);
return
this
.
animate
(
genFx
(
"show"
,
3
),
speed
,
callback
);
}
else
{
}
else
{
...
@@ -57,7 +57,7 @@ jQuery.fn.extend({
...
@@ -57,7 +57,7 @@ jQuery.fn.extend({
},
},
hide
:
function
(
speed
,
callback
)
{
hide
:
function
(
speed
,
callback
)
{
if
(
speed
!=
null
)
{
if
(
speed
||
speed
===
0
)
{
return
this
.
animate
(
genFx
(
"hide"
,
3
),
speed
,
callback
);
return
this
.
animate
(
genFx
(
"hide"
,
3
),
speed
,
callback
);
}
else
{
}
else
{
...
...
src/offset.js
View file @
8ea634fd
...
@@ -2,16 +2,16 @@ if ( "getBoundingClientRect" in document.documentElement ) {
...
@@ -2,16 +2,16 @@ if ( "getBoundingClientRect" in document.documentElement ) {
jQuery
.
fn
.
offset
=
function
(
options
)
{
jQuery
.
fn
.
offset
=
function
(
options
)
{
var
elem
=
this
[
0
];
var
elem
=
this
[
0
];
if
(
!
elem
||
!
elem
.
ownerDocument
)
{
return
null
;
}
if
(
options
)
{
if
(
options
)
{
return
this
.
each
(
function
(
i
)
{
return
this
.
each
(
function
(
i
)
{
jQuery
.
offset
.
setOffset
(
this
,
options
,
i
);
jQuery
.
offset
.
setOffset
(
this
,
options
,
i
);
});
});
}
}
if
(
!
elem
||
!
elem
.
ownerDocument
)
{
return
null
;
}
if
(
elem
===
elem
.
ownerDocument
.
body
)
{
if
(
elem
===
elem
.
ownerDocument
.
body
)
{
return
jQuery
.
offset
.
bodyOffset
(
elem
);
return
jQuery
.
offset
.
bodyOffset
(
elem
);
}
}
...
@@ -28,16 +28,16 @@ if ( "getBoundingClientRect" in document.documentElement ) {
...
@@ -28,16 +28,16 @@ if ( "getBoundingClientRect" in document.documentElement ) {
jQuery
.
fn
.
offset
=
function
(
options
)
{
jQuery
.
fn
.
offset
=
function
(
options
)
{
var
elem
=
this
[
0
];
var
elem
=
this
[
0
];
if
(
!
elem
||
!
elem
.
ownerDocument
)
{
return
null
;
}
if
(
options
)
{
if
(
options
)
{
return
this
.
each
(
function
(
i
)
{
return
this
.
each
(
function
(
i
)
{
jQuery
.
offset
.
setOffset
(
this
,
options
,
i
);
jQuery
.
offset
.
setOffset
(
this
,
options
,
i
);
});
});
}
}
if
(
!
elem
||
!
elem
.
ownerDocument
)
{
return
null
;
}
if
(
elem
===
elem
.
ownerDocument
.
body
)
{
if
(
elem
===
elem
.
ownerDocument
.
body
)
{
return
jQuery
.
offset
.
bodyOffset
(
elem
);
return
jQuery
.
offset
.
bodyOffset
(
elem
);
}
}
...
...
test/unit/effects.js
View file @
8ea634fd
module
(
"effects"
);
module
(
"effects"
);
test
(
"show()"
,
function
()
{
test
(
"show()"
,
function
()
{
expect
(
16
);
expect
(
23
);
var
pass
=
true
,
div
=
jQuery
(
"#main div"
);
var
pass
=
true
,
div
=
jQuery
(
"#main div"
);
div
.
show
().
each
(
function
(){
div
.
show
().
each
(
function
(){
if
(
this
.
style
.
display
==
"none"
)
pass
=
false
;
if
(
this
.
style
.
display
==
"none"
)
pass
=
false
;
});
});
ok
(
pass
,
"Show"
);
ok
(
pass
,
"Show"
);
pass
=
true
;
var
speeds
=
{
div
.
hide
().
show
(
null
).
each
(
function
()
{
"null speed"
:
null
,
if
(
this
.
style
.
display
==
"none"
)
pass
=
false
;
"undefined speed"
:
undefined
,
"empty string speed"
:
""
,
"false speed"
:
false
};
jQuery
.
each
(
speeds
,
function
(
name
,
speed
)
{
pass
=
true
;
div
.
hide
().
show
(
speed
).
each
(
function
()
{
if
(
this
.
style
.
display
==
"none"
)
pass
=
false
;
});
ok
(
pass
,
"Show with "
+
name
);
});
jQuery
.
each
(
speeds
,
function
(
name
,
speed
)
{
pass
=
true
;
div
.
hide
().
show
(
speed
,
function
()
{
pass
=
false
;
});
ok
(
pass
,
"Show with "
+
name
+
" does not call animate callback"
);
});
});
ok
(
pass
,
"Show will null speed"
);
jQuery
(
"#main"
).
append
(
'<div id="show-tests"><div><p><a href="#"></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div>'
);
jQuery
(
"#main"
).
append
(
'<div id="show-tests"><div><p><a href="#"></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div>'
);
...
...
test/unit/offset.js
View file @
8ea634fd
...
@@ -305,6 +305,13 @@ testoffset("body", function( jQuery ) {
...
@@ -305,6 +305,13 @@ testoffset("body", function( jQuery ) {
equals
(
jQuery
(
'body'
).
offset
().
left
,
1
,
"jQuery('#body').offset().left"
);
equals
(
jQuery
(
'body'
).
offset
().
left
,
1
,
"jQuery('#body').offset().left"
);
});
});
test
(
"Chaining offset(coords) returns jQuery object"
,
function
()
{
expect
(
2
);
var
coords
=
{
top
:
1
,
left
:
1
};
equals
(
jQuery
(
"#absolute-1"
).
offset
(
coords
).
selector
,
"#absolute-1"
,
"offset(coords) returns jQuery object"
);
equals
(
jQuery
(
"#non-existent"
).
offset
(
coords
).
selector
,
"#non-existent"
,
"offset(coords) with empty jQuery set returns jQuery object"
);
});
test
(
"offsetParent"
,
function
(){
test
(
"offsetParent"
,
function
(){
expect
(
11
);
expect
(
11
);
...
...
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