/usr/lib/python2.7/dist-packages/notebook/static/edit/js/menubar.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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | // Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/namespace',
'base/js/utils',
'base/js/dialog',
'codemirror/lib/codemirror',
'codemirror/mode/meta',
], function($, IPython, utils, dialog, CodeMirror) {
"use strict";
var MenuBar = function (selector, options) {
/**
* Constructor
*
* A MenuBar Class to generate the menubar of IPython notebook
*
* Parameters:
* selector: string
* options: dictionary
* Dictionary of keyword arguments.
* codemirror: CodeMirror instance
* contents: ContentManager instance
* events: $(Events) instance
* base_url : string
* file_path : string
*/
options = options || {};
this.base_url = options.base_url || utils.get_body_data("baseUrl");
this.selector = selector;
this.editor = options.editor;
this.events = options.events;
this.save_widget = options.save_widget;
if (this.selector !== undefined) {
this.element = $(selector);
this.bind_events();
}
this._load_mode_menu();
Object.seal(this);
};
MenuBar.prototype.bind_events = function () {
var that = this;
var editor = that.editor;
// File
this.element.find('#new-file').click(function () {
var w = window.open(undefined, IPython._target);
// Create a new file in the current directory
var parent = utils.url_path_split(editor.file_path)[0];
editor.contents.new_untitled(parent, {type: "file"}).then(
function (data) {
w.location = utils.url_path_join(
that.base_url, 'edit', utils.encode_uri_components(data.path)
);
},
function(error) {
w.close();
dialog.modal({
title : 'Creating New File Failed',
body : "The error was: " + error.message,
buttons : {'OK' : {'class' : 'btn-primary'}}
});
}
);
});
this.element.find('#save-file').click(function () {
editor.save();
});
this.element.find('#rename-file').click(function () {
that.save_widget.rename();
});
this.element.find('#download-file').click(function () {
window.open(utils.url_path_join(
that.base_url, 'files',
utils.encode_uri_components(that.editor.file_path)
) + '?download=1');
});
// Edit
this.element.find('#menu-find').click(function () {
editor.codemirror.execCommand("find");
});
this.element.find('#menu-replace').click(function () {
editor.codemirror.execCommand("replace");
});
this.element.find('#menu-keymap-default').click(function () {
editor.update_codemirror_options({
vimMode: false,
keyMap: 'default'
});
});
this.element.find('#menu-keymap-sublime').click(function () {
editor.update_codemirror_options({
vimMode: false,
keyMap: 'sublime'
});
});
this.element.find('#menu-keymap-emacs').click(function () {
editor.update_codemirror_options({
vimMode: false,
keyMap: 'emacs'
});
});
this.element.find('#menu-keymap-vim').click(function () {
editor.update_codemirror_options({
vimMode: true,
keyMap: 'vim'
});
});
// View
this.element.find('#toggle_header').click(function (){
$("#header-container").toggle();
});
this.element.find('#menu-line-numbers').click(function () {
var current = editor.codemirror.getOption('lineNumbers');
var value = Boolean(1-current);
editor.update_codemirror_options({lineNumbers: value});
});
this.events.on("config_changed.Editor", function () {
var keyMap = editor.codemirror.getOption('keyMap') || 'default';
that.element.find(".selected-keymap").removeClass("selected-keymap");
that.element.find("#menu-keymap-" + keyMap).addClass("selected-keymap");
});
this.events.on("mode_changed.Editor", function (evt, modeinfo) {
that.element.find("#current-mode")
.text(modeinfo.name)
.attr(
'title',
"The current language is " + modeinfo.name
);
});
};
MenuBar.prototype._load_mode_menu = function () {
var list = this.element.find("#mode-menu");
var editor = this.editor;
function make_set_mode(info) {
return function () {
editor.set_codemirror_mode(info);
// save codemirror mode for extension when explicitly selected
editor.save_codemirror_mode(info);
};
}
for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
var info = CodeMirror.modeInfo[i];
list.append($("<li>").append(
$("<a>").attr("href", "#")
.text(info.name)
.click(make_set_mode(info))
.attr('title',
"Set language to " + info.name
)
));
}
};
return {'MenuBar': MenuBar};
});
|