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

Commit

Permalink
chore(carousel): refactor to remove try-catch
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleycho committed Aug 6, 2015
1 parent c7f19d5 commit e633ca8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
18 changes: 8 additions & 10 deletions src/carousel/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
*
*/
angular.module('ui.bootstrap.carousel', [])
.constant('ANIMATE_CSS', angular.version.minor >= 4)
.controller('CarouselController', ['$scope', '$element', '$interval', '$animate', 'ANIMATE_CSS', function ($scope, $element, $interval, $animate, ANIMATE_CSS) {
.controller('CarouselController', ['$scope', '$element', '$interval', '$animate', function ($scope, $element, $interval, $animate) {
var self = this,
slides = self.slides = $scope.slides = [],
NEW_ANIMATE = angular.version.minor >= 4,
NO_TRANSITION = 'uib-noTransition',
SLIDE_DIRECTION = 'uib-slideDirection',
currentIndex = -1,
Expand Down Expand Up @@ -45,7 +45,7 @@ angular.module('ui.bootstrap.carousel', [])
}

$scope.$currentTransition = true;
if (ANIMATE_CSS) {
if (NEW_ANIMATE) {
$animate.on('addClass', slide.$element, function (element, phase) {
if (phase === 'close') {
$scope.$currentTransition = null;
Expand Down Expand Up @@ -330,17 +330,15 @@ function CarouselDemoCtrl($scope) {
})

.animation('.item', [
'$injector', '$animate', 'ANIMATE_CSS',
function ($injector, $animate, ANIMATE_CSS) {
'$injector', '$animate',
function ($injector, $animate) {
var NO_TRANSITION = 'uib-noTransition',
SLIDE_DIRECTION = 'uib-slideDirection',
$animateCss = null;

if (ANIMATE_CSS) {
try {
$animateCss = $injector.get('$animateCss');
} catch(e) {}
}
if ($injector.has('$animateCss')) {
$animateCss = $injector.get('$animateCss');
}

function removeClass(element, className, callback) {
element.removeClass(className);
Expand Down
18 changes: 6 additions & 12 deletions src/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ angular.module('ui.bootstrap.modal', [])
function ($animate , $injector, $modalStack) {
var $animateCss = null;

if (angular.version.minor >= 4) {
try {
$animateCss = $injector.get('$animateCss');
} catch(e) {}
if ($injector.has('$animateCss')) {
$animateCss = $injector.get('$animateCss');
}

return {
Expand Down Expand Up @@ -107,10 +105,8 @@ angular.module('ui.bootstrap.modal', [])
function ($modalStack , $q , $animate, $injector) {
var $animateCss = null;

if (angular.version.minor >= 4) {
try {
$animateCss = $injector.get('$animateCss');
} catch(e) {}
if ($injector.has('$animateCss')) {
$animateCss = $injector.get('$animateCss');
}

return {
Expand Down Expand Up @@ -231,10 +227,8 @@ angular.module('ui.bootstrap.modal', [])
$$stackedMap) {
var $animateCss = null;

if (angular.version.minor >= 4) {
try {
$animateCss = $injector.get('$animateCss');
} catch(e) {}
if ($injector.has('$animateCss')) {
$animateCss = $injector.get('$animateCss');
}

var OPENED_MODAL_CLASS = 'modal-open';
Expand Down

0 comments on commit e633ca8

Please sign in to comment.