From af244a63b82c03d01783d29d0f821d1dcade8709 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Fri, 21 Apr 2017 14:49:21 +0100 Subject: [PATCH] Allow toolbar buttons to have short label I've wanted this for ages - little monochrome icons can only convey so much information. So far, I've only added a label to the run button. --- notebook/static/notebook/js/maintoolbar.js | 3 +- notebook/static/notebook/js/toolbar.js | 37 +++++++++++++++------- notebook/static/notebook/less/toolbar.less | 4 +++ 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/notebook/static/notebook/js/maintoolbar.js b/notebook/static/notebook/js/maintoolbar.js index 6505df201b..2c7ae6a609 100644 --- a/notebook/static/notebook/js/maintoolbar.js +++ b/notebook/static/notebook/js/maintoolbar.js @@ -49,7 +49,8 @@ define([ 'jupyter-notebook:move-cell-down' ], 'move_up_down'], - [ ['jupyter-notebook:run-cell-and-select-next', + [ [new toolbar.Button('jupyter-notebook:run-cell-and-select-next', + {label: 'Run'}), 'jupyter-notebook:interrupt-kernel', 'jupyter-notebook:confirm-restart-kernel' ], diff --git a/notebook/static/notebook/js/toolbar.js b/notebook/static/notebook/js/toolbar.js index be4c2bc7c8..7f66db2eeb 100644 --- a/notebook/static/notebook/js/toolbar.js +++ b/notebook/static/notebook/js/toolbar.js @@ -82,19 +82,15 @@ define(['jquery'], function($) { if( group_id !== undefined ) { btn_group.attr('id',group_id); } - for(var i=0; i < list.length; i++) { - - // IIFE because javascript don't have loop scope so - // action_name would otherwise be the same on all iteration - // of the loop - (function(i,list){ - var el = list[i]; + list.forEach(function(el) { var action_name; var action; if(typeof(el) === 'string'){ action = that.actions.get(el); action_name = el; - + } else if (el.action) { + action = that.actions.get(el.action); + action_name = el.action } var button = $('