forked from angular-ui/bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathalert.js
65 lines (56 loc) · 1.73 KB
/
alert.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
angular.module('ui.bootstrap.alert', [])
.controller('UibAlertController', ['$scope', '$attrs', '$timeout', function($scope, $attrs, $timeout) {
$scope.closeable = !!$attrs.close;
if (angular.isDefined($attrs.dismissOnTimeout)) {
$timeout(function() {
$scope.close();
}, parseInt($attrs.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.');
}
}
};
}]);