5 <div class="modal fade" id="add_data_agreement_dialog" name="add_data_agreement_dialog" tabindex="-1" role="dialog" aria-labelledby="addDataAgreementDialog" data-backdrop="static" data-keyboard="false">
6 <div class="modal-dialog modal-lg" role="document">
7 <div class="modal-content">
8 <div class="modal-header">
9 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
10 <h4 class="modal-title" id="addDataAgreementDialog">Modify Data Agreement</h4>
12 <div class="modal-body">
13 <div class="container-fluid">
15 <textarea class="form-control" rows="10" id="data_agreement_text">
20 <div class="modal-footer">
21 <button type="button" class="btn btn-default" data-dismiss="modal" id="data_agreement_cancel_button">Close</button>
22 <button type="button" class="btn btn-primary" name="data_agreement_ok_button" id="data_agreement_ok_button">Submit</button>
30 jQuery(document).ready(function () {
32 jQuery('#data_agreement_ok_button').click(function(){
36 jQuery('#add_data_agreement').click( function() {
37 get_data_agreement(<% $trial_id %>, 'data_agreement_text');
38 jQuery('#add_data_agreement_dialog').modal('show');
41 function add_data_agreement() {
42 var data_agreement_text = jQuery('#data_agreement_text').val();
44 url: '/breeders/trial/add/data_agreement',
45 data: { 'text': data_agreement_text, 'project_id': <% $trial_id %> },
46 success: function(response) {
47 if (response.error) { alert(response.error); }
49 if (response.message) { alert(response.message); }
51 alert("Successfully added a data agreement to this trial.");
53 get_data_agreement(<% $trial_id %>, 'data_agreement_div');
55 error: function(response) {
56 alert("An error occurred storing the data agreement.");
61 function get_data_agreement(project_id, div) {
64 url: '/breeders/trial/data_agreement/get',
65 data: { 'project_id': project_id },
66 success: function(response) {
68 jQuery('#'+div).html(response.text);
71 jQuery('#'+div).html('By default, trial data is provided under the Toronto agreement, as explained in the <a href="/usage_policy">data usage policy</a>.');
73 if (response.message) { alert(response.message); }
75 error: function(response) {
76 alert('An error occurred fetching the data agreement data.');