Skip to content

Commit db277be

Browse files
committed
Merge pull request #200 from samejack/feature-colresize-commit
[New Feature] Use the mouse to drop the header to resize height of row.
2 parents 8c24b58 + 0596342 commit db277be

8 files changed

+244
-82
lines changed

SocialCalcModule.js

+114-33
Large diffs are not rendered by default.

l10n/de.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@
3737
"defaultHighlightTypeRangeClass": "",
3838
"defaultHighlightTypeRangeStyle": "color:#000;backgroundColor:#E5E5E5;",
3939
"defaultColnameClass": "",
40-
"defaultColnameStyle": "font-size:small;text-align:center;color:#FFFFFF;background-color:#808080;cursor:e-resize;",
40+
"defaultColnameStyle": "font-size:small;text-align:center;color:#FFFFFF;background-color:#808080;cursor:col-resize;",
4141
"defaultSelectedColnameClass": "",
42-
"defaultSelectedColnameStyle": "font-size:small;text-align:center;color:#FFFFFF;background-color:#404040;cursor:e-resize;",
42+
"defaultSelectedColnameStyle": "font-size:small;text-align:center;color:#FFFFFF;background-color:#404040;cursor:col-resize;",
4343
"defaultRownameClass": "",
44-
"defaultRownameStyle": "font-size:small;text-align:right;color:#FFFFFF;background-color:#808080;direction:rtl;",
44+
"defaultRownameStyle": "font-size:small;text-align:right;color:#FFFFFF;background-color:#808080;direction:rtl;cursor:row-resize;",
4545
"defaultSelectedRownameClass": "",
46-
"defaultSelectedRownameStyle": "font-size:small;text-align:right;color:#FFFFFF;background-color:#404040;",
46+
"defaultSelectedRownameStyle": "font-size:small;text-align:right;color:#FFFFFF;background-color:#404040;cursor:row-resize;",
4747
"defaultUpperLeftClass": "",
4848
"defaultUpperLeftStyle": "font-size:small;",
4949
"defaultSkippedCellClass": "",

l10n/en.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@
3737
"defaultHighlightTypeRangeClass": "",
3838
"defaultHighlightTypeRangeStyle": "color:#000;backgroundColor:#E5E5E5;",
3939
"defaultColnameClass": "",
40-
"defaultColnameStyle": "font-size:small;text-align:center;color:#FFFFFF;background-color:#808080;cursor:e-resize;",
40+
"defaultColnameStyle": "font-size:small;text-align:center;color:#FFFFFF;background-color:#808080;cursor:col-resize;",
4141
"defaultSelectedColnameClass": "",
42-
"defaultSelectedColnameStyle": "font-size:small;text-align:center;color:#FFFFFF;background-color:#404040;cursor:e-resize;",
42+
"defaultSelectedColnameStyle": "font-size:small;text-align:center;color:#FFFFFF;background-color:#404040;cursor:col-resize;",
4343
"defaultRownameClass": "",
44-
"defaultRownameStyle": "font-size:small;text-align:right;color:#FFFFFF;background-color:#808080;direction:rtl;",
44+
"defaultRownameStyle": "font-size:small;text-align:right;color:#FFFFFF;background-color:#808080;direction:rtl;cursor:row-resize;",
4545
"defaultSelectedRownameClass": "",
46-
"defaultSelectedRownameStyle": "font-size:small;text-align:right;color:#FFFFFF;background-color:#404040;",
46+
"defaultSelectedRownameStyle": "font-size:small;text-align:right;color:#FFFFFF;background-color:#404040;cursor:row-resize;",
4747
"defaultUpperLeftClass": "",
4848
"defaultUpperLeftStyle": "font-size:small;",
4949
"defaultSkippedCellClass": "",

l10n/zh-TW.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@
3737
"defaultHighlightTypeRangeClass": "",
3838
"defaultHighlightTypeRangeStyle": "color:#000;backgroundColor:#E5E5E5;",
3939
"defaultColnameClass": "",
40-
"defaultColnameStyle": "font-size:small;text-align:center;color:#FFFFFF;background-color:#808080;cursor:e-resize;",
40+
"defaultColnameStyle": "font-size:small;text-align:center;color:#FFFFFF;background-color:#808080;cursor:col-resize;",
4141
"defaultSelectedColnameClass": "",
42-
"defaultSelectedColnameStyle": "font-size:small;text-align:center;color:#FFFFFF;background-color:#404040;cursor:e-resize;",
42+
"defaultSelectedColnameStyle": "font-size:small;text-align:center;color:#FFFFFF;background-color:#404040;cursor:col-resize;",
4343
"defaultRownameClass": "",
44-
"defaultRownameStyle": "font-size:small;text-align:right;color:#FFFFFF;background-color:#808080;direction:rtl;",
44+
"defaultRownameStyle": "font-size:small;text-align:right;color:#FFFFFF;background-color:#808080;direction:rtl;cursor:row-resize;",
4545
"defaultSelectedRownameClass": "",
46-
"defaultSelectedRownameStyle": "font-size:small;text-align:right;color:#FFFFFF;background-color:#404040;",
46+
"defaultSelectedRownameStyle": "font-size:small;text-align:right;color:#FFFFFF;background-color:#404040;cursor:row-resize;",
4747
"defaultUpperLeftClass": "",
4848
"defaultUpperLeftStyle": "font-size:small;",
4949
"defaultSkippedCellClass": "",

