Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OutputArea.append_type functions are not prototype methods #5295

Merged
merged 2 commits into from Mar 10, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 25 additions & 19 deletions IPython/html/static/notebook/js/outputarea.js
Expand Up @@ -425,7 +425,10 @@ var IPython = (function (IPython) {
}
s = s + '\n';
var toinsert = this.create_output_area();
this.append_text(s, {}, toinsert).addClass('output_pyerr');
var append_text = OutputArea.append_map['text/plain'];
if (append_text) {
append_text.apply(this, [s, {}, toinsert]).addClass('output_pyerr');
}
this._safe_append(toinsert);
}
};
Expand All @@ -434,7 +437,7 @@ var IPython = (function (IPython) {
OutputArea.prototype.append_stream = function (json) {
// temporary fix: if stream undefined (json file written prior to this patch),
// default to most likely stdout:
if (json.stream == undefined){
if (json.stream === undefined){
json.stream = 'stdout';
}
var text = json.text;
Expand Down Expand Up @@ -464,7 +467,10 @@ var IPython = (function (IPython) {

// If we got here, attach a new div
var toinsert = this.create_output_area();
this.append_text(text, {}, toinsert).addClass("output_stream "+subclass);
var append_text = OutputArea.append_map['text/plain'];
if (append_text) {
append_text.apply(this, [text, {}, toinsert]).addClass("output_stream " + subclass);
}
this._safe_append(toinsert);
};

Expand Down Expand Up @@ -514,7 +520,7 @@ var IPython = (function (IPython) {
};


OutputArea.prototype.append_html = function (html, md, element) {
var append_html = function (html, md, element) {
var type = 'text/html';
var toinsert = this.create_output_subarea(md, "output_html rendered_html", type);
IPython.keyboard_manager.register_events(toinsert);
Expand All @@ -524,7 +530,7 @@ var IPython = (function (IPython) {
};


OutputArea.prototype.append_javascript = function (js, md, element) {
var append_javascript = function (js, md, element) {
// We just eval the JS code, element appears in the local scope.
var type = 'application/javascript';
var toinsert = this.create_output_subarea(md, "output_javascript", type);
Expand All @@ -545,7 +551,7 @@ var IPython = (function (IPython) {
};


OutputArea.prototype.append_text = function (data, md, element) {
var append_text = function (data, md, element) {
var type = 'text/plain';
var toinsert = this.create_output_subarea(md, "output_text", type);
// escape ANSI & HTML specials in plaintext:
Expand All @@ -560,7 +566,7 @@ var IPython = (function (IPython) {
};


OutputArea.prototype.append_svg = function (svg, md, element) {
var append_svg = function (svg, md, element) {
var type = 'image/svg+xml';
var toinsert = this.create_output_subarea(md, "output_svg", type);
toinsert.append(svg);
Expand Down Expand Up @@ -601,7 +607,7 @@ var IPython = (function (IPython) {
if (width !== undefined) img.attr('width', width);
};

OutputArea.prototype.append_png = function (png, md, element) {
var append_png = function (png, md, element) {
var type = 'image/png';
var toinsert = this.create_output_subarea(md, "output_png", type);
var img = $("<img/>").attr('src','data:image/png;base64,'+png);
Expand All @@ -613,7 +619,7 @@ var IPython = (function (IPython) {
};


OutputArea.prototype.append_jpeg = function (jpeg, md, element) {
var append_jpeg = function (jpeg, md, element) {
var type = 'image/jpeg';
var toinsert = this.create_output_subarea(md, "output_jpeg", type);
var img = $("<img/>").attr('src','data:image/jpeg;base64,'+jpeg);
Expand All @@ -625,7 +631,7 @@ var IPython = (function (IPython) {
};


OutputArea.prototype.append_pdf = function (pdf, md, element) {
var append_pdf = function (pdf, md, element) {
var type = 'application/pdf';
var toinsert = this.create_output_subarea(md, "output_pdf", type);
var a = $('<a/>').attr('href', 'data:application/pdf;base64,'+pdf);
Expand All @@ -636,7 +642,7 @@ var IPython = (function (IPython) {
return toinsert;
}

OutputArea.prototype.append_latex = function (latex, md, element) {
var append_latex = function (latex, md, element) {
// This method cannot do the typesetting because the latex first has to
// be on the page.
var type = 'text/latex';
Expand Down Expand Up @@ -851,14 +857,14 @@ var IPython = (function (IPython) {
];

OutputArea.append_map = {
"text/plain" : OutputArea.prototype.append_text,
"text/html" : OutputArea.prototype.append_html,
"image/svg+xml" : OutputArea.prototype.append_svg,
"image/png" : OutputArea.prototype.append_png,
"image/jpeg" : OutputArea.prototype.append_jpeg,
"text/latex" : OutputArea.prototype.append_latex,
"application/javascript" : OutputArea.prototype.append_javascript,
"application/pdf" : OutputArea.prototype.append_pdf
"text/plain" : append_text,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just as a quick glance append_stream uses this.append_text, so either fix there or keep this one attached to output area?

"text/html" : append_html,
"image/svg+xml" : append_svg,
"image/png" : append_png,
"image/jpeg" : append_jpeg,
"text/latex" : append_latex,
"application/javascript" : append_javascript,
"application/pdf" : append_pdf
};

IPython.OutputArea = OutputArea;
Expand Down