{"version":3,"sources":["../js/Text/GreenlightTextTools_TextHighlight.js"],"names":["g_oTextTools_TextHighlight","TextTools_TextHighlight","prototype","initialiseHighlight","oViewer","g_oTextTools","g_bHighlightOnCompareCanvas","g_oCompare","g_oCompareViewer","g_oViewer","g_oArtworkViewer","oAnnotationViewer","g_oCompareAnnotationViewer","g_oAnnotationViewer","szHighlightCanvas","szNonHighlightCanvas","removeHighlights","highlightSections","g_oAnnotationText","changeCanvasFunction","$","event","mouseMove","mouseDown","css","g_oGreenlightMessages","displayWarningBubble","c_szHighlightUnavailableCanvas","oArtworkCanvas","oAnnotationCanvas","oPosition","convertMousePositionToPercentages","g_oCurrentText","findText","x","y","szCanvasId","findClosestText","concat","startingText","endingText","leftToRight","isTextHighlightLeftToRight","g_oStartingText","g_oEndingText","mouseDrag","mouseUp","c_szNoLiveTextFound","push","g_iExistingAnnotationId","endhighlight","initialiseTextTool","g_eToolTypes","TextHighlight","g_eActiveAnnotationType","g_bHighlightIsCharacterAccuracy","g_szHighlightColour","window"],"mappings":"AAcA,IAAIA,2BAA6B,IAEhC,WACA,aAKA,SAASC,2BAKTA,wBAAwBC,UAAUC,oBAAsB,WAGvD,IAAIC,QAAWC,aAAaC,4BAA2DC,WAAWC,iBAAxCC,UAAUC,iBAChEC,kBAAqBN,aAAaC,4BAA8DC,WAAWK,2BAA3CH,UAAUI,oBAC1EC,kBAAqBT,aAAaC,4BAAmD,0BAArB,mBAChES,qBAAwBV,aAAaC,4BAA0D,mBAA5B,0BAGvED,aAAaW,iBAAiBL,mBAC9BN,aAAaY,kBAAkBZ,aAAaa,kBAAmBd,QAASO,mBAGxEQ,qBAAqBC,EAAE,IAAMN,mBAAoB,2BAA4B,SAAUO,OACtFrB,2BAA2BsB,UAAUD,MAAOjB,QAASO,qBAItDQ,qBAAqBC,EAAE,IAAMN,mBAAoB,cAAe,SAAUO,OACzErB,2BAA2BuB,UAAUF,MAAOjB,QAASO,qBAItDS,EAAE,IAAML,sBAAsBS,IAAI,SAA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AAgBC,mBAAmB,GAL5DxB,aAAa8C,mBAAmB9C,aAAa+C,aAAaC,cAAehD,aAAaiD,wBAAyBjD,aAAakD,gCAAiClD,aAAaC,4BAA6BD,aAAamD,sBAStNC,OAAOxD,wBAA0BA,wBAjLlC","file":"GreenlightTextTools_TextHighlight-aaac0fb85a.js","sourcesContent":["/*\r\n * Copyright (c) 2021 SGS Europe. All rights reserved.\r\n *\r\n * This program is the CONFIDENTIAL and PROPRIETARY property of SGS Europe.\r\n * Any unauthorised use, reproduction, or transfer of this program is strictly\r\n * prohibited.\r\n *\r\n * File Name:\tGreenlightTextTools_TextHighlight.js\r\n *\r\n * Description:\tThe class containing the functionality required by the Greenlight for text tools for a text highlight.\r\n * \r\n */\r\n\r\n// The text tools object.\r\nvar g_oTextTools_TextHighlight = {};\r\n\r\n(function () {\r\n\t\"use strict\";\r\n\r\n\t/**\r\n\t * Load the text highlight tool for the page.\r\n\t */\r\n\tfunction TextTools_TextHighlight() {};\r\n\r\n\t/**\r\n\t * Initialises a text highlight.\r\n\t */\r\n\tTextTools_TextHighlight.prototype.initialiseHighlight = function () {\r\n\r\n\t\t// Determine the canvas to highlight on, and the non highlight canvas.\r\n\t\tvar oViewer = !g_oTextTools.g_bHighlightOnCompareCanvas ? g_oViewer.g_oArtworkViewer : g_oCompare.g_oCompareViewer;\r\n\t\tvar oAnnotationViewer = !g_oTextTools.g_bHighlightOnCompareCanvas ? g_oViewer.g_oAnnotationViewer : g_oCompare.g_oCompareAnnotationViewer;\r\n\t\tvar szHighlightCanvas = !g_oTextTools.g_bHighlightOnCompareCanvas ? \"AnnotationViewer\" : \"CompareAnnotationViewer\";\r\n\t\tvar szNonHighlightCanvas = !g_oTextTools.g_bHighlightOnCompareCanvas ? \"CompareAnnotationViewer\" : \"AnnotationViewer\";\r\n\r\n\t\t// Reset the highlighting to the existing sections.\r\n\t\tg_oTextTools.removeHighlights(oAnnotationViewer);\r\n\t\tg_oTextTools.highlightSections(g_oTextTools.g_oAnnotationText, oViewer, oAnnotationViewer);\r\n\r\n\t\t// Activate the mouse move event.\r\n\t\tchangeCanvasFunction($(\"#\" + szHighlightCanvas), 'pointermove.annotationUI', function (event) {\r\n\t\t\tg_oTextTools_TextHighlight.mouseMove(event, oViewer, oAnnotationViewer);\r\n\t\t});\r\n\r\n\t\t// Activate the mouse down event.\r\n\t\tchangeCanvasFunction($(\"#\" + szHighlightCanvas), 'pointerdown', function (event) {\r\n\t\t\tg_oTextTools_TextHighlight.mouseDown(event, oViewer, oAnnotationViewer);\r\n\t\t});\r\n\r\n\t\t// Activate the mouse down event for the compare canvas.\r\n\t\t$(\"#\" + szNonHighlightCanvas).css(\"cursor\", \"default\");\r\n\t\tchangeCanvasFunction($(\"#\" + szNonHighlightCanvas), 'pointerdown', function (event) {\r\n\t\t\tg_oGreenlightMessages.displayWarningBubble(g_oTextTools.c_szHighlightUnavailableCanvas);\r\n\t\t});\r\n\t};\r\n\r\n\t/**\r\n\t * Mouse move event for a text highlight.\r\n\t * @param {object} event - The event.\r\n\t * @param {object} oArtworkCanvas - The artwork canvas.\r\n\t * @param {object} oAnnotationCanvas - The annotation canvas.\r\n\t */\r\n\tTextTools_TextHighlight.prototype.mouseMove = function (event, oArtworkCanvas, oAnnotationCanvas) {\r\n\t\t\r\n\t\t// Search for text.\r\n\t\tvar oPosition = g_oTextTools.convertMousePositionToPercentages(event, oArtworkCanvas, oAnnotationCanvas);\r\n\t\tg_oTextTools.g_oCurrentText = g_oTextTools.findText(oPosition.x, oPosition.y, oArtworkCanvas, oAnnotationCanvas);\r\n\r\n\t\t// Determine the canvas id.\r\n\t\tvar szCanvasId = \"#\" + (!g_oTextTools.g_bHighlightOnCompareCanvas ? \"AnnotationViewer\" : \"CompareAnnotationViewer\");\r\n\r\n\t\t// Change the cursor based on if a word was found.\r\n\t\t$(szCanvasId).css(\"cursor\", g_oTextTools.g_oCurrentText == null ? \"default\" : \"text\");\r\n\r\n\t\t// If we have not found any text, find the closest text.\r\n\t\tif (g_oTextTools.g_oCurrentText == null) {\r\n\t\t\tg_oTextTools.g_oCurrentText = g_oTextTools.findClosestText(oPosition.x, oPosition.y, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t}\r\n\r\n\t\t// If we have not found any text, highlight only the existing words.\r\n\t\tif (g_oTextTools.g_oCurrentText == null) {\r\n\t\t\tg_oTextTools.removeHighlights(oAnnotationCanvas);\r\n\t\t\tg_oTextTools.highlightSections(g_oTextTools.g_oAnnotationText, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Highlight the existing section and new word.\r\n\t\tg_oTextTools.removeHighlights(oAnnotationCanvas);\r\n\t\tg_oTextTools.highlightSections(g_oTextTools.g_oAnnotationText.concat([{ startingText: g_oTextTools.g_oCurrentText, endingText: g_oTextTools.g_oCurrentText, leftToRight: g_oTextTools.isTextHighlightLeftToRight() }]), oArtworkCanvas, oAnnotationCanvas);\r\n\t};\r\n\r\n\t/**\r\n\t * Mouse down event for a text highlight.\r\n\t * @param {object} event - The event.\r\n\t * @param {object} oArtworkCanvas - The artwork canvas.\r\n\t * @param {object} oAnnotationCanvas - The annotation canvas.\r\n\t */\r\n\tTextTools_TextHighlight.prototype.mouseDown = function (event, oArtworkCanvas, oAnnotationCanvas) {\r\n\r\n\t\t// Search for text.\r\n\t\tvar oPosition = g_oTextTools.convertMousePositionToPercentages(event, oArtworkCanvas, oAnnotationCanvas);\r\n\t\tg_oTextTools.g_oCurrentText = g_oTextTools.findText(oPosition.x, oPosition.y, oArtworkCanvas, oAnnotationCanvas);\r\n\r\n\t\t// If we have not found any text, find the closest text.\r\n\t\tif (g_oTextTools.g_oCurrentText == null) {\r\n\t\t\tg_oTextTools.g_oCurrentText = g_oTextTools.findClosestText(oPosition.x, oPosition.y, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t}\r\n\r\n\t\t// Ensure we have moused down on text.\r\n\t\tif (g_oTextTools.g_oCurrentText == null) {\r\n\t\t\tg_oGreenlightMessages.displayWarningBubble(g_oTextTools.c_szNoLiveTextFound);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Update the starting and ending text.\r\n\t\tg_oTextTools.g_oStartingText = g_oTextTools.g_oEndingText = g_oTextTools.g_oCurrentText;\r\n\r\n\t\t// Reset the highlighting, then highlight the existing and new sections.\r\n\t\tg_oTextTools.removeHighlights(oAnnotationCanvas);\r\n\t\tg_oTextTools.highlightSections(g_oTextTools.g_oAnnotationText.concat([{ startingText: g_oTextTools.g_oStartingText, endingText: g_oTextTools.g_oEndingText, leftToRight: g_oTextTools.isTextHighlightLeftToRight() }]), oArtworkCanvas, oAnnotationCanvas);\r\n\r\n\t\t// Clear all bindings.\r\n\t\tchangeCanvasFunction();\r\n\r\n\t\t// Determine the canvas id.\r\n\t\tvar szCanvasId = \"#\" + (!g_oTextTools.g_bHighlightOnCompareCanvas ? \"AnnotationViewer\" : \"CompareAnnotationViewer\");\r\n\r\n\t\t// Change the cursor to text.\r\n\t\t$(szCanvasId).css(\"cursor\", \"text\");\r\n\r\n\t\t// Set the mouse drag event.\r\n\t\tchangeCanvasFunction($(szCanvasId), 'pointermove.annotationUI', function (event) {\r\n\t\t\tg_oTextTools_TextHighlight.mouseDrag(event, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t});\r\n\r\n\t\t// Set the mouse up event.\r\n\t\tchangeCanvasFunction($(szCanvasId), 'pointerup', function (event) {\r\n\t\t\tg_oTextTools_TextHighlight.mouseUp(event, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t});\r\n\t};\r\n\r\n\t/**\r\n\t * Mouse drag event for a text highlight.\r\n\t * @param {object} event - The event.\r\n\t * @param {object} oArtworkCanvas - The artwork canvas.\r\n\t * @param {object} oAnnotationCanvas - The annotation canvas.\r\n\t */\r\n\tTextTools_TextHighlight.prototype.mouseDrag = function (event, oArtworkCanvas, oAnnotationCanvas) {\r\n\r\n\t\t// Search for text.\r\n\t\tvar oPosition = g_oTextTools.convertMousePositionToPercentages(event, oArtworkCanvas, oAnnotationCanvas);\r\n\t\tg_oTextTools.g_oCurrentText = g_oTextTools.findText(oPosition.x, oPosition.y, oArtworkCanvas, oAnnotationCanvas);\r\n\r\n\t\t// If we have not found any text, find the closest text.\r\n\t\tif (g_oTextTools.g_oCurrentText == null) {\r\n\t\t\tg_oTextTools.g_oCurrentText = g_oTextTools.findClosestText(oPosition.x, oPosition.y, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t}\r\n\r\n\t\t// Check a word has been found.\r\n\t\tif (g_oTextTools.g_oCurrentText == null) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Update the ending word for the highlight.\r\n\t\tg_oTextTools.g_oEndingText = g_oTextTools.g_oCurrentText;\r\n\r\n\t\t// Reset the highlighting, then highlight the existing and new sections.\r\n\t\tg_oTextTools.removeHighlights(oAnnotationCanvas);\r\n\t\tg_oTextTools.highlightSections(g_oTextTools.g_oAnnotationText.concat([{ startingText: g_oTextTools.g_oStartingText, endingText: g_oTextTools.g_oEndingText, leftToRight: g_oTextTools.isTextHighlightLeftToRight() }]), oArtworkCanvas, oAnnotationCanvas);\r\n\t};\r\n\r\n\t/**\r\n\t * Mouse up event for a text highlight.\r\n\t * @param {object} event - The event.\r\n\t * @param {object} oArtworkCanvas - The artwork canvas.\r\n\t * @param {object} oAnnotationCanvas - The annotation canvas.\r\n\t */\r\n\tTextTools_TextHighlight.prototype.mouseUp = function (event, oArtworkCanvas, oAnnotationCanvas) {\r\n\t\t\r\n\t\t// Add the section to the annotation text.\r\n\t\tg_oTextTools.g_oAnnotationText.push({ startingText: g_oTextTools.g_oStartingText, endingText: g_oTextTools.g_oEndingText, leftToRight: g_oTextTools.isTextHighlightLeftToRight() });\r\n\r\n\t\t// If this is not a new annotation, re-initialise the highlight.\r\n\t\tif (g_oTextTools.g_iExistingAnnotationId != null) {\r\n\t\t\tg_oTextTools.initialiseTextTool(g_oTextTools.g_eToolTypes.TextHighlight, g_oTextTools.g_eActiveAnnotationType, g_oTextTools.g_bHighlightIsCharacterAccuracy, g_oTextTools.g_bHighlightOnCompareCanvas, g_oTextTools.g_szHighlightColour);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// End the highlight.\r\n\t\tg_oTextTools.endhighlight(oArtworkCanvas, oAnnotationCanvas, true);\r\n\t};\r\n\r\n\t// Add the Text Tools tool object to the window.\r\n\twindow.TextTools_TextHighlight = TextTools_TextHighlight;\r\n}());"]}