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

Side by Side Diff: include.postload.js

Issue 6224757330542592: Issue 1603 - Register events for "Block element" with capturing (Closed)
Patch Set: Created Nov. 24, 2014, 5:05 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 // If we are already selecting, abort now 263 // If we are already selecting, abort now
264 if (clickHide_activated || clickHideFiltersDialog) 264 if (clickHide_activated || clickHideFiltersDialog)
265 clickHide_deactivate(); 265 clickHide_deactivate();
266 266
267 // Add overlays for elements with URLs so user can easily click them 267 // Add overlays for elements with URLs so user can easily click them
268 var elts = document.querySelectorAll('object,embed,img,iframe'); 268 var elts = document.querySelectorAll('object,embed,img,iframe');
269 for(var i=0; i<elts.length; i++) 269 for(var i=0; i<elts.length; i++)
270 addElementOverlay(elts[i]); 270 addElementOverlay(elts[i]);
271 271
272 clickHide_activated = true; 272 clickHide_activated = true;
273 document.addEventListener("mouseover", clickHide_mouseOver, false); 273 document.addEventListener("mouseover", clickHide_mouseOver, true);
274 document.addEventListener("mouseout", clickHide_mouseOut, false); 274 document.addEventListener("mouseout", clickHide_mouseOut, true);
275 document.addEventListener("click", clickHide_mouseClick, false); 275 document.addEventListener("click", clickHide_mouseClick, true);
276 document.addEventListener("keydown", clickHide_keyDown, false); 276 document.addEventListener("keydown", clickHide_keyDown, true);
277 } 277 }
278 278
279 // Called when user has clicked on something and we are waiting for confirmation 279 // Called when user has clicked on something and we are waiting for confirmation
280 // on whether the user actually wants these filters 280 // on whether the user actually wants these filters
281 function clickHide_rulesPending() { 281 function clickHide_rulesPending() {
282 clickHide_activated = false; 282 clickHide_activated = false;
283 document.removeEventListener("mouseover", clickHide_mouseOver, false); 283 document.removeEventListener("mouseover", clickHide_mouseOver, true);
284 document.removeEventListener("mouseout", clickHide_mouseOut, false); 284 document.removeEventListener("mouseout", clickHide_mouseOut, true);
285 document.removeEventListener("click", clickHide_mouseClick, false); 285 document.removeEventListener("click", clickHide_mouseClick, true);
286 document.removeEventListener("keydown", clickHide_keyDown, false); 286 document.removeEventListener("keydown", clickHide_keyDown, true);
287 } 287 }
288 288
289 // Turn off click-to-hide 289 // Turn off click-to-hide
290 function clickHide_deactivate() 290 function clickHide_deactivate()
291 { 291 {
292 if (clickHideFiltersDialog) 292 if (clickHideFiltersDialog)
293 { 293 {
294 document.body.removeChild(clickHideFiltersDialog); 294 document.body.removeChild(clickHideFiltersDialog);
295 clickHideFiltersDialog = null; 295 clickHideFiltersDialog = null;
296 } 296 }
297 297
298 if(currentElement) { 298 if(currentElement) {
299 currentElement.removeEventListener("contextmenu", clickHide_elementClickHand ler, false); 299 currentElement.removeEventListener("contextmenu", clickHide_elementClickHand ler, false);
300 unhighlightElements(); 300 unhighlightElements();
301 unhighlightElement(currentElement); 301 unhighlightElement(currentElement);
302 currentElement = null; 302 currentElement = null;
303 clickHideFilters = null; 303 clickHideFilters = null;
304 } 304 }
305 unhighlightElements(); 305 unhighlightElements();
306 306
307 clickHide_activated = false; 307 clickHide_activated = false;
308 clickHide_filters = null; 308 clickHide_filters = null;
309 if(!document) 309 if(!document)
310 return; // This can happen inside a nuked iframe...I think 310 return; // This can happen inside a nuked iframe...I think
311 document.removeEventListener("mouseover", clickHide_mouseOver, false); 311 document.removeEventListener("mouseover", clickHide_mouseOver, true);
312 document.removeEventListener("mouseout", clickHide_mouseOut, false); 312 document.removeEventListener("mouseout", clickHide_mouseOut, true);
313 document.removeEventListener("click", clickHide_mouseClick, false); 313 document.removeEventListener("click", clickHide_mouseClick, true);
314 document.removeEventListener("keydown", clickHide_keyDown, false); 314 document.removeEventListener("keydown", clickHide_keyDown, true);
315 315
316 // Remove overlays 316 // Remove overlays
317 // For some reason iterating over the array returend by getElementsByClassName () doesn't work 317 // For some reason iterating over the array returend by getElementsByClassName () doesn't work
318 var elt; 318 var elt;
319 while(elt = document.querySelector('.__adblockplus__overlay')) 319 while(elt = document.querySelector('.__adblockplus__overlay'))
320 elt.parentNode.removeChild(elt); 320 elt.parentNode.removeChild(elt);
321 } 321 }
322 322
323 function clickHide_elementClickHandler(ev) { 323 function clickHide_elementClickHandler(ev) {
324 ev.preventDefault(); 324 ev.preventDefault();
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld