827b26b20991e4fe26b444d3031c314f99eef91c
[redakcja.git] / platforma / static / js / wiki / save_dialog.js
1 /* 
2  * Dialog for saving document to the server
3  * 
4  */
5 (function($) {
6         
7         function SaveDialog(element) {
8                 $.wiki.cls.GenericDialog.call(this, element);
9                 this.ctx = $.wiki.exitContext();
10         };
11         
12         SaveDialog.prototype = new $.wiki.cls.GenericDialog();
13         
14         SaveDialog.prototype 
15         
16         SaveDialog.prototype.saveAction = function() {
17                         var self = this;                                
18                         
19                         self.$elem.block({
20                                 message: "Zapisywanie..."
21                         });
22                         
23                         try {
24                                 
25                                 CurrentDocument.save({
26                                         comment: $("#komentarz").text(),
27                                         success: function(doc, changed, info){
28                                                 self.$elem.block({
29                                                         message: info,
30                                                         timeout: 1000,
31                                                         fadeOut: 0, 
32                                                         onUnblock: function() {                                                                                                                 
33                                                                 self.hide();
34                                                         }
35                                                 });
36                                         },
37                                         failure: function(doc, info) {
38                                                 self.reportErrors(info);
39                                                 self.$elem.unblock();
40                                         }                                       
41                                 });
42                         } catch(e) {
43                                 console.log('Exception:', e)
44                                 self.$elem.unblock();
45                         }
46         }; /* end of save dialog */
47         
48         /* make it global */
49         $.wiki.cls.SaveDialog = SaveDialog;     
50 })(jQuery);