Show More
@@ -320,9 +320,21 b' var IPython = (function (IPython) {' | |||||
320 | }; |
|
320 | }; | |
321 |
|
321 | |||
322 |
|
322 | |||
323 | OutputArea.prototype.create_output_subarea = function(md, classes) { |
|
323 | function _get_metadata_key(metadata, key, mime) { | |
|
324 | var mime_md = metadata[mime]; | |||
|
325 | // mime-specific higher priority | |||
|
326 | if (mime_md && mime_md[key] !== undefined) { | |||
|
327 | console.log("got" + key + " "+ mime_md[key]); | |||
|
328 | return mime_md[key]; | |||
|
329 | } | |||
|
330 | // fallback on global | |||
|
331 | console.log("fallback" + key + " "+ metadata[key]); | |||
|
332 | return metadata[key]; | |||
|
333 | } | |||
|
334 | ||||
|
335 | OutputArea.prototype.create_output_subarea = function(md, classes, mime) { | |||
324 | var subarea = $('<div/>').addClass('output_subarea').addClass(classes); |
|
336 | var subarea = $('<div/>').addClass('output_subarea').addClass(classes); | |
325 |
if (md |
|
337 | if (_get_metadata_key(md, 'isolated', mime)) { | |
326 | // Create an iframe to isolate the subarea from the rest of the |
|
338 | // Create an iframe to isolate the subarea from the rest of the | |
327 | // document |
|
339 | // document | |
328 | var iframe = $('<iframe/>').addClass('box-flex1'); |
|
340 | var iframe = $('<iframe/>').addClass('box-flex1'); | |
@@ -476,22 +488,13 b' var IPython = (function (IPython) {' | |||||
476 | OutputArea.display_order = ['javascript','html','latex','svg','png','jpeg','text']; |
|
488 | OutputArea.display_order = ['javascript','html','latex','svg','png','jpeg','text']; | |
477 |
|
489 | |||
478 | OutputArea.prototype.append_mime_type = function (json, element, dynamic) { |
|
490 | OutputArea.prototype.append_mime_type = function (json, element, dynamic) { | |
|
491 | ||||
479 | for(var type_i in OutputArea.display_order){ |
|
492 | for(var type_i in OutputArea.display_order){ | |
480 | var type = OutputArea.display_order[type_i]; |
|
493 | var type = OutputArea.display_order[type_i]; | |
481 | if(json[type] != undefined ){ |
|
494 | if(json[type] != undefined ){ | |
482 | var md = {}; |
|
495 | var md = {}; | |
483 | if (json.metadata) { |
|
496 | if (json.metadata) { | |
484 | md = json.metadata; |
|
497 | md = json.metadata; | |
485 | if (json.metadata[type]) { |
|
|||
486 | // XXX: need some sort of dict.update, style here if |
|
|||
487 | // we want to support the merging of the overall |
|
|||
488 | // metadata with the mimetype specific metadata. For |
|
|||
489 | // now, they are mutually exclusive - if the |
|
|||
490 | // mimetype-keyed metadata exists, *it* is used, |
|
|||
491 | // otherwise, only the message-wide metadata is |
|
|||
492 | // available. |
|
|||
493 | md = json.metadata[type]; |
|
|||
494 | } |
|
|||
495 | } |
|
498 | } | |
496 | if(type == 'javascript'){ |
|
499 | if(type == 'javascript'){ | |
497 | if (dynamic) { |
|
500 | if (dynamic) { | |
@@ -509,17 +512,17 b' var IPython = (function (IPython) {' | |||||
509 | }; |
|
512 | }; | |
510 |
|
513 | |||
511 |
|
514 | |||
512 | OutputArea.prototype.append_html = function (html, md, element) { |
|
515 | OutputArea.prototype.append_html = function (html, md, element, type) { | |
513 | var toinsert = this.create_output_subarea(md, "output_html rendered_html"); |
|
516 | var toinsert = this.create_output_subarea(md, "output_html rendered_html", type); | |
514 | IPython.keyboard_manager.register_events(toinsert); |
|
517 | IPython.keyboard_manager.register_events(toinsert); | |
515 | toinsert.append(html); |
|
518 | toinsert.append(html); | |
516 | element.append(toinsert); |
|
519 | element.append(toinsert); | |
517 | }; |
|
520 | }; | |
518 |
|
521 | |||
519 |
|
522 | |||
520 | OutputArea.prototype.append_javascript = function (js, md, container) { |
|
523 | OutputArea.prototype.append_javascript = function (js, md, container, type) { | |
521 | // We just eval the JS code, element appears in the local scope. |
|
524 | // We just eval the JS code, element appears in the local scope. | |
522 | var element = this.create_output_subarea(md, "output_javascript"); |
|
525 | var element = this.create_output_subarea(md, "output_javascript", type); | |
523 | IPython.keyboard_manager.register_events(element); |
|
526 | IPython.keyboard_manager.register_events(element); | |
524 | container.append(element); |
|
527 | container.append(element); | |
525 | try { |
|
528 | try { | |
@@ -531,8 +534,8 b' var IPython = (function (IPython) {' | |||||
531 | }; |
|
534 | }; | |
532 |
|
535 | |||
533 |
|
536 | |||
534 | OutputArea.prototype.append_text = function (data, md, element, extra_class) { |
|
537 | OutputArea.prototype.append_text = function (data, md, element, extra_class, type) { | |
535 | var toinsert = this.create_output_subarea(md, "output_text"); |
|
538 | var toinsert = this.create_output_subarea(md, "output_text", type); | |
536 | // escape ANSI & HTML specials in plaintext: |
|
539 | // escape ANSI & HTML specials in plaintext: | |
537 | data = utils.fixConsole(data); |
|
540 | data = utils.fixConsole(data); | |
538 | data = utils.fixCarriageReturn(data); |
|
541 | data = utils.fixCarriageReturn(data); | |
@@ -545,8 +548,8 b' var IPython = (function (IPython) {' | |||||
545 | }; |
|
548 | }; | |
546 |
|
549 | |||
547 |
|
550 | |||
548 | OutputArea.prototype.append_svg = function (svg, md, element) { |
|
551 | OutputArea.prototype.append_svg = function (svg, md, element, type) { | |
549 | var toinsert = this.create_output_subarea(md, "output_svg"); |
|
552 | var toinsert = this.create_output_subarea(md, "output_svg", type); | |
550 | toinsert.append(svg); |
|
553 | toinsert.append(svg); | |
551 | element.append(toinsert); |
|
554 | element.append(toinsert); | |
552 | }; |
|
555 | }; | |
@@ -579,10 +582,9 b' var IPython = (function (IPython) {' | |||||
579 | }; |
|
582 | }; | |
580 |
|
583 | |||
581 |
|
584 | |||
582 | OutputArea.prototype.append_png = function (png, md, element) { |
|
585 | OutputArea.prototype.append_png = function (png, md, element, type) { | |
583 | var toinsert = this.create_output_subarea(md, "output_png"); |
|
586 | var toinsert = this.create_output_subarea(md, "output_png", type); | |
584 | var img = $("<img/>"); |
|
587 | var img = $("<img/>").attr('src','data:image/png;base64,'+png); | |
585 | img[0].setAttribute('src','data:image/png;base64,'+png); |
|
|||
586 | if (md['height']) { |
|
588 | if (md['height']) { | |
587 | img[0].setAttribute('height', md['height']); |
|
589 | img[0].setAttribute('height', md['height']); | |
588 | } |
|
590 | } | |
@@ -595,8 +597,8 b' var IPython = (function (IPython) {' | |||||
595 | }; |
|
597 | }; | |
596 |
|
598 | |||
597 |
|
599 | |||
598 | OutputArea.prototype.append_jpeg = function (jpeg, md, element) { |
|
600 | OutputArea.prototype.append_jpeg = function (jpeg, md, element, type) { | |
599 | var toinsert = this.create_output_subarea(md, "output_jpeg"); |
|
601 | var toinsert = this.create_output_subarea(md, "output_jpeg", type); | |
600 | var img = $("<img/>").attr('src','data:image/jpeg;base64,'+jpeg); |
|
602 | var img = $("<img/>").attr('src','data:image/jpeg;base64,'+jpeg); | |
601 | if (md['height']) { |
|
603 | if (md['height']) { | |
602 | img.attr('height', md['height']); |
|
604 | img.attr('height', md['height']); | |
@@ -610,10 +612,10 b' var IPython = (function (IPython) {' | |||||
610 | }; |
|
612 | }; | |
611 |
|
613 | |||
612 |
|
614 | |||
613 | OutputArea.prototype.append_latex = function (latex, md, element) { |
|
615 | OutputArea.prototype.append_latex = function (latex, md, element, type) { | |
614 | // This method cannot do the typesetting because the latex first has to |
|
616 | // This method cannot do the typesetting because the latex first has to | |
615 | // be on the page. |
|
617 | // be on the page. | |
616 | var toinsert = this.create_output_subarea(md, "output_latex"); |
|
618 | var toinsert = this.create_output_subarea(md, "output_latex", type); | |
617 | toinsert.append(latex); |
|
619 | toinsert.append(latex); | |
618 | element.append(toinsert); |
|
620 | element.append(toinsert); | |
619 | }; |
|
621 | }; |
General Comments 0
You need to be logged in to leave comments.
Login now