mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-21 04:10:17 +08:00
Improving the save notification.
* Added last saved with time/date display. * Reimplemented save widget status updates.
This commit is contained in:
parent
2a7666639c
commit
76f500b3c3
@ -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) {
|
||||
|
@ -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...');
|
||||
};
|
||||
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
<span id="ipython_notebook"><h1><a href='..' alt='dashboard'><img src='/static/ipynblogo.png' alt='IPython Notebook'/></a></h1></span>
|
||||
<span id="save_widget">
|
||||
<span id="notebook_name"></span>
|
||||
<span id="save_status"></span>
|
||||
</span>
|
||||
|
||||
<span id="login_widget">
|
||||
@ -159,6 +160,7 @@
|
||||
<script src="/static/pagedown/Markdown.Converter.js" charset="utf-8"></script>
|
||||
|
||||
<script src="/static/prettify/prettify.js" charset="utf-8"></script>
|
||||
<script src="/static/dateformat/date.format.js" charset="utf-8"></script>
|
||||
|
||||
<script src="/static/js/namespace.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="/static/js/utils.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user