From f328e43ca4cb5f3d2c2613a611b47ab8b4dfbf9a Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Tue, 1 Sep 2020 17:15:39 +0300 Subject: [PATCH] [common] Update bootstrap (fix tooltip) --- apps/common/main/lib/util/Tip.js | 55 +++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/apps/common/main/lib/util/Tip.js b/apps/common/main/lib/util/Tip.js index 100401260..2795fec8f 100644 --- a/apps/common/main/lib/util/Tip.js +++ b/apps/common/main/lib/util/Tip.js @@ -89,7 +89,7 @@ define([ }; Tip['VERSION'] = $.fn.tooltip.Constructor['VERSION']; - Tip['Default'] = $.extend($.fn.tooltip.Constructor['Default'], {container: 'body', delay: {show:500}, arrow: false}); + Tip['Default'] = $.extend($.fn.tooltip.Constructor['Default'], {container: 'body', delay: {show:500}, arrow: false, boundary: $('#viewport')[0]}); Tip['NAME'] = $.fn.tooltip.Constructor['NAME']; Tip['DATA_KEY'] = $.fn.tooltip.Constructor['DATA_KEY']; Tip['Event'] = $.fn.tooltip.Constructor['Event']; @@ -106,6 +106,11 @@ define([ this._activeTrigger = {}; this._popper = null; this.element = element; + if (!config.template) { + config.template = config.arrow ? + '' : + ''; + } this.config = this._getConfig(config); this.tip = null; @@ -139,7 +144,8 @@ define([ }, show: function (at) { - var me = this; + var me = this, + prevHoverState = this._hoverState; if (this.isWithContent() && this._isEnabled && !this.dontShow) { @@ -162,10 +168,6 @@ define([ $(tip).addClass('fade'); } var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement; - if (placement !== 'cursor') { - var attachment = this._getAttachment(placement); - this.addAttachmentClass(attachment); - } var container = this._getContainer(); $(tip).data(this.constructor.DATA_KEY, this); if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) { @@ -228,19 +230,18 @@ define([ $(document.body).children().on('mouseover', null, $.noop); } - var prevHoverState = me._hoverState; - me._hoverState = null; - $(me.element).trigger(me.constructor.Event.SHOWN); + this._hoverState = null; + $(this.element).trigger(this.constructor.Event.SHOWN); if (prevHoverState === 'out') { - me._leave(null, me); + this._leave(null, this); } } } - clearTimeout(me.timeout); - me.timeout = setTimeout(function () { + clearTimeout(this.timeout); + this.timeout = setTimeout(function () { if (prevHoverState == 'show') me.hide(); me.dontShow = false; }, 5000); @@ -296,6 +297,36 @@ define([ context.show(context.config.placement == 'cursor' && context.mouse ? [context.mouse.clientX, context.mouse.clientY] : undefined); } }, context.config.delay.show); + }, + + _getPopperConfig: function (attachment) { + var me = this; + var config = { + placement: attachment, + modifiers: { + offset: this._getOffset(), + flip: { + behavior: this.config.fallbackPlacement + }, + preventOverflow: { + boundariesElement: this.config.boundary + } + }, + onCreate: function onCreate(data) { + if (data.originalPlacement !== data.placement) { + me._handlePopperPlacementChange(data); + } + }, + onUpdate: function onUpdate(data) { + return me._handlePopperPlacementChange(data); + } + }; + if (this.config.arrow) { + config.modifiers.arrow = { + element: '.arrow' + }; + } + return config; } /*_getOffset: function (placement, pos, actualWidth, actualHeight) {