move xml check to celery,
[redakcja.git] / redakcja / static / js / wiki / view_summary.js
1 (function($){
2
3         function SummaryPerspective(options) {
4                 var old_callback = options.callback;
5                 var self = this;
6
7         options.callback = function(){
8                         $('#publish_button').click(function() {
9                                 $.blockUI({message: "Oczekiwanie na odpowiedź serwera..."});
10                                 self.doc.publish({
11                                         success: function(doc, data) {
12                                                 $.blockUI({message: "Udało się.", timeout: 2000});
13                                         },
14                                         failure: function(doc, message) {
15                                                 $.blockUI({
16                                                         message: message,
17                                                         timeout: 5000
18                                                 });
19                                         }
20
21                                 });
22                         });
23
24                         old_callback.call(this);
25                 };
26
27                 $.wiki.Perspective.call(this, options);
28     };
29
30     SummaryPerspective.prototype = new $.wiki.Perspective();
31
32     SummaryPerspective.prototype.showCharCount = function() {
33         var cc;
34         try {
35             cc = this.doc.getLength();
36             $('#charcount_untagged').hide();
37         }
38         catch (e) {
39             $('#charcount_untagged').show();
40             cc = this.doc.text.replace(/\s{2,}/g, ' ').length;
41         }
42         $('#charcount').html(cc);
43         $('#charcount_pages').html((Math.round(cc/18)/100).toLocaleString());
44     }
45
46     SummaryPerspective.prototype.freezeState = function(){
47         // must
48     };
49
50         SummaryPerspective.prototype.onEnter = function(success, failure){
51                 $.wiki.Perspective.prototype.onEnter.call(this);
52                 
53                 this.showCharCount();
54
55                 console.log("Entered summery view");
56         };
57
58         $.wiki.SummaryPerspective = SummaryPerspective;
59
60 })(jQuery);
61