mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
The previous commit assigned the accesskey 'n' to the notes page, which was already assigned to create a new note. I've changed it to 'o'.
I also realised that I was making things much more difficult than they needed to be when checking whether the current page matched a particular link, so I altered the navigation_link method to simplify it. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@225 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
959c2c2f53
commit
330133ef03
2 changed files with 5 additions and 12 deletions
|
|
@ -34,19 +34,10 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
# Replicates the link_to method but also checks request.request_uri to find
|
# Replicates the link_to method but also checks request.request_uri to find
|
||||||
# current page. If that matches the name parameter, the link is marked
|
# current page. If that matches the url, the link is marked
|
||||||
# id = "current"
|
# id = "current"
|
||||||
#
|
#
|
||||||
def navigation_link(name, options = {}, html_options = nil, *parameters_for_method_reference)
|
def navigation_link(name, options = {}, html_options = nil, *parameters_for_method_reference)
|
||||||
curr_path = request.request_uri.to_s
|
|
||||||
if curr_path =~ /([a-z]+)$/
|
|
||||||
curr_page = $&
|
|
||||||
elsif curr_path == "/"
|
|
||||||
curr_page = "home"
|
|
||||||
end
|
|
||||||
|
|
||||||
id_tag = (curr_page == name.downcase) ? " id=\"current\"" : ""
|
|
||||||
|
|
||||||
if html_options
|
if html_options
|
||||||
html_options = html_options.stringify_keys
|
html_options = html_options.stringify_keys
|
||||||
convert_options_to_javascript!(html_options)
|
convert_options_to_javascript!(html_options)
|
||||||
|
|
@ -54,7 +45,9 @@ module ApplicationHelper
|
||||||
else
|
else
|
||||||
tag_options = nil
|
tag_options = nil
|
||||||
end
|
end
|
||||||
url = options.is_a?(String) ? options : self.url_for(options, *parameters_for_method_reference)
|
url = options.is_a?(String) ? options : self.url_for(options, *parameters_for_method_reference)
|
||||||
|
id_tag = (request.request_uri == url) ? " id=\"current\"" : ""
|
||||||
|
|
||||||
"<a href=\"#{url}\"#{tag_options}#{id_tag}>#{name || url}</a>"
|
"<a href=\"#{url}\"#{tag_options}#{id_tag}>#{name || url}</a>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
<li><%= navigation_link( "Contexts", {:controller => "context", :action => "list"}, {:accesskey=>"c", :title=>"Contexts"} ) %></li>
|
<li><%= navigation_link( "Contexts", {:controller => "context", :action => "list"}, {:accesskey=>"c", :title=>"Contexts"} ) %></li>
|
||||||
<li><%= navigation_link( "Projects", {:controller => "project", :action => "list"}, {:accesskey=>"p", :title=>"Projects"} ) %></li>
|
<li><%= navigation_link( "Projects", {:controller => "project", :action => "list"}, {:accesskey=>"p", :title=>"Projects"} ) %></li>
|
||||||
<li><%= navigation_link( "Done", {:controller => "todo", :action => "completed"}, {:accesskey=>"d", :title=>"Completed"} ) %></li>
|
<li><%= navigation_link( "Done", {:controller => "todo", :action => "completed"}, {:accesskey=>"d", :title=>"Completed"} ) %></li>
|
||||||
<li><%= navigation_link( "Notes", {:controller => "note", :action => "index"}, {:accesskey => "n", :title => "Show all notes"} ) %></li>
|
<li><%= navigation_link( "Notes", {:controller => "note", :action => "index"}, {:accesskey => "o", :title => "Show all notes"} ) %></li>
|
||||||
<li><%= navigation_link( "Preferences", {:controller => "user", :action => "preferences"}, {:accesskey => "u", :title => "Show my preferences"} ) %></li>
|
<li><%= navigation_link( "Preferences", {:controller => "user", :action => "preferences"}, {:accesskey => "u", :title => "Show my preferences"} ) %></li>
|
||||||
<li><a href="javascript:toggleAll('notes','block')" accesskey="S" title="Show all notes">Show</a></li>
|
<li><a href="javascript:toggleAll('notes','block')" accesskey="S" title="Show all notes">Show</a></li>
|
||||||
<li><a href="javascript:toggleAll('notes','none')" accesskey="H" title="Hide all notes">Hide</a></li>
|
<li><a href="javascript:toggleAll('notes','none')" accesskey="H" title="Hide all notes">Hide</a></li>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue