diff --git a/src/tooltip/docs/demo.html b/src/tooltip/docs/demo.html index 0e7a7463e9..09aa0ba496 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 ab96a86d73..960a7d154f 100644 --- a/src/tooltip/docs/readme.md +++ b/src/tooltip/docs/readme.md @@ -21,6 +21,7 @@ will display: `tooltip-trigger`. - `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 c161ba01ac..2127a493c8 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 () { @@ -144,5 +160,4 @@ describe('tooltip directive', function () { // One needs to flush deferred functions before checking there is no tooltip. expect(fragment).not.toHaveOpenTooltips(); }); - }); diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index 70932db2b0..ec7ed327f3 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"'+ '>'+ @@ -276,6 +277,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; @@ -343,7 +348,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' }; }) @@ -356,7 +361,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 @@ -
+