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

Unified Diff: iconAnimation.js

Issue 5196306347720704: Issue 1965 - Simplified and fixed missing image for icon animation (Closed)
Patch Set: Rabased and addressed comments Created March 6, 2014, 8:38 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « background.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: iconAnimation.js
===================================================================
--- a/iconAnimation.js
+++ b/iconAnimation.js
@@ -16,35 +16,25 @@
*/
iconAnimation = {
- _icons: new TabMap(),
- _animatedTabs: new TabMap(),
- _step: 0,
+ step: 0,
+ tabs: new TabMap(),
update: function(severity)
{
- if (severity == this._severity)
+ if (severity == this.severity)
return;
- if (!this._severity)
+ if (!this.severity)
this._start();
- this._severity = severity;
+ this.severity = severity;
},
stop: function()
{
clearInterval(this._interval);
delete this._interval;
- delete this._severity;
-
- this._animatedTabs.clear();
- },
- registerTab: function(tab, icon)
- {
- this._icons.set(tab, icon);
-
- if (this._animatedTabs.has(tab))
- this._updateIcon(tab);
+ delete this.severity;
},
_start: function()
{
@@ -56,14 +46,14 @@
return;
for (var i = 0; i < tabs.length; i++)
- this._animatedTabs.set(tabs[i], null);
+ this.tabs.set(tabs[i], null);
var interval = setInterval(function()
{
- this._step++;
+ this.step++;
tabs.forEach(this._updateIcon.bind(this));
- if (this._step < 10)
+ if (this.step < 10)
return;
clearInterval(interval);
@@ -71,14 +61,14 @@
{
interval = setInterval(function()
{
- this._step--;
+ this.step--;
tabs.forEach(this._updateIcon.bind(this));
- if (this._step > 0)
+ if (this.step > 0)
return;
clearInterval(interval);
- this._animatedTabs.clear();
+ this.tabs.clear();
}.bind(this), 100);
}.bind(this), 1000);
}.bind(this), 100);
@@ -114,21 +104,6 @@
},
_updateIcon: function(tab)
{
- var path = this._icons.get(tab);
-
- if (!path)
- return;
-
- if (this._step > 0)
- {
- var suffix = "-notification-" + this._severity;
-
- if (this._step < 10)
- suffix += "-" + this._step;
-
- path = path.replace(/(?=\..+$)/, suffix);
- }
-
- tab.browserAction.setIcon(path);
+ tab.browserAction.setIcon(getTabStatus(tab).icon);
}
};
« no previous file with comments | « background.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld