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: Created Nov. 26, 2014, 10:48 a.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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 document.body.appendChild(overlay); 212 document.body.appendChild(overlay);
213 return overlay; 213 return overlay;
214 } 214 }
215 215
216 // Show dialog asking user whether she wants to add the proposed filters derived 216 // Show dialog asking user whether she wants to add the proposed filters derived
217 // from selected page element 217 // from selected page element
218 function clickHide_showDialog(left, top, filters) 218 function clickHide_showDialog(left, top, filters)
219 { 219 {
220 // If we are already selecting, abort now 220 // If we are already selecting, abort now
221 if (clickHide_activated || clickHideFiltersDialog) 221 if (clickHide_activated || clickHideFiltersDialog)
222 { 222 clickHide_deactivate(true);
223 var savedElement = (currentElement.prisoner ? currentElement.prisoner : curr entElement);
224 clickHide_deactivate();
225 currentElement = savedElement;
226 }
227 223
228 clickHide_filters = filters; 224 clickHide_filters = filters;
229 225
230 clickHideFiltersDialog = document.createElement("iframe"); 226 clickHideFiltersDialog = document.createElement("iframe");
231 clickHideFiltersDialog.src = ext.getURL("block.html"); 227 clickHideFiltersDialog.src = ext.getURL("block.html");
232 clickHideFiltersDialog.setAttribute("style", "position: fixed !important; visi bility: hidden; display: block !important; border: 0px !important;"); 228 clickHideFiltersDialog.setAttribute("style", "position: fixed !important; visi bility: hidden; display: block !important; border: 0px !important;");
233 clickHideFiltersDialog.style.WebkitBoxShadow = "5px 5px 20px rgba(0,0,0,0.5)"; 229 clickHideFiltersDialog.style.WebkitBoxShadow = "5px 5px 20px rgba(0,0,0,0.5)";
234 clickHideFiltersDialog.style.zIndex = 0x7FFFFFFF; 230 clickHideFiltersDialog.style.zIndex = 0x7FFFFFFF;
235 231
236 // Position in upper-left all the time 232 // Position in upper-left all the time
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // on whether the user actually wants these filters 274 // on whether the user actually wants these filters
279 function clickHide_rulesPending() { 275 function clickHide_rulesPending() {
280 clickHide_activated = false; 276 clickHide_activated = false;
281 document.removeEventListener("mouseover", clickHide_mouseOver, true); 277 document.removeEventListener("mouseover", clickHide_mouseOver, true);
282 document.removeEventListener("mouseout", clickHide_mouseOut, true); 278 document.removeEventListener("mouseout", clickHide_mouseOut, true);
283 document.removeEventListener("click", clickHide_mouseClick, true); 279 document.removeEventListener("click", clickHide_mouseClick, true);
284 document.removeEventListener("keydown", clickHide_keyDown, true); 280 document.removeEventListener("keydown", clickHide_keyDown, true);
285 } 281 }
286 282
287 // Turn off click-to-hide 283 // Turn off click-to-hide
288 function clickHide_deactivate() 284 function clickHide_deactivate(keepOverlays)
kzar 2014/11/26 14:14:04 We're relying on the legacy code not passing this
Sebastian Noack 2014/11/26 14:41:39 Correct. I tried to keep the patch as compact as p
289 { 285 {
290 if (clickHideFiltersDialog) 286 if (clickHideFiltersDialog)
291 { 287 {
292 document.body.removeChild(clickHideFiltersDialog); 288 document.body.removeChild(clickHideFiltersDialog);
293 clickHideFiltersDialog = null; 289 clickHideFiltersDialog = null;
294 } 290 }
295 291
296 if(currentElement) {
297 currentElement.removeEventListener("contextmenu", clickHide_elementClickHand ler, false);
298 unhighlightElements();
299 unhighlightElement(currentElement);
300 currentElement = null;
301 clickHideFilters = null;
302 }
303 unhighlightElements();
304
305 clickHide_activated = false; 292 clickHide_activated = false;
306 clickHide_filters = null; 293 clickHide_filters = null;
307 if(!document) 294 if(!document)
308 return; // This can happen inside a nuked iframe...I think 295 return; // This can happen inside a nuked iframe...I think
309 document.removeEventListener("mouseover", clickHide_mouseOver, true); 296 document.removeEventListener("mouseover", clickHide_mouseOver, true);
310 document.removeEventListener("mouseout", clickHide_mouseOut, true); 297 document.removeEventListener("mouseout", clickHide_mouseOut, true);
311 document.removeEventListener("click", clickHide_mouseClick, true); 298 document.removeEventListener("click", clickHide_mouseClick, true);
312 document.removeEventListener("keydown", clickHide_keyDown, true); 299 document.removeEventListener("keydown", clickHide_keyDown, true);
313 300
314 // Remove overlays 301 if (!keepOverlays)
315 // For some reason iterating over the array returend by getElementsByClassName () doesn't work 302 {
Sebastian Noack 2014/11/26 12:03:29 It's not an Array, but a NodeList, and therefore l
316 var elt; 303 if(currentElement) {
kzar 2014/11/26 14:14:04 Nitpick: Should be space between "if" and "("?
Sebastian Noack 2014/11/26 14:41:39 I just copied the code from above, but I have adde
317 while(elt = document.querySelector('.__adblockplus__overlay')) 304 currentElement.removeEventListener("contextmenu", clickHide_elementClickHa ndler, false);
kzar 2014/11/26 14:14:04 Last parameter should be true?
Sebastian Noack 2014/11/26 14:41:39 Yes, this patch was created on top of a version, w
318 elt.parentNode.removeChild(elt); 305 unhighlightElements();
306 unhighlightElement(currentElement);
307 currentElement = null;
308 clickHideFilters = null;
309 }
310 unhighlightElements();
311
312 var overlays = document.getElementsByClassName("__adblockplus__overlay");
313 while (overlays.length > 0)
314 overlays[0].parentNode.removeChild(overlays[0]);
315 }
319 } 316 }
320 317
321 function clickHide_elementClickHandler(ev) { 318 function clickHide_elementClickHandler(ev) {
322 ev.preventDefault(); 319 ev.preventDefault();
323 ev.stopPropagation(); 320 ev.stopPropagation();
324 clickHide_mouseClick(ev); 321 clickHide_mouseClick(ev);
325 } 322 }
326 323
327 // Hovering over an element so highlight it 324 // Hovering over an element so highlight it
328 function clickHide_mouseOver(e) 325 function clickHide_mouseOver(e)
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 break; 709 break;
713 default: 710 default:
714 sendResponse({}); 711 sendResponse({});
715 break; 712 break;
716 } 713 }
717 }); 714 });
718 715
719 if (window == window.top) 716 if (window == window.top)
720 ext.backgroundPage.sendMessage({type: "report-html-page"}); 717 ext.backgroundPage.sendMessage({type: "report-html-page"});
721 } 718 }
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