support multiple popup widgets, part of MKWS-235
[mkws-moved-to-github.git] / src / mkws-popup.js
1 /* generic function to open results in a popup window
2  *
3  */
4
5 // "use strict";
6 $(document).ready(function () {
7     // mkws.registerWidgetType('PopupWindow', function() {
8     var $ = mkws.$;
9     var debug = mkws.log;
10     debug("init popup window");
11
12     if (!$.ui) {
13         alert("Error: jquery-ui.js is missing, did you include it after jQuery core in the HTML file?");
14         return;
15     }
16
17     var popup_window = $(".PopupWindow");
18     if (!popup_window) {
19         debug("no popup found, skip");
20         return;
21     } else {
22         debug("found popup windows: " + popup_window.length);
23     }
24
25     popup_window.each(function (i) {
26         var that = $(this);
27
28         var width = parseInt(that.attr("popup_width") || "800");
29         var height = parseInt(that.attr("popup_height") || "600");
30         var autoOpen = parseInt(that.attr("popup_autoOpen") || "0");
31         var modal = parseInt(that.attr("popup_modal") || "0");
32
33         debug("Popup parameters: width: " + width + ", height: " + height + ", autoOpen: " + autoOpen);
34         that.dialog({
35             closeOnEscape: true,
36             autoOpen: autoOpen,
37             height: height,
38             width: width,
39             modal: modal ? true : false,
40             resizable: true,
41             buttons: {
42                 Cancel: function () {
43                     that.dialog("close");
44                 }
45             },
46             close: function () {}
47         });
48     });
49 });