2017-01-10 18:02:20 -05:00
|
|
|
/* 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 */
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-03-11 02:30:44 -05:00
|
|
|
window.Flash = (function() {
|
|
|
|
var hideFlash;
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-03-11 02:30:44 -05:00
|
|
|
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');
|
2016-07-24 16:45:11 -04:00
|
|
|
}
|
2017-03-11 02:30:44 -05:00
|
|
|
flash.appendTo(this.flashContainer);
|
|
|
|
this.flashContainer.show();
|
|
|
|
}
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-03-11 02:30:44 -05:00
|
|
|
return Flash;
|
|
|
|
})();
|