]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #3539 two conditions for triggering init,system now - dom is ready and language...
authorCash Costello <cash.costello@gmail.com>
Wed, 14 Sep 2011 02:21:12 +0000 (22:21 -0400)
committerCash Costello <cash.costello@gmail.com>
Wed, 14 Sep 2011 02:21:12 +0000 (22:21 -0400)
js/lib/elgglib.js
js/lib/languages.js
views/default/js/elgg.php

index f2545fb6c9236350912cb0af1be8a8e62b91bbe0..9a372738db7049f92ee5e328f4a4f5d0409c1d2f 100644 (file)
@@ -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
index 4cfe84968df2952ba19c4bbe91e57d62849168f8..ae7ba63e20565b06e7a6537200f21443dcf60dad 100644 (file)
@@ -32,6 +32,8 @@ elgg.reload_all_translations = function(language) {
                },
                success: function(json) {
                        elgg.add_translation(lang, json);
+                       elgg.config.languageReady = true;
+                       elgg.initWhenReady();
                }
        });
 };
index 76388f80cf6378ad556b674d29f45d5d5909b4c5..133e128a49d1f9c7b55c48de1a92a3f98ff936d3 100644 (file)
@@ -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