Browse files

Merge branch 'stefanv-htmlnotebook_publish' into htmlnotebook

  • Loading branch information...
2 parents f4c8372 + 898a609 commit d33fac54bff72dbec419c24eb9bbaf9be117a902 @ellisonbg ellisonbg committed Aug 19, 2011
View
12 IPython/frontend/html/notebook/static/css/notebook.css
@@ -184,6 +184,10 @@ div.prompt {
font-family: monospace;
}
+div.input {
+ page-break-inside: avoid;
+}
+
div.input_area {
color: black;
}
@@ -203,7 +207,8 @@ div.output_prompt {
/* This class is applied to all types of output (pyout, pyerr, stream, display_data) */
div.output_area {
- padding: 0px 0.4em
+ padding: 0px 0.4em;
+ page-break-inside: avoid;
}
/* This is the output area after the Out[] prompt of type pyout */
@@ -295,3 +300,8 @@ div.text_cell_render {
font-family: monospace;
}
+@media print {
+ body { overflow: visible !important; }
+ .ui-widget-content { border: 0px; }
+}
+
View
30 IPython/frontend/html/notebook/static/js/codecell.js
@@ -206,12 +206,12 @@ var IPython = (function (IPython) {
CodeCell.prototype.append_pyout = function (json) {
n = json.prompt_number || ' ';
- var toinsert = $("<div/>").addClass("output_pyout hbox");
+ var toinsert = $("<div/>").addClass("output_pyout hbox output_area");
toinsert.append($('<div/>').
addClass('prompt output_prompt').
html('Out[' + n + ']:')
);
- this.append_mime_type(json, toinsert).addClass('output_area');
+ this.append_mime_type(json, toinsert);
toinsert.children().last().addClass("box_flex1 pyout_area");
this.element.find("div.output").append(toinsert);
// If we just output latex, typeset it.
@@ -252,19 +252,19 @@ var IPython = (function (IPython) {
CodeCell.prototype.append_mime_type = function (json, element) {
element = element || this.element.find("div.output");
if (json.html !== undefined) {
- this.append_html(json.html, element);
+ inserted = this.append_html(json.html, element);
} else if (json.latex !== undefined) {
- this.append_latex(json.latex, element);
+ inserted = this.append_latex(json.latex, element);
} else if (json.svg !== undefined) {
- this.append_svg(json.svg, element);
+ inserted = this.append_svg(json.svg, element);
} else if (json.png !== undefined) {
- this.append_png(json.png, element);
+ inserted = this.append_png(json.png, element);
} else if (json.jpeg !== undefined) {
- this.append_jpeg(json.jpeg, element);
+ inserted = this.append_jpeg(json.jpeg, element);
} else if (json.text !== undefined) {
- this.append_text(json.text, element);
+ inserted = this.append_text(json.text, element);
};
- return element;
+ return inserted;
};
@@ -273,7 +273,7 @@ var IPython = (function (IPython) {
var toinsert = $("<div/>").addClass("output_html rendered_html");
toinsert.append(html);
element.append(toinsert);
- return element;
+ return toinsert;
}
@@ -282,7 +282,7 @@ var IPython = (function (IPython) {
var toinsert = $("<div/>").addClass("output_stream");
toinsert.append($("<pre/>").html(data));
element.append(toinsert);
- return element;
+ return toinsert;
};
@@ -291,7 +291,7 @@ var IPython = (function (IPython) {
var toinsert = $("<div/>").addClass("output_svg");
toinsert.append(svg);
element.append(toinsert);
- return element;
+ return toinsert;
};
@@ -300,7 +300,7 @@ var IPython = (function (IPython) {
var toinsert = $("<div/>").addClass("output_png");
toinsert.append($("<img/>").attr('src','data:image/png;base64,'+png));
element.append(toinsert);
- return element;
+ return toinsert;
};
@@ -309,7 +309,7 @@ var IPython = (function (IPython) {
var toinsert = $("<div/>").addClass("output_jpeg");
toinsert.append($("<img/>").attr('src','data:image/jpeg;base64,'+jpeg));
element.append(toinsert);
- return element;
+ return toinsert;
};
@@ -320,7 +320,7 @@ var IPython = (function (IPython) {
var toinsert = $("<div/>").addClass("output_latex");
toinsert.append(latex);
element.append(toinsert);
- return element;
+ return toinsert;
}
View
1 IPython/frontend/html/notebook/static/js/notebook_main.js
@@ -32,6 +32,7 @@ $(document).ready(function () {
IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter');
IPython.left_panel = new IPython.LeftPanel('div#left_panel', 'div#left_panel_splitter');
IPython.save_widget = new IPython.SaveWidget('span#save_widget');
+ IPython.print_widget = new IPython.PrintWidget('span#print_widget');
IPython.notebook = new IPython.Notebook('div#notebook');
IPython.kernel_status_widget = new IPython.KernelStatusWidget('#kernel_status');
IPython.kernel_status_widget.status_idle();
View
54 IPython/frontend/html/notebook/static/js/printwidget.js
@@ -0,0 +1,54 @@
+var IPython = (function (IPython) {
+
+ var PrintWidget = function (selector) {
+ this.selector = selector;
+ if (this.selector !== undefined) {
+ this.element = $(selector);
+ this.style();
+ this.bind_events();
+ }
+ };
+
+ PrintWidget.prototype.style = function () {
+ this.element.find('button#print_notebook').button();
+ };
+
+ PrintWidget.prototype.bind_events = function () {
+ var that = this;
+ this.element.find('button#print_notebook').click(function () {
+ that.print_notebook();
+ });
+ };
+
+ PrintWidget.prototype.enable = function () {
+ this.element.find('button#print_notebook').button('enable');
+ };
+
+ PrintWidget.prototype.disable = function () {
+ this.element.find('button#print_notebook').button('disable');
+ };
+
+ PrintWidget.prototype.print_notebook = function () {
+ var w = window.open('', '_blank', 'scrollbars=1,menubar=1');
+ var html = '<html><head>' +
+ $('head').clone().html() +
+ '<style type="text/css">' +
+ '@media print { body { overflow: visible !important; } }' +
+ '.ui-widget-content { border: 0px; }' +
+ '</style>' +
+ '</head><body style="overflow: auto;">' +
+ $('#notebook').clone().html() +
+ '</body></html>';
+
+ w.document.open();
+ w.document.write(html);
+ w.document.close();
+
+ return false;
+ };
+
+ IPython.PrintWidget = PrintWidget;
+
+ return IPython;
+
+}(IPython));
View
13 IPython/frontend/html/notebook/static/js/savewidget.js
@@ -90,20 +90,23 @@ var IPython = (function (IPython) {
SaveWidget.prototype.status_save = function () {
- this.element.find('span.ui-button-text').text('Save');
+ this.element.find('button#save_notebook').button('option', 'label', 'Save');
this.element.find('button#save_notebook').button('enable');
- };
+ IPython.print_widget.enable();
+ };
SaveWidget.prototype.status_saving = function () {
- this.element.find('span.ui-button-text').text('Saving');
+ this.element.find('button#save_notebook').button('option', 'label', 'Saving');
this.element.find('button#save_notebook').button('disable');
- };
+ IPython.print_widget.disable();
+ };
SaveWidget.prototype.status_loading = function () {
- this.element.find('span.ui-button-text').text('Loading');
+ this.element.find('button#save_notebook').button('option', 'label', 'Loading');
this.element.find('button#save_notebook').button('disable');
+ IPython.print_widget.disable();
};
View
5 IPython/frontend/html/notebook/templates/notebook.html
@@ -68,6 +68,10 @@ <h3 class="section_header">Notebook</h3>
</select>
</span>
<span class="section_row_buttons">
+ <span id="print_widget">
+ <button id="print_notebook">Print</button>
+ </span>
+
<button id="download_notebook">Export</button>
</span>
</div>
@@ -212,6 +216,7 @@ <h3 class="section_header">Help</h3>
<script src="static/js/savewidget.js" type="text/javascript" charset="utf-8"></script>
<script src="static/js/pager.js" type="text/javascript" charset="utf-8"></script>
<script src="static/js/panelsection.js" type="text/javascript" charset="utf-8"></script>
+<script src="static/js/printwidget.js" type="text/javascript" charset="utf-8"></script>
<script src="static/js/leftpanel.js" type="text/javascript" charset="utf-8"></script>
<script src="static/js/notebook.js" type="text/javascript" charset="utf-8"></script>
<script src="static/js/notebook_main.js" type="text/javascript" charset="utf-8"></script>

0 comments on commit d33fac5

Please sign in to comment.