{"version":3,"sources":["../js/Annotations/Annotation.js"],"names":["g_AvailableColours","Annotation","approvalId","this","createdDate","modifiedDate","g_iApprovalId","g_iAnnotationType","eAnnotationTypes","Rectangle","g_szColour","g_oAnnotationData","g_iOrigx","g_iOrigy","g_oDrawArray","g_oDrawCoordSetArray","g_oMarqueeDrawArray","g_iuvX","g_iuvY","id","g_oTextMeasurementWordsArray","g_iAuthor","g_szAuthorEmail","g_szAuthorDisplayName","g_oReplies","g_oStatuses","g_bClosed","g_bSaved","g_bReadState","g_bVisible","g_iParentAnnotationId","g_iNumber","g_iDocumentId","g_iDocumentPageId","g_bUnlocked","dirtystate","status","g_bSVGTextAnnotation","g_bSVGHoverAnnotation","g_bSVGSearchAnnotation","g_bSVGPositionUpdated","g_oSVGVariable","g_szSVGOriginalContent","g_szTextHighlightContent","attachments","prototype","createAnnotationDiv","type","editableInputType","annotationReplyId","oArtworkCanvas","oAnnotationCanvas","svgDivID","classNames","origSvgDivID","oDestination","sztextContent","g_szTextContent","oAnnotationReplies","oAnnotationStatuses","annotationDate","szArtworkCanvasId","g_szCanvasId","annotationIsReadOnly","szAnnotationcolour","g_oAnnotations","getStringColour","eAnnotationDivType","Popup","g_bOverrideCloseBubble","i","g_oActiveBubbles","length","g_oGreenlightMessages","closeBubble","$","css","removeExistingHighlights","changeCanvasFunction","annotationStack","filteredAnnotationStack","g_oAnnotationsMade","newDiv","document","createElement","className","setAttribute","getElementById","append","ThreeD","existingAnnotation","grep","g_oScene","children","child","Id","oAnnotation2DCoords","threeDToTwoDCoords","position","x","g_oContainer","offsetLeft","left","top","y","width","addClass","show","oHeaderBar","addDomElement","bAddDeleteButton","g_bMainCanvas","g_oViewer","g_bReadOnly","g_oUserDetails","UserId","isEmptyObject","TextMeasurement","TextHighlight","TextClassification","c_szCloseAnnotation","c_szDeleteAnnotation","g_bMultiView","Global","inArray","g_oMultiView","copiedAnnotationIds","c_szCopyAnnotationBatch","g_oAudit","c_szOpenAnnotationAudit","AdditionalData","c_szAnnotationAttachDocumentPrompt","ListItem","annNumberContainer","innerHTML","g_oSettings","g_oUserSettings","ShowAnnotationNumbers","style","display","appendChild","Date","now","CreateTextEditing","oPopupContent","oJQTEOptions","szJQTEBackgroundColour","g_oSVGText","getJQTEOptions","switchId","getJQTEBackgroundColour","g_oAnnotationTextClassification","g_oJQTEOptions","createAnnotationTextArea","replyContainer","replyContainerId","iFieldType","eFieldTypes","ReplyHeader","bReadOnly","j","parseInt","oReplyDate","statusContainer","statusContainerId","StatusHeader","g_iAnnotationStatus","annotationStatusDateTime","undefined","CreateStatus","statusGroupId","oExistingStatus","iExistingStatus","renderAnnotationStatusIcons","CreateReply","oThisAnnotation","c_szAnnotationAddReplyPrompt","displayWarningBubble","c_szUnsavedAnnotationReply","bListItem","event","toElement","target","indexOf","oAnnotationItem","preReplyScrollRequired","replace","result","annotation","EmailAddress","scrollReplyAnnotation","BarcodeMeasurement","ColourDensityMeasurement","ColourDensityMeasurementPostit","oCurrentAnnotation","g_oLastAnnotation","c_szAnnotationAddShapePrompt","displayInfoBubble","c_szMakingShapeTip","g_szPrevCursorStyle","getCanvas","g_oAnnotationCanvas","parent","remove","rebuildAnnotationList","off","redraw","g_oAnnotationColSelected","toUpperCase","slice","click","initiateAnnotationDraw","hide","c_szColourAnnotationText","g_AnnotationId","SelectColourFromDisplay","oTextAnnotation","g_oTextData","loadTextData","g_oDoc","documentId","g_iCurrentPage","g_oTextTools","g_iExistingAnnotationId","g_oAnnotationText","JSON","parse","initialiseTextTool","g_eToolTypes","startingText","character","RemoveTextHighlight","oAnnotationAttachmentBubbleContainer","toString","on","e","stopPropagation","preventDefault","g_oAnnotationAttachments","renderAnnotationAttachments","oAnnotationAttachmentContainer","oAnnotationAuditContainer","oAnnotationDataContainer","destination","annotationStatus","svgDivId","eAnnotationStatuses","Approved","c_szRemoveStatus","c_szApproveAnnotation","Rejected","c_szRejectAnnotation","Query","c_szQueryAnnotation","ToDo","c_szTodoAnnotation","renderAnnotationStatusTooltips","iStatusCode","iStatusChangeAction","oApprovedIcons","oApprovedIcon","hasClass","tooltipster","eAnnotationStatusUpdateType","deleteStatus","attr","oRejectedIcons","oRejectedIcon","oQueryIcons","oQueryIcon","oToDoIcons","oToDoIcon","generateAnnotationHeader","iType","szCreatorEmail","szCreatorDisplayName","oDate","dbId","bExistingAnnotation","bMyAnnotation","bInFlyout","oHeaderContainer","oDetails","szHeaderClass","oAnnHeader","getDisplayName","formatDate","generateAnnotationHeaderDetails","oButtons","generateAnnotationHeaderButtons","createTextAreaInputActive","SVGDivId","textContent","oJQTEOptionsOverride","szJQTEBackgroundColourOverride","input","AnnotationMainHeader","size","value","g_szAnnotationContent","br","center","color","format","indent","link","outdent","ol","p","right","rule","source","title","unlink","jqte","DifferenceHeader","AnnotationTextEditorLooseFocusEvent","oButtonsContainer","szClassName","szHoverText","c_szDeleteAnnotationReply","EditButtonOnClick","displayErrorBubble","relatedAnnotationId","iListScrollTop","scrollTop","relatedAnnotationDiv","parents","relatedAnnotationListItem","substring","relatedAnnotation","ann","annotations","pages","push","documentPageId","documentPageNumber","sort","a","b","g_oFilter","applyAnnotationFilters","l","currentTarget","substr","lastIndexOf","g_iApprovalType","eDocumentTypes","redraw3DAnnotations","g_oRenderer","render","g_oCamera","AnnotationUI","repositionSpeechBubbles","focus","oElement","scrollEditAnnotation","creator","creatorEmail","creatorDisplayName","readOnly","date","CopyMagic","oContentContainer","bIsMyAnnotation","szAnnotationHeader","renderAnnotationTextClassificationContent","szCreator","getUnformattedSVGText","bIE","documentMode","bEdge","window","StyleMedia","dir","copyOverride","c_szEditAnnotationText","createTextAreaInputDisabled","setTimeout","documentType","_this","callerType","bReply","oInputDiv","oAnnotationDiv","oParentAnnotationObject","checkForUnsavedAnnotation","contains","c_szSessionId","szRaw","html","szInputValueText","reply","getAttribute","oNewAnnotation","getNextAnnotationId","jqteVal","AnnotationSave","resultParent","g_oArtworkViewer","getLinkedArtworkCanvas","vector","THREE","Vector3","z","project","g_oCanvas","clientWidth","clientHeight","bIsMainAnnotation","oDocument","g_oaComboControls","documents","selectedDocumentIndex","bNewThreeDViewAnnotation","Approval3DViewId","oThreeDViewParentDocument","iParentDocumentId","iParentDocumentPageId","szModelPath","szModelPrimaryArtworkTexture","iThreeDViewdocumentId","oNewCopyMagicTextAnnotation","copyMagicText","swapImage","oThreeDView","g_oThreeDView","GetThreeDView","GetFileNameWithoutExtension","ModelTemplatePrimaryArtworkFileName","ModelTemplatePath","ModelTemplateName","ParentDocumentId","ParentDocumentPageId","findfirst","greenlightDocumentId","deepCopyObject","prefix","newTextContent","val","annotationReplies","oReplyObject","annotationId","approvalUserId","approvalUserEmailAddress","replyToAnnotId","annotationType","annotationDateTime","modifiedDateTime","svgVariableId","stringify","svgOriginalContent","textHighlightContent","annotationContent","annotationColour","getHexColour","annotationData","unlocked","deleted","annotationStatuses","annotationCoords","oAnnotationCoordObject","annotationX","annotationY","annotationZ","annotation3dvUVx","annotation3dvUVy","marqueeX","marqueeY","g_oPreviouslySavedAnnotationCoords","deepCopyArray","resetAnnotationStatus","applySVGTextUpdate","updateAnnotationTextClassificationData","oAnnotationObject","iCompareDocumentId","g_oCompareMode","eCompareMode","NoCompare","g_oCompare","g_oCompareDocument","AddThreeDViewAnnotation","ThirdParyMemberId","oJSON","iApprovalId","iApprovalUserId","szSessionId","szThirdPartyMemberId","oAnnotation","ajax","url","data","contentType","dataType","success","response","displaySuccessBubble","c_szAnnotationSavedSuccessfully","g_oTextCompare","g_bTextCompareInProgress","getAnnotationCanvasId","splice","g_oExistingTextAnnotations","anno","responseObj","Contents","setupAnnotations","Annotations","ColladaModelTexture","oAdditionalShapeAnnotations","g_oSVGCopyMagic","generateCopyMagicAdditionalShapes","contentDataId","contentId","annotationSaveShape","renderPageAnnotationNumbers","g_oAnnotationHub","server","send","ex","oTimer","currentTimeoutListRemove","g_bNonAnnotationActionInProgress","g_oLastUsedTool","currentTimeoutListAdd","failure","c_szAnnotationFailedtoSave","error","bUpdating","szUrlString","szSuccessMessage","c_szAnnotationUpdateSuccess","szErrorMessage","c_szAnnotationUpdateFail","bSetCoords","tmp","annotationCoordId","xCoordinate","yCoordinate","zCoordinate","ApprovalId","SessionId","AnnotationShape","updateSavedShape","console","log","c_szFailedToNotifyOthersMessage","g_oAnnotationActions","mouseMoveLite","panToAnnotation","oSyncCanvas","parentCanvasObj","parentArtworkViewer","g_iZoomLevel","annotationMidPoint","annotationBounds","maxCanvasWidth","g_iScaledImageWidth","maxCanvasHeight","g_iScaledImageHeight","syncCanvas","Math","max","g_iTempDragOffset_x","g_iTempDragOffset_y","g_iDragXDiff","g_iDragOffset_x","g_iAnimateFrames","g_iDragYDiff","g_iDragOffset_y","synchroniseZoomPanProperties","g_oCanvasZoom","startZoomAnimate","oReturnedAnnotation","iTempId","coordSet","DrawCoordinatesSet","updateAnnotationId","tempId","highlightTextMeasurementWords","bApplyTextHighlight","compareOffset_x","compareOffset_y","iScaledImageWidth","iScaledImageHeight","co","calculateCompareOffsetInPx","iCompareRotation","getCompareRotation","m","word","ChildTextElements","n","iLowerLeftX","Llx","iLowerLeftY","Lly","iUpperRightX","Urx","iUpperRightY","Ury","oRotatedLetterLower","rotate","rotated_x","rotated_y","oRotatedLetterUpper","startX","g_iCenterShift_x","startY","g_iCenterShift_y","distX","distY","removeTextHighlight","g_oContext","IsTextVisible","drawTextHighlight","g_szTextMeasurementFill","insertedCharsBefore","insStartX","insStartY","insDistX","insDistY","insertedCharsAfter","Convert2DTo3DAnnotation","uvx","uvy","szColladaModelTexture","oScene","annotation3DPoint","TraversePolygonsForGeometries","DisplayColourSelection","c_szColourErrorUnableToFind","ResetPreviousSelection","g_oPreviousSpeechAnnotation","g_oPreviousSpeechAnnotationArrow","classList","szPreviousColour","AnnotationColour","updateSettingAnnotationColour","presetUserTools","oActive","bListAnnotation","szSelectedAnnotationColourIcon","bIsAddShapeAvailable","RemoveLastColourSelection","ClearColourSelection","szBackgroundColour","c_iSkinType","colourGrid","cloneNode","background","oSectionToAppendTo","add","ResizeColourSelection","scrollColourSelection","szColour","oColourElement","charAt","RemoveColourClass","removeClass","toLowerCase","SelectedColour","szLocalColour","annotationColourChange","resultSelected","oSpeechBubble","szSaveNewColour","szSavePrev","iCallCount","UpdateColourSelection","c_szColourUpdate","iId","szHexColour","szAnnotationContent","iapprovalUserId","iAnnotationId","szAnnotationColour","c_szColourSuccessAnnotationText","c_szColourErrorAnnotationText","bClearSelection","parentElement","removeChild","oNewPopupColour","oColourGrid","scrollColourSelectionList","scrollColourSelectionPopup","iToolPosition","height","iScrollAmount","animate","iToolBottomPosition","iOverflowAmount","scrollRepositionSpeechBubbles","iEditStart","iEditEnd","iScrollDownAmount","iScrollUpAmount","scrollReplyAnnotationList","scrollHeight","iReplyPosition","bScrollRequired","ScrollStatusAnnotationList","iStatusStart","iStatusEnd","clearRect","redrawAnnotations"],"mappings":"CAaC,WACA,aAGA,IAAIA,mBAAqB,CAAC,OAAQ,MAAO,QAAS,SAAU,SAAU,OAAQ,SAAU,UAAW,QAMnG,SAASC,WAAWC,YACnBC,KAAKC,YAAc,KACnBD,KAAKE,aAAe,KACpBF,KAAKG,cAAgBJ,WAErBC,KAAKI,kBAAoBC,iBAAiBC,UAC1CN,KAAKO,WAAa,GAClBP,KAAKQ,kBAAoB,KACzBR,KAAKS,SAAW,EAChBT,KAAKU,SAAW,EAChBV,KAAKW,aAAe,GACpBX,KAAKY,qBAAuB,GAC5BZ,KAAKa,oBAAsB,GAE3Bb,KAAKc,OAAS,EACdd,KAAKe,OAAS,EACdf,KAAKgB,IAAM,EAEXhB,KAAKiB,6BAA+B,GAEpCjB,KAAKkB,UAAY,EACjBlB,KAAKmB,gBAAkB,GACvBnB,KAAKoB,sBAAwB,GAC7BpB,KAAKE,aAAe,KACpBF,KAAKqB,WAAa,GAClBrB,KAAKsB,YAAc,GACnBtB,KAAKuB,WAAY,EACjBvB,KAAKwB,UAAW,EAChBxB,KAAKyB,cAAe,EACpBzB,KAAK0B,YAAa,EAClB1B,KAAK2B,sBAAwB,EA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served.\r\n *\r\n * This program is the CONFIDENTIAL and PROPRIETARY property of SGS Europe.\r\n * Any unauthorised use, reproduction, or transfer of this program is strictly\r\n * prohibited.\r\n *\r\n * File Name: Annotation.js\r\n *\r\n * Description:\tCode to encapsulate the Annotation JavaScript object.\r\n *\r\n */\r\n\r\n(function () {\r\n\t\"use strict\";\r\n\r\n\t// Single global instance of colours.\r\n\tvar g_AvailableColours = [\"blue\", \"red\", \"green\", \"orange\", \"purple\", \"cyan\", \"yellow\", \"magenta\", \"grey\"];\r\n\r\n\t/**\r\n\t * Prototype for holding an individual annotation\r\n\t * @param {type} approvalId - The ID of the Approval that this annotation is to be attached to.\r\n\t */\r\n\tfunction Annotation(approvalId) {\r\n\t\tthis.createdDate = null;\r\n\t\tthis.modifiedDate = null;\r\n\t\tthis.g_iApprovalId = approvalId;\r\n\t\t// The type of the annotation\r\n\t\tthis.g_iAnnotationType = eAnnotationTypes.Rectangle;\r\n\t\tthis.g_szColour = \"\";\r\n\t\tthis.g_oAnnotationData = null;\r\n\t\tthis.g_iOrigx = 0;\r\n\t\tthis.g_iOrigy = 0;\r\n\t\tthis.g_oDrawArray = [];\t\t\t// Used to hold the annotation bounding box coordinates.\r\n\t\tthis.g_oDrawCoordSetArray = []; // Used to hold the object array for each annotation shape point. Needed to send the annotationCoordId to the server.\r\n\t\tthis.g_oMarqueeDrawArray = [];\t// Used to hold the original Marquee coordinates as the Tech Tools Text Measurement needs them to reacquire the word list.\r\n\t\t// UV coordinates for translating 3d to 2D annotations\r\n\t\tthis.g_iuvX = 0;\r\n\t\tthis.g_iuvY = 0;\r\n\t\tthis.id = -1;\r\n\t\t// Properties to hold the annotation text content.\r\n\t\tthis.g_oTextMeasurementWordsArray = [];\r\n\t\t// Login Id of the users.\r\n\t\tthis.g_iAuthor = 0;\r\n\t\tthis.g_szAuthorEmail = \"\";\r\n\t\tthis.g_szAuthorDisplayName = \"\";\r\n\t\tthis.modifiedDate = null;\r\n\t\tthis.g_oReplies = [];\r\n\t\tthis.g_oStatuses = [];\r\n\t\tthis.g_bClosed = true;\r\n\t\tthis.g_bSaved = false;\r\n\t\tthis.g_bReadState = true;\r\n\t\tthis.g_bVisible = true;\r\n\t\tthis.g_iParentAnnotationId = 0;\r\n\t\tthis.g_iNumber = 0;\r\n\t\tthis.g_iDocumentId = 0;\r\n\t\tthis.g_iDocumentPageId = null;\r\n\t\tthis.g_bUnlocked = false;\r\n\t\tthis.dirtystate = false;\r\n\t\tthis.status = \"\";\r\n\t\tthis.g_bSVGTextAnnotation = false;\r\n\t\tthis.g_bSVGHoverAnnotation = false;\r\n\t\tthis.g_bSVGSearchAnnotation = false;\r\n\t\tthis.g_bSVGPositionUpdated = false;\r\n\t\tthis.g_oSVGVariable = null;\r\n\t\tthis.g_szSVGOriginalContent = \"\";\r\n\t\tthis.g_szTextHighlightContent = \"\";\r\n\t\tthis.attachments = [];\r\n\t}\r\n\r\n\t/*\r\n\t * - - - P U B L I C M E T H O D S - - -\r\n\t */\r\n\r\n\t/**\r\n\t * Renders an annotation div.\r\n\t * @param {int} type - What type of annotation to render.\r\n\t * @param {bool} editableInputType - Is to be rendered in read only mode.\r\n\t * @param {int} annotationReplyId - The ID of the reply which we are creating.\r\n\t * @param {any} oArtworkCanvas - The artwork canvas.\r\n\t * @param {any} oAnnotationCanvas - The annotation canvas.\r\n\t */\r\n\tAnnotation.prototype.createAnnotationDiv = function (type, editableInputType, annotationReplyId, oArtworkCanvas, oAnnotationCanvas) {\r\n\t\tvar svgDivID;\r\n\t\tvar classNames;\r\n\t\tvar origSvgDivID;\r\n\t\tvar oDestination;\r\n\t\tvar sztextContent = this.g_szTextContent;\r\n\t\tvar oAnnotationReplies = this.g_oReplies;\r\n\t\tvar oAnnotationStatuses = this.g_oStatuses;\r\n\t\tvar annotationDate = this.modifiedDate || this.createdDate;\r\n\t\tvar szArtworkCanvasId = oArtworkCanvas.g_szCanvasId;\r\n\t\tvar annotationIsReadOnly = editableInputType;\r\n\r\n\t\t// This will convert the hex string (if needed), to the class colour.\r\n\t\tvar szAnnotationcolour = g_oAnnotations.getStringColour(this.g_szColour);\r\n\t\t\r\n\t\t// If this is being drawn on the canvas\r\n\t\tif (type === eAnnotationDivType.Popup) {\r\n\t\t\tsvgDivID = this.id;\r\n\t\t\torigSvgDivID = this.id;\r\n\r\n\t\t\tclassNames = \"speechbubble annotation annotation\" + szAnnotationcolour;\r\n\t\t\tthis.g_bClosed = false;\r\n\r\n\t\t\t// Close any active bubbles, unless suppressed.\r\n\t\t\tif (g_oAnnotations.g_bOverrideCloseBubble) {\r\n\t\t\t\tg_oAnnotations.g_bOverrideCloseBubble = false;\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tfor (var i = 0; i < g_oActiveBubbles.length; i++) {\r\n\t\t\t\t\tg_oGreenlightMessages.closeBubble(g_oActiveBubbles[i].id, true, true);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// Remove all highlighted buttons.\r\n\t\t\t$(\".techToolType\").css(\"background-color\", \"\");\r\n\t\t\tremoveExistingHighlights(null);\r\n\r\n\t\t\t// Enable handle mouseover checking\r\n\t\t\tchangeCanvasFunction();\r\n\t\t}\r\n\t\t// If this is a list item.\r\n\t\telse {\r\n\t\t\tsvgDivID = \"li_\" + this.id;\r\n\t\t\torigSvgDivID = this.id;\r\n\t\t\tclassNames = \"annotationListItem annotationlist\" + szAnnotationcolour;\r\n\t\t}\r\n\r\n\t\tvar annotationStack = g_oAnnotations.filteredAnnotationStack(g_oAnnotations.g_oAnnotationsMade);\r\n\r\n\t\t// Iterate through the annotations and set the div children to open\r\n\t\tfor (var i = 0; i < annotationStack.length; i++) {\r\n\t\t\tif (annotationStack[i].g_iParentAnnotationId == svgDivID) { // Only when opening a pop-up\r\n\t\t\t\tannotationStack[i].g_bClosed = false;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Begin to build up the div elements.\r\n\t\tvar newDiv = document.createElement(\"div\");\r\n\t\tnewDiv.id = svgDivID;\r\n\t\tnewDiv.className = classNames;\r\n\t\tnewDiv.setAttribute(\"data-artworkcanvas\", szArtworkCanvasId);\r\n\r\n\t\t// Set the Destination of the object.\r\n\t\tif (type === eAnnotationDivType.Popup) {\r\n\t\t\toDestination = document.getElementById(\"divViewerCell\");\r\n\t\t\t// Set CSS to display to none to avoid the canvas widths from going out of sync.\r\n\t\t\t$(newDiv).css(\"display\", \"none\");\r\n\t\t}\r\n\t\telse {\r\n\t\t\toDestination = document.getElementById(\"divAnnDiv_ListItems\");\r\n\t\t}\r\n\r\n\t\t// Apply the div.\r\n\t\t$(oDestination).append(newDiv);\r\n\r\n\t\t// For 3D Annotations, place it statically.\r\n\t\tif (this.g_iAnnotationType === eAnnotationTypes.ThreeD && type === eAnnotationDivType.Popup) {\r\n\t\t\tvar existingAnnotation = $.grep(oArtworkCanvas.g_oScene.children, function (child) { return child.Id == svgDivID; });\r\n\t\t\tif (existingAnnotation.length > 0) {\r\n\t\t\t\tvar oAnnotation2DCoords = this.threeDToTwoDCoords(existingAnnotation[0].position, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\toAnnotation2DCoords.x += oArtworkCanvas.g_oContainer.offsetLeft;\r\n\t\t\t\t$(newDiv).css({ \"left\": oAnnotation2DCoords.x, \"top\": oAnnotation2DCoords.y });\r\n\t\t\t\t$(newDiv).css({ \"width\": 350 });\r\n\t\t\t\t$(newDiv).addClass(\"noAfter\");\r\n\t\t\t\t$(newDiv).show();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Now we are adding to the bubble itself\r\n\t\t// Reset the destination\r\n\t\toDestination = document.getElementById(svgDivID);\r\n\r\n\t\t// Add header bar.\r\n\t\tvar oHeaderBar = addDomElement(\"hb_\" + svgDivID, \"div\", null, \"HeaderBar\", null, null, oDestination);\r\n\t\toHeaderBar.setAttribute(\"data-artworkcanvas\", szArtworkCanvasId);\r\n\r\n\t\t// Track if a delete button is going to be added.\r\n\t\t// -- If this is the main canvas, the approval is not read only, the user is the author or unlocked, and the annotation has no replies or statuses.\r\n\t\t// -- If this is the main canvas, the approval is read only, and this is a new text measurement or new SVG text annotation.\r\n\t\t// -- If this is the compare canvas, and this is a new text measurement, text highlight or SVG text annotation.\r\n\t\tvar bAddDeleteButton = ((oArtworkCanvas.g_bMainCanvas && !g_oViewer.g_bReadOnly && (this.g_iAuthor === g_oUserDetails.UserId || this.g_bUnlocked) && $.isEmptyObject(this.g_oReplies) && $.isEmptyObject(this.g_oStatuses)) ||\r\n\t\t\t(oArtworkCanvas.g_bMainCanvas && g_oViewer.g_bReadOnly && (this.g_iAnnotationType === eAnnotationTypes.TextMeasurement || this.g_iAnnotationType === eAnnotationTypes.TextHighlight || this.g_iAnnotationType === eAnnotationTypes.TextClassification || this.g_bSVGTextAnnotation) && this.id < 0) ||\r\n\t\t\t(!oArtworkCanvas.g_bMainCanvas && (this.g_iAnnotationType === eAnnotationTypes.TextMeasurement || this.g_iAnnotationType === eAnnotationTypes.TextHighlight || this.g_iAnnotationType === eAnnotationTypes.TextClassification || this.g_bSVGTextAnnotation) && this.id < 0));\r\n\r\n\t\t// A new annotation has no close option - save or delete only!\r\n\t\tif ((type === eAnnotationDivType.Popup) && (this.id > 0 || !bAddDeleteButton)) {\t\t// If it's not a new annotation or there's no delete button (MUST have a delete button, close button or both).\r\n\t\t\t// Add close button\r\n\t\t\taddDomElement(svgDivID + \"_clo\", \"input\", \"img/Cancel-Close_wht_24.png\", \"closebutton\", g_oAnnotations.c_szCloseAnnotation, null, oHeaderBar);\r\n\t\t}\r\n\r\n\t\t// Determine if a delete/copy button should be added.\r\n\t\tif (bAddDeleteButton) {\r\n\r\n\t\t\t// Add the delete button.\r\n\t\t\taddDomElement(svgDivID + \"_del\", \"input\", \"img/Delete_wht_24.png\", \"deletebutton\", g_oAnnotations.c_szDeleteAnnotation, null, oHeaderBar);\r\n\r\n\t\t\t// Copy Annotation button.\r\n\t\t\tif (g_bMultiView && this.id > 0 && this.g_iAnnotationType === eAnnotationTypes.Global) {\r\n\r\n\t\t\t\t// Also make sure it's not in the blocked copy array.\r\n\t\t\t\tif ($.inArray(this.id, g_oMultiView.copiedAnnotationIds) === -1) {\r\n\t\t\t\t\taddDomElement(svgDivID + \"_batchAdd\", \"input\", \"img/Ann_Copy_All_v2.svg\", \"copybatchbutton\", g_oAnnotations.c_szCopyAnnotationBatch, null, oHeaderBar);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Add an annotation audit icon if this is not a new annotation.\r\n\t\tif (this.id > 0) {\r\n\t\t\taddDomElement(svgDivID + \"_annotationaudit\", \"input\", \"img/Annotation-Audit_wht_24.png\", \"annotationauditbutton\", g_oAudit.c_szOpenAnnotationAudit, null, oHeaderBar);\r\n\t\t}\r\n\r\n\t\t// Add an annotation data icon if this annotation has data to be shown.\r\n\t\tif (this.g_oAnnotationData != null && this.g_oAnnotationData.AdditionalData != null && this.id > 0) {\r\n\t\t\taddDomElement(svgDivID + \"_annotationdata\", \"input\", \"img/Annotation-Data_wht_24.png\", \"annotationdatabutton\", \"View Annotation Data\", null, oHeaderBar);\r\n\t\t}\r\n\r\n\t\t// Add document attachment icon if the user created this annotation, or this is an unlocked annotation.\r\n\t\tif ((this.g_iAuthor === g_oUserDetails.UserId || this.g_bUnlocked) && !g_oViewer.g_bReadOnly && oArtworkCanvas.g_bMainCanvas) {\r\n\t\t\taddDomElement(svgDivID + \"_annotationattachment\", \"input\", \"img/paperclip_wht_24.png\", \"annotationattachmentbutton\", g_oAnnotations.c_szAnnotationAttachDocumentPrompt, null, oHeaderBar);\r\n\t\t}\r\n\r\n\t\t// If this is a list item.\r\n\t\tif (type === eAnnotationDivType.ListItem) {\r\n\r\n\t\t\t// List items get a number.\r\n\t\t\tvar annNumberContainer = document.createElement(\"span\");\r\n\t\t\tannNumberContainer.className = \"annNumber\";\r\n\t\t\tannNumberContainer.innerHTML = this.g_iNumber;\r\n\r\n\t\t\t// Hide the list item number if required.\r\n\t\t\tif (!g_oSettings.g_oUserSettings.ShowAnnotationNumbers) {\r\n\t\t\t\tannNumberContainer.style.display = \"none\";\r\n\t\t\t}\r\n\r\n\t\t\t// Add the list item number.\r\n\t\t\toDestination.appendChild(annNumberContainer);\r\n\t\t}\r\n\r\n\t\t// No date means a new annotation! Make it editable by default\r\n\t\t// Or if we called this function via the edit button in which case the editableInputType will be false (for main text box)\r\n\t\tif (annotationDate == null || !editableInputType) {\r\n\t\t\tannotationIsReadOnly = false;\r\n\t\t\tannotationDate = Date.now();\r\n\t\t\tchangeCanvasFunction(\"#AnnotationViewer\");\r\n\t\t}\r\n\r\n\t\t// If it's an annotation created by the Text Measurement or Text Highlight tool on an Asset, the annotation needs to be read-only if this is not a live approval.\r\n\t\tif ((this.g_iAnnotationType === eAnnotationTypes.TextMeasurement || this.g_iAnnotationType === eAnnotationTypes.TextHighlight || this.g_iAnnotationType === eAnnotationTypes.TextClassification) && (g_oAnnotations.g_iApprovalId === 0 || g_oViewer.g_bReadOnly)) {\r\n\t\t\tannotationIsReadOnly = true;\r\n\t\t}\r\n\r\n\t\t// If this is an SVG annotation, the annotation needs to be read-only if this is not a live approval or the user does not have text edit access.\r\n\t\tif (this.g_bSVGTextAnnotation && (g_oAnnotations.g_iApprovalId === 0 || g_oViewer.g_bReadOnly || !g_oUserDetails.CreateTextEditing)) {\r\n\t\t\tannotationIsReadOnly = true;\r\n\t\t}\r\n\r\n\t\t// If this annotation is not on the main canvas, the annotation needs to be read-only.\r\n\t\tif (!oArtworkCanvas.g_bMainCanvas) {\r\n\t\t\tannotationIsReadOnly = true;\r\n\t\t}\r\n\r\n\t\t// Create the popup content div.\r\n\t\tvar oPopupContent = document.createElement(\"div\");\r\n\t\t$(oPopupContent).addClass(\"popup-content\");\r\n\t\toDestination.appendChild(oPopupContent);\r\n\r\n\t\t// Outline the default JQTE options to be used.\r\n\t\tvar oJQTEOptions = null;\r\n\r\n\t\t// Outline the default JQTE background colour to be used.\r\n\t\tvar szJQTEBackgroundColour = null;\r\n\r\n\t\t// If this is an editable SVG text annotation.\r\n\t\tif (this.g_bSVGTextAnnotation === true && !annotationIsReadOnly) {\r\n\r\n\t\t\t// Get the JQTE options for this SVG text annotation.\r\n\t\t\toJQTEOptions = g_oSVGText.getJQTEOptions(this.g_oSVGVariable.switchId, oArtworkCanvas, oAnnotationCanvas);\r\n\r\n\t\t\t// Get the JQTE background colour for this SVG text annotation.\r\n\t\t\tszJQTEBackgroundColour = g_oSVGText.getJQTEBackgroundColour(this.g_oSVGVariable.switchId, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t}\r\n\r\n\t\t// If this is an editable text classification annotation.\r\n\t\tif (this.g_iAnnotationType === eAnnotationTypes.TextClassification && !annotationIsReadOnly) {\r\n\r\n\t\t\t// Get the JQTE options for text classification annotations.\r\n\t\t\toJQTEOptions = g_oAnnotationTextClassification.g_oJQTEOptions;\r\n\t\t}\r\n\r\n\t\t// Create the annotation text area.\r\n\t\tthis.createAnnotationTextArea(\"ti\" + svgDivID, this.g_iAuthor, this.g_szAuthorEmail, this.g_szAuthorDisplayName, 0, annotationIsReadOnly, sztextContent, oPopupContent, annotationDate, this.id, oArtworkCanvas, oAnnotationCanvas, oJQTEOptions, szJQTEBackgroundColour);\r\n\r\n\t\t// Create an annotation text area for any replies that exist.\r\n\t\tif (oAnnotationReplies !== null) {\r\n\t\t\tvar replyContainer = document.createElement(\"div\");\r\n\t\t\tvar replyContainerId = \"rc_\" + svgDivID;\r\n\t\t\treplyContainer.id = replyContainerId;\r\n\t\t\toPopupContent.appendChild(replyContainer);\r\n\r\n\t\t\t// Assume this is a reply.\r\n\t\t\tvar iFieldType = eFieldTypes.ReplyHeader;\r\n\r\n\t\t\tvar bReadOnly = true;\r\n\t\t\tfor (var j = 0; j < oAnnotationReplies.length; j++) {\r\n\t\t\t\t// If this is the same author, we are loading in edit mode, only render the reply in edit mode that was clicked.\r\n\t\t\t\tif (parseInt(oAnnotationReplies[j].g_iAuthor) === g_oUserDetails.UserId && editableInputType\r\n\t\t\t\t\t&& oAnnotationReplies[j].id == annotationReplyId && this.g_iApprovalId === g_oAnnotations.g_iApprovalId) {\r\n\t\t\t\t\tbReadOnly = false;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Determine the date to be used.\r\n\t\t\t\tvar oReplyDate = oAnnotationReplies[j].modifiedDate || oAnnotationReplies[j].createdDate;\r\n\t\t\t\t\r\n\t\t\t\toAnnotationReplies[j].createAnnotationTextArea(\"ar_\" + (type === eAnnotationDivType.Popup ? \"\" : \"li_\") + oAnnotationReplies[j].g_iParentAnnotationId, oAnnotationReplies[j].g_iAuthor, oAnnotationReplies[j].g_szAuthorEmail, oAnnotationReplies[j].g_szAuthorDisplayName, iFieldType, bReadOnly, oAnnotationReplies[j].g_szTextContent, document.getElementById(replyContainerId), oReplyDate, oAnnotationReplies[j].id, oArtworkCanvas, oAnnotationCanvas, null, null);\r\n\t\t\t\tiFieldType = eFieldTypes.ReplyHeader;\r\n\t\t\t\tbReadOnly = true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Create the status container div.\r\n\t\tvar statusContainer = document.createElement(\"div\");\r\n\t\tvar statusContainerId = \"sc_\" + svgDivID;\r\n\t\tstatusContainer.id = statusContainerId;\r\n\t\toDestination.appendChild(statusContainer);\r\n\r\n\t\t// Add in any annotation statuses.\r\n\t\tif (oAnnotationStatuses !== null) {\r\n\t\t\tiFieldType = eFieldTypes.StatusHeader;\r\n\t\t\tbReadOnly = true;\r\n\t\t\tfor (var j = 0; j < oAnnotationStatuses.length; j++) {\r\n\t\t\t\tvar annStatusList = [\"Initial\", \"Approved\", \"Rejected\", \"Query\", \"ToDo\"];\r\n\t\t\t\tthis.createAnnotationTextArea(oAnnotationStatuses[j].id, oAnnotationStatuses[j].g_iAuthor, oAnnotationStatuses[j].g_szAuthorEmail, oAnnotationStatuses[j].g_szAuthorDisplayName, iFieldType, bReadOnly, annStatusList[oAnnotationStatuses[j].g_iAnnotationStatus], document.getElementById(statusContainerId), new Date(oAnnotationStatuses[j].annotationStatusDateTime), undefined, oArtworkCanvas, oAnnotationCanvas, null, null);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Add in the status buttons.\r\n\t\tif (this.createdDate !== null && g_oUserDetails.CreateStatus && !g_oViewer.g_bReadOnly && oArtworkCanvas.g_bMainCanvas) {\r\n\r\n\t\t\t// The status icons require two classes to enable the event which is called when setting a status\r\n\t\t\t// to set the CSS correctly. The group as a whole (all four statuses) has a class set per annotation div, to allow\r\n\t\t\t// for the resetting of the class from the same event. We also require a class each status separately. This cannot\r\n\t\t\t// be an Id, as it will exist as both a list item and on the canvas.\r\n\t\t\tvar statusGroupId = \"statusGroup_\" + this.id;\r\n\r\n\t\t\t// Get any existing status left by this user.\r\n\t\t\tvar oExistingStatus = $.grep(this.g_oStatuses, function (status) { return status.g_iAuthor == g_oUserDetails.UserId; });\r\n\r\n\t\t\t// If this is an unlocked annotation, all users share a single annotation status.\r\n\t\t\tif (this.g_bUnlocked) {\r\n\t\t\t\toExistingStatus = this.g_oStatuses;\r\n\t\t\t}\r\n\r\n\t\t\t// Extract the existing status to be used.\r\n\t\t\tvar iExistingStatus = oExistingStatus.length === 0 ? 0 : oExistingStatus[0].g_iAnnotationStatus;\r\n\r\n\t\t\t// Render the status icons.\r\n\t\t\tthis.renderAnnotationStatusIcons(statusGroupId, oDestination, iExistingStatus, svgDivID);\r\n\t\t}\r\n\r\n\t\t// Add in the annotation reply buttons.\r\n\t\tif ((annotationIsReadOnly || !editableInputType) && this.createdDate !== null && g_oUserDetails.CreateReply && !g_oViewer.g_bReadOnly && oArtworkCanvas.g_bMainCanvas) {\r\n\t\t\tvar oThisAnnotation = this;\r\n\r\n\t\t\t// Outline the button function.\r\n\t\t\tvar replyButtonFunction = function () {\r\n\r\n\t\t\t\t// Do not allow for multiple editors, so return early.\r\n\t\t\t\tif ($('.jqte_editor').length > 0) {\r\n\t\t\t\t\tg_oGreenlightMessages.displayWarningBubble(g_oAnnotations.c_szUnsavedAnnotationReply);\r\n\t\t\t\t\tg_oAnnotations.g_bOverrideCloseBubble = true;\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Determine if this is a list item.\r\n\t\t\t\tvar szButtonId = (event.toElement == undefined) ? event.target.id : event.toElement.id;\r\n\t\t\t\tvar bListItem = szButtonId.indexOf(\"_li_\") != -1;\r\n\r\n\t\t\t\t// Get the annotation.\r\n\t\t\t\tvar oAnnotationItem = bListItem ? $(\"#li_\" + oThisAnnotation.id)[0] : $(\"#\" + oThisAnnotation.id)[0];\r\n\t\t\t\t\r\n\t\t\t\t// If this is a popup that will overflow the bottom of the canvas.\r\n\t\t\t\tif (!bListItem && Annotation.prototype.preReplyScrollRequired(oAnnotationItem)) {\r\n\r\n\t\t\t\t\t// Move the popup up to make room for the reply.\r\n\t\t\t\t\t$(oAnnotationItem).css(\"top\", (parseInt($(oAnnotationItem).css(\"top\").replace(\"px\", \"\")) - 100) + \"px\");\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Create the reply text area.\r\n\t\t\t\tvar id = origSvgDivID;\r\n\t\t\t\tvar result = $.grep(annotationStack, function (annotation) { return annotation.id == oThisAnnotation.id; });\r\n\t\t\t\tresult[0].createAnnotationTextArea(\"ar_\" + svgDivID, oThisAnnotation.g_iAuthor, g_oUserDetails.EmailAddress, \"\", 1, 0, \"\", document.getElementById(replyContainerId), Date.now(), id, oArtworkCanvas, oAnnotationCanvas, null, null);\r\n\t\t\t\tresult[0].g_bSaved = false;\r\n\r\n\t\t\t\t// Auto scroll the annotation.\r\n\t\t\t\tAnnotation.prototype.scrollReplyAnnotation(oAnnotationItem, bListItem);\r\n\t\t\t};\r\n\r\n\t\t\taddDomElement(\"rb_\" + svgDivID, \"input\", \"img/Reset-Form_wht_16.png\", \"replyButton\", g_oAnnotations.c_szAnnotationAddReplyPrompt, replyButtonFunction, oDestination);\r\n\t\t\t$(\".addShapeButton\").css(\"cursor\", \"pointer\"); // IE & Edge don't like this set through the CSS, so force it manually.\r\n\t\t}\r\n\r\n\t\t// Add multi shape support.\r\n\t\t// Only show button if the user is the original author of the annotation, it isn't a global annotation\r\n\t\t// and it isn't a 3D or SVG Text Annotation.\r\n\t\tif (this.g_iAuthor === g_oUserDetails.UserId && this.createdDate !== null && !g_oViewer.g_bReadOnly && oArtworkCanvas.g_bMainCanvas\r\n\t\t\t&& (this.g_iAnnotationType !== eAnnotationTypes.Global && this.g_iAnnotationType !== eAnnotationTypes.ThreeD && this.g_iAnnotationType !== eAnnotationTypes.TextMeasurement && this.g_iAnnotationType !== eAnnotationTypes.TextHighlight && this.g_iAnnotationType !== eAnnotationTypes.TextClassification && this.g_iAnnotationType !== eAnnotationTypes.BarcodeMeasurement\r\n\t\t\t\t&& this.g_iAnnotationType !== eAnnotationTypes.ColourDensityMeasurement && this.g_iAnnotationType !== eAnnotationTypes.ColourDensityMeasurementPostit && this.g_bSVGTextAnnotation !== true)) {\r\n\t\t\tvar oCurrentAnnotation = this;\r\n\t\t\tg_oAnnotations.g_oLastAnnotation = this;\r\n\t\t\tvar addShapeButtonFunction = function () {\r\n\r\n\t\t\t\t// Display the add shape info bubble.\r\n\t\t\t\tg_oGreenlightMessages.displayInfoBubble(g_oAnnotations.c_szMakingShapeTip, true);\r\n\t\t\t\t$('#AnnotationViewer').css(\"cursor\", \"crosshair\");\r\n\t\t\t\tg_oAnnotations.g_szPrevCursorStyle = \"crosshair\";\r\n\r\n\t\t\t\t// Get the artwork and annotation canvas.\r\n\t\t\t\tvar oArtworkCanvas = g_oViewer.getCanvas(szArtworkCanvasId);\r\n\t\t\t\tvar oAnnotationCanvas = oArtworkCanvas.g_oAnnotationCanvas;\r\n\r\n\t\t\t\t// Delete the div to clear the dotted line to annotation div if present\r\n\t\t\t\t$(this).parent().remove();\r\n\t\t\t\tg_oAnnotations.rebuildAnnotationList(oArtworkCanvas, oAnnotationCanvas);\r\n\r\n\t\t\t\t$(\".annotationviewer\").off(\"pointerdown\");\r\n\t\t\t\t$(\".annotationviewer\").off(\"pointerup\");\r\n\r\n\t\t\t\toAnnotationCanvas.redraw(false);\r\n\t\t\t\tvar result = $.grep(annotationStack, function (annotation) { return annotation.id == oCurrentAnnotation.id; });\r\n\r\n\t\t\t\t// Set the annotation type and colour to the same as the parent\r\n\t\t\t\tg_oAnnotations.g_iAnnotationType = result[0].g_iAnnotationType;\r\n\t\t\t\tg_oAnnotations.g_oAnnotationColSelected = g_oAnnotations.getStringColour(result[0].g_szColour);\r\n\r\n\t\t\t\t// Update colour preference by faking a click on the correct colour.\r\n\t\t\t\t$(\"#annotate\" + g_oAnnotations.g_oAnnotationColSelected[0].toUpperCase() + g_oAnnotations.g_oAnnotationColSelected.slice(1)).click();\r\n\r\n\t\t\t\tg_oAnnotations.initiateAnnotationDraw(result[0], oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t};\r\n\r\n\t\t\taddDomElement(\"asb_\" + svgDivID, \"input\", \"img/Freedraw annotation_wht_16.png\", \"addShapeButton\", g_oAnnotations.c_szAnnotationAddShapePrompt, addShapeButtonFunction, oDestination);\r\n\t\t\t$(\".addShapeButton\").css(\"cursor\", \"pointer\"); // IE & Edge don't like this set through the CSS, so force it manually.\r\n\t\t}\r\n\r\n\t\t// We allow the colour of the annotation to be changed if:\r\n\t\t// This is not a read only approval.\r\n\t\t// This is an annotation on the main canvas.\r\n\t\t// The user created the annotation, or the annotation is unlocked.\r\n\t\tif (!g_oViewer.g_bReadOnly && oArtworkCanvas.g_bMainCanvas && (this.g_iAuthor === g_oUserDetails.UserId || this.g_bUnlocked)) {\r\n\t\t\t// Annotation colour change\r\n\t\t\tvar colourSelectionFunction = function () {\r\n\t\t\t\t// define global variable for annotation id.\r\n\t\t\t\tg_oAnnotations.g_AnnotationId = origSvgDivID;\r\n\t\t\r\n\t\t\t\t// Get the artwork and annotation canvas.\r\n\t\t\t\tvar oArtworkCanvas = g_oViewer.getCanvas(szArtworkCanvasId);\r\n\t\t\t\tvar oAnnotationCanvas = oArtworkCanvas.g_oAnnotationCanvas;\r\n\t\t\r\n\t\t\t\t// Call the Select colour\r\n\t\t\t\tAnnotation.prototype.SelectColourFromDisplay(oAnnotationCanvas);\r\n\t\t\t};\r\n\t\t\r\n\t\t\t// If hidden we need to show our colour selection.\r\n\t\t\t$(\"scPop_\" + svgDivID).show;\r\n\t\t\taddDomElement(\"scPop_\" + svgDivID, \"input\", \"img/Annotation_colour_16_pb.png\", \"colourSelection\", g_oAnnotations.c_szColourAnnotationText, colourSelectionFunction, oDestination);\r\n\t\t\t$(\".colourSelection\").css(\"cursor\", \"pointer\"); // IE & Edge don't like this set through the css, so force it manually.\r\n\t\t}\r\n\t\telse {\r\n\t\t\t$(\"scPop_\" + svgDivID).hide;\r\n\t\t}\r\n\r\n\t\t// Add text support if:\r\n\t\t// This is not a read only approval.\r\n\t\t// This is an annotation on the main canvas.\r\n\t\t// This is a text based annotation.\r\n\t\t// The user created the annotation, or the annotation is unlocked.\r\n\t\tif (!g_oViewer.g_bReadOnly && oArtworkCanvas.g_bMainCanvas && (this.g_iAnnotationType == eAnnotationTypes.TextHighlight || this.g_iAnnotationType == eAnnotationTypes.TextClassification) && (this.g_iAuthor === g_oUserDetails.UserId || this.g_bUnlocked)) {\r\n\r\n\t\t\t// Extract the text annotation.\r\n\t\t\tvar oTextAnnotation = this;\r\n\r\n\t\t\t// Outline the add text button function.\r\n\t\t\tvar addTextButtonFunction = function () {\r\n\r\n\t\t\t\t// Initialise the highlight once the data has been loaded.\r\n\t\t\t\tvar oAddCallbackAction = function () {\r\n\t\t\t\t\t\r\n\t\t\t\t\t// Set that this will be an addition to an existing annotation.\r\n\t\t\t\t\tg_oTextTools.g_iExistingAnnotationId = oTextAnnotation.id;\r\n\r\n\t\t\t\t\t// Set up the existing annotation text.\r\n\t\t\t\t\tg_oTextTools.g_oAnnotationText = JSON.parse(oTextAnnotation.g_szTextHighlightContent);\r\n\r\n\t\t\t\t\t// Initialise the highlight.\r\n\t\t\t\t\tg_oTextTools.initialiseTextTool(g_oTextTools.g_eToolTypes.TextHighlight, oTextAnnotation.g_iAnnotationType, JSON.parse(oTextAnnotation.g_szTextHighlightContent)[0].startingText.character != undefined, false, oTextAnnotation.g_szColour);\r\n\t\t\t\t};\r\n\r\n\t\t\t\t// Load the text data.\r\n\t\t\t\tg_oTextData.loadTextData(oArtworkCanvas.g_oDoc.documentId, oArtworkCanvas.g_iCurrentPage, true, oAddCallbackAction);\r\n\t\t\t};\r\n\r\n\t\t\t// Outline the remove text button function.\r\n\t\t\tvar removeTextButtonFunction = function () {\r\n\r\n\t\t\t\t// Initialise the highlight once the data has been loaded.\r\n\t\t\t\tvar oRemoveCallbackAction = function () {\r\n\r\n\t\t\t\t\t// Set that this will be an addition to an existing annotation.\r\n\t\t\t\t\tg_oTextTools.g_iExistingAnnotationId = oTextAnnotation.id;\r\n\r\n\t\t\t\t\t// Set up the existing annotation text.\r\n\t\t\t\t\tg_oTextTools.g_oAnnotationText = JSON.parse(oTextAnnotation.g_szTextHighlightContent);\r\n\r\n\t\t\t\t\t// Initialise the highlight.\r\n\t\t\t\t\tg_oTextTools.initialiseTextTool(g_oTextTools.g_eToolTypes.RemoveTextHighlight, oTextAnnotation.g_iAnnotationType, JSON.parse(oTextAnnotation.g_szTextHighlightContent)[0].startingText.character != undefined, false, oTextAnnotation.g_szColour);\r\n\t\t\t\t};\r\n\r\n\t\t\t\t// Load the text data.\r\n\t\t\t\tg_oTextData.loadTextData(oArtworkCanvas.g_oDoc.documentId, oArtworkCanvas.g_iCurrentPage, true, oRemoveCallbackAction);\r\n\t\t\t};\r\n\r\n\t\t\t// Add the buttons.\r\n\t\t\taddDomElement(\"atb_\" + svgDivID, \"input\", \"img/TextCursor_16 white.png\", \"addTextButton\", \"Add Text to Highlight\", addTextButtonFunction, oDestination);\r\n\t\t\taddDomElement(\"rtb_\" + svgDivID, \"input\", \"img/TextCursorRemove_16 white.png\", \"removeTextButton\", \"Remove Text from Highlight\", removeTextButtonFunction, oDestination);\r\n\r\n\t\t\t// Set the cursors to a pointer.\r\n\t\t\t$(\".addTextButton\").css(\"cursor\", \"pointer\");\r\n\t\t\t$(\".removeTextButton\").css(\"cursor\", \"pointer\");\r\n\t\t}\r\n\r\n\t\t// If this is a popup.\r\n\t\tif (type === eAnnotationDivType.Popup) {\r\n\r\n\t\t\t// Add a annotation attachment container for annotation bubble.\r\n\t\t\tvar oAnnotationAttachmentBubbleContainer = document.createElement(\"div\");\r\n\t\t\toAnnotationAttachmentBubbleContainer.id = \"annotationAttachmentBubble_Container_\" + this.id.toString();\r\n\t\t\toAnnotationAttachmentBubbleContainer.display = true;\r\n\t\t\toDestination.appendChild(oAnnotationAttachmentBubbleContainer);\r\n\r\n\t\t\t// Prevent drag & drop on the attachment list.\r\n\t\t\t$('#' + oAnnotationAttachmentBubbleContainer.id).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\t$('#' + oAnnotationAttachmentBubbleContainer.id).css('cursor', \"default\");\r\n\r\n\t\t\t// Render the attachments for this annotation bubble.\r\n\t\t\tg_oAnnotationAttachments.renderAnnotationAttachments(this.id, \"annotationAttachmentBubble_\");\r\n\t\t}\r\n\r\n\t\t// If this is a list item.\r\n\t\tif (type === eAnnotationDivType.ListItem) {\r\n\r\n\t\t\t// Add a annotation attachment container for list item.\r\n\t\t\tvar oAnnotationAttachmentContainer = document.createElement(\"div\");\r\n\t\t\toAnnotationAttachmentContainer.id = \"annotationAttachment_Container_\" + this.id.toString();\r\n\t\t\toAnnotationAttachmentContainer.display = true;\r\n\t\t\toDestination.appendChild(oAnnotationAttachmentContainer);\r\n\t\t\t// render the attachments for this annotation list item.\r\n\t\t\tg_oAnnotationAttachments.renderAnnotationAttachments(this.id, \"annotationAttachment_\");\r\n\r\n\t\t\t// Add a hidden annotation audit container.\r\n\t\t\tvar oAnnotationAuditContainer = document.createElement(\"div\");\r\n\t\t\toAnnotationAuditContainer.id = this.id + \"_annotationAuditContainer\";\r\n\t\t\toAnnotationAuditContainer.display = false;\r\n\t\t\toDestination.appendChild(oAnnotationAuditContainer);\r\n\r\n\t\t\t// Add a hidden annotation data container.\r\n\t\t\tvar oAnnotationDataContainer = document.createElement(\"div\");\r\n\t\t\toAnnotationDataContainer.id = this.id + \"_annotationDataContainer\";\r\n\t\t\toAnnotationDataContainer.display = false;\r\n\t\t\toDestination.appendChild(oAnnotationDataContainer);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Apends the annotation status icons to an annotation Div.\r\n\t * @param {string} statusGroupId The status group id assigned to the set of icons getting rendered.\r\n\t * @param {object} destination - The div the icons are getting appended to.\r\n\t * @param {number} annotationStatus - The passed in annotation status\r\n\t * @param {string} svgDivId - The unique id for the Div Id.\r\n\t */\r\n\tAnnotation.prototype.renderAnnotationStatusIcons = function (statusGroupId, destination, annotationStatus, svgDivId) {\r\n\t\taddDomElement(svgDivId + \"_Approved\", \"input\", (annotationStatus == eAnnotationStatuses.Approved ? \"img/Status_Approved_Inverted_16.svg\" : \"img/Status_Approved_White_16.svg\"), \"fas fa-check addStatusButton approve \" + statusGroupId + \" Approved_\" + statusGroupId, (annotationStatus == eAnnotationStatuses.Approved ? g_oAnnotations.c_szRemoveStatus : g_oAnnotations.c_szApproveAnnotation), null, destination, \"data-annotationStatus\", \"Approved\");\r\n\t\taddDomElement(svgDivId + \"_Rejected\", \"input\", (annotationStatus == eAnnotationStatuses.Rejected ? \"img/Status_Rejected_Inverted_16.svg\" : \"img/Status_Rejected_White_16.svg\"), \"fas fa-times addStatusButton reject \" + statusGroupId + \" Rejected_\" + statusGroupId, (annotationStatus == eAnnotationStatuses.Rejected ? g_oAnnotations.c_szRemoveStatus : g_oAnnotations.c_szRejectAnnotation), null, destination, \"data-annotationStatus\", \"Rejected\");\r\n\t\taddDomElement(svgDivId + \"_Query\", \"input\", (annotationStatus == eAnnotationStatuses.Query ? \"img/Status_Query_Inverted_16.svg\" : \"img/Status_Query_White_16.svg\"), \"fas fa-question addStatusButton query \" + statusGroupId + \" Query_\" + statusGroupId, (annotationStatus == eAnnotationStatuses.Query ? g_oAnnotations.c_szRemoveStatus : g_oAnnotations.c_szQueryAnnotation), null, destination, \"data-annotationStatus\", \"Query\");\r\n\t\taddDomElement(svgDivId + \"_ToDo\", \"input\", (annotationStatus == eAnnotationStatuses.ToDo ? \"img/Status_ToDo_Inverted_16.svg\" : \"img/Status_ToDo_White_16.svg\"), \"fas fa-tasks addStatusButton todo \" + statusGroupId + \" ToDo_\" + statusGroupId, (annotationStatus == eAnnotationStatuses.ToDo ? g_oAnnotations.c_szRemoveStatus : g_oAnnotations.c_szTodoAnnotation), null, destination, \"data-annotationStatus\", \"ToDo\");\r\n\t};\r\n\r\n\t/**\r\n\t * Updates the status icon tooltips based on the status change.\r\n\t * @param {int} id - The id of the annotation to update the status for.\r\n\t * @param {int} iStatusCode - The active status code.\r\n\t * @param {int} iStatusChangeAction - The status change action.\r\n\t */\r\n\tAnnotation.prototype.renderAnnotationStatusTooltips = function (id, iStatusCode, iStatusChangeAction) {\r\n\t\t\r\n\t\t// Get a list of annotation approved status icons for this annotation.\r\n\t\tvar oApprovedIcons = $(\".Approved_statusGroup_\" + id);\r\n\r\n\t\t// Loop through each of the approved icons.\r\n\t\tfor (var i = 0; i < oApprovedIcons.length; i++) {\r\n\t\t\tvar oApprovedIcon = oApprovedIcons[i];\r\n\r\n\t\t\t// The control has already been hovered over by the mouse and Tooltipster has created the custom tooltip and removed the 'title' attribute.\r\n\t\t\tif ($(oApprovedIcon).hasClass(\"tooltipstered\")) {\r\n\t\t\t\t$(oApprovedIcon).tooltipster('content', (iStatusCode == eAnnotationStatuses.Approved && iStatusChangeAction != eAnnotationStatusUpdateType.deleteStatus ? g_oAnnotations.c_szRemoveStatus : g_oAnnotations.c_szApproveAnnotation));\r\n\t\t\t}\r\n\t\t\t// The control has not yet been hovered.\r\n\t\t\telse {\r\n\t\t\t\t$(oApprovedIcon).attr(\"title\", (iStatusCode == eAnnotationStatuses.Approved && iStatusChangeAction != eAnnotationStatusUpdateType.deleteStatus ? g_oAnnotations.c_szRemoveStatus : g_oAnnotations.c_szApproveAnnotation));\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Get a list of annotation rejected status icons for this annotation.\r\n\t\tvar oRejectedIcons = $(\".Rejected_statusGroup_\" + id);\r\n\r\n\t\t// Loop through each of the approved icons.\r\n\t\tfor (var i = 0; i < oRejectedIcons.length; i++) {\r\n\t\t\tvar oRejectedIcon = oRejectedIcons[i];\r\n\r\n\t\t\t// The control has already been hovered over by the mouse and Tooltipster has created the custom tooltip and removed the 'title' attribute.\r\n\t\t\tif ($(oRejectedIcon).hasClass(\"tooltipstered\")) {\r\n\t\t\t\t$(oRejectedIcon).tooltipster('content', (iStatusCode == eAnnotationStatuses.Rejected && iStatusChangeAction != eAnnotationStatusUpdateType.deleteStatus ? g_oAnnotations.c_szRemoveStatus : g_oAnnotations.c_szRejectAnnotation));\r\n\t\t\t}\r\n\t\t\t// The control has not yet been hovered.\r\n\t\t\telse {\r\n\t\t\t\t$(oRejectedIcon).attr(\"title\", (iStatusCode == eAnnotationStatuses.Rejected && iStatusChangeAction != eAnnotationStatusUpdateType.deleteStatus ? g_oAnnotations.c_szRemoveStatus : g_oAnnotations.c_szRejectAnnotation));\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Get a list of annotation query status icons for this annotation.\r\n\t\tvar oQueryIcons = $(\".Query_statusGroup_\" + id);\r\n\r\n\t\t// Loop through each of the approved icons.\r\n\t\tfor (var i = 0; i < oQueryIcons.length; i++) {\r\n\t\t\tvar oQueryIcon = oQueryIcons[i];\r\n\r\n\t\t\t// The control has already been hovered over by the mouse and Tooltipster has created the custom tooltip and removed the 'title' attribute.\r\n\t\t\tif ($(oQueryIcon).hasClass(\"tooltipstered\")) {\r\n\t\t\t\t$(oQueryIcon).tooltipster('content', (iStatusCode == eAnnotationStatuses.Query && iStatusChangeAction != eAnnotationStatusUpdateType.deleteStatus ? g_oAnnotations.c_szRemoveStatus : g_oAnnotations.c_szQueryAnnotation));\r\n\t\t\t}\r\n\t\t\t// The control has not yet been hovered.\r\n\t\t\telse {\r\n\t\t\t\t$(oQueryIcon).attr(\"title\", (iStatusCode == eAnnotationStatuses.Query && iStatusChangeAction != eAnnotationStatusUpdateType.deleteStatus ? g_oAnnotations.c_szRemoveStatus : g_oAnnotations.c_szQueryAnnotation));\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Get a list of annotation to do status icons for this annotation.\r\n\t\tvar oToDoIcons = $(\".ToDo_statusGroup_\" + id);\r\n\r\n\t\t// Loop through each of the approved icons.\r\n\t\tfor (var i = 0; i < oToDoIcons.length; i++) {\r\n\t\t\tvar oToDoIcon = oToDoIcons[i];\r\n\r\n\t\t\t// The control has already been hovered over by the mouse and Tooltipster has created the custom tooltip and removed the 'title' attribute.\r\n\t\t\tif ($(oToDoIcon).hasClass(\"tooltipstered\")) {\r\n\t\t\t\t$(oToDoIcon).tooltipster('content', (iStatusCode == eAnnotationStatuses.ToDo && iStatusChangeAction != eAnnotationStatusUpdateType.deleteStatus ? g_oAnnotations.c_szRemoveStatus : g_oAnnotations.c_szTodoAnnotation));\r\n\t\t\t}\r\n\t\t\t// The control has not yet been hovered.\r\n\t\t\telse {\r\n\t\t\t\t$(oToDoIcon).attr(\"title\", (iStatusCode == eAnnotationStatuses.ToDo && iStatusChangeAction != eAnnotationStatusUpdateType.deleteStatus ? g_oAnnotations.c_szRemoveStatus : g_oAnnotations.c_szTodoAnnotation));\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Generates the annotation header details.\r\n\t * @param {int} iType - The type of annotation we are creating.\r\n\t * @param {string} szCreatorEmail - The email address of the creator.\r\n\t * @param {string} szCreatorDisplayName - The display name of the creator.\r\n\t * @param {object} oDate - The date.\r\n\t * @returns {object} - The created annotation header .\r\n\t */\r\n\tvar generateAnnotationHeaderDetails = function (iType, szCreatorEmail, szCreatorDisplayName, oDate) {\r\n\r\n\t\t// Create the header element.\r\n\t\tvar oAnnHeader = document.createElement(\"p\");\r\n\r\n\t\t// Add the display name.\r\n\t\toAnnHeader.innerHTML = g_oAnnotations.getDisplayName(szCreatorEmail, szCreatorDisplayName);\r\n\r\n\t\t// If we have a date, add this.\r\n\t\tif (!!oDate) {\r\n\t\t\toAnnHeader.innerHTML += \" \" + formatDate(oDate);\r\n\t\t}\r\n\r\n\t\t// Add the status field if this is a status header.\r\n\t\tif (iType == eFieldTypes.StatusHeader) {\r\n\t\t\toAnnHeader.innerHTML = \"\" + oAnnHeader.innerHTML + \"\";\r\n\t\t}\r\n\r\n\t\t// Set the relevant CSS stylings.\r\n\t\tvar szHeaderClass;\r\n\t\tswitch (iType) {\r\n\t\t\tcase eFieldTypes.StatusHeader: szHeaderClass = \"HeaderTextStatus\"; break;\r\n\t\t\tcase eFieldTypes.ReplyHeader: szHeaderClass = \"HeaderTextReply\"; break;\r\n\t\t\tdefault: szHeaderClass = \"HeaderText\"; break;\r\n\t\t}\r\n\r\n\t\t// Add the class name.\r\n\t\toAnnHeader.className = szHeaderClass;\r\n\r\n\t\t// Return the header.\r\n\t\treturn oAnnHeader;\r\n\t};\r\n\r\n\t/**\r\n\t * Generates the header containing details + buttons that appears above the annotation text.\r\n\t * @param {number} iType - (eFieldTypes) The type of header to be created\r\n\t * @param {string} szCreatorEmail - The email corresponding of the annotation creator.\r\n\t * @param {string} szCreatorDisplayName - The display name of the annotation creator.\r\n\t * @param {object|null} oDate - The date to be rendered (if desired).\r\n\t * @param {number} dbId - The ID of the annotation as saved in the database.\r\n\t * @param {object} oArtworkCanvas - Object containing artwork canvas.\r\n\t * @param {boolean} bExistingAnnotation - Whether this annotation already exists.\r\n\t * @param {boolean} bMyAnnotation - Does this annotation belong to the user signed in?\r\n\t * @param {boolean} bInFlyout - Is this being rendered in the flyout?\r\n\t * @returns {object} Returns DOM object\r\n\t */\r\n\tvar generateAnnotationHeader = function (iType, szCreatorEmail, szCreatorDisplayName, oDate, dbId, oArtworkCanvas, bExistingAnnotation, bMyAnnotation, bInFlyout) {\r\n\t\tvar oHeaderContainer = document.createElement(\"span\");\r\n\r\n\t\tvar bShowDate = dbId > 0 || iType === eFieldTypes.StatusHeader;\r\n\t\tvar oDetails = generateAnnotationHeaderDetails(iType, szCreatorEmail, szCreatorDisplayName, bShowDate ? oDate : null);\r\n\t\toHeaderContainer.appendChild(oDetails);\r\n\r\n\t\t// Buttons are to appear within the

element created previously.\r\n\t\toHeaderContainer = oDetails;\r\n\r\n\t\tvar oButtons = generateAnnotationHeaderButtons(iType, dbId, oArtworkCanvas, bExistingAnnotation, bMyAnnotation, bInFlyout);\r\n\t\toHeaderContainer.appendChild(oButtons);\r\n\r\n\t\treturn oHeaderContainer;\r\n\t};\r\n\r\n\t/**\r\n\t * Generates the relevant buttons to show alongside the annotation.\r\n\t * @param {number} iType - (eFieldTypes) The type of header to be created\r\n\t * @param {number} dbId - The ID of the annotation as saved in the database.\r\n\t * @param {object} oArtworkCanvas - Object containing artwork canvas.\r\n\t * @param {boolean} bExistingAnnotation - Whether this annotation already exists.\r\n\t * @param {boolean} bMyAnnotation - Does this annotation belong to the user signed in?\r\n\t * @param {boolean} bInFlyout - Is this being rendered in the flyout?\r\n\t * @returns {object} Returns DOM object\r\n\t */\r\n\tvar generateAnnotationHeaderButtons = function (iType, dbId, oArtworkCanvas, bExistingAnnotation, bMyAnnotation, bInFlyout) {\r\n\t\tvar oButtonsContainer = document.createElement(\"span\");\r\n\t\toButtonsContainer.setAttribute(\"data-artworkCanvas\", oArtworkCanvas.g_szCanvasId);\r\n\r\n\t\t// Create the 'delete annotation reply' button.\r\n\t\t// This should only be visible on annotation replies if the approval is active on the main canvas AND EITHER it's our annotation reply OR if we're creating a new reply.\r\n\t\tif (!g_oViewer.g_bReadOnly && oArtworkCanvas.g_bMainCanvas && (bMyAnnotation || !bExistingAnnotation) && iType === eFieldTypes.ReplyHeader) {\r\n\t\t\tvar szClassName = bExistingAnnotation ? \"deleteAnnotationReplyButton\" : \"cancelAnnotationReplyButton\";\r\n\t\t\tvar szHoverText = bExistingAnnotation ? g_oAnnotations.c_szDeleteAnnotationReply : \"Cancel Annotation Reply\";\r\n\t\t\tvar szButtonId = dbId + \"_del_reply\" + (bInFlyout ? \"_li\" : \"\");\r\n\t\t\taddDomElement(szButtonId, \"input\", \"img/Delete_wht_16.png\", szClassName, szHoverText, null, oButtonsContainer);\r\n\t\t}\r\n\r\n\t\treturn oButtonsContainer;\r\n\t};\r\n\r\n\t/**\r\n\t * Create an active text area for use in an annotation and appends it to the target.\r\n\t * @param {string} SVGDivId - The div that the text area is being created in.\r\n\t * @param {number} iType - (eFieldTypes) The type of annotation header.\r\n\t * @param {number} dbId - The ID of the annotation as saved in the database.\r\n\t * @param {string} textContent - The contents of the annotation.\r\n\t * @param {object} oArtworkCanvas - Object containing artwork canvas.\r\n\t * @param {object} oAnnotationCanvas - Object containing annotation canvas.\r\n\t * @param {object} oJQTEOptionsOverride - Object containing JQTE override options.\r\n\t * @param {object} szJQTEBackgroundColourOverride - Object containing JQTE background colour override.\r\n\t * @param {object} oCurrentAnnotation - The current annotation.\r\n\t * @param {object} target - The target container.\r\n\t * @returns {object} Returns a generated DOM object that may be appended as a child.\r\n\t */\r\n\tvar createTextAreaInputActive = function (SVGDivId, iType, dbId, textContent, oArtworkCanvas, oAnnotationCanvas, oJQTEOptionsOverride, szJQTEBackgroundColourOverride, oCurrentAnnotation, target) {\r\n\t\tvar input = document.createElement(\"textarea\");\r\n\r\n\t\tif (iType === eFieldTypes.AnnotationMainHeader) {\r\n\t\t\tinput.className = \"Original\";\r\n\t\t}\r\n\t\telse {\r\n\t\t\tinput.className = \"Reply\";\r\n\t\t\t$(\"#rb_\" + $(target).parent().attr(\"id\")).hide();\r\n\t\t}\r\n\r\n\t\tinput.id = SVGDivId;\r\n\t\tinput.size = 36;\r\n\r\n\t\tif (dbId !== undefined) {\r\n\t\t\tinput.setAttribute(\"data-annotationreplyid\", dbId);\r\n\t\t}\r\n\r\n\t\tif (textContent !== undefined) {\r\n\t\t\tinput.value = textContent;\r\n\t\t\t// Store a copy of the old content.\r\n\t\t\tg_oAnnotations.g_szAnnotationContent = input.value;\r\n\t\t}\r\n\r\n\t\ttarget.appendChild(input);\r\n\r\n\t\t// If this is a NEW annotation, turn off the events that draw annotations.\r\n\t\tif (dbId < 0) {\r\n\t\t\t$(\"#AnnotationViewer\").off(\"pointerdown\");\r\n\t\t\t$(\"#AnnotationViewer\").off(\"pointerup\");\r\n\t\t}\r\n\r\n\t\t// Outline the JQTE options.\r\n\t\tvar oJQTEOptions = {\r\n\t\t\t\"br\": true,\r\n\t\t\t\"center\": false,\r\n\t\t\t\"color\": false,\r\n\t\t\t\"format\": false,\r\n\t\t\t\"indent\": false,\r\n\t\t\t\"link\": false,\r\n\t\t\t\"left\": false,\r\n\t\t\t\"outdent\": false,\r\n\t\t\t\"ol\": false,\r\n\t\t\t\"p\": false,\r\n\t\t\t\"remove\": false,\r\n\t\t\t\"right\": false,\r\n\t\t\t\"rule\": false,\r\n\t\t\t\"source\": false,\r\n\t\t\t\"title\": false,\r\n\t\t\t\"unlink\": false\r\n\t\t};\r\n\r\n\t\t// If we have a JQTE options override, use this instead.\r\n\t\tif (oJQTEOptionsOverride !== null) {\r\n\t\t\toJQTEOptions = oJQTEOptionsOverride;\r\n\t\t}\r\n\r\n\t\t// TE will automatically escape tags that are entered by the user.\r\n\t\t$(input).jqte(oJQTEOptions);\r\n\r\n\t\t$(\".jqte_editor\").attr(\"dir\", \"auto\");\r\n\r\n\t\t// If we have a JQTE background colour override, use this.\r\n\t\tif (szJQTEBackgroundColourOverride !== null) {\r\n\t\t\t$(\".jqte_editor\").addClass(szJQTEBackgroundColourOverride);\r\n\t\t}\r\n\r\n\t\t// If we have custom options for the JQTE text editor.\r\n\t\tif (oJQTEOptionsOverride !== null) {\r\n\t\t\t\r\n\t\t\t// Disable the keyboard shortcuts.\r\n\t\t\t$(\".jqte_editor\").attr(\"data-disableshortcuts\", \"true\");\r\n\t\t}\r\n\r\n\t\t$(\".jqte_editor\").on(\"pointerdown\", function (e) {\r\n\t\t\te.stopPropagation();\r\n\t\t});\r\n\r\n\t\t$(\".jqte_editor\").on(\"pointermove\", function (e) {\r\n\t\t\te.stopPropagation();\r\n\t\t\t$(\".speechbubble\").off(\"pointerup\");\r\n\t\t});\r\n\t\t\r\n\t\t// Only set the lose focus if this is not a difference type.\r\n\t\tif (iType != eFieldTypes.DifferenceHeader) {\r\n\t\t\t$(\".jqte_editor\").on(\"focus\", function (e) {\r\n\t\t\t\tchangeCanvasFunction(\"#AnnotationViewer\", \"pointerdown\", function (e) {\r\n\t\t\t\t\toCurrentAnnotation.AnnotationTextEditorLooseFocusEvent(e, oCurrentAnnotation, input, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn input;\r\n\t};\r\n\r\n\t/**\r\n\t * Creates a disabled text area for use in an annotation and appends it to the target.\r\n\t * @param {number} iType - (eFieldTypes) The type of annotation header.\r\n\t * @param {number} dbId - The ID of the annotation as saved in the database.\r\n\t * @param {string} szCreator - The email address of the creator\r\n\t * @param {string} textContent - The contents of the annotation.\r\n\t * @param {object} oArtworkCanvas - Object containing artwork canvas.\r\n\t * @param {object} oAnnotationCanvas - Object containing annotation canvas.\r\n\t * @param {object} oCurrentAnnotation - The current annotation.\r\n\t * @param {object} target - The target container.\r\n\t * @returns {object} Returns a generated DOM object that may be appended as a child.\r\n\t */\r\n\tvar createTextAreaInputDisabled = function (iType, dbId, szCreator, textContent, oArtworkCanvas, oCurrentAnnotation, target) {\r\n\t\t\r\n\t\tvar input = document.createElement(\"p\");\r\n\t\tif (dbId !== undefined) {\r\n\t\t\tinput.setAttribute(\"data-dbId\", dbId);\r\n\t\t}\r\n\r\n\t\tinput.id = \"_p\" + oCurrentAnnotation.id; // svg id\r\n\t\tif (iType === eFieldTypes.AnnotationMainHeader) {\r\n\t\t\tinput.className = \"ReadOnlyAnnotationText\";\r\n\t\t}\r\n\t\telse if (iType === eFieldTypes.StatusHeader) {\r\n\t\t\tinput.className = \"status\";\r\n\t\t\tinput.setAttribute(\"data-statusfield\", \"statusValue\");\r\n\t\t\tinput.setAttribute(\"data-authorid\", szCreator);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tinput.className = \"ReadOnlyReplyText\";\r\n\t\t}\r\n\r\n\t\t// Determin if this is a list item or popup.\r\n\t\tvar bListItem = ($(target).parents(\".annotationListItem\").length > 0);\r\n\r\n\t\t// If this is an SVG annotation.\r\n\t\tif (oCurrentAnnotation.g_bSVGTextAnnotation) {\r\n\r\n\t\t\t// Get the unformatted text from the text content.\r\n\t\t\ttextContent = g_oSVGText.getUnformattedSVGText(textContent);\r\n\t\t}\r\n\r\n\t\tinput.innerHTML = textContent;\r\n\r\n\t\t// Internet Explorer 6-11\r\n\t\tvar bIE = false || !!document.documentMode;\r\n\t\t// Edge 20+\r\n\t\tvar bEdge = !bIE && !!window.StyleMedia;\r\n\t\tif (!bIE && !bEdge) {\r\n\t\t\tinput.dir = \"auto\";\r\n\t\t}\r\n\r\n\t\t$(\".speechbubble\").off('copy');\r\n\t\t$(\".speechbubble\").on('copy', function (event) { AnnotationUI.prototype.copyOverride(event); });\r\n\r\n\t\t// We show the edit option if the user has an open approval slot and this is not a new annotation or an annotation status.\r\n\t\t// And they created the annotation, this is an unlocked annotation, or this is an svg text annotation which the user has permissions to edit.\r\n\t\tif (oCurrentAnnotation.g_iApprovalId === g_oAnnotations.g_iApprovalId && !g_oViewer.g_bReadOnly && oArtworkCanvas.g_bMainCanvas && oCurrentAnnotation.id > 0 && iType != eFieldTypes.StatusHeader) {\r\n\t\t\tif ((szCreator === g_oUserDetails.UserId || oCurrentAnnotation.g_bUnlocked) || (oCurrentAnnotation.g_bSVGTextAnnotation && iType != eFieldTypes.ReplyHeader && g_oUserDetails.CreateTextEditing)) {\r\n\t\t\t\taddDomElement(\"eb_\" + (bListItem ? \"li_\" : \"\") + input.id + \"_\" + dbId, \"input\", \"img/Edit_Wht_16.png\", \"editAnnotationTextButton\", g_oAnnotations.c_szEditAnnotationText, EditButtonOnClick, input);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Append the child.\r\n\t\ttarget.appendChild(input);\r\n\r\n\t\t// Return the input.\r\n\t\treturn input;\r\n\t};\r\n\r\n\t/**\r\n\t * Creates the text area for an annotation area. Uses jQuery TE for functionality.\r\n\t * @param {string} SVGDivId - The Div Id.\r\n\t * @param {number} creator - The User ID of the Creator.\r\n\t * @param {string} creatorEmail - The email of the creator.\r\n\t * @param {string} creatorDisplayName - The display name of the creator.\r\n\t * @param {number} type - (eFieldTypes) The type of header we are creating.\r\n\t * @param {bool} readOnly - Is it read only?\r\n\t * @param {string} textContent - The content of the annotation\r\n\t * @param {string} target - The div to create the target to.\r\n\t * @param {object} date - The date of the annotation (moment.js object).\r\n\t * @param {number} dbId - The ID of the annotation as saved in the database.\r\n\t * @param {object} oArtworkCanvas - The artwork canvas.\r\n\t * @param {object} oAnnotationCanvas - The annotation canvas.\r\n\t * @param {object} oJQTEOptionsOverride - The override for the JQTE options.\r\n\t * @param {object} szJQTEBackgroundColourOverride - The override for the JQTE background colour.\r\n\t */\r\n\tAnnotation.prototype.createAnnotationTextArea = function (SVGDivId, creator, creatorEmail, creatorDisplayName, type, readOnly, textContent, target, date, dbId, oArtworkCanvas, oAnnotationCanvas, oJQTEOptionsOverride, szJQTEBackgroundColourOverride) {\r\n\r\n\t\t// Ensure the div id is a string.\r\n\t\tSVGDivId = \"\" + SVGDivId;\r\n\r\n\t\t// If this is a difference type, only create the active text area.\r\n\t\tif (type == eFieldTypes.DifferenceHeader) {\r\n\t\t\tcreateTextAreaInputActive(SVGDivId, type, dbId, textContent, oArtworkCanvas, oArtworkCanvas, oJQTEOptionsOverride, szJQTEBackgroundColourOverride, oCurrentAnnotation, target);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// If this is a copy magic type, only create the active text area.\r\n\t\tif (type == eFieldTypes.CopyMagic) {\r\n\t\t\tcreateTextAreaInputActive(SVGDivId, type, dbId, textContent, oArtworkCanvas, oArtworkCanvas, oJQTEOptionsOverride, szJQTEBackgroundColourOverride, oCurrentAnnotation, target);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Extract the current annotation.\r\n\t\tvar oCurrentAnnotation = this;\r\n $('#AnnotationViewer').css(\"cursor\", \"default\");\r\n g_oAnnotations.g_szPrevCursorStyle = \"default\";\r\n\r\n\t\t// Ensure we have a target.\r\n\t\tif (target === null) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Create a child div, insert into target then make this the new target.\r\n\t\tvar oContentContainer = document.createElement(\"div\");\r\n\t\ttarget.appendChild(oContentContainer);\r\n\t\ttarget = oContentContainer;\r\n\r\n\t\t// Create annotation header and insert into container.\r\n\t\tvar bIsMyAnnotation = creator === g_oUserDetails.UserId;\r\n\t\tvar bInFlyout = !SVGDivId || SVGDivId.indexOf(\"li\") >= 0;\r\n\t\tvar szAnnotationHeader = generateAnnotationHeader(type, creatorEmail, creatorDisplayName, date, dbId, oArtworkCanvas, !!textContent, bIsMyAnnotation, bInFlyout);\r\n\t\ttarget.appendChild(szAnnotationHeader);\r\n\r\n\t\t// If this is a text classification annotation, add the text classification details.\r\n\t\tif (type === eFieldTypes.AnnotationMainHeader && oCurrentAnnotation.g_iAnnotationType == eAnnotationTypes.TextClassification) {\r\n\t\t\tg_oAnnotationTextClassification.renderAnnotationTextClassificationContent(oCurrentAnnotation, oArtworkCanvas, target);\r\n\t\t}\r\n\r\n\t\t// Generate text area input and append result into target container.\r\n\t\tvar input;\r\n\t\tif (!readOnly) {\r\n\t\t\tinput = createTextAreaInputActive(SVGDivId, type, dbId, textContent, oArtworkCanvas, oArtworkCanvas, oJQTEOptionsOverride, szJQTEBackgroundColourOverride, oCurrentAnnotation, target);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tinput = createTextAreaInputDisabled(type, dbId, creator, textContent, oArtworkCanvas, oCurrentAnnotation, target);\r\n\t\t}\r\n\t\t$(\".jqte_editor\").focus();\r\n\r\n\t\t// If this is an svg annotation, ensure focus is correctly applied after rich text is loaded.\r\n\t\tif (oCurrentAnnotation.g_bSVGTextAnnotation) {\r\n\t\t\tsetTimeout(function () { $(\".jqte_editor\").focus(); }, 500);\r\n\t\t\t// If this is a brand new annotation popup, ensure we are scrolled to the top.\r\n\t\t\tif (dbId < 0 && type === eFieldTypes.AnnotationMainHeader && !readOnly) {\r\n\t\t\t\tsetTimeout(function () { $(target).parent().scrollTop(0); }, 600);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Override the pointer up event.\r\n\t\t$(\"#\" + input.id).on(\"pointerup\", function () {\r\n\t\t\tif (oArtworkCanvas.g_oDoc.documentType === eDocumentTypes.ThreeD) {\r\n\t\t\t\tg_oAnnotations.redraw3DAnnotations(oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\toArtworkCanvas.g_oRenderer.render(oArtworkCanvas.g_oScene, oArtworkCanvas.g_oCamera);\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\toArtworkCanvas.redraw(false);\r\n\t\t\t}\r\n\t\t});\r\n\t};\r\n\r\n\t/**\r\n\t * Event executed when the text editor looses focus.\r\n\t * @param e {object} - The focus Event.\r\n\t * @param oCurrentAnnotation {object} - The current annotation object.\r\n\t * @param input {object} - The element that has lost focus.\r\n\t * @param oArtworkCanvas {object} - The current artwork canvas.\r\n\t * @param oAnnotationCanvas {object} - The current annotation canvas.\r\n\t */\r\n\tAnnotation.prototype.AnnotationTextEditorLooseFocusEvent = function (e, oCurrentAnnotation, input, oArtworkCanvas, oAnnotationCanvas) {\r\n\t\tvar _this = this;\r\n\r\n\t\t// If we have no input, return.\r\n\t\tif (input && input.value === \"\") {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Determine the caller type as either a list item or pop-up.\r\n\t\tvar callerType = eAnnotationDivType.Popup;\r\n\t\tif ($(\".jqte_editor\").parents(\".annotationListItem\").length > 0) {\r\n\t\t\tcallerType = eAnnotationDivType.ListItem;\r\n\t\t}\r\n\r\n\t\t// Determine if this is an original annotation or a reply.\r\n\t\tvar bReply = false;\r\n\t\tif (_this.g_iParentAnnotationId > 0 ||\r\n\t\t\t(callerType == eAnnotationDivType.ListItem && $(\".jqte_editor\").parents(\"#rc_li_\" + _this.id).length > 0) ||\r\n\t\t\t(callerType == eAnnotationDivType.Popup && $(\".jqte_editor\").parents(\"#rc_\" + _this.id).length > 0)) {\r\n\t\t\tbReply = true;\r\n\t\t}\r\n\r\n\t\t// Get the input div and annotation div.\r\n\t\tvar oInputDiv = null\r\n\t\tvar oAnnotationDiv = null;\r\n\t\t\r\n\t\t// If this is an original list item.\r\n\t\tif (callerType == eAnnotationDivType.ListItem && bReply == false) {\r\n\r\n\t\t\t// Get the text input.\r\n\t\t\toInputDiv = $(\"#tili_\" + _this.id)[0];\r\n\r\n\t\t\t// Get the annotations div.\r\n\t\t\toAnnotationDiv = $(\".jqte_editor\").parents(\".annotationListItem\")[0];\r\n\t\t}\r\n\t\t// If this is an reply list item.\r\n\t\telse if (callerType == eAnnotationDivType.ListItem && bReply == true) {\r\n\t\t\t\r\n\t\t\t// If this is an existing reply.\r\n\t\t\tif (_this.g_iParentAnnotationId > 0) {\r\n\r\n\t\t\t\t// Get the parent annotation object.\r\n\t\t\t\tvar oParentAnnotationObject = $.grep(g_oAnnotations.g_oAnnotationsMade, function (annotation) { return annotation.id == _this.g_iParentAnnotationId; });\r\n\r\n\t\t\t\t// Get the text input.\r\n\t\t\t\toInputDiv = $(\"#ar_\" + \"li_\" + oParentAnnotationObject[0].id)[0];\r\n\t\t\t}\r\n\t\t\t// If this is a new reply.\r\n\t\t\telse {\r\n\t\t\t\t// Get the correct text input.\r\n\t\t\t\toInputDiv = typeof $(\"#ar_li_\" + _this.id)[0] === \"undefined\" ? $(\"#ar_\" + _this.id)[0] : $(\"#ar_li_\" + _this.id)[0];\r\n\t\t\t}\r\n\r\n\t\t\t// Get the annotations div.\r\n\t\t\toAnnotationDiv = $(\".jqte_editor\").parents(\".annotationListItem\")[0];\r\n\t\t}\r\n\t\t// If this is an original pop-up.\r\n\t\telse if (callerType == eAnnotationDivType.Popup && bReply == false) {\r\n\r\n\t\t\t// Get the text input.\r\n\t\t\toInputDiv = $(\"#ti\" + _this.id)[0];\r\n\r\n\t\t\t// Get the annotations div.\r\n\t\t\toAnnotationDiv = $(\".jqte_editor\").parents(\".annotation\")[0];\r\n\t\t}\r\n\t\t// If this is an reply pop-up.\r\n\t\telse if (callerType == eAnnotationDivType.Popup && bReply == true) {\r\n\t\t\t\r\n\t\t\t// If this is an existing reply.\r\n\t\t\tif (_this.g_iParentAnnotationId > 0) {\r\n\r\n\t\t\t\t// Get the parent annotation object.\r\n\t\t\t\tvar oParentAnnotationObject = $.grep(g_oAnnotations.g_oAnnotationsMade, function (annotation) { return annotation.id == _this.g_iParentAnnotationId; });\r\n\r\n\t\t\t\t// Get the text input.\r\n\t\t\t\toInputDiv = $(\"#ar_\" + oParentAnnotationObject[0].id)[0];\r\n\t\t\t}\r\n\t\t\t// If this is a new reply.\r\n\t\t\telse {\r\n\t\t\t\t// Get the correct text input.\r\n\t\t\t\toInputDiv = typeof $(\"#ar_li_\" + _this.id)[0] === \"undefined\" ? $(\"#ar_\" + _this.id)[0] : $(\"#ar_li_\" + _this.id)[0];\r\n\t\t\t}\r\n\r\n\t\t\t// Get the annotations div.\r\n\t\t\toAnnotationDiv = $(\".jqte_editor\").parents(\".annotation\")[0];\r\n\t\t}\r\n\t\t\r\n\t\t// There is an unsaved annotation and we've clicked OUTSIDE the annotation and OUTSIDE the JQTE text editor.\r\n\t\tif (g_oAnnotations.checkForUnsavedAnnotation() && oInputDiv != null && oAnnotationDiv !== null && !oAnnotationDiv.contains(e.target) && $(e.target).parents(\".jqte_focused\").length == 0) {\r\n\t\t\t// See if Move to own function.\r\n\t\t\t// Check the user has a valid approval session and that the doc is the one under approval\r\n\t\t\tif (g_oAnnotations.c_szSessionId !== 0 && _this.g_iApprovalId === g_oAnnotations.g_iApprovalId) {\r\n\t\t\t\te.stopPropagation();\r\n\t\t\t}\r\n\r\n\t\t\t// Grab the actual input and replace line breaks with spaces.\r\n\t\t\tvar szRaw = $(\".jqte_editor\").html().replace(/\\n/g, ' ');\r\n\t\t\toInputDiv.value = szRaw;\r\n\r\n\t\t\t// If this is a single break due to an edge bug, set this as blank.\r\n\t\t\tif (oInputDiv.value === \"
\") {\r\n\t\t\t\toInputDiv.value = \"\";\r\n\t\t\t}\r\n\r\n\t\t\t// Escape HTML to check for empty comments.\r\n\t\t\tvar szInputValueText = oInputDiv.value.replace(/(<([^>]+)>)/ig, \"\");\r\n\r\n\t\t\t// We now need to check on whether or not this is a reply or an annotation being saved.\r\n\t\t\tif (!bReply) {\r\n\r\n\t\t\t\t// Find the resulting annotation.\r\n\t\t\t\tvar result = $.grep(g_oAnnotations.g_oAnnotationsMade, function (ann) {\r\n\t\t\t\t\treturn ann.id == _this.id;\r\n\t\t\t\t});\r\n\r\n\t\t\t\t// Only save if the input has changed and it isn't blank.\r\n\t\t\t\tif (((oInputDiv.value != _this.g_szTextContent) && szInputValueText != \"\") || // Has the annotation content changed?\r\n\t\t\t\t\t((_this.g_iAnnotationType === eAnnotationTypes.TextMeasurement) && !_this.g_bSaved) || // Or is the annotation a new Text Measurement?\r\n\t\t\t\t\t((_this.g_iAnnotationType === eAnnotationTypes.TextHighlight) && !_this.g_bSaved) || // Or is the annotation a new Text Highlight?\r\n\t\t\t\t\t((_this.g_iAnnotationType === eAnnotationTypes.TextClassification) && !_this.g_bSaved) || // Or is the annotation a new Text Classification?\r\n\t\t\t\t\t(oInputDiv.value != \"\" && !_this.g_bSaved)) { // Or is it a new annotation without empty text?\r\n\r\n\t\t\t\t\t// Set the correct annotation status.\r\n\t\t\t\t\tresult[0].status = result[0].status == \"a\" ? result[0].status = \"a\" : result[0].status = \"u\";\r\n\r\n\t\t\t\t\t// Update the JQTE value.\r\n\t\t\t\t\t$(\".jqte_editor\").jqteVal(oInputDiv.value);\r\n\r\n\t\t\t\t\t// Save the annotation.\r\n\t\t\t\t\tresult[0].AnnotationSave(callerType, oArtworkCanvas, oAnnotationCanvas, true);\r\n\r\n\t\t\t\t\t// Remove the PointerDown event to allow other controls to register click events.\r\n\t\t\t\t\t$(document).off(\"pointerdown\");\r\n\t\t\t\t}\r\n\t\t\t\t// Reset the div to read only, if we haven't changed the text and it isn't blank.\r\n\t\t\t\telse if (oInputDiv.value != \"\") {\r\n\t\t\t\t\tg_oAnnotations.rebuildAnnotationList(oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t\tg_oAnnotations.initiateAnnotationDraw(0, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// If this is a reply.\r\n\t\t\telse if (bReply) {\r\n\r\n\t\t\t\t// Same as above, but save the current annotation, not the result.\r\n\t\t\t\tfor (var i = 0; i < g_oAnnotations.g_oAnnotationsMade.length; i++) {\r\n\t\t\t\t\tvar result = $.grep(g_oAnnotations.g_oAnnotationsMade[i].g_oReplies, function (reply) {\r\n\t\t\t\t\t\treturn reply.id == oInputDiv.getAttribute(\"data-annotationreplyid\");\r\n\t\t\t\t\t});\r\n\t\t\t\t\tif (result.length > 0) {\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// New reply, so check that isn't blank.\r\n\t\t\t\tif (result.length == 0 && oInputDiv.value != \"\") {\r\n\r\n\t\t\t\t\t// Create new annotation reply.\r\n\t\t\t\t\tvar oNewAnnotation = new Annotation(g_oAnnotations.g_iApprovalId);\r\n\t\t\t\t\toNewAnnotation.id = parseInt(oInputDiv.getAttribute(\"data-annotationreplyid\")) || g_oAnnotations.getNextAnnotationId();\r\n\t\t\t\t\toNewAnnotation.g_szColour = _this.g_szColour;\r\n\t\t\t\t\toNewAnnotation.g_iAnnotationType = _this.g_iAnnotationType;\r\n\t\t\t\t\toNewAnnotation.g_iParentAnnotationId = _this.id;\r\n\t\t\t\t\toNewAnnotation.g_iDocumentId = _this.g_iDocumentId;\r\n\t\t\t\t\toNewAnnotation.g_iDocumentPageId = _this.g_iDocumentPageId;\r\n\t\t\t\t\toNewAnnotation.g_iAuthor = g_oUserDetails.UserId;\r\n\t\t\t\t\toNewAnnotation.g_szAuthorEmail = g_oUserDetails.EmailAddress;\r\n\t\t\t\t\toNewAnnotation.g_szTextContent = oInputDiv.value;\r\n\t\t\t\t\toNewAnnotation.g_bSaved = true;\r\n\t\t\t\t\toNewAnnotation.status = \"a\";\r\n\r\n\t\t\t\t\t// Set the parent to update.\r\n\t\t\t\t\t_this.status = \"u\";\r\n\r\n\t\t\t\t\t// Push the new reply into the reply array.\r\n\t\t\t\t\t_this.g_oReplies.push(oNewAnnotation);\r\n\r\n\t\t\t\t\t// Update the JQTE value.\r\n\t\t\t\t\t$(\".jqte_editor\").jqteVal(oInputDiv.value);\r\n\r\n\t\t\t\t\t// Save the annotation reply.\r\n\t\t\t\t\toCurrentAnnotation.AnnotationSave(0, oArtworkCanvas, oAnnotationCanvas, false);\r\n\r\n\t\t\t\t\t// Remove the PointerDown event to allow other controls to register click events.\r\n\t\t\t\t\t$(document).off(\"pointerdown\");\r\n\t\t\t\t}\r\n\t\t\t\t// Otherwise check the replies for change.\r\n\t\t\t\telse if ((oInputDiv.value != result[0].g_szTextContent) && oInputDiv.value != \"\") {\r\n\r\n\t\t\t\t\t// Update the existing annotation with the new values.\r\n\t\t\t\t\tresult[0].g_szTextContent = oInputDiv.value;\r\n\t\t\t\t\tresult[0].status = \"u\";\r\n\r\n\t\t\t\t\t// Update the JQTE value.\r\n\t\t\t\t\t$(\".jqte_editor\").jqteVal(oInputDiv.value);\r\n\r\n\t\t\t\t\t// Save the annotation.\r\n\t\t\t\t\t_this.AnnotationSave(0, oArtworkCanvas, oAnnotationCanvas, false);\r\n\r\n\t\t\t\t\t// Remove the PointerDown event to allow other controls to register click events.\r\n\t\t\t\t\t$(document).off(\"pointerdown\");\r\n\t\t\t\t}\r\n\t\t\t\t// If there is no change and it's blank, reset the list.\r\n\t\t\t\telse if (oInputDiv.value != \"\") {\r\n\t\t\t\t\t\r\n\t\t\t\t\tvar resultParent = $.grep(g_oAnnotations.g_oAnnotationsMade, function (ann) {\r\n\t\t\t\t\t\treturn ann.id == result[0].g_iParentAnnotationId;\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t\tresult[0].g_bSaved = true;\r\n\t\t\t\t\tresultParent[0].g_bSaved = true;\r\n\r\n\t\t\t\t\t// If we have an open popup for this annotation, close it.\r\n\t\t\t\t\tif ($(\"#\" + resultParent[0].id + \"_clo\").length > 0) {\r\n\t\t\t\t\t\t$(\"#\" + resultParent[0].id + \"_clo\").click();\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (g_oViewer.g_oArtworkViewer.g_oDoc.documentType !== eDocumentTypes.ThreeD) {\r\n\t\t\t\t\t\tg_oAnnotations.rebuildAnnotationList(oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t\t\tg_oAnnotations.initiateAnnotationDraw(0, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse {\r\n\t\t\t\t\t\t// Artwork Canvas is actually the Annotation Canvas at this point, so swap these around.\r\n\t\t\t\t\t\toAnnotationCanvas = oArtworkCanvas;\r\n\t\t\t\t\t\toArtworkCanvas = g_oViewer.getLinkedArtworkCanvas(oAnnotationCanvas.g_szCanvasId);\r\n\t\t\t\t\t\tg_oAnnotations.rebuildAnnotationList(oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t\t\tg_oAnnotations.redraw3DAnnotations(oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Prevent default behaviour and bubbling.\r\n\t\te.preventDefault();\r\n\t\te.stopPropagation();\r\n\t},\r\n\r\n\t/**\r\n\t * Convert 3D co-ordinates to 2D Coordinates for placing pop-ups.\r\n\t * @param {array} position - The current position in 3D.\r\n\t * @returns {array} - An array of co-ordinates\r\n\t */\r\n\tAnnotation.prototype.threeDToTwoDCoords = function (position, oArtworkCanvas, oAnnotationCanvas) {\r\n\t\tvar p = new THREE.Vector3(position.x, position.y, position.z);\r\n\t\tvar vector = p.project(oArtworkCanvas.g_oCamera);\r\n\r\n\t\tvector.x = (vector.x + 1) / 2 * oArtworkCanvas.g_oCanvas.clientWidth;\r\n\t\tvector.y = -(vector.y - 1) / 2 * oArtworkCanvas.g_oCanvas.clientHeight;\r\n\t\treturn vector;\r\n\t},\r\n\r\n\t/**\r\n\t * Saves or updates an annotation.\r\n\t * @param {int} callerType - Whether the annotation is being saved from the list or the pop-up div. If 1, it's saved from the list.\r\n\t * @param {object} oArtworkCanvas - The artwork canvas.\r\n\t * @param {object} oAnnotationCanvas - The annotation canvas.\r\n\t * @param {bool} bIsMainAnnotation - If we are saving the main annotation.\r\n\t */\r\n\tAnnotation.prototype.AnnotationSave = function (callerType, oArtworkCanvas, oAnnotationCanvas, bIsMainAnnotation) {\r\n\t\t\r\n\t\t// Get the selected document from the combo control.\r\n\t\tvar oDocument = g_oaComboControls[0].documents[g_oaComboControls[0].selectedDocumentIndex];\r\n\r\n\t\t// If we are dealing with a 3d view annotation then the variables below will be populated.\r\n\t\tvar bNewThreeDViewAnnotation = oDocument.document.Approval3DViewId > 0;\r\n\t\tvar oThreeDViewParentDocument = null;\r\n\t\tvar iParentDocumentId = -1;\r\n\t\tvar iParentDocumentPageId = -1;\r\n\t\tvar szModelPath = \"\";\r\n\t\tvar szModelPrimaryArtworkTexture = \"\";\r\n\t\tvar iThreeDViewdocumentId = -1;\r\n\r\n\t\t// Determine if this is a new copy magic text annotation.\r\n\t\tvar oNewCopyMagicTextAnnotation = this.g_bSVGTextAnnotation && this.g_oSVGVariable.copyMagicText && this.status == \"a\" ? this.g_oSVGVariable : null;\r\n\r\n\t\t// Check we are not already processing a new annotation.\r\n\t\tif (this.id < 0 && $(\"#\" + this.id.toString() + \"_del\").attr(\"src\") == \"img/WhiteSpinner24.gif\") {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Switch Delete Icon to Loading Spinner if this is a new annotation and this is NOT a read only Text Measurement annotation.\r\n\t\tif (!(g_oViewer.g_bReadOnly && this.g_iAnnotationType === eAnnotationTypes.TextMeasurement && this.id < 0)) {\r\n\t\t\tswapImage(this.id.toString() + \"_del\", \"img/WhiteSpinner24.gif\");\r\n\t\t}\r\n\r\n\t\t// Populate 3D View metadata when adding an annotation to a 3D view\r\n\t\tif (bNewThreeDViewAnnotation) {\r\n\t\t\t// 3D view and model details\r\n\t\t\tiThreeDViewdocumentId = oDocument.document.documentId;\r\n\t\t\tvar oThreeDView = g_oThreeDView.GetThreeDView(oDocument.document.Approval3DViewId);\r\n\t\t\tszModelPrimaryArtworkTexture = GetFileNameWithoutExtension(oThreeDView.ModelTemplatePrimaryArtworkFileName);\r\n\t\t\tszModelPath = oThreeDView.ModelTemplatePath + '\\\\' + oThreeDView.ModelTemplateName;\r\n\t\t\tiThreeDViewdocumentId = oDocument.document.documentId;\r\n\r\n\t\t\t// Parent details\r\n\t\t\tiParentDocumentId = oThreeDView.ParentDocumentId;\r\n\t\t\tiParentDocumentPageId = oThreeDView.ParentDocumentPageId;\r\n\t\t\toThreeDViewParentDocument = $.findfirst(g_oaComboControls[0].documents, function (x) {\r\n\t\t\t\treturn x.greenlightDocumentId === iParentDocumentId;\r\n\t\t\t}).document;\r\n\t\t}\r\n\r\n\t\t// Note the scroll position of the list before the re-render.\r\n\t\tvar iListScrollTop = $(\"#divAnnDiv_ListItems\").scrollTop();\r\n\r\n\t\t// Turn off the jqte editor.\r\n\t\t$(\".jqte_editor\").off();\r\n\r\n\t\t// Return any linked shape annotations (i.e. linked to parent annotation pop-up)\r\n\t\t// For some reason JQuery grep does not work with properties\r\n\t\t// So create a variable for it instead\r\n\t\tvar _this = deepCopyObject(this);\r\n\r\n\t\t// Reset dirty state\r\n\t\tthis.dirtystate = false;\r\n\r\n\t\t// Determine the prefix to be added.\r\n\t\tvar prefix = (callerType === eAnnotationDivType.ListItem) ? \"li_\" : \"\";\r\n\r\n\t\t// Grab the text content for the parent annotation.\r\n\t\tvar newTextContent = $(\"#\" + \"ti\" + prefix + this.id).val();\r\n\t\tif (newTextContent) {\r\n\t\t\tthis.g_szTextContent = newTextContent;\r\n\t\t}\r\n\r\n\t\t// Set the modified date if required.\r\n\t\tif (this.modifiedDate == null || this.modifiedDate < new Date()) {\r\n\t\t\tthis.modifiedDate = new Date();\r\n\t\t}\r\n\r\n\t\t// Set up the replies\r\n\t\tvar annotationReplies = [];\r\n\t\tfor (var i = 0; i < this.g_oReplies.length; i++) {\r\n\t\t\t// As the reply will mostly the same as the parent, copy the Annotation to hold the reply.\r\n\t\t\t// Create a cut down version of the Reply object to be passed to the server.\r\n\t\t\t// This is the same as the actual annotation, but updated with the relevant information.\r\n\t\t\tvar oReplyObject = {\r\n\t\t\t\tannotationId: this.g_oReplies[i].id,\r\n\t\t\t\tapprovalId: this.g_oReplies[i].g_iApprovalId,\r\n\t\t\t\tapprovalUserId: g_oUserDetails.UserId,\r\n\t\t\t\tapprovalUserEmailAddress: this.g_oReplies[i].g_szAuthorEmail,\r\n\t\t\t\tdocumentId: bNewThreeDViewAnnotation ? iParentDocumentId : this.g_iDocumentId,\r\n\t\t\t\tdocumentPageId: bNewThreeDViewAnnotation ? iParentDocumentPageId : this.g_oReplies[i].g_iDocumentPageId,\r\n\t\t\t\treplyToAnnotId: this.g_oReplies[i].g_iParentAnnotationId,\r\n\t\t\t\tannotationType: bNewThreeDViewAnnotation ? 0 : this.g_oReplies[i].g_iAnnotationType,\r\n\t\t\t\tannotationDateTime: \"\",\r\n\t\t\t\tmodifiedDateTime: \"\",\r\n\t\t\t\tsvgVariableId: JSON.stringify(this.g_oReplies[i].g_oSVGVariable),\r\n\t\t\t\tsvgOriginalContent: this.g_oReplies[i].g_szSVGOriginalContent,\r\n\t\t\t\ttextHighlightContent: this.g_oReplies[i].g_szTextHighlightContent,\r\n\t\t\t\tannotationContent: this.g_oReplies[i].g_szTextContent,\r\n\t\t\t\tannotationColour: g_oAnnotations.getHexColour(this.g_oReplies[i].g_szColour) || this.g_oReplies[i].g_szColour,\r\n\t\t\t\tannotationData: this.g_oReplies[i].g_oAnnotationData == null ? \"\" : JSON.stringify(this.g_oReplies[i].g_oAnnotationData),\r\n\t\t\t\tunlocked: false,\r\n\t\t\t\tdeleted: false,\r\n\t\t\t\tstatus: this.g_oReplies[i].status,\r\n\t\t\t\tannotationStatuses: [],\r\n\t\t\t\tannotationCoords: []\r\n\t\t\t};\r\n\r\n\t\t\tannotationReplies.push(oReplyObject);\r\n\t\t}\r\n\t\t\r\n\t\t// Create the array co-ordinates for the annotations.\r\n\t\tvar annotationCoords = [];\r\n\t\tfor (var i = 0; i < this.g_oDrawArray.length; i++) {\r\n\t\t\tvar oAnnotationCoordObject = {\r\n\t\t\t\tannotationId: this.id,\r\n\t\t\t\tannotationX: this.g_oDrawArray[i][0],\r\n\t\t\t\tannotationY: this.g_oDrawArray[i][1],\r\n\t\t\t\tannotationZ: this.g_oDrawArray[i][2] !== undefined ? this.g_oDrawArray[i][i + 2] : null,\r\n\t\t\t\tannotation3dvUVx: this.g_iuvX,\r\n\t\t\t\tannotation3dvUVy: this.g_iuvY,\r\n\t\t\t\tmarqueeX: null,\r\n\t\t\t\tmarqueeY: null\r\n\t\t\t};\r\n\r\n\t\t\tif (this.g_iAnnotationType === eAnnotationTypes.TextMeasurement &&\r\n\t\t\t\tthis.g_oMarqueeDrawArray.length > 0) {\r\n\t\t\t\toAnnotationCoordObject.marqueeX = this.g_oMarqueeDrawArray[i][0];\r\n\t\t\t\toAnnotationCoordObject.marqueeY = this.g_oMarqueeDrawArray[i][1];\r\n\t\t\t}\r\n\r\n\t\t\tannotationCoords.push(oAnnotationCoordObject);\r\n\t\t}\r\n\r\n\t\t// We have a duplicate annotation! Return so we don't save it.\r\n\t\tif (g_oAnnotations.g_oPreviouslySavedAnnotationCoords == annotationCoords) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Update the previous Annotation coordinates to the new set that we're about to save.\r\n\t\tg_oAnnotations.g_oPreviouslySavedAnnotationCoords = deepCopyArray(annotationCoords);\r\n\r\n\t\t// If this is an SVG text annotation.\r\n\t\tif (this.g_bSVGTextAnnotation) {\r\n\t\t\t\r\n\t\t\t// If the main annotation has been updated.\r\n\t\t\tif (bIsMainAnnotation && this.status == \"u\") {\r\n\r\n\t\t\t\t// Reset any statuses on the annotation.\r\n\t\t\t\tg_oAnnotations.resetAnnotationStatus(this, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t}\r\n\r\n\t\t\t// Apply the SVG text update.\r\n\t\t\tg_oSVGText.applySVGTextUpdate(this.g_oSVGVariable, this.g_szTextContent, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t}\r\n\r\n\t\t// If this is a new text classification annotation, update the annotation data.\r\n\t\tif (this.g_iAnnotationType === eAnnotationTypes.TextClassification && this.id < 0) {\r\n\t\t\tg_oAnnotationTextClassification.updateAnnotationTextClassificationData(this, false);\r\n\t\t}\r\n\r\n\t\t// Create a cut down version of the Annotation object to be passed to the server.\r\n\t\tvar oAnnotationObject = {\r\n\t\t\tannotationId: this.id,\r\n\t\t\tapprovalId: this.g_iApprovalId,\r\n\t\t\tapprovalUserId: this.g_iAuthor,\r\n\t\t\tapprovalUserEmailAddress: this.g_szAuthorEmail,\r\n\t\t\tdocumentId: bNewThreeDViewAnnotation ? iParentDocumentId : this.g_iDocumentId,\r\n\t\t\tdocumentPageId: bNewThreeDViewAnnotation ? iParentDocumentPageId : this.g_iDocumentPageId,\r\n\t\t\treplyToAnnotId: this.g_iParentAnnotationId,\r\n\t\t\tannotationType: bNewThreeDViewAnnotation ? 0 : this.g_iAnnotationType,\r\n\t\t\tannotationDateTime: \"\",\r\n\t\t\tmodifiedDateTime: \"\",\r\n\t\t\tsvgVariableId: JSON.stringify(this.g_oSVGVariable),\r\n\t\t\tsvgOriginalContent: this.g_szSVGOriginalContent,\r\n\t\t\ttextHighlightContent: this.g_szTextHighlightContent,\r\n\t\t\tannotationContent: this.g_szTextContent,\r\n\t\t\tannotationColour: g_oAnnotations.getHexColour(this.g_szColour) || this.g_szColour,\r\n\t\t\tannotationData: this.g_oAnnotationData == null ? \"\" : JSON.stringify(this.g_oAnnotationData),\r\n\t\t\tunlocked: false,\r\n\t\t\tdeleted: false,\r\n\t\t\tstatus: this.status,\r\n\t\t\tannotationReplies: annotationReplies,\r\n\t\t\tannotationStatuses: this.g_oStatuses,\r\n\t\t\tannotationCoords: annotationCoords,\r\n\t\t\tattachments: this.attachments\r\n\t\t};\r\n\r\n\t\t// Determine if we have a compare document.\r\n\t\tvar iCompareDocumentId = 0;\r\n\r\n\t\t// If we are in a compare mode, include the annotations for the compare document if a different document has been selected.\r\n\t\tif (g_oViewer.g_oCompareMode != eCompareMode.NoCompare && oAnnotationObject.documentId != g_oCompare.g_oCompareDocument.document.documentId) {\r\n\t\t\tiCompareDocumentId = g_oCompare.g_oCompareDocument.document.documentId;\r\n\t\t}\r\n\r\n\t\t// ThreeDView annotations handled in Greenlight3dView.js\r\n\t\tif (bNewThreeDViewAnnotation) {\r\n\t\t\tg_oThreeDView.AddThreeDViewAnnotation(this.g_iApprovalId, g_oUserDetails.UserId, g_oAnnotations.c_szSessionId, g_oUserDetails.ThirdParyMemberId, iCompareDocumentId, oAnnotationObject, oThreeDViewParentDocument, iParentDocumentPageId, szModelPath, szModelPrimaryArtworkTexture, iThreeDViewdocumentId, _this.id);\r\n\t\t}\r\n\t\telse {\r\n\t\t\t// Build up the annotation string.\r\n\t\t\tvar oJSON = {\r\n\t\t\t\tiApprovalId: this.g_iApprovalId,\r\n\t\t\t\tiApprovalUserId: g_oUserDetails.UserId,\r\n\t\t\t\tiCompareDocumentId: iCompareDocumentId,\r\n\t\t\t\tszSessionId: g_oAnnotations.c_szSessionId,\r\n\t\t\t\tszThirdPartyMemberId: g_oUserDetails.ThirdParyMemberId,\r\n\t\t\t\toAnnotation: oAnnotationObject\r\n\t\t\t};\r\n\r\n\t\t\t$.ajax({\r\n\t\t\t\ttype: \"POST\",\r\n\t\t\t\turl: \"internal/GreenlightAnnotation/SaveAnnotation\",\r\n\t\t\t\tdata: JSON.stringify(oJSON),\r\n\t\t\t\tcontentType: \"application/json; charset=utf-8\",\r\n\t\t\t\tdataType: \"json\",\r\n\t\t\t\tsuccess: function (response) {\r\n\t\t\t\t\t\r\n\t\t\t\t\t// Display the success bubble.\r\n\t\t\t\t\tg_oGreenlightMessages.displaySuccessBubble(g_oAnnotations.c_szAnnotationSavedSuccessfully);\r\n\r\n\t\t\t\t\t// If we are in text compare mode, stop here as we do not want to render this annotation.\r\n\t\t\t\t\tif (g_oTextCompare.g_bTextCompareInProgress) {\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// Determine the canvas to used for rendering based on the annotation toggle.\r\n\t\t\t\t\tvar oAnnotationCanvas = g_oViewer.getCanvas(g_oCompare.getAnnotationCanvasId());\r\n\t\t\t\t\tvar oArtworkCanvas = g_oViewer.getLinkedArtworkCanvas(oAnnotationCanvas.g_szCanvasId);\r\n\r\n\t\t\t\t\t// Splice the old ID out the array, it will be re-rendered later.\r\n\t\t\t\t\tif (g_oaComboControls[0].documents[g_oaComboControls[0].selectedDocumentIndex].document.documentType === eDocumentTypes.ThreeD) {\r\n\t\t\t\t\t\tfor (var i = (oArtworkCanvas.g_oScene.children.length - 1); i > -1; i--) {\r\n\t\t\t\t\t\t\t// Remove both the Annotation object & the Annotation Number from the 3D scene array.\r\n\t\t\t\t\t\t\tif (oArtworkCanvas.g_oScene.children[i].Id == _this.id || oArtworkCanvas.g_oScene.children[i].Id == \"annNo_\" + _this.id) {\r\n\t\t\t\t\t\t\t\toArtworkCanvas.g_oScene.children.splice(i, 1);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// Gather the text annotations.\r\n\t\t\t\t\tg_oAnnotations.g_oExistingTextAnnotations = $.grep(g_oAnnotations.g_oAnnotationsMade, function (anno) {\r\n\t\t\t\t\t\treturn anno.g_iAnnotationType === eAnnotationTypes.TextMeasurement;\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t\t// Reset the annotations, and re-load these from the new response content.\r\n\t\t\t\t\tg_oAnnotations.g_oAnnotationsMade = [];\r\n\t\t\t\t\tif (bNewThreeDViewAnnotation) {\r\n\t\t\t\t\t\tvar responseObj = JSON.parse(response.Contents);\r\n\t\t\t\t\t\tg_oAnnotations.setupAnnotations(responseObj.Annotations, oArtworkCanvas, oAnnotationCanvas, responseObj.ColladaModelTexture);\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse {\r\n\t\t\t\t\t\tg_oAnnotations.setupAnnotations(JSON.parse(response.Contents), oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\t// If this was a new copy magic annotation, create any required additional shapes.\r\n\t\t\t\t\tif (oNewCopyMagicTextAnnotation != null) {\r\n\r\n\t\t\t\t\t\t// Generate and save each of the additional shapes.\r\n\t\t\t\t\t\tvar oAdditionalShapeAnnotations = g_oSVGCopyMagic.generateCopyMagicAdditionalShapes(oNewCopyMagicTextAnnotation.switchId, oNewCopyMagicTextAnnotation.contentDataId, oNewCopyMagicTextAnnotation.contentId, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t\t\tfor (var i = 0; i < oAdditionalShapeAnnotations.length; i++) {\r\n\t\t\t\t\t\t\tg_oAnnotations.g_oAnnotationsMade.push(oAdditionalShapeAnnotations[i]);\r\n\t\t\t\t\t\t\toAdditionalShapeAnnotations[i].annotationSaveShape(oAnnotationCanvas, false);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// If the annotation save was called on the main annotation only\r\n\t\t\t\t\t$(\".annotation\").remove();\r\n\r\n\t\t\t\t\t// Redraw the annotation canvas.\r\n\t\t\t\t\toAnnotationCanvas.redraw(false);\r\n\r\n\t\t\t\t\t// Recalculate the page annotation numbers.\r\n\t\t\t\t\tg_oAnnotations.renderPageAnnotationNumbers();\r\n\r\n\t\t\t\t\t// Update the signal-r.\r\n\t\t\t\t\ttry {\r\n\t\t\t\t\t\tg_oAnnotations.g_oAnnotationHub.server.send(g_oAnnotations.g_iApprovalId, g_oUserDetails.EmailAddress);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcatch (ex) {\r\n\t\t\t\t\t\t// do nothing\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// Rebind the draw functions once annotation saves.\r\n\t\t\t\t\t// Use setTimeout to make sure we ONLY rebind the canvas functions,\r\n\t\t\t\t\t// once they have finished, as they will execute twice!.\r\n\t\t\t\t\tvar oTimer = setTimeout(function () {\r\n\t\t\t\t\t\tg_oAnnotations.currentTimeoutListRemove(oTimer);\r\n\r\n\t\t\t\t\t\t// Only reset the annotation mouse events if there are no other actions in progress (i.e. Pan or Marquee Zoom).\r\n\t\t\t\t\t\tif (!g_oAnnotations.g_bNonAnnotationActionInProgress) {\r\n\t\t\t\t\t\t\t// Rebind previous draw/measurement by faking a click on the last selected tool.\r\n\t\t\t\t\t\t\t$(g_oAnnotations.g_oLastUsedTool).click();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}, 1000);\r\n\r\n\t\t\t\t\tg_oAnnotations.currentTimeoutListAdd(oTimer);\r\n\r\n\t\t\t\t\t// Set the position of the list following the re-render.\r\n\t\t\t\t\t$(\"#divAnnDiv_ListItems\").scrollTop(iListScrollTop);\r\n\t\t\t\t},\r\n\t\t\t\tfailure: function () {\r\n\t\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oAnnotations.c_szAnnotationFailedtoSave);\r\n\t\t\t\t},\r\n\t\t\t\terror: function () {\r\n\t\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oAnnotations.c_szAnnotationFailedtoSave);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Called when adding a new shape.\r\n\t * @param {object} oAnnotationCanvas - The annotation canvas\r\n\t * @param {bool} bUpdating - Whether it's an update event or not.\r\n\t */\r\n\tAnnotation.prototype.annotationSaveShape = function (oAnnotationCanvas, bUpdating) {\r\n\t\tvar oThisAnnotation = this;\r\n\t\tbUpdating = (typeof(bUpdating) !== \"undefined\") ? bUpdating : false;\r\n\r\n\t\t// Create the array co-ordinates for the annotations.\r\n\t\tvar annotationCoords = [];\r\n\r\n\t\tfor (var i = 0; i < oThisAnnotation.g_oDrawArray.length; i++) {\r\n\t\t\tvar oAnnotationCoordObject = {\r\n\t\t\t\tannotationId: oThisAnnotation.id,\r\n\t\t\t\tannotationX: oThisAnnotation.g_oDrawArray[i][0],\r\n\t\t\t\tannotationY: oThisAnnotation.g_oDrawArray[i][1],\r\n\t\t\t\tannotationZ: (typeof(oThisAnnotation.g_oDrawArray[i][2]) !== \"undefined\") ? oThisAnnotation.g_oDrawArray[i][i + 2] : null,\r\n\t\t\t\tmarqueeX: null,\r\n\t\t\t\tmarqueeY: null\r\n\t\t\t};\r\n\r\n\t\t\tannotationCoords.push(oAnnotationCoordObject);\r\n\t\t}\r\n\r\n\t\tif (g_oAnnotations.g_oPreviouslySavedAnnotationCoords == annotationCoords) {\r\n\t\t\t// We have a duplicate annotation! Return so we don't save it.\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Update the previous Annotation coordinates to the new set that we're about to save.\r\n\t\tg_oAnnotations.g_oPreviouslySavedAnnotationCoords = deepCopyArray(annotationCoords);\r\n\r\n\t\t// Create a cut down version of the Annotation object to be passed to the server.\r\n\t\tvar oAnnotationObject = {\r\n\t\t\tannotationId: this.id,\r\n\t\t\tapprovalId: this.g_iApprovalId,\r\n\t\t\tapprovalUserId: this.g_iAuthor,\r\n\t\t\tdocumentId: this.g_iDocumentId,\r\n\t\t\tdocumentPageId: this.g_iDocumentPageId,\r\n\t\t\treplyToAnnotId: this.g_iParentAnnotationId,\r\n\t\t\tannotationType: this.g_iAnnotationType,\r\n\t\t\tannotationDateTime: \"\",\r\n\t\t\tmodifiedDateTime: \"\",\r\n\t\t\tsvgVariableId: JSON.stringify(this.g_oSVGVariable),\r\n\t\t\tsvgOriginalContent: this.g_szSVGOriginalContent,\r\n\t\t\tannotationContent: this.g_szTextContent,\r\n\t\t\tannotationColour: g_oAnnotations.getHexColour(this.g_szColour) || this.g_szColour,\r\n\t\t\tunlocked: false,\r\n\t\t\tdeleted: false,\r\n\t\t\tannotationReplies: [],\r\n\t\t\tannotationStatuses: [],\r\n\t\t\tannotationCoords: annotationCoords,\r\n\t\t\tattachments: this.attachments\r\n\t\t};\r\n\r\n\t\t// Set the variables to point at the right method and give the right messages if it's updating the shape or not.\r\n\t\tvar szUrlString = bUpdating ? \"internal/GreenlightAnnotation/UpdateAnnotationShape\" : \"internal/GreenlightAnnotation/SaveAnnotationShape\";\r\n\t\tvar szSuccessMessage = bUpdating ? g_oAnnotations.c_szAnnotationUpdateSuccess : g_oAnnotations.c_szAnnotationSavedSuccessfully;\r\n\t\tvar szErrorMessage = bUpdating ? g_oAnnotations.c_szAnnotationUpdateFail : g_oAnnotations.c_szAnnotationFailedtoSave;\r\n\t\tvar bSetCoords = !bUpdating;\r\n\r\n\t\tif (bUpdating) {\r\n\t\t\tvar tmp = [];\r\n\t\t\tfor (var i = 0; i < this.g_oDrawCoordSetArray.length; i++) {\r\n\t\t\t\tvar oAnnotationCoordObject = {\r\n\t\t\t\t\tannotationCoordId: this.g_oDrawCoordSetArray[i].annotationCoordId,\r\n\t\t\t\t\tannotationId: this.g_oDrawCoordSetArray[i].annotationId,\r\n\t\t\t\t\tannotationX: this.g_oDrawCoordSetArray[i].xCoordinate,\r\n\t\t\t\t\tannotationY: this.g_oDrawCoordSetArray[i].yCoordinate,\r\n\t\t\t\t\tannotationZ: this.g_oDrawCoordSetArray[i].zCoordinate,\r\n\t\t\t\t\tmarqueeX: null,\r\n\t\t\t\t\tmarqueeY: null\r\n\t\t\t\t};\r\n\t\t\t\ttmp.push(oAnnotationCoordObject);\r\n\t\t\t}\r\n\t\t\t// Overwrite the previous coordinates which didn't have the coordinate id\r\n\t\t\toAnnotationObject.annotationCoords = tmp;\r\n\t\t}\r\n\r\n\t\t// Build up the annotation string.\r\n\t\tvar oJSON = {\r\n\t\t\tApprovalId: this.g_iApprovalId,\r\n\t\t\tSessionId: g_oAnnotations.c_szSessionId,\r\n\t\t\tAnnotationShape: oAnnotationObject\r\n\t\t};\r\n\t\t$.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: szUrlString,\r\n\t\t\tdata: JSON.stringify(oJSON),\r\n\t\t\tcontentType: \"application/json; charset=utf-8\",\r\n\t\t\tdataType: \"json\",\r\n\t\t\tsuccess: function (response) {\r\n\t\t\t\tg_oGreenlightMessages.displaySuccessBubble(szSuccessMessage);\r\n\r\n\t\t\t\t// Update the annotation just made.\r\n\t\t\t\toThisAnnotation.updateSavedShape(response, oThisAnnotation.id, bSetCoords);\r\n\t\t\t\toThisAnnotation.g_bSaved = true;\r\n\r\n\t\t\t\t// If the annotation save was called on the main annotation only\r\n\t\t\t\t$(\".annotation\").remove();\r\n\t\t\t\ttry {\r\n\t\t\t\t\tg_oAnnotations.g_oAnnotationHub.server.send(g_oAnnotations.g_iApprovalId, g_oUserDetails.EmailAddress);\r\n\t\t\t\t}\r\n\t\t\t\tcatch (ex){\r\n\t\t\t\t\tconsole.log(g_oAnnotations.c_szFailedToNotifyOthersMessage);\r\n\t\t\t\t}\r\n\t\t\t\toAnnotationCanvas.redraw(false);\r\n\r\n\t\t\t\tif (bSetCoords) { // Saving new child\r\n\t\t\t\t\t$(\"#AnnotationViewer\").on(\"pointermove.annotationUI\", function (e) {\r\n\t\t\t\t\t\tg_oAnnotationActions.mouseMoveLite(e, g_oViewer.getLinkedArtworkCanvas(oAnnotationCanvas.g_szCanvasId), oAnnotationCanvas);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\r\n\t\t\t},\r\n\t\t\tfailure: function () {\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(szErrorMessage);\r\n\t\t\t},\r\n\t\t\terror: function () {\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(szErrorMessage);\r\n\t\t\t}\r\n\t\t});\r\n\t};\r\n\r\n\t/**\r\n\t * On Click for the annotation edit button.\r\n\t * @param {event} e - The event object for the on click.\r\n\t */\r\n\tfunction EditButtonOnClick(e) {\r\n\r\n\t\t// Stop the defult click behaviours.\r\n\t\te.preventDefault();\r\n\t\te.stopPropagation();\r\n\r\n\t\t// Ensure we are not already editing text classification data.\r\n\t\tif ($(\".saveAnnotationDataButton\").length > 0) {\r\n\t\t\tg_oGreenlightMessages.displayErrorBubble(\"Please save any outstanding changes to text classifications.\");\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Note the scroll position of the list before the re-render.\r\n\t\tvar iListScrollTop = $(\"#divAnnDiv_ListItems\").scrollTop();\r\n\r\n\t\t// Work out whether or not this is read-only.\r\n\t\tvar bReadOnly = false;\r\n\t\tif ($(this).parent().hasClass(\"ReadOnlyReplyText\")) {\r\n\t\t\tbReadOnly = true;\r\n\t\t}\r\n\r\n\t\t// Grab the various elements of the edit button we just clicked on.\r\n\t\tvar relatedAnnotationId;\r\n\t\tvar relatedAnnotationDiv = $(this).parents(\".speechbubble\");\r\n\t\tvar relatedAnnotationListItem = $(this).parents(\".annotationListItem\");\r\n\r\n\t\t// Get the artwork and annotation canvas based on the related annotation item.\r\n\t\tvar oArtworkCanvas = null;\r\n\t\tvar oAnnotationCanvas = null;\r\n\r\n\t\t// If we have clicked the edit button from an annotation div.\r\n\t\tif (relatedAnnotationDiv.length === 0) {\r\n\t\t\trelatedAnnotationId = parseInt(relatedAnnotationListItem[0].id.substring(3), 10);\r\n\t\t\toArtworkCanvas = g_oViewer.getCanvas($(\"#\" + relatedAnnotationListItem[0].id).attr(\"data-artworkCanvas\"));\r\n\t\t\toAnnotationCanvas = oArtworkCanvas.g_oAnnotationCanvas;\r\n\t\t}\r\n\t\t// If we have clicked the edit button from an annotation list item.\r\n\t\telse {\r\n\t\t\trelatedAnnotationId = parseInt(relatedAnnotationDiv[0].id, 10);\r\n\t\t\toArtworkCanvas = g_oViewer.getCanvas($(\"#\" + relatedAnnotationDiv[0].id).attr(\"data-artworkCanvas\"));\r\n\t\t\toAnnotationCanvas = oArtworkCanvas.g_oAnnotationCanvas;\r\n\t\t}\r\n\r\n\t\t// Find the annotation.\r\n\t\tvar relatedAnnotation = $.grep(g_oAnnotations.g_oAnnotationsMade, function (ann) { return ann.id == relatedAnnotationId; });\r\n\r\n\t\t// If we could not find the annotation.\r\n\t\tif (!relatedAnnotation.length > 0) {\r\n\r\n\t\t\t// Find the annotation reply.\r\n\t\t\trelatedAnnotation = $.grep(g_oAnnotations.g_oReplies, function (ann) { return ann.id == relatedAnnotationId; });\r\n\t\t}\r\n\r\n\t\t// Remove the divs from the page as these will be rendered later.\r\n\t\t$(\".annotationListItem\").remove();\r\n\t\t$(\".annotation\").remove();\r\n\r\n\t\t// Create a list of annotations to be populated.\r\n\t\tvar annotations = [];\r\n\r\n\t\t// Loop through each of the annotations.\r\n\t\tfor (var i = 0; i < g_oAnnotations.g_oAnnotationsMade.length; i++) {\r\n\r\n\t\t\t// Skip if this annotation is an SVG hover or search.\r\n\t\t\tif (g_oAnnotations.g_oAnnotationsMade[i].g_bSVGHoverAnnotation || g_oAnnotations.g_oAnnotationsMade[i].g_bSVGSearchAnnotation) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\t// Ensure the annotation is on the current page.\r\n\t\t\tif ($.isEmptyObject(oArtworkCanvas.g_oDoc.pages)) {\r\n\t\t\t\toArtworkCanvas.g_oDoc.documentId == g_oAnnotations.g_oAnnotationsMade[i].g_iDocumentId ? annotations.push(g_oAnnotations.g_oAnnotationsMade[i]) : \"\";\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\t// Loop through the pages.\r\n\t\t\t\tfor (var j = 0; j < oArtworkCanvas.g_oDoc.pages.length; j++) {\r\n\t\t\t\t\tif (oArtworkCanvas.g_oDoc.pages[j].documentPageId == g_oAnnotations.g_oAnnotationsMade[i].g_iDocumentPageId &&\r\n\t\t\t\t\t\t(oArtworkCanvas.g_iCurrentPage == oArtworkCanvas.g_oDoc.pages[j].documentPageNumber)) {\r\n\t\t\t\t\t\tannotations.push(g_oAnnotations.g_oAnnotationsMade[i]);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Sort the annotations by number so they get re-added to the list correctly.\r\n\t\tannotations.sort(function (a, b) {\r\n\t\t\treturn a.g_iNumber - b.g_iNumber;\r\n\t\t});\r\n\r\n\t\t// Apply any annotation filters.\r\n\t\tannotations = g_oFilter.applyAnnotationFilters(annotations);\r\n\r\n\t\t// This loops through all the annotations on the current page.\r\n\t\t// This either, re-renders the editable text box or adds it to be rendered in the list.\r\n\t\tfor (var l = 0; l < annotations.length; l++) {\r\n\r\n\t\t\t// If we have a match to the annotation that we're changing\r\n\t\t\tif (relatedAnnotation[0].id === annotations[l].id) {\r\n\r\n\t\t\t\t// And the change was initiated from a pop-up.\r\n\t\t\t\tif (relatedAnnotationDiv.length !== 0) {\r\n\r\n\t\t\t\t\t// Create both the pop-up AND list item Div (in read only mode).\r\n\t\t\t\t\t// Use the event object id to work out if this edit button clicked on was a reply, as the edit has the ID added as an extra attribute.\r\n\t\t\t\t\trelatedAnnotation[0].createAnnotationDiv(eAnnotationDivType.Popup, bReadOnly, e.currentTarget.id.substr(e.currentTarget.id.lastIndexOf(\"_\") + 1), oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t\trelatedAnnotation[0].createAnnotationDiv(eAnnotationDivType.ListItem, true, null, oArtworkCanvas, oAnnotationCanvas);\r\n\r\n\t\t\t\t\t// If this is not a 3D canvas.\r\n\t\t\t\t\tif (g_oAnnotations.g_iApprovalType !== eDocumentTypes.ThreeD) {\r\n\t\t\t\t\t\toAnnotationCanvas.redraw(false);\r\n\t\t\t\t\t}\r\n\t\t\t\t\t// If this is a 3D canvas.\r\n\t\t\t\t\telse {\r\n\t\t\t\t\t\tg_oAnnotations.redraw3DAnnotations(oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t\t\toArtworkCanvas.g_oRenderer.render(oArtworkCanvas.g_oScene, oArtworkCanvas.g_oCamera);\r\n\t\t\t\t\t\tAnnotationUI.prototype.repositionSpeechBubbles(oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tchangeCanvasFunction(\".jqte_editor\", \"focus\", function (e) {\r\n\t\t\t\t\t\tchangeCanvasFunction(\"#AnnotationViewer\", \"pointerdown\", function (e) {\r\n\t\t\t\t\t\t\trelatedAnnotation[0].AnnotationTextEditorLooseFocusEvent(e, relatedAnnotation[0], null, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t\t$(\".jqte_editor\").focus();\r\n\t\t\t\t\trelatedAnnotation[0].g_bSaved = false;\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\t// The change was initiated from a list item, but check anyway\r\n\t\t\t\t\tif (relatedAnnotationListItem.length !== 0) {\r\n\t\t\t\t\t\tif (relatedAnnotation[0].g_iParentAnnotationId === 0 || relatedAnnotation[0].g_iParentAnnotationId === \"undefined\") {\r\n\t\t\t\t\t\t\trelatedAnnotation[0].createAnnotationDiv(eAnnotationDivType.ListItem, bReadOnly, e.currentTarget.id.substr(e.currentTarget.id.lastIndexOf(\"_\") + 1), oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tif (g_oAnnotations.g_iApprovalType !== eDocumentTypes.ThreeD) {\r\n\t\t\t\t\t\t\toAnnotationCanvas.redraw(false);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse {\r\n\t\t\t\t\t\t\tg_oAnnotations.redraw3DAnnotations(oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t\t\t\toArtworkCanvas.g_oRenderer.render(oArtworkCanvas.g_oScene, oArtworkCanvas.g_oCamera);\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tchangeCanvasFunction(\".jqte_editor\", \"focus\", function (e) {\r\n\t\t\t\t\t\t\tchangeCanvasFunction(\"#AnnotationViewer\", \"pointerdown\", function (e) {\r\n\t\t\t\t\t\t\t\trelatedAnnotation[0].AnnotationTextEditorLooseFocusEvent(e, relatedAnnotation[0], null, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\t$(\".jqte_editor\").focus();\r\n\t\t\t\t\t\trelatedAnnotation[0].g_bSaved = false;\r\n\t\t\t\t\t\tif ($(\"#\" + relatedAnnotationListItem[0].id).length && $(\"#\" + relatedAnnotationListItem[0].id).attr(\"class\").indexOf(\"annotationListItemSelected\") === -1) {\r\n\t\t\t\t\t\t\tvar oElement = document.getElementById(relatedAnnotationListItem[0].id);\r\n\t\t\t\t\t\t\t$(\"#\" + oElement.id).click();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\t// Not the annotation that we're changing. But we need to recreate the list item anyway.\r\n\t\t\t\tif (annotations[l].g_iParentAnnotationId == 0) {\r\n\t\t\t\t\tannotations[l].createAnnotationDiv(eAnnotationDivType.ListItem, true, null, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Set the position of the list following the re-render.\r\n\t\t$(\"#divAnnDiv_ListItems\").scrollTop(iListScrollTop);\r\n\r\n\t\t// Scroll to the edited annotaton item in the list.\r\n\t\tAnnotation.prototype.scrollEditAnnotation(relatedAnnotation[0]);\r\n\t}\r\n\r\n\t/**\r\n\t * Pans to a select annotation\r\n\t * @param {any} oArtworkCanvas - The artwork canvas.\r\n\t * @param {any} oAnnotationCanvas - The annotation canvas.\r\n\t */\r\n\tAnnotation.prototype.panToAnnotation = function (oArtworkCanvas, oAnnotationCanvas, oSyncCanvas) {\r\n\t\tvar parentCanvasObj = oAnnotationCanvas;\r\n\t\tvar parentArtworkViewer = oArtworkCanvas;\r\n\t\tif (parentArtworkViewer.g_iZoomLevel != 1) {\r\n\t\t\tvar annotationCoords = this.g_oDrawArray;\r\n\t\t\tvar annotationBounds = [1, 1, 0, 0];\r\n\t\t\tvar annotationMidPoint;\r\n\t\t\tfor (var i = 0; i < annotationCoords.length; i++) {\r\n\t\t\t\tif (annotationCoords[i][0] < annotationBounds[0]) {\r\n\t\t\t\t\tannotationBounds[0] = annotationCoords[i][0];\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (annotationCoords[i][1] < annotationBounds[1]) {\r\n\t\t\t\t\tannotationBounds[1] = annotationCoords[i][1];\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (annotationCoords[i][0] > annotationBounds[2]) {\r\n\t\t\t\t\tannotationBounds[2] = annotationCoords[i][0];\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (annotationCoords[i][1] > annotationBounds[3]) {\r\n\t\t\t\t\tannotationBounds[3] = annotationCoords[i][1];\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tvar maxCanvasWidth = parentArtworkViewer.g_iScaledImageWidth;\r\n\t\t\tvar maxCanvasHeight = parentArtworkViewer.g_iScaledImageHeight;\r\n\r\n\t\t\tfor (var syncCanvas in oSyncCanvas) {\r\n\t\t\t\tif (oSyncCanvas[syncCanvas].g_iZoomLevel == parentArtworkViewer.g_iZoomLevel) {\r\n\t\t\t\t\tmaxCanvasWidth = Math.max(maxCanvasWidth, oSyncCanvas[syncCanvas].g_iScaledImageWidth);\r\n\t\t\t\t\tmaxCanvasHeight = Math.max(maxCanvasHeight, oSyncCanvas[syncCanvas].g_iScaledImageHeight);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tannotationMidPoint = [annotationBounds[0] + ((annotationBounds[2] - annotationBounds[0]) / 2), annotationBounds[1] + ((annotationBounds[3] - annotationBounds[1]) / 2)];\r\n\t\t\tparentArtworkViewer.g_iTempDragOffset_x = (annotationMidPoint[0] * parentArtworkViewer.g_iScaledImageWidth) - (maxCanvasWidth / 2);\r\n\t\t\tparentArtworkViewer.g_iTempDragOffset_y = (annotationMidPoint[1] * parentArtworkViewer.g_iScaledImageHeight) - (maxCanvasHeight / 2);\r\n\t\t\tparentArtworkViewer.g_iDragXDiff = (parentArtworkViewer.g_iDragOffset_x - parentArtworkViewer.g_iTempDragOffset_x) / parentCanvasObj.g_iAnimateFrames;\r\n\t\t\tparentArtworkViewer.g_iDragYDiff = (parentArtworkViewer.g_iDragOffset_y - parentArtworkViewer.g_iTempDragOffset_y) / parentCanvasObj.g_iAnimateFrames;\r\n\r\n\t\t\tfor (var syncCanvas in oSyncCanvas) {\r\n\t\t\t\toSyncCanvas[syncCanvas].synchroniseZoomPanProperties(parentArtworkViewer);\r\n\t\t\t\toSyncCanvas[syncCanvas].g_oCanvasZoom.startZoomAnimate();\r\n\t\t\t}\r\n\r\n\t\t\tparentArtworkViewer.g_oCanvasZoom.startZoomAnimate();\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Updates a newly created annotation with the ID and sets the coordinate set object.\r\n\t * @param {object} oReturnedAnnotation - The server response as a JSON string.\r\n\t * @param {int} iTempId - The temporary ID given to this annotation.\r\n\t * @param {bool} bSetCoords - Boolean whether to set the annotation coordinates set object\r\n\t */\r\n\tAnnotation.prototype.updateSavedShape = function (oReturnedAnnotation, iTempId, bSetCoords) {\r\n\t\t// Find the annotation and update.\r\n\t\tfor (var i = 0; i < g_oAnnotations.g_oAnnotationsMade.length; i++) {\r\n\t\t\tif (g_oAnnotations.g_oAnnotationsMade[i].id === iTempId) {\r\n\t\t\t\tg_oAnnotations.g_oAnnotationsMade[i].id = oReturnedAnnotation.annotationId;\r\n\t\t\t\tif (bSetCoords) {\r\n\t\t\t\t\tfor (var j = 0; j < oReturnedAnnotation.annotationCoords.length; j++) {\r\n\t\t\t\t\t\tvar coordSet = g_oAnnotations.DrawCoordinatesSet(oReturnedAnnotation.annotationCoords[j].annotationId,\r\n\t\t\t\t\t\t\toReturnedAnnotation.annotationId,\r\n\t\t\t\t\t\t\toReturnedAnnotation.annotationCoords[j].annotationX,\r\n\t\t\t\t\t\t\toReturnedAnnotation.annotationCoords[j].annotationY,\r\n\t\t\t\t\t\t\toReturnedAnnotation.annotationCoords[j].annotationZ != null ? oReturnedAnnotation.annotationCoords[j].annotationZ : \"\");\r\n\t\t\t\t\t\tg_oAnnotations.g_oAnnotationsMade[i].g_oDrawCoordSetArray.push(coordSet);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\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 a newly created Annotation with it's ID from the database.\r\n\t * @param {string} response - The server response as a JSON String.\r\n\t * @param {number} tempId - The temporary ID given to this annotation\r\n\t */\r\n\tAnnotation.prototype.updateAnnotationId = function (response, tempId) {\r\n\t\tvar oReturnedAnnotation = JSON.parse(response);\r\n\t\t// Find the annotation and update.\r\n\t\tfor (var i = 0; i < g_oAnnotations.g_oAnnotationsMade.length; i++) {\r\n\t\t\tif (g_oAnnotations.g_oAnnotationsMade[i].id === tempId) {\r\n\t\t\t\tg_oAnnotations.g_oAnnotationsMade[i].id = oReturnedAnnotation.annotationId;\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 * Highlights the text measurement.\r\n\t * @param {any} bApplyTextHighlight - Boolean whether to apply the text highlight.\r\n\t * @param {any} oArtworkCanvas - The artwork canvas.\r\n\t * @param {any} oAnnotationCanvas - The annotation canvas.\r\n\t */\r\n\tAnnotation.prototype.highlightTextMeasurementWords = function (bApplyTextHighlight, oArtworkCanvas, oAnnotationCanvas) {\r\n\t\t\r\n\t\t// If the annotation type is a text measurement.\r\n\t\tif (this.g_iAnnotationType === eAnnotationTypes.TextMeasurement) {\r\n\r\n\t\t\t// Get the canvas scaled image width and height.\r\n\t\t\tvar iScaledImageWidth = oArtworkCanvas.g_iScaledImageWidth;\r\n\t\t\tvar iScaledImageHeight = oArtworkCanvas.g_iScaledImageHeight;\r\n\r\n\t\t\t// Calculate the compare offset on the artwork canvas.\r\n\t\t\tvar compareOffset_x, compareOffset_y;\r\n\t\t\tvar co = g_oCompare.calculateCompareOffsetInPx(oArtworkCanvas);\r\n\t\t\tcompareOffset_x = co.x;\r\n\t\t\tcompareOffset_y = co.y;\r\n\r\n\t\t\t// Get the compare rotation of the canvas.\r\n\t\t\tvar iCompareRotation = g_oCompare.getCompareRotation(oArtworkCanvas);\r\n\r\n\t\t\t// If we have a compare rotation of 90 or 270, swap the scaled image width and height.\r\n\t\t\tif (iCompareRotation == 90 || iCompareRotation == 270) {\r\n\t\t\t\tiScaledImageWidth = oArtworkCanvas.g_iScaledImageHeight;\r\n\t\t\t\tiScaledImageHeight = oArtworkCanvas.g_iScaledImageWidth;\r\n\t\t\t}\r\n\r\n\t\t\t// If the text measurement words array is populated.\r\n\t\t\tif (this.g_oTextMeasurementWordsArray !== undefined && this.g_oTextMeasurementWordsArray.length !== 0) {\r\n\r\n\t\t\t\t// Loop through each of the text measurement words.\r\n\t\t\t\tfor (var m = 0; m < this.g_oTextMeasurementWordsArray.length; m++) {\r\n\r\n\t\t\t\t\t// Get the text measurement word.\r\n\t\t\t\t\tvar word = this.g_oTextMeasurementWordsArray[m].ChildTextElements;\r\n\r\n\t\t\t\t\t// For each of the letters in the word.\r\n\t\t\t\t\tfor (var n = 0; n < word.length; n++) {\r\n\r\n\t\t\t\t\t\t// Get the positions of the letter.\r\n\t\t\t\t\t\tvar iLowerLeftX = word[n].Llx;\r\n\t\t\t\t\t\tvar iLowerLeftY = word[n].Lly;\r\n\t\t\t\t\t\tvar iUpperRightX = word[n].Urx;\r\n\t\t\t\t\t\tvar iUpperRightY = word[n].Ury;\r\n\r\n\t\t\t\t\t\t// If we have a compare rotation.\r\n\t\t\t\t\t\tif (iCompareRotation > 0) {\r\n\r\n\t\t\t\t\t\t\t// Rotate the lower left positions.\r\n\t\t\t\t\t\t\tvar oRotatedLetterLower = oAnnotationCanvas.rotate(iLowerLeftX, iLowerLeftY, 0.5, 0.5, iCompareRotation);\r\n\t\t\t\t\t\t\tiLowerLeftX = oRotatedLetterLower.rotated_x;\r\n\t\t\t\t\t\t\tiLowerLeftY = oRotatedLetterLower.rotated_y;\r\n\r\n\t\t\t\t\t\t\t// Rotate the upper right positions.\r\n\t\t\t\t\t\t\tvar oRotatedLetterUpper = oAnnotationCanvas.rotate(iUpperRightX, iUpperRightY, 0.5, 0.5, iCompareRotation);\r\n\t\t\t\t\t\t\tiUpperRightX = oRotatedLetterUpper.rotated_x;\r\n\t\t\t\t\t\t\tiUpperRightY = oRotatedLetterUpper.rotated_y;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t// Calculate the start positions and distance.\r\n\t\t\t\t\t\tvar startX = (iLowerLeftX * iScaledImageWidth) + oArtworkCanvas.g_iCenterShift_x + compareOffset_x;\r\n\t\t\t\t\t\tvar startY = (iUpperRightY * iScaledImageHeight) + oArtworkCanvas.g_iCenterShift_y + compareOffset_y;\r\n\t\t\t\t\t\tvar distX = ((iUpperRightX - iLowerLeftX) * iScaledImageWidth);\r\n\t\t\t\t\t\tvar distY = ((iLowerLeftY - iUpperRightY) * iScaledImageHeight);\r\n\r\n\t\t\t\t\t\toAnnotationCanvas.removeTextHighlight(oAnnotationCanvas.g_oContext, startX, startY, distX, distY);\r\n\r\n\t\t\t\t\t\tif (word[n].IsTextVisible && bApplyTextHighlight) {\r\n\t\t\t\t\t\t\toAnnotationCanvas.drawTextHighlight(oAnnotationCanvas.g_oContext, startX, startY, distX, distY, g_oAnnotations.g_szTextMeasurementFill);\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tif (word[n].insertedCharsBefore) {\r\n\t\t\t\t\t\t\tif (word[n].insertedCharsBefore.length) {\r\n\t\t\t\t\t\t\t\tvar insStartX = (iLowerLeftX * iScaledImageWidth) + oArtworkCanvas.g_iCenterShift_x + compareOffset_x - (distX / 2);\r\n\t\t\t\t\t\t\t\tvar insStartY = (iUpperRightY * iScaledImageHeight) + oArtworkCanvas.g_iCenterShift_y + compareOffset_y - (distY / 2);\r\n\t\t\t\t\t\t\t\tvar insDistX = distX;\r\n\t\t\t\t\t\t\t\tvar insDistY = distY;\r\n\r\n\t\t\t\t\t\t\t\toAnnotationCanvas.removeTextHighlight(oAnnotationCanvas.g_oContext, insStartX, insStartY, insDistX, insDistY);\r\n\r\n\t\t\t\t\t\t\t\tif (word[n].IsTextVisible && bApplyTextHighlight) {\r\n\t\t\t\t\t\t\t\t\toAnnotationCanvas.drawTextHighlight(oAnnotationCanvas.g_oContext, insStartX, insStartY, insDistX, insDistY, g_oAnnotations.g_szTextMeasurementFill);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t// Draw highlight in the middle of any inserted chars and offset by 50% vertically\r\n\t\t\t\t\t\tif (word[n].insertedCharsAfter) {\r\n\t\t\t\t\t\t\tif (word[n].insertedCharsAfter.length) {\r\n\t\t\t\t\t\t\t\tvar insStartX = (iLowerLeftX * iScaledImageWidth) + oArtworkCanvas.g_iCenterShift_x + compareOffset_x - (distX / 2);\r\n\t\t\t\t\t\t\t\tvar insStartY = (iUpperRightY * iScaledImageHeight) + oArtworkCanvas.g_iCenterShift_y + compareOffset_y - (distY / 2);\r\n\t\t\t\t\t\t\t\tvar insDistX = distX;\r\n\t\t\t\t\t\t\t\tvar insDistY = distY;\r\n\r\n\t\t\t\t\t\t\t\toAnnotationCanvas.removeTextHighlight(oAnnotationCanvas.g_oContext, insStartX, insStartY, insDistX, insDistY);\r\n\r\n\t\t\t\t\t\t\t\tif (word[n].IsTextVisible && bApplyTextHighlight) {\r\n\t\t\t\t\t\t\t\t\toAnnotationCanvas.drawTextHighlight(oAnnotationCanvas.g_oContext, insStartX, insStartY, insDistX, insDistY, g_oAnnotations.g_szTextMeasurementFill);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\t// These functions convert a 2D annotation point - uvx, uvy - into 3D.\r\n\r\n\t// Pass in the annotation 2d point (mid or start etc) that you want to convert.\r\n\t// Get back the 3d coordinates IF the annotation point exists against the relevant 3D texture.\r\n\t/**\r\n\t *\r\n\t * @param {any} uvx\r\n\t * @param {any} uvy\r\n\t * @param {any} szColladaModelTexture\r\n\t * @param {any} oScene\r\n\t */\r\n\tAnnotation.prototype.Convert2DTo3DAnnotation = function (uvx, uvy, szColladaModelTexture, oScene) {\r\n\t\t// Reverse the y coordinate. PDF Y coordinates measured from bottom up.\r\n\t\tuvy = 1 - uvy;\r\n\t\t\t\t// First we traverse the polygons in the model to determine if there is anything that has a geometry.\r\n\t\t// The three.js scene object describes all objects in the 3d world.\r\n\t\tvar annotation3DPoint = g_oThreeDView.TraversePolygonsForGeometries(oScene, uvx, uvy, this.g_iDocumentId, szColladaModelTexture);\r\n\r\n // Clear draw array\r\n this.g_oDrawArray = [];\r\n // Change type to 3D annotation\r\n this.g_iAnnotationType = eAnnotationTypes.ThreeD;\r\n if (annotation3DPoint) {\r\n\t\t\tthis.g_oDrawArray.push([annotation3DPoint.x, annotation3DPoint.y, annotation3DPoint.z]);\r\n } else {\r\n // Annotation is out of artwork bounds\r\n // Stick it in the middle\r\n this.g_oDrawArray.push([0, 0, 0]);\r\n }\r\n };\r\n\r\n\t/**\r\n\t* Manage the entire colour selection and changing of the annotation \r\n * @param {object} oAnnotationCanvas - Annotation canvas area.\r\n **/\r\n\tAnnotation.prototype.SelectColourFromDisplay = function (oAnnotationCanvas) {\r\n\t\tvar annotationStack = g_oAnnotations.filteredAnnotationStack(g_oAnnotations.g_oAnnotationsMade);\r\n\t\t// Delete the div to clear the dotted line to annotation div if present\r\n\t\t$(this).parent().remove();\r\n\t\tevent.stopPropagation();\r\n\t\t\r\n\t\t$(\".annotationviewer\").off(\"pointerdown\");\r\n\t\t$(\".annotationviewer\").off(\"pointerup\");\r\n\t\t\r\n\t\toAnnotationCanvas.redraw(false);\r\n\t\tvar result = $.grep(annotationStack, function (annotation) { return annotation.id === g_oAnnotations.g_AnnotationId; });\r\n\t\t\r\n\t\tif (result.length || result.length > 0) {\r\n\t\t\t// Popup colour selection grid.\r\n\t\t\tAnnotation.prototype.DisplayColourSelection(result[0].g_szColour, event);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oAnnotations.c_szColourErrorUnableToFind);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Remove the NoAfter if we are dealing with speech bubbles\r\n\t */ \r\n\tAnnotation.prototype.ResetPreviousSelection = function () {\r\n\t\tif (g_oAnnotations.g_oPreviousSpeechAnnotation && g_oAnnotations.g_oPreviousSpeechAnnotationArrow) {\r\n\t\t\tg_oAnnotations.g_oPreviousSpeechAnnotation.classList.remove(\"noAfter\");\r\n\r\n\t\t\tg_oAnnotations.g_oPreviousSpeechAnnotationArrow = false;\r\n\t\t\tg_oAnnotations.g_oPreviousSpeechAnnotation = null;\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * popup a colour selection panel.\r\n\t * @param {string} szPreviousColour - Previous colour.\r\n\t * @param {obj} event - The event.\r\n\t */\r\n\tAnnotation.prototype.DisplayColourSelection = function (szPreviousColour, event) {\r\n\t\t\r\n\t\t// Update the annotation colour.\r\n\t\tg_oSettings.g_oUserSettings.AnnotationColour = g_oAnnotations.getHexColour(szPreviousColour);\r\n\t\tg_oSettings.updateSettingAnnotationColour(true);\r\n\r\n\t\t// Preset the user tools.\r\n\t\tAnnotationUI.prototype.presetUserTools();\r\n\r\n\t\t// clone the colour thingie.\r\n\t\tvar oActive = null;\r\n\r\n\t\t// if we are a list annotation\r\n\t\tvar bListAnnotation = false;\r\n\r\n\t\t// name of the colour selection icon we need to attach too.\r\n\t\tvar szSelectedAnnotationColourIcon = \"\";\r\n\r\n\t\tvar id = (event.toElement == undefined) ? event.target.id : event.toElement.id;\r\n\t\tvar bIsAddShapeAvailable = undefined;\r\n\r\n\t\t// check if our previous item is a speech bubble as we need to remove the noAfter to show our box pointer.\r\n\t\tAnnotation.prototype.ResetPreviousSelection();\r\n\r\n\t\tif (\"scPop_\" + g_oAnnotations.g_AnnotationId.toString() === id) {\r\n\t\t\toActive = document.getElementById(g_oAnnotations.g_AnnotationId.toString());\r\n\t\t\tg_oAnnotations.g_oPreviousSpeechAnnotation = oActive;\r\n\t\t\tszSelectedAnnotationColourIcon = \"sc_\" + g_oAnnotations.g_AnnotationId.toString();\r\n\t\t\tbIsAddShapeAvailable = document.getElementById(\"asb_\" + g_oAnnotations.g_AnnotationId.toString())\r\n\t\t}\r\n\t\telse { \r\n\t\t\toActive = document.getElementById(\"li_\" + g_oAnnotations.g_AnnotationId.toString());\r\n\t\t\tbListAnnotation = true;\r\n\t\t\tszSelectedAnnotationColourIcon = \"sc_li_\" + g_oAnnotations.g_AnnotationId.toString();\r\n\t\t\tbIsAddShapeAvailable = document.getElementById(\"asb_li_\" + g_oAnnotations.g_AnnotationId.toString())\r\n\t\t}\r\n\r\n\t\t// Check if we have a colour pop-up as we need to remove it.\r\n\t\tAnnotation.prototype.RemoveLastColourSelection();\r\n\r\n\t\tif (oActive) {\r\n\t\t\tAnnotation.prototype.ClearColourSelection((g_AvailableColours.indexOf(szPreviousColour) !== -1)\r\n\t\t\t\t? g_oAnnotations.getHexColour(szPreviousColour) : szPreviousColour);\r\n\r\n\t\t\tvar szBackgroundColour = (g_oSettings.c_iSkinType == 0) ? \"black\" : \"white\";\r\n\r\n\t\t\t// get the original table to clone from.\r\n\t\t\tvar colourGrid = document.getElementById(\"colourSelectionGridTable\").cloneNode(true);\r\n\t\t\tif (colourGrid) {\r\n\t\t\t\tcolourGrid.id = \"newPopupColourSelection_1\";\r\n\t\t\t\tcolourGrid.style.background = szBackgroundColour;\r\n\t\t\t\tcolourGrid.style.display = \"block\";\r\n\r\n\t\t\t\t// check if the shape icon is available, otherwise we need to move the colour selection.\r\n\t\t\t\tif (bIsAddShapeAvailable) {\r\n\t\t\t\t\tcolourGrid.style['margin-top'] = \"28px\";\r\n\t\t\t\t\tcolourGrid.style['margin-left'] = \"21px\";\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\tcolourGrid.style['margin-top'] = \"28px\";\r\n\t\t\t\t\tcolourGrid.style['margin-left'] = \"4px\";\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\t// get the colour selection icon as we need to attach our selection to this.\r\n\t\t\t\tvar oSectionToAppendTo = document.getElementById(szSelectedAnnotationColourIcon);\r\n\t\t\t\tif (oSectionToAppendTo) {\r\n\t\t\t\t\toSectionToAppendTo.appendChild(colourGrid);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// we need to add and the new class and toggle when we are type 1 interface\r\n\t\t\t\tif (g_oSettings.c_iSkinType == 1) {\r\n\t\t\t\t\tdocument.getElementById(\"newPopupColourSelection_1\").classList.add(\"dvPopupAnnotationWhiteColour\");\r\n\t\t\t\t\tdocument.getElementById(\"newPopupColourSelection_1\").classList.add(\"colorWhiteSelection\");\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\t// check if we have a noAfter as this draws the speech bubble arrow.\r\n\t\t\t\tif (!oActive.classList.contains(\"noAfter\")) {\r\n\t\t\t\t\t$(oActive).addClass(\"noAfter\");\r\n\t\t\t\t\tg_oAnnotations.g_oPreviousSpeechAnnotationArrow = true;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\t// handle the resizing.\r\n\t\t\t\tAnnotation.prototype.ResizeColourSelection(false);\r\n\t\t\t\t\r\n\t\t\t\t// Scroll the colour selection tool into view.\r\n\t\t\t\tAnnotation.prototype.scrollColourSelection(oActive, colourGrid, bListAnnotation);\r\n\t\t\t} \r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Clears the popup colour selection grid of the last selection.\r\n\t * @param {string} szColour - Remove any highlighted from colour selection.\r\n\t **/\r\n\tAnnotation.prototype.ClearColourSelection = function (szColour) {\r\n\t\tfor (var i = 0; i < g_AvailableColours.length; i++) {\r\n\t\t\tvar oColourElement = $(\"#annotatePopUpTable\" + g_AvailableColours[i].charAt(0).toUpperCase() + g_AvailableColours[i].substring(1))\r\n\t\t\t$(oColourElement).css(\"background\", g_AvailableColours[i]);\r\n\r\n\t\t\tif (g_oAnnotations.getHexColour(g_AvailableColours[i]) != szColour) {\r\n\t\t\t\t$(oColourElement).css(\"border-color\", g_AvailableColours[i]);\r\n\r\n\t\t\t\t// change the main selection colour to this colour.\r\n\t\t\t\tvar oColourElement = document.getElementById(\"annotate\" + g_AvailableColours[i].charAt(0).toUpperCase() + g_AvailableColours[i].substring(1));\r\n\t\t\t\t$(oColourElement).css(\"border-color\", g_AvailableColours[i]);\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Remove the colour element from the class.\r\n\t * @param {object} oElement - Speechbubble object to remove class from.\r\n\t **/\r\n\tAnnotation.prototype.RemoveColourClass = function (oElement) {\r\n\t\tfor (var i = 0; i < g_AvailableColours.length; i++) {\r\n\t\t\t// check for camel case\r\n\t\t\t$(oElement).removeClass(\"annotation\" + g_AvailableColours[i].charAt(0).toUpperCase() + g_AvailableColours[i].substring(1))\r\n\t\t\t// check for lower case\r\n\t\t\t$(oElement).removeClass(\"annotation\" + g_AvailableColours[i].toLowerCase());\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * A coulour has been selected now we need to update the various annotations.\r\n\t **/\r\n\tAnnotation.prototype.SelectedColour = function () {\r\n\t\tevent.stopPropagation();\r\n\t\tevent.preventDefault();\r\n\t\t\r\n\t\t// Get the local colour attribute.\r\n\t\tvar szLocalColour = event.target.getAttribute('data-annotationcolour');\r\n\r\n\t\t// If found.\r\n\t\tif (szLocalColour !== undefined) {\r\n\r\n\t\t\t// If we are updating a colour setting.\r\n\t\t\tif ($(event.target).parents(\"#settingAnnotationColourPopup\").length > 0) {\r\n\r\n\t\t\t\t// Update the annotation colour setting.\r\n\t\t\t\tg_oAnnotations.annotationColourChange(szLocalColour);\r\n\t\t\t}\r\n\t\t\t// Otherwise we are updating an annotation colour.\r\n\t\t\telse {\r\n\r\n\t\t\t\tvar annotationStack = g_oAnnotations.filteredAnnotationStack(g_oAnnotations.g_oAnnotationsMade);\r\n\t\t\t\tvar resultSelected = $.grep(annotationStack, function (annotation) { return annotation.id == g_oAnnotations.g_AnnotationId; });\r\n\t\t\t\tif (resultSelected.length > 0) {\r\n\t\t\t\t\tfor (var i = 0; i < annotationStack.length; i++) {\r\n\t\t\t\t\t\tif (annotationStack[i].g_iNumber == resultSelected[0].g_iNumber) {\r\n\r\n\t\t\t\t\t\t\t// Get the previous colour.\r\n\t\t\t\t\t\t\tvar szPreviousColour = annotationStack[i].g_szColour;\r\n\r\n\t\t\t\t\t\t\t// Update the colour to the newly selected colour.\r\n\t\t\t\t\t\t\tannotationStack[i].g_szColour = szLocalColour;\r\n\r\n\t\t\t\t\t\t\t// Set the new selected colour on the user tool menu.\r\n\t\t\t\t\t\t\tvar oColourElement = document.getElementById(\"annotate\" + szLocalColour.charAt(0).toUpperCase() + szLocalColour.substring(1));\r\n\t\t\t\t\t\t\t$(oColourElement).click();\r\n\r\n\t\t\t\t\t\t\t// Get the artwork and annotation canvas.\r\n\t\t\t\t\t\t\tvar oArtworkCanvas = g_oViewer.getCanvas(\"ArtworkViewer\");\r\n\t\t\t\t\t\t\tvar oAnnotationCanvas = oArtworkCanvas.g_oAnnotationCanvas;\r\n\r\n\t\t\t\t\t\t\t// Delete the div to clear the dotted line to annotation div if present\r\n\t\t\t\t\t\t\t$(this).parent().remove();\r\n\r\n\t\t\t\t\t\t\t// Rebuild the annotation div.\r\n\t\t\t\t\t\t\tg_oAnnotations.rebuildAnnotationList(oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// handle speech bubble colour changes.\r\n\t\t\t\t\tthis.g_szColour = szLocalColour;\r\n\t\t\t\t\tvar oSpeechBubble = document.getElementById(g_oAnnotations.g_AnnotationId.toString());\r\n\t\t\t\t\tif (oSpeechBubble) {\r\n\t\t\t\t\t\tthis.RemoveColourClass(oSpeechBubble);\r\n\t\t\t\t\t\t$(oSpeechBubble).addClass(\"annotation\" + szLocalColour);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// Get the save colour as a hex string.\r\n\t\t\t\t\tvar szSaveNewColour = g_oAnnotations.getHexColour(szLocalColour);\r\n\r\n\t\t\t\t\t// Check if we have an annotation id and if not don't do any selection.\r\n\t\t\t\t\tif ((g_oAnnotations.g_AnnotationId !== -1) && (g_oAnnotations.g_AnnotationId !== undefined)) {\r\n\r\n\t\t\t\t\t\t// Convert the previous colour to a hex string.\r\n\t\t\t\t\t\tvar szSavePrev = g_oAnnotations.getHexColour(szPreviousColour);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t// If we have changed colour.\r\n\t\t\t\t\t\tif (resultSelected.length > 0 && szSavePrev !== szSaveNewColour) {\r\n\r\n\t\t\t\t\t\t\t// Counter used to track the number.\r\n\t\t\t\t\t\t\tvar iCallCount = 0;\r\n\t\t\t\t\t\t\tfor (var i = 0; i < annotationStack.length; i++) {\r\n\t\t\t\t\t\t\t\tif (annotationStack[i].g_iNumber == resultSelected[0].g_iNumber) {\r\n\r\n\t\t\t\t\t\t\t\t\t// Call the save mechanism.\r\n\t\t\t\t\t\t\t\t\tAnnotation.prototype.UpdateColourSelection(annotationStack[i].id, szSaveNewColour, g_oAnnotations.c_szColourUpdate.replace(\"{colour1}\", g_oAnnotations.getStringColour(szPreviousColour)).replace(\"{colour2}\", g_oAnnotations.getStringColour(szLocalColour)), g_oUserDetails.UserId, iCallCount);\r\n\t\t\t\t\t\t\t\t\tiCallCount += 1;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// Check if we have a colour pop-up as we need to remove it.\r\n\t\t\t\t\tAnnotation.prototype.RemoveLastColourSelection();\r\n\r\n\t\t\t\t\t// Override the pointer up event.\r\n\t\t\t\t\tif (oArtworkCanvas.g_oDoc.documentType === eDocumentTypes.ThreeD) {\r\n\t\t\t\t\t\t// remove the old number so we can call the re-create mechanism.\r\n\t\t\t\t\t\tfor (var i = (oArtworkCanvas.g_oScene.children.length - 1); i > -1; i--) {\r\n\t\t\t\t\t\t\t// Remove both the Annotation object & the Annotation Number from the 3D scene array.\r\n\t\t\t\t\t\t\tif (oArtworkCanvas.g_oScene.children[i].Id == resultSelected[0].id ||\r\n\t\t\t\t\t\t\t\toArtworkCanvas.g_oScene.children[i].Id == \"annNo_\" + resultSelected[0].id) {\r\n\t\t\t\t\t\t\t\toArtworkCanvas.g_oScene.children.splice(i, 1);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tg_oAnnotations.redraw3DAnnotations(oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t\t\toArtworkCanvas.g_oRenderer.render(oArtworkCanvas.g_oScene, oArtworkCanvas.g_oCamera);\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse {\r\n\t\t\t\t\t\toArtworkCanvas.redraw(false);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// clear any selections\r\n\t\t\t\t\tg_oAnnotations.g_AnnotationId = null;\r\n\t\t\t\t\tg_oAnnotations.g_oAnnotationColSelected = szSaveNewColour;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Perform the update of the annotation colour.\r\n\t * @param {int} iId - ID of the annotation we want to update.\r\n\t * @param {string} szHexColour - the colour we wisht to update too.\r\n\t * @param {string} szAnnotationContent - Description of change.\r\n\t * @param {int} iapprovalUserId - Who approved it.\r\n\t * @param {int} iCallCount - The position of the save requests only occurs with multiple shapes\r\n\t */\r\n\tAnnotation.prototype.UpdateColourSelection = function (iId, szHexColour, szAnnotationContent, iapprovalUserId, iCallCount) {\r\n\r\n\t\t// Build up the annotation string.\r\n\t\tvar oJSON = {\r\n\t\t\tiAnnotationId: iId,\r\n\t\t\tszAnnotationColour: szHexColour,\r\n\t\t\tannotationContent: szAnnotationContent,\r\n\t\t\tapprovalUserId: iapprovalUserId\r\n\t\t};\r\n\r\n\t\t$.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: \"internal/GreenlightAnnotation/UpdateColourAnnotation\",\r\n\t\t\tdata: JSON.stringify(oJSON),\r\n\t\t\tcontentType: \"application/json; charset=utf-8\",\r\n\t\t\tdataType: \"json\",\r\n\t\t\tsuccess: function () {\r\n\t\t\t\tif (iCallCount == 0) {\r\n\t\t\t\t\t// display success message.\r\n\t\t\t\t\tg_oGreenlightMessages.displaySuccessBubble(g_oAnnotations.c_szColourSuccessAnnotationText);\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tfailure: function () {\r\n\t\t\t\tif (iCallCount == 0) {\r\n\t\t\t\t\t// display failure message.\r\n\t\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oAnnotations.c_szColourErrorAnnotationText);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t * Handle the resize of the browser \r\n\t * @param {bool} bClearSelection - Option to clear colour selection pop-up.\r\n\t **/\r\n\tAnnotation.prototype.ResizeColourSelection = function (bClearSelection) {\r\n\t\tvar colourGrid = document.getElementById(\"newPopupColourSelection_1\");\r\n\r\n\t\t// remove colour pop-up only if we are resizing the canvas\r\n\t\tif (bClearSelection && (colourGrid != null || colourGrid != undefined)) {\r\n\t\t\tcolourGrid.parentElement.removeChild(colourGrid);\r\n\t\t\treturn;\r\n\t\t}\r\n\t};\r\n\r\n\t/*\r\n\t * Catch the click event of the form and clean-up.\r\n\t **/\r\n\t$(document).on('click', function (event) {\r\n\t\tAnnotation.prototype.RemoveLastColourSelection();\r\n\t});\r\n\r\n\t/*\r\n\t * Removes the last colour pop-up if it exists.\r\n\t **/\t\r\n\tAnnotation.prototype.RemoveLastColourSelection = function () {\r\n\t\tvar oNewPopupColour = document.getElementById(\"newPopupColourSelection_1\");\r\n\t\tif (oNewPopupColour) {\r\n\t\t\toNewPopupColour.parentElement.removeChild(oNewPopupColour);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Scrolls to the colour selection tool once shown.\r\n\t * @param {object} oAnnotationItem - The annotation item.\r\n\t * @param {object} oColourGrid - The colour grid item.\r\n\t * @param {bool} bListAnnotation - If the item is in a list or popup.\r\n\t */\r\n\tAnnotation.prototype.scrollColourSelection = function (oAnnotationItem, oColourGrid, bListAnnotation) {\r\n\t\t\r\n\t\t// If this is a list item, scroll the list.\r\n\t\tif (bListAnnotation) {\r\n\t\t\tAnnotation.prototype.scrollColourSelectionList(oColourGrid);\r\n\t\t}\r\n\t\t// If this is a popup item, move the popup.\r\n\t\telse {\r\n\t\t\tAnnotation.prototype.scrollColourSelectionPopup(oColourGrid, oAnnotationItem);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Scroll to the colour selection tool in the list.\r\n\t * @param {object} oColourGrid - The colour selection tool.\r\n\t */\r\n\tAnnotation.prototype.scrollColourSelectionList = function (oColourGrid) {\r\n\r\n\t\t// Get the position of the tool.\r\n\t\tvar iToolPosition = $(oColourGrid).position().top;\r\n\r\n\t\t// Add the height of the tool.\r\n\t\tiToolPosition += $(oColourGrid).height();\r\n\r\n\t\t// Add the top margin of the tool.\r\n\t\tiToolPosition += parseInt($(oColourGrid).css(\"margin-top\"));\r\n\r\n\t\t// If this is off the bottom of the div.\r\n\t\tif (iToolPosition > $(\"#divAnnDiv_ListItems\").height()) {\r\n\r\n\t\t\t// Calculate the amount we need to scroll by, plus some nice padding.\r\n\t\t\tvar iScrollAmount = iToolPosition - $(\"#divAnnDiv_ListItems\").height() + 10;\r\n\r\n\t\t\t// Scroll the annotation list item into view.\r\n\t\t\t$(\"#divAnnDiv_ListItems\").animate({ scrollTop: \"+=\" + iScrollAmount + \"px\" });\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Scroll to the colour selection tool in the popup.\r\n\t * @param {object} oColourGrid - The colour selection tool.\r\n\t * @param {object} oAnnotationItem - The annotation item.\r\n\t */\r\n\tAnnotation.prototype.scrollColourSelectionPopup = function (oColourGrid, oAnnotationItem) {\r\n\r\n\t\t// Determine the bottom position of the tooltip.\r\n\t\tvar iToolBottomPosition = $(oAnnotationItem).position().top + $(oAnnotationItem).height() + $(oColourGrid).height() + 20;\r\n\r\n\t\t// If our tool has not overflown the height of the canvas holder.\r\n\t\tif (iToolBottomPosition < $(\"#divCanvasHolder\").height()) {\r\n\r\n\t\t\t// We do not need to scroll the popup.\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Determine the overflow amount.\r\n\t\tvar iOverflowAmount = iToolBottomPosition - $(\"#divCanvasHolder\").height();\r\n\r\n\t\t// Add margin of 10px.\r\n\t\tiOverflowAmount += 10;\r\n\r\n\t\t// Move the bubble up by the height of the tool.\r\n\t\t$(oAnnotationItem).css(\"top\", (parseInt($(oAnnotationItem).css(\"top\").replace(\"px\", \"\")) - iOverflowAmount) + \"px\");\r\n\r\n\t\t// Reposition the speech bubbles.\r\n\t\tAnnotation.prototype.scrollRepositionSpeechBubbles(oAnnotationItem);\r\n\t};\r\n\r\n\t/**\r\n\t * Scrolls to the annotation edit.\r\n\t * @param {object} oAnnotationItem - The annotation that is being edited.\r\n\t */\r\n\tAnnotation.prototype.scrollEditAnnotation = function (oAnnotationItem) {\r\n\t\t\r\n\t\t// Get the position of the top and bottom of the annotation edit.\r\n\t\tvar iEditStart = $(\"#li_\" + oAnnotationItem.id).position().top;\r\n\t\tvar iEditEnd = $(\"#li_\" + oAnnotationItem.id).position().top + $(\"#li_\" + oAnnotationItem.id).height();\r\n\r\n\t\t// If this is off the bottom of the div.\r\n\t\tif (iEditEnd > $(\"#divAnnDiv_ListItems\").height()) {\r\n\r\n\t\t\t// Calculate the amount we need to scroll by plus some padding\r\n\t\t\tvar iScrollDownAmount = iEditEnd - $(\"#divAnnDiv_ListItems\").height() + 50;\r\n\r\n\t\t\t// Scroll the annotation edit into view.\r\n\t\t\t$(\"#divAnnDiv_ListItems\").animate({ scrollTop: \"+=\" + iScrollDownAmount + \"px\" });\r\n\t\t}\r\n\t\t// If this is before the start of the div.\r\n\t\telse if (iEditStart < 0) {\r\n\r\n\t\t\t// Calculate the amount we need to scroll up by plus some padding.\r\n\t\t\tvar iScrollUpAmount = iEditStart - 10;\r\n\r\n\t\t\t// Scroll the annotation edit into view.\r\n\t\t\t$(\"#divAnnDiv_ListItems\").animate({ scrollTop: \"+=\" + iScrollUpAmount + \"px\" });\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Scrolls to the annotation reply.\r\n\t * @param {object} oAnnotationItem - The annotation item.\r\n\t * @param {object} bListItem - If the item is a list or popup.\r\n\t */\r\n\tAnnotation.prototype.scrollReplyAnnotation = function (oAnnotationItem, bListItem) {\r\n\r\n\t\t// If this is a list item.\r\n\t\tif (bListItem) {\r\n\r\n\t\t\t// Scroll the list.\r\n\t\t\tAnnotation.prototype.scrollReplyAnnotationList(oAnnotationItem);\r\n\t\t}\r\n\t\t// If this is a popup.\r\n\t\telse {\r\n\r\n\t\t\t// Scroll the popup.\r\n\t\t\tAnnotation.prototype.scrollRepositionSpeechBubbles(oAnnotationItem);\r\n\t\t}\r\n\t\t\r\n\t\t// Scroll the popup content to the bottom to ensure we can see the full reply.\r\n\t\t$(oAnnotationItem).children(\".popup-content\").scrollTop($(oAnnotationItem).children(\".popup-content\")[0].scrollHeight);\r\n\t};\r\n\r\n\t/**\r\n\t * Scrolls the reply into view in the list.\r\n\t * @param {object} oAnnotationItem - The annotation item.\r\n\t */\r\n\tAnnotation.prototype.scrollReplyAnnotationList = function (oAnnotationItem) {\r\n\r\n\t\t// Get the position of the footer underneath the reply.\r\n\t\tvar iReplyPosition = $(\"#sc_\" + oAnnotationItem.id).position().top;\r\n\r\n\t\t// If this is off the bottom of the div.\r\n\t\tif (iReplyPosition > $(\"#divAnnDiv_ListItems\").height()) {\r\n\r\n\t\t\t// Calculate the amount we need to scroll by.\r\n\t\t\tvar iScrollAmount = iReplyPosition - $(\"#divAnnDiv_ListItems\").height();\r\n\r\n\t\t\t// Scroll the annotation list item into view.\r\n\t\t\t$(\"#divAnnDiv_ListItems\").animate({ scrollTop: \"+=\" + iScrollAmount + \"px\" });\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Checks to see if a reply popup needs an initial scroll.\r\n\t * @param {object} oAnnotationItem - The annotation to be checked.\r\n\t * @returns {bool} - If the scroll is required.\r\n\t */\r\n\tAnnotation.prototype.preReplyScrollRequired = function (oAnnotationItem) {\r\n\r\n\t\t// Outline the variable to be returned..\r\n\t\tvar bScrollRequired = false;\r\n\r\n\t\t// Determine the bottom position of the popup.\r\n\t\tvar iPopupBottomPosition = $(oAnnotationItem).position().top + $(oAnnotationItem).height() + 100;\r\n\r\n\t\t// If our popup will overflow the canvas.\r\n\t\tif (iPopupBottomPosition > $(\"#divCanvasHolder\").height()) {\r\n\r\n\t\t\t// We need to scroll the popup.\r\n\t\t\tbScrollRequired = true;\r\n\t\t}\r\n\r\n\t\t// Return if the scroll is required.\r\n\t\treturn bScrollRequired;\r\n\t}\r\n\r\n\t/**\r\n\t * Scrolls to the annotation status in the list if required.\r\n\t * @param {object} oAnnotationItem - The annotation to scroll to the status of.\r\n\t */\r\n\tAnnotation.prototype.ScrollStatusAnnotationList = function (oAnnotationItem) {\r\n\t\t\r\n\t\t// Get the position of the top and bottom of the annotation status section.\r\n\t\tvar iStatusStart = $(\"#sc_li_\" + oAnnotationItem.id).position().top;\r\n\t\tvar iStatusEnd = $(\"#li_\" + oAnnotationItem.id).position().top + $(\"#li_\" + oAnnotationItem.id).height();\r\n\r\n\t\t// If this is off the bottom of the div.\r\n\t\tif (iStatusEnd > $(\"#divAnnDiv_ListItems\").height()) {\r\n\r\n\t\t\t// Calculate the amount we need to scroll by plus some padding\r\n\t\t\tvar iScrollDownAmount = iStatusEnd - $(\"#divAnnDiv_ListItems\").height() + 20;\r\n\r\n\t\t\t// Scroll the annotation status into view.\r\n\t\t\t$(\"#divAnnDiv_ListItems\").animate({ scrollTop: \"+=\" + iScrollDownAmount + \"px\" });\r\n\t\t}\r\n\t\t// If this is before the start of the div.\r\n\t\telse if (iStatusStart < 0) {\r\n\r\n\t\t\t// Calculate the amount we need to scroll up by plus some padding.\r\n\t\t\tvar iScrollUpAmount = iStatusStart - 150;\r\n\r\n\t\t\t// Scroll the annotation status into view.\r\n\t\t\t$(\"#divAnnDiv_ListItems\").animate({ scrollTop: \"+=\" + iScrollUpAmount + \"px\" });\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Repositions the bubbles following auto scrolling.\r\n\t * @param {object} oAnnotationItem - The annotation item.\r\n\t */\r\n\tAnnotation.prototype.scrollRepositionSpeechBubbles = function (oAnnotationItem) {\r\n\r\n\t\t// Reposition the speech bubbles.\r\n\t\tvar oArtworkCanvas = g_oViewer.getCanvas(oAnnotationItem.getAttribute(\"data-artworkcanvas\"));\r\n\t\tvar oAnnotationCanvas = oArtworkCanvas.g_oAnnotationCanvas;\r\n\t\toAnnotationCanvas.g_oContext.clearRect(0, 0, oAnnotationCanvas.g_oCanvas.width, oAnnotationCanvas.g_oCanvas.height);\r\n\t\tif (oArtworkCanvas.g_oDoc.documentType != eDocumentTypes.ThreeD) {\r\n\t\t\tg_oAnnotations.redrawAnnotations(oArtworkCanvas, oAnnotationCanvas);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tg_oAnnotations.redraw3DAnnotations(oArtworkCanvas, oAnnotationCanvas);\r\n\t\t}\r\n\t\tAnnotationUI.prototype.repositionSpeechBubbles(oArtworkCanvas, oAnnotationCanvas);\r\n\t};\r\n\r\n\t// Add the Annotation UI object to the window.\r\n\twindow.Annotation = Annotation;\r\n}());"]}