Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/bandwagon/content/ui/publishController.js
diff options
context:
space:
mode:
Diffstat (limited to 'bandwagon/content/ui/publishController.js')
-rw-r--r--bandwagon/content/ui/publishController.js68
1 files changed, 53 insertions, 15 deletions
diff --git a/bandwagon/content/ui/publishController.js b/bandwagon/content/ui/publishController.js
index 492d5dc..1ff0d27 100644
--- a/bandwagon/content/ui/publishController.js
+++ b/bandwagon/content/ui/publishController.js
@@ -19,6 +19,7 @@
* the Initial Developer. All Rights Reserved.
*
* 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
@@ -38,13 +39,14 @@ Bandwagon.Controller.Publish = new function()
{
this.stringBundle = null;
this.hasSubmitted = false;
+ this.hasSubmittedWithSuccess = false;
this.publishType = -1; // one of the TYPE_ constants
- this.publishDestination = null; // email address or feed obj
+ this.publishDestination = null; // email address or collection obj
this.publishExtension = null; // the add-on / theme obj to publish
}
-Bandwagon.Controller.Publish.TYPE_FEED = 1;
+Bandwagon.Controller.Publish.TYPE_COLLECTION = 1;
Bandwagon.Controller.Publish.TYPE_EXISTING_EMAIL = 2;
Bandwagon.Controller.Publish.TYPE_NEW_EMAIL = 3;
@@ -62,27 +64,33 @@ Bandwagon.Controller.Publish.init = function()
Bandwagon.Controller.Publish.publishDestination = inArgs.publishDestination;
Bandwagon.Controller.Publish.publishExtension = inArgs.publishExtension;
- document.getElementById("dialog-desc").value = Bandwagon.Controller.Publish.stringBundle.getFormattedString("you.are.sharing.the.add.on", [Bandwagon.Controller.Publish.publishExtension.name]);
+ //document.getElementById("dialog-desc").value = Bandwagon.Controller.Publish.stringBundle.getFormattedString("you.are.sharing.the.add.on", [Bandwagon.Controller.Publish.publishExtension.name]);
document.getElementById("type-deck").selectedIndex = Bandwagon.Controller.Publish.publishType-1;
switch (Bandwagon.Controller.Publish.publishType)
{
- case Bandwagon.Controller.Publish.TYPE_FEED:
- document.getElementById("publishing-to").value = Bandwagon.Controller.Publish.stringBundle.getFormattedString("publishing.to", [(Bandwagon.Controller.Publish.publishDestination.name?Bandwagon.Controller.Publish.publishDestination.name:Bandwagon.Controller.Publish.publishDestination.url)]);
+ case Bandwagon.Controller.Publish.TYPE_COLLECTION:
+ document.getElementById("publishing-to").value = Bandwagon.Controller.Publish.stringBundle.getFormattedString("publishing.to", [Bandwagon.Controller.Publish.publishExtension.name, (Bandwagon.Controller.Publish.publishDestination.name?Bandwagon.Controller.Publish.publishDestination.name:Bandwagon.Controller.Publish.publishDestination.url)]);
document.getElementById("new-email-box").collapsed = true;
document.getElementById("sharing-with-box").collapsed = true;
document.getElementById("publishing-to-box").collapsed = false;
+ document.getElementById("sharing-with-new").collapsed = true;
break;
case Bandwagon.Controller.Publish.TYPE_EXISTING_EMAIL:
- document.getElementById("sharing-with").value = Bandwagon.Controller.Publish.stringBundle.getFormattedString("sharing.with", [Bandwagon.Controller.Publish.publishDestination]);
+ document.getElementById("sharing-with").textContent = Bandwagon.Controller.Publish.stringBundle.getFormattedString("sharing.with", [Bandwagon.Controller.Publish.publishDestination, Bandwagon.Controller.Publish.publishExtension.name]);
document.getElementById("new-email-box").collapsed = true;
document.getElementById("sharing-with-box").collapsed = false;
document.getElementById("publishing-to-box").collapsed = true;
+ document.getElementById("sharing-with-new").collapsed = true;
+ document.getElementById("bandwagon-publish").getButton("accept").label = Bandwagon.Controller.Publish.stringBundle.getString("send.email");
break;
case Bandwagon.Controller.Publish.TYPE_NEW_EMAIL:
+ document.getElementById("sharing-with-new").textContent = Bandwagon.Controller.Publish.stringBundle.getFormattedString("sharing.with.new", [Bandwagon.Controller.Publish.publishExtension.name]);
+ document.getElementById("sharing-with-new").collapsed = false;
document.getElementById("new-email-box").collapsed = false;
document.getElementById("sharing-with-box").collapsed = true;
document.getElementById("publishing-to-box").collapsed = true;
+ document.getElementById("bandwagon-publish").getButton("accept").label = Bandwagon.Controller.Publish.stringBundle.getString("send.email");
break;
}
@@ -93,6 +101,12 @@ Bandwagon.Controller.Publish.doAccept = function()
{
Bandwagon.Logger.debug("In Bandwagon.Controller.Publish.doAccept();");
+ if (Bandwagon.Controller.Publish.hasSubmittedWithSuccess)
+ {
+ document.getElementById("bandwagon-publish").cancelDialog();
+ return true;
+ }
+
if (Bandwagon.Controller.Publish.publishType == Bandwagon.Controller.Publish.TYPE_NEW_EMAIL && document.getElementById("email-address").value == "")
{
Bandwagon.Controller.Publish._showError(Bandwagon.Controller.Publish.stringBundle.getString("please.enter.an.email.address"));
@@ -104,8 +118,8 @@ Bandwagon.Controller.Publish.doAccept = function()
switch (Bandwagon.Controller.Publish.publishType)
{
- case Bandwagon.Controller.Publish.TYPE_FEED:
- Bandwagon.Controller.Publish._publishToFeed();
+ case Bandwagon.Controller.Publish.TYPE_COLLECTION:
+ Bandwagon.Controller.Publish._publishToCollection();
break;
case Bandwagon.Controller.Publish.TYPE_EXISTING_EMAIL:
Bandwagon.Controller.Publish._shareToExistingEmail();
@@ -123,9 +137,9 @@ Bandwagon.Controller.Publish.doCancel = function()
return true;
}
-Bandwagon.Controller.Publish._publishToFeed = function()
+Bandwagon.Controller.Publish._publishToCollection = function()
{
- bandwagonService.publishToFeed(
+ bandwagonService.publishToCollection(
Bandwagon.Controller.Publish.publishExtension,
Bandwagon.Controller.Publish.publishDestination,
document.getElementById("personal-note").value,
@@ -164,22 +178,46 @@ Bandwagon.Controller.Publish.invalidate = function()
Bandwagon.Controller.Publish.finished = function(event)
{
- Bandwagon.Controller.Publish.hasSubmitted = false;
- Bandwagon.Controller.Publish.invalidate();
-
if (event.isError())
{
+ Bandwagon.Controller.Publish.hasSubmitted = false;
+ Bandwagon.Controller.Publish.invalidate();
+
Bandwagon.Controller.Publish._showError(event.getError());
+
return;
}
+ Bandwagon.Controller.Publish.hasSubmittedWithSuccess = true;
+
if (Bandwagon.Controller.Publish.publishType == Bandwagon.Controller.Publish.TYPE_NEW_EMAIL
&& document.getElementById("remember-email").checked)
{
- bandwagonService.addPreviouslySharedEmailAddress(document.getElementById("email-address").value);
+ bandwagonService.addPreviouslySharedEmailAddresses(document.getElementById("email-address").value);
}
- document.getElementById("bandwagon-publish").cancelDialog();
+ if (Bandwagon.Controller.Publish.publishType == Bandwagon.Controller.Publish.TYPE_COLLECTION)
+ {
+ bandwagonService.forceCheckForUpdates(Bandwagon.Controller.Publish.publishDestination);
+
+ document.getElementById("error").value = Bandwagon.Controller.Publish.stringBundle.getString("the.addon.has.been.published");
+ }
+ else
+ {
+ document.getElementById("error").value = Bandwagon.Controller.Publish.stringBundle.getString("the.email.has.been.sent");
+ }
+
+ document.getElementById("error").style.visibility = "visible";
+ document.getElementById("error").style.color = 'green';
+ document.getElementById("spinner").collapsed = true;
+ document.getElementById("email-address").disabled = true;
+ document.getElementById("personal-note").disabled = true;
+ document.getElementById("bandwagon-publish").getButton("cancel").hidden = true;
+ document.getElementById("bandwagon-publish").getButton("accept").disabled = false;
+ document.getElementById("bandwagon-publish").getButton("accept").label = Bandwagon.Controller.Publish.stringBundle.getFormattedString("closing.in", ["2"]);
+
+ setTimeout(function() { document.getElementById("bandwagon-publish").getButton("accept").label = Bandwagon.Controller.Publish.stringBundle.getFormattedString("closing.in", ["1"]); }, 2000);
+ setTimeout(function() { document.getElementById("bandwagon-publish").cancelDialog(); }, 3000);
}
Bandwagon.Controller.Publish._showError = function(message)