Refactored arrows. #1274

This commit is contained in:
Eric Davis
2008-06-12 15:41:49 -07:00
parent 60a0539d53
commit 55aa505243
2 changed files with 21 additions and 8 deletions

View File

@@ -43,4 +43,24 @@ module DeliverablesHelper
def l_field(field, prefix='')
l((prefix + field.to_s).to_sym)
end
def toggle_arrows(deliverable_id)
open_js = "$('deliverable-details-#{deliverable_id}').show(); $$('.toggle_#{deliverable_id}').each(function(e) {e.toggle();})"
close_js = "$('deliverable-details-#{deliverable_id}').hide(); $$('.toggle_#{deliverable_id}').each(function(e) {e.toggle();})"
return toggle_arrow(deliverable_id, "toggle-arrow-closed.gif", open_js, false) +
toggle_arrow(deliverable_id, "toggle-arrow-open.gif", close_js, true)
end
def toggle_arrow(deliverable_id, image, js, hide=false)
style = "display:none;" if hide
style ||= ''
content_tag(:span,
link_to_function(image_tag(image, :plugin => "budget_plugin"), js),
:class => "toggle_" + deliverable_id.to_s,
:style => style
)
end
end

View File

@@ -1,14 +1,7 @@
<% css = cycle('odd','even') %>
<tr id="deliverable-<%= deliverable.id %>" class="deliverable <%= css %>">
<td class="actions">
<span class="toggle_<%= deliverable.id -%>">
<%= link_to_function(image_tag("toggle-arrow-closed.gif", :plugin => "budget_plugin"),
"$('deliverable-details-#{deliverable.id}').show(); $$('.toggle_#{deliverable.id}').each(function(e) {e.toggle();})") %>
</span>
<span class="toggle_<%= deliverable.id -%>" style="display:none;">
<%= link_to_function(image_tag("toggle-arrow-open.gif", :plugin => "budget_plugin"),
"$('deliverable-details-#{deliverable.id}').hide(); $$('.toggle_#{deliverable.id}').each(function(e) {e.toggle();})") %>
</span>
<%= toggle_arrows(deliverable.id) %>
</td>
<%= content_tag(:td, deliverable.id) %>