From 3232367e409185ad922db46db7006bd99c1dbae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Bercher?= Date: Sat, 20 May 2017 12:45:36 +0200 Subject: [PATCH 1/5] [toc2] Improve sidebar toggle transition --- src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js b/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js index 053fcf97a..08a0ddf84 100644 --- a/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js +++ b/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js @@ -165,8 +165,9 @@ var make_link = function(h, num_lbl) { callback && callback(); } - function setNotebookWidth(cfg, st) { - //cfg.widenNotebook = false; + function setNotebookWidth(cfg, st, sideBarIsToggling) { + //cfg.widenNotebook = true; + var sideBarIsToggling = typeof sideBarIsToggling !== 'undefined' ? sideBarIsToggling : false; if (cfg.sideBar) { if ($('#toc-wrapper').is(':visible')) { $('#notebook-container').css('margin-left', $('#toc-wrapper').width() + 30) @@ -649,7 +650,7 @@ var table_of_contents = function (cfg,st) { //$("#toc-wrapper").toggle({'complete':function(){ $("#toc-wrapper").toggle({ 'progress':function(){ - setNotebookWidth(cfg,st); + setNotebookWidth(cfg,st, true); }, 'complete': function(){ if(liveNotebook){ From 6a3c37f12ce0ada3e0b7e4066d2921884b8ecd3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Bercher?= Date: Sat, 20 May 2017 12:48:38 +0200 Subject: [PATCH 2/5] [toc2] Restore cells to original width, see #993 --- src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js b/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js index 08a0ddf84..ac24f4dfe 100644 --- a/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js +++ b/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js @@ -177,7 +177,7 @@ var make_link = function(h, num_lbl) { $('#notebook-container').css('margin-left', 30); $('#notebook-container').css('width', $('#notebook').width() - 30); } else { // original width - $("#notebook-container").css({'width':"82%", 'margin-left':'auto'}) + $("#notebook-container").css({'width':st.nbcontainer_width, 'margin-left':'auto'}) } } } else { @@ -185,7 +185,7 @@ var make_link = function(h, num_lbl) { $('#notebook-container').css('margin-left', 30); $('#notebook-container').css('width', $('#notebook').width() - 30); } else { // original width - $("#notebook-container").css({'width':"82%", 'margin-left':'auto'}) + $("#notebook-container").css({'width':st.nbcontainer_width, 'margin-left':'auto'}) } } } From 1dfafa6df3a14f75fcd8dc67eb2af1dcf7a9ea82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Bercher?= Date: Sat, 20 May 2017 19:13:48 +0200 Subject: [PATCH 3/5] [toc2] Restore cells to original width, see #993, following @jcb91 --- src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js b/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js index ac24f4dfe..54f39718b 100644 --- a/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js +++ b/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js @@ -177,7 +177,7 @@ var make_link = function(h, num_lbl) { $('#notebook-container').css('margin-left', 30); $('#notebook-container').css('width', $('#notebook').width() - 30); } else { // original width - $("#notebook-container").css({'width':st.nbcontainer_width, 'margin-left':'auto'}) + $("#notebook-container").css({'width':'', 'margin-left':'auto'}) } } } else { @@ -185,7 +185,7 @@ var make_link = function(h, num_lbl) { $('#notebook-container').css('margin-left', 30); $('#notebook-container').css('width', $('#notebook').width() - 30); } else { // original width - $("#notebook-container").css({'width':st.nbcontainer_width, 'margin-left':'auto'}) + $("#notebook-container").css({'width':'', 'margin-left':'auto'}) } } } From 3245587c01b4126d7d924f3fc5f83440f502aeaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Bercher?= Date: Sat, 20 May 2017 19:29:57 +0200 Subject: [PATCH 4/5] [toc2] Recompute sideBar height on window resize --- .../nbextensions/toc2/toc2.js | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js b/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js index 54f39718b..192da0e91 100644 --- a/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js +++ b/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js @@ -190,6 +190,15 @@ var make_link = function(h, num_lbl) { } } + function setSideBarHeight(cfg, st) { + if (cfg.sideBar) { + var headerVisibleHeight = $('#header').is(':visible') ? $('#header').height() : 0 + $('#toc-wrapper').css('top', liveNotebook ? headerVisibleHeight : 0) + $('#toc-wrapper').css('height', $('#site').height()); + $('#toc').css('height', $('#toc-wrapper').height() - $('#toc-header').height()) + } + } + var create_toc_div = function (cfg,st) { var toc_wrapper = $('
') .append( @@ -282,21 +291,8 @@ var make_link = function(h, num_lbl) { // On header/menu/toolbar resize, resize the toc itself // (if displayed as a sidebar) if (liveNotebook) { - $([Jupyter.events]).on("resize-header.Page", function() { - if (cfg.sideBar) { - $('#toc-wrapper').css('top', liveNotebook ? $('#header').height() : 0) - $('#toc-wrapper').css('height', $('#site').height()); - $('#toc').css('height', $('#toc-wrapper').height() - $('#toc-header').height()) - } - }); - $([Jupyter.events]).on("toggle-all-headers", function() { - if (cfg.sideBar) { - var headerVisibleHeight = $('#header').is(':visible') ? $('#header').height() : 0 - $('#toc-wrapper').css('top', liveNotebook ? headerVisibleHeight : 0) - $('#toc-wrapper').css('height', $('#site').height()); - $('#toc').css('height', $('#toc-wrapper').height() - $('#toc-header').height()) - } - }); + $([Jupyter.events]).on("resize-header.Page", function() {setSideBarHeight(cfg, st);}); + $([Jupyter.events]).on("toggle-all-headers", function() {setSideBarHeight(cfg, st);}); } // enable dragging and save position on stop moving @@ -637,6 +633,7 @@ var table_of_contents = function (cfg,st) { $(window).resize(function(){ $('#toc').css({maxHeight: $(window).height() - 30}); $('#toc-wrapper').css({maxHeight: $(window).height() - 10}); + setSideBarHeight(cfg, st), setNotebookWidth(cfg, st); }); From 521f86c9da083c0bd3111b205b8dbe1ec40e6598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Bercher?= Date: Sun, 21 May 2017 18:08:13 +0200 Subject: [PATCH 5/5] [toc2] Remove extra cell styling and a useless parameter --- .../nbextensions/toc2/toc2.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js b/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js index 192da0e91..ef476b9ae 100644 --- a/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js +++ b/src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js @@ -165,9 +165,8 @@ var make_link = function(h, num_lbl) { callback && callback(); } - function setNotebookWidth(cfg, st, sideBarIsToggling) { + function setNotebookWidth(cfg, st) { //cfg.widenNotebook = true; - var sideBarIsToggling = typeof sideBarIsToggling !== 'undefined' ? sideBarIsToggling : false; if (cfg.sideBar) { if ($('#toc-wrapper').is(':visible')) { $('#notebook-container').css('margin-left', $('#toc-wrapper').width() + 30) @@ -177,7 +176,7 @@ var make_link = function(h, num_lbl) { $('#notebook-container').css('margin-left', 30); $('#notebook-container').css('width', $('#notebook').width() - 30); } else { // original width - $("#notebook-container").css({'width':'', 'margin-left':'auto'}) + $("#notebook-container").css({'width':''}) } } } else { @@ -185,7 +184,7 @@ var make_link = function(h, num_lbl) { $('#notebook-container').css('margin-left', 30); $('#notebook-container').css('width', $('#notebook').width() - 30); } else { // original width - $("#notebook-container").css({'width':'', 'margin-left':'auto'}) + $("#notebook-container").css({'width':''}) } } } @@ -647,7 +646,7 @@ var table_of_contents = function (cfg,st) { //$("#toc-wrapper").toggle({'complete':function(){ $("#toc-wrapper").toggle({ 'progress':function(){ - setNotebookWidth(cfg,st, true); + setNotebookWidth(cfg,st); }, 'complete': function(){ if(liveNotebook){