Pass project as requirejs config rather than globally
Pass project as requirejs config rather than globally

--- a/js/modules/getproject.js
+++ b/js/modules/getproject.js
@@ -9,10 +9,10 @@
  * @subpackage Javascript
  */
 
-define(
-	function() {
+define(['module'],
+	function(module) {
 		return function() {
-			return GitPHP.Project || null;
+			return module.config().project || null;
 		}
 	}
 );

--- a/templates/jsconst.tpl
+++ b/templates/jsconst.tpl
@@ -19,9 +19,5 @@
 	NoMatchesFound: '{t escape=no}No matches found for "%1"{/t}'
 {rdelim};
 
-{if $project}
-GitPHP.Project = '{$project->GetProject()}';
-{/if}
-		
 </script>
 

--- a/templates/main.tpl
+++ b/templates/main.tpl
@@ -53,6 +53,11 @@
 		'modules/snapshotformats': {ldelim}
 			formats: {ldelim}{foreach from=$snapshotformats key=format item=extension name=formats}"{$format}": "{$extension}"{if !$smarty.foreach.formats.last},{/if}{/foreach}{rdelim}
 		{rdelim},
+		{if $project}
+		'modules/getproject': {ldelim}
+			project: '{$project->GetProject()}'
+		{rdelim},
+		{/if}
 		'modules/geturl': {ldelim}
 			baseurl: '{$baseurl}/'
 		{rdelim}

comments