@@ -106,18 +106,18 Redmine::AccessControl.map do |map| | |||||
106 | end |
|
106 | end | |
107 |
|
107 | |||
108 | Redmine::MenuManager.map :top_menu do |menu| |
|
108 | Redmine::MenuManager.map :top_menu do |menu| | |
109 |
menu.push :home, :home_path |
|
109 | menu.push :home, :home_path | |
110 |
menu.push :my_page, { :controller => 'my', :action => 'page' }, |
|
110 | menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? } | |
111 |
menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural |
|
111 | menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural | |
112 |
menu.push :administration, { :controller => 'admin', :action => 'index' |
|
112 | menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true | |
113 |
menu.push :help, Redmine::Info.help_url, |
|
113 | menu.push :help, Redmine::Info.help_url, :last => true | |
114 | end |
|
114 | end | |
115 |
|
115 | |||
116 | Redmine::MenuManager.map :account_menu do |menu| |
|
116 | Redmine::MenuManager.map :account_menu do |menu| | |
117 |
menu.push :login, :signin_path |
|
117 | menu.push :login, :signin_path, :if => Proc.new { !User.current.logged? } | |
118 |
menu.push :register, { :controller => 'account', :action |
|
118 | menu.push :register, { :controller => 'account', :action => 'register' }, :if => Proc.new { !User.current.logged? && Setting.self_registration? } | |
119 |
menu.push :my_account, { :controller => 'my', :action => 'account' }, |
|
119 | menu.push :my_account, { :controller => 'my', :action => 'account' }, :if => Proc.new { User.current.logged? } | |
120 |
menu.push :logout, :signout_path |
|
120 | menu.push :logout, :signout_path, :if => Proc.new { User.current.logged? } | |
121 | end |
|
121 | end | |
122 |
|
122 | |||
123 | Redmine::MenuManager.map :application_menu do |menu| |
|
123 | Redmine::MenuManager.map :application_menu do |menu| |
@@ -72,7 +72,7 module Redmine | |||||
72 | links = [] |
|
72 | links = [] | |
73 | menu_items_for(menu, project) do |item, caption, url, selected| |
|
73 | menu_items_for(menu, project) do |item, caption, url, selected| | |
74 | links << content_tag('li', |
|
74 | links << content_tag('li', | |
75 |
link_to(h(caption), url, |
|
75 | link_to(h(caption), url, item.html_options(:selected => selected))) | |
76 | end |
|
76 | end | |
77 | links.empty? ? nil : content_tag('ul', links.join("\n")) |
|
77 | links.empty? ? nil : content_tag('ul', links.join("\n")) | |
78 | end |
|
78 | end | |
@@ -168,7 +168,7 module Redmine | |||||
168 |
|
168 | |||
169 | class MenuItem |
|
169 | class MenuItem | |
170 | include GLoc |
|
170 | include GLoc | |
171 |
attr_reader :name, :url, :param, :condition |
|
171 | attr_reader :name, :url, :param, :condition | |
172 |
|
172 | |||
173 | def initialize(name, url, options) |
|
173 | def initialize(name, url, options) | |
174 | raise "Invalid option :if for menu item '#{name}'" if options[:if] && !options[:if].respond_to?(:call) |
|
174 | raise "Invalid option :if for menu item '#{name}'" if options[:if] && !options[:if].respond_to?(:call) | |
@@ -179,6 +179,8 module Redmine | |||||
179 | @param = options[:param] || :id |
|
179 | @param = options[:param] || :id | |
180 | @caption = options[:caption] |
|
180 | @caption = options[:caption] | |
181 | @html_options = options[:html] || {} |
|
181 | @html_options = options[:html] || {} | |
|
182 | # Adds a unique class to each menu item based on its name | |||
|
183 | @html_options[:class] = [@html_options[:class], @name.to_s.dasherize].compact.join(' ') | |||
182 | end |
|
184 | end | |
183 |
|
185 | |||
184 | def caption(project=nil) |
|
186 | def caption(project=nil) | |
@@ -191,6 +193,16 module Redmine | |||||
191 | @caption_key ||= (@caption || (l_has_string?("label_#{@name}".to_sym) ? "label_#{@name}".to_sym : @name.to_s.humanize)) |
|
193 | @caption_key ||= (@caption || (l_has_string?("label_#{@name}".to_sym) ? "label_#{@name}".to_sym : @name.to_s.humanize)) | |
192 | end |
|
194 | end | |
193 | end |
|
195 | end | |
|
196 | ||||
|
197 | def html_options(options={}) | |||
|
198 | if options[:selected] | |||
|
199 | o = @html_options.dup | |||
|
200 | o[:class] += ' selected' | |||
|
201 | o | |||
|
202 | else | |||
|
203 | @html_options | |||
|
204 | end | |||
|
205 | end | |||
194 | end |
|
206 | end | |
195 | end |
|
207 | end | |
196 | end |
|
208 | end |
@@ -26,7 +26,7 h2, h3, h4, .wiki h1, .wiki h2, .wiki h3 { border-bottom: 0px; color:#606060; fo | |||||
26 | h2, .wiki h1 { letter-spacing:-1px; } |
|
26 | h2, .wiki h1 { letter-spacing:-1px; } | |
27 | h4 { border-bottom: dotted 1px #c0c0c0; } |
|
27 | h4 { border-bottom: dotted 1px #c0c0c0; } | |
28 |
|
28 | |||
29 | #top-menu a.home, #top-menu a.mypage, #top-menu a.projects, #top-menu a.admin, #top-menu a.help { |
|
29 | #top-menu a.home, #top-menu a.my-page, #top-menu a.projects, #top-menu a.administration, #top-menu a.help { | |
30 | background-position: 0% 40%; |
|
30 | background-position: 0% 40%; | |
31 | background-repeat: no-repeat; |
|
31 | background-repeat: no-repeat; | |
32 | padding-left: 20px; |
|
32 | padding-left: 20px; | |
@@ -35,7 +35,7 h4 { border-bottom: dotted 1px #c0c0c0; } | |||||
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | #top-menu a.home { background-image: url(../../../images/home.png); } |
|
37 | #top-menu a.home { background-image: url(../../../images/home.png); } | |
38 | #top-menu a.mypage { background-image: url(../../../images/user_page.png); } |
|
38 | #top-menu a.my-page { background-image: url(../../../images/user_page.png); } | |
39 | #top-menu a.projects { background-image: url(../../../images/projects.png); } |
|
39 | #top-menu a.projects { background-image: url(../../../images/projects.png); } | |
40 | #top-menu a.admin { background-image: url(../../../images/admin.png); } |
|
40 | #top-menu a.administration { background-image: url(../../../images/admin.png); } | |
41 | #top-menu a.help { background-image: url(../../../images/help.png); } |
|
41 | #top-menu a.help { background-image: url(../../../images/help.png); } |
@@ -234,14 +234,17 class ProjectsControllerTest < Test::Unit::TestCase | |||||
234 |
|
234 | |||
235 | get :show, :id => 1 |
|
235 | get :show, :id => 1 | |
236 | assert_tag :div, :attributes => { :id => 'main-menu' }, |
|
236 | assert_tag :div, :attributes => { :id => 'main-menu' }, | |
237 |
:descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Foo' |
|
237 | :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Foo', | |
|
238 | :attributes => { :class => 'foo' } } } | |||
238 |
|
239 | |||
239 | assert_tag :div, :attributes => { :id => 'main-menu' }, |
|
240 | assert_tag :div, :attributes => { :id => 'main-menu' }, | |
240 |
:descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Bar' |
|
241 | :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Bar', | |
|
242 | :attributes => { :class => 'bar' } }, | |||
241 | :before => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK' } } } |
|
243 | :before => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK' } } } | |
242 |
|
244 | |||
243 | assert_tag :div, :attributes => { :id => 'main-menu' }, |
|
245 | assert_tag :div, :attributes => { :id => 'main-menu' }, | |
244 |
:descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK' |
|
246 | :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK', | |
|
247 | :attributes => { :class => 'hello' } }, | |||
245 | :before => { :tag => 'li', :child => { :tag => 'a', :content => 'Activity' } } } |
|
248 | :before => { :tag => 'li', :child => { :tag => 'a', :content => 'Activity' } } } | |
246 |
|
249 | |||
247 | # Remove the menu items |
|
250 | # Remove the menu items |
General Comments 0
You need to be logged in to leave comments.
Login now