Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typeahead render method. #4024

Closed
wants to merge 3 commits into from
Closed
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
38 changes: 37 additions & 1 deletion docs/assets/css/bootstrap.css
Original file line number Diff line number Diff line change
Expand Up @@ -1643,6 +1643,42 @@ legend + .control-group {
padding-left: 160px;
}

.form-oversize .control-label {
padding-top: 7px;
font-size: 16px;
}

.form-oversize .controls > .radio:first-child,
.form-oversize .controls > .checkbox:first-child {
padding-top: 8px;
}

.form-oversize select,
.form-oversize input[type="file"] {
margin-top: 2px;
}

.form-oversize textarea,
.form-oversize input[type="text"],
.form-oversize input[type="password"],
.form-oversize input[type="datetime"],
.form-oversize input[type="datetime-local"],
.form-oversize input[type="date"],
.form-oversize input[type="month"],
.form-oversize input[type="time"],
.form-oversize input[type="week"],
.form-oversize input[type="number"],
.form-oversize input[type="email"],
.form-oversize input[type="url"],
.form-oversize input[type="search"],
.form-oversize input[type="tel"],
.form-oversize input[type="color"],
.form-oversize .uneditable-input {
padding: 6px;
font-size: 16px;
line-height: 20px;
}

table {
max-width: 100%;
background-color: transparent;
Expand Down Expand Up @@ -5027,7 +5063,7 @@ a.badge:hover {

.progress .bar {
width: 0;
height: 18px;
height: 100%;
font-size: 12px;
color: #ffffff;
text-align: center;
Expand Down
9 changes: 6 additions & 3 deletions docs/assets/js/bootstrap-typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
this.updater = this.options.updater || this.updater
this.$menu = $(this.options.menu).appendTo('body')
this.source = this.options.source
this.render = this.options.render || this.render
this.shown = false
this.listen()
}
Expand Down Expand Up @@ -103,7 +104,9 @@
return this.shown ? this.hide() : this
}

return this.render(items.slice(0, this.options.items)).show()
this.render(items.slice(0, this.options.items))

return this.show()
}

