Show More
@@ -282,35 +282,37 var IPython = (function (IPython) { | |||||
282 | // (FireFox) doesn't render the image immediately as the data is |
|
282 | // (FireFox) doesn't render the image immediately as the data is | |
283 | // available. |
|
283 | // available. | |
284 | var that = this; |
|
284 | var that = this; | |
285 | var handle_appended = function () { |
|
285 | var handle_appended = function ($el) { | |
286 | // Only reset the height to automatic if the height is currently |
|
286 | // Only reset the height to automatic if the height is currently | |
287 | // fixed (done by wait=True flag on clear_output). |
|
287 | // fixed (done by wait=True flag on clear_output). | |
288 | console.log('appended'); |
|
|||
289 | if (needs_height_reset) { |
|
288 | if (needs_height_reset) { | |
290 |
that.element.height(''); |
|
289 | that.element.height(''); | |
|
290 | console.log(that.element.height(), $el.height()); | |||
291 | } |
|
291 | } | |
292 | that.element.trigger('resize'); |
|
292 | that.element.trigger('resize'); | |
293 | }; |
|
293 | }; | |
294 |
|
294 | |||
295 | // validate output data types |
|
295 | // validate output data types | |
296 | json = this.validate_output(json); |
|
296 | json = this.validate_output(json); | |
297 |
|
297 | var is_empty = false; | ||
298 | if (json.output_type === 'pyout') { |
|
298 | if (json.output_type === 'pyout') { | |
299 | this.append_pyout(json); |
|
299 | this.append_pyout(json); | |
300 | } else if (json.output_type === 'pyerr') { |
|
300 | } else if (json.output_type === 'pyerr') { | |
301 | this.append_pyerr(json); |
|
301 | this.append_pyerr(json); | |
302 | } else if (json.output_type === 'stream') { |
|
302 | } else if (json.output_type === 'stream') { | |
303 | this.append_stream(json); |
|
303 | this.append_stream(json); | |
|
304 | // TODO: Why are we recieving these new line characters for no | |||
|
305 | // reason? They ruin everything. | |||
|
306 | is_empty = !json.text.trim(); | |||
304 | } |
|
307 | } | |
305 |
|
308 | |||
306 | if (json.output_type === 'display_data') { |
|
309 | if (json.output_type === 'display_data') { | |
307 | this.append_display_data(json, handle_appended); |
|
310 | this.append_display_data(json, handle_appended); | |
308 | } else { |
|
311 | } else if (!is_empty) { | |
309 | handle_appended(); |
|
312 | handle_appended(); | |
310 | } |
|
313 | } | |
311 |
|
314 | |||
312 | this.outputs.push(json); |
|
315 | this.outputs.push(json); | |
313 |
|
||||
314 | }; |
|
316 | }; | |
315 |
|
317 | |||
316 |
|
318 | |||
@@ -526,7 +528,7 var IPython = (function (IPython) { | |||||
526 | // callback, if the mim type is something other we must call the |
|
528 | // callback, if the mim type is something other we must call the | |
527 | // inserted callback only when the element is actually inserted |
|
529 | // inserted callback only when the element is actually inserted | |
528 | // into the DOM. Use a timeout of 0 to do this. |
|
530 | // into the DOM. Use a timeout of 0 to do this. | |
529 | if (['image/png', 'image/jpeg'].indexOf() < 0 && handle_inserted !== undefined) { |
|
531 | if (['image/png', 'image/jpeg'].indexOf(type) < 0 && handle_inserted !== undefined) { | |
530 | setTimeout(handle_inserted, 0); |
|
532 | setTimeout(handle_inserted, 0); | |
531 | } |
|
533 | } | |
532 | $([IPython.events]).trigger('output_appended.OutputArea', [type, value, md, toinsert]); |
|
534 | $([IPython.events]).trigger('output_appended.OutputArea', [type, value, md, toinsert]); | |
@@ -631,10 +633,13 var IPython = (function (IPython) { | |||||
631 | var append_png = function (png, md, element, handle_inserted) { |
|
633 | var append_png = function (png, md, element, handle_inserted) { | |
632 | var type = 'image/png'; |
|
634 | var type = 'image/png'; | |
633 | var toinsert = this.create_output_subarea(md, "output_png", type); |
|
635 | var toinsert = this.create_output_subarea(md, "output_png", type); | |
634 | var img = $("<img/>").attr('src','data:image/png;base64,'+png); |
|
636 | var img = $("<img/>"); | |
635 |
if (handle_inserted !== undefined) { |
|
637 | if (handle_inserted !== undefined) { | |
636 |
img.on( |
|
638 | img[0].onload = function(){ | |
|
639 | handle_inserted(img); | |||
|
640 | }; | |||
637 | } |
|
641 | } | |
|
642 | img[0].src = 'data:image/png;base64,'+png; | |||
638 | set_width_height(img, md, 'image/png'); |
|
643 | set_width_height(img, md, 'image/png'); | |
639 | this._dblclick_to_reset_size(img); |
|
644 | this._dblclick_to_reset_size(img); | |
640 | toinsert.append(img); |
|
645 | toinsert.append(img); | |
@@ -646,10 +651,13 var IPython = (function (IPython) { | |||||
646 | var append_jpeg = function (jpeg, md, element, handle_inserted) { |
|
651 | var append_jpeg = function (jpeg, md, element, handle_inserted) { | |
647 | var type = 'image/jpeg'; |
|
652 | var type = 'image/jpeg'; | |
648 | var toinsert = this.create_output_subarea(md, "output_jpeg", type); |
|
653 | var toinsert = this.create_output_subarea(md, "output_jpeg", type); | |
649 | var img = $("<img/>").attr('src','data:image/jpeg;base64,'+jpeg); |
|
654 | var img = $("<img/>"); | |
650 |
if (handle_inserted !== undefined) { |
|
655 | if (handle_inserted !== undefined) { | |
651 |
img.on( |
|
656 | img[0].onload = function(){ | |
|
657 | handle_inserted(img); | |||
|
658 | }; | |||
652 | } |
|
659 | } | |
|
660 | img[0].src = 'data:image/jpeg;base64,'+jpeg; | |||
653 | set_width_height(img, md, 'image/jpeg'); |
|
661 | set_width_height(img, md, 'image/jpeg'); | |
654 | this._dblclick_to_reset_size(img); |
|
662 | this._dblclick_to_reset_size(img); | |
655 | toinsert.append(img); |
|
663 | toinsert.append(img); |
General Comments 0
You need to be logged in to leave comments.
Login now