Skip to content
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

[toc2] update for cells width ans sidebar height #994

Merged
merged 5 commits into from
May 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 15 additions & 18 deletions src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ var make_link = function(h, num_lbl) {
}

function setNotebookWidth(cfg, st) {
//cfg.widenNotebook = false;
//cfg.widenNotebook = true;
if (cfg.sideBar) {
if ($('#toc-wrapper').is(':visible')) {
$('#notebook-container').css('margin-left', $('#toc-wrapper').width() + 30)
Expand All @@ -176,19 +176,28 @@ 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':''})
}
}
} else {
if (cfg.widenNotebook) {
$('#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':''})
}
}
}

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 = $('<div id="toc-wrapper"/>')
.append(
Expand Down Expand Up @@ -281,21 +290,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
Expand Down Expand Up @@ -636,6 +632,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);
});

Expand Down