##// END OF EJS Templates
Merge pull request #4774 from Carreau/emit-output...
Min RK -
r15087:0fa6bdf0 merge
parent child Browse files
Show More
@@ -0,0 +1,3 b''
1 * calling `container.show()` on javascript display is deprecated and will
2 trigger errors on future IPython notebook versions. `container` now show
3 itself as soon as non-empty
@@ -43,6 +43,11 b' var IPython = (function (IPython) {'
43 43 this.bind_events();
44 44 };
45 45
46
47 /**
48 * Class prototypes
49 **/
50
46 51 OutputArea.prototype.create_elements = function () {
47 52 this.element = $("<div/>");
48 53 this.collapse_button = $("<div/>");
@@ -160,33 +165,6 b' var IPython = (function (IPython) {'
160 165 };
161 166
162 167 /**
163 * Threshold to trigger autoscroll when the OutputArea is resized,
164 * typically when new outputs are added.
165 *
166 * Behavior is undefined if autoscroll is lower than minimum_scroll_threshold,
167 * unless it is < 0, in which case autoscroll will never be triggered
168 *
169 * @property auto_scroll_threshold
170 * @type Number
171 * @default 100
172 *
173 **/
174 OutputArea.auto_scroll_threshold = 100;
175
176
177 /**
178 * Lower limit (in lines) for OutputArea to be made scrollable. OutputAreas
179 * shorter than this are never scrolled.
180 *
181 * @property minimum_scroll_threshold
182 * @type Number
183 * @default 20
184 *
185 **/
186 OutputArea.minimum_scroll_threshold = 20;
187
188
189 /**
190 168 *
191 169 * Scroll OutputArea if height supperior than a threshold (in lines).
192 170 *
@@ -256,27 +234,6 b' var IPython = (function (IPython) {'
256 234 this.append_output(json);
257 235 };
258 236
259 OutputArea.mime_map = {
260 "text/plain" : "text",
261 "text/html" : "html",
262 "image/svg+xml" : "svg",
263 "image/png" : "png",
264 "image/jpeg" : "jpeg",
265 "text/latex" : "latex",
266 "application/json" : "json",
267 "application/javascript" : "javascript",
268 };
269
270 OutputArea.mime_map_r = {
271 "text" : "text/plain",
272 "html" : "text/html",
273 "svg" : "image/svg+xml",
274 "png" : "image/png",
275 "jpeg" : "image/jpeg",
276 "latex" : "text/latex",
277 "json" : "application/json",
278 "javascript" : "application/javascript",
279 };
280 237
281 238 OutputArea.prototype.rename_keys = function (data, key_map) {
282 239 var remapped = {};
@@ -518,15 +475,6 b' var IPython = (function (IPython) {'
518 475 }
519 476 };
520 477
521 OutputArea.display_order = [
522 'application/javascript',
523 'text/html',
524 'text/latex',
525 'image/svg+xml',
526 'image/png',
527 'image/jpeg',
528 'text/plain'
529 ];
530 478
531 479 OutputArea.safe_outputs = {
532 480 'text/plain' : true,
@@ -549,7 +497,8 b' var IPython = (function (IPython) {'
549 497 continue;
550 498 }
551 499 var md = json.metadata || {};
552 append.apply(this, [json[type], md, element]);
500 var toinsert = append.apply(this, [json[type], md, element]);
501 $([IPython.events]).trigger('output_appended.OutputArea', [type, json[type], md, toinsert]);
553 502 return true;
554 503 }
555 504 }
@@ -563,21 +512,28 b' var IPython = (function (IPython) {'
563 512 IPython.keyboard_manager.register_events(toinsert);
564 513 toinsert.append(html);
565 514 element.append(toinsert);
515 return toinsert;
566 516 };
567 517
568 518
569 OutputArea.prototype.append_javascript = function (js, md, container) {
519 OutputArea.prototype.append_javascript = function (js, md, element) {
570 520 // We just eval the JS code, element appears in the local scope.
571 521 var type = 'application/javascript';
572 var element = this.create_output_subarea(md, "output_javascript", type);
573 IPython.keyboard_manager.register_events(element);
574 container.append(element);
522 var toinsert = this.create_output_subarea(md, "output_javascript", type);
523 IPython.keyboard_manager.register_events(toinsert);
524 element.append(toinsert);
525 // FIXME TODO : remove `container element for 3.0`
526 //backward compat, js should be eval'ed in a context where `container` is defined.
527 var container = element;
528 container.show = function(){console.log('Warning "container.show()" is deprecated.')};
529 // end backward compat
575 530 try {
576 531 eval(js);
577 532 } catch(err) {
578 533 console.log(err);
579 this._append_javascript_error(err, element);
534 this._append_javascript_error(err, toinsert);
580 535 }
536 return toinsert;
581 537 };
582 538
583 539
@@ -593,6 +549,7 b' var IPython = (function (IPython) {'
593 549 }
594 550 toinsert.append($("<pre/>").html(data));
595 551 element.append(toinsert);
552 return toinsert;
596 553 };
597 554
598 555
@@ -601,6 +558,7 b' var IPython = (function (IPython) {'
601 558 var toinsert = this.create_output_subarea(md, "output_svg", type);
602 559 toinsert.append(svg);
603 560 element.append(toinsert);
561 return toinsert;
604 562 };
605 563
606 564
@@ -646,6 +604,7 b' var IPython = (function (IPython) {'
646 604 this._dblclick_to_reset_size(img);
647 605 toinsert.append(img);
648 606 element.append(toinsert);
607 return toinsert;
649 608 };
650 609
651 610
@@ -657,6 +616,7 b' var IPython = (function (IPython) {'
657 616 this._dblclick_to_reset_size(img);
658 617 toinsert.append(img);
659 618 element.append(toinsert);
619 return toinsert;
660 620 };
661 621
662 622
@@ -667,18 +627,9 b' var IPython = (function (IPython) {'
667 627 var toinsert = this.create_output_subarea(md, "output_latex", type);
668 628 toinsert.append(latex);
669 629 element.append(toinsert);
630 return toinsert;
670 631 };
671 632
672 OutputArea.append_map = {
673 "text/plain" : OutputArea.prototype.append_text,
674 "text/html" : OutputArea.prototype.append_html,
675 "image/svg+xml" : OutputArea.prototype.append_svg,
676 "image/png" : OutputArea.prototype.append_png,
677 "image/jpeg" : OutputArea.prototype.append_jpeg,
678 "text/latex" : OutputArea.prototype.append_latex,
679 "application/json" : OutputArea.prototype.append_json,
680 "application/javascript" : OutputArea.prototype.append_javascript,
681 };
682 633
683 634 OutputArea.prototype.append_raw_input = function (msg) {
684 635 var that = this;
@@ -819,6 +770,79 b' var IPython = (function (IPython) {'
819 770 return outputs;
820 771 };
821 772
773 /**
774 * Class properties
775 **/
776
777 /**
778 * Threshold to trigger autoscroll when the OutputArea is resized,
779 * typically when new outputs are added.
780 *
781 * Behavior is undefined if autoscroll is lower than minimum_scroll_threshold,
782 * unless it is < 0, in which case autoscroll will never be triggered
783 *
784 * @property auto_scroll_threshold
785 * @type Number
786 * @default 100
787 *
788 **/
789 OutputArea.auto_scroll_threshold = 100;
790
791 /**
792 * Lower limit (in lines) for OutputArea to be made scrollable. OutputAreas
793 * shorter than this are never scrolled.
794 *
795 * @property minimum_scroll_threshold
796 * @type Number
797 * @default 20
798 *
799 **/
800 OutputArea.minimum_scroll_threshold = 20;
801
802
803
804 OutputArea.mime_map = {
805 "text/plain" : "text",
806 "text/html" : "html",
807 "image/svg+xml" : "svg",
808 "image/png" : "png",
809 "image/jpeg" : "jpeg",
810 "text/latex" : "latex",
811 "application/json" : "json",
812 "application/javascript" : "javascript",
813 };
814
815 OutputArea.mime_map_r = {
816 "text" : "text/plain",
817 "html" : "text/html",
818 "svg" : "image/svg+xml",
819 "png" : "image/png",
820 "jpeg" : "image/jpeg",
821 "latex" : "text/latex",
822 "json" : "application/json",
823 "javascript" : "application/javascript",
824 };
825
826 OutputArea.display_order = [
827 'application/javascript',
828 'text/html',
829 'text/latex',
830 'image/svg+xml',
831 'image/png',
832 'image/jpeg',
833 'text/plain'
834 ];
835
836 OutputArea.append_map = {
837 "text/plain" : OutputArea.prototype.append_text,
838 "text/html" : OutputArea.prototype.append_html,
839 "image/svg+xml" : OutputArea.prototype.append_svg,
840 "image/png" : OutputArea.prototype.append_png,
841 "image/jpeg" : OutputArea.prototype.append_jpeg,
842 "text/latex" : OutputArea.prototype.append_latex,
843 "application/json" : OutputArea.prototype.append_json,
844 "application/javascript" : OutputArea.prototype.append_javascript,
845 };
822 846
823 847 IPython.OutputArea = OutputArea;
824 848
General Comments 0
You need to be logged in to leave comments. Login now