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

Delta Between Two Patch Sets: lib/child/flasher.js

Issue 29329779: Issue 3258 - Blockable items: restore item flashing functionality (Closed)
Left Patch Set: Created Nov. 5, 2015, 8:52 p.m.
Right Patch Set: Addressed comments Created Nov. 25, 2015, 7:05 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « chrome/content/ui/sidebar.xul ('k') | lib/child/requestNotifier.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 /** 18 /**
19 * @fileOverview Draws a blinking border for a list of matching nodes. 19 * @fileOverview Draws a blinking border for a list of matching elements.
20 */ 20 */
21 21
22 function Flasher(nodes, scrollToItem) 22 function Flasher(elements, scrollToItem)
23 { 23 {
24 if (scrollToItem && nodes[0].ownerDocument) 24 if (scrollToItem && elements[0].ownerDocument)
25 { 25 {
26 // Ensure that at least one node is visible when flashing 26 // Ensure that at least one element is visible when flashing
27 nodes[0].scrollIntoView(); 27 elements[0].scrollIntoView();
28 } 28 }
29 29
30 this.nodes = nodes; 30 this.elements = elements;
31 this.count = 0; 31 this.count = 0;
32 32
33 this.doFlash(); 33 this.doFlash();
34 34
35 } 35 }
36 Flasher.prototype = 36 Flasher.prototype =
37 { 37 {
38 nodes: null, 38 elements: null,
39 count: 0, 39 count: 0,
40 timer: null, 40 timer: null,
41 41
42 doFlash: function() 42 doFlash: function()
43 { 43 {
44 if (this.count >= 12) 44 if (this.count >= 12)
45 { 45 {
46 this.stop(); 46 this.stop();
47 return; 47 return;
48 } 48 }
(...skipping 10 matching lines...) Expand all
59 }, 59 },
60 60
61 stop: function() 61 stop: function()
62 { 62 {
63 if (this.timer) 63 if (this.timer)
64 { 64 {
65 this.timer.cancel(); 65 this.timer.cancel();
66 this.timer = null; 66 this.timer = null;
67 } 67 }
68 68
69 if (this.nodes) 69 if (this.elements)
70 { 70 {
71 this.switchOff(); 71 this.switchOff();
72 this.nodes = null; 72 this.elements = null;
73 } 73 }
74 }, 74 },
75 75
76 setOutline: function(outline, offset) 76 setOutline: function(outline, offset)
77 { 77 {
78 for (let node of this.nodes) 78 for (let element of this.elements)
79 { 79 {
80 if (!Cu.isDeadWrapper(node) && "style" in node) 80 if (!Cu.isDeadWrapper(element) && "style" in element)
81 { 81 {
82 node.style.outline = outline; 82 element.style.outline = outline;
83 node.style.outlineOffset = offset; 83 element.style.outlineOffset = offset;
84 } 84 }
85 } 85 }
86 }, 86 },
87 87
88 switchOn: function() 88 switchOn: function()
89 { 89 {
90 this.setOutline("#CC0000 dotted 2px", "-2px"); 90 this.setOutline("#CC0000 dotted 2px", "-2px");
91 }, 91 },
92 92
93 switchOff: function() 93 switchOff: function()
94 { 94 {
95 this.setOutline("", ""); 95 this.setOutline("", "");
96 } 96 }
97 }; 97 };
98 98
99 exports.Flasher = Flasher; 99 exports.Flasher = Flasher;
LEFTRIGHT

Powered by Google App Engine
This is Rietveld