Left: | ||
Right: |
OLD | NEW |
---|---|
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 } | 101 } |
102 | 102 |
103 // Show dialog asking user whether she wants to add the proposed filters derived | 103 // Show dialog asking user whether she wants to add the proposed filters derived |
104 // from selected page element | 104 // from selected page element |
105 function clickHide_showDialog(left, top, filters) | 105 function clickHide_showDialog(left, top, filters) |
106 { | 106 { |
107 // If we are already selecting, abort now | 107 // If we are already selecting, abort now |
108 if (clickHide_activated || clickHideFiltersDialog) | 108 if (clickHide_activated || clickHideFiltersDialog) |
109 { | 109 { |
110 var savedElement = (currentElement.prisoner ? currentElement.prisoner : curr entElement); | 110 var savedElement = (currentElement.prisoner ? currentElement.prisoner : curr entElement); |
111 clickHide_deactivate(); | 111 clickHide_deactivate(); |
saroyanm
2014/09/04 13:01:17
While ext.backgroundPage.sendMessage with "type: f
| |
112 currentElement = savedElement; | 112 currentElement = savedElement; |
113 } | 113 } |
114 | 114 |
115 clickHide_filters = filters; | 115 clickHide_filters = filters; |
116 | 116 |
117 clickHideFiltersDialog = document.createElement("iframe"); | 117 clickHideFiltersDialog = document.createElement("iframe"); |
118 clickHideFiltersDialog.src = ext.getURL("block.html"); | 118 clickHideFiltersDialog.src = ext.getURL("block.html"); |
119 clickHideFiltersDialog.setAttribute("style", "position: fixed !important; visi bility: hidden; display: block !important; border: 0px !important;"); | 119 clickHideFiltersDialog.setAttribute("style", "position: fixed !important; visi bility: hidden; display: block !important; border: 0px !important;"); |
120 clickHideFiltersDialog.style.WebkitBoxShadow = "5px 5px 20px rgba(0,0,0,0.5)"; | 120 clickHideFiltersDialog.style.WebkitBoxShadow = "5px 5px 20px rgba(0,0,0,0.5)"; |
121 clickHideFiltersDialog.style.zIndex = 0x7FFFFFFF; | 121 clickHideFiltersDialog.style.zIndex = 0x7FFFFFFF; |
(...skipping 18 matching lines...) Expand all Loading... | |
140 document.body.appendChild(clickHideFiltersDialog); | 140 document.body.appendChild(clickHideFiltersDialog); |
141 } | 141 } |
142 | 142 |
143 // Turn on the choose element to create filter thing | 143 // Turn on the choose element to create filter thing |
144 function clickHide_activate() { | 144 function clickHide_activate() { |
145 if(document == null) | 145 if(document == null) |
146 return; | 146 return; |
147 | 147 |
148 // If we are already selecting, abort now | 148 // If we are already selecting, abort now |
149 if (clickHide_activated || clickHideFiltersDialog) | 149 if (clickHide_activated || clickHideFiltersDialog) |
150 clickHide_deactivate(); | 150 clickHide_deactivate(); |
saroyanm
2014/09/04 13:01:17
While ext.backgroundPage.sendMessage with "type: f
| |
151 | 151 |
152 // Add overlays for elements with URLs so user can easily click them | 152 // Add overlays for elements with URLs so user can easily click them |
153 var elts = document.querySelectorAll('object,embed,img,iframe'); | 153 var elts = document.querySelectorAll('object,embed,img,iframe'); |
154 for(var i=0; i<elts.length; i++) | 154 for(var i=0; i<elts.length; i++) |
155 addElementOverlay(elts[i]); | 155 addElementOverlay(elts[i]); |
156 | 156 |
157 clickHide_activated = true; | 157 clickHide_activated = true; |
158 document.addEventListener("mouseover", clickHide_mouseOver, false); | 158 document.addEventListener("mouseover", clickHide_mouseOver, false); |
159 document.addEventListener("mouseout", clickHide_mouseOut, false); | 159 document.addEventListener("mouseout", clickHide_mouseOut, false); |
160 document.addEventListener("click", clickHide_mouseClick, false); | 160 document.addEventListener("click", clickHide_mouseClick, false); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 currentElement.removeEventListener("contextmenu", clickHide_elementClickHandle r, false); | 248 currentElement.removeEventListener("contextmenu", clickHide_elementClickHandle r, false); |
249 } | 249 } |
250 | 250 |
251 // Selects the currently hovered-over filter or cancels selection | 251 // Selects the currently hovered-over filter or cancels selection |
252 function clickHide_keyDown(e) | 252 function clickHide_keyDown(e) |
253 { | 253 { |
254 if (!e.ctrlKey && !e.altKey && !e.shiftKey && e.keyCode == 13 /*DOM_VK_RETURN* /) | 254 if (!e.ctrlKey && !e.altKey && !e.shiftKey && e.keyCode == 13 /*DOM_VK_RETURN* /) |
255 clickHide_mouseClick(e); | 255 clickHide_mouseClick(e); |
256 else if (!e.ctrlKey && !e.altKey && !e.shiftKey && e.keyCode == 27 /*DOM_VK_ES CAPE*/) | 256 else if (!e.ctrlKey && !e.altKey && !e.shiftKey && e.keyCode == 27 /*DOM_VK_ES CAPE*/) |
257 { | 257 { |
258 clickHide_deactivate(); | 258 ext.backgroundPage.sendMessage( |
259 { | |
260 type: "forward", | |
261 payload: | |
262 { | |
263 type: "clickhide-deactivate" | |
264 } | |
265 }); | |
259 e.preventDefault(); | 266 e.preventDefault(); |
260 e.stopPropagation(); | 267 e.stopPropagation(); |
261 } | 268 } |
262 } | 269 } |
263 | 270 |
264 // When the user clicks, the currentElement is the one we want. | 271 // When the user clicks, the currentElement is the one we want. |
265 // We should have ABP rules ready for when the | 272 // We should have ABP rules ready for when the |
266 // popup asks for them. | 273 // popup asks for them. |
267 function clickHide_mouseClick(e) | 274 function clickHide_mouseClick(e) |
268 { | 275 { |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
549 clickHideFiltersDialog.style.left = (parseInt(clickHideFiltersDialog.s tyle.left, 10) + request.x) + "px"; | 556 clickHideFiltersDialog.style.left = (parseInt(clickHideFiltersDialog.s tyle.left, 10) + request.x) + "px"; |
550 clickHideFiltersDialog.style.top = (parseInt(clickHideFiltersDialog.st yle.top, 10) + request.y) + "px"; | 557 clickHideFiltersDialog.style.top = (parseInt(clickHideFiltersDialog.st yle.top, 10) + request.y) + "px"; |
551 } | 558 } |
552 break; | 559 break; |
553 case "clickhide-close": | 560 case "clickhide-close": |
554 if (clickHideFiltersDialog) | 561 if (clickHideFiltersDialog) |
555 { | 562 { |
556 // Explicitly get rid of currentElement | 563 // Explicitly get rid of currentElement |
557 if (msg.remove && currentElement && currentElement.parentNode) | 564 if (msg.remove && currentElement && currentElement.parentNode) |
558 currentElement.parentNode.removeChild(currentElement); | 565 currentElement.parentNode.removeChild(currentElement); |
559 | |
560 clickHide_deactivate(); | |
561 } | 566 } |
567 clickHide_deactivate(); | |
562 break; | 568 break; |
563 default: | 569 default: |
564 sendResponse({}); | 570 sendResponse({}); |
565 break; | 571 break; |
566 } | 572 } |
567 }); | 573 }); |
568 } | 574 } |
OLD | NEW |