Librarian in regular requirements.
[redakcja.git] / redakcja / static / js / wiki / dialog_pubmark.js
1 /*
2  * Dialog for marking document for publishing
3  *
4  */
5 (function($){
6
7     function PubmarkDialog(element, options){
8         if (!options.revision  && options.revision != 0)
9             throw "PubmarkDialog needs a revision number.";
10
11         this.ctx = $.wiki.exitContext();
12         this.clearForm();
13
14         /* fill out hidden fields */
15         this.$form = $('form', element);
16
17         $("input[name='pubmark-id']", this.$form).val(CurrentDocument.id);
18         $("input[name='pubmark-revision']", this.$form).val(options.revision);
19
20         $.wiki.cls.GenericDialog.call(this, element);
21     };
22
23     PubmarkDialog.prototype = $.extend(new $.wiki.cls.GenericDialog(), {
24         cancelAction: function(){
25             $.wiki.enterContext(this.ctx);
26             this.hide();
27         },
28
29         saveAction: function(){
30             var self = this;
31
32             self.$elem.block({
33                 message: "Oznaczanie wersji",
34                 fadeIn: 0,
35             });
36
37             CurrentDocument.pubmark({
38                 form: self.$form,
39                 success: function(doc, changed, info){
40                     self.$elem.block({
41                         message: info,
42                         timeout: 2000,
43                         fadeOut: 0,
44                         onUnblock: function(){
45                             self.hide();
46                             $.wiki.enterContext(self.ctx);
47                         }
48                     });
49                 },
50                 failure: function(doc, info){
51                     console.log("Failure", info);
52                     self.reportErrors(info);
53                     self.$elem.unblock();
54                 }
55             });
56         }
57     });
58
59     /* make it global */
60     $.wiki.cls.PubmarkDialog = PubmarkDialog;
61 })(jQuery);