From 1ff140ea386d856c526b4797f38b4937e9b26f80 Mon Sep 17 00:00:00 2001 From: Linus G Thiel Date: Tue, 11 Oct 2016 11:30:32 +0200 Subject: Close any open tooltips before page:fetch --- app/assets/javascripts/application.js | 6 +----- app/assets/javascripts/lib/utils/common_utils.js | 8 ++++++++ 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 8a61669822c..b966a568bbd 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -123,15 +123,11 @@ return str.replace(/<(?:.|\n)*?>/gm, ''); }; - window.unbindEvents = function() { - return $(document).off('scroll'); - }; - window.shiftWindow = function() { return scrollBy(0, -100); }; - document.addEventListener("page:fetch", unbindEvents); + document.addEventListener("page:fetch", gl.utils.cleanupBeforeFetch); window.addEventListener("hashchange", shiftWindow); diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js index b170e26eebf..698abae6228 100644 --- a/app/assets/javascripts/lib/utils/common_utils.js +++ b/app/assets/javascripts/lib/utils/common_utils.js @@ -43,6 +43,14 @@ parser.href = url; return parser; }; + + gl.utils.cleanupBeforeFetch = function() { + // Unbind scroll events + $(document).off('scroll'); + // Close any open tooltips + $('.has-tooltip, [data-toggle="tooltip"]').tooltip('destroy'); + }; + return jQuery.timefor = function(time, suffix, expiredLabel) { var suffixFromNow, timefor; if (!time) { -- cgit v1.2.1