From f444fa3b6e272a199f62ac1093db251488a1e2c3 Mon Sep 17 00:00:00 2001 From: Michael Save Date: Sat, 31 Mar 2012 19:37:31 +1100 Subject: onready() instead of onload() --- templates/main.js | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'templates/main.js') diff --git a/templates/main.js b/templates/main.js index 0b514a80..3903ff6e 100644 --- a/templates/main.js +++ b/templates/main.js @@ -158,25 +158,18 @@ var RecaptchaOptions = { theme : 'clean' }; -function onload(fnc) { - if(typeof window.addEventListener != "undefined") { - window.addEventListener("load", fnc, false); - } else if(typeof window.attachEvent != "undefined") { - window.attachEvent( "onload", fnc ); - } else { - if (window.onload != null) { - var oldOnload = window.onload; - window.onload = function (e) { - oldOnload(e); - window[fnc](); - }; - } else { - window.onload = fnc; - } +onready_callbacks = []; +function onready(fnc) { + onready_callbacks.push(fnc); +} + +function ready() { + for(var i = 0; i < onready_callbacks.length; i++) { + onready_callbacks[i](); } } -onload(init); +onready(init); {% endraw %}{% if config.google_analytics %}{% raw %} -- cgit v1.3