123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- -module(element_input).
- %%-author('Maxim Sokhatsky').
- -include_lib("nitro/include/nitro.hrl").
- -compile([export_all, nowarn_export_all]).
- render_element(Record) ->
- Id = case Record#input.postback of
- undefined -> Record#input.id;
- [] -> Record#input.id;
- Postback ->
- ID0 = case Record#input.id of
- undefined -> nitro:temp_id();
- I -> I
- end,
- nitro:wire( #event{type = click, postback = Postback, target = ID0,
- source = Record#input.source, delegate = Record#input.delegate} ),
- ID0
- end,
- List = [
- %% global
- {<<"accesskey">>, Record#input.accesskey},
- {<<"class">>, Record#input.class},
- {<<"contenteditable">>,
- case Record#input.contenteditable of
- true -> "true";
- false -> "false";
- _ -> undefined
- end},
-
- {<<"contextmenu">>, Record#input.contextmenu},
- {<<"dir">>,
- case Record#input.dir of
- "ltr" -> "ltr";
- "rtl" -> "rtl";
- "auto" -> "auto";
- _ -> undefined
- end},
-
- {<<"draggable">>,
- case Record#input.draggable of
- true -> "true";
- false -> "false";
- _ -> undefined
- end},
-
- {<<"dropzone">>, Record#input.dropzone},
- {<<"hidden">>,
- case Record#input.hidden of
- "hidden" -> "hidden";
- _ -> undefined
- end},
-
- {<<"id">>, Id},
- {<<"lang">>, Record#input.lang},
- {<<"spellcheck">>,
- case Record#input.spellcheck of
- true -> "true";
- false -> "false";
- _ -> undefined
- end},
-
- {<<"style">>, Record#input.style},
- {<<"tabindex">>, Record#input.tabindex},
- {<<"title">>, Record#input.title},
- {<<"translate">>,
- case Record#input.contenteditable of
- "yes" -> "yes";
- "no" -> "no";
- _ -> undefined
- end},
-
- %% spec
- {<<"autofocus">>, Record#input.autofocus},
- {<<"disabled">>,
- case Record#input.disabled of
- true -> "disabled";
- _ -> undefined
- end},
-
- {<<"name">>, Record#input.name},
- {<<"type">>, Record#input.type},
- {<<"accept">>, Record#input.accept},
- {<<"max">>, Record#input.max},
- {<<"placeholder">>, Record#input.placeholder},
- {<<"min">>, Record#input.min},
- {<<"multiple">>, Record#input.multiple},
- {<<"pattern">>, Record#input.pattern},
- {<<"value">>, Record#input.value},
- {<<"onkeypress">>, Record#input.onkeypress},
- {<<"onkeyup">>, Record#input.onkeyup},
- {<<"onkeydown">>, Record#input.onkeydown},
- {<<"onclick">>, Record#input.onclick},
- {<<"onchange">>, Record#input.onchange} | Record#input.data_fields
- ],
-
- wf_tags:emit_tag(<<"input">>, nitro:render(Record#input.body), List).
|