support multiple popup windows
[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
7 $(document).ready(function () {
8     // mkws.registerWidgetType('PopupWindow', function() {
9     var $ = mkws.$;
10     var debug = mkws.log;
11     debug("init popup window");
12
13     if (!$.ui) {
14         alert("Error: jquery-ui.js is missing, did you include it after jQuery core in the HTML file?");
15         return;
16     }
17
18     var popup = $(".PopupWindow");
19     if (!popup) {
20         debug("no popup found");
21         return;
22     } else {
23         debug("found popup windows: " + popup.length);
24     }
25
26     $(popup).each(function (i) {
27         var width = parseInt(this.attr("popup_width") || "800");
28         var height = parseInt(this.attr("popup_height") || "600");
29         var autoOpen = parseInt(this.attr("popup_autoOpen") || "0");
30
31         debug("Popup parameters: width: " + width + ", height: " + height + ", autoOpen: " + autoOpen);
32         $(this).dialog({
33             closeOnEscape: true,
34             autoOpen: autoOpen,
35             height: height,
36             width: width,
37             modal: true,
38             resizable: true,
39             buttons: {
40                 Cancel: function () {
41                     $(this).dialog("close");
42                 }
43             },
44             close: function () {}
45         });
46     });
47 });