X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/133e3be21233547506c2d7342c92ca7fd7b8354a..a88e544966ffc9b0d5b2990709fdcb7c4713c1fd:/js/kivi.js diff --git a/js/kivi.js b/js/kivi.js index 5901c89a1..2be03018b 100644 --- a/js/kivi.js +++ b/js/kivi.js @@ -48,6 +48,47 @@ namespace("kivi", function(ns) { return window[name]; return namespace(parts[1])[ parts[2] ]; }; + + // Open a modal jQuery UI popup dialog. The content is loaded via AJAX. + // + // Parameters: + // - id: dialog DIV ID (optional; defaults to 'jqueryui_popup_dialog') + // - url, data, type: passed as the first three arguments to the $.ajax() call + // - dialog: an optional object of options passed to the $.dialog() call + ns.popup_dialog = function(params) { + var dialog; + + params = params || { }; + var id = params.id || 'jqueryui_popup_dialog'; + var dialog_params = $.extend( + { // kivitendo default parameters: + width: 800 + , height: 500 + , modal: true + }, + // User supplied options: + params.dialog || { }, + { // Options that must not be changed: + close: function(event, ui) { dialog.remove(); } + }); + + $('#' + id).remove(); + + dialog = $('').appendTo('body'); + dialog.dialog(dialog_params); + + $.ajax({ + url: params.url, + data: params.data, + type: params.type, + success: function(new_html) { + dialog.html(new_html); + dialog.removeClass('loading'); + } + }); + + return true; + }; }); kivi = namespace('kivi');