From 22ebfe90b5d1a52f55093f0c33a083041ca0f0e7 Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Tue, 9 Oct 2007 11:35:43 +0000 Subject: [PATCH] Man kann jetzt eine Alternative aus der Liste aller Alternativen auswaehlen --- css/background-colors.css | 13 +- js/personAdmin/personSearch1.js | 165 ++++++++++++++++++-- locale/de/LC_MESSAGES/bilder.mo | Bin 1470 -> 1470 bytes po/de.po | 4 +- templates/personAdmin/personSearch1.tpl.php | 9 ++ 5 files changed, 170 insertions(+), 21 deletions(-) diff --git a/css/background-colors.css b/css/background-colors.css index f3b57b4..105fd59 100644 --- a/css/background-colors.css +++ b/css/background-colors.css @@ -1,21 +1,22 @@ /* ======================================================================= * Styles for components * ======================================================================= */ -.bgc-bg1 { background-color: #888888 } +.bgc-bg1 { background-color: #888888 } /* ======================================================================= */ /* ======================================================================= * Styles for logical groups. A group is defined by a bounding box "grp*" * containing one or more header lines "head*" and content-boxes "box*" * ======================================================================= */ -.bgc-grp1 { background-color: #aaaaaa } -.bgc-box1 { background-color: #ffb400 } -.bgc-grp-head1 { background-color: #e5a200 } -.bgc-box-head1 { background-color: #ffc434 } +.bgc-grp1 { background-color: #aaaaaa } +.bgc-box1 { background-color: #ffb400 } +.bgc-grp-head1 { background-color: #e5a200 } +.bgc-box-head1 { background-color: #ffc434 } /* ======================================================================= */ /* ======================================================================= * Styles for tooltips * ======================================================================= */ -.bgc-tt1 { background-color: #eeeeee } +.bgc-tt1 { background-color: #eeeeee } +.bgc-tt1-selItem { background-color: #ffc434 } /* ======================================================================= */ diff --git a/js/personAdmin/personSearch1.js b/js/personAdmin/personSearch1.js index 17c80bc..1def067 100644 --- a/js/personAdmin/personSearch1.js +++ b/js/personAdmin/personSearch1.js @@ -46,6 +46,37 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) this.sNameBest = new Array (-1, -1, null); this.fNameBest = new Array (-1, -1, null); + this.snameIdx = -1; + this.fnameIdx = -1; + this.snameMaxIdx = -1; + this.fnameMaxIdx = -1; + this.snameDists = new Array (); + this.fnameDists = new Array (); + + this.incSnameIdx = function () + { + if (this.snameIdx < this.snameMaxIdx-1) + this.snameIdx ++; + } + + this.incFnameIdx = function () + { + if (this.fnameIdx < this.fnameMaxIdx-1) + this.fnameIdx ++; + } + + this.decSnameIdx = function () + { + if (this.snameIdx >= 0) + this.snameIdx --; + } + + this.decFnameIdx = function () + { + if (this.fnameIdx >= 0) + this.fnameIdx --; + } + this.show = function (id) { var node = document.getElementById (id); @@ -56,9 +87,42 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) this.hide = function (id) { - var node = document.getElementById (id); + var node = document.getElementById (id); + var inField = + node.parentNode.parentNode.getElementsByTagName ('input')[0]; + var idx = -1; + var dists = new Array (); + node.parentNode.style.visibility = 'hidden'; + switch (inField.getAttribute ('id')) + { + case 'personSearch1_fname': + idx = this.fnameIdx; + if (idx != -1) + { + dists = this.fnameDists[idx].split ('::'); + this.fNameBest = new Array (0, 0, dists[2]); + inField.value = dists[2]; + } + break; + case 'personSearch1_sname': + idx = this.snameIdx; + if (idx != -1) + { + dists = this.snameDists[idx].split ('::'); + this.sNameBest = new Array (0, 0, dists[2]); + inField.value = dists[2]; + } + } + + if (this.person != null) + if (this.fNameBest[1] == 0) + this.person.update ( + this.persons[this.sNameBest[2]][this.fNameBest[2]]); + else + this.person.empty (); + return false; } @@ -73,7 +137,7 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) return this.hide (altId); } - this.genAlternativesList = function (bestFit, dists) + this.genAlternativesList = function (bestFit, dists, idx) { if (dists.length > 0) // there are caculated distances for surnames @@ -93,12 +157,16 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) // create list entries newLi = document.createElement ('li'); + + if (i == idx) + newLi.className = 'bgc-tt1-selItem'; + liTxt = document.createTextNode (sMatch[2]); newLi.appendChild (liTxt); bestFit.appendChild (newLi); i=i+1; - if (i >= bestMatch[1]) + if (i >= bestMatch[1] && sMatch[1] > bestMatch[1]) // dont show more than best match distance matches. break; } @@ -115,23 +183,33 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) return bestMatch; } - this.altSurnames = function () + this.altSurnames = function (_event) { var surname = document.getElementById (this.surname); var sNameAlt = document.getElementById (this.sNameAlt); - var dists = fittingStrings (surname.value, this.surnames, false); - this.sNameBest = this.genAlternativesList (sNameAlt, dists); + this.snameDists = fittingStrings (surname.value, this.surnames, false); + if (this.snameDists.length > 0) + this.snameMaxIdx = this.snameDists[0].split ('::')[1]; + else + this.snameMaxIdx = -1; + + this.sNameBest = + this.genAlternativesList (sNameAlt, this.snameDists, this.snameIdx); this.updField (surname, this.sNameBest, this.sNameAlt) if (this.sNameBest[1] == 0) { var firstname = document.getElementById (this.firstname); - var dists = fittingStrings ( + this.fnameDists = fittingStrings ( firstname.value, this.firstnames[this.sNameBest[2]], false); + if (this.fnameDists.length > 0) + this.fnameMaxIdx = this.fnameDists[0].split ('::')[1]; + else + this.fnameMaxIdx = -1; - if (dists.length > 0) - this.fNameBest = dists[0].split ('::'); + if (this.fnameDists.length > 0) + this.fNameBest = this.fnameDists[0].split ('::'); if (this.person != null) if (this.fNameBest[1] == 0) @@ -150,7 +228,7 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) return false; } - this.altFirstnames = function (person) + this.altFirstnames = function () { var firstname = document.getElementById (this.firstname); var fNameAlt = document.getElementById (this.fNameAlt); @@ -158,13 +236,18 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) if (this.sNameBest[1] == 0) { var surname = document.getElementById (this.surname); - var dists = fittingStrings ( + this.fnameDists = fittingStrings ( firstname.value, this.firstnames[this.sNameBest[2]], false); + if (this.fnameDists.length > 0) + this.fnameMaxIdx = this.fnameDists[0].split ('::')[1]; + else + this.fnameMaxIdx = -1; } else - dists = new Array (); + this.fnameDists = new Array (); - this.fNameBest = this.genAlternativesList (fNameAlt, dists); + this.fNameBest = + this.genAlternativesList (fNameAlt, this.fnameDists, this.fnameIdx); this.updField (firstname, this.fNameBest, this.fNameAlt) if (this.person != null) @@ -177,3 +260,59 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) return false; } } + +function personSearch1AltFirstnameHandler (_event) +{ + if (_event == undefined) + _event = window.event; + + if (_event.which) + var keycode = _event.which; + else if (_event.keyCode) + var keycode = _event.keyCode; + + var dists = pSearch1.fnameDists; + + // pSearch1 wird im php personSearch1.js angelegt. + switch (keycode) + { + case 38: + pSearch1.decFnameIdx (); + break; + case 40: + pSearch1.incFnameIdx (); + break; + default: + pSearch1.fnameIdx = -1; + } + + pSearch1.altFirstnames (); +} + +function personSearch1AltSurnameHandler (_event) +{ + if (_event == undefined) + _event = window.event; + + if (_event.which) + var keycode = _event.which; + else if (_event.keyCode) + var keycode = _event.keyCode; + + var dists = pSearch1.snameDists; + + // pSearch1 wird im php personSearch1.js angelegt. + switch (keycode) + { + case 38: + pSearch1.decSnameIdx (); + break; + case 40: + pSearch1.incSnameIdx (); + break; + default: + pSearch1.snameIdx = -1; + } + + pSearch1.altSurnames (); +} diff --git a/locale/de/LC_MESSAGES/bilder.mo b/locale/de/LC_MESSAGES/bilder.mo index 14a175944d76a757b0fecef17fcd9fc6ffd9d186..c12e791f40486334f53308dbd1f38cad2377df4b 100644 GIT binary patch delta 91 zcmdnTy^nhX3!^PN0|NsKD+2>3kmdo>96(wONDBgKc_`lyNCOdr6_8*9(hg8@_sx!s Yhnbnf@{1;OusX2#B_?M~_GT>x0CT?z%m4rY delta 91 zcmdnTy^nhX3!^Ou0|NsKD+2>3kmd!_Aig+|76j4?P`(k61|kM)Ai)Nt9f34EkoMT@ Z$at8U#V;{AV=_Cd19Mn@(PVGdVgPkJ3eo@o diff --git a/po/de.po b/po/de.po index 929f778..5105e53 100644 --- a/po/de.po +++ b/po/de.po @@ -49,12 +49,12 @@ msgstr "Perönliche Daten" #: templates/personAdmin/personInUp.tpl.php:81 #: templates/personAdmin/personSearch1.tpl.php:56 msgid "firstname" -msgstr "Nachname" +msgstr "Vorname" #: templates/personAdmin/personInUp.tpl.php:87 #: templates/personAdmin/personSearch1.tpl.php:45 msgid "surname" -msgstr "Vorname" +msgstr "Nachname" #: templates/personAdmin/personInUp.tpl.php:93 msgid "company" diff --git a/templates/personAdmin/personSearch1.tpl.php b/templates/personAdmin/personSearch1.tpl.php index 7bca46a..de79cf3 100644 --- a/templates/personAdmin/personSearch1.tpl.php +++ b/templates/personAdmin/personSearch1.tpl.php @@ -63,3 +63,12 @@ + +