diff --git a/src/jupyter_contrib_nbextensions/nbextensions/toc2/README.md b/src/jupyter_contrib_nbextensions/nbextensions/toc2/README.md index 6354d19..0675b65 100644 --- a/src/jupyter_contrib_nbextensions/nbextensions/toc2/README.md +++ b/src/jupyter_contrib_nbextensions/nbextensions/toc2/README.md @@ -11,7 +11,7 @@ The toc2 extension enables to collect all running headers and display them in a  ### Third demo: Notebook scrolling and Collapsing sections - + The table of contents is automatically updated when modifications occur in the notebook. The toc window can be moved and resized. It can be docked as a sidebar or dragged from the sidebar into a floating window. The table of contents can be collapsed or the window can be completely hidden. The navigation menu can be enabled/disabled via the nbextensions configuration utility. It can also be resized. The position, dimensions, and states (that is 'collapsed' and 'hidden' states) are remembered (actually stored in the notebook's metadata) and restored on the next session. diff --git a/src/jupyter_contrib_nbextensions/nbextensions/toc2/demo_scroll_collapse.gif b/src/jupyter_contrib_nbextensions/nbextensions/toc2/demo_scroll_collapse.gif deleted file mode 100644 index e019a1f..0000000 Binary files a/src/jupyter_contrib_nbextensions/nbextensions/toc2/demo_scroll_collapse.gif and /dev/null differ diff --git a/src/jupyter_contrib_nbextensions/nbextensions/toc2/main.js b/src/jupyter_contrib_nbextensions/nbextensions/toc2/main.js index 21c6be8..07f8ad6 100644 --- a/src/jupyter_contrib_nbextensions/nbextensions/toc2/main.js +++ b/src/jupyter_contrib_nbextensions/nbextensions/toc2/main.js @@ -21,7 +21,6 @@ define([ var highlight_toc_item = toc2.highlight_toc_item; var table_of_contents = toc2.table_of_contents; var toggle_toc = toc2.toggle_toc; - var highlightTocItemOnScroll = toc2.highlightTocItemOnScroll; // ...........Parameters configuration...................... // default values for system-wide configurable parameters @@ -147,7 +146,7 @@ define([ function create_additional_css() { var sheet = document.createElement('style') - sheet.innerHTML = "#toc-level0 li > a:hover { background-color: " + cfg.colors.hover_highlight + " }\n" + + sheet.innerHTML = "#toc-level0 li > span:hover { background-color: " + cfg.colors.hover_highlight + " }\n" + ".toc-item-highlight-select {background-color: " + cfg.colors.selected_highlight + "}\n" + ".toc-item-highlight-execute {background-color: " + cfg.colors.running_highlight + "}\n" + ".toc-item-highlight-execute.toc-item-highlight-select {background-color: " + cfg.colors.selected_highlight + "}" @@ -214,7 +213,6 @@ define([ // read configuration, then call toc cfg = read_config(cfg, function() { table_of_contents(cfg, st); - highlightTocItemOnScroll(cfg, st); }); // called after config is stable // event: render toc for each markdown cell modification $([IPython.events]).on("rendered.MarkdownCell", diff --git a/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js b/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js index 0202b8b..b554389 100644 --- a/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js +++ b/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js @@ -19,7 +19,7 @@ liveNotebook = true; } catch (err) { - // We *are* in a live notebook + // We *are* theoretically in a non-live notebook console.log('[toc2] working in non-live notebook'); //, err); // in non-live notebook, there's no event structure, so we make our own if (window.events === undefined) { @@ -374,8 +374,7 @@ function highlight_toc_item(evt, data) { // On header/menu/toolbar resize, resize the toc itself // (if displayed as a sidebar) if (liveNotebook) { - $([Jupyter.events]).on("resize-header.Page", function() {setSideBarHeight(cfg, st);}); - $([Jupyter.events]).on("toggle-all-headers", function() {setSideBarHeight(cfg, st);}); + $([Jupyter.events]).on("resize-header.Page toggle-all-headers", function() {setSideBarHeight(cfg, st);}); } @@ -582,8 +581,9 @@ var table_of_contents = function (cfg,st) { var toc_wrapper = $("#toc-wrapper"); // var toc_index=0; - if (toc_wrapper.length === 0) { - create_toc_div(cfg,st); + if (toc_wrapper.length === 0) { // toc window doesn't exist at all + create_toc_div(cfg,st); // create it + highlightTocItemOnScroll(cfg, st); // initialize highlighting on scroll } var segments = []; var ul = $("