X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/8132fc186eb0c5fd02c86828c3a4735754296d02..5913c54d19b8f6775633176032161d49f9b2f1aa:/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 new file mode 100644 index 00000000..099a0e81 --- /dev/null +++ b/src/redakcja/static/js/wiki/view_summary.js @@ -0,0 +1,61 @@ +(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); + }; + + SummaryPerspective.prototype = new $.wiki.Perspective(); + + 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'); + } + }); + }; + + SummaryPerspective.prototype.showCharCount = function() { + var cc; + try { + cc = this.doc.getLength(); + $('#charcount_untagged').hide(); + } + catch (e) { + $('#charcount_untagged').show(); + cc = this.doc.text.replace(/\s{2,}/g, ' ').length; + } + $('#charcount').html(cc); + $('#charcount_pages').html((Math.round(cc/18)/100).toLocaleString()); + } + + 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; + +})(jQuery); +