element_input_time.erl 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. -module(element_input_time).
  2. %%-author('Vladimir Galunshchikov').
  3. -include_lib("nitro/include/nitro.hrl").
  4. -export([
  5. render_element/1
  6. ]).
  7. render_element(Record) ->
  8. Id = case Record#input_time.postback of
  9. undefined -> Record#input_time.id;
  10. Postback ->
  11. ID0 = case Record#input_time.id of
  12. undefined -> nitro:temp_id();
  13. I -> I
  14. end,
  15. nitro:wire( #event{type = click, postback = Postback, target = ID0,
  16. source = Record#input_time.source, delegate = Record#input_time.delegate} ),
  17. ID0
  18. end,
  19. List = [
  20. %% global
  21. {<<"accesskey">>, Record#input_time.accesskey},
  22. {<<"class">>, Record#input_time.class},
  23. {<<"contenteditable">>,
  24. case Record#input_time.contenteditable of
  25. true -> "true";
  26. false -> "false";
  27. _ -> undefined
  28. end},
  29. {<<"contextmenu">>, Record#input_time.contextmenu},
  30. {<<"dir">>,
  31. case Record#input_time.dir of
  32. "ltr" -> "ltr";
  33. "rtl" -> "rtl";
  34. "auto" -> "auto";
  35. _ -> undefined
  36. end},
  37. {<<"draggable">>,
  38. case Record#input_time.draggable of
  39. true -> "true";
  40. false -> "false";
  41. _ -> undefined
  42. end},
  43. {<<"dropzone">>, Record#input_time.dropzone},
  44. {<<"hidden">>,
  45. case Record#input_time.hidden of
  46. "hidden" -> "hidden";
  47. _ -> undefined
  48. end},
  49. {<<"id">>, Id},
  50. {<<"lang">>, Record#input_time.lang},
  51. {<<"spellcheck">>,
  52. case Record#input_time.spellcheck of
  53. true -> "true";
  54. false -> "false";
  55. _ -> undefined
  56. end},
  57. {<<"style">>, Record#input_time.style},
  58. {<<"tabindex">>, Record#input_time.tabindex},
  59. {<<"title">>, Record#input_time.title},
  60. {<<"translate">>,
  61. case Record#input_time.contenteditable of
  62. "yes" -> "yes";
  63. "no" -> "no";
  64. _ -> undefined
  65. end},
  66. %% spec
  67. {<<"autocomplete">>,
  68. case Record#input_time.autocomplete of
  69. true -> "on";
  70. false -> "off";
  71. _ -> undefined
  72. end},
  73. {<<"autofocus">>,
  74. case Record#input_time.autofocus of
  75. true -> "autofocus";
  76. _ -> undefined
  77. end},
  78. {<<"disabled">>,
  79. case Record#input_time.disabled of
  80. true -> "disabled";
  81. _ -> undefined
  82. end},
  83. {<<"form">>, Record#input_time.form},
  84. {<<"list">>, Record#input_time.list},
  85. {<<"max">>, Record#input_time.max},
  86. {<<"min">>, Record#input_time.min},
  87. {<<"name">>, Record#input_time.name},
  88. {<<"readonly">>,
  89. case Record#input_time.readonly of
  90. true -> "readonly";
  91. _ -> undefined
  92. end},
  93. {<<"required">>,
  94. case Record#input_time.required of
  95. true -> "required";
  96. _ -> undefined
  97. end},
  98. {<<"step">>, Record#input_time.step},
  99. {<<"type">>, <<"time">>},
  100. {<<"value">>, Record#input_time.value} | Record#input_time.data_fields
  101. ],
  102. wf_tags:emit_tag(<<"input">>, nitro:render(Record#input_time.body), List).