{"version":3,"sources":["../js/Greenlight.js"],"names":["Viewer","readOnly","compareDocuments","readOnlyApprovals","onComplete","this","g_bReadOnly","g_oaCompareDocuments","g_oReadOnlyApprovals","g_oEvents","g_oArtworkViewer","g_oAnnotationViewer","g_oCompareMode","eCompareMode","NoCompare","g_oOnComplete","g_oActiveCanvasList","g_bSettingsAnimating","prototype","clearCanvasHolder","canvasHolder","canvasId","$","html","i","length","g_oContainer","id","g_szCanvasId","splice","getCanvas","oCanvas","getCanvasByName","canvasName","findfirst","g_oViewer","canvas","getArtworkCanvas","oArtworkCanvas","g_iCanvasType","eCanvasType","Artwork","push","getLinkedArtworkCanvas","g_oAnnotationCanvas","docChangeEvent","oDoc","g_oTextTools","g_bHighlightInProgress","endhighlight","g_oTextCompare","g_bTextCompareInProgress","changeDocument","g_oAnnotations","closeActiveAnnotations","css","g_oSVGCopyMagic","hideCopyMagicSlideOut","g_oArchive","g_ArchiveDocument","removeArchiveLock","isEmptyObject","oComboControl","comboControl_GetControlById","selectedDocumentIndex","iPageNumber","documents","document","pages","selectedPageIndex","documentPageNumber","setupViewer","g_oCompare","g_bAlignmentModeActive","RenderTechTools","g_bMultiView","g_oApproval","g_bApprovalInformationHidden","show","documentType","eDocumentTypes","ThreeD","documentDisplaysAsSVG","hide","documentHasSeparations","configureButtons","g_oDoc","g_oCompareViewer","c_bFindSVGText","g_oSVGSearch","clearSVGSearch","is","finalizeRenderingImage","resolve","pan","oSyncCanvas","registerEvents","oEventService","subscribe","resizeWindow","resize","rotate","iRotDegrees","rotateAnimate","DrawLabel","x","y","text","context","g_oContext","fillStyle","g_oSettings","c_iSkinType","fillRect","font","fillText","setupApprovalDocument","oCompareDocs","iSelectedDocumentId","comboControl_CreateNewControl","c_szApprovalDocument","c_szChangeCurrentDocument","iControlIndex","iDocumentIndex","comboControl_GetDocumentById","g_oGreenlightMessages","displayErrorBubble","c_szInvalidDocument","comboControl_SelectOption","setupAnnotationsDiv","offset","slideDiv","oDocument","pageNumber","_doc","_pageNumber","window","Canvas","Annotation","ThreeDCanvas","g_oTechTools","g_iCurrentPage","changeCurrentPage","EventService","publish","activateCompare","g_oCompareDocument","g_oComparePage","toggleAnnotationsDiv","syncSettings","toggleSeparationsDiv","zoomIn","g_oCanvasZoom","marqueeZoom","zoomOut","zoomReset"],"mappings":"CAyBC,WAEA,aAWA,SAASA,OAAOC,SAAUC,iBAAkBC,kBAAmBC,YAG9DC,KAAKC,YAAcL,SAGnBI,KAAKE,qBAAuBL,iBAG5BG,KAAKG,qBAAuBL,kBAG5BE,KAAKI,UAAY,GAGjBJ,KAAKK,iBAAmB,KACxBL,KAAKM,oBAAsB,KAG3BN,KAAKO,eAAiBC,aAAaC,UAGnCT,KAAKU,cAAgBX,WAGrBC,KAAKW,oBAAsB,GAG3BX,KAAKY,sBAAuB,EAG7BjB,OAAOkB,UAAUC,kBAAoB,SAAUC,aAAcC,UAG5DC,EAAE,IAAMF,cAAcG,KAAK,IAG3B,IAAK,IAAIC,EAAI,EAAGA,EAAInB,KAAKW,oBAAoBS,OAAQD,IAGhDnB,KAAKW,oBAAoBQ,GAAGE,aAAaC,IAAMP,cAAgBf,KAAKW,oBAAoBQ,GAAGI,cAAgBP,WAG9GhB,KAAKW,oBAAoBa,OAAOL,EAAG,GACnCA,MAKHxB,OAAOkB,UAAUY,UAAY,SAAUT,UAMtC,IAHA,IAAIU,QAAU,KAGLP,EAAI,EAAGA,EAAInB,KAAKW,oBAAoBS,OAAQD,IACpD,GAAInB,KAAKW,oBAAoBQ,GAAGI,cAAgBP,SAAU,CACzDU,QAAU1B,KAAKW,oBAAoBQ,GACnC,MAKF,OAAOO,SAOR/B,OAAOkB,UAAUc,gBAAkB,SAAUC,YAC5C,OAAOX,EAAEY,UAAUC,UAAUnB,oBAAqB,SAAUoB,QAC3D,OAAOA,OAAOR,cAAgBK,cAIhCjC,OAAOkB,UAAUmB,iBAAmB,WAMnC,IAHA,IAAIC,eAAiB,GAGZd,EAAI,EAAGA,EAAInB,KAAKW,oB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qB7G,UAAUzB,iBAAkByB,UAAUxB,sBAI7EwB,UAAUvB,gBAAkBC,aAAaC,WAC5C0D,WAAWyE,gBAAgB9G,UAAUvB,eAAgB4D,WAAW0E,mBAAoB1E,WAAW2E,iBAOjGnJ,OAAOkB,UAAUkI,qBAAuB,WAGvCjB,SAAS7G,EAAE,6BAA6B,GAAM,GAG9CyF,YAAYsC,gBAMbrJ,OAAOkB,UAAUoI,qBAAuB,WAGvCnB,SAAS7G,EAAE,qBAAqB,GAAO,GAGvCyF,YAAYsC,gBAMbrJ,OAAOkB,UAAUqI,OAAS,SAAUxD,aAGnC1F,KAAKK,iBAAiB8I,cAAcD,SAGpC,IAAK,IAAI/H,EAAI,EAAGA,EAAIuE,YAAYtE,OAAQD,IACvCuE,YAAYvE,GAAGgI,cAAcD,UAO/BvJ,OAAOkB,UAAUuI,YAAc,SAAU1D,aACxC1F,KAAKK,iBAAiB8I,cAAcC,YAAY1D,cAMjD/F,OAAOkB,UAAUwI,QAAU,SAAU3D,aAGpC1F,KAAKK,iBAAiB8I,cAAcE,UAGpC,IAAK,IAAIlI,EAAI,EAAGA,EAAIuE,YAAYtE,OAAQD,IACvCuE,YAAYvE,GAAGgI,cAAcE,WAO/B1J,OAAOkB,UAAUyI,UAAY,SAAU5D,aAGtC1F,KAAKK,iBAAiB8I,cAAcG,YAGpC,IAAK,IAAInI,EAAI,EAAGA,EAAIuE,YAAYtE,OAAQD,IACvCuE,YAAYvE,GAAGgI,cAAcG,aAK/BnB,OAAOxI,OAASA,OAjiBjB","file":"Greenlight-e84920b8de.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:\tGreenlight.js\r\n*\r\n* Description:\tGeneric Greenlight JavaScript code.\r\n*\r\n* History:\t\t10-JUL-17\tJ Fuller\t\tInitial implementation.\r\n*\t\t\t\t22-NOV-17\tM Sherer\t\tChanges for the Greenlight Annotation Module (DR207).\r\n*\t\t\t\t14-FEB-18\tJ Fuller\t\tGreenlight enhancements to remove existing canvases.\r\n*\t\t\t\t14-DEC-18\tP Dickson\t\tImplemented SVG documents.\r\n*\t\t\t\t08-OCT-18 R Pavolas Refactored bubble calls. (DR158989)\r\n*\t\t\t\t12-OCT-18\tH Tapp\t\t\tModified Rotate to handle anticlockwise direction (GL205006).\r\n*\t\t\t\t16-OCT-18\tD Tregoiing\t Added methods for drawing labels to the screen.\r\n*\t\t\t\t04-DEC-18 R Pavolas Added a method to get Canvas by ID name.\r\n*\t\t\t\t21-JAN-19\tM Sherer\t\tFix to make sure all annotations are closed during a doc event.\r\n*\t\t\t\t23-APR-19 J Fuller Updated to render tech tools with office docs.\r\n*\t\t\t\t18-DEC-19\tS Norman\t\tUpdated Greenlight to hide approval information determined by a boolean passed from the calling application. (Feature 43023 Greenlight - Hide Approval Information)\r\n *\t\t\t\t05-FEB-20\tR Pavolas\t\tChanged url for updating user preferences.\r\n*/\r\n\r\n(function () {\r\n\r\n\t\"use strict\";\r\n\r\n\t/**\r\n\t * Creates a new Viewer\r\n\t * This is equivalent to the approvalEnvironment object within the CopyMagic Solution.\r\n\t * @param {bool} readOnly - Determines if the viewer should be shown in read only mode.\r\n\t * @param {array} compareDocuments - These are the compare documents that will be available to the user.\r\n\t * @param {array} readOnlyApprovals - The approvals requested as read only.\r\n\t * @param {object} onComplete - Deferred object to be resolved when viewer completed loading.\r\n\t * @class\r\n\t */\r\n\tfunction Viewer(readOnly, compareDocuments, readOnlyApprovals, onComplete) {\r\n\t\t\r\n\t\t// Read only Mode.\r\n\t\tthis.g_bReadOnly = readOnly;\r\n\r\n\t\t// Any compare documents that are available.\r\n\t\tthis.g_oaCompareDocuments = compareDocuments;\r\n\r\n\t\t// Any approvals that should remain as read only.\r\n\t\tthis.g_oReadOnlyApprovals = readOnlyApprovals;\r\n\r\n\t\t// Add the events.\r\n\t\tthis.g_oEvents = {};\r\n\r\n\t\t// The Main Artwork Viewer Canvas.\r\n\t\tthis.g_oArtworkViewer = null;\r\n\t\tthis.g_oAnnotationViewer = null;\r\n\r\n\t\t// The current Compare Mode.\r\n\t\tthis.g_oCompareMode = eCompareMode.NoCompare;\r\n\t\t\r\n\t\t// The function to be called on completion of loading.\r\n\t\tthis.g_oOnComplete = onComplete;\r\n\r\n\t\t// The list of active canvases.\r\n\t\tthis.g_oActiveCanvasList = [];\r\n\r\n\t\t// If the settings menu is in animation.\r\n\t\tthis.g_bSettingsAnimating = false;\r\n\t}\r\n\r\n\tViewer.prototype.clearCanvasHolder = function (canvasHolder, canvasId) {\r\n\r\n\t\t// Remove the current canvases from the holder.\r\n\t\t$(\"#\" + canvasHolder).html(\"\");\r\n\r\n\t\t// Loop through each of the canvas in the active canvas list.\r\n\t\tfor (var i = 0; i < this.g_oActiveCanvasList.length; i++) {\r\n\r\n\t\t\t// If this canvas is part of the cleared canvas holder, or this is the individual canvas we wish to clear.\r\n\t\t\tif (this.g_oActiveCanvasList[i].g_oContainer.id == canvasHolder || this.g_oActiveCanvasList[i].g_szCanvasId == canvasId) {\r\n\r\n\t\t\t\t// Remove the canvas from the active canvas list.\r\n\t\t\t\tthis.g_oActiveCanvasList.splice(i, 1);\r\n\t\t\t\ti--;\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\tViewer.prototype.getCanvas = function (canvasId) {\r\n\r\n\t\t// Create a variable to hold the canvas.\r\n\t\tvar oCanvas = null;\r\n\r\n\t\t// Find the requested canvas from the list of active canvases.\r\n\t\tfor (var i = 0; i < this.g_oActiveCanvasList.length; i++) {\r\n\t\t\tif (this.g_oActiveCanvasList[i].g_szCanvasId == canvasId) {\r\n\t\t\t\toCanvas = this.g_oActiveCanvasList[i];\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Return the requested canvas.\r\n\t\treturn oCanvas;\r\n\t};\r\n\r\n\t/**\r\n\t * Returns the first canvas found with the supplied name.\r\n\t * @param {string} canvasName - the name of the canvas.\r\n\t */\r\n\tViewer.prototype.getCanvasByName = function (canvasName) {\r\n\t\treturn $.findfirst(g_oViewer.g_oActiveCanvasList, function (canvas) {\r\n\t\t\treturn canvas.g_szCanvasId == canvasName;\r\n\t\t});\r\n\t};\r\n\r\n\tViewer.prototype.getArtworkCanvas = function () {\r\n\r\n\t\t// Create a variable to hold the canvas list.\r\n\t\tvar oArtworkCanvas = [];\r\n\r\n\t\t// Find the requested canvas from the list of active canvases.\r\n\t\tfor (var i = 0; i < this.g_oActiveCanvasList.length; i++) {\r\n\t\t\tif (this.g_oActiveCanvasList[i].g_iCanvasType == eCanvasType.Artwork) {\r\n\t\t\t\t// If this is not the navigation canvas.\r\n\t\t\t\tif (this.g_oActiveCanvasList[i].g_szCanvasId != \"navCanvas\" && this.g_oActiveCanvasList[i].g_szCanvasId != \"navCanvasOverlay\") {\r\n\t\t\t\t\toArtworkCanvas.push(this.g_oActiveCanvasList[i]);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Return the artwork canvas.\r\n\t\treturn oArtworkCanvas;\r\n\t};\r\n\r\n\tViewer.prototype.getLinkedArtworkCanvas = function (canvasId) {\r\n\r\n\t\t// Create a variable to hold the canvas.\r\n\t\tvar oCanvas = null;\r\n\r\n\t\t// Find the requested canvas from the list of active canvases.\r\n\t\tfor (var i = 0; i < this.g_oActiveCanvasList.length; i++) {\r\n\t\t\tif (this.g_oActiveCanvasList[i].g_iCanvasType == eCanvasType.Artwork && this.g_oActiveCanvasList[i].g_oAnnotationCanvas != null && this.g_oActiveCanvasList[i].g_oAnnotationCanvas.g_szCanvasId == canvasId) {\r\n\t\t\t\toCanvas = this.g_oActiveCanvasList[i];\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Return the requested canvas.\r\n\t\treturn oCanvas;\r\n\t};\r\n\r\n\t/**\r\n\t * Change the document to the one that has been selected.\r\n\t * @param {string} optionValue - Selected document value.\r\n\t */\r\n\tViewer.prototype.docChangeEvent = function (oDoc) {\r\n\t\t\r\n\t\t// If we have an active text highlight, end this.\r\n\t\tif (g_oTextTools.g_bHighlightInProgress) {\r\n\t\t\tg_oTextTools.endhighlight(g_oViewer.g_oArtworkViewer, g_oViewer.g_oAnnotationViewer, false);\r\n\t\t}\r\n\r\n\t\t// If we are in text compare mode, get set up for the document change.\r\n\t\tif (g_oTextCompare.g_bTextCompareInProgress) {\r\n\t\t\tg_oTextCompare.changeDocument();\r\n\t\t}\r\n\r\n\t\t// If we still have open annotations, close them.\r\n\t\tif (typeof (g_oAnnotations) !== \"undefined\") {\r\n\t\t\tg_oAnnotations.closeActiveAnnotations();\r\n\t\t}\r\n\r\n\t\t// If the copy magic slide out is shown, hide this.\r\n\t\tif ($(\"#divCopyMagicContainer\").css(\"display\") != \"none\") {\r\n\t\t\tg_oSVGCopyMagic.hideCopyMagicSlideOut();\r\n\t\t}\r\n\r\n\t\t// If we are showing the archive module, remove this.\r\n\t\tif (g_oArchive.g_ArchiveDocument > 0) {\r\n\t\t\tg_oArchive.removeArchiveLock();\r\n\t\t}\r\n\r\n\t\t// If the doc isn't defined it was selected via the combo box.\r\n\t\tif ($.isEmptyObject(oDoc) || oDoc === null) {\r\n\t\t\t// Get the index of the approval document combo control.\r\n\t\t\tvar oComboControl = comboControl_GetControlById(\"approvalNameComboControl\", false);\r\n\r\n\t\t\t// If the combo control has been found and a document has been selected.\r\n\t\t\tif (oComboControl != null && oComboControl.selectedDocumentIndex != -1) {\r\n\r\n\t\t\t\t// Get the selected approval document.\r\n\t\t\t\toDoc = oComboControl.documents[oComboControl.selectedDocumentIndex].document;\r\n\r\n\t\t\t\t// Determine the page number required.\r\n\t\t\t\tvar iPageNumber = 1;\r\n\r\n\t\t\t\t// If the current document has multiple pages.\r\n\t\t\t\tif (oDoc.pages.length > 1) {\r\n\r\n\t\t\t\t\t// Get the selected document page.\r\n\t\t\t\t\tvar oPage = oDoc.pages[oComboControl.selectedPageIndex];\r\n\r\n\t\t\t\t\t// Set the page number to the selected page number.\r\n\t\t\t\t\tiPageNumber = oPage.documentPageNumber;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Setup the viewer with the document.\r\n\t\t\t\tg_oViewer.setupViewer(oDoc, iPageNumber);\r\n\r\n\t\t\t\t// If Alignment Mode is Active, we don't want to render the Tech Tools menu.\r\n\t\t\t\tif (!g_oCompare.g_bAlignmentModeActive && !g_oTextCompare.g_bTextCompareInProgress) {\r\n\t\t\t\t\tg_oViewer.RenderTechTools(oDoc);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t// Doc is defined it's been manually selected.\r\n\t\telse {\r\n\t\t\tg_oViewer.setupViewer(oDoc.document, 1);\r\n\t\t\tg_oViewer.RenderTechTools(oDoc.document);\r\n\t\t}\r\n\r\n\t\t// If we're in MultiView & not in compare, show the approval tools.\r\n\t\tif (g_bMultiView && $(\"#divCanvasToolsContainer\").css(\"display\") === \"none\" && !g_oApproval.g_bApprovalInformationHidden) {\r\n\t\t\t$(\"#tblBatchApprovalTools\").show();\r\n\t\t}\r\n\t};\r\n\r\n\tViewer.prototype.RenderTechTools = function (oDoc) {\r\n\t\t\r\n\t\t// Hide or Show the correct tech controls.\r\n\t\tif (oDoc.documentType === eDocumentTypes.ThreeD || documentDisplaysAsSVG(oDoc.documentType)) {\r\n\t\t\t$(\"#tblTechTools\").hide();\r\n\t\t}\r\n\t\telse {\r\n\t\t\t$(\"#tblTechTools\").show();\r\n\t\t\t\r\n\t\t\t// Sub category tech tools.\r\n\t\t\tif (documentHasSeparations(oDoc.documentType, oDoc.pages.length)) {\r\n\t\t\t\t$(\"#divTechToolsText\").show();\r\n\t\t\t\t$(\"#divTechToolsBarcode\").show();\r\n\t\t\t\t$(\"#divTechToolsDensity\").show();\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\t$(\"#divTechToolsText\").hide();\r\n\t\t\t\t$(\"#divTechToolsBarcode\").hide();\r\n\t\t\t\t$(\"#divTechToolsDensity\").hide();\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Hides or shows the buttons based upon the device size.\r\n\t */\r\n\tViewer.prototype.configureButtons = function () {\r\n\r\n\t\tif (g_oViewer.g_oArtworkViewer.g_oDoc.documentType === eDocumentTypes.ThreeD ||\r\n\t\t\t(g_oViewer.g_oCompareMode != eCompareMode.NoCompare && g_oCompare.g_oCompareViewer.g_oDoc != null && g_oCompare.g_oCompareViewer.g_oDoc.documentType === eDocumentTypes.ThreeD)) {\r\n\t\t\t// Hide the marquee tool.\r\n\t\t\t$(\"#btnZoomMarquee\").hide();\r\n\t\t}\r\n\t\t// If the document is not a 3d document.\r\n\t\telse {\r\n\r\n\t\t\t// Show the marquee tool.\r\n\t\t\t$(\"#btnZoomMarquee\").show();\r\n\t\t}\r\n\r\n\t\t// If we are currently finding SVG text.\r\n\t\tif (g_oViewer.c_bFindSVGText) {\r\n\r\n\t\t\t// Clear the SVG search.\r\n\t\t\tg_oSVGSearch.clearSVGSearch(null, null, false);\r\n\r\n\t\t\t// Stop finding SVG text.\r\n\t\t\tg_oViewer.c_bFindSVGText = false;\r\n\t\t}\r\n\r\n\t\t// If the document is an SVG.\r\n\t\tif (documentDisplaysAsSVG(g_oViewer.g_oArtworkViewer.g_oDoc.documentType)) {\r\n\r\n\t\t\t// Show the SVG tools.\r\n\t\t\t$(\"#tblSVGTools\").show();\r\n\t\t}\r\n\t\t// If the document is not an SVG.\r\n\t\telse {\r\n\r\n\t\t\t// Hide the SVG tools\r\n\t\t\t$(\"#tblSVGTools\").hide();\r\n\t\t}\r\n\r\n\t\t// If we are in read only mode.\r\n\t\tif (g_oViewer.g_bReadOnly) {\r\n\r\n\t\t\t// Hide the annotate tools if visible.\r\n\t\t\tif ($(\"#tblAnnotateTools\").is(\":visible\")) {\r\n\t\t\t\t$(\"#tblAnnotateTools\").hide();\r\n\t\t\t}\r\n\t\t}\r\n\t\t// If we are not in read only mode.\r\n\t\telse {\r\n\t\t\t// Show the annotation tools.\r\n\t\t\t$(\"#tblAnnotateTools\").show();\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Finalize the rendering of the initial image.\r\n\t */\r\n\tViewer.prototype.finalizeRenderingImage = function () {\r\n\t\tif (g_oViewer.g_oOnComplete != null) {\r\n\t\t\tg_oViewer.g_oOnComplete.resolve();\r\n\t\t\tg_oViewer.g_oOnComplete = null;\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Pans across the canvas.\r\n\t */\r\n\tViewer.prototype.pan = function (oSyncCanvas) {\r\n\t\tthis.g_oArtworkViewer.pan(oSyncCanvas);\r\n\t};\r\n\r\n\t/**\r\n\t * Registers the viewers events.\r\n\t * @param {object} oEventService - The event service we are registering the events to.\r\n\t */\r\n\tViewer.prototype.registerEvents = function (oEventService) {\r\n\t\tthis.g_oEvents = oEventService;\r\n\t\tthis.g_oEvents.subscribe(\"changeDoc\", this.docChangeEvent);\r\n\t};\r\n\r\n\t/**\r\n\t * On Window Resize event.\r\n\t */\r\n\tViewer.prototype.resizeWindow = function () {\r\n\t\tthis.g_oArtworkViewer.resize();\r\n\t};\r\n\r\n\t/**\r\n\t * Rotates a canvas.\r\n\t * @param {int} iRotDegrees - Used to specify the degrees of rotation\r\n\t */\r\n\tViewer.prototype.rotate = function (oSyncCanvas, iRotDegrees) {\r\n\r\n\t\t// Perform the rotation on the main canvas.\r\n\t\tthis.g_oArtworkViewer.rotateAnimate(iRotDegrees);\r\n\r\n\t\t// Perform the rotation on any sync canvas.\r\n\t\tfor (var i = 0; i < oSyncCanvas.length; i++) {\r\n\t\t\toSyncCanvas[i].rotateAnimate(iRotDegrees);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Draws a label to the screen\r\n\t * @param {number} x - The x coordinate of the label\r\n\t * @param {number} y - The y coordinate of the label\r\n\t * @param {string} text - The text of the label\r\n\t */\r\n\tViewer.prototype.DrawLabel = function (x, y, text) {\r\n\t\tvar boxHeight = 25;\r\n\t\tvar boxWidth = 135;\r\n\t\tvar context = this.getCanvas(\"CompareAnnotationViewer\").g_oContext;\r\n\r\n\t\tcontext.fillStyle = (g_oSettings.c_iSkinType == 0 ? '#2c2121' : '#fbfaf9');\r\n\t\tcontext.fillRect(x, y, boxWidth, boxHeight);\r\n\r\n\t\tcontext.font = \"12px Varela Round, sans-serif\";\r\n\t\tcontext.fillStyle = (g_oSettings.c_iSkinType == 0 ? 'White' : 'Black');\r\n\t\tcontext.fillText(text, x + 10, y + 15);\r\n\t};\r\n\r\n\t/**\r\n\t * Sets up the approval document combo control.\r\n\t */\r\n\tViewer.prototype.setupApprovalDocument = function (oCompareDocs, iSelectedDocumentId) {\r\n\t\t\r\n\t\t// Create the approval document combo control.\r\n\t\tcomboControl_CreateNewControl(\"approvalNameComboControl\", \"divApprovalName\", g_oViewer.c_szApprovalDocument, oCompareDocs, true, \"EventService.publish('changeDoc')\", g_oViewer.c_szChangeCurrentDocument, \"\", 0);\r\n\r\n\t\t// Get the index of the approval document control.\r\n\t\tvar iControlIndex = comboControl_GetControlById(\"approvalNameComboControl\", true);\r\n\r\n\t\t// Get the index of the approval document.\r\n\t\tvar iDocumentIndex = comboControl_GetDocumentById(iControlIndex, iSelectedDocumentId, true);\r\n\r\n\t\t// Check that we have found the desired document.\r\n\t\tif (iDocumentIndex == null) {\r\n\r\n\t\t\t// Display an error and default to the first document in the list.\r\n\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oViewer.c_szInvalidDocument);\r\n\t\t\tiDocumentIndex = 0;\r\n\t\t}\r\n\r\n\t\t// Set the current document as the selected control item.\r\n\t\tcomboControl_SelectOption(iControlIndex, iDocumentIndex, -1, false);\r\n\t};\r\n\r\n\t/**\r\n\t * Sets up the annotations div. Left side bar.\r\n\t */\r\n\tViewer.prototype.setupAnnotationsDiv = function () {\r\n\r\n\t\t// Show the annotations container if we are not in alignment mode.\r\n\t\tif (!g_oCompare.g_bAlignmentModeActive && !g_oTextCompare.g_bTextCompareInProgress) {\r\n\t\t\t$(\"#divAnnotationsContainer\").css(\"display\", \"\");\r\n\t\t}\r\n\r\n\t\t// Make sure the top of the annotations menu lines up beneath the approval status bar.\r\n\t\t$(\"#divAnnotationsContainer\").css(\"top\", ($(\"#divViewerCell\").offset().top));\r\n\r\n\t\t// Slide the menu to the correct position.\r\n\t\tslideDiv($(\"#divAnnotationsContainer\"), true, false);\r\n\t};\r\n\r\n\t/**\r\n\t * Setup the viewer object.\r\n\t * @param {object} - The document we are setting up in the viewer.\r\n\t */\r\n\tViewer.prototype.setupViewer = function (oDocument, pageNumber) {\r\n\t\t\r\n\t\t// Select the document and page.\r\n\t\tvar _doc = oDocument;\r\n\t\tvar _pageNumber = pageNumber;\r\n\r\n\t\t// Clear the current canvases.\r\n\t\tg_oViewer.clearCanvasHolder(\"divCanvasHolder\", \"\");\r\n\t\tg_oViewer.clearCanvasHolder(\"divCompareCanvasHolder\", \"\");\r\n\t\tg_oViewer.clearCanvasHolder(\"divDifferencesCanvasHolder\", \"\");\r\n\r\n\t\t// If this is a 3D approval.\r\n\t\tif (_doc !== null && _doc.documentType == eDocumentTypes.ThreeD) {\r\n\r\n\t\t\t// Setup the Annotation Viewer.\r\n\t\t\tthis.g_oAnnotationViewer = new window.Canvas(\"divCanvasHolder\", \"AnnotationViewer\", \"annotationViewer\", null, 0, null, false, eCanvasType.Annotation);\r\n\r\n\t\t\t// Setup the Artwork Canvas.\r\n\t\t\tthis.g_oArtworkViewer = new window.ThreeDCanvas(\"divCanvasHolder\", \"ArtworkViewer\", _doc, 1, this.g_oAnnotationViewer, true, eCanvasType.Artwork);\r\n\r\n\t\t\t// Hide the separations container and page tools.\r\n\t\t\t$(\"#divSepContainer\").hide();\r\n\t\t\t$(\"#tblPageTools\").hide();\r\n\t\t}\r\n\t\t// If this is a 2D approval.\r\n\t\telse {\r\n\t\t\t// Setup the Annotation Viewer.\r\n\t\t\tthis.g_oAnnotationViewer = new window.Canvas(\"divCanvasHolder\", \"AnnotationViewer\", \"annotationViewer\", null, 0, null, false, eCanvasType.Annotation, 2);\r\n\r\n\t\t\t// Setup the Artwork Canvas.\r\n\t\t\tthis.g_oArtworkViewer = new window.Canvas(\"divCanvasHolder\", \"ArtworkViewer\", \"viewer\", _doc, _pageNumber, this.g_oAnnotationViewer, true, eCanvasType.Artwork, 1);\r\n\r\n\t\t\t// Update the page number.\r\n\t\t\t$(\"#divPageSelectCounter\").text((pageNumber > 1 ? pageNumber : 1) + \"/\" + oDocument.pages.length);\r\n\r\n\t\t\t// Setup the annotations div.\r\n\t\t\tg_oViewer.setupAnnotationsDiv();\r\n\r\n\t\t\t// Show the page tools if this document has multiple pages.\r\n\t\t\tif (oDocument.pages.length > 1) {\r\n\t\t\t\t$(\"#tblPageTools\").show();\r\n\t\t\t}\r\n\t\t\t// Hide the page tools if this document does not have multiple pages.\r\n\t\t\telse {\r\n\t\t\t\t$(\"#tblPageTools\").hide();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Set the main viewers on the annotation script.\r\n\t\tg_oAnnotations.g_oArtworkViewer = this.g_oArtworkViewer;\r\n\t\tg_oAnnotations.g_oAnnotationViewer = this.g_oAnnotationViewer;\r\n\r\n\t\t// Set the main viewers on the tech tools script.\r\n\t\tg_oTechTools.g_oArtworkViewer = this.g_oArtworkViewer;\r\n\t\tg_oTechTools.g_oAnnotationViewer = this.g_oAnnotationViewer;\r\n\r\n\t\t// Set the main viewers on the compare script.\r\n\t\tg_oCompare.g_oArtworkViewer = this.g_oArtworkViewer;\r\n\t\tg_oCompare.g_oAnnotationViewer = this.g_oAnnotationViewer;\r\n\r\n\t\t// Configure the buttons.\r\n\t\tthis.configureButtons();\r\n\r\n\t\t// If a specific page is required.\r\n\t\tif (pageNumber > 1) {\r\n\r\n\t\t\t// Change the approval to use the new page number.\r\n\t\t\tg_oViewer.g_oArtworkViewer.g_iCurrentPage = pageNumber;\r\n\t\t\tg_oViewer.g_oArtworkViewer.changeCurrentPage();\r\n\t\t\tEventService.publish(\"changeCurrentPage\", g_oViewer.g_oArtworkViewer, g_oViewer.g_oAnnotationViewer);\r\n\t\t}\r\n\r\n\t\t// If we have an active compare mode.\r\n\t\tif (g_oViewer.g_oCompareMode != eCompareMode.NoCompare) {\r\n\t\t\tg_oCompare.activateCompare(g_oViewer.g_oCompareMode, g_oCompare.g_oCompareDocument, g_oCompare.g_oComparePage);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Toggles the Annotations div.\r\n\t */\r\n\tViewer.prototype.toggleAnnotationsDiv = function () {\r\n\r\n\t\t// Slide the menu.\r\n\t\tslideDiv($(\"#divAnnotationsContainer\"), true, true);\r\n\r\n\t\t// Update the user settings.\r\n\t\tg_oSettings.syncSettings();\r\n\t};\r\n\r\n\t/**\r\n\t * Toggles the separations div.\r\n\t */\r\n\tViewer.prototype.toggleSeparationsDiv = function () {\r\n\r\n\t\t// Slide the menu.\r\n\t\tslideDiv($(\"#divSepContainer\"), false, true);\r\n\r\n\t\t// Update the user settings.\r\n\t\tg_oSettings.syncSettings();\r\n\t};\r\n\r\n\t/**\r\n\t * Zooms the chosen canvas in.\r\n\t */\r\n\tViewer.prototype.zoomIn = function (oSyncCanvas) {\r\n\r\n\t\t// Perform the zoom in on the main canvas.\r\n\t\tthis.g_oArtworkViewer.g_oCanvasZoom.zoomIn();\r\n\r\n\t\t// Perform the zoom in on any sync canvas.\r\n\t\tfor (var i = 0; i < oSyncCanvas.length; i++) {\r\n\t\t\toSyncCanvas[i].g_oCanvasZoom.zoomIn();\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Zoom Marquee Event Start.\r\n\t */\r\n\tViewer.prototype.marqueeZoom = function (oSyncCanvas) {\r\n\t\tthis.g_oArtworkViewer.g_oCanvasZoom.marqueeZoom(oSyncCanvas);\r\n\t};\r\n\r\n\t/**\r\n\t * Zooms the chosen canvas out.\r\n\t */\r\n\tViewer.prototype.zoomOut = function (oSyncCanvas) {\r\n\r\n\t\t// Perform the zoom out on the main canvas.\r\n\t\tthis.g_oArtworkViewer.g_oCanvasZoom.zoomOut();\r\n\r\n\t\t// Perform the zoom out on any sync canvas.\r\n\t\tfor (var i = 0; i < oSyncCanvas.length; i++) {\r\n\t\t\toSyncCanvas[i].g_oCanvasZoom.zoomOut();\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Reset the Zoom of a canvas.\r\n\t */\r\n\tViewer.prototype.zoomReset = function (oSyncCanvas) {\r\n\r\n\t\t// Perform the zoom reset on the main canvas.\r\n\t\tthis.g_oArtworkViewer.g_oCanvasZoom.zoomReset();\r\n\r\n\t\t// Perform the zoom reset on any sync canvas.\r\n\t\tfor (var i = 0; i < oSyncCanvas.length; i++) {\r\n\t\t\toSyncCanvas[i].g_oCanvasZoom.zoomReset();\r\n\t\t}\r\n\t};\r\n\r\n\t// Add the viewer object to the window.\r\n\twindow.Viewer = Viewer;\r\n}());"]}