|
1 | 1 | uis.directive('uiSelectChoices',
|
2 |
| - ['uiSelectConfig', 'uisRepeatParser', 'uiSelectMinErr', '$compile', |
3 |
| - function(uiSelectConfig, RepeatParser, uiSelectMinErr, $compile) { |
| 2 | + ['uiSelectConfig', 'uisRepeatParser', 'uiSelectMinErr', '$compile', '$window', |
| 3 | + function(uiSelectConfig, RepeatParser, uiSelectMinErr, $compile, $window) { |
4 | 4 |
|
5 | 5 | return {
|
6 | 6 | restrict: 'EA',
|
@@ -45,12 +45,19 @@ uis.directive('uiSelectChoices',
|
45 | 45 | }
|
46 | 46 |
|
47 | 47 | choices.attr('ng-repeat', $select.parserResult.repeatExpression(groupByExp))
|
48 |
| - .attr('ng-if', '$select.open') //Prevent unnecessary watches when dropdown is closed |
49 |
| - .attr('ng-click', '$select.select(' + $select.parserResult.itemName + ',false,$event)'); |
| 48 | + .attr('ng-if', '$select.open'); //Prevent unnecessary watches when dropdown is closed |
| 49 | + if ($window.document.addEventListener) { //crude way to exclude IE8, specifically, which also cannot capture events |
| 50 | + choices.attr('ng-mouseenter', '$select.setActiveItem('+$select.parserResult.itemName +')') |
| 51 | + .attr('ng-click', '$select.select(' + $select.parserResult.itemName + ',false,$event)'); |
| 52 | + } |
50 | 53 |
|
51 | 54 | var rowsInner = element.querySelectorAll('.ui-select-choices-row-inner');
|
52 | 55 | if (rowsInner.length !== 1) throw uiSelectMinErr('rows', "Expected 1 .ui-select-choices-row-inner but got '{0}'.", rowsInner.length);
|
53 | 56 | rowsInner.attr('uis-transclude-append', ''); //Adding uisTranscludeAppend directive to row element after choices element has ngRepeat
|
| 57 | + if (!$window.document.addEventListener) { //crude way to target IE8, specifically, which also cannot capture events - so event bindings must be here |
| 58 | + rowsInner.attr('ng-mouseenter', '$select.setActiveItem('+$select.parserResult.itemName +')') |
| 59 | + .attr('ng-click', '$select.select(' + $select.parserResult.itemName + ',false,$event)'); |
| 60 | + } |
54 | 61 |
|
55 | 62 | $compile(element, transcludeFn)(scope); //Passing current transcludeFn to be able to append elements correctly from uisTranscludeAppend
|
56 | 63 |
|
|
0 commit comments