Commit 22ebfe90b5d1a52f55093f0c33a083041ca0f0e7
1 parent
7477bd75
Man kann jetzt eine Alternative aus der Liste aller Alternativen auswaehlen
Showing
5 changed files
with
170 additions
and
21 deletions
1 | 1 | /* ======================================================================= |
2 | 2 | * Styles for components |
3 | 3 | * ======================================================================= */ |
4 | -.bgc-bg1 { background-color: #888888 } | |
4 | +.bgc-bg1 { background-color: #888888 } | |
5 | 5 | /* ======================================================================= */ |
6 | 6 | |
7 | 7 | /* ======================================================================= |
8 | 8 | * Styles for logical groups. A group is defined by a bounding box "grp*" |
9 | 9 | * containing one or more header lines "head*" and content-boxes "box*" |
10 | 10 | * ======================================================================= */ |
11 | -.bgc-grp1 { background-color: #aaaaaa } | |
12 | -.bgc-box1 { background-color: #ffb400 } | |
13 | -.bgc-grp-head1 { background-color: #e5a200 } | |
14 | -.bgc-box-head1 { background-color: #ffc434 } | |
11 | +.bgc-grp1 { background-color: #aaaaaa } | |
12 | +.bgc-box1 { background-color: #ffb400 } | |
13 | +.bgc-grp-head1 { background-color: #e5a200 } | |
14 | +.bgc-box-head1 { background-color: #ffc434 } | |
15 | 15 | /* ======================================================================= */ |
16 | 16 | |
17 | 17 | /* ======================================================================= |
18 | 18 | * Styles for tooltips |
19 | 19 | * ======================================================================= */ |
20 | -.bgc-tt1 { background-color: #eeeeee } | |
20 | +.bgc-tt1 { background-color: #eeeeee } | |
21 | +.bgc-tt1-selItem { background-color: #ffc434 } | |
21 | 22 | /* ======================================================================= */ | ... | ... |
... | ... | @@ -46,6 +46,37 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) |
46 | 46 | this.sNameBest = new Array (-1, -1, null); |
47 | 47 | this.fNameBest = new Array (-1, -1, null); |
48 | 48 | |
49 | + this.snameIdx = -1; | |
50 | + this.fnameIdx = -1; | |
51 | + this.snameMaxIdx = -1; | |
52 | + this.fnameMaxIdx = -1; | |
53 | + this.snameDists = new Array (); | |
54 | + this.fnameDists = new Array (); | |
55 | + | |
56 | + this.incSnameIdx = function () | |
57 | + { | |
58 | + if (this.snameIdx < this.snameMaxIdx-1) | |
59 | + this.snameIdx ++; | |
60 | + } | |
61 | + | |
62 | + this.incFnameIdx = function () | |
63 | + { | |
64 | + if (this.fnameIdx < this.fnameMaxIdx-1) | |
65 | + this.fnameIdx ++; | |
66 | + } | |
67 | + | |
68 | + this.decSnameIdx = function () | |
69 | + { | |
70 | + if (this.snameIdx >= 0) | |
71 | + this.snameIdx --; | |
72 | + } | |
73 | + | |
74 | + this.decFnameIdx = function () | |
75 | + { | |
76 | + if (this.fnameIdx >= 0) | |
77 | + this.fnameIdx --; | |
78 | + } | |
79 | + | |
49 | 80 | this.show = function (id) |
50 | 81 | { |
51 | 82 | var node = document.getElementById (id); |
... | ... | @@ -56,9 +87,42 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) |
56 | 87 | |
57 | 88 | this.hide = function (id) |
58 | 89 | { |
59 | - var node = document.getElementById (id); | |
90 | + var node = document.getElementById (id); | |
91 | + var inField = | |
92 | + node.parentNode.parentNode.getElementsByTagName ('input')[0]; | |
93 | + var idx = -1; | |
94 | + var dists = new Array (); | |
95 | + | |
60 | 96 | node.parentNode.style.visibility = 'hidden'; |
61 | 97 | |
98 | + switch (inField.getAttribute ('id')) | |
99 | + { | |
100 | + case 'personSearch1_fname': | |
101 | + idx = this.fnameIdx; | |
102 | + if (idx != -1) | |
103 | + { | |
104 | + dists = this.fnameDists[idx].split ('::'); | |
105 | + this.fNameBest = new Array (0, 0, dists[2]); | |
106 | + inField.value = dists[2]; | |
107 | + } | |
108 | + break; | |
109 | + case 'personSearch1_sname': | |
110 | + idx = this.snameIdx; | |
111 | + if (idx != -1) | |
112 | + { | |
113 | + dists = this.snameDists[idx].split ('::'); | |
114 | + this.sNameBest = new Array (0, 0, dists[2]); | |
115 | + inField.value = dists[2]; | |
116 | + } | |
117 | + } | |
118 | + | |
119 | + if (this.person != null) | |
120 | + if (this.fNameBest[1] == 0) | |
121 | + this.person.update ( | |
122 | + this.persons[this.sNameBest[2]][this.fNameBest[2]]); | |
123 | + else | |
124 | + this.person.empty (); | |
125 | + | |
62 | 126 | return false; |
63 | 127 | } |
64 | 128 | |
... | ... | @@ -73,7 +137,7 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) |
73 | 137 | return this.hide (altId); |
74 | 138 | } |
75 | 139 | |
76 | - this.genAlternativesList = function (bestFit, dists) | |
140 | + this.genAlternativesList = function (bestFit, dists, idx) | |
77 | 141 | { |
78 | 142 | if (dists.length > 0) |
79 | 143 | // there are caculated distances for surnames |
... | ... | @@ -93,12 +157,16 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) |
93 | 157 | |
94 | 158 | // create list entries |
95 | 159 | newLi = document.createElement ('li'); |
160 | + | |
161 | + if (i == idx) | |
162 | + newLi.className = 'bgc-tt1-selItem'; | |
163 | + | |
96 | 164 | liTxt = document.createTextNode (sMatch[2]); |
97 | 165 | newLi.appendChild (liTxt); |
98 | 166 | bestFit.appendChild (newLi); |
99 | 167 | i=i+1; |
100 | 168 | |
101 | - if (i >= bestMatch[1]) | |
169 | + if (i >= bestMatch[1] && sMatch[1] > bestMatch[1]) | |
102 | 170 | // dont show more than best match distance matches. |
103 | 171 | break; |
104 | 172 | } |
... | ... | @@ -115,23 +183,33 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) |
115 | 183 | return bestMatch; |
116 | 184 | } |
117 | 185 | |
118 | - this.altSurnames = function () | |
186 | + this.altSurnames = function (_event) | |
119 | 187 | { |
120 | 188 | var surname = document.getElementById (this.surname); |
121 | 189 | var sNameAlt = document.getElementById (this.sNameAlt); |
122 | - var dists = fittingStrings (surname.value, this.surnames, false); | |
123 | 190 | |
124 | - this.sNameBest = this.genAlternativesList (sNameAlt, dists); | |
191 | + this.snameDists = fittingStrings (surname.value, this.surnames, false); | |
192 | + if (this.snameDists.length > 0) | |
193 | + this.snameMaxIdx = this.snameDists[0].split ('::')[1]; | |
194 | + else | |
195 | + this.snameMaxIdx = -1; | |
196 | + | |
197 | + this.sNameBest = | |
198 | + this.genAlternativesList (sNameAlt, this.snameDists, this.snameIdx); | |
125 | 199 | this.updField (surname, this.sNameBest, this.sNameAlt) |
126 | 200 | |
127 | 201 | if (this.sNameBest[1] == 0) |
128 | 202 | { |
129 | 203 | var firstname = document.getElementById (this.firstname); |
130 | - var dists = fittingStrings ( | |
204 | + this.fnameDists = fittingStrings ( | |
131 | 205 | firstname.value, this.firstnames[this.sNameBest[2]], false); |
206 | + if (this.fnameDists.length > 0) | |
207 | + this.fnameMaxIdx = this.fnameDists[0].split ('::')[1]; | |
208 | + else | |
209 | + this.fnameMaxIdx = -1; | |
132 | 210 | |
133 | - if (dists.length > 0) | |
134 | - this.fNameBest = dists[0].split ('::'); | |
211 | + if (this.fnameDists.length > 0) | |
212 | + this.fNameBest = this.fnameDists[0].split ('::'); | |
135 | 213 | |
136 | 214 | if (this.person != null) |
137 | 215 | if (this.fNameBest[1] == 0) |
... | ... | @@ -150,7 +228,7 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) |
150 | 228 | return false; |
151 | 229 | } |
152 | 230 | |
153 | - this.altFirstnames = function (person) | |
231 | + this.altFirstnames = function () | |
154 | 232 | { |
155 | 233 | var firstname = document.getElementById (this.firstname); |
156 | 234 | var fNameAlt = document.getElementById (this.fNameAlt); |
... | ... | @@ -158,13 +236,18 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) |
158 | 236 | if (this.sNameBest[1] == 0) |
159 | 237 | { |
160 | 238 | var surname = document.getElementById (this.surname); |
161 | - var dists = fittingStrings ( | |
239 | + this.fnameDists = fittingStrings ( | |
162 | 240 | firstname.value, this.firstnames[this.sNameBest[2]], false); |
241 | + if (this.fnameDists.length > 0) | |
242 | + this.fnameMaxIdx = this.fnameDists[0].split ('::')[1]; | |
243 | + else | |
244 | + this.fnameMaxIdx = -1; | |
163 | 245 | } |
164 | 246 | else |
165 | - dists = new Array (); | |
247 | + this.fnameDists = new Array (); | |
166 | 248 | |
167 | - this.fNameBest = this.genAlternativesList (fNameAlt, dists); | |
249 | + this.fNameBest = | |
250 | + this.genAlternativesList (fNameAlt, this.fnameDists, this.fnameIdx); | |
168 | 251 | this.updField (firstname, this.fNameBest, this.fNameAlt) |
169 | 252 | |
170 | 253 | if (this.person != null) |
... | ... | @@ -177,3 +260,59 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) |
177 | 260 | return false; |
178 | 261 | } |
179 | 262 | } |
263 | + | |
264 | +function personSearch1AltFirstnameHandler (_event) | |
265 | +{ | |
266 | + if (_event == undefined) | |
267 | + _event = window.event; | |
268 | + | |
269 | + if (_event.which) | |
270 | + var keycode = _event.which; | |
271 | + else if (_event.keyCode) | |
272 | + var keycode = _event.keyCode; | |
273 | + | |
274 | + var dists = pSearch1.fnameDists; | |
275 | + | |
276 | + // pSearch1 wird im php personSearch1.js angelegt. | |
277 | + switch (keycode) | |
278 | + { | |
279 | + case 38: | |
280 | + pSearch1.decFnameIdx (); | |
281 | + break; | |
282 | + case 40: | |
283 | + pSearch1.incFnameIdx (); | |
284 | + break; | |
285 | + default: | |
286 | + pSearch1.fnameIdx = -1; | |
287 | + } | |
288 | + | |
289 | + pSearch1.altFirstnames (); | |
290 | +} | |
291 | + | |
292 | +function personSearch1AltSurnameHandler (_event) | |
293 | +{ | |
294 | + if (_event == undefined) | |
295 | + _event = window.event; | |
296 | + | |
297 | + if (_event.which) | |
298 | + var keycode = _event.which; | |
299 | + else if (_event.keyCode) | |
300 | + var keycode = _event.keyCode; | |
301 | + | |
302 | + var dists = pSearch1.snameDists; | |
303 | + | |
304 | + // pSearch1 wird im php personSearch1.js angelegt. | |
305 | + switch (keycode) | |
306 | + { | |
307 | + case 38: | |
308 | + pSearch1.decSnameIdx (); | |
309 | + break; | |
310 | + case 40: | |
311 | + pSearch1.incSnameIdx (); | |
312 | + break; | |
313 | + default: | |
314 | + pSearch1.snameIdx = -1; | |
315 | + } | |
316 | + | |
317 | + pSearch1.altSurnames (); | |
318 | +} | ... | ... |
No preview for this file type
... | ... | @@ -49,12 +49,12 @@ msgstr "Perönliche Daten" |
49 | 49 | #: templates/personAdmin/personInUp.tpl.php:81 |
50 | 50 | #: templates/personAdmin/personSearch1.tpl.php:56 |
51 | 51 | msgid "firstname" |
52 | -msgstr "Nachname" | |
52 | +msgstr "Vorname" | |
53 | 53 | |
54 | 54 | #: templates/personAdmin/personInUp.tpl.php:87 |
55 | 55 | #: templates/personAdmin/personSearch1.tpl.php:45 |
56 | 56 | msgid "surname" |
57 | -msgstr "Vorname" | |
57 | +msgstr "Nachname" | |
58 | 58 | |
59 | 59 | #: templates/personAdmin/personInUp.tpl.php:93 |
60 | 60 | msgid "company" | ... | ... |
... | ... | @@ -63,3 +63,12 @@ |
63 | 63 | </form> |
64 | 64 | </div> |
65 | 65 | </div> |
66 | + | |
67 | +<script language="javascript"> | |
68 | +//<![CDATA[ | |
69 | + document.getElementById ('personSearch1_sname').onkeyup = | |
70 | + personSearch1AltSurnameHandler; | |
71 | + document.getElementById ('personSearch1_fname').onkeyup = | |
72 | + personSearch1AltFirstnameHandler; | |
73 | +//]]> | |
74 | +</script> | ... | ... |
Please
register
or
login
to post a comment