Custom action for showing/hiding/toggling menu bar

102 views
Skip to first unread message

Milos Miljkovic

unread,
Apr 5, 2017, 5:39:57 PM4/5/17
to Project Jupyter
Hi,

If I wanted to add a custom notebook action for showing/hiding/toggling menu bar, would including the code below into /notebook/static/notebook/js/actions.js work and correctly add entry to /.jupyter/nbconfig/notebook.json if a custom keyboard shortcut was created?


'toggle-menubar':{
    help: 'hide/show the menu bar',
    handler : function(env) {
        var value = !env.notebook.menubar;
        if (value === true) {
            $('#menubar-container').show();
        } else if (value === false) {
            $('#menubar-container').hide();
        }
        events.trigger('resize-header.Page');
        env.notebook.menubar = value;
    }
},
'show-menubar':{
    help: 'show the menu bar',
    handler : function(env) {
        $('#menubar-container').show();
        events.trigger('resize-header.Page');
        env.notebook.menubar = true;
    }
},
'hide-menubar':{
    help: 'hide the menu bar',
    handler : function(env) {
        $('#menubar-container').hide();
        events.trigger('resize-header.Page');
        env.notebook.menubar = false;
    }
},


Cheers,

Milos.

Thomas Kluyver

unread,
Apr 6, 2017, 7:46:39 AM4/6/17
to Project Jupyter
That code looks reasonable. Have you tested it? Do you want to make a PR?

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/0acf4c0d-183d-460e-a13d-9273be1581b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matthias Bussonnier

unread,
Apr 6, 2017, 1:52:20 PM4/6/17
to jup...@googlegroups.com
That should work, you can even use $(...).toggle() to simplify the logic :-) PR welcomed.
-- 
M

--

Milos Miljkovic

unread,
Apr 6, 2017, 1:52:27 PM4/6/17
to Project Jupyter
There are a few more places to patch the code into and building minified JS. Will test this later US EDT and if it works, I will make a PR.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.

Milos Miljkovic

unread,
Apr 6, 2017, 3:45:43 PM4/6/17
to Project Jupyter
My JS knowledge is shit but $(...).toggle() did cross my mind. I was just being lazy and copied toggle-header logic. Tonight I will properly do this for menu and editor files and see if it works after minifying JS. If it's a go, a PR will be forthcoming.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages