diff --git a/IPython/frontend/html/notebook/static/js/outputarea.js b/IPython/frontend/html/notebook/static/js/outputarea.js index f38e5abe7..38fe50316 100644 --- a/IPython/frontend/html/notebook/static/js/outputarea.js +++ b/IPython/frontend/html/notebook/static/js/outputarea.js @@ -25,7 +25,7 @@ var IPython = (function (IPython) { this.prompt_area = true; } else { this.prompt_area = prompt_area; - }; + } this.create_elements(); this.style(); this.bind_events(); @@ -107,7 +107,7 @@ var IPython = (function (IPython) { this.collapse_button.show(); } this.collapsed = true; - }; + } }; @@ -117,7 +117,7 @@ var IPython = (function (IPython) { this.element.show(); this.prompt_overlay.show(); this.collapsed = false; - }; + } }; @@ -126,7 +126,7 @@ var IPython = (function (IPython) { this.expand(); } else { this.collapse(); - }; + } }; @@ -148,7 +148,7 @@ var IPython = (function (IPython) { if (this._should_scroll(lines)) { // only allow scrolling long-enough output this.scroll_area(); - }; + } }; @@ -158,7 +158,7 @@ var IPython = (function (IPython) { } else { // only allow scrolling long-enough output this.scroll_if_long(20); - }; + } }; @@ -185,7 +185,7 @@ var IPython = (function (IPython) { json.ename = content.ename; json.evalue = content.evalue; json.traceback = content.traceback; - }; + } // append with dynamic=true this.append_output(json, true); }; @@ -194,25 +194,25 @@ var IPython = (function (IPython) { OutputArea.prototype.convert_mime_types = function (json, data) { if (data['text/plain'] !== undefined) { json.text = data['text/plain']; - }; + } if (data['text/html'] !== undefined) { json.html = data['text/html']; - }; + } if (data['image/svg+xml'] !== undefined) { json.svg = data['image/svg+xml']; - }; + } if (data['image/png'] !== undefined) { json.png = data['image/png']; - }; + } if (data['image/jpeg'] !== undefined) { json.jpeg = data['image/jpeg']; - }; + } if (data['text/latex'] !== undefined) { json.latex = data['text/latex']; - }; + } if (data['application/json'] !== undefined) { json.json = data['application/json']; - }; + } if (data['application/javascript'] !== undefined) { json.javascript = data['application/javascript']; } @@ -232,7 +232,7 @@ var IPython = (function (IPython) { this.append_display_data(json, dynamic); } else if (json.output_type === 'stream') { this.append_stream(json); - }; + } this.outputs.push(json); var that = this; setTimeout(function(){that.element.trigger('resize');}, 100); @@ -259,7 +259,7 @@ var IPython = (function (IPython) { // If we just output latex, typeset it. if ((json.latex !== undefined) || (json.html !== undefined)) { this.typeset(); - }; + } }; @@ -275,7 +275,7 @@ var IPython = (function (IPython) { var toinsert = this.create_output_area(); this.append_text(s, toinsert); this.element.append(toinsert); - }; + } }; @@ -322,26 +322,23 @@ var IPython = (function (IPython) { // If we just output latex, typeset it. if ( (json.latex !== undefined) || (json.html !== undefined) ) { this.typeset(); - }; + } }; + OutputArea.display_order = ['javascript','html','latex','svg','png','jpeg','text']; OutputArea.prototype.append_mime_type = function (json, element, dynamic) { - if (json.javascript !== undefined && dynamic) { - this.append_javascript(json.javascript, element, dynamic); - } else if (json.html !== undefined) { - this.append_html(json.html, element); - } else if (json.latex !== undefined) { - this.append_latex(json.latex, element); - } else if (json.svg !== undefined) { - this.append_svg(json.svg, element); - } else if (json.png !== undefined) { - this.append_png(json.png, element); - } else if (json.jpeg !== undefined) { - this.append_jpeg(json.jpeg, element); - } else if (json.text !== undefined) { - this.append_text(json.text, element); - }; + for(var type_i in OutputArea.display_order){ + var type = OutputArea.display_order[type_i]; + if(json[type] != undefined ){ + if(type == 'javascript' && dynamic){ + this.append_javascript(json.javascript, element, dynamic); + } else { + this['append_'+type](json[type], element); + } + return; + } + } }; @@ -373,7 +370,7 @@ var IPython = (function (IPython) { .addClass('js-error') ); } - } + }; OutputArea.prototype.append_text = function (data, element, extra_class) { @@ -408,7 +405,7 @@ var IPython = (function (IPython) { if (!(h0 && w0)) { // zero size, schedule another timeout that._dblclick_to_reset_size(img); - return + return; } img.resizable({ aspectRatio: true, @@ -422,7 +419,7 @@ var IPython = (function (IPython) { img.width(w0); }); }, 250); - } + }; OutputArea.prototype.append_png = function (png, element) { @@ -454,7 +451,7 @@ var IPython = (function (IPython) { OutputArea.prototype.handle_clear_output = function (content) { this.clear_output(content.stdout, content.stderr, content.other); - } + }; OutputArea.prototype.clear_output = function (stdout, stderr, other) { @@ -527,8 +524,8 @@ var IPython = (function (IPython) { clearTimeout(this.clear_out_timeout); this.clear_out_timeout = null; this.clear_output_callback(this._clear_stdout, this._clear_stderr, this._clear_other); - }; - } + } + }; // JSON serialization @@ -538,7 +535,7 @@ var IPython = (function (IPython) { for (var i=0; i