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
627a32ce
Commit
627a32ce
authored
Jul 19, 2009
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Broke out some of the inline RegExp from css.js. Goes towards fixing #4111.
parent
4d1f15c3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
12 deletions
+20
-12
css.js
src/css.js
+20
-12
No files found.
src/css.js
View file @
627a32ce
// exclude the following css properties to add px
// exclude the following css properties to add px
var
exclude
=
/z-
?
index|font-
?
weight|opacity|zoom|line-
?
height/i
,
var
rexclude
=
/z-
?
index|font-
?
weight|opacity|zoom|line-
?
height/i
,
ralpha
=
/alpha
\([^
)
]
*
\)
/
,
ropacity
=
/opacity=
([^
)
]
*
)
/
,
rfloat
=
/float/i
,
rdashAlpha
=
/-
([
a-z
])
/ig
,
rupper
=
/
([
A-Z
])
/g
,
rnumpx
=
/^
\d
+
(?:
px
)?
$/i
,
rnum
=
/^
\d
/
,
// cache check for defaultView.getComputedStyle
// cache check for defaultView.getComputedStyle
getComputedStyle
=
document
.
defaultView
&&
document
.
defaultView
.
getComputedStyle
,
getComputedStyle
=
document
.
defaultView
&&
document
.
defaultView
.
getComputedStyle
,
// normalize float css property
// normalize float css property
...
@@ -45,7 +53,7 @@ jQuery.fn.css = function( name, value ) {
...
@@ -45,7 +53,7 @@ jQuery.fn.css = function( name, value ) {
value
=
value
.
call
(
elem
,
i
);
value
=
value
.
call
(
elem
,
i
);
}
}
if
(
typeof
value
===
"number"
&&
!
exclude
.
test
(
prop
)
)
{
if
(
typeof
value
===
"number"
&&
!
r
exclude
.
test
(
prop
)
)
{
value
=
value
+
"px"
;
value
=
value
+
"px"
;
}
}
...
@@ -78,21 +86,21 @@ jQuery.extend({
...
@@ -78,21 +86,21 @@ jQuery.extend({
style
.
zoom
=
1
;
style
.
zoom
=
1
;
// Set the alpha filter to set the opacity
// Set the alpha filter to set the opacity
style
.
filter
=
(
style
.
filter
||
""
).
replace
(
/alpha
\([^
)
]
*
\)
/
,
""
)
+
style
.
filter
=
(
style
.
filter
||
""
).
replace
(
ralpha
,
""
)
+
(
parseInt
(
value
)
+
''
===
"NaN"
?
""
:
"alpha(opacity="
+
value
*
100
+
")"
);
(
parseInt
(
value
)
+
''
===
"NaN"
?
""
:
"alpha(opacity="
+
value
*
100
+
")"
);
}
}
return
style
.
filter
&&
style
.
filter
.
indexOf
(
"opacity="
)
>=
0
?
return
style
.
filter
&&
style
.
filter
.
indexOf
(
"opacity="
)
>=
0
?
(
parseFloat
(
/opacity=
([^
)
]
*
)
/
.
exec
(
style
.
filter
)[
1
]
)
/
100
)
+
''
:
(
parseFloat
(
ropacity
.
exec
(
style
.
filter
)[
1
]
)
/
100
)
+
''
:
""
;
""
;
}
}
// Make sure we're using the right name for getting the float value
// Make sure we're using the right name for getting the float value
if
(
/float/i
.
test
(
name
)
)
{
if
(
rfloat
.
test
(
name
)
)
{
name
=
styleFloat
;
name
=
styleFloat
;
}
}
name
=
name
.
replace
(
/-
([
a-z
])
/ig
,
fcamelCase
);
name
=
name
.
replace
(
rdashAlpha
,
fcamelCase
);
if
(
set
)
{
if
(
set
)
{
style
[
name
]
=
value
;
style
[
name
]
=
value
;
...
@@ -140,7 +148,7 @@ jQuery.extend({
...
@@ -140,7 +148,7 @@ jQuery.extend({
// IE uses filters for opacity
// IE uses filters for opacity
if
(
!
jQuery
.
support
.
opacity
&&
name
===
"opacity"
&&
elem
.
currentStyle
)
{
if
(
!
jQuery
.
support
.
opacity
&&
name
===
"opacity"
&&
elem
.
currentStyle
)
{
ret
=
/opacity=
([^
)
]
*
)
/
.
test
(
elem
.
currentStyle
.
filter
||
""
)
?
ret
=
ropacity
.
test
(
elem
.
currentStyle
.
filter
||
""
)
?
(
parseFloat
(
RegExp
.
$1
)
/
100
)
+
""
:
(
parseFloat
(
RegExp
.
$1
)
/
100
)
+
""
:
""
;
""
;
...
@@ -150,7 +158,7 @@ jQuery.extend({
...
@@ -150,7 +158,7 @@ jQuery.extend({
}
}
// Make sure we're using the right name for getting the float value
// Make sure we're using the right name for getting the float value
if
(
/float/i
.
test
(
name
)
)
{
if
(
rfloat
.
test
(
name
)
)
{
name
=
styleFloat
;
name
=
styleFloat
;
}
}
...
@@ -160,11 +168,11 @@ jQuery.extend({
...
@@ -160,11 +168,11 @@ jQuery.extend({
}
else
if
(
getComputedStyle
)
{
}
else
if
(
getComputedStyle
)
{
// Only "float" is needed here
// Only "float" is needed here
if
(
/float/i
.
test
(
name
)
)
{
if
(
rfloat
.
test
(
name
)
)
{
name
=
"float"
;
name
=
"float"
;
}
}
name
=
name
.
replace
(
/
([
A-Z
])
/g
,
"-$1"
).
toLowerCase
();
name
=
name
.
replace
(
rupper
,
"-$1"
).
toLowerCase
();
var
computedStyle
=
elem
.
ownerDocument
.
defaultView
.
getComputedStyle
(
elem
,
null
);
var
computedStyle
=
elem
.
ownerDocument
.
defaultView
.
getComputedStyle
(
elem
,
null
);
...
@@ -178,7 +186,7 @@ jQuery.extend({
...
@@ -178,7 +186,7 @@ jQuery.extend({
}
}
}
else
if
(
elem
.
currentStyle
)
{
}
else
if
(
elem
.
currentStyle
)
{
var
camelCase
=
name
.
replace
(
/
\-(\w)
/g
,
fcamelCase
);
var
camelCase
=
name
.
replace
(
rdashAlpha
,
fcamelCase
);
ret
=
elem
.
currentStyle
[
name
]
||
elem
.
currentStyle
[
camelCase
];
ret
=
elem
.
currentStyle
[
name
]
||
elem
.
currentStyle
[
camelCase
];
...
@@ -187,7 +195,7 @@ jQuery.extend({
...
@@ -187,7 +195,7 @@ jQuery.extend({
// If we're not dealing with a regular pixel number
// If we're not dealing with a regular pixel number
// but a number that has a weird ending, we need to convert it to pixels
// but a number that has a weird ending, we need to convert it to pixels
if
(
!
/^
\d
+
(
px
)?
$/i
.
test
(
ret
)
&&
/^
\d
/
.
test
(
ret
)
)
{
if
(
!
rnumpx
.
test
(
ret
)
&&
rnum
.
test
(
ret
)
)
{
// Remember the original values
// Remember the original values
var
left
=
style
.
left
,
rsLeft
=
elem
.
runtimeStyle
.
left
;
var
left
=
style
.
left
,
rsLeft
=
elem
.
runtimeStyle
.
left
;
...
...
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