forked from nitrogen/nitrogen
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: include/wf.inc www/nitrogen.js
- Loading branch information
Showing
28 changed files
with
210 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
-module (web_samples_radio). | ||
-include ("wf.inc"). | ||
-include ("google_chart.inc"). | ||
-compile(export_all). | ||
|
||
main() -> #template { file="./wwwroot/onecolumn.html", bindings=[ | ||
{'Group', learn}, | ||
{'Item', samples} | ||
]}. | ||
|
||
title() -> "Radio Button Example". | ||
headline() -> "Radio Button Example". | ||
right() -> linecount:render(). | ||
|
||
body() -> [ | ||
|
||
#p{}, | ||
#label { text="Radio Buttons" }, | ||
#radiogroup { id=myRadio, body=[ | ||
#radio { id=myRadio1, text="Option 1", value="1", postback={checked, 1}, checked=true }, #p{}, | ||
#radio { id=myRadio2, text="Option 2", value="2", postback={checked, 2} }, #p{}, | ||
#radio { id=myRadio3, text="Option 3", value="3", postback={checked, 3} }, #p{}, | ||
#radio { id=myRadio4, text="Option 4", value="4", postback={checked, 4} } | ||
]}, | ||
#p{}, | ||
#button { text="Postback", postback=clicked_button } | ||
]. | ||
|
||
event({checked, Number}) -> | ||
wf:flash(wf:f("You selected radio button ~p.", [Number])), | ||
ok; | ||
|
||
event(clicked_button) -> | ||
|
||
wf:flash("Radio button " ++ wf:q(myRadio) ++ " is selected."), | ||
wf:flash("Is radio button 1 selected: " ++ wf:q(myRadio1)), | ||
ok; | ||
|
||
event(_) -> ok. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ compile: | |
erl -make | ||
|
||
clean: | ||
rm -rf ./ebin/*.beam | ||
rm -rf ./ebin/*.beam |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
% Nitrogen Web Framework for Erlang | ||
% Copyright (c) 2008-2009 Rusty Klophaus | ||
% See MIT-LICENSE for licensing information. | ||
|
||
-module (element_radio). | ||
-include ("wf.inc"). | ||
-compile(export_all). | ||
|
||
reflect() -> record_info(fields, radio). | ||
|
||
render(ControlID, Record) -> | ||
CheckedOrNot = case Record#radio.checked of | ||
true -> checked; | ||
_ -> not_checked | ||
end, | ||
|
||
case Record#radio.postback of | ||
undefined -> ok; | ||
Postback -> wf:wire(ControlID, #event { type=change, postback=Postback }) | ||
end, | ||
|
||
Content = wf:html_encode(Record#radio.text, Record#radio.html_encode), | ||
|
||
[ | ||
%% Checkbox... | ||
wf_tags:emit_tag(input, [ | ||
{id, ControlID}, | ||
{name, Record#radio.name}, | ||
{value, Record#radio.value}, | ||
{type, radio}, | ||
{class, [radio, Record#radio.class]}, | ||
{style, Record#radio.style}, | ||
{CheckedOrNot, true} | ||
]), | ||
|
||
%% Label for Radio... | ||
wf_tags:emit_tag(label, Content, [ | ||
{for, ControlID} | ||
]) | ||
]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
% Nitrogen Web Framework for Erlang | ||
% Copyright (c) 2008-2009 Rusty Klophaus | ||
% See MIT-LICENSE for licensing information. | ||
|
||
-module (element_radiogroup). | ||
-include ("wf.inc"). | ||
-compile(export_all). | ||
|
||
reflect() -> record_info(fields, radiogroup). | ||
|
||
render(ControlID, Record) -> | ||
% Set the group to the current ControlID... | ||
|
||
F = fun(X) -> | ||
case is_record(X, radio) of | ||
true -> X#radio { name=ControlID }; | ||
false -> X | ||
end | ||
end, | ||
Body = [F(X) || X <- Record#radiogroup.body], | ||
|
||
% Render the record... | ||
element_panel:render(ControlID, #panel { | ||
class="radiogroup " ++ wf:to_list(Record#radiogroup.class), | ||
style=Record#radiogroup.style, | ||
body=Body | ||
}). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.