Hi Massimo,
I just noticed that my second patch is derived from an old revision of
web2py skeleton app. It might not be directly patched the latest
trunk.
Anyway, this is what it tries to solve, and you can digest it and do
it again in the latest trunk.
1. Wrap all those "{{=MENU(...)}} <script type="text/javascript">...
jQuery('ul.sf-menu')....superfish(); ... </script>" inside the {{if
response.menu:}}...{{pass}} too
2. Add a long-lost parameter as: {{=MENU(..., li_active='current')}}
3. and then add a css snippet to make active menu distinguishing:
<style>li.current {background:white; /* #BDD2FF; */}</style>
Regards,
Ray
On Dec 27, 1:29 am, "Ray (a.k.a. Iceberg)" <[email protected]> wrote:
> My fault. There should be one more modification.
>
> diff -r 04673c0ce6ab views/layout.html
> --- a/views/layout.html Tue Dec 27 01:29:01 2011 +0800
> +++ b/views/layout.html Tue Dec 27 01:29:17 2011 +0800
> @@ -39,8 +39,10 @@
>
> {{#------ require CSS and JS files for this page (read info in
> base.css) ------}}
> {{response.files.append(URL('static','css/base.css'))}}
> - {{response.files.append(URL('static','css/superfish.css'))}}
> - {{response.files.append(URL('static','js/superfish.js'))}}
> + {{if response.menu:}}
> + {{response.files.append(URL('static','css/superfish.css'))}}
> + {{response.files.append(URL('static','js/superfish.js'))}}
> + {{pass}}
> {{#------ include web2py specific js code (jquery, calendar, form
> stuff) ------}}
> {{include 'web2py_ajax.html'}}
>
> @@ -88,13 +90,14 @@
>
> <div id="statusbar"><!-- statusbar is menu zone -->
> {{block statusbar}} <!-- this is default statusbar -->
> - {{#------ superfish menu ------}}
> - <style>li.current {background:white; /* #BDD2FF; */}</style>
> - {{=MENU(response.menu,_class='sf-menu',li_active='current')}}
> - <script type="text/javascript">
> - jQuery(document).ready(function(){
> - jQuery('ul.sf-menu').superfish();});
> - </script>
> + {{if response.menu:}}{{#------ superfish menu ------}}
> + <style>li.current {background:white; /* #BDD2FF; */}</
> style>
> + {{=MENU(response.menu,_class='sf-
> menu',li_active='current')}}
> + <script type="text/javascript">
> + jQuery(document).ready(function(){
> + jQuery('ul.sf-menu').superfish();});
> + </script>
> + {{pass}}
> <div style="clear: both;"></div><!-- Clear the divs -->
> {{end}}
> </div><!-- statusbar -->
>
> On Dec 27, 12:31 am, Massimo Di Pierro <[email protected]>
> wrote:
>
>
>
>
>
>
>
> > good idea. In trunk!
>
> > On Dec 26, 9:32 am, "Ray (a.k.a. Iceberg)" <[email protected]> wrote:
>
> > > Hey folks,
>
> > > I just use this little trick in my app, to reduce two unnecessary http
> > > requests when menus are not needed.
>
> > > I think the optimization is reasonable. And people can always manually
> > > re-enable superfish by response.files.extend([...]). So, my proposal
> > > is to put this into the default welcome (scaffold) app. Shall we?
>
> > > diff -r 483ebd275b49 views/layout.html
> > > --- a/views/layout.html Mon Dec 26 23:19:42 2011 +0800
> > > +++ b/views/layout.html Mon Dec 26 23:26:26 2011 +0800
> > > @@ -39,8 +39,10 @@
>
> > > {{#------ require CSS and JS files for this page (read info in
> > > base.css) ------}}
> > > {{response.files.append(URL('static','css/base.css'))}}
> > > - {{response.files.append(URL('static','css/superfish.css'))}}
> > > - {{response.files.append(URL('static','js/superfish.js'))}}
> > > + {{if response.menu:}}
> > > + {{response.files.append(URL('static','css/superfish.css'))}}
> > > + {{response.files.append(URL('static','js/superfish.js'))}}
> > > + {{pass}}
> > > {{#------ include web2py specific js code (jquery, calendar, form
> > > stuff) ------}}
> > > {{include 'web2py_ajax.html'}}