-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added javascript extension which is supposed to add sliders for numbe…
…rs in code blocks, but it is not yet working for some reason.
- Loading branch information
Tom Malone
committed
Oct 19, 2015
1 parent
d2146e0
commit 3c7f5ee
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); |