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

feat(tooltip): remove deprecated code #4713

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 3 additions & 81 deletions src/popover/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ angular.module('ui.bootstrap.popover', ['ui.bootstrap.tooltip'])
replace: true,
scope: { title: '@', contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&',
originScope: '&' },
templateUrl: 'template/popover/popover-template.html',
link: function(scope, element) {
element.addClass('popover');
}
templateUrl: 'template/popover/popover-template.html'
};
})

Expand All @@ -27,10 +24,7 @@ angular.module('ui.bootstrap.popover', ['ui.bootstrap.tooltip'])
return {
replace: true,
scope: { contentExp: '&', title: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
templateUrl: 'template/popover/popover-html.html',
link: function(scope, element) {
element.addClass('popover');
}
templateUrl: 'template/popover/popover-html.html'
};
})

Expand All @@ -44,82 +38,10 @@ angular.module('ui.bootstrap.popover', ['ui.bootstrap.tooltip'])
return {
replace: true,
scope: { title: '@', content: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
templateUrl: 'template/popover/popover.html',
link: function(scope, element) {
element.addClass('popover');
}
templateUrl: 'template/popover/popover.html'
};
})

.directive('uibPopover', ['$uibTooltip', function($uibTooltip) {
return $uibTooltip('uibPopover', 'popover', 'click');
}]);

/* Deprecated popover below */

angular.module('ui.bootstrap.popover')

.value('$popoverSuppressWarning', false)

.directive('popoverTemplatePopup', ['$log', '$popoverSuppressWarning', function($log, $popoverSuppressWarning) {
return {
replace: true,
scope: { title: '@', contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&',
originScope: '&' },
templateUrl: 'template/popover/popover-template.html',
link: function(scope, element) {
if (!$popoverSuppressWarning) {
$log.warn('popover-template-popup is now deprecated. Use uib-popover-template-popup instead.');
}

element.addClass('popover');
}
};
}])

.directive('popoverTemplate', ['$tooltip', function($tooltip) {
return $tooltip('popoverTemplate', 'popover', 'click', {
useContentExp: true
});
}])

.directive('popoverHtmlPopup', ['$log', '$popoverSuppressWarning', function($log, $popoverSuppressWarning) {
return {
replace: true,
scope: { contentExp: '&', title: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
templateUrl: 'template/popover/popover-html.html',
link: function(scope, element) {
if (!$popoverSuppressWarning) {
$log.warn('popover-html-popup is now deprecated. Use uib-popover-html-popup instead.');
}

element.addClass('popover');
}
};
}])

.directive('popoverHtml', ['$tooltip', function($tooltip) {
return $tooltip('popoverHtml', 'popover', 'click', {
useContentExp: true
});
}])

.directive('popoverPopup', ['$log', '$popoverSuppressWarning', function($log, $popoverSuppressWarning) {
return {
replace: true,
scope: { title: '@', content: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
templateUrl: 'template/popover/popover.html',
link: function(scope, element) {
if (!$popoverSuppressWarning) {
$log.warn('popover-popup is now deprecated. Use uib-popover-popup instead.');
}

element.addClass('popover');
}
};
}])

.directive('popover', ['$tooltip', function($tooltip) {

return $tooltip('popover', 'popover', 'click');
}]);
61 changes: 0 additions & 61 deletions src/popover/test/popover-html.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,64 +187,3 @@ describe('popover', function() {
});
});
});

/* Deprecation tests below */

