changeset 68:abae5a36eb6d

make filtering work, and save both filters and the unread flag to the URI
author Myk Melez <myk@mozilla.org>
date Tue, 13 May 2008 11:09:16 -0700
parents d4a7ff1fd61e
children e6c3b67e38ff
files extension/content/river.css extension/content/river.js extension/content/river.xhtml
diffstat 3 files changed, 66 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/extension/content/river.css	Mon May 12 23:55:12 2008 -0700
+++ b/extension/content/river.css	Tue May 13 11:09:16 2008 -0700
@@ -21,4 +21,13 @@
 
 h3 {
   margin-top: 0;
-}
\ No newline at end of file
+}
+
+html { 
+  background-color: white;
+  color: black;
+}
+
+label {
+  -moz-margin-start: 0;
+}
--- a/extension/content/river.js	Mon May 12 23:55:12 2008 -0700
+++ b/extension/content/river.js	Tue May 13 11:09:16 2008 -0700
@@ -64,6 +64,7 @@
 }
 
 const XML_NS = "http://www.w3.org/XML/1998/namespace"
+const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 const HTML_NS = "http://www.w3.org/1999/xhtml";
 const URI_BUNDLE = "chrome://browser/locale/feeds/subscribe.properties";
 
@@ -99,6 +100,24 @@
   _collection: null,
   
   init: function SH_init() {
+    // Explicitly wrap |window| in an XPCNativeWrapper to make sure
+    // it's a real native object! This will throw an exception if we
+    // get a non-native object.
+    this._window = new XPCNativeWrapper(window);
+    this._document = this._window.document;
+
+    this._collection = new SnowlCollection(null, null, true);
+
+    this._updateToolbar();
+
+    this.writeContent();
+  },
+
+  uninit: function SH_uninit() {
+    this.close();
+  },
+
+  _updateToolbar: function() {
     this._params = {};
     let query = window.location.search.substr(1);
     for each (let param in query.split("&")) {
@@ -112,23 +131,14 @@
       this._params[name] = value;
     }
 
-    this._collection = new SnowlCollection(null, null, true);
     if ("unread" in this._params) {
       this._collection.read = false;
       document.getElementById("unreadButton").checked = true;
     }
-
-    // Explicitly wrap |window| in an XPCNativeWrapper to make sure
-    // it's a real native object! This will throw an exception if we
-    // get a non-native object.
-    this._window = new XPCNativeWrapper(window);
-    this._document = this._window.document;
-
-    this.writeContent();
-  },
-
-  uninit: function SH_uninit() {
-    this.close();
+    if ("filter" in this._params) {
+      this._collection.filter = this._params.filter;
+      document.getElementById("filterTextbox").value = this._params.filter;
+    }
   },
 
   onCommandUnreadButton: function(aEvent, aButton) {
@@ -145,9 +155,29 @@
       this.rebuildView();
     }
 
-    let query = aButton.checked ? "?unread" : "";
+    this._updateURI();
+  },
+
+  onCommandFilterTextbox: function(aEvent, aFilterTextbox) {
+    this._collection.filter = aFilterTextbox.value;
+    this.rebuildView();
+    this._updateURI();
+  },
+
+  _updateURI: function() {
+    let params = [];
+
+    if (typeof this._collection.read != "undefined" && !this._collection.read)
+      params.push("unread");
+
+    if (this._collection.filter)
+      params.push("filter=" + encodeURIComponent(this._collection.filter));
+
+    let query = params.length > 0 ? "?" + params.join("&") : "";
     let spec = "chrome://snowl/content/river.xhtml" + query;
-    let uri = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService).newURI(spec, null, null);
+    let uri = Cc["@mozilla.org/network/io-service;1"].
+              getService(Ci.nsIIOService).
+              newURI(spec, null, null);
 
     let gBrowserWindow = window.QueryInterface(Ci.nsIInterfaceRequestor).
                          getInterface(Ci.nsIWebNavigation).
@@ -157,8 +187,11 @@
                          getInterface(Ci.nsIDOMWindow);
 
     gBrowserWindow.gBrowser.docShell.setCurrentURI(uri);
+
+    // FIXME: figure out how to make reload reload the new URI instead of
+    // the original one.
   },
-  
+
   onScroll: function(aEvent) {
     // The "current message" is the topmost one whose header appears on the page
     // 
@@ -376,8 +409,10 @@
         sourceBox.className = "source";
 
         if (entry.author) {
-          let author = this._document.createElementNS(HTML_NS, "div");
-          author.appendChild(this._document.createTextNode(entry.author));
+          let author = this._document.createElementNS(XUL_NS, "label");
+          author.setAttribute("crop", "end");
+          author.setAttribute("value", entry.author);
+          //author.appendChild(this._document.createTextNode(entry.author));
           sourceBox.appendChild(author);
         }
 
--- a/extension/content/river.xhtml	Mon May 12 23:55:12 2008 -0700
+++ b/extension/content/river.xhtml	Tue May 13 11:09:16 2008 -0700
@@ -29,19 +29,11 @@
     <xul:hbox id="toolbar" align="center">
       <xul:button id="unreadButton" type="checkbox" label="Unread"
                   oncommand="RiverView.onCommandUnreadButton(event, this)"/>
-      <input/>
+      <xul:textbox id="filterTextbox" type="timed" timeout="200"
+                   oncommand="RiverView.onCommandFilterTextbox(event, this)"/>
     </xul:hbox>
 
-    <div id="feedBody">
-      <div id="feedTitle">
-        <a id="feedTitleLink">
-          <img id="feedTitleImage"/>
-        </a>
-        <div id="feedTitleContainer">
-          <h1 id="feedTitleText"/>
-          <h2 id="feedSubtitleText"/>
-        </div>
-      </div>
+    <div>
       <div id="feedContent"/>
     </div>
   </body>