From bdec36e7eab9ccb7c72c273ce7ab2c9ae92369f9 Mon Sep 17 00:00:00 2001
From: Eric Davis
<%= f.text_field :cost_per_hour, :size => 7 %>
+<%= f.text_field :cost_per_hour, :size => 7 %>
<%= observe_field('deliverable_cost_per_hour', :function => "new Budget.updateAmounts();") %> -+
<%= f.text_field :total_hours, :size => 7 %> <%= content_tag(:span, 0, :class => "budget-calculation", :id => 'variableCost') %>
<%= observe_field('deliverable_total_hours', :function => "new Budget.updateAmounts();") %> + + <%= observe_field('deliverable_fixed_cost', :function => "new Budget.updateAmounts();") %> + <%= field_with_budget_observer_and_totals(f, :overhead) %> <%= field_with_budget_observer_and_totals(f, :materials) %> <%= field_with_budget_observer_and_totals(f, :profit) %> @@ -122,6 +129,20 @@ Object.extend(BudgetModule.prototype, { } }, + changeType: function() { + if ($('deliverable_type').checked) { + // Fixed + $$('.budget-hourly').each(function(ele) { ele.hide(); }); + $$('.budget-fixed').each(function(ele) { ele.show(); }); + } else { + // Variable + $$('.budget-hourly').each(function(ele) { ele.show(); }); + $$('.budget-fixed').each(function(ele) { ele.hide(); }); + } + + Budget.updateAmounts(); + }, + // Rails-like number_to_currency currency formatting // http://snippets.dzone.com/posts/show/4646 number_to_currency: function (number, options) {