Fixed the Policy GUI Editor tab right click issue.
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / CSS / bootstrap / dist / js / bootstrap-modalmanager.min.js
1 /* ===========================================================
2  * bootstrap-modalmanager.min.js v2.2.5
3  * ===========================================================
4  * Copyright 2012 Jordan Schroter
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  * ========================================================== */
18
19 !function(c) {
20     var a = function(f, e) {
21         this.init(f, e)
22     };
23     a.prototype = {
24         constructor : a,
25         init : function(f, e) {
26             this.$element = c(f);
27             this.options = c.extend({}, c.fn.modalmanager.defaults,
28                     this.$element.data(), typeof e == "object" && e);
29             this.stack = [];
30             this.backdropCount = 0;
31             if (this.options.resize) {
32                 var h, g = this;
33                 c(window).on("resize.modal", function() {
34                     h && clearTimeout(h);
35                     h = setTimeout(function() {
36                         for (var j = 0; j < g.stack.length; j++) {
37                             g.stack[j].isShown && g.stack[j].layout()
38                         }
39                     }, 10)
40                 })
41             }
42         },
43         createModal : function(f, e) {
44             c(f).modal(c.extend({
45                 manager : this
46             }, e))
47         },
48         appendModal : function(f) {
49             this.stack.push(f);
50             var e = this;
51             f.$element.on("show.modalmanager",
52                     b(function(h) {
53                         var g = function() {
54                             f.isShown = true;
55                             var i = c.support.transition
56                                     && f.$element.hasClass("fade");
57                             e.$element.toggleClass("modal-open",
58                                     e.hasOpenModal()).toggleClass(
59                                     "page-overflow",
60                                     c(window).height() < e.$element.height());
61                             f.$parent = f.$element.parent();
62                             f.$container = e.createContainer(f);
63                             f.$element.appendTo(f.$container);
64                             e.backdrop(f, function() {
65                                 f.$element.show();
66                                 if (i) {
67                                     f.$element[0].offsetWidth
68                                 }
69                                 f.layout();
70                                 f.$element.addClass("in").attr("aria-hidden",
71                                         false);
72                                 var j = function() {
73                                     e.setFocus();
74                                     f.$element.trigger("shown")
75                                 };
76                                 i ? f.$element.one(c.support.transition.end, j)
77                                         : j()
78                             })
79                         };
80                         f.options.replace ? e.replace(g) : g()
81                     }));
82             f.$element
83                     .on(
84                             "hidden.modalmanager",
85                             b(function(g) {
86                                 e.backdrop(f);
87                                 if (!f.$element.parent().length) {
88                                     e.destroyModal(f)
89                                 } else {
90                                     if (f.$backdrop) {
91                                         var h = c.support.transition
92                                                 && f.$element.hasClass("fade");
93                                         if (h) {
94                                             f.$element[0].offsetWidth
95                                         }
96                                         c.support.transition
97                                                 && f.$element.hasClass("fade") ? f.$backdrop
98                                                 .one(c.support.transition.end,
99                                                         function() {
100                                                             f.destroy()
101                                                         })
102                                                 : f.destroy()
103                                     } else {
104                                         f.destroy()
105                                     }
106                                 }
107                             }));
108             f.$element.on("destroyed.modalmanager", b(function(g) {
109                 e.destroyModal(f)
110             }))
111         },
112         getOpenModals : function() {
113             var f = [];
114             for (var e = 0; e < this.stack.length; e++) {
115                 if (this.stack[e].isShown) {
116                     f.push(this.stack[e])
117                 }
118             }
119             return f
120         },
121         hasOpenModal : function() {
122             return this.getOpenModals().length > 0
123         },
124         setFocus : function() {
125             var f;
126             for (var e = 0; e < this.stack.length; e++) {
127                 if (this.stack[e].isShown) {
128                     f = this.stack[e]
129                 }
130             }
131             if (!f) {
132                 return
133             }
134             f.focus()
135         },
136         destroyModal : function(f) {
137             f.$element.off(".modalmanager");
138             if (f.$backdrop) {
139                 this.removeBackdrop(f)
140             }
141             this.stack.splice(this.getIndexOfModal(f), 1);
142             var e = this.hasOpenModal();
143             this.$element.toggleClass("modal-open", e);
144             if (!e) {
145                 this.$element.removeClass("page-overflow")
146             }
147             this.removeContainer(f);
148             this.setFocus()
149         },
150         getModalAt : function(e) {
151             return this.stack[e]
152         },
153         getIndexOfModal : function(f) {
154             for (var e = 0; e < this.stack.length; e++) {
155                 if (f === this.stack[e]) {
156                     return e
157                 }
158             }
159         },
160         replace : function(g) {
161             var f;
162             for (var e = 0; e < this.stack.length; e++) {
163                 if (this.stack[e].isShown) {
164                     f = this.stack[e]
165                 }
166             }
167             if (f) {
168                 this.$backdropHandle = f.$backdrop;
169                 f.$backdrop = null;
170                 g && f.$element.one("hidden", b(c.proxy(g, this)));
171                 f.hide()
172             } else {
173                 if (g) {
174                     g()
175                 }
176             }
177         },
178         removeBackdrop : function(e) {
179             e.$backdrop.remove();
180             e.$backdrop = null
181         },
182         createBackdrop : function(g, f) {
183             var e;
184             if (!this.$backdropHandle) {
185                 e = c(f).addClass(g).appendTo(this.$element)
186             } else {
187                 e = this.$backdropHandle;
188                 e.off(".modalmanager");
189                 this.$backdropHandle = null;
190                 this.isLoading && this.removeSpinner()
191             }
192             return e
193         },
194         removeContainer : function(e) {
195             e.$container.remove();
196             e.$container = null
197         },
198         createContainer : function(e) {
199             var f;
200             f = c('<div class="modal-scrollable">').css("z-index",
201                     d("modal", this.getOpenModals().length)).appendTo(
202                     this.$element);
203             if (e && e.options.backdrop != "static") {
204                 f.on("click.modal", b(function(g) {
205                     e.hide()
206                 }))
207             } else {
208                 if (e) {
209                     f.on("click.modal", b(function(g) {
210                         e.attention()
211                     }))
212                 }
213             }
214             return f
215         },
216         backdrop : function(h, j) {
217             var f = h.$element.hasClass("fade") ? "fade" : "", i = h.options.backdrop
218                     && this.backdropCount < this.options.backdropLimit;
219             if (h.isShown && i) {
220                 var e = c.support.transition && f && !this.$backdropHandle;
221                 h.$backdrop = this
222                         .createBackdrop(f, h.options.backdropTemplate);
223                 h.$backdrop.css("z-index", d("backdrop",
224                         this.getOpenModals().length));
225                 if (e) {
226                     h.$backdrop[0].offsetWidth
227                 }
228                 h.$backdrop.addClass("in");
229                 this.backdropCount += 1;
230                 e ? h.$backdrop.one(c.support.transition.end, j) : j()
231             } else {
232                 if (!h.isShown && h.$backdrop) {
233                     h.$backdrop.removeClass("in");
234                     this.backdropCount -= 1;
235                     var g = this;
236                     c.support.transition && h.$element.hasClass("fade") ? h.$backdrop
237                             .one(c.support.transition.end, function() {
238                                 g.removeBackdrop(h)
239                             })
240                             : g.removeBackdrop(h)
241                 } else {
242                     if (j) {
243                         j()
244                     }
245                 }
246             }
247         },
248         removeSpinner : function() {
249             this.$spinner && this.$spinner.remove();
250             this.$spinner = null;
251             this.isLoading = false
252         },
253         removeLoading : function() {
254             this.$backdropHandle && this.$backdropHandle.remove();
255             this.$backdropHandle = null;
256             this.removeSpinner()
257         },
258         loading : function(h) {
259             h = h || function() {
260             };
261             this.$element.toggleClass("modal-open",
262                     !this.isLoading || this.hasOpenModal()).toggleClass(
263                     "page-overflow",
264                     c(window).height() < this.$element.height());
265             if (!this.isLoading) {
266                 this.$backdropHandle = this.createBackdrop("fade",
267                         this.options.backdropTemplate);
268                 this.$backdropHandle[0].offsetWidth;
269                 var e = this.getOpenModals();
270                 this.$backdropHandle
271                         .css("z-index", d("backdrop", e.length + 1)).addClass(
272                                 "in");
273                 var g = c(this.options.spinner).css("z-index",
274                         d("modal", e.length + 1)).appendTo(this.$element)
275                         .addClass("in");
276                 this.$spinner = c(this.createContainer()).append(g).on(
277                         "click.modalmanager", c.proxy(this.loading, this));
278                 this.isLoading = true;
279                 c.support.transition ? this.$backdropHandle.one(
280                         c.support.transition.end, h) : h()
281             } else {
282                 if (this.isLoading && this.$backdropHandle) {
283                     this.$backdropHandle.removeClass("in");
284                     var f = this;
285                     c.support.transition ? this.$backdropHandle.one(
286                             c.support.transition.end, function() {
287                                 f.removeLoading()
288                             }) : f.removeLoading()
289                 } else {
290                     if (h) {
291                         h(this.isLoading)
292                     }
293                 }
294             }
295         }
296     };
297     var d = (function() {
298         var f, e = {};
299         return function(g, j) {
300             if (typeof f === "undefined") {
301                 var i = c('<div class="modal hide" />').appendTo("body"), h = c(
302                         '<div class="modal-backdrop hide" />').appendTo("body");
303                 e.modal = +i.css("z-index");
304                 e.backdrop = +h.css("z-index");
305                 f = e.modal - e.backdrop;
306                 i.remove();
307                 h.remove();
308                 h = i = null
309             }
310             return e[g] + (f * j)
311         }
312     }());
313     function b(e) {
314         return function(f) {
315             if (f && this === f.target) {
316                 return e.apply(this, arguments)
317             }
318         }
319     }
320     c.fn.modalmanager = function(f, e) {
321         return this.each(function() {
322             var h = c(this), g = h.data("modalmanager");
323             if (!g) {
324                 h.data("modalmanager", (g = new a(this, f)))
325             }
326             if (typeof f === "string") {
327                 g[f].apply(g, [].concat(e))
328             }
329         })
330     };
331     c.fn.modalmanager.defaults = {
332         backdropLimit : 999,
333         resize : true,
334         spinner : '<div class="loading-spinner fade" style="width: 200px; margin-left: -100px;"><div class="progress progress-striped active"><div class="bar" style="width: 100%;"></div></div></div>',
335         backdropTemplate : '<div class="modal-backdrop" />'
336     };
337     c.fn.modalmanager.Constructor = a;
338     c(function() {
339         c(document).off("show.bs.modal").off("hidden.bs.modal")
340     })
341 }(jQuery);