[FIX]tooltip: fix bootstrap bug when using auto placement and element was removed...
authorCedric Snauwaert <csn@openerp.com>
Fri, 18 Apr 2014 15:25:11 +0000 (17:25 +0200)
committerCedric Snauwaert <csn@openerp.com>
Fri, 18 Apr 2014 15:25:11 +0000 (17:25 +0200)
bzr revid: csn@openerp.com-20140418152511-f11mzqefa791vgl2

addons/web/static/src/js/core.js
addons/web/static/src/js/view_form.js

index acb4c2b..a4bcd19 100644 (file)
@@ -790,9 +790,19 @@ instance.web.unblockUI = function() {
 
 
 /* Bootstrap defaults overwrite */
-$.fn.tooltip.Constructor.DEFAULTS.placement = 'bottom';
+$.fn.tooltip.Constructor.DEFAULTS.placement = 'auto top';
 $.fn.tooltip.Constructor.DEFAULTS.html = true;
 $.fn.tooltip.Constructor.DEFAULTS.container = 'body';
+//overwrite bootstrap tooltip method to fix bug when using placement
+//auto and the parent element does not exist anymore resulting in
+//an error. This should be remove once bootstrap fix the bug
+var bootstrap_show_function = $.fn.tooltip.Constructor.prototype.show;
+$.fn.tooltip.Constructor.prototype.show = function (e) {
+    if (this.$element.parent().length === 0){
+        return;
+    }
+    return bootstrap_show_function.call(this, e);
+};
 
 /**
  * Registry for all the client actions key: tag value: widget
index 6212cc3..aabaf0a 100644 (file)
@@ -1866,9 +1866,17 @@ instance.web.form.FormWidget = instance.web.Widget.extend(instance.web.form.Invi
     do_attach_tooltip: function(widget, trigger, options) {
         widget = widget || this;
         trigger = trigger || this.$el;
+        var container = 'body';
+        //in the case we have a modal currently showing, attach tooltip
+        //to the modal to prevent the tooltip to show in the body in the
+        //case we close the modal too fast
+        if (window.$('.modal.in').length>0){
+            container = window.$('.modal.in:last()');
+        }
         options = _.extend({
                 delay: { show: 500, hide: 0 },
                 trigger: 'hover',
+                container: container,
                 title: function() {
                     var template = widget.template + '.tooltip';
                     if (!QWeb.has_template(template)) {