LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 while (target.parentNode && !(target.id || target.className || getElementURLs(
target).length > 0 || /:.+:/.test(target.getAttribute("style")))) | 336 while (target.parentNode && !(target.id || target.className || getElementURLs(
target).length > 0 || /:.+:/.test(target.getAttribute("style")))) |
337 target = target.parentNode; | 337 target = target.parentNode; |
338 if (target == document.documentElement || target == document.body) | 338 if (target == document.documentElement || target == document.body) |
339 target = null; | 339 target = null; |
340 | 340 |
341 if (target && target instanceof HTMLElement) | 341 if (target && target instanceof HTMLElement) |
342 { | 342 { |
343 currentElement = target; | 343 currentElement = target; |
344 | 344 |
345 highlightElement(target, "#d6d84b", "#f8fa47"); | 345 highlightElement(target, "#d6d84b", "#f8fa47"); |
346 target.addEventListener("contextmenu", clickHide_elementClickHandler, false)
; | 346 target.addEventListener("contextmenu", clickHide_elementClickHandler, true); |
347 } | 347 } |
348 } | 348 } |
349 | 349 |
350 // No longer hovering over this element so unhighlight it | 350 // No longer hovering over this element so unhighlight it |
351 function clickHide_mouseOut(e) | 351 function clickHide_mouseOut(e) |
352 { | 352 { |
353 if (!clickHide_activated || !currentElement) | 353 if (!clickHide_activated || !currentElement) |
354 return; | 354 return; |
355 | 355 |
356 unhighlightElement(currentElement); | 356 unhighlightElement(currentElement); |
357 currentElement.removeEventListener("contextmenu", clickHide_elementClickHandle
r, false); | 357 currentElement.removeEventListener("contextmenu", clickHide_elementClickHandle
r, true); |
358 } | 358 } |
359 | 359 |
360 // Selects the currently hovered-over filter or cancels selection | 360 // Selects the currently hovered-over filter or cancels selection |
361 function clickHide_keyDown(e) | 361 function clickHide_keyDown(e) |
362 { | 362 { |
363 if (!e.ctrlKey && !e.altKey && !e.shiftKey && e.keyCode == 13 /*DOM_VK_RETURN*
/) | 363 if (!e.ctrlKey && !e.altKey && !e.shiftKey && e.keyCode == 13 /*DOM_VK_RETURN*
/) |
364 clickHide_mouseClick(e); | 364 clickHide_mouseClick(e); |
365 else if (!e.ctrlKey && !e.altKey && !e.shiftKey && e.keyCode == 27 /*DOM_VK_ES
CAPE*/) | 365 else if (!e.ctrlKey && !e.altKey && !e.shiftKey && e.keyCode == 27 /*DOM_VK_ES
CAPE*/) |
366 { | 366 { |
367 ext.backgroundPage.sendMessage( | 367 ext.backgroundPage.sendMessage( |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 // exists before continuing to avoid "Uncaught ReferenceError: ext is not define
d". | 578 // exists before continuing to avoid "Uncaught ReferenceError: ext is not define
d". |
579 // See https://crbug.com/416907 | 579 // See https://crbug.com/416907 |
580 if ("ext" in window && document instanceof HTMLDocument) | 580 if ("ext" in window && document instanceof HTMLDocument) |
581 { | 581 { |
582 // Use a contextmenu handler to save the last element the user right-clicked o
n. | 582 // Use a contextmenu handler to save the last element the user right-clicked o
n. |
583 // To make things easier, we actually save the DOM event. | 583 // To make things easier, we actually save the DOM event. |
584 // We have to do this because the contextMenu API only provides a URL, not the
actual | 584 // We have to do this because the contextMenu API only provides a URL, not the
actual |
585 // DOM element. | 585 // DOM element. |
586 document.addEventListener('contextmenu', function(e) { | 586 document.addEventListener('contextmenu', function(e) { |
587 lastRightClickEvent = e; | 587 lastRightClickEvent = e; |
588 }, false); | 588 }, true); |
589 | 589 |
590 document.addEventListener("click", function(event) | 590 document.addEventListener("click", function(event) |
591 { | 591 { |
592 // Ignore right-clicks | 592 // Ignore right-clicks |
593 if (event.button == 2) | 593 if (event.button == 2) |
594 return; | 594 return; |
595 | 595 |
596 // Search the link associated with the click | 596 // Search the link associated with the click |
597 var link = event.target; | 597 var link = event.target; |
598 while (link && !(link instanceof HTMLAnchorElement)) | 598 while (link && !(link instanceof HTMLAnchorElement)) |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 break; | 735 break; |
736 default: | 736 default: |
737 sendResponse({}); | 737 sendResponse({}); |
738 break; | 738 break; |
739 } | 739 } |
740 }); | 740 }); |
741 | 741 |
742 if (window == window.top) | 742 if (window == window.top) |
743 ext.backgroundPage.sendMessage({type: "report-html-page"}); | 743 ext.backgroundPage.sendMessage({type: "report-html-page"}); |
744 } | 744 } |
LEFT | RIGHT |