{"version":3,"sources":["../js/Text/GreenlightTextTools_ParagraphHighlight.js"],"names":["g_oTextTools_ParagraphHighlight","TextTools_ParagraphHighlight","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","oTextData","g_oTextData","getTextData","g_oDoc","documentId","g_iCurrentPage","textData","oPosition","convertMousePositionToPercentages","iParagraph","findParagraph","x","y","szCanvasId","g_oCurrentText","concat","startingText","getFirstTextInParagraph","endingText","getLastTextInParagraph","leftToRight","isTextHighlightLeftToRight","push","g_iExistingAnnotationId","endhighlight","initialiseTextTool","g_eToolTypes","ParagraphHighlight","g_eActiveAnnotationType","g_bHighlightIsCharacterAccuracy","g_szHighlightColour","c_szNoLiveTextFound","window"],"mappings":"AAcA,IAAIA,gCAAkC,IAErC,WACA,aAKA,SAASC,gCAKTA,6BAA6BC,UAAUC,oBAAsB,WAG5D,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,gCAAgCsB,UAAUD,MAAOjB,QAASO,qBAI3DQ,qBAAqBC,EAAE,IAAMN,mBAAoB,cAAe,SAAUO,OACzErB,gCAAgCuB,U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uBV,WAAYX,eAAgBC,mBAAoBqB,YAAa7C,aAAa8C,+BAGvN,MAAxC9C,aAAagD,wBAMjBhD,aAAaiD,aAAa1B,eAAgBC,mBAAmB,GAL5DxB,aAAakD,mBAAmBlD,aAAamD,aAAaC,mBAAoBpD,aAAaqD,wBAAyBrD,aAAasD,gCAAiCtD,aAAaC,4BAA6BD,aAAauD,sBATzNnC,sBAAsBC,qBAAqBrB,aAAawD,sBAkB1DC,OAAO7D,6BAA+BA,6BAhHvC","file":"GreenlightTextTools_ParagraphHighlight-af88c33ba8.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_ParagraphHighlight.js\r\n *\r\n * Description:\tThe class containing the functionality required by the Greenlight for text tools for a paragraph highlight.\r\n * \r\n */\r\n\r\n// The text tools object.\r\nvar g_oTextTools_ParagraphHighlight = {};\r\n\r\n(function () {\r\n\t\"use strict\";\r\n\r\n\t/**\r\n\t * Load the paragraph highlight tool for the page.\r\n\t */\r\n\tfunction TextTools_ParagraphHighlight() {};\r\n\r\n\t/**\r\n\t * Initialises the paragraph highlight.\r\n\t */\r\n\tTextTools_ParagraphHighlight.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_ParagraphHighlight.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_ParagraphHighlight.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 the paragraph 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_ParagraphHighlight.prototype.mouseMove = function (event, oArtworkCanvas, oAnnotationCanvas) {\r\n\r\n\t\t// Get the text data for the document page.\r\n\t\tvar oTextData = g_oTextData.getTextData(oArtworkCanvas.g_oDoc.documentId, oArtworkCanvas.g_iCurrentPage).textData;\r\n\r\n\t\t// Get the position of the mouse.\r\n\t\tvar oPosition = g_oTextTools.convertMousePositionToPercentages(event, oArtworkCanvas, oAnnotationCanvas);\r\n\r\n\t\t// Try to find a paragragh.\r\n\t\tvar iParagraph = g_oTextTools.findParagraph(oPosition.x, oPosition.y, oTextData);\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 no paragraph, highlight only the existing sections.\r\n\t\tif (iParagraph == -1) {\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 sections and new paragraph.\r\n\t\tg_oTextTools.removeHighlights(oAnnotationCanvas);\r\n\t\tg_oTextTools.highlightSections(g_oTextTools.g_oAnnotationText.concat([{ startingText: g_oTextTools.getFirstTextInParagraph(iParagraph, oArtworkCanvas, oAnnotationCanvas), endingText: g_oTextTools.getLastTextInParagraph(iParagraph, oArtworkCanvas, oAnnotationCanvas), leftToRight: g_oTextTools.isTextHighlightLeftToRight() }]), oArtworkCanvas, oAnnotationCanvas);\r\n\t};\r\n\r\n\t/**\r\n\t * Mouse down event for the paragraph 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_ParagraphHighlight.prototype.mouseDown = function (event, oArtworkCanvas, oAnnotationCanvas) {\r\n\r\n\t\t// Get the text data for the document page.\r\n\t\tvar oTextData = g_oTextData.getTextData(oArtworkCanvas.g_oDoc.documentId, oArtworkCanvas.g_iCurrentPage).textData;\r\n\r\n\t\t// Get the position of the mouse.\r\n\t\tvar oPosition = g_oTextTools.convertMousePositionToPercentages(event, oArtworkCanvas, oAnnotationCanvas);\r\n\r\n\t\t// Try to find a paragragh.\r\n\t\tvar iParagraph = g_oTextTools.findParagraph(oPosition.x, oPosition.y, oTextData);\r\n\r\n\t\t// Ensure we have moused down on text.\r\n\t\tif (iParagraph == -1) {\r\n\t\t\tg_oGreenlightMessages.displayWarningBubble(g_oTextTools.c_szNoLiveTextFound);\r\n\t\t\treturn;\r\n\t\t}\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.getFirstTextInParagraph(iParagraph, oArtworkCanvas, oAnnotationCanvas), endingText: g_oTextTools.getLastTextInParagraph(iParagraph, oArtworkCanvas, oAnnotationCanvas), leftToRight: g_oTextTools.isTextHighlightLeftToRight() });\r\n\r\n\t\t// If this is an existing annotation, re-initialise the tool.\r\n\t\tif (g_oTextTools.g_iExistingAnnotationId != null) {\r\n\t\t\tg_oTextTools.initialiseTextTool(g_oTextTools.g_eToolTypes.ParagraphHighlight, 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_ParagraphHighlight = TextTools_ParagraphHighlight;\r\n}());"]}