loleaflet/src/control/Control.RowHeader.js |  108 +++++++++++++++--------------
 1 file changed, 58 insertions(+), 50 deletions(-)

New commits:
commit 7ed35f810e50471aee8958d1f23b9bc000d32706
Author: Henry Castro <hcas...@collabora.com>
Date:   Sun Nov 15 19:25:50 2015 -0400

    loleaflet: update row headers to modified css styles

diff --git a/loleaflet/src/control/Control.RowHeader.js 
b/loleaflet/src/control/Control.RowHeader.js
index 45bfb17..c4fab2a 100644
--- a/loleaflet/src/control/Control.RowHeader.js
+++ b/loleaflet/src/control/Control.RowHeader.js
@@ -3,67 +3,75 @@
 */
 
 L.Control.RowHeader = L.Control.extend({
-       onAdd: function () {
-               var docContainer = L.DomUtil.get('document-container');
-               var divRowHeader = L.DomUtil.create('div', 
'spreadsheet-container-row', docContainer.parentElement);
-               var divRowInner = L.DomUtil.create('div', 
'spreadsheet-container-row-inner', divRowHeader);
-               this._table = L.DomUtil.create('table', '', divRowInner);
-               this._table.id = 'spreadsheet-table-row';
-               this._rows = L.DomUtil.create('tbody', '', this._table);
+    onAdd: function () {
+       var docContainer = L.DomUtil.get('document-container');
+       var divRowHeader = L.DomUtil.create('div', 'spreadsheet-container-row', 
docContainer.parentElement);
+       this._table = L.DomUtil.create('table', 'spreadsheet-table-row', 
divRowHeader);
+       this._rows = L.DomUtil.create('tbody', '', this._table);
 
-               this._position = 0;
+       this._position = 0;
+       this._totalHeight = 0;
+       this._viewPort = 0;
 
-               // dummy initial row header
-               var row = L.DomUtil.create('tr', '', this._rows);
-               L.DomUtil.create('th', 'spreadsheet-table-row-cell', row);
+       // dummy initial row header
+       var trRow = L.DomUtil.create('tr', '', this._rows);
+       var thRow = L.DomUtil.create('th', 'spreadsheet-table-row-cell', trRow);
+       L.DomUtil.create('div', 'spreadsheet-table-row-cell-text', thRow);
 
-               return document.createElement('div');
-       },
+       return document.createElement('div');
+    },
 
-       clearRows: function () {
-               L.DomUtil.remove(this._rows);
-               this._rows = L.DomUtil.create('tbody', '', this._table);
-       },
+    clearRows: function () {
+       L.DomUtil.remove(this._rows);
+       this._rows = L.DomUtil.create('tbody', '', this._table);
+    },
 
-       setScrollPosition: function (position) {
-               this._position = position;
-               L.DomUtil.setStyle(this._table, 'top', this._position + 'px');
-       },
+    setViewPort: function(totalHeight, viewPort) {
+       this._viewPort = viewPort;
+       this._totalHeight = totalHeight;
+    },
 
-       offsetScrollPosition: function (offset) {
-               this._position = this._position - offset;
-               L.DomUtil.setStyle(this._table, 'top', this._position + 'px');
-       },
+    setScrollPosition: function (position) {
+       this._position = Math.min(0, position);
+       L.DomUtil.setStyle(this._table, 'top', this._position + 'px');
+    },
 
-       fillRows: function (rows, converter, context) {
-               var iterator, twip, height, row, cell;
+    offsetScrollPosition: function (offset) {
+       this._position = Math.min(0,
+       Math.max(this._position - offset,
+               -(this._totalHeight - this._viewPort - 4)));
+       L.DomUtil.setStyle(this._table, 'top', this._position + 'px');
+    },
 
-               this.clearRows();
-               var totalHeight = -1;
-               for (iterator = 0; iterator < rows.length; iterator++) {
-                       twip = new L.Point(parseInt(rows[iterator].size), 
parseInt(rows[iterator].size));
-                       height =  Math.round(converter.call(context, twip).y) - 
2 - totalHeight;
-                       row  = L.DomUtil.create('tr', '', this._rows);
-                       cell = L.DomUtil.create('th', 
'spreadsheet-table-row-cell', row);
-                       cell.innerHTML  = rows[iterator].text;
-                       cell.twipHeight = rows[iterator].size;
-                       cell.height = height + 'px';
-                       totalHeight += height + 1;
-               }
-       },
+    fillRows: function (rows, converter, context) {
+       var iterator, twip, height, row, cell, text;
 
-       updateRows: function (converter, context) {
-               var iterator, twip, height, row;
+       this.clearRows();
+       for (iterator = 0; iterator < rows.length; iterator++) {
+               height = rows[iterator].size - (iterator > 0 ? rows[iterator - 
1].size : 0);
+               twip = new L.Point(height, height);
+               row  = L.DomUtil.create('tr', '', this._rows);
+               cell = L.DomUtil.create('th', 'spreadsheet-table-row-cell', 
row);
+               text = L.DomUtil.create('div', 
'spreadsheet-table-row-cell-text', cell);
+               text.innerHTML  = rows[iterator].text;
+               height = Math.round(converter.call(context, twip).y) - 
(iterator > 0 ? 1 : 0) + 'px';
+               L.DomUtil.setStyle(text, 'line-height', height);
+               L.DomUtil.setStyle(text, 'height', height);
+       }
+    },
+
+    updateRows: function (rows, converter, context) {
+       var iterator, twip, height, text;
 
-               var totalHeight = -1;
-               for (iterator = 0; iterator < this._rows.childNodes.length; 
iterator++) {
-                       row  = this._rows.childNodes[iterator].firstChild;
-                       twip = new L.Point(parseInt(row.twipHeight), 
parseInt(row.twipHeight));
-                       height =  Math.round(converter.call(context, twip).y) - 
2 - totalHeight;
-                       row.height = height + 'px';
-                       totalHeight += height + 1;
-               }
+       for (iterator = 0; iterator < this._rows.childNodes.length; iterator++) 
{
+               text  = this._rows.childNodes[iterator].firstChild.firstChild;
+               height = rows[iterator].size - (iterator > 0 ? rows[iterator - 
1].size : 0);
+               twip = new L.Point(height, height);
+               height = Math.round(converter.call(context, twip).y) - 
(iterator > 0 ? 1 : 0) + 'px';
+               L.DomUtil.setStyle(text, 'line-height', height);
+               L.DomUtil.setStyle(text, 'height', height);
        }
+    }
 });
 
 L.control.rowHeader = function (options) {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to