{"version":3,"sources":["Settings.min__d957946aa95219e5e0e2.js","./src/ui/Settings/Settings.ts"],"names":["webpackJsonpCoveo__temporary","279","module","exports","__webpack_require__","__extends","this","extendStatics","Object","setPrototypeOf","__proto__","Array","d","b","p","hasOwnProperty","__","constructor","prototype","create","defineProperty","value","element","options","bindings","Settings","ID","isOpened","ComponentOptions","initComponentOptions","bind","onRootElement","InitializationEvents","afterInitialization","init","_this","open","menu","$$","detach","buildMenu","insertAfter","placement","modifiers","offset","preventOverflow","boundariesElement","root","close","toggle","square","className","el","squares","times","appendChild","cloneNode","AccessibleButton","withElement","withOwner","withSelectAction","withFocusAndMouseEnterAction","onfocus","withBlurAndMouseLeaveAction","onblur","withLabel","l","build","settingsPopulateMenuArgs","settings","menuData","trigger","SettingsEvents","settingsPopulateMenu","each","menuItem","menuItemElement","menuItemIcon","menuItemText","buildMenuItem","selectAction","onClose","onOpen","tooltip","text","buildMenuItemIcon","buildMenuItemText","iconElement","svgIcon","innerHTML","svgIconClassName","SVGDom","addClassToSVGInContainer","escape","clearTimeout","closeTimeout","window","setTimeout","menuDelay","doExport","exportGlobally","buildNumberOption","defaultValue","min","Component","Initialization","registerAutoCreateComponent","669"],"mappings":"AAAAA,8BAA8B,KAExBC,IACA,SAAUC,EAAQC,EAASC,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,OAGvFR,QAAOY,eAAejB,EAAS,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,cAClBzF,KAAKyF,aAAeC,OAAOC,WAAW,WACpC,EAAKjD,SACJ1C,KAAKiB,QAAQ2E,YAGV,YAAApC,QAAR,WACEgC,aAAaxF,KAAKyF,eArLb,EAAArE,GAAK,WAEL,EAAAyE,SAAW,WAChB,EAAAC,gBACE3E,SAAUA,KAQP,EAAAF,SAML2E,UAAW,EAAAtE,iBAAiByE,mBAAoBC,aAAc,IAAKC,IAAK,KAqK5E,GAxL8B,EAAAC,UAAjB,GAAA/E,WAyLb,EAAAgF,eAAeC,4BAA4BjF,IDXrCkF,IACA,SAAUzG,EAAQC","file":"Settings.min__d957946aa95219e5e0e2.js","sourcesContent":["webpackJsonpCoveo__temporary([62],{\n\n/***/ 279:\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})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar popper_js_1 = __webpack_require__(96);\n__webpack_require__(669);\nvar underscore_1 = __webpack_require__(0);\nvar InitializationEvents_1 = __webpack_require__(16);\nvar SettingsEvents_1 = __webpack_require__(55);\nvar GlobalExports_1 = __webpack_require__(3);\nvar Strings_1 = __webpack_require__(6);\nvar AccessibleButton_1 = __webpack_require__(17);\nvar Dom_1 = __webpack_require__(1);\nvar SVGDom_1 = __webpack_require__(15);\nvar Component_1 = __webpack_require__(7);\nvar ComponentOptions_1 = __webpack_require__(8);\nvar Initialization_1 = __webpack_require__(2);\n/**\n * The Settings component renders a **Settings** button that the end user can click to access a popup menu from which\n * it is possible to perform several contextual actions. The usual location of the **Settings** button in the page is to\n * the right of the {@link Searchbox}.\n *\n * This component can reference several components to populate its popup menu:\n * - {@link AdvancedSearch}\n * - {@link ExportToExcel}\n * - {@link PreferencesPanel} (see also {@link ResultsFiltersPreferences} and {@link ResultsPreferences})\n * - {@link SearchAlerts} (see also {@link SearchAlertsMessage})\n * - {@link ShareQuery}\n */\nvar Settings = /** @class */ (function (_super) {\n    __extends(Settings, _super);\n    /**\n     * Creates a new Settings component.\n     * @param element The HTMLElement on which to instantiate the component.\n     * @param options The options for the Settings 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     */\n    function Settings(element, options, bindings) {\n        var _this = _super.call(this, element, Settings.ID, bindings) || this;\n        _this.element = element;\n        _this.options = options;\n        _this.isOpened = false;\n        _this.options = ComponentOptions_1.ComponentOptions.initComponentOptions(element, Settings, options);\n        _this.bind.onRootElement(InitializationEvents_1.InitializationEvents.afterInitialization, function () { return _this.init(); });\n        return _this;\n    }\n    /**\n     * Opens the **Settings** popup menu.\n     */\n    Settings.prototype.open = function () {\n        this.isOpened = true;\n        if (this.menu != null) {\n            Dom_1.$$(this.menu).detach();\n        }\n        this.menu = this.buildMenu();\n        Dom_1.$$(this.menu).insertAfter(this.element);\n        new popper_js_1.default(this.element, this.menu, {\n            placement: 'bottom-end',\n            modifiers: {\n                offset: {\n                    offset: '0, 5'\n                },\n                preventOverflow: {\n                    boundariesElement: this.root\n                }\n            }\n        });\n    };\n    /**\n     * Closes the **Settings** popup menu.\n     */\n    Settings.prototype.close = function () {\n        this.isOpened = false;\n        if (this.menu != null) {\n            Dom_1.$$(this.menu).detach();\n            this.menu = null;\n        }\n    };\n    Settings.prototype.toggle = function () {\n        if (this.isOpened) {\n            this.close();\n        }\n        else {\n            this.open();\n        }\n    };\n    Settings.prototype.init = function () {\n        var _this = this;\n        var square = Dom_1.$$('span', { className: 'coveo-settings-square' }).el;\n        var squares = Dom_1.$$('span', { className: 'coveo-settings-squares' }).el;\n        underscore_1.times(3, function () { return squares.appendChild(square.cloneNode()); });\n        this.element.appendChild(squares);\n        new AccessibleButton_1.AccessibleButton()\n            .withElement(this.element)\n            .withOwner(this.bind)\n            .withSelectAction(function () { return _this.toggle(); })\n            .withFocusAndMouseEnterAction(function () { return _this.onfocus(); })\n            .withBlurAndMouseLeaveAction(function () { return _this.onblur(); })\n            .withLabel(Strings_1.l('Settings'))\n            .build();\n    };\n    Settings.prototype.buildMenu = function () {\n        var _this = this;\n        var menu = Dom_1.$$('div', { className: 'coveo-settings-advanced-menu' }).el;\n        var settingsPopulateMenuArgs = {\n            settings: this,\n            menuData: []\n        };\n        Dom_1.$$(this.root).trigger(SettingsEvents_1.SettingsEvents.settingsPopulateMenu, settingsPopulateMenuArgs);\n        underscore_1.each(settingsPopulateMenuArgs.menuData, function (menuItem) {\n            var _a = _this.buildMenuItem(menuItem, settingsPopulateMenuArgs), menuItemElement = _a.menuItemElement, menuItemIcon = _a.menuItemIcon, menuItemText = _a.menuItemText;\n            menuItemElement.appendChild(menuItemIcon);\n            menuItemElement.appendChild(menuItemText);\n            menu.appendChild(menuItemElement);\n        });\n        return menu;\n    };\n    Settings.prototype.buildMenuItem = function (menuItem, settingsPopulateMenuArgs) {\n        var _this = this;\n        var menuItemElement = Dom_1.$$('div', {\n            className: \"coveo-settings-item \" + menuItem.className\n        }).el;\n        var selectAction = function () {\n            underscore_1.each(settingsPopulateMenuArgs.menuData, function (menuItem) {\n                menuItem.onClose && menuItem.onClose();\n            });\n            _this.close();\n            menuItem.onOpen();\n        };\n        new AccessibleButton_1.AccessibleButton()\n            .withElement(menuItemElement)\n            .withSelectAction(selectAction)\n            .withFocusAndMouseEnterAction(function () { return _this.onfocus(); })\n            .withBlurAndMouseLeaveAction(function () { return _this.onblur(); })\n            .withLabel(menuItem.tooltip || menuItem.text)\n            .build();\n        return {\n            menuItemElement: menuItemElement,\n            menuItemIcon: this.buildMenuItemIcon(menuItem),\n            menuItemText: this.buildMenuItemText(menuItem)\n        };\n    };\n    Settings.prototype.buildMenuItemIcon = function (menuItem) {\n        var iconElement = Dom_1.$$('div', {\n            className: 'coveo-icon'\n        }).el;\n        if (menuItem.svgIcon) {\n            iconElement.innerHTML = menuItem.svgIcon;\n        }\n        if (menuItem.svgIconClassName) {\n            SVGDom_1.SVGDom.addClassToSVGInContainer(iconElement, menuItem.svgIconClassName);\n        }\n        return iconElement;\n    };\n    Settings.prototype.buildMenuItemText = function (menuItem) {\n        var textElement = Dom_1.$$('div', {\n            className: 'coveo-settings-text'\n        }, underscore_1.escape(menuItem.text)).el;\n        return textElement;\n    };\n    Settings.prototype.onblur = function () {\n        var _this = this;\n        clearTimeout(this.closeTimeout);\n        this.closeTimeout = window.setTimeout(function () {\n            _this.close();\n        }, this.options.menuDelay);\n    };\n    Settings.prototype.onfocus = function () {\n        clearTimeout(this.closeTimeout);\n    };\n    Settings.ID = 'Settings';\n    Settings.doExport = function () {\n        GlobalExports_1.exportGlobally({\n            Settings: Settings\n        });\n    };\n    /**\n     * The options for Settings\n     * @componentOptions\n     */\n    Settings.options = {\n        /**\n         * Specifies the delay (in milliseconds) before hiding the popup menu when the cursor is not hovering over it.\n         *\n         * Default value is `300`. Minimum value is `0 `.\n         */\n        menuDelay: ComponentOptions_1.ComponentOptions.buildNumberOption({ defaultValue: 300, min: 0 })\n    };\n    return Settings;\n}(Component_1.Component));\nexports.Settings = Settings;\nInitialization_1.Initialization.registerAutoCreateComponent(Settings);\n\n\n/***/ }),\n\n/***/ 669:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ })\n\n});\n\n\n// WEBPACK FOOTER //\n// Settings.min__d957946aa95219e5e0e2.js","import PopperJs from 'popper.js';\nimport 'styling/_Settings';\nimport { each, escape, times } from 'underscore';\nimport { InitializationEvents } from '../../events/InitializationEvents';\nimport { SettingsEvents } from '../../events/SettingsEvents';\nimport { exportGlobally } from '../../GlobalExports';\nimport { l } from '../../strings/Strings';\nimport { AccessibleButton } from '../../utils/AccessibleButton';\nimport { $$ } from '../../utils/Dom';\nimport { SVGDom } from '../../utils/SVGDom';\nimport { Component } from '../Base/Component';\nimport { IComponentBindings } from '../Base/ComponentBindings';\nimport { ComponentOptions } from '../Base/ComponentOptions';\nimport { Initialization } from '../Base/Initialization';\nimport { IMenuItem } from '../Menu/MenuItem';\n\nexport interface ISettingsPopulateMenuArgs {\n  settings: Settings;\n  menuData: IMenuItem[];\n}\n\nexport interface ISettingsOptions {\n  menuDelay: number;\n}\n\n/**\n * The Settings component renders a **Settings** button that the end user can click to access a popup menu from which\n * it is possible to perform several contextual actions. The usual location of the **Settings** button in the page is to\n * the right of the {@link Searchbox}.\n *\n * This component can reference several components to populate its popup menu:\n * - {@link AdvancedSearch}\n * - {@link ExportToExcel}\n * - {@link PreferencesPanel} (see also {@link ResultsFiltersPreferences} and {@link ResultsPreferences})\n * - {@link SearchAlerts} (see also {@link SearchAlertsMessage})\n * - {@link ShareQuery}\n */\nexport class Settings extends Component {\n  static ID = 'Settings';\n\n  static doExport = () => {\n    exportGlobally({\n      Settings: Settings\n    });\n  };\n\n  /**\n   * The options for Settings\n   * @componentOptions\n   */\n  static options: ISettingsOptions = {\n    /**\n     * Specifies the delay (in milliseconds) before hiding the popup menu when the cursor is not hovering over it.\n     *\n     * Default value is `300`. Minimum value is `0 `.\n     */\n    menuDelay: ComponentOptions.buildNumberOption({ defaultValue: 300, min: 0 })\n  };\n\n  private menu: HTMLElement;\n  private closeTimeout: number;\n  private isOpened: boolean = false;\n\n  /**\n   * Creates a new Settings component.\n   * @param element The HTMLElement on which to instantiate the component.\n   * @param options The options for the Settings 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   */\n  constructor(public element: HTMLElement, public options: ISettingsOptions, bindings?: IComponentBindings) {\n    super(element, Settings.ID, bindings);\n    this.options = ComponentOptions.initComponentOptions(element, Settings, options);\n    this.bind.onRootElement(InitializationEvents.afterInitialization, () => this.init());\n  }\n\n  /**\n   * Opens the **Settings** popup menu.\n   */\n  public open() {\n    this.isOpened = true;\n    if (this.menu != null) {\n      $$(this.menu).detach();\n    }\n\n    this.menu = this.buildMenu();\n    $$(this.menu).insertAfter(this.element);\n\n    new PopperJs(this.element, this.menu, {\n      placement: 'bottom-end',\n      modifiers: {\n        offset: {\n          offset: '0, 5'\n        },\n        preventOverflow: {\n          boundariesElement: this.root\n        }\n      }\n    });\n  }\n\n  /**\n   * Closes the **Settings** popup menu.\n   */\n  public close() {\n    this.isOpened = false;\n    if (this.menu != null) {\n      $$(this.menu).detach();\n      this.menu = null;\n    }\n  }\n\n  private toggle() {\n    if (this.isOpened) {\n      this.close();\n    } else {\n      this.open();\n    }\n  }\n\n  private init() {\n    const square = $$('span', { className: 'coveo-settings-square' }).el;\n    const squares = $$('span', { className: 'coveo-settings-squares' }).el;\n    times(3, () => squares.appendChild(square.cloneNode()));\n    this.element.appendChild(squares);\n\n    new AccessibleButton()\n      .withElement(this.element)\n      .withOwner(this.bind)\n      .withSelectAction(() => this.toggle())\n      .withFocusAndMouseEnterAction(() => this.onfocus())\n      .withBlurAndMouseLeaveAction(() => this.onblur())\n      .withLabel(l('Settings'))\n      .build();\n  }\n\n  private buildMenu(): HTMLElement {\n    const menu = $$('div', { className: 'coveo-settings-advanced-menu' }).el;\n    const settingsPopulateMenuArgs: ISettingsPopulateMenuArgs = {\n      settings: this,\n      menuData: []\n    };\n    $$(this.root).trigger(SettingsEvents.settingsPopulateMenu, settingsPopulateMenuArgs);\n\n    each(settingsPopulateMenuArgs.menuData, menuItem => {\n      const { menuItemElement, menuItemIcon, menuItemText } = this.buildMenuItem(menuItem, settingsPopulateMenuArgs);\n\n      menuItemElement.appendChild(menuItemIcon);\n      menuItemElement.appendChild(menuItemText);\n\n      menu.appendChild(menuItemElement);\n    });\n    return menu;\n  }\n\n  private buildMenuItem(menuItem: IMenuItem, settingsPopulateMenuArgs: ISettingsPopulateMenuArgs) {\n    const menuItemElement = $$('div', {\n      className: `coveo-settings-item ${menuItem.className}`\n    }).el;\n\n    const selectAction = () => {\n      each(settingsPopulateMenuArgs.menuData, menuItem => {\n        menuItem.onClose && menuItem.onClose();\n      });\n      this.close();\n      menuItem.onOpen();\n    };\n\n    new AccessibleButton()\n      .withElement(menuItemElement)\n      .withSelectAction(selectAction)\n      .withFocusAndMouseEnterAction(() => this.onfocus())\n      .withBlurAndMouseLeaveAction(() => this.onblur())\n      .withLabel(menuItem.tooltip || menuItem.text)\n      .build();\n\n    return {\n      menuItemElement,\n      menuItemIcon: this.buildMenuItemIcon(menuItem),\n      menuItemText: this.buildMenuItemText(menuItem)\n    };\n  }\n\n  private buildMenuItemIcon(menuItem: IMenuItem) {\n    const iconElement = $$('div', {\n      className: 'coveo-icon'\n    }).el;\n\n    if (menuItem.svgIcon) {\n      iconElement.innerHTML = menuItem.svgIcon;\n    }\n\n    if (menuItem.svgIconClassName) {\n      SVGDom.addClassToSVGInContainer(iconElement, menuItem.svgIconClassName);\n    }\n\n    return iconElement;\n  }\n\n  private buildMenuItemText(menuItem: IMenuItem) {\n    const textElement = $$(\n      'div',\n      {\n        className: 'coveo-settings-text'\n      },\n      escape(menuItem.text)\n    ).el;\n\n    return textElement;\n  }\n\n  private onblur() {\n    clearTimeout(this.closeTimeout);\n    this.closeTimeout = window.setTimeout(() => {\n      this.close();\n    }, this.options.menuDelay);\n  }\n\n  private onfocus() {\n    clearTimeout(this.closeTimeout);\n  }\n}\nInitialization.registerAutoCreateComponent(Settings);\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/Settings/Settings.ts"],"sourceRoot":""}