var FORM_MANAGER_CONDITION_SEPARATOR = „UND“;
var FORM_MANAGER_POSSIBILITY_SEPARATOR = „ODER“;
var FORM_MANAGER_NAME_VALUE_SEPARATOR = „SEIEND“;
var FORM_MANAGER_DEPENDS = „HÄNGT VON“ ab;
var FORM_MANAGER_CONFLICTS = „WIDERSPRICHT MIT“;
var FORM_MANAGER_EMPTY = „LEEREN sich“;
Funktion addEvent (EL, ev, f) {
wenn (el.addEventListener)
el.addEventListener (ev, f, falsch);
sonst, wenn (el.attachEvent) {
var t = Funktion () {
f.apply (EL);
};
addEvent.events.push ({„Element“: EL, „Ereignis“: ev, „Zufuhr“: f});
el.attachEvent ("ON" + ev, t);
} sonst
EL ["ON" + ev] = f;
}
Funktion addEvents (els, evs, f) {
für (var I = 0; I < els.length; ++i)
für (var J = 0; J < evs.length; ++j)
addEvent (els [i], evs [J], f);
}
addEvent.events = [];
wenn (typeof window.event! == „undefined“)
addEvent (Fenster, „leeren“, Funktion () {
für (var I = 0, e = addEvent.events; I < e.length; ++i)
e [i] .element.detachEvent ("ON" + e [i] .event, e [i] .handler);
}
);
Funktion getRadioValue (EL) {
wenn (! el.length) Rückkehr ungültig;
für (var I = 0; I < el.length; ++i)
wenn (EL [i] .checked) Rückholel [i] .value;
Rückholnull;
}
Funktion getSelectValue (EL) {
wenn (! el.tagName || el.tagName.toLowerCase ()! == „wählen“) vor
Rückholnull;
Rückholel.options [el.selectedIndex] .value;
}
Funktion isElementValue (EL, V) {
wenn (v === FORM_MANAGER_EMPTY) v = '';
zurückgehen (
getRadioValue (EL) == V ||
getSelectValue (EL) == V ||
(
el.tagName &&
el.tagName.toLowerCase ()! == „wählen“ && vor
el.value == V
)
);
}
Funktion setupDependencies () {
var-showEl = Funktion () {
this.style.display = "";
wenn (this.parentNode.tagName.toLowerCase () == „Aufkleber“)
this.parentNode.style.display = "";
};
var-hideEl = Funktion () {
this.style.display = „keine“;
wenn (typeof this.checked! == „undefined“) this.checked = falsch;
sonst this.value = "";
wenn (this.parentNode.tagName.toLowerCase () == „Aufkleber“)
this.parentNode.style.display = „keine“;
this.hidden = richten aus;
};
var-calcDeps = Funktion () {
für (var I = 0, e = this.elements; I < e.length; ++i) {
e [i] .hidden = falsch;
für (var J = 0, f = e [i] .className.split (FORM_MANAGER_CONDITION_SEPARATOR); J < f.length; ++j)
wenn (f [J] .indexOf (FORM_MANAGER_DEPENDS) === 0) {
für (var k = 0, g = f [J] .substr (FORM_MANAGER_DEPENDS.length) .split (FORM_MANAGER_POSSIBILITY_SEPARATOR); k < g.length; ++k)
wenn (g [k] .indexOf (FORM_MANAGER_NAME_VALUE_SEPARATOR) === -1) {
wenn (e [g [k]] && e [g [k]] .checked) Bruch;
sonst, wenn (k + 1 == g.length)
e [i] .hide ();
} sonst {
var n = g [k] .split (FORM_MANAGER_NAME_VALUE_SEPARATOR),
V = n [1];
n = n [0];
wenn (e [n])
wenn (isElementValue (e [n], V)) Bruch;
sonst wenn (k + 1 == g.length) e [i] .hide ();
}
} sonst, wenn (f [J] .indexOf (FORM_MANAGER_CONFLICTS) === 0) {
wenn (f [J] .indexOf (FORM_MANAGER_NAME_VALUE_SEPARATOR) === -1) {
wenn (e [f [J] .substr (FORM_MANAGER_CONFLICTS.length)] && e [f [J] .substr (FORM_MANAGER_CONFLICTS.length)].checked) {
e [i] .hide ();
Bruch;
}
} sonst {
var n = f [J] .substr (FORM_MANAGER_CONFLICTS.length) .split (FORM_MANAGER_NAME_VALUE_SEPARATOR),
V = n [1];
n = n [0];
wenn (e [n]) {
wenn (isElementValue (e [n], V)) {
e [i] .hide ();
Bruch;
}
}
}
}
wenn (! e [i] .hidden) e [i] .show ();
}
};
var-changeHandler = Funktion () {
this.form.calculateDependencies ();
Rückhol richten aus;
};
für (var I = 0; I < arguments.length; ++i) {
für (var J = 0, e = window.document.forms [Argumente [i]] .elements; J < e.length; ++j) {
addEvents ([e [J]], [„Änderung“, „keyup“, „Fokus“, „Klicken“, „keydown“], changeHandler);
e [J] .hide = hideEl;
e [J] .show = showEl;
}
(e = window.document.forms [Argumente [i]]) .calculateDependencies = calcDeps;
e.calculateDependencies ();
}
}
|