Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 7cadf62045
Fetching contributors…

Cannot retrieve contributors at this time

executable file 27 lines (22 sloc) 0.825 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
-module (element_menu).
-compile(export_all).

-include("nitrogen_elements.hrl").
%-record(menu, {?ELEMENT_BASE(element_menu), text="", body=[]}).

% desc: Provides a collapsable menu. The menu options are specified
% as listitem elements in the body.

reflect() -> record_info(fields, menu).

render(ControlID, Record) ->
Script = wf:f("$('#~s ul').hide();~n$('#~s li a').click(~nfunction() {~n$(this).next().slideToggle('normal');~n}~n);", [ControlID, ControlID]),
wf:wire(Script),
    Title = wf:render(Record#menu.text),
Content = wf:render(Record#menu.body),
wf_tags:emit_tag(ul,
        wf_tags:emit_tag(li,
        Title++wf_tags:emit_tag(ul, Content, []),
        []),
        [
            {id, ControlID},
            {class, Record#menu.class},
            {style, Record#menu.style}
        ]
    ).
    
Something went wrong with that request. Please try again.