More javascript refactoring.
[redakcja.git] / platforma / static / js / wiki / save_dialog.js
diff --git a/platforma/static/js/wiki/save_dialog.js b/platforma/static/js/wiki/save_dialog.js
new file mode 100644 (file)
index 0000000..827b26b
--- /dev/null
@@ -0,0 +1,50 @@
+/* 
+ * Dialog for saving document to the server
+ * 
+ */
+(function($) {
+       
+       function SaveDialog(element) {
+               $.wiki.cls.GenericDialog.call(this, element);
+               this.ctx = $.wiki.exitContext();
+       };
+       
+       SaveDialog.prototype = new $.wiki.cls.GenericDialog();
+       
+       SaveDialog.prototype 
+       
+       SaveDialog.prototype.saveAction = function() {
+                       var self = this;                                
+                       
+                       self.$elem.block({
+                               message: "Zapisywanie..."
+                       });
+                       
+                       try {
+                               
+                               CurrentDocument.save({
+                                       comment: $("#komentarz").text(),
+                                       success: function(doc, changed, info){
+                                               self.$elem.block({
+                                                       message: info,
+                                                       timeout: 1000,
+                                                       fadeOut: 0, 
+                                                       onUnblock: function() {                                                                                                                 
+                                                               self.hide();
+                                                       }
+                                               });
+                                       },
+                                       failure: function(doc, info) {
+                                               self.reportErrors(info);
+                                               self.$elem.unblock();
+                                       }                                       
+                               });
+                       } catch(e) {
+                               console.log('Exception:', e)
+                               self.$elem.unblock();
+                       }
+       }; /* end of save dialog */
+       
+       /* make it global */
+       $.wiki.cls.SaveDialog = SaveDialog;     
+})(jQuery);