Flash messaging using jQGrowl:
>>> f = Flash()
>>> f.info('my info')
>>> f.warn('my warn')
>>> print f.render() #doctest: +NORMALIZE_WHITESPACE
<script language="javascript">
jQuery(document).ready(function () {
jQuery.jGrowl("my info", {"header": "Info", "theme": "ui-state-info", "life": 2000});
jQuery.jGrowl("my warn", {"header": "Warning", "theme": "ui-state-warning", "life": 3000});
});
</script>
You can also render messages inline:
>>> print f.render_inline() #doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
<div class="jGrowl" style="position:relative;">
<div id="message_..." style="width:auto;display:none;" class="jGrowl-notification ui-state-highlight ui-corner-all ui-state-info">
<div class="header">Info</div>
my info
</div>
<div id="message_..." style="width:auto;display:none;" class="jGrowl-notification ui-state-highlight ui-corner-all ui-state-warning">
<div class="header">Warning</div>
my warn
</div>
<script language="javascript">
jQuery(document).ready(function () {
jQuery("#message_...").slideDown('slow', function() {
var self = $(this);setTimeout(function() { self.slideUp('slow', function(){self.remove();}); }, 20...);
});
jQuery("#message_...").slideDown('slow', function() {
var self = $(this);setTimeout(function() { self.slideUp('slow', function(){self.remove();}); }, 30...);
});
});
</script>
</div>
return a path to script. you can change the root_url. default to /jquery:
>>> url.root_url = '/path_to_static'
>>> print url('/absolute.js')
/absolute.js
>>> print url('relative', 'plugin.js')
/path_to_static/relative/plugin.js
>>> print url('..', 'plugin.js')
/path_to_static/../plugin.js
>>> print url('plugin.js', prefix='/my_js')
/my_js/plugin.js