Use "DOM ready" event instead of window.onload
parent
811d30acbd
commit
a7b98817a7
|
@ -3,7 +3,7 @@
|
||||||
* Author(s): Vitaliy Filippov <vitalif@mail.ru>
|
* Author(s): Vitaliy Filippov <vitalif@mail.ru>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
addListener(window, 'load', initControlledFields);
|
onDomReady(initControlledFields);
|
||||||
|
|
||||||
function initControlledFields()
|
function initControlledFields()
|
||||||
{
|
{
|
||||||
|
|
|
@ -358,7 +358,7 @@ function search_filter_click(e)
|
||||||
this.href = new_href;
|
this.href = new_href;
|
||||||
}
|
}
|
||||||
|
|
||||||
addListener(window, 'load', function()
|
onDomReady(function()
|
||||||
{
|
{
|
||||||
if (document.getElementById('form_bug_edit'))
|
if (document.getElementById('form_bug_edit'))
|
||||||
{
|
{
|
||||||
|
|
|
@ -169,7 +169,7 @@ function validateEntryForm(theform)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
addListener(window, 'load', function()
|
onDomReady(function()
|
||||||
{
|
{
|
||||||
var f = document.getElementById('bug_status');
|
var f = document.getElementById('bug_status');
|
||||||
addListener(f, 'change', bug_status_change);
|
addListener(f, 'change', bug_status_change);
|
||||||
|
|
21
js/field.js
21
js/field.js
|
@ -25,7 +25,7 @@ function hideEditableField( container, input, action, field_id, original_value )
|
||||||
addClass(input, 'bz_default_hidden');
|
addClass(input, 'bz_default_hidden');
|
||||||
addListener(action, 'click', function(ev) { return showEditableField(ev, [ container, input ]); });
|
addListener(action, 'click', function(ev) { return showEditableField(ev, [ container, input ]); });
|
||||||
if (field_id != "")
|
if (field_id != "")
|
||||||
addListener(window, 'load', function(ev) {
|
onDomReady(function(ev) {
|
||||||
return checkForChangedFieldValues(ev, [ container, input, field_id, original_value ])
|
return checkForChangedFieldValues(ev, [ container, input, field_id, original_value ])
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -114,9 +114,7 @@ function hideAliasAndSummary(short_desc_value, alias_value)
|
||||||
var bz_alias_check_array = [
|
var bz_alias_check_array = [
|
||||||
'summary_alias_container', 'summary_alias_input', 'alias', alias_value
|
'summary_alias_container', 'summary_alias_input', 'alias', alias_value
|
||||||
];
|
];
|
||||||
addListener(window, 'load',
|
onDomReady(function(ev) { return checkForChangedFieldValues(ev, bz_alias_check_array) });
|
||||||
function(ev) { return checkForChangedFieldValues(ev, bz_alias_check_array) }
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showPeopleOnChange(field_id_list)
|
function showPeopleOnChange(field_id_list)
|
||||||
|
@ -145,13 +143,16 @@ function assignToDefaultOnChange(field_id_list)
|
||||||
function initDefaultCheckbox(field_id)
|
function initDefaultCheckbox(field_id)
|
||||||
{
|
{
|
||||||
addListener('set_default_'+field_id, 'change',
|
addListener('set_default_'+field_id, 'change',
|
||||||
function(ev) { return boldOnChange(ev, 'set_default_'+field_id) });
|
function(ev) { return boldOnChange(ev, 'set_default_'+field_id) }
|
||||||
addListener(window, 'load',
|
);
|
||||||
function(ev) { return checkForChangedFieldValues(ev, [
|
onDomReady(function(ev)
|
||||||
|
{
|
||||||
|
checkForChangedFieldValues(ev, [
|
||||||
'bz_'+field_id+'_edit_container', 'bz_'+field_id+'_input',
|
'bz_'+field_id+'_edit_container', 'bz_'+field_id+'_input',
|
||||||
'set_default_'+field_id, '1' ]) });
|
'set_default_'+field_id, '1' ]
|
||||||
addListener(window, 'load',
|
);
|
||||||
function(ev) { return boldOnChange(ev, 'set_default_'+field_id) });
|
boldOnChange(ev, 'set_default_'+field_id);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function showHideStatusItems(is_duplicate, initial_status)
|
function showHideStatusItems(is_duplicate, initial_status)
|
||||||
|
|
|
@ -82,4 +82,4 @@ function disableRequesteeFields()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addListener(window, "load", disableRequesteeFields);
|
onDomReady(disableRequesteeFields);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// Author(s): Vitaliy Filippov <vitalif@mail.ru>
|
// Author(s): Vitaliy Filippov <vitalif@mail.ru>
|
||||||
|
|
||||||
// Requires global vars: queryform, checkwidths, userAutocomplete
|
// Requires global vars: queryform, checkwidths, userAutocomplete
|
||||||
addListener(window, 'load', function()
|
onDomReady(function()
|
||||||
{
|
{
|
||||||
document.forms[queryform].content.focus();
|
document.forms[queryform].content.focus();
|
||||||
if (document.getElementById('deadlinefrom'))
|
if (document.getElementById('deadlinefrom'))
|
||||||
|
|
|
@ -37,7 +37,7 @@ respecting this "list of active IDs".
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
addListener(window, 'load', initQueryformFields);
|
onDomReady(initQueryformFields);
|
||||||
|
|
||||||
function initQueryformFields()
|
function initQueryformFields()
|
||||||
{
|
{
|
||||||
|
|
87
js/util.js
87
js/util.js
|
@ -455,11 +455,86 @@ function AjaxLoader(url, callback)
|
||||||
x.send(null);
|
x.send(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
function existElement(el_id) {
|
function existElement(el_id)
|
||||||
|
{
|
||||||
var el = document.getElementById(el_id);
|
var el = document.getElementById(el_id);
|
||||||
if (typeof (el) != undefined && typeof (el) != null && typeof (el) != 'undefined' && el !== null) {
|
return (typeof (el) != undefined && typeof (el) != null && typeof (el) != 'undefined' && el !== null);
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.onDomReady = (function()
|
||||||
|
{
|
||||||
|
var readyBound = false;
|
||||||
|
var bindReady = function()
|
||||||
|
{
|
||||||
|
if (readyBound)
|
||||||
|
return;
|
||||||
|
readyBound = true;
|
||||||
|
if (document.addEventListener)
|
||||||
|
{
|
||||||
|
document.addEventListener("DOMContentLoaded", function()
|
||||||
|
{
|
||||||
|
document.removeEventListener("DOMContentLoaded", arguments.callee, false);
|
||||||
|
ready();
|
||||||
|
}, false);
|
||||||
|
}
|
||||||
|
else if (document.attachEvent)
|
||||||
|
{
|
||||||
|
document.attachEvent("onreadystatechange", function()
|
||||||
|
{
|
||||||
|
if (document.readyState === "complete")
|
||||||
|
{
|
||||||
|
document.detachEvent( "onreadystatechange", arguments.callee );
|
||||||
|
ready();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (document.documentElement.doScroll && window == window.top)
|
||||||
|
{
|
||||||
|
(function()
|
||||||
|
{
|
||||||
|
if (isReady)
|
||||||
|
return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
document.documentElement.doScroll("left");
|
||||||
|
}
|
||||||
|
catch(error)
|
||||||
|
{
|
||||||
|
setTimeout(arguments.callee, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ready();
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (window.addEventListener)
|
||||||
|
window.addEventListener('load', ready, false);
|
||||||
|
else if (window.attachEvent)
|
||||||
|
window.attachEvent('onload', ready);
|
||||||
|
else
|
||||||
|
window.onload = ready;
|
||||||
|
};
|
||||||
|
var isReady = false;
|
||||||
|
var readyList = [];
|
||||||
|
var ready = function()
|
||||||
|
{
|
||||||
|
if (!isReady)
|
||||||
|
{
|
||||||
|
isReady = true;
|
||||||
|
if (readyList)
|
||||||
|
{
|
||||||
|
var fn_temp = null;
|
||||||
|
while (fn_temp = readyList.shift())
|
||||||
|
fn_temp.call(document);
|
||||||
|
readyList = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return function(fn) {
|
||||||
|
bindReady();
|
||||||
|
if (isReady)
|
||||||
|
fn.call(document);
|
||||||
|
else
|
||||||
|
readyList.push(fn);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
|
@ -86,7 +86,7 @@
|
||||||
"login" : "login",
|
"login" : "login",
|
||||||
"warning" : "You must set the login and password before logging in."
|
"warning" : "You must set the login and password before logging in."
|
||||||
};
|
};
|
||||||
addListener(window, 'load', function() {
|
onDomReady(function() {
|
||||||
init_mini_login_form('_[% qs_suffix %]');
|
init_mini_login_form('_[% qs_suffix %]');
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -319,15 +319,13 @@ You are currently not watching any users.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<script type="text/javascript" language="JavaScript">
|
<script type="text/javascript" language="JavaScript">
|
||||||
addListener(window, 'load', function() {
|
[%-# FIXME: remove hardcoded i18n message, also from js/field.js::userAutocomplete() %]
|
||||||
[%-# FIXME: remove hardcoded i18n message, also from js/field.js::userAutocomplete() %]
|
new SimpleAutocomplete("new_watchedusers",
|
||||||
new SimpleAutocomplete("new_watchedusers",
|
function(h) { userAutocomplete(h, null); },
|
||||||
function(h) { userAutocomplete(h, null); },
|
{ multipleDelimiter: ',', emptyText: 'No users found' });
|
||||||
{ multipleDelimiter: ',', emptyText: 'No users found' });
|
new SimpleAutocomplete("new_watchers",
|
||||||
new SimpleAutocomplete("new_watchers",
|
function(h) { userAutocomplete(h, null); },
|
||||||
function(h) { userAutocomplete(h, null); },
|
{ multipleDelimiter: ',', emptyText: 'No users found' });
|
||||||
{ multipleDelimiter: ',', emptyText: 'No users found' });
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
|
@ -189,7 +189,7 @@ var close_status_array = [
|
||||||
<td>
|
<td>
|
||||||
<input id="keywords" name="keywords" size="60" value="[% default.keywords | html %]">
|
<input id="keywords" name="keywords" size="60" value="[% default.keywords | html %]">
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
addListener(window, 'load', addKeywordsAutocomplete);
|
addKeywordsAutocomplete();
|
||||||
</script>
|
</script>
|
||||||
<div id="keywords_description_container"></div>
|
<div id="keywords_description_container"></div>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -537,7 +537,7 @@ document.changeform = document.[% cfname %];
|
||||||
</td>
|
</td>
|
||||||
[% PROCESS input inputname => "keywords" size => 40 colspan => 2 %]
|
[% PROCESS input inputname => "keywords" size => 40 colspan => 2 %]
|
||||||
<script>
|
<script>
|
||||||
addListener(window, 'load', addKeywordsAutocomplete);
|
addKeywordsAutocomplete();
|
||||||
</script>
|
</script>
|
||||||
</tr>
|
</tr>
|
||||||
[% END %]
|
[% END %]
|
||||||
|
@ -942,7 +942,7 @@ document.changeform = document.[% cfname %];
|
||||||
<input name="deadline" id="deadline" value="[% bug.deadline %]"
|
<input name="deadline" id="deadline" value="[% bug.deadline %]"
|
||||||
size="10" maxlength="10"><br />
|
size="10" maxlength="10"><br />
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
Calendar.set('deadline');
|
Calendar.set('deadline');
|
||||||
</script>
|
</script>
|
||||||
<small>(YYYY-MM-DD)</small>
|
<small>(YYYY-MM-DD)</small>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -29,11 +29,8 @@
|
||||||
[% IF style %] style="[% style | html %]" [% END %]
|
[% IF style %] style="[% style | html %]" [% END %]
|
||||||
/>
|
/>
|
||||||
<script language="JavaScript">
|
<script language="JavaScript">
|
||||||
addListener(window, 'load', function() {
|
[%-# FIXME: remove hardcoded i18n message, also from js/field.js::userAutocomplete() %]
|
||||||
[%-# FIXME: remove hardcoded i18n message, also from js/field.js::userAutocomplete() %]
|
new SimpleAutocomplete("[% id | js %]",
|
||||||
var emptyOptions = [% custom_userlist ? json(custom_userlist) : "null" %];
|
function(h) { userAutocomplete(h, [% custom_userlist ? json(custom_userlist) : "null" %], [% Param('usemenuforusers') ? 1 : 0 %]); },
|
||||||
new SimpleAutocomplete("[% id | js %]",
|
{ emptyText: 'No users found'[% ', multipleDelimiter: ","' IF multiple %] });
|
||||||
function(h) { userAutocomplete(h, emptyOptions, [% Param('usemenuforusers') ? 1 : 0 %]); },
|
|
||||||
{ emptyText: 'No users found'[% ', multipleDelimiter: ","' IF multiple %] });
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -211,9 +211,6 @@ document.write(' <input type="button" name="check_all" value="Check All" onclick
|
||||||
[% IF use_keywords %]
|
[% IF use_keywords %]
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
<script type="text/javascript">
|
|
||||||
addListener(window, 'load', addKeywordsAutocomplete);
|
|
||||||
</script>
|
|
||||||
<label for="keywords">
|
<label for="keywords">
|
||||||
<a href="describekeywords.cgi">Keywords</a>:
|
<a href="describekeywords.cgi">Keywords</a>:
|
||||||
</label>
|
</label>
|
||||||
|
@ -225,6 +222,9 @@ document.write(' <input type="button" name="check_all" value="Check All" onclick
|
||||||
<option value="delete">Delete these keywords</option>
|
<option value="delete">Delete these keywords</option>
|
||||||
<option value="makeexact">Make the keywords be exactly this list</option>
|
<option value="makeexact">Make the keywords be exactly this list</option>
|
||||||
</select>
|
</select>
|
||||||
|
<script type="text/javascript">
|
||||||
|
addKeywordsAutocomplete();
|
||||||
|
</script>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|
Loading…
Reference in New Issue