<commit_before>﻿var abp = abp || {};
(function ($) {
    if (!sweetAlert || !$) {
        return;
    }

    /* DEFAULTS *************************************************/

    abp.libs = abp.libs || {};
    abp.libs.sweetAlert = {
        config: {
            'default': {

            },
            info: {
                icon: 'info'
            },
            success: {
                icon: 'success'
            },
            warn: {
                icon: 'warning'
            },
            error: {
                icon: 'error'
            },
            confirm: {
                icon: 'warning',
                title: 'Are you sure?',
                buttons: ['Cancel', 'Yes']
            }
        }
    };

    /* MESSAGE **************************************************/

    var showMessage = function (type, message, title, isHtml) {

        if (!title) {
            title = message;
            message = undefined;
        }

        var messageContent = {
            title: title
        };

        if (isHtml) {
            const el = document.createElement('div');
            el.innerHTML = message;

            messageContent.content = el;
        } else {
            messageContent.text = message;
        }

        var opts = $.extend(
            {},
            abp.libs.sweetAlert.config['default'],
            abp.libs.sweetAlert.config[type],
            messageContent
        );

        return $.Deferred(function ($dfd) {
            sweetAlert(opts).then(function () {
                $dfd.resolve();
            });
        });
    };

    abp.message.info = function (message, title, isHtml) {
        return showMessage('info', message, title, isHtml);
    };

    abp.message.success = function (message, title, isHtml) {
        return showMessage('success', message, title, isHtml);
    };

    abp.message.warn = function (message, title, isHtml) {
        return showMessage('warn', message, title, isHtml);
    };

    abp.message.error = function (message, title, isHtml) {
        return showMessage('error', message, title, isHtml);
    };

    abp.message.confirm = function (message, titleOrCallback, callback, isHtml) {
        var messageContent;

        if (isHtml) {
            const el = document.createElement('div');
            el.innerHTML = message;

            messageContent = {
                content: el
            }
        } else {
            messageContent = {
                text: message
            }
        }

        if ($.isFunction(titleOrCallback)) {
            callback = titleOrCallback;
        } else if (titleOrCallback) {
            messageContent.title = titleOrCallback;
        };

        var opts = $.extend(
            {},
            abp.libs.sweetAlert.config['default'],
            abp.libs.sweetAlert.config.confirm,
            messageContent
        );

        return $.Deferred(function ($dfd) {
            sweetAlert(opts).then(function (isConfirmed) {
                callback && callback(isConfirmed);
                $dfd.resolve(isConfirmed);<commit_msg>fixes #18<commit_after>﻿var abp = abp || {};
(function ($) {
    if (!sweetAlert || !$) {
        return;
    }

    /* DEFAULTS *************************************************/

    abp.libs = abp.libs || {};
    abp.libs.sweetAlert = {
        config: {
            'default': {

            },
            info: {
                icon: 'info'
            },
            success: {
                icon: 'success'
            },
            warn: {
                icon: 'warning'
            },
            error: {
                icon: 'error'
            },
            confirm: {
                icon: 'warning',
                title: 'Are you sure?',
                buttons: ['Cancel', 'Yes']
            }
        }
    };

    /* MESSAGE **************************************************/

    var showMessage = function (type, message, title, isHtml) {

        if (!title) {
            title = message;
            message = undefined;
        }

        var messageContent = {
            title: title
        };

        if (isHtml) {
            var el = document.createElement('div');
            el.innerHTML = message;

            messageContent.content = el;
        } else {
            messageContent.text = message;
        }

        var opts = $.extend(
            {},
            abp.libs.sweetAlert.config['default'],
            abp.libs.sweetAlert.config[type],
            messageContent
        );

        return $.Deferred(function ($dfd) {
            sweetAlert(opts).then(function () {
                $dfd.resolve();
            });
        });
    };

    abp.message.info = function (message, title, isHtml) {
        return showMessage('info', message, title, isHtml);
    };

    abp.message.success = function (message, title, isHtml) {
        return showMessage('success', message, title, isHtml);
    };

    abp.message.warn = function (message, title, isHtml) {
        return showMessage('warn', message, title, isHtml);
    };

    abp.message.error = function (message, title, isHtml) {
        return showMessage('error', message, title, isHtml);
    };

    abp.message.confirm = function (message, titleOrCallback, callback, isHtml) {
        var messageContent;

        if (isHtml) {
            var el = document.createElement('div');
            el.innerHTML = message;

            messageContent = {
                content: el
            }
        } else {
            messageContent = {
                text: message
            }
        }

        if ($.isFunction(titleOrCallback)) {
            callback = titleOrCallback;
        } else if (titleOrCallback) {
            messageContent.title = titleOrCallback;
        };

        var opts = $.extend(
            {},
            abp.libs.sweetAlert.config['default'],
            abp.libs.sweetAlert.config.confirm,
            messageContent
        );

        return $.Deferred(function ($dfd) {
            sweetAlert(opts).then(function (isConfirmed) {
                callback && callback(isConfirmed);
                $dfd.resolve(isConfirmed);
{'fraction_non_alphanumeric': 0.1507627393703343, 'fraction_numerical': 0.0003245699448231094, 'mean_word_length': 1.4263779527559055, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6604280', 'n_tokens_mistral': 1655, 'n_tokens_neox': 1563, 'n_words': 322}