The built-in flash mechanism involves the following:

   1. Setting response.flash in the server-side code.
   2. Insertion of {{=response.flash}} somewhere in the view.
   3. Embedding {{=response.flash}} in a div with class "flash".
   4. CSS rules defining how the "flash" class is displayed (defaults set 
   in web2py.css and overridden in web2py_bootstrap3.css).
   5. Javascript code in web2py.js determining the behavior of any div with 
   a "flash" class.

If you simply want to change the display, you can add CSS rules that 
override those in web2py.css and/or web2py_bootstrap3.css (or edit those 
files). If you want to change the behavior, then you'll have to write some 
Javascript code, being mindful that it must work in conjunction with the 
code already in web2py.js.


If you need something more customized, then just be sure *not* to wrap 
{{=response.flash}} in a div with class "flash", as all the built-in CSS 
and Javascript code affects only divs with class "flash". Then you can 
implement your own styling and behavior.


Note, use of response.flash itself is not mandatory (you can pass a flash 
message to the view using any custom variable or response attribute you 
like), but it does provide some convenience as (a) during Ajax requests, 
response.flash will automatically get copied to a special custom HTTP 
header which can be read on the client, and (b) response.flash will get 
transferred to and from session.flash upon redirects.


Anthony


On Monday, July 11, 2016 at 10:45:15 AM UTC-4, rajjmatt...@gmail.com wrote:
>
> On that note, how do we customize the flash? For example, lets say we want 
> a much larger and brighter flash with css rule (brighter color), or have to 
> display as soon as user log in on the center of the screen as an 
> advertisement?
>
> On Monday, July 11, 2016 at 4:49:08 AM UTC-4, Massimiliano wrote:
>>
>> Hi Jim, 
>> I’m doing it in this way:
>>
>> Edit static/web2py.js search for /*helper for flash messages*/
>>
>> and add this command:
>>
>> setTimeout(‘jQuery(".flash").fadeOut("slow")',5000);
>>
>> just after:
>>
>> if (flash.html()) flash.append('<span id="closeflash"> &times; 
>> </span>').slideDown();
>>
>> Adjust 5000 that stands for 5 secods to your needs.
>>
>>
>> On Thu, Jul 7, 2016 at 6:00 PM, Jim Brouzoulis <jim.bro...@chalmers.se> 
>> wrote:
>>
>>> Hi everyone,
>>>
>>> Can I easily customise the web2py.js file to automatically hide/fade out 
>>> the flash message after some given time (like a few seconds) instead of 
>>> clicking on it? If so, how? 
>>> I have a feeling that the solution is probably not that complicated but 
>>> my js-skills aren't very impressive :)
>>>
>>> Regards
>>> // Jim
>>>
>>> -- 
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to web2py+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>> Massimiliano
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to