-
Notifications
You must be signed in to change notification settings - Fork 807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Hide Header which toggles header + toolbar + menubar visibility #863
Conversation
Works and is certainly a good idea. |
Nice idea. To be future-proof, I'd suggest triggering the actions |
see notebook/static/notebook/js/actions.js#L432-L446 for the actions in notebook 4.3.0 |
Can I get the current on/off status of those toggles? It's needed to have everything sync up. |
(Upstream should just add this as a feature, but the extension is a measure needed until then.) |
agreed!
Not through the API, as far as I've seen so far. The only way I can think of to check the current status would be to use something like var header_shown = $('#header-container').is(':visible');
var toolbar_shown = $('div#maintoolbar').is(':visible'); which clearly isn't as future-proof, but perhaps suits the purpose? |
I have no prior experience with jquery or js, so excuse all the questions. I'd like to query visibility, toggle those actions if needed, but then the toggling of the menu bar comes at the end, so the resize event still happens between say the toolbar is hidden and the menubar is (is this right?) which doesn't sound like it helps anything. |
Indeed, you may check for visibility before toggling. A possibility could be: If one is visible, then hide, otherwise show both. In both cases issue a (unique) resize event.
with |
no worries, I make it up as I go along anyway 😉
If both actions get called, there will be a resize event for each action, so one will fire between the two, which isn't massively helpful, but is also not a problem, then the second will fire at the end, fixing everything correctly. You could limit this to one event, as @jfbercher suggests, but this adds complexity without really gaining much, so I'd just keep it simple and robust by calling the actions. Something like var desired_shown = true; // or false, as appropriate
if (desired_shown !== $('#header-container').is(':visible')) {
Jupyter.keyboard_manager.actions.call('jupyter-notebook:toggle-header');
}
if (desired_shown !== $('div#maintoolbar').is(':visible')) {
Jupyter.keyboard_manager.actions.call('jupyter-notebook:toggle-toolbar');
} |
A small drawback that I saw with the actions is that the menu is not hidden, reason for which I used |
Ah, I see, this is providing functionality not present in the default actions. Apologies, I missed that. |
I'm back. I would like this to just hide/show menubar, header, toolbar as a unit. If I unhide, I want just the parts that were visible before to be visible. That maybe doesn't make much sense, but it works for me. |
Ugh, apologies for the misunderstanding there. Now it makes more sense, and I think your initial implementation of just hiding the whole // events should really obtained as an arg retrieved from the define([...] call
var events = require('base/js/events');
events.trigger('resize-header.Page'); I'd also suggest making the keyboard shortcut configurable, as ctrl-H opens browser history in many cases,so rebinding it may be undesirable for some people. That can wait for a further PR though, I guess. |
ah, yeah, except that by hiding the |
- Changed name of the extension without changing its functionality - Add a config parameter for the hotkey
I have pushed a new commit. The mechanism of hiding the header + menubar + toolbar is still the same, just decided to rename the extension to Hide Header and the action to Toggle Header. Also added a hotkey config (with the the comment-uncomment extension as guide. |
Oh, there's already a default action called Toggle Header. New try for the action name is Toggle All Headers... |
Nice progress! Can I suggest to add a more meaningful name for the triggered event, eg |
Ah, the new event in commit 2 was a mistake, not intentional to keep that experiment in the code. I've changed it to a new event name. |
Thanks a lot! I expect it will be popular. |
Quite possibly, but I'm not aware of an easy way to tell how popular any extension is, aside from the number of PRs, issues and questions it prompts. If anyone has any better ideas, I'd love to know! 😆 |
Thanks for this, but I couldn't make it work: |
@oztalha did you also run the second, nbextension install step (which copies the javascript etc into the jupyter data directories)? If you've installed using conda in the past, I'd suggest using the |
Also, just to note, this duplicates a lot of zenmode (which doesn't hide the toolbar, but does hide everything else), so it might have been easier to extend that, but it's a bit late now (my fault, should have thought to mention it earlier)! |
That seems the most likely explanation :) |
This is useful for giving talks with relatively large font size; you don't want menu bar or the status field (“checkpoint saved” etc) visible.