Skip to content

Commit 18c6acf

Browse files
committed
Revert "feat(popover): support templates (WIP) angular-ui#1848"
This reverts commit b7beaae.
1 parent b7beaae commit 18c6acf

File tree

9 files changed

+22
-68
lines changed

9 files changed

+22
-68
lines changed

src/popover/docs/demo.html

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,14 @@
22
<h4>Dynamic</h4>
33
<div class="form-group">
44
<label>Popup Text:</label>
5-
<input type="text" ng-model="dynamicPopover.content" class="form-control">
5+
<input type="text" ng-model="dynamicPopover" class="form-control">
66
</div>
77
<div class="form-group">
88
<label>Popup Title:</label>
9-
<input type="text" ng-model="dynamicPopover.title" class="form-control">
9+
<input type="text" ng-model="dynamicPopoverTitle" class="form-control">
1010
</div>
11-
<button popover="{{dynamicPopover.content}}" popover-title="{{dynamicPopover.title}}" class="btn btn-default">Dynamic Popover</button>
11+
<button popover="{{dynamicPopover}}" popover-title="{{dynamicPopoverTitle}}" class="btn btn-default">Dynamic Popover</button>
1212

13-
<button popover-window="templatePopover.html" popover-title="{{dynamicPopover.title}}" class="btn btn-default">Popover With Template</button>
14-
15-
<script type="text/ng-template" id="templatePopover.html">
16-
<div class="form-group">
17-
<label>Popup Title:</label>
18-
<input type="text" ng-model="dynamicPopover.title" class="form-control">
19-
</div>
20-
</script>
21-
2213
<hr />
2314
<h4>Positional</h4>
2415
<button popover-placement="top" popover="On the Top!" class="btn btn-default">Top</button>

src/popover/docs/demo.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
angular.module('ui.bootstrap.demo').controller('PopoverDemoCtrl', function ($scope) {
2-
$scope.dynamicPopover = {
3-
content: 'Hello, World!',
4-
title: 'Title'
5-
};
2+
$scope.dynamicPopover = 'Hello, World!';
3+
$scope.dynamicPopoverTitle = 'Title';
64
});

src/popover/popover.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,11 @@
55
*/
66
angular.module( 'ui.bootstrap.popover', [ 'ui.bootstrap.tooltip' ] )
77

8-
.directive( 'popoverWindowPopup', function () {
9-
return {
10-
restrict: 'EA',
11-
replace: true,
12-
templateUrl: 'template/popover/popover-window.html'
13-
};
14-
})
15-
16-
.directive( 'popoverWindow', [ '$tooltip', function ( $tooltip ) {
17-
return $tooltip( 'popoverWindow', 'popoverWindow', 'click' );
18-
}])
19-
208
.directive( 'popoverPopup', function () {
219
return {
2210
restrict: 'EA',
2311
replace: true,
12+
scope: { title: '@', content: '@', placement: '@', animation: '&', isOpen: '&' },
2413
templateUrl: 'template/popover/popover.html'
2514
};
2615
})

src/tooltip/test/tooltip.spec.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ describe('tooltip', function() {
135135
}));
136136

