Work on save widget, kernel status widget and notebook section.

Brian E. Granger 15 years ago
parent 41e20d3f3e
commit 5fb6787570

@ -74,23 +74,39 @@ body {
div#header {
height: 35px;
position: relative;
height: 45px;
padding: 5px;
margin: 0px;
width: 100%
}
span#ipython_notebook {
position: absolute;
}
span#ipython_notebook h1 {
font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
font-size: 22pt;
display: inline;
}
span#save_widget {
position: absolute;
left: 0px;
padding: 5px 0px;
margin: 0px 0px 0px 0px;
}
input#notebook_name {
height: 1em;
line-height: 1em;
padding: 5px;
}
span#kernel_status {
position: absolute;
top: 12%;
padding: 8px 5px 5px 5px;
right: 10px;
font-weight: bold;
}
@ -129,22 +145,27 @@ div.section_content {
padding: 5px;
}
#expand_cell, #collapse_cell, #insert_cell_above, #insert_cell_below,
#move_cell_up, #move_cell_down, #to_code, #to_text, #run_selected_cell,
#run_all_cells, #int_kernel, #restart_kernel, #python_help, #ipython_help,
#numpy_help, #matplotlib_help, #scipy_help, #sympy_help {
width: 65px;
/*#expand_cell, #collapse_cell, #insert_cell_above, #insert_cell_below,*/
/*#move_cell_up, #move_cell_down, #to_code, #to_text, #run_selected_cell,*/
/*#run_all_cells, #int_kernel, #restart_kernel, #python_help, #ipython_help,*/
/*#numpy_help, #matplotlib_help, #scipy_help, #sympy_help, #new_notebook,*/
/*#open_notebook {*/
/* width: 60px;*/
/*}*/
span.section_row_buttons > button {
width: 60px;
}
.cell_section_row {
.section_row {
margin: 5px 0px;
}
.cell_section_row_buttons {
.section_row_buttons {
float: right;
}
.cell_section_row_header {
.section_row_header {
float: left;
font-size: 0.8em;
padding: 0.2em 0em;
@ -158,7 +179,7 @@ span.button_label {
}
/* This is needed because FF was adding a 2px margin top and bottom. */
.cell_section_row .ui-button {
.section_row .ui-button {
margin-top: 0px;
margin-bottom: 0px;
}

@ -73,40 +73,18 @@ var IPython = (function (IPython) {
Kernel.prototype.restart = function () {
this.status_restarting();
IPython.kernel_status_widget.status_restarting();
url = this.kernel_url + "/restart"
var that = this;
$.post(url, function (kernel_id) {
console.log("Kernel restarted: " + kernel_id);
that.kernel_id = kernel_id;
that.kernel_url = that.base_url + "/" + that.kernel_id;
that.status_idle();
IPython.kernel_status_widget.status_idle();
}, 'json');
};
Kernel.prototype.status_busy = function () {
$("#kernel_status").removeClass("status_idle");
$("#kernel_status").removeClass("status_restarting");
$("#kernel_status").addClass("status_busy");
$("#kernel_status").text("Busy");
};
Kernel.prototype.status_idle = function () {
$("#kernel_status").removeClass("status_busy");
$("#kernel_status").removeClass("status_restarting");
$("#kernel_status").addClass("status_idle");
$("#kernel_status").text("Idle");
};
Kernel.prototype.status_restarting = function () {
$("#kernel_status").removeClass("status_busy");
$("#kernel_status").removeClass("status_idle");
$("#kernel_status").addClass("status_restarting");
$("#kernel_status").text("Restarting");
};
IPython.Kernel = Kernel;
return IPython;

@ -474,9 +474,9 @@ var IPython = (function (IPython) {
cell.append_pyerr(content.ename, content.evalue, content.traceback);
} else if (msg_type === "status") {
if (content.execution_state === "busy") {
this.kernel.status_busy();
IPython.kernel_status_widget.status_busy();
} else if (content.execution_state === "idle") {
this.kernel.status_idle();
IPython.kernel_status_widget.status_idle();
};
}
};

@ -17,14 +17,17 @@ $(document).ready(function () {
}
});
$('div#header').addClass('border-box-sizing');
$('div#notebook_app').addClass('border-box-sizing ui-widget ui-widget-content');
$('div#notebook_panel').addClass('border-box-sizing ui-widget');
IPython.layout_manager = new IPython.LayoutManager();
// IPython.save_widget = new IPython.SaveWidget('span#save_widget');
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.notebook = new IPython.Notebook('div#notebook');
IPython.kernel_status_widget = new IPython.KernelStatusWidget('#kernel_status');
IPython.kernel_status_widget.status_idle();
IPython.notebook.insert_code_cell_after();
IPython.layout_manager.do_resize();

@ -11,7 +11,7 @@ var IPython = (function (IPython) {
this.pager_element = $(pager_selector);
this.pager_splitter_element = $(pager_splitter_selector);
this.expanded = true;
this.percentage_height = 0.30;
this.percentage_height = 0.40;
this.style();
this.bind_events();
};

@ -8,26 +8,41 @@ var IPython = (function (IPython) {
var utils = IPython.utils;
var SaveWidget = function (selector) {
this.element = $(selector);
this.create_element();
if (this.element !== undefined) {
this.element.data("cell", this);
this.selector = selector;
if (this.selector !== undefined) {
this.element = $(selector);
this.style();
this.bind_events();
}
};
SaveWidget.prototype.style = function () {
this.element.find('input#notebook_name').addClass('ui-widget ui-widget-content');
this.element.find('button#save_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});
};
SaveWidget.prototype.bind_events = function () {
var that = this;
this.element.find('button#save_notebook').click(function () {
IPython.notebook.save_notebook(that.get_notebook_name());
});
};
// Subclasses must implement create_element.
SaveWidget.prototype.create_element = function () {
this.element.
append($('textarea')).
append($('<button>Save</button>').button());
};
SaveWidget.prototype.get_notebook_name = function () {
return this.element.find('input#notebook_name').attr('value');
}
SaveWidget.prototype.set_notebook_name = function (name) {
this.element.find('input#notebook_name').attr('value',name);
}
IPython.SaveWidget = SaveWidget;

@ -31,12 +31,112 @@
<div id="header">
<span id="ipython_notebook"><h1>IPython Notebook</h1></span>
<span id="save_widget"></span>
<span id="save_widget">
<input type="text" id="notebook_name" size="20"></textarea>
<button id="save_notebook">Save</button>
</span>
<span id="kernel_status">Idle</span>
</div>
<div id="notebook_app">
<div id="left_panel"></div>
<div id="left_panel">
<div id="notebook_section">
<h3 class="section_header">Notebook</h3>
<div class="section_content">
<div class="section_row">
<span id="new_open" class="section_row_buttons">
<button id="new_notebook">New</button>
<button id="open_notebook">Open</button>
</span>
<span class="section_row_header">Actions</span>
</div>
</div>
</div>
<div id="cell_section">
<h3 class="section_header">Cell</h3>
<div class="section_content">
<div class="section_row">
<span class="section_row_buttons">
<button id="delete_cell">Delete</button>
</span>
<span class="section_row_header">Actions</span>
</div>
<div class="section_row">
<span id="insert" class="section_row_buttons">
<button id="insert_cell_above">Above</button>
<button id="insert_cell_below">Below</button>
</span>
<span class="button_label">Insert</span>
</div>
<div class="section_row">
<span id="move" class="section_row_buttons">
<button id="move_cell_up">Up</button>
<button id="move_cell_down">Down</button>
</span>
<span class="button_label">Move</span>
</div>
<div class="section_row">
<span id="cell_type" class="section_row_buttons">
<button id="to_code">Code</button>
<button id="to_text">Text</button>
</span>
<span class="button_label">Cell Type</span>
</div>
<div class="section_row">
<span id="toggle_output" class="section_row_buttons">
<button id="collapse_cell">Collapse</button>
<button id="expand_cell">Expand</button>
</span>
<span class="button_label">Output</span>
</div>
<div class="section_row">
<span id="run_cells" class="section_row_buttons">
<button id="run_selected_cell">Selected</button>
<button id="run_all_cells">All</button>
</span>
<span class="button_label">Run</span>
</div>
</div>
</div>
<div id="kernel_section">
<h3 class="section_header">Kernel</h3>
<div class="section_content">
<div class="section_row">
<span id="int_restart" class="section_row_buttons">
<button id="int_kernel">Interrupt</button>
<button id="restart_kernel">Restart</button>
</span>
<span class="section_row_header">Actions</span>
</div>
</div>
</div>
<div id="help_section">
<h3 class="section_header">Help</h3>
<div class="section_content">
<div class="section_row">
<span id="help_buttons0" class="section_row_buttons">
<button id="python_help"><a href="http://docs.python.org" target="_blank">Python</a></button>
<button id="ipython_help"><a href="http://ipython.org/documentation.html" target="_blank">IPython</a></button>
<button id="numpy_help"><a href="http://docs.scipy.org/doc/numpy/reference/" target="_blank">NumPy</a></button>
</span>
<span class="section_row_header">Links</span>
</div>
<div class="section_row">
<span id="help_buttons1" class="section_row_buttons">
<button id="matplotlib_help"><a href="http://matplotlib.sourceforge.net/" target="_blank">MPL</a></button>
<button id="scipy_help"><a href="http://docs.scipy.org/doc/scipy/reference/" target="_blank">SciPy</a></button>
<button id="sympy_help"><a href="http://docs.sympy.org/dev/index.html" target="_blank">SymPy</a></button>
</span>
</div>
</div>
</div>
</div>
<div id="left_panel_splitter"></div>
<div id="notebook_panel">
<div id="notebook"></div>
@ -55,6 +155,7 @@
<script src="static/js/codecell.js" type="text/javascript" charset="utf-8"></script>
<script src="static/js/textcell.js" type="text/javascript" charset="utf-8"></script>
<script src="static/js/kernel.js" type="text/javascript" charset="utf-8"></script>
<script src="static/js/kernelstatus.js" type="text/javascript" charset="utf-8"></script>
<script src="static/js/layout.js" type="text/javascript" charset="utf-8"></script>
<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>

Loading…
Cancel
Save