{"version":3,"sources":["../js/SavedCalipers.js"],"names":["g_oSavedCalipers","SavedCalipers","this","g_iOriginScroll","g_iCurMeas","g_oSaveIconWht","Image","src","g_oRedrawData","prototype","CaliperDrawData","type","artworkViewer","annotationViewer","canvasContext","canvasWidth","canvasHeight","beginPointX","beginPointY","coordDistanceX","coordDistanceY","measurement","measurementText","fakeClick","oArtworkViewer","oAnnotationViewer","beginPoint_x","beginPoint_y","coordinateDistance_x","coordinateDistance_y","szMeasurementText","ClearSavedMeasurementsDiv","$","empty","css","CaliperMeasurementOptionHoverLeave","event","relatedTarget","target","id","contains","TechToolsHoverLeave","CaliperMeasurementOptionHover","PopulateCaliperMeasurementsDiv","swipe","swipeStatus","e","phase","dir","dis","HandleSwipe","allowPageScroll","selector","g_oTechTools","g_eMeasurementTypes","HORIZONTAL","offset","offsetTop","g_oSettings","c_iSkinType","parentPadding","replace","DrawSaveIcon","AnnotationContext","Coords","size","GetHandleSize","GetDrawOffset","drawCoords","GetDrawCoords","setTransform","DrawSaveIconHandle","HandleHover","CanvasContext","IsEventOnHandle","g_oAnnotations","g_szPrevCursorStyle","TryHandleClick","SaveCurrentDrawData","SaveMeasurementHandleClickHandler","StoreEvent","StoreDrawPoints","bpX","bpY","GetLeftmostPoint","c","getClickCoords","g_oViewer","g_oArtworkViewer","Math","min","Type","Measurement","d","CollateCaliperRedrawMethodParams","TypeIsHorizontal","redrawInPlace","SelectivelyShowCaliperFlexArrows","g_oUserDetails","SavedHorizontalMeasurements","length","ShowCaliperFlexArrow","HideCaliperFlexArrow","SavedVerticalMeasurements","VERTICAL","removeStyle","prop","CaliperEventsBound","element","eventType","getBoundEvents","some","x","namespace","RebindCaliperRedrawEvent","off","isHorizontal","g_iSelectedMeasurementType","curMeas","distToDraw","GetScaledDistance","CaliperMeasurePointerUp","g_oAnnotationViewer","g_oContext","calculateCentralXCoordinate","g_oCanvas","width","height","calculateCentralYCoordinate","FormatMeasurement","MeasurementAlreadyExists","list","MeasurementExists","PopulateSavedMeasurementsDiv","i","append","num","index","FormatExactMeasurement","BindMeasurementClickEvents","tap","SavedMeasurementClick","stopPropagation","SavedMeasurementDeleteClick","GetSelectedMeasurement","ChangeSelectedCaliperToolType","DrawAndBindCaliperEvents","g_oCompareMode","eCompareMode","SideBySide","SideBySideDiff","g_oCompare","g_oCompareViewer","g_oGreenlightMessages","displayConfirmBubble","c_szDeleteConfirmation","g_iActiveBubbleId","click","GetElementId","DeleteMeasurement","DeleteHandler","data","CaliperRedrawCaller","BindDraggableCaliperMeasurementEvent","changeCanvasFunction","on","slideUp","toolTypeChange","direction","distance","fn","directions","UP","DOWN","scrollElement","scrollTop","coords","HandleCoords","ClickIsOnHandle","szMeas","g_oUserSettings","UseMetricUnits","toFixed","c_iDPI","handlecoords","isPointInPath","s","displayWarningBubble","c_szMeasurementExists","SaveMeasurement","oJSON","SessionId","g_szSessionId","UserId","Value","ajax","url","JSON","stringify","contentType","dataType","success","response","SaveMeasurement_CH","failure","error","displayErrorBubble","c_szSaveFailure","Success","displaySuccessBubble","c_szSaveSuccess","sort","AscendingOrder","AddMeasurementToList","DeleteMeasurement_CH","c_szDeleteFailure","c_szDeleteSuccess","indexOf","splice","RemoveMeasurement","scaledMeasurement","g_oAnnotationCanvas","GetMeasurement","GetExactMeasurement","round","artworkViewerImage","g_oaImages","artScaleFactor","ImageWidth","g_iScaledImageWidth","zoomScaleFactor","g_iZoomLevel","g_iOriginalZoomLevel","WidthResolution","HeightResolution","c_dMeasurementFactorMetric","Size","DrawImage","DrawSaveIconBase","DrawSaveIconImage","save","beginPath","fillStyle","strokeStyle","rect","closePath","fill","drawImage","window"],"mappings":"AAeA,IAAIA,iBAAmB,IAEtB,WACA,aAEA,SAASC,gBACRC,KAAKC,gBAAkB,EACvBD,KAAKE,WAAa,EAInB,IAAIC,eAAiB,IAAIC,MACzBD,eAAeE,IAAM,sBACrB,IACIC,cAAgB,GAmBpBP,cAAcQ,UAAUC,gBAAkB,SAAUC,KAAMC,cAAeC,iBAAkBC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AAK,IAMlGY,OAAOvP,cAAgBA,cAz1BxB","file":"SavedCalipers-7bb95daa13.js","sourcesContent":["/*\r\n* Copyright (c) 2020 SGS Europe. All rights reserved.\r\n*\r\n* This program is the CONFIDENTIAL and PROPRIETARY property of 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:\tSavedCalipers.js\r\n*\r\n* Description:\tJavaScript code for logic relating to the saved calliper measurements.\r\n*\r\n* History:\t\t28-JAN-20\tR Pavolas\tInitial implementation\r\n*\r\n*/\r\n\r\nvar g_oSavedCalipers = {};\r\n\r\n(function () {\r\n\t\"use strict\";\r\n\r\n\tfunction SavedCalipers() {\r\n\t\tthis.g_iOriginScroll = 0;\r\n\t\tthis.g_iCurMeas = 0;\r\n\t}\r\n\r\n\t// Private\r\n\tvar g_oSaveIconWht = new Image();\r\n\tg_oSaveIconWht.src = \"img/Save_wht_24.png\";\r\n\tvar c_iHandleSize = 20;\r\n\tvar g_oRedrawData = {};\r\n\r\n\t/**\r\n\t * Returns an object containing all the parameters needed to call g_oTechTools.CaliperRedraw(...)\r\n\t * @param {number} type Enum for what type of calliper, Horizontal or Vertical\r\n\t * @param {object} artworkViewer The artwork viewer\r\n\t * @param {object} annotationViewer The annotation viewer\r\n\t * @param {object} canvasContext The 2dCanvasRenderingContext object\r\n\t * @param {number} canvasWidth Width of the canvas\r\n\t * @param {number} canvasHeight Height of the canvas\r\n\t * @param {number} beginPointX Where the method will think the mouse was clicked, this determines where the measurement size is shown\r\n\t * @param {number} beginPointY Where the method will think the mouse was clicked, this determines where the measurement size is shown\r\n\t * @param {number} coordDistanceX How much the mouse was dragged alongside the x axis\r\n\t * @param {number} coordDistanceY How much the mouse was dragged alongside the y axis\r\n\t * @param {number} measurement The measurement itself\r\n\t * @param {string} measurementText The measurement as a string alongside the suffix\r\n\t * @param {bool} fakeClick Whether we'll be faking a click with our own coordinates\r\n\t * @returns {object} Object containing all the parameters needed to call g_oTechTools.CaliperRedraw(...)\r\n\t */\r\n\tSavedCalipers.prototype.CaliperDrawData = function (type, artworkViewer, annotationViewer, canvasContext, canvasWidth, canvasHeight, beginPointX, beginPointY, coordDistanceX, coordDistanceY, measurement, measurementText, fakeClick) {\r\n\t\treturn {\r\n\t\t\ttype: type,\r\n\t\t\toArtworkViewer: artworkViewer,\r\n\t\t\toAnnotationViewer: annotationViewer,\r\n\t\t\tcanvasContext: canvasContext,\r\n\t\t\tcanvasWidth: canvasWidth,\r\n\t\t\tcanvasHeight: canvasHeight,\r\n\t\t\tbeginPoint_x: beginPointX,\r\n\t\t\tbeginPoint_y: beginPointY,\r\n\t\t\tcoordinateDistance_x: coordDistanceX,\r\n\t\t\tcoordinateDistance_y: coordDistanceY,\r\n\t\t\tmeasurement: measurement,\r\n\t\t\tszMeasurementText: measurementText,\r\n\t\t\tfakeClick: fakeClick\r\n\t\t};\r\n\t};\r\n\r\n\t/**\r\n\t * Clears the savedMeasurementContainer\r\n\t */\r\n\tSavedCalipers.prototype.ClearSavedMeasurementsDiv = function () {\r\n\t\t$(\"#savedMeasurementContainer\").empty();\r\n\t\t$(\"#savedMeasurementContainer\").css(\"border\", \"none\");\r\n\t};\r\n\r\n\t/**\r\n\t * Event for when the calliper measurement tech tool is hovered away from\r\n\t * @param {object} event The triggering event\r\n\t */\r\n\tSavedCalipers.prototype.CaliperMeasurementOptionHoverLeave = function (event) {\r\n\t\tif (!event || !event.relatedTarget) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tvar target = event.relatedTarget.id;\r\n\t\tif (!target.contains(\"savedMeasurement\") && target !== \"techToolsDrodown\" && target !== \"divTechToolsDropDown\") {\r\n\t\t\tthis.ClearSavedMeasurementsDiv();\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Event for when the tech tools drop-down is hovered away from\r\n\t * @param {object} event The triggering event\r\n\t */\r\n\tSavedCalipers.prototype.TechToolsHoverLeave = function (event) {\r\n\t\tif (!event || !event.relatedTarget) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tvar target = event.relatedTarget.id;\r\n\t\tif (!target.contains(\"savedMeasurement\") && target !== \"divTechToolsDropDown\") {\r\n\t\t\tthis.ClearSavedMeasurementsDiv();\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Event for when a calliper measurement tool is hovered over\r\n\t * @param {number} type Enum type of what type of tool is hovered over\r\n\t */\r\n\tSavedCalipers.prototype.CaliperMeasurementOptionHover = function (type) {\r\n\t\tthis.ClearSavedMeasurementsDiv();\r\n\t\tPopulateCaliperMeasurementsDiv(type);\r\n\t\t$(\"#savedMeasurementContainer\").swipe('destroy');\r\n\t\t$(\"#savedMeasurementContainer\").swipe({\r\n\t\t\tswipeStatus: function (e, phase, dir, dis) {\r\n\t\t\t\tHandleSwipe(e, phase, dir, dis);\r\n\t\t\t},\r\n\t\t\tallowPageScroll: \"vertical\"\r\n\t\t});\r\n\t\tvar selector = type === g_oTechTools.g_eMeasurementTypes.HORIZONTAL ? \"#divTechToolsHorizontal\" : \"#divTechToolsVertical\";\r\n\t\tvar offset = $(selector)[0].offsetTop;\r\n\t\tif (g_oSettings.c_iSkinType === 1) {\r\n\t\t\toffset--;\r\n\t\t}\r\n\t\tvar parentPadding = +$(\"#divTechToolsDropDown\").css(\"padding-top\").replace(/[a-z]/gi, '');\r\n\t\t$(\"#savedMeasurementContainer\").css(\"margin-top\", offset - parentPadding + \"px\");\r\n\t};\r\n\r\n\t/**\r\n\t * Draws the save measurement handle similar to how annotation handles are drawn.\r\n\t * @param {object} AnnotationContext The 2DContext object\r\n\t * @param {number[]} Coords The coordinates to draw to\r\n\t * @param {number} type Enum of the type of measurement\r\n\t * @param {numer} measurement The measurement\r\n\t */\r\n\tSavedCalipers.prototype.DrawSaveIcon = function (AnnotationContext, Coords, type, measurement) {\r\n\t\tvar size = GetHandleSize();\r\n\t\tvar offset = GetDrawOffset(measurement);\r\n\t\tvar drawCoords = GetDrawCoords(Coords, type, size[0], offset);\r\n\r\n\t\tAnnotationContext.setTransform(1, 0, 0, 1, 0, 0);\r\n\t\tDrawSaveIconHandle(AnnotationContext, drawCoords, size, true);\r\n\t};\r\n\r\n\t/**\r\n\t * Chances the cursor based on whether it's hovering over the handle or not\r\n\t * @param {object} e The event\r\n\t * @param {object} CanvasContext The 2DContext object\r\n\t * @param {number[]} Coords The handle coordinates\r\n\t * @param {number} type Enum of the type of measurement\r\n\t * @param {number} measurement The measurement itself\r\n\t */\r\n\tSavedCalipers.prototype.HandleHover = function (e, CanvasContext, Coords, type, measurement) {\r\n\t\tif (IsEventOnHandle(e, CanvasContext, Coords, type, measurement)) {\r\n\t\t\t$('#AnnotationViewer').css('cursor', 'pointer');\r\n\t\t}\r\n\t\telse {\r\n\t\t\t$('#AnnotationViewer').css('cursor', g_oAnnotations.g_szPrevCursorStyle);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Checks whether the handle was clicked and handles it.\r\n\t * @param {object} e The event\r\n\t * @param {object} CanvasContext The 2DContext object\r\n\t * @param {number[]} Coords The coordinates where the handle is drawn\r\n\t * @param {number} type Enum of the type of measurement the handle is drawn for\r\n\t * @param {number} measurement The actual measurement itself\r\n\t * @returns {boolean} True if the click was on a handle.\r\n\t */\r\n\tSavedCalipers.prototype.TryHandleClick = function (e, CanvasContext, Coords, type, measurement) {\r\n\t\tif (IsEventOnHandle(e, CanvasContext, Coords, type, measurement)) {\r\n\t\t\tSaveCurrentDrawData(type, measurement);\r\n\t\t\tSaveMeasurementHandleClickHandler(type, measurement);\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\tg_oRedrawData = {};\r\n\t\treturn false;\r\n\t};\r\n\r\n\t/**\r\n\t * Saves the event\r\n\t * @param {object} e event to save\r\n\t */\r\n\tSavedCalipers.prototype.StoreEvent = function (e) {\r\n\t\tg_oRedrawData.e = e;\r\n\t};\r\n\r\n\t/**\r\n\t * Saves the top-left-most coordinates\r\n\t * @param {number} beginPoint_x x coordinate\r\n\t * @param {number} beginPoint_y y coordinate\r\n\t */\r\n\tSavedCalipers.prototype.StoreDrawPoints = function (beginPoint_x, beginPoint_y){\r\n\t\tg_oRedrawData.bpX = beginPoint_x;\r\n\t\tg_oRedrawData.bpY = beginPoint_y;\r\n\t};\r\n\r\n\t/**\r\n\t * Gets the leftmost point comparing the stored coordinates to the event coordinates\r\n\t * @param {any} event The event to check against\r\n\t * @returns {number[]} Leftmost coordinates\r\n\t */\r\n\tSavedCalipers.prototype.GetLeftmostPoint = function (event) {\r\n\t\tvar c = getClickCoords(event, g_oViewer.g_oArtworkViewer);\r\n\t\tvar x = Math.min(g_oRedrawData.bpX, c[0]);\r\n\t\tvar y = Math.min(g_oRedrawData.bpY, c[1]);\r\n\t\treturn [x, y];\r\n\t};\r\n\r\n\t/**\r\n\t * Saves all the calliper redraw data\r\n\t * @param {number} Type Enum of the type of measurement\r\n\t * @param {number} Measurement The measurement itself\r\n\t */\r\n\tvar SaveCurrentDrawData = function (Type, Measurement) {\r\n\t\tg_oRedrawData.d = CollateCaliperRedrawMethodParams(g_oViewer.g_oArtworkViewer, Measurement, TypeIsHorizontal(Type));\r\n\r\n\t\t// Overwrite the data with our own\r\n\t\tg_oRedrawData.d.beginPoint_x = g_oRedrawData.bpX;\r\n\t\tg_oRedrawData.d.beginPoint_y = g_oRedrawData.bpY;\r\n\t\tg_oRedrawData.d.redrawInPlace = true;\r\n\t};\r\n\r\n\t/**\r\n\t * Shows or hides the arrows on the calliper tool div based on whether there are measurements.\r\n\t */\r\n\tSavedCalipers.prototype.SelectivelyShowCaliperFlexArrows = function () {\r\n\t\tif (g_oUserDetails.SavedHorizontalMeasurements.length > 0) {\r\n\t\t\tShowCaliperFlexArrow(g_oTechTools.g_eMeasurementTypes.HORIZONTAL);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tHideCaliperFlexArrow(g_oTechTools.g_eMeasurementTypes.HORIZONTAL);\r\n\t\t}\r\n\r\n\t\tif (g_oUserDetails.SavedVerticalMeasurements.length > 0) {\r\n\t\t\tShowCaliperFlexArrow(g_oTechTools.g_eMeasurementTypes.VERTICAL);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tHideCaliperFlexArrow(g_oTechTools.g_eMeasurementTypes.VERTICAL);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Shows the right arrow in the calliper tool div by removing any styling\r\n\t * @param {number} type Enum of the type of measurement to show for\r\n\t */\r\n\tvar ShowCaliperFlexArrow = function (type) {\r\n\t\tvar selector = TypeIsHorizontal(type) ? \"#divTechToolsHorizontal\" : \"#divTechToolsVertical\";\r\n\t\t$(selector + \" .rightArrowFlex\").removeStyle();\r\n\t};\r\n\r\n\t/**\r\n\t * Hides the right arrow in the calliper tool div by making it transparent\r\n\t * @param {number} type Enum of the type of measurement to hide for\r\n\t */\r\n\tvar HideCaliperFlexArrow = function (type) {\r\n\t\tvar selector = TypeIsHorizontal(type) ? \"#divTechToolsHorizontal\" : \"#divTechToolsVertical\";\r\n\t\t$(selector + \" .rightArrowFlex\").prop(\"style\")[\"border-left-color\"] = \"transparent\";\r\n\t};\r\n\r\n\t/**\r\n\t * Checks whether the given type is a horizontal calliper\r\n\t * @param {number} type Enum of the type\r\n\t * @returns {bool} Whether the given type is a horizontal calliper\r\n\t */\r\n\tvar TypeIsHorizontal = function (type) {\r\n\t\treturn type === g_oTechTools.g_eMeasurementTypes.HORIZONTAL;\r\n\t};\r\n\r\n\t/**\r\n\t * Handler for when the deletion of a measurement is confirmed\r\n\t * @param {object} element The original element for which the delete icon was clicked.\r\n\t * @param {number} type Enum of the type of measurement it was.\r\n\t */\r\n\tvar DeleteHandler = function (element, type) {\r\n\t\tvar list = type === g_oTechTools.g_eMeasurementTypes.HORIZONTAL ? g_oUserDetails.SavedHorizontalMeasurements : g_oUserDetails.SavedVerticalMeasurements;\r\n\t\tvar index = +GetElementId(element).replace(/[a-z]/gi, '');\r\n\t\tvar measurement = list[index];\r\n\r\n\t\tDeleteMeasurement(list, type, measurement);\r\n\t};\r\n\r\n\t/**\r\n\t * Returns whether calliper events are currently bound on the given element\r\n\t * @param {string|object} element Element to check\r\n\t * @param {string} eventType Type of event to check\r\n\t * @returns {bool} True if calliper redraw events are currently bound on the element.\r\n\t */\r\n\tSavedCalipers.prototype.CaliperEventsBound = function (element, eventType) {\r\n\t\treturn $(element).getBoundEvents(eventType).some(function (x) { return x.namespace === \"caliperdraw\"; });\r\n\t};\r\n\r\n\t/**\r\n\t * Rebinds the calliper redraw events with correct data.\r\n\t */\r\n\tSavedCalipers.prototype.RebindCaliperRedrawEvent = function () {\r\n\t\t$(\"#AnnotationViewer\").off(\"pointerdown\");\r\n\t\t$(\"#AnnotationViewer\").off(\"pointermove\");\r\n\t\t$(\"#AnnotationViewer\").off(\"pointerup\");\r\n\r\n\t\tvar isHorizontal = TypeIsHorizontal(g_oTechTools.g_iSelectedMeasurementType);\r\n\t\tvar artworkViewer = g_oViewer.g_oArtworkViewer;\r\n\t\tvar curMeas = this.g_iCurMeas;\r\n\t\tvar distToDraw = GetScaledDistance(artworkViewer, curMeas, isHorizontal);\r\n\r\n\t\tg_oTechTools.CaliperMeasurePointerUp(\r\n\t\t\tartworkViewer,\r\n\t\t\tg_oViewer.g_oAnnotationViewer,\r\n\t\t\tg_oViewer.g_oAnnotationViewer.g_oContext,\r\n\t\t\tisHorizontal ? calculateCentralXCoordinate(artworkViewer.g_oCanvas.width) : artworkViewer.g_oCanvas.width / 2,\r\n\t\t\tisHorizontal ? artworkViewer.g_oCanvas.height / 2 : calculateCentralYCoordinate(artworkViewer.g_oCanvas.height),\r\n\t\t\tcurMeas,\r\n\t\t\tdistToDraw,\r\n\t\t\tdistToDraw,\r\n\t\t\tg_oViewer.g_oAnnotationViewer.g_oCanvas.width,\r\n\t\t\tg_oViewer.g_oAnnotationViewer.g_oCanvas.height,\r\n\t\t\tFormatMeasurement(curMeas),\r\n\t\t\tg_oTechTools.g_iSelectedMeasurementType\r\n\t\t);\r\n\t};\r\n\r\n\t/**\r\n\t * Checks whether the measurement already exists\r\n\t * @param {number} type Enum of the type of measurement\r\n\t * @param {number} measurement The measurement\r\n\t * @returns {bool} True if it already exists\r\n\t */\r\n\tSavedCalipers.prototype.MeasurementAlreadyExists = function (type, measurement) {\r\n\t\tvar list = type === g_oTechTools.g_eMeasurementTypes.HORIZONTAL ? g_oUserDetails.SavedHorizontalMeasurements : g_oUserDetails.SavedVerticalMeasurements;\r\n\t\treturn MeasurementExists(list, measurement);\r\n\t};\r\n\r\n\r\n\t/**\r\n\t * Creates the html string for representing a single saved measurement entry.\r\n\t * @param {number} index Index of the entry\r\n\t * @param {number} num The measurement value\r\n\t * @returns {string} Html that can be appended\r\n\t */\r\n\tvar ConstructSavedMeasurementEntry = function (index, num) {\r\n\t\treturn \"
\" + FormatMeasurement(num)\r\n\t\t\t+ \"
\";\r\n\t};\r\n\r\n\t/**\r\n\t * Populates the savedMeasurementContainer with the values of a given list\r\n\t * @param {number[]} list List to populate for\r\n\t */\r\n\tvar PopulateSavedMeasurementsDiv = function (list) {\r\n\t\tfor (var i = 0; i < list.length; i++) {\r\n\t\t\t$(\"#savedMeasurementContainer\").append(ConstructSavedMeasurementEntry(i, list[i]));\r\n\t\t}\r\n\r\n\t\tif (list.length > 0 && g_oSettings.c_iSkinType === 1) {\r\n\t\t\t$(\"#savedMeasurementContainer\").removeStyle();\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Populates the savedMeasurementContainer with the saved measurements of a given type\r\n\t * @param {number} type Enum type of measurements to populate for\r\n\t */\r\n\tvar PopulateCaliperMeasurementsDiv = function (type) {\r\n\t\tif (type === g_oTechTools.g_eMeasurementTypes.HORIZONTAL) {\r\n\t\t\tPopulateSavedMeasurementsDiv(g_oUserDetails.SavedHorizontalMeasurements);\r\n\t\t}\r\n\t\telse if (type === g_oTechTools.g_eMeasurementTypes.VERTICAL) {\r\n\t\t\tPopulateSavedMeasurementsDiv(g_oUserDetails.SavedVerticalMeasurements);\r\n\t\t}\r\n\t\telse {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tBindMeasurementClickEvents(type);\r\n\t};\r\n\r\n\t/**\r\n\t * Binds the click events for the measurements and their delete icons.\r\n\t * @param {number} type Enum of the type of measurements are displayed.\r\n\t */\r\n\tvar BindMeasurementClickEvents = function (type) {\r\n\t\t$(\".savedMeasurement\").swipe('destroy');\r\n\t\t$(\".savedMeasDelButton\").swipe('destroy');\r\n\t\t$(\".savedMeasurement\").swipe({\r\n\t\t\ttap: function (e) {\r\n\t\t\t\tSavedMeasurementClick(this, type, e);\r\n\t\t\t}\r\n\t\t});\r\n\t\t$(\".savedMeasDelButton\").swipe({\r\n\t\t\ttap: function (e) {\r\n\t\t\t\te.stopPropagation();\r\n\t\t\t\tSavedMeasurementDeleteClick(this, type);\r\n\t\t\t}\r\n\t\t});\r\n\t};\r\n\r\n\t/**\r\n\t * Event for when a user selects a saved measurement\r\n\t * @param {object} element Element that was clicked/tapped\r\n\t * @param {number} type Enum for the type of measurements that are displayed\r\n\t * @param {object} event The triggering event\r\n\t */\r\n\tvar SavedMeasurementClick = function (element, type, event) {\r\n\t\tvar measurement = GetSelectedMeasurement(element, type);\r\n\t\tChangeSelectedCaliperToolType(type);\r\n\r\n\t\tDrawAndBindCaliperEvents(g_oViewer.g_oArtworkViewer, measurement, type === g_oTechTools.g_eMeasurementTypes.HORIZONTAL, event);\r\n\r\n\t\tif (g_oViewer.g_oCompareMode === eCompareMode.SideBySide || g_oViewer.g_oCompareMode === eCompareMode.SideBySideDiff) {\r\n\t\t\tDrawAndBindCaliperEvents(g_oCompare.g_oCompareViewer, measurement, type === g_oTechTools.g_eMeasurementTypes.HORIZONTAL, event);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Shows the confirmation bubble for when a measurement deletion icon is pressed.\r\n\t * @param {object} element The measurement for which the deletion icon was pressed.\r\n\t * @param {number} type Enum of the type of measurement it is.\r\n\t */\r\n\tvar SavedMeasurementDeleteClick = function (element, type) {\r\n\t\tg_oGreenlightMessages.displayConfirmBubble(g_oSavedCalipers.c_szDeleteConfirmation);\r\n\t\t// Override the confirm method\r\n\t\t$(\"#tdSpeech_Confirm_\" + (g_iActiveBubbleId - 1) + \"_Confirm\").click(function () {\r\n\t\t\tDeleteHandler(element, type);\r\n\t\t});\r\n\t};\r\n\r\n\t/**\r\n\t * Draws the calliper and binds the events for dragging it.\r\n\t * @param {object} artworkViewer The artwork viewer\r\n\t * @param {number} measurement The measurement\r\n\t * @param {bool} isHorizontal Whether the measurement is a horizontal calliper\r\n\t * @param {object} event The event\r\n\t */\r\n\tvar DrawAndBindCaliperEvents = function (artworkViewer, measurement, isHorizontal, event) {\r\n\t\tvar data = CollateCaliperRedrawMethodParams(artworkViewer, measurement, isHorizontal);\r\n\r\n\t\tg_oTechTools.CaliperRedrawCaller(event, data);\r\n\t\tg_oSavedCalipers.g_iCurMeas = measurement;\r\n\t\tdata.fakeClick = false;\r\n\t\tBindDraggableCaliperMeasurementEvent(data);\r\n\t};\r\n\r\n\t/**\r\n\t * Binds the events needed so that a the calliper measurement can be dragged around on the canvas\r\n\t * @param {object} data Object containing all the parameters needed to call g_oTechTools.CaliperRedraw(...)\r\n\t */\r\n\tvar BindDraggableCaliperMeasurementEvent = function (data) {\r\n\t\tchangeCanvasFunction(data.oAnnotationViewer.g_oCanvas);\r\n\t\t$(data.oAnnotationViewer.g_oCanvas).off(\"pointermove.annotationUIRedraw\"); // Stays bound afterwards the ways to cancel the redraw get it bound again.\r\n\t\tchangeCanvasFunction(data.oAnnotationViewer.g_oCanvas, \"pointerdown.caliperdraw\", function () {\r\n\t\t\t$(data.oAnnotationViewer.g_oCanvas).on('pointerup', function () {\r\n\t\t\t\t$(data.oAnnotationViewer.g_oCanvas).off('pointermove');\r\n\t\t\t});\r\n\t\t\t$(data.oAnnotationViewer.g_oCanvas).on('pointermove', function (event) {\r\n\t\t\t\t// Hide the toolbar if it's still there\r\n\t\t\t\t$(\"#divTechToolsDropDown\").slideUp(200);\r\n\t\t\t\tg_oTechTools.CaliperRedrawCaller(event, data);\r\n\t\t\t});\r\n\t\t});\r\n\t};\r\n\r\n\t/**\r\n\t * Gets the selected measurement.\r\n\t * @param {object} element The element that was selected.\r\n\t * @param {numer} type Enum of the type of measurements being displayed.\r\n\t * @returns {number} The measurement.\r\n\t */\r\n\tvar GetSelectedMeasurement = function (element, type) {\r\n\t\tvar index = +GetElementId(element).replace(/[a-z]/gi, '');\r\n\t\tif (type === g_oTechTools.g_eMeasurementTypes.HORIZONTAL) {\r\n\t\t\treturn g_oUserDetails.SavedHorizontalMeasurements[index];\r\n\t\t}\r\n\t\telse {\r\n\t\t\treturn g_oUserDetails.SavedVerticalMeasurements[index];\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Calls the tool type change method based on the type.\r\n\t * @param {number} type Enum of the type to change to.\r\n\t */\r\n\tvar ChangeSelectedCaliperToolType = function (type) {\r\n\t\tif (type === g_oTechTools.g_eMeasurementTypes.HORIZONTAL) {\r\n\t\t\tg_oTechTools.toolTypeChange($(\"#divTechToolsHorizontal\"), type);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tg_oTechTools.toolTypeChange($(\"#divTechToolsVertical\"), type);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Event for when the user drags the list with a mouse swipes with a mobile device\r\n\t * See http://labs.rampinteractive.co.uk/touchSwipe/docs/index.html\r\n\t * @param {object} event The triggering event\r\n\t * @param {string} phase What phase the swipe is in, possible values: start, move, end, cancel\r\n\t * @param {string} direction What direction it's being swiped in, possible values: left, right, up, down, in, out\r\n\t * @param {number} distance How far the mouse/finger is from it's starting point\r\n\t */\r\n\tvar HandleSwipe = function (event, phase, direction, distance) {\r\n\t\tif (phase === \"start\") {\r\n\t\t\t// note the current status\r\n\t\t\tg_oSavedCalipers.g_iOriginScroll = $(\"#savedMeasurementContainer\").scrollTop();\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (phase === \"cancel\") {\r\n\t\t\tg_oSavedCalipers.g_iOriginScroll = 0;\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar target = g_oSavedCalipers.g_iOriginScroll;\r\n\r\n\t\tswitch (direction) {\r\n\t\t\tcase $.fn.swipe.directions.UP:\r\n\t\t\t\ttarget += distance;\r\n\t\t\t\tbreak;\r\n\t\t\tcase $.fn.swipe.directions.DOWN:\r\n\t\t\t\ttarget -= distance;\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tscrollElement($(\"#savedMeasurementContainer\"), target, 1);\r\n\t};\r\n\r\n\t/**\r\n\t * Checks whether the given event is done over a handle's position\r\n\t * @param {object} e The event\r\n\t * @param {object} CanvasContext The 2dCanvas object\r\n\t * @param {numer[]} Coords The coordinates of the handle\r\n\t * @param {numer} type Enum of the type of measurement\r\n\t * @param {numer} measurement The measurement\r\n\t * @returns {bool} True if the event is on top of a handle.\r\n\t */\r\n\tvar IsEventOnHandle = function (e, CanvasContext, Coords, type, measurement) {\r\n\t\tvar coords = getClickCoords(e, g_oViewer.g_oArtworkViewer);\r\n\t\tvar size = GetHandleSize();\r\n\t\tvar offset = GetDrawOffset(measurement);\r\n\t\tvar HandleCoords = GetDrawCoords(Coords, type, size[0], offset);\r\n\r\n\t\treturn ClickIsOnHandle(CanvasContext, coords, HandleCoords);\r\n\t};\r\n\r\n\t/**\r\n\t * Gets the coordinates of where the handle should be drawn.\r\n\t * @param {number[]} Coords The coordinates of where it would be drawn.\r\n\t * @param {number} type Enum of the type of measurement it's being drawn for.\r\n\t * @param {number} size The size of the handle\r\n\t * @param {number} offset The offset of the handle based on the size of the measurement\r\n\t * @returns {number[]} New coordinates\r\n\t */\r\n\tvar GetDrawCoords = function (Coords, type, size, offset) {\r\n\t\tif (type === g_oTechTools.g_eMeasurementTypes.HORIZONTAL) {\r\n\t\t\t// We want it above(?) the text\r\n\t\t\treturn [Coords[0] - size, Coords[1] - offset - size];\r\n\t\t}\r\n\t\telse {\r\n\t\t\t// We want it to the right\r\n\t\t\treturn [Coords[0] + offset, Coords[1] - size];\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Gets the offset for the save handle to be to the right of the text\r\n\t * @param {number} measurement The measurement itself\r\n\t * @returns {number} The offset to apply in pixels\r\n\t */\r\n\tvar GetDrawOffset = function (measurement) {\r\n\t\t// Get the measurement as it's displayed\r\n\t\tvar szMeas = g_oSettings.g_oUserSettings.UseMetricUnits ? measurement.toFixed(2) + \" mm\" : (measurement / 25.4).toFixed(4) + \" in\";\r\n\r\n\t\t// Valera round isn't mono-space so we have to play around to handle the difference in width between \"mm\" and \"in\"\r\n\t\tif (g_oSettings.g_oUserSettings.UseMetricUnits) {\r\n\t\t\treturn (szMeas.length * 8 + 10 + 10) * g_oViewer.c_iDPI;\r\n\t\t}\r\n\t\telse {\r\n\t\t\treturn (szMeas.length * 8 - 4 + 10) * g_oViewer.c_iDPI;\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Checks whether a click on the given coordinates is on the save handle.\r\n\t * @param {object} AnnotationContext The 2DContext object\r\n\t * @param {number[]} coords The click coordinates\r\n\t * @param {number[]} handlecoords The handle coordinates\r\n\t * @returns {bool} True if the click is on the handle\r\n\t */\r\n\tvar ClickIsOnHandle = function (AnnotationContext, coords, handlecoords) {\r\n\t\tDrawSaveIconHandle(AnnotationContext, handlecoords, GetHandleSize(), false);\r\n\t\treturn AnnotationContext.isPointInPath(coords[0], coords[1]);\r\n\t};\r\n\r\n\t/**\r\n\t * Gets the size of the handle\r\n\t * @returns {number[]} Size array for the handle\r\n\t */\r\n\tvar GetHandleSize = function () {\r\n\t\tvar s = c_iHandleSize * g_oViewer.c_iDPI;\r\n\t\treturn [s, s];\r\n\t};\r\n\r\n\t/**\r\n\t * Checks whether the measurement exists and attempts to save it.\r\n\t * @param {number} type Enum of the type of measurement to save\r\n\t * @param {number} measurement The measurement itself\r\n\t */\r\n\tvar SaveMeasurementHandleClickHandler = function (type, measurement) {\r\n\t\tvar list = type === g_oTechTools.g_eMeasurementTypes.HORIZONTAL ? g_oUserDetails.SavedHorizontalMeasurements : g_oUserDetails.SavedVerticalMeasurements;\r\n\r\n\t\tif (MeasurementExists(list, measurement)) {\r\n\t\t\tg_oGreenlightMessages.displayWarningBubble(g_oSavedCalipers.c_szMeasurementExists);\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tSaveMeasurement(list, type, measurement);\r\n\t};\r\n\r\n\t/**\r\n\t * Checks whether the measurement exists within a given list\r\n\t * @param {number[]} list List to check\r\n\t * @param {number} measurement Measurement to look for\r\n\t * @returns {bool} True if the measurement is found within the list\r\n\t */\r\n\tvar MeasurementExists = function (list, measurement) {\r\n\t\treturn list.some(function (x) { return x === measurement; });\r\n\t};\r\n\r\n\t/**\r\n\t * Adds a measurement to the list and sorts it.\r\n\t * @param {number[]} list List to add to\r\n\t * @param {number} measurement The measurement\r\n\t */\r\n\tvar AddMeasurementToList = function (list, measurement) {\r\n\t\tlist[list.length] = measurement;\r\n\t\tlist.sort(AscendingOrder);\r\n\t};\r\n\r\n\t/**\r\n\t * Tries to remove the measurement from a list\r\n\t * @param {number[]} list List to remover for\r\n\t * @param {number} measurement The measurement\r\n\t */\r\n\tvar RemoveMeasurement = function (list, measurement) {\r\n\t\tvar index = list.indexOf(measurement);\r\n\t\tif (index === -1) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tlist.splice(index, 1);\r\n\t};\r\n\r\n\t/**\r\n\t * Sends the request to save the measurement to the server\r\n\t * @param {number[]} list List to add to\r\n\t * @param {number} type Enum of type of measurement to save\r\n\t * @param {number} measurement The measurement\r\n\t */\r\n\tvar SaveMeasurement = function (list, type, measurement) {\r\n\t\tvar oJSON = {\r\n\t\t\tSessionId: g_szSessionId,\r\n\t\t\tUserId: g_oUserDetails.UserId,\r\n\t\t\tType: type,\r\n\t\t\tValue: measurement\r\n\t\t};\r\n\t\t$.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: \"UserDetails/SaveUserMeasurement\",\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\tSaveMeasurement_CH(response, list, type, measurement);\r\n\t\t\t},\r\n\t\t\tfailure: function () {\r\n\t\t\t},\r\n\t\t\terror: function () {\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oSavedCalipers.c_szSaveFailure);\r\n\t\t\t}\r\n\t\t});\r\n\t};\r\n\r\n\t/**\r\n\t * Callback handler for when server responds to the save request.\r\n\t * @param {object} response The response object\r\n\t * @param {numer[]} list The list to save to\r\n\t * @param {number} type Enum of the type of measurement\r\n\t * @param {numer} measurement The measurement\r\n\t */\r\n\tvar SaveMeasurement_CH = function (response, list, type, measurement) {\r\n\t\tif (response && response.Success) {\r\n\t\t\tg_oGreenlightMessages.displaySuccessBubble(g_oSavedCalipers.c_szSaveSuccess);\r\n\t\t\tAddMeasurementToList(list, measurement);\r\n\t\t\tShowCaliperFlexArrow(type);\r\n\t\t\tg_oTechTools.CaliperRedrawCaller(g_oRedrawData.e, g_oRedrawData.d);\r\n\t\t\t$('#AnnotationViewer').off('.calipersave');\r\n\t\t\t$('#AnnotationViewer').css('cursor', g_oAnnotations.g_szPrevCursorStyle);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oSavedCalipers.c_szSaveFailure);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Sends the request to delete the measurement to the server\r\n\t * @param {number[]} list List to delete for\r\n\t * @param {number} type Enum of type of measurement to delete\r\n\t * @param {number} measurement The measurement\r\n\t */\r\n\tvar DeleteMeasurement = function (list, type, measurement) {\r\n\t\tvar oJSON = {\r\n\t\t\tSessionId: g_szSessionId,\r\n\t\t\tUserId: g_oUserDetails.UserId,\r\n\t\t\tType: type,\r\n\t\t\tValue: measurement\r\n\t\t};\r\n\t\t$.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: \"UserDetails/DeleteUserMeasurement\",\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\tDeleteMeasurement_CH(response, list, type, measurement);\r\n\t\t\t},\r\n\t\t\tfailure: function () {\r\n\t\t\t},\r\n\t\t\terror: function () {\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oSavedCalipers.c_szDeleteFailure);\r\n\t\t\t}\r\n\t\t});\r\n\t};\r\n\r\n\t/**\r\n\t * Callback handler for when server responds to the delete request.\r\n\t * @param {object} response The response object\r\n\t * @param {numer[]} list The list to delete for\r\n\t * @param {number} type Enum of the type of measurement to delete\r\n\t * @param {numer} measurement The measurement\r\n\t */\r\n\tvar DeleteMeasurement_CH = function (response, list, type, measurement) {\r\n\t\tif (response && response.Success) {\r\n\t\t\tg_oGreenlightMessages.displaySuccessBubble(g_oSavedCalipers.c_szDeleteSuccess);\r\n\t\t\tRemoveMeasurement(list, measurement);\r\n\r\n\t\t\tif (list.length === 0) {\r\n\t\t\t\tHideCaliperFlexArrow(type);\r\n\t\t\t}\r\n\r\n\t\t\tif ($(\".savedMeasurement\").length > 0) {\r\n\t\t\t\t// Redraw on mobile devices\r\n\t\t\t\tg_oSavedCalipers.CaliperMeasurementOptionHover(type);\r\n\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oSavedCalipers.c_szDeleteFailure);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Grabs the relevant data needed to call g_oTechTools.CaliperRedraw(...)\r\n\t * @param {object} artworkViewer The artwork viewer object\r\n\t * @param {number} measurement The measurement\r\n\t * @param {bool} isHorizontal Whether it's a horizontal calliper\r\n\t * @returns {object} Object containing all the parameters needed to call g_oTechTools.CaliperRedraw(...)\r\n\t */\r\n\tvar CollateCaliperRedrawMethodParams = function (artworkViewer, measurement, isHorizontal) {\r\n\t\tvar scaledMeasurement = GetScaledDistance(artworkViewer, measurement, isHorizontal);\r\n\t\treturn g_oSavedCalipers.CaliperDrawData(\r\n\t\t\tisHorizontal ? g_oTechTools.g_eMeasurementTypes.HORIZONTAL : g_oTechTools.g_eMeasurementTypes.VERTICAL,\r\n\t\t\tartworkViewer,\r\n\t\t\tartworkViewer.g_oAnnotationCanvas,\r\n\t\t\tartworkViewer.g_oAnnotationCanvas.g_oContext,\r\n\t\t\tartworkViewer.g_oCanvas.width,\r\n\t\t\tartworkViewer.g_oCanvas.height,\r\n\t\t\tisHorizontal ? calculateCentralXCoordinate(artworkViewer.g_oCanvas.width) : artworkViewer.g_oCanvas.width / 2,\r\n\t\t\tisHorizontal ? artworkViewer.g_oCanvas.height / 2 : calculateCentralYCoordinate(artworkViewer.g_oCanvas.height),\r\n\t\t\t0,\r\n\t\t\t0,\r\n\t\t\tscaledMeasurement,\r\n\t\t\tFormatMeasurement(measurement),\r\n\t\t\ttrue, // fakeClick\r\n\t\t\tfalse // redrawInPlace\r\n\t\t);\r\n\t};\r\n\r\n\t/**\r\n\t * Return a measurement in a user friendly format\r\n\t * @param {number} num Number to format\r\n\t * @returns {string} The number in a user friendly format\r\n\t */\r\n\tvar FormatMeasurement = function (num) {\r\n\t\treturn GetMeasurement(num) + (g_oSettings.g_oUserSettings.UseMetricUnits ? \" mm\" : \" in\");\r\n\t};\r\n\r\n\t/**\r\n\t * Return an un-rounded measurement in a user friendly format\r\n\t * @param {number} num Number to format\r\n\t * @returns {string} The number in a user friendly format\r\n\t */\r\n\tvar FormatExactMeasurement = function (num) {\r\n\t\treturn GetExactMeasurement(num) + (g_oSettings.g_oUserSettings.UseMetricUnits ? \" mm\" : \" in\");\r\n\t};\r\n\r\n\t/**\r\n\t * Convert a number to the user's units\r\n\t * @param {number} num The number to convert\r\n\t * @returns {number} Converted number\r\n\t */\r\n\tvar GetMeasurement = function (num) {\r\n\t\treturn g_oSettings.g_oUserSettings.UseMetricUnits ? round(num, 2).toFixed(2) : round(num / 25.4, 4).toFixed(4);\r\n\t};\r\n\r\n\t/**\r\n\t * Converts an un-rounded number to the user's units\r\n\t * @param {number} num The number to convert\r\n\t * @returns {number} Converted number\r\n\t */\r\n\tvar GetExactMeasurement = function (num) {\r\n\t\treturn g_oSettings.g_oUserSettings.UseMetricUnits ? num : num / 25.4;\r\n\t};\r\n\r\n\t/**\r\n\t * Gets the scaled distance of a given measurement in pixels\r\n\t * @param {object} artworkViewer the artworkViewer object\r\n\t * @param {number} num The measurement\r\n\t * @param {bool} isHorizontal Whether it's a horizontal calliper measurement\r\n\t * @returns {number} Scaled distance in pixels needed to represent the measurement\r\n\t */\r\n\tvar GetScaledDistance = function (artworkViewer, num, isHorizontal) {\r\n\t\tvar artworkViewerImage = artworkViewer.g_oaImages[0];\r\n\t\tvar artScaleFactor = artworkViewerImage.ImageWidth / artworkViewer.g_iScaledImageWidth;\r\n\t\tvar zoomScaleFactor = artworkViewer.g_iZoomLevel / g_oTechTools.g_iOriginalZoomLevel;\r\n\r\n\t\treturn num * (isHorizontal ? artworkViewerImage.WidthResolution : artworkViewerImage.HeightResolution) / artScaleFactor / zoomScaleFactor / g_oTechTools.c_dMeasurementFactorMetric;\r\n\t};\r\n\r\n\t/**\r\n\t * Draws the save measurement handle\r\n\t * @param {object} AnnotationContext The 2DContext object\r\n\t * @param {number[]} Coords Where to draw\r\n\t * @param {number[]} Size Size of the handle\r\n\t * @param {bool} DrawImage Whether to draw the image as well\r\n\t */\r\n\tvar DrawSaveIconHandle = function (AnnotationContext, Coords, Size, DrawImage) {\r\n\t\tDrawSaveIconBase(AnnotationContext, Coords, Size);\r\n\t\tif (DrawImage) {\r\n\t\t\tDrawSaveIconImage(AnnotationContext, Coords, Size);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Draws the background rectangle for the handle\r\n\t * @param {object} AnnotationContext The 2DContext object\r\n\t * @param {number[]} Coords Where to draw\r\n\t * @param {number[]} Size Size of the handle\r\n\t */\r\n\tvar DrawSaveIconBase = function (AnnotationContext, Coords, Size) {\r\n\t\tAnnotationContext.save();\r\n\t\tAnnotationContext.beginPath();\r\n\t\tAnnotationContext.fillStyle = \"rgba(0,0,0,0)\";\r\n\t\tAnnotationContext.strokeStyle = \"rgba(0,0,0,0)\";\r\n\t\tAnnotationContext.rect(Coords[0], Coords[1], Size[0], Size[1]);\r\n\t\tAnnotationContext.closePath();\r\n\t\tAnnotationContext.fill();\r\n\t};\r\n\r\n\t/**\r\n\t * Draws the save icon\r\n\t * @param {object} AnnotationContext The 2DContext object\r\n\t * @param {number[]} Coords Where to draw\r\n\t * @param {number[]} Size Size of the handle\r\n\t */\r\n\tvar DrawSaveIconImage = function (AnnotationContext, Coords, Size) {\r\n\t\tAnnotationContext.drawImage(g_oSaveIconWht, Coords[0] + 2, Coords[1] + 2, Size[0] - 4, Size[1] - 4);\r\n\t};\r\n\r\n\t/**\r\n\t * Add the Audit object to the window.\r\n\t */\r\n\twindow.SavedCalipers = SavedCalipers;\r\n}());"]}