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

Side by Side Diff: include.postload.js

Issue 4923599135703040: Issue 1610 - Don't remove overlays before the "Block element" dialog is closed (Closed)
Patch Set: Rebased and addressed comments Created Nov. 26, 2014, 2:40 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 document.body.appendChild(overlay); 302 document.body.appendChild(overlay);
303 return overlay; 303 return overlay;
304 } 304 }
305 305
306 // Show dialog asking user whether she wants to add the proposed filters derived 306 // Show dialog asking user whether she wants to add the proposed filters derived
307 // from selected page element 307 // from selected page element
308 function clickHide_showDialog(left, top, filters) 308 function clickHide_showDialog(left, top, filters)
309 { 309 {
310 // If we are already selecting, abort now 310 // If we are already selecting, abort now
311 if (clickHide_activated || clickHideFiltersDialog) 311 if (clickHide_activated || clickHideFiltersDialog)
312 { 312 clickHide_deactivate(true);
313 var savedElement = (currentElement.prisoner ? currentElement.prisoner : curr entElement);
314 clickHide_deactivate();
315 currentElement = savedElement;
316 }
317 313
318 clickHide_filters = filters; 314 clickHide_filters = filters;
319 315
320 clickHideFiltersDialog = document.createElement("iframe"); 316 clickHideFiltersDialog = document.createElement("iframe");
321 clickHideFiltersDialog.src = ext.getURL("block.html"); 317 clickHideFiltersDialog.src = ext.getURL("block.html");
322 clickHideFiltersDialog.setAttribute("style", "position: fixed !important; visi bility: hidden; display: block !important; border: 0px !important;"); 318 clickHideFiltersDialog.setAttribute("style", "position: fixed !important; visi bility: hidden; display: block !important; border: 0px !important;");
323 clickHideFiltersDialog.style.WebkitBoxShadow = "5px 5px 20px rgba(0,0,0,0.5)"; 319 clickHideFiltersDialog.style.WebkitBoxShadow = "5px 5px 20px rgba(0,0,0,0.5)";
324 clickHideFiltersDialog.style.zIndex = 0x7FFFFFFF; 320 clickHideFiltersDialog.style.zIndex = 0x7FFFFFFF;
325 321
326 // Position in upper-left all the time 322 // Position in upper-left all the time
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 // on whether the user actually wants these filters 364 // on whether the user actually wants these filters
369 function clickHide_rulesPending() { 365 function clickHide_rulesPending() {
370 clickHide_activated = false; 366 clickHide_activated = false;
371 document.removeEventListener("mouseover", clickHide_mouseOver, true); 367 document.removeEventListener("mouseover", clickHide_mouseOver, true);
372 document.removeEventListener("mouseout", clickHide_mouseOut, true); 368 document.removeEventListener("mouseout", clickHide_mouseOut, true);
373 document.removeEventListener("click", clickHide_mouseClick, true); 369 document.removeEventListener("click", clickHide_mouseClick, true);
374 document.removeEventListener("keydown", clickHide_keyDown, true); 370 document.removeEventListener("keydown", clickHide_keyDown, true);
375 } 371 }
376 372
377 // Turn off click-to-hide 373 // Turn off click-to-hide
378 function clickHide_deactivate() 374 function clickHide_deactivate(keepOverlays)
379 { 375 {
380 if (clickHideFiltersDialog) 376 if (clickHideFiltersDialog)
381 { 377 {
382 document.body.removeChild(clickHideFiltersDialog); 378 document.body.removeChild(clickHideFiltersDialog);
383 clickHideFiltersDialog = null; 379 clickHideFiltersDialog = null;
384 } 380 }
385 381
386 if(currentElement) {
387 currentElement.removeEventListener("contextmenu", clickHide_elementClickHand ler, true);
388 unhighlightElements();
389 unhighlightElement(currentElement);
390 currentElement = null;
391 clickHideFilters = null;
392 }
393 unhighlightElements();
394
395 clickHide_activated = false; 382 clickHide_activated = false;
396 clickHide_filters = null; 383 clickHide_filters = null;
397 if(!document) 384 if(!document)
398 return; // This can happen inside a nuked iframe...I think 385 return; // This can happen inside a nuked iframe...I think
399 document.removeEventListener("mouseover", clickHide_mouseOver, true); 386 document.removeEventListener("mouseover", clickHide_mouseOver, true);
400 document.removeEventListener("mouseout", clickHide_mouseOut, true); 387 document.removeEventListener("mouseout", clickHide_mouseOut, true);
401 document.removeEventListener("click", clickHide_mouseClick, true); 388 document.removeEventListener("click", clickHide_mouseClick, true);
402 document.removeEventListener("keydown", clickHide_keyDown, true); 389 document.removeEventListener("keydown", clickHide_keyDown, true);
403 390
404 // Remove overlays 391 if (!keepOverlays)
405 // For some reason iterating over the array returend by getElementsByClassName () doesn't work 392 {
406 var elt; 393 if (currentElement) {
407 while(elt = document.querySelector('.__adblockplus__overlay')) 394 currentElement.removeEventListener("contextmenu", clickHide_elementClickH andler, true);
408 elt.parentNode.removeChild(elt); 395 unhighlightElements();
396 unhighlightElement(currentElement);
397 currentElement = null;
398 clickHideFilters = null;
399 }
400 unhighlightElements();
401
402 var overlays = document.getElementsByClassName("__adblockplus__overlay");
403 while (overlays.length > 0)
404 overlays[0].parentNode.removeChild(overlays[0]);
405 }
409 } 406 }
410 407
411 function clickHide_elementClickHandler(ev) { 408 function clickHide_elementClickHandler(ev) {
412 ev.preventDefault(); 409 ev.preventDefault();
413 ev.stopPropagation(); 410 ev.stopPropagation();
414 clickHide_mouseClick(ev); 411 clickHide_mouseClick(ev);
415 } 412 }
416 413
417 // Hovering over an element so highlight it 414 // Hovering over an element so highlight it
418 function clickHide_mouseOver(e) 415 function clickHide_mouseOver(e)
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 break; 715 break;
719 default: 716 default:
720 sendResponse({}); 717 sendResponse({});
721 break; 718 break;
722 } 719 }
723 }); 720 });
724 721
725 if (window == window.top) 722 if (window == window.top)
726 ext.backgroundPage.sendMessage({type: "report-html-page"}); 723 ext.backgroundPage.sendMessage({type: "report-html-page"});
727 } 724 }
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