Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<!DOCTYPE html>
<html>
<head>
<title>Typehead & Bootstrap</title>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
<script src="//code.jquery.com/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.9.3/typeahead.min.js"></script>
<link href="typeahead.js-bootstrap.css" rel="stylesheet">
<script type="text/javascript">
var data = [
'Salt Lake City',
'Provo',
'Ogden',
'Bountiful',
'Orem',
'Centerville',
'St. George',
'Cedar City',
'Hurricane',
];
$(document).ready(function() {
$('#choose').text(data.join(', '));
$('#typeahead-1').typeahead({
name: 'normal',
local: data
});
$('#typeahead-2').typeahead({
name: 'addon',
local: data
});
$('#typeahead-3').typeahead({
name: 'pre-addon',
local: data
});
});
</script>
</head>
<body>
<div class="container">
<h1 class="page-header">typeahead.js and Bootstrap 3 example</h1>
<p>Choose from: <span id="choose"></span></p>
<div class="row">
<div class="col-xs-12">
<h2>Normal</h2>
<div class="input-group col-sm-3">
<input type="text" class="form-control" id="typeahead-1" />
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<h2>Addon</h2>
<p>This is more complex because of CSS's inability to select a parent. add <code>input-group-appended</code> to the container div</p>
<div class="input-group input-group-appended col-sm-3">
<input type="text" class="form-control" id="typeahead-2" />
<span class="input-group-addon">#</span>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<h2>Pre-addon aka Prepend</h2>
<p>Prepending an input group is easier because of CSS's sibling select <code>+</code></p>
<div class="input-group col-sm-3">
<span class="input-group-addon">#</span>
<input type="text" class="form-control" id="typeahead-3" />
</div>
</div>
</div>
</div>
</body>
</html>
96 changes: 64 additions & 32 deletions typeahead.js-bootstrap.css
Original file line number Diff line number Diff line change
@@ -1,49 +1,81 @@
.twitter-typeahead {
width: 100%;
position: relative;
}

.twitter-typeahead .tt-query,
.twitter-typeahead .tt-hint {
margin-bottom: 0;
margin-bottom: 0;
width: 100%;
height: 34px;
position: absolute;
top: 0;
left: 0;
}

.twitter-typeahead .tt-hint {
color: #a1a1a1;
z-index: 1;
padding: 6px 12px;
border: 1px solid transparent;
}

.twitter-typeahead .tt-query {
z-index: 2;
border-radius: 4px !important;
}

.input-group-addon + .twitter-typeahead > .tt-query {
border-top-left-radius: 0!important;
border-bottom-left-radius: 0!important;
}

.input-group-appended > .twitter-typeahead > .tt-query {
border-top-right-radius: 0!important;
border-bottom-right-radius: 0!important;
}

.tt-dropdown-menu {
min-width: 160px;
margin-top: 2px;
padding: 5px 0;
background-color: #fff;
border: 1px solid #ccc;
border: 1px solid rgba(0,0,0,.2);
*border-right-width: 2px;
*border-bottom-width: 2px;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
-webkit-box-shadow: 0 5px 10px rgba(0,0,0,.2);
-moz-box-shadow: 0 5px 10px rgba(0,0,0,.2);
box-shadow: 0 5px 10px rgba(0,0,0,.2);
-webkit-background-clip: padding-box;
-moz-background-clip: padding;
background-clip: padding-box;
min-width: 160px;
margin-top: 2px;
padding: 5px 0;
background-color: #fff;
border: 1px solid #ccc;
border: 1px solid rgba(0, 0, 0, .2);
*border-right-width: 2px;
*border-bottom-width: 2px;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
-webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
-moz-box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
-webkit-background-clip: padding-box;
-moz-background-clip: padding;
background-clip: padding-box;
}

.tt-suggestion {
display: block;
padding: 3px 20px;
display: block;
padding: 3px 20px;
}

.tt-suggestion.tt-is-under-cursor {
color: #fff;
background-color: #0081c2;
background-image: -moz-linear-gradient(top, #0088cc, #0077b3);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3));
background-image: -webkit-linear-gradient(top, #0088cc, #0077b3);
background-image: -o-linear-gradient(top, #0088cc, #0077b3);
background-image: linear-gradient(to bottom, #0088cc, #0077b3);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0)
color: #fff;
background-color: #0081c2;
background-image: -moz-linear-gradient(top, #0088cc, #0077b3);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3));
background-image: -webkit-linear-gradient(top, #0088cc, #0077b3);
background-image: -o-linear-gradient(top, #0088cc, #0077b3);
background-image: linear-gradient(to bottom, #0088cc, #0077b3);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0)
}

.tt-suggestion.tt-is-under-cursor a {
color: #fff;
color: #fff;
}

.tt-suggestion p {
margin: 0;
}
margin: 0;
}
33 changes: 0 additions & 33 deletions typeahead.js-bootstrap.less

This file was deleted.