1 <% n_files = @required_user_agreements.collect(&:files).flatten(1).count %>
2 <% content_for :page_title do %>
4 <%= @required_user_agreements.first.files.first[1].sub(/\.[a-z]{3,4}$/,'') %>
10 <%= form_for(@required_user_agreements.first, {url: {action: 'sign', controller: 'user_agreements'}}) do |f| %>
11 <%= hidden_field_tag :return_to, request.url %>
12 <div id="open_user_agreement">
13 <div class="alert alert-info">
14 <strong>Please check <%= n_files > 1 ? 'each' : 'the' %> box below</strong> to indicate that you have read and accepted the user agreement<%= 's' if n_files > 1 %>.
16 <% if n_files == 1 and (Rails.configuration.show_user_agreement_inline rescue false) %>
17 <% ua = @required_user_agreements.first; file = ua.files.first %>
18 <object data="<%= url_for(controller: 'collections', action: 'show_file', uuid: ua.uuid, file: "#{file[0]}/#{file[1]}") %>" type="<%= Rack::Mime::MIME_TYPES[file[1].match(/\.\w+$/)[0]] rescue '' %>" width="100%" height="400px">
22 <% @required_user_agreements.each do |ua| %>
23 <% ua.files.each do |file| %>
24 <%= f.label 'checked[]', class: 'checkbox inline' do %>
25 <%= check_box_tag 'checked[]', "#{ua.uuid}/#{file[0]}/#{file[1]}", false %>
26 Accept <%= file[1].sub(/\.[a-z]{3,4}$/,'') %>
27 <%= link_to 'View agreement', {controller: 'collections', action: 'show_file', uuid: ua.uuid, file: "#{file[0]}/#{file[1]}"}, {target: '_blank', class: 'btn btn-mini btn-primary'} %>
32 <div style="height: 1em"></div>
34 <%= f.submit 'Continue', {class: 'btn btn-primary', disabled: true} %>
39 <% content_for :footer_js do %>
40 $('#open_user_agreement input[name="checked[]"]').on('click', function() {
41 var dialog = $('#open_user_agreement')[0]
42 $('input[type=submit]', dialog).prop('disabled',false);
43 $('input[name="checked[]"]', dialog).each(function(){
45 $('input[type=submit]', dialog).prop('disabled',true);