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

Unified Diff: options.js

Issue 8616119: Use require() properly instead of importing all symbols of a module (Closed)
Patch Set: Created Oct. 22, 2012, 8:48 a.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') | popup.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: options.js
===================================================================
--- a/options.js
+++ b/options.js
@@ -1,24 +1,36 @@
var backgroundPage = chrome.extension.getBackgroundPage();
-var imports = ["FilterStorage", "FilterNotifier", "Subscription", "SpecialSubscription",
- "DownloadableSubscription", "Filter", "WhitelistFilter",
- "Synchronizer", "Prefs", "Utils", "require"];
-for (var i = 0; i < imports.length; i++)
- window[imports[i]] = backgroundPage[imports[i]];
+var require = backgroundPage.require;
+
+with(require("filterClasses"))
+{
+ this.Filter = Filter;
+ this.WhitelistFilter = WhitelistFilter;
+}
+with(require("subscriptionClasses"))
+{
+ this.Subscription = Subscription;
+ this.SpecialSubscription = SpecialSubscription;
+ this.DownloadableSubscription = DownloadableSubscription;
+}
+var FilterStorage = require("filterStorage").FilterStorage;
+var FilterNotifier = require("filterNotifier").FilterNotifier;
+var Prefs = require("prefs").Prefs;
+var Synchronizer = require("synchronizer").Synchronizer;
// Loads options from localStorage and sets UI elements accordingly
function loadOptions()
{
// Set page title to i18n version of "Adblock Plus Options"
document.title = i18n.getMessage("options");
// Set links
$("#acceptableAdsLink").attr("href", Prefs.subscriptions_exceptionsurl);
- $("#acceptableAdsDocs").attr("href", Prefs.documentation_link.replace(/%LINK%/g, "acceptable_ads").replace(/%LANG%/g, Utils.appLocale));
+ $("#acceptableAdsDocs").attr("href", Prefs.documentation_link.replace(/%LINK%/g, "acceptable_ads").replace(/%LANG%/g, require("utils").Utils.appLocale));
// Add event listeners
window.addEventListener("unload", unloadOptions, false);
$("#updateFilterLists").click(updateFilterLists);
$("#startSubscriptionSelection").click(startSubscriptionSelection);
$("#subscriptionSelector").change(updateSubscriptionSelection);
$("#addSubscription").click(addSubscription);
$("#acceptableAds").click(allowAcceptableAds);
« no previous file with comments | « background.js ('k') | popup.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld