CoreFiles by mySites.guru
Notifications.js37 lines, 1,110 bytes, from Joomla_4.0.0-alpha7-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha6
md5
ff5adb6222ea00436f843aec0df2356d
sha1
76195c072141c70280f8168849aa465edb5667c4
sha256
e82118c55b33401f72c6355d807c70e22ed464d4d8339c7f17a041c795b515a0
class Notifications {

    /* Send and success notification */
    success(message, options) {
        notifications.notify(message, Object.assign({
            type: 'success',
            dismiss: true
        }, options));
    }

    /* Send an error notification */
    error(message, options) {
        notifications.notify(message, Object.assign({
            type: 'danger',
            dismiss: true
        }, options));
    }

    /* Ask the user a question */
    ask(message, options) {
        return window.confirm(message);
    }

    /* Send a notification */
    notify(message, options) {
        const alert = document.createElement('joomla-alert');
        alert.setAttribute('type', options.type || 'info');
        alert.setAttribute('dismiss', options.dismiss || true);
        alert.setAttribute('auto-dismiss', options.autoDismiss || true);
        alert.innerHTML = Joomla.JText._(message, message) || '';

        const messageContainer = document.getElementById('system-message');
        messageContainer.appendChild(alert);
    }
}

export let notifications = new Notifications();

The same content is in 8 releases, Joomla 4.0.0-alpha5 to 4.0.0-alpha12. See them all, or every version of this file.