Skip to content

Commit

Permalink
Added javascript extension which is supposed to add sliders for numbe…
Browse files Browse the repository at this point in the history
…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.
39 changes: 39 additions & 0 deletions ipython-inlets.js
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);

0 comments on commit 3c7f5ee

Please sign in to comment.