Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/bandwagon/content/ui/collectionsPaneController.js
diff options
context:
space:
mode:
Diffstat (limited to 'bandwagon/content/ui/collectionsPaneController.js')
-rw-r--r--bandwagon/content/ui/collectionsPaneController.js297
1 files changed, 159 insertions, 138 deletions
diff --git a/bandwagon/content/ui/collectionsPaneController.js b/bandwagon/content/ui/collectionsPaneController.js
index af2933f..b145aae 100644
--- a/bandwagon/content/ui/collectionsPaneController.js
+++ b/bandwagon/content/ui/collectionsPaneController.js
@@ -50,8 +50,8 @@ Bandwagon.Controller.CollectionsPane = new function()
this.elemBandwagonCollectionDescription = null;
this.elemBandwagonCollectionsNotification = null;
this.elemBandwagonCollectionDeck = null;
+ this.elemBandwagonCollectionHeader = null;
this.stringBundle = null;
- this.loginInProcess = false;
//this.previewNotificationVal = "bandwagon-collection-preview";
}
@@ -72,6 +72,7 @@ Bandwagon.Controller.CollectionsPane.init = function()
this.elemBandwagonCollectionDescription = document.getElementById("bandwagon-collection-description");
this.elemBandwagonCollectionsNotification = document.getElementById("bandwagon-collections-notification");
this.elemBandwagonCollectionDeck = document.getElementById("bandwagon-collection-deck");
+ this.elemBandwagonCollectionHeader = document.getElementById("bandwagon-collection-header");
Bandwagon.Controller.CollectionsPane._repopulateCollectionsList();
Bandwagon.Controller.CollectionsPane.invalidate();
@@ -81,11 +82,8 @@ Bandwagon.Controller.CollectionsPane.init = function()
bandwagonService.registerCollectionUpdateObserver(Bandwagon.Controller.CollectionsPane.collectionUpdateObserver);
bandwagonService.registerCollectionListChangeObserver(Bandwagon.Controller.CollectionsPane.collectionListChangeObserver);
- bandwagonService.registerAuthenticationStatusChangeObserver(Bandwagon.Controller.CollectionsPane.authenticationStatusChangeObserver);
Bandwagon.Preferences.addObserver(Bandwagon.Controller.CollectionsPane.prefObserver);
- Bandwagon.Preferences.addGlobalObserver(Bandwagon.Controller.CollectionsPane.prefObserver, "extensions.bandwagon.allow.incompatible.");
-
Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService).addObserver(Bandwagon.Controller.CollectionsPane.prefObserver, "nsPref:changed", false);
}
@@ -103,10 +101,7 @@ Bandwagon.Controller.CollectionsPane.onViewSelect = function()
if (elemsAddonExpanded && elemsAddonExpanded[0])
{
- try
- {
- Bandwagon.Controller.CollectionsPane.elemBandwagonAddons.ensureElementIsVisible(elemsAddonExpanded[0]);
- } catch (e) {}
+ Bandwagon.Controller.CollectionsPane.elemBandwagonAddons.ensureElementIsVisible(elemsAddonExpanded[0]);
}
}
}
@@ -134,10 +129,8 @@ Bandwagon.Controller.CollectionsPane.uninit = function()
bandwagonService.unregisterCollectionUpdateObserver(Bandwagon.Controller.CollectionsPane.collectionUpdateObserver);
bandwagonService.unregisterCollectionListChangeObserver(Bandwagon.Controller.CollectionsPane.collectionListChangeObserver);
- bandwagonService.unregisterAuthenticationStatusChangeObserver(Bandwagon.Controller.CollectionsPane.authenticationStatusChangeObserver);
Bandwagon.Preferences.removeObserver(Bandwagon.Controller.CollectionsPane.prefObserver);
- Bandwagon.Preferences.removeGlobalObserver(Bandwagon.Controller.CollectionsPane.prefObserver, "extensions.bandwagon.allow.incompatible.");
// now is a good time to save collections to storage
if (Bandwagon.COMMIT_NOW)
@@ -154,8 +147,7 @@ Bandwagon.Controller.CollectionsPane.invalidate = function()
Bandwagon.Controller.CollectionsPane.elemBandwagonButtonViewSite.disabled = true;
//Bandwagon.Controller.CollectionsPane.elemBandwagonButtonUpdate.disabled = true;
Bandwagon.Controller.CollectionsPane.elemBandwagonButtonRemove.disabled = true;
- Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionTitle.collapsed = true;
- Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionDescription.collapsed = true;
+ Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionHeader.collapsed = true;
Bandwagon.Controller.CollectionsPane._repopulateAddonsList(null);
@@ -166,8 +158,7 @@ Bandwagon.Controller.CollectionsPane.invalidate = function()
Bandwagon.Controller.CollectionsPane.elemBandwagonButtonViewSite.disabled = false;
//Bandwagon.Controller.CollectionsPane.elemBandwagonButtonUpdate.disabled = false;
Bandwagon.Controller.CollectionsPane.elemBandwagonButtonRemove.disabled = false;
- Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionTitle.collapsed = false;
- Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionDescription.collapsed = false;
+ Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionHeader.collapsed = false;
var collection = Bandwagon.Controller.CollectionsPane.elemBandwagonCollections.selectedItem.collection;
@@ -194,14 +185,16 @@ Bandwagon.Controller.CollectionsPane._invalidateExtensionsDeck = function()
{
var elemsBandwagonCollection = Bandwagon.Controller.CollectionsPane.elemBandwagonCollections.getElementsByTagName("bandwagonCollection");
- if (!bandwagonService.isAuthenticated() || this.loginInProcess == true)
- {
- Bandwagon.Controller.CollectionsPane.elemBandwagonExtensionsDeck.selectedIndex = 2;
- window.setTimeout(function() { document.getElementById("login").focus(); }, 200);
- }
- else if (elemsBandwagonCollection.length == 0)
+ if (elemsBandwagonCollection.length == 0)
{
- Bandwagon.Controller.CollectionsPane.elemBandwagonExtensionsDeck.selectedIndex = 1;
+ if (!bandwagonService.isAMOAuthenticated())
+ {
+ Bandwagon.Controller.CollectionsPane.elemBandwagonExtensionsDeck.selectedIndex = 2;
+ }
+ else
+ {
+ Bandwagon.Controller.CollectionsPane.elemBandwagonExtensionsDeck.selectedIndex = 1;
+ }
}
else
{
@@ -265,17 +258,21 @@ Bandwagon.Controller.CollectionsPane.collectionUpdateObserver = function(collect
if (Bandwagon.Controller.CollectionsPane.elemBandwagonCollections.selectedItem && collection.equals(Bandwagon.Controller.CollectionsPane.elemBandwagonCollections.selectedItem.collection))
{
Bandwagon.Controller.CollectionsPane._repopulateAddonsList(collection);
+
+ /* OBSOLETE
+ // if this is a just arrived collection preview, show the notification box
+ if (collection.preview)
+ {
+ Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionsNotification.notificationsHidden = false;
+ setTimeout(Bandwagon.Controller.CollectionsPane._createPreviewNotification, 200);
+ }
+ */
}
}
Bandwagon.Controller.CollectionsPane.invalidate();
}
-Bandwagon.Controller.CollectionsPane.authenticationStatusChangeObserver = function()
-{
- Bandwagon.Controller.CollectionsPane._invalidateExtensionsDeck();
-}
-
Bandwagon.Controller.CollectionsPane.doUpdateAll = function(event)
{
Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionDeck.selectedIndex = 1;
@@ -290,52 +287,10 @@ Bandwagon.Controller.CollectionsPane.doSubscribe = function(event)
Bandwagon.Controller.CollectionsPane.doLogin = function(event)
{
- var uname = document.getElementById("login").value;
- var pwd = document.getElementById("password").value;
-
- // Some client side checking for blank login details
- if (!uname || uname == "" || !uname.match(/.*\w.*/) ||
- !pwd || pwd == "" || !pwd.match(/.*\w.*/))
- {
- document.getElementById("auth-error").textContent = Bandwagon.Controller.ExtensionsOverlay.stringBundle.getString("login.error");
- document.getElementById("auth-error").collapsed = false;
- return;
- }
-
- this.loginInProcess = true;
-
- document.getElementById("auth-button").disabled = true;
- document.getElementById("auth-spinner").style.visibility = "visible";
- document.getElementById("auth-error").collapsed = true;
-
- var callback2 = function(event)
- {
- document.getElementById("auth-button").disabled = false;
- document.getElementById("auth-spinner").style.visibility = "hidden";
- document.getElementById("password").value = "";
- Bandwagon.Controller.CollectionsPane.loginInProcess = false;
- Bandwagon.Controller.CollectionsPane._invalidateExtensionsDeck();
- }
-
- var callback1 = function(event)
- {
- if (event.isError())
- {
- // show err
- document.getElementById("auth-error").textContent = Bandwagon.Controller.ExtensionsOverlay.stringBundle.getString("login.error");
- document.getElementById("auth-error").collapsed = false;
- document.getElementById("auth-button").disabled = false;
- document.getElementById("auth-spinner").style.visibility = "hidden";
- }
- else
- {
- bandwagonService.updateCollectionsList(callback2);
- }
- }
-
- bandwagonService.authenticate(uname, pwd, callback1);
+ Bandwagon.Controller.CollectionsPane._openLocalizedURL(Bandwagon.COLLECTIONSPANE_DO_LOGIN_URL);
}
+
Bandwagon.Controller.CollectionsPane.doSettings = function(event)
{
var prefSvc = Components.classes["@mozilla.org/preferences-service;1"].
@@ -395,36 +350,29 @@ Bandwagon.Controller.CollectionsPane.doUnsubscribe = function(event)
var collection = Bandwagon.Controller.CollectionsPane.elemBandwagonCollections.selectedItem.collection;
+ if (collection == null || !collection.links["unsubscribe"])
+ return;
+
+ Bandwagon.Controller.CollectionsPane._openURL(collection.links["unsubscribe"]);
+}
+
+/** OBSOLETE
+Bandwagon.Controller.CollectionsPane.doRemove = function(event)
+{
+ if (Bandwagon.Controller.CollectionsPane.elemBandwagonCollections.selectedItem == null)
+ return;
+
+ var collection = Bandwagon.Controller.CollectionsPane.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.ExtensionsOverlay.stringBundle.getString("unsubscribe.confirm.title"),
- Bandwagon.Controller.ExtensionsOverlay.stringBundle.getString("unsubscribe.confirm.label"),
- flags,
- Bandwagon.Controller.ExtensionsOverlay.stringBundle.getString("unsubscribe.confirm.button0"),
- Bandwagon.Controller.ExtensionsOverlay.stringBundle.getString("unsubscribe.confirm.button1"),
- null,
- null,
- check);
-
- if (button == 0)
- {
- var callback = function(event)
- {
- if (event.isError())
- {
- window.alert(Bandwagon.Controller.ExtensionsOverlay.stringBundle.getString("unsubscribe.error"));
- }
- }
+ bandwagonService.unlinkCollection(collection);
- bandwagonService.unsubscribeFromCollection(collection, callback);
- }
+ if (!collection.preview)
+ bandwagonService.unsubscribe(collection);
}
+*/
Bandwagon.Controller.CollectionsPane.doShowCollection = function()
{
@@ -441,11 +389,11 @@ Bandwagon.Controller.CollectionsPane.doShowCollection = function()
// misc. ui
- Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionTitle.textContent = (collection?(collection.name?collection.name:collection.resourceURL):"");
+ Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionTitle.setAttribute("value", (collection?(collection.name?collection.name:collection.resourceURL):""));
if (collection && collection.description != "")
{
- Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionDescription.textContent = collection.description;
+ Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionDescription.setAttribute("value", collection.description);
Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionDescription.removeAttribute("collsaped");
}
else
@@ -453,7 +401,20 @@ Bandwagon.Controller.CollectionsPane.doShowCollection = function()
Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionDescription.setAttribute("collapsed", true);
}
- Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionsNotification.notificationsHidden = true;
+ /** OBSOLETE
+ // collection preview notification box
+ if (collection && collection.preview && collection.status != collection.STATUS_LOADING)
+ {
+ Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionsNotification.notificationsHidden = false;
+
+ // this needs to be in a seperate thread
+ setTimeout(Bandwagon.Controller.CollectionsPane._createPreviewNotification, 500);
+ }
+ else
+ */
+ {
+ Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionsNotification.notificationsHidden = true;
+ }
// show items
@@ -584,13 +545,13 @@ Bandwagon.Controller.CollectionsPane.doAddToFirefox = function()
var params = [];
params[addon.name] = installer;
- // TODO do some user feedback here?
+ // TODO do some user collectionback here?
var callback = function(url, status)
{
Bandwagon.Logger.info("Finished installing '" + url + "'; status = " + status);
- // TODO some user feedback here?
+ // TODO some user collectionback here?
}
InstallTrigger.install(params, callback);
@@ -610,6 +571,99 @@ Bandwagon.Controller.CollectionsPane.doDownloadFirefoxNBeta = function(version)
Bandwagon.Controller.CollectionsPane._openURL("http://www.mozilla.com/en-US/firefox/all-beta.html");
}
+/** OBSOLETE
+Bandwagon.Controller.CollectionsPane.doShowCollectionPreview = function(collectionURL)
+{
+ // this is executed when the browser overlay controller opens the EM window to subscribe to a new collection.
+ // i.e. after a custom bandwagonSubscribe is detected and handled
+
+ Bandwagon.Logger.debug("In Bandwagon.Controller.CollectionsPane.doShowCollectionPreview() with collectionURL = " + collectionURL);
+
+ // check if we already have this collection
+
+ if (bandwagonService.collections[collectionURL])
+ {
+ var collection = bandwagonService.collections[collectionURL];
+ Bandwagon.Controller.CollectionsPane.preferredCollection = collection;
+ //Bandwagon.Controller.CollectionsPane._selectCollection(collection);
+ setTimeout(function() { Bandwagon.Controller.CollectionsPane._selectCollection(collection); }, 500);
+ return;
+ }
+
+ // add and select the collection
+
+ var collection = bandwagonService.addPreviewCollection(collectionURL);
+ //collection.status = collection.STATUS_LOADING;
+
+ Bandwagon.Controller.CollectionsPane.preferredCollection = collection;
+ setTimeout(function() { Bandwagon.Controller.CollectionsPane._selectCollection(collection); }, 500);
+}
+*/
+
+/** OBSOLETE
+Bandwagon.Controller.CollectionsPane._createPreviewNotification = function()
+{
+ if (!Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionsNotification.getNotificationWithValue(Bandwagon.Controller.CollectionsPane.previewNotificationVal))
+ {
+ Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionsNotification.appendNotification
+ (
+ Bandwagon.Controller.ExtensionsOverlay.stringBundle.getString("collectionspane.this.is.only.a.preview"),
+ Bandwagon.Controller.CollectionsPane.previewNotificationVal,
+ null,
+ Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionsNotification.PRIORITY_WARNING_MEDIUM,
+ [
+ {
+ accessKey: Bandwagon.Controller.ExtensionsOverlay.stringBundle.getString("collectionspane.dont.subscribe.accesskey"),
+ callback: Bandwagon.Controller.CollectionsPane.doCollectionPreviewDontSubscribe,
+ label: Bandwagon.Controller.ExtensionsOverlay.stringBundle.getString("collectionspane.dont.subscribe"),
+ popup: null
+ },
+ {
+ accessKey: Bandwagon.Controller.ExtensionsOverlay.stringBundle.getString("collectionspane.subscribe.accesskey"),
+ callback: Bandwagon.Controller.CollectionsPane.doCollectionPreviewSubscribe,
+ label: Bandwagon.Controller.ExtensionsOverlay.stringBundle.getString("collectionspane.subscribe"),
+ popup: null
+ }
+ ]
+ );
+ }
+}
+*/
+
+/** OBSOLETE
+Bandwagon.Controller.CollectionsPane.doCollectionPreviewDontSubscribe = function()
+{
+ Bandwagon.Logger.debug("in Bandwagon.Controller.CollectionsPane.doCollectionPreviewDontSubscribe()");
+
+ Bandwagon.Controller.CollectionsPane.preferredCollection = null;
+
+ Bandwagon.Controller.CollectionsPane.doRemove();
+}
+*/
+
+/** OBSOLETE
+Bandwagon.Controller.CollectionsPane.doCollectionPreviewSubscribe = function()
+{
+ Bandwagon.Logger.debug("in Bandwagon.Controller.CollectionsPane.doCollectionPreviewSubscribe()");
+
+ if (Bandwagon.Controller.CollectionsPane.elemBandwagonCollections.selectedItem == null)
+ return;
+
+ var collection = Bandwagon.Controller.CollectionsPane.elemBandwagonCollections.selectedItem.collection;
+
+ if (collection == null)
+ return;
+
+ bandwagonService.subscribe(collection);
+
+ if (Bandwagon.COMMIT_NOW)
+ bandwagonService.commit(collection);
+
+ Bandwagon.Controller.CollectionsPane.elemBandwagonCollections.selectedItem.preview = false;
+ Bandwagon.Controller.CollectionsPane.doShowCollection();
+}
+*/
+
/**
* Refreshes the collection pane
*/
@@ -635,24 +689,8 @@ Bandwagon.Controller.CollectionsPane.prefObserver =
if (data.match(/addonsperpage/))
{
- Bandwagon.Logger.debug("In prefObserver; addonsperpage has changed");
-
Bandwagon.Controller.CollectionsPane.refresh();
}
- else if (data.match(/checkCompatibility/) || data.match(/install/))
- {
- Bandwagon.Logger.debug("In prefObserver; checkCompatibility has changed");
-
- if (Bandwagon.Controller.CollectionsPane.elemBandwagonAddons.selectedItem != null)
- {
- var elemsAddonExpanded = Bandwagon.Controller.CollectionsPane.elemBandwagonAddons.getElementsByTagName("bandwagonAddonExpanded");
-
- if (elemsAddonExpanded && elemsAddonExpanded[0])
- {
- elemsAddonExpanded[0].invalidateCompatibilityCheck();
- }
- }
- }
}
}
@@ -692,12 +730,9 @@ Bandwagon.Controller.CollectionsPane._selectCollection = function(collection)
return false;
}
- try
- {
- Bandwagon.Controller.CollectionsPane.elemBandwagonCollections.selectItem(elemBandwagonCollection);
- Bandwagon.Controller.CollectionsPane.elemBandwagonCollections.ensureElementIsVisible(elemBandwagonCollection);
- Bandwagon.Controller.CollectionsPane.elemBandwagonCollections.focus();
- } catch (e) {}
+ Bandwagon.Controller.CollectionsPane.elemBandwagonCollections.selectItem(elemBandwagonCollection);
+ Bandwagon.Controller.CollectionsPane.elemBandwagonCollections.ensureElementIsVisible(elemBandwagonCollection);
+ Bandwagon.Controller.CollectionsPane.elemBandwagonCollections.focus();
return true;
}
@@ -802,20 +837,10 @@ Bandwagon.Controller.CollectionsPane._repopulateAddonsList = function(collection
// repopulate with collection items
+ var addonsPerPage = bandwagonService.getAddonsPerPage(collection);
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
- var addonsToDisplay;
-
- if (Bandwagon.ENABLE_PAGINATION)
- {
- addonsToDisplay = Math.max(bandwagonService.getAddonsPerPage(collection), addonsSorted.length);
- }
- else
- {
- addonsToDisplay = addonsSorted.length;
- }
-
- for (var i=0; i<addonsToDisplay; i++)
+ for (var i=0; (i<addonsSorted.length&&i<addonsPerPage); i++)
{
var addon = collection.addons[addonsSorted[i].guid];
@@ -831,8 +856,6 @@ Bandwagon.Controller.CollectionsPane._repopulateAddonsList = function(collection
Bandwagon.Controller.CollectionsPane._openURL = function(url)
{
- Bandwagon.Logger.debug("Opening URL " + url);
-
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var mainWindow = wm.getMostRecentWindow("navigator:browser");
@@ -853,8 +876,6 @@ Bandwagon.Controller.CollectionsPane._openLocalizedURL = function(url)
{
var locale = Bandwagon.Util.getBrowserLocale();
- Bandwagon.Logger.debug("locale = " + locale);
-
if (locale && locale != "")
url = url.replace(/en-US/, locale, "g");