BigW Consortium Gitlab

flash.js 1.09 KB
Newer Older
1
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, one-var, one-var-declaration-per-line, no-param-reassign, quotes, quote-props, prefer-template, comma-dangle, max-len */
Fatih Acet committed
2

3 4
window.Flash = (function() {
  var hideFlash;
Fatih Acet committed
5

6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  hideFlash = function() {
    return $(this).fadeOut();
  };

  function Flash(message, type, parent) {
    var flash, textDiv;
    if (type == null) {
      type = 'alert';
    }
    if (parent == null) {
      parent = null;
    }
    if (parent) {
      this.flashContainer = parent.find('.flash-container');
    } else {
      this.flashContainer = $('.flash-container-page');
    }
    this.flashContainer.html('');
    flash = $('<div/>', {
      "class": "flash-" + type
    });
    flash.on('click', hideFlash);
    textDiv = $('<div/>', {
      "class": 'flash-text',
      text: message
    });
    textDiv.appendTo(flash);
    if (this.flashContainer.parent().hasClass('content-wrapper')) {
      textDiv.addClass('container-fluid container-limited');
Fatih Acet committed
35
    }
36 37 38
    flash.appendTo(this.flashContainer);
    this.flashContainer.show();
  }
Fatih Acet committed
39

40 41
  return Flash;
})();