UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

100 lines (98 loc) 3.4 kB
/** * DevExtreme (cjs/ui/slider/ui.slider_tooltip.js) * Version: 23.2.6 * Build date: Wed May 01 2024 * * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ "use strict"; exports.default = void 0; var _tooltip = _interopRequireDefault(require("../tooltip")); var _extend = require("../../core/utils/extend"); var _slider_tooltip_position_controller = require("./slider_tooltip_position_controller"); var _number = _interopRequireDefault(require("../../localization/number")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj } } const SLIDER_TOOLTIP_VISIBILITY_CLASS = "dx-slider-tooltip-visible-on-hover"; const SliderTooltip = _tooltip.default.inherit({ _getDefaultOptions() { return (0, _extend.extend)(this.callBase(), { visible: false, position: "top", hideOnOutsideClick: false, hideTopOverlayHandler: null, hideOnParentScroll: false, animation: null, arrowPosition: null, templatesRenderAsynchronously: false, _fixWrapperPosition: false, useResizeObserver: false, showMode: "onHover", format: value => value, value: 0 }) }, _initMarkup() { this.callBase(); this._attachToMarkup(this.option("visible")); this._toggleShowModeClass() }, _renderContent() { this.callBase(); this._renderContentText() }, _toggleAriaAttributes() {}, _renderContentText() { const { value: value, format: format } = this.option(); const formattedText = _number.default.format(null !== value && void 0 !== value ? value : 0, format); this.$content().text(formattedText); this._renderPosition() }, _toggleShowModeClass() { const isHoverMode = "onHover" === this.option("showMode"); const $sliderHandle = this.option("target"); $sliderHandle.toggleClass(SLIDER_TOOLTIP_VISIBILITY_CLASS, isHoverMode) }, _initPositionController() { this._positionController = new _slider_tooltip_position_controller.SliderTooltipPositionController(this._getPositionControllerConfig()) }, _attachToMarkup(enabled) { const $sliderHandle = this.option("target"); enabled ? this.$element().appendTo($sliderHandle) : this.$element().detach() }, _optionChanged(args) { const { name: name, value: value } = args; switch (name) { case "visible": this._attachToMarkup(value); this.callBase(args); break; case "showMode": this._toggleShowModeClass(); break; case "format": case "value": this._renderContentText(); break; default: this.callBase(args) } }, updatePosition() { this._renderPosition() } }); var _default = SliderTooltip; exports.default = _default; module.exports = exports.default; module.exports.default = exports.default;