Clean up tree JS a little
[gitphp.git] / js / tree.js
blob:a/js/tree.js -> blob:b/js/tree.js
--- a/js/tree.js
+++ b/js/tree.js
@@ -16,7 +16,7 @@
 	a.addClass('jsTree');
 	a.addClass('expander');
 	return a;
-}
+};
 
 function initTree() {
 	var url = window.location.href.match(/^([^\?]+\/)/);
@@ -29,7 +29,7 @@
 	var expanded = '[–]';
 	var indent = '—';
 
-	$('a.jsTree').each(function() {
+	$('a.treeLink').each(function() {
 		$(this).parent().parent().find('td.expander').append(expanderLink($(this).attr('href'), collapsed));
 	});
 
@@ -73,7 +73,7 @@
 			img.attr('src', url + "images/tree-loader.gif");
 			img.attr('alt', GITPHP_RES_LOADING);
 			img.addClass('treeSpinner');
-			img.appendTo(cell);
+			row.find('a.treeLink').after(img);
 
 			$.get($(this).attr('href'), { o: 'js' },
 			function(data) {
@@ -95,7 +95,7 @@
 					$(this).data('depth', depth);
 
 					var fileCell = $(this).find('td.fileName');
-					var treeLink = $(this).find('a.jsTree');
+					var treeLink = $(this).find('a.treeLink');
 					if (treeLink && (treeLink.size() > 0)) {
 						fileCell.prepend(expanderLink(treeLink.attr('href'), collapsed));
 					} else {
@@ -110,13 +110,13 @@
 				row.after(subRows);
 
 				row.find('a.expander').text(expanded);
-				cell.children('img.treeSpinner').remove();
+				row.find('img.treeSpinner').remove();
 			});
 		}
 
 		return false;
 	});
-}
+};
 
 $(document).ready(function() {
 	initTree();

comments