Show More
@@ -871,7 +871,8 b' var IPython = (function (IPython) {' | |||||
871 | type : "PUT", |
|
871 | type : "PUT", | |
872 | data : JSON.stringify(data), |
|
872 | data : JSON.stringify(data), | |
873 | headers : {'Content-Type': 'application/json'}, |
|
873 | headers : {'Content-Type': 'application/json'}, | |
874 | success : $.proxy(this.notebook_saved,this) |
|
874 | success : $.proxy(this.notebook_saved,this), | |
|
875 | error : $.proxy(this.notebook_save_failed,this) | |||
875 | }; |
|
876 | }; | |
876 | IPython.save_widget.status_saving(); |
|
877 | IPython.save_widget.status_saving(); | |
877 | $.ajax("/notebooks/" + notebook_id, settings); |
|
878 | $.ajax("/notebooks/" + notebook_id, settings); | |
@@ -881,10 +882,19 b' var IPython = (function (IPython) {' | |||||
881 |
|
882 | |||
882 | Notebook.prototype.notebook_saved = function (data, status, xhr) { |
|
883 | Notebook.prototype.notebook_saved = function (data, status, xhr) { | |
883 | this.dirty = false; |
|
884 | this.dirty = false; | |
|
885 | IPython.save_widget.notebook_saved(); | |||
884 | setTimeout($.proxy(IPython.save_widget.status_save,IPython.save_widget),500); |
|
886 | setTimeout($.proxy(IPython.save_widget.status_save,IPython.save_widget),500); | |
885 | } |
|
887 | } | |
886 |
|
888 | |||
887 |
|
889 | |||
|
890 | Notebook.prototype.notebook_save_failed = function (xhr, status, error_msg) { | |||
|
891 | // Notify the user and reset the save button | |||
|
892 | // TODO: Handle different types of errors (timeout etc.) | |||
|
893 | alert('An unexpected error occured while saving the notebook.'); | |||
|
894 | setTimeout($.proxy(IPython.save_widget.reset_status,IPython.save_widget),500); | |||
|
895 | } | |||
|
896 | ||||
|
897 | ||||
888 | Notebook.prototype.load_notebook = function (callback) { |
|
898 | Notebook.prototype.load_notebook = function (callback) { | |
889 | var that = this; |
|
899 | var that = this; | |
890 | var notebook_id = IPython.save_widget.get_notebook_id(); |
|
900 | var notebook_id = IPython.save_widget.get_notebook_id(); |
@@ -15,7 +15,7 b' var IPython = (function (IPython) {' | |||||
15 |
|
15 | |||
16 | var SaveWidget = function (selector) { |
|
16 | var SaveWidget = function (selector) { | |
17 | this.selector = selector; |
|
17 | this.selector = selector; | |
18 |
this.notebook_name_re = /[ |
|
18 | this.notebook_name_blacklist_re = /[\/\\]/ | |
19 | this.last_saved_name = ''; |
|
19 | this.last_saved_name = ''; | |
20 | if (this.selector !== undefined) { |
|
20 | if (this.selector !== undefined) { | |
21 | this.element = $(selector); |
|
21 | this.element = $(selector); | |
@@ -49,6 +49,10 b' var IPython = (function (IPython) {' | |||||
49 |
|
49 | |||
50 | SaveWidget.prototype.save_notebook = function () { |
|
50 | SaveWidget.prototype.save_notebook = function () { | |
51 | IPython.notebook.save_notebook(); |
|
51 | IPython.notebook.save_notebook(); | |
|
52 | }; | |||
|
53 | ||||
|
54 | ||||
|
55 | SaveWidget.prototype.notebook_saved = function () { | |||
52 | this.set_document_title(); |
|
56 | this.set_document_title(); | |
53 | this.last_saved_name = this.get_notebook_name(); |
|
57 | this.last_saved_name = this.get_notebook_name(); | |
54 | }; |
|
58 | }; | |
@@ -96,14 +100,14 b' var IPython = (function (IPython) {' | |||||
96 |
|
100 | |||
97 | SaveWidget.prototype.test_notebook_name = function () { |
|
101 | SaveWidget.prototype.test_notebook_name = function () { | |
98 | var nbname = this.get_notebook_name(); |
|
102 | var nbname = this.get_notebook_name(); | |
99 | if (this.notebook_name_re.test(nbname)) { |
|
103 | if (this.notebook_name_blacklist_re.test(nbname) == false) { | |
100 | return true; |
|
104 | return true; | |
101 | } else { |
|
105 | } else { | |
102 | var bad_name = $('<div/>'); |
|
106 | var bad_name = $('<div/>'); | |
103 | bad_name.html( |
|
107 | bad_name.html( | |
104 | "The notebook name you entered (" + |
|
108 | "The notebook name you entered (" + | |
105 | nbname + |
|
109 | nbname + | |
106 | ") is not valid. Notebook names can contain any characters except / and \\" |
|
110 | ") is not valid. Notebook names can contain any characters except / and \\." | |
107 | ); |
|
111 | ); | |
108 | bad_name.dialog({title: 'Invalid name', modal: true}); |
|
112 | bad_name.dialog({title: 'Invalid name', modal: true}); | |
109 | return false; |
|
113 | return false; | |
@@ -111,6 +115,11 b' var IPython = (function (IPython) {' | |||||
111 | }; |
|
115 | }; | |
112 |
|
116 | |||
113 |
|
117 | |||
|
118 | SaveWidget.prototype.reset_status = function () { | |||
|
119 | this.is_renaming(); | |||
|
120 | }; | |||
|
121 | ||||
|
122 | ||||
114 | SaveWidget.prototype.status_save = function () { |
|
123 | SaveWidget.prototype.status_save = function () { | |
115 | this.element.find('button#save_notebook').button('option', 'label', '<u>S</u>ave'); |
|
124 | this.element.find('button#save_notebook').button('option', 'label', '<u>S</u>ave'); | |
116 | this.element.find('button#save_notebook').button('enable'); |
|
125 | this.element.find('button#save_notebook').button('enable'); |
General Comments 0
You need to be logged in to leave comments.
Login now