support cancel operation while signing in
[releng.git] / utils / test / testapi / 3rd_party / static / testapi-ui / shared / alerts / alertModalFactory.js
1 /*
2  * Licensed under the Apache License, Version 2.0 (the "License");
3  * you may not use this file except in compliance with the License.
4  * You may obtain a copy of the License at
5  *
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  * Unless required by applicable law or agreed to in writing, software
9  * distributed under the License is distributed on an "AS IS" BASIS,
10  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  * See the License for the specific language governing permissions and
12  * limitations under the License.
13  */
14
15 (function () {
16     'use strict';
17
18     angular
19         .module('testapiApp')
20         .factory('raiseAlert', raiseAlert);
21
22     raiseAlert.$inject = ['$uibModal'];
23
24     /**
25      * This allows alert pop-ups to be raised. Just inject it as a dependency
26      * in the calling controller.
27      */
28     function raiseAlert($uibModal) {
29         return function(mode, title, text) {
30             $uibModal.open({
31                 templateUrl: 'testapi-ui/shared/alerts/alertModal.html',
32                 controller: 'RaiseAlertModalController as alert',
33                 backdrop: true,
34                 keyboard: true,
35                 backdropClick: true,
36                 size: 'md',
37                 resolve: {
38                     data: function () {
39                         return {
40                             mode: mode,
41                             title: title,
42                             text: text
43                         };
44                     }
45                 }
46             });
47         };
48     }
49
50     angular
51         .module('testapiApp')
52         .controller('RaiseAlertModalController', RaiseAlertModalController);
53
54     RaiseAlertModalController.$inject = ['$uibModalInstance', 'data'];
55
56     /**
57      * This is the controller for the alert pop-up.
58      */
59     function RaiseAlertModalController($uibModalInstance, data) {
60         var ctrl = this;
61
62         ctrl.close = close;
63         ctrl.data = data;
64
65         /**
66          * This method will close the alert modal. The modal will close
67          * when the user clicks the close button or clicks outside of the
68          * modal.
69          */
70         function close() {
71             $uibModalInstance.close();
72         }
73     }
74 })();