bootstrap
bootstrap copied to clipboard
Feature: Disable tooltips on touch devices
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?
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);
}
}
];
}]);
Thanks for that, very helpful