From 16a82d9cca9092b59d9c962af586ea01a4c57808 2012-01-30 19:50:03 From: Brian Granger Date: 2012-01-30 19:50:03 Subject: [PATCH] Adding new HeadingCell. --- diff --git a/IPython/frontend/html/notebook/static/js/textcell.js b/IPython/frontend/html/notebook/static/js/textcell.js index 19c9744..570be4e 100644 --- a/IPython/frontend/html/notebook/static/js/textcell.js +++ b/IPython/frontend/html/notebook/static/js/textcell.js @@ -286,6 +286,44 @@ var IPython = (function (IPython) { }; + // HTMLCell + + var HeadingCell = function (notebook) { + this.placeholder = "Type Heading Here"; + IPython.TextCell.apply(this, arguments); + this.cell_type = 'heading'; + this.level = 1; + }; + + + HeadingCell.prototype = new TextCell(); + + + HeadingCell.prototype.set_rendered = function (text) { + var r = this.element.find("div.text_cell_render"); + r.empty(); + r.append($('

').html(text)); + } + + + HeadingCell.prototype.get_rendered = function () { + var r = this.element.find("div.text_cell_render"); + return r.children().first().html(); + } + + + HeadingCell.prototype.render = function () { + if (this.rendered === false) { + var text = this.get_text(); + if (text === "") { text = this.placeholder; } + this.set_rendered(text); + this.typeset(); + this.element.find('div.text_cell_input').hide(); + this.element.find("div.text_cell_render").show(); + this.rendered = true; + } + }; + IPython.TextCell = TextCell; IPython.HTMLCell = HTMLCell; IPython.MarkdownCell = MarkdownCell;