Replace external toggle_notes.js with inline link_to_function.

Cleanup sidebar views and markup
Minor cleanup to make html more valid. 



git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@368 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lukemelia 2006-12-09 07:10:55 +00:00
parent a2b660bd77
commit e43c5b727a
18 changed files with 63 additions and 81 deletions

View file

@ -84,17 +84,6 @@ module TodoHelper
"<a title='" + format_date(due) + "'><span class=\"green\">Show in " + @days.to_s + " days</span></a> "
end
end
def toggle_show_notes( item )
str = "<a href=\"javascript:Element.toggle('"
str << item.id.to_s
str << "')\" class=\"show_notes\" title=\"Show notes\">"
str << image_tag( "blank.png", :width=>"16", :height=>"16", :border=>"0" ) + "</a>"
m_notes = markdown( item.notes )
str << "\n<div class=\"notes\" id=\"" + item.id.to_s + "\" style=\"display:none\">"
str << m_notes + "</div>"
str
end
def calendar_setup( input_field )
date_format = @user.preference.date_format

View file

@ -6,5 +6,5 @@
<div id="input_box">
<%= render :partial => "shared/add_new_item_form" %>
<%= render "shared/sidebar" %>
<%= render "sidebar/sidebar" %>
</div><!-- End of input box -->

View file

@ -78,5 +78,5 @@
</div><!-- End of display_box -->
<div id="input_box">
<%= render "shared/sidebar" %>
<%= render "sidebar/sidebar" %>
</div><!-- End of input box -->

View file

@ -7,7 +7,6 @@
<% end -%>
<%= stylesheet_link_tag "standard" %>
<%= stylesheet_link_tag "print", :media => "print" %>
<%= javascript_include_tag "toggle_notes" %>
<%= javascript_include_tag :defaults %>
<%= javascript_include_tag "selector-addon-v1" %>
<%= stylesheet_link_tag 'calendar-system.css' %>
@ -32,7 +31,10 @@
</h1>
</div>
<div id="minilinks">
<a href="javascript:toggleAll('notes')" accesskey="S" title="Toggle all notes">Toggle notes</a>&nbsp;|&nbsp;
<%= link_to_function("Toggle notes", nil, {:accesskey => "S", :title => "Toggle all notes"}) do |page|
page.select('.notes').each { |e| e.toggle }
end
-%>&nbsp;|&nbsp;
<% if @user.is_admin? -%>
<%= link_to "Add users", :controller => "login", :action => "signup" %>&nbsp;|&nbsp;
<% end -%>

View file

@ -45,5 +45,5 @@
<div id="input_box">
<%= render :partial => "shared/add_new_item_form" %>
<%= render "shared/sidebar" %>
<%= render "sidebar/sidebar" %>
</div><!-- End of input box -->

View file

