add Revert to the menu bar

MinRK 13 years ago
parent 5bc55ba984
commit e119a6469b

@ -87,6 +87,8 @@ var IPython = (function (IPython) {
this.element.find('#save_checkpoint').click(function () {
IPython.notebook.save_checkpoint();
});
this.element.find('#restore_checkpoint').click(function () {
});
this.element.find('#download_ipynb').click(function () {
var notebook_id = IPython.notebook.get_notebook_id();
var url = that.baseProjectUrl() + 'notebooks/' +
@ -221,8 +223,34 @@ var IPython = (function (IPython) {
this.element.find('#keyboard_shortcuts').click(function () {
IPython.quick_help.show_keyboard_shortcuts();
});
this.update_restore_checkpoint(null);
$([IPython.events]).on('checkpoints_listed.Notebook', function (event, data) {
that.update_restore_checkpoint(data);
});
$([IPython.events]).on('checkpoint_created.Notebook', function (event, data) {
that.update_restore_checkpoint(data);
});
};
MenuBar.prototype.update_restore_checkpoint = function(checkpoint) {
if (!checkpoint) {
this.element.find("#restore_checkpoint")
.addClass('ui-state-disabled')
.off('click')
.find('a').text("Revert");
return;
};
var d = new Date(checkpoint.last_modified);
this.element.find("#restore_checkpoint")
.removeClass('ui-state-disabled')
.off('click')
.click(function () {
IPython.notebook.restore_checkpoint_dialog();
}).find('a').html("Revert to: <br/>" + d.format("mmm dd HH:MM:ss"));
}
IPython.MenuBar = MenuBar;

@ -1696,10 +1696,13 @@ var IPython = (function (IPython) {
});
}
// Create the kernel after the notebook is completely loaded to prevent
// code execution upon loading, which is a security risk.
if (! this.read_only) {
this.start_kernel();
// load our checkpoint list
IPython.notebook.list_checkpoints();
}
$([IPython.events]).trigger('notebook_loaded.Notebook');
};

@ -59,6 +59,8 @@ class="notebook_app"
<li id="save_notebook"><a href="#">Save</a></li>
<li id="save_checkpoint"><a href="#">Save Checkpoint</a></li>
<hr/>
<li id="restore_checkpoint"><a href="#">Revert to Checkpoint</a></li>
<hr/>
<li><a href="#">Download as</a>
<ul>
<li id="download_ipynb"><a href="#">IPython (.ipynb)</a></li>

Loading…
Cancel
Save