Disable tooltips conditionally:
diff --git a/src/tooltip/docs/readme.md b/src/tooltip/docs/readme.md
index 602508720f..0da8848f9a 100644
--- a/src/tooltip/docs/readme.md
+++ b/src/tooltip/docs/readme.md
@@ -1,16 +1,16 @@
A lightweight, extensible directive for fancy tooltip creation. The tooltip
directive supports multiple placements, optional transition animation, and more.
-There are three versions of the tooltip: `tooltip`, `tooltip-template`, and
-`tooltip-html-unsafe`:
+There are three versions of the tooltip: `uib-tooltip`, `uib-tooltip-template`, and
+`uib-tooltip-html-unsafe`:
-- `tooltip` takes text only and will escape any HTML provided.
-- `tooltip-template` takes text that specifies the location of a template to
+- `uib-tooltip` takes text only and will escape any HTML provided.
+- `uib-tooltip-template` takes text that specifies the location of a template to
use for the tooltip. Note that this needs to be wrapped in a tag.
-- `tooltip-html` takes
+- `uib-tooltip-html` takes
whatever HTML is provided and displays it in a tooltip; *The user is responsible for ensuring the
content is safe to put into the DOM!*
-- `tooltip-html-unsafe` -- deprecated in favour of `tooltip-html`
+- `uib-tooltip-html-unsafe` -- deprecated in favour of `tooltip-html`
The tooltip directives provide several optional attributes to control how they
will display:
@@ -47,9 +47,9 @@ For any non-supported value, the trigger will be used to both show and hide the
tooltip. Using the 'none' trigger will disable the internal trigger(s), one can
then use the `tooltip-is-open` attribute exclusively to show and hide the tooltip.
-**$tooltipProvider**
+**$uibTooltipProvider**
-Through the `$tooltipProvider`, you can change the way tooltips and popovers
+Through the `$uibTooltipProvider`, you can change the way tooltips and popovers
behave by default; the attributes above always take precedence. The following
methods are available:
@@ -71,7 +71,7 @@ methods are available:
For Safari 7+ support, if you want to use the **focus** `tooltip-trigger`, you need to use an anchor tag with a tab index. For example:
```
-
+
Click Me
```
diff --git a/src/tooltip/test/tooltip-template.spec.js b/src/tooltip/test/tooltip-template.spec.js
index 79c1d2c702..ad1c97318f 100644
--- a/src/tooltip/test/tooltip-template.spec.js
+++ b/src/tooltip/test/tooltip-template.spec.js
@@ -17,7 +17,7 @@ describe('tooltip template', function() {
beforeEach(inject(function($rootScope, $compile) {
elmBody = angular.element(
- '
Selector Text
'
+ '
Selector Text
'
);
scope = $rootScope;
@@ -82,3 +82,65 @@ describe('tooltip template', function() {
expect(elmBody.children().length).toBe(1);
}));
});
+
+/* Deprecation tests below */
+
+describe('tooltip template deprecation', function() {
+ beforeEach(module('ui.bootstrap.tooltip'));
+ beforeEach(module('template/tooltip/tooltip-template-popup.html'));
+
+ var elm, elmBody, elmScope, tooltipScope;
+
+ function trigger(element, evt) {
+ evt = new Event(evt);
+
+ element[0].dispatchEvent(evt);
+ element.scope().$$childTail.$digest();
+ }
+
+ it('should suppress warning', function() {
+ module(function($provide) {
+ $provide.value('$tooltipSuppressWarning', true);
+ });
+
+ inject(function($compile, $log, $rootScope, $templateCache) {
+ spyOn($log, 'warn');
+ $templateCache.put('myUrl', [200, '
{{ myTemplateText }} ', {}]);
+ $rootScope.templateUrl = 'myUrl';
+
+ elmBody = angular.element('
Selector Text
');
+ $compile(elmBody)($rootScope);
+ $rootScope.$digest();
+ elm = elmBody.find('span');
+ elmScope = elm.scope();
+ tooltipScope = elmScope.$$childTail;
+
+ trigger(elm, 'mouseenter');
+
+ expect($log.warn.calls.count()).toBe(0);
+ });
+ });
+
+ it('should give warning by default', inject(function($compile, $log, $rootScope, $templateCache) {
+ spyOn($log, 'warn');
+ $templateCache.put('myUrl', [200, '
{{ myTemplateText }} ', {}]);
+ $rootScope.templateUrl = 'myUrl';
+
+ var element = '
Selector Text
';
+ element = $compile(element)($rootScope);
+ $rootScope.$digest();
+
+ elmBody = angular.element('
Selector Text
');
+ $compile(elmBody)($rootScope);
+ $rootScope.$digest();
+ elm = elmBody.find('span');
+ elmScope = elm.scope();
+ tooltipScope = elmScope.$$childTail;
+
+ trigger(elm, 'mouseenter');
+
+ expect($log.warn.calls.count()).toBe(2);
+ expect($log.warn.calls.argsFor(0)).toEqual(['$tooltip is now deprecated. Use $uibTooltip instead.']);
+ expect($log.warn.calls.argsFor(1)).toEqual(['tooltip-template-popup is now deprecated. Use uib-tooltip-template-popup instead.']);
+ }));
+});
diff --git a/src/tooltip/test/tooltip.spec.js b/src/tooltip/test/tooltip.spec.js
index e99675aa6c..a8c731a42f 100644
--- a/src/tooltip/test/tooltip.spec.js
+++ b/src/tooltip/test/tooltip.spec.js
@@ -14,7 +14,7 @@ describe('tooltip', function() {
beforeEach(inject(function($rootScope, $compile, _$document_) {
elmBody = angular.element(
- '
Selector Text
'
+ '
Selector Text
'
);
$document = _$document_;
@@ -67,7 +67,7 @@ describe('tooltip', function() {
it('should allow specification of placement', inject(function($compile) {
elm = $compile(angular.element(
- '
Selector Text '
+ '
Selector Text '
))(scope);
scope.$apply();
elmScope = elm.scope();
@@ -80,7 +80,7 @@ describe('tooltip', function() {
it('should update placement dynamically', inject(function($compile, $timeout) {
scope.place = 'bottom';
elm = $compile(angular.element(
- '
Selector Text '
+ '
Selector Text '
))(scope);
scope.$apply();
elmScope = elm.scope();
@@ -99,7 +99,7 @@ describe('tooltip', function() {
elm = $compile(angular.element(
'
'+
''+
- '{{item.name}} '+
+ '{{item.name}} '+
' '+
' '
))(scope);
@@ -126,7 +126,7 @@ describe('tooltip', function() {
elm = $compile(angular.element(
'
'+
''+
- '{{item.name}} '+
+ '{{item.name}} '+
' '+
' '
))(scope);
@@ -165,7 +165,7 @@ describe('tooltip', function() {
scope.alt = 'Alt Message';
elmBody = $compile(angular.element(
- '
Selector Text
'
+ '
Selector Text
'
))(scope);
$compile(elmBody)(scope);
@@ -192,7 +192,7 @@ describe('tooltip', function() {
it('should not show tooltips if there is nothing to show - issue #129', inject(function($compile) {
elmBody = $compile(angular.element(
- '
Selector Text
'
+ '
Selector Text
'
))(scope);
scope.$digest();
elmBody.find('span').trigger('mouseenter');
@@ -231,7 +231,7 @@ describe('tooltip', function() {
beforeEach(inject(function($compile) {
scope.enable = false;
elmBody = $compile(angular.element(
- '
Selector Text
'
+ '
Selector Text
'
))(scope);
scope.$digest();
elm = elmBody.find('span');
@@ -260,7 +260,7 @@ describe('tooltip', function() {
$timeout = _$timeout_;
scope.delay = '1000';
elm = $compile(angular.element(
- '
Selector Text '
+ '
Selector Text '
))(scope);
elmScope = elm.scope();
tooltipScope = elmScope.$$childTail;
@@ -324,7 +324,7 @@ describe('tooltip', function() {
});
it('should close the tooltips in order', inject(function($compile) {
- var elm2 = $compile('
Selector Text
')(scope);
+ var elm2 = $compile('
Selector Text
')(scope);
scope.$digest();
elm2 = elm2.find('span');
var tooltipScope2 = elm2.scope().$$childTail;
@@ -369,7 +369,7 @@ describe('tooltip', function() {
beforeEach(inject(function ($compile) {
scope.isOpen = false;
elm = $compile(angular.element(
- '
Selector Text '
+ '
Selector Text '
))(scope);
elmScope = elm.scope();
tooltipScope = elmScope.$$childTail;
@@ -398,7 +398,7 @@ describe('tooltip', function() {
beforeEach(inject(function($compile) {
scope.isOpen = false;
elm = $compile(angular.element(
- '
Selector Text '
+ '
Selector Text '
))(scope);
elmScope = elm.scope();
tooltipScope = elmScope.$$childTail;
@@ -425,7 +425,7 @@ describe('tooltip', function() {
it('should use it to show but set the hide trigger based on the map for mapped triggers', inject(function($compile) {
elmBody = angular.element(
- '
'
+ '
'
);
$compile(elmBody)(scope);
scope.$apply();
@@ -442,7 +442,7 @@ describe('tooltip', function() {
it('should use it as both the show and hide triggers for unmapped triggers', inject(function($compile) {
elmBody = angular.element(
- '
'
+ '
'
);
$compile(elmBody)(scope);
scope.$apply();
@@ -461,8 +461,8 @@ describe('tooltip', function() {
scope.test = true;
elmBody = angular.element(
'
' +
- ' ' +
- ' ' +
+ ' ' +
+ ' ' +
'
'
);
@@ -487,7 +487,7 @@ describe('tooltip', function() {
it('should accept multiple triggers based on the map for mapped triggers', inject(function($compile) {
elmBody = angular.element(
- '
'
+ '
'
);
$compile(elmBody)(scope);
scope.$apply();
@@ -508,7 +508,7 @@ describe('tooltip', function() {
it('should not show when trigger is set to "none"', inject(function($compile) {
elmBody = angular.element(
- '
'
+ '
'
);
$compile(elmBody)(scope);
scope.$apply();
@@ -535,7 +535,7 @@ describe('tooltip', function() {
it('should append to the body', inject(function($compile, $document) {
$body = $document.find('body');
elmBody = angular.element(
- '
Selector Text
'
+ '
Selector Text
'
);
$compile(elmBody)(scope);
@@ -569,7 +569,7 @@ describe('tooltip', function() {
}
beforeEach(inject(function($compile, $rootScope) {
- elmBody = angular.element('
');
+ elmBody = angular.element('
');
$compile(elmBody)($rootScope);
$rootScope.$apply();
@@ -594,7 +594,7 @@ describe('tooltip', function() {
scope = $rootScope;
scope.content = 'tooltip content';
scope.placement = 'top';
- elmBody = angular.element('
');
+ elmBody = angular.element('
');
$compile(elmBody)(scope);
scope.$apply();
@@ -652,7 +652,7 @@ describe('tooltipWithDifferentSymbols', function() {
it('should show the correct tooltip text', inject(function($compile, $rootScope) {
elmBody = angular.element(
- '
'
+ '
'
);
$compile(elmBody)($rootScope);
$rootScope.$apply();
@@ -683,7 +683,7 @@ describe('tooltip positioning', function() {
scope.text = 'Some Text';
elmBody = $compile(angular.element(
- '
Selector Text
'
+ '
Selector Text
'
))(scope);
scope.$digest();
elm = elmBody.find('span');
@@ -708,7 +708,7 @@ describe('tooltip positioning', function() {
scope.text = 'New Text';
scope.$digest();
$timeout.flush();
- expect(elm.attr('tooltip')).toBe('New Text' );
+ expect(elm.attr('uib-tooltip')).toBe('New Text');
expect($position.positionElements.calls.count()).toEqual(startingPositionCalls + 1);
// Check that positionElements was called with elm
expect($position.positionElements.calls.argsFor(startingPositionCalls)[0][0])
@@ -741,7 +741,7 @@ describe('tooltipHtml', function() {
scope.safeHtml = $sce.trustAsHtml(scope.html);
elmBody = $compile(angular.element(
- '
Selector Text
'
+ '
Selector Text
'
))(scope);
scope.$digest();
elm = elmBody.find('span');
@@ -756,7 +756,6 @@ describe('tooltipHtml', function() {
element.scope().$$childTail.$digest();
}
-
it('should render html properly', inject(function() {
trigger(elm, 'mouseenter');
expect(elmBody.find('.tooltip-inner').html()).toBe(scope.html);
@@ -808,7 +807,7 @@ describe('$tooltipProvider', function() {
beforeEach(inject(function($rootScope, $compile) {
elmBody = angular.element(
- '
Selector Text
'
+ '
Selector Text
'
);
scope = $rootScope;
@@ -843,7 +842,7 @@ describe('$tooltipProvider', function() {
it('should append to the body', inject(function($rootScope, $compile, $document) {
$body = $document.find('body');
elmBody = angular.element(
- '
Selector Text
'
+ '
Selector Text
'
);
scope = $rootScope;
@@ -863,7 +862,7 @@ describe('$tooltipProvider', function() {
it('should close on location change', inject(function($rootScope, $compile) {
elmBody = angular.element(
- '
Selector Text
'
+ '
Selector Text
'
);
scope = $rootScope;
@@ -884,8 +883,8 @@ describe('$tooltipProvider', function() {
describe('triggers', function() {
describe('triggers with a mapped value', function() {
- beforeEach(module('ui.bootstrap.tooltip', function($tooltipProvider) {
- $tooltipProvider.options({trigger: 'focus'});
+ beforeEach(module('ui.bootstrap.tooltip', function($uibTooltipProvider) {
+ $uibTooltipProvider.options({trigger: 'focus'});
}));
// load the template
@@ -893,7 +892,7 @@ describe('$tooltipProvider', function() {
it('should use the show trigger and the mapped value for the hide trigger', inject(function($rootScope, $compile) {
elmBody = angular.element(
- '
'
+ '
'
);
scope = $rootScope;
@@ -912,7 +911,7 @@ describe('$tooltipProvider', function() {
it('should override the show and hide triggers if there is an attribute', inject(function($rootScope, $compile) {
elmBody = angular.element(
- '
'
+ '
'
);
scope = $rootScope;
@@ -931,9 +930,9 @@ describe('$tooltipProvider', function() {
});
describe('triggers with a custom mapped value', function() {
- beforeEach(module('ui.bootstrap.tooltip', function($tooltipProvider) {
- $tooltipProvider.setTriggers({ customOpenTrigger: 'foo bar' });
- $tooltipProvider.options({trigger: 'customOpenTrigger'});
+ beforeEach(module('ui.bootstrap.tooltip', function($uibTooltipProvider) {
+ $uibTooltipProvider.setTriggers({ customOpenTrigger: 'foo bar' });
+ $uibTooltipProvider.options({trigger: 'customOpenTrigger'});
}));
// load the template
@@ -941,7 +940,7 @@ describe('$tooltipProvider', function() {
it('should use the show trigger and the mapped value for the hide trigger', inject(function($rootScope, $compile) {
elmBody = angular.element(
- '
'
+ '
'
);
scope = $rootScope;
@@ -964,8 +963,8 @@ describe('$tooltipProvider', function() {
});
describe('triggers without a mapped value', function() {
- beforeEach(module('ui.bootstrap.tooltip', function($tooltipProvider) {
- $tooltipProvider.options({trigger: 'fakeTrigger'});
+ beforeEach(module('ui.bootstrap.tooltip', function($uibTooltipProvider) {
+ $uibTooltipProvider.options({trigger: 'fakeTrigger'});
}));
// load the template
@@ -973,7 +972,7 @@ describe('$tooltipProvider', function() {
it('should use the show trigger to hide', inject(function($rootScope, $compile) {
elmBody = angular.element(
- '
Selector Text
'
+ '
Selector Text
'
);
scope = $rootScope;
diff --git a/src/tooltip/test/tooltip2.spec.js b/src/tooltip/test/tooltip2.spec.js
index 5554be0849..2ed8e2b1a4 100644
--- a/src/tooltip/test/tooltip2.spec.js
+++ b/src/tooltip/test/tooltip2.spec.js
@@ -60,7 +60,7 @@ describe('tooltip directive', function() {
describe('basic scenarios with default options', function() {
it('shows default tooltip on mouse enter and closes on mouse leave', function() {
- var fragment = compileTooltip('
Trigger here ');
+ var fragment = compileTooltip('
Trigger here ');
trigger(fragment.find('span'), 'mouseenter');
expect(fragment).toHaveOpenTooltips();
@@ -70,14 +70,14 @@ describe('tooltip directive', function() {
});
it('should not show a tooltip when its content is empty', function() {
- var fragment = compileTooltip('
');
+ var fragment = compileTooltip('
');
trigger(fragment.find('span'), 'mouseenter');
expect(fragment).not.toHaveOpenTooltips();
});
it('should not show a tooltip when its content becomes empty', function() {
$rootScope.content = 'some text';
- var fragment = compileTooltip('
');
+ var fragment = compileTooltip('
');
trigger(fragment.find('span'), 'mouseenter');
expect(fragment).toHaveOpenTooltips();
@@ -90,7 +90,7 @@ describe('tooltip directive', function() {
it('should update tooltip when its content becomes empty', function() {
$rootScope.content = 'some text';
- var fragment = compileTooltip('
');
+ var fragment = compileTooltip('
');
$rootScope.content = '';
$rootScope.$digest();
@@ -102,9 +102,9 @@ describe('tooltip directive', function() {
describe('option by option', function() {
var tooltipTypes = {
- 'tooltip': 'tooltip="tooltip text"',
- 'tooltip-html': 'tooltip-html="tooltipSafeHtml"',
- 'tooltip-template': 'tooltip-template="\'tooltipTextUrl\'"'
+ 'tooltip': 'uib-tooltip="tooltip text"',
+ 'tooltip-html': 'uib-tooltip-html="tooltipSafeHtml"',
+ 'tooltip-template': 'uib-tooltip-template="\'tooltipTextUrl\'"'
};
beforeEach(inject(function($sce, $templateCache) {
@@ -147,7 +147,7 @@ describe('tooltip directive', function() {
});
it('should show even after close trigger is called multiple times - issue #1847', function() {
- var fragment = compileTooltip('
Trigger here ');
+ var fragment = compileTooltip('
Trigger here ');
trigger(fragment.find('span'), 'mouseenter');
expect(fragment).toHaveOpenTooltips();
@@ -167,7 +167,7 @@ describe('tooltip directive', function() {
});
it('should hide even after show trigger is called multiple times', function() {
- var fragment = compileTooltip('
Trigger here ');
+ var fragment = compileTooltip('
Trigger here ');
trigger(fragment.find('span'), 'mouseenter');
trigger(fragment.find('span'), 'mouseenter');
@@ -177,7 +177,7 @@ describe('tooltip directive', function() {
});
it('should not show tooltips element is disabled (button) - issue #3167', function() {
- var fragment = compileTooltip('
Cancel ');
+ var fragment = compileTooltip('
Cancel ');
trigger(fragment.find('button'), 'mouseenter');
expect(fragment).toHaveOpenTooltips();
@@ -188,3 +188,95 @@ describe('tooltip directive', function() {
expect(fragment).not.toHaveOpenTooltips();
});
});
+
+/* Deprecation tests below */
+
+describe('tooltip deprecation', function() {
+ beforeEach(module('ui.bootstrap.tooltip'));
+ beforeEach(module('template/tooltip/tooltip-popup.html'));
+ beforeEach(module('template/tooltip/tooltip-template-popup.html'));
+ beforeEach(module('template/tooltip/tooltip-html-popup.html'));
+
+ describe('tooltip', function() {
+ it('should suppress warning', function() {
+ module(function($provide) {
+ $provide.value('$tooltipSuppressWarning', true);
+ });
+
+ inject(function($compile, $log, $rootScope) {
+ spyOn($log, 'warn');
+
+ var element = '
Trigger here
';
+ element = $compile(element)($rootScope);
+ $rootScope.$digest();
+ expect($log.warn.calls.count()).toBe(0);
+ });
+ });
+
+ it('should give warning by default', inject(function($compile, $log, $rootScope) {
+ spyOn($log, 'warn');
+
+ var element = '
Trigger here
';
+ element = $compile(element)($rootScope);
+ $rootScope.$digest();
+
+ expect($log.warn.calls.count()).toBe(1);
+ expect($log.warn.calls.argsFor(0)).toEqual(['$tooltip is now deprecated. Use $uibTooltip instead.']);
+ }));
+ });
+
+ describe('tooltip html', function() {
+ var elm, elmBody, elmScope, tooltipScope;
+
+ function trigger(element, evt) {
+ evt = new Event(evt);
+
+ element[0].dispatchEvent(evt);
+ element.scope().$$childTail.$digest();
+ }
+
+ it('should suppress warning', function() {
+ module(function($provide) {
+ $provide.value('$tooltipSuppressWarning', true);
+ });
+
+ inject(function($compile, $log, $rootScope, $sce) {
+ spyOn($log, 'warn');
+
+ $rootScope.html = 'I say:
Hello! ';
+ $rootScope.safeHtml = $sce.trustAsHtml($rootScope.html);
+ elmBody = angular.element('
Selector Text
');
+ $compile(elmBody)($rootScope);
+ $rootScope.$digest();
+ elm = elmBody.find('span');
+ elmScope = elm.scope();
+ tooltipScope = elmScope.$$childTail;
+
+ trigger(elm, 'mouseenter');
+ tooltipScope.$digest();
+
+ expect($log.warn.calls.count()).toBe(0);
+ });
+ });
+
+ it('should give warning by default', inject(function($compile, $log, $rootScope, $sce) {
+ spyOn($log, 'warn');
+
+ $rootScope.html = 'I say:
Hello! ';
+ $rootScope.safeHtml = $sce.trustAsHtml($rootScope.html);
+ elmBody = angular.element('
Selector Text
');
+ $compile(elmBody)($rootScope);
+ $rootScope.$digest();
+ elm = elmBody.find('span');
+ elmScope = elm.scope();
+ tooltipScope = elmScope.$$childTail;
+
+ trigger(elm, 'mouseenter');
+ tooltipScope.$digest();
+
+ expect($log.warn.calls.count()).toBe(2);
+ expect($log.warn.calls.argsFor(0)).toEqual(['$tooltip is now deprecated. Use $uibTooltip instead.']);
+ expect($log.warn.calls.argsFor(1)).toEqual(['tooltip-html-popup is now deprecated. Use uib-tooltip-html-popup instead.']);
+ }));
+ });
+});
diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js
index 5c330382c9..e75afaf998 100644
--- a/src/tooltip/tooltip.js
+++ b/src/tooltip/tooltip.js
@@ -9,7 +9,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
* The $tooltip service creates tooltip- and popover-like directives as well as
* houses global options for them.
*/
-.provider('$tooltip', function() {
+.provider('$uibTooltip', function() {
// The default options tooltip and popover.
var defaultOptions = {
placement: 'top',
@@ -112,22 +112,21 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
var startSym = $interpolate.startSymbol();
var endSym = $interpolate.endSymbol();
var template =
- '
'+
+ 'content="' + startSym + 'content' + endSym + '" ') +
+ 'placement="' + startSym + 'placement' + endSym + '" '+
+ 'popup-class="' + startSym + 'popupClass' + endSym + '" '+
+ 'animation="animation" ' +
+ 'is-open="isOpen"' +
+ 'origin-scope="origScope" ' +
+ 'style="visibility: hidden; display: block;"' +
+ '>' +
'
';
return {
- restrict: 'EA',
compile: function(tElem, tAttrs) {
var tooltipLinker = $compile(template);
@@ -317,6 +316,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
} else {
ttScope.content = attrs[ttType];
}
+
ttScope.popupClass = attrs[prefix + 'Class'];
ttScope.placement = angular.isDefined(attrs[prefix + 'Placement']) ? attrs[prefix + 'Placement'] : options.placement;
@@ -348,6 +348,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
if (!val === ttScope.isOpen) {
toggleTooltipBind();
}
+ /*jshint +W018 */
});
}
@@ -455,6 +456,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
});
}
}
+
prepTriggers();
var animation = scope.$eval(attrs[prefix + 'Animation']);
@@ -491,7 +493,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
})
// This is mostly ngInclude code but with a custom scope
-.directive('tooltipTemplateTransclude', [
+.directive('uibTooltipTemplateTransclude', [
'$animate', '$sce', '$compile', '$templateRequest',
function ($animate , $sce , $compile , $templateRequest) {
return {
@@ -508,10 +510,12 @@ function ($animate , $sce , $compile , $templateRequest) {
previousElement.remove();
previousElement = null;
}
+
if (currentScope) {
currentScope.$destroy();
currentScope = null;
}
+
if (currentElement) {
$animate.leave(currentElement).then(function() {
previousElement = null;
@@ -521,7 +525,7 @@ function ($animate , $sce , $compile , $templateRequest) {
}
};
- scope.$watch($sce.parseAsResourceUrl(attrs.tooltipTemplateTransclude), function(src) {
+ scope.$watch($sce.parseAsResourceUrl(attrs.uibTooltipTemplateTransclude), function(src) {
var thisChangeId = ++changeCounter;
if (src) {
@@ -563,16 +567,18 @@ function ($animate , $sce , $compile , $templateRequest) {
* They must not be animated as they're expected to be present on the tooltip on
* initialization.
*/
-.directive('tooltipClasses', function() {
+.directive('uibTooltipClasses', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
if (scope.placement) {
element.addClass(scope.placement);
}
+
if (scope.popupClass) {
element.addClass(scope.popupClass);
}
+
if (scope.animation()) {
element.addClass(attrs.tooltipAnimationClass);
}
@@ -580,22 +586,20 @@ function ($animate , $sce , $compile , $templateRequest) {
};
})
-.directive('tooltipPopup', function() {
+.directive('uibTooltipPopup', function() {
return {
- restrict: 'EA',
replace: true,
scope: { content: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
templateUrl: 'template/tooltip/tooltip-popup.html'
};
})
-.directive('tooltip', [ '$tooltip', function($tooltip) {
- return $tooltip('tooltip', 'tooltip', 'mouseenter');
+.directive('uibTooltip', [ '$uibTooltip', function($uibTooltip) {
+ return $uibTooltip('uibTooltip', 'tooltip', 'mouseenter');
}])
-.directive('tooltipTemplatePopup', function() {
+.directive('uibTooltipTemplatePopup', function() {
return {
- restrict: 'EA',
replace: true,
scope: { contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&',
originScope: '&' },
@@ -603,21 +607,187 @@ function ($animate , $sce , $compile , $templateRequest) {
};
})
-.directive('tooltipTemplate', ['$tooltip', function($tooltip) {
- return $tooltip('tooltipTemplate', 'tooltip', 'mouseenter', {
+.directive('uibTooltipTemplate', ['$uibTooltip', function($uibTooltip) {
+ return $uibTooltip('uibTooltipTemplate', 'tooltip', 'mouseenter', {
useContentExp: true
});
}])
-.directive('tooltipHtmlPopup', function() {
+.directive('uibTooltipHtmlPopup', function() {
return {
- restrict: 'EA',
replace: true,
scope: { contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
templateUrl: 'template/tooltip/tooltip-html-popup.html'
};
})
+.directive('uibTooltipHtml', ['$uibTooltip', function($uibTooltip) {
+ return $uibTooltip('uibTooltipHtml', 'tooltip', 'mouseenter', {
+ useContentExp: true
+ });
+}]);
+
+/* Deprecated tooltip below */
+
+angular.module('ui.bootstrap.tooltip')
+
+.value('$tooltipSuppressWarning', false)
+
+.provider('$tooltip', ['$uibTooltipProvider', function($uibTooltipProvider) {
+ angular.extend(this, $uibTooltipProvider);
+
+ this.$get = ['$log', '$tooltipSuppressWarning', '$injector', function($log, $tooltipSuppressWarning, $injector) {
+ if (!$tooltipSuppressWarning) {
+ $log.warn('$tooltip is now deprecated. Use $uibTooltip instead.');
+ }
+
+ return $injector.invoke($uibTooltipProvider.$get);
+ }];
+}])
+
+// This is mostly ngInclude code but with a custom scope
+.directive('tooltipTemplateTransclude', [
+ '$animate', '$sce', '$compile', '$templateRequest', '$log', '$tooltipSuppressWarning',
+function ($animate , $sce , $compile , $templateRequest, $log, $tooltipSuppressWarning) {
+ return {
+ link: function(scope, elem, attrs) {
+ if (!$tooltipSuppressWarning) {
+ $log.warn('tooltip-template-transclude is now deprecated. Use uib-tooltip-template-transclude instead.');
+ }
+
+ var origScope = scope.$eval(attrs.tooltipTemplateTranscludeScope);
+
+ var changeCounter = 0,
+ currentScope,
+ previousElement,
+ currentElement;
+
+ var cleanupLastIncludeContent = function() {
+ if (previousElement) {
+ previousElement.remove();
+ previousElement = null;
+ }
+ if (currentScope) {
+ currentScope.$destroy();
+ currentScope = null;
+ }
+ if (currentElement) {
+ $animate.leave(currentElement).then(function() {
+ previousElement = null;
+ });
+ previousElement = currentElement;
+ currentElement = null;
+ }
+ };
+
+ scope.$watch($sce.parseAsResourceUrl(attrs.tooltipTemplateTransclude), function(src) {
+ var thisChangeId = ++changeCounter;
+
+ if (src) {
+ //set the 2nd param to true to ignore the template request error so that the inner
+ //contents and scope can be cleaned up.
+ $templateRequest(src, true).then(function(response) {
+ if (thisChangeId !== changeCounter) { return; }
+ var newScope = origScope.$new();
+ var template = response;
+
+ var clone = $compile(template)(newScope, function(clone) {
+ cleanupLastIncludeContent();
+ $animate.enter(clone, elem);
+ });
+
+ currentScope = newScope;
+ currentElement = clone;
+
+ currentScope.$emit('$includeContentLoaded', src);
+ }, function() {
+ if (thisChangeId === changeCounter) {
+ cleanupLastIncludeContent();
+ scope.$emit('$includeContentError', src);
+ }
+ });
+ scope.$emit('$includeContentRequested', src);
+ } else {
+ cleanupLastIncludeContent();
+ }
+ });
+
+ scope.$on('$destroy', cleanupLastIncludeContent);
+ }
+ };
+}])
+
+.directive('tooltipClasses', ['$log', '$tooltipSuppressWarning', function($log, $tooltipSuppressWarning) {
+ return {
+ restrict: 'A',
+ link: function(scope, element, attrs) {
+ if (!$tooltipSuppressWarning) {
+ $log.warn('tooltip-classes is now deprecated. Use uib-tooltip-classes instead.');
+ }
+
+ if (scope.placement) {
+ element.addClass(scope.placement);
+ }
+ if (scope.popupClass) {
+ element.addClass(scope.popupClass);
+ }
+ if (scope.animation()) {
+ element.addClass(attrs.tooltipAnimationClass);
+ }
+ }
+ };
+}])
+
+.directive('tooltipPopup', ['$log', '$tooltipSuppressWarning', function($log, $tooltipSuppressWarning) {
+ return {
+ replace: true,
+ scope: { content: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
+ templateUrl: 'template/tooltip/tooltip-popup.html',
+ link: function() {
+ if (!$tooltipSuppressWarning) {
+ $log.warn('tooltip-classes is now deprecated. Use uib-tooltip-classes instead.');
+ }
+ }
+ };
+}])
+
+.directive('tooltip', ['$tooltip', function($tooltip) {
+ return $tooltip('tooltip', 'tooltip', 'mouseenter');
+}])
+
+.directive('tooltipTemplatePopup', ['$log', '$tooltipSuppressWarning', function($log, $tooltipSuppressWarning) {
+ return {
+ replace: true,
+ scope: { contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&',
+ originScope: '&' },
+ templateUrl: 'template/tooltip/tooltip-template-popup.html',
+ link: function() {
+ if (!$tooltipSuppressWarning) {
+ $log.warn('tooltip-template-popup is now deprecated. Use uib-tooltip-template-popup instead.');
+ }
+ }
+ };
+}])
+
+.directive('tooltipTemplate', ['$tooltip', function($tooltip) {
+ return $tooltip('tooltipTemplate', 'tooltip', 'mouseenter', {
+ useContentExp: true
+ });
+}])
+
+.directive('tooltipHtmlPopup', ['$log', '$tooltipSuppressWarning', function($log, $tooltipSuppressWarning) {
+ return {
+ replace: true,
+ scope: { contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
+ templateUrl: 'template/tooltip/tooltip-html-popup.html',
+ link: function() {
+ if (!$tooltipSuppressWarning) {
+ $log.warn('tooltip-html-popup is now deprecated. Use uib-tooltip-html-popup instead.');
+ }
+ }
+ };
+}])
+
.directive('tooltipHtml', ['$tooltip', function($tooltip) {
return $tooltip('tooltipHtml', 'tooltip', 'mouseenter', {
useContentExp: true
diff --git a/template/popover/popover-html.html b/template/popover/popover-html.html
index 0655274f35..9d33c26e27 100644
--- a/template/popover/popover-html.html
+++ b/template/popover/popover-html.html
@@ -1,6 +1,6 @@
diff --git a/template/popover/popover-template.html b/template/popover/popover-template.html
index 91c12e143d..3d8a8ec40f 100644
--- a/template/popover/popover-template.html
+++ b/template/popover/popover-template.html
@@ -1,13 +1,13 @@
diff --git a/template/popover/popover.html b/template/popover/popover.html
index fa536fd230..b31a5b4648 100644
--- a/template/popover/popover.html
+++ b/template/popover/popover.html
@@ -1,6 +1,6 @@
diff --git a/template/tooltip/tooltip-html-popup.html b/template/tooltip/tooltip-html-popup.html
index 23f60fb55d..6ecef364c3 100644
--- a/template/tooltip/tooltip-html-popup.html
+++ b/template/tooltip/tooltip-html-popup.html
@@ -1,6 +1,6 @@