Skip to content
This repository has been archived by the owner on May 21, 2021. It is now read-only.

Commit

Permalink
feat(select): added config option to show the clearbutton.
Browse files Browse the repository at this point in the history
The clear button can now be always displayed with the option config.showAlwaysClear
Its default is false.

close #16
  • Loading branch information
sengmann committed Dec 3, 2014
1 parent 0cd0852 commit 67f0bcb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/w11k-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ angular.module('w11k.select').constant('w11kSelectConfig', {
marginBottom: '10px',
/** static or manually calculated max height (disables internal height calculation) */
maxHeight: undefined
}
},
showAlwaysClear: false
}
});

Expand Down Expand Up @@ -324,7 +325,7 @@ angular.module('w11k.select').directive('w11kSelect', [
$timeout(function () {
adjustHeight();
jqDropDownMenu.css(visibility, 'visible');

if (scope.config.filter.active) {
// use timeout to open dropdown first and then set the focus,
// otherwise focus won't be set because element is not visible
Expand Down
2 changes: 1 addition & 1 deletion src/w11k-select.tpl.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="dropdown w11k-select">
<div class="input-group select-toggle" w11k-dropdown-toggle="dropdown" ng-class="{disabled: config.disabled}">
<div class="input-group-addon deselect-all" ng-if="!config.disabled && !config.required && !isEmpty()" ng-click="deselectAll($event)">
<div class="input-group-addon deselect-all" ng-if="!config.disabled && (!config.required || config.showAlwaysClear) && !isEmpty()" ng-click="deselectAll($event)">
<i class="fa fa-times icon-deselect-all"></i>
</div>
<div class="form-control" ng-disabled="config.disabled">
Expand Down
1 change: 1 addition & 0 deletions test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<button class="btn btn-default" ng-click="staticConfig.disabled = !staticConfig.disabled">Toggle Disabled</button>
<button class="btn btn-default" ng-click="dynamicConfig.required = !dynamicConfig.required">Toggle Required</button>
<button class="btn btn-default" ng-click="dynamicConfig.multiple = !dynamicConfig.multiple">Toggle Multiple</button>
<button class="btn btn-default" ng-click="dynamicConfig.showAlwaysClear = !dynamicConfig.showAlwaysClear">Toggle Multiple</button>
</div>
</div>

Expand Down

0 comments on commit 67f0bcb

Please sign in to comment.