Merge pull request #3513 from minrk/nocp

add 'No Checkpoints' to Revert menu
This commit is contained in:
Matthias Bussonnier 2013-07-05 05:03:43 -07:00
commit 2052b1f1cf

View File

@ -233,27 +233,34 @@ var IPython = (function (IPython) {
};
MenuBar.prototype.update_restore_checkpoint = function(checkpoints) {
if (! checkpoints) {
checkpoints = [];
var ul = this.element.find("#restore_checkpoint").find("ul");
ul.empty();
if (! checkpoints || checkpoints.length == 0) {
ul.append(
$("<li/>")
.addClass("disabled")
.append(
$("<a/>")
.text("No checkpoints")
)
);
return;
};
this.element.find("#restore_checkpoint").find("ul").find("li").each(function(i) {
var li = $(this);
var a = li.find("a");
a.off("click");
if (checkpoints.length <= i) {
li.hide();
return;
} else {
li.show();
};
for (var i = 0; i < checkpoints.length; i++) {
var checkpoint = checkpoints[i];
var d = new Date(checkpoint.last_modified);
li.find('a').text(
d.format("mmm dd HH:MM:ss")
).click(function () {
IPython.notebook.restore_checkpoint_dialog(checkpoint);
});
});
ul.append(
$("<li/>").append(
$("<a/>")
.attr("href", "#")
.text(d.format("mmm dd HH:MM:ss"))
.click(function () {
IPython.notebook.restore_checkpoint_dialog(checkpoint);
})
)
);
};
};
IPython.MenuBar = MenuBar;