Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2018-11-25 01:58:14 +0300
committerStefan Giehl <stefan@piwik.org>2018-11-25 01:58:14 +0300
commit058fe3ae8034ca9adfb13323894b6185c16d26b1 (patch)
tree4ceb3cd292fe9583b01db4e44e1b8e9c827e5dcb /plugins/CoreHome/angularjs/common/directives
parente5d021155c18a38d3e566c48dc9440d1061df73b (diff)
Dashboard selector listing all widgets is hidden once the scroll bar is used (#13608)
* Dashboard selector listing all widgets is hidden once the scroll bar is used * make sure it works even when scrolling, then keep holding mouse down for few seconds before releasing the scroll
Diffstat (limited to 'plugins/CoreHome/angularjs/common/directives')
-rw-r--r--plugins/CoreHome/angularjs/common/directives/focus-anywhere-but-here.js28
1 files changed, 27 insertions, 1 deletions
diff --git a/plugins/CoreHome/angularjs/common/directives/focus-anywhere-but-here.js b/plugins/CoreHome/angularjs/common/directives/focus-anywhere-but-here.js
index ee1a2cf219..6587118635 100644
--- a/plugins/CoreHome/angularjs/common/directives/focus-anywhere-but-here.js
+++ b/plugins/CoreHome/angularjs/common/directives/focus-anywhere-but-here.js
@@ -22,7 +22,18 @@
restrict: 'A',
link: function(scope, element, attr, ctrl) {
+ var isMouseDown = false;
+ var hasScrolled = false;
+
function onClickOutsideElement (event) {
+ var hadUsedScrollbar = isMouseDown && hasScrolled;
+ isMouseDown = false;
+ hasScrolled = false;
+
+ if (hadUsedScrollbar) {
+ return;
+ }
+
if (element.has(event.target).length === 0) {
setTimeout(function () {
scope.$apply(attr.piwikFocusAnywhereButHere);
@@ -30,19 +41,34 @@
}
}
+ function onScroll (event) {
+ hasScrolled = true;
+ }
+
+ function onMouseDown (event) {
+ isMouseDown = true;
+ hasScrolled = false;
+ }
+
function onEscapeHandler (event) {
if (event.which === 27) {
setTimeout(function () {
+ isMouseDown = false;
+ hasScrolled = false;
scope.$apply(attr.piwikFocusAnywhereButHere);
}, 0);
}
}
$document.on('keyup', onEscapeHandler);
+ $document.on('mousedown', onMouseDown);
$document.on('mouseup', onClickOutsideElement);
+ $document.on('scroll', onScroll);
scope.$on('$destroy', function() {
- $document.off('mouseup', onClickOutsideElement);
$document.off('keyup', onEscapeHandler);
+ $document.off('mousedown', onMouseDown);
+ $document.off('mouseup', onClickOutsideElement);
+ $document.off('scroll', onScroll);
});
}
};