mirror of
https://github.com/jupyter/notebook.git
synced 2025-03-19 13:20:36 +08:00
Merge pull request #6748 from Carreau/cleanup-nb
Some cleanup unused code and missing use-strict
This commit is contained in:
commit
25fd994dba
@ -3,6 +3,7 @@
|
||||
|
||||
var IPython = IPython || {};
|
||||
define([], function(){
|
||||
"use strict";
|
||||
IPython.version = "3.0.0-dev";
|
||||
return IPython;
|
||||
});
|
||||
|
@ -40,6 +40,7 @@ define([
|
||||
slideshow_celltoolbar,
|
||||
scrollmanager
|
||||
) {
|
||||
"use strict";
|
||||
|
||||
var Notebook = function (selector, options) {
|
||||
// Constructor
|
||||
@ -99,7 +100,7 @@ define([
|
||||
}
|
||||
utils.requireCodeMirrorMode(lang, function () {
|
||||
var el = document.createElement("div");
|
||||
mode = CodeMirror.getMode({}, lang);
|
||||
var mode = CodeMirror.getMode({}, lang);
|
||||
if (!mode) {
|
||||
console.log("No CodeMirror mode: " + lang);
|
||||
callback(null, code);
|
||||
@ -149,21 +150,25 @@ define([
|
||||
this.codemirror_mode = 'ipython';
|
||||
this.create_elements();
|
||||
this.bind_events();
|
||||
this.save_notebook = function() { // don't allow save until notebook_loaded
|
||||
this.save_notebook_error(null, null, "Load failed, save is disabled");
|
||||
};
|
||||
this.kernel_selector = null;
|
||||
this.dirty = null;
|
||||
this.trusted = null;
|
||||
this._fully_loaded = false;
|
||||
|
||||
// Trigger cell toolbar registration.
|
||||
default_celltoolbar.register(this);
|
||||
rawcell_celltoolbar.register(this);
|
||||
slideshow_celltoolbar.register(this);
|
||||
|
||||
// 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.
|
||||
Notebook: {
|
||||
default_cell_type: 'code',
|
||||
default_cell_type: 'code'
|
||||
}
|
||||
};
|
||||
|
||||
@ -880,7 +885,7 @@ define([
|
||||
config: this.config,
|
||||
keyboard_manager: this.keyboard_manager,
|
||||
notebook: this,
|
||||
tooltip: this.tooltip,
|
||||
tooltip: this.tooltip
|
||||
};
|
||||
switch(type) {
|
||||
case 'code':
|
||||
@ -1116,7 +1121,7 @@ define([
|
||||
'## This is a level 2 heading'
|
||||
)),
|
||||
buttons : {
|
||||
"OK" : {},
|
||||
"OK" : {}
|
||||
}
|
||||
});
|
||||
};
|
||||
@ -1913,6 +1918,12 @@ define([
|
||||
* @method save_notebook
|
||||
*/
|
||||
Notebook.prototype.save_notebook = function () {
|
||||
if(!this._fully_loaded){
|
||||
this.events.trigger('notebook_save_failed.Notebook',
|
||||
new Error("Load failed, save is disabled")
|
||||
);
|
||||
return;
|
||||
}
|
||||
// Create a JSON model to be sent to the server.
|
||||
var model = {
|
||||
type : "notebook",
|
||||
@ -2240,7 +2251,7 @@ define([
|
||||
}
|
||||
|
||||
// now that we're fully loaded, it is safe to restore save functionality
|
||||
delete(this.save_notebook);
|
||||
this._fully_loaded = true;
|
||||
this.events.trigger('notebook_loaded.Notebook');
|
||||
};
|
||||
|
||||
|
@ -179,29 +179,6 @@ define([
|
||||
// easy access for julia monkey patching.
|
||||
Tooltip.last_token_re = /[a-z_][0-9a-z._]*$/gi;
|
||||
|
||||
Tooltip.prototype.extract_oir_token = function(line){
|
||||
// use internally just to make the request to the kernel
|
||||
// Feel free to shorten this logic if you are better
|
||||
// than me in regEx
|
||||
// basicaly you shoul be able to get xxx.xxx.xxx from
|
||||
// something(range(10), kwarg=smth) ; xxx.xxx.xxx( firstarg, rand(234,23), kwarg1=2,
|
||||
// remove everything between matchin bracket (need to iterate)
|
||||
var matchBracket = /\([^\(\)]+\)/g;
|
||||
var endBracket = /\([^\(]*$/g;
|
||||
var oldline = line;
|
||||
|
||||
line = line.replace(matchBracket, "");
|
||||
while (oldline != line) {
|
||||
oldline = line;
|
||||
line = line.replace(matchBracket, "");
|
||||
}
|
||||
// remove everything after last open bracket
|
||||
line = line.replace(endBracket, "");
|
||||
// reset the regex object
|
||||
Tooltip.last_token_re.lastIndex = 0;
|
||||
return Tooltip.last_token_re.exec(line);
|
||||
};
|
||||
|
||||
Tooltip.prototype._request_tooltip = function (cell, text, cursor_pos) {
|
||||
var callbacks = $.proxy(this._show, this);
|
||||
var msg_id = cell.kernel.inspect(text, cursor_pos, callbacks);
|
||||
|
Loading…
x
Reference in New Issue
Block a user