aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/lib/elgglib.js17
-rw-r--r--js/lib/hooks.js22
-rw-r--r--js/lib/languages.js2
-rw-r--r--js/lib/ui.js1
4 files changed, 36 insertions, 6 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/hooks.js b/js/lib/hooks.js
index eeaffb846..ab3a8a224 100644
--- a/js/lib/hooks.js
+++ b/js/lib/hooks.js
@@ -77,11 +77,23 @@ elgg.trigger_hook = function(name, type, params, value) {
elgg.provide(name + '.all', hooks);
elgg.provide('all.all', hooks);
- [ hooks[name][type],
- hooks['all'][type],
- hooks[name]['all'],
- hooks['all']['all']
- ].every(function(handlers) {
+ var hooksList = [];
+
+ if (name != 'all' && type != 'all') {
+ hooksList.push(hooks[name][type]);
+ }
+
+ if (type != 'all') {
+ hooksList.push(hooks['all'][type]);
+ }
+
+ if (name != 'all') {
+ hooksList.push(hooks[name]['all']);
+ }
+
+ hooksList.push(hooks['all']['all']);
+
+ hooksList.every(function(handlers) {
if (handlers instanceof elgg.ElggPriorityList) {
handlers.forEach(callHookHandler);
}
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/js/lib/ui.js b/js/lib/ui.js
index 4426917ed..7abf7626f 100644
--- a/js/lib/ui.js
+++ b/js/lib/ui.js
@@ -275,5 +275,6 @@ elgg.ui.initDatePicker = function() {
});
}
+
elgg.register_hook_handler('init', 'system', elgg.ui.init);
elgg.register_hook_handler('getOptions', 'ui.popup', elgg.ui.LoginHandler); \ No newline at end of file