[FIX] web: fix tooltip that were stuck visible

tooltip stuck visible should be removed on click + remove tooltip container except for modal in order to prevent them for staying visible in some rare occasion
This commit is contained in:
Cedric Snauwaert 2014-07-28 17:07:47 +02:00
parent c86f217f7e
commit 5ddc0305cd
3 changed files with 15 additions and 3 deletions

View File

@ -115,6 +115,7 @@ instance.web.Dialog = instance.web.Widget.extend({
this.init_dialog();
}
this.$buttons.insertAfter(this.$dialog_box.find(".modal-body"));
$('.tooltip').remove(); //remove open tooltip if any to prevent them staying when modal is opened
//add to list of currently opened modal
opened_modal.push(this.$dialog_box);
return this;
@ -1121,7 +1122,7 @@ instance.web.Client = instance.web.Widget.extend({
}, 0);
});
instance.web.bus.on('click', this, function(ev) {
$.fn.tooltip('destroy');
$('.tooltip').remove();
if (!$(ev.target).is('input[type=file]')) {
self.$el.find('.oe_dropdown_menu.oe_opened, .oe_dropdown_toggle.oe_opened').removeClass('oe_opened');
}

View File

@ -772,7 +772,7 @@ instance.web.unblockUI = function() {
/* Bootstrap defaults overwrite */
$.fn.tooltip.Constructor.DEFAULTS.placement = 'auto top';
$.fn.tooltip.Constructor.DEFAULTS.html = true;
$.fn.tooltip.Constructor.DEFAULTS.container = 'body';
$.fn.tooltip.Constructor.DEFAULTS.trigger = 'hover focus click';
//overwrite bootstrap tooltip method to prevent showing 2 tooltip at the same time
var bootstrap_show_function = $.fn.tooltip.Constructor.prototype.show;
$.fn.tooltip.Constructor.prototype.show = function () {
@ -786,6 +786,18 @@ $.fn.tooltip.Constructor.prototype.show = function () {
if (e.isDefaultPrevented() || !inDom) return;
return bootstrap_show_function.call(this);
};
//overwrite bootstrap tooltip init method in order to check if tooltip is in a modal or not and
//if so it needs to have a container body in order to be visible
var bootstrap_init_tooltip_fnct = $.fn.tooltip.Constructor.prototype.init;
$.fn.tooltip.Constructor.prototype.init = function (type, element, options) {
options = options || {}
if ($('.modal[aria-hidden="false"]').length !== 0){
if (options && !options.container){
options = _.extend({container: 'body'},options);
}
}
return bootstrap_init_tooltip_fnct.call(this, type, element, options);
}
/**
* Registry for all the client actions key: tag value: widget

View File

@ -1871,7 +1871,6 @@ instance.web.form.FormWidget = instance.web.Widget.extend(instance.web.form.Invi
trigger = trigger || this.$el;
options = _.extend({
delay: { show: 500, hide: 0 },
trigger: 'hover',
title: function() {
var template = widget.template + '.tooltip';
if (!QWeb.has_template(template)) {