From f7ae28ea45656d2821262998e9a71c351dcced8c Mon Sep 17 00:00:00 2001 From: ewinslow Date: Tue, 2 Nov 2010 04:23:04 +0000 Subject: Refs #2538: Added Elggy event system. Javascript boot sequence mimics PHP. git-svn-id: http://code.elgg.org/elgg/trunk@7186 36083f99-b078-4883-b0ff-0f9b5a30f544 --- views/default/js/initialise_elgg.php | 44 ++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 17 deletions(-) (limited to 'views') diff --git a/views/default/js/initialise_elgg.php b/views/default/js/initialise_elgg.php index b6c3f7ecd..98dfc28a7 100644 --- a/views/default/js/initialise_elgg.php +++ b/views/default/js/initialise_elgg.php @@ -4,12 +4,23 @@ */ global $CONFIG; -//Include library files -$lib_files = array( - //core - 'elgglib', +include("{$CONFIG->path}engine/js/lib/elgglib.js"); +//No such thing as autoloading classes in javascript +$model_files = array( + 'ElggEntity', + 'ElggUser', + 'ElggPriorityList', +); + +foreach($model_files as $file) { + include("{$CONFIG->path}engine/js/classes/$file.js"); +} + +//Include library files +$libs = array( //libraries + 'events', 'security', 'languages', 'ajax', @@ -20,23 +31,12 @@ $lib_files = array( 'ui.widgets', ); -foreach($lib_files as $file) { +foreach($libs as $file) { include("{$CONFIG->path}engine/js/lib/$file.js"); } -//Include classes -$model_files = array( - 'ElggEntity', - - 'ElggUser', -); - -foreach($model_files as $file) { - include("{$CONFIG->path}engine/js/classes/$file.js"); -} - /** - * Finally, set some values that are cacheable + * Set some values that are cacheable */ ?> @@ -45,6 +45,16 @@ elgg.release = ''; elgg.config.wwwroot = ''; elgg.security.interval = 5 * 60 * 1000; +//Mimic PHP engine boot process + +//Before the DOM is ready -- note that plugins aren't loaded yet +elgg.trigger_event('boot', 'system'); + +//After the DOM is ready +$(function() { + elgg.trigger_event('init', 'system'); +}); + $(document).ready(function () { // COLLAPSABLE WIDGETS (on Dashboard? & Profile pages) -- cgit v1.2.3