MobileBlur

menu.py at [eba4a35a21]
Login

menu.py at [eba4a35a21]

File applications/examples/models/menu.py artifact e8143d44af part of check-in eba4a35a21


# -*- coding: utf-8 -*-

#########################################################################
## Changes the menu active item
#########################################################################
def toggle_menuclass(cssclass='pressed',menuid='headermenu'):
    """This function changes the menu class to put pressed appearance"""

    positions = dict(
                           index='',
                           what='-108px -115px',
                           download='-211px -115px',
                           who='-315px -115px',
                           support='-418px -115px',
                           documentation='-520px -115px'
                           )


    if request.function in positions.keys():
            jscript = """
            <script>
             $(document).ready(function(){
                         $('.%(menuid)s a').removeClass('%(cssclass)s');
                         $('.%(function)s').toggleClass('%(cssclass)s').css('background-position','%(cssposition)s')

             });
            </script>
            """ % dict(cssclass=cssclass,
                            menuid=menuid,
                            function=request.function,
                            cssposition=positions[request.function]
                            )

            return XML(jscript)
    else:
        return ''