CoreFiles by mySites.guru
Notifications.js37 lines, 1,114 bytes, from Joomla_4.0.0-alpha2-Alpha-Full_Package.zip
Raw History Compare with 3.10.0-alpha9
md5
d06bdd4d11cb9020a38ef0376926abf4
sha1
9fc9bb2d66ae65b00046df43365778373ab01a57
sha256
a5e36ac94df077ce124ced8efbce994eeb0806e60bd530b2ce8fa488f228d4c6
class Notifications {

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

    /* Send an error notification */
    error(message, options) {
        notifications.notify(message, Object.assign({
            level: '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('level', options.level || '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 2 releases, Joomla 4.0.0-alpha2 to 4.0.0-alpha3. See them all, or every version of this file.