Skip to content

Commit 416493b

Browse files
committed
Added: Made close on blur configurable
1 parent e2e167b commit 416493b

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/app/component/dropdownTree.controller.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default class DropDownTreeController {
2222
this.settings = {
2323
displayProperty: 'name',
2424
childrenProperty: 'children',
25+
closeOnBlur: true,
2526
selectedClass: [
2627
'glyphicon',
2728
'glyphicon-ok',
@@ -48,7 +49,7 @@ export default class DropDownTreeController {
4849

4950
toggleDropdown() {
5051
this.open = !this.open;
51-
if (this.open) {
52+
if (this.open && this.settings.closeOnBlur) {
5253
this.closeToggleOnBlurBinded = this.toggleOnBlur.bind(this);
5354
this.$document.on('click', this.closeToggleOnBlurBinded);
5455
}

src/app/main/main.controller.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ export default class MainController {
1919
],
2020
},
2121
];
22+
23+
this.settings = {
24+
};
2225
}
2326

2427
selectionChanged(selection) {

src/app/main/main.template.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ <h1>AngularJS Dropdown Tree</h1>
1818
<div>
1919
<h2>Examlpe</h2>
2020
<dropdown-tree options="$ctrl.options"
21-
selection-changed="$ctrl.selectionChanged(selection)">
21+
selection-changed="$ctrl.selectionChanged(selection)"
22+
settings="$ctrl.settings">
2223
</dropdown-tree>
2324
</div>
2425
<div>
@@ -108,6 +109,12 @@ <h3>Settings</h3>
108109
<td>string or array of string</td>
109110
<td>When an option is selcted a span is added with the classes configured</td>
110111
</tr>
112+
<tr>
113+
<td>closeOnBlur</td>
114+
<td>true</td>
115+
<td>boolean</td>
116+
<td>When true will close the dropdown when clicked outside of it.</td>
117+
</tr>
111118
</tbody>
112119
</table>
113120
</div>

0 commit comments

Comments
 (0)