Skip to content

Commit b1eae4f

Browse files
committed
Save UI orintation (fix #307)
1 parent 96e9950 commit b1eae4f

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

js/core/app.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,20 @@
126126

127127
// Setup splitter
128128
if (document.getElementsByClassName("split-pane").length) {
129+
var orientation = Espruino.Config.UI_VERTICAL ? "horizontal" : "vertical";
130+
129131
$(".split-pane").splitster({
130-
orientation: "vertical", //TODO: Load from local storage,
132+
orientation: orientation,
131133
barWidth: 0, // Don't show the bar when vertical,
132134
draggable: ".editor--code > .sidebar"
133135
});
134-
136+
function updateSplitter() {
137+
$(".split-pane").splitster("orientation", orientation);
138+
$(".split-pane").splitster("barWidth", orientation == "vertical" ? 0 : 10);
139+
$(".split-pane").splitster("draggable", orientation == "vertical" ? ".editor--code > .sidebar" : false);
140+
}
141+
updateSplitter();
135142
// Setup orientation button
136-
var orientation = "vertical";
137143
var orientationBtn = Espruino.Core.App.addIcon({
138144
id: "orientation",
139145
icon: "split-" + orientation,
@@ -146,9 +152,8 @@
146152
},
147153
click: function() {
148154
orientation = orientation == "vertical" ? "horizontal" : "vertical";
149-
$(".split-pane").splitster("orientation", orientation);
150-
$(".split-pane").splitster("barWidth", orientation == "vertical" ? 0 : 10);
151-
$(".split-pane").splitster("draggable", orientation == "vertical" ? ".editor--code > .sidebar" : false);
155+
Espruino.Config.set("UI_VERTICAL", orientation == "horizontal"); // splitter=horiz means vertical layout
156+
updateSplitter();
152157
orientationBtn.setIcon("split-" + orientation);
153158
}
154159
});

0 commit comments

Comments
 (0)