Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/bandwagon/content/ui/settingsController.js
diff options
context:
space:
mode:
Diffstat (limited to 'bandwagon/content/ui/settingsController.js')
-rw-r--r--bandwagon/content/ui/settingsController.js278
1 files changed, 84 insertions, 194 deletions
diff --git a/bandwagon/content/ui/settingsController.js b/bandwagon/content/ui/settingsController.js
index 7e3525a..0af3dcc 100644
--- a/bandwagon/content/ui/settingsController.js
+++ b/bandwagon/content/ui/settingsController.js
@@ -42,7 +42,6 @@ Bandwagon.Controller.Settings = new function()
this.elemBandwagonCollections = null;
this.stringBundle = null;
- this.stringBundle2 = null;
}
Bandwagon.Controller.Settings.init = function()
@@ -50,7 +49,6 @@ Bandwagon.Controller.Settings.init = function()
Bandwagon.Logger.debug("Initializing Bandwagon.Controller.Settings");
Bandwagon.Controller.Settings.stringBundle = document.getElementById("bandwagon-strings");
- Bandwagon.Controller.Settings.stringBundle2 = document.getElementById("bandwagon-strings2");
Bandwagon.Controller.Settings.elemBandwagonCollections = document.getElementById("collections-list");
Bandwagon.Controller.Settings.elemBandwagonCollections.addEventListener("select", Bandwagon.Controller.Settings.doShowCollection, true);
@@ -75,7 +73,6 @@ Bandwagon.Controller.Settings.init = function()
//document.getElementById("perpage-group").addEventListener("command", Bandwagon.Controller.Settings.doSaveCollection, true);
bandwagonService.registerCollectionListChangeObserver(Bandwagon.Controller.Settings.collectionListChangeObserver);
- bandwagonService.registerAuthenticationStatusChangeObserver(Bandwagon.Controller.Settings.authenticationStatusChangeObserver);
setTimeout(function()
{
@@ -93,7 +90,6 @@ Bandwagon.Controller.Settings._delayedInit = function()
Bandwagon.Controller.Settings.invalidateAutoPublisher();
Bandwagon.Controller.Settings.invalidateAllowIncompatibleInstall();
Bandwagon.Controller.Settings.invalidateCustomizeCollectionUI();
- Bandwagon.Controller.Settings.invalidatePaginationSettings();
Bandwagon.Controller.Settings.invalidate();
}
@@ -111,7 +107,6 @@ Bandwagon.Controller.Settings.bindingsReady = function()
Bandwagon.Controller.Settings.uninit = function()
{
bandwagonService.unregisterCollectionListChangeObserver(Bandwagon.Controller.Settings.collectionListChangeObserver);
- bandwagonService.unregisterAuthenticationStatusChangeObserver(Bandwagon.Controller.Settings.authenticationStatusChangeObserver);
// now is a good time to save collections to storage
if (Bandwagon.COMMIT_NOW)
@@ -137,12 +132,6 @@ Bandwagon.Controller.Settings.collectionListChangeObserver = function()
Bandwagon.Controller.Settings.invalidate();
}
-Bandwagon.Controller.Settings.authenticationStatusChangeObserver = function()
-{
- Bandwagon.Controller.Settings.invalidateLogin();
- Bandwagon.Controller.Settings.invalidate();
-}
-
Bandwagon.Controller.Settings.invalidate = function()
{
var collectionCount = Bandwagon.Controller.Settings.elemBandwagonCollections.getElementsByTagName("bandwagonCollection").length;
@@ -150,7 +139,8 @@ Bandwagon.Controller.Settings.invalidate = function()
var disabled = (!collectionSelection || collectionCount == 0);
- document.getElementById("remove-button").disabled = disabled;
+ // XXTODO Disable more controls
+ //document.getElementById("remove-collection-button").disabled = disabled;
document.getElementById("updates-group").disabled = disabled;
document.getElementById("textbox-updateinterval-quantity-percollection").disabled = disabled;
document.getElementById("menulist-updateinterval-units-percollection").disabled = disabled;
@@ -158,14 +148,7 @@ Bandwagon.Controller.Settings.invalidate = function()
document.getElementById("label-addonsshow-percollection").disabled = disabled;
document.getElementById("label-addonsperpage-percollection").disabled = disabled;
document.getElementById("textbox-addonsperpage-percollection").disabled = disabled;
- document.getElementById("perpage-default").disabled = disabled;
- document.getElementById("perpage-custom").disabled = disabled;
-}
-
-Bandwagon.Controller.Settings.invalidatePaginationSettings = function()
-{
- document.getElementById("pagination-box").collapsed = (Bandwagon.ENABLE_PAGINATION?false:true);
- document.getElementById("global-pagination-box").collapsed = (Bandwagon.ENABLE_PAGINATION?false:true);
+ //document.getElementById("checkbox-autopublish-percollection").disabled = disabled;
}
Bandwagon.Controller.Settings.invalidateCustomizeCollectionUI = function()
@@ -183,13 +166,14 @@ Bandwagon.Controller.Settings.invalidateCustomizeCollectionUI = function()
Bandwagon.Controller.Settings.invalidateLogin = function()
{
- var isLoggedIn = bandwagonService.isAuthenticated();
+ var isLoggedIn = bandwagonService.isAMOAuthenticated();
if (isLoggedIn)
{
- var loginEmail = Bandwagon.Preferences.getPreference("login");
- document.getElementById("login-status-text").value = Bandwagon.Controller.Settings.stringBundle.getFormattedString("login.status.with.email", [loginEmail]);
+ //var loginEmail = "???"; // TODO the client doesn't know what this is
+ //document.getElementById("login-status-text").value = Bandwagon.Controller.Settings.stringBundle.getFormattedString("login.status.with.email", [loginEmail]);
+ document.getElementById("login-status-text").value = Bandwagon.Controller.Settings.stringBundle.getString("login.status");
document.getElementById("login-button").collapsed = true;
document.getElementById("logout-button").removeAttribute("collapsed");
}
@@ -198,23 +182,7 @@ Bandwagon.Controller.Settings.invalidateLogin = function()
document.getElementById("login-status-text").value = Bandwagon.Controller.Settings.stringBundle.getString("logout.status");
document.getElementById("login-button").removeAttribute("collapsed");
document.getElementById("logout-button").collapsed = true;
-
- while (Bandwagon.Controller.Settings.elemBandwagonCollections.hasChildNodes())
- {
- Bandwagon.Controller.Settings.elemBandwagonCollections.removeChild(Bandwagon.Controller.Settings.elemBandwagonCollections.firstChild);
- }
}
-
- document.getElementById("auto-name").disabled = !isLoggedIn;
- document.getElementById("auto-create-button").disabled = !isLoggedIn;
- document.getElementById("auto-delete-button").disabled = !isLoggedIn;
- document.getElementById("auto-update-button").disabled = !isLoggedIn;
- document.getElementById("auto-list").disabled = !isLoggedIn;
- document.getElementById("auto-only-publish-enabled").disabled = !isLoggedIn;
- document.getElementById("auto-type-extensions").disabled = !isLoggedIn;
- document.getElementById("auto-type-themes").disabled = !isLoggedIn;
- document.getElementById("auto-type-dicts").disabled = !isLoggedIn;
- document.getElementById("auto-type-langpacks").disabled = !isLoggedIn;
}
Bandwagon.Controller.Settings.invalidateAutoPublisher = function()
@@ -223,18 +191,18 @@ Bandwagon.Controller.Settings.invalidateAutoPublisher = function()
if (localAutoPublisher != null)
{
+ Bandwagon.Controller.Settings._autoCreateToggleUIEnabledState(true);
+
document.getElementById("auto-spinner").collapsed = true;
document.getElementById("auto-create-button").collapsed = true;
document.getElementById("auto-delete-button").removeAttribute("collapsed");
- document.getElementById("auto-update-button").removeAttribute("collapsed");
document.getElementById("auto-name").value = localAutoPublisher.name;
- document.getElementById("auto-list").checked = localAutoPublisher.listed;
}
}
Bandwagon.Controller.Settings.invalidateAllowIncompatibleInstall = function()
{
- var isExtensionsCheckCompatibility = Bandwagon.Preferences.getGlobalPreference("extensions.checkCompatibility", true);
+ var isExtensionsCheckCompatibility = Bandwagon.Preferences.getGlobalPreference("extensions.checkCompatibility");
if (isExtensionsCheckCompatibility == null || isExtensionsCheckCompatibility == true)
{
@@ -434,29 +402,12 @@ Bandwagon.Controller.Settings._repopulateCollectionsList = function()
Bandwagon.Controller.Settings.doLogin = function()
{
- // open the extensions manager window.
-
- const EMTYPE = "Extension:Manager";
- var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
- .getService(Components.interfaces.nsIWindowMediator);
- var theEM = wm.getMostRecentWindow(EMTYPE);
-
- if (theEM)
- {
- theEM.focus();
- theEM.showView('bandwagon-collections');
- }
- else
- {
- const EMURL = "chrome://mozapps/content/extensions/extensions.xul";
- const EMFEATURES = "chrome,menubar,extra-chrome,toolbar,dialog=no,resizable";
- window.openDialog(EMURL, "", EMFEATURES);
- }
+ Bandwagon.Controller.Settings._openLocalizedURL(Bandwagon.COLLECTIONSPANE_DO_LOGIN_URL);
}
Bandwagon.Controller.Settings.doLogout = function()
{
- bandwagonService.deauthenticate();
+ Bandwagon.Controller.Settings._openLocalizedURL(Bandwagon.COLLECTIONSPANE_DO_LOGOUT_URL);
}
Bandwagon.Controller.Settings._openLocalizedURL = function(url)
@@ -498,13 +449,14 @@ Bandwagon.Controller.Settings.doCreateAutoPublisher = function()
{
// check form
document.getElementById("auto-error").value = "";
- document.getElementById("auto-error").style.color = 'red';
+ document.getElementById("auto-error").collapsed = true;
var collectionName = document.getElementById("auto-name").value;
- if (!collectionName || collectionName == "" || !collectionName.match(/.*\w.*/))
+ if (!collectionName || collectionName == "")
{
document.getElementById("auto-error").value = Bandwagon.Controller.Settings.stringBundle.getFormattedString("auto.invalid.name", [collectionName]);
+ document.getElementById("auto-error").collapsed = false;
return;
}
@@ -512,11 +464,11 @@ Bandwagon.Controller.Settings.doCreateAutoPublisher = function()
var autoPublishThemes = document.getElementById("auto-type-themes").checked;
var autoPublishDicts = document.getElementById("auto-type-dicts").checked;
var autoPublishLangPacks = document.getElementById("auto-type-langpacks").checked;
- var autoPublishDisabled = !document.getElementById("auto-only-publish-enabled").checked;
if (!autoPublishExtensions && !autoPublishThemes && !autoPublishDicts && !autoPublishLangPacks)
{
document.getElementById("auto-error").value = Bandwagon.Controller.Settings.stringBundle.getString("auto.please.select.type");
+ document.getElementById("auto-error").collapsed = false;
return;
}
@@ -525,13 +477,11 @@ Bandwagon.Controller.Settings.doCreateAutoPublisher = function()
Bandwagon.Controller.Settings._autoCreateToggleUIEnabledState(true);
// create the collection object
- //
- // TODO this logic should not be in the UI controller
var collection = new Bandwagon.Model.Collection();
collection.name = collectionName;
- collection.description = Bandwagon.Controller.Settings.stringBundle.getString("auto.create.description");
+ collection.description = collectionName; // nothing better to put here - api demands it
collection.listed = document.getElementById("auto-list").checked;
collection.writable = true;
collection.showNotifications = false;
@@ -543,46 +493,33 @@ Bandwagon.Controller.Settings.doCreateAutoPublisher = function()
collection.autoPublishThemes = autoPublishThemes;
collection.autoPublishDicts = autoPublishDicts;
collection.autoPublishLangPacks = autoPublishLangPacks;
- collection.autoPublishDisabled = autoPublishDisabled;
- Bandwagon.Preferences.setPreferenceList("autopublished.extensions", []);
-
// send the api call
-
+
var newCollectionCallback = function(event)
{
if (event.isError())
{
- if (event.getError().getMessage() == "invalid_parameters")
- {
- // this happens when the api doesn't like the collection name or description. TODO do we need a better error her?
- document.getElementById("auto-error").value = Bandwagon.Controller.Settings.stringBundle.getString("auto.create.internal.error");
- }
- else
- {
- document.getElementById("auto-error").value = Bandwagon.Controller.Settings.stringBundle.getString("auto.create.internal.error");
- }
-
- Bandwagon.Controller.Settings._autoCreateToggleUIEnabledState(false);
+ document.getElementById("auto-error").value = Bandwagon.Controller.Settings.stringBundle.getString("auto.create.internal.error");
+ document.getElementById("auto-error").collapsed = false;
+ Bandwagon.Controller.Settings._autoCreateToggleUIEnabledState(false);
}
else
{
- Bandwagon.Preferences.setPreference("local.autopublisher", collection.resourceURL);
-
- // we also need to subscribe to this collection
- bandwagonService.subscribeToCollection(collection);
+ // FIXME, we should really be using the guid here, but the api call doesn't give it to us :(
+ Bandwagon.Preferences.setPreference("local.autopublisher", collectionName);
- // publish extensions to this collection
- bandwagonService.autopublishExtensions();
+ // on callback of above, refresh collection list
+ bandwagonService.forceCheckAllForUpdatesAndUpdateCollectionsList();
// on callback of above, tell user we're done
document.getElementById("auto-error").style.color = 'green';
document.getElementById("auto-error").value = Bandwagon.Controller.Settings.stringBundle.getString("auto.create.done");
+ document.getElementById("auto-error").collapsed = false;
// clean-up
document.getElementById("auto-create-button").collapsed = true;
document.getElementById("auto-delete-button").collapsed = false;
- document.getElementById("auto-update-button").collapsed = false;
document.getElementById("auto-spinner").collapsed = true;
}
}
@@ -590,88 +527,9 @@ Bandwagon.Controller.Settings.doCreateAutoPublisher = function()
bandwagonService.newCollection(collection, newCollectionCallback);
}
-Bandwagon.Controller.Settings.doUpdateAutoPublisher = function()
-{
- document.getElementById("auto-error").value = "";
- document.getElementById("auto-error").style.color = 'red';
-
- var collectionName = document.getElementById("auto-name").value;
-
- if (!collectionName || collectionName == "" || !collectionName.match(/.*\w.*/))
- {
- document.getElementById("auto-error").value = Bandwagon.Controller.Settings.stringBundle.getFormattedString("auto.invalid.name", [collectionName]);
- return;
- }
-
- var promptService;
-
- try
- {
- promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService();
- promptService = promptService.QueryInterface(Components.interfaces.nsIPromptService);
- } catch (e) { return; }
-
- var promptTitle = document.getElementById("auto-update-button").label;
- var promptMsg = Bandwagon.Controller.Settings.stringBundle.getString("auto.update.confirm.message");
- var proceed = promptService.confirm(
- window,
- promptTitle,
- promptMsg
- );
-
- if (!proceed)
- {
- return;
- }
-
- document.getElementById("auto-spinner").collapsed = false;
-
- var collection = bandwagonService.getLocalAutoPublisher();
-
- collection.name = document.getElementById("auto-name").value;
- collection.listed = document.getElementById("auto-list").checked;
- collection.autoPublishExtensions = document.getElementById("auto-type-extensions").checked;
- collection.autoPublishThemes = document.getElementById("auto-type-themes").checked;
- collection.autoPublishDicts = document.getElementById("auto-type-dicts").checked;
- collection.autoPublishLangPacks = document.getElementById("auto-type-langpacks").checked;
- collection.autoPublishDisabled = !document.getElementById("auto-only-publish-enabled").checked;
-
- var callback = function(event)
- {
- document.getElementById("auto-spinner").collapsed = true;
-
- if (event.isError())
- {
- document.getElementById("auto-error").value = Bandwagon.Controller.Settings.stringBundle.getString("auto.update.internal.error");
- }
- else
- {
- Bandwagon.Preferences.setPreference("local.autopublisher", collection.resourceURL);
-
- // on callback of above, refresh collection list
- bandwagonService.forceCheckAllForUpdatesAndUpdateCollectionsList();
-
- Bandwagon.Controller.Settings._autoCreateToggleUIEnabledState(false);
-
- // on callback of above, tell user we're done
- document.getElementById("auto-error").style.color = 'green';
- document.getElementById("auto-error").value = Bandwagon.Controller.Settings.stringBundle.getString("auto.update.done");
-
- // clean-up
- document.getElementById("auto-create-button").collapsed = true;
- document.getElementById("auto-update-button").collapsed = false;
- document.getElementById("auto-delete-button").collapsed = false;
- document.getElementById("auto-spinner").collapsed = true;
- }
- }
-
- bandwagonService.updateCollectionDetails(collection, callback);
-}
-
Bandwagon.Controller.Settings.doDeleteAutoPublisher = function()
{
document.getElementById("auto-spinner").collapsed = false;
- document.getElementById("auto-error").style.color = 'red';
var localAutoPublisher = bandwagonService.getLocalAutoPublisher();
@@ -682,6 +540,7 @@ Bandwagon.Controller.Settings.doDeleteAutoPublisher = function()
if (event.isError())
{
document.getElementById("auto-error").value = Bandwagon.Controller.Settings.stringBundle.getString("auto.delete.internal.error");
+ document.getElementById("auto-error").collapsed = false;
}
else
{
@@ -695,10 +554,10 @@ Bandwagon.Controller.Settings.doDeleteAutoPublisher = function()
// on callback of above, tell user we're done
document.getElementById("auto-error").style.color = 'green';
document.getElementById("auto-error").value = Bandwagon.Controller.Settings.stringBundle.getString("auto.delete.done");
+ document.getElementById("auto-error").collapsed = false;
// clean-up
document.getElementById("auto-create-button").collapsed = false;
- document.getElementById("auto-update-button").collapsed = true;
document.getElementById("auto-delete-button").collapsed = true;
document.getElementById("auto-spinner").collapsed = true;
}
@@ -748,40 +607,71 @@ Bandwagon.Controller.Settings.doCancel = function()
// nothing
}
-Bandwagon.Controller.Settings.doUnsubscribe = function()
+/** OBSOLETE
+Bandwagon.Controller.Settings.doAdd = function()
+{
+ var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+ var promptTitle = Bandwagon.Controller.Settings.stringBundle.getString("add.collection");
+ var promptMsg = Bandwagon.Controller.Settings.stringBundle.getString("enter.url.to.add.collection");
+ var input = {value: "http://"};
+ var check = {value: false};
+ var proceed = prompts.prompt(window, promptTitle, promptMsg, input, null, check);
+
+ if (proceed)
+ {
+ bandwagonService.addPreviewCollection(input.value);
+ }
+}
+*/
+
+/** OBSOLETE XX Brian, er, I think not, see Remove Subscription button
+ * XX Dave, remove != unsubscribe
+Bandwagon.Controller.Settings.doRemove = function()
{
var collection = Bandwagon.Controller.Settings.elemBandwagonCollections.selectedItem.collection;
if (collection == null)
return;
- var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
- var check = {value: false};
- var flags = promptService.BUTTON_POS_0 * promptService.BUTTON_TITLE_IS_STRING + promptService.BUTTON_POS_1 * promptService.BUTTON_TITLE_IS_STRING;
- var button = promptService.confirmEx(
- window,
- Bandwagon.Controller.Settings.stringBundle2.getString("unsubscribe.confirm.title"),
- Bandwagon.Controller.Settings.stringBundle2.getString("unsubscribe.confirm.label"),
- flags,
- Bandwagon.Controller.Settings.stringBundle2.getString("unsubscribe.confirm.button0"),
- Bandwagon.Controller.Settings.stringBundle2.getString("unsubscribe.confirm.button1"),
- null,
- null,
- check);
-
- if (button == 0)
- {
- var callback = function(event)
- {
- if (event.isError())
- {
- window.alert(Bandwagon.Controller.Settings.stringBundle2.getString("unsubscribe.error"));
- }
- }
+ var promptService;
+
+ try
+ {
+ promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService();
+ promptService = promptService.QueryInterface(Components.interfaces.nsIPromptService);
+ } catch (e) { return; }
+
+ var promptTitle = Bandwagon.Controller.Settings.stringBundle.getString("remove.collection");
+ var promptMsg = Bandwagon.Controller.Settings.stringBundle.getFormattedString("are.you.sure.you.want.to.remove", [(collection.name?collection.name:collection.resourceURL)]);
+ var proceed = promptService.confirm(
+ window,
+ promptTitle,
+ promptMsg
+ );
- bandwagonService.unsubscribeFromCollection(collection, callback);
+ if (proceed)
+ {
+ // TODO for non-instant-apply dialogs, should we wait until 'Ok' is clicked before removal?
+
+ bandwagonService.unlinkCollection(collection);
+
+ if (!collection.preview)
+ bandwagonService.unsubscribe(collection);
}
}
+*/
+
+Bandwagon.Controller.Settings.doUnsubscribe = function()
+{
+ var collection = Bandwagon.Controller.Settings.elemBandwagonCollections.selectedItem.collection;
+
+ if (collection == null || !collection.links["unsubscribe"])
+ return;
+
+ Bandwagon.Controller.Settings._openLocalizedURL(collection.links["unsubscribe"]);
+}
Bandwagon.Controller.Settings.doUpdateIntervalScopeChange = function(event)
{