@@ -87,6 +87,8 @@ var IPython = (function (IPython) {
8787 this . element . find ( '#save_checkpoint' ) . click ( function ( ) {
8888 IPython . notebook . save_checkpoint ( ) ;
8989 } ) ;
90+ this . element . find ( '#restore_checkpoint' ) . click ( function ( ) {
91+ } ) ;
9092 this . element . find ( '#download_ipynb' ) . click ( function ( ) {
9193 var notebook_id = IPython . notebook . get_notebook_id ( ) ;
9294 var url = that . baseProjectUrl ( ) + 'notebooks/' +
@@ -221,8 +223,34 @@ var IPython = (function (IPython) {
221223 this . element . find ( '#keyboard_shortcuts' ) . click ( function ( ) {
222224 IPython . quick_help . show_keyboard_shortcuts ( ) ;
223225 } ) ;
226+
227+ this . update_restore_checkpoint ( null ) ;
228+
229+ $ ( [ IPython . events ] ) . on ( 'checkpoints_listed.Notebook' , function ( event , data ) {
230+ that . update_restore_checkpoint ( data ) ;
231+ } ) ;
232+
233+ $ ( [ IPython . events ] ) . on ( 'checkpoint_created.Notebook' , function ( event , data ) {
234+ that . update_restore_checkpoint ( data ) ;
235+ } ) ;
224236 } ;
225237
238+ MenuBar . prototype . update_restore_checkpoint = function ( checkpoint ) {
239+ if ( ! checkpoint ) {
240+ this . element . find ( "#restore_checkpoint" )
241+ . addClass ( 'ui-state-disabled' )
242+ . off ( 'click' )
243+ . find ( 'a' ) . text ( "Revert" ) ;
244+ return ;
245+ } ;
246+ var d = new Date ( checkpoint . last_modified ) ;
247+ this . element . find ( "#restore_checkpoint" )
248+ . removeClass ( 'ui-state-disabled' )
249+ . off ( 'click' )
250+ . click ( function ( ) {
251+ IPython . notebook . restore_checkpoint_dialog ( ) ;
252+ } ) . find ( 'a' ) . html ( "Revert to: <br/>" + d . format ( "mmm dd HH:MM:ss" ) ) ;
253+ }
226254
227255 IPython . MenuBar = MenuBar ;
228256
0 commit comments