Index: iconAnimation.js |
=================================================================== |
--- a/iconAnimation.js |
+++ b/iconAnimation.js |
@@ -1,6 +1,6 @@ |
/* |
* This file is part of Adblock Plus <http://adblockplus.org/>, |
- * Copyright (C) 2006-2013 Eyeo GmbH |
+ * Copyright (C) 2006-2014 Eyeo GmbH |
* |
* Adblock Plus is free software: you can redistribute it and/or modify |
* it under the terms of the GNU General Public License version 3 as |
@@ -16,52 +16,52 @@ |
*/ |
iconAnimation = { |
- _icons: new TabMap(), |
- _animatedTabs: new TabMap(), |
- step: 0, |
+ _icons: new ext.PageMap(), |
+ _animatedPages: new ext.PageMap(), |
+ _step: 0, |
- update: function(severity) |
+ update: function(type) |
{ |
- if (severity == this._severity) |
+ if (type == this._type) |
return; |
- if (!this._severity) |
+ if (!this._type) |
this._start(); |
- this._severity = severity; |
+ this._type = type; |
}, |
stop: function() |
{ |
clearInterval(this._interval); |
delete this._interval; |
- delete this._severity; |
+ delete this._type; |
- this._animatedTabs.clear(); |
+ this._animatedPages.clear(); |
}, |
- registerTab: function(tab, icon) |
+ registerPage: function(page, icon) |
{ |
- this._icons.set(tab, icon); |
+ this._icons.set(page, icon); |
- if (this._animatedTabs.has(tab)) |
- this._updateIcon(tab); |
+ if (this._animatedPages.has(page)) |
+ this._updateIcon(page); |
}, |
_start: function() |
{ |
this._interval = setInterval(function() |
{ |
- this._getVisibleTabs(function(tabs) |
+ ext.pages.query({active: true}, function(pages) |
{ |
- if (tabs.length == 0) |
+ if (pages.length == 0) |
return; |
- for (var i = 0; i < tabs.length; i++) |
- this._animatedTabs.set(tabs[i], null); |
+ for (var i = 0; i < pages.length; i++) |
+ this._animatedPages.set(pages[i], null); |
var interval = setInterval(function() |
{ |
this._step++; |
- tabs.forEach(this._updateIcon.bind(this)); |
+ pages.forEach(this._updateIcon.bind(this)); |
if (this._step < 10) |
return; |
@@ -72,56 +72,29 @@ |
interval = setInterval(function() |
{ |
this._step--; |
- tabs.forEach(this._updateIcon.bind(this)); |
+ pages.forEach(this._updateIcon.bind(this)); |
if (this._step > 0) |
return; |
clearInterval(interval); |
- this._animatedTabs.clear(); |
+ this._animatedPages.clear(); |
}.bind(this), 100); |
}.bind(this), 1000); |
}.bind(this), 100); |
}.bind(this)); |
}.bind(this), 15000); |
}, |
- _getVisibleTabs: function(callback) |
+ _updateIcon: function(page) |
{ |
- ext.windows.getAll(function(windows) |
- { |
- var tabs = []; |
- var visibleWindows = windows.length; |
- |
- for (var i = 0; i < windows.length; i++) |
- { |
- if (!windows[i].visible) |
- { |
- if (--visibleWindows == 0) |
- callback(tabs); |
- |
- continue; |
- } |
- |
- windows[i].getActiveTab(function(tab) |
- { |
- tabs.push(tab); |
- |
- if (tabs.length == visibleWindows) |
- callback(tabs); |
- }); |
- } |
- }); |
- }, |
- _updateIcon: function(tab) |
- { |
- var path = this._icons.get(tab); |
+ var path = this._icons.get(page); |
if (!path) |
return; |
if (this._step > 0) |
{ |
- var suffix = "-notification-" + this._severity; |
+ var suffix = "-notification-" + this._type; |
if (this._step < 10) |
suffix += "-" + this._step; |
@@ -129,6 +102,6 @@ |
path = path.replace(/(?=\..+$)/, suffix); |
} |
- tab.browserAction.setIcon(path); |
+ page.browserAction.setIcon(path); |
} |
}; |