Skip to content

Pass the output area object in events specific to the output area. #2411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions notebook/static/notebook/js/codecell.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ define([
stop_on_error = true;
}

this.output_area.clear_output(false, true);
this.clear_output(false, true);
var old_msg_id = this.last_msg_id;
if (old_msg_id) {
this.kernel.clear_callbacks_for_msg(old_msg_id);
Expand Down Expand Up @@ -509,10 +509,10 @@ define([
};


CodeCell.prototype.clear_output = function (wait) {
this.output_area.clear_output(wait);
this.set_input_prompt();
CodeCell.prototype.clear_output = function (wait, ignore_queue) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should ignore_queue have a default argument since prior calls to this would not have had an argument? Perhaps undefined is ok to pass through to this.output_area.clear_output?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I'll check.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine the way it is. undefined is treated as false, which means things should proceed as normal in the clear_output function.

this.events.trigger('clear_output.CodeCell', {cell: this});
this.output_area.clear_output(wait, ignore_queue);
this.set_input_prompt();
};


Expand Down
13 changes: 7 additions & 6 deletions notebook/static/notebook/js/outputarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ define([
this._needs_height_reset = false;
}

this.element.trigger('resizeOutput');
this.element.trigger('resizeOutput', {output_area: this});
};

OutputArea.prototype.create_output_area = function () {
Expand Down Expand Up @@ -451,7 +451,7 @@ define([
}

// Notify others of changes.
this.element.trigger('changed');
this.element.trigger('changed', {output_area: this});
};


Expand Down Expand Up @@ -942,7 +942,7 @@ define([
};


OutputArea.prototype.clear_output = function(wait, ignore_que) {
OutputArea.prototype.clear_output = function(wait, ignore_clear_queue) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly better naming. 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a while of staring at it to figure out the double negative logic and what it was supposed to say :).

if (wait) {

// If a clear is queued, clear before adding another to the queue.
Expand All @@ -955,7 +955,7 @@ define([

// Fix the output div's height if the clear_output is waiting for
// new output (it is being used in an animation).
if (!ignore_que && this.clear_queued) {
if (!ignore_clear_queue && this.clear_queued) {
var height = this.element.height();
this.element.height(height);
this.clear_queued = false;
Expand All @@ -965,11 +965,12 @@ define([
// 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');
this.element.trigger('clearing', {output_area: this});
this.element.html("");

// Notify others of changes.
this.element.trigger('changed');
this.element.trigger('cleared');
this.element.trigger('changed', {output_area: this});
this.element.trigger('cleared', {output_area: this});

this.outputs = [];
this._display_id_targets = {};
Expand Down