Define `header` and `toolbar` properties for notebook

If `notebook.header` or `notebook.toolbar` are `false`, hide them on
load
Grant Nestor 10 years ago
parent 83785e3533
commit 11d56a23e8

@ -484,6 +484,7 @@ define(function(require){
'toggle-toolbar':{
help: 'hide/show the toolbar',
handler : function(env){
env.notebook.toolbar = !env.notebook.toolbar;
$('div#maintoolbar').toggle();
events.trigger('resize-header.Page');
}
@ -491,6 +492,7 @@ define(function(require){
'toggle-header':{
help: 'hide/show the header',
handler : function(env){
env.notebook.header = !env.notebook.header;
$('#header-container').toggle();
$('.header-bar').toggle();
events.trigger('resize-header.Page');

@ -164,19 +164,56 @@ import {ShortcutEditor} from 'notebook/js/shortcuteditor';
var that = this;
Object.defineProperty(this, 'line_numbers', {
get: function(){
var d = that.config.data||{}
var cmc = (d['Cell']||{})['cm_config']||{}
return cmc['lineNumbers'] || false;
},
set: function(value){
this.get_cells().map(function(c) {
c.code_mirror.setOption('lineNumbers', value);
})
that.config.update({'Cell':{'cm_config':{'lineNumbers':value}}})
}
})
get: function() {
var d = that.config.data || {};
var cmc = (d['Cell'] || {}) ['cm_config'] || {};
return cmc['lineNumbers'] || false;
},
set: function(value) {
this.get_cells().map(function(c) {
c.code_mirror.setOption('lineNumbers', value);
});
that.config.update({
'Cell': {
'cm_config': {
'lineNumbers':value
}
}
});
}
});
Object.defineProperty(this, 'header', {
get: function() {
var d = that.config.data || {};
return d['Header'] || true;
},
set: function(value) {
that.config.update({'Header': value});
}
});
if (!this.header) {
$('#header-container').hide();
$('.header-bar').hide();
this.events.trigger('resize-header.Page');
}
Object.defineProperty(this, 'toolbar', {
get: function() {
var d = that.config.data || {};
return d['Toolbar'] || true;
},
set: function(value) {
that.config.update({'Toolbar': value});
}
});
if (!this.toolbar) {
$('div#maintoolbar').hide();
this.events.trigger('resize-header.Page');
}
// prevent assign to miss-typed properties.
Object.seal(this);
};
@ -578,7 +615,7 @@ import {ShortcutEditor} from 'notebook/js/shortcuteditor';
*/
Notebook.prototype.toggle_all_line_numbers = function () {
this.line_numbers = !this.line_numbers;
}
};
/**
* Get the cell above a given cell.
@ -3185,4 +3222,3 @@ import {ShortcutEditor} from 'notebook/js/shortcuteditor';
this.events.trigger('checkpoint_deleted.Notebook');
this.load_notebook(this.notebook_path);
};

Loading…
Cancel
Save