Commit 723a114425f513e21eaec721f86138b735503adf
- Date: Sun Apr 27 21:22:27 +0000 2008
- Committer: Johan Sørensen (johan@johansorensen.com)
- Author: Johan Sørensen (johan@johansorensen.com)
- Commit SHA1: 723a114425f513e21eaec721f86138b735503adf
- Tree SHA1: 79cdb37cf455339b319dc9ed259fd59717cf617c
Make the menu tabs have a selected class depending on context
Commit diff
| |   |
| 1 | 1 | new-ui: |
| 2 | | * Make the project tabs active styled depending on context |
| 3 | 2 | * Fix menu bottom spacing issue in safari |
| 4 | 3 | * Clone stats graph on repositories#index |
| 5 | 4 | * divergence from mainline in +/- |
| toggle raw diff |
--- a/TODO.txt
+++ b/TODO.txt
@@ -1,5 +1,4 @@
new-ui:
-* Make the project tabs active styled depending on context
* Fix menu bottom spacing issue in safari
* Clone stats graph on repositories#index
* divergence from mainline in +/- |
| |   |
| 38 | 38 | end |
| 39 | 39 | end |
| 40 | 40 | |
| 41 | def submenu_selected_class_if_current?(section) |
| 42 | case section |
| 43 | when :overview |
| 44 | if %w[projects].include?(controller.controller_name ) |
| 45 | return "selected" |
| 46 | end |
| 47 | when :repositories |
| 48 | if %w[repositories trees logs commits comitters comments merge_requests |
| 49 | blobs committers].include?(controller.controller_name ) |
| 50 | return "selected" |
| 51 | end |
| 52 | end |
| 53 | end |
| 54 | |
| 41 | 55 | def link_to_with_selected(name, options = {}, html_options = nil) |
| 42 | 56 | html_options = current_page?(options) ? {:class => "selected"} : nil |
| 43 | 57 | link_to(name, options = {}, html_options) |
| toggle raw diff |
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -38,6 +38,20 @@ module ApplicationHelper
end
end
+ def submenu_selected_class_if_current?(section)
+ case section
+ when :overview
+ if %w[projects].include?(controller.controller_name )
+ return "selected"
+ end
+ when :repositories
+ if %w[repositories trees logs commits comitters comments merge_requests
+ blobs committers].include?(controller.controller_name )
+ return "selected"
+ end
+ end
+ end
+
def link_to_with_selected(name, options = {}, html_options = nil)
html_options = current_page?(options) ? {:class => "selected"} : nil
link_to(name, options = {}, html_options) |
| |   |
| 50 | 50 | <% if @project -%> |
| 51 | 51 | <h2 id="project_title"><%= link_to h(@project.title), @project -%></h2> |
| 52 | 52 | <ul id="submenu"> |
| 53 | | <li class="selected"><%= link_to "Overview", project_path(@project), :class => "round-tl-5 round-tr-5" -%></li> |
| 54 | | <li><%= link_to "Repositories", project_repositories_path(@project), :class => "round-tl-5 round-tr-5" -%></li> |
| 53 | <li class="<%= submenu_selected_class_if_current?(:overview) -%>"> |
| 54 | <%= link_to "Project Overview", |
| 55 | project_path(@project), :class => "round-tl-5 round-tr-5" -%> |
| 56 | </li> |
| 57 | <li class="<%= submenu_selected_class_if_current?(:repositories) -%>"> |
| 58 | <%= link_to "Repositories", |
| 59 | project_repositories_path(@project), :class => "round-tl-5 round-tr-5" -%> |
| 60 | </li> |
| 55 | 61 | </ul> |
| 56 | 62 | <% end -%> |
| 57 | 63 | </div> |
| toggle raw diff |
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -50,8 +50,14 @@
<% if @project -%>
<h2 id="project_title"><%= link_to h(@project.title), @project -%></h2>
<ul id="submenu">
- <li class="selected"><%= link_to "Overview", project_path(@project), :class => "round-tl-5 round-tr-5" -%></li>
- <li><%= link_to "Repositories", project_repositories_path(@project), :class => "round-tl-5 round-tr-5" -%></li>
+ <li class="<%= submenu_selected_class_if_current?(:overview) -%>">
+ <%= link_to "Project Overview",
+ project_path(@project), :class => "round-tl-5 round-tr-5" -%>
+ </li>
+ <li class="<%= submenu_selected_class_if_current?(:repositories) -%>">
+ <%= link_to "Repositories",
+ project_repositories_path(@project), :class => "round-tl-5 round-tr-5" -%>
+ </li>
</ul>
<% end -%>
</div> |