For now this is in trunk. Your implementation looks good.

For me the problem whether we want to do this or not. Most of the 
conventions implemented in web2py core are web2py own conventions or 
standard protocol.  Bootstrap is a css library. very popular today but will 
disappear tomorrow as a better one comes out. Now everybody will use it. Is 
it a good idea to include code which is designed exclusively for bootstap 
conventions and specifically refers to bootstrap css classes? Or is it 
better to handle it from the layout only using js?

So we need to think about this some more. I cannot promise this will stay 
in web2py 2.0 in this form.

Massimo



On Saturday, 26 May 2012 08:53:53 UTC-5, Paolo Caruccio wrote:
>
> Here attached the html.py with modified class MENU.
> This is only a draft not deeply tested. 
>
> Il giorno sabato 26 maggio 2012 03:40:26 UTC+2, Massimo Di Pierro ha 
> scritto:
>>
>> We can include this in MENU and eliminate the JS. What do you think?
>>
>> On Friday, 25 May 2012 15:52:50 UTC-5, Niphlod wrote:
>>>
>>> I may be a little late....I implemented it for my app but never used 
>>> because my menu has only 4 items :-P
>>> include bootstrap.css and add to css this (took from 
>>> https://github.com/twitter/bootstrap/issues/424)
>>>
>>> .nav li.dropdown ul.dropdown-menu li:HOVER ul {
>>>         display:block;
>>>         position:absolute;
>>>         left:100%;
>>>         -webkit-border-radius: 3px;
>>>         -moz-border-radius: 3px;
>>>         border-radius: 3px;
>>>     }
>>>     .nav li.dropdown ul.dropdown-menu ul {
>>>         display: none;
>>>         float:right;
>>>         position: relative;
>>>         top: auto;
>>>         margin-top: -30px;
>>>     }
>>>
>>>     .nav li.dropdown ul.dropdown-menu .dropdown-menu::before {
>>>         content: '';
>>>         display: inline-block;
>>>         border-top: 7px solid transparent;
>>>         border-bottom: 7px solid transparent;
>>>         border-right:7px solid #CCC;
>>>         border-right-color: rgba(0, 0, 0, 0.2);
>>>         position: absolute;
>>>         top: 9px;
>>>         left: -14px;
>>>     }
>>>
>>>     .nav li.dropdown ul.dropdown-menu .dropdown-menu::after {
>>>         content: '';
>>>         display: inline-block;
>>>         border-top: 6px solid transparent;
>>>         border-bottom: 6px solid transparent;
>>>         border-right:6px solid white;
>>>         position: absolute;
>>>         top: 10px;
>>>         left: -12px;
>>>     }
>>>
>>>
>>> def twitter_menu(menu, level=0):
>>>     """
>>>     Generates twitter bootstrap's compliant menu
>>>     """
>>>     lis = []
>>>     for li in menu:
>>>         (text, active, href) = li[:3]
>>>         sub =  len(li) > 3 and li[3] or []
>>>         if len(sub) == 0:
>>>             li_class = None
>>>             el = LI(A(text, _href=href), _class=li_class)
>>>         else:
>>>             li_class = 'dropdown'
>>>             caret = level == 0 and B(_class='caret') or 
>>> I(_class='icon-chevron-right')
>>>             sub_ul = twitter_menu(sub, level=level+1)
>>>             el = LI(A(text, caret, _href=href, _class="dropdown-toggle", 
>>> **{'_data-toggle' : 'dropdown'}), sub_ul, _class=li_class)
>>>         lis.append(el)
>>>
>>>     if level == 0:
>>>         return UL(*lis, _class='nav')
>>>     else:
>>>         return UL(*lis, _class="dropdown-menu")
>>>
>>>

Reply via email to