/usr/lib/python2.7/dist-packages/notebook/static/notebook/js/maintoolbar.js is in python-notebook 5.2.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | // Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'require',
'./toolbar',
'./celltoolbar',
'base/js/i18n'
], function($, require, toolbar, celltoolbar, i18n) {
"use strict";
var MainToolBar = function (selector, options) {
/**
* Constructor
*
* Parameters:
* selector: string
* options: dictionary
* Dictionary of keyword arguments.
* events: $(Events) instance
* notebook: Notebook instance
**/
toolbar.ToolBar.apply(this, [selector, options] );
this.events = options.events;
this.notebook = options.notebook;
this._make();
Object.seal(this);
};
MainToolBar.prototype = Object.create(toolbar.ToolBar.prototype);
MainToolBar.prototype._make = function () {
var grps = [
[
['jupyter-notebook:save-notebook'],
'save-notbook'
],
[
['jupyter-notebook:insert-cell-below'],
'insert_above_below'],
[
['jupyter-notebook:cut-cell',
'jupyter-notebook:copy-cell',
'jupyter-notebook:paste-cell-below'
] ,
'cut_copy_paste'],
[
['jupyter-notebook:move-cell-up',
'jupyter-notebook:move-cell-down'
],
'move_up_down'],
[ [new toolbar.Button('jupyter-notebook:run-cell-and-select-next',
{label: i18n.msg._('Run')}),
'jupyter-notebook:interrupt-kernel',
'jupyter-notebook:confirm-restart-kernel'
],
'run_int'],
['<add_celltype_list>'],
[['jupyter-notebook:show-command-palette']]
];
this.construct(grps);
};
MainToolBar.prototype._pseudo_actions = {};
// add a cell type drop down to the maintoolbar.
// triggered when the pseudo action `<add_celltype_list>` is
// encountered when building a toolbar.
MainToolBar.prototype._pseudo_actions.add_celltype_list = function () {
var that = this;
var multiselect = $('<option/>').attr('value','multiselect').attr('disabled','').text('-');
var sel = $('<select/>')
.attr('id','cell_type')
.addClass('form-control select-xs')
.append($('<option/>').attr('value','code').text(i18n.msg._('Code')))
.append($('<option/>').attr('value','markdown').text(i18n.msg._('Markdown')))
.append($('<option/>').attr('value','raw').text(i18n.msg._('Raw NBConvert')))
.append($('<option/>').attr('value','heading').text(i18n.msg._('Heading')))
.append(multiselect);
this.notebook.keyboard_manager.register_events(sel);
this.events.on('selected_cell_type_changed.Notebook', function (event, data) {
if ( that.notebook.get_selected_cells_indices().length > 1) {
multiselect.show();
sel.val('multiselect');
} else {
multiselect.hide()
if (data.cell_type === 'heading') {
sel.val('Markdown');
} else {
sel.val(data.cell_type);
}
}
});
sel.change(function () {
var cell_type = $(this).val();
switch (cell_type) {
case 'code':
that.notebook.cells_to_code();
break;
case 'markdown':
that.notebook.cells_to_markdown();
break;
case 'raw':
that.notebook.cells_to_raw();
break;
case 'heading':
that.notebook._warn_heading();
that.notebook.to_heading();
sel.val('markdown');
break;
case 'multiselect':
break;
default:
console.log(i18n.msg._("unrecognized cell type:"), cell_type);
}
that.notebook.focus_cell();
});
return sel;
};
return {'MainToolBar': MainToolBar};
});
|