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

Commit

Permalink
feat(collapse): remove deprecated code
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Remove deprecated non-prefixed directives

Closes #4715
  • Loading branch information
Foxandxss authored and wesleycho committed Oct 23, 2015
1 parent 21e852b commit bc004df
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 116 deletions.
83 changes: 0 additions & 83 deletions src/collapse/collapse.js
Expand Up @@ -74,86 +74,3 @@ angular.module('ui.bootstrap.collapse', [])
}
};
}]);

/* Deprecated collapse below */

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

.value('$collapseSuppressWarning', false)

.directive('collapse', ['$animate', '$injector', '$log', '$collapseSuppressWarning', function($animate, $injector, $log, $collapseSuppressWarning) {
var $animateCss = $injector.has('$animateCss') ? $injector.get('$animateCss') : null;
return {
link: function(scope, element, attrs) {
if (!$collapseSuppressWarning) {
$log.warn('collapse is now deprecated. Use uib-collapse instead.');
}

function expand() {
element.removeClass('collapse')
.addClass('collapsing')
.attr('aria-expanded', true)
.attr('aria-hidden', false);

if ($animateCss) {
$animateCss(element, {
easing: 'ease',
to: { height: element[0].scrollHeight + 'px' }
}).start().done(expandDone);
} else {
$animate.animate(element, {}, {
height: element[0].scrollHeight + 'px'
}).then(expandDone);
}
}

function expandDone() {
element.removeClass('collapsing')
.addClass('collapse in')
.css({height: 'auto'});
}

function collapse() {
if (!element.hasClass('collapse') && !element.hasClass('in')) {
return collapseDone();
}

element
// IMPORTANT: The height must be set before adding "collapsing" class.
// Otherwise, the browser attempts to animate from height 0 (in
// collapsing class) to the given height here.
.css({height: element[0].scrollHeight + 'px'})
// initially all panel collapse have the collapse class, this removal
// prevents the animation from jumping to collapsed state
.removeClass('collapse in')
.addClass('collapsing')
.attr('aria-expanded', false)
.attr('aria-hidden', true);

if ($animateCss) {
$animateCss(element, {
to: {height: '0'}
}).start().done(collapseDone);
} else {
$animate.animate(element, {}, {
height: '0'
}).then(collapseDone);
}
}

function collapseDone() {
element.css({height: '0'}); // Required so that collapse works when animation is disabled
element.removeClass('collapsing')
.addClass('collapse');
}

scope.$watch(attrs.collapse, function(shouldCollapse) {
if (shouldCollapse) {
collapse();
} else {
expand();
}
});
}
};
}]);
33 changes: 0 additions & 33 deletions src/collapse/test/collapse.spec.js
Expand Up @@ -130,36 +130,3 @@ describe('collapse directive', function() {
});
});
});

/* Deprecation tests below */

describe('collapse deprecation', function() {
beforeEach(module('ui.bootstrap.collapse'));
beforeEach(module('ngAnimateMock'));

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

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

var element = $compile('<div collapse="isCollapsed">Some Content</div>')($rootScope);
$rootScope.$digest();

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

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

var element = $compile('<div collapse="isCollapsed">Some Content</div>')($rootScope);
$rootScope.$digest();

expect($log.warn.calls.count()).toBe(1);
expect($log.warn.calls.argsFor(0)).toEqual(['collapse is now deprecated. Use uib-collapse instead.']);

}));
});

0 comments on commit bc004df

Please sign in to comment.