Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(tooltip): support of custom $interpolate.startSymbol
Browse files Browse the repository at this point in the history
  • Loading branch information
nils-wisiol authored and pkozlowski-opensource committed Jun 21, 2013
1 parent 58efec8 commit 88c94ee
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
34 changes: 34 additions & 0 deletions src/tooltip/test/tooltip.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,40 @@ describe('tooltip', function() {

});

describe('tooltipWithDifferentSymbols', function() {
var elm,
elmBody,
scope,
elmScope;

// load the tooltip code
beforeEach(module('ui.bootstrap.tooltip'));

// load the template
beforeEach(module('template/tooltip/tooltip-popup.html'));

// configure interpolate provider to use [[ ]] instead of {{ }}
beforeEach(module( function($interpolateProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.startSymbol(']]');
}));

it( 'should show the correct tooltip text', inject( function ( $compile, $rootScope ) {

elmBody = angular.element(
'<div><input type="text" tooltip="My tooltip" tooltip-trigger="focus" tooltip-placement="right" /></div>'
);
$compile(elmBody)($rootScope);
$rootScope.$apply();
elmInput = elmBody.find('input');
elmInput.trigger('focus');

expect( elmInput.next().find('div').next().html() ).toBe('My tooltip');

}));

});

describe( 'tooltipHtmlUnsafe', function() {
var elm, elmBody, scope;

Expand Down
10 changes: 6 additions & 4 deletions src/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] )
* Returns the actual instance of the $tooltip service.
* TODO support multiple triggers
*/
this.$get = [ '$window', '$compile', '$timeout', '$parse', '$document', '$position', function ( $window, $compile, $timeout, $parse, $document, $position ) {
this.$get = [ '$window', '$compile', '$timeout', '$parse', '$document', '$position', '$interpolate', function ( $window, $compile, $timeout, $parse, $document, $position, $interpolate ) {
return function $tooltip ( type, prefix, defaultTriggerShow ) {
var options = angular.extend( {}, defaultOptions, globalOptions );

Expand Down Expand Up @@ -92,11 +92,13 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] )
var directiveName = snake_case( type );
var triggers = setTriggers( undefined );

var startSym = $interpolate.startSymbol();
var endSym = $interpolate.endSymbol();
var template =
'<'+ directiveName +'-popup '+
'title="{{tt_title}}" '+
'content="{{tt_content}}" '+
'placement="{{tt_placement}}" '+
'title="'+startSym+'tt_title'+endSym+'" '+
'content="'+startSym+'tt_content'+endSym+'" '+
'placement="'+startSym+'tt_placement'+endSym+'" '+
'animation="tt_animation()" '+
'is-open="tt_isOpen"'+
'>'+
Expand Down

0 comments on commit 88c94ee

Please sign in to comment.