| OLD | NEW |
| 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-2014 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 |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 else | 276 else |
| 277 notifyUser(); | 277 notifyUser(); |
| 278 } | 278 } |
| 279 | 279 |
| 280 Prefs.addListener(function(name) | 280 Prefs.addListener(function(name) |
| 281 { | 281 { |
| 282 if (name == "shouldShowBlockElementMenu") | 282 if (name == "shouldShowBlockElementMenu") |
| 283 refreshIconAndContextMenuForAllPages(); | 283 refreshIconAndContextMenuForAllPages(); |
| 284 }); | 284 }); |
| 285 | 285 |
| 286 /** | |
| 287 * Opens options page or focuses an existing one, within the last focused windo
w. | |
| 288 * @param {Function} callback function to be called with the | |
| 289 Page object of the options page | |
| 290 */ | |
| 291 function openOptions(callback) | |
| 292 { | |
| 293 ext.pages.query({lastFocusedWindow: true}, function(pages) | |
| 294 { | |
| 295 var optionsUrl = ext.getURL("options.html"); | |
| 296 | |
| 297 for (var i = 0; i < pages.length; i++) | |
| 298 { | |
| 299 var page = pages[i]; | |
| 300 if (page.url == optionsUrl) | |
| 301 { | |
| 302 page.activate(); | |
| 303 if (callback) | |
| 304 callback(page); | |
| 305 return; | |
| 306 } | |
| 307 } | |
| 308 | |
| 309 ext.pages.open(optionsUrl, callback); | |
| 310 }); | |
| 311 } | |
| 312 | |
| 313 function prepareNotificationIconAndPopup() | 286 function prepareNotificationIconAndPopup() |
| 314 { | 287 { |
| 315 var animateIcon = (activeNotification.type !== "question"); | 288 var animateIcon = (activeNotification.type !== "question"); |
| 316 activeNotification.onClicked = function() | 289 activeNotification.onClicked = function() |
| 317 { | 290 { |
| 318 if (animateIcon) | 291 if (animateIcon) |
| 319 iconAnimation.stop(); | 292 iconAnimation.stop(); |
| 320 notificationClosed(); | 293 notificationClosed(); |
| 321 }; | 294 }; |
| 322 if (animateIcon) | 295 if (animateIcon) |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 } | 544 } |
| 572 break; | 545 break; |
| 573 case "add-filters": | 546 case "add-filters": |
| 574 if (msg.filters && msg.filters.length) | 547 if (msg.filters && msg.filters.length) |
| 575 { | 548 { |
| 576 for (var i = 0; i < msg.filters.length; i++) | 549 for (var i = 0; i < msg.filters.length; i++) |
| 577 FilterStorage.addFilter(Filter.fromText(msg.filters[i])); | 550 FilterStorage.addFilter(Filter.fromText(msg.filters[i])); |
| 578 } | 551 } |
| 579 break; | 552 break; |
| 580 case "add-subscription": | 553 case "add-subscription": |
| 581 openOptions(function(page) | 554 ext.showOptions(function(page) |
| 582 { | 555 { |
| 583 page.sendMessage(msg); | 556 page.sendMessage(msg); |
| 584 }); | 557 }); |
| 585 break; | 558 break; |
| 586 case "add-key-exception": | 559 case "add-key-exception": |
| 587 processKeyException(msg.token, sender.page, sender.frame); | 560 processKeyException(msg.token, sender.page, sender.frame); |
| 588 break; | 561 break; |
| 589 case "forward": | 562 case "forward": |
| 590 if (sender.page) | 563 if (sender.page) |
| 591 { | 564 { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 607 page.sendMessage({type: "clickhide-deactivate"}); | 580 page.sendMessage({type: "clickhide-deactivate"}); |
| 608 refreshIconAndContextMenu(page); | 581 refreshIconAndContextMenu(page); |
| 609 }); | 582 }); |
| 610 | 583 |
| 611 setTimeout(function() | 584 setTimeout(function() |
| 612 { | 585 { |
| 613 var notificationToShow = Notification.getNextToShow(); | 586 var notificationToShow = Notification.getNextToShow(); |
| 614 if (notificationToShow) | 587 if (notificationToShow) |
| 615 showNotification(notificationToShow); | 588 showNotification(notificationToShow); |
| 616 }, 3 * 60 * 1000); | 589 }, 3 * 60 * 1000); |
| OLD | NEW |