{"version":3,"sources":["ResultLink.min__d957946aa95219e5e0e2.js","./src/ui/ResultLink/ResultLink.ts"],"names":["webpackJsonpCoveo__temporary","532","module","exports","69","__webpack_require__","__extends","this","extendStatics","Object","setPrototypeOf","__proto__","Array","d","b","p","hasOwnProperty","__","constructor","prototype","create","__assign","assign","t","s","i","n","arguments","length","call","defineProperty","value","element","options","bindings","result","os","ResultLink","ID","logAnalytics","debounce","queryController","saveLastQuery","documentURL","$$","getAttribute","undefined","escapedClickUri","logDocumentOpen","Defer","flush","globalOptions","searchInterface","originalOptionsObject","initialOptions","ComponentOptions","initComponentOptions","resultLinkOptions","componentOptionsModel","get","ComponentOptionsModel","attributesEnum","resultLink","extend","resolveResult","openQuickview","raw","DeviceUtils","isMobileDevice","hasAttribute","setAttribute","Assert","exists","quickviewShouldBeOpened","once","on","window","setTimeout","clearTimeout","renderUri","bindEventToOpen","_this","test","innerHTML","title","getDisplayedTitle","titleAsText","getDisplayedTitleAsText","openLink","location","href","getResultUri","openLinkInNewWindow","open","openLinkInOutlook","hasOutlookField","openLinkAsConfigured","toExecuteOnOpen","bindOnClickIfNotUndefined","bindOpenQuickviewIfNotUndefined","setHrefIfNotAlready","openLinkThatIsNotAnAnchor","titleTemplate","newTitle","StringUtils","buildStringTemplateFromResult","StreamHighlightUtils","highlightStreamText","termsToHighlight","phrasesToHighlight","HighlightUtils","highlightString","titleHighlights","container","setHtml","text","escape","clickUri","enumerable","configurable","onClick","e","AccessibleButton","withElement","withLabel","withSelectAction","build","resultElement","trigger","ResultListEvents","preventDefault","elementIsAnAnchor","alwaysOpenInNewWindow","openInOutlook","Utils","isNonEmptyString","usageAnalytics","logClickEvent","analyticsActionCauseList","documentOpen","documentTitle","author","getFieldValue","root","filterProtocol","uri","isAbsolute","isRelative","hrefTemplate","field","setField","tagName","OSUtils","OS_NAME","MACOSX","WINDOWS","isUriThatMustBeOpenedInQuickview","toLowerCase","indexOf","QueryUtils","hasHTMLVersion","doExport","exportGlobally","buildFieldOption","buildBooleanOption","defaultValue","buildStringOption","buildCustomOption","Component","Initialization","registerAutoCreateComponent"],"mappings":"AAAAA,8BAA8B,KAExBC,IACA,SAAUC,EAAQC,KAMlBC,GACA,SAAUF,EAAQC,EAASE,GAEjC,YAEA,IAAIC,GAAaC,MAAQA,KAAKD,WAAc,WACxC,GAAIE,GAAgBC,OAAOC,iBACpBC,uBAA2BC,QAAS,SAAUC,EAAGC,GAAKD,EAAEF,UAAYG,IACvE,SAAUD,EAAGC,GAAK,IAAK,GAAIC,KAAKD,GAAOA,EAAEE,eAAeD,KAAIF,EAAEE,GAAKD,EAAEC,IACzE,OAAO,UAAUF,EAAGC,GAEhB,QAASG,KAAOV,KAAKW,YAAcL,EADnCL,EAAcK,EAAGC,GAEjBD,EAAEM,UAAkB,OAANL,EAAaL,OAAOW,OAAON,IAAMG,EAAGE,UAAYL,EAAEK,UAAW,GAAIF,QAGnFI,EAAYd,MAAQA,KAAKc,UAAaZ,OAAOa,QAAU,SAASC,GAChE,IAAK,GAAIC,GAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAAK,CACjDD,EAAIG,UAAUF,EACd,KAAK,GAAIV,KAAKS,GAAOf,OAAOU,UAAUH,eAAea,KAAKL,EAAGT,KACzDQ,EAAER,GAAKS,EAAET,IAEjB,MAAOQ,GAEXd,QAAOqB,eAAe3B,EAAS,cAAgB4B,OAAO,GChCtD,YACA,OACA,QAEA,QAEA,QACA,QAEA,QACA,SACA,OACA,QACA,OACA,OACA,QACA,OACA,SACA,QACA,OACA,MAEA,OACA,aAQA,cA2OE,WACSC,EACAC,EACAC,EACAC,EACAC,GALT,MAOE,YAAMJ,EAASK,EAAWC,GAAIJ,IAAS,IANhC,GAAAF,UACA,EAAAC,UACA,EAAAC,WACA,EAAAC,SACA,EAAAC,KAyOD,EAAAG,aAAe,EAAAC,SACrB,WACE,EAAKC,gBAAgBC,eACrB,IAAIC,GAAc,EAAAC,GAAG,EAAKZ,SAASa,aAAa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aAA4C7G,IAAjCvC,KAAK4B,OAAO+B,IAAgB,YAM1D,YAAA0F,iCAAR,WACE,MAAgE,IAAzDrJ,KAAKwC,gBAAgB8G,cAAcC,QAAQ,YAG5C,YAAArF,wBAAR,WACE,OAAQlE,KAAK0B,QAAQgC,eAAiB1D,KAAKqJ,qCAAuC,EAAAG,WAAWC,eAAezJ,KAAK4B,SA9hB5G,EAAAG,GAAK,aAEL,EAAA2H,SAAW,WAChB,EAAAC,gBACE7H,WAAYA,KAQT,EAAAJ,SA8BLoH,MAAO,EAAA9F,iBAAiB4G,mBAaxB9B,cAAe,EAAA9E,iBAAiB6G,oBAAqBC,cAAc,IAQnEpG,cAAe,EAAAV,iBAAiB6G,oBAAqBC,cAAc,IAmBnEjC,sBAAuB,EAAA7E,iBAAiB6G,oBAAqBC,cAAc,IA2B3EjB,aAAc,EAAA7F,iBAAiB+G,oBAyC/BhE,cAAe,EAAA/C,iBAAiB+G,oBA0ChC9C,QAAS,EAAAjE,iBAAiBgH,kBAA2D,WACnF,MAAO,QA2BThI,aAAc,EAAAgB,iBAAiBgH,kBAA0C,WAAM,eAoUnF,GAjiBgC,EAAAC,UAAnB,GAAAnI,aAmiBb,EAAAoI,eAAeC,4BAA4BrI","file":"ResultLink.min__d957946aa95219e5e0e2.js","sourcesContent":["webpackJsonpCoveo__temporary([65],{\n\n/***/ 532:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n\n/***/ 69:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Component_1 = __webpack_require__(7);\nvar ComponentOptions_1 = __webpack_require__(8);\nvar ComponentOptionsModel_1 = __webpack_require__(28);\nvar AnalyticsActionListMeta_1 = __webpack_require__(10);\nvar ResultListEvents_1 = __webpack_require__(29);\nvar HighlightUtils_1 = __webpack_require__(67);\nvar DeviceUtils_1 = __webpack_require__(24);\nvar OSUtils_1 = __webpack_require__(178);\nvar Initialization_1 = __webpack_require__(2);\nvar QueryUtils_1 = __webpack_require__(21);\nvar Assert_1 = __webpack_require__(5);\nvar Utils_1 = __webpack_require__(4);\nvar Defer_1 = __webpack_require__(31);\nvar Dom_1 = __webpack_require__(1);\nvar StreamHighlightUtils_1 = __webpack_require__(118);\nvar StringUtils_1 = __webpack_require__(22);\nvar underscore_1 = __webpack_require__(0);\nvar GlobalExports_1 = __webpack_require__(3);\n__webpack_require__(532);\nvar AccessibleButton_1 = __webpack_require__(17);\n/**\n * The `ResultLink` component automatically transform a search result title into a clickable link pointing to the\n * original item.\n *\n * This component is a result template component (see [Result Templates](https://docs.coveo.com/en/413/)).\n */\nvar ResultLink = /** @class */ (function (_super) {\n __extends(ResultLink, _super);\n /**\n * Creates a new `ResultLink` component.\n * @param element The HTMLElement on which to instantiate the component.\n * @param options The options for the `ResultLink` component.\n * @param bindings The bindings that the component requires to function normally. If not set, these will be\n * automatically resolved (with a slower execution time).\n * @param result The result to associate the component with.\n * @param os\n */\n function ResultLink(element, options, bindings, result, os) {\n var _this = _super.call(this, element, ResultLink.ID, bindings) || this;\n _this.element = element;\n _this.options = options;\n _this.bindings = bindings;\n _this.result = result;\n _this.os = os;\n _this.logAnalytics = underscore_1.debounce(function () {\n _this.queryController.saveLastQuery();\n var documentURL = Dom_1.$$(_this.element).getAttribute('href');\n if (documentURL == undefined || documentURL == '') {\n documentURL = _this.escapedClickUri;\n }\n if (_this.options.logAnalytics) {\n _this.options.logAnalytics(documentURL);\n }\n else {\n _this.logDocumentOpen(documentURL);\n }\n Defer_1.Defer.flush();\n }, 1500, true);\n var globalOptions = _this.searchInterface.options.originalOptionsObject[ResultLink.ID] || {};\n var initialOptions = ComponentOptions_1.ComponentOptions.initComponentOptions(element, ResultLink, __assign({}, globalOptions, options));\n var resultLinkOptions = _this.componentOptionsModel.get(ComponentOptionsModel_1.ComponentOptionsModel.attributesEnum.resultLink);\n _this.options = underscore_1.extend({}, initialOptions, resultLinkOptions);\n _this.result = result || _this.resolveResult();\n if (_this.options.openQuickview == null) {\n _this.options.openQuickview = result.raw['connectortype'] == 'ExchangeCrawler' && DeviceUtils_1.DeviceUtils.isMobileDevice();\n }\n if (!_this.element.hasAttribute('tabindex')) {\n _this.element.setAttribute('tabindex', '0');\n }\n Assert_1.Assert.exists(_this.componentOptionsModel);\n Assert_1.Assert.exists(_this.result);\n if (!_this.quickviewShouldBeOpened()) {\n // Bind on multiple \"click\" or \"mouse\" events.\n // Create a function that will be executed only once, so as not to log multiple events\n // Once a result link has been opened, and that we log at least one analytics event,\n // it should not matter if the end user open the same link multiple times with different methods.\n // It's still only one \"click\" event as far as UA is concerned.\n // Also need to handle \"longpress\" on mobile (the contextual menu), which we assume to be 1 s long.\n var executeOnlyOnce_1 = underscore_1.once(function () { return _this.logAnalytics(); });\n Dom_1.$$(element).on(['contextmenu', 'click', 'mousedown', 'mouseup'], executeOnlyOnce_1);\n var longPressTimer_1;\n Dom_1.$$(element).on('touchstart', function () {\n longPressTimer_1 = window.setTimeout(executeOnlyOnce_1, 1000);\n });\n Dom_1.$$(element).on('touchend', function () {\n if (longPressTimer_1) {\n clearTimeout(longPressTimer_1);\n }\n });\n }\n _this.renderUri(element, result);\n _this.bindEventToOpen();\n return _this;\n }\n ResultLink.prototype.renderUri = function (element, result) {\n if (/^\\s*$/.test(this.element.innerHTML)) {\n var title = this.getDisplayedTitle();\n this.element.innerHTML = title;\n var titleAsText = this.getDisplayedTitleAsText();\n if (!this.element.hasAttribute('aria-label')) {\n this.element.setAttribute('aria-label', titleAsText);\n }\n if (!this.element.title) {\n this.element.title = titleAsText;\n }\n }\n };\n /**\n * Opens the result in the same window, no matter how the actual component is configured for the end user.\n * @param logAnalytics Specifies whether the method should log an analytics event.\n */\n ResultLink.prototype.openLink = function (logAnalytics) {\n if (logAnalytics === void 0) { logAnalytics = true; }\n if (logAnalytics) {\n this.logAnalytics();\n }\n window.location.href = this.getResultUri();\n };\n /**\n * Opens the result in a new window, no matter how the actual component is configured for the end user.\n * @param logAnalytics Specifies whether the method should log an analytics event.\n */\n ResultLink.prototype.openLinkInNewWindow = function (logAnalytics) {\n if (logAnalytics === void 0) { logAnalytics = true; }\n if (logAnalytics) {\n this.logAnalytics();\n }\n window.open(this.getResultUri(), '_blank');\n };\n /**\n * Tries to open the result in Microsoft Outlook if the result has an `outlookformacuri` or `outlookuri` field.\n *\n * Normally, this implies the result should be a link to an email.\n *\n * If the needed fields are not present, this method does nothing.\n * @param logAnalytics Specifies whether the method should log an analytics event.\n */\n ResultLink.prototype.openLinkInOutlook = function (logAnalytics) {\n if (logAnalytics === void 0) { logAnalytics = true; }\n if (this.hasOutlookField()) {\n if (logAnalytics) {\n this.logAnalytics();\n }\n this.openLink();\n }\n };\n /**\n * Opens the link in the same manner the end user would.\n *\n * This essentially simulates a click on the result link.\n *\n * @param logAnalytics Specifies whether the method should log an analytics event.\n */\n ResultLink.prototype.openLinkAsConfigured = function (logAnalytics) {\n if (logAnalytics === void 0) { logAnalytics = true; }\n if (this.toExecuteOnOpen) {\n if (logAnalytics) {\n this.logAnalytics();\n }\n this.toExecuteOnOpen();\n }\n };\n ResultLink.prototype.bindEventToOpen = function () {\n return (this.bindOnClickIfNotUndefined() ||\n this.bindOpenQuickviewIfNotUndefined() ||\n this.setHrefIfNotAlready() ||\n this.openLinkThatIsNotAnAnchor());\n };\n ResultLink.prototype.getDisplayedTitle = function () {\n if (!this.options.titleTemplate) {\n return this.result.title\n ? HighlightUtils_1.HighlightUtils.highlightString(this.result.title, this.result.titleHighlights, null, 'coveo-highlight')\n : this.escapedClickUri;\n }\n else {\n var newTitle = StringUtils_1.StringUtils.buildStringTemplateFromResult(this.options.titleTemplate, this.result);\n return newTitle\n ? StreamHighlightUtils_1.StreamHighlightUtils.highlightStreamText(newTitle, this.result.termsToHighlight, this.result.phrasesToHighlight)\n : this.escapedClickUri;\n }\n };\n ResultLink.prototype.getDisplayedTitleAsText = function () {\n var container = Dom_1.$$('div');\n container.setHtml(this.getDisplayedTitle());\n return container.text();\n };\n Object.defineProperty(ResultLink.prototype, \"escapedClickUri\", {\n get: function () {\n return underscore_1.escape(this.result.clickUri);\n },\n enumerable: true,\n configurable: true\n });\n ResultLink.prototype.bindOnClickIfNotUndefined = function () {\n var _this = this;\n if (this.options.onClick != undefined) {\n this.toExecuteOnOpen = function (e) {\n _this.options.onClick.call(_this, e, _this.result);\n };\n new AccessibleButton_1.AccessibleButton()\n .withElement(this.element)\n .withLabel(this.result.title)\n .withSelectAction(function (e) { return _this.toExecuteOnOpen(e); })\n .build();\n return true;\n }\n else {\n return false;\n }\n };\n ResultLink.prototype.bindOpenQuickviewIfNotUndefined = function () {\n var _this = this;\n if (this.quickviewShouldBeOpened()) {\n this.toExecuteOnOpen = function () {\n Dom_1.$$(_this.bindings.resultElement).trigger(ResultListEvents_1.ResultListEvents.openQuickview);\n };\n Dom_1.$$(this.element).on('click', function (e) {\n e.preventDefault();\n _this.toExecuteOnOpen();\n });\n return true;\n }\n else {\n return false;\n }\n };\n ResultLink.prototype.openLinkThatIsNotAnAnchor = function () {\n var _this = this;\n if (!this.elementIsAnAnchor()) {\n this.toExecuteOnOpen = function () {\n if (_this.options.alwaysOpenInNewWindow) {\n if (_this.options.openInOutlook) {\n _this.openLinkInOutlook();\n }\n else {\n _this.openLinkInNewWindow();\n }\n }\n else {\n _this.openLink();\n }\n };\n Dom_1.$$(this.element).on('click', function () {\n _this.toExecuteOnOpen();\n });\n return true;\n }\n return false;\n };\n ResultLink.prototype.setHrefIfNotAlready = function () {\n // Do not erase any value put in href by the template, etc. Allows\n // using custom click urls while still keeping analytics recording\n // and other behavior brought by the component.\n if (this.elementIsAnAnchor() && !Utils_1.Utils.isNonEmptyString(Dom_1.$$(this.element).getAttribute('href'))) {\n Dom_1.$$(this.element).setAttribute('href', this.getResultUri());\n if (this.options.alwaysOpenInNewWindow && !(this.options.openInOutlook && this.hasOutlookField())) {\n Dom_1.$$(this.element).setAttribute('target', '_blank');\n }\n return true;\n }\n else {\n return false;\n }\n };\n ResultLink.prototype.logDocumentOpen = function (href) {\n this.usageAnalytics.logClickEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.documentOpen, {\n documentURL: href,\n documentTitle: this.result.title,\n author: Utils_1.Utils.getFieldValue(this.result, 'author')\n }, this.result, this.root);\n };\n ResultLink.prototype.filterProtocol = function (uri) {\n var isAbsolute = /^(https?|ftp|file|mailto|tel):/i.test(uri);\n var isRelative = /^(\\/|\\.\\/|\\.\\.\\/)/.test(uri);\n return isAbsolute || isRelative ? uri : '';\n };\n ResultLink.prototype.getResultUri = function () {\n if (this.options.hrefTemplate) {\n var uri = StringUtils_1.StringUtils.buildStringTemplateFromResult(this.options.hrefTemplate, this.result);\n return this.filterProtocol(uri);\n }\n if (this.options.field == undefined && this.options.openInOutlook) {\n this.setField();\n }\n if (this.options.field != undefined) {\n return this.filterProtocol(Utils_1.Utils.getFieldValue(this.result, this.options.field));\n }\n return this.filterProtocol(this.result.clickUri);\n };\n ResultLink.prototype.elementIsAnAnchor = function () {\n return this.element.tagName == 'A';\n };\n ResultLink.prototype.setField = function () {\n var os = Utils_1.Utils.exists(this.os) ? this.os : OSUtils_1.OSUtils.get();\n if (os == OSUtils_1.OS_NAME.MACOSX && this.hasOutlookField()) {\n this.options.field = '@outlookformacuri';\n }\n else if (os == OSUtils_1.OS_NAME.WINDOWS && this.hasOutlookField()) {\n this.options.field = '@outlookuri';\n }\n };\n ResultLink.prototype.hasOutlookField = function () {\n var os = Utils_1.Utils.exists(this.os) ? this.os : OSUtils_1.OSUtils.get();\n if (os == OSUtils_1.OS_NAME.MACOSX && this.result.raw['outlookformacuri'] != undefined) {\n return true;\n }\n else if (os == OSUtils_1.OS_NAME.WINDOWS && this.result.raw['outlookuri'] != undefined) {\n return true;\n }\n return false;\n };\n ResultLink.prototype.isUriThatMustBeOpenedInQuickview = function () {\n return this.escapedClickUri.toLowerCase().indexOf('ldap://') == 0;\n };\n ResultLink.prototype.quickviewShouldBeOpened = function () {\n return (this.options.openQuickview || this.isUriThatMustBeOpenedInQuickview()) && QueryUtils_1.QueryUtils.hasHTMLVersion(this.result);\n };\n ResultLink.ID = 'ResultLink';\n ResultLink.doExport = function () {\n GlobalExports_1.exportGlobally({\n ResultLink: ResultLink\n });\n };\n /**\n * The options for the ResultLink\n * @componentOptions\n */\n ResultLink.options = {\n /**\n * Specifies the field to use to output the component `href` attribute value.\n *\n * **Tip:**\n * > Instead of specifying a value for the `field` option, you can directly add an `href` attribute to the\n * > `ResultLink` HTML element. Then, you can use a custom script to generate the `href` value.\n *\n * **Examples:**\n * - With the following markup, the `ResultLink` outputs its `href` value using the `@uri` field (rather than the\n * default field):\n *\n * ```html\n * \n * ```\n *\n * - In the following result template, the custom `getMyKBUri()` function provides the `href` value:\n *\n * ```html\n * \n * ```\n *\n * See also [`hrefTemplate`]{@link ResultLink.options.hrefTemplate}, which can override this option.\n *\n * By default, the component uses the `@clickUri` field of the item to output the value of its `href` attribute.\n */\n field: ComponentOptions_1.ComponentOptions.buildFieldOption(),\n /**\n * Specifies whether the component should try to open its link in Microsoft Outlook.\n *\n * Setting this option to `true` is normally useful for `ResultLink` instances related to Microsoft Exchange emails.\n *\n * If this option is `true`, clicking the `ResultLink` calls the\n * [`openLinkInOutlook`]{@link ResultLink.openLinkInOutlook} method instead of the\n * [`openLink`]{@link ResultLink.openLink} method.\n *\n * Default value is `false`.\n */\n openInOutlook: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: false }),\n /**\n * Specifies whether the component should open its link in the [`Quickview`]{@link Quickview} component rather than\n * loading through the original URL.\n *\n * Default value is `false`.\n */\n openQuickview: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: false }),\n /**\n * Specifies whether the component should open its link in a new window instead of opening it in the current\n * context.\n *\n * If this option is `true`, clicking the `ResultLink` calls the\n * [`openLinkInNewWindow`]{@link ResultLink.openLinkInNewWindow} method instead of the\n * [`openLink`]{@link ResultLink.openLink} method.\n *\n * **Note:**\n * > If a search page contains a [`ResultPreferences`]{@link ResultsPreferences} component whose\n * > [`enableOpenInNewWindow`]{@link ResultsPreferences.options.enableOpenInNewWindow} option is `true`, and the end\n * > user checks the Always open results in new window box, `ResultLink` components in this page will always\n * > open their links in a new window when the end user clicks them, no matter what the value of their\n * > `alwaysOpenInNewWindow` option is.\n *\n * Default value is `false`.\n */\n alwaysOpenInNewWindow: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: false }),\n /**\n * Specifies a template literal from which to generate the `ResultLink` `href` attribute value (see\n * [Template literals](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals)).\n *\n * This option overrides the [`field`]{@link ResultLink.options.field} option value.\n *\n * The template literal can reference any number of fields from the parent result. It can also reference global\n * scope properties.\n *\n * **Examples:**\n *\n * - The following markup generates an `href` value such as `http://uri.com?id=itemTitle`:\n *\n * ```html\n * \n * ```\n *\n * - The following markup generates an `href` value such as `localhost/fooBar`:\n *\n * ```html\n * \n * ```\n *\n * Default value is `undefined`.\n */\n hrefTemplate: ComponentOptions_1.ComponentOptions.buildStringOption(),\n /**\n * Specifies a template literal from which to generate the `ResultLink` display title (see\n * [Template literals](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals)).\n *\n * This option overrides the default `ResultLink` display title behavior.\n *\n * The template literal can reference any number of fields from the parent result. However, if the template literal\n * references a key whose value is undefined in the parent result fields, the `ResultLink` title displays the\n * name of this key instead.\n *\n * This option is ignored if the `ResultLink` innerHTML contains any value.\n *\n * **Examples:**\n *\n * - The following markup generates a `ResultLink` display title such as `Case number: 123456` if both the\n * `raw.objecttype` and `raw.objectnumber` keys are defined in the parent result fields:\n *\n * ```html\n * \n * ```\n *\n * - The following markup generates `${myField}` as a `ResultLink` display title if the `myField` key is undefined\n * in the parent result fields:\n *\n * ```html\n * \n * ```\n *\n * - The following markup generates `Foobar` as a `ResultLink` display title, because the `ResultLink` innterHTML is\n * not empty:\n *\n * ```html\n * Foobar\n * ```\n *\n * Default value is `undefined`.\n *\n * @availablesince [January 2017 Release (v1.1865.9)](https://docs.coveo.com/en/396/#january-2017-release-v118659)\n */\n titleTemplate: ComponentOptions_1.ComponentOptions.buildStringOption(),\n /**\n * Specifies an event handler function to execute when the user clicks the `ResultLink` component.\n *\n * The handler function takes a JavaScript [`Event`](https://developer.mozilla.org/en/docs/Web/API/Event) object and\n * an [`IQueryResult`]{@link IQueryResult} as its parameters.\n *\n * Overriding the default behavior of the `onClick` event can allow you to execute specific code instead.\n *\n * **Note:**\n * > You cannot set this option directly in the component markup as an HTML attribute. You must either set it in the\n * > [`init`]{@link init} call of your search interface (see\n * > [Passing Component Options in the init Call](https://docs.coveo.com/en/346/#passing-component-options-in-the-init-call)),\n * > or before the `init` call, using the `options` top-level function (see\n * > [Passing Component Options Before the init Call](https://docs.coveo.com/en/346/#passing-component-options-before-the-init-call)).\n *\n * **Example:**\n * ```javascript\n * // You can set the option in the 'init' call:\n * Coveo.init(document.querySelector(\"#search\"), {\n * ResultLink : {\n * onClick : function(e, result) {\n * e.preventDefault();\n * // Custom code to execute with the item URI and title.\n * openUriInASpecialTab(result.clickUri, result.title);\n * }\n * }\n * });\n *\n * // Or before the 'init' call, using the 'options' top-level function:\n * // Coveo.options(document.querySelector('#search'), {\n * // ResultLink : {\n * // onClick : function(e, result) {\n * // e.preventDefault();\n * // // Custom code to execute with the item URI and title.\n * // openUriInASpecialTab(result.clickUri, result.title);\n * // }\n * // }\n * // });\n * ```\n */\n onClick: ComponentOptions_1.ComponentOptions.buildCustomOption(function () {\n return null;\n }),\n /**\n * Specify this option to log additional analytics when this result link is pressed.\n *\n * **Example:**\n * ```javascript\n * const resultLink = new Coveo.ResultLink(\n * linkElement,\n * {\n * logAnalytics: (href) => Coveo.logCustomEvent(\n * Coveo.analyticsActionCauseList.openSmartSnippetSource,\n * {\n * searchQueryUid: searchInterface.queryController.lastSearchUid,\n * documentTitle: result.title,\n * author: Utils.getFieldValue(result, 'author'),\n * documentURL: href\n * },\n * element\n * )\n * },\n * searchInterface.getBindings(),\n * result\n * )\n * ```\n */\n logAnalytics: ComponentOptions_1.ComponentOptions.buildCustomOption(function () { return null; })\n };\n return ResultLink;\n}(Component_1.Component));\nexports.ResultLink = ResultLink;\nInitialization_1.Initialization.registerAutoCreateComponent(ResultLink);\n\n\n/***/ })\n\n});\n\n\n// WEBPACK FOOTER //\n// ResultLink.min__d957946aa95219e5e0e2.js","import { Component } from '../Base/Component';\nimport { ComponentOptions } from '../Base/ComponentOptions';\nimport { ComponentOptionsModel } from '../../models/ComponentOptionsModel';\nimport { IResultsComponentBindings } from '../Base/ResultsComponentBindings';\nimport { analyticsActionCauseList } from '../Analytics/AnalyticsActionListMeta';\nimport { IResultLinkOptions } from './ResultLinkOptions';\nimport { ResultListEvents } from '../../events/ResultListEvents';\nimport { HighlightUtils } from '../../utils/HighlightUtils';\nimport { IQueryResult } from '../../rest/QueryResult';\nimport { DeviceUtils } from '../../utils/DeviceUtils';\nimport { OS_NAME, OSUtils } from '../../utils/OSUtils';\nimport { Initialization } from '../Base/Initialization';\nimport { QueryUtils } from '../../utils/QueryUtils';\nimport { Assert } from '../../misc/Assert';\nimport { Utils } from '../../utils/Utils';\nimport { Defer } from '../../misc/Defer';\nimport { $$ } from '../../utils/Dom';\nimport { StreamHighlightUtils } from '../../utils/StreamHighlightUtils';\nimport { StringUtils } from '../../utils/StringUtils';\nimport { once, debounce, extend, escape } from 'underscore';\nimport { exportGlobally } from '../../GlobalExports';\n\nimport 'styling/_ResultLink';\nimport { AccessibleButton } from '../../utils/AccessibleButton';\n\n/**\n * The `ResultLink` component automatically transform a search result title into a clickable link pointing to the\n * original item.\n *\n * This component is a result template component (see [Result Templates](https://docs.coveo.com/en/413/)).\n */\nexport class ResultLink extends Component {\n static ID = 'ResultLink';\n\n static doExport = () => {\n exportGlobally({\n ResultLink: ResultLink\n });\n };\n\n /**\n * The options for the ResultLink\n * @componentOptions\n */\n static options: IResultLinkOptions = {\n /**\n * Specifies the field to use to output the component `href` attribute value.\n *\n * **Tip:**\n * > Instead of specifying a value for the `field` option, you can directly add an `href` attribute to the\n * > `ResultLink` HTML element. Then, you can use a custom script to generate the `href` value.\n *\n * **Examples:**\n * - With the following markup, the `ResultLink` outputs its `href` value using the `@uri` field (rather than the\n * default field):\n *\n * ```html\n * \n * ```\n *\n * - In the following result template, the custom `getMyKBUri()` function provides the `href` value:\n *\n * ```html\n * \n * ```\n *\n * See also [`hrefTemplate`]{@link ResultLink.options.hrefTemplate}, which can override this option.\n *\n * By default, the component uses the `@clickUri` field of the item to output the value of its `href` attribute.\n */\n field: ComponentOptions.buildFieldOption(),\n\n /**\n * Specifies whether the component should try to open its link in Microsoft Outlook.\n *\n * Setting this option to `true` is normally useful for `ResultLink` instances related to Microsoft Exchange emails.\n *\n * If this option is `true`, clicking the `ResultLink` calls the\n * [`openLinkInOutlook`]{@link ResultLink.openLinkInOutlook} method instead of the\n * [`openLink`]{@link ResultLink.openLink} method.\n *\n * Default value is `false`.\n */\n openInOutlook: ComponentOptions.buildBooleanOption({ defaultValue: false }),\n\n /**\n * Specifies whether the component should open its link in the [`Quickview`]{@link Quickview} component rather than\n * loading through the original URL.\n *\n * Default value is `false`.\n */\n openQuickview: ComponentOptions.buildBooleanOption({ defaultValue: false }),\n\n /**\n * Specifies whether the component should open its link in a new window instead of opening it in the current\n * context.\n *\n * If this option is `true`, clicking the `ResultLink` calls the\n * [`openLinkInNewWindow`]{@link ResultLink.openLinkInNewWindow} method instead of the\n * [`openLink`]{@link ResultLink.openLink} method.\n *\n * **Note:**\n * > If a search page contains a [`ResultPreferences`]{@link ResultsPreferences} component whose\n * > [`enableOpenInNewWindow`]{@link ResultsPreferences.options.enableOpenInNewWindow} option is `true`, and the end\n * > user checks the Always open results in new window box, `ResultLink` components in this page will always\n * > open their links in a new window when the end user clicks them, no matter what the value of their\n * > `alwaysOpenInNewWindow` option is.\n *\n * Default value is `false`.\n */\n alwaysOpenInNewWindow: ComponentOptions.buildBooleanOption({ defaultValue: false }),\n\n /**\n * Specifies a template literal from which to generate the `ResultLink` `href` attribute value (see\n * [Template literals](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals)).\n *\n * This option overrides the [`field`]{@link ResultLink.options.field} option value.\n *\n * The template literal can reference any number of fields from the parent result. It can also reference global\n * scope properties.\n *\n * **Examples:**\n *\n * - The following markup generates an `href` value such as `http://uri.com?id=itemTitle`:\n *\n * ```html\n * \n * ```\n *\n * - The following markup generates an `href` value such as `localhost/fooBar`:\n *\n * ```html\n * \n * ```\n *\n * Default value is `undefined`.\n */\n hrefTemplate: ComponentOptions.buildStringOption(),\n\n /**\n * Specifies a template literal from which to generate the `ResultLink` display title (see\n * [Template literals](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals)).\n *\n * This option overrides the default `ResultLink` display title behavior.\n *\n * The template literal can reference any number of fields from the parent result. However, if the template literal\n * references a key whose value is undefined in the parent result fields, the `ResultLink` title displays the\n * name of this key instead.\n *\n * This option is ignored if the `ResultLink` innerHTML contains any value.\n *\n * **Examples:**\n *\n * - The following markup generates a `ResultLink` display title such as `Case number: 123456` if both the\n * `raw.objecttype` and `raw.objectnumber` keys are defined in the parent result fields:\n *\n * ```html\n * \n * ```\n *\n * - The following markup generates `${myField}` as a `ResultLink` display title if the `myField` key is undefined\n * in the parent result fields:\n *\n * ```html\n * \n * ```\n *\n * - The following markup generates `Foobar` as a `ResultLink` display title, because the `ResultLink` innterHTML is\n * not empty:\n *\n * ```html\n * Foobar\n * ```\n *\n * Default value is `undefined`.\n *\n * @availablesince [January 2017 Release (v1.1865.9)](https://docs.coveo.com/en/396/#january-2017-release-v118659)\n */\n titleTemplate: ComponentOptions.buildStringOption(),\n\n /**\n * Specifies an event handler function to execute when the user clicks the `ResultLink` component.\n *\n * The handler function takes a JavaScript [`Event`](https://developer.mozilla.org/en/docs/Web/API/Event) object and\n * an [`IQueryResult`]{@link IQueryResult} as its parameters.\n *\n * Overriding the default behavior of the `onClick` event can allow you to execute specific code instead.\n *\n * **Note:**\n * > You cannot set this option directly in the component markup as an HTML attribute. You must either set it in the\n * > [`init`]{@link init} call of your search interface (see\n * > [Passing Component Options in the init Call](https://docs.coveo.com/en/346/#passing-component-options-in-the-init-call)),\n * > or before the `init` call, using the `options` top-level function (see\n * > [Passing Component Options Before the init Call](https://docs.coveo.com/en/346/#passing-component-options-before-the-init-call)).\n *\n * **Example:**\n * ```javascript\n * // You can set the option in the 'init' call:\n * Coveo.init(document.querySelector(\"#search\"), {\n * ResultLink : {\n * onClick : function(e, result) {\n * e.preventDefault();\n * // Custom code to execute with the item URI and title.\n * openUriInASpecialTab(result.clickUri, result.title);\n * }\n * }\n * });\n *\n * // Or before the 'init' call, using the 'options' top-level function:\n * // Coveo.options(document.querySelector('#search'), {\n * // ResultLink : {\n * // onClick : function(e, result) {\n * // e.preventDefault();\n * // // Custom code to execute with the item URI and title.\n * // openUriInASpecialTab(result.clickUri, result.title);\n * // }\n * // }\n * // });\n * ```\n */\n onClick: ComponentOptions.buildCustomOption<(e: Event, result: IQueryResult) => any>(() => {\n return null;\n }),\n\n /**\n * Specify this option to log additional analytics when this result link is pressed.\n *\n * **Example:**\n * ```javascript\n * const resultLink = new Coveo.ResultLink(\n * linkElement,\n * {\n * logAnalytics: (href) => Coveo.logCustomEvent(\n * Coveo.analyticsActionCauseList.openSmartSnippetSource,\n * {\n * searchQueryUid: searchInterface.queryController.lastSearchUid,\n * documentTitle: result.title,\n * author: Utils.getFieldValue(result, 'author'),\n * documentURL: href\n * },\n * element\n * )\n * },\n * searchInterface.getBindings(),\n * result\n * )\n * ```\n */\n logAnalytics: ComponentOptions.buildCustomOption<(href: string) => void>(() => null)\n };\n\n private toExecuteOnOpen: (e?: Event) => void;\n\n /**\n * Creates a new `ResultLink` component.\n * @param element The HTMLElement on which to instantiate the component.\n * @param options The options for the `ResultLink` component.\n * @param bindings The bindings that the component requires to function normally. If not set, these will be\n * automatically resolved (with a slower execution time).\n * @param result The result to associate the component with.\n * @param os\n */\n constructor(\n public element: HTMLElement,\n public options: IResultLinkOptions,\n public bindings?: IResultsComponentBindings,\n public result?: IQueryResult,\n public os?: OS_NAME\n ) {\n super(element, ResultLink.ID, bindings);\n\n const globalOptions = this.searchInterface.options.originalOptionsObject[ResultLink.ID] || {};\n const initialOptions = ComponentOptions.initComponentOptions(element, ResultLink, { ...globalOptions, ...options });\n const resultLinkOptions = this.componentOptionsModel.get(ComponentOptionsModel.attributesEnum.resultLink);\n this.options = extend({}, initialOptions, resultLinkOptions);\n\n this.result = result || this.resolveResult();\n\n if (this.options.openQuickview == null) {\n this.options.openQuickview = result.raw['connectortype'] == 'ExchangeCrawler' && DeviceUtils.isMobileDevice();\n }\n if (!this.element.hasAttribute('tabindex')) {\n this.element.setAttribute('tabindex', '0');\n }\n\n Assert.exists(this.componentOptionsModel);\n Assert.exists(this.result);\n\n if (!this.quickviewShouldBeOpened()) {\n // Bind on multiple \"click\" or \"mouse\" events.\n // Create a function that will be executed only once, so as not to log multiple events\n // Once a result link has been opened, and that we log at least one analytics event,\n // it should not matter if the end user open the same link multiple times with different methods.\n // It's still only one \"click\" event as far as UA is concerned.\n // Also need to handle \"longpress\" on mobile (the contextual menu), which we assume to be 1 s long.\n\n const executeOnlyOnce = once(() => this.logAnalytics());\n\n $$(element).on(['contextmenu', 'click', 'mousedown', 'mouseup'], executeOnlyOnce);\n let longPressTimer: number;\n $$(element).on('touchstart', () => {\n longPressTimer = window.setTimeout(executeOnlyOnce, 1000);\n });\n $$(element).on('touchend', () => {\n if (longPressTimer) {\n clearTimeout(longPressTimer);\n }\n });\n }\n this.renderUri(element, result);\n this.bindEventToOpen();\n }\n public renderUri(element: HTMLElement, result?: IQueryResult) {\n if (/^\\s*$/.test(this.element.innerHTML)) {\n const title = this.getDisplayedTitle();\n this.element.innerHTML = title;\n\n const titleAsText = this.getDisplayedTitleAsText();\n if (!this.element.hasAttribute('aria-label')) {\n this.element.setAttribute('aria-label', titleAsText);\n }\n\n if (!this.element.title) {\n this.element.title = titleAsText;\n }\n }\n }\n /**\n * Opens the result in the same window, no matter how the actual component is configured for the end user.\n * @param logAnalytics Specifies whether the method should log an analytics event.\n */\n public openLink(logAnalytics = true) {\n if (logAnalytics) {\n this.logAnalytics();\n }\n window.location.href = this.getResultUri();\n }\n\n /**\n * Opens the result in a new window, no matter how the actual component is configured for the end user.\n * @param logAnalytics Specifies whether the method should log an analytics event.\n */\n public openLinkInNewWindow(logAnalytics = true) {\n if (logAnalytics) {\n this.logAnalytics();\n }\n window.open(this.getResultUri(), '_blank');\n }\n\n /**\n * Tries to open the result in Microsoft Outlook if the result has an `outlookformacuri` or `outlookuri` field.\n *\n * Normally, this implies the result should be a link to an email.\n *\n * If the needed fields are not present, this method does nothing.\n * @param logAnalytics Specifies whether the method should log an analytics event.\n */\n public openLinkInOutlook(logAnalytics = true) {\n if (this.hasOutlookField()) {\n if (logAnalytics) {\n this.logAnalytics();\n }\n this.openLink();\n }\n }\n\n /**\n * Opens the link in the same manner the end user would.\n *\n * This essentially simulates a click on the result link.\n *\n * @param logAnalytics Specifies whether the method should log an analytics event.\n */\n public openLinkAsConfigured(logAnalytics = true) {\n if (this.toExecuteOnOpen) {\n if (logAnalytics) {\n this.logAnalytics();\n }\n this.toExecuteOnOpen();\n }\n }\n\n protected bindEventToOpen(): boolean {\n return (\n this.bindOnClickIfNotUndefined() ||\n this.bindOpenQuickviewIfNotUndefined() ||\n this.setHrefIfNotAlready() ||\n this.openLinkThatIsNotAnAnchor()\n );\n }\n\n private getDisplayedTitle() {\n if (!this.options.titleTemplate) {\n return this.result.title\n ? HighlightUtils.highlightString(this.result.title, this.result.titleHighlights, null, 'coveo-highlight')\n : this.escapedClickUri;\n } else {\n let newTitle = StringUtils.buildStringTemplateFromResult(this.options.titleTemplate, this.result);\n return newTitle\n ? StreamHighlightUtils.highlightStreamText(newTitle, this.result.termsToHighlight, this.result.phrasesToHighlight)\n : this.escapedClickUri;\n }\n }\n\n private getDisplayedTitleAsText() {\n const container = $$('div');\n container.setHtml(this.getDisplayedTitle());\n return container.text();\n }\n\n private get escapedClickUri() {\n return escape(this.result.clickUri);\n }\n\n private bindOnClickIfNotUndefined() {\n if (this.options.onClick != undefined) {\n this.toExecuteOnOpen = (e: MouseEvent) => {\n this.options.onClick.call(this, e, this.result);\n };\n\n new AccessibleButton()\n .withElement(this.element)\n .withLabel(this.result.title)\n .withSelectAction((e: Event) => this.toExecuteOnOpen(e))\n .build();\n\n return true;\n } else {\n return false;\n }\n }\n\n private bindOpenQuickviewIfNotUndefined() {\n if (this.quickviewShouldBeOpened()) {\n this.toExecuteOnOpen = () => {\n $$(this.bindings.resultElement).trigger(ResultListEvents.openQuickview);\n };\n\n $$(this.element).on('click', (e: Event) => {\n e.preventDefault();\n this.toExecuteOnOpen();\n });\n\n return true;\n } else {\n return false;\n }\n }\n\n private openLinkThatIsNotAnAnchor() {\n if (!this.elementIsAnAnchor()) {\n this.toExecuteOnOpen = () => {\n if (this.options.alwaysOpenInNewWindow) {\n if (this.options.openInOutlook) {\n this.openLinkInOutlook();\n } else {\n this.openLinkInNewWindow();\n }\n } else {\n this.openLink();\n }\n };\n\n $$(this.element).on('click', () => {\n this.toExecuteOnOpen();\n });\n\n return true;\n }\n return false;\n }\n\n private setHrefIfNotAlready() {\n // Do not erase any value put in href by the template, etc. Allows\n // using custom click urls while still keeping analytics recording\n // and other behavior brought by the component.\n if (this.elementIsAnAnchor() && !Utils.isNonEmptyString($$(this.element).getAttribute('href'))) {\n $$(this.element).setAttribute('href', this.getResultUri());\n if (this.options.alwaysOpenInNewWindow && !(this.options.openInOutlook && this.hasOutlookField())) {\n $$(this.element).setAttribute('target', '_blank');\n }\n return true;\n } else {\n return false;\n }\n }\n\n private logDocumentOpen(href: string) {\n this.usageAnalytics.logClickEvent(\n analyticsActionCauseList.documentOpen,\n {\n documentURL: href,\n documentTitle: this.result.title,\n author: Utils.getFieldValue(this.result, 'author')\n },\n this.result,\n this.root\n );\n }\n\n private logAnalytics = debounce(\n () => {\n this.queryController.saveLastQuery();\n let documentURL = $$(this.element).getAttribute('href');\n if (documentURL == undefined || documentURL == '') {\n documentURL = this.escapedClickUri;\n }\n if (this.options.logAnalytics) {\n this.options.logAnalytics(documentURL);\n } else {\n this.logDocumentOpen(documentURL);\n }\n Defer.flush();\n },\n 1500,\n true\n );\n\n private filterProtocol(uri: string) {\n const isAbsolute = /^(https?|ftp|file|mailto|tel):/i.test(uri);\n const isRelative = /^(\\/|\\.\\/|\\.\\.\\/)/.test(uri);\n\n return isAbsolute || isRelative ? uri : '';\n }\n\n private getResultUri(): string {\n if (this.options.hrefTemplate) {\n const uri = StringUtils.buildStringTemplateFromResult(this.options.hrefTemplate, this.result);\n return this.filterProtocol(uri);\n }\n\n if (this.options.field == undefined && this.options.openInOutlook) {\n this.setField();\n }\n\n if (this.options.field != undefined) {\n return this.filterProtocol(Utils.getFieldValue(this.result, this.options.field));\n }\n\n return this.filterProtocol(this.result.clickUri);\n }\n\n private elementIsAnAnchor() {\n return this.element.tagName == 'A';\n }\n\n private setField() {\n let os = Utils.exists(this.os) ? this.os : OSUtils.get();\n if (os == OS_NAME.MACOSX && this.hasOutlookField()) {\n this.options.field = '@outlookformacuri';\n } else if (os == OS_NAME.WINDOWS && this.hasOutlookField()) {\n this.options.field = '@outlookuri';\n }\n }\n\n private hasOutlookField() {\n let os = Utils.exists(this.os) ? this.os : OSUtils.get();\n if (os == OS_NAME.MACOSX && this.result.raw['outlookformacuri'] != undefined) {\n return true;\n } else if (os == OS_NAME.WINDOWS && this.result.raw['outlookuri'] != undefined) {\n return true;\n }\n return false;\n }\n\n private isUriThatMustBeOpenedInQuickview(): boolean {\n return this.escapedClickUri.toLowerCase().indexOf('ldap://') == 0;\n }\n\n private quickviewShouldBeOpened() {\n return (this.options.openQuickview || this.isUriThatMustBeOpenedInQuickview()) && QueryUtils.hasHTMLVersion(this.result);\n }\n}\n\nInitialization.registerAutoCreateComponent(ResultLink);\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/ResultLink/ResultLink.ts"],"sourceRoot":""}