feature: display pdf attachments inline

This commit is contained in:
Gary Sharp
2026-01-26 16:34:26 +11:00
parent f807d75162
commit 204d57a4a5
15 changed files with 6285 additions and 274 deletions
@@ -56,7 +56,19 @@
<script type="text/javascript">
Shadowbox.init({
skipSetup: true,
modal: true
modal: true,
onOpen: function (obj) {
if (obj.player === 'iframe' && obj.content.indexOf('inline=True') === -1) {
obj.content += (obj.content.indexOf('?') === -1 ? '?' : '&') + 'inline=True';
}
return true;
},
onChange: function (obj) {
if (obj.player === 'iframe' && obj.content.indexOf('inline=True') === -1) {
obj.content += (obj.content.indexOf('?') === -1 ? '?' : '&') + 'inline=True';
}
return true;
}
});
$(function () {
const $Attachments = $('#Attachments');
@@ -117,6 +129,8 @@
e.show('slow');
if (a.MimeType.toLowerCase().indexOf('image/') == 0)
e.shadowbox({ gallery: 'attachments', player: 'img', title: a.Description });
else if (a.MimeType.toLowerCase().indexOf('application/pdf') == 0 && navigator.pdfViewerEnabled)
e.shadowbox({ gallery: 'attachments', player: 'iframe', title: a.Description });
else
e.click(onDownload);
@@ -171,7 +185,7 @@
a.hide(300).delay(300).queue(function () {
var $this = $(this);
if ($this.attr('data-mimetype').toLowerCase().indexOf('image/') == 0)
if (this['shadowboxCacheKey'])
Shadowbox.removeCache(this);
$this.find('.timestamp').livestamp('destroy');
$this.remove();
@@ -337,6 +351,8 @@
$this = $(this);
if ($this.attr('data-mimetype').toLowerCase().indexOf('image/') == 0)
$this.shadowbox({ gallery: 'attachments', player: 'img', title: $this.find('.comments').text() });
else if ($this.attr('data-mimetype').toLowerCase().indexOf('application/pdf') == 0 && navigator.pdfViewerEnabled)
$this.shadowbox({ gallery: 'attachments', player: 'iframe', title: $this.find('.comments').text() });
else
$this.click(onDownload);
});
@@ -491,25 +491,29 @@ WriteLiteral(" </div>\r\n <script");
WriteLiteral(" type=\"text/javascript\"");
WriteLiteral(@">
Shadowbox.init({
skipSetup: true,
modal: true
});
$(function () {
const $Attachments = $('#Attachments');
const $attachmentOutput = $Attachments.find('.attachmentOutput');
let $attachmentDownloadHost = null;
let $dialogRemoveAttachment = null;
let attachmentUploader = null;
function onAttachmentAdded(id, quick) {
var data = { id: id };
$.ajax({
url: '");
WriteLiteral(">\r\n Shadowbox.init({\r\n skipSetu" +
"p: true,\r\n modal: true,\r\n " +
"onOpen: function (obj) {\r\n if (obj.player === \'if" +
"rame\' && obj.content.indexOf(\'inline=True\') === -1) {\r\n " +
" obj.content += (obj.content.indexOf(\'?\') === -1 ? \'?\' : \'&\') + \'inlin" +
"e=True\';\r\n }\r\n ret" +
"urn true;\r\n },\r\n onChange:" +
" function (obj) {\r\n if (obj.player === \'iframe\' &" +
"& obj.content.indexOf(\'inline=True\') === -1) {\r\n " +
" obj.content += (obj.content.indexOf(\'?\') === -1 ? \'?\' : \'&\') + \'inline=True\'" +
";\r\n }\r\n return tru" +
"e;\r\n }\r\n });\r\n " +
" $(function () {\r\n const $Attachments = $(\'#At" +
"tachments\');\r\n const $attachmentOutput = $Attachments" +
".find(\'.attachmentOutput\');\r\n let $attachmentDownload" +
"Host = null;\r\n let $dialogRemoveAttachment = null;\r\n " +
" let attachmentUploader = null;\r\n\r\n " +
" function onAttachmentAdded(id, quick) {\r\n " +
" var data = { id: id };\r\n $.ajax({\r\n " +
" url: \'");
#line 71 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 83 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Url.Action(MVC.API.Device.Attachment()));
@@ -546,39 +550,36 @@ WriteLiteral("\',\r\n dataType: \'json\',\r\n
"href\', \'");
#line 106 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 118 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Url.Action(MVC.API.Device.AttachmentDownload()));
#line default
#line hidden
WriteLiteral(@"/' + a.Id);
e.find('.comments').text(a.Description);
e.find('.author').text(a.Author);
e.find('.timestamp').text(a.TimestampFull).attr('title', a.TimestampFull).livestamp(a.TimestampUnixEpoc);
if (canRemove)
e.find('.remove').click(removeAttachment);
if (!quick)
e.hide();
$attachmentOutput.prepend(e);
onUpdate();
if (!quick)
e.show('slow');
if (a.MimeType.toLowerCase().indexOf('image/') == 0)
e.shadowbox({ gallery: 'attachments', player: 'img', title: a.Description });
else
e.click(onDownload);
// Add Thumbnail
var buildThumbnail = function () {
var retryCount = 0;
var img = e.find('.icon img');
var setThumbnailUrl = function () {
img.attr('src', '");
WriteLiteral("/\' + a.Id);\r\n e.find(\'.comments\').text(a.Descripti" +
"on);\r\n e.find(\'.author\').text(a.Author);\r\n " +
" e.find(\'.timestamp\').text(a.TimestampFull).attr(\'title\'" +
", a.TimestampFull).livestamp(a.TimestampUnixEpoc);\r\n " +
" if (canRemove)\r\n e.find(\'.remove\').click(" +
"removeAttachment);\r\n if (!quick)\r\n " +
" e.hide();\r\n $attachmentOutpu" +
"t.prepend(e);\r\n onUpdate();\r\n " +
" if (!quick)\r\n e.show(\'slow\');\r\n " +
" if (a.MimeType.toLowerCase().indexOf(\'image/\') == " +
"0)\r\n e.shadowbox({ gallery: \'attachments\', pl" +
"ayer: \'img\', title: a.Description });\r\n else if (" +
"a.MimeType.toLowerCase().indexOf(\'application/pdf\') == 0 && navigator.pdfViewerE" +
"nabled)\r\n e.shadowbox({ gallery: \'attachments" +
"\', player: \'iframe\', title: a.Description });\r\n e" +
"lse\r\n e.click(onDownload);\r\n\r\n " +
" // Add Thumbnail\r\n var buildThum" +
"bnail = function () {\r\n var retryCount = 0;\r\n" +
" var img = e.find(\'.icon img\');\r\n\r\n " +
" var setThumbnailUrl = function () {\r\n " +
" img.attr(\'src\', \'");
#line 129 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 143 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Url.Action(MVC.API.Device.AttachmentThumbnail()));
@@ -617,61 +618,60 @@ WriteLiteral("/\' + a.Id + \'?v=\' + retryCount);\r\n
"mentRemoved(id) {\r\n var a = $attachmentOutput.fin" +
"d(\'a[data-attachmentid=\' + id + \']\');\r\n\r\n a.hide(" +
"300).delay(300).queue(function () {\r\n var $th" +
"is = $(this);\r\n if ($this.attr(\'data-mimetype" +
"\').toLowerCase().indexOf(\'image/\') == 0)\r\n " +
" Shadowbox.removeCache(this);\r\n $this.find(\'" +
".timestamp\').livestamp(\'destroy\');\r\n $this.re" +
"move();\r\n onUpdate();\r\n " +
" });\r\n }\r\n\r\n func" +
"tion onUpdate() {\r\n var attachmentCount = $attach" +
"mentOutput.children(\'a\').length;\r\n var tabHeading" +
" = \'Attachments [\' + attachmentCount + \']\';\r\n $(\'" +
"#DeviceDetailTab-ResourcesLink\').text(tabHeading);\r\n " +
"}\r\n\r\n $Attachments\r\n ." +
"find(\'.attachmentInput span.download-all\')\r\n .on(" +
"\'click\', function (event) {\r\n const downloadA" +
"llUrl = $Attachments.attr(\'data-downloadallurl\');\r\n " +
" const id = $Attachments.attr(\'data-id\');\r\n " +
" const $this = $(this);\r\n\r\n if ($this.has" +
"Class(\'fa-spinner\'))\r\n return;\r\n\r\n " +
" $this\r\n .rem" +
"oveClass(\'fa-download\')\r\n .addClass(\'fa-s" +
"pinner fa-spin\');\r\n\r\n if (!$attachmentDownloa" +
"dHost) {\r\n $attachmentDownloadHost = $(\'<" +
"iframe>\')\r\n .attr({ \'id\': \'Attachment" +
"sDownloadHost\', \'name\': \'AttachmentsDownloadHost\', \'title\': \'Attachment Download" +
" Host\' })\r\n .addClass(\'hidden\')\r\n " +
" .appendTo(\'body\')\r\n " +
" .contents();\r\n }\r\n " +
" const $form = $(\'<form>\')\r\n " +
" .attr({\r\n method: " +
"\'POST\',\r\n action: downloadAllUrl,\r\n " +
" target: \'AttachmentsDownloadHost\'\r\n " +
" })\r\n " +
" .append($(\'<input>\')\r\n .attr({ type:" +
" \'hidden\', name: \'__RequestVerificationToken\' })\r\n " +
" .val(document.body.dataset.antiforgery))\r\n " +
" .append($(\'<input>\')\r\n " +
" .attr({ type: \'hidden\', name: \'id\' })\r\n " +
" .val(id))\r\n .appendTo(document.body)" +
"\r\n .trigger(\'submit\');\r\n\r\n " +
" window.setTimeout(function () {\r\n " +
" $this\r\n .removeClass(\'f" +
"a-spinner fa-spin\')\r\n .addClass(\'fa-d" +
"ownload\');\r\n $form.remove();\r\n " +
" }, 2000);\r\n });\r\n\r\n " +
" document.DiscoFunctions.onAttachmentAdded = onAttachmentA" +
"dded;\r\n document.DiscoFunctions.onAttachmentRemoved =" +
" onAttachmentRemoved;\r\n\r\n");
"is = $(this);\r\n if (this[\'shadowboxCacheKey\']" +
")\r\n Shadowbox.removeCache(this);\r\n " +
" $this.find(\'.timestamp\').livestamp(\'destroy\');\r\n " +
" $this.remove();\r\n " +
" onUpdate();\r\n });\r\n " +
" }\r\n\r\n function onUpdate() {\r\n " +
" var attachmentCount = $attachmentOutput.children(\'a\').length;\r\n " +
" var tabHeading = \'Attachments [\' + attachmentCount + " +
"\']\';\r\n $(\'#DeviceDetailTab-ResourcesLink\').text(t" +
"abHeading);\r\n }\r\n\r\n $Attac" +
"hments\r\n .find(\'.attachmentInput span.download-al" +
"l\')\r\n .on(\'click\', function (event) {\r\n " +
" const downloadAllUrl = $Attachments.attr(\'data-downloa" +
"dallurl\');\r\n const id = $Attachments.attr(\'da" +
"ta-id\');\r\n const $this = $(this);\r\n\r\n " +
" if ($this.hasClass(\'fa-spinner\'))\r\n " +
" return;\r\n\r\n $this\r\n " +
" .removeClass(\'fa-download\')\r\n " +
" .addClass(\'fa-spinner fa-spin\');\r\n\r\n " +
" if (!$attachmentDownloadHost) {\r\n " +
" $attachmentDownloadHost = $(\'<iframe>\')\r\n " +
" .attr({ \'id\': \'AttachmentsDownloadHost\', \'name\': \'AttachmentsDow" +
"nloadHost\', \'title\': \'Attachment Download Host\' })\r\n " +
" .addClass(\'hidden\')\r\n " +
" .appendTo(\'body\')\r\n .contents();\r\n " +
" }\r\n const $" +
"form = $(\'<form>\')\r\n .attr({\r\n " +
" method: \'POST\',\r\n " +
" action: downloadAllUrl,\r\n " +
" target: \'AttachmentsDownloadHost\'\r\n })" +
"\r\n .append($(\'<input>\')\r\n " +
" .attr({ type: \'hidden\', name: \'__RequestVerification" +
"Token\' })\r\n .val(document.body.datase" +
"t.antiforgery))\r\n .append($(\'<input>\')\r\n " +
" .attr({ type: \'hidden\', name: \'id\' })" +
"\r\n .val(id))\r\n " +
" .appendTo(document.body)\r\n " +
" .trigger(\'submit\');\r\n\r\n window.setTimeout(" +
"function () {\r\n $this\r\n " +
" .removeClass(\'fa-spinner fa-spin\')\r\n " +
" .addClass(\'fa-download\');\r\n " +
" $form.remove();\r\n }, 2000);\r\n " +
" });\r\n\r\n document.DiscoFu" +
"nctions.onAttachmentAdded = onAttachmentAdded;\r\n docu" +
"ment.DiscoFunctions.onAttachmentRemoved = onAttachmentRemoved;\r\n\r\n");
#line 235 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 249 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line default
#line hidden
#line 235 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 249 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
if (canAddAttachments)
{
@@ -718,7 +718,7 @@ WriteLiteral("\r\n //#region Add Attachments\r\n
" //#endregion\r\n ");
#line 282 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 296 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
}
@@ -727,7 +727,7 @@ WriteLiteral("\r\n //#region Add Attachments\r\n
WriteLiteral(" ");
#line 283 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 297 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
if (canRemoveAnyAttachments || canRemoveOwnAttachments)
{
@@ -770,7 +770,7 @@ WriteLiteral("\r\n //#region Remove Attachments\r\n
" }\r\n //#endregion\r\n ");
#line 334 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 348 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
}
@@ -781,6 +781,8 @@ WriteLiteral(@"
$this = $(this);
if ($this.attr('data-mimetype').toLowerCase().indexOf('image/') == 0)
$this.shadowbox({ gallery: 'attachments', player: 'img', title: $this.find('.comments').text() });
else if ($this.attr('data-mimetype').toLowerCase().indexOf('application/pdf') == 0 && navigator.pdfViewerEnabled)
$this.shadowbox({ gallery: 'attachments', player: 'iframe', title: $this.find('.comments').text() });
else
$this.click(onDownload);
});
@@ -807,7 +809,7 @@ WriteLiteral("></i>&nbsp;Are you sure?\r\n </p>\r\n </div>\r\n <scr
"etailTab-ResourcesLink\">Attachments [");
#line 355 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 371 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Model.Device.DeviceAttachments == null ? 0 : Model.Device.DeviceAttachments.Count);
+18 -2
View File
@@ -289,7 +289,19 @@
<script>
Shadowbox.init({
skipSetup: true,
modal: true
modal: true,
onOpen: function (obj) {
if (obj.player === 'iframe' && obj.content.indexOf('inline=True') === -1) {
obj.content += (obj.content.indexOf('?') === -1 ? '?' : '&') + 'inline=True';
}
return true;
},
onChange: function (obj) {
if (obj.player === 'iframe' && obj.content.indexOf('inline=True') === -1) {
obj.content += (obj.content.indexOf('?') === -1 ? '?' : '&') + 'inline=True';
}
return true;
}
});
if (!document.DiscoFunctions) {
@@ -466,6 +478,8 @@
e.show('slow');
if (a.MimeType.toLowerCase().indexOf('image/') == 0)
e.shadowbox({ gallery: 'attachments', player: 'img', title: a.Description });
else if (a.MimeType.toLowerCase().indexOf('application/pdf') == 0 && navigator.pdfViewerEnabled)
e.shadowbox({ gallery: 'attachments', player: 'iframe', title: a.Description });
else
e.click(onDownload);
@@ -520,7 +534,7 @@
var $element = $attachmentOutput.find('a[data-attachmentid="' + key + '"]');
if ($element.length > 0) {
$element.hide(300).delay(300).queue(function () {
if ($element.attr('data-mimetype').toLowerCase().indexOf('image/') == 0)
if (this['shadowboxCacheKey'])
Shadowbox.removeCache(this);
$element.remove();
document.DiscoFunctions.liveAfterUpdate();
@@ -532,6 +546,8 @@
$this = $(this);
if ($this.attr('data-mimetype').toLowerCase().indexOf('image/') == 0)
$this.shadowbox({ gallery: 'attachments', player: 'img', title: $this.find('.comments').text() });
else if ($this.attr('data-mimetype').toLowerCase().indexOf('application/pdf') == 0 && navigator.pdfViewerEnabled)
$this.shadowbox({ gallery: 'attachments', player: 'iframe', title: $this.find('.comments').text() });
else
$this.click(onDownload);
});
@@ -1008,7 +1008,19 @@ WriteLiteral("\r\n async function loadLiveComment(id) {\r\n\r\n
WriteLiteral(@" <script>
Shadowbox.init({
skipSetup: true,
modal: true
modal: true,
onOpen: function (obj) {
if (obj.player === 'iframe' && obj.content.indexOf('inline=True') === -1) {
obj.content += (obj.content.indexOf('?') === -1 ? '?' : '&') + 'inline=True';
}
return true;
},
onChange: function (obj) {
if (obj.player === 'iframe' && obj.content.indexOf('inline=True') === -1) {
obj.content += (obj.content.indexOf('?') === -1 ? '?' : '&') + 'inline=True';
}
return true;
}
});
if (!document.DiscoFunctions) {
@@ -1019,7 +1031,7 @@ WriteLiteral(@" <script>
var jobId = parseInt('");
#line 300 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 312 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Model.Job.Id);
@@ -1036,13 +1048,13 @@ WriteLiteral(@"');
");
#line 308 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 320 "..\..\Views\Job\JobParts\Resources.cshtml"
#line default
#line hidden
#line 308 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 320 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canAddAttachments)
{
@@ -1080,7 +1092,7 @@ WriteLiteral("\r\n //#region Add Attachments\r\n attachmen
"Tab.resourcesIndex);\r\n });\r\n //#endregion\r\n ");
#line 355 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 367 "..\..\Views\Job\JobParts\Resources.cshtml"
}
@@ -1089,13 +1101,13 @@ WriteLiteral("\r\n //#region Add Attachments\r\n attachmen
WriteLiteral("\r\n");
#line 357 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 369 "..\..\Views\Job\JobParts\Resources.cshtml"
#line default
#line hidden
#line 357 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 369 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canRemoveAnyAttachments || canRemoveOwnAttachments)
{
@@ -1148,7 +1160,7 @@ WriteLiteral("></i>&nbsp;Are you sure?</p></div>\')\r\n .
" }\r\n\r\n //#endregion\r\n\r\n ");
#line 415 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 427 "..\..\Views\Job\JobParts\Resources.cshtml"
}
@@ -1158,7 +1170,7 @@ WriteLiteral("\r\n function addAttachment(key, quick) {\r\n
"id: key };\r\n $.ajax({\r\n url: \'");
#line 420 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 432 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Url.Action(MVC.API.Job.Attachment()));
@@ -1190,7 +1202,7 @@ WriteLiteral("\',\r\n dataType: \'json\',\r\n
"\', \'");
#line 455 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 467 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Url.Action(MVC.API.Job.AttachmentDownload()));
@@ -1210,6 +1222,8 @@ WriteLiteral(@"/' + a.Id);
e.show('slow');
if (a.MimeType.toLowerCase().indexOf('image/') == 0)
e.shadowbox({ gallery: 'attachments', player: 'img', title: a.Description });
else if (a.MimeType.toLowerCase().indexOf('application/pdf') == 0 && navigator.pdfViewerEnabled)
e.shadowbox({ gallery: 'attachments', player: 'iframe', title: a.Description });
else
e.click(onDownload);
@@ -1222,7 +1236,7 @@ WriteLiteral(@"/' + a.Id);
img.attr('src', '");
#line 478 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 492 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Url.Action(MVC.API.Job.AttachmentThumbnail()));
@@ -1255,51 +1269,54 @@ WriteLiteral("/\' + a.Id + \'?v=\' + retryCount);\r\n };\
"key) {\r\n var $element = $attachmentOutput.find(\'a[data-attachment" +
"id=\"\' + key + \'\"]\');\r\n if ($element.length > 0) {\r\n " +
" $element.hide(300).delay(300).queue(function () {\r\n " +
" if ($element.attr(\'data-mimetype\').toLowerCase().indexOf(\'image/\') == 0)\r\n " +
" Shadowbox.removeCache(this);\r\n $el" +
"ement.remove();\r\n document.DiscoFunctions.liveAfterUpdate" +
"();\r\n });\r\n }\r\n }\r\n\r\n $a" +
"ttachmentOutput.children(\'a\').each(function () {\r\n $this = $(this" +
");\r\n if ($this.attr(\'data-mimetype\').toLowerCase().indexOf(\'image" +
"/\') == 0)\r\n $this.shadowbox({ gallery: \'attachments\', player:" +
" \'img\', title: $this.find(\'.comments\').text() });\r\n else\r\n " +
" $this.click(onDownload);\r\n });\r\n\r\n $Attachmen" +
"ts\r\n .find(\'.attachmentInput span.download-all\')\r\n " +
" .on(\'click\', function (event) {\r\n const downloadAllUrl = $At" +
"tachments.attr(\'data-downloadallurl\');\r\n const $this = $(this" +
");\r\n\r\n if ($this.hasClass(\'fa-spinner\'))\r\n " +
" return;\r\n\r\n $this\r\n .removeClass(" +
"\'fa-download\')\r\n .addClass(\'fa-spinner fa-spin\');\r\n\r\n " +
" if (!$attachmentDownloadHost) {\r\n $attach" +
"mentDownloadHost = $(\'<iframe>\')\r\n .attr({ \'id\': \'Att" +
"achmentsDownloadHost\', \'name\': \'AttachmentsDownloadHost\', \'title\': \'Attachment D" +
"ownload Host\' })\r\n .addClass(\'hidden\')\r\n " +
" .appendTo(\'body\')\r\n .contents();\r\n " +
" }\r\n const $form = $(\'<form>\')\r\n " +
" .attr({\r\n method: \'POST\',\r\n " +
" action: downloadAllUrl,\r\n target: \'Attach" +
"mentsDownloadHost\'\r\n })\r\n .append(" +
"$(\'<input>\')\r\n .attr({ type: \'hidden\', name: \'__Reque" +
"stVerificationToken\' })\r\n .val(document.body.dataset." +
"antiforgery))\r\n .appendTo(document.body)\r\n " +
" .trigger(\'submit\');\r\n\r\n window.setTimeout(function (" +
") {\r\n $this\r\n .removeClass(\'fa" +
"-spinner fa-spin\')\r\n .addClass(\'fa-download\');\r\n " +
" $form.remove();\r\n }, 2000);\r\n " +
" });\r\n\r\n // Add Globally Available Functions\r\n document." +
"DiscoFunctions.liveAddAttachment = addAttachment;\r\n document.DiscoFun" +
"ctions.liveRemoveAttachment = removeAttachment;\r\n\r\n //#endregion\r\n " +
" });\r\n\r\n\r\n </script>\r\n");
" if (this[\'shadowboxCacheKey\'])\r\n Shadowbox.removeCac" +
"he(this);\r\n $element.remove();\r\n d" +
"ocument.DiscoFunctions.liveAfterUpdate();\r\n });\r\n " +
" }\r\n }\r\n\r\n $attachmentOutput.children(\'a\').each(functio" +
"n () {\r\n $this = $(this);\r\n if ($this.attr(\'data-m" +
"imetype\').toLowerCase().indexOf(\'image/\') == 0)\r\n $this.shado" +
"wbox({ gallery: \'attachments\', player: \'img\', title: $this.find(\'.comments\').tex" +
"t() });\r\n else if ($this.attr(\'data-mimetype\').toLowerCase().inde" +
"xOf(\'application/pdf\') == 0 && navigator.pdfViewerEnabled)\r\n " +
"$this.shadowbox({ gallery: \'attachments\', player: \'iframe\', title: $this.find(\'." +
"comments\').text() });\r\n else\r\n $this.click(onD" +
"ownload);\r\n });\r\n\r\n $Attachments\r\n .find(\'." +
"attachmentInput span.download-all\')\r\n .on(\'click\', function (even" +
"t) {\r\n const downloadAllUrl = $Attachments.attr(\'data-downloa" +
"dallurl\');\r\n const $this = $(this);\r\n\r\n if" +
" ($this.hasClass(\'fa-spinner\'))\r\n return;\r\n\r\n " +
" $this\r\n .removeClass(\'fa-download\')\r\n " +
" .addClass(\'fa-spinner fa-spin\');\r\n\r\n if (!$attach" +
"mentDownloadHost) {\r\n $attachmentDownloadHost = $(\'<ifram" +
"e>\')\r\n .attr({ \'id\': \'AttachmentsDownloadHost\', \'name" +
"\': \'AttachmentsDownloadHost\', \'title\': \'Attachment Download Host\' })\r\n " +
" .addClass(\'hidden\')\r\n .appendTo(\'bo" +
"dy\')\r\n .contents();\r\n }\r\n " +
" const $form = $(\'<form>\')\r\n .attr({\r\n " +
" method: \'POST\',\r\n action: download" +
"AllUrl,\r\n target: \'AttachmentsDownloadHost\'\r\n " +
" })\r\n .append($(\'<input>\')\r\n " +
" .attr({ type: \'hidden\', name: \'__RequestVerificationToken\' })\r\n " +
" .val(document.body.dataset.antiforgery))\r\n " +
" .appendTo(document.body)\r\n .trigger(\'submit\');" +
"\r\n\r\n window.setTimeout(function () {\r\n " +
" $this\r\n .removeClass(\'fa-spinner fa-spin\')\r\n " +
" .addClass(\'fa-download\');\r\n $form.rem" +
"ove();\r\n }, 2000);\r\n });\r\n\r\n // Add" +
" Globally Available Functions\r\n document.DiscoFunctions.liveAddAttach" +
"ment = addAttachment;\r\n document.DiscoFunctions.liveRemoveAttachment " +
"= removeAttachment;\r\n\r\n //#endregion\r\n });\r\n\r\n\r\n </script>\r" +
"\n");
#line 588 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 604 "..\..\Views\Job\JobParts\Resources.cshtml"
}
#line default
#line hidden
#line 589 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 605 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canShowLogs || canShowAttachments)
{
@@ -1309,7 +1326,7 @@ WriteLiteral("/\' + a.Id + \'?v=\' + retryCount);\r\n };\
WriteLiteral(" <script>\r\n $(function () {\r\n var jobId = parseInt(\'");
#line 593 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 609 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Model.Job.Id);
@@ -1319,7 +1336,7 @@ WriteLiteral("\');\r\n\r\n //#region LiveEvents\r\n var hu
"dates;\r\n\r\n // Map Functions\r\n");
#line 599 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 615 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canShowLogs)
{
@@ -1330,14 +1347,14 @@ WriteLiteral("\r\n hub.client.addLog = document.DiscoFunctions.liveLo
" ");
#line 603 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 619 "..\..\Views\Job\JobParts\Resources.cshtml"
}
#line default
#line hidden
#line 604 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 620 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canShowAttachments)
{
@@ -1358,7 +1375,7 @@ WriteLiteral(@"
");
#line 617 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 633 "..\..\Views\Job\JobParts\Resources.cshtml"
}
@@ -1396,7 +1413,7 @@ WriteLiteral(@"
");
#line 647 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 663 "..\..\Views\Job\JobParts\Resources.cshtml"
}
#line default
@@ -56,7 +56,19 @@
<script type="text/javascript">
Shadowbox.init({
skipSetup: true,
modal: true
modal: true,
onOpen: function (obj) {
if (obj.player === 'iframe' && obj.content.indexOf('inline=True') === -1) {
obj.content += (obj.content.indexOf('?') === -1 ? '?' : '&') + 'inline=True';
}
return true;
},
onChange: function (obj) {
if (obj.player === 'iframe' && obj.content.indexOf('inline=True') === -1) {
obj.content += (obj.content.indexOf('?') === -1 ? '?' : '&') + 'inline=True';
}
return true;
}
});
$(function () {
var $Attachments = $('#Attachments');
@@ -116,6 +128,8 @@
e.show('slow');
if (a.MimeType.toLowerCase().indexOf('image/') == 0)
e.shadowbox({ gallery: 'attachments', player: 'img', title: a.Description });
else if (a.MimeType.toLowerCase().indexOf('application/pdf') == 0 && navigator.pdfViewerEnabled)
e.shadowbox({ gallery: 'attachments', player: 'iframe', title: a.Description });
else
e.click(onDownload);
@@ -170,7 +184,7 @@
a.hide(300).delay(300).queue(function () {
var $this = $(this);
if ($this.attr('data-mimetype').toLowerCase().indexOf('image/') == 0)
if (this['shadowboxCacheKey'])
Shadowbox.removeCache(this);
$this.find('.timestamp').livestamp('destroy');
$this.remove();
@@ -338,6 +352,8 @@
$this = $(this);
if ($this.attr('data-mimetype').toLowerCase().indexOf('image/') == 0)
$this.shadowbox({ gallery: 'attachments', player: 'img', title: $this.find('.comments').text() });
else if ($this.attr('data-mimetype').toLowerCase().indexOf('application/pdf') == 0 && navigator.pdfViewerEnabled)
$this.shadowbox({ gallery: 'attachments', player: 'iframe', title: $this.find('.comments').text() });
else
$this.click(onDownload);
});
@@ -491,25 +491,29 @@ WriteLiteral(" </div>\r\n <script");
WriteLiteral(" type=\"text/javascript\"");
WriteLiteral(@">
Shadowbox.init({
skipSetup: true,
modal: true
});
$(function () {
var $Attachments = $('#Attachments');
var $attachmentOutput = $Attachments.find('.attachmentOutput');
var $dialogRemoveAttachment = null;
let $attachmentDownloadHost = null;
let attachmentUploader = null;
function onAttachmentAdded(id, quick) {
var data = { id: id };
$.ajax({
url: '");
WriteLiteral(">\r\n Shadowbox.init({\r\n skipSetu" +
"p: true,\r\n modal: true,\r\n " +
"onOpen: function (obj) {\r\n if (obj.player === \'if" +
"rame\' && obj.content.indexOf(\'inline=True\') === -1) {\r\n " +
" obj.content += (obj.content.indexOf(\'?\') === -1 ? \'?\' : \'&\') + \'inlin" +
"e=True\';\r\n }\r\n ret" +
"urn true;\r\n },\r\n onChange:" +
" function (obj) {\r\n if (obj.player === \'iframe\' &" +
"& obj.content.indexOf(\'inline=True\') === -1) {\r\n " +
" obj.content += (obj.content.indexOf(\'?\') === -1 ? \'?\' : \'&\') + \'inline=True\'" +
";\r\n }\r\n return tru" +
"e;\r\n }\r\n });\r\n " +
" $(function () {\r\n var $Attachments = $(\'#Atta" +
"chments\');\r\n var $attachmentOutput = $Attachments.fin" +
"d(\'.attachmentOutput\');\r\n var $dialogRemoveAttachment" +
" = null;\r\n let $attachmentDownloadHost = null;\r\n " +
" let attachmentUploader = null;\r\n\r\n " +
" function onAttachmentAdded(id, quick) {\r\n va" +
"r data = { id: id };\r\n $.ajax({\r\n " +
" url: \'");
#line 71 "..\..\Views\User\UserParts\_Resources.cshtml"
#line 83 "..\..\Views\User\UserParts\_Resources.cshtml"
Write(Url.Action(MVC.API.User.Attachment()));
@@ -546,39 +550,36 @@ WriteLiteral("\',\r\n dataType: \'json\',\r\n
"ef\', \'");
#line 105 "..\..\Views\User\UserParts\_Resources.cshtml"
#line 117 "..\..\Views\User\UserParts\_Resources.cshtml"
Write(Url.Action(MVC.API.User.AttachmentDownload()));
#line default
#line hidden
WriteLiteral(@"/' + a.Id);
e.find('.comments').text(a.Description);
e.find('.author').text(a.Author);
e.find('.timestamp').text(a.TimestampFull).attr('title', a.TimestampFull).livestamp(a.TimestampUnixEpoc);
if (canRemove)
e.find('.remove').click(removeAttachment);
if (!quick)
e.hide();
$attachmentOutput.prepend(e);
onUpdate();
if (!quick)
e.show('slow');
if (a.MimeType.toLowerCase().indexOf('image/') == 0)
e.shadowbox({ gallery: 'attachments', player: 'img', title: a.Description });
else
e.click(onDownload);
// Add Thumbnail
var buildThumbnail = function () {
var retryCount = 0;
var img = e.find('.icon img');
var setThumbnailUrl = function () {
img.attr('src', '");
WriteLiteral("/\' + a.Id);\r\n e.find(\'.comments\').text(a.Descripti" +
"on);\r\n e.find(\'.author\').text(a.Author);\r\n " +
" e.find(\'.timestamp\').text(a.TimestampFull).attr(\'title\'" +
", a.TimestampFull).livestamp(a.TimestampUnixEpoc);\r\n " +
" if (canRemove)\r\n e.find(\'.remove\').click(" +
"removeAttachment);\r\n if (!quick)\r\n " +
" e.hide();\r\n $attachmentOutpu" +
"t.prepend(e);\r\n onUpdate();\r\n " +
" if (!quick)\r\n e.show(\'slow\');\r\n " +
" if (a.MimeType.toLowerCase().indexOf(\'image/\') == " +
"0)\r\n e.shadowbox({ gallery: \'attachments\', pl" +
"ayer: \'img\', title: a.Description });\r\n else if (" +
"a.MimeType.toLowerCase().indexOf(\'application/pdf\') == 0 && navigator.pdfViewerE" +
"nabled)\r\n e.shadowbox({ gallery: \'attachments" +
"\', player: \'iframe\', title: a.Description });\r\n e" +
"lse\r\n e.click(onDownload);\r\n\r\n " +
" // Add Thumbnail\r\n var buildThum" +
"bnail = function () {\r\n var retryCount = 0;\r\n" +
" var img = e.find(\'.icon img\');\r\n\r\n " +
" var setThumbnailUrl = function () {\r\n " +
" img.attr(\'src\', \'");
#line 128 "..\..\Views\User\UserParts\_Resources.cshtml"
#line 142 "..\..\Views\User\UserParts\_Resources.cshtml"
Write(Url.Action(MVC.API.User.AttachmentThumbnail()));
@@ -617,61 +618,61 @@ WriteLiteral("/\' + a.Id + \'?v=\' + retryCount);\r\n
"unction onAttachmentRemoved(id) {\r\n var a = $atta" +
"chmentOutput.find(\'a[data-attachmentid=\' + id + \']\');\r\n\r\n " +
" a.hide(300).delay(300).queue(function () {\r\n " +
" var $this = $(this);\r\n if ($this.att" +
"r(\'data-mimetype\').toLowerCase().indexOf(\'image/\') == 0)\r\n " +
" Shadowbox.removeCache(this);\r\n " +
" $this.find(\'.timestamp\').livestamp(\'destroy\');\r\n " +
" $this.remove();\r\n onUpdate();\r\n " +
" });\r\n }\r\n\r\n " +
" function onUpdate() {\r\n var attachmen" +
"tCount = $attachmentOutput.children(\'a\').length;\r\n " +
" var tabHeading = \'Attachments [\' + attachmentCount + \']\';\r\n " +
" $(\'#UserDetailTab-ResourcesLink\').text(tabHeading);\r\n " +
" }\r\n\r\n $Attachments\r\n " +
" .find(\'.attachmentInput span.download-all\')\r\n " +
" .on(\'click\', function (event) {\r\n c" +
"onst downloadAllUrl = $Attachments.attr(\'data-downloadallurl\');\r\n " +
" const id = $Attachments.attr(\'data-id\');\r\n " +
" const $this = $(this);\r\n\r\n " +
" if ($this.hasClass(\'fa-spinner\'))\r\n retu" +
"rn;\r\n\r\n $this\r\n " +
" .removeClass(\'fa-download\')\r\n ." +
"addClass(\'fa-spinner fa-spin\');\r\n\r\n if (!$att" +
"achmentDownloadHost) {\r\n $attachmentDownl" +
"oadHost = $(\'<iframe>\')\r\n .attr({ \'id" +
"\': \'AttachmentsDownloadHost\', \'name\': \'AttachmentsDownloadHost\', \'title\': \'Attac" +
"hment Download Host\' })\r\n .addClass(\'" +
"hidden\')\r\n .appendTo(\'body\')\r\n " +
" .contents();\r\n " +
" }\r\n const $form = $(\'<form>\')\r\n " +
" .attr({\r\n " +
" method: \'POST\',\r\n action: downl" +
"oadAllUrl,\r\n target: \'AttachmentsDown" +
"loadHost\'\r\n })\r\n " +
" .append($(\'<input>\')\r\n " +
" .attr({ type: \'hidden\', name: \'__RequestVerificationToken\' })\r\n " +
" .val(document.body.dataset.antiforgery))\r\n " +
" .append($(\'<input>\')\r\n " +
" .attr({ type: \'hidden\', name: \'id\' })\r\n " +
" .val(id))\r\n .appendTo(" +
"document.body)\r\n .trigger(\'submit\');\r\n\r\n " +
" window.setTimeout(function () {\r\n " +
" $this\r\n ." +
"removeClass(\'fa-spinner fa-spin\')\r\n ." +
"addClass(\'fa-download\');\r\n $form.remove()" +
";\r\n }, 2000);\r\n " +
" });\r\n\r\n document.DiscoFunctions.onAttachmentAdded =" +
" onAttachmentAdded;\r\n document.DiscoFunctions.onAttac" +
"hmentRemoved = onAttachmentRemoved;\r\n\r\n");
" var $this = $(this);\r\n if (this[\'sha" +
"dowboxCacheKey\'])\r\n Shadowbox.removeCache" +
"(this);\r\n $this.find(\'.timestamp\').livestamp(" +
"\'destroy\');\r\n $this.remove();\r\n " +
" onUpdate();\r\n });\r\n " +
" }\r\n\r\n function onUpdate() {\r\n " +
" var attachmentCount = $attachmentOutput.children(\'a\'" +
").length;\r\n var tabHeading = \'Attachments [\' + at" +
"tachmentCount + \']\';\r\n $(\'#UserDetailTab-Resource" +
"sLink\').text(tabHeading);\r\n }\r\n\r\n " +
" $Attachments\r\n .find(\'.attachmentInput sp" +
"an.download-all\')\r\n .on(\'click\', function (event)" +
" {\r\n const downloadAllUrl = $Attachments.attr" +
"(\'data-downloadallurl\');\r\n const id = $Attach" +
"ments.attr(\'data-id\');\r\n const $this = $(this" +
");\r\n\r\n if ($this.hasClass(\'fa-spinner\'))\r\n " +
" return;\r\n\r\n " +
" $this\r\n .removeClass(\'fa-download\')\r\n" +
" .addClass(\'fa-spinner fa-spin\');\r\n\r\n " +
" if (!$attachmentDownloadHost) {\r\n " +
" $attachmentDownloadHost = $(\'<iframe>\')\r\n " +
" .attr({ \'id\': \'AttachmentsDownloadHost\', \'name\': \'" +
"AttachmentsDownloadHost\', \'title\': \'Attachment Download Host\' })\r\n " +
" .addClass(\'hidden\')\r\n " +
" .appendTo(\'body\')\r\n .c" +
"ontents();\r\n }\r\n " +
" const $form = $(\'<form>\')\r\n .attr(" +
"{\r\n method: \'POST\',\r\n " +
" action: downloadAllUrl,\r\n " +
" target: \'AttachmentsDownloadHost\'\r\n " +
" })\r\n .append($(\'<input>\')\r\n " +
" .attr({ type: \'hidden\', name: \'__Reque" +
"stVerificationToken\' })\r\n .val(docume" +
"nt.body.dataset.antiforgery))\r\n .append($" +
"(\'<input>\')\r\n .attr({ type: \'hidden\'," +
" name: \'id\' })\r\n .val(id))\r\n " +
" .appendTo(document.body)\r\n " +
" .trigger(\'submit\');\r\n\r\n wind" +
"ow.setTimeout(function () {\r\n $this\r\n " +
" .removeClass(\'fa-spinner fa-spin\')\r\n " +
" .addClass(\'fa-download\');\r\n " +
" $form.remove();\r\n " +
"}, 2000);\r\n });\r\n\r\n do" +
"cument.DiscoFunctions.onAttachmentAdded = onAttachmentAdded;\r\n " +
" document.DiscoFunctions.onAttachmentRemoved = onAttachmentRemoved;\r\n\r\n" +
"");
#line 234 "..\..\Views\User\UserParts\_Resources.cshtml"
#line 248 "..\..\Views\User\UserParts\_Resources.cshtml"
#line default
#line hidden
#line 234 "..\..\Views\User\UserParts\_Resources.cshtml"
#line 248 "..\..\Views\User\UserParts\_Resources.cshtml"
if (canAddAttachments)
{
@@ -718,7 +719,7 @@ WriteLiteral("\r\n //#region Add Attachments\r\n
" //#endregion\r\n ");
#line 281 "..\..\Views\User\UserParts\_Resources.cshtml"
#line 295 "..\..\Views\User\UserParts\_Resources.cshtml"
}
@@ -727,7 +728,7 @@ WriteLiteral("\r\n //#region Add Attachments\r\n
WriteLiteral(" ");
#line 282 "..\..\Views\User\UserParts\_Resources.cshtml"
#line 296 "..\..\Views\User\UserParts\_Resources.cshtml"
if (canRemoveAnyAttachments || canRemoveOwnAttachments)
{
@@ -771,7 +772,7 @@ WriteLiteral("\r\n //#region Remove Attachments\r\n\r
"");
#line 335 "..\..\Views\User\UserParts\_Resources.cshtml"
#line 349 "..\..\Views\User\UserParts\_Resources.cshtml"
}
@@ -782,6 +783,8 @@ WriteLiteral(@"
$this = $(this);
if ($this.attr('data-mimetype').toLowerCase().indexOf('image/') == 0)
$this.shadowbox({ gallery: 'attachments', player: 'img', title: $this.find('.comments').text() });
else if ($this.attr('data-mimetype').toLowerCase().indexOf('application/pdf') == 0 && navigator.pdfViewerEnabled)
$this.shadowbox({ gallery: 'attachments', player: 'iframe', title: $this.find('.comments').text() });
else
$this.click(onDownload);
});
@@ -795,7 +798,7 @@ WriteLiteral(@"
$('#UserDetailTabItems').append('<li><a href=""#UserDetailTab-Resources"" id=""UserDetailTab-ResourcesLink"">Attachments [");
#line 351 "..\..\Views\User\UserParts\_Resources.cshtml"
#line 367 "..\..\Views\User\UserParts\_Resources.cshtml"
Write(Model.User.UserAttachments == null ? 0 : Model.User.UserAttachments.Count);
@@ -804,7 +807,7 @@ WriteLiteral(@"
WriteLiteral("]</a></li>\');\r\n </script>\r\n</div>\r\n");
#line 354 "..\..\Views\User\UserParts\_Resources.cshtml"
#line 370 "..\..\Views\User\UserParts\_Resources.cshtml"
if (canRemoveAnyAttachments || canRemoveOwnAttachments)
{
@@ -826,7 +829,7 @@ WriteLiteral(" class=\"fa fa-exclamation-triangle fa-lg\"");
WriteLiteral("></i>&nbsp;Are you sure?\r\n </p>\r\n </div>\r\n");
#line 361 "..\..\Views\User\UserParts\_Resources.cshtml"
#line 377 "..\..\Views\User\UserParts\_Resources.cshtml"
}
#line default