##// END OF EJS Templates
allow requesting contents without body...
allow requesting contents without body adds `?content=0` to only fetch the metadata in the model. The REST API now exposes all arguments to ContentsManager.get.

File last commit:

r20072:59f28a7f
r20134:e2450ea7
Show More
widget_output.js
64 lines | 2.0 KiB | application/javascript | JavascriptLexer
Jonathan Frederic
Output Widget
r18953 // Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.
define([
"widgets/js/widget",
"jquery",
'notebook/js/outputarea',
Jonathan Frederic
Address @carreau 's comments
r18958 ], function(widget, $, outputarea) {
'use strict';
Jonathan Frederic
Output Widget
r18953
var OutputView = widget.DOMWidgetView.extend({
Jonathan Frederic
Finished changing output widget logic.
r20060 /**
* Public constructor
*/
Jonathan Frederic
Output Widget
r18953 initialize: function (parameters) {
OutputView.__super__.initialize.apply(this, [parameters]);
this.model.on('msg:custom', this._handle_route_msg, this);
},
Jonathan Frederic
Finished changing output widget logic.
r20060 /**
* Called when view is rendered.
*/
Jonathan Frederic
Output Widget
r18953 render: function(){
this.output_area = new outputarea.OutputArea({
selector: this.$el,
prompt_area: false,
events: this.model.widget_manager.notebook.events,
keyboard_manager: this.model.widget_manager.keyboard_manager });
Jonathan Frederic
Make output widget reactive.
r18954
// Make output area reactive.
var that = this;
this.output_area.element.on('changed', function() {
that.model.set('contents', that.output_area.element.html());
});
this.model.on('change:contents', function(){
var html = this.model.get('contents');
if (this.output_area.element.html() != html) {
this.output_area.element.html(html);
}
}, this);
// Set initial contents.
this.output_area.element.html(this.model.get('contents'));
Jonathan Frederic
Output Widget
r18953 },
Jonathan Frederic
Finished changing output widget logic.
r20060 /**
* Handles re-routed iopub messages.
*/
Jonathan Frederic
Hook the output the right way.
r20072 _handle_route_msg: function(msg) {
if (msg) {
var msg_type = msg.msg_type;
Jonathan Frederic
Finished changing output widget logic.
r20060 if (msg_type=='clear_output') {
Jonathan Frederic
Hook the output the right way.
r20072 this.output_area.handle_clear_output(msg);
Jonathan Frederic
Finished changing output widget logic.
r20060 } else {
Jonathan Frederic
Hook the output the right way.
r20072 this.output_area.handle_output(msg);
Jonathan Frederic
Output Widget
r18953 }
}
},
});
return {
'OutputView': OutputView,
};
});