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
543db644
Commit
543db644
authored
Oct 09, 2010
by
Colin Snover
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed code convention issues. Reduced size of overflow reset code. Fixed broken show() test cases.
parent
91028794
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
43 deletions
+44
-43
effects.js
src/effects.js
+26
-24
support.js
src/support.js
+10
-10
effects.js
test/unit/effects.js
+8
-9
No files found.
src/effects.js
View file @
543db644
...
@@ -13,23 +13,6 @@ var elemdisplay = {},
...
@@ -13,23 +13,6 @@ var elemdisplay = {},
[
"opacity"
]
[
"opacity"
]
];
];
function
defaultDisplay
(
nodeName
)
{
if
(
!
elemdisplay
[
nodeName
]
)
{
var
elem
=
jQuery
(
"<"
+
nodeName
+
">"
).
appendTo
(
"body"
),
display
=
elem
.
css
(
"display"
);
elem
.
remove
();
if
(
display
===
"none"
||
display
===
""
)
{
display
=
"block"
;
}
elemdisplay
[
nodeName
]
=
display
;
}
return
elemdisplay
[
nodeName
];
}
jQuery
.
fn
.
extend
({
jQuery
.
fn
.
extend
({
show
:
function
(
speed
,
easing
,
callback
)
{
show
:
function
(
speed
,
easing
,
callback
)
{
if
(
speed
||
speed
===
0
)
{
if
(
speed
||
speed
===
0
)
{
...
@@ -45,7 +28,7 @@ jQuery.fn.extend({
...
@@ -45,7 +28,7 @@ jQuery.fn.extend({
// Set elements which have been overridden with display: none
// Set elements which have been overridden with display: none
// in a stylesheet to whatever the default browser style is
// in a stylesheet to whatever the default browser style is
// for such an element
// for such an element
if
(
jQuery
.
css
(
this
[
i
],
"display"
)
===
"none"
&&
this
[
i
].
style
.
display
===
"
"
)
{
if
(
this
[
i
].
style
.
display
===
""
&&
jQuery
.
css
(
this
[
i
],
"display"
)
===
"none
"
)
{
jQuery
.
data
(
this
[
i
],
"olddisplay"
,
defaultDisplay
(
this
[
i
].
nodeName
));
jQuery
.
data
(
this
[
i
],
"olddisplay"
,
defaultDisplay
(
this
[
i
].
nodeName
));
}
}
}
}
...
@@ -152,6 +135,7 @@ jQuery.fn.extend({
...
@@ -152,6 +135,7 @@ jQuery.fn.extend({
jQuery
.
css
(
this
,
"float"
)
===
"none"
)
{
jQuery
.
css
(
this
,
"float"
)
===
"none"
)
{
if
(
!
jQuery
.
support
.
inlineBlockNeedsLayout
)
{
if
(
!
jQuery
.
support
.
inlineBlockNeedsLayout
)
{
this
.
style
.
display
=
"inline-block"
;
this
.
style
.
display
=
"inline-block"
;
}
else
{
}
else
{
var
display
=
defaultDisplay
(
this
.
nodeName
);
var
display
=
defaultDisplay
(
this
.
nodeName
);
...
@@ -159,8 +143,8 @@ jQuery.fn.extend({
...
@@ -159,8 +143,8 @@ jQuery.fn.extend({
// block-level elements need to be inline with layout
// block-level elements need to be inline with layout
if
(
display
===
"inline"
)
{
if
(
display
===
"inline"
)
{
this
.
style
.
display
=
"inline-block"
;
this
.
style
.
display
=
"inline-block"
;
}
else
{
}
else
{
this
.
style
.
display
=
"inline"
;
this
.
style
.
display
=
"inline"
;
this
.
style
.
zoom
=
1
;
this
.
style
.
zoom
=
1
;
}
}
...
@@ -409,9 +393,10 @@ jQuery.fx.prototype = {
...
@@ -409,9 +393,10 @@ jQuery.fx.prototype = {
if
(
done
)
{
if
(
done
)
{
// Reset the overflow
// Reset the overflow
if
(
this
.
options
.
overflow
!=
null
&&
!
jQuery
.
support
.
shrinkWrapBlocks
)
{
if
(
this
.
options
.
overflow
!=
null
&&
!
jQuery
.
support
.
shrinkWrapBlocks
)
{
this
.
elem
.
style
.
overflow
=
this
.
options
.
overflow
[
0
];
var
elem
=
this
.
elem
,
options
=
this
.
options
;
this
.
elem
.
style
.
overflowX
=
this
.
options
.
overflow
[
1
];
jQuery
.
each
(
[
""
,
"X"
,
"Y"
],
function
(
index
,
value
)
{
this
.
elem
.
style
.
overflowY
=
this
.
options
.
overflow
[
2
];
elem
.
style
[
"overflow"
+
value
]
=
options
.
overflow
[
index
];
}
);
}
}
// Hide the element if the "hide" operation was done
// Hide the element if the "hide" operation was done
...
@@ -502,4 +487,21 @@ if ( jQuery.expr && jQuery.expr.filters ) {
...
@@ -502,4 +487,21 @@ if ( jQuery.expr && jQuery.expr.filters ) {
};
};
}
}
function
defaultDisplay
(
nodeName
)
{
if
(
!
elemdisplay
[
nodeName
]
)
{
var
elem
=
jQuery
(
"<"
+
nodeName
+
">"
).
appendTo
(
"body"
),
display
=
elem
.
css
(
"display"
);
elem
.
remove
();
if
(
display
===
"none"
||
display
===
""
)
{
display
=
"block"
;
}
elemdisplay
[
nodeName
]
=
display
;
}
return
elemdisplay
[
nodeName
];
}
})(
jQuery
);
})(
jQuery
);
src/support.js
View file @
543db644
...
@@ -121,24 +121,24 @@
...
@@ -121,24 +121,24 @@
document
.
body
.
appendChild
(
div
);
document
.
body
.
appendChild
(
div
);
jQuery
.
boxModel
=
jQuery
.
support
.
boxModel
=
div
.
offsetWidth
===
2
;
jQuery
.
boxModel
=
jQuery
.
support
.
boxModel
=
div
.
offsetWidth
===
2
;
if
(
'zoom'
in
div
.
style
)
{
if
(
"zoom"
in
div
.
style
)
{
// Check if natively block-level elements act like inline-block
// Check if natively block-level elements act like inline-block
// elements when setting their display to 'inline' and giving
// elements when setting their display to 'inline' and giving
// them layout
// them layout
// (IE < 8 does this)
// (IE < 8 does this)
div
.
style
.
display
=
'inline'
;
div
.
style
.
display
=
"inline"
;
div
.
style
.
zoom
=
1
;
div
.
style
.
zoom
=
1
;
jQuery
.
support
.
inlineBlockNeedsLayout
=
div
.
offsetWidth
===
2
;
jQuery
.
support
.
inlineBlockNeedsLayout
=
div
.
offsetWidth
===
2
;
// Check if elements with layout shrink-wrap their children
// Check if elements with layout shrink-wrap their children
// (IE 6 does this)
// (IE 6 does this)
div
.
style
.
display
=
''
;
div
.
style
.
display
=
""
;
div
.
innerHTML
=
'<div style="width:4px;"></div>'
;
div
.
innerHTML
=
"<div style='width:4px;'></div>"
;
jQuery
.
support
.
shrinkWrapBlocks
=
div
.
offsetWidth
!==
2
;
jQuery
.
support
.
shrinkWrapBlocks
=
div
.
offsetWidth
!==
2
;
}
}
div
.
innerHTML
=
'<table><tr><td style="padding:0;display:none"></td><td>t</td></tr></table>'
;
div
.
innerHTML
=
"<table><tr><td style='padding:0;display:none'></td><td>t</td></tr></table>"
;
var
tds
=
div
.
getElementsByTagName
(
'td'
);
var
tds
=
div
.
getElementsByTagName
(
"td"
);
// Check if table cells still have offsetWidth/Height when they are set
// Check if table cells still have offsetWidth/Height when they are set
// to display:none and there are still other visible table cells in a
// to display:none and there are still other visible table cells in a
...
@@ -149,15 +149,15 @@
...
@@ -149,15 +149,15 @@
// (only IE 8 fails this test)
// (only IE 8 fails this test)
jQuery
.
support
.
reliableHiddenOffsets
=
tds
[
0
].
offsetHeight
===
0
;
jQuery
.
support
.
reliableHiddenOffsets
=
tds
[
0
].
offsetHeight
===
0
;
tds
[
0
].
style
.
display
=
''
;
tds
[
0
].
style
.
display
=
""
;
tds
[
1
].
style
.
display
=
'none'
;
tds
[
1
].
style
.
display
=
"none"
;
// Check if empty table cells still have offsetWidth/Height
// Check if empty table cells still have offsetWidth/Height
// (IE < 8 fail this test)
// (IE < 8 fail this test)
jQuery
.
support
.
reliableHiddenOffsets
=
jQuery
.
support
.
reliableHiddenOffsets
&&
tds
[
0
].
offsetHeight
===
0
;
jQuery
.
support
.
reliableHiddenOffsets
=
jQuery
.
support
.
reliableHiddenOffsets
&&
tds
[
0
].
offsetHeight
===
0
;
div
.
innerHTML
=
''
;
div
.
innerHTML
=
""
;
document
.
body
.
removeChild
(
div
).
style
.
display
=
'none'
;
document
.
body
.
removeChild
(
div
).
style
.
display
=
"none"
;
div
=
tds
=
null
;
div
=
tds
=
null
;
});
});
...
...
test/unit/effects.js
View file @
543db644
...
@@ -38,9 +38,10 @@ test("show()", function() {
...
@@ -38,9 +38,10 @@ test("show()", function() {
});
});
// #show-tests * is set display: none in CSS
// #show-tests * is set display: none in CSS
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>
<table id="test-table"></table>
'
);
var
old
=
jQuery
(
"#show-tests table"
).
show
().
css
(
"display"
)
!==
"table"
;
var
old
=
jQuery
(
"#test-table"
).
show
().
css
(
"display"
)
!==
"table"
;
jQuery
(
"#test-table"
).
remove
();
var
test
=
{
var
test
=
{
"div"
:
"block"
,
"div"
:
"block"
,
...
@@ -71,10 +72,11 @@ test("show(Number) - other displays", function() {
...
@@ -71,10 +72,11 @@ test("show(Number) - other displays", function() {
stop
();
stop
();
// #show-tests * is set display: none in CSS
// #show-tests * is set display: none in CSS
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>
<table id="test-table"></table>
'
);
var
old
=
jQuery
(
"#
show-tests
table"
).
show
().
css
(
"display"
)
!==
"table"
,
var
old
=
jQuery
(
"#
test-
table"
).
show
().
css
(
"display"
)
!==
"table"
,
num
=
0
;
num
=
0
;
jQuery
(
"#test-table"
).
remove
();
var
test
=
{
var
test
=
{
"div"
:
"block"
,
"div"
:
"block"
,
...
@@ -94,10 +96,7 @@ test("show(Number) - other displays", function() {
...
@@ -94,10 +96,7 @@ test("show(Number) - other displays", function() {
};
};
jQuery
.
each
(
test
,
function
(
selector
,
expected
)
{
jQuery
.
each
(
test
,
function
(
selector
,
expected
)
{
// IE sometimes has issues with chained functions referencing
var
elem
=
jQuery
(
selector
,
"#show-tests"
).
show
(
1
,
function
()
{
// assignments from outside the closure
var
elem
=
jQuery
(
selector
,
"#show-tests"
);
elem
.
show
(
1
,
function
()
{
equals
(
elem
.
css
(
"display"
),
expected
,
"Show using correct display type for "
+
selector
);
equals
(
elem
.
css
(
"display"
),
expected
,
"Show using correct display type for "
+
selector
);
if
(
++
num
===
15
)
{
if
(
++
num
===
15
)
{
start
();
start
();
...
...
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