blob: 4b007c666a139b1a00b7992ed2d74ec4bc2c299a [file] [log] [blame]
angular.module('ui.bootstrap.alert', [])
.controller('UibAlertController', ['$scope', '$attrs', '$interpolate', '$timeout', function($scope, $attrs, $interpolate, $timeout) {
$scope.closeable = !!$attrs.close;
var dismissOnTimeout = angular.isDefined($attrs.dismissOnTimeout) ?
$interpolate($attrs.dismissOnTimeout)($scope.$parent) : null;
if (dismissOnTimeout) {
$timeout(function() {
$scope.close();
}, parseInt(dismissOnTimeout, 10));
}
}])
.directive('uibAlert', function() {
return {
controller: 'UibAlertController',
controllerAs: 'alert',
templateUrl: function(element, attrs) {
return attrs.templateUrl || 'template/alert/alert.html';
},
transclude: true,
replace: true,
scope: {
type: '@',
close: '&'
}
};
});
/* Deprecated alert below */
angular.module('ui.bootstrap.alert')
.value('$alertSuppressWarning', false)
.controller('AlertController', ['$scope', '$attrs', '$controller', '$log', '$alertSuppressWarning', function($scope, $attrs, $controller, $log, $alertSuppressWarning) {
if (!$alertSuppressWarning) {
$log.warn('AlertController is now deprecated. Use UibAlertController instead.');
}
angular.extend(this, $controller('UibAlertController', {
$scope: $scope,
$attrs: $attrs
}));
}])
.directive('alert', ['$log', '$alertSuppressWarning', function($log, $alertSuppressWarning) {
return {
controller: 'AlertController',
controllerAs: 'alert',
templateUrl: function(element, attrs) {
return attrs.templateUrl || 'template/alert/alert.html';
},
transclude: true,
replace: true,
scope: {
type: '@',
close: '&'
},
link: function() {
if (!$alertSuppressWarning) {
$log.warn('alert is now deprecated. Use uib-alert instead.');
}
}
};
}]);