Skip to content

@Carreau /slideshow.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Slideshow mode of Notebook
<div id='presentation_mode'>
<style>
.pmode{ display: none !important }
</style>
<script>
grp=0;
pmode = function(){
init()
cells = $('.cell')
nbcells = IPython.notebook.get_cells();
$('div#notebook').addClass('pove');
clist = [];
var lgrp = [];
for(var i in nbcells) {
if (nbcells[i].code_mirror.getValue().match(/(\n)?(<!--|#)?====(-->)?(\n)?/) != null){
clist.push(lgrp)
lgrp = [i]
} else{
lgrp.push(i)
}
}
clist.push(lgrp)
$(cells).fadeOut(500);
ccell = 0;
ncellingrp = 0;
$(cells[clist[grp][0]]).fadeIn()
prev_grp = function(){
for(var i in clist[grp]){
$(cells).fadeOut()
}
grp = grp-1;
setTimeout(function(){$(cells[clist[grp][0]]).fadeIn()},800)
ccell = 0; //current cell
}
next_grp = function(){
for(var i in clist[grp]){
$(cells).fadeOut()
}
grp = grp +1;
var vcell = clist[grp] ;
if (vcell != undefined ){
setTimeout(function(){
$(cells[clist[grp][0]]).fadeIn()},800
)
} else {
setTimeout(function(){stop()},200);
}
ccell = 0; //current cell
console.log('ccel is ', ccell);
}
next_cell = function(){
ccell = ccell+1;
var vcell = cells[clist[grp][ccell]];
if ( vcell != undefined ){
$(vcell).fadeIn();
}else{
next_grp()
}
setTimeout(function(){IPython.layout_manager.do_resize();},1000);
}
nslide = function(){next_grp()}
pslide = function(){prev_grp()}
nstep = function(){next_cell()}
$('#menubar, #pager_splitter, #pager, #header,#toolbar').addClass('pmode');
};
var init = function()
{
var pt = $('<div/>').attr('id','toolbar_present').addClass('toolbar');
$('#toolbar').after(pt);
ptoolbar = new IPython.ToolBar('#toolbar_present');
IPython.ptoolbar = ptoolbar;
ptoolbar.addButtonsGroup([{label:'Next Slide', icon:'ui-icon-stop', callback:function(){stop()}}])
ptoolbar.addButtonsGroup([
{label:'Next Slide', icon:'ui-icon-seek-prev', callback:function(){pslide()}},
{label:'Next Slide', icon:'ui-icon-seek-next', callback:function(){nslide()}},
])
ptoolbar.addButtonsGroup([{label:'Step Next Cell', icon:'ui-icon-play', callback:function(){nstep()}}])
}
var stop = function() {
$(cells).show();
$(ptoolbar.selector).remove();
$('.pmode').removeClass('pmode');
$('div#notebook').removeClass('pove');
}
var sid = 'start_pmode'
if(($('#'+sid)).length == 0) {
IPython.toolbar.addButtonsGroup([
{'label':'Start Slideshow', 'icon':'ui-icon-image', 'callback':function(){pmode()},'id':sid},
])
}
</script>
</div>
@Carreau
Owner

e2032e seem to be working, improving when arriving at the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.