Refactor static printing.

This commit is contained in:
Stefan van der Walt 2011-08-17 17:05:08 -07:00
parent 49ad421c8b
commit 823124215c
4 changed files with 15 additions and 33 deletions

View File

@ -762,24 +762,6 @@ var IPython = (function (IPython) {
};
};
Notebook.prototype.publish_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;
};
Notebook.prototype.notebook_saved = function (data, status, xhr) {
this.dirty = false;

View File

@ -26,6 +26,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 File

@ -21,7 +21,6 @@ var IPython = (function (IPython) {
SaveWidget.prototype.style = function () {
this.element.find('input#notebook_name').addClass('ui-widget ui-widget-content');
this.element.find('button#save_notebook').button();
this.element.find('button#publish_notebook').button();
var left_panel_width = $('div#left_panel').outerWidth();
var left_panel_splitter_width = $('div#left_panel_splitter').outerWidth();
$('span#save_widget').css({marginLeft:left_panel_width+left_panel_splitter_width});
@ -34,10 +33,6 @@ var IPython = (function (IPython) {
IPython.notebook.save_notebook();
that.set_document_title();
});
this.element.find('button#publish_notebook').click(function () {
IPython.notebook.publish_notebook();
});
};
@ -89,23 +84,23 @@ var IPython = (function (IPython) {
SaveWidget.prototype.status_save = function () {
$('button#save_notebook').button('option', 'label', 'Save');
$('button#save_notebook').button('enable');
$('button#publish_notebook').button('enable');
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 () {
$('button#save_notebook').button('option', 'label', 'Saving');
$('button#save_notebook').button('disable');
$('button#publish_notebook').button('disable');
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 () {
$('button#save_notebook').button('option', 'label', 'Loading');
$('button#save_notebook').button('disable');
$('button#publish_notebook').button('disable');
this.element.find('button#save_notebook').button('option', 'label', 'Loading');
this.element.find('button#save_notebook').button('disable');
IPython.print_widget.disable();
};

View File

@ -41,7 +41,6 @@
<input type="text" id="notebook_name" size="20"></textarea>
<span id="notebook_id" style="display:none">{{notebook_id}}</span>
<button id="save_notebook">Save</button>
<button id="publish_notebook">Publish</button>
</span>
<span id="kernel_status">Idle</span>
</div>
@ -69,6 +68,10 @@
</select>
</span>
<span class="section_row_buttons">
<span id="print_widget">
<button id="print_notebook">Print/HTML</button>
</span>
<button id="download_notebook">Export</button>
</span>
</div>
@ -213,6 +216,7 @@
<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>