nexus site path corrected
[portal.git] / ecomp-portal-BE / war / static / js / modalService.js
1 angular.module("modalServices",[]).service('modalService', ['$modal', function ($modal) {
2         
3                                                                                                                 
4                 this.showSuccess = function(heading, messageBody){
5                         var modalInstance = $modal.open({
6                         templateUrl: 'modal_informative.html',
7                         controller: 'modalpopupController',
8                         resolve: {
9                            message: function () {
10                                         $(".overlayed").css("display","none");
11                                         $(".loadingId").css("display","none");
12                                    var message = {
13                                                    title:    heading,
14                                         text:     messageBody
15                                 };
16                                   return message;
17                                         }
18                         }
19                       }); 
20                 };
21                 this.showFailure = function(heading, messageBody){
22                 var modalInstance = $modal.open({
23                         templateUrl: 'modal_warning.html',
24                         controller: 'modalpopupController',
25                         resolve: {
26                            message: function () {
27                                   var message = {
28                                  title:    heading,
29                                  text:     messageBody
30                                 };
31                                   return message;
32                                         }
33                         }
34                       }); 
35                 };
36                 
37                 this.showWarning = function(heading, messageBody){
38                 var modalInstance = $modal.open({
39                         templateUrl: 'modal_warning_message.html',
40                         controller: 'modalpopupController',
41                         resolve: {
42                            message: function () {
43                                   var message = {
44                                          title:    heading,
45                                          text:     messageBody
46                                         };
47                                           return message;
48                                                 }
49                         }
50                       }); 
51                 };
52                 
53                 this.popupConfirmWin = function(title, msgBody, callback){
54                          var modalInstance = $modal.open({
55                         templateUrl: 'confirmation_informative.html',
56                         controller: 'modalpopupController',
57                         resolve: {
58                            message: function () {
59                                    var message = {
60                                                    title:    title,
61                                         text:    msgBody
62                                 };
63                                           return message;
64                                         }
65                         }
66                       }); 
67                          var args = Array.prototype.slice.call( arguments, 0 );
68                      args.splice( 0, 3); 
69                         modalInstance.result.then(function(){
70                                         callback.apply(null, args);
71                                 }, function() {
72                           })['finally'](function(){
73                            modalInstance = undefined;
74                           });
75                         
76                 };
77         this.popupDeleteConfirmWin = function(title, msgBody, callback, argForCallBack){
78                          var modalInstance = $modal.open({
79                         templateUrl: 'confirmation_for_delete.html',
80                         controller: 'modalpopupController',
81                         resolve: {
82                            message: function () {
83                                    var message = {
84                                                    title:    title,
85                                         text:    msgBody
86                                 };
87                                           return message;
88                                         }
89                         }
90                       }); 
91                          
92                         modalInstance.result.then(function(){
93                                         callback(argForCallBack);
94                                 }, function() {
95                           })['finally'](function(){
96                            modalInstance = undefined;
97                           });
98                         
99                 };              
100                 
101          this.popupSuccessRedirectWin = function(title, msgBody, redirectUrl){
102                 var modalInstance = $modal.open({
103                 templateUrl: 'modal_informative.html',
104                 controller: 'modalpopupController',
105                 resolve: {
106                    message: function () {
107                            var message = {
108                                            title:    title,
109                                text:    msgBody
110                         };
111                                   return message;
112                                 }
113                 }
114               }); 
115                 modalInstance.result.then(function() {
116                   }, function() {
117                           window.location.href=redirectUrl;
118                   })['finally'](function(){
119                    modalInstance = undefined;
120                   });   
121         };      
122         
123         this.popupWarningRedirectWin = function(title, msgBody, redirectUrl){
124                 var modalInstance = $modal.open({
125                         templateUrl: 'modal_warning_message.html',
126                 controller: 'modalpopupController',
127                 resolve: {
128                    message: function () {
129                            var message = {
130                                            title:    title,
131                                text:    msgBody
132                         };
133                                   return message;
134                                 }
135                 }
136               }); 
137                 modalInstance.result.then(function() {
138                   }, function() {
139                           window.location.href=redirectUrl;
140                   })['finally'](function(){
141                    modalInstance = undefined;
142                   });   
143         };      
144  }]);