highcharts
Version:
JavaScript charting framework
70 lines (69 loc) • 1.95 kB
JavaScript
/* *
*
* Popup generator for Stock tools
*
* (c) 2009-2026 Highsoft AS
* Author: Sebastian Bochan
*
* A commercial license may be required depending on use.
* See www.highcharts.com/license
*
*
* */
;
import H from '../../../Core/Globals.js';
const { composed } = H;
import Popup from './Popup.js';
import { addEvent, pushUnique, wrap } from '../../../Shared/Utilities.js';
/* *
*
* Functions
*
* */
/** @internal */
function compose(NavigationBindingsClass, PointerClass) {
if (pushUnique(composed, 'Popup')) {
addEvent(NavigationBindingsClass, 'closePopup', onNavigationBindingsClosePopup);
addEvent(NavigationBindingsClass, 'showPopup', onNavigationBindingsShowPopup);
wrap(PointerClass.prototype, 'onContainerMouseDown', wrapPointerOnContainerMouserDown);
}
}
/** @internal */
function onNavigationBindingsClosePopup() {
if (this.popup) {
this.popup.closePopup();
}
}
/** @internal */
function onNavigationBindingsShowPopup(config) {
if (!this.popup) {
// Add popup to main container
this.popup = new Popup(this.chart.container, (this.chart.options.navigation.iconsURL ||
(this.chart.options.stockTools &&
this.chart.options.stockTools.gui.iconsURL) ||
'https://code.highcharts.com/12.6.0/gfx/stock-icons/'), this.chart);
}
this.popup.showForm(config.formType, this.chart, config.options, config.onSubmit);
}
/**
* `onContainerMouseDown` blocks internal popup events, due to e.preventDefault.
* Related issue #4606
* @internal
*/
function wrapPointerOnContainerMouserDown(proceed, e) {
// Elements is not in popup
if (!this.inClass(e.target, 'highcharts-popup')) {
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
}
}
/* *
*
* Default Export
*
* */
/** @internal */
const PopupComposition = {
compose
};
/** @internal */
export default PopupComposition;