Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: jpfuentes2/bootstrap-combobox
base: cb875d5a4a
...
head fork: jpfuentes2/bootstrap-combobox
compare: 96176752eb
Checking mergeability… Don't worry, you can still create the pull request.
  • 11 commits
  • 4 files changed
  • 0 commit comments
  • 2 contributors
View
40 css/bootstrap-combobox.css
@@ -2,19 +2,22 @@
margin-bottom: 5px;
*zoom: 1;
}
-.combobox-container:before, .combobox-container:after {
+.combobox-container:before,
+.combobox-container:after {
display: table;
content: "";
}
.combobox-container:after {
clear: both;
}
-.combobox-container input, .combobox-container .uneditable-input {
+.combobox-container input,
+.combobox-container .uneditable-input {
-webkit-border-radius: 0 3px 3px 0;
-moz-border-radius: 0 3px 3px 0;
border-radius: 0 3px 3px 0;
}
-.combobox-container input:focus, .combobox-container .uneditable-input:focus {
+.combobox-container input:focus,
+.combobox-container .uneditable-input:focus {
position: relative;
z-index: 2;
}
@@ -44,7 +47,8 @@
background-color: #a9dba9;
border-color: #46a546;
}
-.combobox-container input, .combobox-container .uneditable-input {
+.combobox-container input,
+.combobox-container .uneditable-input {
float: left;
-webkit-border-radius: 3px 0 0 3px;
-moz-border-radius: 3px 0 0 3px;
@@ -74,7 +78,6 @@
border: 0;
padding: 0;
margin: 0;
- float: left;
text-indent: -99999px;
*text-indent: 0;
}
@@ -93,7 +96,8 @@
opacity: 0.3;
filter: alpha(opacity=30);
}
-.dropdown:hover .combobox-clear, .open.dropdown .combobox-clear {
+.dropdown:hover .combobox-clear,
+.open.dropdown .combobox-clear {
opacity: 1;
filter: alpha(opacity=100);
}
@@ -101,7 +105,8 @@
margin-top: 1px;
margin-left: 1px;
}
-.btn:hover .combobox-clear, .open.btn-group .combobox-clear {
+.btn:hover .combobox-clear,
+.open.btn-group .combobox-clear {
opacity: 1;
filter: alpha(opacity=100);
}
@@ -109,3 +114,24 @@
max-height: 300px;
overflow-y: auto;
}
+.control-group.error .combobox-container .add-on {
+ color: #B94A48;
+ border-color: #B94A48;
+}
+.control-group.error .combobox-container .caret {
+ border-top-color: #B94A48;
+}
+.control-group.warning .combobox-container .add-on {
+ color: #C09853;
+ border-color: #C09853;
+}
+.control-group.warning .combobox-container .caret {
+ border-top-color: #C09853;
+}
+.control-group.success .combobox-container .add-on {
+ color: #468847;
+ border-color: #468847;
+}
+.control-group.success .combobox-container .caret {
+ border-top-color: #468847;
+}
View
11 js/bootstrap-combobox.js
@@ -30,6 +30,8 @@
this.sorter = this.options.sorter || this.sorter
this.highlighter = this.options.highlighter || this.highlighter
this.$menu = $(this.options.menu).appendTo('body')
+ this.placeholder = this.options.placeholder || this.$target.attr('data-placeholder')
+ this.$element.attr('placeholder', this.placeholder)
this.shown = false
this.refresh()
this.listen()
@@ -47,7 +49,7 @@
, combobox = $(this.options.template)
select.before(combobox)
select.detach()
- combobox.prepend(select)
+ combobox.append(select)
return combobox
}
@@ -78,6 +80,7 @@
if (this.shown) {
this.hide()
} else {
+ this.$element.focus()
this.lookup()
}
}
@@ -143,6 +146,11 @@
var that = this
e.stopPropagation()
e.preventDefault()
+ var val = this.$element.val();
+ if (val.length == 0 || this.matcher(val) == -1) {
+ this.$element.val("")
+ this.$target.val("").trigger('change')
+ }
if (this.shown) {
setTimeout(function () { that.hide() }, 150)
}
@@ -166,6 +174,7 @@
template: '<div class="combobox-container"><input type="text" /><span class="add-on btn dropdown-toggle" data-dropdown="dropdown"><span class="caret"/><span class="combobox-clear"><i class="icon-remove"/></span></span></div>'
, menu: '<ul class="typeahead typeahead-long dropdown-menu"></ul>'
, item: '<li><a href="#"></a></li>'
+ , placeholder: null
}
$.fn.combobox.Constructor = Combobox
View
31 js/tests/unit/bootstrap-combobox.js
@@ -197,4 +197,35 @@ $(function () {
equals($input.val(), 'ab', 'input value was correctly set')
equals($select.val(), 'ab', 'select value was correctly set')
})
+
+ test("should clear input on blur when value does not exist", function() {
+ var $select = $('<select><option>aa</option></select>')
+ , $input = $select.combobox().data('combobox').$element
+ , combobox = $select.data('combobox')
+
+ $input.val('DOES NOT EXIST')
+ combobox.lookup()
+ $input.trigger('blur')
+
+ equals($input.val(), '', 'input value was correctly set')
+ equals($select.val(), 'aa', 'select value was correctly set')
+
+ combobox.$menu.remove()
+ })
+
+ test("should set placeholder text on the input if specified as an option", function() {
+ var $select = $('<select><option></option><option>aa</option><option selected>ab</option><option>ac</option></select>')
+ , $input = $select.combobox({placeholder: "Type something..."}).data('combobox').$element
+ , combobox = $select.data('combobox')
+
+ equals($input.attr('placeholder'), 'Type something...', 'input value was correctly set')
+ })
+
+ test("should set placeholder text on the input if specified as an data attribute", function() {
+ var $select = $('<select data-placeholder="Type something..."><option></option><option>aa</option><option selected>ab</option><option>ac</option></select>')
+ , $input = $select.combobox().data('combobox').$element
+ , combobox = $select.data('combobox')
+
+ equals($input.attr('placeholder'), 'Type something...', 'input value was correctly set')
+ })
})
View
37 less/combobox.less
@@ -7,7 +7,6 @@
border: 0;
padding: 0;
margin: 0;
- float: left;
text-indent: -99999px;
*text-indent: 0;
}
@@ -49,3 +48,39 @@
max-height: 300px;
overflow-y: auto;
}
+
+.control-group.error {
+ .combobox-container {
+ .add-on {
+ color: #B94A48;
+ border-color: #B94A48;
+ }
+ .caret {
+ border-top-color: #B94A48;
+ }
+ }
+}
+
+.control-group.warning {
+ .combobox-container {
+ .add-on {
+ color: #C09853;
+ border-color: #C09853;
+ }
+ .caret {
+ border-top-color: #C09853;
+ }
+ }
+}
+
+.control-group.success {
+ .combobox-container {
+ .add-on {
+ color: #468847;
+ border-color: #468847;
+ }
+ .caret {
+ border-top-color: #468847;
+ }
+ }
+}

No commit comments for this range

Something went wrong with that request. Please try again.