Browse Source

Merged template_javascript and template_javascript_vars (the second never called) and moved to Subs.php because it's useless to have those functions repeated in each and every theme - Thanks marcusforsberg for the suggestion

Signed-off-by: emanuele <[email protected]>
emanuele 12 years ago
parent
commit
d0452d5866
2 changed files with 45 additions and 45 deletions
  1. 45 0
      Sources/Subs.php
  2. 0 45
      Themes/default/index.template.php

+ 45 - 0
Sources/Subs.php

@@ -3223,6 +3223,51 @@ function template_footer()
 
 }
 
+/**
+ * Output the Javascript files
+ */
+function template_javascript($do_defered = false)
+{
+	global $context;
+
+	// Use this hook to minify/optimize Javascript files
+	call_integration_hook('pre_javascript_output');
+
+	foreach ($context['javascript_files'] as $filename => $options)
+		if ((!$do_defered && empty($options['defer'])) || ($do_defered && !empty($options['defer'])))
+			echo '
+		<script type="text/javascript" src="', $filename, '"></script>';
+
+	if (!empty($context['javascript_vars']))
+	{
+		echo '
+		<script type="text/javascript"><!-- // --><![CDATA[';
+
+		foreach ($context['javascript_vars'] as $key => $value)
+			echo '
+			var ', $key, ' = ', $value;
+
+		echo '
+		// ]]></script>';
+
+	}
+}
+
+/**
+ * Output the CSS files
+ */
+function template_css()
+{
+	global $context;
+
+	// Use this hook to minify/optimize CSS files
+	call_integration_hook('pre_css_output');
+
+	foreach ($context['css_files'] as $filename => $options)
+		echo '
+	<link rel="stylesheet" type="text/css" href="', $filename, '" />';
+}
+
 /**
  * Get an attachment's encrypted filename. If $new is true, won't check for file existence.
  * @todo this currently returns the hash if new, and the full filename otherwise.

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

@@ -591,49 +591,4 @@ function template_button_strip($button_strip, $direction = '', $strip_options =
 		</div>';
 }
 
-/**
- * Output the Javascript files
- */
-function template_javascript($do_defered = false)
-{
-	global $context;
-
-	// Use this hook to minify/optimize Javascript files
-	call_integration_hook('pre_javascript_output');
-
-	foreach ($context['javascript_files'] as $filename => $options)
-		if ((!$do_defered && empty($options['defer'])) || ($do_defered && !empty($options['defer'])))
-			echo '
-		<script type="text/javascript" src="', $filename, '"></script>';
-}
-
-/**
- * Output the Javascript vars
- */
-function template_javascript_vars()
-{
-	global $context;
-
-	call_integration_hook('pre_javascript_vars_output');
-
-	foreach ($context['javascript_vars'] as $key => $value)
-		echo '
-		var ', $key, ' = ', $value;
-}
-
-/**
- * Output the CSS files
- */
-function template_css()
-{
-	global $context;
-
-	// Use this hook to minify/optimize CSS files
-	call_integration_hook('pre_css_output');
-
-	foreach ($context['css_files'] as $filename => $options)
-		echo '
-	<link rel="stylesheet" type="text/css" href="', $filename, '" />';
-}
-
 ?>