ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject [1/3] incubator-ponymail git commit: ensure listview is approximately the same height always
Date Mon, 05 Sep 2016 09:46:59 GMT
Repository: incubator-ponymail
Updated Branches:
  refs/heads/coffee-and-cake ef0fcb477 -> bd51f449c


ensure listview is approximately the same height always


Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/180f6e11
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/180f6e11
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/180f6e11

Branch: refs/heads/coffee-and-cake
Commit: 180f6e11192fd78446d021e9e14b48951fa9201a
Parents: ef0fcb4
Author: Daniel Gruno <humbedooh@apache.org>
Authored: Mon Sep 5 11:45:52 2016 +0200
Committer: Daniel Gruno <humbedooh@apache.org>
Committed: Mon Sep 5 11:45:52 2016 +0200

----------------------------------------------------------------------
 site/js/coffee/listview_basic.coffee        | 20 +++++++++-----
 site/js/coffee/listview_single_email.coffee | 10 ++++---
 site/js/ponymail-coffee.js                  | 34 +++++++++++++++---------
 3 files changed, 42 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/180f6e11/site/js/coffee/listview_basic.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/listview_basic.coffee b/site/js/coffee/listview_basic.coffee
index 183b34a..71dd9ff 100644
--- a/site/js/coffee/listview_basic.coffee
+++ b/site/js/coffee/listview_basic.coffee
@@ -77,7 +77,7 @@ class BasicListView
         
         ### Show how many threads out of how many we are showing ###
         f = pos+1
-        l = Math.min(@listsize - pos, pos+rpp)
+        l = Math.min(@listsize, pos+rpp)
         dStat = new HTML('div', { style: {float: "left", width: "100%", fontSize: "80%",
textAlign: "center"}}, "Showing items #{f} through #{l} out of #{@listsize}")
         @lv.inject(dStat)
         
@@ -110,7 +110,12 @@ class BasicListView
                 topButtons.inject(nbutton)
             @lv.inject(topButtons)
             
-        @renderItems()
+        lastitem = @renderItems()
+        
+        if lastitem
+            bj = lastitem.getBoundingClientRect()
+            @lvitems.style.minHeight = (@rpp*bj.height) + "px"
+            
         
         ### If we made buttons, clone them at the bottom ###
         if topButtons
@@ -135,17 +140,20 @@ class BasicListView
     ### renderItems: render the list view emails/theads ###
     renderItems: () ->
         ### For each email result,...###
-        lvitems = new HTML('div', { class: "listview_table" })
+        @lvitems = new HTML('div', { class: "listview_table" })
+        lastitem = null
         for item in @json.thread_struct[@pos...(@pos+@rpp)]
             original = @findEmail(item.tid)
             ### Be sure we actually have an email here ###
             if original
                 ### Call listViewItem to compile a list view HTML element ###
-                item = @listViewItem(original, item)
+                lvitem = @listViewItem(original, item)
+                lastitem = lvitem
                 
                 ### Inject new item into the list view ###
-                lvitems.inject(item)
-        @lv.inject(lvitems)
+                @lvitems.inject(lvitem)
+        @lv.inject(@lvitems)
+        return lastitem
         
     ### findEmail: find an email given an ID ###
     findEmail: (id) ->

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/180f6e11/site/js/coffee/listview_single_email.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/listview_single_email.coffee b/site/js/coffee/listview_single_email.coffee
index 8b8ed2f..8f1d3d7 100644
--- a/site/js/coffee/listview_single_email.coffee
+++ b/site/js/coffee/listview_single_email.coffee
@@ -67,16 +67,18 @@ class SingleListView extends BasicListView
     
     renderItems: () ->
         ### For each email result,...###
-        lvitems = new HTML('div', { class: "listview_table" })
+        @lvitems = new HTML('div', { class: "listview_table" })
+        lastitem = null
         for original in @json.emails[@pos...(@pos+@rpp)]
             ### Be sure we actually have an email here ###
             if original
                 ### Call listViewItem to compile a list view HTML element ###
                 item = @listViewItem(original, null)
-                
+                lastitem = item
                 ### Inject new item into the list view ###
