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
820a3b27
Commit
820a3b27
authored
Dec 07, 2012
by
fat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get tests passing for typeahead :P
parent
1747caf1
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
28 deletions
+43
-28
docs/assets/js/bootstrap-typeahead.js
docs/assets/js/bootstrap-typeahead.js
+8
-6
docs/assets/js/bootstrap.js
docs/assets/js/bootstrap.js
+8
-6
docs/assets/js/bootstrap.min.js
docs/assets/js/bootstrap.min.js
+1
-1
js/bootstrap-typeahead.js
js/bootstrap-typeahead.js
+8
-6
js/tests/unit/bootstrap-typeahead.js
js/tests/unit/bootstrap-typeahead.js
+18
-9
No files found.
docs/assets/js/bootstrap-typeahead.js
View file @
820a3b27
...
@@ -33,8 +33,8 @@
...
@@ -33,8 +33,8 @@
this
.
sorter
=
this
.
options
.
sorter
||
this
.
sorter
this
.
sorter
=
this
.
options
.
sorter
||
this
.
sorter
this
.
highlighter
=
this
.
options
.
highlighter
||
this
.
highlighter
this
.
highlighter
=
this
.
options
.
highlighter
||
this
.
highlighter
this
.
updater
=
this
.
options
.
updater
||
this
.
updater
this
.
updater
=
this
.
options
.
updater
||
this
.
updater
this
.
$menu
=
$
(
this
.
options
.
menu
).
insertAfter
(
this
.
$element
)
this
.
source
=
this
.
options
.
source
this
.
source
=
this
.
options
.
source
this
.
$menu
=
$
(
this
.
options
.
menu
)
this
.
shown
=
false
this
.
shown
=
false
this
.
listen
()
this
.
listen
()
}
}
...
@@ -60,12 +60,14 @@
...
@@ -60,12 +60,14 @@
height
:
this
.
$element
[
0
].
offsetHeight
height
:
this
.
$element
[
0
].
offsetHeight
})
})
this
.
$menu
.
css
({
this
.
$menu
top
:
pos
.
top
+
pos
.
height
.
insertAfter
(
this
.
$element
)
,
left
:
pos
.
left
.
css
({
})
top
:
pos
.
top
+
pos
.
height
,
left
:
pos
.
left
})
.
show
()
this
.
$menu
.
show
()
this
.
shown
=
true
this
.
shown
=
true
return
this
return
this
}
}
...
...
docs/assets/js/bootstrap.js
View file @
820a3b27
...
@@ -1752,8 +1752,8 @@
...
@@ -1752,8 +1752,8 @@
this
.
sorter
=
this
.
options
.
sorter
||
this
.
sorter
this
.
sorter
=
this
.
options
.
sorter
||
this
.
sorter
this
.
highlighter
=
this
.
options
.
highlighter
||
this
.
highlighter
this
.
highlighter
=
this
.
options
.
highlighter
||
this
.
highlighter
this
.
updater
=
this
.
options
.
updater
||
this
.
updater
this
.
updater
=
this
.
options
.
updater
||
this
.
updater
this
.
$menu
=
$
(
this
.
options
.
menu
).
insertAfter
(
this
.
$element
)
this
.
source
=
this
.
options
.
source
this
.
source
=
this
.
options
.
source
this
.
$menu
=
$
(
this
.
options
.
menu
)
this
.
shown
=
false
this
.
shown
=
false
this
.
listen
()
this
.
listen
()
}
}
...
@@ -1779,12 +1779,14 @@
...
@@ -1779,12 +1779,14 @@
height
:
this
.
$element
[
0
].
offsetHeight
height
:
this
.
$element
[
0
].
offsetHeight
})
})
this
.
$menu
.
css
({
this
.
$menu
top
:
pos
.
top
+
pos
.
height
.
insertAfter
(
this
.
$element
)
,
left
:
pos
.
left
.
css
({
})
top
:
pos
.
top
+
pos
.
height
,
left
:
pos
.
left
})
.
show
()
this
.
$menu
.
show
()
this
.
shown
=
true
this
.
shown
=
true
return
this
return
this
}
}
...
...
docs/assets/js/bootstrap.min.js
View file @
820a3b27
This diff is collapsed.
Click to expand it.
js/bootstrap-typeahead.js
View file @
820a3b27
...
@@ -33,8 +33,8 @@
...
@@ -33,8 +33,8 @@
this
.
sorter
=
this
.
options
.
sorter
||
this
.
sorter
this
.
sorter
=
this
.
options
.
sorter
||
this
.
sorter
this
.
highlighter
=
this
.
options
.
highlighter
||
this
.
highlighter
this
.
highlighter
=
this
.
options
.
highlighter
||
this
.
highlighter
this
.
updater
=
this
.
options
.
updater
||
this
.
updater
this
.
updater
=
this
.
options
.
updater
||
this
.
updater
this
.
$menu
=
$
(
this
.
options
.
menu
).
insertAfter
(
this
.
$element
)
this
.
source
=
this
.
options
.
source
this
.
source
=
this
.
options
.
source
this
.
$menu
=
$
(
this
.
options
.
menu
)
this
.
shown
=
false
this
.
shown
=
false
this
.
listen
()
this
.
listen
()
}
}
...
@@ -60,12 +60,14 @@
...
@@ -60,12 +60,14 @@
height
:
this
.
$element
[
0
].
offsetHeight
height
:
this
.
$element
[
0
].
offsetHeight
})
})
this
.
$menu
.
css
({
this
.
$menu
top
:
pos
.
top
+
pos
.
height
.
insertAfter
(
this
.
$element
)
,
left
:
pos
.
left
.
css
({
})
top
:
pos
.
top
+
pos
.
height
,
left
:
pos
.
left
})
.
show
()
this
.
$menu
.
show
()
this
.
shown
=
true
this
.
shown
=
true
return
this
return
this
}
}
...
...
js/tests/unit/bootstrap-typeahead.js
View file @
820a3b27
...
@@ -38,7 +38,9 @@ $(function () {
...
@@ -38,7 +38,9 @@ $(function () {
})
})
test
(
"
should show menu when query entered
"
,
function
()
{
test
(
"
should show menu when query entered
"
,
function
()
{
var
$input
=
$
(
'
<input />
'
).
typeahead
({
var
$input
=
$
(
'
<input />
'
)
.
appendTo
(
'
body
'
)
.
typeahead
({
source
:
[
'
aa
'
,
'
ab
'
,
'
ac
'
]
source
:
[
'
aa
'
,
'
ab
'
,
'
ac
'
]
})
})
,
typeahead
=
$input
.
data
(
'
typeahead
'
)
,
typeahead
=
$input
.
data
(
'
typeahead
'
)
...
@@ -50,6 +52,7 @@ $(function () {
...
@@ -50,6 +52,7 @@ $(function () {
equals
(
typeahead
.
$menu
.
find
(
'
li
'
).
length
,
3
,
'
has 3 items in menu
'
)
equals
(
typeahead
.
$menu
.
find
(
'
li
'
).
length
,
3
,
'
has 3 items in menu
'
)
equals
(
typeahead
.
$menu
.
find
(
'
.active
'
).
length
,
1
,
'
one item is active
'
)
equals
(
typeahead
.
$menu
.
find
(
'
.active
'
).
length
,
1
,
'
one item is active
'
)
$input
.
remove
()
typeahead
.
$menu
.
remove
()
typeahead
.
$menu
.
remove
()
})
})
...
@@ -58,7 +61,7 @@ $(function () {
...
@@ -58,7 +61,7 @@ $(function () {
source
:
function
()
{
source
:
function
()
{
return
[
'
aa
'
,
'
ab
'
,
'
ac
'
]
return
[
'
aa
'
,
'
ab
'
,
'
ac
'
]
}
}
})
})
.
appendTo
(
'
body
'
)
,
typeahead
=
$input
.
data
(
'
typeahead
'
)
,
typeahead
=
$input
.
data
(
'
typeahead
'
)
$input
.
val
(
'
a
'
)
$input
.
val
(
'
a
'
)
...
@@ -68,6 +71,7 @@ $(function () {
...
@@ -68,6 +71,7 @@ $(function () {
equals
(
typeahead
.
$menu
.
find
(
'
li
'
).
length
,
3
,
'
has 3 items in menu
'
)
equals
(
typeahead
.
$menu
.
find
(
'
li
'
).
length
,
3
,
'
has 3 items in menu
'
)
equals
(
typeahead
.
$menu
.
find
(
'
.active
'
).
length
,
1
,
'
one item is active
'
)
equals
(
typeahead
.
$menu
.
find
(
'
.active
'
).
length
,
1
,
'
one item is active
'
)
$input
.
remove
()
typeahead
.
$menu
.
remove
()
typeahead
.
$menu
.
remove
()
})
})
...
@@ -76,7 +80,7 @@ $(function () {
...
@@ -76,7 +80,7 @@ $(function () {
source
:
function
(
query
,
process
)
{
source
:
function
(
query
,
process
)
{
process
([
'
aa
'
,
'
ab
'
,
'
ac
'
])
process
([
'
aa
'
,
'
ab
'
,
'
ac
'
])
}
}
})
})
.
appendTo
(
'
body
'
)
,
typeahead
=
$input
.
data
(
'
typeahead
'
)
,
typeahead
=
$input
.
data
(
'
typeahead
'
)
$input
.
val
(
'
a
'
)
$input
.
val
(
'
a
'
)
...
@@ -86,13 +90,14 @@ $(function () {
...
@@ -86,13 +90,14 @@ $(function () {
equals
(
typeahead
.
$menu
.
find
(
'
li
'
).
length
,
3
,
'
has 3 items in menu
'
)
equals
(
typeahead
.
$menu
.
find
(
'
li
'
).
length
,
3
,
'
has 3 items in menu
'
)
equals
(
typeahead
.
$menu
.
find
(
'
.active
'
).
length
,
1
,
'
one item is active
'
)
equals
(
typeahead
.
$menu
.
find
(
'
.active
'
).
length
,
1
,
'
one item is active
'
)
$input
.
remove
()
typeahead
.
$menu
.
remove
()
typeahead
.
$menu
.
remove
()
})
})
test
(
"
should not explode when regex chars are entered
"
,
function
()
{
test
(
"
should not explode when regex chars are entered
"
,
function
()
{
var
$input
=
$
(
'
<input />
'
).
typeahead
({
var
$input
=
$
(
'
<input />
'
).
typeahead
({
source
:
[
'
aa
'
,
'
ab
'
,
'
ac
'
,
'
mdo*
'
,
'
fat+
'
]
source
:
[
'
aa
'
,
'
ab
'
,
'
ac
'
,
'
mdo*
'
,
'
fat+
'
]
})
})
.
appendTo
(
'
body
'
)
,
typeahead
=
$input
.
data
(
'
typeahead
'
)
,
typeahead
=
$input
.
data
(
'
typeahead
'
)
$input
.
val
(
'
+
'
)
$input
.
val
(
'
+
'
)
...
@@ -102,6 +107,7 @@ $(function () {
...
@@ -102,6 +107,7 @@ $(function () {
equals
(
typeahead
.
$menu
.
find
(
'
li
'
).
length
,
1
,
'
has 1 item in menu
'
)
equals
(
typeahead
.
$menu
.
find
(
'
li
'
).
length
,
1
,
'
has 1 item in menu
'
)
equals
(
typeahead
.
$menu
.
find
(
'
.active
'
).
length
,
1
,
'
one item is active
'
)
equals
(
typeahead
.
$menu
.
find
(
'
.active
'
).
length
,
1
,
'
one item is active
'
)
$input
.
remove
()
typeahead
.
$menu
.
remove
()
typeahead
.
$menu
.
remove
()
})
})
...
@@ -109,7 +115,7 @@ $(function () {
...
@@ -109,7 +115,7 @@ $(function () {
stop
()
stop
()
var
$input
=
$
(
'
<input />
'
).
typeahead
({
var
$input
=
$
(
'
<input />
'
).
typeahead
({
source
:
[
'
aa
'
,
'
ab
'
,
'
ac
'
]
source
:
[
'
aa
'
,
'
ab
'
,
'
ac
'
]
})
})
.
appendTo
(
'
body
'
)
,
typeahead
=
$input
.
data
(
'
typeahead
'
)
,
typeahead
=
$input
.
data
(
'
typeahead
'
)
$input
.
val
(
'
a
'
)
$input
.
val
(
'
a
'
)
...
@@ -126,13 +132,14 @@ $(function () {
...
@@ -126,13 +132,14 @@ $(function () {
start
()
start
()
},
200
)
},
200
)
$input
.
remove
()
typeahead
.
$menu
.
remove
()
typeahead
.
$menu
.
remove
()
})
})
test
(
"
should set next item when down arrow is pressed
"
,
function
()
{
test
(
"
should set next item when down arrow is pressed
"
,
function
()
{
var
$input
=
$
(
'
<input />
'
).
typeahead
({
var
$input
=
$
(
'
<input />
'
).
typeahead
({
source
:
[
'
aa
'
,
'
ab
'
,
'
ac
'
]
source
:
[
'
aa
'
,
'
ab
'
,
'
ac
'
]
})
})
.
appendTo
(
'
body
'
)
,
typeahead
=
$input
.
data
(
'
typeahead
'
)
,
typeahead
=
$input
.
data
(
'
typeahead
'
)
$input
.
val
(
'
a
'
)
$input
.
val
(
'
a
'
)
...
@@ -159,7 +166,6 @@ $(function () {
...
@@ -159,7 +166,6 @@ $(function () {
ok
(
typeahead
.
$menu
.
find
(
'
li
'
).
first
().
next
().
hasClass
(
'
active
'
),
"
second item is active
"
)
ok
(
typeahead
.
$menu
.
find
(
'
li
'
).
first
().
next
().
hasClass
(
'
active
'
),
"
second item is active
"
)
$input
.
trigger
({
$input
.
trigger
({
type
:
'
keydown
'
type
:
'
keydown
'
,
keyCode
:
38
,
keyCode
:
38
...
@@ -175,6 +181,7 @@ $(function () {
...
@@ -175,6 +181,7 @@ $(function () {
ok
(
typeahead
.
$menu
.
find
(
'
li
'
).
first
().
hasClass
(
'
active
'
),
"
first item is active
"
)
ok
(
typeahead
.
$menu
.
find
(
'
li
'
).
first
().
hasClass
(
'
active
'
),
"
first item is active
"
)
$input
.
remove
()
typeahead
.
$menu
.
remove
()
typeahead
.
$menu
.
remove
()
})
})
...
@@ -182,7 +189,7 @@ $(function () {
...
@@ -182,7 +189,7 @@ $(function () {
test
(
"
should set input value to selected item
"
,
function
()
{
test
(
"
should set input value to selected item
"
,
function
()
{
var
$input
=
$
(
'
<input />
'
).
typeahead
({
var
$input
=
$
(
'
<input />
'
).
typeahead
({
source
:
[
'
aa
'
,
'
ab
'
,
'
ac
'
]
source
:
[
'
aa
'
,
'
ab
'
,
'
ac
'
]
})
})
.
appendTo
(
'
body
'
)
,
typeahead
=
$input
.
data
(
'
typeahead
'
)
,
typeahead
=
$input
.
data
(
'
typeahead
'
)
,
changed
=
false
,
changed
=
false
...
@@ -197,6 +204,7 @@ $(function () {
...
@@ -197,6 +204,7 @@ $(function () {
ok
(
!
typeahead
.
$menu
.
is
(
'
:visible
'
),
'
the menu was hidden
'
)
ok
(
!
typeahead
.
$menu
.
is
(
'
:visible
'
),
'
the menu was hidden
'
)
ok
(
changed
,
'
a change event was fired
'
)
ok
(
changed
,
'
a change event was fired
'
)
$input
.
remove
()
typeahead
.
$menu
.
remove
()
typeahead
.
$menu
.
remove
()
})
})
...
@@ -204,7 +212,7 @@ $(function () {
...
@@ -204,7 +212,7 @@ $(function () {
var
$input
=
$
(
'
<input />
'
).
typeahead
({
var
$input
=
$
(
'
<input />
'
).
typeahead
({
source
:
[
'
aaaa
'
,
'
aaab
'
,
'
aaac
'
],
source
:
[
'
aaaa
'
,
'
aaab
'
,
'
aaac
'
],
minLength
:
3
minLength
:
3
})
})
.
appendTo
(
'
body
'
)
,
typeahead
=
$input
.
data
(
'
typeahead
'
)
,
typeahead
=
$input
.
data
(
'
typeahead
'
)
$input
.
val
(
'
aa
'
)
$input
.
val
(
'
aa
'
)
...
@@ -217,6 +225,7 @@ $(function () {
...
@@ -217,6 +225,7 @@ $(function () {
equals
(
typeahead
.
$menu
.
find
(
'
li
'
).
length
,
3
,
'
has 3 items in menu
'
)
equals
(
typeahead
.
$menu
.
find
(
'
li
'
).
length
,
3
,
'
has 3 items in menu
'
)
$input
.
remove
()
typeahead
.
$menu
.
remove
()
typeahead
.
$menu
.
remove
()
})
})
})
})
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