mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-12 11:45:38 +08:00
Merge pull request #5316 from berendjan/reduce_duplication
Another (Minor) Duplicate Code Reduction
This commit is contained in:
commit
ed5e9d6d0e
@ -844,34 +844,16 @@ define([
|
||||
}
|
||||
};
|
||||
|
||||
var append_png = function (png, md, element, handle_inserted) {
|
||||
var type = MIME_PNG;
|
||||
var toinsert = this.create_output_subarea(md, "output_png", type);
|
||||
OutputArea.prototype._append_img = function (src_type, md, element, handle_inserted, MIME, type_string) {
|
||||
var type = MIME;
|
||||
var toinsert = this.create_output_subarea(md, 'output_' + type_string, type);
|
||||
var img = $("<img/>");
|
||||
if (handle_inserted !== undefined) {
|
||||
img.on('load', function(){
|
||||
handle_inserted(img);
|
||||
});
|
||||
}
|
||||
img[0].src = 'data:image/png;base64,'+ png;
|
||||
set_width_height(img, md, type);
|
||||
dblclick_to_reset_size(img);
|
||||
toinsert.append(img);
|
||||
element.append(toinsert);
|
||||
return toinsert;
|
||||
};
|
||||
|
||||
|
||||
var append_jpeg = function (jpeg, md, element, handle_inserted) {
|
||||
var type = MIME_JPEG;
|
||||
var toinsert = this.create_output_subarea(md, "output_jpeg", type);
|
||||
var img = $("<img/>");
|
||||
if (handle_inserted !== undefined) {
|
||||
img.on('load', function(){
|
||||
handle_inserted(img);
|
||||
});
|
||||
}
|
||||
img[0].src = 'data:image/jpeg;base64,'+ jpeg;
|
||||
img[0].src = 'data:image/' + type_string + ';base64,'+ src_type;
|
||||
set_width_height(img, md, type);
|
||||
dblclick_to_reset_size(img);
|
||||
toinsert.append(img);
|
||||
@ -879,23 +861,17 @@ define([
|
||||
return toinsert;
|
||||
};
|
||||
|
||||
var append_gif = function (gif, md, element, handle_inserted) {
|
||||
var type = MIME_GIF;
|
||||
var toinsert = this.create_output_subarea(md, "output_gif", type);
|
||||
var img = $("<img/>");
|
||||
if (handle_inserted !== undefined) {
|
||||
img.on('load', function(){
|
||||
handle_inserted(img);
|
||||
});
|
||||
}
|
||||
img[0].src = 'data:image/gif;base64,'+ gif;
|
||||
set_width_height(img, md, type);
|
||||
dblclick_to_reset_size(img);
|
||||
toinsert.append(img);
|
||||
element.append(toinsert);
|
||||
return toinsert;
|
||||
var append_png = function (png, md, element, handle_inserted) {
|
||||
return this._append_img(png, md, element, handle_inserted, MIME_PNG, 'png');
|
||||
};
|
||||
|
||||
var append_jpeg = function (jpeg, md, element, handle_inserted) {
|
||||
return this._append_img(jpeg, md, element, handle_inserted, MIME_JPEG, 'jpeg');
|
||||
};
|
||||
|
||||
var append_gif = function (gif, md, element, handle_inserted) {
|
||||
return this._append_img(gif, md, element, handle_inserted, MIME_GIF, 'gif');
|
||||
};
|
||||
|
||||
var append_pdf = function (pdf, md, element) {
|
||||
var type = MIME_PDF;
|
||||
|
Loading…
Reference in New Issue
Block a user