socialcalc-3.js

+30
Original file line numberDiff line numberDiff line change
@@ -4212,7 +4212,9 @@ SocialCalc.RenderContext = function(sheetobj) {
42124212
this.cellskip = {}; // if present, coord of cell covering this cell
42134213
this.coordToCR = {}; // for cells starting spans, coordToCR[coord]={row:row, col:col}
42144214
this.colwidth = []; // precomputed column widths, taking into account defaults
4215+
this.rowheight = []; // precomputed row height, taking into account defaults
42154216
this.totalwidth = 0; // precomputed total table width
4217+
this.totalheight = 0; // precomputed total table height
42164218

42174219
this.rowpanes = []; // for each pane, {first: firstrow, last: lastrow}
42184220
this.colpanes = []; // for each pane, {first: firstrow, last: lastrow}
@@ -4324,6 +4326,7 @@ SocialCalc.RenderContext = function(sheetobj) {
43244326
SocialCalc.RenderContext.prototype.PrecomputeSheetFontsAndLayouts = function() {SocialCalc.PrecomputeSheetFontsAndLayouts(this);};
43254327
SocialCalc.RenderContext.prototype.CalculateCellSkipData = function() {SocialCalc.CalculateCellSkipData(this);};
43264328
SocialCalc.RenderContext.prototype.CalculateColWidthData = function() {SocialCalc.CalculateColWidthData(this);};
4329+
SocialCalc.RenderContext.prototype.CalculateRowHeightData = function() {SocialCalc.CalculateRowHeightData(this);};
43274330
SocialCalc.RenderContext.prototype.SetRowPaneFirstLast = function(panenum, first, last) {this.rowpanes[panenum]={first:first, last:last};};
43284331
SocialCalc.RenderContext.prototype.SetColPaneFirstLast = function(panenum, first, last) {this.colpanes[panenum]={first:first, last:last};};
43294332
SocialCalc.RenderContext.prototype.CoordInPane = function(coord, rowpane, colpane) {return SocialCalc.CoordInPane(this, coord, rowpane, colpane);};
@@ -4464,6 +4467,28 @@ SocialCalc.CalculateColWidthData = function(context) {
44644467

44654468
}
44664469

4470+
SocialCalc.CalculateRowHeightData = function(context) {
4471+
var rownum, rowheight, totalheight;
4472+
var sheetobj = context.sheetobj;
4473+
4474+
// Calculate row height data
4475+
totalheight = context.showRCHeaders ? context.pixelsPerRow : 0;
4476+
for (rowpane = 0; rowpane < context.rowpanes.length; rowpane++) {
4477+
for (rownum = context.rowpanes[rowpane].first; rownum <= context.rowpanes[rowpane].last; rownum++) {
4478+
if (sheetobj.rowattribs.hide[rownum] === "yes") {
4479+
context.rowheight[rownum] = 0;
4480+
} else {
4481+
rowheight = sheetobj.rowattribs.height[rownum] || sheetobj.attribs.defaultrowheight || SocialCalc.Constants.defaultAssumedRowHeight;
4482+
if (rowheight === "blank" || rowheight === "auto") rowheight = "";
4483+
context.rowheight[rownum] = rowheight+"";
4484+
totalheight += (rowheight && ((rowheight - 0) > 0)) ? (rowheight-0) : 10;
4485+
}
4486+
}
4487+
}
4488+
context.totalheight = totalheight;
4489+
4490+
}
4491+
44674492
SocialCalc.InitializeTable = function(context, tableobj) {
44684493

44694494
/*
@@ -4527,6 +4552,7 @@ SocialCalc.RenderSheet = function(context, oldtable, linkstyle) {
45274552
}
45284553

45294554
context.CalculateColWidthData(); // always make sure col width values are up to date
4555+
context.CalculateRowHeightData();
45304556

45314557
// make the table element and fill it in
45324558

@@ -4579,6 +4605,7 @@ SocialCalc.RenderRow = function(context, rownum, rowpane, linkstyle) {
45794605
if (context.classnames) newcol.className=context.classnames.rowname;
45804606
if (context.explicitStyles) newcol.style.cssText=context.explicitStyles.rowname;
45814607
newcol.width=context.rownamewidth;
4608+
newcol.height = context.rowheight[rownum];
45824609
newcol.style.verticalAlign="top"; // to get around Safari making top of centered row number be
45834610
// considered top of row (and can't get <row> position in Safari)
45844611
newcol.innerHTML=rownum+"";
@@ -4592,6 +4619,9 @@ SocialCalc.RenderRow = function(context, rownum, rowpane, linkstyle) {
45924619
var unhide = document.createElement("div");
45934620
if (context.classnames) unhide.className=context.classnames.unhidetop;
45944621
if (context.explicitStyles) unhide.style.cssText=context.explicitStyles.unhidetop;
4622+
var fixPosition = ((context.rowheight[rownum] - 0) - SocialCalc.Constants.defaultAssumedRowHeight);
4623+
fixPosition = (fixPosition === 0) ? 4 : fixPosition;
4624+
unhide.style.bottom = '-' + fixPosition + 'px';
45954625
context.rowunhidetop[rownum] = unhide;
45964626
container.appendChild(unhide);
45974627
newcol.appendChild(container);

socialcalcconstants.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ SocialCalc.Constants = {
150150
defaultHighlightTypeRangeStyle: "color:#000;backgroundColor:#E5E5E5;",
151151

152152
defaultColnameClass: "", // regular column heading letters, needs a cursor property
153-
defaultColnameStyle: "font-size:small;text-align:center;color:#FFFFFF;background-color:#808080;cursor:e-resize;",
153+
defaultColnameStyle: "font-size:small;text-align:center;color:#FFFFFF;background-color:#808080;cursor:col-resize;",
154154
defaultSelectedColnameClass: "", // column with selected cell, needs a cursor property
155-
defaultSelectedColnameStyle: "font-size:small;text-align:center;color:#FFFFFF;background-color:#404040;cursor:e-resize;",
155+
defaultSelectedColnameStyle: "font-size:small;text-align:center;color:#FFFFFF;background-color:#404040;cursor:col-resize;",
156156
defaultRownameClass: "", // regular row heading numbers
157-
defaultRownameStyle: "font-size:small;text-align:right;color:#FFFFFF;background-color:#808080;direction:rtl;",
157+
defaultRownameStyle: "font-size:small;text-align:right;color:#FFFFFF;background-color:#808080;direction:rtl;cursor:row-resize;",
158158
defaultSelectedRownameClass: "", // column with selected cell, needs a cursor property
159-
defaultSelectedRownameStyle: "font-size:small;text-align:right;color:#FFFFFF;background-color:#404040;",
159+
defaultSelectedRownameStyle: "font-size:small;text-align:right;color:#FFFFFF;background-color:#404040;cursor:row-resize;",
160160
defaultUpperLeftClass: "", // Corner cell in upper left
161161
defaultUpperLeftStyle: "font-size:small;",
162162
defaultSkippedCellClass: "", // used if present for spanned cells peeking into a pane (at least one of class/style needed)
@@ -168,7 +168,7 @@ SocialCalc.Constants = {
168168
defaultUnhideRightClass: "",
169169
defaultUnhideRightStyle: "float:left;width:9px;height:12px;cursor:pointer;background-image:url(images/sc-unhideright.gif);padding:0;", // used if present
170170
defaultUnhideTopClass: "",
171-
defaultUnhideTopStyle: "float:left;position:absolute;bottom:-4px;width:12px;height:9px;cursor:pointer;background-image:url(images/sc-unhidetop.gif);padding:0;",
171+
defaultUnhideTopStyle: "float:left;left:1px;position:absolute;bottom:-4px;width:12px;height:9px;cursor:pointer;background-image:url(images/sc-unhidetop.gif);padding:0;",
172172
defaultUnhideBottomClass: "",
173173
defaultUnhideBottomStyle: "float:left;width:12px;height:9px;cursor:pointer;background-image:url(images/sc-unhidebottom.gif);padding:0;",
174174

@@ -288,7 +288,7 @@ SocialCalc.Constants = {
288288

289289
//*** SocialCalc.TCPSDragFunctionStart
290290

291-
TCPStrackinglineClass: "", // at least one of class/style for pane slider tracking line display in table control
291+
TCPStrackinglineClass: "tracklingine", // at least one of class/style for pane slider tracking line display in table control
292292
TCPStrackinglineStyle: "overflow:hidden;position:absolute;zIndex:100;",
293293
// if present, pseudo style (text-align is textAlign)
294294
TCPStrackinglineThickness: "2px", // narrow dimension of trackling line (string with units)

0 commit comments

Comments
 (0)