Move toggle logic from property setters in to actions

Grant Nestor 10 years ago
parent c656fc0846
commit 6c1fe1f947

@ -466,19 +466,91 @@ define(function(require){
help : 'toggles line numbers in all cells, and persist the setting',
icon: 'fa-list-ol',
handler: function(env) {
env.notebook.line_numbers = !env.notebook.line_numbers;
var value = !env.notebook.line_numbers;
env.notebook.get_cells().map(function(c) {
c.code_mirror.setOption('lineNumbers', value);
});
env.notebook.line_numbers = value;
}
},
'show-all-line-numbers': {
help : 'show line numbers in all cells, and persist the setting',
handler: function(env) {
env.notebook.get_cells().map(function(c) {
c.code_mirror.setOption('lineNumbers', true);
});
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.get_cells().map(function(c) {
c.code_mirror.setOption('lineNumbers', false);
});
env.notebook.line_numbers = false;
}
},
'toggle-header':{
help: 'hide/show the header',
handler : function(env){
env.notebook.header = !env.notebook.header;
handler : function(env) {
var value = !env.notebook.header;
if (value === true) {
$('#header-container').show();
$('.header-bar').show();
} else if (value === false) {
$('#header-container').hide();
$('.header-bar').hide();
}
events.trigger('resize-header.Page');
env.notebook.header = value;
}
},
'show-header':{
help: 'show the header',
handler : function(env) {
$('#header-container').show();
$('.header-bar').show();
events.trigger('resize-header.Page');
env.notebook.header = true;
}
},
'hide-header':{
help: 'hide the header',
handler : function(env) {
$('#header-container').hide();
$('.header-bar').hide();
events.trigger('resize-header.Page');
env.notebook.header = false;
}
},
'toggle-toolbar':{
help: 'hide/show the toolbar',
handler : function(env){
env.notebook.toolbar = !env.notebook.toolbar;
handler : function(env) {
var value = !env.notebook.toolbar;
if (value === true) {
$('div#maintoolbar').show();
} else if (value === false) {
$('div#maintoolbar').hide();
}
events.trigger('resize-header.Page');
env.notebook.toolbar = value;
}
},
'show-toolbar':{
help: 'show the toolbar',
handler : function(env) {
$('div#maintoolbar').show();
events.trigger('resize-header.Page');
env.notebook.toolbar = true;
}
},
'hide-toolbar':{
help: 'hide the toolbar',
handler : function(env) {
$('div#maintoolbar').hide();
events.trigger('resize-header.Page');
env.notebook.toolbar = false;
}
},
'close-pager': {

@ -170,9 +170,6 @@ import {ShortcutEditor} from 'notebook/js/shortcuteditor';
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': {
@ -188,14 +185,6 @@ import {ShortcutEditor} from 'notebook/js/shortcuteditor';
return that.class_config.get_sync('Header');
},
set: function(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);
}
});
@ -205,26 +194,20 @@ import {ShortcutEditor} from 'notebook/js/shortcuteditor';
return that.class_config.get_sync('Toolbar');
},
set: function(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;
that.keyboard_manager.actions.call('jupyter-notebook:hide-header');
}
});
this.class_config.get('Toolbar').then(function(toolbar) {
if (toolbar === false) {
that.toolbar = false;
}
if (toolbar === false) {
that.keyboard_manager.actions.call('jupyter-notebook:hide-toolbar');
}
});
// prevent assign to miss-typed properties.

Loading…
Cancel
Save