X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmkws-popup.js;h=ca38e5d86b08977c2ea11a89fe09d9faa0b85664;hb=cfaf82446f3eee1f51784817bb43cf2ea8862679;hp=4d03c52d28f71f1ba07e24ed026c917256441234;hpb=91496e8aa6251dd1bfcdd04b8c233194c0fbc143;p=mkws-moved-to-github.git diff --git a/src/mkws-popup.js b/src/mkws-popup.js index 4d03c52..ca38e5d 100644 --- a/src/mkws-popup.js +++ b/src/mkws-popup.js @@ -3,33 +3,56 @@ */ // "use strict"; +$(document).ready(function () { +// mkws.registerWidgetType('WmkwsPopup', function() { + var $ = mkws.$; + var debug = mkws.log; + debug("init popup window"); -mkws.registerWidgetType('Popup', function() { - alert("running popup"); + if (!$.ui) { + alert("Error: jquery-ui.js is missing, did you include it after jQuery core in the HTML file?"); + return; + } - if (!mkws.$.ui) { - alert("Error: jquery-ui.js is missing, did you include it after jQuery core in the HTML file?"); - return; - } + var popup_window = $(".WmkwsPopup"); + if (!popup_window) { + debug("no popup found, skip"); + return; + } else { + debug("found popup windows: " + popup_window.length); + } - 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"; + // more than one widget on a page are possible + popup_window.each(function (i) { + var that = $(this); - $(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(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 () {} + }); + // open at search query submit + var id_botton = that.attr("popup_button"); + if (id_botton) { + $(id_botton).button().click(function () { + that.dialog("open"); + }); + } + }); +});