##// END OF EJS Templates
clarify name of 'default' cell toolbar
MinRK -
Show More
@@ -1,46 +1,46
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2012 The IPython Development Team
2 // Copyright (C) 2012 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // CellToolbar Default
9 // CellToolbar Default
10 //============================================================================
10 //============================================================================
11
11
12 /**
12 /**
13 * Example Use for the CellToolbar library
13 * Example Use for the CellToolbar library
14 */
14 */
15 // IIFE without asignement, we don't modifiy the IPython namespace
15 // IIFE without asignement, we don't modifiy the IPython namespace
16 (function (IPython) {
16 (function (IPython) {
17 "use strict";
17 "use strict";
18
18
19 var CellToolbar = IPython.CellToolbar;
19 var CellToolbar = IPython.CellToolbar;
20
20
21 var raw_edit = function(cell){
21 var raw_edit = function(cell){
22 IPython.dialog.edit_metadata(cell.metadata, function (md) {
22 IPython.dialog.edit_metadata(cell.metadata, function (md) {
23 cell.metadata = md;
23 cell.metadata = md;
24 });
24 });
25 };
25 };
26
26
27 var add_raw_edit_button = function(div, cell) {
27 var add_raw_edit_button = function(div, cell) {
28 var button_container = div;
28 var button_container = div;
29 var button = $('<button/>')
29 var button = $('<button/>')
30 .addClass("btn btn-mini")
30 .addClass("btn btn-mini")
31 .text("Raw Edit")
31 .text("Edit Metadata")
32 .click( function () {
32 .click( function () {
33 raw_edit(cell);
33 raw_edit(cell);
34 return false;
34 return false;
35 });
35 });
36 button_container.append(button);
36 button_container.append(button);
37 };
37 };
38
38
39 CellToolbar.register_callback('default.rawedit', add_raw_edit_button);
39 CellToolbar.register_callback('default.rawedit', add_raw_edit_button);
40 var example_preset = [];
40 var example_preset = [];
41 example_preset.push('default.rawedit');
41 example_preset.push('default.rawedit');
42
42
43 CellToolbar.register_preset('Default', example_preset);
43 CellToolbar.register_preset('Edit Metadata', example_preset);
44 console.log('Default extension for metadata editing loaded.');
44 console.log('Default extension for cell metadata editing loaded.');
45
45
46 }(IPython));
46 }(IPython));
General Comments 0
You need to be logged in to leave comments. Login now