X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/82b3920c64a77f00e2b38d8f0e1601cd74e427e4..9d566b4741eb66bf09b5c7d213aa8541886e100a:/src/redakcja/static/js/wiki/view_summary.js diff --git a/src/redakcja/static/js/wiki/view_summary.js b/src/redakcja/static/js/wiki/view_summary.js index 1bc3fb5d..171e9b72 100644 --- a/src/redakcja/static/js/wiki/view_summary.js +++ b/src/redakcja/static/js/wiki/view_summary.js @@ -1,69 +1,67 @@ (function($){ - function SummaryPerspective(options) { - var old_callback = options.callback || function() {}; + class SummaryPerspective extends $.wiki.Perspective { + constructor(options) { + var old_callback = options.callback || function() {}; - options.callback = function() { - var self = this; + options.callback = function() { + var self = this; - // first time page is rendered - $('#summary-cover-refresh').click(function() { - self.refreshCover(); - }); + // first time page is rendered + $('#summary-cover-refresh').click(function() { + self.refreshCover(); + }); - old_callback.call(this); - } + old_callback.call(this); + } - $.wiki.Perspective.call(this, options); - }; - - SummaryPerspective.prototype = new $.wiki.Perspective(); + super(options); + } - 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'); - } - }); - }; + 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.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()); + 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()); + 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()); + } } - 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.freezeState = function(){ - // must - }; + freezeState = function() { + // must + } - SummaryPerspective.prototype.onEnter = function(success, failure){ - $.wiki.Perspective.prototype.onEnter.call(this); - - this.showCharCount(); + onEnter(success, failure){ + super.onEnter(); - console.log("Entered summery view"); - }; + this.showCharCount(); - $.wiki.SummaryPerspective = SummaryPerspective; + console.log("Entered summery view"); + } + } + $.wiki.SummaryPerspective = SummaryPerspective; })(jQuery); -