File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ export default class DropDownTreeController {
2222this . settings  =  { 
2323displayProperty : 'name' , 
2424childrenProperty : 'children' , 
25+ closeOnBlur : true , 
2526selectedClass : [ 
2627'glyphicon' , 
2728'glyphicon-ok' , 
@@ -48,7 +49,7 @@ export default class DropDownTreeController {
4849
4950toggleDropdown ( )  { 
5051this . open  =  ! this . open ; 
51- if  ( this . open )  { 
52+ if  ( this . open   &&   this . settings . closeOnBlur )  { 
5253this . closeToggleOnBlurBinded  =  this . toggleOnBlur . bind ( this ) ; 
5354this . $document . on ( 'click' ,  this . closeToggleOnBlurBinded ) ; 
5455} 
Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ export default class MainController {
1919] , 
2020} , 
2121] ; 
22+ 
23+ this . settings  =  { 
24+ } ; 
2225} 
2326
2427selectionChanged ( selection )  { 
Original file line number Diff line number Diff 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 > 
                         You can’t perform that action at this time. 
           
                  
0 commit comments