OLD | NEW |
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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 /** | 391 /** |
392 * Gets called once the initialization is finished and Adblock Plus elements | 392 * Gets called once the initialization is finished and Adblock Plus elements |
393 * can be added to the UI. | 393 * can be added to the UI. |
394 */ | 394 */ |
395 initDone: function() | 395 initDone: function() |
396 { | 396 { |
397 // The icon might be added already, make sure its state is correct | 397 // The icon might be added already, make sure its state is correct |
398 this.updateState(); | 398 this.updateState(); |
399 | 399 |
400 // Listen for pref and filters changes | 400 // Listen for pref and filters changes |
401 Prefs.addListener(function(name) | 401 Prefs.addListener(name => |
402 { | 402 { |
403 if (name == "enabled" || name == "defaulttoolbaraction" || name == "defaul
tstatusbaraction") | 403 if (name == "enabled" || name == "defaulttoolbaraction" || name == "defaul
tstatusbaraction") |
404 this.updateState(); | 404 this.updateState(); |
405 else if (name == "showinstatusbar") | 405 else if (name == "showinstatusbar") |
406 { | 406 { |
407 for (let window of this.applicationWindows) | 407 for (let window of this.applicationWindows) |
408 this.updateStatusbarIcon(window); | 408 this.updateStatusbarIcon(window); |
409 } | 409 } |
410 }.bind(this)); | 410 }); |
411 FilterNotifier.addListener(function(action) | 411 |
| 412 for (let eventName of [ |
| 413 "filter.added", "filter.removed", "filter.disabled", |
| 414 "subscription.added", "subscription.removed", "subscription.disabled", |
| 415 "subscription.updated", "load" |
| 416 ]) |
412 { | 417 { |
413 if (/^(filter|subscription)\.(added|removed|disabled|updated)$/.test(actio
n) || action == "load") | 418 FilterNotifier.on(eventName, () => this.updateState()); |
414 this.updateState(); | 419 } |
415 }.bind(this)); | |
416 | 420 |
417 Notification.addShowListener(notification => | 421 Notification.addShowListener(notification => |
418 { | 422 { |
419 let window = this.currentWindow; | 423 let window = this.currentWindow; |
420 if (!window) | 424 if (!window) |
421 return; | 425 return; |
422 | 426 |
423 let button = window.document.getElementById("abp-toolbarbutton") | 427 let button = window.document.getElementById("abp-toolbarbutton") |
424 || window.document.getElementById("abp-status"); | 428 || window.document.getElementById("abp-status"); |
425 if (!button) | 429 if (!button) |
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1877 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)], | 1881 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)], |
1878 ["abp-command-toggleshownotifications", "command", Notification.toggleIgnoreCa
tegory.bind(Notification, "*", null)] | 1882 ["abp-command-toggleshownotifications", "command", Notification.toggleIgnoreCa
tegory.bind(Notification, "*", null)] |
1879 ]; | 1883 ]; |
1880 | 1884 |
1881 onShutdown.add(function() | 1885 onShutdown.add(function() |
1882 { | 1886 { |
1883 for (let window of UI.applicationWindows) | 1887 for (let window of UI.applicationWindows) |
1884 if (UI.isBottombarOpen(window)) | 1888 if (UI.isBottombarOpen(window)) |
1885 UI.toggleBottombar(window); | 1889 UI.toggleBottombar(window); |
1886 }); | 1890 }); |
OLD | NEW |