Permalink
Browse files

Merge branch 'htmlnotebook_publish' of https://github.com/stefanv/ipy…

…thon into stefanv-htmlnotebook_publish
  • Loading branch information...
2 parents 7777bdd + 968e3fe commit d5b4ff0ab5fca0d73a333fb36f36e55888f02a8d @ellisonbg ellisonbg committed Aug 18, 2011
@@ -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();
@@ -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));
@@ -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();
};
@@ -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/HTML</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 d5b4ff0

Please sign in to comment.