|
726 | 726 | };
|
727 | 727 | }]);
|
728 | 728 |
|
729 |
| - module.directive('uiGridRenderContainer', ['$timeout', '$document', 'gridUtil', 'uiGridConstants', 'uiGridCellNavService', 'uiGridCellNavConstants','$log', |
730 |
| - function ($timeout, $document, gridUtil, uiGridConstants, uiGridCellNavService, uiGridCellNavConstants, $log) { |
| 729 | + module.directive('uiGridRenderContainer', ['$timeout', '$document', 'gridUtil', 'uiGridConstants', 'uiGridCellNavService', '$compile', |
| 730 | + function ($timeout, $document, gridUtil, uiGridConstants, uiGridCellNavService, $compile) { |
731 | 731 | return {
|
732 | 732 | replace: true,
|
733 | 733 | priority: -99999, //this needs to run very last
|
|
746 | 746 |
|
747 | 747 | var grid = uiGridCtrl.grid;
|
748 | 748 |
|
| 749 | + // focusser only created for body |
| 750 | + if (containerId !== 'body') { |
| 751 | + return; |
| 752 | + } |
| 753 | + |
749 | 754 | // Needs to run last after all renderContainers are built
|
750 | 755 | uiGridCellNavService.decorateRenderContainers(grid);
|
751 | 756 |
|
| 757 | + //add an element with no dimensions that can be used to set focus and capture keystrokes |
| 758 | + var focuser = $compile('<div class="ui-grid-focuser" tabindex="-1"></div>')($scope); |
| 759 | + $elm.append(focuser); |
| 760 | + |
| 761 | + uiGridCtrl.focus = function () { |
| 762 | + focuser[0].focus(); |
| 763 | + }; |
| 764 | + |
| 765 | + // Bind to keydown events in the render container |
| 766 | + focuser.on('keydown', function (evt) { |
| 767 | + evt.uiGridTargetRenderContainerId = containerId; |
| 768 | + var rowCol = uiGridCtrl.grid.api.cellNav.getFocusedCell(); |
| 769 | + var result = uiGridCtrl.cellNav.handleKeyDown(evt); |
| 770 | + if (result === null) { |
| 771 | + uiGridCtrl.grid.api.cellNav.raise.viewPortKeyDown(evt, rowCol); |
| 772 | + } |
| 773 | + }); |
| 774 | + |
752 | 775 | }
|
753 | 776 | };
|
754 | 777 | }
|
|
781 | 804 |
|
782 | 805 | var grid = uiGridCtrl.grid;
|
783 | 806 |
|
784 |
| - //add an element with no dimensions that can be used to set focus and capture keystrokes |
785 |
| - var focuser = $compile('<div class="ui-grid-focuser" tabindex="-1"></div>')($scope); |
786 |
| - $elm.append(focuser); |
787 | 807 |
|
788 |
| - uiGridCtrl.focus = function () { |
789 |
| - focuser[0].focus(); |
790 |
| - }; |
791 | 808 |
|
792 | 809 | uiGridCtrl.focus();
|
793 | 810 |
|
794 |
| - // Bind to keydown events in the render container |
795 |
| - focuser.on('keydown', function (evt) { |
796 |
| - evt.uiGridTargetRenderContainerId = containerId; |
797 |
| - var rowCol = uiGridCtrl.grid.api.cellNav.getFocusedCell(); |
798 |
| - var result = uiGridCtrl.cellNav.handleKeyDown(evt); |
799 |
| - if (result === null) { |
800 |
| - uiGridCtrl.grid.api.cellNav.raise.viewPortKeyDown(evt, rowCol); |
801 |
| - } |
802 |
| - }); |
| 811 | + |
803 | 812 |
|
804 | 813 | grid.api.core.on.scrollBegin($scope, function (args) {
|
805 | 814 |
|
|
0 commit comments