diff --git a/chrome.manifest b/chrome.manifest
index f22dad7..d2b5e52 100644
--- a/chrome.manifest
+++ b/chrome.manifest
@@ -19,6 +19,10 @@ style chrome://global/content/customizeToolbar.xul chrome://snowl/content/browse
# on exact matches of the entire URL.
overlay chrome://snowl/content/list-sidebar.xul chrome://snowl/content/collections.xul
+# Add the interface for writing messages to the stream and river views.
+overlay chrome://snowl/content/stream.xul chrome://snowl/content/write.xul
+overlay chrome://snowl/content/river.xul chrome://snowl/content/write.xul
+
# Add the toolbar to the collections and stream views.
# XXX Should we add the toolbar directly to the list and river views
# rather than indirectly via the collections view?
diff --git a/content/stream.js b/content/stream.js
index 7c1ba8e..f7efa04 100644
--- a/content/stream.js
+++ b/content/stream.js
@@ -85,34 +85,14 @@ let SnowlMessageView = {
getService(Ci.nsIFaviconService);
},
- get _stringBundle() {
- delete this._stringBundle;
- return this._stringBundle = document.getElementById("snowlStringBundle");
+ get _writeButton() {
+ delete this._writeButton;
+ return this._writeButton = document.getElementById("snowlWriteButton");
},
- get _writeMessageButton() {
- delete this._writeMessageButton;
- return this._writeMessageButton = document.getElementById("snowlWriteMessageButton");
- },
-
- get _writeBox() {
- delete this._writeBox;
- return this._writeBox = document.getElementById("writeBox");
- },
-
- get _writeTextbox() {
- delete this._writeTextbox;
- return this._writeTextbox = document.getElementById("writeTextbox");
- },
-
- get _writeCounter() {
- delete this._writeCounter;
- return this._writeCounter = document.getElementById("writeCounter");
- },
-
- get _sendButton() {
- delete this._sendButton;
- return this._sendButton = document.getElementById("sendButton");
+ get _writeForm() {
+ delete this._writeForm;
+ return this._writeForm = document.getElementById("writeForm");
},
_window: null,
@@ -194,10 +174,10 @@ let SnowlMessageView = {
gBrowserWindow.Snowl._initSnowlToolbar();
// For some reason setting hidden="true" in the XUL file prevents us
- // from showing the box later via writeBox.hidden = false, so we set it
+ // from showing the box later via writeForm.hidden = false, so we set it
// here instead.
// FIXME: file a bug on this abnormality.
- this._writeBox.hidden = true;
+ this._writeForm.hidden = true;
this._updateWriteButton();
},
@@ -214,10 +194,10 @@ let SnowlMessageView = {
window.setTimeout(function() { SnowlMessageView.onMidnight() }, msUntilMidnight);
},
- // Selectively show/hide the button for writing a message depending on
+ // Selectively enable/disable the button for writing a message depending on
// whether or not the user has an account that supports writing.
_updateWriteButton: function() {
- this._writeMessageButton.disabled = (SnowlService.targets.length == 0);
+ this._writeButton.disabled = (SnowlService.targets.length == 0);
},
@@ -282,53 +262,20 @@ let SnowlMessageView = {
//**************************************************************************//
// Writing and Sending Messages
- // FIXME: if there is more than one target, let the user choose which one to use.
- _target: null,
-
- onWriteMessage: function(event) {
- this._writeBox.hidden = !event.target.checked;
- this._target = SnowlService.targets[0];
- this.onInputMessage();
- },
-
- onInputMessage: function() {
- // Update the counter to reflect how many characters the user can still type.
- this._writeCounter.value =
- this._target.maxMessageLength - this._writeTextbox.value.length;
-
- // If the user has typed more than they can send, disable the Send button.
- this._sendButton.disabled =
- (this._writeTextbox.value.length > this._target.maxMessageLength);
- },
-
- onSendMessage: function() {
- this._sendButton.setAttribute("state", "sending");
- this._sendButton.label = this._stringBundle.getString("sendButton.label.sending");
- this._sendButton.disabled = true;
- this._writeTextbox.disabled = true;
-
- let content = this._writeTextbox.value;
- let callback = function() { SnowlMessageView.onMessageSent() };
- // FIXME: pass an error callback and display a message to users on error.
- this._target.send(content, callback);
+ onToggleWrite: function(event) {
+ if (event.target.checked) {
+ this._writeForm.hidden = false;
+ // FIXME: only do this when the user first starts to write a message,
+ // not every time they show the write form.
+ WriteForm.init();
+ }
+ else
+ this._writeForm.hidden = true;
},
onMessageSent: function() {
- this._sendButton.setAttribute("state", "sent");
- this._sendButton.label = this._stringBundle.getString("sendButton.label.sent");
-
- window.setTimeout(function() { SnowlMessageView._resetWriteForm() }, 5000);
- },
-
- _resetWriteForm: function() {
- this._writeBox.hidden = true;
- this._writeMessageButton.checked = false;
- this._sendButton.removeAttribute("state");
- this._sendButton.label = this._stringBundle.getString("sendButton.label");
- this._sendButton.disabled = false;
- this._writeTextbox.disabled = false;
- this._writeTextbox.value = "";
- this._target = null;
+ this._writeButton.checked = false;
+ this._writeForm.hidden = true;
},
diff --git a/content/stream.xul b/content/stream.xul
index a16290e..3d4a40a 100644
--- a/content/stream.xul
+++ b/content/stream.xul
@@ -53,20 +53,11 @@
-
-
-
+
-
-
-
-
-
-
-
-
+
diff --git a/content/toolbar.js b/content/toolbar.js
index 3336123..a17e78d 100644
--- a/content/toolbar.js
+++ b/content/toolbar.js
@@ -59,7 +59,7 @@ let SnowlToolbar = {
SnowlOPML.export(window);
},
- onWriteMessage: function(event) {
- SnowlMessageView.onWriteMessage(event);
+ onToggleWrite: function(event) {
+ SnowlMessageView.onToggleWrite(event);
}
};
diff --git a/content/toolbar.xul b/content/toolbar.xul
index 5157aca..2d8323f 100644
--- a/content/toolbar.xul
+++ b/content/toolbar.xul
@@ -62,10 +62,10 @@
oncommand="SnowlToolbar.onExportOPML()"
tooltiptext="&exportButton.tooltip;"/>
-
+ oncommand="SnowlToolbar.onToggleWrite(event)"
+ tooltiptext="&writeButton.tooltip;"/>
diff --git a/content/write.js b/content/write.js
new file mode 100644
index 0000000..a1fc8e0
--- /dev/null
+++ b/content/write.js
@@ -0,0 +1,126 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Snowl.
+ *
+ * The Initial Developer of the Original Code is Mozilla.
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Myk Melez
+ *
+ * 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
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+// Since we're an overlay, we assume the main XUL document has defined these.
+//const Cc = Components.classes;
+//const Ci = Components.interfaces;
+//const Cr = Components.results;
+//const Cu = Components.utils;
+
+// modules that come with Firefox
+
+// modules that are generic
+
+// modules that are Snowl-specific
+Cu.import("resource://snowl/modules/service.js");
+
+/**
+ * The controller for the write message form.
+ */
+let WriteForm = {
+ get _writeTextbox() {
+ delete this._writeTextbox;
+ return this._writeTextbox = document.getElementById("writeTextbox");
+ },
+
+ get _writeCounter() {
+ delete this._writeCounter;
+ return this._writeCounter = document.getElementById("writeCounter");
+ },
+
+ get _sendButton() {
+ delete this._sendButton;
+ return this._sendButton = document.getElementById("sendButton");
+ },
+
+ get _stringBundle() {
+dump('document.getElementById("snowlWriteBundle"): ' + document.getElementById("snowlWriteBundle") + "\n");
+ delete this._stringBundle;
+ return this._stringBundle = document.getElementById("snowlWriteBundle");
+ },
+
+ // FIXME: if there is more than one target, let the user choose which one to use.
+ _target: null,
+
+ init: function() {
+ this._target = SnowlService.targets[0];
+
+ // Set the initial state of the length counter and send button.
+ this.onInputMessage();
+ },
+
+ onInputMessage: function() {
+ // Update the counter to reflect how many characters the user can still type.
+ this._writeCounter.value =
+ this._target.maxMessageLength - this._writeTextbox.value.length;
+
+ // If the user has typed more than they can send, disable the Send button.
+ this._sendButton.disabled =
+ (this._writeTextbox.value.length > this._target.maxMessageLength);
+ },
+
+ onSendMessage: function() {
+ this._sendButton.setAttribute("state", "sending");
+ this._sendButton.label = this._stringBundle.getString("sendButton.label.sending");
+ this._sendButton.disabled = true;
+ this._writeTextbox.disabled = true;
+
+ let content = this._writeTextbox.value;
+ let callback = function() { WriteForm.onMessageSent() };
+ // FIXME: pass an error callback and display a message to users on error.
+ this._target.send(content, callback);
+ },
+
+ onMessageSent: function() {
+ this._sendButton.setAttribute("state", "sent");
+ this._sendButton.label = this._stringBundle.getString("sendButton.label.sent");
+
+ window.setTimeout(function() { WriteForm.reset() }, 5000);
+ },
+
+ reset: function() {
+ this._sendButton.removeAttribute("state");
+ this._sendButton.label = this._stringBundle.getString("sendButton.label");
+ this._sendButton.disabled = false;
+ this._writeTextbox.disabled = false;
+ this._writeTextbox.value = "";
+ this._target = null;
+
+ // Let the view know the message was sent so it can do any necessary cleanup.
+ SnowlMessageView.onMessageSent();
+ }
+
+};
diff --git a/content/write.xul b/content/write.xul
new file mode 100644
index 0000000..5e872b8
--- /dev/null
+++ b/content/write.xul
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/locale/en-US/stream.dtd b/locale/en-US/stream.dtd
index 1de4003..32b57d0 100644
--- a/locale/en-US/stream.dtd
+++ b/locale/en-US/stream.dtd
@@ -1,2 +1 @@
-
diff --git a/locale/en-US/toolbar.dtd b/locale/en-US/toolbar.dtd
index ccbbdd7..4bb94d6 100644
--- a/locale/en-US/toolbar.dtd
+++ b/locale/en-US/toolbar.dtd
@@ -2,4 +2,4 @@
-
+
diff --git a/locale/en-US/write.dtd b/locale/en-US/write.dtd
new file mode 100644
index 0000000..35d3db6
--- /dev/null
+++ b/locale/en-US/write.dtd
@@ -0,0 +1 @@
+
diff --git a/locale/en-US/stream.properties b/locale/en-US/write.properties
similarity index 100%
rename from locale/en-US/stream.properties
rename to locale/en-US/write.properties