Sha256: b73ac24650a53a776959596a7a6b1166cb72dbcd2ba86c87dd43fa6faba4b98c

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

(function(object) {
  'use strict';

  object.flash = {
    success: function(message) {
      object.flash.flashMessage('success', message);
    },

    error: function(message) {
      object.flash.danger(message);
    },
    danger: function(message) {
      object.flash.flashMessage('danger', message);
    },

    alert: function(message) {
      object.flash.warning(message);
    },
    warning: function(message) {
      object.flash.flashMessage('warning', message);
    },

    notice: function(message) {
      object.flash.info(message);
    },
    info: function(message) {
      object.flash.flashMessage('info', message);
    },

    flashMessage: function(type, message) {
      if (message == '' || message == undefined) {
        return false;
      }

      type = type || 'warning';

      var messagesContainer = document.querySelector('#alert-messages'),
          msgContainer = document.createElement('div');

      msgContainer.setAttribute('class', 'alert alert-' + type + ' alert-link');
      msgContainer.setAttribute('role', 'alert');
      msgContainer.innerHTML = message;

      messagesContainer.appendChild(msgContainer);
    }
  };

  return object;
}(Archangel || {}));

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
archangel-0.0.5 app/assets/javascripts/archangel/object/flash.js
archangel-0.0.4 app/assets/javascripts/archangel/object/flash.js
archangel-0.0.3 app/assets/javascripts/archangel/object/flash.js
archangel-0.0.2 app/assets/javascripts/archangel/object/flash.js