Skip to content

Commit 19fcdc7

Browse files
committed
Merge pull request #338 from demokritos/dev
Autohide statusbar in fullscreen.
2 parents 99c43d7 + 87911d4 commit 19fcdc7

File tree

5 files changed

+71
-39
lines changed

5 files changed

+71
-39
lines changed

common/content/commandline.js

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
let timeID = null;
1515

1616
const CommandLine = Module("commandline", {
17-
requires: ["config", "liberator", "modes", "services", "storage", "template", "util", "styles"],
17+
requires: ["config", "liberator", "modes", "services", "storage", "template", "util"],
1818

1919
init: function () {
2020
const self = this;
@@ -26,9 +26,6 @@ const CommandLine = Module("commandline", {
2626
storage.newArray(liberator.storeName(mode, isPrivate), { store: !isPrivate});
2727
}, this);
2828

29-
liberator.registerObserver("fullscreen", this.updateBottombar);
30-
liberator.registerObserver("modeChange", this.updateBottombar);
31-
3229
// Really inideal.
3330
let services = modules.services; // Storage objects are global to all windows, 'modules' isn't.
3431
storage.newObject("sanitize", function () {
@@ -183,9 +180,6 @@ const CommandLine = Module("commandline", {
183180

184181
this._commandlineDisplayTimeoutID = null;
185182

186-
this._bottomBarHidden = false;
187-
this._hlContentSepValue;
188-
189183
this.registerCallback("submit", modes.EX, function (command) {
190184
if (self._commandlineDisplayTimeoutID) {
191185
window.clearTimeout(self._commandlineDisplayTimeoutID);
@@ -566,38 +560,6 @@ const CommandLine = Module("commandline", {
566560
this._setPrompt("");
567561
},
568562

569-
/**
570-
* Callback function for updating the Bottombar
571-
*/
572-
updateBottombar: function (){
573-
hide = window.fullScreen && liberator.mode == 1;
574-
commandline.hideBottombar(hide);
575-
},
576-
/**
577-
* Totally hides the vimperator bar at the bottom of the screen (for fullscreen mode)
578-
*/
579-
hideBottombar: function (hide){
580-
if( hide == this._bottomBarHidden)
581-
return;
582-
this._bottomBarHidden = hide;
583-
let bb = document.getElementById('liberator-bottombar');
584-
if (! bb)
585-
return;
586-
587-
if (hide) {
588-
this._hlContentSepValue = highlight.get('ContentSeparator').value;
589-
bb.style.height = '0px';
590-
bb.style.overflow = 'hidden';
591-
highlight.set('ContentSeparator', 'display:none', true, false);
592-
}
593-
else {
594-
bb.style.height = '';
595-
bb.style.overflow = '';
596-
highlight.set('ContentSeparator', this._hlContentSepValue, true, false);
597-
}
598-
},
599-
600-
601563
/**
602564
* Make the command line visible, hiding the status messages below
603565
*

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)