add dialog when loading newer minor-version notebooks

This commit is contained in:
MinRK 2012-06-13 02:27:23 -07:00
parent ec50e94524
commit 224f024257

View File

@ -32,6 +32,7 @@ var IPython = (function (IPython) {
this.notebook_name = null;
this.notebook_name_blacklist_re = /[\/\\:]/;
this.nbformat = 3 // Increment this when changing the nbformat
this.nbformat_minor = 0 // Increment this when changing the nbformat
this.style();
this.create_elements();
this.bind_events();
@ -1050,6 +1051,7 @@ var IPython = (function (IPython) {
var data = this.toJSON();
data.metadata.name = this.notebook_name;
data.nbformat = this.nbformat;
data.nbformat_minor = this.nbformat_minor;
// We do the call with settings so we can set cache to false.
var settings = {
processData : false,
@ -1126,6 +1128,31 @@ var IPython = (function (IPython) {
},
width: 400
});
} else if (data.orig_nbformat_minor !== undefined && data.nbformat_minor !== data.orig_nbformat_minor) {
var that = this;
var orig_vs = 'v' + data.nbformat + '.' + data.orig_nbformat_minor;
var this_vs = 'v' + data.nbformat + '.' + this.nbformat_minor;
msg = "This notebook is version " + orig_vs + ", but we only fully support up to " +
this_vs + ". You can still work with this notebook, but some features " +
"introduced in later notebook versions may not be available."
var dialog = $('<div/>');
dialog.html(msg);
this.element.append(dialog);
dialog.dialog({
resizable: false,
modal: true,
title: "Newer Notebook",
closeText: "",
close: function(event, ui) {$(this).dialog('destroy').remove();},
buttons : {
"OK": function () {
$(this).dialog('close');
}
},
width: 400
});
}
// Create the kernel after the notebook is completely loaded to prevent
// code execution upon loading, which is a security risk.