137137
it('should only have an isolate scope on the popup', inject( function ( $compile ) {
138+
var ttScope;
138139

139140
scope.tooltipMsg = 'Tooltip Text';
140141
scope.alt = 'Alt Message';
@@ -147,21 +148,22 @@ describe('tooltip', function() {
147148
scope.$digest();
148149
elm = elmBody.find( 'span' );
149150
elmScope = elm.scope();
150-
tooltipScope = elmScope.$$childTail;
151151

152152
elm.trigger( 'mouseenter' );
153153
expect( elm.attr( 'alt' ) ).toBe( scope.alt );
154154

155-
expect( tooltipScope.placement ).toBe('top');
156-
expect( tooltipScope.content ).toBe(scope.tooltipMsg);
155+
ttScope = angular.element( elmBody.children()[1] ).isolateScope();
156+
expect( ttScope.placement ).toBe( 'top' );
157+
expect( ttScope.content ).toBe( scope.tooltipMsg );
157158

158159
elm.trigger( 'mouseleave' );
159160

160161
//Isolate scope contents should be the same after hiding and showing again (issue 1191)
161162
elm.trigger( 'mouseenter' );
162163

163-
expect( tooltipScope.placement ).toBe('top');
164-
expect( tooltipScope.content ).toBe(scope.tooltipMsg);
164+
ttScope = angular.element( elmBody.children()[1] ).isolateScope();
165+
expect( ttScope.placement ).toBe( 'top' );
166+
expect( ttScope.content ).toBe( scope.tooltipMsg );
165167
}));
166168

167169
it('should not show tooltips if there is nothing to show - issue #129', inject(function ($compile) {

src/tooltip/tooltip.js

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
3636
* $tooltipProvider.options( { placement: 'left' } );
3737
* });
3838
*/
39-
this.options = function( value ) {
40-
angular.extend( globalOptions, value );
41-
};
39+
this.options = function( value ) {
40+
angular.extend( globalOptions, value );
41+
};
4242

4343
/**
4444
* This allows you to extend the set of trigger mappings available. E.g.:
@@ -202,7 +202,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
202202

203203
// And show the tooltip.
204204
ttScope.isOpen = true;
205-
ttScope.$apply(); // digest required as $apply is not called
205+
ttScope.$digest(); // digest required as $apply is not called
206206

207207
// Return positioning function as promise callback for correct
208208
// positioning after draw.
@@ -289,7 +289,6 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
289289
}
290290

291291
var unregisterTriggers = function () {
292-
element.unbind(triggers.show, toggleTooltipBind);
293292
element.unbind(triggers.show, showTooltipBind);
294293
element.unbind(triggers.hide, hideTooltipBind);
295294
};
@@ -341,29 +340,11 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
341340
}];
342341
})
343342

344-
.directive( 'tooltipTemplateTransclude', ['$http', '$compile', '$templateCache', function ($http , $compile , $templateCache) {
345-
return {
346-
link: function ( scope, elem, attrs ) {
347-
if (scope.content) {
348-
// TODO: How to solve the problem of pre-loading the template?
349-
// TODO: Should this be watching for changes in scope.content?
350-
var templateUrl = scope.content,
351-
transcludeScope = scope.$parent.$parent;
352-
353-
$http.get( templateUrl, { cache: $templateCache })
354-
.then(function (response) {
355-
elem.html(response.data);
356-
$compile(elem.contents())(transcludeScope);
357-
});
358-
}
359-
}
360-
};
361-
}])
362-
363343
.directive( 'tooltipPopup', function () {
364344
return {
365345
restrict: 'EA',
366346
replace: true,
347+
scope: { content: '@', placement: '@', animation: '&', isOpen: '&' },
367348
templateUrl: 'template/tooltip/tooltip-popup.html'
368349
};
369350
})
@@ -376,11 +357,11 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
376357
return {
377358
restrict: 'EA',
378359
replace: true,
360+
scope: { content: '@', placement: '@', animation: '&', isOpen: '&' },
379361
templateUrl: 'template/tooltip/tooltip-html-unsafe-popup.html'
380362
};
381363
})
382364

383365
.directive( 'tooltipHtmlUnsafe', [ '$tooltip', function ( $tooltip ) {
384366
return $tooltip( 'tooltipHtmlUnsafe', 'tooltip', 'mouseenter' );
385367
}]);
386-

template/popover/popover-window.html

Lines changed: 0 additions & 7 deletions
This file was deleted.

template/popover/popover.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="popover {{placement}}" ng-class="{ in: isOpen, fade: animation }">
1+
<div class="popover {{placement}}" ng-class="{ in: isOpen(), fade: animation() }">
22
<div class="arrow"></div>
33

44
<div class="popover-inner">
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="tooltip {{placement}}" ng-class="{ in: isOpen, fade: animation }">
1+
<div class="tooltip {{placement}}" ng-class="{ in: isOpen(), fade: animation() }">
22
<div class="tooltip-arrow"></div>
33
<div class="tooltip-inner" bind-html-unsafe="content"></div>
44
</div>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="tooltip {{placement}}" ng-class="{ in: isOpen, fade: animation }">
1+
<div class="tooltip {{placement}}" ng-class="{ in: isOpen(), fade: animation() }">
22
<div class="tooltip-arrow"></div>
33
<div class="tooltip-inner" ng-bind="content"></div>
44
</div>

0 commit comments

Comments
 (0)