blob: 7909c3e20d6aa9fea009822468ebbfa8e4c41e7e [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001[# Make a 3x8 grid of label entry form fields with autocomplete on each one.
2
3 Args:
4 arg0: if "just-two" is passed, only show the first two rows
5 and give the user links to click to expose more rows.
6 arg1: the ID prefix for the row divs.
7]
8
9<div id="[arg1]LF_row1" class="nowrap">
10 <input aria-label="label 1" type="text" class="labelinput" id="[arg1]label0" size="20" autocomplete="off"
11 name="label" value="[label0]">
12 <input aria-label="label 2" type="text" class="labelinput" id="[arg1]label1" size="20" autocomplete="off"
13 name="label" value="[label1]">
14 <input aria-label="label 3" type="text" class="labelinput" id="[arg1]label2" size="20" autocomplete="off"
15 name="label" value="[label2]">
16</div>
17
18<div id="[arg1]LF_row2" class="nowrap">
19 <input aria-label="label 4" type="text" class="labelinput" id="[arg1]label3" size="20" autocomplete="off"
20 name="label" value="[label3]">
21 <input aria-label="label 5" type="text" class="labelinput" id="[arg1]label4" size="20" autocomplete="off"
22 name="label" value="[label4]">
23 <input aria-label="label 6" type="text" class="labelinput" id="[arg1]label5" size="20" autocomplete="off"
24 [is arg0 "just-two"]data-show-id="LF_row3" data-hide-id="addrow2"[end]
25 name="label" value="[label5]">
26 [is arg0 "just-two"]<span id="addrow2" class="fakelink" data-instead="LF_row3">Add a row</span>[end]
27</div>
28
29<div id="[arg1]LF_row3" [is arg0 "just-two"]style="display:none"[end] class="nowrap">
30 <input aria-label="label 7" type="text" class="labelinput" id="[arg1]label6" size="20" autocomplete="off"
31 name="label" value="[label6]">
32 <input aria-label="label 8" type="text" class="labelinput" id="[arg1]label7" size="20" autocomplete="off"
33 name="label" value="[label7]">
34 <input aria-label="label 9" type="text" class="labelinput" id="[arg1]label8" size="20" autocomplete="off"
35 [is arg0 "just-two"]data-show-id="LF_row4" data-hide-id="addrow3"[end]
36 name="label" value="[label8]">
37 [is arg0 "just-two"]<span id="addrow3" class="fakelink" data-instead="LF_row4">Add a row</span>[end]
38</div>
39
40<div id="[arg1]LF_row4" [is arg0 "just-two"]style="display:none"[end] class="nowrap">
41 <input aria-label="label 10" type="text" class="labelinput" id="[arg1]label9" size="20" autocomplete="off"
42 name="label" value="[label9]">
43 <input aria-label="label 11" type="text" class="labelinput" id="[arg1]label10" size="20" autocomplete="off"
44 name="label" value="[label10]">
45 <input aria-label="label 12" type="text" class="labelinput" id="[arg1]label11" size="20" autocomplete="off"
46 [is arg0 "just-two"]data-show-id="LF_row5" data-hide-id="addrow4"[end]
47 name="label" value="[label11]">
48 [is arg0 "just-two"]<span id="addrow4" class="fakelink" data-instead="LF_row5">Add a row</span>[end]
49</div>
50
51<div id="[arg1]LF_row5" [is arg0 "just-two"]style="display:none"[end] class="nowrap">
52 <input aria-label="label 13" type="text" class="labelinput" id="[arg1]label12" size="20" autocomplete="off"
53 name="label" value="[label12]">
54 <input aria-label="label 14" type="text" class="labelinput" id="[arg1]label13" size="20" autocomplete="off"
55 name="label" value="[label13]">
56 <input aria-label="label 15" type="text" class="labelinput" id="[arg1]label14" size="20" autocomplete="off"
57 [is arg0 "just-two"]data-show-id="LF_row6" data-hide-id="addrow5"[end]
58 name="label" value="[label14]">
59 [is arg0 "just-two"]<span id="addrow5" class="fakelink" data-instead="LF_row6">Add a row</span>[end]
60</div>
61
62<div id="[arg1]LF_row6" [is arg0 "just-two"]style="display:none"[end] class="nowrap">
63 <input aria-label="label 16" type="text" class="labelinput" id="[arg1]label15" size="20" autocomplete="off"
64 name="label" value="[label15]">
65 <input aria-label="label 17" type="text" class="labelinput" id="[arg1]label16" size="20" autocomplete="off"
66 name="label" value="[label16]">
67 <input aria-label="label 18" type="text" class="labelinput" id="[arg1]label17" size="20" autocomplete="off"
68 [is arg0 "just-two"]data-show-id="LF_row7" data-hide-id="addrow6"[end]
69 name="label" value="[label17]">
70 [is arg0 "just-two"]<span id="addrow6" class="fakelink" data-instead="LF_row7">Add a row</span>[end]
71</div>
72
73<div id="[arg1]LF_row7" [is arg0 "just-two"]style="display:none"[end] class="nowrap">
74 <input aria-label="label 19" type="text" class="labelinput" id="[arg1]label18" size="20" autocomplete="off"
75 name="label" value="[label18]">
76 <input aria-label="label 20" type="text" class="labelinput" id="[arg1]label19" size="20" autocomplete="off"
77 name="label" value="[label19]">
78 <input aria-label="label 21" type="text" class="labelinput" id="[arg1]label20" size="20" autocomplete="off"
79 [is arg0 "just-two"]data-show-id="LF_row8" data-hide-id="addrow7"[end]
80 name="label" value="[label20]">
81 [is arg0 "just-two"]<span id="addrow7" class="fakelink" data-instead="LF_row8">Add a row</span>[end]
82</div>
83
84<div id="[arg1]LF_row8" [is arg0 "just-two"]style="display:none"[end] class="nowrap">
85 <input aria-label="label 22" type="text" class="labelinput" id="[arg1]label21" size="20" autocomplete="off"
86 name="label" value="[label21]">
87 <input aria-label="label 23" type="text" class="labelinput" id="[arg1]label22" size="20" autocomplete="off"
88 name="label" value="[label22]">
89 <input aria-label="label 24" type="text" class="labelinput" id="[arg1]label23" size="20" autocomplete="off"
90 name="label" value="[label23]">
91</div>
92
93<script type="text/javascript" nonce="[nonce]">
94runOnLoad(function() {
95 var labelInputs = document.getElementsByClassName("labelinput");
96 for (var i = 0; i < labelInputs.length; ++i) {
97 var labelInput = labelInputs[[]i];
98 if (labelInput.getAttribute("id").startsWith("hidden")) continue;
99 labelInput.addEventListener("keyup", function (event) {
100 if (event.target.getAttribute("data-show-id") &&
101 event.target.getAttribute("data-hide-id") &&
102 event.target.value) {
103 _showID(event.target.getAttribute("data-show-id"));
104 _hideID(event.target.getAttribute("data-hide-id"));
105 }
106 return _vallab(event.target);
107 });
108 labelInput.addEventListener("blur", function (event) {
109 _acrob(null);
110 return _vallab(event.target);
111 });
112 labelInput.addEventListener("focus", function (event) {
113 return _acof(event);
114 });
115 }
116
117 var addRowLinks = document.getElementsByClassName("fakelink");
118 for (var i = 0; i < addRowLinks.length; ++i) {
119 var rowLink = addRowLinks[[]i];
120 rowLink.addEventListener("click", function (event) {
121 _acrob(null);
122 var insteadID = event.target.getAttribute("data-instead");
123 if (insteadID)
124 _showInstead(insteadID, this);
125 });
126 }
127});
128</script>