").attr("id", newId);
$("body").append(newElement);
var removeBaseElement = function () // this is utility function to be executed on dialog closing
{
$(newIdSelector).remove();
}
// now set default options
options.title = title;
options.modal = true;
options.resizable = (options.resizable === undefined) || options.resizable;
options.closeOnEscape = false || (options.closeOnEscape === true); // default is false
options.minHeight = options.minHeight || 280;
options.maxHeight = options.maxHeight || 560;
options.minWidth = options.minWidth || 320;
options.height = options.height || "auto";
options.close = (!options.close) ? removeBaseElement : function (e) { removeBaseElement(); options.close(e); }
// create dialog with given options
var dlg = $(newIdSelector).dialog(options);
// set dialogs body
dlg.html(body);
//alert($(newElement).find(".ui-dialog-buttonpane").size());
var buttonPane = $(newElement).parent().find(".ui-dialog-buttonpane");
buttonPane.addClass("stc-dialog");
return dlg;
}
dialogs.okCancelDialog = function (title, body, okAction, buttonCaptions, options) {
options = options || {};
okAction = okAction || function () { $(dlg).dialog("close"); };
buttonCaptions = buttonCaptions || {};
buttonCaptions.ok = buttonCaptions.ok || "Ok";
buttonCaptions.cancel = buttonCaptions.cancel || "Відмовитись";
// if any buttons defined in options parameter thay will be overriden
options.buttons =
[
{ text: buttonCaptions.ok, click: okAction }
, { text: buttonCaptions.cancel, click: function () { $(this).dialog("close"); } }
]
options.minWidth = options.minWidth || 560;
options.minHeight = options.minHeight || 560;
options.height = options.height || 560;
var dlg = genericDialog(title, body, options);
return dlg;
}
dialogs.submitDialog = function (title, fieldSetUrl, onFieldSetLoaded, httpMethod, submitUrl, onSuccess, onError, buttonCaptions, options) {
// options parameter beyond standart dialog optios could have additional boolean property "closeOnSuccess" (default is true)
buttonCaptions = buttonCaptions || { ok: "Зберегти", cancel: "Відмовитись" };
options = options || {};
var customBeforeCloseHandler = options.beforeClose;
options.beforeClose = function () { customBeforeCloseHandler && customBeforeCloseHandler(); $(frameIdSelector).remove(); }
onSuccess = onSuccess || function (xhr) { };
var closeOnSuccess = (options.closeOnSuccess === undefined) || (options.closeOnSuccess === 'undefined') || options.closeOnSuccess;
var internalSuccessHandler = function (dlg, xhr) {
if (closeOnSuccess) {
$(dlg).dialog("close");
}
onSuccess && onSuccess(xhr.responseText ? xhr.responseText : xhr);
}
// prepare dom element for fieldset
var formContainer = $("
");
var frameId = stc.utils.getNewId();
var frameIdSelector = "#" + frameId;
var iframe = $("