CoreFiles by mySites.guru
Notifications.es6.js54 lines, 1,016 bytes, from Joomla_6.1.4-Stable-Full_Package.zip
Raw History Compare with 6.1.3
md5
9ea1decb62d1e93348984fba95ac2377
sha1
7456d0ce39d869427516df413d39469a8cfcf394
sha256
10e5562018d8e0789f61d7f8ec9ca5025c65bdfad7b0e5ecaadb562bca875471
/**
 * Send a notification
 * @param {String} message
 * @param {{}} options
 *
 */
function notify(message, options) {
  let timer;
  if (options.type === 'message') {
    timer = 3000;
  }
  Joomla.renderMessages(
    {
      [options.type]: [Joomla.Text._(message)],
    },
    undefined,
    true,
    timer,
  );
}

const notifications = {
  /* Send a success notification */
  success: (message, options) => {
    notify(message, {
      type: 'message', // @todo rename it to success
      dismiss: true,
      ...options,
    });
  },

  /* Send an error notification */
  error: (message, options) => {
    notify(message, {
      type: 'error', // @todo rename it to danger
      dismiss: true,
      ...options,
    });
  },

  /* Send a general notification */
  notify: (message, options) => {
    notify(message, {
      type: 'message',
      dismiss: true,
      ...options,
    });
  },

  /* Ask the user a question */
  ask: (message) => window.confirm(message),
};

export default notifications;

The same content is in 18 releases, Joomla 6.1.0-beta1 to 6.1.4. See them all, or every version of this file.