[geeklog-cvs] geeklog: Updated Scripts class to treat common.js as a library
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Fri Mar 4 17:11:29 EST 2011
changeset 8142:68e31072e1e3
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/68e31072e1e3
user: Tom <websitemaster at cogeco.net>
date: Fri Mar 04 17:10:52 2011 -0500
description:
Updated Scripts class to treat common.js as a library
diffstat:
system/classes/scripts.class.php | 37 +++++++++++++++++++++++--------------
1 files changed, 23 insertions(+), 14 deletions(-)
diffs (76 lines):
diff -r 86c6245abc60 -r 68e31072e1e3 system/classes/scripts.class.php
--- a/system/classes/scripts.class.php Fri Mar 04 14:58:16 2011 -0500
+++ b/system/classes/scripts.class.php Fri Mar 04 17:10:52 2011 -0500
@@ -52,7 +52,7 @@
private $scripts; // Array of JavaScript set to be loaded either in the header or footer
- private $restricted_names;
+ private $restricted_names; // Restricted names list for JavaScript files
private $header_set; // Flag to know if Header Code already has been retrieved
private $javascript_set; // Flag to know if ANY JavaScript has been set yet
@@ -84,20 +84,21 @@
$this->jquery_ui_cdn = false;
// Add Theme CSS File
- $this->setCSSFilePrivate('theme',$theme_path . '/style.css');
+ $this->setCSSFilePrivate('theme', $theme_path . '/style.css');
- // Add Geeklog Specific JavaScript files
- $this->setJavaScriptFile('core','/javascript/common.js');
- // Check to see if advanced editor is needed
+ // Find available JavaScript libraries
+ $this->findJavaScriptLibraries();
+
+ // Automatically set Common library since we have not updated core yet to set it when needed
+ $this->setJavaScriptLibrary('common');
+
+ // Check to see if advanced editor is needed, this should be setup as a library at some point like common
if ($_CONF['advanced_editor'] && $_USER['advanced_editor']) {
$this->setJavaScriptFile('fckeditor','/fckeditor/fckeditor.js');
- }
+ }
- // Find available JavaScript libraries
- $this->findJavaScriptLibraries();
-
- // Setup restricted names after setting main libraries (do not want plugins missing with them)
- $this->restricted_names = array('core', 'jquery', 'theme');
+ // Setup restricted names after setting main libraries (do not want plugins messing with them)
+ $this->restricted_names = array('fckeditor', 'core', 'jquery', 'theme');
}
@@ -114,8 +115,14 @@
$theme_path = '/layout/' . $_CONF['theme'];
- // Find available jQuery files
+ // Add Geeklog Specific JavaScript files. Treat them as library files since other plugins may try to load them
+ $name = 'common';
+ $this->library_files[$name]['file'] = 'javascript/common.js';
+ $this->library_files[$name]['load'] = false;
+
+
+ // Find available jQuery library files
$version_jQuery = '1.5.1';
$this->jquery_cdn_file = 'https://ajax.googleapis.com/ajax/libs/jquery/' . $version_jQuery .'/jquery.min.js';
$name = 'jquery';
@@ -184,11 +191,13 @@
global $_CONF;
+ $name = strtolower($name);
+
if (isset($this->library_files[$name])) {
if (!$this->library_files[$name]['load']) {
$this->library_files[$name]['load'] = true;
- // If name something else besides jQuery make sure all libraries are loaded
- if ($name != 'jquery' && !$this->jquery_ui_cdn) {
+ // If name is subset of jQuery.UI make sure all UI libraries are loaded
+ if (substr($name, 0, 10) == 'jquery.ui.' && !$this->jquery_ui_cdn) {
// Check that file exists, if not use Google version
if (!file_exists($_CONF['path'] . 'public_html/' .$this->library_files[$name]['file'])) {
$this->jquery_ui_cdn = true;
More information about the geeklog-cvs
mailing list