/**
 * 
 *  
    confirmMessage(pageName + " 차트를 파일로 저장 하시겠습니까?").done((yes)=>{
        if (yes){
            fcltSttsChart.exportChart({
                filename: pageName + '_' + excellTime()
            });
        }
    });
 */

/**
 * jquery-confirm
 */
document.write("<link rel='stylesheet' type='text/css' href='/libs/jquery-confirm-v3.3.4/jquery-confirm.min.css'/>");
document.write("<script src='/libs/jquery-confirm-v3.3.4/jquery-confirm.min.js'></script>");

function alertError(AMessage, ATitle, id) {
    return alertMessage("fa fa-warning", "red", "btn-red", AMessage, ATitle, id);
}

function alertWarning(AMessage, ATitle, id) {
    //return alertMessage("fa fa-asterisk", "blue", "btn-blue", AMessage, ATitle, id);
    return alertMessage("fa fa-warning", "red", "btn-red", AMessage, ATitle, id);
}

function alertConfirm(AMessage, ATitle, id) {
    return alertMessage("fa fa-info-circle", "blue", "btn-blue", AMessage, ATitle, id);
}

function alertMessage(icon, type, btnClass, AMessage, ATitle, id) {
    if (id) {
        id.focus();
    }
    const title = ATitle ?? document.title;
    const message = AMessage;
    $.alert({
        useBootstrap: false,
        title: title,
        content: message,
        titleClass: type,
        //theme: "dark",
        type: type,
        typeAnimated: true,
        columnClass: "col-md-4 col-md-offset-4",
        icon: icon,
        closeIcon: true,
        closeIcon: "close",
        closeIconClass: "fa fa-close",
        draggable: true,
        escapeKey: true,
        backgroundDismiss: false,
        backgroundDismissAnimation: "glow",
        buttons: {
            close: {
                text: " 확 인 ",
                btnClass: btnClass,
                keys: ["enter"],
                action: function () {
                    if (id) {
                        id.focus();
                    }
                },
            },
        },
    });
    return false;
}

function confirmMessage(AMessage, ATitle) {
    const title = ATitle ?? document.title;
    const message = AMessage;
    const ok = new $.Deferred();
    $.alert({
        useBootstrap: false,
        title: title,
        titleClass: "blue",
        content: message,
        //theme: "dark",
        type: "blue",
        typeAnimated: true,
        columnClass: "small",
        icon: "fa fa-check",
        closeIcon: true,
        closeIcon: "cancel",
        closeIconClass: "fa fa-close",
        draggable: true,
        escapeKey: false,
        backgroundDismiss: false,
        backgroundDismissAnimation: "glow",
        buttons: {
            close: {
                text: " 확 인 ",
                btnClass: "btn-blue",
                action: function () {
                    ok.resolve(true);
                },
            },
            cancel: {
                text: " 취 소 ",
                //btnClass: "btn-blue",
                action: function () {
                    ok.resolve(false);
                },
            },
        },
    });
    return ok.promise();
}
