Woblink
[redakcja.git] / src / redakcja / static / js / wiki / view_summary.js
index 1bc3fb5..bb65530 100644 (file)
@@ -1,69 +1,54 @@
 (function($){
 
-       function SummaryPerspective(options) {
-               var old_callback = options.callback || function() {};
-
-               options.callback = function() {
-                       var self = this;
-
-                       // first time page is rendered
-               $('#summary-cover-refresh').click(function() {
-                               self.refreshCover();
-                       });
-
-               old_callback.call(this);
-               }
-
-               $.wiki.Perspective.call(this, options);
-    };
+    class SummaryPerspective extends $.wiki.Perspective {
+        constructor(options) {
+            super(options);
+            var self = this;
+
+            // first time page is rendered
+            $('#summary-cover-refresh').click(function() {
+                self.refreshCover();
+            });
+        }
 
-    SummaryPerspective.prototype = new $.wiki.Perspective();
+        refreshCover() {
+            $('#summary-cover-refresh').attr('disabled', 'disabled');
+            this.doc.refreshCover({
+                success: function(text) {
+                    $('#summary-cover').attr('src', text);
+                    $('#summary-cover-refresh').removeAttr('disabled');
+                }
+            });
+        }
 
-       SummaryPerspective.prototype.refreshCover = function() {
-               $('#summary-cover-refresh').attr('disabled', 'disabled');
-               this.doc.refreshCover({
-                       success: function(text) {
-                               $('#summary-cover').attr('src', text);
-                       $('#summary-cover-refresh').removeAttr('disabled');
-                       }
-               });
-       };
+        showCharCount() {
+            var cc;
+            try {
+                $('#charcounts_text').show();
+                $('#charcounts_raw').hide();
+                cc = this.doc.getLength({noFootnotes: true, noThemes: true});
+                $('#charcount').html(cc);
+                $('#charcount_pages').html((Math.round(cc/18)/100).toLocaleString());
+
+                cc = this.doc.getLength();
+                $('#charcount_full').html(cc);
+                $('#charcount_full_pages').html((Math.round(cc/18)/100).toLocaleString());
+            }
+            catch (e) {
+                $('#charcounts_text').hide();
+                $('#charcounts_raw').show();
+                cc = this.doc.text.replace(/\s{2,}/g, ' ').length;
+                $('#charcount_raw').html(cc);
+                $('#charcount_raw_pages').html((Math.round(cc/18)/100).toLocaleString());
+            }
+        }
 
-    SummaryPerspective.prototype.showCharCount = function() {
-        var cc;
-        try {
-            $('#charcounts_text').show();
-            $('#charcounts_raw').hide();
-            cc = this.doc.getLength({noFootnotes: true, noThemes: true});
-            $('#charcount').html(cc);
-            $('#charcount_pages').html((Math.round(cc/18)/100).toLocaleString());
+        onEnter(success, failure){
+            super.onEnter();
 
-            cc = this.doc.getLength();
-            $('#charcount_full').html(cc);
-            $('#charcount_full_pages').html((Math.round(cc/18)/100).toLocaleString());
-        }
-        catch (e) {
-            $('#charcounts_text').hide();
-            $('#charcounts_raw').show();
-            cc = this.doc.text.replace(/\s{2,}/g, ' ').length;
-            $('#charcount_raw').html(cc);
-            $('#charcount_raw_pages').html((Math.round(cc/18)/100).toLocaleString());
+            this.showCharCount();
         }
     }
-
-    SummaryPerspective.prototype.freezeState = function(){
-        // must
-    };
-
-       SummaryPerspective.prototype.onEnter = function(success, failure){
-               $.wiki.Perspective.prototype.onEnter.call(this);
-               
-               this.showCharCount();
-
-               console.log("Entered summery view");
-       };
-
-       $.wiki.SummaryPerspective = SummaryPerspective;
+    $.wiki.SummaryPerspective = SummaryPerspective;
 
 })(jQuery);
-