Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bootstrap
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
bootstrap
Commits
e9a648cd
Commit
e9a648cd
authored
Sep 27, 2012
by
Erlend Halvorsen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug in dropdown toggle where menu would only clear on the first drop down
parent
0540b63a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
10 deletions
+53
-10
docs/assets/js/bootstrap-dropdown.js
docs/assets/js/bootstrap-dropdown.js
+4
-3
docs/assets/js/bootstrap.js
docs/assets/js/bootstrap.js
+4
-3
js/bootstrap-dropdown.js
js/bootstrap-dropdown.js
+4
-3
js/tests/unit/bootstrap-dropdown.js
js/tests/unit/bootstrap-dropdown.js
+41
-1
No files found.
docs/assets/js/bootstrap-dropdown.js
View file @
e9a648cd
...
@@ -100,8 +100,9 @@
...
@@ -100,8 +100,9 @@
}
}
function
clearMenus
()
{
function
clearMenus
()
{
getParent
(
$
(
toggle
))
$
(
toggle
).
each
(
function
()
{
.
removeClass
(
'
open
'
)
getParent
(
$
(
this
)).
removeClass
(
"
open
"
)
})
}
}
function
getParent
(
$this
)
{
function
getParent
(
$this
)
{
...
...
docs/assets/js/bootstrap.js
View file @
e9a648cd
...
@@ -675,8 +675,9 @@
...
@@ -675,8 +675,9 @@
}
}
function
clearMenus
()
{
function
clearMenus
()
{
getParent
(
$
(
toggle
))
$
(
toggle
).
each
(
function
()
{
.
removeClass
(
'
open
'
)
getParent
(
$
(
this
)).
removeClass
(
"
open
"
)
})
}
}
function
getParent
(
$this
)
{
function
getParent
(
$this
)
{
...
...
js/bootstrap-dropdown.js
View file @
e9a648cd
...
@@ -100,8 +100,9 @@
...
@@ -100,8 +100,9 @@
}
}
function
clearMenus
()
{
function
clearMenus
()
{
getParent
(
$
(
toggle
))
$
(
toggle
).
each
(
function
()
{
.
removeClass
(
'
open
'
)
getParent
(
$
(
this
)).
removeClass
(
"
open
"
)
})
}
}
function
getParent
(
$this
)
{
function
getParent
(
$this
)
{
...
...
js/tests/unit/bootstrap-dropdown.js
View file @
e9a648cd
...
@@ -7,7 +7,8 @@ $(function () {
...
@@ -7,7 +7,8 @@ $(function () {
})
})
test
(
"
should return element
"
,
function
()
{
test
(
"
should return element
"
,
function
()
{
ok
(
$
(
document
.
body
).
dropdown
()[
0
]
==
document
.
body
,
'
document.body returned
'
)
var
el
=
$
(
"
<div />
"
)
ok
(
el
.
dropdown
()[
0
]
===
el
[
0
],
'
same element returned
'
)
})
})
test
(
"
should not open dropdown if target is disabled
"
,
function
()
{
test
(
"
should not open dropdown if target is disabled
"
,
function
()
{
...
@@ -102,4 +103,43 @@ $(function () {
...
@@ -102,4 +103,43 @@ $(function () {
dropdown
.
remove
()
dropdown
.
remove
()
})
})
test
(
"
should remove open class if body clicked, with multiple drop downs
"
,
function
()
{
var
dropdownHTML
=
'
<ul class="nav">
'
+
'
<li><a href="#menu1">Menu 1</a></li>
'
+
'
<li class="dropdown" id="testmenu">
'
+
'
<a class="dropdown-toggle" data-toggle="dropdown" href="#testmenu">Test menu <b class="caret"></b></a>
'
+
'
<ul class="dropdown-menu" role="menu">
'
+
'
<li><a href="#sub1">Submenu 1</a></li>
'
+
'
</ul>
'
+
'
</li>
'
+
'
</ul>
'
+
'
<div class="btn-group">
'
+
'
<button class="btn">Actions</button>
'
+
'
<button class="btn dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
'
+
'
<ul class="dropdown-menu">
'
+
'
<li><a href="#">Action 1</a></li>
'
+
'
</ul>
'
+
'
</div>
'
,
dropdowns
=
$
(
dropdownHTML
).
appendTo
(
'
#qunit-fixture
'
).
find
(
'
[data-toggle="dropdown"]
'
)
,
first
=
dropdowns
.
first
()
,
last
=
dropdowns
.
last
()
ok
(
dropdowns
.
length
==
2
,
"
Should be two dropdowns
"
)
first
.
click
()
ok
(
first
.
parents
(
'
.open
'
).
length
==
1
,
'
open class added on click
'
)
ok
(
$
(
'
#qunit-fixture .open
'
).
length
==
1
,
'
only one object is open
'
)
$
(
'
body
'
).
click
()
ok
(
$
(
"
#qunit-fixture .open
"
).
length
===
0
,
'
open class removed
'
)
last
.
click
()
ok
(
last
.
parent
(
'
.open
'
).
length
==
1
,
'
open class added on click
'
)
ok
(
$
(
'
#qunit-fixture .open
'
).
length
==
1
,
'
only one object is open
'
)
$
(
'
body
'
).
click
()
ok
(
$
(
"
#qunit-fixture .open
"
).
length
===
0
,
'
open class removed
'
)
$
(
"
#qunit-fixture
"
).
html
(
""
)
})
})
})
\ No newline at end of file
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