Comment 3 for bug 1144820

Revision history for this message
Lin Hua Cheng (lin-hua-cheng) wrote :

What I implemented right now is still basic.

In settings.py, the delay for auto-dismiss message and the duration of the fadeout are configured.

HORIZON_CONFIG = {
    ..
    'data_dismiss_delay': 3000,
    'data_dismiss_fade_duration': 1500,
    .}

In _messages.html, define what messages you want to auto-fade by adding the attribute data-dismiss-auto="true"

<div class="alert alert-block alert-success fade in" data-dismiss-auto="true">
      <a class="close" data-dismiss="alert" href="#">&times;</a>
      <p><strong>{% trans "Success: " %}</strong>{{ message }}</p>
</div>

Another alternative configuration I could this of is:

HORIZON_CONFIG = {
    ..
    'auto_fade_message': {
     'delay': 3000,
            'fade_duration': 1500,
     'alerts' : ['success', 'info']
    },
 ..
}

The alerts takes a list of alert type where the auto-fade will be applied. By default the alerts can be an empty list to fallback to default behavior of no auto-fade.