mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
change load modal ??????
This commit is contained in:
parent
89e83e38e0
commit
578400aa92
@ -1,4 +1,4 @@
|
|||||||
/* global $ */
|
/* global $ uniqId*/
|
||||||
/* exported load_modal */
|
/* exported load_modal */
|
||||||
/*JS to Show user modals :
|
/*JS to Show user modals :
|
||||||
- Confirm dialogs.
|
- Confirm dialogs.
|
||||||
@ -60,12 +60,19 @@ function logo_preview(icon_name, icon_path, incoming_options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Advanced Form control.
|
// Advanced Form control.
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
function load_modal(settings) {
|
function load_modal(settings) {
|
||||||
var AJAX_RUNNING = 0;
|
var AJAX_RUNNING = 0;
|
||||||
var data = new FormData();
|
var data = new FormData();
|
||||||
if (settings.extradata) {
|
if (settings.extradata) {
|
||||||
settings.extradata.forEach(function(item) {
|
settings.extradata.forEach(function(item) {
|
||||||
if (item.value != undefined) data.append(item.name, item.value);
|
if (item.value != undefined) {
|
||||||
|
if (item.value instanceof Object || item.value instanceof Array) {
|
||||||
|
data.append(item.name, JSON.stringify(item.value));
|
||||||
|
} else {
|
||||||
|
data.append(item.name, item.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
data.append("page", settings.onshow.page);
|
data.append("page", settings.onshow.page);
|
||||||
@ -99,6 +106,10 @@ function load_modal(settings) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings.beforeClose == undefined) {
|
||||||
|
settings.beforeClose = function() {};
|
||||||
|
}
|
||||||
|
|
||||||
settings.target.html("Loading modal...");
|
settings.target.html("Loading modal...");
|
||||||
settings.target
|
settings.target
|
||||||
.dialog({
|
.dialog({
|
||||||
@ -168,7 +179,6 @@ function load_modal(settings) {
|
|||||||
text: settings.modal.ok,
|
text: settings.modal.ok,
|
||||||
click: function() {
|
click: function() {
|
||||||
if (AJAX_RUNNING) return;
|
if (AJAX_RUNNING) return;
|
||||||
|
|
||||||
if (settings.onsubmit != undefined) {
|
if (settings.onsubmit != undefined) {
|
||||||
if (settings.onsubmit.preaction != undefined) {
|
if (settings.onsubmit.preaction != undefined) {
|
||||||
settings.onsubmit.preaction();
|
settings.onsubmit.preaction();
|
||||||
@ -189,7 +199,7 @@ function load_modal(settings) {
|
|||||||
formdata.append("method", settings.onsubmit.method);
|
formdata.append("method", settings.onsubmit.method);
|
||||||
|
|
||||||
var flagError = false;
|
var flagError = false;
|
||||||
|
if (Array.isArray(settings.form) === false) {
|
||||||
$("#" + settings.form + " :input").each(function() {
|
$("#" + settings.form + " :input").each(function() {
|
||||||
if (this.checkValidity() === false) {
|
if (this.checkValidity() === false) {
|
||||||
$(this).attr("title", this.validationMessage);
|
$(this).attr("title", this.validationMessage);
|
||||||
@ -237,8 +247,35 @@ function load_modal(settings) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
settings.form.forEach(function(element) {
|
||||||
|
$("#" + element + " :input").each(function() {
|
||||||
|
// TODO VALIDATE ALL INPUTS.
|
||||||
|
if (this.type == "file") {
|
||||||
|
if ($(this).prop("files")[0]) {
|
||||||
|
formdata.append(this.name, $(this).prop("files")[0]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($(this).attr("type") == "checkbox") {
|
||||||
|
if (this.checked) {
|
||||||
|
formdata.append(this.name, "on");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
formdata.append(this.name, $(this).val());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (flagError === false) {
|
if (flagError === false) {
|
||||||
|
if (
|
||||||
|
settings.onsubmitClose != undefined &&
|
||||||
|
settings.onsubmitClose == 1
|
||||||
|
) {
|
||||||
|
$(this).dialog("close");
|
||||||
|
}
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "post",
|
method: "post",
|
||||||
url: settings.url,
|
url: settings.url,
|
||||||
@ -289,17 +326,32 @@ function load_modal(settings) {
|
|||||||
modal: true,
|
modal: true,
|
||||||
title: settings.modal.title,
|
title: settings.modal.title,
|
||||||
width: width,
|
width: width,
|
||||||
|
minHeight:
|
||||||
|
settings.onshow.minHeight != undefined
|
||||||
|
? settings.onshow.minHeight
|
||||||
|
: "auto",
|
||||||
|
maxHeight:
|
||||||
|
settings.onshow.maxHeight != undefined
|
||||||
|
? settings.onshow.maxHeight
|
||||||
|
: "auto",
|
||||||
overlay: settings.modal.overlay,
|
overlay: settings.modal.overlay,
|
||||||
buttons: required_buttons,
|
buttons: required_buttons,
|
||||||
closeOnEscape: false,
|
closeOnEscape: true,
|
||||||
open: function() {
|
open: function() {
|
||||||
$(".ui-dialog-titlebar-close").hide();
|
//$(".ui-dialog-titlebar-close").hide();
|
||||||
},
|
},
|
||||||
close: function() {
|
close: function() {
|
||||||
if (id_modal_target != undefined) {
|
if (id_modal_target != undefined) {
|
||||||
$(id_modal_target).remove();
|
$(id_modal_target).remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings.cleanup != undefined) {
|
||||||
|
settings.cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$(this).dialog("destroy");
|
||||||
|
},
|
||||||
|
beforeClose: settings.beforeClose()
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error: function(data) {
|
error: function(data) {
|
||||||
@ -308,7 +360,9 @@ function load_modal(settings) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//Function that shows a dialog box to confirm closures of generic manners. The modal id is random
|
// Function that shows a dialog box to confirm closures of generic manners.
|
||||||
|
// The modal id is random.
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
function confirmDialog(settings) {
|
function confirmDialog(settings) {
|
||||||
var randomStr = uniqId();
|
var randomStr = uniqId();
|
||||||
|
|
||||||
@ -365,6 +419,7 @@ function confirmDialog(settings) {
|
|||||||
*
|
*
|
||||||
* @return {void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
function generalShowMsg(data, idMsg) {
|
function generalShowMsg(data, idMsg) {
|
||||||
var title = data.title[data.error];
|
var title = data.title[data.error];
|
||||||
var text = data.text[data.error];
|
var text = data.text[data.error];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user