|
87 | 87 | }); |
88 | 88 | }; |
89 | 89 |
|
90 | | - $element.bind('click', function (event) { |
| 90 | + var onEvent = function (event) { |
91 | 91 | event.stopPropagation(); |
92 | 92 | if (!$scope.dropdownDisabled) { |
93 | 93 | DropdownService.toggleActive($element); |
94 | 94 | } |
95 | | - }); |
| 95 | + }; |
96 | 96 |
|
97 | | - $element.bind('focus', function (event) { |
98 | | - event.stopPropagation(); |
99 | | - if (!$scope.dropdownDisabled) { |
100 | | - DropdownService.toggleActive($element); |
101 | | - } |
102 | | - }); |
| 97 | + $element.bind('click', onEvent); |
| 98 | + $element.bind('focus', onEvent); |
103 | 99 |
|
104 | 100 | $scope.$on('$destroy', function () { |
105 | 101 | DropdownService.unregister($element); |
|
174 | 170 | }); |
175 | 171 | }; |
176 | 172 |
|
177 | | - $element.bind('click', function (event) { |
| 173 | + var onEvent = function (event) { |
178 | 174 | event.stopPropagation(); |
179 | 175 | if (!$scope.dropdownDisabled) { |
180 | | - DropdownService.toggleActive(tpl); |
| 176 | + DropdownService.toggleActive($element); |
181 | 177 | } |
182 | | - }); |
| 178 | + }; |
| 179 | + |
| 180 | + $element.bind('click', onEvent); |
183 | 181 |
|
184 | 182 | $scope.$on('$destroy', function () { |
185 | 183 | DropdownService.unregister(tpl); |
|
225 | 223 | }); |
226 | 224 | }); |
227 | 225 |
|
228 | | - body.keydown(function(e) { |
229 | | - var code = e.keyCode || e.which; |
230 | | - if (code == '9') { |
| 226 | + body.bind('keydown', function (evt) { |
| 227 | + var code = evt.keyCode || evt.which; |
| 228 | + //on tab, remove 'active' any dropdown element |
| 229 | + if (code === 9) { |
231 | 230 | angular.forEach(_dropdowns, function (el) { |
232 | 231 | el.removeClass('active'); |
233 | 232 | }); |
|
0 commit comments