Revision 26e884f3
Von Sven Schöling vor mehr als 16 Jahren hinzugefügt
js/common.js | ||
---|---|---|
1 |
if (!window.a_onload_functions) var a_onload_functions = new Object();
|
|
2 |
if (!window.a_onsubmit_functions) var a_onsubmit_functions = new Object();
|
|
3 |
if (!window.a_onfocus_functions) var a_onfocus_functions = new Object();
|
|
1 |
if (!window.a_onload_functions) a_onload_functions = new Object(); |
|
2 |
if (!window.a_onsubmit_functions) a_onsubmit_functions = new Object(); |
|
3 |
if (!window.a_onfocus_functions) a_onfocus_functions = new Object(); |
|
4 | 4 |
window.focused_element = null; |
5 | 5 |
|
6 | 6 |
function setupPoints(numberformat, wrongFormat) { |
... | ... | |
139 | 139 |
return ''; |
140 | 140 |
} |
141 | 141 |
|
142 |
a_onfocus_functions["focus_listener"] = function (event) { |
|
142 |
a_onfocus_functions["focus_listener"] = (function (event) {
|
|
143 | 143 |
if (focussable(event.target)) window.focused_element = event.target; |
144 |
} |
|
144 |
});
|
|
145 | 145 |
|
146 |
a_onsubmit_functions["get_cursor_position"] = function () { |
|
146 |
a_onsubmit_functions["get_cursor_position"] = (function () {
|
|
147 | 147 |
if (window.focused_element) |
148 | 148 |
document.forms[0].cursor_fokus.value = window.focused_element.name; |
149 |
} |
|
149 |
});
|
|
150 | 150 |
|
151 | 151 |
function set_cursor_position(n) { |
152 | 152 |
document.getElementsByName(n)[0].focus(); |
153 | 153 |
} |
154 | 154 |
|
155 |
a_onload_functions["restore_cursor_position"] = function () { |
|
155 |
a_onload_functions["restore_cursor_position"] = (function () {
|
|
156 | 156 |
var e = document.getElementsByName('cursor_fokus')[0]; |
157 |
var f = document.getElementsByName(e.value)[0]; |
|
157 |
if (e) var f = document.getElementsByName(e.value)[0];
|
|
158 | 158 |
if (focussable(f)) set_cursor_position(f.name) |
159 | 159 |
else set_cursor_to_first_element(); |
160 |
} |
|
160 |
});
|
|
161 | 161 |
|
162 | 162 |
function focussable(e) { |
163 |
return e && e.type != 'hidden' && e.type != 'submit' && e.disabled != true; |
|
163 |
return e && e.name && e.type != 'hidden' && e.type != 'submit' && e.disabled != true;
|
|
164 | 164 |
} |
165 | 165 |
|
166 | 166 |
function set_cursor_to_first_element(){ |
... | ... | |
173 | 173 |
|
174 | 174 |
function add_event(e, type, fn, c) { |
175 | 175 |
var ret = 0; |
176 |
if (e.addEventListener) ret = e.addEventListener(type, fn, c)
|
|
177 |
else if (e.attachEvent) ret = e.attachEvent('on' + type, fn)
|
|
176 |
if (e.addEventListener) e.addEventListener(type, fn, c) |
|
177 |
else if (e.attachEvent) e.attachEvent('on' + type, fn) |
|
178 | 178 |
else e['on' + type] = fn; |
179 |
return ret; |
|
180 | 179 |
} |
181 | 180 |
|
182 | 181 |
function do_load_events() { |
183 | 182 |
for (var name in window.a_onload_functions) add_event(window, "load", window.a_onload_functions[name], false); |
184 | 183 |
for (var name in window.a_onsubmit_functions) add_event(window, "submit", window.a_onsubmit_functions[name], false); |
185 |
for (var name in window.a_onfocus_functions) add_event(window, "focus", window.a_onfocus_functions[name], true);
|
|
184 |
for (var name in window.a_onfocus_functions) add_event(window, "focus", window.a_onfocus_functions[name], false);
|
|
186 | 185 |
} |
187 | 186 |
do_load_events(); |
Auch abrufbar als: Unified diff
Näher am Standard, und Bugfix für bestimmte Renderer.