Skip to content
This repository
Browse code

Merge branch 'stefanv-htmlnotebook_publish' into htmlnotebook

  • Loading branch information...
commit d33fac54bff72dbec419c24eb9bbaf9be117a902 2 parents f4c8372 + 898a609
Brian E. Granger ellisonbg authored
12 IPython/frontend/html/notebook/static/css/notebook.css
@@ -184,6 +184,10 @@ div.prompt {
184 184 font-family: monospace;
185 185 }
186 186
  187 +div.input {
  188 + page-break-inside: avoid;
  189 +}
  190 +
187 191 div.input_area {
188 192 color: black;
189 193 }
@@ -203,7 +207,8 @@ div.output_prompt {
203 207
204 208 /* This class is applied to all types of output (pyout, pyerr, stream, display_data) */
205 209 div.output_area {
206   - padding: 0px 0.4em
  210 + padding: 0px 0.4em;
  211 + page-break-inside: avoid;
207 212 }
208 213
209 214 /* This is the output area after the Out[] prompt of type pyout */
@@ -295,3 +300,8 @@ div.text_cell_render {
295 300 font-family: monospace;
296 301 }
297 302
  303 +@media print {
  304 + body { overflow: visible !important; }
  305 + .ui-widget-content { border: 0px; }
  306 +}
  307 +
30 IPython/frontend/html/notebook/static/js/codecell.js
@@ -206,12 +206,12 @@ var IPython = (function (IPython) {
206 206
207 207 CodeCell.prototype.append_pyout = function (json) {
208 208 n = json.prompt_number || ' ';
209   - var toinsert = $("<div/>").addClass("output_pyout hbox");
  209 + var toinsert = $("<div/>").addClass("output_pyout hbox output_area");
210 210 toinsert.append($('<div/>').
211 211 addClass('prompt output_prompt').
212 212 html('Out[' + n + ']:')
213 213 );
214   - this.append_mime_type(json, toinsert).addClass('output_area');
  214 + this.append_mime_type(json, toinsert);
215 215 toinsert.children().last().addClass("box_flex1 pyout_area");
216 216 this.element.find("div.output").append(toinsert);
217 217 // If we just output latex, typeset it.
@@ -252,19 +252,19 @@ var IPython = (function (IPython) {
252 252 CodeCell.prototype.append_mime_type = function (json, element) {
253 253 element = element || this.element.find("div.output");
254 254 if (json.html !== undefined) {
255   - this.append_html(json.html, element);
  255 + inserted = this.append_html(json.html, element);
256 256 } else if (json.latex !== undefined) {
257   - this.append_latex(json.latex, element);
  257 + inserted = this.append_latex(json.latex, element);
258 258 } else if (json.svg !== undefined) {
259   - this.append_svg(json.svg, element);
  259 + inserted = this.append_svg(json.svg, element);
260 260 } else if (json.png !== undefined) {
261   - this.append_png(json.png, element);
  261 + inserted = this.append_png(json.png, element);
262 262 } else if (json.jpeg !== undefined) {
263   - this.append_jpeg(json.jpeg, element);
  263 + inserted = this.append_jpeg(json.jpeg, element);
264 264 } else if (json.text !== undefined) {
265   - this.append_text(json.text, element);
  265 + inserted = this.append_text(json.text, element);
266 266 };
267   - return element;
  267 + return inserted;
268 268 };
269 269
270 270
@@ -273,7 +273,7 @@ var IPython = (function (IPython) {
273 273 var toinsert = $("<div/>").addClass("output_html rendered_html");
274 274 toinsert.append(html);
275 275 element.append(toinsert);
276   - return element;
  276 + return toinsert;
277 277 }
278 278
279 279
@@ -282,7 +282,7 @@ var IPython = (function (IPython) {
282 282 var toinsert = $("<div/>").addClass("output_stream");
283 283 toinsert.append($("<pre/>").html(data));
284 284 element.append(toinsert);
285   - return element;
  285 + return toinsert;
286 286 };
287 287
288 288
@@ -291,7 +291,7 @@ var IPython = (function (IPython) {
291 291 var toinsert = $("<div/>").addClass("output_svg");
292 292 toinsert.append(svg);
293 293 element.append(toinsert);
294   - return element;
  294 + return toinsert;
295 295 };
296 296
297 297
@@ -300,7 +300,7 @@ var IPython = (function (IPython) {
300 300 var toinsert = $("<div/>").addClass("output_png");
301 301 toinsert.append($("<img/>").attr('src','data:image/png;base64,'+png));
302 302 element.append(toinsert);
303   - return element;
  303 + return toinsert;
304 304 };
305 305
306 306
@@ -309,7 +309,7 @@ var IPython = (function (IPython) {
309 309 var toinsert = $("<div/>").addClass("output_jpeg");
310 310 toinsert.append($("<img/>").attr('src','data:image/jpeg;base64,'+jpeg));
311 311 element.append(toinsert);
312   - return element;
  312 + return toinsert;
313 313 };
314 314
315 315
@@ -320,7 +320,7 @@ var IPython = (function (IPython) {
320 320 var toinsert = $("<div/>").addClass("output_latex");
321 321 toinsert.append(latex);
322 322 element.append(toinsert);
323   - return element;
  323 + return toinsert;
324 324 }
325 325
326 326
1  IPython/frontend/html/notebook/static/js/notebook_main.js
@@ -32,6 +32,7 @@ $(document).ready(function () {
32 32 IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter');
33 33 IPython.left_panel = new IPython.LeftPanel('div#left_panel', 'div#left_panel_splitter');
34 34 IPython.save_widget = new IPython.SaveWidget('span#save_widget');
  35 + IPython.print_widget = new IPython.PrintWidget('span#print_widget');
35 36 IPython.notebook = new IPython.Notebook('div#notebook');
36 37 IPython.kernel_status_widget = new IPython.KernelStatusWidget('#kernel_status');
37 38 IPython.kernel_status_widget.status_idle();
54 IPython/frontend/html/notebook/static/js/printwidget.js
... ... @@ -0,0 +1,54 @@
  1 +var IPython = (function (IPython) {
  2 +
  3 + var PrintWidget = function (selector) {
  4 + this.selector = selector;
  5 + if (this.selector !== undefined) {
  6 + this.element = $(selector);
  7 + this.style();
  8 + this.bind_events();
  9 + }
  10 + };
  11 +
  12 + PrintWidget.prototype.style = function () {
  13 + this.element.find('button#print_notebook').button();
  14 + };
  15 +
  16 + PrintWidget.prototype.bind_events = function () {
  17 + var that = this;
  18 + this.element.find('button#print_notebook').click(function () {
  19 + that.print_notebook();
  20 + });
  21 + };
  22 +
  23 + PrintWidget.prototype.enable = function () {
  24 + this.element.find('button#print_notebook').button('enable');
  25 + };
  26 +
  27 + PrintWidget.prototype.disable = function () {
  28 + this.element.find('button#print_notebook').button('disable');
  29 + };
  30 +
  31 + PrintWidget.prototype.print_notebook = function () {
  32 + var w = window.open('', '_blank', 'scrollbars=1,menubar=1');
  33 + var html = '<html><head>' +
  34 + $('head').clone().html() +
  35 + '<style type="text/css">' +
  36 + '@media print { body { overflow: visible !important; } }' +
  37 + '.ui-widget-content { border: 0px; }' +
  38 + '</style>' +
  39 + '</head><body style="overflow: auto;">' +
  40 + $('#notebook').clone().html() +
  41 + '</body></html>';
  42 +
  43 + w.document.open();
  44 + w.document.write(html);
  45 + w.document.close();
  46 +
  47 + return false;
  48 + };
  49 +
  50 + IPython.PrintWidget = PrintWidget;
  51 +
  52 + return IPython;
  53 +
  54 +}(IPython));
13 IPython/frontend/html/notebook/static/js/savewidget.js
@@ -90,20 +90,23 @@ var IPython = (function (IPython) {
90 90
91 91
92 92 SaveWidget.prototype.status_save = function () {
93   - this.element.find('span.ui-button-text').text('Save');
  93 + this.element.find('button#save_notebook').button('option', 'label', 'Save');
94 94 this.element.find('button#save_notebook').button('enable');
95   - };
  95 + IPython.print_widget.enable();
  96 + };
96 97
97 98
98 99 SaveWidget.prototype.status_saving = function () {
99   - this.element.find('span.ui-button-text').text('Saving');
  100 + this.element.find('button#save_notebook').button('option', 'label', 'Saving');
100 101 this.element.find('button#save_notebook').button('disable');
101   - };
  102 + IPython.print_widget.disable();
  103 + };
102 104
103 105
104 106 SaveWidget.prototype.status_loading = function () {
105   - this.element.find('span.ui-button-text').text('Loading');
  107 + this.element.find('button#save_notebook').button('option', 'label', 'Loading');
106 108 this.element.find('button#save_notebook').button('disable');
  109 + IPython.print_widget.disable();
107 110 };
108 111
109 112
5 IPython/frontend/html/notebook/templates/notebook.html
@@ -68,6 +68,10 @@ <h3 class="section_header">Notebook</h3>
68 68 </select>
69 69 </span>
70 70 <span class="section_row_buttons">
  71 + <span id="print_widget">
  72 + <button id="print_notebook">Print</button>
  73 + </span>
  74 +
71 75 <button id="download_notebook">Export</button>
72 76 </span>
73 77 </div>
@@ -212,6 +216,7 @@ <h3 class="section_header">Help</h3>
212 216 <script src="static/js/savewidget.js" type="text/javascript" charset="utf-8"></script>
213 217 <script src="static/js/pager.js" type="text/javascript" charset="utf-8"></script>
214 218 <script src="static/js/panelsection.js" type="text/javascript" charset="utf-8"></script>
  219 +<script src="static/js/printwidget.js" type="text/javascript" charset="utf-8"></script>
215 220 <script src="static/js/leftpanel.js" type="text/javascript" charset="utf-8"></script>
216 221 <script src="static/js/notebook.js" type="text/javascript" charset="utf-8"></script>
217 222 <script src="static/js/notebook_main.js" type="text/javascript" charset="utf-8"></script>

0 comments on commit d33fac5

Please sign in to comment.
Something went wrong with that request. Please try again.