diff --git a/IPython/html/static/base/js/utils.js b/IPython/html/static/base/js/utils.js index bb903ad..aa85d17 100644 --- a/IPython/html/static/base/js/utils.js +++ b/IPython/html/static/base/js/utils.js @@ -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, }; diff --git a/IPython/html/static/notebook/js/cell.js b/IPython/html/static/notebook/js/cell.js index a747c80..0485ca9 100644 --- a/IPython/html/static/notebook/js/cell.js +++ b/IPython/html/static/notebook/js/cell.js @@ -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 diff --git a/IPython/html/static/notebook/js/codecell.js b/IPython/html/static/notebook/js/codecell.js index c7724c4..2703042 100644 --- a/IPython/html/static/notebook/js/codecell.js +++ b/IPython/html/static/notebook/js/codecell.js @@ -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, diff --git a/IPython/html/static/notebook/js/textcell.js b/IPython/html/static/notebook/js/textcell.js index 3f98da6..f1c93f5 100644 --- a/IPython/html/static/notebook/js/textcell.js +++ b/IPython/html/static/notebook/js/textcell.js @@ -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;