Showing 2 changed files with 27 additions and 11 deletions
+5 -1
templates/branches.html.ep
... ...
@@ -18,6 +18,7 @@
18 18
   my $branches;
19 19
   my $branches_count;
20 20
   my $no_merged_branches_count;
21
+  my $base_branch_name;
21 22
   my $merged_branches_count;
22 23
   my $max;
23 24
   
... ...
@@ -78,7 +79,7 @@
78 79
   # List
79 80
   else {
80 81
     # Default branch
81
-    my $base_branch_name = stash('base_branch') || app->manager->default_branch($user, $project);
82
+    $base_branch_name = stash('base_branch') || app->manager->default_branch($user, $project);
82 83
     $base_branch = $git->branch($user, $project, $base_branch_name);
83 84
     
84 85
     # No merged branches
... ...
@@ -93,6 +94,9 @@
93 94
     $no_merged_branches_count = $git->no_merged_branches_count($user, $project);
94 95
     $merged_branches_count = $branches_count - $no_merged_branches_count - 1;
95 96
   }
97
+  
98
+  # Global variable
99
+  stash(rev => $base_branch_name);
96 100
 %>
97 101
 
98 102
 % layout 'common';
+22 -10
templates/include/code_menu.html.ep
... ...
@@ -1,10 +1,9 @@
1 1
 <%
2 2
   my $display = stash('display') || '';
3 3
   my $rev = stash('rev');
4
-  $rev = app->manager->default_branch($user, $project)
5
-    unless defined $rev;
6 4
   my $branches = stash('branches');
7 5
   my $branches_count = app->git->branches_count($user, $project);
6
+  my $default_branch_name = app->manager->default_branch($user, $project);
8 7
   my $tags_count = app->git->tags_count($user, $project);
9 8
 %>
10 9
 
... ...
@@ -12,14 +11,11 @@
12 11
   $(document).ready(function () {
13 12
   
14 13
     % if ($display eq 'files' || $display eq 'commits') {
14
+      % my $type = $display eq 'files' ? 'tree' : 'commits';
15
+      
15 16
       // Switch branches and tags
16 17
       var revs_init = false;
17 18
       $('#rev-btn').on('click', function () {
18
-        $('#rev-popup')
19
-          .css('display', 'block')
20
-          .css('top', '40px')
21
-          .css('left', '0px')
22
-        ;
23 19
         
24 20
         if (!revs_init) {
25 21
           $.get('<%= url_for("/$user/$project/api/revs") %>', function (result) {
... ...
@@ -36,7 +32,7 @@
36 32
               for (var i = 0; i < branch_names.length; i++) {
37 33
                 var branch_name = branch_names[i];
38 34
                 $('#branch-names-list').append(
39
-                  '<li><a ' + style + ' href="<%= url_for("/$user/$project/tree/") %>' + branch_name + '">' + branch_name + '</a></li>'
35
+                  '<li><a ' + style + ' href="<%= url_for("/$user/$project/$type/") %>' + branch_name + '">' + branch_name + '</a></li>'
40 36
                 );
41 37
               }
42 38
             }
... ...
@@ -50,13 +46,25 @@
50 46
               for (var i = 0; i < tag_names.length; i++) {
51 47
                 var tag_name = tag_names[i];
52 48
                 $('#tag-names-list').append(
53
-                  '<li><a ' + style + ' href="<%= url_for("/$user/$project/tree/") %>' + tag_name + '">' + tag_name + '</a></li>'
49
+                  '<li><a ' + style + ' href="<%= url_for("/$user/$project/$type/") %>' + tag_name + '">' + tag_name + '</a></li>'
54 50
                 );
55 51
               }
56 52
             }
53
+            $('#rev-popup')
54
+              .css('display', 'block')
55
+              .css('top', '40px')
56
+              .css('left', '0px')
57
+            ;
57 58
           });
58 59
           revs_init = true;
59 60
         }
61
+        else {
62
+          $('#rev-popup')
63
+            .css('display', 'block')
64
+            .css('top', '40px')
65
+            .css('left', '0px')
66
+          ;
67
+        }
60 68
       });
61 69
 
62 70
       $('#revs-tab a').click(function (e) {
... ...
@@ -106,7 +114,11 @@
106 114
       </li>
107 115
     % }
108 116
     <li class="<%= $display eq 'files' ? 'active' : '' %>">
109
-      <a href="<%= url_for("/$user/$project") %>">Files</a>
117
+      % if ($rev eq $default_branch_name) {
118
+        <a href="<%= url_for("/$user/$project") %>">Files</a>
119
+      % } else {
120
+        <a href="<%= url_for("/$user/$project/tree/$rev") %>">Files</a>
121
+      % }
110 122
     </li>
111 123
     <li class="<%= $display eq 'commits' ? 'active' : '' %>">
112 124
       <a href="<%= url_for("/$user/$project/commits/$rev") %>">Commits</a>