bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Feature: Disable tooltips on touch devices

Open 0xsven opened this issue 12 years ago • 2 comments

Tooltips on touch devices don't make any sense in my application. Is there a way to disable them in general for the whole application?

0xsven avatar Apr 16 '14 16:04 0xsven

i've had success doing this - basically, you decorate the $tooltipProvider to return nothing if touch features are detected:

myApp.config(['$tooltipProvider', function ($tooltipProvider) {
    var tooltipFactory = $tooltipProvider.$get[$tooltipProvider.$get.length - 1];

    // decorate the tooltip getter
    $tooltipProvider.$get = [
        '$window',
        '$compile',
        '$timeout',
        '$parse',
        '$document',
        '$position',
        '$interpolate',
        function ( $window, $compile, $timeout, $parse, $document, $position, $interpolate ) {
            // for touch devices, don't return tooltips
            if ('ontouchstart' in $window) {
                return function () {
                    return {
                        compile: function () { }
                    };
                };
            } else {
                // run the default behavior
                return tooltipFactory($window, $compile, $timeout, $parse, $document, $position, $interpolate);
            }
        }
    ];
}]);

dust4ngel avatar Oct 30 '14 17:10 dust4ngel

Thanks for that, very helpful

supercrabtree avatar Apr 02 '15 14:04 supercrabtree