mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
[enh] Cleanup flash alert display.
This commit is contained in:
parent
52eb6201fe
commit
dc4f9649d6
5 changed files with 48 additions and 24 deletions
|
@ -498,3 +498,15 @@ input[type='radio'].nice-radio {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Alert messages **/
|
||||
.alert {}
|
||||
.alert-log {
|
||||
p {display: none;}
|
||||
.btn-show-log {
|
||||
.btn();
|
||||
.btn-default();
|
||||
.btn-sm();
|
||||
}
|
||||
}
|
4
src/dist/css/style.min.css
vendored
4
src/dist/css/style.min.css
vendored
File diff suppressed because one or more lines are too long
5
src/dist/js/script.min.js
vendored
5
src/dist/js/script.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -23,7 +23,7 @@
|
|||
</span>
|
||||
</header>
|
||||
|
||||
<div id="flash" role="alert" style="display: none"></div>
|
||||
<div id="flash" role="alert"></div>
|
||||
|
||||
<div id="slider-container">
|
||||
|
||||
|
|
|
@ -71,26 +71,37 @@ var app = Sammy('#main', function (sam) {
|
|||
if (!store.get('flash')) {
|
||||
store.set('flash', true);
|
||||
}
|
||||
if (level == 'fail') { alertClass = 'alert-danger'; }
|
||||
else { alertClass = 'alert-'+ level; }
|
||||
if ($('#flash .alert').last().hasClass(alertClass)) {
|
||||
|
||||
var flashContainer = $('#flash'),
|
||||
lastFlashAlert = $('.alert:last-child', flashContainer),
|
||||
alertClass = (level !== 'fail') ? alertClass = 'alert-'+ level : 'alert-danger';
|
||||
|
||||
// If last alert has the same class, append content into it
|
||||
if (lastFlashAlert.hasClass(alertClass)) {
|
||||
lastFlashAlert.append('<p>'+ message +'</p>');
|
||||
}
|
||||
// Else, create a new alert box
|
||||
else {
|
||||
var alertCloseButton = '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>';
|
||||
if (level == 'log') {
|
||||
$('#flash .alert').last().append('<p style="display: none">'+ message +'</p>');
|
||||
} else {
|
||||
$('#flash .alert').last().append('<p>'+ message +'</p>');
|
||||
}
|
||||
} else {
|
||||
if (level == 'log') {
|
||||
$('#flash').append('<pre style="display:none" class="alert alert-dismissable '+ alertClass +'"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><button type="button" class="btn btn-default btn-small" data-show="log">'+ y18n.t('log') +'</button><p style="display: none">'+ message +'</p></pre>').show();
|
||||
} else {
|
||||
$('#flash').append('<div style="display:none" class="alert alert-dismissable '+ alertClass +'"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><p>'+ message +'</p></div>').show();
|
||||
}
|
||||
$('#flash .alert').last().fadeIn();
|
||||
}
|
||||
document.body.scrollTop = document.documentElement.scrollTop = 0;
|
||||
$('#flash [data-show="log"]').on('click', function() {
|
||||
// Log messages could be very long
|
||||
// Hidden by default with a "view log" button
|
||||
flashContainer
|
||||
.append('<pre class="alert alert-dismissable '+ alertClass +'">'+alertCloseButton+
|
||||
'<button type="button" class="btn-show-log">'+ y18n.t('log') +'</button>'+
|
||||
'<p>'+ message +'</p></pre>')
|
||||
.find('.btn-show-log').on('click', function() {
|
||||
$(this).hide().nextAll('p').fadeIn();
|
||||
});
|
||||
} else {
|
||||
flashContainer
|
||||
.append('<div class="alert alert-dismissable '+ alertClass +'">'+alertCloseButton+
|
||||
'<p>'+ message +'</p></div>');
|
||||
}
|
||||
}
|
||||
|
||||
// Scroll to the top
|
||||
document.body.scrollTop = document.documentElement.scrollTop = 0;
|
||||
},
|
||||
|
||||
checkInstall: function(callback) {
|
||||
|
@ -444,7 +455,7 @@ var app = Sammy('#main', function (sam) {
|
|||
|
||||
// Clear flash display
|
||||
if (!store.get('flash')) {
|
||||
$('#flash').fadeOut(function() { $('#flash').html(''); });
|
||||
$('#flash').fadeOut(function() { $('#flash').html('').show(); });
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue