aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2011-09-13 22:21:12 -0400
committerCash Costello <cash.costello@gmail.com>2011-09-13 22:21:12 -0400
commit8a2611e5002982cbfd2843240c181c0796b043b2 (patch)
tree481f7d4ca018e3fcdc241b5b140b01bbd1c93562
parent61337b126e0ee3a316f5cb9faf8982b0803793a4 (diff)
downloadelgg-8a2611e5002982cbfd2843240c181c0796b043b2.tar.gz
elgg-8a2611e5002982cbfd2843240c181c0796b043b2.tar.bz2
Fixes #3539 two conditions for triggering init,system now - dom is ready and languages loaded
-rw-r--r--js/lib/elgglib.js17
-rw-r--r--js/lib/languages.js2
-rw-r--r--views/default/js/elgg.php6
3 files changed, 22 insertions, 3 deletions
diff --git a/js/lib/elgglib.js b/js/lib/elgglib.js
index f2545fb6c..9a372738d 100644
--- a/js/lib/elgglib.js
+++ b/js/lib/elgglib.js
@@ -379,4 +379,19 @@ elgg.getSelectorFromUrlFragment = function(url) {
}
}
return '';
-}; \ No newline at end of file
+};
+
+/**
+ * Triggers the init hook when the library is ready
+ *
+ * Current requirements:
+ * - DOM is ready
+ * - languages loaded
+ *
+ */
+elgg.initWhenReady = function() {
+ if (elgg.config.languageReady && elgg.config.domReady) {
+ elgg.trigger_hook('init', 'system');
+ elgg.trigger_hook('ready', 'system');
+ }
+} \ No newline at end of file
diff --git a/js/lib/languages.js b/js/lib/languages.js
index 4cfe84968..ae7ba63e2 100644
--- a/js/lib/languages.js
+++ b/js/lib/languages.js
@@ -32,6 +32,8 @@ elgg.reload_all_translations = function(language) {
},
success: function(json) {
elgg.add_translation(lang, json);
+ elgg.config.languageReady = true;
+ elgg.initWhenReady();
}
});
};
diff --git a/views/default/js/elgg.php b/views/default/js/elgg.php
index 76388f80c..133e128a4 100644
--- a/views/default/js/elgg.php
+++ b/views/default/js/elgg.php
@@ -56,11 +56,13 @@ elgg.version = '<?php echo get_version(); ?>';
elgg.release = '<?php echo get_version(true); ?>';
elgg.config.wwwroot = '<?php echo elgg_get_site_url(); ?>';
elgg.security.interval = 5 * 60 * 1000; <?php //@todo make this configurable ?>
+elgg.config.domReady = false;
+elgg.config.languageReady = false;
//After the DOM is ready
$(function() {
- elgg.trigger_hook('init', 'system');
- elgg.trigger_hook('ready', 'system');
+ elgg.config.domReady = true;
+ elgg.initWhenReady();
});
<?php