@ -46,15 +46,15 @@ Event.observe($('todo_project_name'), "click", projectAutoCompleter.activate.bin
<br />
<label for="todo_due">Due</label><br />
<%= text_field("todo", "due", "size" => 10, "class" => "Date", "onFocus" => "Calendar.setup", "tabindex" => 5, "autocomplete" => "off") %>
<%= text_field("todo", "due", "size" => 10, "class" => "Date", "onfocus" => "Calendar.setup", "tabindex" => 5, "autocomplete" => "off") %>
<br /> <label for="todo_show_from">Show from</label><br />
<%= text_field("todo", "show_from", "size" => 10, "class" => "Date", "onFocus" => "Calendar.setup", "tabindex" => 6, "autocomplete" => "off") %><br />
<%= text_field("todo", "show_from", "size" => 10, "class" => "Date", "onfocus" => "Calendar.setup", "tabindex" => 6, "autocomplete" => "off") %><br />
<div id="date-preview" style="display: none;"></div>
<%= source_view_tag( @source_view ) %>
<input type="submit" value="Add item" tabindex="7">
<input type="submit" value="Add item" tabindex="7" />
<% end -%><!--[eoform:todo]-->
<%= observe_field "todo_due",

View file

@ -1,44 +0,0 @@
<h3>Active Projects:</h3>
<ul>
<% for project in @projects.select{|p| p.active? } -%>
<li id="sidebar-project-<%= project.id %>" class="sidebar-project"><%= link_to( sanitize(project.name), { :controller => "project", :action => "show",
:name => urlize(project.name) } ) + " (" + count_undone_todos(project,"actions") + ")" %></li>
<% end -%>
</ul>
<% if @user.preference.show_hidden_projects_in_sidebar %>
<h3>Hidden Projects:</h3>
<ul>
<% for project in @projects.select{|p| p.hidden? } -%>
<li id="sidebar-project-<%= project.id %>" class="sidebar-project"><%= link_to( sanitize(project.name), { :controller => "project", :action => "show", :name => urlize(project.name) } ) + " (" + count_undone_todos(project,"actions") + ")" %></li>
<% end -%>
</ul>
<% end %>
<% if @user.preference.show_completed_projects_in_sidebar %>
<h3>Completed Projects:</h3>
<ul>
<% for project in @projects.select{|p| p.completed? } -%>
<li id="sidebar-project-<%= project.id %>" class="sidebar-project"><%= link_to( sanitize(project.name), { :controller => "project", :action => "show",
:name => urlize(project.name) } ) + " (" + count_undone_todos(project,"actions") + ")" %></li>
<% end -%>
</ul>
<% end %>
<h3>Active Contexts:</h3>
<ul>
<% for context in @contexts.reject{|c| c.hide? } -%>
<li id="sidebar-context-<%= context.id %>" class="sidebar-context"><%= link_to( sanitize(context.name), { :controller => "context", :action => "show",
:name => urlize(context.name) } ) + " (" + count_undone_todos(context,"actions") + ")" %></li>
<% end -%>
</ul>
<% if @user.preference.show_hidden_contexts_in_sidebar %>
<h3>Hidden Contexts:</h3>
<ul>
<% for context in @contexts.reject{|c| !c.hide? } -%>
<li id="sidebar-context-<%= context.id %>" class="sidebar-context"><%= link_to( sanitize(context.name), { :controller => "context", :action => "show",
:name => urlize(context.name) } ) + " (" + count_undone_todos(context,"actions") + ")" %></li>
<% end -%>
</ul>
<% end %>

View file

@ -0,0 +1 @@
<li><%= link_to( sanitize(context.name), { :controller => "context", :action => "show", :name => urlize(context.name) } ) + " (" + count_undone_todos(context,"actions") + ")"%></li>

View file

@ -0,0 +1,8 @@
<h3><%= list_name %></h3>
<ul>
<% if contexts.empty? -%>
<li>None</li>
<% else -%>
<%= render :partial => "sidebar/context", :collection => contexts -%>
<% end -%>
</ul>

View file

@ -0,0 +1 @@
<li><%= link_to( sanitize(project.name), { :controller => "project", :action => "show", :name => urlize(project.name) } ) + " (" + count_undone_todos(project,"actions") + ")" %></li>

View file

@ -0,0 +1,8 @@
<h3><%= list_name %></h3>
<ul>
<% if projects.empty? %>
<li>None</li>
<% else %>
<%= render :partial => "sidebar/project", :collection => projects %>
<% end %>
</ul>

View file

@ -0,0 +1,29 @@
<div id="sidebar">
<%= render :partial => "sidebar/project_list",
:locals => { :list_name => 'Active Projects',
:projects => @projects.select{|p| p.active? } } -%>
<% if @user.preference.show_hidden_projects_in_sidebar -%>
<%= render :partial => "sidebar/project_list",
:locals => { :list_name => 'Hidden Projects',
:projects => @projects.select{|p| p.hidden? } } -%>
<% end -%>
<% if @user.preference.show_completed_projects_in_sidebar -%>
<%= render :partial => "sidebar/project_list",
:locals => { :list_name => 'Completed Projects',
:projects => @projects.select{|p| p.completed? } } -%>
<% end -%>
<%= render :partial => "sidebar/context_list",
:locals => { :list_name => 'Active Contexts',
:contexts => @contexts.reject{|c| c.hide? } } -%>
<% if @user.preference.show_hidden_contexts_in_sidebar -%>
<%= render :partial => "sidebar/context_list",
:locals => { :list_name => 'Hidden Contexts',
:contexts => @contexts.select{|c| c.hide? } } -%>
<% end -%>
</div>

View file

@ -15,7 +15,7 @@
<% end %>
<% if done.notes? -%>
<%= toggle_show_notes( done ) %>
<%= render :partial => "todo/toggle_notes", :locals => { :item => done } %>
<% end -%>
</td>
<% end %>

View file

@ -36,11 +36,11 @@
</tr>
<tr>
<td class="label"><label for="item_due">Due</td>
<td><input name="item[due]" id="due_<%= @item.id %>" type="text" value="<%= format_date(@item.due) %>" tabindex="5" size="10" onFocus="Calendar.setup" autocomplete="off" class="Date" /></td>
<td><input name="item[due]" id="due_<%= @item.id %>" type="text" value="<%= format_date(@item.due) %>" tabindex="5" size="10" onfocus="Calendar.setup" autocomplete="off" class="Date" /></td>
</tr>
<tr>
<td class="label"><label for="item_show_from">Show from</td>
<td><input name="item[show_from]" id="show_from_<%= @item.id %>" type="text" value="<%= format_date(@item.show_from) %>" tabindex="5" size="10" onFocus="Calendar.setup" autocomplete="off" class="Date" /></td>
<td><input name="item[show_from]" id="show_from_<%= @item.id %>" type="text" value="<%= format_date(@item.show_from) %>" tabindex="5" size="10" onfocus="Calendar.setup" autocomplete="off" class="Date" /></td>
</tr>
<% if controller.controller_name == "project" || @item.deferred? -%>
<input type="hidden" name="on_project_page" value="true" />

View file

@ -35,7 +35,7 @@
<% end -%>
<% if item.notes? -%>
<%= toggle_show_notes( item ) %>
<%= render :partial => "todo/toggle_notes", :locals => { :item => item } %>
<% end -%>
</div>
</div><!-- [end:item-item.id] -->

View file

@ -10,5 +10,5 @@
<div id="input_box">
<%= render :partial => "shared/add_new_item_form" %>
<%= render "shared/sidebar" %>
<%= render "sidebar/sidebar" %>
</div><!-- End of input box -->

View file

@ -17,5 +17,5 @@
<div id="input_box">
<%= render :partial => "shared/add_new_item_form" %>
<%= render "shared/sidebar" %>
<%= render "sidebar/sidebar" %>
</div><!-- End of input box -->

View file

@ -1,12 +0,0 @@
function toggleAll(className) {
document.getElementsByClassName(className).each(function(elem){
if (elem.style.display == 'block')
{
elem.style.display = 'none';
}
else
{
elem.style.display = 'block';
}
});
}