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

Side by Side Diff: include.postload.js

Issue 6008293193416704: Issue 2080 - Removed duplicated code from clickHide_deactivate (Closed)
Patch Set: Removed silly comment Created March 4, 2015, 10:46 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 <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 document.documentElement.appendChild(overlay); 264 document.documentElement.appendChild(overlay);
265 return overlay; 265 return overlay;
266 } 266 }
267 267
268 // Show dialog asking user whether she wants to add the proposed filters derived 268 // Show dialog asking user whether she wants to add the proposed filters derived
269 // from selected page element 269 // from selected page element
270 function clickHide_showDialog(left, top, filters) 270 function clickHide_showDialog(left, top, filters)
271 { 271 {
272 // If we are already selecting, abort now 272 // If we are already selecting, abort now
273 if (clickHide_activated || clickHideFiltersDialog) 273 if (clickHide_activated || clickHideFiltersDialog)
274 clickHide_deactivate(true); 274 clickHide_rulesPending();
Wladimir Palant 2015/03/04 12:47:16 What if we go here because clickHideFiltersDialog
Sebastian Noack 2015/03/04 13:36:38 You are right, checking for clickHideFiltersDialog
275 275
276 clickHide_filters = filters; 276 clickHide_filters = filters;
277 277
278 clickHideFiltersDialog = document.createElement("iframe"); 278 clickHideFiltersDialog = document.createElement("iframe");
279 clickHideFiltersDialog.src = ext.getURL("block.html"); 279 clickHideFiltersDialog.src = ext.getURL("block.html");
280 clickHideFiltersDialog.setAttribute("style", "position: fixed !important; visi bility: hidden; display: block !important; border: 0px !important;"); 280 clickHideFiltersDialog.setAttribute("style", "position: fixed !important; visi bility: hidden; display: block !important; border: 0px !important;");
281 clickHideFiltersDialog.style.WebkitBoxShadow = "5px 5px 20px rgba(0,0,0,0.5)"; 281 clickHideFiltersDialog.style.WebkitBoxShadow = "5px 5px 20px rgba(0,0,0,0.5)";
282 clickHideFiltersDialog.style.zIndex = 0x7FFFFFFF; 282 clickHideFiltersDialog.style.zIndex = 0x7FFFFFFF;
283 283
284 // Position in upper-left all the time 284 // Position in upper-left all the time
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 document.removeEventListener("mousedown", clickHide_stopPropagation, true); 340 document.removeEventListener("mousedown", clickHide_stopPropagation, true);
341 document.removeEventListener("mouseup", clickHide_stopPropagation, true); 341 document.removeEventListener("mouseup", clickHide_stopPropagation, true);
342 document.removeEventListener("mouseenter", clickHide_stopPropagation, true); 342 document.removeEventListener("mouseenter", clickHide_stopPropagation, true);
343 document.removeEventListener("mouseleave", clickHide_stopPropagation, true); 343 document.removeEventListener("mouseleave", clickHide_stopPropagation, true);
344 document.removeEventListener("mouseover", clickHide_mouseOver, true); 344 document.removeEventListener("mouseover", clickHide_mouseOver, true);
345 document.removeEventListener("mouseout", clickHide_mouseOut, true); 345 document.removeEventListener("mouseout", clickHide_mouseOut, true);
346 document.removeEventListener("click", clickHide_mouseClick, true); 346 document.removeEventListener("click", clickHide_mouseClick, true);
347 document.removeEventListener("keydown", clickHide_keyDown, true); 347 document.removeEventListener("keydown", clickHide_keyDown, true);
348 } 348 }
349 349
350 // Turn off click-to-hide 350 function clickHide_deactivate()
351 function clickHide_deactivate(keepOverlays)
352 { 351 {
352 clickHide_rulesPending();
353
353 if (clickHideFiltersDialog) 354 if (clickHideFiltersDialog)
354 { 355 {
355 document.documentElement.removeChild(clickHideFiltersDialog); 356 document.documentElement.removeChild(clickHideFiltersDialog);
356 clickHideFiltersDialog = null; 357 clickHideFiltersDialog = null;
357 } 358 }
358 359
359 clickHide_activated = false;
360 clickHide_filters = null; 360 clickHide_filters = null;
361 if(!document) 361 lastRightClickEvent = null;
362 return; // This can happen inside a nuked iframe...I think
363 362
364 document.removeEventListener("mousedown", clickHide_stopPropagation, true); 363 if (currentElement) {
Wladimir Palant 2015/03/04 12:47:16 Nit: Opening bracket should go on the next line, w
Sebastian Noack 2015/03/04 13:36:38 Done.
365 document.removeEventListener("mouseup", clickHide_stopPropagation, true); 364 currentElement.removeEventListener("contextmenu", clickHide_elementClickHan dler, true);
366 document.removeEventListener("mouseenter", clickHide_stopPropagation, true); 365 unhighlightElements();
367 document.removeEventListener("mouseleave", clickHide_stopPropagation, true); 366 unhighlightElement(currentElement);
368 document.removeEventListener("mouseover", clickHide_mouseOver, true); 367 currentElement = null;
369 document.removeEventListener("mouseout", clickHide_mouseOut, true); 368 }
370 document.removeEventListener("click", clickHide_mouseClick, true); 369 unhighlightElements();
371 document.removeEventListener("keydown", clickHide_keyDown, true);
372 370
373 if (keepOverlays !== true) 371 var overlays = document.getElementsByClassName("__adblockplus__overlay");
374 { 372 while (overlays.length > 0)
375 lastRightClickEvent = null; 373 overlays[0].parentNode.removeChild(overlays[0]);
376 374
377 if (currentElement) { 375 ext.onExtensionUnloaded.removeListener(clickHide_deactivate);
378 currentElement.removeEventListener("contextmenu", clickHide_elementClickH andler, true);
379 unhighlightElements();
380 unhighlightElement(currentElement);
381 currentElement = null;
382 }
383 unhighlightElements();
384
385 var overlays = document.getElementsByClassName("__adblockplus__overlay");
386 while (overlays.length > 0)
387 overlays[0].parentNode.removeChild(overlays[0]);
388
389 ext.onExtensionUnloaded.removeListener(clickHide_deactivate);
390 }
391 } 376 }
392 377
393 function clickHide_stopPropagation(e) 378 function clickHide_stopPropagation(e)
394 { 379 {
395 e.stopPropagation(); 380 e.stopPropagation();
396 } 381 }
397 382
398 function clickHide_elementClickHandler(e) { 383 function clickHide_elementClickHandler(e) {
399 e.preventDefault(); 384 e.preventDefault();
400 e.stopPropagation(); 385 e.stopPropagation();
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 lastRightClickEventValid = false; 702 lastRightClickEventValid = false;
718 else 703 else
719 lastRightClickEvent = null; 704 lastRightClickEvent = null;
720 break; 705 break;
721 } 706 }
722 }); 707 });
723 708
724 if (window == window.top) 709 if (window == window.top)
725 ext.backgroundPage.sendMessage({type: "report-html-page"}); 710 ext.backgroundPage.sendMessage({type: "report-html-page"});
726 } 711 }
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