Merge "Implement configurable auto-fade for alerts messages."
This commit is contained in:
commit
7a0f593f6c
@ -27,6 +27,22 @@ horizon.clearAllMessages = function() {
|
||||
horizon.clearSuccessMessages();
|
||||
};
|
||||
|
||||
horizon.autoDismissAlerts = function() {
|
||||
var $alerts = $('#main_content .messages .alert');
|
||||
|
||||
$alerts.each(function(index, alert) {
|
||||
var $alert = $(this),
|
||||
types = $alert.attr('class').split(' ');
|
||||
|
||||
// Check if alert should auto-fade
|
||||
if (_.intersection(types, horizon.conf.auto_fade_alerts.types).length > 0) {
|
||||
setTimeout(function() {
|
||||
$alert.fadeOut(horizon.conf.auto_fade_alerts.fade_duration);
|
||||
}, horizon.conf.auto_fade_alerts.delay);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
horizon.addInitFunction(function () {
|
||||
// Bind AJAX message handling.
|
||||
$("body").ajaxComplete(function(event, request, settings){
|
||||
@ -43,4 +59,7 @@ horizon.addInitFunction(function () {
|
||||
|
||||
// Bind dismiss(x) handlers for alert messages.
|
||||
$(".alert").alert();
|
||||
|
||||
// Hide alerts automatically if attribute data-dismiss-auto is set to true.
|
||||
horizon.autoDismissAlerts();
|
||||
});
|
||||
|
@ -12,5 +12,10 @@ horizon.conf.static_url = "{{ STATIC_URL }}";
|
||||
horizon.conf.ajax = {
|
||||
queue_limit: {{ HORIZON_CONFIG.ajax_queue_limit|default:"null" }}
|
||||
};
|
||||
horizon.conf.auto_fade_alerts = {
|
||||
delay: {{ HORIZON_CONFIG.auto_fade_alerts.delay|default:"3000" }},
|
||||
fade_duration: {{ HORIZON_CONFIG.auto_fade_alerts.fade_duration|default:"1500" }},
|
||||
types: {{ HORIZON_CONFIG.auto_fade_alerts.types|default:"[]"|safe }}
|
||||
};
|
||||
</script>
|
||||
{% endcompress %}
|
||||
|
@ -25,6 +25,11 @@ HORIZON_CONFIG = {
|
||||
'default_dashboard': 'project',
|
||||
'user_home': 'openstack_dashboard.views.get_user_home',
|
||||
'ajax_queue_limit': 10,
|
||||
'auto_fade_alerts': {
|
||||
'delay': 3000,
|
||||
'fade_duration': 1500,
|
||||
'types': ['alert-success', 'alert-info']
|
||||
},
|
||||
'help_url': "http://docs.openstack.org",
|
||||
'exceptions': {'recoverable': exceptions.RECOVERABLE,
|
||||
'not_found': exceptions.NOT_FOUND,
|
||||
|
@ -59,6 +59,11 @@ HORIZON_CONFIG = {
|
||||
'default_dashboard': 'project',
|
||||
'user_home': 'openstack_dashboard.views.get_user_home',
|
||||
'ajax_queue_limit': 10,
|
||||
'auto_fade_alerts': {
|
||||
'delay': 3000,
|
||||
'fade_duration': 1500,
|
||||
'types': ['alert-success', 'alert-info']
|
||||
},
|
||||
'help_url': "http://docs.openstack.org",
|
||||
'exceptions': {'recoverable': exceptions.RECOVERABLE,
|
||||
'not_found': exceptions.NOT_FOUND,
|
||||
|
Loading…
x
Reference in New Issue
Block a user