From d9a42fe43bb8636a8130a966f121c0d743326368 2012-10-02 16:58:48 From: Brian E. Granger Date: 2012-10-02 16:58:48 Subject: [PATCH] Merge pull request #2127 from Carreau/jsToolbar Ability to build toolbar in JS --- diff --git a/IPython/frontend/html/notebook/static/css/notebook.css b/IPython/frontend/html/notebook/static/css/notebook.css index 27f72ce..a66b63e 100644 --- a/IPython/frontend/html/notebook/static/css/notebook.css +++ b/IPython/frontend/html/notebook/static/css/notebook.css @@ -70,7 +70,7 @@ span#notebook_name { z-index: 10; } -#toolbar { +.toolbar { padding: 3px 15px; } diff --git a/IPython/frontend/html/notebook/static/js/layoutmanager.js b/IPython/frontend/html/notebook/static/js/layoutmanager.js index d40643c..b599e93 100644 --- a/IPython/frontend/html/notebook/static/js/layoutmanager.js +++ b/IPython/frontend/html/notebook/static/js/layoutmanager.js @@ -32,10 +32,10 @@ var IPython = (function (IPython) { } var menubar_height = $('div#menubar').outerHeight(true); var toolbar_height; - if ($('div#toolbar').css('display') === 'none') { + if ($('div#maintoolbar').css('display') === 'none') { toolbar_height = 0; } else { - toolbar_height = $('div#toolbar').outerHeight(true); + toolbar_height = $('div#maintoolbar').outerHeight(true); } return h-header_height-menubar_height-toolbar_height; // content height } diff --git a/IPython/frontend/html/notebook/static/js/maintoolbar.js b/IPython/frontend/html/notebook/static/js/maintoolbar.js new file mode 100644 index 0000000..328fca1 --- /dev/null +++ b/IPython/frontend/html/notebook/static/js/maintoolbar.js @@ -0,0 +1,179 @@ +//---------------------------------------------------------------------------- +// Copyright (C) 2011 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. +//---------------------------------------------------------------------------- + +//============================================================================ +// ToolBar +//============================================================================ + +var IPython = (function (IPython) { + + var MainToolBar = function (selector) { + this.selector = selector; + IPython.ToolBar.apply(this, arguments); + this.construct(); + this.add_drop_down_list(); + this.bind_events(); + }; + + MainToolBar.prototype = new IPython.ToolBar(); + + MainToolBar.prototype.construct = function () { + this.add_buttons_group([ + { + id : 'save_b', + label : 'Save', + icon : 'ui-icon-disk', + callback : function () { + IPython.notebook.save_notebook(); + } + } + ]); + this.add_buttons_group([ + { + id : 'cut_b', + label : 'Cut Cell', + icon : 'ui-icon-scissors', + callback : function () { + IPython.notebook.cut_cell(); + } + }, + { + id : 'copy_b', + label : 'Copy Cell', + icon : 'ui-icon-copy', + callback : function () { + IPython.notebook.copy_cell(); + } + }, + { + id : 'paste_b', + label : 'Paste Cell', + icon : 'ui-icon-clipboard', + callback : function () { + IPython.notebook.paste_cell(); + } + } + ],'cut_copy_paste'); + + this.add_buttons_group([ + { + id : 'move_up_b', + label : 'Move Cell Up', + icon : 'ui-icon-arrowthick-1-n', + callback : function () { + IPython.notebook.move_cell_up(); + } + }, + { + id : 'move_down_b', + label : 'Move Cell Down', + icon : 'ui-icon-arrowthick-1-s', + callback : function () { + IPython.notebook.move_cell_down(); + } + } + ],'move_up_down'); + + this.add_buttons_group([ + { + id : 'insert_above_b', + label : 'Insert Cell Above', + icon : 'ui-icon-arrowthickstop-1-n', + callback : function () { + IPython.notebook.insert_cell_above('code'); + } + }, + { + id : 'insert_below_b', + label : 'Insert Cell Below', + icon : 'ui-icon-arrowthickstop-1-s', + callback : function () { + IPython.notebook.insert_cell_below('code'); + } + } + ],'insert_above_below'); + + this.add_buttons_group([ + { + id : 'run_b', + label : 'Run Cell', + icon : 'ui-icon-play', + callback : function () { + IPython.notebook.execute_selected_cell(); + } + }, + { + id : 'interrupt_b', + label : 'Interrupt', + icon : 'ui-icon-stop', + callback : function () { + IPython.notebook.kernel.interrupt(); + } + } + ],'run_int'); + + + }; + + MainToolBar.prototype.add_drop_down_list = function () { + var select = $(this.selector) + .append($(' - - - - - - - - - - - - - +
@@ -247,6 +211,7 @@ data-notebook-id={{notebook_id}} +