From: Wolfram Schneider Date: Wed, 9 Jul 2014 14:47:03 +0000 (+0000) Subject: code cleanup X-Git-Tag: 1.0.0~389^2~10 X-Git-Url: http://git.indexdata.com/?p=mkws-moved-to-github.git;a=commitdiff_plain;h=91496e8aa6251dd1bfcdd04b8c233194c0fbc143 code cleanup --- diff --git a/src/mkws-popup.js b/src/mkws-popup.js index 4145652..4d03c52 100644 --- a/src/mkws-popup.js +++ b/src/mkws-popup.js @@ -1,41 +1,26 @@ -/*! jQuery plugin for MKWS, the MasterKey Widget Set. - * Copyright (C) 2013-2014 Index Data - * See the file LICENSE for details +/* generic function to open results in a popup window + * */ -"use strict"; +// "use strict"; +mkws.registerWidgetType('Popup', function() { + alert("running popup"); -/* - * implement jQuery plugin $.pazpar2({}) - */ -function _mkws_jquery_plugin($) { - function debug(string) { - mkws.log("jQuery.pazpar2: " + string); + if (!mkws.$.ui) { + alert("Error: jquery-ui.js is missing, did you include it after jQuery core in the HTML file?"); + return; } - function init_popup(obj) { - var config = obj ? obj : {}; - - var height = config.height || 760; - var width = config.width || 880; - var id_button = config.id_button || "input.mkwsButton"; - var id_popup = config.id_popup || ".mkwsPopup"; - - debug("popup height: " + height + ", width: " + width); + 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"; - // make sure that jquery-ui was loaded afte jQuery core lib, e.g.: - // - if (!$.ui) { - debug("Error: jquery-ui.js is missing, did you include it after jQuery core in the HTML file?"); - return; - } - - $(id_popup).dialog({ + $(this).dialog({ closeOnEscape: true, - autoOpen: false, - height: height, - width: width, + 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: { @@ -44,106 +29,7 @@ function _mkws_jquery_plugin($) { } }, close: function() { } - }); - - $(id_button) - .button() - .click(function() { - $(id_popup).dialog("open"); - }); - }; - - $.extend({ - - // service-proxy or pazpar2 - pazpar2: function(config) { - if (config == null || typeof config != 'object') { - config = {}; - } - var id_popup = config.id_popup || ".mkwsPopup"; - id_popup = id_popup.replace(/^[#\.]/, ""); - - // simple layout - var div = '\ -
\ -
\ -
\ -
\ -
\ -
'; - - // new table layout - var table = '\ -\ - \ -\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
'; - - var popup = '\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
' - - if (config && config.layout == 'div') { - debug("jquery plugin layout: div"); - document.write(div); - } else if (config && config.layout == 'popup') { - debug("jquery plugin layout: popup with id: " + id_popup); - document.write(popup); - $(document).ready(function() { init_popup(config); }); - } else { - debug("jquery plugin layout: table"); - document.write(table); - } - } }); -}; - -// XXX: enable before page load, so we could call it before mkws() runs -_mkws_jquery_plugin(mkws.$); +});