show more hits gloda-facet
authorDavid Ascher <david@mozillamessaging.com>
Tue, 08 Sep 2009 23:19:49 -0700
branchgloda-facet
changeset 3717 03a6d5fd16f10d1c184355bbe2c61f70356b2cfd
parent 3712 d9ad1f4f89510a5bc894cdffbe3d6fac711f316c
child 3718 0abb2352aa0c200d95bff9eab65be2b407a5af46
push idunknown
push userunknown
push dateunknown
show more hits
mail/base/content/glodaFacetBindings.xml
mail/base/content/glodaFacetView.css
mail/base/content/glodaFacetView.js
mail/base/content/glodaFacetView.xhtml
mail/locales/en-US/chrome/messenger/glodaFacetView.dtd
--- a/mail/base/content/glodaFacetBindings.xml
+++ b/mail/base/content/glodaFacetBindings.xml
@@ -1107,16 +1107,26 @@
           msgNode.setAttribute("class", "message");
           messagesNode.appendChild(msgNode);
         }
       } catch (e) {
         logException(e);
       }
       ]]></body>
     </method>
+    <method name="ensureNodeVisible">
+      <parameter name="messageIndex"/>
+      <body><![CDATA[
+        let messagesNode = document.getAnonymousElementByAttribute(
+                             this, "anonid", "messages");
+        let message = messagesNode.childNodes[messageIndex];
+        window.scrollTo(0, $(message).position()['top']);
+      ]]></body>
+    </method>
+      
     <method name="updateSortLabels">
       <body><![CDATA[
       try {
         let sortBy = FacetContext.sortBy;
         let sortRelevanceNode = document.getAnonymousElementByAttribute(
                           this, "anonid", "sort-relevance");
         let sortDateNode = document.getAnonymousElementByAttribute(
                           this, "anonid", "sort-date");
--- a/mail/base/content/glodaFacetView.css
+++ b/mail/base/content/glodaFacetView.css
@@ -573,8 +573,22 @@ h3 {
   -moz-border-radius: 2px;
   padding: 1px 3px;
   margin-right: 3px;
 }
 .message-folder {
   background-color: #faf0b8;
   border: 1px solid #ede4af;
 }
+
+.show-more {
+  font-size: small;
+  text-align: right;
+  margin-right: 1em;
+  margin-bottom: 2em;
+  color: #3465a4;
+  font-weight: bold;
+}
+
+.show-more:hover {
+  text-decoration: underline;
+  cursor: pointer;
+}
\ No newline at end of file
--- a/mail/base/content/glodaFacetView.js
+++ b/mail/base/content/glodaFacetView.js
@@ -488,33 +488,49 @@ var FacetContext = {
         else {
           faceter.xblNode.orderedGroups = faceter.orderedGroups;
           faceter.xblNode.build(false);
           $(faceter.xblNode).show();
         }
       }
     }
 
-    let results = document.getElementById("results");
-    let numMessageToShow = Math.min(this.maxMessagesToShow,
-                                    this._activeSet.length);
-    results.setMessages(this._activeSet.slice(0, numMessageToShow));
+    this.showMore();
 
     if (this._callbackOnFacetComplete) {
       let callback = this._callbackOnFacetComplete;
       this._callbackOnFacetComplete = null;
       callback();
     }
   },
 
+  showMore: function() {
+    this._numPages += 1;
+    let results = document.getElementById("results");
+    let numMessageToShow = Math.min(this.maxMessagesToShow * this._numPages,
+                                    this._activeSet.length);
+    results.setMessages(this._activeSet.slice(0, numMessageToShow));
+
+    let showMore = document.getElementById("showMore");
+
+    if (this._activeSet.length > numMessageToShow)
+      $(showMore).show();
+    else
+      $(showMore).hide();
+
+    if (this._numPages > 1)
+      results.ensureNodeVisible((this._numPages-1) * this.maxMessagesToShow);
+  },
+
   /** For use in hovering specific results. */
   fakeResultFaceter: {},
   /** For use in hovering specific results. */
   fakeResultAttr: {},
 
+  _numPages: 0,
   _HOVER_STABILITY_DURATION_MS: 100,
   _brushedFacet: null,
   _brushedGroup: null,
   _brushedItems: null,
   _brushTimeout: null,
   hoverFacet: function(aFaceter, aAttrDef, aGroupValue, aGroupItems) {
     // bail if we are already brushing this item
     if (this._brushedFacet == aFaceter && this._brushedGroup == aGroupValue)
--- a/mail/base/content/glodaFacetView.xhtml
+++ b/mail/base/content/glodaFacetView.xhtml
@@ -53,12 +53,13 @@
              groupDisplayProperty="categoryLabel"
              uninitialized="true"/>
       </div>
     </div>
     <div id="main-column">
       <div id="query-explanation"/>
       <div id="facet-date" class="facetious" type="date" />
       <div class="results" id="results" type="message" />
+      <div class="show-more" id="showMore" onclick="FacetContext.showMore()">&glodaFacetView.showMore.label;</div>
     </div>
   </div>
 </body>
 </html>
--- a/mail/locales/en-US/chrome/messenger/glodaFacetView.dtd
+++ b/mail/locales/en-US/chrome/messenger/glodaFacetView.dtd
@@ -1,4 +1,8 @@
 <!-- LOCALIZATION NOTE (glodaFacetView.filters.label): Label at the top of the
      faceting sidebar.  Serves as a header both for the checkboxes under it as
      well for labeled facets with multiple options. -->
 <!ENTITY glodaFacetView.filters.label "Filter by:">
+
+<!-- LOCALIZATION NOTE (glodaFacetView.showMore.label): Label at the bottom
+     of the results list to show more hits. -->
+<!ENTITY glodaFacetView.showMore.label "Show more hits">