X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Fmkws-popup.js;h=6282ceb1ec902edea81d0464346dfd696fb999b7;hb=595c919870587c9ecc6e9e015213c9e39008e287;hp=153425b866daff6a06fe8befa639e087f41a90c6;hpb=d05e75ede48a52fae21f388471acc37ad5e92293;p=mkws-moved-to-github.git diff --git a/src/mkws-popup.js b/src/mkws-popup.js index 153425b..6282ceb 100644 --- a/src/mkws-popup.js +++ b/src/mkws-popup.js @@ -3,9 +3,8 @@ */ // "use strict"; - -$(document).ready(function () { - // mkws.registerWidgetType('PopupWindow', function() { +// $(document).ready(function () { +mkws.registerWidgetType('Popup', function() { var $ = mkws.$; var debug = mkws.log; debug("init popup window"); @@ -15,30 +14,47 @@ $(document).ready(function () { return; } - var popup = $(".PopupWindow"); - if (!popup) { - debug("no popup found"); + // var popup_window = $(this.node); // + var popup_window = $(".mkwsPopup"); + + if (!popup_window) { + debug("no popup found, skip"); return; } else { - debug("found popup windows: " + popup.length); + debug("found popup windows: " + popup_window.length); } - var width = parseInt($(popup).attr("popup_width") || "800"); - var height = parseInt($(popup).attr("popup_height") || "600"); - var autoOpen = parseInt($(popup).attr("popup_autoOpen") || "0"); + // more than one widget on a page are possible + popup_window.each(function (i) { + var that = $(this); + + var width = parseInt(that.attr("popup_width") || "800"); + var height = parseInt(that.attr("popup_height") || "600"); + var autoOpen = parseInt(that.attr("popup_autoOpen") || "0"); + var modal = parseInt(that.attr("popup_modal") || "0"); + + debug("Popup parameters: width: " + width + ", height: " + height + ", autoOpen: " + autoOpen); + that.dialog({ + closeOnEscape: true, + autoOpen: autoOpen, + height: height, + width: width, + modal: modal ? true : false, + resizable: true, + buttons: { + Cancel: function () { + that.dialog("close"); + } + }, + close: function () {} + }); - $(popup).dialog({ - closeOnEscape: true, - autoOpen: autoOpen, - height: height, - width: width, - modal: true, - resizable: true, - buttons: { - Cancel: function () { - $(popup).dialog("close"); - } - }, - close: function () {} + // open at search query submit + var id_botton = that.attr("popup_button"); + if (id_botton) { + $(id_botton).button().click(function () { + that.dialog("open"); + }); + } }); });