Access config via `ConfigWithDefaults` vs. `ConfigSection`

Move toggle logic to `notebook.js` vs. `actions.js` to be consistent
with `notebook.line_numbers`
Grant Nestor 10 years ago
parent 61eec926fe
commit c656fc0846

@ -462,18 +462,6 @@ define(function(require){
env.notebook.show_command_palette();
}
},
'show-all-line-numbers': {
help : 'show line numbers in all cells, and persist the setting',
handler: function(env) {
env.notebook.line_numbers = true;
}
},
'hide-all-line-numbers': {
help : 'hide line numbers in all cells, and persist the setting',
handler: function(env) {
env.notebook.line_numbers = false;
}
},
'toggle-all-line-numbers': {
help : 'toggles line numbers in all cells, and persist the setting',
icon: 'fa-list-ol',
@ -481,21 +469,16 @@ define(function(require){
env.notebook.line_numbers = !env.notebook.line_numbers;
}
},
'toggle-toolbar':{
help: 'hide/show the toolbar',
handler : function(env){
env.notebook.toolbar = !env.notebook.toolbar;
$('div#maintoolbar').toggle();
events.trigger('resize-header.Page');
}
},
'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');
}
},
'toggle-toolbar':{
help: 'hide/show the toolbar',
handler : function(env){
env.notebook.toolbar = !env.notebook.toolbar;
}
},
'close-pager': {

@ -185,46 +185,58 @@ import {ShortcutEditor} from 'notebook/js/shortcuteditor';
Object.defineProperty(this, 'header', {
get: function() {
if (that.config.data.Header === undefined) return true;
return that.config.data.Header;
return that.class_config.get_sync('Header');
},
set: function(value) {
that.config.update({'Header': value});
if (value === true) {
$('#header-container').show();
$('.header-bar').show();
} else if (value === false) {
$('#header-container').hide();
$('.header-bar').hide();
}
that.events.trigger('resize-header.Page');
that.class_config.set('Header', value);
}
});
Object.defineProperty(this, 'toolbar', {
get: function() {
if (that.config.data.Toolbar === undefined) return true;
return that.config.data.Toolbar;
return that.class_config.get_sync('Toolbar');
},
set: function(value) {
that.config.update({'Toolbar': value});
if (value === true) {
$('div#maintoolbar').show();
} else if (value === false) {
$('div#maintoolbar').hide();
}
that.events.trigger('resize-header.Page');
that.class_config.set('Toolbar', value);
}
});
this.class_config.get('Header').then(function(header) {
if (header === false) {
that.header = false;
}
});
this.config.loaded.then(function() {
if (!that.header) {
$('#header-container').hide();
$('.header-bar').hide();
that.events.trigger('resize-header.Page');
}
if (!that.toolbar) {
$('div#maintoolbar').hide();
that.events.trigger('resize-header.Page');
}
this.class_config.get('Toolbar').then(function(toolbar) {
if (toolbar === false) {
that.toolbar = false;
}
});
// prevent assign to miss-typed properties.
Object.seal(this);
};
Notebook.options_default = {
// can be any cell type, or the special values of
// 'above', 'below', or 'selected' to get the value from another cell.
default_cell_type: 'code'
default_cell_type: 'code',
Header: true,
Toolbar: true
};
/**

Loading…
Cancel
Save