From 76f500b3c30dc39bdf8f83f5c94a7ecd50ac65eb Mon Sep 17 00:00:00 2001 From: Brian Granger Date: Wed, 11 Jan 2012 21:33:38 -0800 Subject: [PATCH] Improving the save notification. * Added last saved with time/date display. * Reimplemented save widget status updates. --- .../html/notebook/static/js/notebook.js | 9 +++---- .../html/notebook/static/js/savewidget.js | 24 ++++++++++++++----- .../html/notebook/templates/notebook.html | 2 ++ 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js index a080fa12d..a65be89b0 100644 --- a/IPython/frontend/html/notebook/static/js/notebook.js +++ b/IPython/frontend/html/notebook/static/js/notebook.js @@ -973,15 +973,12 @@ var IPython = (function (IPython) { Notebook.prototype.notebook_saved = function (data, status, xhr) { this.dirty = false; IPython.save_widget.notebook_saved(); - IPython.save_widget.status_save(); + IPython.save_widget.status_last_saved(); }; Notebook.prototype.notebook_save_failed = function (xhr, status, error_msg) { - // Notify the user and reset the save button - // TODO: Handle different types of errors (timeout etc.) - alert('An unexpected error occured while saving the notebook.'); - IPython.save_widget.reset_status(); + IPython.save_widget.status_save_failed(); }; @@ -1013,7 +1010,7 @@ var IPython = (function (IPython) { if (this.ncells() === 0) { this.insert_code_cell_below(); }; - IPython.save_widget.status_save(); + IPython.save_widget.status_last_saved(); IPython.save_widget.set_notebook_name(data.metadata.name); this.dirty = false; if (! this.read_only) { diff --git a/IPython/frontend/html/notebook/static/js/savewidget.js b/IPython/frontend/html/notebook/static/js/savewidget.js index 7f8d5322b..9688a31de 100644 --- a/IPython/frontend/html/notebook/static/js/savewidget.js +++ b/IPython/frontend/html/notebook/static/js/savewidget.js @@ -28,6 +28,8 @@ var IPython = (function (IPython) { SaveWidget.prototype.style = function () { this.element.find('span#save_widget').addClass('ui-widget'); this.element.find('span#notebook_name').addClass('ui-widget ui-widget-content'); + this.element.find('span#save_status').addClass('ui-widget ui-widget-content') + .css({border: 'none', 'margin-left': '20px'}); }; @@ -137,24 +139,34 @@ var IPython = (function (IPython) { }; + SaveWidget.prototype.set_last_saved = function () { + var d = new Date(); + $('#save_status').html('Last saved: '+d.format('mmm dd h:MM TT')); + + }; + SaveWidget.prototype.reset_status = function () { - this.is_renaming(); + this.element.find('span#save_status').html(''); }; - SaveWidget.prototype.status_save = function () { + SaveWidget.prototype.status_last_saved = function () { + this.set_last_saved(); }; SaveWidget.prototype.status_saving = function () { + this.element.find('span#save_status').html('Saving...'); + }; + + + SaveWidget.prototype.status_save_failed = function () { + this.element.find('span#save_status').html('Save failed'); }; SaveWidget.prototype.status_loading = function () { - }; - - - SaveWidget.prototype.status_rename = function () { + this.element.find('span#save_status').html('Loading...'); }; diff --git a/IPython/frontend/html/notebook/templates/notebook.html b/IPython/frontend/html/notebook/templates/notebook.html index 161945cd1..f51ecece3 100644 --- a/IPython/frontend/html/notebook/templates/notebook.html +++ b/IPython/frontend/html/notebook/templates/notebook.html @@ -45,6 +45,7 @@

IPython Notebook

+ @@ -159,6 +160,7 @@ +