From 40b882906fadaaaf4001be9c8d22547261d74436 Mon Sep 17 00:00:00 2001 From: MinRK Date: Tue, 2 Jul 2013 10:38:05 -0700 Subject: [PATCH 1/2] add 'No Checkpoints' to Revert menu when there are None, rather than an empty menu. closes #3261 --- IPython/html/static/notebook/js/menubar.js | 44 +++++++++++++--------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/IPython/html/static/notebook/js/menubar.js b/IPython/html/static/notebook/js/menubar.js index 0d9715e3e..dc46db70b 100644 --- a/IPython/html/static/notebook/js/menubar.js +++ b/IPython/html/static/notebook/js/menubar.js @@ -233,27 +233,35 @@ var IPython = (function (IPython) { }; MenuBar.prototype.update_restore_checkpoint = function(checkpoints) { - if (! checkpoints) { - checkpoints = []; + var ul = this.element.find("#restore_checkpoint").find("ul"); + ul.empty(); + if (! checkpoints || checkpoints.length == 0) { + ul.append( + $("
  • ") + .addClass("disabled") + .append( + $("") + .attr("href", "#") + .text("No checkpoints") + ) + ); + return; }; - this.element.find("#restore_checkpoint").find("ul").find("li").each(function(i) { - var li = $(this); - var a = li.find("a"); - a.off("click"); - if (checkpoints.length <= i) { - li.hide(); - return; - } else { - li.show(); - }; + console.log("checkpoints!", checkpoints); + for (var i = 0; i < checkpoints.length; i++) { var checkpoint = checkpoints[i]; var d = new Date(checkpoint.last_modified); - li.find('a').text( - d.format("mmm dd HH:MM:ss") - ).click(function () { - IPython.notebook.restore_checkpoint_dialog(checkpoint); - }); - }); + ul.append( + $("
  • ").append( + $("") + .attr("href", "#") + .text(d.format("mmm dd HH:MM:ss")) + .click(function () { + IPython.notebook.restore_checkpoint_dialog(checkpoint); + }) + ) + ); + }; }; IPython.MenuBar = MenuBar; From 09567f835b76c5a1980832a37266e0ebf449ab72 Mon Sep 17 00:00:00 2001 From: MinRK Date: Thu, 4 Jul 2013 08:58:43 -0700 Subject: [PATCH 2/2] remove debug statement and anchor --- IPython/html/static/notebook/js/menubar.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/IPython/html/static/notebook/js/menubar.js b/IPython/html/static/notebook/js/menubar.js index dc46db70b..985de1e76 100644 --- a/IPython/html/static/notebook/js/menubar.js +++ b/IPython/html/static/notebook/js/menubar.js @@ -241,13 +241,12 @@ var IPython = (function (IPython) { .addClass("disabled") .append( $("") - .attr("href", "#") .text("No checkpoints") ) ); return; }; - console.log("checkpoints!", checkpoints); + for (var i = 0; i < checkpoints.length; i++) { var checkpoint = checkpoints[i]; var d = new Date(checkpoint.last_modified);