// Copyright (c) IPython Development Team. // Distributed under the terms of the Modified BSD License. define([ 'base/js/namespace', 'jquery' ], function(IPython, $) { "use strict"; /** * A generic toolbar on which one can add button * @class ToolBar * @constructor * @param {Dom_object} selector */ var ToolBar = function (selector, options) { this.selector = selector; this.actions = (options||{}).actions; if (this.selector !== undefined) { this.element = $(selector); this.style(); } }; ToolBar.prototype._pseudo_actions={}; ToolBar.prototype.construct = function (config) { for(var k=0; k' to inject custom element that cannot * be bound to an action. * */ // TODO JUPYTER: // get rid of legacy code that handle things that are not actions. ToolBar.prototype.add_buttons_group = function (list, group_id) { // handle custom call of pseudoaction binding. if(typeof(list) === 'string' && list.slice(0,1) === '<' && list.slice(-1) === '>'){ var _pseudo_action; try{ _pseudo_action = list.slice(1,-1); this.element.append(this._pseudo_actions[_pseudo_action].call(this)); } catch (e) { console.warn('ouch, calling ', _pseudo_action, 'does not seem to work...:', e); } return ; } var that = this; var btn_group = $('
').addClass("btn-group"); 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]; var action_name; var action; if(typeof(el) === 'string'){ action = that.actions.get(el); action_name = el; } var button = $('