Skip to content

Commit 08a1fc7

Browse files
committed
IE 11 compatibility, bugfixes
1 parent 94561d2 commit 08a1fc7

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

FileUploadEmbed.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function redcap_data_entry_form($project_id, $record, $instrument, $event_id, $g
5252

5353
// exit if file type isn't whitelisted in module config or couldn't lookup mime type
5454
if (!in_array($uploadedFileType, $supportedFiletypes) || !$uploadedFileType) {
55-
exit();
55+
$this->exitAfterHook();
5656
}
5757

5858
// generate verification hash
@@ -65,30 +65,31 @@ function redcap_data_entry_form($project_id, $record, $instrument, $event_id, $g
6565

6666
// exit if no valid fields found
6767
if (!count($data)) {
68-
exit();
68+
$this->exitAfterHook();
6969
}
7070
?>
7171
<script>
7272
$(document).ready(function() {
7373
$.each(<?= json_encode($data) ?>, function(field, url) {
74-
let $uploadTr = $(`[sq_id="${field}"]`);
74+
let $uploadTr = $("[sq_id='" + field + "']");
7575

7676
// if field appears on page, add embed
7777
if ($uploadTr.length) {
7878
let embedId = 'fileUploadEmbed_' + field;
7979

80-
$uploadTr.after(`<tr id="${embedId}"></tr>`);
80+
$uploadTr.after("<tr id='" + embedId + "'></tr>");
8181

82-
$('#' + embedId).html(`
83-
<td colspan="2">
84-
<object id="embeddedFile_${field}" data="${url}" style="width:100%;height:800px"></object>
85-
</td>
86-
`);
82+
$('#' + embedId).html(
83+
"<td colspan='2'>" +
84+
"<object id='embeddedFile_" + field + "' data='" + url + "#toolbar=0&navpanes=0&scrollbar=0" + "' style='width:100%;height:800px'></object>" +
85+
"</td>"
86+
);
8787
}
8888
});
8989
});
9090
</script>
91-
<?
91+
<?php
9292
}
9393
}
94-
}
94+
}
95+
?>

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
This module allows File Upload fields to display the uploaded file as an inline embed on a data entry form.
55

66
### Setup
7-
No system-level configuration is required, but you may want to customize the whitelisted file extensions. By default, the only file types that will display as embedded elements are PDF, JPG, JPEG, and PNG. This module has only been tested extensively with PDFs.
7+
No system-level configuration is required, but you may want to customize the whitelisted file extensions. By default, the only file types that will display as embedded elements are PDF, JPG, JPEG, and PNG.
8+
9+
This module has only been tested extensively with PDFs, but most file types compatible with the HTML <object> tag should work as well.
810

911
Once enabled on a project, you need to define which field(s) can be embedded via the project-level configuration. The selected fields must be the "File Upload" type.
1012

index.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@
1313

1414
// set mime type and file contents
1515
header('Content-type: ' . $docInfo[0]);
16-
echo $docInfo[2];
16+
echo $docInfo[2];
17+
18+
?>

0 commit comments

Comments
 (0)