DRY up javascript for form visibility toggling.

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@644 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lukemelia 2007-11-18 08:05:39 +00:00
parent cb648ef141
commit ae95f03c5b
6 changed files with 46 additions and 43 deletions

View file

@ -9,7 +9,17 @@
<div id="input_box">
<div id="context_new_container">
<a id="toggle-new-context-form" href="#" accesskey="n" title="Create a new context">Create new context &#187;</a>
<div id="toggle_context_new" class="hide_form">
<a title="Hide new context form" accesskey="n">&laquo; Hide form</a>
<% apply_behavior '#toggle_context_new a:click', :prevent_default => true do |page|
page << "TracksForm.toggle('toggle_context_new', 'context_new', 'context-form',
'&laquo; Hide form', 'Hide new context form',
'Create a new context &#187;', 'Add a context');"
end
%>
</div>
<div id="context_new" class="context_new" style="display:block">
<% form_remote_tag(
:url => contexts_path,
@ -41,10 +51,4 @@
</div>
<%
sortable_element 'list-contexts', get_listing_sortable_options
apply_behavior '#toggle-new-context-form:click', :prevent_default => true do |page|
page['context_new'].toggle
page['context-form'].down('input').focus
#page << "Form.focusFirstElement('context-form');"
end
-%>

View file

@ -12,10 +12,16 @@
<div id="project_new_project_filler">
<div id="project_new_project_container">
<%= link_to_function("Create a new project &#187;",
"Element.toggle('project_new');Form.focusFirstElement('project-form');",
{:title => "Add a next action", :accesskey => "n"}) %>
<div id="toggle_project_new" class="hide_form">
<a title="Hide new project form" accesskey="n">&laquo; Hide form</a>
<% apply_behavior '#toggle_project_new a:click', :prevent_default => true do |page|
page << "TracksForm.toggle('toggle_project_new', 'project_new', 'project-form',
'&laquo; Hide form', 'Hide new project form',
'Create a new project &#187;', 'Add a project');"
end
%>
</div>
<div id="project_new" class="project_new" style="display:block">
<% form_remote_tag(:url => projects_path, :method => :post,
:html=> { :id=>'project-form', :name=>'project', :class => 'inline-form'},

View file

@ -7,16 +7,15 @@
%>
<div id="todo_new_action_container">
<div id="show_todo_new_action" style="display:none">
<%= link_to_function("Add a next action &#187;",
"todoItems.showNewActionForm();return false;",
{:title => "Add a next action"}) %>
</div>
<div id="hide_todo_new_action" style="display:block">
<%= link_to_function("&laquo; Hide form",
"todoItems.hideNewActionForm();return false;",
{:title => "Hide next action form", :accesskey => "n"}) %>
</div>
<div id="toggle_action_new" class="hide_form">
<a title="Hide new action form" accesskey="n">&laquo; Hide form</a>
<% apply_behavior '#toggle_action_new a:click', :prevent_default => true do |page|
page << "TracksForm.toggle('toggle_action_new', 'todo_new_action', 'todo-form-new-action',
'&laquo; Hide form', 'Hide next action form',
'Add a next action &#187;', 'Add a next action');"
end
%>
</div>
<div id="todo_new_action" style="display:block">