|
461 | 461 | }
|
462 | 462 |
|
463 | 463 | if (selected && noUnselect){
|
464 |
| - // don't deselect the row |
| 464 | + // don't deselect the row |
465 | 465 | } else if (row.enableSelection !== false) {
|
466 | 466 | row.setSelected(!selected);
|
467 | 467 | if (row.isSelected === true) {
|
|
642 | 642 |
|
643 | 643 | uiGridCtrl.grid.addRowHeaderColumn(selectionRowHeaderDef);
|
644 | 644 | }
|
645 |
| - |
| 645 | + |
646 | 646 | var processorSet = false;
|
647 |
| - |
| 647 | + |
648 | 648 | var processSelectableRows = function( rows ){
|
649 | 649 | rows.forEach(function(row){
|
650 | 650 | row.enableSelection = uiGridCtrl.grid.options.isRowSelectable(row);
|
651 | 651 | });
|
652 | 652 | return rows;
|
653 | 653 | };
|
654 |
| - |
| 654 | + |
655 | 655 | var updateOptions = function(){
|
656 | 656 | if (uiGridCtrl.grid.options.isRowSelectable !== angular.noop && processorSet !== true) {
|
657 | 657 | uiGridCtrl.grid.registerRowsProcessor(processSelectableRows, 500);
|
658 | 658 | processorSet = true;
|
659 | 659 | }
|
660 | 660 | };
|
661 |
| - |
| 661 | + |
662 | 662 | updateOptions();
|
663 | 663 |
|
664 | 664 | var dataChangeDereg = uiGridCtrl.grid.registerDataChangeCallback( updateOptions, [uiGridConstants.dataChange.OPTIONS] );
|
665 |
| - |
| 665 | + |
666 | 666 | $scope.$on( '$destroy', dataChangeDereg);
|
667 | 667 | },
|
668 | 668 | post: function ($scope, $elm, $attrs, uiGridCtrl) {
|
|
673 | 673 | };
|
674 | 674 | }]);
|
675 | 675 |
|
676 |
| - module.directive('uiGridSelectionRowHeaderButtons', ['$templateCache', 'uiGridSelectionService', |
677 |
| - function ($templateCache, uiGridSelectionService) { |
| 676 | + module.directive('uiGridSelectionRowHeaderButtons', ['$templateCache', 'uiGridSelectionService', 'gridUtil', |
| 677 | + function ($templateCache, uiGridSelectionService, gridUtil) { |
678 | 678 | return {
|
679 | 679 | replace: true,
|
680 | 680 | restrict: 'E',
|
|
683 | 683 | require: '^uiGrid',
|
684 | 684 | link: function($scope, $elm, $attrs, uiGridCtrl) {
|
685 | 685 | var self = uiGridCtrl.grid;
|
686 |
| - $scope.selectButtonClick = function(row, evt) { |
| 686 | + $scope.selectButtonClick = selectButtonClick; |
| 687 | + |
| 688 | + // On IE, prevent mousedowns on the select button from starting a selection. |
| 689 | + // If this is not done and you shift+click on another row, the browser will select a big chunk of text |
| 690 | + if (gridUtil.detectBrowser() === 'ie') { |
| 691 | + $elm.on('mousedown', selectButtonMouseDown); |
| 692 | + } |
| 693 | + |
| 694 | + |
| 695 | + function selectButtonClick(row, evt) { |
687 | 696 | evt.stopPropagation();
|
| 697 | + |
688 | 698 | if (evt.shiftKey) {
|
689 | 699 | uiGridSelectionService.shiftSelect(self, row, evt, self.options.multiSelect);
|
690 | 700 | }
|
|
694 | 704 | else {
|
695 | 705 | uiGridSelectionService.toggleRowSelection(self, row, evt, (self.options.multiSelect && !self.options.modifierKeysToMultiSelect), self.options.noUnselect);
|
696 | 706 | }
|
697 |
| - }; |
| 707 | + } |
| 708 | + |
| 709 | + function selectButtonMouseDown(evt) { |
| 710 | + if (evt.ctrlKey || evt.shiftKey) { |
| 711 | + evt.target.onselectstart = function () { return false; }; |
| 712 | + window.setTimeout(function () { evt.target.onselectstart = null; }, 0); |
| 713 | + } |
| 714 | + } |
698 | 715 | }
|
699 | 716 | };
|
700 | 717 | }]);
|
|
814 | 831 | var selectCells = function(evt){
|
815 | 832 | // if we get a click, then stop listening for touchend
|
816 | 833 | $elm.off('touchend', touchEnd);
|
817 |
| - |
| 834 | + |
818 | 835 | if (evt.shiftKey) {
|
819 | 836 | uiGridSelectionService.shiftSelect($scope.grid, $scope.row, evt, $scope.grid.options.multiSelect);
|
820 | 837 | }
|
|
825 | 842 | uiGridSelectionService.toggleRowSelection($scope.grid, $scope.row, evt, ($scope.grid.options.multiSelect && !$scope.grid.options.modifierKeysToMultiSelect), $scope.grid.options.noUnselect);
|
826 | 843 | }
|
827 | 844 | $scope.$apply();
|
828 |
| - |
| 845 | + |
829 | 846 | // don't re-enable the touchend handler for a little while - some devices generate both, and it will
|
830 | 847 | // take a little while to move your hand from the mouse to the screen if you have both modes of input
|
831 | 848 | $timeout(function() {
|
|
848 | 865 | // short touch
|
849 | 866 | selectCells(evt);
|
850 | 867 | }
|
851 |
| - |
| 868 | + |
852 | 869 | // don't re-enable the click handler for a little while - some devices generate both, and it will
|
853 | 870 | // take a little while to move your hand from the screen to the mouse if you have both modes of input
|
854 | 871 | $timeout(function() {
|
|
0 commit comments