Added function display_confirm_dialog with custom dialog

This commit is contained in:
fermin831 2018-04-25 12:32:58 +02:00
parent 112bbac527
commit 675e8deb47
2 changed files with 80 additions and 0 deletions

View File

@ -1563,3 +1563,67 @@ function round_with_decimals (value, multiplier = 1) {
} }
return round_with_decimals (value, multiplier * 10); return round_with_decimals (value, multiplier * 10);
} }
/*
$("body").append('<div id="event_delete_confirm_dialog"><h4>' + '<?php echo __('Are you sure?'); ?>' + '</h4></div>');
$("#event_delete_confirm_dialog").dialog({
resizable: false,
draggable: false,
modal: true,
height: 280,
width: 330,
overlay: {
opacity: 0.5,
background: "black"
},
closeOnEscape: false,
open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); }
});
*/
/**
* Display a confirm dialog box
*
* @param string Text to display
* @param string Ok button text
* @param string Cancel button text
* @param function Callback to action when ok button is pressed
*/
function display_confirm_dialog (
message = '',
ok_text = '',
cancel_text = '',
ok_function = function () {}
) {
// Clean function to close the dialog
var clean_function = function () {
$("#pandora_confirm_dialog_text").hide();
$("#pandora_confirm_dialog_text").remove();
}
// Modify the ok function to close the dialog too
var ok_function_clean = function () {
ok_function();
clean_function();
}
// Display the dialog
$("body").append('<div id="pandora_confirm_dialog_text"><h3>' + message + '</h3></div>');
$("#pandora_confirm_dialog_text").dialog({
resizable: false,
draggable: true,
modal: true,
dialogClass: "pandora_confirm_dialog",
overlay: {
opacity: 0.5,
background: "black"
},
closeOnEscape: true,
modal: true,
buttons: {
Cancel: clean_function,
"Confirm": ok_function_clean
}
});
}

View File

@ -4633,3 +4633,19 @@ form ul.form_flex li ul li{
line-height: 1.05em!important; line-height: 1.05em!important;
} }
.pandora_confirm_dialog .ui-dialog-buttonset {
display: flex;
width: 100%;
margin-left: 10px;
float: none !important;
}
.pandora_confirm_dialog .ui-dialog-buttonset button{
flex: 50%;
}
#pandora_confirm_dialog_text h3{
margin-left: 20px;
margin-right: 20px;
text-align: center;
}