@ -354,6 +354,41 @@ define([
NotebookList . prototype . load _list = function ( ) {
var that = this ;
// Add an event handler browser back and forward events
window . onpopstate = function ( e ) {
var path = window . history . state ? window . history . state . path : '' ;
that . update _location ( path ) ;
} ;
var breadcrumb = $ ( '.breadcrumb' ) ;
breadcrumb . empty ( ) ;
var list _item = $ ( '<li/>' ) ;
var root = $ ( '<li/>' ) . append ( '<a href="/tree"><i class="fa fa-folder"></i></a>' ) . click ( function ( e ) {
var path = '' ;
window . history . pushState ( {
path : path
} , 'Home' , utils . url _path _join ( that . base _url , 'tree' ) ) ;
that . update _location ( path ) ;
return false ;
} ) ;
breadcrumb . append ( root ) ;
var path _parts = [ ] ;
this . notebook _path . split ( '/' ) . forEach ( function ( path _part ) {
path _parts . push ( path _part )
var path = path _parts . join ( '/' )
var url = utils . url _path _join (
that . base _url ,
'/tree' ,
utils . encode _uri _components ( path )
) ;
var crumb = $ ( '<li/>' ) . append ( '<a href="' + url + '">' + path _part + '</a>' ) . click ( function ( e ) {
window . history . pushState ( {
path : path
} , path , url ) ;
that . update _location ( path ) ;
return false ;
} ) ;
breadcrumb . append ( crumb ) ;
} ) ;
this . contents . list _contents ( that . notebook _path ) . then (
$ . proxy ( this . draw _notebook _list , this ) ,
function ( error ) {
@ -361,6 +396,12 @@ define([
}
) ;
} ;
NotebookList . prototype . update _location = function ( path ) {
this . notebook _path = path ;
// Update the file tree list without reloading the page
this . load _list ( ) ;
} ;
/ * *
* Draw the list of notebooks
@ -723,6 +764,7 @@ define([
} ;
NotebookList . prototype . add _link = function ( model , item ) {
var that = this ;
var running = ( model . type === 'notebook' && this . sessions [ model . path ] !== undefined ) ;
item . data ( 'name' , model . name ) ;
item . data ( 'path' , model . path ) ;
@ -762,7 +804,21 @@ define([
// directory nav doesn't open new tabs
// files, notebooks do
if ( model . type !== "directory" ) {
link . attr ( 'target' , IPython . _target ) ;
link . attr ( 'target' , IPython . _target ) ;
} else {
// Replace with a click handler that will use the History API to
// push a new route without reloading the page
link . click ( function ( e ) {
window . history . pushState ( {
path : model . path
} , model . path , utils . url _path _join (
that . base _url ,
'tree' ,
utils . encode _uri _components ( model . path )
) ) ;
that . update _location ( model . path ) ;
return false ;
} ) ;
}
// Add in the date that the file was last modified