##// END OF EJS Templates
restore checkpoints in a sub-list...
MinRK -
Show More
@@ -943,6 +943,7 b' a.heading-anchor:link,a.heading-anchor:visited{text-decoration:none;color:inheri'
943 div.raw_input{padding-top:0px;padding-bottom:0px;height:1em;line-height:1em;font-family:monospace;}
943 div.raw_input{padding-top:0px;padding-bottom:0px;height:1em;line-height:1em;font-family:monospace;}
944 span.input_prompt{font-family:inherit;}
944 span.input_prompt{font-family:inherit;}
945 input.raw_input{font-family:inherit;font-size:inherit;color:inherit;width:auto;margin:-2px 0px 0px 1px;padding-left:1px;padding-top:2px;height:1em;}
945 input.raw_input{font-family:inherit;font-size:inherit;color:inherit;width:auto;margin:-2px 0px 0px 1px;padding-left:1px;padding-top:2px;height:1em;}
946 p.p-space{margin-bottom:10px;}
946 .rendered_html{color:black;}.rendered_html em{font-style:italic;}
947 .rendered_html{color:black;}.rendered_html em{font-style:italic;}
947 .rendered_html strong{font-weight:bold;}
948 .rendered_html strong{font-weight:bold;}
948 .rendered_html u{text-decoration:underline;}
949 .rendered_html u{text-decoration:underline;}
@@ -60,6 +60,7 b' var IPython = (function (IPython) {'
60 IPython.notebook.select(i);
60 IPython.notebook.select(i);
61 }
61 }
62 });
62 });
63 this.element.find("#restore_checkpoint").find("ul").find("li").hide();
63 };
64 };
64
65
65
66
@@ -228,26 +229,33 b' var IPython = (function (IPython) {'
228 });
229 });
229
230
230 $([IPython.events]).on('checkpoint_created.Notebook', function (event, data) {
231 $([IPython.events]).on('checkpoint_created.Notebook', function (event, data) {
231 that.update_restore_checkpoint(data);
232 that.update_restore_checkpoint([data]);
232 });
233 });
233 };
234 };
234
235
235 MenuBar.prototype.update_restore_checkpoint = function(checkpoint) {
236 MenuBar.prototype.update_restore_checkpoint = function(checkpoints) {
236 if (!checkpoint) {
237 if (! checkpoints) {
237 this.element.find("#restore_checkpoint")
238 checkpoints = [];
238 .addClass('ui-state-disabled')
239 .off('click')
240 .find('a').text("Revert");
241 return;
242 };
239 };
243 var d = new Date(checkpoint.last_modified);
240 this.element.find("#restore_checkpoint").find("ul").find("li").each(function(i) {
244 this.element.find("#restore_checkpoint")
241 var li = $(this);
245 .removeClass('ui-state-disabled')
242 var a = li.find("a");
246 .off('click')
243 a.off("click");
247 .click(function () {
244 if (checkpoints.length <= i) {
248 IPython.notebook.restore_checkpoint_dialog();
245 li.hide();
249 }).find('a').html("Revert to: <br/>" + d.format("mmm dd HH:MM:ss"));
246 return;
250 }
247 } else {
248 li.show();
249 };
250 var checkpoint = checkpoints[i];
251 var d = new Date(checkpoint.last_modified);
252 li.find('a').text(
253 d.format("mmm dd HH:MM:ss")
254 ).click(function () {
255 IPython.notebook.restore_checkpoint_dialog(checkpoint);
256 });
257 });
258 };
251
259
252 IPython.MenuBar = MenuBar;
260 IPython.MenuBar = MenuBar;
253
261
@@ -1839,7 +1839,7 b' var IPython = (function (IPython) {'
1839 } else {
1839 } else {
1840 this.last_checkpoint = null;
1840 this.last_checkpoint = null;
1841 }
1841 }
1842 $([IPython.events]).trigger('checkpoints_listed.Notebook', data);
1842 $([IPython.events]).trigger('checkpoints_listed.Notebook', [data]);
1843 };
1843 };
1844
1844
1845 /**
1845 /**
@@ -1894,15 +1894,16 b' var IPython = (function (IPython) {'
1894 $([IPython.events]).trigger('checkpoint_failed.Notebook');
1894 $([IPython.events]).trigger('checkpoint_failed.Notebook');
1895 };
1895 };
1896
1896
1897 Notebook.prototype.restore_checkpoint_dialog = function () {
1897 Notebook.prototype.restore_checkpoint_dialog = function (checkpoint) {
1898 var that = this;
1898 var that = this;
1899 var checkpoint = this.last_checkpoint;
1899 var checkpoint = checkpoint || this.last_checkpoint;
1900 if ( ! checkpoint ) {
1900 if ( ! checkpoint ) {
1901 console.log("restore dialog, but no checkpoint to restore to!");
1901 console.log("restore dialog, but no checkpoint to restore to!");
1902 return;
1902 return;
1903 }
1903 }
1904 var dialog = $('<div/>').append(
1904 var dialog = $('<div/>').append(
1905 $('<p/>').text("Are you sure you want to revert the notebook to " +
1905 $('<p/>').addClass("p-space").text(
1906 "Are you sure you want to revert the notebook to " +
1906 "the latest checkpoint?"
1907 "the latest checkpoint?"
1907 ).append(
1908 ).append(
1908 $("<strong/>").text(
1909 $("<strong/>").text(
@@ -1910,9 +1911,11 b' var IPython = (function (IPython) {'
1910 )
1911 )
1911 )
1912 )
1912 ).append(
1913 ).append(
1913 $('<p/>').text("The checkpoint was last updated at")
1914 $('<p/>').addClass("p-space").text("The checkpoint was last updated at:")
1914 ).append(
1915 ).append(
1915 $('<p/>').text(Date(checkpoint.last_modified))
1916 $('<p/>').addClass("p-space").text(
1917 Date(checkpoint.last_modified)
1918 ).css("text-align", "center")
1916 );
1919 );
1917
1920
1918 $(document).append(dialog);
1921 $(document).append(dialog);
@@ -57,7 +57,7 b' var IPython = (function (IPython) {'
57 that.set_save_status('Last Save Failed!');
57 that.set_save_status('Last Save Failed!');
58 });
58 });
59 $([IPython.events]).on('checkpoints_listed.Notebook', function (event, data) {
59 $([IPython.events]).on('checkpoints_listed.Notebook', function (event, data) {
60 that.set_last_checkpoint(data);
60 that.set_last_checkpoint(data[0]);
61 });
61 });
62
62
63 $([IPython.events]).on('checkpoint_created.Notebook', function (event, data) {
63 $([IPython.events]).on('checkpoint_created.Notebook', function (event, data) {
@@ -507,3 +507,7 b' input.raw_input {'
507 height: 1em;
507 height: 1em;
508 }
508 }
509
509
510 p.p-space {
511 margin-bottom: 10px;
512 }
513
@@ -59,7 +59,15 b' class="notebook_app"'
59 <li id="rename_notebook"><a href="#">Rename...</a></li>
59 <li id="rename_notebook"><a href="#">Rename...</a></li>
60 <li id="save_checkpoint"><a href="#">Save and Checkpoint</a></li>
60 <li id="save_checkpoint"><a href="#">Save and Checkpoint</a></li>
61 <hr/>
61 <hr/>
62 <li id="restore_checkpoint"><a href="#">Revert to Checkpoint</a></li>
62 <li id="restore_checkpoint"><a href="#">Revert to Checkpoint</a>
63 <ul>
64 <li><a href="#"></a></li>
65 <li><a href="#"></a></li>
66 <li><a href="#"></a></li>
67 <li><a href="#"></a></li>
68 <li><a href="#"></a></li>
69 </ul>
70 </li>
63 <hr/>
71 <hr/>
64 <li><a href="#">Download as</a>
72 <li><a href="#">Download as</a>
65 <ul>
73 <ul>
General Comments 0
You need to be logged in to leave comments. Login now