diff --git a/src/tooltip/docs/demo.html b/src/tooltip/docs/demo.html index 4f26ba402c..c3fb94b8a9 100644 --- a/src/tooltip/docs/demo.html +++ b/src/tooltip/docs/demo.html @@ -10,20 +10,36 @@

Pellentesque {{dynamicTooltipText}}, sit amet venenatis urna cursus eget nunc scelerisque viverra mauris, in - aliquam. Tincidunt lobortis feugiat vivamus at + aliquam. Tincidunt lobortis feugiat vivamus at left eget arcu dictum varius duis at consectetur lorem. Vitae elementum curabitur - right - nunc sed velit dignissim sodales ut eu sem integer vitae. Turpis egestas - bottom - pharetra convallis posuere morbi leo urna, + right + nunc sed velit dignissim sodales ut eu sem integer vitae. Turpis egestas + bottom + pharetra convallis posuere morbi leo urna, fading at elementum eu, facilisis sed odio morbi quis commodo odio. In cursus delayed turpis massa tincidunt dui ut.

- I can even contain HTML. Check me out! + I can even contain HTML. Check me out! +

+ +

+ + I can have a custom class. Check me out!

diff --git a/src/tooltip/docs/readme.md b/src/tooltip/docs/readme.md index 40ab67f6cb..0df72aadf7 100644 --- a/src/tooltip/docs/readme.md +++ b/src/tooltip/docs/readme.md @@ -18,6 +18,7 @@ will display: - `tooltip-trigger`: What should trigger a show of the tooltip? - `tooltip-append-to-body`: Should the tooltip be appended to `$body` instead of the parent element? +- `tooltip-class`: Custom class to be applied to the tooltip. The tooltip directives require the `$position` service. diff --git a/src/tooltip/test/tooltip2.spec.js b/src/tooltip/test/tooltip2.spec.js index 7162d23208..9b863e6822 100644 --- a/src/tooltip/test/tooltip2.spec.js +++ b/src/tooltip/test/tooltip2.spec.js @@ -101,6 +101,22 @@ describe('tooltip directive', function () { }); + describe('class', function () { + + it('can specify a custom class', function () { + var fragment = compileTooltip('Trigger here'); + fragment.find('span').trigger( 'mouseenter' ); + + var ttipElement = fragment.find('div.tooltip'); + expect(fragment).toHaveOpenTooltips(); + expect(ttipElement).toHaveClass('custom'); + + closeTooltip(fragment.find('span')); + expect(fragment).not.toHaveOpenTooltips(); + }); + + }); + }); it('should show even after close trigger is called multiple times - issue #1847', function () { @@ -133,4 +149,4 @@ describe('tooltip directive', function () { expect(fragment).not.toHaveOpenTooltips(); }); -}); \ No newline at end of file +}); diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index 4659e8bdc7..b24fb99591 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -100,6 +100,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap 'title="'+startSym+'title'+endSym+'" '+ 'content="'+startSym+'content'+endSym+'" '+ 'placement="'+startSym+'placement'+endSym+'" '+ + 'class="'+startSym+'class'+endSym+'" '+ 'animation="animation" '+ 'is-open="isOpen"'+ '>'+ @@ -270,6 +271,10 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap ttScope.title = val; }); + attrs.$observe( prefix+'Class', function ( val ) { + ttScope.class = val; + }); + function prepPlacement() { var val = attrs[ prefix + 'Placement' ]; ttScope.placement = angular.isDefined( val ) ? val : options.placement; @@ -337,7 +342,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap return { restrict: 'EA', replace: true, - scope: { content: '@', placement: '@', animation: '&', isOpen: '&' }, + scope: { content: '@', placement: '@', class: '@', animation: '&', isOpen: '&' }, templateUrl: 'template/tooltip/tooltip-popup.html' }; }) @@ -350,7 +355,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap return { restrict: 'EA', replace: true, - scope: { content: '@', placement: '@', animation: '&', isOpen: '&' }, + scope: { content: '@', placement: '@', class: '@', animation: '&', isOpen: '&' }, templateUrl: 'template/tooltip/tooltip-html-unsafe-popup.html' }; }) diff --git a/template/tooltip/tooltip-html-unsafe-popup.html b/template/tooltip/tooltip-html-unsafe-popup.html index 129016d9c1..b5b3784acf 100644 --- a/template/tooltip/tooltip-html-unsafe-popup.html +++ b/template/tooltip/tooltip-html-unsafe-popup.html @@ -1,4 +1,4 @@ -
+
diff --git a/template/tooltip/tooltip-popup.html b/template/tooltip/tooltip-popup.html index fd51120774..14c3e3a27c 100644 --- a/template/tooltip/tooltip-popup.html +++ b/template/tooltip/tooltip-popup.html @@ -1,4 +1,4 @@ -
+