Don't use custom globals to define javascript modules
Don't use custom globals to define javascript modules

--- a/js/modules/tooltip.commit.js
+++ b/js/modules/tooltip.commit.js
@@ -9,7 +9,7 @@
  * @subpackage Javascript
  */
 
-define(["jquery", "modules/geturl", "modules/getproject", "ext/jquery.qtip.min"],
+define(["jquery", "modules/geturl", "modules/getproject", "qtip"],
 	function($, getUrl, getProject) {
 
 		var url = null;

--- a/js/modules/tooltip.snapshot.js
+++ b/js/modules/tooltip.snapshot.js
@@ -9,7 +9,7 @@
  * @subpackage Javascript
  */
 
-define(["jquery", "ext/jquery.qtip.min"],
+define(["jquery", "qtip"],
 	function($) {
 		
 		function buildTipContent(href) {

--- a/js/modules/tooltip.tag.js
+++ b/js/modules/tooltip.tag.js
@@ -9,7 +9,7 @@
  * @subpackage Javascript
  */
 
-define(["jquery", "modules/geturl", "modules/getproject", "ext/jquery.qtip.min"],
+define(["jquery", "modules/geturl", "modules/getproject", "qtip"],
 	function($, getUrl, getProject) {
 
 		var url = null;

--- a/templates/blob.tpl
+++ b/templates/blob.tpl
@@ -15,13 +15,11 @@
 {/if}
 {/block}
 
-{block name=javascriptpaths}
+{block name=javascript}
+require.deps = ['blob'];
 {if file_exists('js/blob.min.js')}
-GitPHPJSPaths.blob = "blob.min";
+require.paths.blob = "blob.min";
 {/if}
-{/block}
-{block name=javascriptmodules}
-GitPHPJSModules = ['blob'];
 {/block}
 
 {block name=main}

--- a/templates/commitdiff.tpl
+++ b/templates/commitdiff.tpl
@@ -7,13 +7,11 @@
  *}
 {extends file='projectbase.tpl'}
 
-{block name=javascriptpaths}
+{block name=javascript}
+require.deps = ['commitdiff'];
 {if file_exists('js/commitdiff.min.js')}
-GitPHPJSPaths.commitdiff = "commitdiff.min";
+require.paths.commitdiff = "commitdiff.min";
 {/if}
-{/block}
-{block name=javascriptmodules}
-GitPHPJSModules = ['commitdiff'];
 {/block}
 
 {block name=main}

--- a/templates/graph.tpl
+++ b/templates/graph.tpl
@@ -8,20 +8,17 @@
  *}
 {extends file='projectbase.tpl'}
 
-{block name=javascriptpaths}
-GitPHPJSPaths.d3 = "ext/d3.v2.min"
-{if $graphtype=='languagedist' && file_exists('js/languagedist.min.js')}
-GitPHPJSPaths.languagedist = "languagedist.min";
-{elseif $graphtype=='commitactivity' && file_exists('js/commitactivity.min.js')}
-GitPHPJSPaths.commitactivity = "commitactivity.min";
-{/if}
-{/block}
-
-{block name=javascriptmodules}
-{if $graphtype}
-GitPHPJSModules = ['{$graphtype}'];
-{else}
-GitPHPJSModules = ['common'];
+{block name=javascript}
+{if $graphtype=='languagedist'}
+  require.deps = ['languagedist'];
+  {if file_exists('js/languagedist.min.js')}
+  require.paths.languagedist = "languagedist.min";
+  {/if}
+{elseif $graphtype=='commitactivity'}
+  require.deps = ['commitactivity'];
+  {if file_exists('js/commitactivity.min.js')}
+  require.paths.commitactivity = "commitactivity.min";
+  {/if}
 {/if}
 {/block}
 

--- a/templates/main.tpl
+++ b/templates/main.tpl
@@ -35,35 +35,29 @@
     {block name=css}
     {/block}
     {if $javascript}
-    {block name=javascript}
-    <script src="{$baseurl}/js/ext/require.js"></script>
     {include file='jsconst.tpl'}
     <script type="text/javascript">
-    var GitPHPJSPaths = {ldelim}
-    {if $googlejs}
-	jquery: 'https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min'
-    {else}
-	jquery: 'ext/jquery-1.8.1.min'
-    {/if}
+    var require = {ldelim}
+    	baseUrl: GitPHP.BaseUrl + 'js',
+	paths: {ldelim}
+		jquery: [
+			{if $googlejs}
+			'https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min',
+			{/if}
+			'ext/jquery-1.8.1.min'
+		],
+		d3: 'ext/d3.v2.min',
+		qtip: 'ext/jquery.qtip.min'
+	{rdelim}
     {rdelim};
-    {block name=javascriptpaths}
-    {if file_exists('js/common.min.js')}
-    GitPHPJSPaths.common = "common.min";
-    {/if}
+    {block name=javascript}
+      {if file_exists('js/common.min.js')}
+      require.paths.common = 'common.min';
+      {/if}
+      require.deps = ['common'];
     {/block}
-
-    var GitPHPJSModules = null;
-    {block name=javascriptmodules}
-    GitPHPJSModules = ['common'];
-    {/block}
-    require.config({ldelim}
-    	baseUrl: GitPHP.BaseUrl + 'js',
-	paths: GitPHPJSPaths,
-    {rdelim});
-
-    require(GitPHPJSModules);
     </script>
-    {/block}
+    <script type="text/javascript" src="{$baseurl}/js/ext/require.js"></script>
     {/if}
   </head>
   <body>

--- a/templates/projectlist.tpl
+++ b/templates/projectlist.tpl
@@ -7,13 +7,11 @@
  *}
 {extends file='main.tpl'}
 
-{block name=javascriptpaths}
+{block name=javascript}
+require.deps = ['projectlist'];
 {if file_exists('js/projectlist.min.js')}
-GitPHPJSPaths.projectlist = "projectlist.min";
+require.paths.projectlist = "projectlist.min";
 {/if}
-{/block}
-{block name=javascriptmodules}
-GitPHPJSModules = ['projectlist'];
 {/block}
 
 {block name=main}

--- a/templates/tree.tpl
+++ b/templates/tree.tpl
@@ -7,13 +7,11 @@
  *}
 {extends file='projectbase.tpl'}
 
-{block name=javascriptpaths}
+{block name=javascript}
+require.deps = ['tree'];
 {if file_exists('js/tree.min.js')}
-GitPHPJSPaths.tree = "tree.min";
+require.paths.tree = "tree.min";
 {/if}
-{/block}
-{block name=javascriptmodules}
-GitPHPJSModules = ['tree'];
 {/block}
 
 {block name=main}

--- a/util/minify.sh
+++ b/util/minify.sh
@@ -34,7 +34,7 @@
 for i in ${JSDIR}/*${JSEXT}; do
 	echo "Minifying ${i}..."
 	JSMODULE="`basename ${i%$JSEXT}`"
-	java -classpath lib/rhino/js.jar:lib/closure/compiler.jar org.mozilla.javascript.tools.shell.Main lib/requirejs/r.js -o name=${JSMODULE} out=${JSDIR}/${JSMODULE}${MINEXT} baseUrl=${JSDIR} paths.jquery="empty:" exclude="jquery" paths.d3="ext/d3.v2.min" optimize="closure"
+	java -classpath lib/rhino/js.jar:lib/closure/compiler.jar org.mozilla.javascript.tools.shell.Main lib/requirejs/r.js -o name=${JSMODULE} out=${JSDIR}/${JSMODULE}${MINEXT} baseUrl=${JSDIR} paths.jquery="empty:" paths.qtip="ext/jquery.qtip.min" paths.d3="ext/d3.v2.min" optimize="closure"
 done
 
 for i in ${CSSDIR}/*${CSSEXT}; do

comments