# HG changeset patch
# User Dan
# Date 1245111030 14400
# Node ID 722f4beeceb615fb5aab2ad3922bcbbcf73ae526
# Parent 5a282dbf8fad7c47b1a8369eeb82d82f88e76f06# Parent 06debbf8dd759a48a0cd795e78d15ba124f3ed4a
Merging branches. Revision 2^10! :D
diff -r 06debbf8dd75 -r 722f4beeceb6 includes/clientside/static/admin-menu.js
--- a/includes/clientside/static/admin-menu.js Tue Jun 09 03:05:20 2009 -0400
+++ b/includes/clientside/static/admin-menu.js Mon Jun 15 20:10:30 2009 -0400
@@ -40,7 +40,7 @@
var ck = 0;
}
-function tree (a_items, a_template) {
+function tree (a_items, a_template, s_target) {
this.a_tpl = a_template;
this.a_config = a_items;
@@ -77,8 +77,12 @@
this.n_id = trees.length;
trees[this.n_id] = this;
- for (var i = 0; i < this.a_children.length; i++) {
- document.write(this.a_children[i].init());
+ for (var i = 0; i < this.a_children.length; i++)
+ {
+ if ( s_target )
+ document.getElementById(s_target).innerHTML += this.a_children[i].init();
+ else
+ document.write(this.a_children[i].init());
this.a_children[i].open(false, true);
}
}
diff -r 06debbf8dd75 -r 722f4beeceb6 includes/clientside/static/enano-lib-basic.js
--- a/includes/clientside/static/enano-lib-basic.js Tue Jun 09 03:05:20 2009 -0400
+++ b/includes/clientside/static/enano-lib-basic.js Mon Jun 15 20:10:30 2009 -0400
@@ -210,6 +210,7 @@
_f(e);
}
}
+ onload_hooks = null;
}
var enano_hooks = {};
diff -r 06debbf8dd75 -r 722f4beeceb6 includes/template.php
--- a/includes/template.php Tue Jun 09 03:05:20 2009 -0400
+++ b/includes/template.php Mon Jun 15 20:10:30 2009 -0400
@@ -21,6 +21,7 @@
var $elements = false;
var $page_id = false;
var $namespace = false;
+ var $js_preload = array();
/**
* Page action conditions
@@ -438,6 +439,30 @@
}
/**
+ * Queue a Javascript file to be loaded with the page instead of on demand.
+ * @param mixed Javascript file string or array thereof, extensions are optional
+ * @example
+
+ $template->preload_js(array('jquery', 'jquery-ui'));
+ $template->preload_js('admin-menu.js');
+
+ * @return null
+ */
+
+ function preload_js($filemixed)
+ {
+ if ( is_string($filemixed) )
+ $files = array($filemixed);
+ else if ( is_array($filemixed) )
+ $files = $filemixed;
+ else
+ // :-/
+ return null;
+
+ $this->js_preload = array_values(array_merge($this->js_preload, $files));
+ }
+
+ /**
* Global, only-called-once init. Goes to all themes.
*/
@@ -516,8 +541,40 @@
if ( getConfig('cdn_path') )
{
// we're on a CDN, point to static includes
- // probably should have a way to compress stuff like this before uploading to CDN
+ // CLI javascript compression script: includes/clientside/jscompress.php
$js_head = '';
+
+ if ( !empty($this->js_preload) )
+ {
+ $loadlines = array();
+
+ // make unique
+ foreach ( $this->js_preload as &$script )
+ {
+ $script = preg_replace('/\.js$/', '', $script) . '.js';
+ }
+ $this->js_preload = array_unique($this->js_preload);
+
+ foreach ( $this->js_preload as $script )
+ {
+ $js_head .= "\n ";
+ // special case for l10n: also load strings
+ if ( $script == 'l10n.js' )
+ {
+ global $lang;
+ $js_head .= "\n ";
+ }
+ $loadlines[] = "loaded_components['$script'] = true;";
+ }
+
+ // tell the system that this stuff is already loaded
+ $loadlines = implode("\n ", $loadlines);
+ $js_head .= "\n ";
+ }
+
$js_foot = <<
// This initializes the Javascript runtime when the DOM is ready - not when the page is
@@ -536,11 +593,14 @@
else
{
$cdnpath = cdnPath;
+ $js_head = '';
+
// point to jsres compressor
- $js_head = <<
JSEOF;
+ }
$js_foot = <<
@@ -557,6 +617,22 @@
}
//]]>
JSEOF;
+
+ if ( !empty($this->js_preload) )
+ {
+ foreach ( $this->js_preload as &$script )
+ {
+ $script = preg_replace('/\.js$/', '', $script) . '.js';
+ }
+ $this->js_preload = array_unique($this->js_preload);
+ if ( in_array('l10n.js', $this->js_preload) )
+ {
+ // special case for l10n: also load strings
+ global $lang;
+ $js_foot .= "\n ";
+ }
+ $scripts = implode(',', $this->js_preload);
+ $js_foot .= "\n ";
}
$this->assign_bool(array(
diff -r 06debbf8dd75 -r 722f4beeceb6 plugins/SpecialAdmin.php
--- a/plugins/SpecialAdmin.php Tue Jun 09 03:05:20 2009 -0400
+++ b/plugins/SpecialAdmin.php Mon Jun 15 20:10:30 2009 -0400
@@ -2051,20 +2051,26 @@
{
global $db, $session, $paths, $template, $plugins; // Common objects
global $lang;
+ global $output;
- if($session->auth_level < USER_LEVEL_ADMIN) {
+ if ( $session->auth_level < USER_LEVEL_ADMIN )
+ {
redirect(makeUrlNS('Special', 'Login/'.$paths->page, 'level='.USER_LEVEL_ADMIN), 'Not authorized', 'You need an authorization level of '.USER_LEVEL_ADMIN.' to use this page, your auth level is: ' . $session->auth_level, 0);
exit;
}
else
{
$template->set_theme('admin', 'default');
- $template->add_header('');
+ $template->preload_js('fat');
+ $template->preload_js('ajax');
+ $template->preload_js('l10n');
+ $template->preload_js('jquery');
+ $template->preload_js('jquery-ui');
+ $template->preload_js('autofill');
+ $template->preload_js('admin-menu');
- if( !isset( $_GET['noheaders'] ) )
- {
- $template->header();
- }
+ $output->header();
+
echo $lang->get('adm_page_tagline');
?>
footer();
+ $output->footer();
}
}
diff -r 06debbf8dd75 -r 722f4beeceb6 themes/admin/footer.tpl
--- a/themes/admin/footer.tpl Tue Jun 09 03:05:20 2009 -0400
+++ b/themes/admin/footer.tpl Mon Jun 15 20:10:30 2009 -0400
@@ -38,6 +38,7 @@
+ {JS_FOOTER}