transferred Code Ocean from original repository to GitHub
This commit is contained in:
0
lib/assets/.keep
Normal file
0
lib/assets/.keep
Normal file
41
lib/assets/javascripts/flash.js
Normal file
41
lib/assets/javascripts/flash.js
Normal file
@ -0,0 +1,41 @@
|
||||
(function() {
|
||||
var DURATION = 10000;
|
||||
var SEVERITIES = ['danger', 'info', 'success', 'warning'];
|
||||
|
||||
var buildFlash = function(options) {
|
||||
if (options.text) {
|
||||
var container = options.container;
|
||||
var html = '';
|
||||
if (options.icon) {
|
||||
html += '<i class="' + options.icon.join(' ') + '"> ';
|
||||
}
|
||||
html += options.text;
|
||||
container.html(html);
|
||||
showFlashes();
|
||||
}
|
||||
};
|
||||
|
||||
var generateMethods = function() {
|
||||
$.flash = {};
|
||||
$.each(SEVERITIES, function(index, severity) {
|
||||
$.flash[severity] = function(options) {
|
||||
buildFlash($.extend(options, {
|
||||
container: $('#flash-' + severity)
|
||||
}));
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
var showFlashes = function() {
|
||||
$('.flash').each(function() {
|
||||
if ($(this).html() !== '') {
|
||||
$(this).slideDown().delay(DURATION).slideUp(function() {
|
||||
$(this).html('');
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
generateMethods();
|
||||
$(showFlashes);
|
||||
})();
|
3
lib/assets/stylesheets/flash.css.scss
Normal file
3
lib/assets/stylesheets/flash.css.scss
Normal file
@ -0,0 +1,3 @@
|
||||
.flash {
|
||||
display: none;
|
||||
}
|
Reference in New Issue
Block a user