From d05e75ede48a52fae21f388471acc37ad5e92293 Mon Sep 17 00:00:00 2001 From: Wolfram Schneider Date: Thu, 10 Jul 2014 09:06:08 +0000 Subject: [PATCH] working popup function --- examples/htdocs/popup.html | 6 ++++- src/mkws-popup.js | 57 +++++++++++++++++++++++++------------------- 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/examples/htdocs/popup.html b/examples/htdocs/popup.html index 2e466b2..18a2d8c 100644 --- a/examples/htdocs/popup.html +++ b/examples/htdocs/popup.html @@ -3,7 +3,9 @@ MKWS demo: Reference Universe widget with popup window + + + -
result will appear here
+ + diff --git a/src/mkws-popup.js b/src/mkws-popup.js index 4d03c52..153425b 100644 --- a/src/mkws-popup.js +++ b/src/mkws-popup.js @@ -4,32 +4,41 @@ // "use strict"; -mkws.registerWidgetType('Popup', function() { - alert("running popup"); +$(document).ready(function () { + // mkws.registerWidgetType('PopupWindow', function() { + var $ = mkws.$; + var debug = mkws.log; + debug("init popup window"); - if (!mkws.$.ui) { - alert("Error: jquery-ui.js is missing, did you include it after jQuery core in the HTML file?"); - return; - } + if (!$.ui) { + alert("Error: jquery-ui.js is missing, did you include it after jQuery core in the HTML file?"); + return; + } - if (!this.config.popup_width) this.config.popup_width = "800"; - if (!this.config.popup_height) this.config.popup_height = "600"; - if (!this.config.auto_open) this.config.auto_open = "0"; + var popup = $(".PopupWindow"); + if (!popup) { + debug("no popup found"); + return; + } else { + debug("found popup windows: " + popup.length); + } - $(this).dialog({ - closeOnEscape: true, - autoOpen: parseInt(this.config.auto_open) ? true : false, - height: parseInt(this.config.popup_height), - width: parseInt(this.config.popup_width), - modal: true, - resizable: true, - buttons: { - Cancel: function() { - $(this).dialog("close"); - } - }, - close: function() { } - }); + var width = parseInt($(popup).attr("popup_width") || "800"); + var height = parseInt($(popup).attr("popup_height") || "600"); + var autoOpen = parseInt($(popup).attr("popup_autoOpen") || "0"); + $(popup).dialog({ + closeOnEscape: true, + autoOpen: autoOpen, + height: height, + width: width, + modal: true, + resizable: true, + buttons: { + Cancel: function () { + $(popup).dialog("close"); + } + }, + close: function () {} + }); }); - -- 1.7.10.4