From 31a61587805a01ff18d14d6d2448bfaaddc618ba 2012-07-11 14:07:53 From: Matthias BUSSONNIER Date: 2012-07-11 14:07:53 Subject: [PATCH] Allow toolbar construction in js Base of allowing a full toolbar construction in js without altering the html template, and use it to construct our toolbar as example. still need some work to be totally decoupled. --- diff --git a/IPython/frontend/html/notebook/static/css/notebook.css b/IPython/frontend/html/notebook/static/css/notebook.css index 8a49a19..1927ee3 100644 --- a/IPython/frontend/html/notebook/static/css/notebook.css +++ b/IPython/frontend/html/notebook/static/css/notebook.css @@ -60,7 +60,7 @@ span#notebook_name { z-index: 10; } -#toolbar { +.toolbar { padding: 3px 15px; } diff --git a/IPython/frontend/html/notebook/static/js/toolbar.js b/IPython/frontend/html/notebook/static/js/toolbar.js index a7e337c..1b4fc9f 100644 --- a/IPython/frontend/html/notebook/static/js/toolbar.js +++ b/IPython/frontend/html/notebook/static/js/toolbar.js @@ -1,5 +1,5 @@ //---------------------------------------------------------------------------- -// Copyright (C) 2008-2011 The IPython Development Team +// Copyright (C) 2008 The IPython Development Team // // Distributed under the terms of the BSD License. The full license is in // the file COPYING, distributed as part of this software. @@ -14,99 +14,195 @@ var IPython = (function (IPython) { var ToolBar = function (selector) { this.selector = selector; if (this.selector !== undefined) { + this.construct(); + this.addDropDownList(); this.element = $(selector); this.style(); this.bind_events(); } }; + // add a group of button into the current toolbar. + // + // First argument : Mandatory + // list of dict as argument, each dict should contain + // 3 mandatory keys and values : + // 'label' : string -- the text to show on hover + // 'icon' : string -- the jQuery-ui icon to add on this button + // 'callback' : function -- the callback to execute on a click + // + // and optionnaly an 'id' key that is assigned to the button element + // + // Second Argument, optionnal, + // string reprensenting the id to give to the button group. + // + // Example + // + // IPython.toolbar.addButtonsGroup([ + // {'label':'my button', + // 'icon':'ui-icon-disk', + // 'callback':function(){alert('hoho'), + // 'id' : 'my_button_id', // this is optionnal + // } + // }, + // {'label':'my second button', + // 'icon':'ui-icon-scissors', + // 'callback':function(){alert('be carefull I cut')} + // } + // ], + // "my_button_group_id" + // ) + // + ToolBar.prototype.addButtonsGroup = function(list, group_id){ + var span_group = $(''); + if( group_id != undefined ) + span_group.attr('id',group_id) + for(var el in list) + { + var button = $('