element_input_button.erl 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. -module(element_input_button).
  2. -author('Vladimir Galunshchikov').
  3. -include_lib("nitro/include/nitro.hrl").
  4. -include_lib("nitro/include/event.hrl").
  5. -compile(export_all).
  6. render_element(Record) ->
  7. Id = case Record#input_button.postback of
  8. [] -> Record#input_button.id;
  9. Postback ->
  10. ID = case Record#input_button.id of
  11. [] -> nitro:temp_id();
  12. I -> I end,
  13. nitro:wire(#event{type=click, postback=Postback, target=ID,
  14. source=Record#input_button.source, delegate=Record#input_button.delegate }),
  15. ID end,
  16. List = [
  17. %global
  18. {<<"accesskey">>, Record#input_button.accesskey},
  19. {<<"class">>, Record#input_button.class},
  20. {<<"contenteditable">>, case Record#input_button.contenteditable of true -> "true"; false -> "false"; _ -> [] end},
  21. {<<"contextmenu">>, Record#input_button.contextmenu},
  22. {<<"dir">>, case Record#input_button.dir of "ltr" -> "ltr"; "rtl" -> "rtl"; "auto" -> "auto"; _ -> [] end},
  23. {<<"draggable">>, case Record#input_button.draggable of true -> "true"; false -> "false"; _ -> [] end},
  24. {<<"dropzone">>, Record#input_button.dropzone},
  25. {<<"hidden">>, case Record#input_button.hidden of "hidden" -> "hidden"; _ -> [] end},
  26. {<<"id">>, Id},
  27. {<<"lang">>, Record#input_button.lang},
  28. {<<"spellcheck">>, case Record#input_button.spellcheck of true -> "true"; false -> "false"; _ -> [] end},
  29. {<<"style">>, Record#input_button.style},
  30. {<<"tabindex">>, Record#input_button.tabindex},
  31. {<<"title">>, Record#input_button.title},
  32. {<<"translate">>, case Record#input_button.contenteditable of "yes" -> "yes"; "no" -> "no"; _ -> [] end},
  33. % spec
  34. {<<"autofocus">>,Record#input_button.autofocus},
  35. {<<"disabled">>, if Record#input_button.disabled == true -> "disabled"; true -> [] end},
  36. {<<"name">>,Record#input_button.name},
  37. {<<"type">>, <<"button">>},
  38. {<<"value">>, Record#input_button.value} | Record#input_button.data_fields
  39. ],
  40. wf_tags:emit_tag(<<"input">>, nitro:render(Record#input_button.body), List).