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
21644321
Commit
21644321
authored
Nov 04, 2014
by
Chris Rebert
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14993 from twbs/fix-14991
Have Carousel ignore keyboard events from <input>s or <textarea>s
parents
db90ff6d
469dc3ab
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
js/carousel.js
js/carousel.js
+1
-0
js/tests/unit/carousel.js
js/tests/unit/carousel.js
+42
-0
No files found.
js/carousel.js
View file @
21644321
...
@@ -42,6 +42,7 @@
...
@@ -42,6 +42,7 @@
}
}
Carousel
.
prototype
.
keydown
=
function
(
e
)
{
Carousel
.
prototype
.
keydown
=
function
(
e
)
{
if
(
/input|textarea/i
.
test
(
e
.
target
.
tagName
))
return
switch
(
e
.
which
)
{
switch
(
e
.
which
)
{
case
37
:
this
.
prev
();
break
case
37
:
this
.
prev
();
break
case
39
:
this
.
next
();
break
case
39
:
this
.
next
();
break
...
...
js/tests/unit/carousel.js
View file @
21644321
...
@@ -478,6 +478,48 @@ $(function () {
...
@@ -478,6 +478,48 @@ $(function () {
strictEqual
(
$template
.
find
(
'
.item
'
)[
0
],
$template
.
find
(
'
.active
'
)[
0
],
'
first item still active after left arrow press
'
)
strictEqual
(
$template
.
find
(
'
.item
'
)[
0
],
$template
.
find
(
'
.active
'
)[
0
],
'
first item still active after left arrow press
'
)
})
})
test
(
'
should ignore keyboard events within <input>s and <textarea>s
'
,
function
()
{
var
templateHTML
=
'
<div id="myCarousel" class="carousel" data-interval="false">
'
+
'
<div class="carousel-inner">
'
+
'
<div id="first" class="item active">
'
+
'
<img alt="">
'
+
'
<input type="text" id="in-put">
'
+
'
<textarea id="text-area"></textarea>
'
+
'
</div>
'
+
'
<div id="second" class="item">
'
+
'
<img alt="">
'
+
'
</div>
'
+
'
<div id="third" class="item">
'
+
'
<img alt="">
'
+
'
</div>
'
+
'
</div>
'
+
'
</div>
'
var
$template
=
$
(
templateHTML
)
var
$input
=
$template
.
find
(
'
#in-put
'
)
var
$textarea
=
$template
.
find
(
'
#text-area
'
)
strictEqual
(
$input
.
length
,
1
,
'
found <input>
'
)
strictEqual
(
$textarea
.
length
,
1
,
'
found <textarea>
'
)
$template
.
bootstrapCarousel
()
strictEqual
(
$template
.
find
(
'
.item
'
)[
0
],
$template
.
find
(
'
.active
'
)[
0
],
'
first item active
'
)
$input
.
trigger
(
$
.
Event
(
'
keydown
'
,
{
which
:
39
}))
strictEqual
(
$template
.
find
(
'
.item
'
)[
0
],
$template
.
find
(
'
.active
'
)[
0
],
'
first item still active after right arrow press in <input>
'
)
$input
.
trigger
(
$
.
Event
(
'
keydown
'
,
{
which
:
37
}))
strictEqual
(
$template
.
find
(
'
.item
'
)[
0
],
$template
.
find
(
'
.active
'
)[
0
],
'
first item still active after left arrow press in <input>
'
)
$textarea
.
trigger
(
$
.
Event
(
'
keydown
'
,
{
which
:
39
}))
strictEqual
(
$template
.
find
(
'
.item
'
)[
0
],
$template
.
find
(
'
.active
'
)[
0
],
'
first item still active after right arrow press in <textarea>
'
)
$textarea
.
trigger
(
$
.
Event
(
'
keydown
'
,
{
which
:
37
}))
strictEqual
(
$template
.
find
(
'
.item
'
)[
0
],
$template
.
find
(
'
.active
'
)[
0
],
'
first item still active after left arrow press in <textarea>
'
)
})
test
(
'
should only add mouseenter and mouseleave listeners when not on mobile
'
,
function
()
{
test
(
'
should only add mouseenter and mouseleave listeners when not on mobile
'
,
function
()
{
var
isMobile
=
'
ontouchstart
'
in
document
.
documentElement
var
isMobile
=
'
ontouchstart
'
in
document
.
documentElement
var
templateHTML
=
'
<div id="myCarousel" class="carousel" data-interval="false" data-pause="hover">
'
var
templateHTML
=
'
<div id="myCarousel" class="carousel" data-interval="false" data-pause="hover">
'
...
...
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