diff --git a/IPython/html/static/notebook/js/cell.js b/IPython/html/static/notebook/js/cell.js index 26ecbd2..b54ade3 100644 --- a/IPython/html/static/notebook/js/cell.js +++ b/IPython/html/static/notebook/js/cell.js @@ -636,7 +636,7 @@ define([ } else { data.metadata = this.metadata; } - this.element.find('.inner_cell').text("Unrecognized cell type: " + data.cell_type); + this.element.find('.inner_cell').find("a").text("Unrecognized cell type: " + data.cell_type); }; UnrecognizedCell.prototype.create_element = function () { @@ -647,10 +647,23 @@ define([ var prompt = $('
').addClass('prompt input_prompt'); cell.append(prompt); var inner_cell = $('').addClass('inner_cell'); - inner_cell.text("Unrecognized cell type"); + inner_cell.append( + $("") + .attr("href", "#") + .text("Unrecognized cell type") + ); cell.append(inner_cell); this.element = cell; }; + + UnrecognizedCell.prototype.bind_events = function () { + Cell.prototype.bind_events.apply(this, arguments); + var cell = this; + + this.element.find('.inner_cell').find("a").click(function () { + cell.events.trigger('unrecognized_cell.Cell', {cell: cell}) + }); + }; // Backwards compatibility. IPython.Cell = Cell; diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js index 9bb3b00..04eb318 100644 --- a/IPython/html/static/notebook/js/notebook.js +++ b/IPython/html/static/notebook/js/notebook.js @@ -147,7 +147,7 @@ define([ this.minimum_autosave_interval = 120000; this.notebook_name_blacklist_re = /[\/\\:]/; this.nbformat = 4; // Increment this when changing the nbformat - this.nbformat_minor = 0; // Increment this when changing the nbformat + this.nbformat_minor = this.current_nbformat_minor = 0; // Increment this when changing the nbformat this.codemirror_mode = 'ipython'; this.create_elements(); this.bind_events(); @@ -207,6 +207,14 @@ define([ that.dirty = true; }); + this.events.on('unrecognized_cell.Cell', function () { + that.warn_nbformat_minor(); + }); + + this.events.on('unrecognized_output.OutputArea', function () { + that.warn_nbformat_minor(); + }); + this.events.on('set_dirty.Notebook', function (event, data) { that.dirty = data.value; }); @@ -300,6 +308,28 @@ define([ return null; }; }; + + Notebook.prototype.warn_nbformat_minor = function (event) { + // trigger a warning dialog about missing functionality from newer minor versions + var v = 'v' + this.nbformat + '.'; + var orig_vs = v + this.nbformat_minor; + var this_vs = v + this.current_nbformat_minor; + var msg = "This notebook is version " + orig_vs + ", but we only fully support up to " + + this_vs + ". You can still work with this notebook, but cell and output types " + + "introduced in later notebook versions will not be available."; + + dialog.modal({ + notebook: this, + keyboard_manager: this.keyboard_manager, + title : "Newer Notebook", + body : msg, + buttons : { + OK : { + "class" : "btn-danger" + } + } + }); + } /** * Set the dirty flag, and trigger the set_dirty.Notebook event @@ -2234,26 +2264,8 @@ define([ } } }); - } else if (orig_nbformat_minor !== undefined && nbmodel.nbformat_minor < orig_nbformat_minor) { - var that = this; - var orig_vs = 'v' + nbmodel.nbformat + '.' + orig_nbformat_minor; - var this_vs = 'v' + nbmodel.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."; - - dialog.modal({ - notebook: this, - keyboard_manager: this.keyboard_manager, - title : "Newer Notebook", - body : msg, - buttons : { - OK : { - class : "btn-danger" - } - } - }); - + } else if (this.nbformat_minor < nbmodel.nbformat_minor) { + this.nbformat_minor = nbmodel.nbformat_minor; } // Create the session after the notebook is completely loaded to prevent diff --git a/IPython/html/static/notebook/js/outputarea.js b/IPython/html/static/notebook/js/outputarea.js index 55bac95..30af73a 100644 --- a/IPython/html/static/notebook/js/outputarea.js +++ b/IPython/html/static/notebook/js/outputarea.js @@ -271,7 +271,6 @@ define([ } var record_output = true; - console.log("appending", json); switch(json.output_type) { case 'execute_result': json = this.validate_mimebundle(json); @@ -490,10 +489,18 @@ define([ OutputArea.prototype.append_unrecognized = function (json) { + var that = this; var toinsert = this.create_output_area(); var subarea = $('').addClass('output_subarea output_unrecognized'); toinsert.append(subarea); - subarea.text("Unrecognized output: " + json.output_type); + subarea.append( + $("") + .attr("href", "#") + .text("Unrecognized output: " + json.output_type) + .click(function () { + that.events.trigger('unrecognized_output.OutputArea', {output: json}) + }) + ); this._safe_append(toinsert); }; diff --git a/IPython/html/static/notebook/less/cell.less b/IPython/html/static/notebook/less/cell.less index 1a5c541..ed4ad4a 100644 --- a/IPython/html/static/notebook/less/cell.less +++ b/IPython/html/static/notebook/less/cell.less @@ -74,6 +74,16 @@ div.unrecognized_cell { color: red; border: 1px solid @light_border_color; background: darken(@cell_background, 5%); + // remove decoration from link + a { + color: inherit; + text-decoration: none; + + &:hover { + color: inherit; + text-decoration: none; + } + } } } @media (max-width: 480px) { diff --git a/IPython/html/static/notebook/less/outputarea.less b/IPython/html/static/notebook/less/outputarea.less index a9f15ed..07f8276 100644 --- a/IPython/html/static/notebook/less/outputarea.less +++ b/IPython/html/static/notebook/less/outputarea.less @@ -177,4 +177,14 @@ div.output_unrecognized { padding: 5px; font-weight: bold; color: red; + // remove decoration from link + a { + color: inherit; + text-decoration: none; + + &:hover { + color: inherit; + text-decoration: none; + } + } } \ No newline at end of file diff --git a/IPython/html/static/style/ipython.min.css b/IPython/html/static/style/ipython.min.css index 0acc29b..5b5c4e3 100644 --- a/IPython/html/static/style/ipython.min.css +++ b/IPython/html/static/style/ipython.min.css @@ -444,6 +444,14 @@ div.unrecognized_cell .inner_cell { border: 1px solid #cfcfcf; background: #eaeaea; } +div.unrecognized_cell .inner_cell a { + color: inherit; + text-decoration: none; +} +div.unrecognized_cell .inner_cell a:hover { + color: inherit; + text-decoration: none; +} @media (max-width: 480px) { div.unrecognized_cell > div.prompt { display: none; @@ -919,11 +927,18 @@ p.p-space { margin-bottom: 10px; } div.output_unrecognized { - border-radius: 4px; padding: 5px; font-weight: bold; color: red; } +div.output_unrecognized a { + color: inherit; + text-decoration: none; +} +div.output_unrecognized a:hover { + color: inherit; + text-decoration: none; +} .rendered_html { color: #000000; /* any extras will just be numbers: */ diff --git a/IPython/html/static/style/style.min.css b/IPython/html/static/style/style.min.css index f0b94db..9d239f1 100644 --- a/IPython/html/static/style/style.min.css +++ b/IPython/html/static/style/style.min.css @@ -8313,6 +8313,14 @@ div.unrecognized_cell .inner_cell { border: 1px solid #cfcfcf; background: #eaeaea; } +div.unrecognized_cell .inner_cell a { + color: inherit; + text-decoration: none; +} +div.unrecognized_cell .inner_cell a:hover { + color: inherit; + text-decoration: none; +} @media (max-width: 480px) { div.unrecognized_cell > div.prompt { display: none; @@ -8788,11 +8796,18 @@ p.p-space { margin-bottom: 10px; } div.output_unrecognized { - border-radius: 4px; padding: 5px; font-weight: bold; color: red; } +div.output_unrecognized a { + color: inherit; + text-decoration: none; +} +div.output_unrecognized a:hover { + color: inherit; + text-decoration: none; +} .rendered_html { color: #000000; /* any extras will just be numbers: */