<p>
  <%= select_tag(
    'user[mail_notification]',
    options_for_select(
      user_mail_notification_options(@user), @user.mail_notification),
    :class => 'block',
    :onchange => '$(".mail-notification").hide();$("#" + this.value).show();'
    ) %>
</p>

<%= content_tag 'div', :id => 'selected', :class => 'mail-notification', :style => (@user.mail_notification == 'selected' ? '' : 'display:none;') do %>
  <%= render_project_nested_lists(@user.projects) do |project|
    content_tag('label',
      check_box_tag(
        'user[notified_project_ids][]',
         project.id,
         @user.notified_projects_ids.map{|id| id.to_i}.include?(project.id),
         :id => nil
      ) + ' ' + h(project.name)
    )
  end %>
  <%= hidden_field_tag 'user[notified_project_ids][]', '' %>
  <p><span class="help-block"><%= l(:text_user_mail_option) %></span></p>
<% end %>

<%= content_tag 'div', :id => 'only_my_events', :class => 'mail-notification', :style => (@user.mail_notification == 'only_my_events' ? '' : 'display:none;') do %>
  <p><span class="help-block"><%= l(:text_user_mail_only_my_events) %></span></p>
<% end %>

<%= fields_for :pref, @user.pref do |pref_fields| %>
  <p>
    <%= pref_fields.check_box :no_self_notified %>
    <label for="pref_no_self_notified"><%= l(:label_user_mail_no_self_notified) %></label>
  </p>
  <p>
    <%= pref_fields.check_box :no_notified_if_issue_closing %>
    <label for="pref_no_notified_if_issue_closing"><%= l(:label_user_mail_no_notified_if_issue_closing) %></label>
  </p>
  <p>
    <%= pref_fields.check_box :no_notification_ever %>
    <label for="pref_no_notification_ever"><%= l(:label_user_mail_no_notification_ever) %></label>
  </p>
<% end %>
