{"version":3,"sources":["../js/Annotations/AnnotationActions.js"],"names":["g_oAnnotationActions","AnnotationAction","this","g_oCursorMoveIcon","Image","src","g_oCursorMoveIconBlk","g_oDeleteIcon","g_oDeleteIcon90","g_oDeleteIcon180","g_oDeleteIcon270","g_oDeleteIconBlk","g_oDeleteIconBlk90","g_oDeleteIconBlk180","g_oDeleteIconBlk270","g_oNewAnnoIcon","g_oNewAnnoIconBlk","g_oAddTextIcon","g_oAddTextIcon90","g_oAddTextIcon180","g_oAddTextIcon270","g_oAddTextIconBlk","g_oAddTextIconBlk90","g_oAddTextIconBlk180","g_oAddTextIconBlk270","g_oRemoveTextIcon","g_oRemoveTextIcon90","g_oRemoveTextIcon180","g_oRemoveTextIcon270","g_oRemoveTextIconBlk","g_oRemoveTextIconBlk90","g_oRemoveTextIconBlk180","g_oRemoveTextIconBlk270","g_oAddParagraphIcon","g_oAddParagraphIcon90","g_oAddParagraphIcon180","g_oAddParagraphIcon270","g_oAddParagraphIconBlk","g_oAddParagraphIconBlk90","g_oAddParagraphIconBlk180","g_oAddParagraphIconBlk270","g_oAddAreaIcon","g_oAddAreaIcon90","g_oAddAreaIcon180","g_oAddAreaIcon270","g_oAddAreaIconBlk","g_oAddAreaIconBlk90","g_oAddAreaIconBlk180","g_oAddAreaIconBlk270","g_iAnnotationDragRectSize","g_oViewer","c_iDPI","g_oArtworkCanvas","g_oArtworkViewer","g_oAnnotationCanvas","getCanvas","g_oCompare","getAnnotationCanvasId","g_oAnnotation","g_iCompareRotation","g_iImageObjW","g_iImageObjH","g_iCenterShift_x","g_iCenterShift_y","g_iCompareOffset_x","g_iCompareOffset_y","g_iDragRectOffset","g_oAnnotationResizeHandleSize","prototype","initializeAnnotationAction","oAnnotation","getCompareRotation","g_iScaledImageHeight","g_iScaledImageWidth","co","calculateCompareOffsetInPx","x","y","createAnnotationHandle","g_bSaved","g_bMainCanvas","g_oAnnotations","g_bClosed","g_iAuthor","g_oUserDetails","UserId","g_iAnnotationType","g_bSVGTextAnnotation","eAnnotationTypes","Postit","oHandleCoords","calculateAnnotationHandleCoords","g_iRotDegrees","drawAnnotationHandle","g_szColour","g_iParentAnnotationId","oHandleCoords2","iHandleType","Object","keys","eAnnotationHandleTypes","parseInt","DeleteButton","CreateNewAnnotation","szColour","bDrawImage","oAnnoContext","oSize","calculateAnnotationHandleSize","oAnnotationContext","g_oContext","save","beginPath","fillStyle","strokeStyle","rect","closePath","fill","bBrightColor","eAnnotationColours","yellow","cyan","drawImage","DragRect","LeftResize","RightResize","TopResize","BottomResize","iRotDegrees","iHandleX","iHandleY","iMinX","iMinY","iMaxX","iMaxY","oAnnotationDrawArray","g_oDrawArray","concat","sort","sortAnnotationCoords","returnXMin","returnXMax","returnYMin","returnYMax","iOffset","AnnotationDragRectSize","iFactor","isclickWithinAnnotationAnyHandle","oClickCoords","g_oApproval","ReadOnly","Global","TextMeasurement","ColourDensityMeasurement","BarcodeMeasurement","ColourDensityMeasurementPostit","TextHighlight","TextClassification","isclickWithinAnnotationHandle","isPointInPath","handleHandler","oArtworkCanvas","oAnnotationCanvas","coords","payload","changeCanvasFunction","g_szPrevCursorStyle","tmp","szTextContent","g_oNewAnnotation","window","Annotation","g_iApprovalId","id","getNextAnnotationId","g_szAuthorEmail","EmailAddress","g_oAnnotationColSelected","deepCopyArray","g_oTempAnnotationArray","length","status","g_iDocumentId","g_oDoc","documentId","type","PointToPointMeasurement","Line","push","c_szMeasurementHeight","height","c_szMeasurementWidth","width","c_szMeasurementLength","lineLength","c_szMeasurementDegrees","degrees","g_szTextContent","join","AreaMeasurement","Rectangle","c_szMeasurementArea","area","i","g_oaImages","SeparationName","Math","round","separations","toFixed","barcodeMeasurements","DisplayText","X","Y","Width","Height","HorizontalCalliperMeasurement","VerticalCalliperMeasurement","$","isEmptyObject","pages","documentPageNumber","g_iCurrentPage","g_iDocumentPageId","documentPageId","g_iNumber","max","apply","g_oAnnotationsMade","map","o","createAnnotationDiv","eAnnotationDivType","Popup","createdDate","moment","utc","Date","ISO_8601","local","redrawAnnotations","dragDiscontinue","focus","shapeHandler","event","compareOffset_x","compareOffset_y","relatedArtworkCanvas","getClick","CanvasRenderingContext2D","isPointInStroke","transformClickForRotation","oAnnotationStack","getAnnotationStackCurrentPage","isAnnotationClosed","canvasCoords","findClickCanvasCoordinates","g_iOrigClickX","g_iOrigClickY","on","e","dragMouseUp","dragMouseMove","resizeDragMove","deleteAnnotation","click","css","mouseMove","annotationSaveShape","iOrigX","iOrigY","hide","iOffX","iOffY","oAnnotationCanvasObject","g_oCanvas","iNewX","iNewY","iOffXt","iOffYt","arrayCopy","bCanMoveX","bCanMoveY","g_oDrawCoordSetArray","xCoordinate","yCoordinate","clearRect","minXindex","minYindex","maxXindex","maxYindex","Freedraw","tCoords","isClickWithinImageBounds","applyFreedrawCoordChange","bHorizontal","bEndMost","iDistance","iCoordinate","iSize","bClear","iMult","mouseMoveLite","findAnnotation","target","handleClick","g_oTextCompare","g_bTextCompareInProgress","g_oTextTools","g_bHighlightInProgress","mouseMoveAnnotationHandles","handleData","handleType","mouseCoordinates","bMouseOverHandle","abs","handleX","handleY","mouseClickAnnotationHandles","annotationCoordinates","annotationData","off"],"mappings":"AAaA,IAAIA,qBAAuB,IAE1B,WACA,aAMA,SAASC,mBAGRC,KAAKC,kBAAoB,IAAIC,MAC7BF,KAAKC,kBAAkBE,IAAM,2BAC7BH,KAAKI,qBAAuB,IAAIF,MAChCF,KAAKI,qBAAqBD,IAAM,+BAGhCH,KAAKK,cAAgB,IAAIH,MACzBF,KAAKK,cAAcF,IAAM,wBACzBH,KAAKM,gBAAkB,IAAIJ,MAC3BF,KAAKM,gBAAgBH,IAAM,2BAC3BH,KAAKO,iBAAmB,IAAIL,MAC5BF,KAAKO,iBAAiBJ,IAAM,4BAC5BH,KAAKQ,iBAAmB,IAAIN,MAC5BF,KAAKQ,iBAAiBL,IAAM,4BAC5BH,KAAKS,iBAAmB,IAAIP,MAC5BF,KAAKS,iBAAiBN,IAAM,wBAC5BH,KAAKU,mB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791c25.js","sourcesContent":["/*\r\n * Copyright (c) 2018 SGS Europe. All rights reserved.\r\n *\r\n * This program is the CONFIDENTIAL and PROPRIETARY property of 2018 SGS Europe.\r\n * Any unauthorised use, reproduction, or transfer of this program is strictly\r\n * prohibited.\r\n *\r\n * File Name: AnnotationActions.js\r\n *\r\n * Description: JavaScript functions for all functionality accessed through the shape handles.\r\n *\r\n */\r\n\r\nvar g_oAnnotationActions = {};\r\n\r\n(function () {\r\n\t\"use strict\";\r\n\r\n\t/**\r\n\t * Prototype for our AnnotationActions object.\r\n\t * @class\r\n\t */\r\n\tfunction AnnotationAction() {\r\n\r\n\t\t// Move icons.\r\n\t\tthis.g_oCursorMoveIcon = new Image();\r\n\t\tthis.g_oCursorMoveIcon.src = \"img/cursor-move-icon.png\";\r\n\t\tthis.g_oCursorMoveIconBlk = new Image();\r\n\t\tthis.g_oCursorMoveIconBlk.src = \"img/cursor-move-icon_blk.png\";\r\n\r\n\t\t// Delete icons.\r\n\t\tthis.g_oDeleteIcon = new Image();\r\n\t\tthis.g_oDeleteIcon.src = \"img/Delete_wht_16.png\";\r\n\t\tthis.g_oDeleteIcon90 = new Image();\r\n\t\tthis.g_oDeleteIcon90.src = \"img/Delete_wht_16_90.png\";\r\n\t\tthis.g_oDeleteIcon180 = new Image();\r\n\t\tthis.g_oDeleteIcon180.src = \"img/Delete_wht_16_180.png\";\r\n\t\tthis.g_oDeleteIcon270 = new Image();\r\n\t\tthis.g_oDeleteIcon270.src = \"img/Delete_wht_16_270.png\";\r\n\t\tthis.g_oDeleteIconBlk = new Image();\r\n\t\tthis.g_oDeleteIconBlk.src = \"img/Delete_blk_16.png\";\r\n\t\tthis.g_oDeleteIconBlk90 = new Image();\r\n\t\tthis.g_oDeleteIconBlk90.src = \"img/Delete_blk_16_90.png\";\r\n\t\tthis.g_oDeleteIconBlk180 = new Image();\r\n\t\tthis.g_oDeleteIconBlk180.src = \"img/Delete_blk_16_180.png\";\r\n\t\tthis.g_oDeleteIconBlk270 = new Image();\r\n\t\tthis.g_oDeleteIconBlk270.src = \"img/Delete_blk_16_270.png\";\r\n\r\n\t\t// New annotation icons.\r\n\t\tthis.g_oNewAnnoIcon = new Image();\r\n\t\tthis.g_oNewAnnoIcon.src = \"img/Annotation_wht_16.png\";\r\n\t\tthis.g_oNewAnnoIconBlk = new Image();\r\n\t\tthis.g_oNewAnnoIconBlk.src = \"img/Annotation_blk_16.png\";\r\n\r\n\t\t// Add text icons.\r\n\t\tthis.g_oAddTextIcon = new Image();\r\n\t\tthis.g_oAddTextIcon.src = \"img/TextCursor_24 white.png\";\r\n\t\tthis.g_oAddTextIcon90 = new Image();\r\n\t\tthis.g_oAddTextIcon90.src = \"img/TextCursor_24 90 white.png\";\r\n\t\tthis.g_oAddTextIcon180 = new Image();\r\n\t\tthis.g_oAddTextIcon180.src = \"img/TextCursor_24 180 white.png\";\r\n\t\tthis.g_oAddTextIcon270 = new Image();\r\n\t\tthis.g_oAddTextIcon270.src = \"img/TextCursor_24 270 white.png\";\r\n\t\tthis.g_oAddTextIconBlk = new Image();\r\n\t\tthis.g_oAddTextIconBlk.src = \"img/TextCursor_24 black.png\";\r\n\t\tthis.g_oAddTextIconBlk90 = new Image();\r\n\t\tthis.g_oAddTextIconBlk90.src = \"img/TextCursor_24 90 black.png\";\r\n\t\tthis.g_oAddTextIconBlk180 = new Image();\r\n\t\tthis.g_oAddTextIconBlk180.src = \"img/TextCursor_24 180 black.png\";\r\n\t\tthis.g_oAddTextIconBlk270 = new Image();\r\n\t\tthis.g_oAddTextIconBlk270.src = \"img/TextCursor_24 270 black.png\";\r\n\r\n\t\t// Remove text icons.\r\n\t\tthis.g_oRemoveTextIcon = new Image();\r\n\t\tthis.g_oRemoveTextIcon.src = \"img/TextCursorRemove_24 white.png\";\r\n\t\tthis.g_oRemoveTextIcon90 = new Image();\r\n\t\tthis.g_oRemoveTextIcon90.src = \"img/TextCursorRemove_24 90 white.png\";\r\n\t\tthis.g_oRemoveTextIcon180 = new Image();\r\n\t\tthis.g_oRemoveTextIcon180.src = \"img/TextCursorRemove_24 180 white.png\";\r\n\t\tthis.g_oRemoveTextIcon270 = new Image();\r\n\t\tthis.g_oRemoveTextIcon270.src = \"img/TextCursorRemove_24 270 white.png\";\r\n\t\tthis.g_oRemoveTextIconBlk = new Image();\r\n\t\tthis.g_oRemoveTextIconBlk.src = \"img/TextCursorRemove_24 black.png\";\r\n\t\tthis.g_oRemoveTextIconBlk90 = new Image();\r\n\t\tthis.g_oRemoveTextIconBlk90.src = \"img/TextCursorRemove_24 90 black.png\";\r\n\t\tthis.g_oRemoveTextIconBlk180 = new Image();\r\n\t\tthis.g_oRemoveTextIconBlk180.src = \"img/TextCursorRemove_24 180 black.png\";\r\n\t\tthis.g_oRemoveTextIconBlk270 = new Image();\r\n\t\tthis.g_oRemoveTextIconBlk270.src = \"img/TextCursorRemove_24 270 black.png\";\r\n\r\n\t\t// Add paragraph icons.\r\n\t\tthis.g_oAddParagraphIcon = new Image();\r\n\t\tthis.g_oAddParagraphIcon.src = \"img/ParagraphCursor_24 white.png\";\r\n\t\tthis.g_oAddParagraphIcon90 = new Image();\r\n\t\tthis.g_oAddParagraphIcon90.src = \"img/ParagraphCursor_24 90 white.png\";\r\n\t\tthis.g_oAddParagraphIcon180 = new Image();\r\n\t\tthis.g_oAddParagraphIcon180.src = \"img/ParagraphCursor_24 180 white.png\";\r\n\t\tthis.g_oAddParagraphIcon270 = new Image();\r\n\t\tthis.g_oAddParagraphIcon270.src = \"img/ParagraphCursor_24 270 white.png\";\r\n\t\tthis.g_oAddParagraphIconBlk = new Image();\r\n\t\tthis.g_oAddParagraphIconBlk.src = \"img/ParagraphCursor_24 black.png\";\r\n\t\tthis.g_oAddParagraphIconBlk90 = new Image();\r\n\t\tthis.g_oAddParagraphIconBlk90.src = \"img/ParagraphCursor_24 90 black.png\";\r\n\t\tthis.g_oAddParagraphIconBlk180 = new Image();\r\n\t\tthis.g_oAddParagraphIconBlk180.src = \"img/ParagraphCursor_24 180 black.png\";\r\n\t\tthis.g_oAddParagraphIconBlk270 = new Image();\r\n\t\tthis.g_oAddParagraphIconBlk270.src = \"img/ParagraphCursor_24 270 black.png\";\r\n\r\n\t\t// Add area icons.\r\n\t\tthis.g_oAddAreaIcon = new Image();\r\n\t\tthis.g_oAddAreaIcon.src = \"img/AreaCursor_24 White.png\";\r\n\t\tthis.g_oAddAreaIcon90 = new Image();\r\n\t\tthis.g_oAddAreaIcon90.src = \"img/AreaCursor_24 90 White.png\";\r\n\t\tthis.g_oAddAreaIcon180 = new Image();\r\n\t\tthis.g_oAddAreaIcon180.src = \"img/AreaCursor_24 180 White.png\";\r\n\t\tthis.g_oAddAreaIcon270 = new Image();\r\n\t\tthis.g_oAddAreaIcon270.src = \"img/AreaCursor_24 270 White.png\";\r\n\t\tthis.g_oAddAreaIconBlk = new Image();\r\n\t\tthis.g_oAddAreaIconBlk.src = \"img/AreaCursor_24 black.png\";\r\n\t\tthis.g_oAddAreaIconBlk90 = new Image();\r\n\t\tthis.g_oAddAreaIconBlk90.src = \"img/AreaCursor_24 90 black.png\";\r\n\t\tthis.g_oAddAreaIconBlk180 = new Image();\r\n\t\tthis.g_oAddAreaIconBlk180.src = \"img/AreaCursor_24 180 black.png\";\r\n\t\tthis.g_oAddAreaIconBlk270 = new Image();\r\n\t\tthis.g_oAddAreaIconBlk270.src = \"img/AreaCursor_24 270 black.png\";\r\n\r\n\t\t// Set the annotation drag rectangle size.\r\n\t\tthis.g_iAnnotationDragRectSize = 20 * g_oViewer.c_iDPI;\r\n\r\n\t\t// Get the artwork canvas.\r\n\t\tthis.g_oArtworkCanvas = g_oViewer.g_oArtworkViewer;\r\n\r\n\t\t// Get the annotation canvas.\r\n\t\tthis.g_oAnnotationCanvas = g_oViewer.getCanvas(g_oCompare.getAnnotationCanvasId());\r\n\r\n\t\t// Set the canvas details.\r\n\t\tthis.g_oAnnotation = null;\r\n\t\tthis.g_iCompareRotation = 0;\r\n\t\tthis.g_iImageObjW = 0;\r\n\t\tthis.g_iImageObjH = 0;\r\n\t\tthis.g_iCenterShift_x = 0;\r\n\t\tthis.g_iCenterShift_y = 0;\r\n\t\tthis.g_iCompareOffset_x = 0;\r\n\t\tthis.g_iCompareOffset_y = 0;\r\n\t\tthis.g_iDragRectOffset = 10;\r\n\t\tthis.g_oAnnotationResizeHandleSize = [30 * g_oViewer.c_iDPI, 5 * g_oViewer.c_iDPI];\r\n\t}\r\n\r\n\t/**\r\n\t * Initializes the annotation\r\n\t * @param {any} oAnnotation - The annotation to initialize.\r\n\t */\r\n\tAnnotationAction.prototype.initializeAnnotationAction = function (oAnnotation) {\r\n\t\t// Set the canvases\r\n\t\tg_oAnnotationActions.g_oAnnotationCanvas = g_oViewer.getCanvas(g_oCompare.getAnnotationCanvasId());\r\n\t\tg_oAnnotationActions.g_oArtworkCanvas = g_oViewer.g_oArtworkViewer;\r\n\t\t// Get the compare rotation of the canvas.\r\n\t\tg_oAnnotationActions.g_iCompareRotation = g_oCompare.getCompareRotation(g_oAnnotationActions.g_oArtworkCanvas);\r\n\t\t// Get the height, width, shift and compare offset of the artwork canvas.\r\n\t\tg_oAnnotationActions.g_iImageObjW = (g_oAnnotationActions.g_iCompareRotation === 90 || g_oAnnotationActions.g_iCompareRotation === 270) ? g_oAnnotationActions.g_oArtworkCanvas.g_iScaledImageHeight : g_oAnnotationActions.g_oArtworkCanvas.g_iScaledImageWidth;\r\n\t\tg_oAnnotationActions.g_iImageObjH = (g_oAnnotationActions.g_iCompareRotation === 90 || g_oAnnotationActions.g_iCompareRotation === 270) ? g_oAnnotationActions.g_oArtworkCanvas.g_iScaledImageWidth : g_oAnnotationActions.g_oArtworkCanvas.g_iScaledImageHeight;\r\n\t\tg_oAnnotationActions.g_iCenterShift_x = g_oAnnotationActions.g_oArtworkCanvas.g_iCenterShift_x;\r\n\t\tg_oAnnotationActions.g_iCenterShift_y = g_oAnnotationActions.g_oArtworkCanvas.g_iCenterShift_y;\r\n\t\tvar co = g_oCompare.calculateCompareOffsetInPx(g_oAnnotationActions.g_oArtworkCanvas);\r\n\t\tg_oAnnotationActions.g_iCompareOffset_x = co.x;\r\n\t\tg_oAnnotationActions.g_iCompareOffset_y = co.y;\r\n\r\n\t\t// The annotation object\r\n\t\tg_oAnnotationActions.g_oAnnotation = oAnnotation;\r\n\r\n\t};\r\n\r\n\t/**\r\n\t * Creates all annotation handles applicable to the annotation.\r\n\t * @param {any} oAnnotation - The annotation to create the handles for.\r\n\t */\r\n\tAnnotationAction.prototype.createAnnotationHandle = function (oAnnotation) {\r\n\r\n\t\t// The annotation's drag handle will be created to the top and right of the annotation.\r\n\t\t// This will be irrespective of canvas rotation.\r\n\t\t// The drag rectangle will display north-east of the annotation itself, offset by 20px each way.\r\n\t\t// This way we don't get affected by zoom level.\r\n\r\n\t\tthis.initializeAnnotationAction(oAnnotation);\r\n\r\n\t\tif (!oAnnotation.g_bSaved || !this.g_oArtworkCanvas.g_bMainCanvas || (g_oAnnotations.g_oArtworkViewer.g_oAnnotationCanvas !== this.g_oAnnotationCanvas) || oAnnotation.g_bClosed || oAnnotation.g_iAuthor !== g_oUserDetails.UserId) { // If the current user doesn't have the permissions to edit the annotation or the annotation is closed.\r\n\t\t\treturn; // Avoid drawing any handles.\r\n\t\t}\r\n\r\n\t\t// Don't draw anything for text, colour density, barcode, SVG or global annotations.\r\n\t\tif (g_oAnnotationActions.g_oAnnotation.g_iAnnotationType === 5 ||\r\n\t\t\tg_oAnnotationActions.g_oAnnotation.g_iAnnotationType === 7 ||\r\n\t\t\tg_oAnnotationActions.g_oAnnotation.g_iAnnotationType === 12 ||\r\n\t\t\tg_oAnnotationActions.g_oAnnotation.g_iAnnotationType === 13 ||\r\n\t\t\tg_oAnnotationActions.g_oAnnotation.g_iAnnotationType === 14 ||\r\n\t\t\tg_oAnnotationActions.g_oAnnotation.g_bSVGTextAnnotation === true) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tif (oAnnotation.g_iAnnotationType === eAnnotationTypes.Postit) { // Do not draw resize handles for post-it notes\r\n\t\t\t// Calculate coordinates for the handle\r\n\t\t\tvar oHandleCoords = this.calculateAnnotationHandleCoords(g_oAnnotationActions.g_oArtworkCanvas.g_iRotDegrees, 0);\r\n\t\t\t// Draw annotation Drag Handle\r\n\t\t\tthis.drawAnnotationHandle(oHandleCoords, g_oAnnotationActions.g_oAnnotation.g_szColour, true, 0);\r\n\t\t\t// Draw annotation Delete handle if it's not the parent\r\n\t\t\tif (oAnnotation.g_iParentAnnotationId !== 0) {\r\n\t\t\t\tvar oHandleCoords2 = this.calculateAnnotationHandleCoords(g_oAnnotationActions.g_oArtworkCanvas.g_iRotDegrees, 1);\r\n\t\t\t\tthis.drawAnnotationHandle(oHandleCoords2, g_oAnnotationActions.g_oAnnotation.g_szColour, true, 1);\r\n\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\tfor (var iHandleType in Object.keys(eAnnotationHandleTypes)) {\r\n\t\t\t\tif (parseInt(iHandleType) == eAnnotationHandleTypes.DeleteButton && oAnnotation.g_iParentAnnotationId == 0 ||\r\n\t\t\t\t\tparseInt(iHandleType) == eAnnotationHandleTypes.CreateNewAnnotation) { // Don't draw the delete handle for parent shapes. Don't draw if it's the createNewAnnotation handle.\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\t// Calculate coordinates for the handle\r\n\t\t\t\t\tvar oHandleCoords = this.calculateAnnotationHandleCoords(g_oAnnotationActions.g_oArtworkCanvas.g_iRotDegrees, parseInt(iHandleType));\r\n\t\t\t\t\t// Draw annotation Handle\r\n\t\t\t\t\tthis.drawAnnotationHandle(oHandleCoords, g_oAnnotationActions.g_oAnnotation.g_szColour, true, parseInt(iHandleType));\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 * Draws the handle for the current annotation.\r\n\t * @param {array} oHandleCoords - Where to draw\r\n\t * @param {string} szColour - The colour to draw the background\r\n\t * @param {bool} bDrawImage - What image to use\r\n\t * @param {enum} iHandleType - What type of handle\r\n\t * @param {object} oAnnoContext - The current context of the annotation\r\n\t */\r\n\tAnnotationAction.prototype.drawAnnotationHandle = function (oHandleCoords, szColour, bDrawImage, iHandleType, oAnnoContext) {\r\n\t\tvar oSize = this.calculateAnnotationHandleSize(iHandleType);\r\n\t\tvar oAnnotationContext = typeof oAnnoContext === \"undefined\" ? g_oAnnotationActions.g_oAnnotationCanvas.g_oContext : oAnnoContext;\r\n\r\n\t\t// Draw handle\r\n\t\toAnnotationContext.save();\r\n\t\toAnnotationContext.beginPath();\r\n\t\toAnnotationContext.fillStyle = szColour;\r\n\t\toAnnotationContext.strokeStyle = szColour;\r\n\t\toAnnotationContext.rect(oHandleCoords[0], oHandleCoords[1], oSize[0], oSize[1]);\r\n\t\toAnnotationContext.closePath();\r\n\t\toAnnotationContext.fill();\r\n\r\n\t\tvar bBrightColor = szColour === eAnnotationColours.yellow || szColour === eAnnotationColours.cyan;\r\n\r\n\t\tif (bDrawImage) {\r\n\t\t\tswitch (iHandleType) {\r\n\t\t\t\tcase eAnnotationHandleTypes.CreateNewAnnotation:\r\n\t\t\t\t\toAnnotationContext.drawImage(bBrightColor ? g_oAnnotationActions.g_oNewAnnoIconBlk : g_oAnnotationActions.g_oNewAnnoIcon, oHandleCoords[0] + 2, oHandleCoords[1] + 2, oSize[0] - 4, oSize[1] - 4);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase eAnnotationHandleTypes.DragRect:\r\n\t\t\t\t\toAnnotationContext.drawImage(bBrightColor ? g_oAnnotationActions.g_oCursorMoveIconBlk : g_oAnnotationActions.g_oCursorMoveIcon, oHandleCoords[0] + 2, oHandleCoords[1] + 2, oSize[0] - 4, oSize[1] - 4);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase eAnnotationHandleTypes.LeftResize:\r\n\t\t\t\tcase eAnnotationHandleTypes.RightResize:\r\n\t\t\t\tcase eAnnotationHandleTypes.TopResize:\r\n\t\t\t\tcase eAnnotationHandleTypes.BottomResize:\r\n\t\t\t\t\toAnnotationContext.beginPath();\r\n\t\t\t\t\toAnnotationContext.rect(oHandleCoords[0] + 1, oHandleCoords[1] + 1, oSize[0] - 2, oSize[1] - 2);\r\n\t\t\t\t\toAnnotationContext.closePath();\r\n\t\t\t\t\toAnnotationContext.fillStyle = bBrightColor ? \"rgba(0,0,0,0.4875)\" : \"rgba(255,255,255,0.75)\";\r\n\t\t\t\t\toAnnotationContext.fill();\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase eAnnotationHandleTypes.DeleteButton:\r\n\t\t\t\t\tswitch (g_oAnnotationActions.g_oArtworkCanvas.g_iRotDegrees) {\r\n\t\t\t\t\t\tcase 90:\r\n\t\t\t\t\t\t\toAnnotationContext.drawImage(bBrightColor ? g_oAnnotationActions.g_oDeleteIconBlk270 : g_oAnnotationActions.g_oDeleteIcon270, oHandleCoords[0] + 1, oHandleCoords[1] + 1, oSize[0] - 2, oSize[1] - 2);\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\tcase 180:\r\n\t\t\t\t\t\t\toAnnotationContext.drawImage(bBrightColor ? g_oAnnotationActions.g_oDeleteIconBlk180 : g_oAnnotationActions.g_oDeleteIcon180, oHandleCoords[0] + 1, oHandleCoords[1] + 1, oSize[0] - 2, oSize[1] - 2);\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\tcase 270:\r\n\t\t\t\t\t\t\toAnnotationContext.drawImage(bBrightColor ? g_oAnnotationActions.g_oDeleteIconBlk90 : g_oAnnotationActions.g_oDeleteIcon90, oHandleCoords[0] + 1, oHandleCoords[1] + 1, oSize[0] - 2, oSize[1] - 2);\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\tdefault:\r\n\t\t\t\t\t\t\toAnnotationContext.drawImage(bBrightColor ? g_oAnnotationActions.g_oDeleteIconBlk : g_oAnnotationActions.g_oDeleteIcon, oHandleCoords[0] + 1, oHandleCoords[1] + 1, oSize[0] - 2, oSize[1] - 2);\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\t};\r\n\r\n\t/**\r\n\t * Calculate handle size based on type.\r\n\t * @param {enum} iHandleType - Type of handle.\r\n\t */\r\n\tAnnotationAction.prototype.calculateAnnotationHandleSize = function (iHandleType) {\r\n\t\tswitch (iHandleType) {\r\n\t\t\tcase eAnnotationHandleTypes.CreateNewAnnotation:\r\n\t\t\tcase eAnnotationHandleTypes.DragRect:\r\n\t\t\tcase eAnnotationHandleTypes.DeleteButton:\r\n\t\t\t\treturn [g_oAnnotationActions.g_iAnnotationDragRectSize, g_oAnnotationActions.g_iAnnotationDragRectSize];\r\n\t\t\tcase eAnnotationHandleTypes.LeftResize:\r\n\t\t\tcase eAnnotationHandleTypes.RightResize:\r\n\t\t\t\treturn [g_oAnnotationActions.g_oAnnotationResizeHandleSize[1], g_oAnnotationActions.g_oAnnotationResizeHandleSize[0]];\r\n\t\t\tcase eAnnotationHandleTypes.TopResize:\r\n\t\t\tcase eAnnotationHandleTypes.BottomResize:\r\n\t\t\t\treturn [g_oAnnotationActions.g_oAnnotationResizeHandleSize[0], g_oAnnotationActions.g_oAnnotationResizeHandleSize[1]];\r\n\t\t\tdefault:\r\n\t\t\t\treturn [0, 0];\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Calculate the canvas annotation handle coordinates based on the handle type and the rotation.\r\n\t * @param {int} iRotDegrees - Current rotation of the canvas.\r\n\t * @param {enum} iHandleType - Type of handle.\r\n\t */\r\n\tAnnotationAction.prototype.calculateAnnotationHandleCoords = function (iRotDegrees, iHandleType) {\r\n\r\n\t\tvar iHandleX, iHandleY, iMinX, iMinY, iMaxX, iMaxY;\r\n\t\tvar oAnnotationDrawArray = g_oAnnotationActions.g_oAnnotation.g_oDrawArray;\r\n\t\tvar oSize = g_oAnnotationActions.calculateAnnotationHandleSize(iHandleType);\r\n\r\n\t\t// Work out bounds of shape\r\n\t\tiMinX = oAnnotationDrawArray.concat().sort(sortAnnotationCoords.returnXMin)[0][0];\r\n\t\tiMaxX = oAnnotationDrawArray.concat().sort(sortAnnotationCoords.returnXMax)[0][0];\r\n\t\tiMinY = oAnnotationDrawArray.concat().sort(sortAnnotationCoords.returnYMin)[0][1];\r\n\t\tiMaxY = oAnnotationDrawArray.concat().sort(sortAnnotationCoords.returnYMax)[0][1];\r\n\r\n\t\tswitch (iHandleType) {\r\n\t\t\tcase eAnnotationHandleTypes.CreateNewAnnotation:\r\n\t\t\tcase eAnnotationHandleTypes.DragRect:\r\n\t\t\tcase eAnnotationHandleTypes.DeleteButton:\r\n\t\t\t\tvar iOffset = (iHandleType == eAnnotationHandleTypes.DeleteButton) ? g_oAnnotationActions.g_iDragRectOffset * 2 + oSize[0] : g_oAnnotationActions.g_iDragRectOffset;\r\n\t\t\t\tswitch (iRotDegrees) {\r\n\t\t\t\t\tcase 90:\r\n\t\t\t\t\t\t// min of x. min of y.\r\n\t\t\t\t\t\tiHandleX = iMinX * g_oAnnotationActions.g_iImageObjW;\r\n\t\t\t\t\t\tiHandleY = (iMinY * g_oAnnotationActions.g_iImageObjH) - oSize[1] - iOffset;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 180:\r\n\t\t\t\t\t\t// Min of x. Max of y.\r\n\t\t\t\t\t\tiHandleX = (iMinX * g_oAnnotationActions.g_iImageObjW) - oSize[0] - iOffset;\r\n\t\t\t\t\t\tiHandleY = (iMaxY * g_oAnnotationActions.g_iImageObjH) - oSize[1];\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 270:\r\n\t\t\t\t\t\t// max of x. max of y.\r\n\t\t\t\t\t\tiHandleX = iMaxX * g_oAnnotationActions.g_iImageObjW - oSize[0];\r\n\t\t\t\t\t\tiHandleY = iMaxY * g_oAnnotationActions.g_iImageObjH + iOffset;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tdefault:\r\n\t\t\t\t\t\t// Max of X. Min of y.\r\n\t\t\t\t\t\tiHandleX = iMaxX * g_oAnnotationActions.g_iImageObjW + iOffset;\r\n\t\t\t\t\t\tiHandleY = iMinY * g_oAnnotationActions.g_iImageObjH;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase eAnnotationHandleTypes.LeftResize:\r\n\t\t\t\tiHandleX = iMinX * g_oAnnotationActions.g_iImageObjW;\r\n\t\t\t\tiHandleX -= oSize[0] / 2;\r\n\t\t\t\tiHandleY = iMinY * g_oAnnotationActions.g_iImageObjH;\r\n\t\t\t\tiHandleY += (iMaxY - iMinY) / 2 * g_oAnnotationActions.g_iImageObjH;\r\n\t\t\t\tiHandleY -= oSize[1] / 2;\r\n\t\t\t\tbreak;\r\n\t\t\tcase eAnnotationHandleTypes.RightResize:\r\n\t\t\t\tiHandleX = iMaxX * g_oAnnotationActions.g_iImageObjW;\r\n\t\t\t\tiHandleX -= oSize[0] / 2;\r\n\t\t\t\tiHandleY = iMinY * g_oAnnotationActions.g_iImageObjH;\r\n\t\t\t\tiHandleY += (iMaxY - iMinY) / 2 * g_oAnnotationActions.g_iImageObjH;\r\n\t\t\t\tiHandleY -= oSize[1] / 2;\r\n\t\t\t\tbreak;\r\n\t\t\tcase eAnnotationHandleTypes.TopResize:\r\n\t\t\t\tiHandleX = iMinX * g_oAnnotationActions.g_iImageObjW;\r\n\t\t\t\tiHandleX += (iMaxX - iMinX) / 2 * g_oAnnotationActions.g_iImageObjW;\r\n\t\t\t\tiHandleX -= oSize[0] / 2;\r\n\t\t\t\tiHandleY = iMinY * g_oAnnotationActions.g_iImageObjH;\r\n\t\t\t\tiHandleY -= oSize[1] / 2;\r\n\t\t\t\tbreak;\r\n\t\t\tcase eAnnotationHandleTypes.BottomResize:\r\n\t\t\t\tiHandleX = iMinX * g_oAnnotationActions.g_iImageObjW;\r\n\t\t\t\tiHandleX += (iMaxX - iMinX) / 2 * g_oAnnotationActions.g_iImageObjW;\r\n\t\t\t\tiHandleX -= oSize[0] / 2;\r\n\t\t\t\tiHandleY = iMaxY * g_oAnnotationActions.g_iImageObjH;\r\n\t\t\t\tiHandleY -= oSize[1] / 2;\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\t// Post it note is drawn with different offsets as it is an image.\r\n\t\tif (g_oAnnotationActions.g_oAnnotation.g_iAnnotationType === eAnnotationTypes.Postit) {\r\n\t\t\tvar heightOffset = 13;\r\n\t\t\tvar widthOffset = 3;\r\n\t\t\tvar AnnotationDragRectSize = g_oAnnotationActions.g_iAnnotationDragRectSize;\r\n\t\t\tvar iFactor = (iHandleType == eAnnotationHandleTypes.DeleteButton) ? g_oAnnotationActions.g_iDragRectOffset + AnnotationDragRectSize : 0;\r\n\t\t\tvar x = oAnnotationDrawArray[0][0] * g_oAnnotationActions.g_iImageObjW - widthOffset;\r\n\t\t\tvar y = oAnnotationDrawArray[0][1] * g_oAnnotationActions.g_iImageObjH - heightOffset;\r\n\t\t\tswitch (iRotDegrees) {\r\n\t\t\t\tcase 90:\r\n\t\t\t\t\tiHandleX = x - AnnotationDragRectSize;\r\n\t\t\t\t\tiHandleY = y - (AnnotationDragRectSize + iFactor);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 180:\r\n\t\t\t\t\tiHandleX = x - (AnnotationDragRectSize + iFactor);\r\n\t\t\t\t\tiHandleY = y + AnnotationDragRectSize;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 270:\r\n\t\t\t\t\tiHandleX = x + AnnotationDragRectSize;\r\n\t\t\t\t\tiHandleY = y + (AnnotationDragRectSize + iFactor);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tiHandleX = x + (AnnotationDragRectSize + iFactor);\r\n\t\t\t\t\tiHandleY = y - AnnotationDragRectSize;\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tiHandleX += g_oAnnotationActions.g_iCenterShift_x;\r\n\t\tiHandleY += g_oAnnotationActions.g_iCenterShift_y;\r\n\t\tiHandleX += g_oAnnotationActions.g_iCompareOffset_x;\r\n\t\tiHandleY += g_oAnnotationActions.g_iCompareOffset_y;\r\n\r\n\t\treturn [iHandleX, iHandleY];\r\n\t};\r\n\r\n\t// Checks if the user click coordinates are within any of the handles of the annotation.\r\n\tAnnotationAction.prototype.isclickWithinAnnotationAnyHandle = function (oClickCoords, oAnnotation) {\r\n\r\n\t\t// If the annotation is open and the user has permissions to edit it and it's not a TextMeasurement/TextHighlight/ColourDensity/Barcode/Global/SVG annotation.\r\n\t\tif (!g_oApproval.ReadOnly() && this.g_oArtworkCanvas.g_bMainCanvas && !oAnnotation.g_bClosed && (oAnnotation.g_iAuthor === g_oUserDetails.UserId)\r\n\t\t\t&& oAnnotation.g_iAnnotationType !== eAnnotationTypes.Global && oAnnotation.g_iAnnotationType !== eAnnotationTypes.TextMeasurement && oAnnotation.g_iAnnotationType !== eAnnotationTypes.ColourDensityMeasurement &&\r\n\t\t\toAnnotation.g_iAnnotationType !== eAnnotationTypes.BarcodeMeasurement && oAnnotation.g_iAnnotationType !== eAnnotationTypes.ColourDensityMeasurementPostit &&\r\n\t\t\toAnnotation.g_iAnnotationType !== eAnnotationTypes.TextHighlight && oAnnotation.g_iAnnotationType !== eAnnotationTypes.TextClassification && oAnnotation.g_bSVGTextAnnotation === false) {\r\n\r\n\t\t\t// Initialise the annotation action.\r\n\t\t\tthis.initializeAnnotationAction(oAnnotation);\r\n\t\t\tfor (var iHandleType in Object.keys(eAnnotationHandleTypes)) {\r\n\r\n\t\t\t\t// If it's the parent shape, ignore the delete button.\r\n\t\t\t\tif ((oAnnotation.g_iParentAnnotationId == 0 && iHandleType == eAnnotationHandleTypes.DeleteButton) || (oAnnotation.g_iAnnotationType === eAnnotationTypes.Postit && (iHandleType != eAnnotationHandleTypes.DragRect && iHandleType != eAnnotationHandleTypes.DeleteButton))) {\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\t\t\t\tvar bHitDetected = this.isclickWithinAnnotationHandle(oClickCoords, g_oAnnotationActions.g_oArtworkCanvas.g_iRotDegrees, parseInt(iHandleType));\r\n\t\t\t\tif (bHitDetected) {\r\n\t\t\t\t\treturn parseInt(iHandleType);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn -1;\r\n\t};\r\n\r\n\t// Check if the user click coordinates are within the handles coordinates on the annotation.\r\n\tAnnotationAction.prototype.isclickWithinAnnotationHandle = function (oClickCoords, iRotDegrees, iHandleType) {\r\n\t\tvar oAnnotationContext = g_oAnnotationActions.g_oAnnotationCanvas.g_oContext;\r\n\r\n\t\tvar oHandleCoords = this.calculateAnnotationHandleCoords(iRotDegrees, iHandleType);\r\n\t\tthis.drawAnnotationHandle(oHandleCoords, \"rgba(0,0,0,0)\", false, iHandleType);\r\n\t\treturn oAnnotationContext.isPointInPath(oClickCoords[0], oClickCoords[1]);\r\n\t};\r\n\r\n\t/**\r\n\t * To be used when working with a handler that isn't attached to a shape, like when a shape isn't saved yet for example.\r\n\t * @param {object} oArtworkCanvas - The artwork canvas.\r\n\t * @param {object} oAnnotationCanvas - The annotation canvas.\r\n\t * @param {enum} iHandleType - The handle that was clicked.\r\n\t * @param {double} coords - The coordinates of the marquee.\r\n\t * @param {object} payload - The information about the annotation.\r\n\t */\r\n\tAnnotationAction.prototype.handleHandler = function (oArtworkCanvas, oAnnotationCanvas, iHandleType, coords, payload) {\r\n\r\n\t\t// Determine the handle type.\r\n\t\tswitch (iHandleType) {\r\n\t\t\tcase eAnnotationHandleTypes.CreateNewAnnotation:\r\n\t\t\t\t// Clear all bindings.\r\n\t\t\t\tchangeCanvasFunction(\"#AnnotationViewer\");\r\n\t\t\t\tg_oAnnotations.g_szPrevCursorStyle = \"default\";\r\n\r\n\t\t\t\tvar tmp = coords;\r\n\t\t\t\tvar szTextContent = [];\r\n\r\n\t\t\t\t// Set up the new annotation.\r\n\t\t\t\tvar g_oNewAnnotation = new window.Annotation(g_oAnnotations.g_iApprovalId);\r\n\t\t\t\tg_oNewAnnotation.id = g_oAnnotations.getNextAnnotationId();\r\n\t\t\t\tg_oNewAnnotation.g_iAuthor = g_oUserDetails.UserId;\r\n\t\t\t\tg_oNewAnnotation.g_szAuthorEmail = g_oUserDetails.EmailAddress;\r\n\t\t\t\tg_oNewAnnotation.g_szColour = g_oAnnotations.g_oAnnotationColSelected;\r\n\t\t\t\tg_oNewAnnotation.g_oDrawArray = deepCopyArray(tmp);\t\t// Deep copy of the array.\r\n\t\t\t\tg_oAnnotations.g_oTempAnnotationArray.length = 0;\t\t// Clear out the temp array now that we've copied the contents.\r\n\r\n\t\t\t\tg_oNewAnnotation.status = \"a\";\r\n\t\t\t\tg_oNewAnnotation.g_iDocumentId = oArtworkCanvas.g_oDoc.documentId;\r\n\r\n\t\t\t\t// Populate new annotation text box with the payload contents & set annotation type\r\n\t\t\t\tswitch (payload.type) {\r\n\t\t\t\t\tcase eAnnotationTypes.PointToPointMeasurement:\r\n\t\t\t\t\t\tg_oNewAnnotation.g_iAnnotationType = eAnnotationTypes.Line;\r\n\t\t\t\t\t\tszTextContent.push(g_oAnnotations.c_szMeasurementHeight, \": \", payload.height, \"
\", g_oAnnotations.c_szMeasurementWidth, \": \", payload.width, \"
\",\r\n\t\t\t\t\t\t\tg_oAnnotations.c_szMeasurementLength, \": \", payload.lineLength, \"
\", g_oAnnotations.c_szMeasurementDegrees, \": \", payload.degrees, \"
\");\r\n\t\t\t\t\t\tg_oNewAnnotation.g_szTextContent = szTextContent.join(\"\");\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase eAnnotationTypes.AreaMeasurement:\r\n\t\t\t\t\t\tg_oNewAnnotation.g_iAnnotationType = eAnnotationTypes.Rectangle;\r\n\t\t\t\t\t\tszTextContent.push(g_oAnnotations.c_szMeasurementHeight, \": \", payload.height, \"
\", g_oAnnotations.c_szMeasurementWidth, \": \", payload.width, \"
\",\r\n\t\t\t\t\t\t\tg_oAnnotations.c_szMeasurementArea, \": \", payload.area, \"
\");\r\n\t\t\t\t\t\tg_oNewAnnotation.g_szTextContent = szTextContent.join(\"\");\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase eAnnotationTypes.ColourDensityMeasurement:\r\n\t\t\t\t\t\t// Set the type to post-it if the mouse didn't move.\r\n\t\t\t\t\t\tg_oNewAnnotation.g_iAnnotationType = (coords[0][0] === coords[1][0] || coords[0][1] === coords[1][1]) ? eAnnotationTypes.ColourDensityMeasurementPostit : eAnnotationTypes.ColourDensityMeasurement;\r\n\t\t\t\t\t\tfor (var i = 0; i < g_oViewer.g_oArtworkViewer.g_oaImages.length; i++) {\r\n\t\t\t\t\t\t\tszTextContent.push(g_oViewer.g_oArtworkViewer.g_oaImages[i].SeparationName, \": \", (Math.round((1 - ((parseInt(payload.separations[g_oViewer.g_oArtworkViewer.g_oaImages[i].SeparationName][0])) / 255)) * 10000) / 100).toFixed(0), \"%\", \"
\");\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tg_oNewAnnotation.g_szTextContent = szTextContent.join(\"\");\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase eAnnotationTypes.BarcodeMeasurement:\r\n\t\t\t\t\t\tg_oNewAnnotation.g_iAnnotationType = eAnnotationTypes.BarcodeMeasurement;\r\n\t\t\t\t\t\tg_oNewAnnotation.g_szTextContent = payload.barcodeMeasurements[0].DisplayText;\r\n\t\t\t\t\t\tg_oNewAnnotation.g_oDrawArray = [[payload.barcodeMeasurements[0].X, payload.barcodeMeasurements[0].Y], [payload.barcodeMeasurements[0].X + payload.barcodeMeasurements[0].Width, payload.barcodeMeasurements[0].Y + payload.barcodeMeasurements[0].Height]];\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase eAnnotationTypes.TextMeasurement:\r\n\t\t\t\t\tcase eAnnotationTypes.TextHighlight:\r\n\t\t\t\t\tcase eAnnotationTypes.TextClassification:\r\n\t\t\t\t\tcase eAnnotationTypes.HorizontalCalliperMeasurement:\r\n\t\t\t\t\tcase eAnnotationTypes.VerticalCalliperMeasurement:\r\n\t\t\t\t\tdefault:\r\n\t\t\t\t\t\tg_oNewAnnotation.g_iAnnotationType = eAnnotationTypes.Rectangle;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// If we have more than one page, grab the page id by looping through the pages.\r\n\t\t\t\tif (!$.isEmptyObject(oArtworkCanvas.g_oDoc.pages)) {\r\n\t\t\t\t\tfor (var i = 0; i < oArtworkCanvas.g_oDoc.pages.length; i++) {\r\n\t\t\t\t\t\tif (oArtworkCanvas.g_oDoc.pages[i].documentPageNumber == oArtworkCanvas.g_iCurrentPage) {\r\n\t\t\t\t\t\t\tg_oNewAnnotation.g_iDocumentPageId = oArtworkCanvas.g_oDoc.pages[i].documentPageId;\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tg_oNewAnnotation.g_iParentAnnotationId = 0;\r\n\r\n\t\t\t\t// Find max annotation number and add 1. We have our new annotation number\r\n\t\t\t\t// If there are no annotations we must do a max of the result or 1. Otherwise -infinity is returned\r\n\t\t\t\t// Which actually evaluates to isNaN = false!\r\n\t\t\t\tg_oNewAnnotation.g_iNumber = Math.max(1, Math.max.apply(Math, g_oAnnotations.g_oAnnotationsMade.map(function (o) { return o.g_iNumber; })) + 1);\r\n\r\n\t\t\t\t// Push the new annotation into the Annotations made Array\r\n\t\t\t\tg_oAnnotations.g_oAnnotationsMade.push(g_oNewAnnotation);\r\n\t\t\t\tg_oNewAnnotation.createAnnotationDiv(eAnnotationDivType.Popup, true, null, oArtworkCanvas, oAnnotationCanvas);\r\n\r\n\t\t\t\tif (g_oNewAnnotation) {\r\n\t\t\t\t\tg_oNewAnnotation.createdDate = moment.utc(new Date(), moment.ISO_8601).local();\r\n\t\t\t\t}\r\n\r\n\t\t\t\t//$(\"#divTechToolsClearCanvas\").click();\r\n\t\t\t\tg_oAnnotations.redrawAnnotations(oArtworkCanvas, oAnnotationCanvas);\r\n\r\n\t\t\t\t//changeCanvasFunction();\r\n\t\t\t\toAnnotationCanvas.dragDiscontinue(false, []);\r\n\t\t\t\t$(\".jqte_editor\").focus();\r\n\t\t\t\tbreak;\r\n\t\t\tcase eAnnotationHandleTypes.DragRect:\r\n\t\t\tcase eAnnotationHandleTypes.LeftResize:\r\n\t\t\tcase eAnnotationHandleTypes.RightResize:\r\n\t\t\tcase eAnnotationHandleTypes.TopResize:\r\n\t\t\tcase eAnnotationHandleTypes.BottomResize:\r\n\t\t\tcase eAnnotationHandleTypes.DeleteButton:\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\treturn;\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Handles any functionality determined with clicking on the handles.\r\n\t * @param {event} event - The event\r\n\t * @param {object} oArtworkCanvas - The artwork canvas\r\n\t * @param {object} oAnnotationCanvas - The annotation canvas\r\n\t * @param {object} oAnnotation - The annotation in question\r\n\t * @param {enum} iHandleType - The type of handle\r\n\t */\r\n\tAnnotationAction.prototype.shapeHandler = function (event, oArtworkCanvas, oAnnotationCanvas, oAnnotation, iHandleType) {\r\n\t\tvar compareOffset_x, compareOffset_y;\r\n\t\tvar co = g_oCompare.calculateCompareOffsetInPx(oArtworkCanvas);\r\n\t\tcompareOffset_x = co.x;\r\n\t\tcompareOffset_y = co.y;\r\n\r\n\t\tvar relatedArtworkCanvas = oArtworkCanvas;\r\n\r\n\t\tvar coords = g_oAnnotations.getClick(event, relatedArtworkCanvas);\r\n\t\tif (typeof CanvasRenderingContext2D.prototype.isPointInStroke === \"undefined\") {\r\n\t\t\tcoords = g_oAnnotations.transformClickForRotation(coords[0], coords[1], relatedArtworkCanvas);\r\n\t\t\tcoords[0] += relatedArtworkCanvas.g_iCenterShift_x + compareOffset_x;\r\n\t\t\tcoords[1] += relatedArtworkCanvas.g_iCenterShift_y + compareOffset_y;\r\n\t\t}\r\n\r\n\t\tvar oAnnotationStack = g_oAnnotations.getAnnotationStackCurrentPage(oArtworkCanvas);\r\n\t\tif (!g_oAnnotations.isAnnotationClosed(oAnnotation, oAnnotationStack)) {\r\n\t\t\t// Setup events for annotation actions.\r\n\t\t\tif (iHandleType > -1) {\r\n\t\t\t\tswitch (iHandleType) {\r\n\t\t\t\t\tcase eAnnotationHandleTypes.DragRect:\r\n\t\t\t\t\t\tvar canvasCoords = findClickCanvasCoordinates(event, oArtworkCanvas, g_oAnnotations);\r\n\r\n\t\t\t\t\t\tg_oAnnotations.g_iOrigClickX = canvasCoords[0];\r\n\t\t\t\t\t\tg_oAnnotations.g_iOrigClickY = canvasCoords[1];\r\n\r\n\t\t\t\t\t\tchangeCanvasFunction(\"#AnnotationViewer\"); // Clear all bindings\r\n\t\t\t\t\t\t$('#AnnotationViewer').on(\"pointerup.annotationUI\", function (e) {\r\n\t\t\t\t\t\t\tg_oAnnotationActions.dragMouseUp(oAnnotation, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t\t$('#AnnotationViewer').on(\"pointermove.annotationUI\", function (e) {\r\n\t\t\t\t\t\t\tg_oAnnotationActions.dragMouseMove(oAnnotation, e, oArtworkCanvas, g_oAnnotations.g_iOrigClickX, g_oAnnotations.g_iOrigClickY);\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\tcase eAnnotationHandleTypes.BottomResize:\r\n\t\t\t\t\tcase eAnnotationHandleTypes.TopResize:\r\n\t\t\t\t\tcase eAnnotationHandleTypes.LeftResize:\r\n\t\t\t\t\tcase eAnnotationHandleTypes.RightResize:\r\n\t\t\t\t\t\tvar canvasCoords = findClickCanvasCoordinates(event, oArtworkCanvas, g_oAnnotations);\r\n\r\n\t\t\t\t\t\tg_oAnnotations.g_iOrigClickX = canvasCoords[0];\r\n\t\t\t\t\t\tg_oAnnotations.g_iOrigClickY = canvasCoords[1];\r\n\r\n\t\t\t\t\t\tchangeCanvasFunction(\"#AnnotationViewer\"); // Clear all bindings\r\n\t\t\t\t\t\t$('#AnnotationViewer').on(\"pointerup.annotationUI\", function (e) {\r\n\t\t\t\t\t\t\tg_oAnnotationActions.dragMouseUp(oAnnotation, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t\t$('#AnnotationViewer').on(\"pointermove.annotationUI\", function (e) {\r\n\t\t\t\t\t\t\tg_oAnnotationActions.resizeDragMove(oAnnotation, e, oArtworkCanvas, oAnnotationCanvas, g_oAnnotations.g_iOrigClickX, g_oAnnotations.g_iOrigClickY, iHandleType);\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\tcase eAnnotationHandleTypes.DeleteButton:\r\n\t\t\t\t\t\tg_oAnnotations.deleteAnnotation(oAnnotation.id, oAnnotationStack, false, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t\t\tg_oAnnotations.redrawAnnotations(oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t\t\t\t$(\"#divTechToolsClearCanvas\").click();\r\n\t\t\t\t\t\t$(\"#AnnotationViewer\").css(\"cursor\", \"default\");\r\n\t\t\t\t\t\tg_oAnnotations.g_szPrevCursorStyle = \"default\";\r\n\t\t\t\t\t\tchangeCanvasFunction('#AnnotationViewer', \"pointermove.annotationUI\", function (e) { g_oAnnotationActions.mouseMove(e, oArtworkCanvas, oAnnotationCanvas); });\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tdefault:\r\n\t\t\t\t\t\tbreak;\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 * Mouse/Pointer release event when dragging the annotations with their handles.\r\n\t * @param {object} oAnnotation - The annotation being dragged.\r\n\t * @param {object} oArtworkCanvas - The artwork canvas.\r\n\t * @param {object} oAnnotationCanvas - The annotation canvas.\r\n\t */\r\n\tAnnotationAction.prototype.dragMouseUp = function (oAnnotation, oArtworkCanvas, oAnnotationCanvas) {\r\n\t\t$('#AnnotationViewer').css(\"cursor\", \"default\");\r\n\t\tchangeCanvasFunction();\r\n\t\toAnnotation.annotationSaveShape(oAnnotationCanvas, true);\r\n\t\tg_oAnnotations.redrawAnnotations(oArtworkCanvas, oAnnotationCanvas);\r\n\t};\r\n\r\n\t/**\r\n\t * Handles the moving of annotations via the move handle.\r\n\t * @param {object} oAnnotation - The annotation being dragged.\r\n\t * @param {event} e - The event.\r\n\t * @param {object} oArtworkCanvas - The artwork canvas.\r\n\t * @param {double} iOrigX - The Old X coordinate.\r\n\t * @param {double} iOrigY - THe Old Y coordinate.\r\n\t */\r\n\tAnnotationAction.prototype.dragMouseMove = function (oAnnotation, e, oArtworkCanvas, iOrigX, iOrigY) {\r\n\t\t$('.speechbubble').hide();\r\n\t\tvar oAnnotationCanvasObject = this.g_oAnnotationCanvas.g_oCanvas;\r\n\t\tvar coords = findClickCanvasCoordinates(e, oArtworkCanvas, g_oAnnotations);\r\n\r\n\t\tvar iNewX = coords[0];\r\n\t\tvar iNewY = coords[1];\r\n\r\n\t\tg_oAnnotations.g_iOrigClickX = iNewX;\r\n\t\tg_oAnnotations.g_iOrigClickY = iNewY;\r\n\r\n\t\tvar iOffXt = iNewX - iOrigX;\r\n\t\tvar iOffYt = iNewY - iOrigY;\r\n\t\tvar iOffX;\r\n\t\tvar iOffY;\r\n\t\tswitch (oArtworkCanvas.g_iRotDegrees) {\r\n\t\t\tcase 90:\r\n\t\t\t\tiOffX = iOffYt;\r\n\t\t\t\tiOffY = iOffXt * -1;\r\n\t\t\t\tbreak;\r\n\t\t\tcase 180:\r\n\t\t\t\tiOffX = iOffXt * -1;\r\n\t\t\t\tiOffY = iOffYt * -1;\r\n\t\t\t\tbreak;\r\n\t\t\tcase 270:\r\n\t\t\t\tiOffX = iOffYt * -1;\r\n\t\t\t\tiOffY = iOffXt;\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tiOffX = iOffXt;\r\n\t\t\t\tiOffY = iOffYt;\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t\t// Create a copy of the array\r\n\t\tvar arrayCopy = deepCopyArray(oAnnotation.g_oDrawArray);\r\n\t\tvar bCanMoveX = true;\r\n\t\tvar bCanMoveY = true;\r\n\t\t// Check whether dragging any further would put the shape out of bounds\r\n\t\tfor (var i = 0; i < arrayCopy.length; i++) {\r\n\t\t\tif (arrayCopy[i][0] + iOffX > 1 || arrayCopy[i][0] + iOffX < 0) {\r\n\t\t\t\tbCanMoveX = false;\r\n\t\t\t}\r\n\t\t\tif (arrayCopy[i][1] + iOffY > 1 || arrayCopy[i][1] + iOffY < 0) {\r\n\t\t\t\tbCanMoveY = false;\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (bCanMoveX) { // Apply the x coordinate changes.\r\n\t\t\tfor (var i = 0; i < oAnnotation.g_oDrawArray.length; i++) {\r\n\t\t\t\toAnnotation.g_oDrawArray[i][0] += iOffX;\r\n\t\t\t\toAnnotation.g_oDrawCoordSetArray[i].xCoordinate += iOffX;\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (bCanMoveY) { // Apply the y coordinate changes\r\n\t\t\tfor (var i = 0; i < oAnnotation.g_oDrawArray.length; i++) {\r\n\t\t\t\toAnnotation.g_oDrawArray[i][1] += iOffY;\r\n\t\t\t\toAnnotation.g_oDrawCoordSetArray[i].yCoordinate += iOffY;\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis.g_oAnnotationCanvas.g_oContext.clearRect(0, 0, oAnnotationCanvasObject.width, oAnnotationCanvasObject.height);\r\n\t\tg_oAnnotations.redrawAnnotations(oArtworkCanvas, this.g_oAnnotationCanvas, oAnnotation.id);\r\n\t};\r\n\r\n\t/**\r\n\t * Handles resizing of annotations via drag handles\r\n\t * @param {object} oAnnotation - The annotation being resized.\r\n\t * @param {event} e - The event\r\n\t * @param {object} oArtworkCanvas - The artwork canvas\r\n\t * @param {object} g_oAnnotationCanvas - The annotation canvas\r\n\t * @param {double} iOrigX - The Old X coordinate.\r\n\t * @param {double} iOrigY - The Old Y coordinate.\r\n\t * @param {enum} iHandleType - The handle the annotation is being dragged by.\r\n\t */\r\n\tAnnotationAction.prototype.resizeDragMove = function (oAnnotation, e, oArtworkCanvas, g_oAnnotationCanvas, iOrigX, iOrigY, iHandleType) {\r\n\t\t$('.speechbubble').hide();\r\n\r\n\t\tvar minXindex, minYindex, maxXindex, maxYindex;\r\n\t\t// Work out the min/max X/Y coordinate holders\r\n\t\tif (oAnnotation.g_iAnnotationType != eAnnotationTypes.Freedraw) {\r\n\t\t\tminXindex = (oAnnotation.g_oDrawArray[0][0] < oAnnotation.g_oDrawArray[1][0]) ? 0 : 1;\r\n\t\t\tminYindex = (oAnnotation.g_oDrawArray[0][1] < oAnnotation.g_oDrawArray[1][1]) ? 0 : 1;\r\n\t\t\tmaxXindex = (minXindex === 0) ? 1 : 0;\r\n\t\t\tmaxYindex = (minYindex === 0) ? 1 : 0;\r\n\t\t}\r\n\t\telse {\r\n\t\t\tminXindex = 0;\r\n\t\t\tminYindex = 0;\r\n\t\t\tmaxXindex = 0;\r\n\t\t\tmaxYindex = 0;\r\n\t\t\tfor (var i = 0; i < oAnnotation.g_oDrawArray.length; i++) {\r\n\t\t\t\tminXindex = (oAnnotation.g_oDrawArray[i][0] <= oAnnotation.g_oDrawArray[minXindex][0]) ? i : minXindex;\r\n\t\t\t\tmaxXindex = (oAnnotation.g_oDrawArray[i][0] >= oAnnotation.g_oDrawArray[maxXindex][0]) ? i : maxXindex;\r\n\t\t\t\tminYindex = (oAnnotation.g_oDrawArray[i][1] <= oAnnotation.g_oDrawArray[minYindex][1]) ? i : minYindex;\r\n\t\t\t\tmaxYindex = (oAnnotation.g_oDrawArray[i][1] >= oAnnotation.g_oDrawArray[maxYindex][1]) ? i : maxYindex;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tvar oAnnotationCanvasObject = this.g_oAnnotationCanvas.g_oCanvas;\r\n\t\tvar coords = findClickCanvasCoordinates(e, oArtworkCanvas, g_oAnnotations);\r\n\r\n\t\tvar iNewX = coords[0];\r\n\t\tvar iNewY = coords[1];\r\n\r\n\t\tg_oAnnotations.g_iOrigClickX = iNewX;\r\n\t\tg_oAnnotations.g_iOrigClickY = iNewY;\r\n\r\n\t\t// Transform the offset based on canvas rotation\r\n\t\tvar iOffXt = iNewX - iOrigX;\r\n\t\tvar iOffYt = iNewY - iOrigY;\r\n\t\tvar iOffX;\r\n\t\tvar iOffY;\r\n\t\tswitch (oArtworkCanvas.g_iRotDegrees) {\r\n\t\t\tcase 90:\r\n\t\t\t\tiOffX = iOffYt;\r\n\t\t\t\tiOffY = iOffXt * -1;\r\n\t\t\t\tbreak;\r\n\t\t\tcase 180:\r\n\t\t\t\tiOffX = iOffXt * -1;\r\n\t\t\t\tiOffY = iOffYt * -1;\r\n\t\t\t\tbreak;\r\n\t\t\tcase 270:\r\n\t\t\t\tiOffX = iOffYt * -1;\r\n\t\t\t\tiOffY = iOffXt;\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tiOffX = iOffXt;\r\n\t\t\t\tiOffY = iOffYt;\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tif (oAnnotation.g_iAnnotationType != eAnnotationTypes.Freedraw) {\r\n\t\t\tswitch (iHandleType) {\r\n\t\t\t\tcase eAnnotationHandleTypes.LeftResize:\r\n\t\t\t\t\t// Only update the X coordinate of the leftmost point. Only update if it's still within bounds after.\r\n\t\t\t\t\tif (oAnnotation.g_oDrawArray[minXindex][0] + iOffX <= 1 && oAnnotation.g_oDrawArray[minXindex][0] + iOffX >= 0) {\r\n\t\t\t\t\t\toAnnotation.g_oDrawArray[minXindex][0] += iOffX;\r\n\t\t\t\t\t\toAnnotation.g_oDrawCoordSetArray[minXindex].xCoordinate += iOffX;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase eAnnotationHandleTypes.RightResize:\r\n\t\t\t\t\t// Only update the X coordinate of the rightmost point. Only update if it's still within bounds after.\r\n\t\t\t\t\tif (oAnnotation.g_oDrawArray[maxXindex][0] + iOffX <= 1 && oAnnotation.g_oDrawArray[maxXindex][0] + iOffX >= 0) {\r\n\t\t\t\t\t\toAnnotation.g_oDrawArray[maxXindex][0] += iOffX;\r\n\t\t\t\t\t\toAnnotation.g_oDrawCoordSetArray[maxXindex].xCoordinate += iOffX;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase eAnnotationHandleTypes.TopResize:\r\n\t\t\t\t\t// Only update the Y coordinate of the highest point. Only update if it's still within bounds after.\r\n\t\t\t\t\tif (oAnnotation.g_oDrawArray[minYindex][1] + iOffY <= 1 && oAnnotation.g_oDrawArray[minYindex][1] + iOffY >= 0) {\r\n\t\t\t\t\t\toAnnotation.g_oDrawArray[minYindex][1] += iOffY;\r\n\t\t\t\t\t\toAnnotation.g_oDrawCoordSetArray[minYindex].yCoordinate += iOffY;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase eAnnotationHandleTypes.BottomResize:\r\n\t\t\t\t\t// Only update the Y coordinate of the lowest point. Only update if it's still within bounds after.\r\n\t\t\t\t\tif (oAnnotation.g_oDrawArray[maxYindex][1] + iOffY <= 1 && oAnnotation.g_oDrawArray[maxYindex][1] + iOffY >= 0) {\r\n\t\t\t\t\t\toAnnotation.g_oDrawArray[maxYindex][1] += iOffY;\r\n\t\t\t\t\t\toAnnotation.g_oDrawCoordSetArray[maxYindex].yCoordinate += iOffY;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\tvar tCoords = g_oAnnotations.getClick(e, g_oAnnotationCanvas);\r\n\t\t\tif (g_oAnnotationCanvas.isClickWithinImageBounds(tCoords[0], tCoords[1], oArtworkCanvas, g_oAnnotationCanvas)) {\r\n\t\t\t\tswitch (iHandleType) {\r\n\t\t\t\t\tcase eAnnotationHandleTypes.LeftResize:\r\n\t\t\t\t\t\tthis.applyFreedrawCoordChange(oAnnotation, true, false, -iOffX);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase eAnnotationHandleTypes.RightResize:\r\n\t\t\t\t\t\tthis.applyFreedrawCoordChange(oAnnotation, true, true, iOffX);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase eAnnotationHandleTypes.TopResize:\r\n\t\t\t\t\t\tthis.applyFreedrawCoordChange(oAnnotation, false, false, -iOffY);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase eAnnotationHandleTypes.BottomResize:\r\n\t\t\t\t\t\tthis.applyFreedrawCoordChange(oAnnotation, false, true, iOffY);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tdefault:\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis.g_oAnnotationCanvas.g_oContext.clearRect(0, 0, oAnnotationCanvasObject.width, oAnnotationCanvasObject.height);\r\n\t\tg_oAnnotations.redrawAnnotations(oArtworkCanvas, this.g_oAnnotationCanvas, oAnnotation.id);\r\n\t};\r\n\r\n\t/**\r\n\t * Applies the coordinate changes if the freedraw shape were to stay in bounds.\r\n\t * @param {object} oAnnotation - The annotation\r\n\t * @param {boolean} bHorizontal - Whether a horizontal handle was selected\r\n\t * @param {boolean} bEndMost - Whether it's the end (right or bottom) handle.\r\n\t * @param {int} iOffset - How much to move it by.\r\n\t */\r\n\tAnnotationAction.prototype.applyFreedrawCoordChange = function (oAnnotation, bHorizontal, bEndMost, iOffset) {\r\n\t\t// Set up the variables.\r\n\t\tvar arrayCopy = deepCopyArray(oAnnotation.g_oDrawArray);\r\n\t\tvar iCoordinate = bHorizontal ? 0 : 1; // Changes to the X or Y coordinate.\r\n\t\t// Get the relevant size. Height for vertical changes, Width for horizontal changes.\r\n\t\tvar iSize = bHorizontal ? arrayCopy.concat().sort(sortAnnotationCoords.returnXMax)[0][iCoordinate] - arrayCopy.concat().sort(sortAnnotationCoords.returnXMin)[0][iCoordinate]\r\n\t\t\t: arrayCopy.concat().sort(sortAnnotationCoords.returnYMax)[0][iCoordinate] - arrayCopy.concat().sort(sortAnnotationCoords.returnYMin)[0][iCoordinate];\r\n\t\tvar iDistance;\r\n\t\tif (bHorizontal) {\r\n\t\t\tiDistance = bEndMost ? arrayCopy.concat().sort(sortAnnotationCoords.returnXMin)[0][iCoordinate] : arrayCopy.concat().sort(sortAnnotationCoords.returnXMax)[0][iCoordinate];\r\n\t\t}\r\n\t\telse {\r\n\t\t\tiDistance = bEndMost ? arrayCopy.concat().sort(sortAnnotationCoords.returnYMin)[0][iCoordinate] : arrayCopy.concat().sort(sortAnnotationCoords.returnYMax)[0][iCoordinate];\r\n\t\t}\r\n\r\n\t\tvar bClear = true;\r\n\t\tfor (var i = 0; i < oAnnotation.g_oDrawArray.length; i++) {\r\n\t\t\tvar diff = arrayCopy[i][iCoordinate] - iDistance;\r\n\t\t\tvar iMult = diff / iSize;\r\n\t\t\t// Check whether any of the coordinates would move out of bounds.\r\n\t\t\tif (bClear && (arrayCopy[i][iCoordinate] + (iOffset * iMult) >= 1 || arrayCopy[i][iCoordinate] + (iOffset * iMult) < 0)) {\r\n\t\t\t\tbClear = false;\r\n\t\t\t}\r\n\t\t\t// Apply changes if safe.\r\n\t\t\tif (bClear) {\r\n\t\t\t\toAnnotation.g_oDrawArray[i][iCoordinate] += (iOffset * iMult);\r\n\t\t\t\tif (bHorizontal) {\r\n\t\t\t\t\toAnnotation.g_oDrawCoordSetArray[i].xCoordinate += (iOffset * iMult);\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\toAnnotation.g_oDrawCoordSetArray[i].yCoordinate += (iOffset * iMult);\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Light version of the mouseMove method that only checks for annotation shapes themselves, ignores handles.\r\n\t * @param {event} e - The event.\r\n\t * @param {object} oArtworkCanvas - The artwork canvas.\r\n\t * @param {object} oAnnotationCanvas - The annotation canvas.\r\n\t */\r\n\tAnnotationAction.prototype.mouseMoveLite = function (e, oArtworkCanvas, oAnnotationCanvas) {\r\n\t\tg_oAnnotations.findAnnotation(e, oArtworkCanvas, oAnnotationCanvas, true);\r\n\t\t$(\"#\" + e.target.id).css(\"cursor\", (g_oAnnotations.g_bAnnotationsFound) ? \"pointer\" : g_oAnnotations.g_szPrevCursorStyle);\r\n\t};\r\n\r\n\t/**\r\n\t * Checks whether a handle was clicked and calls the handler.\r\n\t * @param {event} e - the event\r\n\t * @param {object} oArtworkCanvas - the artwork canvas\r\n\t * @param {object} oAnnotationCanvas - the annotation canvas\r\n\t */\r\n\tAnnotationAction.prototype.handleClick = function (e, oArtworkCanvas, oAnnotationCanvas) {\r\n\t\t\r\n\t\t// If we are text compare mode and not in a text highlight, allow text compare to handle the click.\r\n\t\tif (g_oTextCompare.g_bTextCompareInProgress && !g_oTextTools.g_bHighlightInProgress) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar coords = g_oAnnotations.getClick(e, oArtworkCanvas);\r\n\t\tvar oAnnotationStack = g_oAnnotations.getAnnotationStackCurrentPage(oArtworkCanvas);\r\n\t\tfor (var i = 0; i < oAnnotationStack.length; i++) {\r\n\t\t\tvar iHandleType = g_oAnnotationActions.isclickWithinAnnotationAnyHandle(coords, oAnnotationStack[i]);\r\n\t\t\tif (iHandleType > -1) {\r\n\t\t\t\tthis.shapeHandler(e, oArtworkCanvas, oAnnotationCanvas, oAnnotationStack[i], iHandleType);\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Changes cursor based on whether a handle (for a non-existent annotation) was hovered over.\r\n\t * @param {event} e - the event.\r\n\t * @param {object} oArtworkCanvas - the artwork canvas.\r\n\t * @param {object} oAnnotationCanvas - the annotation canvas.\r\n\t * @param {array} handleData - coordinates of the handle.\r\n\t * @param {enum} handleType - what type of handle it is.\r\n\t */\r\n\tAnnotationAction.prototype.mouseMoveAnnotationHandles = function (e, oArtworkCanvas, oAnnotationCanvas, handleData, handleType) {\r\n\t\t\r\n\t\t// Get the mouse coordinates.\r\n\t\tvar mouseCoordinates = g_oAnnotations.getClick(e, oArtworkCanvas);\r\n\r\n\t\t// Keep track of if we are over a handle.\r\n\t\tvar bMouseOverHandle = false;\r\n\r\n\t\t// Loop through each of the handle coordinates.\r\n\t\tfor (var i = 0; i < handleData.length; i++) {\r\n\r\n\t\t\t// Check if we are over the handle.\r\n\t\t\tif ((Math.abs(mouseCoordinates[0] - handleData[i].handleX - this.calculateAnnotationHandleSize(handleType)[0] / 2) < this.calculateAnnotationHandleSize(handleType)[0] / 2)\r\n\t\t\t\t&& (Math.abs(mouseCoordinates[1] - handleData[i].handleY - this.calculateAnnotationHandleSize(handleType)[1] / 2) < this.calculateAnnotationHandleSize(handleType)[1] / 2)) {\r\n\r\n\t\t\t\t// Set that we are over the handle.\r\n\t\t\t\tbMouseOverHandle = true;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Set the cursor.\r\n\t\t$('#AnnotationViewer').css(\"cursor\", (bMouseOverHandle ? \"pointer\" : g_oAnnotations.g_szPrevCursorStyle));\r\n\t};\r\n\r\n\t/**\r\n\t * Checks whether a handle was clicked for a non-existent annotation and calls the handler.\r\n\t * @param {event} e - the event\r\n\t * @param {object} oArtworkCanvas - the artwork canvas.\r\n\t * @param {object} oAnnotationCanvas - the annotation canvas.\r\n\t * @param {array} handleData - Handle location and where to draw the annotation.\r\n\t * @param {enum} handleType - What type of handle was clicked.\r\n\t */\r\n\tAnnotationAction.prototype.mouseClickAnnotationHandles = function (e, oArtworkCanvas, oAnnotationCanvas, handleData, handleType) {\r\n\r\n\t\t// Get the mouse coordinates.\r\n\t\tvar mouseCoordinates = g_oAnnotations.getClick(e, oArtworkCanvas);\r\n\r\n\t\t// Loop through each of the handle coordinates.\r\n\t\tfor (var i = 0; i < handleData.length; i++) {\r\n\r\n\t\t\t// Check if we are over the handle.\r\n\t\t\tif ((Math.abs(mouseCoordinates[0] - handleData[i].handleX - this.calculateAnnotationHandleSize(handleType)[0] / 2) < this.calculateAnnotationHandleSize(handleType)[0] / 2)\r\n\t\t\t\t&& (Math.abs(mouseCoordinates[1] - handleData[i].handleY - this.calculateAnnotationHandleSize(handleType)[1] / 2) < this.calculateAnnotationHandleSize(handleType)[1] / 2)) {\r\n\r\n\t\t\t\t// Action the handle.\r\n\t\t\t\tthis.handleHandler(oArtworkCanvas, oAnnotationCanvas, handleType, handleData[i].annotationCoordinates, handleData[i].annotationData);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// We are not over a handle, remove the pointer down event.\r\n\t\t$(\"#AnnotationViewer\").off(\"pointerdown.annotationUI\");\r\n\t};\r\n\r\n\t/**\r\n\t * Changes the mouse cursor based on what handle/annotation was hovered over.\r\n\t * @param {event} e - The event.\r\n\t * @param {object} oArtworkCanvas - The artwork canvas.\r\n\t * @param {object} oAnnotationCanvas - The annotation canvas.\r\n\t */\r\n\tAnnotationAction.prototype.mouseMove = function (e, oArtworkCanvas, oAnnotationCanvas) {\r\n\t\tvar coords = g_oAnnotations.getClick(e, oArtworkCanvas);\r\n\r\n\t\tvar oAnnotationStack = g_oAnnotations.getAnnotationStackCurrentPage(oArtworkCanvas);\r\n\t\tfor (var i = 0; i < oAnnotationStack.length; i++) {\r\n\t\t\tvar iHandleType = g_oAnnotationActions.isclickWithinAnnotationAnyHandle(coords, oAnnotationStack[i]);\r\n\t\t\tswitch (iHandleType) {\r\n\t\t\t\tcase eAnnotationHandleTypes.DragRect:\r\n\t\t\t\t\t$('#AnnotationViewer').css('cursor', 'move');\r\n\t\t\t\t\treturn;\r\n\t\t\t\tcase eAnnotationHandleTypes.DeleteButton:\r\n\t\t\t\t\t$('#AnnotationViewer').css('cursor', 'pointer');\r\n\t\t\t\t\treturn;\r\n\t\t\t\tcase eAnnotationHandleTypes.TopResize:\r\n\t\t\t\tcase eAnnotationHandleTypes.BottomResize:\r\n\t\t\t\t\t$('#AnnotationViewer').css('cursor', (oArtworkCanvas.g_iRotDegrees === 90 || oArtworkCanvas.g_iRotDegrees === 270) ? 'ew-resize' : 'ns-resize');\r\n\t\t\t\t\treturn;\r\n\t\t\t\tcase eAnnotationHandleTypes.LeftResize:\r\n\t\t\t\tcase eAnnotationHandleTypes.RightResize:\r\n\t\t\t\t\t$('#AnnotationViewer').css('cursor', (oArtworkCanvas.g_iRotDegrees === 90 || oArtworkCanvas.g_iRotDegrees === 270) ? 'ns-resize' : 'ew-resize');\r\n\t\t\t\t\treturn;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\tg_oAnnotations.findAnnotation(e, oArtworkCanvas, oAnnotationCanvas, true);\r\n\t\t$('#AnnotationViewer').css(\"cursor\", (g_oAnnotations.g_bAnnotationsFound) ? \"pointer\" : g_oAnnotations.g_szPrevCursorStyle);\r\n\t};\r\n\r\n\twindow.AnnotationAction = AnnotationAction;\r\n}());"]}