Skip to content
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

Executing cell when clicking its prompt #3535

Merged
merged 5 commits into from
May 23, 2018
Merged
Show file tree
Hide file tree
Changes from 4 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
12 changes: 11 additions & 1 deletion notebook/static/notebook/js/codecell.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@ define([

var input = $('<div></div>').addClass('input');
this.input = input;

var run_this_cell = $('<div></div>').addClass('run_this_cell');
run_this_cell.prop('title', 'Run this cell');
run_this_cell.append('<i class="fa-step-forward fa"></i>');
run_this_cell.mouseup(function (event) {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason to do this on the mouseup event rather than the click event? I think we usually use click.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll replace it with click event

event.stopImmediatePropagation();
that.execute();
});

var prompt = $('<div/>').addClass('prompt input_prompt');
var inner_cell = $('<div/>').addClass('inner_cell');
this.celltoolbar = new celltoolbar.CellToolbar({
Expand All @@ -180,7 +189,7 @@ define([
this.code_mirror.on('keydown', $.proxy(this.handle_keyevent,this));
$(this.code_mirror.getInputField()).attr("spellcheck", "false");
inner_cell.append(input_area);
input.append(prompt).append(inner_cell);
input.append(run_this_cell).append(prompt).append(inner_cell);

var output = $('<div></div>');
cell.append(input).append(output);
Expand Down Expand Up @@ -505,6 +514,7 @@ define([
}
this.input_prompt_number = number;
var prompt_html = CodeCell.input_prompt_function(this.input_prompt_number, nline);

// This HTML call is okay because the user contents are escaped.
this.element.find('div.input_prompt').html(prompt_html);
this.events.trigger('set_dirty.Notebook', {value: true});
Expand Down
25 changes: 25 additions & 0 deletions notebook/static/notebook/less/codecell.less
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,31 @@ div.input_prompt {
border-top: 1px solid transparent;
}

.run_this_cell {
visibility: hidden;
cursor: pointer;
color: #333;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 1ex;
padding-right: 1ex;
width: 1ex;
}

div.code_cell div.input_prompt {
min-width: 11ex;
}

div.code_cell:hover .run_this_cell {
visibility: visible;
}

@media (-moz-touch-enabled: 1), (any-pointer: coarse) {
.run_this_cell {
visibility: visible;
}
}

// The styles related to div.highlight are for nbconvert HTML output only. This works
// because the .highlight div isn't present in the live notebook. We could put this into
// nbconvert, but it easily falls out of sync, can't use our less variables and doesn't
Expand Down