My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 46 attachment: simpler_navigation_highlight.patch (6.9 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
Index: /home/edmundo/workspace_aptana/substruct_trunk/vendor/plugins/substruct/app/controllers/substruct_application_controller.rb
===================================================================
--- /home/edmundo/workspace_aptana/substruct_trunk/vendor/plugins/substruct/app/controllers/substruct_application_controller.rb (revision 43)
+++ /home/edmundo/workspace_aptana/substruct_trunk/vendor/plugins/substruct/app/controllers/substruct_application_controller.rb (working copy)
@@ -10,30 +10,35 @@
end
end

- def set_substruct_view_defaults
- # TODO - Clean up this messy navigation generation stuff...
- #
- @cname = self.controller_name
- @aname = self.action_name
- # Special handling for the home page...
- if (@cname == 'content_nodes' && @aname == 'show_by_name' && params[:name] == 'home') then
- @cname = 'main'
- end
- # Is this a blog post?
- @blog_post = false
- if (@cname == 'content_nodes' && @content_node) then
- if (@content_node.is_blog_post?) then
- @blog_post = true
- end
- end
- end
-
- # Gets navigation tags for our renderer.
- # Also lets us know if we're in one of our nav tags so
- # we can display the proper header.
- #
- def get_nav_tags
- @main_nav_tags = Tag.find_ordered_parents
+ # Set variables that identifies which tab is active.
+ def set_navigation_tabs
+ @navbar_tags = Tag.find_ordered_parents
+
+ # There is only tree situations where we must highlight tabs, when the home
+ # content node, or index and show_by_tags actions from store are requested.
+ cname = self.controller_name
+ aname = self.action_name
+
+ # Special handling for the home page...
+ if (cname == 'content_nodes' && aname == 'show_by_name' && params[:name] == 'home') then
+ @navbar_active_tab_name = "Home"
+ @navbar_active_tag = nil
+ elsif (cname == 'store' && aname == 'index') then
+ @navbar_active_tab_name = "All Products"
+ @navbar_active_tag = nil
+ elsif (cname == 'store' && aname == 'show_by_tags') then
+ # show_by_tags is NEVER called without a tag, if so it gives an error.
+ used_tag_names = params[:tags]
+ @navbar_active_tab_name = used_tag_names[0]
+ @navbar_active_tag = Tag.find_by_name(used_tag_names[0])
+
+ if @navbar_active_tag.children.count > 0
+ @show_subnavbar = true
+ @subnavbar_active_subtab_name = used_tag_names[1]
+ else
+ @show_subnavbar = false
+ end
+ end
end

# Finds customer if they're logged in or not.
Index: /home/edmundo/workspace_aptana/substruct_trunk/vendor/plugins/substruct/app/helpers/application_helper.rb
===================================================================
--- /home/edmundo/workspace_aptana/substruct_trunk/vendor/plugins/substruct/app/helpers/application_helper.rb (revision 43)
+++ /home/edmundo/workspace_aptana/substruct_trunk/vendor/plugins/substruct/app/helpers/application_helper.rb (working copy)
@@ -63,29 +63,4 @@
return product << '</div>'
end

- # When browsing the store by tags we need to know what
- # is the main "parent" tag or tag group.
- #
- # This lets us display the "active" state in the UI
- #
- def is_main_tab_active?(tab_id)
- if @viewing_tags && @viewing_tags[0].id == tab_id
- @show_subnav = true
- @main_tag_active = Tag.find(tab_id)
- @subnav_tags = @main_tag_active.children
- return true
- end
-
- return false
- end
-
- def is_sub_tab_active?(tab_id)
- if @viewing_tags && @viewing_tags.size > 1 && @viewing_tags[1].id == tab_id
- @show_subnav = true
- return true
- end
-
- return false
- end
Index: /home/edmundo/workspace_aptana/substruct_trunk/vendor/plugins/substruct/app/views/layouts/main.rhtml
===================================================================
--- /home/edmundo/workspace_aptana/substruct_trunk/vendor/plugins/substruct/app/views/layouts/main.rhtml (revision 43)
+++ /home/edmundo/workspace_aptana/substruct_trunk/vendor/plugins/substruct/app/views/layouts/main.rhtml (working copy)
@@ -59,15 +59,19 @@
<div id="navcap_right"></div>
<div id="navigation-inner">
<ul class="navigation">
- <li class="<%= @cname == 'main' ? 'active' : '' %>"><a href="/">Home</a></li>
- <li class="<%= (@cname == 'store' && @aname == 'index') ? 'active' : '' %>"><a href="/store">All Products</a></li>
+ <!-- Activate it if the tab name is ... and a nil tag object was
+ returned, meaning that its not a tag called. -->
+ <li class="<%= (@navbar_active_tab_name == 'Home' && @navbar_active_tag.nil?) ? 'active' : '' %>"><a href="/">Home</a></li>
+ <li class="<%= (@navbar_active_tab_name == 'All Products' && @navbar_active_tag.nil?) ? 'active' : '' %>"><a href="/store">All Products</a></li>
<%
- @main_nav_tags.each_index do |i|
- tag = @main_nav_tags[i]
+ @navbar_tags.each_index do |i|
+ tag = @navbar_tags[i]
%>
+ <!-- Activate it if the tab name is equal the tag name and a valid
+ tag object was returned. -->
<li
- class="<%= is_main_tab_active?(tag.id) ? 'active' : '' %>"
- style="<%= i == @main_nav_tags.size-1 ? 'margin-right: 0px !important;' : '' %>"
+ class="<%= (@navbar_active_tab_name == tag.name && !@navbar_active_tag.nil?) ? 'active' : '' %>"
+ style="<%= i == @navbar_tags.size-1 ? 'margin-right: 0px !important;' : '' %>"
>
<%=
link_to(
@@ -84,11 +88,13 @@
</div>
</div>

- <% if @show_subnav %>
+ <% if @show_subnavbar %>
<div id="subnavigation">
<ul class="navigation">
- <% for tag in @subnav_tags do %>
- <li class="<%= is_sub_tab_active?(tag.id) ? 'active' : '' %>">
+ <% for tag in @navbar_active_tag.children do %>
+ <!-- Activate it if the subtab name is equal the subtag name, theres no
+ tag object to worry about as all subtabs are tags. -->
+ <li class="<%= @subnavbar_active_subtab_name == tag.name ? 'active' : '' %>">
<%=
link_to(
tag.name,
@@ -94,7 +100,7 @@
tag.name,
:controller => 'store',
:action => 'show_by_tags',
- :tags => [@main_tag_active.name, tag.name]
+ :tags => [@navbar_active_tag.name, tag.name]
)
%>
</li>
Index: /home/edmundo/workspace_aptana/substruct_trunk/vendor/plugins/substruct/config/application.rb.example
===================================================================
--- /home/edmundo/workspace_aptana/substruct_trunk/vendor/plugins/substruct/config/application.rb.example (revision 43)
+++ /home/edmundo/workspace_aptana/substruct_trunk/vendor/plugins/substruct/config/application.rb.example (working copy)
@@ -1,6 +1,5 @@
class ApplicationController < ActionController::Base
include SubstructApplicationController
- before_filter :set_substruct_view_defaults
- before_filter :get_nav_tags
+ before_filter :set_navigation_tabs
before_filter :find_customer
end
\ No newline at end of file

Powered by Google Project Hosting