From fba51f1cbd395db9a390701bdb96142ec0aeb833 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Mon, 29 Aug 2016 12:01:41 +0200 Subject: [PATCH] [FIX] web_tour: correct automatic click on links Previous implementation was checking if the element we want to click on is a link and if this is the case, only forced a redirection. This had been done because the redirection was not working by simulating a click, but in fact it works, the click simulation only had to be improved. Also, only forcing a redirection is wrong as some links have both a real redirection link and a event handler binded to them. --- addons/web_tour/static/src/js/tour_manager.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/addons/web_tour/static/src/js/tour_manager.js b/addons/web_tour/static/src/js/tour_manager.js index 87c7f5ed8ff..2ca7d2bfc2d 100644 --- a/addons/web_tour/static/src/js/tour_manager.js +++ b/addons/web_tour/static/src/js/tour_manager.js @@ -96,11 +96,18 @@ var RunningTourActionHelper = core.Class.extend({ }; }, _click: function (values) { - var href = values.$element.attr("href"); - if (href && href.length && href[0] !== "#" && values.$element.is("a") && href !== "javascript:void(0)") { - window.location.href = href; - } else { - values.$element.trigger("mouseenter").mousedown().mouseup().click().trigger("mouseleave"); + trigger_mouse_event(values.$element, "mouseover"); + values.$element.trigger("mouseenter"); + trigger_mouse_event(values.$element, "mousedown"); + trigger_mouse_event(values.$element, "mouseup"); + trigger_mouse_event(values.$element, "click"); + trigger_mouse_event(values.$element, "mouseout"); + values.$element.trigger("mouseleave"); + + function trigger_mouse_event($element, type) { + var e = document.createEvent("MouseEvents"); + e.initMouseEvent(type, true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, $element[0]); + $element[0].dispatchEvent(e); } }, _text: function (values, text) {