spDialog
Basic Alert
Basic Confirm
Confirm with Cancel
Custom Body Alert
Custom Dialog Design
Github
Discussions
let dlgBasicAlert = null;
function init()
{
let dlgBasicAlertParams = {
textTitle: 'Example: Alert Replacement',
textBody: `<div style='margin-bottom: 5px'>This is an example of a simple alert() replacement dialog.</div><div><span style='font-weight: bold'>NOTE:</span> textBody can contain HTML.</div>`,
showAnswerCancel: false,
showAnswerFalse: false,
dialogWidth: '375px',
dialogHeight: '175px',
dialogFontSize: '.85rem',
dialogAnimate: true,
onOpen: () => {ProcessOpen(document.getElementById('ex-basic-alert-response'));}
}
dlgBasicAlert = new spDialog(dlgBasicAlertParams);
}
async function ShowBasicAlert()
{
await dlgBasicAlert.ShowDialog().then(result => {ProcessResponse(document.getElementById('ex-basic-alert-response'), dlgBasicAlert.userResponse)});
}
let dlgBasicConfirm = null;
function init()
{
let dlgBasicConfirmParams = {
textTitle: 'Example: Confirm Replacement',
textBody: `This is a simple confirm box to ask the user a question.<br/><br/>Would you like to continue?`,
showAnswerCancel: false,
showAnswerFalse: true,
dialogWidth: '425px',
dialogHeight: '150px',
dialogFontSize: '.85rem',
dialogAnimate: true,
onOpen: () => {ProcessOpen(document.getElementById('ex-basic-confirm-response'));}
}
dlgBasicConfirm = new spDialog(dlgBasicConfirmParams);
}
async function ShowBasicConfirm()
{
await dlgBasicConfirm.ShowDialog().then(result => {ProcessResponse(document.getElementById('ex-basic-confirm-response'), dlgBasicConfirm.userResponse)});
}
let dlgConfirmCancel = null;
function init()
{
let dlgConfirmCancelParams = {
textTitle: 'Example: Confirm Replacement with Cancel',
textBody: `This is a simple confirm box to ask the user a question and allow them to cancel the request. It also shows that you can adjust the text of the buttons and use percentages for width/height.
Do you agree?`,
showAnswerCancel: true,
showAnswerFalse: true,
dialogWidth: '40%',
dialogHeight: '20%',
dialogFontSize: '.75rem',
dialogAnimate: true,
textAnswerTrue: 'Agree',
textAnswerFalse: 'Disagree',
onOpen: () => {ProcessOpen(document.getElementById('ex-confirm-cancel-response'));}
}
dlgConfirmCancel = new spDialog(dlgConfirmCancelParams);
}
async function ShowConfirmCancel()
{
await dlgConfirmCancel.ShowDialog().then(result => {ProcessResponse(document.getElementById('ex-confirm-cancel-response'), dlgConfirmCancel.userResponse)});
}
let dlgCustomAlertBody = null;
function init()
{
let dlgCustomAlertBodyParams = {
textTitle: 'Example: Alert Custom Body',
showAnswerCancel: false,
showAnswerFalse: false,
dialogFontSize: '.75rem',
dialogWidth: '35%',
dialogHeight: '15%',
dialogAnimate: true,
customBody: document.getElementById('customAlertBody'),
onOpen: () => {ProcessOpen(document.getElementById('ex-alert-custom-response'));},
onClose: () => { document.getElementById('ex-alert-custom-onclose').innerHTML = `Welcome ${document.getElementById('customAlertBody_PersonName').value}!`; document.getElementById('customAlertBody_PersonName').value = ''; }
}
dlgCustomAlertBody = new spDialog(dlgCustomAlertBodyParams);
}
async function ShowAlertCustomBody()
{
await dlgCustomAlertBody.ShowDialog().then(result => {ProcessResponse(document.getElementById('ex-alert-custom-response'), dlgCustomAlertBody.userResponse)});
}
let dlgCompletelyCustom = null;
function init()
{
let dlgCompletelyCustomParams = {
textTitle: 'Example: Custom Dialog Design',
textBody: 'This is an example of a dialog with custom formatting. Compare it to the other examples and the differences should be apparent.',
dialogWidth: '40%',
dialogHeight: '175px',
dialogAnimate: true,
onOpen: () => {ProcessOpen(document.getElementById('ex-alert-completely-custom-response'));},
}
dlgCompletelyCustom = new spDialog(dlgCompletelyCustomParams);
dlgCompletelyCustom.modalCover.style.backgroundColor = 'rgba(255, 255, 255, .5)';
dlgCompletelyCustom.modalDialog.style.border = '1px solid #969696';
dlgCompletelyCustom.modalDialog.style.borderTop = '0px solid #3268a8';
dlgCompletelyCustom.modalDialog.style.backgroundColor = '#e0e0e0';
dlgCompletelyCustom.modalDialog.style.padding = '0px';
dlgCompletelyCustom.dialogTitle.style.height = '15px';
dlgCompletelyCustom.dialogTitle.style.border = '4px solid #3268a8';
dlgCompletelyCustom.dialogTitle.style.backgroundColor = '#3268a8';
dlgCompletelyCustom.dialogTitle.style.borderRadius = '10px 10px 0px 0px';
dlgCompletelyCustom.dialogTitle.style.textAlign = 'left';
dlgCompletelyCustom.dialogTitle.style.color = '#ffffff';
dlgCompletelyCustom.dialogTitle.style.padding = '5px';
dlgCompletelyCustom.dialogTitle.style.textShadow = '2px 2px 2px rgba(0, 0, 0, .85)';
dlgCompletelyCustom.dialogTitle.style.fontSize = '.9em';
dlgCompletelyCustom.dialogBody.style.padding = '5px';
dlgCompletelyCustom.dialogBody.style.height = '50%';
}
async function ShowAlertCompletelyCustom()
{
await dlgCompletelyCustom.ShowDialog().then(result => {ProcessResponse(document.getElementById('ex-alert-completely-custom-response'), dlgCompletelyCustom.userResponse)});
}