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

Delta Between Two Patch Sets: iconAnimation.js

Issue 5464830253203456: Refactored the abstraction layer to address prerendered pages on Safari caused by leaky abstraction (Closed)
Left Patch Set: Created Feb. 22, 2014, 10:45 a.m.
Right Patch Set: Addressed comments Created April 11, 2014, 2:47 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 | « ext/common.js ('k') | lib/stats.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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 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
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 iconAnimation = { 18 iconAnimation = {
19 _icons: new ext.PageMap(), 19 _icons: new ext.PageMap(),
20 _animatedPages: new ext.PageMap(), 20 _animatedPages: new ext.PageMap(),
21 step: 0, 21 _step: 0,
22 22
23 update: function(severity) 23 update: function(type)
24 { 24 {
25 if (severity == this._severity) 25 if (type == this._type)
26 return; 26 return;
27 27
28 if (!this._severity) 28 if (!this._type)
29 this._start(); 29 this._start();
30 30
31 this._severity = severity; 31 this._type = type;
32 }, 32 },
33 stop: function() 33 stop: function()
34 { 34 {
35 clearInterval(this._interval); 35 clearInterval(this._interval);
36 36
37 delete this._interval; 37 delete this._interval;
38 delete this._severity; 38 delete this._type;
39 39
40 this._animatedPages.clear(); 40 this._animatedPages.clear();
41 }, 41 },
42 registerPage: function(page, icon) 42 registerPage: function(page, icon)
43 { 43 {
44 this._icons.set(page, icon); 44 this._icons.set(page, icon);
45 45
46 if (this._animatedPages.has(page)) 46 if (this._animatedPages.has(page))
47 this._updateIcon(page); 47 this._updateIcon(page);
48 }, 48 },
49 _start: function() 49 _start: function()
50 { 50 {
51 this._interval = setInterval(function() 51 this._interval = setInterval(function()
52 { 52 {
53 ext.pages.query({active: true, visibleWindow: true}, function(pages) 53 ext.pages.query({active: true}, function(pages)
54 { 54 {
55 if (pages.length == 0) 55 if (pages.length == 0)
56 return; 56 return;
57 57
58 for (var i = 0; i < pages.length; i++) 58 for (var i = 0; i < pages.length; i++)
59 this._animatedPages.set(pages[i], null); 59 this._animatedPages.set(pages[i], null);
60 60
61 var interval = setInterval(function() 61 var interval = setInterval(function()
62 { 62 {
63 this._step++; 63 this._step++;
(...skipping 23 matching lines...) Expand all
87 }, 87 },
88 _updateIcon: function(page) 88 _updateIcon: function(page)
89 { 89 {
90 var path = this._icons.get(page); 90 var path = this._icons.get(page);
91 91
92 if (!path) 92 if (!path)
93 return; 93 return;
94 94
95 if (this._step > 0) 95 if (this._step > 0)
96 { 96 {
97 var suffix = "-notification-" + this._severity; 97 var suffix = "-notification-" + this._type;
98 98
99 if (this._step < 10) 99 if (this._step < 10)
100 suffix += "-" + this._step; 100 suffix += "-" + this._step;
101 101
102 path = path.replace(/(?=\..+$)/, suffix); 102 path = path.replace(/(?=\..+$)/, suffix);
103 } 103 }
104 104
105 page.browserAction.setIcon(path); 105 page.browserAction.setIcon(path);
106 } 106 }
107 }; 107 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld