Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: include.postload.js

Issue 6175313801248768: Issue 1665 - Catch all mouse events when clickHide is active (Closed)
Patch Set: Created Feb. 11, 2015, 6:22 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include.postload.js
===================================================================
--- a/include.postload.js
+++ b/include.postload.js
@@ -345,6 +345,10 @@
}
clickHide_activated = true;
+ document.addEventListener("mousedown", clickHide_stopPropagation, true);
+ document.addEventListener("mouseup", clickHide_stopPropagation, true);
+ document.addEventListener("mouseenter", clickHide_stopPropagation, true);
+ document.addEventListener("mouseleave", clickHide_stopPropagation, true);
document.addEventListener("mouseover", clickHide_mouseOver, true);
document.addEventListener("mouseout", clickHide_mouseOut, true);
document.addEventListener("click", clickHide_mouseClick, true);
@@ -357,6 +361,10 @@
// on whether the user actually wants these filters
function clickHide_rulesPending() {
clickHide_activated = false;
+ document.removeEventListener("mousedown", clickHide_stopPropagation, true);
+ document.removeEventListener("mouseup", clickHide_stopPropagation, true);
+ document.removeEventListener("mouseenter", clickHide_stopPropagation, true);
+ document.removeEventListener("mouseleave", clickHide_stopPropagation, true);
document.removeEventListener("mouseover", clickHide_mouseOver, true);
document.removeEventListener("mouseout", clickHide_mouseOut, true);
document.removeEventListener("click", clickHide_mouseClick, true);
@@ -376,6 +384,11 @@
clickHide_filters = null;
if(!document)
return; // This can happen inside a nuked iframe...I think
+
+ document.removeEventListener("mousedown", clickHide_stopPropagation, true);
+ document.removeEventListener("mouseup", clickHide_stopPropagation, true);
+ document.removeEventListener("mouseenter", clickHide_stopPropagation, true);
+ document.removeEventListener("mouseleave", clickHide_stopPropagation, true);
document.removeEventListener("mouseover", clickHide_mouseOver, true);
document.removeEventListener("mouseout", clickHide_mouseOut, true);
document.removeEventListener("click", clickHide_mouseClick, true);
@@ -401,10 +414,15 @@
}
}
-function clickHide_elementClickHandler(ev) {
- ev.preventDefault();
- ev.stopPropagation();
- clickHide_mouseClick(ev);
+function clickHide_stopPropagation(e)
+{
+ e.stopPropagation();
+}
+
+function clickHide_elementClickHandler(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ clickHide_mouseClick(e);
}
function getBlockableElementOrAncestor(element)
@@ -457,6 +475,7 @@
highlightElement(target, "#d6d84b", "#f8fa47");
target.addEventListener("contextmenu", clickHide_elementClickHandler, true);
}
+ e.stopPropagation();
}
// No longer hovering over this element so unhighlight it
@@ -467,6 +486,7 @@
unhighlightElement(currentElement);
currentElement.removeEventListener("contextmenu", clickHide_elementClickHandler, true);
+ e.stopPropagation();
}
// Selects the currently hovered-over filter or cancels selection
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld