[#263] Refactor: move top menu logic to ApplicationHelper
This commit is contained in:
parent
3e87af38d4
commit
1897459b76
|
@ -962,7 +962,39 @@ module ApplicationHelper
|
|||
|
||||
javascript_tag("jQuery.menu_expand({ menuItem: '.#{current_menu_class}' });")
|
||||
end
|
||||
|
||||
|
||||
# Menu items for the main top menu
|
||||
def main_top_menu_items
|
||||
split_top_menu_into_main_or_more_menus[:main]
|
||||
end
|
||||
|
||||
# Menu items for the more top menu
|
||||
def more_top_menu_items
|
||||
split_top_menu_into_main_or_more_menus[:more]
|
||||
end
|
||||
|
||||
# Split the :top_menu into separate :main and :more items
|
||||
def split_top_menu_into_main_or_more_menus
|
||||
unless @top_menu_split
|
||||
items_for_main_level = []
|
||||
items_for_more_level = []
|
||||
menu_items_for(:top_menu) do |item|
|
||||
if item.name == :home || item.name == :my_page
|
||||
items_for_main_level << item
|
||||
elsif item.name == :projects
|
||||
# Remove, present in layout
|
||||
else
|
||||
items_for_more_level << item
|
||||
end
|
||||
end
|
||||
@top_menu_split = {
|
||||
:main => items_for_main_level,
|
||||
:more => items_for_more_level
|
||||
}
|
||||
end
|
||||
@top_menu_split
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def wiki_helper
|
||||
|
|
|
@ -41,23 +41,9 @@
|
|||
<% end %>
|
||||
</ul>
|
||||
|
||||
<%
|
||||
items_for_main_level = []
|
||||
items_for_more_level = []
|
||||
menu_items_for(:top_menu) do |item|
|
||||
if item.name == :home || item.name == :my_page
|
||||
items_for_main_level << item
|
||||
elsif item.name == :projects
|
||||
# Remove
|
||||
else
|
||||
items_for_more_level << item
|
||||
end
|
||||
end
|
||||
%>
|
||||
|
||||
<% if User.current.logged? || !Setting.login_required? %>
|
||||
<ul id="account-nav">
|
||||
<% items_for_main_level.each do |item| %>
|
||||
<% main_top_menu_items.each do |item| %>
|
||||
<%= render_menu_node(item) %>
|
||||
<% end %>
|
||||
<li class="drop-down">
|
||||
|
@ -77,7 +63,7 @@
|
|||
<li class="drop-down" id="more-menu">
|
||||
<a class="more" href="#">More</a>
|
||||
<ul style="display:none;">
|
||||
<% items_for_more_level.each do |item| %>
|
||||
<% more_top_menu_items.each do |item| %>
|
||||
<%= render_menu_node(item) %>
|
||||
<% end %>
|
||||
<%# TODO: Redmine defines these in a view, should be moved to a helper or data structure %>
|
||||
|
|
Loading…
Reference in New Issue