Skip to content

Commit 78b3590

Browse files
committed
* First sketch of #189.
1 parent 2f71c26 commit 78b3590

7 files changed

+36
-16
lines changed

SocialCalcModule.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -10196,6 +10196,7 @@ SocialCalc.CalculateRowPositions = function(editor, panenum, positions, sizes) {
1019610196
for (rownum=context.rowpanes[rowpane].first; rownum<=context.rowpanes[rowpane].last; rownum++) {
1019710197
trowobj = tbodyobj.childNodes[toprow+offset];
1019810198
offset++;
10199+
if (!trowobj) { continue; }
1019910200
cellposition = SocialCalc.GetElementPosition(trowobj.firstChild);
1020010201

1020110202
// Safari has problem: If a cell in the row is high, cell 1 is centered and it returns top of centered part
@@ -23086,12 +23087,18 @@ SocialCalc.SpreadsheetControlExecuteCommand = function(obj, combostr, sstr) {
2308623087
str.W = SocialCalc.rcColname(eobj.range.left) + ":" + SocialCalc.rcColname(eobj.range.right);
2308723088
str.H = eobj.range.top + ":" + eobj.range.bottom;
2308823089
}
23089-
else {
23090+
else if (eobj.ecell) {
2309023091
str.C = eobj.ecell.coord;
2309123092
str.R = eobj.ecell.coord+":"+eobj.ecell.coord;
2309223093
str.W = SocialCalc.rcColname(SocialCalc.coordToCr(eobj.ecell.coord).col);
2309323094
str.H = SocialCalc.coordToCr(eobj.ecell.coord).row;
2309423095
}
23096+
else {
23097+
str.C = 'A1'
23098+
str.R = 'A1:A1'
23099+
str.W = SocialCalc.rcColname(SocialCalc.coordToCr('A1').col);
23100+
str.H = SocialCalc.coordToCr('A1').row;
23101+
}
2309523102
str.S = sstr;
2309623103
combostr = combostr.replace(/%C/g, str.C);
2309723104
combostr = combostr.replace(/%R/g, str.R);

multi/main.ls

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
require \./styles.styl
22
React = require \react
33
TabPanel = require \react-basic-tabs
4-
BasePath = if window.location.href is /(?:127.0.0.1|localhost):8080/ then \http://127.0.0.1:8000 else \.
4+
BasePath = if window.location.href is /(?:127.0.0.1|localhost|\.local):8080/ then \http://127.0.0.1:8000 else \.
55
Index = \foobar
6-
Index = RegExp.$1 if window.location.href is /\/=([^_][^\/]*)$/
6+
Index = RegExp.$1 if window.location.href is /\/=([^_][^\/?]*)(?:\?.*)?$/
77
HackFoldr = require(\./foldr.ls).HackFoldr
8+
IsReadOnly = window.location.href is /auth=0/
9+
if /\?auth=/.test window.location.search
10+
IsReadOnly = (/\??auth=0/.test window.location.search)
811

912
{div, iframe, input, button} = React.DOM
1013

@@ -14,9 +17,9 @@ App = createClass do
1417
getDefaultProps: -> activeIndex: 0
1518
render: ->
1619
can-delete = @props.foldr.size! > 1
17-
div { className: \nav },
20+
div { className: "nav#{ if IsReadOnly then ' readonly' else '' }" },
1821
Nav { rows: @props.foldr.rows, activeIndex: @get-idx!, @~onChange }
19-
Buttons { can-delete, @~on-add, @~on-rename, @~on-delete }
22+
if IsReadOnly then '' else Buttons { can-delete, @~on-add, @~on-rename, @~on-delete }
2023
get-idx: -> @props.activeIndex <? @props.foldr.lastIndex!
2124
get-sheet: -> @props.foldr.at(@get-idx!)
2225
componentDidUpdate: ->
@@ -66,7 +69,7 @@ Nav = createClass do
6669
TabPanel { activeIndex: @props.activeIndex, @~onChange, tabVerticalPosition: \bottom },
6770
...for { title, link="/#{ encodeURIComponent title }" } in @props.rows
6871
div { key: title, title, className: \wrapper },
69-
Frame { src: "#BasePath#link", rows: @props.rows }
72+
Frame { src: "#BasePath#link#{ if IsReadOnly then \/view else '' }", rows: @props.rows }
7073

7174
Frame = createClass do
7275
shouldComponentUpdate: -> @props.src isnt it.src

multi/styles.styl

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ nav
1919
white-space nowrap
2020
// overflow-x auto
2121

22+
.readonly nav
23+
right 0
24+
2225
.buttons
2326
width 200px
2427
right 0px

socialcalcspreadsheetcontrol.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1930,12 +1930,18 @@ SocialCalc.SpreadsheetControlExecuteCommand = function(obj, combostr, sstr) {
19301930
str.W = SocialCalc.rcColname(eobj.range.left) + ":" + SocialCalc.rcColname(eobj.range.right);
19311931
str.H = eobj.range.top + ":" + eobj.range.bottom;
19321932
}
1933-
else {
1933+
else if (eobj.ecell) {
19341934
str.C = eobj.ecell.coord;
19351935
str.R = eobj.ecell.coord+":"+eobj.ecell.coord;
19361936
str.W = SocialCalc.rcColname(SocialCalc.coordToCr(eobj.ecell.coord).col);
19371937
str.H = SocialCalc.coordToCr(eobj.ecell.coord).row;
19381938
}
1939+
else {
1940+
str.C = 'A1'
1941+
str.R = 'A1:A1'
1942+
str.W = SocialCalc.rcColname(SocialCalc.coordToCr('A1').col);
1943+
str.H = SocialCalc.coordToCr('A1').row;
1944+
}
19391945
str.S = sstr;
19401946
combostr = combostr.replace(/%C/g, str.C);
19411947
combostr = combostr.replace(/%R/g, str.R);

socialcalctableeditor.js

+1
Original file line numberDiff line numberDiff line change
@@ -3139,6 +3139,7 @@ SocialCalc.CalculateRowPositions = function(editor, panenum, positions, sizes) {
31393139
for (rownum=context.rowpanes[rowpane].first; rownum<=context.rowpanes[rowpane].last; rownum++) {
31403140
trowobj = tbodyobj.childNodes[toprow+offset];
31413141
offset++;
3142+
if (!trowobj) { continue; }
31423143
cellposition = SocialCalc.GetElementPosition(trowobj.firstChild);
31433144

31443145
// Safari has problem: If a cell in the row is high, cell 1 is centered and it returns top of centered part

static/ethercalc.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/multi.js

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)