describe('popover deprecation', function() {
beforeEach(module('ui.bootstrap.popover'));
beforeEach(module('template/popover/popover-html.html'));

var elm, elmBody, elmScope, tooltipScope;

function trigger(element, evt) {
evt = new Event(evt);

element[0].dispatchEvent(evt);
element.scope().$$childTail.$digest();
}

it('should suppress warning', function() {
module(function($provide) {
$provide.value('$popoverSuppressWarning', true);
$provide.value('$tooltipSuppressWarning', true);
});

inject(function($compile, $log, $rootScope, $sce) {
spyOn($log, 'warn');

$rootScope.html = 'I say: <strong class="hello">Hello!</strong>';
$rootScope.safeHtml = $sce.trustAsHtml($rootScope.html);
elmBody = angular.element('<div><span popover-html="safeHtml">Selector Text</span></div>');
$compile(elmBody)($rootScope);
$rootScope.$digest();
elm = elmBody.find('span');
elmScope = elm.scope();
tooltipScope = elmScope.$$childTail;

trigger(elm, 'mouseenter');
tooltipScope.$digest();

expect($log.warn.calls.count()).toBe(0);
});
});

it('should give warning by default', inject(function($compile, $log, $rootScope, $sce) {
spyOn($log, 'warn');

$rootScope.html = 'I say: <strong class="hello">Hello!</strong>';
$rootScope.safeHtml = $sce.trustAsHtml($rootScope.html);
elmBody = angular.element('<div><span popover-html="safeHtml">Selector Text</span></div>');
$compile(elmBody)($rootScope);
$rootScope.$digest();
elm = elmBody.find('span');
elmScope = elm.scope();
tooltipScope = elmScope.$$childTail;

elm.trigger('click');
tooltipScope.$digest();

expect($log.warn.calls.count()).toBe(2);
expect($log.warn.calls.argsFor(0)).toEqual(['$tooltip is now deprecated. Use $uibTooltip instead.']);
expect($log.warn.calls.argsFor(1)).toEqual(['popover-html-popup is now deprecated. Use uib-popover-html-popup instead.']);
}));
});
53 changes: 0 additions & 53 deletions src/popover/test/popover-template.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,56 +125,3 @@ describe('popover template', function() {
});
});
});

/* Deprecation tests below */

describe('popover template deprecation', function() {
beforeEach(module('ui.bootstrap.popover'));
beforeEach(module('template/popover/popover.html'));
beforeEach(module('template/popover/popover-template.html'));

var elm, elmBody, elmScope, tooltipScope;

it('should suppress warning', function() {
module(function($provide) {
$provide.value('$popoverSuppressWarning', true);
$provide.value('$tooltipSuppressWarning', true);
});

inject(function($compile, $log, $rootScope, $templateCache) {
spyOn($log, 'warn');
$templateCache.put('myUrl', [200, '<span>{{ myTemplateText }}</span>', {}]);
$rootScope.templateUrl = 'myUrl';

elmBody = angular.element('<div><span popover-template="templateUrl">Selector Text</span></div>');
$compile(elmBody)($rootScope);
$rootScope.$digest();
elm = elmBody.find('span');
elmScope = elm.scope();
tooltipScope = elmScope.$$childTail;

elm.trigger('click');
tooltipScope.$digest();
expect($log.warn.calls.count()).toBe(0);
});
});

it('should give warning by default', inject(function($compile, $log, $rootScope, $templateCache) {
spyOn($log, 'warn');
$templateCache.put('myUrl', [200, '<span>{{ myTemplateText }}</span>', {}]);
$rootScope.templateUrl = 'myUrl';

elmBody = angular.element('<div><span popover-template="templateUrl">Selector Text</span></div>');
$compile(elmBody)($rootScope);
elm = elmBody.find('span');
elmScope = elm.scope();
tooltipScope = elmScope.$$childTail;

elm.trigger('click');
tooltipScope.$digest();

expect($log.warn.calls.count()).toBe(2);
expect($log.warn.calls.argsFor(0)).toEqual(['$tooltip is now deprecated. Use $uibTooltip instead.']);
expect($log.warn.calls.argsFor(1)).toEqual(['popover-template-popup is now deprecated. Use uib-popover-template-popup instead.']);
}));
});
50 changes: 0 additions & 50 deletions src/popover/test/popover.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,53 +174,3 @@ describe('popover', function() {
});
});
});

/* Deprecation tests below */

