{"version":3,"sources":["../js/GreenlightSeparations.js"],"names":["GreenlightSeparations","constants","c_szSwatchClassName","c_szSeparationDisabledClassName","c_szSeparationClassName","c_szSpinnerClassName","c_szColourInputClassName","c_szColourResetClassName","c_szDivSeparationItemsClassName","c_szDisplayAsBlackCheckboxClassName","c_szDisplayAsBlackLabelClassName","c_szColourChangeButtonClassName","c_szColourInputOpacityDropdownClassName","g_bDragging","getSeparationElements","oCanvas","oSyncCanvas","requestedOrder","oSeparationList","deepCopyArray","g_oaImages","i","length","oCompareSeparationList","j","bSeparationInList","k","SeparationName","toLowerCase","push","oSeparationListOrdered","getSeparationName","id","separation","sanitiseSeparationName","separationName","replace","separationOnDropEvent","event","preventDefault","stopPropagation","$","css","oDraggedItemId","dataTransfer","getData","iDragDestination","target","oAllSeparations","children","oAllSeparationsOrdered","oCanvasSeparationsOrdered","oDraggedSeparation","grep","oSeparation","parseInt","getimagePNGData","swatchDragStartEvent","g_oSeparations","g_oDraggedSeparationColour","separationOnDragOverEvent","_this","height","background-color","separationOnDragAutoScroll","separationOnDragLeaveEvent","divPosition","offset","divHeight","iContentQtr","substring","indexOf","iFirstQtr","top","iEndQtr","clientY","animate","scrollTop","stop","swatchOnDragEndEvent","checkColourChangeInputIsVisible","oColourChange","oID","undefined","oResultSeparation","oDestinationContainer","bColourChangeInputVisible","parent","attr","document","getElementById","c_szColourInputElementName","clearColourChangeInput","remove","c_szColourResetElementName","c_szDisplayAsBlackCheckboxElementName","c_szDisplayAsBlackLabelElementName","classList","g_oSeparationOpen","colourChangeButtonOnClickEvent","setupColourChange","SeparationDisabledClassName","oaVisibleColourChangeInputsArray","getElementsByClassName","deepCopyObject","displayAsBlackCheck","add","bInputDisabled","oInputR","createElement","type","className","c_szToolTipStyleClassName","title","c_szSeparationRGBValueProcessToolTip","c_szSeparationRGBValueRedToolTip","value","Red","style","backgroundColor","disabled","appendChild","oInputG","c_szSeparationRGBValueGreenToolTip","Green","oInputB","c_szSeparationRGBValueBlueToolTip","Blue","oInputOpaque","oSelectArray","oMenuOption","text","c_szSeparationOpacityValueToolTip","Opaque","width","append","g_iVisibleSeparataionCount","createDisplayAsBlackControls","oSeparationItem","oColourResetButton","src","c_szSeparationResetChangeColourValuesToolTip","on","e","colourChangeInputsUpdateImage","c_szColourInputOpacityDropdownElementName","colourResetButtonOnClickEvent","oResult","oInputs","OrigRed","OrigGreen","OrigBlue","OrigOpaque","oCheckbox","checked","displayAsBlackCheckboxClickEvent","this","Number","validateColourValueInput","oInputValue","isInt","outerSeparationDivOnClickEvent","getImageData","ToggleCanvasImages","setSeparationCanvasVisibility","visibility","Visible","setupSeparationsDiv","bSetupCanvas","saRequestedOrder","hasSeparations","g_oViewer","g_oCompareMode","eCompareMode","NoCompare","g_oCompare","g_oCompareViewer","g_oCanvas","slideDiv","c_iDPI","clearCanvasHolder","g_oNavCanvasObj","Canvas","eCanvasType","Artwork","g_oNavCanvasOver","g_oContainer","off","navPointerUp","navOnMove","hide","getRatio","getSyncCanvas","RenderSeparationElements","g_bReadOnly","g_oDoc","documentType","eDocumentTypes","ThreeD","g_oChecklist","showChecklistOnLaunch","oApprovalUser","hasChecklist","oChecklist","ChecklistState","g_eChecklistItemState","Pass","makeChecklistTabVisible","oDisplayAsBlackCheckbox","name","oDisplayAsBlackLabel","htmlFor","innerHTML","appendTo","g_bOverrideSingleColourChange","renderSeparationElements","AreSeparationsEnabled","c_szSeparationElementName","oSeparationDropZone","ondragover","ondrop","ondragleave","oSwatch","draggable","ondragstart","setData","parentNode","setTimeout","ondragend","oSpinner","oColourChangeButton","c_szSeparationChangeColourValuesToolTip","addEventListener","l","oInnerSeparationDiv","verticalAlign","oOuterSeparationDiv","oSeparationDiv","oFinalSeparationDropZone","bDisplayCheckBox","find","click","prop","ResetAllCanvasImages","resetAllCanvasImages","clickedSwatch","c_szColourChangeButtonElementName","removeClass","disableCanvasImages","GetVisibleCanvasSeparationsCount","addClass","g_oTechTools","c_szSeparationPercentageElementName","c_szSeparationPercentage_BarcodeElementName","szSeparationElementName","szCurrentPercentageOfColour","iPercentageNumberOfColour","szCurrentTACPercentage","g_szTACFieldDefault","iUpdatedTAC","show","bMultipleSeparationsEnabled","bContainsDensityPercentage","StepThroughCanvasImages","stepThroughCanvasImages","not","next","oSeparations","SetupSeparationsDiv","areSeparationsEnabled","g_bSessionHasTechToolPermissions","documentHasSeparations","g_oArtworkViewer","pages","ShowSpinners","showSpinners","c_szDivSeparationItemsElementName","c_szSeparationDisabledElementName","c_szSpinnerElementName","IsSeparationEnabled","isSeparationEnabled","szSeparationName","oImage","sep","getVisibleCanvasSeparationsCount","iVisibleSeparations","MatchVisibleSeparations","matchVisibleSeparations","oVisibleSeparations","bSeparationVisibilityMatch","oCanvasVisibleSeparations","bSeparationMatched","ToggleOverprintPreview","toggleOverprintPreview","g_bOverprintPreview","window","navigator","userAgent","SanitiseSeparationName","GetSeparationElements","SetSeparationVisibility","setSeparationVisibility","visible","SetSeparationVisibilityDefaults","setSeparationVisibilityDefaults","oHiddenSeparations","SetConstant","setConstant","constantName","hasOwnProperty","call","SeparationClassName","SpinnerElementName","OpenSeparation"],"mappings":"AAyBA,IAAIA,sBAAyB,WAC5B,aAOA,IAAIC,UAAY,CAChBC,oBAAmC,SACnCC,gCAA+C,sBAC/CF,UAA6C,kCAAI,IAAMA,UAAUE,gCACjEF,UAAmC,wBAAI,MACvCA,UAAqC,0BAAI,IAAMA,UAAUG,wBACzDH,UAAgC,qBAAI,UACpCA,UAAkC,uBAAI,IAAMA,UAAUI,qBACtDJ,UAAoC,yBAAI,WACxCA,UAAsC,2BAAI,IAAMA,UAAUK,yBAC1DL,UAAoC,yBAAI,oBACxCA,UAAsC,2BAAI,IAAMA,UAAUM,yBAC1DN,UAA2C,gCAAI,qBAC/CA,UAA6C,kCAAI,IAAMA,UAAUO,gCACjEP,UAA+C,oCAAI,yBACnDA,UAAiD,sCAAI,IAAMA,UAAUQ,oCACrER,UAA4C,iCAAI,sBAChDA,UAA8C,mCAAI,IAAMA,UAAUS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,UAAUmT,cAAgBhM,QA2B3Bf,4BAA6BpG,UAAUE,gCACvCoT,oBAAqBtT,UAAUG,wBAC/BoT,mBAAoBvT,UAAUqR,uBAC9BmC,eA72CuB,IAlCG","file":"GreenlightSeparations-80440917a8.js","sourcesContent":["/*\r\n *\tCopyright (c) 2018 SGS Europe. All rights reserved.\r\n *\r\n *\tThis program is the CONFIDENTIAL and PROPRIETARY property of 2018 SGS Europe.\r\n *\tAny unauthorised use, reproduction, or transfer of this program is strictly\r\n *\tprohibited.\r\n *\r\n *\tFile Name:\tGreenlightSeparations.js\r\n *\r\n *\tDescription:\tThis JavaScript file contains the functions required by the\r\n *\t\t\t\t\timage separations within the Greenlight website.\r\n *\r\n *\tHistory:\t\t21-DEC-17\tN Settle\tInitial implementation.\r\n *\t\t\t\t\t22-FEB-18\tP Raper\t\tAdded code line to update image after separation reset.\r\n *\t\t\t\t\t08-MAR-18\tN Settle\tFixing issue where Colour Separations were not being displayed when they should have been (DR208).\r\n *\t\t\t\t\t20-APR-18\tM Sherer\tFixed bug where separations would close on browser resize and elements would overhang.\r\n *\t\t\t\t\t13-JUL-18\tP Dickson\tUpdated calls to get the image data to pass through a default parameter.\r\n *\t\t\t\t\t09-OCT-18\tS Dervey\tUpdated disableCanvasImages() and setupSeparationsDiv() to update the TAC field (GL205006).\r\n *\t\t\t\t\t10-OCT-18\tD Tregoiing\tUpdated disableCanvasImages to also hide/show the % of each colour (3386 Azure Dev Ops MySGS)\r\n *\t\t\t\t\t19-OCT-18\tS Dervey\tUpdated disableCanvasImages() for the change in the location of the percentage div (GL205006).\r\n *\t\t\t\t\t26-OCT-18 R Pavolas Global refactor bind/unbind to on/off.\r\n *\t\t\t\t\t07-MAR-19\tP Dickson\tAdded functionality for the overprint preview. (GL297649)\r\n *\t\t\t\t\t18-SEP-19\tR Pavolas\tMade sure separation names are sanitized.\r\n */\r\n\r\nvar GreenlightSeparations = (function () {\r\n\t\"use strict\";\r\n\r\n\t// Constants\r\n\r\n\t/**\r\n\t* Holds the constants declared against the object.\r\n\t*/\r\n\tvar constants = {};\r\n\tconstants[\"c_szSwatchClassName\"] = \"swatch\";\r\n\tconstants[\"c_szSeparationDisabledClassName\"] = \"separationDisabled\";\r\n\tconstants[\"c_szSeparationDisabledElementName\"] = \".\" + constants.c_szSeparationDisabledClassName;\r\n\tconstants[\"c_szSeparationClassName\"] = \"sep\";\r\n\tconstants[\"c_szSeparationElementName\"] = \".\" + constants.c_szSeparationClassName;\r\n\tconstants[\"c_szSpinnerClassName\"] = \"spinner\";\r\n\tconstants[\"c_szSpinnerElementName\"] = \".\" + constants.c_szSpinnerClassName;\r\n\tconstants[\"c_szColourInputClassName\"] = \"colinput\";\r\n\tconstants[\"c_szColourInputElementName\"] = \".\" + constants.c_szColourInputClassName;\r\n\tconstants[\"c_szColourResetClassName\"] = \"colourResetButton\";\r\n\tconstants[\"c_szColourResetElementName\"] = \".\" + constants.c_szColourResetClassName;\r\n\tconstants[\"c_szDivSeparationItemsClassName\"] = \"divSeparationItems\";\r\n\tconstants[\"c_szDivSeparationItemsElementName\"] = \"#\" + constants.c_szDivSeparationItemsClassName;\r\n\tconstants[\"c_szDisplayAsBlackCheckboxClassName\"] = \"displayAsBlackCheckbox\";\r\n\tconstants[\"c_szDisplayAsBlackCheckboxElementName\"] = \".\" + constants.c_szDisplayAsBlackCheckboxClassName;\r\n\tconstants[\"c_szDisplayAsBlackLabelClassName\"] = \"displayAsBlackLabel\";\r\n\tconstants[\"c_szDisplayAsBlackLabelElementName\"] = \".\" + constants.c_szDisplayAsBlackLabelClassName;\r\n\tconstants[\"c_szColourChangeButtonClassName\"] = \"colourChangeButton\";\r\n\tconstants[\"c_szColourChangeButtonElementName\"] = \".\" + constants.c_szColourChangeButtonClassName;\r\n\tconstants[\"c_szColourInputOpacityDropdownClassName\"] = \"opacityDropdown\";\r\n\tconstants[\"c_szColourInputOpacityDropdownElementName\"] = \".\" + constants.c_szColourInputOpacityDropdownClassName;\r\n\tconstants[\"c_szToolTipStyleClassName\"] = \"tooltip\";\r\n\r\n\tvar g_iVisibleSeparataionCount = 0;\r\n\r\n\tvar g_oSeparationOpen = {};\r\n\r\n\tvar g_bDragging = false;\r\n\tvar g_oDraggedSeparationColour = \"\";\r\n\r\n\tvar g_bOverprintPreview = false;\r\n\r\n\t// Keep track of if the session has tech tool permissions.\r\n\tvar g_bSessionHasTechToolPermissions = false;\r\n\r\n\t/**\r\n\t * Gets a list of separation elements.\r\n\t * @param {object} oCanvas - The canvas.\r\n\t * @param {object} oSyncCanvas - The sync canvas.\r\n\t * @param {object} requestedOrder - The requested order.\r\n\t * @returns {array} - The separation elements.\r\n\t */\r\n\tfunction getSeparationElements(oCanvas, oSyncCanvas, requestedOrder) {\r\n\r\n\t\t// Get the list of separations for the main canvas.\r\n\t\tvar oSeparationList = deepCopyArray(oCanvas.g_oaImages);\r\n\r\n\t\t// Loop through each of the sync canvas.\r\n\t\tfor (var i = 0; i < oSyncCanvas.length; i++) {\r\n\r\n\t\t\t// Get the separations for the sync canvas.\r\n\t\t\tvar oCompareSeparationList = oSyncCanvas[i].g_oaImages;\r\n\r\n\t\t\t// Loop through each of the images in the canvas.\r\n\t\t\tfor (var j = 0; j < oCompareSeparationList.length; j++) {\r\n\r\n\t\t\t\t// Check if this separation is already in the list.\r\n\t\t\t\tvar bSeparationInList = false;\r\n\r\n\t\t\t\t// Loop through each of the main separations.\r\n\t\t\t\tfor (var k = 0; k < oSeparationList.length; k++) {\r\n\r\n\t\t\t\t\t// If this is the matching separation.\r\n\t\t\t\t\tif (oCompareSeparationList[j].SeparationName.toLowerCase() === oSeparationList[k].SeparationName.toLowerCase()) {\r\n\r\n\t\t\t\t\t\t// Set that the separation is already in the list.\r\n\t\t\t\t\t\tbSeparationInList = true;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// If the separation is not in the list.\r\n\t\t\t\tif (!bSeparationInList) {\r\n\r\n\t\t\t\t\t// Add the separation to the list.\r\n\t\t\t\t\toSeparationList.push(oCompareSeparationList[j]);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// If we have a requested order.\r\n\t\tif (requestedOrder.length > 0) {\r\n\r\n\t\t\t// Create a new array to hold the updated order.\r\n\t\t\tvar oSeparationListOrdered = [];\r\n\r\n\t\t\t// Loop through each of the requested order items.\r\n\t\t\tfor (var i = 0; i < requestedOrder.length; i++) {\r\n\r\n\t\t\t\t// Find the matching item in the separations list.\r\n\t\t\t\tfor (var j = 0; j < oSeparationList.length; j++) {\r\n\r\n\t\t\t\t\t// If this is the matching item.\r\n\t\t\t\t\tif (getSeparationName(oSeparationList[j]) == requestedOrder[i].id) {\r\n\r\n\t\t\t\t\t\t// Add the separation to the list in this order.\r\n\t\t\t\t\t\toSeparationListOrdered.push(oSeparationList[j]);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// Update the separation list to the ordered separation list.\r\n\t\t\toSeparationList = oSeparationListOrdered;\r\n\t\t}\r\n\r\n\t\t// Return the separations list.\r\n\t\treturn oSeparationList;\r\n\t}\r\n\r\n\t/**\r\n\t * Renders the separation elements to the canvas\r\n\t * @param {object} oCanvas - The main canvas we are drawing.\r\n\t * @param {object} oSyncCanvas - The canvas we need to sync the elements to.\r\n\t */\r\n\tfunction renderSeparationElements(oCanvas, oSyncCanvas, requestedOrder) {\r\n\t\t\r\n\t\t// Only render the separation elements if these are enabled.\r\n\t\tif (!g_oSeparations.AreSeparationsEnabled()) {\r\n\r\n\t\t\t// Remove the separations content.\r\n\t\t\t$(\"#divSeparationItems_Header\").hide();\r\n\t\t\t$(\"#divSeparationItems\").hide();\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Get the list of separation elements.\r\n\t\tvar oSeparationList = getSeparationElements(oCanvas, oSyncCanvas, requestedOrder);\r\n\r\n\t\t// Remove the current elements.\r\n\t\t$(\".sepDropZone\").remove();\r\n\t\t$(constants.c_szSeparationElementName).remove();\r\n\r\n\t\t// Reset the visible separations counter.\r\n\t\tthis.g_iVisibleSeparataionCount = 0;\r\n\r\n\t\t// Loop through each of the separations in the list.\r\n\t\tfor (var i = 0; i < oSeparationList.length; i++) {\r\n\r\n\t\t\t// If this separation is visible.\r\n\t\t\tif (oSeparationList[i].Visible) {\r\n\r\n\t\t\t\t// Increase the visible separations counter.\r\n\t\t\t\tthis.g_iVisibleSeparataionCount++;\r\n\t\t\t}\r\n\r\n\t\t\t// Add the Separation drop zone.\r\n\t\t\tvar oSeparationDropZone = document.createElement('div');\r\n\t\t\toSeparationDropZone.className = \"sepDropZone\";\r\n\r\n\t\t\t// Add the Separation.\r\n\t\t\toSeparationDropZone.id = i;\t\t// Need a unique ID that doesn't clash with the Inner Separation Div ID.\r\n\r\n\t\t\t// Add the Separation drop zone events.\r\n\t\t\toSeparationDropZone.ondragover = function (e) { separationOnDragOverEvent(e, this); };\r\n\t\t\toSeparationDropZone.ondrop = function (e) {\r\n\r\n\t\t\t\t// Update the separations on the main canvas, storing the list of ordered separations.\r\n\t\t\t\tvar oAllSeparationsOrdered = separationOnDropEvent(e, oCanvas);\r\n\r\n\t\t\t\t// Update the separations on each of the sync canvas.\r\n\t\t\t\tfor (var j = 0; j < oSyncCanvas.length; j++) {\r\n\t\t\t\t\tseparationOnDropEvent(e, oSyncCanvas[j]);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Re-render the separation elements with the requested order.\r\n\t\t\t\tsetupSeparationsDiv(oCanvas, false, oAllSeparationsOrdered);\r\n\t\t\t};\r\n\t\t\toSeparationDropZone.ondragleave = function (e) { separationOnDragLeaveEvent(e, this); };\r\n\r\n\t\t\t// Add the draggable swatch.\r\n\t\t\tvar oSwatch = document.createElement('div');\r\n\t\t\toSwatch.className = constants.c_szSwatchClassName;\r\n\t\t\toSwatch.draggable = true;\r\n\r\n\t\t\t// Amend the colour values.\r\n\t\t\toSwatch.style.backgroundColor = \"rgb(\" + oSeparationList[i].Red + \",\" + oSeparationList[i].Green + \",\" + oSeparationList[i].Blue + \")\";\r\n\r\n\t\t\t// Add swatch events.\r\n\t\t\toSwatch.ondragstart = function (e) {\r\n\t\t\t\te.dataTransfer.setData(\"text\", e.target.parentNode.id);\t\t// Setting the ID now as the dataTransfer will not be accessible when the function swatchDragStartEvent() is called due to the required delay.\r\n\t\t\t\tsetTimeout(function () { swatchDragStartEvent(e); }, 10);\t\t\t// Have to delay the call to the swatchDragStartEvent() function as Chrome fires the event before the initialisation of the Drag & Drop event has been completed.\r\n\t\t\t};\r\n\t\t\toSwatch.ondragend = function (e) { swatchOnDragEndEvent(e); };\r\n\r\n\t\t\t// Add the spinner element.\r\n\t\t\tvar oSpinner = document.createElement(\"input\");\r\n\t\t\toSpinner.src = \"img/spinner_16.gif\";\r\n\t\t\toSpinner.type = \"image\";\r\n\t\t\toSpinner.className = constants.c_szSpinnerClassName;\r\n\r\n\t\t\t// Add the colour change button.\r\n\t\t\tvar oColourChangeButton = document.createElement(\"input\");\r\n\t\t\toColourChangeButton.src = \"img/rgb_levels_16.png\";\r\n\t\t\toColourChangeButton.type = \"image\";\r\n\t\t\toColourChangeButton.className = constants.c_szColourChangeButtonClassName + \" \" + constants.c_szToolTipStyleClassName;\r\n\t\t\toColourChangeButton.title = constants.c_szSeparationChangeColourValuesToolTip;\r\n\r\n\t\t\t// Add the colour change button's events.\r\n\t\t\toColourChangeButton.addEventListener('click', function (e) {\r\n\t\t\t\tcolourChangeButtonOnClickEvent(e, oCanvas, this, true);\r\n\t\t\t\tfor (var l = 0; l < oSyncCanvas.length; l++) {\r\n\t\t\t\t\t// Determine if the colour change input has been made visible.\r\n\t\t\t\t\tvar oColourChange = checkColourChangeInputIsVisible(oSyncCanvas[l], this);\r\n\t\t\t\t\tcolourChangeButtonOnClickEvent(e, oSyncCanvas[l], this, !oColourChange.bColourChangeInputVisible);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\t// Add inner Separation div element.\r\n\t\t\tvar oInnerSeparationDiv = document.createElement('div');\r\n\t\t\toInnerSeparationDiv.className = \"innerSepDiv\";\r\n\t\t\toInnerSeparationDiv.style.verticalAlign = \"middle\";\r\n\t\t\toInnerSeparationDiv.innerHTML = oSeparationList[i].SeparationName;\r\n\t\t\toInnerSeparationDiv.draggable = \"true\";\r\n\r\n\t\t\t// Add the outer div element.\r\n\t\t\tvar oOuterSeparationDiv = document.createElement('div');\r\n\t\t\toOuterSeparationDiv.className = constants.c_szSeparationClassName + \" textNormal\" + (oSeparationList[i].Visible ? \"\" : \" \" + constants.c_szSeparationDisabledClassName);\r\n\t\t\toOuterSeparationDiv.id = getSeparationName(oSeparationList[i]);\t\t// Remove any whitespace from the ID.\r\n\r\n\t\t\t// Add the outer div events.\r\n\t\t\toOuterSeparationDiv.addEventListener('click', function (e) {\r\n\t\t\t\te.stopPropagation();\r\n\t\t\t\touterSeparationDivOnClickEvent(this, oCanvas, oSyncCanvas, true);\r\n\t\t\t}, false);\r\n\r\n\t\t\t// Add the child elements to the outer Separations div.\r\n\t\t\toOuterSeparationDiv.appendChild(oSwatch);\r\n\t\t\toOuterSeparationDiv.appendChild(oSpinner);\r\n\t\t\toOuterSeparationDiv.appendChild(oColourChangeButton);\r\n\t\t\toOuterSeparationDiv.appendChild(oInnerSeparationDiv);\r\n\r\n\t\t\t// Add the drop zone to the separation div.\r\n\t\t\tvar oSeparationDiv = document.getElementById(constants.c_szDivSeparationItemsClassName);\r\n\t\t\toSeparationDiv.appendChild(oSeparationDropZone);\r\n\t\t\toSeparationDiv.appendChild(oOuterSeparationDiv);\r\n\r\n\t\t\t// If this is the final separation in the list.\r\n\t\t\tif ((i + 1) == oSeparationList.length) {\r\n\r\n\t\t\t\t// Add a drop zone to the end of the separations list.\r\n\t\t\t\tvar oFinalSeparationDropZone = document.createElement('div');\r\n\t\t\t\toFinalSeparationDropZone.className = \"sepDropZone\";\r\n\r\n\t\t\t\t// Add the Separation.\r\n\t\t\t\toFinalSeparationDropZone.id = i + 1;\r\n\r\n\t\t\t\t// Add the Separation drop zone events.\r\n\t\t\t\toFinalSeparationDropZone.ondragover = function (e) { separationOnDragOverEvent(e, this); };\r\n\t\t\t\toFinalSeparationDropZone.ondrop = function (e) {\r\n\r\n\t\t\t\t\t// Update the separations on the main canvas, storing the list of ordered separations.\r\n\t\t\t\t\tvar oAllSeparationsOrdered = separationOnDropEvent(e, oCanvas);\r\n\r\n\t\t\t\t\t// Update the separations on each of the sync canvas.\r\n\t\t\t\t\tfor (var k = 0; k < oSyncCanvas.length; k++) {\r\n\t\t\t\t\t\tseparationOnDropEvent(e, oSyncCanvas[k]);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// Re-render the separation elements with the requested order.\r\n\t\t\t\t\tsetupSeparationsDiv(oCanvas, false, oAllSeparationsOrdered);\r\n\t\t\t\t};\r\n\t\t\t\toFinalSeparationDropZone.ondragleave = function (e) { separationOnDragLeaveEvent(e, this); };\r\n\r\n\t\t\t\t// Add the separation drop zone.\r\n\t\t\t\toSeparationDiv.appendChild(oFinalSeparationDropZone);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Finally, open any separations if they exist.\r\n\t\tif (typeof g_oSeparations.g_oSeparationOpen != \"undefined\" && g_oSeparations.g_oSeparationOpen.oID.length > 0) {\r\n\r\n\t\t\t// Find the element needed.\r\n\t\t\tvar bDisplayCheckBox = g_oSeparations.g_oSeparationOpen.displayAsBlackCheck;\r\n\r\n\t\t\t$('#' + g_oSeparations.g_oSeparationOpen.oID).find('input.colourChangeButton').click();\r\n\t\t\t$('#' + g_oSeparations.g_oSeparationOpen.oID).find('input.displayAsBlackCheckbox').prop('checked', bDisplayCheckBox);\r\n\r\n\t\t\tg_oSeparations.g_oSeparationOpen.displayAsBlackCheck = bDisplayCheckBox;\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Gets and sanitizes the separation name.\r\n\t * @param {string} separation The separation to get the name for.\r\n\t * @returns {string} Separation name.\r\n\t */\r\n\tfunction getSeparationName(separation) {\r\n\t\treturn sanitiseSeparationName(separation.SeparationName);\r\n\t}\r\n\r\n\t/**\r\n\t * Sanitizes a separation name.\r\n\t * @param {string} separationName - The separation name to sanitize.\r\n\t * @returns {string} Separation name.\r\n\t */\r\n\tfunction sanitiseSeparationName(separationName) {\r\n\t\treturn separationName.toLowerCase().replace(/[^a-z0-9]/gi, '');\r\n\t}\r\n\r\n\t/**\r\n\t * Toggles the overprint preview.\r\n\t */\r\n\tfunction toggleOverprintPreview() {\r\n\r\n\t\t// Update if we are showing the overprint preview.\r\n\t\tg_oSeparations.g_bOverprintPreview = $(\"#chkOverprintToggle\").prop(\"checked\");\r\n\r\n\t\t// If we are showing the overprint preview.\r\n\t\tif (g_oSeparations.g_bOverprintPreview) {\r\n\r\n\t\t\t// Check if we are in IE.\r\n\t\t\tvar bInternetExplorerBrowser = window.navigator.userAgent.indexOf(\"MSIE \") !== -1 || window.navigator.userAgent.indexOf('Trident/') !== -1;\r\n\r\n\t\t\t// If we are not in IE. (IE does not support the colour input type)\r\n\t\t\tif (!bInternetExplorerBrowser) {\r\n\r\n\t\t\t\t// Show the overprint colour option.\r\n\t\t\t\t$(\"#tdOverprintColour\").css(\"display\", \"block\");\r\n\t\t\t}\r\n\t\t}\r\n\t\t// If we are not showing the overprint preview.\r\n\t\telse {\r\n\r\n\t\t\t// Hide the overprint colour option.\r\n\t\t\t$(\"#tdOverprintColour\").css(\"display\", \"none\");\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * The separations 'on drop' event handler. Updates the separation orders.\r\n\t * @param {object} event - The event.\r\n\t * @param {object} oCanvas - The calling canvas.\r\n\t * @returns {object} - An object containing the updated separations list.\r\n\t */\r\n\tfunction separationOnDropEvent(event, oCanvas) {\r\n\t\tevent.preventDefault();\r\n\t\tevent.stopPropagation();\r\n\r\n\t\t// Reset the height of the drop zones.\r\n\t\t$(\".sepDropZone\").css(\"height\", \"0\");\r\n\r\n\t\t// Get the dragged item and destination.\r\n\t\tvar oDraggedItemId = event.dataTransfer.getData(\"text\");\r\n\t\tvar iDragDestination = event.target.id;\r\n\r\n\t\t// Get a list of the full separations.\r\n\t\tvar oAllSeparations = $(\"#divSeparationItems\").children(\".sep\");\r\n\r\n\t\t// Create a new array to order the separations.\r\n\t\tvar oAllSeparationsOrdered = [];\r\n\r\n\t\t// Create a new array to order the canvas separations.\r\n\t\tvar oCanvasSeparationsOrdered = [];\r\n\r\n\t\t// Get the dragged separation from the list.\r\n\t\tvar oDraggedSeparation = $.grep(oAllSeparations, function (separation) { return separation.id == oDraggedItemId; });\r\n\r\n\t\t// Perform the ordering update on the full separations list.\r\n\t\tfor (var i = 0; i < oAllSeparations.length; i++) {\r\n\r\n\t\t\t// Get the current separation.\r\n\t\t\tvar oSeparation = $.grep(oAllSeparations, function (separation) { return separation.id == oAllSeparations[i].id; });\r\n\r\n\t\t\t// If this is the desired position of the dragged separation.\r\n\t\t\tif (i === parseInt(iDragDestination)) {\r\n\r\n\t\t\t\t// Add the dragged separation.\r\n\t\t\t\toAllSeparationsOrdered.push(oDraggedSeparation[0]);\r\n\t\t\t}\r\n\r\n\t\t\t// If the separation is not the dragged separation.\r\n\t\t\tif (oSeparation[0].id != oDraggedSeparation[0].id) {\r\n\r\n\t\t\t\t// Add the current separation.\r\n\t\t\t\toAllSeparationsOrdered.push(oSeparation[0]);\r\n\t\t\t}\r\n\r\n\t\t\t// If the desired position is at the end of the separations, and this is the last separation.\r\n\t\t\tif ((i + 1) == oAllSeparations.length && (i + 1) === parseInt(iDragDestination)) {\r\n\r\n\t\t\t\t// Add the dragged separation.\r\n\t\t\t\toAllSeparationsOrdered.push(oDraggedSeparation[0]);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Perform the ordering update on the list of canvas separations.\r\n\t\tfor (var i = 0; i < oAllSeparationsOrdered.length; i++) {\r\n\r\n\t\t\t// Loop through each of the canvas separations.\r\n\t\t\tfor (var j = 0; j < oCanvas.g_oaImages.length; j++) {\r\n\r\n\t\t\t\t// If this is the matching separation.\r\n\t\t\t\tif (getSeparationName(oCanvas.g_oaImages[j]) == oAllSeparationsOrdered[i].id) {\r\n\r\n\t\t\t\t\t// Add the separation to the ordered list.\r\n\t\t\t\t\toCanvasSeparationsOrdered.push(oCanvas.g_oaImages[j]);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Update the separations with the newly ordered array.\r\n\t\toCanvas.g_oaImages = oCanvasSeparationsOrdered;\r\n\r\n\t\t// Get the image data with the newly ordered separations.\r\n\t\toCanvas.getimagePNGData(true, false);\r\n\r\n\t\t// Return the updated list of separations.\r\n\t\treturn oAllSeparationsOrdered;\r\n\t}\r\n\r\n\t/**\r\n\t * The swatches 'drag start' event handler.\r\n\t * @param {object} event - The event,\r\n\t */\r\n\tfunction swatchDragStartEvent(event) {\r\n\r\n\t\t// Set that we are currently dragging.\r\n\t\tg_bDragging = true;\r\n\r\n\t\t// Set the colour of the dragged element.\r\n\t\tg_oSeparations.g_oDraggedSeparationColour = $(event.target).css(\"background-color\");\r\n\r\n\t\t// Activate the drop zones.\r\n\t\t$(\".sepDropZone\").css(\"margin\", \"5px\");\r\n\t\t$(\".sepDropZone\").css(\"height\", \"20px\");\r\n\t\t$(\".sepDropZone\").css(\"border\", \"1px black dashed\");\r\n\t}\r\n\r\n\t/**\r\n\t * The separations 'on drag over' event handler. Updates the highlighted colour.\r\n\t * @param {object} event - The event\r\n\t * @param {object} _this - The calling object\r\n\t */\r\n\tfunction separationOnDragOverEvent(event, _this) {\r\n\t\tevent.preventDefault();\r\n\t\tevent.stopPropagation();\r\n\r\n\t\t// Apply the background colour of the drop zone.\r\n\t\t$(_this).css({ \"height\": \"20\", \"background-color\": g_oSeparations.g_oDraggedSeparationColour });\r\n\r\n\t\t// Check if the div should be auto scrolled.\r\n\t\tseparationOnDragAutoScroll(event);\r\n\t}\r\n\r\n\t/**\r\n\t * The separations 'on drag leave' event handler. Updates the highlighted colour.\r\n\t * @param {object} event - The event\r\n\t * @param {object} _this - The calling object\r\n\t */\r\n\tfunction separationOnDragLeaveEvent(event, _this) {\r\n\t\tevent.preventDefault();\r\n\t\tevent.stopPropagation();\r\n\r\n\t\t// Remove the background colour of the drop zone.\r\n\t\t$(_this).css({ \"height\": \"20\", \"background-color\": \"\" });\r\n\r\n\t\t// Check if the div should be auto scrolled.\r\n\t\tseparationOnDragAutoScroll(event);\r\n\t}\r\n\r\n\t/**\r\n\t * The separations 'on drag move' event handler. Updates the scroll position.\r\n\t * @param {object} event - The event.\r\n\t */\r\n\tfunction separationOnDragAutoScroll(event) {\r\n\r\n\t\t// If we are currently dragging.\r\n\t\tif (g_bDragging) {\r\n\r\n\t\t\t// Calculate the areas we want to trigger scrolling when the mouse is within.\r\n\t\t\tvar divPosition = $(\"#divSeparationItems\").offset();\r\n\t\t\tvar divHeight = $(\"#divSeparationItems\").css(\"height\");\r\n\t\t\tvar divHeight = parseInt(divHeight.substring(0, divHeight.indexOf(\"px\")), 10);\r\n\t\t\tvar iContentQtr = divHeight / 4;\r\n\r\n\t\t\t// Calculate the first and end quarter of the div.\r\n\t\t\tvar iFirstQtr = divPosition.top + iContentQtr;\r\n\t\t\tvar iEndQtr = divPosition.top + (iContentQtr * 3);\r\n\r\n\t\t\t// If we are within the last quarter of the div height.\r\n\t\t\tif (event.clientY > iEndQtr) {\r\n\r\n\t\t\t\t// Animate the div, scrolling it down.\r\n\t\t\t\t$(\"#divSeparationItems\").animate({ scrollTop: \"+=\" + 40 + \"px\" });\r\n\t\t\t}\r\n\t\t\t// If we are within the first quarter of the div height.\r\n\t\t\telse if (event.clientY < iFirstQtr) {\r\n\r\n\t\t\t\t// Animate the div, scrolling it up.\r\n\t\t\t\t$(\"#divSeparationItems\").animate({ scrollTop: \"-=\" + 40 + \"px\" });\r\n\t\t\t}\r\n\t\t\t// If we are not in either quarter.\r\n\t\t\telse {\r\n\r\n\t\t\t\t// Stop the scroll animation (clear any animations from the queue).\r\n\t\t\t\t$(\"#divSeparationItems\").stop(true);\r\n\t\t\t}\r\n\t\t}\r\n\t\t// If we are not dragging.\r\n\t\telse {\r\n\r\n\t\t\t// Stop the scroll animation (clear any animations from the queue).\r\n\t\t\t$(\"#divSeparationItems\").stop(true);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * The swatches 'on drag end' event handler.\r\n\t * @param {object} event - The event\r\n\t */\r\n\tfunction swatchOnDragEndEvent(event) {\r\n\r\n\t\t// Set that we are no longer dragging.\r\n\t\tg_bDragging = true;\r\n\r\n\t\t// Reset the colour of the dragged element.\r\n\t\tg_oSeparations.g_oDraggedSeparationColour = \"\";\r\n\r\n\t\t// Reset the drop zones.\r\n\t\t$(\".sepDropZone\").css(\"margin\", \"0px\");\r\n\t\t$(\".sepDropZone\").css(\"height\", \"0px\");\r\n\t\t$(\".sepDropZone\").css(\"border\", \"none\");\r\n\t}\r\n\r\n\t/**\r\n\t * Checks if the colour change input is visible.\r\n\t * @param {object} oCanvas - The Canvas Object\r\n\t * @param {object} _this - The Calling Object\r\n\t * @returns {object} - An object containing the following information:\r\n\t\t- The object ID\r\n\t\t- The associated colour separation\r\n\t\t- The containing element of the colour change inputs\r\n\t\t- If the colour change inputs are visible.\r\n\t */\r\n\tfunction checkColourChangeInputIsVisible(oCanvas, _this) {\r\n\t\tvar oColourChange = { oID: undefined, oResultSeparation: undefined, oDestinationContainer: undefined, bColourChangeInputVisible: false };\r\n\t\toColourChange.oID = $(_this).parent().attr(\"id\");\r\n\t\toColourChange.oResultSeparation = $.grep(oCanvas.g_oaImages, function (oSeparation) { return getSeparationName(oSeparation) == oColourChange.oID; });\r\n\t\toColourChange.oDestinationContainer = document.getElementById(oColourChange.oID);\r\n\t\toColourChange.bColourChangeInputVisible = $(_this).parent().children(constants.c_szColourInputElementName).length > 0;\r\n\r\n\t\treturn oColourChange;\r\n\t}\r\n\r\n\t/**\r\n\t * Method to clear the colour change input.\r\n\t * Removes all the elements associated with the colour change inputs.\r\n\t * @param {object} _this - The object to clear the colour input.\r\n\t */\r\n\tfunction clearColourChangeInput(_this) {\r\n\t\t$(_this).parent().children(constants.c_szColourInputElementName).remove();\r\n\t\t$(_this).parent().children(constants.c_szColourResetElementName).remove();\r\n\t\t$(_this).parent().children(constants.c_szDisplayAsBlackCheckboxElementName).remove();\r\n\t\t$(_this).parent().children(constants.c_szDisplayAsBlackLabelElementName).remove();\r\n\t\t$(_this)[0].classList.remove(\"colourChangeInputVisible\");\r\n\t\t$('.textNormal #divCheckBoxWrapper').remove();\r\n\t\tdelete g_oSeparations.g_oSeparationOpen;\r\n\t}\r\n\r\n\t/**\r\n\t * The function which renders the colour change inputs.\r\n\t * @param {object} event - The click event\r\n\t * @param {object} oCanvas - The canvas we are rendering to.\r\n\t * @param {object} _this - The object calling the function\r\n\t * @param {bool} setupColourChange - Are we initially setting up the colours?\r\n\t */\r\n\tfunction colourChangeButtonOnClickEvent(event, oCanvas, _this, setupColourChange) {\r\n\r\n\t\tevent.stopPropagation();\r\n\r\n\t\tvar oColourChange = checkColourChangeInputIsVisible(oCanvas, _this);\r\n\r\n\t\t// If we are setting up the colour change.\r\n\t\tif (setupColourChange && oColourChange.oResultSeparation.length > 0) {\r\n\r\n\t\t\tif (oColourChange.bColourChangeInputVisible || $(_this).parent().attr('class').indexOf(g_oSeparations.SeparationDisabledClassName) > -1) {\r\n\t\t\t\tclearColourChangeInput(_this);\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tvar oaVisibleColourChangeInputsArray = document.getElementsByClassName(\"colourChangeInputVisible\");\r\n\t\t\t\tfor (var j = 0; j < oaVisibleColourChangeInputsArray.length; j++) {\r\n\t\t\t\t\tif (oaVisibleColourChangeInputsArray[j].id != oColourChange.oID) {\r\n\t\t\t\t\t\tclearColourChangeInput(oaVisibleColourChangeInputsArray[j]);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Add the colour element to the global element.\r\n\t\t\t\tg_oSeparations.g_oSeparationOpen = deepCopyObject(oColourChange);\r\n\t\t\t\tg_oSeparations.g_oSeparationOpen.displayAsBlackCheck = true;\r\n\r\n\t\t\t\t_this.classList.add(\"colourChangeInputVisible\");\r\n\r\n\t\t\t\t// Determine if the RGB input values are disabled.\r\n\t\t\t\tvar bInputDisabled = g_oSeparations.g_oSeparationOpen.oID == \"cyan\" || g_oSeparations.g_oSeparationOpen.oID == \"magenta\" || g_oSeparations.g_oSeparationOpen.oID == \"yellow\" || g_oSeparations.g_oSeparationOpen.oID == \"black\";\r\n\r\n\t\t\t\tvar oInputR = document.createElement(\"input\");\r\n\t\t\t\toInputR.type = \"text\";\r\n\t\t\t\toInputR.className = constants.c_szColourInputClassName + \" \" + constants.c_szToolTipStyleClassName;\r\n\t\t\t\toInputR.title = bInputDisabled ? constants.c_szSeparationRGBValueProcessToolTip : constants.c_szSeparationRGBValueRedToolTip;\r\n\t\t\t\toInputR.value = oColourChange.oResultSeparation[0].Red;\r\n\t\t\t\toInputR.style.backgroundColor = \"rgba(255,0,0,0.1)\";\r\n\t\t\t\toInputR.disabled = bInputDisabled;\r\n\t\t\t\toColourChange.oDestinationContainer.appendChild(oInputR);\r\n\r\n\t\t\t\tvar oInputG = document.createElement(\"input\");\r\n\t\t\t\toInputG.type = \"text\";\r\n\t\t\t\toInputG.className = constants.c_szColourInputClassName + \" \" + constants.c_szToolTipStyleClassName;\r\n\t\t\t\toInputG.title = bInputDisabled ? constants.c_szSeparationRGBValueProcessToolTip : constants.c_szSeparationRGBValueGreenToolTip;\r\n\t\t\t\toInputG.value = oColourChange.oResultSeparation[0].Green;\r\n\t\t\t\toInputG.style.backgroundColor = \"rgba(0,255,0,0.1)\";\r\n\t\t\t\toInputG.disabled = bInputDisabled;\r\n\t\t\t\toColourChange.oDestinationContainer.appendChild(oInputG);\r\n\r\n\t\t\t\tvar oInputB = document.createElement(\"input\");\r\n\t\t\t\toInputB.type = \"text\";\r\n\t\t\t\toInputB.className = constants.c_szColourInputClassName + \" \" + constants.c_szToolTipStyleClassName;\r\n\t\t\t\toInputB.title = bInputDisabled ? constants.c_szSeparationRGBValueProcessToolTip : constants.c_szSeparationRGBValueBlueToolTip;\r\n\t\t\t\toInputB.value = oColourChange.oResultSeparation[0].Blue;\r\n\t\t\t\toInputB.style.backgroundColor = \"rgba(0,0,255,0.1)\";\r\n\t\t\t\toInputB.disabled = bInputDisabled;\r\n\t\t\t\toColourChange.oDestinationContainer.appendChild(oInputB);\r\n\r\n\t\t\t\tvar oInputOpaque = document.createElement(\"SELECT\");\r\n\t\t\t\tvar oSelectArray = [\"normal\", \"opaque\", \"varnish\", \"technical\"];\r\n\r\n\t\t\t\tfor (var i = 0; i < oSelectArray.length; i++) {\r\n\t\t\t\t\tvar oMenuOption = document.createElement(\"option\");\r\n\t\t\t\t\toMenuOption.value = oSelectArray[i];\r\n\t\t\t\t\toMenuOption.text = oSelectArray[i];\r\n\t\t\t\t\toInputOpaque.appendChild(oMenuOption);\r\n\t\t\t\t}\r\n\r\n\t\t\t\toInputOpaque.className = constants.c_szColourInputClassName + \" \" + constants.c_szColourInputOpacityDropdownClassName + \" \" + constants.c_szToolTipStyleClassName;\r\n\t\t\t\toInputOpaque.title = bInputDisabled ? constants.c_szSeparationRGBValueProcessToolTip : constants.c_szSeparationOpacityValueToolTip;\r\n\t\t\t\toInputOpaque.value = oColourChange.oResultSeparation[0].Opaque === \"none\" ? \"normal\" : oColourChange.oResultSeparation[0].Opaque;\r\n\t\t\t\toInputOpaque.style.width = \"80px\";\r\n\t\t\t\toInputOpaque.disabled = bInputDisabled;\r\n\t\t\t\toColourChange.oDestinationContainer.appendChild(oInputOpaque);\r\n\r\n\t\t\t\t// Add in the div to wrap the black checkbox and reset button.\r\n\t\t\t\t$(oColourChange.oDestinationContainer).append(\"
\");\r\n\r\n\t\t\t\t// Add the display as black checkbox if this is the last enabled separation.\r\n\t\t\t\tif (g_oSeparations.g_iVisibleSeparataionCount == 1) {\r\n\t\t\t\t\tvar oSeparation = $.grep(oCanvas.g_oaImages, function (oSeparationItem) { return getSeparationName(oSeparationItem) == oColourChange.oID; });\r\n\t\t\t\t\tcreateDisplayAsBlackControls(oSeparation[0], oColourChange, oCanvas);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tvar oColourResetButton = document.createElement(\"input\");\r\n\t\t\t\toColourResetButton.src = \"img/Reset-Form_col_16 blue.png\";\r\n\t\t\t\toColourResetButton.type = \"image\";\r\n\t\t\t\toColourResetButton.className = constants.c_szColourResetClassName + \" \" + constants.c_szToolTipStyleClassName;\r\n\t\t\t\toColourResetButton.title = constants.c_szSeparationResetChangeColourValuesToolTip;\r\n\t\t\t\toColourChange.oDestinationContainer.appendChild(oColourResetButton);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Add the events to the elements.\r\n\t\t$(constants.c_szColourInputElementName).on('click', function (e) { e.stopPropagation(); });\r\n\t\t$(constants.c_szColourInputElementName).on('focusout', function () { colourChangeInputsUpdateImage(oCanvas, oColourChange, _this); });\r\n\t\t$(constants.c_szColourInputOpacityDropdownElementName).on('change', function () { colourChangeInputsUpdateImage(oCanvas, oColourChange, _this); });\r\n\t\t$(\".\" + constants.c_szColourResetClassName).on('click', function (e) { colourResetButtonOnClickEvent(e, this, oCanvas); });\r\n\t\t$(\".\" + constants.c_szDisplayAsBlackCheckboxClassName).on('click', function (e) { displayAsBlackCheckboxClickEvent(e, this, oCanvas); });\r\n\t}\r\n\r\n\t/**\r\n\t * Function used to update the image based on the values in the colour change inputs.\r\n\t * @param {object} oCanvas - The artwork viewer.\r\n\t * @param {object} oColourChange - The colour change object.\r\n\t * @param {object} _this - The calling object\r\n\t */\r\n\tfunction colourChangeInputsUpdateImage(oCanvas, oColourChange, _this) {\r\n\t\tvar oResult = $.grep(oCanvas.g_oaImages, function (oSeparation) { return getSeparationName(oSeparation) == oColourChange.oID; });\r\n\r\n\t\tvar oInputs = $(_this).parent().children(constants.c_szColourInputElementName);\r\n\r\n\t\toResult[0].Red = oInputs[0].value = Number(validateColourValueInput(oInputs[0].value) ? oInputs[0].value : oResult[0].OrigRed);\r\n\t\toResult[0].Green = oInputs[1].value = Number(validateColourValueInput(oInputs[1].value) ? oInputs[1].value : oResult[0].OrigGreen);\r\n\t\toResult[0].Blue = oInputs[2].value = Number(validateColourValueInput(oInputs[2].value) ? oInputs[2].value : oResult[0].OrigBlue);\r\n\t\toResult[0].Opaque = oInputs[3].value;\r\n\r\n\t\tvar oSwatch = $(_this).parent().children(\".\" + constants.c_szSwatchClassName);\r\n\t\toSwatch[0].style.backgroundColor = \"rgb(\" + oInputs[0].value + \",\" + oInputs[1].value + \",\" + oInputs[2].value + \")\";\r\n\r\n\t\toCanvas.getimagePNGData(true, false);\r\n\t}\r\n\r\n\t/**\r\n\t * Validates the colour value input. Checks that the input value is a valid integer between 0 and 255.\r\n\t * @param {int} oInputValue - The input value.\r\n\t * @returns {bool}\r\n\t */\r\n\tfunction validateColourValueInput(oInputValue) {\r\n\t\tif (isInt(oInputValue)) {\r\n\t\t\treturn (oInputValue >= 0) && (oInputValue <= 255);\t// Value to be between 0 and 255 inclusive.\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t}\r\n\r\n\t/**\r\n\t * The 'on click' event for the outer separation div. This enables or disables a colour separation item.\r\n\t * @param {object} _this - The calling object\r\n\t * @param {object} oCanvas - The artwork canvas\r\n\t * @param {object} oSyncCanvas - The canvas we need to sync to for compare mode.\r\n\t * @param {bool} getImageData - If the image data should be requested for the canvas.\r\n\t */\r\n\tfunction outerSeparationDivOnClickEvent(_this, oCanvas, oSyncCanvas, getImageData) {\r\n\t\t\r\n\t\t// Toggle the canvas images on the main canvas.\r\n\t\tg_oSeparations.ToggleCanvasImages(_this, oCanvas);\r\n\r\n\t\t// Toggle the canvas images on the sync canvas.\r\n\t\tfor (var i = 0; i < oSyncCanvas.length; i++) {\r\n\t\t\tg_oSeparations.ToggleCanvasImages(_this, oSyncCanvas[i]);\r\n\t\t}\r\n\r\n\t\t// If we require image data for the canvas.\r\n\t\tif (getImageData) {\r\n\r\n\t\t\t// We are getting the whole image back and drawing to canvas.\r\n\t\t\toCanvas.getimagePNGData(true, false);\r\n\r\n\t\t\t// Get the image data for each of the sync canvas.\r\n\t\t\tfor (var i = 0; i < oSyncCanvas.length; i++) {\r\n\t\t\t\toSyncCanvas[i].getimagePNGData(true, false);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Gets the visible separation count.\r\n\t * @param {object} oCanvas - The artwork viewer.\r\n\t * @returns {int} - The number of separations\r\n\t */\r\n\tfunction getVisibleCanvasSeparationsCount(oCanvas) {\r\n\r\n\t\t// Declare a variable to hold the number of visible separations.\r\n\t\tvar iVisibleSeparations = 0;\r\n\r\n\t\t// Get the separation elements from the canvas.\r\n\t\tvar oSeparationList = oCanvas.g_oaImages;\r\n\r\n\t\t// Loop through each of the separations on the canvas.\r\n\t\tfor (var i = 0; i < oSeparationList.length; i++) {\r\n\r\n\t\t\t// If the separation is visible.\r\n\t\t\tif (oSeparationList[i].Visible) {\r\n\r\n\t\t\t\t// Add this to the number of visible separations.\r\n\t\t\t\tiVisibleSeparations++;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Return the number of visible separations.\r\n\t\treturn iVisibleSeparations;\r\n\t}\r\n\r\n\t/**\r\n\t * Steps through the separations on the canvas.\r\n\t */\r\n\tfunction stepThroughCanvasImages(oCanvas, oSyncCanvas) {\r\n\r\n\t\t// If we have only one separation enabled.\r\n\t\tif ($(\"#divSeparationItems\").children(\".sep\").not(\".separationDisabled\").length == 1) {\r\n\r\n\t\t\t// Get the separation.\r\n\t\t\tvar oSeparation = $(\"#divSeparationItems\").children(\".sep\").not(\".separationDisabled\")[0];\r\n\r\n\t\t\t// If there is another separation in the list.\r\n\t\t\tif ($(\"#divSeparationItems\").children(\".sep\").not(\".separationDisabled\").next().next().length > 0) {\r\n\r\n\t\t\t\t// Enable the next separation.\r\n\t\t\t\touterSeparationDivOnClickEvent($(\"#divSeparationItems\").children(\".sep\").not(\".separationDisabled\").next().next()[0], oCanvas, oSyncCanvas, false);\r\n\t\t\t}\r\n\t\t\t// If there is not another separation in the list.\r\n\t\t\telse {\r\n\r\n\t\t\t\t// Enable the first separation.\r\n\t\t\t\touterSeparationDivOnClickEvent($(\"#\" + $(\"#divSeparationItems\").children(\".sep\")[0].id)[0], oCanvas, oSyncCanvas, false);\r\n\t\t\t}\r\n\r\n\t\t\t// Disable the current separation.\r\n\t\t\touterSeparationDivOnClickEvent($(\"#\" + oSeparation.id)[0], oCanvas, oSyncCanvas, false);\r\n\t\t}\r\n\t\t// Disable all but the first separation.\r\n\t\telse {\r\n\r\n\t\t\t// Get a list of all separations.\r\n\t\t\tvar oSeparations = $(\"#divSeparationItems\").children(\".sep\");\r\n\r\n\t\t\t// Loop through each of the separations.\r\n\t\t\tfor (var i = 0; i < oSeparations.length; i++) {\r\n\r\n\t\t\t\t// If this is the first separation.\r\n\t\t\t\tif (i == 0) {\r\n\r\n\t\t\t\t\t// If the separation is not enabled.\r\n\t\t\t\t\tif (oSeparations[i].className.indexOf(\"separationDisabled\") != -1) {\r\n\r\n\t\t\t\t\t\t// Enable the separation.\r\n\t\t\t\t\t\touterSeparationDivOnClickEvent($(\"#\" + oSeparations[i].id)[0], oCanvas, oSyncCanvas, false);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t// If this is not the first separation.\r\n\t\t\t\telse {\r\n\r\n\t\t\t\t\t// If the separation is not disabled.\r\n\t\t\t\t\tif (oSeparations[i].className.indexOf(\"separationDisabled\") == -1) {\r\n\r\n\t\t\t\t\t\t// Disable the separation.\r\n\t\t\t\t\t\touterSeparationDivOnClickEvent($(\"#\" + oSeparations[i].id)[0], oCanvas, oSyncCanvas, false);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Get the image data for the main canvas.\r\n\t\toCanvas.getimagePNGData(true, false);\r\n\r\n\t\t// Get the image data for each of the sync canvas.\r\n\t\tfor (var i = 0; i < oSyncCanvas.length; i++) {\r\n\t\t\toSyncCanvas[i].getimagePNGData(true, false);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Resets the separations on the canvas.\r\n\t * @param {object} oCanvas - The artwork viewer.\r\n\t */\r\n\tfunction resetAllCanvasImages(oCanvas) {\r\n\r\n\t\t// Get the separation elements from the canvas.\r\n\t\tvar oSeparationList = oCanvas.g_oaImages;\r\n\r\n\t\t// Loop through each of the separations on the canvas.\r\n\t\tfor (var i = 0; i < oSeparationList.length; i++) {\r\n\r\n\t\t\t// Find the separation.\r\n\t\t\tvar clickedSwatch = $(\"#\" + getSeparationName(oSeparationList[i]));\r\n\t\t\tvar _this = $(clickedSwatch).find(constants.c_szColourChangeButtonElementName)[0];\r\n\t\t\tvar oColourChange = checkColourChangeInputIsVisible(oCanvas, _this);\r\n\r\n\t\t\t// If the separation is currently not visible.\r\n\t\t\tif (oSeparationList[i].Visible == false) {\r\n\r\n\t\t\t\t// Set that the separation is visible.\r\n\t\t\t\toSeparationList[i].Visible = true;\r\n\r\n\t\t\t\t// If the separation is not already enabled within the list.\r\n\t\t\t\tif ($(clickedSwatch).attr(\"class\").indexOf(constants.c_szSeparationDisabledClassName) != - 1) {\r\n\r\n\t\t\t\t\t// Enable the clicked swatch.\r\n\t\t\t\t\t$(clickedSwatch).removeClass(constants.c_szSeparationDisabledClassName);\r\n\t\t\t\t\tthis.g_iVisibleSeparataionCount++;\r\n\t\t\t\t\t$(_this)[0].style.visibility = \"visible\";\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// If the Colour Change Input is visible, hide it.\r\n\t\t\tif (oColourChange.bColourChangeInputVisible) {\r\n\t\t\t\tclearColourChangeInput(_this);\r\n\t\t\t}\r\n\r\n\t\t\t// Reset the separation back to the original colours.\r\n\t\t\toSeparationList[i].Red = oSeparationList[i].OrigRed;\r\n\t\t\toSeparationList[i].Green = oSeparationList[i].OrigGreen;\r\n\t\t\toSeparationList[i].Blue = oSeparationList[i].OrigBlue;\r\n\t\t\toSeparationList[i].Opaque = oSeparationList[i].OrigOpaque === \"none\" ? \"normal\" : oSeparationList[i].OrigOpaque;\r\n\r\n\t\t\t// Update the swatch with the colour change.\r\n\t\t\tvar oSwatch = $(_this).parent().children(\".\" + constants.c_szSwatchClassName);\r\n\t\t\toSwatch[0].style.backgroundColor = \"rgb(\" + oSeparationList[i].Red + \",\" + oSeparationList[i].Green + \",\" + oSeparationList[i].Blue + \")\";\r\n\t\t}\r\n\r\n\t\t// We are getting the whole image back and drawing to canvas.\r\n\t\toCanvas.getimagePNGData(true, false);\r\n\t}\r\n\r\n\t/**\r\n\t * Disables canvas images.\r\n\t * @param {object} clickedSwatch - The clicked swatch from the separation list.\r\n\t * @param {object} oCanvas - The artwork viewer.\r\n\t */\r\n\tfunction disableCanvasImages(clickedSwatch, oCanvas) {\r\n\r\n\t\t// Get the separation elements from the canvas.\r\n\t\tvar oSeparationList = oCanvas.g_oaImages;\r\n\r\n\t\t// Loop through each of the separations on the canvas.\r\n\t\tfor (var i = 0; i < oSeparationList.length; i++) {\r\n\r\n\t\t\t// If this is the matching separation.\r\n\t\t\tif (getSeparationName(oSeparationList[i]) === clickedSwatch.id.toLowerCase()) {\r\n\r\n\t\t\t\t// Find the separation.\r\n\t\t\t\tvar _this = $(clickedSwatch).find(constants.c_szColourChangeButtonElementName)[0];\r\n\t\t\t\tvar oColourChange = checkColourChangeInputIsVisible(oCanvas, _this);\r\n\r\n\t\t\t\t// If the separation is currently visible.\r\n\t\t\t\tif (oSeparationList[i].Visible === true) {\r\n\r\n\t\t\t\t\t// Must keep at least one separation visible.\r\n\t\t\t\t\tif (this.g_iVisibleSeparataionCount > 1 || this.GetVisibleCanvasSeparationsCount(oCanvas) > 1) {\r\n\r\n\t\t\t\t\t\t// Set that the separation is not visible.\r\n\t\t\t\t\t\toSeparationList[i].Visible = false;\r\n\r\n\t\t\t\t\t\t// If the separation is not already disabled within the list.\r\n\t\t\t\t\t\tif ($(clickedSwatch).attr(\"class\").indexOf(constants.c_szSeparationDisabledClassName) == -1) {\r\n\r\n\t\t\t\t\t\t\t// Disable the clicked swatch.\r\n\t\t\t\t\t\t\t$(clickedSwatch).addClass(constants.c_szSeparationDisabledClassName);\r\n\t\t\t\t\t\t\tthis.g_iVisibleSeparataionCount--;\r\n\r\n\t\t\t\t\t\t\t// If the Colour Change Input is visible, hide it.\r\n\t\t\t\t\t\t\tif (oColourChange.bColourChangeInputVisible) {\r\n\t\t\t\t\t\t\t\tclearColourChangeInput(_this);\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t// Update the visibility.\r\n\t\t\t\t\t\t\t$(_this)[0].style.visibility = \"hidden\";\r\n\r\n\t\t\t\t\t\t\t// Hide any separation percentages and barcodes.\r\n\t\t\t\t\t\t\t$(clickedSwatch).children('.innerSepDiv').children(g_oTechTools.c_szSeparationPercentageElementName).hide();\r\n\r\n\t\t\t\t\t\t\t// Hide any separation barcodes.\r\n\t\t\t\t\t\t\t$(clickedSwatch).children(g_oTechTools.c_szSeparationPercentage_BarcodeElementName).hide();\r\n\r\n\t\t\t\t\t\t\tvar szSeparationElementName = \"#\" + getSeparationName(oSeparationList[i]);\r\n\t\t\t\t\t\t\tif ($(szSeparationElementName).find(g_oTechTools.c_szSeparationPercentageElementName).length > 0) {\r\n\r\n\t\t\t\t\t\t\t\t// Get the current percentage of the colour which is selected to be removed.\r\n\t\t\t\t\t\t\t\tvar szCurrentPercentageOfColour = $(szSeparationElementName).find(g_oTechTools.c_szSeparationPercentageElementName).text();\r\n\t\t\t\t\t\t\t\tvar iPercentageNumberOfColour = parseInt(szCurrentPercentageOfColour) || 0;\r\n\r\n\t\t\t\t\t\t\t\t// Get the current total area coverage percentage.\r\n\t\t\t\t\t\t\t\tvar szCurrentTACPercentage = $('#td_TAC').text().replace(g_oTechTools.g_szTACFieldDefault,'');\r\n\t\t\t\t\t\t\t\tvar iPercentageNumberTAC = parseInt(szCurrentTACPercentage) || 0;\r\n\r\n\t\t\t\t\t\t\t\t// Remove the percentage, update the field.\r\n\t\t\t\t\t\t\t\tvar iUpdatedTAC = iPercentageNumberTAC - iPercentageNumberOfColour;\r\n\t\t\t\t\t\t\t\t$('#td_TAC').text(g_oTechTools.g_szTACFieldDefault + iUpdatedTAC + \"%\");\r\n\r\n\t\t\t\t\t\t\t\t// Removes the percentage div.\r\n\t\t\t\t\t\t\t\t$(szSeparationElementName).children('.innerSepDiv').children(g_oTechTools.c_szSeparationPercentageElementName).remove();\r\n\r\n\t\t\t\t\t\t\t\t// Removes the barcode div.\r\n\t\t\t\t\t\t\t\t$(szSeparationElementName).children(g_oTechTools.c_szSeparationPercentage_BarcodeElementName).remove();\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t// If the separation is currently not visible.\r\n\t\t\t\telse {\r\n\r\n\t\t\t\t\t// Set that the separation is visible.\r\n\t\t\t\t\toSeparationList[i].Visible = true;\r\n\r\n\t\t\t\t\t// If the separation is not already enabled within the list.\r\n\t\t\t\t\tif ($(clickedSwatch).attr(\"class\").indexOf(constants.c_szSeparationDisabledClassName) != - 1) {\r\n\r\n\t\t\t\t\t\t// Enable the clicked swatch.\r\n\t\t\t\t\t\t$(clickedSwatch).removeClass(constants.c_szSeparationDisabledClassName);\r\n\t\t\t\t\t\tthis.g_iVisibleSeparataionCount++;\r\n\t\t\t\t\t\t$(_this)[0].style.visibility = \"visible\";\r\n\t\t\t\t\t\t$(clickedSwatch).children('.innerSepDiv').children('.separationPercentage').show();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Determine if there are multiple separations visible.\r\n\t\tvar bMultipleSeparationsEnabled = this.g_iVisibleSeparataionCount > 1;\r\n\r\n\t\tvar bContainsDensityPercentage = false;\r\n\r\n\t\t// Loop through each of the separations.\r\n\t\tfor (var i = 0; i < oSeparationList.length; i++) {\r\n\r\n\t\t\t// Get the separation element.\r\n\t\t\tvar szSeparationElementName = \"#\" + getSeparationName(oSeparationList[i]);\r\n\r\n\t\t\t// Look for a density percentage on each of the separations, if one exists set the boolean to be true.\r\n\t\t\tif (($(szSeparationElementName).find(g_oTechTools.c_szSeparationPercentageElementName).length > 0) && !bContainsDensityPercentage) {\r\n\t\t\t\tbContainsDensityPercentage = true;\r\n\t\t\t}\r\n\r\n\t\t\t// If we are the last item and we haven't got a density percentage, hide the TAC field\r\n\t\t\tif (i === (oSeparationList.length - 1) && !bContainsDensityPercentage) {\r\n\t\t\t\t$('#td_TAC').hide();\r\n\t\t\t}\r\n\r\n\t\t\t// If there are multiple separations visible and this element has the display as black checkbox.\r\n\t\t\tif (bMultipleSeparationsEnabled && ($(szSeparationElementName).find(constants.c_szDisplayAsBlackCheckboxElementName).length > 0)) {\r\n\r\n\t\t\t\t// Remove the display as black checkbox.\r\n\t\t\t\t$(szSeparationElementName).children(constants.c_szDisplayAsBlackCheckboxElementName).remove();\r\n\t\t\t\t$(szSeparationElementName).children(constants.c_szDisplayAsBlackLabelElementName).remove();\r\n\t\t\t}\r\n\t\t\t// If there are not multiple separations visible and this element does not have the display as black checkbox.\r\n\t\t\telse if (!bMultipleSeparationsEnabled) {\r\n\r\n\t\t\t\t// Check if the colour change input is visible.\r\n\t\t\t\tvar oColourChange = checkColourChangeInputIsVisible(oCanvas, $(szSeparationElementName).find(constants.c_szColourChangeButtonElementName));\r\n\r\n\t\t\t\t// If the colour change input is visible.\r\n\t\t\t\tif (oColourChange.bColourChangeInputVisible) {\r\n\r\n\t\t\t\t\t// If the display as black checkbox does not exist.\r\n\t\t\t\t\tif ($(szSeparationElementName).find(constants.c_szDisplayAsBlackCheckboxElementName).length === 0) {\r\n\r\n\t\t\t\t\t\t// Create the display as black checkbox.\r\n\t\t\t\t\t\tcreateDisplayAsBlackControls(oSeparationList[i], oColourChange, oCanvas);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// Add the display as black checkbox event.\r\n\t\t\t\t\t$(\".\" + constants.c_szDisplayAsBlackCheckboxClassName).on('click', function (e) { displayAsBlackCheckboxClickEvent(e, this, oCanvas); });\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 * Sets the separation visibility.\r\n\t * @param {any} oCanvas - The main canvas.\r\n\t * @param {any} oSyncCanvas - The sync canvas.\r\n\t * @param {any} separationName - The separation name.\r\n\t * @param {any} visible\r\n\t */\r\n\tfunction setSeparationVisibility(oCanvas, oSyncCanvas, separationName, visible) {\r\n\r\n\t\t// Update the visible layers count.\r\n\t\tthis.g_iVisibleSeparataionCount = visible ? this.g_iVisibleSeparataionCount + 1 : this.g_iVisibleSeparataionCount - 1;\r\n\r\n\t\t// Set the visibility on the main canvas.\r\n\t\tsetSeparationCanvasVisibility(oCanvas, separationName, visible);\r\n\r\n\t\t// Set the visibility on each of the sync canvas.\r\n\t\tfor (var i = 0; i < oSyncCanvas.length; i++) {\r\n\t\t\tsetSeparationCanvasVisibility(oSyncCanvas[i], separationName, visible);\r\n\t\t}\r\n\r\n\t\t// We are getting the whole image back and drawing to canvas.\r\n\t\toCanvas.getimagePNGData(true, false);\r\n\r\n\t\t// Get the image data for each of the sync canvas.\r\n\t\tfor (var i = 0; i < oSyncCanvas.length; i++) {\r\n\t\t\toSyncCanvas[i].getimagePNGData(true, false);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Sets the separation visbility of a separation on a canvas.\r\n\t * @param {any} oCanvas - The canvas.\r\n\t * @param {any} separationName - The separation name.\r\n\t * @param {any} visibility - The visibility.\r\n\t */\r\n\tfunction setSeparationCanvasVisibility(oCanvas, separationName, visibility) {\r\n\r\n\t\t// Get the separation elements from the canvas.\r\n\t\tvar oSeparationList = oCanvas.g_oaImages;\r\n\r\n\t\t// Loop through each of the separations on the canvas.\r\n\t\tfor (var i = 0; i < oSeparationList.length; i++) {\r\n\r\n\t\t\t// If this is the matching separation.\r\n\t\t\tif (sanitiseSeparationName(oSeparationList[i].SeparationName) == sanitiseSeparationName(separationName)) {\r\n\r\n\t\t\t\t// Set the visibility of the separation.\r\n\t\t\t\toSeparationList[i].Visible = visibility;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Sets the separation visibility defaults.\r\n\t * @param {any} oSeparations - The separations.\r\n\t * @param {any} oHiddenSeparations - The hidden separations.\r\n\t */\r\n\tfunction setSeparationVisibilityDefaults(oSeparations, oHiddenSeparations) {\r\n\r\n\t\t// Loop through each of the separations.\r\n\t\tfor (var i = 0; i < oSeparations.length; i++) {\r\n\r\n\t\t\t// Loop through each of the hidden separations.\r\n\t\t\tfor (var j = 0; j < oHiddenSeparations.length; j++) {\r\n\r\n\t\t\t\t// If this separation is hidden.\r\n\t\t\t\tif (sanitiseSeparationName(oSeparations[i].SeparationName) == sanitiseSeparationName(oHiddenSeparations[j])) {\r\n\r\n\t\t\t\t\t// Set the separation to hidden.\r\n\t\t\t\t\toSeparations[i].Visible = false;\r\n\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 * Sets up the separations div ready to receive the colour separation items.\r\n\t * @param {object} oCanvas - The selected canvas.\r\n\t * @param {bool} bSetupCanvas - Boolean to indicate if the canvas is being set up for the first time and needs the navigation canvas setting up.\r\n\t * @param {array} saRequestedOrder - The requested order.\r\n\t */\r\n\tfunction setupSeparationsDiv(oCanvas, bSetupCanvas, saRequestedOrder) {\r\n\t\t\r\n\t\t// Check if the canvas has separations.\r\n\t\tif (oCanvas.hasSeparations() && (g_oViewer.g_oCompareMode == eCompareMode.NoCompare || g_oCompare.g_oCompareViewer.hasSeparations())) {\r\n\r\n\t\t\t// Set the width and height of the div.\r\n\t\t\t$(\"#divSepDiv\").css(\"width\", oCanvas.g_oCanvas.width / 5);\r\n\t\t\t$(\"#divSepDiv\").css(\"height\", oCanvas.g_oCanvas.height);\r\n\r\n\t\t\t// Make sure the top of the annotations menu lines up beneath the approval status bar.\r\n\t\t\t$(\"#divSepContainer\").css(\"top\", ($(\"#divViewerCell\").offset().top));\r\n\r\n\t\t\t// Slide the menu to the correct position.\r\n\t\t\tslideDiv($(\"#divSepContainer\"), false, false);\r\n\r\n\t\t\t// Set the height of the navigator divs.\r\n\t\t\t$(\"#divNavigatorDisabled\").css(\"height\", oCanvas.g_oCanvas.height * 0.2 / g_oViewer.c_iDPI);\r\n\t\t\t$(\"#divNavCanvasHolder\").css(\"height\", oCanvas.g_oCanvas.height * 0.2 / g_oViewer.c_iDPI);\r\n\r\n\t\t\t// If this is the initial setup we need to setup the canvas.\r\n\t\t\tif (bSetupCanvas) {\r\n\r\n\t\t\t\t// Clear the navigation canvas holder.\r\n\t\t\t\tg_oViewer.clearCanvasHolder(\"divNavCanvasHolder\", \"navCanvas\");\r\n\t\t\t\tg_oViewer.clearCanvasHolder(\"divNavCanvasHolder\", \"navCanvasOverlay\");\r\n\r\n\t\t\t\t// Create the navigation canvas.\r\n\t\t\t\toCanvas.g_oNavCanvasObj = new Canvas(\"divNavCanvasHolder\", \"navCanvas\", \"navCanvas\", null, 0, null, false, eCanvasType.Artwork, \"\");\r\n\t\t\t\toCanvas.g_oNavCanvasOver = new Canvas(\"divNavCanvasHolder\", \"navCanvasOverlay\", \"navCanvasOverlay\", null, 0, null, false, eCanvasType.Artwork, \"\");\r\n\r\n\t\t\t\t// Update the container of the navigation canvas to be the canvas holder.\r\n\t\t\t\toCanvas.g_oNavCanvasObj.g_oContainer = $(\"#divCanvasHolder\")[0];\r\n\t\t\t\toCanvas.g_oNavCanvasOver.g_oContainer = $(\"#divCanvasHolder\")[0];\r\n\r\n\t\t\t\t$(\"#navCanvasOverlay\").on('pointerdown', function (event) {\r\n\t\t\t\t\tevent.preventDefault();\r\n\t\t\t\t\tevent.stopPropagation();\r\n\t\t\t\t\t$(\"#navCanvasOverlay\").off('pointerup');\r\n\t\t\t\t\t$(\"#navCanvasOverlay\").on('pointerup', function (event) {\r\n\t\t\t\t\t\t$(\"#navCanvasOverlay\").off('pointermove');\r\n\t\t\t\t\t\toCanvas.navPointerUp();\r\n\t\t\t\t\t});\r\n\t\t\t\t\t$(\"#navCanvasOverlay\").on('pointermove', function (event) {\r\n\t\t\t\t\t\tevent.preventDefault();\r\n\t\t\t\t\t\tevent.stopPropagation();\r\n\t\t\t\t\t\toCanvas.navOnMove(event);\r\n\t\t\t\t\t});\r\n\t\t\t\t});\r\n\r\n\t\t\t\t// Hide the TAC (Total Area Coverage) field and percentage value if it is currently shown.\r\n\t\t\t\t$('#td_TAC').hide();\r\n\t\t\t}\r\n\r\n\t\t\t// Set the height of the navigation canvas and overlay.\r\n\t\t\t$(\"#navCanvas\").css(\"height\", oCanvas.g_oCanvas.height * 0.2 / g_oViewer.c_iDPI);\r\n\t\t\t$(\"#navCanvasOverlay\").css(\"height\", oCanvas.g_oCanvas.height * 0.2 / g_oViewer.c_iDPI);\r\n\r\n\t\t\t// If we are setting up the canvas, get the ratio of the navigation canvas.\r\n\t\t\tif (bSetupCanvas) {\r\n\t\t\t\toCanvas.g_oNavCanvasObj.getRatio();\r\n\t\t\t\toCanvas.g_oNavCanvasOver.getRatio();\r\n\t\t\t}\r\n\r\n\t\t\t// Get the list of sync canvas from the compare module.\r\n\t\t\tvar oSyncCanvas = g_oCompare.getSyncCanvas(oCanvas);\r\n\r\n\t\t\t// Render the separation elements.\r\n\t\t\tg_oSeparations.RenderSeparationElements(oCanvas, oSyncCanvas, saRequestedOrder);\r\n\t\t}\r\n\t\t// If not PDF, hide the sep div.\r\n\t\telse {\r\n\t\t\t$(\"#divSepContainer\").css(\"display\", \"none\");\r\n\t\t}\r\n\t\t\r\n\t\t// If the user has a non-complete checklist, make this visible if the consumer has this setting on.\r\n\t\tif (!g_oViewer.g_bReadOnly && oCanvas.g_oDoc.documentType != eDocumentTypes.ThreeD && g_oChecklist.showChecklistOnLaunch) {\r\n\t\t\tif (g_oChecklist.oApprovalUser != null && g_oChecklist.oApprovalUser.hasChecklist && g_oChecklist.oChecklist != null && g_oChecklist.oChecklist.ChecklistState != g_oChecklist.g_eChecklistItemState.Pass) {\r\n\t\t\t\tg_oChecklist.makeChecklistTabVisible();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * The navigation canvas 'on pointer down' event handler.\r\n\t * @param {object} event - The event.\r\n\t * @param {object} _this - The calling object.\r\n\t * @param {object} oCanvas - The selected canvas.\r\n\t */\r\n\tfunction navigationCanvasOnPointerDownEvent(event, _this, oCanvas) {\r\n\t\tevent.preventDefault();\r\n\t\tevent.stopPropagation();\r\n\r\n\t\t$(_this).off('pointerup');\r\n\r\n\t\t$(_this).on('pointerup', function (event) {\r\n\t\t\t$(_this).off('pointermove');\r\n\t\t\t_this.navPointerUp();\r\n\t\t});\r\n\r\n\t\t$(_this).on('pointermove', function (event) {\r\n\t\t\tevent.preventDefault();\r\n\t\t\tevent.stopPropagation();\r\n\t\t\t_this.navOnMove(event);\r\n\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t * The Colour Reset Button 'on click' event handler.\r\n\t * @param {object} event - The event.\r\n\t * @param {object} _this - The calling object.\r\n\t * @param {object} oCanvas - The selected canvas\r\n\t */\r\n\tfunction colourResetButtonOnClickEvent(event, _this, oCanvas) {\r\n\t\tevent.preventDefault();\r\n\t\tevent.stopPropagation();\r\n\r\n\t\tvar oID = $(_this).parent().attr(\"id\");\r\n\t\tvar oResult = $.grep(oCanvas.g_oaImages, function (oSeparation) { return getSeparationName(oSeparation) == oID; });\r\n\r\n\t\tvar oInputs = $(_this).parent().children(constants.c_szColourInputElementName);\r\n\t\tfor (var i = 0; i < oResult.length; i++) {\r\n\t\t\toResult[i].Red = oResult[0].OrigRed;\r\n\t\t\toResult[i].Green = oResult[0].OrigGreen;\r\n\t\t\toResult[i].Blue = oResult[0].OrigBlue;\r\n\t\t\toResult[i].Opaque = oResult[0].OrigOpaque === \"none\" ? \"normal\" : oResult[0].OrigOpaque;\r\n\t\t}\r\n\r\n\t\toInputs[0].value = oResult[0].OrigRed;\r\n\t\toInputs[1].value = oResult[0].OrigGreen;\r\n\t\toInputs[2].value = oResult[0].OrigBlue;\r\n\t\toInputs[3].value = oResult[0].OrigOpaque === \"none\" ? \"normal\" : oResult[0].OrigOpaque;\r\n\r\n\t\tvar oSwatch = $(_this).parent().children(\".\" + constants.c_szSwatchClassName);\r\n\t\toSwatch[0].style.backgroundColor = \"rgb(\" + oInputs[0].value + \",\" + oInputs[1].value + \",\" + oInputs[2].value + \")\";\r\n\r\n\t\tif ($(_this).parent().children(constants.c_szDisplayAsBlackCheckboxElementName).length == 1) {\r\n\t\t\tvar oCheckbox = $(_this).parent().children(constants.c_szDisplayAsBlackCheckboxElementName)[0];\r\n\t\t\toCheckbox.checked = true;\r\n\t\t\tdisplayAsBlackCheckboxClickEvent(event, oCheckbox, oCanvas);\r\n\t\t}\r\n\r\n\t\toCanvas.getimagePNGData(true, false);\r\n\t}\r\n\r\n\t/**\r\n\t * Creates the 'Display as Black' controls. This checkbox will tell the server side code to render the last enabled colour,\r\n\t * separation in it's actual colour instead of black (the normal behaviour).\r\n\t * @param {object} oSeparation - The colour separation object\r\n\t * @param {object} oColourChange - The colour change details object.\r\n\t * @param {object} oCanvas - The canvas object.\r\n\t */\r\n\tfunction createDisplayAsBlackControls(oSeparation, oColourChange, oCanvas) {\r\n\t\tif (oSeparation.Visible === true) {\r\n\r\n\t\t\t// Create the display as black checkbox.\r\n\t\t\tvar oDisplayAsBlackCheckbox = document.createElement('input');\r\n\t\t\toDisplayAsBlackCheckbox.id = constants.c_szDisplayAsBlackCheckboxClassName;\r\n\t\t\toDisplayAsBlackCheckbox.className = constants.c_szDisplayAsBlackCheckboxClassName;\r\n\t\t\toDisplayAsBlackCheckbox.name = constants.c_szDisplayAsBlackCheckboxClassName;\r\n\t\t\toDisplayAsBlackCheckbox.type = \"checkbox\";\r\n\t\t\toDisplayAsBlackCheckbox.checked = true;\r\n\t\t\toDisplayAsBlackCheckbox.style.width = \"15px;\";\r\n\t\t\toDisplayAsBlackCheckbox.style.height = \"15px;\";\r\n\r\n\t\t\t// Create the display as black prompt.\r\n\t\t\tvar oDisplayAsBlackLabel = document.createElement(\"label\");\r\n\t\t\toDisplayAsBlackLabel.className = constants.c_szDisplayAsBlackLabelClassName;\r\n\t\t\toDisplayAsBlackLabel.htmlFor = constants.c_szDisplayAsBlackCheckboxClassName;\r\n\t\t\toDisplayAsBlackLabel.innerHTML = \"Display as black\";\t\t// TODO: (DR208) - Get this from resources file.\r\n\r\n\t\t\t$(oDisplayAsBlackCheckbox).appendTo('#divCheckBoxWrapper');\r\n\t\t\t$(oDisplayAsBlackLabel).appendTo('#divCheckBoxWrapper');\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * The 'Display as Black' checkbox click event.\r\n\t * @param {event} event - The event passed in.\r\n\t * @param {object} _this - The calling element.\r\n\t * @param {object} oCanvas - The canvas this refers to.\r\n\t */\r\n\tfunction displayAsBlackCheckboxClickEvent(event, _this, oCanvas) {\r\n\t\toCanvas.g_bOverrideSingleColourChange = !($(_this)[0].checked);\r\n\r\n\t\t// Set the open separation object to if it is checked or not.\r\n\t\t// This is used to preserve the open separation when resizing.\r\n\t\tif (typeof g_oSeparations.g_oSeparationOpen != 'undefined') {\r\n\t\t\tg_oSeparations.g_oSeparationOpen.displayAsBlackCheck = ($(_this)[0].checked);\r\n\t\t}\r\n\r\n\t\toCanvas.getimagePNGData(true, false);\r\n\t}\r\n\r\n\t/**\r\n\t * A helper function that indicates if the separations are enabled.\r\n\t * @returns {bool}\r\n\t */\r\n\tfunction areSeparationsEnabled() {\r\n\t\treturn g_oTechTools.g_bSessionHasTechToolPermissions && documentHasSeparations(g_oViewer.g_oArtworkViewer.g_oDoc.documentType, g_oViewer.g_oArtworkViewer.g_oDoc.pages.length);\r\n\t}\r\n\r\n\t/**\r\n\t * Helper function to display the colour separation item spinners.\r\n\t */\r\n\tfunction showSpinners() {\r\n\t\t$(constants.c_szDivSeparationItemsElementName).children(constants.c_szSeparationElementName).not(constants.c_szSeparationDisabledElementName).children(constants.c_szSpinnerElementName).show();\r\n\t}\r\n\r\n\t/**\r\n\t * A helper function to indicate if a specific colour separation is visible.\r\n\t * @param {object} oCanvas - The canvas object.\r\n\t * @param {string} szSeparationName - The name of the colour separation\r\n\t * @returns {type}\r\n\t */\r\n\tfunction isSeparationEnabled(oCanvas, szSeparationName) {\r\n\t\tvar oImage = $.grep(oCanvas.g_oaImages, function (sep) { return sep.SeparationName == szSeparationName; });\r\n\t\tif (oImage === undefined || oImage === null) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\telse {\r\n\t\t\treturn oImage[0].Visible;\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Matches visible separations\r\n\t * @param {object} oCanvas - The object canvas\r\n\t * @param {object} oVisibleSeparations - The current visible separation objects.\r\n\t * @returns {bool} - Returns true if all separations are visible.\r\n\t */\r\n\tfunction matchVisibleSeparations(oCanvas, oVisibleSeparations) {\r\n\r\n\t\t// Declare a variable to hold if a separation fails to match.\r\n\t\tvar bSeparationVisibilityMatch = true;\r\n\r\n\t\t// Get a list of the visible separations on the canvas.\r\n\t\tvar oCanvasVisibleSeparations = $.grep(oCanvas.g_oaImages, function (oSeparation) { return oSeparation.Visible; });\r\n\r\n\t\t// Ensure the same number of separations are visible.\r\n\t\tif (oVisibleSeparations.length != oCanvasVisibleSeparations.length) {\r\n\t\t\tbSeparationVisibilityMatch = false;\r\n\t\t}\r\n\t\t// If there are the same number of visible separations.\r\n\t\telse {\r\n\r\n\t\t\t// Check that each of the separations are visible on the canvas.\r\n\t\t\tfor (var i = 0; i < oVisibleSeparations.length; i++) {\r\n\t\t\t\tvar bSeparationMatched = false;\r\n\r\n\t\t\t\t// Match the separation.\r\n\t\t\t\tfor (var j = 0; j < oCanvasVisibleSeparations.length; j++) {\r\n\t\t\t\t\tif (oCanvasVisibleSeparations[j].SeparationName == oVisibleSeparations[i].SeparationName) {\r\n\t\t\t\t\t\tbSeparationMatched = true;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// If the separation was not matched.\r\n\t\t\t\tif (!bSeparationMatched) {\r\n\t\t\t\t\tbSeparationVisibilityMatch = false;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Return if all of the separation matches visibility.\r\n\t\treturn bSeparationVisibilityMatch;\r\n\t}\r\n\r\n\t/**\r\n\t * Sets a constant string against the object.\r\n\t * @param {string} - The name of the constant to be added to the object.\r\n\t * @param {string} - The value of the constant.\r\n\t */\r\n\tfunction setConstant(constantName, value) {\r\n\t\tif (!constants.hasOwnProperty.call(constants, constantName)) {\r\n\t\t\tconstants[constantName] = value;\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t* This is the class interface.\r\n\t* These are the public functions that can be seen from g_oSeparations.\r\n\t*/\r\n\treturn {\r\n\t\t// Functions\r\n\t\tRenderSeparationElements: renderSeparationElements,\r\n\t\tResetAllCanvasImages: resetAllCanvasImages,\r\n\t\tToggleCanvasImages: disableCanvasImages,\r\n\t\tStepThroughCanvasImages: stepThroughCanvasImages,\r\n\t\tSetupSeparationsDiv: setupSeparationsDiv,\r\n\t\tAreSeparationsEnabled: areSeparationsEnabled,\r\n\t\tShowSpinners: showSpinners,\r\n\t\tIsSeparationEnabled: isSeparationEnabled,\r\n\t\tGetVisibleCanvasSeparationsCount: getVisibleCanvasSeparationsCount,\r\n\t\tMatchVisibleSeparations: matchVisibleSeparations,\r\n\t\tToggleOverprintPreview: toggleOverprintPreview,\r\n\t\tSanitiseSeparationName: sanitiseSeparationName,\r\n\t\tGetSeparationElements: getSeparationElements,\r\n\t\tSetSeparationVisibility: setSeparationVisibility,\r\n\t\tSetSeparationVisibilityDefaults: setSeparationVisibilityDefaults,\r\n\t\t// Constants\r\n\t\tSetConstant: setConstant,\r\n\t\tSeparationDisabledClassName: constants.c_szSeparationDisabledClassName,\r\n\t\tSeparationClassName: constants.c_szSeparationClassName,\r\n\t\tSpinnerElementName: constants.c_szSpinnerElementName,\r\n\t\tOpenSeparation: g_oSeparationOpen\r\n\t};\r\n}());"]}