-                lvitems.inject(item)
-        @lv.inject(lvitems)
+                @lvitems.inject(item)
+        @lv.inject(@lvitems)
+        return lastitem
         
     listViewItem: (original, thread) ->
         ### Be sure we actually have an email here ###

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/180f6e11/site/js/ponymail-coffee.js
----------------------------------------------------------------------
diff --git a/site/js/ponymail-coffee.js b/site/js/ponymail-coffee.js
index cc21032..73f4eb8 100644
--- a/site/js/ponymail-coffee.js
+++ b/site/js/ponymail-coffee.js
@@ -1255,7 +1255,7 @@ BasicListView = (function() {
   /* scroll: scroll to a position and show N emails/threads */
 
   BasicListView.prototype.scroll = function(rpp, pos) {
-    var dStat, diff, f, l, nbutton, nno, now, np, pbutton, pno, pp, tmpthis, topButtons;
+    var bj, dStat, diff, f, l, lastitem, nbutton, nno, now, np, pbutton, pno, pp, tmpthis,
topButtons;
     this.lastScroll = new Date().getTime();
 
     /* Clear the list view */
@@ -1266,7 +1266,7 @@ BasicListView = (function() {
 
     /* Show how many threads out of how many we are showing */
     f = pos + 1;
-    l = Math.min(this.listsize - pos, pos + rpp);
+    l = Math.min(this.listsize, pos + rpp);
     dStat = new HTML('div', {
       style: {
         float: "left",
@@ -1317,7 +1317,11 @@ BasicListView = (function() {
       }
       this.lv.inject(topButtons);
     }
-    this.renderItems();
+    lastitem = this.renderItems();
+    if (lastitem) {
+      bj = lastitem.getBoundingClientRect();
+      this.lvitems.style.minHeight = (this.rpp * bj.height) + "px";
+    }
 
     /* If we made buttons, clone them at the bottom */
     if (topButtons) {
@@ -1347,10 +1351,11 @@ BasicListView = (function() {
   BasicListView.prototype.renderItems = function() {
 
     /* For each email result,... */
-    var item, j, len, lvitems, original, ref;
-    lvitems = new HTML('div', {
+    var item, j, lastitem, len, lvitem, original, ref;
+    this.lvitems = new HTML('div', {
       "class": "listview_table"
     });
+    lastitem = null;
     ref = this.json.thread_struct.slice(this.pos, this.pos + this.rpp);
     for (j = 0, len = ref.length; j < len; j++) {
       item = ref[j];
@@ -1360,13 +1365,15 @@ BasicListView = (function() {
       if (original) {
 
         /* Call listViewItem to compile a list view HTML element */
-        item = this.listViewItem(original, item);
+        lvitem = this.listViewItem(original, item);
+        lastitem = lvitem;
 
         /* Inject new item into the list view */
-        lvitems.inject(item);
+        this.lvitems.inject(lvitem);
       }
     }
-    return this.lv.inject(lvitems);
+    this.lv.inject(this.lvitems);
+    return lastitem;
   };
 
 
@@ -1831,10 +1838,11 @@ SingleListView = (function(superClass) {
   SingleListView.prototype.renderItems = function() {
 
     /* For each email result,... */
-    var item, j, len, lvitems, original, ref;
-    lvitems = new HTML('div', {
+    var item, j, lastitem, len, original, ref;
+    this.lvitems = new HTML('div', {
       "class": "listview_table"
     });
+    lastitem = null;
     ref = this.json.emails.slice(this.pos, this.pos + this.rpp);
     for (j = 0, len = ref.length; j < len; j++) {
       original = ref[j];
@@ -1844,12 +1852,14 @@ SingleListView = (function(superClass) {
 
         /* Call listViewItem to compile a list view HTML element */
         item = this.listViewItem(original, null);
+        lastitem = item;
 
         /* Inject new item into the list view */
-        lvitems.inject(item);
+        this.lvitems.inject(item);
       }
     }
-    return this.lv.inject(lvitems);
+    this.lv.inject(this.lvitems);
+    return lastitem;
   };
 
   SingleListView.prototype.listViewItem = function(original, thread) {


Mime
View raw message