##// END OF EJS Templates
use \0 instead of 'wake up' to finish output...
use \0 instead of 'wake up' to finish output since we are now seeing the captured output, we don't need `wake up` at the end of all of our test outputs.

File last commit:

r20299:6fb4c32f
r20318:d5648dc2
Show More
outputarea.js
992 lines | 33.3 KiB | application/javascript | JavascriptLexer
MinRK
pyout -> execute_result...
r16568 // Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177
Jonathan Frederic
Almost done!...
r17198 define([
'base/js/namespace',
Jonathan Frederic
More requirejs fixes
r17215 'jqueryui',
Jonathan Frederic
Almost done!...
r17198 'base/js/utils',
'base/js/security',
'base/js/keyboard',
'notebook/js/mathjaxutils',
Ben Duffield
add marked to require dependencies
r17389 'components/marked/lib/marked',
], function(IPython, $, utils, security, keyboard, mathjaxutils, marked) {
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 "use strict";
Matthias BUSSONNIER
Use different threshold for (auto)scroll in output...
r10776 /**
* @class OutputArea
*
* @constructor
*/
Jonathan Frederic
More review changes
r17214 var OutputArea = function (options) {
this.selector = options.selector;
this.events = options.events;
this.keyboard_manager = options.keyboard_manager;
this.wrapper = $(options.selector);
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 this.outputs = [];
this.collapsed = false;
MinRK
third attempt at scrolled long output...
r7362 this.scrolled = false;
Min RK
allow users to set scroll state...
r20058 this.scroll_state = 'auto';
MinRK
sign notebooks
r14856 this.trusted = true;
Jonathan Frederic
Added wait flag to clear_output.
r12592 this.clear_queued = null;
Jonathan Frederic
More review changes
r17214 if (options.prompt_area === undefined) {
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 this.prompt_area = true;
Brian Granger
Fixing bug in prompt_area handling of OutputArea.
r7181 } else {
Jonathan Frederic
More review changes
r17214 this.prompt_area = options.prompt_area;
Matthias BUSSONNIER
jslint
r9555 }
MinRK
third attempt at scrolled long output...
r7362 this.create_elements();
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 this.style();
MinRK
third attempt at scrolled long output...
r7362 this.bind_events();
};
Matthias BUSSONNIER
reorder class properties
r14886
/**
* Class prototypes
**/
MinRK
third attempt at scrolled long output...
r7362 OutputArea.prototype.create_elements = function () {
this.element = $("<div/>");
this.collapse_button = $("<div/>");
this.prompt_overlay = $("<div/>");
this.wrapper.append(this.prompt_overlay);
this.wrapper.append(this.element);
this.wrapper.append(this.collapse_button);
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
OutputArea.prototype.style = function () {
MinRK
third attempt at scrolled long output...
r7362 this.collapse_button.hide();
this.prompt_overlay.hide();
this.wrapper.addClass('output_wrapper');
Matthias BUSSONNIER
remove more hard coded layout
r13332 this.element.addClass('output');
MinRK
third attempt at scrolled long output...
r7362
Jonathan Frederic
Ran jdfreder/bootstrap2to3
r16913 this.collapse_button.addClass("btn btn-default output_collapsed");
Harry Moreno
changed instances of 'outout' to 'output' in alt text's
r9903 this.collapse_button.attr('title', 'click to expand output');
Matthias BUSSONNIER
some $.html( -> $.text(...
r14634 this.collapse_button.text('. . .');
MinRK
third attempt at scrolled long output...
r7362
this.prompt_overlay.addClass('out_prompt_overlay prompt');
Harry Moreno
changed instances of 'outout' to 'output' in alt text's
r9903 this.prompt_overlay.attr('title', 'click to expand output; double click to hide output');
MinRK
third attempt at scrolled long output...
r7362
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 this.collapse();
};
Matthias BUSSONNIER
Use different threshold for (auto)scroll in output...
r10776 /**
* Should the OutputArea scroll?
Min RK
allow users to set scroll state...
r20058 * Returns whether the height (in lines) exceeds the current threshold.
* Threshold will be OutputArea.minimum_scroll_threshold if scroll_state=true (manually requested)
* or OutputArea.auto_scroll_threshold if scroll_state='auto'.
* This will always return false if scroll_state=false (scroll disabled).
Matthias BUSSONNIER
Use different threshold for (auto)scroll in output...
r10776 *
*/
Min RK
allow users to set scroll state...
r20058 OutputArea.prototype._should_scroll = function () {
var threshold;
if (this.scroll_state === false) {
return false;
} else if (this.scroll_state === true) {
threshold = OutputArea.minimum_scroll_threshold;
} else {
threshold = OutputArea.auto_scroll_threshold;
}
if (threshold <=0) {
return false;
MinRK
third attempt at scrolled long output...
r7362 }
// line-height from http://stackoverflow.com/questions/1185151
var fontSize = this.element.css('font-size');
var lineHeight = Math.floor(parseInt(fontSize.replace('px','')) * 1.5);
Min RK
allow users to set scroll state...
r20058 return (this.element.height() > threshold * lineHeight);
MinRK
third attempt at scrolled long output...
r7362 };
OutputArea.prototype.bind_events = function () {
var that = this;
this.prompt_overlay.dblclick(function () { that.toggle_output(); });
this.prompt_overlay.click(function () { that.toggle_scroll(); });
this.element.resize(function () {
MinRK
disable auto-scroll on mozilla...
r7733 // FIXME: Firefox on Linux misbehaves, so automatic scrolling is disabled
Jonathan Frederic
Almost done!...
r17198 if ( utils.browser[0] === "Firefox" ) {
MinRK
disable auto-scroll on mozilla...
r7733 return;
}
MinRK
third attempt at scrolled long output...
r7362 // maybe scroll output,
// if it's grown large enough and hasn't already been scrolled.
Min RK
allow users to set scroll state...
r20058 if (!that.scrolled && that._should_scroll()) {
MinRK
third attempt at scrolled long output...
r7362 that.scroll_area();
}
});
this.collapse_button.click(function () {
that.expand();
});
};
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 OutputArea.prototype.collapse = function () {
if (!this.collapsed) {
this.element.hide();
MinRK
third attempt at scrolled long output...
r7362 this.prompt_overlay.hide();
if (this.element.html()){
this.collapse_button.show();
}
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 this.collapsed = true;
Min RK
allow users to set scroll state...
r20058 // collapsing output clears scroll state
this.scroll_state = 'auto';
Matthias BUSSONNIER
jslint
r9555 }
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
OutputArea.prototype.expand = function () {
if (this.collapsed) {
MinRK
third attempt at scrolled long output...
r7362 this.collapse_button.hide();
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 this.element.show();
Min RK
only show prompt overlay if there's a prompt...
r20299 if (this.prompt_area) {
this.prompt_overlay.show();
}
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 this.collapsed = false;
Min RK
allow users to set scroll state...
r20058 this.scroll_if_long();
Matthias BUSSONNIER
jslint
r9555 }
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
OutputArea.prototype.toggle_output = function () {
if (this.collapsed) {
this.expand();
} else {
this.collapse();
Matthias BUSSONNIER
jslint
r9555 }
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
MinRK
third attempt at scrolled long output...
r7362 OutputArea.prototype.scroll_area = function () {
this.element.addClass('output_scroll');
MinRK
dblclick/double click for humans
r7423 this.prompt_overlay.attr('title', 'click to unscroll output; double click to hide');
MinRK
third attempt at scrolled long output...
r7362 this.scrolled = true;
};
OutputArea.prototype.unscroll_area = function () {
this.element.removeClass('output_scroll');
MinRK
dblclick/double click for humans
r7423 this.prompt_overlay.attr('title', 'click to scroll output; double click to hide');
MinRK
third attempt at scrolled long output...
r7362 this.scrolled = false;
};
Matthias BUSSONNIER
Use different threshold for (auto)scroll in output...
r10776 /**
Min RK
allow users to set scroll state...
r20058 * Scroll OutputArea if height exceeds a threshold.
Matthias BUSSONNIER
Use different threshold for (auto)scroll in output...
r10776 *
Min RK
allow users to set scroll state...
r20058 * Threshold is OutputArea.minimum_scroll_threshold if scroll_state = true,
* OutputArea.auto_scroll_threshold if scroll_state='auto'.
Matthias BUSSONNIER
Use different threshold for (auto)scroll in output...
r10776 *
**/
Min RK
allow users to set scroll state...
r20058 OutputArea.prototype.scroll_if_long = function () {
var should_scroll = this._should_scroll();
if (!this.scrolled && should_scroll) {
MinRK
third attempt at scrolled long output...
r7362 // only allow scrolling long-enough output
this.scroll_area();
Min RK
allow users to set scroll state...
r20058 } else if (this.scrolled && !should_scroll) {
// scrolled and shouldn't be
this.unscroll_area();
Matthias BUSSONNIER
jslint
r9555 }
MinRK
third attempt at scrolled long output...
r7362 };
OutputArea.prototype.toggle_scroll = function () {
Min RK
allow users to set scroll state...
r20058 if (this.scroll_state == 'auto') {
Min RK
toggle scroll from auto based on current scroll...
r20059 this.scroll_state = !this.scrolled;
Min RK
allow users to set scroll state...
r20058 } else {
this.scroll_state = !this.scroll_state;
}
MinRK
third attempt at scrolled long output...
r7362 if (this.scrolled) {
this.unscroll_area();
} else {
// only allow scrolling long-enough output
Matthias BUSSONNIER
Use different threshold for (auto)scroll in output...
r10776 this.scroll_if_long();
Matthias BUSSONNIER
jslint
r9555 }
MinRK
third attempt at scrolled long output...
r7362 };
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 // typeset with MathJax if MathJax is available
OutputArea.prototype.typeset = function () {
Nicholas Bollweg (Nick)
moving typeset to utils, usage in cell and outputarea
r19235 utils.typeset(this.element);
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
MinRK
refactor js callbacks...
r13207 OutputArea.prototype.handle_output = function (msg) {
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 var json = {};
MinRK
refactor js callbacks...
r13207 var msg_type = json.output_type = msg.header.msg_type;
var content = msg.content;
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 if (msg_type === "stream") {
MinRK
msgspec 5: stream.data -> stream.text
r18104 json.text = content.text;
MinRK
update html/js to nbformat 4
r18584 json.name = content.name;
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 } else if (msg_type === "display_data") {
MinRK
output[mime/type] -> output.data[mime/type] in javascript
r18592 json.data = content.data;
Paul Ivanov
love them semicolons
r14131 json.metadata = content.metadata;
MinRK
pyout -> execute_result...
r16568 } else if (msg_type === "execute_result") {
MinRK
output[mime/type] -> output.data[mime/type] in javascript
r18592 json.data = content.data;
Paul Ivanov
love them semicolons
r14131 json.metadata = content.metadata;
MinRK
s/prompt_number/execution_count in nbformat 4
r18587 json.execution_count = content.execution_count;
MinRK
pyerr -> error
r16569 } else if (msg_type === "error") {
MinRK
move pyout/execute_result and pyerr/error transforms to to/fromJSON...
r16589 json.ename = content.ename;
json.evalue = content.evalue;
json.traceback = content.traceback;
} else {
console.log("unhandled output message", msg);
return;
Matthias BUSSONNIER
jslint
r9555 }
Paul Ivanov
remove dynamic keyword, handling it in fromJSON...
r14134 this.append_output(json);
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
Paul Ivanov
use mime type in memory
r14118
MinRK
revert output area changes
r14157
MinRK
validate output types in append_output...
r14158 OutputArea.output_types = [
'application/javascript',
'text/html',
Andrew Jesaitis
Adds markdown formatting to output cells
r16364 'text/markdown',
MinRK
validate output types in append_output...
r14158 'text/latex',
'image/svg+xml',
'image/png',
'image/jpeg',
Brian E. Granger
Adding basic append_pdf in OutputArea.
r15127 'application/pdf',
MinRK
validate output types in append_output...
r14158 'text/plain'
];
Min RK
handle missing data, metadata in validate_mimebundle
r19803 OutputArea.prototype.validate_mimebundle = function (bundle) {
/** scrub invalid outputs */
if (typeof bundle.data !== 'object') {
console.warn("mimebundle missing data", bundle);
bundle.data = {};
}
if (typeof bundle.metadata !== 'object') {
console.warn("mimebundle missing metadata", bundle);
bundle.metadata = {};
}
var data = bundle.data;
MinRK
validate output types in append_output...
r14158 $.map(OutputArea.output_types, function(key){
MinRK
update html/js to nbformat 4
r18584 if (key !== 'application/json' &&
MinRK
output[mime/type] -> output.data[mime/type] in javascript
r18592 data[key] !== undefined &&
typeof data[key] !== 'string'
MinRK
update html/js to nbformat 4
r18584 ) {
MinRK
output[mime/type] -> output.data[mime/type] in javascript
r18592 console.log("Invalid type for " + key, data[key]);
delete data[key];
MinRK
validate output types in append_output...
r14158 }
});
Min RK
handle missing data, metadata in validate_mimebundle
r19803 return bundle;
MinRK
validate output types in append_output...
r14158 };
MinRK
sign notebooks
r14856
Paul Ivanov
remove dynamic keyword, handling it in fromJSON...
r14134 OutputArea.prototype.append_output = function (json) {
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 this.expand();
Jonathan Frederic
Cleanup
r16191
Jonathan Frederic
Added wait flag to clear_output.
r12592 // Clear the output if clear is queued.
Jonathan Frederic
Fix scrolling output not working...
r12817 var needs_height_reset = false;
Jonathan Frederic
Added wait flag to clear_output.
r12592 if (this.clear_queued) {
this.clear_output(false);
Jonathan Frederic
Fix scrolling output not working...
r12817 needs_height_reset = true;
Jonathan Frederic
Added wait flag to clear_output.
r12592 }
jon
Use .load() to resize
r16187
MinRK
coalesce stream output in the notebook...
r17305 var record_output = true;
Min RK
Handle unrecognized outputs and cells from the future
r18999 switch(json.output_type) {
case 'execute_result':
json = this.validate_mimebundle(json);
this.append_execute_result(json);
break;
case 'stream':
// append_stream might have merged the output with earlier stream output
record_output = this.append_stream(json);
break;
case 'error':
this.append_error(json);
break;
case 'display_data':
// append handled below
json = this.validate_mimebundle(json);
break;
default:
console.log("unrecognized output type: " + json.output_type);
this.append_unrecognized(json);
Matthias BUSSONNIER
jslint
r9555 }
jon
Use .load() to resize
r16187
Jonathan Frederic
Cleanup
r16191 // We must release the animation fixed height in a callback since Gecko
// (FireFox) doesn't render the image immediately as the data is
// available.
var that = this;
var handle_appended = function ($el) {
Jonathan Frederic
Ran function comment conversion tool
r19176 /**
* Only reset the height to automatic if the height is currently
* fixed (done by wait=True flag on clear_output).
*/
Jonathan Frederic
Cleanup
r16191 if (needs_height_reset) {
that.element.height('');
}
that.element.trigger('resize');
};
jon
Use .load() to resize
r16187 if (json.output_type === 'display_data') {
this.append_display_data(json, handle_appended);
Jonathan Frederic
Cleanup
r16191 } else {
jon
Use .load() to resize
r16187 handle_appended();
}
MinRK
sign notebooks
r14856
MinRK
coalesce stream output in the notebook...
r17305 if (record_output) {
this.outputs.push(json);
}
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
OutputArea.prototype.create_output_area = function () {
Matthias BUSSONNIER
include hbox in outpuarea css
r10216 var oa = $("<div/>").addClass("output_area");
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 if (this.prompt_area) {
oa.append($('<div/>').addClass('prompt'));
}
return oa;
};
Pablo de Oliveira
Support isolated metadata tag for any content...
r13412
Paul Ivanov
check mime-keyed metadata first, then top level
r14116 function _get_metadata_key(metadata, key, mime) {
var mime_md = metadata[mime];
// mime-specific higher priority
if (mime_md && mime_md[key] !== undefined) {
return mime_md[key];
}
// fallback on global
return metadata[key];
}
OutputArea.prototype.create_output_subarea = function(md, classes, mime) {
Pablo de Oliveira
Support isolated metadata tag for any content...
r13412 var subarea = $('<div/>').addClass('output_subarea').addClass(classes);
Paul Ivanov
check mime-keyed metadata first, then top level
r14116 if (_get_metadata_key(md, 'isolated', mime)) {
Pablo de Oliveira
Support isolated metadata tag for any content...
r13412 // Create an iframe to isolate the subarea from the rest of the
// document
Pablo de Oliveira
Preserve layout for large isolated objects
r13418 var iframe = $('<iframe/>').addClass('box-flex1');
Pablo de Oliveira
Set both height and width using css
r13419 iframe.css({'height':1, 'width':'100%', 'display':'block'});
Pablo de Oliveira
Support isolated metadata tag for any content...
r13412 iframe.attr('frameborder', 0);
iframe.attr('scrolling', 'auto');
// Once the iframe is loaded, the subarea is dynamically inserted
iframe.on('load', function() {
// Workaround needed by Firefox, to properly render svg inside
// iframes, see http://stackoverflow.com/questions/10177190/
// svg-dynamically-added-to-iframe-does-not-render-correctly
this.contentDocument.open();
// Insert the subarea into the iframe
// We must directly write the html. When using Jquery's append
// method, javascript is evaluated in the parent document and
Jonathan Frederic
Audit .html() calls take #2
r15376 // not in the iframe document. At this point, subarea doesn't
// contain any user content.
Pablo de Oliveira
Support isolated metadata tag for any content...
r13412 this.contentDocument.write(subarea.html());
this.contentDocument.close();
var body = this.contentDocument.body;
Pablo de Oliveira
Preserve layout for large isolated objects
r13418 // Adjust the iframe height automatically
Pablo de Oliveira
Support isolated metadata tag for any content...
r13412 iframe.height(body.scrollHeight + 'px');
});
// Elements should be appended to the inner subarea and not to the
// iframe
iframe.append = function(that) {
subarea.append(that);
};
return iframe;
} else {
return subarea;
}
MinRK
semicolons, you guys!
r18591 };
Pablo de Oliveira
Support isolated metadata tag for any content...
r13412
Brian E. Granger
Fixing various output related things:...
r13792 OutputArea.prototype._append_javascript_error = function (err, element) {
Jonathan Frederic
Ran function comment conversion tool
r19176 /**
* display a message when a javascript error occurs in display output
*/
MinRK
semicolons, you guys!
r18591 var msg = "Javascript error adding output!";
Brian E. Granger
Fixing various output related things:...
r13792 if ( element === undefined ) return;
Jonathan Frederic
Audit .html() calls take #2
r15376 element
.append($('<div/>').text(msg).addClass('js-error'))
.append($('<div/>').text(err.toString()).addClass('js-error'))
.append($('<div/>').text('See your browser Javascript console for more details.').addClass('js-error'));
MinRK
use _safe_append for all output...
r12332 };
OutputArea.prototype._safe_append = function (toinsert) {
Jonathan Frederic
Ran function comment conversion tool
r19176 /**
* safely append an item to the document
* this is an object created by user code,
* and may have errors, which should not be raised
* under any circumstances.
*/
MinRK
use _safe_append for all output...
r12332 try {
this.element.append(toinsert);
} catch(err) {
console.log(err);
Brian E. Granger
Fixing various output related things:...
r13792 // Create an actual output_area and output_subarea, which creates
// the prompt area and the proper indentation.
var toinsert = this.create_output_area();
var subarea = $('<div/>').addClass('output_subarea');
toinsert.append(subarea);
this._append_javascript_error(err, subarea);
this.element.append(toinsert);
MinRK
use _safe_append for all output...
r12332 }
Jonathan Frederic
Make output widget reactive.
r18954
// Notify others of changes.
this.element.trigger('changed');
MinRK
use _safe_append for all output...
r12332 };
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177
MinRK
pyout -> execute_result...
r16568 OutputArea.prototype.append_execute_result = function (json) {
MinRK
s/prompt_number/execution_count in nbformat 4
r18587 var n = json.execution_count || ' ';
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 var toinsert = this.create_output_area();
if (this.prompt_area) {
Matthias BUSSONNIER
some $.html( -> $.text(...
r14634 toinsert.find('div.prompt').addClass('output_prompt').text('Out[' + n + ']:');
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 }
Jonathan Frederic
addClass instead of adding extra_class arg everywhere
r15729 var inserted = this.append_mime_type(json, toinsert);
if (inserted) {
MinRK
move pyout/execute_result and pyerr/error transforms to to/fromJSON...
r16589 inserted.addClass('output_result');
Jonathan Frederic
addClass instead of adding extra_class arg everywhere
r15729 }
MinRK
use _safe_append for all output...
r12332 this._safe_append(toinsert);
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 // If we just output latex, typeset it.
Matthias Bussonnier
Actually typeset latex
r18939 if ((json.data['text/latex'] !== undefined) ||
(json.data['text/html'] !== undefined) ||
(json.data['text/markdown'] !== undefined)) {
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 this.typeset();
Matthias BUSSONNIER
jslint
r9555 }
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
MinRK
pyerr -> error
r16569 OutputArea.prototype.append_error = function (json) {
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 var tb = json.traceback;
if (tb !== undefined && tb.length > 0) {
var s = '';
var len = tb.length;
for (var i=0; i<len; i++) {
s = s + tb[i] + '\n';
}
s = s + '\n';
var toinsert = this.create_output_area();
MinRK
call append_text from append_map
r15783 var append_text = OutputArea.append_map['text/plain'];
if (append_text) {
MinRK
move pyout/execute_result and pyerr/error transforms to to/fromJSON...
r16589 append_text.apply(this, [s, {}, toinsert]).addClass('output_error');
MinRK
call append_text from append_map
r15783 }
MinRK
use _safe_append for all output...
r12332 this._safe_append(toinsert);
Matthias BUSSONNIER
jslint
r9555 }
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
OutputArea.prototype.append_stream = function (json) {
MinRK
msgspec: stream.data -> stream.text
r18588 var text = json.text;
Min RK
discard invalid stream output...
r19928 if (typeof text !== 'string') {
console.error("Stream output is invalid (missing text)", json);
return false;
}
MinRK
update html/js to nbformat 4
r18584 var subclass = "output_"+json.name;
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 if (this.outputs.length > 0){
// have at least one output to consider
var last = this.outputs[this.outputs.length-1];
MinRK
update html/js to nbformat 4
r18584 if (last.output_type == 'stream' && json.name == last.name){
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 // latest output was in the same stream,
// so append directly into its pre tag
// escape ANSI & HTML specials:
MinRK
msgspec: stream.data -> stream.text
r18588 last.text = utils.fixCarriageReturn(last.text + json.text);
Michael Droettboom
Fix rebase.
r7350 var pre = this.element.find('div.'+subclass).last().find('pre');
MinRK
msgspec: stream.data -> stream.text
r18588 var html = utils.fixConsole(last.text);
Jonathan Frederic
s/with with/with
r15406 // The only user content injected with this HTML call is
Jonathan Frederic
Audit .html() calls take #2
r15376 // escaped by the fixConsole() method.
Michael Droettboom
Handle carriage return characters ("\r") in HTML notebook output....
r7339 pre.html(html);
MinRK
coalesce stream output in the notebook...
r17305 // return false signals that we merged this output with the previous one,
// and the new output shouldn't be recorded.
return false;
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 }
}
Michael Droettboom
Handle carriage return characters ("\r") in HTML notebook output....
r7339
if (!text.replace("\r", "")) {
// text is nothing (empty string, \r, etc.)
// so don't append any elements, which might add undesirable space
MinRK
coalesce stream output in the notebook...
r17305 // return true to indicate the output should be recorded.
return true;
Michael Droettboom
Handle carriage return characters ("\r") in HTML notebook output....
r7339 }
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 // If we got here, attach a new div
var toinsert = this.create_output_area();
MinRK
call append_text from append_map
r15783 var append_text = OutputArea.append_map['text/plain'];
if (append_text) {
append_text.apply(this, [text, {}, toinsert]).addClass("output_stream " + subclass);
}
MinRK
use _safe_append for all output...
r12332 this._safe_append(toinsert);
MinRK
coalesce stream output in the notebook...
r17305 return true;
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
Min RK
Handle unrecognized outputs and cells from the future
r18999 OutputArea.prototype.append_unrecognized = function (json) {
Min RK
Preserve nbformat_minor from the future...
r19107 var that = this;
Min RK
Handle unrecognized outputs and cells from the future
r18999 var toinsert = this.create_output_area();
var subarea = $('<div/>').addClass('output_subarea output_unrecognized');
toinsert.append(subarea);
Min RK
Preserve nbformat_minor from the future...
r19107 subarea.append(
$("<a>")
.attr("href", "#")
.text("Unrecognized output: " + json.output_type)
.click(function () {
Min RK
allow users to set scroll state...
r20058 that.events.trigger('unrecognized_output.OutputArea', {output: json});
Min RK
Preserve nbformat_minor from the future...
r19107 })
);
Min RK
Handle unrecognized outputs and cells from the future
r18999 this._safe_append(toinsert);
};
jon
Use .load() to resize
r16187 OutputArea.prototype.append_display_data = function (json, handle_inserted) {
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 var toinsert = this.create_output_area();
jon
Use .load() to resize
r16187 if (this.append_mime_type(json, toinsert, handle_inserted)) {
Jonathan Frederic
Fix blank space added by included Javascript on page refresh or notebook load
r13454 this._safe_append(toinsert);
// If we just output latex, typeset it.
Matthias Bussonnier
Actually typeset latex
r18939 if ((json.data['text/latex'] !== undefined) ||
(json.data['text/html'] !== undefined) ||
(json.data['text/markdown'] !== undefined)) {
Jonathan Frederic
Fix blank space added by included Javascript on page refresh or notebook load
r13454 this.typeset();
}
Matthias BUSSONNIER
jslint
r9555 }
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
MinRK
sign notebooks
r14856 OutputArea.safe_outputs = {
'text/plain' : true,
MinRK
trust latex...
r15643 'text/latex' : true,
MinRK
sign notebooks
r14856 'image/png' : true,
'image/jpeg' : true
};
jon
Use .load() to resize
r16187 OutputArea.prototype.append_mime_type = function (json, element, handle_inserted) {
MinRK
never use `for (var i in array)`...
r16226 for (var i=0; i < OutputArea.display_order.length; i++) {
var type = OutputArea.display_order[i];
Paul Ivanov
minor cleanup
r14135 var append = OutputArea.append_map[type];
MinRK
output[mime/type] -> output.data[mime/type] in javascript
r18592 if ((json.data[type] !== undefined) && append) {
var value = json.data[type];
MinRK
sign notebooks
r14856 if (!this.trusted && !OutputArea.safe_outputs[type]) {
MinRK
sanitize untrusted HTML output...
r15644 // not trusted, sanitize HTML
Brian E. Granger
Display safe HTML+SVG even if untrusted, but don't set trusted=1.
r15634 if (type==='text/html' || type==='text/svg') {
Jonathan Frederic
Almost done!...
r17198 value = security.sanitize_html(value);
MinRK
sanitize untrusted HTML output...
r15644 } else {
MinRK
remove warning for stripped output
r15658 // don't display if we don't know how to sanitize it
MinRK
log excluded untrusted output
r15661 console.log("Ignoring untrusted " + type + " output.");
Jonathan Frederic
Fixed rebase issues
r15728 continue;
MinRK
sign notebooks
r14856 }
}
Paul Ivanov
love javascript....
r14140 var md = json.metadata || {};
jon
Use .load() to resize
r16187 var toinsert = append.apply(this, [value, md, element, handle_inserted]);
// Since only the png and jpeg mime types call the inserted
Jonathan Frederic
Cleanup
r16191 // callback, if the mime type is something other we must call the
jon
Use .load() to resize
r16187 // inserted callback only when the element is actually inserted
// into the DOM. Use a timeout of 0 to do this.
Jonathan Frederic
A couple of fixes,...
r16189 if (['image/png', 'image/jpeg'].indexOf(type) < 0 && handle_inserted !== undefined) {
jon
Use .load() to resize
r16187 setTimeout(handle_inserted, 0);
}
Jonathan Frederic
Almost done!...
r17198 this.events.trigger('output_appended.OutputArea', [type, value, md, toinsert]);
Jonathan Frederic
addClass instead of adding extra_class arg everywhere
r15729 return toinsert;
Matthias BUSSONNIER
display order in output area configurable
r9540 }
}
Jonathan Frederic
addClass instead of adding extra_class arg everywhere
r15729 return null;
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
MinRK
append functions are not prototype methods
r15762 var append_html = function (html, md, element) {
Paul Ivanov
love javascript....
r14140 var type = 'text/html';
Paul Ivanov
check mime-keyed metadata first, then top level
r14116 var toinsert = this.create_output_subarea(md, "output_html rendered_html", type);
Jonathan Frederic
Almost done!...
r17198 this.keyboard_manager.register_events(toinsert);
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 toinsert.append(html);
element.append(toinsert);
Matthias BUSSONNIER
emit event when mimetype are append to output area.
r14883 return toinsert;
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
Andrew Jesaitis
Adds markdown formatting to output cells
r16364 var append_markdown = function(markdown, md, element) {
var type = 'text/markdown';
var toinsert = this.create_output_subarea(md, "output_markdown", type);
Jonathan Frederic
Almost done!...
r17198 var text_and_math = mathjaxutils.remove_math(markdown);
Andrew Jesaitis
Adds markdown formatting to output cells
r16364 var text = text_and_math[0];
var math = text_and_math[1];
MinRK
use CodeMirror.runMode to highlight in markdown...
r18864 marked(text, function (err, html) {
html = mathjaxutils.replace_math(html, math);
toinsert.append(html);
});
Andrew Jesaitis
Adds markdown formatting to output cells
r16364 element.append(toinsert);
return toinsert;
};
MinRK
append functions are not prototype methods
r15762 var append_javascript = function (js, md, element) {
Jonathan Frederic
Ran function comment conversion tool
r19176 /**
* We just eval the JS code, element appears in the local scope.
*/
Paul Ivanov
love javascript....
r14140 var type = 'application/javascript';
Matthias BUSSONNIER
fix Brian and Min comment
r14884 var toinsert = this.create_output_subarea(md, "output_javascript", type);
Jonathan Frederic
Almost done!...
r17198 this.keyboard_manager.register_events(toinsert);
Matthias BUSSONNIER
fix Brian and Min comment
r14884 element.append(toinsert);
Jonathan Frederic
Make sure `element` is correct in the context of displayed JS...
r15992
// Fix for ipython/issues/5293, make sure `element` is the area which
// output can be inserted into at the time of JS execution.
element = toinsert;
Matthias BUSSONNIER
warn on error when user display javascript
r8071 try {
eval(js);
} catch(err) {
Brian E. Granger
Fixing various output related things:...
r13792 console.log(err);
Matthias BUSSONNIER
fix Brian and Min comment
r14884 this._append_javascript_error(err, toinsert);
Matthias BUSSONNIER
warn on error when user display javascript
r8071 }
Matthias BUSSONNIER
fix Brian and Min comment
r14884 return toinsert;
Matthias BUSSONNIER
jslint
r9555 };
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177
MinRK
append functions are not prototype methods
r15762 var append_text = function (data, md, element) {
Paul Ivanov
love javascript....
r14140 var type = 'text/plain';
Paul Ivanov
check mime-keyed metadata first, then top level
r14116 var toinsert = this.create_output_subarea(md, "output_text", type);
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 // escape ANSI & HTML specials in plaintext:
data = utils.fixConsole(data);
Michael Droettboom
Handle carriage return characters ("\r") in HTML notebook output....
r7339 data = utils.fixCarriageReturn(data);
Erik M. Bray
Locate URLs in text output and convert them to hyperlinks.
r8528 data = utils.autoLinkUrls(data);
Jonathan Frederic
s/with with/with
r15406 // The only user content injected with this HTML call is
Jonathan Frederic
Audit .html() calls take #2
r15376 // escaped by the fixConsole() method.
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 toinsert.append($("<pre/>").html(data));
element.append(toinsert);
Matthias BUSSONNIER
emit event when mimetype are append to output area.
r14883 return toinsert;
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
Jonathan Frederic
Make SVGs resizable in the NB
r16203 var append_svg = function (svg_html, md, element) {
Paul Ivanov
love javascript....
r14140 var type = 'image/svg+xml';
Paul Ivanov
check mime-keyed metadata first, then top level
r14116 var toinsert = this.create_output_subarea(md, "output_svg", type);
Jonathan Frederic
Make SVGs resizable in the NB
r16203
// Get the svg element from within the HTML.
var svg = $('<div />').html(svg_html).find('svg');
var svg_area = $('<div />');
var width = svg.attr('width');
var height = svg.attr('height');
svg
.width('100%')
.height('100%');
svg_area
.width(width)
.height(height);
// The jQuery resize handlers don't seem to work on the svg element.
// When the svg renders completely, measure it's size and set the parent
// div to that size. Then set the svg to 100% the size of the parent
// div and make the parent div resizable.
this._dblclick_to_reset_size(svg_area, true, false);
svg_area.append(svg);
toinsert.append(svg_area);
Brian Granger
Removing resizable SVGs from output.
r7355 element.append(toinsert);
Jonathan Frederic
Make SVGs resizable in the NB
r16203
Matthias BUSSONNIER
emit event when mimetype are append to output area.
r14883 return toinsert;
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
Jonathan Frederic
Make SVGs resizable in the NB
r16203 OutputArea.prototype._dblclick_to_reset_size = function (img, immediately, resize_parent) {
Jonathan Frederic
Ran function comment conversion tool
r19176 /**
* Add a resize handler to an element
*
* img: jQuery element
* immediately: bool=False
* Wait for the element to load before creating the handle.
* resize_parent: bool=True
* Should the parent of the element be resized when the element is
* reset (by double click).
*/
Jonathan Frederic
Make SVGs resizable in the NB
r16203 var callback = function (){
MinRK
use chained delay for setting resizable images
r7601 var h0 = img.height();
var w0 = img.width();
if (!(h0 && w0)) {
MinRK
use on-load event to trigger resizable images...
r15551 // zero size, don't make it resizable
Matthias BUSSONNIER
jslint
r9555 return;
MinRK
use chained delay for setting resizable images
r7601 }
MinRK
dblclick to restore size of images
r7599 img.resizable({
aspectRatio: true,
MinRK
use chained delay for setting resizable images
r7601 autoHide: true
});
img.dblclick(function () {
// resize wrapper & image together for some reason:
img.height(h0);
img.width(w0);
Jonathan Frederic
Make SVGs resizable in the NB
r16203 if (resize_parent === undefined || resize_parent) {
img.parent().height(h0);
img.parent().width(w0);
}
MinRK
dblclick to restore size of images
r7599 });
Jonathan Frederic
Make SVGs resizable in the NB
r16203 };
if (immediately) {
callback();
} else {
img.on("load", callback);
}
Matthias BUSSONNIER
jslint
r9555 };
MinRK
fix setting image height/width from metadata
r14727
var set_width_height = function (img, md, mime) {
Jonathan Frederic
Ran function comment conversion tool
r19176 /**
* set width and height of an img element from metadata
*/
MinRK
fix setting image height/width from metadata
r14727 var height = _get_metadata_key(md, 'height', mime);
MinRK
use jQuery attr instead of setAttribute...
r14807 if (height !== undefined) img.attr('height', height);
MinRK
fix setting image height/width from metadata
r14727 var width = _get_metadata_key(md, 'width', mime);
MinRK
use jQuery attr instead of setAttribute...
r14807 if (width !== undefined) img.attr('width', width);
MinRK
fix setting image height/width from metadata
r14727 };
jon
Use .load() to resize
r16187 var append_png = function (png, md, element, handle_inserted) {
Paul Ivanov
love javascript....
r14140 var type = 'image/png';
Paul Ivanov
check mime-keyed metadata first, then top level
r14116 var toinsert = this.create_output_subarea(md, "output_png", type);
Jonathan Frederic
A couple of fixes,...
r16189 var img = $("<img/>");
if (handle_inserted !== undefined) {
Jonathan Frederic
Cleanup
r16191 img.on('load', function(){
handle_inserted(img);
});
jon
Use .load() to resize
r16187 }
Jonathan Frederic
Make sure to not call old load events
r16190 img[0].src = 'data:image/png;base64,'+ png;
MinRK
use jQuery attr instead of setAttribute...
r14807 set_width_height(img, md, 'image/png');
MinRK
use chained delay for setting resizable images
r7601 this._dblclick_to_reset_size(img);
Brian Granger
Make svg, jpeg and png images resizable in notebook.
r7352 toinsert.append(img);
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 element.append(toinsert);
Matthias BUSSONNIER
emit event when mimetype are append to output area.
r14883 return toinsert;
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
jon
Use .load() to resize
r16187 var append_jpeg = function (jpeg, md, element, handle_inserted) {
Paul Ivanov
love javascript....
r14140 var type = 'image/jpeg';
Paul Ivanov
check mime-keyed metadata first, then top level
r14116 var toinsert = this.create_output_subarea(md, "output_jpeg", type);
Jonathan Frederic
A couple of fixes,...
r16189 var img = $("<img/>");
if (handle_inserted !== undefined) {
Jonathan Frederic
Cleanup
r16191 img.on('load', function(){
handle_inserted(img);
});
jon
Use .load() to resize
r16187 }
Jonathan Frederic
Make sure to not call old load events
r16190 img[0].src = 'data:image/jpeg;base64,'+ jpeg;
MinRK
use jQuery attr instead of setAttribute...
r14807 set_width_height(img, md, 'image/jpeg');
MinRK
use chained delay for setting resizable images
r7601 this._dblclick_to_reset_size(img);
Brian Granger
Make svg, jpeg and png images resizable in notebook.
r7352 toinsert.append(img);
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 element.append(toinsert);
Matthias BUSSONNIER
emit event when mimetype are append to output area.
r14883 return toinsert;
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
MinRK
append functions are not prototype methods
r15762 var append_pdf = function (pdf, md, element) {
Brian E. Granger
Adding basic append_pdf in OutputArea.
r15127 var type = 'application/pdf';
var toinsert = this.create_output_subarea(md, "output_pdf", type);
var a = $('<a/>').attr('href', 'data:application/pdf;base64,'+pdf);
a.attr('target', '_blank');
MinRK
semicolons, you guys!
r18591 a.text('View PDF');
Brian E. Granger
Adding basic append_pdf in OutputArea.
r15127 toinsert.append(a);
element.append(toinsert);
return toinsert;
MinRK
semicolons, you guys!
r18591 };
Brian E. Granger
Adding basic append_pdf in OutputArea.
r15127
MinRK
append functions are not prototype methods
r15762 var append_latex = function (latex, md, element) {
Jonathan Frederic
Ran function comment conversion tool
r19176 /**
* This method cannot do the typesetting because the latex first has to
* be on the page.
*/
Paul Ivanov
love javascript....
r14140 var type = 'text/latex';
Paul Ivanov
check mime-keyed metadata first, then top level
r14116 var toinsert = this.create_output_subarea(md, "output_latex", type);
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 toinsert.append(latex);
element.append(toinsert);
Matthias BUSSONNIER
emit event when mimetype are append to output area.
r14883 return toinsert;
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
Matthias BUSSONNIER
Use different threshold for (auto)scroll in output...
r10776
Paul Ivanov
dispatch on mime type for append methods
r14132
MinRK
refactor js callbacks...
r13207 OutputArea.prototype.append_raw_input = function (msg) {
MinRK
cleanup stdin event submission...
r10370 var that = this;
MinRK
use inline raw_input instead of a dialog
r10368 this.expand();
MinRK
refactor js callbacks...
r13207 var content = msg.content;
MinRK
use inline raw_input instead of a dialog
r10368 var area = this.create_output_area();
MinRK
remove any lingering raw_inputs on raw_input...
r11612
// disable any other raw_inputs, if they are left around
MinRK
fix ambiguous raw_input classes
r15825 $("div.output_subarea.raw_input_container").remove();
MinRK
remove any lingering raw_inputs on raw_input...
r11612
MinRK
support password in input_request
r16573 var input_type = content.password ? 'password' : 'text';
MinRK
use inline raw_input instead of a dialog
r10368 area.append(
$("<div/>")
MinRK
fix ambiguous raw_input classes
r15825 .addClass("box-flex1 output_subarea raw_input_container")
MinRK
use inline raw_input instead of a dialog
r10368 .append(
MinRK
cleanup stdin event submission...
r10370 $("<span/>")
MinRK
fix ambiguous raw_input classes
r15825 .addClass("raw_input_prompt")
MinRK
cleanup stdin event submission...
r10370 .text(content.prompt)
)
.append(
$("<input/>")
.addClass("raw_input")
MinRK
support password in input_request
r16573 .attr('type', input_type)
MinRK
fix raw_input...
r10934 .attr("size", 47)
MinRK
cleanup stdin event submission...
r10370 .keydown(function (event, ui) {
// make sure we submit on enter,
// and don't re-execute the *cell* on shift-enter
Jonathan Frederic
Almost done!...
r17198 if (event.which === keyboard.keycodes.enter) {
MinRK
cleanup stdin event submission...
r10370 that._submit_raw_input();
return false;
}
})
MinRK
use inline raw_input instead of a dialog
r10368 )
MinRK
cleanup stdin event submission...
r10370 );
Brian E. Granger
Fix raw_input.
r14046
MinRK
use inline raw_input instead of a dialog
r10368 this.element.append(area);
Brian E. Granger
Fix raw_input.
r14046 var raw_input = area.find('input.raw_input');
// Register events that enable/disable the keyboard manager while raw
// input is focused.
Jonathan Frederic
Almost done!...
r17198 this.keyboard_manager.register_events(raw_input);
Brian E. Granger
Fix raw_input.
r14046 // Note, the following line used to read raw_input.focus().focus().
// This seemed to be needed otherwise only the cell would be focused.
// But with the modal UI, this seems to work fine with one call to focus().
raw_input.focus();
MinRK
semicolons, you guys!
r18591 };
Brian E. Granger
Fix raw_input.
r14046
MinRK
use inline raw_input instead of a dialog
r10368 OutputArea.prototype._submit_raw_input = function (evt) {
MinRK
fix ambiguous raw_input classes
r15825 var container = this.element.find("div.raw_input_container");
var theprompt = container.find("span.raw_input_prompt");
MinRK
use inline raw_input instead of a dialog
r10368 var theinput = container.find("input.raw_input");
MinRK
fix raw_input...
r10934 var value = theinput.val();
MinRK
support password in input_request
r16573 var echo = value;
// don't echo if it's a password
if (theinput.attr('type') == 'password') {
echo = '········';
}
MinRK
use inline raw_input instead of a dialog
r10368 var content = {
output_type : 'stream',
Thomas Kluyver
Fix conversion of input area to stream output...
r18981 name : 'stdout',
MinRK
support password in input_request
r16573 text : theprompt.text() + echo + '\n'
MinRK
semicolons, you guys!
r18591 };
MinRK
use inline raw_input instead of a dialog
r10368 // remove form container
container.parent().remove();
// replace with plaintext version in stdout
this.append_output(content, false);
Jonathan Frederic
Almost done!...
r17198 this.events.trigger('send_input_reply.Kernel', value);
MinRK
output[mime/type] -> output.data[mime/type] in javascript
r18592 };
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177
MinRK
refactor js callbacks...
r13207 OutputArea.prototype.handle_clear_output = function (msg) {
Jonathan Frederic
Ran function comment conversion tool
r19176 /**
* msg spec v4 had stdout, stderr, display keys
* v4.1 replaced these with just wait
* The default behavior is the same (stdout=stderr=display=True, wait=False),
* so v4 messages will still be properly handled,
* except for the rarely used clearing less than all output.
*/
MinRK
note v4.1 msg spec change in clear_output handler
r14977 this.clear_output(msg.content.wait || false);
Matthias BUSSONNIER
jslint
r9555 };
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177
Jonathan Frederic
When executing a cell, clear output and ignore queued animations.
r19769 OutputArea.prototype.clear_output = function(wait, ignore_que) {
Jonathan Frederic
Added wait flag to clear_output.
r12592 if (wait) {
Jonathan Frederic
Remove clear_output timeout callback in favor of fixed height
r12582
Jonathan Frederic
Added wait flag to clear_output.
r12592 // If a clear is queued, clear before adding another to the queue.
if (this.clear_queued) {
this.clear_output(false);
MinRK
semicolons, you guys!
r18591 }
Jonathan Frederic
Added wait flag to clear_output.
r12592
this.clear_queued = true;
} else {
Jonathan Frederic
Don't preserve height when clear_output(wait=False) is called
r12606 // Fix the output div's height if the clear_output is waiting for
// new output (it is being used in an animation).
Jonathan Frederic
When executing a cell, clear output and ignore queued animations.
r19769 if (!ignore_que && this.clear_queued) {
Jonathan Frederic
Don't preserve height when clear_output(wait=False) is called
r12606 var height = this.element.height();
this.element.height(height);
this.clear_queued = false;
}
Jonathan Frederic
Cleanup
r16191 // Clear all
// Remove load event handlers from img tags because we don't want
// them to fire if the image is never added to the page.
this.element.find('img').off('load');
Jonathan Frederic
Added wait flag to clear_output.
r12592 this.element.html("");
Jonathan Frederic
Make output widget reactive.
r18954
// Notify others of changes.
this.element.trigger('changed');
Jonathan Frederic
Added wait flag to clear_output.
r12592 this.outputs = [];
MinRK
sign notebooks
r14856 this.trusted = true;
Jonathan Frederic
Added wait flag to clear_output.
r12592 this.unscroll_area();
return;
MinRK
semicolons, you guys!
r18591 }
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
// JSON serialization
MinRK
update html/js to nbformat 4
r18584 OutputArea.prototype.fromJSON = function (outputs, metadata) {
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 var len = outputs.length;
MinRK
update html/js to nbformat 4
r18584 metadata = metadata || {};
Paul Ivanov
remove dynamic keyword, handling it in fromJSON...
r14134
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 for (var i=0; i<len; i++) {
MinRK
update html/js to nbformat 4
r18584 this.append_output(outputs[i]);
}
if (metadata.collapsed !== undefined) {
if (metadata.collapsed) {
Min RK
allow users to set scroll state...
r20058 this.collapse();
Min RK
fix initial collapsed state on load...
r20253 } else {
this.expand();
MinRK
move pyout/execute_result and pyerr/error transforms to to/fromJSON...
r16589 }
MinRK
update html/js to nbformat 4
r18584 }
Min RK
allow users to set scroll state...
r20058 if (metadata.scrolled !== undefined) {
this.scroll_state = metadata.scrolled;
if (metadata.scrolled) {
this.scroll_if_long();
MinRK
update html/js to nbformat 4
r18584 } else {
Min RK
allow users to set scroll state...
r20058 this.unscroll_area();
Paul Ivanov
convert short names like 'png' to mimetype names
r14120 }
Matthias BUSSONNIER
jslint
r9555 }
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
OutputArea.prototype.toJSON = function () {
MinRK
update html/js to nbformat 4
r18584 return this.outputs;
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 };
Matthias BUSSONNIER
put OutputArea map at the end
r14985 /**
* Class properties
**/
/**
* Threshold to trigger autoscroll when the OutputArea is resized,
* typically when new outputs are added.
*
* Behavior is undefined if autoscroll is lower than minimum_scroll_threshold,
* unless it is < 0, in which case autoscroll will never be triggered
*
* @property auto_scroll_threshold
* @type Number
* @default 100
*
**/
OutputArea.auto_scroll_threshold = 100;
/**
* Lower limit (in lines) for OutputArea to be made scrollable. OutputAreas
* shorter than this are never scrolled.
*
* @property minimum_scroll_threshold
* @type Number
* @default 20
*
**/
OutputArea.minimum_scroll_threshold = 20;
OutputArea.display_order = [
'application/javascript',
'text/html',
Andrew Jesaitis
Adds markdown formatting to output cells
r16364 'text/markdown',
Matthias BUSSONNIER
put OutputArea map at the end
r14985 'text/latex',
'image/svg+xml',
'image/png',
'image/jpeg',
Brian E. Granger
Adding basic append_pdf in OutputArea.
r15127 'application/pdf',
Matthias BUSSONNIER
put OutputArea map at the end
r14985 'text/plain'
];
OutputArea.append_map = {
MinRK
append functions are not prototype methods
r15762 "text/plain" : append_text,
"text/html" : append_html,
Andrew Jesaitis
Adds markdown formatting to output cells
r16364 "text/markdown": append_markdown,
MinRK
append functions are not prototype methods
r15762 "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
Matthias BUSSONNIER
put OutputArea map at the end
r14985 };
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177
Jonathan Frederic
Almost done!...
r17198 // For backwards compatability.
Brian Granger
Refactored CodeCell to use new OutputArea object for output....
r7177 IPython.OutputArea = OutputArea;
Jonathan Frederic
Return dicts instead of classes,...
r17201 return {'OutputArea': OutputArea};
Jonathan Frederic
Almost done!...
r17198 });