mirror of
https://github.com/jupyter/notebook.git
synced 2025-02-17 12:39:54 +08:00
move mergeopt to utils
from Cell
This commit is contained in:
parent
9e8cf39956
commit
78fdc1ebb4
@ -514,6 +514,12 @@ define([
|
||||
}
|
||||
};
|
||||
|
||||
var mergeopt = function(_class, options, overwrite){
|
||||
options = options || {};
|
||||
overwrite = overwrite || {};
|
||||
return $.extend(true, {}, _class.options_default, options, overwrite);
|
||||
};
|
||||
|
||||
var ajax_error_msg = function (jqXHR) {
|
||||
// Return a JSON error message if there is one,
|
||||
// otherwise the basic HTTP status text.
|
||||
@ -552,6 +558,7 @@ define([
|
||||
platform: platform,
|
||||
is_or_has : is_or_has,
|
||||
is_focused : is_focused,
|
||||
mergeopt: mergeopt,
|
||||
ajax_error_msg : ajax_error_msg,
|
||||
log_ajax_error : log_ajax_error,
|
||||
};
|
||||
|
@ -42,7 +42,7 @@ define([
|
||||
options = options || {};
|
||||
this.keyboard_manager = options.keyboard_manager;
|
||||
this.events = options.events;
|
||||
var config = this.mergeopt(Cell, options.config);
|
||||
var config = utils.mergeopt(Cell, options.config);
|
||||
// superclass default overwrite our default
|
||||
|
||||
this.placeholder = config.placeholder || '';
|
||||
@ -94,12 +94,6 @@ define([
|
||||
Cell.options_default.cm_config.dragDrop = false;
|
||||
}
|
||||
|
||||
Cell.prototype.mergeopt = function(_class, options, overwrite){
|
||||
options = options || {};
|
||||
overwrite = overwrite || {};
|
||||
return $.extend(true, {}, _class.options_default, options, overwrite);
|
||||
};
|
||||
|
||||
/**
|
||||
* Empty. Subclasses must implement create_element.
|
||||
* This should contain all the code to create the DOM element in notebook
|
||||
|
@ -76,7 +76,7 @@ define([
|
||||
onKeyEvent: $.proxy(this.handle_keyevent,this)
|
||||
};
|
||||
|
||||
var config = this.mergeopt(CodeCell, this.config, {cm_config: cm_overwrite_options});
|
||||
var config = utils.mergeopt(CodeCell, this.config, {cm_config: cm_overwrite_options});
|
||||
Cell.apply(this,[{
|
||||
config: config,
|
||||
keyboard_manager: options.keyboard_manager,
|
||||
|
@ -3,13 +3,14 @@
|
||||
|
||||
define([
|
||||
'base/js/namespace',
|
||||
'base/js/utils',
|
||||
'jquery',
|
||||
'notebook/js/cell',
|
||||
'base/js/security',
|
||||
'notebook/js/mathjaxutils',
|
||||
'notebook/js/celltoolbar',
|
||||
'components/marked/lib/marked',
|
||||
], function(IPython, $, cell, security, mathjaxutils, celltoolbar, marked) {
|
||||
], function(IPython, utils, $, cell, security, mathjaxutils, celltoolbar, marked) {
|
||||
"use strict";
|
||||
var Cell = cell.Cell;
|
||||
|
||||
@ -40,7 +41,7 @@ define([
|
||||
var cm_overwrite_options = {
|
||||
onKeyEvent: $.proxy(this.handle_keyevent,this)
|
||||
};
|
||||
var config = this.mergeopt(TextCell, this.config, {cm_config:cm_overwrite_options});
|
||||
var config = utils.mergeopt(TextCell, this.config, {cm_config:cm_overwrite_options});
|
||||
Cell.apply(this, [{
|
||||
config: config,
|
||||
keyboard_manager: options.keyboard_manager,
|
||||
@ -230,7 +231,7 @@ define([
|
||||
// keyboard_manager: KeyboardManager instance
|
||||
// notebook: Notebook instance
|
||||
options = options || {};
|
||||
var config = this.mergeopt(MarkdownCell, options.config);
|
||||
var config = utils.mergeopt(MarkdownCell, options.config);
|
||||
TextCell.apply(this, [$.extend({}, options, {config: config})]);
|
||||
|
||||
this.cell_type = 'markdown';
|
||||
@ -283,7 +284,7 @@ define([
|
||||
// keyboard_manager: KeyboardManager instance
|
||||
// notebook: Notebook instance
|
||||
options = options || {};
|
||||
var config = this.mergeopt(RawCell, options.config);
|
||||
var config = utils.mergeopt(RawCell, options.config);
|
||||
TextCell.apply(this, [$.extend({}, options, {config: config})]);
|
||||
|
||||
// RawCell should always hide its rendered div
|
||||
@ -343,7 +344,7 @@ define([
|
||||
// keyboard_manager: KeyboardManager instance
|
||||
// notebook: Notebook instance
|
||||
options = options || {};
|
||||
var config = this.mergeopt(HeadingCell, options.config);
|
||||
var config = utils.mergeopt(HeadingCell, options.config);
|
||||
TextCell.apply(this, [$.extend({}, options, {config: config})]);
|
||||
|
||||
this.level = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user