Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50654 views
1
//----------------------------------------------------------------------------
2
// Copyright (C) 2012 The IPython Development Team
3
//
4
// Distributed under the terms of the BSD License. The full license is in
5
// the file COPYING, distributed as part of this software.
6
//----------------------------------------------------------------------------
7
8
//============================================================================
9
// CellToolbar Default
10
//============================================================================
11
12
/**
13
* Example Use for the CellToolbar library
14
*/
15
// IIFE without asignement, we don't modifiy the IPython namespace
16
(function (IPython) {
17
"use strict";
18
19
var CellToolbar = IPython.CellToolbar;
20
21
var raw_edit = function(cell){
22
IPython.dialog.edit_metadata(cell.metadata, function (md) {
23
cell.metadata = md;
24
});
25
};
26
27
var add_raw_edit_button = function(div, cell) {
28
var button_container = div;
29
var button = $('<button/>')
30
.addClass("btn btn-mini")
31
.text("Edit Metadata")
32
.click( function () {
33
raw_edit(cell);
34
return false;
35
});
36
button_container.append(button);
37
};
38
39
CellToolbar.register_callback('default.rawedit', add_raw_edit_button);
40
var example_preset = [];
41
example_preset.push('default.rawedit');
42
43
CellToolbar.register_preset('Edit Metadata', example_preset);
44
console.log('Default extension for cell metadata editing loaded.');
45
46
}(IPython));
47
48