{"version":3,"sources":["../js/Annotations/AnnotationAttachments.js"],"names":["g_oAnnotationAttachments","AnnotationAttachment","this","c_szDeleteAttachment","c_szConfirmAttachmentDelete","c_szErrorInvalidFileType","c_szMaxSizeMessage","c_szUploadingMessage","iAnnotationId","iMaxAttachmentSizeMB","prototype","chooseFileOnChange","addAnnotationAttachments","$","files","annotationAttachments","data","FormData","i","length","setUploadingStatus","validateAttachmentSize","append","ajax","url","g_szSessionId","Date","getTimezoneOffset","g_oSettings","c_szDateFormat","g_oAnnotations","g_iApprovalId","g_oUserDetails","ThirdParyMemberId","processData","contentType","type","success","response","addNewAttachments","renderAttachments","replaceWith","val","clone","failure","xhr","textStatus","ProcessApiError","error","status","responseJSON","Message","css","text","hide","show","annotationAttachment","size","confirmAttachmentDeletion","documentId","annotationId","g_oGreenlightMessages","displayConfirmBubble","deleteAnnotationAttachment","oAnnotation","findfirst","g_oAnnotationsMade","annotation","id","szDocumentName","attachments","attachment","DocumentId","DocumentName","oJSONDeletionRequest","AnnotationId","SessionId","c_szSessionId","TimeZone","DateFormat","ApprovalId","ThirdPartyMemberId","removeDeletedAttachment","renderPopupAttachments","renderAnnotationAttachments","splice","push","sort","sortAlphabetical","empty","oAnnotationAttachments","oFindResult","oAttachment","appendPopupAttachment","DocumentPath","attachmentElementId","isBubble","toLowerCase","contains","toString","html","oAnnotationAttachmentHTML","getAttachmentListItemHTML","g_iAuthor","addClass","j","oAttachmentItem","elementLinkId","elementDelId","appendAttachmentLinkBubbleEvents","openAttachmentLink","documentName","documentPath","window","open","oJSONRequest","switchAttachmentLinkColour","element","mouseOver","bInPopup","hasClass","removeClass","uploading","elementDelIconId","attachmentName","oAnnotationCanvas","g_oViewer","getCanvas","g_oCompare","getAnnotationCanvasId","oArtworkCanvas","getLinkedArtworkCanvas","g_szCanvasId","g_bReadOnly","g_bMainCanvas","click","e","stopPropagation","preventDefault","on","parent","mouseover","mouseout","encodeURI","elementId","authorId","bAddDeleteIcon","canDeleteAttachment","g_bUnlocked","szAttchmentHTML","annotationUnlocked","UserId","attachmentTitle","attachmentDocumentId","szLinkHTML","szDeleteButtonHtml","displayUploadPopUp","lockScreen","adjustOverlayPosition","fadeIn","top","position","newTop","Math","floor","modalOverlayResize","elementExistsAndIsVisible","widthPercentage","heightPercentage","idivHeight","getClientHeight","idivWidth","getNewWidth","iTop","calculateCentralYCoordinate","parseInt","iLeft","calculateCentralXCoordinate","round","height","width","left","newWidth","getClientWidth","max"],"mappings":"AAiBA,IAAIA,yBAA2B,IAE9B,WACA,aAKA,SAASC,uBACRC,KAAKC,qBAAuB,GAC5BD,KAAKE,4BAA8B,GACnCF,KAAKG,yBAA2B,GAChCH,KAAKI,mBAAqB,GAC1BJ,KAAKK,qBAAuB,GAC5BL,KAAKM,cAAgB,KACrBN,KAAKO,qBAAuB,EAM7BR,qBAAqBS,UAAUC,mBAAqB,WACnDX,yBAAyBY,yBAAyBC,EAAE,iBAAiB,GAAGC,QAOzEb,qBAAqBS,UAAUE,yBAA2B,SAAUG,uBAMnE,IAHA,IAAIC,KAAO,IAAIC,SAGNC,EAAI,EAAGA,EAAIH,sBAAsBI,OAAQD,IAAK,CAGtD,IAAKH,sBAAsBG,GAE1B,YADAlB,yBAAyBoB,oBAAmB,GAK7C,IAAKpB,yBAAyBqB,uBAAuBN,sBAAsBG,IAC1E,OAIDF,KAAKM,OAAO,OAASJ,EAAGH,sBAAsBG,IAI/CL,EAAEU,KAAK,CACNC,IAAK,sEAAwEC,cAAgB,iBAC5FzB,yBAAyBQ,cAAgB,cAAe,IAAKkB,MAAMC,oBAAsB,eAAiBC,YAAYC,eACpH,eAAiBC,eAAeC,cAAgB,uBAAyBC,eAAeC,kBAC3FC,aAAa,EACbC,aAAa,EACbnB,KAAMA,KACNoB,KAAM,OACNC,QAAS,SAAUC,UAClBtC,yBAAyBoB,oBAAmB,GAC5CpB,yBAAyBuC,kBAAkBvC,yBAAyBQ,cAAe8B,UACnFtC,yBAAyBwC,kBAAkBxC,yBAAyBQ,eAE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AE,sBAC/BiJ,sBAAsBjJ,EAAE,oBAAqB,GAAI,IAE9CyJ,0BAA0BzJ,EAAE,sBAAuB,CACtDiJ,sBAAsBjJ,EAAE,qBAAsB,GAAI,IAGlD,IAAImJ,IAAMnJ,EAAE,qBAAqBoJ,WAAWD,IACxCE,OAASF,IAAMG,KAAKC,MAAMJ,IAAM,IAAM,IAC1CnJ,EAAE,qBAAqBuC,IAAI,MAAO8G,OAAS,QAU7C,IAAIJ,sBAAwB,SAAUzC,QAASkD,gBAAiBC,kBAE/D,IAAIC,WAAaD,iBAAmBE,kBAAoB,IACpDC,UAAYC,YAAYvD,QAASkD,iBACjCM,KAAOC,4BAA4BC,SAASN,WAAY,KACxDO,MAAQC,4BAA4BF,SAASJ,UAAW,KAE5DF,WAAaN,KAAKe,MAAMT,YACxBE,UAAYR,KAAKe,MAAMP,WACvBE,KAAOV,KAAKe,MAAML,MAClBG,MAAQb,KAAKe,MAAMF,OAGnB3D,QAAQjE,IAAI,CACX+H,OAAUV,WACVW,MAAST,UACTX,IAAOa,KACPQ,KAAQL,SAWNJ,YAAc,SAAUvD,QAASkD,iBACpC,IAAIe,SAAWf,gBAAkBgB,iBAAmB,IACpD,OAAIlE,QAAQjE,IAAI,aACR+G,KAAKqB,IAAIF,SAAUP,SAAS1D,QAAQjE,IAAI,aAAc,KAEvDkI,UAIRrE,OAAOhH,qBAAuBA,qBAjnB/B","file":"AnnotationAttachments-5c05edc8c3.js","sourcesContent":["/*\r\n* Copyright (c) 2020 SGS Europe. All rights reserved.\r\n*\r\n* This program is the CONFIDENTIAL and PROPRIETARY property of 2020 SGS Europe.\r\n* Any unauthorized use, reproduction, or transfer of this program is strictly\r\n* prohibited.\r\n*\r\n* File Name:\tAnnotationAttachment.js\r\n*\r\n* Description:\tJavaScript code for the annotation attachments module.\r\n*\r\n* History:\t\t20-JAN-20\tS Norman\tInitial implementation.\r\n*\t\t\t\t22-JAN-20\tP Raper\t\tUpdated to use generic API method.\r\n*\r\n*/\r\n\r\n\r\nvar g_oAnnotationAttachments = {};\r\n\r\n(function () {\r\n\t\"use strict\";\r\n\r\n\t/**\r\n\t* Prototype for holding an individual AnnotationAttachment.\r\n\t*/\r\n\tfunction AnnotationAttachment() {\r\n\t\tthis.c_szDeleteAttachment = \"\";\r\n\t\tthis.c_szConfirmAttachmentDelete = \"\";\r\n\t\tthis.c_szErrorInvalidFileType = \"\";\r\n\t\tthis.c_szMaxSizeMessage = \"\";\r\n\t\tthis.c_szUploadingMessage = \"\";\r\n\t\tthis.iAnnotationId = null;\r\n\t\tthis.iMaxAttachmentSizeMB = 0;\r\n\t}\r\n\r\n\t/**\r\n\t * On Change function which is hit when an attachment file is chosen.\r\n\t * */\r\n\tAnnotationAttachment.prototype.chooseFileOnChange = function () {\r\n\t\tg_oAnnotationAttachments.addAnnotationAttachments($('#fuAttachment')[0].files);\r\n\t};\r\n\r\n\t/**\r\n\t * Uploads attachments and them as documents within the database.\r\n\t * @param {object} annotationAttachments - Attachment Files.\r\n\t */\r\n\tAnnotationAttachment.prototype.addAnnotationAttachments = function (annotationAttachments) {\r\n\r\n\t\t// Create new form data to be submit.\r\n\t\tvar data = new FormData();\r\n\r\n\t\t// Loop through each of the files provided.\r\n\t\tfor (var i = 0; i < annotationAttachments.length; i++) {\r\n\r\n\t\t\t// Check if a file was added to the upload control.\r\n\t\t\tif (!annotationAttachments[i]) {\r\n\t\t\t\tg_oAnnotationAttachments.setUploadingStatus(false);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Validate the file size.\r\n\t\t\tif (!g_oAnnotationAttachments.validateAttachmentSize(annotationAttachments[i])) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Append the file and make sure the key is unique by attaching the index.\r\n\t\t\tdata.append(\"file\" + i, annotationAttachments[i]);\r\n\t\t}\r\n\r\n\t\t// Upload the attachments.\r\n\t\t$.ajax({\r\n\t\t\turl: \"internal/GreenlightAnnotation/UploadAnnotationAttachment?SessionId=\" + g_szSessionId + \"&AnnotationId=\" +\r\n\t\t\t\tg_oAnnotationAttachments.iAnnotationId + \"&TimeZone=\" + (new Date).getTimezoneOffset() + \"&DateFormat=\" + g_oSettings.c_szDateFormat\r\n\t\t\t\t+ \"&ApprovalId=\" + g_oAnnotations.g_iApprovalId + \"&ThirdPartyMemberId=\" + g_oUserDetails.ThirdParyMemberId,\r\n\t\t\tprocessData: false,\r\n\t\t\tcontentType: false,\r\n\t\t\tdata: data,\r\n\t\t\ttype: 'POST',\r\n\t\t\tsuccess: function (response) {\r\n\t\t\t\tg_oAnnotationAttachments.setUploadingStatus(false);\r\n\t\t\t\tg_oAnnotationAttachments.addNewAttachments(g_oAnnotationAttachments.iAnnotationId, response);\r\n\t\t\t\tg_oAnnotationAttachments.renderAttachments(g_oAnnotationAttachments.iAnnotationId);\r\n\t\t\t\t// Reset upload control.\r\n\t\t\t\t$(\"#fuAttachment\").replaceWith($(\"#fuAttachment\").val('').clone(true));\r\n\t\t\t},\r\n\t\t\tfailure: function (xhr, textStatus) {\r\n\t\t\t\tProcessApiError(xhr, textStatus);\r\n\t\t\t\tg_oAnnotationAttachments.setUploadingStatus(false);\r\n\t\t\t},\r\n\t\t\terror: function (xhr, textStatus) {\r\n\t\t\t\t// If the file type is not valid then we need to process the error within the attachment pop-up.\r\n\t\t\t\tif (xhr.status === 400 && xhr.responseJSON.Message === g_oAnnotationAttachments.c_szErrorInvalidFileType) {\r\n\t\t\t\t\t$('#spnUploadMessage').css('color', 'red');\r\n\t\t\t\t\t$('#spnUploadMessage').text(g_oAnnotationAttachments.c_szErrorInvalidFileType);\r\n\t\t\t\t\t$('#imgUploading').hide();\r\n\t\t\t\t\t$('#spnUploadMessage').show();\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t\tProcessApiError(xhr, textStatus);\r\n\t\t\t\tg_oAnnotationAttachments.setUploadingStatus(false);\r\n\t\t\t}\r\n\t\t});\r\n\t};\r\n\r\n\t/**\r\n\t * Validates if the attachment file is greater than the maximum file size for that consumer.\r\n\t * Highlights the file size message red if validation fails.\r\n\t * @param {object} annotationAttachment - attachment file object.\r\n\t * @returns {boolean} - True if the file size is valid.\r\n\t */\r\n\tAnnotationAttachment.prototype.validateAttachmentSize = function (annotationAttachment) {\r\n\t\tif (annotationAttachment && annotationAttachment.size * 0.000001 > g_oAnnotationAttachments.iMaxAttachmentSizeMB) {\r\n\t\t\tg_oAnnotationAttachments.setUploadingStatus(false);\r\n\t\t\t$('#spnUploadMessage').css('color', 'red');\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\t$('#spnUploadMessage').css('color', '#777');\r\n\t\treturn true;\r\n\t};\r\n\r\n\t/**\r\n\t * Gets confirmation that the user wants to progress with the deletion of the attachment before calling the function to delete it if confirmed.\r\n\t * @param {number} documentId - id of the document to delete\r\n\t * @param {number} annotationId - id of the annotation the document belongs to.\r\n\t */\r\n\tAnnotationAttachment.prototype.confirmAttachmentDeletion = function (documentId, annotationId) {\r\n\t\t// Setup the confirmation/rejection actions.\r\n\t\tvar oConfirmAction = function () {\r\n\t\t\tg_oAnnotationAttachments.deleteAnnotationAttachment(documentId, annotationId);\r\n\t\t};\r\n\t\tvar oRejectionAction = function () {\r\n\t\t\t// Do nothing.\r\n\t\t};\r\n\r\n\t\t// Display the confirmation bubble.\r\n\t\tg_oGreenlightMessages.displayConfirmBubble(g_oAnnotationAttachments.c_szConfirmAttachmentDelete, oConfirmAction, oRejectionAction);\r\n\t};\r\n\r\n\t/**\r\n\t * After user confirmation, deletes an attachment from the file store and the database.\r\n\t * If attachment is cached, just removes it from the JS list.\r\n\t * @param {number} documentId - id of the document to delete\r\n\t * @param {number} annotationId - id of the annotation the document belongs to.\r\n\t */\r\n\tAnnotationAttachment.prototype.deleteAnnotationAttachment = function (documentId, annotationId) {\r\n\t\tif (annotationId > 0 && documentId > 0) {\r\n\t\t\t// Get the data required for our request.\r\n\t\t\tvar oAnnotation = $.findfirst(g_oAnnotations.g_oAnnotationsMade, function (annotation) {\r\n\t\t\t\treturn annotation.id === annotationId;\r\n\t\t\t});\r\n\t\t\tvar oAnnotationAttachment = $.findfirst(oAnnotation.attachments, function (attachment) {\r\n\t\t\t\treturn attachment.DocumentId === documentId;\r\n\t\t\t});\r\n\t\t\tvar szDocumentName = oAnnotationAttachment.DocumentName;\r\n\t\t\tvar oJSONDeletionRequest = {\r\n\t\t\t\tAnnotationId: annotationId,\r\n\t\t\t\tDocumentId: documentId,\r\n\t\t\t\tDocumentName: szDocumentName,\r\n\t\t\t\tSessionId: g_oAnnotations.c_szSessionId,\r\n\t\t\t\tTimeZone: (new Date).getTimezoneOffset(),\r\n\t\t\t\tDateFormat: g_oSettings.c_szDateFormat,\r\n\t\t\t\tApprovalId: g_oAnnotations.g_iApprovalId,\r\n\t\t\t\tThirdPartyMemberId: g_oUserDetails.ThirdParyMemberId\r\n\t\t\t};\r\n\r\n\t\t\t// Make the request to delete the attachment.\r\n\t\t\t$.ajax({\r\n\t\t\t\turl: \"internal/GreenlightAnnotation/DeleteAttachment\",\r\n\t\t\t\tdata: oJSONDeletionRequest,\r\n\t\t\t\ttype: 'POST',\r\n\t\t\t\tsuccess: function (response) {\r\n\t\t\t\t\tg_oAnnotationAttachments.removeDeletedAttachment(annotationId, documentId);\r\n\t\t\t\t\tg_oAnnotationAttachments.renderAttachments(annotationId);\r\n\t\t\t\t},\r\n\t\t\t\tfailure: function (xhr, textStatus) {\r\n\t\t\t\t\tProcessApiError(xhr, textStatus);\r\n\t\t\t\t\tg_oAnnotationAttachments.setUploadingStatus(false);\r\n\t\t\t\t},\r\n\t\t\t\terror: function (xhr, textStatus) {\r\n\t\t\t\t\tProcessApiError(xhr, textStatus);\r\n\t\t\t\t\tg_oAnnotationAttachments.setUploadingStatus(false);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\t\telse if (documentId < 0){\r\n\t\t\t// Cached attachments only need removing from the list.\r\n\t\t\tg_oAnnotationAttachments.removeDeletedAttachment(annotationId, documentId);\r\n\t\t\tg_oAnnotationAttachments.renderAttachments(annotationId);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Render all annotation attachment lists for an annotation.\r\n\t * @param {number} annotationId - annotation Id\r\n\t */\r\n\tAnnotationAttachment.prototype.renderAttachments = function (annotationId) {\r\n\t\t// Render to the attachments upload pop-up.\r\n\t\tg_oAnnotationAttachments.renderPopupAttachments(annotationId);\r\n\t\t// Render to the annotation left hand side div.\r\n\t\tg_oAnnotationAttachments.renderAnnotationAttachments(annotationId, \"annotationAttachment_\");\r\n\t\t// Render to the pop-up div if its currently shown.\r\n\t\tg_oAnnotationAttachments.renderAnnotationAttachments(annotationId, \"annotationAttachmentBubble_\");\r\n\t};\r\n\r\n\t/**\r\n\t * Removes a document from the annotations attachment list JS object.\r\n\t * @param {number} annotationId - annotation id of the annotation the attachment is attached to.\r\n\t * @param {number} documentId - document id of the attachment to be remove.\r\n\t */\r\n\tAnnotationAttachment.prototype.removeDeletedAttachment = function (annotationId, documentId) {\r\n\t\tvar oAnnotation = $.findfirst(g_oAnnotations.g_oAnnotationsMade, function (annotation) {\r\n\t\t\treturn annotation.id === annotationId;\r\n\t\t});\r\n\r\n\t\tfor (var i = 0; i < oAnnotation.attachments.length; i++) {\r\n\t\t\tif (oAnnotation.attachments[i].DocumentId === documentId) {\r\n\t\t\t\toAnnotation.attachments.splice(i, 1);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Updates an annotations attachment list with new attachments.\r\n\t * @param {int} annotationId - Id of annotation.\r\n\t * @param {object} attachments - List of attachments to add.\r\n\t */\r\n\tAnnotationAttachment.prototype.addNewAttachments = function (annotationId, attachments) {\r\n\t\t\r\n\t\t// Find the annotation.\r\n\t\tvar oAnnotation = $.findfirst(g_oAnnotations.g_oAnnotationsMade, function(annotation) {\r\n\t\t\treturn annotation.id === annotationId;\r\n\t\t});\r\n\r\n\t\t// Update the doc id if this is a new annotation.\r\n\t\tif (annotationId <= 0) {\r\n\r\n\t\t\t// Set the DocumentId to the next lowest value.\r\n\t\t\tfor (var i = 0; i < attachments.length; i++) {\r\n\t\t\t\tattachments[i].DocumentId = oAnnotation.attachments.length * -1 - 1;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Add the attachments.\r\n\t\tfor (var i = 0; i < attachments.length; i++) {\r\n\t\t\toAnnotation.attachments.push(attachments[i]);\r\n\t\t}\r\n\r\n\t\t// Sort the attachments alphabetically.\r\n\t\toAnnotation.attachments.sort(sortAlphabetical);\r\n\t};\r\n\r\n\t/**\r\n\t * Renders the pop-up attachments list.\r\n\t * @param {int} annotationId - Id of the annotation to render the attachments list for.\r\n\t */\r\n\tAnnotationAttachment.prototype.renderPopupAttachments = function (annotationId) {\r\n\r\n\t\t// Remove any existing html.\r\n\t\t$(\"#listAnnotationAttachments\").empty();\r\n\r\n\t\t// Get the annotations attachments array.\r\n\t\tvar oFindResult = $.findfirst(g_oAnnotations.g_oAnnotationsMade, function (annotation) {\r\n\t\t\treturn annotation.id === annotationId;\r\n\t\t});\r\n\r\n\t\tvar oAnnotationAttachments;\r\n\t\tif (oFindResult && oFindResult.attachments.length > 0) {\r\n\t\t\toAnnotationAttachments = oFindResult.attachments;\r\n\t\t}\r\n\r\n\t\tif (oAnnotationAttachments && oAnnotationAttachments.length > 0) {\r\n\t\t\toAnnotationAttachments.sort(sortAlphabetical);\r\n\r\n\t\t\tfor (var i = 0; i < oAnnotationAttachments.length; i++) {\r\n\t\t\t\tvar oAttachment = oAnnotationAttachments[i];\r\n\t\t\t\tappendPopupAttachment(oAttachment.DocumentName, oAttachment.DocumentPath, oAttachment.DocumentId, annotationId);\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Renders the attachments HTML of an annotation to the annotation div element.\r\n\t * @param {number} annotationId - Id of the annotation.\r\n\t * @param {string} attachmentElementId - Id of the element to render to, bubble or left hand side divs.\r\n\t */\r\n\tAnnotationAttachment.prototype.renderAnnotationAttachments = function (annotationId, attachmentElementId) {\r\n\t\tvar isBubble = attachmentElementId.toLowerCase().contains(\"bubble\");\r\n\r\n\t\t// Get out attachments array out of the annotations object.\r\n\t\tvar oAnnotation = $.findfirst(g_oAnnotations.g_oAnnotationsMade, function (annotation) {\r\n\t\t\treturn annotation.id === annotationId;\r\n\t\t});\r\n\r\n\t\t// Get the annotation attachments.\r\n\t\tvar oAnnotationAttachments = oAnnotation.attachments;\r\n\r\n\t\t// Sort these alphabetically.\r\n\t\toAnnotationAttachments.sort(sortAlphabetical);\r\n\r\n\t\t// If we are rendering for a bubble make sure it exists.\r\n\t\tif (isBubble && $(\"#\" + annotationId.toString() + \".speechbubble\").length === 0) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Hide the div if we have no annotations.\r\n\t\tif (oAnnotationAttachments.length === 0) {\r\n\t\t\t$(\"#\" + attachmentElementId + \"Container_\" + annotationId.toString()).hide();\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Clear any existing html if it exists.\r\n\t\tif ($(\"#\" + attachmentElementId + annotationId.toString()).length) {\r\n\t\t\t$(\"#\" + attachmentElementId + annotationId.toString()).html(\"\");\r\n\t\t}\r\n\r\n\t\t// Build up the HTML for the attachments.\r\n\t\tvar oAnnotationAttachmentHTML = \"\";\r\n\r\n\t\t// Loop through each of the attachments.\r\n\t\tfor (var i = 0; i < oAnnotationAttachments.length; i++) {\r\n\t\t\tvar oAttachment = oAnnotationAttachments[i];\r\n\r\n\t\t\t// Add the attachment link.\r\n\t\t\toAnnotationAttachmentHTML += getAttachmentListItemHTML(annotationId, attachmentElementId, oAttachment.DocumentId, oAttachment.DocumentName, oAnnotation.g_iAuthor, isBubble);\r\n\t\t}\r\n\r\n\t\t// Add the annotation attachment html to the container.\r\n\t\t$(\"#\" + attachmentElementId + \"Container_\" + annotationId.toString()).html(oAnnotationAttachmentHTML);\r\n\r\n\t\t// Add the display class to the annotation attachment container.\r\n\t\t$(\"#\" + attachmentElementId + \"Container_\" + annotationId.toString()).addClass(\"annotationAttachmentContainer\");\r\n\r\n\t\t// If we have an attachment show the container div.\r\n\t\t$(\"#\" + attachmentElementId + \"Container_\" + annotationId.toString()).show();\r\n\r\n\t\t// Add event handlers to links and deletion icons.\r\n\t\tfor (var j = 0; j < oAnnotationAttachments.length; j++) {\r\n\t\t\tvar oAttachmentItem = oAnnotationAttachments[j];\r\n\t\t\tvar elementLinkId = \"#\" + attachmentElementId + \"Link\" + oAttachmentItem.DocumentId;\r\n\t\t\tvar elementDelId = \"#\" + attachmentElementId + \"BubbleDel\" + oAttachmentItem.DocumentId;\r\n\r\n\t\t\tappendAttachmentLinkBubbleEvents(elementLinkId, elementDelId, oAttachmentItem.DocumentId, annotationId, oAttachmentItem.DocumentName, oAttachmentItem.DocumentPath);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * opens a document in a new window.\r\n\t * @param {string} documentName - Name of the attachment document.\r\n\t * @param {number} documentId - Id of the attachment document.\r\n\t * @param {string} documentPath - Path of the attachment document, used for opening cached files.\r\n\t */\r\n\tAnnotationAttachment.prototype.openAttachmentLink = function (documentName, documentId, documentPath) {\r\n\t\tif (documentId < 0) {\r\n\t\t\twindow.open(documentPath, '_blank');\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tvar oJSONRequest = {\r\n\t\t\tDocumentId: documentId,\r\n\t\t\tDocumentName: documentName,\r\n\t\t\tSessionId: g_oAnnotations.c_szSessionId\r\n\t\t};\r\n\r\n\t\t// Make the request to get the URI.\r\n\t\t$.ajax({\r\n\t\t\turl: \"internal/GreenlightAnnotation/GetAttachmentReadURI\",\r\n\t\t\tdata: oJSONRequest,\r\n\t\t\ttype: 'POST',\r\n\t\t\tsuccess: function (response) {\r\n\t\t\t\t// Open URI in new window.\r\n\t\t\t\twindow.open(response, '_blank');\r\n\t\t\t},\r\n\t\t\tfailure: function (xhr, textStatus) {\r\n\t\t\t\tProcessApiError(xhr, textStatus);\r\n\t\t\t\tg_oAnnotationAttachments.setUploadingStatus(false);\r\n\t\t\t},\r\n\t\t\terror: function (xhr, textStatus) {\r\n\t\t\t\tProcessApiError(xhr, textStatus);\r\n\t\t\t\tg_oAnnotationAttachments.setUploadingStatus(false);\r\n\t\t\t}\r\n\t\t});\r\n\t};\r\n\r\n\t/**\r\n\t * Switches the CSS colour of the attachment button link on mouse over or mouse out.\r\n\t * @param {object} element - Element of the attachment link button.\r\n\t * @param {boolean} mouseOver - Is the mouse currently hovering.\r\n\t */\r\n\tvar switchAttachmentLinkColour = function (element, mouseOver) {\r\n\r\n\t\t// Determine if this is in the popup.\r\n\t\tvar bInPopup = $(element).hasClass(\"annotationAttachmentEntry\");\r\n\r\n\t\t// If we are mouse overing an attachment link.\r\n\t\tif (mouseOver && !bInPopup) {\r\n\t\t\t$(element).addClass(\"annotationAttachmentActive\");\r\n\t\t}\r\n\t\t// If we are mouse outing an attachment link.\r\n\t\telse if (!mouseOver && !bInPopup) {\r\n\t\t\t$(element).removeClass(\"annotationAttachmentActive\");\r\n\t\t}\r\n\t\t// If we are mousing over a popup link.\r\n\t\telse if (mouseOver && bInPopup) {\r\n\t\t\t$(element).addClass(\"annotationAttachmentEntryActive\");\r\n\t\t}\r\n\t\t// If we are mousing out a popup link.\r\n\t\telse if (!mouseOver && bInPopup) {\r\n\t\t\t$(element).removeClass(\"annotationAttachmentEntryActive\");\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Shows the uploading image and message while a file is uploading.\r\n\t * @param {boolean} uploading - show or hide the uploading image and message.\r\n\t */\r\n\tAnnotationAttachment.prototype.setUploadingStatus = function (uploading) {\r\n\t\tif (uploading) {\r\n\t\t\t$('#spnUploadMessage').css('color', '#777');\r\n\t\t\t$('#spnUploadMessage').text(g_oAnnotationAttachments.c_szUploadingMessage);\r\n\t\t\t$('#imgUploading').show();\r\n\t\t}\r\n\t\telse {\r\n\t\t\t$('#spnUploadMessage').css('color', '#777');\r\n\t\t\t$('#spnUploadMessage').text(g_oAnnotationAttachments.c_szMaxSizeMessage + g_oAnnotationAttachments.iMaxAttachmentSizeMB.toString() + \"MB\");\r\n\t\t\t$('#imgUploading').hide();\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Append event handlers for attachment links and deletion icons.\r\n\t * @param {element} elementLinkId - element for attachment link.\r\n\t * @param {element} elementDelIconId - element for attachment deletion icon.\r\n\t * @param {number} DocumentId - Id of attachment document.\r\n\t * @param {number} annotationId - Id of annotation.\r\n\t * @param {string} attachmentName - Name of attachment.\r\n\t * @param {string} documentPath - Path to document.\r\n\t */\r\n\tvar appendAttachmentLinkBubbleEvents = function (elementLinkId, elementDelIconId, DocumentId, annotationId, attachmentName, documentPath) {\r\n\t\t// Determine the canvas to use for rendering based on the annotation toggle.\r\n\t\tvar oAnnotationCanvas = g_oViewer.getCanvas(g_oCompare.getAnnotationCanvasId());\r\n\t\tvar oArtworkCanvas = g_oViewer.getLinkedArtworkCanvas(oAnnotationCanvas.g_szCanvasId);\r\n\r\n\t\tif (!g_oViewer.g_bReadOnly && oArtworkCanvas.g_bMainCanvas) {\r\n\t\t\t//deletion pointer down event.\r\n\t\t\t$(elementDelIconId).click(function (e) {\r\n\t\t\t\te.stopPropagation();\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\tg_oAnnotationAttachments.confirmAttachmentDeletion(DocumentId, annotationId);\r\n\t\t\t});\r\n\r\n\t\t\t$(elementDelIconId).on(\"pointerdown\", function (e) {\r\n\t\t\t\te.stopPropagation();\r\n\t\t\t\te.preventDefault();\r\n\t\t\t});\r\n\t\t}\r\n\t\t\r\n\t\t// Attachment link events.\r\n\t\t$(elementLinkId).parent().mouseover(function () {\r\n\t\t\tswitchAttachmentLinkColour(this, true);\r\n\t\t});\r\n\r\n\t\t$(elementLinkId).parent().mouseout(function () {\r\n\t\t\tswitchAttachmentLinkColour(this, false);\r\n\t\t});\r\n\r\n\t\t$(elementLinkId).parent().click(function (e) {\r\n\t\t\te.stopPropagation();\r\n\t\t\te.preventDefault();\r\n\t\t\tg_oAnnotationAttachments.openAttachmentLink(attachmentName, DocumentId, encodeURI(documentPath));\r\n\t\t});\r\n\r\n\t\t$(elementLinkId).parent().on(\"pointerdown\", function (e) {\r\n\t\t\te.stopPropagation();\r\n\t\t\te.preventDefault();\r\n\t\t});\r\n\t};\r\n\r\n\t/**\r\n\t * Gets the HTML for the attachment link and attachment deletion icons.\r\n\t * @param {string} annotationId = The id of the annotation.\r\n\t * @param {string} elementId - Element id which differentiates between a bubble and list item.\r\n\t * @param {number} documentId - Id of the attachment document.\r\n\t * @param {string} documentName - name of the attachment document.\r\n\t * @param {number} authorId - id of the user.\r\n\t * @param {bool} isBubble if it's a bubble\r\n\t * @returns {string} HTML for the attachment link and attachment deletion icons.\r\n\t */\r\n\tvar getAttachmentListItemHTML = function (annotationId, elementId, documentId, documentName, authorId, isBubble) {\r\n\r\n\t\t// Determine the canvas to use for rendering based on the annotation toggle.\r\n\t\tvar oAnnotationCanvas = g_oViewer.getCanvas(g_oCompare.getAnnotationCanvasId());\r\n\t\tvar oArtworkCanvas = g_oViewer.getLinkedArtworkCanvas(oAnnotationCanvas.g_szCanvasId);\r\n\r\n\t\t// Get the annotation.\r\n\t\tvar oAnnotation = $.findfirst(g_oAnnotations.g_oAnnotationsMade, function (annotation) {\r\n\t\t\treturn annotation.id === annotationId;\r\n\t\t});\r\n\r\n\t\t// Determine if a delete icon will be added.\r\n\t\tvar bAddDeleteIcon = canDeleteAttachment(oArtworkCanvas, authorId, oAnnotation.g_bUnlocked);\r\n\t\t\r\n\t\t// Determine the class based on if this is a bubble or not.\r\n\t\tvar szClass = isBubble ? \"attachmentLink \" + (!bAddDeleteIcon ? \"attachmentLinkWide \" : \"\") + \"attachmentBubbleLink tooltip\" : \"attachmentLink \" + (!bAddDeleteIcon ? \"attachmentLinkWide \" : \"\") + \"tooltip\";\r\n\r\n\t\t// Create a div to hold the attachments.\r\n\t\tvar szAttchmentHTML = \"
\";\r\n\r\n\t\t// Add the link for the attachment.\r\n\t\tszAttchmentHTML += \"
\";\r\n\r\n\t\t// Add the attachment icon.\r\n\t\tszAttchmentHTML += \"\";\r\n\r\n\t\t// Add the document name.\r\n\t\tszAttchmentHTML += \"\" + documentName + \"\";\r\n\r\n\t\t// Close the link for the attachment.\r\n\t\tszAttchmentHTML += \"
\";\r\n\r\n\t\t// Add a delete icon if required.\r\n\t\tif (bAddDeleteIcon) {\r\n\t\t\tszAttchmentHTML += \"
\";\r\n\t\t}\r\n\r\n\t\t// Close the div for the attachment.\r\n\t\tszAttchmentHTML += \"
\";\r\n\r\n\t\t// Return the html.\r\n\t\treturn szAttchmentHTML;\r\n\t};\r\n\r\n\t/**\r\n\t * Determines if an attachment can be deleted.\r\n\t * @param {object} oArtworkCanvas - The artwork canvas.\r\n\t * @param {int} authorId - The author of the attachment.\r\n\t * @param {bool} annotationUnlocked - If the annotation is unlocked.\r\n\t * @returns {bool} - If the attachment can be deleted.\r\n\t */\r\n\tvar canDeleteAttachment = function (oArtworkCanvas, authorId, annotationUnlocked) {\r\n\t\treturn !g_oViewer.g_bReadOnly && oArtworkCanvas.g_bMainCanvas && (authorId === g_oUserDetails.UserId || annotationUnlocked);\r\n\t};\r\n\r\n\t/**\r\n\t * Append an attachment to the attachment list on the pop-up.\r\n\t * @param {string} attachmentTitle - The title displayed when hovered over the attachment link.\r\n\t * @param {string} documentPath - The URI to the document.\r\n\t * @param {number} attachmentDocumentId - The document Id for the attachment which is used for deletion.\r\n\t * @param {number} annotationId - The annotation the attachment is added to.\r\n\t */\r\n\tvar appendPopupAttachment = function (attachmentTitle, documentPath, attachmentDocumentId, annotationId) {\r\n\t\tvar szLinkHTML = \"\";\r\n\r\n\t\tvar szDeleteButtonHtml = '';\r\n\r\n\t\t$(\"#listAnnotationAttachments\").append(szLinkHTML + szDeleteButtonHtml);\r\n\r\n\t\tappendAttachmentLinkBubbleEvents(\"#annotationDocumentPopupLink\" + attachmentDocumentId, \"#annotationDocumentPopupDel\" + attachmentDocumentId,\r\n\t\t\tattachmentDocumentId, annotationId, attachmentTitle, documentPath);\r\n\t};\r\n\r\n\t/**\r\n\t * Displays the upload overlay\r\n\t */\r\n\tAnnotationAttachment.prototype.displayUploadPopUp = function () {\r\n\t\tlockScreen();\r\n\r\n\t\t$('#imgSpinner').hide();\r\n\r\n\t\t// Calculate the Pop-up position and content sizes.\r\n\t\tadjustOverlayPosition($(\"#divUploadOverlay\"), 30, 20);\r\n\r\n\t\t// Show the window.\r\n\t\t$(\"#divUploadOverlay\").fadeIn();\r\n\r\n\t\t// move div up 25%.\r\n\t\tvar top = $(\"#divUploadOverlay\").position().top;\r\n\t\tvar newTop = top - Math.floor(top / 100 * 25);\r\n\t\t$('#divUploadOverlay').css('top', newTop + 'px');\r\n\t};\r\n\r\n\t/**\r\n\t * Resize event to adjust the overlay location\r\n\t */\r\n\tAnnotationAttachment.prototype.modalOverlayResize = function () {\r\n\r\n\t\tif (elementExistsAndIsVisible($(\"#divModalOverlay\"))) {\r\n\t\t\tadjustOverlayPosition($(\"#divModalOverlay\"), 80, 82);\r\n\t\t}\r\n\t\tif (elementExistsAndIsVisible($(\"#divUploadOverlay\"))) {\r\n\t\t\tadjustOverlayPosition($(\"#divUploadOverlay\"), 30, 20);\r\n\r\n\t\t\t// move div up 25%.\r\n\t\t\tvar top = $(\"#divUploadOverlay\").position().top;\r\n\t\t\tvar newTop = top - Math.floor(top / 100 * 25);\r\n\t\t\t$('#divUploadOverlay').css('top', newTop + 'px');\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * calculates & sets the CSS for the given element to be in the middle of the screen\r\n\t * @param {object} element The element to adjust\r\n\t * @param {number} widthPercentage Percentage of the width the element will take up\r\n\t * @param {number} heightPercentage Percentage of the height the element will take up\r\n\t */\r\n\tvar adjustOverlayPosition = function (element, widthPercentage, heightPercentage) {\r\n\t\t// Calculate the Pop-up positions.\r\n\t\tvar idivHeight = heightPercentage * getClientHeight() / 100;\r\n\t\tvar idivWidth = getNewWidth(element, widthPercentage);\r\n\t\tvar iTop = calculateCentralYCoordinate(parseInt(idivHeight, 10));\r\n\t\tvar iLeft = calculateCentralXCoordinate(parseInt(idivWidth, 10));\r\n\r\n\t\tidivHeight = Math.round(idivHeight);\r\n\t\tidivWidth = Math.round(idivWidth);\r\n\t\tiTop = Math.round(iTop);\r\n\t\tiLeft = Math.round(iLeft);\r\n\r\n\t\t// Apply the CSS.\r\n\t\telement.css({\r\n\t\t\t\"height\": idivHeight,\r\n\t\t\t\"width\": idivWidth,\r\n\t\t\t\"top\": iTop,\r\n\t\t\t\"left\": iLeft\r\n\t\t});\r\n\t};\r\n\r\n\t/**\r\n\t * Gets the width needed to take up the given percentage of the screen\r\n\t * If the element has min-width property, it makes sure it's above it.\r\n\t * @param {object} element The element\r\n\t * @param {number} widthPercentage The percentage of the screen it's to take up\r\n\t * @returns {number} The new width of the element.\r\n\t */\r\n\tvar getNewWidth = function (element, widthPercentage) {\r\n\t\tvar newWidth = widthPercentage * getClientWidth() / 100;\r\n\t\tif (element.css(\"min-width\")) {\r\n\t\t\treturn Math.max(newWidth, parseInt(element.css(\"min-width\"), 10));\r\n\t\t}\r\n\t\treturn newWidth;\r\n\t};\r\n\r\n\t// Add the Annotation UI object to the window.\r\n\twindow.AnnotationAttachment = AnnotationAttachment;\r\n}());"]}