working popup function
[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     var width = parseInt($(popup).attr("popup_width") || "800");
27     var height = parseInt($(popup).attr("popup_height") || "600");
28     var autoOpen = parseInt($(popup).attr("popup_autoOpen") || "0");
29
30     $(popup).dialog({
31         closeOnEscape: true,
32         autoOpen: autoOpen,
33         height: height,
34         width: width,
35         modal: true,
36         resizable: true,
37         buttons: {
38             Cancel: function () {
39                 $(popup).dialog("close");
40             }
41         },
42         close: function () {}
43     });
44 });