element_input_image.erl 2.5 KB

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