Skip to content

Commit

Permalink
[toc2] ensure default config values are present in non-live notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
jcb91 committed Dec 19, 2017
1 parent 6dc75c3 commit 8e61312
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,12 @@
return
}

// In a live notebook, read_config will have been called already, but
// in non-live notebooks, ensure that all config values are defined.
if (!liveNotebook) {
cfg = $.extend(true, {}, default_cfg, cfg);
}

var toc_wrapper = $("#toc-wrapper");
if (toc_wrapper.length === 0) { // toc window doesn't exist at all
create_toc_div(cfg, st); // create it
Expand All @@ -537,9 +543,6 @@
var ul = $('<ul/>').addClass('toc-item');

// update sidebar/window title
if (typeof cfg.title_sidebar === 'undefined') { // For backwards compatibility:
cfg.title_sidebar = "Contents" // May not be defined in some non-live notebooks
};
$('#toc-header > .header').text(cfg.title_sidebar + ' ');

// update toc element
Expand Down

1 comment on commit 8e61312

@jfbercher
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is a nice solution. Thanks!

Please sign in to comment.