Browse Source

+ Add Jquery load selection (local/auto/cdn) to admin panel
! re-arrange index.template again ... still not happy

Spuds 13 years ago
parent
commit
6f740513ce

+ 4 - 1
Sources/ManageSettings.php

@@ -438,6 +438,9 @@ function ModifyBasicSettings($return_config = false)
 			array('check', 'allow_hideOnline'),
 			array('check', 'titlesEnable'),
 			array('text', 'default_personal_text'),
+		'',
+			// Jquery source
+			array('select', 'jquery_source', array('auto' => $txt['jquery_auto'], 'local' => $txt['jquery_local'], 'cdn' => $txt['jquery_cdn'])),
 		'',
 			// SEO stuff
 			array('check', 'queryless_urls'),
@@ -459,7 +462,7 @@ function ModifyBasicSettings($return_config = false)
 		'',
 			// Option-ish things... miscellaneous sorta.
 			array('check', 'allow_disableAnnounce'),
-			array('check', 'disallow_sendBody'),
+			array('check', 'disallow_sendBody'),	
 	);
 
 	// Get all the time zones.

+ 45 - 28
Themes/default/index.template.php

@@ -73,28 +73,6 @@ function template_init()
 
 	// Set the following variable to true if this theme requires the optional theme strings file to be loaded.
 	$settings['require_theme_strings'] = false;
-
-	// Load the CSS
-	// The ?fin20 part of this link is just here to make sure browsers don't cache it wrongly.
-	loadCSSFile($settings['theme_url'] . '/css/index' . $context['theme_variant'] . '.css?fin20');
-
-	// Some browsers need an extra stylesheet due to bugs/compatibility issues.
-	foreach (array('ie7', 'ie6', 'webkit') as $cssfix)
-		if (isBrowser('is_' . $cssfix))
-			loadCSSFile($settings['default_theme_url'] . '/css/' . $cssfix . '.css');
-
-	// RTL languages require an additional stylesheet.
-	if (!empty($context['right_to_left']))
-		loadCSSFile($settings['theme_url'] . '/css/rtl.css');
-
-	// Now load the JS
-	// Note that the Superfish function seems to like being called by the full syntax.
-	// It doesn't appear to like being called by short syntax. Please test if contemplating changes.
-	loadJavascriptFile($settings['theme_url'] . '/scripts/jquery-1.6.4.min.js');
-	loadJavascriptFile($settings['theme_url'] . '/scripts/hoverIntent.js');
-	loadJavascriptFile($settings['theme_url'] . '/scripts/superfish.js');
-	loadJavascriptFile($settings['default_theme_url'] . '/scripts/script.js?fin20');
-	loadJavascriptFile($settings['theme_url'] . '/scripts/theme.js?fin20');
 }
 
 /**
@@ -109,10 +87,48 @@ function template_html_above()
 <html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>
 <head>';
 
+	// The ?fin20 part of this link is just here to make sure browsers don't cache it wrongly.
+	echo '
+	<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?fin20" />';
+
+	// Some browsers need an extra stylesheet due to bugs/compatibility issues.
+	foreach (array('ie7', 'ie6', 'webkit') as $cssfix)
+		if ($context['browser']['is_' . $cssfix])
+			echo '
+	<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/', $cssfix, '.css" />';
+
+	// RTL languages require an additional stylesheet.
+	if ($context['right_to_left'])
+		echo '
+	<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/rtl.css" />';
+
+	// load in any css from mods or themes so they can overwrite if wanted
 	template_css();
 
+	// Jquery Librarys
+	if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn')
+		echo '
+	<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>';
+	elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local')
+		echo '
+	<script type="text/javascript" src="', $settings['theme_url'], '/scripts/jquery-1.7.1.min.js"></script>';
+	else
+		echo '
+	<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
+	<script type="text/javascript"><!-- // --><![CDATA[
+		window.jQuery || document.write(\'<script src="', $settings['theme_url'], '/scripts/jquery-1.7.1.min.js"><\/script>\');
+	// ]]></script>';
+    
+	// Note that the Superfish function seems to like being called by the full syntax.
+	// It doesn't appear to like being called by short syntax. Please test if contemplating changes.
+	echo '
+	<script type="text/javascript" src="', $settings['theme_url'], '/scripts/hoverIntent.js"></script>
+	<script type="text/javascript" src="', $settings['theme_url'], '/scripts/superfish.js"></script>';
+	
 	// Here comes the JavaScript bits!
 	echo '
+	<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js?fin20"></script>
+	<script type="text/javascript" src="', $settings['theme_url'], '/scripts/theme.js?fin20"></script>
 	<script type="text/javascript"><!-- // --><![CDATA[
 		var smf_theme_url = "', $settings['theme_url'], '";
 		var smf_default_theme_url = "', $settings['default_theme_url'], '";
@@ -133,15 +149,16 @@ function template_html_above()
 		var ajax_notification_cancel_text = "', $txt['modify_cancel'], '";
 	// ]]></script>';
 
-	template_javascript();
-	
 	echo '
 	<script type="text/javascript"><!-- // --><![CDATA[
-			$(document).ready(function() { 
-				$("ul.dropmenu").superfish(); 
-			});
+		$(document).ready(function() { 
+			$("ul.dropmenu").superfish(); 
+		});
 	// ]]></script>';
-
+		
+	// load in any javascript files from mods and themes
+	template_javascript();
+		
 	echo '
 	<meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
 	<meta name="description" content="', $context['page_title_html_safe'], '" />', !empty($context['meta_keywords']) ? '

+ 1 - 0
Themes/default/languages/Help.english.php

@@ -283,6 +283,7 @@ $helptxt['enableErrorLogging'] = 'This will log any errors, like a failed login,
 $helptxt['enableErrorQueryLogging'] = 'This will include the full query sent to the database in the error log.  Requires error logging to be turned on.<br /><br /><strong>Note:  This will affect the ability to filter the error log by the error message.</strong>';
 $helptxt['allow_disableAnnounce'] = 'This will allow users to opt out of notification of topics you announce by checking the &quot;announce topic&quot; checkbox when posting.';
 $helptxt['disallow_sendBody'] = 'This option removes the option to receive the text of replies and posts in notification emails.<br /><br />Often, members will reply to the notification email, which in most cases means the webmaster receives the reply.';
+$helptxt['jquery_source'] = 'This will determine the source used to load the Jquery Library.  Auto will use the CDN first and if not available fall back to the local source.  Local will only use the local source, CDN will only load it from Googles CDN network';
 $helptxt['compactTopicPagesEnable'] = 'This will just show a selection of the number of pages.<br /><em>Example:</em>
 		&quot;3&quot; to display: 1 ... 4 [5] 6 ... 9 <br />
 		&quot;5&quot; to display: 1 ... 3 4 [5] 6 7 ... 9';

+ 4 - 0
Themes/default/languages/ManageSettings.english.php

@@ -57,6 +57,10 @@ $txt['autoOptMaxOnline'] = 'Maximum users online when optimizing<div class="smal
 $txt['autoFixDatabase'] = 'Automatically fix broken tables';
 $txt['allow_disableAnnounce'] = 'Allow users to disable announcements';
 $txt['disallow_sendBody'] = 'Don\'t allow post text in notifications';
+$txt['jquery_source'] = 'Source for the Jquery Library';
+$txt['jquery_local'] = 'Local';
+$txt['jquery_cdn'] = 'Google CDN';
+$txt['jquery_auto'] = 'Auto';
 $txt['queryless_urls'] = 'Search engine friendly URLs<div class="smalltext"><strong>Apache/Lighttpd only!</strong></div>';
 $txt['max_image_width'] = 'Max width of posted pictures (0 = disable)';
 $txt['max_image_height'] = 'Max height of posted pictures (0 = disable)';