Skip to content

Commit 225886c

Browse files
authored
Zenmode: Updated main.js
The background will only change when there are images to replace it. The notebook container background is transparent in zenmode.
1 parent 35605b4 commit 225886c

File tree

1 file changed

+22
-14
lines changed
  • src/jupyter_contrib_nbextensions/nbextensions/zenmode

1 file changed

+22
-14
lines changed

src/jupyter_contrib_nbextensions/nbextensions/zenmode/main.js

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* ----------------------------------------------------------------------------
3-
* Copyright (c) 2013 - Damián Avila
3+
* Copyright (c) 2013 - Damián Avila
44
* Copyright (c) 2015 - Joshua Cooke Barnes (jcb91)
55
*
66
* Distributed under the terms of the Modified BSD License.
@@ -60,10 +60,14 @@ define([
6060
$('#zenmode-toggle-btn .fa').removeClass("fa-rebel").addClass("fa-empire");
6161
$('#zenmodecss').remove();
6262

63-
// retrieve and reapply old bg css settings
64-
var oldBg = $('body').attr(oldBgAttrName) || "#ffffff";
65-
$('body').css({"background": oldBg});
6663

64+
// Remove zenmode css settings only when changes were made.
65+
if (backgrounds.length != 0) {
66+
$('body').css({
67+
'background-image': 'none'
68+
})
69+
}
70+
6771
// This should be changed at some point in the future to preserve non-zenmode visibility settings
6872
$(menu_pattern).toggle(true);
6973
$(header_pattern).toggle(true);
@@ -84,16 +88,20 @@ define([
8488
background = requirejs.toUrl("./images/" + background);
8589
}
8690

87-
// save old bg css, then apply new
88-
$('body').attr(oldBgAttrName, ($('body').get(0).style.background || ""));
89-
$('body').css({
90-
'background': 'url(' + background + ') no-repeat center center fixed',
91-
'-webkit-background-size': 'cover',
92-
'-moz-background-size': 'cover',
93-
'-o-background-size': 'cover',
94-
'background-size': 'cover'
95-
});
96-
91+
// Apply zenmode css when there are images to be used.
92+
if (backgrounds.length != 0) {
93+
$('body').css({
94+
'background-image': 'url(' + background + ')',
95+
'background-repeat': 'no-repeat',
96+
'background-position': 'center center',
97+
'background-attachment': 'fixed',
98+
'-webkit-background-size': 'cover',
99+
'-moz-background-size': 'cover',
100+
'-o-background-size': 'cover',
101+
'background-size': 'cover'
102+
});
103+
}
104+
97105
if (hide_menubar)
98106
{$(menu_pattern).toggle(false);}
99107
if (hide_header)

0 commit comments

Comments
 (0)