restore checkpoints in a sub-list

minor styling update to the restore dialog as well
MinRK 13 years ago
parent c1b19755fd
commit 8b5e5a5e09

@ -60,6 +60,7 @@ var IPython = (function (IPython) {
IPython.notebook.select(i);
}
});
this.element.find("#restore_checkpoint").find("ul").find("li").hide();
};
@ -228,26 +229,33 @@ var IPython = (function (IPython) {
});
$([IPython.events]).on('checkpoint_created.Notebook', function (event, data) {
that.update_restore_checkpoint(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;
MenuBar.prototype.update_restore_checkpoint = function(checkpoints) {
if (! checkpoints) {
checkpoints = [];
};
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"));
}
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();
};
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);
});
});
};
IPython.MenuBar = MenuBar;

@ -1839,7 +1839,7 @@ var IPython = (function (IPython) {
} else {
this.last_checkpoint = null;
}
$([IPython.events]).trigger('checkpoints_listed.Notebook', data);
$([IPython.events]).trigger('checkpoints_listed.Notebook', [data]);
};
/**
@ -1894,15 +1894,16 @@ var IPython = (function (IPython) {
$([IPython.events]).trigger('checkpoint_failed.Notebook');
};
Notebook.prototype.restore_checkpoint_dialog = function () {
Notebook.prototype.restore_checkpoint_dialog = function (checkpoint) {
var that = this;
var checkpoint = this.last_checkpoint;
var checkpoint = checkpoint || this.last_checkpoint;
if ( ! checkpoint ) {
console.log("restore dialog, but no checkpoint to restore to!");
return;
}
var dialog = $('<div/>').append(
$('<p/>').text("Are you sure you want to revert the notebook to " +
$('<p/>').addClass("p-space").text(
"Are you sure you want to revert the notebook to " +
"the latest checkpoint?"
).append(
$("<strong/>").text(
@ -1910,9 +1911,11 @@ var IPython = (function (IPython) {
)
)
).append(
$('<p/>').text("The checkpoint was last updated at")
$('<p/>').addClass("p-space").text("The checkpoint was last updated at:")
).append(
$('<p/>').text(Date(checkpoint.last_modified))
$('<p/>').addClass("p-space").text(
Date(checkpoint.last_modified)
).css("text-align", "center")
);
$(document).append(dialog);

@ -57,7 +57,7 @@ var IPython = (function (IPython) {
that.set_save_status('Last Save Failed!');
});
$([IPython.events]).on('checkpoints_listed.Notebook', function (event, data) {
that.set_last_checkpoint(data);
that.set_last_checkpoint(data[0]);
});
$([IPython.events]).on('checkpoint_created.Notebook', function (event, data) {

@ -507,3 +507,7 @@ input.raw_input {
height: 1em;
}
p.p-space {
margin-bottom: 10px;
}

@ -59,7 +59,15 @@ class="notebook_app"
<li id="rename_notebook"><a href="#">Rename...</a></li>
<li id="save_checkpoint"><a href="#">Save and Checkpoint</a></li>
<hr/>
<li id="restore_checkpoint"><a href="#">Revert to Checkpoint</a></li>
<li id="restore_checkpoint"><a href="#">Revert to Checkpoint</a>
<ul>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
</ul>
</li>
<hr/>
<li><a href="#">Download as</a>
<ul>

Loading…
Cancel
Save