[REF] web, *: BS4, adapt use of tooltip/popover.js
This commit is contained in:
@@ -80,6 +80,7 @@ var ShowPaymentLineWidget = AbstractField.extend({
|
||||
title: 'Payment Information',
|
||||
trigger: 'focus',
|
||||
delay: { "show": 0, "hide": 100 },
|
||||
container: $(k).parent(), // FIXME Ugly, should use the default body container but system & tests to adapt to properly destroy the popover
|
||||
};
|
||||
$(k).popover(options);
|
||||
});
|
||||
|
||||
@@ -485,7 +485,7 @@ var LineRenderer = Widget.extend(FieldManagerMixin, {
|
||||
_destroyPopover: function ($el) {
|
||||
var popover = $el.data('bs.popover');
|
||||
if (popover) {
|
||||
popover.destroy();
|
||||
popover.dispose();
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -775,7 +775,7 @@ var LineRenderer = Widget.extend(FieldManagerMixin, {
|
||||
_onTogglePartialReconcile: function (e) {
|
||||
e.stopPropagation();
|
||||
var popover = $(e.target).data('bs.popover');
|
||||
popover && popover.destroy();
|
||||
popover && popover.dispose();
|
||||
this.trigger_up('toggle_partial_reconcile');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -91,7 +91,7 @@ var FieldOrgChart = AbstractField.extend({
|
||||
'.o_employee_sub_redirect', _.bind(self._onEmployeeSubRedirect, self));
|
||||
return $content;
|
||||
},
|
||||
template: $(QWeb.render('hr_orgchart_emp_popover', {})),
|
||||
template: QWeb.render('hr_orgchart_emp_popover', {}),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -322,8 +322,10 @@ var Activity = AbstractActivityField.extend({
|
||||
var previousActivityTypeID = $popoverElement.data('previous-activity-type-id');
|
||||
if (!$popoverElement.data('bs.popover')) {
|
||||
$popoverElement.popover({
|
||||
template: $(Popover.Default.template).addClass('o_mail_activity_feedback')[0].outerHTML, // Ugly but cannot find another way
|
||||
container: $popoverElement.parent(), // FIXME Ugly and should probably be in the body as by default but form view should handle destroying popovers
|
||||
title : _t("Feedback"),
|
||||
html: 'true',
|
||||
html: true,
|
||||
trigger:'click',
|
||||
content : function () {
|
||||
var $popover = $(QWeb.render('mail.activity_feedback_form', { 'previous_activity_type_id': previousActivityTypeID }));
|
||||
@@ -344,12 +346,10 @@ var Activity = AbstractActivityField.extend({
|
||||
});
|
||||
return $popover;
|
||||
},
|
||||
}).on('show.bs.popover', function (e) {
|
||||
var $popover = $(this).data('bs.popover').tip();
|
||||
$popover.addClass('o_mail_activity_feedback').attr('tabindex', 0);
|
||||
$('.o_mail_activity_feedback.popover').not(e.target).popover('hide');
|
||||
}).on('shown.bs.popover', function () {
|
||||
var $popover = $(this).data('bs.popover').tip();
|
||||
var $popover = $($(this).data("bs.popover").tip);
|
||||
$(".o_mail_activity_feedback.popover").not($popover).popover("hide");
|
||||
$popover.addClass('o_mail_activity_feedback').attr('tabindex', 0);
|
||||
$popover.find('#activity_feedback').focus();
|
||||
$popover.off('focusout');
|
||||
$popover.focusout(function (e) {
|
||||
|
||||
@@ -143,7 +143,7 @@ var Menu = Widget.extend({
|
||||
}
|
||||
// add a tooltip to cropped menu items
|
||||
this.$secondary_menus.find('.oe_secondary_submenu li a span').each(function() {
|
||||
$(this).tooltip(this.scrollWidth > this.clientWidth ? {title: $(this).text().trim(), placement: 'right'} :'destroy');
|
||||
$(this).tooltip(this.scrollWidth > this.clientWidth ? {title: $(this).text().trim(), placement: 'right'} : 'dispose');
|
||||
});
|
||||
},
|
||||
/**
|
||||
|
||||
+12
-16
@@ -7,23 +7,19 @@ odoo.define('web.bootstrap.extensions', function () {
|
||||
*/
|
||||
|
||||
/* Bootstrap defaults overwrite */
|
||||
$.fn.tooltip.Constructor.DEFAULTS.placement = 'auto top';
|
||||
$.fn.tooltip.Constructor.DEFAULTS.html = true;
|
||||
$.fn.tooltip.Constructor.DEFAULTS.trigger = 'hover focus click';
|
||||
$.fn.tooltip.Constructor.DEFAULTS.container = 'body';
|
||||
$.fn.tooltip.Constructor.DEFAULTS.delay = { show: 1000, hide: 0 };
|
||||
//overwrite bootstrap tooltip method to prevent showing 2 tooltip at the same time
|
||||
var bootstrap_show_function = $.fn.tooltip.Constructor.prototype.show;
|
||||
$.fn.modal.Constructor.prototype.enforceFocus = function () { };
|
||||
$.fn.tooltip.Constructor.Default.placement = 'top';
|
||||
$.fn.tooltip.Constructor.Default.fallbackPlacement = ['bottom', 'right', 'left', 'top'];
|
||||
$.fn.tooltip.Constructor.Default.html = true;
|
||||
$.fn.tooltip.Constructor.Default.trigger = 'hover focus click';
|
||||
$.fn.tooltip.Constructor.Default.container = 'body';
|
||||
$.fn.tooltip.Constructor.Default.delay = { show: 1000, hide: 0 };
|
||||
|
||||
var bootstrapShowFunction = $.fn.tooltip.Constructor.prototype.show;
|
||||
$.fn.tooltip.Constructor.prototype.show = function () {
|
||||
// Overwrite bootstrap tooltip method to prevent showing 2 tooltip at the
|
||||
// same time
|
||||
$('.tooltip').remove();
|
||||
//the following fix the bug when using placement
|
||||
//auto and the parent element does not exist anymore resulting in
|
||||
//an error. This should be remove once we updade bootstrap to a version that fix the bug
|
||||
//edit: bug has been fixed here : https://github.com/twbs/bootstrap/pull/13752
|
||||
var e = $.Event('show.bs.' + this.type);
|
||||
var inDom = $.contains(document.documentElement, this.$element[0]);
|
||||
if (e.isDefaultPrevented() || !inDom) return;
|
||||
return bootstrap_show_function.call(this);
|
||||
|
||||
return bootstrapShowFunction.call(this);
|
||||
};
|
||||
});
|
||||
|
||||
@@ -142,7 +142,7 @@ var CrashManager = core.Class.extend({
|
||||
});
|
||||
});
|
||||
dialog.on("closed", this, function () {
|
||||
$clipboardBtn.tooltip("destroy");
|
||||
$clipboardBtn.tooltip('dispose');
|
||||
clipboard.destroy();
|
||||
});
|
||||
|
||||
|
||||
@@ -152,7 +152,6 @@ var BasicRenderer = AbstractRenderer.extend({
|
||||
// widget's $el
|
||||
$node = $node.length ? $node : widget.$el;
|
||||
$node.tooltip({
|
||||
delay: { show: 1000, hide: 0 },
|
||||
title: function () {
|
||||
return qweb.render('WidgetLabel.tooltip', {
|
||||
debug: config.debug,
|
||||
|
||||
@@ -265,7 +265,6 @@ var FormRenderer = BasicRenderer.extend({
|
||||
_addButtonTooltip: function (node, $button) {
|
||||
var self = this;
|
||||
$button.tooltip({
|
||||
delay: { show: 1000, hide: 0 },
|
||||
title: function () {
|
||||
return qweb.render('WidgetButton.tooltip', {
|
||||
debug: config.debug,
|
||||
|
||||
@@ -45,7 +45,7 @@ var GraphController = AbstractController.extend(GroupByMenuInterfaceMixin,{
|
||||
destroy: function () {
|
||||
if (this.$buttons) {
|
||||
// remove jquery's tooltip() handlers
|
||||
this.$buttons.find('button').off().tooltip('destroy');
|
||||
this.$buttons.find('button').off().tooltip('dispose');
|
||||
}
|
||||
this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
@@ -153,7 +153,7 @@ var KanbanColumn = Widget.extend({
|
||||
this.$el.toggleClass('o_column_folded', this.folded && !config.device.isMobile);
|
||||
var tooltip = this.data.count + _t(' records');
|
||||
tooltip = '<p>' + tooltip + '</p>' + this.tooltipInfo;
|
||||
this.$header.find('.o_kanban_header_title').tooltip({html: true}).attr('data-original-title', tooltip);
|
||||
this.$header.find('.o_kanban_header_title').tooltip({}).attr('data-original-title', tooltip);
|
||||
if (!this.remaining) {
|
||||
this.$('.o_kanban_load_more').remove();
|
||||
} else {
|
||||
|
||||
@@ -133,9 +133,8 @@ var KanbanColumnProgressBar = Widget.extend({
|
||||
});
|
||||
if (this.progressBarHelp && _.every(this.subgroupCounts, function (val) { return val === 0; })) {
|
||||
this.$el.tooltip({
|
||||
delay: '0',
|
||||
trigger:'hover',
|
||||
placement: 'top',
|
||||
delay: 0,
|
||||
trigger: 'hover',
|
||||
title: this.progressBarHelp,
|
||||
});
|
||||
}
|
||||
@@ -152,9 +151,8 @@ var KanbanColumnProgressBar = Widget.extend({
|
||||
// Adapt tooltip
|
||||
$bar.attr('data-original-title', count + ' ' + key);
|
||||
$bar.tooltip({
|
||||
delay: '0',
|
||||
trigger:'hover',
|
||||
placement: 'top'
|
||||
delay: 0,
|
||||
trigger: 'hover',
|
||||
});
|
||||
|
||||
// Adapt active state
|
||||
|
||||
@@ -99,8 +99,7 @@ var KanbanRecord = Widget.extend({
|
||||
var tooltip = $el.attr('tooltip');
|
||||
if (tooltip) {
|
||||
$el.tooltip({
|
||||
'html': true,
|
||||
'title': self.qweb.render(tooltip, self.qweb_context)
|
||||
title: self.qweb.render(tooltip, self.qweb_context)
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -490,7 +489,7 @@ var KanbanRecord = Widget.extend({
|
||||
if (elem === event.currentTarget) {
|
||||
ischild = false;
|
||||
}
|
||||
var test_event = events && events.click && (events.click.length > 1 || events.click[0].namespace !== "tooltip");
|
||||
var test_event = events && events.click && (events.click.length > 1 || events.click[0].namespace !== 'bs.tooltip');
|
||||
if (ischild) {
|
||||
children.push(elem);
|
||||
if (test_event) {
|
||||
|
||||
@@ -316,7 +316,7 @@ var RTEWidget = Widget.extend({
|
||||
|
||||
$('body').addClass('editor_enable');
|
||||
|
||||
$(document)
|
||||
$(document.body)
|
||||
.tooltip({
|
||||
selector: '[data-oe-readonly]',
|
||||
container: 'body',
|
||||
@@ -364,7 +364,7 @@ var RTEWidget = Widget.extend({
|
||||
|
||||
$(document).off('click.rte keyup.rte mousedown.rte activate.rte mouseup.rte');
|
||||
$(document).off('content_changed').removeClass('o_is_inline_editable').removeData('rte');
|
||||
$(document).tooltip('destroy');
|
||||
$(document).tooltip('dispose');
|
||||
$('body').removeClass('editor_enable');
|
||||
this.trigger('rte:stop');
|
||||
},
|
||||
|
||||
@@ -196,7 +196,7 @@ renderer.tplPopovers = function (lang, options) {
|
||||
|
||||
setTimeout(function () {
|
||||
$airPopover.add($linkPopover).add($imagePopover).find("button")
|
||||
.tooltip('destroy')
|
||||
.tooltip('dispose')
|
||||
.tooltip({
|
||||
container: 'body',
|
||||
trigger: 'hover',
|
||||
@@ -895,7 +895,7 @@ eventHandler.attach = function (oLayoutInfo, options) {
|
||||
if (!show_tooltip) return;
|
||||
$target.tooltip({title: _t('Double-click to edit'), trigger: 'manuel', container: 'body'}).tooltip('show');
|
||||
setTimeout(function () {
|
||||
$target.tooltip('destroy');
|
||||
$target.tooltip('dispose');
|
||||
}, 800);
|
||||
}, 400);
|
||||
});
|
||||
|
||||
@@ -153,7 +153,7 @@ var SnippetEditor = Widget.extend({
|
||||
});
|
||||
|
||||
var $parent = this.$target.parent();
|
||||
this.$target.find('*').andSelf().tooltip('destroy');
|
||||
this.$target.find('*').andSelf().tooltip('dispose');
|
||||
this.$target.remove();
|
||||
this.$el.remove();
|
||||
|
||||
|
||||
@@ -863,7 +863,7 @@ registry.socialShare = Animation.extend({
|
||||
var self = this;
|
||||
setTimeout(function () {
|
||||
if (!$(".popover:hover").length) {
|
||||
$(self).popover("destroy");
|
||||
$(self).popover('dispose');
|
||||
}
|
||||
}, 200);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user