working popup function
authorWolfram Schneider <wosch@indexdata.dk>
Thu, 10 Jul 2014 09:06:08 +0000 (09:06 +0000)
committerWolfram Schneider <wosch@indexdata.dk>
Thu, 10 Jul 2014 09:06:08 +0000 (09:06 +0000)
examples/htdocs/popup.html
src/mkws-popup.js

index 2e466b2..18a2d8c 100644 (file)
@@ -3,7 +3,9 @@
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     <title>MKWS demo: Reference Universe widget with popup window</title>
     <link rel="stylesheet" type="text/css" href="tools/htdocs/mkws.css" />
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     <title>MKWS demo: Reference Universe widget with popup window</title>
     <link rel="stylesheet" type="text/css" href="tools/htdocs/mkws.css" />
+    <link rel="stylesheet" type="text/css" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
     <link rel="stylesheet" type="text/css" href="mkws-widget-reference.css" />
     <link rel="stylesheet" type="text/css" href="mkws-widget-reference.css" />
+    <link rel="stylesheet" type="text/css" href="mkws-widget-ru.css" />
 
     <script type="text/javascript">
       var mkws_config = {
 
     <script type="text/javascript">
       var mkws_config = {
     <script type="text/javascript" src="src/mkws-widget-reference.js"></script>
     <script type="text/javascript" src="src/mkws-widget-builder.js"></script>
 
     <script type="text/javascript" src="src/mkws-widget-reference.js"></script>
     <script type="text/javascript" src="src/mkws-widget-builder.js"></script>
 
+    <script type="text/javascript" src="mkws-widget-ru.js"></script>
   </head>
   <body>
   </head>
   <body>
-    <div class='mkwsReference' autosearch='!param!q' sentences='1'>result will appear here</div>
+    <div class='mkwsReferenceUniverse PopupWindow' popup_width="400" popup_height="400" popup_autoOpen="1" autosearch='berlin' sentences='1'>Reference Universe result will appear here</div>
+    <div class='mkwsReference PopupWindow' popup_width="800" popup_height="400" popup_autoOpen="1" autosearch='sushi' sentences='1'>Reference result will appear here</div
   </body>
 </html>
   </body>
 </html>
index 4d03c52..153425b 100644 (file)
@@ -4,32 +4,41 @@
 
 // "use strict";
 
 
 // "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 () {}
+    });
 });
 });
-