-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipython-inlets.js
39 lines (32 loc) · 1.04 KB
/
ipython-inlets.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
console.info('iPython Inlets script loaded...');
;(function(IPython, $, require, element){
'use strict';
// this would be replaced with `nbextensions/inlet`
var url_base = '//enjalot.github.io/Inlet';
// add the style (for the slider)
$(element).append($('<style/>')
.text('@import url("' + url_base + '/inlet.css")'));
// at present, inlet exposes one global: `Inlet`
require.config({
paths: {inlet: url_base + '/inlet'},
shim: {inlet: {exports: 'Inlet'}}
});
require(["inlet", "underscore"], function(inlet, _){
$([IPython.events])
.on('edit_mode.Cell', function(evt, data){
var cell = data.cell,
cm = data.cell.code_mirror;
if(cm._inletted){ return; }
cm._inletted = true;
inlet(cm);
cm.on("change", _.debounce(
function(cm, delta){
if(!delta.origin && data.cell.execute){
data.cell.execute();
}
},
300
));
});
});
}).call(this, IPython, jQuery, require, element);