diff options
Diffstat (limited to 'bandwagon/content/ui/overlays')
-rw-r--r-- | bandwagon/content/ui/overlays/browserOverlay.xul | 22 | ||||
-rw-r--r-- | bandwagon/content/ui/overlays/browserOverlayController.js | 103 | ||||
-rw-r--r-- | bandwagon/content/ui/overlays/extensionsOverlay.xul | 150 | ||||
-rw-r--r-- | bandwagon/content/ui/overlays/extensionsOverlayController.js | 128 |
4 files changed, 273 insertions, 130 deletions
diff --git a/bandwagon/content/ui/overlays/browserOverlay.xul b/bandwagon/content/ui/overlays/browserOverlay.xul index 619b97b..cb9d0e8 100644 --- a/bandwagon/content/ui/overlays/browserOverlay.xul +++ b/bandwagon/content/ui/overlays/browserOverlay.xul @@ -19,7 +19,7 @@ - Portions created by the Initial Developer are Copyright (C) 2008 - the Initial Developer. All Rights Reserved. - - - Contributor(s): Brian King + - Contributor(s): Brian King <brian (at) briks (dot) si> - - Alternatively, the contents of this file may be used under the terms of - either the GNU General Public License Version 2 or later (the "GPL"), or @@ -35,6 +35,10 @@ - - ***** END LICENSE BLOCK ***** --> +<!DOCTYPE overlay SYSTEM "chrome://bandwagon/locale/browserOverlay.dtd" > + +<?xml-stylesheet href="chrome://bandwagon/skin/browserOverlay.css" type="text/css"?> + <overlay id="bandwagon-browser-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> @@ -47,9 +51,10 @@ <script src="chrome://bandwagon/content/scripts/rpc/error.js"/> <script src="chrome://bandwagon/content/scripts/rpc/event.js"/> <script src="chrome://bandwagon/content/scripts/rpc/net.js"/> - <script src="chrome://bandwagon/content/scripts/model/feed.js"/> - <script src="chrome://bandwagon/content/scripts/model/feedItem.js"/> - <script src="chrome://bandwagon/content/scripts/factory/feedFactory.js"/> + <script src="chrome://bandwagon/content/scripts/model/serviceDocument.js"/> + <script src="chrome://bandwagon/content/scripts/model/collection.js"/> + <script src="chrome://bandwagon/content/scripts/model/addon.js"/> + <script src="chrome://bandwagon/content/scripts/factory/collectionFactory.js"/> <script src="chrome://bandwagon/content/ui/overlays/browserOverlayController.js"/> @@ -57,4 +62,13 @@ <stringbundle id="bandwagon-strings" src="chrome://bandwagon/locale/browserOverlay.properties"/> </stringbundleset> + <!-- Firefox Toolbar --> + <toolbarpalette id="BrowserToolbarPalette"> + <toolbarbutton id="extensions-bandwagon-button" + class="toolbarbutton-1 bandwagon-button" + oncommand="Bandwagon.Controller.BrowserOverlay.openAddons();" + tooltiptext="&bandwagon.tooltip;" + label="&bandwagon.label;" /> + </toolbarpalette> + </overlay> diff --git a/bandwagon/content/ui/overlays/browserOverlayController.js b/bandwagon/content/ui/overlays/browserOverlayController.js index d2f3761..868ac37 100644 --- a/bandwagon/content/ui/overlays/browserOverlayController.js +++ b/bandwagon/content/ui/overlays/browserOverlayController.js @@ -14,11 +14,11 @@ * The Original Code is bandwagon. * * The Initial Developer of the Original Code is - * David McNamara. + * Mozilla Corporation. * Portions created by the Initial Developer are Copyright (C) 2008 * the Initial Developer. All Rights Reserved. * - * Contributor(s): + * Contributor(s): David McNamara * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -34,6 +34,8 @@ * * ***** END LICENSE BLOCK ***** */ +var bandwagonService; + Bandwagon.Controller.BrowserOverlay = new function() {} Bandwagon.Controller.BrowserOverlay.initBandwagon = function() @@ -44,7 +46,7 @@ Bandwagon.Controller.BrowserOverlay.initBandwagon = function() { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - var bandwagonService = Components.classes["@addons.mozilla.org/bandwagonservice;1"] + bandwagonService = Components.classes["@addons.mozilla.org/bandwagonservice;1"] .getService().wrappedJSObject; // We can safely call init() for each new browser window; the service @@ -60,10 +62,44 @@ Bandwagon.Controller.BrowserOverlay.initBandwagon = function() Bandwagon.Logger.error("Error initializing bandwagon: " + e); } + /** OBSOLETE // add listener to every page loaded in the browser - listen for our custom bandwagonSubscribe event gBrowser.addEventListener("load", Bandwagon.Controller.BrowserOverlay.addSubscribeEventListenerToDocument, true); + */ + + gBrowser.addEventListener("load", Bandwagon.Controller.BrowserOverlay.addSubscriptionRefreshEventListenerToDocument, true); +} + +Bandwagon.Controller.BrowserOverlay.addSubscriptionRefreshEventListenerToDocument = function(event) +{ + if (event.originalTarget instanceof HTMLDocument) + { + var doc = event.originalTarget; + + if (event.originalTarget.defaultView.frameElement) + { + while (doc.defaultView.frameElement) + { + doc=doc.defaultView.frameElement.ownerDocument; + } + } + + // TODO only add to AMO + + doc.addEventListener("bandwagonRefresh", Bandwagon.Controller.BrowserOverlay.handleSubscriptionRefreshEvent, true); + + Bandwagon.Logger.debug("added bandwagonRefresh listener"); + } } +Bandwagon.Controller.BrowserOverlay.handleSubscriptionRefreshEvent = function(event) +{ + Bandwagon.Logger.info("Received bandwagon subscription refresh event"); + + bandwagonService.updateCollectionsList(); +} + +/** OBSOLETE Bandwagon.Controller.BrowserOverlay.addSubscribeEventListenerToDocument = function(event) { if (event.originalTarget instanceof HTMLDocument) @@ -83,24 +119,28 @@ Bandwagon.Controller.BrowserOverlay.addSubscribeEventListenerToDocument = functi //Bandwagon.Logger.debug("added bandwagonSubscribe listener"); } } +*/ +/** OBSOLETE Bandwagon.Controller.BrowserOverlay.handleSubscribeEvent = function(event) { if (event.target && event.target.getAttribute("href")) { - var feedURL = event.target.getAttribute("href"); + var collectionURL = event.target.getAttribute("href"); - Bandwagon.Logger.info("Received subscribe event for feed: " + feedURL); + Bandwagon.Logger.info("Received subscribe event for collection: " + collectionURL); - Bandwagon.Controller.BrowserOverlay._openExtensionManagerFeedsPaneWithSubscribe(feedURL); + Bandwagon.Controller.BrowserOverlay._openExtensionManagerCollectionsPaneWithSubscribe(collectionURL); } else { Bandwagon.Logger.error("Missing data payload in bandwagonSubscribe event"); } } +*/ -Bandwagon.Controller.BrowserOverlay._openExtensionManagerFeedsPaneWithSubscribe = function(feedURL) +/** OBSOLETE +Bandwagon.Controller.BrowserOverlay._openExtensionManagerCollectionsPaneWithSubscribe = function(collectionURL) { const EMTYPE = "Extension:Manager"; var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] @@ -109,23 +149,24 @@ Bandwagon.Controller.BrowserOverlay._openExtensionManagerFeedsPaneWithSubscribe if (theEM) { - // extensions manager window already open - focus, show feeds pane, call doShowFeedPreview + // extensions manager window already open - focus, show collections pane, call doShowCollectionPreview theEM.focus(); - theEM.showView('bandwagon-feeds'); + theEM.showView('bandwagon-collections'); - setTimeout(function() { Bandwagon.Controller.FeedsPane.doShowFeedPreview(feedURL); }, 500); + setTimeout(function() { Bandwagon.Controller.CollectionsPane.doShowCollectionPreview(collectionURL); }, 500); } else { - // extensions manager window NOT already open - open with 'subscribe' argument (this will show feeds pane, call doShowFeedPreview) + // extensions manager window NOT already open - open with 'subscribe' argument (this will show collection pane, call doShowCollectionPreview) const EMURL = "chrome://mozapps/content/extensions/extensions.xul"; const EMFEATURES = "chrome,menubar,extra-chrome,toolbar,dialog=no,resizable"; - window.openDialog(EMURL, "", EMFEATURES, {subscribe: feedURL}); + window.openDialog(EMURL, "", EMFEATURES, {subscribe: collectionURL}); } } +*/ Bandwagon.Controller.BrowserOverlay._removeLoadListener = function() { @@ -144,18 +185,26 @@ Bandwagon.Controller.BrowserOverlay.openFirstRunLandingPage = function() 1000); } -Bandwagon.Controller.BrowserOverlay.showNewFeedItemsAlert = function(feed) +/* Toolbar button action - Open add-ons window with Subscriptions tab focused */ +Bandwagon.Controller.BrowserOverlay.openAddons = function() +{ + const EMURL = "chrome://mozapps/content/extensions/extensions.xul"; + const EMFEATURES = "chrome,menubar,extra-chrome,toolbar,dialog=no,resizable"; + window.openDialog(EMURL, "", EMFEATURES, "bandwagon-collections"); +} + +Bandwagon.Controller.BrowserOverlay.showNewAddonsAlert = function(collection) { - Bandwagon.Logger.debug("in showNewFeedItemsAlert()"); + Bandwagon.Logger.debug("in showNewAddonsAlert()"); var bandwagonStrings = document.getElementById("bandwagon-strings"); var alertsService = Components.classes["@mozilla.org/alerts-service;1"] .getService(Components.interfaces.nsIAlertsService); - var unnotifiedCount = feed.getUnnotifiedFeedItems().length; - var feedName = (feed.name?feed.name:feed.url); - var feedURL = feed.url; + var unnotifiedCount = collection.getUnnotifiedAddons().length; + var collectionName = (collection.name?collection.name:collection.resourceURL); + var collectionURL = collection.resourceURL; var listener = { @@ -163,7 +212,7 @@ Bandwagon.Controller.BrowserOverlay.showNewFeedItemsAlert = function(feed) { if (topic == "alertclickcallback") { - var feedURL = data; + var collectionURL = data; const EMTYPE = "Extension:Manager"; var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] @@ -173,22 +222,22 @@ Bandwagon.Controller.BrowserOverlay.showNewFeedItemsAlert = function(feed) if (theEM) { theEM.focus(); - theEM.showView('bandwagon-feeds'); + theEM.showView('bandwagon-collections'); - // if the em is open, select the bandwagon-feeds pane, but don't select the feed itself. + // if the em is open, select the bandwagon-collections pane, but don't select the collection itself. // the user will be notified by the unread count in the left hand side bar - //theEM.setTimeout(function() { Bandwagon.Controller.FeedsPane._selectFeed(feed); }, 500); + //theEM.setTimeout(function() { Bandwagon.Controller.CollectionsPane._selectCollection(collection); }, 500); } else { const EMURL = "chrome://mozapps/content/extensions/extensions.xul"; const EMFEATURES = "chrome,menubar,extra-chrome,toolbar,dialog=no,resizable"; - // the em is not open - open it, and select this feed + // the em is not open - open it, and select this collection if (window) - window.openDialog(EMURL, "", EMFEATURES, {selectFeed: feedURL}); + window.openDialog(EMURL, "", EMFEATURES, {selectCollection: collectionURL}); else Bandwagon.Logger.error("No browser windows open - can't open EM"); } @@ -200,11 +249,11 @@ Bandwagon.Controller.BrowserOverlay.showNewFeedItemsAlert = function(feed) try { alertsService.showAlertNotification( - "chrome://bandwagon/skin/images/tango-addonfeed-32x32.png", - bandwagonStrings.getString("newfeeditems.alert.title"), - bandwagonStrings.getFormattedString("newfeeditems.alert.text", [feedName]), + "chrome://bandwagon/skin/images/icon32.png", + bandwagonStrings.getString("newaddons.alert.title"), + bandwagonStrings.getFormattedString("newaddons.alert.text", [collectionName]), true, - feedURL, + collectionURL, listener ); } diff --git a/bandwagon/content/ui/overlays/extensionsOverlay.xul b/bandwagon/content/ui/overlays/extensionsOverlay.xul index 0d679f1..6f546dc 100644 --- a/bandwagon/content/ui/overlays/extensionsOverlay.xul +++ b/bandwagon/content/ui/overlays/extensionsOverlay.xul @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> + <!-- ***** BEGIN LICENSE BLOCK ***** - Version: MPL 1.1/GPL 2.0/LGPL 2.1 - @@ -15,11 +16,12 @@ - The Original Code is bandwagon. - - The Initial Developer of the Original Code is - - David McNamara. + - Mozilla Corporation. - Portions created by the Initial Developer are Copyright (C) 2008 - the Initial Developer. All Rights Reserved. - - - Contributor(s): Brian King + - Contributor(s): David McNamara + - Brian King <brian (at) briks (dot) si> - - Alternatively, the contents of this file may be used under the terms of - either the GNU General Public License Version 2 or later (the "GPL"), or @@ -46,7 +48,7 @@ <script src="chrome://bandwagon/content/ui/dialog.js"/> <script src="chrome://bandwagon/content/ui/overlays/extensionsOverlayController.js"/> - <script src="chrome://bandwagon/content/ui/feedsPaneController.js"/> + <script src="chrome://bandwagon/content/ui/collectionsPaneController.js"/> <stringbundleset> <stringbundle id="bandwagon-strings" src="chrome://bandwagon/locale/extensionOverlay.properties"/> @@ -55,10 +57,10 @@ <stack id="topStackBar"> <radiogroup id="viewGroup"> - <radio id="bandwagon-feeds-view" - label="&feeds.label;" + <radio id="bandwagon-collections-view" + label="&collections.label;" insertbefore="extensions-view" - oncommand="showView('bandwagon-feeds');" + oncommand="showView('bandwagon-collections');" persist="last-selected"/> <radio id="search-view" label="&search.label.bandwagon;" @@ -69,65 +71,89 @@ </stack> <vbox id="extensionsBox"> - <hbox id="bandwagon-feeds-panel" hidden="true" flex="1"> - <vbox id="bandwagon-feeds-list-box" persist="width"> - <richlistbox id="bandwagon-feeds-list" - seltype="single" - style="min-width: 14em; width: 16em; max-width: 36em;" - flex="1"/> - <toolbox class="bandwagon-feeds-toolbox"> - <toolbar pack="start" - align="center"> - <toolbarbutton id="bandwagon-button-subscribe" - tooltiptext="&subscribe.label;" - oncommand="Bandwagon.Controller.FeedsPane.doSubscribe();"/> - <toolbarbutton id="bandwagon-button-update-all" - tooltiptext="&reload.label;" - oncommand="Bandwagon.Controller.FeedsPane.doUpdateAll();"/> - <toolbarbutton id="bandwagon-button-settings" - tooltiptext="&settings.label;" - oncommand="Bandwagon.Controller.FeedsPane.doSettings();"/> - </toolbar> - </toolbox> - </vbox> - <splitter id="bandwagon-sidebar-splitter" /> - <notificationbox flex="1" id="bandwagon-feeds-notification"> - <toolbox class="bandwagon-feeds-toolbox"> - <toolbar pack="end"> - <button id="bandwagon-button-viewsite" label="&viewsite.label;" oncommand="Bandwagon.Controller.FeedsPane.doViewSite();"/> - <button id="bandwagon-button-update" label="&update.label;" oncommand="Bandwagon.Controller.FeedsPane.doUpdate();"/> - <button id="bandwagon-button-remove" label="&remove.label;" oncommand="Bandwagon.Controller.FeedsPane.doRemove();"/> - </toolbar> - </toolbox> - <vbox id="bandwagon-feed-header"> - <label id="bandwagon-feed-title"/> - <label id="bandwagon-feed-description"/> - </vbox> - <deck id="bandwagon-feed-deck" selectedIndex="0" flex="1"> - <hbox flex="1"> - <richlistbox id="bandwagon-feeditems-list" + <vbox id="bandwagon-collections-panel" hidden="true" flex="1"> + <deck id="bandwagon-extensions-deck" flex="1"> + <hbox id="bandwagon-subscriptions-panel" flex="1"> + <vbox id="bandwagon-collections-list-box" persist="width"> + <richlistbox id="bandwagon-collections-list" seltype="single" + style="min-width: 14em; width: 16em; max-width: 36em;" flex="1"/> - </hbox> - <vbox flex="1" align="center" pack="center"> - <label value="&nofeedssubscribed.label;"/> - <button label="&clicktosubscribe.label;" oncommand="Bandwagon.Controller.FeedsPane.doSubscribe();"/> - </vbox> - <vbox flex="1" align="center" pack="center"> - <label class="userfeedback" value="&feedisloading.label;"/> - <image src="chrome://bandwagon/skin/images/spinner.gif"/> - </vbox> - <vbox flex="1" align="center" pack="center"> - <image src="chrome://bandwagon/skin/images/information.png"/> - <label class="userfeedback" value="&feedhasnoitems.label;"/> + <toolbox class="bandwagon-collections-toolbox"> + <toolbar pack="start" + align="center"> + <toolbarbutton id="bandwagon-button-subscribe" + tooltiptext="&subscribe.label;" + oncommand="Bandwagon.Controller.CollectionsPane.doSubscribe();"/> + <toolbarbutton id="bandwagon-button-update-all" + tooltiptext="&reload.label;" + oncommand="Bandwagon.Controller.CollectionsPane.doUpdateAll();"/> + <toolbarbutton id="bandwagon-button-settings" + tooltiptext="&settings.label;" + oncommand="Bandwagon.Controller.CollectionsPane.doSettings();"/> + </toolbar> + </toolbox> </vbox> - <vbox flex="1" align="center" pack="center"> - <image src="chrome://bandwagon/skin/images/error.png"/> - <label class="userfeedback" value="&feedhaserror.label;"/> - </vbox> - </deck> - </notificationbox> - </hbox> + <splitter id="bandwagon-sidebar-splitter" /> + <notificationbox flex="1" id="bandwagon-collections-notification"> + <hbox pack="end"> + <label id="bandwagon-button-viewsite" + value="&view.label;" + class="text-link" + onclick="Bandwagon.Controller.CollectionsPane.doViewSite();"/> + <separator id="bandwagon-link-splitter"/> + <label id="bandwagon-button-remove" + value="&unsubscribe.label;" + class="text-link" + onclick="Bandwagon.Controller.CollectionsPane.doRemove();"/> + </hbox> + <vbox id="bandwagon-collection-header"> + <label id="bandwagon-collection-title"/> + <label id="bandwagon-collection-description"/> + </vbox> + <deck id="bandwagon-collection-deck" selectedIndex="0" flex="1"> + <hbox flex="1"> + <richlistbox id="bandwagon-addons-list" + seltype="single" + flex="1"/> + </hbox> + <vbox flex="1" align="center" pack="center"> + <label class="usercollectionback" value="&collectionisloading.label;"/> + <image src="chrome://bandwagon/skin/images/spinner.gif"/> + </vbox> + <vbox flex="1" align="center" pack="center"> + <image src="chrome://bandwagon/skin/images/information.png"/> + <label class="usercollectionback" value="&collectionhasnoitems.label;"/> + </vbox> + <vbox flex="1" align="center" pack="center"> + <image src="chrome://bandwagon/skin/images/error.png"/> + <label class="usercollectionback" value="&collectionhaserror.label;"/> + </vbox> + </deck> + </notificationbox> + </hbox> + <vbox id="nosubs-box" class="fs-info-panel" flex="1" > + <label id="nosubs-header" class="fs-info-panel-header" value="&nocollectionstitle.label;"/> + <separator/> + <description class="fs-info-panel-text">&nocollectionssubscribed.label;</description> + <separator/> + <hbox pack="center"> + <button label="&clicktosubscribe.label;" + oncommand="Bandwagon.Controller.CollectionsPane.doSubscribe();"/> + </hbox> + </vbox> + <vbox id="no-amo-auth-box" class="fs-info-panel" flex="1" > + <label id="no-amo-auth-header" class="fs-info-panel-header" value="&nocollectionstitle.label;"/> + <separator/> + <description class="fs-info-panel-text">&noamoauth.label;</description> + <separator/> + <hbox pack="center"> + <button label="&clicktologin.label;" + oncommand="Bandwagon.Controller.CollectionsPane.doLogin();"/> + </hbox> + </vbox> + </deck> + </vbox> </vbox> </overlay> diff --git a/bandwagon/content/ui/overlays/extensionsOverlayController.js b/bandwagon/content/ui/overlays/extensionsOverlayController.js index 3cb08b5..a1faac0 100644 --- a/bandwagon/content/ui/overlays/extensionsOverlayController.js +++ b/bandwagon/content/ui/overlays/extensionsOverlayController.js @@ -19,7 +19,7 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): David McNamara - * Brian King + * Brian King <brian (at) briks (dot) si> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -54,7 +54,7 @@ Bandwagon.Controller.ExtensionsOverlay.init = function() // So lets hackily hide ours in that circumstance var extView = document.getElementById("extensions-view"); - var bfv = document.getElementById("bandwagon-feeds-view"); + var bfv = document.getElementById("bandwagon-collections-view"); var lsi = extView.ownerDocument.defaultView.getComputedStyle( extView, '' ).getPropertyCSSValue("list-style-image").cssText; if (lsi == "none") @@ -82,29 +82,32 @@ Bandwagon.Controller.ExtensionsOverlay.init = function() if (inArgs) { + /** OBSOLETE if (inArgs.subscribe) { Bandwagon.Logger.debug("Have window argument subscribe = " + inArgs.subscribe); setTimeout(function() { - Bandwagon.Controller.ExtensionsOverlay._showFeedsPaneView(); - Bandwagon.Controller.FeedsPane.doShowFeedPreview(inArgs.subscribe); + Bandwagon.Controller.ExtensionsOverlay._showCollectionsPaneView(); + Bandwagon.Controller.CollectionsPane.doShowCollectionPreview(inArgs.subscribe); }, 500); } - else if (inArgs.selectFeed) + else + */ + if (inArgs.selectCollection) { - Bandwagon.Logger.debug("Have window argument selectFeed = " + inArgs.selectFeed); + Bandwagon.Logger.debug("Have window argument selectCollection = " + inArgs.selectCollection); - if (bandwagonService.feeds[inArgs.selectFeed]) + if (bandwagonService.collections[inArgs.selectCollection]) { - Bandwagon.Controller.FeedsPane.preferredFeed = bandwagonService.feeds[inArgs.selectFeed]; + Bandwagon.Controller.CollectionsPane.preferredCollection = bandwagonService.collections[inArgs.selectCollection]; } setTimeout(function() { - Bandwagon.Controller.ExtensionsOverlay._showFeedsPaneView(); + Bandwagon.Controller.ExtensionsOverlay._showCollectionsPaneView(); }, 500); } @@ -112,22 +115,48 @@ Bandwagon.Controller.ExtensionsOverlay.init = function() } } -Bandwagon.Controller.ExtensionsOverlay.doPublishToFeed = function(feed) +Bandwagon.Controller.ExtensionsOverlay.doPublishToCollection = function(collection) { - Bandwagon.Logger.debug("In Bandwagon.Controller.ExtensionsOverlay.doPublishToFeed() with feed = '" + feed.url + "'"); + Bandwagon.Logger.debug("In Bandwagon.Controller.ExtensionsOverlay.doPublishToCollection() with collection = '" + collection.toString() + "'"); var extension = Bandwagon.Controller.ExtensionsOverlay._getSelectedExtension(); var params = { publishType: 1, - publishDestination: feed, + publishDestination: collection, publishExtension: extension }; Bandwagon.Controller.ExtensionsOverlay._openPublishDialog(params); } +Bandwagon.Controller.ExtensionsOverlay.doRemoveFromCollection = function(collection) +{ + var extension = Bandwagon.Controller.ExtensionsOverlay._getSelectedExtension(); + + Bandwagon.Logger.debug("In Bandwagon.Controller.ExtensionsOverlay.doRemoveFromCollection() with collection = '" + collection.toString() + "' and extension: name = '" + extension.name + "', guid = '" + extension.guid + "'"); + + 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("publish.remove.title"), + Bandwagon.Controller.ExtensionsOverlay.stringBundle.getFormattedString("publish.remove.label", [extension.name, collection.name]), + flags, + Bandwagon.Controller.ExtensionsOverlay.stringBundle.getString("publish.remove.button0"), + Bandwagon.Controller.ExtensionsOverlay.stringBundle.getString("publish.remove.button1"), + null, + null, + check); + + if (button == 0) + { + bandwagonService.removeAddonFromCollection(extension.guid, collection); + } +} + Bandwagon.Controller.ExtensionsOverlay.doShareToEmail = function(emailAddress) { Bandwagon.Logger.debug("In Bandwagon.Controller.ExtensionsOverlay.doShareToEmail() with email = '" + emailAddress + "'"); @@ -150,15 +179,15 @@ Bandwagon.Controller.ExtensionsOverlay._getSelectedExtension = function() if (document.getElementById("extensionsView").selectedItem) { - var selectedFeedItem = document.getElementById("extensionsView").selectedItem; - extension.guid = selectedFeedItem.getAttribute("addonID"); - extension.name = selectedFeedItem.getAttribute("name"); + var selectedAddon = document.getElementById("extensionsView").selectedItem; + extension.guid = selectedAddon.getAttribute("addonID"); + extension.name = selectedAddon.getAttribute("name"); } - else if (Bandwagon.Controller.FeedsPane && Bandwagon.Controller.FeedsPane.elemBandwagonFeedItems.selectedItem) + else if (Bandwagon.Controller.CollectionsPane && Bandwagon.Controller.CollectionsPane.elemBandwagonAddons && Bandwagon.Controller.CollectionsPane.elemBandwagonAddons.selectedItem) { - var selectedFeedItem = Bandwagon.Controller.FeedsPane.elemBandwagonFeedItems.selectedItem; - extension.guid = selectedFeedItem.guid; - extension.name = selectedFeedItem.name; + var selectedAddon = Bandwagon.Controller.CollectionsPane.elemBandwagonAddons.selectedItem; + extension.guid = selectedAddon.guid; + extension.name = selectedAddon.name; } else { @@ -168,6 +197,13 @@ Bandwagon.Controller.ExtensionsOverlay._getSelectedExtension = function() return extension; } +Bandwagon.Controller.ExtensionsOverlay.doNewCollection = function() +{ + Bandwagon.Logger.debug("In Bandwagon.Controller.ExtensionsOverlay.doNewCollection()"); + + Bandwagon.Controller.CollectionsPane._openLocalizedURL(Bandwagon.COLLECTIONSPANE_DO_NEW_COLLECTION_URL); +} + Bandwagon.Controller.ExtensionsOverlay.doAddNewShareEmail = function() { Bandwagon.Logger.debug("In Bandwagon.Controller.ExtensionsOverlay.doAddNewShareEmail()"); @@ -241,7 +277,7 @@ Bandwagon.Controller.ExtensionsOverlay._invalidatePublishButton = function() } Bandwagon.Controller.ExtensionsOverlay._publishButton.emailAddresses = Bandwagon.Controller.ExtensionsOverlay._getEmailAddresses(); - Bandwagon.Controller.ExtensionsOverlay._publishButton.writableFeeds = Bandwagon.Controller.ExtensionsOverlay._getWritableFeeds(); + Bandwagon.Controller.ExtensionsOverlay._publishButton.writableCollections = Bandwagon.Controller.ExtensionsOverlay._getWritableCollections(); try { @@ -250,21 +286,39 @@ Bandwagon.Controller.ExtensionsOverlay._invalidatePublishButton = function() catch (e) {} } -Bandwagon.Controller.ExtensionsOverlay._getWritableFeeds = function() +Bandwagon.Controller.ExtensionsOverlay._getWritableCollections = function() { - var writableFeeds = []; + var writableCollections = []; + + var extension = Bandwagon.Controller.ExtensionsOverlay._getSelectedExtension(); - for (var id in bandwagonService.feeds) + for (var id in bandwagonService.collections) { - if (1 || (bandwagonService.feeds[id].editable && !bandwagonService.feeds[id].preview)) + var collection = bandwagonService.collections[id]; + + //if (1 || (bandwagonService.collections[id].writable && !bandwagonService.collections[id].preview)) + + if (collection.writable) { - writableFeeds.push(bandwagonService.feeds[id]); + // Check if extension is in collection + collection.__containsCurrentlySelectedExtension = false; + + for (var id in collection.addons) + { + if (extension.guid == collection.addons[id].guid) + { + collection.__containsCurrentlySelectedExtension = true; + break; + } + } + + writableCollections.push(collection); } } - writableFeeds.sort(); + writableCollections.sort(); - return writableFeeds; + return writableCollections; } Bandwagon.Controller.ExtensionsOverlay._getEmailAddresses = function() @@ -276,12 +330,12 @@ Bandwagon.Controller.ExtensionsOverlay._getEmailAddresses = function() return previouslySharedEmailAddresses; } -Bandwagon.Controller.ExtensionsOverlay._showFeedsPaneView = function() +Bandwagon.Controller.ExtensionsOverlay._showCollectionsPaneView = function() { - Bandwagon.Logger.debug("in _showFeedsPaneView()"); + Bandwagon.Logger.debug("in _showCollectionsPaneView()"); - updateLastSelected("bandwagon-feeds"); - gView = "bandwagon-feeds"; + updateLastSelected("bandwagon-collections"); + gView = "bandwagon-collections"; document.getElementById("installFileButton").hidden = true; document.getElementById("checkUpdatesAllButton").hidden = true; @@ -301,12 +355,12 @@ Bandwagon.Controller.ExtensionsOverlay._showFeedsPaneView = function() AddonsViewBuilder.clearChildren(gExtensionsView); - document.getElementById("bandwagon-feeds-panel").hidden = false; + document.getElementById("bandwagon-collections-panel").hidden = false; updateGlobalCommands(); - Bandwagon.Controller.FeedsPane.init(); - Bandwagon.Controller.FeedsPane.onViewSelect(); + Bandwagon.Controller.CollectionsPane.init(); + Bandwagon.Controller.CollectionsPane.onViewSelect(); } // magic @@ -315,13 +369,13 @@ Bandwagon.Controller.ExtensionsOverlay._defaultShowView = showView; Bandwagon.Controller.ExtensionsOverlay._showView = function(aView) { - if (aView == "bandwagon-feeds") + if (aView == "bandwagon-collections") { - Bandwagon.Controller.ExtensionsOverlay._showFeedsPaneView(); + Bandwagon.Controller.ExtensionsOverlay._showCollectionsPaneView(); } else { - document.getElementById("bandwagon-feeds-panel").hidden = true; + document.getElementById("bandwagon-collections-panel").hidden = true; document.getElementById("extensionsView").hidden = false; document.getElementById("extensionsView").parentNode.hidden = false; |