describe('popover deprecation', function() {
beforeEach(module('ui.bootstrap.popover'));
beforeEach(module('template/popover/popover.html'));

var elm, elmBody, elmScope, tooltipScope;

it('should suppress warning', function() {
module(function($provide) {
$provide.value('$popoverSuppressWarning', true);
$provide.value('$tooltipSuppressWarning', true);
});

inject(function($compile, $log, $rootScope) {
spyOn($log, 'warn');

elmBody = angular.element('<div><span popover="popover text">Selector Text</span></div>');
$compile(elmBody)($rootScope);
$rootScope.$digest();
elm = elmBody.find('span');
elmScope = elm.scope();
tooltipScope = elmScope.$$childTail;

elm.trigger('click');
tooltipScope.$digest();

expect($log.warn.calls.count()).toBe(0);
});
});

it('should give warning by default', inject(function($compile, $log, $rootScope) {
spyOn($log, 'warn');

elmBody = angular.element('<div><span popover="popover text">Selector Text</span></div>');
$compile(elmBody)($rootScope);
$rootScope.$digest();
elm = elmBody.find('span');
elmScope = elm.scope();
tooltipScope = elmScope.$$childTail;

elm.trigger('click');
tooltipScope.$digest();

expect($log.warn.calls.count()).toBe(2);
expect($log.warn.calls.argsFor(0)).toEqual(['$tooltip is now deprecated. Use $uibTooltip instead.']);
expect($log.warn.calls.argsFor(1)).toEqual(['popover-popup is now deprecated. Use uib-popover-popup instead.']);
}));
});
62 changes: 0 additions & 62 deletions src/tooltip/test/tooltip-template.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,65 +82,3 @@ describe('tooltip template', function() {
expect(elmBody.children().length).toBe(1);
}));
});

/* Deprecation tests below */

describe('tooltip template deprecation', function() {
beforeEach(module('ui.bootstrap.tooltip'));
beforeEach(module('template/tooltip/tooltip-template-popup.html'));

var elm, elmBody, elmScope, tooltipScope;

function trigger(element, evt) {
evt = new Event(evt);

element[0].dispatchEvent(evt);
element.scope().$$childTail.$digest();
}

it('should suppress warning', function() {
module(function($provide) {
$provide.value('$tooltipSuppressWarning', true);
});

inject(function($compile, $log, $rootScope, $templateCache) {
spyOn($log, 'warn');
$templateCache.put('myUrl', [200, '<span>{{ myTemplateText }}</span>', {}]);
$rootScope.templateUrl = 'myUrl';

elmBody = angular.element('<div><span tooltip-template="templateUrl">Selector Text</span></div>');
$compile(elmBody)($rootScope);
$rootScope.$digest();
elm = elmBody.find('span');
elmScope = elm.scope();
tooltipScope = elmScope.$$childTail;

trigger(elm, 'mouseenter');

expect($log.warn.calls.count()).toBe(0);
});
});

it('should give warning by default', inject(function($compile, $log, $rootScope, $templateCache) {
spyOn($log, 'warn');
$templateCache.put('myUrl', [200, '<span>{{ myTemplateText }}</span>', {}]);
$rootScope.templateUrl = 'myUrl';

var element = '<div><span tooltip-template="templateUrl">Selector Text</span></div>';
element = $compile(element)($rootScope);
$rootScope.$digest();

elmBody = angular.element('<div><span tooltip-template="templateUrl">Selector Text</span></div>');
$compile(elmBody)($rootScope);
$rootScope.$digest();
elm = elmBody.find('span');
elmScope = elm.scope();
tooltipScope = elmScope.$$childTail;

trigger(elm, 'mouseenter');

expect($log.warn.calls.count()).toBe(2);
expect($log.warn.calls.argsFor(0)).toEqual(['$tooltip is now deprecated. Use $uibTooltip instead.']);
expect($log.warn.calls.argsFor(1)).toEqual(['tooltip-template-popup is now deprecated. Use uib-tooltip-template-popup instead.']);
}));
});
Loading