, matcher: function (item) {
Expand Down Expand Up @@ -148,7 +151,7 @@

, next: function (event) {
var active = this.$menu.find('.active').removeClass('active')
, next = active.next()
, next = active.nextAll(':has(a):first')

if (!next.length) {
next = $(this.$menu.find('li')[0])
Expand All @@ -159,7 +162,7 @@

, prev: function (event) {
var active = this.$menu.find('.active').removeClass('active')
, prev = active.prev()
, prev = active.prevAll(':has(a):first')

if (!prev.length) {
prev = this.$menu.find('li').last()
Expand Down
9 changes: 6 additions & 3 deletions docs/assets/js/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -1644,6 +1644,7 @@
this.updater = this.options.updater || this.updater
this.$menu = $(this.options.menu).appendTo('body')
this.source = this.options.source
this.render = this.options.render || this.render
this.shown = false
this.listen()
}
Expand Down Expand Up @@ -1712,7 +1713,9 @@
return this.shown ? this.hide() : this
}

return this.render(items.slice(0, this.options.items)).show()
this.render(items.slice(0, this.options.items))

return this.show()
}

, matcher: function (item) {
Expand Down Expand Up @@ -1757,7 +1760,7 @@

, next: function (event) {
var active = this.$menu.find('.active').removeClass('active')
, next = active.next()
, next = active.nextAll(':has(a):first')

if (!next.length) {
next = $(this.$menu.find('li')[0])
Expand All @@ -1768,7 +1771,7 @@

, prev: function (event) {
var active = this.$menu.find('.active').removeClass('active')
, prev = active.prev()
, prev = active.prevAll(':has(a):first')

if (!prev.length) {
prev = this.$menu.find('li').last()
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/js/bootstrap.min.js

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions docs/base-css.html
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,28 @@ <h3>Horizontal form</h3>
&lt;/form&gt;
</pre>

<h3>Oversize form controls</h3>
<p>Add <code>.form-oversize</code> to the form to increase all form controls so they are bigger than standard.</p>

<form class="bs-docs-example form-oversize form-horizontal">
<div class="control-group">
<label class="control-label" for="">Email</label>
<div class="controls">
<input type="text" placeholder="Email">
</div>
</div>
</form>
<pre class="prettyprint linenums">
&lt;form class="form-oversize form-horizontal"&gt;
&lt;div class="control-group"&gt;
&lt;label class="control-label" for=""&gt;Email&lt;/label&gt;
&lt;div class="controls"&gt;
&lt;input type="text" placeholder="Email"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/form&gt;
</pre>


<hr class="bs-docs-separator"></hr>

Expand Down
6 changes: 6 additions & 0 deletions docs/javascript.html
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,12 @@ <h3>Options</h3>
<td>[ ]</td>
<td>The data source to query against. May be an array of strings or a function. The function is passed two arguments, the <code>query</code> value in the input field and the <code>process</code> callback. The function may be used synchronously by returning the data source directly or asynchronously via the <code>process</code> callback's single argument.</td>
</tr>
<tr>
<td>render</td>
<td>function</td>
<td>iterates results displaying value and highlighting matched characters with <code>&lt;strong&gt;</code></td>
<td>The method is used to render the results in the typeahead <code>ul</code>. You can override this method to provide your own html based on the type of object being rendered, useful when your results contain mixed types (i.e. photos, people etc).</td>
</tr>
<tr>
<td>items</td>
<td>number</td>
Expand Down
22 changes: 22 additions & 0 deletions docs/templates/pages/base-css.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,28 @@
&lt;/form&gt;
</pre>

<h3>{{_i}}Oversize form controls{{/i}}</h3>
<p>{{_i}}Add <code>.form-oversize</code> to the form to increase all form controls so they are bigger than standard.{{/i}}</p>

<form class="bs-docs-example form-oversize form-horizontal">
<div class="control-group">
<label class="control-label" for="">{{_i}}Email{{/i}}</label>
<div class="controls">
<input type="text" placeholder="{{_i}}Email{{/i}}">
</div>
</div>
</form>
<pre class="prettyprint linenums">
&lt;form class="form-oversize form-horizontal"&gt;
&lt;div class="control-group"&gt;
&lt;label class="control-label" for=""&gt;{{_i}}Email{{/i}}&lt;/label&gt;
&lt;div class="controls"&gt;
&lt;input type="text" placeholder="{{_i}}Email{{/i}}"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/form&gt;
</pre>


<hr class="bs-docs-separator"></hr>

Expand Down
6 changes: 6 additions & 0 deletions docs/templates/pages/javascript.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -1448,6 +1448,12 @@ $('.carousel').carousel({
<td>[ ]</td>
<td>{{_i}}The data source to query against. May be an array of strings or a function. The function is passed two arguments, the <code>query</code> value in the input field and the <code>process</code> callback. The function may be used synchronously by returning the data source directly or asynchronously via the <code>process</code> callback's single argument.{{/i}}</td>
</tr>
<tr>
<td>{{_i}}render{{/i}}</td>
<td>{{_i}}function{{/i}}</td>
<td>iterates results displaying value and highlighting matched characters with <code>&lt;strong&gt;</code></td>
<td>{{_i}}The method is used to render the results in the typeahead <code>ul</code>. You can override this method to provide your own html based on the type of object being rendered, useful when your results contain mixed types (i.e. photos, people etc).{{/i}}</td>
</tr>
<tr>
<td>{{_i}}items{{/i}}</td>
<td>{{_i}}number{{/i}}</td>
Expand Down
9 changes: 6 additions & 3 deletions js/bootstrap-typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
this.updater = this.options.updater || this.updater
this.$menu = $(this.options.menu).appendTo('body')
this.source = this.options.source
this.render = this.options.render || this.render
this.shown = false
this.listen()
}
Expand Down Expand Up @@ -103,7 +104,9 @@
return this.shown ? this.hide() : this
}

return this.render(items.slice(0, this.options.items)).show()
this.render(items.slice(0, this.options.items))

return this.show()
}

, matcher: function (item) {
Expand Down Expand Up @@ -148,7 +151,7 @@

, next: function (event) {
var active = this.$menu.find('.active').removeClass('active')
, next = active.next()
, next = active.nextAll(':has(a):first')

if (!next.length) {
next = $(this.$menu.find('li')[0])
Expand All @@ -159,7 +162,7 @@

, prev: function (event) {
var active = this.$menu.find('.active').removeClass('active')
, prev = active.prev()
, prev = active.prevAll(':has(a):first')

if (!prev.length) {
prev = this.$menu.find('li').last()
Expand Down
40 changes: 40 additions & 0 deletions less/forms.less
Original file line number Diff line number Diff line change
Expand Up @@ -589,3 +589,43 @@ legend + .control-group {
padding-left: 160px;
}
}

// Oversize Form Elements
// --------------------------
.form-oversize {
.control-label {
font-size: 16px;
padding-top: 7px;
}

.controls > .radio:first-child,
.controls > .checkbox:first-child {
padding-top: 8px;
}

select,
input[type="file"] {
margin-top: 2px;
}

textarea,
input[type="text"],
input[type="password"],
input[type="datetime"],
input[type="datetime-local"],
input[type="date"],
input[type="month"],
input[type="time"],
input[type="week"],
input[type="number"],
input[type="email"],
input[type="url"],
input[type="search"],
input[type="tel"],
input[type="color"],
.uneditable-input {
font-size: 16px;
line-height: 20px;
padding: 6px;
}
}