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
10 changes: 10 additions & 0 deletions notebook/static/notebook/js/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,16 @@ define([
env.notebook.select(index);
}
},
'mute-cell' : {
handler : function (env) {
env.notebook.mute_cell();
}
},
'unmute-cell' : {
handler : function (env) {
env.notebook.unmute_cell();
}
},
'copy-cell' : {
cmd: i18n.msg._('copy selected cells'),
help: i18n.msg._('copy selected cells'),
Expand Down
2 changes: 2 additions & 0 deletions notebook/static/notebook/js/menubar.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ define([
'#insert_image': 'insert-image',
'#keyboard_shortcuts' : 'show-keyboard-shortcuts',
'#edit_keyboard_shortcuts' : 'edit-command-mode-keyboard-shortcuts',
'#mute_cell' : 'mute-cell',
'#unmute_cell' : 'unmute-cell',
};

for(var idx in id_actions_dict){
Expand Down
35 changes: 35 additions & 0 deletions notebook/static/notebook/js/notebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ define([
this.trusted = null;
this._changed_on_disk_dialog = null;
this._fully_loaded = false;
this.mutedCells = [];

// Trigger cell toolbar registration.
default_celltoolbar.register(this);
Expand Down Expand Up @@ -1639,6 +1640,30 @@ define([
this.delete_cell();
};

/**
* Mute a cell
*/
Notebook.prototype.mute_cell = function () {
var cells = this.get_selected_cells_indices();
this.mutedCells.push(cells.tabindex);
};

/**
* Unmute a cell
*/
Notebook.prototype.unmute_cell = function () {
var cells = this.get_selected_cells_indices();
//console.log("muted cell == " + JSON.stringify(cells));
for (var i = 0;j<cells.len();i++)
{
var currentIndex = cells[i].tabindex;
if(currentIndex in this.mutedCells)
{
this.mutedCells.remove(currentIndex);
}
}
this.mutedCells.remove(cells.tabindex);
};
/**
* Copy cells.
*/
Expand Down Expand Up @@ -2566,6 +2591,16 @@ define([
for (var i=start; i<end; i++) {
indices.push(i);
}

for (var j = 0;j<this.mutedCells.len();j++)
{
var currentIndex = this.mutedCells[j];
if(currentIndex in indices)
{
indices.remove(currentIndex);
}
}

this.execute_cells(indices);
};

Expand Down
2 changes: 2 additions & 0 deletions notebook/templates/notebook.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@
<ul id="edit_menu" class="dropdown-menu" role="menu" aria-labelledby="editlink">
<li id="cut_cell" role="none"><a href="#" role="menuitem">{% trans %}Cut Cells{% endtrans %}</a></li>
<li id="copy_cell" role="none"><a href="#" role="menuitem">{% trans %}Copy Cells{% endtrans %}</a></li>
<li id="mute_cell" role="none"><a href="#" role="menuitem">{% trans %} Mute Cells {% endtrans } </a></li>
<li id="unmute_cell" role="none"><a href="#" role="menuitem">{% trans %} Unmute Cells {% endtrans } </a></li>
<li id="paste_cell_above" class="disabled" role="none"><a href="#" role="menuitem" aria-disabled="true">{% trans %}Paste Cells Above{% endtrans %}</a></li>
<li id="paste_cell_below" class="disabled" role="none"><a href="#" role="menuitem" aria-disabled="true">{% trans %}Paste Cells Below{% endtrans %}</a></li>
<li id="paste_cell_replace" class="disabled" role="none"><a href="#" role="menuitem" aria-disabled="true">{% trans %}Paste Cells &amp; Replace{% endtrans %}</a></li>
Expand Down