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
9a3683b1
Commit
9a3683b1
authored
May 11, 2013
by
Jason Bedard
Committed by
Dave Methvin
Jun 03, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid jQuery(this) and a closure for .toggle(Boolean), close gh-1271.
(cherry picked from commit
e53a9190
)
parent
adf30903
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
7 deletions
+14
-7
attributes.js
src/attributes.js
+10
-5
css.js
src/css.js
+4
-2
No files found.
src/attributes.js
View file @
9a3683b1
...
@@ -111,8 +111,11 @@ jQuery.fn.extend({
...
@@ -111,8 +111,11 @@ jQuery.fn.extend({
},
},
toggleClass
:
function
(
value
,
stateVal
)
{
toggleClass
:
function
(
value
,
stateVal
)
{
var
type
=
typeof
value
,
var
type
=
typeof
value
;
isBool
=
typeof
stateVal
===
"boolean"
;
if
(
typeof
stateVal
===
"boolean"
&&
type
===
"string"
)
{
return
stateVal
?
this
.
addClass
(
value
)
:
this
.
removeClass
(
value
);
}
if
(
jQuery
.
isFunction
(
value
)
)
{
if
(
jQuery
.
isFunction
(
value
)
)
{
return
this
.
each
(
function
(
i
)
{
return
this
.
each
(
function
(
i
)
{
...
@@ -126,13 +129,15 @@ jQuery.fn.extend({
...
@@ -126,13 +129,15 @@ jQuery.fn.extend({
var
className
,
var
className
,
i
=
0
,
i
=
0
,
self
=
jQuery
(
this
),
self
=
jQuery
(
this
),
state
=
stateVal
,
classNames
=
value
.
match
(
core_rnotwhite
)
||
[];
classNames
=
value
.
match
(
core_rnotwhite
)
||
[];
while
(
(
className
=
classNames
[
i
++
])
)
{
while
(
(
className
=
classNames
[
i
++
])
)
{
// check each className given, space separated list
// check each className given, space separated list
state
=
isBool
?
state
:
!
self
.
hasClass
(
className
);
if
(
self
.
hasClass
(
className
)
)
{
self
[
state
?
"addClass"
:
"removeClass"
](
className
);
self
.
removeClass
(
className
);
}
else
{
self
.
addClass
(
className
);
}
}
}
// Toggle whole class name
// Toggle whole class name
...
...
src/css.js
View file @
9a3683b1
...
@@ -134,10 +134,12 @@ jQuery.fn.extend({
...
@@ -134,10 +134,12 @@ jQuery.fn.extend({
return
showHide
(
this
);
return
showHide
(
this
);
},
},
toggle
:
function
(
state
)
{
toggle
:
function
(
state
)
{
var
bool
=
typeof
state
===
"boolean"
;
if
(
typeof
state
===
"boolean"
)
{
return
state
?
this
.
show
()
:
this
.
hide
();
}
return
this
.
each
(
function
()
{
return
this
.
each
(
function
()
{
if
(
bool
?
state
:
isHidden
(
this
)
)
{
if
(
isHidden
(
this
)
)
{
jQuery
(
this
).
show
();
jQuery
(
this
).
show
();
}
else
{
}
else
{
jQuery
(
this
).
hide
();
jQuery
(
this
).
hide
();
...
...
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