|
32 | 32 | var ngModel = ctrls[1];
|
33 | 33 |
|
34 | 34 | var searchInput = element.querySelectorAll('input.ui-select-search');
|
35 |
| - var scrollFlag = false; // marks if the mouseover event is triggered by the ensureHighlightVisible function call. stopPropagation if so |
36 | 35 |
|
37 | 36 | //From view --> model
|
38 | 37 | ngModel.$parsers.unshift(function (inputValue) {
|
|
81 | 80 | $select.selected = ngModel.$viewValue;
|
82 | 81 | };
|
83 | 82 |
|
84 |
| - // element.on('focusin', function(){ |
85 |
| - // console.log('focusin event on dropdown-list') |
86 |
| - // }); |
87 | 83 |
|
88 |
| - // element.on('mouseover', function(){ |
89 |
| - // console.log('mouseover event bubble mode'); |
90 |
| - // }); |
91 |
| - |
92 |
| - element[0].addEventListener('mouseover', function(e){ |
93 |
| - console.log('mouseover event capture mode'); |
94 |
| - if (scrollFlag){ |
95 |
| - e.preventDefault(); |
96 |
| - e.stopPropagation(); |
97 |
| - } |
98 |
| - scrollFlag = false; |
99 |
| - }, true); |
| 84 | + element.on('focus', function(){ |
| 85 | + console.log('focus event on dropdown-list') |
| 86 | + }); |
100 | 87 |
|
101 | 88 | // handle key press
|
102 | 89 | element.on('keydown', function(e) {
|
103 | 90 | var key = e.which;
|
| 91 | + console.log('key event on dropdown-list'); |
104 | 92 | scope.$apply(function() {
|
105 | 93 | var processed = false;
|
106 | 94 | if (!processed && $select.items.length > 0) {
|
|
109 | 97 | if (processed) {
|
110 | 98 | //TODO Check si el tab selecciona aun correctamente
|
111 | 99 | //Crear test
|
112 |
| - console.log('processed'); |
113 | 100 | e.preventDefault();
|
114 | 101 | e.stopPropagation();
|
115 | 102 | }
|
116 | 103 | if((key === 38 || key ===40) && $select.items.length > 0){
|
117 | 104 | ensureHighlightVisible();
|
118 | 105 | }
|
| 106 | + |
| 107 | + |
119 | 108 | });
|
120 | 109 | });
|
121 | 110 |
|
|
134 | 123 | }
|
135 | 124 | });
|
136 | 125 |
|
137 |
| - // when move UP/DOWN, ensure that the dropdown scrolls to keep the current highlighted item in sight |
| 126 | + // when move the UP/DOWN, ensure that the dropdown scrolls to keep the current highlighted item in sight |
138 | 127 | function ensureHighlightVisible() {
|
139 |
| - scrollFlag = true; |
| 128 | + // debugger; |
140 | 129 | var container = angular.element(element[0].querySelectorAll('.acq-dropdown-item'));
|
141 | 130 | var choices = angular.element(container[0].querySelectorAll('.acq-dropdown-item-row'));
|
142 |
| - // if (choices.length < 1) { |
143 |
| - // throw uiSelectMinErr('choices', "Expected multiple .ui-select-choices-row but got '{0}'.", choices.length); |
144 |
| - // } |
145 |
| - // debugger; |
| 131 | + if (choices.length < 1) { |
| 132 | + throw uiSelectMinErr('choices', "Expected multiple .ui-select-choices-row but got '{0}'.", choices.length); |
| 133 | + } |
| 134 | + |
146 | 135 | var highlighted = choices[$select.activeIndex];
|
147 | 136 | var posY = highlighted.offsetTop + highlighted.clientHeight - container[0].scrollTop;
|
148 | 137 | var height = container[0].offsetHeight;
|
|
175 | 164 | $document.on('click', onDocumentClick);
|
176 | 165 |
|
177 | 166 | element.on('$destroy', function(){
|
178 |
| - |
| 167 | + console.log('dropdow-list directive element destroy'); |
179 | 168 | });
|
180 | 169 |
|
181 | 170 | scope.$on('$destroy', function() {
|
182 | 171 | $document.off('click', onDocumentClick);
|
| 172 | + console.log('dropdow-list directive scope destroy'); |
183 | 173 | });
|
184 | 174 |
|
185 | 175 | transcludeFn(scope, function(clone) {
|
|
0 commit comments