##// END OF EJS Templates
Remove uneccessary lines in String.js
Remove uneccessary lines in String.js

File last commit:

r14085:b696039a
r14448:73f786bf
Show More
maintoolbar.js
205 lines | 7.7 KiB | application/javascript | JavascriptLexer
Matthias BUSSONNIER
add maintoolbar file
r7833 //----------------------------------------------------------------------------
Matthias BUSSONNIER
#toolbar -> #maintoolbar
r8207 // Copyright (C) 2011 The IPython Development Team
Matthias BUSSONNIER
add maintoolbar file
r7833 //
// 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) {
Matthias BUSSONNIER
"use strict" in most (if not all) our javascript...
r12103 "use strict";
Matthias BUSSONNIER
add maintoolbar file
r7833
var MainToolBar = function (selector) {
Matthias BUSSONNIER
check for selector only in parent classes
r8213 IPython.ToolBar.apply(this, arguments);
this.construct();
Brian Granger
Decoupling the celltoolbar select UI from CellToolbar....
r9146 this.add_celltype_list();
this.add_celltoolbar_list();
Matthias BUSSONNIER
check for selector only in parent classes
r8213 this.bind_events();
Matthias BUSSONNIER
add maintoolbar file
r7833 };
MainToolBar.prototype = new IPython.ToolBar();
Matthias BUSSONNIER
space around :
r8210 MainToolBar.prototype.construct = function () {
Matthias BUSSONNIER
DeCamelCasify method names
r8051 this.add_buttons_group([
Matthias BUSSONNIER
add maintoolbar file
r7833 {
Matthias BUSSONNIER
space around :
r8210 id : 'save_b',
MinRK
Save and Checkpoint
r10513 label : 'Save and Checkpoint',
Thomas Kluyver
Change to standard save icon in Notebook toolbar...
r11192 icon : 'icon-save',
Matthias BUSSONNIER
space around :
r8210 callback : function () {
MinRK
expose notebook checkpoints in html/js...
r10501 IPython.notebook.save_checkpoint();
Matthias BUSSONNIER
jslint 1
r8209 }
}
Matthias BUSSONNIER
add maintoolbar file
r7833 ]);
Susan Tan
Fixed #2923 Move Save Away from Cut in toolbar
r13731
this.add_buttons_group([
{
id : 'insert_below_b',
label : 'Insert Cell Below',
icon : 'icon-plus-sign',
callback : function () {
IPython.notebook.insert_cell_below('code');
Brian E. Granger
select next cell in insert cell below in menubar to match kb.
r14074 IPython.notebook.select_next();
Brian E. Granger
Focus cells after they are inserted.
r14075 IPython.notebook.focus_cell();
Susan Tan
Fixed #2923 Move Save Away from Cut in toolbar
r13731 }
}
],'insert_above_below');
Matthias BUSSONNIER
DeCamelCasify method names
r8051 this.add_buttons_group([
Matthias BUSSONNIER
add maintoolbar file
r7833 {
Matthias BUSSONNIER
space around :
r8210 id : 'cut_b',
label : 'Cut Cell',
MinRK
bootstrap toolbar
r10889 icon : 'icon-cut',
Matthias BUSSONNIER
space around :
r8210 callback : function () {
Matthias BUSSONNIER
add maintoolbar file
r7833 IPython.notebook.cut_cell();
Matthias BUSSONNIER
jslint 1
r8209 }
Matthias BUSSONNIER
add maintoolbar file
r7833 },
{
Matthias BUSSONNIER
space around :
r8210 id : 'copy_b',
label : 'Copy Cell',
MinRK
bootstrap toolbar
r10889 icon : 'icon-copy',
Matthias BUSSONNIER
space around :
r8210 callback : function () {
Matthias BUSSONNIER
add maintoolbar file
r7833 IPython.notebook.copy_cell();
Matthias BUSSONNIER
jslint 1
r8209 }
Matthias BUSSONNIER
add maintoolbar file
r7833 },
{
Matthias BUSSONNIER
space around :
r8210 id : 'paste_b',
Matthias BUSSONNIER
past below by default
r8770 label : 'Paste Cell Below',
MinRK
bootstrap toolbar
r10889 icon : 'icon-paste',
Matthias BUSSONNIER
space around :
r8210 callback : function () {
Matthias BUSSONNIER
past below by default
r8770 IPython.notebook.paste_cell_below();
Matthias BUSSONNIER
jslint 1
r8209 }
}
Matthias BUSSONNIER
add maintoolbar file
r7833 ],'cut_copy_paste');
Matthias BUSSONNIER
DeCamelCasify method names
r8051 this.add_buttons_group([
Matthias BUSSONNIER
add maintoolbar file
r7833 {
Matthias BUSSONNIER
space around :
r8210 id : 'move_up_b',
label : 'Move Cell Up',
MinRK
bootstrap toolbar
r10889 icon : 'icon-arrow-up',
Matthias BUSSONNIER
space around :
r8210 callback : function () {
Matthias BUSSONNIER
add maintoolbar file
r7833 IPython.notebook.move_cell_up();
Matthias BUSSONNIER
jslint 1
r8209 }
Matthias BUSSONNIER
add maintoolbar file
r7833 },
{
Matthias BUSSONNIER
space around :
r8210 id : 'move_down_b',
label : 'Move Cell Down',
MinRK
fix wrong arrow direction
r10904 icon : 'icon-arrow-down',
Matthias BUSSONNIER
space around :
r8210 callback : function () {
Matthias BUSSONNIER
add maintoolbar file
r7833 IPython.notebook.move_cell_down();
Matthias BUSSONNIER
jslint 1
r8209 }
}
Matthias BUSSONNIER
add maintoolbar file
r7833 ],'move_up_down');
Matthias BUSSONNIER
DeCamelCasify method names
r8051 this.add_buttons_group([
Matthias BUSSONNIER
add maintoolbar file
r7833 {
Matthias BUSSONNIER
space around :
r8210 id : 'run_b',
label : 'Run Cell',
MinRK
bootstrap toolbar
r10889 icon : 'icon-play',
Matthias BUSSONNIER
space around :
r8210 callback : function () {
Brian E. Granger
Renaming execute methods.
r14085 IPython.notebook.execute_cell();
Matthias BUSSONNIER
jslint 1
r8209 }
Matthias BUSSONNIER
add maintoolbar file
r7833 },
{
Matthias BUSSONNIER
space around :
r8210 id : 'interrupt_b',
label : 'Interrupt',
MinRK
bootstrap toolbar
r10889 icon : 'icon-stop',
Matthias BUSSONNIER
space around :
r8210 callback : function () {
Zachary Sailer
fix restart/interrupt kernel buttons
r12994 IPython.notebook.session.interrupt_kernel();
Matthias BUSSONNIER
jslint 1
r8209 }
}
Matthias BUSSONNIER
add maintoolbar file
r7833 ],'run_int');
Matthias BUSSONNIER
jslint 1
r8209 };
Matthias BUSSONNIER
add maintoolbar file
r7833
Brian Granger
Decoupling the celltoolbar select UI from CellToolbar....
r9146 MainToolBar.prototype.add_celltype_list = function () {
this.element
Matthias BUSSONNIER
reorder methods and fix typo
r8212 .append($('<select/>')
.attr('id','cell_type')
MinRK
bootstrap toolbar
r10889 // .addClass('ui-widget-content')
Brian Granger
Decoupling the celltoolbar select UI from CellToolbar....
r9146 .append($('<option/>').attr('value','code').text('Code'))
.append($('<option/>').attr('value','markdown').text('Markdown'))
MinRK
add raw cell toolbar preset
r13671 .append($('<option/>').attr('value','raw').text('Raw NBConvert'))
Brian Granger
Decoupling the celltoolbar select UI from CellToolbar....
r9146 .append($('<option/>').attr('value','heading1').text('Heading 1'))
.append($('<option/>').attr('value','heading2').text('Heading 2'))
.append($('<option/>').attr('value','heading3').text('Heading 3'))
.append($('<option/>').attr('value','heading4').text('Heading 4'))
.append($('<option/>').attr('value','heading5').text('Heading 5'))
.append($('<option/>').attr('value','heading6').text('Heading 6'))
);
Matthias BUSSONNIER
reorder methods and fix typo
r8212 };
Brian Granger
Decoupling the celltoolbar select UI from CellToolbar....
r9146
MainToolBar.prototype.add_celltoolbar_list = function () {
MinRK
bootstrap toolbar
r10889 var label = $('<span/>').addClass("navbar-text").text('Cell Toolbar:');
Brian Granger
Decoupling the celltoolbar select UI from CellToolbar....
r9146 var select = $('<select/>')
MinRK
bootstrap toolbar
r10889 // .addClass('ui-widget-content')
Brian Granger
Decoupling the celltoolbar select UI from CellToolbar....
r9146 .attr('id', 'ctb_select')
.append($('<option/>').attr('value', '').text('None'));
this.element.append(label).append(select);
select.change(function() {
var val = $(this).val()
if (val =='') {
IPython.CellToolbar.global_hide();
MinRK
store cell toolbar preset in notebook metadata...
r13679 delete IPython.notebook.metadata.celltoolbar;
Brian Granger
Decoupling the celltoolbar select UI from CellToolbar....
r9146 } else {
IPython.CellToolbar.global_show();
IPython.CellToolbar.activate_preset(val);
MinRK
store cell toolbar preset in notebook metadata...
r13679 IPython.notebook.metadata.celltoolbar = val;
Brian Granger
Decoupling the celltoolbar select UI from CellToolbar....
r9146 }
});
// Setup the currently registered presets.
var presets = IPython.CellToolbar.list_presets();
for (var i=0; i<presets.length; i++) {
var name = presets[i];
select.append($('<option/>').attr('value', name).text(name));
}
// Setup future preset registrations.
$([IPython.events]).on('preset_added.CellToolbar', function (event, data) {
var name = data.name;
select.append($('<option/>').attr('value', name).text(name));
});
};
Matthias BUSSONNIER
add maintoolbar file
r7833 MainToolBar.prototype.bind_events = function () {
var that = this;
this.element.find('#cell_type').change(function () {
var cell_type = $(this).val();
if (cell_type === 'code') {
IPython.notebook.to_code();
} else if (cell_type === 'markdown') {
IPython.notebook.to_markdown();
} else if (cell_type === 'raw') {
IPython.notebook.to_raw();
} else if (cell_type === 'heading1') {
IPython.notebook.to_heading(undefined, 1);
} else if (cell_type === 'heading2') {
IPython.notebook.to_heading(undefined, 2);
} else if (cell_type === 'heading3') {
IPython.notebook.to_heading(undefined, 3);
} else if (cell_type === 'heading4') {
IPython.notebook.to_heading(undefined, 4);
} else if (cell_type === 'heading5') {
IPython.notebook.to_heading(undefined, 5);
} else if (cell_type === 'heading6') {
IPython.notebook.to_heading(undefined, 6);
Matthias BUSSONNIER
jslint 1
r8209 }
Matthias BUSSONNIER
add maintoolbar file
r7833 });
$([IPython.events]).on('selected_cell_type_changed.Notebook', function (event, data) {
if (data.cell_type === 'heading') {
that.element.find('#cell_type').val(data.cell_type+data.level);
} else {
that.element.find('#cell_type').val(data.cell_type);
}
});
};
IPython.MainToolBar = MainToolBar;
return IPython;
}(IPython));