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