tooltip.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * DevExtreme (ui/tooltip/tooltip.js)
  3. * Version: 19.1.16
  4. * Build date: Tue Oct 18 2022
  5. *
  6. * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
  7. * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
  8. */
  9. "use strict";
  10. var $ = require("../../core/renderer");
  11. var Guid = require("../../core/guid");
  12. var registerComponent = require("../../core/component_registrator");
  13. var extend = require("../../core/utils/extend").extend;
  14. var Popover = require("../popover");
  15. var TOOLTIP_CLASS = "dx-tooltip";
  16. var TOOLTIP_WRAPPER_CLASS = "dx-tooltip-wrapper";
  17. var Tooltip = Popover.inherit({
  18. _getDefaultOptions: function() {
  19. return extend(this.callBase(), {
  20. toolbarItems: [],
  21. showCloseButton: false,
  22. showTitle: false,
  23. title: null,
  24. titleTemplate: null,
  25. onTitleRendered: null,
  26. bottomTemplate: null,
  27. propagateOutsideClick: true
  28. })
  29. },
  30. _render: function() {
  31. this.$element().addClass(TOOLTIP_CLASS);
  32. this._wrapper().addClass(TOOLTIP_WRAPPER_CLASS);
  33. this.callBase()
  34. },
  35. _renderContent: function() {
  36. this.callBase();
  37. this._contentId = "dx-" + new Guid;
  38. this._$content.attr({
  39. id: this._contentId,
  40. role: "tooltip"
  41. });
  42. this._toggleAriaDescription(true)
  43. },
  44. _toggleAriaDescription: function(showing) {
  45. var $target = $(this.option("target"));
  46. var label = showing ? this._contentId : void 0;
  47. this.setAria("describedby", label, $target)
  48. }
  49. });
  50. registerComponent("dxTooltip", Tooltip);
  51. module.exports = Tooltip;