changeset 369:6ede77153361

Automated merge with http://hg.mozdev.org/snowl/
author Myk Melez <myk@mozilla.org>
date Fri, 07 Nov 2008 14:06:36 -0800
parents d2636b3cd8e2 (current diff) 69f55e6480f3 (diff)
children 44df99064ae5
files
diffstat 4 files changed, 97 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/content/river.css	Thu Nov 06 12:22:28 2008 -0700
+++ b/content/river.css	Fri Nov 07 14:06:36 2008 -0800
@@ -98,14 +98,45 @@
   color: #555;
 }
 
-h2 {
-  font-size: larger;
-  margin-bottom: 0;
+.message {
+  clear: both;
+}
+
+.messageIcon {
+  max-width: 100px !important;
+  max-height: 100px !important;
+  float: right;
 }
 
 .byline {
   font-size: smaller;
   font-family: sans-serif;
+  color: grey;
+}
+
+.title {
+  font-size: 100%;
+  margin-bottom: 0.5em;
+  margin-top: 0;
+}
+
+#contentBox div.body {
+  display: none;
+}
+
+#contentBox.body div.body {
+  display: block;
+}
+
+#contentBox.body .messageIcon {
+  display: none;
+}
+
+/* Suppress the top margin on the initial content element so we can control
+ * the amount of margin between the subject and the content with the rule
+ * above on the subject element. */
+div.body > *:first-child {
+  margin-top: 0;
 }
 
 .metadata {
--- a/content/river.js	Thu Nov 06 12:22:28 2008 -0700
+++ b/content/river.js	Fri Nov 07 14:06:36 2008 -0800
@@ -389,7 +389,14 @@
   },
 
   onCommandBodyButton: function(aEvent) {
-    this.rebuildView();
+    let contentBox = document.getElementById("contentBox");
+    if (this._bodyButton.checked) {
+      let classes = contentBox.className.split(/\s/);
+      classes.push("body");
+      contentBox.className = classes.join(" ");
+    }
+    else
+      contentBox.className = contentBox.className.split(/\s/).filter(function(v) v != "body").join(" ");
     this._updateURI();
   },
 
@@ -748,20 +755,23 @@
       messageBox.className = "message";
       messageBox.setAttribute("index", i);
 
-      // Title
-      let title = this._document.createElementNS(HTML_NS, "h2");
-      title.className = "title";
-      let titleLink = this._document.createElementNS(HTML_NS, "a");
-      titleLink.appendChild(this._document.createTextNode(message.subject || "untitled"));
-      if (message.link)
-        this._unsafeSetURIAttribute(titleLink, "href", message.link);
-      title.appendChild(titleLink);
-      messageBox.appendChild(title);
+      // These are the elements that will be appended to the message box.
+      let messageIcon, bylineBox, title, body;
+
+      messageIcon = document.createElementNS(HTML_NS, "img");
 
       // Byline
-      let bylineBox = this._document.createElementNS(HTML_NS, "div");
+      bylineBox = this._document.createElementNS(HTML_NS, "div");
       bylineBox.className = "byline";
-      messageBox.appendChild(bylineBox);
+
+      // Author and/or Source
+      if (message.author)
+        bylineBox.appendChild(this._document.createTextNode(message.author));
+      if (message.source) {
+        if (message.author)
+          bylineBox.appendChild(this._document.createTextNode(" - "));
+        bylineBox.appendChild(this._document.createTextNode(message.source.name));
+      }
 
       // Source
       //let source = this._document.createElementNS(HTML_NS, "a");
@@ -775,11 +785,37 @@
       //  this._unsafeSetURIAttribute(source, "href", message.source.humanURI.spec);
       //bylineBox.appendChild(source);
 
-      // Author or Source
-      if (message.author)
-        bylineBox.appendChild(this._document.createTextNode(message.author));
-      else if (message.source)
-        bylineBox.appendChild(this._document.createTextNode(message.source.name));
+      // Title
+      title = this._document.createElementNS(HTML_NS, "h2");
+      title.className = "title";
+      let titleLink = this._document.createElementNS(HTML_NS, "a");
+      titleLink.appendChild(this._document.createTextNode(message.subject || "untitled"));
+      if (message.link)
+        this._unsafeSetURIAttribute(titleLink, "href", message.link);
+      title.appendChild(titleLink);
+
+      // Body
+      let bodyText = message.content || message.summary;
+      if (bodyText) {
+        body = this._document.createElementNS(HTML_NS, "div");
+        body.className = "body";
+        if (bodyText.base)
+          body.setAttributeNS(XML_NS, "base", bodyText.base.spec);
+
+        let docFragment = bodyText.createDocumentFragment(body);
+        if (docFragment) {
+          body.appendChild(docFragment);
+          // If the message contains an image, use it to create an icon
+          // representing the image.
+          let firstImage = body.getElementsByTagName("img")[0];
+          if (firstImage) {
+            messageIcon = firstImage.cloneNode(false);
+            messageIcon.removeAttribute("width");
+            messageIcon.removeAttribute("height");
+            messageIcon.className = "messageIcon";
+          }
+        }
+      }
 
       //// Timestamp
       //let lastUpdated = SnowlDateUtils._formatDate(message.timestamp);
@@ -792,24 +828,12 @@
       //  bylineBox.appendChild(timestamp);
       //}
 
-      // Body
-      if (this._bodyButton.checked) {
-        let bodyText = message.content || message.summary;
-        if (bodyText) {
-          let body = this._document.createElementNS(HTML_NS, "div");
-          body.className = "body";
-          messageBox.appendChild(body);
+      // FIXME: implement support for enclosures.
 
-          if (bodyText.base)
-            body.setAttributeNS(XML_NS, "base", bodyText.base.spec);
-
-          let docFragment = bodyText.createDocumentFragment(body);
-          if (docFragment)
-            body.appendChild(docFragment);
-        }
-      }
-
-      // FIXME: implement support for enclosures.
+      messageBox.appendChild(messageIcon);
+      messageBox.appendChild(bylineBox);
+      messageBox.appendChild(title);
+      messageBox.appendChild(body);
 
       this._contentSandbox.messageBox = messageBox;
 
--- a/content/river.xul	Thu Nov 06 12:22:28 2008 -0700
+++ b/content/river.xul	Fri Nov 07 14:06:36 2008 -0800
@@ -68,6 +68,8 @@
 
     <vbox flex="1">
       <toolbar id="toolbar">
+        <!-- <toolbarbutton oncommand="dump(new XMLSerializer().serializeToString(document))"/> -->
+
         <toolbarbutton id="currentButton" type="checkbox"
                     image="chrome://snowl/content/icons/newspaper.png"
                     oncommand="SnowlMessageView.onCommandCurrentButton(event)"
--- a/content/riverContent.css	Thu Nov 06 12:22:28 2008 -0700
+++ b/content/riverContent.css	Fri Nov 07 14:06:36 2008 -0800
@@ -50,6 +50,9 @@
 }
 
 /* FIXME: figure out why this doesn't resize images proportionally. */
+/* SOLUTION: it's because the images still have "width" and/or "height"
+ * attributes.  Remove those attributes, and this rule (plus the one above)
+ * will work proportionally. */
 #contentBox img {
   max-height: 0;
 }