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
|
@ -497,4 +497,16 @@ input[type='radio'].nice-radio {
|
||||||
content: @fa-var-check-circle-o;
|
content: @fa-var-check-circle-o;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** 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>
|
</span>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div id="flash" role="alert" style="display: none"></div>
|
<div id="flash" role="alert"></div>
|
||||||
|
|
||||||
<div id="slider-container">
|
<div id="slider-container">
|
||||||
|
|
||||||
|
|
|
@ -71,26 +71,37 @@ var app = Sammy('#main', function (sam) {
|
||||||
if (!store.get('flash')) {
|
if (!store.get('flash')) {
|
||||||
store.set('flash', true);
|
store.set('flash', true);
|
||||||
}
|
}
|
||||||
if (level == 'fail') { alertClass = 'alert-danger'; }
|
|
||||||
else { alertClass = 'alert-'+ level; }
|
var flashContainer = $('#flash'),
|
||||||
if ($('#flash .alert').last().hasClass(alertClass)) {
|
lastFlashAlert = $('.alert:last-child', flashContainer),
|
||||||
if (level == 'log') {
|
alertClass = (level !== 'fail') ? alertClass = 'alert-'+ level : 'alert-danger';
|
||||||
$('#flash .alert').last().append('<p style="display: none">'+ message +'</p>');
|
|
||||||
} else {
|
// If last alert has the same class, append content into it
|
||||||
$('#flash .alert').last().append('<p>'+ message +'</p>');
|
if (lastFlashAlert.hasClass(alertClass)) {
|
||||||
}
|
lastFlashAlert.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();
|
|
||||||
}
|
}
|
||||||
|
// Else, create a new alert box
|
||||||
|
else {
|
||||||
|
var alertCloseButton = '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>';
|
||||||
|
if (level == 'log') {
|
||||||
|
// 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;
|
document.body.scrollTop = document.documentElement.scrollTop = 0;
|
||||||
$('#flash [data-show="log"]').on('click', function() {
|
|
||||||
$(this).hide().nextAll('p').fadeIn();
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
checkInstall: function(callback) {
|
checkInstall: function(callback) {
|
||||||
|
@ -444,7 +455,7 @@ var app = Sammy('#main', function (sam) {
|
||||||
|
|
||||||
// Clear flash display
|
// Clear flash display
|
||||||
if (!store.get('flash')) {
|
if (!store.get('flash')) {
|
||||||
$('#flash').fadeOut(function() { $('#flash').html(''); });
|
$('#flash').fadeOut(function() { $('#flash').html('').show(); });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue