Show More
@@ -514,6 +514,12 b' define([' | |||||
514 | } |
|
514 | } | |
515 | }; |
|
515 | }; | |
516 |
|
516 | |||
|
517 | var mergeopt = function(_class, options, overwrite){ | |||
|
518 | options = options || {}; | |||
|
519 | overwrite = overwrite || {}; | |||
|
520 | return $.extend(true, {}, _class.options_default, options, overwrite); | |||
|
521 | }; | |||
|
522 | ||||
517 | var ajax_error_msg = function (jqXHR) { |
|
523 | var ajax_error_msg = function (jqXHR) { | |
518 | // Return a JSON error message if there is one, |
|
524 | // Return a JSON error message if there is one, | |
519 | // otherwise the basic HTTP status text. |
|
525 | // otherwise the basic HTTP status text. | |
@@ -552,6 +558,7 b' define([' | |||||
552 | platform: platform, |
|
558 | platform: platform, | |
553 | is_or_has : is_or_has, |
|
559 | is_or_has : is_or_has, | |
554 | is_focused : is_focused, |
|
560 | is_focused : is_focused, | |
|
561 | mergeopt: mergeopt, | |||
555 | ajax_error_msg : ajax_error_msg, |
|
562 | ajax_error_msg : ajax_error_msg, | |
556 | log_ajax_error : log_ajax_error, |
|
563 | log_ajax_error : log_ajax_error, | |
557 | }; |
|
564 | }; |
@@ -42,7 +42,7 b' define([' | |||||
42 | options = options || {}; |
|
42 | options = options || {}; | |
43 | this.keyboard_manager = options.keyboard_manager; |
|
43 | this.keyboard_manager = options.keyboard_manager; | |
44 | this.events = options.events; |
|
44 | this.events = options.events; | |
45 |
var config = t |
|
45 | var config = utils.mergeopt(Cell, options.config); | |
46 | // superclass default overwrite our default |
|
46 | // superclass default overwrite our default | |
47 |
|
47 | |||
48 | this.placeholder = config.placeholder || ''; |
|
48 | this.placeholder = config.placeholder || ''; | |
@@ -94,12 +94,6 b' define([' | |||||
94 | Cell.options_default.cm_config.dragDrop = false; |
|
94 | Cell.options_default.cm_config.dragDrop = false; | |
95 | } |
|
95 | } | |
96 |
|
96 | |||
97 | Cell.prototype.mergeopt = function(_class, options, overwrite){ |
|
|||
98 | options = options || {}; |
|
|||
99 | overwrite = overwrite || {}; |
|
|||
100 | return $.extend(true, {}, _class.options_default, options, overwrite); |
|
|||
101 | }; |
|
|||
102 |
|
||||
103 | /** |
|
97 | /** | |
104 | * Empty. Subclasses must implement create_element. |
|
98 | * Empty. Subclasses must implement create_element. | |
105 | * This should contain all the code to create the DOM element in notebook |
|
99 | * This should contain all the code to create the DOM element in notebook |
@@ -76,7 +76,7 b' define([' | |||||
76 | onKeyEvent: $.proxy(this.handle_keyevent,this) |
|
76 | onKeyEvent: $.proxy(this.handle_keyevent,this) | |
77 | }; |
|
77 | }; | |
78 |
|
78 | |||
79 |
var config = t |
|
79 | var config = utils.mergeopt(CodeCell, this.config, {cm_config: cm_overwrite_options}); | |
80 | Cell.apply(this,[{ |
|
80 | Cell.apply(this,[{ | |
81 | config: config, |
|
81 | config: config, | |
82 | keyboard_manager: options.keyboard_manager, |
|
82 | keyboard_manager: options.keyboard_manager, |
@@ -3,13 +3,14 b'' | |||||
3 |
|
3 | |||
4 | define([ |
|
4 | define([ | |
5 | 'base/js/namespace', |
|
5 | 'base/js/namespace', | |
|
6 | 'base/js/utils', | |||
6 | 'jquery', |
|
7 | 'jquery', | |
7 | 'notebook/js/cell', |
|
8 | 'notebook/js/cell', | |
8 | 'base/js/security', |
|
9 | 'base/js/security', | |
9 | 'notebook/js/mathjaxutils', |
|
10 | 'notebook/js/mathjaxutils', | |
10 | 'notebook/js/celltoolbar', |
|
11 | 'notebook/js/celltoolbar', | |
11 | 'components/marked/lib/marked', |
|
12 | 'components/marked/lib/marked', | |
12 | ], function(IPython, $, cell, security, mathjaxutils, celltoolbar, marked) { |
|
13 | ], function(IPython, utils, $, cell, security, mathjaxutils, celltoolbar, marked) { | |
13 | "use strict"; |
|
14 | "use strict"; | |
14 | var Cell = cell.Cell; |
|
15 | var Cell = cell.Cell; | |
15 |
|
16 | |||
@@ -40,7 +41,7 b' define([' | |||||
40 | var cm_overwrite_options = { |
|
41 | var cm_overwrite_options = { | |
41 | onKeyEvent: $.proxy(this.handle_keyevent,this) |
|
42 | onKeyEvent: $.proxy(this.handle_keyevent,this) | |
42 | }; |
|
43 | }; | |
43 |
var config = t |
|
44 | var config = utils.mergeopt(TextCell, this.config, {cm_config:cm_overwrite_options}); | |
44 | Cell.apply(this, [{ |
|
45 | Cell.apply(this, [{ | |
45 | config: config, |
|
46 | config: config, | |
46 | keyboard_manager: options.keyboard_manager, |
|
47 | keyboard_manager: options.keyboard_manager, | |
@@ -230,7 +231,7 b' define([' | |||||
230 | // keyboard_manager: KeyboardManager instance |
|
231 | // keyboard_manager: KeyboardManager instance | |
231 | // notebook: Notebook instance |
|
232 | // notebook: Notebook instance | |
232 | options = options || {}; |
|
233 | options = options || {}; | |
233 |
var config = t |
|
234 | var config = utils.mergeopt(MarkdownCell, options.config); | |
234 | TextCell.apply(this, [$.extend({}, options, {config: config})]); |
|
235 | TextCell.apply(this, [$.extend({}, options, {config: config})]); | |
235 |
|
236 | |||
236 | this.cell_type = 'markdown'; |
|
237 | this.cell_type = 'markdown'; | |
@@ -283,7 +284,7 b' define([' | |||||
283 | // keyboard_manager: KeyboardManager instance |
|
284 | // keyboard_manager: KeyboardManager instance | |
284 | // notebook: Notebook instance |
|
285 | // notebook: Notebook instance | |
285 | options = options || {}; |
|
286 | options = options || {}; | |
286 |
var config = t |
|
287 | var config = utils.mergeopt(RawCell, options.config); | |
287 | TextCell.apply(this, [$.extend({}, options, {config: config})]); |
|
288 | TextCell.apply(this, [$.extend({}, options, {config: config})]); | |
288 |
|
289 | |||
289 | // RawCell should always hide its rendered div |
|
290 | // RawCell should always hide its rendered div | |
@@ -343,7 +344,7 b' define([' | |||||
343 | // keyboard_manager: KeyboardManager instance |
|
344 | // keyboard_manager: KeyboardManager instance | |
344 | // notebook: Notebook instance |
|
345 | // notebook: Notebook instance | |
345 | options = options || {}; |
|
346 | options = options || {}; | |
346 |
var config = t |
|
347 | var config = utils.mergeopt(HeadingCell, options.config); | |
347 | TextCell.apply(this, [$.extend({}, options, {config: config})]); |
|
348 | TextCell.apply(this, [$.extend({}, options, {config: config})]); | |
348 |
|
349 | |||
349 | this.level = 1; |
|
350 | this.level = 1; |
General Comments 0
You need to be logged in to leave comments.
Login now