use a flat config for the popup window
[mkws-moved-to-github.git] / tools / htdocs / mkws.js
index ab65016..4004ce2 100644 (file)
@@ -846,10 +846,7 @@ jQuery.extend({
        <div id="mkwsSearch"></div>\
        <div id="mkwsResults"></div>\
        <div id="mkwsTargets"></div>\
-       <div id="mkwsFooter">\
-         <div id="mkwsStat"></div>\
-         <span>Powered by MKWS &copy; 2013 <a target="_new" href="http://www.indexdata.com">Index Data</a></span>\
-       </div>';
+        <div id="mkwsStat"></div>';
 
        // new table layout
        var table = '\
@@ -904,11 +901,8 @@ jQuery.extend({
            <div id="mkwsLang"></div>\
            <div id="mkwsResults"></div>\
            <div id="mkwsTargets"></div>\
-           <div id="mkwsFooter">\
-             <div id="mkwsStat"></div>\
-           </div>\
-         </div>\
-         <script> $(document).ready(function() { init_popup();});  </script>';
+           <div id="mkwsStat"></div>\
+         </div>'
 
        if (config && config.layout == 'div') {
            this.debug2("jquery plugin layout: div");
@@ -916,6 +910,7 @@ jQuery.extend({
        } else if (config && config.layout == 'popup') {
            this.debug2("jquery plugin layout: popup");
            document.write(popup);
+           $(document).ready( function() { init_popup(config); } );
        } else {
            this.debug2("jquery plugin layout: table");
            document.write(table);
@@ -923,12 +918,21 @@ jQuery.extend({
     }
 });
 
-function init_popup(config) {
-    $("#mkwsPopup").dialog({
+function init_popup(obj) {
+    var config = obj ? obj : {};
+
+    var height = config.height || 760;
+    var width = config.width || 880;
+    var id_button = config.button || "input#mkwsButton";
+    var id_popup = config.popup || "#mkwsPopup";
+
+    debug("popup height: " + height + ", width: " + width);
+
+    $(id_popup).dialog({
       closeOnEscape: true,
       autoOpen: false,
-      height: 760,
-      width: 880,
+      height: height,
+      width: width,
       modal: true,
       resizable: true,
       buttons: {
@@ -936,15 +940,13 @@ function init_popup(config) {
                      $(this).dialog("close");
              }
       },
-      close: function() {
-             // allFields.val( "" ).removeClass( "ui-state-error" );
-      }
+      close: function() { }
     });
 
-    $("input#mkwsButton")
+    $(id_button)
       .button()
       .click(function() {
-             $("#mkwsPopup").dialog("open");
+             $(id_popup).dialog("open");
       });
 };