diff --git a/IPython/html/static/notebook/js/celltoolbar.js b/IPython/html/static/notebook/js/celltoolbar.js index bd1842f..89a9405 100644 --- a/IPython/html/static/notebook/js/celltoolbar.js +++ b/IPython/html/static/notebook/js/celltoolbar.js @@ -37,7 +37,6 @@ var IPython = (function (IPython) { this.inner_element = $('
').addClass('celltoolbar') this.element = $('
').addClass('ctb_hideshow') .append(this.inner_element); - this.show(); }; @@ -250,6 +249,7 @@ var IPython = (function (IPython) { // which is probably inner_element // or this.element. this.inner_element.empty(); + this.ui_controls_list = []; var callbacks = CellToolbar._callback_dict; var preset = CellToolbar._ui_controls_list; @@ -267,6 +267,7 @@ var IPython = (function (IPython) { var local_div = $('
').addClass('button_container'); try { callback(local_div, this.cell, this); + this.ui_controls_list.push(key); } catch (e) { console.log("Error in cell toolbar callback " + key, e); continue; @@ -274,6 +275,13 @@ var IPython = (function (IPython) { // only append if callback succeeded. this.inner_element.append(local_div); } + + // If there are no controls hide the toolbar. + if (this.ui_controls_list.length) { + this.show(); + } else { + this.hide(); + } };