Skip to content
Closed
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
1 change: 1 addition & 0 deletions notebook/static/notebook/js/cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ define([
this.element.removeClass('marked');
}
}
this.events.trigger('cell:marking-changed', {cell:this, value:value});
}
});

Expand Down
21 changes: 21 additions & 0 deletions notebook/static/notebook/js/notebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ define(function (require) {
Notebook.prototype.bind_events = function () {
var that = this;

this.events.on('cell:marking-changed', function(){
console.log('trigger');
that.update_marked_status();
});

this.events.on('set_next_input.Notebook', function (event, data) {
if (data.replace) {
data.cell.set_text(data.text);
Expand Down Expand Up @@ -621,6 +626,7 @@ define(function (require) {
Notebook.prototype.toggle_cells_marked = function(cells) {
cells = cells || this.get_cells();
cells.forEach(function(cell) { cell.marked = !cell.marked; });
this.update_marked_status();
};

/**
Expand All @@ -630,6 +636,7 @@ define(function (require) {
Notebook.prototype.mark_all_cells = function(cells) {
cells = cells || this.get_cells();
cells.forEach(function(cell) { cell.marked = true; });
this.update_marked_status();
};

/**
Expand All @@ -638,6 +645,7 @@ define(function (require) {
*/
Notebook.prototype.unmark_all_cells = function(cells) {
this.get_marked_cells(cells).forEach(function(cell) { cell.marked = false; });
this.update_marked_status();
};

/**
Expand Down Expand Up @@ -728,8 +736,18 @@ define(function (require) {
var selectedIndex = Math.min(Math.max(this.get_selected_index() + offset, 0), this.ncells()-1);
this.select(selectedIndex);
this.get_selected_cell().marked = true;
this.update_marked_status()
};

Notebook.prototype.update_marked_status = function(){
var indicies = this.get_marked_indices();
if ( indicies.length === 0){
this.element.removeClass('jp-marking');
} else {
this.element.addClass('jp-marking');
}
}

// Cell selection.

/**
Expand Down Expand Up @@ -1018,6 +1036,7 @@ define(function (require) {
this.set_dirty(true);

return this;
this.update_marked_status();
};

/**
Expand Down Expand Up @@ -1061,6 +1080,7 @@ define(function (require) {
this.undelete_index = null;
}
$('#undelete_cell').addClass('disabled');
this.update_marked_status();
};

/**
Expand Down Expand Up @@ -1484,6 +1504,7 @@ define(function (require) {
new_cell.set_text(texta);
new_cell.marked = cell.marked;
}
this.update_marked_status();
};

/**
Expand Down
39 changes: 35 additions & 4 deletions notebook/static/notebook/less/cell.less
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
._marked_style(@n) {

border-left-color: @marked_border_color;
border-left-width: @n;
padding-left: 6px-@n;
}

div.cell {
border: 1px solid transparent;
.vbox();
Expand All @@ -7,13 +14,39 @@ div.cell {
border-style: solid;

&.selected {
border-color: @border_color;
border-color: transparent;
/* Don't border the cells when printing */
@media print {
border-color: transparent;
}
}

.command_mode .jp-marking &.selected {

/* Don't border the cells when printing */
@media print {
border-color: transparent;
}

._marked_style(2px);

&.marked {
border-left-color: @marked_border_color;
._marked_style(4px);
}



}

.command_mode &.selected {

._marked_style(2px);

}



.edit_mode &.selected {
border-color: green;

Expand All @@ -24,9 +57,7 @@ div.cell {
}

&.marked {
border-left-color: @marked_border_color;
border-left-width: 3px;
padding-left: 3px;
._marked_style(3px);
}

width: 100%;
Expand Down