From 5a53a034f44deb1ae21cfdca42cfd470935f8a42 Mon Sep 17 00:00:00 2001 From: Raffaele De Feo Date: Tue, 15 Apr 2014 15:29:24 +0200 Subject: [PATCH] Hide the cell toolbar if there are no ui controls in it. --- IPython/html/static/notebook/js/celltoolbar.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/IPython/html/static/notebook/js/celltoolbar.js b/IPython/html/static/notebook/js/celltoolbar.js index bd1842f8c..89a940511 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(); + } };