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

Commit 88a41dc

Browse files
chrisirhcrvanbaalen
authored and
rvanbaalen
committedApr 30, 2015
feat(popover): respect popover-class option
This functionality now works the same between tooltips and popovers. Closes #3569
1 parent 6af627a commit 88a41dc

File tree

3 files changed

+99
-2
lines changed

3 files changed

+99
-2
lines changed
 

Diff for: ‎src/popover/popover.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ angular.module( 'ui.bootstrap.popover', [ 'ui.bootstrap.tooltip' ] )
99
return {
1010
restrict: 'EA',
1111
replace: true,
12-
scope: { title: '@', contentExp: '&', placement: '@', animation: '&', isOpen: '&',
12+
scope: { title: '@', contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&',
1313
originScope: '&' },
1414
templateUrl: 'template/popover/popover-template.html'
1515
};
@@ -25,7 +25,7 @@ angular.module( 'ui.bootstrap.popover', [ 'ui.bootstrap.tooltip' ] )
2525
return {
2626
restrict: 'EA',
2727
replace: true,
28-
scope: { title: '@', content: '@', placement: '@', animation: '&', isOpen: '&' },
28+
scope: { title: '@', content: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
2929
templateUrl: 'template/popover/popover.html'
3030
};
3131
})

Diff for: ‎src/popover/test/popover-template.spec.js

+49
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,54 @@ describe('popover template', function() {
7676
expect( elmBody.children().length ).toBe( 1 );
7777
}));
7878

79+
describe('supports options', function () {
80+
81+
describe('placement', function () {
82+
83+
it('can specify an alternative, valid placement', inject(function ($compile) {
84+
elmBody = angular.element(
85+
'<div><span popover-template="templateUrl" popover-placement="left">Trigger</span></div>'
86+
);
87+
$compile(elmBody)(scope);
88+
scope.$digest();
89+
elm = elmBody.find('span');
90+
elmScope = elm.scope();
91+
tooltipScope = elmScope.$$childTail;
92+
93+
elm.trigger( 'click' );
94+
expect( tooltipScope.isOpen ).toBe( true );
95+
96+
expect( elmBody.children().length ).toBe( 2 );
97+
var ttipElement = elmBody.find('div.popover');
98+
expect(ttipElement).toHaveClass('left');
99+
}));
100+
101+
});
102+
103+
describe('class', function () {
104+
105+
it('can specify a custom class', inject(function ($compile) {
106+
elmBody = angular.element(
107+
'<div><span popover-template="templateUrl" popover-class="custom">Trigger</span></div>'
108+
);
109+
$compile(elmBody)(scope);
110+
scope.$digest();
111+
elm = elmBody.find('span');
112+
elmScope = elm.scope();
113+
tooltipScope = elmScope.$$childTail;
114+
115+
elm.trigger( 'click' );
116+
expect( tooltipScope.isOpen ).toBe( true );
117+
118+
expect( elmBody.children().length ).toBe( 2 );
119+
var ttipElement = elmBody.find('div.popover');
120+
expect(ttipElement).toHaveClass('custom');
121+
}));
122+
123+
});
124+
125+
});
126+
127+
79128
});
80129

Diff for: ‎src/popover/test/popover.spec.js

+48
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,54 @@ describe('popover', function() {
9292
expect(elmBody.children().eq(1)).not.toHaveClass('fade');
9393
}));
9494

95+
describe('supports options', function () {
96+
97+
describe('placement', function () {
98+
99+
it('can specify an alternative, valid placement', inject(function ($compile) {
100+
elmBody = angular.element(
101+
'<div><span popover="popover text" popover-placement="left">Trigger here</span></div>'
102+
);
103+
$compile(elmBody)(scope);
104+
scope.$digest();
105+
elm = elmBody.find('span');
106+
elmScope = elm.scope();
107+
tooltipScope = elmScope.$$childTail;
108+
109+
elm.trigger( 'click' );
110+
expect( tooltipScope.isOpen ).toBe( true );
111+
112+
expect( elmBody.children().length ).toBe( 2 );
113+
var ttipElement = elmBody.find('div.popover');
114+
expect(ttipElement).toHaveClass('left');
115+
}));
116+
117+
});
118+
119+
describe('class', function () {
120+
121+
it('can specify a custom class', inject(function ($compile) {
122+
elmBody = angular.element(
123+
'<div><span popover="popover text" popover-class="custom">Trigger here</span></div>'
124+
);
125+
$compile(elmBody)(scope);
126+
scope.$digest();
127+
elm = elmBody.find('span');
128+
elmScope = elm.scope();
129+
tooltipScope = elmScope.$$childTail;
130+
131+
elm.trigger( 'click' );
132+
expect( tooltipScope.isOpen ).toBe( true );
133+
134+
expect( elmBody.children().length ).toBe( 2 );
135+
var ttipElement = elmBody.find('div.popover');
136+
expect(ttipElement).toHaveClass('custom');
137+
}));
138+
139+
});
140+
141+
});
142+
95143
});
96144

97145

0 commit comments

Comments
 (0)