Skip to content

Commit 87911d4

Browse files
committed
add a function for setting statusline visibility
statusline.setVisibility is called when the fullscreen mode or the commandline mode changes. In fullscreen, it hides the statusline. If commandline is needed, it unhide the statusline. Users can change the statusline's visiblility by calling statusline.setVisibility(statusline.setVisibility.TOGGLE).
1 parent ec64e66 commit 87911d4

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

common/content/events.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,7 @@ const Events = Module("events", {
11791179
this._fullscreen = window.fullScreen;
11801180
liberator.triggerObserver("fullscreen", this._fullscreen);
11811181
autocommands.trigger("Fullscreen", { state: this._fullscreen });
1182+
statusline.setVisibility(statusline.setVisibility.FULLSCREEN);
11821183
}
11831184
}
11841185
}, {

common/content/modes.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ const Modes = Module("modes", {
104104
if (oldExtended & modes.HINTS)
105105
hints.hide();
106106
commandline.close();
107+
statusline.setVisibility(statusline.setVisibility.MODE_OFF);
107108
break;
108109
}
109110

@@ -119,6 +120,11 @@ const Modes = Module("modes", {
119120
} else if (newMode === modes.COMPOSE) {
120121
services.get("focus").clearFocus(window);
121122
}
123+
124+
if (newMode == modes.COMMAND_LINE) {
125+
statusline.setVisibility(statusline.setVisibility.MODE_ON);
126+
}
127+
122128
},
123129

124130
NONE: 0,

common/content/statusline.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ const StatusLine = Module("statusline", {
7272
// our status bar fields
7373
this._statusfields = {};
7474
this._statuslineWidget = document.getElementById("liberator-status");
75+
// initialize setVisibility static variables
76+
this.setVisibility(-1);
7577
},
7678

7779
/**
@@ -123,6 +125,63 @@ const StatusLine = Module("statusline", {
123125
}
124126
},
125127

128+
// set the visibility of the statusline
129+
setVisibility: function (request) {
130+
if ( typeof this.setVisibility.currVisibility == 'undefined' ) {
131+
this.setVisibility.currVisibility = true;
132+
this.setVisibility.prevVisibility = true;
133+
this.setVisibility.contentSeparator
134+
= highlight.get('ContentSeparator').value;
135+
136+
// kinds of requests
137+
this.setVisibility.MODE_ON = 0; // commandline active
138+
this.setVisibility.MODE_OFF = 1; // commandline inactive
139+
this.setVisibility.TOGGLE = 2; // toggle on or off
140+
this.setVisibility.FULLSCREEN = 3; // in or out of fullscreen
141+
}
142+
143+
const bb = document.getElementById("liberator-bottombar");
144+
const sv = this.setVisibility;
145+
146+
if (!bb) return;
147+
148+
var toggle_off = function () {
149+
bb.style.height = '0px';
150+
bb.style.overflow = 'hidden';
151+
highlight.set('ContentSeparator', 'display: none;');
152+
};
153+
154+
var toggle_on = function () {
155+
bb.style.height = '';
156+
bb.style.overflow = '';
157+
highlight.set('ContentSeparator', sv.contentSeparatorValue);
158+
};
159+
160+
switch (request) {
161+
case sv.TOGGLE:
162+
sv.currVisibility = !sv.currVisibility;
163+
if (sv.currVisibility) toggle_on();
164+
else toggle_off();
165+
break;
166+
case sv.FULLSCREEN:
167+
if (window.fullScreen) {
168+
sv.prevVisibility = sv.currVisibility;
169+
sv.currVisibility = false;
170+
toggle_off();
171+
} else {
172+
sv.currVisibility = sv.currVisibility || sv.prevVisibility;
173+
if (sv.currVisibility) toggle_on();
174+
}
175+
break;
176+
case sv.MODE_ON:
177+
if (!sv.currVisibility) toggle_on();
178+
break;
179+
case sv.MODE_OFF:
180+
if (!sv.currVisibility) toggle_off();
181+
break;
182+
}
183+
},
184+
126185
/**
127186
* Set any field in the statusbar
128187
*

vimperator/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
the window when closing the last tab, should set this option to false (either through about:config
99
or with :set! browser.tabs.closeWindowWithLastTab=false)
1010
* gr toggles Reader View
11+
* Autohide statusbar: When entering fullscreen mode, the statusbar is
12+
hidden and temporarily showed up with command inputs. Also, Users can
13+
manually hide and unhide the statusbar with a command:
14+
:js statusline.setVisibility(statusline.setVisibility.TOGGLE)
1115

1216
2015-08-25:
1317
* Version 3.10.1

0 commit comments

Comments
 (0)