1 <h1>User agreements</h1>
3 <p>You must read and sign all applicable user agreements before continuing.</p>
5 <button data-toggle="modal" href="#open_user_agreement" class="btn btn-primary">Show details</button>
7 <% n_files = @required_user_agreements.collect(&:files).flatten(1).count %>
10 <% content_for :css do %>
11 #open_user_agreement { width: 900px; margin-left: -450px; }
12 #open_user_agreement .modal-body { max-height: 900px; }
16 <div id="open_user_agreement" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="uaModalLabel" aria-hidden="true" data-show="true">
17 <%= form_for(@required_user_agreements.first, {url: {action: 'sign', controller: 'user_agreements'}}) do |f| %>
18 <%= hidden_field_tag :return_to, request.url %>
19 <div class="modal-header">
20 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
21 <h3 id="uaModalLabel">User agreement<%= 's' if n_files != 1 %></h3>
23 <div class="modal-body">
25 <% ua = @required_user_agreements.first; file = ua.files.first %>
26 <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">
29 <div class="alert alert-info">
30 <strong>Please check <%= n_files > 1 ? 'each' : 'the' %> box</strong> to indicate that you have read and accepted the agreement.
32 <div style="margin-left: 4em">
33 <% @required_user_agreements.each do |ua| %>
34 <% ua.files.each do |file| %>
35 <%= f.label 'checked[]', class: 'checkbox inline' do %>
36 <%= check_box_tag 'checked[]', "#{ua.uuid}/#{file[0]}/#{file[1]}", false %>
37 <%= link_to 'open', {controller: 'collections', action: 'show_file', uuid: ua.uuid, file: "#{file[0]}/#{file[1]}"}, {target: '_blank', class: 'label label-info'} %>
44 <div class="modal-footer">
45 <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
46 <%= f.submit 'Accept', {class: 'btn btn-primary', disabled: true} %>
51 <% content_for :footer_js do %>
52 $('#open_user_agreement').modal();
53 $('#open_user_agreement input[name="checked[]"]').on('click', function() {
54 var dialog = $('#open_user_agreement')[0]
55 $('input[type=submit]', dialog).prop('disabled',false);
56 $('input[name="checked[]"]', dialog).each(function(){
58 $('input[type=submit]', dialog).prop('disabled',true);