Skip to content

Commit

Permalink
add bs-placeholder for advanced styling
Browse files Browse the repository at this point in the history
  • Loading branch information
caseyjhol authored and avantika-gupta-jtg committed May 14, 2020
1 parent 7deccf7 commit 5ee06f9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions js/bootstrap-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,8 @@
that.setDisabled(index, this.disabled || this.parentNode.tagName === 'OPTGROUP' && this.parentNode.disabled, $lis);
that.setSelected(index, this.selected, $lis);
});

this.togglePlaceholder();
}

this.tabIndex();
Expand Down Expand Up @@ -990,6 +992,8 @@
},

setSelected: function (index, selected, $lis) {
if (!$lis) this.togglePlaceholder(); // check if setSelected is being called by changing the value of the select

if (!$lis) {
$lis = this.findLis().eq(this.liObj[index]);
}
Expand Down Expand Up @@ -1035,6 +1039,11 @@
});
},

togglePlaceholder: function () {
var value = this.$element.val();
this.$button.toggleClass('bs-placeholder', value === null || value === '');
},

tabIndex: function () {
if (this.$element.data('tabindex') !== this.$element.attr('tabindex') &&
(this.$element.attr('tabindex') !== -98 && this.$element.attr('tabindex') !== '-98')) {
Expand Down
4 changes: 4 additions & 0 deletions less/bootstrap-select.less
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ select.selectpicker {
width: 100%;
padding-right: 25px;
z-index: 1;

&.bs-placeholder,
&.bs-placeholder:hover,
&.bs-placeholder:active { color: @input-color-placeholder; }
}

> select {
Expand Down
3 changes: 3 additions & 0 deletions less/variables.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
@width-default: 220px; // 3 960px-grid columns

@zindex-select-dropdown: 1060; // must be higher than a modal background (1050)

//** Placeholder text color
@input-color-placeholder: #999;
4 changes: 4 additions & 0 deletions sass/bootstrap-select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ select.selectpicker {
width: 100%;
padding-right: 25px;
z-index: 1;

&.bs-placeholder,
&.bs-placeholder:hover,
&.bs-placeholder:active { color: $input-color-placeholder; }
}

> select {
Expand Down
3 changes: 3 additions & 0 deletions sass/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ $color-grey-arrow: rgba(204, 204, 204, 0.2);
$width-default: 220px; // 3 960px-grid columns

$zindex-select-dropdown: 1060; // must be higher than a modal background (1050)

//** Placeholder text color
$input-color-placeholder: #999;

0 comments on commit 5ee06f9

Please sign in to comment.