SumOfUs/Champaign

View on GitHub
app/views/plugins/donations_thermometers/_form.slim

Summary

Maintainability
Test Coverage
.col-md-7
  // There's a single ThermometersController that handles both actions and donations thermometers, so use the
  // generic plugins_thermometer_path for the toggle.
  = render partial: 'plugins/shared/toggle_form', locals: { plugin: plugin, path: plugins_thermometer_path(plugin) }

  - name = "plugins_donations_thermometer_#{plugin.id}"
  = form_for plugin, url: plugins_thermometer_path(plugin), remote: true, as: name, html: {class: 'plugin-settings one-form', data: {type: name }} do |f|
    = render "shared/error_messages", target: plugin
    = render "shared/success_message", success: (defined?(success) || false)
    = render 'plugins/shared/plugin_metadata', f: f

    .form-group
      = label_with_tooltip(f, :offset_amount, t('plugins.thermometer.offset'), t('tooltips.thermometer.donations.offset'))
      = number_field_tag :offset_amount, plugin.offset/100, class: 'form-control'
      = f.hidden_field :offset, class: 'offset-in-cents'

  = form_for page, remote: true, html: {class: 'one-form', data: {type: "page" }} do |pf|
    .form-group
      = label_with_tooltip(pf, :fundraising_goal, t('tooltips.fundraising_goal.goal'), t('tooltips.fundraising_goal.formatting'))
      = number_field_tag :fundraising_goal, page.fundraising_goal/100, class: 'form-control'
      = pf.hidden_field :fundraising_goal, class: 'fundraising-goal-in-cents'

javascript:
  $(function () {
    $('#offset_amount').on('change', function(){
      // change the value of the hidden offset-in-cents field to the manually entered offset amount * 100
      $('.offset-in-cents').val($(this).val() * 100);
    })
    $('#fundraising_goal').on('change', function () {

      $('.fundraising-goal-in-cents').val($(this).val() * 100);
    })
  });