Skip to content

Commit

Permalink
Refactoring of text/markdown/rst/html cells.
Browse files Browse the repository at this point in the history
  • Loading branch information
ellisonbg committed Aug 9, 2011
1 parent f5f6198 commit fbce942
Show file tree
Hide file tree
Showing 10 changed files with 316 additions and 415 deletions.
45 changes: 4 additions & 41 deletions IPython/frontend/html/notebook/static/css/notebook.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ div.section_content {


span.section_row_buttons > button {
width: 60px;
width: 70px;
}

.section_row {
Expand Down Expand Up @@ -205,31 +205,15 @@ div.output_html {
div.output_png {
}

div.html_cell {
div.text_cell {
background-color: white;
}

div.html_cell_input {
color: black;
}

div.html_cell_render {
font-family: "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
/* Slightly bigger than the rest of the notebook */
font-size: 116%;
outline: none;
resize: none;
width: inherit;
border-style: none;
padding: 5px;
color: black;
}

div.rst_cell_input {
div.text_cell_input {
color: black;
}

div.rst_cell_render {
div.text_cell_render {
font-family: "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
/* Slightly bigger than the rest of the notebook */
font-size: 116%;
Expand All @@ -241,27 +225,6 @@ div.rst_cell_render {
color: black;
}

.rendered_html {color: black;}
.rendered_html em {font-style: italic;}
.rendered_html strong {font-weight: bold;}
.rendered_html u {text-decoration: underline;}
.rendered_html :link { text-decoration: underline }
.rendered_html :visited { text-decoration: underline }
.rendered_html h1 {font-size: 197%; margin: .67em 0; font-weight: bold;}
.rendered_html h2 {font-size: 153.9%; margin: .75em 0; font-weight: bold;}
.rendered_html h3 {font-size: 116%; margin: .83em 0; font-weight: bold;}
.rendered_html h4 {margin: 1.12em 0; font-weight: bold;}
.rendered_html h5 {font-size: 85%.; margin: 1.5em 0; font-weight: bold;}
.rendered_html h6 {font-size: 77%; margin: 1.67em 0; font-weight: bold;}
.rendered_html ul {list-style:disc; margin-left: 40px;}
.rendered_html ul ul {list-style:square; margin-left: 40px;}
.rendered_html ul ul ul {list-style:circle; margin-left: 40px;}
.rendered_html ol {list-style:upper-roman; margin-left: 40px;}
.rendered_html ol ol {list-style:upper-alpha;}
.rendered_html ol ol ol {list-style:decimal;}
.rendered_html ol ol ol ol {list-style:lower-alpha;}
.rendered_html ol ol ol ol ol {list-style:lower-roman;}

.CodeMirror {
line-height: 1.231; /* Changed from 1em to our global default */
}
Expand Down
20 changes: 20 additions & 0 deletions IPython/frontend/html/notebook/static/css/renderedhtml.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.rendered_html {color: black;}
.rendered_html em {font-style: italic;}
.rendered_html strong {font-weight: bold;}
.rendered_html u {text-decoration: underline;}
.rendered_html :link { text-decoration: underline }
.rendered_html :visited { text-decoration: underline }
.rendered_html h1 {font-size: 197%; margin: .67em 0; font-weight: bold;}
.rendered_html h2 {font-size: 153.9%; margin: .75em 0; font-weight: bold;}
.rendered_html h3 {font-size: 116%; margin: .83em 0; font-weight: bold;}
.rendered_html h4 {margin: 1.12em 0; font-weight: bold;}
.rendered_html h5 {font-size: 85%.; margin: 1.5em 0; font-weight: bold;}
.rendered_html h6 {font-size: 77%; margin: 1.67em 0; font-weight: bold;}
.rendered_html ul {list-style:disc; margin-left: 40px;}
.rendered_html ul ul {list-style:square; margin-left: 40px;}
.rendered_html ul ul ul {list-style:circle; margin-left: 40px;}
.rendered_html ol {list-style:upper-roman; margin-left: 40px;}
.rendered_html ol ol {list-style:upper-alpha;}
.rendered_html ol ol ol {list-style:decimal;}
.rendered_html ol ol ol ol {list-style:lower-alpha;}
.rendered_html ol ol ol ol ol {list-style:lower-roman;}
2 changes: 1 addition & 1 deletion IPython/frontend/html/notebook/static/js/cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var IPython = (function (IPython) {
Cell.prototype.select = function () {
this.element.addClass('ui-widget-content ui-corner-all');
this.selected = true;
// TODO: we need t test across browsers to see if both of these are needed.
// TODO: we need to test across browsers to see if both of these are needed.
// In the meantime, there should not be any harm in having them both.
this.element.find('textarea').trigger('focusin');
this.element.find('textarea').trigger('focus');
Expand Down
156 changes: 0 additions & 156 deletions IPython/frontend/html/notebook/static/js/htmlcell.js

This file was deleted.

2 changes: 1 addition & 1 deletion IPython/frontend/html/notebook/static/js/leftpanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var IPython = (function (IPython) {
this.left_panel_element = $(left_panel_selector);
this.left_panel_splitter_element = $(left_panel_splitter_selector);
this.expanded = true;
this.width = 250;
this.width = 300;
this.style();
this.bind_events();
this.create_children();
Expand Down
25 changes: 16 additions & 9 deletions IPython/frontend/html/notebook/static/js/notebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,21 +342,21 @@ var IPython = (function (IPython) {
}


Notebook.prototype.insert_rst_cell_before = function (index) {
Notebook.prototype.insert_markdown_cell_before = function (index) {
// TODO: Bounds check for i
var i = this.index_or_selected(index);
var cell = new IPython.RSTCell(this);
var cell = new IPython.MarkdownCell(this);
cell.config_mathjax();
this.insert_cell_before(cell, i);
this.select(this.find_cell_index(cell));
return cell;
}


Notebook.prototype.insert_rst_cell_after = function (index) {
Notebook.prototype.insert_markdown_cell_after = function (index) {
// TODO: Bounds check for i
var i = this.index_or_selected(index);
var cell = new IPython.RSTCell(this);
var cell = new IPython.MarkdownCell(this);
cell.config_mathjax();
this.insert_cell_after(cell, i);
this.select(this.find_cell_index(cell));
Expand All @@ -369,7 +369,8 @@ var IPython = (function (IPython) {
var i = this.index_or_selected(index);
var source_element = this.cell_elements().eq(i);
var source_cell = source_element.data("cell");
if (source_cell instanceof IPython.HTMLCell || source_cell instanceof IPython.RSTCell) {
if (source_cell instanceof IPython.HTMLCell ||
source_cell instanceof IPython.MarkdownCell) {
this.insert_code_cell_after(i);
var target_cell = this.cells()[i+1];
target_cell.set_code(source_cell.get_source());
Expand All @@ -378,20 +379,23 @@ var IPython = (function (IPython) {
};


Notebook.prototype.to_rst = function (index) {
Notebook.prototype.to_markdown = function (index) {
// TODO: Bounds check for i
var i = this.index_or_selected(index);
var source_element = this.cell_elements().eq(i);
var source_cell = source_element.data("cell");
var target_cell = null;
if (source_cell instanceof IPython.CodeCell) {
this.insert_rst_cell_after(i);
this.insert_markdown_cell_after(i);
var target_cell = this.cells()[i+1];
var text = source_cell.get_code();
} else if (source_cell instanceof IPython.HTMLCell) {
this.insert_rst_cell_after(i);
this.insert_markdown_cell_after(i);
var target_cell = this.cells()[i+1];
var text = source_cell.get_source();
if (text === source_cell.placeholder) {
text = target_cell.placeholder;
}
}
if (target_cell !== null) {
if (text === "") {text = target_cell.placeholder;};
Expand All @@ -412,10 +416,13 @@ var IPython = (function (IPython) {
this.insert_html_cell_after(i);
var target_cell = this.cells()[i+1];
var text = source_cell.get_code();
} else if (source_cell instanceof IPython.RSTCell) {
} else if (source_cell instanceof IPython.MarkdownCell) {
this.insert_html_cell_after(i);
var target_cell = this.cells()[i+1];
var text = source_cell.get_source();
if (text === source_cell.placeholder) {
text = target_cell.placeholder;
}
}
if (target_cell !== null) {
if (text === "") {text = target_cell.placeholder;};
Expand Down
4 changes: 2 additions & 2 deletions IPython/frontend/html/notebook/static/js/panelsection.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ var IPython = (function (IPython) {
this.content.find('#to_html').click(function () {
IPython.notebook.to_html();
});
this.content.find('#to_rst').click(function () {
IPython.notebook.to_rst();
this.content.find('#to_markdown').click(function () {
IPython.notebook.to_markdown();
});
this.content.find('#run_selected_cell').click(function () {
IPython.notebook.execute_selected_cell();
Expand Down
Loading

0 comments on commit fbce942

Please sign in to comment.